summaryrefslogtreecommitdiff
path: root/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/BackgroundLayerTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/BackgroundLayerTest.java')
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/BackgroundLayerTest.java256
1 files changed, 135 insertions, 121 deletions
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/BackgroundLayerTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/BackgroundLayerTest.java
index 851660f06e..50f2fa7d62 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/BackgroundLayerTest.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/BackgroundLayerTest.java
@@ -3,42 +3,34 @@
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.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.layers.BackgroundLayer;
-import com.mapbox.mapboxsdk.testapp.R;
-import com.mapbox.mapboxsdk.testapp.activity.style.RuntimeStyleTestActivity;
-import com.mapbox.mapboxsdk.testapp.utils.OnMapReadyIdlingResource;
+import com.mapbox.mapboxsdk.style.layers.TransitionOptions;
import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest;
+import com.mapbox.mapboxsdk.testapp.activity.espresso.EspressoTestActivity;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Rule;
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 org.junit.Assert.*;
-import static com.mapbox.mapboxsdk.style.layers.Property.*;
-import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*;
+import timber.log.Timber;
-import com.mapbox.mapboxsdk.style.layers.TransitionOptions;
-import com.mapbox.mapboxsdk.testapp.activity.espresso.EspressoTestActivity;
+import static com.mapbox.mapboxsdk.style.functions.Function.zoom;
+import static com.mapbox.mapboxsdk.style.functions.stops.Stop.stop;
+import static com.mapbox.mapboxsdk.style.functions.stops.Stops.exponential;
+import static com.mapbox.mapboxsdk.style.functions.stops.Stops.interval;
+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.backgroundColor;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.backgroundOpacity;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.backgroundPattern;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.visibility;
+import static com.mapbox.mapboxsdk.testapp.action.MapboxMapAction.invoke;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
/**
* Basic smoke tests for BackgroundLayer
@@ -53,9 +45,9 @@ public class BackgroundLayerTest extends BaseActivityTest {
return EspressoTestActivity.class;
}
- private void setupLayer(){
+ private void setupLayer() {
Timber.i("Retrieving layer");
- layer = mapboxMap.getLayerAs("background");
+ invoke(mapboxMap, (uiController, mapboxMap) -> layer = mapboxMap.getLayerAs("background"));
}
@Test
@@ -63,14 +55,16 @@ public class BackgroundLayerTest extends BaseActivityTest {
validateTestSetup();
setupLayer();
Timber.i("Visibility");
- 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);
+ });
}
@Test
@@ -78,12 +72,14 @@ public class BackgroundLayerTest extends BaseActivityTest {
validateTestSetup();
setupLayer();
Timber.i("background-colorTransitionOptions");
- assertNotNull(layer);
-
- // Set and Get
- TransitionOptions options = new TransitionOptions(300, 100);
- layer.setBackgroundColorTransition(options);
- assertEquals(layer.getBackgroundColorTransition(), options);
+ invoke(mapboxMap, (uiController, mapboxMap) -> {
+ assertNotNull(layer);
+
+ // Set and Get
+ TransitionOptions options = new TransitionOptions(300, 100);
+ layer.setBackgroundColorTransition(options);
+ assertEquals(layer.getBackgroundColorTransition(), options);
+ });
}
@Test
@@ -91,11 +87,13 @@ public class BackgroundLayerTest extends BaseActivityTest {
validateTestSetup();
setupLayer();
Timber.i("background-color");
- assertNotNull(layer);
+ invoke(mapboxMap, (uiController, mapboxMap) -> {
+ assertNotNull(layer);
- // Set and Get
- layer.setProperties(backgroundColor("rgba(0, 0, 0, 1)"));
- assertEquals((String) layer.getBackgroundColor().getValue(), (String) "rgba(0, 0, 0, 1)");
+ // Set and Get
+ layer.setProperties(backgroundColor("rgba(0, 0, 0, 1)"));
+ assertEquals((String) layer.getBackgroundColor().getValue(), (String) "rgba(0, 0, 0, 1)");
+ });
}
@Test
@@ -103,26 +101,28 @@ public class BackgroundLayerTest extends BaseActivityTest {
validateTestSetup();
setupLayer();
Timber.i("background-color");
- assertNotNull(layer);
-
- // Set
- layer.setProperties(
- backgroundColor(
- zoom(
- exponential(
- stop(2, backgroundColor("rgba(0, 0, 0, 1)"))
- ).withBase(0.5f)
+ invoke(mapboxMap, (uiController, mapboxMap) -> {
+ assertNotNull(layer);
+
+ // Set
+ layer.setProperties(
+ backgroundColor(
+ zoom(
+ exponential(
+ stop(2, backgroundColor("rgba(0, 0, 0, 1)"))
+ ).withBase(0.5f)
+ )
)
- )
- );
-
- // Verify
- assertNotNull(layer.getBackgroundColor());
- assertNotNull(layer.getBackgroundColor().getFunction());
- assertEquals(CameraFunction.class, layer.getBackgroundColor().getFunction().getClass());
- assertEquals(ExponentialStops.class, layer.getBackgroundColor().getFunction().getStops().getClass());
- assertEquals(0.5f, ((ExponentialStops) layer.getBackgroundColor().getFunction().getStops()).getBase(), 0.001);
- assertEquals(1, ((ExponentialStops) layer.getBackgroundColor().getFunction().getStops()).size());
+ );
+
+ // Verify
+ assertNotNull(layer.getBackgroundColor());
+ assertNotNull(layer.getBackgroundColor().getFunction());
+ assertEquals(CameraFunction.class, layer.getBackgroundColor().getFunction().getClass());
+ assertEquals(ExponentialStops.class, layer.getBackgroundColor().getFunction().getStops().getClass());
+ assertEquals(0.5f, ((ExponentialStops) layer.getBackgroundColor().getFunction().getStops()).getBase(), 0.001);
+ assertEquals(1, ((ExponentialStops) layer.getBackgroundColor().getFunction().getStops()).size());
+ });
}
@Test
@@ -130,11 +130,13 @@ public class BackgroundLayerTest extends BaseActivityTest {
validateTestSetup();
setupLayer();
Timber.i("background-color");
- assertNotNull(layer);
+ invoke(mapboxMap, (uiController, mapboxMap) -> {
+ assertNotNull(layer);
- // Set and Get
- layer.setProperties(backgroundColor(Color.RED));
- assertEquals(layer.getBackgroundColorAsInt(), Color.RED);
+ // Set and Get
+ layer.setProperties(backgroundColor(Color.RED));
+ assertEquals(layer.getBackgroundColorAsInt(), Color.RED);
+ });
}
@Test
@@ -142,12 +144,14 @@ public class BackgroundLayerTest extends BaseActivityTest {
validateTestSetup();
setupLayer();
Timber.i("background-patternTransitionOptions");
- assertNotNull(layer);
-
- // Set and Get
- TransitionOptions options = new TransitionOptions(300, 100);
- layer.setBackgroundPatternTransition(options);
- assertEquals(layer.getBackgroundPatternTransition(), options);
+ invoke(mapboxMap, (uiController, mapboxMap) -> {
+ assertNotNull(layer);
+
+ // Set and Get
+ TransitionOptions options = new TransitionOptions(300, 100);
+ layer.setBackgroundPatternTransition(options);
+ assertEquals(layer.getBackgroundPatternTransition(), options);
+ });
}
@Test
@@ -155,11 +159,13 @@ public class BackgroundLayerTest extends BaseActivityTest {
validateTestSetup();
setupLayer();
Timber.i("background-pattern");
- assertNotNull(layer);
+ invoke(mapboxMap, (uiController, mapboxMap) -> {
+ assertNotNull(layer);
- // Set and Get
- layer.setProperties(backgroundPattern("pedestrian-polygon"));
- assertEquals((String) layer.getBackgroundPattern().getValue(), (String) "pedestrian-polygon");
+ // Set and Get
+ layer.setProperties(backgroundPattern("pedestrian-polygon"));
+ assertEquals((String) layer.getBackgroundPattern().getValue(), (String) "pedestrian-polygon");
+ });
}
@Test
@@ -167,25 +173,27 @@ public class BackgroundLayerTest extends BaseActivityTest {
validateTestSetup();
setupLayer();
Timber.i("background-pattern");
- assertNotNull(layer);
-
- // Set
- layer.setProperties(
- backgroundPattern(
- zoom(
- interval(
- stop(2, backgroundPattern("pedestrian-polygon"))
+ invoke(mapboxMap, (uiController, mapboxMap) -> {
+ assertNotNull(layer);
+
+ // Set
+ layer.setProperties(
+ backgroundPattern(
+ zoom(
+ interval(
+ stop(2, backgroundPattern("pedestrian-polygon"))
+ )
)
)
- )
- );
-
- // Verify
- assertNotNull(layer.getBackgroundPattern());
- assertNotNull(layer.getBackgroundPattern().getFunction());
- assertEquals(CameraFunction.class, layer.getBackgroundPattern().getFunction().getClass());
- assertEquals(IntervalStops.class, layer.getBackgroundPattern().getFunction().getStops().getClass());
- assertEquals(1, ((IntervalStops) layer.getBackgroundPattern().getFunction().getStops()).size());
+ );
+
+ // Verify
+ assertNotNull(layer.getBackgroundPattern());
+ assertNotNull(layer.getBackgroundPattern().getFunction());
+ assertEquals(CameraFunction.class, layer.getBackgroundPattern().getFunction().getClass());
+ assertEquals(IntervalStops.class, layer.getBackgroundPattern().getFunction().getStops().getClass());
+ assertEquals(1, ((IntervalStops) layer.getBackgroundPattern().getFunction().getStops()).size());
+ });
}
@Test
@@ -193,12 +201,14 @@ public class BackgroundLayerTest extends BaseActivityTest {
validateTestSetup();
setupLayer();
Timber.i("background-opacityTransitionOptions");
- assertNotNull(layer);
-
- // Set and Get
- TransitionOptions options = new TransitionOptions(300, 100);
- layer.setBackgroundOpacityTransition(options);
- assertEquals(layer.getBackgroundOpacityTransition(), options);
+ invoke(mapboxMap, (uiController, mapboxMap) -> {
+ assertNotNull(layer);
+
+ // Set and Get
+ TransitionOptions options = new TransitionOptions(300, 100);
+ layer.setBackgroundOpacityTransition(options);
+ assertEquals(layer.getBackgroundOpacityTransition(), options);
+ });
}
@Test
@@ -206,11 +216,13 @@ public class BackgroundLayerTest extends BaseActivityTest {
validateTestSetup();
setupLayer();
Timber.i("background-opacity");
- assertNotNull(layer);
+ invoke(mapboxMap, (uiController, mapboxMap) -> {
+ assertNotNull(layer);
- // Set and Get
- layer.setProperties(backgroundOpacity(0.3f));
- assertEquals((Float) layer.getBackgroundOpacity().getValue(), (Float) 0.3f);
+ // Set and Get
+ layer.setProperties(backgroundOpacity(0.3f));
+ assertEquals((Float) layer.getBackgroundOpacity().getValue(), (Float) 0.3f);
+ });
}
@Test
@@ -218,26 +230,28 @@ public class BackgroundLayerTest extends BaseActivityTest {
validateTestSetup();
setupLayer();
Timber.i("background-opacity");
- assertNotNull(layer);
-
- // Set
- layer.setProperties(
- backgroundOpacity(
- zoom(
- exponential(
- stop(2, backgroundOpacity(0.3f))
- ).withBase(0.5f)
+ invoke(mapboxMap, (uiController, mapboxMap) -> {
+ assertNotNull(layer);
+
+ // Set
+ layer.setProperties(
+ backgroundOpacity(
+ zoom(
+ exponential(
+ stop(2, backgroundOpacity(0.3f))
+ ).withBase(0.5f)
+ )
)
- )
- );
-
- // Verify
- assertNotNull(layer.getBackgroundOpacity());
- assertNotNull(layer.getBackgroundOpacity().getFunction());
- assertEquals(CameraFunction.class, layer.getBackgroundOpacity().getFunction().getClass());
- assertEquals(ExponentialStops.class, layer.getBackgroundOpacity().getFunction().getStops().getClass());
- assertEquals(0.5f, ((ExponentialStops) layer.getBackgroundOpacity().getFunction().getStops()).getBase(), 0.001);
- assertEquals(1, ((ExponentialStops) layer.getBackgroundOpacity().getFunction().getStops()).size());
+ );
+
+ // Verify
+ assertNotNull(layer.getBackgroundOpacity());
+ assertNotNull(layer.getBackgroundOpacity().getFunction());
+ assertEquals(CameraFunction.class, layer.getBackgroundOpacity().getFunction().getClass());
+ assertEquals(ExponentialStops.class, layer.getBackgroundOpacity().getFunction().getStops().getClass());
+ assertEquals(0.5f, ((ExponentialStops) layer.getBackgroundOpacity().getFunction().getStops()).getBase(), 0.001);
+ assertEquals(1, ((ExponentialStops) layer.getBackgroundOpacity().getFunction().getStops()).size());
+ });
}
}