diff options
author | John Firebaugh <john.firebaugh@gmail.com> | 2018-07-17 12:21:50 -0700 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2018-07-20 12:35:00 -0700 |
commit | 2c5d0e74a1ef6743a23dbd346b79958e4b2f8614 (patch) | |
tree | 5dd56c0079294b6cebf2d26970bcb12852add27e /platform/darwin/test/MGLSymbolStyleLayerTests.mm | |
parent | af89318b1d3bef15e92e591887c9d65b10be54ce (diff) | |
download | qtlocation-mapboxgl-2c5d0e74a1ef6743a23dbd346b79958e4b2f8614.tar.gz |
[ios, macos] Convert token strings to expressions on input
Removes mgl_expressionByReplacingTokensWithKeyPaths and associated code. Converting on output is no longer necessary: from the prior commit, core converts token strings to expressions at parse time; all that's necessary is to ensure that the runtime styling API does so as well.
Diffstat (limited to 'platform/darwin/test/MGLSymbolStyleLayerTests.mm')
-rw-r--r-- | platform/darwin/test/MGLSymbolStyleLayerTests.mm | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/platform/darwin/test/MGLSymbolStyleLayerTests.mm b/platform/darwin/test/MGLSymbolStyleLayerTests.mm index 7566617872..8643e8388b 100644 --- a/platform/darwin/test/MGLSymbolStyleLayerTests.mm +++ b/platform/darwin/test/MGLSymbolStyleLayerTests.mm @@ -211,6 +211,21 @@ @"Unsetting iconImageName should return icon-image to the default value."); XCTAssertEqualObjects(layer.iconImageName, defaultExpression, @"iconImageName should return the default value after being unset."); + + // Tokens test + layer.iconImageName = [NSExpression expressionForConstantValue:@"{token}"]; + + { + using namespace mbgl::style::expression::dsl; + propertyValue = mbgl::style::PropertyExpression<std::string>( + toString(get(literal("token"))) + ); + } + + XCTAssertEqual(rawLayer->getIconImage(), propertyValue, + @"Setting iconImageName to a constant string with tokens should convert to an expression."); + XCTAssertEqualObjects(layer.iconImageName, [NSExpression expressionWithFormat:@"CAST(token, \"NSString\")"], + @"Setting iconImageName to a constant string with tokens should convert to an expression."); } // icon-offset @@ -1065,6 +1080,21 @@ @"Unsetting text should return text-field to the default value."); XCTAssertEqualObjects(layer.text, defaultExpression, @"text should return the default value after being unset."); + + // Tokens test + layer.text = [NSExpression expressionForConstantValue:@"{token}"]; + + { + using namespace mbgl::style::expression::dsl; + propertyValue = mbgl::style::PropertyExpression<std::string>( + toString(get(literal("token"))) + ); + } + + XCTAssertEqual(rawLayer->getTextField(), propertyValue, + @"Setting text to a constant string with tokens should convert to an expression."); + XCTAssertEqualObjects(layer.text, [NSExpression expressionWithFormat:@"CAST(token, \"NSString\")"], + @"Setting text to a constant string with tokens should convert to an expression."); } // text-allow-overlap |