diff options
Diffstat (limited to 'platform/darwin/test')
-rw-r--r-- | platform/darwin/test/MGLStyleLayerTests.mm.ejs | 20 | ||||
-rw-r--r-- | platform/darwin/test/MGLSymbolStyleLayerTests.mm | 20 |
2 files changed, 31 insertions, 9 deletions
diff --git a/platform/darwin/test/MGLStyleLayerTests.mm.ejs b/platform/darwin/test/MGLStyleLayerTests.mm.ejs index 89b6cbe7e4..c97813eca2 100644 --- a/platform/darwin/test/MGLStyleLayerTests.mm.ejs +++ b/platform/darwin/test/MGLStyleLayerTests.mm.ejs @@ -68,7 +68,11 @@ @"<%- originalPropertyName(property) %> should be unset initially."); NSExpression *defaultExpression = layer.<%- objCName(property) %>; +<% if (property.type === 'formatted') { -%> + NSExpression *constantExpression = [NSExpression expressionWithFormat:<%- objCTestValue(property, 'string', true, 3) %>]; +<% } else { -%> NSExpression *constantExpression = [NSExpression expressionWithFormat:<%- objCTestValue(property, type, true, 3) %>]; +<% } -%> layer.<%- objCName(property) %> = constantExpression; mbgl::style::PropertyValue<<%- mbglType(property) %>> propertyValue = { <%- mbglTestValue(property, type) %> }; XCTAssertEqual(rawLayer->get<%- camelize(originalPropertyName(property)) %>(), propertyValue, @@ -83,7 +87,11 @@ { using namespace mbgl::style::expression::dsl; propertyValue = mbgl::style::PropertyExpression<<%- mbglType(property) %>>( +<% if (property.type === 'formatted') { -%> + step(zoom(), format(<%- mbglExpressionTestValue(property, type) %>), 18.0, format(<%- mbglExpressionTestValue(property, type) %>)) +<% } else { -%> step(zoom(), literal(<%- mbglExpressionTestValue(property, type) %>), 18.0, literal(<%- mbglExpressionTestValue(property, type) %>)) +<% } -%> ); } @@ -160,13 +168,23 @@ { using namespace mbgl::style::expression::dsl; propertyValue = mbgl::style::PropertyExpression<<%- mbglType(property) %>>( +<% if (property.type === 'formatted') { -%> + format(toString(get(literal("token")))) +<% } else { -%> toString(get(literal("token"))) +<% } -%> ); } XCTAssertEqual(rawLayer->get<%- camelize(originalPropertyName(property)) %>(), propertyValue, @"Setting <%- objCName(property) %> to a constant string with tokens should convert to an expression."); - XCTAssertEqualObjects(layer.<%- objCName(property) %>, [NSExpression expressionWithFormat:@"CAST(token, \"NSString\")"], + +<% if (property.type === 'formatted') { -%> + NSExpression* tokenExpression = [NSExpression expressionWithFormat:@"MGL_FUNCTION('format', CAST(token, 'NSString'), %@)", @{}]; +<% } else { -%> + NSExpression* tokenExpression = [NSExpression expressionWithFormat:@"CAST(token, \"NSString\")"]; +<% } -%> + XCTAssertEqualObjects(layer.<%- objCName(property) %>, tokenExpression, @"Setting <%- objCName(property) %> to a constant string with tokens should convert to an expression."); <% } -%> } diff --git a/platform/darwin/test/MGLSymbolStyleLayerTests.mm b/platform/darwin/test/MGLSymbolStyleLayerTests.mm index 865de68933..42430940cd 100644 --- a/platform/darwin/test/MGLSymbolStyleLayerTests.mm +++ b/platform/darwin/test/MGLSymbolStyleLayerTests.mm @@ -224,7 +224,9 @@ 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\")"], + + NSExpression* tokenExpression = [NSExpression expressionWithFormat:@"CAST(token, \"NSString\")"]; + XCTAssertEqualObjects(layer.iconImageName, tokenExpression, @"Setting iconImageName to a constant string with tokens should convert to an expression."); } @@ -1096,20 +1098,20 @@ NSExpression *constantExpression = [NSExpression expressionWithFormat:@"'Text Field'"]; layer.text = constantExpression; - mbgl::style::PropertyValue<std::string> propertyValue = { "Text Field" }; + mbgl::style::PropertyValue<mbgl::style::expression::Formatted> propertyValue = { "Text Field" }; XCTAssertEqual(rawLayer->getTextField(), propertyValue, @"Setting text to a constant value expression should update text-field."); XCTAssertEqualObjects(layer.text, constantExpression, @"text should round-trip constant value expressions."); - constantExpression = [NSExpression expressionWithFormat:@"'Text Field'"]; + constantExpression = [NSExpression expressionWithFormat:@"MGL_FUNCTION('format', 'Text Field', %@)", @{}]; NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}]; layer.text = functionExpression; { using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression<std::string>( - step(zoom(), literal("Text Field"), 18.0, literal("Text Field")) + propertyValue = mbgl::style::PropertyExpression<mbgl::style::expression::Formatted>( + step(zoom(), format("Text Field"), 18.0, format("Text Field")) ); } @@ -1130,14 +1132,16 @@ { using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression<std::string>( - toString(get(literal("token"))) + propertyValue = mbgl::style::PropertyExpression<mbgl::style::expression::Formatted>( + format(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\")"], + + NSExpression* tokenExpression = [NSExpression expressionWithFormat:@"MGL_FUNCTION('format', CAST(token, 'NSString'), %@)", @{}]; + XCTAssertEqualObjects(layer.text, tokenExpression, @"Setting text to a constant string with tokens should convert to an expression."); } |