summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOsana Babayan <32496536+osana@users.noreply.github.com>2018-12-11 14:39:19 -0500
committerGitHub <noreply@github.com>2018-12-11 14:39:19 -0500
commitcff524f037dd24b9d32e5dbd01243b794b4fd29e (patch)
tree7e89c8bbb993c75a39f7cc710feeb683ef45fb17
parentf48f86b9531ee94b636237eb08bce02d0241f42c (diff)
parent3810e7b5b8dc7ab824268bb6b99d47b41284f92e (diff)
downloadqtlocation-mapboxgl-cff524f037dd24b9d32e5dbd01243b794b4fd29e.tar.gz
Merge branch 'osana-lat-lng-donotwrap' into tvn-dont-wrap-bounds
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/constants/GeometryConstants.java12
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/LatLng.java3
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/LatLngBounds.java315
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/LatLngSpan.java18
-rwxr-xr-xplatform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/NativeMapView.java74
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Projection.java19
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/geometry/LatLngBoundsTest.java456
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/BaseLayerTest.kt26
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/NativeMapViewTest.kt349
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/VisibleRegionTest.kt83
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/BackgroundLayerTest.java162
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/CircleLayerTest.java559
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/FillExtrusionLayerTest.java454
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/FillLayerTest.java431
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/HeatmapLayerTest.java276
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/HillshadeLayerTest.java280
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/LineLayerTest.java612
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/RasterLayerTest.java313
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/SymbolLayerTest.java1594
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/layer.junit.ejs194
-rwxr-xr-xplatform/android/src/native_map_view.cpp14
-rwxr-xr-xplatform/android/src/native_map_view.hpp4
-rw-r--r--platform/android/src/style/layers/layer_manager.cpp41
-rw-r--r--platform/android/src/style/layers/layer_manager.hpp18
24 files changed, 2907 insertions, 3400 deletions
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/constants/GeometryConstants.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/constants/GeometryConstants.java
index 0ca3b82a29..7e5c37d302 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/constants/GeometryConstants.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/constants/GeometryConstants.java
@@ -12,9 +12,19 @@ public class GeometryConstants {
public static final int RADIUS_EARTH_METERS = 6378137;
/**
+ * This constant represents the lowest longitude value available to represent a wrapped geolocation.
+ */
+ public static final double MIN_WRAP_LONGITUDE = -180;
+
+ /**
+ * This constant represents the highest longitude value available to represent a wrapped geolocation.
+ */
+ public static final double MAX_WRAP_LONGITUDE = 180;
+
+ /**
* This constant represents the lowest longitude value available to represent a geolocation.
*/
- public static final double MIN_LONGITUDE = -Double.MAX_VALUE;
+ public static final double MIN_LONGITUDE = Double.MAX_VALUE;
/**
* This constant represents the highest longitude value available to represent a geolocation.
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 dc1fbfe740..8ae388549e 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
@@ -208,7 +208,8 @@ public class LatLng implements Parcelable {
*/
@NonNull
public LatLng wrap() {
- return new LatLng(latitude, wrap(longitude, GeometryConstants.MIN_LONGITUDE, GeometryConstants.MAX_LONGITUDE));
+ return new LatLng(latitude, wrap(longitude,
+ GeometryConstants.MIN_WRAP_LONGITUDE, GeometryConstants.MAX_WRAP_LONGITUDE));
}
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 07c56b6da7..025703c3b3 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
@@ -12,6 +12,13 @@ import com.mapbox.mapboxsdk.exceptions.InvalidLatLngBoundsException;
import java.util.ArrayList;
import java.util.List;
+import static com.mapbox.mapboxsdk.constants.GeometryConstants.MAX_LATITUDE;
+import static com.mapbox.mapboxsdk.constants.GeometryConstants.MAX_LONGITUDE;
+import static com.mapbox.mapboxsdk.constants.GeometryConstants.MAX_WRAP_LONGITUDE;
+import static com.mapbox.mapboxsdk.constants.GeometryConstants.MIN_LATITUDE;
+import static com.mapbox.mapboxsdk.constants.GeometryConstants.MIN_LONGITUDE;
+import static com.mapbox.mapboxsdk.constants.GeometryConstants.MIN_WRAP_LONGITUDE;
+
/**
* A geographical area representing a latitude/longitude aligned rectangle.
* <p>
@@ -33,9 +40,12 @@ public class LatLngBounds implements Parcelable {
* Construct a new LatLngBounds based on its corners, given in NESW
* order.
* <p>
- * If eastern longitude is smaller than the western one, bounds will include antimeridian.
- * For example, if the NE point is (10, -170) and the SW point is (-10, 170), then bounds will span over 20 degrees
- * and cross the antimeridian.
+ * @since 7.0.0 LatLngBounds cannot be wrapped any more, i.e longitudeWest has to be
+ * less or equal to longitudeEast.
+ *
+ * For example, to represent bounds spanning 20 degrees crossing antimeridian with
+ * the NE point as (10, -170) and the SW point as (-10, 170),
+ * use (10, -190) and (-10, -170), or (10, -170) and (-10, -150).
*
* @param northLatitude Northern Latitude
* @param eastLongitude Eastern Longitude
@@ -43,8 +53,8 @@ public class LatLngBounds implements Parcelable {
* @param westLongitude Western Longitude
*/
@Keep
- LatLngBounds(final double northLatitude, final double eastLongitude, final double southLatitude,
- final double westLongitude) {
+ LatLngBounds(final double northLatitude, final double eastLongitude,
+ final double southLatitude, final double westLongitude) {
this.latitudeNorth = northLatitude;
this.longitudeEast = eastLongitude;
this.latitudeSouth = southLatitude;
@@ -58,8 +68,8 @@ public class LatLngBounds implements Parcelable {
*/
public static LatLngBounds world() {
return LatLngBounds.from(
- GeometryConstants.MAX_LATITUDE, GeometryConstants.MAX_LONGITUDE,
- GeometryConstants.MIN_LATITUDE, GeometryConstants.MIN_LONGITUDE);
+ MAX_LATITUDE, MAX_WRAP_LONGITUDE,
+ MIN_LATITUDE, MIN_WRAP_LONGITUDE);
}
/**
@@ -71,17 +81,7 @@ public class LatLngBounds implements Parcelable {
@NonNull
public LatLng getCenter() {
double latCenter = (this.latitudeNorth + this.latitudeSouth) / 2.0;
- double longCenter;
-
- if (this.longitudeEast >= this.longitudeWest) {
- longCenter = (this.longitudeEast + this.longitudeWest) / 2;
- } else {
- double halfSpan = (GeometryConstants.LONGITUDE_SPAN + this.longitudeEast - this.longitudeWest) / 2.0;
- longCenter = this.longitudeWest + halfSpan;
- if (longCenter >= GeometryConstants.MAX_LONGITUDE) {
- longCenter = this.longitudeEast - halfSpan;
- }
- }
+ double longCenter = (this.longitudeEast + this.longitudeWest) / 2.0;
return new LatLng(latCenter, longCenter);
}
@@ -189,23 +189,7 @@ public class LatLngBounds implements Parcelable {
* @return Span distance
*/
public double getLongitudeSpan() {
- double longSpan = Math.abs(this.longitudeEast - this.longitudeWest);
- if (this.longitudeEast >= this.longitudeWest) {
- return longSpan;
- }
-
- // shortest span contains antimeridian
- return GeometryConstants.LONGITUDE_SPAN - longSpan;
- }
-
- static double getLongitudeSpan(final double longEast, final double longWest) {
- double longSpan = Math.abs(longEast - longWest);
- if (longEast >= longWest) {
- return longSpan;
- }
-
- // shortest span contains antimeridian
- return GeometryConstants.LONGITUDE_SPAN - longSpan;
+ return Math.abs(this.longitudeEast - this.longitudeWest);
}
/**
@@ -226,7 +210,7 @@ public class LatLngBounds implements Parcelable {
@Override
public String toString() {
return "N:" + this.latitudeNorth + "; E:" + this.longitudeEast + "; S:" + this.latitudeSouth
- + "; W:" + this.longitudeWest;
+ + "; W:" + this.longitudeWest;
}
/**
@@ -237,45 +221,21 @@ public class LatLngBounds implements Parcelable {
* @return LatLngBounds
*/
static LatLngBounds fromLatLngs(final List<? extends LatLng> latLngs) {
- double minLat = GeometryConstants.MAX_LATITUDE;
- double maxLat = GeometryConstants.MIN_LATITUDE;
-
- double eastLon = latLngs.get(0).getLongitude();
- double westLon = latLngs.get(1).getLongitude();
- double lonSpan = Math.abs(eastLon - westLon);
- if (lonSpan < GeometryConstants.LONGITUDE_SPAN / 2) {
- if (eastLon < westLon) {
- double temp = eastLon;
- eastLon = westLon;
- westLon = temp;
- }
- } else {
- lonSpan = GeometryConstants.LONGITUDE_SPAN - lonSpan;
- if (westLon < eastLon) {
- double temp = eastLon;
- eastLon = westLon;
- westLon = temp;
- }
- }
+ double minLat = MAX_LATITUDE;
+ double minLon = MAX_LONGITUDE;
+ double maxLat = MIN_LATITUDE;
+ double maxLon = MIN_LONGITUDE;
for (final LatLng gp : latLngs) {
final double latitude = gp.getLatitude();
+ final double longitude = gp.getLongitude();
minLat = Math.min(minLat, latitude);
+ minLon = Math.min(minLon, longitude);
maxLat = Math.max(maxLat, latitude);
-
- final double longitude = gp.getLongitude();
- if (!containsLongitude(eastLon, westLon, longitude)) {
- final double eastSpan = getLongitudeSpan(longitude, westLon);
- final double westSpan = getLongitudeSpan(eastLon, longitude);
- if (eastSpan <= westSpan) {
- eastLon = longitude;
- } else {
- westLon = longitude;
- }
- }
+ maxLon = Math.max(maxLon, longitude);
}
- return new LatLngBounds(maxLat, eastLon, minLat, westLon);
+ return new LatLngBounds(maxLat, maxLon, minLat, minLon);
}
/**
@@ -297,24 +257,27 @@ public class LatLngBounds implements Parcelable {
* latNorth should be greater or equal latSouth, otherwise IllegalArgumentException will be thrown.
* <p>
* This method doesn't recalculate most east or most west boundaries.
+ * Note @since 7.0.0 lonEast and lonWest will NOT be wrapped to be in the range of [-180, 180],
* see {@link GeometryConstants#MIN_LONGITUDE} and {@link GeometryConstants#MAX_LONGITUDE}
+ * lonEast should be greater or equal lonWest, otherwise IllegalArgumentException will be thrown.
* </p>
*/
public static LatLngBounds from(
- @FloatRange(from = GeometryConstants.MIN_LATITUDE, to = GeometryConstants.MAX_LATITUDE) double latNorth,
- double lonEast,
- @FloatRange(from = GeometryConstants.MIN_LATITUDE, to = GeometryConstants.MAX_LATITUDE) double latSouth,
- double lonWest) {
+ @FloatRange(from = MIN_LATITUDE, to = MAX_LATITUDE) double latNorth,
+ double lonEast,
+ @FloatRange(from = MIN_LATITUDE, to = MAX_LATITUDE) double latSouth,
+ double lonWest) {
checkParams(latNorth, lonEast, latSouth, lonWest);
+
return new LatLngBounds(latNorth, lonEast, latSouth, lonWest);
}
private static void checkParams(
- @FloatRange(from = GeometryConstants.MIN_LATITUDE, to = GeometryConstants.MAX_LATITUDE) double latNorth,
- double lonEast,
- @FloatRange(from = GeometryConstants.MIN_LATITUDE, to = GeometryConstants.MAX_LATITUDE) double latSouth,
- double lonWest) {
+ @FloatRange(from = MIN_LATITUDE, to = MAX_LATITUDE) double latNorth,
+ double lonEast,
+ @FloatRange(from = MIN_LATITUDE, to = MAX_LATITUDE) double latSouth,
+ double lonWest) {
if (Double.isNaN(latNorth) || Double.isNaN(latSouth)) {
throw new IllegalArgumentException("latitude must not be NaN");
@@ -324,12 +287,8 @@ public class LatLngBounds implements Parcelable {
throw new IllegalArgumentException("longitude must not be NaN");
}
- if (Double.isInfinite(lonEast) || Double.isInfinite(lonWest)) {
- throw new IllegalArgumentException("longitude must not be infinite");
- }
-
- if (latNorth > GeometryConstants.MAX_LATITUDE || latNorth < GeometryConstants.MIN_LATITUDE
- || latSouth > GeometryConstants.MAX_LATITUDE || latSouth < GeometryConstants.MIN_LATITUDE) {
+ if (latNorth > MAX_LATITUDE || latNorth < MIN_LATITUDE
+ || latSouth > MAX_LATITUDE || latSouth < MIN_LATITUDE) {
throw new IllegalArgumentException("latitude must be between -90 and 90");
}
@@ -348,7 +307,7 @@ public class LatLngBounds implements Parcelable {
}
private static double lon_(int z, int x) {
- return x / Math.pow(2.0, z) * 360.0 - GeometryConstants.MAX_LONGITUDE;
+ return x / Math.pow(2.0, z) * 360.0 - GeometryConstants.MAX_WRAP_LONGITUDE;
}
/**
@@ -375,10 +334,10 @@ public class LatLngBounds implements Parcelable {
@NonNull
public LatLngBounds include(@NonNull LatLng latLng) {
return new LatLngBounds.Builder()
- .include(getNorthEast())
- .include(getSouthWest())
- .include(latLng)
- .build();
+ .include(getNorthEast())
+ .include(getSouthWest())
+ .include(latLng)
+ .build();
}
/**
@@ -395,9 +354,9 @@ public class LatLngBounds implements Parcelable {
if (o instanceof LatLngBounds) {
LatLngBounds other = (LatLngBounds) o;
return latitudeNorth == other.getLatNorth()
- && latitudeSouth == other.getLatSouth()
- && longitudeEast == other.getLonEast()
- && longitudeWest == other.getLonWest();
+ && latitudeSouth == other.getLatSouth()
+ && longitudeEast == other.getLonEast()
+ && longitudeWest == other.getLonWest();
}
return false;
}
@@ -405,19 +364,12 @@ public class LatLngBounds implements Parcelable {
private boolean containsLatitude(final double latitude) {
return (latitude <= this.latitudeNorth)
- && (latitude >= this.latitudeSouth);
+ && (latitude >= this.latitudeSouth);
}
private boolean containsLongitude(final double longitude) {
- return containsLongitude(this.longitudeEast, this.longitudeWest, longitude);
- }
-
- static boolean containsLongitude(final double eastLon, final double westLon, final double longitude) {
- if (eastLon >= westLon) {
- return (longitude <= eastLon)
- && (longitude >= westLon);
- }
- return (longitude <= eastLon) || (longitude >= westLon);
+ return (longitude <= this.longitudeEast)
+ && (longitude >= this.longitudeWest);
}
/**
@@ -450,21 +402,21 @@ public class LatLngBounds implements Parcelable {
*/
@NonNull
public LatLngBounds union(@NonNull LatLngBounds bounds) {
- return unionNoParamCheck(bounds.getLatNorth(), bounds.getLonEast(), bounds.getLatSouth(), bounds.getLonWest());
+ return unionNoParamCheck(bounds.getLatNorth(), bounds.getLonEast(),
+ bounds.getLatSouth(), bounds.getLonWest());
}
/**
- * Returns a new LatLngBounds that stretches to include another LatLngBounds,
- * given by corner points.
+ * Returns a new LatLngBounds that stretches to contain both this and another LatLngBounds.
+ *
* <p>
* This values of northLat and southLat should be in the range of [-90, 90],
* see {@link GeometryConstants#MIN_LATITUDE} and {@link GeometryConstants#MAX_LATITUDE},
* otherwise IllegalArgumentException will be thrown.
* northLat should be greater or equal southLat, otherwise IllegalArgumentException will be thrown.
+ *
* <p>
- * This method doesn't recalculate most east or most west boundaries.
- * Note that eastLon and westLon will be wrapped to be in the range of [-180, 180],
- * see {@link GeometryConstants#MIN_LONGITUDE} and {@link GeometryConstants#MAX_LONGITUDE}
+ * eastLon should be greater or equal westLon, otherwise IllegalArgumentException will be thrown.
*
* @param northLat Northern Latitude corner point
* @param eastLon Eastern Longitude corner point
@@ -473,72 +425,23 @@ public class LatLngBounds implements Parcelable {
* @return LatLngBounds
*/
@NonNull
- public LatLngBounds union(
- @FloatRange(from = GeometryConstants.MIN_LATITUDE, to = GeometryConstants.MAX_LATITUDE) double northLat,
- double eastLon,
- @FloatRange(from = GeometryConstants.MIN_LATITUDE, to = GeometryConstants.MAX_LATITUDE) double southLat,
- double westLon) {
+ public LatLngBounds union(final double northLat, final double eastLon,
+ final double southLat, final double westLon) {
checkParams(northLat, eastLon, southLat, westLon);
return unionNoParamCheck(northLat, eastLon, southLat, westLon);
}
- @NonNull
- private LatLngBounds unionNoParamCheck(
- @FloatRange(from = GeometryConstants.MIN_LATITUDE, to = GeometryConstants.MAX_LATITUDE) double northLat,
- double eastLon,
- @FloatRange(from = GeometryConstants.MIN_LATITUDE, to = GeometryConstants.MAX_LATITUDE) double southLat,
- double westLon) {
- northLat = (this.latitudeNorth < northLat) ? northLat : this.latitudeNorth;
- southLat = (this.latitudeSouth > southLat) ? southLat : this.latitudeSouth;
- eastLon = LatLng.wrap(eastLon, GeometryConstants.MIN_LONGITUDE, GeometryConstants.MAX_LONGITUDE);
- westLon = LatLng.wrap(westLon, GeometryConstants.MIN_LONGITUDE, GeometryConstants.MAX_LONGITUDE);
-
- // longitudes match
- if (this.longitudeEast == eastLon && this.longitudeWest == westLon) {
- return new LatLngBounds(northLat, eastLon, southLat, westLon);
- }
-
- boolean eastInThis = containsLongitude(this.longitudeEast, this.longitudeWest, eastLon);
- boolean westInThis = containsLongitude(this.longitudeEast, this.longitudeWest, westLon);
- boolean thisEastInside = containsLongitude(eastLon, westLon, this.longitudeEast);
- boolean thisWestInside = containsLongitude(eastLon, westLon, this.longitudeWest);
-
- // two intersections on each end - covers entire longitude
- if (eastInThis && westInThis && thisEastInside && thisWestInside) {
- return new LatLngBounds(northLat, GeometryConstants.MAX_LONGITUDE, southLat, GeometryConstants.MIN_LONGITUDE);
- }
+ private LatLngBounds unionNoParamCheck(final double northLat, final double eastLon,
+ final double southLat, final double westLon) {
- if (eastInThis) {
- if (westInThis) {
- return new LatLngBounds(northLat, this.longitudeEast, southLat, this.longitudeWest);
- }
- return new LatLngBounds(northLat, this.longitudeEast, southLat, westLon);
- }
-
- if (thisEastInside) {
- if (thisWestInside) {
- return new LatLngBounds(northLat, eastLon, southLat, westLon);
- }
- return new LatLngBounds(northLat, eastLon, southLat, this.longitudeWest);
- }
-
- // bounds do not intersect, find where they will form shortest union
- if (LatLngSpan.getLongitudeSpan(eastLon, this.longitudeWest)
- < LatLngSpan.getLongitudeSpan(this.longitudeEast, westLon)) {
- return new LatLngBounds(northLat,
- eastLon,
- southLat,
- this.longitudeWest);
- }
-
- return new LatLngBounds(northLat,
- this.longitudeEast,
- southLat,
- westLon);
+ return new LatLngBounds((this.latitudeNorth < northLat) ? northLat : this.latitudeNorth,
+ (this.longitudeEast < eastLon) ? eastLon : this.longitudeEast,
+ (this.latitudeSouth > southLat) ? southLat : this.latitudeSouth,
+ (this.longitudeWest > westLon) ? westLon : this.longitudeWest);
}
/**
- * Returns a new LatLngBounds that is the intersection of this with another box
+ * Returns a new LatLngBounds that is the intersection of this with another LatLngBounds,
*
* @param box LatLngBounds to intersect with
* @return LatLngBounds
@@ -548,17 +451,18 @@ public class LatLngBounds implements Parcelable {
return intersectNoParamCheck(box.getLatNorth(), box.getLonEast(), box.getLatSouth(), box.getLonWest());
}
+
/**
- * Returns a new LatLngBounds that is the intersection of this with another LatLngBounds
+ * Returns a new LatLngBounds that is the intersection of this with another box.
+ *
* <p>
* This values of northLat and southLat should be in the range of [-90, 90],
* see {@link GeometryConstants#MIN_LATITUDE} and {@link GeometryConstants#MAX_LATITUDE},
* otherwise IllegalArgumentException will be thrown.
* northLat should be greater or equal southLat, otherwise IllegalArgumentException will be thrown.
+ *
* <p>
- * This method doesn't recalculate most east or most west boundaries.
- * Note that eastLon and westLon will be wrapped to be in the range of [-180, 180],
- * see {@link GeometryConstants#MIN_LONGITUDE} and {@link GeometryConstants#MAX_LONGITUDE}
+ * eastLon should be greater or equal westLon, otherwise IllegalArgumentException will be thrown.
*
* @param northLat Northern Latitude corner point
* @param eastLon Eastern Longitude corner point
@@ -566,71 +470,30 @@ public class LatLngBounds implements Parcelable {
* @param westLon Western Longitude corner point
* @return LatLngBounds
*/
- @Nullable
- public LatLngBounds intersect(
- @FloatRange(from = GeometryConstants.MIN_LATITUDE, to = GeometryConstants.MAX_LATITUDE) double northLat,
- double eastLon,
- @FloatRange(from = GeometryConstants.MIN_LATITUDE, to = GeometryConstants.MAX_LATITUDE) double southLat,
- double westLon) {
-
+ @NonNull
+ public LatLngBounds intersect(final double northLat, final double eastLon,
+ final double southLat, final double westLon) {
checkParams(northLat, eastLon, southLat, westLon);
-
return intersectNoParamCheck(northLat, eastLon, southLat, westLon);
}
- @Nullable
- private LatLngBounds intersectNoParamCheck(
- @FloatRange(from = GeometryConstants.MIN_LATITUDE, to = GeometryConstants.MAX_LATITUDE) double northLat,
- double eastLon,
- @FloatRange(from = GeometryConstants.MIN_LATITUDE, to = GeometryConstants.MAX_LATITUDE) double southLat,
- double westLon) {
-
- double maxsouthLat = Math.max(getLatSouth(), Math.min(GeometryConstants.MAX_LATITUDE, southLat));
- double minnorthLat = Math.min(getLatNorth(), Math.max(GeometryConstants.MIN_LATITUDE, northLat));
- if (minnorthLat < maxsouthLat) {
- return null;
- }
-
- eastLon = LatLng.wrap(eastLon, GeometryConstants.MIN_LONGITUDE, GeometryConstants.MAX_LONGITUDE);
- westLon = LatLng.wrap(westLon, GeometryConstants.MIN_LONGITUDE, GeometryConstants.MAX_LONGITUDE);
-
- // longitudes match
- if (this.longitudeEast == eastLon && this.longitudeWest == westLon) {
- return new LatLngBounds(minnorthLat, eastLon, maxsouthLat, westLon);
- }
-
- boolean eastInThis = containsLongitude(this.longitudeEast, this.longitudeWest, eastLon);
- boolean westInThis = containsLongitude(this.longitudeEast, this.longitudeWest, westLon);
- boolean thisEastInside = containsLongitude(eastLon, westLon, this.longitudeEast);
- boolean thisWestInside = containsLongitude(eastLon, westLon, this.longitudeWest);
-
- // two intersections : find the one that has longest span
- if (eastInThis && westInThis && thisEastInside && thisWestInside) {
-
- if (getLongitudeSpan(eastLon, this.longitudeWest) > getLongitudeSpan(this.longitudeEast, westLon)) {
- return new LatLngBounds(minnorthLat, eastLon, maxsouthLat, this.longitudeWest);
- }
+ private LatLngBounds intersectNoParamCheck(final double northLat, final double eastLon,
+ final double southLat, final double westLon) {
- return new LatLngBounds(minnorthLat, this.longitudeEast, maxsouthLat, westLon);
- }
-
- if (eastInThis) {
- if (westInThis) {
- return new LatLngBounds(minnorthLat, eastLon, maxsouthLat, westLon);
- }
- return new LatLngBounds(minnorthLat, eastLon, maxsouthLat, this.longitudeWest);
- }
-
- if (thisEastInside) {
- if (thisWestInside) {
- return new LatLngBounds(minnorthLat, this.longitudeEast, maxsouthLat, this.longitudeWest);
+ double minLonWest = Math.max(this.longitudeWest, westLon);
+ double maxLonEast = Math.min(this.longitudeEast, eastLon);
+ if (maxLonEast >= minLonWest) {
+ double minLatSouth = Math.max(this.latitudeSouth, southLat);
+ double maxLatNorth = Math.min(this.latitudeNorth, northLat);
+ if (maxLatNorth >= minLatSouth) {
+ return new LatLngBounds(maxLatNorth, maxLonEast, minLatSouth, minLonWest);
}
- return new LatLngBounds(minnorthLat, this.longitudeEast, maxsouthLat, westLon);
}
-
return null;
}
+
+
/**
* Inner class responsible for recreating Parcels into objects.
*/
@@ -655,9 +518,9 @@ public class LatLngBounds implements Parcelable {
@Override
public int hashCode() {
return (int) ((latitudeNorth + 90)
- + ((latitudeSouth + 90) * 1000)
- + ((longitudeEast + 180) * 1000000)
- + ((longitudeWest + 180) * 1000000000));
+ + ((latitudeSouth + 90) * 1000)
+ + ((longitudeEast + 180) * 1000000)
+ + ((longitudeWest + 180) * 1000000000));
}
/**
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 f069d7807f..941e6652f9 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
@@ -4,8 +4,6 @@ import android.os.Parcel;
import android.os.Parcelable;
import android.support.annotation.NonNull;
-import com.mapbox.mapboxsdk.constants.GeometryConstants;
-
/**
* A geographical span defined by its latitude and longitude span.
*/
@@ -138,20 +136,4 @@ public class LatLngSpan implements Parcelable {
result = 31 * result + (int) (temp ^ (temp >>> 32));
return result;
}
-
- /**
- * Get the absolute distance, in degrees, between the west and
- * east boundaries of this LatLngBounds
- *
- * @return Span distance
- */
- static double getLongitudeSpan(double east, double west) {
- double longSpan = Math.abs(east - west);
- if (east > west) {
- return longSpan;
- }
-
- // shortest span contains antimeridian
- return GeometryConstants.LONGITUDE_SPAN - longSpan;
- }
}
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/NativeMapView.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/NativeMapView.java
index 8b6c4b7001..8c3ae6bf4f 100755
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/NativeMapView.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/NativeMapView.java
@@ -64,6 +64,7 @@ final class NativeMapView {
private ViewCallback viewCallback;
// Used for map change callbacks
+ @Nullable
private StateCallback stateCallback;
// Device density
@@ -310,6 +311,10 @@ final class NativeMapView {
return nativeGetPitch();
}
+ public void setPitch(double pitch) {
+ setPitch(pitch, 0);
+ }
+
public void setPitch(double pitch, long duration) {
if (checkState("setPitch")) {
return;
@@ -381,10 +386,11 @@ final class NativeMapView {
nativeRotateBy(sx / pixelRatio, sy / pixelRatio, ex, ey, duration);
}
- public void setContentPadding(int[] padding) {
+ public void setContentPadding(float[] padding) {
if (checkState("setContentPadding")) {
return;
}
+ // TopLeftBottomRight
nativeSetContentPadding(
padding[1] / pixelRatio,
padding[0] / pixelRatio,
@@ -392,6 +398,19 @@ final class NativeMapView {
padding[2] / pixelRatio);
}
+ public float[] getContentPadding() {
+ if (checkState("getContentPadding")) {
+ return new float[] {0, 0, 0, 0};
+ }
+ float[] topLeftBottomRight = nativeGetContentPadding();
+ return new float[]{
+ topLeftBottomRight[1] * pixelRatio,
+ topLeftBottomRight[0] * pixelRatio,
+ topLeftBottomRight[3] * pixelRatio,
+ topLeftBottomRight[2] * pixelRatio
+ };
+ }
+
public void setBearing(double degrees) {
if (checkState("setBearing")) {
return;
@@ -921,62 +940,86 @@ final class NativeMapView {
@Keep
private void onCameraWillChange(boolean animated) {
- stateCallback.onCameraWillChange(animated);
+ if (stateCallback != null) {
+ stateCallback.onCameraWillChange(animated);
+ }
}
@Keep
private void onCameraIsChanging() {
- stateCallback.onCameraIsChanging();
+ if (stateCallback != null) {
+ stateCallback.onCameraIsChanging();
+ }
}
@Keep
private void onCameraDidChange(boolean animated) {
- stateCallback.onCameraDidChange(animated);
+ if (stateCallback != null) {
+ stateCallback.onCameraDidChange(animated);
+ }
}
@Keep
private void onWillStartLoadingMap() {
- stateCallback.onWillStartLoadingMap();
+ if (stateCallback != null) {
+ stateCallback.onWillStartLoadingMap();
+ }
}
@Keep
private void onDidFinishLoadingMap() {
- stateCallback.onDidFinishLoadingMap();
+ if (stateCallback != null) {
+ stateCallback.onDidFinishLoadingMap();
+ }
}
@Keep
private void onDidFailLoadingMap(String error) {
- stateCallback.onDidFailLoadingMap(error);
+ if (stateCallback != null) {
+ stateCallback.onDidFailLoadingMap(error);
+ }
}
@Keep
private void onWillStartRenderingFrame() {
- stateCallback.onWillStartRenderingFrame();
+ if (stateCallback != null) {
+ stateCallback.onWillStartRenderingFrame();
+ }
}
@Keep
private void onDidFinishRenderingFrame(boolean fully) {
- stateCallback.onDidFinishRenderingFrame(fully);
+ if (stateCallback != null) {
+ stateCallback.onDidFinishRenderingFrame(fully);
+ }
}
@Keep
private void onWillStartRenderingMap() {
- stateCallback.onWillStartRenderingMap();
+ if (stateCallback != null) {
+ stateCallback.onWillStartRenderingMap();
+ }
}
@Keep
private void onDidFinishRenderingMap(boolean fully) {
- stateCallback.onDidFinishRenderingMap(fully);
+ if (stateCallback != null) {
+ stateCallback.onDidFinishRenderingMap(fully);
+ }
}
@Keep
private void onDidFinishLoadingStyle() {
- stateCallback.onDidFinishLoadingStyle();
+ if (stateCallback != null) {
+ stateCallback.onDidFinishLoadingStyle();
+ }
}
@Keep
private void onSourceChanged(String sourceId) {
- stateCallback.onSourceChanged(sourceId);
+ if (stateCallback != null) {
+ stateCallback.onSourceChanged(sourceId);
+ }
}
@Keep
@@ -1085,7 +1128,10 @@ final class NativeMapView {
private native void nativeRotateBy(double sx, double sy, double ex, double ey, long duration);
@Keep
- private native void nativeSetContentPadding(double top, double left, double bottom, double right);
+ private native void nativeSetContentPadding(float top, float left, float bottom, float right);
+
+ @Keep
+ private native float[] nativeGetContentPadding();
@Keep
private native void nativeSetBearing(double degrees, long duration);
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Projection.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Projection.java
index 8e3092ae1d..cbf5426012 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Projection.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Projection.java
@@ -3,7 +3,6 @@ package com.mapbox.mapboxsdk.maps;
import android.graphics.PointF;
import android.support.annotation.FloatRange;
import android.support.annotation.NonNull;
-
import com.mapbox.geojson.Point;
import com.mapbox.mapboxsdk.constants.GeometryConstants;
import com.mapbox.mapboxsdk.geometry.LatLng;
@@ -32,7 +31,11 @@ public class Projection {
void setContentPadding(int[] contentPadding) {
this.contentPadding = contentPadding;
- nativeMapView.setContentPadding(contentPadding);
+ float[] output = new float[contentPadding.length];
+ for (int i = 0; i < contentPadding.length; i++) {
+ output[i] = contentPadding[i];
+ }
+ nativeMapView.setContentPadding(output);
}
int[] getContentPadding() {
@@ -121,10 +124,10 @@ public class Projection {
top = 0;
bottom = nativeMapView.getHeight();
} else {
- left = contentPadding[0];
- right = nativeMapView.getWidth() - contentPadding[2];
- top = contentPadding[1];
- bottom = nativeMapView.getHeight() - contentPadding[3];
+ left = (float) contentPadding[0];
+ right = (float) (nativeMapView.getWidth() - contentPadding[2]);
+ top = (float) contentPadding[1];
+ bottom = (float) (nativeMapView.getHeight() - contentPadding[3]);
}
LatLng center = fromScreenLocation(new PointF(left + (right - left) / 2, top + (bottom - top) / 2));
@@ -173,6 +176,10 @@ public class Projection {
}
}
+ if (east < west) {
+ return new VisibleRegion(topLeft, topRight, bottomLeft, bottomRight,
+ LatLngBounds.from(north, east + GeometryConstants.LONGITUDE_SPAN, south, west));
+ }
return new VisibleRegion(topLeft, topRight, bottomLeft, bottomRight,
LatLngBounds.from(north, east, south, west));
}
diff --git a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/geometry/LatLngBoundsTest.java b/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/geometry/LatLngBoundsTest.java
index 8ba166e62d..80d274c20a 100644
--- a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/geometry/LatLngBoundsTest.java
+++ b/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/geometry/LatLngBoundsTest.java
@@ -30,9 +30,9 @@ public class LatLngBoundsTest {
@Before
public void beforeTest() {
latLngBounds = new LatLngBounds.Builder()
- .include(LAT_LNG_NULL_ISLAND)
- .include(LAT_LNG_NOT_NULL_ISLAND)
- .build();
+ .include(LAT_LNG_NULL_ISLAND)
+ .include(LAT_LNG_NOT_NULL_ISLAND)
+ .build();
}
@Test
@@ -71,41 +71,41 @@ public class LatLngBoundsTest {
@Test
public void dateLineSpanBuilder1() {
latLngBounds = new LatLngBounds.Builder()
- .include(new LatLng(10, -170))
- .include(new LatLng(-10, 170))
- .build();
+ .include(new LatLng(10, -170))
+ .include(new LatLng(-10, 170))
+ .build();
LatLngSpan latLngSpan = latLngBounds.getSpan();
- assertEquals("LatLngSpan should be shortest distance", new LatLngSpan(20, 20),
- latLngSpan);
+ assertEquals("LatLngSpan should be the same", new LatLngSpan(20, 340),
+ latLngSpan);
}
@Test
public void dateLineSpanBuilder2() {
latLngBounds = new LatLngBounds.Builder()
- .include(new LatLng(-10, -170))
- .include(new LatLng(10, 170))
- .build();
+ .include(new LatLng(-10, -170))
+ .include(new LatLng(10, 170))
+ .build();
LatLngSpan latLngSpan = latLngBounds.getSpan();
- assertEquals("LatLngSpan should be shortest distance", new LatLngSpan(20, 20),
- latLngSpan);
+ assertEquals("LatLngSpan should be the same", new LatLngSpan(20, 340),
+ latLngSpan);
}
@Test
public void dateLineSpanFrom1() {
- latLngBounds = LatLngBounds.from(10, -170, -10, 170);
+ latLngBounds = LatLngBounds.from(10, -170, -10, -190);
LatLngSpan latLngSpan = latLngBounds.getSpan();
- assertEquals("LatLngSpan should be shortest distance", new LatLngSpan(20, 20),
- latLngSpan);
+ assertEquals("LatLngSpan should be the same", new LatLngSpan(20, 20),
+ latLngSpan);
}
@Test
public void dateLineSpanFrom2() {
latLngBounds = LatLngBounds.from(10, 170, -10, -170);
LatLngSpan latLngSpan = latLngBounds.getSpan();
- assertEquals("LatLngSpan should be shortest distance", new LatLngSpan(20, 340),
- latLngSpan);
+ assertEquals("LatLngSpan should be the same", new LatLngSpan(20, 340),
+ latLngSpan);
}
@Test
@@ -113,33 +113,33 @@ public class LatLngBoundsTest {
latLngBounds = LatLngBounds.from(10, 10, -10, 10);
LatLngSpan latLngSpan = latLngBounds.getSpan();
assertEquals("LatLngSpan should be shortest distance", new LatLngSpan(20, 0),
- latLngSpan);
+ latLngSpan);
}
@Test
public void nearDateLineCenter1() {
- latLngBounds = LatLngBounds.from(10, -175, -10, 165);
+ latLngBounds = LatLngBounds.from(10, -175, -10, -195);
LatLng center = latLngBounds.getCenter();
- assertEquals("Center should match", new LatLng(0, 175), center);
+ assertEquals("Center should match", new LatLng(0, -185), center);
}
@Test
public void nearDateLineCenter2() {
- latLngBounds = LatLngBounds.from(10, -165, -10, 175);
+ latLngBounds = LatLngBounds.from(10, 195, -10, 175);
LatLng center = latLngBounds.getCenter();
- assertEquals("Center should match", new LatLng(0, -175), center);
+ assertEquals("Center should match", new LatLng(0, 185), center);
}
@Test
public void nearDateLineCenter3() {
- latLngBounds = LatLngBounds.from(10, -170, -10, 170);
+ latLngBounds = LatLngBounds.from(10, -170, -10, -190);
LatLng center = latLngBounds.getCenter();
assertEquals("Center should match", new LatLng(0, -180), center);
}
@Test
public void nearDateLineCenter4() {
- latLngBounds = LatLngBounds.from(10, -180, -10, 0);
+ latLngBounds = LatLngBounds.from(10, 180, -10, 0);
LatLng center = latLngBounds.getCenter();
assertEquals("Center should match", new LatLng(0, 90), center);
}
@@ -174,20 +174,20 @@ public class LatLngBoundsTest {
@Test
public void notEmptySpan() {
latLngBounds = new LatLngBounds.Builder()
- .include(LAT_LNG_NOT_NULL_ISLAND)
- .include(LAT_LNG_NULL_ISLAND)
- .build();
+ .include(LAT_LNG_NOT_NULL_ISLAND)
+ .include(LAT_LNG_NULL_ISLAND)
+ .build();
assertFalse("Should not be empty", latLngBounds.isEmptySpan());
}
@Test
public void includeSameLatLngs() {
latLngBounds = new LatLngBounds.Builder()
- .include(LAT_LNG_NOT_NULL_ISLAND)
- .include(LAT_LNG_NOT_NULL_ISLAND)
- .include(LAT_LNG_NULL_ISLAND)
- .include(LAT_LNG_NULL_ISLAND)
- .build();
+ .include(LAT_LNG_NOT_NULL_ISLAND)
+ .include(LAT_LNG_NOT_NULL_ISLAND)
+ .include(LAT_LNG_NULL_ISLAND)
+ .include(LAT_LNG_NULL_ISLAND)
+ .build();
assertEquals(latLngBounds.getNorthEast(), LAT_LNG_NOT_NULL_ISLAND);
assertEquals(latLngBounds.getSouthWest(), LAT_LNG_NULL_ISLAND);
}
@@ -195,13 +195,13 @@ public class LatLngBoundsTest {
@Test
public void toLatLngs() {
latLngBounds = new LatLngBounds.Builder()
- .include(LAT_LNG_NOT_NULL_ISLAND)
- .include(LAT_LNG_NULL_ISLAND)
- .build();
+ .include(LAT_LNG_NOT_NULL_ISLAND)
+ .include(LAT_LNG_NULL_ISLAND)
+ .build();
assertArrayEquals("LatLngs should match",
- new LatLng[] {LAT_LNG_NOT_NULL_ISLAND, LAT_LNG_NULL_ISLAND},
- latLngBounds.toLatLngs());
+ new LatLng[] {LAT_LNG_NOT_NULL_ISLAND, LAT_LNG_NULL_ISLAND},
+ latLngBounds.toLatLngs());
}
@Test
@@ -216,13 +216,13 @@ public class LatLngBoundsTest {
points.add(LAT_LNG_NOT_NULL_ISLAND);
LatLngBounds latLngBounds1 = new LatLngBounds.Builder()
- .includes(points)
- .build();
+ .includes(points)
+ .build();
LatLngBounds latLngBounds2 = new LatLngBounds.Builder()
- .include(LAT_LNG_NULL_ISLAND)
- .include(LAT_LNG_NOT_NULL_ISLAND)
- .build();
+ .include(LAT_LNG_NULL_ISLAND)
+ .include(LAT_LNG_NOT_NULL_ISLAND)
+ .build();
assertEquals("LatLngBounds should match", latLngBounds1, latLngBounds2);
}
@@ -230,20 +230,20 @@ public class LatLngBoundsTest {
@Test
public void includesOrderDoesNotMatter() {
LatLngBounds sameLongitudeFirst = new LatLngBounds.Builder()
- .include(new LatLng(50, 10)) // southWest
- .include(new LatLng(60, 10))
- .include(new LatLng(60, 20)) // northEast
- .include(new LatLng(50, 20))
- .include(new LatLng(50, 10)) // southWest again
- .build();
+ .include(new LatLng(50, 10)) // southWest
+ .include(new LatLng(60, 10))
+ .include(new LatLng(60, 20)) // northEast
+ .include(new LatLng(50, 20))
+ .include(new LatLng(50, 10)) // southWest again
+ .build();
LatLngBounds sameLatitudeFirst = new LatLngBounds.Builder()
- .include(new LatLng(50, 20))
- .include(new LatLng(50, 10)) // southWest
- .include(new LatLng(60, 10))
- .include(new LatLng(60, 20)) // northEast
- .include(new LatLng(50, 20))
- .build();
+ .include(new LatLng(50, 20))
+ .include(new LatLng(50, 10)) // southWest
+ .include(new LatLng(60, 10))
+ .include(new LatLng(60, 20)) // northEast
+ .include(new LatLng(50, 20))
+ .build();
assertEquals(sameLatitudeFirst, sameLongitudeFirst);
}
@@ -252,77 +252,80 @@ public class LatLngBoundsTest {
public void includesOverDateline1() {
LatLngBounds latLngBounds = new LatLngBounds.Builder()
- .include(new LatLng(10, -170))
- .include(new LatLng(-10, -175))
- .include(new LatLng(0, 170))
- .build();
+ .include(new LatLng(10, -170))
+ .include(new LatLng(-10, -175))
+ .include(new LatLng(0, -190))
+ .build();
assertEquals("LatLngSpan should be the same",
- new LatLngSpan(20, 20), latLngBounds.getSpan());
+ new LatLngSpan(20, 20), latLngBounds.getSpan());
}
@Test
public void includesOverDateline2() {
LatLngBounds latLngBounds = new LatLngBounds.Builder()
- .include(new LatLng(10, 170))
- .include(new LatLng(-10, 175))
- .include(new LatLng(0, -170))
- .build();
+ .include(new LatLng(10, 170))
+ .include(new LatLng(-10, 175))
+ .include(new LatLng(0, 190))
+ .build();
assertEquals("LatLngSpan should be the same",
- new LatLngSpan(20, 20), latLngBounds.getSpan());
+ new LatLngSpan(20, 20), latLngBounds.getSpan());
}
@Test
public void includesOverDateline3() {
LatLngBounds latLngBounds = new LatLngBounds.Builder()
- .include(new LatLng(10, 170))
- .include(new LatLng(-10, -170))
- .include(new LatLng(0, -180))
- .include(new LatLng(5, 180))
- .build();
+ .include(new LatLng(10, -190))
+ .include(new LatLng(-10, -170))
+ .include(new LatLng(0, -180))
+ .include(new LatLng(5, -180))
+ .build();
assertEquals("LatLngSpan should be the same",
- new LatLngSpan(20, 20), latLngBounds.getSpan());
+ new LatLngSpan(20, 20), latLngBounds.getSpan());
}
@Test
public void containsNot() {
- assertFalse("LatLng should not be included", latLngBounds.contains(new LatLng(3, 1)));
+ assertFalse("LatLng should not be included",
+ latLngBounds.contains(new LatLng(3, 1)));
}
@Test
public void containsBoundsInWorld() {
- assertTrue("LatLngBounds should be contained in the world", LatLngBounds.world().contains(latLngBounds));
+ assertTrue("LatLngBounds should be contained in the world",
+ LatLngBounds.world().contains(latLngBounds));
}
@Test
public void worldSpan() {
assertEquals("LatLngBounds world span should be 180, 360",
- GeometryConstants.LATITUDE_SPAN, LatLngBounds.world().getLatitudeSpan(), DELTA);
+ GeometryConstants.LATITUDE_SPAN, LatLngBounds.world().getLatitudeSpan(), DELTA);
assertEquals("LatLngBounds world span should be 180, 360",
- GeometryConstants.LONGITUDE_SPAN, LatLngBounds.world().getLongitudeSpan(), DELTA);
+ GeometryConstants.LONGITUDE_SPAN, LatLngBounds.world().getLongitudeSpan(), DELTA);
}
@Test
public void emptySpan() {
- LatLngBounds latLngBounds = LatLngBounds.from(GeometryConstants.MIN_LATITUDE, GeometryConstants.MAX_LONGITUDE,
- GeometryConstants.MIN_LATITUDE, GeometryConstants.MAX_LONGITUDE);
+ LatLngBounds latLngBounds = LatLngBounds.from(
+ GeometryConstants.MIN_LATITUDE, GeometryConstants.MAX_LONGITUDE,
+ GeometryConstants.MIN_LATITUDE, GeometryConstants.MAX_LONGITUDE);
assertTrue("LatLngBounds empty span", latLngBounds.isEmptySpan());
}
@Test
public void containsBounds() {
LatLngBounds inner = new LatLngBounds.Builder()
- .include(new LatLng(-5, -5))
- .include(new LatLng(5, 5))
- .build();
+ .include(new LatLng(-5, -5))
+ .include(new LatLng(5, 5))
+ .build();
LatLngBounds outer = new LatLngBounds.Builder()
- .include(new LatLng(-10, -10))
- .include(new LatLng(10, 10))
- .build();
+ .include(new LatLng(-10, -10))
+ .include(new LatLng(10, 10))
+ .build();
assertTrue(outer.contains(inner));
assertFalse(inner.contains(outer));
}
@@ -335,11 +338,12 @@ public class LatLngBoundsTest {
@Test
public void equality() {
LatLngBounds latLngBounds = new LatLngBounds.Builder()
- .include(LAT_LNG_NULL_ISLAND)
- .include(LAT_LNG_NOT_NULL_ISLAND)
- .build();
+ .include(LAT_LNG_NULL_ISLAND)
+ .include(LAT_LNG_NOT_NULL_ISLAND)
+ .build();
assertEquals("equality should match", this.latLngBounds, latLngBounds);
- assertEquals("not equal to a different object type", this.latLngBounds.equals(LAT_LNG_NOT_NULL_ISLAND), false);
+ assertEquals("not equal to a different object type",
+ this.latLngBounds.equals(LAT_LNG_NOT_NULL_ISLAND), false);
}
@Test
@@ -350,19 +354,22 @@ public class LatLngBoundsTest {
@Test
public void intersect() {
LatLngBounds latLngBounds = new LatLngBounds.Builder()
- .include(new LatLng(1, 1))
- .include(LAT_LNG_NULL_ISLAND)
- .build();
- assertEquals("intersect should match", latLngBounds, latLngBounds.intersect(this.latLngBounds.getLatNorth(),
- this.latLngBounds.getLonEast(), this.latLngBounds.getLatSouth(), this.latLngBounds.getLonWest()));
+ .include(new LatLng(1, 1))
+ .include(LAT_LNG_NULL_ISLAND)
+ .build();
+ assertEquals("intersect should match", latLngBounds,
+ latLngBounds.intersect(this.latLngBounds.getLatNorth(),
+ this.latLngBounds.getLonEast(),
+ this.latLngBounds.getLatSouth(),
+ this.latLngBounds.getLonWest()));
}
@Test
public void intersectNot() {
LatLngBounds latLngBounds = new LatLngBounds.Builder()
- .include(new LatLng(10, 10))
- .include(new LatLng(9, 8))
- .build();
+ .include(new LatLng(10, 10))
+ .include(new LatLng(9, 8))
+ .build();
assertNull(latLngBounds.intersect(this.latLngBounds));
}
@@ -371,8 +378,8 @@ public class LatLngBoundsTest {
exception.expect(IllegalArgumentException.class);
exception.expectMessage("latitude must be between -90 and 90");
LatLngBounds intersectLatLngBounds =
- LatLngBounds.from(10, 10, 0, 0)
- .intersect(200, 200, 0, 0);
+ LatLngBounds.from(10, 10, 0, 0)
+ .intersect(200, 200, 0, 0);
}
@Test
@@ -380,8 +387,8 @@ public class LatLngBoundsTest {
exception.expect(IllegalArgumentException.class);
exception.expectMessage("latitude must be between -90 and 90");
LatLngBounds intersectLatLngBounds =
- LatLngBounds.from(0, 0, -10, -10)
- .intersect(0, 0, -200, -200);
+ LatLngBounds.from(0, 0, -10, -10)
+ .intersect(0, 0, -200, -200);
}
@Test
@@ -389,8 +396,8 @@ public class LatLngBoundsTest {
exception.expect(IllegalArgumentException.class);
exception.expectMessage("latNorth cannot be less than latSouth");
LatLngBounds intersectLatLngBounds =
- LatLngBounds.from(10, 10, 0, 0)
- .intersect(0, 200, 20, 0);
+ LatLngBounds.from(10, 10, 0, 0)
+ .intersect(0, 200, 20, 0);
}
@Test
@@ -402,49 +409,71 @@ public class LatLngBoundsTest {
.intersect(0, 200, 20, 0);
}
+ public void intersectEastDoesNotWrapCheck() {
+
+ LatLngBounds latLngBounds1 = LatLngBounds.from(10, 210, 0, 0);
+ LatLngBounds latLngBounds2 = LatLngBounds.from(90, 200, 0, 0);
+
+ LatLngBounds intersectLatLngBounds = LatLngBounds.from(10, 200, 0, 0);
+
+ assertEquals(latLngBounds1.intersect(latLngBounds2), intersectLatLngBounds);
+ assertEquals(latLngBounds2.intersect(latLngBounds1), intersectLatLngBounds);
+ }
+
+ @Test
+ public void intersectDoesNotWestWrapCheck() {
+ LatLngBounds latLngBounds1 = LatLngBounds.from(0, 0, -10, -210);
+ LatLngBounds latLngBounds2 = LatLngBounds.from(0, 0, -90, -200);
+
+ LatLngBounds intersectLatLngBounds = LatLngBounds.from(0, 0, -10, -200);
+
+ assertEquals(latLngBounds1.intersect(latLngBounds2), intersectLatLngBounds);
+ assertEquals(latLngBounds2.intersect(latLngBounds1), intersectLatLngBounds);
+ }
+
@Test
public void innerUnion() {
LatLngBounds latLngBounds = new LatLngBounds.Builder()
- .include(new LatLng(1, 1))
- .include(LAT_LNG_NULL_ISLAND)
- .build();
+ .include(new LatLng(1, 1))
+ .include(LAT_LNG_NULL_ISLAND)
+ .build();
assertEquals("union should match", latLngBounds, latLngBounds.intersect(this.latLngBounds));
}
@Test
public void outerUnion() {
LatLngBounds latLngBounds = new LatLngBounds.Builder()
- .include(new LatLng(10, 10))
- .include(new LatLng(9, 8))
- .build();
+ .include(new LatLng(10, 10))
+ .include(new LatLng(9, 8))
+ .build();
assertEquals("outer union should match",
- latLngBounds.union(this.latLngBounds),
- new LatLngBounds.Builder()
- .include(new LatLng(10, 10))
- .include(LAT_LNG_NULL_ISLAND)
- .build());
+ latLngBounds.union(this.latLngBounds),
+ new LatLngBounds.Builder()
+ .include(new LatLng(10, 10))
+ .include(LAT_LNG_NULL_ISLAND)
+ .build());
}
@Test
public void unionOverDateLine() {
LatLngBounds latLngBounds1 = new LatLngBounds.Builder()
- .include(new LatLng(10, 170))
- .include(new LatLng(0, 160))
- .build();
+ .include(new LatLng(10, 170))
+ .include(new LatLng(0, 160))
+ .build();
LatLngBounds latLngBounds2 = new LatLngBounds.Builder()
- .include(new LatLng(0, -170))
- .include(new LatLng(-10, -160))
- .build();
+ .include(new LatLng(0, 190))
+ .include(new LatLng(-10, 200))
+ .build();
LatLngBounds union1 = latLngBounds1.union(latLngBounds2);
LatLngBounds union2 = latLngBounds2.union(latLngBounds1);
assertEquals(union1,
- new LatLngBounds.Builder()
- .include(new LatLng(10, 160))
- .include(new LatLng(-10, -160))
- .build());
+ new LatLngBounds.Builder()
+ .include(new LatLng(10, 160))
+ .include(new LatLng(-10, 200))
+ .build());
assertEquals(union1, union2);
}
@@ -452,23 +481,23 @@ public class LatLngBoundsTest {
@Test
public void unionOverDateLine2() {
LatLngBounds latLngBounds1 = new LatLngBounds.Builder()
- .include(new LatLng(10, 170))
- .include(new LatLng(0, 160))
- .build();
+ .include(new LatLng(10, 170))
+ .include(new LatLng(0, 160))
+ .build();
LatLngBounds latLngBounds2 = new LatLngBounds.Builder()
- .include(new LatLng(0, 165))
- .include(new LatLng(-10, -160))
- .build();
+ .include(new LatLng(0, 165))
+ .include(new LatLng(-10, 200))
+ .build();
LatLngBounds union1 = latLngBounds1.union(latLngBounds2);
LatLngBounds union2 = latLngBounds2.union(latLngBounds1);
assertEquals(union1,
- new LatLngBounds.Builder()
- .include(new LatLng(10, 160))
- .include(new LatLng(-10, -160))
- .build());
+ new LatLngBounds.Builder()
+ .include(new LatLng(10, 160))
+ .include(new LatLng(-10, 200))
+ .build());
assertEquals(union1, union2);
}
@@ -476,23 +505,23 @@ public class LatLngBoundsTest {
@Test
public void unionOverDateLine3() {
LatLngBounds latLngBounds1 = new LatLngBounds.Builder()
- .include(new LatLng(10, -165))
- .include(new LatLng(0, 160))
- .build();
+ .include(new LatLng(10, 195))
+ .include(new LatLng(0, 160))
+ .build();
LatLngBounds latLngBounds2 = new LatLngBounds.Builder()
- .include(new LatLng(0, -170))
- .include(new LatLng(-10, -160))
- .build();
+ .include(new LatLng(0, 190))
+ .include(new LatLng(-10, 200))
+ .build();
LatLngBounds union1 = latLngBounds1.union(latLngBounds2);
LatLngBounds union2 = latLngBounds2.union(latLngBounds1);
assertEquals(union1,
- new LatLngBounds.Builder()
- .include(new LatLng(10, 160))
- .include(new LatLng(-10, -160))
- .build());
+ new LatLngBounds.Builder()
+ .include(new LatLng(10, 160))
+ .include(new LatLng(-10, 200))
+ .build());
assertEquals(union1, union2);
}
@@ -500,23 +529,23 @@ public class LatLngBoundsTest {
@Test
public void unionOverDateLine4() {
LatLngBounds latLngBounds1 = new LatLngBounds.Builder()
- .include(new LatLng(10, -160))
- .include(new LatLng(0, 160))
- .build();
+ .include(new LatLng(10, -160))
+ .include(new LatLng(0, -200))
+ .build();
LatLngBounds latLngBounds2 = new LatLngBounds.Builder()
- .include(new LatLng(0, -170))
- .include(new LatLng(-10, -175))
- .build();
+ .include(new LatLng(0, -170))
+ .include(new LatLng(-10, -175))
+ .build();
LatLngBounds union1 = latLngBounds1.union(latLngBounds2);
LatLngBounds union2 = latLngBounds2.union(latLngBounds1);
assertEquals(union1,
- new LatLngBounds.Builder()
- .include(new LatLng(10, 160))
- .include(new LatLng(-10, -160))
- .build());
+ new LatLngBounds.Builder()
+ .include(new LatLng(10, -200))
+ .include(new LatLng(-10, -160))
+ .build());
assertEquals(union1, union2);
}
@@ -524,37 +553,37 @@ public class LatLngBoundsTest {
@Test
public void unionOverDateLine5() {
LatLngBounds latLngBounds1 = new LatLngBounds.Builder()
- .include(new LatLng(10, -160))
- .include(new LatLng(0, 160))
- .build();
+ .include(new LatLng(10, 200))
+ .include(new LatLng(0, 160))
+ .build();
LatLngBounds latLngBounds2 = new LatLngBounds.Builder()
- .include(new LatLng(0, 170))
- .include(new LatLng(-10, 175))
- .build();
+ .include(new LatLng(0, 170))
+ .include(new LatLng(-10, 175))
+ .build();
LatLngBounds union1 = latLngBounds1.union(latLngBounds2);
LatLngBounds union2 = latLngBounds2.union(latLngBounds1);
assertEquals(union1,
- new LatLngBounds.Builder()
- .include(new LatLng(10, 160))
- .include(new LatLng(-10, -160))
- .build());
+ new LatLngBounds.Builder()
+ .include(new LatLng(10, 160))
+ .include(new LatLng(-10, 200))
+ .build());
assertEquals(union1, union2);
}
@Test
- public void unionOverDateLineReturnWorldLonSpan() {
- LatLngBounds latLngBounds1 = LatLngBounds.from(10, -160, -10, -10);
- LatLngBounds latLngBounds2 = LatLngBounds.from(10, 10, -10, 160);
+ public void unionOverDateLineReturnLongerThanWorldLonSpan() {
+ LatLngBounds latLngBounds1 = LatLngBounds.from(10, 200, -10, -10);
+ LatLngBounds latLngBounds2 = LatLngBounds.from(10, 10, -10, -200);
LatLngBounds union1 = latLngBounds1.union(latLngBounds2);
LatLngBounds union2 = latLngBounds2.union(latLngBounds1);
assertEquals(union1, union2);
- assertEquals(union1, LatLngBounds.from(10, 180, -10, -180));
+ assertEquals(union1, LatLngBounds.from(10, 200, -10, -200));
}
@Test
@@ -562,8 +591,8 @@ public class LatLngBoundsTest {
exception.expect(IllegalArgumentException.class);
exception.expectMessage("latitude must be between -90 and 90");
LatLngBounds unionLatLngBounds =
- LatLngBounds.from(10, 10, 0, 0)
- .union(200, 200, 0, 0);
+ LatLngBounds.from(10, 10, 0, 0)
+ .union(200, 200, 0, 0);
}
@Test
@@ -571,8 +600,41 @@ public class LatLngBoundsTest {
exception.expect(IllegalArgumentException.class);
exception.expectMessage("latitude must be between -90 and 90");
LatLngBounds unionLatLngBounds =
- LatLngBounds.from(0, 0, -10, -10)
- .union(0, 0, -200, -200);
+ LatLngBounds.from(0, 0, -10, -10)
+ .union(0, 0, -200, -200);
+ }
+
+ @Test
+ public void unionSouthLessThanNorthCheck() {
+ exception.expect(IllegalArgumentException.class);
+ exception.expectMessage("latNorth cannot be less than latSouth");
+
+ LatLngBounds unionLatLngBounds =
+ LatLngBounds.from(10, 10, 0, 0)
+ .union(0, 200, 20, 0);
+ }
+
+
+ @Test
+ public void unionEastDoesNotWrapCheck() {
+
+ LatLngBounds latLngBounds1 = LatLngBounds.from(10, 10, 0, 0);
+ LatLngBounds latLngBounds2 = LatLngBounds.from(90, 200, 0, 0);
+ LatLngBounds unionLatLngBounds = LatLngBounds.from(90, 200, 0, 0);
+
+ assertEquals(latLngBounds1.union(latLngBounds2), unionLatLngBounds);
+ assertEquals(latLngBounds2.union(latLngBounds1), unionLatLngBounds);
+ }
+
+ @Test
+ public void unionWestDoesNotWrapCheck() {
+ LatLngBounds latLngBounds1 = LatLngBounds.from(0, 0, -10, -10);
+ LatLngBounds latLngBounds2 = LatLngBounds.from(0, 0, -90, -200);
+
+ LatLngBounds unionLatLngBounds = LatLngBounds.from(0, 0, -90, -200);
+
+ assertEquals(latLngBounds1.union(latLngBounds2), unionLatLngBounds);
+ assertEquals(latLngBounds2.union(latLngBounds1), unionLatLngBounds);
}
@Test
@@ -583,9 +645,9 @@ public class LatLngBoundsTest {
double maxLon = 21;
LatLngBounds latLngBounds = new LatLngBounds.Builder()
- .include(new LatLng(minLat, minLon))
- .include(new LatLng(maxLat, maxLon))
- .build();
+ .include(new LatLng(minLat, minLon))
+ .include(new LatLng(maxLat, maxLon))
+ .build();
assertEquals("NorthWest should match", latLngBounds.getNorthWest(), new LatLng(maxLat, minLon));
}
@@ -598,9 +660,9 @@ public class LatLngBoundsTest {
double maxLon = 21;
LatLngBounds latLngBounds = new LatLngBounds.Builder()
- .include(new LatLng(minLat, minLon))
- .include(new LatLng(maxLat, maxLon))
- .build();
+ .include(new LatLng(minLat, minLon))
+ .include(new LatLng(maxLat, maxLon))
+ .build();
assertEquals("SouthWest should match", latLngBounds.getSouthWest(), new LatLng(minLat, minLon));
}
@@ -613,9 +675,9 @@ public class LatLngBoundsTest {
double maxLon = 21;
LatLngBounds latLngBounds = new LatLngBounds.Builder()
- .include(new LatLng(minLat, minLon))
- .include(new LatLng(maxLat, maxLon))
- .build();
+ .include(new LatLng(minLat, minLon))
+ .include(new LatLng(maxLat, maxLon))
+ .build();
assertEquals("NorthEast should match", latLngBounds.getNorthEast(), new LatLng(maxLat, maxLon));
}
@@ -628,9 +690,9 @@ public class LatLngBoundsTest {
double maxLon = 21;
LatLngBounds latLngBounds = new LatLngBounds.Builder()
- .include(new LatLng(minLat, minLon))
- .include(new LatLng(maxLat, maxLon))
- .build();
+ .include(new LatLng(minLat, minLon))
+ .include(new LatLng(maxLat, maxLon))
+ .build();
assertEquals("SouthEast should match", latLngBounds.getSouthEast(), new LatLng(minLat, maxLon));
}
@@ -638,9 +700,9 @@ public class LatLngBoundsTest {
@Test
public void testParcelable() {
LatLngBounds latLngBounds = new LatLngBounds.Builder()
- .include(new LatLng(10, 10))
- .include(new LatLng(9, 8))
- .build();
+ .include(new LatLng(10, 10))
+ .include(new LatLng(9, 8))
+ .build();
Parcelable parcel = MockParcel.obtain(latLngBounds);
assertEquals("Parcel should match original object", parcel, latLngBounds);
}
@@ -648,9 +710,9 @@ public class LatLngBoundsTest {
@Test
public void fromTileID() {
LatLngBounds bounds = LatLngBounds.from(0, 0, 0);
- assertEquals(GeometryConstants.MIN_LONGITUDE, bounds.getLonWest(), DELTA);
+ assertEquals(GeometryConstants.MIN_WRAP_LONGITUDE, bounds.getLonWest(), DELTA);
assertEquals(GeometryConstants.MIN_MERCATOR_LATITUDE, bounds.getLatSouth(), DELTA);
- assertEquals(GeometryConstants.MAX_LONGITUDE, bounds.getLonEast(), DELTA);
+ assertEquals(GeometryConstants.MAX_WRAP_LONGITUDE, bounds.getLonEast(), DELTA);
assertEquals(GeometryConstants.MAX_MERCATOR_LATITUDE, bounds.getLatNorth(), DELTA);
bounds = LatLngBounds.from(10, 288, 385);
@@ -693,10 +755,10 @@ public class LatLngBoundsTest {
}
@Test
- public void testConstructorChecksEastLongitudeInfinity() {
- exception.expect(IllegalArgumentException.class);
- exception.expectMessage("longitude must not be infinite");
- LatLngBounds.from(0, Double.POSITIVE_INFINITY, -20, -20);
+ public void testConstructorEastLongitudeInfinityAllowed() {
+ LatLngBounds latLngBounds =
+ LatLngBounds.from(0, Double.POSITIVE_INFINITY, -20, -20);
+ assertEquals(Double.POSITIVE_INFINITY, latLngBounds.getLonEast(), DELTA);
}
@Test
@@ -728,10 +790,10 @@ public class LatLngBoundsTest {
}
@Test
- public void testConstructorChecksWestLongitudeInfinity() {
- exception.expect(IllegalArgumentException.class);
- exception.expectMessage("longitude must not be infinite");
- LatLngBounds.from(20, 20, 0, Double.POSITIVE_INFINITY);
+ public void testConstructorWestLongitudeInfinityAllowed() {
+ LatLngBounds latLngBounds =
+ LatLngBounds.from(20, 20, 0, Double.NEGATIVE_INFINITY);
+ assertEquals(Double.NEGATIVE_INFINITY, latLngBounds.getLonWest(), DELTA);
}
@Test
@@ -742,9 +804,9 @@ public class LatLngBoundsTest {
}
@Test
- public void testConstructorCheckLonEastGreaterLonWest() {
+ public void testConstructorCheckLonWestGreaterLonEast() {
exception.expect(IllegalArgumentException.class);
exception.expectMessage("lonEast cannot be less than lonWest");
- LatLngBounds.from(30, 20, 20, 30);
+ LatLngBounds.from(20, 0, 0, 20);
}
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/BaseLayerTest.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/BaseLayerTest.kt
new file mode 100644
index 0000000000..4b3b97b481
--- /dev/null
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/BaseLayerTest.kt
@@ -0,0 +1,26 @@
+package com.mapbox.mapboxsdk.maps
+
+import android.support.test.InstrumentationRegistry
+import android.support.test.runner.AndroidJUnit4
+import com.mapbox.mapboxsdk.style.layers.Layer
+import org.junit.runner.RunWith
+
+@RunWith(AndroidJUnit4::class)
+abstract class BaseLayerTest {
+ private lateinit var nativeMapView: NativeMapView
+
+ companion object {
+ const val WIDTH = 500
+ const val HEIGHT = WIDTH
+ }
+
+ fun before() {
+ val context = InstrumentationRegistry.getContext()
+ nativeMapView = NativeMapView(context, false, null, null, NativeMapViewTest.DummyRenderer(context))
+ nativeMapView.resizeView(WIDTH, HEIGHT)
+ }
+
+ fun setupLayer(layer: Layer) {
+ nativeMapView.addLayer(layer)
+ }
+} \ No newline at end of file
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/NativeMapViewTest.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/NativeMapViewTest.kt
new file mode 100644
index 0000000000..c48b99964f
--- /dev/null
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/NativeMapViewTest.kt
@@ -0,0 +1,349 @@
+package com.mapbox.mapboxsdk.maps
+
+import android.content.Context
+import android.graphics.PointF
+import android.support.test.InstrumentationRegistry
+import android.support.test.annotation.UiThreadTest
+import android.support.test.runner.AndroidJUnit4
+import com.mapbox.mapboxsdk.camera.CameraPosition
+import com.mapbox.mapboxsdk.geometry.LatLng
+import com.mapbox.mapboxsdk.geometry.LatLngBounds
+import com.mapbox.mapboxsdk.geometry.ProjectedMeters
+import com.mapbox.mapboxsdk.maps.renderer.MapRenderer
+import com.mapbox.mapboxsdk.testapp.utils.TestConstants
+import junit.framework.Assert.assertEquals
+import org.junit.Before
+import org.junit.Test
+import org.junit.runner.RunWith
+
+@RunWith(AndroidJUnit4::class)
+class NativeMapViewTest {
+
+ private lateinit var nativeMapView: NativeMapView
+
+ companion object {
+ const val DELTA = 0.000001
+ const val DELTA_BIG = 1.0
+ const val BEARING_TEST = 60.0
+ const val PITCH_TEST = 40.0
+ const val ZOOM_TEST = 16.0
+ const val WIDTH = 500
+ const val HEIGHT = WIDTH
+ val LATLNG_TEST = LatLng(12.0, 34.0)
+ }
+
+ @Before
+ @UiThreadTest
+ fun before() {
+ val context = InstrumentationRegistry.getContext()
+ nativeMapView = NativeMapView(context, 2.0f, false, null, null, DummyRenderer(context))
+ nativeMapView.resizeView(WIDTH, HEIGHT)
+ }
+
+ @Test
+ @UiThreadTest
+ fun testBearing() {
+ val expected = BEARING_TEST
+ nativeMapView.bearing = expected
+ val actual = nativeMapView.bearing
+ assertEquals("Bearing should match", expected, actual, DELTA)
+ }
+
+ @Test
+ @UiThreadTest
+ fun testLatLng() {
+ val expected = LATLNG_TEST
+ nativeMapView.latLng = expected
+ val actual = nativeMapView.latLng
+ assertEquals("Latitude should match", expected.latitude, actual.latitude, DELTA)
+ assertEquals("Longitude should match", expected.longitude, actual.longitude, DELTA)
+ }
+
+ @Test
+ @UiThreadTest
+ fun testLatLngDefault() {
+ val expected = LatLng()
+ val actual = nativeMapView.latLng
+ assertEquals("Latitude should match", expected.latitude, actual.latitude, DELTA)
+ assertEquals("Longitude should match", expected.longitude, actual.longitude, DELTA)
+ }
+
+
+ @Test
+ @UiThreadTest
+ fun testBearingDefault() {
+ val expected = 0.0
+ val actual = nativeMapView.bearing
+ assertEquals("Bearing should match", expected, actual, DELTA)
+ }
+
+ @Test
+ @UiThreadTest
+ fun testPitch() {
+ val expected = PITCH_TEST
+ nativeMapView.pitch = expected
+ val actual = nativeMapView.pitch
+ assertEquals("Pitch should match", expected, actual, DELTA)
+ }
+
+ @Test
+ @UiThreadTest
+ fun testPitchDefault() {
+ val expected = 0.0
+ val actual = nativeMapView.pitch
+ assertEquals("Pitch should match", expected, actual, DELTA)
+ }
+
+ @Test
+ @UiThreadTest
+ fun testZoom() {
+ val expected = ZOOM_TEST
+ nativeMapView.setZoom(expected, PointF(0.0f, 0.0f), 0)
+ val actual = nativeMapView.zoom
+ assertEquals("Zoom should match", expected, actual, DELTA)
+ }
+
+ @Test
+ @UiThreadTest
+ fun testZoomDefault() {
+ val expected = 0.0
+ val actual = nativeMapView.zoom
+ assertEquals("Zoom should match", expected, actual, DELTA)
+ }
+
+ @Test
+ @UiThreadTest
+ fun testJumpTo() {
+ val expected = CameraPosition.Builder()
+ .bearing(BEARING_TEST)
+ .target(LATLNG_TEST)
+ .tilt(PITCH_TEST)
+ .zoom(ZOOM_TEST)
+ .build()
+ nativeMapView.jumpTo(BEARING_TEST, LATLNG_TEST, PITCH_TEST, ZOOM_TEST)
+ val actual = nativeMapView.cameraPosition
+ assertEquals("Latitude should match", expected.target.latitude, actual.target.latitude, DELTA)
+ assertEquals("Longitude should match", expected.target.longitude, actual.target.longitude, DELTA)
+ assertEquals("Bearing should match", expected.bearing, actual.bearing, DELTA)
+ assertEquals("Pitch should match", expected.tilt, actual.tilt, DELTA)
+ assertEquals("Zoom should match", expected.zoom, actual.zoom, DELTA)
+ }
+
+ @Test
+ @UiThreadTest
+ fun testLatLngForPixel() {
+ val expected = LATLNG_TEST
+ nativeMapView.latLng = LATLNG_TEST
+ val actual = nativeMapView.latLngForPixel(
+ PointF((WIDTH / 2).toFloat(), (HEIGHT / 2).toFloat())
+ )
+ assertEquals("Latitude should match", expected.latitude, actual.latitude, DELTA_BIG)
+ assertEquals("Longitude should match", expected.longitude, actual.longitude, DELTA_BIG)
+ }
+
+ @Test
+ @UiThreadTest
+ fun testPixelForLatLng() {
+ val expected = PointF((WIDTH / 2).toFloat(), (HEIGHT / 2).toFloat())
+ nativeMapView.latLng = LATLNG_TEST
+ val actual = nativeMapView.pixelForLatLng(LATLNG_TEST)
+ assertEquals("X should match", expected.x.toDouble(), actual.x.toDouble(), DELTA_BIG)
+ assertEquals("Y should match", expected.y.toDouble(), actual.y.toDouble(), DELTA_BIG)
+ }
+
+ @Test
+ @UiThreadTest
+ fun testPrefetchTilesTrue() {
+ val expected = true
+ nativeMapView.prefetchesTiles = true
+ val actual = nativeMapView.prefetchesTiles
+ assertEquals("Flag should match", expected, actual)
+ }
+
+ @Test
+ @UiThreadTest
+ fun testPrefetchTilesFalse() {
+ val expected = false
+ nativeMapView.prefetchesTiles = false
+ val actual = nativeMapView.prefetchesTiles
+ assertEquals("Flag should match", expected, actual)
+ }
+
+ @Test
+ @UiThreadTest
+ fun testPrefetchTilesDefault() {
+ val expected = true
+ val actual = nativeMapView.prefetchesTiles
+ assertEquals("Flag should match", expected, actual)
+ }
+
+ @Test
+ @UiThreadTest
+ fun testSetStyleUrl() {
+ val expected = Style.DARK
+ nativeMapView.styleUrl = expected
+ val actual = nativeMapView.styleUrl
+ assertEquals("Style URL should match", expected, actual)
+ }
+
+ @Test
+ @UiThreadTest
+ fun testSetStyleJson() {
+ val expected = "{}"
+ nativeMapView.styleJson = expected
+ val actual = nativeMapView.styleJson
+ assertEquals("Style JSON should match", expected, actual)
+ }
+
+ @Test
+ @UiThreadTest
+ fun testSetContentPadding() {
+ val expected = floatArrayOf(1.0f, 2.0f, 3.0f, 4.0f)
+ nativeMapView.contentPadding = expected
+ val actual = nativeMapView.contentPadding
+ assertEquals("Left should match", expected[0], actual[0])
+ assertEquals("Top should match", expected[1], actual[1])
+ assertEquals("Right should match", expected[2], actual[2])
+ assertEquals("Bottom should match", expected[3], actual[3])
+ }
+
+ @Test
+ @UiThreadTest
+ fun testSetMinZoom() {
+ val expected = 12.0
+ nativeMapView.minZoom = expected
+ val actual = nativeMapView.minZoom
+ assertEquals("Min zoom should match", expected, actual)
+ }
+
+ @Test
+ @UiThreadTest
+ fun testSetMaxZoom() {
+ val expected = 12.0
+ nativeMapView.maxZoom = expected
+ val actual = nativeMapView.maxZoom
+ assertEquals("Max zoom should match", expected, actual)
+ }
+
+ @Test
+ @UiThreadTest
+ fun testGetProjectedMetersAtLatitude() {
+ val expected = 38986.83510557766
+ val actual = nativeMapView.getMetersPerPixelAtLatitude(5.0)
+ assertEquals("Get projected meters should match", expected, actual)
+ }
+
+ @Test
+ @UiThreadTest
+ fun testLatLngForProjectedMeters() {
+ val expected = LatLng(0.01796630538796444, 0.02694945852363162)
+ val actual = nativeMapView.latLngForProjectedMeters(ProjectedMeters(2000.0, 3000.0))
+ assertEquals("Get LatLng for projected meters", expected, actual)
+ }
+
+ @Test
+ @UiThreadTest
+ fun testFlyTo() {
+ val expected = CameraPosition.Builder()
+ .zoom(12.0)
+ .tilt(30.0)
+ .target(LatLng(12.0, 14.0))
+ .bearing(20.0)
+ .build()
+ nativeMapView.flyTo(expected.bearing, expected.target, 0, expected.tilt, expected.zoom)
+ val actual = nativeMapView.cameraPosition
+ assertEquals("Bearing should match", expected.bearing, actual.bearing, TestConstants.BEARING_DELTA)
+ assertEquals("Latitude should match", expected.target.latitude, actual.target.latitude, TestConstants.LAT_LNG_DELTA)
+ assertEquals("Longitude should match", expected.target.longitude, actual.target.longitude, TestConstants.LAT_LNG_DELTA)
+ assertEquals("Tilt should match", expected.tilt, actual.tilt, TestConstants.TILT_DELTA)
+ assertEquals("Zoom should match", expected.zoom, actual.zoom, TestConstants.ZOOM_DELTA)
+ }
+
+ @Test
+ @UiThreadTest
+ fun testEaseTo() {
+ val expected = CameraPosition.Builder()
+ .zoom(12.0)
+ .tilt(30.0)
+ .target(LatLng(12.0, 14.0))
+ .bearing(20.0)
+ .build()
+ nativeMapView.easeTo(expected.bearing, expected.target, 0, expected.tilt, expected.zoom, false)
+ val actual = nativeMapView.cameraPosition
+ assertEquals("Bearing should match", expected.bearing, actual.bearing, TestConstants.BEARING_DELTA)
+ assertEquals("Latitude should match", expected.target.latitude, actual.target.latitude, TestConstants.LAT_LNG_DELTA)
+ assertEquals("Longitude should match", expected.target.longitude, actual.target.longitude, TestConstants.LAT_LNG_DELTA)
+ assertEquals("Tilt should match", expected.tilt, actual.tilt, TestConstants.TILT_DELTA)
+ assertEquals("Zoom should match", expected.zoom, actual.zoom, TestConstants.ZOOM_DELTA)
+ }
+
+ @Test
+ @UiThreadTest
+ fun testResetPosition() {
+ val expected = CameraPosition.Builder()
+ .zoom(0.0)
+ .tilt(0.0)
+ .target(LatLng(0.0, 0.0))
+ .bearing(0.0)
+ .build()
+ nativeMapView.jumpTo(1.0, LatLng(1.0, 2.0), 23.0, 12.0)
+ nativeMapView.resetPosition()
+ val actual = nativeMapView.cameraPosition
+ assertEquals("Bearing should match", expected.bearing, actual.bearing, TestConstants.BEARING_DELTA)
+ assertEquals("Latitude should match", expected.target.latitude, actual.target.latitude, TestConstants.LAT_LNG_DELTA)
+ assertEquals("Longitude should match", expected.target.longitude, actual.target.longitude, TestConstants.LAT_LNG_DELTA)
+ assertEquals("Tilt should match", expected.tilt, actual.tilt, TestConstants.TILT_DELTA)
+ assertEquals("Zoom should match", expected.zoom, actual.zoom, TestConstants.ZOOM_DELTA)
+ }
+
+ @Test
+ @UiThreadTest
+ fun testGetCameraForLatLngBounds() {
+ val expected = CameraPosition.Builder()
+ .zoom(3.5258764777024005)
+ .tilt(0.0)
+ .target(LatLng(23.182767623652808, 13.999999999994088))
+ .bearing(0.0)
+ .build()
+ val actual = nativeMapView.getCameraForLatLngBounds(
+ LatLngBounds.from(30.0, 12.0, 16.0, 16.0),
+ intArrayOf(0, 0, 0, 0),
+ 0.0,
+ 0.0
+ )
+ assertEquals("Bearing should match", expected.bearing, actual.bearing, TestConstants.BEARING_DELTA)
+ assertEquals("Latitude should match", expected.target.latitude, actual.target.latitude, TestConstants.LAT_LNG_DELTA)
+ assertEquals("Longitude should match", expected.target.longitude, actual.target.longitude, TestConstants.LAT_LNG_DELTA)
+ assertEquals("Tilt should match", expected.tilt, actual.tilt, TestConstants.TILT_DELTA)
+ assertEquals("Zoom should match", expected.zoom, actual.zoom, TestConstants.ZOOM_DELTA)
+ }
+
+ @Test
+ @UiThreadTest
+ fun testMoveBy() {
+ val expected = CameraPosition.Builder()
+ .zoom(0.0)
+ .tilt(0.0)
+ .target(LatLng(4.21494310024160, -4.218749958739409))
+ .bearing(0.0)
+ .build()
+ nativeMapView.moveBy(12.0, 12.0)
+ val actual = nativeMapView.cameraPosition
+ assertEquals("Bearing should match", expected.bearing, actual.bearing, TestConstants.BEARING_DELTA)
+ assertEquals("Latitude should match", expected.target.latitude, actual.target.latitude, TestConstants.LAT_LNG_DELTA)
+ assertEquals("Longitude should match", expected.target.longitude, actual.target.longitude, TestConstants.LAT_LNG_DELTA)
+ assertEquals("Tilt should match", expected.tilt, actual.tilt, TestConstants.TILT_DELTA)
+ assertEquals("Zoom should match", expected.zoom, actual.zoom, TestConstants.ZOOM_DELTA)
+ }
+
+ class DummyRenderer(context: Context) : MapRenderer(context, null) {
+
+ override fun requestRender() {
+ //no-op
+ }
+
+ override fun queueEvent(runnable: Runnable?) {
+ //no-op
+ }
+ }
+} \ No newline at end of file
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/VisibleRegionTest.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/VisibleRegionTest.kt
index f0d62dd370..72ff293c3e 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/VisibleRegionTest.kt
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/VisibleRegionTest.kt
@@ -2,8 +2,6 @@ package com.mapbox.mapboxsdk.testapp.maps
import android.graphics.PointF
import android.support.test.espresso.UiController
-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.MapView
@@ -67,10 +65,10 @@ class VisibleRegionTest : BaseActivityTest() {
)
mapboxMap.setPadding(
- (mapView.width / 4f).toInt(),
- (mapView.height / 4f).toInt(),
- (mapView.width / 4f).toInt(),
- (mapView.height / 4f).toInt())
+ mapView.width / 4,
+ mapView.height / 4,
+ mapView.width / 4,
+ mapView.height / 4)
val visibleRegion = mapboxMap.projection.getVisibleRegion(false)
val filtered = latLngs.filter { visibleRegion.latLngBounds.contains(it) }
@@ -96,7 +94,7 @@ class VisibleRegionTest : BaseActivityTest() {
mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height / 2f)
)
- mapboxMap.setPadding((mapView.width / 4f).toInt(), 0, 0, 0)
+ mapboxMap.setPadding(mapView.width / 4, 0, 0, 0)
val visibleRegion = mapboxMap.projection.getVisibleRegion(false)
val filtered = latLngs.filter { visibleRegion.latLngBounds.contains(it) }
@@ -122,7 +120,7 @@ class VisibleRegionTest : BaseActivityTest() {
mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height / 2f)
)
- mapboxMap.setPadding(0, (mapView.height / 4f).toInt(), 0, 0)
+ mapboxMap.setPadding(0, mapView.height / 4, 0, 0)
val visibleRegion = mapboxMap.projection.getVisibleRegion(false)
val filtered = latLngs.filter { visibleRegion.latLngBounds.contains(it) }
@@ -148,7 +146,7 @@ class VisibleRegionTest : BaseActivityTest() {
mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height / 2f)
)
- mapboxMap.setPadding(0, 0, (mapView.width / 4f).toInt(), 0)
+ mapboxMap.setPadding(0, 0, mapView.width / 4, 0)
val visibleRegion = mapboxMap.projection.getVisibleRegion(false)
val filtered = latLngs.filter { visibleRegion.latLngBounds.contains(it) }
@@ -174,7 +172,7 @@ class VisibleRegionTest : BaseActivityTest() {
mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height / 2f)
)
- mapboxMap.setPadding(0, 0, 0, (mapView.height / 4f).toInt())
+ mapboxMap.setPadding(0, 0, 0, mapView.height / 4)
val visibleRegion = mapboxMap.projection.getVisibleRegion(false)
val filtered = latLngs.filter { visibleRegion.latLngBounds.contains(it) }
@@ -191,9 +189,12 @@ class VisibleRegionTest : BaseActivityTest() {
val latLngs = listOf(
mapboxMap.getLatLngFromScreenCoords(0f, 0f),
mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f, 0f),
- mapboxMap.getLatLngFromScreenCoords(mapView.width.toFloat(), 0f),
- mapboxMap.getLatLngFromScreenCoords(mapView.width.toFloat(), mapView.height / 2f),
- mapboxMap.getLatLngFromScreenCoords(mapView.width.toFloat(), mapView.height.toFloat()),
+ mapboxMap.getLatLngFromScreenCoords(mapView.width.toFloat(), 0f)
+ .also { it.longitude += 360 },
+ mapboxMap.getLatLngFromScreenCoords(mapView.width.toFloat(), mapView.height / 2f)
+ .also { it.longitude += 360 },
+ mapboxMap.getLatLngFromScreenCoords(mapView.width.toFloat(), mapView.height.toFloat())
+ .also { it.longitude += 360 },
mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height.toFloat()),
mapboxMap.getLatLngFromScreenCoords(0f, mapView.height.toFloat()),
mapboxMap.getLatLngFromScreenCoords(0f, mapView.height / 2f),
@@ -222,10 +223,10 @@ class VisibleRegionTest : BaseActivityTest() {
)
mapboxMap.setPadding(
- (mapView.width / 4f).toInt(),
- (mapView.height / 4f).toInt(),
- (mapView.width / 4f).toInt(),
- (mapView.height / 4f).toInt())
+ mapView.width / 4,
+ mapView.height / 4,
+ mapView.width / 4,
+ mapView.height / 4)
val visibleRegion = mapboxMap.projection.getVisibleRegion(false)
val filtered = latLngs.filter { visibleRegion.latLngBounds.contains(it) }
@@ -242,16 +243,19 @@ class VisibleRegionTest : BaseActivityTest() {
val latLngs = listOf(
mapboxMap.getLatLngFromScreenCoords(0f, 0f),
mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f, 0f),
- mapboxMap.getLatLngFromScreenCoords(mapView.width.toFloat(), 0f),
- mapboxMap.getLatLngFromScreenCoords(mapView.width.toFloat(), mapView.height / 2f),
- mapboxMap.getLatLngFromScreenCoords(mapView.width.toFloat(), mapView.height.toFloat()),
+ mapboxMap.getLatLngFromScreenCoords(mapView.width.toFloat(), 0f)
+ .also { it.longitude += 360 },
+ mapboxMap.getLatLngFromScreenCoords(mapView.width.toFloat(), mapView.height / 2f)
+ .also { it.longitude += 360 },
+ mapboxMap.getLatLngFromScreenCoords(mapView.width.toFloat(), mapView.height.toFloat())
+ .also { it.longitude += 360 },
mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height.toFloat()),
mapboxMap.getLatLngFromScreenCoords(0f, mapView.height.toFloat()),
mapboxMap.getLatLngFromScreenCoords(0f, mapView.height / 2f),
mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height / 2f)
)
- mapboxMap.setPadding((mapView.width / 4f).toInt(), 0, 0, 0)
+ mapboxMap.setPadding(mapView.width / 4, 0, 0, 0)
val visibleRegion = mapboxMap.projection.getVisibleRegion(false)
val filtered = latLngs.filter { visibleRegion.latLngBounds.contains(it) }
@@ -265,19 +269,23 @@ class VisibleRegionTest : BaseActivityTest() {
validateTestSetup()
invoke(mapboxMap) { _: UiController, mapboxMap: MapboxMap ->
mapboxMap.moveCamera(CameraUpdateFactory.newLatLngZoom(LatLng(0.0, 180.0), 8.0))
+
val latLngs = listOf(
mapboxMap.getLatLngFromScreenCoords(0f, 0f),
mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f, 0f),
- mapboxMap.getLatLngFromScreenCoords(mapView.width.toFloat(), 0f),
- mapboxMap.getLatLngFromScreenCoords(mapView.width.toFloat(), mapView.height / 2f),
- mapboxMap.getLatLngFromScreenCoords(mapView.width.toFloat(), mapView.height.toFloat()),
+ mapboxMap.getLatLngFromScreenCoords(mapView.width.toFloat(), 0f)
+ .also { it.longitude += 360 },
+ mapboxMap.getLatLngFromScreenCoords(mapView.width.toFloat(), mapView.height / 2f)
+ .also { it.longitude += 360 },
+ mapboxMap.getLatLngFromScreenCoords(mapView.width.toFloat(), mapView.height.toFloat())
+ .also { it.longitude += 360 },
mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height.toFloat()),
mapboxMap.getLatLngFromScreenCoords(0f, mapView.height.toFloat()),
mapboxMap.getLatLngFromScreenCoords(0f, mapView.height / 2f),
mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height / 2f)
)
- mapboxMap.setPadding(0, (mapView.height / 4f).toInt(), 0, 0)
+ mapboxMap.setPadding(0, mapView.height / 4, 0, 0)
val visibleRegion = mapboxMap.projection.getVisibleRegion(false)
val filtered = latLngs.filter { visibleRegion.latLngBounds.contains(it) }
@@ -294,16 +302,19 @@ class VisibleRegionTest : BaseActivityTest() {
val latLngs = listOf(
mapboxMap.getLatLngFromScreenCoords(0f, 0f),
mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f, 0f),
- mapboxMap.getLatLngFromScreenCoords(mapView.width.toFloat(), 0f),
- mapboxMap.getLatLngFromScreenCoords(mapView.width.toFloat(), mapView.height / 2f),
- mapboxMap.getLatLngFromScreenCoords(mapView.width.toFloat(), mapView.height.toFloat()),
+ mapboxMap.getLatLngFromScreenCoords(mapView.width.toFloat(), 0f)
+ .also { it.longitude += 360 },
+ mapboxMap.getLatLngFromScreenCoords(mapView.width.toFloat(), mapView.height / 2f)
+ .also { it.longitude += 360 },
+ mapboxMap.getLatLngFromScreenCoords(mapView.width.toFloat(), mapView.height.toFloat())
+ .also { it.longitude += 360 },
mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height.toFloat()),
mapboxMap.getLatLngFromScreenCoords(0f, mapView.height.toFloat()),
mapboxMap.getLatLngFromScreenCoords(0f, mapView.height / 2f),
mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height / 2f)
)
- mapboxMap.setPadding(0, 0, (mapView.width / 4f).toInt(), 0)
+ mapboxMap.setPadding(0, 0, mapView.width / 4, 0)
val visibleRegion = mapboxMap.projection.getVisibleRegion(false)
val filtered = latLngs.filter { visibleRegion.latLngBounds.contains(it) }
@@ -320,16 +331,19 @@ class VisibleRegionTest : BaseActivityTest() {
val latLngs = listOf(
mapboxMap.getLatLngFromScreenCoords(0f, 0f),
mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f, 0f),
- mapboxMap.getLatLngFromScreenCoords(mapView.width.toFloat(), 0f),
- mapboxMap.getLatLngFromScreenCoords(mapView.width.toFloat(), mapView.height / 2f),
- mapboxMap.getLatLngFromScreenCoords(mapView.width.toFloat(), mapView.height.toFloat()),
+ mapboxMap.getLatLngFromScreenCoords(mapView.width.toFloat(), 0f)
+ .also { it.longitude += 360 },
+ mapboxMap.getLatLngFromScreenCoords(mapView.width.toFloat(), mapView.height / 2f)
+ .also { it.longitude += 360 },
+ mapboxMap.getLatLngFromScreenCoords(mapView.width.toFloat(), mapView.height.toFloat())
+ .also { it.longitude += 360 },
mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height.toFloat()),
mapboxMap.getLatLngFromScreenCoords(0f, mapView.height.toFloat()),
mapboxMap.getLatLngFromScreenCoords(0f, mapView.height / 2f),
mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height / 2f)
)
- mapboxMap.setPadding(0, 0, 0, (mapView.height / 4f).toInt())
+ mapboxMap.setPadding(0, 0, 0, mapView.height / 4)
val visibleRegion = mapboxMap.projection.getVisibleRegion(false)
val filtered = latLngs.filter { visibleRegion.latLngBounds.contains(it) }
@@ -370,7 +384,8 @@ class VisibleRegionTest : BaseActivityTest() {
val latLngs = listOf(
mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height / 2f),
mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f - d / 2f, mapView.height / 2f),
- mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f + d / 2f, mapView.height / 2f),
+ mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f + d / 2f, mapView.height / 2f)
+ .also { it.longitude += 360 },
mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height / 2f - d / 2f),
mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height / 2f + d / 2f)
)
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 4398be744f..3cce0ee867 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,167 +3,139 @@
package com.mapbox.mapboxsdk.testapp.style;
import android.graphics.Color;
+import android.support.test.annotation.UiThreadTest;
import android.support.test.runner.AndroidJUnit4;
+import com.mapbox.mapboxsdk.maps.BaseLayerTest;
+import org.junit.Before;
import timber.log.Timber;
import com.mapbox.mapboxsdk.style.expressions.Expression;
import com.mapbox.mapboxsdk.style.layers.BackgroundLayer;
-import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest;
import org.junit.Test;
import org.junit.runner.RunWith;
import static com.mapbox.mapboxsdk.style.expressions.Expression.*;
-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.*;
import com.mapbox.mapboxsdk.style.layers.TransitionOptions;
-import com.mapbox.mapboxsdk.testapp.activity.espresso.EspressoTestActivity;
/**
* Basic smoke tests for BackgroundLayer
*/
@RunWith(AndroidJUnit4.class)
-public class BackgroundLayerTest extends BaseActivityTest {
+public class BackgroundLayerTest extends BaseLayerTest {
private BackgroundLayer layer;
- @Override
- protected Class getActivityClass() {
- return EspressoTestActivity.class;
- }
-
- private void setupLayer() {
- Timber.i("Retrieving layer");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- layer = mapboxMap.getStyle().getLayerAs("background");
- });
+ @Before
+ @UiThreadTest
+ public void beforeTest(){
+ super.before();
+ layer = new BackgroundLayer("my-layer");
+ setupLayer(layer);
}
@Test
+ @UiThreadTest
public void testSetVisibility() {
- validateTestSetup();
- setupLayer();
Timber.i("Visibility");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
+ 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
+ @UiThreadTest
public void testBackgroundColorTransition() {
- validateTestSetup();
- setupLayer();
Timber.i("background-colorTransitionOptions");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
-
- // Set and Get
- TransitionOptions options = new TransitionOptions(300, 100);
- layer.setBackgroundColorTransition(options);
- assertEquals(layer.getBackgroundColorTransition(), options);
- });
+ assertNotNull(layer);
+
+ // Set and Get
+ TransitionOptions options = new TransitionOptions(300, 100);
+ layer.setBackgroundColorTransition(options);
+ assertEquals(layer.getBackgroundColorTransition(), options);
}
@Test
+ @UiThreadTest
public void testBackgroundColorAsConstant() {
- validateTestSetup();
- setupLayer();
Timber.i("background-color");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getBackgroundColor().getValue());
-
- // Set and Get
- String propertyValue = "rgba(0, 0, 0, 1)";
- layer.setProperties(backgroundColor(propertyValue));
- assertEquals(layer.getBackgroundColor().getValue(), propertyValue);
- });
+ assertNotNull(layer);
+ assertNull(layer.getBackgroundColor().getValue());
+
+ // Set and Get
+ String propertyValue = "rgba(0, 0, 0, 1)";
+ layer.setProperties(backgroundColor(propertyValue));
+ assertEquals(layer.getBackgroundColor().getValue(), propertyValue);
}
@Test
+ @UiThreadTest
public void testBackgroundColorAsIntConstant() {
- validateTestSetup();
- setupLayer();
Timber.i("background-color");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
+ assertNotNull(layer);
- // Set and Get
- layer.setProperties(backgroundColor(Color.RED));
- assertEquals(layer.getBackgroundColorAsInt(), Color.RED);
- });
+ // Set and Get
+ layer.setProperties(backgroundColor(Color.RED));
+ assertEquals(layer.getBackgroundColorAsInt(), Color.RED);
}
@Test
+ @UiThreadTest
public void testBackgroundPatternTransition() {
- validateTestSetup();
- setupLayer();
Timber.i("background-patternTransitionOptions");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
-
- // Set and Get
- TransitionOptions options = new TransitionOptions(300, 100);
- layer.setBackgroundPatternTransition(options);
- assertEquals(layer.getBackgroundPatternTransition(), options);
- });
+ assertNotNull(layer);
+
+ // Set and Get
+ TransitionOptions options = new TransitionOptions(300, 100);
+ layer.setBackgroundPatternTransition(options);
+ assertEquals(layer.getBackgroundPatternTransition(), options);
}
@Test
+ @UiThreadTest
public void testBackgroundPatternAsConstant() {
- validateTestSetup();
- setupLayer();
Timber.i("background-pattern");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getBackgroundPattern().getValue());
-
- // Set and Get
- String propertyValue = "pedestrian-polygon";
- layer.setProperties(backgroundPattern(propertyValue));
- assertEquals(layer.getBackgroundPattern().getValue(), propertyValue);
- });
+ assertNotNull(layer);
+ assertNull(layer.getBackgroundPattern().getValue());
+
+ // Set and Get
+ String propertyValue = "pedestrian-polygon";
+ layer.setProperties(backgroundPattern(propertyValue));
+ assertEquals(layer.getBackgroundPattern().getValue(), propertyValue);
}
@Test
+ @UiThreadTest
public void testBackgroundOpacityTransition() {
- validateTestSetup();
- setupLayer();
Timber.i("background-opacityTransitionOptions");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
-
- // Set and Get
- TransitionOptions options = new TransitionOptions(300, 100);
- layer.setBackgroundOpacityTransition(options);
- assertEquals(layer.getBackgroundOpacityTransition(), options);
- });
+ assertNotNull(layer);
+
+ // Set and Get
+ TransitionOptions options = new TransitionOptions(300, 100);
+ layer.setBackgroundOpacityTransition(options);
+ assertEquals(layer.getBackgroundOpacityTransition(), options);
}
@Test
+ @UiThreadTest
public void testBackgroundOpacityAsConstant() {
- validateTestSetup();
- setupLayer();
Timber.i("background-opacity");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getBackgroundOpacity().getValue());
-
- // Set and Get
- Float propertyValue = 0.3f;
- layer.setProperties(backgroundOpacity(propertyValue));
- assertEquals(layer.getBackgroundOpacity().getValue(), propertyValue);
- });
+ assertNotNull(layer);
+ assertNull(layer.getBackgroundOpacity().getValue());
+
+ // Set and Get
+ Float propertyValue = 0.3f;
+ layer.setProperties(backgroundOpacity(propertyValue));
+ assertEquals(layer.getBackgroundOpacity().getValue(), propertyValue);
}
}
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 23479b2893..bf8b8ef2b2 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,558 +3,451 @@
package com.mapbox.mapboxsdk.testapp.style;
import android.graphics.Color;
+import android.support.test.annotation.UiThreadTest;
import android.support.test.runner.AndroidJUnit4;
+import com.mapbox.mapboxsdk.maps.BaseLayerTest;
+import org.junit.Before;
import timber.log.Timber;
import com.mapbox.mapboxsdk.style.expressions.Expression;
import com.mapbox.mapboxsdk.style.layers.CircleLayer;
-import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest;
import org.junit.Test;
import org.junit.runner.RunWith;
import static com.mapbox.mapboxsdk.style.expressions.Expression.*;
-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.*;
import com.mapbox.mapboxsdk.style.layers.TransitionOptions;
-import com.mapbox.mapboxsdk.testapp.activity.espresso.EspressoTestActivity;
/**
* Basic smoke tests for CircleLayer
*/
@RunWith(AndroidJUnit4.class)
-public class CircleLayerTest extends BaseActivityTest {
+public class CircleLayerTest extends BaseLayerTest {
private CircleLayer layer;
- @Override
- protected Class getActivityClass() {
- return EspressoTestActivity.class;
- }
-
- private void setupLayer() {
- Timber.i("Retrieving layer");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- if ((layer = mapboxMap.getStyle().getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new CircleLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.getStyle().addLayer(layer);
- // Layer reference is now stale, get new reference
- layer = mapboxMap.getStyle().getLayerAs("my-layer");
- }
- });
+ @Before
+ @UiThreadTest
+ public void beforeTest(){
+ super.before();
+ layer = new CircleLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ setupLayer(layer);
}
@Test
+ @UiThreadTest
public void testSourceId() {
- validateTestSetup();
- setupLayer();
Timber.i("SourceId");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- // Get source id
- assertEquals(layer.getSourceId(), "composite");
- });
+ assertNotNull(layer);
+ assertEquals(layer.getSourceId(), "composite");
}
@Test
+ @UiThreadTest
public void testSetVisibility() {
- validateTestSetup();
- setupLayer();
Timber.i("Visibility");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
+ 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
+ @UiThreadTest
public void testSourceLayer() {
- validateTestSetup();
- setupLayer();
Timber.i("SourceLayer");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
+ 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
+ @UiThreadTest
public void testFilter() {
- validateTestSetup();
- setupLayer();
Timber.i("Filter");
- invoke(mapboxMap, (uiController, mapboxMap1) -> {
- assertNotNull(layer);
+ assertNotNull(layer);
- // Get initial
- assertEquals(layer.getFilter(), null);
+ // Get initial
+ assertEquals(layer.getFilter(), null);
- // Set
- Expression filter = eq(get("undefined"), literal(1.0));
- layer.setFilter(filter);
- assertEquals(layer.getFilter().toString(), filter.toString());
+ // Set
+ Expression filter = eq(get("undefined"), literal(1.0));
+ layer.setFilter(filter);
+ assertEquals(layer.getFilter().toString(), filter.toString());
- // Set constant
- filter = literal(true);
- layer.setFilter(filter);
- assertEquals(layer.getFilter().toString(), filter.toString());
- });
+ // Set constant
+ filter = literal(true);
+ layer.setFilter(filter);
+ assertEquals(layer.getFilter().toString(), filter.toString());
}
@Test
+ @UiThreadTest
public void testCircleRadiusTransition() {
- validateTestSetup();
- setupLayer();
Timber.i("circle-radiusTransitionOptions");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
+ assertNotNull(layer);
- // Set and Get
- TransitionOptions options = new TransitionOptions(300, 100);
- layer.setCircleRadiusTransition(options);
- assertEquals(layer.getCircleRadiusTransition(), options);
- });
+ // Set and Get
+ TransitionOptions options = new TransitionOptions(300, 100);
+ layer.setCircleRadiusTransition(options);
+ assertEquals(layer.getCircleRadiusTransition(), options);
}
@Test
+ @UiThreadTest
public void testCircleRadiusAsConstant() {
- validateTestSetup();
- setupLayer();
Timber.i("circle-radius");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getCircleRadius().getValue());
+ assertNotNull(layer);
+ assertNull(layer.getCircleRadius().getValue());
- // Set and Get
- Float propertyValue = 0.3f;
- layer.setProperties(circleRadius(propertyValue));
- assertEquals(layer.getCircleRadius().getValue(), propertyValue);
- });
+ // Set and Get
+ Float propertyValue = 0.3f;
+ layer.setProperties(circleRadius(propertyValue));
+ assertEquals(layer.getCircleRadius().getValue(), propertyValue);
}
@Test
+ @UiThreadTest
public void testCircleRadiusAsExpression() {
- validateTestSetup();
- setupLayer();
Timber.i("circle-radius-expression");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getCircleRadius().getExpression());
+ assertNotNull(layer);
+ assertNull(layer.getCircleRadius().getExpression());
- // Set and Get
- Expression expression = number(Expression.get("undefined"));
- layer.setProperties(circleRadius(expression));
- assertEquals(layer.getCircleRadius().getExpression(), expression);
- });
+ // Set and Get
+ Expression expression = number(Expression.get("undefined"));
+ layer.setProperties(circleRadius(expression));
+ assertEquals(layer.getCircleRadius().getExpression(), expression);
}
@Test
+ @UiThreadTest
public void testCircleColorTransition() {
- validateTestSetup();
- setupLayer();
Timber.i("circle-colorTransitionOptions");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
+ assertNotNull(layer);
- // Set and Get
- TransitionOptions options = new TransitionOptions(300, 100);
- layer.setCircleColorTransition(options);
- assertEquals(layer.getCircleColorTransition(), options);
- });
+ // Set and Get
+ TransitionOptions options = new TransitionOptions(300, 100);
+ layer.setCircleColorTransition(options);
+ assertEquals(layer.getCircleColorTransition(), options);
}
@Test
+ @UiThreadTest
public void testCircleColorAsConstant() {
- validateTestSetup();
- setupLayer();
Timber.i("circle-color");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getCircleColor().getValue());
+ assertNotNull(layer);
+ assertNull(layer.getCircleColor().getValue());
- // Set and Get
- String propertyValue = "rgba(0, 0, 0, 1)";
- layer.setProperties(circleColor(propertyValue));
- assertEquals(layer.getCircleColor().getValue(), propertyValue);
- });
+ // Set and Get
+ String propertyValue = "rgba(0, 0, 0, 1)";
+ layer.setProperties(circleColor(propertyValue));
+ assertEquals(layer.getCircleColor().getValue(), propertyValue);
}
@Test
+ @UiThreadTest
public void testCircleColorAsExpression() {
- validateTestSetup();
- setupLayer();
Timber.i("circle-color-expression");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getCircleColor().getExpression());
+ assertNotNull(layer);
+ assertNull(layer.getCircleColor().getExpression());
- // Set and Get
- Expression expression = toColor(Expression.get("undefined"));
- layer.setProperties(circleColor(expression));
- assertEquals(layer.getCircleColor().getExpression(), expression);
- });
+ // Set and Get
+ Expression expression = toColor(Expression.get("undefined"));
+ layer.setProperties(circleColor(expression));
+ assertEquals(layer.getCircleColor().getExpression(), expression);
}
@Test
+ @UiThreadTest
public void testCircleColorAsIntConstant() {
- validateTestSetup();
- setupLayer();
Timber.i("circle-color");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
+ assertNotNull(layer);
- // Set and Get
- layer.setProperties(circleColor(Color.RED));
- assertEquals(layer.getCircleColorAsInt(), Color.RED);
- });
+ // Set and Get
+ layer.setProperties(circleColor(Color.RED));
+ assertEquals(layer.getCircleColorAsInt(), Color.RED);
}
@Test
+ @UiThreadTest
public void testCircleBlurTransition() {
- validateTestSetup();
- setupLayer();
Timber.i("circle-blurTransitionOptions");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
+ assertNotNull(layer);
- // Set and Get
- TransitionOptions options = new TransitionOptions(300, 100);
- layer.setCircleBlurTransition(options);
- assertEquals(layer.getCircleBlurTransition(), options);
- });
+ // Set and Get
+ TransitionOptions options = new TransitionOptions(300, 100);
+ layer.setCircleBlurTransition(options);
+ assertEquals(layer.getCircleBlurTransition(), options);
}
@Test
+ @UiThreadTest
public void testCircleBlurAsConstant() {
- validateTestSetup();
- setupLayer();
Timber.i("circle-blur");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getCircleBlur().getValue());
+ assertNotNull(layer);
+ assertNull(layer.getCircleBlur().getValue());
- // Set and Get
- Float propertyValue = 0.3f;
- layer.setProperties(circleBlur(propertyValue));
- assertEquals(layer.getCircleBlur().getValue(), propertyValue);
- });
+ // Set and Get
+ Float propertyValue = 0.3f;
+ layer.setProperties(circleBlur(propertyValue));
+ assertEquals(layer.getCircleBlur().getValue(), propertyValue);
}
@Test
+ @UiThreadTest
public void testCircleBlurAsExpression() {
- validateTestSetup();
- setupLayer();
Timber.i("circle-blur-expression");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getCircleBlur().getExpression());
+ assertNotNull(layer);
+ assertNull(layer.getCircleBlur().getExpression());
- // Set and Get
- Expression expression = number(Expression.get("undefined"));
- layer.setProperties(circleBlur(expression));
- assertEquals(layer.getCircleBlur().getExpression(), expression);
- });
+ // Set and Get
+ Expression expression = number(Expression.get("undefined"));
+ layer.setProperties(circleBlur(expression));
+ assertEquals(layer.getCircleBlur().getExpression(), expression);
}
@Test
+ @UiThreadTest
public void testCircleOpacityTransition() {
- validateTestSetup();
- setupLayer();
Timber.i("circle-opacityTransitionOptions");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
+ assertNotNull(layer);
- // Set and Get
- TransitionOptions options = new TransitionOptions(300, 100);
- layer.setCircleOpacityTransition(options);
- assertEquals(layer.getCircleOpacityTransition(), options);
- });
+ // Set and Get
+ TransitionOptions options = new TransitionOptions(300, 100);
+ layer.setCircleOpacityTransition(options);
+ assertEquals(layer.getCircleOpacityTransition(), options);
}
@Test
+ @UiThreadTest
public void testCircleOpacityAsConstant() {
- validateTestSetup();
- setupLayer();
Timber.i("circle-opacity");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getCircleOpacity().getValue());
+ assertNotNull(layer);
+ assertNull(layer.getCircleOpacity().getValue());
- // Set and Get
- Float propertyValue = 0.3f;
- layer.setProperties(circleOpacity(propertyValue));
- assertEquals(layer.getCircleOpacity().getValue(), propertyValue);
- });
+ // Set and Get
+ Float propertyValue = 0.3f;
+ layer.setProperties(circleOpacity(propertyValue));
+ assertEquals(layer.getCircleOpacity().getValue(), propertyValue);
}
@Test
+ @UiThreadTest
public void testCircleOpacityAsExpression() {
- validateTestSetup();
- setupLayer();
Timber.i("circle-opacity-expression");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getCircleOpacity().getExpression());
+ assertNotNull(layer);
+ assertNull(layer.getCircleOpacity().getExpression());
- // Set and Get
- Expression expression = number(Expression.get("undefined"));
- layer.setProperties(circleOpacity(expression));
- assertEquals(layer.getCircleOpacity().getExpression(), expression);
- });
+ // Set and Get
+ Expression expression = number(Expression.get("undefined"));
+ layer.setProperties(circleOpacity(expression));
+ assertEquals(layer.getCircleOpacity().getExpression(), expression);
}
@Test
+ @UiThreadTest
public void testCircleTranslateTransition() {
- validateTestSetup();
- setupLayer();
Timber.i("circle-translateTransitionOptions");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
+ assertNotNull(layer);
- // Set and Get
- TransitionOptions options = new TransitionOptions(300, 100);
- layer.setCircleTranslateTransition(options);
- assertEquals(layer.getCircleTranslateTransition(), options);
- });
+ // Set and Get
+ TransitionOptions options = new TransitionOptions(300, 100);
+ layer.setCircleTranslateTransition(options);
+ assertEquals(layer.getCircleTranslateTransition(), options);
}
@Test
+ @UiThreadTest
public void testCircleTranslateAsConstant() {
- validateTestSetup();
- setupLayer();
Timber.i("circle-translate");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getCircleTranslate().getValue());
+ assertNotNull(layer);
+ assertNull(layer.getCircleTranslate().getValue());
- // Set and Get
- Float[] propertyValue = new Float[] {0f, 0f};
- layer.setProperties(circleTranslate(propertyValue));
- assertEquals(layer.getCircleTranslate().getValue(), propertyValue);
- });
+ // Set and Get
+ Float[] propertyValue = new Float[] {0f, 0f};
+ layer.setProperties(circleTranslate(propertyValue));
+ assertEquals(layer.getCircleTranslate().getValue(), propertyValue);
}
@Test
+ @UiThreadTest
public void testCircleTranslateAnchorAsConstant() {
- validateTestSetup();
- setupLayer();
Timber.i("circle-translate-anchor");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getCircleTranslateAnchor().getValue());
+ assertNotNull(layer);
+ assertNull(layer.getCircleTranslateAnchor().getValue());
- // Set and Get
- String propertyValue = CIRCLE_TRANSLATE_ANCHOR_MAP;
- layer.setProperties(circleTranslateAnchor(propertyValue));
- assertEquals(layer.getCircleTranslateAnchor().getValue(), propertyValue);
- });
+ // Set and Get
+ String propertyValue = CIRCLE_TRANSLATE_ANCHOR_MAP;
+ layer.setProperties(circleTranslateAnchor(propertyValue));
+ assertEquals(layer.getCircleTranslateAnchor().getValue(), propertyValue);
}
@Test
+ @UiThreadTest
public void testCirclePitchScaleAsConstant() {
- validateTestSetup();
- setupLayer();
Timber.i("circle-pitch-scale");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getCirclePitchScale().getValue());
+ assertNotNull(layer);
+ assertNull(layer.getCirclePitchScale().getValue());
- // Set and Get
- String propertyValue = CIRCLE_PITCH_SCALE_MAP;
- layer.setProperties(circlePitchScale(propertyValue));
- assertEquals(layer.getCirclePitchScale().getValue(), propertyValue);
- });
+ // Set and Get
+ String propertyValue = CIRCLE_PITCH_SCALE_MAP;
+ layer.setProperties(circlePitchScale(propertyValue));
+ assertEquals(layer.getCirclePitchScale().getValue(), propertyValue);
}
@Test
+ @UiThreadTest
public void testCirclePitchAlignmentAsConstant() {
- validateTestSetup();
- setupLayer();
Timber.i("circle-pitch-alignment");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getCirclePitchAlignment().getValue());
+ assertNotNull(layer);
+ assertNull(layer.getCirclePitchAlignment().getValue());
- // Set and Get
- String propertyValue = CIRCLE_PITCH_ALIGNMENT_MAP;
- layer.setProperties(circlePitchAlignment(propertyValue));
- assertEquals(layer.getCirclePitchAlignment().getValue(), propertyValue);
- });
+ // Set and Get
+ String propertyValue = CIRCLE_PITCH_ALIGNMENT_MAP;
+ layer.setProperties(circlePitchAlignment(propertyValue));
+ assertEquals(layer.getCirclePitchAlignment().getValue(), propertyValue);
}
@Test
+ @UiThreadTest
public void testCircleStrokeWidthTransition() {
- validateTestSetup();
- setupLayer();
Timber.i("circle-stroke-widthTransitionOptions");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
+ assertNotNull(layer);
- // Set and Get
- TransitionOptions options = new TransitionOptions(300, 100);
- layer.setCircleStrokeWidthTransition(options);
- assertEquals(layer.getCircleStrokeWidthTransition(), options);
- });
+ // Set and Get
+ TransitionOptions options = new TransitionOptions(300, 100);
+ layer.setCircleStrokeWidthTransition(options);
+ assertEquals(layer.getCircleStrokeWidthTransition(), options);
}
@Test
+ @UiThreadTest
public void testCircleStrokeWidthAsConstant() {
- validateTestSetup();
- setupLayer();
Timber.i("circle-stroke-width");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getCircleStrokeWidth().getValue());
+ assertNotNull(layer);
+ assertNull(layer.getCircleStrokeWidth().getValue());
- // Set and Get
- Float propertyValue = 0.3f;
- layer.setProperties(circleStrokeWidth(propertyValue));
- assertEquals(layer.getCircleStrokeWidth().getValue(), propertyValue);
- });
+ // Set and Get
+ Float propertyValue = 0.3f;
+ layer.setProperties(circleStrokeWidth(propertyValue));
+ assertEquals(layer.getCircleStrokeWidth().getValue(), propertyValue);
}
@Test
+ @UiThreadTest
public void testCircleStrokeWidthAsExpression() {
- validateTestSetup();
- setupLayer();
Timber.i("circle-stroke-width-expression");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getCircleStrokeWidth().getExpression());
+ assertNotNull(layer);
+ assertNull(layer.getCircleStrokeWidth().getExpression());
- // Set and Get
- Expression expression = number(Expression.get("undefined"));
- layer.setProperties(circleStrokeWidth(expression));
- assertEquals(layer.getCircleStrokeWidth().getExpression(), expression);
- });
+ // Set and Get
+ Expression expression = number(Expression.get("undefined"));
+ layer.setProperties(circleStrokeWidth(expression));
+ assertEquals(layer.getCircleStrokeWidth().getExpression(), expression);
}
@Test
+ @UiThreadTest
public void testCircleStrokeColorTransition() {
- validateTestSetup();
- setupLayer();
Timber.i("circle-stroke-colorTransitionOptions");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
+ assertNotNull(layer);
- // Set and Get
- TransitionOptions options = new TransitionOptions(300, 100);
- layer.setCircleStrokeColorTransition(options);
- assertEquals(layer.getCircleStrokeColorTransition(), options);
- });
+ // Set and Get
+ TransitionOptions options = new TransitionOptions(300, 100);
+ layer.setCircleStrokeColorTransition(options);
+ assertEquals(layer.getCircleStrokeColorTransition(), options);
}
@Test
+ @UiThreadTest
public void testCircleStrokeColorAsConstant() {
- validateTestSetup();
- setupLayer();
Timber.i("circle-stroke-color");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getCircleStrokeColor().getValue());
+ assertNotNull(layer);
+ assertNull(layer.getCircleStrokeColor().getValue());
- // Set and Get
- String propertyValue = "rgba(0, 0, 0, 1)";
- layer.setProperties(circleStrokeColor(propertyValue));
- assertEquals(layer.getCircleStrokeColor().getValue(), propertyValue);
- });
+ // Set and Get
+ String propertyValue = "rgba(0, 0, 0, 1)";
+ layer.setProperties(circleStrokeColor(propertyValue));
+ assertEquals(layer.getCircleStrokeColor().getValue(), propertyValue);
}
@Test
+ @UiThreadTest
public void testCircleStrokeColorAsExpression() {
- validateTestSetup();
- setupLayer();
Timber.i("circle-stroke-color-expression");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getCircleStrokeColor().getExpression());
+ assertNotNull(layer);
+ assertNull(layer.getCircleStrokeColor().getExpression());
- // Set and Get
- Expression expression = toColor(Expression.get("undefined"));
- layer.setProperties(circleStrokeColor(expression));
- assertEquals(layer.getCircleStrokeColor().getExpression(), expression);
- });
+ // Set and Get
+ Expression expression = toColor(Expression.get("undefined"));
+ layer.setProperties(circleStrokeColor(expression));
+ assertEquals(layer.getCircleStrokeColor().getExpression(), expression);
}
@Test
+ @UiThreadTest
public void testCircleStrokeColorAsIntConstant() {
- validateTestSetup();
- setupLayer();
Timber.i("circle-stroke-color");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
+ assertNotNull(layer);
- // Set and Get
- layer.setProperties(circleStrokeColor(Color.RED));
- assertEquals(layer.getCircleStrokeColorAsInt(), Color.RED);
- });
+ // Set and Get
+ layer.setProperties(circleStrokeColor(Color.RED));
+ assertEquals(layer.getCircleStrokeColorAsInt(), Color.RED);
}
@Test
+ @UiThreadTest
public void testCircleStrokeOpacityTransition() {
- validateTestSetup();
- setupLayer();
Timber.i("circle-stroke-opacityTransitionOptions");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
+ assertNotNull(layer);
- // Set and Get
- TransitionOptions options = new TransitionOptions(300, 100);
- layer.setCircleStrokeOpacityTransition(options);
- assertEquals(layer.getCircleStrokeOpacityTransition(), options);
- });
+ // Set and Get
+ TransitionOptions options = new TransitionOptions(300, 100);
+ layer.setCircleStrokeOpacityTransition(options);
+ assertEquals(layer.getCircleStrokeOpacityTransition(), options);
}
@Test
+ @UiThreadTest
public void testCircleStrokeOpacityAsConstant() {
- validateTestSetup();
- setupLayer();
Timber.i("circle-stroke-opacity");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getCircleStrokeOpacity().getValue());
+ assertNotNull(layer);
+ assertNull(layer.getCircleStrokeOpacity().getValue());
- // Set and Get
- Float propertyValue = 0.3f;
- layer.setProperties(circleStrokeOpacity(propertyValue));
- assertEquals(layer.getCircleStrokeOpacity().getValue(), propertyValue);
- });
+ // Set and Get
+ Float propertyValue = 0.3f;
+ layer.setProperties(circleStrokeOpacity(propertyValue));
+ assertEquals(layer.getCircleStrokeOpacity().getValue(), propertyValue);
}
@Test
+ @UiThreadTest
public void testCircleStrokeOpacityAsExpression() {
- validateTestSetup();
- setupLayer();
Timber.i("circle-stroke-opacity-expression");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getCircleStrokeOpacity().getExpression());
-
- // Set and Get
- Expression expression = number(Expression.get("undefined"));
- layer.setProperties(circleStrokeOpacity(expression));
- assertEquals(layer.getCircleStrokeOpacity().getExpression(), expression);
- });
+ assertNotNull(layer);
+ assertNull(layer.getCircleStrokeOpacity().getExpression());
+
+ // Set and Get
+ Expression expression = number(Expression.get("undefined"));
+ layer.setProperties(circleStrokeOpacity(expression));
+ assertEquals(layer.getCircleStrokeOpacity().getExpression(), expression);
}
}
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 70f903ca3b..7a6ebb7ac6 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,418 +3,338 @@
package com.mapbox.mapboxsdk.testapp.style;
import android.graphics.Color;
+import android.support.test.annotation.UiThreadTest;
import android.support.test.runner.AndroidJUnit4;
+import com.mapbox.mapboxsdk.maps.BaseLayerTest;
+import org.junit.Before;
import timber.log.Timber;
import com.mapbox.mapboxsdk.style.expressions.Expression;
import com.mapbox.mapboxsdk.style.layers.FillExtrusionLayer;
-import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest;
import org.junit.Test;
import org.junit.runner.RunWith;
import static com.mapbox.mapboxsdk.style.expressions.Expression.*;
-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.*;
import com.mapbox.mapboxsdk.style.layers.TransitionOptions;
-import com.mapbox.mapboxsdk.testapp.activity.espresso.EspressoTestActivity;
/**
* Basic smoke tests for FillExtrusionLayer
*/
@RunWith(AndroidJUnit4.class)
-public class FillExtrusionLayerTest extends BaseActivityTest {
+public class FillExtrusionLayerTest extends BaseLayerTest {
private FillExtrusionLayer layer;
- @Override
- protected Class getActivityClass() {
- return EspressoTestActivity.class;
- }
-
- private void setupLayer() {
- Timber.i("Retrieving layer");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- if ((layer = mapboxMap.getStyle().getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new FillExtrusionLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.getStyle().addLayer(layer);
- // Layer reference is now stale, get new reference
- layer = mapboxMap.getStyle().getLayerAs("my-layer");
- }
- });
+ @Before
+ @UiThreadTest
+ public void beforeTest(){
+ super.before();
+ layer = new FillExtrusionLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ setupLayer(layer);
}
@Test
+ @UiThreadTest
public void testSourceId() {
- validateTestSetup();
- setupLayer();
Timber.i("SourceId");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- // Get source id
- assertEquals(layer.getSourceId(), "composite");
- });
+ assertNotNull(layer);
+ assertEquals(layer.getSourceId(), "composite");
}
@Test
+ @UiThreadTest
public void testSetVisibility() {
- validateTestSetup();
- setupLayer();
Timber.i("Visibility");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
+ 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
+ @UiThreadTest
public void testSourceLayer() {
- validateTestSetup();
- setupLayer();
Timber.i("SourceLayer");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
+ 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
+ @UiThreadTest
public void testFilter() {
- validateTestSetup();
- setupLayer();
Timber.i("Filter");
- invoke(mapboxMap, (uiController, mapboxMap1) -> {
- assertNotNull(layer);
-
- // Get initial
- assertEquals(layer.getFilter(), null);
-
- // Set
- Expression filter = eq(get("undefined"), literal(1.0));
- layer.setFilter(filter);
- assertEquals(layer.getFilter().toString(), filter.toString());
-
- // Set constant
- filter = literal(true);
- layer.setFilter(filter);
- assertEquals(layer.getFilter().toString(), filter.toString());
- });
+ assertNotNull(layer);
+
+ // Get initial
+ assertEquals(layer.getFilter(), null);
+
+ // Set
+ Expression filter = eq(get("undefined"), literal(1.0));
+ layer.setFilter(filter);
+ assertEquals(layer.getFilter().toString(), filter.toString());
+
+ // Set constant
+ filter = literal(true);
+ layer.setFilter(filter);
+ assertEquals(layer.getFilter().toString(), filter.toString());
}
@Test
+ @UiThreadTest
public void testFillExtrusionOpacityTransition() {
- validateTestSetup();
- setupLayer();
Timber.i("fill-extrusion-opacityTransitionOptions");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
-
- // Set and Get
- TransitionOptions options = new TransitionOptions(300, 100);
- layer.setFillExtrusionOpacityTransition(options);
- assertEquals(layer.getFillExtrusionOpacityTransition(), options);
- });
+ assertNotNull(layer);
+
+ // Set and Get
+ TransitionOptions options = new TransitionOptions(300, 100);
+ layer.setFillExtrusionOpacityTransition(options);
+ assertEquals(layer.getFillExtrusionOpacityTransition(), options);
}
@Test
+ @UiThreadTest
public void testFillExtrusionOpacityAsConstant() {
- validateTestSetup();
- setupLayer();
Timber.i("fill-extrusion-opacity");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getFillExtrusionOpacity().getValue());
-
- // Set and Get
- Float propertyValue = 0.3f;
- layer.setProperties(fillExtrusionOpacity(propertyValue));
- assertEquals(layer.getFillExtrusionOpacity().getValue(), propertyValue);
- });
+ assertNotNull(layer);
+ assertNull(layer.getFillExtrusionOpacity().getValue());
+
+ // Set and Get
+ Float propertyValue = 0.3f;
+ layer.setProperties(fillExtrusionOpacity(propertyValue));
+ assertEquals(layer.getFillExtrusionOpacity().getValue(), propertyValue);
}
@Test
+ @UiThreadTest
public void testFillExtrusionColorTransition() {
- validateTestSetup();
- setupLayer();
Timber.i("fill-extrusion-colorTransitionOptions");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
-
- // Set and Get
- TransitionOptions options = new TransitionOptions(300, 100);
- layer.setFillExtrusionColorTransition(options);
- assertEquals(layer.getFillExtrusionColorTransition(), options);
- });
+ assertNotNull(layer);
+
+ // Set and Get
+ TransitionOptions options = new TransitionOptions(300, 100);
+ layer.setFillExtrusionColorTransition(options);
+ assertEquals(layer.getFillExtrusionColorTransition(), options);
}
@Test
+ @UiThreadTest
public void testFillExtrusionColorAsConstant() {
- validateTestSetup();
- setupLayer();
Timber.i("fill-extrusion-color");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getFillExtrusionColor().getValue());
-
- // Set and Get
- String propertyValue = "rgba(0, 0, 0, 1)";
- layer.setProperties(fillExtrusionColor(propertyValue));
- assertEquals(layer.getFillExtrusionColor().getValue(), propertyValue);
- });
+ assertNotNull(layer);
+ assertNull(layer.getFillExtrusionColor().getValue());
+
+ // Set and Get
+ String propertyValue = "rgba(0, 0, 0, 1)";
+ layer.setProperties(fillExtrusionColor(propertyValue));
+ assertEquals(layer.getFillExtrusionColor().getValue(), propertyValue);
}
@Test
+ @UiThreadTest
public void testFillExtrusionColorAsExpression() {
- validateTestSetup();
- setupLayer();
Timber.i("fill-extrusion-color-expression");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getFillExtrusionColor().getExpression());
-
- // Set and Get
- Expression expression = toColor(Expression.get("undefined"));
- layer.setProperties(fillExtrusionColor(expression));
- assertEquals(layer.getFillExtrusionColor().getExpression(), expression);
- });
+ assertNotNull(layer);
+ assertNull(layer.getFillExtrusionColor().getExpression());
+
+ // Set and Get
+ Expression expression = toColor(Expression.get("undefined"));
+ layer.setProperties(fillExtrusionColor(expression));
+ assertEquals(layer.getFillExtrusionColor().getExpression(), expression);
}
@Test
+ @UiThreadTest
public void testFillExtrusionColorAsIntConstant() {
- validateTestSetup();
- setupLayer();
Timber.i("fill-extrusion-color");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
+ 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
+ @UiThreadTest
public void testFillExtrusionTranslateTransition() {
- validateTestSetup();
- setupLayer();
Timber.i("fill-extrusion-translateTransitionOptions");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
-
- // Set and Get
- TransitionOptions options = new TransitionOptions(300, 100);
- layer.setFillExtrusionTranslateTransition(options);
- assertEquals(layer.getFillExtrusionTranslateTransition(), options);
- });
+ assertNotNull(layer);
+
+ // Set and Get
+ TransitionOptions options = new TransitionOptions(300, 100);
+ layer.setFillExtrusionTranslateTransition(options);
+ assertEquals(layer.getFillExtrusionTranslateTransition(), options);
}
@Test
+ @UiThreadTest
public void testFillExtrusionTranslateAsConstant() {
- validateTestSetup();
- setupLayer();
Timber.i("fill-extrusion-translate");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getFillExtrusionTranslate().getValue());
-
- // Set and Get
- Float[] propertyValue = new Float[] {0f, 0f};
- layer.setProperties(fillExtrusionTranslate(propertyValue));
- assertEquals(layer.getFillExtrusionTranslate().getValue(), propertyValue);
- });
+ assertNotNull(layer);
+ assertNull(layer.getFillExtrusionTranslate().getValue());
+
+ // Set and Get
+ Float[] propertyValue = new Float[] {0f, 0f};
+ layer.setProperties(fillExtrusionTranslate(propertyValue));
+ assertEquals(layer.getFillExtrusionTranslate().getValue(), propertyValue);
}
@Test
+ @UiThreadTest
public void testFillExtrusionTranslateAnchorAsConstant() {
- validateTestSetup();
- setupLayer();
Timber.i("fill-extrusion-translate-anchor");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getFillExtrusionTranslateAnchor().getValue());
-
- // Set and Get
- String propertyValue = FILL_EXTRUSION_TRANSLATE_ANCHOR_MAP;
- layer.setProperties(fillExtrusionTranslateAnchor(propertyValue));
- assertEquals(layer.getFillExtrusionTranslateAnchor().getValue(), propertyValue);
- });
+ assertNotNull(layer);
+ assertNull(layer.getFillExtrusionTranslateAnchor().getValue());
+
+ // Set and Get
+ String propertyValue = FILL_EXTRUSION_TRANSLATE_ANCHOR_MAP;
+ layer.setProperties(fillExtrusionTranslateAnchor(propertyValue));
+ assertEquals(layer.getFillExtrusionTranslateAnchor().getValue(), propertyValue);
}
@Test
+ @UiThreadTest
public void testFillExtrusionPatternTransition() {
- validateTestSetup();
- setupLayer();
Timber.i("fill-extrusion-patternTransitionOptions");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
-
- // Set and Get
- TransitionOptions options = new TransitionOptions(300, 100);
- layer.setFillExtrusionPatternTransition(options);
- assertEquals(layer.getFillExtrusionPatternTransition(), options);
- });
+ assertNotNull(layer);
+
+ // Set and Get
+ TransitionOptions options = new TransitionOptions(300, 100);
+ layer.setFillExtrusionPatternTransition(options);
+ assertEquals(layer.getFillExtrusionPatternTransition(), options);
}
@Test
+ @UiThreadTest
public void testFillExtrusionPatternAsConstant() {
- validateTestSetup();
- setupLayer();
Timber.i("fill-extrusion-pattern");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getFillExtrusionPattern().getValue());
-
- // Set and Get
- String propertyValue = "pedestrian-polygon";
- layer.setProperties(fillExtrusionPattern(propertyValue));
- assertEquals(layer.getFillExtrusionPattern().getValue(), propertyValue);
- });
+ assertNotNull(layer);
+ assertNull(layer.getFillExtrusionPattern().getValue());
+
+ // Set and Get
+ String propertyValue = "pedestrian-polygon";
+ layer.setProperties(fillExtrusionPattern(propertyValue));
+ assertEquals(layer.getFillExtrusionPattern().getValue(), propertyValue);
}
@Test
+ @UiThreadTest
public void testFillExtrusionPatternAsExpression() {
- validateTestSetup();
- setupLayer();
Timber.i("fill-extrusion-pattern-expression");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getFillExtrusionPattern().getExpression());
-
- // Set and Get
- Expression expression = string(Expression.get("undefined"));
- layer.setProperties(fillExtrusionPattern(expression));
- assertEquals(layer.getFillExtrusionPattern().getExpression(), expression);
- });
+ assertNotNull(layer);
+ assertNull(layer.getFillExtrusionPattern().getExpression());
+
+ // Set and Get
+ Expression expression = string(Expression.get("undefined"));
+ layer.setProperties(fillExtrusionPattern(expression));
+ assertEquals(layer.getFillExtrusionPattern().getExpression(), expression);
}
@Test
+ @UiThreadTest
public void testFillExtrusionHeightTransition() {
- validateTestSetup();
- setupLayer();
Timber.i("fill-extrusion-heightTransitionOptions");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
-
- // Set and Get
- TransitionOptions options = new TransitionOptions(300, 100);
- layer.setFillExtrusionHeightTransition(options);
- assertEquals(layer.getFillExtrusionHeightTransition(), options);
- });
+ assertNotNull(layer);
+
+ // Set and Get
+ TransitionOptions options = new TransitionOptions(300, 100);
+ layer.setFillExtrusionHeightTransition(options);
+ assertEquals(layer.getFillExtrusionHeightTransition(), options);
}
@Test
+ @UiThreadTest
public void testFillExtrusionHeightAsConstant() {
- validateTestSetup();
- setupLayer();
Timber.i("fill-extrusion-height");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getFillExtrusionHeight().getValue());
-
- // Set and Get
- Float propertyValue = 0.3f;
- layer.setProperties(fillExtrusionHeight(propertyValue));
- assertEquals(layer.getFillExtrusionHeight().getValue(), propertyValue);
- });
+ assertNotNull(layer);
+ assertNull(layer.getFillExtrusionHeight().getValue());
+
+ // Set and Get
+ Float propertyValue = 0.3f;
+ layer.setProperties(fillExtrusionHeight(propertyValue));
+ assertEquals(layer.getFillExtrusionHeight().getValue(), propertyValue);
}
@Test
+ @UiThreadTest
public void testFillExtrusionHeightAsExpression() {
- validateTestSetup();
- setupLayer();
Timber.i("fill-extrusion-height-expression");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getFillExtrusionHeight().getExpression());
-
- // Set and Get
- Expression expression = number(Expression.get("undefined"));
- layer.setProperties(fillExtrusionHeight(expression));
- assertEquals(layer.getFillExtrusionHeight().getExpression(), expression);
- });
+ assertNotNull(layer);
+ assertNull(layer.getFillExtrusionHeight().getExpression());
+
+ // Set and Get
+ Expression expression = number(Expression.get("undefined"));
+ layer.setProperties(fillExtrusionHeight(expression));
+ assertEquals(layer.getFillExtrusionHeight().getExpression(), expression);
}
@Test
+ @UiThreadTest
public void testFillExtrusionBaseTransition() {
- validateTestSetup();
- setupLayer();
Timber.i("fill-extrusion-baseTransitionOptions");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
-
- // Set and Get
- TransitionOptions options = new TransitionOptions(300, 100);
- layer.setFillExtrusionBaseTransition(options);
- assertEquals(layer.getFillExtrusionBaseTransition(), options);
- });
+ assertNotNull(layer);
+
+ // Set and Get
+ TransitionOptions options = new TransitionOptions(300, 100);
+ layer.setFillExtrusionBaseTransition(options);
+ assertEquals(layer.getFillExtrusionBaseTransition(), options);
}
@Test
+ @UiThreadTest
public void testFillExtrusionBaseAsConstant() {
- validateTestSetup();
- setupLayer();
Timber.i("fill-extrusion-base");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getFillExtrusionBase().getValue());
-
- // Set and Get
- Float propertyValue = 0.3f;
- layer.setProperties(fillExtrusionBase(propertyValue));
- assertEquals(layer.getFillExtrusionBase().getValue(), propertyValue);
- });
+ assertNotNull(layer);
+ assertNull(layer.getFillExtrusionBase().getValue());
+
+ // Set and Get
+ Float propertyValue = 0.3f;
+ layer.setProperties(fillExtrusionBase(propertyValue));
+ assertEquals(layer.getFillExtrusionBase().getValue(), propertyValue);
}
@Test
+ @UiThreadTest
public void testFillExtrusionBaseAsExpression() {
- validateTestSetup();
- setupLayer();
Timber.i("fill-extrusion-base-expression");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getFillExtrusionBase().getExpression());
-
- // Set and Get
- Expression expression = number(Expression.get("undefined"));
- layer.setProperties(fillExtrusionBase(expression));
- assertEquals(layer.getFillExtrusionBase().getExpression(), expression);
- });
+ assertNotNull(layer);
+ assertNull(layer.getFillExtrusionBase().getExpression());
+
+ // Set and Get
+ Expression expression = number(Expression.get("undefined"));
+ layer.setProperties(fillExtrusionBase(expression));
+ assertEquals(layer.getFillExtrusionBase().getExpression(), expression);
}
@Test
+ @UiThreadTest
public void testFillExtrusionVerticalGradientAsConstant() {
- validateTestSetup();
- setupLayer();
Timber.i("fill-extrusion-vertical-gradient");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getFillExtrusionVerticalGradient().getValue());
-
- // Set and Get
- Boolean propertyValue = true;
- layer.setProperties(fillExtrusionVerticalGradient(propertyValue));
- assertEquals(layer.getFillExtrusionVerticalGradient().getValue(), propertyValue);
- });
+ assertNotNull(layer);
+ assertNull(layer.getFillExtrusionVerticalGradient().getValue());
+
+ // Set and Get
+ Boolean propertyValue = true;
+ layer.setProperties(fillExtrusionVerticalGradient(propertyValue));
+ assertEquals(layer.getFillExtrusionVerticalGradient().getValue(), propertyValue);
}
}
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 98a39790dd..dce5633fc8 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,401 +3,324 @@
package com.mapbox.mapboxsdk.testapp.style;
import android.graphics.Color;
+import android.support.test.annotation.UiThreadTest;
import android.support.test.runner.AndroidJUnit4;
+import com.mapbox.mapboxsdk.maps.BaseLayerTest;
+import org.junit.Before;
import timber.log.Timber;
import com.mapbox.mapboxsdk.style.expressions.Expression;
import com.mapbox.mapboxsdk.style.layers.FillLayer;
-import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest;
import org.junit.Test;
import org.junit.runner.RunWith;
import static com.mapbox.mapboxsdk.style.expressions.Expression.*;
-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.*;
import com.mapbox.mapboxsdk.style.layers.TransitionOptions;
-import com.mapbox.mapboxsdk.testapp.activity.espresso.EspressoTestActivity;
/**
* Basic smoke tests for FillLayer
*/
@RunWith(AndroidJUnit4.class)
-public class FillLayerTest extends BaseActivityTest {
+public class FillLayerTest extends BaseLayerTest {
private FillLayer layer;
- @Override
- protected Class getActivityClass() {
- return EspressoTestActivity.class;
- }
-
- private void setupLayer() {
- Timber.i("Retrieving layer");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- if ((layer = mapboxMap.getStyle().getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new FillLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.getStyle().addLayer(layer);
- // Layer reference is now stale, get new reference
- layer = mapboxMap.getStyle().getLayerAs("my-layer");
- }
- });
+ @Before
+ @UiThreadTest
+ public void beforeTest(){
+ super.before();
+ layer = new FillLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ setupLayer(layer);
}
@Test
+ @UiThreadTest
public void testSourceId() {
- validateTestSetup();
- setupLayer();
Timber.i("SourceId");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- // Get source id
- assertEquals(layer.getSourceId(), "composite");
- });
+ assertNotNull(layer);
+ assertEquals(layer.getSourceId(), "composite");
}
@Test
+ @UiThreadTest
public void testSetVisibility() {
- validateTestSetup();
- setupLayer();
Timber.i("Visibility");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
+ 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
+ @UiThreadTest
public void testSourceLayer() {
- validateTestSetup();
- setupLayer();
Timber.i("SourceLayer");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
+ 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
+ @UiThreadTest
public void testFilter() {
- validateTestSetup();
- setupLayer();
Timber.i("Filter");
- invoke(mapboxMap, (uiController, mapboxMap1) -> {
- assertNotNull(layer);
-
- // Get initial
- assertEquals(layer.getFilter(), null);
-
- // Set
- Expression filter = eq(get("undefined"), literal(1.0));
- layer.setFilter(filter);
- assertEquals(layer.getFilter().toString(), filter.toString());
-
- // Set constant
- filter = literal(true);
- layer.setFilter(filter);
- assertEquals(layer.getFilter().toString(), filter.toString());
- });
+ assertNotNull(layer);
+
+ // Get initial
+ assertEquals(layer.getFilter(), null);
+
+ // Set
+ Expression filter = eq(get("undefined"), literal(1.0));
+ layer.setFilter(filter);
+ assertEquals(layer.getFilter().toString(), filter.toString());
+
+ // Set constant
+ filter = literal(true);
+ layer.setFilter(filter);
+ assertEquals(layer.getFilter().toString(), filter.toString());
}
@Test
+ @UiThreadTest
public void testFillAntialiasAsConstant() {
- validateTestSetup();
- setupLayer();
Timber.i("fill-antialias");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getFillAntialias().getValue());
-
- // Set and Get
- Boolean propertyValue = true;
- layer.setProperties(fillAntialias(propertyValue));
- assertEquals(layer.getFillAntialias().getValue(), propertyValue);
- });
+ assertNotNull(layer);
+ assertNull(layer.getFillAntialias().getValue());
+
+ // Set and Get
+ Boolean propertyValue = true;
+ layer.setProperties(fillAntialias(propertyValue));
+ assertEquals(layer.getFillAntialias().getValue(), propertyValue);
}
@Test
+ @UiThreadTest
public void testFillOpacityTransition() {
- validateTestSetup();
- setupLayer();
Timber.i("fill-opacityTransitionOptions");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
-
- // Set and Get
- TransitionOptions options = new TransitionOptions(300, 100);
- layer.setFillOpacityTransition(options);
- assertEquals(layer.getFillOpacityTransition(), options);
- });
+ assertNotNull(layer);
+
+ // Set and Get
+ TransitionOptions options = new TransitionOptions(300, 100);
+ layer.setFillOpacityTransition(options);
+ assertEquals(layer.getFillOpacityTransition(), options);
}
@Test
+ @UiThreadTest
public void testFillOpacityAsConstant() {
- validateTestSetup();
- setupLayer();
Timber.i("fill-opacity");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getFillOpacity().getValue());
-
- // Set and Get
- Float propertyValue = 0.3f;
- layer.setProperties(fillOpacity(propertyValue));
- assertEquals(layer.getFillOpacity().getValue(), propertyValue);
- });
+ assertNotNull(layer);
+ assertNull(layer.getFillOpacity().getValue());
+
+ // Set and Get
+ Float propertyValue = 0.3f;
+ layer.setProperties(fillOpacity(propertyValue));
+ assertEquals(layer.getFillOpacity().getValue(), propertyValue);
}
@Test
+ @UiThreadTest
public void testFillOpacityAsExpression() {
- validateTestSetup();
- setupLayer();
Timber.i("fill-opacity-expression");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getFillOpacity().getExpression());
-
- // Set and Get
- Expression expression = number(Expression.get("undefined"));
- layer.setProperties(fillOpacity(expression));
- assertEquals(layer.getFillOpacity().getExpression(), expression);
- });
+ assertNotNull(layer);
+ assertNull(layer.getFillOpacity().getExpression());
+
+ // Set and Get
+ Expression expression = number(Expression.get("undefined"));
+ layer.setProperties(fillOpacity(expression));
+ assertEquals(layer.getFillOpacity().getExpression(), expression);
}
@Test
+ @UiThreadTest
public void testFillColorTransition() {
- validateTestSetup();
- setupLayer();
Timber.i("fill-colorTransitionOptions");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
-
- // Set and Get
- TransitionOptions options = new TransitionOptions(300, 100);
- layer.setFillColorTransition(options);
- assertEquals(layer.getFillColorTransition(), options);
- });
+ assertNotNull(layer);
+
+ // Set and Get
+ TransitionOptions options = new TransitionOptions(300, 100);
+ layer.setFillColorTransition(options);
+ assertEquals(layer.getFillColorTransition(), options);
}
@Test
+ @UiThreadTest
public void testFillColorAsConstant() {
- validateTestSetup();
- setupLayer();
Timber.i("fill-color");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getFillColor().getValue());
-
- // Set and Get
- String propertyValue = "rgba(0, 0, 0, 1)";
- layer.setProperties(fillColor(propertyValue));
- assertEquals(layer.getFillColor().getValue(), propertyValue);
- });
+ assertNotNull(layer);
+ assertNull(layer.getFillColor().getValue());
+
+ // Set and Get
+ String propertyValue = "rgba(0, 0, 0, 1)";
+ layer.setProperties(fillColor(propertyValue));
+ assertEquals(layer.getFillColor().getValue(), propertyValue);
}
@Test
+ @UiThreadTest
public void testFillColorAsExpression() {
- validateTestSetup();
- setupLayer();
Timber.i("fill-color-expression");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getFillColor().getExpression());
-
- // Set and Get
- Expression expression = toColor(Expression.get("undefined"));
- layer.setProperties(fillColor(expression));
- assertEquals(layer.getFillColor().getExpression(), expression);
- });
+ assertNotNull(layer);
+ assertNull(layer.getFillColor().getExpression());
+
+ // Set and Get
+ Expression expression = toColor(Expression.get("undefined"));
+ layer.setProperties(fillColor(expression));
+ assertEquals(layer.getFillColor().getExpression(), expression);
}
@Test
+ @UiThreadTest
public void testFillColorAsIntConstant() {
- validateTestSetup();
- setupLayer();
Timber.i("fill-color");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
+ 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
+ @UiThreadTest
public void testFillOutlineColorTransition() {
- validateTestSetup();
- setupLayer();
Timber.i("fill-outline-colorTransitionOptions");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
-
- // Set and Get
- TransitionOptions options = new TransitionOptions(300, 100);
- layer.setFillOutlineColorTransition(options);
- assertEquals(layer.getFillOutlineColorTransition(), options);
- });
+ assertNotNull(layer);
+
+ // Set and Get
+ TransitionOptions options = new TransitionOptions(300, 100);
+ layer.setFillOutlineColorTransition(options);
+ assertEquals(layer.getFillOutlineColorTransition(), options);
}
@Test
+ @UiThreadTest
public void testFillOutlineColorAsConstant() {
- validateTestSetup();
- setupLayer();
Timber.i("fill-outline-color");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getFillOutlineColor().getValue());
-
- // Set and Get
- String propertyValue = "rgba(0, 0, 0, 1)";
- layer.setProperties(fillOutlineColor(propertyValue));
- assertEquals(layer.getFillOutlineColor().getValue(), propertyValue);
- });
+ assertNotNull(layer);
+ assertNull(layer.getFillOutlineColor().getValue());
+
+ // Set and Get
+ String propertyValue = "rgba(0, 0, 0, 1)";
+ layer.setProperties(fillOutlineColor(propertyValue));
+ assertEquals(layer.getFillOutlineColor().getValue(), propertyValue);
}
@Test
+ @UiThreadTest
public void testFillOutlineColorAsExpression() {
- validateTestSetup();
- setupLayer();
Timber.i("fill-outline-color-expression");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getFillOutlineColor().getExpression());
-
- // Set and Get
- Expression expression = toColor(Expression.get("undefined"));
- layer.setProperties(fillOutlineColor(expression));
- assertEquals(layer.getFillOutlineColor().getExpression(), expression);
- });
+ assertNotNull(layer);
+ assertNull(layer.getFillOutlineColor().getExpression());
+
+ // Set and Get
+ Expression expression = toColor(Expression.get("undefined"));
+ layer.setProperties(fillOutlineColor(expression));
+ assertEquals(layer.getFillOutlineColor().getExpression(), expression);
}
@Test
+ @UiThreadTest
public void testFillOutlineColorAsIntConstant() {
- validateTestSetup();
- setupLayer();
Timber.i("fill-outline-color");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
+ 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
+ @UiThreadTest
public void testFillTranslateTransition() {
- validateTestSetup();
- setupLayer();
Timber.i("fill-translateTransitionOptions");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
-
- // Set and Get
- TransitionOptions options = new TransitionOptions(300, 100);
- layer.setFillTranslateTransition(options);
- assertEquals(layer.getFillTranslateTransition(), options);
- });
+ assertNotNull(layer);
+
+ // Set and Get
+ TransitionOptions options = new TransitionOptions(300, 100);
+ layer.setFillTranslateTransition(options);
+ assertEquals(layer.getFillTranslateTransition(), options);
}
@Test
+ @UiThreadTest
public void testFillTranslateAsConstant() {
- validateTestSetup();
- setupLayer();
Timber.i("fill-translate");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getFillTranslate().getValue());
-
- // Set and Get
- Float[] propertyValue = new Float[] {0f, 0f};
- layer.setProperties(fillTranslate(propertyValue));
- assertEquals(layer.getFillTranslate().getValue(), propertyValue);
- });
+ assertNotNull(layer);
+ assertNull(layer.getFillTranslate().getValue());
+
+ // Set and Get
+ Float[] propertyValue = new Float[] {0f, 0f};
+ layer.setProperties(fillTranslate(propertyValue));
+ assertEquals(layer.getFillTranslate().getValue(), propertyValue);
}
@Test
+ @UiThreadTest
public void testFillTranslateAnchorAsConstant() {
- validateTestSetup();
- setupLayer();
Timber.i("fill-translate-anchor");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getFillTranslateAnchor().getValue());
-
- // Set and Get
- String propertyValue = FILL_TRANSLATE_ANCHOR_MAP;
- layer.setProperties(fillTranslateAnchor(propertyValue));
- assertEquals(layer.getFillTranslateAnchor().getValue(), propertyValue);
- });
+ assertNotNull(layer);
+ assertNull(layer.getFillTranslateAnchor().getValue());
+
+ // Set and Get
+ String propertyValue = FILL_TRANSLATE_ANCHOR_MAP;
+ layer.setProperties(fillTranslateAnchor(propertyValue));
+ assertEquals(layer.getFillTranslateAnchor().getValue(), propertyValue);
}
@Test
+ @UiThreadTest
public void testFillPatternTransition() {
- validateTestSetup();
- setupLayer();
Timber.i("fill-patternTransitionOptions");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
-
- // Set and Get
- TransitionOptions options = new TransitionOptions(300, 100);
- layer.setFillPatternTransition(options);
- assertEquals(layer.getFillPatternTransition(), options);
- });
+ assertNotNull(layer);
+
+ // Set and Get
+ TransitionOptions options = new TransitionOptions(300, 100);
+ layer.setFillPatternTransition(options);
+ assertEquals(layer.getFillPatternTransition(), options);
}
@Test
+ @UiThreadTest
public void testFillPatternAsConstant() {
- validateTestSetup();
- setupLayer();
Timber.i("fill-pattern");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getFillPattern().getValue());
-
- // Set and Get
- String propertyValue = "pedestrian-polygon";
- layer.setProperties(fillPattern(propertyValue));
- assertEquals(layer.getFillPattern().getValue(), propertyValue);
- });
+ assertNotNull(layer);
+ assertNull(layer.getFillPattern().getValue());
+
+ // Set and Get
+ String propertyValue = "pedestrian-polygon";
+ layer.setProperties(fillPattern(propertyValue));
+ assertEquals(layer.getFillPattern().getValue(), propertyValue);
}
@Test
+ @UiThreadTest
public void testFillPatternAsExpression() {
- validateTestSetup();
- setupLayer();
Timber.i("fill-pattern-expression");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getFillPattern().getExpression());
-
- // Set and Get
- Expression expression = string(Expression.get("undefined"));
- layer.setProperties(fillPattern(expression));
- assertEquals(layer.getFillPattern().getExpression(), expression);
- });
+ assertNotNull(layer);
+ assertNull(layer.getFillPattern().getExpression());
+
+ // Set and Get
+ Expression expression = string(Expression.get("undefined"));
+ layer.setProperties(fillPattern(expression));
+ assertEquals(layer.getFillPattern().getExpression(), expression);
}
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/HeatmapLayerTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/HeatmapLayerTest.java
index 417197ee83..21a17723db 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/HeatmapLayerTest.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/HeatmapLayerTest.java
@@ -3,263 +3,213 @@
package com.mapbox.mapboxsdk.testapp.style;
import android.graphics.Color;
+import android.support.test.annotation.UiThreadTest;
import android.support.test.runner.AndroidJUnit4;
+import com.mapbox.mapboxsdk.maps.BaseLayerTest;
+import org.junit.Before;
import timber.log.Timber;
import com.mapbox.mapboxsdk.style.expressions.Expression;
import com.mapbox.mapboxsdk.style.layers.HeatmapLayer;
-import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest;
import org.junit.Test;
import org.junit.runner.RunWith;
import static com.mapbox.mapboxsdk.style.expressions.Expression.*;
-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.*;
import com.mapbox.mapboxsdk.style.layers.TransitionOptions;
-import com.mapbox.mapboxsdk.testapp.activity.espresso.EspressoTestActivity;
/**
* Basic smoke tests for HeatmapLayer
*/
@RunWith(AndroidJUnit4.class)
-public class HeatmapLayerTest extends BaseActivityTest {
+public class HeatmapLayerTest extends BaseLayerTest {
private HeatmapLayer layer;
- @Override
- protected Class getActivityClass() {
- return EspressoTestActivity.class;
- }
-
- private void setupLayer() {
- Timber.i("Retrieving layer");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- if ((layer = mapboxMap.getStyle().getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new HeatmapLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.getStyle().addLayer(layer);
- // Layer reference is now stale, get new reference
- layer = mapboxMap.getStyle().getLayerAs("my-layer");
- }
- });
+ @Before
+ @UiThreadTest
+ public void beforeTest(){
+ super.before();
+ layer = new HeatmapLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ setupLayer(layer);
}
@Test
+ @UiThreadTest
public void testSourceId() {
- validateTestSetup();
- setupLayer();
Timber.i("SourceId");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- // Get source id
- assertEquals(layer.getSourceId(), "composite");
- });
+ assertNotNull(layer);
+ assertEquals(layer.getSourceId(), "composite");
}
@Test
+ @UiThreadTest
public void testSetVisibility() {
- validateTestSetup();
- setupLayer();
Timber.i("Visibility");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
+ 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
+ @UiThreadTest
public void testSourceLayer() {
- validateTestSetup();
- setupLayer();
Timber.i("SourceLayer");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
+ 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
+ @UiThreadTest
public void testFilter() {
- validateTestSetup();
- setupLayer();
Timber.i("Filter");
- invoke(mapboxMap, (uiController, mapboxMap1) -> {
- assertNotNull(layer);
-
- // Get initial
- assertEquals(layer.getFilter(), null);
-
- // Set
- Expression filter = eq(get("undefined"), literal(1.0));
- layer.setFilter(filter);
- assertEquals(layer.getFilter().toString(), filter.toString());
-
- // Set constant
- filter = literal(true);
- layer.setFilter(filter);
- assertEquals(layer.getFilter().toString(), filter.toString());
- });
+ assertNotNull(layer);
+
+ // Get initial
+ assertEquals(layer.getFilter(), null);
+
+ // Set
+ Expression filter = eq(get("undefined"), literal(1.0));
+ layer.setFilter(filter);
+ assertEquals(layer.getFilter().toString(), filter.toString());
+
+ // Set constant
+ filter = literal(true);
+ layer.setFilter(filter);
+ assertEquals(layer.getFilter().toString(), filter.toString());
}
@Test
+ @UiThreadTest
public void testHeatmapRadiusTransition() {
- validateTestSetup();
- setupLayer();
Timber.i("heatmap-radiusTransitionOptions");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
-
- // Set and Get
- TransitionOptions options = new TransitionOptions(300, 100);
- layer.setHeatmapRadiusTransition(options);
- assertEquals(layer.getHeatmapRadiusTransition(), options);
- });
+ assertNotNull(layer);
+
+ // Set and Get
+ TransitionOptions options = new TransitionOptions(300, 100);
+ layer.setHeatmapRadiusTransition(options);
+ assertEquals(layer.getHeatmapRadiusTransition(), options);
}
@Test
+ @UiThreadTest
public void testHeatmapRadiusAsConstant() {
- validateTestSetup();
- setupLayer();
Timber.i("heatmap-radius");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getHeatmapRadius().getValue());
-
- // Set and Get
- Float propertyValue = 0.3f;
- layer.setProperties(heatmapRadius(propertyValue));
- assertEquals(layer.getHeatmapRadius().getValue(), propertyValue);
- });
+ assertNotNull(layer);
+ assertNull(layer.getHeatmapRadius().getValue());
+
+ // Set and Get
+ Float propertyValue = 0.3f;
+ layer.setProperties(heatmapRadius(propertyValue));
+ assertEquals(layer.getHeatmapRadius().getValue(), propertyValue);
}
@Test
+ @UiThreadTest
public void testHeatmapRadiusAsExpression() {
- validateTestSetup();
- setupLayer();
Timber.i("heatmap-radius-expression");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getHeatmapRadius().getExpression());
-
- // Set and Get
- Expression expression = number(Expression.get("undefined"));
- layer.setProperties(heatmapRadius(expression));
- assertEquals(layer.getHeatmapRadius().getExpression(), expression);
- });
+ assertNotNull(layer);
+ assertNull(layer.getHeatmapRadius().getExpression());
+
+ // Set and Get
+ Expression expression = number(Expression.get("undefined"));
+ layer.setProperties(heatmapRadius(expression));
+ assertEquals(layer.getHeatmapRadius().getExpression(), expression);
}
@Test
+ @UiThreadTest
public void testHeatmapWeightAsConstant() {
- validateTestSetup();
- setupLayer();
Timber.i("heatmap-weight");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getHeatmapWeight().getValue());
-
- // Set and Get
- Float propertyValue = 0.3f;
- layer.setProperties(heatmapWeight(propertyValue));
- assertEquals(layer.getHeatmapWeight().getValue(), propertyValue);
- });
+ assertNotNull(layer);
+ assertNull(layer.getHeatmapWeight().getValue());
+
+ // Set and Get
+ Float propertyValue = 0.3f;
+ layer.setProperties(heatmapWeight(propertyValue));
+ assertEquals(layer.getHeatmapWeight().getValue(), propertyValue);
}
@Test
+ @UiThreadTest
public void testHeatmapWeightAsExpression() {
- validateTestSetup();
- setupLayer();
Timber.i("heatmap-weight-expression");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getHeatmapWeight().getExpression());
-
- // Set and Get
- Expression expression = number(Expression.get("undefined"));
- layer.setProperties(heatmapWeight(expression));
- assertEquals(layer.getHeatmapWeight().getExpression(), expression);
- });
+ assertNotNull(layer);
+ assertNull(layer.getHeatmapWeight().getExpression());
+
+ // Set and Get
+ Expression expression = number(Expression.get("undefined"));
+ layer.setProperties(heatmapWeight(expression));
+ assertEquals(layer.getHeatmapWeight().getExpression(), expression);
}
@Test
+ @UiThreadTest
public void testHeatmapIntensityTransition() {
- validateTestSetup();
- setupLayer();
Timber.i("heatmap-intensityTransitionOptions");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
-
- // Set and Get
- TransitionOptions options = new TransitionOptions(300, 100);
- layer.setHeatmapIntensityTransition(options);
- assertEquals(layer.getHeatmapIntensityTransition(), options);
- });
+ assertNotNull(layer);
+
+ // Set and Get
+ TransitionOptions options = new TransitionOptions(300, 100);
+ layer.setHeatmapIntensityTransition(options);
+ assertEquals(layer.getHeatmapIntensityTransition(), options);
}
@Test
+ @UiThreadTest
public void testHeatmapIntensityAsConstant() {
- validateTestSetup();
- setupLayer();
Timber.i("heatmap-intensity");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getHeatmapIntensity().getValue());
-
- // Set and Get
- Float propertyValue = 0.3f;
- layer.setProperties(heatmapIntensity(propertyValue));
- assertEquals(layer.getHeatmapIntensity().getValue(), propertyValue);
- });
+ assertNotNull(layer);
+ assertNull(layer.getHeatmapIntensity().getValue());
+
+ // Set and Get
+ Float propertyValue = 0.3f;
+ layer.setProperties(heatmapIntensity(propertyValue));
+ assertEquals(layer.getHeatmapIntensity().getValue(), propertyValue);
}
@Test
+ @UiThreadTest
public void testHeatmapOpacityTransition() {
- validateTestSetup();
- setupLayer();
Timber.i("heatmap-opacityTransitionOptions");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
-
- // Set and Get
- TransitionOptions options = new TransitionOptions(300, 100);
- layer.setHeatmapOpacityTransition(options);
- assertEquals(layer.getHeatmapOpacityTransition(), options);
- });
+ assertNotNull(layer);
+
+ // Set and Get
+ TransitionOptions options = new TransitionOptions(300, 100);
+ layer.setHeatmapOpacityTransition(options);
+ assertEquals(layer.getHeatmapOpacityTransition(), options);
}
@Test
+ @UiThreadTest
public void testHeatmapOpacityAsConstant() {
- validateTestSetup();
- setupLayer();
Timber.i("heatmap-opacity");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getHeatmapOpacity().getValue());
-
- // Set and Get
- Float propertyValue = 0.3f;
- layer.setProperties(heatmapOpacity(propertyValue));
- assertEquals(layer.getHeatmapOpacity().getValue(), propertyValue);
- });
+ assertNotNull(layer);
+ assertNull(layer.getHeatmapOpacity().getValue());
+
+ // Set and Get
+ Float propertyValue = 0.3f;
+ layer.setProperties(heatmapOpacity(propertyValue));
+ assertEquals(layer.getHeatmapOpacity().getValue(), propertyValue);
}
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/HillshadeLayerTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/HillshadeLayerTest.java
index 1259489bc0..a01d562cf9 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/HillshadeLayerTest.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/HillshadeLayerTest.java
@@ -3,277 +3,221 @@
package com.mapbox.mapboxsdk.testapp.style;
import android.graphics.Color;
+import android.support.test.annotation.UiThreadTest;
import android.support.test.runner.AndroidJUnit4;
+import com.mapbox.mapboxsdk.maps.BaseLayerTest;
+import org.junit.Before;
import timber.log.Timber;
import com.mapbox.mapboxsdk.style.expressions.Expression;
import com.mapbox.mapboxsdk.style.layers.HillshadeLayer;
-import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest;
import org.junit.Test;
import org.junit.runner.RunWith;
import static com.mapbox.mapboxsdk.style.expressions.Expression.*;
-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.*;
import com.mapbox.mapboxsdk.style.layers.TransitionOptions;
-import com.mapbox.mapboxsdk.testapp.activity.espresso.EspressoTestActivity;
/**
* Basic smoke tests for HillshadeLayer
*/
@RunWith(AndroidJUnit4.class)
-public class HillshadeLayerTest extends BaseActivityTest {
+public class HillshadeLayerTest extends BaseLayerTest {
private HillshadeLayer layer;
- @Override
- protected Class getActivityClass() {
- return EspressoTestActivity.class;
- }
-
- private void setupLayer() {
- Timber.i("Retrieving layer");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- if ((layer = mapboxMap.getStyle().getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new HillshadeLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.getStyle().addLayer(layer);
- // Layer reference is now stale, get new reference
- layer = mapboxMap.getStyle().getLayerAs("my-layer");
- }
- });
+ @Before
+ @UiThreadTest
+ public void beforeTest(){
+ super.before();
+ layer = new HillshadeLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ setupLayer(layer);
}
@Test
+ @UiThreadTest
public void testSourceId() {
- validateTestSetup();
- setupLayer();
Timber.i("SourceId");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- // Get source id
- assertEquals(layer.getSourceId(), "composite");
- });
+ assertNotNull(layer);
+ assertEquals(layer.getSourceId(), "composite");
}
@Test
+ @UiThreadTest
public void testSetVisibility() {
- validateTestSetup();
- setupLayer();
Timber.i("Visibility");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
+ 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
+ @UiThreadTest
public void testHillshadeIlluminationDirectionAsConstant() {
- validateTestSetup();
- setupLayer();
Timber.i("hillshade-illumination-direction");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getHillshadeIlluminationDirection().getValue());
-
- // Set and Get
- Float propertyValue = 0.3f;
- layer.setProperties(hillshadeIlluminationDirection(propertyValue));
- assertEquals(layer.getHillshadeIlluminationDirection().getValue(), propertyValue);
- });
+ assertNotNull(layer);
+ assertNull(layer.getHillshadeIlluminationDirection().getValue());
+
+ // Set and Get
+ Float propertyValue = 0.3f;
+ layer.setProperties(hillshadeIlluminationDirection(propertyValue));
+ assertEquals(layer.getHillshadeIlluminationDirection().getValue(), propertyValue);
}
@Test
+ @UiThreadTest
public void testHillshadeIlluminationAnchorAsConstant() {
- validateTestSetup();
- setupLayer();
Timber.i("hillshade-illumination-anchor");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getHillshadeIlluminationAnchor().getValue());
-
- // Set and Get
- String propertyValue = HILLSHADE_ILLUMINATION_ANCHOR_MAP;
- layer.setProperties(hillshadeIlluminationAnchor(propertyValue));
- assertEquals(layer.getHillshadeIlluminationAnchor().getValue(), propertyValue);
- });
+ assertNotNull(layer);
+ assertNull(layer.getHillshadeIlluminationAnchor().getValue());
+
+ // Set and Get
+ String propertyValue = HILLSHADE_ILLUMINATION_ANCHOR_MAP;
+ layer.setProperties(hillshadeIlluminationAnchor(propertyValue));
+ assertEquals(layer.getHillshadeIlluminationAnchor().getValue(), propertyValue);
}
@Test
+ @UiThreadTest
public void testHillshadeExaggerationTransition() {
- validateTestSetup();
- setupLayer();
Timber.i("hillshade-exaggerationTransitionOptions");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
-
- // Set and Get
- TransitionOptions options = new TransitionOptions(300, 100);
- layer.setHillshadeExaggerationTransition(options);
- assertEquals(layer.getHillshadeExaggerationTransition(), options);
- });
+ assertNotNull(layer);
+
+ // Set and Get
+ TransitionOptions options = new TransitionOptions(300, 100);
+ layer.setHillshadeExaggerationTransition(options);
+ assertEquals(layer.getHillshadeExaggerationTransition(), options);
}
@Test
+ @UiThreadTest
public void testHillshadeExaggerationAsConstant() {
- validateTestSetup();
- setupLayer();
Timber.i("hillshade-exaggeration");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getHillshadeExaggeration().getValue());
-
- // Set and Get
- Float propertyValue = 0.3f;
- layer.setProperties(hillshadeExaggeration(propertyValue));
- assertEquals(layer.getHillshadeExaggeration().getValue(), propertyValue);
- });
+ assertNotNull(layer);
+ assertNull(layer.getHillshadeExaggeration().getValue());
+
+ // Set and Get
+ Float propertyValue = 0.3f;
+ layer.setProperties(hillshadeExaggeration(propertyValue));
+ assertEquals(layer.getHillshadeExaggeration().getValue(), propertyValue);
}
@Test
+ @UiThreadTest
public void testHillshadeShadowColorTransition() {
- validateTestSetup();
- setupLayer();
Timber.i("hillshade-shadow-colorTransitionOptions");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
-
- // Set and Get
- TransitionOptions options = new TransitionOptions(300, 100);
- layer.setHillshadeShadowColorTransition(options);
- assertEquals(layer.getHillshadeShadowColorTransition(), options);
- });
+ assertNotNull(layer);
+
+ // Set and Get
+ TransitionOptions options = new TransitionOptions(300, 100);
+ layer.setHillshadeShadowColorTransition(options);
+ assertEquals(layer.getHillshadeShadowColorTransition(), options);
}
@Test
+ @UiThreadTest
public void testHillshadeShadowColorAsConstant() {
- validateTestSetup();
- setupLayer();
Timber.i("hillshade-shadow-color");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getHillshadeShadowColor().getValue());
-
- // Set and Get
- String propertyValue = "rgba(0, 0, 0, 1)";
- layer.setProperties(hillshadeShadowColor(propertyValue));
- assertEquals(layer.getHillshadeShadowColor().getValue(), propertyValue);
- });
+ assertNotNull(layer);
+ assertNull(layer.getHillshadeShadowColor().getValue());
+
+ // Set and Get
+ String propertyValue = "rgba(0, 0, 0, 1)";
+ layer.setProperties(hillshadeShadowColor(propertyValue));
+ assertEquals(layer.getHillshadeShadowColor().getValue(), propertyValue);
}
@Test
+ @UiThreadTest
public void testHillshadeShadowColorAsIntConstant() {
- validateTestSetup();
- setupLayer();
Timber.i("hillshade-shadow-color");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
+ assertNotNull(layer);
- // Set and Get
- layer.setProperties(hillshadeShadowColor(Color.RED));
- assertEquals(layer.getHillshadeShadowColorAsInt(), Color.RED);
- });
+ // Set and Get
+ layer.setProperties(hillshadeShadowColor(Color.RED));
+ assertEquals(layer.getHillshadeShadowColorAsInt(), Color.RED);
}
@Test
+ @UiThreadTest
public void testHillshadeHighlightColorTransition() {
- validateTestSetup();
- setupLayer();
Timber.i("hillshade-highlight-colorTransitionOptions");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
-
- // Set and Get
- TransitionOptions options = new TransitionOptions(300, 100);
- layer.setHillshadeHighlightColorTransition(options);
- assertEquals(layer.getHillshadeHighlightColorTransition(), options);
- });
+ assertNotNull(layer);
+
+ // Set and Get
+ TransitionOptions options = new TransitionOptions(300, 100);
+ layer.setHillshadeHighlightColorTransition(options);
+ assertEquals(layer.getHillshadeHighlightColorTransition(), options);
}
@Test
+ @UiThreadTest
public void testHillshadeHighlightColorAsConstant() {
- validateTestSetup();
- setupLayer();
Timber.i("hillshade-highlight-color");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getHillshadeHighlightColor().getValue());
-
- // Set and Get
- String propertyValue = "rgba(0, 0, 0, 1)";
- layer.setProperties(hillshadeHighlightColor(propertyValue));
- assertEquals(layer.getHillshadeHighlightColor().getValue(), propertyValue);
- });
+ assertNotNull(layer);
+ assertNull(layer.getHillshadeHighlightColor().getValue());
+
+ // Set and Get
+ String propertyValue = "rgba(0, 0, 0, 1)";
+ layer.setProperties(hillshadeHighlightColor(propertyValue));
+ assertEquals(layer.getHillshadeHighlightColor().getValue(), propertyValue);
}
@Test
+ @UiThreadTest
public void testHillshadeHighlightColorAsIntConstant() {
- validateTestSetup();
- setupLayer();
Timber.i("hillshade-highlight-color");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
+ assertNotNull(layer);
- // Set and Get
- layer.setProperties(hillshadeHighlightColor(Color.RED));
- assertEquals(layer.getHillshadeHighlightColorAsInt(), Color.RED);
- });
+ // Set and Get
+ layer.setProperties(hillshadeHighlightColor(Color.RED));
+ assertEquals(layer.getHillshadeHighlightColorAsInt(), Color.RED);
}
@Test
+ @UiThreadTest
public void testHillshadeAccentColorTransition() {
- validateTestSetup();
- setupLayer();
Timber.i("hillshade-accent-colorTransitionOptions");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
-
- // Set and Get
- TransitionOptions options = new TransitionOptions(300, 100);
- layer.setHillshadeAccentColorTransition(options);
- assertEquals(layer.getHillshadeAccentColorTransition(), options);
- });
+ assertNotNull(layer);
+
+ // Set and Get
+ TransitionOptions options = new TransitionOptions(300, 100);
+ layer.setHillshadeAccentColorTransition(options);
+ assertEquals(layer.getHillshadeAccentColorTransition(), options);
}
@Test
+ @UiThreadTest
public void testHillshadeAccentColorAsConstant() {
- validateTestSetup();
- setupLayer();
Timber.i("hillshade-accent-color");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getHillshadeAccentColor().getValue());
-
- // Set and Get
- String propertyValue = "rgba(0, 0, 0, 1)";
- layer.setProperties(hillshadeAccentColor(propertyValue));
- assertEquals(layer.getHillshadeAccentColor().getValue(), propertyValue);
- });
+ assertNotNull(layer);
+ assertNull(layer.getHillshadeAccentColor().getValue());
+
+ // Set and Get
+ String propertyValue = "rgba(0, 0, 0, 1)";
+ layer.setProperties(hillshadeAccentColor(propertyValue));
+ assertEquals(layer.getHillshadeAccentColor().getValue(), propertyValue);
}
@Test
+ @UiThreadTest
public void testHillshadeAccentColorAsIntConstant() {
- validateTestSetup();
- setupLayer();
Timber.i("hillshade-accent-color");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
+ assertNotNull(layer);
- // Set and Get
- layer.setProperties(hillshadeAccentColor(Color.RED));
- assertEquals(layer.getHillshadeAccentColorAsInt(), Color.RED);
- });
+ // Set and Get
+ layer.setProperties(hillshadeAccentColor(Color.RED));
+ assertEquals(layer.getHillshadeAccentColorAsInt(), Color.RED);
}
}
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 f484095f25..06802cd9b5 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,607 +3,491 @@
package com.mapbox.mapboxsdk.testapp.style;
import android.graphics.Color;
+import android.support.test.annotation.UiThreadTest;
import android.support.test.runner.AndroidJUnit4;
+import com.mapbox.mapboxsdk.maps.BaseLayerTest;
+import org.junit.Before;
import timber.log.Timber;
import com.mapbox.mapboxsdk.style.expressions.Expression;
import com.mapbox.mapboxsdk.style.layers.LineLayer;
-import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest;
import org.junit.Test;
import org.junit.runner.RunWith;
import static com.mapbox.mapboxsdk.style.expressions.Expression.*;
-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.*;
import com.mapbox.mapboxsdk.style.layers.TransitionOptions;
-import com.mapbox.mapboxsdk.testapp.activity.espresso.EspressoTestActivity;
/**
* Basic smoke tests for LineLayer
*/
@RunWith(AndroidJUnit4.class)
-public class LineLayerTest extends BaseActivityTest {
+public class LineLayerTest extends BaseLayerTest {
private LineLayer layer;
- @Override
- protected Class getActivityClass() {
- return EspressoTestActivity.class;
- }
-
- private void setupLayer() {
- Timber.i("Retrieving layer");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- if ((layer = mapboxMap.getStyle().getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new LineLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.getStyle().addLayer(layer);
- // Layer reference is now stale, get new reference
- layer = mapboxMap.getStyle().getLayerAs("my-layer");
- }
- });
+ @Before
+ @UiThreadTest
+ public void beforeTest(){
+ super.before();
+ layer = new LineLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ setupLayer(layer);
}
@Test
+ @UiThreadTest
public void testSourceId() {
- validateTestSetup();
- setupLayer();
Timber.i("SourceId");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- // Get source id
- assertEquals(layer.getSourceId(), "composite");
- });
+ assertNotNull(layer);
+ assertEquals(layer.getSourceId(), "composite");
}
@Test
+ @UiThreadTest
public void testSetVisibility() {
- validateTestSetup();
- setupLayer();
Timber.i("Visibility");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
+ 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
+ @UiThreadTest
public void testSourceLayer() {
- validateTestSetup();
- setupLayer();
Timber.i("SourceLayer");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
+ 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
+ @UiThreadTest
public void testFilter() {
- validateTestSetup();
- setupLayer();
Timber.i("Filter");
- invoke(mapboxMap, (uiController, mapboxMap1) -> {
- assertNotNull(layer);
+ assertNotNull(layer);
- // Get initial
- assertEquals(layer.getFilter(), null);
+ // Get initial
+ assertEquals(layer.getFilter(), null);
- // Set
- Expression filter = eq(get("undefined"), literal(1.0));
- layer.setFilter(filter);
- assertEquals(layer.getFilter().toString(), filter.toString());
+ // Set
+ Expression filter = eq(get("undefined"), literal(1.0));
+ layer.setFilter(filter);
+ assertEquals(layer.getFilter().toString(), filter.toString());
- // Set constant
- filter = literal(true);
- layer.setFilter(filter);
- assertEquals(layer.getFilter().toString(), filter.toString());
- });
+ // Set constant
+ filter = literal(true);
+ layer.setFilter(filter);
+ assertEquals(layer.getFilter().toString(), filter.toString());
}
@Test
+ @UiThreadTest
public void testLineCapAsConstant() {
- validateTestSetup();
- setupLayer();
Timber.i("line-cap");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getLineCap().getValue());
+ assertNotNull(layer);
+ assertNull(layer.getLineCap().getValue());
- // Set and Get
- String propertyValue = LINE_CAP_BUTT;
- layer.setProperties(lineCap(propertyValue));
- assertEquals(layer.getLineCap().getValue(), propertyValue);
- });
+ // Set and Get
+ String propertyValue = LINE_CAP_BUTT;
+ layer.setProperties(lineCap(propertyValue));
+ assertEquals(layer.getLineCap().getValue(), propertyValue);
}
@Test
+ @UiThreadTest
public void testLineJoinAsConstant() {
- validateTestSetup();
- setupLayer();
Timber.i("line-join");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getLineJoin().getValue());
+ assertNotNull(layer);
+ assertNull(layer.getLineJoin().getValue());
- // Set and Get
- String propertyValue = LINE_JOIN_BEVEL;
- layer.setProperties(lineJoin(propertyValue));
- assertEquals(layer.getLineJoin().getValue(), propertyValue);
- });
+ // Set and Get
+ String propertyValue = LINE_JOIN_BEVEL;
+ layer.setProperties(lineJoin(propertyValue));
+ assertEquals(layer.getLineJoin().getValue(), propertyValue);
}
@Test
+ @UiThreadTest
public void testLineJoinAsExpression() {
- validateTestSetup();
- setupLayer();
Timber.i("line-join-expression");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getLineJoin().getExpression());
+ assertNotNull(layer);
+ assertNull(layer.getLineJoin().getExpression());
- // Set and Get
- Expression expression = string(Expression.get("undefined"));
- layer.setProperties(lineJoin(expression));
- assertEquals(layer.getLineJoin().getExpression(), expression);
- });
+ // Set and Get
+ Expression expression = string(Expression.get("undefined"));
+ layer.setProperties(lineJoin(expression));
+ assertEquals(layer.getLineJoin().getExpression(), expression);
}
@Test
+ @UiThreadTest
public void testLineMiterLimitAsConstant() {
- validateTestSetup();
- setupLayer();
Timber.i("line-miter-limit");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getLineMiterLimit().getValue());
+ assertNotNull(layer);
+ assertNull(layer.getLineMiterLimit().getValue());
- // Set and Get
- Float propertyValue = 0.3f;
- layer.setProperties(lineMiterLimit(propertyValue));
- assertEquals(layer.getLineMiterLimit().getValue(), propertyValue);
- });
+ // Set and Get
+ Float propertyValue = 0.3f;
+ layer.setProperties(lineMiterLimit(propertyValue));
+ assertEquals(layer.getLineMiterLimit().getValue(), propertyValue);
}
@Test
+ @UiThreadTest
public void testLineRoundLimitAsConstant() {
- validateTestSetup();
- setupLayer();
Timber.i("line-round-limit");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getLineRoundLimit().getValue());
+ assertNotNull(layer);
+ assertNull(layer.getLineRoundLimit().getValue());
- // Set and Get
- Float propertyValue = 0.3f;
- layer.setProperties(lineRoundLimit(propertyValue));
- assertEquals(layer.getLineRoundLimit().getValue(), propertyValue);
- });
+ // Set and Get
+ Float propertyValue = 0.3f;
+ layer.setProperties(lineRoundLimit(propertyValue));
+ assertEquals(layer.getLineRoundLimit().getValue(), propertyValue);
}
@Test
+ @UiThreadTest
public void testLineOpacityTransition() {
- validateTestSetup();
- setupLayer();
Timber.i("line-opacityTransitionOptions");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
+ 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
+ @UiThreadTest
public void testLineOpacityAsConstant() {
- validateTestSetup();
- setupLayer();
Timber.i("line-opacity");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getLineOpacity().getValue());
+ assertNotNull(layer);
+ assertNull(layer.getLineOpacity().getValue());
- // Set and Get
- Float propertyValue = 0.3f;
- layer.setProperties(lineOpacity(propertyValue));
- assertEquals(layer.getLineOpacity().getValue(), propertyValue);
- });
+ // Set and Get
+ Float propertyValue = 0.3f;
+ layer.setProperties(lineOpacity(propertyValue));
+ assertEquals(layer.getLineOpacity().getValue(), propertyValue);
}
@Test
+ @UiThreadTest
public void testLineOpacityAsExpression() {
- validateTestSetup();
- setupLayer();
Timber.i("line-opacity-expression");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getLineOpacity().getExpression());
+ assertNotNull(layer);
+ assertNull(layer.getLineOpacity().getExpression());
- // Set and Get
- Expression expression = number(Expression.get("undefined"));
- layer.setProperties(lineOpacity(expression));
- assertEquals(layer.getLineOpacity().getExpression(), expression);
- });
+ // Set and Get
+ Expression expression = number(Expression.get("undefined"));
+ layer.setProperties(lineOpacity(expression));
+ assertEquals(layer.getLineOpacity().getExpression(), expression);
}
@Test
+ @UiThreadTest
public void testLineColorTransition() {
- validateTestSetup();
- setupLayer();
Timber.i("line-colorTransitionOptions");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
+ 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
+ @UiThreadTest
public void testLineColorAsConstant() {
- validateTestSetup();
- setupLayer();
Timber.i("line-color");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getLineColor().getValue());
+ assertNotNull(layer);
+ assertNull(layer.getLineColor().getValue());
- // Set and Get
- String propertyValue = "rgba(0, 0, 0, 1)";
- layer.setProperties(lineColor(propertyValue));
- assertEquals(layer.getLineColor().getValue(), propertyValue);
- });
+ // Set and Get
+ String propertyValue = "rgba(0, 0, 0, 1)";
+ layer.setProperties(lineColor(propertyValue));
+ assertEquals(layer.getLineColor().getValue(), propertyValue);
}
@Test
+ @UiThreadTest
public void testLineColorAsExpression() {
- validateTestSetup();
- setupLayer();
Timber.i("line-color-expression");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getLineColor().getExpression());
+ assertNotNull(layer);
+ assertNull(layer.getLineColor().getExpression());
- // Set and Get
- Expression expression = toColor(Expression.get("undefined"));
- layer.setProperties(lineColor(expression));
- assertEquals(layer.getLineColor().getExpression(), expression);
- });
+ // Set and Get
+ Expression expression = toColor(Expression.get("undefined"));
+ layer.setProperties(lineColor(expression));
+ assertEquals(layer.getLineColor().getExpression(), expression);
}
@Test
+ @UiThreadTest
public void testLineColorAsIntConstant() {
- validateTestSetup();
- setupLayer();
Timber.i("line-color");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
+ 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
+ @UiThreadTest
public void testLineTranslateTransition() {
- validateTestSetup();
- setupLayer();
Timber.i("line-translateTransitionOptions");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
+ 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
+ @UiThreadTest
public void testLineTranslateAsConstant() {
- validateTestSetup();
- setupLayer();
Timber.i("line-translate");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getLineTranslate().getValue());
+ assertNotNull(layer);
+ assertNull(layer.getLineTranslate().getValue());
- // Set and Get
- Float[] propertyValue = new Float[] {0f, 0f};
- layer.setProperties(lineTranslate(propertyValue));
- assertEquals(layer.getLineTranslate().getValue(), propertyValue);
- });
+ // Set and Get
+ Float[] propertyValue = new Float[] {0f, 0f};
+ layer.setProperties(lineTranslate(propertyValue));
+ assertEquals(layer.getLineTranslate().getValue(), propertyValue);
}
@Test
+ @UiThreadTest
public void testLineTranslateAnchorAsConstant() {
- validateTestSetup();
- setupLayer();
Timber.i("line-translate-anchor");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getLineTranslateAnchor().getValue());
+ assertNotNull(layer);
+ assertNull(layer.getLineTranslateAnchor().getValue());
- // Set and Get
- String propertyValue = LINE_TRANSLATE_ANCHOR_MAP;
- layer.setProperties(lineTranslateAnchor(propertyValue));
- assertEquals(layer.getLineTranslateAnchor().getValue(), propertyValue);
- });
+ // Set and Get
+ String propertyValue = LINE_TRANSLATE_ANCHOR_MAP;
+ layer.setProperties(lineTranslateAnchor(propertyValue));
+ assertEquals(layer.getLineTranslateAnchor().getValue(), propertyValue);
}
@Test
+ @UiThreadTest
public void testLineWidthTransition() {
- validateTestSetup();
- setupLayer();
Timber.i("line-widthTransitionOptions");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
+ 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
+ @UiThreadTest
public void testLineWidthAsConstant() {
- validateTestSetup();
- setupLayer();
Timber.i("line-width");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getLineWidth().getValue());
+ assertNotNull(layer);
+ assertNull(layer.getLineWidth().getValue());
- // Set and Get
- Float propertyValue = 0.3f;
- layer.setProperties(lineWidth(propertyValue));
- assertEquals(layer.getLineWidth().getValue(), propertyValue);
- });
+ // Set and Get
+ Float propertyValue = 0.3f;
+ layer.setProperties(lineWidth(propertyValue));
+ assertEquals(layer.getLineWidth().getValue(), propertyValue);
}
@Test
+ @UiThreadTest
public void testLineWidthAsExpression() {
- validateTestSetup();
- setupLayer();
Timber.i("line-width-expression");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getLineWidth().getExpression());
+ assertNotNull(layer);
+ assertNull(layer.getLineWidth().getExpression());
- // Set and Get
- Expression expression = number(Expression.get("undefined"));
- layer.setProperties(lineWidth(expression));
- assertEquals(layer.getLineWidth().getExpression(), expression);
- });
+ // Set and Get
+ Expression expression = number(Expression.get("undefined"));
+ layer.setProperties(lineWidth(expression));
+ assertEquals(layer.getLineWidth().getExpression(), expression);
}
@Test
+ @UiThreadTest
public void testLineGapWidthTransition() {
- validateTestSetup();
- setupLayer();
Timber.i("line-gap-widthTransitionOptions");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
+ 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
+ @UiThreadTest
public void testLineGapWidthAsConstant() {
- validateTestSetup();
- setupLayer();
Timber.i("line-gap-width");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getLineGapWidth().getValue());
+ assertNotNull(layer);
+ assertNull(layer.getLineGapWidth().getValue());
- // Set and Get
- Float propertyValue = 0.3f;
- layer.setProperties(lineGapWidth(propertyValue));
- assertEquals(layer.getLineGapWidth().getValue(), propertyValue);
- });
+ // Set and Get
+ Float propertyValue = 0.3f;
+ layer.setProperties(lineGapWidth(propertyValue));
+ assertEquals(layer.getLineGapWidth().getValue(), propertyValue);
}
@Test
+ @UiThreadTest
public void testLineGapWidthAsExpression() {
- validateTestSetup();
- setupLayer();
Timber.i("line-gap-width-expression");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getLineGapWidth().getExpression());
+ assertNotNull(layer);
+ assertNull(layer.getLineGapWidth().getExpression());
- // Set and Get
- Expression expression = number(Expression.get("undefined"));
- layer.setProperties(lineGapWidth(expression));
- assertEquals(layer.getLineGapWidth().getExpression(), expression);
- });
+ // Set and Get
+ Expression expression = number(Expression.get("undefined"));
+ layer.setProperties(lineGapWidth(expression));
+ assertEquals(layer.getLineGapWidth().getExpression(), expression);
}
@Test
+ @UiThreadTest
public void testLineOffsetTransition() {
- validateTestSetup();
- setupLayer();
Timber.i("line-offsetTransitionOptions");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
+ 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
+ @UiThreadTest
public void testLineOffsetAsConstant() {
- validateTestSetup();
- setupLayer();
Timber.i("line-offset");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getLineOffset().getValue());
+ assertNotNull(layer);
+ assertNull(layer.getLineOffset().getValue());
- // Set and Get
- Float propertyValue = 0.3f;
- layer.setProperties(lineOffset(propertyValue));
- assertEquals(layer.getLineOffset().getValue(), propertyValue);
- });
+ // Set and Get
+ Float propertyValue = 0.3f;
+ layer.setProperties(lineOffset(propertyValue));
+ assertEquals(layer.getLineOffset().getValue(), propertyValue);
}
@Test
+ @UiThreadTest
public void testLineBlurTransition() {
- validateTestSetup();
- setupLayer();
Timber.i("line-blurTransitionOptions");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
+ 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
+ @UiThreadTest
public void testLineBlurAsConstant() {
- validateTestSetup();
- setupLayer();
Timber.i("line-blur");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getLineBlur().getValue());
+ assertNotNull(layer);
+ assertNull(layer.getLineBlur().getValue());
- // Set and Get
- Float propertyValue = 0.3f;
- layer.setProperties(lineBlur(propertyValue));
- assertEquals(layer.getLineBlur().getValue(), propertyValue);
- });
+ // Set and Get
+ Float propertyValue = 0.3f;
+ layer.setProperties(lineBlur(propertyValue));
+ assertEquals(layer.getLineBlur().getValue(), propertyValue);
}
@Test
+ @UiThreadTest
public void testLineBlurAsExpression() {
- validateTestSetup();
- setupLayer();
Timber.i("line-blur-expression");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getLineBlur().getExpression());
+ assertNotNull(layer);
+ assertNull(layer.getLineBlur().getExpression());
- // Set and Get
- Expression expression = number(Expression.get("undefined"));
- layer.setProperties(lineBlur(expression));
- assertEquals(layer.getLineBlur().getExpression(), expression);
- });
+ // Set and Get
+ Expression expression = number(Expression.get("undefined"));
+ layer.setProperties(lineBlur(expression));
+ assertEquals(layer.getLineBlur().getExpression(), expression);
}
@Test
+ @UiThreadTest
public void testLineDasharrayTransition() {
- validateTestSetup();
- setupLayer();
Timber.i("line-dasharrayTransitionOptions");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
+ 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
+ @UiThreadTest
public void testLineDasharrayAsConstant() {
- validateTestSetup();
- setupLayer();
Timber.i("line-dasharray");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getLineDasharray().getValue());
+ assertNotNull(layer);
+ assertNull(layer.getLineDasharray().getValue());
- // Set and Get
- Float[] propertyValue = new Float[] {};
- layer.setProperties(lineDasharray(propertyValue));
- assertEquals(layer.getLineDasharray().getValue(), propertyValue);
- });
+ // Set and Get
+ Float[] propertyValue = new Float[] {};
+ layer.setProperties(lineDasharray(propertyValue));
+ assertEquals(layer.getLineDasharray().getValue(), propertyValue);
}
@Test
+ @UiThreadTest
public void testLinePatternTransition() {
- validateTestSetup();
- setupLayer();
Timber.i("line-patternTransitionOptions");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
+ 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
+ @UiThreadTest
public void testLinePatternAsConstant() {
- validateTestSetup();
- setupLayer();
Timber.i("line-pattern");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getLinePattern().getValue());
+ assertNotNull(layer);
+ assertNull(layer.getLinePattern().getValue());
- // Set and Get
- String propertyValue = "pedestrian-polygon";
- layer.setProperties(linePattern(propertyValue));
- assertEquals(layer.getLinePattern().getValue(), propertyValue);
- });
+ // Set and Get
+ String propertyValue = "pedestrian-polygon";
+ layer.setProperties(linePattern(propertyValue));
+ assertEquals(layer.getLinePattern().getValue(), propertyValue);
}
@Test
+ @UiThreadTest
public void testLinePatternAsExpression() {
- validateTestSetup();
- setupLayer();
Timber.i("line-pattern-expression");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getLinePattern().getExpression());
-
- // Set and Get
- Expression expression = string(Expression.get("undefined"));
- layer.setProperties(linePattern(expression));
- assertEquals(layer.getLinePattern().getExpression(), expression);
- });
+ assertNotNull(layer);
+ assertNull(layer.getLinePattern().getExpression());
+
+ // Set and Get
+ Expression expression = string(Expression.get("undefined"));
+ layer.setProperties(linePattern(expression));
+ assertEquals(layer.getLinePattern().getExpression(), expression);
}
}
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 ae334fdf29..aa50b1fe52 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,297 +3,238 @@
package com.mapbox.mapboxsdk.testapp.style;
import android.graphics.Color;
+import android.support.test.annotation.UiThreadTest;
import android.support.test.runner.AndroidJUnit4;
+import com.mapbox.mapboxsdk.maps.BaseLayerTest;
+import org.junit.Before;
import timber.log.Timber;
import com.mapbox.mapboxsdk.style.expressions.Expression;
import com.mapbox.mapboxsdk.style.layers.RasterLayer;
-import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest;
import org.junit.Test;
import org.junit.runner.RunWith;
import static com.mapbox.mapboxsdk.style.expressions.Expression.*;
-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.*;
import com.mapbox.mapboxsdk.style.layers.TransitionOptions;
-import com.mapbox.mapboxsdk.testapp.activity.espresso.EspressoTestActivity;
/**
* Basic smoke tests for RasterLayer
*/
@RunWith(AndroidJUnit4.class)
-public class RasterLayerTest extends BaseActivityTest {
+public class RasterLayerTest extends BaseLayerTest {
private RasterLayer layer;
- @Override
- protected Class getActivityClass() {
- return EspressoTestActivity.class;
- }
-
- private void setupLayer() {
- Timber.i("Retrieving layer");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- if ((layer = mapboxMap.getStyle().getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new RasterLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.getStyle().addLayer(layer);
- // Layer reference is now stale, get new reference
- layer = mapboxMap.getStyle().getLayerAs("my-layer");
- }
- });
+ @Before
+ @UiThreadTest
+ public void beforeTest(){
+ super.before();
+ layer = new RasterLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ setupLayer(layer);
}
@Test
+ @UiThreadTest
public void testSourceId() {
- validateTestSetup();
- setupLayer();
Timber.i("SourceId");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- // Get source id
- assertEquals(layer.getSourceId(), "composite");
- });
+ assertNotNull(layer);
+ assertEquals(layer.getSourceId(), "composite");
}
@Test
+ @UiThreadTest
public void testSetVisibility() {
- validateTestSetup();
- setupLayer();
Timber.i("Visibility");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
+ 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
+ @UiThreadTest
public void testRasterOpacityTransition() {
- validateTestSetup();
- setupLayer();
Timber.i("raster-opacityTransitionOptions");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
-
- // Set and Get
- TransitionOptions options = new TransitionOptions(300, 100);
- layer.setRasterOpacityTransition(options);
- assertEquals(layer.getRasterOpacityTransition(), options);
- });
+ assertNotNull(layer);
+
+ // Set and Get
+ TransitionOptions options = new TransitionOptions(300, 100);
+ layer.setRasterOpacityTransition(options);
+ assertEquals(layer.getRasterOpacityTransition(), options);
}
@Test
+ @UiThreadTest
public void testRasterOpacityAsConstant() {
- validateTestSetup();
- setupLayer();
Timber.i("raster-opacity");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getRasterOpacity().getValue());
-
- // Set and Get
- Float propertyValue = 0.3f;
- layer.setProperties(rasterOpacity(propertyValue));
- assertEquals(layer.getRasterOpacity().getValue(), propertyValue);
- });
+ assertNotNull(layer);
+ assertNull(layer.getRasterOpacity().getValue());
+
+ // Set and Get
+ Float propertyValue = 0.3f;
+ layer.setProperties(rasterOpacity(propertyValue));
+ assertEquals(layer.getRasterOpacity().getValue(), propertyValue);
}
@Test
+ @UiThreadTest
public void testRasterHueRotateTransition() {
- validateTestSetup();
- setupLayer();
Timber.i("raster-hue-rotateTransitionOptions");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
-
- // Set and Get
- TransitionOptions options = new TransitionOptions(300, 100);
- layer.setRasterHueRotateTransition(options);
- assertEquals(layer.getRasterHueRotateTransition(), options);
- });
+ assertNotNull(layer);
+
+ // Set and Get
+ TransitionOptions options = new TransitionOptions(300, 100);
+ layer.setRasterHueRotateTransition(options);
+ assertEquals(layer.getRasterHueRotateTransition(), options);
}
@Test
+ @UiThreadTest
public void testRasterHueRotateAsConstant() {
- validateTestSetup();
- setupLayer();
Timber.i("raster-hue-rotate");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getRasterHueRotate().getValue());
-
- // Set and Get
- Float propertyValue = 0.3f;
- layer.setProperties(rasterHueRotate(propertyValue));
- assertEquals(layer.getRasterHueRotate().getValue(), propertyValue);
- });
+ assertNotNull(layer);
+ assertNull(layer.getRasterHueRotate().getValue());
+
+ // Set and Get
+ Float propertyValue = 0.3f;
+ layer.setProperties(rasterHueRotate(propertyValue));
+ assertEquals(layer.getRasterHueRotate().getValue(), propertyValue);
}
@Test
+ @UiThreadTest
public void testRasterBrightnessMinTransition() {
- validateTestSetup();
- setupLayer();
Timber.i("raster-brightness-minTransitionOptions");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
-
- // Set and Get
- TransitionOptions options = new TransitionOptions(300, 100);
- layer.setRasterBrightnessMinTransition(options);
- assertEquals(layer.getRasterBrightnessMinTransition(), options);
- });
+ assertNotNull(layer);
+
+ // Set and Get
+ TransitionOptions options = new TransitionOptions(300, 100);
+ layer.setRasterBrightnessMinTransition(options);
+ assertEquals(layer.getRasterBrightnessMinTransition(), options);
}
@Test
+ @UiThreadTest
public void testRasterBrightnessMinAsConstant() {
- validateTestSetup();
- setupLayer();
Timber.i("raster-brightness-min");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getRasterBrightnessMin().getValue());
-
- // Set and Get
- Float propertyValue = 0.3f;
- layer.setProperties(rasterBrightnessMin(propertyValue));
- assertEquals(layer.getRasterBrightnessMin().getValue(), propertyValue);
- });
+ assertNotNull(layer);
+ assertNull(layer.getRasterBrightnessMin().getValue());
+
+ // Set and Get
+ Float propertyValue = 0.3f;
+ layer.setProperties(rasterBrightnessMin(propertyValue));
+ assertEquals(layer.getRasterBrightnessMin().getValue(), propertyValue);
}
@Test
+ @UiThreadTest
public void testRasterBrightnessMaxTransition() {
- validateTestSetup();
- setupLayer();
Timber.i("raster-brightness-maxTransitionOptions");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
-
- // Set and Get
- TransitionOptions options = new TransitionOptions(300, 100);
- layer.setRasterBrightnessMaxTransition(options);
- assertEquals(layer.getRasterBrightnessMaxTransition(), options);
- });
+ assertNotNull(layer);
+
+ // Set and Get
+ TransitionOptions options = new TransitionOptions(300, 100);
+ layer.setRasterBrightnessMaxTransition(options);
+ assertEquals(layer.getRasterBrightnessMaxTransition(), options);
}
@Test
+ @UiThreadTest
public void testRasterBrightnessMaxAsConstant() {
- validateTestSetup();
- setupLayer();
Timber.i("raster-brightness-max");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getRasterBrightnessMax().getValue());
-
- // Set and Get
- Float propertyValue = 0.3f;
- layer.setProperties(rasterBrightnessMax(propertyValue));
- assertEquals(layer.getRasterBrightnessMax().getValue(), propertyValue);
- });
+ assertNotNull(layer);
+ assertNull(layer.getRasterBrightnessMax().getValue());
+
+ // Set and Get
+ Float propertyValue = 0.3f;
+ layer.setProperties(rasterBrightnessMax(propertyValue));
+ assertEquals(layer.getRasterBrightnessMax().getValue(), propertyValue);
}
@Test
+ @UiThreadTest
public void testRasterSaturationTransition() {
- validateTestSetup();
- setupLayer();
Timber.i("raster-saturationTransitionOptions");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
-
- // Set and Get
- TransitionOptions options = new TransitionOptions(300, 100);
- layer.setRasterSaturationTransition(options);
- assertEquals(layer.getRasterSaturationTransition(), options);
- });
+ assertNotNull(layer);
+
+ // Set and Get
+ TransitionOptions options = new TransitionOptions(300, 100);
+ layer.setRasterSaturationTransition(options);
+ assertEquals(layer.getRasterSaturationTransition(), options);
}
@Test
+ @UiThreadTest
public void testRasterSaturationAsConstant() {
- validateTestSetup();
- setupLayer();
Timber.i("raster-saturation");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getRasterSaturation().getValue());
-
- // Set and Get
- Float propertyValue = 0.3f;
- layer.setProperties(rasterSaturation(propertyValue));
- assertEquals(layer.getRasterSaturation().getValue(), propertyValue);
- });
+ assertNotNull(layer);
+ assertNull(layer.getRasterSaturation().getValue());
+
+ // Set and Get
+ Float propertyValue = 0.3f;
+ layer.setProperties(rasterSaturation(propertyValue));
+ assertEquals(layer.getRasterSaturation().getValue(), propertyValue);
}
@Test
+ @UiThreadTest
public void testRasterContrastTransition() {
- validateTestSetup();
- setupLayer();
Timber.i("raster-contrastTransitionOptions");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
-
- // Set and Get
- TransitionOptions options = new TransitionOptions(300, 100);
- layer.setRasterContrastTransition(options);
- assertEquals(layer.getRasterContrastTransition(), options);
- });
+ assertNotNull(layer);
+
+ // Set and Get
+ TransitionOptions options = new TransitionOptions(300, 100);
+ layer.setRasterContrastTransition(options);
+ assertEquals(layer.getRasterContrastTransition(), options);
}
@Test
+ @UiThreadTest
public void testRasterContrastAsConstant() {
- validateTestSetup();
- setupLayer();
Timber.i("raster-contrast");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getRasterContrast().getValue());
-
- // Set and Get
- Float propertyValue = 0.3f;
- layer.setProperties(rasterContrast(propertyValue));
- assertEquals(layer.getRasterContrast().getValue(), propertyValue);
- });
+ assertNotNull(layer);
+ assertNull(layer.getRasterContrast().getValue());
+
+ // Set and Get
+ Float propertyValue = 0.3f;
+ layer.setProperties(rasterContrast(propertyValue));
+ assertEquals(layer.getRasterContrast().getValue(), propertyValue);
}
@Test
+ @UiThreadTest
public void testRasterResamplingAsConstant() {
- validateTestSetup();
- setupLayer();
Timber.i("raster-resampling");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getRasterResampling().getValue());
-
- // Set and Get
- String propertyValue = RASTER_RESAMPLING_LINEAR;
- layer.setProperties(rasterResampling(propertyValue));
- assertEquals(layer.getRasterResampling().getValue(), propertyValue);
- });
+ assertNotNull(layer);
+ assertNull(layer.getRasterResampling().getValue());
+
+ // Set and Get
+ String propertyValue = RASTER_RESAMPLING_LINEAR;
+ layer.setProperties(rasterResampling(propertyValue));
+ assertEquals(layer.getRasterResampling().getValue(), propertyValue);
}
@Test
+ @UiThreadTest
public void testRasterFadeDurationAsConstant() {
- validateTestSetup();
- setupLayer();
Timber.i("raster-fade-duration");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getRasterFadeDuration().getValue());
-
- // Set and Get
- Float propertyValue = 0.3f;
- layer.setProperties(rasterFadeDuration(propertyValue));
- assertEquals(layer.getRasterFadeDuration().getValue(), propertyValue);
- });
+ assertNotNull(layer);
+ assertNull(layer.getRasterFadeDuration().getValue());
+
+ // Set and Get
+ Float propertyValue = 0.3f;
+ layer.setProperties(rasterFadeDuration(propertyValue));
+ assertEquals(layer.getRasterFadeDuration().getValue(), propertyValue);
}
}
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 755876cd14..149064d684 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,1538 +3,1246 @@
package com.mapbox.mapboxsdk.testapp.style;
import android.graphics.Color;
+import android.support.test.annotation.UiThreadTest;
import android.support.test.runner.AndroidJUnit4;
+import com.mapbox.mapboxsdk.maps.BaseLayerTest;
+import org.junit.Before;
import timber.log.Timber;
import com.mapbox.mapboxsdk.style.expressions.Expression;
import com.mapbox.mapboxsdk.style.layers.SymbolLayer;
import com.mapbox.mapboxsdk.style.types.Formatted;
import com.mapbox.mapboxsdk.style.types.FormattedSection;
-import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest;
import org.junit.Test;
import org.junit.runner.RunWith;
import static com.mapbox.mapboxsdk.style.expressions.Expression.*;
-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.*;
import com.mapbox.mapboxsdk.style.layers.TransitionOptions;
-import com.mapbox.mapboxsdk.testapp.activity.espresso.EspressoTestActivity;
/**
* Basic smoke tests for SymbolLayer
*/
@RunWith(AndroidJUnit4.class)
-public class SymbolLayerTest extends BaseActivityTest {
+public class SymbolLayerTest extends BaseLayerTest {
private SymbolLayer layer;
- @Override
- protected Class getActivityClass() {
- return EspressoTestActivity.class;
- }
-
- private void setupLayer() {
- Timber.i("Retrieving layer");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- if ((layer = mapboxMap.getStyle().getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new SymbolLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.getStyle().addLayer(layer);
- // Layer reference is now stale, get new reference
- layer = mapboxMap.getStyle().getLayerAs("my-layer");
- }
- });
+ @Before
+ @UiThreadTest
+ public void beforeTest(){
+ super.before();
+ layer = new SymbolLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ setupLayer(layer);
}
@Test
+ @UiThreadTest
public void testSourceId() {
- validateTestSetup();
- setupLayer();
Timber.i("SourceId");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- // Get source id
- assertEquals(layer.getSourceId(), "composite");
- });
+ assertNotNull(layer);
+ assertEquals(layer.getSourceId(), "composite");
}
@Test
+ @UiThreadTest
public void testSetVisibility() {
- validateTestSetup();
- setupLayer();
Timber.i("Visibility");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
+ 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
+ @UiThreadTest
public void testSourceLayer() {
- validateTestSetup();
- setupLayer();
Timber.i("SourceLayer");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
+ 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
+ @UiThreadTest
public void testFilter() {
- validateTestSetup();
- setupLayer();
Timber.i("Filter");
- invoke(mapboxMap, (uiController, mapboxMap1) -> {
- assertNotNull(layer);
+ assertNotNull(layer);
- // Get initial
- assertEquals(layer.getFilter(), null);
+ // Get initial
+ assertEquals(layer.getFilter(), null);
- // Set
- Expression filter = eq(get("undefined"), literal(1.0));
- layer.setFilter(filter);
- assertEquals(layer.getFilter().toString(), filter.toString());
+ // Set
+ Expression filter = eq(get("undefined"), literal(1.0));
+ layer.setFilter(filter);
+ assertEquals(layer.getFilter().toString(), filter.toString());
- // Set constant
- filter = literal(true);
- layer.setFilter(filter);
- assertEquals(layer.getFilter().toString(), filter.toString());
- });
+ // Set constant
+ filter = literal(true);
+ layer.setFilter(filter);
+ assertEquals(layer.getFilter().toString(), filter.toString());
}
@Test
+ @UiThreadTest
public void testSymbolPlacementAsConstant() {
- validateTestSetup();
- setupLayer();
Timber.i("symbol-placement");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getSymbolPlacement().getValue());
+ assertNotNull(layer);
+ assertNull(layer.getSymbolPlacement().getValue());
- // Set and Get
- String propertyValue = SYMBOL_PLACEMENT_POINT;
- layer.setProperties(symbolPlacement(propertyValue));
- assertEquals(layer.getSymbolPlacement().getValue(), propertyValue);
- });
+ // Set and Get
+ String propertyValue = SYMBOL_PLACEMENT_POINT;
+ layer.setProperties(symbolPlacement(propertyValue));
+ assertEquals(layer.getSymbolPlacement().getValue(), propertyValue);
}
@Test
+ @UiThreadTest
public void testSymbolSpacingAsConstant() {
- validateTestSetup();
- setupLayer();
Timber.i("symbol-spacing");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getSymbolSpacing().getValue());
+ assertNotNull(layer);
+ assertNull(layer.getSymbolSpacing().getValue());
- // Set and Get
- Float propertyValue = 0.3f;
- layer.setProperties(symbolSpacing(propertyValue));
- assertEquals(layer.getSymbolSpacing().getValue(), propertyValue);
- });
+ // Set and Get
+ Float propertyValue = 0.3f;
+ layer.setProperties(symbolSpacing(propertyValue));
+ assertEquals(layer.getSymbolSpacing().getValue(), propertyValue);
}
@Test
+ @UiThreadTest
public void testSymbolAvoidEdgesAsConstant() {
- validateTestSetup();
- setupLayer();
Timber.i("symbol-avoid-edges");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getSymbolAvoidEdges().getValue());
+ assertNotNull(layer);
+ assertNull(layer.getSymbolAvoidEdges().getValue());
- // Set and Get
- Boolean propertyValue = true;
- layer.setProperties(symbolAvoidEdges(propertyValue));
- assertEquals(layer.getSymbolAvoidEdges().getValue(), propertyValue);
- });
+ // Set and Get
+ Boolean propertyValue = true;
+ layer.setProperties(symbolAvoidEdges(propertyValue));
+ assertEquals(layer.getSymbolAvoidEdges().getValue(), propertyValue);
}
@Test
+ @UiThreadTest
public void testSymbolZOrderAsConstant() {
- validateTestSetup();
- setupLayer();
Timber.i("symbol-z-order");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getSymbolZOrder().getValue());
+ assertNotNull(layer);
+ assertNull(layer.getSymbolZOrder().getValue());
- // Set and Get
- String propertyValue = SYMBOL_Z_ORDER_VIEWPORT_Y;
- layer.setProperties(symbolZOrder(propertyValue));
- assertEquals(layer.getSymbolZOrder().getValue(), propertyValue);
- });
+ // Set and Get
+ String propertyValue = SYMBOL_Z_ORDER_VIEWPORT_Y;
+ layer.setProperties(symbolZOrder(propertyValue));
+ assertEquals(layer.getSymbolZOrder().getValue(), propertyValue);
}
@Test
+ @UiThreadTest
public void testIconAllowOverlapAsConstant() {
- validateTestSetup();
- setupLayer();
Timber.i("icon-allow-overlap");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getIconAllowOverlap().getValue());
+ assertNotNull(layer);
+ assertNull(layer.getIconAllowOverlap().getValue());
- // Set and Get
- Boolean propertyValue = true;
- layer.setProperties(iconAllowOverlap(propertyValue));
- assertEquals(layer.getIconAllowOverlap().getValue(), propertyValue);
- });
+ // Set and Get
+ Boolean propertyValue = true;
+ layer.setProperties(iconAllowOverlap(propertyValue));
+ assertEquals(layer.getIconAllowOverlap().getValue(), propertyValue);
}
@Test
+ @UiThreadTest
public void testIconIgnorePlacementAsConstant() {
- validateTestSetup();
- setupLayer();
Timber.i("icon-ignore-placement");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getIconIgnorePlacement().getValue());
+ assertNotNull(layer);
+ assertNull(layer.getIconIgnorePlacement().getValue());
- // Set and Get
- Boolean propertyValue = true;
- layer.setProperties(iconIgnorePlacement(propertyValue));
- assertEquals(layer.getIconIgnorePlacement().getValue(), propertyValue);
- });
+ // Set and Get
+ Boolean propertyValue = true;
+ layer.setProperties(iconIgnorePlacement(propertyValue));
+ assertEquals(layer.getIconIgnorePlacement().getValue(), propertyValue);
}
@Test
+ @UiThreadTest
public void testIconOptionalAsConstant() {
- validateTestSetup();
- setupLayer();
Timber.i("icon-optional");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getIconOptional().getValue());
+ assertNotNull(layer);
+ assertNull(layer.getIconOptional().getValue());
- // Set and Get
- Boolean propertyValue = true;
- layer.setProperties(iconOptional(propertyValue));
- assertEquals(layer.getIconOptional().getValue(), propertyValue);
- });
+ // Set and Get
+ Boolean propertyValue = true;
+ layer.setProperties(iconOptional(propertyValue));
+ assertEquals(layer.getIconOptional().getValue(), propertyValue);
}
@Test
+ @UiThreadTest
public void testIconRotationAlignmentAsConstant() {
- validateTestSetup();
- setupLayer();
Timber.i("icon-rotation-alignment");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getIconRotationAlignment().getValue());
+ assertNotNull(layer);
+ assertNull(layer.getIconRotationAlignment().getValue());
- // Set and Get
- String propertyValue = ICON_ROTATION_ALIGNMENT_MAP;
- layer.setProperties(iconRotationAlignment(propertyValue));
- assertEquals(layer.getIconRotationAlignment().getValue(), propertyValue);
- });
+ // Set and Get
+ String propertyValue = ICON_ROTATION_ALIGNMENT_MAP;
+ layer.setProperties(iconRotationAlignment(propertyValue));
+ assertEquals(layer.getIconRotationAlignment().getValue(), propertyValue);
}
@Test
+ @UiThreadTest
public void testIconSizeAsConstant() {
- validateTestSetup();
- setupLayer();
Timber.i("icon-size");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getIconSize().getValue());
+ assertNotNull(layer);
+ assertNull(layer.getIconSize().getValue());
- // Set and Get
- Float propertyValue = 0.3f;
- layer.setProperties(iconSize(propertyValue));
- assertEquals(layer.getIconSize().getValue(), propertyValue);
- });
+ // Set and Get
+ Float propertyValue = 0.3f;
+ layer.setProperties(iconSize(propertyValue));
+ assertEquals(layer.getIconSize().getValue(), propertyValue);
}
@Test
+ @UiThreadTest
public void testIconSizeAsExpression() {
- validateTestSetup();
- setupLayer();
Timber.i("icon-size-expression");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getIconSize().getExpression());
+ assertNotNull(layer);
+ assertNull(layer.getIconSize().getExpression());
- // Set and Get
- Expression expression = number(Expression.get("undefined"));
- layer.setProperties(iconSize(expression));
- assertEquals(layer.getIconSize().getExpression(), expression);
- });
+ // Set and Get
+ Expression expression = number(Expression.get("undefined"));
+ layer.setProperties(iconSize(expression));
+ assertEquals(layer.getIconSize().getExpression(), expression);
}
@Test
+ @UiThreadTest
public void testIconTextFitAsConstant() {
- validateTestSetup();
- setupLayer();
Timber.i("icon-text-fit");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getIconTextFit().getValue());
+ assertNotNull(layer);
+ assertNull(layer.getIconTextFit().getValue());
- // Set and Get
- String propertyValue = ICON_TEXT_FIT_NONE;
- layer.setProperties(iconTextFit(propertyValue));
- assertEquals(layer.getIconTextFit().getValue(), propertyValue);
- });
+ // Set and Get
+ String propertyValue = ICON_TEXT_FIT_NONE;
+ layer.setProperties(iconTextFit(propertyValue));
+ assertEquals(layer.getIconTextFit().getValue(), propertyValue);
}
@Test
+ @UiThreadTest
public void testIconTextFitPaddingAsConstant() {
- validateTestSetup();
- setupLayer();
Timber.i("icon-text-fit-padding");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getIconTextFitPadding().getValue());
+ assertNotNull(layer);
+ assertNull(layer.getIconTextFitPadding().getValue());
- // Set and Get
- Float[] propertyValue = new Float[] {0f, 0f, 0f, 0f};
- layer.setProperties(iconTextFitPadding(propertyValue));
- assertEquals(layer.getIconTextFitPadding().getValue(), propertyValue);
- });
+ // Set and Get
+ Float[] propertyValue = new Float[] {0f, 0f, 0f, 0f};
+ layer.setProperties(iconTextFitPadding(propertyValue));
+ assertEquals(layer.getIconTextFitPadding().getValue(), propertyValue);
}
@Test
+ @UiThreadTest
public void testIconImageAsConstant() {
- validateTestSetup();
- setupLayer();
Timber.i("icon-image");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getIconImage().getValue());
+ assertNotNull(layer);
+ assertNull(layer.getIconImage().getValue());
- // Set and Get
- String propertyValue = "undefined";
- layer.setProperties(iconImage(propertyValue));
- assertEquals(layer.getIconImage().getValue(), propertyValue);
+ // Set and Get
+ String propertyValue = "undefined";
+ layer.setProperties(iconImage(propertyValue));
+ assertEquals(layer.getIconImage().getValue(), propertyValue);
- layer.setProperties(iconImage("{token}"));
- assertEquals(layer.getIconImage().getExpression(), Expression.toString(Expression.get("token")));
- });
+ layer.setProperties(iconImage("{token}"));
+ assertEquals(layer.getIconImage().getExpression(), Expression.toString(Expression.get("token")));
}
@Test
+ @UiThreadTest
public void testIconImageAsExpression() {
- validateTestSetup();
- setupLayer();
Timber.i("icon-image-expression");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getIconImage().getExpression());
+ assertNotNull(layer);
+ assertNull(layer.getIconImage().getExpression());
- // Set and Get
- Expression expression = string(Expression.get("undefined"));
- layer.setProperties(iconImage(expression));
- assertEquals(layer.getIconImage().getExpression(), expression);
- });
+ // Set and Get
+ Expression expression = string(Expression.get("undefined"));
+ layer.setProperties(iconImage(expression));
+ assertEquals(layer.getIconImage().getExpression(), expression);
}
@Test
+ @UiThreadTest
public void testIconRotateAsConstant() {
- validateTestSetup();
- setupLayer();
Timber.i("icon-rotate");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getIconRotate().getValue());
+ assertNotNull(layer);
+ assertNull(layer.getIconRotate().getValue());
- // Set and Get
- Float propertyValue = 0.3f;
- layer.setProperties(iconRotate(propertyValue));
- assertEquals(layer.getIconRotate().getValue(), propertyValue);
- });
+ // Set and Get
+ Float propertyValue = 0.3f;
+ layer.setProperties(iconRotate(propertyValue));
+ assertEquals(layer.getIconRotate().getValue(), propertyValue);
}
@Test
+ @UiThreadTest
public void testIconRotateAsExpression() {
- validateTestSetup();
- setupLayer();
Timber.i("icon-rotate-expression");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getIconRotate().getExpression());
+ assertNotNull(layer);
+ assertNull(layer.getIconRotate().getExpression());
- // Set and Get
- Expression expression = number(Expression.get("undefined"));
- layer.setProperties(iconRotate(expression));
- assertEquals(layer.getIconRotate().getExpression(), expression);
- });
+ // Set and Get
+ Expression expression = number(Expression.get("undefined"));
+ layer.setProperties(iconRotate(expression));
+ assertEquals(layer.getIconRotate().getExpression(), expression);
}
@Test
+ @UiThreadTest
public void testIconPaddingAsConstant() {
- validateTestSetup();
- setupLayer();
Timber.i("icon-padding");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getIconPadding().getValue());
+ assertNotNull(layer);
+ assertNull(layer.getIconPadding().getValue());
- // Set and Get
- Float propertyValue = 0.3f;
- layer.setProperties(iconPadding(propertyValue));
- assertEquals(layer.getIconPadding().getValue(), propertyValue);
- });
+ // Set and Get
+ Float propertyValue = 0.3f;
+ layer.setProperties(iconPadding(propertyValue));
+ assertEquals(layer.getIconPadding().getValue(), propertyValue);
}
@Test
+ @UiThreadTest
public void testIconKeepUprightAsConstant() {
- validateTestSetup();
- setupLayer();
Timber.i("icon-keep-upright");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getIconKeepUpright().getValue());
+ assertNotNull(layer);
+ assertNull(layer.getIconKeepUpright().getValue());
- // Set and Get
- Boolean propertyValue = true;
- layer.setProperties(iconKeepUpright(propertyValue));
- assertEquals(layer.getIconKeepUpright().getValue(), propertyValue);
- });
+ // Set and Get
+ Boolean propertyValue = true;
+ layer.setProperties(iconKeepUpright(propertyValue));
+ assertEquals(layer.getIconKeepUpright().getValue(), propertyValue);
}
@Test
+ @UiThreadTest
public void testIconOffsetAsConstant() {
- validateTestSetup();
- setupLayer();
Timber.i("icon-offset");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getIconOffset().getValue());
+ assertNotNull(layer);
+ assertNull(layer.getIconOffset().getValue());
- // Set and Get
- Float[] propertyValue = new Float[] {0f, 0f};
- layer.setProperties(iconOffset(propertyValue));
- assertEquals(layer.getIconOffset().getValue(), propertyValue);
- });
+ // Set and Get
+ Float[] propertyValue = new Float[] {0f, 0f};
+ layer.setProperties(iconOffset(propertyValue));
+ assertEquals(layer.getIconOffset().getValue(), propertyValue);
}
@Test
+ @UiThreadTest
public void testIconAnchorAsConstant() {
- validateTestSetup();
- setupLayer();
Timber.i("icon-anchor");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getIconAnchor().getValue());
+ assertNotNull(layer);
+ assertNull(layer.getIconAnchor().getValue());
- // Set and Get
- String propertyValue = ICON_ANCHOR_CENTER;
- layer.setProperties(iconAnchor(propertyValue));
- assertEquals(layer.getIconAnchor().getValue(), propertyValue);
- });
+ // Set and Get
+ String propertyValue = ICON_ANCHOR_CENTER;
+ layer.setProperties(iconAnchor(propertyValue));
+ assertEquals(layer.getIconAnchor().getValue(), propertyValue);
}
@Test
+ @UiThreadTest
public void testIconAnchorAsExpression() {
- validateTestSetup();
- setupLayer();
Timber.i("icon-anchor-expression");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getIconAnchor().getExpression());
+ assertNotNull(layer);
+ assertNull(layer.getIconAnchor().getExpression());
- // Set and Get
- Expression expression = string(Expression.get("undefined"));
- layer.setProperties(iconAnchor(expression));
- assertEquals(layer.getIconAnchor().getExpression(), expression);
- });
+ // Set and Get
+ Expression expression = string(Expression.get("undefined"));
+ layer.setProperties(iconAnchor(expression));
+ assertEquals(layer.getIconAnchor().getExpression(), expression);
}
@Test
+ @UiThreadTest
public void testIconPitchAlignmentAsConstant() {
- validateTestSetup();
- setupLayer();
Timber.i("icon-pitch-alignment");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getIconPitchAlignment().getValue());
+ assertNotNull(layer);
+ assertNull(layer.getIconPitchAlignment().getValue());
- // Set and Get
- String propertyValue = ICON_PITCH_ALIGNMENT_MAP;
- layer.setProperties(iconPitchAlignment(propertyValue));
- assertEquals(layer.getIconPitchAlignment().getValue(), propertyValue);
- });
+ // Set and Get
+ String propertyValue = ICON_PITCH_ALIGNMENT_MAP;
+ layer.setProperties(iconPitchAlignment(propertyValue));
+ assertEquals(layer.getIconPitchAlignment().getValue(), propertyValue);
}
@Test
+ @UiThreadTest
public void testTextPitchAlignmentAsConstant() {
- validateTestSetup();
- setupLayer();
Timber.i("text-pitch-alignment");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getTextPitchAlignment().getValue());
+ assertNotNull(layer);
+ assertNull(layer.getTextPitchAlignment().getValue());
- // Set and Get
- String propertyValue = TEXT_PITCH_ALIGNMENT_MAP;
- layer.setProperties(textPitchAlignment(propertyValue));
- assertEquals(layer.getTextPitchAlignment().getValue(), propertyValue);
- });
+ // Set and Get
+ String propertyValue = TEXT_PITCH_ALIGNMENT_MAP;
+ layer.setProperties(textPitchAlignment(propertyValue));
+ assertEquals(layer.getTextPitchAlignment().getValue(), propertyValue);
}
@Test
+ @UiThreadTest
public void testTextRotationAlignmentAsConstant() {
- validateTestSetup();
- setupLayer();
Timber.i("text-rotation-alignment");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getTextRotationAlignment().getValue());
+ assertNotNull(layer);
+ assertNull(layer.getTextRotationAlignment().getValue());
- // Set and Get
- String propertyValue = TEXT_ROTATION_ALIGNMENT_MAP;
- layer.setProperties(textRotationAlignment(propertyValue));
- assertEquals(layer.getTextRotationAlignment().getValue(), propertyValue);
- });
+ // Set and Get
+ String propertyValue = TEXT_ROTATION_ALIGNMENT_MAP;
+ layer.setProperties(textRotationAlignment(propertyValue));
+ assertEquals(layer.getTextRotationAlignment().getValue(), propertyValue);
}
@Test
+ @UiThreadTest
public void testTextFieldAsConstant() {
- validateTestSetup();
- setupLayer();
Timber.i("text-field");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getTextField().getValue());
-
- // Set and Get
- Formatted propertyValue = new Formatted(new FormattedSection("default"));
+ assertNotNull(layer);
+ assertNull(layer.getTextField().getValue());
- layer.setProperties(textField("default"));
- assertEquals(layer.getTextField().getValue(), propertyValue);
+ // Set and Get
+ Formatted propertyValue = new Formatted(new FormattedSection("default"));
+ layer.setProperties(textField("default"));
+ assertEquals(layer.getTextField().getValue(), propertyValue);
+ layer.setProperties(textField(propertyValue));
+ assertEquals(layer.getTextField().getValue(), propertyValue);
- layer.setProperties(textField(propertyValue));
- assertEquals(layer.getTextField().getValue(), propertyValue);
-
- layer.setProperties(textField("{token}"));
- assertEquals(layer.getTextField().getExpression(), format(Expression.formatEntry(Expression.toString(Expression.get("token")))));
- });
+ layer.setProperties(textField("{token}"));
+ assertEquals(layer.getTextField().getExpression(), format(Expression.formatEntry(Expression.toString(Expression.get("token")))));
}
@Test
+ @UiThreadTest
public void testTextFieldAsExpression() {
- validateTestSetup();
- setupLayer();
Timber.i("text-field-expression");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getTextField().getExpression());
+ assertNotNull(layer);
+ assertNull(layer.getTextField().getExpression());
- // Set and Get
- Expression expression = format(Expression.formatEntry(Expression.get("undefined"), FormatOption.formatFontScale(2.0), FormatOption.formatTextFont(new String[]{"Open Sans Regular", "Arial Unicode MS Regular"})));
- layer.setProperties(textField(expression));
- assertEquals(layer.getTextField().getExpression(), expression);
- });
+ // Set and Get
+ Expression expression = format(Expression.formatEntry(Expression.get("undefined"), FormatOption.formatFontScale(2.0), FormatOption.formatTextFont(new String[]{"Open Sans Regular", "Arial Unicode MS Regular"})));
+ layer.setProperties(textField(expression));
+ assertEquals(layer.getTextField().getExpression(), expression);
}
@Test
+ @UiThreadTest
public void testTextFontAsConstant() {
- validateTestSetup();
- setupLayer();
Timber.i("text-font");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getTextFont().getValue());
+ assertNotNull(layer);
+ assertNull(layer.getTextFont().getValue());
- // Set and Get
- String[] propertyValue = new String[]{"Open Sans Regular", "Arial Unicode MS Regular"};
- layer.setProperties(textFont(propertyValue));
- assertEquals(layer.getTextFont().getValue(), propertyValue);
- });
+ // Set and Get
+ String[] propertyValue = new String[]{"Open Sans Regular", "Arial Unicode MS Regular"};
+ layer.setProperties(textFont(propertyValue));
+ assertEquals(layer.getTextFont().getValue(), propertyValue);
}
@Test
+ @UiThreadTest
public void testTextSizeAsConstant() {
- validateTestSetup();
- setupLayer();
Timber.i("text-size");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getTextSize().getValue());
+ assertNotNull(layer);
+ assertNull(layer.getTextSize().getValue());
- // Set and Get
- Float propertyValue = 0.3f;
- layer.setProperties(textSize(propertyValue));
- assertEquals(layer.getTextSize().getValue(), propertyValue);
- });
+ // Set and Get
+ Float propertyValue = 0.3f;
+ layer.setProperties(textSize(propertyValue));
+ assertEquals(layer.getTextSize().getValue(), propertyValue);
}
@Test
+ @UiThreadTest
public void testTextSizeAsExpression() {
- validateTestSetup();
- setupLayer();
Timber.i("text-size-expression");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getTextSize().getExpression());
+ assertNotNull(layer);
+ assertNull(layer.getTextSize().getExpression());
- // Set and Get
- Expression expression = number(Expression.get("undefined"));
- layer.setProperties(textSize(expression));
- assertEquals(layer.getTextSize().getExpression(), expression);
- });
+ // Set and Get
+ Expression expression = number(Expression.get("undefined"));
+ layer.setProperties(textSize(expression));
+ assertEquals(layer.getTextSize().getExpression(), expression);
}
@Test
+ @UiThreadTest
public void testTextMaxWidthAsConstant() {
- validateTestSetup();
- setupLayer();
Timber.i("text-max-width");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getTextMaxWidth().getValue());
+ assertNotNull(layer);
+ assertNull(layer.getTextMaxWidth().getValue());
- // Set and Get
- Float propertyValue = 0.3f;
- layer.setProperties(textMaxWidth(propertyValue));
- assertEquals(layer.getTextMaxWidth().getValue(), propertyValue);
- });
+ // Set and Get
+ Float propertyValue = 0.3f;
+ layer.setProperties(textMaxWidth(propertyValue));
+ assertEquals(layer.getTextMaxWidth().getValue(), propertyValue);
}
@Test
+ @UiThreadTest
public void testTextMaxWidthAsExpression() {
- validateTestSetup();
- setupLayer();
Timber.i("text-max-width-expression");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getTextMaxWidth().getExpression());
+ assertNotNull(layer);
+ assertNull(layer.getTextMaxWidth().getExpression());
- // Set and Get
- Expression expression = number(Expression.get("undefined"));
- layer.setProperties(textMaxWidth(expression));
- assertEquals(layer.getTextMaxWidth().getExpression(), expression);
- });
+ // Set and Get
+ Expression expression = number(Expression.get("undefined"));
+ layer.setProperties(textMaxWidth(expression));
+ assertEquals(layer.getTextMaxWidth().getExpression(), expression);
}
@Test
+ @UiThreadTest
public void testTextLineHeightAsConstant() {
- validateTestSetup();
- setupLayer();
Timber.i("text-line-height");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getTextLineHeight().getValue());
+ assertNotNull(layer);
+ assertNull(layer.getTextLineHeight().getValue());
- // Set and Get
- Float propertyValue = 0.3f;
- layer.setProperties(textLineHeight(propertyValue));
- assertEquals(layer.getTextLineHeight().getValue(), propertyValue);
- });
+ // Set and Get
+ Float propertyValue = 0.3f;
+ layer.setProperties(textLineHeight(propertyValue));
+ assertEquals(layer.getTextLineHeight().getValue(), propertyValue);
}
@Test
+ @UiThreadTest
public void testTextLetterSpacingAsConstant() {
- validateTestSetup();
- setupLayer();
Timber.i("text-letter-spacing");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getTextLetterSpacing().getValue());
+ assertNotNull(layer);
+ assertNull(layer.getTextLetterSpacing().getValue());
- // Set and Get
- Float propertyValue = 0.3f;
- layer.setProperties(textLetterSpacing(propertyValue));
- assertEquals(layer.getTextLetterSpacing().getValue(), propertyValue);
- });
+ // Set and Get
+ Float propertyValue = 0.3f;
+ layer.setProperties(textLetterSpacing(propertyValue));
+ assertEquals(layer.getTextLetterSpacing().getValue(), propertyValue);
}
@Test
+ @UiThreadTest
public void testTextLetterSpacingAsExpression() {
- validateTestSetup();
- setupLayer();
Timber.i("text-letter-spacing-expression");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getTextLetterSpacing().getExpression());
+ assertNotNull(layer);
+ assertNull(layer.getTextLetterSpacing().getExpression());
- // Set and Get
- Expression expression = number(Expression.get("undefined"));
- layer.setProperties(textLetterSpacing(expression));
- assertEquals(layer.getTextLetterSpacing().getExpression(), expression);
- });
+ // Set and Get
+ Expression expression = number(Expression.get("undefined"));
+ layer.setProperties(textLetterSpacing(expression));
+ assertEquals(layer.getTextLetterSpacing().getExpression(), expression);
}
@Test
+ @UiThreadTest
public void testTextJustifyAsConstant() {
- validateTestSetup();
- setupLayer();
Timber.i("text-justify");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getTextJustify().getValue());
+ assertNotNull(layer);
+ assertNull(layer.getTextJustify().getValue());
- // Set and Get
- String propertyValue = TEXT_JUSTIFY_LEFT;
- layer.setProperties(textJustify(propertyValue));
- assertEquals(layer.getTextJustify().getValue(), propertyValue);
- });
+ // Set and Get
+ String propertyValue = TEXT_JUSTIFY_LEFT;
+ layer.setProperties(textJustify(propertyValue));
+ assertEquals(layer.getTextJustify().getValue(), propertyValue);
}
@Test
+ @UiThreadTest
public void testTextJustifyAsExpression() {
- validateTestSetup();
- setupLayer();
Timber.i("text-justify-expression");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getTextJustify().getExpression());
+ assertNotNull(layer);
+ assertNull(layer.getTextJustify().getExpression());
- // Set and Get
- Expression expression = string(Expression.get("undefined"));
- layer.setProperties(textJustify(expression));
- assertEquals(layer.getTextJustify().getExpression(), expression);
- });
+ // Set and Get
+ Expression expression = string(Expression.get("undefined"));
+ layer.setProperties(textJustify(expression));
+ assertEquals(layer.getTextJustify().getExpression(), expression);
}
@Test
+ @UiThreadTest
public void testTextAnchorAsConstant() {
- validateTestSetup();
- setupLayer();
Timber.i("text-anchor");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getTextAnchor().getValue());
+ assertNotNull(layer);
+ assertNull(layer.getTextAnchor().getValue());
- // Set and Get
- String propertyValue = TEXT_ANCHOR_CENTER;
- layer.setProperties(textAnchor(propertyValue));
- assertEquals(layer.getTextAnchor().getValue(), propertyValue);
- });
+ // Set and Get
+ String propertyValue = TEXT_ANCHOR_CENTER;
+ layer.setProperties(textAnchor(propertyValue));
+ assertEquals(layer.getTextAnchor().getValue(), propertyValue);
}
@Test
+ @UiThreadTest
public void testTextAnchorAsExpression() {
- validateTestSetup();
- setupLayer();
Timber.i("text-anchor-expression");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getTextAnchor().getExpression());
+ assertNotNull(layer);
+ assertNull(layer.getTextAnchor().getExpression());
- // Set and Get
- Expression expression = string(Expression.get("undefined"));
- layer.setProperties(textAnchor(expression));
- assertEquals(layer.getTextAnchor().getExpression(), expression);
- });
+ // Set and Get
+ Expression expression = string(Expression.get("undefined"));
+ layer.setProperties(textAnchor(expression));
+ assertEquals(layer.getTextAnchor().getExpression(), expression);
}
@Test
+ @UiThreadTest
public void testTextMaxAngleAsConstant() {
- validateTestSetup();
- setupLayer();
Timber.i("text-max-angle");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getTextMaxAngle().getValue());
+ assertNotNull(layer);
+ assertNull(layer.getTextMaxAngle().getValue());
- // Set and Get
- Float propertyValue = 0.3f;
- layer.setProperties(textMaxAngle(propertyValue));
- assertEquals(layer.getTextMaxAngle().getValue(), propertyValue);
- });
+ // Set and Get
+ Float propertyValue = 0.3f;
+ layer.setProperties(textMaxAngle(propertyValue));
+ assertEquals(layer.getTextMaxAngle().getValue(), propertyValue);
}
@Test
+ @UiThreadTest
public void testTextRotateAsConstant() {
- validateTestSetup();
- setupLayer();
Timber.i("text-rotate");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getTextRotate().getValue());
+ assertNotNull(layer);
+ assertNull(layer.getTextRotate().getValue());
- // Set and Get
- Float propertyValue = 0.3f;
- layer.setProperties(textRotate(propertyValue));
- assertEquals(layer.getTextRotate().getValue(), propertyValue);
- });
+ // Set and Get
+ Float propertyValue = 0.3f;
+ layer.setProperties(textRotate(propertyValue));
+ assertEquals(layer.getTextRotate().getValue(), propertyValue);
}
@Test
+ @UiThreadTest
public void testTextRotateAsExpression() {
- validateTestSetup();
- setupLayer();
Timber.i("text-rotate-expression");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getTextRotate().getExpression());
+ assertNotNull(layer);
+ assertNull(layer.getTextRotate().getExpression());
- // Set and Get
- Expression expression = number(Expression.get("undefined"));
- layer.setProperties(textRotate(expression));
- assertEquals(layer.getTextRotate().getExpression(), expression);
- });
+ // Set and Get
+ Expression expression = number(Expression.get("undefined"));
+ layer.setProperties(textRotate(expression));
+ assertEquals(layer.getTextRotate().getExpression(), expression);
}
@Test
+ @UiThreadTest
public void testTextPaddingAsConstant() {
- validateTestSetup();
- setupLayer();
Timber.i("text-padding");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getTextPadding().getValue());
+ assertNotNull(layer);
+ assertNull(layer.getTextPadding().getValue());
- // Set and Get
- Float propertyValue = 0.3f;
- layer.setProperties(textPadding(propertyValue));
- assertEquals(layer.getTextPadding().getValue(), propertyValue);
- });
+ // Set and Get
+ Float propertyValue = 0.3f;
+ layer.setProperties(textPadding(propertyValue));
+ assertEquals(layer.getTextPadding().getValue(), propertyValue);
}
@Test
+ @UiThreadTest
public void testTextKeepUprightAsConstant() {
- validateTestSetup();
- setupLayer();
Timber.i("text-keep-upright");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getTextKeepUpright().getValue());
+ assertNotNull(layer);
+ assertNull(layer.getTextKeepUpright().getValue());
- // Set and Get
- Boolean propertyValue = true;
- layer.setProperties(textKeepUpright(propertyValue));
- assertEquals(layer.getTextKeepUpright().getValue(), propertyValue);
- });
+ // Set and Get
+ Boolean propertyValue = true;
+ layer.setProperties(textKeepUpright(propertyValue));
+ assertEquals(layer.getTextKeepUpright().getValue(), propertyValue);
}
@Test
+ @UiThreadTest
public void testTextTransformAsConstant() {
- validateTestSetup();
- setupLayer();
Timber.i("text-transform");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getTextTransform().getValue());
+ assertNotNull(layer);
+ assertNull(layer.getTextTransform().getValue());
- // Set and Get
- String propertyValue = TEXT_TRANSFORM_NONE;
- layer.setProperties(textTransform(propertyValue));
- assertEquals(layer.getTextTransform().getValue(), propertyValue);
- });
+ // Set and Get
+ String propertyValue = TEXT_TRANSFORM_NONE;
+ layer.setProperties(textTransform(propertyValue));
+ assertEquals(layer.getTextTransform().getValue(), propertyValue);
}
@Test
+ @UiThreadTest
public void testTextTransformAsExpression() {
- validateTestSetup();
- setupLayer();
Timber.i("text-transform-expression");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getTextTransform().getExpression());
+ assertNotNull(layer);
+ assertNull(layer.getTextTransform().getExpression());
- // Set and Get
- Expression expression = string(Expression.get("undefined"));
- layer.setProperties(textTransform(expression));
- assertEquals(layer.getTextTransform().getExpression(), expression);
- });
+ // Set and Get
+ Expression expression = string(Expression.get("undefined"));
+ layer.setProperties(textTransform(expression));
+ assertEquals(layer.getTextTransform().getExpression(), expression);
}
@Test
+ @UiThreadTest
public void testTextOffsetAsConstant() {
- validateTestSetup();
- setupLayer();
Timber.i("text-offset");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getTextOffset().getValue());
+ assertNotNull(layer);
+ assertNull(layer.getTextOffset().getValue());
- // Set and Get
- Float[] propertyValue = new Float[] {0f, 0f};
- layer.setProperties(textOffset(propertyValue));
- assertEquals(layer.getTextOffset().getValue(), propertyValue);
- });
+ // Set and Get
+ Float[] propertyValue = new Float[] {0f, 0f};
+ layer.setProperties(textOffset(propertyValue));
+ assertEquals(layer.getTextOffset().getValue(), propertyValue);
}
@Test
+ @UiThreadTest
public void testTextAllowOverlapAsConstant() {
- validateTestSetup();
- setupLayer();
Timber.i("text-allow-overlap");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getTextAllowOverlap().getValue());
+ assertNotNull(layer);
+ assertNull(layer.getTextAllowOverlap().getValue());
- // Set and Get
- Boolean propertyValue = true;
- layer.setProperties(textAllowOverlap(propertyValue));
- assertEquals(layer.getTextAllowOverlap().getValue(), propertyValue);
- });
+ // Set and Get
+ Boolean propertyValue = true;
+ layer.setProperties(textAllowOverlap(propertyValue));
+ assertEquals(layer.getTextAllowOverlap().getValue(), propertyValue);
}
@Test
+ @UiThreadTest
public void testTextIgnorePlacementAsConstant() {
- validateTestSetup();
- setupLayer();
Timber.i("text-ignore-placement");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getTextIgnorePlacement().getValue());
+ assertNotNull(layer);
+ assertNull(layer.getTextIgnorePlacement().getValue());
- // Set and Get
- Boolean propertyValue = true;
- layer.setProperties(textIgnorePlacement(propertyValue));
- assertEquals(layer.getTextIgnorePlacement().getValue(), propertyValue);
- });
+ // Set and Get
+ Boolean propertyValue = true;
+ layer.setProperties(textIgnorePlacement(propertyValue));
+ assertEquals(layer.getTextIgnorePlacement().getValue(), propertyValue);
}
@Test
+ @UiThreadTest
public void testTextOptionalAsConstant() {
- validateTestSetup();
- setupLayer();
Timber.i("text-optional");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getTextOptional().getValue());
+ assertNotNull(layer);
+ assertNull(layer.getTextOptional().getValue());
- // Set and Get
- Boolean propertyValue = true;
- layer.setProperties(textOptional(propertyValue));
- assertEquals(layer.getTextOptional().getValue(), propertyValue);
- });
+ // Set and Get
+ Boolean propertyValue = true;
+ layer.setProperties(textOptional(propertyValue));
+ assertEquals(layer.getTextOptional().getValue(), propertyValue);
}
@Test
+ @UiThreadTest
public void testIconOpacityTransition() {
- validateTestSetup();
- setupLayer();
Timber.i("icon-opacityTransitionOptions");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
+ 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
+ @UiThreadTest
public void testIconOpacityAsConstant() {
- validateTestSetup();
- setupLayer();
Timber.i("icon-opacity");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getIconOpacity().getValue());
+ assertNotNull(layer);
+ assertNull(layer.getIconOpacity().getValue());
- // Set and Get
- Float propertyValue = 0.3f;
- layer.setProperties(iconOpacity(propertyValue));
- assertEquals(layer.getIconOpacity().getValue(), propertyValue);
- });
+ // Set and Get
+ Float propertyValue = 0.3f;
+ layer.setProperties(iconOpacity(propertyValue));
+ assertEquals(layer.getIconOpacity().getValue(), propertyValue);
}
@Test
+ @UiThreadTest
public void testIconOpacityAsExpression() {
- validateTestSetup();
- setupLayer();
Timber.i("icon-opacity-expression");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getIconOpacity().getExpression());
+ assertNotNull(layer);
+ assertNull(layer.getIconOpacity().getExpression());
- // Set and Get
- Expression expression = number(Expression.get("undefined"));
- layer.setProperties(iconOpacity(expression));
- assertEquals(layer.getIconOpacity().getExpression(), expression);
- });
+ // Set and Get
+ Expression expression = number(Expression.get("undefined"));
+ layer.setProperties(iconOpacity(expression));
+ assertEquals(layer.getIconOpacity().getExpression(), expression);
}
@Test
+ @UiThreadTest
public void testIconColorTransition() {
- validateTestSetup();
- setupLayer();
Timber.i("icon-colorTransitionOptions");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
+ 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
+ @UiThreadTest
public void testIconColorAsConstant() {
- validateTestSetup();
- setupLayer();
Timber.i("icon-color");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getIconColor().getValue());
+ assertNotNull(layer);
+ assertNull(layer.getIconColor().getValue());
- // Set and Get
- String propertyValue = "rgba(0, 0, 0, 1)";
- layer.setProperties(iconColor(propertyValue));
- assertEquals(layer.getIconColor().getValue(), propertyValue);
- });
+ // Set and Get
+ String propertyValue = "rgba(0, 0, 0, 1)";
+ layer.setProperties(iconColor(propertyValue));
+ assertEquals(layer.getIconColor().getValue(), propertyValue);
}
@Test
+ @UiThreadTest
public void testIconColorAsExpression() {
- validateTestSetup();
- setupLayer();
Timber.i("icon-color-expression");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getIconColor().getExpression());
+ assertNotNull(layer);
+ assertNull(layer.getIconColor().getExpression());
- // Set and Get
- Expression expression = toColor(Expression.get("undefined"));
- layer.setProperties(iconColor(expression));
- assertEquals(layer.getIconColor().getExpression(), expression);
- });
+ // Set and Get
+ Expression expression = toColor(Expression.get("undefined"));
+ layer.setProperties(iconColor(expression));
+ assertEquals(layer.getIconColor().getExpression(), expression);
}
@Test
+ @UiThreadTest
public void testIconColorAsIntConstant() {
- validateTestSetup();
- setupLayer();
Timber.i("icon-color");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
+ 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
+ @UiThreadTest
public void testIconHaloColorTransition() {
- validateTestSetup();
- setupLayer();
Timber.i("icon-halo-colorTransitionOptions");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
+ 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
+ @UiThreadTest
public void testIconHaloColorAsConstant() {
- validateTestSetup();
- setupLayer();
Timber.i("icon-halo-color");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getIconHaloColor().getValue());
+ assertNotNull(layer);
+ assertNull(layer.getIconHaloColor().getValue());
- // Set and Get
- String propertyValue = "rgba(0, 0, 0, 1)";
- layer.setProperties(iconHaloColor(propertyValue));
- assertEquals(layer.getIconHaloColor().getValue(), propertyValue);
- });
+ // Set and Get
+ String propertyValue = "rgba(0, 0, 0, 1)";
+ layer.setProperties(iconHaloColor(propertyValue));
+ assertEquals(layer.getIconHaloColor().getValue(), propertyValue);
}
@Test
+ @UiThreadTest
public void testIconHaloColorAsExpression() {
- validateTestSetup();
- setupLayer();
Timber.i("icon-halo-color-expression");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getIconHaloColor().getExpression());
+ assertNotNull(layer);
+ assertNull(layer.getIconHaloColor().getExpression());
- // Set and Get
- Expression expression = toColor(Expression.get("undefined"));
- layer.setProperties(iconHaloColor(expression));
- assertEquals(layer.getIconHaloColor().getExpression(), expression);
- });
+ // Set and Get
+ Expression expression = toColor(Expression.get("undefined"));
+ layer.setProperties(iconHaloColor(expression));
+ assertEquals(layer.getIconHaloColor().getExpression(), expression);
}
@Test
+ @UiThreadTest
public void testIconHaloColorAsIntConstant() {
- validateTestSetup();
- setupLayer();
Timber.i("icon-halo-color");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
+ 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
+ @UiThreadTest
public void testIconHaloWidthTransition() {
- validateTestSetup();
- setupLayer();
Timber.i("icon-halo-widthTransitionOptions");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
+ 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
+ @UiThreadTest
public void testIconHaloWidthAsConstant() {
- validateTestSetup();
- setupLayer();
Timber.i("icon-halo-width");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getIconHaloWidth().getValue());
+ assertNotNull(layer);
+ assertNull(layer.getIconHaloWidth().getValue());
- // Set and Get
- Float propertyValue = 0.3f;
- layer.setProperties(iconHaloWidth(propertyValue));
- assertEquals(layer.getIconHaloWidth().getValue(), propertyValue);
- });
+ // Set and Get
+ Float propertyValue = 0.3f;
+ layer.setProperties(iconHaloWidth(propertyValue));
+ assertEquals(layer.getIconHaloWidth().getValue(), propertyValue);
}
@Test
+ @UiThreadTest
public void testIconHaloWidthAsExpression() {
- validateTestSetup();
- setupLayer();
Timber.i("icon-halo-width-expression");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getIconHaloWidth().getExpression());
+ assertNotNull(layer);
+ assertNull(layer.getIconHaloWidth().getExpression());
- // Set and Get
- Expression expression = number(Expression.get("undefined"));
- layer.setProperties(iconHaloWidth(expression));
- assertEquals(layer.getIconHaloWidth().getExpression(), expression);
- });
+ // Set and Get
+ Expression expression = number(Expression.get("undefined"));
+ layer.setProperties(iconHaloWidth(expression));
+ assertEquals(layer.getIconHaloWidth().getExpression(), expression);
}
@Test
+ @UiThreadTest
public void testIconHaloBlurTransition() {
- validateTestSetup();
- setupLayer();
Timber.i("icon-halo-blurTransitionOptions");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
+ 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
+ @UiThreadTest
public void testIconHaloBlurAsConstant() {
- validateTestSetup();
- setupLayer();
Timber.i("icon-halo-blur");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getIconHaloBlur().getValue());
+ assertNotNull(layer);
+ assertNull(layer.getIconHaloBlur().getValue());
- // Set and Get
- Float propertyValue = 0.3f;
- layer.setProperties(iconHaloBlur(propertyValue));
- assertEquals(layer.getIconHaloBlur().getValue(), propertyValue);
- });
+ // Set and Get
+ Float propertyValue = 0.3f;
+ layer.setProperties(iconHaloBlur(propertyValue));
+ assertEquals(layer.getIconHaloBlur().getValue(), propertyValue);
}
@Test
+ @UiThreadTest
public void testIconHaloBlurAsExpression() {
- validateTestSetup();
- setupLayer();
Timber.i("icon-halo-blur-expression");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getIconHaloBlur().getExpression());
+ assertNotNull(layer);
+ assertNull(layer.getIconHaloBlur().getExpression());
- // Set and Get
- Expression expression = number(Expression.get("undefined"));
- layer.setProperties(iconHaloBlur(expression));
- assertEquals(layer.getIconHaloBlur().getExpression(), expression);
- });
+ // Set and Get
+ Expression expression = number(Expression.get("undefined"));
+ layer.setProperties(iconHaloBlur(expression));
+ assertEquals(layer.getIconHaloBlur().getExpression(), expression);
}
@Test
+ @UiThreadTest
public void testIconTranslateTransition() {
- validateTestSetup();
- setupLayer();
Timber.i("icon-translateTransitionOptions");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
+ 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
+ @UiThreadTest
public void testIconTranslateAsConstant() {
- validateTestSetup();
- setupLayer();
Timber.i("icon-translate");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getIconTranslate().getValue());
+ assertNotNull(layer);
+ assertNull(layer.getIconTranslate().getValue());
- // Set and Get
- Float[] propertyValue = new Float[] {0f, 0f};
- layer.setProperties(iconTranslate(propertyValue));
- assertEquals(layer.getIconTranslate().getValue(), propertyValue);
- });
+ // Set and Get
+ Float[] propertyValue = new Float[] {0f, 0f};
+ layer.setProperties(iconTranslate(propertyValue));
+ assertEquals(layer.getIconTranslate().getValue(), propertyValue);
}
@Test
+ @UiThreadTest
public void testIconTranslateAnchorAsConstant() {
- validateTestSetup();
- setupLayer();
Timber.i("icon-translate-anchor");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getIconTranslateAnchor().getValue());
+ assertNotNull(layer);
+ assertNull(layer.getIconTranslateAnchor().getValue());
- // Set and Get
- String propertyValue = ICON_TRANSLATE_ANCHOR_MAP;
- layer.setProperties(iconTranslateAnchor(propertyValue));
- assertEquals(layer.getIconTranslateAnchor().getValue(), propertyValue);
- });
+ // Set and Get
+ String propertyValue = ICON_TRANSLATE_ANCHOR_MAP;
+ layer.setProperties(iconTranslateAnchor(propertyValue));
+ assertEquals(layer.getIconTranslateAnchor().getValue(), propertyValue);
}
@Test
+ @UiThreadTest
public void testTextOpacityTransition() {
- validateTestSetup();
- setupLayer();
Timber.i("text-opacityTransitionOptions");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
+ 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
+ @UiThreadTest
public void testTextOpacityAsConstant() {
- validateTestSetup();
- setupLayer();
Timber.i("text-opacity");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getTextOpacity().getValue());
+ assertNotNull(layer);
+ assertNull(layer.getTextOpacity().getValue());
- // Set and Get
- Float propertyValue = 0.3f;
- layer.setProperties(textOpacity(propertyValue));
- assertEquals(layer.getTextOpacity().getValue(), propertyValue);
- });
+ // Set and Get
+ Float propertyValue = 0.3f;
+ layer.setProperties(textOpacity(propertyValue));
+ assertEquals(layer.getTextOpacity().getValue(), propertyValue);
}
@Test
+ @UiThreadTest
public void testTextOpacityAsExpression() {
- validateTestSetup();
- setupLayer();
Timber.i("text-opacity-expression");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getTextOpacity().getExpression());
+ assertNotNull(layer);
+ assertNull(layer.getTextOpacity().getExpression());
- // Set and Get
- Expression expression = number(Expression.get("undefined"));
- layer.setProperties(textOpacity(expression));
- assertEquals(layer.getTextOpacity().getExpression(), expression);
- });
+ // Set and Get
+ Expression expression = number(Expression.get("undefined"));
+ layer.setProperties(textOpacity(expression));
+ assertEquals(layer.getTextOpacity().getExpression(), expression);
}
@Test
+ @UiThreadTest
public void testTextColorTransition() {
- validateTestSetup();
- setupLayer();
Timber.i("text-colorTransitionOptions");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
+ 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
+ @UiThreadTest
public void testTextColorAsConstant() {
- validateTestSetup();
- setupLayer();
Timber.i("text-color");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getTextColor().getValue());
+ assertNotNull(layer);
+ assertNull(layer.getTextColor().getValue());
- // Set and Get
- String propertyValue = "rgba(0, 0, 0, 1)";
- layer.setProperties(textColor(propertyValue));
- assertEquals(layer.getTextColor().getValue(), propertyValue);
- });
+ // Set and Get
+ String propertyValue = "rgba(0, 0, 0, 1)";
+ layer.setProperties(textColor(propertyValue));
+ assertEquals(layer.getTextColor().getValue(), propertyValue);
}
@Test
+ @UiThreadTest
public void testTextColorAsExpression() {
- validateTestSetup();
- setupLayer();
Timber.i("text-color-expression");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getTextColor().getExpression());
+ assertNotNull(layer);
+ assertNull(layer.getTextColor().getExpression());
- // Set and Get
- Expression expression = toColor(Expression.get("undefined"));
- layer.setProperties(textColor(expression));
- assertEquals(layer.getTextColor().getExpression(), expression);
- });
+ // Set and Get
+ Expression expression = toColor(Expression.get("undefined"));
+ layer.setProperties(textColor(expression));
+ assertEquals(layer.getTextColor().getExpression(), expression);
}
@Test
+ @UiThreadTest
public void testTextColorAsIntConstant() {
- validateTestSetup();
- setupLayer();
Timber.i("text-color");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
+ 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
+ @UiThreadTest
public void testTextHaloColorTransition() {
- validateTestSetup();
- setupLayer();
Timber.i("text-halo-colorTransitionOptions");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
+ 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
+ @UiThreadTest
public void testTextHaloColorAsConstant() {
- validateTestSetup();
- setupLayer();
Timber.i("text-halo-color");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getTextHaloColor().getValue());
+ assertNotNull(layer);
+ assertNull(layer.getTextHaloColor().getValue());
- // Set and Get
- String propertyValue = "rgba(0, 0, 0, 1)";
- layer.setProperties(textHaloColor(propertyValue));
- assertEquals(layer.getTextHaloColor().getValue(), propertyValue);
- });
+ // Set and Get
+ String propertyValue = "rgba(0, 0, 0, 1)";
+ layer.setProperties(textHaloColor(propertyValue));
+ assertEquals(layer.getTextHaloColor().getValue(), propertyValue);
}
@Test
+ @UiThreadTest
public void testTextHaloColorAsExpression() {
- validateTestSetup();
- setupLayer();
Timber.i("text-halo-color-expression");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getTextHaloColor().getExpression());
+ assertNotNull(layer);
+ assertNull(layer.getTextHaloColor().getExpression());
- // Set and Get
- Expression expression = toColor(Expression.get("undefined"));
- layer.setProperties(textHaloColor(expression));
- assertEquals(layer.getTextHaloColor().getExpression(), expression);
- });
+ // Set and Get
+ Expression expression = toColor(Expression.get("undefined"));
+ layer.setProperties(textHaloColor(expression));
+ assertEquals(layer.getTextHaloColor().getExpression(), expression);
}
@Test
+ @UiThreadTest
public void testTextHaloColorAsIntConstant() {
- validateTestSetup();
- setupLayer();
Timber.i("text-halo-color");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
+ 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
+ @UiThreadTest
public void testTextHaloWidthTransition() {
- validateTestSetup();
- setupLayer();
Timber.i("text-halo-widthTransitionOptions");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
+ 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
+ @UiThreadTest
public void testTextHaloWidthAsConstant() {
- validateTestSetup();
- setupLayer();
Timber.i("text-halo-width");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getTextHaloWidth().getValue());
+ assertNotNull(layer);
+ assertNull(layer.getTextHaloWidth().getValue());
- // Set and Get
- Float propertyValue = 0.3f;
- layer.setProperties(textHaloWidth(propertyValue));
- assertEquals(layer.getTextHaloWidth().getValue(), propertyValue);
- });
+ // Set and Get
+ Float propertyValue = 0.3f;
+ layer.setProperties(textHaloWidth(propertyValue));
+ assertEquals(layer.getTextHaloWidth().getValue(), propertyValue);
}
@Test
+ @UiThreadTest
public void testTextHaloWidthAsExpression() {
- validateTestSetup();
- setupLayer();
Timber.i("text-halo-width-expression");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getTextHaloWidth().getExpression());
+ assertNotNull(layer);
+ assertNull(layer.getTextHaloWidth().getExpression());
- // Set and Get
- Expression expression = number(Expression.get("undefined"));
- layer.setProperties(textHaloWidth(expression));
- assertEquals(layer.getTextHaloWidth().getExpression(), expression);
- });
+ // Set and Get
+ Expression expression = number(Expression.get("undefined"));
+ layer.setProperties(textHaloWidth(expression));
+ assertEquals(layer.getTextHaloWidth().getExpression(), expression);
}
@Test
+ @UiThreadTest
public void testTextHaloBlurTransition() {
- validateTestSetup();
- setupLayer();
Timber.i("text-halo-blurTransitionOptions");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
+ 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
+ @UiThreadTest
public void testTextHaloBlurAsConstant() {
- validateTestSetup();
- setupLayer();
Timber.i("text-halo-blur");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getTextHaloBlur().getValue());
+ assertNotNull(layer);
+ assertNull(layer.getTextHaloBlur().getValue());
- // Set and Get
- Float propertyValue = 0.3f;
- layer.setProperties(textHaloBlur(propertyValue));
- assertEquals(layer.getTextHaloBlur().getValue(), propertyValue);
- });
+ // Set and Get
+ Float propertyValue = 0.3f;
+ layer.setProperties(textHaloBlur(propertyValue));
+ assertEquals(layer.getTextHaloBlur().getValue(), propertyValue);
}
@Test
+ @UiThreadTest
public void testTextHaloBlurAsExpression() {
- validateTestSetup();
- setupLayer();
Timber.i("text-halo-blur-expression");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getTextHaloBlur().getExpression());
+ assertNotNull(layer);
+ assertNull(layer.getTextHaloBlur().getExpression());
- // Set and Get
- Expression expression = number(Expression.get("undefined"));
- layer.setProperties(textHaloBlur(expression));
- assertEquals(layer.getTextHaloBlur().getExpression(), expression);
- });
+ // Set and Get
+ Expression expression = number(Expression.get("undefined"));
+ layer.setProperties(textHaloBlur(expression));
+ assertEquals(layer.getTextHaloBlur().getExpression(), expression);
}
@Test
+ @UiThreadTest
public void testTextTranslateTransition() {
- validateTestSetup();
- setupLayer();
Timber.i("text-translateTransitionOptions");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
+ 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
+ @UiThreadTest
public void testTextTranslateAsConstant() {
- validateTestSetup();
- setupLayer();
Timber.i("text-translate");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getTextTranslate().getValue());
+ assertNotNull(layer);
+ assertNull(layer.getTextTranslate().getValue());
- // Set and Get
- Float[] propertyValue = new Float[] {0f, 0f};
- layer.setProperties(textTranslate(propertyValue));
- assertEquals(layer.getTextTranslate().getValue(), propertyValue);
- });
+ // Set and Get
+ Float[] propertyValue = new Float[] {0f, 0f};
+ layer.setProperties(textTranslate(propertyValue));
+ assertEquals(layer.getTextTranslate().getValue(), propertyValue);
}
@Test
+ @UiThreadTest
public void testTextTranslateAnchorAsConstant() {
- validateTestSetup();
- setupLayer();
Timber.i("text-translate-anchor");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.getTextTranslateAnchor().getValue());
-
- // Set and Get
- String propertyValue = TEXT_TRANSLATE_ANCHOR_MAP;
- layer.setProperties(textTranslateAnchor(propertyValue));
- assertEquals(layer.getTextTranslateAnchor().getValue(), propertyValue);
- });
+ assertNotNull(layer);
+ assertNull(layer.getTextTranslateAnchor().getValue());
+
+ // Set and Get
+ String propertyValue = TEXT_TRANSLATE_ANCHOR_MAP;
+ layer.setProperties(textTranslateAnchor(propertyValue));
+ assertEquals(layer.getTextTranslateAnchor().getValue(), propertyValue);
}
}
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 14ad359dbf..a7b5ffeb08 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,8 +7,11 @@
package com.mapbox.mapboxsdk.testapp.style;
import android.graphics.Color;
+import android.support.test.annotation.UiThreadTest;
import android.support.test.runner.AndroidJUnit4;
+import com.mapbox.mapboxsdk.maps.BaseLayerTest;
+import org.junit.Before;
import timber.log.Timber;
import com.mapbox.mapboxsdk.style.expressions.Expression;
@@ -17,125 +20,96 @@ import com.mapbox.mapboxsdk.style.layers.<%- camelize(type) %>Layer;
import com.mapbox.mapboxsdk.style.types.Formatted;
import com.mapbox.mapboxsdk.style.types.FormattedSection;
<% } -%>
-import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest;
import org.junit.Test;
import org.junit.runner.RunWith;
import static com.mapbox.mapboxsdk.style.expressions.Expression.*;
-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.*;
import com.mapbox.mapboxsdk.style.layers.TransitionOptions;
-import com.mapbox.mapboxsdk.testapp.activity.espresso.EspressoTestActivity;
/**
* Basic smoke tests for <%- camelize(type) %>Layer
*/
@RunWith(AndroidJUnit4.class)
-public class <%- camelize(type) %>LayerTest extends BaseActivityTest {
+public class <%- camelize(type) %>LayerTest extends BaseLayerTest {
private <%- camelize(type) %>Layer layer;
- @Override
- protected Class getActivityClass() {
- return EspressoTestActivity.class;
- }
-
- private void setupLayer() {
+ @Before
+ @UiThreadTest
+ public void beforeTest(){
+ super.before();
<% if (type === 'background') { -%>
- Timber.i("Retrieving layer");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- layer = mapboxMap.getStyle().getLayerAs("background");
- });
+ layer = new <%- camelize(type) %>Layer("my-layer");
<% } else { -%>
- Timber.i("Retrieving layer");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- if ((layer = mapboxMap.getStyle().getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new <%- camelize(type) %>Layer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.getStyle().addLayer(layer);
- // Layer reference is now stale, get new reference
- layer = mapboxMap.getStyle().getLayerAs("my-layer");
- }
- });
+ layer = new <%- camelize(type) %>Layer("my-layer", "composite");
+ layer.setSourceLayer("composite");
<% } -%>
+ setupLayer(layer);
}
<% if (type !== 'background') { -%>
@Test
+ @UiThreadTest
public void testSourceId() {
- validateTestSetup();
- setupLayer();
Timber.i("SourceId");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- // Get source id
- assertEquals(layer.getSourceId(), "composite");
- });
+ assertNotNull(layer);
+ assertEquals(layer.getSourceId(), "composite");
}
<% } -%>
@Test
+ @UiThreadTest
public void testSetVisibility() {
- validateTestSetup();
- setupLayer();
Timber.i("Visibility");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
+ 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);
}
<% if (!(type === 'background' || type === 'raster' || type === 'hillshade')) { -%>
@Test
+ @UiThreadTest
public void testSourceLayer() {
- validateTestSetup();
- setupLayer();
Timber.i("SourceLayer");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
+ 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
+ @UiThreadTest
public void testFilter() {
- validateTestSetup();
- setupLayer();
Timber.i("Filter");
- invoke(mapboxMap, (uiController, mapboxMap1) -> {
- assertNotNull(layer);
-
- // Get initial
- assertEquals(layer.getFilter(), null);
-
- // Set
- Expression filter = eq(get("undefined"), literal(1.0));
- layer.setFilter(filter);
- assertEquals(layer.getFilter().toString(), filter.toString());
-
- // Set constant
- filter = literal(true);
- layer.setFilter(filter);
- assertEquals(layer.getFilter().toString(), filter.toString());
- });
+ assertNotNull(layer);
+
+ // Get initial
+ assertEquals(layer.getFilter(), null);
+
+ // Set
+ Expression filter = eq(get("undefined"), literal(1.0));
+ layer.setFilter(filter);
+ assertEquals(layer.getFilter().toString(), filter.toString());
+
+ // Set constant
+ filter = literal(true);
+ layer.setFilter(filter);
+ assertEquals(layer.getFilter().toString(), filter.toString());
}
@@ -145,89 +119,75 @@ public class <%- camelize(type) %>LayerTest extends BaseActivityTest {
<% if (property.transition) { -%>
@Test
+ @UiThreadTest
public void test<%- camelize(property.name) %>Transition() {
- validateTestSetup();
- setupLayer();
Timber.i("<%- property.name %>TransitionOptions");
- invoke(mapboxMap, (uiController, 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);
- });
+ 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);
}
<% } -%>
@Test
+ @UiThreadTest
public void test<%- camelize(property.name) %>AsConstant() {
- validateTestSetup();
- setupLayer();
Timber.i("<%- property.name %>");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.get<%- camelize(property.name) %>().getValue());
+ assertNotNull(layer);
+ assertNull(layer.get<%- camelize(property.name) %>().getValue());
- // Set and Get
- <%- propertyType(property) %> propertyValue = <%- defaultValueJava(property) %>;
+ // Set and Get
+ <%- propertyType(property) %> propertyValue = <%- defaultValueJava(property) %>;
<% if (property.type === 'formatted') { -%>
-
- layer.setProperties(<%- camelizeWithLeadingLowercase(property.name) %>("default"));
- assertEquals(layer.get<%- camelize(property.name) %>().getValue(), propertyValue);
-
+ layer.setProperties(<%- camelizeWithLeadingLowercase(property.name) %>("default"));
+ assertEquals(layer.get<%- camelize(property.name) %>().getValue(), propertyValue);
<% } -%>
- layer.setProperties(<%- camelizeWithLeadingLowercase(property.name) %>(propertyValue));
- assertEquals(layer.get<%- camelize(property.name) %>().getValue(), propertyValue);
+ layer.setProperties(<%- camelizeWithLeadingLowercase(property.name) %>(propertyValue));
+ assertEquals(layer.get<%- camelize(property.name) %>().getValue(), propertyValue);
<% if (property.tokens) { -%>
- layer.setProperties(<%- camelizeWithLeadingLowercase(property.name) %>("{token}"));
+ layer.setProperties(<%- camelizeWithLeadingLowercase(property.name) %>("{token}"));
<% if (property.type === 'formatted') { -%>
- assertEquals(layer.get<%- camelize(property.name) %>().getExpression(), <%- defaultExpressionJava(property) %>(Expression.formatEntry(Expression.toString(Expression.get("token")))));
+ assertEquals(layer.get<%- camelize(property.name) %>().getExpression(), <%- defaultExpressionJava(property) %>(Expression.formatEntry(Expression.toString(Expression.get("token")))));
<% } else {-%>
- assertEquals(layer.get<%- camelize(property.name) %>().getExpression(), Expression.toString(Expression.get("token")));
+ assertEquals(layer.get<%- camelize(property.name) %>().getExpression(), Expression.toString(Expression.get("token")));
<% } -%>
<% } -%>
- });
}
<% if (property['property-type'] === 'data-driven' || property['property-type'] === 'cross-faded-data-driven') { -%>
<% if (!(property.name.endsWith("-font")||property.name.endsWith("-offset"))) { -%>
@Test
+ @UiThreadTest
public void test<%- camelize(property.name) %>AsExpression() {
- validateTestSetup();
- setupLayer();
Timber.i("<%- property.name %>-expression");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
- assertNull(layer.get<%- camelize(property.name) %>().getExpression());
+ assertNotNull(layer);
+ assertNull(layer.get<%- camelize(property.name) %>().getExpression());
- // Set and Get
+ // Set and Get
<% if (property.type === 'formatted') { -%>
- Expression expression = <%- defaultExpressionJava(property) %>(Expression.formatEntry(Expression.get("undefined"), FormatOption.formatFontScale(2.0), FormatOption.formatTextFont(new String[]{"Open Sans Regular", "Arial Unicode MS Regular"})));
+ Expression expression = <%- defaultExpressionJava(property) %>(Expression.formatEntry(Expression.get("undefined"), FormatOption.formatFontScale(2.0), FormatOption.formatTextFont(new String[]{"Open Sans Regular", "Arial Unicode MS Regular"})));
<% } else { -%>
- Expression expression = <%- defaultExpressionJava(property) %>(Expression.get("undefined"));
+ Expression expression = <%- defaultExpressionJava(property) %>(Expression.get("undefined"));
<% } -%>
- layer.setProperties(<%- camelizeWithLeadingLowercase(property.name) %>(expression));
- assertEquals(layer.get<%- camelize(property.name) %>().getExpression(), expression);
- });
+ layer.setProperties(<%- camelizeWithLeadingLowercase(property.name) %>(expression));
+ assertEquals(layer.get<%- camelize(property.name) %>().getExpression(), expression);
}
<% } -%>
<% } -%>
<% if (property.type == 'color') { -%>
@Test
+ @UiThreadTest
public void test<%- camelize(property.name) %>AsIntConstant() {
- validateTestSetup();
- setupLayer();
Timber.i("<%- property.name %>");
- invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertNotNull(layer);
+ assertNotNull(layer);
- // Set and Get
- layer.setProperties(<%- camelizeWithLeadingLowercase(property.name) %>(Color.RED));
- assertEquals(layer.get<%- camelize(property.name) %>AsInt(), Color.RED);
- });
+ // Set and Get
+ layer.setProperties(<%- camelizeWithLeadingLowercase(property.name) %>(Color.RED));
+ assertEquals(layer.get<%- camelize(property.name) %>AsInt(), Color.RED);
}
<% } -%>
<% } -%>
diff --git a/platform/android/src/native_map_view.cpp b/platform/android/src/native_map_view.cpp
index d908b14d36..a750baa62c 100755
--- a/platform/android/src/native_map_view.cpp
+++ b/platform/android/src/native_map_view.cpp
@@ -429,10 +429,21 @@ void NativeMapView::setVisibleCoordinateBounds(JNIEnv& env, const jni::Array<jni
map->easeTo(cameraOptions, animationOptions);
}
-void NativeMapView::setContentPadding(JNIEnv&, double top, double left, double bottom, double right) {
+void NativeMapView::setContentPadding(JNIEnv&, float top, float left, float bottom, float right) {
insets = {top, left, bottom, right};
}
+jni::Local<jni::Array<jni::jfloat>> NativeMapView::getContentPadding(JNIEnv& env) {
+ auto result = jni::Array<jni::jfloat>::New(env, 4);
+ std::vector<jfloat> vect;
+ vect.push_back(insets.top());
+ vect.push_back(insets.left());
+ vect.push_back(insets.bottom());
+ vect.push_back(insets.right());
+ result.SetRegion<std::vector<jni::jfloat>>(env, 0, vect);
+ return result;
+}
+
void NativeMapView::scheduleSnapshot(jni::JNIEnv&) {
mapRenderer.requestSnapshot([&](PremultipliedImage image) {
auto _env = android::AttachEnv();
@@ -1005,6 +1016,7 @@ void NativeMapView::registerNative(jni::JNIEnv& env) {
METHOD(&NativeMapView::resetNorth, "nativeResetNorth"),
METHOD(&NativeMapView::setVisibleCoordinateBounds, "nativeSetVisibleCoordinateBounds"),
METHOD(&NativeMapView::setContentPadding, "nativeSetContentPadding"),
+ METHOD(&NativeMapView::getContentPadding, "nativeGetContentPadding"),
METHOD(&NativeMapView::scheduleSnapshot, "nativeTakeSnapshot"),
METHOD(&NativeMapView::getCameraPosition, "nativeGetCameraPosition"),
METHOD(&NativeMapView::updateMarker, "nativeUpdateMarker"),
diff --git a/platform/android/src/native_map_view.hpp b/platform/android/src/native_map_view.hpp
index 57676d3edf..b1f8354d46 100755
--- a/platform/android/src/native_map_view.hpp
+++ b/platform/android/src/native_map_view.hpp
@@ -138,7 +138,9 @@ public:
void setVisibleCoordinateBounds(JNIEnv&, const jni::Array<jni::Object<LatLng>>&, const jni::Object<RectF>&, jni::jdouble, jni::jlong);
- void setContentPadding(JNIEnv&, double, double, double, double);
+ void setContentPadding(JNIEnv&, float, float, float, float);
+
+ jni::Local<jni::Array<jni::jfloat>> getContentPadding(JNIEnv&);
void scheduleSnapshot(jni::JNIEnv&);
diff --git a/platform/android/src/style/layers/layer_manager.cpp b/platform/android/src/style/layers/layer_manager.cpp
index 706c5a76a1..2f023bd3ae 100644
--- a/platform/android/src/style/layers/layer_manager.cpp
+++ b/platform/android/src/style/layers/layer_manager.cpp
@@ -52,29 +52,43 @@ jni::Local<jni::Object<Layer>> LayerManagerAndroid::createJavaLayerPeer(jni::JNI
}
void LayerManagerAndroid::registerNative(jni::JNIEnv& env) {
+ if (peerFactories.empty()) {
+ return;
+ }
+
Layer::registerNative(env);
- for (const auto& factory: factories) {
+ for (const auto& factory: peerFactories) {
factory->registerNative(env);
}
}
void LayerManagerAndroid::addLayerType(std::unique_ptr<JavaLayerPeerFactory> factory) {
- auto* coreFactory = factory->getLayerFactory();
- std::string type{coreFactory->getTypeInfo()->type};
+ assert(getFactory(factory->getLayerFactory()->getTypeInfo()) == nullptr);
+ registerCoreFactory(factory->getLayerFactory());
+ peerFactories.emplace_back(std::move(factory));
+}
+
+void LayerManagerAndroid::addLayerTypeCoreOnly(std::unique_ptr<LayerFactory> factory) {
+ assert(getFactory(factory->getTypeInfo()) == nullptr);
+ registerCoreFactory(factory.get());
+ coreFactories.emplace_back(std::move(factory));
+}
+
+void LayerManagerAndroid::registerCoreFactory(mbgl::LayerFactory* factory) {
+ std::string type{factory->getTypeInfo()->type};
if (!type.empty()) {
- typeToFactory.emplace(std::make_pair(std::move(type), coreFactory));
+ assert(typeToFactory.find(type) == typeToFactory.end());
+ typeToFactory.emplace(std::make_pair(std::move(type), factory));
}
- factories.emplace_back(std::move(factory));
}
JavaLayerPeerFactory* LayerManagerAndroid::getPeerFactory(const mbgl::style::LayerTypeInfo* typeInfo) {
assert(typeInfo);
- for (const auto& factory: factories) {
+ for (const auto& factory: peerFactories) {
if (factory->getLayerFactory()->getTypeInfo() == typeInfo) {
return factory.get();
}
}
- assert(false);
return nullptr;
}
@@ -84,8 +98,17 @@ LayerFactory* LayerManagerAndroid::getFactory(const std::string& type) noexcept
}
LayerFactory* LayerManagerAndroid::getFactory(const mbgl::style::LayerTypeInfo* info) noexcept {
- JavaLayerPeerFactory* peerFactory = getPeerFactory(info);
- return (peerFactory != nullptr) ? peerFactory->getLayerFactory() : nullptr;
+ if (JavaLayerPeerFactory* peerFactory = getPeerFactory(info)) {
+ return peerFactory->getLayerFactory();
+ }
+
+ for (const auto& factory: coreFactories) {
+ if (factory->getTypeInfo() == info) {
+ return factory.get();
+ }
+ }
+
+ return nullptr;
}
// static
diff --git a/platform/android/src/style/layers/layer_manager.hpp b/platform/android/src/style/layers/layer_manager.hpp
index ff7e48027e..fb87721dd2 100644
--- a/platform/android/src/style/layers/layer_manager.hpp
+++ b/platform/android/src/style/layers/layer_manager.hpp
@@ -29,13 +29,27 @@ public:
private:
LayerManagerAndroid();
- void addLayerType(std::unique_ptr<JavaLayerPeerFactory>);
+ /**
+ * @brief Enables a layer type for both JSON style an runtime API.
+ */
+ void addLayerType(std::unique_ptr<JavaLayerPeerFactory>);
+ /**
+ * @brief Enables a layer type for JSON style only.
+ *
+ * We might not want to expose runtime API for some layer types
+ * in order to save binary size - JNI glue code for these layer types
+ * won't be added to the binary.
+ */
+ void addLayerTypeCoreOnly(std::unique_ptr<mbgl::LayerFactory>);
+
+ void registerCoreFactory(mbgl::LayerFactory*);
JavaLayerPeerFactory* getPeerFactory(const mbgl::style::LayerTypeInfo*);
// mbgl::LayerManager overrides.
LayerFactory* getFactory(const std::string& type) noexcept final;
LayerFactory* getFactory(const mbgl::style::LayerTypeInfo* info) noexcept final;
- std::vector<std::unique_ptr<JavaLayerPeerFactory>> factories;
+ std::vector<std::unique_ptr<JavaLayerPeerFactory>> peerFactories;
+ std::vector<std::unique_ptr<mbgl::LayerFactory>> coreFactories;
std::map<std::string, mbgl::LayerFactory*> typeToFactory;
};