diff options
Diffstat (limited to 'platform')
143 files changed, 10674 insertions, 7305 deletions
diff --git a/platform/android/CHANGELOG.md b/platform/android/CHANGELOG.md index d8a58fe140..fa54b1e3ed 100644 --- a/platform/android/CHANGELOG.md +++ b/platform/android/CHANGELOG.md @@ -2,12 +2,46 @@ Mapbox welcomes participation and contributions from everyone. If you'd like to do so please see the [`Contributing Guide`](https://github.com/mapbox/mapbox-gl-native/blob/master/CONTRIBUTING.md) first to get started. -## master +## 5.2.0 - TBA + * Add support for ImageSource [#9110](https://github.com/mapbox/mapbox-gl-native/pull/9110) -## 5.1.0 - TBA +## 5.1.0 - June 30, 2017 + +* Update to MAS 2.1.3 [#9402](https://github.com/mapbox/mapbox-gl-native/pull/9402) +* Downgrade LOST to v1.1.1 [#9394](https://github.com/mapbox/mapbox-gl-native/pull/9394) +* OnCameraIdle hook into quickzoom gesture [#9339](https://github.com/mapbox/mapbox-gl-native/pull/9339) +* LatLngBounds conversion regression, add test [#9324](https://github.com/mapbox/mapbox-gl-native/pull/9324) + +## 5.1.0-beta.5 - June 21, 2017 + +* Update MAS dependency to 2.1.2 [#9311](https://github.com/mapbox/mapbox-gl-native/pull/9311) +* Update LOST dependency to 3.0.1 [#9302](https://github.com/mapbox/mapbox-gl-native/pull/9302) +* Fix Pulse example Parcelable creator [#9283](https://github.com/mapbox/mapbox-gl-native/pull/9283) +* Custom marker view anchoring [#9282](https://github.com/mapbox/mapbox-gl-native/pull/9282) +* Update Activity test generation [#9276](https://github.com/mapbox/mapbox-gl-native/pull/9276) +* Validate camera position before transforming [#9275](https://github.com/mapbox/mapbox-gl-native/pull/9275) +* Revisit javadoc [#9266](https://github.com/mapbox/mapbox-gl-native/pull/9266) +* Build with NDK 15 [#9263](https://github.com/mapbox/mapbox-gl-native/pull/9263) +* Snapshot with view content [#9263](https://github.com/mapbox/mapbox-gl-native/pull/9263) +* Update source changed javadoc [#9243](https://github.com/mapbox/mapbox-gl-native/pull/9243) +* Run tests on UI-thread [#9198](https://github.com/mapbox/mapbox-gl-native/pull/9198) +* Fix trackball on worker thread [#9305](https://github.com/mapbox/mapbox-gl-native/pull/9305) + +## 5.1.0-beta.4 - June 9, 2017 + +* Option to disable location change animation [#9210](https://github.com/mapbox/mapbox-gl-native/pull/9210) +* Invalidating MyLocationView bearing when not following [#9212](https://github.com/mapbox/mapbox-gl-native/pull/9212) +* Remove upgrade runtime exceptions [#9191](https://github.com/mapbox/mapbox-gl-native/pull/9191) +* Check source usage before removal [#9129](https://github.com/mapbox/mapbox-gl-native/pull/9129) * Fix tracking mode + camera race condition [#9133](https://github.com/mapbox/mapbox-gl-native/pull/9133) * Harden orientation changes [#9128](https://github.com/mapbox/mapbox-gl-native/pull/9128) +* Infinite location animation updates [#9194](https://github.com/mapbox/mapbox-gl-native/pull/9194) +* Invoke callback with valid fling gestures [#9192](https://github.com/mapbox/mapbox-gl-native/pull/9192) +* Keep location tracking after screen rotation [#9187](https://github.com/mapbox/mapbox-gl-native/pull/9187) +* Update components with camera values when animating [#9174](https://github.com/mapbox/mapbox-gl-native/pull/9174) +* Validate if gestures should execute [#9173](https://github.com/mapbox/mapbox-gl-native/pull/9173) +* Custom location source and LOST integration [#9142](https://github.com/mapbox/mapbox-gl-native/pull/9142) ## 5.1.0-beta.3 - May 26, 2017 diff --git a/platform/android/MapboxGLAndroidSDK/build.gradle b/platform/android/MapboxGLAndroidSDK/build.gradle index adbc7cad7f..8b92fa1af2 100644 --- a/platform/android/MapboxGLAndroidSDK/build.gradle +++ b/platform/android/MapboxGLAndroidSDK/build.gradle @@ -6,7 +6,9 @@ dependencies { compile rootProject.ext.dep.supportDesign compile rootProject.ext.dep.timber compile rootProject.ext.dep.okhttp3 - compile rootProject.ext.dep.lost + compile(rootProject.ext.dep.lost) { + exclude group: 'com.google.guava' + } testCompile rootProject.ext.dep.junit testCompile rootProject.ext.dep.mockito diff --git a/platform/android/MapboxGLAndroidSDK/gradle.properties b/platform/android/MapboxGLAndroidSDK/gradle.properties index 9f555da5f8..078fdbc801 100644 --- a/platform/android/MapboxGLAndroidSDK/gradle.properties +++ b/platform/android/MapboxGLAndroidSDK/gradle.properties @@ -1,5 +1,5 @@ GROUP=com.mapbox.mapboxsdk -VERSION_NAME=5.1.0-SNAPSHOT +VERSION_NAME=5.2.0-SNAPSHOT POM_DESCRIPTION=Mapbox GL Android SDK POM_URL=https://github.com/mapbox/mapbox-gl-native diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/Mapbox.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/Mapbox.java index bc1049d146..3af7921596 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/Mapbox.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/Mapbox.java @@ -1,6 +1,5 @@ package com.mapbox.mapboxsdk; -import android.app.Application; import android.content.Context; import android.net.ConnectivityManager; import android.net.NetworkInfo; @@ -17,10 +16,10 @@ import com.mapbox.services.android.telemetry.location.LocationEngine; import com.mapbox.services.android.telemetry.location.LocationEnginePriority; /** - * The entry point of the Mapbox Android SDK. + * The entry point to initialize the Mapbox Android SDK. * <p> * Obtain a reference by calling {@link #getInstance(Context, String)}. Usually this class is configured in - * {@link Application#onCreate()} and is responsible for the active access token, application context, and + * Application#onCreate() and is responsible for the active access token, application context, and * connectivity state. * </p> */ @@ -31,6 +30,7 @@ public final class Mapbox { private Context context; private String accessToken; private Boolean connected; + private LocationSource locationSource; /** * Get an instance of Mapbox. @@ -46,8 +46,8 @@ public final class Mapbox { public static synchronized Mapbox getInstance(@NonNull Context context, @NonNull String accessToken) { if (INSTANCE == null) { Context appContext = context.getApplicationContext(); - INSTANCE = new Mapbox(appContext, accessToken); - LocationEngine locationEngine = LocationSource.getLocationEngine(appContext); + INSTANCE = new Mapbox(appContext, accessToken, new LocationSource(appContext)); + LocationEngine locationEngine = new LocationSource(appContext); locationEngine.setPriority(LocationEnginePriority.NO_POWER); MapboxTelemetry.getInstance().initialize( appContext, accessToken, BuildConfig.MAPBOX_EVENTS_USER_AGENT, locationEngine); @@ -56,9 +56,10 @@ public final class Mapbox { return INSTANCE; } - Mapbox(@NonNull Context context, @NonNull String accessToken) { + Mapbox(@NonNull Context context, @NonNull String accessToken, LocationSource locationSource) { this.context = context; this.accessToken = accessToken; + this.locationSource = locationSource; } /** @@ -96,6 +97,8 @@ public final class Mapbox { /** * Application context + * + * @return the application context */ public static Context getApplicationContext() { return INSTANCE.context; @@ -129,4 +132,8 @@ public final class Mapbox { NetworkInfo activeNetwork = cm.getActiveNetworkInfo(); return (activeNetwork != null && activeNetwork.isConnected()); } + + public static LocationSource getLocationSource() { + return INSTANCE.locationSource; + } } diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/BubbleLayout.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/BubbleLayout.java index 07e038c08c..c58cc310a8 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/BubbleLayout.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/BubbleLayout.java @@ -27,14 +27,32 @@ public class BubbleLayout extends LinearLayout { private float strokeWidth; private int strokeColor; + /** + * Creates an instance of bubble layout. + * + * @param context The context used to inflate this bubble layout + */ public BubbleLayout(Context context) { this(context, null, 0); } + /** + * Creates an instance of bubble layout. + * + * @param context The context used to inflate this bubble layout + * @param attrs The attribute set to initialise this bubble layout from + */ public BubbleLayout(Context context, AttributeSet attrs) { this(context, attrs, 0); } + /** + * Creates an instance of bubble layout. + * + * @param context The context used to inflate this bubble layout + * @param attrs The attribute set to initialise this bubble layout from + * @param defStyleAttr The default style to apply this bubble layout with + */ public BubbleLayout(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); @@ -78,10 +96,21 @@ public class BubbleLayout extends LinearLayout { return dp * (metrics.densityDpi / DisplayMetrics.DENSITY_DEFAULT); } + /** + * Get the arrow direction. + * + * @return the arrow direction + */ public ArrowDirection getArrowDirection() { return arrowDirection; } + /** + * Set the arrow direction. + * + * @param arrowDirection The direction of the arrow + * @return this + */ public BubbleLayout setArrowDirection(ArrowDirection arrowDirection) { resetPadding(); this.arrowDirection = arrowDirection; @@ -89,10 +118,21 @@ public class BubbleLayout extends LinearLayout { return this; } + /** + * Get the arrow width. + * + * @return the width of the arrow + */ public float getArrowWidth() { return arrowWidth; } + /** + * Set the arrow width. + * + * @param arrowWidth The width of the arrow + * @return this + */ public BubbleLayout setArrowWidth(float arrowWidth) { resetPadding(); this.arrowWidth = arrowWidth; @@ -100,10 +140,21 @@ public class BubbleLayout extends LinearLayout { return this; } + /** + * Get the arrow height + * + * @return the height of the arrow + */ public float getArrowHeight() { return arrowHeight; } + /** + * Set the arrow height. + * + * @param arrowHeight The height of the arrow + * @return this + */ public BubbleLayout setArrowHeight(float arrowHeight) { resetPadding(); this.arrowHeight = arrowHeight; @@ -111,10 +162,21 @@ public class BubbleLayout extends LinearLayout { return this; } + /** + * Get the arrow position. + * + * @return the arrow position + */ public float getArrowPosition() { return arrowPosition; } + /** + * Get the arrow position. + * + * @param arrowPosition The arrow position + * @return this + */ public BubbleLayout setArrowPosition(float arrowPosition) { resetPadding(); this.arrowPosition = arrowPosition; @@ -122,30 +184,63 @@ public class BubbleLayout extends LinearLayout { return this; } + /** + * Get the corner radius + * + * @return the corner radius + */ public float getCornersRadius() { return cornersRadius; } + /** + * Set the corner radius + * + * @param cornersRadius The corner radius + * @return this + */ public BubbleLayout setCornersRadius(float cornersRadius) { this.cornersRadius = cornersRadius; requestLayout(); return this; } + /** + * Get the bubble color. + * + * @return the bubble color + */ public int getBubbleColor() { return bubbleColor; } + /** + * Set the bubble color. + * + * @param bubbleColor The buble color + * @return this + */ public BubbleLayout setBubbleColor(int bubbleColor) { this.bubbleColor = bubbleColor; requestLayout(); return this; } + /** + * Get stroke width. + * + * @return the stroke width + */ public float getStrokeWidth() { return strokeWidth; } + /** + * Set the stroke width. + * + * @param strokeWidth The stroke width + * @return this + */ public BubbleLayout setStrokeWidth(float strokeWidth) { resetPadding(); this.strokeWidth = strokeWidth; @@ -153,10 +248,21 @@ public class BubbleLayout extends LinearLayout { return this; } + /** + * Get the stroke color. + * + * @return the stroke color + */ public int getStrokeColor() { return strokeColor; } + /** + * Set the stroke color. + * + * @param strokeColor The stroke color + * @return this + */ public BubbleLayout setStrokeColor(int strokeColor) { this.strokeColor = strokeColor; requestLayout(); diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/IconFactory.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/IconFactory.java index 57aa512401..f9ca9bf4cc 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/IconFactory.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/IconFactory.java @@ -23,7 +23,7 @@ import java.io.InputStream; /** * Factory for creating Icons from bitmap images. * <p> - * {@link Icon} is used to display bitmaps on top of the map using {@link Marker} and {@link MarkerView}. + * icon is used to display bitmaps on top of the map using {@link Marker} and {@link MarkerView}. * </p> * * @see Icon @@ -42,6 +42,12 @@ public final class IconFactory { private int nextId = 0; + /** + * Get a single instance of IconFactory. + * + * @param context the context to derive the application context from + * @return the single instance of IconFactory + */ public static synchronized IconFactory getInstance(@NonNull Context context) { if (instance == null) { instance = new IconFactory(context.getApplicationContext()); @@ -71,10 +77,10 @@ public final class IconFactory { } /** - * Creates an {@link Icon} from a given Bitmap image. + * Creates an icon from a given Bitmap image. * * @param bitmap image used for creating the Icon. - * @return The {@link Icon} using the given Bitmap image. + * @return The icon using the given Bitmap image. */ public Icon fromBitmap(@NonNull Bitmap bitmap) { if (nextId < 0) { @@ -85,10 +91,10 @@ public final class IconFactory { } /** - * Create an {@link Icon} using the resource ID of a Bitmap image. + * Creates an icon using the resource ID of a Bitmap image. * * @param resourceId The resource ID of a Bitmap image. - * @return The {@link Icon} that was loaded from the asset or {@code null} if failed to load. + * @return The icon that was loaded from the asset or {@code null} if failed to load. */ public Icon fromResource(@DrawableRes int resourceId) { Drawable drawable = ContextCompat.getDrawable(context, resourceId); @@ -101,9 +107,9 @@ public final class IconFactory { } /** - * Provides an {@link Icon} using the default marker icon used for {@link Marker}. + * Provides an icon using the default marker icon used for {@link Marker}. * - * @return An {@link Icon} with the default {@link Marker} icon. + * @return An icon with the default {@link Marker} icon. */ public Icon defaultMarker() { if (defaultMarker == null) { @@ -113,9 +119,9 @@ public final class IconFactory { } /** - * Provides an {@link Icon} using the default marker icon used for {@link MarkerView}. + * Provides an icon using the default marker icon used for {@link MarkerView}. * - * @return An {@link Icon} with the default {@link MarkerView} icon. + * @return An icon with the default {@link MarkerView} icon. */ public Icon defaultMarkerView() { if (defaultMarkerView == null) { @@ -130,10 +136,10 @@ public final class IconFactory { } /** - * Creates an {@link Icon} using the name of a Bitmap image in the assets directory. + * Creates an Icon using the name of a Bitmap image in the assets directory. * * @param assetName The name of a Bitmap image in the assets directory. - * @return The {@link Icon} that was loaded from the asset or {@code null} if failed to load. + * @return The Icon that was loaded from the asset or null if failed to load. */ public Icon fromAsset(@NonNull String assetName) { InputStream is; @@ -146,11 +152,10 @@ public final class IconFactory { } /** - * Creates an {@link Icon} using the absolute file path of a Bitmap image. + * Creates an Icon using the absolute file path of a Bitmap image. * * @param absolutePath The absolute path of the Bitmap image. - * @return The {@link Icon} that was loaded from the absolute path or {@code null} if failed to - * load. + * @return The Icon that was loaded from the absolute path or null if failed to load. */ public Icon fromPath(@NonNull String absolutePath) { Bitmap bitmap = BitmapFactory.decodeFile(absolutePath, options); @@ -158,11 +163,11 @@ public final class IconFactory { } /** - * Create an {@link Icon} using the name of a Bitmap image file located in the internal storage. - * In particular, this calls {@link Context#openFileInput(String)}. + * Create an Icon using the name of a Bitmap image file located in the internal storage. + * In particular, this calls Context#openFileInput(String). * * @param fileName The name of the Bitmap image file. - * @return The {@link Icon} that was loaded from the asset or {@code null} if failed to load. + * @return The Icon that was loaded from the asset or null if failed to load. * @see <a href="https://developer.android.com/guide/topics/data/data-storage.html#filesInternal"> * Using the Internal Storage</a> */ @@ -177,12 +182,11 @@ public final class IconFactory { } /** - * Create an {@link Icon} using a previously created icon identifier along with a provided - * Bitmap. + * Create an Icon using a previously created icon identifier along with a provided Bitmap. * - * @param iconId The {@link Icon} identifier you'd like to recreate. + * @param iconId The Icon identifier you'd like to recreate. * @param bitmap a Bitmap used to replace the current one. - * @return The {@link Icon} using the new Bitmap. + * @return The Icon using the new Bitmap. */ public static Icon recreate(@NonNull String iconId, @NonNull Bitmap bitmap) { return new Icon(iconId, bitmap); diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/MarkerViewManager.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/MarkerViewManager.java index bb51f3bfc2..dce6f6b277 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/MarkerViewManager.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/MarkerViewManager.java @@ -10,6 +10,7 @@ import android.support.v4.util.LongSparseArray; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.view.ViewTreeObserver; import android.widget.ImageView; import com.mapbox.mapboxsdk.R; @@ -33,6 +34,15 @@ import java.util.Map; public class MarkerViewManager implements MapView.OnMapChangedListener { private final ViewGroup markerViewContainer; + private final ViewTreeObserver.OnPreDrawListener markerViewPreDrawObserver = + new ViewTreeObserver.OnPreDrawListener() { + @Override + public boolean onPreDraw() { + invalidateViewMarkersInVisibleRegion(); + markerViewContainer.getViewTreeObserver().removeOnPreDrawListener(markerViewPreDrawObserver); + return false; + } + }; private final Map<MarkerView, View> markerViewMap = new HashMap<>(); private final LongSparseArray<OnMarkerViewAddedListener> markerViewAddedListenerMap = new LongSparseArray<>(); private final List<MapboxMap.MarkerViewAdapter> markerViewAdapters = new ArrayList<>(); @@ -125,6 +135,12 @@ public class MarkerViewManager implements MapView.OnMapChangedListener { } } + /** + * Set the rotation of a MarkerView to a given rotation value. + * + * @param marker The MarkerView to change its rotation value + * @param rotation The rotation value + */ public void setRotation(@NonNull MarkerView marker, float rotation) { View convertView = markerViewMap.get(marker); if (convertView != null) { @@ -180,14 +196,16 @@ public class MarkerViewManager implements MapView.OnMapChangedListener { PointF point = mapboxMap.getProjection().toScreenLocation(marker.getPosition()); if (marker.getOffsetX() == MapboxConstants.UNMEASURED) { // ensure view is measured first - if (marker.getWidth() == 0) { - convertView.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED); - if (convertView.getMeasuredWidth() != 0) { - marker.setWidth(convertView.getMeasuredWidth()); - marker.setHeight(convertView.getMeasuredHeight()); - } + // #6805 invalidate marker views to ensure convertView width and height + // values are properly measured and up to date + if (marker.getWidth() == 0 && marker.isVisible()) { + convertView.getViewTreeObserver().addOnPreDrawListener(markerViewPreDrawObserver); } } + + marker.setWidth(convertView.getWidth()); + marker.setHeight(convertView.getHeight()); + if (marker.getWidth() != 0) { int x = (int) (marker.getAnchorU() * marker.getWidth()); int y = (int) (marker.getAnchorV() * marker.getHeight()); @@ -532,10 +550,11 @@ public class MarkerViewManager implements MapView.OnMapChangedListener { } /** - * When the provided {@link MarkerView} is clicked on by a user, we check if a custom click - * event has been created and if not, display a {@link InfoWindow}. + * When the provided MarkerView is clicked on by a user, we check if a custom click + * event has been created and if not, display a InfoWindow. * - * @param markerView that the click event occurred. + * @param markerView that the click event occurred + * @return true if the marker view click has been handled, false if not */ public boolean onClickMarkerView(MarkerView markerView) { boolean clickHandled = false; @@ -560,9 +579,9 @@ public class MarkerViewManager implements MapView.OnMapChangedListener { } /** - * Handles the {@link MarkerView}'s info window offset. + * Handles the MarkerView info window offset. * - * @param marker that we are ensuring info window offset. + * @param marker that we are ensuring info window offset */ public void ensureInfoWindowOffset(MarkerView marker) { View view = null; @@ -612,7 +631,7 @@ public class MarkerViewManager implements MapView.OnMapChangedListener { } /** - * Default MarkerViewAdapter used for base class of {@link MarkerView} to adapt a MarkerView to + * Default MarkerViewAdapter used for base class of MarkerView to adapt a MarkerView to * an ImageView. */ private static class ImageMarkerViewAdapter extends MapboxMap.MarkerViewAdapter<MarkerView> { diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/camera/CameraPosition.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/camera/CameraPosition.java index 66c261f1d0..c2f19072db 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/camera/CameraPosition.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/camera/CameraPosition.java @@ -3,6 +3,7 @@ package com.mapbox.mapboxsdk.camera; import android.content.res.TypedArray; import android.os.Parcel; import android.os.Parcelable; +import android.support.annotation.FloatRange; import com.mapbox.mapboxsdk.R; import com.mapbox.mapboxsdk.constants.MapboxConstants; @@ -166,14 +167,14 @@ public final class CameraPosition implements Parcelable { private double zoom = -1; /** - * Creates an empty builder. + * Create an empty builder. */ public Builder() { super(); } /** - * Create Builder with an existing CameraPosition data. + * Create a builder with an existing CameraPosition data. * * @param previous Existing CameraPosition values to use */ @@ -188,7 +189,7 @@ public final class CameraPosition implements Parcelable { } /** - * Create Builder with an existing CameraPosition data. + * Create a builder with an existing CameraPosition data. * * @param typedArray TypedArray containing attribute values */ @@ -205,7 +206,7 @@ public final class CameraPosition implements Parcelable { } /** - * Create Builder from an existing CameraPositionUpdate update. + * Create a builder from an existing CameraPositionUpdate update. * * @param update Update containing camera options */ @@ -220,7 +221,7 @@ public final class CameraPosition implements Parcelable { } /** - * Create Builder from an existing CameraPositionUpdate update. + * Create builder from an existing CameraPositionUpdate update. * * @param update Update containing camera options */ @@ -235,7 +236,7 @@ public final class CameraPosition implements Parcelable { * Sets the direction that the camera is pointing in, in degrees clockwise from north. * * @param bearing Bearing - * @return Builder + * @return this */ public Builder bearing(double bearing) { double direction = bearing; @@ -252,19 +253,10 @@ public final class CameraPosition implements Parcelable { } /** - * Builds a CameraPosition. + * Sets the location where the camera is pointing at. * - * @return CameraPosition - */ - public CameraPosition build() { - return new CameraPosition(target, zoom, tilt, bearing); - } - - /** - * Sets the location that the camera is pointing at. - * - * @param location Location - * @return Builder + * @param location target of the camera + * @return this */ public Builder target(LatLng location) { this.target = location; @@ -272,28 +264,42 @@ public final class CameraPosition implements Parcelable { } /** - * Set the tilt in degrees + * Set the tilt of the camera in degrees * <p> - * value is clamped to 0 and 60. + * value is clamped to {@link MapboxConstants#MINIMUM_TILT} and {@link MapboxConstants#MAXIMUM_TILT}. * </p> * - * @param tilt Tilt value - * @return Builder + * @param tilt Tilt value of the camera + * @return this */ - public Builder tilt(double tilt) { + public Builder tilt(@FloatRange(from = MapboxConstants.MINIMUM_TILT, + to = MapboxConstants.MAXIMUM_TILT) double tilt) { this.tilt = MathUtils.clamp(tilt, MapboxConstants.MINIMUM_TILT, MapboxConstants.MAXIMUM_TILT); return this; } /** - * Set the zoom + * Set the zoom of the camera + * <p> + * Zoom ranges from {@link MapboxConstants#MINIMUM_ZOOM} to {@link MapboxConstants#MAXIMUM_ZOOM} + * </p> * - * @param zoom Zoom value - * @return Builder + * @param zoom Zoom value of the camera + * @return this */ - public Builder zoom(double zoom) { + public Builder zoom(@FloatRange(from = MapboxConstants.MINIMUM_ZOOM, + to = MapboxConstants.MAXIMUM_ZOOM) double zoom) { this.zoom = zoom; return this; } + + /** + * Builds the CameraPosition. + * + * @return CameraPosition + */ + public CameraPosition build() { + return new CameraPosition(target, zoom, tilt, bearing); + } } } diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/camera/CameraUpdate.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/camera/CameraUpdate.java index 7e0dbf08fb..31f13cbcff 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/camera/CameraUpdate.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/camera/CameraUpdate.java @@ -1,14 +1,22 @@ package com.mapbox.mapboxsdk.camera; import android.support.annotation.NonNull; +import android.support.annotation.Nullable; import com.mapbox.mapboxsdk.maps.MapboxMap; /** - * Interface definition for camera position changes. + * Interface definition for camera updates. */ public interface CameraUpdate { + /** + * Get the camera position from the camera update. + * + * @param mapboxMap Map object to build the position from + * @return the camera position from the implementing camera update + */ + @Nullable CameraPosition getCameraPosition(@NonNull MapboxMap mapboxMap); } diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/camera/CameraUpdateFactory.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/camera/CameraUpdateFactory.java index 8e1411e273..50e33f4f9f 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/camera/CameraUpdateFactory.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/camera/CameraUpdateFactory.java @@ -42,7 +42,7 @@ public final class CameraUpdateFactory { } /** - * Returns a {@link CameraUpdate} that transforms the camera such that the specified + * Returns a CameraUpdate that transforms the camera such that the specified * latitude/longitude bounds are centered on screen at the greatest possible zoom level. * You can specify padding, in order to inset the bounding box from the map view's edges. * The returned CameraUpdate has a bearing of 0 and a tilt of 0. @@ -56,7 +56,7 @@ public final class CameraUpdateFactory { } /** - * Returns a {@link CameraUpdate} that transforms the camera such that the specified + * Returns a CameraUpdate that transforms the camera such that the specified * latitude/longitude bounds are centered on screen at the greatest possible zoom level. * You can specify padding, in order to inset the bounding box from the map view's edges. * The returned CameraUpdate has a bearing of 0 and a tilt of 0. diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/constants/MapboxConstants.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/constants/MapboxConstants.java index ecb6ffe24e..1ee59057d2 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/constants/MapboxConstants.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/constants/MapboxConstants.java @@ -133,5 +133,6 @@ public class MapboxConstants { public static final String STATE_ATTRIBUTION_MARGIN_RIGHT = "mapbox_attrMarginRight"; public static final String STATE_ATTRIBUTION_MARGIN_BOTTOM = "mapbox_atrrMarginBottom"; public static final String STATE_ATTRIBUTION_ENABLED = "mapbox_atrrEnabled"; - + public static final String STATE_LOCATION_CHANGE_ANIMATION_ENABLED = "mapbox_locationChangeAnimationEnabled"; + public static final String STATE_USING_CUSTOM_LOCATION_SOURCE = "mapbox_usingCustomLocationSource"; } diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/constants/MyBearingTracking.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/constants/MyBearingTracking.java index 88c3bef673..ceac862f39 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/constants/MyBearingTracking.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/constants/MyBearingTracking.java @@ -2,23 +2,27 @@ package com.mapbox.mapboxsdk.constants; import android.support.annotation.IntDef; +import com.mapbox.mapboxsdk.maps.MapboxMap; import com.mapbox.mapboxsdk.maps.widgets.MyLocationView; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; /** - * MyBearingTracking exposes different types bearing tracking modes. + * MyBearingTracking exposes different types of bearing tracking modes. + * <p> + * These modes visualise the user direction by extracting the direction from either sensor or location data. + * </p> + * <p> + * Required to enable showing the user location first through {@link MapboxMap#setMyLocationEnabled(boolean)}. + * </p> * * @see com.mapbox.mapboxsdk.maps.TrackingSettings#setMyBearingTrackingMode(int) * @see MyLocationView#setMyBearingTrackingMode(int) */ public class MyBearingTracking { - /** - * Indicates that the parameter accepts one of the values from MyBearingTracking. - */ - @IntDef( {NONE, COMPASS, GPS, /**COMBINED**/}) + @IntDef( {NONE, COMPASS, GPS}) @Retention(RetentionPolicy.SOURCE) public @interface Mode { } diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/constants/MyLocationTracking.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/constants/MyLocationTracking.java index a1744d701f..1283283fa5 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/constants/MyLocationTracking.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/constants/MyLocationTracking.java @@ -3,29 +3,34 @@ package com.mapbox.mapboxsdk.constants; import android.support.annotation.IntDef; import com.mapbox.mapboxsdk.maps.MapView; +import com.mapbox.mapboxsdk.maps.MapboxMap; +import com.mapbox.mapboxsdk.maps.TrackingSettings; import com.mapbox.mapboxsdk.maps.widgets.MyLocationView; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; /** - * MyLocationTracking exposes different types of locational tracking modes. + * MyLocationTracking exposes types of location tracking modes. + * * <p> + * This allows tracking the user location on screen by updating the camera position when a location update occurs. + * </p> + * <p> + * Required to enable showing the user location first through {@link MapboxMap#setMyLocationEnabled(boolean)}. + * </p> * - * @see com.mapbox.mapboxsdk.maps.TrackingSettings#setMyLocationTrackingMode(int) - * @see MyLocationView#setMyLocationTrackingMode(int) + * @see MapboxMap#setMyLocationEnabled(boolean) + * @see TrackingSettings#setMyLocationTrackingMode(int) */ public class MyLocationTracking { - /** - * Indicates the parameter accepts one of the values from MyLocationTracking. - */ @IntDef( {TRACKING_NONE, TRACKING_FOLLOW}) @Retention(RetentionPolicy.SOURCE) public @interface Mode { } /** - * Location tracking is disabled. + * Tracking the location of the user is disabled. */ public static final int TRACKING_NONE = 0x00000000; diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/constants/Style.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/constants/Style.java index 31e6313509..9943a72e06 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/constants/Style.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/constants/Style.java @@ -17,7 +17,6 @@ import java.lang.annotation.RetentionPolicy; */ public class Style { - /** * Indicates the parameter accepts one of the values from Style. Using one of these * constants means your map style will always use the latest version and may change as we diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/exceptions/IconBitmapChangedException.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/exceptions/IconBitmapChangedException.java index 7154049bd7..1f6b0efc4d 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/exceptions/IconBitmapChangedException.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/exceptions/IconBitmapChangedException.java @@ -1,15 +1,13 @@ package com.mapbox.mapboxsdk.exceptions; -import android.graphics.Bitmap; - import com.mapbox.mapboxsdk.annotations.Icon; import com.mapbox.mapboxsdk.annotations.Marker; import com.mapbox.mapboxsdk.maps.MapView; /** * <p> - * A {@code IconBitmapChangedException} is thrown by {@link MapView} when a {@link Marker} is added - * that has a {@link Icon} with a {@link Bitmap} that has been modified since the creation of the Icon. + * An IconBitmapChangedException is thrown by MapView when a Marker is added + * that has an Icon with a Bitmap that has been modified since the creation of the Icon. * </p> * You cannot modify a {@code Icon} after it has been added to the map in a {@code Marker} * diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/exceptions/InvalidLatLngBoundsException.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/exceptions/InvalidLatLngBoundsException.java index 08a23a7373..c1d0385815 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/exceptions/InvalidLatLngBoundsException.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/exceptions/InvalidLatLngBoundsException.java @@ -1,8 +1,8 @@ package com.mapbox.mapboxsdk.exceptions; /** - * A InvalidLatLngBoundsException is thrown by {@link com.mapbox.mapboxsdk.geometry.LatLngBounds} - * when there aren't enough {@link com.mapbox.mapboxsdk.geometry.LatLng} to create a bounds. + * An InvalidLatLngBoundsException is thrown by LatLngBounds + * when there aren't enough LatLng to create a bounds. */ public class InvalidLatLngBoundsException extends RuntimeException { diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/exceptions/InvalidMarkerPositionException.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/exceptions/InvalidMarkerPositionException.java index f0f9b9236b..44ee83265d 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/exceptions/InvalidMarkerPositionException.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/exceptions/InvalidMarkerPositionException.java @@ -5,6 +5,9 @@ package com.mapbox.mapboxsdk.exceptions; */ public class InvalidMarkerPositionException extends RuntimeException { + /** + * Creates a invalid marker position exception thrown when a Marker object is created with an invalid LatLng position. + */ public InvalidMarkerPositionException() { super("Adding an invalid Marker to a Map. " + "Missing the required position field. " diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/exceptions/MapboxConfigurationException.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/exceptions/MapboxConfigurationException.java index 74bceb196c..e9a0261d85 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/exceptions/MapboxConfigurationException.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/exceptions/MapboxConfigurationException.java @@ -8,10 +8,14 @@ import android.content.Context; * This occurs either when {@link com.mapbox.mapboxsdk.Mapbox} is not correctly initialised or the provided access token * through {@link com.mapbox.mapboxsdk.Mapbox#getInstance(Context, String)} isn't valid. * </p> + * * @see com.mapbox.mapboxsdk.Mapbox#getInstance(Context, String) */ public class MapboxConfigurationException extends RuntimeException { + /** + * Creates a Mapbox configuration exception thrown by MapboxMap when the SDK hasn't been properly initialised. + */ public MapboxConfigurationException() { super("\nUsing MapView requires setting a valid access token. Use Mapbox.getInstance(Context context, " + "String accessToken) to provide one. " diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/exceptions/TooManyIconsException.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/exceptions/TooManyIconsException.java index 8923d822f2..bffc10dc04 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/exceptions/TooManyIconsException.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/exceptions/TooManyIconsException.java @@ -1,12 +1,11 @@ package com.mapbox.mapboxsdk.exceptions; -import com.mapbox.mapboxsdk.annotations.Icon; import com.mapbox.mapboxsdk.annotations.IconFactory; /** * <p> - * A {@code TooManyIconsException} is thrown by {@link IconFactory} when it - * cannot create a {@link Icon} because there are already too many icons created. + * A TooManyIconsException is thrown by IconFactory when it + * cannot create a Icon because there are already too many icons created. * </p> * You should try to reuse Icon objects whenever possible. * diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/ILatLng.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/ILatLng.java index 1af8e7cfc7..07df87af3a 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/ILatLng.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/ILatLng.java @@ -1,12 +1,28 @@ package com.mapbox.mapboxsdk.geometry; /** - * Describes a latitude, longitude point. + * Describes a latitude, longitude, and altitude tuple. */ public interface ILatLng { + + /** + * Get the latitude, in degrees. + * + * @return the latitude value in degrees + */ double getLatitude(); + /** + * Get the longitude, in degrees. + * + * @return the longitude value in degrees + */ double getLongitude(); + /** + * Get the altitude, in meters. + * + * @return the altitude value in meters + */ double getAltitude(); } diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/IProjectedMeters.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/IProjectedMeters.java index 694c935143..db459d7cbb 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/IProjectedMeters.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/IProjectedMeters.java @@ -4,7 +4,19 @@ package com.mapbox.mapboxsdk.geometry; * Describes a projection in Mercator meters. */ public interface IProjectedMeters { + + /** + * Get the north projection, in meters. + * + * @return the projected meters in north direction + */ double getNorthing(); + /** + * Get the east projection, in meters. + * + * @return the projected meters in east direction + */ double getEasting(); + } diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/LatLng.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/LatLng.java index ca2d3673b2..eb57241196 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/LatLng.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/LatLng.java @@ -3,6 +3,7 @@ package com.mapbox.mapboxsdk.geometry; import android.location.Location; import android.os.Parcel; import android.os.Parcelable; +import android.support.annotation.FloatRange; import com.mapbox.services.android.telemetry.constants.GeoConstants; import com.mapbox.services.android.telemetry.utils.MathUtils; @@ -21,6 +22,9 @@ import com.mapbox.services.android.telemetry.utils.MathUtils; */ public class LatLng implements ILatLng, Parcelable { + /** + * Inner class responsible for recreating Parcels into objects. + */ public static final Parcelable.Creator<LatLng> CREATOR = new Parcelable.Creator<LatLng>() { public LatLng createFromParcel(Parcel in) { return new LatLng(in); @@ -44,7 +48,7 @@ public class LatLng implements ILatLng, Parcelable { } /** - * Construct a new latitude, longitude point given float arguments + * Construct a new latitude, longitude point given double arguments * * @param latitude Latitude in degrees * @param longitude Longitude in degrees @@ -55,7 +59,7 @@ public class LatLng implements ILatLng, Parcelable { } /** - * Construct a new latitude, longitude, altitude point given float arguments + * Construct a new latitude, longitude, altitude point given double arguments * * @param latitude Latitude in degrees * @param longitude Longitude in degress @@ -68,7 +72,7 @@ public class LatLng implements ILatLng, Parcelable { } /** - * Transform a Location into a LatLng point + * Construct a new latitude, longitude, altitude point given location argument * * @param location Android Location */ @@ -77,23 +81,40 @@ public class LatLng implements ILatLng, Parcelable { } /** - * Clone an existing latitude longitude point + * Construct a new latitude, longitude, altitude point given another latitude, longitude, altitude point. * - * @param aLatLng LatLng + * @param latLng LatLng to be cloned. */ - public LatLng(LatLng aLatLng) { - this.latitude = aLatLng.latitude; - this.longitude = aLatLng.longitude; - this.altitude = aLatLng.altitude; + public LatLng(LatLng latLng) { + this.latitude = latLng.latitude; + this.longitude = latLng.longitude; + this.altitude = latLng.altitude; } + /** + * Constructs a new latitude, longitude, altitude tuple given a parcel. + * + * @param in the parcel containing the latitude, longitude, altitude values + */ protected LatLng(Parcel in) { setLatitude(in.readDouble()); setLongitude(in.readDouble()); setAltitude(in.readDouble()); } - public void setLatitude(double latitude) { + /** + * Set the latitude, in degrees. + * <p> + * This value is in the range of [-85.05112878, 85.05112878], see {@link GeoConstants#MIN_LATITUDE} and + * {@link GeoConstants#MAX_LATITUDE} + * </p> + * + * @param latitude the latitude value in degrees + * @see GeoConstants#MIN_LATITUDE + * @see GeoConstants#MAX_LATITUDE + */ + public void setLatitude( + @FloatRange(from = GeoConstants.MIN_LATITUDE, to = GeoConstants.MAX_LATITUDE) double latitude) { if (Double.isNaN(latitude)) { throw new IllegalArgumentException("latitude must not be NaN"); } @@ -103,12 +124,35 @@ public class LatLng implements ILatLng, Parcelable { this.latitude = latitude; } + /** + * Get the latitude, in degrees. + * <p> + * This value is in the range of [-85.05112878, 85.05112878], see {@link GeoConstants#MIN_LATITUDE} and + * {@link GeoConstants#MAX_LATITUDE} + * </p> + * + * @return the latitude value in degrees + * @see GeoConstants#MIN_LATITUDE + * @see GeoConstants#MAX_LATITUDE + */ @Override public double getLatitude() { return latitude; } - public void setLongitude(double longitude) { + /** + * Set the longitude, in degrees. + * <p> + * This value is in the range of [-180, 180], see {@link GeoConstants#MIN_LONGITUDE} and + * {@link GeoConstants#MAX_LONGITUDE} + * </p> + * + * @param longitude the longitude value in degrees + * @see GeoConstants#MIN_LONGITUDE + * @see GeoConstants#MAX_LONGITUDE + */ + public void setLongitude(@FloatRange(from = GeoConstants.MIN_LONGITUDE, to = GeoConstants.MAX_LONGITUDE) + double longitude) { if (Double.isNaN(longitude)) { throw new IllegalArgumentException("longitude must not be NaN"); } @@ -118,15 +162,36 @@ public class LatLng implements ILatLng, Parcelable { this.longitude = longitude; } + /** + * Get the longitude, in degrees. + * <p> + * This value is in the range of [-180, 180], see {@link GeoConstants#MIN_LONGITUDE} and + * {@link GeoConstants#MAX_LONGITUDE} + * </p> + * + * @return the longitude value in degrees + * @see GeoConstants#MIN_LONGITUDE + * @see GeoConstants#MAX_LONGITUDE + */ @Override public double getLongitude() { return longitude; } + /** + * Set the altitude, in meters. + * + * @param altitude the altitude in meters + */ public void setAltitude(double altitude) { this.altitude = altitude; } + /** + * Get the altitude, in meters. + * + * @return the altitude value in meters + */ @Override public double getAltitude() { return altitude; @@ -136,13 +201,19 @@ public class LatLng implements ILatLng, Parcelable { * Return a new LatLng object with a wrapped Longitude. This allows original data object * to remain unchanged. * - * @return New LatLng object with wrapped Longitude + * @return new LatLng object with wrapped Longitude */ public LatLng wrap() { longitude = MathUtils.wrap(longitude, GeoConstants.MIN_LONGITUDE, GeoConstants.MAX_LONGITUDE); return this; } + /** + * Indicates whether some other object is "equal to" this one. + * + * @param object The object to compare + * @return True if equal, false if not + */ @Override public boolean equals(Object object) { if (this == object) { @@ -158,6 +229,11 @@ public class LatLng implements ILatLng, Parcelable { && Double.compare(latLng.longitude, longitude) == 0; } + /** + * Returns a hash code value for the object. + * + * @return the hash code value + */ @Override public int hashCode() { int result; @@ -171,16 +247,32 @@ public class LatLng implements ILatLng, Parcelable { return result; } + /** + * Returns a string representation of the object. + * + * @return the string representation + */ @Override public String toString() { return "LatLng [latitude=" + latitude + ", longitude=" + longitude + ", altitude=" + altitude + "]"; } + /** + * Describe the kinds of special objects contained in this Parcelable instance's marshaled representation. + * + * @return a bitmask indicating the set of special object types marshaled by this Parcelable object instance. + */ @Override public int describeContents() { return 0; } + /** + * Flatten this object in to a Parcel. + * + * @param out The Parcel in which the object should be written. + * @param flags Additional flags about how the object should be written + */ @Override public void writeToParcel(Parcel out, int flags) { out.writeDouble(latitude); diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/LatLngBounds.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/LatLngBounds.java index 4a4e2a30aa..505b2db192 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/LatLngBounds.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/LatLngBounds.java @@ -3,6 +3,7 @@ package com.mapbox.mapboxsdk.geometry; import android.os.Parcel; import android.os.Parcelable; import android.support.annotation.NonNull; +import android.support.annotation.Nullable; import com.mapbox.mapboxsdk.exceptions.InvalidLatLngBoundsException; import com.mapbox.services.android.telemetry.constants.GeoConstants; @@ -18,10 +19,10 @@ import java.util.List; */ public class LatLngBounds implements Parcelable { - private final double mLatNorth; - private final double mLatSouth; - private final double mLonEast; - private final double mLonWest; + private final double latitudeNorth; + private final double latitudeSouth; + private final double longitudeEast; + private final double longitudeWest; /** * Construct a new LatLngBounds based on its corners, given in NESW @@ -34,10 +35,10 @@ public class LatLngBounds implements Parcelable { */ LatLngBounds(final double northLatitude, final double eastLongitude, final double southLatitude, final double westLongitude) { - this.mLatNorth = northLatitude; - this.mLonEast = eastLongitude; - this.mLatSouth = southLatitude; - this.mLonWest = westLongitude; + this.latitudeNorth = northLatitude; + this.longitudeEast = eastLongitude; + this.latitudeSouth = southLatitude; + this.longitudeWest = westLongitude; } /** @@ -59,8 +60,8 @@ public class LatLngBounds implements Parcelable { * @return LatLng center of this LatLngBounds */ public LatLng getCenter() { - return new LatLng((this.mLatNorth + this.mLatSouth) / 2, - (this.mLonEast + this.mLonWest) / 2); + return new LatLng((this.latitudeNorth + this.latitudeSouth) / 2, + (this.longitudeEast + this.longitudeWest) / 2); } /** @@ -69,7 +70,7 @@ public class LatLngBounds implements Parcelable { * @return double latitude value for north */ public double getLatNorth() { - return this.mLatNorth; + return this.latitudeNorth; } /** @@ -78,7 +79,7 @@ public class LatLngBounds implements Parcelable { * @return double latitude value for south */ public double getLatSouth() { - return this.mLatSouth; + return this.latitudeSouth; } /** @@ -87,7 +88,7 @@ public class LatLngBounds implements Parcelable { * @return double longitude value for east */ public double getLonEast() { - return this.mLonEast; + return this.longitudeEast; } /** @@ -96,7 +97,7 @@ public class LatLngBounds implements Parcelable { * @return double longitude value for west */ public double getLonWest() { - return this.mLonWest; + return this.longitudeWest; } /** @@ -105,7 +106,7 @@ public class LatLngBounds implements Parcelable { * @return LatLng of the south west corner */ public LatLng getSouthWest() { - return new LatLng(mLatSouth, mLonWest); + return new LatLng(latitudeSouth, longitudeWest); } /** @@ -114,7 +115,7 @@ public class LatLngBounds implements Parcelable { * @return LatLng of the north east corner */ public LatLng getNorthEast() { - return new LatLng(mLatNorth, mLonEast); + return new LatLng(latitudeNorth, longitudeEast); } /** @@ -123,7 +124,7 @@ public class LatLngBounds implements Parcelable { * @return LatLng of the south east corner */ public LatLng getSouthEast() { - return new LatLng(mLatSouth, mLonEast); + return new LatLng(latitudeSouth, longitudeEast); } /** @@ -132,7 +133,7 @@ public class LatLngBounds implements Parcelable { * @return LatLng of the north west corner */ public LatLng getNorthWest() { - return new LatLng(mLatNorth, mLonWest); + return new LatLng(latitudeNorth, longitudeWest); } /** @@ -151,7 +152,7 @@ public class LatLngBounds implements Parcelable { * @return Span distance */ public double getLatitudeSpan() { - return Math.abs(this.mLatNorth - this.mLatSouth); + return Math.abs(this.latitudeNorth - this.latitudeSouth); } /** @@ -161,7 +162,7 @@ public class LatLngBounds implements Parcelable { * @return Span distance */ public double getLongitudeSpan() { - return Math.abs(this.mLonEast - this.mLonWest); + return Math.abs(this.longitudeEast - this.longitudeWest); } @@ -174,9 +175,15 @@ public class LatLngBounds implements Parcelable { return getLongitudeSpan() == 0.0 || getLatitudeSpan() == 0.0; } + /** + * Returns a string representaton of the object. + * + * @return the string representation + */ @Override public String toString() { - return "N:" + this.mLatNorth + "; E:" + this.mLonEast + "; S:" + this.mLatSouth + "; W:" + this.mLonWest; + return "N:" + this.latitudeNorth + "; E:" + this.longitudeEast + "; S:" + this.latitudeSouth + + "; W:" + this.longitudeWest; } /** @@ -241,10 +248,10 @@ public class LatLngBounds implements Parcelable { } if (o instanceof LatLngBounds) { LatLngBounds other = (LatLngBounds) o; - return mLatNorth == other.getLatNorth() - && mLatSouth == other.getLatSouth() - && mLonEast == other.getLonEast() - && mLonWest == other.getLonWest(); + return latitudeNorth == other.getLatNorth() + && latitudeSouth == other.getLatSouth() + && longitudeEast == other.getLonEast() + && longitudeWest == other.getLonWest(); } return false; } @@ -258,10 +265,10 @@ public class LatLngBounds implements Parcelable { public boolean contains(final ILatLng latLng) { final double latitude = latLng.getLatitude(); final double longitude = latLng.getLongitude(); - return ((latitude <= this.mLatNorth) - && (latitude >= this.mLatSouth)) - && ((longitude <= this.mLonEast) - && (longitude >= this.mLonWest)); + return ((latitude <= this.latitudeNorth) + && (latitude >= this.latitudeSouth)) + && ((longitude <= this.longitudeEast) + && (longitude >= this.longitudeWest)); } /** @@ -295,10 +302,10 @@ public class LatLngBounds implements Parcelable { * @return BoundingBox */ public LatLngBounds union(final double lonNorth, final double latEast, final double lonSouth, final double latWest) { - return new LatLngBounds((this.mLatNorth < lonNorth) ? lonNorth : this.mLatNorth, - (this.mLonEast < latEast) ? latEast : this.mLonEast, - (this.mLatSouth > lonSouth) ? lonSouth : this.mLatSouth, - (this.mLonWest > latWest) ? latWest : this.mLonWest); + return new LatLngBounds((this.latitudeNorth < lonNorth) ? lonNorth : this.latitudeNorth, + (this.longitudeEast < latEast) ? latEast : this.longitudeEast, + (this.latitudeSouth > lonSouth) ? lonSouth : this.latitudeSouth, + (this.longitudeWest > latWest) ? latWest : this.longitudeWest); } /** @@ -307,6 +314,7 @@ public class LatLngBounds implements Parcelable { * @param box LatLngBounds to intersect with * @return LatLngBounds */ + @Nullable public LatLngBounds intersect(LatLngBounds box) { double minLatWest = Math.max(getLonWest(), box.getLonWest()); double maxLatEast = Math.min(getLonEast(), box.getLonEast()); @@ -334,6 +342,9 @@ public class LatLngBounds implements Parcelable { return intersect(new LatLngBounds(northLatitude, eastLongitude, southLatitude, westLongitude)); } + /** + * Inner class responsible for recreating Parcels into objects. + */ public static final Parcelable.Creator<LatLngBounds> CREATOR = new Parcelable.Creator<LatLngBounds>() { @Override @@ -347,25 +358,41 @@ public class LatLngBounds implements Parcelable { } }; + /** + * Returns a hash code value for the object. + * + * @return the hash code + */ @Override public int hashCode() { - return (int) ((mLatNorth + 90) - + ((mLatSouth + 90) * 1000) - + ((mLonEast + 180) * 1000000) - + ((mLonEast + 180) * 1000000000)); + return (int) ((latitudeNorth + 90) + + ((latitudeSouth + 90) * 1000) + + ((longitudeEast + 180) * 1000000) + + ((longitudeEast + 180) * 1000000000)); } + /** + * Describe the kinds of special objects contained in this Parcelable instance's marshaled representation. + * + * @return a bitmask indicating the set of special object types marshaled by this Parcelable object instance. + */ @Override public int describeContents() { return 0; } + /** + * Flatten this object in to a Parcel. + * + * @param out The Parcel in which the object should be written. + * @param flags Additional flags about how the object should be written + */ @Override - public void writeToParcel(final Parcel out, final int arg1) { - out.writeDouble(this.mLatNorth); - out.writeDouble(this.mLonEast); - out.writeDouble(this.mLatSouth); - out.writeDouble(this.mLonWest); + public void writeToParcel(final Parcel out, final int flags) { + out.writeDouble(this.latitudeNorth); + out.writeDouble(this.longitudeEast); + out.writeDouble(this.latitudeSouth); + out.writeDouble(this.longitudeWest); } private static LatLngBounds readFromParcel(final Parcel in) { @@ -381,28 +408,51 @@ public class LatLngBounds implements Parcelable { */ public static final class Builder { - private List<LatLng> mLatLngList; + private List<LatLng> latLngList; + /** + * Constructs a builder to compose LatLng objects to a LatLngBounds. + */ public Builder() { - mLatLngList = new ArrayList<>(); + latLngList = new ArrayList<>(); } + /** + * Builds a new LatLngBounds. + * <p> + * Throws an {@link InvalidLatLngBoundsException} when no LatLngBounds can be created. + * </p> + * + * @return the build LatLngBounds + */ public LatLngBounds build() { - if (mLatLngList.size() < 2) { - throw new InvalidLatLngBoundsException(mLatLngList.size()); + if (latLngList.size() < 2) { + throw new InvalidLatLngBoundsException(latLngList.size()); } - return LatLngBounds.fromLatLngs(mLatLngList); + return LatLngBounds.fromLatLngs(latLngList); } + /** + * Adds a LatLng object to the LatLngBounds.Builder. + * + * @param latLngs the List of LatLng objects to be added + * @return this + */ public Builder includes(List<LatLng> latLngs) { for (LatLng point : latLngs) { - mLatLngList.add(point); + latLngList.add(point); } return this; } + /** + * Adds a LatLng object to the LatLngBounds.Builder. + * + * @param latLng the LatLng to be added + * @return this + */ public Builder include(@NonNull LatLng latLng) { - mLatLngList.add(latLng); + latLngList.add(latLng); return this; } } diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/LatLngSpan.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/LatLngSpan.java index d00ccdb9b8..322c7dfb74 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/LatLngSpan.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/LatLngSpan.java @@ -64,19 +64,28 @@ public class LatLngSpan implements Parcelable { mLongitudeSpan = longitudeSpan; } + /** + * Indicates whether some other object is "equal to" this one. + * + * @param object The object to compare + * @return True if equal, false if not + */ @Override - public boolean equals(Object o) { - if (this == o) { + public boolean equals(Object object) { + if (this == object) { return true; } - if (o instanceof LatLngSpan) { - LatLngSpan other = (LatLngSpan) o; + if (object instanceof LatLngSpan) { + LatLngSpan other = (LatLngSpan) object; return mLongitudeSpan == other.getLongitudeSpan() && mLatitudeSpan == other.getLatitudeSpan(); } return false; } + /** + * Inner class responsible for recreating Parcels into objects. + */ public static final Parcelable.Creator<LatLngSpan> CREATOR = new Parcelable.Creator<LatLngSpan>() { @Override @@ -90,14 +99,41 @@ public class LatLngSpan implements Parcelable { } }; + /** + * Describe the kinds of special objects contained in this Parcelable instance's marshaled representation. + * + * @return a bitmask indicating the set of special object types marshaled by this Parcelable object instance. + */ @Override public int describeContents() { return 0; } + /** + * Flatten this object in to a Parcel. + * + * @param out Parcel in which the object should be written + * @param flags Additional flags about how the object should be written + */ @Override - public void writeToParcel(Parcel out, int arg1) { + public void writeToParcel(Parcel out, int flags) { out.writeDouble(mLatitudeSpan); out.writeDouble(mLongitudeSpan); } + + /** + * Returns a hash code value for the object. + * + * @return hash code value of this + */ + @Override + public int hashCode() { + int result; + long temp; + temp = Double.doubleToLongBits(mLatitudeSpan); + result = (int) (temp ^ (temp >>> 32)); + temp = Double.doubleToLongBits(mLongitudeSpan); + result = 31 * result + (int) (temp ^ (temp >>> 32)); + return result; + } } diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/ProjectedMeters.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/ProjectedMeters.java index 761d8f2a8b..fa84c33b2b 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/ProjectedMeters.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/ProjectedMeters.java @@ -13,6 +13,9 @@ import android.os.Parcelable; */ public class ProjectedMeters implements IProjectedMeters, Parcelable { + /** + * Inner class responsible for recreating Parcels into objects. + */ public static final Creator<ProjectedMeters> CREATOR = new Creator<ProjectedMeters>() { public ProjectedMeters createFromParcel(Parcel in) { return new ProjectedMeters(in); @@ -47,6 +50,12 @@ public class ProjectedMeters implements IProjectedMeters, Parcelable { this.easting = projectedMeters.easting; } + /** + * Creates a ProjectedMeters from a Parcel. + * + * @param in The parcel to create from + * @return a bitmask indicating the set of special object types marshaled by this Parcelable object instance. + */ private ProjectedMeters(Parcel in) { northing = in.readDouble(); easting = in.readDouble(); @@ -72,22 +81,32 @@ public class ProjectedMeters implements IProjectedMeters, Parcelable { return easting; } + /** + * Indicates whether some other object is "equal to" this one. + * + * @param other The object to compare this to + * @return true if equal, false if not + */ @Override - public boolean equals(Object o) { - if (this == o) { + public boolean equals(Object other) { + if (this == other) { return true; } - if (o == null || getClass() != o.getClass()) { + if (other == null || getClass() != other.getClass()) { return false; } - ProjectedMeters projectedMeters = (ProjectedMeters) o; + ProjectedMeters projectedMeters = (ProjectedMeters) other; return Double.compare(projectedMeters.easting, easting) == 0 && Double.compare(projectedMeters.northing, northing) == 0; - } + /** + * Returns a hash code value for the object. + * + * @return the hash code of this + */ @Override public int hashCode() { int result; @@ -99,16 +118,32 @@ public class ProjectedMeters implements IProjectedMeters, Parcelable { return result; } + /** + * Returns a string representation of the object. + * + * @return the string representation of this + */ @Override public String toString() { return "ProjectedMeters [northing=" + northing + ", easting=" + easting + "]"; } + /** + * Describe the kinds of special objects contained in this Parcelable instance's marshaled representation. + * + * @return a bitmask indicating the set of special object types marshaled by this Parcelable object instance. + */ @Override public int describeContents() { return 0; } + /** + * Flatten this object in to a Parcel. + * + * @param out The Parcel in which the object should be written. + * @param flags Additional flags about how the object should be written + */ @Override public void writeToParcel(Parcel out, int flags) { out.writeDouble(northing); diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/VisibleRegion.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/VisibleRegion.java index c5b8ad3077..c09c00fced 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/VisibleRegion.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/VisibleRegion.java @@ -37,6 +37,11 @@ public class VisibleRegion implements Parcelable { */ public final LatLngBounds latLngBounds; + /** + * Creates a VisibleRegion from a Parcel. + * + * @param in The Parcel to create this from + */ private VisibleRegion(Parcel in) { this.farLeft = in.readParcelable(LatLng.class.getClassLoader()); this.farRight = in.readParcelable(LatLng.class.getClassLoader()); @@ -46,7 +51,7 @@ public class VisibleRegion implements Parcelable { } /** - * Creates a new VisibleRegion given the four corners of the camera. + * Creates a VisibleRegion given the four corners of the camera. * * @param farLeft A LatLng object containing the latitude and longitude of the near left corner of the region. * @param farRight A LatLng object containing the latitude and longitude of the near left corner of the region. @@ -88,12 +93,22 @@ public class VisibleRegion implements Parcelable { && latLngBounds.equals(visibleRegion.latLngBounds); } + /** + * The string representation of the object. + * + * @return the string representation of this + */ @Override public String toString() { return "[farLeft [" + farLeft + "], farRight [" + farRight + "], nearLeft [" + nearLeft + "], nearRight [" + nearRight + "], latLngBounds [" + latLngBounds + "]]"; } + /** + * Returns a hash code value for the object. + * + * @return the hash code + */ @Override public int hashCode() { return ((farLeft.hashCode() + 90) @@ -102,11 +117,22 @@ public class VisibleRegion implements Parcelable { + ((nearRight.hashCode() + 180) * 1000000000)); } + /** + * Describe the kinds of special objects contained in this Parcelable instance's marshaled representation. + * + * @return a bitmask indicating the set of special object types marshaled by this Parcelable object instance. + */ @Override public int describeContents() { return 0; } + /** + * Flatten this object in to a Parcel. + * + * @param out The Parcel in which the object should be written. + * @param flags Additional flags about how the object should be written + */ @Override public void writeToParcel(Parcel out, int flags) { out.writeParcelable(farLeft, flags); @@ -116,6 +142,9 @@ public class VisibleRegion implements Parcelable { out.writeParcelable(latLngBounds, flags); } + /** + * Inner class responsible for recreating Parcels into objects. + */ public static final Parcelable.Creator<VisibleRegion> CREATOR = new Parcelable.Creator<VisibleRegion>() { public VisibleRegion createFromParcel(Parcel in) { diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationSource.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationSource.java index 4e934fa3cc..6652142be3 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationSource.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationSource.java @@ -2,7 +2,7 @@ package com.mapbox.mapboxsdk.location; import android.content.Context; import android.location.Location; -import android.support.annotation.NonNull; +import android.support.annotation.Nullable; import com.mapbox.services.android.telemetry.location.LocationEngine; import com.mapbox.services.android.telemetry.location.LocationEngineListener; @@ -13,10 +13,6 @@ import com.mapzen.android.lost.api.LocationRequest; import com.mapzen.android.lost.api.LocationServices; import com.mapzen.android.lost.api.LostApiClient; -import java.lang.ref.WeakReference; - -import timber.log.Timber; - /** * Manages locational updates. Contains methods to register and unregister location listeners. * <ul> @@ -32,34 +28,20 @@ import timber.log.Timber; * in the history stack. * </p> */ -public class LocationSource extends LocationEngine implements - LostApiClient.ConnectionCallbacks, LocationListener { +public class LocationSource extends LocationEngine implements LocationListener { - private static LocationEngine instance; - - private WeakReference<Context> context; + private Context context; private LostApiClient lostApiClient; - private LocationSource(Context context) { - super(); - this.context = new WeakReference<>(context); - lostApiClient = new LostApiClient.Builder(this.context.get()) - .addConnectionCallbacks(this) - .build(); - } - /** - * Get the LocationEngine instance. + * Constructs a location source instance. * - * @param context a Context from which the application context is derived - * @return the LocationEngine instance + * @param context the context from which the Application context will be derived. */ - public static synchronized LocationEngine getLocationEngine(@NonNull Context context) { - if (instance == null) { - instance = new LocationSource(context.getApplicationContext()); - } - - return instance; + public LocationSource(Context context) { + super(); + this.context = context.getApplicationContext(); + lostApiClient = new LostApiClient.Builder(this.context).build(); } /** @@ -68,9 +50,12 @@ public class LocationSource extends LocationEngine implements */ @Override public void activate() { - if (lostApiClient != null && !lostApiClient.isConnected()) { + if (!lostApiClient.isConnected()) { lostApiClient.connect(); } + for (LocationEngineListener listener : locationListeners) { + listener.onConnected(); + } } /** @@ -80,7 +65,7 @@ public class LocationSource extends LocationEngine implements */ @Override public void deactivate() { - if (lostApiClient != null && lostApiClient.isConnected()) { + if (lostApiClient.isConnected()) { lostApiClient.disconnect(); } } @@ -97,35 +82,17 @@ public class LocationSource extends LocationEngine implements } /** - * Invoked when the location provider has connected. - */ - @Override - public void onConnected() { - for (LocationEngineListener listener : locationListeners) { - listener.onConnected(); - } - } - - /** - * Invoked when the location provider connection has been suspended. - */ - @Override - public void onConnectionSuspended() { - Timber.d("Connection suspended."); - } - - /** * Returns the Last known location is the location provider is connected and location permissions are granted. * * @return the last known location */ @Override + @Nullable public Location getLastLocation() { - if (lostApiClient.isConnected() && PermissionsManager.areLocationPermissionsGranted(context.get())) { + if (lostApiClient.isConnected() && PermissionsManager.areLocationPermissionsGranted(context)) { //noinspection MissingPermission - return LocationServices.FusedLocationApi.getLastLocation(lostApiClient); + return LocationServices.FusedLocationApi.getLastLocation(); } - return null; } @@ -151,9 +118,9 @@ public class LocationSource extends LocationEngine implements request.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY); } - if (lostApiClient.isConnected() && PermissionsManager.areLocationPermissionsGranted(context.get())) { + if (lostApiClient.isConnected() && PermissionsManager.areLocationPermissionsGranted(context)) { //noinspection MissingPermission - LocationServices.FusedLocationApi.requestLocationUpdates(lostApiClient, request, this); + LocationServices.FusedLocationApi.requestLocationUpdates(request, this); } } @@ -163,7 +130,7 @@ public class LocationSource extends LocationEngine implements @Override public void removeLocationUpdates() { if (lostApiClient.isConnected()) { - LocationServices.FusedLocationApi.removeLocationUpdates(lostApiClient, this); + LocationServices.FusedLocationApi.removeLocationUpdates(this); } } diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/CameraChangeDispatcher.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/CameraChangeDispatcher.java index bd028aecb6..6f7d7c0080 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/CameraChangeDispatcher.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/CameraChangeDispatcher.java @@ -2,8 +2,8 @@ package com.mapbox.mapboxsdk.maps; import static com.mapbox.mapboxsdk.maps.MapboxMap.OnCameraIdleListener; import static com.mapbox.mapboxsdk.maps.MapboxMap.OnCameraMoveCanceledListener; -import static com.mapbox.mapboxsdk.maps.MapboxMap.OnCameraMoveStartedListener; import static com.mapbox.mapboxsdk.maps.MapboxMap.OnCameraMoveListener; +import static com.mapbox.mapboxsdk.maps.MapboxMap.OnCameraMoveStartedListener; class CameraChangeDispatcher implements MapboxMap.OnCameraMoveStartedListener, MapboxMap.OnCameraMoveListener, MapboxMap.OnCameraMoveCanceledListener, OnCameraIdleListener { @@ -59,9 +59,11 @@ class CameraChangeDispatcher implements MapboxMap.OnCameraMoveStartedListener, M @Override public void onCameraIdle() { - if (onCameraIdleListener != null && !idle) { + if (!idle) { idle = true; - onCameraIdleListener.onCameraIdle(); + if (onCameraIdleListener != null) { + onCameraIdleListener.onCameraIdle(); + } } } } diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapGestureDetector.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapGestureDetector.java index 33e13c5ecc..3607703ab1 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapGestureDetector.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapGestureDetector.java @@ -57,6 +57,7 @@ final class MapGestureDetector { private boolean quickZoom = false; private boolean scrollInProgress = false; private boolean scaleGestureOccurred = false; + private boolean recentScaleGestureOccurred = false; MapGestureDetector(Context context, Transform transform, Projection projection, UiSettings uiSettings, TrackingSettings trackingSettings, AnnotationManager annotationManager, @@ -148,7 +149,7 @@ final class MapGestureDetector { switch (event.getActionMasked()) { case MotionEvent.ACTION_DOWN: // First pointer down, reset scaleGestureOccurred, used to avoid triggering a fling after a scale gesture #7666 - scaleGestureOccurred = false; + recentScaleGestureOccurred = false; transform.setGestureInProgress(true); break; @@ -274,7 +275,7 @@ final class MapGestureDetector { break; case MotionEvent.ACTION_UP: if (quickZoom) { - // insert here? + cameraChangeDispatcher.onCameraIdle(); quickZoom = false; break; } @@ -341,12 +342,11 @@ final class MapGestureDetector { @Override public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) { - if ((!trackingSettings.isScrollGestureCurrentlyEnabled()) || scaleGestureOccurred) { + if ((!trackingSettings.isScrollGestureCurrentlyEnabled()) || recentScaleGestureOccurred) { // don't allow a fling is scroll is disabled // and ignore when a scale gesture has occurred return false; } - cameraChangeDispatcher.onCameraMoveStarted(REASON_API_GESTURE); float screenDensity = uiSettings.getPixelRatio(); @@ -362,6 +362,8 @@ final class MapGestureDetector { // cancel any animation transform.cancelTransitions(); + cameraChangeDispatcher.onCameraMoveStarted(REASON_API_GESTURE); + // tilt results in a bigger translation, limiting input for #5281 double tilt = transform.getTilt(); double tiltFactor = 1 + ((tilt != 0) ? (tilt / 10) : 0); /* 1 -> 7 */ @@ -391,12 +393,17 @@ final class MapGestureDetector { return false; } + if (scaleGestureOccurred) { + return false; + } + if (!scrollInProgress) { scrollInProgress = true; // Cancel any animation transform.cancelTransitions(); cameraChangeDispatcher.onCameraMoveStarted(REASON_API_GESTURE); + MapboxTelemetry.getInstance().pushEvent(MapboxEventWrapper.buildMapClickEvent( getLocationFromGesture(e1.getX(), e1.getY()), MapboxEvent.GESTURE_PAN_START, transform)); @@ -431,6 +438,7 @@ final class MapGestureDetector { } scaleGestureOccurred = true; + recentScaleGestureOccurred = true; beginTime = detector.getEventTime(); MapboxTelemetry.getInstance().pushEvent(MapboxEventWrapper.buildMapClickEvent( getLocationFromGesture(detector.getFocusX(), detector.getFocusY()), @@ -441,9 +449,11 @@ final class MapGestureDetector { // Called when fingers leave screen @Override public void onScaleEnd(ScaleGestureDetector detector) { + scaleGestureOccurred = false; beginTime = 0; scaleFactor = 1.0f; zoomStarted = false; + cameraChangeDispatcher.onCameraIdle(); } // Called each time a finger moves @@ -479,6 +489,9 @@ final class MapGestureDetector { } // Gesture is a quickzoom if there aren't two fingers + if (!quickZoom && !twoTap) { + cameraChangeDispatcher.onCameraMoveStarted(REASON_API_GESTURE); + } quickZoom = !twoTap; // make an assumption here; if the zoom center is specified by the gesture, it's NOT going @@ -491,6 +504,7 @@ final class MapGestureDetector { // arround user provided focal point transform.zoomBy(Math.log(detector.getScaleFactor()) / Math.log(2), focalPoint.x, focalPoint.y); } else if (quickZoom) { + cameraChangeDispatcher.onCameraMove(); // clamp scale factors we feed to core #7514 float scaleFactor = MathUtils.clamp(detector.getScaleFactor(), MapboxConstants.MINIMUM_SCALE_FACTOR_CLAMP, @@ -552,7 +566,7 @@ final class MapGestureDetector { // If rotate is large enough ignore a tap // Also is zoom already started, don't rotate totalAngle += detector.getRotationDegreesDelta(); - if (!zoomStarted && ((totalAngle > 20.0f) || (totalAngle < -20.0f))) { + if (totalAngle > 20.0f || totalAngle < -20.0f) { started = true; } diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapKeyListener.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapKeyListener.java index 7175242282..d1f01a30f7 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapKeyListener.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapKeyListener.java @@ -2,6 +2,7 @@ package com.mapbox.mapboxsdk.maps; import android.graphics.PointF; import android.os.Handler; +import android.os.Looper; import android.support.annotation.NonNull; import android.view.KeyEvent; import android.view.MotionEvent; @@ -204,7 +205,7 @@ final class MapKeyListener { currentTrackballLongPressTimeOut = null; } currentTrackballLongPressTimeOut = new TrackballLongPressTimeOut(); - new Handler().postDelayed(currentTrackballLongPressTimeOut, + new Handler(Looper.getMainLooper()).postDelayed(currentTrackballLongPressTimeOut, ViewConfiguration.getLongPressTimeout()); return true; 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 19cad1d8e0..a0aebfda50 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 @@ -1,7 +1,5 @@ package com.mapbox.mapboxsdk.maps; -import android.app.Activity; -import android.app.Fragment; import android.content.Context; import android.graphics.Canvas; import android.graphics.PointF; @@ -28,7 +26,6 @@ import android.widget.FrameLayout; import android.widget.ImageView; import android.widget.ZoomButtonsController; -import com.mapbox.mapboxsdk.Mapbox; import com.mapbox.mapboxsdk.R; import com.mapbox.mapboxsdk.annotations.Annotation; import com.mapbox.mapboxsdk.annotations.MarkerViewManager; @@ -187,14 +184,14 @@ public class MapView extends FrameLayout { /** * <p> - * You must call this method from the parent's {@link android.app.Activity#onCreate(Bundle)} or - * {@link android.app.Fragment#onCreate(Bundle)}. + * You must call this method from the parent's Activity#onCreate(Bundle)} or + * Fragment#onCreate(Bundle). * </p> - * You must set a valid access token with {@link Mapbox#getInstance(Context, String)}) before you call this method - * or an exception will be thrown. + * You must set a valid access token with {@link com.mapbox.mapboxsdk.Mapbox#getInstance(Context, String)} + * before you call this method or an exception will be thrown. * * @param savedInstanceState Pass in the parent's savedInstanceState. - * @see Mapbox#getInstance(Context, String) + * @see com.mapbox.mapboxsdk.Mapbox#getInstance(Context, String) */ @UiThread public void onCreate(@Nullable Bundle savedInstanceState) { @@ -223,12 +220,11 @@ public class MapView extends FrameLayout { } /** - * You must call this method from the parent's {@link android.app.Activity#onSaveInstanceState(Bundle)} - * or {@link android.app.Fragment#onSaveInstanceState(Bundle)}. + * You must call this method from the parent's Activity#onSaveInstanceState(Bundle) + * or Fragment#onSaveInstanceState(Bundle). * * @param outState Pass in the parent's outState. */ - @UiThread public void onSaveInstanceState(@NonNull Bundle outState) { outState.putBoolean(MapboxConstants.STATE_HAS_SAVED_STATE, true); @@ -236,7 +232,7 @@ public class MapView extends FrameLayout { } /** - * You must call this method from the parent's {@link Activity#onStart()} or {@link Fragment#onStart()} + * You must call this method from the parent's Activity#onStart() or Fragment#onStart() */ @UiThread public void onStart() { @@ -245,7 +241,7 @@ public class MapView extends FrameLayout { } /** - * You must call this method from the parent's {@link Activity#onResume()} or {@link Fragment#onResume()}. + * You must call this method from the parent's Activity#onResume() or Fragment#onResume(). */ @UiThread public void onResume() { @@ -253,7 +249,7 @@ public class MapView extends FrameLayout { } /** - * You must call this method from the parent's {@link Activity#onPause()} or {@link Fragment#onPause()}. + * You must call this method from the parent's Activity#onPause() or Fragment#onPause(). */ @UiThread public void onPause() { @@ -261,7 +257,7 @@ public class MapView extends FrameLayout { } /** - * You must call this method from the parent's {@link Activity#onStop()} or {@link Fragment#onStop()}. + * You must call this method from the parent's Activity#onStop() or Fragment#onStop(). */ @UiThread public void onStop() { @@ -270,7 +266,7 @@ public class MapView extends FrameLayout { } /** - * You must call this method from the parent's {@link Activity#onDestroy()} or {@link Fragment#onDestroy()}. + * You must call this method from the parent's Activity#onDestroy() or Fragment#onDestroy(). */ @UiThread public void onDestroy() { @@ -334,7 +330,7 @@ public class MapView extends FrameLayout { } /** - * You must call this method from the parent's {@link Activity#onLowMemory()} or {@link Fragment#onLowMemory()}. + * You must call this method from the parent's Activity#onLowMemory() or Fragment#onLowMemory(). */ @UiThread public void onLowMemory() { @@ -783,7 +779,7 @@ public class MapView extends FrameLayout { public static final int DID_FINISH_LOADING_STYLE = 14; /** - * This {@link MapChange} is triggered when a source attribution changes. + * This {@link MapChange} is triggered when a source changes. * <p> * Register to {@link MapChange} events with {@link MapView#addOnMapChangedListener(OnMapChangedListener)}. * </p> 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 f60ddf616a..18bcd4953d 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 @@ -37,7 +37,6 @@ import com.mapbox.mapboxsdk.constants.MyLocationTracking; import com.mapbox.mapboxsdk.constants.Style; import com.mapbox.mapboxsdk.geometry.LatLng; import com.mapbox.mapboxsdk.geometry.LatLngBounds; -import com.mapbox.mapboxsdk.location.LocationSource; import com.mapbox.mapboxsdk.maps.widgets.MyLocationViewSettings; import com.mapbox.mapboxsdk.style.layers.Filter; import com.mapbox.mapboxsdk.style.layers.Layer; @@ -141,12 +140,20 @@ public final class MapboxMap { */ void onRestoreInstanceState(Bundle savedInstanceState) { final CameraPosition cameraPosition = savedInstanceState.getParcelable(MapboxConstants.STATE_CAMERA_POSITION); - if (cameraPosition != null) { - moveCamera(CameraUpdateFactory.newCameraPosition(new CameraPosition.Builder(cameraPosition).build())); - } uiSettings.onRestoreInstanceState(savedInstanceState); trackingSettings.onRestoreInstanceState(savedInstanceState); + + if (cameraPosition != null) { + easeCamera(CameraUpdateFactory.newCameraPosition( + new CameraPosition.Builder(cameraPosition).build()), + 0, + false, + null, + !trackingSettings.isLocationTrackingDisabled() + ); + } + nativeMapView.setDebug(savedInstanceState.getBoolean(MapboxConstants.STATE_DEBUG_ACTIVE)); final String styleUrl = savedInstanceState.getString(MapboxConstants.STATE_STYLE_URL); @@ -729,8 +736,8 @@ public final class MapboxMap { * will return the current location of the camera in flight. * <p> * Note that this will cancel location tracking mode if enabled. You can change this behaviour by calling - * {@link TrackingSettings#setDismissTrackingModeForCameraPositionChange(boolean)} with false before invoking this - * method and calling it with true in the {@link CancelableCallback#onFinish()}. + * {@link com.mapbox.mapboxsdk.maps.TrackingSettings#setDismissLocationTrackingOnGesture(boolean)} with false before + * invoking this method and calling it with true in the {@link CancelableCallback#onFinish()}. * </p> * * @param update The change that should be applied to the camera. @@ -756,8 +763,8 @@ public final class MapboxMap { * will return the current location of the camera in flight. * <p> * Note that this will cancel location tracking mode if enabled. You can change this behaviour by calling - * {@link TrackingSettings#setDismissTrackingModeForCameraPositionChange(boolean)} with false before invoking this - * method and calling it with true in the {@link CancelableCallback#onFinish()}. + * {@link com.mapbox.mapboxsdk.maps.TrackingSettings#setDismissLocationTrackingOnGesture(boolean)} with false before + * invoking this method and calling it with true in the {@link CancelableCallback#onFinish()}. * </p> * * @param update The change that should be applied to the camera. @@ -880,7 +887,12 @@ public final class MapboxMap { } /** - * Set focal bearing. + * Transform the map bearing given a bearing, focal point coordinates, and a duration. + * + * @param bearing The bearing of the Map to be transformed to + * @param focalX The x coordinate of the focal point + * @param focalY The y coordinate of the focal point + * @param duration The duration of the transformation */ public void setFocalBearing(double bearing, float focalX, float focalY, long duration) { transform.setBearing(bearing, focalX, focalY, duration); @@ -1052,7 +1064,7 @@ public final class MapboxMap { * An error message will be logged in the Android logcat and {@link MapView#DID_FAIL_LOADING_MAP} event will be * sent. * - * @param style The bundled style. Accepts one of the values from {@link Style}. + * @param style The bundled style. * @see Style */ @UiThread @@ -1068,7 +1080,8 @@ public final class MapboxMap { * An error message will be logged in the Android logcat and {@link MapView#DID_FAIL_LOADING_MAP} event will be * sent. * - * @param style The bundled style. Accepts one of the values from {@link Style}. + * @param style The bundled style. + * @param callback The callback to be invoked when the style has finished loading * @see Style */ @UiThread @@ -1569,9 +1582,11 @@ public final class MapboxMap { } /** - * Gets a camera position that would fit a bounds. + * Get a camera position that fits a provided bounds and padding. * * @param latLngBounds the bounds to constrain the map with + * @param padding the padding to apply to the bounds + * @return the camera position that fits the bounds and padding */ public CameraPosition getCameraForLatLngBounds(@Nullable LatLngBounds latLngBounds, int[] padding) { // calculate and set additional bounds padding @@ -1864,8 +1879,6 @@ public final class MapboxMap { * Replaces the location source of the my-location layer. * * @param locationSource A {@link LocationEngine} location source to use in the my-location layer. - * Set to null to use the default {@link LocationSource} - * location source. */ @UiThread public void setLocationSource(@Nullable LocationEngine locationSource) { @@ -2405,11 +2418,13 @@ public final class MapboxMap { } /** - * Interface definintion for a callback to be invoked when the style has finished loading. + * Interface definition for a callback to be invoked when the style has finished loading. */ public interface OnStyleLoadedListener { /** - * Invoked when the style has finished loading. + * Invoked when the style has finished loading + * + * @param style the style that has been loaded */ void onStyleLoaded(String style); } 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 98f94ddb39..2efed1b322 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 @@ -378,7 +378,7 @@ public class MapboxMapOptions implements Parcelable { /** * Specifies the gravity state of mapbox_compass_icon for a map view. * - * @param gravity see {@link android.view.Gravity} + * @param gravity Android SDK Gravity. * @return This */ public MapboxMapOptions compassGravity(int gravity) { @@ -439,7 +439,7 @@ public class MapboxMapOptions implements Parcelable { /** * Specifies the gravity state of logo for a map view. * - * @param gravity see {@link android.view.Gravity} + * @param gravity Android SDK Gravity. * @return This */ public MapboxMapOptions logoGravity(int gravity) { @@ -472,7 +472,7 @@ public class MapboxMapOptions implements Parcelable { /** * Specifies the gravity state of attribution for a map view. * - * @param gravity see {@link android.view.Gravity} + * @param gravity Android SDK Gravity. * @return This */ public MapboxMapOptions attributionGravity(int gravity) { diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/TrackingSettings.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/TrackingSettings.java index 7dcd84de75..bd0bf7c83b 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/TrackingSettings.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/TrackingSettings.java @@ -6,11 +6,11 @@ import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.annotation.UiThread; +import com.mapbox.mapboxsdk.Mapbox; import com.mapbox.mapboxsdk.camera.CameraPosition; import com.mapbox.mapboxsdk.constants.MapboxConstants; import com.mapbox.mapboxsdk.constants.MyBearingTracking; import com.mapbox.mapboxsdk.constants.MyLocationTracking; -import com.mapbox.mapboxsdk.location.LocationSource; import com.mapbox.mapboxsdk.maps.widgets.MyLocationView; import com.mapbox.services.android.telemetry.location.LocationEngine; import com.mapbox.services.android.telemetry.location.LocationEngineListener; @@ -29,6 +29,8 @@ public final class TrackingSettings { private final CameraZoomInvalidator zoomInvalidator; private LocationEngine locationSource; private LocationEngineListener myLocationListener; + private boolean locationChangeAnimationEnabled = true; + private boolean isCustomLocationSource; private boolean myLocationEnabled; private boolean dismissLocationTrackingOnGesture = true; @@ -46,7 +48,7 @@ public final class TrackingSettings { } void initialise(MapboxMapOptions options) { - locationSource = LocationSource.getLocationEngine(myLocationView.getContext()); + locationSource = Mapbox.getLocationSource(); setMyLocationEnabled(options.getLocationEnabled()); } @@ -56,11 +58,16 @@ public final class TrackingSettings { outState.putBoolean(MapboxConstants.STATE_MY_LOCATION_TRACKING_DISMISS, isDismissLocationTrackingOnGesture()); outState.putBoolean(MapboxConstants.STATE_MY_BEARING_TRACKING_DISMISS, isDismissBearingTrackingOnGesture()); outState.putBoolean(MapboxConstants.STATE_MY_LOCATION_ENABLED, isMyLocationEnabled()); + outState.putBoolean(MapboxConstants.STATE_LOCATION_CHANGE_ANIMATION_ENABLED, isLocationChangeAnimationEnabled()); + outState.putBoolean(MapboxConstants.STATE_USING_CUSTOM_LOCATION_SOURCE, isCustomLocationSource()); } void onRestoreInstanceState(Bundle savedInstanceState) { try { - setMyLocationEnabled(savedInstanceState.getBoolean(MapboxConstants.STATE_MY_LOCATION_ENABLED)); + setMyLocationEnabled( + savedInstanceState.getBoolean(MapboxConstants.STATE_MY_LOCATION_ENABLED), + savedInstanceState.getBoolean(MapboxConstants.STATE_USING_CUSTOM_LOCATION_SOURCE) + ); } catch (SecurityException ignore) { // User did not accept location permissions } @@ -74,6 +81,8 @@ public final class TrackingSettings { MapboxConstants.STATE_MY_LOCATION_TRACKING_DISMISS, true)); setDismissBearingTrackingOnGesture(savedInstanceState.getBoolean( MapboxConstants.STATE_MY_BEARING_TRACKING_DISMISS, true)); + setLocationChangeAnimationEnabled(savedInstanceState.getBoolean( + MapboxConstants.STATE_LOCATION_CHANGE_ANIMATION_ENABLED, true)); } /** @@ -91,6 +100,7 @@ public final class TrackingSettings { */ @UiThread public void setMyLocationTrackingMode(@MyLocationTracking.Mode int myLocationTrackingMode) { + myLocationView.setLocationChangeAnimationEnabled(isLocationChangeAnimationEnabled()); myLocationView.setMyLocationTrackingMode(myLocationTrackingMode); if (myLocationTrackingMode == MyLocationTracking.TRACKING_FOLLOW) { @@ -254,6 +264,26 @@ public final class TrackingSettings { } /** + * Returns whether location change animation is applied for {@link MyLocationTracking#TRACKING_FOLLOW}. + * + * @return True if animation is applied, false otherwise. + */ + public boolean isLocationChangeAnimationEnabled() { + return locationChangeAnimationEnabled; + } + + /** + * Set whether location change animation should be applied for {@link MyLocationTracking#TRACKING_FOLLOW}. + * + * @param locationChangeAnimationEnabled True if animation should be applied, false otherwise. + */ + public void setLocationChangeAnimationEnabled(boolean locationChangeAnimationEnabled) { + this.locationChangeAnimationEnabled = locationChangeAnimationEnabled; + + myLocationView.setLocationChangeAnimationEnabled(locationChangeAnimationEnabled); + } + + /** * Reset the tracking modes as necessary. Location tracking is reset if the map center is changed and not from * location, bearing tracking if there is a rotation. * @@ -314,6 +344,10 @@ public final class TrackingSettings { } } + public boolean isCustomLocationSource() { + return isCustomLocationSource; + } + void setOnMyLocationTrackingModeChangeListener(MapboxMap.OnMyLocationTrackingModeChangeListener listener) { this.onMyLocationTrackingModeChangeListener = listener; } @@ -332,16 +366,30 @@ public final class TrackingSettings { } void setMyLocationEnabled(boolean locationEnabled) { + setMyLocationEnabled(locationEnabled, isCustomLocationSource()); + } + + private void setMyLocationEnabled(boolean locationEnabled, boolean isCustomLocationSource) { if (!PermissionsManager.areLocationPermissionsGranted(myLocationView.getContext())) { Timber.e("Could not activate user location tracking: " + "user did not accept the permission or permissions were not requested."); return; } myLocationEnabled = locationEnabled; - myLocationView.setEnabled(locationEnabled); + this.isCustomLocationSource = isCustomLocationSource; + myLocationView.setEnabled(locationEnabled, isCustomLocationSource); } void setLocationSource(LocationEngine locationSource) { + if (this.locationSource != null && this.locationSource.equals(locationSource)) { + // this source is already active + return; + } + + this.isCustomLocationSource = locationSource != null; + if (locationSource == null) { + locationSource = Mapbox.getLocationSource(); + } this.locationSource = locationSource; myLocationView.setLocationSource(locationSource); } diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Transform.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Transform.java index 7f44e0de07..d788b7772b 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Transform.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Transform.java @@ -79,7 +79,7 @@ final class Transform implements MapView.OnMapChangedListener { @Override public void onMapChanged(@MapView.MapChange int change) { - if (change == REGION_DID_CHANGE_ANIMATED && cameraCancelableCallback != null) { + if (change == REGION_DID_CHANGE_ANIMATED) { updateCameraPosition(invalidateCameraPosition()); if (cameraCancelableCallback != null) { cameraCancelableCallback.onFinish(); @@ -93,7 +93,7 @@ final class Transform implements MapView.OnMapChangedListener { @UiThread final void moveCamera(MapboxMap mapboxMap, CameraUpdate update, MapboxMap.CancelableCallback callback) { CameraPosition cameraPosition = update.getCameraPosition(mapboxMap); - if (!cameraPosition.equals(this.cameraPosition)) { + if (isValidCameraPosition(cameraPosition)) { trackingSettings.resetTrackingModesIfRequired(this.cameraPosition, cameraPosition, false); cancelTransitions(); cameraChangeDispatcher.onCameraMoveStarted(OnCameraMoveStartedListener.REASON_API_ANIMATION); @@ -109,15 +109,15 @@ final class Transform implements MapView.OnMapChangedListener { final void easeCamera(MapboxMap mapboxMap, CameraUpdate update, int durationMs, boolean easingInterpolator, final MapboxMap.CancelableCallback callback, boolean isDismissable) { CameraPosition cameraPosition = update.getCameraPosition(mapboxMap); - if (!cameraPosition.equals(this.cameraPosition)) { + if (isValidCameraPosition(cameraPosition)) { trackingSettings.resetTrackingModesIfRequired(this.cameraPosition, cameraPosition, isDismissable); cancelTransitions(); cameraChangeDispatcher.onCameraMoveStarted(OnCameraMoveStartedListener.REASON_API_ANIMATION); if (callback != null) { cameraCancelableCallback = callback; - mapView.addOnMapChangedListener(this); } + mapView.addOnMapChangedListener(this); mapView.easeTo(cameraPosition.bearing, cameraPosition.target, durationMs, cameraPosition.tilt, cameraPosition.zoom, easingInterpolator); } @@ -127,21 +127,24 @@ final class Transform implements MapView.OnMapChangedListener { final void animateCamera(MapboxMap mapboxMap, CameraUpdate update, int durationMs, final MapboxMap.CancelableCallback callback) { CameraPosition cameraPosition = update.getCameraPosition(mapboxMap); - if (!cameraPosition.equals(this.cameraPosition)) { + if (isValidCameraPosition(cameraPosition)) { trackingSettings.resetTrackingModesIfRequired(this.cameraPosition, cameraPosition, false); cancelTransitions(); cameraChangeDispatcher.onCameraMoveStarted(OnCameraMoveStartedListener.REASON_API_ANIMATION); if (callback != null) { cameraCancelableCallback = callback; - mapView.addOnMapChangedListener(this); } - + mapView.addOnMapChangedListener(this); mapView.flyTo(cameraPosition.bearing, cameraPosition.target, durationMs, cameraPosition.tilt, cameraPosition.zoom); } } + private boolean isValidCameraPosition(@Nullable CameraPosition cameraPosition) { + return cameraPosition != null && !cameraPosition.equals(this.cameraPosition); + } + @UiThread @Nullable CameraPosition invalidateCameraPosition() { @@ -151,6 +154,10 @@ final class Transform implements MapView.OnMapChangedListener { cameraChangeDispatcher.onCameraMove(); } + if (isComponentUpdateRequired(cameraPosition)) { + updateCameraPosition(cameraPosition); + } + this.cameraPosition = cameraPosition; if (onCameraChangeListener != null) { onCameraChangeListener.onCameraChange(this.cameraPosition); @@ -159,6 +166,11 @@ final class Transform implements MapView.OnMapChangedListener { return cameraPosition; } + private boolean isComponentUpdateRequired(@NonNull CameraPosition cameraPosition) { + return this.cameraPosition != null && (this.cameraPosition.tilt != cameraPosition.tilt + || this.cameraPosition.bearing != cameraPosition.bearing); + } + void cancelTransitions() { // notify user about cancel cameraChangeDispatcher.onCameraMoveCanceled(); @@ -203,6 +215,9 @@ final class Transform implements MapView.OnMapChangedListener { if (cameraPosition != null) { int newZoom = (int) Math.round(cameraPosition.zoom + (zoomIn ? 1 : -1)); setZoom(newZoom, focalPoint, MapboxConstants.ANIMATION_DURATION); + } else { + // we are not transforming, notify about being idle + cameraChangeDispatcher.onCameraIdle(); } } @@ -215,8 +230,8 @@ final class Transform implements MapView.OnMapChangedListener { @Override public void onMapChanged(int change) { if (change == MapView.REGION_DID_CHANGE_ANIMATED) { - mapView.removeOnMapChangedListener(this); cameraChangeDispatcher.onCameraIdle(); + mapView.removeOnMapChangedListener(this); } } }); @@ -315,7 +330,7 @@ final class Transform implements MapView.OnMapChangedListener { mapView.addOnMapChangedListener(new MapView.OnMapChangedListener() { @Override public void onMapChanged(int change) { - if (change == MapView.DID_FINISH_RENDERING_MAP_FULLY_RENDERED) { + if (change == MapView.REGION_DID_CHANGE_ANIMATED) { mapView.removeOnMapChangedListener(this); cameraChangeDispatcher.onCameraIdle(); } 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 285cd18089..e8891429f9 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 @@ -16,7 +16,6 @@ import android.support.annotation.Nullable; import android.support.annotation.UiThread; import android.support.v4.content.ContextCompat; import android.support.v4.content.res.ResourcesCompat; -import android.view.Gravity; import android.view.View; import android.widget.FrameLayout; import android.widget.ImageView; @@ -315,8 +314,7 @@ public final class UiSettings { * </p> * By default, the compass is in the top right corner. * - * @param gravity One of the values from {@link Gravity}. - * @see Gravity + * @param gravity Android SDK Gravity. */ @UiThread public void setCompassGravity(int gravity) { @@ -460,8 +458,7 @@ public final class UiSettings { * </p> * By default, the logo is in the bottom left corner. * - * @param gravity One of the values from {@link Gravity}. - * @see Gravity + * @param gravity Android SDK Gravity. */ public void setLogoGravity(int gravity) { setWidgetGravity(logoView, gravity); @@ -552,8 +549,7 @@ public final class UiSettings { * </p> * By default, the attribution is in the bottom left corner next to the Mapbox logo. * - * @param gravity One of the values from {@link Gravity}. - * @see Gravity + * @param gravity Android SDK Gravity. */ public void setAttributionGravity(int gravity) { setWidgetGravity(attributionsView, gravity); diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationView.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationView.java index f5ef46a5d3..8b6b93e03a 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationView.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationView.java @@ -26,6 +26,7 @@ import android.util.AttributeSet; import android.view.View; import android.view.ViewGroup; +import com.mapbox.mapboxsdk.Mapbox; import com.mapbox.mapboxsdk.camera.CameraPosition; import com.mapbox.mapboxsdk.camera.CameraUpdateFactory; import com.mapbox.mapboxsdk.constants.MyBearingTracking; @@ -40,8 +41,13 @@ import com.mapbox.services.android.telemetry.location.LocationEnginePriority; import java.lang.ref.WeakReference; +import timber.log.Timber; + /** * UI element overlaid on a map to show the user's location. + * <p> + * Use {@link MyLocationViewSettings} to manipulate the state of this view. + * </p> */ public class MyLocationView extends View { @@ -68,6 +74,7 @@ public class MyLocationView extends View { private ValueAnimator locationChangeAnimator; private ValueAnimator accuracyAnimator; private ValueAnimator directionAnimator; + private boolean locationChangeAnimationEnabled; private ValueAnimator.AnimatorUpdateListener invalidateSelfOnUpdateListener = new ValueAnimator.AnimatorUpdateListener() { @@ -147,6 +154,16 @@ public class MyLocationView extends View { compassListener = new CompassListener(context); } + public void init(LocationSource locationSource) { + this.locationSource = locationSource; + } + + /** + * Set the foreground drawable, for internal use only. + * + * @param defaultDrawable The drawable shown when showing this view + * @param bearingDrawable The drawable shown when tracking of bearing is enabled + */ public final void setForegroundDrawables(Drawable defaultDrawable, Drawable bearingDrawable) { if (defaultDrawable == null) { return; @@ -175,6 +192,11 @@ public class MyLocationView extends View { invalidateBounds(); } + /** + * Set the foreground drawable tint, for internal use only. + * + * @param color The color to tint the drawable with + */ public final void setForegroundDrawableTint(@ColorInt int color) { if (foregroundDrawable != null) { foregroundDrawable.mutate().setColorFilter(color, PorterDuff.Mode.SRC_IN); @@ -185,10 +207,24 @@ public class MyLocationView extends View { invalidate(); } + /** + * Set the shadow drawable, for internal use only. + * + * @param drawable The drawable shown as shadow + */ public final void setShadowDrawable(Drawable drawable) { setShadowDrawable(drawable, 0, 0, 0, 0); } + /** + * Set the shadow drawable with some additional offset. + * + * @param drawable The drawable shown as shadow + * @param left The left offset margin + * @param top The top offset margin + * @param right The right offset margin + * @param bottom The bottom offset margin + */ public final void setShadowDrawable(Drawable drawable, int left, int top, int right, int bottom) { if (drawable != null) { backgroundDrawable = drawable; @@ -202,6 +238,11 @@ public class MyLocationView extends View { invalidateBounds(); } + /** + * Set the shadow drawable tint color, for internal use only. + * + * @param color The tint color to apply + */ public final void setShadowDrawableTint(@ColorInt int color) { if (backgroundDrawable == null) { return; @@ -210,6 +251,11 @@ public class MyLocationView extends View { invalidate(); } + /** + * Set the accuracy tint color, for internal use only. + * + * @param color The tint color to apply + */ public final void setAccuracyTint(@ColorInt int color) { int alpha = accuracyPaint.getAlpha(); accuracyPaint.setColor(color); @@ -217,6 +263,11 @@ public class MyLocationView extends View { invalidate(); } + /** + * Set the accuracy alpha value, for internal use only. + * + * @param alpha The alpha accuracy value to apply + */ public final void setAccuracyAlpha(@IntRange(from = 0, to = 255) int alpha) { accuracyPaint.setAlpha(alpha); invalidate(); @@ -297,15 +348,25 @@ public class MyLocationView extends View { } // draw foreground - if (myBearingTrackingMode == MyBearingTracking.NONE || !compassListener.isSensorAvailable()) { + if (myBearingTrackingMode == MyBearingTracking.NONE) { if (foregroundDrawable != null) { foregroundDrawable.draw(canvas); } } else if (foregroundBearingDrawable != null && foregroundBounds != null) { - foregroundBearingDrawable.draw(canvas); + if (myBearingTrackingMode == MyBearingTracking.GPS || compassListener.isSensorAvailable()) { + foregroundBearingDrawable.draw(canvas); + } else { + // We are tracking MyBearingTracking.COMPASS, but sensor is not available. + foregroundDrawable.draw(canvas); + } } } + /** + * Set the tilt value, for internal use only. + * + * @param tilt The tilt to apply + */ public void setTilt(@FloatRange(from = 0, to = 60.0f) double tilt) { this.tilt = tilt; if (myLocationTrackingMode == MyLocationTracking.TRACKING_FOLLOW) { @@ -314,6 +375,11 @@ public class MyLocationView extends View { invalidate(); } + /** + * Set the bearing value, for internal use only. + * + * @param bearing The bearing to apply + */ public void setBearing(double bearing) { this.bearing = bearing; if (myLocationTrackingMode == MyLocationTracking.TRACKING_NONE) { @@ -327,6 +393,11 @@ public class MyLocationView extends View { } } + /** + * Set the bearing and tilt from a camera position, for internal use only. + * + * @param position The camera position to extract bearing and tilt from + */ public void setCameraPosition(CameraPosition position) { if (position != null) { setBearing(position.bearing); @@ -334,6 +405,9 @@ public class MyLocationView extends View { } } + /** + * Called when the hosting activity is starting, for internal use only. + */ public void onStart() { if (myBearingTrackingMode == MyBearingTracking.COMPASS && compassListener.isSensorAvailable()) { compassListener.onResume(); @@ -343,6 +417,9 @@ public class MyLocationView extends View { } } + /** + * Called when the hosting activity is stopping, for internal use only. + */ public void onStop() { compassListener.onPause(); toggleGps(false); @@ -374,6 +451,9 @@ public class MyLocationView extends View { } } + /** + * Update current locationstate. + */ public void update() { if (isEnabled()) { myLocationBehavior.invalidate(); @@ -388,13 +468,33 @@ public class MyLocationView extends View { this.projection = mapboxMap.getProjection(); } + /** + * Set the enabled state, for internal use only. + * + * @param enabled The value to set the state to + */ @Override public void setEnabled(boolean enabled) { + setEnabled(enabled, false); + } + + /** + * Set the enabled state, for internal use only. + * + * @param enabled The value to set the state to + * @param isCustomLocationSource Flag handling for handling user provided custom location source + */ + public void setEnabled(boolean enabled, boolean isCustomLocationSource) { super.setEnabled(enabled); setVisibility(enabled ? View.VISIBLE : View.INVISIBLE); - toggleGps(enabled); + toggleGps(enabled, isCustomLocationSource); } + /** + * Save the view instance state, for internal use only. + * + * @return the marshaled representation of the view state + */ @Override protected Parcelable onSaveInstanceState() { Bundle bundle = new Bundle(); @@ -403,6 +503,11 @@ public class MyLocationView extends View { return bundle; } + /** + * Restore the view instance state, for internal use only. + * + * @param state the marshalled representation of the state to restore + */ @Override public void onRestoreInstanceState(Parcelable state) { if (state instanceof Bundle) { @@ -413,22 +518,23 @@ public class MyLocationView extends View { super.onRestoreInstanceState(state); } + private void toggleGps(boolean enableGps) { + toggleGps(enableGps, mapboxMap != null && mapboxMap.getTrackingSettings().isCustomLocationSource()); + } + /** - * Enabled / Disable GPS location updates along with updating the UI + * Enabled / Disable GPS location updates along with updating the UI, for internal use only. * * @param enableGps true if GPS is to be enabled, false if GPS is to be disabled */ - private void toggleGps(boolean enableGps) { - if (locationSource == null) { - locationSource = LocationSource.getLocationEngine(this.getContext()); - } - + private void toggleGps(boolean enableGps, boolean isCustomLocationSource) { if (enableGps) { - // Set an initial location if one available - Location lastLocation = locationSource.getLastLocation(); - - if (lastLocation != null) { - setLocation(lastLocation); + if (locationSource == null) { + if (!isCustomLocationSource) { + locationSource = Mapbox.getLocationSource(); + } else { + return; + } } if (userLocationListener == null) { @@ -436,22 +542,34 @@ public class MyLocationView extends View { } locationSource.addLocationEngineListener(userLocationListener); + locationSource.setPriority(LocationEnginePriority.HIGH_ACCURACY); locationSource.activate(); } else { + if (locationSource == null) { + return; + } // Disable location and user dot location = null; - locationSource.removeLocationUpdates(); locationSource.removeLocationEngineListener(userLocationListener); + locationSource.removeLocationUpdates(); locationSource.deactivate(); } - - locationSource.setPriority(LocationEnginePriority.HIGH_ACCURACY); } + /** + * Get the current location. + * + * @return the current location + */ public Location getLocation() { return location; } + /** + * Set the current location, for internal use only. + * + * @param location The current location + */ public void setLocation(Location location) { if (location == null) { this.location = null; @@ -460,8 +578,27 @@ public class MyLocationView extends View { this.location = location; myLocationBehavior.updateLatLng(location); + + if (mapboxMap != null && myBearingTrackingMode == MyBearingTracking.GPS + && myLocationTrackingMode == MyLocationTracking.TRACKING_NONE) { + setBearing(mapboxMap.getCameraPosition().bearing); + } } + /** + * Set location change animation enabled, for internal use only. + * + * @param locationChangeAnimationEnabled True if location changes are animated + */ + public void setLocationChangeAnimationEnabled(boolean locationChangeAnimationEnabled) { + this.locationChangeAnimationEnabled = locationChangeAnimationEnabled; + } + + /** + * Set the bearing tracking mode, for internal use only. + * + * @param myBearingTrackingMode The bearing tracking mode + */ public void setMyBearingTrackingMode(@MyBearingTracking.Mode int myBearingTrackingMode) { this.myBearingTrackingMode = myBearingTrackingMode; if (myBearingTrackingMode == MyBearingTracking.COMPASS && compassListener.isSensorAvailable()) { @@ -478,6 +615,11 @@ public class MyLocationView extends View { invalidate(); } + /** + * Set the location tracking mode, for internla use only. + * + * @param myLocationTrackingMode The location tracking mode + */ public void setMyLocationTrackingMode(@MyLocationTracking.Mode int myLocationTrackingMode) { MyLocationBehaviorFactory factory = new MyLocationBehaviorFactory(); myLocationBehavior = factory.getBehavioralModel(myLocationTrackingMode); @@ -498,17 +640,32 @@ public class MyLocationView extends View { invalidate(); } + /** + * Get the location tracking mode, for internal use only. + * + * @return The location tracking mode + */ @MyLocationTracking.Mode public int getMyLocationTrackingMode() { return myLocationTrackingMode; } + /** + * Get the bearing tracking mode, for internal use only. + * + * @return the bearing tracking mode + */ @MyBearingTracking.Mode public int getMyBearingTrackingMode() { return myBearingTrackingMode; } + /** + * Set the compass bearing value, for internal use only. + * + * @param bearing The compas bearing value + */ private void setCompass(double bearing) { setCompass(bearing, 0 /* no animation */); } @@ -536,14 +693,29 @@ public class MyLocationView extends View { directionAnimator.start(); } + /** + * Get the center of this view in screen coordinates. + * + * @return the center of the view + */ public PointF getCenter() { return new PointF(getCenterX(), getCenterY()); } + /** + * Get the x value of the center of this view. + * + * @return the x value of the center of the view + */ private float getCenterX() { return (getX() + getMeasuredWidth()) / 2 + contentPaddingX - projectedX; } + /** + * Get the y value of the center of this view. + * + * @return the y value of the center of the view + */ private float getCenterY() { return (getY() + getMeasuredHeight()) / 2 + contentPaddingY - projectedY; } @@ -553,8 +725,16 @@ public class MyLocationView extends View { contentPaddingY = (padding[1] - padding[3]) / 2; } + /** + * Set the location source from which location updates are received, for internal use only. + * + * @param locationSource The location source to receive updates from + */ public void setLocationSource(LocationEngine locationSource) { + toggleGps(false); this.locationSource = locationSource; + this.userLocationListener = null; + setEnabled(isEnabled(), locationSource != null); } private static class GpsLocationListener implements LocationEngineListener { @@ -570,10 +750,12 @@ public class MyLocationView extends View { @Override public void onConnected() { MyLocationView locationView = userLocationView.get(); - if (locationView != null) { - LocationEngine locationEngine = locationSource.get(); - Location location = locationEngine.getLastLocation(); - locationView.setLocation(location); + LocationEngine locationEngine = locationSource.get(); + if (locationView != null && locationEngine != null) { + Location lastKnownLocation = locationEngine.getLastLocation(); + if (lastKnownLocation != null) { + locationView.setLocation(lastKnownLocation); + } locationEngine.requestLocationUpdates(); } } @@ -597,9 +779,9 @@ public class MyLocationView extends View { private final SensorManager sensorManager; private Sensor rotationVectorSensor; - float[] matrix = new float[9]; - float[] orientation = new float[3]; - + private float[] matrix = new float[9]; + private float[] orientation = new float[3]; + private boolean reportMissingSensor = true; // Compass data private long compassUpdateNextTimestamp = 0; @@ -617,6 +799,10 @@ public class MyLocationView extends View { } public boolean isSensorAvailable() { + if (rotationVectorSensor == null && reportMissingSensor) { + reportMissingSensor = false; + Timber.e("Sensor.TYPE_ROTATION_VECTOR is missing from this device. Unable to use MyBearingTracking.COMPASS."); + } return rotationVectorSensor != null; } @@ -701,6 +887,12 @@ public class MyLocationView extends View { private abstract class MyLocationBehavior { + MyLocationBehavior() { + if (latLng != null) { + locationUpdateTimestamp = SystemClock.elapsedRealtime(); + } + } + void updateLatLng(@NonNull Location newLocation) { location = newLocation; } @@ -767,9 +959,14 @@ public class MyLocationView extends View { // accuracy updateAccuracy(location); - // ease to new camera position with a linear interpolator - mapboxMap.easeCamera(CameraUpdateFactory.newCameraPosition(builder.build()), animationDuration, false, null, - true); + if (locationChangeAnimationEnabled) { + // ease to new camera position with a linear interpolator + mapboxMap.easeCamera(CameraUpdateFactory.newCameraPosition(builder.build()), animationDuration, false, null, + true); + } else { + mapboxMap.easeCamera(CameraUpdateFactory.newCameraPosition(builder.build()), 0, false, null, + true); + } } @Override @@ -811,7 +1008,11 @@ public class MyLocationView extends View { } locationChangeAnimator = ValueAnimator.ofFloat(0.0f, 1.0f); - locationChangeAnimator.setDuration(locationUpdateDuration); + if (locationChangeAnimationEnabled) { + locationChangeAnimator.setDuration(locationUpdateDuration); + } else { + locationChangeAnimator.setDuration(0); + } locationChangeAnimator.addUpdateListener(new MarkerCoordinateAnimatorListener(this, latLng, newLocation )); diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationViewSettings.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationViewSettings.java index e9d823ebda..2ad1bf7ebc 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationViewSettings.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationViewSettings.java @@ -5,9 +5,9 @@ import android.support.annotation.ColorInt; import android.support.annotation.IntRange; import android.support.annotation.NonNull; +import com.mapbox.mapboxsdk.camera.CameraPosition; import com.mapbox.mapboxsdk.constants.MyLocationTracking; import com.mapbox.mapboxsdk.maps.FocalPointChangeListener; -import com.mapbox.mapboxsdk.camera.CameraPosition; import com.mapbox.mapboxsdk.maps.MapboxMapOptions; import com.mapbox.mapboxsdk.maps.Projection; @@ -77,6 +77,11 @@ public class MyLocationViewSettings { this.focalPointChangeListener = focalPointChangedListener; } + /** + * Initialise this with MapboxMapOptions. + * + * @param options the options to initialise this class from + */ public void initialise(@NonNull MapboxMapOptions options) { CameraPosition position = options.getCamera(); if (position != null && !position.equals(CameraPosition.DEFAULT)) { diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/net/ConnectivityReceiver.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/net/ConnectivityReceiver.java index 7be56fa694..a1bd98b780 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/net/ConnectivityReceiver.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/net/ConnectivityReceiver.java @@ -24,7 +24,10 @@ public class ConnectivityReceiver extends BroadcastReceiver { private static ConnectivityReceiver INSTANCE; /** - * Get or create the singleton instance + * Get a single instance of ConnectivityReceiver. + * + * @param context the context to extract the application context from + * @return single instance of ConnectivityReceiver */ public static synchronized ConnectivityReceiver instance(Context context) { if (INSTANCE == null) { @@ -74,7 +77,7 @@ public class ConnectivityReceiver extends BroadcastReceiver { } /** - * @see BroadcastReceiver#onReceive(Context, Intent) + * {@inheritDoc} */ @Override public void onReceive(Context context, Intent intent) { diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/offline/OfflineManager.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/offline/OfflineManager.java index ce498da8f5..1cf3711255 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/offline/OfflineManager.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/offline/OfflineManager.java @@ -116,6 +116,12 @@ public class OfflineManager { }).start(); } + /** + * Get the single instance of offline manager. + * + * @param context the context used to host the offline manager + * @return the single instance of offline manager + */ public static synchronized OfflineManager getInstance(Context context) { if (instance == null) { instance = new OfflineManager(context); diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/offline/OfflineRegion.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/offline/OfflineRegion.java index fae53c2086..1b8c4121ef 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/offline/OfflineRegion.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/offline/OfflineRegion.java @@ -394,6 +394,7 @@ public class OfflineRegion { * After you call this method, you may not call any additional methods on this object. * </p> * + * @param bytes the metadata in bytes * @param callback the callback to be invoked */ public void updateMetadata(@NonNull final byte[] bytes, @NonNull final OfflineRegionUpdateMetadataCallback callback) { diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/offline/OfflineRegionStatus.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/offline/OfflineRegionStatus.java index 9c3655fbec..fe12dd46c4 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/offline/OfflineRegionStatus.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/offline/OfflineRegionStatus.java @@ -7,6 +7,7 @@ package com.mapbox.mapboxsdk.offline; * <p> * Note that the total required size in bytes is not currently available. A * future API release may provide an estimate of this number. + * </p> */ public class OfflineRegionStatus { @@ -51,6 +52,7 @@ public class OfflineRegionStatus { * Specifically, it is false during early phases of an offline download. Once * style and tile sources have been downloaded, it is possible to calculate the * precise number of required resources, at which point it is set to true. + * </p> */ private boolean requiredResourceCountIsPrecise = true; @@ -73,37 +75,93 @@ public class OfflineRegionStatus { } /** - * Is the region complete? + * Validates if the region download has completed + * + * @return true if download is complete, false if not */ public boolean isComplete() { return (completedResourceCount == requiredResourceCount); } + /** + * Returns the download state. + * <p> + * State is defined as + * </p> + * <ul> + * <li>{@link OfflineRegion#STATE_ACTIVE}</li> + * <li>{@link OfflineRegion#STATE_INACTIVE}</li> + * </ul> + * + * @return the download state. + */ @OfflineRegion.DownloadState public int getDownloadState() { return downloadState; } + /** + * Get the number of resources (inclusive of tiles) that have been fully downloaded + * and are ready for offline access. + * + * @return the amount of resources that have finished downloading. + */ public long getCompletedResourceCount() { return completedResourceCount; } + /** + * The cumulative size, in bytes, of all resources (inclusive of tiles) that have + * been fully downloaded. + * + * @return the size of the resources that have finished downloading + */ public long getCompletedResourceSize() { return completedResourceSize; } + /** + * Get the number of tiles that have been fully downloaded and are ready for + * offline access. + * + * @return the completed tile count + */ public long getCompletedTileCount() { return completedTileCount; } + /** + * Get the cumulative size, in bytes, of all tiles that have been fully downloaded. + * + * @return the completed tile size + */ public long getCompletedTileSize() { return completedTileSize; } + /** + * Get the number of resources that are known to be required for this region. See the + * documentation for `requiredResourceCountIsPrecise` for an important caveat + * about this number. + * + * @return the amount of resources that are required + */ public long getRequiredResourceCount() { return requiredResourceCount; } + /** + * Returns when the value of requiredResourceCount is a precise + * count of the number of required resources, and false when it is merely a lower + * bound. + * <p> + * Specifically, it is false during early phases of an offline download. Once + * style and tile sources have been downloaded, it is possible to calculate the + * precise number of required resources, at which point it is set to true. + * </p> + * + * @return True if the required resource count is precise, false if not + */ public boolean isRequiredResourceCountPrecise() { return requiredResourceCountIsPrecise; } diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/storage/FileSource.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/storage/FileSource.java index 06676d76a1..eafef80e8d 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/storage/FileSource.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/storage/FileSource.java @@ -3,9 +3,9 @@ package com.mapbox.mapboxsdk.storage; import android.content.Context; import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager; +import android.content.res.AssetManager; import android.os.Environment; import android.support.annotation.NonNull; -import android.content.res.AssetManager; import com.mapbox.mapboxsdk.Mapbox; import com.mapbox.mapboxsdk.constants.MapboxConstants; @@ -28,8 +28,9 @@ public class FileSource { /** * Called whenever a URL needs to be transformed. * - * @param kind The kind of URL to be transformed. - * @return A URL that will now be downloaded. + * @param kind the kind of URL to be transformed. + * @param url the URL to be transformed + * @return a URL that will now be downloaded. */ String onURL(@Resource.Kind int kind, String url); @@ -38,6 +39,12 @@ public class FileSource { // File source instance is kept alive after initialization private static FileSource INSTANCE; + /** + * Get the single instance of FileSource. + * + * @param context the context to derive the cache path from + * @return the single instance of FileSource + */ public static synchronized FileSource getInstance(Context context) { if (INSTANCE == null) { String cachePath = getCachePath(context); @@ -47,6 +54,12 @@ public class FileSource { return INSTANCE; } + /** + * Get the cache path for a context. + * + * @param context the context to derive the cache path from + * @return the cache path + */ public static String getCachePath(Context context) { // Default value boolean setStorageExternal = MapboxConstants.DEFAULT_SET_STORAGE_EXTERNAL; diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/PropertyValue.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/PropertyValue.java index 68727c8a4f..a57c440df4 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/PropertyValue.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/PropertyValue.java @@ -30,14 +30,29 @@ public class PropertyValue<T> { this.value = value; } + /** + * Returns if this is null + * + * @return true if this is null, false if not + */ public boolean isNull() { return value == null; } + /** + * Returns if this is a function. + * + * @return true if is a function, false if not + */ public boolean isFunction() { return !isNull() && value instanceof Function; } + /** + * Returns if this is a value. + * + * @return true if is a value, false if not + */ public boolean isValue() { return !isNull() && !isFunction(); } @@ -53,6 +68,11 @@ public class PropertyValue<T> { } } + /** + * Get the value of the property. + * + * @return the property value + */ @Nullable public T getValue() { if (isValue()) { @@ -64,6 +84,11 @@ public class PropertyValue<T> { } } + /** + * Get the color int value of the property if the value is a color. + * + * @return the color int value of the property, null if not a color value + */ @ColorInt @Nullable public Integer getColorInt() { @@ -80,6 +105,11 @@ public class PropertyValue<T> { } } + /** + * Get the string representation of a property value. + * + * @return the string representation + */ @Override public String toString() { return String.format("%s: %s", name, value); diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/light/Light.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/light/Light.java index b66a50b8a4..cb6465a6b1 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/light/Light.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/light/Light.java @@ -13,7 +13,7 @@ import com.mapbox.mapboxsdk.style.layers.TransitionOptions; /** * The global light source. * - * @see <a href="https://www.mapbox.com/mapbox-gl-style-spec/#light>">The online documentation</a> + * @see <a href="https://www.mapbox.com/mapbox-gl-style-spec/#light">The online documentation</a> */ @UiThread public class Light { @@ -43,7 +43,8 @@ public class Light { * * @return anchor as String */ - @Property.ANCHOR public String getAnchor() { + @Property.ANCHOR + public String getAnchor() { return nativeGetAnchor(); } @@ -106,7 +107,7 @@ public class Light { * * @return color as String */ - public String getColor() { + public String getColor() { return nativeGetColor(); } @@ -142,7 +143,7 @@ public class Light { * * @return intensity as Float */ - public float getIntensity() { + public float getIntensity() { return nativeGetIntensity(); } @@ -165,17 +166,30 @@ public class Light { } private native void nativeSetAnchor(String anchor); + private native String nativeGetAnchor(); + private native void nativeSetPosition(Position position); + private native Position nativeGetPosition(); + private native TransitionOptions nativeGetPositionTransition(); + private native void nativeSetPositionTransition(long duration, long delay); + private native void nativeSetColor(String color); + private native String nativeGetColor(); + private native TransitionOptions nativeGetColorTransition(); + private native void nativeSetColorTransition(long duration, long delay); + private native void nativeSetIntensity(float intensity); + private native float nativeGetIntensity(); + private native TransitionOptions nativeGetIntensityTransition(); + private native void nativeSetIntensityTransition(long duration, long delay); }
\ No newline at end of file diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/light/Position.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/light/Position.java index 215db03ad2..cd6218d3e2 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/light/Position.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/light/Position.java @@ -18,7 +18,7 @@ public class Position { private float polarAngle; /** - * Creates a Position from a radial coordinate, an azimuthal angle & a polar angle. + * Creates a Position from a radial coordinate, an azimuthal angle and a polar angle. * * @param radialCoordinate the distance from the center of the base of an object to its light * @param azimuthalAngle the position of the light relative to 0° @@ -31,7 +31,7 @@ public class Position { } /** - * Returns a Position from a radial coordinate, an azimuthal angle & a polar angle + * Returns a Position from a radial coordinate, an azimuthal angle and a polar angle * * @param radialCoordinate the radial coordinate * @param azimuthalAngle the azimuthal angle diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/light/light.java.ejs b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/light/light.java.ejs index 067efe1092..80d927128d 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/light/light.java.ejs +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/light/light.java.ejs @@ -17,7 +17,7 @@ import com.mapbox.mapboxsdk.style.layers.TransitionOptions; /** * The global light source. * - * @see <a href="https://www.mapbox.com/mapbox-gl-style-spec/#light>">The online documentation</a> + * @see <a href="https://www.mapbox.com/mapbox-gl-style-spec/#light">The online documentation</a> */ @UiThread public class Light { diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/utils/BitmapUtils.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/utils/BitmapUtils.java index e3fc765734..af3a79539f 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/utils/BitmapUtils.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/utils/BitmapUtils.java @@ -5,8 +5,17 @@ import android.graphics.Canvas; import android.support.annotation.NonNull; import android.view.View; +/** + * Utility class for creating bitmaps + */ public class BitmapUtils { + /** + * Convert a view to a bitmap. + * + * @param view the view to convert + * @return the converted bitmap + */ public static Bitmap createBitmapFromView(@NonNull View view) { view.setDrawingCacheEnabled(true); view.setDrawingCacheQuality(View.DRAWING_CACHE_QUALITY_LOW); @@ -22,6 +31,13 @@ public class BitmapUtils { return snapshot; } + /** + * Create a bitmap from a background and a foreground bitmap + * + * @param background The bitmap placed in the background + * @param foreground The bitmap placed in the foreground + * @return the merged bitmap + */ public static Bitmap mergeBitmap(@NonNull Bitmap background, @NonNull Bitmap foreground) { Bitmap result = Bitmap.createBitmap(background.getWidth(), background.getHeight(), background.getConfig()); Canvas canvas = new Canvas(result); diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/utils/ColorUtils.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/utils/ColorUtils.java index 24c76243d9..14b18b00dc 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/utils/ColorUtils.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/utils/ColorUtils.java @@ -23,7 +23,7 @@ import java.util.regex.Pattern; public class ColorUtils { /** - * Returns a color integer associated as primary color from a theme based on a {@link Context}. + * Returns a color integer associated as primary color from a theme based on a Context. * * @param context The context used to style the color attributes. * @return The primary color value of current theme in the form 0xAARRGGBB. @@ -37,7 +37,7 @@ public class ColorUtils { } /** - * Returns a color integer associated as primary dark color from a theme based on a {@link Context}. + * Returns a color integer associated as primary dark color from a theme based on a Context. * * @param context The context used to style the color attributes. * @return The primary dark color value of current theme in the form 0xAARRGGBB. @@ -51,7 +51,7 @@ public class ColorUtils { } /** - * Returns a color integer associated as accent color from a theme based on a {@link Context}. + * Returns a color integer associated as accent color from a theme based on a Context. * * @param context The context used to style the color attributes. * @return The accent color value of current theme in the form 0xAARRGGBB. @@ -65,7 +65,7 @@ public class ColorUtils { } /** - * Returns a color state list associated with a theme based on a {@link Context} + * Returns a color state list associated with a theme based on a Context. * * @param color The color used for tinting. * @return A ColorStateList object containing the primary color of a theme @@ -85,7 +85,7 @@ public class ColorUtils { } /** - * Set a color tint list to the {@link Drawable} of an {@link ImageView}. + * Set a color tint list to the Drawable of an ImageView. * * @param imageView The view to set the default tint list. * @param tintColor The color to tint. diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/utils/MapFragmentUtils.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/utils/MapFragmentUtils.java index f810d6231d..007880acd1 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/utils/MapFragmentUtils.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/utils/MapFragmentUtils.java @@ -18,12 +18,25 @@ import com.mapbox.mapboxsdk.maps.MapboxMapOptions; */ public class MapFragmentUtils { + /** + * Convert MapboxMapOptions to a bundle of fragment arguments. + * + * @param options The MapboxMapOptions to convert + * @return a bundle of converted fragment arguments + */ public static Bundle createFragmentArgs(MapboxMapOptions options) { Bundle bundle = new Bundle(); bundle.putParcelable(MapboxConstants.FRAG_ARG_MAPBOXMAPOPTIONS, options); return bundle; } + /** + * Convert a bundle of fragment arguments to MapboxMapOptions. + * + * @param context The context of the activity hosting the fragment + * @param args The fragment arguments + * @return converted MapboxMapOptions + */ public static MapboxMapOptions resolveArgs(Context context, Bundle args) { MapboxMapOptions options; if (args != null && args.containsKey(MapboxConstants.FRAG_ARG_MAPBOXMAPOPTIONS)) { diff --git a/platform/android/MapboxGLAndroidSDK/src/main/resources/fabric/com.mapbox.mapboxsdk.mapbox-android-sdk.properties b/platform/android/MapboxGLAndroidSDK/src/main/resources/fabric/com.mapbox.mapboxsdk.mapbox-android-sdk.properties index bc0350fe1f..029d25e046 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/resources/fabric/com.mapbox.mapboxsdk.mapbox-android-sdk.properties +++ b/platform/android/MapboxGLAndroidSDK/src/main/resources/fabric/com.mapbox.mapboxsdk.mapbox-android-sdk.properties @@ -1,3 +1,3 @@ fabric-identifier=com.mapbox.mapboxsdk.mapbox-android-sdk -fabric-version=5.0.1 +fabric-version=5.1.0 fabric-build-type=binary diff --git a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/MapboxTest.java b/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/MapboxTest.java index 6ee5c157b9..e05190cd57 100644 --- a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/MapboxTest.java +++ b/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/MapboxTest.java @@ -5,6 +5,7 @@ import android.net.ConnectivityManager; import android.net.NetworkInfo; import com.mapbox.mapboxsdk.exceptions.MapboxConfigurationException; +import com.mapbox.mapboxsdk.location.LocationSource; import org.junit.Before; import org.junit.Test; @@ -24,11 +25,13 @@ public class MapboxTest { private Context context; private Context appContext; + private LocationSource locationSource; @Before public void before() { context = mock(Context.class); appContext = mock(Context.class); + locationSource = mock(LocationSource.class); when(context.getApplicationContext()).thenReturn(appContext); } @@ -80,7 +83,7 @@ public class MapboxTest { } private void injectMapboxSingleton(String accessToken) { - Mapbox mapbox = new Mapbox(appContext, accessToken); + Mapbox mapbox = new Mapbox(appContext, accessToken, locationSource); try { Field field = Mapbox.class.getDeclaredField("INSTANCE"); field.setAccessible(true); diff --git a/platform/android/MapboxGLAndroidSDKTestApp/gradle-checkstyle.gradle b/platform/android/MapboxGLAndroidSDKTestApp/gradle-checkstyle.gradle index fdc4399f16..e4e1ba0453 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/gradle-checkstyle.gradle +++ b/platform/android/MapboxGLAndroidSDKTestApp/gradle-checkstyle.gradle @@ -13,6 +13,7 @@ task checkstyle(type: Checkstyle) { include '**/*.java' exclude '**/gen/**' exclude '**/style/*LayerTest.java' + exclude '**/style/LightTest.java' classpath = files() ignoreFailures = false } diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/action/MapboxMapAction.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/action/MapboxMapAction.java new file mode 100644 index 0000000000..47af80cab9 --- /dev/null +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/action/MapboxMapAction.java @@ -0,0 +1,49 @@ +package com.mapbox.mapboxsdk.testapp.action; + +import android.support.test.espresso.UiController; +import android.support.test.espresso.ViewAction; +import android.view.View; + +import com.mapbox.mapboxsdk.maps.MapboxMap; + +import org.hamcrest.Matcher; + +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 MapboxMapAction implements ViewAction { + + private OnInvokeActionListener invokeViewAction; + private MapboxMap mapboxMap; + + private MapboxMapAction(OnInvokeActionListener invokeViewAction, MapboxMap mapboxMap) { + this.invokeViewAction = invokeViewAction; + this.mapboxMap = mapboxMap; + } + + @Override + public Matcher<View> getConstraints() { + return isDisplayed(); + } + + @Override + public String getDescription() { + return getClass().getSimpleName(); + } + + @Override + public void perform(UiController uiController, View view) { + invokeViewAction.onInvokeAction(uiController, mapboxMap); + } + + public static void invoke(MapboxMap mapboxMap, OnInvokeActionListener invokeViewAction) { + onView(withId(android.R.id.content)).perform(new MapboxMapAction(invokeViewAction, mapboxMap)); + } + + public interface OnInvokeActionListener { + void onInvokeAction(UiController uiController, MapboxMap mapboxMap); + } +} + + diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/annotations/MarkerTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/annotations/MarkerTest.java index 2f638ff651..e511135b99 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/annotations/MarkerTest.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/annotations/MarkerTest.java @@ -1,27 +1,24 @@ package com.mapbox.mapboxsdk.testapp.annotations; import android.support.test.espresso.UiController; -import android.support.test.espresso.ViewAction; -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.action.MapboxMapAction; import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest; import com.mapbox.mapboxsdk.testapp.activity.espresso.EspressoTestActivity; import com.mapbox.mapboxsdk.testapp.utils.TestConstants; -import org.hamcrest.Matcher; import org.junit.Ignore; import org.junit.Test; import static android.support.test.espresso.Espresso.onView; import static android.support.test.espresso.assertion.ViewAssertions.matches; import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed; -import static android.support.test.espresso.matcher.ViewMatchers.withId; import static android.support.test.espresso.matcher.ViewMatchers.withText; +import static com.mapbox.mapboxsdk.testapp.action.MapboxMapAction.invoke; import static org.junit.Assert.assertEquals; public class MarkerTest extends BaseActivityTest { @@ -37,87 +34,45 @@ public class MarkerTest extends BaseActivityTest { @Ignore public void addMarkerTest() { validateTestSetup(); - 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()); + MapboxMapAction.invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + 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); + marker = mapboxMap.addMarker(options); + + assertEquals("Markers size 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 @Ignore public void showInfoWindowTest() { validateTestSetup(); - - 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)); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + final MarkerOptions options = new MarkerOptions(); + options.setPosition(new LatLng()); + options.setSnippet(TestConstants.TEXT_MARKER_SNIPPET); + options.setTitle(TestConstants.TEXT_MARKER_TITLE); + marker = mapboxMap.addMarker(options); + mapboxMap.selectMarker(marker); + } + }); 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); - - } - } } diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/annotations/MarkerViewTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/annotations/MarkerViewTest.java index bee20c3150..8bf847c2e7 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/annotations/MarkerViewTest.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/annotations/MarkerViewTest.java @@ -1,28 +1,25 @@ package com.mapbox.mapboxsdk.testapp.annotations; import android.support.test.espresso.UiController; -import android.support.test.espresso.ViewAction; -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.action.MapboxMapAction; import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest; 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.TestConstants; -import org.hamcrest.Matcher; import org.junit.Ignore; import org.junit.Test; import static android.support.test.espresso.Espresso.onView; import static android.support.test.espresso.assertion.ViewAssertions.matches; import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed; -import static android.support.test.espresso.matcher.ViewMatchers.withId; import static android.support.test.espresso.matcher.ViewMatchers.withText; +import static com.mapbox.mapboxsdk.testapp.action.MapboxMapAction.invoke; import static org.junit.Assert.assertEquals; public class MarkerViewTest extends BaseActivityTest { @@ -38,20 +35,26 @@ public class MarkerViewTest extends BaseActivityTest { @Ignore public void addMarkerViewTest() { validateTestSetup(); - 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()); + addAdapter(); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + 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); + marker = mapboxMap.addMarker(options); + assertEquals("Markers size 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()); + uiController.loopMainThreadForAtLeast(500); + } + }); onView(withText(TestConstants.TEXT_MARKER_TEXT)).check(matches(isDisplayed())); } @@ -59,71 +62,33 @@ public class MarkerViewTest extends BaseActivityTest { @Ignore public void showInfoWindowTest() { validateTestSetup(); - - 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)); + addAdapter(); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + 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); + marker = mapboxMap.addMarker(options); + uiController.loopMainThreadForAtLeast(500); + mapboxMap.selectMarker(marker); + } + }); 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); - uiController.loopMainThreadForAtLeast(250); - } + private void addAdapter() { + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + mapboxMap.getMarkerViewManager().addMarkerViewAdapter( + new MarkerViewActivity.TextAdapter(rule.getActivity(), mapboxMap)); + } + }); } - 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); - uiController.loopMainThreadForAtLeast(250); - } - } } diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/annotations/PolygonTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/annotations/PolygonTest.java index 325568bec4..c90a5f60c6 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/annotations/PolygonTest.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/annotations/PolygonTest.java @@ -2,24 +2,19 @@ package com.mapbox.mapboxsdk.testapp.annotations; import android.graphics.Color; import android.support.test.espresso.UiController; -import android.support.test.espresso.ViewAction; -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.action.MapboxMapAction; import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest; import com.mapbox.mapboxsdk.testapp.activity.espresso.EspressoTestActivity; -import org.hamcrest.Matcher; import org.junit.Ignore; 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 com.mapbox.mapboxsdk.testapp.action.MapboxMapAction.invoke; import static org.junit.Assert.assertEquals; public class PolygonTest extends BaseActivityTest { @@ -29,60 +24,35 @@ public class PolygonTest extends BaseActivityTest { return EspressoTestActivity.class; } - private Polygon polygon; - @Test @Ignore - /** native crash **/ public void addPolygonTest() { validateTestSetup(); - 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); - } + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + 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); + Polygon polygon = mapboxMap.addPolygon(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()); + } + }); } } diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/annotations/PolylineTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/annotations/PolylineTest.java index 91553f7042..e6aa661729 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/annotations/PolylineTest.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/annotations/PolylineTest.java @@ -2,82 +2,53 @@ package com.mapbox.mapboxsdk.testapp.annotations; import android.graphics.Color; import android.support.test.espresso.UiController; -import android.support.test.espresso.ViewAction; -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.action.MapboxMapAction; import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest; import com.mapbox.mapboxsdk.testapp.activity.espresso.EspressoTestActivity; -import org.hamcrest.Matcher; import org.junit.Ignore; 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 com.mapbox.mapboxsdk.testapp.action.MapboxMapAction.invoke; import static org.junit.Assert.assertEquals; public class PolylineTest extends BaseActivityTest { - private Polyline polyline; - @Override protected Class getActivityClass() { return EspressoTestActivity.class; } - @Ignore @Test + @Ignore public void addPolylineTest() { validateTestSetup(); - 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); - } + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + 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); + Polyline polyline = mapboxMap.addPolyline(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()); + } + }); } } 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 af1a146ca2..c16c8f05bb 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 @@ -2,27 +2,21 @@ package com.mapbox.mapboxsdk.testapp.camera; import android.graphics.PointF; 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.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.action.MapboxMapAction; import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest; import com.mapbox.mapboxsdk.testapp.activity.espresso.EspressoTestActivity; import com.mapbox.mapboxsdk.testapp.utils.TestConstants; -import org.hamcrest.Matcher; import org.junit.Ignore; 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 com.mapbox.mapboxsdk.testapp.action.MapboxMapAction.invoke; import static org.junit.Assert.assertEquals; public class CameraAnimateTest extends BaseActivityTest { @@ -36,202 +30,199 @@ public class CameraAnimateTest extends BaseActivityTest { @Ignore public void testAnimateToCameraPositionTarget() { validateTestSetup(); - - /*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); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + 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); + mapboxMap.animateCamera(CameraUpdateFactory.newLatLng(moveTarget)); + uiController.loopMainThreadForAtLeast(TestConstants.ANIMATION_TEST_TIME); + 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 @Ignore public void testAnimateToCameraPositionTargetZoom() { validateTestSetup(); - - 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); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + final float moveZoom = 15.5f; + final LatLng moveTarget = new LatLng(1.0000000001, 1.0000000003); + mapboxMap.animateCamera(CameraUpdateFactory.newLatLngZoom(moveTarget, moveZoom)); + uiController.loopMainThreadForAtLeast(TestConstants.ANIMATION_TEST_TIME); + 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 @Ignore public void testAnimateToCameraPosition() { validateTestSetup(); - - 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); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + final LatLng moveTarget = new LatLng(1.0000000001, 1.0000000003); + final float moveZoom = 15.5f; + final float moveTilt = 45.5f; + final float moveBearing = 12.5f; + + mapboxMap.animateCamera(CameraUpdateFactory.newCameraPosition( + new CameraPosition.Builder() + .target(moveTarget) + .zoom(moveZoom) + .tilt(moveTilt) + .bearing(moveBearing) + .build()) + ); + uiController.loopMainThreadForAtLeast(TestConstants.ANIMATION_TEST_TIME); + 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 @Ignore public void testAnimateToBounds() { validateTestSetup(); - - 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); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + 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); + mapboxMap.animateCamera(CameraUpdateFactory.newLatLngBounds(builder.build(), 0)); + uiController.loopMainThreadForAtLeast(TestConstants.ANIMATION_TEST_TIME); + 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 @Ignore public void testAnimateToMoveBy() { validateTestSetup(); - - 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); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + final PointF centerPoint = mapboxMap.getProjection().toScreenLocation(mapboxMap.getCameraPosition().target); + final LatLng moveTarget = new LatLng(2, 2); + final PointF moveTargetPoint = mapboxMap.getProjection().toScreenLocation(moveTarget); + mapboxMap.animateCamera(CameraUpdateFactory.scrollBy( + moveTargetPoint.x - centerPoint.x, moveTargetPoint.y - centerPoint.y)); + uiController.loopMainThreadForAtLeast(TestConstants.ANIMATION_TEST_TIME); + 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 @Ignore public void testAnimateToZoomIn() { validateTestSetup(); - - /*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); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + float zoom = 1.0f; + mapboxMap.animateCamera(CameraUpdateFactory.zoomIn()); + uiController.loopMainThreadForAtLeast(TestConstants.ANIMATION_TEST_TIME); + CameraPosition cameraPosition = mapboxMap.getCameraPosition(); + assertEquals("Moved camera zoom should match moved camera zoom", cameraPosition.zoom, zoom + 1, + TestConstants.ZOOM_DELTA); + } + }); } @Test @Ignore public void testAnimateToZoomOut() { validateTestSetup(); - - /*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); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + float zoom = 10.0f; + mapboxMap.animateCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(), zoom)); + uiController.loopMainThreadForAtLeast(TestConstants.ANIMATION_TEST_TIME); + mapboxMap.animateCamera(CameraUpdateFactory.zoomOut()); + uiController.loopMainThreadForAtLeast(TestConstants.ANIMATION_TEST_TIME); + CameraPosition cameraPosition = mapboxMap.getCameraPosition(); + assertEquals("Moved camera zoom should match moved camera zoom", cameraPosition.zoom, zoom - 1, + TestConstants.ZOOM_DELTA); + } + }); } @Test @Ignore public void testAnimateToZoomBy() { validateTestSetup(); - - /*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); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + float zoom = 1.0f; + final float zoomBy = 2.45f; + mapboxMap.animateCamera(CameraUpdateFactory.zoomBy(zoomBy)); + uiController.loopMainThreadForAtLeast(TestConstants.ANIMATION_TEST_TIME); + CameraPosition cameraPosition = mapboxMap.getCameraPosition(); + assertEquals("Moved camera zoom should match moved camera zoom", cameraPosition.zoom, zoom + zoomBy, + TestConstants.ZOOM_DELTA); + } + }); } @Test @Ignore public void testAnimateToZoomTo() { validateTestSetup(); - - /*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); - } - - 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(TestConstants.ANIMATION_TEST_TIME); - } + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + final float zoomTo = 2.45f; + mapboxMap.animateCamera(CameraUpdateFactory.zoomTo(zoomTo)); + uiController.loopMainThreadForAtLeast(TestConstants.ANIMATION_TEST_TIME); + CameraPosition cameraPosition = mapboxMap.getCameraPosition(); + assertEquals("Moved camera zoom should match moved camera zoom", cameraPosition.zoom, zoomTo, + TestConstants.ZOOM_DELTA); + } + }); } } 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 4fae894039..8c67af7da3 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 @@ -2,27 +2,21 @@ package com.mapbox.mapboxsdk.testapp.camera; import android.graphics.PointF; 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.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.action.MapboxMapAction; import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest; import com.mapbox.mapboxsdk.testapp.activity.espresso.EspressoTestActivity; import com.mapbox.mapboxsdk.testapp.utils.TestConstants; -import org.hamcrest.Matcher; import org.junit.Ignore; 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 com.mapbox.mapboxsdk.testapp.action.MapboxMapAction.invoke; import static org.junit.Assert.assertEquals; public class CameraEaseTest extends BaseActivityTest { @@ -36,201 +30,198 @@ public class CameraEaseTest extends BaseActivityTest { @Ignore public void testEaseToCameraPositionTarget() { validateTestSetup(); - - /*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); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + 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); + mapboxMap.easeCamera(CameraUpdateFactory.newLatLng(moveTarget)); + uiController.loopMainThreadForAtLeast(TestConstants.ANIMATION_TEST_TIME); + 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 @Ignore public void testEaseToCameraPositionTargetZoom() { validateTestSetup(); - - 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); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + final float moveZoom = 15.5f; + final LatLng moveTarget = new LatLng(1.0000000001, 1.0000000003); + mapboxMap.easeCamera(CameraUpdateFactory.newLatLngZoom(moveTarget, moveZoom)); + uiController.loopMainThreadForAtLeast(TestConstants.ANIMATION_TEST_TIME); + 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 @Ignore public void testEaseToCameraPosition() { validateTestSetup(); - - 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); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + final LatLng moveTarget = new LatLng(1.0000000001, 1.0000000003); + final float moveZoom = 15.5f; + final float moveTilt = 45.5f; + final float moveBearing = 12.5f; + + mapboxMap.easeCamera(CameraUpdateFactory.newCameraPosition( + new CameraPosition.Builder() + .target(moveTarget) + .zoom(moveZoom) + .tilt(moveTilt) + .bearing(moveBearing) + .build()) + ); + uiController.loopMainThreadForAtLeast(TestConstants.ANIMATION_TEST_TIME); + 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 @Ignore public void testEaseToBounds() { validateTestSetup(); - - 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); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + 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); + mapboxMap.easeCamera(CameraUpdateFactory.newLatLngBounds(builder.build(), 0)); + uiController.loopMainThreadForAtLeast(TestConstants.ANIMATION_TEST_TIME); + 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 @Ignore public void testEaseToMoveBy() { validateTestSetup(); - - 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); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + final PointF centerPoint = mapboxMap.getProjection().toScreenLocation(mapboxMap.getCameraPosition().target); + final LatLng moveTarget = new LatLng(2, 2); + final PointF moveTargetPoint = mapboxMap.getProjection().toScreenLocation(moveTarget); + mapboxMap.easeCamera(CameraUpdateFactory.scrollBy( + moveTargetPoint.x - centerPoint.x, moveTargetPoint.y - centerPoint.y)); + uiController.loopMainThreadForAtLeast(TestConstants.ANIMATION_TEST_TIME); + 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 @Ignore public void testEaseToZoomIn() { validateTestSetup(); - - /*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); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + float zoom = 1.0f; + mapboxMap.easeCamera(CameraUpdateFactory.zoomIn()); + uiController.loopMainThreadForAtLeast(TestConstants.ANIMATION_TEST_TIME); + CameraPosition cameraPosition = mapboxMap.getCameraPosition(); + assertEquals("Moved camera zoom should match moved camera zoom", cameraPosition.zoom, zoom + 1, + TestConstants.ZOOM_DELTA); + } + }); } @Test @Ignore public void testEaseToZoomOut() { validateTestSetup(); - - /*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); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + float zoom = 10.0f; + mapboxMap.easeCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(), zoom)); + uiController.loopMainThreadForAtLeast(TestConstants.ANIMATION_TEST_TIME); + mapboxMap.easeCamera(CameraUpdateFactory.zoomOut()); + uiController.loopMainThreadForAtLeast(TestConstants.ANIMATION_TEST_TIME); + CameraPosition cameraPosition = mapboxMap.getCameraPosition(); + assertEquals("Moved camera zoom should match moved camera zoom", cameraPosition.zoom, zoom - 1, + TestConstants.ZOOM_DELTA); + } + }); } @Test @Ignore public void testEaseToZoomBy() { validateTestSetup(); - - /*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); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + float zoom = 1.0f; + final float zoomBy = 2.45f; + mapboxMap.easeCamera(CameraUpdateFactory.zoomBy(zoomBy)); + uiController.loopMainThreadForAtLeast(TestConstants.ANIMATION_TEST_TIME); + CameraPosition cameraPosition = mapboxMap.getCameraPosition(); + assertEquals("Moved camera zoom should match moved camera zoom", cameraPosition.zoom, zoom + zoomBy, + TestConstants.ZOOM_DELTA); + } + }); } @Test @Ignore public void testEaseToZoomTo() { validateTestSetup(); - - /*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); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + final float zoomTo = 2.45f; + mapboxMap.easeCamera(CameraUpdateFactory.zoomTo(zoomTo)); + uiController.loopMainThreadForAtLeast(TestConstants.ANIMATION_TEST_TIME); + CameraPosition cameraPosition = mapboxMap.getCameraPosition(); + assertEquals("Moved camera zoom should match moved camera zoom", cameraPosition.zoom, zoomTo, + TestConstants.ZOOM_DELTA); + } + }); } - - 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(TestConstants.ANIMATION_TEST_TIME); - } - } -} - +}
\ No newline at end of file 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 ea8398fc8e..54590981fa 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 @@ -2,27 +2,21 @@ package com.mapbox.mapboxsdk.testapp.camera; import android.graphics.PointF; 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.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.action.MapboxMapAction; import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest; import com.mapbox.mapboxsdk.testapp.activity.espresso.EspressoTestActivity; import com.mapbox.mapboxsdk.testapp.utils.TestConstants; -import org.hamcrest.Matcher; import org.junit.Ignore; 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 com.mapbox.mapboxsdk.testapp.action.MapboxMapAction.invoke; import static org.junit.Assert.assertEquals; public class CameraMoveTest extends BaseActivityTest { @@ -36,201 +30,199 @@ public class CameraMoveTest extends BaseActivityTest { @Ignore public void testMoveToCameraPositionTarget() { validateTestSetup(); - - /*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); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + 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); + mapboxMap.moveCamera(CameraUpdateFactory.newLatLng(moveTarget)); + uiController.loopMainThreadForAtLeast(TestConstants.ANIMATION_TEST_TIME); + 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 @Ignore public void testMoveToCameraPositionTargetZoom() { validateTestSetup(); - - 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); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + final float moveZoom = 15.5f; + final LatLng moveTarget = new LatLng(1.0000000001, 1.0000000003); + mapboxMap.moveCamera(CameraUpdateFactory.newLatLngZoom(moveTarget, moveZoom)); + uiController.loopMainThreadForAtLeast(TestConstants.ANIMATION_TEST_TIME); + 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 @Ignore public void testMoveToCameraPosition() { validateTestSetup(); - - 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); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + final LatLng moveTarget = new LatLng(1.0000000001, 1.0000000003); + final float moveZoom = 15.5f; + final float moveTilt = 45.5f; + final float moveBearing = 12.5f; + + mapboxMap.moveCamera(CameraUpdateFactory.newCameraPosition( + new CameraPosition.Builder() + .target(moveTarget) + .zoom(moveZoom) + .tilt(moveTilt) + .bearing(moveBearing) + .build()) + ); + uiController.loopMainThreadForAtLeast(TestConstants.ANIMATION_TEST_TIME); + 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 @Ignore public void testMoveToBounds() { validateTestSetup(); - - 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); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + 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); + mapboxMap.moveCamera(CameraUpdateFactory.newLatLngBounds(builder.build(), 0)); + uiController.loopMainThreadForAtLeast(TestConstants.ANIMATION_TEST_TIME); + 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 @Ignore public void testMoveToMoveBy() { validateTestSetup(); - - 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); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + final PointF centerPoint = mapboxMap.getProjection().toScreenLocation(mapboxMap.getCameraPosition().target); + final LatLng moveTarget = new LatLng(2, 2); + final PointF moveTargetPoint = mapboxMap.getProjection().toScreenLocation(moveTarget); + mapboxMap.moveCamera(CameraUpdateFactory.scrollBy( + moveTargetPoint.x - centerPoint.x, moveTargetPoint.y - centerPoint.y)); + uiController.loopMainThreadForAtLeast(TestConstants.ANIMATION_TEST_TIME); + 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 @Ignore public void testMoveToZoomIn() { validateTestSetup(); - - /*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); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + float zoom = 1.0f; + mapboxMap.moveCamera(CameraUpdateFactory.zoomIn()); + uiController.loopMainThreadForAtLeast(TestConstants.ANIMATION_TEST_TIME); + CameraPosition cameraPosition = mapboxMap.getCameraPosition(); + assertEquals("Moved camera zoom should match moved camera zoom", cameraPosition.zoom, zoom + 1, + TestConstants.ZOOM_DELTA); + } + }); } @Test @Ignore public void testMoveToZoomOut() { validateTestSetup(); - - /*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); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + float zoom = 10.0f; + mapboxMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(), zoom)); + uiController.loopMainThreadForAtLeast(TestConstants.ANIMATION_TEST_TIME); + mapboxMap.moveCamera(CameraUpdateFactory.zoomOut()); + uiController.loopMainThreadForAtLeast(TestConstants.ANIMATION_TEST_TIME); + CameraPosition cameraPosition = mapboxMap.getCameraPosition(); + assertEquals("Moved camera zoom should match moved camera zoom", cameraPosition.zoom, zoom - 1, + TestConstants.ZOOM_DELTA); + } + }); } @Test @Ignore public void testMoveToZoomBy() { validateTestSetup(); - - /*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); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + float zoom = 1.0f; + final float zoomBy = 2.45f; + mapboxMap.moveCamera(CameraUpdateFactory.zoomBy(zoomBy)); + uiController.loopMainThreadForAtLeast(TestConstants.ANIMATION_TEST_TIME); + CameraPosition cameraPosition = mapboxMap.getCameraPosition(); + assertEquals("Moved camera zoom should match moved camera zoom", cameraPosition.zoom, zoom + zoomBy, + TestConstants.ZOOM_DELTA); + } + }); } @Test @Ignore public void testMoveToZoomTo() { validateTestSetup(); - - /*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); - } - - 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); - uiController.loopMainThreadForAtLeast(100); - } + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + final float zoomTo = 2.45f; + mapboxMap.moveCamera(CameraUpdateFactory.zoomTo(zoomTo)); + uiController.loopMainThreadForAtLeast(TestConstants.ANIMATION_TEST_TIME); + CameraPosition cameraPosition = mapboxMap.getCameraPosition(); + assertEquals("Moved camera zoom should match moved camera zoom", cameraPosition.zoom, zoomTo, + TestConstants.ZOOM_DELTA); + } + }); } } + diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/geometry/LatLngBoundsTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/geometry/LatLngBoundsTest.java new file mode 100644 index 0000000000..f3ce9994a3 --- /dev/null +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/geometry/LatLngBoundsTest.java @@ -0,0 +1,40 @@ +package com.mapbox.mapboxsdk.testapp.geometry; + +import android.support.test.espresso.UiController; + +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.action.MapboxMapAction; +import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest; +import com.mapbox.mapboxsdk.testapp.activity.feature.QueryRenderedFeaturesBoxHighlightActivity; + +import org.junit.Test; + +/** + * Instrumentation test to validate integration of LatLngBounds + */ +public class LatLngBoundsTest extends BaseActivityTest { + + @Override + protected Class getActivityClass() { + return QueryRenderedFeaturesBoxHighlightActivity.class; + } + + @Test + public void testLatLngBounds() { + // regression test for #9322 + validateTestSetup(); + MapboxMapAction.invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + LatLngBounds bounds = new LatLngBounds.Builder() + .include(new LatLng(48.8589506, 2.2773457)) + .include(new LatLng(47.2383171, -1.6309316)) + .build(); + mapboxMap.moveCamera(CameraUpdateFactory.newLatLngBounds(bounds, 0)); + } + }); + } +}
\ No newline at end of file diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/widgets/CompassViewTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/widgets/CompassViewTest.java index f15605042b..28389a3386 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/widgets/CompassViewTest.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/widgets/CompassViewTest.java @@ -1,20 +1,17 @@ package com.mapbox.mapboxsdk.testapp.maps.widgets; 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.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.action.MapboxMapAction; import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest; import com.mapbox.mapboxsdk.testapp.activity.espresso.EspressoTestActivity; import com.mapbox.mapboxsdk.testapp.utils.TestConstants; -import org.hamcrest.Matcher; import org.junit.Ignore; import org.junit.Test; @@ -23,6 +20,7 @@ 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 com.mapbox.mapboxsdk.testapp.action.MapboxMapAction.invoke; import static org.hamcrest.Matchers.not; import static org.junit.Assert.assertEquals; @@ -40,96 +38,51 @@ public class CompassViewTest extends BaseActivityTest { } @Test + @Ignore public void testVisible() { validateTestSetup(); - - onView(withId(R.id.mapView)).perform(new MoveCameraAction(mapboxMap, - CameraUpdateFactory.newCameraPosition( + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + mapboxMap.moveCamera(CameraUpdateFactory.newCameraPosition( new CameraPosition.Builder() .bearing(45) .zoom(1) .target(new LatLng()) .build() - ) - ) - ); - waitLoop(); + )); + uiController.loopMainThreadForAtLeast(500); + } + }); onView(withId(R.id.compassView)).check(matches(isDisplayed())); } @Test - @Ignore // 10-31-2016 click action is not working + @Ignore public void testClick() { validateTestSetup(); - - onView(withId(R.id.mapView)).perform(new MoveCameraAction(mapboxMap, - CameraUpdateFactory.newCameraPosition( + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + mapboxMap.moveCamera(CameraUpdateFactory.newCameraPosition( new CameraPosition.Builder() .bearing(45) .zoom(1) .target(new LatLng()) .build() - ) - ) - ); - - waitLoop(); + )); + } + }); onView(withId(R.id.compassView)).perform(click()); - onView(withId(R.id.mapView)).perform(new WaitAction(3000)); + waitLoop(); 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); - } - - 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); - } + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + CameraPosition cameraPosition = mapboxMap.getCameraPosition(); + assertEquals("Camera bearing should face north, ", 0, cameraPosition.bearing, TestConstants.BEARING_DELTA); + } + }); } } diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/widgets/MyLocationViewTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/widgets/MyLocationViewTest.java index efd67db356..fa19235ad0 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/widgets/MyLocationViewTest.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/widgets/MyLocationViewTest.java @@ -9,12 +9,12 @@ import android.support.test.espresso.UiController; import android.support.test.espresso.ViewAction; import android.view.View; +import com.mapbox.mapboxsdk.Mapbox; 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.LocationSource; import com.mapbox.mapboxsdk.maps.MapboxMap; import com.mapbox.mapboxsdk.maps.widgets.MyLocationView; import com.mapbox.mapboxsdk.testapp.R; @@ -104,7 +104,7 @@ public class MyLocationViewTest extends BaseActivityTest { mapboxMap.moveCamera( CameraUpdateFactory.newCameraPosition( new CameraPosition.Builder() - .target(new LatLng(LocationSource.getLocationEngine(view.getContext()).getLastLocation())) + .target(new LatLng(Mapbox.getLocationSource().getLastLocation())) .build() ) ); diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/BackgroundLayerTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/BackgroundLayerTest.java index 851660f06e..0e4cf6a8ca 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/BackgroundLayerTest.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/BackgroundLayerTest.java @@ -3,9 +3,9 @@ package com.mapbox.mapboxsdk.testapp.style; import android.graphics.Color; -import android.support.test.espresso.Espresso; -import android.support.test.rule.ActivityTestRule; +import android.support.test.espresso.UiController; import android.support.test.runner.AndroidJUnit4; + import timber.log.Timber; import com.mapbox.mapboxsdk.maps.MapboxMap; @@ -19,20 +19,16 @@ import com.mapbox.mapboxsdk.style.functions.stops.IntervalStops; import com.mapbox.mapboxsdk.style.functions.stops.Stop; import com.mapbox.mapboxsdk.style.functions.stops.Stops; import com.mapbox.mapboxsdk.style.layers.BackgroundLayer; -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.action.MapboxMapAction; import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest; -import org.junit.After; -import org.junit.Before; -import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; import static com.mapbox.mapboxsdk.style.functions.Function.*; import static com.mapbox.mapboxsdk.style.functions.stops.Stop.stop; import static com.mapbox.mapboxsdk.style.functions.stops.Stops.*; +import static com.mapbox.mapboxsdk.testapp.action.MapboxMapAction.invoke; import static org.junit.Assert.*; import static com.mapbox.mapboxsdk.style.layers.Property.*; import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*; @@ -53,9 +49,14 @@ public class BackgroundLayerTest extends BaseActivityTest { return EspressoTestActivity.class; } - private void setupLayer(){ + private void setupLayer() { Timber.i("Retrieving layer"); - layer = mapboxMap.getLayerAs("background"); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + layer = mapboxMap.getLayerAs("background"); + } + }); } @Test @@ -63,14 +64,19 @@ public class BackgroundLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("Visibility"); - assertNotNull(layer); - - // Get initial - assertEquals(layer.getVisibility().getValue(), VISIBLE); - - // Set - layer.setProperties(visibility(NONE)); - assertEquals(layer.getVisibility().getValue(), NONE); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Get initial + assertEquals(layer.getVisibility().getValue(), VISIBLE); + + // Set + layer.setProperties(visibility(NONE)); + assertEquals(layer.getVisibility().getValue(), NONE); + } + }); } @Test @@ -78,12 +84,17 @@ public class BackgroundLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("background-colorTransitionOptions"); - assertNotNull(layer); - - // Set and Get - TransitionOptions options = new TransitionOptions(300, 100); - layer.setBackgroundColorTransition(options); - assertEquals(layer.getBackgroundColorTransition(), options); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set and Get + TransitionOptions options = new TransitionOptions(300, 100); + layer.setBackgroundColorTransition(options); + assertEquals(layer.getBackgroundColorTransition(), options); + } + }); } @Test @@ -91,11 +102,16 @@ public class BackgroundLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("background-color"); - assertNotNull(layer); - - // Set and Get - layer.setProperties(backgroundColor("rgba(0, 0, 0, 1)")); - assertEquals((String) layer.getBackgroundColor().getValue(), (String) "rgba(0, 0, 0, 1)"); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set and Get + layer.setProperties(backgroundColor("rgba(0, 0, 0, 1)")); + assertEquals((String) layer.getBackgroundColor().getValue(), (String) "rgba(0, 0, 0, 1)"); + } + }); } @Test @@ -103,26 +119,31 @@ public class BackgroundLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("background-color"); - assertNotNull(layer); - - // Set - layer.setProperties( - backgroundColor( - zoom( - exponential( - stop(2, backgroundColor("rgba(0, 0, 0, 1)")) - ).withBase(0.5f) - ) - ) - ); - - // Verify - assertNotNull(layer.getBackgroundColor()); - assertNotNull(layer.getBackgroundColor().getFunction()); - assertEquals(CameraFunction.class, layer.getBackgroundColor().getFunction().getClass()); - assertEquals(ExponentialStops.class, layer.getBackgroundColor().getFunction().getStops().getClass()); - assertEquals(0.5f, ((ExponentialStops) layer.getBackgroundColor().getFunction().getStops()).getBase(), 0.001); - assertEquals(1, ((ExponentialStops) layer.getBackgroundColor().getFunction().getStops()).size()); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + backgroundColor( + zoom( + exponential( + stop(2, backgroundColor("rgba(0, 0, 0, 1)")) + ).withBase(0.5f) + ) + ) + ); + + // Verify + assertNotNull(layer.getBackgroundColor()); + assertNotNull(layer.getBackgroundColor().getFunction()); + assertEquals(CameraFunction.class, layer.getBackgroundColor().getFunction().getClass()); + assertEquals(ExponentialStops.class, layer.getBackgroundColor().getFunction().getStops().getClass()); + assertEquals(0.5f, ((ExponentialStops) layer.getBackgroundColor().getFunction().getStops()).getBase(), 0.001); + assertEquals(1, ((ExponentialStops) layer.getBackgroundColor().getFunction().getStops()).size()); + } + }); } @Test @@ -130,11 +151,16 @@ public class BackgroundLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("background-color"); - assertNotNull(layer); - - // Set and Get - layer.setProperties(backgroundColor(Color.RED)); - assertEquals(layer.getBackgroundColorAsInt(), Color.RED); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set and Get + layer.setProperties(backgroundColor(Color.RED)); + assertEquals(layer.getBackgroundColorAsInt(), Color.RED); + } + }); } @Test @@ -142,12 +168,17 @@ public class BackgroundLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("background-patternTransitionOptions"); - assertNotNull(layer); - - // Set and Get - TransitionOptions options = new TransitionOptions(300, 100); - layer.setBackgroundPatternTransition(options); - assertEquals(layer.getBackgroundPatternTransition(), options); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set and Get + TransitionOptions options = new TransitionOptions(300, 100); + layer.setBackgroundPatternTransition(options); + assertEquals(layer.getBackgroundPatternTransition(), options); + } + }); } @Test @@ -155,11 +186,16 @@ public class BackgroundLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("background-pattern"); - assertNotNull(layer); - - // Set and Get - layer.setProperties(backgroundPattern("pedestrian-polygon")); - assertEquals((String) layer.getBackgroundPattern().getValue(), (String) "pedestrian-polygon"); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set and Get + layer.setProperties(backgroundPattern("pedestrian-polygon")); + assertEquals((String) layer.getBackgroundPattern().getValue(), (String) "pedestrian-polygon"); + } + }); } @Test @@ -167,25 +203,30 @@ public class BackgroundLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("background-pattern"); - assertNotNull(layer); - - // Set - layer.setProperties( - backgroundPattern( - zoom( - interval( - stop(2, backgroundPattern("pedestrian-polygon")) + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + backgroundPattern( + zoom( + interval( + stop(2, backgroundPattern("pedestrian-polygon")) + ) + ) ) - ) - ) - ); - - // Verify - assertNotNull(layer.getBackgroundPattern()); - assertNotNull(layer.getBackgroundPattern().getFunction()); - assertEquals(CameraFunction.class, layer.getBackgroundPattern().getFunction().getClass()); - assertEquals(IntervalStops.class, layer.getBackgroundPattern().getFunction().getStops().getClass()); - assertEquals(1, ((IntervalStops) layer.getBackgroundPattern().getFunction().getStops()).size()); + ); + + // Verify + assertNotNull(layer.getBackgroundPattern()); + assertNotNull(layer.getBackgroundPattern().getFunction()); + assertEquals(CameraFunction.class, layer.getBackgroundPattern().getFunction().getClass()); + assertEquals(IntervalStops.class, layer.getBackgroundPattern().getFunction().getStops().getClass()); + assertEquals(1, ((IntervalStops) layer.getBackgroundPattern().getFunction().getStops()).size()); + } + }); } @Test @@ -193,12 +234,17 @@ public class BackgroundLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("background-opacityTransitionOptions"); - assertNotNull(layer); - - // Set and Get - TransitionOptions options = new TransitionOptions(300, 100); - layer.setBackgroundOpacityTransition(options); - assertEquals(layer.getBackgroundOpacityTransition(), options); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set and Get + TransitionOptions options = new TransitionOptions(300, 100); + layer.setBackgroundOpacityTransition(options); + assertEquals(layer.getBackgroundOpacityTransition(), options); + } + }); } @Test @@ -206,11 +252,16 @@ public class BackgroundLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("background-opacity"); - assertNotNull(layer); - - // Set and Get - layer.setProperties(backgroundOpacity(0.3f)); - assertEquals((Float) layer.getBackgroundOpacity().getValue(), (Float) 0.3f); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set and Get + layer.setProperties(backgroundOpacity(0.3f)); + assertEquals((Float) layer.getBackgroundOpacity().getValue(), (Float) 0.3f); + } + }); } @Test @@ -218,26 +269,31 @@ public class BackgroundLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("background-opacity"); - assertNotNull(layer); - - // Set - layer.setProperties( - backgroundOpacity( - zoom( - exponential( - stop(2, backgroundOpacity(0.3f)) - ).withBase(0.5f) - ) - ) - ); - - // Verify - assertNotNull(layer.getBackgroundOpacity()); - assertNotNull(layer.getBackgroundOpacity().getFunction()); - assertEquals(CameraFunction.class, layer.getBackgroundOpacity().getFunction().getClass()); - assertEquals(ExponentialStops.class, layer.getBackgroundOpacity().getFunction().getStops().getClass()); - assertEquals(0.5f, ((ExponentialStops) layer.getBackgroundOpacity().getFunction().getStops()).getBase(), 0.001); - assertEquals(1, ((ExponentialStops) layer.getBackgroundOpacity().getFunction().getStops()).size()); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + backgroundOpacity( + zoom( + exponential( + stop(2, backgroundOpacity(0.3f)) + ).withBase(0.5f) + ) + ) + ); + + // Verify + assertNotNull(layer.getBackgroundOpacity()); + assertNotNull(layer.getBackgroundOpacity().getFunction()); + assertEquals(CameraFunction.class, layer.getBackgroundOpacity().getFunction().getClass()); + assertEquals(ExponentialStops.class, layer.getBackgroundOpacity().getFunction().getStops().getClass()); + assertEquals(0.5f, ((ExponentialStops) layer.getBackgroundOpacity().getFunction().getStops()).getBase(), 0.001); + assertEquals(1, ((ExponentialStops) layer.getBackgroundOpacity().getFunction().getStops()).size()); + } + }); } } diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/BaseStyleTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/BaseStyleTest.java deleted file mode 100644 index 3d56752150..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/BaseStyleTest.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.mapbox.mapboxsdk.testapp.style; - -import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest; -import com.mapbox.mapboxsdk.testapp.activity.style.RuntimeStyleTestActivity; - -/** - * Base Test class for Style tests - */ -public class BaseStyleTest extends BaseActivityTest { - - @Override - protected Class getActivityClass() { - return RuntimeStyleTestActivity.class; - } -} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/CircleLayerTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/CircleLayerTest.java index bf31a935f8..c8f9640433 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/CircleLayerTest.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/CircleLayerTest.java @@ -3,9 +3,9 @@ package com.mapbox.mapboxsdk.testapp.style; import android.graphics.Color; -import android.support.test.espresso.Espresso; -import android.support.test.rule.ActivityTestRule; +import android.support.test.espresso.UiController; import android.support.test.runner.AndroidJUnit4; + import timber.log.Timber; import com.mapbox.mapboxsdk.maps.MapboxMap; @@ -19,20 +19,16 @@ import com.mapbox.mapboxsdk.style.functions.stops.IntervalStops; import com.mapbox.mapboxsdk.style.functions.stops.Stop; import com.mapbox.mapboxsdk.style.functions.stops.Stops; import com.mapbox.mapboxsdk.style.layers.CircleLayer; -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.action.MapboxMapAction; import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest; -import org.junit.After; -import org.junit.Before; -import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; import static com.mapbox.mapboxsdk.style.functions.Function.*; import static com.mapbox.mapboxsdk.style.functions.stops.Stop.stop; import static com.mapbox.mapboxsdk.style.functions.stops.Stops.*; +import static com.mapbox.mapboxsdk.testapp.action.MapboxMapAction.invoke; import static org.junit.Assert.*; import static com.mapbox.mapboxsdk.style.layers.Property.*; import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*; @@ -53,15 +49,21 @@ public class CircleLayerTest extends BaseActivityTest { return EspressoTestActivity.class; } - private void setupLayer(){ - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new CircleLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - // Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } + private void setupLayer() { + Timber.i("Retrieving layer"); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new CircleLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + // Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); + } + } + }); } @Test @@ -69,14 +71,19 @@ public class CircleLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("Visibility"); - assertNotNull(layer); - - // Get initial - assertEquals(layer.getVisibility().getValue(), VISIBLE); - - // Set - layer.setProperties(visibility(NONE)); - assertEquals(layer.getVisibility().getValue(), NONE); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Get initial + assertEquals(layer.getVisibility().getValue(), VISIBLE); + + // Set + layer.setProperties(visibility(NONE)); + assertEquals(layer.getVisibility().getValue(), NONE); + } + }); } @Test @@ -84,15 +91,20 @@ public class CircleLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("SourceLayer"); - assertNotNull(layer); - - // Get initial - assertEquals(layer.getSourceLayer(), "composite"); - - // Set - final String sourceLayer = "test"; - layer.setSourceLayer(sourceLayer); - assertEquals(layer.getSourceLayer(), sourceLayer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Get initial + assertEquals(layer.getSourceLayer(), "composite"); + + // Set + final String sourceLayer = "test"; + layer.setSourceLayer(sourceLayer); + assertEquals(layer.getSourceLayer(), sourceLayer); + } + }); } @Test @@ -100,12 +112,17 @@ public class CircleLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("circle-radiusTransitionOptions"); - assertNotNull(layer); - - // Set and Get - TransitionOptions options = new TransitionOptions(300, 100); - layer.setCircleRadiusTransition(options); - assertEquals(layer.getCircleRadiusTransition(), options); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set and Get + TransitionOptions options = new TransitionOptions(300, 100); + layer.setCircleRadiusTransition(options); + assertEquals(layer.getCircleRadiusTransition(), options); + } + }); } @Test @@ -113,11 +130,16 @@ public class CircleLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("circle-radius"); - assertNotNull(layer); - - // Set and Get - layer.setProperties(circleRadius(0.3f)); - assertEquals((Float) layer.getCircleRadius().getValue(), (Float) 0.3f); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set and Get + layer.setProperties(circleRadius(0.3f)); + assertEquals((Float) layer.getCircleRadius().getValue(), (Float) 0.3f); + } + }); } @Test @@ -125,26 +147,31 @@ public class CircleLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("circle-radius"); - assertNotNull(layer); - - // Set - layer.setProperties( - circleRadius( - zoom( - exponential( - stop(2, circleRadius(0.3f)) - ).withBase(0.5f) - ) - ) - ); - - // Verify - assertNotNull(layer.getCircleRadius()); - assertNotNull(layer.getCircleRadius().getFunction()); - assertEquals(CameraFunction.class, layer.getCircleRadius().getFunction().getClass()); - assertEquals(ExponentialStops.class, layer.getCircleRadius().getFunction().getStops().getClass()); - assertEquals(0.5f, ((ExponentialStops) layer.getCircleRadius().getFunction().getStops()).getBase(), 0.001); - assertEquals(1, ((ExponentialStops) layer.getCircleRadius().getFunction().getStops()).size()); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + circleRadius( + zoom( + exponential( + stop(2, circleRadius(0.3f)) + ).withBase(0.5f) + ) + ) + ); + + // Verify + assertNotNull(layer.getCircleRadius()); + assertNotNull(layer.getCircleRadius().getFunction()); + assertEquals(CameraFunction.class, layer.getCircleRadius().getFunction().getClass()); + assertEquals(ExponentialStops.class, layer.getCircleRadius().getFunction().getStops().getClass()); + assertEquals(0.5f, ((ExponentialStops) layer.getCircleRadius().getFunction().getStops()).getBase(), 0.001); + assertEquals(1, ((ExponentialStops) layer.getCircleRadius().getFunction().getStops()).size()); + } + }); } @Test @@ -152,19 +179,24 @@ public class CircleLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("circle-radius"); - assertNotNull(layer); - - // Set - layer.setProperties( - circleRadius(property("FeaturePropertyA", Stops.<Float>identity())) - ); - - // Verify - assertNotNull(layer.getCircleRadius()); - assertNotNull(layer.getCircleRadius().getFunction()); - assertEquals(SourceFunction.class, layer.getCircleRadius().getFunction().getClass()); - assertEquals("FeaturePropertyA", ((SourceFunction) layer.getCircleRadius().getFunction()).getProperty()); - assertEquals(IdentityStops.class, layer.getCircleRadius().getFunction().getStops().getClass()); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + circleRadius(property("FeaturePropertyA", Stops.<Float>identity())) + ); + + // Verify + assertNotNull(layer.getCircleRadius()); + assertNotNull(layer.getCircleRadius().getFunction()); + assertEquals(SourceFunction.class, layer.getCircleRadius().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getCircleRadius().getFunction()).getProperty()); + assertEquals(IdentityStops.class, layer.getCircleRadius().getFunction().getStops().getClass()); + } + }); } @Test @@ -172,26 +204,31 @@ public class CircleLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("circle-radius"); - assertNotNull(layer); - - // Set - layer.setProperties( - circleRadius( - property( - "FeaturePropertyA", - exponential( - stop(0.3f, circleRadius(0.3f)) - ).withBase(0.5f) - ) - ) - ); - - // Verify - assertNotNull(layer.getCircleRadius()); - assertNotNull(layer.getCircleRadius().getFunction()); - assertEquals(SourceFunction.class, layer.getCircleRadius().getFunction().getClass()); - assertEquals("FeaturePropertyA", ((SourceFunction) layer.getCircleRadius().getFunction()).getProperty()); - assertEquals(ExponentialStops.class, layer.getCircleRadius().getFunction().getStops().getClass()); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + circleRadius( + property( + "FeaturePropertyA", + exponential( + stop(0.3f, circleRadius(0.3f)) + ).withBase(0.5f) + ) + ) + ); + + // Verify + assertNotNull(layer.getCircleRadius()); + assertNotNull(layer.getCircleRadius().getFunction()); + assertEquals(SourceFunction.class, layer.getCircleRadius().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getCircleRadius().getFunction()).getProperty()); + assertEquals(ExponentialStops.class, layer.getCircleRadius().getFunction().getStops().getClass()); + } + }); } @Test @@ -199,29 +236,35 @@ public class CircleLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("circle-radius"); - assertNotNull(layer); - - // Set - layer.setProperties( - circleRadius( - property( - "FeaturePropertyA", - categorical( - stop(1.0f, circleRadius(0.3f)) + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + circleRadius( + property( + "FeaturePropertyA", + categorical( + stop(1.0f, circleRadius(0.3f)) + ) + ).withDefaultValue(circleRadius(0.3f)) ) - ).withDefaultValue(circleRadius(0.3f)) - ) - ); - - // Verify - assertNotNull(layer.getCircleRadius()); - assertNotNull(layer.getCircleRadius().getFunction()); - assertEquals(SourceFunction.class, layer.getCircleRadius().getFunction().getClass()); - assertEquals("FeaturePropertyA", ((SourceFunction) layer.getCircleRadius().getFunction()).getProperty()); - assertEquals(CategoricalStops.class, layer.getCircleRadius().getFunction().getStops().getClass()); - assertNotNull(((SourceFunction) layer.getCircleRadius().getFunction()).getDefaultValue()); - assertNotNull(((SourceFunction) layer.getCircleRadius().getFunction()).getDefaultValue().getValue()); - assertEquals(0.3f, ((SourceFunction) layer.getCircleRadius().getFunction()).getDefaultValue().getValue()); + ); + + // Verify + assertNotNull(layer.getCircleRadius()); + assertNotNull(layer.getCircleRadius().getFunction()); + assertEquals(SourceFunction.class, layer.getCircleRadius().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getCircleRadius().getFunction()).getProperty()); + assertEquals(CategoricalStops.class, layer.getCircleRadius().getFunction().getStops().getClass()); + assertNotNull(((SourceFunction) layer.getCircleRadius().getFunction()).getDefaultValue()); + assertNotNull(((SourceFunction) layer.getCircleRadius().getFunction()).getDefaultValue().getValue()); + assertEquals(0.3f, ((SourceFunction) layer.getCircleRadius().getFunction()).getDefaultValue().getValue()); + } + }); + } @Test @@ -229,34 +272,39 @@ public class CircleLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("circle-radius"); - assertNotNull(layer); - - // Set - layer.setProperties( - circleRadius( - composite( - "FeaturePropertyA", - exponential( - stop(0, 0.3f, circleRadius(0.9f)) - ).withBase(0.5f) - ).withDefaultValue(circleRadius(0.3f)) - ) - ); - - // Verify - assertNotNull(layer.getCircleRadius()); - assertNotNull(layer.getCircleRadius().getFunction()); - assertEquals(CompositeFunction.class, layer.getCircleRadius().getFunction().getClass()); - assertEquals("FeaturePropertyA", ((CompositeFunction) layer.getCircleRadius().getFunction()).getProperty()); - assertEquals(ExponentialStops.class, layer.getCircleRadius().getFunction().getStops().getClass()); - assertEquals(1, ((ExponentialStops) layer.getCircleRadius().getFunction().getStops()).size()); - - ExponentialStops<Stop.CompositeValue<Float, Float>, Float> stops = - (ExponentialStops<Stop.CompositeValue<Float, Float>, Float>) layer.getCircleRadius().getFunction().getStops(); - Stop<Stop.CompositeValue<Float, Float>, Float> stop = stops.iterator().next(); - assertEquals(0f, stop.in.zoom, 0.001); - assertEquals(0.3f, stop.in.value, 0.001f); - assertEquals(0.9f, stop.out, 0.001f); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + circleRadius( + composite( + "FeaturePropertyA", + exponential( + stop(0, 0.3f, circleRadius(0.9f)) + ).withBase(0.5f) + ).withDefaultValue(circleRadius(0.3f)) + ) + ); + + // Verify + assertNotNull(layer.getCircleRadius()); + assertNotNull(layer.getCircleRadius().getFunction()); + assertEquals(CompositeFunction.class, layer.getCircleRadius().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((CompositeFunction) layer.getCircleRadius().getFunction()).getProperty()); + assertEquals(ExponentialStops.class, layer.getCircleRadius().getFunction().getStops().getClass()); + assertEquals(1, ((ExponentialStops) layer.getCircleRadius().getFunction().getStops()).size()); + + ExponentialStops<Stop.CompositeValue<Float, Float>, Float> stops = + (ExponentialStops<Stop.CompositeValue<Float, Float>, Float>) layer.getCircleRadius().getFunction().getStops(); + Stop<Stop.CompositeValue<Float, Float>, Float> stop = stops.iterator().next(); + assertEquals(0f, stop.in.zoom, 0.001); + assertEquals(0.3f, stop.in.value, 0.001f); + assertEquals(0.9f, stop.out, 0.001f); + } + }); } @Test @@ -264,12 +312,17 @@ public class CircleLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("circle-colorTransitionOptions"); - assertNotNull(layer); - - // Set and Get - TransitionOptions options = new TransitionOptions(300, 100); - layer.setCircleColorTransition(options); - assertEquals(layer.getCircleColorTransition(), options); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set and Get + TransitionOptions options = new TransitionOptions(300, 100); + layer.setCircleColorTransition(options); + assertEquals(layer.getCircleColorTransition(), options); + } + }); } @Test @@ -277,11 +330,16 @@ public class CircleLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("circle-color"); - assertNotNull(layer); - - // Set and Get - layer.setProperties(circleColor("rgba(0, 0, 0, 1)")); - assertEquals((String) layer.getCircleColor().getValue(), (String) "rgba(0, 0, 0, 1)"); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set and Get + layer.setProperties(circleColor("rgba(0, 0, 0, 1)")); + assertEquals((String) layer.getCircleColor().getValue(), (String) "rgba(0, 0, 0, 1)"); + } + }); } @Test @@ -289,26 +347,31 @@ public class CircleLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("circle-color"); - assertNotNull(layer); - - // Set - layer.setProperties( - circleColor( - zoom( - exponential( - stop(2, circleColor("rgba(0, 0, 0, 1)")) - ).withBase(0.5f) - ) - ) - ); - - // Verify - assertNotNull(layer.getCircleColor()); - assertNotNull(layer.getCircleColor().getFunction()); - assertEquals(CameraFunction.class, layer.getCircleColor().getFunction().getClass()); - assertEquals(ExponentialStops.class, layer.getCircleColor().getFunction().getStops().getClass()); - assertEquals(0.5f, ((ExponentialStops) layer.getCircleColor().getFunction().getStops()).getBase(), 0.001); - assertEquals(1, ((ExponentialStops) layer.getCircleColor().getFunction().getStops()).size()); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + circleColor( + zoom( + exponential( + stop(2, circleColor("rgba(0, 0, 0, 1)")) + ).withBase(0.5f) + ) + ) + ); + + // Verify + assertNotNull(layer.getCircleColor()); + assertNotNull(layer.getCircleColor().getFunction()); + assertEquals(CameraFunction.class, layer.getCircleColor().getFunction().getClass()); + assertEquals(ExponentialStops.class, layer.getCircleColor().getFunction().getStops().getClass()); + assertEquals(0.5f, ((ExponentialStops) layer.getCircleColor().getFunction().getStops()).getBase(), 0.001); + assertEquals(1, ((ExponentialStops) layer.getCircleColor().getFunction().getStops()).size()); + } + }); } @Test @@ -316,19 +379,24 @@ public class CircleLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("circle-color"); - assertNotNull(layer); - - // Set - layer.setProperties( - circleColor(property("FeaturePropertyA", Stops.<String>identity())) - ); - - // Verify - assertNotNull(layer.getCircleColor()); - assertNotNull(layer.getCircleColor().getFunction()); - assertEquals(SourceFunction.class, layer.getCircleColor().getFunction().getClass()); - assertEquals("FeaturePropertyA", ((SourceFunction) layer.getCircleColor().getFunction()).getProperty()); - assertEquals(IdentityStops.class, layer.getCircleColor().getFunction().getStops().getClass()); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + circleColor(property("FeaturePropertyA", Stops.<String>identity())) + ); + + // Verify + assertNotNull(layer.getCircleColor()); + assertNotNull(layer.getCircleColor().getFunction()); + assertEquals(SourceFunction.class, layer.getCircleColor().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getCircleColor().getFunction()).getProperty()); + assertEquals(IdentityStops.class, layer.getCircleColor().getFunction().getStops().getClass()); + } + }); } @Test @@ -336,26 +404,31 @@ public class CircleLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("circle-color"); - assertNotNull(layer); - - // Set - layer.setProperties( - circleColor( - property( - "FeaturePropertyA", - exponential( - stop(Color.RED, circleColor(Color.RED)) - ).withBase(0.5f) - ) - ) - ); - - // Verify - assertNotNull(layer.getCircleColor()); - assertNotNull(layer.getCircleColor().getFunction()); - assertEquals(SourceFunction.class, layer.getCircleColor().getFunction().getClass()); - assertEquals("FeaturePropertyA", ((SourceFunction) layer.getCircleColor().getFunction()).getProperty()); - assertEquals(ExponentialStops.class, layer.getCircleColor().getFunction().getStops().getClass()); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + circleColor( + property( + "FeaturePropertyA", + exponential( + stop(Color.RED, circleColor(Color.RED)) + ).withBase(0.5f) + ) + ) + ); + + // Verify + assertNotNull(layer.getCircleColor()); + assertNotNull(layer.getCircleColor().getFunction()); + assertEquals(SourceFunction.class, layer.getCircleColor().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getCircleColor().getFunction()).getProperty()); + assertEquals(ExponentialStops.class, layer.getCircleColor().getFunction().getStops().getClass()); + } + }); } @Test @@ -363,29 +436,35 @@ public class CircleLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("circle-color"); - assertNotNull(layer); - - // Set - layer.setProperties( - circleColor( - property( - "FeaturePropertyA", - categorical( - stop("valueA", circleColor(Color.RED)) + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + circleColor( + property( + "FeaturePropertyA", + categorical( + stop("valueA", circleColor(Color.RED)) + ) + ).withDefaultValue(circleColor(Color.GREEN)) ) - ).withDefaultValue(circleColor(Color.GREEN)) - ) - ); - - // Verify - assertNotNull(layer.getCircleColor()); - assertNotNull(layer.getCircleColor().getFunction()); - assertEquals(SourceFunction.class, layer.getCircleColor().getFunction().getClass()); - assertEquals("FeaturePropertyA", ((SourceFunction) layer.getCircleColor().getFunction()).getProperty()); - assertEquals(CategoricalStops.class, layer.getCircleColor().getFunction().getStops().getClass()); - assertNotNull(((SourceFunction) layer.getCircleColor().getFunction()).getDefaultValue()); - assertNotNull(((SourceFunction) layer.getCircleColor().getFunction()).getDefaultValue().getValue()); - assertEquals(Color.GREEN, (int) ((SourceFunction) layer.getCircleColor().getFunction()).getDefaultValue().getColorInt()); + ); + + // Verify + assertNotNull(layer.getCircleColor()); + assertNotNull(layer.getCircleColor().getFunction()); + assertEquals(SourceFunction.class, layer.getCircleColor().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getCircleColor().getFunction()).getProperty()); + assertEquals(CategoricalStops.class, layer.getCircleColor().getFunction().getStops().getClass()); + assertNotNull(((SourceFunction) layer.getCircleColor().getFunction()).getDefaultValue()); + assertNotNull(((SourceFunction) layer.getCircleColor().getFunction()).getDefaultValue().getValue()); + assertEquals(Color.GREEN, (int) ((SourceFunction) layer.getCircleColor().getFunction()).getDefaultValue().getColorInt()); + } + }); + } @Test @@ -393,11 +472,16 @@ public class CircleLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("circle-color"); - assertNotNull(layer); - - // Set and Get - layer.setProperties(circleColor(Color.RED)); - assertEquals(layer.getCircleColorAsInt(), Color.RED); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set and Get + layer.setProperties(circleColor(Color.RED)); + assertEquals(layer.getCircleColorAsInt(), Color.RED); + } + }); } @Test @@ -405,12 +489,17 @@ public class CircleLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("circle-blurTransitionOptions"); - assertNotNull(layer); - - // Set and Get - TransitionOptions options = new TransitionOptions(300, 100); - layer.setCircleBlurTransition(options); - assertEquals(layer.getCircleBlurTransition(), options); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set and Get + TransitionOptions options = new TransitionOptions(300, 100); + layer.setCircleBlurTransition(options); + assertEquals(layer.getCircleBlurTransition(), options); + } + }); } @Test @@ -418,11 +507,16 @@ public class CircleLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("circle-blur"); - assertNotNull(layer); - - // Set and Get - layer.setProperties(circleBlur(0.3f)); - assertEquals((Float) layer.getCircleBlur().getValue(), (Float) 0.3f); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set and Get + layer.setProperties(circleBlur(0.3f)); + assertEquals((Float) layer.getCircleBlur().getValue(), (Float) 0.3f); + } + }); } @Test @@ -430,26 +524,31 @@ public class CircleLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("circle-blur"); - assertNotNull(layer); - - // Set - layer.setProperties( - circleBlur( - zoom( - exponential( - stop(2, circleBlur(0.3f)) - ).withBase(0.5f) - ) - ) - ); - - // Verify - assertNotNull(layer.getCircleBlur()); - assertNotNull(layer.getCircleBlur().getFunction()); - assertEquals(CameraFunction.class, layer.getCircleBlur().getFunction().getClass()); - assertEquals(ExponentialStops.class, layer.getCircleBlur().getFunction().getStops().getClass()); - assertEquals(0.5f, ((ExponentialStops) layer.getCircleBlur().getFunction().getStops()).getBase(), 0.001); - assertEquals(1, ((ExponentialStops) layer.getCircleBlur().getFunction().getStops()).size()); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + circleBlur( + zoom( + exponential( + stop(2, circleBlur(0.3f)) + ).withBase(0.5f) + ) + ) + ); + + // Verify + assertNotNull(layer.getCircleBlur()); + assertNotNull(layer.getCircleBlur().getFunction()); + assertEquals(CameraFunction.class, layer.getCircleBlur().getFunction().getClass()); + assertEquals(ExponentialStops.class, layer.getCircleBlur().getFunction().getStops().getClass()); + assertEquals(0.5f, ((ExponentialStops) layer.getCircleBlur().getFunction().getStops()).getBase(), 0.001); + assertEquals(1, ((ExponentialStops) layer.getCircleBlur().getFunction().getStops()).size()); + } + }); } @Test @@ -457,19 +556,24 @@ public class CircleLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("circle-blur"); - assertNotNull(layer); - - // Set - layer.setProperties( - circleBlur(property("FeaturePropertyA", Stops.<Float>identity())) - ); - - // Verify - assertNotNull(layer.getCircleBlur()); - assertNotNull(layer.getCircleBlur().getFunction()); - assertEquals(SourceFunction.class, layer.getCircleBlur().getFunction().getClass()); - assertEquals("FeaturePropertyA", ((SourceFunction) layer.getCircleBlur().getFunction()).getProperty()); - assertEquals(IdentityStops.class, layer.getCircleBlur().getFunction().getStops().getClass()); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + circleBlur(property("FeaturePropertyA", Stops.<Float>identity())) + ); + + // Verify + assertNotNull(layer.getCircleBlur()); + assertNotNull(layer.getCircleBlur().getFunction()); + assertEquals(SourceFunction.class, layer.getCircleBlur().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getCircleBlur().getFunction()).getProperty()); + assertEquals(IdentityStops.class, layer.getCircleBlur().getFunction().getStops().getClass()); + } + }); } @Test @@ -477,26 +581,31 @@ public class CircleLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("circle-blur"); - assertNotNull(layer); - - // Set - layer.setProperties( - circleBlur( - property( - "FeaturePropertyA", - exponential( - stop(0.3f, circleBlur(0.3f)) - ).withBase(0.5f) - ) - ) - ); - - // Verify - assertNotNull(layer.getCircleBlur()); - assertNotNull(layer.getCircleBlur().getFunction()); - assertEquals(SourceFunction.class, layer.getCircleBlur().getFunction().getClass()); - assertEquals("FeaturePropertyA", ((SourceFunction) layer.getCircleBlur().getFunction()).getProperty()); - assertEquals(ExponentialStops.class, layer.getCircleBlur().getFunction().getStops().getClass()); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + circleBlur( + property( + "FeaturePropertyA", + exponential( + stop(0.3f, circleBlur(0.3f)) + ).withBase(0.5f) + ) + ) + ); + + // Verify + assertNotNull(layer.getCircleBlur()); + assertNotNull(layer.getCircleBlur().getFunction()); + assertEquals(SourceFunction.class, layer.getCircleBlur().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getCircleBlur().getFunction()).getProperty()); + assertEquals(ExponentialStops.class, layer.getCircleBlur().getFunction().getStops().getClass()); + } + }); } @Test @@ -504,29 +613,35 @@ public class CircleLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("circle-blur"); - assertNotNull(layer); - - // Set - layer.setProperties( - circleBlur( - property( - "FeaturePropertyA", - categorical( - stop(1.0f, circleBlur(0.3f)) + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + circleBlur( + property( + "FeaturePropertyA", + categorical( + stop(1.0f, circleBlur(0.3f)) + ) + ).withDefaultValue(circleBlur(0.3f)) ) - ).withDefaultValue(circleBlur(0.3f)) - ) - ); - - // Verify - assertNotNull(layer.getCircleBlur()); - assertNotNull(layer.getCircleBlur().getFunction()); - assertEquals(SourceFunction.class, layer.getCircleBlur().getFunction().getClass()); - assertEquals("FeaturePropertyA", ((SourceFunction) layer.getCircleBlur().getFunction()).getProperty()); - assertEquals(CategoricalStops.class, layer.getCircleBlur().getFunction().getStops().getClass()); - assertNotNull(((SourceFunction) layer.getCircleBlur().getFunction()).getDefaultValue()); - assertNotNull(((SourceFunction) layer.getCircleBlur().getFunction()).getDefaultValue().getValue()); - assertEquals(0.3f, ((SourceFunction) layer.getCircleBlur().getFunction()).getDefaultValue().getValue()); + ); + + // Verify + assertNotNull(layer.getCircleBlur()); + assertNotNull(layer.getCircleBlur().getFunction()); + assertEquals(SourceFunction.class, layer.getCircleBlur().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getCircleBlur().getFunction()).getProperty()); + assertEquals(CategoricalStops.class, layer.getCircleBlur().getFunction().getStops().getClass()); + assertNotNull(((SourceFunction) layer.getCircleBlur().getFunction()).getDefaultValue()); + assertNotNull(((SourceFunction) layer.getCircleBlur().getFunction()).getDefaultValue().getValue()); + assertEquals(0.3f, ((SourceFunction) layer.getCircleBlur().getFunction()).getDefaultValue().getValue()); + } + }); + } @Test @@ -534,34 +649,39 @@ public class CircleLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("circle-blur"); - assertNotNull(layer); - - // Set - layer.setProperties( - circleBlur( - composite( - "FeaturePropertyA", - exponential( - stop(0, 0.3f, circleBlur(0.9f)) - ).withBase(0.5f) - ).withDefaultValue(circleBlur(0.3f)) - ) - ); - - // Verify - assertNotNull(layer.getCircleBlur()); - assertNotNull(layer.getCircleBlur().getFunction()); - assertEquals(CompositeFunction.class, layer.getCircleBlur().getFunction().getClass()); - assertEquals("FeaturePropertyA", ((CompositeFunction) layer.getCircleBlur().getFunction()).getProperty()); - assertEquals(ExponentialStops.class, layer.getCircleBlur().getFunction().getStops().getClass()); - assertEquals(1, ((ExponentialStops) layer.getCircleBlur().getFunction().getStops()).size()); - - ExponentialStops<Stop.CompositeValue<Float, Float>, Float> stops = - (ExponentialStops<Stop.CompositeValue<Float, Float>, Float>) layer.getCircleBlur().getFunction().getStops(); - Stop<Stop.CompositeValue<Float, Float>, Float> stop = stops.iterator().next(); - assertEquals(0f, stop.in.zoom, 0.001); - assertEquals(0.3f, stop.in.value, 0.001f); - assertEquals(0.9f, stop.out, 0.001f); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + circleBlur( + composite( + "FeaturePropertyA", + exponential( + stop(0, 0.3f, circleBlur(0.9f)) + ).withBase(0.5f) + ).withDefaultValue(circleBlur(0.3f)) + ) + ); + + // Verify + assertNotNull(layer.getCircleBlur()); + assertNotNull(layer.getCircleBlur().getFunction()); + assertEquals(CompositeFunction.class, layer.getCircleBlur().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((CompositeFunction) layer.getCircleBlur().getFunction()).getProperty()); + assertEquals(ExponentialStops.class, layer.getCircleBlur().getFunction().getStops().getClass()); + assertEquals(1, ((ExponentialStops) layer.getCircleBlur().getFunction().getStops()).size()); + + ExponentialStops<Stop.CompositeValue<Float, Float>, Float> stops = + (ExponentialStops<Stop.CompositeValue<Float, Float>, Float>) layer.getCircleBlur().getFunction().getStops(); + Stop<Stop.CompositeValue<Float, Float>, Float> stop = stops.iterator().next(); + assertEquals(0f, stop.in.zoom, 0.001); + assertEquals(0.3f, stop.in.value, 0.001f); + assertEquals(0.9f, stop.out, 0.001f); + } + }); } @Test @@ -569,12 +689,17 @@ public class CircleLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("circle-opacityTransitionOptions"); - assertNotNull(layer); - - // Set and Get - TransitionOptions options = new TransitionOptions(300, 100); - layer.setCircleOpacityTransition(options); - assertEquals(layer.getCircleOpacityTransition(), options); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set and Get + TransitionOptions options = new TransitionOptions(300, 100); + layer.setCircleOpacityTransition(options); + assertEquals(layer.getCircleOpacityTransition(), options); + } + }); } @Test @@ -582,11 +707,16 @@ public class CircleLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("circle-opacity"); - assertNotNull(layer); - - // Set and Get - layer.setProperties(circleOpacity(0.3f)); - assertEquals((Float) layer.getCircleOpacity().getValue(), (Float) 0.3f); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set and Get + layer.setProperties(circleOpacity(0.3f)); + assertEquals((Float) layer.getCircleOpacity().getValue(), (Float) 0.3f); + } + }); } @Test @@ -594,26 +724,31 @@ public class CircleLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("circle-opacity"); - assertNotNull(layer); - - // Set - layer.setProperties( - circleOpacity( - zoom( - exponential( - stop(2, circleOpacity(0.3f)) - ).withBase(0.5f) - ) - ) - ); - - // Verify - assertNotNull(layer.getCircleOpacity()); - assertNotNull(layer.getCircleOpacity().getFunction()); - assertEquals(CameraFunction.class, layer.getCircleOpacity().getFunction().getClass()); - assertEquals(ExponentialStops.class, layer.getCircleOpacity().getFunction().getStops().getClass()); - assertEquals(0.5f, ((ExponentialStops) layer.getCircleOpacity().getFunction().getStops()).getBase(), 0.001); - assertEquals(1, ((ExponentialStops) layer.getCircleOpacity().getFunction().getStops()).size()); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + circleOpacity( + zoom( + exponential( + stop(2, circleOpacity(0.3f)) + ).withBase(0.5f) + ) + ) + ); + + // Verify + assertNotNull(layer.getCircleOpacity()); + assertNotNull(layer.getCircleOpacity().getFunction()); + assertEquals(CameraFunction.class, layer.getCircleOpacity().getFunction().getClass()); + assertEquals(ExponentialStops.class, layer.getCircleOpacity().getFunction().getStops().getClass()); + assertEquals(0.5f, ((ExponentialStops) layer.getCircleOpacity().getFunction().getStops()).getBase(), 0.001); + assertEquals(1, ((ExponentialStops) layer.getCircleOpacity().getFunction().getStops()).size()); + } + }); } @Test @@ -621,19 +756,24 @@ public class CircleLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("circle-opacity"); - assertNotNull(layer); - - // Set - layer.setProperties( - circleOpacity(property("FeaturePropertyA", Stops.<Float>identity())) - ); - - // Verify - assertNotNull(layer.getCircleOpacity()); - assertNotNull(layer.getCircleOpacity().getFunction()); - assertEquals(SourceFunction.class, layer.getCircleOpacity().getFunction().getClass()); - assertEquals("FeaturePropertyA", ((SourceFunction) layer.getCircleOpacity().getFunction()).getProperty()); - assertEquals(IdentityStops.class, layer.getCircleOpacity().getFunction().getStops().getClass()); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + circleOpacity(property("FeaturePropertyA", Stops.<Float>identity())) + ); + + // Verify + assertNotNull(layer.getCircleOpacity()); + assertNotNull(layer.getCircleOpacity().getFunction()); + assertEquals(SourceFunction.class, layer.getCircleOpacity().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getCircleOpacity().getFunction()).getProperty()); + assertEquals(IdentityStops.class, layer.getCircleOpacity().getFunction().getStops().getClass()); + } + }); } @Test @@ -641,26 +781,31 @@ public class CircleLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("circle-opacity"); - assertNotNull(layer); - - // Set - layer.setProperties( - circleOpacity( - property( - "FeaturePropertyA", - exponential( - stop(0.3f, circleOpacity(0.3f)) - ).withBase(0.5f) - ) - ) - ); - - // Verify - assertNotNull(layer.getCircleOpacity()); - assertNotNull(layer.getCircleOpacity().getFunction()); - assertEquals(SourceFunction.class, layer.getCircleOpacity().getFunction().getClass()); - assertEquals("FeaturePropertyA", ((SourceFunction) layer.getCircleOpacity().getFunction()).getProperty()); - assertEquals(ExponentialStops.class, layer.getCircleOpacity().getFunction().getStops().getClass()); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + circleOpacity( + property( + "FeaturePropertyA", + exponential( + stop(0.3f, circleOpacity(0.3f)) + ).withBase(0.5f) + ) + ) + ); + + // Verify + assertNotNull(layer.getCircleOpacity()); + assertNotNull(layer.getCircleOpacity().getFunction()); + assertEquals(SourceFunction.class, layer.getCircleOpacity().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getCircleOpacity().getFunction()).getProperty()); + assertEquals(ExponentialStops.class, layer.getCircleOpacity().getFunction().getStops().getClass()); + } + }); } @Test @@ -668,29 +813,35 @@ public class CircleLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("circle-opacity"); - assertNotNull(layer); - - // Set - layer.setProperties( - circleOpacity( - property( - "FeaturePropertyA", - categorical( - stop(1.0f, circleOpacity(0.3f)) + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + circleOpacity( + property( + "FeaturePropertyA", + categorical( + stop(1.0f, circleOpacity(0.3f)) + ) + ).withDefaultValue(circleOpacity(0.3f)) ) - ).withDefaultValue(circleOpacity(0.3f)) - ) - ); - - // Verify - assertNotNull(layer.getCircleOpacity()); - assertNotNull(layer.getCircleOpacity().getFunction()); - assertEquals(SourceFunction.class, layer.getCircleOpacity().getFunction().getClass()); - assertEquals("FeaturePropertyA", ((SourceFunction) layer.getCircleOpacity().getFunction()).getProperty()); - assertEquals(CategoricalStops.class, layer.getCircleOpacity().getFunction().getStops().getClass()); - assertNotNull(((SourceFunction) layer.getCircleOpacity().getFunction()).getDefaultValue()); - assertNotNull(((SourceFunction) layer.getCircleOpacity().getFunction()).getDefaultValue().getValue()); - assertEquals(0.3f, ((SourceFunction) layer.getCircleOpacity().getFunction()).getDefaultValue().getValue()); + ); + + // Verify + assertNotNull(layer.getCircleOpacity()); + assertNotNull(layer.getCircleOpacity().getFunction()); + assertEquals(SourceFunction.class, layer.getCircleOpacity().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getCircleOpacity().getFunction()).getProperty()); + assertEquals(CategoricalStops.class, layer.getCircleOpacity().getFunction().getStops().getClass()); + assertNotNull(((SourceFunction) layer.getCircleOpacity().getFunction()).getDefaultValue()); + assertNotNull(((SourceFunction) layer.getCircleOpacity().getFunction()).getDefaultValue().getValue()); + assertEquals(0.3f, ((SourceFunction) layer.getCircleOpacity().getFunction()).getDefaultValue().getValue()); + } + }); + } @Test @@ -698,34 +849,39 @@ public class CircleLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("circle-opacity"); - assertNotNull(layer); - - // Set - layer.setProperties( - circleOpacity( - composite( - "FeaturePropertyA", - exponential( - stop(0, 0.3f, circleOpacity(0.9f)) - ).withBase(0.5f) - ).withDefaultValue(circleOpacity(0.3f)) - ) - ); - - // Verify - assertNotNull(layer.getCircleOpacity()); - assertNotNull(layer.getCircleOpacity().getFunction()); - assertEquals(CompositeFunction.class, layer.getCircleOpacity().getFunction().getClass()); - assertEquals("FeaturePropertyA", ((CompositeFunction) layer.getCircleOpacity().getFunction()).getProperty()); - assertEquals(ExponentialStops.class, layer.getCircleOpacity().getFunction().getStops().getClass()); - assertEquals(1, ((ExponentialStops) layer.getCircleOpacity().getFunction().getStops()).size()); - - ExponentialStops<Stop.CompositeValue<Float, Float>, Float> stops = - (ExponentialStops<Stop.CompositeValue<Float, Float>, Float>) layer.getCircleOpacity().getFunction().getStops(); - Stop<Stop.CompositeValue<Float, Float>, Float> stop = stops.iterator().next(); - assertEquals(0f, stop.in.zoom, 0.001); - assertEquals(0.3f, stop.in.value, 0.001f); - assertEquals(0.9f, stop.out, 0.001f); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + circleOpacity( + composite( + "FeaturePropertyA", + exponential( + stop(0, 0.3f, circleOpacity(0.9f)) + ).withBase(0.5f) + ).withDefaultValue(circleOpacity(0.3f)) + ) + ); + + // Verify + assertNotNull(layer.getCircleOpacity()); + assertNotNull(layer.getCircleOpacity().getFunction()); + assertEquals(CompositeFunction.class, layer.getCircleOpacity().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((CompositeFunction) layer.getCircleOpacity().getFunction()).getProperty()); + assertEquals(ExponentialStops.class, layer.getCircleOpacity().getFunction().getStops().getClass()); + assertEquals(1, ((ExponentialStops) layer.getCircleOpacity().getFunction().getStops()).size()); + + ExponentialStops<Stop.CompositeValue<Float, Float>, Float> stops = + (ExponentialStops<Stop.CompositeValue<Float, Float>, Float>) layer.getCircleOpacity().getFunction().getStops(); + Stop<Stop.CompositeValue<Float, Float>, Float> stop = stops.iterator().next(); + assertEquals(0f, stop.in.zoom, 0.001); + assertEquals(0.3f, stop.in.value, 0.001f); + assertEquals(0.9f, stop.out, 0.001f); + } + }); } @Test @@ -733,12 +889,17 @@ public class CircleLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("circle-translateTransitionOptions"); - assertNotNull(layer); - - // Set and Get - TransitionOptions options = new TransitionOptions(300, 100); - layer.setCircleTranslateTransition(options); - assertEquals(layer.getCircleTranslateTransition(), options); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set and Get + TransitionOptions options = new TransitionOptions(300, 100); + layer.setCircleTranslateTransition(options); + assertEquals(layer.getCircleTranslateTransition(), options); + } + }); } @Test @@ -746,11 +907,16 @@ public class CircleLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("circle-translate"); - assertNotNull(layer); - - // Set and Get - layer.setProperties(circleTranslate(new Float[]{0f,0f})); - assertEquals((Float[]) layer.getCircleTranslate().getValue(), (Float[]) new Float[]{0f,0f}); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set and Get + layer.setProperties(circleTranslate(new Float[] {0f, 0f})); + assertEquals((Float[]) layer.getCircleTranslate().getValue(), (Float[]) new Float[] {0f, 0f}); + } + }); } @Test @@ -758,26 +924,31 @@ public class CircleLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("circle-translate"); - assertNotNull(layer); - - // Set - layer.setProperties( - circleTranslate( - zoom( - exponential( - stop(2, circleTranslate(new Float[]{0f,0f})) - ).withBase(0.5f) - ) - ) - ); - - // Verify - assertNotNull(layer.getCircleTranslate()); - assertNotNull(layer.getCircleTranslate().getFunction()); - assertEquals(CameraFunction.class, layer.getCircleTranslate().getFunction().getClass()); - assertEquals(ExponentialStops.class, layer.getCircleTranslate().getFunction().getStops().getClass()); - assertEquals(0.5f, ((ExponentialStops) layer.getCircleTranslate().getFunction().getStops()).getBase(), 0.001); - assertEquals(1, ((ExponentialStops) layer.getCircleTranslate().getFunction().getStops()).size()); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + circleTranslate( + zoom( + exponential( + stop(2, circleTranslate(new Float[] {0f, 0f})) + ).withBase(0.5f) + ) + ) + ); + + // Verify + assertNotNull(layer.getCircleTranslate()); + assertNotNull(layer.getCircleTranslate().getFunction()); + assertEquals(CameraFunction.class, layer.getCircleTranslate().getFunction().getClass()); + assertEquals(ExponentialStops.class, layer.getCircleTranslate().getFunction().getStops().getClass()); + assertEquals(0.5f, ((ExponentialStops) layer.getCircleTranslate().getFunction().getStops()).getBase(), 0.001); + assertEquals(1, ((ExponentialStops) layer.getCircleTranslate().getFunction().getStops()).size()); + } + }); } @Test @@ -785,11 +956,16 @@ public class CircleLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("circle-translate-anchor"); - assertNotNull(layer); - - // Set and Get - layer.setProperties(circleTranslateAnchor(CIRCLE_TRANSLATE_ANCHOR_MAP)); - assertEquals((String) layer.getCircleTranslateAnchor().getValue(), (String) CIRCLE_TRANSLATE_ANCHOR_MAP); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set and Get + layer.setProperties(circleTranslateAnchor(CIRCLE_TRANSLATE_ANCHOR_MAP)); + assertEquals((String) layer.getCircleTranslateAnchor().getValue(), (String) CIRCLE_TRANSLATE_ANCHOR_MAP); + } + }); } @Test @@ -797,25 +973,30 @@ public class CircleLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("circle-translate-anchor"); - assertNotNull(layer); - - // Set - layer.setProperties( - circleTranslateAnchor( - zoom( - interval( - stop(2, circleTranslateAnchor(CIRCLE_TRANSLATE_ANCHOR_MAP)) + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + circleTranslateAnchor( + zoom( + interval( + stop(2, circleTranslateAnchor(CIRCLE_TRANSLATE_ANCHOR_MAP)) + ) + ) ) - ) - ) - ); - - // Verify - assertNotNull(layer.getCircleTranslateAnchor()); - assertNotNull(layer.getCircleTranslateAnchor().getFunction()); - assertEquals(CameraFunction.class, layer.getCircleTranslateAnchor().getFunction().getClass()); - assertEquals(IntervalStops.class, layer.getCircleTranslateAnchor().getFunction().getStops().getClass()); - assertEquals(1, ((IntervalStops) layer.getCircleTranslateAnchor().getFunction().getStops()).size()); + ); + + // Verify + assertNotNull(layer.getCircleTranslateAnchor()); + assertNotNull(layer.getCircleTranslateAnchor().getFunction()); + assertEquals(CameraFunction.class, layer.getCircleTranslateAnchor().getFunction().getClass()); + assertEquals(IntervalStops.class, layer.getCircleTranslateAnchor().getFunction().getStops().getClass()); + assertEquals(1, ((IntervalStops) layer.getCircleTranslateAnchor().getFunction().getStops()).size()); + } + }); } @Test @@ -823,11 +1004,16 @@ public class CircleLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("circle-pitch-scale"); - assertNotNull(layer); - - // Set and Get - layer.setProperties(circlePitchScale(CIRCLE_PITCH_SCALE_MAP)); - assertEquals((String) layer.getCirclePitchScale().getValue(), (String) CIRCLE_PITCH_SCALE_MAP); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set and Get + layer.setProperties(circlePitchScale(CIRCLE_PITCH_SCALE_MAP)); + assertEquals((String) layer.getCirclePitchScale().getValue(), (String) CIRCLE_PITCH_SCALE_MAP); + } + }); } @Test @@ -835,25 +1021,30 @@ public class CircleLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("circle-pitch-scale"); - assertNotNull(layer); - - // Set - layer.setProperties( - circlePitchScale( - zoom( - interval( - stop(2, circlePitchScale(CIRCLE_PITCH_SCALE_MAP)) + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + circlePitchScale( + zoom( + interval( + stop(2, circlePitchScale(CIRCLE_PITCH_SCALE_MAP)) + ) + ) ) - ) - ) - ); - - // Verify - assertNotNull(layer.getCirclePitchScale()); - assertNotNull(layer.getCirclePitchScale().getFunction()); - assertEquals(CameraFunction.class, layer.getCirclePitchScale().getFunction().getClass()); - assertEquals(IntervalStops.class, layer.getCirclePitchScale().getFunction().getStops().getClass()); - assertEquals(1, ((IntervalStops) layer.getCirclePitchScale().getFunction().getStops()).size()); + ); + + // Verify + assertNotNull(layer.getCirclePitchScale()); + assertNotNull(layer.getCirclePitchScale().getFunction()); + assertEquals(CameraFunction.class, layer.getCirclePitchScale().getFunction().getClass()); + assertEquals(IntervalStops.class, layer.getCirclePitchScale().getFunction().getStops().getClass()); + assertEquals(1, ((IntervalStops) layer.getCirclePitchScale().getFunction().getStops()).size()); + } + }); } @Test @@ -861,12 +1052,17 @@ public class CircleLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("circle-stroke-widthTransitionOptions"); - assertNotNull(layer); - - // Set and Get - TransitionOptions options = new TransitionOptions(300, 100); - layer.setCircleStrokeWidthTransition(options); - assertEquals(layer.getCircleStrokeWidthTransition(), options); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set and Get + TransitionOptions options = new TransitionOptions(300, 100); + layer.setCircleStrokeWidthTransition(options); + assertEquals(layer.getCircleStrokeWidthTransition(), options); + } + }); } @Test @@ -874,11 +1070,16 @@ public class CircleLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("circle-stroke-width"); - assertNotNull(layer); - - // Set and Get - layer.setProperties(circleStrokeWidth(0.3f)); - assertEquals((Float) layer.getCircleStrokeWidth().getValue(), (Float) 0.3f); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set and Get + layer.setProperties(circleStrokeWidth(0.3f)); + assertEquals((Float) layer.getCircleStrokeWidth().getValue(), (Float) 0.3f); + } + }); } @Test @@ -886,26 +1087,31 @@ public class CircleLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("circle-stroke-width"); - assertNotNull(layer); - - // Set - layer.setProperties( - circleStrokeWidth( - zoom( - exponential( - stop(2, circleStrokeWidth(0.3f)) - ).withBase(0.5f) - ) - ) - ); - - // Verify - assertNotNull(layer.getCircleStrokeWidth()); - assertNotNull(layer.getCircleStrokeWidth().getFunction()); - assertEquals(CameraFunction.class, layer.getCircleStrokeWidth().getFunction().getClass()); - assertEquals(ExponentialStops.class, layer.getCircleStrokeWidth().getFunction().getStops().getClass()); - assertEquals(0.5f, ((ExponentialStops) layer.getCircleStrokeWidth().getFunction().getStops()).getBase(), 0.001); - assertEquals(1, ((ExponentialStops) layer.getCircleStrokeWidth().getFunction().getStops()).size()); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + circleStrokeWidth( + zoom( + exponential( + stop(2, circleStrokeWidth(0.3f)) + ).withBase(0.5f) + ) + ) + ); + + // Verify + assertNotNull(layer.getCircleStrokeWidth()); + assertNotNull(layer.getCircleStrokeWidth().getFunction()); + assertEquals(CameraFunction.class, layer.getCircleStrokeWidth().getFunction().getClass()); + assertEquals(ExponentialStops.class, layer.getCircleStrokeWidth().getFunction().getStops().getClass()); + assertEquals(0.5f, ((ExponentialStops) layer.getCircleStrokeWidth().getFunction().getStops()).getBase(), 0.001); + assertEquals(1, ((ExponentialStops) layer.getCircleStrokeWidth().getFunction().getStops()).size()); + } + }); } @Test @@ -913,19 +1119,24 @@ public class CircleLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("circle-stroke-width"); - assertNotNull(layer); - - // Set - layer.setProperties( - circleStrokeWidth(property("FeaturePropertyA", Stops.<Float>identity())) - ); - - // Verify - assertNotNull(layer.getCircleStrokeWidth()); - assertNotNull(layer.getCircleStrokeWidth().getFunction()); - assertEquals(SourceFunction.class, layer.getCircleStrokeWidth().getFunction().getClass()); - assertEquals("FeaturePropertyA", ((SourceFunction) layer.getCircleStrokeWidth().getFunction()).getProperty()); - assertEquals(IdentityStops.class, layer.getCircleStrokeWidth().getFunction().getStops().getClass()); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + circleStrokeWidth(property("FeaturePropertyA", Stops.<Float>identity())) + ); + + // Verify + assertNotNull(layer.getCircleStrokeWidth()); + assertNotNull(layer.getCircleStrokeWidth().getFunction()); + assertEquals(SourceFunction.class, layer.getCircleStrokeWidth().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getCircleStrokeWidth().getFunction()).getProperty()); + assertEquals(IdentityStops.class, layer.getCircleStrokeWidth().getFunction().getStops().getClass()); + } + }); } @Test @@ -933,26 +1144,31 @@ public class CircleLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("circle-stroke-width"); - assertNotNull(layer); - - // Set - layer.setProperties( - circleStrokeWidth( - property( - "FeaturePropertyA", - exponential( - stop(0.3f, circleStrokeWidth(0.3f)) - ).withBase(0.5f) - ) - ) - ); - - // Verify - assertNotNull(layer.getCircleStrokeWidth()); - assertNotNull(layer.getCircleStrokeWidth().getFunction()); - assertEquals(SourceFunction.class, layer.getCircleStrokeWidth().getFunction().getClass()); - assertEquals("FeaturePropertyA", ((SourceFunction) layer.getCircleStrokeWidth().getFunction()).getProperty()); - assertEquals(ExponentialStops.class, layer.getCircleStrokeWidth().getFunction().getStops().getClass()); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + circleStrokeWidth( + property( + "FeaturePropertyA", + exponential( + stop(0.3f, circleStrokeWidth(0.3f)) + ).withBase(0.5f) + ) + ) + ); + + // Verify + assertNotNull(layer.getCircleStrokeWidth()); + assertNotNull(layer.getCircleStrokeWidth().getFunction()); + assertEquals(SourceFunction.class, layer.getCircleStrokeWidth().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getCircleStrokeWidth().getFunction()).getProperty()); + assertEquals(ExponentialStops.class, layer.getCircleStrokeWidth().getFunction().getStops().getClass()); + } + }); } @Test @@ -960,29 +1176,35 @@ public class CircleLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("circle-stroke-width"); - assertNotNull(layer); - - // Set - layer.setProperties( - circleStrokeWidth( - property( - "FeaturePropertyA", - categorical( - stop(1.0f, circleStrokeWidth(0.3f)) + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + circleStrokeWidth( + property( + "FeaturePropertyA", + categorical( + stop(1.0f, circleStrokeWidth(0.3f)) + ) + ).withDefaultValue(circleStrokeWidth(0.3f)) ) - ).withDefaultValue(circleStrokeWidth(0.3f)) - ) - ); - - // Verify - assertNotNull(layer.getCircleStrokeWidth()); - assertNotNull(layer.getCircleStrokeWidth().getFunction()); - assertEquals(SourceFunction.class, layer.getCircleStrokeWidth().getFunction().getClass()); - assertEquals("FeaturePropertyA", ((SourceFunction) layer.getCircleStrokeWidth().getFunction()).getProperty()); - assertEquals(CategoricalStops.class, layer.getCircleStrokeWidth().getFunction().getStops().getClass()); - assertNotNull(((SourceFunction) layer.getCircleStrokeWidth().getFunction()).getDefaultValue()); - assertNotNull(((SourceFunction) layer.getCircleStrokeWidth().getFunction()).getDefaultValue().getValue()); - assertEquals(0.3f, ((SourceFunction) layer.getCircleStrokeWidth().getFunction()).getDefaultValue().getValue()); + ); + + // Verify + assertNotNull(layer.getCircleStrokeWidth()); + assertNotNull(layer.getCircleStrokeWidth().getFunction()); + assertEquals(SourceFunction.class, layer.getCircleStrokeWidth().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getCircleStrokeWidth().getFunction()).getProperty()); + assertEquals(CategoricalStops.class, layer.getCircleStrokeWidth().getFunction().getStops().getClass()); + assertNotNull(((SourceFunction) layer.getCircleStrokeWidth().getFunction()).getDefaultValue()); + assertNotNull(((SourceFunction) layer.getCircleStrokeWidth().getFunction()).getDefaultValue().getValue()); + assertEquals(0.3f, ((SourceFunction) layer.getCircleStrokeWidth().getFunction()).getDefaultValue().getValue()); + } + }); + } @Test @@ -990,34 +1212,39 @@ public class CircleLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("circle-stroke-width"); - assertNotNull(layer); - - // Set - layer.setProperties( - circleStrokeWidth( - composite( - "FeaturePropertyA", - exponential( - stop(0, 0.3f, circleStrokeWidth(0.9f)) - ).withBase(0.5f) - ).withDefaultValue(circleStrokeWidth(0.3f)) - ) - ); - - // Verify - assertNotNull(layer.getCircleStrokeWidth()); - assertNotNull(layer.getCircleStrokeWidth().getFunction()); - assertEquals(CompositeFunction.class, layer.getCircleStrokeWidth().getFunction().getClass()); - assertEquals("FeaturePropertyA", ((CompositeFunction) layer.getCircleStrokeWidth().getFunction()).getProperty()); - assertEquals(ExponentialStops.class, layer.getCircleStrokeWidth().getFunction().getStops().getClass()); - assertEquals(1, ((ExponentialStops) layer.getCircleStrokeWidth().getFunction().getStops()).size()); - - ExponentialStops<Stop.CompositeValue<Float, Float>, Float> stops = - (ExponentialStops<Stop.CompositeValue<Float, Float>, Float>) layer.getCircleStrokeWidth().getFunction().getStops(); - Stop<Stop.CompositeValue<Float, Float>, Float> stop = stops.iterator().next(); - assertEquals(0f, stop.in.zoom, 0.001); - assertEquals(0.3f, stop.in.value, 0.001f); - assertEquals(0.9f, stop.out, 0.001f); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + circleStrokeWidth( + composite( + "FeaturePropertyA", + exponential( + stop(0, 0.3f, circleStrokeWidth(0.9f)) + ).withBase(0.5f) + ).withDefaultValue(circleStrokeWidth(0.3f)) + ) + ); + + // Verify + assertNotNull(layer.getCircleStrokeWidth()); + assertNotNull(layer.getCircleStrokeWidth().getFunction()); + assertEquals(CompositeFunction.class, layer.getCircleStrokeWidth().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((CompositeFunction) layer.getCircleStrokeWidth().getFunction()).getProperty()); + assertEquals(ExponentialStops.class, layer.getCircleStrokeWidth().getFunction().getStops().getClass()); + assertEquals(1, ((ExponentialStops) layer.getCircleStrokeWidth().getFunction().getStops()).size()); + + ExponentialStops<Stop.CompositeValue<Float, Float>, Float> stops = + (ExponentialStops<Stop.CompositeValue<Float, Float>, Float>) layer.getCircleStrokeWidth().getFunction().getStops(); + Stop<Stop.CompositeValue<Float, Float>, Float> stop = stops.iterator().next(); + assertEquals(0f, stop.in.zoom, 0.001); + assertEquals(0.3f, stop.in.value, 0.001f); + assertEquals(0.9f, stop.out, 0.001f); + } + }); } @Test @@ -1025,12 +1252,17 @@ public class CircleLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("circle-stroke-colorTransitionOptions"); - assertNotNull(layer); - - // Set and Get - TransitionOptions options = new TransitionOptions(300, 100); - layer.setCircleStrokeColorTransition(options); - assertEquals(layer.getCircleStrokeColorTransition(), options); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set and Get + TransitionOptions options = new TransitionOptions(300, 100); + layer.setCircleStrokeColorTransition(options); + assertEquals(layer.getCircleStrokeColorTransition(), options); + } + }); } @Test @@ -1038,11 +1270,16 @@ public class CircleLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("circle-stroke-color"); - assertNotNull(layer); - - // Set and Get - layer.setProperties(circleStrokeColor("rgba(0, 0, 0, 1)")); - assertEquals((String) layer.getCircleStrokeColor().getValue(), (String) "rgba(0, 0, 0, 1)"); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set and Get + layer.setProperties(circleStrokeColor("rgba(0, 0, 0, 1)")); + assertEquals((String) layer.getCircleStrokeColor().getValue(), (String) "rgba(0, 0, 0, 1)"); + } + }); } @Test @@ -1050,26 +1287,31 @@ public class CircleLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("circle-stroke-color"); - assertNotNull(layer); - - // Set - layer.setProperties( - circleStrokeColor( - zoom( - exponential( - stop(2, circleStrokeColor("rgba(0, 0, 0, 1)")) - ).withBase(0.5f) - ) - ) - ); - - // Verify - assertNotNull(layer.getCircleStrokeColor()); - assertNotNull(layer.getCircleStrokeColor().getFunction()); - assertEquals(CameraFunction.class, layer.getCircleStrokeColor().getFunction().getClass()); - assertEquals(ExponentialStops.class, layer.getCircleStrokeColor().getFunction().getStops().getClass()); - assertEquals(0.5f, ((ExponentialStops) layer.getCircleStrokeColor().getFunction().getStops()).getBase(), 0.001); - assertEquals(1, ((ExponentialStops) layer.getCircleStrokeColor().getFunction().getStops()).size()); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + circleStrokeColor( + zoom( + exponential( + stop(2, circleStrokeColor("rgba(0, 0, 0, 1)")) + ).withBase(0.5f) + ) + ) + ); + + // Verify + assertNotNull(layer.getCircleStrokeColor()); + assertNotNull(layer.getCircleStrokeColor().getFunction()); + assertEquals(CameraFunction.class, layer.getCircleStrokeColor().getFunction().getClass()); + assertEquals(ExponentialStops.class, layer.getCircleStrokeColor().getFunction().getStops().getClass()); + assertEquals(0.5f, ((ExponentialStops) layer.getCircleStrokeColor().getFunction().getStops()).getBase(), 0.001); + assertEquals(1, ((ExponentialStops) layer.getCircleStrokeColor().getFunction().getStops()).size()); + } + }); } @Test @@ -1077,19 +1319,24 @@ public class CircleLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("circle-stroke-color"); - assertNotNull(layer); - - // Set - layer.setProperties( - circleStrokeColor(property("FeaturePropertyA", Stops.<String>identity())) - ); - - // Verify - assertNotNull(layer.getCircleStrokeColor()); - assertNotNull(layer.getCircleStrokeColor().getFunction()); - assertEquals(SourceFunction.class, layer.getCircleStrokeColor().getFunction().getClass()); - assertEquals("FeaturePropertyA", ((SourceFunction) layer.getCircleStrokeColor().getFunction()).getProperty()); - assertEquals(IdentityStops.class, layer.getCircleStrokeColor().getFunction().getStops().getClass()); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + circleStrokeColor(property("FeaturePropertyA", Stops.<String>identity())) + ); + + // Verify + assertNotNull(layer.getCircleStrokeColor()); + assertNotNull(layer.getCircleStrokeColor().getFunction()); + assertEquals(SourceFunction.class, layer.getCircleStrokeColor().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getCircleStrokeColor().getFunction()).getProperty()); + assertEquals(IdentityStops.class, layer.getCircleStrokeColor().getFunction().getStops().getClass()); + } + }); } @Test @@ -1097,26 +1344,31 @@ public class CircleLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("circle-stroke-color"); - assertNotNull(layer); - - // Set - layer.setProperties( - circleStrokeColor( - property( - "FeaturePropertyA", - exponential( - stop(Color.RED, circleStrokeColor(Color.RED)) - ).withBase(0.5f) - ) - ) - ); - - // Verify - assertNotNull(layer.getCircleStrokeColor()); - assertNotNull(layer.getCircleStrokeColor().getFunction()); - assertEquals(SourceFunction.class, layer.getCircleStrokeColor().getFunction().getClass()); - assertEquals("FeaturePropertyA", ((SourceFunction) layer.getCircleStrokeColor().getFunction()).getProperty()); - assertEquals(ExponentialStops.class, layer.getCircleStrokeColor().getFunction().getStops().getClass()); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + circleStrokeColor( + property( + "FeaturePropertyA", + exponential( + stop(Color.RED, circleStrokeColor(Color.RED)) + ).withBase(0.5f) + ) + ) + ); + + // Verify + assertNotNull(layer.getCircleStrokeColor()); + assertNotNull(layer.getCircleStrokeColor().getFunction()); + assertEquals(SourceFunction.class, layer.getCircleStrokeColor().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getCircleStrokeColor().getFunction()).getProperty()); + assertEquals(ExponentialStops.class, layer.getCircleStrokeColor().getFunction().getStops().getClass()); + } + }); } @Test @@ -1124,29 +1376,35 @@ public class CircleLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("circle-stroke-color"); - assertNotNull(layer); - - // Set - layer.setProperties( - circleStrokeColor( - property( - "FeaturePropertyA", - categorical( - stop("valueA", circleStrokeColor(Color.RED)) + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + circleStrokeColor( + property( + "FeaturePropertyA", + categorical( + stop("valueA", circleStrokeColor(Color.RED)) + ) + ).withDefaultValue(circleStrokeColor(Color.GREEN)) ) - ).withDefaultValue(circleStrokeColor(Color.GREEN)) - ) - ); - - // Verify - assertNotNull(layer.getCircleStrokeColor()); - assertNotNull(layer.getCircleStrokeColor().getFunction()); - assertEquals(SourceFunction.class, layer.getCircleStrokeColor().getFunction().getClass()); - assertEquals("FeaturePropertyA", ((SourceFunction) layer.getCircleStrokeColor().getFunction()).getProperty()); - assertEquals(CategoricalStops.class, layer.getCircleStrokeColor().getFunction().getStops().getClass()); - assertNotNull(((SourceFunction) layer.getCircleStrokeColor().getFunction()).getDefaultValue()); - assertNotNull(((SourceFunction) layer.getCircleStrokeColor().getFunction()).getDefaultValue().getValue()); - assertEquals(Color.GREEN, (int) ((SourceFunction) layer.getCircleStrokeColor().getFunction()).getDefaultValue().getColorInt()); + ); + + // Verify + assertNotNull(layer.getCircleStrokeColor()); + assertNotNull(layer.getCircleStrokeColor().getFunction()); + assertEquals(SourceFunction.class, layer.getCircleStrokeColor().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getCircleStrokeColor().getFunction()).getProperty()); + assertEquals(CategoricalStops.class, layer.getCircleStrokeColor().getFunction().getStops().getClass()); + assertNotNull(((SourceFunction) layer.getCircleStrokeColor().getFunction()).getDefaultValue()); + assertNotNull(((SourceFunction) layer.getCircleStrokeColor().getFunction()).getDefaultValue().getValue()); + assertEquals(Color.GREEN, (int) ((SourceFunction) layer.getCircleStrokeColor().getFunction()).getDefaultValue().getColorInt()); + } + }); + } @Test @@ -1154,11 +1412,16 @@ public class CircleLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("circle-stroke-color"); - assertNotNull(layer); - - // Set and Get - layer.setProperties(circleStrokeColor(Color.RED)); - assertEquals(layer.getCircleStrokeColorAsInt(), Color.RED); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set and Get + layer.setProperties(circleStrokeColor(Color.RED)); + assertEquals(layer.getCircleStrokeColorAsInt(), Color.RED); + } + }); } @Test @@ -1166,12 +1429,17 @@ public class CircleLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("circle-stroke-opacityTransitionOptions"); - assertNotNull(layer); - - // Set and Get - TransitionOptions options = new TransitionOptions(300, 100); - layer.setCircleStrokeOpacityTransition(options); - assertEquals(layer.getCircleStrokeOpacityTransition(), options); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set and Get + TransitionOptions options = new TransitionOptions(300, 100); + layer.setCircleStrokeOpacityTransition(options); + assertEquals(layer.getCircleStrokeOpacityTransition(), options); + } + }); } @Test @@ -1179,11 +1447,16 @@ public class CircleLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("circle-stroke-opacity"); - assertNotNull(layer); - - // Set and Get - layer.setProperties(circleStrokeOpacity(0.3f)); - assertEquals((Float) layer.getCircleStrokeOpacity().getValue(), (Float) 0.3f); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set and Get + layer.setProperties(circleStrokeOpacity(0.3f)); + assertEquals((Float) layer.getCircleStrokeOpacity().getValue(), (Float) 0.3f); + } + }); } @Test @@ -1191,26 +1464,31 @@ public class CircleLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("circle-stroke-opacity"); - assertNotNull(layer); - - // Set - layer.setProperties( - circleStrokeOpacity( - zoom( - exponential( - stop(2, circleStrokeOpacity(0.3f)) - ).withBase(0.5f) - ) - ) - ); - - // Verify - assertNotNull(layer.getCircleStrokeOpacity()); - assertNotNull(layer.getCircleStrokeOpacity().getFunction()); - assertEquals(CameraFunction.class, layer.getCircleStrokeOpacity().getFunction().getClass()); - assertEquals(ExponentialStops.class, layer.getCircleStrokeOpacity().getFunction().getStops().getClass()); - assertEquals(0.5f, ((ExponentialStops) layer.getCircleStrokeOpacity().getFunction().getStops()).getBase(), 0.001); - assertEquals(1, ((ExponentialStops) layer.getCircleStrokeOpacity().getFunction().getStops()).size()); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + circleStrokeOpacity( + zoom( + exponential( + stop(2, circleStrokeOpacity(0.3f)) + ).withBase(0.5f) + ) + ) + ); + + // Verify + assertNotNull(layer.getCircleStrokeOpacity()); + assertNotNull(layer.getCircleStrokeOpacity().getFunction()); + assertEquals(CameraFunction.class, layer.getCircleStrokeOpacity().getFunction().getClass()); + assertEquals(ExponentialStops.class, layer.getCircleStrokeOpacity().getFunction().getStops().getClass()); + assertEquals(0.5f, ((ExponentialStops) layer.getCircleStrokeOpacity().getFunction().getStops()).getBase(), 0.001); + assertEquals(1, ((ExponentialStops) layer.getCircleStrokeOpacity().getFunction().getStops()).size()); + } + }); } @Test @@ -1218,19 +1496,24 @@ public class CircleLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("circle-stroke-opacity"); - assertNotNull(layer); - - // Set - layer.setProperties( - circleStrokeOpacity(property("FeaturePropertyA", Stops.<Float>identity())) - ); - - // Verify - assertNotNull(layer.getCircleStrokeOpacity()); - assertNotNull(layer.getCircleStrokeOpacity().getFunction()); - assertEquals(SourceFunction.class, layer.getCircleStrokeOpacity().getFunction().getClass()); - assertEquals("FeaturePropertyA", ((SourceFunction) layer.getCircleStrokeOpacity().getFunction()).getProperty()); - assertEquals(IdentityStops.class, layer.getCircleStrokeOpacity().getFunction().getStops().getClass()); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + circleStrokeOpacity(property("FeaturePropertyA", Stops.<Float>identity())) + ); + + // Verify + assertNotNull(layer.getCircleStrokeOpacity()); + assertNotNull(layer.getCircleStrokeOpacity().getFunction()); + assertEquals(SourceFunction.class, layer.getCircleStrokeOpacity().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getCircleStrokeOpacity().getFunction()).getProperty()); + assertEquals(IdentityStops.class, layer.getCircleStrokeOpacity().getFunction().getStops().getClass()); + } + }); } @Test @@ -1238,26 +1521,31 @@ public class CircleLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("circle-stroke-opacity"); - assertNotNull(layer); - - // Set - layer.setProperties( - circleStrokeOpacity( - property( - "FeaturePropertyA", - exponential( - stop(0.3f, circleStrokeOpacity(0.3f)) - ).withBase(0.5f) - ) - ) - ); - - // Verify - assertNotNull(layer.getCircleStrokeOpacity()); - assertNotNull(layer.getCircleStrokeOpacity().getFunction()); - assertEquals(SourceFunction.class, layer.getCircleStrokeOpacity().getFunction().getClass()); - assertEquals("FeaturePropertyA", ((SourceFunction) layer.getCircleStrokeOpacity().getFunction()).getProperty()); - assertEquals(ExponentialStops.class, layer.getCircleStrokeOpacity().getFunction().getStops().getClass()); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + circleStrokeOpacity( + property( + "FeaturePropertyA", + exponential( + stop(0.3f, circleStrokeOpacity(0.3f)) + ).withBase(0.5f) + ) + ) + ); + + // Verify + assertNotNull(layer.getCircleStrokeOpacity()); + assertNotNull(layer.getCircleStrokeOpacity().getFunction()); + assertEquals(SourceFunction.class, layer.getCircleStrokeOpacity().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getCircleStrokeOpacity().getFunction()).getProperty()); + assertEquals(ExponentialStops.class, layer.getCircleStrokeOpacity().getFunction().getStops().getClass()); + } + }); } @Test @@ -1265,29 +1553,35 @@ public class CircleLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("circle-stroke-opacity"); - assertNotNull(layer); - - // Set - layer.setProperties( - circleStrokeOpacity( - property( - "FeaturePropertyA", - categorical( - stop(1.0f, circleStrokeOpacity(0.3f)) + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + circleStrokeOpacity( + property( + "FeaturePropertyA", + categorical( + stop(1.0f, circleStrokeOpacity(0.3f)) + ) + ).withDefaultValue(circleStrokeOpacity(0.3f)) ) - ).withDefaultValue(circleStrokeOpacity(0.3f)) - ) - ); - - // Verify - assertNotNull(layer.getCircleStrokeOpacity()); - assertNotNull(layer.getCircleStrokeOpacity().getFunction()); - assertEquals(SourceFunction.class, layer.getCircleStrokeOpacity().getFunction().getClass()); - assertEquals("FeaturePropertyA", ((SourceFunction) layer.getCircleStrokeOpacity().getFunction()).getProperty()); - assertEquals(CategoricalStops.class, layer.getCircleStrokeOpacity().getFunction().getStops().getClass()); - assertNotNull(((SourceFunction) layer.getCircleStrokeOpacity().getFunction()).getDefaultValue()); - assertNotNull(((SourceFunction) layer.getCircleStrokeOpacity().getFunction()).getDefaultValue().getValue()); - assertEquals(0.3f, ((SourceFunction) layer.getCircleStrokeOpacity().getFunction()).getDefaultValue().getValue()); + ); + + // Verify + assertNotNull(layer.getCircleStrokeOpacity()); + assertNotNull(layer.getCircleStrokeOpacity().getFunction()); + assertEquals(SourceFunction.class, layer.getCircleStrokeOpacity().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getCircleStrokeOpacity().getFunction()).getProperty()); + assertEquals(CategoricalStops.class, layer.getCircleStrokeOpacity().getFunction().getStops().getClass()); + assertNotNull(((SourceFunction) layer.getCircleStrokeOpacity().getFunction()).getDefaultValue()); + assertNotNull(((SourceFunction) layer.getCircleStrokeOpacity().getFunction()).getDefaultValue().getValue()); + assertEquals(0.3f, ((SourceFunction) layer.getCircleStrokeOpacity().getFunction()).getDefaultValue().getValue()); + } + }); + } @Test @@ -1295,34 +1589,39 @@ public class CircleLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("circle-stroke-opacity"); - assertNotNull(layer); - - // Set - layer.setProperties( - circleStrokeOpacity( - composite( - "FeaturePropertyA", - exponential( - stop(0, 0.3f, circleStrokeOpacity(0.9f)) - ).withBase(0.5f) - ).withDefaultValue(circleStrokeOpacity(0.3f)) - ) - ); - - // Verify - assertNotNull(layer.getCircleStrokeOpacity()); - assertNotNull(layer.getCircleStrokeOpacity().getFunction()); - assertEquals(CompositeFunction.class, layer.getCircleStrokeOpacity().getFunction().getClass()); - assertEquals("FeaturePropertyA", ((CompositeFunction) layer.getCircleStrokeOpacity().getFunction()).getProperty()); - assertEquals(ExponentialStops.class, layer.getCircleStrokeOpacity().getFunction().getStops().getClass()); - assertEquals(1, ((ExponentialStops) layer.getCircleStrokeOpacity().getFunction().getStops()).size()); - - ExponentialStops<Stop.CompositeValue<Float, Float>, Float> stops = - (ExponentialStops<Stop.CompositeValue<Float, Float>, Float>) layer.getCircleStrokeOpacity().getFunction().getStops(); - Stop<Stop.CompositeValue<Float, Float>, Float> stop = stops.iterator().next(); - assertEquals(0f, stop.in.zoom, 0.001); - assertEquals(0.3f, stop.in.value, 0.001f); - assertEquals(0.9f, stop.out, 0.001f); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + circleStrokeOpacity( + composite( + "FeaturePropertyA", + exponential( + stop(0, 0.3f, circleStrokeOpacity(0.9f)) + ).withBase(0.5f) + ).withDefaultValue(circleStrokeOpacity(0.3f)) + ) + ); + + // Verify + assertNotNull(layer.getCircleStrokeOpacity()); + assertNotNull(layer.getCircleStrokeOpacity().getFunction()); + assertEquals(CompositeFunction.class, layer.getCircleStrokeOpacity().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((CompositeFunction) layer.getCircleStrokeOpacity().getFunction()).getProperty()); + assertEquals(ExponentialStops.class, layer.getCircleStrokeOpacity().getFunction().getStops().getClass()); + assertEquals(1, ((ExponentialStops) layer.getCircleStrokeOpacity().getFunction().getStops()).size()); + + ExponentialStops<Stop.CompositeValue<Float, Float>, Float> stops = + (ExponentialStops<Stop.CompositeValue<Float, Float>, Float>) layer.getCircleStrokeOpacity().getFunction().getStops(); + Stop<Stop.CompositeValue<Float, Float>, Float> stop = stops.iterator().next(); + assertEquals(0f, stop.in.zoom, 0.001); + assertEquals(0.3f, stop.in.value, 0.001f); + assertEquals(0.9f, stop.out, 0.001f); + } + }); } } diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/FillExtrusionLayerTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/FillExtrusionLayerTest.java index fec9a6c119..66c6093537 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/FillExtrusionLayerTest.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/FillExtrusionLayerTest.java @@ -3,9 +3,9 @@ package com.mapbox.mapboxsdk.testapp.style; import android.graphics.Color; -import android.support.test.espresso.Espresso; -import android.support.test.rule.ActivityTestRule; +import android.support.test.espresso.UiController; import android.support.test.runner.AndroidJUnit4; + import timber.log.Timber; import com.mapbox.mapboxsdk.maps.MapboxMap; @@ -19,20 +19,16 @@ import com.mapbox.mapboxsdk.style.functions.stops.IntervalStops; import com.mapbox.mapboxsdk.style.functions.stops.Stop; import com.mapbox.mapboxsdk.style.functions.stops.Stops; import com.mapbox.mapboxsdk.style.layers.FillExtrusionLayer; -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.action.MapboxMapAction; import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest; -import org.junit.After; -import org.junit.Before; -import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; import static com.mapbox.mapboxsdk.style.functions.Function.*; import static com.mapbox.mapboxsdk.style.functions.stops.Stop.stop; import static com.mapbox.mapboxsdk.style.functions.stops.Stops.*; +import static com.mapbox.mapboxsdk.testapp.action.MapboxMapAction.invoke; import static org.junit.Assert.*; import static com.mapbox.mapboxsdk.style.layers.Property.*; import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*; @@ -53,15 +49,21 @@ public class FillExtrusionLayerTest extends BaseActivityTest { return EspressoTestActivity.class; } - private void setupLayer(){ - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new FillExtrusionLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - // Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } + private void setupLayer() { + Timber.i("Retrieving layer"); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new FillExtrusionLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + // Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); + } + } + }); } @Test @@ -69,14 +71,19 @@ public class FillExtrusionLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("Visibility"); - assertNotNull(layer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); - // Get initial - assertEquals(layer.getVisibility().getValue(), VISIBLE); + // Get initial + assertEquals(layer.getVisibility().getValue(), VISIBLE); - // Set - layer.setProperties(visibility(NONE)); - assertEquals(layer.getVisibility().getValue(), NONE); + // Set + layer.setProperties(visibility(NONE)); + assertEquals(layer.getVisibility().getValue(), NONE); + } + }); } @Test @@ -84,15 +91,20 @@ public class FillExtrusionLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("SourceLayer"); - assertNotNull(layer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); - // Get initial - assertEquals(layer.getSourceLayer(), "composite"); + // Get initial + assertEquals(layer.getSourceLayer(), "composite"); - // Set - final String sourceLayer = "test"; - layer.setSourceLayer(sourceLayer); - assertEquals(layer.getSourceLayer(), sourceLayer); + // Set + final String sourceLayer = "test"; + layer.setSourceLayer(sourceLayer); + assertEquals(layer.getSourceLayer(), sourceLayer); + } + }); } @Test @@ -100,12 +112,17 @@ public class FillExtrusionLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("fill-extrusion-opacityTransitionOptions"); - assertNotNull(layer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); - // Set and Get - TransitionOptions options = new TransitionOptions(300, 100); - layer.setFillExtrusionOpacityTransition(options); - assertEquals(layer.getFillExtrusionOpacityTransition(), options); + // Set and Get + TransitionOptions options = new TransitionOptions(300, 100); + layer.setFillExtrusionOpacityTransition(options); + assertEquals(layer.getFillExtrusionOpacityTransition(), options); + } + }); } @Test @@ -113,11 +130,16 @@ public class FillExtrusionLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("fill-extrusion-opacity"); - assertNotNull(layer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); - // Set and Get - layer.setProperties(fillExtrusionOpacity(0.3f)); - assertEquals((Float) layer.getFillExtrusionOpacity().getValue(), (Float) 0.3f); + // Set and Get + layer.setProperties(fillExtrusionOpacity(0.3f)); + assertEquals((Float) layer.getFillExtrusionOpacity().getValue(), (Float) 0.3f); + } + }); } @Test @@ -125,26 +147,31 @@ public class FillExtrusionLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("fill-extrusion-opacity"); - assertNotNull(layer); - - // Set - layer.setProperties( - fillExtrusionOpacity( - zoom( - exponential( - stop(2, fillExtrusionOpacity(0.3f)) - ).withBase(0.5f) - ) - ) - ); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + fillExtrusionOpacity( + zoom( + exponential( + stop(2, fillExtrusionOpacity(0.3f)) + ).withBase(0.5f) + ) + ) + ); - // Verify - assertNotNull(layer.getFillExtrusionOpacity()); - assertNotNull(layer.getFillExtrusionOpacity().getFunction()); - assertEquals(CameraFunction.class, layer.getFillExtrusionOpacity().getFunction().getClass()); - assertEquals(ExponentialStops.class, layer.getFillExtrusionOpacity().getFunction().getStops().getClass()); - assertEquals(0.5f, ((ExponentialStops) layer.getFillExtrusionOpacity().getFunction().getStops()).getBase(), 0.001); - assertEquals(1, ((ExponentialStops) layer.getFillExtrusionOpacity().getFunction().getStops()).size()); + // Verify + assertNotNull(layer.getFillExtrusionOpacity()); + assertNotNull(layer.getFillExtrusionOpacity().getFunction()); + assertEquals(CameraFunction.class, layer.getFillExtrusionOpacity().getFunction().getClass()); + assertEquals(ExponentialStops.class, layer.getFillExtrusionOpacity().getFunction().getStops().getClass()); + assertEquals(0.5f, ((ExponentialStops) layer.getFillExtrusionOpacity().getFunction().getStops()).getBase(), 0.001); + assertEquals(1, ((ExponentialStops) layer.getFillExtrusionOpacity().getFunction().getStops()).size()); + } + }); } @Test @@ -152,12 +179,17 @@ public class FillExtrusionLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("fill-extrusion-colorTransitionOptions"); - assertNotNull(layer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); - // Set and Get - TransitionOptions options = new TransitionOptions(300, 100); - layer.setFillExtrusionColorTransition(options); - assertEquals(layer.getFillExtrusionColorTransition(), options); + // Set and Get + TransitionOptions options = new TransitionOptions(300, 100); + layer.setFillExtrusionColorTransition(options); + assertEquals(layer.getFillExtrusionColorTransition(), options); + } + }); } @Test @@ -165,11 +197,16 @@ public class FillExtrusionLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("fill-extrusion-color"); - assertNotNull(layer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); - // Set and Get - layer.setProperties(fillExtrusionColor("rgba(0, 0, 0, 1)")); - assertEquals((String) layer.getFillExtrusionColor().getValue(), (String) "rgba(0, 0, 0, 1)"); + // Set and Get + layer.setProperties(fillExtrusionColor("rgba(0, 0, 0, 1)")); + assertEquals((String) layer.getFillExtrusionColor().getValue(), (String) "rgba(0, 0, 0, 1)"); + } + }); } @Test @@ -177,26 +214,31 @@ public class FillExtrusionLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("fill-extrusion-color"); - assertNotNull(layer); - - // Set - layer.setProperties( - fillExtrusionColor( - zoom( - exponential( - stop(2, fillExtrusionColor("rgba(0, 0, 0, 1)")) - ).withBase(0.5f) - ) - ) - ); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + fillExtrusionColor( + zoom( + exponential( + stop(2, fillExtrusionColor("rgba(0, 0, 0, 1)")) + ).withBase(0.5f) + ) + ) + ); - // Verify - assertNotNull(layer.getFillExtrusionColor()); - assertNotNull(layer.getFillExtrusionColor().getFunction()); - assertEquals(CameraFunction.class, layer.getFillExtrusionColor().getFunction().getClass()); - assertEquals(ExponentialStops.class, layer.getFillExtrusionColor().getFunction().getStops().getClass()); - assertEquals(0.5f, ((ExponentialStops) layer.getFillExtrusionColor().getFunction().getStops()).getBase(), 0.001); - assertEquals(1, ((ExponentialStops) layer.getFillExtrusionColor().getFunction().getStops()).size()); + // Verify + assertNotNull(layer.getFillExtrusionColor()); + assertNotNull(layer.getFillExtrusionColor().getFunction()); + assertEquals(CameraFunction.class, layer.getFillExtrusionColor().getFunction().getClass()); + assertEquals(ExponentialStops.class, layer.getFillExtrusionColor().getFunction().getStops().getClass()); + assertEquals(0.5f, ((ExponentialStops) layer.getFillExtrusionColor().getFunction().getStops()).getBase(), 0.001); + assertEquals(1, ((ExponentialStops) layer.getFillExtrusionColor().getFunction().getStops()).size()); + } + }); } @Test @@ -204,19 +246,24 @@ public class FillExtrusionLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("fill-extrusion-color"); - assertNotNull(layer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); - // Set - layer.setProperties( - fillExtrusionColor(property("FeaturePropertyA", Stops.<String>identity())) - ); + // Set + layer.setProperties( + fillExtrusionColor(property("FeaturePropertyA", Stops.<String>identity())) + ); - // Verify - assertNotNull(layer.getFillExtrusionColor()); - assertNotNull(layer.getFillExtrusionColor().getFunction()); - assertEquals(SourceFunction.class, layer.getFillExtrusionColor().getFunction().getClass()); - assertEquals("FeaturePropertyA", ((SourceFunction) layer.getFillExtrusionColor().getFunction()).getProperty()); - assertEquals(IdentityStops.class, layer.getFillExtrusionColor().getFunction().getStops().getClass()); + // Verify + assertNotNull(layer.getFillExtrusionColor()); + assertNotNull(layer.getFillExtrusionColor().getFunction()); + assertEquals(SourceFunction.class, layer.getFillExtrusionColor().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getFillExtrusionColor().getFunction()).getProperty()); + assertEquals(IdentityStops.class, layer.getFillExtrusionColor().getFunction().getStops().getClass()); + } + }); } @Test @@ -224,26 +271,31 @@ public class FillExtrusionLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("fill-extrusion-color"); - assertNotNull(layer); - - // Set - layer.setProperties( - fillExtrusionColor( - property( - "FeaturePropertyA", - exponential( - stop(Color.RED, fillExtrusionColor(Color.RED)) - ).withBase(0.5f) - ) - ) - ); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + fillExtrusionColor( + property( + "FeaturePropertyA", + exponential( + stop(Color.RED, fillExtrusionColor(Color.RED)) + ).withBase(0.5f) + ) + ) + ); - // Verify - assertNotNull(layer.getFillExtrusionColor()); - assertNotNull(layer.getFillExtrusionColor().getFunction()); - assertEquals(SourceFunction.class, layer.getFillExtrusionColor().getFunction().getClass()); - assertEquals("FeaturePropertyA", ((SourceFunction) layer.getFillExtrusionColor().getFunction()).getProperty()); - assertEquals(ExponentialStops.class, layer.getFillExtrusionColor().getFunction().getStops().getClass()); + // Verify + assertNotNull(layer.getFillExtrusionColor()); + assertNotNull(layer.getFillExtrusionColor().getFunction()); + assertEquals(SourceFunction.class, layer.getFillExtrusionColor().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getFillExtrusionColor().getFunction()).getProperty()); + assertEquals(ExponentialStops.class, layer.getFillExtrusionColor().getFunction().getStops().getClass()); + } + }); } @Test @@ -251,29 +303,35 @@ public class FillExtrusionLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("fill-extrusion-color"); - assertNotNull(layer); - - // Set - layer.setProperties( - fillExtrusionColor( - property( - "FeaturePropertyA", - categorical( - stop("valueA", fillExtrusionColor(Color.RED)) + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + fillExtrusionColor( + property( + "FeaturePropertyA", + categorical( + stop("valueA", fillExtrusionColor(Color.RED)) + ) + ).withDefaultValue(fillExtrusionColor(Color.GREEN)) ) - ).withDefaultValue(fillExtrusionColor(Color.GREEN)) - ) - ); + ); + + // Verify + assertNotNull(layer.getFillExtrusionColor()); + assertNotNull(layer.getFillExtrusionColor().getFunction()); + assertEquals(SourceFunction.class, layer.getFillExtrusionColor().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getFillExtrusionColor().getFunction()).getProperty()); + assertEquals(CategoricalStops.class, layer.getFillExtrusionColor().getFunction().getStops().getClass()); + assertNotNull(((SourceFunction) layer.getFillExtrusionColor().getFunction()).getDefaultValue()); + assertNotNull(((SourceFunction) layer.getFillExtrusionColor().getFunction()).getDefaultValue().getValue()); + assertEquals(Color.GREEN, (int) ((SourceFunction) layer.getFillExtrusionColor().getFunction()).getDefaultValue().getColorInt()); + } + }); - // Verify - assertNotNull(layer.getFillExtrusionColor()); - assertNotNull(layer.getFillExtrusionColor().getFunction()); - assertEquals(SourceFunction.class, layer.getFillExtrusionColor().getFunction().getClass()); - assertEquals("FeaturePropertyA", ((SourceFunction) layer.getFillExtrusionColor().getFunction()).getProperty()); - assertEquals(CategoricalStops.class, layer.getFillExtrusionColor().getFunction().getStops().getClass()); - assertNotNull(((SourceFunction) layer.getFillExtrusionColor().getFunction()).getDefaultValue()); - assertNotNull(((SourceFunction) layer.getFillExtrusionColor().getFunction()).getDefaultValue().getValue()); - assertEquals(Color.GREEN, (int) ((SourceFunction) layer.getFillExtrusionColor().getFunction()).getDefaultValue().getColorInt()); } @Test @@ -281,11 +339,16 @@ public class FillExtrusionLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("fill-extrusion-color"); - assertNotNull(layer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); - // Set and Get - layer.setProperties(fillExtrusionColor(Color.RED)); - assertEquals(layer.getFillExtrusionColorAsInt(), Color.RED); + // Set and Get + layer.setProperties(fillExtrusionColor(Color.RED)); + assertEquals(layer.getFillExtrusionColorAsInt(), Color.RED); + } + }); } @Test @@ -293,12 +356,17 @@ public class FillExtrusionLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("fill-extrusion-translateTransitionOptions"); - assertNotNull(layer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); - // Set and Get - TransitionOptions options = new TransitionOptions(300, 100); - layer.setFillExtrusionTranslateTransition(options); - assertEquals(layer.getFillExtrusionTranslateTransition(), options); + // Set and Get + TransitionOptions options = new TransitionOptions(300, 100); + layer.setFillExtrusionTranslateTransition(options); + assertEquals(layer.getFillExtrusionTranslateTransition(), options); + } + }); } @Test @@ -306,11 +374,16 @@ public class FillExtrusionLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("fill-extrusion-translate"); - assertNotNull(layer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); - // Set and Get - layer.setProperties(fillExtrusionTranslate(new Float[]{0f,0f})); - assertEquals((Float[]) layer.getFillExtrusionTranslate().getValue(), (Float[]) new Float[]{0f,0f}); + // Set and Get + layer.setProperties(fillExtrusionTranslate(new Float[] {0f, 0f})); + assertEquals((Float[]) layer.getFillExtrusionTranslate().getValue(), (Float[]) new Float[] {0f, 0f}); + } + }); } @Test @@ -318,26 +391,31 @@ public class FillExtrusionLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("fill-extrusion-translate"); - assertNotNull(layer); - - // Set - layer.setProperties( - fillExtrusionTranslate( - zoom( - exponential( - stop(2, fillExtrusionTranslate(new Float[]{0f,0f})) - ).withBase(0.5f) - ) - ) - ); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + fillExtrusionTranslate( + zoom( + exponential( + stop(2, fillExtrusionTranslate(new Float[] {0f, 0f})) + ).withBase(0.5f) + ) + ) + ); - // Verify - assertNotNull(layer.getFillExtrusionTranslate()); - assertNotNull(layer.getFillExtrusionTranslate().getFunction()); - assertEquals(CameraFunction.class, layer.getFillExtrusionTranslate().getFunction().getClass()); - assertEquals(ExponentialStops.class, layer.getFillExtrusionTranslate().getFunction().getStops().getClass()); - assertEquals(0.5f, ((ExponentialStops) layer.getFillExtrusionTranslate().getFunction().getStops()).getBase(), 0.001); - assertEquals(1, ((ExponentialStops) layer.getFillExtrusionTranslate().getFunction().getStops()).size()); + // Verify + assertNotNull(layer.getFillExtrusionTranslate()); + assertNotNull(layer.getFillExtrusionTranslate().getFunction()); + assertEquals(CameraFunction.class, layer.getFillExtrusionTranslate().getFunction().getClass()); + assertEquals(ExponentialStops.class, layer.getFillExtrusionTranslate().getFunction().getStops().getClass()); + assertEquals(0.5f, ((ExponentialStops) layer.getFillExtrusionTranslate().getFunction().getStops()).getBase(), 0.001); + assertEquals(1, ((ExponentialStops) layer.getFillExtrusionTranslate().getFunction().getStops()).size()); + } + }); } @Test @@ -345,11 +423,16 @@ public class FillExtrusionLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("fill-extrusion-translate-anchor"); - assertNotNull(layer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); - // Set and Get - layer.setProperties(fillExtrusionTranslateAnchor(FILL_EXTRUSION_TRANSLATE_ANCHOR_MAP)); - assertEquals((String) layer.getFillExtrusionTranslateAnchor().getValue(), (String) FILL_EXTRUSION_TRANSLATE_ANCHOR_MAP); + // Set and Get + layer.setProperties(fillExtrusionTranslateAnchor(FILL_EXTRUSION_TRANSLATE_ANCHOR_MAP)); + assertEquals((String) layer.getFillExtrusionTranslateAnchor().getValue(), (String) FILL_EXTRUSION_TRANSLATE_ANCHOR_MAP); + } + }); } @Test @@ -357,25 +440,30 @@ public class FillExtrusionLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("fill-extrusion-translate-anchor"); - assertNotNull(layer); - - // Set - layer.setProperties( - fillExtrusionTranslateAnchor( - zoom( - interval( - stop(2, fillExtrusionTranslateAnchor(FILL_EXTRUSION_TRANSLATE_ANCHOR_MAP)) + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + fillExtrusionTranslateAnchor( + zoom( + interval( + stop(2, fillExtrusionTranslateAnchor(FILL_EXTRUSION_TRANSLATE_ANCHOR_MAP)) + ) + ) ) - ) - ) - ); + ); - // Verify - assertNotNull(layer.getFillExtrusionTranslateAnchor()); - assertNotNull(layer.getFillExtrusionTranslateAnchor().getFunction()); - assertEquals(CameraFunction.class, layer.getFillExtrusionTranslateAnchor().getFunction().getClass()); - assertEquals(IntervalStops.class, layer.getFillExtrusionTranslateAnchor().getFunction().getStops().getClass()); - assertEquals(1, ((IntervalStops) layer.getFillExtrusionTranslateAnchor().getFunction().getStops()).size()); + // Verify + assertNotNull(layer.getFillExtrusionTranslateAnchor()); + assertNotNull(layer.getFillExtrusionTranslateAnchor().getFunction()); + assertEquals(CameraFunction.class, layer.getFillExtrusionTranslateAnchor().getFunction().getClass()); + assertEquals(IntervalStops.class, layer.getFillExtrusionTranslateAnchor().getFunction().getStops().getClass()); + assertEquals(1, ((IntervalStops) layer.getFillExtrusionTranslateAnchor().getFunction().getStops()).size()); + } + }); } @Test @@ -383,12 +471,17 @@ public class FillExtrusionLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("fill-extrusion-patternTransitionOptions"); - assertNotNull(layer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); - // Set and Get - TransitionOptions options = new TransitionOptions(300, 100); - layer.setFillExtrusionPatternTransition(options); - assertEquals(layer.getFillExtrusionPatternTransition(), options); + // Set and Get + TransitionOptions options = new TransitionOptions(300, 100); + layer.setFillExtrusionPatternTransition(options); + assertEquals(layer.getFillExtrusionPatternTransition(), options); + } + }); } @Test @@ -396,11 +489,16 @@ public class FillExtrusionLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("fill-extrusion-pattern"); - assertNotNull(layer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); - // Set and Get - layer.setProperties(fillExtrusionPattern("pedestrian-polygon")); - assertEquals((String) layer.getFillExtrusionPattern().getValue(), (String) "pedestrian-polygon"); + // Set and Get + layer.setProperties(fillExtrusionPattern("pedestrian-polygon")); + assertEquals((String) layer.getFillExtrusionPattern().getValue(), (String) "pedestrian-polygon"); + } + }); } @Test @@ -408,25 +506,30 @@ public class FillExtrusionLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("fill-extrusion-pattern"); - assertNotNull(layer); - - // Set - layer.setProperties( - fillExtrusionPattern( - zoom( - interval( - stop(2, fillExtrusionPattern("pedestrian-polygon")) + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + fillExtrusionPattern( + zoom( + interval( + stop(2, fillExtrusionPattern("pedestrian-polygon")) + ) + ) ) - ) - ) - ); + ); - // Verify - assertNotNull(layer.getFillExtrusionPattern()); - assertNotNull(layer.getFillExtrusionPattern().getFunction()); - assertEquals(CameraFunction.class, layer.getFillExtrusionPattern().getFunction().getClass()); - assertEquals(IntervalStops.class, layer.getFillExtrusionPattern().getFunction().getStops().getClass()); - assertEquals(1, ((IntervalStops) layer.getFillExtrusionPattern().getFunction().getStops()).size()); + // Verify + assertNotNull(layer.getFillExtrusionPattern()); + assertNotNull(layer.getFillExtrusionPattern().getFunction()); + assertEquals(CameraFunction.class, layer.getFillExtrusionPattern().getFunction().getClass()); + assertEquals(IntervalStops.class, layer.getFillExtrusionPattern().getFunction().getStops().getClass()); + assertEquals(1, ((IntervalStops) layer.getFillExtrusionPattern().getFunction().getStops()).size()); + } + }); } @Test @@ -434,12 +537,17 @@ public class FillExtrusionLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("fill-extrusion-heightTransitionOptions"); - assertNotNull(layer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); - // Set and Get - TransitionOptions options = new TransitionOptions(300, 100); - layer.setFillExtrusionHeightTransition(options); - assertEquals(layer.getFillExtrusionHeightTransition(), options); + // Set and Get + TransitionOptions options = new TransitionOptions(300, 100); + layer.setFillExtrusionHeightTransition(options); + assertEquals(layer.getFillExtrusionHeightTransition(), options); + } + }); } @Test @@ -447,11 +555,16 @@ public class FillExtrusionLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("fill-extrusion-height"); - assertNotNull(layer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); - // Set and Get - layer.setProperties(fillExtrusionHeight(0.3f)); - assertEquals((Float) layer.getFillExtrusionHeight().getValue(), (Float) 0.3f); + // Set and Get + layer.setProperties(fillExtrusionHeight(0.3f)); + assertEquals((Float) layer.getFillExtrusionHeight().getValue(), (Float) 0.3f); + } + }); } @Test @@ -459,26 +572,31 @@ public class FillExtrusionLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("fill-extrusion-height"); - assertNotNull(layer); - - // Set - layer.setProperties( - fillExtrusionHeight( - zoom( - exponential( - stop(2, fillExtrusionHeight(0.3f)) - ).withBase(0.5f) - ) - ) - ); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + fillExtrusionHeight( + zoom( + exponential( + stop(2, fillExtrusionHeight(0.3f)) + ).withBase(0.5f) + ) + ) + ); - // Verify - assertNotNull(layer.getFillExtrusionHeight()); - assertNotNull(layer.getFillExtrusionHeight().getFunction()); - assertEquals(CameraFunction.class, layer.getFillExtrusionHeight().getFunction().getClass()); - assertEquals(ExponentialStops.class, layer.getFillExtrusionHeight().getFunction().getStops().getClass()); - assertEquals(0.5f, ((ExponentialStops) layer.getFillExtrusionHeight().getFunction().getStops()).getBase(), 0.001); - assertEquals(1, ((ExponentialStops) layer.getFillExtrusionHeight().getFunction().getStops()).size()); + // Verify + assertNotNull(layer.getFillExtrusionHeight()); + assertNotNull(layer.getFillExtrusionHeight().getFunction()); + assertEquals(CameraFunction.class, layer.getFillExtrusionHeight().getFunction().getClass()); + assertEquals(ExponentialStops.class, layer.getFillExtrusionHeight().getFunction().getStops().getClass()); + assertEquals(0.5f, ((ExponentialStops) layer.getFillExtrusionHeight().getFunction().getStops()).getBase(), 0.001); + assertEquals(1, ((ExponentialStops) layer.getFillExtrusionHeight().getFunction().getStops()).size()); + } + }); } @Test @@ -486,19 +604,24 @@ public class FillExtrusionLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("fill-extrusion-height"); - assertNotNull(layer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); - // Set - layer.setProperties( - fillExtrusionHeight(property("FeaturePropertyA", Stops.<Float>identity())) - ); + // Set + layer.setProperties( + fillExtrusionHeight(property("FeaturePropertyA", Stops.<Float>identity())) + ); - // Verify - assertNotNull(layer.getFillExtrusionHeight()); - assertNotNull(layer.getFillExtrusionHeight().getFunction()); - assertEquals(SourceFunction.class, layer.getFillExtrusionHeight().getFunction().getClass()); - assertEquals("FeaturePropertyA", ((SourceFunction) layer.getFillExtrusionHeight().getFunction()).getProperty()); - assertEquals(IdentityStops.class, layer.getFillExtrusionHeight().getFunction().getStops().getClass()); + // Verify + assertNotNull(layer.getFillExtrusionHeight()); + assertNotNull(layer.getFillExtrusionHeight().getFunction()); + assertEquals(SourceFunction.class, layer.getFillExtrusionHeight().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getFillExtrusionHeight().getFunction()).getProperty()); + assertEquals(IdentityStops.class, layer.getFillExtrusionHeight().getFunction().getStops().getClass()); + } + }); } @Test @@ -506,26 +629,31 @@ public class FillExtrusionLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("fill-extrusion-height"); - assertNotNull(layer); - - // Set - layer.setProperties( - fillExtrusionHeight( - property( - "FeaturePropertyA", - exponential( - stop(0.3f, fillExtrusionHeight(0.3f)) - ).withBase(0.5f) - ) - ) - ); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + fillExtrusionHeight( + property( + "FeaturePropertyA", + exponential( + stop(0.3f, fillExtrusionHeight(0.3f)) + ).withBase(0.5f) + ) + ) + ); - // Verify - assertNotNull(layer.getFillExtrusionHeight()); - assertNotNull(layer.getFillExtrusionHeight().getFunction()); - assertEquals(SourceFunction.class, layer.getFillExtrusionHeight().getFunction().getClass()); - assertEquals("FeaturePropertyA", ((SourceFunction) layer.getFillExtrusionHeight().getFunction()).getProperty()); - assertEquals(ExponentialStops.class, layer.getFillExtrusionHeight().getFunction().getStops().getClass()); + // Verify + assertNotNull(layer.getFillExtrusionHeight()); + assertNotNull(layer.getFillExtrusionHeight().getFunction()); + assertEquals(SourceFunction.class, layer.getFillExtrusionHeight().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getFillExtrusionHeight().getFunction()).getProperty()); + assertEquals(ExponentialStops.class, layer.getFillExtrusionHeight().getFunction().getStops().getClass()); + } + }); } @Test @@ -533,29 +661,35 @@ public class FillExtrusionLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("fill-extrusion-height"); - assertNotNull(layer); - - // Set - layer.setProperties( - fillExtrusionHeight( - property( - "FeaturePropertyA", - categorical( - stop(1.0f, fillExtrusionHeight(0.3f)) + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + fillExtrusionHeight( + property( + "FeaturePropertyA", + categorical( + stop(1.0f, fillExtrusionHeight(0.3f)) + ) + ).withDefaultValue(fillExtrusionHeight(0.3f)) ) - ).withDefaultValue(fillExtrusionHeight(0.3f)) - ) - ); + ); + + // Verify + assertNotNull(layer.getFillExtrusionHeight()); + assertNotNull(layer.getFillExtrusionHeight().getFunction()); + assertEquals(SourceFunction.class, layer.getFillExtrusionHeight().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getFillExtrusionHeight().getFunction()).getProperty()); + assertEquals(CategoricalStops.class, layer.getFillExtrusionHeight().getFunction().getStops().getClass()); + assertNotNull(((SourceFunction) layer.getFillExtrusionHeight().getFunction()).getDefaultValue()); + assertNotNull(((SourceFunction) layer.getFillExtrusionHeight().getFunction()).getDefaultValue().getValue()); + assertEquals(0.3f, ((SourceFunction) layer.getFillExtrusionHeight().getFunction()).getDefaultValue().getValue()); + } + }); - // Verify - assertNotNull(layer.getFillExtrusionHeight()); - assertNotNull(layer.getFillExtrusionHeight().getFunction()); - assertEquals(SourceFunction.class, layer.getFillExtrusionHeight().getFunction().getClass()); - assertEquals("FeaturePropertyA", ((SourceFunction) layer.getFillExtrusionHeight().getFunction()).getProperty()); - assertEquals(CategoricalStops.class, layer.getFillExtrusionHeight().getFunction().getStops().getClass()); - assertNotNull(((SourceFunction) layer.getFillExtrusionHeight().getFunction()).getDefaultValue()); - assertNotNull(((SourceFunction) layer.getFillExtrusionHeight().getFunction()).getDefaultValue().getValue()); - assertEquals(0.3f, ((SourceFunction) layer.getFillExtrusionHeight().getFunction()).getDefaultValue().getValue()); } @Test @@ -563,34 +697,39 @@ public class FillExtrusionLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("fill-extrusion-height"); - assertNotNull(layer); - - // Set - layer.setProperties( - fillExtrusionHeight( - composite( - "FeaturePropertyA", - exponential( - stop(0, 0.3f, fillExtrusionHeight(0.9f)) - ).withBase(0.5f) - ).withDefaultValue(fillExtrusionHeight(0.3f)) - ) - ); - - // Verify - assertNotNull(layer.getFillExtrusionHeight()); - assertNotNull(layer.getFillExtrusionHeight().getFunction()); - assertEquals(CompositeFunction.class, layer.getFillExtrusionHeight().getFunction().getClass()); - assertEquals("FeaturePropertyA", ((CompositeFunction) layer.getFillExtrusionHeight().getFunction()).getProperty()); - assertEquals(ExponentialStops.class, layer.getFillExtrusionHeight().getFunction().getStops().getClass()); - assertEquals(1, ((ExponentialStops) layer.getFillExtrusionHeight().getFunction().getStops()).size()); - - ExponentialStops<Stop.CompositeValue<Float, Float>, Float> stops = - (ExponentialStops<Stop.CompositeValue<Float, Float>, Float>) layer.getFillExtrusionHeight().getFunction().getStops(); - Stop<Stop.CompositeValue<Float, Float>, Float> stop = stops.iterator().next(); - assertEquals(0f, stop.in.zoom, 0.001); - assertEquals(0.3f, stop.in.value, 0.001f); - assertEquals(0.9f, stop.out, 0.001f); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + fillExtrusionHeight( + composite( + "FeaturePropertyA", + exponential( + stop(0, 0.3f, fillExtrusionHeight(0.9f)) + ).withBase(0.5f) + ).withDefaultValue(fillExtrusionHeight(0.3f)) + ) + ); + + // Verify + assertNotNull(layer.getFillExtrusionHeight()); + assertNotNull(layer.getFillExtrusionHeight().getFunction()); + assertEquals(CompositeFunction.class, layer.getFillExtrusionHeight().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((CompositeFunction) layer.getFillExtrusionHeight().getFunction()).getProperty()); + assertEquals(ExponentialStops.class, layer.getFillExtrusionHeight().getFunction().getStops().getClass()); + assertEquals(1, ((ExponentialStops) layer.getFillExtrusionHeight().getFunction().getStops()).size()); + + ExponentialStops<Stop.CompositeValue<Float, Float>, Float> stops = + (ExponentialStops<Stop.CompositeValue<Float, Float>, Float>) layer.getFillExtrusionHeight().getFunction().getStops(); + Stop<Stop.CompositeValue<Float, Float>, Float> stop = stops.iterator().next(); + assertEquals(0f, stop.in.zoom, 0.001); + assertEquals(0.3f, stop.in.value, 0.001f); + assertEquals(0.9f, stop.out, 0.001f); + } + }); } @Test @@ -598,12 +737,17 @@ public class FillExtrusionLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("fill-extrusion-baseTransitionOptions"); - assertNotNull(layer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); - // Set and Get - TransitionOptions options = new TransitionOptions(300, 100); - layer.setFillExtrusionBaseTransition(options); - assertEquals(layer.getFillExtrusionBaseTransition(), options); + // Set and Get + TransitionOptions options = new TransitionOptions(300, 100); + layer.setFillExtrusionBaseTransition(options); + assertEquals(layer.getFillExtrusionBaseTransition(), options); + } + }); } @Test @@ -611,11 +755,16 @@ public class FillExtrusionLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("fill-extrusion-base"); - assertNotNull(layer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); - // Set and Get - layer.setProperties(fillExtrusionBase(0.3f)); - assertEquals((Float) layer.getFillExtrusionBase().getValue(), (Float) 0.3f); + // Set and Get + layer.setProperties(fillExtrusionBase(0.3f)); + assertEquals((Float) layer.getFillExtrusionBase().getValue(), (Float) 0.3f); + } + }); } @Test @@ -623,26 +772,31 @@ public class FillExtrusionLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("fill-extrusion-base"); - assertNotNull(layer); - - // Set - layer.setProperties( - fillExtrusionBase( - zoom( - exponential( - stop(2, fillExtrusionBase(0.3f)) - ).withBase(0.5f) - ) - ) - ); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + fillExtrusionBase( + zoom( + exponential( + stop(2, fillExtrusionBase(0.3f)) + ).withBase(0.5f) + ) + ) + ); - // Verify - assertNotNull(layer.getFillExtrusionBase()); - assertNotNull(layer.getFillExtrusionBase().getFunction()); - assertEquals(CameraFunction.class, layer.getFillExtrusionBase().getFunction().getClass()); - assertEquals(ExponentialStops.class, layer.getFillExtrusionBase().getFunction().getStops().getClass()); - assertEquals(0.5f, ((ExponentialStops) layer.getFillExtrusionBase().getFunction().getStops()).getBase(), 0.001); - assertEquals(1, ((ExponentialStops) layer.getFillExtrusionBase().getFunction().getStops()).size()); + // Verify + assertNotNull(layer.getFillExtrusionBase()); + assertNotNull(layer.getFillExtrusionBase().getFunction()); + assertEquals(CameraFunction.class, layer.getFillExtrusionBase().getFunction().getClass()); + assertEquals(ExponentialStops.class, layer.getFillExtrusionBase().getFunction().getStops().getClass()); + assertEquals(0.5f, ((ExponentialStops) layer.getFillExtrusionBase().getFunction().getStops()).getBase(), 0.001); + assertEquals(1, ((ExponentialStops) layer.getFillExtrusionBase().getFunction().getStops()).size()); + } + }); } @Test @@ -650,19 +804,24 @@ public class FillExtrusionLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("fill-extrusion-base"); - assertNotNull(layer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); - // Set - layer.setProperties( - fillExtrusionBase(property("FeaturePropertyA", Stops.<Float>identity())) - ); + // Set + layer.setProperties( + fillExtrusionBase(property("FeaturePropertyA", Stops.<Float>identity())) + ); - // Verify - assertNotNull(layer.getFillExtrusionBase()); - assertNotNull(layer.getFillExtrusionBase().getFunction()); - assertEquals(SourceFunction.class, layer.getFillExtrusionBase().getFunction().getClass()); - assertEquals("FeaturePropertyA", ((SourceFunction) layer.getFillExtrusionBase().getFunction()).getProperty()); - assertEquals(IdentityStops.class, layer.getFillExtrusionBase().getFunction().getStops().getClass()); + // Verify + assertNotNull(layer.getFillExtrusionBase()); + assertNotNull(layer.getFillExtrusionBase().getFunction()); + assertEquals(SourceFunction.class, layer.getFillExtrusionBase().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getFillExtrusionBase().getFunction()).getProperty()); + assertEquals(IdentityStops.class, layer.getFillExtrusionBase().getFunction().getStops().getClass()); + } + }); } @Test @@ -670,26 +829,31 @@ public class FillExtrusionLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("fill-extrusion-base"); - assertNotNull(layer); - - // Set - layer.setProperties( - fillExtrusionBase( - property( - "FeaturePropertyA", - exponential( - stop(0.3f, fillExtrusionBase(0.3f)) - ).withBase(0.5f) - ) - ) - ); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + fillExtrusionBase( + property( + "FeaturePropertyA", + exponential( + stop(0.3f, fillExtrusionBase(0.3f)) + ).withBase(0.5f) + ) + ) + ); - // Verify - assertNotNull(layer.getFillExtrusionBase()); - assertNotNull(layer.getFillExtrusionBase().getFunction()); - assertEquals(SourceFunction.class, layer.getFillExtrusionBase().getFunction().getClass()); - assertEquals("FeaturePropertyA", ((SourceFunction) layer.getFillExtrusionBase().getFunction()).getProperty()); - assertEquals(ExponentialStops.class, layer.getFillExtrusionBase().getFunction().getStops().getClass()); + // Verify + assertNotNull(layer.getFillExtrusionBase()); + assertNotNull(layer.getFillExtrusionBase().getFunction()); + assertEquals(SourceFunction.class, layer.getFillExtrusionBase().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getFillExtrusionBase().getFunction()).getProperty()); + assertEquals(ExponentialStops.class, layer.getFillExtrusionBase().getFunction().getStops().getClass()); + } + }); } @Test @@ -697,29 +861,35 @@ public class FillExtrusionLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("fill-extrusion-base"); - assertNotNull(layer); - - // Set - layer.setProperties( - fillExtrusionBase( - property( - "FeaturePropertyA", - categorical( - stop(1.0f, fillExtrusionBase(0.3f)) + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + fillExtrusionBase( + property( + "FeaturePropertyA", + categorical( + stop(1.0f, fillExtrusionBase(0.3f)) + ) + ).withDefaultValue(fillExtrusionBase(0.3f)) ) - ).withDefaultValue(fillExtrusionBase(0.3f)) - ) - ); + ); + + // Verify + assertNotNull(layer.getFillExtrusionBase()); + assertNotNull(layer.getFillExtrusionBase().getFunction()); + assertEquals(SourceFunction.class, layer.getFillExtrusionBase().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getFillExtrusionBase().getFunction()).getProperty()); + assertEquals(CategoricalStops.class, layer.getFillExtrusionBase().getFunction().getStops().getClass()); + assertNotNull(((SourceFunction) layer.getFillExtrusionBase().getFunction()).getDefaultValue()); + assertNotNull(((SourceFunction) layer.getFillExtrusionBase().getFunction()).getDefaultValue().getValue()); + assertEquals(0.3f, ((SourceFunction) layer.getFillExtrusionBase().getFunction()).getDefaultValue().getValue()); + } + }); - // Verify - assertNotNull(layer.getFillExtrusionBase()); - assertNotNull(layer.getFillExtrusionBase().getFunction()); - assertEquals(SourceFunction.class, layer.getFillExtrusionBase().getFunction().getClass()); - assertEquals("FeaturePropertyA", ((SourceFunction) layer.getFillExtrusionBase().getFunction()).getProperty()); - assertEquals(CategoricalStops.class, layer.getFillExtrusionBase().getFunction().getStops().getClass()); - assertNotNull(((SourceFunction) layer.getFillExtrusionBase().getFunction()).getDefaultValue()); - assertNotNull(((SourceFunction) layer.getFillExtrusionBase().getFunction()).getDefaultValue().getValue()); - assertEquals(0.3f, ((SourceFunction) layer.getFillExtrusionBase().getFunction()).getDefaultValue().getValue()); } @Test @@ -727,34 +897,39 @@ public class FillExtrusionLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("fill-extrusion-base"); - assertNotNull(layer); - - // Set - layer.setProperties( - fillExtrusionBase( - composite( - "FeaturePropertyA", - exponential( - stop(0, 0.3f, fillExtrusionBase(0.9f)) - ).withBase(0.5f) - ).withDefaultValue(fillExtrusionBase(0.3f)) - ) - ); - - // Verify - assertNotNull(layer.getFillExtrusionBase()); - assertNotNull(layer.getFillExtrusionBase().getFunction()); - assertEquals(CompositeFunction.class, layer.getFillExtrusionBase().getFunction().getClass()); - assertEquals("FeaturePropertyA", ((CompositeFunction) layer.getFillExtrusionBase().getFunction()).getProperty()); - assertEquals(ExponentialStops.class, layer.getFillExtrusionBase().getFunction().getStops().getClass()); - assertEquals(1, ((ExponentialStops) layer.getFillExtrusionBase().getFunction().getStops()).size()); - - ExponentialStops<Stop.CompositeValue<Float, Float>, Float> stops = - (ExponentialStops<Stop.CompositeValue<Float, Float>, Float>) layer.getFillExtrusionBase().getFunction().getStops(); - Stop<Stop.CompositeValue<Float, Float>, Float> stop = stops.iterator().next(); - assertEquals(0f, stop.in.zoom, 0.001); - assertEquals(0.3f, stop.in.value, 0.001f); - assertEquals(0.9f, stop.out, 0.001f); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + fillExtrusionBase( + composite( + "FeaturePropertyA", + exponential( + stop(0, 0.3f, fillExtrusionBase(0.9f)) + ).withBase(0.5f) + ).withDefaultValue(fillExtrusionBase(0.3f)) + ) + ); + + // Verify + assertNotNull(layer.getFillExtrusionBase()); + assertNotNull(layer.getFillExtrusionBase().getFunction()); + assertEquals(CompositeFunction.class, layer.getFillExtrusionBase().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((CompositeFunction) layer.getFillExtrusionBase().getFunction()).getProperty()); + assertEquals(ExponentialStops.class, layer.getFillExtrusionBase().getFunction().getStops().getClass()); + assertEquals(1, ((ExponentialStops) layer.getFillExtrusionBase().getFunction().getStops()).size()); + + ExponentialStops<Stop.CompositeValue<Float, Float>, Float> stops = + (ExponentialStops<Stop.CompositeValue<Float, Float>, Float>) layer.getFillExtrusionBase().getFunction().getStops(); + Stop<Stop.CompositeValue<Float, Float>, Float> stop = stops.iterator().next(); + assertEquals(0f, stop.in.zoom, 0.001); + assertEquals(0.3f, stop.in.value, 0.001f); + assertEquals(0.9f, stop.out, 0.001f); + } + }); } } diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/FillLayerTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/FillLayerTest.java index b6b6578839..939bcb6892 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/FillLayerTest.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/FillLayerTest.java @@ -3,9 +3,9 @@ package com.mapbox.mapboxsdk.testapp.style; import android.graphics.Color; -import android.support.test.espresso.Espresso; -import android.support.test.rule.ActivityTestRule; +import android.support.test.espresso.UiController; import android.support.test.runner.AndroidJUnit4; + import timber.log.Timber; import com.mapbox.mapboxsdk.maps.MapboxMap; @@ -19,20 +19,16 @@ import com.mapbox.mapboxsdk.style.functions.stops.IntervalStops; import com.mapbox.mapboxsdk.style.functions.stops.Stop; import com.mapbox.mapboxsdk.style.functions.stops.Stops; import com.mapbox.mapboxsdk.style.layers.FillLayer; -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.action.MapboxMapAction; import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest; -import org.junit.After; -import org.junit.Before; -import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; import static com.mapbox.mapboxsdk.style.functions.Function.*; import static com.mapbox.mapboxsdk.style.functions.stops.Stop.stop; import static com.mapbox.mapboxsdk.style.functions.stops.Stops.*; +import static com.mapbox.mapboxsdk.testapp.action.MapboxMapAction.invoke; import static org.junit.Assert.*; import static com.mapbox.mapboxsdk.style.layers.Property.*; import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*; @@ -53,15 +49,21 @@ public class FillLayerTest extends BaseActivityTest { return EspressoTestActivity.class; } - private void setupLayer(){ - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new FillLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - // Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } + private void setupLayer() { + Timber.i("Retrieving layer"); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new FillLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + // Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); + } + } + }); } @Test @@ -69,14 +71,19 @@ public class FillLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("Visibility"); - assertNotNull(layer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); - // Get initial - assertEquals(layer.getVisibility().getValue(), VISIBLE); + // Get initial + assertEquals(layer.getVisibility().getValue(), VISIBLE); - // Set - layer.setProperties(visibility(NONE)); - assertEquals(layer.getVisibility().getValue(), NONE); + // Set + layer.setProperties(visibility(NONE)); + assertEquals(layer.getVisibility().getValue(), NONE); + } + }); } @Test @@ -84,15 +91,20 @@ public class FillLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("SourceLayer"); - assertNotNull(layer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); - // Get initial - assertEquals(layer.getSourceLayer(), "composite"); + // Get initial + assertEquals(layer.getSourceLayer(), "composite"); - // Set - final String sourceLayer = "test"; - layer.setSourceLayer(sourceLayer); - assertEquals(layer.getSourceLayer(), sourceLayer); + // Set + final String sourceLayer = "test"; + layer.setSourceLayer(sourceLayer); + assertEquals(layer.getSourceLayer(), sourceLayer); + } + }); } @Test @@ -100,11 +112,16 @@ public class FillLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("fill-antialias"); - assertNotNull(layer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); - // Set and Get - layer.setProperties(fillAntialias(true)); - assertEquals((Boolean) layer.getFillAntialias().getValue(), (Boolean) true); + // Set and Get + layer.setProperties(fillAntialias(true)); + assertEquals((Boolean) layer.getFillAntialias().getValue(), (Boolean) true); + } + }); } @Test @@ -112,25 +129,30 @@ public class FillLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("fill-antialias"); - assertNotNull(layer); - - // Set - layer.setProperties( - fillAntialias( - zoom( - interval( - stop(2, fillAntialias(true)) + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + fillAntialias( + zoom( + interval( + stop(2, fillAntialias(true)) + ) + ) ) - ) - ) - ); + ); - // Verify - assertNotNull(layer.getFillAntialias()); - assertNotNull(layer.getFillAntialias().getFunction()); - assertEquals(CameraFunction.class, layer.getFillAntialias().getFunction().getClass()); - assertEquals(IntervalStops.class, layer.getFillAntialias().getFunction().getStops().getClass()); - assertEquals(1, ((IntervalStops) layer.getFillAntialias().getFunction().getStops()).size()); + // Verify + assertNotNull(layer.getFillAntialias()); + assertNotNull(layer.getFillAntialias().getFunction()); + assertEquals(CameraFunction.class, layer.getFillAntialias().getFunction().getClass()); + assertEquals(IntervalStops.class, layer.getFillAntialias().getFunction().getStops().getClass()); + assertEquals(1, ((IntervalStops) layer.getFillAntialias().getFunction().getStops()).size()); + } + }); } @Test @@ -138,12 +160,17 @@ public class FillLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("fill-opacityTransitionOptions"); - assertNotNull(layer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); - // Set and Get - TransitionOptions options = new TransitionOptions(300, 100); - layer.setFillOpacityTransition(options); - assertEquals(layer.getFillOpacityTransition(), options); + // Set and Get + TransitionOptions options = new TransitionOptions(300, 100); + layer.setFillOpacityTransition(options); + assertEquals(layer.getFillOpacityTransition(), options); + } + }); } @Test @@ -151,11 +178,16 @@ public class FillLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("fill-opacity"); - assertNotNull(layer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); - // Set and Get - layer.setProperties(fillOpacity(0.3f)); - assertEquals((Float) layer.getFillOpacity().getValue(), (Float) 0.3f); + // Set and Get + layer.setProperties(fillOpacity(0.3f)); + assertEquals((Float) layer.getFillOpacity().getValue(), (Float) 0.3f); + } + }); } @Test @@ -163,26 +195,31 @@ public class FillLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("fill-opacity"); - assertNotNull(layer); - - // Set - layer.setProperties( - fillOpacity( - zoom( - exponential( - stop(2, fillOpacity(0.3f)) - ).withBase(0.5f) - ) - ) - ); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + fillOpacity( + zoom( + exponential( + stop(2, fillOpacity(0.3f)) + ).withBase(0.5f) + ) + ) + ); - // Verify - assertNotNull(layer.getFillOpacity()); - assertNotNull(layer.getFillOpacity().getFunction()); - assertEquals(CameraFunction.class, layer.getFillOpacity().getFunction().getClass()); - assertEquals(ExponentialStops.class, layer.getFillOpacity().getFunction().getStops().getClass()); - assertEquals(0.5f, ((ExponentialStops) layer.getFillOpacity().getFunction().getStops()).getBase(), 0.001); - assertEquals(1, ((ExponentialStops) layer.getFillOpacity().getFunction().getStops()).size()); + // Verify + assertNotNull(layer.getFillOpacity()); + assertNotNull(layer.getFillOpacity().getFunction()); + assertEquals(CameraFunction.class, layer.getFillOpacity().getFunction().getClass()); + assertEquals(ExponentialStops.class, layer.getFillOpacity().getFunction().getStops().getClass()); + assertEquals(0.5f, ((ExponentialStops) layer.getFillOpacity().getFunction().getStops()).getBase(), 0.001); + assertEquals(1, ((ExponentialStops) layer.getFillOpacity().getFunction().getStops()).size()); + } + }); } @Test @@ -190,19 +227,24 @@ public class FillLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("fill-opacity"); - assertNotNull(layer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); - // Set - layer.setProperties( - fillOpacity(property("FeaturePropertyA", Stops.<Float>identity())) - ); + // Set + layer.setProperties( + fillOpacity(property("FeaturePropertyA", Stops.<Float>identity())) + ); - // Verify - assertNotNull(layer.getFillOpacity()); - assertNotNull(layer.getFillOpacity().getFunction()); - assertEquals(SourceFunction.class, layer.getFillOpacity().getFunction().getClass()); - assertEquals("FeaturePropertyA", ((SourceFunction) layer.getFillOpacity().getFunction()).getProperty()); - assertEquals(IdentityStops.class, layer.getFillOpacity().getFunction().getStops().getClass()); + // Verify + assertNotNull(layer.getFillOpacity()); + assertNotNull(layer.getFillOpacity().getFunction()); + assertEquals(SourceFunction.class, layer.getFillOpacity().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getFillOpacity().getFunction()).getProperty()); + assertEquals(IdentityStops.class, layer.getFillOpacity().getFunction().getStops().getClass()); + } + }); } @Test @@ -210,26 +252,31 @@ public class FillLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("fill-opacity"); - assertNotNull(layer); - - // Set - layer.setProperties( - fillOpacity( - property( - "FeaturePropertyA", - exponential( - stop(0.3f, fillOpacity(0.3f)) - ).withBase(0.5f) - ) - ) - ); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + fillOpacity( + property( + "FeaturePropertyA", + exponential( + stop(0.3f, fillOpacity(0.3f)) + ).withBase(0.5f) + ) + ) + ); - // Verify - assertNotNull(layer.getFillOpacity()); - assertNotNull(layer.getFillOpacity().getFunction()); - assertEquals(SourceFunction.class, layer.getFillOpacity().getFunction().getClass()); - assertEquals("FeaturePropertyA", ((SourceFunction) layer.getFillOpacity().getFunction()).getProperty()); - assertEquals(ExponentialStops.class, layer.getFillOpacity().getFunction().getStops().getClass()); + // Verify + assertNotNull(layer.getFillOpacity()); + assertNotNull(layer.getFillOpacity().getFunction()); + assertEquals(SourceFunction.class, layer.getFillOpacity().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getFillOpacity().getFunction()).getProperty()); + assertEquals(ExponentialStops.class, layer.getFillOpacity().getFunction().getStops().getClass()); + } + }); } @Test @@ -237,29 +284,35 @@ public class FillLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("fill-opacity"); - assertNotNull(layer); - - // Set - layer.setProperties( - fillOpacity( - property( - "FeaturePropertyA", - categorical( - stop(1.0f, fillOpacity(0.3f)) + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + fillOpacity( + property( + "FeaturePropertyA", + categorical( + stop(1.0f, fillOpacity(0.3f)) + ) + ).withDefaultValue(fillOpacity(0.3f)) ) - ).withDefaultValue(fillOpacity(0.3f)) - ) - ); + ); + + // Verify + assertNotNull(layer.getFillOpacity()); + assertNotNull(layer.getFillOpacity().getFunction()); + assertEquals(SourceFunction.class, layer.getFillOpacity().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getFillOpacity().getFunction()).getProperty()); + assertEquals(CategoricalStops.class, layer.getFillOpacity().getFunction().getStops().getClass()); + assertNotNull(((SourceFunction) layer.getFillOpacity().getFunction()).getDefaultValue()); + assertNotNull(((SourceFunction) layer.getFillOpacity().getFunction()).getDefaultValue().getValue()); + assertEquals(0.3f, ((SourceFunction) layer.getFillOpacity().getFunction()).getDefaultValue().getValue()); + } + }); - // Verify - assertNotNull(layer.getFillOpacity()); - assertNotNull(layer.getFillOpacity().getFunction()); - assertEquals(SourceFunction.class, layer.getFillOpacity().getFunction().getClass()); - assertEquals("FeaturePropertyA", ((SourceFunction) layer.getFillOpacity().getFunction()).getProperty()); - assertEquals(CategoricalStops.class, layer.getFillOpacity().getFunction().getStops().getClass()); - assertNotNull(((SourceFunction) layer.getFillOpacity().getFunction()).getDefaultValue()); - assertNotNull(((SourceFunction) layer.getFillOpacity().getFunction()).getDefaultValue().getValue()); - assertEquals(0.3f, ((SourceFunction) layer.getFillOpacity().getFunction()).getDefaultValue().getValue()); } @Test @@ -267,34 +320,39 @@ public class FillLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("fill-opacity"); - assertNotNull(layer); - - // Set - layer.setProperties( - fillOpacity( - composite( - "FeaturePropertyA", - exponential( - stop(0, 0.3f, fillOpacity(0.9f)) - ).withBase(0.5f) - ).withDefaultValue(fillOpacity(0.3f)) - ) - ); - - // Verify - assertNotNull(layer.getFillOpacity()); - assertNotNull(layer.getFillOpacity().getFunction()); - assertEquals(CompositeFunction.class, layer.getFillOpacity().getFunction().getClass()); - assertEquals("FeaturePropertyA", ((CompositeFunction) layer.getFillOpacity().getFunction()).getProperty()); - assertEquals(ExponentialStops.class, layer.getFillOpacity().getFunction().getStops().getClass()); - assertEquals(1, ((ExponentialStops) layer.getFillOpacity().getFunction().getStops()).size()); - - ExponentialStops<Stop.CompositeValue<Float, Float>, Float> stops = - (ExponentialStops<Stop.CompositeValue<Float, Float>, Float>) layer.getFillOpacity().getFunction().getStops(); - Stop<Stop.CompositeValue<Float, Float>, Float> stop = stops.iterator().next(); - assertEquals(0f, stop.in.zoom, 0.001); - assertEquals(0.3f, stop.in.value, 0.001f); - assertEquals(0.9f, stop.out, 0.001f); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + fillOpacity( + composite( + "FeaturePropertyA", + exponential( + stop(0, 0.3f, fillOpacity(0.9f)) + ).withBase(0.5f) + ).withDefaultValue(fillOpacity(0.3f)) + ) + ); + + // Verify + assertNotNull(layer.getFillOpacity()); + assertNotNull(layer.getFillOpacity().getFunction()); + assertEquals(CompositeFunction.class, layer.getFillOpacity().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((CompositeFunction) layer.getFillOpacity().getFunction()).getProperty()); + assertEquals(ExponentialStops.class, layer.getFillOpacity().getFunction().getStops().getClass()); + assertEquals(1, ((ExponentialStops) layer.getFillOpacity().getFunction().getStops()).size()); + + ExponentialStops<Stop.CompositeValue<Float, Float>, Float> stops = + (ExponentialStops<Stop.CompositeValue<Float, Float>, Float>) layer.getFillOpacity().getFunction().getStops(); + Stop<Stop.CompositeValue<Float, Float>, Float> stop = stops.iterator().next(); + assertEquals(0f, stop.in.zoom, 0.001); + assertEquals(0.3f, stop.in.value, 0.001f); + assertEquals(0.9f, stop.out, 0.001f); + } + }); } @Test @@ -302,12 +360,17 @@ public class FillLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("fill-colorTransitionOptions"); - assertNotNull(layer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); - // Set and Get - TransitionOptions options = new TransitionOptions(300, 100); - layer.setFillColorTransition(options); - assertEquals(layer.getFillColorTransition(), options); + // Set and Get + TransitionOptions options = new TransitionOptions(300, 100); + layer.setFillColorTransition(options); + assertEquals(layer.getFillColorTransition(), options); + } + }); } @Test @@ -315,11 +378,16 @@ public class FillLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("fill-color"); - assertNotNull(layer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); - // Set and Get - layer.setProperties(fillColor("rgba(0, 0, 0, 1)")); - assertEquals((String) layer.getFillColor().getValue(), (String) "rgba(0, 0, 0, 1)"); + // Set and Get + layer.setProperties(fillColor("rgba(0, 0, 0, 1)")); + assertEquals((String) layer.getFillColor().getValue(), (String) "rgba(0, 0, 0, 1)"); + } + }); } @Test @@ -327,26 +395,31 @@ public class FillLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("fill-color"); - assertNotNull(layer); - - // Set - layer.setProperties( - fillColor( - zoom( - exponential( - stop(2, fillColor("rgba(0, 0, 0, 1)")) - ).withBase(0.5f) - ) - ) - ); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + fillColor( + zoom( + exponential( + stop(2, fillColor("rgba(0, 0, 0, 1)")) + ).withBase(0.5f) + ) + ) + ); - // Verify - assertNotNull(layer.getFillColor()); - assertNotNull(layer.getFillColor().getFunction()); - assertEquals(CameraFunction.class, layer.getFillColor().getFunction().getClass()); - assertEquals(ExponentialStops.class, layer.getFillColor().getFunction().getStops().getClass()); - assertEquals(0.5f, ((ExponentialStops) layer.getFillColor().getFunction().getStops()).getBase(), 0.001); - assertEquals(1, ((ExponentialStops) layer.getFillColor().getFunction().getStops()).size()); + // Verify + assertNotNull(layer.getFillColor()); + assertNotNull(layer.getFillColor().getFunction()); + assertEquals(CameraFunction.class, layer.getFillColor().getFunction().getClass()); + assertEquals(ExponentialStops.class, layer.getFillColor().getFunction().getStops().getClass()); + assertEquals(0.5f, ((ExponentialStops) layer.getFillColor().getFunction().getStops()).getBase(), 0.001); + assertEquals(1, ((ExponentialStops) layer.getFillColor().getFunction().getStops()).size()); + } + }); } @Test @@ -354,19 +427,24 @@ public class FillLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("fill-color"); - assertNotNull(layer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); - // Set - layer.setProperties( - fillColor(property("FeaturePropertyA", Stops.<String>identity())) - ); + // Set + layer.setProperties( + fillColor(property("FeaturePropertyA", Stops.<String>identity())) + ); - // Verify - assertNotNull(layer.getFillColor()); - assertNotNull(layer.getFillColor().getFunction()); - assertEquals(SourceFunction.class, layer.getFillColor().getFunction().getClass()); - assertEquals("FeaturePropertyA", ((SourceFunction) layer.getFillColor().getFunction()).getProperty()); - assertEquals(IdentityStops.class, layer.getFillColor().getFunction().getStops().getClass()); + // Verify + assertNotNull(layer.getFillColor()); + assertNotNull(layer.getFillColor().getFunction()); + assertEquals(SourceFunction.class, layer.getFillColor().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getFillColor().getFunction()).getProperty()); + assertEquals(IdentityStops.class, layer.getFillColor().getFunction().getStops().getClass()); + } + }); } @Test @@ -374,26 +452,31 @@ public class FillLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("fill-color"); - assertNotNull(layer); - - // Set - layer.setProperties( - fillColor( - property( - "FeaturePropertyA", - exponential( - stop(Color.RED, fillColor(Color.RED)) - ).withBase(0.5f) - ) - ) - ); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + fillColor( + property( + "FeaturePropertyA", + exponential( + stop(Color.RED, fillColor(Color.RED)) + ).withBase(0.5f) + ) + ) + ); - // Verify - assertNotNull(layer.getFillColor()); - assertNotNull(layer.getFillColor().getFunction()); - assertEquals(SourceFunction.class, layer.getFillColor().getFunction().getClass()); - assertEquals("FeaturePropertyA", ((SourceFunction) layer.getFillColor().getFunction()).getProperty()); - assertEquals(ExponentialStops.class, layer.getFillColor().getFunction().getStops().getClass()); + // Verify + assertNotNull(layer.getFillColor()); + assertNotNull(layer.getFillColor().getFunction()); + assertEquals(SourceFunction.class, layer.getFillColor().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getFillColor().getFunction()).getProperty()); + assertEquals(ExponentialStops.class, layer.getFillColor().getFunction().getStops().getClass()); + } + }); } @Test @@ -401,29 +484,35 @@ public class FillLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("fill-color"); - assertNotNull(layer); - - // Set - layer.setProperties( - fillColor( - property( - "FeaturePropertyA", - categorical( - stop("valueA", fillColor(Color.RED)) + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + fillColor( + property( + "FeaturePropertyA", + categorical( + stop("valueA", fillColor(Color.RED)) + ) + ).withDefaultValue(fillColor(Color.GREEN)) ) - ).withDefaultValue(fillColor(Color.GREEN)) - ) - ); + ); + + // Verify + assertNotNull(layer.getFillColor()); + assertNotNull(layer.getFillColor().getFunction()); + assertEquals(SourceFunction.class, layer.getFillColor().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getFillColor().getFunction()).getProperty()); + assertEquals(CategoricalStops.class, layer.getFillColor().getFunction().getStops().getClass()); + assertNotNull(((SourceFunction) layer.getFillColor().getFunction()).getDefaultValue()); + assertNotNull(((SourceFunction) layer.getFillColor().getFunction()).getDefaultValue().getValue()); + assertEquals(Color.GREEN, (int) ((SourceFunction) layer.getFillColor().getFunction()).getDefaultValue().getColorInt()); + } + }); - // Verify - assertNotNull(layer.getFillColor()); - assertNotNull(layer.getFillColor().getFunction()); - assertEquals(SourceFunction.class, layer.getFillColor().getFunction().getClass()); - assertEquals("FeaturePropertyA", ((SourceFunction) layer.getFillColor().getFunction()).getProperty()); - assertEquals(CategoricalStops.class, layer.getFillColor().getFunction().getStops().getClass()); - assertNotNull(((SourceFunction) layer.getFillColor().getFunction()).getDefaultValue()); - assertNotNull(((SourceFunction) layer.getFillColor().getFunction()).getDefaultValue().getValue()); - assertEquals(Color.GREEN, (int) ((SourceFunction) layer.getFillColor().getFunction()).getDefaultValue().getColorInt()); } @Test @@ -431,11 +520,16 @@ public class FillLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("fill-color"); - assertNotNull(layer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); - // Set and Get - layer.setProperties(fillColor(Color.RED)); - assertEquals(layer.getFillColorAsInt(), Color.RED); + // Set and Get + layer.setProperties(fillColor(Color.RED)); + assertEquals(layer.getFillColorAsInt(), Color.RED); + } + }); } @Test @@ -443,12 +537,17 @@ public class FillLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("fill-outline-colorTransitionOptions"); - assertNotNull(layer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); - // Set and Get - TransitionOptions options = new TransitionOptions(300, 100); - layer.setFillOutlineColorTransition(options); - assertEquals(layer.getFillOutlineColorTransition(), options); + // Set and Get + TransitionOptions options = new TransitionOptions(300, 100); + layer.setFillOutlineColorTransition(options); + assertEquals(layer.getFillOutlineColorTransition(), options); + } + }); } @Test @@ -456,11 +555,16 @@ public class FillLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("fill-outline-color"); - assertNotNull(layer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); - // Set and Get - layer.setProperties(fillOutlineColor("rgba(0, 0, 0, 1)")); - assertEquals((String) layer.getFillOutlineColor().getValue(), (String) "rgba(0, 0, 0, 1)"); + // Set and Get + layer.setProperties(fillOutlineColor("rgba(0, 0, 0, 1)")); + assertEquals((String) layer.getFillOutlineColor().getValue(), (String) "rgba(0, 0, 0, 1)"); + } + }); } @Test @@ -468,26 +572,31 @@ public class FillLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("fill-outline-color"); - assertNotNull(layer); - - // Set - layer.setProperties( - fillOutlineColor( - zoom( - exponential( - stop(2, fillOutlineColor("rgba(0, 0, 0, 1)")) - ).withBase(0.5f) - ) - ) - ); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + fillOutlineColor( + zoom( + exponential( + stop(2, fillOutlineColor("rgba(0, 0, 0, 1)")) + ).withBase(0.5f) + ) + ) + ); - // Verify - assertNotNull(layer.getFillOutlineColor()); - assertNotNull(layer.getFillOutlineColor().getFunction()); - assertEquals(CameraFunction.class, layer.getFillOutlineColor().getFunction().getClass()); - assertEquals(ExponentialStops.class, layer.getFillOutlineColor().getFunction().getStops().getClass()); - assertEquals(0.5f, ((ExponentialStops) layer.getFillOutlineColor().getFunction().getStops()).getBase(), 0.001); - assertEquals(1, ((ExponentialStops) layer.getFillOutlineColor().getFunction().getStops()).size()); + // Verify + assertNotNull(layer.getFillOutlineColor()); + assertNotNull(layer.getFillOutlineColor().getFunction()); + assertEquals(CameraFunction.class, layer.getFillOutlineColor().getFunction().getClass()); + assertEquals(ExponentialStops.class, layer.getFillOutlineColor().getFunction().getStops().getClass()); + assertEquals(0.5f, ((ExponentialStops) layer.getFillOutlineColor().getFunction().getStops()).getBase(), 0.001); + assertEquals(1, ((ExponentialStops) layer.getFillOutlineColor().getFunction().getStops()).size()); + } + }); } @Test @@ -495,19 +604,24 @@ public class FillLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("fill-outline-color"); - assertNotNull(layer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); - // Set - layer.setProperties( - fillOutlineColor(property("FeaturePropertyA", Stops.<String>identity())) - ); + // Set + layer.setProperties( + fillOutlineColor(property("FeaturePropertyA", Stops.<String>identity())) + ); - // Verify - assertNotNull(layer.getFillOutlineColor()); - assertNotNull(layer.getFillOutlineColor().getFunction()); - assertEquals(SourceFunction.class, layer.getFillOutlineColor().getFunction().getClass()); - assertEquals("FeaturePropertyA", ((SourceFunction) layer.getFillOutlineColor().getFunction()).getProperty()); - assertEquals(IdentityStops.class, layer.getFillOutlineColor().getFunction().getStops().getClass()); + // Verify + assertNotNull(layer.getFillOutlineColor()); + assertNotNull(layer.getFillOutlineColor().getFunction()); + assertEquals(SourceFunction.class, layer.getFillOutlineColor().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getFillOutlineColor().getFunction()).getProperty()); + assertEquals(IdentityStops.class, layer.getFillOutlineColor().getFunction().getStops().getClass()); + } + }); } @Test @@ -515,26 +629,31 @@ public class FillLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("fill-outline-color"); - assertNotNull(layer); - - // Set - layer.setProperties( - fillOutlineColor( - property( - "FeaturePropertyA", - exponential( - stop(Color.RED, fillOutlineColor(Color.RED)) - ).withBase(0.5f) - ) - ) - ); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + fillOutlineColor( + property( + "FeaturePropertyA", + exponential( + stop(Color.RED, fillOutlineColor(Color.RED)) + ).withBase(0.5f) + ) + ) + ); - // Verify - assertNotNull(layer.getFillOutlineColor()); - assertNotNull(layer.getFillOutlineColor().getFunction()); - assertEquals(SourceFunction.class, layer.getFillOutlineColor().getFunction().getClass()); - assertEquals("FeaturePropertyA", ((SourceFunction) layer.getFillOutlineColor().getFunction()).getProperty()); - assertEquals(ExponentialStops.class, layer.getFillOutlineColor().getFunction().getStops().getClass()); + // Verify + assertNotNull(layer.getFillOutlineColor()); + assertNotNull(layer.getFillOutlineColor().getFunction()); + assertEquals(SourceFunction.class, layer.getFillOutlineColor().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getFillOutlineColor().getFunction()).getProperty()); + assertEquals(ExponentialStops.class, layer.getFillOutlineColor().getFunction().getStops().getClass()); + } + }); } @Test @@ -542,29 +661,35 @@ public class FillLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("fill-outline-color"); - assertNotNull(layer); - - // Set - layer.setProperties( - fillOutlineColor( - property( - "FeaturePropertyA", - categorical( - stop("valueA", fillOutlineColor(Color.RED)) + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + fillOutlineColor( + property( + "FeaturePropertyA", + categorical( + stop("valueA", fillOutlineColor(Color.RED)) + ) + ).withDefaultValue(fillOutlineColor(Color.GREEN)) ) - ).withDefaultValue(fillOutlineColor(Color.GREEN)) - ) - ); + ); + + // Verify + assertNotNull(layer.getFillOutlineColor()); + assertNotNull(layer.getFillOutlineColor().getFunction()); + assertEquals(SourceFunction.class, layer.getFillOutlineColor().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getFillOutlineColor().getFunction()).getProperty()); + assertEquals(CategoricalStops.class, layer.getFillOutlineColor().getFunction().getStops().getClass()); + assertNotNull(((SourceFunction) layer.getFillOutlineColor().getFunction()).getDefaultValue()); + assertNotNull(((SourceFunction) layer.getFillOutlineColor().getFunction()).getDefaultValue().getValue()); + assertEquals(Color.GREEN, (int) ((SourceFunction) layer.getFillOutlineColor().getFunction()).getDefaultValue().getColorInt()); + } + }); - // Verify - assertNotNull(layer.getFillOutlineColor()); - assertNotNull(layer.getFillOutlineColor().getFunction()); - assertEquals(SourceFunction.class, layer.getFillOutlineColor().getFunction().getClass()); - assertEquals("FeaturePropertyA", ((SourceFunction) layer.getFillOutlineColor().getFunction()).getProperty()); - assertEquals(CategoricalStops.class, layer.getFillOutlineColor().getFunction().getStops().getClass()); - assertNotNull(((SourceFunction) layer.getFillOutlineColor().getFunction()).getDefaultValue()); - assertNotNull(((SourceFunction) layer.getFillOutlineColor().getFunction()).getDefaultValue().getValue()); - assertEquals(Color.GREEN, (int) ((SourceFunction) layer.getFillOutlineColor().getFunction()).getDefaultValue().getColorInt()); } @Test @@ -572,11 +697,16 @@ public class FillLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("fill-outline-color"); - assertNotNull(layer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); - // Set and Get - layer.setProperties(fillOutlineColor(Color.RED)); - assertEquals(layer.getFillOutlineColorAsInt(), Color.RED); + // Set and Get + layer.setProperties(fillOutlineColor(Color.RED)); + assertEquals(layer.getFillOutlineColorAsInt(), Color.RED); + } + }); } @Test @@ -584,12 +714,17 @@ public class FillLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("fill-translateTransitionOptions"); - assertNotNull(layer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); - // Set and Get - TransitionOptions options = new TransitionOptions(300, 100); - layer.setFillTranslateTransition(options); - assertEquals(layer.getFillTranslateTransition(), options); + // Set and Get + TransitionOptions options = new TransitionOptions(300, 100); + layer.setFillTranslateTransition(options); + assertEquals(layer.getFillTranslateTransition(), options); + } + }); } @Test @@ -597,11 +732,16 @@ public class FillLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("fill-translate"); - assertNotNull(layer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); - // Set and Get - layer.setProperties(fillTranslate(new Float[]{0f,0f})); - assertEquals((Float[]) layer.getFillTranslate().getValue(), (Float[]) new Float[]{0f,0f}); + // Set and Get + layer.setProperties(fillTranslate(new Float[] {0f, 0f})); + assertEquals((Float[]) layer.getFillTranslate().getValue(), (Float[]) new Float[] {0f, 0f}); + } + }); } @Test @@ -609,26 +749,31 @@ public class FillLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("fill-translate"); - assertNotNull(layer); - - // Set - layer.setProperties( - fillTranslate( - zoom( - exponential( - stop(2, fillTranslate(new Float[]{0f,0f})) - ).withBase(0.5f) - ) - ) - ); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + fillTranslate( + zoom( + exponential( + stop(2, fillTranslate(new Float[] {0f, 0f})) + ).withBase(0.5f) + ) + ) + ); - // Verify - assertNotNull(layer.getFillTranslate()); - assertNotNull(layer.getFillTranslate().getFunction()); - assertEquals(CameraFunction.class, layer.getFillTranslate().getFunction().getClass()); - assertEquals(ExponentialStops.class, layer.getFillTranslate().getFunction().getStops().getClass()); - assertEquals(0.5f, ((ExponentialStops) layer.getFillTranslate().getFunction().getStops()).getBase(), 0.001); - assertEquals(1, ((ExponentialStops) layer.getFillTranslate().getFunction().getStops()).size()); + // Verify + assertNotNull(layer.getFillTranslate()); + assertNotNull(layer.getFillTranslate().getFunction()); + assertEquals(CameraFunction.class, layer.getFillTranslate().getFunction().getClass()); + assertEquals(ExponentialStops.class, layer.getFillTranslate().getFunction().getStops().getClass()); + assertEquals(0.5f, ((ExponentialStops) layer.getFillTranslate().getFunction().getStops()).getBase(), 0.001); + assertEquals(1, ((ExponentialStops) layer.getFillTranslate().getFunction().getStops()).size()); + } + }); } @Test @@ -636,11 +781,16 @@ public class FillLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("fill-translate-anchor"); - assertNotNull(layer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); - // Set and Get - layer.setProperties(fillTranslateAnchor(FILL_TRANSLATE_ANCHOR_MAP)); - assertEquals((String) layer.getFillTranslateAnchor().getValue(), (String) FILL_TRANSLATE_ANCHOR_MAP); + // Set and Get + layer.setProperties(fillTranslateAnchor(FILL_TRANSLATE_ANCHOR_MAP)); + assertEquals((String) layer.getFillTranslateAnchor().getValue(), (String) FILL_TRANSLATE_ANCHOR_MAP); + } + }); } @Test @@ -648,25 +798,30 @@ public class FillLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("fill-translate-anchor"); - assertNotNull(layer); - - // Set - layer.setProperties( - fillTranslateAnchor( - zoom( - interval( - stop(2, fillTranslateAnchor(FILL_TRANSLATE_ANCHOR_MAP)) + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + fillTranslateAnchor( + zoom( + interval( + stop(2, fillTranslateAnchor(FILL_TRANSLATE_ANCHOR_MAP)) + ) + ) ) - ) - ) - ); + ); - // Verify - assertNotNull(layer.getFillTranslateAnchor()); - assertNotNull(layer.getFillTranslateAnchor().getFunction()); - assertEquals(CameraFunction.class, layer.getFillTranslateAnchor().getFunction().getClass()); - assertEquals(IntervalStops.class, layer.getFillTranslateAnchor().getFunction().getStops().getClass()); - assertEquals(1, ((IntervalStops) layer.getFillTranslateAnchor().getFunction().getStops()).size()); + // Verify + assertNotNull(layer.getFillTranslateAnchor()); + assertNotNull(layer.getFillTranslateAnchor().getFunction()); + assertEquals(CameraFunction.class, layer.getFillTranslateAnchor().getFunction().getClass()); + assertEquals(IntervalStops.class, layer.getFillTranslateAnchor().getFunction().getStops().getClass()); + assertEquals(1, ((IntervalStops) layer.getFillTranslateAnchor().getFunction().getStops()).size()); + } + }); } @Test @@ -674,12 +829,17 @@ public class FillLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("fill-patternTransitionOptions"); - assertNotNull(layer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); - // Set and Get - TransitionOptions options = new TransitionOptions(300, 100); - layer.setFillPatternTransition(options); - assertEquals(layer.getFillPatternTransition(), options); + // Set and Get + TransitionOptions options = new TransitionOptions(300, 100); + layer.setFillPatternTransition(options); + assertEquals(layer.getFillPatternTransition(), options); + } + }); } @Test @@ -687,11 +847,16 @@ public class FillLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("fill-pattern"); - assertNotNull(layer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); - // Set and Get - layer.setProperties(fillPattern("pedestrian-polygon")); - assertEquals((String) layer.getFillPattern().getValue(), (String) "pedestrian-polygon"); + // Set and Get + layer.setProperties(fillPattern("pedestrian-polygon")); + assertEquals((String) layer.getFillPattern().getValue(), (String) "pedestrian-polygon"); + } + }); } @Test @@ -699,25 +864,30 @@ public class FillLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("fill-pattern"); - assertNotNull(layer); - - // Set - layer.setProperties( - fillPattern( - zoom( - interval( - stop(2, fillPattern("pedestrian-polygon")) + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + fillPattern( + zoom( + interval( + stop(2, fillPattern("pedestrian-polygon")) + ) + ) ) - ) - ) - ); - - // Verify - assertNotNull(layer.getFillPattern()); - assertNotNull(layer.getFillPattern().getFunction()); - assertEquals(CameraFunction.class, layer.getFillPattern().getFunction().getClass()); - assertEquals(IntervalStops.class, layer.getFillPattern().getFunction().getStops().getClass()); - assertEquals(1, ((IntervalStops) layer.getFillPattern().getFunction().getStops()).size()); + ); + + // Verify + assertNotNull(layer.getFillPattern()); + assertNotNull(layer.getFillPattern().getFunction()); + assertEquals(CameraFunction.class, layer.getFillPattern().getFunction().getClass()); + assertEquals(IntervalStops.class, layer.getFillPattern().getFunction().getStops().getClass()); + assertEquals(1, ((IntervalStops) layer.getFillPattern().getFunction().getStops()).size()); + } + }); } } diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/LightTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/LightTest.java index 36833fb4ee..88da6e45be 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/LightTest.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/LightTest.java @@ -6,6 +6,7 @@ import android.support.test.espresso.ViewAction; import android.support.test.runner.AndroidJUnit4; import android.view.View; +import com.mapbox.mapboxsdk.maps.MapboxMap; import com.mapbox.mapboxsdk.style.light.Light; import com.mapbox.mapboxsdk.style.functions.Function; import com.mapbox.mapboxsdk.style.functions.stops.IdentityStops; @@ -13,6 +14,7 @@ import com.mapbox.mapboxsdk.style.layers.FillExtrusionLayer; import com.mapbox.mapboxsdk.style.layers.TransitionOptions; import com.mapbox.mapboxsdk.style.light.Position; import com.mapbox.mapboxsdk.testapp.R; +import com.mapbox.mapboxsdk.testapp.action.MapboxMapAction; import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest; import com.mapbox.mapboxsdk.testapp.activity.style.FillExtrusionStyleTestActivity; @@ -32,6 +34,7 @@ import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillExtrusionCol import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillExtrusionHeight; import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillExtrusionOpacity; +import static com.mapbox.mapboxsdk.testapp.action.MapboxMapAction.invoke; import static junit.framework.Assert.assertEquals; import static junit.framework.Assert.assertNotNull; @@ -43,89 +46,120 @@ public class LightTest extends BaseActivityTest { @Test public void testAnchor() { validateTestSetup(); - setupLayer(); + setupLight(); Timber.i("anchor"); - assertNotNull(light); - // Set and Get - light.setAnchor(ANCHOR_MAP); - assertEquals("Anchor should match", ANCHOR_MAP, light.getAnchor()); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(light); + // Set and Get + light.setAnchor(ANCHOR_MAP); + assertEquals("Anchor should match", ANCHOR_MAP, light.getAnchor()); + } + }); } @Test public void testPositionTransition() { validateTestSetup(); - setupLayer(); + setupLight(); Timber.i("positionTransitionOptions"); - assertNotNull(light); - - // Set and Get - TransitionOptions options = new TransitionOptions(300, 100); - light.setPositionTransition(options); - assertEquals("Transition options should match", options, light.getPositionTransition()); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(light); + // Set and Get + TransitionOptions options = new TransitionOptions(300, 100); + light.setPositionTransition(options); + assertEquals("Transition options should match", options, light.getPositionTransition()); + } + }); } @Test public void testPosition() { validateTestSetup(); - setupLayer(); + setupLight(); Timber.i("position"); - assertNotNull(light); - - // Set and Get - Position position = new Position(1,2,3); - light.setPosition(position); - assertEquals("Position should match", position, light.getPosition()); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(light); + // Set and Get + Position position = new Position(1, 2, 3); + light.setPosition(position); + assertEquals("Position should match", position, light.getPosition()); + } + }); } @Test public void testColorTransition() { validateTestSetup(); - setupLayer(); + setupLight(); Timber.i("colorTransitionOptions"); - assertNotNull(light); - - // Set and Get - TransitionOptions options = new TransitionOptions(300, 100); - light.setColorTransition(options); - assertEquals("Transition options should match", options, light.getColorTransition()); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(light); + // Set and Get + TransitionOptions options = new TransitionOptions(300, 100); + light.setColorTransition(options); + assertEquals("Transition options should match", options, light.getColorTransition()); + } + }); } @Test public void testColor() { validateTestSetup(); - setupLayer(); + setupLight(); Timber.i("color"); - assertNotNull(light); - // Set and Get - light.setColor("rgba(0, 0, 0, 1)"); - assertEquals("Color should match", "rgba(0, 0, 0, 1)".replaceAll("\\s+",""), light.getColor()); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(light); + // Set and Get + light.setColor("rgba(0, 0, 0, 1)"); + assertEquals("Color should match", "rgba(0, 0, 0, 1)".replaceAll("\\s+", ""), light.getColor()); + } + }); } @Test public void testIntensityTransition() { validateTestSetup(); - setupLayer(); + setupLight(); Timber.i("intensityTransitionOptions"); - assertNotNull(light); - - // Set and Get - TransitionOptions options = new TransitionOptions(300, 100); - light.setIntensityTransition(options); - assertEquals("Transition options should match", options, light.getIntensityTransition()); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(light); + // Set and Get + TransitionOptions options = new TransitionOptions(300, 100); + light.setIntensityTransition(options); + assertEquals("Transition options should match", options, light.getIntensityTransition()); + } + }); } @Test public void testIntensity() { validateTestSetup(); - setupLayer(); + setupLight(); Timber.i("intensity"); - assertNotNull(light); - // Set and Get - light.setIntensity(0.3f); - assertEquals("Intensity should match", 0.3f, light.getIntensity()); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(light); + // Set and Get + light.setIntensity(0.3f); + assertEquals("Intensity should match", 0.3f, light.getIntensity()); + } + }); } - private void setupLayer() { + private void setupLight() { onView(withId(R.id.mapView)).perform(new ViewAction() { @Override public Matcher<View> getConstraints() { diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/LineLayerTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/LineLayerTest.java index c10c908c8d..234bc583d7 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/LineLayerTest.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/LineLayerTest.java @@ -3,9 +3,9 @@ package com.mapbox.mapboxsdk.testapp.style; import android.graphics.Color; -import android.support.test.espresso.Espresso; -import android.support.test.rule.ActivityTestRule; +import android.support.test.espresso.UiController; import android.support.test.runner.AndroidJUnit4; + import timber.log.Timber; import com.mapbox.mapboxsdk.maps.MapboxMap; @@ -19,20 +19,16 @@ import com.mapbox.mapboxsdk.style.functions.stops.IntervalStops; import com.mapbox.mapboxsdk.style.functions.stops.Stop; import com.mapbox.mapboxsdk.style.functions.stops.Stops; import com.mapbox.mapboxsdk.style.layers.LineLayer; -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.action.MapboxMapAction; import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest; -import org.junit.After; -import org.junit.Before; -import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; import static com.mapbox.mapboxsdk.style.functions.Function.*; import static com.mapbox.mapboxsdk.style.functions.stops.Stop.stop; import static com.mapbox.mapboxsdk.style.functions.stops.Stops.*; +import static com.mapbox.mapboxsdk.testapp.action.MapboxMapAction.invoke; import static org.junit.Assert.*; import static com.mapbox.mapboxsdk.style.layers.Property.*; import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*; @@ -53,15 +49,21 @@ public class LineLayerTest extends BaseActivityTest { return EspressoTestActivity.class; } - private void setupLayer(){ - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new LineLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - // Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } + private void setupLayer() { + Timber.i("Retrieving layer"); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new LineLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + // Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); + } + } + }); } @Test @@ -69,14 +71,19 @@ public class LineLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("Visibility"); - assertNotNull(layer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); - // Get initial - assertEquals(layer.getVisibility().getValue(), VISIBLE); + // Get initial + assertEquals(layer.getVisibility().getValue(), VISIBLE); - // Set - layer.setProperties(visibility(NONE)); - assertEquals(layer.getVisibility().getValue(), NONE); + // Set + layer.setProperties(visibility(NONE)); + assertEquals(layer.getVisibility().getValue(), NONE); + } + }); } @Test @@ -84,15 +91,20 @@ public class LineLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("SourceLayer"); - assertNotNull(layer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); - // Get initial - assertEquals(layer.getSourceLayer(), "composite"); + // Get initial + assertEquals(layer.getSourceLayer(), "composite"); - // Set - final String sourceLayer = "test"; - layer.setSourceLayer(sourceLayer); - assertEquals(layer.getSourceLayer(), sourceLayer); + // Set + final String sourceLayer = "test"; + layer.setSourceLayer(sourceLayer); + assertEquals(layer.getSourceLayer(), sourceLayer); + } + }); } @Test @@ -100,11 +112,16 @@ public class LineLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("line-cap"); - assertNotNull(layer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); - // Set and Get - layer.setProperties(lineCap(LINE_CAP_BUTT)); - assertEquals((String) layer.getLineCap().getValue(), (String) LINE_CAP_BUTT); + // Set and Get + layer.setProperties(lineCap(LINE_CAP_BUTT)); + assertEquals((String) layer.getLineCap().getValue(), (String) LINE_CAP_BUTT); + } + }); } @Test @@ -112,25 +129,30 @@ public class LineLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("line-cap"); - assertNotNull(layer); - - // Set - layer.setProperties( - lineCap( - zoom( - interval( - stop(2, lineCap(LINE_CAP_BUTT)) + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + lineCap( + zoom( + interval( + stop(2, lineCap(LINE_CAP_BUTT)) + ) + ) ) - ) - ) - ); + ); - // Verify - assertNotNull(layer.getLineCap()); - assertNotNull(layer.getLineCap().getFunction()); - assertEquals(CameraFunction.class, layer.getLineCap().getFunction().getClass()); - assertEquals(IntervalStops.class, layer.getLineCap().getFunction().getStops().getClass()); - assertEquals(1, ((IntervalStops) layer.getLineCap().getFunction().getStops()).size()); + // Verify + assertNotNull(layer.getLineCap()); + assertNotNull(layer.getLineCap().getFunction()); + assertEquals(CameraFunction.class, layer.getLineCap().getFunction().getClass()); + assertEquals(IntervalStops.class, layer.getLineCap().getFunction().getStops().getClass()); + assertEquals(1, ((IntervalStops) layer.getLineCap().getFunction().getStops()).size()); + } + }); } @Test @@ -138,11 +160,16 @@ public class LineLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("line-join"); - assertNotNull(layer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); - // Set and Get - layer.setProperties(lineJoin(LINE_JOIN_BEVEL)); - assertEquals((String) layer.getLineJoin().getValue(), (String) LINE_JOIN_BEVEL); + // Set and Get + layer.setProperties(lineJoin(LINE_JOIN_BEVEL)); + assertEquals((String) layer.getLineJoin().getValue(), (String) LINE_JOIN_BEVEL); + } + }); } @Test @@ -150,25 +177,30 @@ public class LineLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("line-join"); - assertNotNull(layer); - - // Set - layer.setProperties( - lineJoin( - zoom( - interval( - stop(2, lineJoin(LINE_JOIN_BEVEL)) + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + lineJoin( + zoom( + interval( + stop(2, lineJoin(LINE_JOIN_BEVEL)) + ) + ) ) - ) - ) - ); + ); - // Verify - assertNotNull(layer.getLineJoin()); - assertNotNull(layer.getLineJoin().getFunction()); - assertEquals(CameraFunction.class, layer.getLineJoin().getFunction().getClass()); - assertEquals(IntervalStops.class, layer.getLineJoin().getFunction().getStops().getClass()); - assertEquals(1, ((IntervalStops) layer.getLineJoin().getFunction().getStops()).size()); + // Verify + assertNotNull(layer.getLineJoin()); + assertNotNull(layer.getLineJoin().getFunction()); + assertEquals(CameraFunction.class, layer.getLineJoin().getFunction().getClass()); + assertEquals(IntervalStops.class, layer.getLineJoin().getFunction().getStops().getClass()); + assertEquals(1, ((IntervalStops) layer.getLineJoin().getFunction().getStops()).size()); + } + }); } @Test @@ -176,11 +208,16 @@ public class LineLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("line-miter-limit"); - assertNotNull(layer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); - // Set and Get - layer.setProperties(lineMiterLimit(0.3f)); - assertEquals((Float) layer.getLineMiterLimit().getValue(), (Float) 0.3f); + // Set and Get + layer.setProperties(lineMiterLimit(0.3f)); + assertEquals((Float) layer.getLineMiterLimit().getValue(), (Float) 0.3f); + } + }); } @Test @@ -188,26 +225,31 @@ public class LineLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("line-miter-limit"); - assertNotNull(layer); - - // Set - layer.setProperties( - lineMiterLimit( - zoom( - exponential( - stop(2, lineMiterLimit(0.3f)) - ).withBase(0.5f) - ) - ) - ); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + lineMiterLimit( + zoom( + exponential( + stop(2, lineMiterLimit(0.3f)) + ).withBase(0.5f) + ) + ) + ); - // Verify - assertNotNull(layer.getLineMiterLimit()); - assertNotNull(layer.getLineMiterLimit().getFunction()); - assertEquals(CameraFunction.class, layer.getLineMiterLimit().getFunction().getClass()); - assertEquals(ExponentialStops.class, layer.getLineMiterLimit().getFunction().getStops().getClass()); - assertEquals(0.5f, ((ExponentialStops) layer.getLineMiterLimit().getFunction().getStops()).getBase(), 0.001); - assertEquals(1, ((ExponentialStops) layer.getLineMiterLimit().getFunction().getStops()).size()); + // Verify + assertNotNull(layer.getLineMiterLimit()); + assertNotNull(layer.getLineMiterLimit().getFunction()); + assertEquals(CameraFunction.class, layer.getLineMiterLimit().getFunction().getClass()); + assertEquals(ExponentialStops.class, layer.getLineMiterLimit().getFunction().getStops().getClass()); + assertEquals(0.5f, ((ExponentialStops) layer.getLineMiterLimit().getFunction().getStops()).getBase(), 0.001); + assertEquals(1, ((ExponentialStops) layer.getLineMiterLimit().getFunction().getStops()).size()); + } + }); } @Test @@ -215,11 +257,16 @@ public class LineLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("line-round-limit"); - assertNotNull(layer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); - // Set and Get - layer.setProperties(lineRoundLimit(0.3f)); - assertEquals((Float) layer.getLineRoundLimit().getValue(), (Float) 0.3f); + // Set and Get + layer.setProperties(lineRoundLimit(0.3f)); + assertEquals((Float) layer.getLineRoundLimit().getValue(), (Float) 0.3f); + } + }); } @Test @@ -227,26 +274,31 @@ public class LineLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("line-round-limit"); - assertNotNull(layer); - - // Set - layer.setProperties( - lineRoundLimit( - zoom( - exponential( - stop(2, lineRoundLimit(0.3f)) - ).withBase(0.5f) - ) - ) - ); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + lineRoundLimit( + zoom( + exponential( + stop(2, lineRoundLimit(0.3f)) + ).withBase(0.5f) + ) + ) + ); - // Verify - assertNotNull(layer.getLineRoundLimit()); - assertNotNull(layer.getLineRoundLimit().getFunction()); - assertEquals(CameraFunction.class, layer.getLineRoundLimit().getFunction().getClass()); - assertEquals(ExponentialStops.class, layer.getLineRoundLimit().getFunction().getStops().getClass()); - assertEquals(0.5f, ((ExponentialStops) layer.getLineRoundLimit().getFunction().getStops()).getBase(), 0.001); - assertEquals(1, ((ExponentialStops) layer.getLineRoundLimit().getFunction().getStops()).size()); + // Verify + assertNotNull(layer.getLineRoundLimit()); + assertNotNull(layer.getLineRoundLimit().getFunction()); + assertEquals(CameraFunction.class, layer.getLineRoundLimit().getFunction().getClass()); + assertEquals(ExponentialStops.class, layer.getLineRoundLimit().getFunction().getStops().getClass()); + assertEquals(0.5f, ((ExponentialStops) layer.getLineRoundLimit().getFunction().getStops()).getBase(), 0.001); + assertEquals(1, ((ExponentialStops) layer.getLineRoundLimit().getFunction().getStops()).size()); + } + }); } @Test @@ -254,12 +306,17 @@ public class LineLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("line-opacityTransitionOptions"); - assertNotNull(layer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); - // Set and Get - TransitionOptions options = new TransitionOptions(300, 100); - layer.setLineOpacityTransition(options); - assertEquals(layer.getLineOpacityTransition(), options); + // Set and Get + TransitionOptions options = new TransitionOptions(300, 100); + layer.setLineOpacityTransition(options); + assertEquals(layer.getLineOpacityTransition(), options); + } + }); } @Test @@ -267,11 +324,16 @@ public class LineLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("line-opacity"); - assertNotNull(layer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); - // Set and Get - layer.setProperties(lineOpacity(0.3f)); - assertEquals((Float) layer.getLineOpacity().getValue(), (Float) 0.3f); + // Set and Get + layer.setProperties(lineOpacity(0.3f)); + assertEquals((Float) layer.getLineOpacity().getValue(), (Float) 0.3f); + } + }); } @Test @@ -279,26 +341,31 @@ public class LineLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("line-opacity"); - assertNotNull(layer); - - // Set - layer.setProperties( - lineOpacity( - zoom( - exponential( - stop(2, lineOpacity(0.3f)) - ).withBase(0.5f) - ) - ) - ); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + lineOpacity( + zoom( + exponential( + stop(2, lineOpacity(0.3f)) + ).withBase(0.5f) + ) + ) + ); - // Verify - assertNotNull(layer.getLineOpacity()); - assertNotNull(layer.getLineOpacity().getFunction()); - assertEquals(CameraFunction.class, layer.getLineOpacity().getFunction().getClass()); - assertEquals(ExponentialStops.class, layer.getLineOpacity().getFunction().getStops().getClass()); - assertEquals(0.5f, ((ExponentialStops) layer.getLineOpacity().getFunction().getStops()).getBase(), 0.001); - assertEquals(1, ((ExponentialStops) layer.getLineOpacity().getFunction().getStops()).size()); + // Verify + assertNotNull(layer.getLineOpacity()); + assertNotNull(layer.getLineOpacity().getFunction()); + assertEquals(CameraFunction.class, layer.getLineOpacity().getFunction().getClass()); + assertEquals(ExponentialStops.class, layer.getLineOpacity().getFunction().getStops().getClass()); + assertEquals(0.5f, ((ExponentialStops) layer.getLineOpacity().getFunction().getStops()).getBase(), 0.001); + assertEquals(1, ((ExponentialStops) layer.getLineOpacity().getFunction().getStops()).size()); + } + }); } @Test @@ -306,19 +373,24 @@ public class LineLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("line-opacity"); - assertNotNull(layer); - - // Set - layer.setProperties( - lineOpacity(property("FeaturePropertyA", Stops.<Float>identity())) - ); - - // Verify - assertNotNull(layer.getLineOpacity()); - assertNotNull(layer.getLineOpacity().getFunction()); - assertEquals(SourceFunction.class, layer.getLineOpacity().getFunction().getClass()); - assertEquals("FeaturePropertyA", ((SourceFunction) layer.getLineOpacity().getFunction()).getProperty()); - assertEquals(IdentityStops.class, layer.getLineOpacity().getFunction().getStops().getClass()); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + lineOpacity(property("FeaturePropertyA", Stops.<Float>identity())) + ); + + // Verify + assertNotNull(layer.getLineOpacity()); + assertNotNull(layer.getLineOpacity().getFunction()); + assertEquals(SourceFunction.class, layer.getLineOpacity().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getLineOpacity().getFunction()).getProperty()); + assertEquals(IdentityStops.class, layer.getLineOpacity().getFunction().getStops().getClass()); + } + }); } @Test @@ -326,26 +398,31 @@ public class LineLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("line-opacity"); - assertNotNull(layer); - - // Set - layer.setProperties( - lineOpacity( - property( - "FeaturePropertyA", - exponential( - stop(0.3f, lineOpacity(0.3f)) - ).withBase(0.5f) - ) - ) - ); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + lineOpacity( + property( + "FeaturePropertyA", + exponential( + stop(0.3f, lineOpacity(0.3f)) + ).withBase(0.5f) + ) + ) + ); - // Verify - assertNotNull(layer.getLineOpacity()); - assertNotNull(layer.getLineOpacity().getFunction()); - assertEquals(SourceFunction.class, layer.getLineOpacity().getFunction().getClass()); - assertEquals("FeaturePropertyA", ((SourceFunction) layer.getLineOpacity().getFunction()).getProperty()); - assertEquals(ExponentialStops.class, layer.getLineOpacity().getFunction().getStops().getClass()); + // Verify + assertNotNull(layer.getLineOpacity()); + assertNotNull(layer.getLineOpacity().getFunction()); + assertEquals(SourceFunction.class, layer.getLineOpacity().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getLineOpacity().getFunction()).getProperty()); + assertEquals(ExponentialStops.class, layer.getLineOpacity().getFunction().getStops().getClass()); + } + }); } @Test @@ -353,29 +430,35 @@ public class LineLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("line-opacity"); - assertNotNull(layer); - - // Set - layer.setProperties( - lineOpacity( - property( - "FeaturePropertyA", - categorical( - stop(1.0f, lineOpacity(0.3f)) + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + lineOpacity( + property( + "FeaturePropertyA", + categorical( + stop(1.0f, lineOpacity(0.3f)) + ) + ).withDefaultValue(lineOpacity(0.3f)) ) - ).withDefaultValue(lineOpacity(0.3f)) - ) - ); + ); + + // Verify + assertNotNull(layer.getLineOpacity()); + assertNotNull(layer.getLineOpacity().getFunction()); + assertEquals(SourceFunction.class, layer.getLineOpacity().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getLineOpacity().getFunction()).getProperty()); + assertEquals(CategoricalStops.class, layer.getLineOpacity().getFunction().getStops().getClass()); + assertNotNull(((SourceFunction) layer.getLineOpacity().getFunction()).getDefaultValue()); + assertNotNull(((SourceFunction) layer.getLineOpacity().getFunction()).getDefaultValue().getValue()); + assertEquals(0.3f, ((SourceFunction) layer.getLineOpacity().getFunction()).getDefaultValue().getValue()); + } + }); - // Verify - assertNotNull(layer.getLineOpacity()); - assertNotNull(layer.getLineOpacity().getFunction()); - assertEquals(SourceFunction.class, layer.getLineOpacity().getFunction().getClass()); - assertEquals("FeaturePropertyA", ((SourceFunction) layer.getLineOpacity().getFunction()).getProperty()); - assertEquals(CategoricalStops.class, layer.getLineOpacity().getFunction().getStops().getClass()); - assertNotNull(((SourceFunction) layer.getLineOpacity().getFunction()).getDefaultValue()); - assertNotNull(((SourceFunction) layer.getLineOpacity().getFunction()).getDefaultValue().getValue()); - assertEquals(0.3f, ((SourceFunction) layer.getLineOpacity().getFunction()).getDefaultValue().getValue()); } @Test @@ -383,34 +466,39 @@ public class LineLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("line-opacity"); - assertNotNull(layer); - - // Set - layer.setProperties( - lineOpacity( - composite( - "FeaturePropertyA", - exponential( - stop(0, 0.3f, lineOpacity(0.9f)) - ).withBase(0.5f) - ).withDefaultValue(lineOpacity(0.3f)) - ) - ); - - // Verify - assertNotNull(layer.getLineOpacity()); - assertNotNull(layer.getLineOpacity().getFunction()); - assertEquals(CompositeFunction.class, layer.getLineOpacity().getFunction().getClass()); - assertEquals("FeaturePropertyA", ((CompositeFunction) layer.getLineOpacity().getFunction()).getProperty()); - assertEquals(ExponentialStops.class, layer.getLineOpacity().getFunction().getStops().getClass()); - assertEquals(1, ((ExponentialStops) layer.getLineOpacity().getFunction().getStops()).size()); - - ExponentialStops<Stop.CompositeValue<Float, Float>, Float> stops = - (ExponentialStops<Stop.CompositeValue<Float, Float>, Float>) layer.getLineOpacity().getFunction().getStops(); - Stop<Stop.CompositeValue<Float, Float>, Float> stop = stops.iterator().next(); - assertEquals(0f, stop.in.zoom, 0.001); - assertEquals(0.3f, stop.in.value, 0.001f); - assertEquals(0.9f, stop.out, 0.001f); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + lineOpacity( + composite( + "FeaturePropertyA", + exponential( + stop(0, 0.3f, lineOpacity(0.9f)) + ).withBase(0.5f) + ).withDefaultValue(lineOpacity(0.3f)) + ) + ); + + // Verify + assertNotNull(layer.getLineOpacity()); + assertNotNull(layer.getLineOpacity().getFunction()); + assertEquals(CompositeFunction.class, layer.getLineOpacity().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((CompositeFunction) layer.getLineOpacity().getFunction()).getProperty()); + assertEquals(ExponentialStops.class, layer.getLineOpacity().getFunction().getStops().getClass()); + assertEquals(1, ((ExponentialStops) layer.getLineOpacity().getFunction().getStops()).size()); + + ExponentialStops<Stop.CompositeValue<Float, Float>, Float> stops = + (ExponentialStops<Stop.CompositeValue<Float, Float>, Float>) layer.getLineOpacity().getFunction().getStops(); + Stop<Stop.CompositeValue<Float, Float>, Float> stop = stops.iterator().next(); + assertEquals(0f, stop.in.zoom, 0.001); + assertEquals(0.3f, stop.in.value, 0.001f); + assertEquals(0.9f, stop.out, 0.001f); + } + }); } @Test @@ -418,12 +506,17 @@ public class LineLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("line-colorTransitionOptions"); - assertNotNull(layer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); - // Set and Get - TransitionOptions options = new TransitionOptions(300, 100); - layer.setLineColorTransition(options); - assertEquals(layer.getLineColorTransition(), options); + // Set and Get + TransitionOptions options = new TransitionOptions(300, 100); + layer.setLineColorTransition(options); + assertEquals(layer.getLineColorTransition(), options); + } + }); } @Test @@ -431,11 +524,16 @@ public class LineLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("line-color"); - assertNotNull(layer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); - // Set and Get - layer.setProperties(lineColor("rgba(0, 0, 0, 1)")); - assertEquals((String) layer.getLineColor().getValue(), (String) "rgba(0, 0, 0, 1)"); + // Set and Get + layer.setProperties(lineColor("rgba(0, 0, 0, 1)")); + assertEquals((String) layer.getLineColor().getValue(), (String) "rgba(0, 0, 0, 1)"); + } + }); } @Test @@ -443,26 +541,31 @@ public class LineLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("line-color"); - assertNotNull(layer); - - // Set - layer.setProperties( - lineColor( - zoom( - exponential( - stop(2, lineColor("rgba(0, 0, 0, 1)")) - ).withBase(0.5f) - ) - ) - ); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + lineColor( + zoom( + exponential( + stop(2, lineColor("rgba(0, 0, 0, 1)")) + ).withBase(0.5f) + ) + ) + ); - // Verify - assertNotNull(layer.getLineColor()); - assertNotNull(layer.getLineColor().getFunction()); - assertEquals(CameraFunction.class, layer.getLineColor().getFunction().getClass()); - assertEquals(ExponentialStops.class, layer.getLineColor().getFunction().getStops().getClass()); - assertEquals(0.5f, ((ExponentialStops) layer.getLineColor().getFunction().getStops()).getBase(), 0.001); - assertEquals(1, ((ExponentialStops) layer.getLineColor().getFunction().getStops()).size()); + // Verify + assertNotNull(layer.getLineColor()); + assertNotNull(layer.getLineColor().getFunction()); + assertEquals(CameraFunction.class, layer.getLineColor().getFunction().getClass()); + assertEquals(ExponentialStops.class, layer.getLineColor().getFunction().getStops().getClass()); + assertEquals(0.5f, ((ExponentialStops) layer.getLineColor().getFunction().getStops()).getBase(), 0.001); + assertEquals(1, ((ExponentialStops) layer.getLineColor().getFunction().getStops()).size()); + } + }); } @Test @@ -470,19 +573,24 @@ public class LineLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("line-color"); - assertNotNull(layer); - - // Set - layer.setProperties( - lineColor(property("FeaturePropertyA", Stops.<String>identity())) - ); - - // Verify - assertNotNull(layer.getLineColor()); - assertNotNull(layer.getLineColor().getFunction()); - assertEquals(SourceFunction.class, layer.getLineColor().getFunction().getClass()); - assertEquals("FeaturePropertyA", ((SourceFunction) layer.getLineColor().getFunction()).getProperty()); - assertEquals(IdentityStops.class, layer.getLineColor().getFunction().getStops().getClass()); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + lineColor(property("FeaturePropertyA", Stops.<String>identity())) + ); + + // Verify + assertNotNull(layer.getLineColor()); + assertNotNull(layer.getLineColor().getFunction()); + assertEquals(SourceFunction.class, layer.getLineColor().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getLineColor().getFunction()).getProperty()); + assertEquals(IdentityStops.class, layer.getLineColor().getFunction().getStops().getClass()); + } + }); } @Test @@ -490,26 +598,31 @@ public class LineLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("line-color"); - assertNotNull(layer); - - // Set - layer.setProperties( - lineColor( - property( - "FeaturePropertyA", - exponential( - stop(Color.RED, lineColor(Color.RED)) - ).withBase(0.5f) - ) - ) - ); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + lineColor( + property( + "FeaturePropertyA", + exponential( + stop(Color.RED, lineColor(Color.RED)) + ).withBase(0.5f) + ) + ) + ); - // Verify - assertNotNull(layer.getLineColor()); - assertNotNull(layer.getLineColor().getFunction()); - assertEquals(SourceFunction.class, layer.getLineColor().getFunction().getClass()); - assertEquals("FeaturePropertyA", ((SourceFunction) layer.getLineColor().getFunction()).getProperty()); - assertEquals(ExponentialStops.class, layer.getLineColor().getFunction().getStops().getClass()); + // Verify + assertNotNull(layer.getLineColor()); + assertNotNull(layer.getLineColor().getFunction()); + assertEquals(SourceFunction.class, layer.getLineColor().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getLineColor().getFunction()).getProperty()); + assertEquals(ExponentialStops.class, layer.getLineColor().getFunction().getStops().getClass()); + } + }); } @Test @@ -517,29 +630,35 @@ public class LineLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("line-color"); - assertNotNull(layer); - - // Set - layer.setProperties( - lineColor( - property( - "FeaturePropertyA", - categorical( - stop("valueA", lineColor(Color.RED)) + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + lineColor( + property( + "FeaturePropertyA", + categorical( + stop("valueA", lineColor(Color.RED)) + ) + ).withDefaultValue(lineColor(Color.GREEN)) ) - ).withDefaultValue(lineColor(Color.GREEN)) - ) - ); + ); + + // Verify + assertNotNull(layer.getLineColor()); + assertNotNull(layer.getLineColor().getFunction()); + assertEquals(SourceFunction.class, layer.getLineColor().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getLineColor().getFunction()).getProperty()); + assertEquals(CategoricalStops.class, layer.getLineColor().getFunction().getStops().getClass()); + assertNotNull(((SourceFunction) layer.getLineColor().getFunction()).getDefaultValue()); + assertNotNull(((SourceFunction) layer.getLineColor().getFunction()).getDefaultValue().getValue()); + assertEquals(Color.GREEN, (int) ((SourceFunction) layer.getLineColor().getFunction()).getDefaultValue().getColorInt()); + } + }); - // Verify - assertNotNull(layer.getLineColor()); - assertNotNull(layer.getLineColor().getFunction()); - assertEquals(SourceFunction.class, layer.getLineColor().getFunction().getClass()); - assertEquals("FeaturePropertyA", ((SourceFunction) layer.getLineColor().getFunction()).getProperty()); - assertEquals(CategoricalStops.class, layer.getLineColor().getFunction().getStops().getClass()); - assertNotNull(((SourceFunction) layer.getLineColor().getFunction()).getDefaultValue()); - assertNotNull(((SourceFunction) layer.getLineColor().getFunction()).getDefaultValue().getValue()); - assertEquals(Color.GREEN, (int) ((SourceFunction) layer.getLineColor().getFunction()).getDefaultValue().getColorInt()); } @Test @@ -547,11 +666,16 @@ public class LineLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("line-color"); - assertNotNull(layer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); - // Set and Get - layer.setProperties(lineColor(Color.RED)); - assertEquals(layer.getLineColorAsInt(), Color.RED); + // Set and Get + layer.setProperties(lineColor(Color.RED)); + assertEquals(layer.getLineColorAsInt(), Color.RED); + } + }); } @Test @@ -559,12 +683,17 @@ public class LineLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("line-translateTransitionOptions"); - assertNotNull(layer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); - // Set and Get - TransitionOptions options = new TransitionOptions(300, 100); - layer.setLineTranslateTransition(options); - assertEquals(layer.getLineTranslateTransition(), options); + // Set and Get + TransitionOptions options = new TransitionOptions(300, 100); + layer.setLineTranslateTransition(options); + assertEquals(layer.getLineTranslateTransition(), options); + } + }); } @Test @@ -572,11 +701,16 @@ public class LineLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("line-translate"); - assertNotNull(layer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); - // Set and Get - layer.setProperties(lineTranslate(new Float[]{0f,0f})); - assertEquals((Float[]) layer.getLineTranslate().getValue(), (Float[]) new Float[]{0f,0f}); + // Set and Get + layer.setProperties(lineTranslate(new Float[] {0f, 0f})); + assertEquals((Float[]) layer.getLineTranslate().getValue(), (Float[]) new Float[] {0f, 0f}); + } + }); } @Test @@ -584,26 +718,31 @@ public class LineLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("line-translate"); - assertNotNull(layer); - - // Set - layer.setProperties( - lineTranslate( - zoom( - exponential( - stop(2, lineTranslate(new Float[]{0f,0f})) - ).withBase(0.5f) - ) - ) - ); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + lineTranslate( + zoom( + exponential( + stop(2, lineTranslate(new Float[] {0f, 0f})) + ).withBase(0.5f) + ) + ) + ); - // Verify - assertNotNull(layer.getLineTranslate()); - assertNotNull(layer.getLineTranslate().getFunction()); - assertEquals(CameraFunction.class, layer.getLineTranslate().getFunction().getClass()); - assertEquals(ExponentialStops.class, layer.getLineTranslate().getFunction().getStops().getClass()); - assertEquals(0.5f, ((ExponentialStops) layer.getLineTranslate().getFunction().getStops()).getBase(), 0.001); - assertEquals(1, ((ExponentialStops) layer.getLineTranslate().getFunction().getStops()).size()); + // Verify + assertNotNull(layer.getLineTranslate()); + assertNotNull(layer.getLineTranslate().getFunction()); + assertEquals(CameraFunction.class, layer.getLineTranslate().getFunction().getClass()); + assertEquals(ExponentialStops.class, layer.getLineTranslate().getFunction().getStops().getClass()); + assertEquals(0.5f, ((ExponentialStops) layer.getLineTranslate().getFunction().getStops()).getBase(), 0.001); + assertEquals(1, ((ExponentialStops) layer.getLineTranslate().getFunction().getStops()).size()); + } + }); } @Test @@ -611,11 +750,16 @@ public class LineLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("line-translate-anchor"); - assertNotNull(layer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); - // Set and Get - layer.setProperties(lineTranslateAnchor(LINE_TRANSLATE_ANCHOR_MAP)); - assertEquals((String) layer.getLineTranslateAnchor().getValue(), (String) LINE_TRANSLATE_ANCHOR_MAP); + // Set and Get + layer.setProperties(lineTranslateAnchor(LINE_TRANSLATE_ANCHOR_MAP)); + assertEquals((String) layer.getLineTranslateAnchor().getValue(), (String) LINE_TRANSLATE_ANCHOR_MAP); + } + }); } @Test @@ -623,25 +767,30 @@ public class LineLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("line-translate-anchor"); - assertNotNull(layer); - - // Set - layer.setProperties( - lineTranslateAnchor( - zoom( - interval( - stop(2, lineTranslateAnchor(LINE_TRANSLATE_ANCHOR_MAP)) + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + lineTranslateAnchor( + zoom( + interval( + stop(2, lineTranslateAnchor(LINE_TRANSLATE_ANCHOR_MAP)) + ) + ) ) - ) - ) - ); + ); - // Verify - assertNotNull(layer.getLineTranslateAnchor()); - assertNotNull(layer.getLineTranslateAnchor().getFunction()); - assertEquals(CameraFunction.class, layer.getLineTranslateAnchor().getFunction().getClass()); - assertEquals(IntervalStops.class, layer.getLineTranslateAnchor().getFunction().getStops().getClass()); - assertEquals(1, ((IntervalStops) layer.getLineTranslateAnchor().getFunction().getStops()).size()); + // Verify + assertNotNull(layer.getLineTranslateAnchor()); + assertNotNull(layer.getLineTranslateAnchor().getFunction()); + assertEquals(CameraFunction.class, layer.getLineTranslateAnchor().getFunction().getClass()); + assertEquals(IntervalStops.class, layer.getLineTranslateAnchor().getFunction().getStops().getClass()); + assertEquals(1, ((IntervalStops) layer.getLineTranslateAnchor().getFunction().getStops()).size()); + } + }); } @Test @@ -649,12 +798,17 @@ public class LineLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("line-widthTransitionOptions"); - assertNotNull(layer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); - // Set and Get - TransitionOptions options = new TransitionOptions(300, 100); - layer.setLineWidthTransition(options); - assertEquals(layer.getLineWidthTransition(), options); + // Set and Get + TransitionOptions options = new TransitionOptions(300, 100); + layer.setLineWidthTransition(options); + assertEquals(layer.getLineWidthTransition(), options); + } + }); } @Test @@ -662,11 +816,16 @@ public class LineLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("line-width"); - assertNotNull(layer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); - // Set and Get - layer.setProperties(lineWidth(0.3f)); - assertEquals((Float) layer.getLineWidth().getValue(), (Float) 0.3f); + // Set and Get + layer.setProperties(lineWidth(0.3f)); + assertEquals((Float) layer.getLineWidth().getValue(), (Float) 0.3f); + } + }); } @Test @@ -674,26 +833,31 @@ public class LineLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("line-width"); - assertNotNull(layer); - - // Set - layer.setProperties( - lineWidth( - zoom( - exponential( - stop(2, lineWidth(0.3f)) - ).withBase(0.5f) - ) - ) - ); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + lineWidth( + zoom( + exponential( + stop(2, lineWidth(0.3f)) + ).withBase(0.5f) + ) + ) + ); - // Verify - assertNotNull(layer.getLineWidth()); - assertNotNull(layer.getLineWidth().getFunction()); - assertEquals(CameraFunction.class, layer.getLineWidth().getFunction().getClass()); - assertEquals(ExponentialStops.class, layer.getLineWidth().getFunction().getStops().getClass()); - assertEquals(0.5f, ((ExponentialStops) layer.getLineWidth().getFunction().getStops()).getBase(), 0.001); - assertEquals(1, ((ExponentialStops) layer.getLineWidth().getFunction().getStops()).size()); + // Verify + assertNotNull(layer.getLineWidth()); + assertNotNull(layer.getLineWidth().getFunction()); + assertEquals(CameraFunction.class, layer.getLineWidth().getFunction().getClass()); + assertEquals(ExponentialStops.class, layer.getLineWidth().getFunction().getStops().getClass()); + assertEquals(0.5f, ((ExponentialStops) layer.getLineWidth().getFunction().getStops()).getBase(), 0.001); + assertEquals(1, ((ExponentialStops) layer.getLineWidth().getFunction().getStops()).size()); + } + }); } @Test @@ -813,12 +977,17 @@ public class LineLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("line-gap-widthTransitionOptions"); - assertNotNull(layer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); - // Set and Get - TransitionOptions options = new TransitionOptions(300, 100); - layer.setLineGapWidthTransition(options); - assertEquals(layer.getLineGapWidthTransition(), options); + // Set and Get + TransitionOptions options = new TransitionOptions(300, 100); + layer.setLineGapWidthTransition(options); + assertEquals(layer.getLineGapWidthTransition(), options); + } + }); } @Test @@ -826,11 +995,16 @@ public class LineLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("line-gap-width"); - assertNotNull(layer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); - // Set and Get - layer.setProperties(lineGapWidth(0.3f)); - assertEquals((Float) layer.getLineGapWidth().getValue(), (Float) 0.3f); + // Set and Get + layer.setProperties(lineGapWidth(0.3f)); + assertEquals((Float) layer.getLineGapWidth().getValue(), (Float) 0.3f); + } + }); } @Test @@ -838,26 +1012,31 @@ public class LineLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("line-gap-width"); - assertNotNull(layer); - - // Set - layer.setProperties( - lineGapWidth( - zoom( - exponential( - stop(2, lineGapWidth(0.3f)) - ).withBase(0.5f) - ) - ) - ); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + lineGapWidth( + zoom( + exponential( + stop(2, lineGapWidth(0.3f)) + ).withBase(0.5f) + ) + ) + ); - // Verify - assertNotNull(layer.getLineGapWidth()); - assertNotNull(layer.getLineGapWidth().getFunction()); - assertEquals(CameraFunction.class, layer.getLineGapWidth().getFunction().getClass()); - assertEquals(ExponentialStops.class, layer.getLineGapWidth().getFunction().getStops().getClass()); - assertEquals(0.5f, ((ExponentialStops) layer.getLineGapWidth().getFunction().getStops()).getBase(), 0.001); - assertEquals(1, ((ExponentialStops) layer.getLineGapWidth().getFunction().getStops()).size()); + // Verify + assertNotNull(layer.getLineGapWidth()); + assertNotNull(layer.getLineGapWidth().getFunction()); + assertEquals(CameraFunction.class, layer.getLineGapWidth().getFunction().getClass()); + assertEquals(ExponentialStops.class, layer.getLineGapWidth().getFunction().getStops().getClass()); + assertEquals(0.5f, ((ExponentialStops) layer.getLineGapWidth().getFunction().getStops()).getBase(), 0.001); + assertEquals(1, ((ExponentialStops) layer.getLineGapWidth().getFunction().getStops()).size()); + } + }); } @Test @@ -865,19 +1044,24 @@ public class LineLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("line-gap-width"); - assertNotNull(layer); - - // Set - layer.setProperties( - lineGapWidth(property("FeaturePropertyA", Stops.<Float>identity())) - ); - - // Verify - assertNotNull(layer.getLineGapWidth()); - assertNotNull(layer.getLineGapWidth().getFunction()); - assertEquals(SourceFunction.class, layer.getLineGapWidth().getFunction().getClass()); - assertEquals("FeaturePropertyA", ((SourceFunction) layer.getLineGapWidth().getFunction()).getProperty()); - assertEquals(IdentityStops.class, layer.getLineGapWidth().getFunction().getStops().getClass()); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + lineGapWidth(property("FeaturePropertyA", Stops.<Float>identity())) + ); + + // Verify + assertNotNull(layer.getLineGapWidth()); + assertNotNull(layer.getLineGapWidth().getFunction()); + assertEquals(SourceFunction.class, layer.getLineGapWidth().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getLineGapWidth().getFunction()).getProperty()); + assertEquals(IdentityStops.class, layer.getLineGapWidth().getFunction().getStops().getClass()); + } + }); } @Test @@ -885,26 +1069,31 @@ public class LineLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("line-gap-width"); - assertNotNull(layer); - - // Set - layer.setProperties( - lineGapWidth( - property( - "FeaturePropertyA", - exponential( - stop(0.3f, lineGapWidth(0.3f)) - ).withBase(0.5f) - ) - ) - ); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + lineGapWidth( + property( + "FeaturePropertyA", + exponential( + stop(0.3f, lineGapWidth(0.3f)) + ).withBase(0.5f) + ) + ) + ); - // Verify - assertNotNull(layer.getLineGapWidth()); - assertNotNull(layer.getLineGapWidth().getFunction()); - assertEquals(SourceFunction.class, layer.getLineGapWidth().getFunction().getClass()); - assertEquals("FeaturePropertyA", ((SourceFunction) layer.getLineGapWidth().getFunction()).getProperty()); - assertEquals(ExponentialStops.class, layer.getLineGapWidth().getFunction().getStops().getClass()); + // Verify + assertNotNull(layer.getLineGapWidth()); + assertNotNull(layer.getLineGapWidth().getFunction()); + assertEquals(SourceFunction.class, layer.getLineGapWidth().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getLineGapWidth().getFunction()).getProperty()); + assertEquals(ExponentialStops.class, layer.getLineGapWidth().getFunction().getStops().getClass()); + } + }); } @Test @@ -912,29 +1101,35 @@ public class LineLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("line-gap-width"); - assertNotNull(layer); - - // Set - layer.setProperties( - lineGapWidth( - property( - "FeaturePropertyA", - categorical( - stop(1.0f, lineGapWidth(0.3f)) + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + lineGapWidth( + property( + "FeaturePropertyA", + categorical( + stop(1.0f, lineGapWidth(0.3f)) + ) + ).withDefaultValue(lineGapWidth(0.3f)) ) - ).withDefaultValue(lineGapWidth(0.3f)) - ) - ); + ); + + // Verify + assertNotNull(layer.getLineGapWidth()); + assertNotNull(layer.getLineGapWidth().getFunction()); + assertEquals(SourceFunction.class, layer.getLineGapWidth().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getLineGapWidth().getFunction()).getProperty()); + assertEquals(CategoricalStops.class, layer.getLineGapWidth().getFunction().getStops().getClass()); + assertNotNull(((SourceFunction) layer.getLineGapWidth().getFunction()).getDefaultValue()); + assertNotNull(((SourceFunction) layer.getLineGapWidth().getFunction()).getDefaultValue().getValue()); + assertEquals(0.3f, ((SourceFunction) layer.getLineGapWidth().getFunction()).getDefaultValue().getValue()); + } + }); - // Verify - assertNotNull(layer.getLineGapWidth()); - assertNotNull(layer.getLineGapWidth().getFunction()); - assertEquals(SourceFunction.class, layer.getLineGapWidth().getFunction().getClass()); - assertEquals("FeaturePropertyA", ((SourceFunction) layer.getLineGapWidth().getFunction()).getProperty()); - assertEquals(CategoricalStops.class, layer.getLineGapWidth().getFunction().getStops().getClass()); - assertNotNull(((SourceFunction) layer.getLineGapWidth().getFunction()).getDefaultValue()); - assertNotNull(((SourceFunction) layer.getLineGapWidth().getFunction()).getDefaultValue().getValue()); - assertEquals(0.3f, ((SourceFunction) layer.getLineGapWidth().getFunction()).getDefaultValue().getValue()); } @Test @@ -942,34 +1137,39 @@ public class LineLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("line-gap-width"); - assertNotNull(layer); - - // Set - layer.setProperties( - lineGapWidth( - composite( - "FeaturePropertyA", - exponential( - stop(0, 0.3f, lineGapWidth(0.9f)) - ).withBase(0.5f) - ).withDefaultValue(lineGapWidth(0.3f)) - ) - ); - - // Verify - assertNotNull(layer.getLineGapWidth()); - assertNotNull(layer.getLineGapWidth().getFunction()); - assertEquals(CompositeFunction.class, layer.getLineGapWidth().getFunction().getClass()); - assertEquals("FeaturePropertyA", ((CompositeFunction) layer.getLineGapWidth().getFunction()).getProperty()); - assertEquals(ExponentialStops.class, layer.getLineGapWidth().getFunction().getStops().getClass()); - assertEquals(1, ((ExponentialStops) layer.getLineGapWidth().getFunction().getStops()).size()); - - ExponentialStops<Stop.CompositeValue<Float, Float>, Float> stops = - (ExponentialStops<Stop.CompositeValue<Float, Float>, Float>) layer.getLineGapWidth().getFunction().getStops(); - Stop<Stop.CompositeValue<Float, Float>, Float> stop = stops.iterator().next(); - assertEquals(0f, stop.in.zoom, 0.001); - assertEquals(0.3f, stop.in.value, 0.001f); - assertEquals(0.9f, stop.out, 0.001f); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + lineGapWidth( + composite( + "FeaturePropertyA", + exponential( + stop(0, 0.3f, lineGapWidth(0.9f)) + ).withBase(0.5f) + ).withDefaultValue(lineGapWidth(0.3f)) + ) + ); + + // Verify + assertNotNull(layer.getLineGapWidth()); + assertNotNull(layer.getLineGapWidth().getFunction()); + assertEquals(CompositeFunction.class, layer.getLineGapWidth().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((CompositeFunction) layer.getLineGapWidth().getFunction()).getProperty()); + assertEquals(ExponentialStops.class, layer.getLineGapWidth().getFunction().getStops().getClass()); + assertEquals(1, ((ExponentialStops) layer.getLineGapWidth().getFunction().getStops()).size()); + + ExponentialStops<Stop.CompositeValue<Float, Float>, Float> stops = + (ExponentialStops<Stop.CompositeValue<Float, Float>, Float>) layer.getLineGapWidth().getFunction().getStops(); + Stop<Stop.CompositeValue<Float, Float>, Float> stop = stops.iterator().next(); + assertEquals(0f, stop.in.zoom, 0.001); + assertEquals(0.3f, stop.in.value, 0.001f); + assertEquals(0.9f, stop.out, 0.001f); + } + }); } @Test @@ -977,12 +1177,17 @@ public class LineLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("line-offsetTransitionOptions"); - assertNotNull(layer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); - // Set and Get - TransitionOptions options = new TransitionOptions(300, 100); - layer.setLineOffsetTransition(options); - assertEquals(layer.getLineOffsetTransition(), options); + // Set and Get + TransitionOptions options = new TransitionOptions(300, 100); + layer.setLineOffsetTransition(options); + assertEquals(layer.getLineOffsetTransition(), options); + } + }); } @Test @@ -990,11 +1195,16 @@ public class LineLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("line-offset"); - assertNotNull(layer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); - // Set and Get - layer.setProperties(lineOffset(0.3f)); - assertEquals((Float) layer.getLineOffset().getValue(), (Float) 0.3f); + // Set and Get + layer.setProperties(lineOffset(0.3f)); + assertEquals((Float) layer.getLineOffset().getValue(), (Float) 0.3f); + } + }); } @Test @@ -1002,26 +1212,31 @@ public class LineLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("line-offset"); - assertNotNull(layer); - - // Set - layer.setProperties( - lineOffset( - zoom( - exponential( - stop(2, lineOffset(0.3f)) - ).withBase(0.5f) - ) - ) - ); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + lineOffset( + zoom( + exponential( + stop(2, lineOffset(0.3f)) + ).withBase(0.5f) + ) + ) + ); - // Verify - assertNotNull(layer.getLineOffset()); - assertNotNull(layer.getLineOffset().getFunction()); - assertEquals(CameraFunction.class, layer.getLineOffset().getFunction().getClass()); - assertEquals(ExponentialStops.class, layer.getLineOffset().getFunction().getStops().getClass()); - assertEquals(0.5f, ((ExponentialStops) layer.getLineOffset().getFunction().getStops()).getBase(), 0.001); - assertEquals(1, ((ExponentialStops) layer.getLineOffset().getFunction().getStops()).size()); + // Verify + assertNotNull(layer.getLineOffset()); + assertNotNull(layer.getLineOffset().getFunction()); + assertEquals(CameraFunction.class, layer.getLineOffset().getFunction().getClass()); + assertEquals(ExponentialStops.class, layer.getLineOffset().getFunction().getStops().getClass()); + assertEquals(0.5f, ((ExponentialStops) layer.getLineOffset().getFunction().getStops()).getBase(), 0.001); + assertEquals(1, ((ExponentialStops) layer.getLineOffset().getFunction().getStops()).size()); + } + }); } @Test @@ -1029,19 +1244,24 @@ public class LineLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("line-offset"); - assertNotNull(layer); - - // Set - layer.setProperties( - lineOffset(property("FeaturePropertyA", Stops.<Float>identity())) - ); - - // Verify - assertNotNull(layer.getLineOffset()); - assertNotNull(layer.getLineOffset().getFunction()); - assertEquals(SourceFunction.class, layer.getLineOffset().getFunction().getClass()); - assertEquals("FeaturePropertyA", ((SourceFunction) layer.getLineOffset().getFunction()).getProperty()); - assertEquals(IdentityStops.class, layer.getLineOffset().getFunction().getStops().getClass()); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + lineOffset(property("FeaturePropertyA", Stops.<Float>identity())) + ); + + // Verify + assertNotNull(layer.getLineOffset()); + assertNotNull(layer.getLineOffset().getFunction()); + assertEquals(SourceFunction.class, layer.getLineOffset().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getLineOffset().getFunction()).getProperty()); + assertEquals(IdentityStops.class, layer.getLineOffset().getFunction().getStops().getClass()); + } + }); } @Test @@ -1049,26 +1269,31 @@ public class LineLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("line-offset"); - assertNotNull(layer); - - // Set - layer.setProperties( - lineOffset( - property( - "FeaturePropertyA", - exponential( - stop(0.3f, lineOffset(0.3f)) - ).withBase(0.5f) - ) - ) - ); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + lineOffset( + property( + "FeaturePropertyA", + exponential( + stop(0.3f, lineOffset(0.3f)) + ).withBase(0.5f) + ) + ) + ); - // Verify - assertNotNull(layer.getLineOffset()); - assertNotNull(layer.getLineOffset().getFunction()); - assertEquals(SourceFunction.class, layer.getLineOffset().getFunction().getClass()); - assertEquals("FeaturePropertyA", ((SourceFunction) layer.getLineOffset().getFunction()).getProperty()); - assertEquals(ExponentialStops.class, layer.getLineOffset().getFunction().getStops().getClass()); + // Verify + assertNotNull(layer.getLineOffset()); + assertNotNull(layer.getLineOffset().getFunction()); + assertEquals(SourceFunction.class, layer.getLineOffset().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getLineOffset().getFunction()).getProperty()); + assertEquals(ExponentialStops.class, layer.getLineOffset().getFunction().getStops().getClass()); + } + }); } @Test @@ -1076,29 +1301,35 @@ public class LineLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("line-offset"); - assertNotNull(layer); - - // Set - layer.setProperties( - lineOffset( - property( - "FeaturePropertyA", - categorical( - stop(1.0f, lineOffset(0.3f)) + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + lineOffset( + property( + "FeaturePropertyA", + categorical( + stop(1.0f, lineOffset(0.3f)) + ) + ).withDefaultValue(lineOffset(0.3f)) ) - ).withDefaultValue(lineOffset(0.3f)) - ) - ); + ); + + // Verify + assertNotNull(layer.getLineOffset()); + assertNotNull(layer.getLineOffset().getFunction()); + assertEquals(SourceFunction.class, layer.getLineOffset().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getLineOffset().getFunction()).getProperty()); + assertEquals(CategoricalStops.class, layer.getLineOffset().getFunction().getStops().getClass()); + assertNotNull(((SourceFunction) layer.getLineOffset().getFunction()).getDefaultValue()); + assertNotNull(((SourceFunction) layer.getLineOffset().getFunction()).getDefaultValue().getValue()); + assertEquals(0.3f, ((SourceFunction) layer.getLineOffset().getFunction()).getDefaultValue().getValue()); + } + }); - // Verify - assertNotNull(layer.getLineOffset()); - assertNotNull(layer.getLineOffset().getFunction()); - assertEquals(SourceFunction.class, layer.getLineOffset().getFunction().getClass()); - assertEquals("FeaturePropertyA", ((SourceFunction) layer.getLineOffset().getFunction()).getProperty()); - assertEquals(CategoricalStops.class, layer.getLineOffset().getFunction().getStops().getClass()); - assertNotNull(((SourceFunction) layer.getLineOffset().getFunction()).getDefaultValue()); - assertNotNull(((SourceFunction) layer.getLineOffset().getFunction()).getDefaultValue().getValue()); - assertEquals(0.3f, ((SourceFunction) layer.getLineOffset().getFunction()).getDefaultValue().getValue()); } @Test @@ -1106,34 +1337,39 @@ public class LineLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("line-offset"); - assertNotNull(layer); - - // Set - layer.setProperties( - lineOffset( - composite( - "FeaturePropertyA", - exponential( - stop(0, 0.3f, lineOffset(0.9f)) - ).withBase(0.5f) - ).withDefaultValue(lineOffset(0.3f)) - ) - ); - - // Verify - assertNotNull(layer.getLineOffset()); - assertNotNull(layer.getLineOffset().getFunction()); - assertEquals(CompositeFunction.class, layer.getLineOffset().getFunction().getClass()); - assertEquals("FeaturePropertyA", ((CompositeFunction) layer.getLineOffset().getFunction()).getProperty()); - assertEquals(ExponentialStops.class, layer.getLineOffset().getFunction().getStops().getClass()); - assertEquals(1, ((ExponentialStops) layer.getLineOffset().getFunction().getStops()).size()); - - ExponentialStops<Stop.CompositeValue<Float, Float>, Float> stops = - (ExponentialStops<Stop.CompositeValue<Float, Float>, Float>) layer.getLineOffset().getFunction().getStops(); - Stop<Stop.CompositeValue<Float, Float>, Float> stop = stops.iterator().next(); - assertEquals(0f, stop.in.zoom, 0.001); - assertEquals(0.3f, stop.in.value, 0.001f); - assertEquals(0.9f, stop.out, 0.001f); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + lineOffset( + composite( + "FeaturePropertyA", + exponential( + stop(0, 0.3f, lineOffset(0.9f)) + ).withBase(0.5f) + ).withDefaultValue(lineOffset(0.3f)) + ) + ); + + // Verify + assertNotNull(layer.getLineOffset()); + assertNotNull(layer.getLineOffset().getFunction()); + assertEquals(CompositeFunction.class, layer.getLineOffset().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((CompositeFunction) layer.getLineOffset().getFunction()).getProperty()); + assertEquals(ExponentialStops.class, layer.getLineOffset().getFunction().getStops().getClass()); + assertEquals(1, ((ExponentialStops) layer.getLineOffset().getFunction().getStops()).size()); + + ExponentialStops<Stop.CompositeValue<Float, Float>, Float> stops = + (ExponentialStops<Stop.CompositeValue<Float, Float>, Float>) layer.getLineOffset().getFunction().getStops(); + Stop<Stop.CompositeValue<Float, Float>, Float> stop = stops.iterator().next(); + assertEquals(0f, stop.in.zoom, 0.001); + assertEquals(0.3f, stop.in.value, 0.001f); + assertEquals(0.9f, stop.out, 0.001f); + } + }); } @Test @@ -1141,12 +1377,17 @@ public class LineLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("line-blurTransitionOptions"); - assertNotNull(layer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); - // Set and Get - TransitionOptions options = new TransitionOptions(300, 100); - layer.setLineBlurTransition(options); - assertEquals(layer.getLineBlurTransition(), options); + // Set and Get + TransitionOptions options = new TransitionOptions(300, 100); + layer.setLineBlurTransition(options); + assertEquals(layer.getLineBlurTransition(), options); + } + }); } @Test @@ -1154,11 +1395,16 @@ public class LineLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("line-blur"); - assertNotNull(layer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); - // Set and Get - layer.setProperties(lineBlur(0.3f)); - assertEquals((Float) layer.getLineBlur().getValue(), (Float) 0.3f); + // Set and Get + layer.setProperties(lineBlur(0.3f)); + assertEquals((Float) layer.getLineBlur().getValue(), (Float) 0.3f); + } + }); } @Test @@ -1166,26 +1412,31 @@ public class LineLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("line-blur"); - assertNotNull(layer); - - // Set - layer.setProperties( - lineBlur( - zoom( - exponential( - stop(2, lineBlur(0.3f)) - ).withBase(0.5f) - ) - ) - ); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + lineBlur( + zoom( + exponential( + stop(2, lineBlur(0.3f)) + ).withBase(0.5f) + ) + ) + ); - // Verify - assertNotNull(layer.getLineBlur()); - assertNotNull(layer.getLineBlur().getFunction()); - assertEquals(CameraFunction.class, layer.getLineBlur().getFunction().getClass()); - assertEquals(ExponentialStops.class, layer.getLineBlur().getFunction().getStops().getClass()); - assertEquals(0.5f, ((ExponentialStops) layer.getLineBlur().getFunction().getStops()).getBase(), 0.001); - assertEquals(1, ((ExponentialStops) layer.getLineBlur().getFunction().getStops()).size()); + // Verify + assertNotNull(layer.getLineBlur()); + assertNotNull(layer.getLineBlur().getFunction()); + assertEquals(CameraFunction.class, layer.getLineBlur().getFunction().getClass()); + assertEquals(ExponentialStops.class, layer.getLineBlur().getFunction().getStops().getClass()); + assertEquals(0.5f, ((ExponentialStops) layer.getLineBlur().getFunction().getStops()).getBase(), 0.001); + assertEquals(1, ((ExponentialStops) layer.getLineBlur().getFunction().getStops()).size()); + } + }); } @Test @@ -1193,19 +1444,24 @@ public class LineLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("line-blur"); - assertNotNull(layer); - - // Set - layer.setProperties( - lineBlur(property("FeaturePropertyA", Stops.<Float>identity())) - ); - - // Verify - assertNotNull(layer.getLineBlur()); - assertNotNull(layer.getLineBlur().getFunction()); - assertEquals(SourceFunction.class, layer.getLineBlur().getFunction().getClass()); - assertEquals("FeaturePropertyA", ((SourceFunction) layer.getLineBlur().getFunction()).getProperty()); - assertEquals(IdentityStops.class, layer.getLineBlur().getFunction().getStops().getClass()); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + lineBlur(property("FeaturePropertyA", Stops.<Float>identity())) + ); + + // Verify + assertNotNull(layer.getLineBlur()); + assertNotNull(layer.getLineBlur().getFunction()); + assertEquals(SourceFunction.class, layer.getLineBlur().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getLineBlur().getFunction()).getProperty()); + assertEquals(IdentityStops.class, layer.getLineBlur().getFunction().getStops().getClass()); + } + }); } @Test @@ -1213,26 +1469,31 @@ public class LineLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("line-blur"); - assertNotNull(layer); - - // Set - layer.setProperties( - lineBlur( - property( - "FeaturePropertyA", - exponential( - stop(0.3f, lineBlur(0.3f)) - ).withBase(0.5f) - ) - ) - ); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + lineBlur( + property( + "FeaturePropertyA", + exponential( + stop(0.3f, lineBlur(0.3f)) + ).withBase(0.5f) + ) + ) + ); - // Verify - assertNotNull(layer.getLineBlur()); - assertNotNull(layer.getLineBlur().getFunction()); - assertEquals(SourceFunction.class, layer.getLineBlur().getFunction().getClass()); - assertEquals("FeaturePropertyA", ((SourceFunction) layer.getLineBlur().getFunction()).getProperty()); - assertEquals(ExponentialStops.class, layer.getLineBlur().getFunction().getStops().getClass()); + // Verify + assertNotNull(layer.getLineBlur()); + assertNotNull(layer.getLineBlur().getFunction()); + assertEquals(SourceFunction.class, layer.getLineBlur().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getLineBlur().getFunction()).getProperty()); + assertEquals(ExponentialStops.class, layer.getLineBlur().getFunction().getStops().getClass()); + } + }); } @Test @@ -1240,29 +1501,35 @@ public class LineLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("line-blur"); - assertNotNull(layer); - - // Set - layer.setProperties( - lineBlur( - property( - "FeaturePropertyA", - categorical( - stop(1.0f, lineBlur(0.3f)) + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + lineBlur( + property( + "FeaturePropertyA", + categorical( + stop(1.0f, lineBlur(0.3f)) + ) + ).withDefaultValue(lineBlur(0.3f)) ) - ).withDefaultValue(lineBlur(0.3f)) - ) - ); + ); + + // Verify + assertNotNull(layer.getLineBlur()); + assertNotNull(layer.getLineBlur().getFunction()); + assertEquals(SourceFunction.class, layer.getLineBlur().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getLineBlur().getFunction()).getProperty()); + assertEquals(CategoricalStops.class, layer.getLineBlur().getFunction().getStops().getClass()); + assertNotNull(((SourceFunction) layer.getLineBlur().getFunction()).getDefaultValue()); + assertNotNull(((SourceFunction) layer.getLineBlur().getFunction()).getDefaultValue().getValue()); + assertEquals(0.3f, ((SourceFunction) layer.getLineBlur().getFunction()).getDefaultValue().getValue()); + } + }); - // Verify - assertNotNull(layer.getLineBlur()); - assertNotNull(layer.getLineBlur().getFunction()); - assertEquals(SourceFunction.class, layer.getLineBlur().getFunction().getClass()); - assertEquals("FeaturePropertyA", ((SourceFunction) layer.getLineBlur().getFunction()).getProperty()); - assertEquals(CategoricalStops.class, layer.getLineBlur().getFunction().getStops().getClass()); - assertNotNull(((SourceFunction) layer.getLineBlur().getFunction()).getDefaultValue()); - assertNotNull(((SourceFunction) layer.getLineBlur().getFunction()).getDefaultValue().getValue()); - assertEquals(0.3f, ((SourceFunction) layer.getLineBlur().getFunction()).getDefaultValue().getValue()); } @Test @@ -1270,34 +1537,39 @@ public class LineLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("line-blur"); - assertNotNull(layer); - - // Set - layer.setProperties( - lineBlur( - composite( - "FeaturePropertyA", - exponential( - stop(0, 0.3f, lineBlur(0.9f)) - ).withBase(0.5f) - ).withDefaultValue(lineBlur(0.3f)) - ) - ); - - // Verify - assertNotNull(layer.getLineBlur()); - assertNotNull(layer.getLineBlur().getFunction()); - assertEquals(CompositeFunction.class, layer.getLineBlur().getFunction().getClass()); - assertEquals("FeaturePropertyA", ((CompositeFunction) layer.getLineBlur().getFunction()).getProperty()); - assertEquals(ExponentialStops.class, layer.getLineBlur().getFunction().getStops().getClass()); - assertEquals(1, ((ExponentialStops) layer.getLineBlur().getFunction().getStops()).size()); - - ExponentialStops<Stop.CompositeValue<Float, Float>, Float> stops = - (ExponentialStops<Stop.CompositeValue<Float, Float>, Float>) layer.getLineBlur().getFunction().getStops(); - Stop<Stop.CompositeValue<Float, Float>, Float> stop = stops.iterator().next(); - assertEquals(0f, stop.in.zoom, 0.001); - assertEquals(0.3f, stop.in.value, 0.001f); - assertEquals(0.9f, stop.out, 0.001f); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + lineBlur( + composite( + "FeaturePropertyA", + exponential( + stop(0, 0.3f, lineBlur(0.9f)) + ).withBase(0.5f) + ).withDefaultValue(lineBlur(0.3f)) + ) + ); + + // Verify + assertNotNull(layer.getLineBlur()); + assertNotNull(layer.getLineBlur().getFunction()); + assertEquals(CompositeFunction.class, layer.getLineBlur().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((CompositeFunction) layer.getLineBlur().getFunction()).getProperty()); + assertEquals(ExponentialStops.class, layer.getLineBlur().getFunction().getStops().getClass()); + assertEquals(1, ((ExponentialStops) layer.getLineBlur().getFunction().getStops()).size()); + + ExponentialStops<Stop.CompositeValue<Float, Float>, Float> stops = + (ExponentialStops<Stop.CompositeValue<Float, Float>, Float>) layer.getLineBlur().getFunction().getStops(); + Stop<Stop.CompositeValue<Float, Float>, Float> stop = stops.iterator().next(); + assertEquals(0f, stop.in.zoom, 0.001); + assertEquals(0.3f, stop.in.value, 0.001f); + assertEquals(0.9f, stop.out, 0.001f); + } + }); } @Test @@ -1305,12 +1577,17 @@ public class LineLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("line-dasharrayTransitionOptions"); - assertNotNull(layer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); - // Set and Get - TransitionOptions options = new TransitionOptions(300, 100); - layer.setLineDasharrayTransition(options); - assertEquals(layer.getLineDasharrayTransition(), options); + // Set and Get + TransitionOptions options = new TransitionOptions(300, 100); + layer.setLineDasharrayTransition(options); + assertEquals(layer.getLineDasharrayTransition(), options); + } + }); } @Test @@ -1318,11 +1595,16 @@ public class LineLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("line-dasharray"); - assertNotNull(layer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); - // Set and Get - layer.setProperties(lineDasharray(new Float[]{})); - assertEquals((Float[]) layer.getLineDasharray().getValue(), (Float[]) new Float[]{}); + // Set and Get + layer.setProperties(lineDasharray(new Float[] {})); + assertEquals((Float[]) layer.getLineDasharray().getValue(), (Float[]) new Float[] {}); + } + }); } @Test @@ -1330,25 +1612,30 @@ public class LineLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("line-dasharray"); - assertNotNull(layer); - - // Set - layer.setProperties( - lineDasharray( - zoom( - interval( - stop(2, lineDasharray(new Float[]{})) + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + lineDasharray( + zoom( + interval( + stop(2, lineDasharray(new Float[] {})) + ) + ) ) - ) - ) - ); + ); - // Verify - assertNotNull(layer.getLineDasharray()); - assertNotNull(layer.getLineDasharray().getFunction()); - assertEquals(CameraFunction.class, layer.getLineDasharray().getFunction().getClass()); - assertEquals(IntervalStops.class, layer.getLineDasharray().getFunction().getStops().getClass()); - assertEquals(1, ((IntervalStops) layer.getLineDasharray().getFunction().getStops()).size()); + // Verify + assertNotNull(layer.getLineDasharray()); + assertNotNull(layer.getLineDasharray().getFunction()); + assertEquals(CameraFunction.class, layer.getLineDasharray().getFunction().getClass()); + assertEquals(IntervalStops.class, layer.getLineDasharray().getFunction().getStops().getClass()); + assertEquals(1, ((IntervalStops) layer.getLineDasharray().getFunction().getStops()).size()); + } + }); } @Test @@ -1356,12 +1643,17 @@ public class LineLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("line-patternTransitionOptions"); - assertNotNull(layer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); - // Set and Get - TransitionOptions options = new TransitionOptions(300, 100); - layer.setLinePatternTransition(options); - assertEquals(layer.getLinePatternTransition(), options); + // Set and Get + TransitionOptions options = new TransitionOptions(300, 100); + layer.setLinePatternTransition(options); + assertEquals(layer.getLinePatternTransition(), options); + } + }); } @Test @@ -1369,11 +1661,16 @@ public class LineLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("line-pattern"); - assertNotNull(layer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); - // Set and Get - layer.setProperties(linePattern("pedestrian-polygon")); - assertEquals((String) layer.getLinePattern().getValue(), (String) "pedestrian-polygon"); + // Set and Get + layer.setProperties(linePattern("pedestrian-polygon")); + assertEquals((String) layer.getLinePattern().getValue(), (String) "pedestrian-polygon"); + } + }); } @Test @@ -1381,25 +1678,30 @@ public class LineLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("line-pattern"); - assertNotNull(layer); - - // Set - layer.setProperties( - linePattern( - zoom( - interval( - stop(2, linePattern("pedestrian-polygon")) + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + linePattern( + zoom( + interval( + stop(2, linePattern("pedestrian-polygon")) + ) + ) ) - ) - ) - ); - - // Verify - assertNotNull(layer.getLinePattern()); - assertNotNull(layer.getLinePattern().getFunction()); - assertEquals(CameraFunction.class, layer.getLinePattern().getFunction().getClass()); - assertEquals(IntervalStops.class, layer.getLinePattern().getFunction().getStops().getClass()); - assertEquals(1, ((IntervalStops) layer.getLinePattern().getFunction().getStops()).size()); + ); + + // Verify + assertNotNull(layer.getLinePattern()); + assertNotNull(layer.getLinePattern().getFunction()); + assertEquals(CameraFunction.class, layer.getLinePattern().getFunction().getClass()); + assertEquals(IntervalStops.class, layer.getLinePattern().getFunction().getStops().getClass()); + assertEquals(1, ((IntervalStops) layer.getLinePattern().getFunction().getStops()).size()); + } + }); } } diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/RasterLayerTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/RasterLayerTest.java index 2a0d3401fb..020effe331 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/RasterLayerTest.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/RasterLayerTest.java @@ -3,9 +3,9 @@ package com.mapbox.mapboxsdk.testapp.style; import android.graphics.Color; -import android.support.test.espresso.Espresso; -import android.support.test.rule.ActivityTestRule; +import android.support.test.espresso.UiController; import android.support.test.runner.AndroidJUnit4; + import timber.log.Timber; import com.mapbox.mapboxsdk.maps.MapboxMap; @@ -19,20 +19,16 @@ import com.mapbox.mapboxsdk.style.functions.stops.IntervalStops; import com.mapbox.mapboxsdk.style.functions.stops.Stop; import com.mapbox.mapboxsdk.style.functions.stops.Stops; import com.mapbox.mapboxsdk.style.layers.RasterLayer; -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.action.MapboxMapAction; import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest; -import org.junit.After; -import org.junit.Before; -import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; import static com.mapbox.mapboxsdk.style.functions.Function.*; import static com.mapbox.mapboxsdk.style.functions.stops.Stop.stop; import static com.mapbox.mapboxsdk.style.functions.stops.Stops.*; +import static com.mapbox.mapboxsdk.testapp.action.MapboxMapAction.invoke; import static org.junit.Assert.*; import static com.mapbox.mapboxsdk.style.layers.Property.*; import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*; @@ -53,15 +49,21 @@ public class RasterLayerTest extends BaseActivityTest { return EspressoTestActivity.class; } - private void setupLayer(){ - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new RasterLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - // Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } + private void setupLayer() { + Timber.i("Retrieving layer"); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new RasterLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + // Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); + } + } + }); } @Test @@ -69,14 +71,19 @@ public class RasterLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("Visibility"); - assertNotNull(layer); - - // Get initial - assertEquals(layer.getVisibility().getValue(), VISIBLE); - - // Set - layer.setProperties(visibility(NONE)); - assertEquals(layer.getVisibility().getValue(), NONE); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Get initial + assertEquals(layer.getVisibility().getValue(), VISIBLE); + + // Set + layer.setProperties(visibility(NONE)); + assertEquals(layer.getVisibility().getValue(), NONE); + } + }); } @Test @@ -84,12 +91,17 @@ public class RasterLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("raster-opacityTransitionOptions"); - assertNotNull(layer); - - // Set and Get - TransitionOptions options = new TransitionOptions(300, 100); - layer.setRasterOpacityTransition(options); - assertEquals(layer.getRasterOpacityTransition(), options); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set and Get + TransitionOptions options = new TransitionOptions(300, 100); + layer.setRasterOpacityTransition(options); + assertEquals(layer.getRasterOpacityTransition(), options); + } + }); } @Test @@ -97,11 +109,16 @@ public class RasterLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("raster-opacity"); - assertNotNull(layer); - - // Set and Get - layer.setProperties(rasterOpacity(0.3f)); - assertEquals((Float) layer.getRasterOpacity().getValue(), (Float) 0.3f); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set and Get + layer.setProperties(rasterOpacity(0.3f)); + assertEquals((Float) layer.getRasterOpacity().getValue(), (Float) 0.3f); + } + }); } @Test @@ -109,26 +126,31 @@ public class RasterLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("raster-opacity"); - assertNotNull(layer); - - // Set - layer.setProperties( - rasterOpacity( - zoom( - exponential( - stop(2, rasterOpacity(0.3f)) - ).withBase(0.5f) - ) - ) - ); - - // Verify - assertNotNull(layer.getRasterOpacity()); - assertNotNull(layer.getRasterOpacity().getFunction()); - assertEquals(CameraFunction.class, layer.getRasterOpacity().getFunction().getClass()); - assertEquals(ExponentialStops.class, layer.getRasterOpacity().getFunction().getStops().getClass()); - assertEquals(0.5f, ((ExponentialStops) layer.getRasterOpacity().getFunction().getStops()).getBase(), 0.001); - assertEquals(1, ((ExponentialStops) layer.getRasterOpacity().getFunction().getStops()).size()); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + rasterOpacity( + zoom( + exponential( + stop(2, rasterOpacity(0.3f)) + ).withBase(0.5f) + ) + ) + ); + + // Verify + assertNotNull(layer.getRasterOpacity()); + assertNotNull(layer.getRasterOpacity().getFunction()); + assertEquals(CameraFunction.class, layer.getRasterOpacity().getFunction().getClass()); + assertEquals(ExponentialStops.class, layer.getRasterOpacity().getFunction().getStops().getClass()); + assertEquals(0.5f, ((ExponentialStops) layer.getRasterOpacity().getFunction().getStops()).getBase(), 0.001); + assertEquals(1, ((ExponentialStops) layer.getRasterOpacity().getFunction().getStops()).size()); + } + }); } @Test @@ -136,12 +158,17 @@ public class RasterLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("raster-hue-rotateTransitionOptions"); - assertNotNull(layer); - - // Set and Get - TransitionOptions options = new TransitionOptions(300, 100); - layer.setRasterHueRotateTransition(options); - assertEquals(layer.getRasterHueRotateTransition(), options); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set and Get + TransitionOptions options = new TransitionOptions(300, 100); + layer.setRasterHueRotateTransition(options); + assertEquals(layer.getRasterHueRotateTransition(), options); + } + }); } @Test @@ -149,11 +176,16 @@ public class RasterLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("raster-hue-rotate"); - assertNotNull(layer); - - // Set and Get - layer.setProperties(rasterHueRotate(0.3f)); - assertEquals((Float) layer.getRasterHueRotate().getValue(), (Float) 0.3f); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set and Get + layer.setProperties(rasterHueRotate(0.3f)); + assertEquals((Float) layer.getRasterHueRotate().getValue(), (Float) 0.3f); + } + }); } @Test @@ -161,26 +193,31 @@ public class RasterLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("raster-hue-rotate"); - assertNotNull(layer); - - // Set - layer.setProperties( - rasterHueRotate( - zoom( - exponential( - stop(2, rasterHueRotate(0.3f)) - ).withBase(0.5f) - ) - ) - ); - - // Verify - assertNotNull(layer.getRasterHueRotate()); - assertNotNull(layer.getRasterHueRotate().getFunction()); - assertEquals(CameraFunction.class, layer.getRasterHueRotate().getFunction().getClass()); - assertEquals(ExponentialStops.class, layer.getRasterHueRotate().getFunction().getStops().getClass()); - assertEquals(0.5f, ((ExponentialStops) layer.getRasterHueRotate().getFunction().getStops()).getBase(), 0.001); - assertEquals(1, ((ExponentialStops) layer.getRasterHueRotate().getFunction().getStops()).size()); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + rasterHueRotate( + zoom( + exponential( + stop(2, rasterHueRotate(0.3f)) + ).withBase(0.5f) + ) + ) + ); + + // Verify + assertNotNull(layer.getRasterHueRotate()); + assertNotNull(layer.getRasterHueRotate().getFunction()); + assertEquals(CameraFunction.class, layer.getRasterHueRotate().getFunction().getClass()); + assertEquals(ExponentialStops.class, layer.getRasterHueRotate().getFunction().getStops().getClass()); + assertEquals(0.5f, ((ExponentialStops) layer.getRasterHueRotate().getFunction().getStops()).getBase(), 0.001); + assertEquals(1, ((ExponentialStops) layer.getRasterHueRotate().getFunction().getStops()).size()); + } + }); } @Test @@ -188,12 +225,17 @@ public class RasterLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("raster-brightness-minTransitionOptions"); - assertNotNull(layer); - - // Set and Get - TransitionOptions options = new TransitionOptions(300, 100); - layer.setRasterBrightnessMinTransition(options); - assertEquals(layer.getRasterBrightnessMinTransition(), options); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set and Get + TransitionOptions options = new TransitionOptions(300, 100); + layer.setRasterBrightnessMinTransition(options); + assertEquals(layer.getRasterBrightnessMinTransition(), options); + } + }); } @Test @@ -201,11 +243,16 @@ public class RasterLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("raster-brightness-min"); - assertNotNull(layer); - - // Set and Get - layer.setProperties(rasterBrightnessMin(0.3f)); - assertEquals((Float) layer.getRasterBrightnessMin().getValue(), (Float) 0.3f); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set and Get + layer.setProperties(rasterBrightnessMin(0.3f)); + assertEquals((Float) layer.getRasterBrightnessMin().getValue(), (Float) 0.3f); + } + }); } @Test @@ -213,26 +260,31 @@ public class RasterLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("raster-brightness-min"); - assertNotNull(layer); - - // Set - layer.setProperties( - rasterBrightnessMin( - zoom( - exponential( - stop(2, rasterBrightnessMin(0.3f)) - ).withBase(0.5f) - ) - ) - ); - - // Verify - assertNotNull(layer.getRasterBrightnessMin()); - assertNotNull(layer.getRasterBrightnessMin().getFunction()); - assertEquals(CameraFunction.class, layer.getRasterBrightnessMin().getFunction().getClass()); - assertEquals(ExponentialStops.class, layer.getRasterBrightnessMin().getFunction().getStops().getClass()); - assertEquals(0.5f, ((ExponentialStops) layer.getRasterBrightnessMin().getFunction().getStops()).getBase(), 0.001); - assertEquals(1, ((ExponentialStops) layer.getRasterBrightnessMin().getFunction().getStops()).size()); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + rasterBrightnessMin( + zoom( + exponential( + stop(2, rasterBrightnessMin(0.3f)) + ).withBase(0.5f) + ) + ) + ); + + // Verify + assertNotNull(layer.getRasterBrightnessMin()); + assertNotNull(layer.getRasterBrightnessMin().getFunction()); + assertEquals(CameraFunction.class, layer.getRasterBrightnessMin().getFunction().getClass()); + assertEquals(ExponentialStops.class, layer.getRasterBrightnessMin().getFunction().getStops().getClass()); + assertEquals(0.5f, ((ExponentialStops) layer.getRasterBrightnessMin().getFunction().getStops()).getBase(), 0.001); + assertEquals(1, ((ExponentialStops) layer.getRasterBrightnessMin().getFunction().getStops()).size()); + } + }); } @Test @@ -240,12 +292,17 @@ public class RasterLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("raster-brightness-maxTransitionOptions"); - assertNotNull(layer); - - // Set and Get - TransitionOptions options = new TransitionOptions(300, 100); - layer.setRasterBrightnessMaxTransition(options); - assertEquals(layer.getRasterBrightnessMaxTransition(), options); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set and Get + TransitionOptions options = new TransitionOptions(300, 100); + layer.setRasterBrightnessMaxTransition(options); + assertEquals(layer.getRasterBrightnessMaxTransition(), options); + } + }); } @Test @@ -253,11 +310,16 @@ public class RasterLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("raster-brightness-max"); - assertNotNull(layer); - - // Set and Get - layer.setProperties(rasterBrightnessMax(0.3f)); - assertEquals((Float) layer.getRasterBrightnessMax().getValue(), (Float) 0.3f); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set and Get + layer.setProperties(rasterBrightnessMax(0.3f)); + assertEquals((Float) layer.getRasterBrightnessMax().getValue(), (Float) 0.3f); + } + }); } @Test @@ -265,26 +327,31 @@ public class RasterLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("raster-brightness-max"); - assertNotNull(layer); - - // Set - layer.setProperties( - rasterBrightnessMax( - zoom( - exponential( - stop(2, rasterBrightnessMax(0.3f)) - ).withBase(0.5f) - ) - ) - ); - - // Verify - assertNotNull(layer.getRasterBrightnessMax()); - assertNotNull(layer.getRasterBrightnessMax().getFunction()); - assertEquals(CameraFunction.class, layer.getRasterBrightnessMax().getFunction().getClass()); - assertEquals(ExponentialStops.class, layer.getRasterBrightnessMax().getFunction().getStops().getClass()); - assertEquals(0.5f, ((ExponentialStops) layer.getRasterBrightnessMax().getFunction().getStops()).getBase(), 0.001); - assertEquals(1, ((ExponentialStops) layer.getRasterBrightnessMax().getFunction().getStops()).size()); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + rasterBrightnessMax( + zoom( + exponential( + stop(2, rasterBrightnessMax(0.3f)) + ).withBase(0.5f) + ) + ) + ); + + // Verify + assertNotNull(layer.getRasterBrightnessMax()); + assertNotNull(layer.getRasterBrightnessMax().getFunction()); + assertEquals(CameraFunction.class, layer.getRasterBrightnessMax().getFunction().getClass()); + assertEquals(ExponentialStops.class, layer.getRasterBrightnessMax().getFunction().getStops().getClass()); + assertEquals(0.5f, ((ExponentialStops) layer.getRasterBrightnessMax().getFunction().getStops()).getBase(), 0.001); + assertEquals(1, ((ExponentialStops) layer.getRasterBrightnessMax().getFunction().getStops()).size()); + } + }); } @Test @@ -292,12 +359,17 @@ public class RasterLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("raster-saturationTransitionOptions"); - assertNotNull(layer); - - // Set and Get - TransitionOptions options = new TransitionOptions(300, 100); - layer.setRasterSaturationTransition(options); - assertEquals(layer.getRasterSaturationTransition(), options); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set and Get + TransitionOptions options = new TransitionOptions(300, 100); + layer.setRasterSaturationTransition(options); + assertEquals(layer.getRasterSaturationTransition(), options); + } + }); } @Test @@ -305,11 +377,16 @@ public class RasterLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("raster-saturation"); - assertNotNull(layer); - - // Set and Get - layer.setProperties(rasterSaturation(0.3f)); - assertEquals((Float) layer.getRasterSaturation().getValue(), (Float) 0.3f); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set and Get + layer.setProperties(rasterSaturation(0.3f)); + assertEquals((Float) layer.getRasterSaturation().getValue(), (Float) 0.3f); + } + }); } @Test @@ -317,26 +394,31 @@ public class RasterLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("raster-saturation"); - assertNotNull(layer); - - // Set - layer.setProperties( - rasterSaturation( - zoom( - exponential( - stop(2, rasterSaturation(0.3f)) - ).withBase(0.5f) - ) - ) - ); - - // Verify - assertNotNull(layer.getRasterSaturation()); - assertNotNull(layer.getRasterSaturation().getFunction()); - assertEquals(CameraFunction.class, layer.getRasterSaturation().getFunction().getClass()); - assertEquals(ExponentialStops.class, layer.getRasterSaturation().getFunction().getStops().getClass()); - assertEquals(0.5f, ((ExponentialStops) layer.getRasterSaturation().getFunction().getStops()).getBase(), 0.001); - assertEquals(1, ((ExponentialStops) layer.getRasterSaturation().getFunction().getStops()).size()); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + rasterSaturation( + zoom( + exponential( + stop(2, rasterSaturation(0.3f)) + ).withBase(0.5f) + ) + ) + ); + + // Verify + assertNotNull(layer.getRasterSaturation()); + assertNotNull(layer.getRasterSaturation().getFunction()); + assertEquals(CameraFunction.class, layer.getRasterSaturation().getFunction().getClass()); + assertEquals(ExponentialStops.class, layer.getRasterSaturation().getFunction().getStops().getClass()); + assertEquals(0.5f, ((ExponentialStops) layer.getRasterSaturation().getFunction().getStops()).getBase(), 0.001); + assertEquals(1, ((ExponentialStops) layer.getRasterSaturation().getFunction().getStops()).size()); + } + }); } @Test @@ -344,12 +426,17 @@ public class RasterLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("raster-contrastTransitionOptions"); - assertNotNull(layer); - - // Set and Get - TransitionOptions options = new TransitionOptions(300, 100); - layer.setRasterContrastTransition(options); - assertEquals(layer.getRasterContrastTransition(), options); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set and Get + TransitionOptions options = new TransitionOptions(300, 100); + layer.setRasterContrastTransition(options); + assertEquals(layer.getRasterContrastTransition(), options); + } + }); } @Test @@ -357,11 +444,16 @@ public class RasterLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("raster-contrast"); - assertNotNull(layer); - - // Set and Get - layer.setProperties(rasterContrast(0.3f)); - assertEquals((Float) layer.getRasterContrast().getValue(), (Float) 0.3f); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set and Get + layer.setProperties(rasterContrast(0.3f)); + assertEquals((Float) layer.getRasterContrast().getValue(), (Float) 0.3f); + } + }); } @Test @@ -369,26 +461,31 @@ public class RasterLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("raster-contrast"); - assertNotNull(layer); - - // Set - layer.setProperties( - rasterContrast( - zoom( - exponential( - stop(2, rasterContrast(0.3f)) - ).withBase(0.5f) - ) - ) - ); - - // Verify - assertNotNull(layer.getRasterContrast()); - assertNotNull(layer.getRasterContrast().getFunction()); - assertEquals(CameraFunction.class, layer.getRasterContrast().getFunction().getClass()); - assertEquals(ExponentialStops.class, layer.getRasterContrast().getFunction().getStops().getClass()); - assertEquals(0.5f, ((ExponentialStops) layer.getRasterContrast().getFunction().getStops()).getBase(), 0.001); - assertEquals(1, ((ExponentialStops) layer.getRasterContrast().getFunction().getStops()).size()); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + rasterContrast( + zoom( + exponential( + stop(2, rasterContrast(0.3f)) + ).withBase(0.5f) + ) + ) + ); + + // Verify + assertNotNull(layer.getRasterContrast()); + assertNotNull(layer.getRasterContrast().getFunction()); + assertEquals(CameraFunction.class, layer.getRasterContrast().getFunction().getClass()); + assertEquals(ExponentialStops.class, layer.getRasterContrast().getFunction().getStops().getClass()); + assertEquals(0.5f, ((ExponentialStops) layer.getRasterContrast().getFunction().getStops()).getBase(), 0.001); + assertEquals(1, ((ExponentialStops) layer.getRasterContrast().getFunction().getStops()).size()); + } + }); } @Test @@ -396,12 +493,17 @@ public class RasterLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("raster-fade-durationTransitionOptions"); - assertNotNull(layer); - - // Set and Get - TransitionOptions options = new TransitionOptions(300, 100); - layer.setRasterFadeDurationTransition(options); - assertEquals(layer.getRasterFadeDurationTransition(), options); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set and Get + TransitionOptions options = new TransitionOptions(300, 100); + layer.setRasterFadeDurationTransition(options); + assertEquals(layer.getRasterFadeDurationTransition(), options); + } + }); } @Test @@ -409,11 +511,16 @@ public class RasterLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("raster-fade-duration"); - assertNotNull(layer); - - // Set and Get - layer.setProperties(rasterFadeDuration(0.3f)); - assertEquals((Float) layer.getRasterFadeDuration().getValue(), (Float) 0.3f); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set and Get + layer.setProperties(rasterFadeDuration(0.3f)); + assertEquals((Float) layer.getRasterFadeDuration().getValue(), (Float) 0.3f); + } + }); } @Test @@ -421,26 +528,31 @@ public class RasterLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("raster-fade-duration"); - assertNotNull(layer); - - // Set - layer.setProperties( - rasterFadeDuration( - zoom( - exponential( - stop(2, rasterFadeDuration(0.3f)) - ).withBase(0.5f) - ) - ) - ); - - // Verify - assertNotNull(layer.getRasterFadeDuration()); - assertNotNull(layer.getRasterFadeDuration().getFunction()); - assertEquals(CameraFunction.class, layer.getRasterFadeDuration().getFunction().getClass()); - assertEquals(ExponentialStops.class, layer.getRasterFadeDuration().getFunction().getStops().getClass()); - assertEquals(0.5f, ((ExponentialStops) layer.getRasterFadeDuration().getFunction().getStops()).getBase(), 0.001); - assertEquals(1, ((ExponentialStops) layer.getRasterFadeDuration().getFunction().getStops()).size()); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + rasterFadeDuration( + zoom( + exponential( + stop(2, rasterFadeDuration(0.3f)) + ).withBase(0.5f) + ) + ) + ); + + // Verify + assertNotNull(layer.getRasterFadeDuration()); + assertNotNull(layer.getRasterFadeDuration().getFunction()); + assertEquals(CameraFunction.class, layer.getRasterFadeDuration().getFunction().getClass()); + assertEquals(ExponentialStops.class, layer.getRasterFadeDuration().getFunction().getStops().getClass()); + assertEquals(0.5f, ((ExponentialStops) layer.getRasterFadeDuration().getFunction().getStops()).getBase(), 0.001); + assertEquals(1, ((ExponentialStops) layer.getRasterFadeDuration().getFunction().getStops()).size()); + } + }); } } diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/RuntimeStyleBackgroundLayerTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/RuntimeStyleBackgroundLayerTest.java deleted file mode 100644 index c95c959644..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/RuntimeStyleBackgroundLayerTest.java +++ /dev/null @@ -1,61 +0,0 @@ -package com.mapbox.mapboxsdk.testapp.style; - -import android.support.test.InstrumentationRegistry; -import android.support.test.runner.AndroidJUnit4; -import android.test.ActivityInstrumentationTestCase2; - -import timber.log.Timber; - -import com.mapbox.mapboxsdk.maps.MapboxMap; -import com.mapbox.mapboxsdk.maps.OnMapReadyCallback; -import com.mapbox.mapboxsdk.style.layers.BackgroundLayer; -import com.mapbox.mapboxsdk.style.layers.Property; -import com.mapbox.mapboxsdk.style.layers.PropertyFactory; -import com.mapbox.mapboxsdk.testapp.activity.style.RuntimeStyleTestActivity; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; - -/** - * Basic smoke tests for BackgroundLayer - */ -@RunWith(AndroidJUnit4.class) -public class RuntimeStyleBackgroundLayerTest - extends ActivityInstrumentationTestCase2<RuntimeStyleTestActivity> { - - public RuntimeStyleBackgroundLayerTest() { - super(RuntimeStyleTestActivity.class); - } - - @Before - public void setUp() throws Exception { - super.setUp(); - injectInstrumentation(InstrumentationRegistry.getInstrumentation()); - } - - @Test - public void testSetVisibility() { - getActivity().mapView.getMapAsync(new OnMapReadyCallback() { - @Override - public void onMapReady(MapboxMap mapboxMap) { - Timber.i("visibility"); - BackgroundLayer layer = mapboxMap.getLayerAs("background"); - assertNotNull(layer); - - // Get initial - assertEquals(layer.getVisibility().getValue(), Property.VISIBLE); - - // Set - layer.setProperties(PropertyFactory.visibility(Property.NONE)); - assertEquals(layer.getVisibility().getValue(), Property.NONE); - } - }); - } - - @After - public void tearDown() throws Exception { - super.tearDown(); - } -} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/RuntimeStyleTests.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/RuntimeStyleTests.java index f1e2a6c418..bf8bcb9f66 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/RuntimeStyleTests.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/RuntimeStyleTests.java @@ -8,6 +8,7 @@ import android.support.test.espresso.ViewAction; import android.support.test.runner.AndroidJUnit4; import android.view.View; +import com.mapbox.mapboxsdk.maps.MapboxMap; import com.mapbox.mapboxsdk.style.layers.CannotAddLayerException; import com.mapbox.mapboxsdk.style.layers.CircleLayer; import com.mapbox.mapboxsdk.style.layers.FillLayer; @@ -21,6 +22,7 @@ import com.mapbox.mapboxsdk.style.sources.RasterSource; import com.mapbox.mapboxsdk.style.sources.Source; import com.mapbox.mapboxsdk.style.sources.VectorSource; import com.mapbox.mapboxsdk.testapp.R; +import com.mapbox.mapboxsdk.testapp.action.MapboxMapAction; import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest; import com.mapbox.mapboxsdk.testapp.activity.style.RuntimeStyleTestActivity; @@ -40,6 +42,7 @@ import timber.log.Timber; 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 com.mapbox.mapboxsdk.testapp.action.MapboxMapAction.invoke; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; @@ -189,63 +192,88 @@ public class RuntimeStyleTests extends BaseActivityTest { @Test public void testAddRemoveSource() { validateTestSetup(); - mapboxMap.addSource(new VectorSource("my-source", "mapbox://mapbox.mapbox-terrain-v2")); - mapboxMap.removeSource("my-source"); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + mapboxMap.addSource(new VectorSource("my-source", "mapbox://mapbox.mapbox-terrain-v2")); + mapboxMap.removeSource("my-source"); + + // Add initial source + mapboxMap.addSource(new VectorSource("my-source", "mapbox://mapbox.mapbox-terrain-v2")); + + // Remove + Source mySource = mapboxMap.removeSource("my-source"); + assertNotNull(mySource); + assertNull(mapboxMap.getLayer("my-source")); + + // Add + Source source = new VectorSource("my-source", "mapbox://mapbox.mapbox-terrain-v2"); + mapboxMap.addSource(source); + + // Remove, preserving the reference + mapboxMap.removeSource(source); + + // Re-add the reference... + mapboxMap.addSource(source); + + // Ensure it's there + Assert.assertNotNull(mapboxMap.getSource(source.getId())); + + // Test adding a duplicate source + try { + Source source2 = new VectorSource("my-source", "mapbox://mapbox.mapbox-terrain-v2"); + mapboxMap.addSource(source2); + fail("Should not have been allowed to add a source with a duplicate id"); + } catch (CannotAddSourceException cannotAddSourceException) { + // OK + } + } + }); - onView(withId(R.id.mapView)).perform(new AddRemoveSourceAction()); } @Test public void testVectorSourceUrlGetter() { validateTestSetup(); - - onView(withId(R.id.mapView)).perform(new BaseViewAction() { - + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { @Override - public void perform(UiController uiController, View view) { + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { VectorSource source = new VectorSource("my-source", "mapbox://mapbox.mapbox-terrain-v2"); mapboxMap.addSource(source); assertEquals("mapbox://mapbox.mapbox-terrain-v2", source.getUrl()); } - }); } @Test public void testRasterSourceUrlGetter() { validateTestSetup(); - - onView(withId(R.id.mapView)).perform(new BaseViewAction() { - + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { @Override - public void perform(UiController uiController, View view) { + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { RasterSource source = new RasterSource("my-source", "mapbox://mapbox.mapbox-terrain-v2"); mapboxMap.addSource(source); assertEquals("mapbox://mapbox.mapbox-terrain-v2", source.getUrl()); } - }); } @Test - public void testGeoJsonSourceUrlGetter() { + public void testGeoJsonSourceUrlGetter() throws MalformedURLException { validateTestSetup(); - - onView(withId(R.id.mapView)).perform(new BaseViewAction() { - + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { @Override - public void perform(UiController uiController, View view) { + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { GeoJsonSource source = new GeoJsonSource("my-source"); mapboxMap.addSource(source); assertNull(source.getUrl()); try { source.setUrl(new URL("http://mapbox.com/my-file.json")); - } catch (MalformedURLException err) { - assertTrue(err.getMessage(), false); + } catch (MalformedURLException exception) { + fail(); } assertEquals("http://mapbox.com/my-file.json", source.getUrl()); } - }); } @@ -329,42 +357,6 @@ public class RuntimeStyleTests extends BaseActivityTest { } } - private class AddRemoveSourceAction extends BaseViewAction { - - @Override - public void perform(UiController uiController, View view) { - // Add initial source - mapboxMap.addSource(new VectorSource("my-source", "mapbox://mapbox.mapbox-terrain-v2")); - - // Remove - Source mySource = mapboxMap.removeSource("my-source"); - assertNotNull(mySource); - assertNull(mapboxMap.getLayer("my-source")); - - // Add - Source source = new VectorSource("my-source", "mapbox://mapbox.mapbox-terrain-v2"); - mapboxMap.addSource(source); - - // Remove, preserving the reference - mapboxMap.removeSource(source); - - // Re-add the reference... - mapboxMap.addSource(source); - - // Ensure it's there - Assert.assertNotNull(mapboxMap.getSource(source.getId())); - - // Test adding a duplicate source - try { - Source source2 = new VectorSource("my-source", "mapbox://mapbox.mapbox-terrain-v2"); - mapboxMap.addSource(source2); - fail("Should not have been allowed to add a source with a duplicate id"); - } catch (CannotAddSourceException cannotAddSourceException) { - // OK - } - } - } - @After public void unregisterIntentServiceIdlingResource() { Espresso.unregisterIdlingResources(idlingResource); diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/SymbolLayerTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/SymbolLayerTest.java index 737a66713a..b0854f4a47 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/SymbolLayerTest.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/SymbolLayerTest.java @@ -3,9 +3,9 @@ package com.mapbox.mapboxsdk.testapp.style; import android.graphics.Color; -import android.support.test.espresso.Espresso; -import android.support.test.rule.ActivityTestRule; +import android.support.test.espresso.UiController; import android.support.test.runner.AndroidJUnit4; + import timber.log.Timber; import com.mapbox.mapboxsdk.maps.MapboxMap; @@ -19,20 +19,16 @@ import com.mapbox.mapboxsdk.style.functions.stops.IntervalStops; import com.mapbox.mapboxsdk.style.functions.stops.Stop; import com.mapbox.mapboxsdk.style.functions.stops.Stops; import com.mapbox.mapboxsdk.style.layers.SymbolLayer; -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.action.MapboxMapAction; import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest; -import org.junit.After; -import org.junit.Before; -import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; import static com.mapbox.mapboxsdk.style.functions.Function.*; import static com.mapbox.mapboxsdk.style.functions.stops.Stop.stop; import static com.mapbox.mapboxsdk.style.functions.stops.Stops.*; +import static com.mapbox.mapboxsdk.testapp.action.MapboxMapAction.invoke; import static org.junit.Assert.*; import static com.mapbox.mapboxsdk.style.layers.Property.*; import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*; @@ -53,15 +49,21 @@ public class SymbolLayerTest extends BaseActivityTest { return EspressoTestActivity.class; } - private void setupLayer(){ - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - // Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } + private void setupLayer() { + Timber.i("Retrieving layer"); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new SymbolLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + // Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); + } + } + }); } @Test @@ -69,14 +71,19 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("Visibility"); - assertNotNull(layer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); - // Get initial - assertEquals(layer.getVisibility().getValue(), VISIBLE); + // Get initial + assertEquals(layer.getVisibility().getValue(), VISIBLE); - // Set - layer.setProperties(visibility(NONE)); - assertEquals(layer.getVisibility().getValue(), NONE); + // Set + layer.setProperties(visibility(NONE)); + assertEquals(layer.getVisibility().getValue(), NONE); + } + }); } @Test @@ -84,15 +91,20 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("SourceLayer"); - assertNotNull(layer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); - // Get initial - assertEquals(layer.getSourceLayer(), "composite"); + // Get initial + assertEquals(layer.getSourceLayer(), "composite"); - // Set - final String sourceLayer = "test"; - layer.setSourceLayer(sourceLayer); - assertEquals(layer.getSourceLayer(), sourceLayer); + // Set + final String sourceLayer = "test"; + layer.setSourceLayer(sourceLayer); + assertEquals(layer.getSourceLayer(), sourceLayer); + } + }); } @Test @@ -100,11 +112,16 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("symbol-placement"); - assertNotNull(layer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); - // Set and Get - layer.setProperties(symbolPlacement(SYMBOL_PLACEMENT_POINT)); - assertEquals((String) layer.getSymbolPlacement().getValue(), (String) SYMBOL_PLACEMENT_POINT); + // Set and Get + layer.setProperties(symbolPlacement(SYMBOL_PLACEMENT_POINT)); + assertEquals((String) layer.getSymbolPlacement().getValue(), (String) SYMBOL_PLACEMENT_POINT); + } + }); } @Test @@ -112,25 +129,30 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("symbol-placement"); - assertNotNull(layer); - - // Set - layer.setProperties( - symbolPlacement( - zoom( - interval( - stop(2, symbolPlacement(SYMBOL_PLACEMENT_POINT)) + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + symbolPlacement( + zoom( + interval( + stop(2, symbolPlacement(SYMBOL_PLACEMENT_POINT)) + ) + ) ) - ) - ) - ); + ); - // Verify - assertNotNull(layer.getSymbolPlacement()); - assertNotNull(layer.getSymbolPlacement().getFunction()); - assertEquals(CameraFunction.class, layer.getSymbolPlacement().getFunction().getClass()); - assertEquals(IntervalStops.class, layer.getSymbolPlacement().getFunction().getStops().getClass()); - assertEquals(1, ((IntervalStops) layer.getSymbolPlacement().getFunction().getStops()).size()); + // Verify + assertNotNull(layer.getSymbolPlacement()); + assertNotNull(layer.getSymbolPlacement().getFunction()); + assertEquals(CameraFunction.class, layer.getSymbolPlacement().getFunction().getClass()); + assertEquals(IntervalStops.class, layer.getSymbolPlacement().getFunction().getStops().getClass()); + assertEquals(1, ((IntervalStops) layer.getSymbolPlacement().getFunction().getStops()).size()); + } + }); } @Test @@ -138,11 +160,16 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("symbol-spacing"); - assertNotNull(layer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); - // Set and Get - layer.setProperties(symbolSpacing(0.3f)); - assertEquals((Float) layer.getSymbolSpacing().getValue(), (Float) 0.3f); + // Set and Get + layer.setProperties(symbolSpacing(0.3f)); + assertEquals((Float) layer.getSymbolSpacing().getValue(), (Float) 0.3f); + } + }); } @Test @@ -150,26 +177,31 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("symbol-spacing"); - assertNotNull(layer); - - // Set - layer.setProperties( - symbolSpacing( - zoom( - exponential( - stop(2, symbolSpacing(0.3f)) - ).withBase(0.5f) - ) - ) - ); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + symbolSpacing( + zoom( + exponential( + stop(2, symbolSpacing(0.3f)) + ).withBase(0.5f) + ) + ) + ); - // Verify - assertNotNull(layer.getSymbolSpacing()); - assertNotNull(layer.getSymbolSpacing().getFunction()); - assertEquals(CameraFunction.class, layer.getSymbolSpacing().getFunction().getClass()); - assertEquals(ExponentialStops.class, layer.getSymbolSpacing().getFunction().getStops().getClass()); - assertEquals(0.5f, ((ExponentialStops) layer.getSymbolSpacing().getFunction().getStops()).getBase(), 0.001); - assertEquals(1, ((ExponentialStops) layer.getSymbolSpacing().getFunction().getStops()).size()); + // Verify + assertNotNull(layer.getSymbolSpacing()); + assertNotNull(layer.getSymbolSpacing().getFunction()); + assertEquals(CameraFunction.class, layer.getSymbolSpacing().getFunction().getClass()); + assertEquals(ExponentialStops.class, layer.getSymbolSpacing().getFunction().getStops().getClass()); + assertEquals(0.5f, ((ExponentialStops) layer.getSymbolSpacing().getFunction().getStops()).getBase(), 0.001); + assertEquals(1, ((ExponentialStops) layer.getSymbolSpacing().getFunction().getStops()).size()); + } + }); } @Test @@ -177,11 +209,16 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("symbol-avoid-edges"); - assertNotNull(layer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); - // Set and Get - layer.setProperties(symbolAvoidEdges(true)); - assertEquals((Boolean) layer.getSymbolAvoidEdges().getValue(), (Boolean) true); + // Set and Get + layer.setProperties(symbolAvoidEdges(true)); + assertEquals((Boolean) layer.getSymbolAvoidEdges().getValue(), (Boolean) true); + } + }); } @Test @@ -189,25 +226,30 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("symbol-avoid-edges"); - assertNotNull(layer); - - // Set - layer.setProperties( - symbolAvoidEdges( - zoom( - interval( - stop(2, symbolAvoidEdges(true)) + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + symbolAvoidEdges( + zoom( + interval( + stop(2, symbolAvoidEdges(true)) + ) + ) ) - ) - ) - ); + ); - // Verify - assertNotNull(layer.getSymbolAvoidEdges()); - assertNotNull(layer.getSymbolAvoidEdges().getFunction()); - assertEquals(CameraFunction.class, layer.getSymbolAvoidEdges().getFunction().getClass()); - assertEquals(IntervalStops.class, layer.getSymbolAvoidEdges().getFunction().getStops().getClass()); - assertEquals(1, ((IntervalStops) layer.getSymbolAvoidEdges().getFunction().getStops()).size()); + // Verify + assertNotNull(layer.getSymbolAvoidEdges()); + assertNotNull(layer.getSymbolAvoidEdges().getFunction()); + assertEquals(CameraFunction.class, layer.getSymbolAvoidEdges().getFunction().getClass()); + assertEquals(IntervalStops.class, layer.getSymbolAvoidEdges().getFunction().getStops().getClass()); + assertEquals(1, ((IntervalStops) layer.getSymbolAvoidEdges().getFunction().getStops()).size()); + } + }); } @Test @@ -215,11 +257,16 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("icon-allow-overlap"); - assertNotNull(layer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); - // Set and Get - layer.setProperties(iconAllowOverlap(true)); - assertEquals((Boolean) layer.getIconAllowOverlap().getValue(), (Boolean) true); + // Set and Get + layer.setProperties(iconAllowOverlap(true)); + assertEquals((Boolean) layer.getIconAllowOverlap().getValue(), (Boolean) true); + } + }); } @Test @@ -227,25 +274,30 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("icon-allow-overlap"); - assertNotNull(layer); - - // Set - layer.setProperties( - iconAllowOverlap( - zoom( - interval( - stop(2, iconAllowOverlap(true)) + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + iconAllowOverlap( + zoom( + interval( + stop(2, iconAllowOverlap(true)) + ) + ) ) - ) - ) - ); + ); - // Verify - assertNotNull(layer.getIconAllowOverlap()); - assertNotNull(layer.getIconAllowOverlap().getFunction()); - assertEquals(CameraFunction.class, layer.getIconAllowOverlap().getFunction().getClass()); - assertEquals(IntervalStops.class, layer.getIconAllowOverlap().getFunction().getStops().getClass()); - assertEquals(1, ((IntervalStops) layer.getIconAllowOverlap().getFunction().getStops()).size()); + // Verify + assertNotNull(layer.getIconAllowOverlap()); + assertNotNull(layer.getIconAllowOverlap().getFunction()); + assertEquals(CameraFunction.class, layer.getIconAllowOverlap().getFunction().getClass()); + assertEquals(IntervalStops.class, layer.getIconAllowOverlap().getFunction().getStops().getClass()); + assertEquals(1, ((IntervalStops) layer.getIconAllowOverlap().getFunction().getStops()).size()); + } + }); } @Test @@ -253,11 +305,16 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("icon-ignore-placement"); - assertNotNull(layer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); - // Set and Get - layer.setProperties(iconIgnorePlacement(true)); - assertEquals((Boolean) layer.getIconIgnorePlacement().getValue(), (Boolean) true); + // Set and Get + layer.setProperties(iconIgnorePlacement(true)); + assertEquals((Boolean) layer.getIconIgnorePlacement().getValue(), (Boolean) true); + } + }); } @Test @@ -265,25 +322,30 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("icon-ignore-placement"); - assertNotNull(layer); - - // Set - layer.setProperties( - iconIgnorePlacement( - zoom( - interval( - stop(2, iconIgnorePlacement(true)) + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + iconIgnorePlacement( + zoom( + interval( + stop(2, iconIgnorePlacement(true)) + ) + ) ) - ) - ) - ); + ); - // Verify - assertNotNull(layer.getIconIgnorePlacement()); - assertNotNull(layer.getIconIgnorePlacement().getFunction()); - assertEquals(CameraFunction.class, layer.getIconIgnorePlacement().getFunction().getClass()); - assertEquals(IntervalStops.class, layer.getIconIgnorePlacement().getFunction().getStops().getClass()); - assertEquals(1, ((IntervalStops) layer.getIconIgnorePlacement().getFunction().getStops()).size()); + // Verify + assertNotNull(layer.getIconIgnorePlacement()); + assertNotNull(layer.getIconIgnorePlacement().getFunction()); + assertEquals(CameraFunction.class, layer.getIconIgnorePlacement().getFunction().getClass()); + assertEquals(IntervalStops.class, layer.getIconIgnorePlacement().getFunction().getStops().getClass()); + assertEquals(1, ((IntervalStops) layer.getIconIgnorePlacement().getFunction().getStops()).size()); + } + }); } @Test @@ -291,11 +353,16 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("icon-optional"); - assertNotNull(layer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); - // Set and Get - layer.setProperties(iconOptional(true)); - assertEquals((Boolean) layer.getIconOptional().getValue(), (Boolean) true); + // Set and Get + layer.setProperties(iconOptional(true)); + assertEquals((Boolean) layer.getIconOptional().getValue(), (Boolean) true); + } + }); } @Test @@ -303,25 +370,30 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("icon-optional"); - assertNotNull(layer); - - // Set - layer.setProperties( - iconOptional( - zoom( - interval( - stop(2, iconOptional(true)) + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + iconOptional( + zoom( + interval( + stop(2, iconOptional(true)) + ) + ) ) - ) - ) - ); + ); - // Verify - assertNotNull(layer.getIconOptional()); - assertNotNull(layer.getIconOptional().getFunction()); - assertEquals(CameraFunction.class, layer.getIconOptional().getFunction().getClass()); - assertEquals(IntervalStops.class, layer.getIconOptional().getFunction().getStops().getClass()); - assertEquals(1, ((IntervalStops) layer.getIconOptional().getFunction().getStops()).size()); + // Verify + assertNotNull(layer.getIconOptional()); + assertNotNull(layer.getIconOptional().getFunction()); + assertEquals(CameraFunction.class, layer.getIconOptional().getFunction().getClass()); + assertEquals(IntervalStops.class, layer.getIconOptional().getFunction().getStops().getClass()); + assertEquals(1, ((IntervalStops) layer.getIconOptional().getFunction().getStops()).size()); + } + }); } @Test @@ -329,11 +401,16 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("icon-rotation-alignment"); - assertNotNull(layer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); - // Set and Get - layer.setProperties(iconRotationAlignment(ICON_ROTATION_ALIGNMENT_MAP)); - assertEquals((String) layer.getIconRotationAlignment().getValue(), (String) ICON_ROTATION_ALIGNMENT_MAP); + // Set and Get + layer.setProperties(iconRotationAlignment(ICON_ROTATION_ALIGNMENT_MAP)); + assertEquals((String) layer.getIconRotationAlignment().getValue(), (String) ICON_ROTATION_ALIGNMENT_MAP); + } + }); } @Test @@ -341,25 +418,30 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("icon-rotation-alignment"); - assertNotNull(layer); - - // Set - layer.setProperties( - iconRotationAlignment( - zoom( - interval( - stop(2, iconRotationAlignment(ICON_ROTATION_ALIGNMENT_MAP)) + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + iconRotationAlignment( + zoom( + interval( + stop(2, iconRotationAlignment(ICON_ROTATION_ALIGNMENT_MAP)) + ) + ) ) - ) - ) - ); + ); - // Verify - assertNotNull(layer.getIconRotationAlignment()); - assertNotNull(layer.getIconRotationAlignment().getFunction()); - assertEquals(CameraFunction.class, layer.getIconRotationAlignment().getFunction().getClass()); - assertEquals(IntervalStops.class, layer.getIconRotationAlignment().getFunction().getStops().getClass()); - assertEquals(1, ((IntervalStops) layer.getIconRotationAlignment().getFunction().getStops()).size()); + // Verify + assertNotNull(layer.getIconRotationAlignment()); + assertNotNull(layer.getIconRotationAlignment().getFunction()); + assertEquals(CameraFunction.class, layer.getIconRotationAlignment().getFunction().getClass()); + assertEquals(IntervalStops.class, layer.getIconRotationAlignment().getFunction().getStops().getClass()); + assertEquals(1, ((IntervalStops) layer.getIconRotationAlignment().getFunction().getStops()).size()); + } + }); } @Test @@ -367,11 +449,16 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("icon-size"); - assertNotNull(layer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); - // Set and Get - layer.setProperties(iconSize(0.3f)); - assertEquals((Float) layer.getIconSize().getValue(), (Float) 0.3f); + // Set and Get + layer.setProperties(iconSize(0.3f)); + assertEquals((Float) layer.getIconSize().getValue(), (Float) 0.3f); + } + }); } @Test @@ -379,26 +466,31 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("icon-size"); - assertNotNull(layer); - - // Set - layer.setProperties( - iconSize( - zoom( - exponential( - stop(2, iconSize(0.3f)) - ).withBase(0.5f) - ) - ) - ); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + iconSize( + zoom( + exponential( + stop(2, iconSize(0.3f)) + ).withBase(0.5f) + ) + ) + ); - // Verify - assertNotNull(layer.getIconSize()); - assertNotNull(layer.getIconSize().getFunction()); - assertEquals(CameraFunction.class, layer.getIconSize().getFunction().getClass()); - assertEquals(ExponentialStops.class, layer.getIconSize().getFunction().getStops().getClass()); - assertEquals(0.5f, ((ExponentialStops) layer.getIconSize().getFunction().getStops()).getBase(), 0.001); - assertEquals(1, ((ExponentialStops) layer.getIconSize().getFunction().getStops()).size()); + // Verify + assertNotNull(layer.getIconSize()); + assertNotNull(layer.getIconSize().getFunction()); + assertEquals(CameraFunction.class, layer.getIconSize().getFunction().getClass()); + assertEquals(ExponentialStops.class, layer.getIconSize().getFunction().getStops().getClass()); + assertEquals(0.5f, ((ExponentialStops) layer.getIconSize().getFunction().getStops()).getBase(), 0.001); + assertEquals(1, ((ExponentialStops) layer.getIconSize().getFunction().getStops()).size()); + } + }); } @Test @@ -406,19 +498,24 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("icon-size"); - assertNotNull(layer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); - // Set - layer.setProperties( - iconSize(property("FeaturePropertyA", Stops.<Float>identity())) - ); + // Set + layer.setProperties( + iconSize(property("FeaturePropertyA", Stops.<Float>identity())) + ); - // Verify - assertNotNull(layer.getIconSize()); - assertNotNull(layer.getIconSize().getFunction()); - assertEquals(SourceFunction.class, layer.getIconSize().getFunction().getClass()); - assertEquals("FeaturePropertyA", ((SourceFunction) layer.getIconSize().getFunction()).getProperty()); - assertEquals(IdentityStops.class, layer.getIconSize().getFunction().getStops().getClass()); + // Verify + assertNotNull(layer.getIconSize()); + assertNotNull(layer.getIconSize().getFunction()); + assertEquals(SourceFunction.class, layer.getIconSize().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getIconSize().getFunction()).getProperty()); + assertEquals(IdentityStops.class, layer.getIconSize().getFunction().getStops().getClass()); + } + }); } @Test @@ -426,26 +523,31 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("icon-size"); - assertNotNull(layer); - - // Set - layer.setProperties( - iconSize( - property( - "FeaturePropertyA", - exponential( - stop(0.3f, iconSize(0.3f)) - ).withBase(0.5f) - ) - ) - ); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + iconSize( + property( + "FeaturePropertyA", + exponential( + stop(0.3f, iconSize(0.3f)) + ).withBase(0.5f) + ) + ) + ); - // Verify - assertNotNull(layer.getIconSize()); - assertNotNull(layer.getIconSize().getFunction()); - assertEquals(SourceFunction.class, layer.getIconSize().getFunction().getClass()); - assertEquals("FeaturePropertyA", ((SourceFunction) layer.getIconSize().getFunction()).getProperty()); - assertEquals(ExponentialStops.class, layer.getIconSize().getFunction().getStops().getClass()); + // Verify + assertNotNull(layer.getIconSize()); + assertNotNull(layer.getIconSize().getFunction()); + assertEquals(SourceFunction.class, layer.getIconSize().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getIconSize().getFunction()).getProperty()); + assertEquals(ExponentialStops.class, layer.getIconSize().getFunction().getStops().getClass()); + } + }); } @Test @@ -453,29 +555,35 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("icon-size"); - assertNotNull(layer); - - // Set - layer.setProperties( - iconSize( - property( - "FeaturePropertyA", - categorical( - stop(1.0f, iconSize(0.3f)) + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + iconSize( + property( + "FeaturePropertyA", + categorical( + stop(1.0f, iconSize(0.3f)) + ) + ).withDefaultValue(iconSize(0.3f)) ) - ).withDefaultValue(iconSize(0.3f)) - ) - ); + ); + + // Verify + assertNotNull(layer.getIconSize()); + assertNotNull(layer.getIconSize().getFunction()); + assertEquals(SourceFunction.class, layer.getIconSize().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getIconSize().getFunction()).getProperty()); + assertEquals(CategoricalStops.class, layer.getIconSize().getFunction().getStops().getClass()); + assertNotNull(((SourceFunction) layer.getIconSize().getFunction()).getDefaultValue()); + assertNotNull(((SourceFunction) layer.getIconSize().getFunction()).getDefaultValue().getValue()); + assertEquals(0.3f, ((SourceFunction) layer.getIconSize().getFunction()).getDefaultValue().getValue()); + } + }); - // Verify - assertNotNull(layer.getIconSize()); - assertNotNull(layer.getIconSize().getFunction()); - assertEquals(SourceFunction.class, layer.getIconSize().getFunction().getClass()); - assertEquals("FeaturePropertyA", ((SourceFunction) layer.getIconSize().getFunction()).getProperty()); - assertEquals(CategoricalStops.class, layer.getIconSize().getFunction().getStops().getClass()); - assertNotNull(((SourceFunction) layer.getIconSize().getFunction()).getDefaultValue()); - assertNotNull(((SourceFunction) layer.getIconSize().getFunction()).getDefaultValue().getValue()); - assertEquals(0.3f, ((SourceFunction) layer.getIconSize().getFunction()).getDefaultValue().getValue()); } @Test @@ -483,34 +591,39 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("icon-size"); - assertNotNull(layer); - - // Set - layer.setProperties( - iconSize( - composite( - "FeaturePropertyA", - exponential( - stop(0, 0.3f, iconSize(0.9f)) - ).withBase(0.5f) - ).withDefaultValue(iconSize(0.3f)) - ) - ); - - // Verify - assertNotNull(layer.getIconSize()); - assertNotNull(layer.getIconSize().getFunction()); - assertEquals(CompositeFunction.class, layer.getIconSize().getFunction().getClass()); - assertEquals("FeaturePropertyA", ((CompositeFunction) layer.getIconSize().getFunction()).getProperty()); - assertEquals(ExponentialStops.class, layer.getIconSize().getFunction().getStops().getClass()); - assertEquals(1, ((ExponentialStops) layer.getIconSize().getFunction().getStops()).size()); - - ExponentialStops<Stop.CompositeValue<Float, Float>, Float> stops = - (ExponentialStops<Stop.CompositeValue<Float, Float>, Float>) layer.getIconSize().getFunction().getStops(); - Stop<Stop.CompositeValue<Float, Float>, Float> stop = stops.iterator().next(); - assertEquals(0f, stop.in.zoom, 0.001); - assertEquals(0.3f, stop.in.value, 0.001f); - assertEquals(0.9f, stop.out, 0.001f); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + iconSize( + composite( + "FeaturePropertyA", + exponential( + stop(0, 0.3f, iconSize(0.9f)) + ).withBase(0.5f) + ).withDefaultValue(iconSize(0.3f)) + ) + ); + + // Verify + assertNotNull(layer.getIconSize()); + assertNotNull(layer.getIconSize().getFunction()); + assertEquals(CompositeFunction.class, layer.getIconSize().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((CompositeFunction) layer.getIconSize().getFunction()).getProperty()); + assertEquals(ExponentialStops.class, layer.getIconSize().getFunction().getStops().getClass()); + assertEquals(1, ((ExponentialStops) layer.getIconSize().getFunction().getStops()).size()); + + ExponentialStops<Stop.CompositeValue<Float, Float>, Float> stops = + (ExponentialStops<Stop.CompositeValue<Float, Float>, Float>) layer.getIconSize().getFunction().getStops(); + Stop<Stop.CompositeValue<Float, Float>, Float> stop = stops.iterator().next(); + assertEquals(0f, stop.in.zoom, 0.001); + assertEquals(0.3f, stop.in.value, 0.001f); + assertEquals(0.9f, stop.out, 0.001f); + } + }); } @Test @@ -518,11 +631,16 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("icon-text-fit"); - assertNotNull(layer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); - // Set and Get - layer.setProperties(iconTextFit(ICON_TEXT_FIT_NONE)); - assertEquals((String) layer.getIconTextFit().getValue(), (String) ICON_TEXT_FIT_NONE); + // Set and Get + layer.setProperties(iconTextFit(ICON_TEXT_FIT_NONE)); + assertEquals((String) layer.getIconTextFit().getValue(), (String) ICON_TEXT_FIT_NONE); + } + }); } @Test @@ -530,25 +648,30 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("icon-text-fit"); - assertNotNull(layer); - - // Set - layer.setProperties( - iconTextFit( - zoom( - interval( - stop(2, iconTextFit(ICON_TEXT_FIT_NONE)) + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + iconTextFit( + zoom( + interval( + stop(2, iconTextFit(ICON_TEXT_FIT_NONE)) + ) + ) ) - ) - ) - ); + ); - // Verify - assertNotNull(layer.getIconTextFit()); - assertNotNull(layer.getIconTextFit().getFunction()); - assertEquals(CameraFunction.class, layer.getIconTextFit().getFunction().getClass()); - assertEquals(IntervalStops.class, layer.getIconTextFit().getFunction().getStops().getClass()); - assertEquals(1, ((IntervalStops) layer.getIconTextFit().getFunction().getStops()).size()); + // Verify + assertNotNull(layer.getIconTextFit()); + assertNotNull(layer.getIconTextFit().getFunction()); + assertEquals(CameraFunction.class, layer.getIconTextFit().getFunction().getClass()); + assertEquals(IntervalStops.class, layer.getIconTextFit().getFunction().getStops().getClass()); + assertEquals(1, ((IntervalStops) layer.getIconTextFit().getFunction().getStops()).size()); + } + }); } @Test @@ -556,11 +679,16 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("icon-text-fit-padding"); - assertNotNull(layer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); - // Set and Get - layer.setProperties(iconTextFitPadding(new Float[]{0f,0f,0f,0f})); - assertEquals((Float[]) layer.getIconTextFitPadding().getValue(), (Float[]) new Float[]{0f,0f,0f,0f}); + // Set and Get + layer.setProperties(iconTextFitPadding(new Float[] {0f, 0f, 0f, 0f})); + assertEquals((Float[]) layer.getIconTextFitPadding().getValue(), (Float[]) new Float[] {0f, 0f, 0f, 0f}); + } + }); } @Test @@ -568,26 +696,31 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("icon-text-fit-padding"); - assertNotNull(layer); - - // Set - layer.setProperties( - iconTextFitPadding( - zoom( - exponential( - stop(2, iconTextFitPadding(new Float[]{0f,0f,0f,0f})) - ).withBase(0.5f) - ) - ) - ); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + iconTextFitPadding( + zoom( + exponential( + stop(2, iconTextFitPadding(new Float[] {0f, 0f, 0f, 0f})) + ).withBase(0.5f) + ) + ) + ); - // Verify - assertNotNull(layer.getIconTextFitPadding()); - assertNotNull(layer.getIconTextFitPadding().getFunction()); - assertEquals(CameraFunction.class, layer.getIconTextFitPadding().getFunction().getClass()); - assertEquals(ExponentialStops.class, layer.getIconTextFitPadding().getFunction().getStops().getClass()); - assertEquals(0.5f, ((ExponentialStops) layer.getIconTextFitPadding().getFunction().getStops()).getBase(), 0.001); - assertEquals(1, ((ExponentialStops) layer.getIconTextFitPadding().getFunction().getStops()).size()); + // Verify + assertNotNull(layer.getIconTextFitPadding()); + assertNotNull(layer.getIconTextFitPadding().getFunction()); + assertEquals(CameraFunction.class, layer.getIconTextFitPadding().getFunction().getClass()); + assertEquals(ExponentialStops.class, layer.getIconTextFitPadding().getFunction().getStops().getClass()); + assertEquals(0.5f, ((ExponentialStops) layer.getIconTextFitPadding().getFunction().getStops()).getBase(), 0.001); + assertEquals(1, ((ExponentialStops) layer.getIconTextFitPadding().getFunction().getStops()).size()); + } + }); } @Test @@ -595,11 +728,16 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("icon-image"); - assertNotNull(layer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); - // Set and Get - layer.setProperties(iconImage("undefined")); - assertEquals((String) layer.getIconImage().getValue(), (String) "undefined"); + // Set and Get + layer.setProperties(iconImage("undefined")); + assertEquals((String) layer.getIconImage().getValue(), (String) "undefined"); + } + }); } @Test @@ -607,25 +745,30 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("icon-image"); - assertNotNull(layer); - - // Set - layer.setProperties( - iconImage( - zoom( - interval( - stop(2, iconImage("undefined")) + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + iconImage( + zoom( + interval( + stop(2, iconImage("undefined")) + ) + ) ) - ) - ) - ); + ); - // Verify - assertNotNull(layer.getIconImage()); - assertNotNull(layer.getIconImage().getFunction()); - assertEquals(CameraFunction.class, layer.getIconImage().getFunction().getClass()); - assertEquals(IntervalStops.class, layer.getIconImage().getFunction().getStops().getClass()); - assertEquals(1, ((IntervalStops) layer.getIconImage().getFunction().getStops()).size()); + // Verify + assertNotNull(layer.getIconImage()); + assertNotNull(layer.getIconImage().getFunction()); + assertEquals(CameraFunction.class, layer.getIconImage().getFunction().getClass()); + assertEquals(IntervalStops.class, layer.getIconImage().getFunction().getStops().getClass()); + assertEquals(1, ((IntervalStops) layer.getIconImage().getFunction().getStops()).size()); + } + }); } @Test @@ -633,19 +776,24 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("icon-image"); - assertNotNull(layer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); - // Set - layer.setProperties( - iconImage(property("FeaturePropertyA", Stops.<String>identity())) - ); + // Set + layer.setProperties( + iconImage(property("FeaturePropertyA", Stops.<String>identity())) + ); - // Verify - assertNotNull(layer.getIconImage()); - assertNotNull(layer.getIconImage().getFunction()); - assertEquals(SourceFunction.class, layer.getIconImage().getFunction().getClass()); - assertEquals("FeaturePropertyA", ((SourceFunction) layer.getIconImage().getFunction()).getProperty()); - assertEquals(IdentityStops.class, layer.getIconImage().getFunction().getStops().getClass()); + // Verify + assertNotNull(layer.getIconImage()); + assertNotNull(layer.getIconImage().getFunction()); + assertEquals(SourceFunction.class, layer.getIconImage().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getIconImage().getFunction()).getProperty()); + assertEquals(IdentityStops.class, layer.getIconImage().getFunction().getStops().getClass()); + } + }); } @Test @@ -653,26 +801,31 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("icon-image"); - assertNotNull(layer); - - // Set - layer.setProperties( - iconImage( - property( - "FeaturePropertyA", - interval( - stop(1, iconImage("undefined")) + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + iconImage( + property( + "FeaturePropertyA", + interval( + stop(1, iconImage("undefined")) + ) + ) ) - ) - ) - ); + ); - // Verify - assertNotNull(layer.getIconImage()); - assertNotNull(layer.getIconImage().getFunction()); - assertEquals(SourceFunction.class, layer.getIconImage().getFunction().getClass()); - assertEquals("FeaturePropertyA", ((SourceFunction) layer.getIconImage().getFunction()).getProperty()); - assertEquals(IntervalStops.class, layer.getIconImage().getFunction().getStops().getClass()); + // Verify + assertNotNull(layer.getIconImage()); + assertNotNull(layer.getIconImage().getFunction()); + assertEquals(SourceFunction.class, layer.getIconImage().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getIconImage().getFunction()).getProperty()); + assertEquals(IntervalStops.class, layer.getIconImage().getFunction().getStops().getClass()); + } + }); } @Test @@ -680,11 +833,16 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("icon-rotate"); - assertNotNull(layer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); - // Set and Get - layer.setProperties(iconRotate(0.3f)); - assertEquals((Float) layer.getIconRotate().getValue(), (Float) 0.3f); + // Set and Get + layer.setProperties(iconRotate(0.3f)); + assertEquals((Float) layer.getIconRotate().getValue(), (Float) 0.3f); + } + }); } @Test @@ -692,26 +850,31 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("icon-rotate"); - assertNotNull(layer); - - // Set - layer.setProperties( - iconRotate( - zoom( - exponential( - stop(2, iconRotate(0.3f)) - ).withBase(0.5f) - ) - ) - ); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + iconRotate( + zoom( + exponential( + stop(2, iconRotate(0.3f)) + ).withBase(0.5f) + ) + ) + ); - // Verify - assertNotNull(layer.getIconRotate()); - assertNotNull(layer.getIconRotate().getFunction()); - assertEquals(CameraFunction.class, layer.getIconRotate().getFunction().getClass()); - assertEquals(ExponentialStops.class, layer.getIconRotate().getFunction().getStops().getClass()); - assertEquals(0.5f, ((ExponentialStops) layer.getIconRotate().getFunction().getStops()).getBase(), 0.001); - assertEquals(1, ((ExponentialStops) layer.getIconRotate().getFunction().getStops()).size()); + // Verify + assertNotNull(layer.getIconRotate()); + assertNotNull(layer.getIconRotate().getFunction()); + assertEquals(CameraFunction.class, layer.getIconRotate().getFunction().getClass()); + assertEquals(ExponentialStops.class, layer.getIconRotate().getFunction().getStops().getClass()); + assertEquals(0.5f, ((ExponentialStops) layer.getIconRotate().getFunction().getStops()).getBase(), 0.001); + assertEquals(1, ((ExponentialStops) layer.getIconRotate().getFunction().getStops()).size()); + } + }); } @Test @@ -719,19 +882,24 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("icon-rotate"); - assertNotNull(layer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); - // Set - layer.setProperties( - iconRotate(property("FeaturePropertyA", Stops.<Float>identity())) - ); + // Set + layer.setProperties( + iconRotate(property("FeaturePropertyA", Stops.<Float>identity())) + ); - // Verify - assertNotNull(layer.getIconRotate()); - assertNotNull(layer.getIconRotate().getFunction()); - assertEquals(SourceFunction.class, layer.getIconRotate().getFunction().getClass()); - assertEquals("FeaturePropertyA", ((SourceFunction) layer.getIconRotate().getFunction()).getProperty()); - assertEquals(IdentityStops.class, layer.getIconRotate().getFunction().getStops().getClass()); + // Verify + assertNotNull(layer.getIconRotate()); + assertNotNull(layer.getIconRotate().getFunction()); + assertEquals(SourceFunction.class, layer.getIconRotate().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getIconRotate().getFunction()).getProperty()); + assertEquals(IdentityStops.class, layer.getIconRotate().getFunction().getStops().getClass()); + } + }); } @Test @@ -739,26 +907,31 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("icon-rotate"); - assertNotNull(layer); - - // Set - layer.setProperties( - iconRotate( - property( - "FeaturePropertyA", - exponential( - stop(0.3f, iconRotate(0.3f)) - ).withBase(0.5f) - ) - ) - ); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + iconRotate( + property( + "FeaturePropertyA", + exponential( + stop(0.3f, iconRotate(0.3f)) + ).withBase(0.5f) + ) + ) + ); - // Verify - assertNotNull(layer.getIconRotate()); - assertNotNull(layer.getIconRotate().getFunction()); - assertEquals(SourceFunction.class, layer.getIconRotate().getFunction().getClass()); - assertEquals("FeaturePropertyA", ((SourceFunction) layer.getIconRotate().getFunction()).getProperty()); - assertEquals(ExponentialStops.class, layer.getIconRotate().getFunction().getStops().getClass()); + // Verify + assertNotNull(layer.getIconRotate()); + assertNotNull(layer.getIconRotate().getFunction()); + assertEquals(SourceFunction.class, layer.getIconRotate().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getIconRotate().getFunction()).getProperty()); + assertEquals(ExponentialStops.class, layer.getIconRotate().getFunction().getStops().getClass()); + } + }); } @Test @@ -766,29 +939,35 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("icon-rotate"); - assertNotNull(layer); - - // Set - layer.setProperties( - iconRotate( - property( - "FeaturePropertyA", - categorical( - stop(1.0f, iconRotate(0.3f)) + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + iconRotate( + property( + "FeaturePropertyA", + categorical( + stop(1.0f, iconRotate(0.3f)) + ) + ).withDefaultValue(iconRotate(0.3f)) ) - ).withDefaultValue(iconRotate(0.3f)) - ) - ); + ); + + // Verify + assertNotNull(layer.getIconRotate()); + assertNotNull(layer.getIconRotate().getFunction()); + assertEquals(SourceFunction.class, layer.getIconRotate().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getIconRotate().getFunction()).getProperty()); + assertEquals(CategoricalStops.class, layer.getIconRotate().getFunction().getStops().getClass()); + assertNotNull(((SourceFunction) layer.getIconRotate().getFunction()).getDefaultValue()); + assertNotNull(((SourceFunction) layer.getIconRotate().getFunction()).getDefaultValue().getValue()); + assertEquals(0.3f, ((SourceFunction) layer.getIconRotate().getFunction()).getDefaultValue().getValue()); + } + }); - // Verify - assertNotNull(layer.getIconRotate()); - assertNotNull(layer.getIconRotate().getFunction()); - assertEquals(SourceFunction.class, layer.getIconRotate().getFunction().getClass()); - assertEquals("FeaturePropertyA", ((SourceFunction) layer.getIconRotate().getFunction()).getProperty()); - assertEquals(CategoricalStops.class, layer.getIconRotate().getFunction().getStops().getClass()); - assertNotNull(((SourceFunction) layer.getIconRotate().getFunction()).getDefaultValue()); - assertNotNull(((SourceFunction) layer.getIconRotate().getFunction()).getDefaultValue().getValue()); - assertEquals(0.3f, ((SourceFunction) layer.getIconRotate().getFunction()).getDefaultValue().getValue()); } @Test @@ -796,34 +975,39 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("icon-rotate"); - assertNotNull(layer); - - // Set - layer.setProperties( - iconRotate( - composite( - "FeaturePropertyA", - exponential( - stop(0, 0.3f, iconRotate(0.9f)) - ).withBase(0.5f) - ).withDefaultValue(iconRotate(0.3f)) - ) - ); - - // Verify - assertNotNull(layer.getIconRotate()); - assertNotNull(layer.getIconRotate().getFunction()); - assertEquals(CompositeFunction.class, layer.getIconRotate().getFunction().getClass()); - assertEquals("FeaturePropertyA", ((CompositeFunction) layer.getIconRotate().getFunction()).getProperty()); - assertEquals(ExponentialStops.class, layer.getIconRotate().getFunction().getStops().getClass()); - assertEquals(1, ((ExponentialStops) layer.getIconRotate().getFunction().getStops()).size()); - - ExponentialStops<Stop.CompositeValue<Float, Float>, Float> stops = - (ExponentialStops<Stop.CompositeValue<Float, Float>, Float>) layer.getIconRotate().getFunction().getStops(); - Stop<Stop.CompositeValue<Float, Float>, Float> stop = stops.iterator().next(); - assertEquals(0f, stop.in.zoom, 0.001); - assertEquals(0.3f, stop.in.value, 0.001f); - assertEquals(0.9f, stop.out, 0.001f); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + iconRotate( + composite( + "FeaturePropertyA", + exponential( + stop(0, 0.3f, iconRotate(0.9f)) + ).withBase(0.5f) + ).withDefaultValue(iconRotate(0.3f)) + ) + ); + + // Verify + assertNotNull(layer.getIconRotate()); + assertNotNull(layer.getIconRotate().getFunction()); + assertEquals(CompositeFunction.class, layer.getIconRotate().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((CompositeFunction) layer.getIconRotate().getFunction()).getProperty()); + assertEquals(ExponentialStops.class, layer.getIconRotate().getFunction().getStops().getClass()); + assertEquals(1, ((ExponentialStops) layer.getIconRotate().getFunction().getStops()).size()); + + ExponentialStops<Stop.CompositeValue<Float, Float>, Float> stops = + (ExponentialStops<Stop.CompositeValue<Float, Float>, Float>) layer.getIconRotate().getFunction().getStops(); + Stop<Stop.CompositeValue<Float, Float>, Float> stop = stops.iterator().next(); + assertEquals(0f, stop.in.zoom, 0.001); + assertEquals(0.3f, stop.in.value, 0.001f); + assertEquals(0.9f, stop.out, 0.001f); + } + }); } @Test @@ -831,11 +1015,16 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("icon-padding"); - assertNotNull(layer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); - // Set and Get - layer.setProperties(iconPadding(0.3f)); - assertEquals((Float) layer.getIconPadding().getValue(), (Float) 0.3f); + // Set and Get + layer.setProperties(iconPadding(0.3f)); + assertEquals((Float) layer.getIconPadding().getValue(), (Float) 0.3f); + } + }); } @Test @@ -843,26 +1032,31 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("icon-padding"); - assertNotNull(layer); - - // Set - layer.setProperties( - iconPadding( - zoom( - exponential( - stop(2, iconPadding(0.3f)) - ).withBase(0.5f) - ) - ) - ); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + iconPadding( + zoom( + exponential( + stop(2, iconPadding(0.3f)) + ).withBase(0.5f) + ) + ) + ); - // Verify - assertNotNull(layer.getIconPadding()); - assertNotNull(layer.getIconPadding().getFunction()); - assertEquals(CameraFunction.class, layer.getIconPadding().getFunction().getClass()); - assertEquals(ExponentialStops.class, layer.getIconPadding().getFunction().getStops().getClass()); - assertEquals(0.5f, ((ExponentialStops) layer.getIconPadding().getFunction().getStops()).getBase(), 0.001); - assertEquals(1, ((ExponentialStops) layer.getIconPadding().getFunction().getStops()).size()); + // Verify + assertNotNull(layer.getIconPadding()); + assertNotNull(layer.getIconPadding().getFunction()); + assertEquals(CameraFunction.class, layer.getIconPadding().getFunction().getClass()); + assertEquals(ExponentialStops.class, layer.getIconPadding().getFunction().getStops().getClass()); + assertEquals(0.5f, ((ExponentialStops) layer.getIconPadding().getFunction().getStops()).getBase(), 0.001); + assertEquals(1, ((ExponentialStops) layer.getIconPadding().getFunction().getStops()).size()); + } + }); } @Test @@ -870,11 +1064,16 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("icon-keep-upright"); - assertNotNull(layer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); - // Set and Get - layer.setProperties(iconKeepUpright(true)); - assertEquals((Boolean) layer.getIconKeepUpright().getValue(), (Boolean) true); + // Set and Get + layer.setProperties(iconKeepUpright(true)); + assertEquals((Boolean) layer.getIconKeepUpright().getValue(), (Boolean) true); + } + }); } @Test @@ -882,25 +1081,30 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("icon-keep-upright"); - assertNotNull(layer); - - // Set - layer.setProperties( - iconKeepUpright( - zoom( - interval( - stop(2, iconKeepUpright(true)) + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + iconKeepUpright( + zoom( + interval( + stop(2, iconKeepUpright(true)) + ) + ) ) - ) - ) - ); + ); - // Verify - assertNotNull(layer.getIconKeepUpright()); - assertNotNull(layer.getIconKeepUpright().getFunction()); - assertEquals(CameraFunction.class, layer.getIconKeepUpright().getFunction().getClass()); - assertEquals(IntervalStops.class, layer.getIconKeepUpright().getFunction().getStops().getClass()); - assertEquals(1, ((IntervalStops) layer.getIconKeepUpright().getFunction().getStops()).size()); + // Verify + assertNotNull(layer.getIconKeepUpright()); + assertNotNull(layer.getIconKeepUpright().getFunction()); + assertEquals(CameraFunction.class, layer.getIconKeepUpright().getFunction().getClass()); + assertEquals(IntervalStops.class, layer.getIconKeepUpright().getFunction().getStops().getClass()); + assertEquals(1, ((IntervalStops) layer.getIconKeepUpright().getFunction().getStops()).size()); + } + }); } @Test @@ -908,11 +1112,16 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("icon-offset"); - assertNotNull(layer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); - // Set and Get - layer.setProperties(iconOffset(new Float[]{0f,0f})); - assertEquals((Float[]) layer.getIconOffset().getValue(), (Float[]) new Float[]{0f,0f}); + // Set and Get + layer.setProperties(iconOffset(new Float[] {0f, 0f})); + assertEquals((Float[]) layer.getIconOffset().getValue(), (Float[]) new Float[] {0f, 0f}); + } + }); } @Test @@ -920,26 +1129,31 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("icon-offset"); - assertNotNull(layer); - - // Set - layer.setProperties( - iconOffset( - zoom( - exponential( - stop(2, iconOffset(new Float[]{0f,0f})) - ).withBase(0.5f) - ) - ) - ); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + iconOffset( + zoom( + exponential( + stop(2, iconOffset(new Float[] {0f, 0f})) + ).withBase(0.5f) + ) + ) + ); - // Verify - assertNotNull(layer.getIconOffset()); - assertNotNull(layer.getIconOffset().getFunction()); - assertEquals(CameraFunction.class, layer.getIconOffset().getFunction().getClass()); - assertEquals(ExponentialStops.class, layer.getIconOffset().getFunction().getStops().getClass()); - assertEquals(0.5f, ((ExponentialStops) layer.getIconOffset().getFunction().getStops()).getBase(), 0.001); - assertEquals(1, ((ExponentialStops) layer.getIconOffset().getFunction().getStops()).size()); + // Verify + assertNotNull(layer.getIconOffset()); + assertNotNull(layer.getIconOffset().getFunction()); + assertEquals(CameraFunction.class, layer.getIconOffset().getFunction().getClass()); + assertEquals(ExponentialStops.class, layer.getIconOffset().getFunction().getStops().getClass()); + assertEquals(0.5f, ((ExponentialStops) layer.getIconOffset().getFunction().getStops()).getBase(), 0.001); + assertEquals(1, ((ExponentialStops) layer.getIconOffset().getFunction().getStops()).size()); + } + }); } @Test @@ -947,19 +1161,24 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("icon-offset"); - assertNotNull(layer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); - // Set - layer.setProperties( - iconOffset(property("FeaturePropertyA", Stops.<Float[]>identity())) - ); + // Set + layer.setProperties( + iconOffset(property("FeaturePropertyA", Stops.<Float[]>identity())) + ); - // Verify - assertNotNull(layer.getIconOffset()); - assertNotNull(layer.getIconOffset().getFunction()); - assertEquals(SourceFunction.class, layer.getIconOffset().getFunction().getClass()); - assertEquals("FeaturePropertyA", ((SourceFunction) layer.getIconOffset().getFunction()).getProperty()); - assertEquals(IdentityStops.class, layer.getIconOffset().getFunction().getStops().getClass()); + // Verify + assertNotNull(layer.getIconOffset()); + assertNotNull(layer.getIconOffset().getFunction()); + assertEquals(SourceFunction.class, layer.getIconOffset().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getIconOffset().getFunction()).getProperty()); + assertEquals(IdentityStops.class, layer.getIconOffset().getFunction().getStops().getClass()); + } + }); } @Test @@ -967,26 +1186,31 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("icon-offset"); - assertNotNull(layer); - - // Set - layer.setProperties( - iconOffset( - property( - "FeaturePropertyA", - interval( - stop(1, iconOffset(new Float[]{0f,0f})) + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + iconOffset( + property( + "FeaturePropertyA", + interval( + stop(1, iconOffset(new Float[] {0f, 0f})) + ) + ) ) - ) - ) - ); + ); - // Verify - assertNotNull(layer.getIconOffset()); - assertNotNull(layer.getIconOffset().getFunction()); - assertEquals(SourceFunction.class, layer.getIconOffset().getFunction().getClass()); - assertEquals("FeaturePropertyA", ((SourceFunction) layer.getIconOffset().getFunction()).getProperty()); - assertEquals(IntervalStops.class, layer.getIconOffset().getFunction().getStops().getClass()); + // Verify + assertNotNull(layer.getIconOffset()); + assertNotNull(layer.getIconOffset().getFunction()); + assertEquals(SourceFunction.class, layer.getIconOffset().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getIconOffset().getFunction()).getProperty()); + assertEquals(IntervalStops.class, layer.getIconOffset().getFunction().getStops().getClass()); + } + }); } @Test @@ -994,11 +1218,16 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("text-pitch-alignment"); - assertNotNull(layer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); - // Set and Get - layer.setProperties(textPitchAlignment(TEXT_PITCH_ALIGNMENT_MAP)); - assertEquals((String) layer.getTextPitchAlignment().getValue(), (String) TEXT_PITCH_ALIGNMENT_MAP); + // Set and Get + layer.setProperties(textPitchAlignment(TEXT_PITCH_ALIGNMENT_MAP)); + assertEquals((String) layer.getTextPitchAlignment().getValue(), (String) TEXT_PITCH_ALIGNMENT_MAP); + } + }); } @Test @@ -1006,25 +1235,30 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("text-pitch-alignment"); - assertNotNull(layer); - - // Set - layer.setProperties( - textPitchAlignment( - zoom( - interval( - stop(2, textPitchAlignment(TEXT_PITCH_ALIGNMENT_MAP)) + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + textPitchAlignment( + zoom( + interval( + stop(2, textPitchAlignment(TEXT_PITCH_ALIGNMENT_MAP)) + ) + ) ) - ) - ) - ); + ); - // Verify - assertNotNull(layer.getTextPitchAlignment()); - assertNotNull(layer.getTextPitchAlignment().getFunction()); - assertEquals(CameraFunction.class, layer.getTextPitchAlignment().getFunction().getClass()); - assertEquals(IntervalStops.class, layer.getTextPitchAlignment().getFunction().getStops().getClass()); - assertEquals(1, ((IntervalStops) layer.getTextPitchAlignment().getFunction().getStops()).size()); + // Verify + assertNotNull(layer.getTextPitchAlignment()); + assertNotNull(layer.getTextPitchAlignment().getFunction()); + assertEquals(CameraFunction.class, layer.getTextPitchAlignment().getFunction().getClass()); + assertEquals(IntervalStops.class, layer.getTextPitchAlignment().getFunction().getStops().getClass()); + assertEquals(1, ((IntervalStops) layer.getTextPitchAlignment().getFunction().getStops()).size()); + } + }); } @Test @@ -1032,11 +1266,16 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("text-rotation-alignment"); - assertNotNull(layer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); - // Set and Get - layer.setProperties(textRotationAlignment(TEXT_ROTATION_ALIGNMENT_MAP)); - assertEquals((String) layer.getTextRotationAlignment().getValue(), (String) TEXT_ROTATION_ALIGNMENT_MAP); + // Set and Get + layer.setProperties(textRotationAlignment(TEXT_ROTATION_ALIGNMENT_MAP)); + assertEquals((String) layer.getTextRotationAlignment().getValue(), (String) TEXT_ROTATION_ALIGNMENT_MAP); + } + }); } @Test @@ -1044,25 +1283,30 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("text-rotation-alignment"); - assertNotNull(layer); - - // Set - layer.setProperties( - textRotationAlignment( - zoom( - interval( - stop(2, textRotationAlignment(TEXT_ROTATION_ALIGNMENT_MAP)) + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + textRotationAlignment( + zoom( + interval( + stop(2, textRotationAlignment(TEXT_ROTATION_ALIGNMENT_MAP)) + ) + ) ) - ) - ) - ); + ); - // Verify - assertNotNull(layer.getTextRotationAlignment()); - assertNotNull(layer.getTextRotationAlignment().getFunction()); - assertEquals(CameraFunction.class, layer.getTextRotationAlignment().getFunction().getClass()); - assertEquals(IntervalStops.class, layer.getTextRotationAlignment().getFunction().getStops().getClass()); - assertEquals(1, ((IntervalStops) layer.getTextRotationAlignment().getFunction().getStops()).size()); + // Verify + assertNotNull(layer.getTextRotationAlignment()); + assertNotNull(layer.getTextRotationAlignment().getFunction()); + assertEquals(CameraFunction.class, layer.getTextRotationAlignment().getFunction().getClass()); + assertEquals(IntervalStops.class, layer.getTextRotationAlignment().getFunction().getStops().getClass()); + assertEquals(1, ((IntervalStops) layer.getTextRotationAlignment().getFunction().getStops()).size()); + } + }); } @Test @@ -1070,11 +1314,16 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("text-field"); - assertNotNull(layer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); - // Set and Get - layer.setProperties(textField("")); - assertEquals((String) layer.getTextField().getValue(), (String) ""); + // Set and Get + layer.setProperties(textField("")); + assertEquals((String) layer.getTextField().getValue(), (String) ""); + } + }); } @Test @@ -1082,25 +1331,30 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("text-field"); - assertNotNull(layer); - - // Set - layer.setProperties( - textField( - zoom( - interval( - stop(2, textField("")) + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + textField( + zoom( + interval( + stop(2, textField("")) + ) + ) ) - ) - ) - ); + ); - // Verify - assertNotNull(layer.getTextField()); - assertNotNull(layer.getTextField().getFunction()); - assertEquals(CameraFunction.class, layer.getTextField().getFunction().getClass()); - assertEquals(IntervalStops.class, layer.getTextField().getFunction().getStops().getClass()); - assertEquals(1, ((IntervalStops) layer.getTextField().getFunction().getStops()).size()); + // Verify + assertNotNull(layer.getTextField()); + assertNotNull(layer.getTextField().getFunction()); + assertEquals(CameraFunction.class, layer.getTextField().getFunction().getClass()); + assertEquals(IntervalStops.class, layer.getTextField().getFunction().getStops().getClass()); + assertEquals(1, ((IntervalStops) layer.getTextField().getFunction().getStops()).size()); + } + }); } @Test @@ -1108,19 +1362,24 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("text-field"); - assertNotNull(layer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); - // Set - layer.setProperties( - textField(property("FeaturePropertyA", Stops.<String>identity())) - ); + // Set + layer.setProperties( + textField(property("FeaturePropertyA", Stops.<String>identity())) + ); - // Verify - assertNotNull(layer.getTextField()); - assertNotNull(layer.getTextField().getFunction()); - assertEquals(SourceFunction.class, layer.getTextField().getFunction().getClass()); - assertEquals("FeaturePropertyA", ((SourceFunction) layer.getTextField().getFunction()).getProperty()); - assertEquals(IdentityStops.class, layer.getTextField().getFunction().getStops().getClass()); + // Verify + assertNotNull(layer.getTextField()); + assertNotNull(layer.getTextField().getFunction()); + assertEquals(SourceFunction.class, layer.getTextField().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getTextField().getFunction()).getProperty()); + assertEquals(IdentityStops.class, layer.getTextField().getFunction().getStops().getClass()); + } + }); } @Test @@ -1128,26 +1387,31 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("text-field"); - assertNotNull(layer); - - // Set - layer.setProperties( - textField( - property( - "FeaturePropertyA", - interval( - stop(1, textField("")) + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + textField( + property( + "FeaturePropertyA", + interval( + stop(1, textField("")) + ) + ) ) - ) - ) - ); + ); - // Verify - assertNotNull(layer.getTextField()); - assertNotNull(layer.getTextField().getFunction()); - assertEquals(SourceFunction.class, layer.getTextField().getFunction().getClass()); - assertEquals("FeaturePropertyA", ((SourceFunction) layer.getTextField().getFunction()).getProperty()); - assertEquals(IntervalStops.class, layer.getTextField().getFunction().getStops().getClass()); + // Verify + assertNotNull(layer.getTextField()); + assertNotNull(layer.getTextField().getFunction()); + assertEquals(SourceFunction.class, layer.getTextField().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getTextField().getFunction()).getProperty()); + assertEquals(IntervalStops.class, layer.getTextField().getFunction().getStops().getClass()); + } + }); } @Test @@ -1155,11 +1419,16 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("text-font"); - assertNotNull(layer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); - // Set and Get - layer.setProperties(textFont(new String[]{"Open Sans Regular", "Arial Unicode MS Regular"})); - assertEquals((String[]) layer.getTextFont().getValue(), (String[]) new String[]{"Open Sans Regular", "Arial Unicode MS Regular"}); + // Set and Get + layer.setProperties(textFont(new String[]{"Open Sans Regular", "Arial Unicode MS Regular"})); + assertEquals((String[]) layer.getTextFont().getValue(), (String[]) new String[]{"Open Sans Regular", "Arial Unicode MS Regular"}); + } + }); } @Test @@ -1167,25 +1436,30 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("text-font"); - assertNotNull(layer); - - // Set - layer.setProperties( - textFont( - zoom( - interval( - stop(2, textFont(new String[]{"Open Sans Regular", "Arial Unicode MS Regular"})) + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + textFont( + zoom( + interval( + stop(2, textFont(new String[]{"Open Sans Regular", "Arial Unicode MS Regular"})) + ) + ) ) - ) - ) - ); + ); - // Verify - assertNotNull(layer.getTextFont()); - assertNotNull(layer.getTextFont().getFunction()); - assertEquals(CameraFunction.class, layer.getTextFont().getFunction().getClass()); - assertEquals(IntervalStops.class, layer.getTextFont().getFunction().getStops().getClass()); - assertEquals(1, ((IntervalStops) layer.getTextFont().getFunction().getStops()).size()); + // Verify + assertNotNull(layer.getTextFont()); + assertNotNull(layer.getTextFont().getFunction()); + assertEquals(CameraFunction.class, layer.getTextFont().getFunction().getClass()); + assertEquals(IntervalStops.class, layer.getTextFont().getFunction().getStops().getClass()); + assertEquals(1, ((IntervalStops) layer.getTextFont().getFunction().getStops()).size()); + } + }); } @Test @@ -1193,11 +1467,16 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("text-size"); - assertNotNull(layer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); - // Set and Get - layer.setProperties(textSize(0.3f)); - assertEquals((Float) layer.getTextSize().getValue(), (Float) 0.3f); + // Set and Get + layer.setProperties(textSize(0.3f)); + assertEquals((Float) layer.getTextSize().getValue(), (Float) 0.3f); + } + }); } @Test @@ -1205,26 +1484,31 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("text-size"); - assertNotNull(layer); - - // Set - layer.setProperties( - textSize( - zoom( - exponential( - stop(2, textSize(0.3f)) - ).withBase(0.5f) - ) - ) - ); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + textSize( + zoom( + exponential( + stop(2, textSize(0.3f)) + ).withBase(0.5f) + ) + ) + ); - // Verify - assertNotNull(layer.getTextSize()); - assertNotNull(layer.getTextSize().getFunction()); - assertEquals(CameraFunction.class, layer.getTextSize().getFunction().getClass()); - assertEquals(ExponentialStops.class, layer.getTextSize().getFunction().getStops().getClass()); - assertEquals(0.5f, ((ExponentialStops) layer.getTextSize().getFunction().getStops()).getBase(), 0.001); - assertEquals(1, ((ExponentialStops) layer.getTextSize().getFunction().getStops()).size()); + // Verify + assertNotNull(layer.getTextSize()); + assertNotNull(layer.getTextSize().getFunction()); + assertEquals(CameraFunction.class, layer.getTextSize().getFunction().getClass()); + assertEquals(ExponentialStops.class, layer.getTextSize().getFunction().getStops().getClass()); + assertEquals(0.5f, ((ExponentialStops) layer.getTextSize().getFunction().getStops()).getBase(), 0.001); + assertEquals(1, ((ExponentialStops) layer.getTextSize().getFunction().getStops()).size()); + } + }); } @Test @@ -1232,19 +1516,24 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("text-size"); - assertNotNull(layer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); - // Set - layer.setProperties( - textSize(property("FeaturePropertyA", Stops.<Float>identity())) - ); + // Set + layer.setProperties( + textSize(property("FeaturePropertyA", Stops.<Float>identity())) + ); - // Verify - assertNotNull(layer.getTextSize()); - assertNotNull(layer.getTextSize().getFunction()); - assertEquals(SourceFunction.class, layer.getTextSize().getFunction().getClass()); - assertEquals("FeaturePropertyA", ((SourceFunction) layer.getTextSize().getFunction()).getProperty()); - assertEquals(IdentityStops.class, layer.getTextSize().getFunction().getStops().getClass()); + // Verify + assertNotNull(layer.getTextSize()); + assertNotNull(layer.getTextSize().getFunction()); + assertEquals(SourceFunction.class, layer.getTextSize().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getTextSize().getFunction()).getProperty()); + assertEquals(IdentityStops.class, layer.getTextSize().getFunction().getStops().getClass()); + } + }); } @Test @@ -1252,26 +1541,31 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("text-size"); - assertNotNull(layer); - - // Set - layer.setProperties( - textSize( - property( - "FeaturePropertyA", - exponential( - stop(0.3f, textSize(0.3f)) - ).withBase(0.5f) - ) - ) - ); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + textSize( + property( + "FeaturePropertyA", + exponential( + stop(0.3f, textSize(0.3f)) + ).withBase(0.5f) + ) + ) + ); - // Verify - assertNotNull(layer.getTextSize()); - assertNotNull(layer.getTextSize().getFunction()); - assertEquals(SourceFunction.class, layer.getTextSize().getFunction().getClass()); - assertEquals("FeaturePropertyA", ((SourceFunction) layer.getTextSize().getFunction()).getProperty()); - assertEquals(ExponentialStops.class, layer.getTextSize().getFunction().getStops().getClass()); + // Verify + assertNotNull(layer.getTextSize()); + assertNotNull(layer.getTextSize().getFunction()); + assertEquals(SourceFunction.class, layer.getTextSize().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getTextSize().getFunction()).getProperty()); + assertEquals(ExponentialStops.class, layer.getTextSize().getFunction().getStops().getClass()); + } + }); } @Test @@ -1279,29 +1573,35 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("text-size"); - assertNotNull(layer); - - // Set - layer.setProperties( - textSize( - property( - "FeaturePropertyA", - categorical( - stop(1.0f, textSize(0.3f)) + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + textSize( + property( + "FeaturePropertyA", + categorical( + stop(1.0f, textSize(0.3f)) + ) + ).withDefaultValue(textSize(0.3f)) ) - ).withDefaultValue(textSize(0.3f)) - ) - ); + ); + + // Verify + assertNotNull(layer.getTextSize()); + assertNotNull(layer.getTextSize().getFunction()); + assertEquals(SourceFunction.class, layer.getTextSize().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getTextSize().getFunction()).getProperty()); + assertEquals(CategoricalStops.class, layer.getTextSize().getFunction().getStops().getClass()); + assertNotNull(((SourceFunction) layer.getTextSize().getFunction()).getDefaultValue()); + assertNotNull(((SourceFunction) layer.getTextSize().getFunction()).getDefaultValue().getValue()); + assertEquals(0.3f, ((SourceFunction) layer.getTextSize().getFunction()).getDefaultValue().getValue()); + } + }); - // Verify - assertNotNull(layer.getTextSize()); - assertNotNull(layer.getTextSize().getFunction()); - assertEquals(SourceFunction.class, layer.getTextSize().getFunction().getClass()); - assertEquals("FeaturePropertyA", ((SourceFunction) layer.getTextSize().getFunction()).getProperty()); - assertEquals(CategoricalStops.class, layer.getTextSize().getFunction().getStops().getClass()); - assertNotNull(((SourceFunction) layer.getTextSize().getFunction()).getDefaultValue()); - assertNotNull(((SourceFunction) layer.getTextSize().getFunction()).getDefaultValue().getValue()); - assertEquals(0.3f, ((SourceFunction) layer.getTextSize().getFunction()).getDefaultValue().getValue()); } @Test @@ -1309,34 +1609,39 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("text-size"); - assertNotNull(layer); - - // Set - layer.setProperties( - textSize( - composite( - "FeaturePropertyA", - exponential( - stop(0, 0.3f, textSize(0.9f)) - ).withBase(0.5f) - ).withDefaultValue(textSize(0.3f)) - ) - ); - - // Verify - assertNotNull(layer.getTextSize()); - assertNotNull(layer.getTextSize().getFunction()); - assertEquals(CompositeFunction.class, layer.getTextSize().getFunction().getClass()); - assertEquals("FeaturePropertyA", ((CompositeFunction) layer.getTextSize().getFunction()).getProperty()); - assertEquals(ExponentialStops.class, layer.getTextSize().getFunction().getStops().getClass()); - assertEquals(1, ((ExponentialStops) layer.getTextSize().getFunction().getStops()).size()); - - ExponentialStops<Stop.CompositeValue<Float, Float>, Float> stops = - (ExponentialStops<Stop.CompositeValue<Float, Float>, Float>) layer.getTextSize().getFunction().getStops(); - Stop<Stop.CompositeValue<Float, Float>, Float> stop = stops.iterator().next(); - assertEquals(0f, stop.in.zoom, 0.001); - assertEquals(0.3f, stop.in.value, 0.001f); - assertEquals(0.9f, stop.out, 0.001f); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + textSize( + composite( + "FeaturePropertyA", + exponential( + stop(0, 0.3f, textSize(0.9f)) + ).withBase(0.5f) + ).withDefaultValue(textSize(0.3f)) + ) + ); + + // Verify + assertNotNull(layer.getTextSize()); + assertNotNull(layer.getTextSize().getFunction()); + assertEquals(CompositeFunction.class, layer.getTextSize().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((CompositeFunction) layer.getTextSize().getFunction()).getProperty()); + assertEquals(ExponentialStops.class, layer.getTextSize().getFunction().getStops().getClass()); + assertEquals(1, ((ExponentialStops) layer.getTextSize().getFunction().getStops()).size()); + + ExponentialStops<Stop.CompositeValue<Float, Float>, Float> stops = + (ExponentialStops<Stop.CompositeValue<Float, Float>, Float>) layer.getTextSize().getFunction().getStops(); + Stop<Stop.CompositeValue<Float, Float>, Float> stop = stops.iterator().next(); + assertEquals(0f, stop.in.zoom, 0.001); + assertEquals(0.3f, stop.in.value, 0.001f); + assertEquals(0.9f, stop.out, 0.001f); + } + }); } @Test @@ -1344,11 +1649,16 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("text-max-width"); - assertNotNull(layer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); - // Set and Get - layer.setProperties(textMaxWidth(0.3f)); - assertEquals((Float) layer.getTextMaxWidth().getValue(), (Float) 0.3f); + // Set and Get + layer.setProperties(textMaxWidth(0.3f)); + assertEquals((Float) layer.getTextMaxWidth().getValue(), (Float) 0.3f); + } + }); } @Test @@ -1356,26 +1666,31 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("text-max-width"); - assertNotNull(layer); - - // Set - layer.setProperties( - textMaxWidth( - zoom( - exponential( - stop(2, textMaxWidth(0.3f)) - ).withBase(0.5f) - ) - ) - ); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + textMaxWidth( + zoom( + exponential( + stop(2, textMaxWidth(0.3f)) + ).withBase(0.5f) + ) + ) + ); - // Verify - assertNotNull(layer.getTextMaxWidth()); - assertNotNull(layer.getTextMaxWidth().getFunction()); - assertEquals(CameraFunction.class, layer.getTextMaxWidth().getFunction().getClass()); - assertEquals(ExponentialStops.class, layer.getTextMaxWidth().getFunction().getStops().getClass()); - assertEquals(0.5f, ((ExponentialStops) layer.getTextMaxWidth().getFunction().getStops()).getBase(), 0.001); - assertEquals(1, ((ExponentialStops) layer.getTextMaxWidth().getFunction().getStops()).size()); + // Verify + assertNotNull(layer.getTextMaxWidth()); + assertNotNull(layer.getTextMaxWidth().getFunction()); + assertEquals(CameraFunction.class, layer.getTextMaxWidth().getFunction().getClass()); + assertEquals(ExponentialStops.class, layer.getTextMaxWidth().getFunction().getStops().getClass()); + assertEquals(0.5f, ((ExponentialStops) layer.getTextMaxWidth().getFunction().getStops()).getBase(), 0.001); + assertEquals(1, ((ExponentialStops) layer.getTextMaxWidth().getFunction().getStops()).size()); + } + }); } @Test @@ -1383,11 +1698,16 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("text-line-height"); - assertNotNull(layer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); - // Set and Get - layer.setProperties(textLineHeight(0.3f)); - assertEquals((Float) layer.getTextLineHeight().getValue(), (Float) 0.3f); + // Set and Get + layer.setProperties(textLineHeight(0.3f)); + assertEquals((Float) layer.getTextLineHeight().getValue(), (Float) 0.3f); + } + }); } @Test @@ -1395,26 +1715,31 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("text-line-height"); - assertNotNull(layer); - - // Set - layer.setProperties( - textLineHeight( - zoom( - exponential( - stop(2, textLineHeight(0.3f)) - ).withBase(0.5f) - ) - ) - ); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + textLineHeight( + zoom( + exponential( + stop(2, textLineHeight(0.3f)) + ).withBase(0.5f) + ) + ) + ); - // Verify - assertNotNull(layer.getTextLineHeight()); - assertNotNull(layer.getTextLineHeight().getFunction()); - assertEquals(CameraFunction.class, layer.getTextLineHeight().getFunction().getClass()); - assertEquals(ExponentialStops.class, layer.getTextLineHeight().getFunction().getStops().getClass()); - assertEquals(0.5f, ((ExponentialStops) layer.getTextLineHeight().getFunction().getStops()).getBase(), 0.001); - assertEquals(1, ((ExponentialStops) layer.getTextLineHeight().getFunction().getStops()).size()); + // Verify + assertNotNull(layer.getTextLineHeight()); + assertNotNull(layer.getTextLineHeight().getFunction()); + assertEquals(CameraFunction.class, layer.getTextLineHeight().getFunction().getClass()); + assertEquals(ExponentialStops.class, layer.getTextLineHeight().getFunction().getStops().getClass()); + assertEquals(0.5f, ((ExponentialStops) layer.getTextLineHeight().getFunction().getStops()).getBase(), 0.001); + assertEquals(1, ((ExponentialStops) layer.getTextLineHeight().getFunction().getStops()).size()); + } + }); } @Test @@ -1422,11 +1747,16 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("text-letter-spacing"); - assertNotNull(layer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); - // Set and Get - layer.setProperties(textLetterSpacing(0.3f)); - assertEquals((Float) layer.getTextLetterSpacing().getValue(), (Float) 0.3f); + // Set and Get + layer.setProperties(textLetterSpacing(0.3f)); + assertEquals((Float) layer.getTextLetterSpacing().getValue(), (Float) 0.3f); + } + }); } @Test @@ -1434,26 +1764,31 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("text-letter-spacing"); - assertNotNull(layer); - - // Set - layer.setProperties( - textLetterSpacing( - zoom( - exponential( - stop(2, textLetterSpacing(0.3f)) - ).withBase(0.5f) - ) - ) - ); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + textLetterSpacing( + zoom( + exponential( + stop(2, textLetterSpacing(0.3f)) + ).withBase(0.5f) + ) + ) + ); - // Verify - assertNotNull(layer.getTextLetterSpacing()); - assertNotNull(layer.getTextLetterSpacing().getFunction()); - assertEquals(CameraFunction.class, layer.getTextLetterSpacing().getFunction().getClass()); - assertEquals(ExponentialStops.class, layer.getTextLetterSpacing().getFunction().getStops().getClass()); - assertEquals(0.5f, ((ExponentialStops) layer.getTextLetterSpacing().getFunction().getStops()).getBase(), 0.001); - assertEquals(1, ((ExponentialStops) layer.getTextLetterSpacing().getFunction().getStops()).size()); + // Verify + assertNotNull(layer.getTextLetterSpacing()); + assertNotNull(layer.getTextLetterSpacing().getFunction()); + assertEquals(CameraFunction.class, layer.getTextLetterSpacing().getFunction().getClass()); + assertEquals(ExponentialStops.class, layer.getTextLetterSpacing().getFunction().getStops().getClass()); + assertEquals(0.5f, ((ExponentialStops) layer.getTextLetterSpacing().getFunction().getStops()).getBase(), 0.001); + assertEquals(1, ((ExponentialStops) layer.getTextLetterSpacing().getFunction().getStops()).size()); + } + }); } @Test @@ -1461,11 +1796,16 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("text-justify"); - assertNotNull(layer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); - // Set and Get - layer.setProperties(textJustify(TEXT_JUSTIFY_LEFT)); - assertEquals((String) layer.getTextJustify().getValue(), (String) TEXT_JUSTIFY_LEFT); + // Set and Get + layer.setProperties(textJustify(TEXT_JUSTIFY_LEFT)); + assertEquals((String) layer.getTextJustify().getValue(), (String) TEXT_JUSTIFY_LEFT); + } + }); } @Test @@ -1473,25 +1813,30 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("text-justify"); - assertNotNull(layer); - - // Set - layer.setProperties( - textJustify( - zoom( - interval( - stop(2, textJustify(TEXT_JUSTIFY_LEFT)) + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + textJustify( + zoom( + interval( + stop(2, textJustify(TEXT_JUSTIFY_LEFT)) + ) + ) ) - ) - ) - ); + ); - // Verify - assertNotNull(layer.getTextJustify()); - assertNotNull(layer.getTextJustify().getFunction()); - assertEquals(CameraFunction.class, layer.getTextJustify().getFunction().getClass()); - assertEquals(IntervalStops.class, layer.getTextJustify().getFunction().getStops().getClass()); - assertEquals(1, ((IntervalStops) layer.getTextJustify().getFunction().getStops()).size()); + // Verify + assertNotNull(layer.getTextJustify()); + assertNotNull(layer.getTextJustify().getFunction()); + assertEquals(CameraFunction.class, layer.getTextJustify().getFunction().getClass()); + assertEquals(IntervalStops.class, layer.getTextJustify().getFunction().getStops().getClass()); + assertEquals(1, ((IntervalStops) layer.getTextJustify().getFunction().getStops()).size()); + } + }); } @Test @@ -1499,11 +1844,16 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("text-anchor"); - assertNotNull(layer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); - // Set and Get - layer.setProperties(textAnchor(TEXT_ANCHOR_CENTER)); - assertEquals((String) layer.getTextAnchor().getValue(), (String) TEXT_ANCHOR_CENTER); + // Set and Get + layer.setProperties(textAnchor(TEXT_ANCHOR_CENTER)); + assertEquals((String) layer.getTextAnchor().getValue(), (String) TEXT_ANCHOR_CENTER); + } + }); } @Test @@ -1511,25 +1861,30 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("text-anchor"); - assertNotNull(layer); - - // Set - layer.setProperties( - textAnchor( - zoom( - interval( - stop(2, textAnchor(TEXT_ANCHOR_CENTER)) + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + textAnchor( + zoom( + interval( + stop(2, textAnchor(TEXT_ANCHOR_CENTER)) + ) + ) ) - ) - ) - ); + ); - // Verify - assertNotNull(layer.getTextAnchor()); - assertNotNull(layer.getTextAnchor().getFunction()); - assertEquals(CameraFunction.class, layer.getTextAnchor().getFunction().getClass()); - assertEquals(IntervalStops.class, layer.getTextAnchor().getFunction().getStops().getClass()); - assertEquals(1, ((IntervalStops) layer.getTextAnchor().getFunction().getStops()).size()); + // Verify + assertNotNull(layer.getTextAnchor()); + assertNotNull(layer.getTextAnchor().getFunction()); + assertEquals(CameraFunction.class, layer.getTextAnchor().getFunction().getClass()); + assertEquals(IntervalStops.class, layer.getTextAnchor().getFunction().getStops().getClass()); + assertEquals(1, ((IntervalStops) layer.getTextAnchor().getFunction().getStops()).size()); + } + }); } @Test @@ -1537,11 +1892,16 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("text-max-angle"); - assertNotNull(layer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); - // Set and Get - layer.setProperties(textMaxAngle(0.3f)); - assertEquals((Float) layer.getTextMaxAngle().getValue(), (Float) 0.3f); + // Set and Get + layer.setProperties(textMaxAngle(0.3f)); + assertEquals((Float) layer.getTextMaxAngle().getValue(), (Float) 0.3f); + } + }); } @Test @@ -1549,26 +1909,31 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("text-max-angle"); - assertNotNull(layer); - - // Set - layer.setProperties( - textMaxAngle( - zoom( - exponential( - stop(2, textMaxAngle(0.3f)) - ).withBase(0.5f) - ) - ) - ); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + textMaxAngle( + zoom( + exponential( + stop(2, textMaxAngle(0.3f)) + ).withBase(0.5f) + ) + ) + ); - // Verify - assertNotNull(layer.getTextMaxAngle()); - assertNotNull(layer.getTextMaxAngle().getFunction()); - assertEquals(CameraFunction.class, layer.getTextMaxAngle().getFunction().getClass()); - assertEquals(ExponentialStops.class, layer.getTextMaxAngle().getFunction().getStops().getClass()); - assertEquals(0.5f, ((ExponentialStops) layer.getTextMaxAngle().getFunction().getStops()).getBase(), 0.001); - assertEquals(1, ((ExponentialStops) layer.getTextMaxAngle().getFunction().getStops()).size()); + // Verify + assertNotNull(layer.getTextMaxAngle()); + assertNotNull(layer.getTextMaxAngle().getFunction()); + assertEquals(CameraFunction.class, layer.getTextMaxAngle().getFunction().getClass()); + assertEquals(ExponentialStops.class, layer.getTextMaxAngle().getFunction().getStops().getClass()); + assertEquals(0.5f, ((ExponentialStops) layer.getTextMaxAngle().getFunction().getStops()).getBase(), 0.001); + assertEquals(1, ((ExponentialStops) layer.getTextMaxAngle().getFunction().getStops()).size()); + } + }); } @Test @@ -1576,11 +1941,16 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("text-rotate"); - assertNotNull(layer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); - // Set and Get - layer.setProperties(textRotate(0.3f)); - assertEquals((Float) layer.getTextRotate().getValue(), (Float) 0.3f); + // Set and Get + layer.setProperties(textRotate(0.3f)); + assertEquals((Float) layer.getTextRotate().getValue(), (Float) 0.3f); + } + }); } @Test @@ -1588,26 +1958,31 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("text-rotate"); - assertNotNull(layer); - - // Set - layer.setProperties( - textRotate( - zoom( - exponential( - stop(2, textRotate(0.3f)) - ).withBase(0.5f) - ) - ) - ); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + textRotate( + zoom( + exponential( + stop(2, textRotate(0.3f)) + ).withBase(0.5f) + ) + ) + ); - // Verify - assertNotNull(layer.getTextRotate()); - assertNotNull(layer.getTextRotate().getFunction()); - assertEquals(CameraFunction.class, layer.getTextRotate().getFunction().getClass()); - assertEquals(ExponentialStops.class, layer.getTextRotate().getFunction().getStops().getClass()); - assertEquals(0.5f, ((ExponentialStops) layer.getTextRotate().getFunction().getStops()).getBase(), 0.001); - assertEquals(1, ((ExponentialStops) layer.getTextRotate().getFunction().getStops()).size()); + // Verify + assertNotNull(layer.getTextRotate()); + assertNotNull(layer.getTextRotate().getFunction()); + assertEquals(CameraFunction.class, layer.getTextRotate().getFunction().getClass()); + assertEquals(ExponentialStops.class, layer.getTextRotate().getFunction().getStops().getClass()); + assertEquals(0.5f, ((ExponentialStops) layer.getTextRotate().getFunction().getStops()).getBase(), 0.001); + assertEquals(1, ((ExponentialStops) layer.getTextRotate().getFunction().getStops()).size()); + } + }); } @Test @@ -1615,19 +1990,24 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("text-rotate"); - assertNotNull(layer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); - // Set - layer.setProperties( - textRotate(property("FeaturePropertyA", Stops.<Float>identity())) - ); + // Set + layer.setProperties( + textRotate(property("FeaturePropertyA", Stops.<Float>identity())) + ); - // Verify - assertNotNull(layer.getTextRotate()); - assertNotNull(layer.getTextRotate().getFunction()); - assertEquals(SourceFunction.class, layer.getTextRotate().getFunction().getClass()); - assertEquals("FeaturePropertyA", ((SourceFunction) layer.getTextRotate().getFunction()).getProperty()); - assertEquals(IdentityStops.class, layer.getTextRotate().getFunction().getStops().getClass()); + // Verify + assertNotNull(layer.getTextRotate()); + assertNotNull(layer.getTextRotate().getFunction()); + assertEquals(SourceFunction.class, layer.getTextRotate().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getTextRotate().getFunction()).getProperty()); + assertEquals(IdentityStops.class, layer.getTextRotate().getFunction().getStops().getClass()); + } + }); } @Test @@ -1635,26 +2015,31 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("text-rotate"); - assertNotNull(layer); - - // Set - layer.setProperties( - textRotate( - property( - "FeaturePropertyA", - exponential( - stop(0.3f, textRotate(0.3f)) - ).withBase(0.5f) - ) - ) - ); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + textRotate( + property( + "FeaturePropertyA", + exponential( + stop(0.3f, textRotate(0.3f)) + ).withBase(0.5f) + ) + ) + ); - // Verify - assertNotNull(layer.getTextRotate()); - assertNotNull(layer.getTextRotate().getFunction()); - assertEquals(SourceFunction.class, layer.getTextRotate().getFunction().getClass()); - assertEquals("FeaturePropertyA", ((SourceFunction) layer.getTextRotate().getFunction()).getProperty()); - assertEquals(ExponentialStops.class, layer.getTextRotate().getFunction().getStops().getClass()); + // Verify + assertNotNull(layer.getTextRotate()); + assertNotNull(layer.getTextRotate().getFunction()); + assertEquals(SourceFunction.class, layer.getTextRotate().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getTextRotate().getFunction()).getProperty()); + assertEquals(ExponentialStops.class, layer.getTextRotate().getFunction().getStops().getClass()); + } + }); } @Test @@ -1662,29 +2047,35 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("text-rotate"); - assertNotNull(layer); - - // Set - layer.setProperties( - textRotate( - property( - "FeaturePropertyA", - categorical( - stop(1.0f, textRotate(0.3f)) + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + textRotate( + property( + "FeaturePropertyA", + categorical( + stop(1.0f, textRotate(0.3f)) + ) + ).withDefaultValue(textRotate(0.3f)) ) - ).withDefaultValue(textRotate(0.3f)) - ) - ); + ); + + // Verify + assertNotNull(layer.getTextRotate()); + assertNotNull(layer.getTextRotate().getFunction()); + assertEquals(SourceFunction.class, layer.getTextRotate().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getTextRotate().getFunction()).getProperty()); + assertEquals(CategoricalStops.class, layer.getTextRotate().getFunction().getStops().getClass()); + assertNotNull(((SourceFunction) layer.getTextRotate().getFunction()).getDefaultValue()); + assertNotNull(((SourceFunction) layer.getTextRotate().getFunction()).getDefaultValue().getValue()); + assertEquals(0.3f, ((SourceFunction) layer.getTextRotate().getFunction()).getDefaultValue().getValue()); + } + }); - // Verify - assertNotNull(layer.getTextRotate()); - assertNotNull(layer.getTextRotate().getFunction()); - assertEquals(SourceFunction.class, layer.getTextRotate().getFunction().getClass()); - assertEquals("FeaturePropertyA", ((SourceFunction) layer.getTextRotate().getFunction()).getProperty()); - assertEquals(CategoricalStops.class, layer.getTextRotate().getFunction().getStops().getClass()); - assertNotNull(((SourceFunction) layer.getTextRotate().getFunction()).getDefaultValue()); - assertNotNull(((SourceFunction) layer.getTextRotate().getFunction()).getDefaultValue().getValue()); - assertEquals(0.3f, ((SourceFunction) layer.getTextRotate().getFunction()).getDefaultValue().getValue()); } @Test @@ -1692,34 +2083,39 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("text-rotate"); - assertNotNull(layer); - - // Set - layer.setProperties( - textRotate( - composite( - "FeaturePropertyA", - exponential( - stop(0, 0.3f, textRotate(0.9f)) - ).withBase(0.5f) - ).withDefaultValue(textRotate(0.3f)) - ) - ); - - // Verify - assertNotNull(layer.getTextRotate()); - assertNotNull(layer.getTextRotate().getFunction()); - assertEquals(CompositeFunction.class, layer.getTextRotate().getFunction().getClass()); - assertEquals("FeaturePropertyA", ((CompositeFunction) layer.getTextRotate().getFunction()).getProperty()); - assertEquals(ExponentialStops.class, layer.getTextRotate().getFunction().getStops().getClass()); - assertEquals(1, ((ExponentialStops) layer.getTextRotate().getFunction().getStops()).size()); - - ExponentialStops<Stop.CompositeValue<Float, Float>, Float> stops = - (ExponentialStops<Stop.CompositeValue<Float, Float>, Float>) layer.getTextRotate().getFunction().getStops(); - Stop<Stop.CompositeValue<Float, Float>, Float> stop = stops.iterator().next(); - assertEquals(0f, stop.in.zoom, 0.001); - assertEquals(0.3f, stop.in.value, 0.001f); - assertEquals(0.9f, stop.out, 0.001f); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + textRotate( + composite( + "FeaturePropertyA", + exponential( + stop(0, 0.3f, textRotate(0.9f)) + ).withBase(0.5f) + ).withDefaultValue(textRotate(0.3f)) + ) + ); + + // Verify + assertNotNull(layer.getTextRotate()); + assertNotNull(layer.getTextRotate().getFunction()); + assertEquals(CompositeFunction.class, layer.getTextRotate().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((CompositeFunction) layer.getTextRotate().getFunction()).getProperty()); + assertEquals(ExponentialStops.class, layer.getTextRotate().getFunction().getStops().getClass()); + assertEquals(1, ((ExponentialStops) layer.getTextRotate().getFunction().getStops()).size()); + + ExponentialStops<Stop.CompositeValue<Float, Float>, Float> stops = + (ExponentialStops<Stop.CompositeValue<Float, Float>, Float>) layer.getTextRotate().getFunction().getStops(); + Stop<Stop.CompositeValue<Float, Float>, Float> stop = stops.iterator().next(); + assertEquals(0f, stop.in.zoom, 0.001); + assertEquals(0.3f, stop.in.value, 0.001f); + assertEquals(0.9f, stop.out, 0.001f); + } + }); } @Test @@ -1727,11 +2123,16 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("text-padding"); - assertNotNull(layer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); - // Set and Get - layer.setProperties(textPadding(0.3f)); - assertEquals((Float) layer.getTextPadding().getValue(), (Float) 0.3f); + // Set and Get + layer.setProperties(textPadding(0.3f)); + assertEquals((Float) layer.getTextPadding().getValue(), (Float) 0.3f); + } + }); } @Test @@ -1739,26 +2140,31 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("text-padding"); - assertNotNull(layer); - - // Set - layer.setProperties( - textPadding( - zoom( - exponential( - stop(2, textPadding(0.3f)) - ).withBase(0.5f) - ) - ) - ); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + textPadding( + zoom( + exponential( + stop(2, textPadding(0.3f)) + ).withBase(0.5f) + ) + ) + ); - // Verify - assertNotNull(layer.getTextPadding()); - assertNotNull(layer.getTextPadding().getFunction()); - assertEquals(CameraFunction.class, layer.getTextPadding().getFunction().getClass()); - assertEquals(ExponentialStops.class, layer.getTextPadding().getFunction().getStops().getClass()); - assertEquals(0.5f, ((ExponentialStops) layer.getTextPadding().getFunction().getStops()).getBase(), 0.001); - assertEquals(1, ((ExponentialStops) layer.getTextPadding().getFunction().getStops()).size()); + // Verify + assertNotNull(layer.getTextPadding()); + assertNotNull(layer.getTextPadding().getFunction()); + assertEquals(CameraFunction.class, layer.getTextPadding().getFunction().getClass()); + assertEquals(ExponentialStops.class, layer.getTextPadding().getFunction().getStops().getClass()); + assertEquals(0.5f, ((ExponentialStops) layer.getTextPadding().getFunction().getStops()).getBase(), 0.001); + assertEquals(1, ((ExponentialStops) layer.getTextPadding().getFunction().getStops()).size()); + } + }); } @Test @@ -1766,11 +2172,16 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("text-keep-upright"); - assertNotNull(layer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); - // Set and Get - layer.setProperties(textKeepUpright(true)); - assertEquals((Boolean) layer.getTextKeepUpright().getValue(), (Boolean) true); + // Set and Get + layer.setProperties(textKeepUpright(true)); + assertEquals((Boolean) layer.getTextKeepUpright().getValue(), (Boolean) true); + } + }); } @Test @@ -1778,25 +2189,30 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("text-keep-upright"); - assertNotNull(layer); - - // Set - layer.setProperties( - textKeepUpright( - zoom( - interval( - stop(2, textKeepUpright(true)) + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + textKeepUpright( + zoom( + interval( + stop(2, textKeepUpright(true)) + ) + ) ) - ) - ) - ); + ); - // Verify - assertNotNull(layer.getTextKeepUpright()); - assertNotNull(layer.getTextKeepUpright().getFunction()); - assertEquals(CameraFunction.class, layer.getTextKeepUpright().getFunction().getClass()); - assertEquals(IntervalStops.class, layer.getTextKeepUpright().getFunction().getStops().getClass()); - assertEquals(1, ((IntervalStops) layer.getTextKeepUpright().getFunction().getStops()).size()); + // Verify + assertNotNull(layer.getTextKeepUpright()); + assertNotNull(layer.getTextKeepUpright().getFunction()); + assertEquals(CameraFunction.class, layer.getTextKeepUpright().getFunction().getClass()); + assertEquals(IntervalStops.class, layer.getTextKeepUpright().getFunction().getStops().getClass()); + assertEquals(1, ((IntervalStops) layer.getTextKeepUpright().getFunction().getStops()).size()); + } + }); } @Test @@ -1804,11 +2220,16 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("text-transform"); - assertNotNull(layer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); - // Set and Get - layer.setProperties(textTransform(TEXT_TRANSFORM_NONE)); - assertEquals((String) layer.getTextTransform().getValue(), (String) TEXT_TRANSFORM_NONE); + // Set and Get + layer.setProperties(textTransform(TEXT_TRANSFORM_NONE)); + assertEquals((String) layer.getTextTransform().getValue(), (String) TEXT_TRANSFORM_NONE); + } + }); } @Test @@ -1816,25 +2237,30 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("text-transform"); - assertNotNull(layer); - - // Set - layer.setProperties( - textTransform( - zoom( - interval( - stop(2, textTransform(TEXT_TRANSFORM_NONE)) + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + textTransform( + zoom( + interval( + stop(2, textTransform(TEXT_TRANSFORM_NONE)) + ) + ) ) - ) - ) - ); + ); - // Verify - assertNotNull(layer.getTextTransform()); - assertNotNull(layer.getTextTransform().getFunction()); - assertEquals(CameraFunction.class, layer.getTextTransform().getFunction().getClass()); - assertEquals(IntervalStops.class, layer.getTextTransform().getFunction().getStops().getClass()); - assertEquals(1, ((IntervalStops) layer.getTextTransform().getFunction().getStops()).size()); + // Verify + assertNotNull(layer.getTextTransform()); + assertNotNull(layer.getTextTransform().getFunction()); + assertEquals(CameraFunction.class, layer.getTextTransform().getFunction().getClass()); + assertEquals(IntervalStops.class, layer.getTextTransform().getFunction().getStops().getClass()); + assertEquals(1, ((IntervalStops) layer.getTextTransform().getFunction().getStops()).size()); + } + }); } @Test @@ -1842,19 +2268,24 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("text-transform"); - assertNotNull(layer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); - // Set - layer.setProperties( - textTransform(property("FeaturePropertyA", Stops.<String>identity())) - ); + // Set + layer.setProperties( + textTransform(property("FeaturePropertyA", Stops.<String>identity())) + ); - // Verify - assertNotNull(layer.getTextTransform()); - assertNotNull(layer.getTextTransform().getFunction()); - assertEquals(SourceFunction.class, layer.getTextTransform().getFunction().getClass()); - assertEquals("FeaturePropertyA", ((SourceFunction) layer.getTextTransform().getFunction()).getProperty()); - assertEquals(IdentityStops.class, layer.getTextTransform().getFunction().getStops().getClass()); + // Verify + assertNotNull(layer.getTextTransform()); + assertNotNull(layer.getTextTransform().getFunction()); + assertEquals(SourceFunction.class, layer.getTextTransform().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getTextTransform().getFunction()).getProperty()); + assertEquals(IdentityStops.class, layer.getTextTransform().getFunction().getStops().getClass()); + } + }); } @Test @@ -1862,26 +2293,31 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("text-transform"); - assertNotNull(layer); - - // Set - layer.setProperties( - textTransform( - property( - "FeaturePropertyA", - interval( - stop(1, textTransform(TEXT_TRANSFORM_NONE)) + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + textTransform( + property( + "FeaturePropertyA", + interval( + stop(1, textTransform(TEXT_TRANSFORM_NONE)) + ) + ) ) - ) - ) - ); + ); - // Verify - assertNotNull(layer.getTextTransform()); - assertNotNull(layer.getTextTransform().getFunction()); - assertEquals(SourceFunction.class, layer.getTextTransform().getFunction().getClass()); - assertEquals("FeaturePropertyA", ((SourceFunction) layer.getTextTransform().getFunction()).getProperty()); - assertEquals(IntervalStops.class, layer.getTextTransform().getFunction().getStops().getClass()); + // Verify + assertNotNull(layer.getTextTransform()); + assertNotNull(layer.getTextTransform().getFunction()); + assertEquals(SourceFunction.class, layer.getTextTransform().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getTextTransform().getFunction()).getProperty()); + assertEquals(IntervalStops.class, layer.getTextTransform().getFunction().getStops().getClass()); + } + }); } @Test @@ -1889,11 +2325,16 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("text-offset"); - assertNotNull(layer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); - // Set and Get - layer.setProperties(textOffset(new Float[]{0f,0f})); - assertEquals((Float[]) layer.getTextOffset().getValue(), (Float[]) new Float[]{0f,0f}); + // Set and Get + layer.setProperties(textOffset(new Float[] {0f, 0f})); + assertEquals((Float[]) layer.getTextOffset().getValue(), (Float[]) new Float[] {0f, 0f}); + } + }); } @Test @@ -1901,26 +2342,31 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("text-offset"); - assertNotNull(layer); - - // Set - layer.setProperties( - textOffset( - zoom( - exponential( - stop(2, textOffset(new Float[]{0f,0f})) - ).withBase(0.5f) - ) - ) - ); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + textOffset( + zoom( + exponential( + stop(2, textOffset(new Float[] {0f, 0f})) + ).withBase(0.5f) + ) + ) + ); - // Verify - assertNotNull(layer.getTextOffset()); - assertNotNull(layer.getTextOffset().getFunction()); - assertEquals(CameraFunction.class, layer.getTextOffset().getFunction().getClass()); - assertEquals(ExponentialStops.class, layer.getTextOffset().getFunction().getStops().getClass()); - assertEquals(0.5f, ((ExponentialStops) layer.getTextOffset().getFunction().getStops()).getBase(), 0.001); - assertEquals(1, ((ExponentialStops) layer.getTextOffset().getFunction().getStops()).size()); + // Verify + assertNotNull(layer.getTextOffset()); + assertNotNull(layer.getTextOffset().getFunction()); + assertEquals(CameraFunction.class, layer.getTextOffset().getFunction().getClass()); + assertEquals(ExponentialStops.class, layer.getTextOffset().getFunction().getStops().getClass()); + assertEquals(0.5f, ((ExponentialStops) layer.getTextOffset().getFunction().getStops()).getBase(), 0.001); + assertEquals(1, ((ExponentialStops) layer.getTextOffset().getFunction().getStops()).size()); + } + }); } @Test @@ -1928,19 +2374,24 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("text-offset"); - assertNotNull(layer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); - // Set - layer.setProperties( - textOffset(property("FeaturePropertyA", Stops.<Float[]>identity())) - ); + // Set + layer.setProperties( + textOffset(property("FeaturePropertyA", Stops.<Float[]>identity())) + ); - // Verify - assertNotNull(layer.getTextOffset()); - assertNotNull(layer.getTextOffset().getFunction()); - assertEquals(SourceFunction.class, layer.getTextOffset().getFunction().getClass()); - assertEquals("FeaturePropertyA", ((SourceFunction) layer.getTextOffset().getFunction()).getProperty()); - assertEquals(IdentityStops.class, layer.getTextOffset().getFunction().getStops().getClass()); + // Verify + assertNotNull(layer.getTextOffset()); + assertNotNull(layer.getTextOffset().getFunction()); + assertEquals(SourceFunction.class, layer.getTextOffset().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getTextOffset().getFunction()).getProperty()); + assertEquals(IdentityStops.class, layer.getTextOffset().getFunction().getStops().getClass()); + } + }); } @Test @@ -1948,26 +2399,31 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("text-offset"); - assertNotNull(layer); - - // Set - layer.setProperties( - textOffset( - property( - "FeaturePropertyA", - interval( - stop(1, textOffset(new Float[]{0f,0f})) + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + textOffset( + property( + "FeaturePropertyA", + interval( + stop(1, textOffset(new Float[] {0f, 0f})) + ) + ) ) - ) - ) - ); + ); - // Verify - assertNotNull(layer.getTextOffset()); - assertNotNull(layer.getTextOffset().getFunction()); - assertEquals(SourceFunction.class, layer.getTextOffset().getFunction().getClass()); - assertEquals("FeaturePropertyA", ((SourceFunction) layer.getTextOffset().getFunction()).getProperty()); - assertEquals(IntervalStops.class, layer.getTextOffset().getFunction().getStops().getClass()); + // Verify + assertNotNull(layer.getTextOffset()); + assertNotNull(layer.getTextOffset().getFunction()); + assertEquals(SourceFunction.class, layer.getTextOffset().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getTextOffset().getFunction()).getProperty()); + assertEquals(IntervalStops.class, layer.getTextOffset().getFunction().getStops().getClass()); + } + }); } @Test @@ -1975,11 +2431,16 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("text-allow-overlap"); - assertNotNull(layer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); - // Set and Get - layer.setProperties(textAllowOverlap(true)); - assertEquals((Boolean) layer.getTextAllowOverlap().getValue(), (Boolean) true); + // Set and Get + layer.setProperties(textAllowOverlap(true)); + assertEquals((Boolean) layer.getTextAllowOverlap().getValue(), (Boolean) true); + } + }); } @Test @@ -1987,25 +2448,30 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("text-allow-overlap"); - assertNotNull(layer); - - // Set - layer.setProperties( - textAllowOverlap( - zoom( - interval( - stop(2, textAllowOverlap(true)) + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + textAllowOverlap( + zoom( + interval( + stop(2, textAllowOverlap(true)) + ) + ) ) - ) - ) - ); + ); - // Verify - assertNotNull(layer.getTextAllowOverlap()); - assertNotNull(layer.getTextAllowOverlap().getFunction()); - assertEquals(CameraFunction.class, layer.getTextAllowOverlap().getFunction().getClass()); - assertEquals(IntervalStops.class, layer.getTextAllowOverlap().getFunction().getStops().getClass()); - assertEquals(1, ((IntervalStops) layer.getTextAllowOverlap().getFunction().getStops()).size()); + // Verify + assertNotNull(layer.getTextAllowOverlap()); + assertNotNull(layer.getTextAllowOverlap().getFunction()); + assertEquals(CameraFunction.class, layer.getTextAllowOverlap().getFunction().getClass()); + assertEquals(IntervalStops.class, layer.getTextAllowOverlap().getFunction().getStops().getClass()); + assertEquals(1, ((IntervalStops) layer.getTextAllowOverlap().getFunction().getStops()).size()); + } + }); } @Test @@ -2013,11 +2479,16 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("text-ignore-placement"); - assertNotNull(layer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); - // Set and Get - layer.setProperties(textIgnorePlacement(true)); - assertEquals((Boolean) layer.getTextIgnorePlacement().getValue(), (Boolean) true); + // Set and Get + layer.setProperties(textIgnorePlacement(true)); + assertEquals((Boolean) layer.getTextIgnorePlacement().getValue(), (Boolean) true); + } + }); } @Test @@ -2025,25 +2496,30 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("text-ignore-placement"); - assertNotNull(layer); - - // Set - layer.setProperties( - textIgnorePlacement( - zoom( - interval( - stop(2, textIgnorePlacement(true)) + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + textIgnorePlacement( + zoom( + interval( + stop(2, textIgnorePlacement(true)) + ) + ) ) - ) - ) - ); + ); - // Verify - assertNotNull(layer.getTextIgnorePlacement()); - assertNotNull(layer.getTextIgnorePlacement().getFunction()); - assertEquals(CameraFunction.class, layer.getTextIgnorePlacement().getFunction().getClass()); - assertEquals(IntervalStops.class, layer.getTextIgnorePlacement().getFunction().getStops().getClass()); - assertEquals(1, ((IntervalStops) layer.getTextIgnorePlacement().getFunction().getStops()).size()); + // Verify + assertNotNull(layer.getTextIgnorePlacement()); + assertNotNull(layer.getTextIgnorePlacement().getFunction()); + assertEquals(CameraFunction.class, layer.getTextIgnorePlacement().getFunction().getClass()); + assertEquals(IntervalStops.class, layer.getTextIgnorePlacement().getFunction().getStops().getClass()); + assertEquals(1, ((IntervalStops) layer.getTextIgnorePlacement().getFunction().getStops()).size()); + } + }); } @Test @@ -2051,11 +2527,16 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("text-optional"); - assertNotNull(layer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); - // Set and Get - layer.setProperties(textOptional(true)); - assertEquals((Boolean) layer.getTextOptional().getValue(), (Boolean) true); + // Set and Get + layer.setProperties(textOptional(true)); + assertEquals((Boolean) layer.getTextOptional().getValue(), (Boolean) true); + } + }); } @Test @@ -2063,25 +2544,30 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("text-optional"); - assertNotNull(layer); - - // Set - layer.setProperties( - textOptional( - zoom( - interval( - stop(2, textOptional(true)) + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + textOptional( + zoom( + interval( + stop(2, textOptional(true)) + ) + ) ) - ) - ) - ); + ); - // Verify - assertNotNull(layer.getTextOptional()); - assertNotNull(layer.getTextOptional().getFunction()); - assertEquals(CameraFunction.class, layer.getTextOptional().getFunction().getClass()); - assertEquals(IntervalStops.class, layer.getTextOptional().getFunction().getStops().getClass()); - assertEquals(1, ((IntervalStops) layer.getTextOptional().getFunction().getStops()).size()); + // Verify + assertNotNull(layer.getTextOptional()); + assertNotNull(layer.getTextOptional().getFunction()); + assertEquals(CameraFunction.class, layer.getTextOptional().getFunction().getClass()); + assertEquals(IntervalStops.class, layer.getTextOptional().getFunction().getStops().getClass()); + assertEquals(1, ((IntervalStops) layer.getTextOptional().getFunction().getStops()).size()); + } + }); } @Test @@ -2089,12 +2575,17 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("icon-opacityTransitionOptions"); - assertNotNull(layer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); - // Set and Get - TransitionOptions options = new TransitionOptions(300, 100); - layer.setIconOpacityTransition(options); - assertEquals(layer.getIconOpacityTransition(), options); + // Set and Get + TransitionOptions options = new TransitionOptions(300, 100); + layer.setIconOpacityTransition(options); + assertEquals(layer.getIconOpacityTransition(), options); + } + }); } @Test @@ -2102,11 +2593,16 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("icon-opacity"); - assertNotNull(layer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); - // Set and Get - layer.setProperties(iconOpacity(0.3f)); - assertEquals((Float) layer.getIconOpacity().getValue(), (Float) 0.3f); + // Set and Get + layer.setProperties(iconOpacity(0.3f)); + assertEquals((Float) layer.getIconOpacity().getValue(), (Float) 0.3f); + } + }); } @Test @@ -2114,26 +2610,31 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("icon-opacity"); - assertNotNull(layer); - - // Set - layer.setProperties( - iconOpacity( - zoom( - exponential( - stop(2, iconOpacity(0.3f)) - ).withBase(0.5f) - ) - ) - ); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + iconOpacity( + zoom( + exponential( + stop(2, iconOpacity(0.3f)) + ).withBase(0.5f) + ) + ) + ); - // Verify - assertNotNull(layer.getIconOpacity()); - assertNotNull(layer.getIconOpacity().getFunction()); - assertEquals(CameraFunction.class, layer.getIconOpacity().getFunction().getClass()); - assertEquals(ExponentialStops.class, layer.getIconOpacity().getFunction().getStops().getClass()); - assertEquals(0.5f, ((ExponentialStops) layer.getIconOpacity().getFunction().getStops()).getBase(), 0.001); - assertEquals(1, ((ExponentialStops) layer.getIconOpacity().getFunction().getStops()).size()); + // Verify + assertNotNull(layer.getIconOpacity()); + assertNotNull(layer.getIconOpacity().getFunction()); + assertEquals(CameraFunction.class, layer.getIconOpacity().getFunction().getClass()); + assertEquals(ExponentialStops.class, layer.getIconOpacity().getFunction().getStops().getClass()); + assertEquals(0.5f, ((ExponentialStops) layer.getIconOpacity().getFunction().getStops()).getBase(), 0.001); + assertEquals(1, ((ExponentialStops) layer.getIconOpacity().getFunction().getStops()).size()); + } + }); } @Test @@ -2141,19 +2642,24 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("icon-opacity"); - assertNotNull(layer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); - // Set - layer.setProperties( - iconOpacity(property("FeaturePropertyA", Stops.<Float>identity())) - ); + // Set + layer.setProperties( + iconOpacity(property("FeaturePropertyA", Stops.<Float>identity())) + ); - // Verify - assertNotNull(layer.getIconOpacity()); - assertNotNull(layer.getIconOpacity().getFunction()); - assertEquals(SourceFunction.class, layer.getIconOpacity().getFunction().getClass()); - assertEquals("FeaturePropertyA", ((SourceFunction) layer.getIconOpacity().getFunction()).getProperty()); - assertEquals(IdentityStops.class, layer.getIconOpacity().getFunction().getStops().getClass()); + // Verify + assertNotNull(layer.getIconOpacity()); + assertNotNull(layer.getIconOpacity().getFunction()); + assertEquals(SourceFunction.class, layer.getIconOpacity().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getIconOpacity().getFunction()).getProperty()); + assertEquals(IdentityStops.class, layer.getIconOpacity().getFunction().getStops().getClass()); + } + }); } @Test @@ -2161,26 +2667,31 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("icon-opacity"); - assertNotNull(layer); - - // Set - layer.setProperties( - iconOpacity( - property( - "FeaturePropertyA", - exponential( - stop(0.3f, iconOpacity(0.3f)) - ).withBase(0.5f) - ) - ) - ); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + iconOpacity( + property( + "FeaturePropertyA", + exponential( + stop(0.3f, iconOpacity(0.3f)) + ).withBase(0.5f) + ) + ) + ); - // Verify - assertNotNull(layer.getIconOpacity()); - assertNotNull(layer.getIconOpacity().getFunction()); - assertEquals(SourceFunction.class, layer.getIconOpacity().getFunction().getClass()); - assertEquals("FeaturePropertyA", ((SourceFunction) layer.getIconOpacity().getFunction()).getProperty()); - assertEquals(ExponentialStops.class, layer.getIconOpacity().getFunction().getStops().getClass()); + // Verify + assertNotNull(layer.getIconOpacity()); + assertNotNull(layer.getIconOpacity().getFunction()); + assertEquals(SourceFunction.class, layer.getIconOpacity().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getIconOpacity().getFunction()).getProperty()); + assertEquals(ExponentialStops.class, layer.getIconOpacity().getFunction().getStops().getClass()); + } + }); } @Test @@ -2188,29 +2699,35 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("icon-opacity"); - assertNotNull(layer); - - // Set - layer.setProperties( - iconOpacity( - property( - "FeaturePropertyA", - categorical( - stop(1.0f, iconOpacity(0.3f)) + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + iconOpacity( + property( + "FeaturePropertyA", + categorical( + stop(1.0f, iconOpacity(0.3f)) + ) + ).withDefaultValue(iconOpacity(0.3f)) ) - ).withDefaultValue(iconOpacity(0.3f)) - ) - ); + ); + + // Verify + assertNotNull(layer.getIconOpacity()); + assertNotNull(layer.getIconOpacity().getFunction()); + assertEquals(SourceFunction.class, layer.getIconOpacity().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getIconOpacity().getFunction()).getProperty()); + assertEquals(CategoricalStops.class, layer.getIconOpacity().getFunction().getStops().getClass()); + assertNotNull(((SourceFunction) layer.getIconOpacity().getFunction()).getDefaultValue()); + assertNotNull(((SourceFunction) layer.getIconOpacity().getFunction()).getDefaultValue().getValue()); + assertEquals(0.3f, ((SourceFunction) layer.getIconOpacity().getFunction()).getDefaultValue().getValue()); + } + }); - // Verify - assertNotNull(layer.getIconOpacity()); - assertNotNull(layer.getIconOpacity().getFunction()); - assertEquals(SourceFunction.class, layer.getIconOpacity().getFunction().getClass()); - assertEquals("FeaturePropertyA", ((SourceFunction) layer.getIconOpacity().getFunction()).getProperty()); - assertEquals(CategoricalStops.class, layer.getIconOpacity().getFunction().getStops().getClass()); - assertNotNull(((SourceFunction) layer.getIconOpacity().getFunction()).getDefaultValue()); - assertNotNull(((SourceFunction) layer.getIconOpacity().getFunction()).getDefaultValue().getValue()); - assertEquals(0.3f, ((SourceFunction) layer.getIconOpacity().getFunction()).getDefaultValue().getValue()); } @Test @@ -2218,34 +2735,39 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("icon-opacity"); - assertNotNull(layer); - - // Set - layer.setProperties( - iconOpacity( - composite( - "FeaturePropertyA", - exponential( - stop(0, 0.3f, iconOpacity(0.9f)) - ).withBase(0.5f) - ).withDefaultValue(iconOpacity(0.3f)) - ) - ); - - // Verify - assertNotNull(layer.getIconOpacity()); - assertNotNull(layer.getIconOpacity().getFunction()); - assertEquals(CompositeFunction.class, layer.getIconOpacity().getFunction().getClass()); - assertEquals("FeaturePropertyA", ((CompositeFunction) layer.getIconOpacity().getFunction()).getProperty()); - assertEquals(ExponentialStops.class, layer.getIconOpacity().getFunction().getStops().getClass()); - assertEquals(1, ((ExponentialStops) layer.getIconOpacity().getFunction().getStops()).size()); - - ExponentialStops<Stop.CompositeValue<Float, Float>, Float> stops = - (ExponentialStops<Stop.CompositeValue<Float, Float>, Float>) layer.getIconOpacity().getFunction().getStops(); - Stop<Stop.CompositeValue<Float, Float>, Float> stop = stops.iterator().next(); - assertEquals(0f, stop.in.zoom, 0.001); - assertEquals(0.3f, stop.in.value, 0.001f); - assertEquals(0.9f, stop.out, 0.001f); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + iconOpacity( + composite( + "FeaturePropertyA", + exponential( + stop(0, 0.3f, iconOpacity(0.9f)) + ).withBase(0.5f) + ).withDefaultValue(iconOpacity(0.3f)) + ) + ); + + // Verify + assertNotNull(layer.getIconOpacity()); + assertNotNull(layer.getIconOpacity().getFunction()); + assertEquals(CompositeFunction.class, layer.getIconOpacity().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((CompositeFunction) layer.getIconOpacity().getFunction()).getProperty()); + assertEquals(ExponentialStops.class, layer.getIconOpacity().getFunction().getStops().getClass()); + assertEquals(1, ((ExponentialStops) layer.getIconOpacity().getFunction().getStops()).size()); + + ExponentialStops<Stop.CompositeValue<Float, Float>, Float> stops = + (ExponentialStops<Stop.CompositeValue<Float, Float>, Float>) layer.getIconOpacity().getFunction().getStops(); + Stop<Stop.CompositeValue<Float, Float>, Float> stop = stops.iterator().next(); + assertEquals(0f, stop.in.zoom, 0.001); + assertEquals(0.3f, stop.in.value, 0.001f); + assertEquals(0.9f, stop.out, 0.001f); + } + }); } @Test @@ -2253,12 +2775,17 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("icon-colorTransitionOptions"); - assertNotNull(layer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); - // Set and Get - TransitionOptions options = new TransitionOptions(300, 100); - layer.setIconColorTransition(options); - assertEquals(layer.getIconColorTransition(), options); + // Set and Get + TransitionOptions options = new TransitionOptions(300, 100); + layer.setIconColorTransition(options); + assertEquals(layer.getIconColorTransition(), options); + } + }); } @Test @@ -2266,11 +2793,16 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("icon-color"); - assertNotNull(layer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); - // Set and Get - layer.setProperties(iconColor("rgba(0, 0, 0, 1)")); - assertEquals((String) layer.getIconColor().getValue(), (String) "rgba(0, 0, 0, 1)"); + // Set and Get + layer.setProperties(iconColor("rgba(0, 0, 0, 1)")); + assertEquals((String) layer.getIconColor().getValue(), (String) "rgba(0, 0, 0, 1)"); + } + }); } @Test @@ -2278,26 +2810,31 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("icon-color"); - assertNotNull(layer); - - // Set - layer.setProperties( - iconColor( - zoom( - exponential( - stop(2, iconColor("rgba(0, 0, 0, 1)")) - ).withBase(0.5f) - ) - ) - ); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + iconColor( + zoom( + exponential( + stop(2, iconColor("rgba(0, 0, 0, 1)")) + ).withBase(0.5f) + ) + ) + ); - // Verify - assertNotNull(layer.getIconColor()); - assertNotNull(layer.getIconColor().getFunction()); - assertEquals(CameraFunction.class, layer.getIconColor().getFunction().getClass()); - assertEquals(ExponentialStops.class, layer.getIconColor().getFunction().getStops().getClass()); - assertEquals(0.5f, ((ExponentialStops) layer.getIconColor().getFunction().getStops()).getBase(), 0.001); - assertEquals(1, ((ExponentialStops) layer.getIconColor().getFunction().getStops()).size()); + // Verify + assertNotNull(layer.getIconColor()); + assertNotNull(layer.getIconColor().getFunction()); + assertEquals(CameraFunction.class, layer.getIconColor().getFunction().getClass()); + assertEquals(ExponentialStops.class, layer.getIconColor().getFunction().getStops().getClass()); + assertEquals(0.5f, ((ExponentialStops) layer.getIconColor().getFunction().getStops()).getBase(), 0.001); + assertEquals(1, ((ExponentialStops) layer.getIconColor().getFunction().getStops()).size()); + } + }); } @Test @@ -2305,19 +2842,24 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("icon-color"); - assertNotNull(layer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); - // Set - layer.setProperties( - iconColor(property("FeaturePropertyA", Stops.<String>identity())) - ); + // Set + layer.setProperties( + iconColor(property("FeaturePropertyA", Stops.<String>identity())) + ); - // Verify - assertNotNull(layer.getIconColor()); - assertNotNull(layer.getIconColor().getFunction()); - assertEquals(SourceFunction.class, layer.getIconColor().getFunction().getClass()); - assertEquals("FeaturePropertyA", ((SourceFunction) layer.getIconColor().getFunction()).getProperty()); - assertEquals(IdentityStops.class, layer.getIconColor().getFunction().getStops().getClass()); + // Verify + assertNotNull(layer.getIconColor()); + assertNotNull(layer.getIconColor().getFunction()); + assertEquals(SourceFunction.class, layer.getIconColor().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getIconColor().getFunction()).getProperty()); + assertEquals(IdentityStops.class, layer.getIconColor().getFunction().getStops().getClass()); + } + }); } @Test @@ -2325,26 +2867,31 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("icon-color"); - assertNotNull(layer); - - // Set - layer.setProperties( - iconColor( - property( - "FeaturePropertyA", - exponential( - stop(Color.RED, iconColor(Color.RED)) - ).withBase(0.5f) - ) - ) - ); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + iconColor( + property( + "FeaturePropertyA", + exponential( + stop(Color.RED, iconColor(Color.RED)) + ).withBase(0.5f) + ) + ) + ); - // Verify - assertNotNull(layer.getIconColor()); - assertNotNull(layer.getIconColor().getFunction()); - assertEquals(SourceFunction.class, layer.getIconColor().getFunction().getClass()); - assertEquals("FeaturePropertyA", ((SourceFunction) layer.getIconColor().getFunction()).getProperty()); - assertEquals(ExponentialStops.class, layer.getIconColor().getFunction().getStops().getClass()); + // Verify + assertNotNull(layer.getIconColor()); + assertNotNull(layer.getIconColor().getFunction()); + assertEquals(SourceFunction.class, layer.getIconColor().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getIconColor().getFunction()).getProperty()); + assertEquals(ExponentialStops.class, layer.getIconColor().getFunction().getStops().getClass()); + } + }); } @Test @@ -2352,29 +2899,35 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("icon-color"); - assertNotNull(layer); - - // Set - layer.setProperties( - iconColor( - property( - "FeaturePropertyA", - categorical( - stop("valueA", iconColor(Color.RED)) + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + iconColor( + property( + "FeaturePropertyA", + categorical( + stop("valueA", iconColor(Color.RED)) + ) + ).withDefaultValue(iconColor(Color.GREEN)) ) - ).withDefaultValue(iconColor(Color.GREEN)) - ) - ); + ); + + // Verify + assertNotNull(layer.getIconColor()); + assertNotNull(layer.getIconColor().getFunction()); + assertEquals(SourceFunction.class, layer.getIconColor().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getIconColor().getFunction()).getProperty()); + assertEquals(CategoricalStops.class, layer.getIconColor().getFunction().getStops().getClass()); + assertNotNull(((SourceFunction) layer.getIconColor().getFunction()).getDefaultValue()); + assertNotNull(((SourceFunction) layer.getIconColor().getFunction()).getDefaultValue().getValue()); + assertEquals(Color.GREEN, (int) ((SourceFunction) layer.getIconColor().getFunction()).getDefaultValue().getColorInt()); + } + }); - // Verify - assertNotNull(layer.getIconColor()); - assertNotNull(layer.getIconColor().getFunction()); - assertEquals(SourceFunction.class, layer.getIconColor().getFunction().getClass()); - assertEquals("FeaturePropertyA", ((SourceFunction) layer.getIconColor().getFunction()).getProperty()); - assertEquals(CategoricalStops.class, layer.getIconColor().getFunction().getStops().getClass()); - assertNotNull(((SourceFunction) layer.getIconColor().getFunction()).getDefaultValue()); - assertNotNull(((SourceFunction) layer.getIconColor().getFunction()).getDefaultValue().getValue()); - assertEquals(Color.GREEN, (int) ((SourceFunction) layer.getIconColor().getFunction()).getDefaultValue().getColorInt()); } @Test @@ -2382,11 +2935,16 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("icon-color"); - assertNotNull(layer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); - // Set and Get - layer.setProperties(iconColor(Color.RED)); - assertEquals(layer.getIconColorAsInt(), Color.RED); + // Set and Get + layer.setProperties(iconColor(Color.RED)); + assertEquals(layer.getIconColorAsInt(), Color.RED); + } + }); } @Test @@ -2394,12 +2952,17 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("icon-halo-colorTransitionOptions"); - assertNotNull(layer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); - // Set and Get - TransitionOptions options = new TransitionOptions(300, 100); - layer.setIconHaloColorTransition(options); - assertEquals(layer.getIconHaloColorTransition(), options); + // Set and Get + TransitionOptions options = new TransitionOptions(300, 100); + layer.setIconHaloColorTransition(options); + assertEquals(layer.getIconHaloColorTransition(), options); + } + }); } @Test @@ -2407,11 +2970,16 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("icon-halo-color"); - assertNotNull(layer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); - // Set and Get - layer.setProperties(iconHaloColor("rgba(0, 0, 0, 1)")); - assertEquals((String) layer.getIconHaloColor().getValue(), (String) "rgba(0, 0, 0, 1)"); + // Set and Get + layer.setProperties(iconHaloColor("rgba(0, 0, 0, 1)")); + assertEquals((String) layer.getIconHaloColor().getValue(), (String) "rgba(0, 0, 0, 1)"); + } + }); } @Test @@ -2419,26 +2987,31 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("icon-halo-color"); - assertNotNull(layer); - - // Set - layer.setProperties( - iconHaloColor( - zoom( - exponential( - stop(2, iconHaloColor("rgba(0, 0, 0, 1)")) - ).withBase(0.5f) - ) - ) - ); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + iconHaloColor( + zoom( + exponential( + stop(2, iconHaloColor("rgba(0, 0, 0, 1)")) + ).withBase(0.5f) + ) + ) + ); - // Verify - assertNotNull(layer.getIconHaloColor()); - assertNotNull(layer.getIconHaloColor().getFunction()); - assertEquals(CameraFunction.class, layer.getIconHaloColor().getFunction().getClass()); - assertEquals(ExponentialStops.class, layer.getIconHaloColor().getFunction().getStops().getClass()); - assertEquals(0.5f, ((ExponentialStops) layer.getIconHaloColor().getFunction().getStops()).getBase(), 0.001); - assertEquals(1, ((ExponentialStops) layer.getIconHaloColor().getFunction().getStops()).size()); + // Verify + assertNotNull(layer.getIconHaloColor()); + assertNotNull(layer.getIconHaloColor().getFunction()); + assertEquals(CameraFunction.class, layer.getIconHaloColor().getFunction().getClass()); + assertEquals(ExponentialStops.class, layer.getIconHaloColor().getFunction().getStops().getClass()); + assertEquals(0.5f, ((ExponentialStops) layer.getIconHaloColor().getFunction().getStops()).getBase(), 0.001); + assertEquals(1, ((ExponentialStops) layer.getIconHaloColor().getFunction().getStops()).size()); + } + }); } @Test @@ -2446,19 +3019,24 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("icon-halo-color"); - assertNotNull(layer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); - // Set - layer.setProperties( - iconHaloColor(property("FeaturePropertyA", Stops.<String>identity())) - ); + // Set + layer.setProperties( + iconHaloColor(property("FeaturePropertyA", Stops.<String>identity())) + ); - // Verify - assertNotNull(layer.getIconHaloColor()); - assertNotNull(layer.getIconHaloColor().getFunction()); - assertEquals(SourceFunction.class, layer.getIconHaloColor().getFunction().getClass()); - assertEquals("FeaturePropertyA", ((SourceFunction) layer.getIconHaloColor().getFunction()).getProperty()); - assertEquals(IdentityStops.class, layer.getIconHaloColor().getFunction().getStops().getClass()); + // Verify + assertNotNull(layer.getIconHaloColor()); + assertNotNull(layer.getIconHaloColor().getFunction()); + assertEquals(SourceFunction.class, layer.getIconHaloColor().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getIconHaloColor().getFunction()).getProperty()); + assertEquals(IdentityStops.class, layer.getIconHaloColor().getFunction().getStops().getClass()); + } + }); } @Test @@ -2466,26 +3044,31 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("icon-halo-color"); - assertNotNull(layer); - - // Set - layer.setProperties( - iconHaloColor( - property( - "FeaturePropertyA", - exponential( - stop(Color.RED, iconHaloColor(Color.RED)) - ).withBase(0.5f) - ) - ) - ); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + iconHaloColor( + property( + "FeaturePropertyA", + exponential( + stop(Color.RED, iconHaloColor(Color.RED)) + ).withBase(0.5f) + ) + ) + ); - // Verify - assertNotNull(layer.getIconHaloColor()); - assertNotNull(layer.getIconHaloColor().getFunction()); - assertEquals(SourceFunction.class, layer.getIconHaloColor().getFunction().getClass()); - assertEquals("FeaturePropertyA", ((SourceFunction) layer.getIconHaloColor().getFunction()).getProperty()); - assertEquals(ExponentialStops.class, layer.getIconHaloColor().getFunction().getStops().getClass()); + // Verify + assertNotNull(layer.getIconHaloColor()); + assertNotNull(layer.getIconHaloColor().getFunction()); + assertEquals(SourceFunction.class, layer.getIconHaloColor().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getIconHaloColor().getFunction()).getProperty()); + assertEquals(ExponentialStops.class, layer.getIconHaloColor().getFunction().getStops().getClass()); + } + }); } @Test @@ -2493,29 +3076,35 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("icon-halo-color"); - assertNotNull(layer); - - // Set - layer.setProperties( - iconHaloColor( - property( - "FeaturePropertyA", - categorical( - stop("valueA", iconHaloColor(Color.RED)) + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + iconHaloColor( + property( + "FeaturePropertyA", + categorical( + stop("valueA", iconHaloColor(Color.RED)) + ) + ).withDefaultValue(iconHaloColor(Color.GREEN)) ) - ).withDefaultValue(iconHaloColor(Color.GREEN)) - ) - ); + ); + + // Verify + assertNotNull(layer.getIconHaloColor()); + assertNotNull(layer.getIconHaloColor().getFunction()); + assertEquals(SourceFunction.class, layer.getIconHaloColor().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getIconHaloColor().getFunction()).getProperty()); + assertEquals(CategoricalStops.class, layer.getIconHaloColor().getFunction().getStops().getClass()); + assertNotNull(((SourceFunction) layer.getIconHaloColor().getFunction()).getDefaultValue()); + assertNotNull(((SourceFunction) layer.getIconHaloColor().getFunction()).getDefaultValue().getValue()); + assertEquals(Color.GREEN, (int) ((SourceFunction) layer.getIconHaloColor().getFunction()).getDefaultValue().getColorInt()); + } + }); - // Verify - assertNotNull(layer.getIconHaloColor()); - assertNotNull(layer.getIconHaloColor().getFunction()); - assertEquals(SourceFunction.class, layer.getIconHaloColor().getFunction().getClass()); - assertEquals("FeaturePropertyA", ((SourceFunction) layer.getIconHaloColor().getFunction()).getProperty()); - assertEquals(CategoricalStops.class, layer.getIconHaloColor().getFunction().getStops().getClass()); - assertNotNull(((SourceFunction) layer.getIconHaloColor().getFunction()).getDefaultValue()); - assertNotNull(((SourceFunction) layer.getIconHaloColor().getFunction()).getDefaultValue().getValue()); - assertEquals(Color.GREEN, (int) ((SourceFunction) layer.getIconHaloColor().getFunction()).getDefaultValue().getColorInt()); } @Test @@ -2523,11 +3112,16 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("icon-halo-color"); - assertNotNull(layer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); - // Set and Get - layer.setProperties(iconHaloColor(Color.RED)); - assertEquals(layer.getIconHaloColorAsInt(), Color.RED); + // Set and Get + layer.setProperties(iconHaloColor(Color.RED)); + assertEquals(layer.getIconHaloColorAsInt(), Color.RED); + } + }); } @Test @@ -2535,12 +3129,17 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("icon-halo-widthTransitionOptions"); - assertNotNull(layer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); - // Set and Get - TransitionOptions options = new TransitionOptions(300, 100); - layer.setIconHaloWidthTransition(options); - assertEquals(layer.getIconHaloWidthTransition(), options); + // Set and Get + TransitionOptions options = new TransitionOptions(300, 100); + layer.setIconHaloWidthTransition(options); + assertEquals(layer.getIconHaloWidthTransition(), options); + } + }); } @Test @@ -2548,11 +3147,16 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("icon-halo-width"); - assertNotNull(layer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); - // Set and Get - layer.setProperties(iconHaloWidth(0.3f)); - assertEquals((Float) layer.getIconHaloWidth().getValue(), (Float) 0.3f); + // Set and Get + layer.setProperties(iconHaloWidth(0.3f)); + assertEquals((Float) layer.getIconHaloWidth().getValue(), (Float) 0.3f); + } + }); } @Test @@ -2560,26 +3164,31 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("icon-halo-width"); - assertNotNull(layer); - - // Set - layer.setProperties( - iconHaloWidth( - zoom( - exponential( - stop(2, iconHaloWidth(0.3f)) - ).withBase(0.5f) - ) - ) - ); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + iconHaloWidth( + zoom( + exponential( + stop(2, iconHaloWidth(0.3f)) + ).withBase(0.5f) + ) + ) + ); - // Verify - assertNotNull(layer.getIconHaloWidth()); - assertNotNull(layer.getIconHaloWidth().getFunction()); - assertEquals(CameraFunction.class, layer.getIconHaloWidth().getFunction().getClass()); - assertEquals(ExponentialStops.class, layer.getIconHaloWidth().getFunction().getStops().getClass()); - assertEquals(0.5f, ((ExponentialStops) layer.getIconHaloWidth().getFunction().getStops()).getBase(), 0.001); - assertEquals(1, ((ExponentialStops) layer.getIconHaloWidth().getFunction().getStops()).size()); + // Verify + assertNotNull(layer.getIconHaloWidth()); + assertNotNull(layer.getIconHaloWidth().getFunction()); + assertEquals(CameraFunction.class, layer.getIconHaloWidth().getFunction().getClass()); + assertEquals(ExponentialStops.class, layer.getIconHaloWidth().getFunction().getStops().getClass()); + assertEquals(0.5f, ((ExponentialStops) layer.getIconHaloWidth().getFunction().getStops()).getBase(), 0.001); + assertEquals(1, ((ExponentialStops) layer.getIconHaloWidth().getFunction().getStops()).size()); + } + }); } @Test @@ -2587,19 +3196,24 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("icon-halo-width"); - assertNotNull(layer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); - // Set - layer.setProperties( - iconHaloWidth(property("FeaturePropertyA", Stops.<Float>identity())) - ); + // Set + layer.setProperties( + iconHaloWidth(property("FeaturePropertyA", Stops.<Float>identity())) + ); - // Verify - assertNotNull(layer.getIconHaloWidth()); - assertNotNull(layer.getIconHaloWidth().getFunction()); - assertEquals(SourceFunction.class, layer.getIconHaloWidth().getFunction().getClass()); - assertEquals("FeaturePropertyA", ((SourceFunction) layer.getIconHaloWidth().getFunction()).getProperty()); - assertEquals(IdentityStops.class, layer.getIconHaloWidth().getFunction().getStops().getClass()); + // Verify + assertNotNull(layer.getIconHaloWidth()); + assertNotNull(layer.getIconHaloWidth().getFunction()); + assertEquals(SourceFunction.class, layer.getIconHaloWidth().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getIconHaloWidth().getFunction()).getProperty()); + assertEquals(IdentityStops.class, layer.getIconHaloWidth().getFunction().getStops().getClass()); + } + }); } @Test @@ -2607,26 +3221,31 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("icon-halo-width"); - assertNotNull(layer); - - // Set - layer.setProperties( - iconHaloWidth( - property( - "FeaturePropertyA", - exponential( - stop(0.3f, iconHaloWidth(0.3f)) - ).withBase(0.5f) - ) - ) - ); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + iconHaloWidth( + property( + "FeaturePropertyA", + exponential( + stop(0.3f, iconHaloWidth(0.3f)) + ).withBase(0.5f) + ) + ) + ); - // Verify - assertNotNull(layer.getIconHaloWidth()); - assertNotNull(layer.getIconHaloWidth().getFunction()); - assertEquals(SourceFunction.class, layer.getIconHaloWidth().getFunction().getClass()); - assertEquals("FeaturePropertyA", ((SourceFunction) layer.getIconHaloWidth().getFunction()).getProperty()); - assertEquals(ExponentialStops.class, layer.getIconHaloWidth().getFunction().getStops().getClass()); + // Verify + assertNotNull(layer.getIconHaloWidth()); + assertNotNull(layer.getIconHaloWidth().getFunction()); + assertEquals(SourceFunction.class, layer.getIconHaloWidth().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getIconHaloWidth().getFunction()).getProperty()); + assertEquals(ExponentialStops.class, layer.getIconHaloWidth().getFunction().getStops().getClass()); + } + }); } @Test @@ -2634,29 +3253,35 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("icon-halo-width"); - assertNotNull(layer); - - // Set - layer.setProperties( - iconHaloWidth( - property( - "FeaturePropertyA", - categorical( - stop(1.0f, iconHaloWidth(0.3f)) + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + iconHaloWidth( + property( + "FeaturePropertyA", + categorical( + stop(1.0f, iconHaloWidth(0.3f)) + ) + ).withDefaultValue(iconHaloWidth(0.3f)) ) - ).withDefaultValue(iconHaloWidth(0.3f)) - ) - ); + ); + + // Verify + assertNotNull(layer.getIconHaloWidth()); + assertNotNull(layer.getIconHaloWidth().getFunction()); + assertEquals(SourceFunction.class, layer.getIconHaloWidth().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getIconHaloWidth().getFunction()).getProperty()); + assertEquals(CategoricalStops.class, layer.getIconHaloWidth().getFunction().getStops().getClass()); + assertNotNull(((SourceFunction) layer.getIconHaloWidth().getFunction()).getDefaultValue()); + assertNotNull(((SourceFunction) layer.getIconHaloWidth().getFunction()).getDefaultValue().getValue()); + assertEquals(0.3f, ((SourceFunction) layer.getIconHaloWidth().getFunction()).getDefaultValue().getValue()); + } + }); - // Verify - assertNotNull(layer.getIconHaloWidth()); - assertNotNull(layer.getIconHaloWidth().getFunction()); - assertEquals(SourceFunction.class, layer.getIconHaloWidth().getFunction().getClass()); - assertEquals("FeaturePropertyA", ((SourceFunction) layer.getIconHaloWidth().getFunction()).getProperty()); - assertEquals(CategoricalStops.class, layer.getIconHaloWidth().getFunction().getStops().getClass()); - assertNotNull(((SourceFunction) layer.getIconHaloWidth().getFunction()).getDefaultValue()); - assertNotNull(((SourceFunction) layer.getIconHaloWidth().getFunction()).getDefaultValue().getValue()); - assertEquals(0.3f, ((SourceFunction) layer.getIconHaloWidth().getFunction()).getDefaultValue().getValue()); } @Test @@ -2664,34 +3289,39 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("icon-halo-width"); - assertNotNull(layer); - - // Set - layer.setProperties( - iconHaloWidth( - composite( - "FeaturePropertyA", - exponential( - stop(0, 0.3f, iconHaloWidth(0.9f)) - ).withBase(0.5f) - ).withDefaultValue(iconHaloWidth(0.3f)) - ) - ); - - // Verify - assertNotNull(layer.getIconHaloWidth()); - assertNotNull(layer.getIconHaloWidth().getFunction()); - assertEquals(CompositeFunction.class, layer.getIconHaloWidth().getFunction().getClass()); - assertEquals("FeaturePropertyA", ((CompositeFunction) layer.getIconHaloWidth().getFunction()).getProperty()); - assertEquals(ExponentialStops.class, layer.getIconHaloWidth().getFunction().getStops().getClass()); - assertEquals(1, ((ExponentialStops) layer.getIconHaloWidth().getFunction().getStops()).size()); - - ExponentialStops<Stop.CompositeValue<Float, Float>, Float> stops = - (ExponentialStops<Stop.CompositeValue<Float, Float>, Float>) layer.getIconHaloWidth().getFunction().getStops(); - Stop<Stop.CompositeValue<Float, Float>, Float> stop = stops.iterator().next(); - assertEquals(0f, stop.in.zoom, 0.001); - assertEquals(0.3f, stop.in.value, 0.001f); - assertEquals(0.9f, stop.out, 0.001f); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + iconHaloWidth( + composite( + "FeaturePropertyA", + exponential( + stop(0, 0.3f, iconHaloWidth(0.9f)) + ).withBase(0.5f) + ).withDefaultValue(iconHaloWidth(0.3f)) + ) + ); + + // Verify + assertNotNull(layer.getIconHaloWidth()); + assertNotNull(layer.getIconHaloWidth().getFunction()); + assertEquals(CompositeFunction.class, layer.getIconHaloWidth().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((CompositeFunction) layer.getIconHaloWidth().getFunction()).getProperty()); + assertEquals(ExponentialStops.class, layer.getIconHaloWidth().getFunction().getStops().getClass()); + assertEquals(1, ((ExponentialStops) layer.getIconHaloWidth().getFunction().getStops()).size()); + + ExponentialStops<Stop.CompositeValue<Float, Float>, Float> stops = + (ExponentialStops<Stop.CompositeValue<Float, Float>, Float>) layer.getIconHaloWidth().getFunction().getStops(); + Stop<Stop.CompositeValue<Float, Float>, Float> stop = stops.iterator().next(); + assertEquals(0f, stop.in.zoom, 0.001); + assertEquals(0.3f, stop.in.value, 0.001f); + assertEquals(0.9f, stop.out, 0.001f); + } + }); } @Test @@ -2699,12 +3329,17 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("icon-halo-blurTransitionOptions"); - assertNotNull(layer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); - // Set and Get - TransitionOptions options = new TransitionOptions(300, 100); - layer.setIconHaloBlurTransition(options); - assertEquals(layer.getIconHaloBlurTransition(), options); + // Set and Get + TransitionOptions options = new TransitionOptions(300, 100); + layer.setIconHaloBlurTransition(options); + assertEquals(layer.getIconHaloBlurTransition(), options); + } + }); } @Test @@ -2712,11 +3347,16 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("icon-halo-blur"); - assertNotNull(layer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); - // Set and Get - layer.setProperties(iconHaloBlur(0.3f)); - assertEquals((Float) layer.getIconHaloBlur().getValue(), (Float) 0.3f); + // Set and Get + layer.setProperties(iconHaloBlur(0.3f)); + assertEquals((Float) layer.getIconHaloBlur().getValue(), (Float) 0.3f); + } + }); } @Test @@ -2724,26 +3364,31 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("icon-halo-blur"); - assertNotNull(layer); - - // Set - layer.setProperties( - iconHaloBlur( - zoom( - exponential( - stop(2, iconHaloBlur(0.3f)) - ).withBase(0.5f) - ) - ) - ); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + iconHaloBlur( + zoom( + exponential( + stop(2, iconHaloBlur(0.3f)) + ).withBase(0.5f) + ) + ) + ); - // Verify - assertNotNull(layer.getIconHaloBlur()); - assertNotNull(layer.getIconHaloBlur().getFunction()); - assertEquals(CameraFunction.class, layer.getIconHaloBlur().getFunction().getClass()); - assertEquals(ExponentialStops.class, layer.getIconHaloBlur().getFunction().getStops().getClass()); - assertEquals(0.5f, ((ExponentialStops) layer.getIconHaloBlur().getFunction().getStops()).getBase(), 0.001); - assertEquals(1, ((ExponentialStops) layer.getIconHaloBlur().getFunction().getStops()).size()); + // Verify + assertNotNull(layer.getIconHaloBlur()); + assertNotNull(layer.getIconHaloBlur().getFunction()); + assertEquals(CameraFunction.class, layer.getIconHaloBlur().getFunction().getClass()); + assertEquals(ExponentialStops.class, layer.getIconHaloBlur().getFunction().getStops().getClass()); + assertEquals(0.5f, ((ExponentialStops) layer.getIconHaloBlur().getFunction().getStops()).getBase(), 0.001); + assertEquals(1, ((ExponentialStops) layer.getIconHaloBlur().getFunction().getStops()).size()); + } + }); } @Test @@ -2751,19 +3396,24 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("icon-halo-blur"); - assertNotNull(layer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); - // Set - layer.setProperties( - iconHaloBlur(property("FeaturePropertyA", Stops.<Float>identity())) - ); + // Set + layer.setProperties( + iconHaloBlur(property("FeaturePropertyA", Stops.<Float>identity())) + ); - // Verify - assertNotNull(layer.getIconHaloBlur()); - assertNotNull(layer.getIconHaloBlur().getFunction()); - assertEquals(SourceFunction.class, layer.getIconHaloBlur().getFunction().getClass()); - assertEquals("FeaturePropertyA", ((SourceFunction) layer.getIconHaloBlur().getFunction()).getProperty()); - assertEquals(IdentityStops.class, layer.getIconHaloBlur().getFunction().getStops().getClass()); + // Verify + assertNotNull(layer.getIconHaloBlur()); + assertNotNull(layer.getIconHaloBlur().getFunction()); + assertEquals(SourceFunction.class, layer.getIconHaloBlur().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getIconHaloBlur().getFunction()).getProperty()); + assertEquals(IdentityStops.class, layer.getIconHaloBlur().getFunction().getStops().getClass()); + } + }); } @Test @@ -2771,26 +3421,31 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("icon-halo-blur"); - assertNotNull(layer); - - // Set - layer.setProperties( - iconHaloBlur( - property( - "FeaturePropertyA", - exponential( - stop(0.3f, iconHaloBlur(0.3f)) - ).withBase(0.5f) - ) - ) - ); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + iconHaloBlur( + property( + "FeaturePropertyA", + exponential( + stop(0.3f, iconHaloBlur(0.3f)) + ).withBase(0.5f) + ) + ) + ); - // Verify - assertNotNull(layer.getIconHaloBlur()); - assertNotNull(layer.getIconHaloBlur().getFunction()); - assertEquals(SourceFunction.class, layer.getIconHaloBlur().getFunction().getClass()); - assertEquals("FeaturePropertyA", ((SourceFunction) layer.getIconHaloBlur().getFunction()).getProperty()); - assertEquals(ExponentialStops.class, layer.getIconHaloBlur().getFunction().getStops().getClass()); + // Verify + assertNotNull(layer.getIconHaloBlur()); + assertNotNull(layer.getIconHaloBlur().getFunction()); + assertEquals(SourceFunction.class, layer.getIconHaloBlur().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getIconHaloBlur().getFunction()).getProperty()); + assertEquals(ExponentialStops.class, layer.getIconHaloBlur().getFunction().getStops().getClass()); + } + }); } @Test @@ -2798,29 +3453,35 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("icon-halo-blur"); - assertNotNull(layer); - - // Set - layer.setProperties( - iconHaloBlur( - property( - "FeaturePropertyA", - categorical( - stop(1.0f, iconHaloBlur(0.3f)) + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + iconHaloBlur( + property( + "FeaturePropertyA", + categorical( + stop(1.0f, iconHaloBlur(0.3f)) + ) + ).withDefaultValue(iconHaloBlur(0.3f)) ) - ).withDefaultValue(iconHaloBlur(0.3f)) - ) - ); + ); + + // Verify + assertNotNull(layer.getIconHaloBlur()); + assertNotNull(layer.getIconHaloBlur().getFunction()); + assertEquals(SourceFunction.class, layer.getIconHaloBlur().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getIconHaloBlur().getFunction()).getProperty()); + assertEquals(CategoricalStops.class, layer.getIconHaloBlur().getFunction().getStops().getClass()); + assertNotNull(((SourceFunction) layer.getIconHaloBlur().getFunction()).getDefaultValue()); + assertNotNull(((SourceFunction) layer.getIconHaloBlur().getFunction()).getDefaultValue().getValue()); + assertEquals(0.3f, ((SourceFunction) layer.getIconHaloBlur().getFunction()).getDefaultValue().getValue()); + } + }); - // Verify - assertNotNull(layer.getIconHaloBlur()); - assertNotNull(layer.getIconHaloBlur().getFunction()); - assertEquals(SourceFunction.class, layer.getIconHaloBlur().getFunction().getClass()); - assertEquals("FeaturePropertyA", ((SourceFunction) layer.getIconHaloBlur().getFunction()).getProperty()); - assertEquals(CategoricalStops.class, layer.getIconHaloBlur().getFunction().getStops().getClass()); - assertNotNull(((SourceFunction) layer.getIconHaloBlur().getFunction()).getDefaultValue()); - assertNotNull(((SourceFunction) layer.getIconHaloBlur().getFunction()).getDefaultValue().getValue()); - assertEquals(0.3f, ((SourceFunction) layer.getIconHaloBlur().getFunction()).getDefaultValue().getValue()); } @Test @@ -2828,34 +3489,39 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("icon-halo-blur"); - assertNotNull(layer); - - // Set - layer.setProperties( - iconHaloBlur( - composite( - "FeaturePropertyA", - exponential( - stop(0, 0.3f, iconHaloBlur(0.9f)) - ).withBase(0.5f) - ).withDefaultValue(iconHaloBlur(0.3f)) - ) - ); - - // Verify - assertNotNull(layer.getIconHaloBlur()); - assertNotNull(layer.getIconHaloBlur().getFunction()); - assertEquals(CompositeFunction.class, layer.getIconHaloBlur().getFunction().getClass()); - assertEquals("FeaturePropertyA", ((CompositeFunction) layer.getIconHaloBlur().getFunction()).getProperty()); - assertEquals(ExponentialStops.class, layer.getIconHaloBlur().getFunction().getStops().getClass()); - assertEquals(1, ((ExponentialStops) layer.getIconHaloBlur().getFunction().getStops()).size()); - - ExponentialStops<Stop.CompositeValue<Float, Float>, Float> stops = - (ExponentialStops<Stop.CompositeValue<Float, Float>, Float>) layer.getIconHaloBlur().getFunction().getStops(); - Stop<Stop.CompositeValue<Float, Float>, Float> stop = stops.iterator().next(); - assertEquals(0f, stop.in.zoom, 0.001); - assertEquals(0.3f, stop.in.value, 0.001f); - assertEquals(0.9f, stop.out, 0.001f); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + iconHaloBlur( + composite( + "FeaturePropertyA", + exponential( + stop(0, 0.3f, iconHaloBlur(0.9f)) + ).withBase(0.5f) + ).withDefaultValue(iconHaloBlur(0.3f)) + ) + ); + + // Verify + assertNotNull(layer.getIconHaloBlur()); + assertNotNull(layer.getIconHaloBlur().getFunction()); + assertEquals(CompositeFunction.class, layer.getIconHaloBlur().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((CompositeFunction) layer.getIconHaloBlur().getFunction()).getProperty()); + assertEquals(ExponentialStops.class, layer.getIconHaloBlur().getFunction().getStops().getClass()); + assertEquals(1, ((ExponentialStops) layer.getIconHaloBlur().getFunction().getStops()).size()); + + ExponentialStops<Stop.CompositeValue<Float, Float>, Float> stops = + (ExponentialStops<Stop.CompositeValue<Float, Float>, Float>) layer.getIconHaloBlur().getFunction().getStops(); + Stop<Stop.CompositeValue<Float, Float>, Float> stop = stops.iterator().next(); + assertEquals(0f, stop.in.zoom, 0.001); + assertEquals(0.3f, stop.in.value, 0.001f); + assertEquals(0.9f, stop.out, 0.001f); + } + }); } @Test @@ -2863,12 +3529,17 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("icon-translateTransitionOptions"); - assertNotNull(layer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); - // Set and Get - TransitionOptions options = new TransitionOptions(300, 100); - layer.setIconTranslateTransition(options); - assertEquals(layer.getIconTranslateTransition(), options); + // Set and Get + TransitionOptions options = new TransitionOptions(300, 100); + layer.setIconTranslateTransition(options); + assertEquals(layer.getIconTranslateTransition(), options); + } + }); } @Test @@ -2876,11 +3547,16 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("icon-translate"); - assertNotNull(layer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); - // Set and Get - layer.setProperties(iconTranslate(new Float[]{0f,0f})); - assertEquals((Float[]) layer.getIconTranslate().getValue(), (Float[]) new Float[]{0f,0f}); + // Set and Get + layer.setProperties(iconTranslate(new Float[] {0f, 0f})); + assertEquals((Float[]) layer.getIconTranslate().getValue(), (Float[]) new Float[] {0f, 0f}); + } + }); } @Test @@ -2888,26 +3564,31 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("icon-translate"); - assertNotNull(layer); - - // Set - layer.setProperties( - iconTranslate( - zoom( - exponential( - stop(2, iconTranslate(new Float[]{0f,0f})) - ).withBase(0.5f) - ) - ) - ); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + iconTranslate( + zoom( + exponential( + stop(2, iconTranslate(new Float[] {0f, 0f})) + ).withBase(0.5f) + ) + ) + ); - // Verify - assertNotNull(layer.getIconTranslate()); - assertNotNull(layer.getIconTranslate().getFunction()); - assertEquals(CameraFunction.class, layer.getIconTranslate().getFunction().getClass()); - assertEquals(ExponentialStops.class, layer.getIconTranslate().getFunction().getStops().getClass()); - assertEquals(0.5f, ((ExponentialStops) layer.getIconTranslate().getFunction().getStops()).getBase(), 0.001); - assertEquals(1, ((ExponentialStops) layer.getIconTranslate().getFunction().getStops()).size()); + // Verify + assertNotNull(layer.getIconTranslate()); + assertNotNull(layer.getIconTranslate().getFunction()); + assertEquals(CameraFunction.class, layer.getIconTranslate().getFunction().getClass()); + assertEquals(ExponentialStops.class, layer.getIconTranslate().getFunction().getStops().getClass()); + assertEquals(0.5f, ((ExponentialStops) layer.getIconTranslate().getFunction().getStops()).getBase(), 0.001); + assertEquals(1, ((ExponentialStops) layer.getIconTranslate().getFunction().getStops()).size()); + } + }); } @Test @@ -2915,11 +3596,16 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("icon-translate-anchor"); - assertNotNull(layer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); - // Set and Get - layer.setProperties(iconTranslateAnchor(ICON_TRANSLATE_ANCHOR_MAP)); - assertEquals((String) layer.getIconTranslateAnchor().getValue(), (String) ICON_TRANSLATE_ANCHOR_MAP); + // Set and Get + layer.setProperties(iconTranslateAnchor(ICON_TRANSLATE_ANCHOR_MAP)); + assertEquals((String) layer.getIconTranslateAnchor().getValue(), (String) ICON_TRANSLATE_ANCHOR_MAP); + } + }); } @Test @@ -2927,25 +3613,30 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("icon-translate-anchor"); - assertNotNull(layer); - - // Set - layer.setProperties( - iconTranslateAnchor( - zoom( - interval( - stop(2, iconTranslateAnchor(ICON_TRANSLATE_ANCHOR_MAP)) + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + iconTranslateAnchor( + zoom( + interval( + stop(2, iconTranslateAnchor(ICON_TRANSLATE_ANCHOR_MAP)) + ) + ) ) - ) - ) - ); + ); - // Verify - assertNotNull(layer.getIconTranslateAnchor()); - assertNotNull(layer.getIconTranslateAnchor().getFunction()); - assertEquals(CameraFunction.class, layer.getIconTranslateAnchor().getFunction().getClass()); - assertEquals(IntervalStops.class, layer.getIconTranslateAnchor().getFunction().getStops().getClass()); - assertEquals(1, ((IntervalStops) layer.getIconTranslateAnchor().getFunction().getStops()).size()); + // Verify + assertNotNull(layer.getIconTranslateAnchor()); + assertNotNull(layer.getIconTranslateAnchor().getFunction()); + assertEquals(CameraFunction.class, layer.getIconTranslateAnchor().getFunction().getClass()); + assertEquals(IntervalStops.class, layer.getIconTranslateAnchor().getFunction().getStops().getClass()); + assertEquals(1, ((IntervalStops) layer.getIconTranslateAnchor().getFunction().getStops()).size()); + } + }); } @Test @@ -2953,12 +3644,17 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("text-opacityTransitionOptions"); - assertNotNull(layer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); - // Set and Get - TransitionOptions options = new TransitionOptions(300, 100); - layer.setTextOpacityTransition(options); - assertEquals(layer.getTextOpacityTransition(), options); + // Set and Get + TransitionOptions options = new TransitionOptions(300, 100); + layer.setTextOpacityTransition(options); + assertEquals(layer.getTextOpacityTransition(), options); + } + }); } @Test @@ -2966,11 +3662,16 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("text-opacity"); - assertNotNull(layer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); - // Set and Get - layer.setProperties(textOpacity(0.3f)); - assertEquals((Float) layer.getTextOpacity().getValue(), (Float) 0.3f); + // Set and Get + layer.setProperties(textOpacity(0.3f)); + assertEquals((Float) layer.getTextOpacity().getValue(), (Float) 0.3f); + } + }); } @Test @@ -2978,26 +3679,31 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("text-opacity"); - assertNotNull(layer); - - // Set - layer.setProperties( - textOpacity( - zoom( - exponential( - stop(2, textOpacity(0.3f)) - ).withBase(0.5f) - ) - ) - ); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + textOpacity( + zoom( + exponential( + stop(2, textOpacity(0.3f)) + ).withBase(0.5f) + ) + ) + ); - // Verify - assertNotNull(layer.getTextOpacity()); - assertNotNull(layer.getTextOpacity().getFunction()); - assertEquals(CameraFunction.class, layer.getTextOpacity().getFunction().getClass()); - assertEquals(ExponentialStops.class, layer.getTextOpacity().getFunction().getStops().getClass()); - assertEquals(0.5f, ((ExponentialStops) layer.getTextOpacity().getFunction().getStops()).getBase(), 0.001); - assertEquals(1, ((ExponentialStops) layer.getTextOpacity().getFunction().getStops()).size()); + // Verify + assertNotNull(layer.getTextOpacity()); + assertNotNull(layer.getTextOpacity().getFunction()); + assertEquals(CameraFunction.class, layer.getTextOpacity().getFunction().getClass()); + assertEquals(ExponentialStops.class, layer.getTextOpacity().getFunction().getStops().getClass()); + assertEquals(0.5f, ((ExponentialStops) layer.getTextOpacity().getFunction().getStops()).getBase(), 0.001); + assertEquals(1, ((ExponentialStops) layer.getTextOpacity().getFunction().getStops()).size()); + } + }); } @Test @@ -3005,19 +3711,24 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("text-opacity"); - assertNotNull(layer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); - // Set - layer.setProperties( - textOpacity(property("FeaturePropertyA", Stops.<Float>identity())) - ); + // Set + layer.setProperties( + textOpacity(property("FeaturePropertyA", Stops.<Float>identity())) + ); - // Verify - assertNotNull(layer.getTextOpacity()); - assertNotNull(layer.getTextOpacity().getFunction()); - assertEquals(SourceFunction.class, layer.getTextOpacity().getFunction().getClass()); - assertEquals("FeaturePropertyA", ((SourceFunction) layer.getTextOpacity().getFunction()).getProperty()); - assertEquals(IdentityStops.class, layer.getTextOpacity().getFunction().getStops().getClass()); + // Verify + assertNotNull(layer.getTextOpacity()); + assertNotNull(layer.getTextOpacity().getFunction()); + assertEquals(SourceFunction.class, layer.getTextOpacity().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getTextOpacity().getFunction()).getProperty()); + assertEquals(IdentityStops.class, layer.getTextOpacity().getFunction().getStops().getClass()); + } + }); } @Test @@ -3025,26 +3736,31 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("text-opacity"); - assertNotNull(layer); - - // Set - layer.setProperties( - textOpacity( - property( - "FeaturePropertyA", - exponential( - stop(0.3f, textOpacity(0.3f)) - ).withBase(0.5f) - ) - ) - ); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + textOpacity( + property( + "FeaturePropertyA", + exponential( + stop(0.3f, textOpacity(0.3f)) + ).withBase(0.5f) + ) + ) + ); - // Verify - assertNotNull(layer.getTextOpacity()); - assertNotNull(layer.getTextOpacity().getFunction()); - assertEquals(SourceFunction.class, layer.getTextOpacity().getFunction().getClass()); - assertEquals("FeaturePropertyA", ((SourceFunction) layer.getTextOpacity().getFunction()).getProperty()); - assertEquals(ExponentialStops.class, layer.getTextOpacity().getFunction().getStops().getClass()); + // Verify + assertNotNull(layer.getTextOpacity()); + assertNotNull(layer.getTextOpacity().getFunction()); + assertEquals(SourceFunction.class, layer.getTextOpacity().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getTextOpacity().getFunction()).getProperty()); + assertEquals(ExponentialStops.class, layer.getTextOpacity().getFunction().getStops().getClass()); + } + }); } @Test @@ -3052,29 +3768,35 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("text-opacity"); - assertNotNull(layer); - - // Set - layer.setProperties( - textOpacity( - property( - "FeaturePropertyA", - categorical( - stop(1.0f, textOpacity(0.3f)) + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + textOpacity( + property( + "FeaturePropertyA", + categorical( + stop(1.0f, textOpacity(0.3f)) + ) + ).withDefaultValue(textOpacity(0.3f)) ) - ).withDefaultValue(textOpacity(0.3f)) - ) - ); + ); + + // Verify + assertNotNull(layer.getTextOpacity()); + assertNotNull(layer.getTextOpacity().getFunction()); + assertEquals(SourceFunction.class, layer.getTextOpacity().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getTextOpacity().getFunction()).getProperty()); + assertEquals(CategoricalStops.class, layer.getTextOpacity().getFunction().getStops().getClass()); + assertNotNull(((SourceFunction) layer.getTextOpacity().getFunction()).getDefaultValue()); + assertNotNull(((SourceFunction) layer.getTextOpacity().getFunction()).getDefaultValue().getValue()); + assertEquals(0.3f, ((SourceFunction) layer.getTextOpacity().getFunction()).getDefaultValue().getValue()); + } + }); - // Verify - assertNotNull(layer.getTextOpacity()); - assertNotNull(layer.getTextOpacity().getFunction()); - assertEquals(SourceFunction.class, layer.getTextOpacity().getFunction().getClass()); - assertEquals("FeaturePropertyA", ((SourceFunction) layer.getTextOpacity().getFunction()).getProperty()); - assertEquals(CategoricalStops.class, layer.getTextOpacity().getFunction().getStops().getClass()); - assertNotNull(((SourceFunction) layer.getTextOpacity().getFunction()).getDefaultValue()); - assertNotNull(((SourceFunction) layer.getTextOpacity().getFunction()).getDefaultValue().getValue()); - assertEquals(0.3f, ((SourceFunction) layer.getTextOpacity().getFunction()).getDefaultValue().getValue()); } @Test @@ -3082,34 +3804,39 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("text-opacity"); - assertNotNull(layer); - - // Set - layer.setProperties( - textOpacity( - composite( - "FeaturePropertyA", - exponential( - stop(0, 0.3f, textOpacity(0.9f)) - ).withBase(0.5f) - ).withDefaultValue(textOpacity(0.3f)) - ) - ); - - // Verify - assertNotNull(layer.getTextOpacity()); - assertNotNull(layer.getTextOpacity().getFunction()); - assertEquals(CompositeFunction.class, layer.getTextOpacity().getFunction().getClass()); - assertEquals("FeaturePropertyA", ((CompositeFunction) layer.getTextOpacity().getFunction()).getProperty()); - assertEquals(ExponentialStops.class, layer.getTextOpacity().getFunction().getStops().getClass()); - assertEquals(1, ((ExponentialStops) layer.getTextOpacity().getFunction().getStops()).size()); - - ExponentialStops<Stop.CompositeValue<Float, Float>, Float> stops = - (ExponentialStops<Stop.CompositeValue<Float, Float>, Float>) layer.getTextOpacity().getFunction().getStops(); - Stop<Stop.CompositeValue<Float, Float>, Float> stop = stops.iterator().next(); - assertEquals(0f, stop.in.zoom, 0.001); - assertEquals(0.3f, stop.in.value, 0.001f); - assertEquals(0.9f, stop.out, 0.001f); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + textOpacity( + composite( + "FeaturePropertyA", + exponential( + stop(0, 0.3f, textOpacity(0.9f)) + ).withBase(0.5f) + ).withDefaultValue(textOpacity(0.3f)) + ) + ); + + // Verify + assertNotNull(layer.getTextOpacity()); + assertNotNull(layer.getTextOpacity().getFunction()); + assertEquals(CompositeFunction.class, layer.getTextOpacity().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((CompositeFunction) layer.getTextOpacity().getFunction()).getProperty()); + assertEquals(ExponentialStops.class, layer.getTextOpacity().getFunction().getStops().getClass()); + assertEquals(1, ((ExponentialStops) layer.getTextOpacity().getFunction().getStops()).size()); + + ExponentialStops<Stop.CompositeValue<Float, Float>, Float> stops = + (ExponentialStops<Stop.CompositeValue<Float, Float>, Float>) layer.getTextOpacity().getFunction().getStops(); + Stop<Stop.CompositeValue<Float, Float>, Float> stop = stops.iterator().next(); + assertEquals(0f, stop.in.zoom, 0.001); + assertEquals(0.3f, stop.in.value, 0.001f); + assertEquals(0.9f, stop.out, 0.001f); + } + }); } @Test @@ -3117,12 +3844,17 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("text-colorTransitionOptions"); - assertNotNull(layer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); - // Set and Get - TransitionOptions options = new TransitionOptions(300, 100); - layer.setTextColorTransition(options); - assertEquals(layer.getTextColorTransition(), options); + // Set and Get + TransitionOptions options = new TransitionOptions(300, 100); + layer.setTextColorTransition(options); + assertEquals(layer.getTextColorTransition(), options); + } + }); } @Test @@ -3130,11 +3862,16 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("text-color"); - assertNotNull(layer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); - // Set and Get - layer.setProperties(textColor("rgba(0, 0, 0, 1)")); - assertEquals((String) layer.getTextColor().getValue(), (String) "rgba(0, 0, 0, 1)"); + // Set and Get + layer.setProperties(textColor("rgba(0, 0, 0, 1)")); + assertEquals((String) layer.getTextColor().getValue(), (String) "rgba(0, 0, 0, 1)"); + } + }); } @Test @@ -3142,26 +3879,31 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("text-color"); - assertNotNull(layer); - - // Set - layer.setProperties( - textColor( - zoom( - exponential( - stop(2, textColor("rgba(0, 0, 0, 1)")) - ).withBase(0.5f) - ) - ) - ); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + textColor( + zoom( + exponential( + stop(2, textColor("rgba(0, 0, 0, 1)")) + ).withBase(0.5f) + ) + ) + ); - // Verify - assertNotNull(layer.getTextColor()); - assertNotNull(layer.getTextColor().getFunction()); - assertEquals(CameraFunction.class, layer.getTextColor().getFunction().getClass()); - assertEquals(ExponentialStops.class, layer.getTextColor().getFunction().getStops().getClass()); - assertEquals(0.5f, ((ExponentialStops) layer.getTextColor().getFunction().getStops()).getBase(), 0.001); - assertEquals(1, ((ExponentialStops) layer.getTextColor().getFunction().getStops()).size()); + // Verify + assertNotNull(layer.getTextColor()); + assertNotNull(layer.getTextColor().getFunction()); + assertEquals(CameraFunction.class, layer.getTextColor().getFunction().getClass()); + assertEquals(ExponentialStops.class, layer.getTextColor().getFunction().getStops().getClass()); + assertEquals(0.5f, ((ExponentialStops) layer.getTextColor().getFunction().getStops()).getBase(), 0.001); + assertEquals(1, ((ExponentialStops) layer.getTextColor().getFunction().getStops()).size()); + } + }); } @Test @@ -3169,19 +3911,24 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("text-color"); - assertNotNull(layer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); - // Set - layer.setProperties( - textColor(property("FeaturePropertyA", Stops.<String>identity())) - ); + // Set + layer.setProperties( + textColor(property("FeaturePropertyA", Stops.<String>identity())) + ); - // Verify - assertNotNull(layer.getTextColor()); - assertNotNull(layer.getTextColor().getFunction()); - assertEquals(SourceFunction.class, layer.getTextColor().getFunction().getClass()); - assertEquals("FeaturePropertyA", ((SourceFunction) layer.getTextColor().getFunction()).getProperty()); - assertEquals(IdentityStops.class, layer.getTextColor().getFunction().getStops().getClass()); + // Verify + assertNotNull(layer.getTextColor()); + assertNotNull(layer.getTextColor().getFunction()); + assertEquals(SourceFunction.class, layer.getTextColor().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getTextColor().getFunction()).getProperty()); + assertEquals(IdentityStops.class, layer.getTextColor().getFunction().getStops().getClass()); + } + }); } @Test @@ -3189,26 +3936,31 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("text-color"); - assertNotNull(layer); - - // Set - layer.setProperties( - textColor( - property( - "FeaturePropertyA", - exponential( - stop(Color.RED, textColor(Color.RED)) - ).withBase(0.5f) - ) - ) - ); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + textColor( + property( + "FeaturePropertyA", + exponential( + stop(Color.RED, textColor(Color.RED)) + ).withBase(0.5f) + ) + ) + ); - // Verify - assertNotNull(layer.getTextColor()); - assertNotNull(layer.getTextColor().getFunction()); - assertEquals(SourceFunction.class, layer.getTextColor().getFunction().getClass()); - assertEquals("FeaturePropertyA", ((SourceFunction) layer.getTextColor().getFunction()).getProperty()); - assertEquals(ExponentialStops.class, layer.getTextColor().getFunction().getStops().getClass()); + // Verify + assertNotNull(layer.getTextColor()); + assertNotNull(layer.getTextColor().getFunction()); + assertEquals(SourceFunction.class, layer.getTextColor().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getTextColor().getFunction()).getProperty()); + assertEquals(ExponentialStops.class, layer.getTextColor().getFunction().getStops().getClass()); + } + }); } @Test @@ -3216,29 +3968,35 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("text-color"); - assertNotNull(layer); - - // Set - layer.setProperties( - textColor( - property( - "FeaturePropertyA", - categorical( - stop("valueA", textColor(Color.RED)) + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + textColor( + property( + "FeaturePropertyA", + categorical( + stop("valueA", textColor(Color.RED)) + ) + ).withDefaultValue(textColor(Color.GREEN)) ) - ).withDefaultValue(textColor(Color.GREEN)) - ) - ); + ); + + // Verify + assertNotNull(layer.getTextColor()); + assertNotNull(layer.getTextColor().getFunction()); + assertEquals(SourceFunction.class, layer.getTextColor().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getTextColor().getFunction()).getProperty()); + assertEquals(CategoricalStops.class, layer.getTextColor().getFunction().getStops().getClass()); + assertNotNull(((SourceFunction) layer.getTextColor().getFunction()).getDefaultValue()); + assertNotNull(((SourceFunction) layer.getTextColor().getFunction()).getDefaultValue().getValue()); + assertEquals(Color.GREEN, (int) ((SourceFunction) layer.getTextColor().getFunction()).getDefaultValue().getColorInt()); + } + }); - // Verify - assertNotNull(layer.getTextColor()); - assertNotNull(layer.getTextColor().getFunction()); - assertEquals(SourceFunction.class, layer.getTextColor().getFunction().getClass()); - assertEquals("FeaturePropertyA", ((SourceFunction) layer.getTextColor().getFunction()).getProperty()); - assertEquals(CategoricalStops.class, layer.getTextColor().getFunction().getStops().getClass()); - assertNotNull(((SourceFunction) layer.getTextColor().getFunction()).getDefaultValue()); - assertNotNull(((SourceFunction) layer.getTextColor().getFunction()).getDefaultValue().getValue()); - assertEquals(Color.GREEN, (int) ((SourceFunction) layer.getTextColor().getFunction()).getDefaultValue().getColorInt()); } @Test @@ -3246,11 +4004,16 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("text-color"); - assertNotNull(layer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); - // Set and Get - layer.setProperties(textColor(Color.RED)); - assertEquals(layer.getTextColorAsInt(), Color.RED); + // Set and Get + layer.setProperties(textColor(Color.RED)); + assertEquals(layer.getTextColorAsInt(), Color.RED); + } + }); } @Test @@ -3258,12 +4021,17 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("text-halo-colorTransitionOptions"); - assertNotNull(layer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); - // Set and Get - TransitionOptions options = new TransitionOptions(300, 100); - layer.setTextHaloColorTransition(options); - assertEquals(layer.getTextHaloColorTransition(), options); + // Set and Get + TransitionOptions options = new TransitionOptions(300, 100); + layer.setTextHaloColorTransition(options); + assertEquals(layer.getTextHaloColorTransition(), options); + } + }); } @Test @@ -3271,11 +4039,16 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("text-halo-color"); - assertNotNull(layer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); - // Set and Get - layer.setProperties(textHaloColor("rgba(0, 0, 0, 1)")); - assertEquals((String) layer.getTextHaloColor().getValue(), (String) "rgba(0, 0, 0, 1)"); + // Set and Get + layer.setProperties(textHaloColor("rgba(0, 0, 0, 1)")); + assertEquals((String) layer.getTextHaloColor().getValue(), (String) "rgba(0, 0, 0, 1)"); + } + }); } @Test @@ -3283,26 +4056,31 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("text-halo-color"); - assertNotNull(layer); - - // Set - layer.setProperties( - textHaloColor( - zoom( - exponential( - stop(2, textHaloColor("rgba(0, 0, 0, 1)")) - ).withBase(0.5f) - ) - ) - ); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + textHaloColor( + zoom( + exponential( + stop(2, textHaloColor("rgba(0, 0, 0, 1)")) + ).withBase(0.5f) + ) + ) + ); - // Verify - assertNotNull(layer.getTextHaloColor()); - assertNotNull(layer.getTextHaloColor().getFunction()); - assertEquals(CameraFunction.class, layer.getTextHaloColor().getFunction().getClass()); - assertEquals(ExponentialStops.class, layer.getTextHaloColor().getFunction().getStops().getClass()); - assertEquals(0.5f, ((ExponentialStops) layer.getTextHaloColor().getFunction().getStops()).getBase(), 0.001); - assertEquals(1, ((ExponentialStops) layer.getTextHaloColor().getFunction().getStops()).size()); + // Verify + assertNotNull(layer.getTextHaloColor()); + assertNotNull(layer.getTextHaloColor().getFunction()); + assertEquals(CameraFunction.class, layer.getTextHaloColor().getFunction().getClass()); + assertEquals(ExponentialStops.class, layer.getTextHaloColor().getFunction().getStops().getClass()); + assertEquals(0.5f, ((ExponentialStops) layer.getTextHaloColor().getFunction().getStops()).getBase(), 0.001); + assertEquals(1, ((ExponentialStops) layer.getTextHaloColor().getFunction().getStops()).size()); + } + }); } @Test @@ -3310,19 +4088,24 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("text-halo-color"); - assertNotNull(layer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); - // Set - layer.setProperties( - textHaloColor(property("FeaturePropertyA", Stops.<String>identity())) - ); + // Set + layer.setProperties( + textHaloColor(property("FeaturePropertyA", Stops.<String>identity())) + ); - // Verify - assertNotNull(layer.getTextHaloColor()); - assertNotNull(layer.getTextHaloColor().getFunction()); - assertEquals(SourceFunction.class, layer.getTextHaloColor().getFunction().getClass()); - assertEquals("FeaturePropertyA", ((SourceFunction) layer.getTextHaloColor().getFunction()).getProperty()); - assertEquals(IdentityStops.class, layer.getTextHaloColor().getFunction().getStops().getClass()); + // Verify + assertNotNull(layer.getTextHaloColor()); + assertNotNull(layer.getTextHaloColor().getFunction()); + assertEquals(SourceFunction.class, layer.getTextHaloColor().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getTextHaloColor().getFunction()).getProperty()); + assertEquals(IdentityStops.class, layer.getTextHaloColor().getFunction().getStops().getClass()); + } + }); } @Test @@ -3330,26 +4113,31 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("text-halo-color"); - assertNotNull(layer); - - // Set - layer.setProperties( - textHaloColor( - property( - "FeaturePropertyA", - exponential( - stop(Color.RED, textHaloColor(Color.RED)) - ).withBase(0.5f) - ) - ) - ); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + textHaloColor( + property( + "FeaturePropertyA", + exponential( + stop(Color.RED, textHaloColor(Color.RED)) + ).withBase(0.5f) + ) + ) + ); - // Verify - assertNotNull(layer.getTextHaloColor()); - assertNotNull(layer.getTextHaloColor().getFunction()); - assertEquals(SourceFunction.class, layer.getTextHaloColor().getFunction().getClass()); - assertEquals("FeaturePropertyA", ((SourceFunction) layer.getTextHaloColor().getFunction()).getProperty()); - assertEquals(ExponentialStops.class, layer.getTextHaloColor().getFunction().getStops().getClass()); + // Verify + assertNotNull(layer.getTextHaloColor()); + assertNotNull(layer.getTextHaloColor().getFunction()); + assertEquals(SourceFunction.class, layer.getTextHaloColor().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getTextHaloColor().getFunction()).getProperty()); + assertEquals(ExponentialStops.class, layer.getTextHaloColor().getFunction().getStops().getClass()); + } + }); } @Test @@ -3357,29 +4145,35 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("text-halo-color"); - assertNotNull(layer); - - // Set - layer.setProperties( - textHaloColor( - property( - "FeaturePropertyA", - categorical( - stop("valueA", textHaloColor(Color.RED)) + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + textHaloColor( + property( + "FeaturePropertyA", + categorical( + stop("valueA", textHaloColor(Color.RED)) + ) + ).withDefaultValue(textHaloColor(Color.GREEN)) ) - ).withDefaultValue(textHaloColor(Color.GREEN)) - ) - ); + ); + + // Verify + assertNotNull(layer.getTextHaloColor()); + assertNotNull(layer.getTextHaloColor().getFunction()); + assertEquals(SourceFunction.class, layer.getTextHaloColor().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getTextHaloColor().getFunction()).getProperty()); + assertEquals(CategoricalStops.class, layer.getTextHaloColor().getFunction().getStops().getClass()); + assertNotNull(((SourceFunction) layer.getTextHaloColor().getFunction()).getDefaultValue()); + assertNotNull(((SourceFunction) layer.getTextHaloColor().getFunction()).getDefaultValue().getValue()); + assertEquals(Color.GREEN, (int) ((SourceFunction) layer.getTextHaloColor().getFunction()).getDefaultValue().getColorInt()); + } + }); - // Verify - assertNotNull(layer.getTextHaloColor()); - assertNotNull(layer.getTextHaloColor().getFunction()); - assertEquals(SourceFunction.class, layer.getTextHaloColor().getFunction().getClass()); - assertEquals("FeaturePropertyA", ((SourceFunction) layer.getTextHaloColor().getFunction()).getProperty()); - assertEquals(CategoricalStops.class, layer.getTextHaloColor().getFunction().getStops().getClass()); - assertNotNull(((SourceFunction) layer.getTextHaloColor().getFunction()).getDefaultValue()); - assertNotNull(((SourceFunction) layer.getTextHaloColor().getFunction()).getDefaultValue().getValue()); - assertEquals(Color.GREEN, (int) ((SourceFunction) layer.getTextHaloColor().getFunction()).getDefaultValue().getColorInt()); } @Test @@ -3387,11 +4181,16 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("text-halo-color"); - assertNotNull(layer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); - // Set and Get - layer.setProperties(textHaloColor(Color.RED)); - assertEquals(layer.getTextHaloColorAsInt(), Color.RED); + // Set and Get + layer.setProperties(textHaloColor(Color.RED)); + assertEquals(layer.getTextHaloColorAsInt(), Color.RED); + } + }); } @Test @@ -3399,12 +4198,17 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("text-halo-widthTransitionOptions"); - assertNotNull(layer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); - // Set and Get - TransitionOptions options = new TransitionOptions(300, 100); - layer.setTextHaloWidthTransition(options); - assertEquals(layer.getTextHaloWidthTransition(), options); + // Set and Get + TransitionOptions options = new TransitionOptions(300, 100); + layer.setTextHaloWidthTransition(options); + assertEquals(layer.getTextHaloWidthTransition(), options); + } + }); } @Test @@ -3412,11 +4216,16 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("text-halo-width"); - assertNotNull(layer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); - // Set and Get - layer.setProperties(textHaloWidth(0.3f)); - assertEquals((Float) layer.getTextHaloWidth().getValue(), (Float) 0.3f); + // Set and Get + layer.setProperties(textHaloWidth(0.3f)); + assertEquals((Float) layer.getTextHaloWidth().getValue(), (Float) 0.3f); + } + }); } @Test @@ -3424,26 +4233,31 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("text-halo-width"); - assertNotNull(layer); - - // Set - layer.setProperties( - textHaloWidth( - zoom( - exponential( - stop(2, textHaloWidth(0.3f)) - ).withBase(0.5f) - ) - ) - ); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + textHaloWidth( + zoom( + exponential( + stop(2, textHaloWidth(0.3f)) + ).withBase(0.5f) + ) + ) + ); - // Verify - assertNotNull(layer.getTextHaloWidth()); - assertNotNull(layer.getTextHaloWidth().getFunction()); - assertEquals(CameraFunction.class, layer.getTextHaloWidth().getFunction().getClass()); - assertEquals(ExponentialStops.class, layer.getTextHaloWidth().getFunction().getStops().getClass()); - assertEquals(0.5f, ((ExponentialStops) layer.getTextHaloWidth().getFunction().getStops()).getBase(), 0.001); - assertEquals(1, ((ExponentialStops) layer.getTextHaloWidth().getFunction().getStops()).size()); + // Verify + assertNotNull(layer.getTextHaloWidth()); + assertNotNull(layer.getTextHaloWidth().getFunction()); + assertEquals(CameraFunction.class, layer.getTextHaloWidth().getFunction().getClass()); + assertEquals(ExponentialStops.class, layer.getTextHaloWidth().getFunction().getStops().getClass()); + assertEquals(0.5f, ((ExponentialStops) layer.getTextHaloWidth().getFunction().getStops()).getBase(), 0.001); + assertEquals(1, ((ExponentialStops) layer.getTextHaloWidth().getFunction().getStops()).size()); + } + }); } @Test @@ -3451,19 +4265,24 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("text-halo-width"); - assertNotNull(layer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); - // Set - layer.setProperties( - textHaloWidth(property("FeaturePropertyA", Stops.<Float>identity())) - ); + // Set + layer.setProperties( + textHaloWidth(property("FeaturePropertyA", Stops.<Float>identity())) + ); - // Verify - assertNotNull(layer.getTextHaloWidth()); - assertNotNull(layer.getTextHaloWidth().getFunction()); - assertEquals(SourceFunction.class, layer.getTextHaloWidth().getFunction().getClass()); - assertEquals("FeaturePropertyA", ((SourceFunction) layer.getTextHaloWidth().getFunction()).getProperty()); - assertEquals(IdentityStops.class, layer.getTextHaloWidth().getFunction().getStops().getClass()); + // Verify + assertNotNull(layer.getTextHaloWidth()); + assertNotNull(layer.getTextHaloWidth().getFunction()); + assertEquals(SourceFunction.class, layer.getTextHaloWidth().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getTextHaloWidth().getFunction()).getProperty()); + assertEquals(IdentityStops.class, layer.getTextHaloWidth().getFunction().getStops().getClass()); + } + }); } @Test @@ -3471,26 +4290,31 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("text-halo-width"); - assertNotNull(layer); - - // Set - layer.setProperties( - textHaloWidth( - property( - "FeaturePropertyA", - exponential( - stop(0.3f, textHaloWidth(0.3f)) - ).withBase(0.5f) - ) - ) - ); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + textHaloWidth( + property( + "FeaturePropertyA", + exponential( + stop(0.3f, textHaloWidth(0.3f)) + ).withBase(0.5f) + ) + ) + ); - // Verify - assertNotNull(layer.getTextHaloWidth()); - assertNotNull(layer.getTextHaloWidth().getFunction()); - assertEquals(SourceFunction.class, layer.getTextHaloWidth().getFunction().getClass()); - assertEquals("FeaturePropertyA", ((SourceFunction) layer.getTextHaloWidth().getFunction()).getProperty()); - assertEquals(ExponentialStops.class, layer.getTextHaloWidth().getFunction().getStops().getClass()); + // Verify + assertNotNull(layer.getTextHaloWidth()); + assertNotNull(layer.getTextHaloWidth().getFunction()); + assertEquals(SourceFunction.class, layer.getTextHaloWidth().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getTextHaloWidth().getFunction()).getProperty()); + assertEquals(ExponentialStops.class, layer.getTextHaloWidth().getFunction().getStops().getClass()); + } + }); } @Test @@ -3498,29 +4322,35 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("text-halo-width"); - assertNotNull(layer); - - // Set - layer.setProperties( - textHaloWidth( - property( - "FeaturePropertyA", - categorical( - stop(1.0f, textHaloWidth(0.3f)) + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + textHaloWidth( + property( + "FeaturePropertyA", + categorical( + stop(1.0f, textHaloWidth(0.3f)) + ) + ).withDefaultValue(textHaloWidth(0.3f)) ) - ).withDefaultValue(textHaloWidth(0.3f)) - ) - ); + ); + + // Verify + assertNotNull(layer.getTextHaloWidth()); + assertNotNull(layer.getTextHaloWidth().getFunction()); + assertEquals(SourceFunction.class, layer.getTextHaloWidth().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getTextHaloWidth().getFunction()).getProperty()); + assertEquals(CategoricalStops.class, layer.getTextHaloWidth().getFunction().getStops().getClass()); + assertNotNull(((SourceFunction) layer.getTextHaloWidth().getFunction()).getDefaultValue()); + assertNotNull(((SourceFunction) layer.getTextHaloWidth().getFunction()).getDefaultValue().getValue()); + assertEquals(0.3f, ((SourceFunction) layer.getTextHaloWidth().getFunction()).getDefaultValue().getValue()); + } + }); - // Verify - assertNotNull(layer.getTextHaloWidth()); - assertNotNull(layer.getTextHaloWidth().getFunction()); - assertEquals(SourceFunction.class, layer.getTextHaloWidth().getFunction().getClass()); - assertEquals("FeaturePropertyA", ((SourceFunction) layer.getTextHaloWidth().getFunction()).getProperty()); - assertEquals(CategoricalStops.class, layer.getTextHaloWidth().getFunction().getStops().getClass()); - assertNotNull(((SourceFunction) layer.getTextHaloWidth().getFunction()).getDefaultValue()); - assertNotNull(((SourceFunction) layer.getTextHaloWidth().getFunction()).getDefaultValue().getValue()); - assertEquals(0.3f, ((SourceFunction) layer.getTextHaloWidth().getFunction()).getDefaultValue().getValue()); } @Test @@ -3528,34 +4358,39 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("text-halo-width"); - assertNotNull(layer); - - // Set - layer.setProperties( - textHaloWidth( - composite( - "FeaturePropertyA", - exponential( - stop(0, 0.3f, textHaloWidth(0.9f)) - ).withBase(0.5f) - ).withDefaultValue(textHaloWidth(0.3f)) - ) - ); - - // Verify - assertNotNull(layer.getTextHaloWidth()); - assertNotNull(layer.getTextHaloWidth().getFunction()); - assertEquals(CompositeFunction.class, layer.getTextHaloWidth().getFunction().getClass()); - assertEquals("FeaturePropertyA", ((CompositeFunction) layer.getTextHaloWidth().getFunction()).getProperty()); - assertEquals(ExponentialStops.class, layer.getTextHaloWidth().getFunction().getStops().getClass()); - assertEquals(1, ((ExponentialStops) layer.getTextHaloWidth().getFunction().getStops()).size()); - - ExponentialStops<Stop.CompositeValue<Float, Float>, Float> stops = - (ExponentialStops<Stop.CompositeValue<Float, Float>, Float>) layer.getTextHaloWidth().getFunction().getStops(); - Stop<Stop.CompositeValue<Float, Float>, Float> stop = stops.iterator().next(); - assertEquals(0f, stop.in.zoom, 0.001); - assertEquals(0.3f, stop.in.value, 0.001f); - assertEquals(0.9f, stop.out, 0.001f); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + textHaloWidth( + composite( + "FeaturePropertyA", + exponential( + stop(0, 0.3f, textHaloWidth(0.9f)) + ).withBase(0.5f) + ).withDefaultValue(textHaloWidth(0.3f)) + ) + ); + + // Verify + assertNotNull(layer.getTextHaloWidth()); + assertNotNull(layer.getTextHaloWidth().getFunction()); + assertEquals(CompositeFunction.class, layer.getTextHaloWidth().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((CompositeFunction) layer.getTextHaloWidth().getFunction()).getProperty()); + assertEquals(ExponentialStops.class, layer.getTextHaloWidth().getFunction().getStops().getClass()); + assertEquals(1, ((ExponentialStops) layer.getTextHaloWidth().getFunction().getStops()).size()); + + ExponentialStops<Stop.CompositeValue<Float, Float>, Float> stops = + (ExponentialStops<Stop.CompositeValue<Float, Float>, Float>) layer.getTextHaloWidth().getFunction().getStops(); + Stop<Stop.CompositeValue<Float, Float>, Float> stop = stops.iterator().next(); + assertEquals(0f, stop.in.zoom, 0.001); + assertEquals(0.3f, stop.in.value, 0.001f); + assertEquals(0.9f, stop.out, 0.001f); + } + }); } @Test @@ -3563,12 +4398,17 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("text-halo-blurTransitionOptions"); - assertNotNull(layer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); - // Set and Get - TransitionOptions options = new TransitionOptions(300, 100); - layer.setTextHaloBlurTransition(options); - assertEquals(layer.getTextHaloBlurTransition(), options); + // Set and Get + TransitionOptions options = new TransitionOptions(300, 100); + layer.setTextHaloBlurTransition(options); + assertEquals(layer.getTextHaloBlurTransition(), options); + } + }); } @Test @@ -3576,11 +4416,16 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("text-halo-blur"); - assertNotNull(layer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); - // Set and Get - layer.setProperties(textHaloBlur(0.3f)); - assertEquals((Float) layer.getTextHaloBlur().getValue(), (Float) 0.3f); + // Set and Get + layer.setProperties(textHaloBlur(0.3f)); + assertEquals((Float) layer.getTextHaloBlur().getValue(), (Float) 0.3f); + } + }); } @Test @@ -3588,26 +4433,31 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("text-halo-blur"); - assertNotNull(layer); - - // Set - layer.setProperties( - textHaloBlur( - zoom( - exponential( - stop(2, textHaloBlur(0.3f)) - ).withBase(0.5f) - ) - ) - ); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + textHaloBlur( + zoom( + exponential( + stop(2, textHaloBlur(0.3f)) + ).withBase(0.5f) + ) + ) + ); - // Verify - assertNotNull(layer.getTextHaloBlur()); - assertNotNull(layer.getTextHaloBlur().getFunction()); - assertEquals(CameraFunction.class, layer.getTextHaloBlur().getFunction().getClass()); - assertEquals(ExponentialStops.class, layer.getTextHaloBlur().getFunction().getStops().getClass()); - assertEquals(0.5f, ((ExponentialStops) layer.getTextHaloBlur().getFunction().getStops()).getBase(), 0.001); - assertEquals(1, ((ExponentialStops) layer.getTextHaloBlur().getFunction().getStops()).size()); + // Verify + assertNotNull(layer.getTextHaloBlur()); + assertNotNull(layer.getTextHaloBlur().getFunction()); + assertEquals(CameraFunction.class, layer.getTextHaloBlur().getFunction().getClass()); + assertEquals(ExponentialStops.class, layer.getTextHaloBlur().getFunction().getStops().getClass()); + assertEquals(0.5f, ((ExponentialStops) layer.getTextHaloBlur().getFunction().getStops()).getBase(), 0.001); + assertEquals(1, ((ExponentialStops) layer.getTextHaloBlur().getFunction().getStops()).size()); + } + }); } @Test @@ -3615,19 +4465,24 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("text-halo-blur"); - assertNotNull(layer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); - // Set - layer.setProperties( - textHaloBlur(property("FeaturePropertyA", Stops.<Float>identity())) - ); + // Set + layer.setProperties( + textHaloBlur(property("FeaturePropertyA", Stops.<Float>identity())) + ); - // Verify - assertNotNull(layer.getTextHaloBlur()); - assertNotNull(layer.getTextHaloBlur().getFunction()); - assertEquals(SourceFunction.class, layer.getTextHaloBlur().getFunction().getClass()); - assertEquals("FeaturePropertyA", ((SourceFunction) layer.getTextHaloBlur().getFunction()).getProperty()); - assertEquals(IdentityStops.class, layer.getTextHaloBlur().getFunction().getStops().getClass()); + // Verify + assertNotNull(layer.getTextHaloBlur()); + assertNotNull(layer.getTextHaloBlur().getFunction()); + assertEquals(SourceFunction.class, layer.getTextHaloBlur().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getTextHaloBlur().getFunction()).getProperty()); + assertEquals(IdentityStops.class, layer.getTextHaloBlur().getFunction().getStops().getClass()); + } + }); } @Test @@ -3635,26 +4490,31 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("text-halo-blur"); - assertNotNull(layer); - - // Set - layer.setProperties( - textHaloBlur( - property( - "FeaturePropertyA", - exponential( - stop(0.3f, textHaloBlur(0.3f)) - ).withBase(0.5f) - ) - ) - ); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + textHaloBlur( + property( + "FeaturePropertyA", + exponential( + stop(0.3f, textHaloBlur(0.3f)) + ).withBase(0.5f) + ) + ) + ); - // Verify - assertNotNull(layer.getTextHaloBlur()); - assertNotNull(layer.getTextHaloBlur().getFunction()); - assertEquals(SourceFunction.class, layer.getTextHaloBlur().getFunction().getClass()); - assertEquals("FeaturePropertyA", ((SourceFunction) layer.getTextHaloBlur().getFunction()).getProperty()); - assertEquals(ExponentialStops.class, layer.getTextHaloBlur().getFunction().getStops().getClass()); + // Verify + assertNotNull(layer.getTextHaloBlur()); + assertNotNull(layer.getTextHaloBlur().getFunction()); + assertEquals(SourceFunction.class, layer.getTextHaloBlur().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getTextHaloBlur().getFunction()).getProperty()); + assertEquals(ExponentialStops.class, layer.getTextHaloBlur().getFunction().getStops().getClass()); + } + }); } @Test @@ -3662,29 +4522,35 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("text-halo-blur"); - assertNotNull(layer); - - // Set - layer.setProperties( - textHaloBlur( - property( - "FeaturePropertyA", - categorical( - stop(1.0f, textHaloBlur(0.3f)) + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + textHaloBlur( + property( + "FeaturePropertyA", + categorical( + stop(1.0f, textHaloBlur(0.3f)) + ) + ).withDefaultValue(textHaloBlur(0.3f)) ) - ).withDefaultValue(textHaloBlur(0.3f)) - ) - ); + ); + + // Verify + assertNotNull(layer.getTextHaloBlur()); + assertNotNull(layer.getTextHaloBlur().getFunction()); + assertEquals(SourceFunction.class, layer.getTextHaloBlur().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getTextHaloBlur().getFunction()).getProperty()); + assertEquals(CategoricalStops.class, layer.getTextHaloBlur().getFunction().getStops().getClass()); + assertNotNull(((SourceFunction) layer.getTextHaloBlur().getFunction()).getDefaultValue()); + assertNotNull(((SourceFunction) layer.getTextHaloBlur().getFunction()).getDefaultValue().getValue()); + assertEquals(0.3f, ((SourceFunction) layer.getTextHaloBlur().getFunction()).getDefaultValue().getValue()); + } + }); - // Verify - assertNotNull(layer.getTextHaloBlur()); - assertNotNull(layer.getTextHaloBlur().getFunction()); - assertEquals(SourceFunction.class, layer.getTextHaloBlur().getFunction().getClass()); - assertEquals("FeaturePropertyA", ((SourceFunction) layer.getTextHaloBlur().getFunction()).getProperty()); - assertEquals(CategoricalStops.class, layer.getTextHaloBlur().getFunction().getStops().getClass()); - assertNotNull(((SourceFunction) layer.getTextHaloBlur().getFunction()).getDefaultValue()); - assertNotNull(((SourceFunction) layer.getTextHaloBlur().getFunction()).getDefaultValue().getValue()); - assertEquals(0.3f, ((SourceFunction) layer.getTextHaloBlur().getFunction()).getDefaultValue().getValue()); } @Test @@ -3692,34 +4558,39 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("text-halo-blur"); - assertNotNull(layer); - - // Set - layer.setProperties( - textHaloBlur( - composite( - "FeaturePropertyA", - exponential( - stop(0, 0.3f, textHaloBlur(0.9f)) - ).withBase(0.5f) - ).withDefaultValue(textHaloBlur(0.3f)) - ) - ); - - // Verify - assertNotNull(layer.getTextHaloBlur()); - assertNotNull(layer.getTextHaloBlur().getFunction()); - assertEquals(CompositeFunction.class, layer.getTextHaloBlur().getFunction().getClass()); - assertEquals("FeaturePropertyA", ((CompositeFunction) layer.getTextHaloBlur().getFunction()).getProperty()); - assertEquals(ExponentialStops.class, layer.getTextHaloBlur().getFunction().getStops().getClass()); - assertEquals(1, ((ExponentialStops) layer.getTextHaloBlur().getFunction().getStops()).size()); - - ExponentialStops<Stop.CompositeValue<Float, Float>, Float> stops = - (ExponentialStops<Stop.CompositeValue<Float, Float>, Float>) layer.getTextHaloBlur().getFunction().getStops(); - Stop<Stop.CompositeValue<Float, Float>, Float> stop = stops.iterator().next(); - assertEquals(0f, stop.in.zoom, 0.001); - assertEquals(0.3f, stop.in.value, 0.001f); - assertEquals(0.9f, stop.out, 0.001f); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + textHaloBlur( + composite( + "FeaturePropertyA", + exponential( + stop(0, 0.3f, textHaloBlur(0.9f)) + ).withBase(0.5f) + ).withDefaultValue(textHaloBlur(0.3f)) + ) + ); + + // Verify + assertNotNull(layer.getTextHaloBlur()); + assertNotNull(layer.getTextHaloBlur().getFunction()); + assertEquals(CompositeFunction.class, layer.getTextHaloBlur().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((CompositeFunction) layer.getTextHaloBlur().getFunction()).getProperty()); + assertEquals(ExponentialStops.class, layer.getTextHaloBlur().getFunction().getStops().getClass()); + assertEquals(1, ((ExponentialStops) layer.getTextHaloBlur().getFunction().getStops()).size()); + + ExponentialStops<Stop.CompositeValue<Float, Float>, Float> stops = + (ExponentialStops<Stop.CompositeValue<Float, Float>, Float>) layer.getTextHaloBlur().getFunction().getStops(); + Stop<Stop.CompositeValue<Float, Float>, Float> stop = stops.iterator().next(); + assertEquals(0f, stop.in.zoom, 0.001); + assertEquals(0.3f, stop.in.value, 0.001f); + assertEquals(0.9f, stop.out, 0.001f); + } + }); } @Test @@ -3727,12 +4598,17 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("text-translateTransitionOptions"); - assertNotNull(layer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); - // Set and Get - TransitionOptions options = new TransitionOptions(300, 100); - layer.setTextTranslateTransition(options); - assertEquals(layer.getTextTranslateTransition(), options); + // Set and Get + TransitionOptions options = new TransitionOptions(300, 100); + layer.setTextTranslateTransition(options); + assertEquals(layer.getTextTranslateTransition(), options); + } + }); } @Test @@ -3740,11 +4616,16 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("text-translate"); - assertNotNull(layer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); - // Set and Get - layer.setProperties(textTranslate(new Float[]{0f,0f})); - assertEquals((Float[]) layer.getTextTranslate().getValue(), (Float[]) new Float[]{0f,0f}); + // Set and Get + layer.setProperties(textTranslate(new Float[] {0f, 0f})); + assertEquals((Float[]) layer.getTextTranslate().getValue(), (Float[]) new Float[] {0f, 0f}); + } + }); } @Test @@ -3752,26 +4633,31 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("text-translate"); - assertNotNull(layer); - - // Set - layer.setProperties( - textTranslate( - zoom( - exponential( - stop(2, textTranslate(new Float[]{0f,0f})) - ).withBase(0.5f) - ) - ) - ); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + textTranslate( + zoom( + exponential( + stop(2, textTranslate(new Float[] {0f, 0f})) + ).withBase(0.5f) + ) + ) + ); - // Verify - assertNotNull(layer.getTextTranslate()); - assertNotNull(layer.getTextTranslate().getFunction()); - assertEquals(CameraFunction.class, layer.getTextTranslate().getFunction().getClass()); - assertEquals(ExponentialStops.class, layer.getTextTranslate().getFunction().getStops().getClass()); - assertEquals(0.5f, ((ExponentialStops) layer.getTextTranslate().getFunction().getStops()).getBase(), 0.001); - assertEquals(1, ((ExponentialStops) layer.getTextTranslate().getFunction().getStops()).size()); + // Verify + assertNotNull(layer.getTextTranslate()); + assertNotNull(layer.getTextTranslate().getFunction()); + assertEquals(CameraFunction.class, layer.getTextTranslate().getFunction().getClass()); + assertEquals(ExponentialStops.class, layer.getTextTranslate().getFunction().getStops().getClass()); + assertEquals(0.5f, ((ExponentialStops) layer.getTextTranslate().getFunction().getStops()).getBase(), 0.001); + assertEquals(1, ((ExponentialStops) layer.getTextTranslate().getFunction().getStops()).size()); + } + }); } @Test @@ -3779,11 +4665,16 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("text-translate-anchor"); - assertNotNull(layer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); - // Set and Get - layer.setProperties(textTranslateAnchor(TEXT_TRANSLATE_ANCHOR_MAP)); - assertEquals((String) layer.getTextTranslateAnchor().getValue(), (String) TEXT_TRANSLATE_ANCHOR_MAP); + // Set and Get + layer.setProperties(textTranslateAnchor(TEXT_TRANSLATE_ANCHOR_MAP)); + assertEquals((String) layer.getTextTranslateAnchor().getValue(), (String) TEXT_TRANSLATE_ANCHOR_MAP); + } + }); } @Test @@ -3791,25 +4682,30 @@ public class SymbolLayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("text-translate-anchor"); - assertNotNull(layer); - - // Set - layer.setProperties( - textTranslateAnchor( - zoom( - interval( - stop(2, textTranslateAnchor(TEXT_TRANSLATE_ANCHOR_MAP)) - ) - ) - ) - ); - - // Verify - assertNotNull(layer.getTextTranslateAnchor()); - assertNotNull(layer.getTextTranslateAnchor().getFunction()); - assertEquals(CameraFunction.class, layer.getTextTranslateAnchor().getFunction().getClass()); - assertEquals(IntervalStops.class, layer.getTextTranslateAnchor().getFunction().getStops().getClass()); - assertEquals(1, ((IntervalStops) layer.getTextTranslateAnchor().getFunction().getStops()).size()); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + textTranslateAnchor( + zoom( + interval( + stop(2, textTranslateAnchor(TEXT_TRANSLATE_ANCHOR_MAP)) + ) + ) + ) + ); + + // Verify + assertNotNull(layer.getTextTranslateAnchor()); + assertNotNull(layer.getTextTranslateAnchor().getFunction()); + assertEquals(CameraFunction.class, layer.getTextTranslateAnchor().getFunction().getClass()); + assertEquals(IntervalStops.class, layer.getTextTranslateAnchor().getFunction().getStops().getClass()); + assertEquals(1, ((IntervalStops) layer.getTextTranslateAnchor().getFunction().getStops()).size()); + } + }); } } diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/layer.junit.ejs b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/layer.junit.ejs index 02aedadfa5..192740f708 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/layer.junit.ejs +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/layer.junit.ejs @@ -7,9 +7,9 @@ package com.mapbox.mapboxsdk.testapp.style; import android.graphics.Color; -import android.support.test.espresso.Espresso; -import android.support.test.rule.ActivityTestRule; +import android.support.test.espresso.UiController; import android.support.test.runner.AndroidJUnit4; + import timber.log.Timber; import com.mapbox.mapboxsdk.maps.MapboxMap; @@ -23,20 +23,16 @@ import com.mapbox.mapboxsdk.style.functions.stops.IntervalStops; import com.mapbox.mapboxsdk.style.functions.stops.Stop; import com.mapbox.mapboxsdk.style.functions.stops.Stops; import com.mapbox.mapboxsdk.style.layers.<%- camelize(type) %>Layer; -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.action.MapboxMapAction; import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest; -import org.junit.After; -import org.junit.Before; -import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; import static com.mapbox.mapboxsdk.style.functions.Function.*; import static com.mapbox.mapboxsdk.style.functions.stops.Stop.stop; import static com.mapbox.mapboxsdk.style.functions.stops.Stops.*; +import static com.mapbox.mapboxsdk.testapp.action.MapboxMapAction.invoke; import static org.junit.Assert.*; import static com.mapbox.mapboxsdk.style.layers.Property.*; import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*; @@ -57,19 +53,30 @@ public class <%- camelize(type) %>LayerTest extends BaseActivityTest { return EspressoTestActivity.class; } - private void setupLayer(){ + private void setupLayer() { <% if (type === 'background') { -%> Timber.i("Retrieving layer"); - layer = mapboxMap.getLayerAs("background"); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + layer = mapboxMap.getLayerAs("background"); + } + }); <% } else { -%> - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new <%- camelize(type) %>Layer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - // Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } + Timber.i("Retrieving layer"); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new <%- camelize(type) %>Layer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + // Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); + } + } + }); <% } -%> } @@ -78,14 +85,19 @@ public class <%- camelize(type) %>LayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("Visibility"); - assertNotNull(layer); - - // Get initial - assertEquals(layer.getVisibility().getValue(), VISIBLE); - - // Set - layer.setProperties(visibility(NONE)); - assertEquals(layer.getVisibility().getValue(), NONE); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Get initial + assertEquals(layer.getVisibility().getValue(), VISIBLE); + + // Set + layer.setProperties(visibility(NONE)); + assertEquals(layer.getVisibility().getValue(), NONE); + } + }); } <% if (!(type === 'background' || type === 'raster')) { -%> @@ -94,15 +106,20 @@ public class <%- camelize(type) %>LayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("SourceLayer"); - assertNotNull(layer); - - // Get initial - assertEquals(layer.getSourceLayer(), "composite"); - - // Set - final String sourceLayer = "test"; - layer.setSourceLayer(sourceLayer); - assertEquals(layer.getSourceLayer(), sourceLayer); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Get initial + assertEquals(layer.getSourceLayer(), "composite"); + + // Set + final String sourceLayer = "test"; + layer.setSourceLayer(sourceLayer); + assertEquals(layer.getSourceLayer(), sourceLayer); + } + }); } <% } -%> <% for (const property of properties) { -%> @@ -113,12 +130,17 @@ public class <%- camelize(type) %>LayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("<%- property.name %>TransitionOptions"); - assertNotNull(layer); - - // Set and Get - TransitionOptions options = new TransitionOptions(300, 100); - layer.set<%- camelize(property.name) %>Transition(options); - assertEquals(layer.get<%- camelize(property.name) %>Transition(), options); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set and Get + TransitionOptions options = new TransitionOptions(300, 100); + layer.set<%- camelize(property.name) %>Transition(options); + assertEquals(layer.get<%- camelize(property.name) %>Transition(), options); + } + }); } <% } -%> @@ -127,11 +149,16 @@ public class <%- camelize(type) %>LayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("<%- property.name %>"); - assertNotNull(layer); - - // Set and Get - layer.setProperties(<%- camelizeWithLeadingLowercase(property.name) %>(<%- defaultValueJava(property) %>)); - assertEquals((<%- propertyType(property) %>) layer.get<%- camelize(property.name) %>().getValue(), (<%- propertyType(property) %>) <%- defaultValueJava(property) %>); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set and Get + layer.setProperties(<%- camelizeWithLeadingLowercase(property.name) %>(<%- defaultValueJava(property) %>)); + assertEquals((<%- propertyType(property) %>) layer.get<%- camelize(property.name) %>().getValue(), (<%- propertyType(property) %>) <%- defaultValueJava(property) %>); + } + }); } <% if (supportsZoomFunction(property)) { -%> @@ -140,37 +167,42 @@ public class <%- camelize(type) %>LayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("<%- property.name %>"); - assertNotNull(layer); - - // Set - layer.setProperties( - <%- camelizeWithLeadingLowercase(property.name) %>( - zoom( + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + <%- camelizeWithLeadingLowercase(property.name) %>( + zoom( <% if (property.function == 'piecewise-constant') { -%> - interval( - stop(2, <%- camelizeWithLeadingLowercase(property.name) %>(<%- defaultValueJava(property) %>)) - ) + interval( + stop(2, <%- camelizeWithLeadingLowercase(property.name) %>(<%- defaultValueJava(property) %>)) + ) <% } else { -%> - exponential( - stop(2, <%- camelizeWithLeadingLowercase(property.name) %>(<%- defaultValueJava(property) %>)) - ).withBase(0.5f) + exponential( + stop(2, <%- camelizeWithLeadingLowercase(property.name) %>(<%- defaultValueJava(property) %>)) + ).withBase(0.5f) <% } -%> - ) - ) - ); - - // Verify - assertNotNull(layer.get<%- camelize(property.name) %>()); - assertNotNull(layer.get<%- camelize(property.name) %>().getFunction()); - assertEquals(CameraFunction.class, layer.get<%- camelize(property.name) %>().getFunction().getClass()); + ) + ) + ); + + // Verify + assertNotNull(layer.get<%- camelize(property.name) %>()); + assertNotNull(layer.get<%- camelize(property.name) %>().getFunction()); + assertEquals(CameraFunction.class, layer.get<%- camelize(property.name) %>().getFunction().getClass()); <% if (property.function == 'piecewise-constant') { -%> - assertEquals(IntervalStops.class, layer.get<%- camelize(property.name) %>().getFunction().getStops().getClass()); - assertEquals(1, ((IntervalStops) layer.get<%- camelize(property.name) %>().getFunction().getStops()).size()); + assertEquals(IntervalStops.class, layer.get<%- camelize(property.name) %>().getFunction().getStops().getClass()); + assertEquals(1, ((IntervalStops) layer.get<%- camelize(property.name) %>().getFunction().getStops()).size()); <% } else { -%> - assertEquals(ExponentialStops.class, layer.get<%- camelize(property.name) %>().getFunction().getStops().getClass()); - assertEquals(0.5f, ((ExponentialStops) layer.get<%- camelize(property.name) %>().getFunction().getStops()).getBase(), 0.001); - assertEquals(1, ((ExponentialStops) layer.get<%- camelize(property.name) %>().getFunction().getStops()).size()); + assertEquals(ExponentialStops.class, layer.get<%- camelize(property.name) %>().getFunction().getStops().getClass()); + assertEquals(0.5f, ((ExponentialStops) layer.get<%- camelize(property.name) %>().getFunction().getStops()).getBase(), 0.001); + assertEquals(1, ((ExponentialStops) layer.get<%- camelize(property.name) %>().getFunction().getStops()).size()); <% } -%> + } + }); } <% } -%> <% if (supportsPropertyFunction(property)) { -%> @@ -180,19 +212,24 @@ public class <%- camelize(type) %>LayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("<%- property.name %>"); - assertNotNull(layer); - - // Set - layer.setProperties( - <%- camelizeWithLeadingLowercase(property.name) %>(property("FeaturePropertyA", Stops.<<%- propertyType(property) %>>identity())) - ); - - // Verify - assertNotNull(layer.get<%- camelize(property.name) %>()); - assertNotNull(layer.get<%- camelize(property.name) %>().getFunction()); - assertEquals(SourceFunction.class, layer.get<%- camelize(property.name) %>().getFunction().getClass()); - assertEquals("FeaturePropertyA", ((SourceFunction) layer.get<%- camelize(property.name) %>().getFunction()).getProperty()); - assertEquals(IdentityStops.class, layer.get<%- camelize(property.name) %>().getFunction().getStops().getClass()); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + <%- camelizeWithLeadingLowercase(property.name) %>(property("FeaturePropertyA", Stops.<<%- propertyType(property) %>>identity())) + ); + + // Verify + assertNotNull(layer.get<%- camelize(property.name) %>()); + assertNotNull(layer.get<%- camelize(property.name) %>().getFunction()); + assertEquals(SourceFunction.class, layer.get<%- camelize(property.name) %>().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.get<%- camelize(property.name) %>().getFunction()).getProperty()); + assertEquals(IdentityStops.class, layer.get<%- camelize(property.name) %>().getFunction().getStops().getClass()); + } + }); } <% if (property.function == 'piecewise-constant') { -%> @@ -201,30 +238,35 @@ public class <%- camelize(type) %>LayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("<%- property.name %>"); - assertNotNull(layer); - - // Set - layer.setProperties( - <%- camelizeWithLeadingLowercase(property.name) %>( - property( - "FeaturePropertyA", - interval( + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + <%- camelizeWithLeadingLowercase(property.name) %>( + property( + "FeaturePropertyA", + interval( <% if (property.type == 'color') { -%> - stop(Color.RED, <%- camelizeWithLeadingLowercase(property.name) %>(Color.RED)) + stop(Color.RED, <%- camelizeWithLeadingLowercase(property.name) %>(Color.RED)) <% } else {-%> - stop(1, <%- camelizeWithLeadingLowercase(property.name) %>(<%- defaultValueJava(property) %>)) - ) + stop(1, <%- camelizeWithLeadingLowercase(property.name) %>(<%- defaultValueJava(property) %>)) + ) <% } -%> - ) - ) - ); - - // Verify - assertNotNull(layer.get<%- camelize(property.name) %>()); - assertNotNull(layer.get<%- camelize(property.name) %>().getFunction()); - assertEquals(SourceFunction.class, layer.get<%- camelize(property.name) %>().getFunction().getClass()); - assertEquals("FeaturePropertyA", ((SourceFunction) layer.get<%- camelize(property.name) %>().getFunction()).getProperty()); - assertEquals(IntervalStops.class, layer.get<%- camelize(property.name) %>().getFunction().getStops().getClass()); + ) + ) + ); + + // Verify + assertNotNull(layer.get<%- camelize(property.name) %>()); + assertNotNull(layer.get<%- camelize(property.name) %>().getFunction()); + assertEquals(SourceFunction.class, layer.get<%- camelize(property.name) %>().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.get<%- camelize(property.name) %>().getFunction()).getProperty()); + assertEquals(IntervalStops.class, layer.get<%- camelize(property.name) %>().getFunction().getStops().getClass()); + } + }); } <% } else if (property.type === 'array') { -%> @@ -233,30 +275,35 @@ public class <%- camelize(type) %>LayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("<%- property.name %>"); - assertNotNull(layer); - - // Set - layer.setProperties( - <%- camelizeWithLeadingLowercase(property.name) %>( - property( - "FeaturePropertyA", - interval( + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + <%- camelizeWithLeadingLowercase(property.name) %>( + property( + "FeaturePropertyA", + interval( <% if (property.type == 'color') { -%> - stop(Color.RED, <%- camelizeWithLeadingLowercase(property.name) %>(Color.RED)) + stop(Color.RED, <%- camelizeWithLeadingLowercase(property.name) %>(Color.RED)) <% } else {-%> - stop(1, <%- camelizeWithLeadingLowercase(property.name) %>(<%- defaultValueJava(property) %>)) + stop(1, <%- camelizeWithLeadingLowercase(property.name) %>(<%- defaultValueJava(property) %>)) <% } -%> + ) + ) ) - ) - ) - ); - - // Verify - assertNotNull(layer.get<%- camelize(property.name) %>()); - assertNotNull(layer.get<%- camelize(property.name) %>().getFunction()); - assertEquals(SourceFunction.class, layer.get<%- camelize(property.name) %>().getFunction().getClass()); - assertEquals("FeaturePropertyA", ((SourceFunction) layer.get<%- camelize(property.name) %>().getFunction()).getProperty()); - assertEquals(IntervalStops.class, layer.get<%- camelize(property.name) %>().getFunction().getStops().getClass()); + ); + + // Verify + assertNotNull(layer.get<%- camelize(property.name) %>()); + assertNotNull(layer.get<%- camelize(property.name) %>().getFunction()); + assertEquals(SourceFunction.class, layer.get<%- camelize(property.name) %>().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.get<%- camelize(property.name) %>().getFunction()).getProperty()); + assertEquals(IntervalStops.class, layer.get<%- camelize(property.name) %>().getFunction().getStops().getClass()); + } + }); } <% } else { -%> @@ -265,30 +312,35 @@ public class <%- camelize(type) %>LayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("<%- property.name %>"); - assertNotNull(layer); - - // Set - layer.setProperties( - <%- camelizeWithLeadingLowercase(property.name) %>( - property( - "FeaturePropertyA", - exponential( + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + <%- camelizeWithLeadingLowercase(property.name) %>( + property( + "FeaturePropertyA", + exponential( <% if (property.type == 'color') { -%> - stop(Color.RED, <%- camelizeWithLeadingLowercase(property.name) %>(Color.RED)) + stop(Color.RED, <%- camelizeWithLeadingLowercase(property.name) %>(Color.RED)) <% } else {-%> - stop(<%- defaultValueJava(property) %>, <%- camelizeWithLeadingLowercase(property.name) %>(<%- defaultValueJava(property) %>)) + stop(<%- defaultValueJava(property) %>, <%- camelizeWithLeadingLowercase(property.name) %>(<%- defaultValueJava(property) %>)) <% } -%> - ).withBase(0.5f) - ) - ) - ); - - // Verify - assertNotNull(layer.get<%- camelize(property.name) %>()); - assertNotNull(layer.get<%- camelize(property.name) %>().getFunction()); - assertEquals(SourceFunction.class, layer.get<%- camelize(property.name) %>().getFunction().getClass()); - assertEquals("FeaturePropertyA", ((SourceFunction) layer.get<%- camelize(property.name) %>().getFunction()).getProperty()); - assertEquals(ExponentialStops.class, layer.get<%- camelize(property.name) %>().getFunction().getStops().getClass()); + ).withBase(0.5f) + ) + ) + ); + + // Verify + assertNotNull(layer.get<%- camelize(property.name) %>()); + assertNotNull(layer.get<%- camelize(property.name) %>().getFunction()); + assertEquals(SourceFunction.class, layer.get<%- camelize(property.name) %>().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.get<%- camelize(property.name) %>().getFunction()).getProperty()); + assertEquals(ExponentialStops.class, layer.get<%- camelize(property.name) %>().getFunction().getStops().getClass()); + } + }); } @Test @@ -296,39 +348,45 @@ public class <%- camelize(type) %>LayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("<%- property.name %>"); - assertNotNull(layer); - - // Set - layer.setProperties( - <%- camelizeWithLeadingLowercase(property.name) %>( - property( - "FeaturePropertyA", - categorical( + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + <%- camelizeWithLeadingLowercase(property.name) %>( + property( + "FeaturePropertyA", + categorical( <% if (property.type == 'color') { -%> - stop("valueA", <%- camelizeWithLeadingLowercase(property.name) %>(Color.RED)) - ) - ).withDefaultValue(<%- camelizeWithLeadingLowercase(property.name) %>(Color.GREEN)) + stop("valueA", <%- camelizeWithLeadingLowercase(property.name) %>(Color.RED)) + ) + ).withDefaultValue(<%- camelizeWithLeadingLowercase(property.name) %>(Color.GREEN)) <% } else {-%> - stop(1.0f, <%- camelizeWithLeadingLowercase(property.name) %>(<%- defaultValueJava(property) %>)) - ) - ).withDefaultValue(<%- camelizeWithLeadingLowercase(property.name) %>(<%- defaultValueJava(property) %>)) + stop(1.0f, <%- camelizeWithLeadingLowercase(property.name) %>(<%- defaultValueJava(property) %>)) + ) + ).withDefaultValue(<%- camelizeWithLeadingLowercase(property.name) %>(<%- defaultValueJava(property) %>)) <% } -%> - ) - ); - - // Verify - assertNotNull(layer.get<%- camelize(property.name) %>()); - assertNotNull(layer.get<%- camelize(property.name) %>().getFunction()); - assertEquals(SourceFunction.class, layer.get<%- camelize(property.name) %>().getFunction().getClass()); - assertEquals("FeaturePropertyA", ((SourceFunction) layer.get<%- camelize(property.name) %>().getFunction()).getProperty()); - assertEquals(CategoricalStops.class, layer.get<%- camelize(property.name) %>().getFunction().getStops().getClass()); - assertNotNull(((SourceFunction) layer.get<%- camelize(property.name) %>().getFunction()).getDefaultValue()); - assertNotNull(((SourceFunction) layer.get<%- camelize(property.name) %>().getFunction()).getDefaultValue().getValue()); + ) + ); + + // Verify + assertNotNull(layer.get<%- camelize(property.name) %>()); + assertNotNull(layer.get<%- camelize(property.name) %>().getFunction()); + assertEquals(SourceFunction.class, layer.get<%- camelize(property.name) %>().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.get<%- camelize(property.name) %>().getFunction()).getProperty()); + assertEquals(CategoricalStops.class, layer.get<%- camelize(property.name) %>().getFunction().getStops().getClass()); + assertNotNull(((SourceFunction) layer.get<%- camelize(property.name) %>().getFunction()).getDefaultValue()); + assertNotNull(((SourceFunction) layer.get<%- camelize(property.name) %>().getFunction()).getDefaultValue().getValue()); <% if (property.type === 'color') { -%> - assertEquals(Color.GREEN, (int) ((SourceFunction) layer.get<%- camelize(property.name) %>().getFunction()).getDefaultValue().getColorInt()); + assertEquals(Color.GREEN, (int) ((SourceFunction) layer.get<%- camelize(property.name) %>().getFunction()).getDefaultValue().getColorInt()); <% } else { -%> - assertEquals(<%- defaultValueJava(property) %>, ((SourceFunction) layer.get<%- camelize(property.name) %>().getFunction()).getDefaultValue().getValue()); + assertEquals(<%- defaultValueJava(property) %>, ((SourceFunction) layer.get<%- camelize(property.name) %>().getFunction()).getDefaultValue().getValue()); <% } -%> + } + }); + } <% if (property.type !== 'color') { -%> @@ -337,38 +395,43 @@ public class <%- camelize(type) %>LayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("<%- property.name %>"); - assertNotNull(layer); - - // Set - layer.setProperties( - <%- camelizeWithLeadingLowercase(property.name) %>( - composite( - "FeaturePropertyA", - exponential( - stop(0, 0.3f, <%- camelizeWithLeadingLowercase(property.name) %>(0.9f)) - ).withBase(0.5f) + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + <%- camelizeWithLeadingLowercase(property.name) %>( + composite( + "FeaturePropertyA", + exponential( + stop(0, 0.3f, <%- camelizeWithLeadingLowercase(property.name) %>(0.9f)) + ).withBase(0.5f) <% if (property.type == 'number') { -%> - ).withDefaultValue(<%- camelizeWithLeadingLowercase(property.name) %>(<%- defaultValueJava(property) %>)) + ).withDefaultValue(<%- camelizeWithLeadingLowercase(property.name) %>(<%- defaultValueJava(property) %>)) <% } else { -%> - ) + ) <% } -%> - ) - ); - - // Verify - assertNotNull(layer.get<%- camelize(property.name) %>()); - assertNotNull(layer.get<%- camelize(property.name) %>().getFunction()); - assertEquals(CompositeFunction.class, layer.get<%- camelize(property.name) %>().getFunction().getClass()); - assertEquals("FeaturePropertyA", ((CompositeFunction) layer.get<%- camelize(property.name) %>().getFunction()).getProperty()); - assertEquals(ExponentialStops.class, layer.get<%- camelize(property.name) %>().getFunction().getStops().getClass()); - assertEquals(1, ((ExponentialStops) layer.get<%- camelize(property.name) %>().getFunction().getStops()).size()); - - ExponentialStops<Stop.CompositeValue<Float, <%- propertyType(property) %>>, <%- propertyType(property) %>> stops = - (ExponentialStops<Stop.CompositeValue<Float, <%- propertyType(property) %>>, <%- propertyType(property) %>>) layer.get<%- camelize(property.name) %>().getFunction().getStops(); - Stop<Stop.CompositeValue<Float, <%- propertyType(property) %>>, <%- propertyType(property) %>> stop = stops.iterator().next(); - assertEquals(0f, stop.in.zoom, 0.001); - assertEquals(0.3f, stop.in.value, 0.001f); - assertEquals(0.9f, stop.out, 0.001f); + ) + ); + + // Verify + assertNotNull(layer.get<%- camelize(property.name) %>()); + assertNotNull(layer.get<%- camelize(property.name) %>().getFunction()); + assertEquals(CompositeFunction.class, layer.get<%- camelize(property.name) %>().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((CompositeFunction) layer.get<%- camelize(property.name) %>().getFunction()).getProperty()); + assertEquals(ExponentialStops.class, layer.get<%- camelize(property.name) %>().getFunction().getStops().getClass()); + assertEquals(1, ((ExponentialStops) layer.get<%- camelize(property.name) %>().getFunction().getStops()).size()); + + ExponentialStops<Stop.CompositeValue<Float, <%- propertyType(property) %>>, <%- propertyType(property) %>> stops = + (ExponentialStops<Stop.CompositeValue<Float, <%- propertyType(property) %>>, <%- propertyType(property) %>>) layer.get<%- camelize(property.name) %>().getFunction().getStops(); + Stop<Stop.CompositeValue<Float, <%- propertyType(property) %>>, <%- propertyType(property) %>> stop = stops.iterator().next(); + assertEquals(0f, stop.in.zoom, 0.001); + assertEquals(0.3f, stop.in.value, 0.001f); + assertEquals(0.9f, stop.out, 0.001f); + } + }); } <% } -%> <% } -%> @@ -380,11 +443,16 @@ public class <%- camelize(type) %>LayerTest extends BaseActivityTest { validateTestSetup(); setupLayer(); Timber.i("<%- property.name %>"); - assertNotNull(layer); - - // Set and Get - layer.setProperties(<%- camelizeWithLeadingLowercase(property.name) %>(Color.RED)); - assertEquals(layer.get<%- camelize(property.name) %>AsInt(), Color.RED); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set and Get + layer.setProperties(<%- camelizeWithLeadingLowercase(property.name) %>(Color.RED)); + assertEquals(layer.get<%- camelize(property.name) %>AsInt(), Color.RED); + } + }); } <% } -%> <% } -%> diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/light.junit.ejs b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/light.junit.ejs index cb3ba58100..2f22a8f3f0 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/light.junit.ejs +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/light.junit.ejs @@ -9,6 +9,7 @@ import android.support.test.espresso.ViewAction; import android.support.test.runner.AndroidJUnit4; import android.view.View; +import com.mapbox.mapboxsdk.maps.MapboxMap; import com.mapbox.mapboxsdk.style.light.Light; import com.mapbox.mapboxsdk.style.functions.Function; import com.mapbox.mapboxsdk.style.functions.stops.IdentityStops; @@ -16,6 +17,7 @@ import com.mapbox.mapboxsdk.style.layers.FillExtrusionLayer; import com.mapbox.mapboxsdk.style.layers.TransitionOptions; import com.mapbox.mapboxsdk.style.light.Position; import com.mapbox.mapboxsdk.testapp.R; +import com.mapbox.mapboxsdk.testapp.action.MapboxMapAction; import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest; import com.mapbox.mapboxsdk.testapp.activity.style.FillExtrusionStyleTestActivity; @@ -35,6 +37,7 @@ import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillExtrusionCol import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillExtrusionHeight; import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillExtrusionOpacity; +import static com.mapbox.mapboxsdk.testapp.action.MapboxMapAction.invoke; import static junit.framework.Assert.assertEquals; import static junit.framework.Assert.assertNotNull; @@ -48,14 +51,18 @@ public class LightTest extends BaseActivityTest { @Test public void test<%- camelize(property.name) %>Transition() { validateTestSetup(); - setupLayer(); + setupLight(); Timber.i("<%- property.name %>TransitionOptions"); - assertNotNull(light); - - // Set and Get - TransitionOptions options = new TransitionOptions(300, 100); - light.set<%- camelize(property.name) %>Transition(options); - assertEquals("Transition options should match", options, light.get<%- camelize(property.name) %>Transition()); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(light); + // Set and Get + TransitionOptions options = new TransitionOptions(300, 100); + light.set<%- camelize(property.name) %>Transition(options); + assertEquals("Transition options should match", options, light.get<%- camelize(property.name) %>Transition()); + } + }); } <% } -%> <% if (property.name == "position") { -%> @@ -63,35 +70,44 @@ public class LightTest extends BaseActivityTest { @Test public void test<%- camelize(property.name) %>() { validateTestSetup(); - setupLayer(); + setupLight(); Timber.i("<%- property.name %>"); - assertNotNull(light); - - // Set and Get - Position position = new Position(1,2,3); - light.set<%- camelize(property.name) %>(position); - assertEquals("Position should match", position, light.get<%- camelize(property.name) %>()); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(light); + // Set and Get + Position position = new Position(1, 2, 3); + light.set<%- camelize(property.name) %>(position); + assertEquals("Position should match", position, light.get<%- camelize(property.name) %>()); + } + }); } <% } else { -%> @Test public void test<%- camelize(property.name) %>() { validateTestSetup(); - setupLayer(); + setupLight(); Timber.i("<%- property.name %>"); - assertNotNull(light); - // Set and Get - light.set<%- camelize(property.name) %>(<%- defaultValueJava(property) %>); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(light); + // Set and Get + light.set<%- camelize(property.name) %>(<%- defaultValueJava(property) %>); <% if (property.name == 'color') { -%> - assertEquals("<%- camelize(property.name) %> should match", <%- defaultValueJava(property) %>.replaceAll("\\s+",""), light.get<%- camelize(property.name) %>()); + assertEquals("<%- camelize(property.name) %> should match", <%- defaultValueJava(property) %>.replaceAll("\\s+", ""), light.get<%- camelize(property.name) %>()); <% } else { -%> - assertEquals("<%- camelize(property.name) %> should match", <%- defaultValueJava(property) %>, light.get<%- camelize(property.name) %>()); + assertEquals("<%- camelize(property.name) %> should match", <%- defaultValueJava(property) %>, light.get<%- camelize(property.name) %>()); <% } -%> + } + }); } <% } -%> <% } -%> - private void setupLayer() { + private void setupLight() { onView(withId(R.id.mapView)).perform(new ViewAction() { @Override public Matcher<View> getConstraints() { diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/FeatureOverviewActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/FeatureOverviewActivity.java index 074be98f5c..f8617366a0 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/FeatureOverviewActivity.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/FeatureOverviewActivity.java @@ -1,6 +1,5 @@ package com.mapbox.mapboxsdk.testapp.activity; -import android.Manifest; import android.content.ComponentName; import android.content.Intent; import android.content.pm.ActivityInfo; @@ -13,11 +12,10 @@ import android.os.Bundle; import android.support.annotation.NonNull; import android.support.annotation.StringRes; import android.support.design.widget.Snackbar; -import android.support.v4.app.ActivityCompat; -import android.support.v4.content.ContextCompat; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; +import android.text.TextUtils; import android.view.View; import com.mapbox.mapboxsdk.testapp.R; @@ -25,6 +23,8 @@ import com.mapbox.mapboxsdk.testapp.adapter.FeatureAdapter; import com.mapbox.mapboxsdk.testapp.adapter.FeatureSectionAdapter; import com.mapbox.mapboxsdk.testapp.model.activity.Feature; import com.mapbox.mapboxsdk.testapp.utils.ItemClickSupport; +import com.mapbox.services.android.telemetry.permissions.PermissionsListener; +import com.mapbox.services.android.telemetry.permissions.PermissionsManager; import java.util.ArrayList; import java.util.Collections; @@ -40,19 +40,23 @@ import timber.log.Timber; * It uses tags as category and description to order the different entries. * </p> */ -public class FeatureOverviewActivity extends AppCompatActivity { +public class FeatureOverviewActivity extends AppCompatActivity implements PermissionsListener { private static final String KEY_STATE_FEATURES = "featureList"; + private PermissionsManager permissionsManager; private RecyclerView recyclerView; private FeatureSectionAdapter sectionAdapter; private List<Feature> features; + private int locationActivityInList; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_feature_overview); + permissionsManager = new PermissionsManager(this); + recyclerView = (RecyclerView) findViewById(R.id.recyclerView); recyclerView.setLayoutManager(new LinearLayoutManager(this)); recyclerView.addOnItemTouchListener(new RecyclerView.SimpleOnItemTouchListener()); @@ -119,22 +123,26 @@ public class FeatureOverviewActivity extends AppCompatActivity { } private boolean requestLocationPermission(final int positionInList) { - if ((ContextCompat.checkSelfPermission(FeatureOverviewActivity.this, - Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) - || (ContextCompat.checkSelfPermission(FeatureOverviewActivity.this, - Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED)) { - ActivityCompat.requestPermissions(FeatureOverviewActivity.this, new String[] { - Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_FINE_LOCATION}, positionInList); + if (isRuntimePermissionsRequired()) { + locationActivityInList = positionInList; + permissionsManager.requestLocationPermissions(this); return true; - } else { - return false; } + return false; } @Override - public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { - if (!isRuntimePermissionsRequired() || isPermissionAccepted(grantResults)) { - startFeature(features.get(requestCode)); + public void onExplanationNeeded(List<String> list) { + Snackbar.make( + findViewById(android.R.id.content), + TextUtils.join("", list.toArray()), + Snackbar.LENGTH_SHORT).show(); + } + + @Override + public void onPermissionResult(boolean isPermissionGranted) { + if (isPermissionGranted) { + startFeature(features.get(locationActivityInList)); } else { Snackbar.make( findViewById(android.R.id.content), @@ -143,12 +151,14 @@ public class FeatureOverviewActivity extends AppCompatActivity { } } - private boolean isRuntimePermissionsRequired() { - return android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.M; + @Override + public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { + super.onRequestPermissionsResult(requestCode, permissions, grantResults); + permissionsManager.onRequestPermissionsResult(requestCode, permissions, grantResults); } - private boolean isPermissionAccepted(@NonNull int[] grantResults) { - return grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED; + private boolean isRuntimePermissionsRequired() { + return android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.M; } @Override @@ -219,13 +229,13 @@ public class FeatureOverviewActivity extends AppCompatActivity { } }; - List<String> requiresPermissionActvities = new ArrayList<String>() { + List<String> requiresPermissionActivities = new ArrayList<String>() { { add(resources.getString(R.string.activity_double_map)); } }; - return requiresPermissionCategories.contains(category) || requiresPermissionActvities.contains(name); + return requiresPermissionCategories.contains(category) || requiresPermissionActivities.contains(name); } @Override diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/CameraPositionActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/CameraPositionActivity.java index 60518239c8..cb2f57d860 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/CameraPositionActivity.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/CameraPositionActivity.java @@ -28,6 +28,7 @@ public class CameraPositionActivity extends AppCompatActivity implements OnMapRe private MapView mapView; private MapboxMap mapboxMap; + private FloatingActionButton fab; @Override protected void onCreate(Bundle savedInstanceState) { @@ -40,13 +41,14 @@ public class CameraPositionActivity extends AppCompatActivity implements OnMapRe } @Override - public void onMapReady(@NonNull final MapboxMap mapboxMap) { - this.mapboxMap = mapboxMap; + public void onMapReady(@NonNull final MapboxMap map) { + mapboxMap = map; mapboxMap.setOnCameraIdleListener(new MapboxMap.OnCameraIdleListener() { @Override public void onCameraIdle() { Timber.e("OnCameraIdle"); + fab.setColorFilter(ContextCompat.getColor(CameraPositionActivity.this, android.R.color.holo_green_dark)); } }); @@ -61,6 +63,7 @@ public class CameraPositionActivity extends AppCompatActivity implements OnMapRe @Override public void onCameraMove() { Timber.e("OnCameraMove"); + fab.setColorFilter(ContextCompat.getColor(CameraPositionActivity.this, android.R.color.holo_orange_dark)); } }); @@ -71,12 +74,13 @@ public class CameraPositionActivity extends AppCompatActivity implements OnMapRe @Override public void onCameraMoveStarted(int reason) { // reason ranges from 1 <-> 3 + fab.setColorFilter(ContextCompat.getColor(CameraPositionActivity.this, android.R.color.holo_red_dark)); Timber.e("OnCameraMoveStarted: %s", REASONS[reason - 1]); } }); // add a listener to FAB - FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab); + fab = (FloatingActionButton) findViewById(R.id.fab); fab.setColorFilter(ContextCompat.getColor(CameraPositionActivity.this, R.color.primary)); fab.setOnClickListener(new View.OnClickListener() { @Override diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/FillExtrusionActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/FillExtrusionActivity.java index 9a7790c6e5..52ba8d7c7b 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/FillExtrusionActivity.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/FillExtrusionActivity.java @@ -26,6 +26,7 @@ import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillExtrusionOpa public class FillExtrusionActivity extends AppCompatActivity { private MapView mapView; + private MapboxMap mapboxMap; @Override public void onCreate(Bundle savedInstanceState) { @@ -36,8 +37,8 @@ public class FillExtrusionActivity extends AppCompatActivity { mapView.onCreate(savedInstanceState); mapView.getMapAsync(new OnMapReadyCallback() { @Override - public void onMapReady(@NonNull - final MapboxMap map) { + public void onMapReady(@NonNull final MapboxMap map) { + mapboxMap = map; Polygon domTower = Polygon.fromCoordinates(new double[][][] { new double[][] { new double[] { @@ -66,7 +67,7 @@ public class FillExtrusionActivity extends AppCompatActivity { GeoJsonSource source = new GeoJsonSource("extrusion-source", domTower); map.addSource(source); - map.addLayer( + mapboxMap.addLayer( new FillExtrusionLayer("extrusion-layer", source.getId()) .withProperties( fillExtrusionHeight(40f), @@ -75,7 +76,7 @@ public class FillExtrusionActivity extends AppCompatActivity { ) ); - map.animateCamera( + mapboxMap.animateCamera( CameraUpdateFactory.newCameraPosition( new CameraPosition.Builder() .target(new LatLng(52.09071040847704, 5.12112557888031)) diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/BaseLocationActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/BaseLocationActivity.java index a8d1772cb2..f41e5e38f0 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/BaseLocationActivity.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/BaseLocationActivity.java @@ -1,25 +1,34 @@ package com.mapbox.mapboxsdk.testapp.activity.userlocation; -import android.Manifest; -import android.content.pm.PackageManager; import android.os.Build; +import android.os.Bundle; import android.support.annotation.NonNull; +import android.support.annotation.Nullable; import android.support.annotation.UiThread; -import android.support.v4.app.ActivityCompat; +import android.support.design.widget.Snackbar; import android.support.v7.app.AppCompatActivity; +import android.text.TextUtils; +import com.mapbox.services.android.telemetry.permissions.PermissionsListener; import com.mapbox.services.android.telemetry.permissions.PermissionsManager; -public abstract class BaseLocationActivity extends AppCompatActivity { +import java.util.List; - private static final int PERMISSIONS_LOCATION = 0; +public abstract class BaseLocationActivity extends AppCompatActivity implements PermissionsListener { + + private PermissionsManager permissionsManager; + + @Override + protected void onCreate(@Nullable Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + permissionsManager = new PermissionsManager(this); + } @UiThread protected final void toggleGps(boolean enableGps) { if (enableGps) { - if (!PermissionsManager.areLocationPermissionsGranted(this)) { - ActivityCompat.requestPermissions(this, new String[] {Manifest.permission.ACCESS_COARSE_LOCATION, - Manifest.permission.ACCESS_FINE_LOCATION}, PERMISSIONS_LOCATION); + if (!isRuntimePermissionsRequired()) { + permissionsManager.requestLocationPermissions(this); } else { enableLocation(true); } @@ -29,16 +38,21 @@ public abstract class BaseLocationActivity extends AppCompatActivity { } @Override - public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { - if (requestCode == PERMISSIONS_LOCATION) { - if (!isRuntimePermissionsRequired() || isPermissionAccepted(grantResults)) { - enableLocation(true); - } - } + public void onExplanationNeeded(List<String> list) { + Snackbar.make( + findViewById(android.R.id.content), + TextUtils.join("", list.toArray()), + Snackbar.LENGTH_SHORT).show(); + } + + @Override + public void onPermissionResult(boolean isPermissionAccepted) { + enableLocation(isPermissionAccepted); } - private boolean isPermissionAccepted(int[] grantResults) { - return grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED; + @Override + public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { + permissionsManager.onRequestPermissionsResult(requestCode, permissions, grantResults); } private boolean isRuntimePermissionsRequired() { diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/CustomLocationEngineActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/CustomLocationEngineActivity.java index 660404f144..b0ea9c608b 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/CustomLocationEngineActivity.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/CustomLocationEngineActivity.java @@ -2,13 +2,15 @@ package com.mapbox.mapboxsdk.testapp.activity.userlocation; import android.os.Bundle; import android.support.design.widget.FloatingActionButton; +import android.view.Menu; +import android.view.MenuItem; import android.view.View; +import com.mapbox.mapboxsdk.Mapbox; import com.mapbox.mapboxsdk.maps.MapView; import com.mapbox.mapboxsdk.maps.MapboxMap; import com.mapbox.mapboxsdk.maps.OnMapReadyCallback; import com.mapbox.mapboxsdk.testapp.R; -import com.mapbox.services.android.telemetry.location.LocationEngine; public class CustomLocationEngineActivity extends BaseLocationActivity { @@ -16,22 +18,18 @@ public class CustomLocationEngineActivity extends BaseLocationActivity { private MapboxMap mapboxMap; private FloatingActionButton locationToggleFab; - private LocationEngine locationServices; - @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_custom_location_engine); - locationServices = new MockLocationEngine(); - mapView = (MapView) findViewById(R.id.mapView); mapView.onCreate(savedInstanceState); mapView.getMapAsync(new OnMapReadyCallback() { @Override public void onMapReady(MapboxMap map) { mapboxMap = map; - mapboxMap.setLocationSource(locationServices); + mapboxMap.setLocationSource(MockLocationEngine.getInstance()); } }); @@ -40,7 +38,7 @@ public class CustomLocationEngineActivity extends BaseLocationActivity { @Override public void onClick(View view) { if (mapboxMap != null) { - toggleGps(!mapboxMap.isMyLocationEnabled()); + enableLocation(!mapboxMap.isMyLocationEnabled()); } } }); @@ -57,6 +55,30 @@ public class CustomLocationEngineActivity extends BaseLocationActivity { } @Override + public boolean onCreateOptionsMenu(Menu menu) { + getMenuInflater().inflate(R.menu.menu_location_engine, menu); + return super.onCreateOptionsMenu(menu); + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + if (mapboxMap != null) { + int itemId = item.getItemId(); + if (itemId == R.id.action_id_location_source_lost) { + mapboxMap.setLocationSource(Mapbox.getLocationSource()); + return true; + } else if (itemId == R.id.action_id_location_source_mock) { + mapboxMap.setLocationSource(MockLocationEngine.getInstance()); + return true; + } else if (itemId == R.id.action_id_location_source_null) { + mapboxMap.setLocationSource(null); + return true; + } + } + return super.onOptionsItemSelected(item); + } + + @Override protected void onStart() { super.onStart(); mapView.onStart(); diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/MockLocationEngine.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/MockLocationEngine.java index b02b35b0d0..da3c78b07a 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/MockLocationEngine.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/MockLocationEngine.java @@ -1,38 +1,55 @@ package com.mapbox.mapboxsdk.testapp.activity.userlocation; - +import android.animation.AnimatorListenerAdapter; +import android.animation.TypeEvaluator; +import android.animation.ValueAnimator; import android.location.Location; -import android.os.Handler; import com.mapbox.services.android.telemetry.location.LocationEngine; import com.mapbox.services.android.telemetry.location.LocationEngineListener; +import timber.log.Timber; + /** - * Sample LocationEngine that provides mocked locations simulating GPS updates + * Sample LocationEngine that provides mocked LOCATIONS simulating GPS updates */ public class MockLocationEngine extends LocationEngine { + private static MockLocationEngine INSTANCE; + + private final LocationAnimator locationAnimator; + private boolean running; + private static int counter; + + MockLocationEngine(Location start, Location end) { + locationAnimator = new LocationAnimator(start, end, new ValueAnimator.AnimatorUpdateListener() { + @Override + public void onAnimationUpdate(ValueAnimator animation) { + for (LocationEngineListener listener : locationListeners) { + listener.onLocationChanged((Location) animation.getAnimatedValue()); + } + } + }); + } + + public static synchronized MockLocationEngine getInstance() { + if (INSTANCE == null) { + INSTANCE = new MockLocationEngine( + MockLocationEngine.createLocation(40.416913, -3.703861), + MockLocationEngine.createLocation(39.461643, -0.368041) + ); + } + return INSTANCE; + } - // Mocked data - private static final int UPDATE_INTERVAL_MS = 1000; - private static final double[][] locations = new double[][] { - new double[] {39.489309, -0.360415}, - new double[] {39.492469, -0.358777}, - new double[] {40.393285, -3.707260}, - new double[] {40.394374, -3.707767}, - new double[] {40.398012, -3.715943}, - new double[] {40.416913, -3.703861}}; - - private Handler handler; - int currentIndex; - - public MockLocationEngine() { - super(); + public static Location createLocation(double latitude, double longitude) { + Location location = new Location(MockLocationEngine.class.getSimpleName()); + location.setLatitude(latitude); + location.setLongitude(longitude); + return location; } @Override public void activate() { - currentIndex = 0; - // "Connection" is immediate here for (LocationEngineListener listener : locationListeners) { listener.onConnected(); @@ -41,7 +58,6 @@ public class MockLocationEngine extends LocationEngine { @Override public void deactivate() { - handler = null; } @Override @@ -51,44 +67,61 @@ public class MockLocationEngine extends LocationEngine { @Override public Location getLastLocation() { - return getNextLocation(); + return null; } @Override public void requestLocationUpdates() { - // Fake regular updates with a handler - handler = new Handler(); - handler.postDelayed(new LocationUpdateRunnable(), UPDATE_INTERVAL_MS); + if (!running) { + locationAnimator.start(); + running = true; + } } @Override public void removeLocationUpdates() { - if (handler != null) { - handler.removeCallbacksAndMessages(null); + if (running) { + locationAnimator.stop(); + running = false; + Timber.e("LOC %s", counter); } } - private Location getNextLocation() { - // Build the next location and rotate the index - Location location = new Location(MockLocationEngine.class.getSimpleName()); - location.setLatitude(locations[currentIndex][0]); - location.setLongitude(locations[currentIndex][1]); - currentIndex = (currentIndex == locations.length - 1 ? 0 : currentIndex + 1); - return location; - } + private static class LocationAnimator extends AnimatorListenerAdapter { - private class LocationUpdateRunnable implements Runnable { - @Override - public void run() { - // Notify of an update - Location location = getNextLocation(); - for (LocationEngineListener listener : locationListeners) { - listener.onLocationChanged(location); - } + private static final long DURATION_ANIMATION = 10000; + private final ValueAnimator locationAnimator; + private long animationTime; + + LocationAnimator(Location start, Location end, ValueAnimator.AnimatorUpdateListener listener) { + locationAnimator = ValueAnimator.ofObject(new LocationEvaluator(), start, end); + locationAnimator.setDuration(DURATION_ANIMATION); + locationAnimator.addUpdateListener(listener); + locationAnimator.addListener(this); + } + + void start() { + locationAnimator.start(); + locationAnimator.setCurrentPlayTime(animationTime); + } + + void stop() { + animationTime = locationAnimator.getCurrentPlayTime(); + locationAnimator.cancel(); + } + + private static class LocationEvaluator implements TypeEvaluator<Location> { + + private Location location = new Location(MockLocationEngine.class.getSimpleName()); - if (handler != null) { - // Schedule the next update - handler.postDelayed(new LocationUpdateRunnable(), UPDATE_INTERVAL_MS); + @Override + public Location evaluate(float fraction, Location startValue, Location endValue) { + counter++; + location.setLatitude(startValue.getLatitude() + + ((endValue.getLatitude() - startValue.getLatitude()) * fraction)); + location.setLongitude(startValue.getLongitude() + + ((endValue.getLongitude() - startValue.getLongitude()) * fraction)); + return location; } } } diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/MyLocationDrawableActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/MyLocationDrawableActivity.java index 5560f81fa9..69e6d64325 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/MyLocationDrawableActivity.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/MyLocationDrawableActivity.java @@ -11,33 +11,33 @@ import android.view.ViewGroup; import com.mapbox.mapboxsdk.camera.CameraUpdateFactory; import com.mapbox.mapboxsdk.constants.Style; import com.mapbox.mapboxsdk.geometry.LatLng; -import com.mapbox.mapboxsdk.location.LocationSource; import com.mapbox.mapboxsdk.maps.MapView; import com.mapbox.mapboxsdk.maps.MapboxMap; import com.mapbox.mapboxsdk.maps.MapboxMapOptions; import com.mapbox.mapboxsdk.maps.OnMapReadyCallback; import com.mapbox.mapboxsdk.testapp.R; -import com.mapbox.services.android.telemetry.location.LocationEngineListener; +import com.mapzen.android.lost.api.LocationListener; +import com.mapzen.android.lost.api.LocationRequest; +import com.mapzen.android.lost.api.LocationServices; +import com.mapzen.android.lost.api.LostApiClient; /** * Test activity showcasing how to change the MyLocationView drawable. */ -public class MyLocationDrawableActivity extends BaseLocationActivity implements LocationEngineListener { +public class MyLocationDrawableActivity extends BaseLocationActivity implements LocationListener { private MapView mapView; private MapboxMap mapboxMap; + private LostApiClient lostApiClient; @Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_my_location_customization); - findViewById(R.id.progress).setVisibility(View.GONE); MapboxMapOptions mapboxMapOptions = new MapboxMapOptions(); mapboxMapOptions.styleUrl(Style.MAPBOX_STREETS); - - // configure MyLocationView drawables mapboxMapOptions.myLocationForegroundDrawable(ContextCompat.getDrawable(this, R.drawable.ic_android)); mapboxMapOptions.myLocationBackgroundDrawable(ContextCompat.getDrawable(this, R.drawable.ic_android)); mapboxMapOptions.myLocationForegroundTintColor(Color.GREEN); @@ -45,7 +45,6 @@ public class MyLocationDrawableActivity extends BaseLocationActivity implements mapboxMapOptions.myLocationBackgroundPadding(new int[] {0, 0, (int) getResources().getDimension(R.dimen.locationview_background_drawable_padding), (int) getResources().getDimension(R.dimen.locationview_background_drawable_padding)}); - mapboxMapOptions.myLocationAccuracyTint(Color.RED); mapboxMapOptions.myLocationAccuracyAlpha(155); @@ -66,29 +65,21 @@ public class MyLocationDrawableActivity extends BaseLocationActivity implements @Override protected void enableLocation(boolean enabled) { - if (enabled) { - mapboxMap.setMyLocationEnabled(true); - Location location = mapboxMap.getMyLocation(); - if (location != null) { - onLocationChanged(location); - } else { - LocationSource.getLocationEngine(this).addLocationEngineListener(this); - } - } else { - mapboxMap.setMyLocationEnabled(false); + mapboxMap.setMyLocationEnabled(enabled); + if (lostApiClient == null) { + lostApiClient = new LostApiClient.Builder(this).build(); + lostApiClient.connect(); + LocationRequest request = LocationRequest.create() + .setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY) + .setInterval(5000) + .setSmallestDisplacement(10); + LocationServices.FusedLocationApi.requestLocationUpdates(request, this); } } @Override - public void onConnected() { - // Nothing - } - - @Override public void onLocationChanged(Location location) { - if (mapboxMap != null) { - mapboxMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(location), 14)); - } + mapboxMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(location), 14)); } @Override @@ -113,6 +104,10 @@ public class MyLocationDrawableActivity extends BaseLocationActivity implements protected void onStop() { super.onStop(); mapView.onStop(); + if (lostApiClient.isConnected()) { + LocationServices.FusedLocationApi.removeLocationUpdates(this); + lostApiClient.disconnect(); + } } @Override diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/MyLocationTintActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/MyLocationTintActivity.java index a219b369f6..44ee030885 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/MyLocationTintActivity.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/MyLocationTintActivity.java @@ -13,7 +13,6 @@ import android.view.View; import com.mapbox.mapboxsdk.camera.CameraUpdateFactory; import com.mapbox.mapboxsdk.constants.MyLocationTracking; import com.mapbox.mapboxsdk.geometry.LatLng; -import com.mapbox.mapboxsdk.location.LocationSource; import com.mapbox.mapboxsdk.maps.MapView; import com.mapbox.mapboxsdk.maps.MapboxMap; import com.mapbox.mapboxsdk.maps.OnMapReadyCallback; @@ -133,7 +132,6 @@ public class MyLocationTintActivity extends BaseLocationActivity implements Loca protected void onStart() { super.onStart(); mapView.onStart(); - LocationSource.getLocationEngine(this).addLocationEngineListener(this); } @Override @@ -151,7 +149,6 @@ public class MyLocationTintActivity extends BaseLocationActivity implements Loca @Override protected void onStop() { super.onStop(); - LocationSource.getLocationEngine(this).removeLocationEngineListener(this); mapView.onStop(); } diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/MyLocationToggleActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/MyLocationToggleActivity.java index ac6c346a88..d465d676f7 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/MyLocationToggleActivity.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/MyLocationToggleActivity.java @@ -1,19 +1,15 @@ package com.mapbox.mapboxsdk.testapp.activity.userlocation; -import android.location.Location; import android.os.Bundle; import android.support.design.widget.FloatingActionButton; import android.view.View; -import com.mapbox.mapboxsdk.camera.CameraUpdateFactory; -import com.mapbox.mapboxsdk.geometry.LatLng; -import com.mapbox.mapboxsdk.location.LocationSource; import com.mapbox.mapboxsdk.maps.MapView; import com.mapbox.mapboxsdk.maps.MapboxMap; import com.mapbox.mapboxsdk.maps.OnMapReadyCallback; import com.mapbox.mapboxsdk.testapp.R; -import com.mapbox.services.android.telemetry.location.LocationEngine; -import com.mapbox.services.android.telemetry.location.LocationEngineListener; + +import timber.log.Timber; public class MyLocationToggleActivity extends BaseLocationActivity { @@ -21,16 +17,11 @@ public class MyLocationToggleActivity extends BaseLocationActivity { private MapboxMap mapboxMap; private FloatingActionButton locationToggleFab; - private LocationEngine locationServices; - private LocationEngineListener locationListener; - @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_my_location_toggle); - locationServices = LocationSource.getLocationEngine(this); - mapView = (MapView) findViewById(R.id.mapView); mapView.onCreate(savedInstanceState); mapView.getMapAsync(new OnMapReadyCallback() { @@ -52,6 +43,17 @@ public class MyLocationToggleActivity extends BaseLocationActivity { } @Override + protected void enableLocation(boolean enabled) { + Timber.e("Enabling location: %s", enabled); + mapboxMap.setMyLocationEnabled(enabled); + if (enabled) { + locationToggleFab.setImageResource(R.drawable.ic_location_disabled); + } else { + locationToggleFab.setImageResource(R.drawable.ic_my_location); + } + } + + @Override protected void onStart() { super.onStart(); mapView.onStart(); @@ -85,11 +87,6 @@ public class MyLocationToggleActivity extends BaseLocationActivity { protected void onDestroy() { super.onDestroy(); mapView.onDestroy(); - // Ensure no memory leak occurs if we register the location listener but the call hasn't - // been made yet. - if (locationListener != null) { - locationServices.removeLocationEngineListener(locationListener); - } } @Override @@ -98,40 +95,4 @@ public class MyLocationToggleActivity extends BaseLocationActivity { mapView.onLowMemory(); } - @Override - protected void enableLocation(boolean enabled) { - if (enabled) { - // To move the camera instantly, we attempt to get the last known location and either - // ease or animate the camera to that position depending on the zoom level. - Location lastLocation = LocationSource.getLocationEngine(this).getLastLocation(); - - if (lastLocation != null) { - if (mapboxMap.getCameraPosition().zoom > 15.99) { - mapboxMap.easeCamera(CameraUpdateFactory.newLatLng(new LatLng(lastLocation)), 1000); - } else { - mapboxMap.animateCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(lastLocation), 16), 1000); - } - } else { - locationListener = new LocationEngineListener() { - @Override - public void onConnected() { - // Nothing - } - - @Override - public void onLocationChanged(Location location) { - if (location != null) { - mapboxMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(location), 16)); - locationServices.removeLocationEngineListener(this); - } - } - }; - locationServices.addLocationEngineListener(locationListener); - } - locationToggleFab.setImageResource(R.drawable.ic_location_disabled); - } else { - locationToggleFab.setImageResource(R.drawable.ic_my_location); - } - mapboxMap.setMyLocationEnabled(enabled); - } } diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/MyLocationTrackingModeActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/MyLocationTrackingModeActivity.java index 3a3301b87f..786aeb8733 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/MyLocationTrackingModeActivity.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/MyLocationTrackingModeActivity.java @@ -1,5 +1,6 @@ package com.mapbox.mapboxsdk.testapp.activity.userlocation; +import android.location.Location; import android.os.Bundle; import android.support.annotation.NonNull; import android.support.v7.app.ActionBar; @@ -13,14 +14,22 @@ import android.widget.ArrayAdapter; import android.widget.Spinner; import android.widget.Toast; +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.maps.MapView; import com.mapbox.mapboxsdk.maps.MapboxMap; import com.mapbox.mapboxsdk.maps.OnMapReadyCallback; import com.mapbox.mapboxsdk.maps.TrackingSettings; import com.mapbox.mapboxsdk.maps.UiSettings; import com.mapbox.mapboxsdk.testapp.R; +import com.mapzen.android.lost.api.LocationListener; +import com.mapzen.android.lost.api.LocationRequest; +import com.mapzen.android.lost.api.LocationServices; +import com.mapzen.android.lost.api.LostApiClient; + +import timber.log.Timber; /** * Test activity showcasing the different tracking modes the SDK exposes. @@ -29,7 +38,11 @@ import com.mapbox.mapboxsdk.testapp.R; * using gesture configurations. * </p> */ -public class MyLocationTrackingModeActivity extends AppCompatActivity implements AdapterView.OnItemSelectedListener { +public class MyLocationTrackingModeActivity extends AppCompatActivity implements AdapterView.OnItemSelectedListener, + OnMapReadyCallback, LocationListener { + + // Testing for user defined LostApiClient + private LostApiClient lostApiClient; public static final int TRACKING_NONE_INDEX = 0; public static final int TRACKING_FOLLOW_INDEX = 1; @@ -41,6 +54,7 @@ public class MyLocationTrackingModeActivity extends AppCompatActivity implements private MapboxMap mapboxMap; private Spinner locationSpinner; private Spinner bearingSpinner; + private boolean firstRun = true; private MenuItem dismissLocationTrackingOnGestureItem; private MenuItem dismissBearingTrackingOnGestureItem; @@ -51,7 +65,46 @@ public class MyLocationTrackingModeActivity extends AppCompatActivity implements protected void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_my_location_tracking); + setupToolbar(); + + mapView = (MapView) findViewById(R.id.mapView); + mapView.onCreate(savedInstanceState); + mapView.getMapAsync(this); + } + + @Override + public void onMapReady(MapboxMap mapboxMap) { + MyLocationTrackingModeActivity.this.mapboxMap = mapboxMap; + lostApiClient = new LostApiClient.Builder(this).build(); + lostApiClient.connect(); + LocationRequest request = LocationRequest.create() + .setPriority(LocationRequest.PRIORITY_LOW_POWER) + .setInterval(5000) + .setSmallestDisplacement(10); + + Location location = LocationServices.FusedLocationApi.getLastLocation(); + if (location != null) { + setInitialLocation(location, 15); + } + LocationServices.FusedLocationApi.requestLocationUpdates(request, this); + } + + @Override + public void onLocationChanged(Location location) { + Timber.e("Location changed %s", location); + if (firstRun) { + setInitialLocation(location, 16); + } + } + + private void setInitialLocation(Location location, double zoom) { + mapboxMap.animateCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(location), zoom)); + mapboxMap.setMyLocationEnabled(true); + setupSpinners(mapboxMap); + firstRun = false; + } + private void setupToolbar() { Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); @@ -60,72 +113,60 @@ public class MyLocationTrackingModeActivity extends AppCompatActivity implements actionBar.setDisplayShowTitleEnabled(false); actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setDisplayShowHomeEnabled(true); - } - - locationSpinner = (Spinner) findViewById(R.id.spinner_location); - ArrayAdapter<CharSequence> locationTrackingAdapter = ArrayAdapter.createFromResource( - actionBar.getThemedContext(), R.array.user_tracking_mode, android.R.layout.simple_spinner_item); - locationTrackingAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); - locationSpinner.setAdapter(locationTrackingAdapter); - bearingSpinner = (Spinner) findViewById(R.id.spinner_bearing); - ArrayAdapter<CharSequence> bearingTrackingAdapter = ArrayAdapter.createFromResource( - actionBar.getThemedContext(), R.array.user_bearing_mode, android.R.layout.simple_spinner_item); - bearingTrackingAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); - bearingSpinner.setAdapter(bearingTrackingAdapter); + locationSpinner = (Spinner) findViewById(R.id.spinner_location); + ArrayAdapter<CharSequence> locationTrackingAdapter = ArrayAdapter.createFromResource( + actionBar.getThemedContext(), R.array.user_tracking_mode, android.R.layout.simple_spinner_item); + locationTrackingAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); + locationSpinner.setAdapter(locationTrackingAdapter); + + bearingSpinner = (Spinner) findViewById(R.id.spinner_bearing); + ArrayAdapter<CharSequence> bearingTrackingAdapter = ArrayAdapter.createFromResource( + actionBar.getThemedContext(), R.array.user_bearing_mode, android.R.layout.simple_spinner_item); + bearingTrackingAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); + bearingSpinner.setAdapter(bearingTrackingAdapter); + } + } - mapView = (MapView) findViewById(R.id.mapView); - mapView.onCreate(savedInstanceState); + private void setupSpinners(@NonNull MapboxMap mapboxMap) { + locationSpinner.setOnItemSelectedListener(MyLocationTrackingModeActivity.this); + bearingSpinner.setOnItemSelectedListener(MyLocationTrackingModeActivity.this); + setCheckBoxes(); - mapView.getMapAsync(new OnMapReadyCallback() { + mapboxMap.setOnMyLocationTrackingModeChangeListener(new MapboxMap.OnMyLocationTrackingModeChangeListener() { @Override - public void onMapReady(@NonNull MapboxMap mapboxMap) { - MyLocationTrackingModeActivity.this.mapboxMap = mapboxMap; - + public void onMyLocationTrackingModeChange(@MyLocationTracking.Mode int myLocationTrackingMode) { + locationSpinner.setOnItemSelectedListener(null); + switch (myLocationTrackingMode) { + case MyLocationTracking.TRACKING_NONE: + locationSpinner.setSelection(TRACKING_NONE_INDEX); + break; + case MyLocationTracking.TRACKING_FOLLOW: + locationSpinner.setSelection(TRACKING_FOLLOW_INDEX); + break; + } locationSpinner.setOnItemSelectedListener(MyLocationTrackingModeActivity.this); - bearingSpinner.setOnItemSelectedListener(MyLocationTrackingModeActivity.this); - setCheckBoxes(); - - mapboxMap.setOnMyLocationTrackingModeChangeListener(new MapboxMap.OnMyLocationTrackingModeChangeListener() { - @Override - public void onMyLocationTrackingModeChange(@MyLocationTracking.Mode int myLocationTrackingMode) { - locationSpinner.setOnItemSelectedListener(null); - switch (myLocationTrackingMode) { - case MyLocationTracking.TRACKING_NONE: - locationSpinner.setSelection(TRACKING_NONE_INDEX); - break; - case MyLocationTracking.TRACKING_FOLLOW: - locationSpinner.setSelection(TRACKING_FOLLOW_INDEX); - break; - } - locationSpinner.setOnItemSelectedListener(MyLocationTrackingModeActivity.this); - } - }); - - mapboxMap.setOnMyBearingTrackingModeChangeListener(new MapboxMap.OnMyBearingTrackingModeChangeListener() { - @Override - public void onMyBearingTrackingModeChange(@MyBearingTracking.Mode int myBearingTrackingMode) { - bearingSpinner.setOnItemSelectedListener(null); - switch (myBearingTrackingMode) { - case MyBearingTracking.NONE: - bearingSpinner.setSelection(BEARING_NONE_INDEX); - break; - - case MyBearingTracking.GPS: - bearingSpinner.setSelection(BEARING_GPS_INDEX); - break; - - case MyBearingTracking.COMPASS: - bearingSpinner.setSelection(BEARING_COMPASS_INDEX); - break; - } - bearingSpinner.setOnItemSelectedListener(MyLocationTrackingModeActivity.this); - } - }); - - if (savedInstanceState == null) { - mapboxMap.setMyLocationEnabled(true); + } + }); + + mapboxMap.setOnMyBearingTrackingModeChangeListener(new MapboxMap.OnMyBearingTrackingModeChangeListener() { + @Override + public void onMyBearingTrackingModeChange(@MyBearingTracking.Mode int myBearingTrackingMode) { + bearingSpinner.setOnItemSelectedListener(null); + switch (myBearingTrackingMode) { + case MyBearingTracking.NONE: + bearingSpinner.setSelection(BEARING_NONE_INDEX); + break; + + case MyBearingTracking.GPS: + bearingSpinner.setSelection(BEARING_GPS_INDEX); + break; + + case MyBearingTracking.COMPASS: + bearingSpinner.setSelection(BEARING_COMPASS_INDEX); + break; } + bearingSpinner.setOnItemSelectedListener(MyLocationTrackingModeActivity.this); } }); } @@ -186,6 +227,10 @@ public class MyLocationTrackingModeActivity extends AppCompatActivity implements @Override protected void onStop() { super.onStop(); + if (lostApiClient.isConnected()) { + LocationServices.FusedLocationApi.removeLocationUpdates(this); + lostApiClient.disconnect(); + } mapView.onStop(); } diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/annotations/PulseMarkerViewOptions.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/annotations/PulseMarkerViewOptions.java index d9c6357774..d752e5d0ef 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/annotations/PulseMarkerViewOptions.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/annotations/PulseMarkerViewOptions.java @@ -66,14 +66,14 @@ public class PulseMarkerViewOptions extends BaseMarkerViewOptions<PulseMarkerVie return new PulseMarkerView(this); } - public static final Parcelable.Creator<CountryMarkerViewOptions> CREATOR - = new Parcelable.Creator<CountryMarkerViewOptions>() { - public CountryMarkerViewOptions createFromParcel(Parcel in) { - return new CountryMarkerViewOptions(in); + public static final Parcelable.Creator<PulseMarkerViewOptions> CREATOR + = new Parcelable.Creator<PulseMarkerViewOptions>() { + public PulseMarkerViewOptions createFromParcel(Parcel in) { + return new PulseMarkerViewOptions(in); } - public CountryMarkerViewOptions[] newArray(int size) { - return new CountryMarkerViewOptions[size]; + public PulseMarkerViewOptions[] newArray(int size) { + return new PulseMarkerViewOptions[size]; } }; } diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_my_location_tracking.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_my_location_tracking.xml index 95f084506b..7236a944e9 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_my_location_tracking.xml +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_my_location_tracking.xml @@ -45,6 +45,6 @@ app:mapbox_myLocationTintColor="@color/primary" app:mapbox_myLocationAccuracyTintColor="@color/primary" app:mapbox_styleUrl="@string/mapbox_style_mapbox_streets" - app:mapbox_cameraZoom="15" /> + app:mapbox_cameraZoom="8" /> </LinearLayout> diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/menu/menu_location_engine.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/menu/menu_location_engine.xml new file mode 100644 index 0000000000..dd7408df09 --- /dev/null +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/menu/menu_location_engine.xml @@ -0,0 +1,20 @@ +<?xml version="1.0" encoding="utf-8"?> +<menu xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:mapbox="http://schemas.android.com/apk/res-auto"> + + <item + android:id="@+id/action_id_location_source_lost" + android:title="@string/menuitem_title_change_location_source_lost" + mapbox:showAsAction="never"/> + + <item + android:id="@+id/action_id_location_source_mock" + android:title="@string/menuitem_title_change_location_source_mock" + mapbox:showAsAction="never"/> + + <item + android:id="@+id/action_id_location_source_null" + android:title="@string/menuitem_title_change_location_source_null" + mapbox:showAsAction="never"/> + +</menu>
\ No newline at end of file diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/strings.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/strings.xml index 0dd0b343fb..7f9a08fd30 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/strings.xml +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/strings.xml @@ -153,6 +153,9 @@ <string name="menuitem_title_reset">Reset</string> <string name="menuitem_title_rotate_gesture_enabled">Enable rotate gestures</string> <string name="menuitem_title_scroll_gesture_enabled">Enable scroll gestures</string> + <string name="menuitem_title_change_location_source_lost">Change to LOST location source</string> + <string name="menuitem_title_change_location_source_mock">Change to mock location source</string> + <string name="menuitem_title_change_location_source_null">Reset location source to null</string> <!--Button--> <string name="button_camera_move">Move</string> diff --git a/platform/android/dependencies.gradle b/platform/android/dependencies.gradle index 5e80e344e4..500b99def6 100644 --- a/platform/android/dependencies.gradle +++ b/platform/android/dependencies.gradle @@ -7,7 +7,7 @@ ext { versionCode = 11 versionName = "5.0.0" - mapboxServicesVersion = "2.1.1" + mapboxServicesVersion = "2.1.3" supportLibVersion = "25.3.1" wearableVersion = '2.0.0' espressoVersion = '2.2.2' @@ -21,7 +21,7 @@ ext { mapboxAndroidTelemetry : "com.mapbox.mapboxsdk:mapbox-android-telemetry:${mapboxServicesVersion}@aar", // mapzen lost - lost : 'com.mapzen.android:lost:3.0.0', + lost : 'com.mapzen.android:lost:1.1.1', // unit test junit : 'junit:junit:4.12', diff --git a/platform/android/scripts/generate-style-code.js b/platform/android/scripts/generate-style-code.js index bb04e3ba2a..a8b2c98c86 100644 --- a/platform/android/scripts/generate-style-code.js +++ b/platform/android/scripts/generate-style-code.js @@ -167,11 +167,11 @@ global.defaultValueJava = function(property) { case 'string': return '[' + property['default'] + "]"; case 'number': - var result ='new Float[]{'; + var result ='new Float[] {'; for (var i = 0; i < property.length; i++) { result += "0f"; if (i +1 != property.length) { - result += ","; + result += ", "; } } return result + "}"; diff --git a/platform/android/scripts/generate-test-code.js b/platform/android/scripts/generate-test-code.js index b054e4a2e7..01a294a301 100644 --- a/platform/android/scripts/generate-test-code.js +++ b/platform/android/scripts/generate-test-code.js @@ -14,7 +14,7 @@ global.camelize = function (str) { } -const excludeActivities = ["DeleteRegionActivity","RealTimeGeoJsonActivity","UpdateMetadataActivity","CarDrivingActivity","MyLocationTrackingModeActivity","MyLocationToggleActivity","MyLocationTintActivity","MyLocationDrawableActivity","DoubleMapActivity", "LocationPickerActivity","GeoJsonClusteringActivity","RuntimeStyleTestActivity", "AnimatedMarkerActivity", "ViewPagerActivity","MapFragmentActivity","SupportMapFragmentActivity","SnapshotActivity","NavigationDrawerActivity", "QueryRenderedFeaturesBoxHighlightActivity", "MultiMapActivity", "MapInDialogActivity", "SimpleMapActivity"]; +const excludeActivities = ["BaseLocationActivity","MockLocationEngine","DeleteRegionActivity","RealTimeGeoJsonActivity","UpdateMetadataActivity","CarDrivingActivity","MyLocationTrackingModeActivity","MyLocationToggleActivity","MyLocationTintActivity","MyLocationDrawableActivity","DoubleMapActivity", "LocationPickerActivity","GeoJsonClusteringActivity","RuntimeStyleTestActivity", "AnimatedMarkerActivity", "ViewPagerActivity","MapFragmentActivity","SupportMapFragmentActivity","SnapshotActivity","NavigationDrawerActivity", "QueryRenderedFeaturesBoxHighlightActivity", "MultiMapActivity", "MapInDialogActivity", "SimpleMapActivity"]; const appBasePath = 'platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity'; const testBasePath = 'platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen'; const subPackages = fs.readdirSync(appBasePath); diff --git a/platform/android/src/geometry/lat_lng_bounds.cpp b/platform/android/src/geometry/lat_lng_bounds.cpp index 9efacde120..ec1a32fed5 100644 --- a/platform/android/src/geometry/lat_lng_bounds.cpp +++ b/platform/android/src/geometry/lat_lng_bounds.cpp @@ -9,10 +9,10 @@ jni::Object<LatLngBounds> LatLngBounds::New(jni::JNIEnv& env, mbgl::LatLngBounds } mbgl::LatLngBounds LatLngBounds::getLatLngBounds(jni::JNIEnv& env, jni::Object<LatLngBounds> bounds) { - static auto swLat = LatLngBounds::javaClass.GetField<jni::jdouble>(env, "mLatSouth"); - static auto swLon = LatLngBounds::javaClass.GetField<jni::jdouble>(env, "mLonWest"); - static auto neLat = LatLngBounds::javaClass.GetField<jni::jdouble>(env, "mLatNorth"); - static auto neLon = LatLngBounds::javaClass.GetField<jni::jdouble>(env, "mLonEast"); + static auto swLat = LatLngBounds::javaClass.GetField<jni::jdouble>(env, "latitudeSouth"); + static auto swLon = LatLngBounds::javaClass.GetField<jni::jdouble>(env, "longitudeWest"); + static auto neLat = LatLngBounds::javaClass.GetField<jni::jdouble>(env, "latitudeNorth"); + static auto neLon = LatLngBounds::javaClass.GetField<jni::jdouble>(env, "longitudeEast"); return mbgl::LatLngBounds::hull( { bounds.Get(env, swLat), bounds.Get(env, swLon) }, { bounds.Get(env, neLat), bounds.Get(env, neLon) } diff --git a/platform/darwin/docs/guides/For Style Authors.md.ejs b/platform/darwin/docs/guides/For Style Authors.md.ejs index 153639371c..06a8907704 100644 --- a/platform/darwin/docs/guides/For Style Authors.md.ejs +++ b/platform/darwin/docs/guides/For Style Authors.md.ejs @@ -121,6 +121,8 @@ for ink economy before printing the map view. <% if (iOS) { -%> For more information about user interface design, consult Apple’s [_iOS Human Interface Guidelines_](https://developer.apple.com/ios/human-interface-guidelines/). +To learn more about designing maps for mobile devices, see [Nathaniel Slaughter's blog post](https://www.mapbox.com/blog/designing-maps-for-mobile-devices/) on +the subject. <% } else { -%> For more information about user interface design, consult Apple’s [_macOS Human Interface Guidelines_](https://developer.apple.com/library/content/documentation/UserExperience/Conceptual/OSXHIGuidelines/). diff --git a/platform/darwin/scripts/generate-style-code.js b/platform/darwin/scripts/generate-style-code.js index 7efc8d441c..5a4936c0ee 100644 --- a/platform/darwin/scripts/generate-style-code.js +++ b/platform/darwin/scripts/generate-style-code.js @@ -149,6 +149,9 @@ global.mbglTestValue = function (property, layerType) { type = 'Alignment'; } let value = camelize(_.last(_.keys(property.values))); + if (property['light-property']) { + return `mbgl::style::Light${type}Type::${value}`; + } return `mbgl::style::${type}Type::${value}`; } case 'color': @@ -225,6 +228,9 @@ global.propertyDoc = function (propertyName, property, layerType, kind) { let doc = property.doc.replace(/`([^`]+?)` is set to `([^`]+?)`/g, function (m, peerPropertyName, propertyValue, offset, str) { let otherProperty = camelizeWithLeadingLowercase(peerPropertyName); let otherValue = objCType(layerType, peerPropertyName) + camelize(propertyValue); + if (property.type == 'array' && kind == 'light') { + otherValue = propertyValue; + } return '`' + `${otherProperty}` + '` is set to `' + `${otherValue}` + '`'; }); // Match references to our own property values. @@ -256,7 +262,7 @@ global.propertyDoc = function (propertyName, property, layerType, kind) { if (kind !== 'enum') { if ('default' in property) { doc += `\n\nThe default value of this property is ${propertyDefault(property, layerType)}.`; - if (!property.required) { + if (!property.required && kind != 'light') { doc += ' Set this property to `nil` to reset it to the default value.'; } } @@ -348,6 +354,8 @@ global.describeValue = function (value, property, layerType) { let objCType = global.objCType(layerType, property.name); return `${conjunction}\`${objCType}${camelize(possibleValue)}\``; }).join(separator); + } else if (property['light-property']) { + displayValue = `\`${prefix}Light${camelize(property.name)}${camelize(value)}\``; } else { let objCType = global.objCType(layerType, property.name); displayValue = `\`${objCType}${camelize(value)}\``; @@ -382,6 +390,8 @@ global.describeValue = function (value, property, layerType) { case 'offset': case 'translate': return 'an `NSValue` object containing a `CGVector` struct set to' + ` ${value[0]}${units} rightward and ${value[1]}${units} downward`; + case 'position': + return 'an `MGLSphericalPosition` struct set to' + ` ${value[0]} radial, ${value[1]} azimuthal and ${value[2]} polar`; default: return 'the array `' + value.join('`, `') + '`'; } @@ -418,6 +428,7 @@ global.propertyType = function (property) { return 'NSArray<NSString *> *'; case 'padding': return 'NSValue *'; + case 'position': case 'offset': case 'translate': return 'NSValue *'; @@ -457,6 +468,8 @@ global.valueTransformerArguments = function (property) { return ['std::vector<std::string>', objCType, 'std::string']; case 'padding': return ['std::array<float, 4>', objCType]; + case 'position': + return ['mbgl::style::Position', objCType]; case 'offset': case 'translate': return ['std::array<float, 2>', objCType]; @@ -478,6 +491,9 @@ global.mbglType = function(property) { return 'std::string'; case 'enum': { let type = camelize(originalPropertyName(property)); + if (property['light-property']) { + return `mbgl::style::Light${type}Type`; + } if (/-translate-anchor$/.test(originalPropertyName(property))) { type = 'TranslateAnchor'; } @@ -499,6 +515,8 @@ global.mbglType = function(property) { case 'offset': case 'translate': return 'std::array<float, 2>'; + case 'position': + return 'mbgl::style::Position'; default: throw new Error(`unknown array type for ${property.name}`); } @@ -519,6 +537,17 @@ global.setSourceLayer = function() { return `_layer->setSourceLayer(sourceLayer.UTF8String);` }; +const lightProperties = Object.keys(spec['light']).reduce((memo, name) => { + var property = spec['light'][name]; + property.name = name; + property['light-property'] = true; + memo.push(property); + return memo; +}, []); + +const lightDoc = spec['light-cocoa-doc']; +const lightType = 'light'; + const layerH = ejs.compile(fs.readFileSync('platform/darwin/src/MGLStyleLayer.h.ejs', 'utf8'), { strict: true }); const layerM = ejs.compile(fs.readFileSync('platform/darwin/src/MGLStyleLayer.mm.ejs', 'utf8'), { strict: true}); const testLayers = ejs.compile(fs.readFileSync('platform/darwin/test/MGLStyleLayerTests.mm.ejs', 'utf8'), { strict: true}); @@ -526,6 +555,14 @@ const forStyleAuthorsMD = ejs.compile(fs.readFileSync('platform/darwin/docs/guid const ddsGuideMD = ejs.compile(fs.readFileSync('platform/darwin/docs/guides/Using Style Functions at Runtime.md.ejs', 'utf8'), { strict: true }); const templatesMD = ejs.compile(fs.readFileSync('platform/darwin/docs/guides/Tile URL Templates.md.ejs', 'utf8'), { strict: true }); +const lightH = ejs.compile(fs.readFileSync('platform/darwin/src/MGLLight.h.ejs', 'utf8'), {strict: true}); +const lightM = ejs.compile(fs.readFileSync('platform/darwin/src/MGLLight.mm.ejs', 'utf8'), {strict: true}); +const testLight = ejs.compile(fs.readFileSync('platform/darwin/test/MGLLightTest.mm.ejs', 'utf8'), { strict: true}); +fs.writeFileSync(`platform/darwin/src/MGLLight.h`, duplicatePlatformDecls(lightH({ properties: lightProperties, doc: lightDoc, type: lightType }))); +fs.writeFileSync(`platform/darwin/src/MGLLight.mm`, lightM({ properties: lightProperties, doc: lightDoc, type: lightType })); +fs.writeFileSync(`platform/darwin/test/MGLLightTest.mm`, testLight({ properties: lightProperties, doc: lightDoc, type: lightType })); + + const layers = _(spec.layer.type.values).map((value, layerType) => { const layoutProperties = Object.keys(spec[`layout_${layerType}`]).reduce((memo, name) => { if (name !== 'visibility') { diff --git a/platform/darwin/scripts/style-spec-overrides-v8.json b/platform/darwin/scripts/style-spec-overrides-v8.json index a594ef2957..67a6641fe7 100644 --- a/platform/darwin/scripts/style-spec-overrides-v8.json +++ b/platform/darwin/scripts/style-spec-overrides-v8.json @@ -1,4 +1,10 @@ { + "light-cocoa-doc": "An `MGLLight` object represents the light source for extruded geometries in `MGLStyle`.", + "light": { + "position": { + "doc": "Position of the `MGLLight` source relative to lit (extruded) geometries, in a `MGLSphericalPosition` struct [radial coordinate, azimuthal angle, polar angle] where radial indicates the distance from the center of the base of an object to its light, azimuthal indicates the position of the light relative to 0° (0° when `MGLLight.anchor` is set to `MGLLightAnchorViewport` corresponds to the top of the viewport, or 0° when `MGLLight.anchor` is set to `MGLLightAnchorMap` corresponds to due north, and degrees proceed clockwise), and polar indicates the height of the light (from 0°, directly above, to 180°, directly below)." + } + }, "layer": { "type": { "values": { diff --git a/platform/darwin/src/MGLForegroundStyleLayer.h b/platform/darwin/src/MGLForegroundStyleLayer.h index 16a973630e..bcd323fb99 100644 --- a/platform/darwin/src/MGLForegroundStyleLayer.h +++ b/platform/darwin/src/MGLForegroundStyleLayer.h @@ -11,9 +11,10 @@ NS_ASSUME_NONNULL_BEGIN `MGLForegroundStyleLayer` is an abstract superclass for style layers whose content is defined by an `MGLSource` object. - Do not create instances of this class directly, and do not create your own - subclasses of this class. Instead, create instances of `MGLRasterStyleLayer` - and the concrete subclasses of `MGLVectorStyleLayer`. + Create instances of `MGLRasterStyleLayer` and the concrete subclasses of + `MGLVectorStyleLayer` in order to use `MGLForegroundStyleLayer`'s methods. + Do not create instances of `MGLForegroundStyleLayer` directly, and do not + create your own subclasses of this class. */ MGL_EXPORT @interface MGLForegroundStyleLayer : MGLStyleLayer diff --git a/platform/darwin/src/MGLGeometry.h b/platform/darwin/src/MGLGeometry.h index 3a3e59fb3e..7c68033abf 100644 --- a/platform/darwin/src/MGLGeometry.h +++ b/platform/darwin/src/MGLGeometry.h @@ -7,7 +7,7 @@ NS_ASSUME_NONNULL_BEGIN /** Defines the area spanned by an `MGLCoordinateBounds`. */ -typedef struct MGLCoordinateSpan { +typedef struct __attribute__((objc_boxable)) MGLCoordinateSpan { /** Latitudes spanned by an `MGLCoordinateBounds`. */ CLLocationDegrees latitudeDelta; /** Longitudes spanned by an `MGLCoordinateBounds`. */ @@ -38,7 +38,7 @@ NS_INLINE BOOL MGLCoordinateSpanEqualToCoordinateSpan(MGLCoordinateSpan span1, M extern MGL_EXPORT const MGLCoordinateSpan MGLCoordinateSpanZero; /** A rectangular area as measured on a two-dimensional map projection. */ -typedef struct MGLCoordinateBounds { +typedef struct __attribute__((objc_boxable)) MGLCoordinateBounds { /** Coordinate at the southwest corner. */ CLLocationCoordinate2D sw; /** Coordinate at the northeast corner. */ diff --git a/platform/darwin/src/MGLLight.h b/platform/darwin/src/MGLLight.h index ef9811bd33..55b789f043 100644 --- a/platform/darwin/src/MGLLight.h +++ b/platform/darwin/src/MGLLight.h @@ -1,3 +1,6 @@ +// This file is generated. +// Edit platform/darwin/scripts/generate-style-code.js, then run `make darwin-style-code`. + #import <CoreLocation/CoreLocation.h> #import "MGLFoundation.h" @@ -5,13 +8,19 @@ NS_ASSUME_NONNULL_BEGIN - -/** Options to specify extruded geometries are lit relative to the map or viewport. */ +/** + Whether extruded geometries are lit relative to the map or viewport. + */ typedef NS_ENUM(NSUInteger, MGLLightAnchor) { - /** The position of the light source is aligned to the rotation of the map. */ + /** + The position of the light source is aligned to the rotation of the map. + */ MGLLightAnchorMap, - /** The position of the light source is aligned to the rotation of the viewport. */ - MGLLightAnchorViewport + /** + The position of the light source is aligned to the rotation of the + viewport. + */ + MGLLightAnchorViewport, }; /** @@ -20,7 +29,7 @@ typedef NS_ENUM(NSUInteger, MGLLightAnchor) { */ typedef struct MGLSphericalPosition { /** Distance from the center of the base of an object to its light. */ - CLLocationDistance radial; + CGFloat radial; /** Position of the light relative to 0° (0° when `MGLLight.anchor` is set to viewport corresponds to the top of the viewport, or 0° when `MGLLight.anchor` is set to map corresponds to due north, and degrees proceed clockwise). */ @@ -38,7 +47,7 @@ typedef struct MGLSphericalPosition { @return Returns a `MGLSphericalPosition` struct containing the position attributes. */ -NS_INLINE MGLSphericalPosition MGLSphericalPositionMake(CLLocationDistance radial, CLLocationDirection azimuthal, CLLocationDirection polar) { +NS_INLINE MGLSphericalPosition MGLSphericalPositionMake(CGFloat radial, CLLocationDirection azimuthal, CLLocationDirection polar) { MGLSphericalPosition position; position.radial = radial; position.azimuthal = azimuthal; @@ -54,8 +63,17 @@ MGL_EXPORT @interface MGLLight : NSObject /** - `anchor` Whether extruded geometries are lit relative to the map or viewport. + Whether extruded geometries are lit relative to the map or viewport. + + The default value of this property is an `MGLStyleValue` object containing an + `NSValue` object containing `MGLLightAnchorViewport`. + You can set this property to an instance of: + + * `MGLConstantStyleValue` + * `MGLCameraStyleFunction` with an interpolation mode of + `MGLInterpolationModeInterval` + This property corresponds to the <a href="https://www.mapbox.com/mapbox-gl-js/style-spec/#light-anchor"><code>anchor</code></a> light property in the Mapbox Style Specification. @@ -63,14 +81,25 @@ MGL_EXPORT @property (nonatomic) MGLStyleValue<NSValue *> *anchor; /** - Values describing animated transitions to `anchor` property. - */ -@property (nonatomic) MGLTransition anchorTransition; - - -/** - Position of the light source relative to lit (extruded) geometries. + Position of the `MGLLight` source relative to lit (extruded) geometries, in a + `MGLSphericalPosition` struct [radial coordinate, azimuthal angle, polar angle] + where radial indicates the distance from the center of the base of an object to + its light, azimuthal indicates the position of the light relative to 0° (0° + when `MGLLight.anchor` is set to `MGLLightAnchorViewport` corresponds to the + top of the viewport, or 0° when `MGLLight.anchor` is set to `MGLLightAnchorMap` + corresponds to due north, and degrees proceed clockwise), and polar indicates + the height of the light (from 0°, directly above, to 180°, directly below). + + The default value of this property is an `MGLStyleValue` object containing an + `MGLSphericalPosition` struct set to 1.15 radial, 210 azimuthal and 30 polar. + + You can set this property to an instance of: + * `MGLConstantStyleValue` + * `MGLCameraStyleFunction` with an interpolation mode of: + * `MGLInterpolationModeExponential` + * `MGLInterpolationModeInterval` + This property corresponds to the <a href="https://www.mapbox.com/mapbox-gl-js/style-spec/#light-position"><code>position</code></a> light property in the Mapbox Style Specification. @@ -78,48 +107,87 @@ MGL_EXPORT @property (nonatomic) MGLStyleValue<NSValue *> *position; /** - Values describing animated transitions to `position` property. - */ -@property (nonatomic) MGLTransition positionTransiton; + The transition affecting any changes to this layer’s `position` property. + This property corresponds to the `position-transition` property in the style JSON file format. +*/ +@property (nonatomic) MGLTransition positionTransition; #if TARGET_OS_IPHONE /** Color tint for lighting extruded geometries. + The default value of this property is an `MGLStyleValue` object containing + `UIColor.whiteColor`. + + You can set this property to an instance of: + + * `MGLConstantStyleValue` + * `MGLCameraStyleFunction` with an interpolation mode of: + * `MGLInterpolationModeExponential` + * `MGLInterpolationModeInterval` + This property corresponds to the <a href="https://www.mapbox.com/mapbox-gl-js/style-spec/#light-color"><code>color</code></a> light property in the Mapbox Style Specification. */ @property (nonatomic) MGLStyleValue<UIColor *> *color; #else - /** Color tint for lighting extruded geometries. + + The default value of this property is an `MGLStyleValue` object containing + `NSColor.whiteColor`. + + You can set this property to an instance of: + + * `MGLConstantStyleValue` + * `MGLCameraStyleFunction` with an interpolation mode of: + * `MGLInterpolationModeExponential` + * `MGLInterpolationModeInterval` + + This property corresponds to the <a + href="https://www.mapbox.com/mapbox-gl-js/style-spec/#light-color"><code>color</code></a> + light property in the Mapbox Style Specification. */ @property (nonatomic) MGLStyleValue<NSColor *> *color; #endif /** - Values describing animated transitions to `color` property. - */ -@property (nonatomic) MGLTransition colorTransiton; + The transition affecting any changes to this layer’s `color` property. + This property corresponds to the `color-transition` property in the style JSON file format. +*/ +@property (nonatomic) MGLTransition colorTransition; /** - Intensity of lighting (on a scale from 0 to 1). Higher numbers will present as more extreme contrast. + Intensity of lighting (on a scale from 0 to 1). Higher numbers will present as + more extreme contrast. + + The default value of this property is an `MGLStyleValue` object containing an + `NSNumber` object containing the float `0.5`. + + You can set this property to an instance of: + * `MGLConstantStyleValue` + * `MGLCameraStyleFunction` with an interpolation mode of: + * `MGLInterpolationModeExponential` + * `MGLInterpolationModeInterval` + This property corresponds to the <a href="https://www.mapbox.com/mapbox-gl-js/style-spec/#light-intensity"><code>intensity</code></a> light property in the Mapbox Style Specification. */ -@property(nonatomic) MGLStyleValue<NSNumber *> *intensity; +@property (nonatomic) MGLStyleValue<NSNumber *> *intensity; /** - Values describing animated transitions to `intensity` property. - */ + The transition affecting any changes to this layer’s `intensity` property. + + This property corresponds to the `intensity-transition` property in the style JSON file format. +*/ @property (nonatomic) MGLTransition intensityTransition; + @end NS_ASSUME_NONNULL_END diff --git a/platform/darwin/src/MGLLight.h.ejs b/platform/darwin/src/MGLLight.h.ejs new file mode 100644 index 0000000000..26ecefc3af --- /dev/null +++ b/platform/darwin/src/MGLLight.h.ejs @@ -0,0 +1,100 @@ +<% + const properties = locals.properties; + const type = locals.type; + const doc = locals.doc; +-%> +// This file is generated. +// Edit platform/darwin/scripts/generate-style-code.js, then run `make darwin-style-code`. + +#import <CoreLocation/CoreLocation.h> + +#import "MGLFoundation.h" +#import "MGLStyleValue.h" + +NS_ASSUME_NONNULL_BEGIN + +<% for (const property of properties) { -%> +<% if (property.type == "enum") { -%> +/** +<%- propertyDoc(property.name, property, type, 'enum').wrap(80, 1) %> + */ +typedef NS_ENUM(NSUInteger, MGLLight<%- camelize(property.name) %>) { +<% for (const value in property.values) { -%> + /** +<%- propertyDoc(property.name, property.values[value], type, 'enum').wrap(80, 4+1) %> + */ + MGLLightAnchor<%- camelize(value) %>, +<% } -%> +}; +<% } -%> +<% } -%> + +/** + A structure containing information about the position of the light source + relative to lit geometries. + */ +typedef struct MGLSphericalPosition { + /** Distance from the center of the base of an object to its light. */ + CGFloat radial; + /** Position of the light relative to 0° (0° when `MGLLight.anchor` is set to viewport corresponds + to the top of the viewport, or 0° when `MGLLight.anchor` is set to map corresponds to due north, + and degrees proceed clockwise). */ + CLLocationDirection azimuthal; + /** Indicates the height of the light (from 0°, directly above, to 180°, directly below). */ + CLLocationDirection polar; +} MGLSphericalPosition; + +/** + Creates a new `MGLSphericalPosition` from the given radial, azimuthal, polar. + + @param radial The radial coordinate. + @param azimuthal The azimuthal angle. + @param polar The polar angle. + + @return Returns a `MGLSphericalPosition` struct containing the position attributes. + */ +NS_INLINE MGLSphericalPosition MGLSphericalPositionMake(CGFloat radial, CLLocationDirection azimuthal, CLLocationDirection polar) { + MGLSphericalPosition position; + position.radial = radial; + position.azimuthal = azimuthal; + position.polar = polar; + + return position; +} + +/** + <%- doc %> + */ +MGL_EXPORT +@interface MGLLight : NSObject +<% if (properties.length) { -%> + +<% for (const property of properties) { -%> +/** +<%- propertyDoc(property.name, property, type, 'light').wrap(80, 1) %> + + This property corresponds to the <a + href="https://www.mapbox.com/mapbox-gl-js/style-spec/#light-<%- originalPropertyName(property) %>"><code><%- originalPropertyName(property) %></code></a> + light property in the Mapbox Style Specification. + */ +@property (nonatomic<% if (property.getter) { %>, getter=<%- objCGetter(property) -%><% } %>) MGLStyleValue<<%- propertyType(property, true) %>> *<%- camelizeWithLeadingLowercase(property.name) %>; + +<% if (property.transition) { -%> +/** + The transition affecting any changes to this layer’s `<%- camelizeWithLeadingLowercase(property.name) %>` property. + + This property corresponds to the `<%- originalPropertyName(property) %>-transition` property in the style JSON file format. +*/ +@property (nonatomic) MGLTransition <%- camelizeWithLeadingLowercase(property.name) %>Transition; + +<% } -%> +<% if (property.original) { -%> +@property (nonatomic<% if (!property.required) { %>, null_resettable<% } %>) MGLStyleValue<<%- propertyType(property, true) %>> *<%- camelizeWithLeadingLowercase(originalPropertyName(property)) %> __attribute__((unavailable("Use <%- camelizeWithLeadingLowercase(property.name) %> instead."))); + +<% } -%> +<% } -%> +<% } -%> + +@end + +NS_ASSUME_NONNULL_END diff --git a/platform/darwin/src/MGLLight.mm b/platform/darwin/src/MGLLight.mm index 262fad3b07..c83ef127a6 100644 --- a/platform/darwin/src/MGLLight.mm +++ b/platform/darwin/src/MGLLight.mm @@ -1,3 +1,7 @@ +// This file is generated. +// Edit platform/darwin/scripts/generate-style-code.js, then run `make darwin-style-code`. +// test + #import "MGLLight.h" #import "MGLTypes.h" @@ -9,7 +13,7 @@ #import <mbgl/style/types.hpp> namespace mbgl { - + MBGL_DEFINE_ENUM(MGLLightAnchor, { { MGLLightAnchorMap, "map" }, { MGLLightAnchorViewport, "viewport" }, @@ -47,11 +51,9 @@ NS_INLINE mbgl::style::TransitionOptions MGLOptionsFromTransition(MGLTransition } else { anchorStyleValue = MGLStyleValueTransformer<mbgl::style::LightAnchorType, NSValue *, mbgl::style::LightAnchorType, MGLLightAnchor>().toEnumStyleValue(anchor); } - + _anchor = anchorStyleValue; - - _anchorTransition = MGLTransitionFromOptions(mbglLight->getAnchorTransition()); - + auto positionValue = mbglLight->getPosition(); if (positionValue.isUndefined()) { _position = MGLStyleValueTransformer<mbgl::style::Position, NSValue *>().toStyleValue(mbglLight->getDefaultPosition()); @@ -59,8 +61,8 @@ NS_INLINE mbgl::style::TransitionOptions MGLOptionsFromTransition(MGLTransition _position = MGLStyleValueTransformer<mbgl::style::Position, NSValue *>().toStyleValue(positionValue); } - _positionTransiton = MGLTransitionFromOptions(mbglLight->getPositionTransition()); - + _positionTransition = MGLTransitionFromOptions(mbglLight->getPositionTransition()); + auto colorValue = mbglLight->getColor(); if (colorValue.isUndefined()) { _color = MGLStyleValueTransformer<mbgl::Color, MGLColor *>().toStyleValue(mbglLight->getDefaultColor()); @@ -68,8 +70,8 @@ NS_INLINE mbgl::style::TransitionOptions MGLOptionsFromTransition(MGLTransition _color = MGLStyleValueTransformer<mbgl::Color, MGLColor *>().toStyleValue(colorValue); } - _colorTransiton = MGLTransitionFromOptions(mbglLight->getColorTransition()); - + _colorTransition = MGLTransitionFromOptions(mbglLight->getColorTransition()); + auto intensityValue = mbglLight->getIntensity(); if (intensityValue.isUndefined()) { _intensity = MGLStyleValueTransformer<float, NSNumber *>().toStyleValue(mbglLight->getDefaultIntensity()); @@ -78,6 +80,7 @@ NS_INLINE mbgl::style::TransitionOptions MGLOptionsFromTransition(MGLTransition } _intensityTransition = MGLTransitionFromOptions(mbglLight->getIntensityTransition()); + } return self; @@ -86,26 +89,24 @@ NS_INLINE mbgl::style::TransitionOptions MGLOptionsFromTransition(MGLTransition - (mbgl::style::Light)mbglLight { mbgl::style::Light mbglLight; - auto anchor = MGLStyleValueTransformer<mbgl::style::LightAnchorType, NSValue *, mbgl::style::LightAnchorType, MGLLightAnchor>().toEnumPropertyValue(self.anchor); mbglLight.setAnchor(anchor); - - mbglLight.setAnchorTransition(MGLOptionsFromTransition(self.anchorTransition)); - + auto position = MGLStyleValueTransformer<mbgl::style::Position, NSValue *>().toInterpolatablePropertyValue(self.position); mbglLight.setPosition(position); - - mbglLight.setPositionTransition(MGLOptionsFromTransition(self.positionTransiton)); - + + mbglLight.setPositionTransition(MGLOptionsFromTransition(self.positionTransition)); + auto color = MGLStyleValueTransformer<mbgl::Color, MGLColor *>().toInterpolatablePropertyValue(self.color); mbglLight.setColor(color); - - mbglLight.setColorTransition(MGLOptionsFromTransition(self.colorTransiton)); - + + mbglLight.setColorTransition(MGLOptionsFromTransition(self.colorTransition)); + auto intensity = MGLStyleValueTransformer<float, NSNumber *>().toInterpolatablePropertyValue(self.intensity); mbglLight.setIntensity(intensity); - + mbglLight.setIntensityTransition(MGLOptionsFromTransition(self.intensityTransition)); + return mbglLight; } diff --git a/platform/darwin/src/MGLLight.mm.ejs b/platform/darwin/src/MGLLight.mm.ejs new file mode 100644 index 0000000000..0d0da124c8 --- /dev/null +++ b/platform/darwin/src/MGLLight.mm.ejs @@ -0,0 +1,114 @@ +<% + const properties = locals.properties; +-%> +// This file is generated. +// Edit platform/darwin/scripts/generate-style-code.js, then run `make darwin-style-code`. +// test + +#import "MGLLight.h" + +#import "MGLTypes.h" +#import "NSDate+MGLAdditions.h" +#import "MGLStyleValue_Private.h" +#import "NSValue+MGLAdditions.h" + +#import <mbgl/style/light.hpp> +#import <mbgl/style/types.hpp> + +namespace mbgl { + + MBGL_DEFINE_ENUM(MGLLightAnchor, { +<% for (const property of properties) { -%> +<% if (property.type == "enum") { -%> +<% for (const value in property.values) { -%> + { MGLLightAnchor<%- camelize(value) %>, "<%- value %>" }, +<% } -%> +<% } -%> +<% } -%> + }); + +} + +NS_INLINE MGLTransition MGLTransitionFromOptions(const mbgl::style::TransitionOptions& options) { + MGLTransition transition; + transition.duration = MGLTimeIntervalFromDuration(options.duration.value_or(mbgl::Duration::zero())); + transition.delay = MGLTimeIntervalFromDuration(options.delay.value_or(mbgl::Duration::zero())); + + return transition; +} + +NS_INLINE mbgl::style::TransitionOptions MGLOptionsFromTransition(MGLTransition transition) { + mbgl::style::TransitionOptions options { { MGLDurationFromTimeInterval(transition.duration) }, { MGLDurationFromTimeInterval(transition.delay) } }; + return options; +} + +@interface MGLLight() + +@end + +@implementation MGLLight + +- (instancetype)initWithMBGLLight:(const mbgl::style::Light *)mbglLight +{ + if (self = [super init]) { +<% if (properties.length) { -%> +<% for (const property of properties) { -%> +<% if (property.type == "enum") { -%> + auto <%- camelizeWithLeadingLowercase(property.name) -%> = mbglLight->get<%- camelize(property.name) -%>(); + MGLStyleValue<NSValue *> *<%- camelizeWithLeadingLowercase(property.name) -%>StyleValue; + if (<%- camelizeWithLeadingLowercase(property.name) -%>.isUndefined()) { + mbgl::style::PropertyValue<mbgl::style::Light<%- camelize(property.name) -%>Type> default<%- camelize(property.name) -%> = mbglLight->getDefault<%- camelize(property.name) -%>(); + <%- camelizeWithLeadingLowercase(property.name) -%>StyleValue = MGLStyleValueTransformer<mbgl::style::LightAnchorType, NSValue *, mbgl::style::Light<%- camelize(property.name) -%>Type, MGLLight<%- camelize(property.name) -%>>().toEnumStyleValue(default<%- camelize(property.name) -%>); + } else { + <%- camelizeWithLeadingLowercase(property.name) -%>StyleValue = MGLStyleValueTransformer<mbgl::style::Light<%- camelize(property.name) -%>Type, NSValue *, mbgl::style::Light<%- camelize(property.name) -%>Type, MGLLight<%- camelize(property.name) -%>>().toEnumStyleValue(<%- camelizeWithLeadingLowercase(property.name) -%>); + } + + _<%- camelizeWithLeadingLowercase(property.name) -%> = <%- camelizeWithLeadingLowercase(property.name) -%>StyleValue; + +<% if (property.transition) { -%> + _<%- camelizeWithLeadingLowercase(property.name) -%>Transition = MGLTransitionFromOptions(mbglLight->get<%- camelize(property.name) -%>Transition()); + +<% } -%> +<% } else {-%> + auto <%- camelizeWithLeadingLowercase(property.name) -%>Value = mbglLight->get<%- camelize(property.name) -%>(); + if (<%- camelizeWithLeadingLowercase(property.name) -%>Value.isUndefined()) { + _<%- camelizeWithLeadingLowercase(property.name) -%> = MGLStyleValueTransformer<<%- valueTransformerArguments(property).join(', ') %>>().toStyleValue(mbglLight->getDefault<%- camelize(property.name) -%>()); + } else { + _<%- camelizeWithLeadingLowercase(property.name) -%> = MGLStyleValueTransformer<<%- valueTransformerArguments(property).join(', ') %>>().toStyleValue(<%- camelizeWithLeadingLowercase(property.name) -%>Value); + } +<% if (property.transition) { -%> + _<%- camelizeWithLeadingLowercase(property.name) -%>Transition = MGLTransitionFromOptions(mbglLight->get<%- camelize(property.name) -%>Transition()); +<% } -%> +<% } -%> +<% } -%> +<% } -%> + } + + return self; +} + +- (mbgl::style::Light)mbglLight +{ + mbgl::style::Light mbglLight; +<% if (properties.length) { -%> +<% for (const property of properties) { -%> +<% if (property.type == "enum") { -%> + auto <%- camelizeWithLeadingLowercase(property.name) -%> = MGLStyleValueTransformer<mbgl::style::Light<%- camelize(property.name) -%>Type, NSValue *, mbgl::style::Light<%- camelize(property.name) -%>Type, MGLLight<%- camelize(property.name) -%>>().toEnumPropertyValue(self.<%- camelizeWithLeadingLowercase(property.name) -%>); + mbglLight.set<%- camelize(property.name) -%>(<%- camelizeWithLeadingLowercase(property.name) -%>); + +<% } else {-%> + auto <%- camelizeWithLeadingLowercase(property.name) -%> = MGLStyleValueTransformer<<%- valueTransformerArguments(property).join(', ') %>>().toInterpolatablePropertyValue(self.<%- camelizeWithLeadingLowercase(property.name) -%>); + mbglLight.set<%- camelize(property.name) -%>(<%- camelizeWithLeadingLowercase(property.name) -%>); + +<% } -%> +<% if (property.transition) { -%> + mbglLight.set<%- camelize(property.name) -%>Transition(MGLOptionsFromTransition(self.<%- camelizeWithLeadingLowercase(property.name) -%>Transition)); + +<% } -%> +<% } -%> +<% } -%> + + return mbglLight; +} + +@end diff --git a/platform/darwin/src/MGLMultiPoint.h b/platform/darwin/src/MGLMultiPoint.h index 429bbdb22d..ee9eb530a4 100644 --- a/platform/darwin/src/MGLMultiPoint.h +++ b/platform/darwin/src/MGLMultiPoint.h @@ -10,8 +10,9 @@ NS_ASSUME_NONNULL_BEGIN The `MGLMultiPoint` class is an abstract superclass used to define shapes composed of multiple vertices. - You do not create instances of this class directly. Instead, you create - instances of the `MGLPolyline` or `MGLPolygon` classes. However, you can use + Create instances of `MGLPolyline` or `MGLPolygon` in order to use + properties of `MGLMultiPoint`. Do not create instances of `MGLMultiPoint` + directly and do not create your own subclasses of this class. You can use the method and properties of this class to access information about the vertices of the line or polygon. diff --git a/platform/darwin/src/MGLOfflinePack.h b/platform/darwin/src/MGLOfflinePack.h index 0b2db35b1a..dfc47bf1c8 100644 --- a/platform/darwin/src/MGLOfflinePack.h +++ b/platform/darwin/src/MGLOfflinePack.h @@ -54,7 +54,7 @@ typedef NS_ENUM (NSInteger, MGLOfflinePackState) { A structure containing information about an offline pack’s current download progress. */ -typedef struct MGLOfflinePackProgress { +typedef struct __attribute__((objc_boxable)) MGLOfflinePackProgress { /** The number of resources, including tiles, that have been completely downloaded and are ready to use offline. diff --git a/platform/darwin/src/MGLShape.h b/platform/darwin/src/MGLShape.h index bd8b6152d2..e965710552 100644 --- a/platform/darwin/src/MGLShape.h +++ b/platform/darwin/src/MGLShape.h @@ -10,11 +10,11 @@ NS_ASSUME_NONNULL_BEGIN constitute the content of a map – not only the overlays atop the map, but also the content that forms the base map. - You do not create instances of this class directly or create subclasses of this - class. Instead, you create instances of `MGLPointAnnotation`, - `MGLPointCollection`, `MGLPolyline`, `MGLMultiPolyline`, `MGLPolygon`, - `MGLMultiPolygon`, or `MGLShapeCollection`. The shape classes correspond to the - <a href="https://tools.ietf.org/html/rfc7946#section-3.1">Geometry</a> object + Create instances of `MGLPointAnnotation`, `MGLPointCollection`, `MGLPolyline`, + `MGLMultiPolyline`, `MGLPolygon`, `MGLMultiPolygon`, or `MGLShapeCollection` in + order to use `MGLShape`'s methods. Do not create instances of `MGLShape` directly, + and do not create your own subclasses of this class. The shape classes correspond + to the <a href="https://tools.ietf.org/html/rfc7946#section-3.1">Geometry</a> object types in the GeoJSON standard, but some have nonstandard names for backwards compatibility. diff --git a/platform/darwin/src/MGLSource.h b/platform/darwin/src/MGLSource.h index f990aedd67..8d8c936833 100644 --- a/platform/darwin/src/MGLSource.h +++ b/platform/darwin/src/MGLSource.h @@ -16,10 +16,10 @@ NS_ASSUME_NONNULL_BEGIN add and remove sources dynamically using methods such as `-[MGLStyle addSource:]` and `-[MGLStyle sourceWithIdentifier:]`. - Do not create instances of this class directly, and do not create your own - subclasses of this class. Instead, create instances of `MGLShapeSource`, - `MGLImageSource` and the concrete subclasses of `MGLTileSource`, - `MGLVectorSource` and `MGLRasterSource`. + Create instances of `MGLShapeSource`, `MGLImageSource` and the concrete subclasses of + `MGLTileSource` (`MGLVectorSource` and `MGLRasterSource`) in order to use + `MGLSource`'s properties and methods. Do not create instances of `MGLSource` + directly, and do not create your own subclasses of this class. */ MGL_EXPORT @interface MGLSource : NSObject diff --git a/platform/darwin/src/MGLStyleLayer.h b/platform/darwin/src/MGLStyleLayer.h index 7d181667d6..b610a27607 100644 --- a/platform/darwin/src/MGLStyleLayer.h +++ b/platform/darwin/src/MGLStyleLayer.h @@ -14,10 +14,10 @@ NS_ASSUME_NONNULL_BEGIN `MGLStyleLayer` object, which you can use to refine the map’s appearance. You can also add and remove style layers dynamically. - Do not create instances of this class directly, and do not create your own - subclasses of this class. Instead, create instances of - `MGLBackgroundStyleLayer` and the concrete subclasses of - `MGLForegroundStyleLayer`. + Create instances of `MGLBackgroundStyleLayer` and the concrete subclasses of + `MGLForegroundStyleLayer` in order to use `MGLStyleLayer`'s properties and methods. + You do not create instances of `MGLStyleLayer` directly, and do not + create your own subclasses of this class. Do not add `MGLStyleLayer` objects to the `style` property of a `MGLMapView` before `-mapView:didFinishLoadingStyle:` is called. diff --git a/platform/darwin/src/MGLStyleValue.h b/platform/darwin/src/MGLStyleValue.h index 2bb3aca4f4..9c9b1dc4d1 100644 --- a/platform/darwin/src/MGLStyleValue.h +++ b/platform/darwin/src/MGLStyleValue.h @@ -239,11 +239,10 @@ MGL_EXPORT defined by an `MGLCameraStyleFunction`, `MGLSourceStyleFunction`, or `MGLCompositeStyleFunction` object. - Do not create instances of this class directly, and do not create your own - subclasses of this class. Instead, use one of the class factory methods in - `MGLStyleValue` to create instances of the following concrete subclasses: - `MGLCameraStyleFunction`, `MGLSourceStyleFunction`, and - `MGLCompositeStyleFunction`. + Create instances of `MGLCameraStyleFunction`, `MGLSourceStyleFunction`, and + `MGLCompositeStyleFunction` in order to use `MGLStyleFunction`'s methods. Do + not create instances of `MGLStyleFunction` directly, and do not create your + own subclasses of this class. The `MGLStyleFunction` class takes a generic parameter `T` that indicates the Foundation class being wrapped by this class. diff --git a/platform/darwin/src/MGLTileSource.h b/platform/darwin/src/MGLTileSource.h index 538b94037e..caeafcd2f6 100644 --- a/platform/darwin/src/MGLTileSource.h +++ b/platform/darwin/src/MGLTileSource.h @@ -140,9 +140,9 @@ typedef NS_ENUM(NSUInteger, MGLTileCoordinateSystem) { Mapbox-hosted tile set, view it in <a href="https://www.mapbox.com/studio/tilesets/">Mapbox Studio’s Tilesets editor</a>. - Do not create instances of this class directly, and do not create your own - subclasses of this class. Instead, create instances of `MGLRasterSource` and - `MGLVectorSource`. + Create instances of `MGLRasterSource` and `MGLVectorSource` in order to use + `MGLTileSource`'s properties and methods. Do not create instances of `MGLTileSource` + directly, and do not create your own subclasses of this class. */ MGL_EXPORT @interface MGLTileSource : MGLSource diff --git a/platform/darwin/src/MGLTypes.h b/platform/darwin/src/MGLTypes.h index 16f510b5a6..b3227e1cdf 100644 --- a/platform/darwin/src/MGLTypes.h +++ b/platform/darwin/src/MGLTypes.h @@ -78,7 +78,7 @@ typedef NS_OPTIONS(NSUInteger, MGLMapDebugMaskOptions) { /** A structure containing information about a transition. */ -typedef struct MGLTransition { +typedef struct __attribute__((objc_boxable)) MGLTransition { /** The amount of time the animation should take, not including the delay. */ diff --git a/platform/darwin/src/MGLVectorStyleLayer.h b/platform/darwin/src/MGLVectorStyleLayer.h index c6193e6046..6603570e25 100644 --- a/platform/darwin/src/MGLVectorStyleLayer.h +++ b/platform/darwin/src/MGLVectorStyleLayer.h @@ -9,10 +9,11 @@ NS_ASSUME_NONNULL_BEGIN `MGLVectorStyleLayer` is an abstract superclass for style layers whose content is defined by an `MGLShapeSource` or `MGLVectorSource` object. - Do not create instances of this class directly, and do not create your own - subclasses of this class. Instead, create instances of the following concrete - subclasses: `MGLCircleStyleLayer`, `MGLFillStyleLayer`, `MGLLineStyleLayer`, - and `MGLSymbolStyleLayer`. + Create instances of `MGLCircleStyleLayer`, `MGLFillStyleLayer`, + `MGLFillExtrusionStyleLayer`, `MGLLineStyleLayer`, and `MGLSymbolStyleLayer` in + order to use `MGLVectorStyleLayer`'s properties and methods. Do not create + instances of `MGLVectorStyleLayer` directly, and do not create your own + subclasses of this class. */ MGL_EXPORT @interface MGLVectorStyleLayer : MGLForegroundStyleLayer diff --git a/platform/darwin/test/MGLLightTest.mm b/platform/darwin/test/MGLLightTest.mm index 2c3d1c7bd1..de64d57851 100644 --- a/platform/darwin/test/MGLLightTest.mm +++ b/platform/darwin/test/MGLLightTest.mm @@ -1,3 +1,5 @@ +// This file is generated. +// Edit platform/darwin/scripts/generate-style-code.js, then run `make darwin-style-code`. #import <XCTest/XCTest.h> #import <Mapbox/Mapbox.h> @@ -16,197 +18,112 @@ @implementation MGLLightTest - (void)testProperties { - + MGLTransition defaultTransition = MGLTransitionMake(0, 0); MGLTransition transition = MGLTransitionMake(6, 3); mbgl::style::TransitionOptions transitionOptions { { MGLDurationFromTimeInterval(6) }, { MGLDurationFromTimeInterval(3) } }; - + // anchor { mbgl::style::Light light; MGLLight *mglLight = [[MGLLight alloc] initWithMBGLLight:&light]; - - NSAssert([mglLight.anchor isKindOfClass:[MGLConstantStyleValue class]], @"mglLight.anchor isn’t a MGLConstantStyleValue."); + auto lightFromMGLlight = [mglLight mbglLight]; + + XCTAssertEqual(light.getDefaultAnchor(), lightFromMGLlight.getAnchor()); + XCTAssert([mglLight.anchor isKindOfClass:[MGLConstantStyleValue class]], @"mglLight.anchor isn’t a MGLConstantStyleValue."); NSValue *anchorValue = ((MGLConstantStyleValue *)mglLight.anchor).rawValue; XCTAssertEqual(anchorValue.MGLLightAnchorValue, MGLLightAnchorViewport); - XCTAssertEqual(mglLight.anchorTransition.delay, defaultTransition.delay); - XCTAssertEqual(mglLight.anchorTransition.duration, defaultTransition.duration); - - auto lightFromMGLlight = [mglLight mbglLight]; - - XCTAssertEqual(light.getDefaultAnchor(), lightFromMGLlight.getAnchor().asConstant()); - auto anchorTransition = lightFromMGLlight.getAnchorTransition(); - XCTAssert(anchorTransition.delay && MGLTimeIntervalFromDuration(*anchorTransition.delay) == defaultTransition.delay); - XCTAssert(anchorTransition.duration && MGLTimeIntervalFromDuration(*anchorTransition.duration) == defaultTransition.duration); - - MGLStyleValue<NSValue *> *anchorStyleValue = [MGLStyleValue<NSValue *> valueWithRawValue:[NSValue valueWithMGLLightAnchor:MGLLightAnchorMap]]; - mglLight.anchor = anchorStyleValue; - mglLight.anchorTransition = transition; - NSAssert([mglLight.anchor isKindOfClass:[MGLConstantStyleValue class]], @"mglLight.anchor isn’t a MGLConstantStyleValue."); - anchorValue = ((MGLConstantStyleValue *)mglLight.anchor).rawValue; - - XCTAssertEqual(anchorValue.MGLLightAnchorValue, MGLLightAnchorMap); - XCTAssertEqual(mglLight.anchorTransition.delay, transition.delay); - XCTAssertEqual(mglLight.anchorTransition.duration, transition.duration); - - mbgl::style::PropertyValue<mbgl::style::LightAnchorType> anchorProperty = { mbgl::style::LightAnchorType::Map }; - light.setAnchor(anchorProperty); - light.setAnchorTransition(transitionOptions); - + + mbgl::style::PropertyValue<mbgl::style::LightAnchorType> propertyValue = { mbgl::style::LightAnchorType::Viewport }; + light.setAnchor(propertyValue); + mglLight = [[MGLLight alloc] initWithMBGLLight:&light]; lightFromMGLlight = [mglLight mbglLight]; - - XCTAssertEqual(light.getAnchor().asConstant(), lightFromMGLlight.getAnchor().asConstant()); - anchorTransition = lightFromMGLlight.getAnchorTransition(); - XCTAssert(anchorTransition.delay && MGLTimeIntervalFromDuration(*anchorTransition.delay) == transition.delay); - XCTAssert(anchorTransition.duration && MGLTimeIntervalFromDuration(*anchorTransition.duration) == transition.duration); - + + XCTAssertEqual(light.getAnchor(), lightFromMGLlight.getAnchor()); } - + // position { mbgl::style::Light light; MGLLight *mglLight = [[MGLLight alloc] initWithMBGLLight:&light]; - NSAssert([mglLight.position isKindOfClass:[MGLConstantStyleValue class]], @"mglLight.position isn’t a MGLConstantStyleValue."); - NSValue *positionValue = ((MGLConstantStyleValue *)mglLight.position).rawValue; - auto positionArray = light.getDefaultPosition().getSpherical(); - MGLSphericalPosition defaultPosition = MGLSphericalPositionMake(positionArray[0], positionArray[1], positionArray[2]); - - XCTAssert(defaultPosition.radial == positionValue.MGLSphericalPositionValue.radial); - XCTAssert(defaultPosition.azimuthal == positionValue.MGLSphericalPositionValue.azimuthal); - XCTAssert(defaultPosition.polar == positionValue.MGLSphericalPositionValue.polar); - XCTAssertEqual(mglLight.positionTransiton.delay, defaultTransition.delay); - XCTAssertEqual(mglLight.positionTransiton.duration, defaultTransition.duration); - auto lightFromMGLlight = [mglLight mbglLight]; - - XCTAssertEqual(positionArray, lightFromMGLlight.getPosition().asConstant().getSpherical()); + + XCTAssertEqual(light.getDefaultPosition(), lightFromMGLlight.getPosition()); auto positionTransition = lightFromMGLlight.getPositionTransition(); XCTAssert(positionTransition.delay && MGLTimeIntervalFromDuration(*positionTransition.delay) == defaultTransition.delay); XCTAssert(positionTransition.duration && MGLTimeIntervalFromDuration(*positionTransition.duration) == defaultTransition.duration); - - defaultPosition = MGLSphericalPositionMake(6, 180, 90); - MGLStyleValue<NSValue *> *positionStyleValue = [MGLStyleValue<NSValue *> valueWithRawValue:[NSValue valueWithMGLSphericalPosition:defaultPosition]]; - mglLight.position = positionStyleValue; - mglLight.positionTransiton = transition; - - NSAssert([mglLight.position isKindOfClass:[MGLConstantStyleValue class]], @"mglLight.position isn’t a MGLConstantStyleValue."); - positionValue = ((MGLConstantStyleValue *)mglLight.position).rawValue; - - XCTAssert(defaultPosition.radial == positionValue.MGLSphericalPositionValue.radial); - XCTAssert(defaultPosition.azimuthal == positionValue.MGLSphericalPositionValue.azimuthal); - XCTAssert(defaultPosition.polar == positionValue.MGLSphericalPositionValue.polar); - XCTAssertEqual(mglLight.positionTransiton.delay, transition.delay); - XCTAssertEqual(mglLight.positionTransiton.duration, transition.duration); - - lightFromMGLlight = [mglLight mbglLight]; - - positionArray = { { 6, 180, 90 } }; + + std::array<float, 3> positionArray = { { 6, 180, 90 } }; mbgl::style::Position position = { positionArray }; - mbgl::style::PropertyValue<mbgl::style::Position> positionProperty = { position }; - light.setPosition(positionProperty); + mbgl::style::PropertyValue<mbgl::style::Position> propertyValue = { position }; + light.setPosition(propertyValue); light.setPositionTransition(transitionOptions); - XCTAssertEqual(positionArray, lightFromMGLlight.getPosition().asConstant().getSpherical()); + mglLight = [[MGLLight alloc] initWithMBGLLight:&light]; + lightFromMGLlight = [mglLight mbglLight]; + + XCTAssertEqual(light.getPosition(), lightFromMGLlight.getPosition()); positionTransition = lightFromMGLlight.getPositionTransition(); XCTAssert(positionTransition.delay && MGLTimeIntervalFromDuration(*positionTransition.delay) == transition.delay); XCTAssert(positionTransition.duration && MGLTimeIntervalFromDuration(*positionTransition.duration) == transition.duration); } - + // color { mbgl::style::Light light; MGLLight *mglLight = [[MGLLight alloc] initWithMBGLLight:&light]; - NSAssert([mglLight.color isKindOfClass:[MGLConstantStyleValue class]], @"mglLight.color isn’t a MGLConstantStyleValue."); - MGLColor *colorValue = ((MGLConstantStyleValue *)mglLight.color).rawValue; - auto color = light.getDefaultColor(); - const CGFloat *colorComponents = CGColorGetComponents(colorValue.CGColor); - - XCTAssert(color.r == colorComponents[0] && color.g == colorComponents[1] && color.b == colorComponents[2] && - color.a == colorComponents[3]); - XCTAssertEqual(mglLight.colorTransiton.delay, defaultTransition.delay); - XCTAssertEqual(mglLight.colorTransiton.duration, defaultTransition.duration); - auto lightFromMGLlight = [mglLight mbglLight]; - - XCTAssertEqual(color, lightFromMGLlight.getColor().asConstant()); + + XCTAssertEqual(light.getDefaultColor(), lightFromMGLlight.getColor()); auto colorTransition = lightFromMGLlight.getColorTransition(); XCTAssert(colorTransition.delay && MGLTimeIntervalFromDuration(*colorTransition.delay) == defaultTransition.delay); XCTAssert(colorTransition.duration && MGLTimeIntervalFromDuration(*colorTransition.duration) == defaultTransition.duration); - - MGLStyleValue<MGLColor *> *colorStyleValue = [MGLStyleValue<MGLColor *> valueWithRawValue:[MGLColor blackColor]]; - mglLight.color = colorStyleValue; - mglLight.colorTransiton = transition; - - NSAssert([mglLight.color isKindOfClass:[MGLConstantStyleValue class]], @"mglLight.color isn’t a MGLConstantStyleValue."); - colorValue = ((MGLConstantStyleValue *)mglLight.color).rawValue; - - XCTAssertEqual([MGLColor blackColor], colorValue); - XCTAssertEqual(mglLight.colorTransiton.delay, transition.delay); - XCTAssertEqual(mglLight.colorTransiton.duration, transition.duration); - - mbgl::style::PropertyValue<mbgl::Color> colorProperty = { { 0, 0, 0, 1 } }; - light.setColor(colorProperty); + + mbgl::style::PropertyValue<mbgl::Color> propertyValue = { { 1, 0, 0, 1 } }; + light.setColor(propertyValue); light.setColorTransition(transitionOptions); - + + mglLight = [[MGLLight alloc] initWithMBGLLight:&light]; lightFromMGLlight = [mglLight mbglLight]; - - colorComponents = CGColorGetComponents(colorValue.CGColor); - color = lightFromMGLlight.getColor().asConstant(); - XCTAssertEqual(light.getColor().asConstant(),lightFromMGLlight.getColor().asConstant()); + + XCTAssertEqual(light.getColor(), lightFromMGLlight.getColor()); colorTransition = lightFromMGLlight.getColorTransition(); XCTAssert(colorTransition.delay && MGLTimeIntervalFromDuration(*colorTransition.delay) == transition.delay); XCTAssert(colorTransition.duration && MGLTimeIntervalFromDuration(*colorTransition.duration) == transition.duration); + } - + // intensity { mbgl::style::Light light; MGLLight *mglLight = [[MGLLight alloc] initWithMBGLLight:&light]; - NSAssert([mglLight.intensity isKindOfClass:[MGLConstantStyleValue class]], @"mglLight.intensity isn’t a MGLConstantStyleValue."); - NSNumber *intensityNumber = ((MGLConstantStyleValue *)mglLight.intensity).rawValue; - auto intensity = light.getDefaultIntensity(); - - XCTAssert(intensityNumber.floatValue == intensity); - XCTAssertEqual(mglLight.intensityTransition.delay, defaultTransition.delay); - XCTAssertEqual(mglLight.intensityTransition.duration, defaultTransition.duration); - auto lightFromMGLlight = [mglLight mbglLight]; - - XCTAssertEqual(intensity, lightFromMGLlight.getIntensity().asConstant()); + + XCTAssertEqual(light.getDefaultIntensity(), lightFromMGLlight.getIntensity()); auto intensityTransition = lightFromMGLlight.getIntensityTransition(); XCTAssert(intensityTransition.delay && MGLTimeIntervalFromDuration(*intensityTransition.delay) == defaultTransition.delay); XCTAssert(intensityTransition.duration && MGLTimeIntervalFromDuration(*intensityTransition.duration) == defaultTransition.duration); - - NSNumber *intensityValue = @0.4; - MGLStyleValue<NSNumber *> *intensityStyleValue = [MGLStyleValue<NSNumber *> valueWithRawValue:intensityValue]; - mglLight.intensity = intensityStyleValue; - mglLight.intensityTransition = transition; - - NSAssert([mglLight.intensity isKindOfClass:[MGLConstantStyleValue class]], @"mglLight.intensity isn’t a MGLConstantStyleValue."); - intensityNumber = ((MGLConstantStyleValue *)mglLight.intensity).rawValue; - XCTAssert(intensityNumber.floatValue == intensityValue.floatValue); - XCTAssertEqual(mglLight.intensityTransition.delay, transition.delay); - XCTAssertEqual(mglLight.intensityTransition.duration, transition.duration); - - mbgl::style::PropertyValue<float> intensityProperty = { 0.4 }; - light.setIntensity(intensityProperty); + + mbgl::style::PropertyValue<float> propertyValue = { 0xff }; + light.setIntensity(propertyValue); light.setIntensityTransition(transitionOptions); + mglLight = [[MGLLight alloc] initWithMBGLLight:&light]; lightFromMGLlight = [mglLight mbglLight]; - - XCTAssertEqual(light.getIntensity().asConstant(), lightFromMGLlight.getIntensity().asConstant()); + + XCTAssertEqual(light.getIntensity(), lightFromMGLlight.getIntensity()); intensityTransition = lightFromMGLlight.getIntensityTransition(); XCTAssert(intensityTransition.delay && MGLTimeIntervalFromDuration(*intensityTransition.delay) == transition.delay); XCTAssert(intensityTransition.duration && MGLTimeIntervalFromDuration(*intensityTransition.duration) == transition.duration); - + } } - (void)testValueAdditions { MGLSphericalPosition position = MGLSphericalPositionMake(1.15, 210, 30); - + XCTAssertEqual([NSValue valueWithMGLSphericalPosition:position].MGLSphericalPositionValue.radial, position.radial); XCTAssertEqual([NSValue valueWithMGLSphericalPosition:position].MGLSphericalPositionValue.azimuthal, position.azimuthal); XCTAssertEqual([NSValue valueWithMGLSphericalPosition:position].MGLSphericalPositionValue.polar, position.polar); diff --git a/platform/darwin/test/MGLLightTest.mm.ejs b/platform/darwin/test/MGLLightTest.mm.ejs new file mode 100644 index 0000000000..5b1f27d8d1 --- /dev/null +++ b/platform/darwin/test/MGLLightTest.mm.ejs @@ -0,0 +1,92 @@ +<% + const type = locals.type; + const properties = locals.properties; +-%> +// This file is generated. +// Edit platform/darwin/scripts/generate-style-code.js, then run `make darwin-style-code`. +#import <XCTest/XCTest.h> +#import <Mapbox/Mapbox.h> + +#import "MGLLight_Private.h" + +#import "../../darwin/src/NSDate+MGLAdditions.h" + +#import <mbgl/style/light.hpp> +#import <mbgl/style/types.hpp> +#include <mbgl/style/transition_options.hpp> + +@interface MGLLightTest : XCTestCase + +@end + +@implementation MGLLightTest + +- (void)testProperties { + + MGLTransition defaultTransition = MGLTransitionMake(0, 0); + MGLTransition transition = MGLTransitionMake(6, 3); + mbgl::style::TransitionOptions transitionOptions { { MGLDurationFromTimeInterval(6) }, { MGLDurationFromTimeInterval(3) } }; + +<% for (const property of properties) { -%> + // <%- property.name %> + { + mbgl::style::Light light; + MGLLight *mglLight = [[MGLLight alloc] initWithMBGLLight:&light]; + auto lightFromMGLlight = [mglLight mbglLight]; + + XCTAssertEqual(light.getDefault<%- camelize(property.name) -%>(), lightFromMGLlight.get<%- camelize(property.name) -%>()); +<% if (property.transition) { -%> + auto <%- camelizeWithLeadingLowercase(property.name) -%>Transition = lightFromMGLlight.get<%- camelize(property.name) -%>Transition(); + XCTAssert(<%- camelizeWithLeadingLowercase(property.name) -%>Transition.delay && MGLTimeIntervalFromDuration(*<%- camelizeWithLeadingLowercase(property.name) -%>Transition.delay) == defaultTransition.delay); + XCTAssert(<%- camelizeWithLeadingLowercase(property.name) -%>Transition.duration && MGLTimeIntervalFromDuration(*<%- camelizeWithLeadingLowercase(property.name) -%>Transition.duration) == defaultTransition.duration); + +<% } -%> +<% if (property.type == "enum" && property.default) { -%> + XCTAssert([mglLight.<%- camelizeWithLeadingLowercase(property.name) -%> isKindOfClass:[MGLConstantStyleValue class]], @"mglLight.<%- camelizeWithLeadingLowercase(property.name) -%> isn’t a MGLConstantStyleValue."); + NSValue *<%- camelizeWithLeadingLowercase(property.name) -%>Value = ((MGLConstantStyleValue *)mglLight.<%- camelizeWithLeadingLowercase(property.name) -%>).rawValue; + XCTAssertEqual(<%- camelizeWithLeadingLowercase(property.name) -%>Value.MGLLight<%- camelize(property.name) -%>Value, MGLLight<%- camelize(property.name) -%><%- camelize(property.default) -%>); + +<% } -%> +<% if (property.type == "array") { -%> + std::array<float, 3> positionArray = { { 6, 180, 90 } }; + mbgl::style::Position position = { positionArray }; + mbgl::style::PropertyValue<mbgl::style::Position> propertyValue = { position }; +<% } else { -%> + mbgl::style::PropertyValue<<%- mbglType(property) %>> propertyValue = { <%- mbglTestValue(property, type) %> }; +<% } -%> + light.set<%- camelize(property.name) -%>(propertyValue); +<% if (property.transition) { -%> + light.set<%- camelize(property.name) -%>Transition(transitionOptions); + +<% } -%> + mglLight = [[MGLLight alloc] initWithMBGLLight:&light]; + lightFromMGLlight = [mglLight mbglLight]; + + XCTAssertEqual(light.get<%- camelize(property.name) -%>(), lightFromMGLlight.get<%- camelize(property.name) -%>()); +<% if (property.transition) { -%> + <%- camelizeWithLeadingLowercase(property.name) -%>Transition = lightFromMGLlight.get<%- camelize(property.name) -%>Transition(); + XCTAssert(<%- camelizeWithLeadingLowercase(property.name) -%>Transition.delay && MGLTimeIntervalFromDuration(*<%- camelizeWithLeadingLowercase(property.name) -%>Transition.delay) == transition.delay); + XCTAssert(<%- camelizeWithLeadingLowercase(property.name) -%>Transition.duration && MGLTimeIntervalFromDuration(*<%- camelizeWithLeadingLowercase(property.name) -%>Transition.duration) == transition.duration); + +<% } -%> + } + +<% } -%> +} + +- (void)testValueAdditions { + MGLSphericalPosition position = MGLSphericalPositionMake(1.15, 210, 30); + + XCTAssertEqual([NSValue valueWithMGLSphericalPosition:position].MGLSphericalPositionValue.radial, position.radial); + XCTAssertEqual([NSValue valueWithMGLSphericalPosition:position].MGLSphericalPositionValue.azimuthal, position.azimuthal); + XCTAssertEqual([NSValue valueWithMGLSphericalPosition:position].MGLSphericalPositionValue.polar, position.polar); +<% for (const property of properties) { -%> +<% if (property.type == "enum") { -%> +<% for (const value in property.values) { -%> + XCTAssertEqual([NSValue valueWithMGLLight<%- camelize(property.name) %>:MGLLight<%- camelize(property.name) %><%- camelize(value) %>].MGLLight<%- camelize(property.name) %>Value, MGLLight<%- camelize(property.name) %><%- camelize(value) %>); +<% } -%> +<% } -%> +<% } -%> +} + +@end diff --git a/platform/default/resources/default_marker.svg b/platform/default/resources/default_marker.svg index 3cb5af09a4..08ae2d76d6 100644 --- a/platform/default/resources/default_marker.svg +++ b/platform/default/resources/default_marker.svg @@ -4,7 +4,7 @@ <svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
width="20px" height="56px" viewBox="0 0 20 56" enable-background="new 0 0 20 56" xml:space="preserve">
<ellipse opacity="0.2" fill="#262626" cx="10" cy="27" rx="9" ry="5"/>
-<path id="path5359" fill="#D84E4E" stroke="#7F1919" stroke-width="1.0229" stroke-linecap="round" stroke-linejoin="round" d="
+<path id="path5359" fill="#F84D4D" stroke="#951212" stroke-width="1.0229" stroke-linecap="round" stroke-linejoin="round" d="
M19.5,10.4c0,6.3-9.5,17.1-9.5,17.1S0.5,16.6,0.5,10.4c0-5.5,4.3-9.9,9.5-9.9S19.5,4.9,19.5,10.4z"/>
<circle id="path5990" fill="#FFFFFF" stroke="#7C2525" stroke-linecap="round" stroke-linejoin="round" cx="10" cy="10" r="3.8"/>
</svg>
diff --git a/platform/ios/CHANGELOG.md b/platform/ios/CHANGELOG.md index ce56d157c1..785b0ee78b 100644 --- a/platform/ios/CHANGELOG.md +++ b/platform/ios/CHANGELOG.md @@ -6,18 +6,18 @@ Mapbox welcomes participation and contributions from everyone. Please read [CONT ### Styles -* Added suuport for diplaying georeferenced images via the `MGLImageSource`. [#9110](https://github.com/mapbox/mapbox-gl-native/pull/9110) +* Added support for displaying geo-referenced images via the `MGLImageSource`. [#9110](https://github.com/mapbox/mapbox-gl-native/pull/9110) +* The previously-deprecated support for style classes has been removed. For interface compatibility, the API methods remain, but they are now non-functional. +* Added an `overlays` property to `MGLMapView`. ([#8617](https://github.com/mapbox/mapbox-gl-native/pull/8617)) + +## 3.6.0 ### Packaging * Xcode 8.0 or higher is now recommended for using this SDK. ([#8775](https://github.com/mapbox/mapbox-gl-native/pull/8775)) * Fixed an issue in the static framework where localizations would never load. ([#9074](https://github.com/mapbox/mapbox-gl-native/pull/9074)) * Updated MGLMapView’s logo view to display [the new Mapbox logo](https://www.mapbox.com/blog/new-mapbox-logo/). ([#8771](https://github.com/mapbox/mapbox-gl-native/pull/8771), [#8773](https://github.com/mapbox/mapbox-gl-native/pull/8773)) - -* The previously-deprecated support for style classes has been removed. For interface compatibility, the API methods remain, but they are now non-functional. -* Added an `overlays` property to `MGLMapView`. ([#8617](https://github.com/mapbox/mapbox-gl-native/pull/8617)) - -## 3.6.0 +* Added a Hungarian localization. ([#9347](https://github.com/mapbox/mapbox-gl-native/pull/9347)) ### Styles @@ -29,8 +29,11 @@ Mapbox welcomes participation and contributions from everyone. Please read [CONT * Fixed an issue preventing programmatically added style layers from appearing in already cached tiles. ([#8954](https://github.com/mapbox/mapbox-gl-native/pull/8954)) * Fixed an issue causing a composite function’s highest zoom level stop to be misinterpreted. ([#8613](https://github.com/mapbox/mapbox-gl-native/pull/8613), [#8790](https://github.com/mapbox/mapbox-gl-native/pull/8790)) * Fixed an issue where re-adding a layer that had been previously removed from a style would reset its paint properties. Moved initializers for `MGLTileSource`, `MGLStyleLayer`, and `MGLForegroundStyleLayer` to their concrete subclasses; because these classes were already intended for initialization only via concrete subclasses, this should have no developer impact. ([#8626](https://github.com/mapbox/mapbox-gl-native/pull/8626)) +* Fixed a crash that occurred when removing a source that was still being used by one or more style layers. Since this is a programming error, a warning is logged to the console instead. ([#9129](https://github.com/mapbox/mapbox-gl-native/pull/9129)) * Feature querying results now account for any changes to a feature’s size caused by a source or composite style function. ([#8665](https://github.com/mapbox/mapbox-gl-native/pull/8665)) +* Fixed the behavior of composite functions that specify fractional zoom level stops. ([#9289](https://github.com/mapbox/mapbox-gl-native/pull/9289)) * Letter spacing is now disabled in Arabic text so that ligatures are drawn correctly. ([#9062](https://github.com/mapbox/mapbox-gl-native/pull/9062)) +* Improved the performance of styles using source and composite style functions. ([#9185](https://github.com/mapbox/mapbox-gl-native/pull/9185), [#9257](https://github.com/mapbox/mapbox-gl-native/pull/9257)) ### Annotations @@ -44,10 +47,14 @@ Mapbox welcomes participation and contributions from everyone. Please read [CONT ### User interaction * Added a scale bar to `MGLMapView` that indicates the scale of the map. ([#7631](https://github.com/mapbox/mapbox-gl-native/pull/7631)) +* Fixed an issue causing the map to go blank during a flight animation that travels a very short distance. ([#9199](https://github.com/mapbox/mapbox-gl-native/pull/9199)) * Fixed an issue where gesture recognizers associated with map view interactivity were not disabled when their related interactions were disabled. ([#8304](https://github.com/mapbox/mapbox-gl-native/pull/8304)) * Fixed an issue preventing the Mapbox Telemetry confirmation dialog from appearing when opened from within a map view in a modal view controller. ([#9027](https://github.com/mapbox/mapbox-gl-native/pull/9027)) * Corrected the size of MGLMapView’s compass. ([#9060](https://github.com/mapbox/mapbox-gl-native/pull/9060)) * The Improve This Map button in the attribution action sheet now leads to a feedback tool that matches MGLMapView’s rotation and pitch. `-[MGLAttributionInfo feedbackURLAtCenterCoordinate:zoomLevel:]` no longer respects the feedback URL specified in TileJSON. ([#9078](https://github.com/mapbox/mapbox-gl-native/pull/9078)) +* `-[MGLMapViewDelegate mapView:shouldChangeFromCamera:toCamera:]` can now block any panning caused by a pinch gesture. ([#9344](https://github.com/mapbox/mapbox-gl-native/pull/9344)) +* If the user taps on the map while it is flying to the user’s location, the user dot no longer appears in the incorrect location. ([#7916](https://github.com/mapbox/mapbox-gl-native/pull/7916)) +* Improved the responsiveness of the tilt gesture by reducing the initial recognition delay. ([#9386](https://github.com/mapbox/mapbox-gl-native/pull/9386)) ### Other changes @@ -57,6 +64,7 @@ Mapbox welcomes participation and contributions from everyone. Please read [CONT * The error passed into `-[MGLMapViewDelegate mapViewDidFailLoadingMap:withError:]` now includes a more specific description and failure reason. ([#8418](https://github.com/mapbox/mapbox-gl-native/pull/8418)) * Improved CPU and battery performance while animating a tilted map’s camera in an area with many labels. ([#9031](https://github.com/mapbox/mapbox-gl-native/pull/9031)) * Fixed an issue rendering polylines that contain duplicate vertices. ([#8808](https://github.com/mapbox/mapbox-gl-native/pull/8808)) +* Added struct boxing to `MGLCoordinateSpan`, `MGLCoordinateBounds`, `MGLOfflinePackProgress`, and `MGLTransition`. ([#9343](https://github.com/mapbox/mapbox-gl-native/pull/9343)) ## 3.5.4 - May 9, 2017 diff --git a/platform/ios/DEVELOPING.md b/platform/ios/DEVELOPING.md index 83064fbbd8..bcb837c243 100644 --- a/platform/ios/DEVELOPING.md +++ b/platform/ios/DEVELOPING.md @@ -46,7 +46,6 @@ Build and package the SDK by using one of the following commands: * `make iframework` builds a dynamic framework in the Debug configuration for devices and the iOS Simulator. The CocoaPods pod downloads the output of this target. * `make ipackage-sim` builds a dynamic framework in the Debug configuration for the iOS simulator. This is the fastest target. * `make ipackage-strip` builds both dynamic and static frameworks in the Debug configuration, stripped of debug symbols, for devices and the iOS Simulator. -* `make ifabric` builds a special static framework for compatibility with the Fabric Mac application. You can customize the build output by passing the following arguments into the `make` invocation: diff --git a/platform/ios/Mapbox-iOS-SDK-symbols.podspec b/platform/ios/Mapbox-iOS-SDK-symbols.podspec index 3116ede9f5..d2a686f1fb 100644 --- a/platform/ios/Mapbox-iOS-SDK-symbols.podspec +++ b/platform/ios/Mapbox-iOS-SDK-symbols.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |m| - version = '3.6.0-beta.2' + version = '3.6.0' m.name = 'Mapbox-iOS-SDK-symbols' m.version = "#{version}-symbols" diff --git a/platform/ios/Mapbox-iOS-SDK.podspec b/platform/ios/Mapbox-iOS-SDK.podspec index f6bc3030ab..55e8791b4c 100644 --- a/platform/ios/Mapbox-iOS-SDK.podspec +++ b/platform/ios/Mapbox-iOS-SDK.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |m| - version = '3.6.0-beta.2' + version = '3.6.0' m.name = 'Mapbox-iOS-SDK' m.version = version diff --git a/platform/ios/app/hu.lproj/Localizable.strings b/platform/ios/app/hu.lproj/Localizable.strings new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/platform/ios/app/hu.lproj/Localizable.strings diff --git a/platform/ios/docs/guides/For Style Authors.md b/platform/ios/docs/guides/For Style Authors.md index 8b7bc05f2c..7eabfed777 100644 --- a/platform/ios/docs/guides/For Style Authors.md +++ b/platform/ios/docs/guides/For Style Authors.md @@ -76,6 +76,8 @@ gestures. For more information about user interface design, consult Apple’s [_iOS Human Interface Guidelines_](https://developer.apple.com/ios/human-interface-guidelines/). +To learn more about designing maps for mobile devices, see [Nathaniel Slaughter's blog post](https://www.mapbox.com/blog/designing-maps-for-mobile-devices/) on +the subject. ## Applying your style diff --git a/platform/ios/ios.xcodeproj/project.pbxproj b/platform/ios/ios.xcodeproj/project.pbxproj index a906c4fd77..9af8387233 100644 --- a/platform/ios/ios.xcodeproj/project.pbxproj +++ b/platform/ios/ios.xcodeproj/project.pbxproj @@ -168,12 +168,12 @@ 404C26E71D89C55D000AA13D /* MGLTileSource_Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 404C26E61D89C515000AA13D /* MGLTileSource_Private.h */; }; 404C26E81D89C55D000AA13D /* MGLTileSource_Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 404C26E61D89C515000AA13D /* MGLTileSource_Private.h */; }; 40599F0C1DEE1B7600182B5D /* api_mapbox_staging.der in Resources */ = {isa = PBXBuildFile; fileRef = 40599F001DEE1B2400182B5D /* api_mapbox_staging.der */; }; - 40599F0D1DEE1B7A00182B5D /* api_mapbox_com-digicert.der in Resources */ = {isa = PBXBuildFile; fileRef = 40599F011DEE1B2400182B5D /* api_mapbox_com-digicert.der */; }; - 40599F0E1DEE1B7E00182B5D /* api_mapbox_com-geotrust.der in Resources */ = {isa = PBXBuildFile; fileRef = 40599F021DEE1B2400182B5D /* api_mapbox_com-geotrust.der */; }; + 40599F0D1DEE1B7A00182B5D /* api_mapbox_com-digicert_2016.der in Resources */ = {isa = PBXBuildFile; fileRef = 40599F011DEE1B2400182B5D /* api_mapbox_com-digicert_2016.der */; }; + 40599F0E1DEE1B7E00182B5D /* api_mapbox_com-geotrust_2016.der in Resources */ = {isa = PBXBuildFile; fileRef = 40599F021DEE1B2400182B5D /* api_mapbox_com-geotrust_2016.der */; }; 4085AF091D933DEA00F11B22 /* MGLTileSetTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4085AF081D933DEA00F11B22 /* MGLTileSetTests.mm */; }; 408982E91DEE208200754016 /* api_mapbox_staging.der in Resources */ = {isa = PBXBuildFile; fileRef = 40599F001DEE1B2400182B5D /* api_mapbox_staging.der */; }; - 408982EA1DEE208B00754016 /* api_mapbox_com-digicert.der in Resources */ = {isa = PBXBuildFile; fileRef = 40599F011DEE1B2400182B5D /* api_mapbox_com-digicert.der */; }; - 408982EB1DEE209100754016 /* api_mapbox_com-geotrust.der in Resources */ = {isa = PBXBuildFile; fileRef = 40599F021DEE1B2400182B5D /* api_mapbox_com-geotrust.der */; }; + 408982EA1DEE208B00754016 /* api_mapbox_com-digicert_2016.der in Resources */ = {isa = PBXBuildFile; fileRef = 40599F011DEE1B2400182B5D /* api_mapbox_com-digicert_2016.der */; }; + 408982EB1DEE209100754016 /* api_mapbox_com-geotrust_2016.der in Resources */ = {isa = PBXBuildFile; fileRef = 40599F021DEE1B2400182B5D /* api_mapbox_com-geotrust_2016.der */; }; 408AA8571DAEDA1700022900 /* NSDictionary+MGLAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = 408AA8551DAEDA0800022900 /* NSDictionary+MGLAdditions.h */; }; 408AA8581DAEDA1E00022900 /* NSDictionary+MGLAdditions.mm in Sources */ = {isa = PBXBuildFile; fileRef = 408AA8561DAEDA0800022900 /* NSDictionary+MGLAdditions.mm */; }; 408AA8591DAEDA1E00022900 /* NSDictionary+MGLAdditions.mm in Sources */ = {isa = PBXBuildFile; fileRef = 408AA8561DAEDA0800022900 /* NSDictionary+MGLAdditions.mm */; }; @@ -181,6 +181,10 @@ 409F43FD1E9E781C0048729D /* MGLMapViewDelegateIntegrationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 409F43FC1E9E781C0048729D /* MGLMapViewDelegateIntegrationTests.swift */; }; 40CF6DBB1DAC3C6600A4D18B /* MGLShape_Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 40CF6DBA1DAC3C1800A4D18B /* MGLShape_Private.h */; }; 40CFA6511D7875BB008103BD /* MGLShapeSourceTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 40CFA6501D787579008103BD /* MGLShapeSourceTests.mm */; }; + 40EA6BC11EF4599600FCCDA2 /* api_mapbox_com-digicert_2017.der in Resources */ = {isa = PBXBuildFile; fileRef = 40EA6BBD1EF4598900FCCDA2 /* api_mapbox_com-digicert_2017.der */; }; + 40EA6BC21EF4599700FCCDA2 /* api_mapbox_com-digicert_2017.der in Resources */ = {isa = PBXBuildFile; fileRef = 40EA6BBD1EF4598900FCCDA2 /* api_mapbox_com-digicert_2017.der */; }; + 40EA6BC31EF4599D00FCCDA2 /* api_mapbox_com-geotrust_2017.der in Resources */ = {isa = PBXBuildFile; fileRef = 40EA6BBE1EF4598900FCCDA2 /* api_mapbox_com-geotrust_2017.der */; }; + 40EA6BC41EF4599D00FCCDA2 /* api_mapbox_com-geotrust_2017.der in Resources */ = {isa = PBXBuildFile; fileRef = 40EA6BBE1EF4598900FCCDA2 /* api_mapbox_com-geotrust_2017.der */; }; 40EDA1C01CFE0E0200D9EA68 /* MGLAnnotationContainerView.h in Headers */ = {isa = PBXBuildFile; fileRef = 40EDA1BD1CFE0D4A00D9EA68 /* MGLAnnotationContainerView.h */; }; 40EDA1C11CFE0E0500D9EA68 /* MGLAnnotationContainerView.m in Sources */ = {isa = PBXBuildFile; fileRef = 40EDA1BE1CFE0D4A00D9EA68 /* MGLAnnotationContainerView.m */; }; 40EDA1C21CFE0E0500D9EA68 /* MGLAnnotationContainerView.m in Sources */ = {isa = PBXBuildFile; fileRef = 40EDA1BE1CFE0D4A00D9EA68 /* MGLAnnotationContainerView.m */; }; @@ -645,8 +649,8 @@ 404C26E11D89B877000AA13D /* MGLTileSource.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MGLTileSource.mm; sourceTree = "<group>"; }; 404C26E61D89C515000AA13D /* MGLTileSource_Private.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MGLTileSource_Private.h; sourceTree = "<group>"; }; 40599F001DEE1B2400182B5D /* api_mapbox_staging.der */ = {isa = PBXFileReference; lastKnownFileType = file; path = api_mapbox_staging.der; sourceTree = "<group>"; }; - 40599F011DEE1B2400182B5D /* api_mapbox_com-digicert.der */ = {isa = PBXFileReference; lastKnownFileType = file; path = "api_mapbox_com-digicert.der"; sourceTree = "<group>"; }; - 40599F021DEE1B2400182B5D /* api_mapbox_com-geotrust.der */ = {isa = PBXFileReference; lastKnownFileType = file; path = "api_mapbox_com-geotrust.der"; sourceTree = "<group>"; }; + 40599F011DEE1B2400182B5D /* api_mapbox_com-digicert_2016.der */ = {isa = PBXFileReference; lastKnownFileType = file; path = "api_mapbox_com-digicert_2016.der"; sourceTree = "<group>"; }; + 40599F021DEE1B2400182B5D /* api_mapbox_com-geotrust_2016.der */ = {isa = PBXFileReference; lastKnownFileType = file; path = "api_mapbox_com-geotrust_2016.der"; sourceTree = "<group>"; }; 4085AF081D933DEA00F11B22 /* MGLTileSetTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = MGLTileSetTests.mm; path = ../../darwin/test/MGLTileSetTests.mm; sourceTree = "<group>"; }; 408AA8551DAEDA0800022900 /* NSDictionary+MGLAdditions.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "NSDictionary+MGLAdditions.h"; sourceTree = "<group>"; }; 408AA8561DAEDA0800022900 /* NSDictionary+MGLAdditions.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = "NSDictionary+MGLAdditions.mm"; sourceTree = "<group>"; }; @@ -654,6 +658,8 @@ 409F43FC1E9E781C0048729D /* MGLMapViewDelegateIntegrationTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MGLMapViewDelegateIntegrationTests.swift; sourceTree = "<group>"; }; 40CF6DBA1DAC3C1800A4D18B /* MGLShape_Private.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MGLShape_Private.h; sourceTree = "<group>"; }; 40CFA6501D787579008103BD /* MGLShapeSourceTests.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; name = MGLShapeSourceTests.mm; path = ../../darwin/test/MGLShapeSourceTests.mm; sourceTree = "<group>"; }; + 40EA6BBD1EF4598900FCCDA2 /* api_mapbox_com-digicert_2017.der */ = {isa = PBXFileReference; lastKnownFileType = file; path = "api_mapbox_com-digicert_2017.der"; sourceTree = "<group>"; }; + 40EA6BBE1EF4598900FCCDA2 /* api_mapbox_com-geotrust_2017.der */ = {isa = PBXFileReference; lastKnownFileType = file; path = "api_mapbox_com-geotrust_2017.der"; sourceTree = "<group>"; }; 40EDA1BD1CFE0D4A00D9EA68 /* MGLAnnotationContainerView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLAnnotationContainerView.h; sourceTree = "<group>"; }; 40EDA1BE1CFE0D4A00D9EA68 /* MGLAnnotationContainerView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MGLAnnotationContainerView.m; sourceTree = "<group>"; }; 40F8876F1D7A1DB8008ECB67 /* MGLShapeSource_Private.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MGLShapeSource_Private.h; sourceTree = "<group>"; }; @@ -749,6 +755,8 @@ DA57D4AA1EBA8ED300793288 /* es */ = {isa = PBXFileReference; lastKnownFileType = text.plist.stringsdict; name = es; path = es.lproj/Localizable.stringsdict; sourceTree = "<group>"; }; DA57D4AB1EBA909900793288 /* lt */ = {isa = PBXFileReference; lastKnownFileType = text.plist.stringsdict; name = lt; path = lt.lproj/Localizable.stringsdict; sourceTree = "<group>"; }; DA57D4AC1EBA922A00793288 /* vi */ = {isa = PBXFileReference; lastKnownFileType = text.plist.stringsdict; name = vi; path = vi.lproj/Localizable.stringsdict; sourceTree = "<group>"; }; + DA5C09BA1EFC48550056B178 /* hu */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = hu; path = hu.lproj/Localizable.strings; sourceTree = "<group>"; }; + DA5C09BB1EFC486C0056B178 /* hu */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = hu; path = hu.lproj/Localizable.strings; sourceTree = "<group>"; }; DA6023F11E4CE94300DBFF23 /* sv */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = sv; path = sv.lproj/Foundation.strings; sourceTree = "<group>"; }; DA6023F21E4CE94800DBFF23 /* sv */ = {isa = PBXFileReference; lastKnownFileType = text.plist.stringsdict; name = sv; path = sv.lproj/Foundation.stringsdict; sourceTree = "<group>"; }; DA618B111E68823600CB7F44 /* ru */ = {isa = PBXFileReference; lastKnownFileType = text.plist.stringsdict; name = ru; path = ru.lproj/Localizable.stringsdict; sourceTree = "<group>"; }; @@ -1362,8 +1370,10 @@ DAC49C5F1CD02BC9009E1AA3 /* Localizable.stringsdict */, DA8933EF1CCD387900E68420 /* strip-frameworks.sh */, 40599F001DEE1B2400182B5D /* api_mapbox_staging.der */, - 40599F011DEE1B2400182B5D /* api_mapbox_com-digicert.der */, - 40599F021DEE1B2400182B5D /* api_mapbox_com-geotrust.der */, + 40599F011DEE1B2400182B5D /* api_mapbox_com-digicert_2016.der */, + 40599F021DEE1B2400182B5D /* api_mapbox_com-geotrust_2016.der */, + 40EA6BBD1EF4598900FCCDA2 /* api_mapbox_com-digicert_2017.der */, + 40EA6BBE1EF4598900FCCDA2 /* api_mapbox_com-geotrust_2017.der */, ); name = "Kit Resources"; path = resources; @@ -2018,6 +2028,7 @@ ca, fi, nl, + hu, ); mainGroup = DA1DC9411CB6C1C2006E619F; productRefGroup = DA1DC94B1CB6C1C2006E619F /* Products */; @@ -2085,9 +2096,11 @@ DA8933F01CCD387900E68420 /* strip-frameworks.sh in Resources */, DAC49C5C1CD02BC9009E1AA3 /* Localizable.stringsdict in Resources */, DA8933BF1CCD2CAD00E68420 /* Foundation.stringsdict in Resources */, + 40EA6BC11EF4599600FCCDA2 /* api_mapbox_com-digicert_2017.der in Resources */, 408982E91DEE208200754016 /* api_mapbox_staging.der in Resources */, - 408982EA1DEE208B00754016 /* api_mapbox_com-digicert.der in Resources */, - 408982EB1DEE209100754016 /* api_mapbox_com-geotrust.der in Resources */, + 408982EA1DEE208B00754016 /* api_mapbox_com-digicert_2016.der in Resources */, + 40EA6BC31EF4599D00FCCDA2 /* api_mapbox_com-geotrust_2017.der in Resources */, + 408982EB1DEE209100754016 /* api_mapbox_com-geotrust_2016.der in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -2099,10 +2112,12 @@ DA8933DB1CCD31D400E68420 /* Foundation.strings in Resources */, 960D0C371ECF5AAF008E151F /* Images.xcassets in Resources */, DA8933DC1CCD31D400E68420 /* Foundation.stringsdict in Resources */, + 40EA6BC41EF4599D00FCCDA2 /* api_mapbox_com-geotrust_2017.der in Resources */, DAC49C5D1CD02BC9009E1AA3 /* Localizable.stringsdict in Resources */, 40599F0C1DEE1B7600182B5D /* api_mapbox_staging.der in Resources */, - 40599F0D1DEE1B7A00182B5D /* api_mapbox_com-digicert.der in Resources */, - 40599F0E1DEE1B7E00182B5D /* api_mapbox_com-geotrust.der in Resources */, + 40599F0D1DEE1B7A00182B5D /* api_mapbox_com-digicert_2016.der in Resources */, + 40599F0E1DEE1B7E00182B5D /* api_mapbox_com-geotrust_2016.der in Resources */, + 40EA6BC21EF4599700FCCDA2 /* api_mapbox_com-digicert_2017.der in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -2416,6 +2431,7 @@ DA618B1A1E68883900CB7F44 /* ca */, DA618B2B1E68932D00CB7F44 /* fi */, DAE8CCAD1E6E8C70009B5CB0 /* nl */, + DA5C09BA1EFC48550056B178 /* hu */, ); name = Localizable.strings; sourceTree = "<group>"; @@ -2460,6 +2476,7 @@ DA737AE91E5917C300AD2CDE /* uk */, DA1AC01B1E5B8774006DF1D6 /* lt */, DA618B1B1E68884E00CB7F44 /* ca */, + DA5C09BB1EFC486C0056B178 /* hu */, ); name = Localizable.strings; sourceTree = "<group>"; diff --git a/platform/ios/resources/Images.xcassets/default_marker.imageset/default_marker.pdf b/platform/ios/resources/Images.xcassets/default_marker.imageset/default_marker.pdf Binary files differindex 4e2e332301..d3e0e2ce12 100644 --- a/platform/ios/resources/Images.xcassets/default_marker.imageset/default_marker.pdf +++ b/platform/ios/resources/Images.xcassets/default_marker.imageset/default_marker.pdf diff --git a/platform/ios/resources/api_mapbox_com-digicert.der b/platform/ios/resources/api_mapbox_com-digicert_2016.der Binary files differindex e8ef427f33..e8ef427f33 100644 --- a/platform/ios/resources/api_mapbox_com-digicert.der +++ b/platform/ios/resources/api_mapbox_com-digicert_2016.der diff --git a/platform/ios/resources/api_mapbox_com-digicert_2017.der b/platform/ios/resources/api_mapbox_com-digicert_2017.der Binary files differnew file mode 100644 index 0000000000..4a190085ab --- /dev/null +++ b/platform/ios/resources/api_mapbox_com-digicert_2017.der diff --git a/platform/ios/resources/api_mapbox_com-geotrust.der b/platform/ios/resources/api_mapbox_com-geotrust_2016.der Binary files differindex 1c7331dedc..1c7331dedc 100644 --- a/platform/ios/resources/api_mapbox_com-geotrust.der +++ b/platform/ios/resources/api_mapbox_com-geotrust_2016.der diff --git a/platform/ios/resources/api_mapbox_com-geotrust_2017.der b/platform/ios/resources/api_mapbox_com-geotrust_2017.der Binary files differnew file mode 100644 index 0000000000..7bb9befbbf --- /dev/null +++ b/platform/ios/resources/api_mapbox_com-geotrust_2017.der diff --git a/platform/ios/resources/de.lproj/Localizable.strings b/platform/ios/resources/de.lproj/Localizable.strings index 1ea03e7d61..e8180ea17c 100644 --- a/platform/ios/resources/de.lproj/Localizable.strings +++ b/platform/ios/resources/de.lproj/Localizable.strings @@ -10,6 +10,9 @@ /* No comment provided by engineer. */ "CANCEL" = "Abbrechen"; +/* Accessibility hint for closing the selected annotation’s callout view and returning to the map */ +"CLOSE_CALLOUT_A11Y_HINT" = "Zurück zur Karte "; + /* Accessibility hint */ "COMPASS_A11Y_HINT" = "Dreht die Karte nach Norden"; @@ -31,6 +34,12 @@ /* Accessibility label */ "INFO_A11Y_LABEL" = "Über diese Karte"; +/* User-friendly error description */ +"LOAD_MAP_FAILED_DESC" = "Die Karte konnte nicht geladen werden, da ein unbekannter Fehler aufgetreten ist."; + +/* User-friendly error description */ +"LOAD_STYLE_FAILED_DESC" = "Die Karte konnte nicht geladen werden, da diese Form nicht geladen werden kann"; + /* Accessibility label */ "LOGO_A11Y_LABEL" = "Mapbox"; @@ -40,9 +49,18 @@ /* Map accessibility value */ "MAP_A11Y_VALUE" = "Zoomstufe %1$d\n%2$ld Anmerkung(en) sichtbar"; +/* User-friendly error description */ +"PARSE_STYLE_FAILED_DESC" = "Die Karte konnte nicht geladen werden, da diese Form beschädigt ist."; + /* Action sheet title */ "SDK_NAME" = "Mapbox iOS SDK"; +/* Developer-only SDK update notification; {latest version, in format x.x.x} */ +"SDK_UPDATE_AVAILABLE" = "Mapbox iOS SDK Version %@ ist ab sofort verfügbar."; + +/* User-friendly error description */ +"STYLE_NOT_FOUND_DESC" = "Die Karte konnte nicht geladen werden, da diese Form nicht gefunden werden kann oder nicht kompatibel ist."; + /* Telemetry prompt message */ "TELEMETRY_DISABLED_MSG" = "Durch anonymisierte Nutzungsdaten können Sie helfen, OpenStreetMap- und Mapbox-Karten zu verbessern."; diff --git a/platform/ios/resources/hu.lproj/Localizable.strings b/platform/ios/resources/hu.lproj/Localizable.strings new file mode 100644 index 0000000000..a4d1b1c3ae --- /dev/null +++ b/platform/ios/resources/hu.lproj/Localizable.strings @@ -0,0 +1,93 @@ +/* Accessibility hint */ +"ANNOTATION_A11Y_HINT" = "Több infót mutat"; + +/* No comment provided by engineer. */ +"API_CLIENT_400_DESC" = "The session data task failed. Original request was: %@"; + +/* No comment provided by engineer. */ +"API_CLIENT_400_REASON" = "A státuszkód %ld volt"; + +/* No comment provided by engineer. */ +"CANCEL" = "Mégse"; + +/* Accessibility hint for closing the selected annotation’s callout view and returning to the map */ +"CLOSE_CALLOUT_A11Y_HINT" = "Visszatér a térképhez"; + +/* Accessibility hint */ +"COMPASS_A11Y_HINT" = "Elforgatja a térképet, hogy észak felé nézzen"; + +/* Accessibility label */ +"COMPASS_A11Y_LABEL" = "Iránytű"; + +/* Compass abbreviation for north */ +"COMPASS_NORTH" = "É"; + +/* Instructions in Interface Builder designable; {key}, {plist file name} */ +"DESIGNABLE" = "To display a Mapbox-hosted map here, set %1$@ to your access token in %2$@\n\nFor detailed instructions, see:"; + +/* Setup documentation URL display string; keep as short as possible */ +"FIRST_STEPS_URL" = "mapbox.com/help/first-steps-ios-sdk"; + +/* Accessibility hint */ +"INFO_A11Y_HINT" = "Shows credits, a feedback form, and more"; + +/* Accessibility label */ +"INFO_A11Y_LABEL" = "Erről a térképről"; + +/* User-friendly error description */ +"LOAD_MAP_FAILED_DESC" = "Nem sikerült betölteni a térképet, mert ismeretlen hiba történt."; + +/* User-friendly error description */ +"LOAD_STYLE_FAILED_DESC" = "Nem sikerült betölteni a térképet, mert a stílust nem lehetett betölteni."; + +/* Accessibility label */ +"LOGO_A11Y_LABEL" = "Mapbox"; + +/* Accessibility label */ +"MAP_A11Y_LABEL" = "Térkép"; + +/* Map accessibility value */ +"MAP_A11Y_VALUE" = "Zoom %1$dx\n%2$ld annotation(s) visible"; + +/* User-friendly error description */ +"PARSE_STYLE_FAILED_DESC" = "Nem sikerült betölteni a térképet, mert a stílus sérült."; + +/* Action sheet title */ +"SDK_NAME" = "Mapbox iOS SDK"; + +/* Developer-only SDK update notification; {latest version, in format x.x.x} */ +"SDK_UPDATE_AVAILABLE" = "Mapbox iOS SDK %@ mostantól elérhető:"; + +/* User-friendly error description */ +"STYLE_NOT_FOUND_DESC" = "Nem sikerült betölteni a térképet, mert a stílus nem található vagy inkompatibilis."; + +/* Telemetry prompt message */ +"TELEMETRY_DISABLED_MSG" = "You can help make OpenStreetMap and Mapbox maps better by contributing anonymous usage data."; + +/* Telemetry prompt button */ +"TELEMETRY_DISABLED_OFF" = "Nem veszek részt"; + +/* Telemetry prompt button */ +"TELEMETRY_DISABLED_ON" = "Részt veszek"; + +/* Telemetry prompt message */ +"TELEMETRY_ENABLED_MSG" = "You are helping to make OpenStreetMap and Mapbox maps better by contributing anonymous usage data."; + +/* Telemetry prompt button */ +"TELEMETRY_ENABLED_OFF" = "Részvétel befejezése"; + +/* Telemetry prompt button */ +"TELEMETRY_ENABLED_ON" = "Részvétel folytatása"; + +/* Telemetry prompt button */ +"TELEMETRY_MORE" = "Többet akarok tudni"; + +/* Action in attribution sheet */ +"TELEMETRY_NAME" = "Mapbox telemetria"; + +/* Telemetry prompt title */ +"TELEMETRY_TITLE" = "Tedd jobbá a Mapbox térképeket"; + +/* Default user location annotation title */ +"USER_DOT_TITLE" = "Itt vagy"; + diff --git a/platform/ios/scripts/deploy-packages.sh b/platform/ios/scripts/deploy-packages.sh index 4a3c73295a..bdc946497d 100755 --- a/platform/ios/scripts/deploy-packages.sh +++ b/platform/ios/scripts/deploy-packages.sh @@ -112,6 +112,5 @@ buildPackageStyle "ipackage" "symbols" buildPackageStyle "ipackage-strip" buildPackageStyle "iframework" "symbols-dynamic" buildPackageStyle "iframework SYMBOLS=NO" "dynamic" -buildPackageStyle "ifabric" "fabric" step "Finished deploying ${PUBLISH_VERSION} in $(($SECONDS / 60)) minutes and $(($SECONDS % 60)) seconds" diff --git a/platform/ios/scripts/release-fabric.sh b/platform/ios/scripts/release-fabric.sh deleted file mode 100755 index a523705b7b..0000000000 --- a/platform/ios/scripts/release-fabric.sh +++ /dev/null @@ -1,37 +0,0 @@ -#!/usr/bin/env bash - -set -e -set -o pipefail -set -u - -export PUBLISH_VERSION=$1 -export BINARY_DIRECTORY=$2 -export ZIP_OUTPUT=mapbox-ios-sdk-${PUBLISH_VERSION}-fabric -export FILE_NAME=mapbox-ios-sdk-${PUBLISH_VERSION}-fabric.zip -export ZIP_ARCHIVE_PATH=${BINARY_DIRECTORY}/${FILE_NAME} -export BUNDLE_ID="com.mapbox.sdk.ios" - -echo "Downloading ${FILE_NAME}:" -wget -P ${BINARY_DIRECTORY} http://mapbox.s3.amazonaws.com/mapbox-gl-native/ios/builds/${FILE_NAME} - -echo "Extracting ${ZIP_ARCHIVE_PATH} to ${BINARY_DIRECTORY}/${ZIP_OUTPUT}" -unzip -q ${ZIP_ARCHIVE_PATH} -d ${BINARY_DIRECTORY}/${ZIP_OUTPUT} -ditto ${BINARY_DIRECTORY}/${ZIP_OUTPUT}/static/Mapbox.framework ${BINARY_DIRECTORY}/Mapbox.framework - -echo "Zipping framework:" -cd ${BINARY_DIRECTORY} -zip -q -r Mapbox.framework.zip Mapbox.framework -cd $OLDPWD - -echo "Validating framework:" -./validate-fabric-zip.sh ${BINARY_DIRECTORY}/Mapbox.framework.zip - -echo "Uploading ${BINARY_DIRECTORY}/Mapbox.framework.zip to https://kits.fabric.io/manage-api/v1/kit-releases/ios/$BUNDLE_ID/$PUBLISH_VERSION with key ${FABRIC_KIT_API_KEY}" -curl --fail -v -X PUT -H "X-FabricKits-ApiKey: ${FABRIC_KIT_API_KEY}" \ - -F "release_artifact=@${BINARY_DIRECTORY}/Mapbox.framework.zip;type=application/octet-stream" \ - https://kits.fabric.io/manage-api/v1/kit-releases/ios/$BUNDLE_ID/$PUBLISH_VERSION - -echo "Cleaning up" -rm -r #{BINARY_DIRECTORY} - -echo "Done" diff --git a/platform/ios/scripts/validate-fabric-zip.sh b/platform/ios/scripts/validate-framework-zip.sh index 2cd1e90ee7..2cd1e90ee7 100755 --- a/platform/ios/scripts/validate-fabric-zip.sh +++ b/platform/ios/scripts/validate-framework-zip.sh diff --git a/platform/ios/src/MGLAPIClient.m b/platform/ios/src/MGLAPIClient.m index 124d436197..8a987d76d8 100644 --- a/platform/ios/src/MGLAPIClient.m +++ b/platform/ios/src/MGLAPIClient.m @@ -17,8 +17,10 @@ static NSString * const MGLAPIClientHTTPMethodPost = @"POST"; @property (nonatomic, copy) NSURLSession *session; @property (nonatomic, copy) NSURL *baseURL; -@property (nonatomic, copy) NSData *digicertCert; -@property (nonatomic, copy) NSData *geoTrustCert; +@property (nonatomic, copy) NSData *digicertCert_2016; +@property (nonatomic, copy) NSData *geoTrustCert_2016; +@property (nonatomic, copy) NSData *digicertCert_2017; +@property (nonatomic, copy) NSData *geoTrustCert_2017; @property (nonatomic, copy) NSData *testServerCert; @property (nonatomic, copy) NSString *userAgent; @property (nonatomic) BOOL usesTestServer; @@ -107,10 +109,14 @@ static NSString * const MGLAPIClientHTTPMethodPost = @"POST"; - (void)loadCertificates { NSData *certificate; - [self loadCertificate:&certificate withResource:@"api_mapbox_com-geotrust"]; - self.geoTrustCert = certificate; - [self loadCertificate:&certificate withResource:@"api_mapbox_com-digicert"]; - self.digicertCert = certificate; + [self loadCertificate:&certificate withResource:@"api_mapbox_com-geotrust_2016"]; + self.geoTrustCert_2016 = certificate; + [self loadCertificate:&certificate withResource:@"api_mapbox_com-digicert_2016"]; + self.digicertCert_2016 = certificate; + [self loadCertificate:&certificate withResource:@"api_mapbox_com-geotrust_2017"]; + self.geoTrustCert_2017 = certificate; + [self loadCertificate:&certificate withResource:@"api_mapbox_com-digicert_2017"]; + self.digicertCert_2017 = certificate; [self loadCertificate:&certificate withResource:@"api_mapbox_staging"]; self.testServerCert = certificate; } @@ -141,75 +147,53 @@ static NSString * const MGLAPIClientHTTPMethodPost = @"POST"; #pragma mark NSURLSessionDelegate +- (BOOL)evaluateCertificateWithCertificateData:(NSData *)certificateData keyCount:(CFIndex)keyCount serverTrust:(SecTrustRef)serverTrust challenge:(NSURLAuthenticationChallenge *)challenge completionHandler:(void (^) (NSURLSessionAuthChallengeDisposition disposition, NSURLCredential *credential))completionHandler { + for (int lc = 0; lc < keyCount; lc++) { + SecCertificateRef certificate = SecTrustGetCertificateAtIndex(serverTrust, lc); + NSData *remoteCertificateData = CFBridgingRelease(SecCertificateCopyData(certificate)); + if ([remoteCertificateData isEqualToData:certificateData]) { + completionHandler(NSURLSessionAuthChallengeUseCredential, [NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust]); + return YES; + } + } + return NO; +} + - (void)URLSession:(NSURLSession *)session didReceiveChallenge:(NSURLAuthenticationChallenge *)challenge completionHandler:(void (^) (NSURLSessionAuthChallengeDisposition disposition, NSURLCredential *credential))completionHandler { + if([challenge.protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust]) { - SecTrustRef serverTrust = [[challenge protectionSpace] serverTrust]; SecTrustResultType trustResult; - - // Validate the certificate chain with the device's trust store anyway - // This *might* give use revocation checking + + // Validate the certificate chain with the device's trust store anyway this *might* use revocation checking SecTrustEvaluate(serverTrust, &trustResult); - if (trustResult == kSecTrustResultUnspecified) - { + + BOOL found = NO; // For clarity; we start in a state where the challange has not been completed and no certificate has been found + + if (trustResult == kSecTrustResultUnspecified) { // Look for a pinned certificate in the server's certificate chain - long numKeys = SecTrustGetCertificateCount(serverTrust); - - BOOL found = NO; - // Try GeoTrust Cert First - for (int lc = 0; lc < numKeys; lc++) { - SecCertificateRef certificate = SecTrustGetCertificateAtIndex(serverTrust, lc); - NSData *remoteCertificateData = CFBridgingRelease(SecCertificateCopyData(certificate)); - - // Compare Remote Key With Local Version - if ([remoteCertificateData isEqualToData:_geoTrustCert]) { - // Found the certificate; continue connecting - completionHandler(NSURLSessionAuthChallengeUseCredential, [NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust]); - found = YES; - break; - } + CFIndex numKeys = SecTrustGetCertificateCount(serverTrust); + + // Check certs in the following order: digicert 2016, digicert 2017, geotrust 2016, geotrust 2017 + found = [self evaluateCertificateWithCertificateData:self.digicertCert_2016 keyCount:numKeys serverTrust:serverTrust challenge:challenge completionHandler:completionHandler]; + if (!found) { + found = [self evaluateCertificateWithCertificateData:self.digicertCert_2017 keyCount:numKeys serverTrust:serverTrust challenge:challenge completionHandler:completionHandler]; } - if (!found) { - // Fallback to Digicert Cert - for (int lc = 0; lc < numKeys; lc++) { - SecCertificateRef certificate = SecTrustGetCertificateAtIndex(serverTrust, lc); - NSData *remoteCertificateData = CFBridgingRelease(SecCertificateCopyData(certificate)); - - // Compare Remote Key With Local Version - if ([remoteCertificateData isEqualToData:_digicertCert]) { - // Found the certificate; continue connecting - completionHandler(NSURLSessionAuthChallengeUseCredential, [NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust]); - found = YES; - break; - } - } - - if (!found && _usesTestServer) { - // See if this is test server - for (int lc = 0; lc < numKeys; lc++) { - SecCertificateRef certificate = SecTrustGetCertificateAtIndex(serverTrust, lc); - NSData *remoteCertificateData = CFBridgingRelease(SecCertificateCopyData(certificate)); - - // Compare Remote Key With Local Version - if ([remoteCertificateData isEqualToData:_testServerCert]) { - // Found the certificate; continue connecting - completionHandler(NSURLSessionAuthChallengeUseCredential, [NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust]); - found = YES; - break; - } - } - } - - if (!found) { - // The certificate wasn't found in GeoTrust nor Digicert. Cancel the connection. - completionHandler(NSURLSessionAuthChallengeCancelAuthenticationChallenge, [NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust]); - } + found = [self evaluateCertificateWithCertificateData:self.geoTrustCert_2016 keyCount:numKeys serverTrust:serverTrust challenge:challenge completionHandler:completionHandler]; + } + if (!found) { + found = [self evaluateCertificateWithCertificateData:self.geoTrustCert_2017 keyCount:numKeys serverTrust:serverTrust challenge:challenge completionHandler:completionHandler]; + } + + // If challenge can't be completed with any of the above certs, then try the test server if the app is configured to use the test server + if (!found && _usesTestServer) { + found = [self evaluateCertificateWithCertificateData:self.testServerCert keyCount:numKeys serverTrust:serverTrust challenge:challenge completionHandler:completionHandler]; } } - else - { - // Certificate chain validation failed; cancel the connection + + if (!found) { + // No certificate was found so cancel the connection. completionHandler(NSURLSessionAuthChallengeCancelAuthenticationChallenge, [NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust]); } } diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm index c1d257dd51..1444fc3cb0 100644 --- a/platform/ios/src/MGLMapView.mm +++ b/platform/ios/src/MGLMapView.mm @@ -85,6 +85,8 @@ typedef NS_ENUM(NSUInteger, MGLUserTrackingState) { MGLUserTrackingStatePossible = 0, /// The map view has begun to move to the first reported user location. MGLUserTrackingStateBegan, + /// The map view begins a significant transition. + MGLUserTrackingStateBeginSignificantTransition, /// The map view has finished moving to the first reported user location. MGLUserTrackingStateChanged, }; @@ -113,6 +115,9 @@ const NSUInteger MGLTargetFrameInterval = 1; // Target FPS will be 60 divided b /// Tolerance for snapping to true north, measured in degrees in either direction. const CLLocationDirection MGLToleranceForSnappingToNorth = 7; +/// Distance threshold to stop the camera while animating. +const CLLocationDistance MGLDistanceThresholdForCameraPause = 500; + /// Reuse identifier and file name of the default point annotation image. static NSString * const MGLDefaultStyleMarkerSymbolName = @"default_marker"; @@ -310,6 +315,8 @@ public: /// Center coordinate of the pinch gesture on the previous iteration of the gesture. CLLocationCoordinate2D _previousPinchCenterCoordinate; NSUInteger _previousPinchNumberOfTouches; + + CLLocationDistance _distanceFromOldUserLocation; BOOL _delegateHasAlphasForShapeAnnotations; BOOL _delegateHasStrokeColorsForShapeAnnotations; @@ -525,21 +532,21 @@ public: _singleTapGestureRecognizer.delegate = self; [self addGestureRecognizer:_singleTapGestureRecognizer]; - _twoFingerTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTwoFingerTapGesture:)]; - _twoFingerTap.numberOfTouchesRequired = 2; - [_twoFingerTap requireGestureRecognizerToFail:_pinch]; - [_twoFingerTap requireGestureRecognizerToFail:_rotate]; - [self addGestureRecognizer:_twoFingerTap]; - _twoFingerDrag = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(handleTwoFingerDragGesture:)]; _twoFingerDrag.minimumNumberOfTouches = 2; _twoFingerDrag.maximumNumberOfTouches = 2; _twoFingerDrag.delegate = self; - [_twoFingerDrag requireGestureRecognizerToFail:_twoFingerTap]; [_twoFingerDrag requireGestureRecognizerToFail:_pan]; [self addGestureRecognizer:_twoFingerDrag]; _pitchEnabled = YES; + _twoFingerTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTwoFingerTapGesture:)]; + _twoFingerTap.numberOfTouchesRequired = 2; + [_twoFingerTap requireGestureRecognizerToFail:_pinch]; + [_twoFingerTap requireGestureRecognizerToFail:_rotate]; + [_twoFingerTap requireGestureRecognizerToFail:_twoFingerDrag]; + [self addGestureRecognizer:_twoFingerTap]; + _decelerationRate = MGLMapViewDecelerationRateNormal; _quickZoom = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(handleQuickZoomGesture:)]; @@ -1130,6 +1137,10 @@ public: { _changeDelimiterSuppressionDepth = 0; _mbglMap->setGestureInProgress(false); + if (self.userTrackingState == MGLUserTrackingStateBegan) + { + [self setUserTrackingMode:MGLUserTrackingModeNone animated:NO]; + } _mbglMap->cancelTransitions(); } @@ -1259,16 +1270,16 @@ public: [self.delegate mapView:self shouldChangeFromCamera:oldCamera toCamera:toCamera]) { _mbglMap->setZoom(zoom, mbgl::ScreenCoordinate { centerPoint.x, centerPoint.y }); - } - // The gesture recognizer only reports the gesture’s current center - // point, so use the previous center point to anchor the transition. - // If the number of touches has changed, the remembered center point is - // meaningless. - if (self.userTrackingMode == MGLUserTrackingModeNone && pinch.numberOfTouches == _previousPinchNumberOfTouches) - { - CLLocationCoordinate2D centerCoordinate = _previousPinchCenterCoordinate; - _mbglMap->setLatLng(MGLLatLngFromLocationCoordinate2D(centerCoordinate), - mbgl::ScreenCoordinate { centerPoint.x, centerPoint.y }); + // The gesture recognizer only reports the gesture’s current center + // point, so use the previous center point to anchor the transition. + // If the number of touches has changed, the remembered center point is + // meaningless. + if (self.userTrackingMode == MGLUserTrackingModeNone && pinch.numberOfTouches == _previousPinchNumberOfTouches) + { + CLLocationCoordinate2D centerCoordinate = _previousPinchCenterCoordinate; + _mbglMap->setLatLng(MGLLatLngFromLocationCoordinate2D(centerCoordinate), + mbgl::ScreenCoordinate { centerPoint.x, centerPoint.y }); + } } [self cameraIsChanging]; } @@ -1635,14 +1646,14 @@ public: if ( ! self.isPitchEnabled) return; _mbglMap->cancelTransitions(); - MGLMapCamera *oldCamera = self.camera; if (twoFingerDrag.state == UIGestureRecognizerStateBegan) { [self trackGestureEvent:MGLEventGesturePitchStart forRecognizer:twoFingerDrag]; [self notifyGestureDidBegin]; } - else if (twoFingerDrag.state == UIGestureRecognizerStateBegan || twoFingerDrag.state == UIGestureRecognizerStateChanged) + + if (twoFingerDrag.state == UIGestureRecognizerStateBegan || twoFingerDrag.state == UIGestureRecognizerStateChanged) { CGFloat gestureDistance = CGPoint([twoFingerDrag translationInView:twoFingerDrag.view]).y; CGFloat currentPitch = _mbglMap->getPitch(); @@ -1652,6 +1663,7 @@ public: CGPoint centerPoint = [self anchorPointForGesture:twoFingerDrag]; + MGLMapCamera *oldCamera = self.camera; MGLMapCamera *toCamera = [self cameraByTiltingToPitch:pitchNew]; if (![self.delegate respondsToSelector:@selector(mapView:shouldChangeFromCamera:toCamera:)] || @@ -4362,6 +4374,7 @@ public: { CLLocation *oldLocation = self.userLocation.location; CLLocation *newLocation = locations.lastObject; + _distanceFromOldUserLocation = [newLocation distanceFromLocation:oldLocation]; if ( ! _showsUserLocation || ! newLocation || ! CLLocationCoordinate2DIsValid(newLocation.coordinate)) return; @@ -4455,7 +4468,12 @@ public: /// first location update. - (void)didUpdateLocationSignificantlyAnimated:(BOOL)animated { - self.userTrackingState = MGLUserTrackingStateBegan; + + if (_distanceFromOldUserLocation >= MGLDistanceThresholdForCameraPause) { + self.userTrackingState = MGLUserTrackingStateBeginSignificantTransition; + } else { + self.userTrackingState = MGLUserTrackingStateBegan; + } MGLMapCamera *camera = self.camera; camera.centerCoordinate = self.userLocation.location.coordinate; @@ -4475,7 +4493,8 @@ public: peakAltitude:-1 completionHandler:^{ MGLMapView *strongSelf = weakSelf; - if (strongSelf.userTrackingState == MGLUserTrackingStateBegan) + if (strongSelf.userTrackingState == MGLUserTrackingStateBegan || + strongSelf.userTrackingState == MGLDistanceThresholdForCameraPause) { strongSelf.userTrackingState = MGLUserTrackingStateChanged; } diff --git a/platform/ios/src/MGLScaleBar.mm b/platform/ios/src/MGLScaleBar.mm index cd88c1e08e..410aa7d57e 100644 --- a/platform/ios/src/MGLScaleBar.mm +++ b/platform/ios/src/MGLScaleBar.mm @@ -188,9 +188,9 @@ static const CGFloat MGLFeetPerMeter = 3.28084; - (MGLRow)preferredRow { CLLocationDistance maximumDistance = [self maximumWidth] * [self unitsPerPoint]; - MGLRow row; BOOL useMetric = [self usesMetricSystem]; + MGLRow row = useMetric ? MGLMetricTable[0] : MGLImperialTable[0]; NSUInteger count = useMetric ? sizeof(MGLMetricTable) / sizeof(MGLMetricTable[0]) : sizeof(MGLImperialTable) / sizeof(MGLImperialTable[0]); diff --git a/platform/ios/src/MGLUserLocation.h b/platform/ios/src/MGLUserLocation.h index c41c3ee7fd..30bfc592ca 100644 --- a/platform/ios/src/MGLUserLocation.h +++ b/platform/ios/src/MGLUserLocation.h @@ -8,7 +8,7 @@ NS_ASSUME_NONNULL_BEGIN /** The MGLUserLocation class defines a specific type of annotation that identifies the user’s current location. You do not create instances of this class - directly. Instead, you retrieve an existing MGLUserLocation object from the + directly. Instead, you retrieve an existing `MGLUserLocation` object from the `userLocation` property of the map view displayed in your application. */ @interface MGLUserLocation : NSObject <MGLAnnotation, NSSecureCoding> diff --git a/platform/macos/CHANGELOG.md b/platform/macos/CHANGELOG.md index b4766eb45a..29e3803dc2 100644 --- a/platform/macos/CHANGELOG.md +++ b/platform/macos/CHANGELOG.md @@ -3,18 +3,20 @@ ## master ### Styles -* Added suuport for diplaying georeferenced images via the `MGLImageSource`. [#9110](https://github.com/mapbox/mapbox-gl-native/pull/9110) - -### Packaging - -* Xcode 8.0 or higher is now recommended for using this SDK. ([#8775](https://github.com/mapbox/mapbox-gl-native/pull/8775)) -* Updated MGLMapView’s logo view to display [the new Mapbox logo](https://www.mapbox.com/blog/new-mapbox-logo/). ([#8771](https://github.com/mapbox/mapbox-gl-native/pull/8771), [#8773](https://github.com/mapbox/mapbox-gl-native/pull/8773)) +* Added support for displaying geo-referenced images via the `MGLImageSource`. [#9110](https://github.com/mapbox/mapbox-gl-native/pull/9110) * The previously-deprecated support for style classes has been removed. For interface compatibility, the API methods remain, but they are now non-functional. * Added an `overlays` property to `MGLMapView`. ([#8617](https://github.com/mapbox/mapbox-gl-native/pull/8617)) ## 0.5.0 +This version of the Mapbox macOS SDK corresponds to version 3.6.0 of the Mapbox iOS SDK. + +### Packaging + +* Xcode 8.0 or higher is now recommended for using this SDK. ([#8775](https://github.com/mapbox/mapbox-gl-native/pull/8775)) +* Updated MGLMapView’s logo view to display [the new Mapbox logo](https://www.mapbox.com/blog/new-mapbox-logo/). ([#8771](https://github.com/mapbox/mapbox-gl-native/pull/8771), [#8773](https://github.com/mapbox/mapbox-gl-native/pull/8773)) + ### Styles * Added support for 3D extrusion of buildings and other polygonal features via the `MGLFillExtrusionStyleLayer` class and the `fill-extrusion` layer type in style JSON. ([#8431](https://github.com/mapbox/mapbox-gl-native/pull/8431)) @@ -25,19 +27,32 @@ * Fixed an issue preventing programmatically added style layers from appearing in already cached tiles. ([#8954](https://github.com/mapbox/mapbox-gl-native/pull/8954)) * Fixed an issue causing a composite function’s highest zoom level stop to be misinterpreted. ([#8613](https://github.com/mapbox/mapbox-gl-native/pull/8613), [#8790](https://github.com/mapbox/mapbox-gl-native/pull/8790)) * Fixed an issue where re-adding a layer that had been previously removed from a style would reset its paint properties. Moved initializers for `MGLTileSource`, `MGLStyleLayer`, and `MGLForegroundStyleLayer` to their concrete subclasses; because these classes were already intended for initialization only via concrete subclasses, this should have no developer impact. ([#8626](https://github.com/mapbox/mapbox-gl-native/pull/8626)) +* Fixed a crash that occurred when removing a source that was still being used by one or more style layers. Since this is a programming error, a warning is logged to the console instead. ([#9129](https://github.com/mapbox/mapbox-gl-native/pull/9129)) * Feature querying results now account for any changes to a feature’s size caused by a source or composite style function. ([#8665](https://github.com/mapbox/mapbox-gl-native/pull/8665)) +* Fixed the behavior of composite functions that specify fractional zoom level stops. ([#9289](https://github.com/mapbox/mapbox-gl-native/pull/9289)) * Letter spacing is now disabled in Arabic text so that ligatures are drawn correctly. ([#9062](https://github.com/mapbox/mapbox-gl-native/pull/9062)) +* Improved the performance of styles using source and composite style functions. ([#9185](https://github.com/mapbox/mapbox-gl-native/pull/9185), [#9257](https://github.com/mapbox/mapbox-gl-native/pull/9257)) + +### Annotations + +* The default marker image has been made slightly larger and now matches the version in the Mapbox iOS SDK. ([#9370](https://github.com/mapbox/mapbox-gl-native/pull/9370)) +* The `MGLPolyline.coordinate` and `MGLPolygon.coordinate` properties now return the midpoint and centroid, respectively, instead of the first coordinate. ([#8713](https://github.com/mapbox/mapbox-gl-native/pull/8713)) + +### User interaction + +* Fixed an issue causing the map to go blank during a flight animation that travels a very short distance. ([#9199](https://github.com/mapbox/mapbox-gl-native/pull/9199)) +* Fixed an issue causing the mouse cursor to jump after Shift- or Option-dragging the map. ([#9390](https://github.com/mapbox/mapbox-gl-native/pull/9390)) +* The Improve This Map button in the attribution action sheet now leads to a feedback tool that matches MGLMapView’s rotation and pitch. `-[MGLAttributionInfo feedbackURLAtCenterCoordinate:zoomLevel:]` no longer respects the feedback URL specified in TileJSON. ([#9078](https://github.com/mapbox/mapbox-gl-native/pull/9078)) ### Other changes * Fixed a crash when calling `MGLMultiPolygon.coordinate` [#8713](https://github.com/mapbox/mapbox-gl-native/pull/8713) * Fixed an issue causing attribution button text to appear blue instead of black. ([#8701](https://github.com/mapbox/mapbox-gl-native/pull/8701)) * Fixed a crash or console spew when MGLMapView is initialized with a frame smaller than 64 points wide by 64 points tall. ([#8562](https://github.com/mapbox/mapbox-gl-native/pull/8562)) -* The Improve This Map button in the attribution action sheet now leads to a feedback tool that matches MGLMapView’s rotation and pitch. `-[MGLAttributionInfo feedbackURLAtCenterCoordinate:zoomLevel:]` no longer respects the feedback URL specified in TileJSON. ([#9078](https://github.com/mapbox/mapbox-gl-native/pull/9078)) * The error passed into `-[MGLMapViewDelegate mapViewDidFailLoadingMap:withError:]` now includes a more specific description and failure reason. ([#8418](https://github.com/mapbox/mapbox-gl-native/pull/8418)) -* The `MGLPolyline.coordinate` and `MGLPolygon.coordinate` properties now return the midpoint and centroid, respectively, instead of the first coordinate. ([#8713](https://github.com/mapbox/mapbox-gl-native/pull/8713)) * Improved CPU and battery performance while animating a tilted map’s camera in an area with many labels. ([#9031](https://github.com/mapbox/mapbox-gl-native/pull/9031)) * Fixed an issue rendering polylines that contain duplicate vertices. ([#8808](https://github.com/mapbox/mapbox-gl-native/pull/8808)) +* Added struct boxing to `MGLCoordinateSpan`, `MGLCoordinateBounds`, `MGLOfflinePackProgress`, and `MGLTransition`. ([#9343](https://github.com/mapbox/mapbox-gl-native/pull/9343)) ## 0.4.1 - April 8, 2017 diff --git a/platform/macos/Mapbox-macOS-SDK-symbols.podspec b/platform/macos/Mapbox-macOS-SDK-symbols.podspec index c621a7312b..5b70c52681 100644 --- a/platform/macos/Mapbox-macOS-SDK-symbols.podspec +++ b/platform/macos/Mapbox-macOS-SDK-symbols.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |m| - version = '0.4.1' + version = '0.5.0' m.name = 'Mapbox-macOS-SDK-symbols' m.version = "#{version}-symbols" diff --git a/platform/macos/Mapbox-macOS-SDK.podspec b/platform/macos/Mapbox-macOS-SDK.podspec index 2417fb11ec..0b26b13beb 100644 --- a/platform/macos/Mapbox-macOS-SDK.podspec +++ b/platform/macos/Mapbox-macOS-SDK.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |m| - version = '0.4.1' + version = '0.5.0' m.name = 'Mapbox-macOS-SDK' m.version = version diff --git a/platform/macos/docs/img/screenshot.jpg b/platform/macos/docs/img/screenshot.jpg Binary files differindex 5341a3d6f0..a8c64a69fe 100644 --- a/platform/macos/docs/img/screenshot.jpg +++ b/platform/macos/docs/img/screenshot.jpg diff --git a/platform/macos/sdk/default_marker.pdf b/platform/macos/sdk/default_marker.pdf Binary files differindex 4e2e332301..d3e0e2ce12 100644 --- a/platform/macos/sdk/default_marker.pdf +++ b/platform/macos/sdk/default_marker.pdf diff --git a/platform/macos/src/MGLMapView.mm b/platform/macos/src/MGLMapView.mm index e0eb0c477c..70198c6432 100644 --- a/platform/macos/src/MGLMapView.mm +++ b/platform/macos/src/MGLMapView.mm @@ -1353,7 +1353,7 @@ public: // Move the cursor back to the start point and show it again, creating // the illusion that it has stayed in place during the entire gesture. CGPoint cursorPoint = [self convertPoint:startPoint toView:nil]; - cursorPoint = [self.window convertRectToScreen:{ startPoint, NSZeroSize }].origin; + cursorPoint = [self.window convertRectToScreen:{ cursorPoint, NSZeroSize }].origin; cursorPoint.y = self.window.screen.frame.size.height - cursorPoint.y; CGDisplayMoveCursorToPoint(kCGDirectMainDisplay, cursorPoint); CGDisplayShowCursor(kCGDirectMainDisplay); |