From e0a5365a70369530d8a0cedf9ce8cf524c7a6be3 Mon Sep 17 00:00:00 2001
From: Tobrun Van Nuland
Date: Wed, 5 Apr 2017 21:58:36 +0200
Subject: [android] - rework instrumentation tests
---
.../com/mapbox/mapboxsdk/maps/MapboxMapTest.java | 165 ++-----
.../testapp/activity/BaseActivityTest.java | 56 +++
.../mapboxsdk/testapp/activity/activity.junit.ejs | 2 +-
.../mapboxsdk/testapp/annotations/MarkerTest.java | 34 +-
.../testapp/annotations/MarkerViewTest.java | 31 +-
.../mapboxsdk/testapp/annotations/PolygonTest.java | 26 +-
.../testapp/annotations/PolylineTest.java | 29 +-
.../testapp/camera/CameraAnimateTest.java | 47 +-
.../mapboxsdk/testapp/camera/CameraEaseTest.java | 47 +-
.../testapp/camera/CameraInternalApiTest.java | 30 +-
.../mapboxsdk/testapp/camera/CameraMoveTest.java | 53 +--
.../feature/QueryRenderedFeaturesBoxCountTest.java | 28 +-
.../QueryRenderedFeaturesHighlightTest.java | 36 +-
.../QueryRenderedFeaturesPropertiesTest.java | 22 +-
.../feature/QueryRenderedSymbolBoxCountTest.java | 29 +-
.../testapp/maps/widgets/AttributionTest.java | 31 +-
.../testapp/maps/widgets/CompassViewTest.java | 38 +-
.../mapboxsdk/testapp/maps/widgets/LogoTest.java | 31 +-
.../testapp/maps/widgets/MyLocationViewTest.java | 26 +-
.../testapp/style/BackgroundLayerTest.java | 58 +--
.../mapboxsdk/testapp/style/BaseStyleTest.java | 41 +-
.../mapboxsdk/testapp/style/CircleLayerTest.java | 196 +++++---
.../mapboxsdk/testapp/style/FillLayerTest.java | 121 +++--
.../testapp/style/GeoJsonSourceTests.java | 37 +-
.../mapboxsdk/testapp/style/LineLayerTest.java | 199 +++++---
.../mapboxsdk/testapp/style/RasterLayerTest.java | 91 ++--
.../mapboxsdk/testapp/style/RuntimeStyleTests.java | 53 +--
.../testapp/style/RuntimeStyleTimingTests.java | 30 +-
.../mapboxsdk/testapp/style/SymbolLayerTest.java | 530 +++++++++++++--------
.../mapbox/mapboxsdk/testapp/style/layer.junit.ejs | 58 +--
.../activity/storage/UrlTransformActivity.java | 2 +
platform/android/scripts/generate-test-code.js | 2 +-
32 files changed, 1059 insertions(+), 1120 deletions(-)
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/MapboxMapTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/MapboxMapTest.java
index c110935133..0aedf270ae 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/MapboxMapTest.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/MapboxMapTest.java
@@ -20,6 +20,7 @@ import com.mapbox.mapboxsdk.constants.MapboxConstants;
import com.mapbox.mapboxsdk.exceptions.InvalidMarkerPositionException;
import com.mapbox.mapboxsdk.geometry.LatLng;
import com.mapbox.mapboxsdk.testapp.R;
+import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest;
import com.mapbox.mapboxsdk.testapp.activity.espresso.EspressoTestActivity;
import com.mapbox.mapboxsdk.testapp.utils.OnMapReadyIdlingResource;
import com.mapbox.mapboxsdk.testapp.utils.TestConstants;
@@ -52,26 +53,16 @@ import static org.junit.Assert.assertTrue;
* with the application UI-thread.
*
*/
-public class MapboxMapTest {
+public class MapboxMapTest extends BaseActivityTest {
- @Rule
- public final ActivityTestRule rule = new ActivityTestRule<>(EspressoTestActivity.class);
-
- private OnMapReadyIdlingResource idlingResource;
- private EspressoTestActivity activity;
-
- @Before
- public void beforeTest() {
- activity = rule.getActivity();
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- idlingResource = new OnMapReadyIdlingResource(activity);
- Espresso.registerIdlingResources(idlingResource);
+ @Override
+ protected Class getActivityClass() {
+ return EspressoTestActivity.class;
}
@Test
public void testSanity() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- MapboxMap mapboxMap = activity.getMapboxMap();
+ validateTestSetup();
assertNotNull("mapboxMap should not be null", mapboxMap);
}
@@ -81,8 +72,7 @@ public class MapboxMapTest {
@Test
public void testTransitionDuration() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- final MapboxMap mapboxMap = activity.getMapboxMap();
+ validateTestSetup();
onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
@Override
public void onViewAction(UiController uiController, View view) {
@@ -95,8 +85,7 @@ public class MapboxMapTest {
@Test
public void testTransitionDelay() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- final MapboxMap mapboxMap = activity.getMapboxMap();
+ validateTestSetup();
onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
@Override
public void onViewAction(UiController uiController, View view) {
@@ -113,8 +102,7 @@ public class MapboxMapTest {
@Test
public void testMinZoom() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- final MapboxMap mapboxMap = activity.getMapboxMap();
+ validateTestSetup();
onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
@Override
public void onViewAction(UiController uiController, View view) {
@@ -126,8 +114,7 @@ public class MapboxMapTest {
@Test
public void testMaxZoom() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- final MapboxMap mapboxMap = activity.getMapboxMap();
+ validateTestSetup();
final double zoom = 10;
onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
@Override
@@ -141,8 +128,7 @@ public class MapboxMapTest {
@Test
@Ignore
public void testInitialZoomLevels() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- final MapboxMap mapboxMap = activity.getMapboxMap();
+ validateTestSetup();
onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
@Override
public void onViewAction(UiController uiController, View view) {
@@ -160,8 +146,7 @@ public class MapboxMapTest {
@Test
public void testTrackingSettings() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- MapboxMap mapboxMap = activity.getMapboxMap();
+ validateTestSetup();
assertNotNull("TrackingSettings should not be null", mapboxMap.getTrackingSettings());
}
@@ -171,8 +156,7 @@ public class MapboxMapTest {
@Test
public void testConcurrentInfoWindowEnabled() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- final MapboxMap mapboxMap = activity.getMapboxMap();
+ validateTestSetup();
onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
@Override
public void onViewAction(UiController uiController, View view) {
@@ -184,8 +168,7 @@ public class MapboxMapTest {
@Test
public void testConcurrentInfoWindowDisabled() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- final MapboxMap mapboxMap = activity.getMapboxMap();
+ validateTestSetup();
onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
@Override
public void onViewAction(UiController uiController, View view) {
@@ -197,8 +180,7 @@ public class MapboxMapTest {
@Test
public void testInfoWindowAdapter() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- final MapboxMap mapboxMap = activity.getMapboxMap();
+ validateTestSetup();
onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
@Override
public void onViewAction(UiController uiController, View view) {
@@ -222,8 +204,7 @@ public class MapboxMapTest {
@Test
@Ignore /* disabled due to enabling permissions during test #7177 */
public void testMyLocationEnabled() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- final MapboxMap mapboxMap = activity.getMapboxMap();
+ validateTestSetup();
onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
@Override
public void onViewAction(UiController uiController, View view) {
@@ -236,8 +217,7 @@ public class MapboxMapTest {
@Test
@Ignore /* can't create handler inside thread that not called Looper.prepare() */
public void testMyLocationDisabled() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- final MapboxMap mapboxMap = activity.getMapboxMap();
+ validateTestSetup();
onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
@Override
public void onViewAction(UiController uiController, View view) {
@@ -253,8 +233,7 @@ public class MapboxMapTest {
@Test
public void testFpsListener() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- final MapboxMap mapboxMap = activity.getMapboxMap();
+ validateTestSetup();
onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
@Override
public void onViewAction(UiController uiController, View view) {
@@ -272,8 +251,7 @@ public class MapboxMapTest {
@Test
public void testInfoWindowClickListener() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- final MapboxMap mapboxMap = activity.getMapboxMap();
+ validateTestSetup();
onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
@Override
public void onViewAction(UiController uiController, View view) {
@@ -291,8 +269,7 @@ public class MapboxMapTest {
@Test
public void testInfoWindowCloseListener() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- final MapboxMap mapboxMap = activity.getMapboxMap();
+ validateTestSetup();
onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
@Override
public void onViewAction(UiController uiController, View view) {
@@ -310,8 +287,7 @@ public class MapboxMapTest {
@Test
public void testInfoWindowLongClickListener() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- final MapboxMap mapboxMap = activity.getMapboxMap();
+ validateTestSetup();
onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
@Override
public void onViewAction(UiController uiController, View view) {
@@ -334,8 +310,7 @@ public class MapboxMapTest {
@Test
public void testAddMarker() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- final MapboxMap mapboxMap = activity.getMapboxMap();
+ validateTestSetup();
onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
@Override
public void onViewAction(UiController uiController, View view) {
@@ -353,8 +328,7 @@ public class MapboxMapTest {
@Test
public void testAddMarkers() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- final MapboxMap mapboxMap = activity.getMapboxMap();
+ validateTestSetup();
onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
@Override
public void onViewAction(UiController uiController, View view) {
@@ -373,8 +347,7 @@ public class MapboxMapTest {
@Test
public void testAddMarkersEmpty() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- final MapboxMap mapboxMap = activity.getMapboxMap();
+ validateTestSetup();
onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
@Override
public void onViewAction(UiController uiController, View view) {
@@ -387,8 +360,7 @@ public class MapboxMapTest {
@Test
public void testAddMarkersSingleMarker() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- final MapboxMap mapboxMap = activity.getMapboxMap();
+ validateTestSetup();
onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
@Override
public void onViewAction(UiController uiController, View view) {
@@ -404,8 +376,7 @@ public class MapboxMapTest {
@Test
public void testAddPolygon() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- final MapboxMap mapboxMap = activity.getMapboxMap();
+ validateTestSetup();
onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
@Override
public void onViewAction(UiController uiController, View view) {
@@ -418,8 +389,7 @@ public class MapboxMapTest {
@Test
public void testAddEmptyPolygon() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- final MapboxMap mapboxMap = activity.getMapboxMap();
+ validateTestSetup();
onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
@Override
public void onViewAction(UiController uiController, View view) {
@@ -432,8 +402,7 @@ public class MapboxMapTest {
@Test
public void testAddPolygons() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- final MapboxMap mapboxMap = activity.getMapboxMap();
+ validateTestSetup();
onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
@Override
public void onViewAction(UiController uiController, View view) {
@@ -455,8 +424,7 @@ public class MapboxMapTest {
@Test
public void addPolygonsEmpty() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- final MapboxMap mapboxMap = activity.getMapboxMap();
+ validateTestSetup();
onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
@Override
public void onViewAction(UiController uiController, View view) {
@@ -468,8 +436,7 @@ public class MapboxMapTest {
@Test
public void addPolygonsSingle() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- final MapboxMap mapboxMap = activity.getMapboxMap();
+ validateTestSetup();
onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
@Override
public void onViewAction(UiController uiController, View view) {
@@ -485,8 +452,7 @@ public class MapboxMapTest {
@Test
public void testAddPolyline() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- final MapboxMap mapboxMap = activity.getMapboxMap();
+ validateTestSetup();
onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
@Override
public void onViewAction(UiController uiController, View view) {
@@ -499,8 +465,7 @@ public class MapboxMapTest {
@Test
public void testAddEmptyPolyline() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- final MapboxMap mapboxMap = activity.getMapboxMap();
+ validateTestSetup();
onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
@Override
public void onViewAction(UiController uiController, View view) {
@@ -513,8 +478,7 @@ public class MapboxMapTest {
@Test
public void testAddPolylines() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- final MapboxMap mapboxMap = activity.getMapboxMap();
+ validateTestSetup();
onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
@Override
public void onViewAction(UiController uiController, View view) {
@@ -536,8 +500,7 @@ public class MapboxMapTest {
@Test
public void testAddPolylinesEmpty() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- final MapboxMap mapboxMap = activity.getMapboxMap();
+ validateTestSetup();
onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
@Override
public void onViewAction(UiController uiController, View view) {
@@ -549,8 +512,7 @@ public class MapboxMapTest {
@Test
public void testAddPolylinesSingle() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- final MapboxMap mapboxMap = activity.getMapboxMap();
+ validateTestSetup();
onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
@Override
public void onViewAction(UiController uiController, View view) {
@@ -566,8 +528,7 @@ public class MapboxMapTest {
@Test
public void testRemoveMarker() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- final MapboxMap mapboxMap = activity.getMapboxMap();
+ validateTestSetup();
onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
@Override
public void onViewAction(UiController uiController, View view) {
@@ -581,8 +542,7 @@ public class MapboxMapTest {
@Test
public void testRemovePolygon() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- final MapboxMap mapboxMap = activity.getMapboxMap();
+ validateTestSetup();
onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
@Override
public void onViewAction(UiController uiController, View view) {
@@ -596,8 +556,7 @@ public class MapboxMapTest {
@Test
public void testRemovePolyline() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- final MapboxMap mapboxMap = activity.getMapboxMap();
+ validateTestSetup();
onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
@Override
public void onViewAction(UiController uiController, View view) {
@@ -611,8 +570,7 @@ public class MapboxMapTest {
@Test
public void testRemoveAnnotation() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- final MapboxMap mapboxMap = activity.getMapboxMap();
+ validateTestSetup();
onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
@Override
public void onViewAction(UiController uiController, View view) {
@@ -626,8 +584,7 @@ public class MapboxMapTest {
@Test
public void testRemoveAnnotationById() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- final MapboxMap mapboxMap = activity.getMapboxMap();
+ validateTestSetup();
onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
@Override
public void onViewAction(UiController uiController, View view) {
@@ -642,8 +599,7 @@ public class MapboxMapTest {
@Test
public void testRemoveAnnotations() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- final MapboxMap mapboxMap = activity.getMapboxMap();
+ validateTestSetup();
onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
@Override
public void onViewAction(UiController uiController, View view) {
@@ -661,8 +617,7 @@ public class MapboxMapTest {
@Test
public void testClear() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- final MapboxMap mapboxMap = activity.getMapboxMap();
+ validateTestSetup();
onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
@Override
public void onViewAction(UiController uiController, View view) {
@@ -680,8 +635,7 @@ public class MapboxMapTest {
@Test
public void testRemoveAnnotationsByList() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- final MapboxMap mapboxMap = activity.getMapboxMap();
+ validateTestSetup();
onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
@Override
public void onViewAction(UiController uiController, View view) {
@@ -701,8 +655,7 @@ public class MapboxMapTest {
@Test
public void testGetAnnotationById() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- final MapboxMap mapboxMap = activity.getMapboxMap();
+ validateTestSetup();
onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
@Override
public void onViewAction(UiController uiController, View view) {
@@ -716,8 +669,7 @@ public class MapboxMapTest {
@Test
public void testGetAnnotations() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- final MapboxMap mapboxMap = activity.getMapboxMap();
+ validateTestSetup();
onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
@Override
public void onViewAction(UiController uiController, View view) {
@@ -728,8 +680,7 @@ public class MapboxMapTest {
@Test
public void testGetMarkers() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- final MapboxMap mapboxMap = activity.getMapboxMap();
+ validateTestSetup();
onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
@Override
public void onViewAction(UiController uiController, View view) {
@@ -740,8 +691,7 @@ public class MapboxMapTest {
@Test
public void testGetPolygons() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- final MapboxMap mapboxMap = activity.getMapboxMap();
+ validateTestSetup();
onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
@Override
public void onViewAction(UiController uiController, View view) {
@@ -752,8 +702,7 @@ public class MapboxMapTest {
@Test
public void testGetPolylines() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- final MapboxMap mapboxMap = activity.getMapboxMap();
+ validateTestSetup();
onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
@Override
public void onViewAction(UiController uiController, View view) {
@@ -764,8 +713,7 @@ public class MapboxMapTest {
@Test
public void testGetSelectedMarkers() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- final MapboxMap mapboxMap = activity.getMapboxMap();
+ validateTestSetup();
onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
@Override
public void onViewAction(UiController uiController, View view) {
@@ -776,8 +724,7 @@ public class MapboxMapTest {
@Test
public void testSelectMarker() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- final MapboxMap mapboxMap = activity.getMapboxMap();
+ validateTestSetup();
onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
@Override
public void onViewAction(UiController uiController, View view) {
@@ -791,8 +738,7 @@ public class MapboxMapTest {
@Test
public void testDeselectMarker() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- final MapboxMap mapboxMap = activity.getMapboxMap();
+ validateTestSetup();
onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
@Override
public void onViewAction(UiController uiController, View view) {
@@ -807,8 +753,7 @@ public class MapboxMapTest {
@Test
public void testDeselectMarkers() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- final MapboxMap mapboxMap = activity.getMapboxMap();
+ validateTestSetup();
onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
@Override
public void onViewAction(UiController uiController, View view) {
@@ -823,12 +768,6 @@ public class MapboxMapTest {
}));
}
- @After
- public void afterTest() {
- Timber.e("@After test: unregister idle resource");
- Espresso.unregisterIdlingResources(idlingResource);
- }
-
private class MapboxMapAction implements ViewAction {
private InvokeViewAction invokeViewAction;
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/BaseActivityTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/BaseActivityTest.java
index 2f51140cd1..8ed1148a98 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/BaseActivityTest.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/BaseActivityTest.java
@@ -1,17 +1,28 @@
package com.mapbox.mapboxsdk.testapp.activity;
import android.app.Activity;
+import android.content.Context;
+import android.net.ConnectivityManager;
+import android.net.NetworkInfo;
import android.support.test.espresso.Espresso;
import android.support.test.espresso.IdlingResourceTimeoutException;
+import android.support.test.espresso.UiController;
+import android.support.test.espresso.ViewAction;
import android.support.test.rule.ActivityTestRule;
+import android.view.View;
import timber.log.Timber;
+import com.mapbox.mapboxsdk.camera.CameraUpdate;
import com.mapbox.mapboxsdk.maps.MapboxMap;
import com.mapbox.mapboxsdk.testapp.R;
import com.mapbox.mapboxsdk.testapp.utils.OnMapReadyIdlingResource;
import com.mapbox.mapboxsdk.testapp.utils.ScreenshotUtil;
+import com.mapbox.mapboxsdk.testapp.utils.TestConstants;
+import junit.framework.Assert;
+
+import org.hamcrest.Matcher;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
@@ -46,6 +57,16 @@ public abstract class BaseActivityTest {
}
}
+ protected void validateTestSetup(){
+ checkViewIsDisplayed(R.id.mapView);
+ Assert.assertTrue("Device is not connected to the Internet.", isConnected(rule.getActivity()));
+ Assert.assertNotNull(mapboxMap);
+ }
+
+ protected MapboxMap getMapboxMap() {
+ return mapboxMap;
+ }
+
protected abstract Class getActivityClass();
protected void checkViewIsDisplayed(int id) {
@@ -53,6 +74,10 @@ public abstract class BaseActivityTest {
.check(matches(isDisplayed()));
}
+ protected void waitLoop(){
+ onView(withId(R.id.mapView)).perform(new LoopAction(100));
+ }
+
protected void takeScreenshot(final String name) {
final Activity activity = rule.getActivity();
activity.runOnUiThread(new Runnable() {
@@ -63,10 +88,41 @@ public abstract class BaseActivityTest {
});
}
+ static boolean isConnected(Context context) {
+ ConnectivityManager connectivityManager
+ = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
+ NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo();
+ return activeNetworkInfo != null && activeNetworkInfo.isConnected();
+ }
+
@After
public void afterTest() {
Timber.e("@After test: unregister idle resource");
Espresso.unregisterIdlingResources(idlingResource);
}
+
+ private class LoopAction implements ViewAction {
+
+ private long loopTime;
+
+ public LoopAction(long loopTime) {
+ this.loopTime = loopTime;
+ }
+
+ @Override
+ public Matcher getConstraints() {
+ return isDisplayed();
+ }
+
+ @Override
+ public String getDescription() {
+ return getClass().getSimpleName();
+ }
+
+ @Override
+ public void perform(UiController uiController, View view) {
+ uiController.loopMainThreadForAtLeast(loopTime);
+ }
+ }
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/activity.junit.ejs b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/activity.junit.ejs
index 3e3ef36c39..03d4de17f4 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/activity.junit.ejs
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/activity.junit.ejs
@@ -27,7 +27,7 @@ public class <%- activity %>Test extends BaseActivityTest {
@Test
public void testSanity() {
- onView(withId(R.id.mapView)).check(matches(isDisplayed()));
+ validateTestSetup();
}
@Override
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/annotations/MarkerTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/annotations/MarkerTest.java
index 77025c8fa5..08e66c5b2f 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/annotations/MarkerTest.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/annotations/MarkerTest.java
@@ -1,9 +1,8 @@
package com.mapbox.mapboxsdk.testapp.annotations;
-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.annotations.Marker;
@@ -11,17 +10,15 @@ import com.mapbox.mapboxsdk.annotations.MarkerOptions;
import com.mapbox.mapboxsdk.geometry.LatLng;
import com.mapbox.mapboxsdk.maps.MapboxMap;
import com.mapbox.mapboxsdk.testapp.R;
+import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest;
import com.mapbox.mapboxsdk.testapp.activity.espresso.EspressoTestActivity;
import com.mapbox.mapboxsdk.testapp.utils.OnMapReadyIdlingResource;
import com.mapbox.mapboxsdk.testapp.utils.TestConstants;
-import com.mapbox.mapboxsdk.testapp.utils.ViewUtils;
import org.hamcrest.Matcher;
-import org.junit.After;
-import org.junit.Before;
import org.junit.Ignore;
-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.assertion.ViewAssertions.matches;
@@ -30,25 +27,19 @@ import static android.support.test.espresso.matcher.ViewMatchers.withId;
import static android.support.test.espresso.matcher.ViewMatchers.withText;
import static org.junit.Assert.assertEquals;
-public class MarkerTest {
+public class MarkerTest extends BaseActivityTest{
- @Rule
- public final ActivityTestRule rule = new ActivityTestRule<>(EspressoTestActivity.class);
-
- private OnMapReadyIdlingResource idlingResource;
private Marker marker;
- @Before
- public void registerIdlingResource() {
- idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
- Espresso.registerIdlingResources(idlingResource);
+ @Override
+ protected Class getActivityClass() {
+ return EspressoTestActivity.class;
}
@Test
@Ignore
public void addMarkerTest() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
+ validateTestSetup();
assertEquals("Markers should be empty", 0, mapboxMap.getMarkers().size());
MarkerOptions options = new MarkerOptions();
@@ -69,8 +60,7 @@ public class MarkerTest {
@Test
@Ignore
public void showInfoWindowTest() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
+ validateTestSetup();
final MarkerOptions options = new MarkerOptions();
options.setPosition(new LatLng());
@@ -133,10 +123,4 @@ public class MarkerTest {
}
}
-
-
- @After
- public void unregisterIdlingResource() {
- Espresso.unregisterIdlingResources(idlingResource);
- }
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/annotations/MarkerViewTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/annotations/MarkerViewTest.java
index 9351ed1c10..5edff31842 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/annotations/MarkerViewTest.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/annotations/MarkerViewTest.java
@@ -1,27 +1,22 @@
package com.mapbox.mapboxsdk.testapp.annotations;
-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.view.View;
import com.mapbox.mapboxsdk.annotations.Marker;
import com.mapbox.mapboxsdk.geometry.LatLng;
import com.mapbox.mapboxsdk.maps.MapboxMap;
import com.mapbox.mapboxsdk.testapp.R;
+import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest;
import com.mapbox.mapboxsdk.testapp.activity.annotation.MarkerViewActivity;
import com.mapbox.mapboxsdk.testapp.activity.espresso.EspressoTestActivity;
import com.mapbox.mapboxsdk.testapp.model.annotations.TextMarkerViewOptions;
-import com.mapbox.mapboxsdk.testapp.utils.OnMapReadyIdlingResource;
import com.mapbox.mapboxsdk.testapp.utils.TestConstants;
import com.mapbox.mapboxsdk.testapp.utils.ViewUtils;
import org.hamcrest.Matcher;
-import org.junit.After;
-import org.junit.Before;
import org.junit.Ignore;
-import org.junit.Rule;
import org.junit.Test;
import static android.support.test.espresso.Espresso.onView;
@@ -31,25 +26,19 @@ import static android.support.test.espresso.matcher.ViewMatchers.withId;
import static android.support.test.espresso.matcher.ViewMatchers.withText;
import static org.junit.Assert.assertEquals;
-public class MarkerViewTest {
+public class MarkerViewTest extends BaseActivityTest {
- @Rule
- public final ActivityTestRule rule = new ActivityTestRule<>(EspressoTestActivity.class);
-
- private OnMapReadyIdlingResource idlingResource;
private Marker marker;
- @Before
- public void registerIdlingResource() {
- idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
- Espresso.registerIdlingResources(idlingResource);
+ @Override
+ protected Class getActivityClass() {
+ return EspressoTestActivity.class;
}
@Test
@Ignore
public void addMarkerViewTest() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
+ validateTestSetup();
assertEquals("Markers should be empty", 0, mapboxMap.getMarkers().size());
TextMarkerViewOptions options = new TextMarkerViewOptions();
@@ -70,8 +59,7 @@ public class MarkerViewTest {
@Test
@Ignore
public void showInfoWindowTest() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
+ validateTestSetup();
final TextMarkerViewOptions options = new TextMarkerViewOptions();
options.position(new LatLng());
@@ -139,9 +127,4 @@ public class MarkerViewTest {
uiController.loopMainThreadForAtLeast(250);
}
}
-
- @After
- public void unregisterIdlingResource() {
- Espresso.unregisterIdlingResources(idlingResource);
- }
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/annotations/PolygonTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/annotations/PolygonTest.java
index 24b9b3bf01..6e9e99942a 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/annotations/PolygonTest.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/annotations/PolygonTest.java
@@ -4,7 +4,6 @@ import android.graphics.Color;
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.view.View;
import com.mapbox.mapboxsdk.annotations.Polygon;
@@ -12,6 +11,7 @@ import com.mapbox.mapboxsdk.annotations.PolygonOptions;
import com.mapbox.mapboxsdk.geometry.LatLng;
import com.mapbox.mapboxsdk.maps.MapboxMap;
import com.mapbox.mapboxsdk.testapp.R;
+import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest;
import com.mapbox.mapboxsdk.testapp.activity.espresso.EspressoTestActivity;
import com.mapbox.mapboxsdk.testapp.utils.OnMapReadyIdlingResource;
import com.mapbox.mapboxsdk.testapp.utils.ViewUtils;
@@ -20,7 +20,6 @@ import org.hamcrest.Matcher;
import org.junit.After;
import org.junit.Before;
import org.junit.Ignore;
-import org.junit.Rule;
import org.junit.Test;
import static android.support.test.espresso.Espresso.onView;
@@ -28,26 +27,20 @@ import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed;
import static android.support.test.espresso.matcher.ViewMatchers.withId;
import static org.junit.Assert.assertEquals;
-public class PolygonTest {
+public class PolygonTest extends BaseActivityTest {
- @Rule
- public final ActivityTestRule rule = new ActivityTestRule<>(EspressoTestActivity.class);
+ @Override
+ protected Class getActivityClass() {
+ return EspressoTestActivity.class;
+ }
- private OnMapReadyIdlingResource idlingResource;
private Polygon polygon;
- @Before
- public void registerIdlingResource() {
- idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
- Espresso.registerIdlingResources(idlingResource);
- }
-
@Test
@Ignore
/** native crash **/
public void addPolygonTest() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- final MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
+ validateTestSetup();
LatLng latLngOne = new LatLng();
LatLng latLngTwo = new LatLng(1, 0);
LatLng latLngThree = new LatLng(1, 1);
@@ -97,9 +90,4 @@ public class PolygonTest {
polygon = mapboxMap.addPolygon(options);
}
}
-
- @After
- public void unregisterIdlingResource() {
- Espresso.unregisterIdlingResources(idlingResource);
- }
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/annotations/PolylineTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/annotations/PolylineTest.java
index 607a4ad263..013641114e 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/annotations/PolylineTest.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/annotations/PolylineTest.java
@@ -1,10 +1,8 @@
package com.mapbox.mapboxsdk.testapp.annotations;
import android.graphics.Color;
-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.view.View;
import com.mapbox.mapboxsdk.annotations.Polyline;
@@ -12,15 +10,11 @@ import com.mapbox.mapboxsdk.annotations.PolylineOptions;
import com.mapbox.mapboxsdk.geometry.LatLng;
import com.mapbox.mapboxsdk.maps.MapboxMap;
import com.mapbox.mapboxsdk.testapp.R;
+import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest;
import com.mapbox.mapboxsdk.testapp.activity.espresso.EspressoTestActivity;
-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;
-import org.junit.Rule;
import org.junit.Test;
import static android.support.test.espresso.Espresso.onView;
@@ -28,25 +22,19 @@ import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed;
import static android.support.test.espresso.matcher.ViewMatchers.withId;
import static org.junit.Assert.assertEquals;
-public class PolylineTest {
+public class PolylineTest extends BaseActivityTest{
- @Rule
- public final ActivityTestRule rule = new ActivityTestRule<>(EspressoTestActivity.class);
-
- private OnMapReadyIdlingResource idlingResource;
private Polyline polyline;
- @Before
- public void registerIdlingResource() {
- idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
- Espresso.registerIdlingResources(idlingResource);
+ @Override
+ protected Class getActivityClass() {
+ return EspressoTestActivity.class;
}
@Ignore
@Test
public void addPolylineTest() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- final MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
+ validateTestSetup();
LatLng latLngOne = new LatLng();
LatLng latLngTwo = new LatLng(1, 0);
@@ -92,9 +80,4 @@ public class PolylineTest {
polyline = mapboxMap.addPolyline(options);
}
}
-
- @After
- public void unregisterIdlingResource() {
- Espresso.unregisterIdlingResources(idlingResource);
- }
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/camera/CameraAnimateTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/camera/CameraAnimateTest.java
index d4b0dbad72..c2b2781905 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/camera/CameraAnimateTest.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/camera/CameraAnimateTest.java
@@ -14,6 +14,7 @@ import com.mapbox.mapboxsdk.geometry.LatLng;
import com.mapbox.mapboxsdk.geometry.LatLngBounds;
import com.mapbox.mapboxsdk.maps.MapboxMap;
import com.mapbox.mapboxsdk.testapp.R;
+import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest;
import com.mapbox.mapboxsdk.testapp.activity.espresso.EspressoTestActivity;
import com.mapbox.mapboxsdk.testapp.utils.OnMapReadyIdlingResource;
import com.mapbox.mapboxsdk.testapp.utils.TestConstants;
@@ -31,24 +32,17 @@ import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed;
import static android.support.test.espresso.matcher.ViewMatchers.withId;
import static org.junit.Assert.assertEquals;
-public class CameraAnimateTest {
+public class CameraAnimateTest extends BaseActivityTest {
- @Rule
- public final ActivityTestRule rule = new ActivityTestRule<>(EspressoTestActivity.class);
-
- private OnMapReadyIdlingResource idlingResource;
-
- @Before
- public void registerIdlingResource() {
- idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
- Espresso.registerIdlingResources(idlingResource);
+ @Override
+ protected Class getActivityClass() {
+ return EspressoTestActivity.class;
}
@Test
@Ignore
public void testAnimateToCameraPositionTarget() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- final MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
+ validateTestSetup();
/*TODO remove zoom #6474*/
float zoom = 1.0f;
@@ -70,8 +64,7 @@ public class CameraAnimateTest {
@Test
@Ignore
public void testAnimateToCameraPositionTargetZoom() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- final MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
+ validateTestSetup();
final float moveZoom = 15.5f;
final LatLng moveTarget = new LatLng(1.0000000001, 1.0000000003);
@@ -88,8 +81,7 @@ public class CameraAnimateTest {
@Test
public void testAnimateToCameraPosition() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- final MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
+ validateTestSetup();
final LatLng moveTarget = new LatLng(1.0000000001, 1.0000000003);
final float moveZoom = 15.5f;
@@ -119,8 +111,7 @@ public class CameraAnimateTest {
@Test
@Ignore
public void testAnimateToBounds() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- final MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
+ validateTestSetup();
final LatLng centerBounds = new LatLng(1, 1);
LatLng cornerOne = new LatLng();
@@ -148,8 +139,7 @@ public class CameraAnimateTest {
@Test
@Ignore
public void testAnimateToMoveBy() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- final MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
+ validateTestSetup();
final PointF centerPoint = mapboxMap.getProjection().toScreenLocation(mapboxMap.getCameraPosition().target);
final LatLng moveTarget = new LatLng(2, 2);
@@ -168,8 +158,7 @@ public class CameraAnimateTest {
@Test
@Ignore
public void testAnimateToZoomIn() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- final MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
+ validateTestSetup();
/*TODO fix zoom #6474*/
float zoom = 1.0f;
@@ -183,8 +172,7 @@ public class CameraAnimateTest {
@Test
@Ignore
public void testAnimateToZoomOut() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- final MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
+ validateTestSetup();
/*TODO fix zoom #6474*/
float zoom = 10.0f;
@@ -199,8 +187,7 @@ public class CameraAnimateTest {
@Test
@Ignore
public void testAnimateToZoomBy() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- final MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
+ validateTestSetup();
/*TODO fix zoom #6474*/
float zoom = 1.0f;
@@ -215,8 +202,7 @@ public class CameraAnimateTest {
@Test
@Ignore
public void testAnimateToZoomTo() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- final MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
+ validateTestSetup();
/*TODO fix zoom #6474*/
final float zoomTo = 2.45f;
@@ -227,11 +213,6 @@ public class CameraAnimateTest {
TestConstants.ZOOM_DELTA);
}
- @After
- public void unregisterIdlingResource() {
- Espresso.unregisterIdlingResources(idlingResource);
- }
-
private class AnimateCameraAction implements ViewAction {
private MapboxMap mapboxMap;
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/camera/CameraEaseTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/camera/CameraEaseTest.java
index 83e7d6084c..7e68ec258d 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/camera/CameraEaseTest.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/camera/CameraEaseTest.java
@@ -14,6 +14,7 @@ import com.mapbox.mapboxsdk.geometry.LatLng;
import com.mapbox.mapboxsdk.geometry.LatLngBounds;
import com.mapbox.mapboxsdk.maps.MapboxMap;
import com.mapbox.mapboxsdk.testapp.R;
+import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest;
import com.mapbox.mapboxsdk.testapp.activity.espresso.EspressoTestActivity;
import com.mapbox.mapboxsdk.testapp.utils.OnMapReadyIdlingResource;
import com.mapbox.mapboxsdk.testapp.utils.TestConstants;
@@ -31,24 +32,17 @@ import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed;
import static android.support.test.espresso.matcher.ViewMatchers.withId;
import static org.junit.Assert.assertEquals;
-public class CameraEaseTest {
+public class CameraEaseTest extends BaseActivityTest {
- @Rule
- public final ActivityTestRule rule = new ActivityTestRule<>(EspressoTestActivity.class);
-
- private OnMapReadyIdlingResource idlingResource;
-
- @Before
- public void registerIdlingResource() {
- idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
- Espresso.registerIdlingResources(idlingResource);
+ @Override
+ protected Class getActivityClass() {
+ return EspressoTestActivity.class;
}
@Test
@Ignore
public void testEaseToCameraPositionTarget() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- final MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
+ validateTestSetup();
/*TODO remove zoom #6474*/
float zoom = 1.0f;
@@ -70,8 +64,7 @@ public class CameraEaseTest {
@Test
@Ignore
public void testEaseToCameraPositionTargetZoom() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- final MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
+ validateTestSetup();
final float moveZoom = 15.5f;
final LatLng moveTarget = new LatLng(1.0000000001, 1.0000000003);
@@ -89,8 +82,7 @@ public class CameraEaseTest {
@Test
@Ignore
public void testEaseToCameraPosition() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- final MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
+ validateTestSetup();
final LatLng moveTarget = new LatLng(1.0000000001, 1.0000000003);
final float moveZoom = 15.5f;
@@ -120,8 +112,7 @@ public class CameraEaseTest {
@Test
@Ignore
public void testEaseToBounds() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- final MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
+ validateTestSetup();
final LatLng centerBounds = new LatLng(1, 1);
LatLng cornerOne = new LatLng();
@@ -149,8 +140,7 @@ public class CameraEaseTest {
@Test
@Ignore
public void testEaseToMoveBy() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- final MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
+ validateTestSetup();
final PointF centerPoint = mapboxMap.getProjection().toScreenLocation(mapboxMap.getCameraPosition().target);
final LatLng moveTarget = new LatLng(2, 2);
@@ -169,8 +159,7 @@ public class CameraEaseTest {
@Test
@Ignore
public void testEaseToZoomIn() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- final MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
+ validateTestSetup();
/*TODO fix zoom #6474*/
float zoom = 1.0f;
@@ -184,8 +173,7 @@ public class CameraEaseTest {
@Test
@Ignore
public void testEaseToZoomOut() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- final MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
+ validateTestSetup();
/*TODO fix zoom #6474*/
float zoom = 10.0f;
@@ -199,8 +187,7 @@ public class CameraEaseTest {
@Test
@Ignore
public void testEaseToZoomBy() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- final MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
+ validateTestSetup();
/*TODO fix zoom #6474*/
float zoom = 1.0f;
@@ -215,8 +202,7 @@ public class CameraEaseTest {
@Test
@Ignore
public void testEaseToZoomTo() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- final MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
+ validateTestSetup();
/*TODO fix zoom #6474*/
final float zoomTo = 2.45f;
@@ -227,11 +213,6 @@ public class CameraEaseTest {
TestConstants.ZOOM_DELTA);
}
- @After
- public void unregisterIdlingResource() {
- Espresso.unregisterIdlingResources(idlingResource);
- }
-
private class EaseCameraAction implements ViewAction {
private MapboxMap mapboxMap;
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/camera/CameraInternalApiTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/camera/CameraInternalApiTest.java
index 2d01347d22..4fc580f908 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/camera/CameraInternalApiTest.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/camera/CameraInternalApiTest.java
@@ -11,16 +11,14 @@ import com.mapbox.mapboxsdk.geometry.LatLng;
import com.mapbox.mapboxsdk.maps.MapViewUtils;
import com.mapbox.mapboxsdk.maps.MapboxMap;
import com.mapbox.mapboxsdk.testapp.R;
+import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest;
import com.mapbox.mapboxsdk.testapp.activity.espresso.EspressoTestActivity;
-import com.mapbox.mapboxsdk.testapp.utils.OnMapReadyIdlingResource;
import com.mapbox.mapboxsdk.testapp.utils.TestConstants;
import com.mapbox.mapboxsdk.testapp.utils.ViewUtils;
import org.hamcrest.Matcher;
import org.junit.After;
-import org.junit.Before;
import org.junit.Ignore;
-import org.junit.Rule;
import org.junit.Test;
import static android.support.test.espresso.Espresso.onView;
@@ -31,25 +29,17 @@ import static org.junit.Assert.assertEquals;
/**
* Tests camera transformations that aren't part of our public API
*/
-public class CameraInternalApiTest {
+public class CameraInternalApiTest extends BaseActivityTest {
- @Rule
- public final ActivityTestRule rule = new ActivityTestRule<>(EspressoTestActivity.class);
-
- private OnMapReadyIdlingResource idlingResource;
-
- @Before
- public void registerIdlingResource() {
- idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
- Espresso.registerIdlingResources(idlingResource);
+ @Override
+ protected Class getActivityClass() {
+ return EspressoTestActivity.class;
}
@Test
@Ignore
public void testBearing() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- EspressoTestActivity activity = rule.getActivity();
- MapboxMap mapboxMap = activity.getMapboxMap();
+ validateTestSetup();
CameraPosition initialPosition = new
CameraPosition.Builder().target(new LatLng()).zoom(1).bearing(0).tilt(0).build();
@@ -63,9 +53,7 @@ public class CameraInternalApiTest {
@Test
@Ignore
public void testTilt() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- EspressoTestActivity activity = rule.getActivity();
- MapboxMap mapboxMap = activity.getMapboxMap();
+ validateTestSetup();
CameraPosition initialPosition = new CameraPosition.Builder().target(
new LatLng()).zoom(1).bearing(0).tilt(0).build();
@@ -79,9 +67,7 @@ public class CameraInternalApiTest {
@Test
@Ignore
public void testLatLng() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- EspressoTestActivity activity = rule.getActivity();
- MapboxMap mapboxMap = activity.getMapboxMap();
+ validateTestSetup();
CameraPosition initialPosition = new CameraPosition.Builder().target(
new LatLng()).zoom(1).bearing(0).tilt(0).build();
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/camera/CameraMoveTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/camera/CameraMoveTest.java
index becf9db7cb..bf477d7f8f 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/camera/CameraMoveTest.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/camera/CameraMoveTest.java
@@ -1,10 +1,8 @@
package com.mapbox.mapboxsdk.testapp.camera;
import android.graphics.PointF;
-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.view.View;
import com.mapbox.mapboxsdk.camera.CameraPosition;
@@ -14,16 +12,13 @@ import com.mapbox.mapboxsdk.geometry.LatLng;
import com.mapbox.mapboxsdk.geometry.LatLngBounds;
import com.mapbox.mapboxsdk.maps.MapboxMap;
import com.mapbox.mapboxsdk.testapp.R;
+import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest;
import com.mapbox.mapboxsdk.testapp.activity.espresso.EspressoTestActivity;
-import com.mapbox.mapboxsdk.testapp.utils.OnMapReadyIdlingResource;
import com.mapbox.mapboxsdk.testapp.utils.TestConstants;
import com.mapbox.mapboxsdk.testapp.utils.ViewUtils;
import org.hamcrest.Matcher;
-import org.junit.After;
-import org.junit.Before;
import org.junit.Ignore;
-import org.junit.Rule;
import org.junit.Test;
import static android.support.test.espresso.Espresso.onView;
@@ -31,24 +26,17 @@ import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed;
import static android.support.test.espresso.matcher.ViewMatchers.withId;
import static org.junit.Assert.assertEquals;
-public class CameraMoveTest {
+public class CameraMoveTest extends BaseActivityTest {
- @Rule
- public final ActivityTestRule rule = new ActivityTestRule<>(EspressoTestActivity.class);
-
- private OnMapReadyIdlingResource idlingResource;
-
- @Before
- public void registerIdlingResource() {
- idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
- Espresso.registerIdlingResources(idlingResource);
+ @Override
+ protected Class getActivityClass() {
+ return EspressoTestActivity.class;
}
@Test
@Ignore
public void testMoveToCameraPositionTarget() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- final MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
+ validateTestSetup();;
/*TODO remove zoom #6474*/
float zoom = 1.0f;
@@ -70,8 +58,7 @@ public class CameraMoveTest {
@Test
@Ignore
public void testMoveToCameraPositionTargetZoom() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- final MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
+ validateTestSetup();;
final float moveZoom = 15.5f;
final LatLng moveTarget = new LatLng(1.0000000001, 1.0000000003);
@@ -89,8 +76,7 @@ public class CameraMoveTest {
@Test
@Ignore
public void testMoveToCameraPosition() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- final MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
+ validateTestSetup();;
final LatLng moveTarget = new LatLng(1.0000000001, 1.0000000003);
final float moveZoom = 15.5f;
@@ -120,8 +106,7 @@ public class CameraMoveTest {
@Test
@Ignore
public void testMoveToBounds() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- final MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
+ validateTestSetup();;
final LatLng centerBounds = new LatLng(1, 1);
LatLng cornerOne = new LatLng();
@@ -149,8 +134,7 @@ public class CameraMoveTest {
@Test
@Ignore
public void testMoveToMoveBy() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- final MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
+ validateTestSetup();
final PointF centerPoint = mapboxMap.getProjection().toScreenLocation(mapboxMap.getCameraPosition().target);
final LatLng moveTarget = new LatLng(2, 2);
@@ -169,8 +153,7 @@ public class CameraMoveTest {
@Test
@Ignore
public void testMoveToZoomIn() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- final MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
+ validateTestSetup();
/*TODO fix zoom #6474*/
float zoom = 1.0f;
@@ -184,8 +167,7 @@ public class CameraMoveTest {
@Test
@Ignore
public void testMoveToZoomOut() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- final MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
+ validateTestSetup();;
/*TODO fix zoom #6474*/
float zoom = 10.0f;
@@ -200,8 +182,7 @@ public class CameraMoveTest {
@Test
@Ignore
public void testMoveToZoomBy() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- final MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
+ validateTestSetup();
/*TODO fix zoom #6474*/
float zoom = 1.0f;
@@ -216,8 +197,7 @@ public class CameraMoveTest {
@Test
@Ignore
public void testMoveToZoomTo() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- final MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
+ validateTestSetup();
/*TODO fix zoom #6474*/
final float zoomTo = 2.45f;
@@ -228,11 +208,6 @@ public class CameraMoveTest {
TestConstants.ZOOM_DELTA);
}
- @After
- public void unregisterIdlingResource() {
- Espresso.unregisterIdlingResources(idlingResource);
- }
-
private class MoveCameraAction implements ViewAction {
private MapboxMap mapboxMap;
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/feature/QueryRenderedFeaturesBoxCountTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/feature/QueryRenderedFeaturesBoxCountTest.java
index f49296a164..8495cebfc3 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/feature/QueryRenderedFeaturesBoxCountTest.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/feature/QueryRenderedFeaturesBoxCountTest.java
@@ -1,16 +1,10 @@
package com.mapbox.mapboxsdk.testapp.feature;
-import android.support.test.espresso.Espresso;
-import android.support.test.rule.ActivityTestRule;
-
import com.mapbox.mapboxsdk.testapp.R;
+import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest;
import com.mapbox.mapboxsdk.testapp.activity.feature.QueryRenderedFeaturesBoxCountActivity;
-import com.mapbox.mapboxsdk.testapp.utils.OnMapReadyIdlingResource;
-import org.junit.After;
-import org.junit.Before;
import org.junit.Ignore;
-import org.junit.Rule;
import org.junit.Test;
import static android.support.test.espresso.Espresso.onView;
@@ -27,18 +21,11 @@ import static org.hamcrest.Matchers.not;
* Instrumentation test to validate if clicking on the blue rectangle from
* QueryRenderedFeaturesBoxSymbolCountActivity shows a Toast that 149 features were found.
*/
-public class QueryRenderedFeaturesBoxCountTest {
-
- @Rule
- public final ActivityTestRule rule =
- new ActivityTestRule<>(QueryRenderedFeaturesBoxCountActivity.class);
-
- private OnMapReadyIdlingResource idlingResource;
+public class QueryRenderedFeaturesBoxCountTest extends BaseActivityTest{
- @Before
- public void registerIdlingResource() {
- idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
- Espresso.registerIdlingResources(idlingResource);
+ @Override
+ protected Class getActivityClass() {
+ return QueryRenderedFeaturesBoxCountActivity.class;
}
@Test
@@ -53,9 +40,4 @@ public class QueryRenderedFeaturesBoxCountTest {
.check(matches(isDisplayed()));
}
- @After
- public void unregisterIdlingResource() {
- Espresso.unregisterIdlingResources(idlingResource);
- }
-
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/feature/QueryRenderedFeaturesHighlightTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/feature/QueryRenderedFeaturesHighlightTest.java
index 0333aba191..4e09652af3 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/feature/QueryRenderedFeaturesHighlightTest.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/feature/QueryRenderedFeaturesHighlightTest.java
@@ -10,6 +10,7 @@ import android.support.test.rule.ActivityTestRule;
import android.view.View;
import com.mapbox.mapboxsdk.testapp.R;
+import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest;
import com.mapbox.mapboxsdk.testapp.activity.feature.QueryRenderedFeaturesBoxHighlightActivity;
import com.mapbox.mapboxsdk.testapp.utils.OnMapReadyIdlingResource;
@@ -32,18 +33,11 @@ import static org.hamcrest.Matchers.not;
/**
* Instrumentation test to validate if clicking box on screen highlights features.
*/
-public class QueryRenderedFeaturesHighlightTest {
+public class QueryRenderedFeaturesHighlightTest extends BaseActivityTest {
- @Rule
- public final ActivityTestRule rule =
- new ActivityTestRule<>(QueryRenderedFeaturesBoxHighlightActivity.class);
-
- private OnMapReadyIdlingResource idlingResource;
-
- @Before
- public void registerIdlingResource() {
- idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
- Espresso.registerIdlingResources(idlingResource);
+ @Override
+ protected Class getActivityClass() {
+ return QueryRenderedFeaturesBoxHighlightActivity.class;
}
@Test
@@ -58,24 +52,4 @@ public class QueryRenderedFeaturesHighlightTest {
.check(matches(isDisplayed()));
}
- @After
- public void unregisterIdlingResource() {
- Espresso.unregisterIdlingResources(idlingResource);
- }
-
- private static ViewAction clickXY(final float x, final float y) {
- return new GeneralClickAction(
- Tap.SINGLE,
- new CoordinatesProvider() {
- @Override
- public float[] calculateCoordinates(View view) {
- final int[] screenPos = new int[2];
- view.getLocationOnScreen(screenPos);
- final float screenX = screenPos[0] + x;
- final float screenY = screenPos[1] + y;
- return new float[] {screenX, screenY};
- }
- },
- Press.FINGER);
- }
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/feature/QueryRenderedFeaturesPropertiesTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/feature/QueryRenderedFeaturesPropertiesTest.java
index 01eb9c8b44..6d0cd975b4 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/feature/QueryRenderedFeaturesPropertiesTest.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/feature/QueryRenderedFeaturesPropertiesTest.java
@@ -13,6 +13,7 @@ import android.view.View;
import com.mapbox.mapboxsdk.geometry.LatLng;
import com.mapbox.mapboxsdk.maps.MapboxMap;
import com.mapbox.mapboxsdk.testapp.R;
+import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest;
import com.mapbox.mapboxsdk.testapp.activity.feature.QueryRenderedFeaturesPropertiesActivity;
import com.mapbox.mapboxsdk.testapp.utils.OnMapReadyIdlingResource;
@@ -31,35 +32,22 @@ import static android.support.test.espresso.matcher.ViewMatchers.withText;
/**
* Instrumentation test to validate if clicking center of screen returns the correct features.
*/
-public class QueryRenderedFeaturesPropertiesTest {
+public class QueryRenderedFeaturesPropertiesTest extends BaseActivityTest {
- @Rule
- public final ActivityTestRule rule =
- new ActivityTestRule<>(QueryRenderedFeaturesPropertiesActivity.class);
-
- private OnMapReadyIdlingResource idlingResource;
-
- @Before
- public void registerIdlingResource() {
- idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
- Espresso.registerIdlingResources(idlingResource);
+ @Override
+ protected Class getActivityClass() {
+ return QueryRenderedFeaturesPropertiesActivity.class;
}
@Test
@Ignore
public void testCountFeatures() {
- MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
LatLng centerScreen = mapboxMap.getCameraPosition().target;
PointF centerPixel = mapboxMap.getProjection().toScreenLocation(centerScreen);
onView(withId(R.id.mapView)).perform(clickXY(centerPixel.x, centerPixel.y));
onView(withText("Found 4 features")).check(matches(isDisplayed()));
}
- @After
- public void unregisterIdlingResource() {
- Espresso.unregisterIdlingResources(idlingResource);
- }
-
private static ViewAction clickXY(final float x, final float y) {
return new GeneralClickAction(
Tap.SINGLE,
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/feature/QueryRenderedSymbolBoxCountTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/feature/QueryRenderedSymbolBoxCountTest.java
index ea80e8689a..a31c3db89e 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/feature/QueryRenderedSymbolBoxCountTest.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/feature/QueryRenderedSymbolBoxCountTest.java
@@ -1,16 +1,10 @@
package com.mapbox.mapboxsdk.testapp.feature;
-import android.support.test.espresso.Espresso;
-import android.support.test.rule.ActivityTestRule;
-
import com.mapbox.mapboxsdk.testapp.R;
+import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest;
import com.mapbox.mapboxsdk.testapp.activity.feature.QueryRenderedFeaturesBoxSymbolCountActivity;
-import com.mapbox.mapboxsdk.testapp.utils.OnMapReadyIdlingResource;
-import org.junit.After;
-import org.junit.Before;
import org.junit.Ignore;
-import org.junit.Rule;
import org.junit.Test;
import static android.support.test.espresso.Espresso.onView;
@@ -27,18 +21,11 @@ import static org.hamcrest.Matchers.not;
* Instrumentation test to validate if clicking on the blue rectangle from
* QueryRenderedFeaturesBoxSymbolCountActivity shows a Toast that 2 symbols were found.
*/
-public class QueryRenderedSymbolBoxCountTest {
-
- @Rule
- public final ActivityTestRule rule =
- new ActivityTestRule<>(QueryRenderedFeaturesBoxSymbolCountActivity.class);
-
- private OnMapReadyIdlingResource idlingResource;
+public class QueryRenderedSymbolBoxCountTest extends BaseActivityTest {
- @Before
- public void registerIdlingResource() {
- idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
- Espresso.registerIdlingResources(idlingResource);
+ @Override
+ protected Class getActivityClass() {
+ return QueryRenderedFeaturesBoxSymbolCountActivity.class;
}
@Test
@@ -52,11 +39,5 @@ public class QueryRenderedSymbolBoxCountTest {
.inRoot(withDecorView(not(is(rule.getActivity().getWindow().getDecorView()))))
.check(matches(isDisplayed()));
}
-
- @After
- public void unregisterIdlingResource() {
- Espresso.unregisterIdlingResources(idlingResource);
- }
-
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/widgets/AttributionTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/widgets/AttributionTest.java
index fa1451092a..5a4aa4dde3 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/widgets/AttributionTest.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/widgets/AttributionTest.java
@@ -12,6 +12,7 @@ import android.view.View;
import com.mapbox.mapboxsdk.maps.MapboxMap;
import com.mapbox.mapboxsdk.testapp.R;
+import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest;
import com.mapbox.mapboxsdk.testapp.activity.espresso.EspressoTestActivity;
import com.mapbox.mapboxsdk.testapp.utils.OnMapReadyIdlingResource;
import com.mapbox.mapboxsdk.testapp.utils.ViewUtils;
@@ -22,6 +23,8 @@ import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
+import timber.log.Timber;
+
import static android.support.test.espresso.Espresso.onView;
import static android.support.test.espresso.action.ViewActions.click;
import static android.support.test.espresso.assertion.ViewAssertions.matches;
@@ -35,20 +38,19 @@ import static android.support.test.espresso.matcher.ViewMatchers.withText;
import static org.hamcrest.Matchers.allOf;
import static org.hamcrest.core.IsNot.not;
-public class AttributionTest {
-
- @Rule
- public final ActivityTestRule rule = new ActivityTestRule<>(EspressoTestActivity.class);
-
- private OnMapReadyIdlingResource idlingResource;
+public class AttributionTest extends BaseActivityTest {
private String[] dialogTexts;
private String[] dialogLinks;
+ @Override
+ protected Class getActivityClass() {
+ return EspressoTestActivity.class;
+ }
+
@Before
public void beforeTest() {
- idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
- Espresso.registerIdlingResources(idlingResource);
+ super.beforeTest();
Intents.init();
dialogTexts = rule.getActivity().getResources().getStringArray(R.array.mapbox_attribution_names);
dialogLinks = rule.getActivity().getResources().getStringArray(R.array.mapbox_attribution_links);
@@ -56,8 +58,7 @@ public class AttributionTest {
@Test
public void testDisabled() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
+ validateTestSetup();
// Default
onView(withId(R.id.attributionView)).check(matches(isDisplayed()));
@@ -70,7 +71,7 @@ public class AttributionTest {
@Test
public void testMapboxLink() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
// click on View to open dialog
onView(withId(R.id.attributionView)).perform(click());
@@ -85,7 +86,7 @@ public class AttributionTest {
@Test
public void testOpenStreetMapLink() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
// click on View to open dialog
onView(withId(R.id.attributionView)).perform(click());
@@ -99,7 +100,7 @@ public class AttributionTest {
@Test
public void testImproveMapLink() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
// click on View to open dialog
onView(withId(R.id.attributionView)).perform(click());
@@ -113,7 +114,7 @@ public class AttributionTest {
@Test
public void testTelemetryDialog() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
// click on View to open dialog
onView(withId(R.id.attributionView)).perform(click());
@@ -126,8 +127,8 @@ public class AttributionTest {
@After
public void afterTest() {
+ super.afterTest();
Intents.release();
- Espresso.unregisterIdlingResources(idlingResource);
}
private class DisableAction implements ViewAction {
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/widgets/CompassViewTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/widgets/CompassViewTest.java
index 02fec41f65..abbf7d92d0 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/widgets/CompassViewTest.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/widgets/CompassViewTest.java
@@ -1,9 +1,7 @@
package com.mapbox.mapboxsdk.testapp.maps.widgets;
-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.view.View;
import com.mapbox.mapboxsdk.camera.CameraPosition;
@@ -12,16 +10,12 @@ import com.mapbox.mapboxsdk.camera.CameraUpdateFactory;
import com.mapbox.mapboxsdk.geometry.LatLng;
import com.mapbox.mapboxsdk.maps.MapboxMap;
import com.mapbox.mapboxsdk.testapp.R;
+import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest;
import com.mapbox.mapboxsdk.testapp.activity.espresso.EspressoTestActivity;
-import com.mapbox.mapboxsdk.testapp.utils.OnMapReadyIdlingResource;
import com.mapbox.mapboxsdk.testapp.utils.TestConstants;
-import com.mapbox.mapboxsdk.testapp.utils.ViewUtils;
import org.hamcrest.Matcher;
-import org.junit.After;
-import org.junit.Before;
import org.junit.Ignore;
-import org.junit.Rule;
import org.junit.Test;
import static android.support.test.espresso.Espresso.onView;
@@ -32,29 +26,22 @@ import static android.support.test.espresso.matcher.ViewMatchers.withId;
import static org.hamcrest.Matchers.not;
import static org.junit.Assert.assertEquals;
-public class CompassViewTest {
+public class CompassViewTest extends BaseActivityTest {
- @Rule
- public final ActivityTestRule rule = new ActivityTestRule<>(EspressoTestActivity.class);
-
- private OnMapReadyIdlingResource idlingResource;
-
- @Before
- public void registerIdlingResource() {
- idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
- Espresso.registerIdlingResources(idlingResource);
+ @Override
+ protected Class getActivityClass() {
+ return EspressoTestActivity.class;
}
@Test
public void testDefault() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
onView(withId(R.id.compassView)).check(matches(not(isDisplayed())));
}
@Test
public void testVisible() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
+ validateTestSetup();
onView(withId(R.id.mapView)).perform(new MoveCameraAction(mapboxMap,
CameraUpdateFactory.newCameraPosition(
@@ -66,15 +53,14 @@ public class CompassViewTest {
)
)
);
-
+ waitLoop();
onView(withId(R.id.compassView)).check(matches(isDisplayed()));
}
@Test
@Ignore // 10-31-2016 click action is not working
public void testClick() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
+ validateTestSetup();
onView(withId(R.id.mapView)).perform(new MoveCameraAction(mapboxMap,
CameraUpdateFactory.newCameraPosition(
@@ -87,6 +73,7 @@ public class CompassViewTest {
)
);
+ waitLoop();
onView(withId(R.id.compassView)).perform(click());
onView(withId(R.id.mapView)).perform(new WaitAction(3000));
onView(withId(R.id.compassView)).check(matches(not(isDisplayed())));
@@ -95,11 +82,6 @@ public class CompassViewTest {
assertEquals("Camera bearing should face north, ", 0, cameraPosition.bearing, TestConstants.BEARING_DELTA);
}
- @After
- public void unregisterIdlingResource() {
- Espresso.unregisterIdlingResources(idlingResource);
- }
-
private class WaitAction implements ViewAction {
private long waitTime;
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/widgets/LogoTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/widgets/LogoTest.java
index f12b2bf160..be1e944663 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/widgets/LogoTest.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/widgets/LogoTest.java
@@ -1,21 +1,16 @@
package com.mapbox.mapboxsdk.testapp.maps.widgets;
-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.view.View;
import com.mapbox.mapboxsdk.maps.MapboxMap;
import com.mapbox.mapboxsdk.testapp.R;
+import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest;
import com.mapbox.mapboxsdk.testapp.activity.espresso.EspressoTestActivity;
-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.Rule;
import org.junit.Test;
import static android.support.test.espresso.Espresso.onView;
@@ -24,40 +19,28 @@ import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed;
import static android.support.test.espresso.matcher.ViewMatchers.withId;
import static org.hamcrest.Matchers.not;
-public class LogoTest {
+public class LogoTest extends BaseActivityTest {
- @Rule
- public final ActivityTestRule rule = new ActivityTestRule<>(EspressoTestActivity.class);
-
- private OnMapReadyIdlingResource idlingResource;
-
- @Before
- public void registerIdlingResource() {
- idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
- Espresso.registerIdlingResources(idlingResource);
+ @Override
+ protected Class getActivityClass() {
+ return EspressoTestActivity.class;
}
@Test
public void testDefault() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
onView(withId(R.id.logoView)).check(matches(isDisplayed()));
}
@Test
public void testDisabled() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
+ validateTestSetup();
onView(withId(R.id.logoView))
.perform(new DisableAction(mapboxMap))
.check(matches(not(isDisplayed())));
}
- @After
- public void unregisterIdlingResource() {
- Espresso.unregisterIdlingResources(idlingResource);
- }
-
private class DisableAction implements ViewAction {
private MapboxMap mapboxMap;
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/widgets/MyLocationViewTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/widgets/MyLocationViewTest.java
index c8a983351b..6f1799401e 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/widgets/MyLocationViewTest.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/widgets/MyLocationViewTest.java
@@ -20,6 +20,7 @@ import com.mapbox.mapboxsdk.location.LocationSource;
import com.mapbox.mapboxsdk.maps.MapboxMap;
import com.mapbox.mapboxsdk.maps.widgets.MyLocationView;
import com.mapbox.mapboxsdk.testapp.R;
+import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest;
import com.mapbox.mapboxsdk.testapp.activity.espresso.EspressoTestActivity;
import com.mapbox.mapboxsdk.testapp.utils.OnMapReadyIdlingResource;
import com.mapbox.mapboxsdk.testapp.utils.ViewUtils;
@@ -49,24 +50,17 @@ import static org.hamcrest.Matchers.not;
* {@link com.mapbox.mapboxsdk.maps.TrackingSettings#setMyBearingTrackingMode(int)}.
*
*/
-public class MyLocationViewTest {
+public class MyLocationViewTest extends BaseActivityTest{
- @Rule
- public final ActivityTestRule rule = new ActivityTestRule<>(EspressoTestActivity.class);
-
- private OnMapReadyIdlingResource idlingResource;
-
- @Before
- public void beforeTest() {
- idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
- Espresso.registerIdlingResources(idlingResource);
+ @Override
+ protected Class getActivityClass() {
+ return EspressoTestActivity.class;
}
@Test
@Ignore // requires runtime permissions, disabled for CI
public void testEnabled() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
+ validateTestSetup();
onView(withId(R.id.userLocationView)).check(matches(not(isDisplayed())));
onView(withId(R.id.mapView)).perform(new ToggleLocationAction(mapboxMap, true));
onView(withId(R.id.userLocationView)).check(matches(isDisplayed()));
@@ -79,8 +73,7 @@ public class MyLocationViewTest {
// requires runtime permissions, disabled for CI + issue with android.support.test.espresso.AppNotIdleException:
// Looped for 5049 iterations over 60 SECONDS.
public void testTracking() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
+ validateTestSetup();
onView(withId(R.id.userLocationView)).check(matches(not(isDisplayed())));
onView(withId(R.id.mapView)).perform(new EnableLocationTrackingAction(mapboxMap));
onView(withId(R.id.userLocationView)).check(matches(isDisplayed()));
@@ -91,11 +84,6 @@ public class MyLocationViewTest {
R.drawable.mapbox_mylocation_icon_bearing, true)));
}
- @After
- public void afterTest() {
- Espresso.unregisterIdlingResources(idlingResource);
- }
-
private class ToggleLocationAction implements ViewAction {
private MapboxMap mapboxMap;
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 4f94dcc28b..d4a0036c4f 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
@@ -22,6 +22,7 @@ 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.testapp.activity.BaseActivityTest;
import org.junit.After;
import org.junit.Before;
@@ -37,35 +38,30 @@ import static com.mapbox.mapboxsdk.style.layers.Property.*;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*;
import com.mapbox.mapboxsdk.style.layers.TransitionOptions;
+import com.mapbox.mapboxsdk.testapp.activity.espresso.EspressoTestActivity;
/**
* Basic smoke tests for BackgroundLayer
*/
@RunWith(AndroidJUnit4.class)
-public class BackgroundLayerTest extends BaseStyleTest {
-
- @Rule
- public final ActivityTestRule rule = new ActivityTestRule<>(RuntimeStyleTestActivity.class);
+public class BackgroundLayerTest extends BaseActivityTest {
private BackgroundLayer layer;
- private OnMapReadyIdlingResource idlingResource;
-
- private MapboxMap mapboxMap;
-
- @Before
- public void setup() {
- idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
- Espresso.registerIdlingResources(idlingResource);
- mapboxMap = rule.getActivity().getMapboxMap();
+ @Override
+ protected Class getActivityClass() {
+ return EspressoTestActivity.class;
+ }
+ private void setupLayer(){
Timber.i("Retrieving layer");
layer = mapboxMap.getLayerAs("background");
}
@Test
public void testSetVisibility() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("Visibility");
assertNotNull(layer);
@@ -79,7 +75,8 @@ public class BackgroundLayerTest extends BaseStyleTest {
@Test
public void testBackgroundColorTransition() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("background-colorTransitionOptions");
assertNotNull(layer);
@@ -91,7 +88,8 @@ public class BackgroundLayerTest extends BaseStyleTest {
@Test
public void testBackgroundColorAsConstant() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("background-color");
assertNotNull(layer);
@@ -102,7 +100,8 @@ public class BackgroundLayerTest extends BaseStyleTest {
@Test
public void testBackgroundColorAsCameraFunction() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("background-color");
assertNotNull(layer);
@@ -128,7 +127,8 @@ public class BackgroundLayerTest extends BaseStyleTest {
@Test
public void testBackgroundColorAsIntConstant() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("background-color");
assertNotNull(layer);
@@ -139,7 +139,8 @@ public class BackgroundLayerTest extends BaseStyleTest {
@Test
public void testBackgroundPatternTransition() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("background-patternTransitionOptions");
assertNotNull(layer);
@@ -151,7 +152,8 @@ public class BackgroundLayerTest extends BaseStyleTest {
@Test
public void testBackgroundPatternAsConstant() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("background-pattern");
assertNotNull(layer);
@@ -162,7 +164,8 @@ public class BackgroundLayerTest extends BaseStyleTest {
@Test
public void testBackgroundPatternAsCameraFunction() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("background-pattern");
assertNotNull(layer);
@@ -187,7 +190,8 @@ public class BackgroundLayerTest extends BaseStyleTest {
@Test
public void testBackgroundOpacityTransition() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("background-opacityTransitionOptions");
assertNotNull(layer);
@@ -199,7 +203,8 @@ public class BackgroundLayerTest extends BaseStyleTest {
@Test
public void testBackgroundOpacityAsConstant() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("background-opacity");
assertNotNull(layer);
@@ -210,7 +215,8 @@ public class BackgroundLayerTest extends BaseStyleTest {
@Test
public void testBackgroundOpacityAsCameraFunction() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("background-opacity");
assertNotNull(layer);
@@ -235,8 +241,4 @@ public class BackgroundLayerTest extends BaseStyleTest {
}
- @After
- public void unregisterIntentServiceIdlingResource() {
- Espresso.unregisterIdlingResources(idlingResource);
- }
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/BaseStyleTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/BaseStyleTest.java
index 620e15579f..3d56752150 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/BaseStyleTest.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/BaseStyleTest.java
@@ -1,44 +1,15 @@
package com.mapbox.mapboxsdk.testapp.style;
-import android.app.Activity;
-
-import com.mapbox.mapboxsdk.testapp.utils.ScreenshotUtil;
-
-import static android.support.test.espresso.Espresso.onView;
-import static android.support.test.espresso.assertion.ViewAssertions.matches;
-import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed;
-import static android.support.test.espresso.matcher.ViewMatchers.withId;
+import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest;
+import com.mapbox.mapboxsdk.testapp.activity.style.RuntimeStyleTestActivity;
/**
* Base Test class for Style tests
*/
-public class BaseStyleTest {
-
- protected static final String HOME_BUTTON_STRING = "Navigate up";
-
- /*
- * Shortcuts for common UI tests
- */
-
- protected void checkViewIsDisplayed(int id) {
- onView(withId(id))
- .check(matches(isDisplayed()));
- }
-
- /*
- * Screenshots logic
- */
-
- protected void takeNamedScreenshot(final Activity activity, final String name) {
-
- // Screenshots need to be taken on the UI thread
- activity.runOnUiThread(new Runnable() {
- @Override
- public void run() {
- ScreenshotUtil.take(activity, name);
- }
- });
+public class BaseStyleTest extends BaseActivityTest {
+ @Override
+ protected Class getActivityClass() {
+ return RuntimeStyleTestActivity.class;
}
-
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/CircleLayerTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/CircleLayerTest.java
index 7b8a03fb35..fe2e4b7072 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/CircleLayerTest.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/CircleLayerTest.java
@@ -22,6 +22,7 @@ import com.mapbox.mapboxsdk.style.layers.CircleLayer;
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.activity.BaseActivityTest;
import org.junit.After;
import org.junit.Before;
@@ -37,28 +38,22 @@ import static com.mapbox.mapboxsdk.style.layers.Property.*;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*;
import com.mapbox.mapboxsdk.style.layers.TransitionOptions;
+import com.mapbox.mapboxsdk.testapp.activity.espresso.EspressoTestActivity;
/**
* Basic smoke tests for CircleLayer
*/
@RunWith(AndroidJUnit4.class)
-public class CircleLayerTest extends BaseStyleTest {
-
- @Rule
- public final ActivityTestRule rule = new ActivityTestRule<>(RuntimeStyleTestActivity.class);
+public class CircleLayerTest extends BaseActivityTest {
private CircleLayer layer;
- private OnMapReadyIdlingResource idlingResource;
-
- private MapboxMap mapboxMap;
-
- @Before
- public void setup() {
- idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
- Espresso.registerIdlingResources(idlingResource);
- mapboxMap = rule.getActivity().getMapboxMap();
+ @Override
+ protected Class getActivityClass() {
+ return EspressoTestActivity.class;
+ }
+ private void setupLayer(){
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
Timber.i("Adding layer");
layer = new CircleLayer("my-layer", "composite");
@@ -71,7 +66,8 @@ public class CircleLayerTest extends BaseStyleTest {
@Test
public void testSetVisibility() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("Visibility");
assertNotNull(layer);
@@ -85,7 +81,8 @@ public class CircleLayerTest extends BaseStyleTest {
@Test
public void testCircleRadiusTransition() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("circle-radiusTransitionOptions");
assertNotNull(layer);
@@ -97,7 +94,8 @@ public class CircleLayerTest extends BaseStyleTest {
@Test
public void testCircleRadiusAsConstant() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("circle-radius");
assertNotNull(layer);
@@ -108,7 +106,8 @@ public class CircleLayerTest extends BaseStyleTest {
@Test
public void testCircleRadiusAsCameraFunction() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("circle-radius");
assertNotNull(layer);
@@ -134,7 +133,8 @@ public class CircleLayerTest extends BaseStyleTest {
@Test
public void testCircleRadiusAsIdentitySourceFunction() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("circle-radius");
assertNotNull(layer);
@@ -153,7 +153,8 @@ public class CircleLayerTest extends BaseStyleTest {
@Test
public void testCircleRadiusAsExponentialSourceFunction() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("circle-radius");
assertNotNull(layer);
@@ -179,7 +180,8 @@ public class CircleLayerTest extends BaseStyleTest {
@Test
public void testCircleRadiusAsCategoricalSourceFunction() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("circle-radius");
assertNotNull(layer);
@@ -208,7 +210,8 @@ public class CircleLayerTest extends BaseStyleTest {
@Test
public void testCircleRadiusAsCompositeFunction() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("circle-radius");
assertNotNull(layer);
@@ -242,7 +245,8 @@ public class CircleLayerTest extends BaseStyleTest {
@Test
public void testCircleColorTransition() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("circle-colorTransitionOptions");
assertNotNull(layer);
@@ -254,7 +258,8 @@ public class CircleLayerTest extends BaseStyleTest {
@Test
public void testCircleColorAsConstant() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("circle-color");
assertNotNull(layer);
@@ -265,7 +270,8 @@ public class CircleLayerTest extends BaseStyleTest {
@Test
public void testCircleColorAsCameraFunction() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("circle-color");
assertNotNull(layer);
@@ -291,7 +297,8 @@ public class CircleLayerTest extends BaseStyleTest {
@Test
public void testCircleColorAsIdentitySourceFunction() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("circle-color");
assertNotNull(layer);
@@ -310,7 +317,8 @@ public class CircleLayerTest extends BaseStyleTest {
@Test
public void testCircleColorAsExponentialSourceFunction() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("circle-color");
assertNotNull(layer);
@@ -336,7 +344,8 @@ public class CircleLayerTest extends BaseStyleTest {
@Test
public void testCircleColorAsCategoricalSourceFunction() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("circle-color");
assertNotNull(layer);
@@ -365,7 +374,8 @@ public class CircleLayerTest extends BaseStyleTest {
@Test
public void testCircleColorAsIntConstant() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("circle-color");
assertNotNull(layer);
@@ -376,7 +386,8 @@ public class CircleLayerTest extends BaseStyleTest {
@Test
public void testCircleBlurTransition() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("circle-blurTransitionOptions");
assertNotNull(layer);
@@ -388,7 +399,8 @@ public class CircleLayerTest extends BaseStyleTest {
@Test
public void testCircleBlurAsConstant() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("circle-blur");
assertNotNull(layer);
@@ -399,7 +411,8 @@ public class CircleLayerTest extends BaseStyleTest {
@Test
public void testCircleBlurAsCameraFunction() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("circle-blur");
assertNotNull(layer);
@@ -425,7 +438,8 @@ public class CircleLayerTest extends BaseStyleTest {
@Test
public void testCircleBlurAsIdentitySourceFunction() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("circle-blur");
assertNotNull(layer);
@@ -444,7 +458,8 @@ public class CircleLayerTest extends BaseStyleTest {
@Test
public void testCircleBlurAsExponentialSourceFunction() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("circle-blur");
assertNotNull(layer);
@@ -470,7 +485,8 @@ public class CircleLayerTest extends BaseStyleTest {
@Test
public void testCircleBlurAsCategoricalSourceFunction() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("circle-blur");
assertNotNull(layer);
@@ -499,7 +515,8 @@ public class CircleLayerTest extends BaseStyleTest {
@Test
public void testCircleBlurAsCompositeFunction() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("circle-blur");
assertNotNull(layer);
@@ -533,7 +550,8 @@ public class CircleLayerTest extends BaseStyleTest {
@Test
public void testCircleOpacityTransition() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("circle-opacityTransitionOptions");
assertNotNull(layer);
@@ -545,7 +563,8 @@ public class CircleLayerTest extends BaseStyleTest {
@Test
public void testCircleOpacityAsConstant() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("circle-opacity");
assertNotNull(layer);
@@ -556,7 +575,8 @@ public class CircleLayerTest extends BaseStyleTest {
@Test
public void testCircleOpacityAsCameraFunction() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("circle-opacity");
assertNotNull(layer);
@@ -582,7 +602,8 @@ public class CircleLayerTest extends BaseStyleTest {
@Test
public void testCircleOpacityAsIdentitySourceFunction() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("circle-opacity");
assertNotNull(layer);
@@ -601,7 +622,8 @@ public class CircleLayerTest extends BaseStyleTest {
@Test
public void testCircleOpacityAsExponentialSourceFunction() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("circle-opacity");
assertNotNull(layer);
@@ -627,7 +649,8 @@ public class CircleLayerTest extends BaseStyleTest {
@Test
public void testCircleOpacityAsCategoricalSourceFunction() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("circle-opacity");
assertNotNull(layer);
@@ -656,7 +679,8 @@ public class CircleLayerTest extends BaseStyleTest {
@Test
public void testCircleOpacityAsCompositeFunction() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("circle-opacity");
assertNotNull(layer);
@@ -690,7 +714,8 @@ public class CircleLayerTest extends BaseStyleTest {
@Test
public void testCircleTranslateTransition() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("circle-translateTransitionOptions");
assertNotNull(layer);
@@ -702,7 +727,8 @@ public class CircleLayerTest extends BaseStyleTest {
@Test
public void testCircleTranslateAsConstant() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("circle-translate");
assertNotNull(layer);
@@ -713,7 +739,8 @@ public class CircleLayerTest extends BaseStyleTest {
@Test
public void testCircleTranslateAsCameraFunction() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("circle-translate");
assertNotNull(layer);
@@ -740,7 +767,8 @@ public class CircleLayerTest extends BaseStyleTest {
@Test
public void testCircleTranslateAnchorAsConstant() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("circle-translate-anchor");
assertNotNull(layer);
@@ -751,7 +779,8 @@ public class CircleLayerTest extends BaseStyleTest {
@Test
public void testCircleTranslateAnchorAsCameraFunction() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("circle-translate-anchor");
assertNotNull(layer);
@@ -777,7 +806,8 @@ public class CircleLayerTest extends BaseStyleTest {
@Test
public void testCirclePitchScaleAsConstant() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("circle-pitch-scale");
assertNotNull(layer);
@@ -788,7 +818,8 @@ public class CircleLayerTest extends BaseStyleTest {
@Test
public void testCirclePitchScaleAsCameraFunction() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("circle-pitch-scale");
assertNotNull(layer);
@@ -813,7 +844,8 @@ public class CircleLayerTest extends BaseStyleTest {
@Test
public void testCircleStrokeWidthTransition() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("circle-stroke-widthTransitionOptions");
assertNotNull(layer);
@@ -825,7 +857,8 @@ public class CircleLayerTest extends BaseStyleTest {
@Test
public void testCircleStrokeWidthAsConstant() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("circle-stroke-width");
assertNotNull(layer);
@@ -836,7 +869,8 @@ public class CircleLayerTest extends BaseStyleTest {
@Test
public void testCircleStrokeWidthAsCameraFunction() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("circle-stroke-width");
assertNotNull(layer);
@@ -862,7 +896,8 @@ public class CircleLayerTest extends BaseStyleTest {
@Test
public void testCircleStrokeWidthAsIdentitySourceFunction() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("circle-stroke-width");
assertNotNull(layer);
@@ -881,7 +916,8 @@ public class CircleLayerTest extends BaseStyleTest {
@Test
public void testCircleStrokeWidthAsExponentialSourceFunction() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("circle-stroke-width");
assertNotNull(layer);
@@ -907,7 +943,8 @@ public class CircleLayerTest extends BaseStyleTest {
@Test
public void testCircleStrokeWidthAsCategoricalSourceFunction() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("circle-stroke-width");
assertNotNull(layer);
@@ -936,7 +973,8 @@ public class CircleLayerTest extends BaseStyleTest {
@Test
public void testCircleStrokeWidthAsCompositeFunction() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("circle-stroke-width");
assertNotNull(layer);
@@ -970,7 +1008,8 @@ public class CircleLayerTest extends BaseStyleTest {
@Test
public void testCircleStrokeColorTransition() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("circle-stroke-colorTransitionOptions");
assertNotNull(layer);
@@ -982,7 +1021,8 @@ public class CircleLayerTest extends BaseStyleTest {
@Test
public void testCircleStrokeColorAsConstant() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("circle-stroke-color");
assertNotNull(layer);
@@ -993,7 +1033,8 @@ public class CircleLayerTest extends BaseStyleTest {
@Test
public void testCircleStrokeColorAsCameraFunction() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("circle-stroke-color");
assertNotNull(layer);
@@ -1019,7 +1060,8 @@ public class CircleLayerTest extends BaseStyleTest {
@Test
public void testCircleStrokeColorAsIdentitySourceFunction() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("circle-stroke-color");
assertNotNull(layer);
@@ -1038,7 +1080,8 @@ public class CircleLayerTest extends BaseStyleTest {
@Test
public void testCircleStrokeColorAsExponentialSourceFunction() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("circle-stroke-color");
assertNotNull(layer);
@@ -1064,7 +1107,8 @@ public class CircleLayerTest extends BaseStyleTest {
@Test
public void testCircleStrokeColorAsCategoricalSourceFunction() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("circle-stroke-color");
assertNotNull(layer);
@@ -1093,7 +1137,8 @@ public class CircleLayerTest extends BaseStyleTest {
@Test
public void testCircleStrokeColorAsIntConstant() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("circle-stroke-color");
assertNotNull(layer);
@@ -1104,7 +1149,8 @@ public class CircleLayerTest extends BaseStyleTest {
@Test
public void testCircleStrokeOpacityTransition() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("circle-stroke-opacityTransitionOptions");
assertNotNull(layer);
@@ -1116,7 +1162,8 @@ public class CircleLayerTest extends BaseStyleTest {
@Test
public void testCircleStrokeOpacityAsConstant() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("circle-stroke-opacity");
assertNotNull(layer);
@@ -1127,7 +1174,8 @@ public class CircleLayerTest extends BaseStyleTest {
@Test
public void testCircleStrokeOpacityAsCameraFunction() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("circle-stroke-opacity");
assertNotNull(layer);
@@ -1153,7 +1201,8 @@ public class CircleLayerTest extends BaseStyleTest {
@Test
public void testCircleStrokeOpacityAsIdentitySourceFunction() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("circle-stroke-opacity");
assertNotNull(layer);
@@ -1172,7 +1221,8 @@ public class CircleLayerTest extends BaseStyleTest {
@Test
public void testCircleStrokeOpacityAsExponentialSourceFunction() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("circle-stroke-opacity");
assertNotNull(layer);
@@ -1198,7 +1248,8 @@ public class CircleLayerTest extends BaseStyleTest {
@Test
public void testCircleStrokeOpacityAsCategoricalSourceFunction() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("circle-stroke-opacity");
assertNotNull(layer);
@@ -1227,7 +1278,8 @@ public class CircleLayerTest extends BaseStyleTest {
@Test
public void testCircleStrokeOpacityAsCompositeFunction() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("circle-stroke-opacity");
assertNotNull(layer);
@@ -1260,8 +1312,4 @@ public class CircleLayerTest extends BaseStyleTest {
}
- @After
- public void unregisterIntentServiceIdlingResource() {
- Espresso.unregisterIdlingResources(idlingResource);
- }
}
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 63dac76edd..1a1740ad07 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
@@ -22,6 +22,7 @@ import com.mapbox.mapboxsdk.style.layers.FillLayer;
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.activity.BaseActivityTest;
import org.junit.After;
import org.junit.Before;
@@ -37,28 +38,22 @@ import static com.mapbox.mapboxsdk.style.layers.Property.*;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*;
import com.mapbox.mapboxsdk.style.layers.TransitionOptions;
+import com.mapbox.mapboxsdk.testapp.activity.espresso.EspressoTestActivity;
/**
* Basic smoke tests for FillLayer
*/
@RunWith(AndroidJUnit4.class)
-public class FillLayerTest extends BaseStyleTest {
-
- @Rule
- public final ActivityTestRule rule = new ActivityTestRule<>(RuntimeStyleTestActivity.class);
+public class FillLayerTest extends BaseActivityTest {
private FillLayer layer;
- private OnMapReadyIdlingResource idlingResource;
-
- private MapboxMap mapboxMap;
-
- @Before
- public void setup() {
- idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
- Espresso.registerIdlingResources(idlingResource);
- mapboxMap = rule.getActivity().getMapboxMap();
+ @Override
+ protected Class getActivityClass() {
+ return EspressoTestActivity.class;
+ }
+ private void setupLayer(){
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
Timber.i("Adding layer");
layer = new FillLayer("my-layer", "composite");
@@ -71,7 +66,8 @@ public class FillLayerTest extends BaseStyleTest {
@Test
public void testSetVisibility() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("Visibility");
assertNotNull(layer);
@@ -86,7 +82,8 @@ public class FillLayerTest extends BaseStyleTest {
@Test
public void testFillAntialiasAsConstant() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("fill-antialias");
assertNotNull(layer);
@@ -97,7 +94,8 @@ public class FillLayerTest extends BaseStyleTest {
@Test
public void testFillAntialiasAsCameraFunction() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("fill-antialias");
assertNotNull(layer);
@@ -122,7 +120,8 @@ public class FillLayerTest extends BaseStyleTest {
@Test
public void testFillOpacityTransition() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("fill-opacityTransitionOptions");
assertNotNull(layer);
@@ -134,7 +133,8 @@ public class FillLayerTest extends BaseStyleTest {
@Test
public void testFillOpacityAsConstant() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("fill-opacity");
assertNotNull(layer);
@@ -145,7 +145,8 @@ public class FillLayerTest extends BaseStyleTest {
@Test
public void testFillOpacityAsCameraFunction() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("fill-opacity");
assertNotNull(layer);
@@ -171,7 +172,8 @@ public class FillLayerTest extends BaseStyleTest {
@Test
public void testFillOpacityAsIdentitySourceFunction() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("fill-opacity");
assertNotNull(layer);
@@ -190,7 +192,8 @@ public class FillLayerTest extends BaseStyleTest {
@Test
public void testFillOpacityAsExponentialSourceFunction() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("fill-opacity");
assertNotNull(layer);
@@ -216,7 +219,8 @@ public class FillLayerTest extends BaseStyleTest {
@Test
public void testFillOpacityAsCategoricalSourceFunction() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("fill-opacity");
assertNotNull(layer);
@@ -245,7 +249,8 @@ public class FillLayerTest extends BaseStyleTest {
@Test
public void testFillOpacityAsCompositeFunction() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("fill-opacity");
assertNotNull(layer);
@@ -279,7 +284,8 @@ public class FillLayerTest extends BaseStyleTest {
@Test
public void testFillColorTransition() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("fill-colorTransitionOptions");
assertNotNull(layer);
@@ -291,7 +297,8 @@ public class FillLayerTest extends BaseStyleTest {
@Test
public void testFillColorAsConstant() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("fill-color");
assertNotNull(layer);
@@ -302,7 +309,8 @@ public class FillLayerTest extends BaseStyleTest {
@Test
public void testFillColorAsCameraFunction() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("fill-color");
assertNotNull(layer);
@@ -328,7 +336,8 @@ public class FillLayerTest extends BaseStyleTest {
@Test
public void testFillColorAsIdentitySourceFunction() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("fill-color");
assertNotNull(layer);
@@ -347,7 +356,8 @@ public class FillLayerTest extends BaseStyleTest {
@Test
public void testFillColorAsExponentialSourceFunction() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("fill-color");
assertNotNull(layer);
@@ -373,7 +383,8 @@ public class FillLayerTest extends BaseStyleTest {
@Test
public void testFillColorAsCategoricalSourceFunction() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("fill-color");
assertNotNull(layer);
@@ -402,7 +413,8 @@ public class FillLayerTest extends BaseStyleTest {
@Test
public void testFillColorAsIntConstant() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("fill-color");
assertNotNull(layer);
@@ -413,7 +425,8 @@ public class FillLayerTest extends BaseStyleTest {
@Test
public void testFillOutlineColorTransition() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("fill-outline-colorTransitionOptions");
assertNotNull(layer);
@@ -425,7 +438,8 @@ public class FillLayerTest extends BaseStyleTest {
@Test
public void testFillOutlineColorAsConstant() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("fill-outline-color");
assertNotNull(layer);
@@ -436,7 +450,8 @@ public class FillLayerTest extends BaseStyleTest {
@Test
public void testFillOutlineColorAsCameraFunction() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("fill-outline-color");
assertNotNull(layer);
@@ -462,7 +477,8 @@ public class FillLayerTest extends BaseStyleTest {
@Test
public void testFillOutlineColorAsIdentitySourceFunction() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("fill-outline-color");
assertNotNull(layer);
@@ -481,7 +497,8 @@ public class FillLayerTest extends BaseStyleTest {
@Test
public void testFillOutlineColorAsExponentialSourceFunction() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("fill-outline-color");
assertNotNull(layer);
@@ -507,7 +524,8 @@ public class FillLayerTest extends BaseStyleTest {
@Test
public void testFillOutlineColorAsCategoricalSourceFunction() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("fill-outline-color");
assertNotNull(layer);
@@ -536,7 +554,8 @@ public class FillLayerTest extends BaseStyleTest {
@Test
public void testFillOutlineColorAsIntConstant() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("fill-outline-color");
assertNotNull(layer);
@@ -547,7 +566,8 @@ public class FillLayerTest extends BaseStyleTest {
@Test
public void testFillTranslateTransition() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("fill-translateTransitionOptions");
assertNotNull(layer);
@@ -559,7 +579,8 @@ public class FillLayerTest extends BaseStyleTest {
@Test
public void testFillTranslateAsConstant() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("fill-translate");
assertNotNull(layer);
@@ -570,7 +591,8 @@ public class FillLayerTest extends BaseStyleTest {
@Test
public void testFillTranslateAsCameraFunction() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("fill-translate");
assertNotNull(layer);
@@ -597,7 +619,8 @@ public class FillLayerTest extends BaseStyleTest {
@Test
public void testFillTranslateAnchorAsConstant() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("fill-translate-anchor");
assertNotNull(layer);
@@ -608,7 +631,8 @@ public class FillLayerTest extends BaseStyleTest {
@Test
public void testFillTranslateAnchorAsCameraFunction() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("fill-translate-anchor");
assertNotNull(layer);
@@ -633,7 +657,8 @@ public class FillLayerTest extends BaseStyleTest {
@Test
public void testFillPatternTransition() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("fill-patternTransitionOptions");
assertNotNull(layer);
@@ -645,7 +670,8 @@ public class FillLayerTest extends BaseStyleTest {
@Test
public void testFillPatternAsConstant() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("fill-pattern");
assertNotNull(layer);
@@ -656,7 +682,8 @@ public class FillLayerTest extends BaseStyleTest {
@Test
public void testFillPatternAsCameraFunction() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("fill-pattern");
assertNotNull(layer);
@@ -680,8 +707,4 @@ public class FillLayerTest extends BaseStyleTest {
}
- @After
- public void unregisterIntentServiceIdlingResource() {
- Espresso.unregisterIdlingResources(idlingResource);
- }
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/GeoJsonSourceTests.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/GeoJsonSourceTests.java
index a8d1ee5911..8afa96bd55 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/GeoJsonSourceTests.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/GeoJsonSourceTests.java
@@ -14,6 +14,7 @@ import com.mapbox.mapboxsdk.style.layers.CircleLayer;
import com.mapbox.mapboxsdk.style.layers.Layer;
import com.mapbox.mapboxsdk.style.sources.GeoJsonSource;
import com.mapbox.mapboxsdk.testapp.R;
+import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest;
import com.mapbox.mapboxsdk.testapp.activity.style.RuntimeStyleTestActivity;
import com.mapbox.mapboxsdk.testapp.utils.OnMapReadyIdlingResource;
import com.mapbox.mapboxsdk.testapp.utils.ViewUtils;
@@ -45,34 +46,20 @@ import static org.junit.Assert.fail;
* Tests for {@link GeoJsonSource}
*/
@RunWith(AndroidJUnit4.class)
-public class GeoJsonSourceTests {
+public class GeoJsonSourceTests extends BaseActivityTest {
- @Rule
- public final ActivityTestRule rule =
- new ActivityTestRule<>(RuntimeStyleTestActivity.class);
-
- private OnMapReadyIdlingResource idlingResource;
-
- @Before
- public void registerIdlingResource() {
- idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
- Espresso.registerIdlingResources(idlingResource);
- }
-
- @After
- public void unregisterIntentServiceIdlingResource() {
- Espresso.unregisterIdlingResources(idlingResource);
+ @Override
+ protected Class getActivityClass() {
+ return RuntimeStyleTestActivity.class;
}
@Test
public void testFeatureCollection() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
onView(withId(R.id.mapView)).perform(new BaseViewAction() {
@Override
public void perform(UiController uiController, View view) {
- MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
-
GeoJsonSource source = new GeoJsonSource("source", FeatureCollection
.fromJson(readRawResource(rule.getActivity().getResources(), R.raw.test_feature_collection)));
mapboxMap.addSource(source);
@@ -85,13 +72,11 @@ public class GeoJsonSourceTests {
@Test
public void testPointGeometry() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
onView(withId(R.id.mapView)).perform(new BaseViewAction() {
@Override
public void perform(UiController uiController, View view) {
- MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
-
GeoJsonSource source = new GeoJsonSource("source", Point.fromCoordinates(new double[] {0d, 0d}));
mapboxMap.addSource(source);
@@ -103,13 +88,11 @@ public class GeoJsonSourceTests {
@Test
public void testFeatureProperties() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
onView(withId(R.id.mapView)).perform(new BaseViewAction() {
@Override
public void perform(UiController uiController, View view) {
- MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
-
GeoJsonSource source = new GeoJsonSource("source",
readRawResource(rule.getActivity().getResources(), R.raw.test_feature_properties));
mapboxMap.addSource(source);
@@ -156,13 +139,11 @@ public class GeoJsonSourceTests {
}
protected void testFeatureFromResource(final @RawRes int resource) {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
onView(withId(R.id.mapView)).perform(new BaseViewAction() {
@Override
public void perform(UiController uiController, View view) {
- MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
-
GeoJsonSource source = new GeoJsonSource("source");
mapboxMap.addSource(source);
Layer layer = new CircleLayer("layer", source.getId());
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/LineLayerTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/LineLayerTest.java
index 110d23dd90..af0766aeca 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/LineLayerTest.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/LineLayerTest.java
@@ -22,6 +22,7 @@ import com.mapbox.mapboxsdk.style.layers.LineLayer;
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.activity.BaseActivityTest;
import org.junit.After;
import org.junit.Before;
@@ -37,28 +38,22 @@ import static com.mapbox.mapboxsdk.style.layers.Property.*;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*;
import com.mapbox.mapboxsdk.style.layers.TransitionOptions;
+import com.mapbox.mapboxsdk.testapp.activity.espresso.EspressoTestActivity;
/**
* Basic smoke tests for LineLayer
*/
@RunWith(AndroidJUnit4.class)
-public class LineLayerTest extends BaseStyleTest {
-
- @Rule
- public final ActivityTestRule rule = new ActivityTestRule<>(RuntimeStyleTestActivity.class);
+public class LineLayerTest extends BaseActivityTest {
private LineLayer layer;
- private OnMapReadyIdlingResource idlingResource;
-
- private MapboxMap mapboxMap;
-
- @Before
- public void setup() {
- idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
- Espresso.registerIdlingResources(idlingResource);
- mapboxMap = rule.getActivity().getMapboxMap();
+ @Override
+ protected Class getActivityClass() {
+ return EspressoTestActivity.class;
+ }
+ private void setupLayer(){
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
Timber.i("Adding layer");
layer = new LineLayer("my-layer", "composite");
@@ -71,7 +66,8 @@ public class LineLayerTest extends BaseStyleTest {
@Test
public void testSetVisibility() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("Visibility");
assertNotNull(layer);
@@ -86,7 +82,8 @@ public class LineLayerTest extends BaseStyleTest {
@Test
public void testLineCapAsConstant() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("line-cap");
assertNotNull(layer);
@@ -97,7 +94,8 @@ public class LineLayerTest extends BaseStyleTest {
@Test
public void testLineCapAsCameraFunction() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("line-cap");
assertNotNull(layer);
@@ -123,7 +121,8 @@ public class LineLayerTest extends BaseStyleTest {
@Test
public void testLineJoinAsConstant() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("line-join");
assertNotNull(layer);
@@ -134,7 +133,8 @@ public class LineLayerTest extends BaseStyleTest {
@Test
public void testLineJoinAsCameraFunction() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("line-join");
assertNotNull(layer);
@@ -160,7 +160,8 @@ public class LineLayerTest extends BaseStyleTest {
@Test
public void testLineMiterLimitAsConstant() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("line-miter-limit");
assertNotNull(layer);
@@ -171,7 +172,8 @@ public class LineLayerTest extends BaseStyleTest {
@Test
public void testLineMiterLimitAsCameraFunction() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("line-miter-limit");
assertNotNull(layer);
@@ -198,7 +200,8 @@ public class LineLayerTest extends BaseStyleTest {
@Test
public void testLineRoundLimitAsConstant() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("line-round-limit");
assertNotNull(layer);
@@ -209,7 +212,8 @@ public class LineLayerTest extends BaseStyleTest {
@Test
public void testLineRoundLimitAsCameraFunction() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("line-round-limit");
assertNotNull(layer);
@@ -235,7 +239,8 @@ public class LineLayerTest extends BaseStyleTest {
@Test
public void testLineOpacityTransition() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("line-opacityTransitionOptions");
assertNotNull(layer);
@@ -247,7 +252,8 @@ public class LineLayerTest extends BaseStyleTest {
@Test
public void testLineOpacityAsConstant() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("line-opacity");
assertNotNull(layer);
@@ -258,7 +264,8 @@ public class LineLayerTest extends BaseStyleTest {
@Test
public void testLineOpacityAsCameraFunction() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("line-opacity");
assertNotNull(layer);
@@ -284,7 +291,8 @@ public class LineLayerTest extends BaseStyleTest {
@Test
public void testLineOpacityAsIdentitySourceFunction() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("line-opacity");
assertNotNull(layer);
@@ -303,7 +311,8 @@ public class LineLayerTest extends BaseStyleTest {
@Test
public void testLineOpacityAsExponentialSourceFunction() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("line-opacity");
assertNotNull(layer);
@@ -329,7 +338,8 @@ public class LineLayerTest extends BaseStyleTest {
@Test
public void testLineOpacityAsCategoricalSourceFunction() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("line-opacity");
assertNotNull(layer);
@@ -358,7 +368,8 @@ public class LineLayerTest extends BaseStyleTest {
@Test
public void testLineOpacityAsCompositeFunction() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("line-opacity");
assertNotNull(layer);
@@ -392,7 +403,8 @@ public class LineLayerTest extends BaseStyleTest {
@Test
public void testLineColorTransition() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("line-colorTransitionOptions");
assertNotNull(layer);
@@ -404,7 +416,8 @@ public class LineLayerTest extends BaseStyleTest {
@Test
public void testLineColorAsConstant() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("line-color");
assertNotNull(layer);
@@ -415,7 +428,8 @@ public class LineLayerTest extends BaseStyleTest {
@Test
public void testLineColorAsCameraFunction() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("line-color");
assertNotNull(layer);
@@ -441,7 +455,8 @@ public class LineLayerTest extends BaseStyleTest {
@Test
public void testLineColorAsIdentitySourceFunction() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("line-color");
assertNotNull(layer);
@@ -460,7 +475,8 @@ public class LineLayerTest extends BaseStyleTest {
@Test
public void testLineColorAsExponentialSourceFunction() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("line-color");
assertNotNull(layer);
@@ -486,7 +502,8 @@ public class LineLayerTest extends BaseStyleTest {
@Test
public void testLineColorAsCategoricalSourceFunction() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("line-color");
assertNotNull(layer);
@@ -515,7 +532,8 @@ public class LineLayerTest extends BaseStyleTest {
@Test
public void testLineColorAsIntConstant() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("line-color");
assertNotNull(layer);
@@ -526,7 +544,8 @@ public class LineLayerTest extends BaseStyleTest {
@Test
public void testLineTranslateTransition() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("line-translateTransitionOptions");
assertNotNull(layer);
@@ -538,7 +557,8 @@ public class LineLayerTest extends BaseStyleTest {
@Test
public void testLineTranslateAsConstant() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("line-translate");
assertNotNull(layer);
@@ -549,7 +569,8 @@ public class LineLayerTest extends BaseStyleTest {
@Test
public void testLineTranslateAsCameraFunction() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("line-translate");
assertNotNull(layer);
@@ -576,7 +597,8 @@ public class LineLayerTest extends BaseStyleTest {
@Test
public void testLineTranslateAnchorAsConstant() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("line-translate-anchor");
assertNotNull(layer);
@@ -587,7 +609,8 @@ public class LineLayerTest extends BaseStyleTest {
@Test
public void testLineTranslateAnchorAsCameraFunction() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("line-translate-anchor");
assertNotNull(layer);
@@ -612,7 +635,8 @@ public class LineLayerTest extends BaseStyleTest {
@Test
public void testLineWidthTransition() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("line-widthTransitionOptions");
assertNotNull(layer);
@@ -624,7 +648,8 @@ public class LineLayerTest extends BaseStyleTest {
@Test
public void testLineWidthAsConstant() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("line-width");
assertNotNull(layer);
@@ -635,7 +660,8 @@ public class LineLayerTest extends BaseStyleTest {
@Test
public void testLineWidthAsCameraFunction() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("line-width");
assertNotNull(layer);
@@ -661,7 +687,8 @@ public class LineLayerTest extends BaseStyleTest {
@Test
public void testLineGapWidthTransition() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("line-gap-widthTransitionOptions");
assertNotNull(layer);
@@ -673,7 +700,8 @@ public class LineLayerTest extends BaseStyleTest {
@Test
public void testLineGapWidthAsConstant() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("line-gap-width");
assertNotNull(layer);
@@ -684,7 +712,8 @@ public class LineLayerTest extends BaseStyleTest {
@Test
public void testLineGapWidthAsCameraFunction() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("line-gap-width");
assertNotNull(layer);
@@ -710,7 +739,8 @@ public class LineLayerTest extends BaseStyleTest {
@Test
public void testLineGapWidthAsIdentitySourceFunction() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("line-gap-width");
assertNotNull(layer);
@@ -729,7 +759,8 @@ public class LineLayerTest extends BaseStyleTest {
@Test
public void testLineGapWidthAsExponentialSourceFunction() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("line-gap-width");
assertNotNull(layer);
@@ -755,7 +786,8 @@ public class LineLayerTest extends BaseStyleTest {
@Test
public void testLineGapWidthAsCategoricalSourceFunction() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("line-gap-width");
assertNotNull(layer);
@@ -784,7 +816,8 @@ public class LineLayerTest extends BaseStyleTest {
@Test
public void testLineGapWidthAsCompositeFunction() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("line-gap-width");
assertNotNull(layer);
@@ -818,7 +851,8 @@ public class LineLayerTest extends BaseStyleTest {
@Test
public void testLineOffsetTransition() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("line-offsetTransitionOptions");
assertNotNull(layer);
@@ -830,7 +864,8 @@ public class LineLayerTest extends BaseStyleTest {
@Test
public void testLineOffsetAsConstant() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("line-offset");
assertNotNull(layer);
@@ -841,7 +876,8 @@ public class LineLayerTest extends BaseStyleTest {
@Test
public void testLineOffsetAsCameraFunction() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("line-offset");
assertNotNull(layer);
@@ -867,7 +903,8 @@ public class LineLayerTest extends BaseStyleTest {
@Test
public void testLineOffsetAsIdentitySourceFunction() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("line-offset");
assertNotNull(layer);
@@ -886,7 +923,8 @@ public class LineLayerTest extends BaseStyleTest {
@Test
public void testLineOffsetAsExponentialSourceFunction() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("line-offset");
assertNotNull(layer);
@@ -912,7 +950,8 @@ public class LineLayerTest extends BaseStyleTest {
@Test
public void testLineOffsetAsCategoricalSourceFunction() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("line-offset");
assertNotNull(layer);
@@ -941,7 +980,8 @@ public class LineLayerTest extends BaseStyleTest {
@Test
public void testLineOffsetAsCompositeFunction() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("line-offset");
assertNotNull(layer);
@@ -975,7 +1015,8 @@ public class LineLayerTest extends BaseStyleTest {
@Test
public void testLineBlurTransition() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("line-blurTransitionOptions");
assertNotNull(layer);
@@ -987,7 +1028,8 @@ public class LineLayerTest extends BaseStyleTest {
@Test
public void testLineBlurAsConstant() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("line-blur");
assertNotNull(layer);
@@ -998,7 +1040,8 @@ public class LineLayerTest extends BaseStyleTest {
@Test
public void testLineBlurAsCameraFunction() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("line-blur");
assertNotNull(layer);
@@ -1024,7 +1067,8 @@ public class LineLayerTest extends BaseStyleTest {
@Test
public void testLineBlurAsIdentitySourceFunction() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("line-blur");
assertNotNull(layer);
@@ -1043,7 +1087,8 @@ public class LineLayerTest extends BaseStyleTest {
@Test
public void testLineBlurAsExponentialSourceFunction() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("line-blur");
assertNotNull(layer);
@@ -1069,7 +1114,8 @@ public class LineLayerTest extends BaseStyleTest {
@Test
public void testLineBlurAsCategoricalSourceFunction() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("line-blur");
assertNotNull(layer);
@@ -1098,7 +1144,8 @@ public class LineLayerTest extends BaseStyleTest {
@Test
public void testLineBlurAsCompositeFunction() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("line-blur");
assertNotNull(layer);
@@ -1132,7 +1179,8 @@ public class LineLayerTest extends BaseStyleTest {
@Test
public void testLineDasharrayTransition() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("line-dasharrayTransitionOptions");
assertNotNull(layer);
@@ -1144,7 +1192,8 @@ public class LineLayerTest extends BaseStyleTest {
@Test
public void testLineDasharrayAsConstant() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("line-dasharray");
assertNotNull(layer);
@@ -1155,7 +1204,8 @@ public class LineLayerTest extends BaseStyleTest {
@Test
public void testLineDasharrayAsCameraFunction() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("line-dasharray");
assertNotNull(layer);
@@ -1180,7 +1230,8 @@ public class LineLayerTest extends BaseStyleTest {
@Test
public void testLinePatternTransition() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("line-patternTransitionOptions");
assertNotNull(layer);
@@ -1192,7 +1243,8 @@ public class LineLayerTest extends BaseStyleTest {
@Test
public void testLinePatternAsConstant() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("line-pattern");
assertNotNull(layer);
@@ -1203,7 +1255,8 @@ public class LineLayerTest extends BaseStyleTest {
@Test
public void testLinePatternAsCameraFunction() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("line-pattern");
assertNotNull(layer);
@@ -1227,8 +1280,4 @@ public class LineLayerTest extends BaseStyleTest {
}
- @After
- public void unregisterIntentServiceIdlingResource() {
- Espresso.unregisterIdlingResources(idlingResource);
- }
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/RasterLayerTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/RasterLayerTest.java
index 2d902a7432..e365056b84 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/RasterLayerTest.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/RasterLayerTest.java
@@ -22,6 +22,7 @@ import com.mapbox.mapboxsdk.style.layers.RasterLayer;
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.activity.BaseActivityTest;
import org.junit.After;
import org.junit.Before;
@@ -37,28 +38,22 @@ import static com.mapbox.mapboxsdk.style.layers.Property.*;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*;
import com.mapbox.mapboxsdk.style.layers.TransitionOptions;
+import com.mapbox.mapboxsdk.testapp.activity.espresso.EspressoTestActivity;
/**
* Basic smoke tests for RasterLayer
*/
@RunWith(AndroidJUnit4.class)
-public class RasterLayerTest extends BaseStyleTest {
-
- @Rule
- public final ActivityTestRule rule = new ActivityTestRule<>(RuntimeStyleTestActivity.class);
+public class RasterLayerTest extends BaseActivityTest {
private RasterLayer layer;
- private OnMapReadyIdlingResource idlingResource;
-
- private MapboxMap mapboxMap;
-
- @Before
- public void setup() {
- idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
- Espresso.registerIdlingResources(idlingResource);
- mapboxMap = rule.getActivity().getMapboxMap();
+ @Override
+ protected Class getActivityClass() {
+ return EspressoTestActivity.class;
+ }
+ private void setupLayer(){
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
Timber.i("Adding layer");
layer = new RasterLayer("my-layer", "composite");
@@ -71,7 +66,8 @@ public class RasterLayerTest extends BaseStyleTest {
@Test
public void testSetVisibility() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("Visibility");
assertNotNull(layer);
@@ -85,7 +81,8 @@ public class RasterLayerTest extends BaseStyleTest {
@Test
public void testRasterOpacityTransition() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("raster-opacityTransitionOptions");
assertNotNull(layer);
@@ -97,7 +94,8 @@ public class RasterLayerTest extends BaseStyleTest {
@Test
public void testRasterOpacityAsConstant() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("raster-opacity");
assertNotNull(layer);
@@ -108,7 +106,8 @@ public class RasterLayerTest extends BaseStyleTest {
@Test
public void testRasterOpacityAsCameraFunction() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("raster-opacity");
assertNotNull(layer);
@@ -134,7 +133,8 @@ public class RasterLayerTest extends BaseStyleTest {
@Test
public void testRasterHueRotateTransition() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("raster-hue-rotateTransitionOptions");
assertNotNull(layer);
@@ -146,7 +146,8 @@ public class RasterLayerTest extends BaseStyleTest {
@Test
public void testRasterHueRotateAsConstant() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("raster-hue-rotate");
assertNotNull(layer);
@@ -157,7 +158,8 @@ public class RasterLayerTest extends BaseStyleTest {
@Test
public void testRasterHueRotateAsCameraFunction() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("raster-hue-rotate");
assertNotNull(layer);
@@ -183,7 +185,8 @@ public class RasterLayerTest extends BaseStyleTest {
@Test
public void testRasterBrightnessMinTransition() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("raster-brightness-minTransitionOptions");
assertNotNull(layer);
@@ -195,7 +198,8 @@ public class RasterLayerTest extends BaseStyleTest {
@Test
public void testRasterBrightnessMinAsConstant() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("raster-brightness-min");
assertNotNull(layer);
@@ -206,7 +210,8 @@ public class RasterLayerTest extends BaseStyleTest {
@Test
public void testRasterBrightnessMinAsCameraFunction() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("raster-brightness-min");
assertNotNull(layer);
@@ -232,7 +237,8 @@ public class RasterLayerTest extends BaseStyleTest {
@Test
public void testRasterBrightnessMaxTransition() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("raster-brightness-maxTransitionOptions");
assertNotNull(layer);
@@ -244,7 +250,8 @@ public class RasterLayerTest extends BaseStyleTest {
@Test
public void testRasterBrightnessMaxAsConstant() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("raster-brightness-max");
assertNotNull(layer);
@@ -255,7 +262,8 @@ public class RasterLayerTest extends BaseStyleTest {
@Test
public void testRasterBrightnessMaxAsCameraFunction() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("raster-brightness-max");
assertNotNull(layer);
@@ -281,7 +289,8 @@ public class RasterLayerTest extends BaseStyleTest {
@Test
public void testRasterSaturationTransition() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("raster-saturationTransitionOptions");
assertNotNull(layer);
@@ -293,7 +302,8 @@ public class RasterLayerTest extends BaseStyleTest {
@Test
public void testRasterSaturationAsConstant() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("raster-saturation");
assertNotNull(layer);
@@ -304,7 +314,8 @@ public class RasterLayerTest extends BaseStyleTest {
@Test
public void testRasterSaturationAsCameraFunction() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("raster-saturation");
assertNotNull(layer);
@@ -330,7 +341,8 @@ public class RasterLayerTest extends BaseStyleTest {
@Test
public void testRasterContrastTransition() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("raster-contrastTransitionOptions");
assertNotNull(layer);
@@ -342,7 +354,8 @@ public class RasterLayerTest extends BaseStyleTest {
@Test
public void testRasterContrastAsConstant() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("raster-contrast");
assertNotNull(layer);
@@ -353,7 +366,8 @@ public class RasterLayerTest extends BaseStyleTest {
@Test
public void testRasterContrastAsCameraFunction() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("raster-contrast");
assertNotNull(layer);
@@ -379,7 +393,8 @@ public class RasterLayerTest extends BaseStyleTest {
@Test
public void testRasterFadeDurationTransition() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("raster-fade-durationTransitionOptions");
assertNotNull(layer);
@@ -391,7 +406,8 @@ public class RasterLayerTest extends BaseStyleTest {
@Test
public void testRasterFadeDurationAsConstant() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("raster-fade-duration");
assertNotNull(layer);
@@ -402,7 +418,8 @@ public class RasterLayerTest extends BaseStyleTest {
@Test
public void testRasterFadeDurationAsCameraFunction() {
- checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
+ setupLayer();
Timber.i("raster-fade-duration");
assertNotNull(layer);
@@ -427,8 +444,4 @@ public class RasterLayerTest extends BaseStyleTest {
}
- @After
- public void unregisterIntentServiceIdlingResource() {
- Espresso.unregisterIdlingResources(idlingResource);
- }
}
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 bf90949ffd..191e97727d 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
@@ -5,7 +5,6 @@ import android.graphics.PointF;
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;
@@ -20,16 +19,13 @@ import com.mapbox.mapboxsdk.style.sources.CannotAddSourceException;
import com.mapbox.mapboxsdk.style.sources.Source;
import com.mapbox.mapboxsdk.style.sources.VectorSource;
import com.mapbox.mapboxsdk.testapp.R;
+import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest;
import com.mapbox.mapboxsdk.testapp.activity.style.RuntimeStyleTestActivity;
-import com.mapbox.mapboxsdk.testapp.utils.OnMapReadyIdlingResource;
-import com.mapbox.mapboxsdk.testapp.utils.ViewUtils;
import junit.framework.Assert;
import org.hamcrest.Matcher;
import org.junit.After;
-import org.junit.Before;
-import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -50,28 +46,20 @@ import static org.junit.Assert.fail;
* Basic smoke tests for Layer and Source
*/
@RunWith(AndroidJUnit4.class)
-public class RuntimeStyleTests {
+public class RuntimeStyleTests extends BaseActivityTest {
- @Rule
- public final ActivityTestRule rule = new ActivityTestRule<>(RuntimeStyleTestActivity.class);
-
- private OnMapReadyIdlingResource idlingResource;
-
- @Before
- public void registerIdlingResource() {
- idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
- Espresso.registerIdlingResources(idlingResource);
+ @Override
+ protected Class getActivityClass() {
+ return RuntimeStyleTestActivity.class;
}
@Test
public void testListLayers() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
onView(withId(R.id.mapView)).perform(new BaseViewAction() {
@Override
public void perform(UiController uiController, View view) {
- MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
-
List layers = mapboxMap.getLayers();
assertNotNull(layers);
assertTrue(layers.size() > 0);
@@ -85,18 +73,16 @@ public class RuntimeStyleTests {
@Test
public void testGetAddRemoveLayer() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
onView(withId(R.id.mapView)).perform(new AddRemoveLayerAction());
}
@Test
public void testAddLayerAbove() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
onView(withId(R.id.mapView)).perform(new BaseViewAction() {
@Override
public void perform(UiController uiController, View view) {
- MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
-
List layers = mapboxMap.getLayers();
Source source = mapboxMap.getSources().get(0);
@@ -126,13 +112,11 @@ public class RuntimeStyleTests {
@Test
public void testRemoveLayerAt() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
onView(withId(R.id.mapView)).perform(new BaseViewAction() {
@Override
public void perform(UiController uiController, View view) {
- MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
-
// Remove by index
Layer firstLayer = mapboxMap.getLayers().get(0);
Layer removed = mapboxMap.removeLayerAt(0);
@@ -148,12 +132,10 @@ public class RuntimeStyleTests {
}
public void testAddLayerAt() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
onView(withId(R.id.mapView)).perform(new BaseViewAction() {
@Override
public void perform(UiController uiController, View view) {
- MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
-
List layers = mapboxMap.getLayers();
Source source = mapboxMap.getSources().get(0);
@@ -184,13 +166,11 @@ public class RuntimeStyleTests {
@Test
public void testListSources() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
+ validateTestSetup();
onView(withId(R.id.mapView)).perform(new BaseViewAction() {
@Override
public void perform(UiController uiController, View view) {
- MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
-
List