diff options
author | Tobrun Van Nuland <tobrun.van.nuland@gmail.com> | 2017-04-05 21:58:36 +0200 |
---|---|---|
committer | Tobrun Van Nuland <tobrun.van.nuland@gmail.com> | 2017-04-05 21:58:36 +0200 |
commit | e0a5365a70369530d8a0cedf9ce8cf524c7a6be3 (patch) | |
tree | 425690f7dfdff6dbf5510a9bda3fc436bcb020da /platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/annotations | |
parent | b404457a74d7a63103285712552a8564823db6d9 (diff) | |
download | qtlocation-mapboxgl-e0a5365a70369530d8a0cedf9ce8cf524c7a6be3.tar.gz |
[android] - rework instrumentation testsupstream/tvn-instrumentation-test-rework
Diffstat (limited to 'platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/annotations')
4 files changed, 29 insertions, 91 deletions
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<EspressoTestActivity> 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<EspressoTestActivity> 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<EspressoTestActivity> 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<EspressoTestActivity> 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); - } } |