diff options
Diffstat (limited to 'platform/darwin/test/MGLLineStyleLayerTests.mm')
-rw-r--r-- | platform/darwin/test/MGLLineStyleLayerTests.mm | 30 |
1 files changed, 24 insertions, 6 deletions
diff --git a/platform/darwin/test/MGLLineStyleLayerTests.mm b/platform/darwin/test/MGLLineStyleLayerTests.mm index 1e92959520..be7d9a6754 100644 --- a/platform/darwin/test/MGLLineStyleLayerTests.mm +++ b/platform/darwin/test/MGLLineStyleLayerTests.mm @@ -713,7 +713,7 @@ MGLStyleValue<NSNumber *> *constantStyleValue = [MGLStyleValue<NSNumber *> valueWithRawValue:@0xff]; layer.lineWidth = constantStyleValue; - mbgl::style::PropertyValue<float> propertyValue = { 0xff }; + mbgl::style::DataDrivenPropertyValue<float> propertyValue = { 0xff }; XCTAssertEqual(rawLayer->getLineWidth(), propertyValue, @"Setting lineWidth to a constant value should update line-width."); XCTAssertEqualObjects(layer.lineWidth, constantStyleValue, @@ -730,6 +730,29 @@ XCTAssertEqualObjects(layer.lineWidth, functionStyleValue, @"lineWidth should round-trip camera functions."); + functionStyleValue = [MGLStyleValue<NSNumber *> valueWithInterpolationMode:MGLInterpolationModeExponential sourceStops:@{@18: constantStyleValue} attributeName:@"keyName" options:nil]; + layer.lineWidth = functionStyleValue; + + mbgl::style::ExponentialStops<float> exponentialStops = { {{18, 0xff}}, 1.0 }; + propertyValue = mbgl::style::SourceFunction<float> { "keyName", exponentialStops }; + + XCTAssertEqual(rawLayer->getLineWidth(), propertyValue, + @"Setting lineWidth to a source function should update line-width."); + XCTAssertEqualObjects(layer.lineWidth, functionStyleValue, + @"lineWidth should round-trip source functions."); + + functionStyleValue = [MGLStyleValue<NSNumber *> valueWithInterpolationMode:MGLInterpolationModeExponential compositeStops:@{@10: @{@18: constantStyleValue}} attributeName:@"keyName" options:nil]; + layer.lineWidth = functionStyleValue; + + std::map<float, float> innerStops { {18, 0xff} }; + mbgl::style::CompositeExponentialStops<float> compositeStops { { {10.0, innerStops} }, 1.0 }; + + propertyValue = mbgl::style::CompositeFunction<float> { "keyName", compositeStops }; + + XCTAssertEqual(rawLayer->getLineWidth(), propertyValue, + @"Setting lineWidth to a composite function should update line-width."); + XCTAssertEqualObjects(layer.lineWidth, functionStyleValue, + @"lineWidth should round-trip composite functions."); layer.lineWidth = nil; @@ -737,11 +760,6 @@ @"Unsetting lineWidth should return line-width to the default value."); XCTAssertEqualObjects(layer.lineWidth, defaultStyleValue, @"lineWidth should return the default value after being unset."); - - functionStyleValue = [MGLStyleValue<NSNumber *> valueWithInterpolationMode:MGLInterpolationModeIdentity sourceStops:nil attributeName:@"" options:nil]; - XCTAssertThrowsSpecificNamed(layer.lineWidth = functionStyleValue, NSException, NSInvalidArgumentException, @"MGLStyleValue should raise an exception if it is applied to a property that cannot support it"); - functionStyleValue = [MGLStyleValue<NSNumber *> valueWithInterpolationMode:MGLInterpolationModeInterval compositeStops:@{@18: constantStyleValue} attributeName:@"" options:nil]; - XCTAssertThrowsSpecificNamed(layer.lineWidth = functionStyleValue, NSException, NSInvalidArgumentException, @"MGLStyleValue should raise an exception if it is applied to a property that cannot support it"); // Transition property test layer.lineWidthTransition = transitionTest; auto toptions = rawLayer->getLineWidthTransition(); |