summaryrefslogtreecommitdiff
path: root/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/RuntimeStyleTests.java
diff options
context:
space:
mode:
authorTobrun <tobrun.van.nuland@gmail.com>2016-11-09 12:56:49 +0100
committerGitHub <noreply@github.com>2016-11-09 12:56:49 +0100
commit33aa14c939cec4b732151b2f864ad84e41cbacd3 (patch)
treeea3917fa1b7924f935e444775c47b3577a29a870 /platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/RuntimeStyleTests.java
parent2411ec83b12fd2457f6f22fe5a4de9122503a2e2 (diff)
downloadqtlocation-mapboxgl-33aa14c939cec4b732151b2f864ad84e41cbacd3.tar.gz
[android] - instrumentation tests upgrade, move view checking to utility class, remove inheritance in runtime style test (#6803)
update gitignore for generated tests add camera move test add realtime geojson to be excluded when generating Activity sanity tests by default show workaround for showing a MapView in a dialog add annotation tests remove older camera tests, introduce tests for move, ease and animate, bring back setLatLng and getLatLng on MapView, add tests for internal camera API. compass view tests add tests for attribution and logo. fix annotation tests Rename Actiivity test class, split up annotation tests, added MarkerView tests, added infowindow tests, added MyLocationView tests fix addRemoveLayer test by integrating map interactions inside a ViewAction
Diffstat (limited to 'platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/RuntimeStyleTests.java')
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/RuntimeStyleTests.java88
1 files changed, 54 insertions, 34 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 783601b1dd..f9ee324ead 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
@@ -1,8 +1,11 @@
package com.mapbox.mapboxsdk.testapp.style;
import android.support.test.espresso.Espresso;
+import android.support.test.espresso.UiController;
+import android.support.test.espresso.ViewAction;
import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;
+import android.view.View;
import com.mapbox.mapboxsdk.maps.MapboxMap;
import com.mapbox.mapboxsdk.style.layers.FillLayer;
@@ -14,7 +17,9 @@ import com.mapbox.mapboxsdk.style.sources.VectorSource;
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.testapp.utils.ViewUtils;
+import org.hamcrest.Matcher;
import org.junit.After;
import org.junit.Before;
import org.junit.Ignore;
@@ -22,6 +27,9 @@ import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
+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 org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
@@ -31,7 +39,7 @@ import static org.junit.Assert.assertTrue;
* Basic smoke tests for Layer and Source
*/
@RunWith(AndroidJUnit4.class)
-public class RuntimeStyleTests extends BaseStyleTest {
+public class RuntimeStyleTests {
@Rule
public final ActivityTestRule<RuntimeStyleTestActivity> rule = new ActivityTestRule<>(RuntimeStyleTestActivity.class);
@@ -44,45 +52,15 @@ public class RuntimeStyleTests extends BaseStyleTest {
Espresso.registerIdlingResources(idlingResource);
}
- /**
- * TODO fix failing test
- */
@Test
- @Ignore
public void testGetAddRemoveLayer() {
- checkViewIsDisplayed(R.id.mapView);
-
- MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
-
- //Get initial
- assertNotNull(mapboxMap.getLayer("building"));
-
- //Remove
- try {
- mapboxMap.removeLayer("building");
- } catch (NoSuchLayerException e) {
- assertFalse(true);
- }
- assertNull(mapboxMap.getLayer("building"));
-
- //Add
- FillLayer layer = new FillLayer("building", "composite");
- layer.setSourceLayer("building");
- mapboxMap.addLayer(layer);
-
- assertNotNull(mapboxMap.getLayer("building"));
-
- try {
- layer.setProperties(PropertyFactory.visibility(Property.VISIBLE));
- assertTrue("Never reached as the reference is invalid after adding", false);
- } catch (Exception e) {
- //Expected, reference is no longer valid
- }
+ ViewUtils.checkViewIsDisplayed(R.id.mapView);
+ onView(withId(R.id.mapView)).perform(new AddRemoveLayerAction());
}
@Test
public void testAddRemoveSource() {
- checkViewIsDisplayed(R.id.mapView);
+ ViewUtils.checkViewIsDisplayed(R.id.mapView);
MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
mapboxMap.addSource(new VectorSource("my-source", "mapbox://mapbox.mapbox-terrain-v2"));
@@ -93,6 +71,48 @@ public class RuntimeStyleTests extends BaseStyleTest {
}
}
+ private class AddRemoveLayerAction implements ViewAction {
+
+ @Override
+ public Matcher<View> getConstraints() {
+ return isDisplayed();
+ }
+
+ @Override
+ public String getDescription() {
+ return getClass().getSimpleName();
+ }
+
+ @Override
+ public void perform(UiController uiController, View view) {
+ MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
+
+ //Get initial
+ assertNotNull(mapboxMap.getLayer("building"));
+
+ //Remove
+ try {
+ mapboxMap.removeLayer("building");
+ } catch (NoSuchLayerException e) {
+ assertFalse(true);
+ }
+ assertNull(mapboxMap.getLayer("building"));
+
+ //Add
+ FillLayer layer = new FillLayer("building", "composite");
+ layer.setSourceLayer("building");
+ mapboxMap.addLayer(layer);
+ assertNotNull(mapboxMap.getLayer("building"));
+
+ try {
+ layer.setProperties(PropertyFactory.visibility(Property.VISIBLE));
+ assertTrue("Never reached as the reference is invalid after adding", false);
+ } catch (Exception e) {
+ //Expected, reference is no longer valid
+ }
+ }
+ }
+
@After
public void unregisterIntentServiceIdlingResource() {
Espresso.unregisterIdlingResources(idlingResource);