From 7cedbff88d8ad206ed19e3adfa675ec348b7f265 Mon Sep 17 00:00:00 2001 From: Fabian Guerra Date: Mon, 6 Mar 2017 16:28:48 -0800 Subject: [ios, macos] added transition properties test --- platform/darwin/src/MGLBackgroundStyleLayer.mm | 2 +- platform/darwin/src/MGLCircleStyleLayer.mm | 2 +- platform/darwin/src/MGLFillStyleLayer.mm | 2 +- platform/darwin/src/MGLLineStyleLayer.mm | 2 +- platform/darwin/src/MGLRasterStyleLayer.mm | 2 +- platform/darwin/src/MGLStyleLayer.h | 2 +- platform/darwin/src/MGLStyleLayer.mm | 4 +++- platform/darwin/src/MGLStyleLayer.mm.ejs | 2 +- platform/darwin/src/MGLSymbolStyleLayer.mm | 2 +- platform/darwin/test/MGLBackgroundStyleLayerTests.mm | 10 ++++++++++ platform/darwin/test/MGLCircleStyleLayerTests.mm | 10 ++++++++++ platform/darwin/test/MGLFillStyleLayerTests.mm | 10 ++++++++++ platform/darwin/test/MGLLineStyleLayerTests.mm | 10 ++++++++++ platform/darwin/test/MGLRasterStyleLayerTests.mm | 10 ++++++++++ platform/darwin/test/MGLStyleLayerTests.mm.ejs | 10 ++++++++++ platform/darwin/test/MGLSymbolStyleLayerTests.mm | 10 ++++++++++ 16 files changed, 81 insertions(+), 9 deletions(-) diff --git a/platform/darwin/src/MGLBackgroundStyleLayer.mm b/platform/darwin/src/MGLBackgroundStyleLayer.mm index 84218aefe7..73d0011d87 100644 --- a/platform/darwin/src/MGLBackgroundStyleLayer.mm +++ b/platform/darwin/src/MGLBackgroundStyleLayer.mm @@ -85,7 +85,7 @@ #pragma mark - Accessing the Paint Attributes -- (NSArray *)transitionKeys ++ (NSArray *)transitionKeys { NSMutableArray *transitionKeys = [NSMutableArray array]; [transitionKeys addObject:@"backgroundColor"]; diff --git a/platform/darwin/src/MGLCircleStyleLayer.mm b/platform/darwin/src/MGLCircleStyleLayer.mm index f8e469a1ed..0fa9ec4f78 100644 --- a/platform/darwin/src/MGLCircleStyleLayer.mm +++ b/platform/darwin/src/MGLCircleStyleLayer.mm @@ -135,7 +135,7 @@ namespace mbgl { #pragma mark - Accessing the Paint Attributes -- (NSArray *)transitionKeys ++ (NSArray *)transitionKeys { NSMutableArray *transitionKeys = [NSMutableArray array]; [transitionKeys addObject:@"circleBlur"]; diff --git a/platform/darwin/src/MGLFillStyleLayer.mm b/platform/darwin/src/MGLFillStyleLayer.mm index 64d1792160..3e84f36f7c 100644 --- a/platform/darwin/src/MGLFillStyleLayer.mm +++ b/platform/darwin/src/MGLFillStyleLayer.mm @@ -130,7 +130,7 @@ namespace mbgl { #pragma mark - Accessing the Paint Attributes -- (NSArray *)transitionKeys ++ (NSArray *)transitionKeys { NSMutableArray *transitionKeys = [NSMutableArray array]; [transitionKeys addObject:@"fillAntialiased"]; diff --git a/platform/darwin/src/MGLLineStyleLayer.mm b/platform/darwin/src/MGLLineStyleLayer.mm index 52259a1bff..6c022b5fa3 100644 --- a/platform/darwin/src/MGLLineStyleLayer.mm +++ b/platform/darwin/src/MGLLineStyleLayer.mm @@ -212,7 +212,7 @@ namespace mbgl { #pragma mark - Accessing the Paint Attributes -- (NSArray *)transitionKeys ++ (NSArray *)transitionKeys { NSMutableArray *transitionKeys = [NSMutableArray array]; [transitionKeys addObject:@"lineBlur"]; diff --git a/platform/darwin/src/MGLRasterStyleLayer.mm b/platform/darwin/src/MGLRasterStyleLayer.mm index 6c5102d83c..b16a5561f7 100644 --- a/platform/darwin/src/MGLRasterStyleLayer.mm +++ b/platform/darwin/src/MGLRasterStyleLayer.mm @@ -92,7 +92,7 @@ #pragma mark - Accessing the Paint Attributes -- (NSArray *)transitionKeys ++ (NSArray *)transitionKeys { NSMutableArray *transitionKeys = [NSMutableArray array]; [transitionKeys addObject:@"maximumRasterBrightness"]; diff --git a/platform/darwin/src/MGLStyleLayer.h b/platform/darwin/src/MGLStyleLayer.h index 2f1a777455..b1cdd78002 100644 --- a/platform/darwin/src/MGLStyleLayer.h +++ b/platform/darwin/src/MGLStyleLayer.h @@ -78,7 +78,7 @@ MGL_EXPORT /** Returns an array of strings that identify transition keys attached to the layer. */ -- (NSArray *)transitionKeys; ++ (NSArray *)transitionKeys; @end diff --git a/platform/darwin/src/MGLStyleLayer.mm b/platform/darwin/src/MGLStyleLayer.mm index d307270799..87f6c18f33 100644 --- a/platform/darwin/src/MGLStyleLayer.mm +++ b/platform/darwin/src/MGLStyleLayer.mm @@ -109,9 +109,11 @@ return propertyTransitionSelector; } -- (NSArray *)transitionKeys ++ (NSArray *)transitionKeys { // This is overridden by subclasses + [NSException raise:@"MGLAbstractClassException" + format:@"MGLStyleLayer is an abstract class"]; return nil; } diff --git a/platform/darwin/src/MGLStyleLayer.mm.ejs b/platform/darwin/src/MGLStyleLayer.mm.ejs index 274a62ac10..50194785ae 100644 --- a/platform/darwin/src/MGLStyleLayer.mm.ejs +++ b/platform/darwin/src/MGLStyleLayer.mm.ejs @@ -230,7 +230,7 @@ namespace mbgl { <% if (paintProperties.length) { -%> #pragma mark - Accessing the Paint Attributes -- (NSArray *)transitionKeys ++ (NSArray *)transitionKeys { NSMutableArray *transitionKeys = [NSMutableArray array]; <% for (const property of paintProperties) { -%> diff --git a/platform/darwin/src/MGLSymbolStyleLayer.mm b/platform/darwin/src/MGLSymbolStyleLayer.mm index 7b4ce2422f..c4259ba6be 100644 --- a/platform/darwin/src/MGLSymbolStyleLayer.mm +++ b/platform/darwin/src/MGLSymbolStyleLayer.mm @@ -888,7 +888,7 @@ namespace mbgl { #pragma mark - Accessing the Paint Attributes -- (NSArray *)transitionKeys ++ (NSArray *)transitionKeys { NSMutableArray *transitionKeys = [NSMutableArray array]; [transitionKeys addObject:@"iconColor"]; diff --git a/platform/darwin/test/MGLBackgroundStyleLayerTests.mm b/platform/darwin/test/MGLBackgroundStyleLayerTests.mm index 92c0ac7cbc..97ddefe7dc 100644 --- a/platform/darwin/test/MGLBackgroundStyleLayerTests.mm +++ b/platform/darwin/test/MGLBackgroundStyleLayerTests.mm @@ -22,6 +22,16 @@ XCTAssertTrue(layer.rawLayer->is()); auto rawLayer = layer.rawLayer->as(); + NSArray *transitionKeys = [MGLBackgroundStyleLayer transitionKeys]; + MGLTransition transitionTest = {.delay = 4, .duration = 5}; + + for (NSString *property in transitionKeys) { + [layer setTransition:transitionTest forKey:property]; + MGLTransition transition = [layer transitionForKey:property]; + XCTAssertEqual(transition.delay, transitionTest.delay); + XCTAssertEqual(transition.duration, transitionTest.duration); + } + // background-color { XCTAssertTrue(rawLayer->getBackgroundColor().isUndefined(), diff --git a/platform/darwin/test/MGLCircleStyleLayerTests.mm b/platform/darwin/test/MGLCircleStyleLayerTests.mm index d7515e8e4e..7754e81766 100644 --- a/platform/darwin/test/MGLCircleStyleLayerTests.mm +++ b/platform/darwin/test/MGLCircleStyleLayerTests.mm @@ -43,6 +43,16 @@ XCTAssertTrue(layer.rawLayer->is()); auto rawLayer = layer.rawLayer->as(); + NSArray *transitionKeys = [MGLCircleStyleLayer transitionKeys]; + MGLTransition transitionTest = {.delay = 4, .duration = 5}; + + for (NSString *property in transitionKeys) { + [layer setTransition:transitionTest forKey:property]; + MGLTransition transition = [layer transitionForKey:property]; + XCTAssertEqual(transition.delay, transitionTest.delay); + XCTAssertEqual(transition.duration, transitionTest.duration); + } + // circle-blur { XCTAssertTrue(rawLayer->getCircleBlur().isUndefined(), diff --git a/platform/darwin/test/MGLFillStyleLayerTests.mm b/platform/darwin/test/MGLFillStyleLayerTests.mm index c03b22c399..8587c4f1d1 100644 --- a/platform/darwin/test/MGLFillStyleLayerTests.mm +++ b/platform/darwin/test/MGLFillStyleLayerTests.mm @@ -43,6 +43,16 @@ XCTAssertTrue(layer.rawLayer->is()); auto rawLayer = layer.rawLayer->as(); + NSArray *transitionKeys = [MGLFillStyleLayer transitionKeys]; + MGLTransition transitionTest = {.delay = 4, .duration = 5}; + + for (NSString *property in transitionKeys) { + [layer setTransition:transitionTest forKey:property]; + MGLTransition transition = [layer transitionForKey:property]; + XCTAssertEqual(transition.delay, transitionTest.delay); + XCTAssertEqual(transition.duration, transitionTest.duration); + } + // fill-antialias { XCTAssertTrue(rawLayer->getFillAntialias().isUndefined(), diff --git a/platform/darwin/test/MGLLineStyleLayerTests.mm b/platform/darwin/test/MGLLineStyleLayerTests.mm index 95c3e434c0..168d927aef 100644 --- a/platform/darwin/test/MGLLineStyleLayerTests.mm +++ b/platform/darwin/test/MGLLineStyleLayerTests.mm @@ -43,6 +43,16 @@ XCTAssertTrue(layer.rawLayer->is()); auto rawLayer = layer.rawLayer->as(); + NSArray *transitionKeys = [MGLLineStyleLayer transitionKeys]; + MGLTransition transitionTest = {.delay = 4, .duration = 5}; + + for (NSString *property in transitionKeys) { + [layer setTransition:transitionTest forKey:property]; + MGLTransition transition = [layer transitionForKey:property]; + XCTAssertEqual(transition.delay, transitionTest.delay); + XCTAssertEqual(transition.duration, transitionTest.duration); + } + // line-cap { XCTAssertTrue(rawLayer->getLineCap().isUndefined(), diff --git a/platform/darwin/test/MGLRasterStyleLayerTests.mm b/platform/darwin/test/MGLRasterStyleLayerTests.mm index b7a764e6c2..9f5422d098 100644 --- a/platform/darwin/test/MGLRasterStyleLayerTests.mm +++ b/platform/darwin/test/MGLRasterStyleLayerTests.mm @@ -25,6 +25,16 @@ XCTAssertTrue(layer.rawLayer->is()); auto rawLayer = layer.rawLayer->as(); + NSArray *transitionKeys = [MGLRasterStyleLayer transitionKeys]; + MGLTransition transitionTest = {.delay = 4, .duration = 5}; + + for (NSString *property in transitionKeys) { + [layer setTransition:transitionTest forKey:property]; + MGLTransition transition = [layer transitionForKey:property]; + XCTAssertEqual(transition.delay, transitionTest.delay); + XCTAssertEqual(transition.duration, transitionTest.duration); + } + // raster-brightness-max { XCTAssertTrue(rawLayer->getRasterBrightnessMax().isUndefined(), diff --git a/platform/darwin/test/MGLStyleLayerTests.mm.ejs b/platform/darwin/test/MGLStyleLayerTests.mm.ejs index 810d7fbd3b..77d02b6a39 100644 --- a/platform/darwin/test/MGLStyleLayerTests.mm.ejs +++ b/platform/darwin/test/MGLStyleLayerTests.mm.ejs @@ -53,6 +53,16 @@ XCTAssertNotEqual(layer.rawLayer, nullptr); XCTAssertTrue(layer.rawLayer->isLayer>()); auto rawLayer = layer.rawLayer->asLayer>(); + + NSArray *transitionKeys = [MGL<%- camelize(type) %>StyleLayer transitionKeys]; + MGLTransition transitionTest = {.delay = 4, .duration = 5}; + + for (NSString *property in transitionKeys) { + [layer setTransition:transitionTest forKey:property]; + MGLTransition transition = [layer transitionForKey:property]; + XCTAssertEqual(transition.delay, transitionTest.delay); + XCTAssertEqual(transition.duration, transitionTest.duration); + } <% for (const property of properties) { -%> // <%- originalPropertyName(property) %> diff --git a/platform/darwin/test/MGLSymbolStyleLayerTests.mm b/platform/darwin/test/MGLSymbolStyleLayerTests.mm index 1d599f5aca..bb5be776b0 100644 --- a/platform/darwin/test/MGLSymbolStyleLayerTests.mm +++ b/platform/darwin/test/MGLSymbolStyleLayerTests.mm @@ -43,6 +43,16 @@ XCTAssertTrue(layer.rawLayer->is()); auto rawLayer = layer.rawLayer->as(); + NSArray *transitionKeys = [MGLSymbolStyleLayer transitionKeys]; + MGLTransition transitionTest = {.delay = 4, .duration = 5}; + + for (NSString *property in transitionKeys) { + [layer setTransition:transitionTest forKey:property]; + MGLTransition transition = [layer transitionForKey:property]; + XCTAssertEqual(transition.delay, transitionTest.delay); + XCTAssertEqual(transition.duration, transitionTest.duration); + } + // icon-allow-overlap { XCTAssertTrue(rawLayer->getIconAllowOverlap().isUndefined(), -- cgit v1.2.1