diff options
Diffstat (limited to 'platform/android/MapboxGLAndroidSDKTestApp/src')
58 files changed, 2227 insertions, 1340 deletions
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/MapViewUtils.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/MapViewUtils.java new file mode 100644 index 0000000000..da9c3f9c8f --- /dev/null +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/MapViewUtils.java @@ -0,0 +1,37 @@ +package com.mapbox.mapboxsdk.maps; + +import com.mapbox.mapboxsdk.geometry.LatLng; + +/** + * Utility class to bypass package visibility + */ +public class MapViewUtils { + + public static void setDirection(MapView mapView, float direction) { + mapView.setBearing(direction); + } + + public static float getDirection(MapView mapView) { + return (float) mapView.getDirection(); + } + + public static void setTilt(MapView mapView, float tilt) { + mapView.setTilt((double) tilt); + } + + public static float getTilt(MapView mapView) { + return (float) mapView.getTilt(); + } + + public static void setLatLng(MapView mapView, LatLng latLng) { + mapView.setCenterCoordinate(latLng); + } + + public static LatLng getLatLng(MapView mapView) { + return mapView.getCenterCoordinate(); + } + + public static int[] getContentPadding(MapView mapView) { + return new int[]{mapView.getContentPaddingLeft(), mapView.getContentPaddingTop(), mapView.getContentPaddingRight(), mapView.getContentPaddingBottom()}; + } +} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/MapboxMapUtils.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/MapboxMapUtils.java deleted file mode 100644 index a88e5aeda5..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/MapboxMapUtils.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.mapbox.mapboxsdk.maps; - -/** - * Utility class to bypass package visibility - */ -public class MapboxMapUtils { - - public static void setDirection(MapView mapView, float direction) { - mapView.setBearing(direction); - } - - public static void setTilt(MapView mapView, float tilt) { - mapView.setTilt((double) tilt); - } -} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/annotation/AddRemoveMarkerActivityTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/annotation/AddRemoveMarkerActivityTest.java deleted file mode 100644 index 76ee101904..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/annotation/AddRemoveMarkerActivityTest.java +++ /dev/null @@ -1,33 +0,0 @@ -// This file is generated. Edit android/platform/scripts/generate-test-code.js, then run `make generate-test-android`. -package com.mapbox.mapboxsdk.testapp.activity.gen.annotation; - -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.annotation.AddRemoveMarkerActivity; - -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 AddRemoveMarkerActivity - */ -@RunWith(AndroidJUnit4.class) -public class AddRemoveMarkerActivityTest extends BaseActivityTest { - - @Test - public void testSanity() { - onView(withId(R.id.mapView)).check(matches(isDisplayed())); - } - - @Override - protected Class getActivityClass() { - return AddRemoveMarkerActivity.class; - } -} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/annotation/BulkMarkerActivityTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/annotation/BulkMarkerActivityTest.java deleted file mode 100644 index 33bfb23b25..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/annotation/BulkMarkerActivityTest.java +++ /dev/null @@ -1,33 +0,0 @@ -// This file is generated. Edit android/platform/scripts/generate-test-code.js, then run `make generate-test-android`. -package com.mapbox.mapboxsdk.testapp.activity.gen.annotation; - -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.annotation.BulkMarkerActivity; - -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 BulkMarkerActivity - */ -@RunWith(AndroidJUnit4.class) -public class BulkMarkerActivityTest extends BaseActivityTest { - - @Test - public void testSanity() { - onView(withId(R.id.mapView)).check(matches(isDisplayed())); - } - - @Override - protected Class getActivityClass() { - return BulkMarkerActivity.class; - } -} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/annotation/DynamicMarkerChangeActivityTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/annotation/DynamicMarkerChangeActivityTest.java deleted file mode 100644 index 040affafda..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/annotation/DynamicMarkerChangeActivityTest.java +++ /dev/null @@ -1,33 +0,0 @@ -// This file is generated. Edit android/platform/scripts/generate-test-code.js, then run `make generate-test-android`. -package com.mapbox.mapboxsdk.testapp.activity.gen.annotation; - -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.annotation.DynamicMarkerChangeActivity; - -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 DynamicMarkerChangeActivity - */ -@RunWith(AndroidJUnit4.class) -public class DynamicMarkerChangeActivityTest extends BaseActivityTest { - - @Test - public void testSanity() { - onView(withId(R.id.mapView)).check(matches(isDisplayed())); - } - - @Override - protected Class getActivityClass() { - return DynamicMarkerChangeActivity.class; - } -} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/annotation/MarkerViewActivityTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/annotation/MarkerViewActivityTest.java deleted file mode 100644 index 9a0b66d8bc..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/annotation/MarkerViewActivityTest.java +++ /dev/null @@ -1,33 +0,0 @@ -// This file is generated. Edit android/platform/scripts/generate-test-code.js, then run `make generate-test-android`. -package com.mapbox.mapboxsdk.testapp.activity.gen.annotation; - -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.annotation.MarkerViewActivity; - -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 MarkerViewActivity - */ -@RunWith(AndroidJUnit4.class) -public class MarkerViewActivityTest extends BaseActivityTest { - - @Test - public void testSanity() { - onView(withId(R.id.mapView)).check(matches(isDisplayed())); - } - - @Override - protected Class getActivityClass() { - return MarkerViewActivity.class; - } -} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/annotation/MarkerViewScaleActivityTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/annotation/MarkerViewScaleActivityTest.java deleted file mode 100644 index 373b2d3d10..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/annotation/MarkerViewScaleActivityTest.java +++ /dev/null @@ -1,33 +0,0 @@ -// This file is generated. Edit android/platform/scripts/generate-test-code.js, then run `make generate-test-android`. -package com.mapbox.mapboxsdk.testapp.activity.gen.annotation; - -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.annotation.MarkerViewScaleActivity; - -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 MarkerViewScaleActivity - */ -@RunWith(AndroidJUnit4.class) -public class MarkerViewScaleActivityTest extends BaseActivityTest { - - @Test - public void testSanity() { - onView(withId(R.id.mapView)).check(matches(isDisplayed())); - } - - @Override - protected Class getActivityClass() { - return MarkerViewScaleActivity.class; - } -} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/annotation/PolygonActivityTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/annotation/PolygonActivityTest.java deleted file mode 100644 index 9569b7880b..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/annotation/PolygonActivityTest.java +++ /dev/null @@ -1,33 +0,0 @@ -// This file is generated. Edit android/platform/scripts/generate-test-code.js, then run `make generate-test-android`. -package com.mapbox.mapboxsdk.testapp.activity.gen.annotation; - -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.annotation.PolygonActivity; - -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 PolygonActivity - */ -@RunWith(AndroidJUnit4.class) -public class PolygonActivityTest extends BaseActivityTest { - - @Test - public void testSanity() { - onView(withId(R.id.mapView)).check(matches(isDisplayed())); - } - - @Override - protected Class getActivityClass() { - return PolygonActivity.class; - } -} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/annotation/PolylineActivityTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/annotation/PolylineActivityTest.java deleted file mode 100644 index 32f099cbc8..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/annotation/PolylineActivityTest.java +++ /dev/null @@ -1,33 +0,0 @@ -// This file is generated. Edit android/platform/scripts/generate-test-code.js, then run `make generate-test-android`. -package com.mapbox.mapboxsdk.testapp.activity.gen.annotation; - -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.annotation.PolylineActivity; - -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 PolylineActivity - */ -@RunWith(AndroidJUnit4.class) -public class PolylineActivityTest extends BaseActivityTest { - - @Test - public void testSanity() { - onView(withId(R.id.mapView)).check(matches(isDisplayed())); - } - - @Override - protected Class getActivityClass() { - return PolylineActivity.class; - } -} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/annotation/PressForMarkerActivityTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/annotation/PressForMarkerActivityTest.java deleted file mode 100644 index 3475a47263..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/annotation/PressForMarkerActivityTest.java +++ /dev/null @@ -1,33 +0,0 @@ -// This file is generated. Edit android/platform/scripts/generate-test-code.js, then run `make generate-test-android`. -package com.mapbox.mapboxsdk.testapp.activity.gen.annotation; - -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.annotation.PressForMarkerActivity; - -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 PressForMarkerActivity - */ -@RunWith(AndroidJUnit4.class) -public class PressForMarkerActivityTest extends BaseActivityTest { - - @Test - public void testSanity() { - onView(withId(R.id.mapView)).check(matches(isDisplayed())); - } - - @Override - protected Class getActivityClass() { - return PressForMarkerActivity.class; - } -} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/camera/CameraAnimationTypeActivityTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/camera/CameraAnimationTypeActivityTest.java deleted file mode 100644 index a4ee61de4d..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/camera/CameraAnimationTypeActivityTest.java +++ /dev/null @@ -1,33 +0,0 @@ -// This file is generated. Edit android/platform/scripts/generate-test-code.js, then run `make generate-test-android`. -package com.mapbox.mapboxsdk.testapp.activity.gen.camera; - -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.camera.CameraAnimationTypeActivity; - -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 CameraAnimationTypeActivity - */ -@RunWith(AndroidJUnit4.class) -public class CameraAnimationTypeActivityTest extends BaseActivityTest { - - @Test - public void testSanity() { - onView(withId(R.id.mapView)).check(matches(isDisplayed())); - } - - @Override - protected Class getActivityClass() { - return CameraAnimationTypeActivity.class; - } -} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/camera/CameraPositionActivityTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/camera/CameraPositionActivityTest.java deleted file mode 100644 index 784488668c..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/camera/CameraPositionActivityTest.java +++ /dev/null @@ -1,33 +0,0 @@ -// This file is generated. Edit android/platform/scripts/generate-test-code.js, then run `make generate-test-android`. -package com.mapbox.mapboxsdk.testapp.activity.gen.camera; - -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.camera.CameraPositionActivity; - -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 CameraPositionActivity - */ -@RunWith(AndroidJUnit4.class) -public class CameraPositionActivityTest extends BaseActivityTest { - - @Test - public void testSanity() { - onView(withId(R.id.mapView)).check(matches(isDisplayed())); - } - - @Override - protected Class getActivityClass() { - return CameraPositionActivity.class; - } -} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/camera/LatLngBoundsActivityTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/camera/LatLngBoundsActivityTest.java deleted file mode 100644 index f0b061a1c5..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/camera/LatLngBoundsActivityTest.java +++ /dev/null @@ -1,33 +0,0 @@ -// This file is generated. Edit android/platform/scripts/generate-test-code.js, then run `make generate-test-android`. -package com.mapbox.mapboxsdk.testapp.activity.gen.camera; - -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.camera.LatLngBoundsActivity; - -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 LatLngBoundsActivity - */ -@RunWith(AndroidJUnit4.class) -public class LatLngBoundsActivityTest extends BaseActivityTest { - - @Test - public void testSanity() { - onView(withId(R.id.mapView)).check(matches(isDisplayed())); - } - - @Override - protected Class getActivityClass() { - return LatLngBoundsActivity.class; - } -} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/camera/ManualZoomActivityTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/camera/ManualZoomActivityTest.java deleted file mode 100644 index 2a50f5f820..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/camera/ManualZoomActivityTest.java +++ /dev/null @@ -1,33 +0,0 @@ -// This file is generated. Edit android/platform/scripts/generate-test-code.js, then run `make generate-test-android`. -package com.mapbox.mapboxsdk.testapp.activity.gen.camera; - -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.camera.ManualZoomActivity; - -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 ManualZoomActivity - */ -@RunWith(AndroidJUnit4.class) -public class ManualZoomActivityTest extends BaseActivityTest { - - @Test - public void testSanity() { - onView(withId(R.id.mapView)).check(matches(isDisplayed())); - } - - @Override - protected Class getActivityClass() { - return ManualZoomActivity.class; - } -} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/camera/MaxMinZoomActivityTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/camera/MaxMinZoomActivityTest.java deleted file mode 100644 index cb63bb8838..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/camera/MaxMinZoomActivityTest.java +++ /dev/null @@ -1,33 +0,0 @@ -// This file is generated. Edit android/platform/scripts/generate-test-code.js, then run `make generate-test-android`. -package com.mapbox.mapboxsdk.testapp.activity.gen.camera; - -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.camera.MaxMinZoomActivity; - -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 MaxMinZoomActivity - */ -@RunWith(AndroidJUnit4.class) -public class MaxMinZoomActivityTest extends BaseActivityTest { - - @Test - public void testSanity() { - onView(withId(R.id.mapView)).check(matches(isDisplayed())); - } - - @Override - protected Class getActivityClass() { - return MaxMinZoomActivity.class; - } -} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/camera/ScrollByActivityTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/camera/ScrollByActivityTest.java deleted file mode 100644 index ce594efd1f..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/camera/ScrollByActivityTest.java +++ /dev/null @@ -1,33 +0,0 @@ -// This file is generated. Edit android/platform/scripts/generate-test-code.js, then run `make generate-test-android`. -package com.mapbox.mapboxsdk.testapp.activity.gen.camera; - -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.camera.ScrollByActivity; - -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 ScrollByActivity - */ -@RunWith(AndroidJUnit4.class) -public class ScrollByActivityTest extends BaseActivityTest { - - @Test - public void testSanity() { - onView(withId(R.id.mapView)).check(matches(isDisplayed())); - } - - @Override - protected Class getActivityClass() { - return ScrollByActivity.class; - } -} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/customlayer/CustomLayerActivityTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/customlayer/CustomLayerActivityTest.java deleted file mode 100644 index 56c2eae817..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/customlayer/CustomLayerActivityTest.java +++ /dev/null @@ -1,33 +0,0 @@ -// This file is generated. Edit android/platform/scripts/generate-test-code.js, then run `make generate-test-android`. -package com.mapbox.mapboxsdk.testapp.activity.gen.customlayer; - -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.customlayer.CustomLayerActivity; - -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 CustomLayerActivity - */ -@RunWith(AndroidJUnit4.class) -public class CustomLayerActivityTest extends BaseActivityTest { - - @Test - public void testSanity() { - onView(withId(R.id.mapView)).check(matches(isDisplayed())); - } - - @Override - protected Class getActivityClass() { - return CustomLayerActivity.class; - } -} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/directions/DirectionsActivityTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/directions/DirectionsActivityTest.java deleted file mode 100644 index 379c57e55a..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/directions/DirectionsActivityTest.java +++ /dev/null @@ -1,33 +0,0 @@ -// This file is generated. Edit android/platform/scripts/generate-test-code.js, then run `make generate-test-android`. -package com.mapbox.mapboxsdk.testapp.activity.gen.directions; - -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.directions.DirectionsActivity; - -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 DirectionsActivity - */ -@RunWith(AndroidJUnit4.class) -public class DirectionsActivityTest extends BaseActivityTest { - - @Test - public void testSanity() { - onView(withId(R.id.mapView)).check(matches(isDisplayed())); - } - - @Override - protected Class getActivityClass() { - return DirectionsActivity.class; - } -} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/feature/QueryRenderedFeaturesBoxCountActivityTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/feature/QueryRenderedFeaturesBoxCountActivityTest.java deleted file mode 100644 index c4a71d8279..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/feature/QueryRenderedFeaturesBoxCountActivityTest.java +++ /dev/null @@ -1,33 +0,0 @@ -// This file is generated. Edit android/platform/scripts/generate-test-code.js, then run `make generate-test-android`. -package com.mapbox.mapboxsdk.testapp.activity.gen.feature; - -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.feature.QueryRenderedFeaturesBoxCountActivity; - -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 QueryRenderedFeaturesBoxCountActivity - */ -@RunWith(AndroidJUnit4.class) -public class QueryRenderedFeaturesBoxCountActivityTest extends BaseActivityTest { - - @Test - public void testSanity() { - onView(withId(R.id.mapView)).check(matches(isDisplayed())); - } - - @Override - protected Class getActivityClass() { - return QueryRenderedFeaturesBoxCountActivity.class; - } -} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/feature/QueryRenderedFeaturesPropertiesActivityTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/feature/QueryRenderedFeaturesPropertiesActivityTest.java deleted file mode 100644 index 8a474fb9bf..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/feature/QueryRenderedFeaturesPropertiesActivityTest.java +++ /dev/null @@ -1,33 +0,0 @@ -// This file is generated. Edit android/platform/scripts/generate-test-code.js, then run `make generate-test-android`. -package com.mapbox.mapboxsdk.testapp.activity.gen.feature; - -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.feature.QueryRenderedFeaturesPropertiesActivity; - -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 QueryRenderedFeaturesPropertiesActivity - */ -@RunWith(AndroidJUnit4.class) -public class QueryRenderedFeaturesPropertiesActivityTest extends BaseActivityTest { - - @Test - public void testSanity() { - onView(withId(R.id.mapView)).check(matches(isDisplayed())); - } - - @Override - protected Class getActivityClass() { - return QueryRenderedFeaturesPropertiesActivity.class; - } -} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/geocoding/GeocoderActivityTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/geocoding/GeocoderActivityTest.java deleted file mode 100644 index 05d1f29547..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/geocoding/GeocoderActivityTest.java +++ /dev/null @@ -1,33 +0,0 @@ -// This file is generated. Edit android/platform/scripts/generate-test-code.js, then run `make generate-test-android`. -package com.mapbox.mapboxsdk.testapp.activity.gen.geocoding; - -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.geocoding.GeocoderActivity; - -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 GeocoderActivity - */ -@RunWith(AndroidJUnit4.class) -public class GeocoderActivityTest extends BaseActivityTest { - - @Test - public void testSanity() { - onView(withId(R.id.mapView)).check(matches(isDisplayed())); - } - - @Override - protected Class getActivityClass() { - return GeocoderActivity.class; - } -} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/imagegenerator/PrintActivityTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/imagegenerator/PrintActivityTest.java deleted file mode 100644 index c14cc413cf..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/imagegenerator/PrintActivityTest.java +++ /dev/null @@ -1,33 +0,0 @@ -// This file is generated. Edit android/platform/scripts/generate-test-code.js, then run `make generate-test-android`. -package com.mapbox.mapboxsdk.testapp.activity.gen.imagegenerator; - -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.imagegenerator.PrintActivity; - -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 PrintActivity - */ -@RunWith(AndroidJUnit4.class) -public class PrintActivityTest extends BaseActivityTest { - - @Test - public void testSanity() { - onView(withId(R.id.mapView)).check(matches(isDisplayed())); - } - - @Override - protected Class getActivityClass() { - return PrintActivity.class; - } -} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/infowindow/DynamicInfoWindowAdapterActivityTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/infowindow/DynamicInfoWindowAdapterActivityTest.java deleted file mode 100644 index b7a8245795..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/infowindow/DynamicInfoWindowAdapterActivityTest.java +++ /dev/null @@ -1,33 +0,0 @@ -// This file is generated. Edit android/platform/scripts/generate-test-code.js, then run `make generate-test-android`. -package com.mapbox.mapboxsdk.testapp.activity.gen.infowindow; - -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.infowindow.DynamicInfoWindowAdapterActivity; - -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 DynamicInfoWindowAdapterActivity - */ -@RunWith(AndroidJUnit4.class) -public class DynamicInfoWindowAdapterActivityTest extends BaseActivityTest { - - @Test - public void testSanity() { - onView(withId(R.id.mapView)).check(matches(isDisplayed())); - } - - @Override - protected Class getActivityClass() { - return DynamicInfoWindowAdapterActivity.class; - } -} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/infowindow/InfoWindowActivityTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/infowindow/InfoWindowActivityTest.java deleted file mode 100644 index 5ba4d56a03..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/infowindow/InfoWindowActivityTest.java +++ /dev/null @@ -1,33 +0,0 @@ -// This file is generated. Edit android/platform/scripts/generate-test-code.js, then run `make generate-test-android`. -package com.mapbox.mapboxsdk.testapp.activity.gen.infowindow; - -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.infowindow.InfoWindowActivity; - -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 InfoWindowActivity - */ -@RunWith(AndroidJUnit4.class) -public class InfoWindowActivityTest extends BaseActivityTest { - - @Test - public void testSanity() { - onView(withId(R.id.mapView)).check(matches(isDisplayed())); - } - - @Override - protected Class getActivityClass() { - return InfoWindowActivity.class; - } -} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/infowindow/InfoWindowAdapterActivityTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/infowindow/InfoWindowAdapterActivityTest.java deleted file mode 100644 index 7071874435..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/infowindow/InfoWindowAdapterActivityTest.java +++ /dev/null @@ -1,33 +0,0 @@ -// This file is generated. Edit android/platform/scripts/generate-test-code.js, then run `make generate-test-android`. -package com.mapbox.mapboxsdk.testapp.activity.gen.infowindow; - -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.infowindow.InfoWindowAdapterActivity; - -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 InfoWindowAdapterActivity - */ -@RunWith(AndroidJUnit4.class) -public class InfoWindowAdapterActivityTest extends BaseActivityTest { - - @Test - public void testSanity() { - onView(withId(R.id.mapView)).check(matches(isDisplayed())); - } - - @Override - protected Class getActivityClass() { - return InfoWindowAdapterActivity.class; - } -} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/maplayout/DebugModeActivityTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/maplayout/DebugModeActivityTest.java deleted file mode 100644 index 5764d364e0..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/maplayout/DebugModeActivityTest.java +++ /dev/null @@ -1,33 +0,0 @@ -// This file is generated. Edit android/platform/scripts/generate-test-code.js, then run `make generate-test-android`. -package com.mapbox.mapboxsdk.testapp.activity.gen.maplayout; - -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.maplayout.DebugModeActivity; - -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 DebugModeActivity - */ -@RunWith(AndroidJUnit4.class) -public class DebugModeActivityTest extends BaseActivityTest { - - @Test - public void testSanity() { - onView(withId(R.id.mapView)).check(matches(isDisplayed())); - } - - @Override - protected Class getActivityClass() { - return DebugModeActivity.class; - } -} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/maplayout/MapPaddingActivityTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/maplayout/MapPaddingActivityTest.java deleted file mode 100644 index 3f94b11246..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/maplayout/MapPaddingActivityTest.java +++ /dev/null @@ -1,33 +0,0 @@ -// This file is generated. Edit android/platform/scripts/generate-test-code.js, then run `make generate-test-android`. -package com.mapbox.mapboxsdk.testapp.activity.gen.maplayout; - -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.maplayout.MapPaddingActivity; - -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 MapPaddingActivity - */ -@RunWith(AndroidJUnit4.class) -public class MapPaddingActivityTest extends BaseActivityTest { - - @Test - public void testSanity() { - onView(withId(R.id.mapView)).check(matches(isDisplayed())); - } - - @Override - protected Class getActivityClass() { - return MapPaddingActivity.class; - } -} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/maplayout/SurfaceViewMediaControlActivityTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/maplayout/SurfaceViewMediaControlActivityTest.java deleted file mode 100644 index a52a4b0edb..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/maplayout/SurfaceViewMediaControlActivityTest.java +++ /dev/null @@ -1,33 +0,0 @@ -// This file is generated. Edit android/platform/scripts/generate-test-code.js, then run `make generate-test-android`. -package com.mapbox.mapboxsdk.testapp.activity.gen.maplayout; - -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.maplayout.SurfaceViewMediaControlActivity; - -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 SurfaceViewMediaControlActivity - */ -@RunWith(AndroidJUnit4.class) -public class SurfaceViewMediaControlActivityTest extends BaseActivityTest { - - @Test - public void testSanity() { - onView(withId(R.id.mapView)).check(matches(isDisplayed())); - } - - @Override - protected Class getActivityClass() { - return SurfaceViewMediaControlActivity.class; - } -} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/maplayout/VideoViewActivityTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/maplayout/VideoViewActivityTest.java deleted file mode 100644 index fb9330f0f4..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/maplayout/VideoViewActivityTest.java +++ /dev/null @@ -1,33 +0,0 @@ -// This file is generated. Edit android/platform/scripts/generate-test-code.js, then run `make generate-test-android`. -package com.mapbox.mapboxsdk.testapp.activity.gen.maplayout; - -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.maplayout.VideoViewActivity; - -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 VideoViewActivity - */ -@RunWith(AndroidJUnit4.class) -public class VideoViewActivityTest extends BaseActivityTest { - - @Test - public void testSanity() { - onView(withId(R.id.mapView)).check(matches(isDisplayed())); - } - - @Override - protected Class getActivityClass() { - return VideoViewActivity.class; - } -} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/offline/OfflineActivityTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/offline/OfflineActivityTest.java deleted file mode 100644 index 00a953f37e..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/offline/OfflineActivityTest.java +++ /dev/null @@ -1,33 +0,0 @@ -// This file is generated. Edit android/platform/scripts/generate-test-code.js, then run `make generate-test-android`. -package com.mapbox.mapboxsdk.testapp.activity.gen.offline; - -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.offline.OfflineActivity; - -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 OfflineActivity - */ -@RunWith(AndroidJUnit4.class) -public class OfflineActivityTest extends BaseActivityTest { - - @Test - public void testSanity() { - onView(withId(R.id.mapView)).check(matches(isDisplayed())); - } - - @Override - protected Class getActivityClass() { - return OfflineActivity.class; - } -} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/style/CircleLayerActivityTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/style/CircleLayerActivityTest.java deleted file mode 100644 index 5299f2e716..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/style/CircleLayerActivityTest.java +++ /dev/null @@ -1,33 +0,0 @@ -// This file is generated. Edit android/platform/scripts/generate-test-code.js, then run `make generate-test-android`. -package com.mapbox.mapboxsdk.testapp.activity.gen.style; - -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.style.CircleLayerActivity; - -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 CircleLayerActivity - */ -@RunWith(AndroidJUnit4.class) -public class CircleLayerActivityTest extends BaseActivityTest { - - @Test - public void testSanity() { - onView(withId(R.id.mapView)).check(matches(isDisplayed())); - } - - @Override - protected Class getActivityClass() { - return CircleLayerActivity.class; - } -} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/style/CustomSpriteActivityTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/style/CustomSpriteActivityTest.java deleted file mode 100644 index 5e482b2b38..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/style/CustomSpriteActivityTest.java +++ /dev/null @@ -1,33 +0,0 @@ -// This file is generated. Edit android/platform/scripts/generate-test-code.js, then run `make generate-test-android`. -package com.mapbox.mapboxsdk.testapp.activity.gen.style; - -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.style.CustomSpriteActivity; - -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 CustomSpriteActivity - */ -@RunWith(AndroidJUnit4.class) -public class CustomSpriteActivityTest extends BaseActivityTest { - - @Test - public void testSanity() { - onView(withId(R.id.mapView)).check(matches(isDisplayed())); - } - - @Override - protected Class getActivityClass() { - return CustomSpriteActivity.class; - } -} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/style/RuntimeStyleActivityTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/style/RuntimeStyleActivityTest.java deleted file mode 100644 index 37d5f64e8c..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/style/RuntimeStyleActivityTest.java +++ /dev/null @@ -1,33 +0,0 @@ -// This file is generated. Edit android/platform/scripts/generate-test-code.js, then run `make generate-test-android`. -package com.mapbox.mapboxsdk.testapp.activity.gen.style; - -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.style.RuntimeStyleActivity; - -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 RuntimeStyleActivity - */ -@RunWith(AndroidJUnit4.class) -public class RuntimeStyleActivityTest extends BaseActivityTest { - - @Test - public void testSanity() { - onView(withId(R.id.mapView)).check(matches(isDisplayed())); - } - - @Override - protected Class getActivityClass() { - return RuntimeStyleActivity.class; - } -} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/style/RuntimeStyleTimingTestActivityTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/style/RuntimeStyleTimingTestActivityTest.java deleted file mode 100644 index 7320b8527c..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/style/RuntimeStyleTimingTestActivityTest.java +++ /dev/null @@ -1,33 +0,0 @@ -// This file is generated. Edit android/platform/scripts/generate-test-code.js, then run `make generate-test-android`. -package com.mapbox.mapboxsdk.testapp.activity.gen.style; - -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.style.RuntimeStyleTimingTestActivity; - -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 RuntimeStyleTimingTestActivity - */ -@RunWith(AndroidJUnit4.class) -public class RuntimeStyleTimingTestActivityTest extends BaseActivityTest { - - @Test - public void testSanity() { - onView(withId(R.id.mapView)).check(matches(isDisplayed())); - } - - @Override - protected Class getActivityClass() { - return RuntimeStyleTimingTestActivity.class; - } -} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/style/StyleFileActivityTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/style/StyleFileActivityTest.java deleted file mode 100644 index 29116b85cb..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/style/StyleFileActivityTest.java +++ /dev/null @@ -1,33 +0,0 @@ -// This file is generated. Edit android/platform/scripts/generate-test-code.js, then run `make generate-test-android`. -package com.mapbox.mapboxsdk.testapp.activity.gen.style; - -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.style.StyleFileActivity; - -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 StyleFileActivity - */ -@RunWith(AndroidJUnit4.class) -public class StyleFileActivityTest extends BaseActivityTest { - - @Test - public void testSanity() { - onView(withId(R.id.mapView)).check(matches(isDisplayed())); - } - - @Override - protected Class getActivityClass() { - return StyleFileActivity.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 new file mode 100644 index 0000000000..650c9dc834 --- /dev/null +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/annotations/MarkerTest.java @@ -0,0 +1,139 @@ +package com.mapbox.mapboxsdk.testapp.annotations; + +import android.support.test.espresso.Espresso; +import android.support.test.espresso.UiController; +import android.support.test.espresso.ViewAction; +import android.support.test.rule.ActivityTestRule; +import android.view.View; + +import com.mapbox.mapboxsdk.annotations.Marker; +import com.mapbox.mapboxsdk.annotations.MarkerOptions; +import com.mapbox.mapboxsdk.geometry.LatLng; +import com.mapbox.mapboxsdk.maps.MapboxMap; +import com.mapbox.mapboxsdk.testapp.R; +import com.mapbox.mapboxsdk.testapp.activity.espresso.EspressoTestActivity; +import com.mapbox.mapboxsdk.testapp.utils.OnMapReadyIdlingResource; +import com.mapbox.mapboxsdk.testapp.utils.TestConstants; +import com.mapbox.mapboxsdk.testapp.utils.ViewUtils; + +import org.hamcrest.Matcher; +import org.junit.After; +import org.junit.Before; +import org.junit.Rule; +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; +import static org.junit.Assert.assertEquals; + +public class MarkerTest { + + @Rule + public final ActivityTestRule<EspressoTestActivity> rule = new ActivityTestRule<>(EspressoTestActivity.class); + + private OnMapReadyIdlingResource idlingResource; + private Marker marker; + + @Before + public void registerIdlingResource() { + idlingResource = new OnMapReadyIdlingResource(rule.getActivity()); + Espresso.registerIdlingResources(idlingResource); + } + + @Test + public void addMarkerTest() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); + assertEquals("Markers should be empty", 0, mapboxMap.getMarkers().size()); + + MarkerOptions options = new MarkerOptions(); + options.setPosition(new LatLng()); + options.setSnippet(TestConstants.TEXT_MARKER_SNIPPET); + options.setTitle(TestConstants.TEXT_MARKER_TITLE); + + onView(withId(R.id.mapView)).perform(new AddMarkerAction(mapboxMap, options)); + assertEquals("Markers sze should be 1, ", 1, mapboxMap.getMarkers().size()); + assertEquals("Marker id should be 0", 0, marker.getId()); + assertEquals("Marker target should match", new LatLng(), marker.getPosition()); + assertEquals("Marker snippet should match", TestConstants.TEXT_MARKER_SNIPPET, marker.getSnippet()); + assertEquals("Marker target should match", TestConstants.TEXT_MARKER_TITLE, marker.getTitle()); + mapboxMap.clear(); + assertEquals("Markers should be empty", 0, mapboxMap.getMarkers().size()); + } + + @Test + public void showInfoWindowTest(){ + ViewUtils.checkViewIsDisplayed(R.id.mapView); + MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); + + final MarkerOptions options = new MarkerOptions(); + options.setPosition(new LatLng()); + options.setSnippet(TestConstants.TEXT_MARKER_SNIPPET); + options.setTitle(TestConstants.TEXT_MARKER_TITLE); + + onView(withId(R.id.mapView)).perform(new AddMarkerAction(mapboxMap, options)); + onView(withId(R.id.mapView)).perform(new ShowInfoWindowAction(mapboxMap)); + onView(withText(TestConstants.TEXT_MARKER_TITLE)).check(matches(isDisplayed())); + onView(withText(TestConstants.TEXT_MARKER_SNIPPET)).check(matches(isDisplayed())); + } + + private class AddMarkerAction implements ViewAction { + + private MapboxMap mapboxMap; + private MarkerOptions options; + + AddMarkerAction(MapboxMap map, MarkerOptions markerOptions) { + mapboxMap = map; + options = markerOptions; + } + + @Override + public Matcher<View> getConstraints() { + return isDisplayed(); + } + + @Override + public String getDescription() { + return getClass().getSimpleName(); + } + + @Override + public void perform(UiController uiController, View view) { + marker = mapboxMap.addMarker(options); + } + } + + private class ShowInfoWindowAction implements ViewAction { + + private MapboxMap mapboxMap; + + ShowInfoWindowAction(MapboxMap map) { + mapboxMap = map; + } + + @Override + public Matcher<View> getConstraints() { + return isDisplayed(); + } + + @Override + public String getDescription() { + return getClass().getSimpleName(); + } + + @Override + public void perform(UiController uiController, View view) { + mapboxMap.selectMarker(marker); + + } + } + + + @After + public void unregisterIdlingResource() { + Espresso.unregisterIdlingResources(idlingResource); + } +} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/annotations/MarkerViewTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/annotations/MarkerViewTest.java new file mode 100644 index 0000000000..776406d555 --- /dev/null +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/annotations/MarkerViewTest.java @@ -0,0 +1,143 @@ +package com.mapbox.mapboxsdk.testapp.annotations; + +import android.support.test.espresso.Espresso; +import android.support.test.espresso.UiController; +import android.support.test.espresso.ViewAction; +import android.support.test.rule.ActivityTestRule; +import android.view.View; + +import com.mapbox.mapboxsdk.annotations.Marker; +import com.mapbox.mapboxsdk.geometry.LatLng; +import com.mapbox.mapboxsdk.maps.MapboxMap; +import com.mapbox.mapboxsdk.testapp.R; +import com.mapbox.mapboxsdk.testapp.activity.annotation.MarkerViewActivity; +import com.mapbox.mapboxsdk.testapp.activity.espresso.EspressoTestActivity; +import com.mapbox.mapboxsdk.testapp.model.annotations.TextMarkerViewOptions; +import com.mapbox.mapboxsdk.testapp.utils.OnMapReadyIdlingResource; +import com.mapbox.mapboxsdk.testapp.utils.TestConstants; +import com.mapbox.mapboxsdk.testapp.utils.ViewUtils; + +import org.hamcrest.Matcher; +import org.junit.After; +import org.junit.Before; +import org.junit.Rule; +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; +import static org.junit.Assert.assertEquals; + +public class MarkerViewTest { + + @Rule + public final ActivityTestRule<EspressoTestActivity> rule = new ActivityTestRule<>(EspressoTestActivity.class); + + private OnMapReadyIdlingResource idlingResource; + private Marker marker; + + @Before + public void registerIdlingResource() { + idlingResource = new OnMapReadyIdlingResource(rule.getActivity()); + Espresso.registerIdlingResources(idlingResource); + } + + @Test + public void addMarkerTest() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); + assertEquals("Markers should be empty", 0, mapboxMap.getMarkers().size()); + + TextMarkerViewOptions options = new TextMarkerViewOptions(); + options.text(TestConstants.TEXT_MARKER_TEXT); + options.position(new LatLng()); + options.snippet(TestConstants.TEXT_MARKER_SNIPPET); + options.title(TestConstants.TEXT_MARKER_TITLE); + + onView(withId(R.id.mapView)).perform(new AddTextMarkerViewAction(mapboxMap, options)); + assertEquals("Markers sze should be 1, ", 1, mapboxMap.getMarkers().size()); + assertEquals("Marker id should be 0", 0, marker.getId()); + assertEquals("Marker target should match", new LatLng(), marker.getPosition()); + assertEquals("Marker snippet should match", TestConstants.TEXT_MARKER_SNIPPET, marker.getSnippet()); + assertEquals("Marker target should match", TestConstants.TEXT_MARKER_TITLE, marker.getTitle()); + onView(withText(TestConstants.TEXT_MARKER_TEXT)).check(matches(isDisplayed())); + } + + @Test + public void showInfoWindowTest() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); + + final TextMarkerViewOptions options = new TextMarkerViewOptions(); + options.position(new LatLng()); + options.text(TestConstants.TEXT_MARKER_TEXT); + options.snippet(TestConstants.TEXT_MARKER_SNIPPET); + options.title(TestConstants.TEXT_MARKER_TITLE); + + onView(withId(R.id.mapView)).perform(new AddTextMarkerViewAction(mapboxMap, options)); + onView(withText(TestConstants.TEXT_MARKER_TEXT)).check(matches(isDisplayed())); + onView(withId(R.id.mapView)).perform(new ShowInfoWindowAction(mapboxMap)); + onView(withText(TestConstants.TEXT_MARKER_TITLE)).check(matches(isDisplayed())); + onView(withText(TestConstants.TEXT_MARKER_SNIPPET)).check(matches(isDisplayed())); + } + + private class AddTextMarkerViewAction implements ViewAction { + + private MapboxMap mapboxMap; + private TextMarkerViewOptions options; + + AddTextMarkerViewAction(MapboxMap map, TextMarkerViewOptions markerOptions) { + mapboxMap = map; + options = markerOptions; + } + + @Override + public Matcher<View> getConstraints() { + return isDisplayed(); + } + + @Override + public String getDescription() { + return getClass().getSimpleName(); + } + + @Override + public void perform(UiController uiController, View view) { + mapboxMap.getMarkerViewManager().addMarkerViewAdapter(new MarkerViewActivity.TextAdapter(view.getContext(), mapboxMap)); + marker = mapboxMap.addMarker(options); + } + } + + private class ShowInfoWindowAction implements ViewAction { + + private MapboxMap mapboxMap; + + ShowInfoWindowAction(MapboxMap map) { + mapboxMap = map; + } + + @Override + public Matcher<View> getConstraints() { + return isDisplayed(); + } + + @Override + public String getDescription() { + return getClass().getSimpleName(); + } + + @Override + public void perform(UiController uiController, View view) { + mapboxMap.selectMarker(marker); + + } + } + + + @After + public void unregisterIdlingResource() { + Espresso.unregisterIdlingResources(idlingResource); + } +} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/annotations/PolygonTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/annotations/PolygonTest.java new file mode 100644 index 0000000000..366e1851b8 --- /dev/null +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/annotations/PolygonTest.java @@ -0,0 +1,104 @@ +package com.mapbox.mapboxsdk.testapp.annotations; + +import android.graphics.Color; +import android.support.test.espresso.Espresso; +import android.support.test.espresso.UiController; +import android.support.test.espresso.ViewAction; +import android.support.test.rule.ActivityTestRule; +import android.view.View; + +import com.mapbox.mapboxsdk.annotations.Polygon; +import com.mapbox.mapboxsdk.annotations.PolygonOptions; +import com.mapbox.mapboxsdk.geometry.LatLng; +import com.mapbox.mapboxsdk.maps.MapboxMap; +import com.mapbox.mapboxsdk.testapp.R; +import com.mapbox.mapboxsdk.testapp.activity.espresso.EspressoTestActivity; +import com.mapbox.mapboxsdk.testapp.utils.OnMapReadyIdlingResource; +import com.mapbox.mapboxsdk.testapp.utils.ViewUtils; + +import org.hamcrest.Matcher; +import org.junit.After; +import org.junit.Before; +import org.junit.Ignore; +import org.junit.Rule; +import org.junit.Test; + +import static android.support.test.espresso.Espresso.onView; +import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed; +import static android.support.test.espresso.matcher.ViewMatchers.withId; +import static org.junit.Assert.assertEquals; + +public class PolygonTest { + + @Rule + public final ActivityTestRule<EspressoTestActivity> rule = new ActivityTestRule<>(EspressoTestActivity.class); + + private OnMapReadyIdlingResource idlingResource; + private Polygon polygon; + + @Before + public void registerIdlingResource() { + idlingResource = new OnMapReadyIdlingResource(rule.getActivity()); + Espresso.registerIdlingResources(idlingResource); + } + + @Test + @Ignore /** native crash **/ + public void addPolygonTest() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + final MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); + LatLng latLngOne = new LatLng(); + LatLng latLngTwo = new LatLng(1, 0); + LatLng latLngThree = new LatLng(1, 1); + + assertEquals("Polygons should be empty", 0, mapboxMap.getPolygons().size()); + + final PolygonOptions options = new PolygonOptions(); + options.strokeColor(Color.BLUE); + options.fillColor(Color.RED); + options.add(latLngOne); + options.add(latLngTwo); + options.add(latLngThree); + + onView(withId(R.id.mapView)).perform(new AddPolygonAction(mapboxMap, options)); + + assertEquals("Polygons should be 1", 1, mapboxMap.getPolygons().size()); + assertEquals("Polygon id should be 0", 0, polygon.getId()); + assertEquals("Polygon points size should match", 3, polygon.getPoints().size()); + assertEquals("Polygon stroke color should match", Color.BLUE, polygon.getStrokeColor()); + assertEquals("Polygon target should match", Color.RED, polygon.getFillColor()); + mapboxMap.clear(); + assertEquals("Polygons should be empty", 0, mapboxMap.getPolygons().size()); + } + + private class AddPolygonAction implements ViewAction { + + private MapboxMap mapboxMap; + private PolygonOptions options; + + AddPolygonAction(MapboxMap map, PolygonOptions polygonOptions) { + mapboxMap = map; + options = polygonOptions; + } + + @Override + public Matcher<View> getConstraints() { + return isDisplayed(); + } + + @Override + public String getDescription() { + return getClass().getSimpleName(); + } + + @Override + public void perform(UiController uiController, View view) { + polygon = mapboxMap.addPolygon(options); + } + } + + @After + public void unregisterIdlingResource() { + Espresso.unregisterIdlingResources(idlingResource); + } +} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/annotations/PolylineTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/annotations/PolylineTest.java new file mode 100644 index 0000000000..eb273b8cf9 --- /dev/null +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/annotations/PolylineTest.java @@ -0,0 +1,100 @@ +package com.mapbox.mapboxsdk.testapp.annotations; + +import android.graphics.Color; +import android.support.test.espresso.Espresso; +import android.support.test.espresso.UiController; +import android.support.test.espresso.ViewAction; +import android.support.test.rule.ActivityTestRule; +import android.view.View; + +import com.mapbox.mapboxsdk.annotations.Polyline; +import com.mapbox.mapboxsdk.annotations.PolylineOptions; +import com.mapbox.mapboxsdk.geometry.LatLng; +import com.mapbox.mapboxsdk.maps.MapboxMap; +import com.mapbox.mapboxsdk.testapp.R; +import com.mapbox.mapboxsdk.testapp.activity.espresso.EspressoTestActivity; +import com.mapbox.mapboxsdk.testapp.utils.OnMapReadyIdlingResource; +import com.mapbox.mapboxsdk.testapp.utils.ViewUtils; + +import org.hamcrest.Matcher; +import org.junit.After; +import org.junit.Before; +import org.junit.Ignore; +import org.junit.Rule; +import org.junit.Test; + +import static android.support.test.espresso.Espresso.onView; +import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed; +import static android.support.test.espresso.matcher.ViewMatchers.withId; +import static org.junit.Assert.assertEquals; + +public class PolylineTest { + + @Rule + public final ActivityTestRule<EspressoTestActivity> rule = new ActivityTestRule<>(EspressoTestActivity.class); + + private OnMapReadyIdlingResource idlingResource; + private Polyline polyline; + + @Before + public void registerIdlingResource() { + idlingResource = new OnMapReadyIdlingResource(rule.getActivity()); + Espresso.registerIdlingResources(idlingResource); + } + + @Ignore + @Test + public void addPolylineTest() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + final MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); + LatLng latLngOne = new LatLng(); + LatLng latLngTwo = new LatLng(1, 0); + + assertEquals("Polygons should be empty", 0, mapboxMap.getPolygons().size()); + + final PolylineOptions options = new PolylineOptions(); + options.color(Color.BLUE); + options.add(latLngOne); + options.add(latLngTwo); + + onView(withId(R.id.mapView)).perform(new AddPolyLineAction(mapboxMap, options)); + + assertEquals("Polylines should be 1", 1, mapboxMap.getPolylines().size()); + assertEquals("Polyline id should be 0", 0, polyline.getId()); + assertEquals("Polyline points size should match", 2, polyline.getPoints().size()); + assertEquals("Polyline stroke color should match", Color.BLUE, polyline.getColor()); + mapboxMap.clear(); + assertEquals("Polyline should be empty", 0, mapboxMap.getPolylines().size()); + } + + private class AddPolyLineAction implements ViewAction { + + private MapboxMap mapboxMap; + private PolylineOptions options; + + AddPolyLineAction(MapboxMap map, PolylineOptions polylineOptions) { + mapboxMap = map; + options = polylineOptions; + } + + @Override + public Matcher<View> getConstraints() { + return isDisplayed(); + } + + @Override + public String getDescription() { + return getClass().getSimpleName(); + } + + @Override + public void perform(UiController uiController, View view) { + polyline = mapboxMap.addPolyline(options); + } + } + + @After + public void unregisterIdlingResource() { + Espresso.unregisterIdlingResources(idlingResource); + } +} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/camera/CameraAnimateTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/camera/CameraAnimateTest.java new file mode 100644 index 0000000000..5e99cff936 --- /dev/null +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/camera/CameraAnimateTest.java @@ -0,0 +1,238 @@ +package com.mapbox.mapboxsdk.testapp.camera; + +import android.graphics.PointF; +import android.support.test.espresso.Espresso; +import android.support.test.espresso.UiController; +import android.support.test.espresso.ViewAction; +import android.support.test.rule.ActivityTestRule; +import android.view.View; + +import com.mapbox.mapboxsdk.camera.CameraPosition; +import com.mapbox.mapboxsdk.camera.CameraUpdate; +import com.mapbox.mapboxsdk.camera.CameraUpdateFactory; +import com.mapbox.mapboxsdk.constants.MapboxConstants; +import com.mapbox.mapboxsdk.geometry.LatLng; +import com.mapbox.mapboxsdk.geometry.LatLngBounds; +import com.mapbox.mapboxsdk.maps.MapboxMap; +import com.mapbox.mapboxsdk.testapp.R; +import com.mapbox.mapboxsdk.testapp.activity.espresso.EspressoTestActivity; +import com.mapbox.mapboxsdk.testapp.utils.OnMapReadyIdlingResource; +import com.mapbox.mapboxsdk.testapp.utils.TestConstants; +import com.mapbox.mapboxsdk.testapp.utils.ViewUtils; + +import org.hamcrest.Matcher; +import org.junit.After; +import org.junit.Before; +import org.junit.Rule; +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; +import static org.junit.Assert.assertEquals; + +public class CameraAnimateTest { + + @Rule + public final ActivityTestRule<EspressoTestActivity> rule = new ActivityTestRule<>(EspressoTestActivity.class); + + private OnMapReadyIdlingResource idlingResource; + + @Before + public void registerIdlingResource() { + idlingResource = new OnMapReadyIdlingResource(rule.getActivity()); + Espresso.registerIdlingResources(idlingResource); + } + + @Test + public void testAnimateToCameraPositionTarget() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + final MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); + + /*TODO remove zoom #6474*/ + float zoom = 1.0f; + LatLng moveTarget = new LatLng(1, 1); + + CameraPosition initialPosition = new CameraPosition.Builder().target(new LatLng()).zoom(zoom).bearing(0).tilt(0).build(); + CameraPosition cameraPosition = mapboxMap.getCameraPosition(); + assertEquals("Default camera position should match default", cameraPosition, initialPosition); + + onView(withId(R.id.mapView)).perform(new AnimateCameraAction(mapboxMap, CameraUpdateFactory.newLatLng(moveTarget))); + cameraPosition = mapboxMap.getCameraPosition(); + assertEquals("Moved camera position latitude should match", cameraPosition.target.getLatitude(), moveTarget.getLatitude(), TestConstants.LAT_LNG_DELTA); + assertEquals("Moved camera position longitude should match", cameraPosition.target.getLongitude(), moveTarget.getLongitude(), TestConstants.LAT_LNG_DELTA); + } + + @Test + public void testAnimateToCameraPositionTargetZoom() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + final MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); + + final float moveZoom = 15.5f; + final LatLng moveTarget = new LatLng(1.0000000001, 1.0000000003); + + onView(withId(R.id.mapView)).perform(new AnimateCameraAction(mapboxMap, CameraUpdateFactory.newLatLngZoom(moveTarget, moveZoom))); + CameraPosition cameraPosition = mapboxMap.getCameraPosition(); + assertEquals("Moved camera position latitude should match", cameraPosition.target.getLatitude(), moveTarget.getLatitude(), TestConstants.LAT_LNG_DELTA); + assertEquals("Moved camera position longitude should match", cameraPosition.target.getLongitude(), moveTarget.getLongitude(), TestConstants.LAT_LNG_DELTA); + assertEquals("Moved zoom should match", cameraPosition.zoom, moveZoom, TestConstants.ZOOM_DELTA); + } + + @Test + public void testAnimateToCameraPosition() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + final MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); + + final LatLng moveTarget = new LatLng(1.0000000001, 1.0000000003); + final float moveZoom = 15.5f; + final float moveTilt = 45.5f; + final float moveBearing = 12.5f; + + onView(withId(R.id.mapView)).perform( + new AnimateCameraAction(mapboxMap, CameraUpdateFactory.newCameraPosition( + new CameraPosition.Builder() + .target(moveTarget) + .zoom(moveZoom) + .tilt(moveTilt) + .bearing(moveBearing) + .build())) + ); + + CameraPosition cameraPosition = mapboxMap.getCameraPosition(); + assertEquals("Moved camera position latitude should match", cameraPosition.target.getLatitude(), moveTarget.getLatitude(), TestConstants.LAT_LNG_DELTA); + assertEquals("Moved camera position longitude should match", cameraPosition.target.getLongitude(), moveTarget.getLongitude(), TestConstants.LAT_LNG_DELTA); + assertEquals("Moved zoom should match", cameraPosition.zoom, moveZoom, TestConstants.ZOOM_DELTA); + assertEquals("Moved zoom should match", cameraPosition.tilt, moveTilt, TestConstants.TILT_DELTA); + assertEquals("Moved bearing should match", cameraPosition.bearing, moveBearing, TestConstants.BEARING_DELTA); + } + + @Test + public void testAnimateToBounds() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + final MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); + + final LatLng centerBounds = new LatLng(1, 1); + LatLng cornerOne = new LatLng(); + LatLng cornerTwo = new LatLng(2, 2); + + final LatLngBounds.Builder builder = new LatLngBounds.Builder(); + builder.include(cornerOne); + builder.include(cornerTwo); + + onView(withId(R.id.mapView)).perform(new AnimateCameraAction(mapboxMap, CameraUpdateFactory.newLatLngBounds(builder.build(), 0))); + + CameraPosition cameraPosition = mapboxMap.getCameraPosition(); + assertEquals("Moved camera position latitude should match center bounds", + cameraPosition.target.getLatitude(), + centerBounds.getLatitude(), + TestConstants.LAT_LNG_DELTA); + + assertEquals("Moved camera position longitude should match center bounds", + cameraPosition.target.getLongitude(), + centerBounds.getLongitude(), + TestConstants.LAT_LNG_DELTA); + } + + @Test + public void testAnimateToMoveBy() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + final MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); + + final PointF centerPoint = mapboxMap.getProjection().toScreenLocation(mapboxMap.getCameraPosition().target); + final LatLng moveTarget = new LatLng(2, 2); + final PointF moveTargetPoint = mapboxMap.getProjection().toScreenLocation(moveTarget); + + onView(withId(R.id.mapView)).perform(new AnimateCameraAction(mapboxMap, CameraUpdateFactory.scrollBy( + moveTargetPoint.x - centerPoint.x, moveTargetPoint.y - centerPoint.y))); + + CameraPosition cameraPosition = mapboxMap.getCameraPosition(); + assertEquals("Moved camera position latitude should match", cameraPosition.target.getLatitude(), moveTarget.getLatitude(), TestConstants.LAT_LNG_DELTA_LARGE); + assertEquals("Moved camera position longitude should match", cameraPosition.target.getLongitude(), moveTarget.getLongitude(), TestConstants.LAT_LNG_DELTA_LARGE); + } + + @Test + public void testAnimateToZoomIn() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + final MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); + + /*TODO fix zoom #6474*/ + float zoom = 1.0f; + + onView(withId(R.id.mapView)).perform(new AnimateCameraAction(mapboxMap, CameraUpdateFactory.zoomIn())); + CameraPosition cameraPosition = mapboxMap.getCameraPosition(); + assertEquals("Moved camera zoom should match moved camera zoom", cameraPosition.zoom, zoom + 1, TestConstants.ZOOM_DELTA); + } + + @Test + public void testAnimateToZoomOut() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + final MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); + + /*TODO fix zoom #6474*/ + float zoom = 10.0f; + onView(withId(R.id.mapView)).perform(new AnimateCameraAction(mapboxMap, CameraUpdateFactory.newLatLngZoom(new LatLng(), zoom))); + onView(withId(R.id.mapView)).perform(new AnimateCameraAction(mapboxMap, CameraUpdateFactory.zoomOut())); + CameraPosition cameraPosition = mapboxMap.getCameraPosition(); + assertEquals("Moved camera zoom should match moved camera zoom", cameraPosition.zoom, zoom - 1, TestConstants.ZOOM_DELTA); + } + + @Test + public void testAnimateToZoomBy() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + final MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); + + /*TODO fix zoom #6474*/ + float zoom = 1.0f; + final float zoomBy = 2.45f; + + onView(withId(R.id.mapView)).perform(new AnimateCameraAction(mapboxMap, CameraUpdateFactory.zoomBy(zoomBy))); + CameraPosition cameraPosition = mapboxMap.getCameraPosition(); + assertEquals("Moved camera zoom should match moved camera zoom", cameraPosition.zoom, zoom + zoomBy, TestConstants.ZOOM_DELTA); + } + + @Test + public void testAnimateToZoomTo() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + final MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); + + /*TODO fix zoom #6474*/ + final float zoomTo = 2.45f; + + onView(withId(R.id.mapView)).perform(new AnimateCameraAction(mapboxMap, CameraUpdateFactory.zoomTo(zoomTo))); + CameraPosition cameraPosition = mapboxMap.getCameraPosition(); + assertEquals("Moved camera zoom should match moved camera zoom", cameraPosition.zoom, zoomTo, TestConstants.ZOOM_DELTA); + } + + @After + public void unregisterIdlingResource() { + Espresso.unregisterIdlingResources(idlingResource); + } + + private class AnimateCameraAction implements ViewAction { + + private MapboxMap mapboxMap; + private CameraUpdate cameraUpdate; + + AnimateCameraAction(MapboxMap map, CameraUpdate update) { + mapboxMap = map; + cameraUpdate = update; + } + + @Override + public Matcher<View> getConstraints() { + return isDisplayed(); + } + + @Override + public String getDescription() { + return getClass().getSimpleName(); + } + + @Override + public void perform(UiController uiController, View view) { + mapboxMap.animateCamera(cameraUpdate); + uiController.loopMainThreadForAtLeast(MapboxConstants.ANIMATION_DURATION); + } + } +} + 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 new file mode 100644 index 0000000000..3782991e58 --- /dev/null +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/camera/CameraEaseTest.java @@ -0,0 +1,238 @@ +package com.mapbox.mapboxsdk.testapp.camera; + +import android.graphics.PointF; +import android.support.test.espresso.Espresso; +import android.support.test.espresso.UiController; +import android.support.test.espresso.ViewAction; +import android.support.test.rule.ActivityTestRule; +import android.view.View; + +import com.mapbox.mapboxsdk.camera.CameraPosition; +import com.mapbox.mapboxsdk.camera.CameraUpdate; +import com.mapbox.mapboxsdk.camera.CameraUpdateFactory; +import com.mapbox.mapboxsdk.constants.MapboxConstants; +import com.mapbox.mapboxsdk.geometry.LatLng; +import com.mapbox.mapboxsdk.geometry.LatLngBounds; +import com.mapbox.mapboxsdk.maps.MapboxMap; +import com.mapbox.mapboxsdk.testapp.R; +import com.mapbox.mapboxsdk.testapp.activity.espresso.EspressoTestActivity; +import com.mapbox.mapboxsdk.testapp.utils.OnMapReadyIdlingResource; +import com.mapbox.mapboxsdk.testapp.utils.TestConstants; +import com.mapbox.mapboxsdk.testapp.utils.ViewUtils; + +import org.hamcrest.Matcher; +import org.junit.After; +import org.junit.Before; +import org.junit.Rule; +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; +import static org.junit.Assert.assertEquals; + +public class CameraEaseTest { + + @Rule + public final ActivityTestRule<EspressoTestActivity> rule = new ActivityTestRule<>(EspressoTestActivity.class); + + private OnMapReadyIdlingResource idlingResource; + + @Before + public void registerIdlingResource() { + idlingResource = new OnMapReadyIdlingResource(rule.getActivity()); + Espresso.registerIdlingResources(idlingResource); + } + + @Test + public void testEaseToCameraPositionTarget() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + final MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); + + /*TODO remove zoom #6474*/ + float zoom = 1.0f; + LatLng moveTarget = new LatLng(1, 1); + + CameraPosition initialPosition = new CameraPosition.Builder().target(new LatLng()).zoom(zoom).bearing(0).tilt(0).build(); + CameraPosition cameraPosition = mapboxMap.getCameraPosition(); + assertEquals("Default camera position should match default", cameraPosition, initialPosition); + + onView(withId(R.id.mapView)).perform(new EaseCameraAction(mapboxMap, CameraUpdateFactory.newLatLng(moveTarget))); + cameraPosition = mapboxMap.getCameraPosition(); + assertEquals("Moved camera position latitude should match", cameraPosition.target.getLatitude(), moveTarget.getLatitude(), TestConstants.LAT_LNG_DELTA); + assertEquals("Moved camera position longitude should match", cameraPosition.target.getLongitude(), moveTarget.getLongitude(), TestConstants.LAT_LNG_DELTA); + } + + @Test + public void testEaseToCameraPositionTargetZoom() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + final MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); + + final float moveZoom = 15.5f; + final LatLng moveTarget = new LatLng(1.0000000001, 1.0000000003); + + onView(withId(R.id.mapView)).perform(new EaseCameraAction(mapboxMap, CameraUpdateFactory.newLatLngZoom(moveTarget, moveZoom))); + CameraPosition cameraPosition = mapboxMap.getCameraPosition(); + assertEquals("Moved camera position latitude should match", cameraPosition.target.getLatitude(), moveTarget.getLatitude(), TestConstants.LAT_LNG_DELTA); + assertEquals("Moved camera position longitude should match", cameraPosition.target.getLongitude(), moveTarget.getLongitude(), TestConstants.LAT_LNG_DELTA); + assertEquals("Moved zoom should match", cameraPosition.zoom, moveZoom, TestConstants.ZOOM_DELTA); + } + + @Test + public void testEaseToCameraPosition() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + final MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); + + final LatLng moveTarget = new LatLng(1.0000000001, 1.0000000003); + final float moveZoom = 15.5f; + final float moveTilt = 45.5f; + final float moveBearing = 12.5f; + + onView(withId(R.id.mapView)).perform( + new EaseCameraAction(mapboxMap, CameraUpdateFactory.newCameraPosition( + new CameraPosition.Builder() + .target(moveTarget) + .zoom(moveZoom) + .tilt(moveTilt) + .bearing(moveBearing) + .build())) + ); + + CameraPosition cameraPosition = mapboxMap.getCameraPosition(); + assertEquals("Moved camera position latitude should match", cameraPosition.target.getLatitude(), moveTarget.getLatitude(), TestConstants.LAT_LNG_DELTA); + assertEquals("Moved camera position longitude should match", cameraPosition.target.getLongitude(), moveTarget.getLongitude(), TestConstants.LAT_LNG_DELTA); + assertEquals("Moved zoom should match", cameraPosition.zoom, moveZoom, TestConstants.ZOOM_DELTA); + assertEquals("Moved zoom should match", cameraPosition.tilt, moveTilt, TestConstants.TILT_DELTA); + assertEquals("Moved bearing should match", cameraPosition.bearing, moveBearing, TestConstants.BEARING_DELTA); + } + + @Test + public void testEaseToBounds() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + final MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); + + final LatLng centerBounds = new LatLng(1, 1); + LatLng cornerOne = new LatLng(); + LatLng cornerTwo = new LatLng(2, 2); + + final LatLngBounds.Builder builder = new LatLngBounds.Builder(); + builder.include(cornerOne); + builder.include(cornerTwo); + + onView(withId(R.id.mapView)).perform(new EaseCameraAction(mapboxMap, CameraUpdateFactory.newLatLngBounds(builder.build(), 0))); + + CameraPosition cameraPosition = mapboxMap.getCameraPosition(); + assertEquals("Moved camera position latitude should match center bounds", + cameraPosition.target.getLatitude(), + centerBounds.getLatitude(), + TestConstants.LAT_LNG_DELTA); + + assertEquals("Moved camera position longitude should match center bounds", + cameraPosition.target.getLongitude(), + centerBounds.getLongitude(), + TestConstants.LAT_LNG_DELTA); + } + + @Test + public void testEaseToMoveBy() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + final MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); + + final PointF centerPoint = mapboxMap.getProjection().toScreenLocation(mapboxMap.getCameraPosition().target); + final LatLng moveTarget = new LatLng(2, 2); + final PointF moveTargetPoint = mapboxMap.getProjection().toScreenLocation(moveTarget); + + onView(withId(R.id.mapView)).perform(new EaseCameraAction(mapboxMap, CameraUpdateFactory.scrollBy( + moveTargetPoint.x - centerPoint.x, moveTargetPoint.y - centerPoint.y))); + + CameraPosition cameraPosition = mapboxMap.getCameraPosition(); + assertEquals("Moved camera position latitude should match", cameraPosition.target.getLatitude(), moveTarget.getLatitude(), TestConstants.LAT_LNG_DELTA_LARGE); + assertEquals("Moved camera position longitude should match", cameraPosition.target.getLongitude(), moveTarget.getLongitude(), TestConstants.LAT_LNG_DELTA_LARGE); + } + + @Test + public void testEaseToZoomIn() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + final MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); + + /*TODO fix zoom #6474*/ + float zoom = 1.0f; + + onView(withId(R.id.mapView)).perform(new EaseCameraAction(mapboxMap, CameraUpdateFactory.zoomIn())); + CameraPosition cameraPosition = mapboxMap.getCameraPosition(); + assertEquals("Moved camera zoom should match moved camera zoom", cameraPosition.zoom, zoom + 1, TestConstants.ZOOM_DELTA); + } + + @Test + public void testEaseToZoomOut() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + final MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); + + /*TODO fix zoom #6474*/ + float zoom = 10.0f; + onView(withId(R.id.mapView)).perform(new EaseCameraAction(mapboxMap, CameraUpdateFactory.newLatLngZoom(new LatLng(), zoom))); + onView(withId(R.id.mapView)).perform(new EaseCameraAction(mapboxMap, CameraUpdateFactory.zoomOut())); + CameraPosition cameraPosition = mapboxMap.getCameraPosition(); + assertEquals("Moved camera zoom should match moved camera zoom", 9, cameraPosition.zoom, TestConstants.ZOOM_DELTA); + } + + @Test + public void testEaseToZoomBy() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + final MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); + + /*TODO fix zoom #6474*/ + float zoom = 1.0f; + final float zoomBy = 2.45f; + + onView(withId(R.id.mapView)).perform(new EaseCameraAction(mapboxMap, CameraUpdateFactory.zoomBy(zoomBy))); + CameraPosition cameraPosition = mapboxMap.getCameraPosition(); + assertEquals("Moved camera zoom should match moved camera zoom", cameraPosition.zoom, zoom + zoomBy, TestConstants.ZOOM_DELTA); + } + + @Test + public void testEaseToZoomTo() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + final MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); + + /*TODO fix zoom #6474*/ + final float zoomTo = 2.45f; + + onView(withId(R.id.mapView)).perform(new EaseCameraAction(mapboxMap, CameraUpdateFactory.zoomTo(zoomTo))); + CameraPosition cameraPosition = mapboxMap.getCameraPosition(); + assertEquals("Moved camera zoom should match moved camera zoom", cameraPosition.zoom, zoomTo, TestConstants.ZOOM_DELTA); + } + + @After + public void unregisterIdlingResource() { + Espresso.unregisterIdlingResources(idlingResource); + } + + private class EaseCameraAction implements ViewAction { + + private MapboxMap mapboxMap; + private CameraUpdate cameraUpdate; + + EaseCameraAction(MapboxMap map, CameraUpdate update) { + mapboxMap = map; + cameraUpdate = update; + } + + @Override + public Matcher<View> getConstraints() { + return isDisplayed(); + } + + @Override + public String getDescription() { + return getClass().getSimpleName(); + } + + @Override + public void perform(UiController uiController, View view) { + mapboxMap.easeCamera(cameraUpdate); + uiController.loopMainThreadForAtLeast(MapboxConstants.ANIMATION_DURATION); + } + } +} + diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/camera/CameraInternalAPITest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/camera/CameraInternalAPITest.java new file mode 100644 index 0000000000..9bb30c0aa1 --- /dev/null +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/camera/CameraInternalAPITest.java @@ -0,0 +1,171 @@ +package com.mapbox.mapboxsdk.testapp.camera; + +import android.support.test.espresso.Espresso; +import android.support.test.espresso.UiController; +import android.support.test.espresso.ViewAction; +import android.support.test.rule.ActivityTestRule; +import android.view.View; + +import com.mapbox.mapboxsdk.camera.CameraPosition; +import com.mapbox.mapboxsdk.geometry.LatLng; +import com.mapbox.mapboxsdk.maps.MapView; +import com.mapbox.mapboxsdk.maps.MapboxMap; +import com.mapbox.mapboxsdk.maps.MapViewUtils; +import com.mapbox.mapboxsdk.testapp.R; +import com.mapbox.mapboxsdk.testapp.activity.espresso.EspressoTestActivity; +import com.mapbox.mapboxsdk.testapp.utils.OnMapReadyIdlingResource; +import com.mapbox.mapboxsdk.testapp.utils.TestConstants; +import com.mapbox.mapboxsdk.testapp.utils.ViewUtils; + +import org.hamcrest.Matcher; +import org.junit.After; +import org.junit.Before; +import org.junit.Rule; +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; +import static org.junit.Assert.assertEquals; + +/** + * Tests camera transformations that aren't part of our public API + */ +public class CameraInternalAPITest { + + @Rule + public final ActivityTestRule<EspressoTestActivity> rule = new ActivityTestRule<>(EspressoTestActivity.class); + + private OnMapReadyIdlingResource idlingResource; + + @Before + public void registerIdlingResource() { + idlingResource = new OnMapReadyIdlingResource(rule.getActivity()); + Espresso.registerIdlingResources(idlingResource); + } + + @Test + public void testBearing() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + EspressoTestActivity activity = rule.getActivity(); + MapboxMap mapboxMap = activity.getMapboxMap(); + + CameraPosition initialPosition = new CameraPosition.Builder().target(new LatLng()).zoom(1).bearing(0).tilt(0).build(); + CameraPosition cameraPosition = mapboxMap.getCameraPosition(); + assertEquals("Default camera position should match default", cameraPosition, initialPosition); + + MapView mapView = (MapView) activity.findViewById(R.id.mapView); + onView(withId(R.id.mapView)).perform(new BearingAction(mapView)); + assertEquals("Bearing should match", 45.1f, MapViewUtils.getDirection(mapView), TestConstants.BEARING_DELTA); + } + + @Test + public void testTilt() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + EspressoTestActivity activity = rule.getActivity(); + MapboxMap mapboxMap = activity.getMapboxMap(); + + CameraPosition initialPosition = new CameraPosition.Builder().target(new LatLng()).zoom(1).bearing(0).tilt(0).build(); + CameraPosition cameraPosition = mapboxMap.getCameraPosition(); + assertEquals("Default camera position should match default", cameraPosition, initialPosition); + + MapView mapView = (MapView) activity.findViewById(R.id.mapView); + onView(withId(R.id.mapView)).perform(new TiltAction(mapView)); + assertEquals("Tilt should match", 40.0f, MapViewUtils.getTilt(mapView), TestConstants.TILT_DELTA); + } + + @Test + public void testLatLng() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + EspressoTestActivity activity = rule.getActivity(); + MapboxMap mapboxMap = activity.getMapboxMap(); + + CameraPosition initialPosition = new CameraPosition.Builder().target(new LatLng()).zoom(1).bearing(0).tilt(0).build(); + CameraPosition cameraPosition = mapboxMap.getCameraPosition(); + assertEquals("Default camera position should match default", cameraPosition, initialPosition); + + MapView mapView = (MapView) activity.findViewById(R.id.mapView); + onView(withId(R.id.mapView)).perform(new LatLngAction(mapView)); + + LatLng centerCoordinate = MapViewUtils.getLatLng(mapView); + assertEquals("Latitude should match", 1.1f, centerCoordinate.getLatitude(), TestConstants.LAT_LNG_DELTA); + assertEquals("Longitude should match", 2.2f, centerCoordinate.getLongitude(), TestConstants.LAT_LNG_DELTA); + } + + @After + public void unregisterIdlingResource() { + Espresso.unregisterIdlingResources(idlingResource); + } + + private class BearingAction implements ViewAction { + + private MapView mapView; + + BearingAction(MapView mapView) { + this.mapView = mapView; + } + + @Override + public Matcher<View> getConstraints() { + return isDisplayed(); + } + + @Override + public String getDescription() { + return getClass().getSimpleName(); + } + + @Override + public void perform(UiController uiController, View view) { + MapViewUtils.setDirection(mapView, -45.1f); + } + } + + private class TiltAction implements ViewAction { + + private MapView mapView; + + TiltAction(MapView mapView) { + this.mapView = mapView; + } + + @Override + public Matcher<View> getConstraints() { + return isDisplayed(); + } + + @Override + public String getDescription() { + return getClass().getSimpleName(); + } + + @Override + public void perform(UiController uiController, View view) { + MapViewUtils.setTilt(mapView, 40.0f); + } + } + + private class LatLngAction implements ViewAction { + + private MapView mapView; + + LatLngAction(MapView mapView) { + this.mapView = mapView; + } + + @Override + public Matcher<View> getConstraints() { + return isDisplayed(); + } + + @Override + public String getDescription() { + return getClass().getSimpleName(); + } + + @Override + public void perform(UiController uiController, View view) { + MapViewUtils.setLatLng(mapView, new LatLng(1.1, 2.2)); + } + } +} 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 new file mode 100644 index 0000000000..053a7fb6bb --- /dev/null +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/camera/CameraMoveTest.java @@ -0,0 +1,236 @@ +package com.mapbox.mapboxsdk.testapp.camera; + +import android.graphics.PointF; +import android.support.test.espresso.Espresso; +import android.support.test.espresso.UiController; +import android.support.test.espresso.ViewAction; +import android.support.test.rule.ActivityTestRule; +import android.view.View; + +import com.mapbox.mapboxsdk.camera.CameraPosition; +import com.mapbox.mapboxsdk.camera.CameraUpdate; +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.R; +import com.mapbox.mapboxsdk.testapp.activity.espresso.EspressoTestActivity; +import com.mapbox.mapboxsdk.testapp.utils.OnMapReadyIdlingResource; +import com.mapbox.mapboxsdk.testapp.utils.TestConstants; +import com.mapbox.mapboxsdk.testapp.utils.ViewUtils; + +import org.hamcrest.Matcher; +import org.junit.After; +import org.junit.Before; +import org.junit.Rule; +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; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +public class CameraMoveTest { + + @Rule + public final ActivityTestRule<EspressoTestActivity> rule = new ActivityTestRule<>(EspressoTestActivity.class); + + private OnMapReadyIdlingResource idlingResource; + + @Before + public void registerIdlingResource() { + idlingResource = new OnMapReadyIdlingResource(rule.getActivity()); + Espresso.registerIdlingResources(idlingResource); + } + + @Test + public void testMoveToCameraPositionTarget() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + final MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); + + /*TODO remove zoom #6474*/ + float zoom = 1.0f; + LatLng moveTarget = new LatLng(1, 1); + + CameraPosition initialPosition = new CameraPosition.Builder().target(new LatLng()).zoom(zoom).bearing(0).tilt(0).build(); + CameraPosition cameraPosition = mapboxMap.getCameraPosition(); + assertEquals("Default camera position should match default", cameraPosition, initialPosition); + + onView(withId(R.id.mapView)).perform(new MoveCameraAction(mapboxMap, CameraUpdateFactory.newLatLng(moveTarget))); + cameraPosition = mapboxMap.getCameraPosition(); + assertEquals("Moved camera position latitude should match", cameraPosition.target.getLatitude(), moveTarget.getLatitude(), TestConstants.LAT_LNG_DELTA); + assertEquals("Moved camera position longitude should match", cameraPosition.target.getLongitude(), moveTarget.getLongitude(), TestConstants.LAT_LNG_DELTA); + } + + @Test + public void testMoveToCameraPositionTargetZoom() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + final MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); + + final float moveZoom = 15.5f; + final LatLng moveTarget = new LatLng(1.0000000001, 1.0000000003); + + onView(withId(R.id.mapView)).perform(new MoveCameraAction(mapboxMap, CameraUpdateFactory.newLatLngZoom(moveTarget, moveZoom))); + CameraPosition cameraPosition = mapboxMap.getCameraPosition(); + assertEquals("Moved camera position latitude should match", cameraPosition.target.getLatitude(), moveTarget.getLatitude(), TestConstants.LAT_LNG_DELTA); + assertEquals("Moved camera position longitude should match", cameraPosition.target.getLongitude(), moveTarget.getLongitude(), TestConstants.LAT_LNG_DELTA); + assertEquals("Moved zoom should match", cameraPosition.zoom, moveZoom, TestConstants.ZOOM_DELTA); + } + + @Test + public void testMoveToCameraPosition() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + final MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); + + final LatLng moveTarget = new LatLng(1.0000000001, 1.0000000003); + final float moveZoom = 15.5f; + final float moveTilt = 45.5f; + final float moveBearing = 12.5f; + + onView(withId(R.id.mapView)).perform( + new MoveCameraAction(mapboxMap, CameraUpdateFactory.newCameraPosition( + new CameraPosition.Builder() + .target(moveTarget) + .zoom(moveZoom) + .tilt(moveTilt) + .bearing(moveBearing) + .build())) + ); + + CameraPosition cameraPosition = mapboxMap.getCameraPosition(); + assertEquals("Moved camera position latitude should match", cameraPosition.target.getLatitude(), moveTarget.getLatitude(), TestConstants.LAT_LNG_DELTA); + assertEquals("Moved camera position longitude should match", cameraPosition.target.getLongitude(), moveTarget.getLongitude(), TestConstants.LAT_LNG_DELTA); + assertEquals("Moved zoom should match", cameraPosition.zoom, moveZoom, TestConstants.ZOOM_DELTA); + assertEquals("Moved zoom should match", cameraPosition.tilt, moveTilt, TestConstants.TILT_DELTA); + assertEquals("Moved bearing should match", cameraPosition.bearing, moveBearing, TestConstants.BEARING_DELTA); + } + + @Test + public void testMoveToBounds() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + final MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); + + final LatLng centerBounds = new LatLng(1, 1); + LatLng cornerOne = new LatLng(); + LatLng cornerTwo = new LatLng(2, 2); + + final LatLngBounds.Builder builder = new LatLngBounds.Builder(); + builder.include(cornerOne); + builder.include(cornerTwo); + + onView(withId(R.id.mapView)).perform(new MoveCameraAction(mapboxMap, CameraUpdateFactory.newLatLngBounds(builder.build(), 0))); + + CameraPosition cameraPosition = mapboxMap.getCameraPosition(); + assertEquals("Moved camera position latitude should match center bounds", + cameraPosition.target.getLatitude(), + centerBounds.getLatitude(), + TestConstants.LAT_LNG_DELTA); + + assertEquals("Moved camera position longitude should match center bounds", + cameraPosition.target.getLongitude(), + centerBounds.getLongitude(), + TestConstants.LAT_LNG_DELTA); + } + + @Test + public void testMoveToMoveBy() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + final MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); + + final PointF centerPoint = mapboxMap.getProjection().toScreenLocation(mapboxMap.getCameraPosition().target); + final LatLng moveTarget = new LatLng(2, 2); + final PointF moveTargetPoint = mapboxMap.getProjection().toScreenLocation(moveTarget); + + onView(withId(R.id.mapView)).perform(new MoveCameraAction(mapboxMap, CameraUpdateFactory.scrollBy( + moveTargetPoint.x - centerPoint.x, moveTargetPoint.y - centerPoint.y))); + + CameraPosition cameraPosition = mapboxMap.getCameraPosition(); + assertEquals("Moved camera position latitude should match", cameraPosition.target.getLatitude(), moveTarget.getLatitude(), TestConstants.LAT_LNG_DELTA_LARGE); + assertEquals("Moved camera position longitude should match", cameraPosition.target.getLongitude(), moveTarget.getLongitude(), TestConstants.LAT_LNG_DELTA_LARGE); + } + + @Test + public void testMoveToZoomIn() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + final MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); + + /*TODO fix zoom #6474*/ + float zoom = 1.0f; + + onView(withId(R.id.mapView)).perform(new MoveCameraAction(mapboxMap, CameraUpdateFactory.zoomIn())); + CameraPosition cameraPosition = mapboxMap.getCameraPosition(); + assertEquals("Moved camera zoom should match moved camera zoom", cameraPosition.zoom, zoom + 1, TestConstants.ZOOM_DELTA); + } + + @Test + public void testMoveToZoomOut() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + final MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); + + /*TODO fix zoom #6474*/ + float zoom = 10.0f; + onView(withId(R.id.mapView)).perform(new MoveCameraAction(mapboxMap, CameraUpdateFactory.newLatLngZoom(new LatLng(), zoom))); + onView(withId(R.id.mapView)).perform(new MoveCameraAction(mapboxMap, CameraUpdateFactory.zoomOut())); + CameraPosition cameraPosition = mapboxMap.getCameraPosition(); + assertEquals("Moved camera zoom should match moved camera zoom", cameraPosition.zoom, zoom - 1, TestConstants.ZOOM_DELTA); + } + + @Test + public void testMoveToZoomBy() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + final MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); + + /*TODO fix zoom #6474*/ + float zoom = 1.0f; + final float zoomBy = 2.45f; + + onView(withId(R.id.mapView)).perform(new MoveCameraAction(mapboxMap, CameraUpdateFactory.zoomBy(zoomBy))); + CameraPosition cameraPosition = mapboxMap.getCameraPosition(); + assertEquals("Moved camera zoom should match moved camera zoom", cameraPosition.zoom, zoom + zoomBy, TestConstants.ZOOM_DELTA); + } + + @Test + public void testMoveToZoomTo() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + final MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); + + /*TODO fix zoom #6474*/ + final float zoomTo = 2.45f; + + onView(withId(R.id.mapView)).perform(new MoveCameraAction(mapboxMap, CameraUpdateFactory.zoomTo(zoomTo))); + CameraPosition cameraPosition = mapboxMap.getCameraPosition(); + assertEquals("Moved camera zoom should match moved camera zoom", cameraPosition.zoom, zoomTo, TestConstants.ZOOM_DELTA); + } + + @After + public void unregisterIdlingResource() { + Espresso.unregisterIdlingResources(idlingResource); + } + + private class MoveCameraAction implements ViewAction { + + private MapboxMap mapboxMap; + private CameraUpdate cameraUpdate; + + MoveCameraAction(MapboxMap map, CameraUpdate update) { + mapboxMap = map; + cameraUpdate = update; + } + + @Override + public Matcher<View> getConstraints() { + return isDisplayed(); + } + + @Override + public String getDescription() { + return getClass().getSimpleName(); + } + + @Override + public void perform(UiController uiController, View view) { + mapboxMap.moveCamera(cameraUpdate); + } + } +} 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 deleted file mode 100644 index edef97027e..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/camera/RotateActivityTest.java +++ /dev/null @@ -1,62 +0,0 @@ -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 deleted file mode 100644 index 8f21f60fb0..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/camera/TiltActivityTest.java +++ /dev/null @@ -1,62 +0,0 @@ -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 deleted file mode 100644 index 700e8f6c5c..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/camera/ZoomActivityTest.java +++ /dev/null @@ -1,71 +0,0 @@ -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); - } - } - } -} 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 new file mode 100644 index 0000000000..1af957dac6 --- /dev/null +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/widgets/AttributionTest.java @@ -0,0 +1,156 @@ +package com.mapbox.mapboxsdk.testapp.maps.widgets; + +import android.app.Instrumentation; +import android.content.Intent; +import android.net.Uri; +import android.support.test.espresso.Espresso; +import android.support.test.espresso.UiController; +import android.support.test.espresso.ViewAction; +import android.support.test.espresso.intent.Intents; +import android.support.test.rule.ActivityTestRule; +import android.view.View; + +import com.mapbox.mapboxsdk.maps.MapboxMap; +import com.mapbox.mapboxsdk.testapp.R; +import com.mapbox.mapboxsdk.testapp.activity.espresso.EspressoTestActivity; +import com.mapbox.mapboxsdk.testapp.utils.OnMapReadyIdlingResource; +import com.mapbox.mapboxsdk.testapp.utils.ViewUtils; + +import org.hamcrest.Matcher; +import org.junit.After; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; + +import static android.support.test.espresso.Espresso.onView; +import static android.support.test.espresso.action.ViewActions.click; +import static android.support.test.espresso.assertion.ViewAssertions.matches; +import static android.support.test.espresso.intent.Intents.intended; +import static android.support.test.espresso.intent.Intents.intending; +import static android.support.test.espresso.intent.matcher.IntentMatchers.hasAction; +import static android.support.test.espresso.intent.matcher.IntentMatchers.hasData; +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.allOf; +import static org.hamcrest.core.IsNot.not; + +public class AttributionTest { + + @Rule + public final ActivityTestRule<EspressoTestActivity> rule = new ActivityTestRule<>(EspressoTestActivity.class); + + private OnMapReadyIdlingResource idlingResource; + + private String[] dialogTexts; + private String[] dialogLinks; + + @Before + public void beforeTest() { + idlingResource = new OnMapReadyIdlingResource(rule.getActivity()); + Espresso.registerIdlingResources(idlingResource); + Intents.init(); + dialogTexts = rule.getActivity().getResources().getStringArray(R.array.mapbox_attribution_names); + dialogLinks = rule.getActivity().getResources().getStringArray(R.array.mapbox_attribution_links); + } + + @Test + public void testDisabled() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); + + // Default + onView(withId(R.id.attributionView)).check(matches(isDisplayed())); + + // Disabled + onView(withId(R.id.attributionView)) + .perform(new DisableAction(mapboxMap)) + .check(matches(not(isDisplayed()))); + } + + @Test + public void testMapboxLink() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + + // click on View to open dialog + onView(withId(R.id.attributionView)).perform(click()); + onView(withText(R.string.mapbox_attributionsDialogTitle)).check(matches(isDisplayed())); + + // click on link and validate browser opening + Matcher<Intent> expectedIntent = allOf(hasAction(Intent.ACTION_VIEW), hasData(Uri.parse(dialogLinks[0]))); + intending(expectedIntent).respondWith(new Instrumentation.ActivityResult(0, null)); + onView(withText(dialogTexts[0])).perform(click()); + intended(expectedIntent); + } + + @Test + public void testOpenStreetMapLink() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + + // click on View to open dialog + onView(withId(R.id.attributionView)).perform(click()); + onView(withText(R.string.mapbox_attributionsDialogTitle)).check(matches(isDisplayed())); + + // click on link and validate browser opening + Matcher<Intent> expectedIntent = allOf(hasAction(Intent.ACTION_VIEW), hasData(Uri.parse(dialogLinks[1]))); + intending(expectedIntent).respondWith(new Instrumentation.ActivityResult(0, null)); + onView(withText(dialogTexts[1])).perform(click()); + } + + @Test + public void testImproveMapLink() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + + // click on View to open dialog + onView(withId(R.id.attributionView)).perform(click()); + onView(withText(R.string.mapbox_attributionsDialogTitle)).check(matches(isDisplayed())); + + // click on Mapbox link and validate browser opening + Matcher<Intent> expectedIntent = allOf(hasAction(Intent.ACTION_VIEW), hasData(Uri.parse(dialogLinks[3]))); + intending(expectedIntent).respondWith(new Instrumentation.ActivityResult(0, null)); + onView(withText(dialogTexts[3])).perform(click()); + } + + @Test + public void testTelemetryDialog() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + + // click on View to open dialog + onView(withId(R.id.attributionView)).perform(click()); + onView(withText(R.string.mapbox_attributionsDialogTitle)).check(matches(isDisplayed())); + + // click on item to open second dialog + onView(withText(dialogTexts[3])).perform(click()); + onView(withText(R.string.mapbox_attributionTelemetryTitle)).check(matches(isDisplayed())); + } + + @After + public void afterTest() { + Intents.release(); + Espresso.unregisterIdlingResources(idlingResource); + } + + private class DisableAction implements ViewAction { + + private MapboxMap mapboxMap; + + DisableAction(MapboxMap map) { + mapboxMap = map; + } + + @Override + public Matcher<View> getConstraints() { + return isDisplayed(); + } + + @Override + public String getDescription() { + return getClass().getSimpleName(); + } + + @Override + public void perform(UiController uiController, View view) { + mapboxMap.getUiSettings().setAttributionEnabled(false); + } + } +} 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 new file mode 100644 index 0000000000..0dfe07bfa2 --- /dev/null +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/widgets/CompassViewTest.java @@ -0,0 +1,153 @@ +package com.mapbox.mapboxsdk.testapp.maps.widgets; + +import android.support.test.espresso.Espresso; +import android.support.test.espresso.UiController; +import android.support.test.espresso.ViewAction; +import android.support.test.rule.ActivityTestRule; +import android.view.View; + +import com.mapbox.mapboxsdk.camera.CameraPosition; +import com.mapbox.mapboxsdk.camera.CameraUpdate; +import com.mapbox.mapboxsdk.camera.CameraUpdateFactory; +import com.mapbox.mapboxsdk.geometry.LatLng; +import com.mapbox.mapboxsdk.maps.MapboxMap; +import com.mapbox.mapboxsdk.testapp.R; +import com.mapbox.mapboxsdk.testapp.activity.espresso.EspressoTestActivity; +import com.mapbox.mapboxsdk.testapp.utils.OnMapReadyIdlingResource; +import com.mapbox.mapboxsdk.testapp.utils.TestConstants; +import com.mapbox.mapboxsdk.testapp.utils.ViewUtils; + +import org.hamcrest.Matcher; +import org.junit.After; +import org.junit.Before; +import org.junit.Ignore; +import org.junit.Rule; +import org.junit.Test; + +import static android.support.test.espresso.Espresso.onView; +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; +import static org.hamcrest.Matchers.not; +import static org.junit.Assert.assertEquals; + +public class CompassViewTest { + + @Rule + public final ActivityTestRule<EspressoTestActivity> rule = new ActivityTestRule<>(EspressoTestActivity.class); + + private OnMapReadyIdlingResource idlingResource; + + @Before + public void registerIdlingResource() { + idlingResource = new OnMapReadyIdlingResource(rule.getActivity()); + Espresso.registerIdlingResources(idlingResource); + } + + @Test + public void testDefault() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + onView(withId(R.id.compassView)).check(matches(not(isDisplayed()))); + } + + @Test + public void testVisible(){ + ViewUtils.checkViewIsDisplayed(R.id.mapView); + MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); + + onView(withId(R.id.mapView)).perform(new MoveCameraAction(mapboxMap, + CameraUpdateFactory.newCameraPosition( + new CameraPosition.Builder() + .bearing(45) + .zoom(1) + .target(new LatLng()) + .build() + ) + ) + ); + + onView(withId(R.id.compassView)).check(matches(isDisplayed())); + } + + @Test + @Ignore // 10-31-2016 click action is not working + public void testClick() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); + + onView(withId(R.id.mapView)).perform(new MoveCameraAction(mapboxMap, + CameraUpdateFactory.newCameraPosition( + new CameraPosition.Builder() + .bearing(45) + .zoom(1) + .target(new LatLng()) + .build() + ) + ) + ); + + onView(withId(R.id.compassView)).perform(click()); + onView(withId(R.id.mapView)).perform(new WaitAction(3000)); + onView(withId(R.id.compassView)).check(matches(not(isDisplayed()))); + + CameraPosition cameraPosition = mapboxMap.getCameraPosition(); + assertEquals("Camera bearing should face north, ", 0, cameraPosition.bearing, TestConstants.BEARING_DELTA); + } + + @After + public void unregisterIdlingResource() { + Espresso.unregisterIdlingResources(idlingResource); + } + + private class WaitAction implements ViewAction { + + private long waitTime; + + WaitAction(long waitTime) { + this.waitTime = waitTime; + } + + @Override + public Matcher<View> getConstraints() { + return isDisplayed(); + } + + @Override + public String getDescription() { + return getClass().getSimpleName(); + } + + @Override + public void perform(UiController uiController, View view) { + uiController.loopMainThreadForAtLeast(waitTime); + } + } + + private class MoveCameraAction implements ViewAction { + + private MapboxMap mapboxMap; + private CameraUpdate cameraUpdate; + + MoveCameraAction(MapboxMap map, CameraUpdate update) { + mapboxMap = map; + cameraUpdate = update; + } + + @Override + public Matcher<View> getConstraints() { + return isDisplayed(); + } + + @Override + public String getDescription() { + return getClass().getSimpleName(); + } + + @Override + public void perform(UiController uiController, View view) { + mapboxMap.moveCamera(cameraUpdate); + } + } +} + 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 new file mode 100644 index 0000000000..8be5e6b694 --- /dev/null +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/widgets/LogoTest.java @@ -0,0 +1,84 @@ +package com.mapbox.mapboxsdk.testapp.maps.widgets; + +import android.support.test.espresso.Espresso; +import android.support.test.espresso.UiController; +import android.support.test.espresso.ViewAction; +import android.support.test.rule.ActivityTestRule; +import android.view.View; + +import com.mapbox.mapboxsdk.maps.MapboxMap; +import com.mapbox.mapboxsdk.testapp.R; +import com.mapbox.mapboxsdk.testapp.activity.espresso.EspressoTestActivity; +import com.mapbox.mapboxsdk.testapp.utils.OnMapReadyIdlingResource; +import com.mapbox.mapboxsdk.testapp.utils.ViewUtils; + +import org.hamcrest.Matcher; +import org.junit.After; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; + +import static android.support.test.espresso.Espresso.onView; +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 org.hamcrest.Matchers.not; + +public class LogoTest { + + @Rule + public final ActivityTestRule<EspressoTestActivity> rule = new ActivityTestRule<>(EspressoTestActivity.class); + + private OnMapReadyIdlingResource idlingResource; + + @Before + public void registerIdlingResource() { + idlingResource = new OnMapReadyIdlingResource(rule.getActivity()); + Espresso.registerIdlingResources(idlingResource); + } + + @Test + public void testDefault() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + onView(withId(R.id.logoView)).check(matches(isDisplayed())); + } + + @Test + public void testDisabled() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); + + onView(withId(R.id.logoView)) + .perform(new DisableAction(mapboxMap)) + .check(matches(not(isDisplayed()))); + } + + @After + public void unregisterIdlingResource() { + Espresso.unregisterIdlingResources(idlingResource); + } + + private class DisableAction implements ViewAction { + + private MapboxMap mapboxMap; + + DisableAction(MapboxMap map) { + mapboxMap = map; + } + + @Override + public Matcher<View> getConstraints() { + return isDisplayed(); + } + + @Override + public String getDescription() { + return getClass().getSimpleName(); + } + + @Override + public void perform(UiController uiController, View view) { + mapboxMap.getUiSettings().setLogoEnabled(false); + } + } +} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/widgets/MyLocationViewTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/widgets/MyLocationViewTest.java new file mode 100644 index 0000000000..05892dfc41 --- /dev/null +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/widgets/MyLocationViewTest.java @@ -0,0 +1,242 @@ +package com.mapbox.mapboxsdk.testapp.maps.widgets; + +import android.content.res.Resources; +import android.graphics.Bitmap; +import android.graphics.Canvas; +import android.graphics.drawable.BitmapDrawable; +import android.graphics.drawable.Drawable; +import android.support.test.espresso.Espresso; +import android.support.test.espresso.UiController; +import android.support.test.espresso.ViewAction; +import android.support.test.rule.ActivityTestRule; +import android.view.View; + +import com.mapbox.mapboxsdk.camera.CameraPosition; +import com.mapbox.mapboxsdk.camera.CameraUpdateFactory; +import com.mapbox.mapboxsdk.constants.MyBearingTracking; +import com.mapbox.mapboxsdk.constants.MyLocationTracking; +import com.mapbox.mapboxsdk.geometry.LatLng; +import com.mapbox.mapboxsdk.location.LocationServices; +import com.mapbox.mapboxsdk.maps.MapboxMap; +import com.mapbox.mapboxsdk.maps.widgets.MyLocationView; +import com.mapbox.mapboxsdk.testapp.R; +import com.mapbox.mapboxsdk.testapp.activity.espresso.EspressoTestActivity; +import com.mapbox.mapboxsdk.testapp.utils.OnMapReadyIdlingResource; +import com.mapbox.mapboxsdk.testapp.utils.ViewUtils; + +import org.hamcrest.Description; +import org.hamcrest.Matcher; +import org.hamcrest.TypeSafeMatcher; +import org.junit.After; +import org.junit.Before; +import org.junit.Ignore; +import org.junit.Rule; +import org.junit.Test; + +import static android.support.test.espresso.Espresso.onView; +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 org.hamcrest.Matchers.not; + +/** + * Experimental MyLocationView tests, + * requires application to be granted with runtime location permissions. + * <p> + * Tests for enabling and disabling the {@link MyLocationView}. + * Tests for enabling tracking modes and if the correct default images are shown when toggling + * {@link com.mapbox.mapboxsdk.maps.TrackingSettings#setMyLocationTrackingMode(int)} & + * {@link com.mapbox.mapboxsdk.maps.TrackingSettings#setMyBearingTrackingMode(int)}. + * </p> + */ +public class MyLocationViewTest { + + @Rule + public final ActivityTestRule<EspressoTestActivity> rule = new ActivityTestRule<>(EspressoTestActivity.class); + + private OnMapReadyIdlingResource idlingResource; + + @Before + public void beforeTest() { + idlingResource = new OnMapReadyIdlingResource(rule.getActivity()); + Espresso.registerIdlingResources(idlingResource); + } + + @Test + @Ignore // requires runtime permissions, disabled for CI + public void testEnabled() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); + onView(withId(R.id.userLocationView)).check(matches(not(isDisplayed()))); + onView(withId(R.id.mapView)).perform(new ToggleLocationAction(mapboxMap, true)); + onView(withId(R.id.userLocationView)).check(matches(isDisplayed())); + onView(withId(R.id.mapView)).perform(new ToggleLocationAction(mapboxMap, false)); + onView(withId(R.id.userLocationView)).check(matches(not(isDisplayed()))); + } + + @Test + @Ignore // requires runtime permissions, disabled for CI + issue with android.support.test.espresso.AppNotIdleException: Looped for 5049 iterations over 60 SECONDS. + public void testTracking() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); + onView(withId(R.id.userLocationView)).check(matches(not(isDisplayed()))); + onView(withId(R.id.mapView)).perform(new EnableLocationTrackingAction(mapboxMap)); + onView(withId(R.id.userLocationView)).check(matches(isDisplayed())); + onView(withId(R.id.userLocationView)).check(matches(new DrawableMatcher(mapboxMap, R.drawable.mapbox_mylocation_icon_default, false))); + onView(withId(R.id.mapView)).perform(new EnableCompassBearingTrackingAction(mapboxMap)); + onView(withId(R.id.userLocationView)).check(matches(new DrawableMatcher(mapboxMap, R.drawable.mapbox_mylocation_icon_bearing, true))); + } + + @After + public void afterTest() { + Espresso.unregisterIdlingResources(idlingResource); + } + + private class ToggleLocationAction implements ViewAction { + + private MapboxMap mapboxMap; + private boolean isEnabled; + + ToggleLocationAction(MapboxMap map, boolean enable) { + mapboxMap = map; + isEnabled = enable; + } + + @Override + public Matcher<View> getConstraints() { + return isDisplayed(); + } + + @Override + public String getDescription() { + return getClass().getSimpleName(); + } + + @Override + public void perform(UiController uiController, View view) { + if (isEnabled) { + // move camera above user location + mapboxMap.moveCamera( + CameraUpdateFactory.newCameraPosition( + new CameraPosition.Builder() + .target(new LatLng(LocationServices.getLocationServices(view.getContext()).getLastLocation())) + .build() + ) + ); + } + + // show loction on screen + mapboxMap.setMyLocationEnabled(isEnabled); + } + } + + private class EnableLocationTrackingAction implements ViewAction { + + private MapboxMap mapboxMap; + + EnableLocationTrackingAction(MapboxMap map) { + mapboxMap = map; + } + + @Override + public Matcher<View> getConstraints() { + return isDisplayed(); + } + + @Override + public String getDescription() { + return getClass().getSimpleName(); + } + + @Override + public void perform(UiController uiController, View view) { + mapboxMap.getTrackingSettings().setMyLocationTrackingMode(MyLocationTracking.TRACKING_FOLLOW); + } + } + + private class EnableCompassBearingTrackingAction implements ViewAction { + + private MapboxMap mapboxMap; + + EnableCompassBearingTrackingAction(MapboxMap map) { + mapboxMap = map; + } + + @Override + public Matcher<View> getConstraints() { + return isDisplayed(); + } + + @Override + public String getDescription() { + return getClass().getSimpleName(); + } + + @Override + public void perform(UiController uiController, View view) { + mapboxMap.getTrackingSettings().setMyBearingTrackingMode(MyBearingTracking.COMPASS); + // wait for next compass update cycle + uiController.loopMainThreadForAtLeast(500); + } + } + + private class DrawableMatcher extends TypeSafeMatcher<View> { + + private MapboxMap mapboxMap; + private boolean isBearingDrawable; + private final int expectedId; + + DrawableMatcher(MapboxMap mapboxMap, int expectedId, boolean isBearingDrawable) { + super(MyLocationView.class); + this.mapboxMap = mapboxMap; + this.expectedId = expectedId; + this.isBearingDrawable = isBearingDrawable; + } + + @Override + protected boolean matchesSafely(View target) { + Drawable currentDrawable = isBearingDrawable ? + mapboxMap.getMyLocationViewSettings().getForegroundBearingDrawable() : + mapboxMap.getMyLocationViewSettings().getForegroundDrawable(); + + Resources resources = target.getContext().getResources(); + Drawable expectedDrawable = resources.getDrawable(expectedId); + return areDrawablesIdentical(currentDrawable, expectedDrawable); + } + + @Override + public void describeTo(Description description) { + description.appendText("trying to match MyLocationView drawable to " + expectedId); + } + + boolean areDrawablesIdentical(Drawable drawableA, Drawable drawableB) { + Drawable.ConstantState stateA = drawableA.getConstantState(); + Drawable.ConstantState stateB = drawableB.getConstantState(); + return (stateA != null && stateB != null && stateA.equals(stateB)) + || getBitmap(drawableA).sameAs(getBitmap(drawableB)); + } + + Bitmap getBitmap(Drawable drawable) { + Bitmap result; + if (drawable instanceof BitmapDrawable) { + result = ((BitmapDrawable) drawable).getBitmap(); + } else { + int width = drawable.getIntrinsicWidth(); + int height = drawable.getIntrinsicHeight(); + // Some drawables have no intrinsic width - e.g. solid colours. + if (width <= 0) { + width = 1; + } + if (height <= 0) { + height = 1; + } + + result = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); + Canvas canvas = new Canvas(result); + drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight()); + drawable.draw(canvas); + } + return result; + } + } +} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/RuntimeStyleTests.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/RuntimeStyleTests.java index 783601b1dd..f9ee324ead 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/RuntimeStyleTests.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/RuntimeStyleTests.java @@ -1,8 +1,11 @@ package com.mapbox.mapboxsdk.testapp.style; import android.support.test.espresso.Espresso; +import android.support.test.espresso.UiController; +import android.support.test.espresso.ViewAction; import android.support.test.rule.ActivityTestRule; import android.support.test.runner.AndroidJUnit4; +import android.view.View; import com.mapbox.mapboxsdk.maps.MapboxMap; import com.mapbox.mapboxsdk.style.layers.FillLayer; @@ -14,7 +17,9 @@ import com.mapbox.mapboxsdk.style.sources.VectorSource; import com.mapbox.mapboxsdk.testapp.R; import com.mapbox.mapboxsdk.testapp.activity.style.RuntimeStyleTestActivity; import com.mapbox.mapboxsdk.testapp.utils.OnMapReadyIdlingResource; +import com.mapbox.mapboxsdk.testapp.utils.ViewUtils; +import org.hamcrest.Matcher; import org.junit.After; import org.junit.Before; import org.junit.Ignore; @@ -22,6 +27,9 @@ import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; +import static android.support.test.espresso.Espresso.onView; +import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed; +import static android.support.test.espresso.matcher.ViewMatchers.withId; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; @@ -31,7 +39,7 @@ import static org.junit.Assert.assertTrue; * Basic smoke tests for Layer and Source */ @RunWith(AndroidJUnit4.class) -public class RuntimeStyleTests extends BaseStyleTest { +public class RuntimeStyleTests { @Rule public final ActivityTestRule<RuntimeStyleTestActivity> rule = new ActivityTestRule<>(RuntimeStyleTestActivity.class); @@ -44,45 +52,15 @@ public class RuntimeStyleTests extends BaseStyleTest { Espresso.registerIdlingResources(idlingResource); } - /** - * TODO fix failing test - */ @Test - @Ignore public void testGetAddRemoveLayer() { - checkViewIsDisplayed(R.id.mapView); - - MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); - - //Get initial - assertNotNull(mapboxMap.getLayer("building")); - - //Remove - try { - mapboxMap.removeLayer("building"); - } catch (NoSuchLayerException e) { - assertFalse(true); - } - assertNull(mapboxMap.getLayer("building")); - - //Add - FillLayer layer = new FillLayer("building", "composite"); - layer.setSourceLayer("building"); - mapboxMap.addLayer(layer); - - assertNotNull(mapboxMap.getLayer("building")); - - try { - layer.setProperties(PropertyFactory.visibility(Property.VISIBLE)); - assertTrue("Never reached as the reference is invalid after adding", false); - } catch (Exception e) { - //Expected, reference is no longer valid - } + ViewUtils.checkViewIsDisplayed(R.id.mapView); + onView(withId(R.id.mapView)).perform(new AddRemoveLayerAction()); } @Test public void testAddRemoveSource() { - checkViewIsDisplayed(R.id.mapView); + ViewUtils.checkViewIsDisplayed(R.id.mapView); MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); mapboxMap.addSource(new VectorSource("my-source", "mapbox://mapbox.mapbox-terrain-v2")); @@ -93,6 +71,48 @@ public class RuntimeStyleTests extends BaseStyleTest { } } + private class AddRemoveLayerAction implements ViewAction { + + @Override + public Matcher<View> getConstraints() { + return isDisplayed(); + } + + @Override + public String getDescription() { + return getClass().getSimpleName(); + } + + @Override + public void perform(UiController uiController, View view) { + MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); + + //Get initial + assertNotNull(mapboxMap.getLayer("building")); + + //Remove + try { + mapboxMap.removeLayer("building"); + } catch (NoSuchLayerException e) { + assertFalse(true); + } + assertNull(mapboxMap.getLayer("building")); + + //Add + FillLayer layer = new FillLayer("building", "composite"); + layer.setSourceLayer("building"); + mapboxMap.addLayer(layer); + assertNotNull(mapboxMap.getLayer("building")); + + try { + layer.setProperties(PropertyFactory.visibility(Property.VISIBLE)); + assertTrue("Never reached as the reference is invalid after adding", false); + } catch (Exception e) { + //Expected, reference is no longer valid + } + } + } + @After public void unregisterIntentServiceIdlingResource() { Espresso.unregisterIdlingResources(idlingResource); 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 new file mode 100644 index 0000000000..67556e49fb --- /dev/null +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/utils/TestConstants.java @@ -0,0 +1,15 @@ +package com.mapbox.mapboxsdk.testapp.utils; + +public class TestConstants { + + public static final double LAT_LNG_DELTA_LARGE = 0.1; + public static final double LAT_LNG_DELTA = 0.01; + public static final double BEARING_DELTA = 0.1; + public static final double TILT_DELTA = 0.1; + public static final double ZOOM_DELTA = 0.1; + + 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 index 01ee3e9b9f..188e75edc7 100644 --- 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 @@ -4,6 +4,8 @@ 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 { @@ -12,4 +14,9 @@ public class ViewUtils { onView(withId(viewRes)) .perform(click()); } + + public static void checkViewIsDisplayed(int id) { + onView(withId(id)) + .check(matches(isDisplayed())); + } } diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/AndroidManifest.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/AndroidManifest.xml index 92a8f0e48e..b1dc3c098e 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/AndroidManifest.xml +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/AndroidManifest.xml @@ -446,9 +446,10 @@ android:value="@string/category_maplayout" /> </activity> - <!-- For Unit tests --> + <!-- For Instrumentation tests --> <activity android:name=".activity.style.RuntimeStyleTestActivity" /> <activity android:name=".activity.style.RuntimeStyleTimingTestActivity" /> + <activity android:name=".activity.espresso.EspressoTestActivity" /> <!-- Configuration Settings --> <meta-data diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/MarkerViewActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/MarkerViewActivity.java index 3a7d8b4a5c..7099b5728a 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/MarkerViewActivity.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/MarkerViewActivity.java @@ -327,12 +327,12 @@ public class MarkerViewActivity extends AppCompatActivity { /** * Adapts a MarkerView to display text in a TextView. */ - private static class TextAdapter extends MapboxMap.MarkerViewAdapter<TextMarkerView> { + public static class TextAdapter extends MapboxMap.MarkerViewAdapter<TextMarkerView> { private LayoutInflater inflater; private MapboxMap mapboxMap; - TextAdapter(@NonNull Context context, @NonNull MapboxMap mapboxMap) { + public TextAdapter(@NonNull Context context, @NonNull MapboxMap mapboxMap) { super(context); this.inflater = LayoutInflater.from(context); this.mapboxMap = mapboxMap; 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 new file mode 100644 index 0000000000..5c6c4b7125 --- /dev/null +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/espresso/EspressoTestActivity.java @@ -0,0 +1,80 @@ +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.maps.OnMapReadyCallback; +import com.mapbox.mapboxsdk.testapp.R; + +/** + * Base activity for instrumentation testing + */ +public class EspressoTestActivity extends AppCompatActivity implements OnMapReadyCallback { + + public MapView mapView; + protected MapboxMap mapboxMap; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_camera_test); + + //Initialize map as normal + mapView = (MapView) findViewById(R.id.mapView); + mapView.onCreate(savedInstanceState); + mapView.getMapAsync(this); + } + + @Override + public void onMapReady(MapboxMap map) { + mapboxMap = map; + } + + public MapboxMap getMapboxMap() { + return mapboxMap; + } + + @Override + public void onResume() { + super.onResume(); + mapView.onResume(); + } + + @Override + protected void onStart() { + super.onStart(); + mapView.onStart(); + } + + @Override + public 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/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_camera_test.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_camera_test.xml new file mode 100644 index 0000000000..4f86120097 --- /dev/null +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_camera_test.xml @@ -0,0 +1,22 @@ +<?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"> + + <android.support.v7.widget.Toolbar + android:id="@+id/toolbar" + android:layout_width="match_parent" + android:layout_height="?attr/actionBarSize" + android:background="@color/primary" + android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" /> + + <!-- TODO remove zoom #6747--> + <com.mapbox.mapboxsdk.maps.MapView + android:id="@id/mapView" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:layout_below="@id/toolbar" + app:mapbox_cameraZoom="1" /> + +</RelativeLayout> diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/fragment_dialog_map.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/fragment_dialog_map.xml index 91a68232e6..b40ad1273d 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/fragment_dialog_map.xml +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/fragment_dialog_map.xml @@ -1,6 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> -<LinearLayout - xmlns:android="http://schemas.android.com/apk/res/android" +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:mapbox="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent" @@ -12,7 +11,8 @@ android:layout_height="match_parent" mapbox:mapbox_cameraTargetLat="47.6077" mapbox:mapbox_cameraTargetLng="-122.3421" - mapbox:mapbox_styleUrl="mapbox://styles/mapbox/streets-v9" - mapbox:mapbox_cameraZoom="11"/> + mapbox:mapbox_cameraZoom="11" + mapbox:mapbox_renderTextureMode="true" + mapbox:mapbox_styleUrl="mapbox://styles/mapbox/streets-v9" /> </LinearLayout>
\ No newline at end of file |