summaryrefslogtreecommitdiff
path: root/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/FillLayerTest.java
diff options
context:
space:
mode:
authorIvo van Dongen <info@ivovandongen.nl>2017-01-17 17:43:49 +0200
committerJohn Firebaugh <john.firebaugh@gmail.com>2017-02-02 09:44:42 -0800
commitf562ecdfc3a08f7b9b0c2be938f237852a82d374 (patch)
tree71c3ceb4b2a877d124f4b069fa80156d701a6125 /platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/FillLayerTest.java
parent8a5bff8ee630673c6ebc496322eab94a41ae9353 (diff)
downloadqtlocation-mapboxgl-f562ecdfc3a08f7b9b0c2be938f237852a82d374.tar.gz
[android] data driven style implementation
Diffstat (limited to 'platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/FillLayerTest.java')
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/FillLayerTest.java573
1 files changed, 453 insertions, 120 deletions
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/FillLayerTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/FillLayerTest.java
index 45fb243ded..40a9ddec58 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/FillLayerTest.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/FillLayerTest.java
@@ -1,12 +1,23 @@
-package com.mapbox.mapboxsdk.testapp.style;
// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make android-style-code`.
+package com.mapbox.mapboxsdk.testapp.style;
+
import android.graphics.Color;
import android.support.test.espresso.Espresso;
import android.support.test.rule.ActivityTestRule;
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.CompositeStops;
+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.Stops;
import com.mapbox.mapboxsdk.style.layers.FillLayer;
import com.mapbox.mapboxsdk.testapp.R;
import com.mapbox.mapboxsdk.testapp.activity.style.RuntimeStyleTestActivity;
@@ -18,21 +29,14 @@ import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
-import timber.log.Timber;
+import java.util.Map;
-import static com.mapbox.mapboxsdk.style.layers.Property.FILL_TRANSLATE_ANCHOR_MAP;
-import static com.mapbox.mapboxsdk.style.layers.Property.NONE;
-import static com.mapbox.mapboxsdk.style.layers.Property.VISIBLE;
-import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillAntialias;
-import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillColor;
-import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillOpacity;
-import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillOutlineColor;
-import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillPattern;
-import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillTranslate;
-import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillTranslateAnchor;
-import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.visibility;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+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 org.junit.Assert.*;
+import static com.mapbox.mapboxsdk.style.layers.Property.*;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*;
/**
* Basic smoke tests for FillLayer
@@ -53,12 +57,6 @@ public class FillLayerTest extends BaseStyleTest {
public void setup() {
idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
Espresso.registerIdlingResources(idlingResource);
- }
-
- @Test
- public void testSetVisibility() {
- checkViewIsDisplayed(R.id.mapView);
-
mapboxMap = rule.getActivity().getMapboxMap();
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
@@ -69,7 +67,12 @@ public class FillLayerTest extends BaseStyleTest {
// Layer reference is now stale, get new reference
layer = mapboxMap.getLayerAs("my-layer");
}
- Timber.i("visibility");
+ }
+
+ @Test
+ public void testSetVisibility() {
+ checkViewIsDisplayed(R.id.mapView);
+ Timber.i("Visibility");
assertNotNull(layer);
// Get initial
@@ -81,19 +84,8 @@ public class FillLayerTest extends BaseStyleTest {
}
@Test
- public void testFillAntialias() {
+ public void testFillAntialiasAsConstant() {
checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new FillLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- // Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
Timber.i("fill-antialias");
assertNotNull(layer);
@@ -103,19 +95,33 @@ public class FillLayerTest extends BaseStyleTest {
}
@Test
- public void testFillOpacity() {
+ public void testFillAntialiasAsCameraFunction() {
checkViewIsDisplayed(R.id.mapView);
+ Timber.i("fill-antialias");
+ assertNotNull(layer);
- mapboxMap = rule.getActivity().getMapboxMap();
+ // Set
+ layer.setProperties(
+ fillAntialias(
+ zoom(
+ interval(
+ stop(2, fillAntialias(true))
+ )
+ )
+ )
+ );
+
+ // Verify
+ assertNotNull(layer.getFillAntialias());
+ assertNotNull(layer.getFillAntialias().getFunction());
+ assertEquals(CameraFunction.class, layer.getFillAntialias().getFunction().getClass());
+ assertEquals(IntervalStops.class, layer.getFillAntialias().getFunction().getStops().getClass());
+ assertEquals(1, ((IntervalStops) layer.getFillAntialias().getFunction().getStops()).size());
+ }
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new FillLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- // Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
+ @Test
+ public void testFillOpacityAsConstant() {
+ checkViewIsDisplayed(R.id.mapView);
Timber.i("fill-opacity");
assertNotNull(layer);
@@ -125,19 +131,142 @@ public class FillLayerTest extends BaseStyleTest {
}
@Test
- public void testFillColor() {
+ public void testFillOpacityAsCameraFunction() {
checkViewIsDisplayed(R.id.mapView);
+ Timber.i("fill-opacity");
+ assertNotNull(layer);
- mapboxMap = rule.getActivity().getMapboxMap();
+ // Set
+ layer.setProperties(
+ fillOpacity(
+ zoom(
+ exponential(
+ stop(2, fillOpacity(0.3f))
+ ).withBase(0.5f)
+ )
+ )
+ );
+
+ // Verify
+ assertNotNull(layer.getFillOpacity());
+ assertNotNull(layer.getFillOpacity().getFunction());
+ assertEquals(CameraFunction.class, layer.getFillOpacity().getFunction().getClass());
+ assertEquals(ExponentialStops.class, layer.getFillOpacity().getFunction().getStops().getClass());
+ assertEquals(0.5f, ((ExponentialStops) layer.getFillOpacity().getFunction().getStops()).getBase(), 0.001);
+ assertEquals(1, ((ExponentialStops) layer.getFillOpacity().getFunction().getStops()).size());
+ }
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new FillLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- // Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
+ @Test
+ public void testFillOpacityAsIdentitySourceFunction() {
+ checkViewIsDisplayed(R.id.mapView);
+ Timber.i("fill-opacity");
+ assertNotNull(layer);
+
+ // Set
+ layer.setProperties(
+ fillOpacity(property("FeaturePropertyA", Stops.<Float>identity()))
+ );
+
+ // Verify
+ assertNotNull(layer.getFillOpacity());
+ assertNotNull(layer.getFillOpacity().getFunction());
+ assertEquals(SourceFunction.class, layer.getFillOpacity().getFunction().getClass());
+ assertEquals("FeaturePropertyA", ((SourceFunction) layer.getFillOpacity().getFunction()).getProperty());
+ assertEquals(IdentityStops.class, layer.getFillOpacity().getFunction().getStops().getClass());
+ }
+
+ @Test
+ public void testFillOpacityAsExponentialSourceFunction() {
+ checkViewIsDisplayed(R.id.mapView);
+ Timber.i("fill-opacity");
+ assertNotNull(layer);
+
+ // Set
+ layer.setProperties(
+ fillOpacity(
+ property(
+ "FeaturePropertyA",
+ exponential(
+ stop(0.3f, fillOpacity(0.3f))
+ ).withBase(0.5f)
+ )
+ )
+ );
+
+ // Verify
+ assertNotNull(layer.getFillOpacity());
+ assertNotNull(layer.getFillOpacity().getFunction());
+ assertEquals(SourceFunction.class, layer.getFillOpacity().getFunction().getClass());
+ assertEquals("FeaturePropertyA", ((SourceFunction) layer.getFillOpacity().getFunction()).getProperty());
+ assertEquals(ExponentialStops.class, layer.getFillOpacity().getFunction().getStops().getClass());
+ }
+
+ @Test
+ public void testFillOpacityAsCategoricalSourceFunction() {
+ checkViewIsDisplayed(R.id.mapView);
+ Timber.i("fill-opacity");
+ assertNotNull(layer);
+
+ // Set
+ layer.setProperties(
+ fillOpacity(
+ property(
+ "FeaturePropertyA",
+ categorical(
+ stop(1.0f, fillOpacity(0.3f))
+ )
+ ).withDefaultValue(0.3f)
+ )
+ );
+
+ // Verify
+ assertNotNull(layer.getFillOpacity());
+ assertNotNull(layer.getFillOpacity().getFunction());
+ assertEquals(SourceFunction.class, layer.getFillOpacity().getFunction().getClass());
+ assertEquals("FeaturePropertyA", ((SourceFunction) layer.getFillOpacity().getFunction()).getProperty());
+ assertEquals(CategoricalStops.class, layer.getFillOpacity().getFunction().getStops().getClass());
+ assertEquals(0.3f, ((SourceFunction) layer.getFillOpacity().getFunction()).getDefaultValue());
+ }
+
+ @Test
+ public void testFillOpacityAsCompositeFunction() {
+ checkViewIsDisplayed(R.id.mapView);
+ Timber.i("fill-opacity");
+ assertNotNull(layer);
+
+ // Set
+ layer.setProperties(
+ fillOpacity(
+ composite(
+ "FeaturePropertyA",
+ exponential(
+ stop(0, 0.3f, fillOpacity(0.9f))
+ ).withBase(0.5f)
+ ).withDefaultValue(0.3f)
+ )
+ );
+
+ // Verify
+ assertNotNull(layer.getFillOpacity());
+ assertNotNull(layer.getFillOpacity().getFunction());
+ assertEquals(CompositeFunction.class, layer.getFillOpacity().getFunction().getClass());
+ assertEquals("FeaturePropertyA", ((CompositeFunction) layer.getFillOpacity().getFunction()).getProperty());
+ assertEquals(CompositeStops.class, layer.getFillOpacity().getFunction().getStops().getClass());
+ assertEquals(1, ((CompositeStops) layer.getFillOpacity().getFunction().getStops()).size());
+
+ CompositeStops<Float, Float, Float, ExponentialStops<Float, Float>> stops =
+ (CompositeStops<Float, Float, Float, ExponentialStops<Float, Float>>) layer.getFillOpacity().getFunction().getStops();
+ Map.Entry<Float, ExponentialStops<Float, Float>> stop = stops.iterator().next();
+ assertEquals(ExponentialStops.class, stop.getValue().getClass());
+ assertEquals(0f, stop.getKey(), 0.001);
+ assertEquals(1, stop.getValue().size());
+ assertEquals(0.3f, stop.getValue().iterator().next().in, 0.001f);
+ assertEquals(0.9f, stop.getValue().iterator().next().out, 0.001f);
+ }
+
+ @Test
+ public void testFillColorAsConstant() {
+ checkViewIsDisplayed(R.id.mapView);
Timber.i("fill-color");
assertNotNull(layer);
@@ -147,19 +276,105 @@ public class FillLayerTest extends BaseStyleTest {
}
@Test
- public void testFillColorAsInt() {
+ public void testFillColorAsCameraFunction() {
checkViewIsDisplayed(R.id.mapView);
+ Timber.i("fill-color");
+ assertNotNull(layer);
- mapboxMap = rule.getActivity().getMapboxMap();
+ // Set
+ layer.setProperties(
+ fillColor(
+ zoom(
+ exponential(
+ stop(2, fillColor("rgba(0, 0, 0, 1)"))
+ ).withBase(0.5f)
+ )
+ )
+ );
+
+ // Verify
+ assertNotNull(layer.getFillColor());
+ assertNotNull(layer.getFillColor().getFunction());
+ assertEquals(CameraFunction.class, layer.getFillColor().getFunction().getClass());
+ assertEquals(ExponentialStops.class, layer.getFillColor().getFunction().getStops().getClass());
+ assertEquals(0.5f, ((ExponentialStops) layer.getFillColor().getFunction().getStops()).getBase(), 0.001);
+ assertEquals(1, ((ExponentialStops) layer.getFillColor().getFunction().getStops()).size());
+ }
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new FillLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- // Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
+ @Test
+ public void testFillColorAsIdentitySourceFunction() {
+ checkViewIsDisplayed(R.id.mapView);
+ Timber.i("fill-color");
+ assertNotNull(layer);
+
+ // Set
+ layer.setProperties(
+ fillColor(property("FeaturePropertyA", Stops.<String>identity()))
+ );
+
+ // Verify
+ assertNotNull(layer.getFillColor());
+ assertNotNull(layer.getFillColor().getFunction());
+ assertEquals(SourceFunction.class, layer.getFillColor().getFunction().getClass());
+ assertEquals("FeaturePropertyA", ((SourceFunction) layer.getFillColor().getFunction()).getProperty());
+ assertEquals(IdentityStops.class, layer.getFillColor().getFunction().getStops().getClass());
+ }
+
+ @Test
+ public void testFillColorAsExponentialSourceFunction() {
+ checkViewIsDisplayed(R.id.mapView);
+ Timber.i("fill-color");
+ assertNotNull(layer);
+
+ // Set
+ layer.setProperties(
+ fillColor(
+ property(
+ "FeaturePropertyA",
+ exponential(
+ stop(Color.RED, fillColor(Color.RED))
+ ).withBase(0.5f)
+ )
+ )
+ );
+
+ // Verify
+ assertNotNull(layer.getFillColor());
+ assertNotNull(layer.getFillColor().getFunction());
+ assertEquals(SourceFunction.class, layer.getFillColor().getFunction().getClass());
+ assertEquals("FeaturePropertyA", ((SourceFunction) layer.getFillColor().getFunction()).getProperty());
+ assertEquals(ExponentialStops.class, layer.getFillColor().getFunction().getStops().getClass());
+ }
+
+ @Test
+ public void testFillColorAsCategoricalSourceFunction() {
+ checkViewIsDisplayed(R.id.mapView);
+ Timber.i("fill-color");
+ assertNotNull(layer);
+
+ // Set
+ layer.setProperties(
+ fillColor(
+ property(
+ "FeaturePropertyA",
+ categorical(
+ stop("valueA", fillColor(Color.RED))
+ )
+ )
+ )
+ );
+
+ // Verify
+ assertNotNull(layer.getFillColor());
+ assertNotNull(layer.getFillColor().getFunction());
+ assertEquals(SourceFunction.class, layer.getFillColor().getFunction().getClass());
+ assertEquals("FeaturePropertyA", ((SourceFunction) layer.getFillColor().getFunction()).getProperty());
+ assertEquals(CategoricalStops.class, layer.getFillColor().getFunction().getStops().getClass());
+ }
+
+ @Test
+ public void testFillColorAsIntConstant() {
+ checkViewIsDisplayed(R.id.mapView);
Timber.i("fill-color");
assertNotNull(layer);
@@ -169,19 +384,8 @@ public class FillLayerTest extends BaseStyleTest {
}
@Test
- public void testFillOutlineColor() {
+ public void testFillOutlineColorAsConstant() {
checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new FillLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- // Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
Timber.i("fill-outline-color");
assertNotNull(layer);
@@ -191,19 +395,105 @@ public class FillLayerTest extends BaseStyleTest {
}
@Test
- public void testFillOutlineColorAsInt() {
+ public void testFillOutlineColorAsCameraFunction() {
checkViewIsDisplayed(R.id.mapView);
+ Timber.i("fill-outline-color");
+ assertNotNull(layer);
- mapboxMap = rule.getActivity().getMapboxMap();
+ // Set
+ layer.setProperties(
+ fillOutlineColor(
+ zoom(
+ exponential(
+ stop(2, fillOutlineColor("rgba(0, 0, 0, 1)"))
+ ).withBase(0.5f)
+ )
+ )
+ );
+
+ // Verify
+ assertNotNull(layer.getFillOutlineColor());
+ assertNotNull(layer.getFillOutlineColor().getFunction());
+ assertEquals(CameraFunction.class, layer.getFillOutlineColor().getFunction().getClass());
+ assertEquals(ExponentialStops.class, layer.getFillOutlineColor().getFunction().getStops().getClass());
+ assertEquals(0.5f, ((ExponentialStops) layer.getFillOutlineColor().getFunction().getStops()).getBase(), 0.001);
+ assertEquals(1, ((ExponentialStops) layer.getFillOutlineColor().getFunction().getStops()).size());
+ }
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new FillLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- // Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
+ @Test
+ public void testFillOutlineColorAsIdentitySourceFunction() {
+ checkViewIsDisplayed(R.id.mapView);
+ Timber.i("fill-outline-color");
+ assertNotNull(layer);
+
+ // Set
+ layer.setProperties(
+ fillOutlineColor(property("FeaturePropertyA", Stops.<String>identity()))
+ );
+
+ // Verify
+ assertNotNull(layer.getFillOutlineColor());
+ assertNotNull(layer.getFillOutlineColor().getFunction());
+ assertEquals(SourceFunction.class, layer.getFillOutlineColor().getFunction().getClass());
+ assertEquals("FeaturePropertyA", ((SourceFunction) layer.getFillOutlineColor().getFunction()).getProperty());
+ assertEquals(IdentityStops.class, layer.getFillOutlineColor().getFunction().getStops().getClass());
+ }
+
+ @Test
+ public void testFillOutlineColorAsExponentialSourceFunction() {
+ checkViewIsDisplayed(R.id.mapView);
+ Timber.i("fill-outline-color");
+ assertNotNull(layer);
+
+ // Set
+ layer.setProperties(
+ fillOutlineColor(
+ property(
+ "FeaturePropertyA",
+ exponential(
+ stop(Color.RED, fillOutlineColor(Color.RED))
+ ).withBase(0.5f)
+ )
+ )
+ );
+
+ // Verify
+ assertNotNull(layer.getFillOutlineColor());
+ assertNotNull(layer.getFillOutlineColor().getFunction());
+ assertEquals(SourceFunction.class, layer.getFillOutlineColor().getFunction().getClass());
+ assertEquals("FeaturePropertyA", ((SourceFunction) layer.getFillOutlineColor().getFunction()).getProperty());
+ assertEquals(ExponentialStops.class, layer.getFillOutlineColor().getFunction().getStops().getClass());
+ }
+
+ @Test
+ public void testFillOutlineColorAsCategoricalSourceFunction() {
+ checkViewIsDisplayed(R.id.mapView);
+ Timber.i("fill-outline-color");
+ assertNotNull(layer);
+
+ // Set
+ layer.setProperties(
+ fillOutlineColor(
+ property(
+ "FeaturePropertyA",
+ categorical(
+ stop("valueA", fillOutlineColor(Color.RED))
+ )
+ )
+ )
+ );
+
+ // Verify
+ assertNotNull(layer.getFillOutlineColor());
+ assertNotNull(layer.getFillOutlineColor().getFunction());
+ assertEquals(SourceFunction.class, layer.getFillOutlineColor().getFunction().getClass());
+ assertEquals("FeaturePropertyA", ((SourceFunction) layer.getFillOutlineColor().getFunction()).getProperty());
+ assertEquals(CategoricalStops.class, layer.getFillOutlineColor().getFunction().getStops().getClass());
+ }
+
+ @Test
+ public void testFillOutlineColorAsIntConstant() {
+ checkViewIsDisplayed(R.id.mapView);
Timber.i("fill-outline-color");
assertNotNull(layer);
@@ -213,41 +503,45 @@ public class FillLayerTest extends BaseStyleTest {
}
@Test
- public void testFillTranslate() {
+ public void testFillTranslateAsConstant() {
checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new FillLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- // Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
Timber.i("fill-translate");
assertNotNull(layer);
// Set and Get
- layer.setProperties(fillTranslate(new Float[] {0f, 0f}));
- assertEquals((Float[]) layer.getFillTranslate().getValue(), (Float[]) new Float[] {0f, 0f});
+ layer.setProperties(fillTranslate(new Float[]{0f,0f}));
+ assertEquals((Float[]) layer.getFillTranslate().getValue(), (Float[]) new Float[]{0f,0f});
}
@Test
- public void testFillTranslateAnchor() {
+ public void testFillTranslateAsCameraFunction() {
checkViewIsDisplayed(R.id.mapView);
+ Timber.i("fill-translate");
+ assertNotNull(layer);
- mapboxMap = rule.getActivity().getMapboxMap();
+ // Set
+ layer.setProperties(
+ fillTranslate(
+ zoom(
+ exponential(
+ stop(2, fillTranslate(new Float[]{0f,0f}))
+ ).withBase(0.5f)
+ )
+ )
+ );
+
+ // Verify
+ assertNotNull(layer.getFillTranslate());
+ assertNotNull(layer.getFillTranslate().getFunction());
+ assertEquals(CameraFunction.class, layer.getFillTranslate().getFunction().getClass());
+ assertEquals(ExponentialStops.class, layer.getFillTranslate().getFunction().getStops().getClass());
+ assertEquals(0.5f, ((ExponentialStops) layer.getFillTranslate().getFunction().getStops()).getBase(), 0.001);
+ assertEquals(1, ((ExponentialStops) layer.getFillTranslate().getFunction().getStops()).size());
+ }
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new FillLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- // Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
+ @Test
+ public void testFillTranslateAnchorAsConstant() {
+ checkViewIsDisplayed(R.id.mapView);
Timber.i("fill-translate-anchor");
assertNotNull(layer);
@@ -257,19 +551,33 @@ public class FillLayerTest extends BaseStyleTest {
}
@Test
- public void testFillPattern() {
+ public void testFillTranslateAnchorAsCameraFunction() {
checkViewIsDisplayed(R.id.mapView);
+ Timber.i("fill-translate-anchor");
+ assertNotNull(layer);
- mapboxMap = rule.getActivity().getMapboxMap();
+ // Set
+ layer.setProperties(
+ fillTranslateAnchor(
+ zoom(
+ interval(
+ stop(2, fillTranslateAnchor(FILL_TRANSLATE_ANCHOR_MAP))
+ )
+ )
+ )
+ );
+
+ // Verify
+ assertNotNull(layer.getFillTranslateAnchor());
+ assertNotNull(layer.getFillTranslateAnchor().getFunction());
+ assertEquals(CameraFunction.class, layer.getFillTranslateAnchor().getFunction().getClass());
+ assertEquals(IntervalStops.class, layer.getFillTranslateAnchor().getFunction().getStops().getClass());
+ assertEquals(1, ((IntervalStops) layer.getFillTranslateAnchor().getFunction().getStops()).size());
+ }
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new FillLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- // Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
+ @Test
+ public void testFillPatternAsConstant() {
+ checkViewIsDisplayed(R.id.mapView);
Timber.i("fill-pattern");
assertNotNull(layer);
@@ -278,6 +586,31 @@ public class FillLayerTest extends BaseStyleTest {
assertEquals((String) layer.getFillPattern().getValue(), (String) "pedestrian-polygon");
}
+ @Test
+ public void testFillPatternAsCameraFunction() {
+ checkViewIsDisplayed(R.id.mapView);
+ Timber.i("fill-pattern");
+ assertNotNull(layer);
+
+ // Set
+ layer.setProperties(
+ fillPattern(
+ zoom(
+ interval(
+ stop(2, fillPattern("pedestrian-polygon"))
+ )
+ )
+ )
+ );
+
+ // Verify
+ assertNotNull(layer.getFillPattern());
+ assertNotNull(layer.getFillPattern().getFunction());
+ assertEquals(CameraFunction.class, layer.getFillPattern().getFunction().getClass());
+ assertEquals(IntervalStops.class, layer.getFillPattern().getFunction().getStops().getClass());
+ assertEquals(1, ((IntervalStops) layer.getFillPattern().getFunction().getStops()).size());
+ }
+
@After
public void unregisterIntentServiceIdlingResource() {