[android] - instrumentation tests upgrade, move view checking to utility class, remove inheritance in runtime style test (#6803)
update gitignore for generated tests add camera move test add realtime geojson to be excluded when generating Activity sanity tests by default show workaround for showing a MapView in a dialog add annotation tests remove older camera tests, introduce tests for move, ease and animate, bring back setLatLng and getLatLng on MapView, add tests for internal camera API. compass view tests add tests for attribution and logo. fix annotation tests Rename Actiivity test class, split up annotation tests, added MarkerView tests, added infowindow tests, added MyLocationView tests fix addRemoveLayer test by integrating map interactions inside a ViewAction
This commit is contained in:
@@ -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()};
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
|
||||
@@ -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";
|
||||
|
||||
}
|
||||
@@ -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()));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user