diff options
author | Tobrun <tobrun.van.nuland@gmail.com> | 2016-10-20 10:20:56 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-10-20 10:20:56 +0200 |
commit | 9a7139b65ccc7d75c256cb04c4ec1e6bd4e327b6 (patch) | |
tree | b33621c0939b228867c962e2c60d14b3513ddfb3 /platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/camera | |
parent | 76f91cc88d5e2c19bcac3e1421bd13b510e21979 (diff) | |
download | qtlocation-mapboxgl-9a7139b65ccc7d75c256cb04c4ec1e6bd4e327b6.tar.gz |
[android] - move instrumentation test code to correct package for Android Studio run configurations integration. (#6748)
Diffstat (limited to 'platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/camera')
3 files changed, 195 insertions, 0 deletions
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/camera/RotateActivityTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/camera/RotateActivityTest.java new file mode 100644 index 0000000000..edef97027e --- /dev/null +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/camera/RotateActivityTest.java @@ -0,0 +1,62 @@ +package com.mapbox.mapboxsdk.testapp.camera; + +import android.support.test.espresso.UiController; +import android.support.test.espresso.ViewAction; +import android.view.View; + +import com.mapbox.mapboxsdk.maps.MapView; +import com.mapbox.mapboxsdk.maps.MapboxMapUtils; +import com.mapbox.mapboxsdk.testapp.R; +import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest; +import com.mapbox.mapboxsdk.testapp.activity.infowindow.InfoWindowActivity; + +import org.hamcrest.Matcher; +import org.junit.Test; + +import static android.support.test.espresso.Espresso.onView; +import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed; +import static android.support.test.espresso.matcher.ViewMatchers.withId; + +public class RotateActivityTest extends BaseActivityTest { + + @Test + // longer testing change second param + public void testRotate() { + onView(withId(R.id.mapView)).perform(new RotateAction(0, 1)); + } + + @Override + public Class getActivityClass() { + return InfoWindowActivity.class; + } + + private class RotateAction implements ViewAction { + + private float startDegree; + private float endDegree; + + public RotateAction(float startDegree, float endDegree) { + this.startDegree = startDegree; + this.endDegree = endDegree; + } + + @Override + public Matcher<View> getConstraints() { + return isDisplayed(); + } + + @Override + public String getDescription() { + return "rotateAction"; + } + + @Override + public void perform(UiController uiController, View view) { + uiController.loopMainThreadForAtLeast(500); + for (float i = startDegree; i < endDegree; i++) { + MapboxMapUtils.setDirection((MapView) view, i); + uiController.loopMainThreadForAtLeast(1); + } + } + } +} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/camera/TiltActivityTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/camera/TiltActivityTest.java new file mode 100644 index 0000000000..8f21f60fb0 --- /dev/null +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/camera/TiltActivityTest.java @@ -0,0 +1,62 @@ +package com.mapbox.mapboxsdk.testapp.camera; + +import android.support.test.espresso.UiController; +import android.support.test.espresso.ViewAction; +import android.view.View; + +import com.mapbox.mapboxsdk.maps.MapView; +import com.mapbox.mapboxsdk.maps.MapboxMapUtils; +import com.mapbox.mapboxsdk.testapp.R; +import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest; +import com.mapbox.mapboxsdk.testapp.activity.annotation.DynamicMarkerChangeActivity; + +import org.hamcrest.Matcher; +import org.junit.Test; + +import static android.support.test.espresso.Espresso.onView; +import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed; +import static android.support.test.espresso.matcher.ViewMatchers.withId; + +public class TiltActivityTest extends BaseActivityTest { + + @Test + // longer testing change param + public void testTilt() { + onView(withId(R.id.mapView)).perform(new TiltAction(0, 1)); + } + + @Override + public Class getActivityClass() { + return DynamicMarkerChangeActivity.class; + } + + private class TiltAction implements ViewAction { + + private float startDegree; + private float endDegree; + + public TiltAction(float startDegree, float endDegree) { + this.startDegree = startDegree; + this.endDegree = endDegree; + } + + @Override + public Matcher<View> getConstraints() { + return isDisplayed(); + } + + @Override + public String getDescription() { + return "tiltAction"; + } + + @Override + public void perform(UiController uiController, View view) { + uiController.loopMainThreadForAtLeast(500); + for (float i = startDegree; i < endDegree; i++) { + MapboxMapUtils.setTilt((MapView) view, i); + uiController.loopMainThreadForAtLeast(1); + } + } + } +} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/camera/ZoomActivityTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/camera/ZoomActivityTest.java new file mode 100644 index 0000000000..700e8f6c5c --- /dev/null +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/camera/ZoomActivityTest.java @@ -0,0 +1,71 @@ +package com.mapbox.mapboxsdk.testapp.camera; + +import android.support.test.espresso.UiController; +import android.support.test.espresso.ViewAction; +import android.view.View; + +import com.mapbox.mapboxsdk.camera.CameraPosition; +import com.mapbox.mapboxsdk.camera.CameraUpdateFactory; +import com.mapbox.mapboxsdk.constants.MapboxConstants; +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.maplayout.DebugModeActivity; + +import org.hamcrest.Matcher; +import org.junit.Test; + +import static android.support.test.espresso.Espresso.onView; +import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed; +import static android.support.test.espresso.matcher.ViewMatchers.withId; + +public class ZoomActivityTest extends BaseActivityTest { + + @Test + // longer testing increase second param + public void testZoom() throws Exception { + onView(withId(R.id.mapView)).perform(new ZoomAction(MapboxConstants.MINIMUM_ZOOM, MapboxConstants.MINIMUM_ZOOM - 1)); + } + + @Override + public Class getActivityClass() { + return DebugModeActivity.class; + } + + private class ZoomAction implements ViewAction { + + private float fromZoom; + private float toZoom; + + public ZoomAction(float fromZoom, float toZoom) { + this.fromZoom = fromZoom; + this.toZoom = toZoom; + } + + @Override + public Matcher<View> getConstraints() { + return isDisplayed(); + } + + @Override + public String getDescription() { + return "zoomAction"; + } + + @Override + public void perform(UiController uiController, View view) { + // move camera above denver + mapboxMap.moveCamera(CameraUpdateFactory.newCameraPosition( + new CameraPosition.Builder() + .target(new LatLng(39.749750, -104.949559)) + .build())); + + uiController.loopMainThreadForAtLeast(500); + + for (float i = fromZoom; i < toZoom; i++) { + mapboxMap.animateCamera(CameraUpdateFactory.zoomTo(i)); + uiController.loopMainThreadForAtLeast(200); + } + } + } +} |