summaryrefslogtreecommitdiff
path: root/platform/android/MapboxGLAndroidSDKTestApp/src
diff options
context:
space:
mode:
authorIvo van Dongen <info@ivovandongen.nl>2017-02-24 17:18:26 +0200
committerIvo van Dongen <ivovandongen@users.noreply.github.com>2017-02-28 09:33:04 -0800
commitdc21396d71ea28b736ee6fb3dcd476fed80fbd5d (patch)
tree7ffda504ae73e9ddb4998e8290601bba5ddcfa9f /platform/android/MapboxGLAndroidSDKTestApp/src
parent3040d407723ed8a8e2dfa27ad0ba49f534772342 (diff)
downloadqtlocation-mapboxgl-dc21396d71ea28b736ee6fb3dcd476fed80fbd5d.tar.gz
[android] insert layer above
Diffstat (limited to 'platform/android/MapboxGLAndroidSDKTestApp/src')
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/RuntimeStyleTests.java43
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/customlayer/CustomLayerActivity.java2
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/CircleLayerActivity.java2
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/CustomSpriteActivity.java2
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/RuntimeStyleActivity.java3
5 files changed, 44 insertions, 8 deletions
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/RuntimeStyleTests.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/RuntimeStyleTests.java
index cda4b62d58..2014208fcf 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/RuntimeStyleTests.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/RuntimeStyleTests.java
@@ -11,6 +11,7 @@ import android.view.View;
import com.mapbox.mapboxsdk.maps.MapboxMap;
import com.mapbox.mapboxsdk.style.layers.CannotAddLayerException;
+import com.mapbox.mapboxsdk.style.layers.CircleLayer;
import com.mapbox.mapboxsdk.style.layers.FillLayer;
import com.mapbox.mapboxsdk.style.layers.Layer;
import com.mapbox.mapboxsdk.style.layers.Property;
@@ -37,10 +38,11 @@ import java.util.List;
import static android.support.test.espresso.Espresso.onView;
import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed;
import static android.support.test.espresso.matcher.ViewMatchers.withId;
-import static junit.framework.Assert.assertTrue;
-import static junit.framework.Assert.fail;
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
/**
* Basic smoke tests for Layer and Source
@@ -86,6 +88,41 @@ public class RuntimeStyleTests {
}
@Test
+ public void testAddLayerAbove() {
+ ViewUtils.checkViewIsDisplayed(R.id.mapView);
+ onView(withId(R.id.mapView)).perform(new BaseViewAction() {
+ @Override
+ public void perform(UiController uiController, View view) {
+ MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
+
+ List<Layer> layers = mapboxMap.getLayers();
+ Source source = mapboxMap.getSources().get(0);
+
+ // Test inserting with invalid above-id
+ try {
+ mapboxMap.addLayerAbove(new CircleLayer("invalid-id-layer-test", source.getId()), "no-such-layer-here-man");
+ fail("Should have thrown exception");
+ } catch (CannotAddLayerException ex) {
+ // Yeah
+ assertNotNull(ex.getMessage());
+ }
+
+ // Insert as last
+ CircleLayer last = new CircleLayer("this is the last one", source.getId());
+ mapboxMap.addLayerAbove(last, layers.get(layers.size() - 1).getId());
+ layers = mapboxMap.getLayers();
+ assertEquals(last.getId(), layers.get(layers.size() - 1).getId());
+
+ // Insert
+ CircleLayer second = new CircleLayer("this is the second one", source.getId());
+ mapboxMap.addLayerAbove(second, layers.get(0).getId());
+ layers = mapboxMap.getLayers();
+ assertEquals(second.getId(), layers.get(1).getId());
+ }
+ });
+ }
+
+ @Test
public void testListSources() {
ViewUtils.checkViewIsDisplayed(R.id.mapView);
onView(withId(R.id.mapView)).perform(new BaseViewAction() {
@@ -97,7 +134,7 @@ public class RuntimeStyleTests {
List<Source> sources = mapboxMap.getSources();
assertNotNull(sources);
assertTrue(sources.size() > 0);
- for (Source source: sources) {
+ for (Source source : sources) {
assertNotNull(source);
}
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/customlayer/CustomLayerActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/customlayer/CustomLayerActivity.java
index 2f445b2c37..dde22db2db 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/customlayer/CustomLayerActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/customlayer/CustomLayerActivity.java
@@ -70,7 +70,7 @@ public class CustomLayerActivity extends AppCompatActivity {
ExampleCustomLayer.InitializeFunction,
ExampleCustomLayer.RenderFunction,
ExampleCustomLayer.DeinitializeFunction);
- mapboxMap.addLayer(customLayer, "building");
+ mapboxMap.addLayerBelow(customLayer, "building");
fab.setImageResource(R.drawable.ic_layers_clear);
}
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/CircleLayerActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/CircleLayerActivity.java
index 7c3afd387e..ebf1fc4fdf 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/CircleLayerActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/CircleLayerActivity.java
@@ -91,7 +91,7 @@ public class CircleLayerActivity extends AppCompatActivity {
Timber.e("That's not an url... ", malformedUrlException);
}
LineLayer lineLayer = new LineLayer("route_layer", "bus_route");
- mapboxMap.addLayer(lineLayer, "stops_layer");
+ mapboxMap.addLayerBelow(lineLayer, "stops_layer");
// move camera to start route
mapboxMap.animateCamera(CameraUpdateFactory.newCameraPosition(
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/CustomSpriteActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/CustomSpriteActivity.java
index 36bfc44057..3763b45e7a 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/CustomSpriteActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/CustomSpriteActivity.java
@@ -77,7 +77,7 @@ public class CustomSpriteActivity extends AppCompatActivity {
);
// lets add a circle below labels!
- mapboxMap.addLayer(layer, "waterway-label");
+ mapboxMap.addLayerBelow(layer, "waterway-label");
fab.setImageResource(R.drawable.ic_directions_car_black);
} else {
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/RuntimeStyleActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/RuntimeStyleActivity.java
index cd50dc2f00..af42b7a0fe 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/RuntimeStyleActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/RuntimeStyleActivity.java
@@ -40,7 +40,6 @@ import java.io.Reader;
import java.io.StringWriter;
import java.io.Writer;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.List;
import timber.log.Timber;
@@ -302,7 +301,7 @@ public class RuntimeStyleActivity extends AppCompatActivity {
// Only show me parks (except westerpark with stroke-width == 3)
layer.setFilter(all(eq("type", "park"), eq("stroke-width", 2)));
- mapboxMap.addLayer(layer, "building");
+ mapboxMap.addLayerBelow(layer, "building");
// layer.setPaintProperty(fillColor(Color.RED)); // XXX But not after the object is attached
// Or get the object later and set it. It's all good.