[android] expose Formatted text-field setter
This commit is contained in:
committed by
Łukasz Paczos
parent
1e7c7e0489
commit
794b851f02
@@ -406,10 +406,9 @@ public class ExpressionTest extends BaseActivityTest {
|
||||
|
||||
assertNull(layer.getTextField().getExpression());
|
||||
assertEquals(new Formatted(
|
||||
new FormattedSection[] {
|
||||
new FormattedSection("test", 1.5, new String[] {"DIN Offc Pro Regular", "Arial Unicode MS Regular"}),
|
||||
new FormattedSection("\ntest2", 2.0),
|
||||
}
|
||||
new FormattedSection("test", 1.5,
|
||||
new String[] {"DIN Offc Pro Regular", "Arial Unicode MS Regular"}),
|
||||
new FormattedSection("\ntest2", 2.0)
|
||||
), layer.getTextField().getValue());
|
||||
});
|
||||
}
|
||||
@@ -493,6 +492,29 @@ public class ExpressionTest extends BaseActivityTest {
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTextFieldFormattedArgument() {
|
||||
validateTestSetup();
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
LatLng latLng = new LatLng(51, 17);
|
||||
mapboxMap.addSource(new GeoJsonSource("source", Point.fromLngLat(latLng.getLongitude(), latLng.getLatitude())));
|
||||
SymbolLayer layer = new SymbolLayer("layer", "source");
|
||||
mapboxMap.addLayer(layer);
|
||||
|
||||
Formatted formatted = new Formatted(
|
||||
new FormattedSection("test", 1.5),
|
||||
new FormattedSection("\ntest", 0.5, new String[] {"Arial Unicode MS Regular", "DIN Offc Pro Regular"})
|
||||
);
|
||||
layer.setProperties(textField(formatted));
|
||||
waitForLayer(uiController, mapboxMap, latLng);
|
||||
assertFalse(mapboxMap.queryRenderedFeatures(mapboxMap.getProjection().toScreenLocation(latLng), "layer")
|
||||
.isEmpty());
|
||||
|
||||
assertNull(layer.getTextField().getExpression());
|
||||
assertEquals(formatted, layer.getTextField().getValue());
|
||||
});
|
||||
}
|
||||
|
||||
private static final long WAIT_TIMEOUT = 5000;
|
||||
private static final long WAIT_DELAY = 150;
|
||||
|
||||
|
||||
@@ -521,11 +521,14 @@ public class SymbolLayerTest extends BaseActivityTest {
|
||||
assertNull(layer.getTextField().getValue());
|
||||
|
||||
// Set and Get
|
||||
Formatted propertyValue = new Formatted(new FormattedSection[]{new FormattedSection("default")});
|
||||
Formatted propertyValue = new Formatted(new FormattedSection("default"));
|
||||
|
||||
layer.setProperties(textField("default"));
|
||||
assertEquals(layer.getTextField().getValue(), propertyValue);
|
||||
|
||||
layer.setProperties(textField(propertyValue));
|
||||
assertEquals(layer.getTextField().getValue(), propertyValue);
|
||||
|
||||
layer.setProperties(textField("{token}"));
|
||||
assertEquals(layer.getTextField().getExpression(), format(Expression.formatEntry(Expression.toString(Expression.get("token")))));
|
||||
});
|
||||
|
||||
@@ -175,10 +175,10 @@ public class <%- camelize(type) %>LayerTest extends BaseActivityTest {
|
||||
|
||||
layer.setProperties(<%- camelizeWithLeadingLowercase(property.name) %>("default"));
|
||||
assertEquals(layer.get<%- camelize(property.name) %>().getValue(), propertyValue);
|
||||
<% } else {-%>
|
||||
|
||||
<% } -%>
|
||||
layer.setProperties(<%- camelizeWithLeadingLowercase(property.name) %>(propertyValue));
|
||||
assertEquals(layer.get<%- camelize(property.name) %>().getValue(), propertyValue);
|
||||
<% } -%>
|
||||
<% if (property.tokens) { -%>
|
||||
|
||||
layer.setProperties(<%- camelizeWithLeadingLowercase(property.name) %>("{token}"));
|
||||
|
||||
Reference in New Issue
Block a user