summaryrefslogtreecommitdiff
path: root/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/ExpressionTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/ExpressionTest.java')
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/ExpressionTest.java53
1 files changed, 45 insertions, 8 deletions
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/ExpressionTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/ExpressionTest.java
index cf7bedeaea..3144807ca6 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/ExpressionTest.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/ExpressionTest.java
@@ -17,8 +17,8 @@ import com.mapbox.mapboxsdk.style.types.Formatted;
import com.mapbox.mapboxsdk.style.types.FormattedSection;
import com.mapbox.mapboxsdk.testapp.R;
import com.mapbox.mapboxsdk.testapp.activity.EspressoTest;
-import com.mapbox.mapboxsdk.testapp.utils.TestingAsyncUtils;
import com.mapbox.mapboxsdk.testapp.utils.ResourceUtils;
+import com.mapbox.mapboxsdk.testapp.utils.TestingAsyncUtils;
import com.mapbox.mapboxsdk.utils.ColorUtils;
import org.junit.Test;
@@ -29,6 +29,7 @@ import java.io.IOException;
import timber.log.Timber;
import static com.mapbox.mapboxsdk.style.expressions.Expression.FormatOption.formatFontScale;
+import static com.mapbox.mapboxsdk.style.expressions.Expression.FormatOption.formatTextColor;
import static com.mapbox.mapboxsdk.style.expressions.Expression.FormatOption.formatTextFont;
import static com.mapbox.mapboxsdk.style.expressions.Expression.collator;
import static com.mapbox.mapboxsdk.style.expressions.Expression.eq;
@@ -353,6 +354,35 @@ public class ExpressionTest extends EspressoTest {
}
@Test
+ public void testConstFormatExpressionTextColorParam() {
+ validateTestSetup();
+ invoke(mapboxMap, (uiController, mapboxMap) -> {
+ LatLng latLng = new LatLng(51, 17);
+ mapboxMap.getStyle()
+ .addSource(new GeoJsonSource("source", Point.fromLngLat(latLng.getLongitude(), latLng.getLatitude())));
+ SymbolLayer layer = new SymbolLayer("layer", "source");
+ mapboxMap.getStyle().addLayer(layer);
+
+ Expression expression = format(
+ formatEntry(
+ literal("test"),
+ formatTextColor(literal("yellow"))
+ )
+ );
+ layer.setProperties(textField(expression));
+ TestingAsyncUtils.INSTANCE.waitForLayer(uiController, idlingResource.getMapView());
+
+ assertFalse(
+ mapboxMap.queryRenderedFeatures(mapboxMap.getProjection().toScreenLocation(latLng), "layer").isEmpty()
+ );
+ assertNull(layer.getTextField().getExpression());
+ assertEquals(new Formatted(
+ new FormattedSection("test", null, null, "rgba(1, 1, 0, 1)")
+ ), layer.getTextField().getValue());
+ });
+ }
+
+ @Test
public void testConstFormatExpressionAllParams() {
validateTestSetup();
invoke(mapboxMap, (uiController, mapboxMap) -> {
@@ -366,7 +396,8 @@ public class ExpressionTest extends EspressoTest {
formatEntry(
"test",
formatFontScale(0.5),
- formatTextFont(new String[] {"DIN Offc Pro Regular", "Arial Unicode MS Regular"})
+ formatTextFont(new String[] {"DIN Offc Pro Regular", "Arial Unicode MS Regular"}),
+ formatTextColor(Color.RED)
)
);
layer.setProperties(textField(expression));
@@ -379,7 +410,8 @@ public class ExpressionTest extends EspressoTest {
assertEquals(new Formatted(
new FormattedSection("test",
0.5,
- new String[] {"DIN Offc Pro Regular", "Arial Unicode MS Regular"})
+ new String[] {"DIN Offc Pro Regular", "Arial Unicode MS Regular"},
+ "rgba(1, 0, 0, 1)")
), layer.getTextField().getValue());
});
}
@@ -400,7 +432,7 @@ public class ExpressionTest extends EspressoTest {
formatFontScale(1.5),
formatTextFont(new String[] {"DIN Offc Pro Regular", "Arial Unicode MS Regular"})
),
- formatEntry("\ntest2", formatFontScale(2))
+ formatEntry("\ntest2", formatFontScale(2), formatTextColor(Color.BLUE))
);
layer.setProperties(textField(expression));
TestingAsyncUtils.INSTANCE.waitForLayer(uiController, idlingResource.getMapView());
@@ -412,7 +444,7 @@ public class ExpressionTest extends EspressoTest {
assertEquals(new Formatted(
new FormattedSection("test", 1.5,
new String[] {"DIN Offc Pro Regular", "Arial Unicode MS Regular"}),
- new FormattedSection("\ntest2", 2.0)
+ new FormattedSection("\ntest2", 2.0, null, "rgba(0, 0, 1, 1)")
), layer.getTextField().getValue());
});
}
@@ -425,6 +457,7 @@ public class ExpressionTest extends EspressoTest {
Feature feature = Feature.fromGeometry(Point.fromLngLat(latLng.getLongitude(), latLng.getLatitude()));
feature.addStringProperty("test_property", "test");
feature.addNumberProperty("test_property_number", 1.5);
+ feature.addStringProperty("test_property_color", "rgba(0, 1, 0, 1)");
mapboxMap.getStyle().addSource(new GeoJsonSource("source", feature));
SymbolLayer layer = new SymbolLayer("layer", "source");
mapboxMap.getStyle().addLayer(layer);
@@ -433,7 +466,8 @@ public class ExpressionTest extends EspressoTest {
formatEntry(
get("test_property"),
Expression.FormatOption.formatFontScale(number(get("test_property_number"))),
- formatTextFont(new String[] {"Arial Unicode MS Regular", "DIN Offc Pro Regular"})
+ formatTextFont(new String[] {"Arial Unicode MS Regular", "DIN Offc Pro Regular"}),
+ formatTextColor(get("test_property_color"))
)
);
layer.setProperties(textField(expression));
@@ -454,6 +488,7 @@ public class ExpressionTest extends EspressoTest {
Feature feature = Feature.fromGeometry(Point.fromLngLat(latLng.getLongitude(), latLng.getLatitude()));
feature.addStringProperty("test_property", "test");
feature.addNumberProperty("test_property_number", 1.5);
+ feature.addStringProperty("test_property_color", "rgba(0, 1, 0, 1)");
mapboxMap.getStyle().addSource(new GeoJsonSource("source", feature));
SymbolLayer layer = new SymbolLayer("layer", "source");
mapboxMap.getStyle().addLayer(layer);
@@ -462,7 +497,8 @@ public class ExpressionTest extends EspressoTest {
formatEntry(
get("test_property"),
formatFontScale(1.25),
- formatTextFont(new String[] {"Arial Unicode MS Regular", "DIN Offc Pro Regular"})
+ formatTextFont(new String[] {"Arial Unicode MS Regular", "DIN Offc Pro Regular"}),
+ formatTextColor(get("test_property_color"))
),
formatEntry("\ntest2", formatFontScale(2))
);
@@ -509,7 +545,8 @@ public class ExpressionTest extends EspressoTest {
Formatted formatted = new Formatted(
new FormattedSection("test", 1.5),
- new FormattedSection("\ntest", 0.5, new String[] {"Arial Unicode MS Regular", "DIN Offc Pro Regular"})
+ new FormattedSection("\ntest", 0.5, new String[] {"Arial Unicode MS Regular", "DIN Offc Pro Regular"}),
+ new FormattedSection("test", null, null, "rgba(1, 0, 0, 1)")
);
layer.setProperties(textField(formatted));
TestingAsyncUtils.INSTANCE.waitForLayer(uiController, idlingResource.getMapView());