From 4562fe83d2e0e54f5d96b06764706844ebd86b46 Mon Sep 17 00:00:00 2001 From: tobrun Date: Mon, 2 Sep 2019 11:39:33 +0200 Subject: [android] - update test to include dds lookup, add changelog entry --- platform/android/CHANGELOG.md | 2 +- .../mapboxsdk/testapp/style/ExpressionTest.java | 43 ++++++++++++++++++---- 2 files changed, 36 insertions(+), 9 deletions(-) diff --git a/platform/android/CHANGELOG.md b/platform/android/CHANGELOG.md index 8a10edd169..60d4fc2f64 100644 --- a/platform/android/CHANGELOG.md +++ b/platform/android/CHANGELOG.md @@ -6,7 +6,7 @@ Mapbox welcomes participation and contributions from everyone. If you'd like to ### Features - Introduce `clusterProperties` option for aggregated cluster properties. [#15425](https://github.com/mapbox/mapbox-gl-native/pull/15425) - Expose the `CameraPosition#padding` field and associated utility camera position builders. This gives a choice to set a persisting map padding immediately during a transition instead of setting it lazily `MapboxMap#setPadding`, which required scheduling additional transition to be applied. This also deprecates `MapboxMap#setPadding` as there should be no need for a lazy padding setter. [#15444](https://github.com/mapbox/mapbox-gl-native/pull/15444) - - Add number-format expression [#15424](https://github.com/mapbox/mapbox-gl-native/pull/15424) + - Add number-format expression that allows to format a number to a string, with configurations as minimal/maximal fraction and locale/currency. [#15424](https://github.com/mapbox/mapbox-gl-native/pull/15424) ### Performance improvements - Mark used offline region resources in batches. [#15521](https://github.com/mapbox/mapbox-gl-native/pull/15521) 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 b62b2ac271..3cbdf016b4 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 @@ -25,7 +25,7 @@ import org.junit.Test; import org.junit.runner.RunWith; import java.io.IOException; -import java.util.Arrays; +import java.util.HashMap; import timber.log.Timber; @@ -62,11 +62,11 @@ import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillOutlineColor import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textColor; import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textField; import static com.mapbox.mapboxsdk.testapp.action.MapboxMapAction.invoke; +import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; @RunWith(AndroidJUnit4.class) public class ExpressionTest extends EspressoTest { @@ -676,20 +676,23 @@ public class ExpressionTest extends EspressoTest { LatLng latLng = new LatLng(51, 17); Feature feature = Feature.fromGeometry(Point.fromLngLat(latLng.getLongitude(), latLng.getLatitude())); feature.addNumberProperty("number_value", 12.345678); + feature.addStringProperty("locale_value", "nl-BE"); + feature.addNumberProperty("max_value", 5); + feature.addNumberProperty("min_value", 1); + mapboxMap.getStyle().addSource(new GeoJsonSource("source", feature)); SymbolLayer layer = new SymbolLayer("layer", "source"); mapboxMap.getStyle().addLayer(layer); Expression numberFormatExpression = numberFormat( - number(get("number_value")), - locale("nl-BE"), - maxFractionDigits(5), - minFractionDigits(1) + number(number(get("number_value"))), + locale(string(get("locale_value"))), + maxFractionDigits(number(get("max_value"))), + minFractionDigits(number(get("min_value"))) ); layer.setProperties(textField(numberFormatExpression)); - TestingAsyncUtils.INSTANCE.waitForLayer(uiController, mapView); assertFalse(mapboxMap.queryRenderedFeatures( @@ -701,8 +704,32 @@ public class ExpressionTest extends EspressoTest { // Expressions evaluated to string are wrapped by a format expression, take array index 1 to get original Object[] returnExpression = (Object[]) layer.getTextField().getExpression().toArray()[1]; Object[] setExpression = numberFormatExpression.toArray(); - assertTrue("Object[] expression representation should match", Arrays.deepEquals(returnExpression, setExpression)); + assertEquals("Number format should match",returnExpression[0], setExpression[0]); + assertArrayEquals("Get value expression should match", + (Object[]) returnExpression[1], + (Object[]) setExpression[1] + ); + + // number format objects + HashMap returnMap = (HashMap) returnExpression[2]; + HashMap setMap = (HashMap) returnExpression[2]; + + assertArrayEquals("Number format min fraction digits should match ", + (Object[]) returnMap.get("min-fraction-digits"), + (Object[]) setMap.get("min-fraction-digits") + ); + + assertArrayEquals("Number format max fraction digits should match ", + (Object[]) returnMap.get("max-fraction-digits"), + (Object[]) setMap.get("max-fraction-digits") + ); + + assertArrayEquals("Number format min fraction digits should match ", + (Object[]) returnMap.get("locale"), + (Object[]) setMap.get("locale") + ); }); + } private void setupStyle() { -- cgit v1.2.1