diff options
58 files changed, 283 insertions, 834 deletions
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/LocationComponentTest.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/LocationComponentTest.kt index 3fbc086621..9868108350 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/LocationComponentTest.kt +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/LocationComponentTest.kt @@ -27,8 +27,8 @@ import com.mapbox.mapboxsdk.location.utils.MapboxTestingUtils.Companion.MAP_CONN import com.mapbox.mapboxsdk.location.utils.MapboxTestingUtils.Companion.MAP_RENDER_DELAY import com.mapbox.mapboxsdk.location.utils.MapboxTestingUtils.Companion.pushSourceUpdates import com.mapbox.mapboxsdk.maps.MapboxMap -import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest -import com.mapbox.mapboxsdk.testapp.activity.SingleActivity +import com.mapbox.mapboxsdk.testapp.activity.EspressoTest +import com.mapbox.mapboxsdk.testapp.activity.espresso.EspressoTestActivity import com.mapbox.mapboxsdk.utils.ColorUtils import org.hamcrest.CoreMatchers.* import org.junit.* @@ -37,16 +37,12 @@ import org.junit.Assert.assertTrue import org.junit.runner.RunWith @RunWith(AndroidJUnit4::class) -class LocationComponentTest : BaseActivityTest() { +class LocationComponentTest : EspressoTest() { @Rule @JvmField val permissionRule: GrantPermissionRule = GrantPermissionRule.grant(Manifest.permission.ACCESS_FINE_LOCATION) - override fun getActivityClass(): Class<*> { - return SingleActivity::class.java - } - private lateinit var styleChangeIdlingResource: StyleChangeIdlingResource private val location: Location by lazy { val initLocation = Location("") @@ -188,7 +184,7 @@ class LocationComponentTest : BaseActivityTest() { component.isLocationComponentEnabled = true // Source should be present but empty - val mapView = (rule.activity as SingleActivity).mapView + val mapView = (rule.activity as EspressoTestActivity).mapView assertThat(mapboxMap.queryRenderedFeatures( RectF(0f, 0f, mapView.width.toFloat(), mapView.height.toFloat()), FOREGROUND_LAYER) .isEmpty(), `is`(true)) diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/LocationLayerControllerTest.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/LocationLayerControllerTest.kt index 12ae701d0a..44126647c0 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/LocationLayerControllerTest.kt +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/LocationLayerControllerTest.kt @@ -25,8 +25,7 @@ import com.mapbox.mapboxsdk.location.utils.MapboxTestingUtils.Companion.MAP_REND import com.mapbox.mapboxsdk.location.utils.MapboxTestingUtils.Companion.pushSourceUpdates import com.mapbox.mapboxsdk.maps.MapboxMap import com.mapbox.mapboxsdk.style.sources.GeoJsonSource -import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest -import com.mapbox.mapboxsdk.testapp.activity.SingleActivity +import com.mapbox.mapboxsdk.testapp.activity.EspressoTest import org.hamcrest.CoreMatchers.`is` import org.hamcrest.CoreMatchers.notNullValue import org.hamcrest.Matchers.equalTo @@ -39,16 +38,12 @@ import org.junit.Test import org.junit.runner.RunWith @RunWith(AndroidJUnit4::class) -class LocationLayerControllerTest : BaseActivityTest() { +class LocationLayerControllerTest : EspressoTest() { @Rule @JvmField val permissionRule: GrantPermissionRule = grant(Manifest.permission.ACCESS_FINE_LOCATION) - override fun getActivityClass(): Class<*> { - return SingleActivity::class.java - } - private lateinit var styleChangeIdlingResource: StyleChangeIdlingResource private val location: Location by lazy { val initLocation = Location("") 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 1b403dc08e..00ec1fe601 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 @@ -14,8 +14,7 @@ import com.mapbox.mapboxsdk.annotations.PolylineOptions; 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.activity.EspressoTest; import org.hamcrest.Matcher; import org.junit.Test; @@ -39,18 +38,7 @@ import static org.junit.Assert.assertTrue; * @deprecated remove this file when removing deprecated annotations */ @Deprecated -public class MapboxMapTest extends BaseActivityTest { - - @Override - protected Class getActivityClass() { - return EspressoTestActivity.class; - } - - @Test - public void testSanity() { - validateTestSetup(); - assertNotNull("mapboxMap should not be null", mapboxMap); - } +public class MapboxMapTest extends EspressoTest { // // InfoWindow diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/MapboxTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/MapboxTest.java index 7c84a92ae0..b56d267b81 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/MapboxTest.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/MapboxTest.java @@ -1,27 +1,22 @@ package com.mapbox.mapboxsdk.maps; +import android.support.test.runner.AndroidJUnit4; import com.mapbox.mapboxsdk.Mapbox; -import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest; -import com.mapbox.mapboxsdk.testapp.activity.espresso.EspressoTestActivity; import org.junit.Test; +import org.junit.runner.RunWith; import static junit.framework.Assert.assertFalse; import static junit.framework.Assert.assertSame; import static junit.framework.Assert.assertTrue; -public class MapboxTest extends BaseActivityTest { +@RunWith(AndroidJUnit4.class) +public class MapboxTest { private static final String ACCESS_TOKEN = "pk.0000000001"; private static final String ACCESS_TOKEN_2 = "pk.0000000002"; - @Override - protected Class getActivityClass() { - return EspressoTestActivity.class; - } - @Test public void testConnected() { - validateTestSetup(); assertTrue(Mapbox.isConnected()); // test manual connectivity @@ -37,7 +32,6 @@ public class MapboxTest extends BaseActivityTest { @Test public void setAccessToken() { - validateTestSetup(); String realToken = Mapbox.getAccessToken(); Mapbox.setAccessToken(ACCESS_TOKEN); assertSame(ACCESS_TOKEN, Mapbox.getAccessToken()); diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/OrientationTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/OrientationTest.java index 89397c30eb..14a2c3bdbf 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/OrientationTest.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/OrientationTest.java @@ -1,6 +1,6 @@ package com.mapbox.mapboxsdk.maps; -import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest; +import com.mapbox.mapboxsdk.testapp.activity.BaseTest; import com.mapbox.mapboxsdk.testapp.activity.camera.CameraAnimationTypeActivity; import org.junit.Test; @@ -11,7 +11,7 @@ import static com.mapbox.mapboxsdk.testapp.action.OrientationChangeAction.orient import static com.mapbox.mapboxsdk.testapp.action.OrientationChangeAction.orientationPortrait; import static com.mapbox.mapboxsdk.testapp.action.OrientationChangeAction.orientationPortraitReverse; -public class OrientationTest extends BaseActivityTest { +public class OrientationTest extends BaseTest { @Test public void testChangeDeviceOrientation() { diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/TransformTest.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/TransformTest.kt index a47ebd6000..85a4bd65a8 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/TransformTest.kt +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/TransformTest.kt @@ -4,15 +4,11 @@ import android.support.test.espresso.UiController import com.mapbox.mapboxsdk.camera.CameraUpdateFactory import com.mapbox.mapboxsdk.geometry.LatLng import com.mapbox.mapboxsdk.testapp.action.MapboxMapAction.invoke -import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest -import com.mapbox.mapboxsdk.testapp.activity.maplayout.SimpleMapActivity +import com.mapbox.mapboxsdk.testapp.activity.EspressoTest import org.junit.Assert.assertEquals import org.junit.Test - -class TransformTest: BaseActivityTest() { - - override fun getActivityClass(): Class<*> = SimpleMapActivity::class.java +class TransformTest: EspressoTest() { companion object { val initialCameraUpdate = CameraUpdateFactory.newLatLngZoom(LatLng(12.0,12.0), 12.0)!! @@ -21,7 +17,7 @@ class TransformTest: BaseActivityTest() { @Test fun mapboxMapScrollByWithPadding() { validateTestSetup() - invoke(mapboxMap) { uiController: UiController, mapboxMap: MapboxMap -> + invoke(mapboxMap) { _: UiController, mapboxMap: MapboxMap -> mapboxMap.moveCamera(initialCameraUpdate) mapboxMap.scrollBy(400.0f, 0.0f) val expectedCameraPosition = mapboxMap.cameraPosition diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/VisibleRegionTest.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/VisibleRegionTest.kt index 72ff293c3e..4866812e67 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/VisibleRegionTest.kt +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/VisibleRegionTest.kt @@ -7,20 +7,16 @@ import com.mapbox.mapboxsdk.geometry.LatLng import com.mapbox.mapboxsdk.maps.MapView import com.mapbox.mapboxsdk.maps.MapboxMap import com.mapbox.mapboxsdk.testapp.action.MapboxMapAction.invoke -import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest +import com.mapbox.mapboxsdk.testapp.activity.EspressoTest import com.mapbox.mapboxsdk.testapp.activity.espresso.EspressoTestActivity import org.junit.Assert.assertFalse import org.junit.Assert.assertTrue import org.junit.Test -class VisibleRegionTest : BaseActivityTest() { +class VisibleRegionTest : EspressoTest() { private lateinit var mapView: MapView - override fun getActivityClass(): Class<*> { - return EspressoTestActivity::class.java - } - override fun beforeTest() { super.beforeTest() mapView = (rule.activity as EspressoTestActivity).mapView diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/action/WaitAction.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/action/WaitAction.java index 26a3a2e4ab..5d98ccb7f8 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/action/WaitAction.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/action/WaitAction.java @@ -10,13 +10,8 @@ import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed; public final class WaitAction implements ViewAction { - private static final long DEFAULT_LOOP_TIME = 375; private final long loopTime; - public WaitAction() { - this(DEFAULT_LOOP_TIME); - } - public WaitAction(long loopTime) { this.loopTime = loopTime; } 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/BaseTest.java index a0168cc63d..ea69f8adae 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/BaseTest.java @@ -3,6 +3,7 @@ package com.mapbox.mapboxsdk.testapp.activity; import android.app.Activity; import android.support.test.espresso.Espresso; import android.support.test.espresso.IdlingRegistry; +import android.support.test.espresso.IdlingResource; import android.support.test.espresso.IdlingResourceTimeoutException; import android.support.test.espresso.ViewInteraction; import android.support.test.rule.ActivityTestRule; @@ -12,8 +13,9 @@ import com.mapbox.mapboxsdk.maps.MapboxMap; import com.mapbox.mapboxsdk.testapp.R; import com.mapbox.mapboxsdk.testapp.action.MapboxMapAction; import com.mapbox.mapboxsdk.testapp.action.WaitAction; -import com.mapbox.mapboxsdk.testapp.utils.OnMapReadyIdlingResource; +import com.mapbox.mapboxsdk.testapp.utils.FinishLoadingStyleIdlingResource; +import com.mapbox.mapboxsdk.testapp.utils.MapboxIdlingResource; import junit.framework.Assert; import org.junit.After; @@ -28,7 +30,10 @@ 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; -public abstract class BaseActivityTest { +/** + * Base class for all Activity test hooking into an existing Activity that will load style. + */ +public abstract class BaseTest { @Rule public ActivityTestRule<Activity> rule = new ActivityTestRule<>(getActivityClass()); @@ -37,7 +42,7 @@ public abstract class BaseActivityTest { public TestName testNameRule = new TestName(); protected MapboxMap mapboxMap; - protected OnMapReadyIdlingResource idlingResource; + protected MapboxIdlingResource idlingResource; @Before public void beforeTest() { @@ -48,19 +53,25 @@ public abstract class BaseActivityTest { testNameRule.getMethodName(), "@Before test: register idle resource" )); - idlingResource = new OnMapReadyIdlingResource(rule.getActivity()); + idlingResource = (MapboxIdlingResource) generateIdlingResource(); IdlingRegistry.getInstance().register(idlingResource); Espresso.onIdle(); mapboxMap = idlingResource.getMapboxMap(); } catch (IdlingResourceTimeoutException idlingResourceTimeoutException) { - throw new RuntimeException(String.format("Could not start %s test for %s.\n Either the ViewHierarchy doesn't " - + "contain a view with resource id = R.id.mapView or \n the hosting Activity wasn't in an idle state.", - testNameRule.getMethodName(), - getActivityClass().getSimpleName()) + throw new RuntimeException( + String.format( + "Could not start %s test for %s.", + testNameRule.getMethodName(), + getActivityClass().getSimpleName() + ) ); } } + protected IdlingResource generateIdlingResource() { + return new FinishLoadingStyleIdlingResource(rule.getActivity()); + } + protected void validateTestSetup() { if (!Mapbox.isConnected()) { Timber.e("Not connected to the internet while running test"); diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/EspressoTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/EspressoTest.java new file mode 100644 index 0000000000..dfb4a46180 --- /dev/null +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/EspressoTest.java @@ -0,0 +1,24 @@ +package com.mapbox.mapboxsdk.testapp.activity; + +import android.support.test.espresso.IdlingResource; +import com.mapbox.mapboxsdk.testapp.activity.espresso.EspressoTestActivity; +import com.mapbox.mapboxsdk.testapp.utils.LoadStyleIdlingResource; + +/** + * Base class for all tests using EspressoTestActivity as wrapper. + * <p> + * Uses {@link LoadStyleIdlingResource} to load "assets/streets.json" as style. + * </p> + */ +public class EspressoTest extends BaseTest { + + @Override + protected IdlingResource generateIdlingResource() { + return new LoadStyleIdlingResource(rule.getActivity()); + } + + @Override + protected final Class getActivityClass() { + return EspressoTestActivity.class; + } +} 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 03d4de17f4..22082400b5 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 @@ -7,27 +7,22 @@ package com.mapbox.mapboxsdk.testapp.activity.gen.<%- subPackage %>; import android.support.test.runner.AndroidJUnit4; -import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest; -import com.mapbox.mapboxsdk.testapp.R; +import com.mapbox.mapboxsdk.testapp.activity.BaseTest; import com.mapbox.mapboxsdk.testapp.activity.<%- subPackage %>.<%- activity %>; +import junit.framework.Assert; 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; -import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed; -import static android.support.test.espresso.matcher.ViewMatchers.withId; - /** * Sanity test for <%- activity %> */ @RunWith(AndroidJUnit4.class) -public class <%- activity %>Test extends BaseActivityTest { +public class <%- activity %>Test extends BaseTest { @Test public void testSanity() { - validateTestSetup(); + } @Override diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/annotations/IconTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/annotations/IconTest.java index c0bf35e3ce..9fb823a377 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/annotations/IconTest.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/annotations/IconTest.java @@ -9,8 +9,7 @@ import com.mapbox.mapboxsdk.annotations.MarkerOptions; import com.mapbox.mapboxsdk.geometry.LatLng; import com.mapbox.mapboxsdk.maps.IconManagerResolver; 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.activity.EspressoTest; import com.mapbox.mapboxsdk.testapp.utils.IconUtils; import org.junit.Before; import org.junit.Test; @@ -25,7 +24,7 @@ import static junit.framework.Assert.assertTrue; /** * Tests integration between Icons and Markers */ -public class IconTest extends BaseActivityTest { +public class IconTest extends EspressoTest { private Map<Icon, Integer> iconMap; @@ -145,9 +144,4 @@ public class IconTest extends BaseActivityTest { assertEquals("Amount of icons should match 0", 0, iconMap.size()); })); } - - @Override - protected Class getActivityClass() { - return EspressoTestActivity.class; - } } 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 11756d3d32..2328023a3d 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 @@ -4,8 +4,7 @@ import com.mapbox.mapboxsdk.annotations.Marker; import com.mapbox.mapboxsdk.annotations.MarkerOptions; import com.mapbox.mapboxsdk.geometry.LatLng; import com.mapbox.mapboxsdk.testapp.action.MapboxMapAction; -import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest; -import com.mapbox.mapboxsdk.testapp.activity.espresso.EspressoTestActivity; +import com.mapbox.mapboxsdk.testapp.activity.EspressoTest; import com.mapbox.mapboxsdk.testapp.utils.TestConstants; import org.junit.Ignore; @@ -18,15 +17,10 @@ import static android.support.test.espresso.matcher.ViewMatchers.withText; import static com.mapbox.mapboxsdk.testapp.action.MapboxMapAction.invoke; import static org.junit.Assert.assertEquals; -public class MarkerTest extends BaseActivityTest { +public class MarkerTest extends EspressoTest { private Marker marker; - @Override - protected Class getActivityClass() { - return EspressoTestActivity.class; - } - @Test @Ignore public void addMarkerTest() { 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 be969f29c3..b604bb7da1 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 @@ -5,8 +5,7 @@ import android.graphics.Color; import com.mapbox.mapboxsdk.annotations.Polygon; import com.mapbox.mapboxsdk.annotations.PolygonOptions; import com.mapbox.mapboxsdk.geometry.LatLng; -import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest; -import com.mapbox.mapboxsdk.testapp.activity.espresso.EspressoTestActivity; +import com.mapbox.mapboxsdk.testapp.activity.EspressoTest; import org.junit.Ignore; import org.junit.Test; @@ -14,12 +13,7 @@ import org.junit.Test; import static com.mapbox.mapboxsdk.testapp.action.MapboxMapAction.invoke; import static org.junit.Assert.assertEquals; -public class PolygonTest extends BaseActivityTest { - - @Override - protected Class getActivityClass() { - return EspressoTestActivity.class; - } +public class PolygonTest extends EspressoTest { @Test @Ignore 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 b9c68ceab7..f977e25981 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 @@ -5,8 +5,7 @@ import android.graphics.Color; import com.mapbox.mapboxsdk.annotations.Polyline; import com.mapbox.mapboxsdk.annotations.PolylineOptions; import com.mapbox.mapboxsdk.geometry.LatLng; -import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest; -import com.mapbox.mapboxsdk.testapp.activity.espresso.EspressoTestActivity; +import com.mapbox.mapboxsdk.testapp.activity.EspressoTest; import org.junit.Ignore; import org.junit.Test; @@ -14,12 +13,7 @@ import org.junit.Test; import static com.mapbox.mapboxsdk.testapp.action.MapboxMapAction.invoke; import static org.junit.Assert.assertEquals; -public class PolylineTest extends BaseActivityTest { - - @Override - protected Class getActivityClass() { - return EspressoTestActivity.class; - } +public class PolylineTest extends EspressoTest { @Test @Ignore 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 376e627b04..625e37798f 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 @@ -9,7 +9,7 @@ import com.mapbox.mapboxsdk.camera.CameraUpdateFactory; import com.mapbox.mapboxsdk.geometry.LatLng; import com.mapbox.mapboxsdk.geometry.LatLngBounds; import com.mapbox.mapboxsdk.maps.MapboxMap; -import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest; +import com.mapbox.mapboxsdk.testapp.activity.BaseTest; import com.mapbox.mapboxsdk.testapp.activity.espresso.DeviceIndependentTestActivity; import com.mapbox.mapboxsdk.testapp.utils.TestConstants; @@ -18,7 +18,7 @@ import org.junit.Test; import static com.mapbox.mapboxsdk.testapp.action.MapboxMapAction.invoke; import static org.junit.Assert.assertEquals; -public class CameraAnimateTest extends BaseActivityTest { +public class CameraAnimateTest extends BaseTest { private final CountingIdlingResource animationIdlingResource = new CountingIdlingResource("animation_idling_resource"); 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 fb0eb71ef3..ae81dc1302 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 @@ -9,7 +9,7 @@ import com.mapbox.mapboxsdk.camera.CameraUpdateFactory; import com.mapbox.mapboxsdk.geometry.LatLng; import com.mapbox.mapboxsdk.geometry.LatLngBounds; import com.mapbox.mapboxsdk.maps.MapboxMap; -import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest; +import com.mapbox.mapboxsdk.testapp.activity.BaseTest; import com.mapbox.mapboxsdk.testapp.activity.espresso.DeviceIndependentTestActivity; import com.mapbox.mapboxsdk.testapp.utils.TestConstants; @@ -18,7 +18,7 @@ import org.junit.Test; import static com.mapbox.mapboxsdk.testapp.action.MapboxMapAction.invoke; import static org.junit.Assert.assertEquals; -public class CameraEaseTest extends BaseActivityTest { +public class CameraEaseTest extends BaseTest { private final CountingIdlingResource animationIdlingResource = new CountingIdlingResource("animation_idling_resource"); diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/camera/CameraForTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/camera/CameraForTest.java index 752d02e319..eb38bddf84 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/camera/CameraForTest.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/camera/CameraForTest.java @@ -6,7 +6,7 @@ import com.mapbox.geojson.Polygon; import com.mapbox.mapboxsdk.camera.CameraPosition; import com.mapbox.mapboxsdk.geometry.LatLng; import com.mapbox.mapboxsdk.geometry.LatLngBounds; -import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest; +import com.mapbox.mapboxsdk.testapp.activity.BaseTest; import com.mapbox.mapboxsdk.testapp.activity.espresso.DeviceIndependentTestActivity; import org.junit.Test; @@ -15,7 +15,7 @@ import java.util.List; import static org.junit.Assert.assertEquals; -public class CameraForTest extends BaseActivityTest { +public class CameraForTest extends BaseTest { @Test public void testGetCameraForLatLngBounds() { 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 22c837a4a5..f8aa43d52d 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 @@ -10,7 +10,7 @@ import com.mapbox.mapboxsdk.camera.CameraUpdateFactory; import com.mapbox.mapboxsdk.geometry.LatLng; import com.mapbox.mapboxsdk.geometry.LatLngBounds; import com.mapbox.mapboxsdk.maps.MapboxMap; -import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest; +import com.mapbox.mapboxsdk.testapp.activity.BaseTest; import com.mapbox.mapboxsdk.testapp.activity.espresso.DeviceIndependentTestActivity; import com.mapbox.mapboxsdk.testapp.utils.TestConstants; @@ -19,7 +19,7 @@ import org.junit.Test; import static com.mapbox.mapboxsdk.testapp.action.MapboxMapAction.invoke; import static org.junit.Assert.assertEquals; -public class CameraMoveTest extends BaseActivityTest { +public class CameraMoveTest extends BaseTest { private final CountingIdlingResource animationIdlingResource = new CountingIdlingResource("animation_idling_resource"); 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 deleted file mode 100644 index 5ef93c72b3..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/feature/QueryRenderedFeaturesBoxCountTest.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.mapbox.mapboxsdk.testapp.feature; - -import com.mapbox.mapboxsdk.testapp.R; -import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest; -import com.mapbox.mapboxsdk.testapp.activity.feature.QueryRenderedFeaturesBoxCountActivity; - -import org.junit.Ignore; -import org.junit.Test; - -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; -import static android.support.test.espresso.matcher.RootMatchers.withDecorView; -import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed; -import static android.support.test.espresso.matcher.ViewMatchers.withId; -import static android.support.test.espresso.matcher.ViewMatchers.withText; -import static org.hamcrest.Matchers.is; -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 extends BaseActivityTest { - - @Override - protected Class getActivityClass() { - return QueryRenderedFeaturesBoxCountActivity.class; - } - - @Test - @Ignore - public void testCountFeatures() { - // click on box to query map - onView(withId(R.id.selection_box)).perform(click()); - - // validate if toast is shown - onView(withText("149 features in box")) - .inRoot(withDecorView(not(is(rule.getActivity().getWindow().getDecorView())))) - .check(matches(isDisplayed())); - } - -} 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 deleted file mode 100644 index 307700e847..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/feature/QueryRenderedFeaturesHighlightTest.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.mapbox.mapboxsdk.testapp.feature; - -import com.mapbox.mapboxsdk.testapp.R; -import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest; -import com.mapbox.mapboxsdk.testapp.activity.feature.QueryRenderedFeaturesBoxHighlightActivity; - -import org.junit.Ignore; -import org.junit.Test; - -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; -import static android.support.test.espresso.matcher.RootMatchers.withDecorView; -import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed; -import static android.support.test.espresso.matcher.ViewMatchers.withId; -import static android.support.test.espresso.matcher.ViewMatchers.withText; -import static org.hamcrest.Matchers.is; -import static org.hamcrest.Matchers.not; - -/** - * Instrumentation test to validate if clicking box on screen highlights features. - */ -public class QueryRenderedFeaturesHighlightTest extends BaseActivityTest { - - @Override - protected Class getActivityClass() { - return QueryRenderedFeaturesBoxHighlightActivity.class; - } - - @Test - @Ignore - public void testCountFeatures() { - // click on box to query map - onView(withId(R.id.selection_box)).perform(click()); - - // validate if toast is shown - onView(withText("50 features in box")) - .inRoot(withDecorView(not(is(rule.getActivity().getWindow().getDecorView())))) - .check(matches(isDisplayed())); - } - -} 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 deleted file mode 100644 index 6e446ceda9..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/feature/QueryRenderedFeaturesPropertiesTest.java +++ /dev/null @@ -1,54 +0,0 @@ -package com.mapbox.mapboxsdk.testapp.feature; - -import android.graphics.PointF; -import android.support.test.espresso.ViewAction; -import android.support.test.espresso.action.GeneralClickAction; -import android.support.test.espresso.action.Press; -import android.support.test.espresso.action.Tap; - -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.feature.QueryRenderedFeaturesPropertiesActivity; - -import org.junit.Ignore; -import org.junit.Test; - -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 static android.support.test.espresso.matcher.ViewMatchers.withText; - -/** - * Instrumentation test to validate if clicking center of screen returns the correct features. - */ -public class QueryRenderedFeaturesPropertiesTest extends BaseActivityTest { - - @Override - protected Class getActivityClass() { - return QueryRenderedFeaturesPropertiesActivity.class; - } - - @Test - @Ignore - public void testCountFeatures() { - 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())); - } - - private static ViewAction clickXY(final float x, final float y) { - return new GeneralClickAction( - Tap.SINGLE, - 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/QueryRenderedSymbolBoxCountTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/feature/QueryRenderedSymbolBoxCountTest.java deleted file mode 100644 index a31c3db89e..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/feature/QueryRenderedSymbolBoxCountTest.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.mapbox.mapboxsdk.testapp.feature; - -import com.mapbox.mapboxsdk.testapp.R; -import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest; -import com.mapbox.mapboxsdk.testapp.activity.feature.QueryRenderedFeaturesBoxSymbolCountActivity; - -import org.junit.Ignore; -import org.junit.Test; - -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; -import static android.support.test.espresso.matcher.RootMatchers.withDecorView; -import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed; -import static android.support.test.espresso.matcher.ViewMatchers.withId; -import static android.support.test.espresso.matcher.ViewMatchers.withText; -import static org.hamcrest.Matchers.is; -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 extends BaseActivityTest { - - @Override - protected Class getActivityClass() { - return QueryRenderedFeaturesBoxSymbolCountActivity.class; - } - - @Test - @Ignore - public void testCountSymbols() { - // click on box to query map - onView(withId(R.id.selection_box)).perform(click()); - - // validate if toast is shown - onView(withText("2 features in box")) - .inRoot(withDecorView(not(is(rule.getActivity().getWindow().getDecorView())))) - .check(matches(isDisplayed())); - } -} - diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/geometry/GeoJsonConversionTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/geometry/GeoJsonConversionTest.java index 5dc66ab77e..90b82d56f3 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/geometry/GeoJsonConversionTest.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/geometry/GeoJsonConversionTest.java @@ -7,8 +7,7 @@ import com.mapbox.mapboxsdk.geometry.LatLngBounds; import com.mapbox.mapboxsdk.style.layers.SymbolLayer; import com.mapbox.mapboxsdk.style.sources.CustomGeometrySource; import com.mapbox.mapboxsdk.style.sources.GeometryTileProvider; -import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest; -import com.mapbox.mapboxsdk.testapp.activity.espresso.EspressoTestActivity; +import com.mapbox.mapboxsdk.testapp.activity.EspressoTest; import org.junit.Test; import static com.mapbox.geojson.Feature.fromGeometry; @@ -23,7 +22,7 @@ import static java.util.Collections.singletonList; /** * Instrumentation test to validate java geojson conversion to c++ */ -public class GeoJsonConversionTest extends BaseActivityTest { +public class GeoJsonConversionTest extends EspressoTest { // Regression test for #12343 @Test @@ -118,11 +117,6 @@ public class GeoJsonConversionTest extends BaseActivityTest { })); } - @Override - protected Class getActivityClass() { - return EspressoTestActivity.class; - } - class CustomProvider implements GeometryTileProvider { private FeatureCollection featureCollection; diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/geometry/LatLngBoundsTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/geometry/LatLngBoundsTest.java index 0fdae6fcda..607d7cd635 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/geometry/LatLngBoundsTest.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/geometry/LatLngBoundsTest.java @@ -4,7 +4,7 @@ import com.mapbox.mapboxsdk.camera.CameraUpdateFactory; import com.mapbox.mapboxsdk.geometry.LatLng; import com.mapbox.mapboxsdk.geometry.LatLngBounds; import com.mapbox.mapboxsdk.testapp.action.MapboxMapAction; -import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest; +import com.mapbox.mapboxsdk.testapp.activity.BaseTest; import com.mapbox.mapboxsdk.testapp.activity.feature.QueryRenderedFeaturesBoxHighlightActivity; import com.mapbox.mapboxsdk.testapp.utils.TestConstants; import org.junit.Test; @@ -14,7 +14,7 @@ import static junit.framework.Assert.assertEquals; /** * Instrumentation test to validate integration of LatLngBounds */ -public class LatLngBoundsTest extends BaseActivityTest { +public class LatLngBoundsTest extends BaseTest { private static final double MAP_BEARING = 50; diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/StyleLoadTest.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/StyleLoadTest.kt index 1f9acbb291..1397ea95c7 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/StyleLoadTest.kt +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/StyleLoadTest.kt @@ -8,21 +8,17 @@ import com.mapbox.mapboxsdk.maps.Style import com.mapbox.mapboxsdk.style.layers.SymbolLayer import com.mapbox.mapboxsdk.style.sources.GeoJsonSource import com.mapbox.mapboxsdk.testapp.action.MapboxMapAction -import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest +import com.mapbox.mapboxsdk.testapp.activity.EspressoTest import com.mapbox.mapboxsdk.testapp.activity.espresso.EspressoTestActivity import org.junit.Before import org.junit.Test import org.junit.runner.RunWith @RunWith(AndroidJUnit4::class) -class StyleLoadTest : BaseActivityTest() { +class StyleLoadTest : EspressoTest() { private lateinit var mapView: MapView - override fun getActivityClass(): Class<*> { - return EspressoTestActivity::class.java - } - @Before override fun beforeTest() { super.beforeTest() 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 b70c3e89ad..0fadd33325 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 @@ -15,8 +15,7 @@ import android.view.View; import com.mapbox.mapboxsdk.maps.MapboxMap; import com.mapbox.mapboxsdk.style.sources.Source; 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.activity.EspressoTest; import org.hamcrest.Matcher; import org.junit.After; @@ -39,15 +38,10 @@ import static org.hamcrest.CoreMatchers.allOf; import static org.hamcrest.CoreMatchers.anything; import static org.hamcrest.core.IsNot.not; -public class AttributionTest extends BaseActivityTest { +public class AttributionTest extends EspressoTest { private URLSpan[] urlSpans; - @Override - protected Class getActivityClass() { - return EspressoTestActivity.class; - } - @Before public void beforeTest() { super.beforeTest(); 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 26aee2de98..1cdf1423a3 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 @@ -4,10 +4,8 @@ import com.mapbox.mapboxsdk.camera.CameraPosition; import com.mapbox.mapboxsdk.camera.CameraUpdateFactory; 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.activity.EspressoTest; import com.mapbox.mapboxsdk.testapp.utils.TestConstants; - import org.junit.Ignore; import org.junit.Test; @@ -20,12 +18,7 @@ import static com.mapbox.mapboxsdk.testapp.action.MapboxMapAction.invoke; import static org.hamcrest.Matchers.not; import static org.junit.Assert.assertEquals; -public class CompassViewTest extends BaseActivityTest { - - @Override - protected Class getActivityClass() { - return EspressoTestActivity.class; - } +public class CompassViewTest extends EspressoTest { @Test public void testDefault() { 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 0c189aa316..677ad6caa5 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 @@ -6,8 +6,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.activity.EspressoTest; import org.hamcrest.Matcher; import org.junit.Test; @@ -18,12 +17,7 @@ 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 extends BaseActivityTest { - - @Override - protected Class getActivityClass() { - return EspressoTestActivity.class; - } +public class LogoTest extends EspressoTest { @Test public void testDefault() { diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/offline/OfflineManagerTest.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/offline/OfflineManagerTest.kt index f702f8dafa..78be095005 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/offline/OfflineManagerTest.kt +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/offline/OfflineManagerTest.kt @@ -11,15 +11,14 @@ import com.mapbox.mapboxsdk.offline.OfflineManager import com.mapbox.mapboxsdk.offline.OfflineRegion import com.mapbox.mapboxsdk.storage.FileSource import com.mapbox.mapboxsdk.testapp.action.MapboxMapAction.invoke -import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest -import com.mapbox.mapboxsdk.testapp.activity.espresso.EspressoTestActivity +import com.mapbox.mapboxsdk.testapp.activity.EspressoTest import com.mapbox.mapboxsdk.testapp.utils.FileUtils import org.junit.Test import org.junit.runner.RunWith import java.io.IOException @RunWith(AndroidJUnit4::class) -class OfflineManagerTest : BaseActivityTest() { +class OfflineManagerTest : EspressoTest() { companion object { private const val TEST_DB_FILE_NAME = "offline.db" @@ -29,10 +28,6 @@ class OfflineManagerTest : BaseActivityTest() { private lateinit var offlineIdlingResource: CountingIdlingResource - override fun getActivityClass(): Class<*> { - return EspressoTestActivity::class.java - } - override fun beforeTest() { super.beforeTest() offlineIdlingResource = CountingIdlingResource("idling_resource") diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/offline/OfflineUtilsTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/offline/OfflineUtilsTest.java index 84f84fdb90..40fba08c25 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/offline/OfflineUtilsTest.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/offline/OfflineUtilsTest.java @@ -1,10 +1,9 @@ package com.mapbox.mapboxsdk.testapp.offline; -import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest; -import com.mapbox.mapboxsdk.testapp.activity.espresso.EspressoTestActivity; +import android.support.test.runner.AndroidJUnit4; import com.mapbox.mapboxsdk.testapp.utils.OfflineUtils; - import org.junit.Test; +import org.junit.runner.RunWith; import java.io.UnsupportedEncodingException; import java.util.Arrays; @@ -13,16 +12,12 @@ import static com.mapbox.mapboxsdk.testapp.activity.offline.OfflineActivity.JSON import static junit.framework.Assert.assertEquals; import static junit.framework.TestCase.assertTrue; -public class OfflineUtilsTest extends BaseActivityTest { +@RunWith(AndroidJUnit4.class) +public class OfflineUtilsTest { private static final String REGION_NAME = "hello world"; private static final String CONVERTED_REGION_NAME = "{\"FIELD_REGION_NAME\":\"hello world\"}"; - @Override - protected Class getActivityClass() { - return EspressoTestActivity.class; - } - @Test public void testOfflineUtilsConvertToBytes() throws UnsupportedEncodingException { byte[] expected = CONVERTED_REGION_NAME.getBytes(JSON_CHARSET); diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/storage/FileSourceTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/storage/FileSourceTest.java index 097c9b89ae..bf7d7491f3 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/storage/FileSourceTest.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/storage/FileSourceTest.java @@ -1,131 +1,40 @@ package com.mapbox.mapboxsdk.testapp.storage; -import android.os.Looper; -import android.support.test.espresso.UiController; -import android.support.test.espresso.ViewAction; -import android.support.test.rule.ActivityTestRule; +import android.support.test.InstrumentationRegistry; +import android.support.test.annotation.UiThreadTest; import android.support.test.runner.AndroidJUnit4; -import android.view.View; - import com.mapbox.mapboxsdk.storage.FileSource; -import com.mapbox.mapboxsdk.testapp.R; -import com.mapbox.mapboxsdk.testapp.action.WaitAction; -import com.mapbox.mapboxsdk.testapp.activity.FeatureOverviewActivity; - -import org.hamcrest.Matcher; 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.Espresso.pressBack; -import static android.support.test.espresso.action.ViewActions.click; -import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed; -import static android.support.test.espresso.matcher.ViewMatchers.isRoot; -import static android.support.test.espresso.matcher.ViewMatchers.withId; -import static android.support.test.espresso.matcher.ViewMatchers.withText; -import static com.mapbox.mapboxsdk.testapp.action.OrientationChangeAction.orientationLandscape; import static junit.framework.TestCase.assertFalse; import static junit.framework.TestCase.assertTrue; @RunWith(AndroidJUnit4.class) public class FileSourceTest { - @Rule - public ActivityTestRule<FeatureOverviewActivity> rule = new ActivityTestRule<>(FeatureOverviewActivity.class); - private FileSource fileSource; @Before - public void setUp() throws Exception { - onView(withId(R.id.recyclerView)).perform(new FileSourceCreator()); + @UiThreadTest + public void setUp() { + fileSource = FileSource.getInstance(InstrumentationRegistry.getContext()); } @Test - public void testDefault() throws Exception { + @UiThreadTest + public void testDefault() { assertFalse("FileSource should not be active", fileSource.isActivated()); } @Test - public void testActivateDeactivate() throws Exception { - assertFalse("1) FileSource should not be active", fileSource.isActivated()); - onView(withId(R.id.recyclerView)).perform(new FileSourceActivator(true)); - assertTrue("2) FileSource should be active", fileSource.isActivated()); - onView(withId(R.id.recyclerView)).perform(new FileSourceActivator(false)); - assertFalse("3) FileSource should not be active", fileSource.isActivated()); - } - - @Test - public void testOpenCloseMapView() throws Exception { - assertFalse("1) FileSource should not be active", fileSource.isActivated()); - onView(withText("Simple Map")).perform(click()); - onView(withId(R.id.mapView)).perform(new WaitAction()); - assertTrue("2) FileSource should be active", fileSource.isActivated()); - onView(withId(R.id.mapView)).perform(new WaitAction()); - pressBack(); - assertFalse("3) FileSource should not be active", fileSource.isActivated()); - } - - @Test - @Ignore - public void testRotateMapView() throws Exception { + @UiThreadTest + public void testActivateDeactivate() { assertFalse("1) FileSource should not be active", fileSource.isActivated()); - onView(withText("Simple Map")).perform(click()); - onView(withId(R.id.mapView)).perform(new WaitAction()); - onView(isRoot()).perform(orientationLandscape()); - onView(withId(R.id.mapView)).perform(new WaitAction()); + fileSource.activate(); assertTrue("2) FileSource should be active", fileSource.isActivated()); - onView(withId(R.id.mapView)).perform(new WaitAction()); - pressBack(); + fileSource.deactivate(); assertFalse("3) FileSource should not be active", fileSource.isActivated()); } - - private class FileSourceCreator implements ViewAction { - @Override - public Matcher<View> getConstraints() { - return isDisplayed(); - } - - @Override - public String getDescription() { - return "Creates the filesource instance on the UI thread"; - } - - @Override - public void perform(UiController uiController, View view) { - assertTrue(Looper.myLooper() == Looper.getMainLooper()); - fileSource = FileSource.getInstance(rule.getActivity()); - } - } - - private class FileSourceActivator implements ViewAction { - - private boolean activate; - - FileSourceActivator(boolean activate) { - this.activate = activate; - } - - @Override - public Matcher<View> getConstraints() { - return isDisplayed(); - } - - @Override - public String getDescription() { - return "Creates the filesource instance on the UI thread"; - } - - @Override - public void perform(UiController uiController, View view) { - assertTrue(Looper.myLooper() == Looper.getMainLooper()); - if (activate) { - fileSource.activate(); - } else { - fileSource.deactivate(); - } - } - } }
\ No newline at end of file diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/string/UppperLowerCaseTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/string/UppperLowerCaseTest.java index f5b4586a86..0ef8051a3f 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/string/UppperLowerCaseTest.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/string/UppperLowerCaseTest.java @@ -1,8 +1,9 @@ package com.mapbox.mapboxsdk.testapp.string; -import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest; -import com.mapbox.mapboxsdk.testapp.activity.espresso.EspressoTestActivity; +import android.support.test.runner.AndroidJUnit4; +import com.mapbox.mapboxsdk.testapp.activity.EspressoTest; import org.junit.Test; +import org.junit.runner.RunWith; import static junit.framework.Assert.assertEquals; @@ -12,12 +13,8 @@ import static junit.framework.Assert.assertEquals; * See core test in https://github.com/mapbox/mapbox-gl-native/blob/master/test/util/text_conversions.test.cpp * </p> */ -public class UppperLowerCaseTest extends BaseActivityTest { - - @Override - protected Class getActivityClass() { - return EspressoTestActivity.class; - } +@RunWith(AndroidJUnit4.class) +public class UppperLowerCaseTest extends EspressoTest { @Test public void testToUpperCase() { diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/CustomGeometrySourceTest.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/CustomGeometrySourceTest.kt index eeb30b97e6..f79d802e5e 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/CustomGeometrySourceTest.kt +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/CustomGeometrySourceTest.kt @@ -8,7 +8,7 @@ import com.mapbox.mapboxsdk.style.sources.CustomGeometrySource.THREAD_PREFIX import com.mapbox.mapboxsdk.testapp.action.MapboxMapAction.invoke import com.mapbox.mapboxsdk.testapp.action.OrientationChangeAction.orientationLandscape import com.mapbox.mapboxsdk.testapp.action.OrientationChangeAction.orientationPortrait -import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest +import com.mapbox.mapboxsdk.testapp.activity.BaseTest import com.mapbox.mapboxsdk.testapp.activity.style.GridSourceActivity import com.mapbox.mapboxsdk.testapp.activity.style.GridSourceActivity.ID_GRID_LAYER import com.mapbox.mapboxsdk.testapp.activity.style.GridSourceActivity.ID_GRID_SOURCE @@ -16,7 +16,7 @@ import org.junit.Assert import org.junit.Ignore import org.junit.Test -class CustomGeometrySourceTest : BaseActivityTest() { +class CustomGeometrySourceTest : BaseTest() { override fun getActivityClass(): Class<*> = GridSourceActivity::class.java diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/ExpressionTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/ExpressionTest.java index 2bfa844a9a..d8d9b354c7 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/ExpressionTest.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/ExpressionTest.java @@ -18,8 +18,7 @@ import com.mapbox.mapboxsdk.style.sources.Source; import com.mapbox.mapboxsdk.style.types.Formatted; import com.mapbox.mapboxsdk.style.types.FormattedSection; 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.activity.EspressoTest; import com.mapbox.mapboxsdk.testapp.utils.ResourceUtils; import com.mapbox.mapboxsdk.utils.ColorUtils; @@ -61,7 +60,7 @@ import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNull; @RunWith(AndroidJUnit4.class) -public class ExpressionTest extends BaseActivityTest { +public class ExpressionTest extends EspressoTest { private FillLayer layer; @@ -557,9 +556,4 @@ public class ExpressionTest extends BaseActivityTest { ); }); } - - @Override - protected Class getActivityClass() { - return EspressoTestActivity.class; - } } 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 e21cfd8296..51c85179b6 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,8 +14,7 @@ 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.action.MapboxMapAction; -import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest; -import com.mapbox.mapboxsdk.testapp.activity.style.RuntimeStyleTestActivity; +import com.mapbox.mapboxsdk.testapp.activity.EspressoTest; import com.mapbox.mapboxsdk.testapp.utils.ResourceUtils; import org.hamcrest.Matcher; @@ -33,12 +32,7 @@ import static org.junit.Assert.assertTrue; * Tests for {@link GeoJsonSource} */ @RunWith(AndroidJUnit4.class) -public class GeoJsonSourceTests extends BaseActivityTest { - - @Override - protected Class getActivityClass() { - return RuntimeStyleTestActivity.class; - } +public class GeoJsonSourceTests extends EspressoTest { @Test public void testFeatureCollection() { diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/ImageTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/ImageTest.java index dabf8d73f9..66bfcb257e 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/ImageTest.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/ImageTest.java @@ -7,9 +7,8 @@ import android.support.test.runner.AndroidJUnit4; import com.mapbox.mapboxsdk.testapp.R; import com.mapbox.mapboxsdk.testapp.action.MapboxMapAction; -import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest; -import com.mapbox.mapboxsdk.testapp.activity.style.RuntimeStyleTestActivity; +import com.mapbox.mapboxsdk.testapp.activity.EspressoTest; import org.junit.Test; import org.junit.runner.RunWith; @@ -20,15 +19,10 @@ import static org.junit.Assert.assertTrue; * CRUD tests around Image */ @RunWith(AndroidJUnit4.class) -public class ImageTest extends BaseActivityTest { +public class ImageTest extends EspressoTest { private static final String IMAGE_ID = "test.image"; - @Override - protected Class getActivityClass() { - return RuntimeStyleTestActivity.class; - } - @Test public void testAddGetImage() { validateTestSetup(); diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/LightTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/LightTest.java index bd0484b578..c5ad242b90 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/LightTest.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/LightTest.java @@ -12,7 +12,7 @@ import com.mapbox.mapboxsdk.style.layers.FillExtrusionLayer; import com.mapbox.mapboxsdk.style.layers.TransitionOptions; import com.mapbox.mapboxsdk.style.light.Position; import com.mapbox.mapboxsdk.testapp.R; -import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest; +import com.mapbox.mapboxsdk.testapp.activity.BaseTest; import com.mapbox.mapboxsdk.testapp.activity.style.FillExtrusionStyleTestActivity; import timber.log.Timber; @@ -36,7 +36,7 @@ import static junit.framework.Assert.assertEquals; import static junit.framework.Assert.assertNotNull; @RunWith(AndroidJUnit4.class) -public class LightTest extends BaseActivityTest { +public class LightTest extends BaseTest { private Light light; 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 e7e7c767a4..ed39f36e32 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 @@ -21,8 +21,7 @@ import com.mapbox.mapboxsdk.style.sources.RasterSource; 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.activity.EspressoTest; import junit.framework.Assert; @@ -52,12 +51,7 @@ import static org.junit.Assert.fail; * Basic smoke tests for Layer and Source */ @RunWith(AndroidJUnit4.class) -public class RuntimeStyleTests extends BaseActivityTest { - - @Override - protected Class getActivityClass() { - return RuntimeStyleTestActivity.class; - } +public class RuntimeStyleTests extends EspressoTest { @Test public void testListLayers() { diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/RuntimeStyleTimingTests.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/RuntimeStyleTimingTests.java index 75c8b57787..4dd01d06cb 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/RuntimeStyleTimingTests.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/RuntimeStyleTimingTests.java @@ -2,7 +2,7 @@ package com.mapbox.mapboxsdk.testapp.style; import android.support.test.runner.AndroidJUnit4; -import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest; +import com.mapbox.mapboxsdk.testapp.activity.BaseTest; import com.mapbox.mapboxsdk.testapp.activity.style.RuntimeStyleTimingTestActivity; import org.junit.Test; @@ -12,7 +12,7 @@ import org.junit.runner.RunWith; * Basic smoke tests for adding Layer and Source as early as possible (in onCreate) */ @RunWith(AndroidJUnit4.class) -public class RuntimeStyleTimingTests extends BaseActivityTest { +public class RuntimeStyleTimingTests extends BaseTest { @Override protected Class getActivityClass() { diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/StyleLoaderTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/StyleLoaderTest.java index 819282f7a8..fd666d9fd3 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/StyleLoaderTest.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/StyleLoaderTest.java @@ -1,17 +1,10 @@ package com.mapbox.mapboxsdk.testapp.style; - -import android.support.test.espresso.UiController; - import com.mapbox.mapboxsdk.maps.MapView; -import com.mapbox.mapboxsdk.maps.MapboxMap; import com.mapbox.mapboxsdk.maps.Style; import com.mapbox.mapboxsdk.testapp.R; -import com.mapbox.mapboxsdk.testapp.action.MapboxMapAction; -import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest; -import com.mapbox.mapboxsdk.testapp.activity.espresso.EspressoTestActivity; +import com.mapbox.mapboxsdk.testapp.activity.EspressoTest; import com.mapbox.mapboxsdk.testapp.utils.ResourceUtils; - import org.junit.Test; import java.io.IOException; @@ -22,56 +15,44 @@ import static org.junit.Assert.assertEquals; /** * Tests around style loading */ -public class StyleLoaderTest extends BaseActivityTest { - - - @Override - protected Class getActivityClass() { - return EspressoTestActivity.class; - } +public class StyleLoaderTest extends EspressoTest { @Test - public void testSetGetStyleJsonString() throws Exception { + public void testSetGetStyleJsonString() { validateTestSetup(); - invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { - @Override - public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { - try { - String expected = ResourceUtils.readRawResource(rule.getActivity(), R.raw.local_style); - mapboxMap.setStyle(new Style.Builder().fromJson(expected)); - String actual = mapboxMap.getStyle().getJson(); - assertEquals("Style json should match", expected, actual); - } catch (IOException exception) { - exception.printStackTrace(); - } + invoke(mapboxMap, (uiController, mapboxMap) -> { + try { + String expected = ResourceUtils.readRawResource(rule.getActivity(), R.raw.local_style); + mapboxMap.setStyle(new Style.Builder().fromJson(expected)); + String actual = mapboxMap.getStyle().getJson(); + assertEquals("Style json should match", expected, actual); + } catch (IOException exception) { + exception.printStackTrace(); } }); } @Test - public void testDefaultStyleLoadWithActivityLifecycleChange() throws Exception { + public void testDefaultStyleLoadWithActivityLifecycleChange() { validateTestSetup(); - invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { - @Override - public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { - try { - String expected = ResourceUtils.readRawResource(rule.getActivity(), R.raw.local_style); - mapboxMap.setStyle(new Style.Builder().fromJson(expected)); - - // fake activity stop/start - MapView mapView = (MapView) rule.getActivity().findViewById(R.id.mapView); - mapView.onPause(); - mapView.onStop(); - - mapView.onStart(); - mapView.onResume(); - - String actual = mapboxMap.getStyle().getJson(); - assertEquals("Style URL should be empty", "", mapboxMap.getStyle().getUrl()); - assertEquals("Style json should match", expected, actual); - } catch (IOException exception) { - exception.printStackTrace(); - } + invoke(mapboxMap, (uiController, mapboxMap) -> { + try { + String expected = ResourceUtils.readRawResource(rule.getActivity(), R.raw.local_style); + mapboxMap.setStyle(new Style.Builder().fromJson(expected)); + + // fake activity stop/start + MapView mapView = (MapView) rule.getActivity().findViewById(R.id.mapView); + mapView.onPause(); + mapView.onStop(); + + mapView.onStart(); + mapView.onResume(); + + String actual = mapboxMap.getStyle().getJson(); + assertEquals("Style URL should be empty", "", mapboxMap.getStyle().getUrl()); + assertEquals("Style json should match", expected, actual); + } catch (IOException exception) { + exception.printStackTrace(); } }); } diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/light.junit.ejs b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/light.junit.ejs index 287fe1ac56..18ae94cc3e 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/light.junit.ejs +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/light.junit.ejs @@ -15,7 +15,7 @@ import com.mapbox.mapboxsdk.style.layers.FillExtrusionLayer; import com.mapbox.mapboxsdk.style.layers.TransitionOptions; import com.mapbox.mapboxsdk.style.light.Position; import com.mapbox.mapboxsdk.testapp.R; -import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest; +import com.mapbox.mapboxsdk.testapp.activity.BaseTest; import com.mapbox.mapboxsdk.testapp.activity.style.FillExtrusionStyleTestActivity; import timber.log.Timber; @@ -39,7 +39,7 @@ import static junit.framework.Assert.assertEquals; import static junit.framework.Assert.assertNotNull; @RunWith(AndroidJUnit4.class) -public class LightTest extends BaseActivityTest { +public class LightTest extends BaseTest { private Light light; <% for (const property of properties) { -%> diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/utils/DrawerUtils.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/utils/DrawerUtils.java deleted file mode 100644 index d9ced47369..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/utils/DrawerUtils.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.mapbox.mapboxsdk.testapp.utils; - -import android.support.annotation.StringRes; -import android.support.test.espresso.Espresso; -import android.support.test.espresso.action.ViewActions; -import android.support.test.espresso.matcher.ViewMatchers; - -import com.mapbox.mapboxsdk.testapp.R; - -import org.hamcrest.Matchers; - -import static android.support.test.espresso.Espresso.onView; -import static android.support.test.espresso.action.ViewActions.click; -import static android.support.test.espresso.matcher.ViewMatchers.withContentDescription; - -public class DrawerUtils { - - private static final String HOME_BUTTON_STRING = "Navigate up"; - - public static void openDrawer() { - onView(withContentDescription(HOME_BUTTON_STRING)).perform(click()); - } - - public static void clickItem(@StringRes int txtId) { - Espresso.onView(Matchers.allOf(ViewMatchers.withId(R.id.design_menu_item_text), - ViewMatchers.hasSibling(ViewMatchers.withText(txtId)))).perform(ViewActions.click()); - } - -} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/utils/FinishLoadingStyleIdlingResource.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/utils/FinishLoadingStyleIdlingResource.java new file mode 100644 index 0000000000..323d2c0f15 --- /dev/null +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/utils/FinishLoadingStyleIdlingResource.java @@ -0,0 +1,35 @@ +package com.mapbox.mapboxsdk.testapp.utils; + +import android.app.Activity; +import android.os.Handler; +import android.os.Looper; +import android.support.annotation.WorkerThread; +import com.mapbox.mapboxsdk.maps.MapboxMap; + +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + +public class FinishLoadingStyleIdlingResource extends MapboxIdlingResource { + + @WorkerThread + public FinishLoadingStyleIdlingResource(final Activity activity) { + new Handler(Looper.getMainLooper()).post(() -> inflateMap(activity)); + } + + @Override + public void initMap(MapboxMap mapboxMap) { + super.initMap(mapboxMap); + mapboxMap.getStyle(style -> { + assertNotNull(style); + assertTrue(style.isFullyLoaded()); + if (resourceCallback != null) { + resourceCallback.onTransitionToIdle(); + } + }); + } + + @Override + public boolean isIdleNow() { + return getMapboxMap() != null && getMapboxMap().getStyle() != null; + } +}
\ No newline at end of file diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/utils/GestureUtils.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/utils/GestureUtils.java deleted file mode 100644 index 3376f5eda4..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/utils/GestureUtils.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.mapbox.mapboxsdk.testapp.utils; - -import android.support.annotation.IdRes; - -import static android.support.test.espresso.Espresso.onView; -import static android.support.test.espresso.action.ViewActions.doubleClick; -import static android.support.test.espresso.matcher.ViewMatchers.withId; - -public class GestureUtils { - - public static void doubleClickGesture(@IdRes int id) { - onView(withId(id)).perform(doubleClick()); - } - -} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/utils/LoadStyleIdlingResource.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/utils/LoadStyleIdlingResource.java new file mode 100644 index 0000000000..5dead21fbb --- /dev/null +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/utils/LoadStyleIdlingResource.java @@ -0,0 +1,40 @@ +package com.mapbox.mapboxsdk.testapp.utils; + +import android.app.Activity; +import android.os.Handler; +import android.os.Looper; +import android.support.annotation.UiThread; +import android.support.annotation.WorkerThread; +import com.mapbox.mapboxsdk.maps.MapboxMap; +import com.mapbox.mapboxsdk.maps.Style; + +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + +public class LoadStyleIdlingResource extends MapboxIdlingResource { + + private Style style; + + @WorkerThread + public LoadStyleIdlingResource(final Activity activity) { + new Handler(Looper.getMainLooper()).post(() -> inflateMap(activity)); + } + + @UiThread + public void initMap(MapboxMap mapboxMap) { + super.initMap(mapboxMap); + mapboxMap.setStyle("asset://streets.json", style -> { + assertNotNull(style); + assertTrue(style.isFullyLoaded()); + this.style = style; + if (resourceCallback != null) { + resourceCallback.onTransitionToIdle(); + } + }); + } + + @Override + public boolean isIdleNow() { + return style != null; + } +}
\ No newline at end of file diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/utils/MapboxIdlingResource.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/utils/MapboxIdlingResource.java new file mode 100644 index 0000000000..2a4cfee01a --- /dev/null +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/utils/MapboxIdlingResource.java @@ -0,0 +1,41 @@ +package com.mapbox.mapboxsdk.testapp.utils; + +import android.app.Activity; +import android.support.annotation.UiThread; +import android.support.test.espresso.IdlingResource; +import com.mapbox.mapboxsdk.maps.MapView; +import com.mapbox.mapboxsdk.maps.MapboxMap; +import com.mapbox.mapboxsdk.testapp.R; + +public abstract class MapboxIdlingResource implements IdlingResource { + + private MapboxMap mapboxMap; + IdlingResource.ResourceCallback resourceCallback; + + @UiThread + void inflateMap(Activity activity) { + MapView mapView = activity.findViewById(R.id.mapView); + if (mapView != null) { + mapView.getMapAsync(this::initMap); + } + } + + @UiThread + protected void initMap(MapboxMap mapboxMap) { + this.mapboxMap = mapboxMap; + } + + @Override + public String getName() { + return getClass().getSimpleName(); + } + + @Override + public void registerIdleTransitionCallback(ResourceCallback resourceCallback) { + this.resourceCallback = resourceCallback; + } + + public MapboxMap getMapboxMap() { + return mapboxMap; + } +}
\ No newline at end of file diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/utils/TestConstants.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/utils/TestConstants.java index d1412e7d2c..09e27d30f2 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/utils/TestConstants.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/utils/TestConstants.java @@ -6,7 +6,6 @@ public class TestConstants { public static final double TILT_DELTA = 0.3; public static final double ZOOM_DELTA = 0.3; - public static final String TEXT_MARKER_TEXT = "Text"; public static final String TEXT_MARKER_TITLE = "Marker"; public static final String TEXT_MARKER_SNIPPET = "Snippet"; } diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/utils/ViewUtils.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/utils/ViewUtils.java deleted file mode 100644 index 5c4d5a03c3..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/utils/ViewUtils.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.mapbox.mapboxsdk.testapp.utils; - -import android.support.annotation.IdRes; - -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; -import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed; -import static android.support.test.espresso.matcher.ViewMatchers.withId; - -public class ViewUtils { - - public static void clickView(@IdRes int viewRes) { - onView(withId(viewRes)) - .perform(click()); - } - - public static void checkViewIsDisplayed(int id) { - onView(withId(id)) - .check(matches(isDisplayed())); - } -} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/debug/AndroidManifest.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/debug/AndroidManifest.xml deleted file mode 100644 index 489ec3f407..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/debug/AndroidManifest.xml +++ /dev/null @@ -1,18 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<manifest xmlns:android="http://schemas.android.com/apk/res/android" - package="com.mapbox.mapboxsdk.testapp"> - - <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/> - <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> - <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/> - <uses-permission android:name="android.permission.CHANGE_WIFI_STATE"/> - <uses-permission android:name="android.permission.CHANGE_NETWORK_STATE"/> - <uses-permission android:name="android.permission.INTERNET" /> - <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> - - <application> - <activity android:name=".activity.SingleFragmentActivity"/> - <activity android:name=".activity.SingleActivity"/> - - </application> -</manifest>
\ No newline at end of file diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/debug/java/com/mapbox/mapboxsdk/testapp/activity/SingleActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/debug/java/com/mapbox/mapboxsdk/testapp/activity/SingleActivity.java deleted file mode 100644 index dbc1920d47..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/debug/java/com/mapbox/mapboxsdk/testapp/activity/SingleActivity.java +++ /dev/null @@ -1,68 +0,0 @@ -package com.mapbox.mapboxsdk.testapp.activity; - -import android.os.Bundle; -import android.support.v7.app.AppCompatActivity; - -import com.mapbox.mapboxsdk.maps.MapView; -import com.mapbox.mapboxsdk.maps.Style; -import com.mapbox.mapboxsdk.testapp.R; - -public class SingleActivity extends AppCompatActivity { - private MapView mapView; - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_single); - - mapView = findViewById(R.id.mapView); - mapView.onCreate(savedInstanceState); - mapView.getMapAsync(mapboxMap -> mapboxMap.setStyle(new Style.Builder().fromUrl(Style.MAPBOX_STREETS))); - } - - public MapView getMapView() { - return mapView; - } - - @Override - protected void onStart() { - super.onStart(); - mapView.onStart(); - } - - @Override - protected void onResume() { - super.onResume(); - mapView.onResume(); - } - - @Override - protected void onPause() { - super.onPause(); - mapView.onPause(); - } - - @Override - protected void onStop() { - super.onStop(); - mapView.onStop(); - } - - @Override - public void onLowMemory() { - super.onLowMemory(); - mapView.onLowMemory(); - } - - @Override - protected void onDestroy() { - super.onDestroy(); - mapView.onDestroy(); - } - - @Override - protected void onSaveInstanceState(Bundle outState) { - super.onSaveInstanceState(outState); - mapView.onSaveInstanceState(outState); - } -} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/debug/java/com/mapbox/mapboxsdk/testapp/activity/SingleFragmentActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/debug/java/com/mapbox/mapboxsdk/testapp/activity/SingleFragmentActivity.java deleted file mode 100644 index 823b80af10..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/debug/java/com/mapbox/mapboxsdk/testapp/activity/SingleFragmentActivity.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.mapbox.mapboxsdk.testapp.activity; - -import android.os.Bundle; -import android.support.annotation.Nullable; -import android.support.v4.app.Fragment; -import android.support.v7.app.AppCompatActivity; -import android.view.ViewGroup; -import android.widget.FrameLayout; - -import com.mapbox.mapboxsdk.testapp.R; - -/** - * Used for testing fragments inside a fake activity. - */ -public class SingleFragmentActivity extends AppCompatActivity { - @Override - protected void onCreate(@Nullable Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - FrameLayout content = new FrameLayout(this); - content.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, - ViewGroup.LayoutParams.MATCH_PARENT)); - content.setId(R.id.container); - setContentView(content); - } - - public void setFragment(Fragment fragment) { - getSupportFragmentManager().beginTransaction() - .add(R.id.container, fragment, "TEST") - .commit(); - } - - public void replaceFragment(Fragment fragment) { - getSupportFragmentManager().beginTransaction() - .replace(R.id.container, fragment).commit(); - } -}
\ No newline at end of file diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/debug/res/layout/activity_single.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/debug/res/layout/activity_single.xml deleted file mode 100644 index f7e3d1f8ec..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/debug/res/layout/activity_single.xml +++ /dev/null @@ -1,13 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:app="http://schemas.android.com/apk/res-auto" - android:layout_width="match_parent" - android:layout_height="match_parent"> - - <com.mapbox.mapboxsdk.maps.MapView - android:id="@+id/mapView" - android:layout_width="match_parent" - android:layout_height="match_parent" - app:mapbox_cameraZoomMin="2.0" /> - -</RelativeLayout>
\ No newline at end of file diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/debug/assets/heavy_style.json b/platform/android/MapboxGLAndroidSDKTestApp/src/main/assets/heavy_style.json index 238ed7d9f2..238ed7d9f2 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/debug/assets/heavy_style.json +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/assets/heavy_style.json diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/espresso/EspressoTestActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/espresso/EspressoTestActivity.java index 251913dcfb..51b504414d 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/espresso/EspressoTestActivity.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/espresso/EspressoTestActivity.java @@ -2,7 +2,6 @@ package com.mapbox.mapboxsdk.testapp.activity.espresso; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; - import com.mapbox.mapboxsdk.maps.MapView; import com.mapbox.mapboxsdk.maps.MapboxMap; import com.mapbox.mapboxsdk.testapp.R; @@ -19,8 +18,6 @@ public class EspressoTestActivity extends AppCompatActivity { protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_espresso_test); - - // Initialize map as normal mapView = findViewById(R.id.mapView); mapView.onCreate(savedInstanceState); } diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/infowindow/DynamicInfoWindowAdapterActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/infowindow/DynamicInfoWindowAdapterActivity.java index f6774696fb..c5743518b1 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/infowindow/DynamicInfoWindowAdapterActivity.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/infowindow/DynamicInfoWindowAdapterActivity.java @@ -15,6 +15,7 @@ import com.mapbox.mapboxsdk.geometry.LatLng; import com.mapbox.mapboxsdk.maps.MapView; import com.mapbox.mapboxsdk.maps.MapboxMap; import com.mapbox.mapboxsdk.maps.OnMapReadyCallback; +import com.mapbox.mapboxsdk.maps.Style; import com.mapbox.mapboxsdk.testapp.R; import com.mapbox.mapboxsdk.testapp.utils.IconUtils; @@ -70,6 +71,8 @@ public class DynamicInfoWindowAdapterActivity extends AppCompatActivity implemen public void onMapReady(@NonNull MapboxMap map) { mapboxMap = map; + map.setStyle(Style.MAPBOX_STREETS); + // Add info window adapter addCustomInfoWindowAdapter(mapboxMap); diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/RuntimeStyleTestActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/RuntimeStyleTestActivity.java deleted file mode 100644 index 53f0870d90..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/RuntimeStyleTestActivity.java +++ /dev/null @@ -1,74 +0,0 @@ -package com.mapbox.mapboxsdk.testapp.activity.style; - -import android.os.Bundle; -import android.support.v7.app.AppCompatActivity; - -import com.mapbox.mapboxsdk.maps.MapView; -import com.mapbox.mapboxsdk.maps.MapboxMap; -import com.mapbox.mapboxsdk.testapp.R; - -/** - * Test activity used for instrumentation test execution. - */ -public class RuntimeStyleTestActivity extends AppCompatActivity { - - public MapView mapView; - private MapboxMap mapboxMap; - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_runtime_style); - - // Initialize map as normal - mapView = (MapView) findViewById(R.id.mapView); - mapView.onCreate(savedInstanceState); - mapView.getMapAsync(mapboxMap -> RuntimeStyleTestActivity.this.mapboxMap = mapboxMap); - } - - public MapboxMap getMapboxMap() { - return mapboxMap; - } - - @Override - protected void onStart() { - super.onStart(); - mapView.onStart(); - } - - @Override - protected void onResume() { - super.onResume(); - mapView.onResume(); - } - - @Override - protected void onPause() { - super.onPause(); - mapView.onPause(); - } - - @Override - protected void onStop() { - super.onStop(); - mapView.onStop(); - } - - @Override - protected void onSaveInstanceState(Bundle outState) { - super.onSaveInstanceState(outState); - mapView.onSaveInstanceState(outState); - } - - @Override - protected void onDestroy() { - super.onDestroy(); - mapView.onDestroy(); - } - - @Override - public void onLowMemory() { - super.onLowMemory(); - mapView.onLowMemory(); - } -} diff --git a/platform/android/scripts/exclude-activity-gen.json b/platform/android/scripts/exclude-activity-gen.json index 7dfe68d965..2a70b47c65 100644 --- a/platform/android/scripts/exclude-activity-gen.json +++ b/platform/android/scripts/exclude-activity-gen.json @@ -44,5 +44,6 @@ "TextureViewDebugModeActivity", "RuntimeStyleActivity", "GridSourceActivity", - "AnimatedImageSourceActivity" + "AnimatedImageSourceActivity", + "EspressoTestActivity" ] |