From 6179110b6bfe8ee0880a055a31c12a88f9bd9b20 Mon Sep 17 00:00:00 2001 From: Tobrun Date: Thu, 8 Mar 2018 16:27:02 +0100 Subject: [android] - add expression conversion, add getters (#11352) --- .../mapboxsdk/testapp/style/HeatmapLayerTest.java | 576 +++------------------ 1 file changed, 85 insertions(+), 491 deletions(-) (limited to 'platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/HeatmapLayerTest.java') diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/HeatmapLayerTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/HeatmapLayerTest.java index 364c8d2679..9a0374a763 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/HeatmapLayerTest.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/HeatmapLayerTest.java @@ -3,31 +3,18 @@ package com.mapbox.mapboxsdk.testapp.style; import android.graphics.Color; -import android.support.test.espresso.UiController; import android.support.test.runner.AndroidJUnit4; import timber.log.Timber; -import com.mapbox.mapboxsdk.maps.MapboxMap; -import com.mapbox.mapboxsdk.style.functions.CompositeFunction; -import com.mapbox.mapboxsdk.style.functions.CameraFunction; -import com.mapbox.mapboxsdk.style.functions.SourceFunction; -import com.mapbox.mapboxsdk.style.functions.stops.CategoricalStops; -import com.mapbox.mapboxsdk.style.functions.stops.ExponentialStops; -import com.mapbox.mapboxsdk.style.functions.stops.IdentityStops; -import com.mapbox.mapboxsdk.style.functions.stops.IntervalStops; -import com.mapbox.mapboxsdk.style.functions.stops.Stop; -import com.mapbox.mapboxsdk.style.functions.stops.Stops; +import com.mapbox.mapboxsdk.style.expressions.Expression; import com.mapbox.mapboxsdk.style.layers.HeatmapLayer; -import com.mapbox.mapboxsdk.testapp.action.MapboxMapAction; import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest; import org.junit.Test; import org.junit.runner.RunWith; -import static com.mapbox.mapboxsdk.style.functions.Function.*; -import static com.mapbox.mapboxsdk.style.functions.stops.Stop.stop; -import static com.mapbox.mapboxsdk.style.functions.stops.Stops.*; +import static com.mapbox.mapboxsdk.style.expressions.Expression.*; import static com.mapbox.mapboxsdk.testapp.action.MapboxMapAction.invoke; import static org.junit.Assert.*; import static com.mapbox.mapboxsdk.style.layers.Property.*; @@ -51,17 +38,14 @@ public class HeatmapLayerTest extends BaseActivityTest { private void setupLayer() { Timber.i("Retrieving layer"); - invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { - @Override - public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new HeatmapLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - // Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } + invoke(mapboxMap, (uiController, mapboxMap) -> { + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new HeatmapLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + // Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } }); } @@ -71,18 +55,15 @@ public class HeatmapLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("Visibility"); - invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { - @Override - public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { - assertNotNull(layer); + invoke(mapboxMap, (uiController, mapboxMap) -> { + assertNotNull(layer); - // Get initial - assertEquals(layer.getVisibility().getValue(), VISIBLE); + // Get initial + assertEquals(layer.getVisibility().getValue(), VISIBLE); - // Set - layer.setProperties(visibility(NONE)); - assertEquals(layer.getVisibility().getValue(), NONE); - } + // Set + layer.setProperties(visibility(NONE)); + assertEquals(layer.getVisibility().getValue(), NONE); }); } @@ -91,19 +72,16 @@ public class HeatmapLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("SourceLayer"); - invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { - @Override - public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { - assertNotNull(layer); - - // Get initial - assertEquals(layer.getSourceLayer(), "composite"); - - // Set - final String sourceLayer = "test"; - layer.setSourceLayer(sourceLayer); - assertEquals(layer.getSourceLayer(), sourceLayer); - } + invoke(mapboxMap, (uiController, mapboxMap) -> { + assertNotNull(layer); + + // Get initial + assertEquals(layer.getSourceLayer(), "composite"); + + // Set + final String sourceLayer = "test"; + layer.setSourceLayer(sourceLayer); + assertEquals(layer.getSourceLayer(), sourceLayer); }); } @@ -112,16 +90,13 @@ public class HeatmapLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("heatmap-radiusTransitionOptions"); - invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { - @Override - public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { - assertNotNull(layer); - - // Set and Get - TransitionOptions options = new TransitionOptions(300, 100); - layer.setHeatmapRadiusTransition(options); - assertEquals(layer.getHeatmapRadiusTransition(), options); - } + invoke(mapboxMap, (uiController, mapboxMap) -> { + assertNotNull(layer); + + // Set and Get + TransitionOptions options = new TransitionOptions(300, 100); + layer.setHeatmapRadiusTransition(options); + assertEquals(layer.getHeatmapRadiusTransition(), options); }); } @@ -130,380 +105,73 @@ public class HeatmapLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("heatmap-radius"); - invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { - @Override - public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { - assertNotNull(layer); - - // Set and Get - layer.setProperties(heatmapRadius(0.3f)); - assertEquals((Float) layer.getHeatmapRadius().getValue(), (Float) 0.3f); - } - }); - } + invoke(mapboxMap, (uiController, mapboxMap) -> { + assertNotNull(layer); - @Test - public void testHeatmapRadiusAsCameraFunction() { - validateTestSetup(); - setupLayer(); - Timber.i("heatmap-radius"); - invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { - @Override - public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { - assertNotNull(layer); - - // Set - layer.setProperties( - heatmapRadius( - zoom( - exponential( - stop(2, heatmapRadius(0.3f)) - ).withBase(0.5f) - ) - ) - ); - - // Verify - assertNotNull(layer.getHeatmapRadius()); - assertNotNull(layer.getHeatmapRadius().getFunction()); - assertEquals(CameraFunction.class, layer.getHeatmapRadius().getFunction().getClass()); - assertEquals(ExponentialStops.class, layer.getHeatmapRadius().getFunction().getStops().getClass()); - assertEquals(0.5f, ((ExponentialStops) layer.getHeatmapRadius().getFunction().getStops()).getBase(), 0.001); - assertEquals(1, ((ExponentialStops) layer.getHeatmapRadius().getFunction().getStops()).size()); - } + // Set and Get + layer.setProperties(heatmapRadius(0.3f)); + assertEquals((Float) layer.getHeatmapRadius().getValue(), (Float) 0.3f); }); } @Test - public void testHeatmapRadiusAsIdentitySourceFunction() { + public void testHeatmapRadiusAsExpression() { validateTestSetup(); setupLayer(); - Timber.i("heatmap-radius"); - invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { - @Override - public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { - assertNotNull(layer); - - // Set - layer.setProperties( - heatmapRadius(property("FeaturePropertyA", Stops.identity())) - ); - - // Verify - assertNotNull(layer.getHeatmapRadius()); - assertNotNull(layer.getHeatmapRadius().getFunction()); - assertEquals(SourceFunction.class, layer.getHeatmapRadius().getFunction().getClass()); - assertEquals("FeaturePropertyA", ((SourceFunction) layer.getHeatmapRadius().getFunction()).getProperty()); - assertEquals(IdentityStops.class, layer.getHeatmapRadius().getFunction().getStops().getClass()); - } - }); - } + Timber.i("heatmap-radius-expression"); + invoke(mapboxMap, (uiController, mapboxMap) -> { + assertNotNull(layer); - @Test - public void testHeatmapRadiusAsExponentialSourceFunction() { - validateTestSetup(); - setupLayer(); - Timber.i("heatmap-radius"); - invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { - @Override - public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { - assertNotNull(layer); - - // Set - layer.setProperties( - heatmapRadius( - property( - "FeaturePropertyA", - exponential( - stop(0.3f, heatmapRadius(0.3f)) - ).withBase(0.5f) - ) - ) - ); - - // Verify - assertNotNull(layer.getHeatmapRadius()); - assertNotNull(layer.getHeatmapRadius().getFunction()); - assertEquals(SourceFunction.class, layer.getHeatmapRadius().getFunction().getClass()); - assertEquals("FeaturePropertyA", ((SourceFunction) layer.getHeatmapRadius().getFunction()).getProperty()); - assertEquals(ExponentialStops.class, layer.getHeatmapRadius().getFunction().getStops().getClass()); - } + // Set and Get + Expression expression = number(Expression.get("undefined")); + layer.setProperties(heatmapRadius(expression)); + assertEquals(layer.getHeatmapRadius().getExpression(), expression); }); } - @Test - public void testHeatmapRadiusAsCategoricalSourceFunction() { - validateTestSetup(); - setupLayer(); - Timber.i("heatmap-radius"); - invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { - @Override - public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { - assertNotNull(layer); - - // Set - layer.setProperties( - heatmapRadius( - property( - "FeaturePropertyA", - categorical( - stop(1.0f, heatmapRadius(0.3f)) - ) - ).withDefaultValue(heatmapRadius(0.3f)) - ) - ); - - // Verify - assertNotNull(layer.getHeatmapRadius()); - assertNotNull(layer.getHeatmapRadius().getFunction()); - assertEquals(SourceFunction.class, layer.getHeatmapRadius().getFunction().getClass()); - assertEquals("FeaturePropertyA", ((SourceFunction) layer.getHeatmapRadius().getFunction()).getProperty()); - assertEquals(CategoricalStops.class, layer.getHeatmapRadius().getFunction().getStops().getClass()); - assertNotNull(((SourceFunction) layer.getHeatmapRadius().getFunction()).getDefaultValue()); - assertNotNull(((SourceFunction) layer.getHeatmapRadius().getFunction()).getDefaultValue().getValue()); - assertEquals(0.3f, ((SourceFunction) layer.getHeatmapRadius().getFunction()).getDefaultValue().getValue()); - } - }); - - } - - @Test - public void testHeatmapRadiusAsCompositeFunction() { - validateTestSetup(); - setupLayer(); - Timber.i("heatmap-radius"); - invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { - @Override - public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { - assertNotNull(layer); - - // Set - layer.setProperties( - heatmapRadius( - composite( - "FeaturePropertyA", - exponential( - stop(0, 0.3f, heatmapRadius(0.9f)) - ).withBase(0.5f) - ).withDefaultValue(heatmapRadius(0.3f)) - ) - ); - - // Verify - assertNotNull(layer.getHeatmapRadius()); - assertNotNull(layer.getHeatmapRadius().getFunction()); - assertEquals(CompositeFunction.class, layer.getHeatmapRadius().getFunction().getClass()); - assertEquals("FeaturePropertyA", ((CompositeFunction) layer.getHeatmapRadius().getFunction()).getProperty()); - assertEquals(ExponentialStops.class, layer.getHeatmapRadius().getFunction().getStops().getClass()); - assertEquals(1, ((ExponentialStops) layer.getHeatmapRadius().getFunction().getStops()).size()); - - ExponentialStops, Float> stops = - (ExponentialStops, Float>) layer.getHeatmapRadius().getFunction().getStops(); - Stop, Float> stop = stops.iterator().next(); - assertEquals(0f, stop.in.zoom, 0.001); - assertEquals(0.3f, stop.in.value, 0.001f); - assertEquals(0.9f, stop.out, 0.001f); - } - }); - } @Test public void testHeatmapWeightAsConstant() { validateTestSetup(); setupLayer(); Timber.i("heatmap-weight"); - invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { - @Override - public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { - assertNotNull(layer); - - // Set and Get - layer.setProperties(heatmapWeight(0.3f)); - assertEquals((Float) layer.getHeatmapWeight().getValue(), (Float) 0.3f); - } - }); - } + invoke(mapboxMap, (uiController, mapboxMap) -> { + assertNotNull(layer); - @Test - public void testHeatmapWeightAsCameraFunction() { - validateTestSetup(); - setupLayer(); - Timber.i("heatmap-weight"); - invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { - @Override - public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { - assertNotNull(layer); - - // Set - layer.setProperties( - heatmapWeight( - zoom( - exponential( - stop(2, heatmapWeight(0.3f)) - ).withBase(0.5f) - ) - ) - ); - - // Verify - assertNotNull(layer.getHeatmapWeight()); - assertNotNull(layer.getHeatmapWeight().getFunction()); - assertEquals(CameraFunction.class, layer.getHeatmapWeight().getFunction().getClass()); - assertEquals(ExponentialStops.class, layer.getHeatmapWeight().getFunction().getStops().getClass()); - assertEquals(0.5f, ((ExponentialStops) layer.getHeatmapWeight().getFunction().getStops()).getBase(), 0.001); - assertEquals(1, ((ExponentialStops) layer.getHeatmapWeight().getFunction().getStops()).size()); - } + // Set and Get + layer.setProperties(heatmapWeight(0.3f)); + assertEquals((Float) layer.getHeatmapWeight().getValue(), (Float) 0.3f); }); } @Test - public void testHeatmapWeightAsIdentitySourceFunction() { + public void testHeatmapWeightAsExpression() { validateTestSetup(); setupLayer(); - Timber.i("heatmap-weight"); - invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { - @Override - public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { - assertNotNull(layer); - - // Set - layer.setProperties( - heatmapWeight(property("FeaturePropertyA", Stops.identity())) - ); - - // Verify - assertNotNull(layer.getHeatmapWeight()); - assertNotNull(layer.getHeatmapWeight().getFunction()); - assertEquals(SourceFunction.class, layer.getHeatmapWeight().getFunction().getClass()); - assertEquals("FeaturePropertyA", ((SourceFunction) layer.getHeatmapWeight().getFunction()).getProperty()); - assertEquals(IdentityStops.class, layer.getHeatmapWeight().getFunction().getStops().getClass()); - } - }); - } + Timber.i("heatmap-weight-expression"); + invoke(mapboxMap, (uiController, mapboxMap) -> { + assertNotNull(layer); - @Test - public void testHeatmapWeightAsExponentialSourceFunction() { - validateTestSetup(); - setupLayer(); - Timber.i("heatmap-weight"); - invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { - @Override - public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { - assertNotNull(layer); - - // Set - layer.setProperties( - heatmapWeight( - property( - "FeaturePropertyA", - exponential( - stop(0.3f, heatmapWeight(0.3f)) - ).withBase(0.5f) - ) - ) - ); - - // Verify - assertNotNull(layer.getHeatmapWeight()); - assertNotNull(layer.getHeatmapWeight().getFunction()); - assertEquals(SourceFunction.class, layer.getHeatmapWeight().getFunction().getClass()); - assertEquals("FeaturePropertyA", ((SourceFunction) layer.getHeatmapWeight().getFunction()).getProperty()); - assertEquals(ExponentialStops.class, layer.getHeatmapWeight().getFunction().getStops().getClass()); - } + // Set and Get + Expression expression = number(Expression.get("undefined")); + layer.setProperties(heatmapWeight(expression)); + assertEquals(layer.getHeatmapWeight().getExpression(), expression); }); } - @Test - public void testHeatmapWeightAsCategoricalSourceFunction() { - validateTestSetup(); - setupLayer(); - Timber.i("heatmap-weight"); - invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { - @Override - public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { - assertNotNull(layer); - - // Set - layer.setProperties( - heatmapWeight( - property( - "FeaturePropertyA", - categorical( - stop(1.0f, heatmapWeight(0.3f)) - ) - ).withDefaultValue(heatmapWeight(0.3f)) - ) - ); - - // Verify - assertNotNull(layer.getHeatmapWeight()); - assertNotNull(layer.getHeatmapWeight().getFunction()); - assertEquals(SourceFunction.class, layer.getHeatmapWeight().getFunction().getClass()); - assertEquals("FeaturePropertyA", ((SourceFunction) layer.getHeatmapWeight().getFunction()).getProperty()); - assertEquals(CategoricalStops.class, layer.getHeatmapWeight().getFunction().getStops().getClass()); - assertNotNull(((SourceFunction) layer.getHeatmapWeight().getFunction()).getDefaultValue()); - assertNotNull(((SourceFunction) layer.getHeatmapWeight().getFunction()).getDefaultValue().getValue()); - assertEquals(0.3f, ((SourceFunction) layer.getHeatmapWeight().getFunction()).getDefaultValue().getValue()); - } - }); - - } - - @Test - public void testHeatmapWeightAsCompositeFunction() { - validateTestSetup(); - setupLayer(); - Timber.i("heatmap-weight"); - invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { - @Override - public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { - assertNotNull(layer); - - // Set - layer.setProperties( - heatmapWeight( - composite( - "FeaturePropertyA", - exponential( - stop(0, 0.3f, heatmapWeight(0.9f)) - ).withBase(0.5f) - ).withDefaultValue(heatmapWeight(0.3f)) - ) - ); - - // Verify - assertNotNull(layer.getHeatmapWeight()); - assertNotNull(layer.getHeatmapWeight().getFunction()); - assertEquals(CompositeFunction.class, layer.getHeatmapWeight().getFunction().getClass()); - assertEquals("FeaturePropertyA", ((CompositeFunction) layer.getHeatmapWeight().getFunction()).getProperty()); - assertEquals(ExponentialStops.class, layer.getHeatmapWeight().getFunction().getStops().getClass()); - assertEquals(1, ((ExponentialStops) layer.getHeatmapWeight().getFunction().getStops()).size()); - - ExponentialStops, Float> stops = - (ExponentialStops, Float>) layer.getHeatmapWeight().getFunction().getStops(); - Stop, Float> stop = stops.iterator().next(); - assertEquals(0f, stop.in.zoom, 0.001); - assertEquals(0.3f, stop.in.value, 0.001f); - assertEquals(0.9f, stop.out, 0.001f); - } - }); - } @Test public void testHeatmapIntensityTransition() { validateTestSetup(); setupLayer(); Timber.i("heatmap-intensityTransitionOptions"); - invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { - @Override - public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { - assertNotNull(layer); - - // Set and Get - TransitionOptions options = new TransitionOptions(300, 100); - layer.setHeatmapIntensityTransition(options); - assertEquals(layer.getHeatmapIntensityTransition(), options); - } + invoke(mapboxMap, (uiController, mapboxMap) -> { + assertNotNull(layer); + + // Set and Get + TransitionOptions options = new TransitionOptions(300, 100); + layer.setHeatmapIntensityTransition(options); + assertEquals(layer.getHeatmapIntensityTransition(), options); }); } @@ -512,47 +180,12 @@ public class HeatmapLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("heatmap-intensity"); - invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { - @Override - public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { - assertNotNull(layer); - - // Set and Get - layer.setProperties(heatmapIntensity(0.3f)); - assertEquals((Float) layer.getHeatmapIntensity().getValue(), (Float) 0.3f); - } - }); - } + invoke(mapboxMap, (uiController, mapboxMap) -> { + assertNotNull(layer); - @Test - public void testHeatmapIntensityAsCameraFunction() { - validateTestSetup(); - setupLayer(); - Timber.i("heatmap-intensity"); - invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { - @Override - public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { - assertNotNull(layer); - - // Set - layer.setProperties( - heatmapIntensity( - zoom( - exponential( - stop(2, heatmapIntensity(0.3f)) - ).withBase(0.5f) - ) - ) - ); - - // Verify - assertNotNull(layer.getHeatmapIntensity()); - assertNotNull(layer.getHeatmapIntensity().getFunction()); - assertEquals(CameraFunction.class, layer.getHeatmapIntensity().getFunction().getClass()); - assertEquals(ExponentialStops.class, layer.getHeatmapIntensity().getFunction().getStops().getClass()); - assertEquals(0.5f, ((ExponentialStops) layer.getHeatmapIntensity().getFunction().getStops()).getBase(), 0.001); - assertEquals(1, ((ExponentialStops) layer.getHeatmapIntensity().getFunction().getStops()).size()); - } + // Set and Get + layer.setProperties(heatmapIntensity(0.3f)); + assertEquals((Float) layer.getHeatmapIntensity().getValue(), (Float) 0.3f); }); } @@ -561,16 +194,13 @@ public class HeatmapLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("heatmap-opacityTransitionOptions"); - invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { - @Override - public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { - assertNotNull(layer); - - // Set and Get - TransitionOptions options = new TransitionOptions(300, 100); - layer.setHeatmapOpacityTransition(options); - assertEquals(layer.getHeatmapOpacityTransition(), options); - } + invoke(mapboxMap, (uiController, mapboxMap) -> { + assertNotNull(layer); + + // Set and Get + TransitionOptions options = new TransitionOptions(300, 100); + layer.setHeatmapOpacityTransition(options); + assertEquals(layer.getHeatmapOpacityTransition(), options); }); } @@ -579,48 +209,12 @@ public class HeatmapLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("heatmap-opacity"); - invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { - @Override - public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { - assertNotNull(layer); - - // Set and Get - layer.setProperties(heatmapOpacity(0.3f)); - assertEquals((Float) layer.getHeatmapOpacity().getValue(), (Float) 0.3f); - } - }); - } + invoke(mapboxMap, (uiController, mapboxMap) -> { + assertNotNull(layer); - @Test - public void testHeatmapOpacityAsCameraFunction() { - validateTestSetup(); - setupLayer(); - Timber.i("heatmap-opacity"); - invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { - @Override - public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { - assertNotNull(layer); - - // Set - layer.setProperties( - heatmapOpacity( - zoom( - exponential( - stop(2, heatmapOpacity(0.3f)) - ).withBase(0.5f) - ) - ) - ); - - // Verify - assertNotNull(layer.getHeatmapOpacity()); - assertNotNull(layer.getHeatmapOpacity().getFunction()); - assertEquals(CameraFunction.class, layer.getHeatmapOpacity().getFunction().getClass()); - assertEquals(ExponentialStops.class, layer.getHeatmapOpacity().getFunction().getStops().getClass()); - assertEquals(0.5f, ((ExponentialStops) layer.getHeatmapOpacity().getFunction().getStops()).getBase(), 0.001); - assertEquals(1, ((ExponentialStops) layer.getHeatmapOpacity().getFunction().getStops()).size()); - } + // Set and Get + layer.setProperties(heatmapOpacity(0.3f)); + assertEquals((Float) layer.getHeatmapOpacity().getValue(), (Float) 0.3f); }); } - -} +} \ No newline at end of file -- cgit v1.2.1