diff options
author | tobrun <tobrun.van.nuland@gmail.com> | 2018-07-04 12:47:08 +0200 |
---|---|---|
committer | Tobrun <tobrun@mapbox.com> | 2018-07-05 13:30:50 +0200 |
commit | 32dce870d756063167e000302afb553714f1f0cb (patch) | |
tree | 9624d19e424b6ddddcb0b5030f898c953ab9d317 /platform/android | |
parent | ec78936e18946e3cad75d23beb03b90fcf0cb915 (diff) | |
download | qtlocation-mapboxgl-32dce870d756063167e000302afb553714f1f0cb.tar.gz |
[android] - create device independent tests for camera position testing
Diffstat (limited to 'platform/android')
17 files changed, 209 insertions, 107 deletions
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java index 3227cb0dab..f4b1bca251 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java @@ -146,8 +146,8 @@ public class MapView extends FrameLayout implements NativeMapView.ViewCallback { nativeMapView.addOnMapChangedListener(mapCallback); // callback for focal point invalidation - final FocalPointInvalidator focalPointInvalidator = new FocalPointInvalidator(); - focalPointInvalidator.addListener(createFocalPointChangeListener()); + final FocalPointInvalidator focalInvalidator = new FocalPointInvalidator(); + focalInvalidator.addListener(createFocalPointChangeListener()); // callback for registering touch listeners GesturesManagerInteractionListener registerTouchListener = new GesturesManagerInteractionListener(); @@ -157,7 +157,7 @@ public class MapView extends FrameLayout implements NativeMapView.ViewCallback { // setup components for MapboxMap creation Projection proj = new Projection(nativeMapView); - UiSettings uiSettings = new UiSettings(proj, focalPointInvalidator, compassView, attrView, logoView); + UiSettings uiSettings = new UiSettings(proj, focalInvalidator, compassView, attrView, logoView, getPixelRatio()); LongSparseArray<Annotation> annotationsArray = new LongSparseArray<>(); MarkerViewManager markerViewManager = new MarkerViewManager((ViewGroup) findViewById(R.id.markerViewContainer)); IconManager iconManager = new IconManager(nativeMapView); @@ -310,15 +310,12 @@ public class MapView extends FrameLayout implements NativeMapView.ViewCallback { addView(glSurfaceView, 0); } - nativeMapView = new NativeMapView(getContext(), this, mapRenderer); - nativeMapView.addOnMapChangedListener(new OnMapChangedListener() { - @Override - public void onMapChanged(int change) { - // dispatch events to external listeners - if (!onMapChangedListeners.isEmpty()) { - for (OnMapChangedListener onMapChangedListener : onMapChangedListeners) { - onMapChangedListener.onMapChanged(change); - } + nativeMapView = new NativeMapView(getContext(), getPixelRatio(), this, mapRenderer); + nativeMapView.addOnMapChangedListener(change -> { + // dispatch events to external listeners + if (!onMapChangedListeners.isEmpty()) { + for (OnMapChangedListener onMapChangedListener : onMapChangedListeners) { + onMapChangedListener.onMapChanged(change); } } }); @@ -583,6 +580,16 @@ public class MapView extends FrameLayout implements NativeMapView.ViewCallback { } } + private float getPixelRatio() { + // check is user defined his own pixel ratio value + float pixelRatio = mapboxMapOptions.getPixelRatio(); + if (pixelRatio == 0) { + // if not, get the one defined by the system + pixelRatio = getResources().getDisplayMetrics().density; + } + return pixelRatio; + } + // // View events // diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMap.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMap.java index 1a8fc1eac7..64ad0d29b3 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMap.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMap.java @@ -1568,7 +1568,7 @@ public final class MapboxMap { /** - * Get a camera position that fits a provided bounds and the current camera tilt. + * Get a camera position that fits a provided bounds and the current camera tilt and bearing. * * @param latLngBounds the bounds to set the map with * @return the camera position that fits the bounds @@ -1581,7 +1581,7 @@ public final class MapboxMap { /** - * Get a camera position that fits a provided bounds and padding and the current camera tilt. + * Get a camera position that fits a provided bounds and padding and the current camera tilt and bearing. * * @param latLngBounds the bounds to set the map with * @param padding the padding to apply to the bounds @@ -1596,12 +1596,12 @@ public final class MapboxMap { /** - * Get a camera position that fits a provided bounds, padding and tilt. + * Get a camera position that fits a provided bounds, bearing and tilt. * * @param latLngBounds the bounds to set the map with * @param bearing the bearing to transform the camera position with * @param tilt to transform the camera position with - * @return the camera position that fits the bounds and padding + * @return the camera position that fits the bounds and given bearing and tilt */ @NonNull public CameraPosition getCameraForLatLngBounds(@NonNull LatLngBounds latLngBounds, @@ -1614,13 +1614,13 @@ public final class MapboxMap { /** - * Get a camera position that fits a provided bounds, padding and tilt. + * Get a camera position that fits a provided bounds, padding, bearing and tilt. * * @param latLngBounds the bounds to set the map with * @param padding the padding to apply to the bounds * @param bearing the bearing to transform the camera position with * @param tilt to transform the camera position with - * @return the camera position that fits the bounds and padding + * @return the camera position that fits the bounds, bearing and tilt */ @NonNull public CameraPosition getCameraForLatLngBounds(@NonNull LatLngBounds latLngBounds, @@ -1633,10 +1633,10 @@ public final class MapboxMap { } /** - * Get a camera position that fits a provided shape with a given bearing and padding. + * Get a camera position that fits a provided shape. * - * @param geometry the geometry to constrain the map with - * @return the camera position that fits the bounds and padding + * @param geometry the geometry to wraps the map with + * @return the camera position that fits the geometry inside */ @NonNull public CameraPosition getCameraForGeometry(@NonNull Geometry geometry) { @@ -1645,11 +1645,11 @@ public final class MapboxMap { } /** - * Get a camera position that fits a provided shape with a given bearing and padding. + * Get a camera position that fits a provided shape and padding. * - * @param geometry the geometry to constrain the map with + * @param geometry the geometry to wraps the map with * @param padding the padding to apply to the bounds - * @return the camera position that fits the bounds and padding + * @return the camera position that fits the geometry inside and padding */ @NonNull public CameraPosition getCameraForGeometry(@NonNull Geometry geometry, @@ -1659,12 +1659,12 @@ public final class MapboxMap { } /** - * Get a camera position that fits a provided shape with a given bearing and padding. + * Get a camera position that fits a provided shape with a given bearing and tilt. * - * @param geometry the geometry to constrain the map with + * @param geometry the geometry to wraps the map with * @param bearing the bearing at which to compute the geometry's bounds * @param tilt the tilt at which to compute the geometry's bounds - * @return the camera position that fits the bounds and padding + * @return the camera position that the geometry inside with bearing and tilt */ @NonNull public CameraPosition getCameraForGeometry(@NonNull Geometry geometry, @@ -1676,13 +1676,13 @@ public final class MapboxMap { } /** - * Get a camera position that fits a provided shape with a given bearing and padding. + * Get a camera position that fits a provided shape with a given padding, bearing and tilt. * - * @param geometry the geometry to constrain the map with + * @param geometry the geometry to wraps the map with * @param padding the padding to apply to the bounds * @param bearing the bearing at which to compute the geometry's bounds * @param tilt the tilt at which to compute the geometry's bounds - * @return the camera position that fits the bounds and padding + * @return the camera position that fits the geometry inside with padding, bearing and tilt */ @NonNull public CameraPosition getCameraForGeometry(@NonNull Geometry geometry, @@ -1697,10 +1697,10 @@ public final class MapboxMap { /** * Get a camera position that fits a provided shape with a given bearing and padding. * - * @param geometry the geometry to constrain the map with + * @param geometry the geometry to wraps the map with * @param bearing the bearing at which to compute the geometry's bounds * @param padding the padding to apply to the bounds - * @return the camera position that fits the bounds and padding + * @return the camera position that fits the geometry inside with padding and bearing * @deprecated use Mapbox{@link #getCameraForGeometry(Geometry, int[], double, double)} instead */ @NonNull diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMapOptions.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMapOptions.java index bb4e2f9212..02c50c9f18 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMapOptions.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMapOptions.java @@ -13,7 +13,6 @@ import android.support.annotation.Nullable; import android.support.v4.content.res.ResourcesCompat; import android.util.AttributeSet; import android.view.Gravity; - import com.mapbox.mapboxsdk.R; import com.mapbox.mapboxsdk.camera.CameraPosition; import com.mapbox.mapboxsdk.constants.MapboxConstants; @@ -76,6 +75,8 @@ public class MapboxMapOptions implements Parcelable { private String style; + private float pixelRatio; + /** * Creates a new MapboxMapOptions object. */ @@ -122,6 +123,7 @@ public class MapboxMapOptions implements Parcelable { prefetchesTiles = in.readByte() != 0; zMediaOverlay = in.readByte() != 0; localIdeographFontFamily = in.readString(); + pixelRatio = in.readFloat(); } /** @@ -218,6 +220,8 @@ public class MapboxMapOptions implements Parcelable { typedArray.getBoolean(R.styleable.mapbox_MapView_mapbox_enableZMediaOverlay, false)); mapboxMapOptions.localIdeographFontFamily( typedArray.getString(R.styleable.mapbox_MapView_mapbox_localIdeographFontFamily)); + mapboxMapOptions.pixelRatio( + typedArray.getFloat(R.styleable.mapbox_MapView_mapbox_pixelRatio, 0)); } finally { typedArray.recycle(); } @@ -546,6 +550,18 @@ public class MapboxMapOptions implements Parcelable { } /** + * Set the custom pixel ratio configuration to override the default value from resources. + * This ratio will be used to initialise the map with. + * + * @param pixelRatio the custom pixel ratio of the map under construction + * @return This + */ + public MapboxMapOptions pixelRatio(float pixelRatio) { + this.pixelRatio = pixelRatio; + return this; + } + + /** * Check whether tile pre-fetching is enabled. * * @return true if enabled @@ -813,6 +829,15 @@ public class MapboxMapOptions implements Parcelable { return localIdeographFontFamily; } + /** + * Return the custom configured pixel ratio, returns 0 if not configured. + * + * @return the pixel ratio used by the map under construction + */ + public float getPixelRatio() { + return pixelRatio; + } + public static final Parcelable.Creator<MapboxMapOptions> CREATOR = new Parcelable.Creator<MapboxMapOptions>() { public MapboxMapOptions createFromParcel(Parcel in) { return new MapboxMapOptions(in); @@ -866,6 +891,7 @@ public class MapboxMapOptions implements Parcelable { dest.writeByte((byte) (prefetchesTiles ? 1 : 0)); dest.writeByte((byte) (zMediaOverlay ? 1 : 0)); dest.writeString(localIdeographFontFamily); + dest.writeFloat(pixelRatio); } @Override @@ -959,7 +985,10 @@ public class MapboxMapOptions implements Parcelable { if (zMediaOverlay != options.zMediaOverlay) { return false; } - if (localIdeographFontFamily != options.localIdeographFontFamily) { + if (!localIdeographFontFamily.equals(options.localIdeographFontFamily)) { + return false; + } + if (pixelRatio != options.pixelRatio) { return false; } @@ -1001,6 +1030,7 @@ public class MapboxMapOptions implements Parcelable { result = 31 * result + (prefetchesTiles ? 1 : 0); result = 31 * result + (zMediaOverlay ? 1 : 0); result = 31 * result + (localIdeographFontFamily != null ? localIdeographFontFamily.hashCode() : 0); + result = 31 * result + (int) pixelRatio; return result; } } diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/UiSettings.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/UiSettings.java index 100787fbf0..32fc0589d1 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/UiSettings.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/UiSettings.java @@ -42,7 +42,7 @@ public final class UiSettings { private final View logoView; private final int[] logoMargins = new int[4]; - private float pixelRatio; + private final float pixelRatio; private boolean rotateGesturesEnabled = true; @@ -68,15 +68,14 @@ public final class UiSettings { private PointF userProvidedFocalPoint; UiSettings(@NonNull Projection projection, @NonNull FocalPointChangeListener listener, - @NonNull CompassView compassView, @NonNull ImageView attributionsView, @NonNull View logoView) { + @NonNull CompassView compassView, @NonNull ImageView attributionsView, @NonNull View logoView, + float pixelRatio) { this.projection = projection; this.focalPointChangeListener = listener; this.compassView = compassView; this.attributionsView = attributionsView; this.logoView = logoView; - if (logoView.getResources() != null) { - this.pixelRatio = logoView.getResources().getDisplayMetrics().density; - } + this.pixelRatio = pixelRatio; } void initialise(@NonNull Context context, @NonNull MapboxMapOptions options) { diff --git a/platform/android/MapboxGLAndroidSDK/src/main/res-public/values/public.xml b/platform/android/MapboxGLAndroidSDK/src/main/res-public/values/public.xml index 9ab8d34ef3..99432e7066 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/res-public/values/public.xml +++ b/platform/android/MapboxGLAndroidSDK/src/main/res-public/values/public.xml @@ -12,6 +12,7 @@ <public name="mapbox_styleUrl" type="attr" /> <public name="mapbox_apiBaseUrl" type="attr" /> <public name="mapbox_localIdeographFontFamily" type="attr" /> + <public name="mapbox_pixelRatio" type="float" /> <!--Camera--> <public name="mapbox_cameraTargetLng" type="attr" /> diff --git a/platform/android/MapboxGLAndroidSDK/src/main/res/values/attrs.xml b/platform/android/MapboxGLAndroidSDK/src/main/res/values/attrs.xml index 0f7e0563f7..75339e3194 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/res/values/attrs.xml +++ b/platform/android/MapboxGLAndroidSDK/src/main/res/values/attrs.xml @@ -106,6 +106,7 @@ <attr name="mapbox_enableTilePrefetch" format="boolean"/> <attr name="mapbox_enableZMediaOverlay" format="boolean"/> + <attr name="mapbox_pixelRatio" format="float"/> </declare-styleable> diff --git a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/maps/UiSettingsTest.java b/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/maps/UiSettingsTest.java index cfce56e6e9..d1f99ad41e 100644 --- a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/maps/UiSettingsTest.java +++ b/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/maps/UiSettingsTest.java @@ -42,7 +42,7 @@ public class UiSettingsTest { @Before public void beforeTest() { - uiSettings = new UiSettings(projection, focalPointChangeListener, compassView, imageView, logoView); + uiSettings = new UiSettings(projection, focalPointChangeListener, compassView, imageView, logoView, 1); } @Test diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/camera/CameraAnimateTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/camera/CameraAnimateTest.java index 94aec734a4..03f7b29bd0 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/camera/CameraAnimateTest.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/camera/CameraAnimateTest.java @@ -7,10 +7,9 @@ import com.mapbox.mapboxsdk.camera.CameraUpdateFactory; import com.mapbox.mapboxsdk.geometry.LatLng; import com.mapbox.mapboxsdk.geometry.LatLngBounds; import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest; -import com.mapbox.mapboxsdk.testapp.activity.espresso.EspressoTestActivity; +import com.mapbox.mapboxsdk.testapp.activity.espresso.DeviceIndependentTestActivity; import com.mapbox.mapboxsdk.testapp.utils.TestConstants; -import org.junit.Ignore; import org.junit.Test; import static com.mapbox.mapboxsdk.testapp.action.MapboxMapAction.invoke; @@ -20,11 +19,10 @@ public class CameraAnimateTest extends BaseActivityTest { @Override protected Class getActivityClass() { - return EspressoTestActivity.class; + return DeviceIndependentTestActivity.class; } @Test - @Ignore public void testAnimateToCameraPositionTarget() { validateTestSetup(); invoke(mapboxMap, (uiController, mapboxMap) -> { @@ -45,7 +43,6 @@ public class CameraAnimateTest extends BaseActivityTest { } @Test - @Ignore public void testAnimateToCameraPositionTargetZoom() { validateTestSetup(); invoke(mapboxMap, (uiController, mapboxMap) -> { @@ -63,7 +60,6 @@ public class CameraAnimateTest extends BaseActivityTest { } @Test - @Ignore public void testAnimateToCameraPosition() { validateTestSetup(); invoke(mapboxMap, (uiController, mapboxMap) -> { @@ -93,7 +89,6 @@ public class CameraAnimateTest extends BaseActivityTest { } @Test - @Ignore public void testAnimateToBounds() { validateTestSetup(); invoke(mapboxMap, (uiController, mapboxMap) -> { @@ -118,7 +113,6 @@ public class CameraAnimateTest extends BaseActivityTest { } @Test - @Ignore public void testAnimateToMoveBy() { validateTestSetup(); invoke(mapboxMap, (uiController, mapboxMap) -> { @@ -137,7 +131,6 @@ public class CameraAnimateTest extends BaseActivityTest { } @Test - @Ignore public void testAnimateToZoomIn() { validateTestSetup(); invoke(mapboxMap, (uiController, mapboxMap) -> { @@ -151,7 +144,6 @@ public class CameraAnimateTest extends BaseActivityTest { } @Test - @Ignore public void testAnimateToZoomOut() { validateTestSetup(); invoke(mapboxMap, (uiController, mapboxMap) -> { @@ -167,7 +159,6 @@ public class CameraAnimateTest extends BaseActivityTest { } @Test - @Ignore public void testAnimateToZoomBy() { validateTestSetup(); invoke(mapboxMap, (uiController, mapboxMap) -> { @@ -182,7 +173,6 @@ public class CameraAnimateTest extends BaseActivityTest { } @Test - @Ignore public void testAnimateToZoomTo() { validateTestSetup(); invoke(mapboxMap, (uiController, mapboxMap) -> { diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/camera/CameraEaseTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/camera/CameraEaseTest.java index e7c8d6b7bb..1869479d2c 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/camera/CameraEaseTest.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/camera/CameraEaseTest.java @@ -7,10 +7,9 @@ import com.mapbox.mapboxsdk.camera.CameraUpdateFactory; import com.mapbox.mapboxsdk.geometry.LatLng; import com.mapbox.mapboxsdk.geometry.LatLngBounds; import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest; -import com.mapbox.mapboxsdk.testapp.activity.espresso.EspressoTestActivity; +import com.mapbox.mapboxsdk.testapp.activity.espresso.DeviceIndependentTestActivity; import com.mapbox.mapboxsdk.testapp.utils.TestConstants; -import org.junit.Ignore; import org.junit.Test; import static com.mapbox.mapboxsdk.testapp.action.MapboxMapAction.invoke; @@ -20,11 +19,10 @@ public class CameraEaseTest extends BaseActivityTest { @Override protected Class getActivityClass() { - return EspressoTestActivity.class; + return DeviceIndependentTestActivity.class; } @Test - @Ignore public void testEaseToCameraPositionTarget() { validateTestSetup(); invoke(mapboxMap, (uiController, mapboxMap) -> { @@ -45,7 +43,6 @@ public class CameraEaseTest extends BaseActivityTest { } @Test - @Ignore public void testEaseToCameraPositionTargetZoom() { validateTestSetup(); invoke(mapboxMap, (uiController, mapboxMap) -> { @@ -63,7 +60,6 @@ public class CameraEaseTest extends BaseActivityTest { } @Test - @Ignore public void testEaseToCameraPosition() { validateTestSetup(); invoke(mapboxMap, (uiController, mapboxMap) -> { @@ -93,7 +89,6 @@ public class CameraEaseTest extends BaseActivityTest { } @Test - @Ignore public void testEaseToBounds() { validateTestSetup(); invoke(mapboxMap, (uiController, mapboxMap) -> { @@ -118,7 +113,6 @@ public class CameraEaseTest extends BaseActivityTest { } @Test - @Ignore public void testEaseToMoveBy() { validateTestSetup(); invoke(mapboxMap, (uiController, mapboxMap) -> { @@ -137,7 +131,6 @@ public class CameraEaseTest extends BaseActivityTest { } @Test - @Ignore public void testEaseToZoomIn() { validateTestSetup(); invoke(mapboxMap, (uiController, mapboxMap) -> { @@ -151,7 +144,6 @@ public class CameraEaseTest extends BaseActivityTest { } @Test - @Ignore public void testEaseToZoomOut() { validateTestSetup(); invoke(mapboxMap, (uiController, mapboxMap) -> { @@ -167,7 +159,6 @@ public class CameraEaseTest extends BaseActivityTest { } @Test - @Ignore public void testEaseToZoomBy() { validateTestSetup(); invoke(mapboxMap, (uiController, mapboxMap) -> { @@ -182,7 +173,6 @@ public class CameraEaseTest extends BaseActivityTest { } @Test - @Ignore public void testEaseToZoomTo() { validateTestSetup(); invoke(mapboxMap, (uiController, mapboxMap) -> { diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/camera/CameraForTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/camera/CameraForTest.java index b835d7daea..39b2c8d763 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/camera/CameraForTest.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/camera/CameraForTest.java @@ -7,7 +7,7 @@ import com.mapbox.mapboxsdk.camera.CameraPosition; import com.mapbox.mapboxsdk.geometry.LatLng; import com.mapbox.mapboxsdk.geometry.LatLngBounds; import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest; -import com.mapbox.mapboxsdk.testapp.activity.espresso.EspressoTestActivity; +import com.mapbox.mapboxsdk.testapp.activity.espresso.DeviceIndependentTestActivity; import org.junit.Test; import java.util.ArrayList; @@ -24,7 +24,7 @@ public class CameraForTest extends BaseActivityTest { CameraPosition actualPosition = mapboxMap.getCameraForLatLngBounds( LatLngBounds.from(10, 10, -10, -10)); CameraPosition expectedPosition = new CameraPosition.Builder() - .target(new LatLng()).zoom(3.66).tilt(0).bearing(0).build(); + .target(new LatLng()).zoom(4.16).tilt(0).bearing(0).build(); assertEquals("Latitude should match", expectedPosition.target.getLatitude(), actualPosition.target.getLatitude(), 0.00001f); assertEquals("Longitude should match", @@ -42,7 +42,7 @@ public class CameraForTest extends BaseActivityTest { CameraPosition actualPosition = mapboxMap.getCameraForLatLngBounds( LatLngBounds.from(10, 10, -10, -10), new int[] {5, 5, 5, 5}); CameraPosition expectedPosition = new CameraPosition.Builder() - .target(new LatLng()).zoom(3.64).tilt(0).bearing(0).build(); + .target(new LatLng()).zoom(4.13).tilt(0).bearing(0).build(); assertEquals("Latitude should match", expectedPosition.target.getLatitude(), actualPosition.target.getLatitude(), 0.00001f); assertEquals("Longitude should match", @@ -63,7 +63,7 @@ public class CameraForTest extends BaseActivityTest { CameraPosition actualPosition = mapboxMap.getCameraForLatLngBounds( LatLngBounds.from(10, 10, -10, -10), 45, 0); CameraPosition expectedPosition = new CameraPosition.Builder() - .target(new LatLng()).zoom(3.15).tilt(0).bearing(45).build(); + .target(new LatLng()).zoom(3.66).tilt(0).bearing(45).build(); assertEquals("Latitude should match", expectedPosition.target.getLatitude(), actualPosition.target.getLatitude(), 0.00001f); assertEquals("Longitude should match", @@ -84,7 +84,7 @@ public class CameraForTest extends BaseActivityTest { CameraPosition actualPosition = mapboxMap.getCameraForLatLngBounds( LatLngBounds.from(10, 10, -10, -10), 0, 45); CameraPosition expectedPosition = new CameraPosition.Builder() - .target(new LatLng(-0.2423318, 0)).zoom(3.62).tilt(45).bearing(0).build(); + .target(new LatLng(-0.264576975267, 0)).zoom(4.13).tilt(45).bearing(0).build(); assertEquals("Latitude should match", expectedPosition.target.getLatitude(), actualPosition.target.getLatitude(), 0.00001f); assertEquals("Longitude should match", @@ -105,7 +105,7 @@ public class CameraForTest extends BaseActivityTest { CameraPosition actualPosition = mapboxMap.getCameraForLatLngBounds( LatLngBounds.from(10, 10, -10, -10), new int[] {5, 5, 5, 5}, 45, 45); CameraPosition expectedPosition = new CameraPosition.Builder() - .target(new LatLng(-0.3418347, -0.3400988)).zoom(3.13).tilt(45).bearing(45).build(); + .target(new LatLng(-0.3732134634, -0.3713191053)).zoom(3.63).tilt(45).bearing(45).build(); assertEquals("Latitude should match", expectedPosition.target.getLatitude(), actualPosition.target.getLatitude(), 0.00001f); assertEquals("Longitude should match", @@ -126,7 +126,7 @@ public class CameraForTest extends BaseActivityTest { List<List<Point>> polygonDefinition = getPolygonDefinition(); CameraPosition actualPosition = mapboxMap.getCameraForGeometry(Polygon.fromLngLats(polygonDefinition)); CameraPosition expectedPosition = new CameraPosition.Builder() - .target(new LatLng()).zoom(3.66).tilt(0).bearing(0).build(); + .target(new LatLng()).zoom(4.16).tilt(0).bearing(0).build(); assertEquals("Latitude should match", expectedPosition.target.getLatitude(), actualPosition.target.getLatitude(), 0.00001f); assertEquals("Longitude should match", @@ -161,7 +161,7 @@ public class CameraForTest extends BaseActivityTest { CameraPosition actualPosition = mapboxMap.getCameraForGeometry(Polygon.fromLngLats(polygonDefinition), new int[] {5, 5, 5, 5}); CameraPosition expectedPosition = new CameraPosition.Builder() - .target(new LatLng()).zoom(3.64).tilt(0).bearing(0).build(); + .target(new LatLng()).zoom(4.13).tilt(0).bearing(0).build(); assertEquals("Latitude should match", expectedPosition.target.getLatitude(), actualPosition.target.getLatitude(), 0.00001f); assertEquals("Longitude should match", @@ -182,7 +182,7 @@ public class CameraForTest extends BaseActivityTest { List<List<Point>> polygonDefinition = getPolygonDefinition(); CameraPosition actualPosition = mapboxMap.getCameraForGeometry(Polygon.fromLngLats(polygonDefinition), 45, 0); CameraPosition expectedPosition = new CameraPosition.Builder() - .target(new LatLng()).zoom(3.15).tilt(0).bearing(45).build(); + .target(new LatLng()).zoom(3.66).tilt(0).bearing(45).build(); assertEquals("Latitude should match", expectedPosition.target.getLatitude(), actualPosition.target.getLatitude(), 0.00001f); assertEquals("Longitude should match", @@ -203,7 +203,7 @@ public class CameraForTest extends BaseActivityTest { List<List<Point>> polygonDefinition = getPolygonDefinition(); CameraPosition actualPosition = mapboxMap.getCameraForGeometry(Polygon.fromLngLats(polygonDefinition), 0, 45); CameraPosition expectedPosition = new CameraPosition.Builder() - .target(new LatLng(-0.2423318, 0)).zoom(3.62).tilt(45).bearing(0).build(); + .target(new LatLng(-0.2645769752, 0)).zoom(4.13).tilt(45).bearing(0).build(); assertEquals("Latitude should match", expectedPosition.target.getLatitude(), actualPosition.target.getLatitude(), 0.00001f); assertEquals("Longitude should match", @@ -225,7 +225,7 @@ public class CameraForTest extends BaseActivityTest { CameraPosition actualPosition = mapboxMap.getCameraForGeometry(Polygon.fromLngLats(polygonDefinition), new int[] {5, 5, 5, 5}, 45, 45); CameraPosition expectedPosition = new CameraPosition.Builder() - .target(new LatLng(-0.3418347, -0.3400988)).zoom(3.13).tilt(45).bearing(45).build(); + .target(new LatLng(-0.373213463, -0.37131910534)).zoom(3.63).tilt(45).bearing(45).build(); assertEquals("Latitude should match", expectedPosition.target.getLatitude(), actualPosition.target.getLatitude(), 0.00001f); assertEquals("Longitude should match", @@ -247,7 +247,7 @@ public class CameraForTest extends BaseActivityTest { CameraPosition actualPosition = mapboxMap.getCameraForGeometry(Polygon.fromLngLats(polygonDefinition), 45, new int[] {5, 5, 5, 5}); CameraPosition expectedPosition = new CameraPosition.Builder() - .target(new LatLng()).zoom(3.13).tilt(0).bearing(45).build(); + .target(new LatLng()).zoom(3.63).tilt(0).bearing(45).build(); assertEquals("Latitude should match", expectedPosition.target.getLatitude(), actualPosition.target.getLatitude(), 0.00001f); assertEquals("Longitude should match", @@ -263,6 +263,6 @@ public class CameraForTest extends BaseActivityTest { @Override protected Class getActivityClass() { - return EspressoTestActivity.class; + return DeviceIndependentTestActivity.class; } } diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/camera/CameraMoveTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/camera/CameraMoveTest.java index 37b9171a95..6c483f64da 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/camera/CameraMoveTest.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/camera/CameraMoveTest.java @@ -8,10 +8,9 @@ import com.mapbox.mapboxsdk.camera.CameraUpdateFactory; import com.mapbox.mapboxsdk.geometry.LatLng; import com.mapbox.mapboxsdk.geometry.LatLngBounds; import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest; -import com.mapbox.mapboxsdk.testapp.activity.espresso.EspressoTestActivity; +import com.mapbox.mapboxsdk.testapp.activity.espresso.DeviceIndependentTestActivity; import com.mapbox.mapboxsdk.testapp.utils.TestConstants; -import org.junit.Ignore; import org.junit.Test; import static com.mapbox.mapboxsdk.testapp.action.MapboxMapAction.invoke; @@ -21,11 +20,10 @@ public class CameraMoveTest extends BaseActivityTest { @Override protected Class getActivityClass() { - return EspressoTestActivity.class; + return DeviceIndependentTestActivity.class; } @Test - @Ignore public void testMoveToCameraPositionTarget() { validateTestSetup(); invoke(mapboxMap, (uiController, mapboxMap) -> { @@ -46,7 +44,6 @@ public class CameraMoveTest extends BaseActivityTest { } @Test - @Ignore public void testMoveToCameraPositionTargetZoom() { validateTestSetup(); invoke(mapboxMap, (uiController, mapboxMap) -> { @@ -64,7 +61,6 @@ public class CameraMoveTest extends BaseActivityTest { } @Test - @Ignore public void testMoveToCameraPosition() { validateTestSetup(); invoke(mapboxMap, (uiController, mapboxMap) -> { @@ -94,7 +90,6 @@ public class CameraMoveTest extends BaseActivityTest { } @Test - @Ignore public void testMoveToBounds() { validateTestSetup(); invoke(mapboxMap, (uiController, mapboxMap) -> { @@ -119,7 +114,6 @@ public class CameraMoveTest extends BaseActivityTest { } @Test - @Ignore public void testMoveToMoveBy() { validateTestSetup(); invoke(mapboxMap, (uiController, mapboxMap) -> { @@ -138,7 +132,6 @@ public class CameraMoveTest extends BaseActivityTest { } @Test - @Ignore public void testMoveToZoomIn() { validateTestSetup(); invoke(mapboxMap, (uiController, mapboxMap) -> { @@ -152,7 +145,6 @@ public class CameraMoveTest extends BaseActivityTest { } @Test - @Ignore public void testMoveToZoomOut() { validateTestSetup(); invoke(mapboxMap, (uiController, mapboxMap) -> { @@ -168,7 +160,6 @@ public class CameraMoveTest extends BaseActivityTest { } @Test - @Ignore public void testMoveToZoomBy() { validateTestSetup(); invoke(mapboxMap, (uiController, mapboxMap) -> { @@ -183,7 +174,6 @@ public class CameraMoveTest extends BaseActivityTest { } @Test - @Ignore public void testMoveToZoomTo() { validateTestSetup(); invoke(mapboxMap, (uiController, mapboxMap) -> { diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/utils/TestConstants.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/utils/TestConstants.java index 965f5d1443..28bb8fe21d 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/utils/TestConstants.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/utils/TestConstants.java @@ -6,11 +6,11 @@ public class TestConstants { public static final long ANIMATION_TEST_TIME = MapboxConstants.ANIMATION_DURATION * 2; - 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.3; + public static final double LAT_LNG_DELTA_LARGE = 0.01; + public static final double LAT_LNG_DELTA = 0.001; + public static final double BEARING_DELTA = 0.01; + public static final double TILT_DELTA = 0.01; + public static final double ZOOM_DELTA = 0.01; public static final String TEXT_MARKER_TEXT = "Text"; public static final String TEXT_MARKER_TITLE = "Marker"; diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/AndroidManifest.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/AndroidManifest.xml index 26ad0ebcfe..a6c0732ee9 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/AndroidManifest.xml +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/AndroidManifest.xml @@ -789,6 +789,9 @@ android:name=".activity.espresso.EspressoTestActivity" android:screenOrientation="portrait" /> <activity + android:name=".activity.espresso.DeviceIndependentTestActivity" + android:screenOrientation="portrait" /> + <activity android:name=".activity.style.FillExtrusionStyleTestActivity" android:screenOrientation="portrait" /> <activity diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/espresso/DeviceIndependentTestActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/espresso/DeviceIndependentTestActivity.java new file mode 100644 index 0000000000..c1bc079c71 --- /dev/null +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/espresso/DeviceIndependentTestActivity.java @@ -0,0 +1,76 @@ +package com.mapbox.mapboxsdk.testapp.activity.espresso; + +import android.os.Bundle; +import android.support.v7.app.AppCompatActivity; +import com.mapbox.mapboxsdk.maps.MapView; +import com.mapbox.mapboxsdk.maps.MapboxMap; +import com.mapbox.mapboxsdk.maps.OnMapReadyCallback; +import com.mapbox.mapboxsdk.testapp.R; + +public class DeviceIndependentTestActivity extends AppCompatActivity implements OnMapReadyCallback { + + public MapView mapView; + protected MapboxMap mapboxMap; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_camera_test); + + // Initialize map as normal + mapView = findViewById(R.id.mapView); + mapView.onCreate(savedInstanceState); + mapView.getMapAsync(this); + } + + @Override + public void onMapReady(MapboxMap map) { + mapboxMap = map; + } + + public MapboxMap getMapboxMap() { + return mapboxMap; + } + + @Override + public void onResume() { + super.onResume(); + mapView.onResume(); + } + + @Override + protected void onStart() { + super.onStart(); + mapView.onStart(); + } + + @Override + public void onPause() { + super.onPause(); + mapView.onPause(); + } + + @Override + protected void onStop() { + super.onStop(); + mapView.onStop(); + } + + @Override + protected void onSaveInstanceState(Bundle outState) { + super.onSaveInstanceState(outState); + mapView.onSaveInstanceState(outState); + } + + @Override + protected void onDestroy() { + super.onDestroy(); + mapView.onDestroy(); + } + + @Override + public void onLowMemory() { + super.onLowMemory(); + mapView.onLowMemory(); + } +} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/espresso/EspressoTestActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/espresso/EspressoTestActivity.java index ee9f20dceb..7ad9f761ff 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/espresso/EspressoTestActivity.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/espresso/EspressoTestActivity.java @@ -19,7 +19,7 @@ public class EspressoTestActivity extends AppCompatActivity implements OnMapRead @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - setContentView(R.layout.activity_camera_test); + setContentView(R.layout.activity_espresso_test); // Initialize map as normal mapView = (MapView) findViewById(R.id.mapView); diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_camera_test.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_camera_test.xml index 05affaf081..0aa26cf37a 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_camera_test.xml +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_camera_test.xml @@ -1,16 +1,16 @@ <?xml version="1.0" encoding="utf-8"?> -<RelativeLayout - xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:app="http://schemas.android.com/apk/res-auto" - android:layout_width="match_parent" - android:layout_height="match_parent"> +<FrameLayout + xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:app="http://schemas.android.com/apk/res-auto" + android:layout_width="match_parent" + android:layout_height="match_parent"> - <!-- TODO remove zoom #6747--> <com.mapbox.mapboxsdk.maps.MapView - android:id="@id/mapView" - android:layout_width="match_parent" - android:layout_height="match_parent" - android:layout_below="@id/toolbar" - app:mapbox_cameraZoom="1"/> + android:layout_gravity="center" + android:id="@id/mapView" + android:layout_width="512px" + android:layout_height="512px" + app:mapbox_pixelRatio="1" + app:mapbox_cameraZoom="1"/> -</RelativeLayout> +</FrameLayout> diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_espresso_test.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_espresso_test.xml new file mode 100644 index 0000000000..e4b66c2981 --- /dev/null +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_espresso_test.xml @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="utf-8"?> +<RelativeLayout + xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:app="http://schemas.android.com/apk/res-auto" + android:layout_width="match_parent" + android:layout_height="match_parent"> + + <com.mapbox.mapboxsdk.maps.MapView + android:id="@id/mapView" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:layout_below="@id/toolbar" + app:mapbox_cameraZoom="1"/> + +</RelativeLayout> |