From 20b958301eb208fe9ed0ae8edfb14b6f3741d8f2 Mon Sep 17 00:00:00 2001 From: Cameron Mace Date: Fri, 16 Dec 2016 16:19:15 -0500 Subject: Adds checkstyle to CI (#7442) * adds checkstyle to CI * fixed gradlew path * resolved testapp checkstyle violations * added back mapboxMap variable for test * checkstyle annotations * checkstyle SDK round 1 * maps package checkstyle * rest of SDK checkstyle * checkstyle gesture library * checkstyle test * finished rest of test checkstyle * resolved all checkstyle errors * fixed class name * removed old test file * fixed camera postion test * fixed native crash --- .../com/mapbox/mapboxsdk/maps/MapViewUtils.java | 36 +- .../com/mapbox/mapboxsdk/maps/MapboxMapTest.java | 1535 ++++++------- .../testapp/activity/BaseActivityTest.java | 78 +- .../mapboxsdk/testapp/annotations/MarkerTest.java | 180 +- .../testapp/annotations/MarkerViewTest.java | 191 +- .../mapboxsdk/testapp/annotations/PolygonTest.java | 129 +- .../testapp/annotations/PolylineTest.java | 120 +- .../testapp/camera/CameraAnimateTest.java | 405 ++-- .../mapboxsdk/testapp/camera/CameraEaseTest.java | 404 ++-- .../testapp/camera/CameraInternalAPITest.java | 167 -- .../testapp/camera/CameraInternalApiTest.java | 169 ++ .../mapboxsdk/testapp/camera/CameraMoveTest.java | 405 ++-- .../feature/QueryRenderedFeaturesBoxCountTest.java | 55 +- .../QueryRenderedFeaturesHighlightTest.java | 75 +- .../QueryRenderedFeaturesPropertiesTest.java | 73 +- .../feature/QueryRenderedSymbolBoxCountTest.java | 55 +- .../testapp/maps/widgets/AttributionTest.java | 218 +- .../testapp/maps/widgets/CompassViewTest.java | 200 +- .../mapboxsdk/testapp/maps/widgets/LogoTest.java | 84 +- .../testapp/maps/widgets/MyLocationViewTest.java | 318 +-- .../testapp/style/BackgroundLayerStyleTest.java | 168 +- .../testapp/style/BackgroundLayerTest.java | 168 +- .../mapboxsdk/testapp/style/BaseStyleTest.java | 40 +- .../testapp/style/CircleLayerStyleTest.java | 432 ++-- .../mapboxsdk/testapp/style/CircleLayerTest.java | 603 ++--- .../testapp/style/FillLayerStyleTest.java | 473 ++-- .../mapboxsdk/testapp/style/FillLayerTest.java | 473 ++-- .../testapp/style/LineLayerStyleTest.java | 734 +++--- .../mapboxsdk/testapp/style/LineLayerTest.java | 734 +++--- .../testapp/style/RasterLayerStyleTest.java | 388 ++-- .../mapboxsdk/testapp/style/RasterLayerTest.java | 389 ++-- .../style/RuntimeStyleBackgroundLayerTest.java | 71 +- .../mapboxsdk/testapp/style/RuntimeStyleTests.java | 278 +-- .../testapp/style/RuntimeStyleTimingTests.java | 43 +- .../testapp/style/SymbolLayerStyleTest.java | 2330 ++++++++++---------- .../mapboxsdk/testapp/style/SymbolLayerTest.java | 2330 ++++++++++---------- .../mapboxsdk/testapp/utils/DrawerUtils.java | 16 +- .../mapboxsdk/testapp/utils/GestureUtils.java | 6 +- .../testapp/utils/OnMapReadyIdlingResource.java | 75 +- .../mapboxsdk/testapp/utils/ScreenshotUtil.java | 189 +- .../mapboxsdk/testapp/utils/TestConstants.java | 18 +- .../mapbox/mapboxsdk/testapp/utils/ViewUtils.java | 16 +- 42 files changed, 7591 insertions(+), 7280 deletions(-) delete mode 100644 platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/camera/CameraInternalAPITest.java create mode 100644 platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/camera/CameraInternalApiTest.java (limited to 'platform/android/MapboxGLAndroidSDKTestApp/src/androidTest') diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/MapViewUtils.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/MapViewUtils.java index 427d7ff21d..38d5297291 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/MapViewUtils.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/MapViewUtils.java @@ -7,27 +7,27 @@ import com.mapbox.mapboxsdk.geometry.LatLng; */ public class MapViewUtils { - public static void setDirection(MapboxMap mapboxMap, float direction) { - mapboxMap.getTransform().setBearing(direction); - } + public static void setDirection(MapboxMap mapboxMap, float direction) { + mapboxMap.getTransform().setBearing(direction); + } - public static float getDirection(MapboxMap mapboxMap) { - return (float) mapboxMap.getTransform().getBearing(); - } + public static float getDirection(MapboxMap mapboxMap) { + return (float) mapboxMap.getTransform().getBearing(); + } - public static void setTilt(MapboxMap mapboxMap, float tilt) { - mapboxMap.getTransform().setTilt((double) tilt); - } + public static void setTilt(MapboxMap mapboxMap, float tilt) { + mapboxMap.getTransform().setTilt((double) tilt); + } - public static float getTilt(MapboxMap mapboxMap) { - return (float) mapboxMap.getTransform().getTilt(); - } + public static float getTilt(MapboxMap mapboxMap) { + return (float) mapboxMap.getTransform().getTilt(); + } - public static void setLatLng(MapboxMap mapboxMap, LatLng latLng) { - mapboxMap.getTransform().setCenterCoordinate(latLng); - } + public static void setLatLng(MapboxMap mapboxMap, LatLng latLng) { + mapboxMap.getTransform().setCenterCoordinate(latLng); + } - public static LatLng getLatLng(MapboxMap mapboxMap) { - return mapboxMap.getTransform().getCenterCoordinate(); - } + public static LatLng getLatLng(MapboxMap mapboxMap) { + return mapboxMap.getTransform().getCenterCoordinate(); + } } diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/MapboxMapTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/MapboxMapTest.java index 347113ce34..330de1e9c8 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/MapboxMapTest.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/MapboxMapTest.java @@ -54,770 +54,773 @@ import static org.junit.Assert.assertTrue; */ public class MapboxMapTest { - @Rule - public final ActivityTestRule rule = new ActivityTestRule<>(EspressoTestActivity.class); - - private OnMapReadyIdlingResource idlingResource; - private EspressoTestActivity activity; - - @Before - public void beforeTest() { - activity = rule.getActivity(); - ViewUtils.checkViewIsDisplayed(R.id.mapView); - idlingResource = new OnMapReadyIdlingResource(activity); - Espresso.registerIdlingResources(idlingResource); - } - - @Test - public void testSanity() { - ViewUtils.checkViewIsDisplayed(R.id.mapView); - MapboxMap mapboxMap = activity.getMapboxMap(); - assertNotNull("mapboxMap should not be null", mapboxMap); - } - - // - // MinZoomLevel - // - - @Test - public void testMinZoom() { - ViewUtils.checkViewIsDisplayed(R.id.mapView); - final MapboxMap mapboxMap = activity.getMapboxMap(); - onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() { - @Override - public void onViewAction(UiController uiController, View view) { - mapboxMap.setMinZoomPreference(10); - assertEquals("MinZoom should match", 10, mapboxMap.getMinZoomLevel(), 10); - } - })); - } - - @Test - public void testMaxZoom() { - ViewUtils.checkViewIsDisplayed(R.id.mapView); - final MapboxMap mapboxMap = activity.getMapboxMap(); - final double zoom = 10; - onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() { - @Override - public void onViewAction(UiController uiController, View view) { - mapboxMap.setMaxZoomPreference(zoom); - assertEquals("MaxZoom should match", zoom, mapboxMap.getMaxZoomLevel(), 10); - } - })); - } - - @Test - public void testInitialZoomLevels() { - ViewUtils.checkViewIsDisplayed(R.id.mapView); - final MapboxMap mapboxMap = activity.getMapboxMap(); - onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() { - @Override - public void onViewAction(UiController uiController, View view) { - assertEquals("MaxZoom should match", MapboxConstants.MAXIMUM_ZOOM, mapboxMap.getMaxZoomLevel(), TestConstants.ZOOM_DELTA); - assertEquals("MinZoom should match", MapboxConstants.MINIMUM_ZOOM, mapboxMap.getMinZoomLevel(), TestConstants.ZOOM_DELTA); - } - })); - } - - // - // TrackingSettings - // - - @Test - public void testTrackingSettings() { - ViewUtils.checkViewIsDisplayed(R.id.mapView); - MapboxMap mapboxMap = activity.getMapboxMap(); - assertNotNull("TrackingSettings should not be null", mapboxMap.getTrackingSettings()); - } - - // - // InfoWindow - // - - @Test - public void testConcurrentInfoWindowEnabled() { - ViewUtils.checkViewIsDisplayed(R.id.mapView); - final MapboxMap mapboxMap = activity.getMapboxMap(); - onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() { - @Override - public void onViewAction(UiController uiController, View view) { - mapboxMap.setAllowConcurrentMultipleOpenInfoWindows(true); - assertTrue("ConcurrentWindows should be true", mapboxMap.isAllowConcurrentMultipleOpenInfoWindows()); - } - })); - } - - @Test - public void testConcurrentInfoWindowDisabled() { - ViewUtils.checkViewIsDisplayed(R.id.mapView); - final MapboxMap mapboxMap = activity.getMapboxMap(); - onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() { - @Override - public void onViewAction(UiController uiController, View view) { - mapboxMap.setAllowConcurrentMultipleOpenInfoWindows(false); - assertFalse("ConcurrentWindows should be false", mapboxMap.isAllowConcurrentMultipleOpenInfoWindows()); - } - })); - } - - @Test - public void testInfoWindowAdapter() { - ViewUtils.checkViewIsDisplayed(R.id.mapView); - final MapboxMap mapboxMap = activity.getMapboxMap(); - onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() { - @Override - public void onViewAction(UiController uiController, View view) { - MapboxMap.InfoWindowAdapter infoWindowAdapter = new MapboxMap.InfoWindowAdapter() { - @Nullable - @Override - public View getInfoWindow(@NonNull Marker marker) { - return null; - } - }; - mapboxMap.setInfoWindowAdapter(infoWindowAdapter); - assertEquals("InfoWindowAdpter should be the same", infoWindowAdapter, mapboxMap.getInfoWindowAdapter()); - } - })); - } - - // - // Location - // - - @Test - @Ignore /* disabled due to enabling permissions during test #7177 */ - public void testMyLocationEnabled() { - ViewUtils.checkViewIsDisplayed(R.id.mapView); - final MapboxMap mapboxMap = activity.getMapboxMap(); - onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() { - @Override - public void onViewAction(UiController uiController, View view) { - mapboxMap.setMyLocationEnabled(true); - assertTrue("MyLocationEnabled should be true", mapboxMap.isMyLocationEnabled()); - } - })); - } - - @Test - @Ignore /* can't create handler inside thread that not called Looper.prepare() */ - public void testMyLocationDisabled() { - ViewUtils.checkViewIsDisplayed(R.id.mapView); - final MapboxMap mapboxMap = activity.getMapboxMap(); - onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() { - @Override - public void onViewAction(UiController uiController, View view) { - mapboxMap.setMyLocationEnabled(false); - assertFalse("MyLocationEnabled should be false", mapboxMap.isMyLocationEnabled()); - } - })); - } - - // - // setters/getters interfaces - // - - @Test - public void testFpsListener() { - ViewUtils.checkViewIsDisplayed(R.id.mapView); - final MapboxMap mapboxMap = activity.getMapboxMap(); - onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() { - @Override - public void onViewAction(UiController uiController, View view) { - MapboxMap.OnFpsChangedListener fpsChangedListener = new MapboxMap.OnFpsChangedListener() { - @Override - public void onFpsChanged(double fps) { - - } - }; - mapboxMap.setOnFpsChangedListener(fpsChangedListener); - assertEquals("FpsListener should match", fpsChangedListener, mapboxMap.getOnFpsChangedListener()); - } - })); - } - - @Test - public void testInfoWindowClickListener() { - ViewUtils.checkViewIsDisplayed(R.id.mapView); - final MapboxMap mapboxMap = activity.getMapboxMap(); - onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() { - @Override - public void onViewAction(UiController uiController, View view) { - MapboxMap.OnInfoWindowClickListener clickListener = new MapboxMap.OnInfoWindowClickListener() { - @Override - public boolean onInfoWindowClick(@NonNull Marker marker) { - return false; - } - }; - mapboxMap.setOnInfoWindowClickListener(clickListener); - assertEquals("InfoWidowClickListener should match", clickListener, mapboxMap.getOnInfoWindowClickListener()); - } - })); - } - - @Test - public void testInfoWindowCloseListener() { - ViewUtils.checkViewIsDisplayed(R.id.mapView); - final MapboxMap mapboxMap = activity.getMapboxMap(); - onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() { - @Override - public void onViewAction(UiController uiController, View view) { - MapboxMap.OnInfoWindowCloseListener listener = new MapboxMap.OnInfoWindowCloseListener() { - @Override - public void onInfoWindowClose(Marker marker) { - - } - }; - mapboxMap.setOnInfoWindowCloseListener(listener); - assertEquals("InfoWindowCloseListener should match", listener, mapboxMap.getOnInfoWindowCloseListener()); - } - })); - } - - @Test - public void testInfoWindowLongClickListener() { - ViewUtils.checkViewIsDisplayed(R.id.mapView); - final MapboxMap mapboxMap = activity.getMapboxMap(); - onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() { - @Override - public void onViewAction(UiController uiController, View view) { - MapboxMap.OnInfoWindowLongClickListener listener = new MapboxMap.OnInfoWindowLongClickListener() { - @Override - public void onInfoWindowLongClick(Marker marker) { - - } - }; - mapboxMap.setOnInfoWindowLongClickListener(listener); - assertEquals("InfoWindowLongClickListener should match", listener, mapboxMap.getOnInfoWindowLongClickListener()); - } - })); - } - - // - // Annotations - // - - @Test - public void testAddMarker() { - ViewUtils.checkViewIsDisplayed(R.id.mapView); - final MapboxMap mapboxMap = activity.getMapboxMap(); - onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() { - @Override - public void onViewAction(UiController uiController, View view) { - MarkerOptions markerOptions = new MarkerOptions().position(new LatLng()); - Marker marker = mapboxMap.addMarker(markerOptions); - assertTrue("Marker should be contained", mapboxMap.getMarkers().contains(marker)); - } - })); - } - - @Test(expected = InvalidMarkerPositionException.class) - public void testAddMarkerInvalidPosition() { - new MarkerOptions().getMarker(); - } - - @Test - public void testAddMarkers() { - ViewUtils.checkViewIsDisplayed(R.id.mapView); - final MapboxMap mapboxMap = activity.getMapboxMap(); - onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() { - @Override - public void onViewAction(UiController uiController, View view) { - List markerList = new ArrayList<>(); - MarkerOptions markerOptions1 = new MarkerOptions().position(new LatLng()).title("a"); - MarkerOptions markerOptions2 = new MarkerOptions().position(new LatLng()).title("b"); - markerList.add(markerOptions1); - markerList.add(markerOptions2); - List markers = mapboxMap.addMarkers(markerList); - assertEquals("Markers size should be 2", 2, mapboxMap.getMarkers().size()); - assertTrue(mapboxMap.getMarkers().contains(markers.get(0))); - assertTrue(mapboxMap.getMarkers().contains(markers.get(1))); - } - })); - } - - @Test - public void testAddMarkersEmpty() { - ViewUtils.checkViewIsDisplayed(R.id.mapView); - final MapboxMap mapboxMap = activity.getMapboxMap(); - onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() { - @Override - public void onViewAction(UiController uiController, View view) { - List markerList = new ArrayList<>(); - mapboxMap.addMarkers(markerList); - assertEquals("Markers size should be 0", 0, mapboxMap.getMarkers().size()); - } - })); - } - - @Test - public void testAddMarkersSingleMarker() { - ViewUtils.checkViewIsDisplayed(R.id.mapView); - final MapboxMap mapboxMap = activity.getMapboxMap(); - onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() { - @Override - public void onViewAction(UiController uiController, View view) { - List markerList = new ArrayList<>(); - MarkerOptions markerOptions = new MarkerOptions().title("a").position(new LatLng()); - markerList.add(markerOptions); - List markers = mapboxMap.addMarkers(markerList); - assertEquals("Markers size should be 1", 1, mapboxMap.getMarkers().size()); - assertTrue(mapboxMap.getMarkers().contains(markers.get(0))); - } - })); - } - - @Test - public void testAddPolygon() { - ViewUtils.checkViewIsDisplayed(R.id.mapView); - final MapboxMap mapboxMap = activity.getMapboxMap(); - onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() { - @Override - public void onViewAction(UiController uiController, View view) { - PolygonOptions polygonOptions = new PolygonOptions().add(new LatLng()); - Polygon polygon = mapboxMap.addPolygon(polygonOptions); - assertTrue("Polygon should be contained", mapboxMap.getPolygons().contains(polygon)); - } - })); - } - - @Test - public void testAddEmptyPolygon() { - ViewUtils.checkViewIsDisplayed(R.id.mapView); - final MapboxMap mapboxMap = activity.getMapboxMap(); - onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() { - @Override - public void onViewAction(UiController uiController, View view) { - PolygonOptions polygonOptions = new PolygonOptions(); - Polygon polygon = mapboxMap.addPolygon(polygonOptions); - assertTrue("Polygon should be ignored", !mapboxMap.getPolygons().contains(polygon)); - } - })); - } - - @Test - public void testAddPolygons() { - ViewUtils.checkViewIsDisplayed(R.id.mapView); - final MapboxMap mapboxMap = activity.getMapboxMap(); - onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() { - @Override - public void onViewAction(UiController uiController, View view) { - List polygonList = new ArrayList<>(); - PolygonOptions polygonOptions1 = new PolygonOptions().fillColor(Color.BLACK).add(new LatLng()); - PolygonOptions polygonOptions2 = new PolygonOptions().fillColor(Color.WHITE).add(new LatLng()); - PolygonOptions polygonOptions3 = new PolygonOptions(); - polygonList.add(polygonOptions1); - polygonList.add(polygonOptions2); - polygonList.add(polygonOptions3); - mapboxMap.addPolygons(polygonList); - assertEquals("Polygons size should be 2", 2, mapboxMap.getPolygons().size()); - assertTrue(mapboxMap.getPolygons().contains(polygonOptions1.getPolygon())); - assertTrue(mapboxMap.getPolygons().contains(polygonOptions2.getPolygon())); - assertTrue("Polygon should be ignored", !mapboxMap.getPolygons().contains(polygonOptions3.getPolygon())); - } - })); - } - - @Test - public void addPolygonsEmpty() { - ViewUtils.checkViewIsDisplayed(R.id.mapView); - final MapboxMap mapboxMap = activity.getMapboxMap(); - onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() { - @Override - public void onViewAction(UiController uiController, View view) { - mapboxMap.addPolygons(new ArrayList()); - assertEquals("Polygons size should be 0", 0, mapboxMap.getPolygons().size()); - } - })); - } - - @Test - public void addPolygonsSingle() { - ViewUtils.checkViewIsDisplayed(R.id.mapView); - final MapboxMap mapboxMap = activity.getMapboxMap(); - onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() { - @Override - public void onViewAction(UiController uiController, View view) { - List polygonList = new ArrayList<>(); - PolygonOptions polygonOptions = new PolygonOptions().fillColor(Color.BLACK).add(new LatLng()); - polygonList.add(polygonOptions); - mapboxMap.addPolygons(polygonList); - assertEquals("Polygons size should be 1", 1, mapboxMap.getPolygons().size()); - assertTrue(mapboxMap.getPolygons().contains(polygonOptions.getPolygon())); - } - })); - } - - @Test - public void testAddPolyline() { - ViewUtils.checkViewIsDisplayed(R.id.mapView); - final MapboxMap mapboxMap = activity.getMapboxMap(); - onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() { - @Override - public void onViewAction(UiController uiController, View view) { - PolylineOptions polylineOptions = new PolylineOptions().add(new LatLng()); - Polyline polyline = mapboxMap.addPolyline(polylineOptions); - assertTrue("Polyline should be contained", mapboxMap.getPolylines().contains(polyline)); - } - })); - } - - @Test - public void testAddEmptyPolyline() { - ViewUtils.checkViewIsDisplayed(R.id.mapView); - final MapboxMap mapboxMap = activity.getMapboxMap(); - onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() { - @Override - public void onViewAction(UiController uiController, View view) { - PolylineOptions polylineOptions = new PolylineOptions(); - Polyline polyline = mapboxMap.addPolyline(polylineOptions); - assertTrue("Polyline should be ignored", !mapboxMap.getPolylines().contains(polyline)); - } - })); - } - - @Test - public void testAddPolylines() { - ViewUtils.checkViewIsDisplayed(R.id.mapView); - final MapboxMap mapboxMap = activity.getMapboxMap(); - onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() { - @Override - public void onViewAction(UiController uiController, View view) { - List polylineList = new ArrayList<>(); - PolylineOptions polygonOptions1 = new PolylineOptions().color(Color.BLACK).add(new LatLng()); - PolylineOptions polygonOptions2 = new PolylineOptions().color(Color.WHITE).add(new LatLng()); - PolylineOptions polygonOptions3 = new PolylineOptions(); - polylineList.add(polygonOptions1); - polylineList.add(polygonOptions2); - polylineList.add(polygonOptions3); - mapboxMap.addPolylines(polylineList); - assertEquals("Polygons size should be 2", 2, mapboxMap.getPolylines().size()); - assertTrue(mapboxMap.getPolylines().contains(polygonOptions1.getPolyline())); - assertTrue(mapboxMap.getPolylines().contains(polygonOptions2.getPolyline())); - assertTrue("Polyline should be ignored", !mapboxMap.getPolylines().contains(polygonOptions3.getPolyline())); - } - })); - } - - @Test - public void testAddPolylinesEmpty() { - ViewUtils.checkViewIsDisplayed(R.id.mapView); - final MapboxMap mapboxMap = activity.getMapboxMap(); - onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() { - @Override - public void onViewAction(UiController uiController, View view) { - mapboxMap.addPolylines(new ArrayList()); - assertEquals("Polygons size should be 0", 0, mapboxMap.getPolylines().size()); - } - })); - } - - @Test - public void testAddPolylinesSingle() { - ViewUtils.checkViewIsDisplayed(R.id.mapView); - final MapboxMap mapboxMap = activity.getMapboxMap(); - onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() { - @Override - public void onViewAction(UiController uiController, View view) { - List polylineList = new ArrayList<>(); - PolylineOptions polygonOptions = new PolylineOptions().color(Color.BLACK).add(new LatLng()); - polylineList.add(polygonOptions); - mapboxMap.addPolylines(polylineList); - assertEquals("Polygons size should be 1", 1, mapboxMap.getPolylines().size()); - assertTrue(mapboxMap.getPolylines().contains(polygonOptions.getPolyline())); - } - })); - } - - @Test - public void testRemoveMarker() { - ViewUtils.checkViewIsDisplayed(R.id.mapView); - final MapboxMap mapboxMap = activity.getMapboxMap(); - onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() { - @Override - public void onViewAction(UiController uiController, View view) { - MarkerOptions markerOptions = new MarkerOptions().position(new LatLng()); - Marker marker = mapboxMap.addMarker(markerOptions); - mapboxMap.removeMarker(marker); - assertTrue("Markers should be empty", mapboxMap.getMarkers().isEmpty()); - } - })); - } - - @Test - public void testRemovePolygon() { - ViewUtils.checkViewIsDisplayed(R.id.mapView); - final MapboxMap mapboxMap = activity.getMapboxMap(); - onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() { - @Override - public void onViewAction(UiController uiController, View view) { - PolygonOptions polygonOptions = new PolygonOptions(); - Polygon polygon = mapboxMap.addPolygon(polygonOptions); - mapboxMap.removePolygon(polygon); - assertTrue("Polygons should be empty", mapboxMap.getPolylines().isEmpty()); - } - })); - } - - @Test - public void testRemovePolyline() { - ViewUtils.checkViewIsDisplayed(R.id.mapView); - final MapboxMap mapboxMap = activity.getMapboxMap(); - onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() { - @Override - public void onViewAction(UiController uiController, View view) { - PolylineOptions polylineOptions = new PolylineOptions(); - Polyline polyline = mapboxMap.addPolyline(polylineOptions); - mapboxMap.removePolyline(polyline); - assertTrue("Polylines should be empty", mapboxMap.getPolylines().isEmpty()); - } - })); - } - - @Test - public void testRemoveAnnotation() { - ViewUtils.checkViewIsDisplayed(R.id.mapView); - final MapboxMap mapboxMap = activity.getMapboxMap(); - onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() { - @Override - public void onViewAction(UiController uiController, View view) { - MarkerOptions markerOptions = new MarkerOptions().position(new LatLng()); - Marker marker = mapboxMap.addMarker(markerOptions); - mapboxMap.removeAnnotation(marker); - assertTrue("Annotations should be empty", mapboxMap.getAnnotations().isEmpty()); - } - })); - } - - @Test - public void testRemoveAnnotationById() { - ViewUtils.checkViewIsDisplayed(R.id.mapView); - final MapboxMap mapboxMap = activity.getMapboxMap(); - onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() { - @Override - public void onViewAction(UiController uiController, View view) { - MarkerOptions markerOptions = new MarkerOptions().position(new LatLng()); - mapboxMap.addMarker(markerOptions); - // id will always be 0 in unit tests - mapboxMap.removeAnnotation(0); - assertTrue("Annotations should be empty", mapboxMap.getAnnotations().isEmpty()); - } - })); - } - - @Test - public void testRemoveAnnotations() { - ViewUtils.checkViewIsDisplayed(R.id.mapView); - final MapboxMap mapboxMap = activity.getMapboxMap(); - onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() { - @Override - public void onViewAction(UiController uiController, View view) { - List markerList = new ArrayList<>(); - MarkerOptions markerOptions1 = new MarkerOptions().title("a").position(new LatLng()); - MarkerOptions markerOptions2 = new MarkerOptions().title("b").position(new LatLng()); - markerList.add(markerOptions1); - markerList.add(markerOptions2); - mapboxMap.addMarkers(markerList); - mapboxMap.removeAnnotations(); - assertTrue("Annotations should be empty", mapboxMap.getAnnotations().isEmpty()); - } - })); - } - - @Test - public void testClear() { - ViewUtils.checkViewIsDisplayed(R.id.mapView); - final MapboxMap mapboxMap = activity.getMapboxMap(); - onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() { - @Override - public void onViewAction(UiController uiController, View view) { - List markerList = new ArrayList<>(); - MarkerOptions markerOptions1 = new MarkerOptions().title("a").position(new LatLng()); - MarkerOptions markerOptions2 = new MarkerOptions().title("b").position(new LatLng()); - markerList.add(markerOptions1); - markerList.add(markerOptions2); - mapboxMap.addMarkers(markerList); - mapboxMap.clear(); - assertTrue("Annotations should be empty", mapboxMap.getAnnotations().isEmpty()); - } - })); - } - - @Test - public void testRemoveAnnotationsByList() { - ViewUtils.checkViewIsDisplayed(R.id.mapView); - final MapboxMap mapboxMap = activity.getMapboxMap(); - onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() { - @Override - public void onViewAction(UiController uiController, View view) { - List markerList = new ArrayList<>(); - MarkerOptions markerOptions1 = new MarkerOptions().title("a").position(new LatLng()); - MarkerOptions markerOptions2 = new MarkerOptions().title("b").position(new LatLng()); - markerList.add(markerOptions1); - markerList.add(markerOptions2); - List markers = mapboxMap.addMarkers(markerList); - Marker marker = mapboxMap.addMarker(new MarkerOptions().position(new LatLng()).title("c")); - mapboxMap.removeAnnotations(markers); - assertTrue("Annotations should not be empty", mapboxMap.getAnnotations().size() == 1); - assertTrue("Marker should be contained", mapboxMap.getAnnotations().contains(marker)); - } - })); - } - - @Test - public void testGetAnnotationById() { - ViewUtils.checkViewIsDisplayed(R.id.mapView); - final MapboxMap mapboxMap = activity.getMapboxMap(); - onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() { - @Override - public void onViewAction(UiController uiController, View view) { - MarkerOptions markerOptions = new MarkerOptions().position(new LatLng()); - Marker initialMarker = mapboxMap.addMarker(markerOptions); - Marker retrievedMarker = (Marker) mapboxMap.getAnnotation(0); - assertEquals("Markers should match", initialMarker, retrievedMarker); - } - })); - } - - @Test - public void testGetAnnotations() { - ViewUtils.checkViewIsDisplayed(R.id.mapView); - final MapboxMap mapboxMap = activity.getMapboxMap(); - onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() { - @Override - public void onViewAction(UiController uiController, View view) { - assertNotNull("Annotations should be non null", mapboxMap.getAnnotations()); - } - })); - } - - @Test - public void testGetMarkers() { - ViewUtils.checkViewIsDisplayed(R.id.mapView); - final MapboxMap mapboxMap = activity.getMapboxMap(); - onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() { - @Override - public void onViewAction(UiController uiController, View view) { - assertNotNull("Markers should be non null", mapboxMap.getMarkers()); - } - })); - } - - @Test - public void testGetPolygons() { - ViewUtils.checkViewIsDisplayed(R.id.mapView); - final MapboxMap mapboxMap = activity.getMapboxMap(); - onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() { - @Override - public void onViewAction(UiController uiController, View view) { - assertNotNull("Polygons should be non null", mapboxMap.getPolygons()); - } - })); - } - - @Test - public void testGetPolylines() { - ViewUtils.checkViewIsDisplayed(R.id.mapView); - final MapboxMap mapboxMap = activity.getMapboxMap(); - onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() { - @Override - public void onViewAction(UiController uiController, View view) { - assertNotNull("Polylines should be non null", mapboxMap.getPolylines()); - } - })); - } - - @Test - public void testGetSelectedMarkers() { - ViewUtils.checkViewIsDisplayed(R.id.mapView); - final MapboxMap mapboxMap = activity.getMapboxMap(); - onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() { - @Override - public void onViewAction(UiController uiController, View view) { - assertNotNull("Selected markers should be non null", mapboxMap.getSelectedMarkers()); - } - })); - } - - @Test - public void testSelectMarker() { - ViewUtils.checkViewIsDisplayed(R.id.mapView); - final MapboxMap mapboxMap = activity.getMapboxMap(); - onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() { - @Override - public void onViewAction(UiController uiController, View view) { - MarkerOptions markerOptions = new MarkerOptions().position(new LatLng()); - Marker marker = mapboxMap.addMarker(markerOptions); - mapboxMap.selectMarker(marker); - assertTrue("Marker should be contained", mapboxMap.getSelectedMarkers().contains(marker)); - } - })); - } - - @Test - public void testDeselectMarker() { - ViewUtils.checkViewIsDisplayed(R.id.mapView); - final MapboxMap mapboxMap = activity.getMapboxMap(); - onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() { - @Override - public void onViewAction(UiController uiController, View view) { - MarkerOptions markerOptions = new MarkerOptions().position(new LatLng()); - Marker marker = mapboxMap.addMarker(markerOptions); - mapboxMap.selectMarker(marker); - mapboxMap.deselectMarker(marker); - assertTrue("Selected markers should be empty", mapboxMap.getSelectedMarkers().isEmpty()); - } - })); - } - - @Test - public void testDeselectMarkers() { - ViewUtils.checkViewIsDisplayed(R.id.mapView); - final MapboxMap mapboxMap = activity.getMapboxMap(); - onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() { - @Override - public void onViewAction(UiController uiController, View view) { - MarkerOptions markerOptions = new MarkerOptions().position(new LatLng()); - Marker marker1 = mapboxMap.addMarker(markerOptions); - Marker marker2 = mapboxMap.addMarker(markerOptions); - mapboxMap.selectMarker(marker1); - mapboxMap.selectMarker(marker2); - mapboxMap.deselectMarkers(); - assertTrue("Selected markers should be empty", mapboxMap.getSelectedMarkers().isEmpty()); - } - })); - } - - @After - public void afterTest() { - Timber.e("@After test: unregister idle resource"); - Espresso.unregisterIdlingResources(idlingResource); - } - - private class MapboxMapAction implements ViewAction{ - - private InvokeViewAction invokeViewAction; - - MapboxMapAction(InvokeViewAction invokeViewAction) { - this.invokeViewAction = invokeViewAction; - } - - @Override - public Matcher getConstraints() { - return isDisplayed(); - } - - @Override - public String getDescription() { - return getClass().getSimpleName(); - } - - @Override - public void perform(UiController uiController, View view) { - invokeViewAction.onViewAction(uiController, view); - } - } - - interface InvokeViewAction { - void onViewAction(UiController uiController, View view); - } + @Rule + public final ActivityTestRule rule = new ActivityTestRule<>(EspressoTestActivity.class); + + private OnMapReadyIdlingResource idlingResource; + private EspressoTestActivity activity; + + @Before + public void beforeTest() { + activity = rule.getActivity(); + ViewUtils.checkViewIsDisplayed(R.id.mapView); + idlingResource = new OnMapReadyIdlingResource(activity); + Espresso.registerIdlingResources(idlingResource); + } + + @Test + public void testSanity() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + MapboxMap mapboxMap = activity.getMapboxMap(); + assertNotNull("mapboxMap should not be null", mapboxMap); + } + + // + // MinZoomLevel + // + + @Test + public void testMinZoom() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + final MapboxMap mapboxMap = activity.getMapboxMap(); + onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() { + @Override + public void onViewAction(UiController uiController, View view) { + mapboxMap.setMinZoomPreference(10); + assertEquals("MinZoom should match", 10, mapboxMap.getMinZoomLevel(), 10); + } + })); + } + + @Test + public void testMaxZoom() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + final MapboxMap mapboxMap = activity.getMapboxMap(); + final double zoom = 10; + onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() { + @Override + public void onViewAction(UiController uiController, View view) { + mapboxMap.setMaxZoomPreference(zoom); + assertEquals("MaxZoom should match", zoom, mapboxMap.getMaxZoomLevel(), 10); + } + })); + } + + @Test + public void testInitialZoomLevels() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + final MapboxMap mapboxMap = activity.getMapboxMap(); + onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() { + @Override + public void onViewAction(UiController uiController, View view) { + assertEquals("MaxZoom should match", MapboxConstants.MAXIMUM_ZOOM, mapboxMap.getMaxZoomLevel(), + TestConstants.ZOOM_DELTA); + assertEquals("MinZoom should match", MapboxConstants.MINIMUM_ZOOM, mapboxMap.getMinZoomLevel(), + TestConstants.ZOOM_DELTA); + } + })); + } + + // + // TrackingSettings + // + + @Test + public void testTrackingSettings() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + MapboxMap mapboxMap = activity.getMapboxMap(); + assertNotNull("TrackingSettings should not be null", mapboxMap.getTrackingSettings()); + } + + // + // InfoWindow + // + + @Test + public void testConcurrentInfoWindowEnabled() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + final MapboxMap mapboxMap = activity.getMapboxMap(); + onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() { + @Override + public void onViewAction(UiController uiController, View view) { + mapboxMap.setAllowConcurrentMultipleOpenInfoWindows(true); + assertTrue("ConcurrentWindows should be true", mapboxMap.isAllowConcurrentMultipleOpenInfoWindows()); + } + })); + } + + @Test + public void testConcurrentInfoWindowDisabled() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + final MapboxMap mapboxMap = activity.getMapboxMap(); + onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() { + @Override + public void onViewAction(UiController uiController, View view) { + mapboxMap.setAllowConcurrentMultipleOpenInfoWindows(false); + assertFalse("ConcurrentWindows should be false", mapboxMap.isAllowConcurrentMultipleOpenInfoWindows()); + } + })); + } + + @Test + public void testInfoWindowAdapter() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + final MapboxMap mapboxMap = activity.getMapboxMap(); + onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() { + @Override + public void onViewAction(UiController uiController, View view) { + MapboxMap.InfoWindowAdapter infoWindowAdapter = new MapboxMap.InfoWindowAdapter() { + @Nullable + @Override + public View getInfoWindow(@NonNull Marker marker) { + return null; + } + }; + mapboxMap.setInfoWindowAdapter(infoWindowAdapter); + assertEquals("InfoWindowAdpter should be the same", infoWindowAdapter, mapboxMap.getInfoWindowAdapter()); + } + })); + } + + // + // Location + // + + @Test + @Ignore /* disabled due to enabling permissions during test #7177 */ + public void testMyLocationEnabled() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + final MapboxMap mapboxMap = activity.getMapboxMap(); + onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() { + @Override + public void onViewAction(UiController uiController, View view) { + mapboxMap.setMyLocationEnabled(true); + assertTrue("MyLocationEnabled should be true", mapboxMap.isMyLocationEnabled()); + } + })); + } + + @Test + @Ignore /* can't create handler inside thread that not called Looper.prepare() */ + public void testMyLocationDisabled() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + final MapboxMap mapboxMap = activity.getMapboxMap(); + onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() { + @Override + public void onViewAction(UiController uiController, View view) { + mapboxMap.setMyLocationEnabled(false); + assertFalse("MyLocationEnabled should be false", mapboxMap.isMyLocationEnabled()); + } + })); + } + + // + // setters/getters interfaces + // + + @Test + public void testFpsListener() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + final MapboxMap mapboxMap = activity.getMapboxMap(); + onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() { + @Override + public void onViewAction(UiController uiController, View view) { + MapboxMap.OnFpsChangedListener fpsChangedListener = new MapboxMap.OnFpsChangedListener() { + @Override + public void onFpsChanged(double fps) { + + } + }; + mapboxMap.setOnFpsChangedListener(fpsChangedListener); + assertEquals("FpsListener should match", fpsChangedListener, mapboxMap.getOnFpsChangedListener()); + } + })); + } + + @Test + public void testInfoWindowClickListener() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + final MapboxMap mapboxMap = activity.getMapboxMap(); + onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() { + @Override + public void onViewAction(UiController uiController, View view) { + MapboxMap.OnInfoWindowClickListener clickListener = new MapboxMap.OnInfoWindowClickListener() { + @Override + public boolean onInfoWindowClick(@NonNull Marker marker) { + return false; + } + }; + mapboxMap.setOnInfoWindowClickListener(clickListener); + assertEquals("InfoWidowClickListener should match", clickListener, mapboxMap.getOnInfoWindowClickListener()); + } + })); + } + + @Test + public void testInfoWindowCloseListener() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + final MapboxMap mapboxMap = activity.getMapboxMap(); + onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() { + @Override + public void onViewAction(UiController uiController, View view) { + MapboxMap.OnInfoWindowCloseListener listener = new MapboxMap.OnInfoWindowCloseListener() { + @Override + public void onInfoWindowClose(Marker marker) { + + } + }; + mapboxMap.setOnInfoWindowCloseListener(listener); + assertEquals("InfoWindowCloseListener should match", listener, mapboxMap.getOnInfoWindowCloseListener()); + } + })); + } + + @Test + public void testInfoWindowLongClickListener() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + final MapboxMap mapboxMap = activity.getMapboxMap(); + onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() { + @Override + public void onViewAction(UiController uiController, View view) { + MapboxMap.OnInfoWindowLongClickListener listener = new MapboxMap.OnInfoWindowLongClickListener() { + @Override + public void onInfoWindowLongClick(Marker marker) { + + } + }; + mapboxMap.setOnInfoWindowLongClickListener(listener); + assertEquals("InfoWindowLongClickListener should match", listener, + mapboxMap.getOnInfoWindowLongClickListener()); + } + })); + } + + // + // Annotations + // + + @Test + public void testAddMarker() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + final MapboxMap mapboxMap = activity.getMapboxMap(); + onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() { + @Override + public void onViewAction(UiController uiController, View view) { + MarkerOptions markerOptions = new MarkerOptions().position(new LatLng()); + Marker marker = mapboxMap.addMarker(markerOptions); + assertTrue("Marker should be contained", mapboxMap.getMarkers().contains(marker)); + } + })); + } + + @Test(expected = InvalidMarkerPositionException.class) + public void testAddMarkerInvalidPosition() { + new MarkerOptions().getMarker(); + } + + @Test + public void testAddMarkers() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + final MapboxMap mapboxMap = activity.getMapboxMap(); + onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() { + @Override + public void onViewAction(UiController uiController, View view) { + List markerList = new ArrayList<>(); + MarkerOptions markerOptions1 = new MarkerOptions().position(new LatLng()).title("a"); + MarkerOptions markerOptions2 = new MarkerOptions().position(new LatLng()).title("b"); + markerList.add(markerOptions1); + markerList.add(markerOptions2); + List markers = mapboxMap.addMarkers(markerList); + assertEquals("Markers size should be 2", 2, mapboxMap.getMarkers().size()); + assertTrue(mapboxMap.getMarkers().contains(markers.get(0))); + assertTrue(mapboxMap.getMarkers().contains(markers.get(1))); + } + })); + } + + @Test + public void testAddMarkersEmpty() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + final MapboxMap mapboxMap = activity.getMapboxMap(); + onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() { + @Override + public void onViewAction(UiController uiController, View view) { + List markerList = new ArrayList<>(); + mapboxMap.addMarkers(markerList); + assertEquals("Markers size should be 0", 0, mapboxMap.getMarkers().size()); + } + })); + } + + @Test + public void testAddMarkersSingleMarker() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + final MapboxMap mapboxMap = activity.getMapboxMap(); + onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() { + @Override + public void onViewAction(UiController uiController, View view) { + List markerList = new ArrayList<>(); + MarkerOptions markerOptions = new MarkerOptions().title("a").position(new LatLng()); + markerList.add(markerOptions); + List markers = mapboxMap.addMarkers(markerList); + assertEquals("Markers size should be 1", 1, mapboxMap.getMarkers().size()); + assertTrue(mapboxMap.getMarkers().contains(markers.get(0))); + } + })); + } + + @Test + public void testAddPolygon() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + final MapboxMap mapboxMap = activity.getMapboxMap(); + onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() { + @Override + public void onViewAction(UiController uiController, View view) { + PolygonOptions polygonOptions = new PolygonOptions().add(new LatLng()); + Polygon polygon = mapboxMap.addPolygon(polygonOptions); + assertTrue("Polygon should be contained", mapboxMap.getPolygons().contains(polygon)); + } + })); + } + + @Test + public void testAddEmptyPolygon() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + final MapboxMap mapboxMap = activity.getMapboxMap(); + onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() { + @Override + public void onViewAction(UiController uiController, View view) { + PolygonOptions polygonOptions = new PolygonOptions(); + Polygon polygon = mapboxMap.addPolygon(polygonOptions); + assertTrue("Polygon should be ignored", !mapboxMap.getPolygons().contains(polygon)); + } + })); + } + + @Test + public void testAddPolygons() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + final MapboxMap mapboxMap = activity.getMapboxMap(); + onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() { + @Override + public void onViewAction(UiController uiController, View view) { + List polygonList = new ArrayList<>(); + PolygonOptions polygonOptions1 = new PolygonOptions().fillColor(Color.BLACK).add(new LatLng()); + PolygonOptions polygonOptions2 = new PolygonOptions().fillColor(Color.WHITE).add(new LatLng()); + PolygonOptions polygonOptions3 = new PolygonOptions(); + polygonList.add(polygonOptions1); + polygonList.add(polygonOptions2); + polygonList.add(polygonOptions3); + mapboxMap.addPolygons(polygonList); + assertEquals("Polygons size should be 2", 2, mapboxMap.getPolygons().size()); + assertTrue(mapboxMap.getPolygons().contains(polygonOptions1.getPolygon())); + assertTrue(mapboxMap.getPolygons().contains(polygonOptions2.getPolygon())); + assertTrue("Polygon should be ignored", !mapboxMap.getPolygons().contains(polygonOptions3.getPolygon())); + } + })); + } + + @Test + public void addPolygonsEmpty() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + final MapboxMap mapboxMap = activity.getMapboxMap(); + onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() { + @Override + public void onViewAction(UiController uiController, View view) { + mapboxMap.addPolygons(new ArrayList()); + assertEquals("Polygons size should be 0", 0, mapboxMap.getPolygons().size()); + } + })); + } + + @Test + public void addPolygonsSingle() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + final MapboxMap mapboxMap = activity.getMapboxMap(); + onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() { + @Override + public void onViewAction(UiController uiController, View view) { + List polygonList = new ArrayList<>(); + PolygonOptions polygonOptions = new PolygonOptions().fillColor(Color.BLACK).add(new LatLng()); + polygonList.add(polygonOptions); + mapboxMap.addPolygons(polygonList); + assertEquals("Polygons size should be 1", 1, mapboxMap.getPolygons().size()); + assertTrue(mapboxMap.getPolygons().contains(polygonOptions.getPolygon())); + } + })); + } + + @Test + public void testAddPolyline() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + final MapboxMap mapboxMap = activity.getMapboxMap(); + onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() { + @Override + public void onViewAction(UiController uiController, View view) { + PolylineOptions polylineOptions = new PolylineOptions().add(new LatLng()); + Polyline polyline = mapboxMap.addPolyline(polylineOptions); + assertTrue("Polyline should be contained", mapboxMap.getPolylines().contains(polyline)); + } + })); + } + + @Test + public void testAddEmptyPolyline() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + final MapboxMap mapboxMap = activity.getMapboxMap(); + onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() { + @Override + public void onViewAction(UiController uiController, View view) { + PolylineOptions polylineOptions = new PolylineOptions(); + Polyline polyline = mapboxMap.addPolyline(polylineOptions); + assertTrue("Polyline should be ignored", !mapboxMap.getPolylines().contains(polyline)); + } + })); + } + + @Test + public void testAddPolylines() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + final MapboxMap mapboxMap = activity.getMapboxMap(); + onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() { + @Override + public void onViewAction(UiController uiController, View view) { + List polylineList = new ArrayList<>(); + PolylineOptions polygonOptions1 = new PolylineOptions().color(Color.BLACK).add(new LatLng()); + PolylineOptions polygonOptions2 = new PolylineOptions().color(Color.WHITE).add(new LatLng()); + PolylineOptions polygonOptions3 = new PolylineOptions(); + polylineList.add(polygonOptions1); + polylineList.add(polygonOptions2); + polylineList.add(polygonOptions3); + mapboxMap.addPolylines(polylineList); + assertEquals("Polygons size should be 2", 2, mapboxMap.getPolylines().size()); + assertTrue(mapboxMap.getPolylines().contains(polygonOptions1.getPolyline())); + assertTrue(mapboxMap.getPolylines().contains(polygonOptions2.getPolyline())); + assertTrue("Polyline should be ignored", !mapboxMap.getPolylines().contains(polygonOptions3.getPolyline())); + } + })); + } + + @Test + public void testAddPolylinesEmpty() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + final MapboxMap mapboxMap = activity.getMapboxMap(); + onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() { + @Override + public void onViewAction(UiController uiController, View view) { + mapboxMap.addPolylines(new ArrayList()); + assertEquals("Polygons size should be 0", 0, mapboxMap.getPolylines().size()); + } + })); + } + + @Test + public void testAddPolylinesSingle() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + final MapboxMap mapboxMap = activity.getMapboxMap(); + onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() { + @Override + public void onViewAction(UiController uiController, View view) { + List polylineList = new ArrayList<>(); + PolylineOptions polygonOptions = new PolylineOptions().color(Color.BLACK).add(new LatLng()); + polylineList.add(polygonOptions); + mapboxMap.addPolylines(polylineList); + assertEquals("Polygons size should be 1", 1, mapboxMap.getPolylines().size()); + assertTrue(mapboxMap.getPolylines().contains(polygonOptions.getPolyline())); + } + })); + } + + @Test + public void testRemoveMarker() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + final MapboxMap mapboxMap = activity.getMapboxMap(); + onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() { + @Override + public void onViewAction(UiController uiController, View view) { + MarkerOptions markerOptions = new MarkerOptions().position(new LatLng()); + Marker marker = mapboxMap.addMarker(markerOptions); + mapboxMap.removeMarker(marker); + assertTrue("Markers should be empty", mapboxMap.getMarkers().isEmpty()); + } + })); + } + + @Test + public void testRemovePolygon() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + final MapboxMap mapboxMap = activity.getMapboxMap(); + onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() { + @Override + public void onViewAction(UiController uiController, View view) { + PolygonOptions polygonOptions = new PolygonOptions(); + Polygon polygon = mapboxMap.addPolygon(polygonOptions); + mapboxMap.removePolygon(polygon); + assertTrue("Polygons should be empty", mapboxMap.getPolylines().isEmpty()); + } + })); + } + + @Test + public void testRemovePolyline() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + final MapboxMap mapboxMap = activity.getMapboxMap(); + onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() { + @Override + public void onViewAction(UiController uiController, View view) { + PolylineOptions polylineOptions = new PolylineOptions(); + Polyline polyline = mapboxMap.addPolyline(polylineOptions); + mapboxMap.removePolyline(polyline); + assertTrue("Polylines should be empty", mapboxMap.getPolylines().isEmpty()); + } + })); + } + + @Test + public void testRemoveAnnotation() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + final MapboxMap mapboxMap = activity.getMapboxMap(); + onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() { + @Override + public void onViewAction(UiController uiController, View view) { + MarkerOptions markerOptions = new MarkerOptions().position(new LatLng()); + Marker marker = mapboxMap.addMarker(markerOptions); + mapboxMap.removeAnnotation(marker); + assertTrue("Annotations should be empty", mapboxMap.getAnnotations().isEmpty()); + } + })); + } + + @Test + public void testRemoveAnnotationById() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + final MapboxMap mapboxMap = activity.getMapboxMap(); + onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() { + @Override + public void onViewAction(UiController uiController, View view) { + MarkerOptions markerOptions = new MarkerOptions().position(new LatLng()); + mapboxMap.addMarker(markerOptions); + // id will always be 0 in unit tests + mapboxMap.removeAnnotation(0); + assertTrue("Annotations should be empty", mapboxMap.getAnnotations().isEmpty()); + } + })); + } + + @Test + public void testRemoveAnnotations() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + final MapboxMap mapboxMap = activity.getMapboxMap(); + onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() { + @Override + public void onViewAction(UiController uiController, View view) { + List markerList = new ArrayList<>(); + MarkerOptions markerOptions1 = new MarkerOptions().title("a").position(new LatLng()); + MarkerOptions markerOptions2 = new MarkerOptions().title("b").position(new LatLng()); + markerList.add(markerOptions1); + markerList.add(markerOptions2); + mapboxMap.addMarkers(markerList); + mapboxMap.removeAnnotations(); + assertTrue("Annotations should be empty", mapboxMap.getAnnotations().isEmpty()); + } + })); + } + + @Test + public void testClear() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + final MapboxMap mapboxMap = activity.getMapboxMap(); + onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() { + @Override + public void onViewAction(UiController uiController, View view) { + List markerList = new ArrayList<>(); + MarkerOptions markerOptions1 = new MarkerOptions().title("a").position(new LatLng()); + MarkerOptions markerOptions2 = new MarkerOptions().title("b").position(new LatLng()); + markerList.add(markerOptions1); + markerList.add(markerOptions2); + mapboxMap.addMarkers(markerList); + mapboxMap.clear(); + assertTrue("Annotations should be empty", mapboxMap.getAnnotations().isEmpty()); + } + })); + } + + @Test + public void testRemoveAnnotationsByList() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + final MapboxMap mapboxMap = activity.getMapboxMap(); + onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() { + @Override + public void onViewAction(UiController uiController, View view) { + List markerList = new ArrayList<>(); + MarkerOptions markerOptions1 = new MarkerOptions().title("a").position(new LatLng()); + MarkerOptions markerOptions2 = new MarkerOptions().title("b").position(new LatLng()); + markerList.add(markerOptions1); + markerList.add(markerOptions2); + List markers = mapboxMap.addMarkers(markerList); + Marker marker = mapboxMap.addMarker(new MarkerOptions().position(new LatLng()).title("c")); + mapboxMap.removeAnnotations(markers); + assertTrue("Annotations should not be empty", mapboxMap.getAnnotations().size() == 1); + assertTrue("Marker should be contained", mapboxMap.getAnnotations().contains(marker)); + } + })); + } + + @Test + public void testGetAnnotationById() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + final MapboxMap mapboxMap = activity.getMapboxMap(); + onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() { + @Override + public void onViewAction(UiController uiController, View view) { + MarkerOptions markerOptions = new MarkerOptions().position(new LatLng()); + Marker initialMarker = mapboxMap.addMarker(markerOptions); + Marker retrievedMarker = (Marker) mapboxMap.getAnnotation(0); + assertEquals("Markers should match", initialMarker, retrievedMarker); + } + })); + } + + @Test + public void testGetAnnotations() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + final MapboxMap mapboxMap = activity.getMapboxMap(); + onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() { + @Override + public void onViewAction(UiController uiController, View view) { + assertNotNull("Annotations should be non null", mapboxMap.getAnnotations()); + } + })); + } + + @Test + public void testGetMarkers() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + final MapboxMap mapboxMap = activity.getMapboxMap(); + onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() { + @Override + public void onViewAction(UiController uiController, View view) { + assertNotNull("Markers should be non null", mapboxMap.getMarkers()); + } + })); + } + + @Test + public void testGetPolygons() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + final MapboxMap mapboxMap = activity.getMapboxMap(); + onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() { + @Override + public void onViewAction(UiController uiController, View view) { + assertNotNull("Polygons should be non null", mapboxMap.getPolygons()); + } + })); + } + + @Test + public void testGetPolylines() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + final MapboxMap mapboxMap = activity.getMapboxMap(); + onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() { + @Override + public void onViewAction(UiController uiController, View view) { + assertNotNull("Polylines should be non null", mapboxMap.getPolylines()); + } + })); + } + + @Test + public void testGetSelectedMarkers() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + final MapboxMap mapboxMap = activity.getMapboxMap(); + onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() { + @Override + public void onViewAction(UiController uiController, View view) { + assertNotNull("Selected markers should be non null", mapboxMap.getSelectedMarkers()); + } + })); + } + + @Test + public void testSelectMarker() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + final MapboxMap mapboxMap = activity.getMapboxMap(); + onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() { + @Override + public void onViewAction(UiController uiController, View view) { + MarkerOptions markerOptions = new MarkerOptions().position(new LatLng()); + Marker marker = mapboxMap.addMarker(markerOptions); + mapboxMap.selectMarker(marker); + assertTrue("Marker should be contained", mapboxMap.getSelectedMarkers().contains(marker)); + } + })); + } + + @Test + public void testDeselectMarker() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + final MapboxMap mapboxMap = activity.getMapboxMap(); + onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() { + @Override + public void onViewAction(UiController uiController, View view) { + MarkerOptions markerOptions = new MarkerOptions().position(new LatLng()); + Marker marker = mapboxMap.addMarker(markerOptions); + mapboxMap.selectMarker(marker); + mapboxMap.deselectMarker(marker); + assertTrue("Selected markers should be empty", mapboxMap.getSelectedMarkers().isEmpty()); + } + })); + } + + @Test + public void testDeselectMarkers() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + final MapboxMap mapboxMap = activity.getMapboxMap(); + onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() { + @Override + public void onViewAction(UiController uiController, View view) { + MarkerOptions markerOptions = new MarkerOptions().position(new LatLng()); + Marker marker1 = mapboxMap.addMarker(markerOptions); + Marker marker2 = mapboxMap.addMarker(markerOptions); + mapboxMap.selectMarker(marker1); + mapboxMap.selectMarker(marker2); + mapboxMap.deselectMarkers(); + assertTrue("Selected markers should be empty", mapboxMap.getSelectedMarkers().isEmpty()); + } + })); + } + + @After + public void afterTest() { + Timber.e("@After test: unregister idle resource"); + Espresso.unregisterIdlingResources(idlingResource); + } + + private class MapboxMapAction implements ViewAction { + + private InvokeViewAction invokeViewAction; + + MapboxMapAction(InvokeViewAction invokeViewAction) { + this.invokeViewAction = invokeViewAction; + } + + @Override + public Matcher getConstraints() { + return isDisplayed(); + } + + @Override + public String getDescription() { + return getClass().getSimpleName(); + } + + @Override + public void perform(UiController uiController, View view) { + invokeViewAction.onViewAction(uiController, view); + } + } + + interface InvokeViewAction { + void onViewAction(UiController uiController, View view); + } } diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/BaseActivityTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/BaseActivityTest.java index 44a98ad664..2f51140cd1 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/BaseActivityTest.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/BaseActivityTest.java @@ -4,6 +4,7 @@ import android.app.Activity; import android.support.test.espresso.Espresso; import android.support.test.espresso.IdlingResourceTimeoutException; import android.support.test.rule.ActivityTestRule; + import timber.log.Timber; import com.mapbox.mapboxsdk.maps.MapboxMap; @@ -22,49 +23,50 @@ import static android.support.test.espresso.matcher.ViewMatchers.withId; public abstract class BaseActivityTest { - @Rule - public ActivityTestRule rule = new ActivityTestRule<>(getActivityClass()); - protected MapboxMap mapboxMap; - protected OnMapReadyIdlingResource idlingResource; + @Rule + public ActivityTestRule rule = new ActivityTestRule<>(getActivityClass()); + protected MapboxMap mapboxMap; + protected OnMapReadyIdlingResource idlingResource; - @Before - public void beforeTest() { - try { - Timber.e("@Before test: register idle resource"); - idlingResource = new OnMapReadyIdlingResource(rule.getActivity()); - Espresso.registerIdlingResources(idlingResource); - checkViewIsDisplayed(R.id.mapView); - mapboxMap = idlingResource.getMapboxMap(); - } catch (IdlingResourceTimeoutException e) { - Timber.e("Idling resource timed out. Couldn't not validate if map is ready."); - throw new RuntimeException("Could not start test for " + getActivityClass().getSimpleName() + ".\n" + - "The ViewHierarchy doesn't contain a view with resource id = R.id.mapView or \n" + - "the Activity doesn't contain an instance variable with a name equal to mapboxMap.\n" + - "You can resolve this issue be implementing the requirements above or\n add " + getActivityClass().getSimpleName() + " to the excludeActivities array in `generate-test-code.js`.\n"); - } + @Before + public void beforeTest() { + try { + Timber.e("@Before test: register idle resource"); + idlingResource = new OnMapReadyIdlingResource(rule.getActivity()); + Espresso.registerIdlingResources(idlingResource); + checkViewIsDisplayed(R.id.mapView); + mapboxMap = idlingResource.getMapboxMap(); + } catch (IdlingResourceTimeoutException idlingResourceTimeoutException) { + Timber.e("Idling resource timed out. Couldn't not validate if map is ready."); + throw new RuntimeException("Could not start test for " + getActivityClass().getSimpleName() + ".\n" + + "The ViewHierarchy doesn't contain a view with resource id = R.id.mapView or \n" + + "the Activity doesn't contain an instance variable with a name equal to mapboxMap.\n" + + "You can resolve this issue be implementing the requirements above or\n add " + + getActivityClass().getSimpleName() + " to the excludeActivities array in `generate-test-code.js`.\n"); } + } - protected abstract Class getActivityClass(); + protected abstract Class getActivityClass(); - protected void checkViewIsDisplayed(int id) { - onView(withId(id)) - .check(matches(isDisplayed())); - } + protected void checkViewIsDisplayed(int id) { + onView(withId(id)) + .check(matches(isDisplayed())); + } - protected void takeScreenshot(final String name) { - final Activity activity = rule.getActivity(); - activity.runOnUiThread(new Runnable() { - @Override - public void run() { - ScreenshotUtil.take(activity, name); - } - }); - } + protected void takeScreenshot(final String name) { + final Activity activity = rule.getActivity(); + activity.runOnUiThread(new Runnable() { + @Override + public void run() { + ScreenshotUtil.take(activity, name); + } + }); + } - @After - public void afterTest() { - Timber.e("@After test: unregister idle resource"); - Espresso.unregisterIdlingResources(idlingResource); - } + @After + public void afterTest() { + Timber.e("@After test: unregister idle resource"); + Espresso.unregisterIdlingResources(idlingResource); + } } diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/annotations/MarkerTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/annotations/MarkerTest.java index 36e943b7ff..77025c8fa5 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/annotations/MarkerTest.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/annotations/MarkerTest.java @@ -32,111 +32,111 @@ import static org.junit.Assert.assertEquals; public class MarkerTest { - @Rule - public final ActivityTestRule rule = new ActivityTestRule<>(EspressoTestActivity.class); - - private OnMapReadyIdlingResource idlingResource; - private Marker marker; - - @Before - public void registerIdlingResource() { - idlingResource = new OnMapReadyIdlingResource(rule.getActivity()); - Espresso.registerIdlingResources(idlingResource); + @Rule + public final ActivityTestRule rule = new ActivityTestRule<>(EspressoTestActivity.class); + + private OnMapReadyIdlingResource idlingResource; + private Marker marker; + + @Before + public void registerIdlingResource() { + idlingResource = new OnMapReadyIdlingResource(rule.getActivity()); + Espresso.registerIdlingResources(idlingResource); + } + + @Test + @Ignore + public void addMarkerTest() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); + assertEquals("Markers should be empty", 0, mapboxMap.getMarkers().size()); + + MarkerOptions options = new MarkerOptions(); + options.setPosition(new LatLng()); + options.setSnippet(TestConstants.TEXT_MARKER_SNIPPET); + options.setTitle(TestConstants.TEXT_MARKER_TITLE); + + onView(withId(R.id.mapView)).perform(new AddMarkerAction(mapboxMap, options)); + assertEquals("Markers sze should be 1, ", 1, mapboxMap.getMarkers().size()); + assertEquals("Marker id should be 0", 0, marker.getId()); + assertEquals("Marker target should match", new LatLng(), marker.getPosition()); + assertEquals("Marker snippet should match", TestConstants.TEXT_MARKER_SNIPPET, marker.getSnippet()); + assertEquals("Marker target should match", TestConstants.TEXT_MARKER_TITLE, marker.getTitle()); + mapboxMap.clear(); + assertEquals("Markers should be empty", 0, mapboxMap.getMarkers().size()); + } + + @Test + @Ignore + public void showInfoWindowTest() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); + + final MarkerOptions options = new MarkerOptions(); + options.setPosition(new LatLng()); + options.setSnippet(TestConstants.TEXT_MARKER_SNIPPET); + options.setTitle(TestConstants.TEXT_MARKER_TITLE); + + onView(withId(R.id.mapView)).perform(new AddMarkerAction(mapboxMap, options)); + onView(withId(R.id.mapView)).perform(new ShowInfoWindowAction(mapboxMap)); + onView(withText(TestConstants.TEXT_MARKER_TITLE)).check(matches(isDisplayed())); + onView(withText(TestConstants.TEXT_MARKER_SNIPPET)).check(matches(isDisplayed())); + } + + private class AddMarkerAction implements ViewAction { + + private MapboxMap mapboxMap; + private MarkerOptions options; + + AddMarkerAction(MapboxMap map, MarkerOptions markerOptions) { + mapboxMap = map; + options = markerOptions; } - @Test - @Ignore - public void addMarkerTest() { - ViewUtils.checkViewIsDisplayed(R.id.mapView); - MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); - assertEquals("Markers should be empty", 0, mapboxMap.getMarkers().size()); - - MarkerOptions options = new MarkerOptions(); - options.setPosition(new LatLng()); - options.setSnippet(TestConstants.TEXT_MARKER_SNIPPET); - options.setTitle(TestConstants.TEXT_MARKER_TITLE); - - onView(withId(R.id.mapView)).perform(new AddMarkerAction(mapboxMap, options)); - assertEquals("Markers sze should be 1, ", 1, mapboxMap.getMarkers().size()); - assertEquals("Marker id should be 0", 0, marker.getId()); - assertEquals("Marker target should match", new LatLng(), marker.getPosition()); - assertEquals("Marker snippet should match", TestConstants.TEXT_MARKER_SNIPPET, marker.getSnippet()); - assertEquals("Marker target should match", TestConstants.TEXT_MARKER_TITLE, marker.getTitle()); - mapboxMap.clear(); - assertEquals("Markers should be empty", 0, mapboxMap.getMarkers().size()); + @Override + public Matcher getConstraints() { + return isDisplayed(); } - @Test - @Ignore - public void showInfoWindowTest(){ - ViewUtils.checkViewIsDisplayed(R.id.mapView); - MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); - - final MarkerOptions options = new MarkerOptions(); - options.setPosition(new LatLng()); - options.setSnippet(TestConstants.TEXT_MARKER_SNIPPET); - options.setTitle(TestConstants.TEXT_MARKER_TITLE); - - onView(withId(R.id.mapView)).perform(new AddMarkerAction(mapboxMap, options)); - onView(withId(R.id.mapView)).perform(new ShowInfoWindowAction(mapboxMap)); - onView(withText(TestConstants.TEXT_MARKER_TITLE)).check(matches(isDisplayed())); - onView(withText(TestConstants.TEXT_MARKER_SNIPPET)).check(matches(isDisplayed())); + @Override + public String getDescription() { + return getClass().getSimpleName(); } - private class AddMarkerAction implements ViewAction { - - private MapboxMap mapboxMap; - private MarkerOptions options; - - AddMarkerAction(MapboxMap map, MarkerOptions markerOptions) { - mapboxMap = map; - options = markerOptions; - } - - @Override - public Matcher getConstraints() { - return isDisplayed(); - } - - @Override - public String getDescription() { - return getClass().getSimpleName(); - } - - @Override - public void perform(UiController uiController, View view) { - marker = mapboxMap.addMarker(options); - } + @Override + public void perform(UiController uiController, View view) { + marker = mapboxMap.addMarker(options); } + } - private class ShowInfoWindowAction implements ViewAction { + private class ShowInfoWindowAction implements ViewAction { - private MapboxMap mapboxMap; + private MapboxMap mapboxMap; - ShowInfoWindowAction(MapboxMap map) { - mapboxMap = map; - } + ShowInfoWindowAction(MapboxMap map) { + mapboxMap = map; + } - @Override - public Matcher getConstraints() { - return isDisplayed(); - } + @Override + public Matcher getConstraints() { + return isDisplayed(); + } - @Override - public String getDescription() { - return getClass().getSimpleName(); - } + @Override + public String getDescription() { + return getClass().getSimpleName(); + } - @Override - public void perform(UiController uiController, View view) { - mapboxMap.selectMarker(marker); + @Override + public void perform(UiController uiController, View view) { + mapboxMap.selectMarker(marker); - } } + } - @After - public void unregisterIdlingResource() { - Espresso.unregisterIdlingResources(idlingResource); - } + @After + public void unregisterIdlingResource() { + Espresso.unregisterIdlingResources(idlingResource); + } } diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/annotations/MarkerViewTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/annotations/MarkerViewTest.java index 09f707c4b5..9351ed1c10 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/annotations/MarkerViewTest.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/annotations/MarkerViewTest.java @@ -33,114 +33,115 @@ import static org.junit.Assert.assertEquals; public class MarkerViewTest { - @Rule - public final ActivityTestRule rule = new ActivityTestRule<>(EspressoTestActivity.class); - - private OnMapReadyIdlingResource idlingResource; - private Marker marker; - - @Before - public void registerIdlingResource() { - idlingResource = new OnMapReadyIdlingResource(rule.getActivity()); - Espresso.registerIdlingResources(idlingResource); + @Rule + public final ActivityTestRule rule = new ActivityTestRule<>(EspressoTestActivity.class); + + private OnMapReadyIdlingResource idlingResource; + private Marker marker; + + @Before + public void registerIdlingResource() { + idlingResource = new OnMapReadyIdlingResource(rule.getActivity()); + Espresso.registerIdlingResources(idlingResource); + } + + @Test + @Ignore + public void addMarkerViewTest() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); + assertEquals("Markers should be empty", 0, mapboxMap.getMarkers().size()); + + TextMarkerViewOptions options = new TextMarkerViewOptions(); + options.text(TestConstants.TEXT_MARKER_TEXT); + options.position(new LatLng()); + options.snippet(TestConstants.TEXT_MARKER_SNIPPET); + options.title(TestConstants.TEXT_MARKER_TITLE); + + onView(withId(R.id.mapView)).perform(new AddTextMarkerViewAction(mapboxMap, options)); + assertEquals("Markers sze should be 1, ", 1, mapboxMap.getMarkers().size()); + assertEquals("Marker id should be 0", 0, marker.getId()); + assertEquals("Marker target should match", new LatLng(), marker.getPosition()); + assertEquals("Marker snippet should match", TestConstants.TEXT_MARKER_SNIPPET, marker.getSnippet()); + assertEquals("Marker target should match", TestConstants.TEXT_MARKER_TITLE, marker.getTitle()); + onView(withText(TestConstants.TEXT_MARKER_TEXT)).check(matches(isDisplayed())); + } + + @Test + @Ignore + public void showInfoWindowTest() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); + + final TextMarkerViewOptions options = new TextMarkerViewOptions(); + options.position(new LatLng()); + options.text(TestConstants.TEXT_MARKER_TEXT); + options.snippet(TestConstants.TEXT_MARKER_SNIPPET); + options.title(TestConstants.TEXT_MARKER_TITLE); + + onView(withId(R.id.mapView)).perform(new AddTextMarkerViewAction(mapboxMap, options)); + onView(withText(TestConstants.TEXT_MARKER_TEXT)).check(matches(isDisplayed())); + onView(withId(R.id.mapView)).perform(new ShowInfoWindowAction(mapboxMap)); + onView(withText(TestConstants.TEXT_MARKER_TITLE)).check(matches(isDisplayed())); + onView(withText(TestConstants.TEXT_MARKER_SNIPPET)).check(matches(isDisplayed())); + } + + private class AddTextMarkerViewAction implements ViewAction { + + private MapboxMap mapboxMap; + private TextMarkerViewOptions options; + + AddTextMarkerViewAction(MapboxMap map, TextMarkerViewOptions markerOptions) { + mapboxMap = map; + options = markerOptions; } - @Test - @Ignore - public void addMarkerViewTest() { - ViewUtils.checkViewIsDisplayed(R.id.mapView); - MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); - assertEquals("Markers should be empty", 0, mapboxMap.getMarkers().size()); - - TextMarkerViewOptions options = new TextMarkerViewOptions(); - options.text(TestConstants.TEXT_MARKER_TEXT); - options.position(new LatLng()); - options.snippet(TestConstants.TEXT_MARKER_SNIPPET); - options.title(TestConstants.TEXT_MARKER_TITLE); - - onView(withId(R.id.mapView)).perform(new AddTextMarkerViewAction(mapboxMap, options)); - assertEquals("Markers sze should be 1, ", 1, mapboxMap.getMarkers().size()); - assertEquals("Marker id should be 0", 0, marker.getId()); - assertEquals("Marker target should match", new LatLng(), marker.getPosition()); - assertEquals("Marker snippet should match", TestConstants.TEXT_MARKER_SNIPPET, marker.getSnippet()); - assertEquals("Marker target should match", TestConstants.TEXT_MARKER_TITLE, marker.getTitle()); - onView(withText(TestConstants.TEXT_MARKER_TEXT)).check(matches(isDisplayed())); + @Override + public Matcher getConstraints() { + return isDisplayed(); } - @Test - @Ignore - public void showInfoWindowTest() { - ViewUtils.checkViewIsDisplayed(R.id.mapView); - MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); - - final TextMarkerViewOptions options = new TextMarkerViewOptions(); - options.position(new LatLng()); - options.text(TestConstants.TEXT_MARKER_TEXT); - options.snippet(TestConstants.TEXT_MARKER_SNIPPET); - options.title(TestConstants.TEXT_MARKER_TITLE); - - onView(withId(R.id.mapView)).perform(new AddTextMarkerViewAction(mapboxMap, options)); - onView(withText(TestConstants.TEXT_MARKER_TEXT)).check(matches(isDisplayed())); - onView(withId(R.id.mapView)).perform(new ShowInfoWindowAction(mapboxMap)); - onView(withText(TestConstants.TEXT_MARKER_TITLE)).check(matches(isDisplayed())); - onView(withText(TestConstants.TEXT_MARKER_SNIPPET)).check(matches(isDisplayed())); + @Override + public String getDescription() { + return getClass().getSimpleName(); } - private class AddTextMarkerViewAction implements ViewAction { - - private MapboxMap mapboxMap; - private TextMarkerViewOptions options; - - AddTextMarkerViewAction(MapboxMap map, TextMarkerViewOptions markerOptions) { - mapboxMap = map; - options = markerOptions; - } - - @Override - public Matcher getConstraints() { - return isDisplayed(); - } - - @Override - public String getDescription() { - return getClass().getSimpleName(); - } - - @Override - public void perform(UiController uiController, View view) { - mapboxMap.getMarkerViewManager().addMarkerViewAdapter(new MarkerViewActivity.TextAdapter(view.getContext(), mapboxMap)); - marker = mapboxMap.addMarker(options); - uiController.loopMainThreadForAtLeast(250); - } + @Override + public void perform(UiController uiController, View view) { + mapboxMap.getMarkerViewManager().addMarkerViewAdapter( + new MarkerViewActivity.TextAdapter(view.getContext(), mapboxMap)); + marker = mapboxMap.addMarker(options); + uiController.loopMainThreadForAtLeast(250); } + } - private class ShowInfoWindowAction implements ViewAction { - - private MapboxMap mapboxMap; + private class ShowInfoWindowAction implements ViewAction { - ShowInfoWindowAction(MapboxMap map) { - mapboxMap = map; - } + private MapboxMap mapboxMap; - @Override - public Matcher getConstraints() { - return isDisplayed(); - } + ShowInfoWindowAction(MapboxMap map) { + mapboxMap = map; + } - @Override - public String getDescription() { - return getClass().getSimpleName(); - } + @Override + public Matcher getConstraints() { + return isDisplayed(); + } - @Override - public void perform(UiController uiController, View view) { - mapboxMap.selectMarker(marker); - uiController.loopMainThreadForAtLeast(250); - } + @Override + public String getDescription() { + return getClass().getSimpleName(); } - @After - public void unregisterIdlingResource() { - Espresso.unregisterIdlingResources(idlingResource); + @Override + public void perform(UiController uiController, View view) { + mapboxMap.selectMarker(marker); + uiController.loopMainThreadForAtLeast(250); } + } + + @After + public void unregisterIdlingResource() { + Espresso.unregisterIdlingResources(idlingResource); + } } diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/annotations/PolygonTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/annotations/PolygonTest.java index 366e1851b8..24b9b3bf01 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/annotations/PolygonTest.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/annotations/PolygonTest.java @@ -30,75 +30,76 @@ import static org.junit.Assert.assertEquals; public class PolygonTest { - @Rule - public final ActivityTestRule rule = new ActivityTestRule<>(EspressoTestActivity.class); - - private OnMapReadyIdlingResource idlingResource; - private Polygon polygon; - - @Before - public void registerIdlingResource() { - idlingResource = new OnMapReadyIdlingResource(rule.getActivity()); - Espresso.registerIdlingResources(idlingResource); + @Rule + public final ActivityTestRule rule = new ActivityTestRule<>(EspressoTestActivity.class); + + private OnMapReadyIdlingResource idlingResource; + private Polygon polygon; + + @Before + public void registerIdlingResource() { + idlingResource = new OnMapReadyIdlingResource(rule.getActivity()); + Espresso.registerIdlingResources(idlingResource); + } + + @Test + @Ignore + /** native crash **/ + public void addPolygonTest() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + final MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); + LatLng latLngOne = new LatLng(); + LatLng latLngTwo = new LatLng(1, 0); + LatLng latLngThree = new LatLng(1, 1); + + assertEquals("Polygons should be empty", 0, mapboxMap.getPolygons().size()); + + final PolygonOptions options = new PolygonOptions(); + options.strokeColor(Color.BLUE); + options.fillColor(Color.RED); + options.add(latLngOne); + options.add(latLngTwo); + options.add(latLngThree); + + onView(withId(R.id.mapView)).perform(new AddPolygonAction(mapboxMap, options)); + + assertEquals("Polygons should be 1", 1, mapboxMap.getPolygons().size()); + assertEquals("Polygon id should be 0", 0, polygon.getId()); + assertEquals("Polygon points size should match", 3, polygon.getPoints().size()); + assertEquals("Polygon stroke color should match", Color.BLUE, polygon.getStrokeColor()); + assertEquals("Polygon target should match", Color.RED, polygon.getFillColor()); + mapboxMap.clear(); + assertEquals("Polygons should be empty", 0, mapboxMap.getPolygons().size()); + } + + private class AddPolygonAction implements ViewAction { + + private MapboxMap mapboxMap; + private PolygonOptions options; + + AddPolygonAction(MapboxMap map, PolygonOptions polygonOptions) { + mapboxMap = map; + options = polygonOptions; } - @Test - @Ignore /** native crash **/ - public void addPolygonTest() { - ViewUtils.checkViewIsDisplayed(R.id.mapView); - final MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); - LatLng latLngOne = new LatLng(); - LatLng latLngTwo = new LatLng(1, 0); - LatLng latLngThree = new LatLng(1, 1); - - assertEquals("Polygons should be empty", 0, mapboxMap.getPolygons().size()); - - final PolygonOptions options = new PolygonOptions(); - options.strokeColor(Color.BLUE); - options.fillColor(Color.RED); - options.add(latLngOne); - options.add(latLngTwo); - options.add(latLngThree); - - onView(withId(R.id.mapView)).perform(new AddPolygonAction(mapboxMap, options)); - - assertEquals("Polygons should be 1", 1, mapboxMap.getPolygons().size()); - assertEquals("Polygon id should be 0", 0, polygon.getId()); - assertEquals("Polygon points size should match", 3, polygon.getPoints().size()); - assertEquals("Polygon stroke color should match", Color.BLUE, polygon.getStrokeColor()); - assertEquals("Polygon target should match", Color.RED, polygon.getFillColor()); - mapboxMap.clear(); - assertEquals("Polygons should be empty", 0, mapboxMap.getPolygons().size()); + @Override + public Matcher getConstraints() { + return isDisplayed(); } - private class AddPolygonAction implements ViewAction { - - private MapboxMap mapboxMap; - private PolygonOptions options; - - AddPolygonAction(MapboxMap map, PolygonOptions polygonOptions) { - mapboxMap = map; - options = polygonOptions; - } - - @Override - public Matcher getConstraints() { - return isDisplayed(); - } - - @Override - public String getDescription() { - return getClass().getSimpleName(); - } - - @Override - public void perform(UiController uiController, View view) { - polygon = mapboxMap.addPolygon(options); - } + @Override + public String getDescription() { + return getClass().getSimpleName(); } - @After - public void unregisterIdlingResource() { - Espresso.unregisterIdlingResources(idlingResource); + @Override + public void perform(UiController uiController, View view) { + polygon = mapboxMap.addPolygon(options); } + } + + @After + public void unregisterIdlingResource() { + Espresso.unregisterIdlingResources(idlingResource); + } } diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/annotations/PolylineTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/annotations/PolylineTest.java index eb273b8cf9..607a4ad263 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/annotations/PolylineTest.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/annotations/PolylineTest.java @@ -30,71 +30,71 @@ import static org.junit.Assert.assertEquals; public class PolylineTest { - @Rule - public final ActivityTestRule rule = new ActivityTestRule<>(EspressoTestActivity.class); - - private OnMapReadyIdlingResource idlingResource; - private Polyline polyline; - - @Before - public void registerIdlingResource() { - idlingResource = new OnMapReadyIdlingResource(rule.getActivity()); - Espresso.registerIdlingResources(idlingResource); + @Rule + public final ActivityTestRule rule = new ActivityTestRule<>(EspressoTestActivity.class); + + private OnMapReadyIdlingResource idlingResource; + private Polyline polyline; + + @Before + public void registerIdlingResource() { + idlingResource = new OnMapReadyIdlingResource(rule.getActivity()); + Espresso.registerIdlingResources(idlingResource); + } + + @Ignore + @Test + public void addPolylineTest() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + final MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); + LatLng latLngOne = new LatLng(); + LatLng latLngTwo = new LatLng(1, 0); + + assertEquals("Polygons should be empty", 0, mapboxMap.getPolygons().size()); + + final PolylineOptions options = new PolylineOptions(); + options.color(Color.BLUE); + options.add(latLngOne); + options.add(latLngTwo); + + onView(withId(R.id.mapView)).perform(new AddPolyLineAction(mapboxMap, options)); + + assertEquals("Polylines should be 1", 1, mapboxMap.getPolylines().size()); + assertEquals("Polyline id should be 0", 0, polyline.getId()); + assertEquals("Polyline points size should match", 2, polyline.getPoints().size()); + assertEquals("Polyline stroke color should match", Color.BLUE, polyline.getColor()); + mapboxMap.clear(); + assertEquals("Polyline should be empty", 0, mapboxMap.getPolylines().size()); + } + + private class AddPolyLineAction implements ViewAction { + + private MapboxMap mapboxMap; + private PolylineOptions options; + + AddPolyLineAction(MapboxMap map, PolylineOptions polylineOptions) { + mapboxMap = map; + options = polylineOptions; } - @Ignore - @Test - public void addPolylineTest() { - ViewUtils.checkViewIsDisplayed(R.id.mapView); - final MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); - LatLng latLngOne = new LatLng(); - LatLng latLngTwo = new LatLng(1, 0); - - assertEquals("Polygons should be empty", 0, mapboxMap.getPolygons().size()); - - final PolylineOptions options = new PolylineOptions(); - options.color(Color.BLUE); - options.add(latLngOne); - options.add(latLngTwo); - - onView(withId(R.id.mapView)).perform(new AddPolyLineAction(mapboxMap, options)); - - assertEquals("Polylines should be 1", 1, mapboxMap.getPolylines().size()); - assertEquals("Polyline id should be 0", 0, polyline.getId()); - assertEquals("Polyline points size should match", 2, polyline.getPoints().size()); - assertEquals("Polyline stroke color should match", Color.BLUE, polyline.getColor()); - mapboxMap.clear(); - assertEquals("Polyline should be empty", 0, mapboxMap.getPolylines().size()); + @Override + public Matcher getConstraints() { + return isDisplayed(); } - private class AddPolyLineAction implements ViewAction { - - private MapboxMap mapboxMap; - private PolylineOptions options; - - AddPolyLineAction(MapboxMap map, PolylineOptions polylineOptions) { - mapboxMap = map; - options = polylineOptions; - } - - @Override - public Matcher getConstraints() { - return isDisplayed(); - } - - @Override - public String getDescription() { - return getClass().getSimpleName(); - } - - @Override - public void perform(UiController uiController, View view) { - polyline = mapboxMap.addPolyline(options); - } + @Override + public String getDescription() { + return getClass().getSimpleName(); } - @After - public void unregisterIdlingResource() { - Espresso.unregisterIdlingResources(idlingResource); + @Override + public void perform(UiController uiController, View view) { + polyline = mapboxMap.addPolyline(options); } + } + + @After + public void unregisterIdlingResource() { + Espresso.unregisterIdlingResources(idlingResource); + } } diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/camera/CameraAnimateTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/camera/CameraAnimateTest.java index 73e3c8559f..5ead54eb7b 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/camera/CameraAnimateTest.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/camera/CameraAnimateTest.java @@ -10,7 +10,6 @@ import android.view.View; import com.mapbox.mapboxsdk.camera.CameraPosition; import com.mapbox.mapboxsdk.camera.CameraUpdate; import com.mapbox.mapboxsdk.camera.CameraUpdateFactory; -import com.mapbox.mapboxsdk.constants.MapboxConstants; import com.mapbox.mapboxsdk.geometry.LatLng; import com.mapbox.mapboxsdk.geometry.LatLngBounds; import com.mapbox.mapboxsdk.maps.MapboxMap; @@ -33,206 +32,222 @@ import static org.junit.Assert.assertEquals; public class CameraAnimateTest { - @Rule - public final ActivityTestRule rule = new ActivityTestRule<>(EspressoTestActivity.class); - - private OnMapReadyIdlingResource idlingResource; - - @Before - public void registerIdlingResource() { - idlingResource = new OnMapReadyIdlingResource(rule.getActivity()); - Espresso.registerIdlingResources(idlingResource); - } - - @Test - public void testAnimateToCameraPositionTarget() { - ViewUtils.checkViewIsDisplayed(R.id.mapView); - final MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); - - /*TODO remove zoom #6474*/ - float zoom = 1.0f; - LatLng moveTarget = new LatLng(1, 1); - - CameraPosition initialPosition = new CameraPosition.Builder().target(new LatLng()).zoom(zoom).bearing(0).tilt(0).build(); - CameraPosition cameraPosition = mapboxMap.getCameraPosition(); - assertEquals("Default camera position should match default", cameraPosition, initialPosition); - - onView(withId(R.id.mapView)).perform(new AnimateCameraAction(mapboxMap, CameraUpdateFactory.newLatLng(moveTarget))); - cameraPosition = mapboxMap.getCameraPosition(); - assertEquals("Moved camera position latitude should match", cameraPosition.target.getLatitude(), moveTarget.getLatitude(), TestConstants.LAT_LNG_DELTA); - assertEquals("Moved camera position longitude should match", cameraPosition.target.getLongitude(), moveTarget.getLongitude(), TestConstants.LAT_LNG_DELTA); - } - - @Test - public void testAnimateToCameraPositionTargetZoom() { - ViewUtils.checkViewIsDisplayed(R.id.mapView); - final MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); - - final float moveZoom = 15.5f; - final LatLng moveTarget = new LatLng(1.0000000001, 1.0000000003); - - onView(withId(R.id.mapView)).perform(new AnimateCameraAction(mapboxMap, CameraUpdateFactory.newLatLngZoom(moveTarget, moveZoom))); - CameraPosition cameraPosition = mapboxMap.getCameraPosition(); - assertEquals("Moved camera position latitude should match", cameraPosition.target.getLatitude(), moveTarget.getLatitude(), TestConstants.LAT_LNG_DELTA); - assertEquals("Moved camera position longitude should match", cameraPosition.target.getLongitude(), moveTarget.getLongitude(), TestConstants.LAT_LNG_DELTA); - assertEquals("Moved zoom should match", cameraPosition.zoom, moveZoom, TestConstants.ZOOM_DELTA); - } - - @Test - public void testAnimateToCameraPosition() { - ViewUtils.checkViewIsDisplayed(R.id.mapView); - final MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); - - final LatLng moveTarget = new LatLng(1.0000000001, 1.0000000003); - final float moveZoom = 15.5f; - final float moveTilt = 45.5f; - final float moveBearing = 12.5f; - - onView(withId(R.id.mapView)).perform( - new AnimateCameraAction(mapboxMap, CameraUpdateFactory.newCameraPosition( - new CameraPosition.Builder() - .target(moveTarget) - .zoom(moveZoom) - .tilt(moveTilt) - .bearing(moveBearing) - .build())) - ); - - CameraPosition cameraPosition = mapboxMap.getCameraPosition(); - assertEquals("Moved camera position latitude should match", cameraPosition.target.getLatitude(), moveTarget.getLatitude(), TestConstants.LAT_LNG_DELTA); - assertEquals("Moved camera position longitude should match", cameraPosition.target.getLongitude(), moveTarget.getLongitude(), TestConstants.LAT_LNG_DELTA); - assertEquals("Moved zoom should match", cameraPosition.zoom, moveZoom, TestConstants.ZOOM_DELTA); - assertEquals("Moved zoom should match", cameraPosition.tilt, moveTilt, TestConstants.TILT_DELTA); - assertEquals("Moved bearing should match", cameraPosition.bearing, moveBearing, TestConstants.BEARING_DELTA); - } - - @Test - public void testAnimateToBounds() { - ViewUtils.checkViewIsDisplayed(R.id.mapView); - final MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); - - final LatLng centerBounds = new LatLng(1, 1); - LatLng cornerOne = new LatLng(); - LatLng cornerTwo = new LatLng(2, 2); - - final LatLngBounds.Builder builder = new LatLngBounds.Builder(); - builder.include(cornerOne); - builder.include(cornerTwo); - - onView(withId(R.id.mapView)).perform(new AnimateCameraAction(mapboxMap, CameraUpdateFactory.newLatLngBounds(builder.build(), 0))); - - CameraPosition cameraPosition = mapboxMap.getCameraPosition(); - assertEquals("Moved camera position latitude should match center bounds", - cameraPosition.target.getLatitude(), - centerBounds.getLatitude(), - TestConstants.LAT_LNG_DELTA); - - assertEquals("Moved camera position longitude should match center bounds", - cameraPosition.target.getLongitude(), - centerBounds.getLongitude(), - TestConstants.LAT_LNG_DELTA); - } - - @Test - public void testAnimateToMoveBy() { - ViewUtils.checkViewIsDisplayed(R.id.mapView); - final MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); - - final PointF centerPoint = mapboxMap.getProjection().toScreenLocation(mapboxMap.getCameraPosition().target); - final LatLng moveTarget = new LatLng(2, 2); - final PointF moveTargetPoint = mapboxMap.getProjection().toScreenLocation(moveTarget); - - onView(withId(R.id.mapView)).perform(new AnimateCameraAction(mapboxMap, CameraUpdateFactory.scrollBy( - moveTargetPoint.x - centerPoint.x, moveTargetPoint.y - centerPoint.y))); - - CameraPosition cameraPosition = mapboxMap.getCameraPosition(); - assertEquals("Moved camera position latitude should match", cameraPosition.target.getLatitude(), moveTarget.getLatitude(), TestConstants.LAT_LNG_DELTA_LARGE); - assertEquals("Moved camera position longitude should match", cameraPosition.target.getLongitude(), moveTarget.getLongitude(), TestConstants.LAT_LNG_DELTA_LARGE); + @Rule + public final ActivityTestRule rule = new ActivityTestRule<>(EspressoTestActivity.class); + + private OnMapReadyIdlingResource idlingResource; + + @Before + public void registerIdlingResource() { + idlingResource = new OnMapReadyIdlingResource(rule.getActivity()); + Espresso.registerIdlingResources(idlingResource); + } + + @Test + public void testAnimateToCameraPositionTarget() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + final MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); + + /*TODO remove zoom #6474*/ + float zoom = 1.0f; + LatLng moveTarget = new LatLng(1, 1); + + CameraPosition initialPosition = new CameraPosition.Builder().target( + new LatLng()).zoom(zoom).bearing(0).tilt(0).build(); + CameraPosition cameraPosition = mapboxMap.getCameraPosition(); + assertEquals("Default camera position should match default", cameraPosition, initialPosition); + + onView(withId(R.id.mapView)).perform(new AnimateCameraAction(mapboxMap, CameraUpdateFactory.newLatLng(moveTarget))); + cameraPosition = mapboxMap.getCameraPosition(); + assertEquals("Moved camera position latitude should match", cameraPosition.target.getLatitude(), + moveTarget.getLatitude(), TestConstants.LAT_LNG_DELTA); + assertEquals("Moved camera position longitude should match", cameraPosition.target.getLongitude(), + moveTarget.getLongitude(), TestConstants.LAT_LNG_DELTA); + } + + @Test + public void testAnimateToCameraPositionTargetZoom() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + final MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); + + final float moveZoom = 15.5f; + final LatLng moveTarget = new LatLng(1.0000000001, 1.0000000003); + + onView(withId(R.id.mapView)).perform(new AnimateCameraAction(mapboxMap, + CameraUpdateFactory.newLatLngZoom(moveTarget, moveZoom))); + CameraPosition cameraPosition = mapboxMap.getCameraPosition(); + assertEquals("Moved camera position latitude should match", cameraPosition.target.getLatitude(), + moveTarget.getLatitude(), TestConstants.LAT_LNG_DELTA); + assertEquals("Moved camera position longitude should match", cameraPosition.target.getLongitude(), + moveTarget.getLongitude(), TestConstants.LAT_LNG_DELTA); + assertEquals("Moved zoom should match", cameraPosition.zoom, moveZoom, TestConstants.ZOOM_DELTA); + } + + @Test + public void testAnimateToCameraPosition() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + final MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); + + final LatLng moveTarget = new LatLng(1.0000000001, 1.0000000003); + final float moveZoom = 15.5f; + final float moveTilt = 45.5f; + final float moveBearing = 12.5f; + + onView(withId(R.id.mapView)).perform( + new AnimateCameraAction(mapboxMap, CameraUpdateFactory.newCameraPosition( + new CameraPosition.Builder() + .target(moveTarget) + .zoom(moveZoom) + .tilt(moveTilt) + .bearing(moveBearing) + .build())) + ); + + CameraPosition cameraPosition = mapboxMap.getCameraPosition(); + assertEquals("Moved camera position latitude should match", cameraPosition.target.getLatitude(), + moveTarget.getLatitude(), TestConstants.LAT_LNG_DELTA); + assertEquals("Moved camera position longitude should match", cameraPosition.target.getLongitude(), + moveTarget.getLongitude(), TestConstants.LAT_LNG_DELTA); + assertEquals("Moved zoom should match", cameraPosition.zoom, moveZoom, TestConstants.ZOOM_DELTA); + assertEquals("Moved zoom should match", cameraPosition.tilt, moveTilt, TestConstants.TILT_DELTA); + assertEquals("Moved bearing should match", cameraPosition.bearing, moveBearing, TestConstants.BEARING_DELTA); + } + + @Test + public void testAnimateToBounds() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + final MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); + + final LatLng centerBounds = new LatLng(1, 1); + LatLng cornerOne = new LatLng(); + LatLng cornerTwo = new LatLng(2, 2); + + final LatLngBounds.Builder builder = new LatLngBounds.Builder(); + builder.include(cornerOne); + builder.include(cornerTwo); + + onView(withId(R.id.mapView)).perform(new AnimateCameraAction(mapboxMap, + CameraUpdateFactory.newLatLngBounds(builder.build(), 0))); + + CameraPosition cameraPosition = mapboxMap.getCameraPosition(); + assertEquals("Moved camera position latitude should match center bounds", + cameraPosition.target.getLatitude(), + centerBounds.getLatitude(), + TestConstants.LAT_LNG_DELTA); + + assertEquals("Moved camera position longitude should match center bounds", + cameraPosition.target.getLongitude(), + centerBounds.getLongitude(), + TestConstants.LAT_LNG_DELTA); + } + + @Test + public void testAnimateToMoveBy() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + final MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); + + final PointF centerPoint = mapboxMap.getProjection().toScreenLocation(mapboxMap.getCameraPosition().target); + final LatLng moveTarget = new LatLng(2, 2); + final PointF moveTargetPoint = mapboxMap.getProjection().toScreenLocation(moveTarget); + + onView(withId(R.id.mapView)).perform(new AnimateCameraAction(mapboxMap, CameraUpdateFactory.scrollBy( + moveTargetPoint.x - centerPoint.x, moveTargetPoint.y - centerPoint.y))); + + CameraPosition cameraPosition = mapboxMap.getCameraPosition(); + assertEquals("Moved camera position latitude should match", cameraPosition.target.getLatitude(), + moveTarget.getLatitude(), TestConstants.LAT_LNG_DELTA_LARGE); + assertEquals("Moved camera position longitude should match", cameraPosition.target.getLongitude(), + moveTarget.getLongitude(), TestConstants.LAT_LNG_DELTA_LARGE); + } + + @Test + public void testAnimateToZoomIn() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + final MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); + + /*TODO fix zoom #6474*/ + float zoom = 1.0f; + + onView(withId(R.id.mapView)).perform(new AnimateCameraAction(mapboxMap, CameraUpdateFactory.zoomIn())); + CameraPosition cameraPosition = mapboxMap.getCameraPosition(); + assertEquals("Moved camera zoom should match moved camera zoom", cameraPosition.zoom, zoom + 1, + TestConstants.ZOOM_DELTA); + } + + @Test + public void testAnimateToZoomOut() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + final MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); + + /*TODO fix zoom #6474*/ + float zoom = 10.0f; + onView(withId(R.id.mapView)).perform(new AnimateCameraAction(mapboxMap, + CameraUpdateFactory.newLatLngZoom(new LatLng(), zoom))); + onView(withId(R.id.mapView)).perform(new AnimateCameraAction(mapboxMap, CameraUpdateFactory.zoomOut())); + CameraPosition cameraPosition = mapboxMap.getCameraPosition(); + assertEquals("Moved camera zoom should match moved camera zoom", cameraPosition.zoom, zoom - 1, + TestConstants.ZOOM_DELTA); + } + + @Test + public void testAnimateToZoomBy() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + final MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); + + /*TODO fix zoom #6474*/ + float zoom = 1.0f; + final float zoomBy = 2.45f; + + onView(withId(R.id.mapView)).perform(new AnimateCameraAction(mapboxMap, CameraUpdateFactory.zoomBy(zoomBy))); + CameraPosition cameraPosition = mapboxMap.getCameraPosition(); + assertEquals("Moved camera zoom should match moved camera zoom", cameraPosition.zoom, zoom + zoomBy, + TestConstants.ZOOM_DELTA); + } + + @Test + public void testAnimateToZoomTo() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + final MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); + + /*TODO fix zoom #6474*/ + final float zoomTo = 2.45f; + + onView(withId(R.id.mapView)).perform(new AnimateCameraAction(mapboxMap, CameraUpdateFactory.zoomTo(zoomTo))); + CameraPosition cameraPosition = mapboxMap.getCameraPosition(); + assertEquals("Moved camera zoom should match moved camera zoom", cameraPosition.zoom, zoomTo, + TestConstants.ZOOM_DELTA); + } + + @After + public void unregisterIdlingResource() { + Espresso.unregisterIdlingResources(idlingResource); + } + + private class AnimateCameraAction implements ViewAction { + + private MapboxMap mapboxMap; + private CameraUpdate cameraUpdate; + + AnimateCameraAction(MapboxMap map, CameraUpdate update) { + mapboxMap = map; + cameraUpdate = update; } - @Test - public void testAnimateToZoomIn() { - ViewUtils.checkViewIsDisplayed(R.id.mapView); - final MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); - - /*TODO fix zoom #6474*/ - float zoom = 1.0f; - - onView(withId(R.id.mapView)).perform(new AnimateCameraAction(mapboxMap, CameraUpdateFactory.zoomIn())); - CameraPosition cameraPosition = mapboxMap.getCameraPosition(); - assertEquals("Moved camera zoom should match moved camera zoom", cameraPosition.zoom, zoom + 1, TestConstants.ZOOM_DELTA); + @Override + public Matcher getConstraints() { + return isDisplayed(); } - @Test - public void testAnimateToZoomOut() { - ViewUtils.checkViewIsDisplayed(R.id.mapView); - final MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); - - /*TODO fix zoom #6474*/ - float zoom = 10.0f; - onView(withId(R.id.mapView)).perform(new AnimateCameraAction(mapboxMap, CameraUpdateFactory.newLatLngZoom(new LatLng(), zoom))); - onView(withId(R.id.mapView)).perform(new AnimateCameraAction(mapboxMap, CameraUpdateFactory.zoomOut())); - CameraPosition cameraPosition = mapboxMap.getCameraPosition(); - assertEquals("Moved camera zoom should match moved camera zoom", cameraPosition.zoom, zoom - 1, TestConstants.ZOOM_DELTA); + @Override + public String getDescription() { + return getClass().getSimpleName(); } - @Test - public void testAnimateToZoomBy() { - ViewUtils.checkViewIsDisplayed(R.id.mapView); - final MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); - - /*TODO fix zoom #6474*/ - float zoom = 1.0f; - final float zoomBy = 2.45f; - - onView(withId(R.id.mapView)).perform(new AnimateCameraAction(mapboxMap, CameraUpdateFactory.zoomBy(zoomBy))); - CameraPosition cameraPosition = mapboxMap.getCameraPosition(); - assertEquals("Moved camera zoom should match moved camera zoom", cameraPosition.zoom, zoom + zoomBy, TestConstants.ZOOM_DELTA); - } - - @Test - public void testAnimateToZoomTo() { - ViewUtils.checkViewIsDisplayed(R.id.mapView); - final MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); - - /*TODO fix zoom #6474*/ - final float zoomTo = 2.45f; - - onView(withId(R.id.mapView)).perform(new AnimateCameraAction(mapboxMap, CameraUpdateFactory.zoomTo(zoomTo))); - CameraPosition cameraPosition = mapboxMap.getCameraPosition(); - assertEquals("Moved camera zoom should match moved camera zoom", cameraPosition.zoom, zoomTo, TestConstants.ZOOM_DELTA); - } - - @After - public void unregisterIdlingResource() { - Espresso.unregisterIdlingResources(idlingResource); - } - - private class AnimateCameraAction implements ViewAction { - - private MapboxMap mapboxMap; - private CameraUpdate cameraUpdate; - - AnimateCameraAction(MapboxMap map, CameraUpdate update) { - mapboxMap = map; - cameraUpdate = update; - } - - @Override - public Matcher getConstraints() { - return isDisplayed(); - } - - @Override - public String getDescription() { - return getClass().getSimpleName(); - } - - @Override - public void perform(UiController uiController, View view) { - mapboxMap.animateCamera(cameraUpdate); - uiController.loopMainThreadForAtLeast(TestConstants.ANIMATION_TEST_TIME); - } + @Override + public void perform(UiController uiController, View view) { + mapboxMap.animateCamera(cameraUpdate); + uiController.loopMainThreadForAtLeast(TestConstants.ANIMATION_TEST_TIME); } + } } diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/camera/CameraEaseTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/camera/CameraEaseTest.java index 4f27703b18..22af72cebb 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/camera/CameraEaseTest.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/camera/CameraEaseTest.java @@ -10,7 +10,6 @@ import android.view.View; import com.mapbox.mapboxsdk.camera.CameraPosition; import com.mapbox.mapboxsdk.camera.CameraUpdate; import com.mapbox.mapboxsdk.camera.CameraUpdateFactory; -import com.mapbox.mapboxsdk.constants.MapboxConstants; import com.mapbox.mapboxsdk.geometry.LatLng; import com.mapbox.mapboxsdk.geometry.LatLngBounds; import com.mapbox.mapboxsdk.maps.MapboxMap; @@ -33,206 +32,221 @@ import static org.junit.Assert.assertEquals; public class CameraEaseTest { - @Rule - public final ActivityTestRule rule = new ActivityTestRule<>(EspressoTestActivity.class); - - private OnMapReadyIdlingResource idlingResource; - - @Before - public void registerIdlingResource() { - idlingResource = new OnMapReadyIdlingResource(rule.getActivity()); - Espresso.registerIdlingResources(idlingResource); - } - - @Test - public void testEaseToCameraPositionTarget() { - ViewUtils.checkViewIsDisplayed(R.id.mapView); - final MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); - - /*TODO remove zoom #6474*/ - float zoom = 1.0f; - LatLng moveTarget = new LatLng(1, 1); - - CameraPosition initialPosition = new CameraPosition.Builder().target(new LatLng()).zoom(zoom).bearing(0).tilt(0).build(); - CameraPosition cameraPosition = mapboxMap.getCameraPosition(); - assertEquals("Default camera position should match default", cameraPosition, initialPosition); - - onView(withId(R.id.mapView)).perform(new EaseCameraAction(mapboxMap, CameraUpdateFactory.newLatLng(moveTarget))); - cameraPosition = mapboxMap.getCameraPosition(); - assertEquals("Moved camera position latitude should match", cameraPosition.target.getLatitude(), moveTarget.getLatitude(), TestConstants.LAT_LNG_DELTA); - assertEquals("Moved camera position longitude should match", cameraPosition.target.getLongitude(), moveTarget.getLongitude(), TestConstants.LAT_LNG_DELTA); - } - - @Test - public void testEaseToCameraPositionTargetZoom() { - ViewUtils.checkViewIsDisplayed(R.id.mapView); - final MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); - - final float moveZoom = 15.5f; - final LatLng moveTarget = new LatLng(1.0000000001, 1.0000000003); - - onView(withId(R.id.mapView)).perform(new EaseCameraAction(mapboxMap, CameraUpdateFactory.newLatLngZoom(moveTarget, moveZoom))); - CameraPosition cameraPosition = mapboxMap.getCameraPosition(); - assertEquals("Moved camera position latitude should match", cameraPosition.target.getLatitude(), moveTarget.getLatitude(), TestConstants.LAT_LNG_DELTA); - assertEquals("Moved camera position longitude should match", cameraPosition.target.getLongitude(), moveTarget.getLongitude(), TestConstants.LAT_LNG_DELTA); - assertEquals("Moved zoom should match", cameraPosition.zoom, moveZoom, TestConstants.ZOOM_DELTA); - } - - @Test - public void testEaseToCameraPosition() { - ViewUtils.checkViewIsDisplayed(R.id.mapView); - final MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); - - final LatLng moveTarget = new LatLng(1.0000000001, 1.0000000003); - final float moveZoom = 15.5f; - final float moveTilt = 45.5f; - final float moveBearing = 12.5f; - - onView(withId(R.id.mapView)).perform( - new EaseCameraAction(mapboxMap, CameraUpdateFactory.newCameraPosition( - new CameraPosition.Builder() - .target(moveTarget) - .zoom(moveZoom) - .tilt(moveTilt) - .bearing(moveBearing) - .build())) - ); - - CameraPosition cameraPosition = mapboxMap.getCameraPosition(); - assertEquals("Moved camera position latitude should match", cameraPosition.target.getLatitude(), moveTarget.getLatitude(), TestConstants.LAT_LNG_DELTA); - assertEquals("Moved camera position longitude should match", cameraPosition.target.getLongitude(), moveTarget.getLongitude(), TestConstants.LAT_LNG_DELTA); - assertEquals("Moved zoom should match", cameraPosition.zoom, moveZoom, TestConstants.ZOOM_DELTA); - assertEquals("Moved zoom should match", cameraPosition.tilt, moveTilt, TestConstants.TILT_DELTA); - assertEquals("Moved bearing should match", cameraPosition.bearing, moveBearing, TestConstants.BEARING_DELTA); - } - - @Test - public void testEaseToBounds() { - ViewUtils.checkViewIsDisplayed(R.id.mapView); - final MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); - - final LatLng centerBounds = new LatLng(1, 1); - LatLng cornerOne = new LatLng(); - LatLng cornerTwo = new LatLng(2, 2); - - final LatLngBounds.Builder builder = new LatLngBounds.Builder(); - builder.include(cornerOne); - builder.include(cornerTwo); - - onView(withId(R.id.mapView)).perform(new EaseCameraAction(mapboxMap, CameraUpdateFactory.newLatLngBounds(builder.build(), 0))); - - CameraPosition cameraPosition = mapboxMap.getCameraPosition(); - assertEquals("Moved camera position latitude should match center bounds", - cameraPosition.target.getLatitude(), - centerBounds.getLatitude(), - TestConstants.LAT_LNG_DELTA); - - assertEquals("Moved camera position longitude should match center bounds", - cameraPosition.target.getLongitude(), - centerBounds.getLongitude(), - TestConstants.LAT_LNG_DELTA); - } - - @Test - public void testEaseToMoveBy() { - ViewUtils.checkViewIsDisplayed(R.id.mapView); - final MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); - - final PointF centerPoint = mapboxMap.getProjection().toScreenLocation(mapboxMap.getCameraPosition().target); - final LatLng moveTarget = new LatLng(2, 2); - final PointF moveTargetPoint = mapboxMap.getProjection().toScreenLocation(moveTarget); - - onView(withId(R.id.mapView)).perform(new EaseCameraAction(mapboxMap, CameraUpdateFactory.scrollBy( - moveTargetPoint.x - centerPoint.x, moveTargetPoint.y - centerPoint.y))); - - CameraPosition cameraPosition = mapboxMap.getCameraPosition(); - assertEquals("Moved camera position latitude should match", cameraPosition.target.getLatitude(), moveTarget.getLatitude(), TestConstants.LAT_LNG_DELTA_LARGE); - assertEquals("Moved camera position longitude should match", cameraPosition.target.getLongitude(), moveTarget.getLongitude(), TestConstants.LAT_LNG_DELTA_LARGE); + @Rule + public final ActivityTestRule rule = new ActivityTestRule<>(EspressoTestActivity.class); + + private OnMapReadyIdlingResource idlingResource; + + @Before + public void registerIdlingResource() { + idlingResource = new OnMapReadyIdlingResource(rule.getActivity()); + Espresso.registerIdlingResources(idlingResource); + } + + @Test + public void testEaseToCameraPositionTarget() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + final MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); + + /*TODO remove zoom #6474*/ + float zoom = 1.0f; + LatLng moveTarget = new LatLng(1, 1); + + CameraPosition initialPosition = new CameraPosition.Builder().target( + new LatLng()).zoom(zoom).bearing(0).tilt(0).build(); + CameraPosition cameraPosition = mapboxMap.getCameraPosition(); + assertEquals("Default camera position should match default", cameraPosition, initialPosition); + + onView(withId(R.id.mapView)).perform(new EaseCameraAction(mapboxMap, CameraUpdateFactory.newLatLng(moveTarget))); + cameraPosition = mapboxMap.getCameraPosition(); + assertEquals("Moved camera position latitude should match", cameraPosition.target.getLatitude(), + moveTarget.getLatitude(), TestConstants.LAT_LNG_DELTA); + assertEquals("Moved camera position longitude should match", cameraPosition.target.getLongitude(), + moveTarget.getLongitude(), TestConstants.LAT_LNG_DELTA); + } + + @Test + public void testEaseToCameraPositionTargetZoom() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + final MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); + + final float moveZoom = 15.5f; + final LatLng moveTarget = new LatLng(1.0000000001, 1.0000000003); + + onView(withId(R.id.mapView)).perform(new EaseCameraAction(mapboxMap, + CameraUpdateFactory.newLatLngZoom(moveTarget, moveZoom))); + CameraPosition cameraPosition = mapboxMap.getCameraPosition(); + assertEquals("Moved camera position latitude should match", cameraPosition.target.getLatitude(), + moveTarget.getLatitude(), TestConstants.LAT_LNG_DELTA); + assertEquals("Moved camera position longitude should match", cameraPosition.target.getLongitude(), + moveTarget.getLongitude(), TestConstants.LAT_LNG_DELTA); + assertEquals("Moved zoom should match", cameraPosition.zoom, moveZoom, TestConstants.ZOOM_DELTA); + } + + @Test + public void testEaseToCameraPosition() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + final MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); + + final LatLng moveTarget = new LatLng(1.0000000001, 1.0000000003); + final float moveZoom = 15.5f; + final float moveTilt = 45.5f; + final float moveBearing = 12.5f; + + onView(withId(R.id.mapView)).perform( + new EaseCameraAction(mapboxMap, CameraUpdateFactory.newCameraPosition( + new CameraPosition.Builder() + .target(moveTarget) + .zoom(moveZoom) + .tilt(moveTilt) + .bearing(moveBearing) + .build())) + ); + + CameraPosition cameraPosition = mapboxMap.getCameraPosition(); + assertEquals("Moved camera position latitude should match", cameraPosition.target.getLatitude(), + moveTarget.getLatitude(), TestConstants.LAT_LNG_DELTA); + assertEquals("Moved camera position longitude should match", cameraPosition.target.getLongitude(), + moveTarget.getLongitude(), TestConstants.LAT_LNG_DELTA); + assertEquals("Moved zoom should match", cameraPosition.zoom, moveZoom, TestConstants.ZOOM_DELTA); + assertEquals("Moved zoom should match", cameraPosition.tilt, moveTilt, TestConstants.TILT_DELTA); + assertEquals("Moved bearing should match", cameraPosition.bearing, moveBearing, TestConstants.BEARING_DELTA); + } + + @Test + public void testEaseToBounds() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + final MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); + + final LatLng centerBounds = new LatLng(1, 1); + LatLng cornerOne = new LatLng(); + LatLng cornerTwo = new LatLng(2, 2); + + final LatLngBounds.Builder builder = new LatLngBounds.Builder(); + builder.include(cornerOne); + builder.include(cornerTwo); + + onView(withId(R.id.mapView)).perform(new EaseCameraAction(mapboxMap, + CameraUpdateFactory.newLatLngBounds(builder.build(), 0))); + + CameraPosition cameraPosition = mapboxMap.getCameraPosition(); + assertEquals("Moved camera position latitude should match center bounds", + cameraPosition.target.getLatitude(), + centerBounds.getLatitude(), + TestConstants.LAT_LNG_DELTA); + + assertEquals("Moved camera position longitude should match center bounds", + cameraPosition.target.getLongitude(), + centerBounds.getLongitude(), + TestConstants.LAT_LNG_DELTA); + } + + @Test + public void testEaseToMoveBy() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + final MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); + + final PointF centerPoint = mapboxMap.getProjection().toScreenLocation(mapboxMap.getCameraPosition().target); + final LatLng moveTarget = new LatLng(2, 2); + final PointF moveTargetPoint = mapboxMap.getProjection().toScreenLocation(moveTarget); + + onView(withId(R.id.mapView)).perform(new EaseCameraAction(mapboxMap, CameraUpdateFactory.scrollBy( + moveTargetPoint.x - centerPoint.x, moveTargetPoint.y - centerPoint.y))); + + CameraPosition cameraPosition = mapboxMap.getCameraPosition(); + assertEquals("Moved camera position latitude should match", cameraPosition.target.getLatitude(), + moveTarget.getLatitude(), TestConstants.LAT_LNG_DELTA_LARGE); + assertEquals("Moved camera position longitude should match", cameraPosition.target.getLongitude(), + moveTarget.getLongitude(), TestConstants.LAT_LNG_DELTA_LARGE); + } + + @Test + public void testEaseToZoomIn() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + final MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); + + /*TODO fix zoom #6474*/ + float zoom = 1.0f; + + onView(withId(R.id.mapView)).perform(new EaseCameraAction(mapboxMap, CameraUpdateFactory.zoomIn())); + CameraPosition cameraPosition = mapboxMap.getCameraPosition(); + assertEquals("Moved camera zoom should match moved camera zoom", cameraPosition.zoom, zoom + 1, + TestConstants.ZOOM_DELTA); + } + + @Test + public void testEaseToZoomOut() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + final MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); + + /*TODO fix zoom #6474*/ + float zoom = 10.0f; + onView(withId(R.id.mapView)).perform(new EaseCameraAction(mapboxMap, + CameraUpdateFactory.newLatLngZoom(new LatLng(), zoom))); + onView(withId(R.id.mapView)).perform(new EaseCameraAction(mapboxMap, CameraUpdateFactory.zoomOut())); + CameraPosition cameraPosition = mapboxMap.getCameraPosition(); + assertEquals("Moved camera zoom should match moved camera zoom", 9, cameraPosition.zoom, TestConstants.ZOOM_DELTA); + } + + @Test + public void testEaseToZoomBy() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + final MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); + + /*TODO fix zoom #6474*/ + float zoom = 1.0f; + final float zoomBy = 2.45f; + + onView(withId(R.id.mapView)).perform(new EaseCameraAction(mapboxMap, CameraUpdateFactory.zoomBy(zoomBy))); + CameraPosition cameraPosition = mapboxMap.getCameraPosition(); + assertEquals("Moved camera zoom should match moved camera zoom", cameraPosition.zoom, zoom + zoomBy, + TestConstants.ZOOM_DELTA); + } + + @Test + public void testEaseToZoomTo() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + final MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); + + /*TODO fix zoom #6474*/ + final float zoomTo = 2.45f; + + onView(withId(R.id.mapView)).perform(new EaseCameraAction(mapboxMap, CameraUpdateFactory.zoomTo(zoomTo))); + CameraPosition cameraPosition = mapboxMap.getCameraPosition(); + assertEquals("Moved camera zoom should match moved camera zoom", cameraPosition.zoom, zoomTo, + TestConstants.ZOOM_DELTA); + } + + @After + public void unregisterIdlingResource() { + Espresso.unregisterIdlingResources(idlingResource); + } + + private class EaseCameraAction implements ViewAction { + + private MapboxMap mapboxMap; + private CameraUpdate cameraUpdate; + + EaseCameraAction(MapboxMap map, CameraUpdate update) { + mapboxMap = map; + cameraUpdate = update; } - @Test - public void testEaseToZoomIn() { - ViewUtils.checkViewIsDisplayed(R.id.mapView); - final MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); - - /*TODO fix zoom #6474*/ - float zoom = 1.0f; - - onView(withId(R.id.mapView)).perform(new EaseCameraAction(mapboxMap, CameraUpdateFactory.zoomIn())); - CameraPosition cameraPosition = mapboxMap.getCameraPosition(); - assertEquals("Moved camera zoom should match moved camera zoom", cameraPosition.zoom, zoom + 1, TestConstants.ZOOM_DELTA); + @Override + public Matcher getConstraints() { + return isDisplayed(); } - @Test - public void testEaseToZoomOut() { - ViewUtils.checkViewIsDisplayed(R.id.mapView); - final MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); - - /*TODO fix zoom #6474*/ - float zoom = 10.0f; - onView(withId(R.id.mapView)).perform(new EaseCameraAction(mapboxMap, CameraUpdateFactory.newLatLngZoom(new LatLng(), zoom))); - onView(withId(R.id.mapView)).perform(new EaseCameraAction(mapboxMap, CameraUpdateFactory.zoomOut())); - CameraPosition cameraPosition = mapboxMap.getCameraPosition(); - assertEquals("Moved camera zoom should match moved camera zoom", 9, cameraPosition.zoom, TestConstants.ZOOM_DELTA); + @Override + public String getDescription() { + return getClass().getSimpleName(); } - @Test - public void testEaseToZoomBy() { - ViewUtils.checkViewIsDisplayed(R.id.mapView); - final MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); - - /*TODO fix zoom #6474*/ - float zoom = 1.0f; - final float zoomBy = 2.45f; - - onView(withId(R.id.mapView)).perform(new EaseCameraAction(mapboxMap, CameraUpdateFactory.zoomBy(zoomBy))); - CameraPosition cameraPosition = mapboxMap.getCameraPosition(); - assertEquals("Moved camera zoom should match moved camera zoom", cameraPosition.zoom, zoom + zoomBy, TestConstants.ZOOM_DELTA); - } - - @Test - public void testEaseToZoomTo() { - ViewUtils.checkViewIsDisplayed(R.id.mapView); - final MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); - - /*TODO fix zoom #6474*/ - final float zoomTo = 2.45f; - - onView(withId(R.id.mapView)).perform(new EaseCameraAction(mapboxMap, CameraUpdateFactory.zoomTo(zoomTo))); - CameraPosition cameraPosition = mapboxMap.getCameraPosition(); - assertEquals("Moved camera zoom should match moved camera zoom", cameraPosition.zoom, zoomTo, TestConstants.ZOOM_DELTA); - } - - @After - public void unregisterIdlingResource() { - Espresso.unregisterIdlingResources(idlingResource); - } - - private class EaseCameraAction implements ViewAction { - - private MapboxMap mapboxMap; - private CameraUpdate cameraUpdate; - - EaseCameraAction(MapboxMap map, CameraUpdate update) { - mapboxMap = map; - cameraUpdate = update; - } - - @Override - public Matcher getConstraints() { - return isDisplayed(); - } - - @Override - public String getDescription() { - return getClass().getSimpleName(); - } - - @Override - public void perform(UiController uiController, View view) { - mapboxMap.easeCamera(cameraUpdate); - uiController.loopMainThreadForAtLeast(TestConstants.ANIMATION_TEST_TIME); - } + @Override + public void perform(UiController uiController, View view) { + mapboxMap.easeCamera(cameraUpdate); + uiController.loopMainThreadForAtLeast(TestConstants.ANIMATION_TEST_TIME); } + } } diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/camera/CameraInternalAPITest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/camera/CameraInternalAPITest.java deleted file mode 100644 index e180ab77b2..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/camera/CameraInternalAPITest.java +++ /dev/null @@ -1,167 +0,0 @@ -package com.mapbox.mapboxsdk.testapp.camera; - -import android.support.test.espresso.Espresso; -import android.support.test.espresso.UiController; -import android.support.test.espresso.ViewAction; -import android.support.test.rule.ActivityTestRule; -import android.view.View; - -import com.mapbox.mapboxsdk.camera.CameraPosition; -import com.mapbox.mapboxsdk.geometry.LatLng; -import com.mapbox.mapboxsdk.maps.MapView; -import com.mapbox.mapboxsdk.maps.MapboxMap; -import com.mapbox.mapboxsdk.maps.MapViewUtils; -import com.mapbox.mapboxsdk.testapp.R; -import com.mapbox.mapboxsdk.testapp.activity.espresso.EspressoTestActivity; -import com.mapbox.mapboxsdk.testapp.utils.OnMapReadyIdlingResource; -import com.mapbox.mapboxsdk.testapp.utils.TestConstants; -import com.mapbox.mapboxsdk.testapp.utils.ViewUtils; - -import org.hamcrest.Matcher; -import org.junit.After; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; - -import static android.support.test.espresso.Espresso.onView; -import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed; -import static android.support.test.espresso.matcher.ViewMatchers.withId; -import static org.junit.Assert.assertEquals; - -/** - * Tests camera transformations that aren't part of our public API - */ -public class CameraInternalAPITest { - - @Rule - public final ActivityTestRule rule = new ActivityTestRule<>(EspressoTestActivity.class); - - private OnMapReadyIdlingResource idlingResource; - - @Before - public void registerIdlingResource() { - idlingResource = new OnMapReadyIdlingResource(rule.getActivity()); - Espresso.registerIdlingResources(idlingResource); - } - - @Test - public void testBearing() { - ViewUtils.checkViewIsDisplayed(R.id.mapView); - EspressoTestActivity activity = rule.getActivity(); - MapboxMap mapboxMap = activity.getMapboxMap(); - - CameraPosition initialPosition = new CameraPosition.Builder().target(new LatLng()).zoom(1).bearing(0).tilt(0).build(); - CameraPosition cameraPosition = mapboxMap.getCameraPosition(); - assertEquals("Default camera position should match default", cameraPosition, initialPosition); - - onView(withId(R.id.mapView)).perform(new BearingAction(mapboxMap)); - assertEquals("Bearing should match", 45.1f, MapViewUtils.getDirection(mapboxMap), TestConstants.BEARING_DELTA); - } - - @Test - public void testTilt() { - ViewUtils.checkViewIsDisplayed(R.id.mapView); - EspressoTestActivity activity = rule.getActivity(); - MapboxMap mapboxMap = activity.getMapboxMap(); - - CameraPosition initialPosition = new CameraPosition.Builder().target(new LatLng()).zoom(1).bearing(0).tilt(0).build(); - CameraPosition cameraPosition = mapboxMap.getCameraPosition(); - assertEquals("Default camera position should match default", cameraPosition, initialPosition); - - onView(withId(R.id.mapView)).perform(new TiltAction(mapboxMap)); - assertEquals("Tilt should match", 40.0f, MapViewUtils.getTilt(mapboxMap), TestConstants.TILT_DELTA); - } - - @Test - public void testLatLng() { - ViewUtils.checkViewIsDisplayed(R.id.mapView); - EspressoTestActivity activity = rule.getActivity(); - MapboxMap mapboxMap = activity.getMapboxMap(); - - CameraPosition initialPosition = new CameraPosition.Builder().target(new LatLng()).zoom(1).bearing(0).tilt(0).build(); - CameraPosition cameraPosition = mapboxMap.getCameraPosition(); - assertEquals("Default camera position should match default", cameraPosition, initialPosition); - - onView(withId(R.id.mapView)).perform(new LatLngAction(mapboxMap)); - LatLng centerCoordinate = MapViewUtils.getLatLng(mapboxMap); - assertEquals("Latitude should match", 1.1f, centerCoordinate.getLatitude(), TestConstants.LAT_LNG_DELTA); - assertEquals("Longitude should match", 2.2f, centerCoordinate.getLongitude(), TestConstants.LAT_LNG_DELTA); - } - - @After - public void unregisterIdlingResource() { - Espresso.unregisterIdlingResources(idlingResource); - } - - private class BearingAction implements ViewAction { - - private MapboxMap mapboxMap; - - BearingAction(MapboxMap mapboxMap) { - this.mapboxMap = mapboxMap; - } - - @Override - public Matcher getConstraints() { - return isDisplayed(); - } - - @Override - public String getDescription() { - return getClass().getSimpleName(); - } - - @Override - public void perform(UiController uiController, View view) { - MapViewUtils.setDirection(mapboxMap, -45.1f); - } - } - - private class TiltAction implements ViewAction { - - private MapboxMap mapboxMap; - - TiltAction(MapboxMap mapboxMap) { - this.mapboxMap = mapboxMap; - } - - @Override - public Matcher getConstraints() { - return isDisplayed(); - } - - @Override - public String getDescription() { - return getClass().getSimpleName(); - } - - @Override - public void perform(UiController uiController, View view) { - MapViewUtils.setTilt(mapboxMap, 40.0f); - } - } - - private class LatLngAction implements ViewAction { - - private MapboxMap mapboxMap; - - LatLngAction(MapboxMap mapboxMap) { - this.mapboxMap = mapboxMap; - } - - @Override - public Matcher getConstraints() { - return isDisplayed(); - } - - @Override - public String getDescription() { - return getClass().getSimpleName(); - } - - @Override - public void perform(UiController uiController, View view) { - MapViewUtils.setLatLng(mapboxMap, new LatLng(1.1, 2.2)); - } - } -} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/camera/CameraInternalApiTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/camera/CameraInternalApiTest.java new file mode 100644 index 0000000000..1b40e265d2 --- /dev/null +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/camera/CameraInternalApiTest.java @@ -0,0 +1,169 @@ +package com.mapbox.mapboxsdk.testapp.camera; + +import android.support.test.espresso.Espresso; +import android.support.test.espresso.UiController; +import android.support.test.espresso.ViewAction; +import android.support.test.rule.ActivityTestRule; +import android.view.View; + +import com.mapbox.mapboxsdk.camera.CameraPosition; +import com.mapbox.mapboxsdk.geometry.LatLng; +import com.mapbox.mapboxsdk.maps.MapViewUtils; +import com.mapbox.mapboxsdk.maps.MapboxMap; +import com.mapbox.mapboxsdk.testapp.R; +import com.mapbox.mapboxsdk.testapp.activity.espresso.EspressoTestActivity; +import com.mapbox.mapboxsdk.testapp.utils.OnMapReadyIdlingResource; +import com.mapbox.mapboxsdk.testapp.utils.TestConstants; +import com.mapbox.mapboxsdk.testapp.utils.ViewUtils; + +import org.hamcrest.Matcher; +import org.junit.After; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; + +import static android.support.test.espresso.Espresso.onView; +import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed; +import static android.support.test.espresso.matcher.ViewMatchers.withId; +import static org.junit.Assert.assertEquals; + +/** + * Tests camera transformations that aren't part of our public API + */ +public class CameraInternalApiTest { + + @Rule + public final ActivityTestRule rule = new ActivityTestRule<>(EspressoTestActivity.class); + + private OnMapReadyIdlingResource idlingResource; + + @Before + public void registerIdlingResource() { + idlingResource = new OnMapReadyIdlingResource(rule.getActivity()); + Espresso.registerIdlingResources(idlingResource); + } + + @Test + public void testBearing() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + EspressoTestActivity activity = rule.getActivity(); + MapboxMap mapboxMap = activity.getMapboxMap(); + + CameraPosition initialPosition = new + CameraPosition.Builder().target(new LatLng()).zoom(1).bearing(0).tilt(0).build(); + CameraPosition cameraPosition = mapboxMap.getCameraPosition(); + assertEquals("Default camera position should match default", cameraPosition, initialPosition); + + onView(withId(R.id.mapView)).perform(new BearingAction(mapboxMap)); + assertEquals("Bearing should match", 45.1f, MapViewUtils.getDirection(mapboxMap), TestConstants.BEARING_DELTA); + } + + @Test + public void testTilt() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + EspressoTestActivity activity = rule.getActivity(); + MapboxMap mapboxMap = activity.getMapboxMap(); + + CameraPosition initialPosition = new CameraPosition.Builder().target( + new LatLng()).zoom(1).bearing(0).tilt(0).build(); + CameraPosition cameraPosition = mapboxMap.getCameraPosition(); + assertEquals("Default camera position should match default", cameraPosition, initialPosition); + + onView(withId(R.id.mapView)).perform(new TiltAction(mapboxMap)); + assertEquals("Tilt should match", 40.0f, MapViewUtils.getTilt(mapboxMap), TestConstants.TILT_DELTA); + } + + @Test + public void testLatLng() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + EspressoTestActivity activity = rule.getActivity(); + MapboxMap mapboxMap = activity.getMapboxMap(); + + CameraPosition initialPosition = new CameraPosition.Builder().target( + new LatLng()).zoom(1).bearing(0).tilt(0).build(); + CameraPosition cameraPosition = mapboxMap.getCameraPosition(); + assertEquals("Default camera position should match default", cameraPosition, initialPosition); + + onView(withId(R.id.mapView)).perform(new LatLngAction(mapboxMap)); + LatLng centerCoordinate = MapViewUtils.getLatLng(mapboxMap); + assertEquals("Latitude should match", 1.1f, centerCoordinate.getLatitude(), TestConstants.LAT_LNG_DELTA); + assertEquals("Longitude should match", 2.2f, centerCoordinate.getLongitude(), TestConstants.LAT_LNG_DELTA); + } + + @After + public void unregisterIdlingResource() { + Espresso.unregisterIdlingResources(idlingResource); + } + + private class BearingAction implements ViewAction { + + private MapboxMap mapboxMap; + + BearingAction(MapboxMap mapboxMap) { + this.mapboxMap = mapboxMap; + } + + @Override + public Matcher getConstraints() { + return isDisplayed(); + } + + @Override + public String getDescription() { + return getClass().getSimpleName(); + } + + @Override + public void perform(UiController uiController, View view) { + MapViewUtils.setDirection(mapboxMap, -45.1f); + } + } + + private class TiltAction implements ViewAction { + + private MapboxMap mapboxMap; + + TiltAction(MapboxMap mapboxMap) { + this.mapboxMap = mapboxMap; + } + + @Override + public Matcher getConstraints() { + return isDisplayed(); + } + + @Override + public String getDescription() { + return getClass().getSimpleName(); + } + + @Override + public void perform(UiController uiController, View view) { + MapViewUtils.setTilt(mapboxMap, 40.0f); + } + } + + private class LatLngAction implements ViewAction { + + private MapboxMap mapboxMap; + + LatLngAction(MapboxMap mapboxMap) { + this.mapboxMap = mapboxMap; + } + + @Override + public Matcher getConstraints() { + return isDisplayed(); + } + + @Override + public String getDescription() { + return getClass().getSimpleName(); + } + + @Override + public void perform(UiController uiController, View view) { + MapViewUtils.setLatLng(mapboxMap, new LatLng(1.1, 2.2)); + } + } +} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/camera/CameraMoveTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/camera/CameraMoveTest.java index 80f5dda77e..b3a7fe0d11 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/camera/CameraMoveTest.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/camera/CameraMoveTest.java @@ -29,209 +29,224 @@ import static android.support.test.espresso.Espresso.onView; import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed; import static android.support.test.espresso.matcher.ViewMatchers.withId; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; public class CameraMoveTest { - - @Rule - public final ActivityTestRule rule = new ActivityTestRule<>(EspressoTestActivity.class); - private OnMapReadyIdlingResource idlingResource; - - @Before - public void registerIdlingResource() { - idlingResource = new OnMapReadyIdlingResource(rule.getActivity()); - Espresso.registerIdlingResources(idlingResource); + @Rule + public final ActivityTestRule rule = new ActivityTestRule<>(EspressoTestActivity.class); + + private OnMapReadyIdlingResource idlingResource; + + @Before + public void registerIdlingResource() { + idlingResource = new OnMapReadyIdlingResource(rule.getActivity()); + Espresso.registerIdlingResources(idlingResource); + } + + @Test + public void testMoveToCameraPositionTarget() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + final MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); + + /*TODO remove zoom #6474*/ + float zoom = 1.0f; + LatLng moveTarget = new LatLng(1, 1); + + CameraPosition initialPosition = new CameraPosition.Builder().target( + new LatLng()).zoom(zoom).bearing(0).tilt(0).build(); + CameraPosition cameraPosition = mapboxMap.getCameraPosition(); + assertEquals("Default camera position should match default", cameraPosition, initialPosition); + + onView(withId(R.id.mapView)).perform(new MoveCameraAction(mapboxMap, CameraUpdateFactory.newLatLng(moveTarget))); + cameraPosition = mapboxMap.getCameraPosition(); + assertEquals("Moved camera position latitude should match", cameraPosition.target.getLatitude(), + moveTarget.getLatitude(), TestConstants.LAT_LNG_DELTA); + assertEquals("Moved camera position longitude should match", cameraPosition.target.getLongitude(), + moveTarget.getLongitude(), TestConstants.LAT_LNG_DELTA); + } + + @Test + public void testMoveToCameraPositionTargetZoom() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + final MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); + + final float moveZoom = 15.5f; + final LatLng moveTarget = new LatLng(1.0000000001, 1.0000000003); + + onView(withId(R.id.mapView)).perform(new MoveCameraAction(mapboxMap, + CameraUpdateFactory.newLatLngZoom(moveTarget, moveZoom))); + CameraPosition cameraPosition = mapboxMap.getCameraPosition(); + assertEquals("Moved camera position latitude should match", cameraPosition.target.getLatitude(), + moveTarget.getLatitude(), TestConstants.LAT_LNG_DELTA); + assertEquals("Moved camera position longitude should match", cameraPosition.target.getLongitude(), + moveTarget.getLongitude(), TestConstants.LAT_LNG_DELTA); + assertEquals("Moved zoom should match", cameraPosition.zoom, moveZoom, TestConstants.ZOOM_DELTA); + } + + @Test + public void testMoveToCameraPosition() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + final MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); + + final LatLng moveTarget = new LatLng(1.0000000001, 1.0000000003); + final float moveZoom = 15.5f; + final float moveTilt = 45.5f; + final float moveBearing = 12.5f; + + onView(withId(R.id.mapView)).perform( + new MoveCameraAction(mapboxMap, CameraUpdateFactory.newCameraPosition( + new CameraPosition.Builder() + .target(moveTarget) + .zoom(moveZoom) + .tilt(moveTilt) + .bearing(moveBearing) + .build())) + ); + + CameraPosition cameraPosition = mapboxMap.getCameraPosition(); + assertEquals("Moved camera position latitude should match", cameraPosition.target.getLatitude(), + moveTarget.getLatitude(), TestConstants.LAT_LNG_DELTA); + assertEquals("Moved camera position longitude should match", cameraPosition.target.getLongitude(), + moveTarget.getLongitude(), TestConstants.LAT_LNG_DELTA); + assertEquals("Moved zoom should match", cameraPosition.zoom, moveZoom, TestConstants.ZOOM_DELTA); + assertEquals("Moved zoom should match", cameraPosition.tilt, moveTilt, TestConstants.TILT_DELTA); + assertEquals("Moved bearing should match", cameraPosition.bearing, moveBearing, TestConstants.BEARING_DELTA); + } + + @Test + public void testMoveToBounds() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + final MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); + + final LatLng centerBounds = new LatLng(1, 1); + LatLng cornerOne = new LatLng(); + LatLng cornerTwo = new LatLng(2, 2); + + final LatLngBounds.Builder builder = new LatLngBounds.Builder(); + builder.include(cornerOne); + builder.include(cornerTwo); + + onView(withId(R.id.mapView)).perform(new MoveCameraAction(mapboxMap, + CameraUpdateFactory.newLatLngBounds(builder.build(), 0))); + + CameraPosition cameraPosition = mapboxMap.getCameraPosition(); + assertEquals("Moved camera position latitude should match center bounds", + cameraPosition.target.getLatitude(), + centerBounds.getLatitude(), + TestConstants.LAT_LNG_DELTA); + + assertEquals("Moved camera position longitude should match center bounds", + cameraPosition.target.getLongitude(), + centerBounds.getLongitude(), + TestConstants.LAT_LNG_DELTA); + } + + @Test + public void testMoveToMoveBy() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + final MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); + + final PointF centerPoint = mapboxMap.getProjection().toScreenLocation(mapboxMap.getCameraPosition().target); + final LatLng moveTarget = new LatLng(2, 2); + final PointF moveTargetPoint = mapboxMap.getProjection().toScreenLocation(moveTarget); + + onView(withId(R.id.mapView)).perform(new MoveCameraAction(mapboxMap, CameraUpdateFactory.scrollBy( + moveTargetPoint.x - centerPoint.x, moveTargetPoint.y - centerPoint.y))); + + CameraPosition cameraPosition = mapboxMap.getCameraPosition(); + assertEquals("Moved camera position latitude should match", cameraPosition.target.getLatitude(), + moveTarget.getLatitude(), TestConstants.LAT_LNG_DELTA_LARGE); + assertEquals("Moved camera position longitude should match", cameraPosition.target.getLongitude(), + moveTarget.getLongitude(), TestConstants.LAT_LNG_DELTA_LARGE); + } + + @Test + public void testMoveToZoomIn() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + final MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); + + /*TODO fix zoom #6474*/ + float zoom = 1.0f; + + onView(withId(R.id.mapView)).perform(new MoveCameraAction(mapboxMap, CameraUpdateFactory.zoomIn())); + CameraPosition cameraPosition = mapboxMap.getCameraPosition(); + assertEquals("Moved camera zoom should match moved camera zoom", cameraPosition.zoom, zoom + 1, + TestConstants.ZOOM_DELTA); + } + + @Test + public void testMoveToZoomOut() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + final MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); + + /*TODO fix zoom #6474*/ + float zoom = 10.0f; + onView(withId(R.id.mapView)).perform(new MoveCameraAction(mapboxMap, + CameraUpdateFactory.newLatLngZoom(new LatLng(), zoom))); + onView(withId(R.id.mapView)).perform(new MoveCameraAction(mapboxMap, CameraUpdateFactory.zoomOut())); + CameraPosition cameraPosition = mapboxMap.getCameraPosition(); + assertEquals("Moved camera zoom should match moved camera zoom", cameraPosition.zoom, zoom - 1, + TestConstants.ZOOM_DELTA); + } + + @Test + public void testMoveToZoomBy() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + final MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); + + /*TODO fix zoom #6474*/ + float zoom = 1.0f; + final float zoomBy = 2.45f; + + onView(withId(R.id.mapView)).perform(new MoveCameraAction(mapboxMap, CameraUpdateFactory.zoomBy(zoomBy))); + CameraPosition cameraPosition = mapboxMap.getCameraPosition(); + assertEquals("Moved camera zoom should match moved camera zoom", cameraPosition.zoom, zoom + zoomBy, + TestConstants.ZOOM_DELTA); + } + + @Test + public void testMoveToZoomTo() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + final MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); + + /*TODO fix zoom #6474*/ + final float zoomTo = 2.45f; + + onView(withId(R.id.mapView)).perform(new MoveCameraAction(mapboxMap, CameraUpdateFactory.zoomTo(zoomTo))); + CameraPosition cameraPosition = mapboxMap.getCameraPosition(); + assertEquals("Moved camera zoom should match moved camera zoom", cameraPosition.zoom, zoomTo, + TestConstants.ZOOM_DELTA); + } + + @After + public void unregisterIdlingResource() { + Espresso.unregisterIdlingResources(idlingResource); + } + + private class MoveCameraAction implements ViewAction { + + private MapboxMap mapboxMap; + private CameraUpdate cameraUpdate; + + MoveCameraAction(MapboxMap map, CameraUpdate update) { + mapboxMap = map; + cameraUpdate = update; } - @Test - public void testMoveToCameraPositionTarget() { - ViewUtils.checkViewIsDisplayed(R.id.mapView); - final MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); - - /*TODO remove zoom #6474*/ - float zoom = 1.0f; - LatLng moveTarget = new LatLng(1, 1); - - CameraPosition initialPosition = new CameraPosition.Builder().target(new LatLng()).zoom(zoom).bearing(0).tilt(0).build(); - CameraPosition cameraPosition = mapboxMap.getCameraPosition(); - assertEquals("Default camera position should match default", cameraPosition, initialPosition); - - onView(withId(R.id.mapView)).perform(new MoveCameraAction(mapboxMap, CameraUpdateFactory.newLatLng(moveTarget))); - cameraPosition = mapboxMap.getCameraPosition(); - assertEquals("Moved camera position latitude should match", cameraPosition.target.getLatitude(), moveTarget.getLatitude(), TestConstants.LAT_LNG_DELTA); - assertEquals("Moved camera position longitude should match", cameraPosition.target.getLongitude(), moveTarget.getLongitude(), TestConstants.LAT_LNG_DELTA); + @Override + public Matcher getConstraints() { + return isDisplayed(); } - @Test - public void testMoveToCameraPositionTargetZoom() { - ViewUtils.checkViewIsDisplayed(R.id.mapView); - final MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); - - final float moveZoom = 15.5f; - final LatLng moveTarget = new LatLng(1.0000000001, 1.0000000003); - - onView(withId(R.id.mapView)).perform(new MoveCameraAction(mapboxMap, CameraUpdateFactory.newLatLngZoom(moveTarget, moveZoom))); - CameraPosition cameraPosition = mapboxMap.getCameraPosition(); - assertEquals("Moved camera position latitude should match", cameraPosition.target.getLatitude(), moveTarget.getLatitude(), TestConstants.LAT_LNG_DELTA); - assertEquals("Moved camera position longitude should match", cameraPosition.target.getLongitude(), moveTarget.getLongitude(), TestConstants.LAT_LNG_DELTA); - assertEquals("Moved zoom should match", cameraPosition.zoom, moveZoom, TestConstants.ZOOM_DELTA); + @Override + public String getDescription() { + return getClass().getSimpleName(); } - @Test - public void testMoveToCameraPosition() { - ViewUtils.checkViewIsDisplayed(R.id.mapView); - final MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); - - final LatLng moveTarget = new LatLng(1.0000000001, 1.0000000003); - final float moveZoom = 15.5f; - final float moveTilt = 45.5f; - final float moveBearing = 12.5f; - - onView(withId(R.id.mapView)).perform( - new MoveCameraAction(mapboxMap, CameraUpdateFactory.newCameraPosition( - new CameraPosition.Builder() - .target(moveTarget) - .zoom(moveZoom) - .tilt(moveTilt) - .bearing(moveBearing) - .build())) - ); - - CameraPosition cameraPosition = mapboxMap.getCameraPosition(); - assertEquals("Moved camera position latitude should match", cameraPosition.target.getLatitude(), moveTarget.getLatitude(), TestConstants.LAT_LNG_DELTA); - assertEquals("Moved camera position longitude should match", cameraPosition.target.getLongitude(), moveTarget.getLongitude(), TestConstants.LAT_LNG_DELTA); - assertEquals("Moved zoom should match", cameraPosition.zoom, moveZoom, TestConstants.ZOOM_DELTA); - assertEquals("Moved zoom should match", cameraPosition.tilt, moveTilt, TestConstants.TILT_DELTA); - assertEquals("Moved bearing should match", cameraPosition.bearing, moveBearing, TestConstants.BEARING_DELTA); - } - - @Test - public void testMoveToBounds() { - ViewUtils.checkViewIsDisplayed(R.id.mapView); - final MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); - - final LatLng centerBounds = new LatLng(1, 1); - LatLng cornerOne = new LatLng(); - LatLng cornerTwo = new LatLng(2, 2); - - final LatLngBounds.Builder builder = new LatLngBounds.Builder(); - builder.include(cornerOne); - builder.include(cornerTwo); - - onView(withId(R.id.mapView)).perform(new MoveCameraAction(mapboxMap, CameraUpdateFactory.newLatLngBounds(builder.build(), 0))); - - CameraPosition cameraPosition = mapboxMap.getCameraPosition(); - assertEquals("Moved camera position latitude should match center bounds", - cameraPosition.target.getLatitude(), - centerBounds.getLatitude(), - TestConstants.LAT_LNG_DELTA); - - assertEquals("Moved camera position longitude should match center bounds", - cameraPosition.target.getLongitude(), - centerBounds.getLongitude(), - TestConstants.LAT_LNG_DELTA); - } - - @Test - public void testMoveToMoveBy() { - ViewUtils.checkViewIsDisplayed(R.id.mapView); - final MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); - - final PointF centerPoint = mapboxMap.getProjection().toScreenLocation(mapboxMap.getCameraPosition().target); - final LatLng moveTarget = new LatLng(2, 2); - final PointF moveTargetPoint = mapboxMap.getProjection().toScreenLocation(moveTarget); - - onView(withId(R.id.mapView)).perform(new MoveCameraAction(mapboxMap, CameraUpdateFactory.scrollBy( - moveTargetPoint.x - centerPoint.x, moveTargetPoint.y - centerPoint.y))); - - CameraPosition cameraPosition = mapboxMap.getCameraPosition(); - assertEquals("Moved camera position latitude should match", cameraPosition.target.getLatitude(), moveTarget.getLatitude(), TestConstants.LAT_LNG_DELTA_LARGE); - assertEquals("Moved camera position longitude should match", cameraPosition.target.getLongitude(), moveTarget.getLongitude(), TestConstants.LAT_LNG_DELTA_LARGE); - } - - @Test - public void testMoveToZoomIn() { - ViewUtils.checkViewIsDisplayed(R.id.mapView); - final MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); - - /*TODO fix zoom #6474*/ - float zoom = 1.0f; - - onView(withId(R.id.mapView)).perform(new MoveCameraAction(mapboxMap, CameraUpdateFactory.zoomIn())); - CameraPosition cameraPosition = mapboxMap.getCameraPosition(); - assertEquals("Moved camera zoom should match moved camera zoom", cameraPosition.zoom, zoom + 1, TestConstants.ZOOM_DELTA); - } - - @Test - public void testMoveToZoomOut() { - ViewUtils.checkViewIsDisplayed(R.id.mapView); - final MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); - - /*TODO fix zoom #6474*/ - float zoom = 10.0f; - onView(withId(R.id.mapView)).perform(new MoveCameraAction(mapboxMap, CameraUpdateFactory.newLatLngZoom(new LatLng(), zoom))); - onView(withId(R.id.mapView)).perform(new MoveCameraAction(mapboxMap, CameraUpdateFactory.zoomOut())); - CameraPosition cameraPosition = mapboxMap.getCameraPosition(); - assertEquals("Moved camera zoom should match moved camera zoom", cameraPosition.zoom, zoom - 1, TestConstants.ZOOM_DELTA); - } - - @Test - public void testMoveToZoomBy() { - ViewUtils.checkViewIsDisplayed(R.id.mapView); - final MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); - - /*TODO fix zoom #6474*/ - float zoom = 1.0f; - final float zoomBy = 2.45f; - - onView(withId(R.id.mapView)).perform(new MoveCameraAction(mapboxMap, CameraUpdateFactory.zoomBy(zoomBy))); - CameraPosition cameraPosition = mapboxMap.getCameraPosition(); - assertEquals("Moved camera zoom should match moved camera zoom", cameraPosition.zoom, zoom + zoomBy, TestConstants.ZOOM_DELTA); - } - - @Test - public void testMoveToZoomTo() { - ViewUtils.checkViewIsDisplayed(R.id.mapView); - final MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); - - /*TODO fix zoom #6474*/ - final float zoomTo = 2.45f; - - onView(withId(R.id.mapView)).perform(new MoveCameraAction(mapboxMap, CameraUpdateFactory.zoomTo(zoomTo))); - CameraPosition cameraPosition = mapboxMap.getCameraPosition(); - assertEquals("Moved camera zoom should match moved camera zoom", cameraPosition.zoom, zoomTo, TestConstants.ZOOM_DELTA); - } - - @After - public void unregisterIdlingResource() { - Espresso.unregisterIdlingResources(idlingResource); - } - - private class MoveCameraAction implements ViewAction { - - private MapboxMap mapboxMap; - private CameraUpdate cameraUpdate; - - MoveCameraAction(MapboxMap map, CameraUpdate update) { - mapboxMap = map; - cameraUpdate = update; - } - - @Override - public Matcher getConstraints() { - return isDisplayed(); - } - - @Override - public String getDescription() { - return getClass().getSimpleName(); - } - - @Override - public void perform(UiController uiController, View view) { - mapboxMap.moveCamera(cameraUpdate); - uiController.loopMainThreadForAtLeast(100); - } + @Override + public void perform(UiController uiController, View view) { + mapboxMap.moveCamera(cameraUpdate); + uiController.loopMainThreadForAtLeast(100); } + } } diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/feature/QueryRenderedFeaturesBoxCountTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/feature/QueryRenderedFeaturesBoxCountTest.java index 7ee5c04e4a..b4be73be7a 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/feature/QueryRenderedFeaturesBoxCountTest.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/feature/QueryRenderedFeaturesBoxCountTest.java @@ -29,32 +29,33 @@ import static org.hamcrest.Matchers.not; */ public class QueryRenderedFeaturesBoxCountTest { - @Rule - public final ActivityTestRule rule = new ActivityTestRule<>(QueryRenderedFeaturesBoxCountActivity.class); - - private OnMapReadyIdlingResource idlingResource; - - @Before - public void registerIdlingResource() { - idlingResource = new OnMapReadyIdlingResource(rule.getActivity()); - Espresso.registerIdlingResources(idlingResource); - } - - @Test - @Ignore - public void testCountFeatures() { - // click on box to query map - onView(withId(R.id.selection_box)).perform(click()); - - // validate if toast is shown - onView(withText("149 features in box")) - .inRoot(withDecorView(not(is(rule.getActivity().getWindow().getDecorView())))) - .check(matches(isDisplayed())); - } - - @After - public void unregisterIdlingResource() { - Espresso.unregisterIdlingResources(idlingResource); - } + @Rule + public final ActivityTestRule rule = + new ActivityTestRule<>(QueryRenderedFeaturesBoxCountActivity.class); + + private OnMapReadyIdlingResource idlingResource; + + @Before + public void registerIdlingResource() { + idlingResource = new OnMapReadyIdlingResource(rule.getActivity()); + Espresso.registerIdlingResources(idlingResource); + } + + @Test + @Ignore + public void testCountFeatures() { + // click on box to query map + onView(withId(R.id.selection_box)).perform(click()); + + // validate if toast is shown + onView(withText("149 features in box")) + .inRoot(withDecorView(not(is(rule.getActivity().getWindow().getDecorView())))) + .check(matches(isDisplayed())); + } + + @After + public void unregisterIdlingResource() { + Espresso.unregisterIdlingResources(idlingResource); + } } \ No newline at end of file diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/feature/QueryRenderedFeaturesHighlightTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/feature/QueryRenderedFeaturesHighlightTest.java index 30cabd9753..b8cd46e612 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/feature/QueryRenderedFeaturesHighlightTest.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/feature/QueryRenderedFeaturesHighlightTest.java @@ -34,47 +34,48 @@ import static org.hamcrest.Matchers.not; */ public class QueryRenderedFeaturesHighlightTest { - @Rule - public final ActivityTestRule rule = new ActivityTestRule<>(QueryRenderedFeaturesBoxHighlightActivity.class); + @Rule + public final ActivityTestRule rule = + new ActivityTestRule<>(QueryRenderedFeaturesBoxHighlightActivity.class); - private OnMapReadyIdlingResource idlingResource; + private OnMapReadyIdlingResource idlingResource; - @Before - public void registerIdlingResource() { - idlingResource = new OnMapReadyIdlingResource(rule.getActivity()); - Espresso.registerIdlingResources(idlingResource); - } + @Before + public void registerIdlingResource() { + idlingResource = new OnMapReadyIdlingResource(rule.getActivity()); + Espresso.registerIdlingResources(idlingResource); + } - @Test - @Ignore - public void testCountFeatures() { - // click on box to query map - onView(withId(R.id.selection_box)).perform(click()); + @Test + @Ignore + public void testCountFeatures() { + // click on box to query map + onView(withId(R.id.selection_box)).perform(click()); - // validate if toast is shown - onView(withText("50 features in box")) - .inRoot(withDecorView(not(is(rule.getActivity().getWindow().getDecorView())))) - .check(matches(isDisplayed())); - } + // validate if toast is shown + onView(withText("50 features in box")) + .inRoot(withDecorView(not(is(rule.getActivity().getWindow().getDecorView())))) + .check(matches(isDisplayed())); + } - @After - public void unregisterIdlingResource() { - Espresso.unregisterIdlingResources(idlingResource); - } + @After + public void unregisterIdlingResource() { + Espresso.unregisterIdlingResources(idlingResource); + } - private static ViewAction clickXY(final float x, final float y) { - return new GeneralClickAction( - Tap.SINGLE, - new CoordinatesProvider() { - @Override - public float[] calculateCoordinates(View view) { - final int[] screenPos = new int[2]; - view.getLocationOnScreen(screenPos); - final float screenX = screenPos[0] + x; - final float screenY = screenPos[1] + y; - return new float[]{screenX, screenY}; - } - }, - Press.FINGER); - } + private static ViewAction clickXY(final float x, final float y) { + return new GeneralClickAction( + Tap.SINGLE, + new CoordinatesProvider() { + @Override + public float[] calculateCoordinates(View view) { + final int[] screenPos = new int[2]; + view.getLocationOnScreen(screenPos); + final float screenX = screenPos[0] + x; + final float screenY = screenPos[1] + y; + return new float[] {screenX, screenY}; + } + }, + Press.FINGER); + } } \ No newline at end of file diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/feature/QueryRenderedFeaturesPropertiesTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/feature/QueryRenderedFeaturesPropertiesTest.java index 800ad05891..3b86397603 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/feature/QueryRenderedFeaturesPropertiesTest.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/feature/QueryRenderedFeaturesPropertiesTest.java @@ -33,45 +33,46 @@ import static android.support.test.espresso.matcher.ViewMatchers.withText; */ public class QueryRenderedFeaturesPropertiesTest { - @Rule - public final ActivityTestRule rule = new ActivityTestRule<>(QueryRenderedFeaturesPropertiesActivity.class); + @Rule + public final ActivityTestRule rule = + new ActivityTestRule<>(QueryRenderedFeaturesPropertiesActivity.class); - private OnMapReadyIdlingResource idlingResource; + private OnMapReadyIdlingResource idlingResource; - @Before - public void registerIdlingResource() { - idlingResource = new OnMapReadyIdlingResource(rule.getActivity()); - Espresso.registerIdlingResources(idlingResource); - } + @Before + public void registerIdlingResource() { + idlingResource = new OnMapReadyIdlingResource(rule.getActivity()); + Espresso.registerIdlingResources(idlingResource); + } - @Test - @Ignore - public void testCountFeatures() { - MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); - LatLng centerScreen = mapboxMap.getCameraPosition().target; - PointF centerPixel = mapboxMap.getProjection().toScreenLocation(centerScreen); - onView(withId(R.id.mapView)).perform(clickXY(centerPixel.x, centerPixel.y)); - onView(withText("Found 4 features")).check(matches(isDisplayed())); - } + @Test + @Ignore + public void testCountFeatures() { + MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); + LatLng centerScreen = mapboxMap.getCameraPosition().target; + PointF centerPixel = mapboxMap.getProjection().toScreenLocation(centerScreen); + onView(withId(R.id.mapView)).perform(clickXY(centerPixel.x, centerPixel.y)); + onView(withText("Found 4 features")).check(matches(isDisplayed())); + } - @After - public void unregisterIdlingResource() { - Espresso.unregisterIdlingResources(idlingResource); - } + @After + public void unregisterIdlingResource() { + Espresso.unregisterIdlingResources(idlingResource); + } - private static ViewAction clickXY(final float x, final float y) { - return new GeneralClickAction( - Tap.SINGLE, - new CoordinatesProvider() { - @Override - public float[] calculateCoordinates(View view) { - final int[] screenPos = new int[2]; - view.getLocationOnScreen(screenPos); - final float screenX = screenPos[0] + x; - final float screenY = screenPos[1] + y; - return new float[]{screenX, screenY}; - } - }, - Press.FINGER); - } + private static ViewAction clickXY(final float x, final float y) { + return new GeneralClickAction( + Tap.SINGLE, + new CoordinatesProvider() { + @Override + public float[] calculateCoordinates(View view) { + final int[] screenPos = new int[2]; + view.getLocationOnScreen(screenPos); + final float screenX = screenPos[0] + x; + final float screenY = screenPos[1] + y; + return new float[] {screenX, screenY}; + } + }, + Press.FINGER); + } } \ No newline at end of file diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/feature/QueryRenderedSymbolBoxCountTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/feature/QueryRenderedSymbolBoxCountTest.java index afb0c607ad..ea80e8689a 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/feature/QueryRenderedSymbolBoxCountTest.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/feature/QueryRenderedSymbolBoxCountTest.java @@ -29,33 +29,34 @@ import static org.hamcrest.Matchers.not; */ public class QueryRenderedSymbolBoxCountTest { - @Rule - public final ActivityTestRule rule = new ActivityTestRule<>(QueryRenderedFeaturesBoxSymbolCountActivity.class); - - private OnMapReadyIdlingResource idlingResource; - - @Before - public void registerIdlingResource() { - idlingResource = new OnMapReadyIdlingResource(rule.getActivity()); - Espresso.registerIdlingResources(idlingResource); - } - - @Test - @Ignore - public void testCountSymbols() { - // click on box to query map - onView(withId(R.id.selection_box)).perform(click()); - - // validate if toast is shown - onView(withText("2 features in box")) - .inRoot(withDecorView(not(is(rule.getActivity().getWindow().getDecorView())))) - .check(matches(isDisplayed())); - } - - @After - public void unregisterIdlingResource() { - Espresso.unregisterIdlingResources(idlingResource); - } + @Rule + public final ActivityTestRule rule = + new ActivityTestRule<>(QueryRenderedFeaturesBoxSymbolCountActivity.class); + + private OnMapReadyIdlingResource idlingResource; + + @Before + public void registerIdlingResource() { + idlingResource = new OnMapReadyIdlingResource(rule.getActivity()); + Espresso.registerIdlingResources(idlingResource); + } + + @Test + @Ignore + public void testCountSymbols() { + // click on box to query map + onView(withId(R.id.selection_box)).perform(click()); + + // validate if toast is shown + onView(withText("2 features in box")) + .inRoot(withDecorView(not(is(rule.getActivity().getWindow().getDecorView())))) + .check(matches(isDisplayed())); + } + + @After + public void unregisterIdlingResource() { + Espresso.unregisterIdlingResources(idlingResource); + } } diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/widgets/AttributionTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/widgets/AttributionTest.java index 1af957dac6..fa1451092a 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/widgets/AttributionTest.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/widgets/AttributionTest.java @@ -37,120 +37,120 @@ import static org.hamcrest.core.IsNot.not; public class AttributionTest { - @Rule - public final ActivityTestRule rule = new ActivityTestRule<>(EspressoTestActivity.class); - - private OnMapReadyIdlingResource idlingResource; - - private String[] dialogTexts; - private String[] dialogLinks; - - @Before - public void beforeTest() { - idlingResource = new OnMapReadyIdlingResource(rule.getActivity()); - Espresso.registerIdlingResources(idlingResource); - Intents.init(); - dialogTexts = rule.getActivity().getResources().getStringArray(R.array.mapbox_attribution_names); - dialogLinks = rule.getActivity().getResources().getStringArray(R.array.mapbox_attribution_links); - } - - @Test - public void testDisabled() { - ViewUtils.checkViewIsDisplayed(R.id.mapView); - MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); - - // Default - onView(withId(R.id.attributionView)).check(matches(isDisplayed())); - - // Disabled - onView(withId(R.id.attributionView)) - .perform(new DisableAction(mapboxMap)) - .check(matches(not(isDisplayed()))); - } - - @Test - public void testMapboxLink() { - ViewUtils.checkViewIsDisplayed(R.id.mapView); - - // click on View to open dialog - onView(withId(R.id.attributionView)).perform(click()); - onView(withText(R.string.mapbox_attributionsDialogTitle)).check(matches(isDisplayed())); - - // click on link and validate browser opening - Matcher expectedIntent = allOf(hasAction(Intent.ACTION_VIEW), hasData(Uri.parse(dialogLinks[0]))); - intending(expectedIntent).respondWith(new Instrumentation.ActivityResult(0, null)); - onView(withText(dialogTexts[0])).perform(click()); - intended(expectedIntent); - } - - @Test - public void testOpenStreetMapLink() { - ViewUtils.checkViewIsDisplayed(R.id.mapView); - - // click on View to open dialog - onView(withId(R.id.attributionView)).perform(click()); - onView(withText(R.string.mapbox_attributionsDialogTitle)).check(matches(isDisplayed())); - - // click on link and validate browser opening - Matcher expectedIntent = allOf(hasAction(Intent.ACTION_VIEW), hasData(Uri.parse(dialogLinks[1]))); - intending(expectedIntent).respondWith(new Instrumentation.ActivityResult(0, null)); - onView(withText(dialogTexts[1])).perform(click()); + @Rule + public final ActivityTestRule rule = new ActivityTestRule<>(EspressoTestActivity.class); + + private OnMapReadyIdlingResource idlingResource; + + private String[] dialogTexts; + private String[] dialogLinks; + + @Before + public void beforeTest() { + idlingResource = new OnMapReadyIdlingResource(rule.getActivity()); + Espresso.registerIdlingResources(idlingResource); + Intents.init(); + dialogTexts = rule.getActivity().getResources().getStringArray(R.array.mapbox_attribution_names); + dialogLinks = rule.getActivity().getResources().getStringArray(R.array.mapbox_attribution_links); + } + + @Test + public void testDisabled() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); + + // Default + onView(withId(R.id.attributionView)).check(matches(isDisplayed())); + + // Disabled + onView(withId(R.id.attributionView)) + .perform(new DisableAction(mapboxMap)) + .check(matches(not(isDisplayed()))); + } + + @Test + public void testMapboxLink() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + + // click on View to open dialog + onView(withId(R.id.attributionView)).perform(click()); + onView(withText(R.string.mapbox_attributionsDialogTitle)).check(matches(isDisplayed())); + + // click on link and validate browser opening + Matcher expectedIntent = allOf(hasAction(Intent.ACTION_VIEW), hasData(Uri.parse(dialogLinks[0]))); + intending(expectedIntent).respondWith(new Instrumentation.ActivityResult(0, null)); + onView(withText(dialogTexts[0])).perform(click()); + intended(expectedIntent); + } + + @Test + public void testOpenStreetMapLink() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + + // click on View to open dialog + onView(withId(R.id.attributionView)).perform(click()); + onView(withText(R.string.mapbox_attributionsDialogTitle)).check(matches(isDisplayed())); + + // click on link and validate browser opening + Matcher expectedIntent = allOf(hasAction(Intent.ACTION_VIEW), hasData(Uri.parse(dialogLinks[1]))); + intending(expectedIntent).respondWith(new Instrumentation.ActivityResult(0, null)); + onView(withText(dialogTexts[1])).perform(click()); + } + + @Test + public void testImproveMapLink() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + + // click on View to open dialog + onView(withId(R.id.attributionView)).perform(click()); + onView(withText(R.string.mapbox_attributionsDialogTitle)).check(matches(isDisplayed())); + + // click on Mapbox link and validate browser opening + Matcher expectedIntent = allOf(hasAction(Intent.ACTION_VIEW), hasData(Uri.parse(dialogLinks[3]))); + intending(expectedIntent).respondWith(new Instrumentation.ActivityResult(0, null)); + onView(withText(dialogTexts[3])).perform(click()); + } + + @Test + public void testTelemetryDialog() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + + // click on View to open dialog + onView(withId(R.id.attributionView)).perform(click()); + onView(withText(R.string.mapbox_attributionsDialogTitle)).check(matches(isDisplayed())); + + // click on item to open second dialog + onView(withText(dialogTexts[3])).perform(click()); + onView(withText(R.string.mapbox_attributionTelemetryTitle)).check(matches(isDisplayed())); + } + + @After + public void afterTest() { + Intents.release(); + Espresso.unregisterIdlingResources(idlingResource); + } + + private class DisableAction implements ViewAction { + + private MapboxMap mapboxMap; + + DisableAction(MapboxMap map) { + mapboxMap = map; } - @Test - public void testImproveMapLink() { - ViewUtils.checkViewIsDisplayed(R.id.mapView); - - // click on View to open dialog - onView(withId(R.id.attributionView)).perform(click()); - onView(withText(R.string.mapbox_attributionsDialogTitle)).check(matches(isDisplayed())); - - // click on Mapbox link and validate browser opening - Matcher expectedIntent = allOf(hasAction(Intent.ACTION_VIEW), hasData(Uri.parse(dialogLinks[3]))); - intending(expectedIntent).respondWith(new Instrumentation.ActivityResult(0, null)); - onView(withText(dialogTexts[3])).perform(click()); + @Override + public Matcher getConstraints() { + return isDisplayed(); } - @Test - public void testTelemetryDialog() { - ViewUtils.checkViewIsDisplayed(R.id.mapView); - - // click on View to open dialog - onView(withId(R.id.attributionView)).perform(click()); - onView(withText(R.string.mapbox_attributionsDialogTitle)).check(matches(isDisplayed())); - - // click on item to open second dialog - onView(withText(dialogTexts[3])).perform(click()); - onView(withText(R.string.mapbox_attributionTelemetryTitle)).check(matches(isDisplayed())); + @Override + public String getDescription() { + return getClass().getSimpleName(); } - @After - public void afterTest() { - Intents.release(); - Espresso.unregisterIdlingResources(idlingResource); - } - - private class DisableAction implements ViewAction { - - private MapboxMap mapboxMap; - - DisableAction(MapboxMap map) { - mapboxMap = map; - } - - @Override - public Matcher getConstraints() { - return isDisplayed(); - } - - @Override - public String getDescription() { - return getClass().getSimpleName(); - } - - @Override - public void perform(UiController uiController, View view) { - mapboxMap.getUiSettings().setAttributionEnabled(false); - } + @Override + public void perform(UiController uiController, View view) { + mapboxMap.getUiSettings().setAttributionEnabled(false); } + } } diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/widgets/CompassViewTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/widgets/CompassViewTest.java index 0dfe07bfa2..02fec41f65 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/widgets/CompassViewTest.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/widgets/CompassViewTest.java @@ -34,120 +34,120 @@ import static org.junit.Assert.assertEquals; public class CompassViewTest { - @Rule - public final ActivityTestRule rule = new ActivityTestRule<>(EspressoTestActivity.class); - - private OnMapReadyIdlingResource idlingResource; - - @Before - public void registerIdlingResource() { - idlingResource = new OnMapReadyIdlingResource(rule.getActivity()); - Espresso.registerIdlingResources(idlingResource); - } - - @Test - public void testDefault() { - ViewUtils.checkViewIsDisplayed(R.id.mapView); - onView(withId(R.id.compassView)).check(matches(not(isDisplayed()))); + @Rule + public final ActivityTestRule rule = new ActivityTestRule<>(EspressoTestActivity.class); + + private OnMapReadyIdlingResource idlingResource; + + @Before + public void registerIdlingResource() { + idlingResource = new OnMapReadyIdlingResource(rule.getActivity()); + Espresso.registerIdlingResources(idlingResource); + } + + @Test + public void testDefault() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + onView(withId(R.id.compassView)).check(matches(not(isDisplayed()))); + } + + @Test + public void testVisible() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); + + onView(withId(R.id.mapView)).perform(new MoveCameraAction(mapboxMap, + CameraUpdateFactory.newCameraPosition( + new CameraPosition.Builder() + .bearing(45) + .zoom(1) + .target(new LatLng()) + .build() + ) + ) + ); + + onView(withId(R.id.compassView)).check(matches(isDisplayed())); + } + + @Test + @Ignore // 10-31-2016 click action is not working + public void testClick() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); + + onView(withId(R.id.mapView)).perform(new MoveCameraAction(mapboxMap, + CameraUpdateFactory.newCameraPosition( + new CameraPosition.Builder() + .bearing(45) + .zoom(1) + .target(new LatLng()) + .build() + ) + ) + ); + + onView(withId(R.id.compassView)).perform(click()); + onView(withId(R.id.mapView)).perform(new WaitAction(3000)); + onView(withId(R.id.compassView)).check(matches(not(isDisplayed()))); + + CameraPosition cameraPosition = mapboxMap.getCameraPosition(); + assertEquals("Camera bearing should face north, ", 0, cameraPosition.bearing, TestConstants.BEARING_DELTA); + } + + @After + public void unregisterIdlingResource() { + Espresso.unregisterIdlingResources(idlingResource); + } + + private class WaitAction implements ViewAction { + + private long waitTime; + + WaitAction(long waitTime) { + this.waitTime = waitTime; } - @Test - public void testVisible(){ - ViewUtils.checkViewIsDisplayed(R.id.mapView); - MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); - - onView(withId(R.id.mapView)).perform(new MoveCameraAction(mapboxMap, - CameraUpdateFactory.newCameraPosition( - new CameraPosition.Builder() - .bearing(45) - .zoom(1) - .target(new LatLng()) - .build() - ) - ) - ); - - onView(withId(R.id.compassView)).check(matches(isDisplayed())); + @Override + public Matcher getConstraints() { + return isDisplayed(); } - @Test - @Ignore // 10-31-2016 click action is not working - public void testClick() { - ViewUtils.checkViewIsDisplayed(R.id.mapView); - MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); - - onView(withId(R.id.mapView)).perform(new MoveCameraAction(mapboxMap, - CameraUpdateFactory.newCameraPosition( - new CameraPosition.Builder() - .bearing(45) - .zoom(1) - .target(new LatLng()) - .build() - ) - ) - ); - - onView(withId(R.id.compassView)).perform(click()); - onView(withId(R.id.mapView)).perform(new WaitAction(3000)); - onView(withId(R.id.compassView)).check(matches(not(isDisplayed()))); - - CameraPosition cameraPosition = mapboxMap.getCameraPosition(); - assertEquals("Camera bearing should face north, ", 0, cameraPosition.bearing, TestConstants.BEARING_DELTA); + @Override + public String getDescription() { + return getClass().getSimpleName(); } - @After - public void unregisterIdlingResource() { - Espresso.unregisterIdlingResources(idlingResource); + @Override + public void perform(UiController uiController, View view) { + uiController.loopMainThreadForAtLeast(waitTime); } + } - private class WaitAction implements ViewAction { - - private long waitTime; - - WaitAction(long waitTime) { - this.waitTime = waitTime; - } + private class MoveCameraAction implements ViewAction { - @Override - public Matcher getConstraints() { - return isDisplayed(); - } + private MapboxMap mapboxMap; + private CameraUpdate cameraUpdate; - @Override - public String getDescription() { - return getClass().getSimpleName(); - } - - @Override - public void perform(UiController uiController, View view) { - uiController.loopMainThreadForAtLeast(waitTime); - } + MoveCameraAction(MapboxMap map, CameraUpdate update) { + mapboxMap = map; + cameraUpdate = update; } - private class MoveCameraAction implements ViewAction { - - private MapboxMap mapboxMap; - private CameraUpdate cameraUpdate; - - MoveCameraAction(MapboxMap map, CameraUpdate update) { - mapboxMap = map; - cameraUpdate = update; - } - - @Override - public Matcher getConstraints() { - return isDisplayed(); - } + @Override + public Matcher getConstraints() { + return isDisplayed(); + } - @Override - public String getDescription() { - return getClass().getSimpleName(); - } + @Override + public String getDescription() { + return getClass().getSimpleName(); + } - @Override - public void perform(UiController uiController, View view) { - mapboxMap.moveCamera(cameraUpdate); - } + @Override + public void perform(UiController uiController, View view) { + mapboxMap.moveCamera(cameraUpdate); } + } } diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/widgets/LogoTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/widgets/LogoTest.java index 8be5e6b694..f12b2bf160 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/widgets/LogoTest.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/widgets/LogoTest.java @@ -26,59 +26,59 @@ import static org.hamcrest.Matchers.not; public class LogoTest { - @Rule - public final ActivityTestRule rule = new ActivityTestRule<>(EspressoTestActivity.class); + @Rule + public final ActivityTestRule rule = new ActivityTestRule<>(EspressoTestActivity.class); - private OnMapReadyIdlingResource idlingResource; + private OnMapReadyIdlingResource idlingResource; - @Before - public void registerIdlingResource() { - idlingResource = new OnMapReadyIdlingResource(rule.getActivity()); - Espresso.registerIdlingResources(idlingResource); - } + @Before + public void registerIdlingResource() { + idlingResource = new OnMapReadyIdlingResource(rule.getActivity()); + Espresso.registerIdlingResources(idlingResource); + } - @Test - public void testDefault() { - ViewUtils.checkViewIsDisplayed(R.id.mapView); - onView(withId(R.id.logoView)).check(matches(isDisplayed())); - } + @Test + public void testDefault() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + onView(withId(R.id.logoView)).check(matches(isDisplayed())); + } - @Test - public void testDisabled() { - ViewUtils.checkViewIsDisplayed(R.id.mapView); - MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); + @Test + public void testDisabled() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); - onView(withId(R.id.logoView)) - .perform(new DisableAction(mapboxMap)) - .check(matches(not(isDisplayed()))); - } + onView(withId(R.id.logoView)) + .perform(new DisableAction(mapboxMap)) + .check(matches(not(isDisplayed()))); + } - @After - public void unregisterIdlingResource() { - Espresso.unregisterIdlingResources(idlingResource); - } + @After + public void unregisterIdlingResource() { + Espresso.unregisterIdlingResources(idlingResource); + } - private class DisableAction implements ViewAction { + private class DisableAction implements ViewAction { - private MapboxMap mapboxMap; + private MapboxMap mapboxMap; - DisableAction(MapboxMap map) { - mapboxMap = map; - } + DisableAction(MapboxMap map) { + mapboxMap = map; + } - @Override - public Matcher getConstraints() { - return isDisplayed(); - } + @Override + public Matcher getConstraints() { + return isDisplayed(); + } - @Override - public String getDescription() { - return getClass().getSimpleName(); - } + @Override + public String getDescription() { + return getClass().getSimpleName(); + } - @Override - public void perform(UiController uiController, View view) { - mapboxMap.getUiSettings().setLogoEnabled(false); - } + @Override + public void perform(UiController uiController, View view) { + mapboxMap.getUiSettings().setLogoEnabled(false); } + } } diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/widgets/MyLocationViewTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/widgets/MyLocationViewTest.java index 05892dfc41..ac10d11922 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/widgets/MyLocationViewTest.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/widgets/MyLocationViewTest.java @@ -51,192 +51,196 @@ import static org.hamcrest.Matchers.not; */ public class MyLocationViewTest { - @Rule - public final ActivityTestRule rule = new ActivityTestRule<>(EspressoTestActivity.class); - - private OnMapReadyIdlingResource idlingResource; - - @Before - public void beforeTest() { - idlingResource = new OnMapReadyIdlingResource(rule.getActivity()); - Espresso.registerIdlingResources(idlingResource); + @Rule + public final ActivityTestRule rule = new ActivityTestRule<>(EspressoTestActivity.class); + + private OnMapReadyIdlingResource idlingResource; + + @Before + public void beforeTest() { + idlingResource = new OnMapReadyIdlingResource(rule.getActivity()); + Espresso.registerIdlingResources(idlingResource); + } + + @Test + @Ignore // requires runtime permissions, disabled for CI + public void testEnabled() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); + onView(withId(R.id.userLocationView)).check(matches(not(isDisplayed()))); + onView(withId(R.id.mapView)).perform(new ToggleLocationAction(mapboxMap, true)); + onView(withId(R.id.userLocationView)).check(matches(isDisplayed())); + onView(withId(R.id.mapView)).perform(new ToggleLocationAction(mapboxMap, false)); + onView(withId(R.id.userLocationView)).check(matches(not(isDisplayed()))); + } + + @Test + @Ignore + // requires runtime permissions, disabled for CI + issue with android.support.test.espresso.AppNotIdleException: + // Looped for 5049 iterations over 60 SECONDS. + public void testTracking() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); + onView(withId(R.id.userLocationView)).check(matches(not(isDisplayed()))); + onView(withId(R.id.mapView)).perform(new EnableLocationTrackingAction(mapboxMap)); + onView(withId(R.id.userLocationView)).check(matches(isDisplayed())); + onView(withId(R.id.userLocationView)).check(matches(new DrawableMatcher(mapboxMap, + R.drawable.mapbox_mylocation_icon_default, false))); + onView(withId(R.id.mapView)).perform(new EnableCompassBearingTrackingAction(mapboxMap)); + onView(withId(R.id.userLocationView)).check(matches(new DrawableMatcher(mapboxMap, + R.drawable.mapbox_mylocation_icon_bearing, true))); + } + + @After + public void afterTest() { + Espresso.unregisterIdlingResources(idlingResource); + } + + private class ToggleLocationAction implements ViewAction { + + private MapboxMap mapboxMap; + private boolean isEnabled; + + ToggleLocationAction(MapboxMap map, boolean enable) { + mapboxMap = map; + isEnabled = enable; } - @Test - @Ignore // requires runtime permissions, disabled for CI - public void testEnabled() { - ViewUtils.checkViewIsDisplayed(R.id.mapView); - MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); - onView(withId(R.id.userLocationView)).check(matches(not(isDisplayed()))); - onView(withId(R.id.mapView)).perform(new ToggleLocationAction(mapboxMap, true)); - onView(withId(R.id.userLocationView)).check(matches(isDisplayed())); - onView(withId(R.id.mapView)).perform(new ToggleLocationAction(mapboxMap, false)); - onView(withId(R.id.userLocationView)).check(matches(not(isDisplayed()))); + @Override + public Matcher getConstraints() { + return isDisplayed(); } - @Test - @Ignore // requires runtime permissions, disabled for CI + issue with android.support.test.espresso.AppNotIdleException: Looped for 5049 iterations over 60 SECONDS. - public void testTracking() { - ViewUtils.checkViewIsDisplayed(R.id.mapView); - MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); - onView(withId(R.id.userLocationView)).check(matches(not(isDisplayed()))); - onView(withId(R.id.mapView)).perform(new EnableLocationTrackingAction(mapboxMap)); - onView(withId(R.id.userLocationView)).check(matches(isDisplayed())); - onView(withId(R.id.userLocationView)).check(matches(new DrawableMatcher(mapboxMap, R.drawable.mapbox_mylocation_icon_default, false))); - onView(withId(R.id.mapView)).perform(new EnableCompassBearingTrackingAction(mapboxMap)); - onView(withId(R.id.userLocationView)).check(matches(new DrawableMatcher(mapboxMap, R.drawable.mapbox_mylocation_icon_bearing, true))); + @Override + public String getDescription() { + return getClass().getSimpleName(); } - @After - public void afterTest() { - Espresso.unregisterIdlingResources(idlingResource); + @Override + public void perform(UiController uiController, View view) { + if (isEnabled) { + // move camera above user location + mapboxMap.moveCamera( + CameraUpdateFactory.newCameraPosition( + new CameraPosition.Builder() + .target(new LatLng(LocationServices.getLocationServices(view.getContext()).getLastLocation())) + .build() + ) + ); + } + + // show loction on screen + mapboxMap.setMyLocationEnabled(isEnabled); } + } - private class ToggleLocationAction implements ViewAction { + private class EnableLocationTrackingAction implements ViewAction { - private MapboxMap mapboxMap; - private boolean isEnabled; + private MapboxMap mapboxMap; - ToggleLocationAction(MapboxMap map, boolean enable) { - mapboxMap = map; - isEnabled = enable; - } - - @Override - public Matcher getConstraints() { - return isDisplayed(); - } - - @Override - public String getDescription() { - return getClass().getSimpleName(); - } - - @Override - public void perform(UiController uiController, View view) { - if (isEnabled) { - // move camera above user location - mapboxMap.moveCamera( - CameraUpdateFactory.newCameraPosition( - new CameraPosition.Builder() - .target(new LatLng(LocationServices.getLocationServices(view.getContext()).getLastLocation())) - .build() - ) - ); - } - - // show loction on screen - mapboxMap.setMyLocationEnabled(isEnabled); - } + EnableLocationTrackingAction(MapboxMap map) { + mapboxMap = map; } - private class EnableLocationTrackingAction implements ViewAction { - - private MapboxMap mapboxMap; - - EnableLocationTrackingAction(MapboxMap map) { - mapboxMap = map; - } - - @Override - public Matcher getConstraints() { - return isDisplayed(); - } + @Override + public Matcher getConstraints() { + return isDisplayed(); + } - @Override - public String getDescription() { - return getClass().getSimpleName(); - } + @Override + public String getDescription() { + return getClass().getSimpleName(); + } - @Override - public void perform(UiController uiController, View view) { - mapboxMap.getTrackingSettings().setMyLocationTrackingMode(MyLocationTracking.TRACKING_FOLLOW); - } + @Override + public void perform(UiController uiController, View view) { + mapboxMap.getTrackingSettings().setMyLocationTrackingMode(MyLocationTracking.TRACKING_FOLLOW); } + } - private class EnableCompassBearingTrackingAction implements ViewAction { + private class EnableCompassBearingTrackingAction implements ViewAction { - private MapboxMap mapboxMap; + private MapboxMap mapboxMap; - EnableCompassBearingTrackingAction(MapboxMap map) { - mapboxMap = map; - } + EnableCompassBearingTrackingAction(MapboxMap map) { + mapboxMap = map; + } - @Override - public Matcher getConstraints() { - return isDisplayed(); - } + @Override + public Matcher getConstraints() { + return isDisplayed(); + } - @Override - public String getDescription() { - return getClass().getSimpleName(); - } + @Override + public String getDescription() { + return getClass().getSimpleName(); + } - @Override - public void perform(UiController uiController, View view) { - mapboxMap.getTrackingSettings().setMyBearingTrackingMode(MyBearingTracking.COMPASS); - // wait for next compass update cycle - uiController.loopMainThreadForAtLeast(500); - } + @Override + public void perform(UiController uiController, View view) { + mapboxMap.getTrackingSettings().setMyBearingTrackingMode(MyBearingTracking.COMPASS); + // wait for next compass update cycle + uiController.loopMainThreadForAtLeast(500); } + } - private class DrawableMatcher extends TypeSafeMatcher { + private class DrawableMatcher extends TypeSafeMatcher { - private MapboxMap mapboxMap; - private boolean isBearingDrawable; - private final int expectedId; + private MapboxMap mapboxMap; + private boolean isBearingDrawable; + private final int expectedId; - DrawableMatcher(MapboxMap mapboxMap, int expectedId, boolean isBearingDrawable) { - super(MyLocationView.class); - this.mapboxMap = mapboxMap; - this.expectedId = expectedId; - this.isBearingDrawable = isBearingDrawable; - } + DrawableMatcher(MapboxMap mapboxMap, int expectedId, boolean isBearingDrawable) { + super(MyLocationView.class); + this.mapboxMap = mapboxMap; + this.expectedId = expectedId; + this.isBearingDrawable = isBearingDrawable; + } - @Override - protected boolean matchesSafely(View target) { - Drawable currentDrawable = isBearingDrawable ? - mapboxMap.getMyLocationViewSettings().getForegroundBearingDrawable() : - mapboxMap.getMyLocationViewSettings().getForegroundDrawable(); + @Override + protected boolean matchesSafely(View target) { + Drawable currentDrawable = isBearingDrawable + ? mapboxMap.getMyLocationViewSettings().getForegroundBearingDrawable() : + mapboxMap.getMyLocationViewSettings().getForegroundDrawable(); - Resources resources = target.getContext().getResources(); - Drawable expectedDrawable = resources.getDrawable(expectedId); - return areDrawablesIdentical(currentDrawable, expectedDrawable); - } + Resources resources = target.getContext().getResources(); + Drawable expectedDrawable = resources.getDrawable(expectedId); + return areDrawablesIdentical(currentDrawable, expectedDrawable); + } - @Override - public void describeTo(Description description) { - description.appendText("trying to match MyLocationView drawable to " + expectedId); - } + @Override + public void describeTo(Description description) { + description.appendText("trying to match MyLocationView drawable to " + expectedId); + } - boolean areDrawablesIdentical(Drawable drawableA, Drawable drawableB) { - Drawable.ConstantState stateA = drawableA.getConstantState(); - Drawable.ConstantState stateB = drawableB.getConstantState(); - return (stateA != null && stateB != null && stateA.equals(stateB)) - || getBitmap(drawableA).sameAs(getBitmap(drawableB)); - } + boolean areDrawablesIdentical(Drawable drawableA, Drawable drawableB) { + Drawable.ConstantState stateA = drawableA.getConstantState(); + Drawable.ConstantState stateB = drawableB.getConstantState(); + return (stateA != null && stateB != null && stateA.equals(stateB)) + || getBitmap(drawableA).sameAs(getBitmap(drawableB)); + } - Bitmap getBitmap(Drawable drawable) { - Bitmap result; - if (drawable instanceof BitmapDrawable) { - result = ((BitmapDrawable) drawable).getBitmap(); - } else { - int width = drawable.getIntrinsicWidth(); - int height = drawable.getIntrinsicHeight(); - // Some drawables have no intrinsic width - e.g. solid colours. - if (width <= 0) { - width = 1; - } - if (height <= 0) { - height = 1; - } - - result = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); - Canvas canvas = new Canvas(result); - drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight()); - drawable.draw(canvas); - } - return result; - } + Bitmap getBitmap(Drawable drawable) { + Bitmap result; + if (drawable instanceof BitmapDrawable) { + result = ((BitmapDrawable) drawable).getBitmap(); + } else { + int width = drawable.getIntrinsicWidth(); + int height = drawable.getIntrinsicHeight(); + // Some drawables have no intrinsic width - e.g. solid colours. + if (width <= 0) { + width = 1; + } + if (height <= 0) { + height = 1; + } + + result = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); + Canvas canvas = new Canvas(result); + drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight()); + drawable.draw(canvas); + } + return result; } + } } diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/BackgroundLayerStyleTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/BackgroundLayerStyleTest.java index 1b954259f6..68ed5cb05d 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/BackgroundLayerStyleTest.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/BackgroundLayerStyleTest.java @@ -1,11 +1,10 @@ -// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make style-code-android`. package com.mapbox.mapboxsdk.testapp.style; +// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make style-code-android`. import android.graphics.Color; import android.support.test.espresso.Espresso; import android.support.test.rule.ActivityTestRule; import android.support.test.runner.AndroidJUnit4; -import timber.log.Timber; import com.mapbox.mapboxsdk.maps.MapboxMap; import com.mapbox.mapboxsdk.style.layers.BackgroundLayer; @@ -19,9 +18,16 @@ import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; -import static org.junit.Assert.*; -import static com.mapbox.mapboxsdk.style.layers.Property.*; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*; +import timber.log.Timber; + +import static com.mapbox.mapboxsdk.style.layers.Property.NONE; +import static com.mapbox.mapboxsdk.style.layers.Property.VISIBLE; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.backgroundColor; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.backgroundOpacity; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.backgroundPattern; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.visibility; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; /** * Basic smoke tests for BackgroundLayer @@ -29,107 +35,107 @@ import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*; @RunWith(AndroidJUnit4.class) public class BackgroundLayerStyleTest extends BaseStyleTest { - @Rule - public final ActivityTestRule rule = new ActivityTestRule<>(RuntimeStyleTestActivity.class); + @Rule + public final ActivityTestRule rule = new ActivityTestRule<>(RuntimeStyleTestActivity.class); - private BackgroundLayer layer; + private BackgroundLayer layer; - private OnMapReadyIdlingResource idlingResource; + private OnMapReadyIdlingResource idlingResource; - private MapboxMap mapboxMap; + private MapboxMap mapboxMap; - @Before - public void setup() { - idlingResource = new OnMapReadyIdlingResource(rule.getActivity()); - Espresso.registerIdlingResources(idlingResource); - } + @Before + public void setup() { + idlingResource = new OnMapReadyIdlingResource(rule.getActivity()); + Espresso.registerIdlingResources(idlingResource); + } - @Test - public void testSetVisibility() { - checkViewIsDisplayed(R.id.mapView); + @Test + public void testSetVisibility() { + checkViewIsDisplayed(R.id.mapView); - mapboxMap = rule.getActivity().getMapboxMap(); + mapboxMap = rule.getActivity().getMapboxMap(); - Timber.i("Retrieving layer"); - layer = mapboxMap.getLayerAs("background"); - Timber.i("visibility"); - assertNotNull(layer); + Timber.i("Retrieving layer"); + layer = mapboxMap.getLayerAs("background"); + Timber.i("visibility"); + 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 - public void testBackgroundColor() { - checkViewIsDisplayed(R.id.mapView); + @Test + public void testBackgroundColor() { + checkViewIsDisplayed(R.id.mapView); - mapboxMap = rule.getActivity().getMapboxMap(); + mapboxMap = rule.getActivity().getMapboxMap(); - Timber.i("Retrieving layer"); - layer = mapboxMap.getLayerAs("background"); - Timber.i("background-color"); - assertNotNull(layer); + Timber.i("Retrieving layer"); + layer = mapboxMap.getLayerAs("background"); + Timber.i("background-color"); + assertNotNull(layer); - //Set and Get - layer.setProperties(backgroundColor("rgba(0, 0, 0, 1)")); - assertEquals((String) layer.getBackgroundColor().getValue(), (String) "rgba(0, 0, 0, 1)"); - } + //Set and Get + layer.setProperties(backgroundColor("rgba(0, 0, 0, 1)")); + assertEquals((String) layer.getBackgroundColor().getValue(), (String) "rgba(0, 0, 0, 1)"); + } - @Test - public void testBackgroundColorAsInt() { - checkViewIsDisplayed(R.id.mapView); + @Test + public void testBackgroundColorAsInt() { + checkViewIsDisplayed(R.id.mapView); - mapboxMap = rule.getActivity().getMapboxMap(); + mapboxMap = rule.getActivity().getMapboxMap(); - Timber.i("Retrieving layer"); - layer = mapboxMap.getLayerAs("background"); - Timber.i("background-color"); - assertNotNull(layer); + Timber.i("Retrieving layer"); + layer = mapboxMap.getLayerAs("background"); + Timber.i("background-color"); + 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 - public void testBackgroundPattern() { - checkViewIsDisplayed(R.id.mapView); + @Test + public void testBackgroundPattern() { + checkViewIsDisplayed(R.id.mapView); - mapboxMap = rule.getActivity().getMapboxMap(); + mapboxMap = rule.getActivity().getMapboxMap(); - Timber.i("Retrieving layer"); - layer = mapboxMap.getLayerAs("background"); - Timber.i("background-pattern"); - assertNotNull(layer); + Timber.i("Retrieving layer"); + layer = mapboxMap.getLayerAs("background"); + Timber.i("background-pattern"); + assertNotNull(layer); - //Set and Get - layer.setProperties(backgroundPattern("pedestrian-polygon")); - assertEquals((String) layer.getBackgroundPattern().getValue(), (String) "pedestrian-polygon"); - } + //Set and Get + layer.setProperties(backgroundPattern("pedestrian-polygon")); + assertEquals((String) layer.getBackgroundPattern().getValue(), (String) "pedestrian-polygon"); + } - @Test - public void testBackgroundOpacity() { - checkViewIsDisplayed(R.id.mapView); + @Test + public void testBackgroundOpacity() { + checkViewIsDisplayed(R.id.mapView); - mapboxMap = rule.getActivity().getMapboxMap(); + mapboxMap = rule.getActivity().getMapboxMap(); - Timber.i("Retrieving layer"); - layer = mapboxMap.getLayerAs("background"); - Timber.i("background-opacity"); - assertNotNull(layer); + Timber.i("Retrieving layer"); + layer = mapboxMap.getLayerAs("background"); + Timber.i("background-opacity"); + assertNotNull(layer); - //Set and Get - layer.setProperties(backgroundOpacity(0.3f)); - assertEquals((Float) layer.getBackgroundOpacity().getValue(), (Float) 0.3f); - } + //Set and Get + layer.setProperties(backgroundOpacity(0.3f)); + assertEquals((Float) layer.getBackgroundOpacity().getValue(), (Float) 0.3f); + } - @After - public void unregisterIntentServiceIdlingResource() { - Espresso.unregisterIdlingResources(idlingResource); - } + @After + public void unregisterIntentServiceIdlingResource() { + Espresso.unregisterIdlingResources(idlingResource); + } } 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 393e4fdd2b..ab53ae0487 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 @@ -1,11 +1,10 @@ -// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make android-style-code`. package com.mapbox.mapboxsdk.testapp.style; +// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make android-style-code`. import android.graphics.Color; import android.support.test.espresso.Espresso; import android.support.test.rule.ActivityTestRule; import android.support.test.runner.AndroidJUnit4; -import timber.log.Timber; import com.mapbox.mapboxsdk.maps.MapboxMap; import com.mapbox.mapboxsdk.style.layers.BackgroundLayer; @@ -19,9 +18,16 @@ import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; -import static org.junit.Assert.*; -import static com.mapbox.mapboxsdk.style.layers.Property.*; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*; +import timber.log.Timber; + +import static com.mapbox.mapboxsdk.style.layers.Property.NONE; +import static com.mapbox.mapboxsdk.style.layers.Property.VISIBLE; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.backgroundColor; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.backgroundOpacity; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.backgroundPattern; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.visibility; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; /** * Basic smoke tests for BackgroundLayer @@ -29,107 +35,107 @@ import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*; @RunWith(AndroidJUnit4.class) public class BackgroundLayerTest extends BaseStyleTest { - @Rule - public final ActivityTestRule rule = new ActivityTestRule<>(RuntimeStyleTestActivity.class); + @Rule + public final ActivityTestRule rule = new ActivityTestRule<>(RuntimeStyleTestActivity.class); - private BackgroundLayer layer; + private BackgroundLayer layer; - private OnMapReadyIdlingResource idlingResource; + private OnMapReadyIdlingResource idlingResource; - private MapboxMap mapboxMap; + private MapboxMap mapboxMap; - @Before - public void setup() { - idlingResource = new OnMapReadyIdlingResource(rule.getActivity()); - Espresso.registerIdlingResources(idlingResource); - } + @Before + public void setup() { + idlingResource = new OnMapReadyIdlingResource(rule.getActivity()); + Espresso.registerIdlingResources(idlingResource); + } - @Test - public void testSetVisibility() { - checkViewIsDisplayed(R.id.mapView); + @Test + public void testSetVisibility() { + checkViewIsDisplayed(R.id.mapView); - mapboxMap = rule.getActivity().getMapboxMap(); + mapboxMap = rule.getActivity().getMapboxMap(); - Timber.i("Retrieving layer"); - layer = mapboxMap.getLayerAs("background"); - Timber.i("visibility"); - assertNotNull(layer); + Timber.i("Retrieving layer"); + layer = mapboxMap.getLayerAs("background"); + Timber.i("visibility"); + 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 - public void testBackgroundColor() { - checkViewIsDisplayed(R.id.mapView); + @Test + public void testBackgroundColor() { + checkViewIsDisplayed(R.id.mapView); - mapboxMap = rule.getActivity().getMapboxMap(); + mapboxMap = rule.getActivity().getMapboxMap(); - Timber.i("Retrieving layer"); - layer = mapboxMap.getLayerAs("background"); - Timber.i("background-color"); - assertNotNull(layer); + Timber.i("Retrieving layer"); + layer = mapboxMap.getLayerAs("background"); + Timber.i("background-color"); + assertNotNull(layer); - //Set and Get - layer.setProperties(backgroundColor("rgba(0, 0, 0, 1)")); - assertEquals((String) layer.getBackgroundColor().getValue(), (String) "rgba(0, 0, 0, 1)"); - } + //Set and Get + layer.setProperties(backgroundColor("rgba(0, 0, 0, 1)")); + assertEquals((String) layer.getBackgroundColor().getValue(), (String) "rgba(0, 0, 0, 1)"); + } - @Test - public void testBackgroundColorAsInt() { - checkViewIsDisplayed(R.id.mapView); + @Test + public void testBackgroundColorAsInt() { + checkViewIsDisplayed(R.id.mapView); - mapboxMap = rule.getActivity().getMapboxMap(); + mapboxMap = rule.getActivity().getMapboxMap(); - Timber.i("Retrieving layer"); - layer = mapboxMap.getLayerAs("background"); - Timber.i("background-color"); - assertNotNull(layer); + Timber.i("Retrieving layer"); + layer = mapboxMap.getLayerAs("background"); + Timber.i("background-color"); + 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 - public void testBackgroundPattern() { - checkViewIsDisplayed(R.id.mapView); + @Test + public void testBackgroundPattern() { + checkViewIsDisplayed(R.id.mapView); - mapboxMap = rule.getActivity().getMapboxMap(); + mapboxMap = rule.getActivity().getMapboxMap(); - Timber.i("Retrieving layer"); - layer = mapboxMap.getLayerAs("background"); - Timber.i("background-pattern"); - assertNotNull(layer); + Timber.i("Retrieving layer"); + layer = mapboxMap.getLayerAs("background"); + Timber.i("background-pattern"); + assertNotNull(layer); - //Set and Get - layer.setProperties(backgroundPattern("pedestrian-polygon")); - assertEquals((String) layer.getBackgroundPattern().getValue(), (String) "pedestrian-polygon"); - } + //Set and Get + layer.setProperties(backgroundPattern("pedestrian-polygon")); + assertEquals((String) layer.getBackgroundPattern().getValue(), (String) "pedestrian-polygon"); + } - @Test - public void testBackgroundOpacity() { - checkViewIsDisplayed(R.id.mapView); + @Test + public void testBackgroundOpacity() { + checkViewIsDisplayed(R.id.mapView); - mapboxMap = rule.getActivity().getMapboxMap(); + mapboxMap = rule.getActivity().getMapboxMap(); - Timber.i("Retrieving layer"); - layer = mapboxMap.getLayerAs("background"); - Timber.i("background-opacity"); - assertNotNull(layer); + Timber.i("Retrieving layer"); + layer = mapboxMap.getLayerAs("background"); + Timber.i("background-opacity"); + assertNotNull(layer); - //Set and Get - layer.setProperties(backgroundOpacity(0.3f)); - assertEquals((Float) layer.getBackgroundOpacity().getValue(), (Float) 0.3f); - } + //Set and Get + layer.setProperties(backgroundOpacity(0.3f)); + assertEquals((Float) layer.getBackgroundOpacity().getValue(), (Float) 0.3f); + } - @After - public void unregisterIntentServiceIdlingResource() { - Espresso.unregisterIdlingResources(idlingResource); - } + @After + public void unregisterIntentServiceIdlingResource() { + Espresso.unregisterIdlingResources(idlingResource); + } } diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/BaseStyleTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/BaseStyleTest.java index 5ec4e5437b..620e15579f 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/BaseStyleTest.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/BaseStyleTest.java @@ -14,31 +14,31 @@ import static android.support.test.espresso.matcher.ViewMatchers.withId; */ public class BaseStyleTest { - protected final static String HOME_BUTTON_STRING = "Navigate up"; + protected static final String HOME_BUTTON_STRING = "Navigate up"; - /* - * Shortcuts for common UI tests - */ + /* + * Shortcuts for common UI tests + */ - protected void checkViewIsDisplayed(int id) { - onView(withId(id)) - .check(matches(isDisplayed())); - } + protected void checkViewIsDisplayed(int id) { + onView(withId(id)) + .check(matches(isDisplayed())); + } - /* - * Screenshots logic - */ + /* + * Screenshots logic + */ - protected void takeNamedScreenshot(final Activity activity, final String name) { + protected void takeNamedScreenshot(final Activity activity, final String name) { - // Screenshots need to be taken on the UI thread - activity.runOnUiThread(new Runnable() { - @Override - public void run() { - ScreenshotUtil.take(activity, name); - } - }); + // Screenshots need to be taken on the UI thread + activity.runOnUiThread(new Runnable() { + @Override + public void run() { + ScreenshotUtil.take(activity, name); + } + }); - } + } } diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/CircleLayerStyleTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/CircleLayerStyleTest.java index 635c88fccf..58fda51f07 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/CircleLayerStyleTest.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/CircleLayerStyleTest.java @@ -1,11 +1,10 @@ -// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make style-code-android`. package com.mapbox.mapboxsdk.testapp.style; +// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make style-code-android`. import android.graphics.Color; import android.support.test.espresso.Espresso; import android.support.test.rule.ActivityTestRule; import android.support.test.runner.AndroidJUnit4; -import timber.log.Timber; import com.mapbox.mapboxsdk.maps.MapboxMap; import com.mapbox.mapboxsdk.style.layers.CircleLayer; @@ -19,9 +18,22 @@ import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; -import static org.junit.Assert.*; -import static com.mapbox.mapboxsdk.style.layers.Property.*; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*; +import timber.log.Timber; + +import static com.mapbox.mapboxsdk.style.layers.Property.CIRCLE_PITCH_SCALE_MAP; +import static com.mapbox.mapboxsdk.style.layers.Property.CIRCLE_TRANSLATE_ANCHOR_MAP; +import static com.mapbox.mapboxsdk.style.layers.Property.NONE; +import static com.mapbox.mapboxsdk.style.layers.Property.VISIBLE; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.circleBlur; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.circleColor; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.circleOpacity; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.circlePitchScale; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.circleRadius; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.circleTranslate; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.circleTranslateAnchor; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.visibility; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; /** * Basic smoke tests for CircleLayer @@ -29,225 +41,225 @@ import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*; @RunWith(AndroidJUnit4.class) public class CircleLayerStyleTest extends BaseStyleTest { - @Rule - public final ActivityTestRule rule = new ActivityTestRule<>(RuntimeStyleTestActivity.class); + @Rule + public final ActivityTestRule rule = new ActivityTestRule<>(RuntimeStyleTestActivity.class); - private CircleLayer layer; + private CircleLayer layer; - private OnMapReadyIdlingResource idlingResource; + private OnMapReadyIdlingResource idlingResource; - private MapboxMap mapboxMap; + private MapboxMap mapboxMap; - @Before - public void setup() { - idlingResource = new OnMapReadyIdlingResource(rule.getActivity()); - Espresso.registerIdlingResources(idlingResource); - } + @Before + public void setup() { + idlingResource = new OnMapReadyIdlingResource(rule.getActivity()); + Espresso.registerIdlingResources(idlingResource); + } - @Test - public void testSetVisibility() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new CircleLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("visibility"); - assertNotNull(layer); - - //Get initial - assertEquals(layer.getVisibility().getValue(), VISIBLE); - - //Set - layer.setProperties(visibility(NONE)); - assertEquals(layer.getVisibility().getValue(), NONE); - } + @Test + public void testSetVisibility() { + checkViewIsDisplayed(R.id.mapView); - @Test - public void testCircleRadius() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new CircleLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("circle-radius"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(circleRadius(0.3f)); - assertEquals((Float) layer.getCircleRadius().getValue(), (Float) 0.3f); - } + mapboxMap = rule.getActivity().getMapboxMap(); - @Test - public void testCircleColor() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new CircleLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("circle-color"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(circleColor("rgba(0, 0, 0, 1)")); - assertEquals((String) layer.getCircleColor().getValue(), (String) "rgba(0, 0, 0, 1)"); + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new CircleLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testCircleColorAsInt() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new CircleLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("circle-color"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(circleColor(Color.RED)); - assertEquals(layer.getCircleColorAsInt(), Color.RED); + Timber.i("visibility"); + assertNotNull(layer); + + //Get initial + assertEquals(layer.getVisibility().getValue(), VISIBLE); + + //Set + layer.setProperties(visibility(NONE)); + assertEquals(layer.getVisibility().getValue(), NONE); + } + + @Test + public void testCircleRadius() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new CircleLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testCircleBlur() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new CircleLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("circle-blur"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(circleBlur(0.3f)); - assertEquals((Float) layer.getCircleBlur().getValue(), (Float) 0.3f); + Timber.i("circle-radius"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(circleRadius(0.3f)); + assertEquals((Float) layer.getCircleRadius().getValue(), (Float) 0.3f); + } + + @Test + public void testCircleColor() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new CircleLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testCircleOpacity() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new CircleLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("circle-opacity"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(circleOpacity(0.3f)); - assertEquals((Float) layer.getCircleOpacity().getValue(), (Float) 0.3f); + Timber.i("circle-color"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(circleColor("rgba(0, 0, 0, 1)")); + assertEquals((String) layer.getCircleColor().getValue(), (String) "rgba(0, 0, 0, 1)"); + } + + @Test + public void testCircleColorAsInt() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new CircleLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testCircleTranslate() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new CircleLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("circle-translate"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(circleTranslate(new Float[]{0f,0f})); - assertEquals((Float[]) layer.getCircleTranslate().getValue(), (Float[]) new Float[]{0f,0f}); + Timber.i("circle-color"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(circleColor(Color.RED)); + assertEquals(layer.getCircleColorAsInt(), Color.RED); + } + + @Test + public void testCircleBlur() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new CircleLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testCircleTranslateAnchor() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new CircleLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("circle-translate-anchor"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(circleTranslateAnchor(CIRCLE_TRANSLATE_ANCHOR_MAP)); - assertEquals((String) layer.getCircleTranslateAnchor().getValue(), (String) CIRCLE_TRANSLATE_ANCHOR_MAP); + Timber.i("circle-blur"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(circleBlur(0.3f)); + assertEquals((Float) layer.getCircleBlur().getValue(), (Float) 0.3f); + } + + @Test + public void testCircleOpacity() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new CircleLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testCirclePitchScale() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new CircleLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("circle-pitch-scale"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(circlePitchScale(CIRCLE_PITCH_SCALE_MAP)); - assertEquals((String) layer.getCirclePitchScale().getValue(), (String) CIRCLE_PITCH_SCALE_MAP); + Timber.i("circle-opacity"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(circleOpacity(0.3f)); + assertEquals((Float) layer.getCircleOpacity().getValue(), (Float) 0.3f); + } + + @Test + public void testCircleTranslate() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new CircleLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); + } + Timber.i("circle-translate"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(circleTranslate(new Float[] {0f, 0f})); + assertEquals((Float[]) layer.getCircleTranslate().getValue(), (Float[]) new Float[] {0f, 0f}); + } + + @Test + public void testCircleTranslateAnchor() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new CircleLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } + Timber.i("circle-translate-anchor"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(circleTranslateAnchor(CIRCLE_TRANSLATE_ANCHOR_MAP)); + assertEquals((String) layer.getCircleTranslateAnchor().getValue(), (String) CIRCLE_TRANSLATE_ANCHOR_MAP); + } + + @Test + public void testCirclePitchScale() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new CircleLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); + } + Timber.i("circle-pitch-scale"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(circlePitchScale(CIRCLE_PITCH_SCALE_MAP)); + assertEquals((String) layer.getCirclePitchScale().getValue(), (String) CIRCLE_PITCH_SCALE_MAP); + } - @After - public void unregisterIntentServiceIdlingResource() { - Espresso.unregisterIdlingResources(idlingResource); - } + @After + public void unregisterIntentServiceIdlingResource() { + Espresso.unregisterIdlingResources(idlingResource); + } } 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 e7be929d24..782598a0b2 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 @@ -1,11 +1,10 @@ -// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make android-style-code`. package com.mapbox.mapboxsdk.testapp.style; +// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make android-style-code`. import android.graphics.Color; import android.support.test.espresso.Espresso; import android.support.test.rule.ActivityTestRule; import android.support.test.runner.AndroidJUnit4; -import timber.log.Timber; import com.mapbox.mapboxsdk.maps.MapboxMap; import com.mapbox.mapboxsdk.style.layers.CircleLayer; @@ -19,9 +18,25 @@ import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; -import static org.junit.Assert.*; -import static com.mapbox.mapboxsdk.style.layers.Property.*; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*; +import timber.log.Timber; + +import static com.mapbox.mapboxsdk.style.layers.Property.CIRCLE_PITCH_SCALE_MAP; +import static com.mapbox.mapboxsdk.style.layers.Property.CIRCLE_TRANSLATE_ANCHOR_MAP; +import static com.mapbox.mapboxsdk.style.layers.Property.NONE; +import static com.mapbox.mapboxsdk.style.layers.Property.VISIBLE; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.circleBlur; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.circleColor; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.circleOpacity; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.circlePitchScale; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.circleRadius; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.circleStrokeColor; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.circleStrokeOpacity; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.circleStrokeWidth; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.circleTranslate; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.circleTranslateAnchor; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.visibility; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; /** * Basic smoke tests for CircleLayer @@ -29,313 +44,313 @@ import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*; @RunWith(AndroidJUnit4.class) public class CircleLayerTest extends BaseStyleTest { - @Rule - public final ActivityTestRule rule = new ActivityTestRule<>(RuntimeStyleTestActivity.class); + @Rule + public final ActivityTestRule rule = new ActivityTestRule<>(RuntimeStyleTestActivity.class); - private CircleLayer layer; + private CircleLayer layer; - private OnMapReadyIdlingResource idlingResource; + private OnMapReadyIdlingResource idlingResource; - private MapboxMap mapboxMap; + private MapboxMap mapboxMap; - @Before - public void setup() { - idlingResource = new OnMapReadyIdlingResource(rule.getActivity()); - Espresso.registerIdlingResources(idlingResource); - } + @Before + public void setup() { + idlingResource = new OnMapReadyIdlingResource(rule.getActivity()); + Espresso.registerIdlingResources(idlingResource); + } - @Test - public void testSetVisibility() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new CircleLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("visibility"); - assertNotNull(layer); - - //Get initial - assertEquals(layer.getVisibility().getValue(), VISIBLE); - - //Set - layer.setProperties(visibility(NONE)); - assertEquals(layer.getVisibility().getValue(), NONE); - } + @Test + public void testSetVisibility() { + checkViewIsDisplayed(R.id.mapView); - @Test - public void testCircleRadius() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new CircleLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("circle-radius"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(circleRadius(0.3f)); - assertEquals((Float) layer.getCircleRadius().getValue(), (Float) 0.3f); - } + mapboxMap = rule.getActivity().getMapboxMap(); - @Test - public void testCircleColor() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new CircleLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("circle-color"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(circleColor("rgba(0, 0, 0, 1)")); - assertEquals((String) layer.getCircleColor().getValue(), (String) "rgba(0, 0, 0, 1)"); + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new CircleLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testCircleColorAsInt() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new CircleLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("circle-color"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(circleColor(Color.RED)); - assertEquals(layer.getCircleColorAsInt(), Color.RED); + Timber.i("visibility"); + assertNotNull(layer); + + //Get initial + assertEquals(layer.getVisibility().getValue(), VISIBLE); + + //Set + layer.setProperties(visibility(NONE)); + assertEquals(layer.getVisibility().getValue(), NONE); + } + + @Test + public void testCircleRadius() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new CircleLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testCircleBlur() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new CircleLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("circle-blur"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(circleBlur(0.3f)); - assertEquals((Float) layer.getCircleBlur().getValue(), (Float) 0.3f); + Timber.i("circle-radius"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(circleRadius(0.3f)); + assertEquals((Float) layer.getCircleRadius().getValue(), (Float) 0.3f); + } + + @Test + public void testCircleColor() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new CircleLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testCircleOpacity() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new CircleLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("circle-opacity"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(circleOpacity(0.3f)); - assertEquals((Float) layer.getCircleOpacity().getValue(), (Float) 0.3f); + Timber.i("circle-color"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(circleColor("rgba(0, 0, 0, 1)")); + assertEquals((String) layer.getCircleColor().getValue(), (String) "rgba(0, 0, 0, 1)"); + } + + @Test + public void testCircleColorAsInt() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new CircleLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testCircleTranslate() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new CircleLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("circle-translate"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(circleTranslate(new Float[]{0f,0f})); - assertEquals((Float[]) layer.getCircleTranslate().getValue(), (Float[]) new Float[]{0f,0f}); + Timber.i("circle-color"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(circleColor(Color.RED)); + assertEquals(layer.getCircleColorAsInt(), Color.RED); + } + + @Test + public void testCircleBlur() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new CircleLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testCircleTranslateAnchor() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new CircleLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("circle-translate-anchor"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(circleTranslateAnchor(CIRCLE_TRANSLATE_ANCHOR_MAP)); - assertEquals((String) layer.getCircleTranslateAnchor().getValue(), (String) CIRCLE_TRANSLATE_ANCHOR_MAP); + Timber.i("circle-blur"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(circleBlur(0.3f)); + assertEquals((Float) layer.getCircleBlur().getValue(), (Float) 0.3f); + } + + @Test + public void testCircleOpacity() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new CircleLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testCirclePitchScale() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new CircleLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("circle-pitch-scale"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(circlePitchScale(CIRCLE_PITCH_SCALE_MAP)); - assertEquals((String) layer.getCirclePitchScale().getValue(), (String) CIRCLE_PITCH_SCALE_MAP); + Timber.i("circle-opacity"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(circleOpacity(0.3f)); + assertEquals((Float) layer.getCircleOpacity().getValue(), (Float) 0.3f); + } + + @Test + public void testCircleTranslate() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new CircleLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testCircleStrokeWidth() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new CircleLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("circle-stroke-width"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(circleStrokeWidth(0.3f)); - assertEquals((Float) layer.getCircleStrokeWidth().getValue(), (Float) 0.3f); + Timber.i("circle-translate"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(circleTranslate(new Float[] {0f, 0f})); + assertEquals((Float[]) layer.getCircleTranslate().getValue(), (Float[]) new Float[] {0f, 0f}); + } + + @Test + public void testCircleTranslateAnchor() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new CircleLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testCircleStrokeColor() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new CircleLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("circle-stroke-color"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(circleStrokeColor("rgba(0, 0, 0, 1)")); - assertEquals((String) layer.getCircleStrokeColor().getValue(), (String) "rgba(0, 0, 0, 1)"); + Timber.i("circle-translate-anchor"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(circleTranslateAnchor(CIRCLE_TRANSLATE_ANCHOR_MAP)); + assertEquals((String) layer.getCircleTranslateAnchor().getValue(), (String) CIRCLE_TRANSLATE_ANCHOR_MAP); + } + + @Test + public void testCirclePitchScale() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new CircleLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testCircleStrokeColorAsInt() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new CircleLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("circle-stroke-color"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(circleStrokeColor(Color.RED)); - assertEquals(layer.getCircleStrokeColorAsInt(), Color.RED); + Timber.i("circle-pitch-scale"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(circlePitchScale(CIRCLE_PITCH_SCALE_MAP)); + assertEquals((String) layer.getCirclePitchScale().getValue(), (String) CIRCLE_PITCH_SCALE_MAP); + } + + @Test + public void testCircleStrokeWidth() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new CircleLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testCircleStrokeOpacity() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new CircleLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("circle-stroke-opacity"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(circleStrokeOpacity(0.3f)); - assertEquals((Float) layer.getCircleStrokeOpacity().getValue(), (Float) 0.3f); + Timber.i("circle-stroke-width"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(circleStrokeWidth(0.3f)); + assertEquals((Float) layer.getCircleStrokeWidth().getValue(), (Float) 0.3f); + } + + @Test + public void testCircleStrokeColor() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new CircleLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); + } + Timber.i("circle-stroke-color"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(circleStrokeColor("rgba(0, 0, 0, 1)")); + assertEquals((String) layer.getCircleStrokeColor().getValue(), (String) "rgba(0, 0, 0, 1)"); + } + + @Test + public void testCircleStrokeColorAsInt() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new CircleLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } + Timber.i("circle-stroke-color"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(circleStrokeColor(Color.RED)); + assertEquals(layer.getCircleStrokeColorAsInt(), Color.RED); + } + + @Test + public void testCircleStrokeOpacity() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new CircleLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); + } + Timber.i("circle-stroke-opacity"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(circleStrokeOpacity(0.3f)); + assertEquals((Float) layer.getCircleStrokeOpacity().getValue(), (Float) 0.3f); + } - @After - public void unregisterIntentServiceIdlingResource() { - Espresso.unregisterIdlingResources(idlingResource); - } + @After + public void unregisterIntentServiceIdlingResource() { + Espresso.unregisterIdlingResources(idlingResource); + } } diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/FillLayerStyleTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/FillLayerStyleTest.java index 4043b07789..c8668fa407 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/FillLayerStyleTest.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/FillLayerStyleTest.java @@ -1,11 +1,10 @@ -// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make style-code-android`. package com.mapbox.mapboxsdk.testapp.style; +// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make style-code-android`. import android.graphics.Color; import android.support.test.espresso.Espresso; import android.support.test.rule.ActivityTestRule; import android.support.test.runner.AndroidJUnit4; -import timber.log.Timber; import com.mapbox.mapboxsdk.maps.MapboxMap; import com.mapbox.mapboxsdk.style.layers.FillLayer; @@ -19,9 +18,21 @@ import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; -import static org.junit.Assert.*; -import static com.mapbox.mapboxsdk.style.layers.Property.*; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*; +import timber.log.Timber; + +import static com.mapbox.mapboxsdk.style.layers.Property.FILL_TRANSLATE_ANCHOR_MAP; +import static com.mapbox.mapboxsdk.style.layers.Property.NONE; +import static com.mapbox.mapboxsdk.style.layers.Property.VISIBLE; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillAntialias; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillColor; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillOpacity; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillOutlineColor; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillPattern; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillTranslate; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillTranslateAnchor; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.visibility; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; /** * Basic smoke tests for FillLayer @@ -29,247 +40,247 @@ import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*; @RunWith(AndroidJUnit4.class) public class FillLayerStyleTest extends BaseStyleTest { - @Rule - public final ActivityTestRule rule = new ActivityTestRule<>(RuntimeStyleTestActivity.class); + @Rule + public final ActivityTestRule rule = new ActivityTestRule<>(RuntimeStyleTestActivity.class); - private FillLayer layer; + private FillLayer layer; - private OnMapReadyIdlingResource idlingResource; + private OnMapReadyIdlingResource idlingResource; - private MapboxMap mapboxMap; + private MapboxMap mapboxMap; - @Before - public void setup() { - idlingResource = new OnMapReadyIdlingResource(rule.getActivity()); - Espresso.registerIdlingResources(idlingResource); - } + @Before + public void setup() { + idlingResource = new OnMapReadyIdlingResource(rule.getActivity()); + Espresso.registerIdlingResources(idlingResource); + } - @Test - public void testSetVisibility() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new FillLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("visibility"); - assertNotNull(layer); - - //Get initial - assertEquals(layer.getVisibility().getValue(), VISIBLE); - - //Set - layer.setProperties(visibility(NONE)); - assertEquals(layer.getVisibility().getValue(), NONE); - } + @Test + public void testSetVisibility() { + checkViewIsDisplayed(R.id.mapView); - @Test - public void testFillAntialias() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new FillLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("fill-antialias"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(fillAntialias(true)); - assertEquals((Boolean) layer.getFillAntialias().getValue(), (Boolean) true); - } + mapboxMap = rule.getActivity().getMapboxMap(); - @Test - public void testFillOpacity() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new FillLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("fill-opacity"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(fillOpacity(0.3f)); - assertEquals((Float) layer.getFillOpacity().getValue(), (Float) 0.3f); + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new FillLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testFillColor() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new FillLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("fill-color"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(fillColor("rgba(0, 0, 0, 1)")); - assertEquals((String) layer.getFillColor().getValue(), (String) "rgba(0, 0, 0, 1)"); + Timber.i("visibility"); + assertNotNull(layer); + + //Get initial + assertEquals(layer.getVisibility().getValue(), VISIBLE); + + //Set + layer.setProperties(visibility(NONE)); + assertEquals(layer.getVisibility().getValue(), NONE); + } + + @Test + public void testFillAntialias() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new FillLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testFillColorAsInt() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new FillLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("fill-color"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(fillColor(Color.RED)); - assertEquals(layer.getFillColorAsInt(), Color.RED); + Timber.i("fill-antialias"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(fillAntialias(true)); + assertEquals((Boolean) layer.getFillAntialias().getValue(), (Boolean) true); + } + + @Test + public void testFillOpacity() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new FillLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testFillOutlineColor() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new FillLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("fill-outline-color"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(fillOutlineColor("rgba(0, 0, 0, 1)")); - assertEquals((String) layer.getFillOutlineColor().getValue(), (String) "rgba(0, 0, 0, 1)"); + Timber.i("fill-opacity"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(fillOpacity(0.3f)); + assertEquals((Float) layer.getFillOpacity().getValue(), (Float) 0.3f); + } + + @Test + public void testFillColor() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new FillLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testFillOutlineColorAsInt() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new FillLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("fill-outline-color"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(fillOutlineColor(Color.RED)); - assertEquals(layer.getFillOutlineColorAsInt(), Color.RED); + Timber.i("fill-color"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(fillColor("rgba(0, 0, 0, 1)")); + assertEquals((String) layer.getFillColor().getValue(), (String) "rgba(0, 0, 0, 1)"); + } + + @Test + public void testFillColorAsInt() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new FillLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testFillTranslate() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new FillLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("fill-translate"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(fillTranslate(new Float[]{0f,0f})); - assertEquals((Float[]) layer.getFillTranslate().getValue(), (Float[]) new Float[]{0f,0f}); + Timber.i("fill-color"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(fillColor(Color.RED)); + assertEquals(layer.getFillColorAsInt(), Color.RED); + } + + @Test + public void testFillOutlineColor() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new FillLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testFillTranslateAnchor() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new FillLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("fill-translate-anchor"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(fillTranslateAnchor(FILL_TRANSLATE_ANCHOR_MAP)); - assertEquals((String) layer.getFillTranslateAnchor().getValue(), (String) FILL_TRANSLATE_ANCHOR_MAP); + Timber.i("fill-outline-color"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(fillOutlineColor("rgba(0, 0, 0, 1)")); + assertEquals((String) layer.getFillOutlineColor().getValue(), (String) "rgba(0, 0, 0, 1)"); + } + + @Test + public void testFillOutlineColorAsInt() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new FillLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testFillPattern() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new FillLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("fill-pattern"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(fillPattern("pedestrian-polygon")); - assertEquals((String) layer.getFillPattern().getValue(), (String) "pedestrian-polygon"); + Timber.i("fill-outline-color"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(fillOutlineColor(Color.RED)); + assertEquals(layer.getFillOutlineColorAsInt(), Color.RED); + } + + @Test + public void testFillTranslate() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new FillLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); + } + Timber.i("fill-translate"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(fillTranslate(new Float[] {0f, 0f})); + assertEquals((Float[]) layer.getFillTranslate().getValue(), (Float[]) new Float[] {0f, 0f}); + } + + @Test + public void testFillTranslateAnchor() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new FillLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } + Timber.i("fill-translate-anchor"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(fillTranslateAnchor(FILL_TRANSLATE_ANCHOR_MAP)); + assertEquals((String) layer.getFillTranslateAnchor().getValue(), (String) FILL_TRANSLATE_ANCHOR_MAP); + } + + @Test + public void testFillPattern() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new FillLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); + } + Timber.i("fill-pattern"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(fillPattern("pedestrian-polygon")); + assertEquals((String) layer.getFillPattern().getValue(), (String) "pedestrian-polygon"); + } - @After - public void unregisterIntentServiceIdlingResource() { - Espresso.unregisterIdlingResources(idlingResource); - } + @After + public void unregisterIntentServiceIdlingResource() { + Espresso.unregisterIdlingResources(idlingResource); + } } 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 5a4a1f7154..95360e1273 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 @@ -1,11 +1,10 @@ -// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make android-style-code`. package com.mapbox.mapboxsdk.testapp.style; +// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make android-style-code`. import android.graphics.Color; import android.support.test.espresso.Espresso; import android.support.test.rule.ActivityTestRule; import android.support.test.runner.AndroidJUnit4; -import timber.log.Timber; import com.mapbox.mapboxsdk.maps.MapboxMap; import com.mapbox.mapboxsdk.style.layers.FillLayer; @@ -19,9 +18,21 @@ import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; -import static org.junit.Assert.*; -import static com.mapbox.mapboxsdk.style.layers.Property.*; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*; +import timber.log.Timber; + +import static com.mapbox.mapboxsdk.style.layers.Property.FILL_TRANSLATE_ANCHOR_MAP; +import static com.mapbox.mapboxsdk.style.layers.Property.NONE; +import static com.mapbox.mapboxsdk.style.layers.Property.VISIBLE; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillAntialias; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillColor; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillOpacity; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillOutlineColor; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillPattern; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillTranslate; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillTranslateAnchor; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.visibility; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; /** * Basic smoke tests for FillLayer @@ -29,247 +40,247 @@ import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*; @RunWith(AndroidJUnit4.class) public class FillLayerTest extends BaseStyleTest { - @Rule - public final ActivityTestRule rule = new ActivityTestRule<>(RuntimeStyleTestActivity.class); + @Rule + public final ActivityTestRule rule = new ActivityTestRule<>(RuntimeStyleTestActivity.class); - private FillLayer layer; + private FillLayer layer; - private OnMapReadyIdlingResource idlingResource; + private OnMapReadyIdlingResource idlingResource; - private MapboxMap mapboxMap; + private MapboxMap mapboxMap; - @Before - public void setup() { - idlingResource = new OnMapReadyIdlingResource(rule.getActivity()); - Espresso.registerIdlingResources(idlingResource); - } + @Before + public void setup() { + idlingResource = new OnMapReadyIdlingResource(rule.getActivity()); + Espresso.registerIdlingResources(idlingResource); + } - @Test - public void testSetVisibility() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new FillLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("visibility"); - assertNotNull(layer); - - //Get initial - assertEquals(layer.getVisibility().getValue(), VISIBLE); - - //Set - layer.setProperties(visibility(NONE)); - assertEquals(layer.getVisibility().getValue(), NONE); - } + @Test + public void testSetVisibility() { + checkViewIsDisplayed(R.id.mapView); - @Test - public void testFillAntialias() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new FillLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("fill-antialias"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(fillAntialias(true)); - assertEquals((Boolean) layer.getFillAntialias().getValue(), (Boolean) true); - } + mapboxMap = rule.getActivity().getMapboxMap(); - @Test - public void testFillOpacity() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new FillLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("fill-opacity"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(fillOpacity(0.3f)); - assertEquals((Float) layer.getFillOpacity().getValue(), (Float) 0.3f); + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new FillLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testFillColor() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new FillLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("fill-color"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(fillColor("rgba(0, 0, 0, 1)")); - assertEquals((String) layer.getFillColor().getValue(), (String) "rgba(0, 0, 0, 1)"); + Timber.i("visibility"); + assertNotNull(layer); + + //Get initial + assertEquals(layer.getVisibility().getValue(), VISIBLE); + + //Set + layer.setProperties(visibility(NONE)); + assertEquals(layer.getVisibility().getValue(), NONE); + } + + @Test + public void testFillAntialias() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new FillLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testFillColorAsInt() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new FillLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("fill-color"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(fillColor(Color.RED)); - assertEquals(layer.getFillColorAsInt(), Color.RED); + Timber.i("fill-antialias"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(fillAntialias(true)); + assertEquals((Boolean) layer.getFillAntialias().getValue(), (Boolean) true); + } + + @Test + public void testFillOpacity() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new FillLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testFillOutlineColor() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new FillLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("fill-outline-color"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(fillOutlineColor("rgba(0, 0, 0, 1)")); - assertEquals((String) layer.getFillOutlineColor().getValue(), (String) "rgba(0, 0, 0, 1)"); + Timber.i("fill-opacity"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(fillOpacity(0.3f)); + assertEquals((Float) layer.getFillOpacity().getValue(), (Float) 0.3f); + } + + @Test + public void testFillColor() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new FillLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testFillOutlineColorAsInt() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new FillLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("fill-outline-color"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(fillOutlineColor(Color.RED)); - assertEquals(layer.getFillOutlineColorAsInt(), Color.RED); + Timber.i("fill-color"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(fillColor("rgba(0, 0, 0, 1)")); + assertEquals((String) layer.getFillColor().getValue(), (String) "rgba(0, 0, 0, 1)"); + } + + @Test + public void testFillColorAsInt() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new FillLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testFillTranslate() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new FillLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("fill-translate"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(fillTranslate(new Float[]{0f,0f})); - assertEquals((Float[]) layer.getFillTranslate().getValue(), (Float[]) new Float[]{0f,0f}); + Timber.i("fill-color"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(fillColor(Color.RED)); + assertEquals(layer.getFillColorAsInt(), Color.RED); + } + + @Test + public void testFillOutlineColor() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new FillLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testFillTranslateAnchor() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new FillLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("fill-translate-anchor"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(fillTranslateAnchor(FILL_TRANSLATE_ANCHOR_MAP)); - assertEquals((String) layer.getFillTranslateAnchor().getValue(), (String) FILL_TRANSLATE_ANCHOR_MAP); + Timber.i("fill-outline-color"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(fillOutlineColor("rgba(0, 0, 0, 1)")); + assertEquals((String) layer.getFillOutlineColor().getValue(), (String) "rgba(0, 0, 0, 1)"); + } + + @Test + public void testFillOutlineColorAsInt() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new FillLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testFillPattern() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new FillLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("fill-pattern"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(fillPattern("pedestrian-polygon")); - assertEquals((String) layer.getFillPattern().getValue(), (String) "pedestrian-polygon"); + Timber.i("fill-outline-color"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(fillOutlineColor(Color.RED)); + assertEquals(layer.getFillOutlineColorAsInt(), Color.RED); + } + + @Test + public void testFillTranslate() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new FillLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); + } + Timber.i("fill-translate"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(fillTranslate(new Float[] {0f, 0f})); + assertEquals((Float[]) layer.getFillTranslate().getValue(), (Float[]) new Float[] {0f, 0f}); + } + + @Test + public void testFillTranslateAnchor() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new FillLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } + Timber.i("fill-translate-anchor"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(fillTranslateAnchor(FILL_TRANSLATE_ANCHOR_MAP)); + assertEquals((String) layer.getFillTranslateAnchor().getValue(), (String) FILL_TRANSLATE_ANCHOR_MAP); + } + + @Test + public void testFillPattern() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new FillLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); + } + Timber.i("fill-pattern"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(fillPattern("pedestrian-polygon")); + assertEquals((String) layer.getFillPattern().getValue(), (String) "pedestrian-polygon"); + } - @After - public void unregisterIntentServiceIdlingResource() { - Espresso.unregisterIdlingResources(idlingResource); - } + @After + public void unregisterIntentServiceIdlingResource() { + Espresso.unregisterIdlingResources(idlingResource); + } } diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/LineLayerStyleTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/LineLayerStyleTest.java index e4401c088a..47a38a11ab 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/LineLayerStyleTest.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/LineLayerStyleTest.java @@ -1,11 +1,10 @@ -// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make style-code-android`. package com.mapbox.mapboxsdk.testapp.style; +// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make style-code-android`. import android.graphics.Color; import android.support.test.espresso.Espresso; import android.support.test.rule.ActivityTestRule; import android.support.test.runner.AndroidJUnit4; -import timber.log.Timber; import com.mapbox.mapboxsdk.maps.MapboxMap; import com.mapbox.mapboxsdk.style.layers.LineLayer; @@ -19,9 +18,30 @@ import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; -import static org.junit.Assert.*; -import static com.mapbox.mapboxsdk.style.layers.Property.*; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*; +import timber.log.Timber; + +import static com.mapbox.mapboxsdk.style.layers.Property.LINE_CAP_BUTT; +import static com.mapbox.mapboxsdk.style.layers.Property.LINE_JOIN_BEVEL; +import static com.mapbox.mapboxsdk.style.layers.Property.LINE_TRANSLATE_ANCHOR_MAP; +import static com.mapbox.mapboxsdk.style.layers.Property.NONE; +import static com.mapbox.mapboxsdk.style.layers.Property.VISIBLE; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineBlur; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineCap; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineColor; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineDasharray; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineGapWidth; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineJoin; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineMiterLimit; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineOffset; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineOpacity; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.linePattern; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineRoundLimit; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineTranslate; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineTranslateAnchor; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineWidth; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.visibility; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; /** * Basic smoke tests for LineLayer @@ -29,379 +49,379 @@ import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*; @RunWith(AndroidJUnit4.class) public class LineLayerStyleTest extends BaseStyleTest { - @Rule - public final ActivityTestRule rule = new ActivityTestRule<>(RuntimeStyleTestActivity.class); + @Rule + public final ActivityTestRule rule = new ActivityTestRule<>(RuntimeStyleTestActivity.class); - private LineLayer layer; + private LineLayer layer; - private OnMapReadyIdlingResource idlingResource; + private OnMapReadyIdlingResource idlingResource; - private MapboxMap mapboxMap; + private MapboxMap mapboxMap; - @Before - public void setup() { - idlingResource = new OnMapReadyIdlingResource(rule.getActivity()); - Espresso.registerIdlingResources(idlingResource); - } + @Before + public void setup() { + idlingResource = new OnMapReadyIdlingResource(rule.getActivity()); + Espresso.registerIdlingResources(idlingResource); + } - @Test - public void testSetVisibility() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new LineLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("visibility"); - assertNotNull(layer); - - //Get initial - assertEquals(layer.getVisibility().getValue(), VISIBLE); - - //Set - layer.setProperties(visibility(NONE)); - assertEquals(layer.getVisibility().getValue(), NONE); - } + @Test + public void testSetVisibility() { + checkViewIsDisplayed(R.id.mapView); - @Test - public void testLineCap() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new LineLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("line-cap"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(lineCap(LINE_CAP_BUTT)); - assertEquals((String) layer.getLineCap().getValue(), (String) LINE_CAP_BUTT); - } + mapboxMap = rule.getActivity().getMapboxMap(); - @Test - public void testLineJoin() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new LineLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("line-join"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(lineJoin(LINE_JOIN_BEVEL)); - assertEquals((String) layer.getLineJoin().getValue(), (String) LINE_JOIN_BEVEL); + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new LineLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testLineMiterLimit() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new LineLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("line-miter-limit"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(lineMiterLimit(0.3f)); - assertEquals((Float) layer.getLineMiterLimit().getValue(), (Float) 0.3f); + Timber.i("visibility"); + assertNotNull(layer); + + //Get initial + assertEquals(layer.getVisibility().getValue(), VISIBLE); + + //Set + layer.setProperties(visibility(NONE)); + assertEquals(layer.getVisibility().getValue(), NONE); + } + + @Test + public void testLineCap() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new LineLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testLineRoundLimit() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new LineLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("line-round-limit"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(lineRoundLimit(0.3f)); - assertEquals((Float) layer.getLineRoundLimit().getValue(), (Float) 0.3f); + Timber.i("line-cap"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(lineCap(LINE_CAP_BUTT)); + assertEquals((String) layer.getLineCap().getValue(), (String) LINE_CAP_BUTT); + } + + @Test + public void testLineJoin() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new LineLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testLineOpacity() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new LineLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("line-opacity"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(lineOpacity(0.3f)); - assertEquals((Float) layer.getLineOpacity().getValue(), (Float) 0.3f); + Timber.i("line-join"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(lineJoin(LINE_JOIN_BEVEL)); + assertEquals((String) layer.getLineJoin().getValue(), (String) LINE_JOIN_BEVEL); + } + + @Test + public void testLineMiterLimit() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new LineLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testLineColor() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new LineLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("line-color"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(lineColor("rgba(0, 0, 0, 1)")); - assertEquals((String) layer.getLineColor().getValue(), (String) "rgba(0, 0, 0, 1)"); + Timber.i("line-miter-limit"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(lineMiterLimit(0.3f)); + assertEquals((Float) layer.getLineMiterLimit().getValue(), (Float) 0.3f); + } + + @Test + public void testLineRoundLimit() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new LineLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testLineColorAsInt() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new LineLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("line-color"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(lineColor(Color.RED)); - assertEquals(layer.getLineColorAsInt(), Color.RED); + Timber.i("line-round-limit"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(lineRoundLimit(0.3f)); + assertEquals((Float) layer.getLineRoundLimit().getValue(), (Float) 0.3f); + } + + @Test + public void testLineOpacity() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new LineLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testLineTranslate() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new LineLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("line-translate"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(lineTranslate(new Float[]{0f,0f})); - assertEquals((Float[]) layer.getLineTranslate().getValue(), (Float[]) new Float[]{0f,0f}); + Timber.i("line-opacity"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(lineOpacity(0.3f)); + assertEquals((Float) layer.getLineOpacity().getValue(), (Float) 0.3f); + } + + @Test + public void testLineColor() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new LineLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testLineTranslateAnchor() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new LineLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("line-translate-anchor"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(lineTranslateAnchor(LINE_TRANSLATE_ANCHOR_MAP)); - assertEquals((String) layer.getLineTranslateAnchor().getValue(), (String) LINE_TRANSLATE_ANCHOR_MAP); + Timber.i("line-color"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(lineColor("rgba(0, 0, 0, 1)")); + assertEquals((String) layer.getLineColor().getValue(), (String) "rgba(0, 0, 0, 1)"); + } + + @Test + public void testLineColorAsInt() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new LineLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testLineWidth() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new LineLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("line-width"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(lineWidth(0.3f)); - assertEquals((Float) layer.getLineWidth().getValue(), (Float) 0.3f); + Timber.i("line-color"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(lineColor(Color.RED)); + assertEquals(layer.getLineColorAsInt(), Color.RED); + } + + @Test + public void testLineTranslate() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new LineLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testLineGapWidth() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new LineLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("line-gap-width"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(lineGapWidth(0.3f)); - assertEquals((Float) layer.getLineGapWidth().getValue(), (Float) 0.3f); + Timber.i("line-translate"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(lineTranslate(new Float[] {0f, 0f})); + assertEquals((Float[]) layer.getLineTranslate().getValue(), (Float[]) new Float[] {0f, 0f}); + } + + @Test + public void testLineTranslateAnchor() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new LineLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testLineOffset() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new LineLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("line-offset"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(lineOffset(0.3f)); - assertEquals((Float) layer.getLineOffset().getValue(), (Float) 0.3f); + Timber.i("line-translate-anchor"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(lineTranslateAnchor(LINE_TRANSLATE_ANCHOR_MAP)); + assertEquals((String) layer.getLineTranslateAnchor().getValue(), (String) LINE_TRANSLATE_ANCHOR_MAP); + } + + @Test + public void testLineWidth() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new LineLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testLineBlur() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new LineLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("line-blur"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(lineBlur(0.3f)); - assertEquals((Float) layer.getLineBlur().getValue(), (Float) 0.3f); + Timber.i("line-width"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(lineWidth(0.3f)); + assertEquals((Float) layer.getLineWidth().getValue(), (Float) 0.3f); + } + + @Test + public void testLineGapWidth() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new LineLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testLineDasharray() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new LineLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("line-dasharray"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(lineDasharray(new Float[]{})); - assertEquals((Float[]) layer.getLineDasharray().getValue(), (Float[]) new Float[]{}); + Timber.i("line-gap-width"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(lineGapWidth(0.3f)); + assertEquals((Float) layer.getLineGapWidth().getValue(), (Float) 0.3f); + } + + @Test + public void testLineOffset() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new LineLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testLinePattern() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new LineLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("line-pattern"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(linePattern("pedestrian-polygon")); - assertEquals((String) layer.getLinePattern().getValue(), (String) "pedestrian-polygon"); + Timber.i("line-offset"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(lineOffset(0.3f)); + assertEquals((Float) layer.getLineOffset().getValue(), (Float) 0.3f); + } + + @Test + public void testLineBlur() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new LineLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } + Timber.i("line-blur"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(lineBlur(0.3f)); + assertEquals((Float) layer.getLineBlur().getValue(), (Float) 0.3f); + } + + @Test + public void testLineDasharray() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new LineLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); + } + Timber.i("line-dasharray"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(lineDasharray(new Float[] {})); + assertEquals((Float[]) layer.getLineDasharray().getValue(), (Float[]) new Float[] {}); + } + + @Test + public void testLinePattern() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new LineLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); + } + Timber.i("line-pattern"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(linePattern("pedestrian-polygon")); + assertEquals((String) layer.getLinePattern().getValue(), (String) "pedestrian-polygon"); + } - @After - public void unregisterIntentServiceIdlingResource() { - Espresso.unregisterIdlingResources(idlingResource); - } + @After + public void unregisterIntentServiceIdlingResource() { + Espresso.unregisterIdlingResources(idlingResource); + } } 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 6280476a3d..ad091c78b3 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 @@ -1,11 +1,10 @@ -// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make android-style-code`. package com.mapbox.mapboxsdk.testapp.style; +// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make android-style-code`. import android.graphics.Color; import android.support.test.espresso.Espresso; import android.support.test.rule.ActivityTestRule; import android.support.test.runner.AndroidJUnit4; -import timber.log.Timber; import com.mapbox.mapboxsdk.maps.MapboxMap; import com.mapbox.mapboxsdk.style.layers.LineLayer; @@ -19,9 +18,30 @@ import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; -import static org.junit.Assert.*; -import static com.mapbox.mapboxsdk.style.layers.Property.*; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*; +import timber.log.Timber; + +import static com.mapbox.mapboxsdk.style.layers.Property.LINE_CAP_BUTT; +import static com.mapbox.mapboxsdk.style.layers.Property.LINE_JOIN_BEVEL; +import static com.mapbox.mapboxsdk.style.layers.Property.LINE_TRANSLATE_ANCHOR_MAP; +import static com.mapbox.mapboxsdk.style.layers.Property.NONE; +import static com.mapbox.mapboxsdk.style.layers.Property.VISIBLE; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineBlur; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineCap; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineColor; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineDasharray; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineGapWidth; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineJoin; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineMiterLimit; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineOffset; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineOpacity; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.linePattern; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineRoundLimit; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineTranslate; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineTranslateAnchor; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineWidth; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.visibility; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; /** * Basic smoke tests for LineLayer @@ -29,379 +49,379 @@ import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*; @RunWith(AndroidJUnit4.class) public class LineLayerTest extends BaseStyleTest { - @Rule - public final ActivityTestRule rule = new ActivityTestRule<>(RuntimeStyleTestActivity.class); + @Rule + public final ActivityTestRule rule = new ActivityTestRule<>(RuntimeStyleTestActivity.class); - private LineLayer layer; + private LineLayer layer; - private OnMapReadyIdlingResource idlingResource; + private OnMapReadyIdlingResource idlingResource; - private MapboxMap mapboxMap; + private MapboxMap mapboxMap; - @Before - public void setup() { - idlingResource = new OnMapReadyIdlingResource(rule.getActivity()); - Espresso.registerIdlingResources(idlingResource); - } + @Before + public void setup() { + idlingResource = new OnMapReadyIdlingResource(rule.getActivity()); + Espresso.registerIdlingResources(idlingResource); + } - @Test - public void testSetVisibility() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new LineLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("visibility"); - assertNotNull(layer); - - //Get initial - assertEquals(layer.getVisibility().getValue(), VISIBLE); - - //Set - layer.setProperties(visibility(NONE)); - assertEquals(layer.getVisibility().getValue(), NONE); - } + @Test + public void testSetVisibility() { + checkViewIsDisplayed(R.id.mapView); - @Test - public void testLineCap() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new LineLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("line-cap"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(lineCap(LINE_CAP_BUTT)); - assertEquals((String) layer.getLineCap().getValue(), (String) LINE_CAP_BUTT); - } + mapboxMap = rule.getActivity().getMapboxMap(); - @Test - public void testLineJoin() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new LineLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("line-join"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(lineJoin(LINE_JOIN_BEVEL)); - assertEquals((String) layer.getLineJoin().getValue(), (String) LINE_JOIN_BEVEL); + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new LineLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testLineMiterLimit() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new LineLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("line-miter-limit"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(lineMiterLimit(0.3f)); - assertEquals((Float) layer.getLineMiterLimit().getValue(), (Float) 0.3f); + Timber.i("visibility"); + assertNotNull(layer); + + //Get initial + assertEquals(layer.getVisibility().getValue(), VISIBLE); + + //Set + layer.setProperties(visibility(NONE)); + assertEquals(layer.getVisibility().getValue(), NONE); + } + + @Test + public void testLineCap() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new LineLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testLineRoundLimit() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new LineLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("line-round-limit"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(lineRoundLimit(0.3f)); - assertEquals((Float) layer.getLineRoundLimit().getValue(), (Float) 0.3f); + Timber.i("line-cap"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(lineCap(LINE_CAP_BUTT)); + assertEquals((String) layer.getLineCap().getValue(), (String) LINE_CAP_BUTT); + } + + @Test + public void testLineJoin() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new LineLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testLineOpacity() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new LineLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("line-opacity"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(lineOpacity(0.3f)); - assertEquals((Float) layer.getLineOpacity().getValue(), (Float) 0.3f); + Timber.i("line-join"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(lineJoin(LINE_JOIN_BEVEL)); + assertEquals((String) layer.getLineJoin().getValue(), (String) LINE_JOIN_BEVEL); + } + + @Test + public void testLineMiterLimit() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new LineLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testLineColor() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new LineLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("line-color"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(lineColor("rgba(0, 0, 0, 1)")); - assertEquals((String) layer.getLineColor().getValue(), (String) "rgba(0, 0, 0, 1)"); + Timber.i("line-miter-limit"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(lineMiterLimit(0.3f)); + assertEquals((Float) layer.getLineMiterLimit().getValue(), (Float) 0.3f); + } + + @Test + public void testLineRoundLimit() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new LineLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testLineColorAsInt() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new LineLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("line-color"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(lineColor(Color.RED)); - assertEquals(layer.getLineColorAsInt(), Color.RED); + Timber.i("line-round-limit"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(lineRoundLimit(0.3f)); + assertEquals((Float) layer.getLineRoundLimit().getValue(), (Float) 0.3f); + } + + @Test + public void testLineOpacity() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new LineLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testLineTranslate() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new LineLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("line-translate"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(lineTranslate(new Float[]{0f,0f})); - assertEquals((Float[]) layer.getLineTranslate().getValue(), (Float[]) new Float[]{0f,0f}); + Timber.i("line-opacity"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(lineOpacity(0.3f)); + assertEquals((Float) layer.getLineOpacity().getValue(), (Float) 0.3f); + } + + @Test + public void testLineColor() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new LineLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testLineTranslateAnchor() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new LineLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("line-translate-anchor"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(lineTranslateAnchor(LINE_TRANSLATE_ANCHOR_MAP)); - assertEquals((String) layer.getLineTranslateAnchor().getValue(), (String) LINE_TRANSLATE_ANCHOR_MAP); + Timber.i("line-color"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(lineColor("rgba(0, 0, 0, 1)")); + assertEquals((String) layer.getLineColor().getValue(), (String) "rgba(0, 0, 0, 1)"); + } + + @Test + public void testLineColorAsInt() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new LineLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testLineWidth() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new LineLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("line-width"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(lineWidth(0.3f)); - assertEquals((Float) layer.getLineWidth().getValue(), (Float) 0.3f); + Timber.i("line-color"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(lineColor(Color.RED)); + assertEquals(layer.getLineColorAsInt(), Color.RED); + } + + @Test + public void testLineTranslate() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new LineLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testLineGapWidth() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new LineLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("line-gap-width"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(lineGapWidth(0.3f)); - assertEquals((Float) layer.getLineGapWidth().getValue(), (Float) 0.3f); + Timber.i("line-translate"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(lineTranslate(new Float[] {0f, 0f})); + assertEquals((Float[]) layer.getLineTranslate().getValue(), (Float[]) new Float[] {0f, 0f}); + } + + @Test + public void testLineTranslateAnchor() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new LineLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testLineOffset() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new LineLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("line-offset"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(lineOffset(0.3f)); - assertEquals((Float) layer.getLineOffset().getValue(), (Float) 0.3f); + Timber.i("line-translate-anchor"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(lineTranslateAnchor(LINE_TRANSLATE_ANCHOR_MAP)); + assertEquals((String) layer.getLineTranslateAnchor().getValue(), (String) LINE_TRANSLATE_ANCHOR_MAP); + } + + @Test + public void testLineWidth() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new LineLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testLineBlur() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new LineLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("line-blur"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(lineBlur(0.3f)); - assertEquals((Float) layer.getLineBlur().getValue(), (Float) 0.3f); + Timber.i("line-width"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(lineWidth(0.3f)); + assertEquals((Float) layer.getLineWidth().getValue(), (Float) 0.3f); + } + + @Test + public void testLineGapWidth() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new LineLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testLineDasharray() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new LineLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("line-dasharray"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(lineDasharray(new Float[]{})); - assertEquals((Float[]) layer.getLineDasharray().getValue(), (Float[]) new Float[]{}); + Timber.i("line-gap-width"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(lineGapWidth(0.3f)); + assertEquals((Float) layer.getLineGapWidth().getValue(), (Float) 0.3f); + } + + @Test + public void testLineOffset() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new LineLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testLinePattern() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new LineLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("line-pattern"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(linePattern("pedestrian-polygon")); - assertEquals((String) layer.getLinePattern().getValue(), (String) "pedestrian-polygon"); + Timber.i("line-offset"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(lineOffset(0.3f)); + assertEquals((Float) layer.getLineOffset().getValue(), (Float) 0.3f); + } + + @Test + public void testLineBlur() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new LineLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } + Timber.i("line-blur"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(lineBlur(0.3f)); + assertEquals((Float) layer.getLineBlur().getValue(), (Float) 0.3f); + } + + @Test + public void testLineDasharray() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new LineLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); + } + Timber.i("line-dasharray"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(lineDasharray(new Float[] {})); + assertEquals((Float[]) layer.getLineDasharray().getValue(), (Float[]) new Float[] {}); + } + + @Test + public void testLinePattern() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new LineLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); + } + Timber.i("line-pattern"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(linePattern("pedestrian-polygon")); + assertEquals((String) layer.getLinePattern().getValue(), (String) "pedestrian-polygon"); + } - @After - public void unregisterIntentServiceIdlingResource() { - Espresso.unregisterIdlingResources(idlingResource); - } + @After + public void unregisterIntentServiceIdlingResource() { + Espresso.unregisterIdlingResources(idlingResource); + } } diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/RasterLayerStyleTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/RasterLayerStyleTest.java index 589c07c129..eb67b48f7a 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/RasterLayerStyleTest.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/RasterLayerStyleTest.java @@ -1,10 +1,9 @@ -// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make style-code-android`. package com.mapbox.mapboxsdk.testapp.style; +// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make style-code-android`. import android.support.test.espresso.Espresso; import android.support.test.rule.ActivityTestRule; import android.support.test.runner.AndroidJUnit4; -import timber.log.Timber; import com.mapbox.mapboxsdk.maps.MapboxMap; import com.mapbox.mapboxsdk.style.layers.RasterLayer; @@ -18,9 +17,20 @@ import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; -import static org.junit.Assert.*; -import static com.mapbox.mapboxsdk.style.layers.Property.*; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*; +import timber.log.Timber; + +import static com.mapbox.mapboxsdk.style.layers.Property.NONE; +import static com.mapbox.mapboxsdk.style.layers.Property.VISIBLE; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.rasterBrightnessMax; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.rasterBrightnessMin; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.rasterContrast; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.rasterFadeDuration; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.rasterHueRotate; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.rasterOpacity; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.rasterSaturation; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.visibility; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; /** * Basic smoke tests for RasterLayer @@ -28,203 +38,203 @@ import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*; @RunWith(AndroidJUnit4.class) public class RasterLayerStyleTest extends BaseStyleTest { - @Rule - public final ActivityTestRule rule = new ActivityTestRule<>(RuntimeStyleTestActivity.class); + @Rule + public final ActivityTestRule rule = new ActivityTestRule<>(RuntimeStyleTestActivity.class); - private RasterLayer layer; + private RasterLayer layer; - private OnMapReadyIdlingResource idlingResource; + private OnMapReadyIdlingResource idlingResource; - private MapboxMap mapboxMap; + private MapboxMap mapboxMap; - @Before - public void setup() { - idlingResource = new OnMapReadyIdlingResource(rule.getActivity()); - Espresso.registerIdlingResources(idlingResource); - } + @Before + public void setup() { + idlingResource = new OnMapReadyIdlingResource(rule.getActivity()); + Espresso.registerIdlingResources(idlingResource); + } - @Test - public void testSetVisibility() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new RasterLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("visibility"); - assertNotNull(layer); - - //Get initial - assertEquals(layer.getVisibility().getValue(), VISIBLE); - - //Set - layer.setProperties(visibility(NONE)); - assertEquals(layer.getVisibility().getValue(), NONE); - } + @Test + public void testSetVisibility() { + checkViewIsDisplayed(R.id.mapView); - @Test - public void testRasterOpacity() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new RasterLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("raster-opacity"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(rasterOpacity(0.3f)); - assertEquals((Float) layer.getRasterOpacity().getValue(), (Float) 0.3f); - } + mapboxMap = rule.getActivity().getMapboxMap(); - @Test - public void testRasterHueRotate() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new RasterLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("raster-hue-rotate"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(rasterHueRotate(0.3f)); - assertEquals((Float) layer.getRasterHueRotate().getValue(), (Float) 0.3f); + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new RasterLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testRasterBrightnessMin() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new RasterLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("raster-brightness-min"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(rasterBrightnessMin(0.3f)); - assertEquals((Float) layer.getRasterBrightnessMin().getValue(), (Float) 0.3f); + Timber.i("visibility"); + assertNotNull(layer); + + //Get initial + assertEquals(layer.getVisibility().getValue(), VISIBLE); + + //Set + layer.setProperties(visibility(NONE)); + assertEquals(layer.getVisibility().getValue(), NONE); + } + + @Test + public void testRasterOpacity() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new RasterLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testRasterBrightnessMax() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new RasterLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("raster-brightness-max"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(rasterBrightnessMax(0.3f)); - assertEquals((Float) layer.getRasterBrightnessMax().getValue(), (Float) 0.3f); + Timber.i("raster-opacity"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(rasterOpacity(0.3f)); + assertEquals((Float) layer.getRasterOpacity().getValue(), (Float) 0.3f); + } + + @Test + public void testRasterHueRotate() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new RasterLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testRasterSaturation() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new RasterLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("raster-saturation"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(rasterSaturation(0.3f)); - assertEquals((Float) layer.getRasterSaturation().getValue(), (Float) 0.3f); + Timber.i("raster-hue-rotate"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(rasterHueRotate(0.3f)); + assertEquals((Float) layer.getRasterHueRotate().getValue(), (Float) 0.3f); + } + + @Test + public void testRasterBrightnessMin() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new RasterLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testRasterContrast() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new RasterLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("raster-contrast"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(rasterContrast(0.3f)); - assertEquals((Float) layer.getRasterContrast().getValue(), (Float) 0.3f); + Timber.i("raster-brightness-min"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(rasterBrightnessMin(0.3f)); + assertEquals((Float) layer.getRasterBrightnessMin().getValue(), (Float) 0.3f); + } + + @Test + public void testRasterBrightnessMax() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new RasterLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testRasterFadeDuration() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new RasterLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("raster-fade-duration"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(rasterFadeDuration(0.3f)); - assertEquals((Float) layer.getRasterFadeDuration().getValue(), (Float) 0.3f); + Timber.i("raster-brightness-max"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(rasterBrightnessMax(0.3f)); + assertEquals((Float) layer.getRasterBrightnessMax().getValue(), (Float) 0.3f); + } + + @Test + public void testRasterSaturation() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new RasterLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); + } + Timber.i("raster-saturation"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(rasterSaturation(0.3f)); + assertEquals((Float) layer.getRasterSaturation().getValue(), (Float) 0.3f); + } + + @Test + public void testRasterContrast() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new RasterLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } + Timber.i("raster-contrast"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(rasterContrast(0.3f)); + assertEquals((Float) layer.getRasterContrast().getValue(), (Float) 0.3f); + } + + @Test + public void testRasterFadeDuration() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new RasterLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); + } + Timber.i("raster-fade-duration"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(rasterFadeDuration(0.3f)); + assertEquals((Float) layer.getRasterFadeDuration().getValue(), (Float) 0.3f); + } - @After - public void unregisterIntentServiceIdlingResource() { - Espresso.unregisterIdlingResources(idlingResource); - } + @After + public void unregisterIntentServiceIdlingResource() { + Espresso.unregisterIdlingResources(idlingResource); + } } 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 7cd36076d3..169d747b9c 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 @@ -1,11 +1,9 @@ -// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make android-style-code`. package com.mapbox.mapboxsdk.testapp.style; +// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make android-style-code`. -import android.graphics.Color; import android.support.test.espresso.Espresso; import android.support.test.rule.ActivityTestRule; import android.support.test.runner.AndroidJUnit4; -import timber.log.Timber; import com.mapbox.mapboxsdk.maps.MapboxMap; import com.mapbox.mapboxsdk.style.layers.RasterLayer; @@ -19,9 +17,20 @@ import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; -import static org.junit.Assert.*; -import static com.mapbox.mapboxsdk.style.layers.Property.*; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*; +import timber.log.Timber; + +import static com.mapbox.mapboxsdk.style.layers.Property.NONE; +import static com.mapbox.mapboxsdk.style.layers.Property.VISIBLE; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.rasterBrightnessMax; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.rasterBrightnessMin; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.rasterContrast; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.rasterFadeDuration; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.rasterHueRotate; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.rasterOpacity; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.rasterSaturation; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.visibility; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; /** * Basic smoke tests for RasterLayer @@ -29,203 +38,203 @@ import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*; @RunWith(AndroidJUnit4.class) public class RasterLayerTest extends BaseStyleTest { - @Rule - public final ActivityTestRule rule = new ActivityTestRule<>(RuntimeStyleTestActivity.class); + @Rule + public final ActivityTestRule rule = new ActivityTestRule<>(RuntimeStyleTestActivity.class); - private RasterLayer layer; + private RasterLayer layer; - private OnMapReadyIdlingResource idlingResource; + private OnMapReadyIdlingResource idlingResource; - private MapboxMap mapboxMap; + private MapboxMap mapboxMap; - @Before - public void setup() { - idlingResource = new OnMapReadyIdlingResource(rule.getActivity()); - Espresso.registerIdlingResources(idlingResource); - } + @Before + public void setup() { + idlingResource = new OnMapReadyIdlingResource(rule.getActivity()); + Espresso.registerIdlingResources(idlingResource); + } - @Test - public void testSetVisibility() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new RasterLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("visibility"); - assertNotNull(layer); - - //Get initial - assertEquals(layer.getVisibility().getValue(), VISIBLE); - - //Set - layer.setProperties(visibility(NONE)); - assertEquals(layer.getVisibility().getValue(), NONE); - } + @Test + public void testSetVisibility() { + checkViewIsDisplayed(R.id.mapView); - @Test - public void testRasterOpacity() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new RasterLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("raster-opacity"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(rasterOpacity(0.3f)); - assertEquals((Float) layer.getRasterOpacity().getValue(), (Float) 0.3f); - } + mapboxMap = rule.getActivity().getMapboxMap(); - @Test - public void testRasterHueRotate() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new RasterLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("raster-hue-rotate"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(rasterHueRotate(0.3f)); - assertEquals((Float) layer.getRasterHueRotate().getValue(), (Float) 0.3f); + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new RasterLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testRasterBrightnessMin() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new RasterLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("raster-brightness-min"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(rasterBrightnessMin(0.3f)); - assertEquals((Float) layer.getRasterBrightnessMin().getValue(), (Float) 0.3f); + Timber.i("visibility"); + assertNotNull(layer); + + //Get initial + assertEquals(layer.getVisibility().getValue(), VISIBLE); + + //Set + layer.setProperties(visibility(NONE)); + assertEquals(layer.getVisibility().getValue(), NONE); + } + + @Test + public void testRasterOpacity() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new RasterLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testRasterBrightnessMax() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new RasterLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("raster-brightness-max"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(rasterBrightnessMax(0.3f)); - assertEquals((Float) layer.getRasterBrightnessMax().getValue(), (Float) 0.3f); + Timber.i("raster-opacity"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(rasterOpacity(0.3f)); + assertEquals((Float) layer.getRasterOpacity().getValue(), (Float) 0.3f); + } + + @Test + public void testRasterHueRotate() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new RasterLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testRasterSaturation() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new RasterLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("raster-saturation"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(rasterSaturation(0.3f)); - assertEquals((Float) layer.getRasterSaturation().getValue(), (Float) 0.3f); + Timber.i("raster-hue-rotate"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(rasterHueRotate(0.3f)); + assertEquals((Float) layer.getRasterHueRotate().getValue(), (Float) 0.3f); + } + + @Test + public void testRasterBrightnessMin() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new RasterLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testRasterContrast() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new RasterLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("raster-contrast"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(rasterContrast(0.3f)); - assertEquals((Float) layer.getRasterContrast().getValue(), (Float) 0.3f); + Timber.i("raster-brightness-min"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(rasterBrightnessMin(0.3f)); + assertEquals((Float) layer.getRasterBrightnessMin().getValue(), (Float) 0.3f); + } + + @Test + public void testRasterBrightnessMax() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new RasterLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testRasterFadeDuration() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new RasterLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("raster-fade-duration"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(rasterFadeDuration(0.3f)); - assertEquals((Float) layer.getRasterFadeDuration().getValue(), (Float) 0.3f); + Timber.i("raster-brightness-max"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(rasterBrightnessMax(0.3f)); + assertEquals((Float) layer.getRasterBrightnessMax().getValue(), (Float) 0.3f); + } + + @Test + public void testRasterSaturation() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new RasterLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); + } + Timber.i("raster-saturation"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(rasterSaturation(0.3f)); + assertEquals((Float) layer.getRasterSaturation().getValue(), (Float) 0.3f); + } + + @Test + public void testRasterContrast() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new RasterLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } + Timber.i("raster-contrast"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(rasterContrast(0.3f)); + assertEquals((Float) layer.getRasterContrast().getValue(), (Float) 0.3f); + } + + @Test + public void testRasterFadeDuration() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new RasterLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); + } + Timber.i("raster-fade-duration"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(rasterFadeDuration(0.3f)); + assertEquals((Float) layer.getRasterFadeDuration().getValue(), (Float) 0.3f); + } - @After - public void unregisterIntentServiceIdlingResource() { - Espresso.unregisterIdlingResources(idlingResource); - } + @After + public void unregisterIntentServiceIdlingResource() { + Espresso.unregisterIdlingResources(idlingResource); + } } diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/RuntimeStyleBackgroundLayerTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/RuntimeStyleBackgroundLayerTest.java index de6e9b5a06..762ae4f846 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/RuntimeStyleBackgroundLayerTest.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/RuntimeStyleBackgroundLayerTest.java @@ -3,6 +3,7 @@ package com.mapbox.mapboxsdk.testapp.style; import android.support.test.InstrumentationRegistry; import android.support.test.runner.AndroidJUnit4; import android.test.ActivityInstrumentationTestCase2; + import timber.log.Timber; import com.mapbox.mapboxsdk.maps.MapboxMap; @@ -22,39 +23,39 @@ import org.junit.runner.RunWith; */ @RunWith(AndroidJUnit4.class) public class RuntimeStyleBackgroundLayerTest - extends ActivityInstrumentationTestCase2 { - - public RuntimeStyleBackgroundLayerTest() { - super(RuntimeStyleTestActivity.class); - } - - @Before - public void setUp() throws Exception { - super.setUp(); - injectInstrumentation(InstrumentationRegistry.getInstrumentation()); - } - - @Test - public void testSetVisibility() { - getActivity().mapView.getMapAsync(new OnMapReadyCallback() { - @Override - public void onMapReady(MapboxMap mapboxMap) { - Timber.i("visibility"); - BackgroundLayer layer = mapboxMap.getLayerAs("background"); - assertNotNull(layer); - - //Get initial - assertEquals(layer.getVisibility().getValue(), Property.VISIBLE); - - //Set - layer.setProperties(PropertyFactory.visibility(Property.NONE)); - assertEquals(layer.getVisibility().getValue(), Property.NONE); - } - }); - } - - @After - public void tearDown() throws Exception { - super.tearDown(); - } + extends ActivityInstrumentationTestCase2 { + + public RuntimeStyleBackgroundLayerTest() { + super(RuntimeStyleTestActivity.class); + } + + @Before + public void setUp() throws Exception { + super.setUp(); + injectInstrumentation(InstrumentationRegistry.getInstrumentation()); + } + + @Test + public void testSetVisibility() { + getActivity().mapView.getMapAsync(new OnMapReadyCallback() { + @Override + public void onMapReady(MapboxMap mapboxMap) { + Timber.i("visibility"); + BackgroundLayer layer = mapboxMap.getLayerAs("background"); + assertNotNull(layer); + + //Get initial + assertEquals(layer.getVisibility().getValue(), Property.VISIBLE); + + //Set + layer.setProperties(PropertyFactory.visibility(Property.NONE)); + assertEquals(layer.getVisibility().getValue(), Property.NONE); + } + }); + } + + @After + public void tearDown() throws Exception { + super.tearDown(); + } } diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/RuntimeStyleTests.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/RuntimeStyleTests.java index 2c5ea8eb3f..eec00bdde9 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/RuntimeStyleTests.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/RuntimeStyleTests.java @@ -45,157 +45,157 @@ import static org.junit.Assert.assertNull; @RunWith(AndroidJUnit4.class) public class RuntimeStyleTests { - @Rule - public final ActivityTestRule rule = new ActivityTestRule<>(RuntimeStyleTestActivity.class); + @Rule + public final ActivityTestRule rule = new ActivityTestRule<>(RuntimeStyleTestActivity.class); + + private OnMapReadyIdlingResource idlingResource; + + @Before + public void registerIdlingResource() { + idlingResource = new OnMapReadyIdlingResource(rule.getActivity()); + Espresso.registerIdlingResources(idlingResource); + } + + @Test + public void testGetAddRemoveLayer() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + onView(withId(R.id.mapView)).perform(new AddRemoveLayerAction()); + } + + @Test + public void testAddRemoveSource() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + + MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); + mapboxMap.addSource(new VectorSource("my-source", "mapbox://mapbox.mapbox-terrain-v2")); + try { + mapboxMap.removeSource("my-source"); + } catch (NoSuchSourceException noSuchSourceException) { + // it's ok.. + } + + onView(withId(R.id.mapView)).perform(new AddRemoveSourceAction()); + } - private OnMapReadyIdlingResource idlingResource; + private class AddRemoveLayerAction implements ViewAction { - @Before - public void registerIdlingResource() { - idlingResource = new OnMapReadyIdlingResource(rule.getActivity()); - Espresso.registerIdlingResources(idlingResource); + @Override + public Matcher getConstraints() { + return isDisplayed(); } - @Test - public void testGetAddRemoveLayer() { - ViewUtils.checkViewIsDisplayed(R.id.mapView); - onView(withId(R.id.mapView)).perform(new AddRemoveLayerAction()); + @Override + public String getDescription() { + return getClass().getSimpleName(); } - @Test - public void testAddRemoveSource() { - ViewUtils.checkViewIsDisplayed(R.id.mapView); + @Override + public void perform(UiController uiController, View view) { + MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); + + //Get initial + assertNotNull(mapboxMap.getLayer("building")); + + //Remove + try { + mapboxMap.removeLayer("building"); + } catch (NoSuchLayerException noSuchSourceException) { + fail("Definitively exists: " + noSuchSourceException.getMessage()); + } + assertNull(mapboxMap.getLayer("building")); + + //Add + FillLayer layer = new FillLayer("building", "composite"); + layer.setSourceLayer("building"); + mapboxMap.addLayer(layer); + assertNotNull(mapboxMap.getLayer("building")); + + //Assure the reference still works + layer.setProperties(PropertyFactory.visibility(Property.VISIBLE)); + + //Remove, preserving the reference + try { + mapboxMap.removeLayer(layer); + } catch (NoSuchLayerException noSuchSourceException) { + fail("Definitively exists: " + noSuchSourceException.getMessage()); + } + + //Property setters should still work + layer.setProperties(PropertyFactory.fillColor(Color.RED)); + + //Re-add the reference... + mapboxMap.addLayer(layer); + + //Ensure it's there + Assert.assertNotNull(mapboxMap.getLayer(layer.getId())); + + //Test adding a duplicate layer + try { + mapboxMap.addLayer(new FillLayer("building", "composite")); + fail("Should not have been allowed to add a layer with a duplicate id"); + } catch (CannotAddLayerException cannotAddLayerException) { + //OK + } + } + } - MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); - mapboxMap.addSource(new VectorSource("my-source", "mapbox://mapbox.mapbox-terrain-v2")); - try { - mapboxMap.removeSource("my-source"); - } catch (NoSuchSourceException e) { - // it's ok.. - } + private class AddRemoveSourceAction implements ViewAction { - onView(withId(R.id.mapView)).perform(new AddRemoveSourceAction()); + @Override + public Matcher getConstraints() { + return isDisplayed(); } - private class AddRemoveLayerAction implements ViewAction { - - @Override - public Matcher getConstraints() { - return isDisplayed(); - } - - @Override - public String getDescription() { - return getClass().getSimpleName(); - } - - @Override - public void perform(UiController uiController, View view) { - MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); - - //Get initial - assertNotNull(mapboxMap.getLayer("building")); - - //Remove - try { - mapboxMap.removeLayer("building"); - } catch (NoSuchLayerException e) { - fail("Definitively exists: " + e.getMessage()); - } - assertNull(mapboxMap.getLayer("building")); - - //Add - FillLayer layer = new FillLayer("building", "composite"); - layer.setSourceLayer("building"); - mapboxMap.addLayer(layer); - assertNotNull(mapboxMap.getLayer("building")); - - //Assure the reference still works - layer.setProperties(PropertyFactory.visibility(Property.VISIBLE)); - - //Remove, preserving the reference - try { - mapboxMap.removeLayer(layer); - } catch (NoSuchLayerException e) { - fail("Definitively exists: " + e.getMessage()); - } - - //Property setters should still work - layer.setProperties(PropertyFactory.fillColor(Color.RED)); - - //Re-add the reference... - mapboxMap.addLayer(layer); - - //Ensure it's there - Assert.assertNotNull(mapboxMap.getLayer(layer.getId())); - - //Test adding a duplicate layer - try { - mapboxMap.addLayer(new FillLayer("building", "composite")); - fail("Should not have been allowed to add a layer with a duplicate id"); - } catch (CannotAddLayerException e) { - //OK - } - } + @Override + public String getDescription() { + return getClass().getSimpleName(); } - private class AddRemoveSourceAction implements ViewAction { - - @Override - public Matcher getConstraints() { - return isDisplayed(); - } - - @Override - public String getDescription() { - return getClass().getSimpleName(); - } - - @Override - public void perform(UiController uiController, View view) { - MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); - - //Add initial source - mapboxMap.addSource(new VectorSource("my-source", "mapbox://mapbox.mapbox-terrain-v2")); - - //Remove - try { - mapboxMap.removeSource("my-source"); - } catch (NoSuchSourceException e) { - fail("Definitively exists: " + e.getMessage()); - } - assertNull(mapboxMap.getLayer("my-source")); - - //Add - Source source = new VectorSource("my-source", "mapbox://mapbox.mapbox-terrain-v2"); - mapboxMap.addSource(source); - - //Remove, preserving the reference - try { - mapboxMap.removeSource(source); - } catch (NoSuchSourceException e) { - fail("Definitively exists: " + e.getMessage()); - } - - //Re-add the reference... - mapboxMap.addSource(source); - - //Ensure it's there - Assert.assertNotNull(mapboxMap.getSource(source.getId())); - - //Test adding a duplicate source - try { - Source source2 = new VectorSource("my-source", "mapbox://mapbox.mapbox-terrain-v2"); - mapboxMap.addSource(source2); - fail("Should not have been allowed to add a source with a duplicate id"); - } catch (CannotAddSourceException e) { - //OK - } - } + @Override + public void perform(UiController uiController, View view) { + MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); + + //Add initial source + mapboxMap.addSource(new VectorSource("my-source", "mapbox://mapbox.mapbox-terrain-v2")); + + //Remove + try { + mapboxMap.removeSource("my-source"); + } catch (NoSuchSourceException noSuchSourceException) { + fail("Definitively exists: " + noSuchSourceException.getMessage()); + } + assertNull(mapboxMap.getLayer("my-source")); + + //Add + Source source = new VectorSource("my-source", "mapbox://mapbox.mapbox-terrain-v2"); + mapboxMap.addSource(source); + + //Remove, preserving the reference + try { + mapboxMap.removeSource(source); + } catch (NoSuchSourceException noSuchSourceException) { + fail("Definitively exists: " + noSuchSourceException.getMessage()); + } + + //Re-add the reference... + mapboxMap.addSource(source); + + //Ensure it's there + Assert.assertNotNull(mapboxMap.getSource(source.getId())); + + //Test adding a duplicate source + try { + Source source2 = new VectorSource("my-source", "mapbox://mapbox.mapbox-terrain-v2"); + mapboxMap.addSource(source2); + fail("Should not have been allowed to add a source with a duplicate id"); + } catch (CannotAddSourceException cannotAddSourceException) { + //OK + } } + } - @After - public void unregisterIntentServiceIdlingResource() { - Espresso.unregisterIdlingResources(idlingResource); - } + @After + public void unregisterIntentServiceIdlingResource() { + Espresso.unregisterIdlingResources(idlingResource); + } } diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/RuntimeStyleTimingTests.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/RuntimeStyleTimingTests.java index 0282e1bcd0..57b0fe72ff 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/RuntimeStyleTimingTests.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/RuntimeStyleTimingTests.java @@ -20,25 +20,26 @@ import org.junit.runner.RunWith; @RunWith(AndroidJUnit4.class) public class RuntimeStyleTimingTests extends BaseStyleTest { - @Rule - public final ActivityTestRule rule = new ActivityTestRule<>(RuntimeStyleTimingTestActivity.class); - - private OnMapReadyIdlingResource idlingResource; - - @Before - public void registerIdlingResource() { - idlingResource = new OnMapReadyIdlingResource(rule.getActivity()); - Espresso.registerIdlingResources(idlingResource); - } - - @Test - public void testGetAddRemoveLayer() { - checkViewIsDisplayed(R.id.mapView); - //We're good if it didn't crash - } - - @After - public void unregisterIntentServiceIdlingResource() { - Espresso.unregisterIdlingResources(idlingResource); - } + @Rule + public final ActivityTestRule rule = + new ActivityTestRule<>(RuntimeStyleTimingTestActivity.class); + + private OnMapReadyIdlingResource idlingResource; + + @Before + public void registerIdlingResource() { + idlingResource = new OnMapReadyIdlingResource(rule.getActivity()); + Espresso.registerIdlingResources(idlingResource); + } + + @Test + public void testGetAddRemoveLayer() { + checkViewIsDisplayed(R.id.mapView); + //We're good if it didn't crash + } + + @After + public void unregisterIntentServiceIdlingResource() { + Espresso.unregisterIdlingResources(idlingResource); + } } diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/SymbolLayerStyleTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/SymbolLayerStyleTest.java index 387e200645..5b59d4ceae 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/SymbolLayerStyleTest.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/SymbolLayerStyleTest.java @@ -1,11 +1,10 @@ -// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make style-code-android`. package com.mapbox.mapboxsdk.testapp.style; +// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make style-code-android`. import android.graphics.Color; import android.support.test.espresso.Espresso; import android.support.test.rule.ActivityTestRule; import android.support.test.runner.AndroidJUnit4; -import timber.log.Timber; import com.mapbox.mapboxsdk.maps.MapboxMap; import com.mapbox.mapboxsdk.style.layers.SymbolLayer; @@ -19,9 +18,71 @@ import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; -import static org.junit.Assert.*; -import static com.mapbox.mapboxsdk.style.layers.Property.*; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*; +import timber.log.Timber; + +import static com.mapbox.mapboxsdk.style.layers.Property.ICON_ROTATION_ALIGNMENT_MAP; +import static com.mapbox.mapboxsdk.style.layers.Property.ICON_TEXT_FIT_NONE; +import static com.mapbox.mapboxsdk.style.layers.Property.ICON_TRANSLATE_ANCHOR_MAP; +import static com.mapbox.mapboxsdk.style.layers.Property.NONE; +import static com.mapbox.mapboxsdk.style.layers.Property.SYMBOL_PLACEMENT_POINT; +import static com.mapbox.mapboxsdk.style.layers.Property.TEXT_ANCHOR_CENTER; +import static com.mapbox.mapboxsdk.style.layers.Property.TEXT_JUSTIFY_LEFT; +import static com.mapbox.mapboxsdk.style.layers.Property.TEXT_PITCH_ALIGNMENT_MAP; +import static com.mapbox.mapboxsdk.style.layers.Property.TEXT_ROTATION_ALIGNMENT_MAP; +import static com.mapbox.mapboxsdk.style.layers.Property.TEXT_TRANSFORM_NONE; +import static com.mapbox.mapboxsdk.style.layers.Property.TEXT_TRANSLATE_ANCHOR_MAP; +import static com.mapbox.mapboxsdk.style.layers.Property.VISIBLE; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconAllowOverlap; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconColor; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconHaloBlur; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconHaloColor; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconHaloWidth; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconIgnorePlacement; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconImage; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconKeepUpright; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconOffset; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconOpacity; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconOptional; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconPadding; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconRotate; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconRotationAlignment; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconSize; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconTextFit; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconTextFitPadding; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconTranslate; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconTranslateAnchor; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.symbolAvoidEdges; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.symbolPlacement; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.symbolSpacing; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textAllowOverlap; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textAnchor; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textColor; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textField; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textFont; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textHaloBlur; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textHaloColor; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textHaloWidth; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textIgnorePlacement; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textJustify; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textKeepUpright; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textLetterSpacing; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textLineHeight; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textMaxAngle; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textMaxWidth; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textOffset; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textOpacity; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textOptional; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textPadding; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textPitchAlignment; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textRotate; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textRotationAlignment; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textSize; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textTransform; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textTranslate; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textTranslateAnchor; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.visibility; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; /** * Basic smoke tests for SymbolLayer @@ -29,1193 +90,1194 @@ import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*; @RunWith(AndroidJUnit4.class) public class SymbolLayerStyleTest extends BaseStyleTest { - @Rule - public final ActivityTestRule rule = new ActivityTestRule<>(RuntimeStyleTestActivity.class); + @Rule + public final ActivityTestRule rule = new ActivityTestRule<>(RuntimeStyleTestActivity.class); - private SymbolLayer layer; + private SymbolLayer layer; - private OnMapReadyIdlingResource idlingResource; + private OnMapReadyIdlingResource idlingResource; - private MapboxMap mapboxMap; + private MapboxMap mapboxMap; - @Before - public void setup() { - idlingResource = new OnMapReadyIdlingResource(rule.getActivity()); - Espresso.registerIdlingResources(idlingResource); - } + @Before + public void setup() { + idlingResource = new OnMapReadyIdlingResource(rule.getActivity()); + Espresso.registerIdlingResources(idlingResource); + } - @Test - public void testSetVisibility() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("visibility"); - assertNotNull(layer); - - //Get initial - assertEquals(layer.getVisibility().getValue(), VISIBLE); - - //Set - layer.setProperties(visibility(NONE)); - assertEquals(layer.getVisibility().getValue(), NONE); - } + @Test + public void testSetVisibility() { + checkViewIsDisplayed(R.id.mapView); - @Test - public void testSymbolPlacement() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("symbol-placement"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(symbolPlacement(SYMBOL_PLACEMENT_POINT)); - assertEquals((String) layer.getSymbolPlacement().getValue(), (String) SYMBOL_PLACEMENT_POINT); - } + mapboxMap = rule.getActivity().getMapboxMap(); - @Test - public void testSymbolSpacing() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("symbol-spacing"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(symbolSpacing(0.3f)); - assertEquals((Float) layer.getSymbolSpacing().getValue(), (Float) 0.3f); + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new SymbolLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testSymbolAvoidEdges() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("symbol-avoid-edges"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(symbolAvoidEdges(true)); - assertEquals((Boolean) layer.getSymbolAvoidEdges().getValue(), (Boolean) true); + Timber.i("visibility"); + assertNotNull(layer); + + //Get initial + assertEquals(layer.getVisibility().getValue(), VISIBLE); + + //Set + layer.setProperties(visibility(NONE)); + assertEquals(layer.getVisibility().getValue(), NONE); + } + + @Test + public void testSymbolPlacement() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new SymbolLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testIconAllowOverlap() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("icon-allow-overlap"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(iconAllowOverlap(true)); - assertEquals((Boolean) layer.getIconAllowOverlap().getValue(), (Boolean) true); + Timber.i("symbol-placement"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(symbolPlacement(SYMBOL_PLACEMENT_POINT)); + assertEquals((String) layer.getSymbolPlacement().getValue(), (String) SYMBOL_PLACEMENT_POINT); + } + + @Test + public void testSymbolSpacing() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new SymbolLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testIconIgnorePlacement() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("icon-ignore-placement"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(iconIgnorePlacement(true)); - assertEquals((Boolean) layer.getIconIgnorePlacement().getValue(), (Boolean) true); + Timber.i("symbol-spacing"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(symbolSpacing(0.3f)); + assertEquals((Float) layer.getSymbolSpacing().getValue(), (Float) 0.3f); + } + + @Test + public void testSymbolAvoidEdges() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new SymbolLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testIconOptional() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("icon-optional"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(iconOptional(true)); - assertEquals((Boolean) layer.getIconOptional().getValue(), (Boolean) true); + Timber.i("symbol-avoid-edges"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(symbolAvoidEdges(true)); + assertEquals((Boolean) layer.getSymbolAvoidEdges().getValue(), (Boolean) true); + } + + @Test + public void testIconAllowOverlap() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new SymbolLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testIconRotationAlignment() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("icon-rotation-alignment"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(iconRotationAlignment(ICON_ROTATION_ALIGNMENT_MAP)); - assertEquals((String) layer.getIconRotationAlignment().getValue(), (String) ICON_ROTATION_ALIGNMENT_MAP); + Timber.i("icon-allow-overlap"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(iconAllowOverlap(true)); + assertEquals((Boolean) layer.getIconAllowOverlap().getValue(), (Boolean) true); + } + + @Test + public void testIconIgnorePlacement() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new SymbolLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testIconSize() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("icon-size"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(iconSize(0.3f)); - assertEquals((Float) layer.getIconSize().getValue(), (Float) 0.3f); + Timber.i("icon-ignore-placement"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(iconIgnorePlacement(true)); + assertEquals((Boolean) layer.getIconIgnorePlacement().getValue(), (Boolean) true); + } + + @Test + public void testIconOptional() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new SymbolLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testIconTextFit() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("icon-text-fit"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(iconTextFit(ICON_TEXT_FIT_NONE)); - assertEquals((String) layer.getIconTextFit().getValue(), (String) ICON_TEXT_FIT_NONE); + Timber.i("icon-optional"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(iconOptional(true)); + assertEquals((Boolean) layer.getIconOptional().getValue(), (Boolean) true); + } + + @Test + public void testIconRotationAlignment() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new SymbolLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testIconTextFitPadding() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("icon-text-fit-padding"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(iconTextFitPadding(new Float[]{0f,0f,0f,0f})); - assertEquals((Float[]) layer.getIconTextFitPadding().getValue(), (Float[]) new Float[]{0f,0f,0f,0f}); + Timber.i("icon-rotation-alignment"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(iconRotationAlignment(ICON_ROTATION_ALIGNMENT_MAP)); + assertEquals((String) layer.getIconRotationAlignment().getValue(), (String) ICON_ROTATION_ALIGNMENT_MAP); + } + + @Test + public void testIconSize() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new SymbolLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testIconImage() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("icon-image"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(iconImage("undefined")); - assertEquals((String) layer.getIconImage().getValue(), (String) "undefined"); + Timber.i("icon-size"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(iconSize(0.3f)); + assertEquals((Float) layer.getIconSize().getValue(), (Float) 0.3f); + } + + @Test + public void testIconTextFit() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new SymbolLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testIconRotate() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("icon-rotate"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(iconRotate(0.3f)); - assertEquals((Float) layer.getIconRotate().getValue(), (Float) 0.3f); + Timber.i("icon-text-fit"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(iconTextFit(ICON_TEXT_FIT_NONE)); + assertEquals((String) layer.getIconTextFit().getValue(), (String) ICON_TEXT_FIT_NONE); + } + + @Test + public void testIconTextFitPadding() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new SymbolLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testIconPadding() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("icon-padding"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(iconPadding(0.3f)); - assertEquals((Float) layer.getIconPadding().getValue(), (Float) 0.3f); + Timber.i("icon-text-fit-padding"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(iconTextFitPadding(new Float[] {0f, 0f, 0f, 0f})); + assertEquals((Float[]) layer.getIconTextFitPadding().getValue(), (Float[]) new Float[] {0f, 0f, 0f, 0f}); + } + + @Test + public void testIconImage() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new SymbolLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testIconKeepUpright() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("icon-keep-upright"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(iconKeepUpright(true)); - assertEquals((Boolean) layer.getIconKeepUpright().getValue(), (Boolean) true); + Timber.i("icon-image"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(iconImage("undefined")); + assertEquals((String) layer.getIconImage().getValue(), (String) "undefined"); + } + + @Test + public void testIconRotate() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new SymbolLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testIconOffset() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("icon-offset"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(iconOffset(new Float[]{0f,0f})); - assertEquals((Float[]) layer.getIconOffset().getValue(), (Float[]) new Float[]{0f,0f}); + Timber.i("icon-rotate"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(iconRotate(0.3f)); + assertEquals((Float) layer.getIconRotate().getValue(), (Float) 0.3f); + } + + @Test + public void testIconPadding() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new SymbolLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testTextPitchAlignment() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("text-pitch-alignment"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(textPitchAlignment(TEXT_PITCH_ALIGNMENT_MAP)); - assertEquals((String) layer.getTextPitchAlignment().getValue(), (String) TEXT_PITCH_ALIGNMENT_MAP); + Timber.i("icon-padding"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(iconPadding(0.3f)); + assertEquals((Float) layer.getIconPadding().getValue(), (Float) 0.3f); + } + + @Test + public void testIconKeepUpright() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new SymbolLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testTextRotationAlignment() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("text-rotation-alignment"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(textRotationAlignment(TEXT_ROTATION_ALIGNMENT_MAP)); - assertEquals((String) layer.getTextRotationAlignment().getValue(), (String) TEXT_ROTATION_ALIGNMENT_MAP); + Timber.i("icon-keep-upright"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(iconKeepUpright(true)); + assertEquals((Boolean) layer.getIconKeepUpright().getValue(), (Boolean) true); + } + + @Test + public void testIconOffset() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new SymbolLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testTextField() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("text-field"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(textField("")); - assertEquals((String) layer.getTextField().getValue(), (String) ""); + Timber.i("icon-offset"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(iconOffset(new Float[] {0f, 0f})); + assertEquals((Float[]) layer.getIconOffset().getValue(), (Float[]) new Float[] {0f, 0f}); + } + + @Test + public void testTextPitchAlignment() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new SymbolLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testTextFont() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("text-font"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(textFont(new String[]{"Open Sans Regular", "Arial Unicode MS Regular"})); - assertEquals((String[]) layer.getTextFont().getValue(), (String[]) new String[]{"Open Sans Regular", "Arial Unicode MS Regular"}); + Timber.i("text-pitch-alignment"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(textPitchAlignment(TEXT_PITCH_ALIGNMENT_MAP)); + assertEquals((String) layer.getTextPitchAlignment().getValue(), (String) TEXT_PITCH_ALIGNMENT_MAP); + } + + @Test + public void testTextRotationAlignment() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new SymbolLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testTextSize() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("text-size"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(textSize(0.3f)); - assertEquals((Float) layer.getTextSize().getValue(), (Float) 0.3f); + Timber.i("text-rotation-alignment"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(textRotationAlignment(TEXT_ROTATION_ALIGNMENT_MAP)); + assertEquals((String) layer.getTextRotationAlignment().getValue(), (String) TEXT_ROTATION_ALIGNMENT_MAP); + } + + @Test + public void testTextField() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new SymbolLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testTextMaxWidth() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("text-max-width"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(textMaxWidth(0.3f)); - assertEquals((Float) layer.getTextMaxWidth().getValue(), (Float) 0.3f); + Timber.i("text-field"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(textField("")); + assertEquals((String) layer.getTextField().getValue(), (String) ""); + } + + @Test + public void testTextFont() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new SymbolLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testTextLineHeight() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("text-line-height"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(textLineHeight(0.3f)); - assertEquals((Float) layer.getTextLineHeight().getValue(), (Float) 0.3f); + Timber.i("text-font"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(textFont(new String[] {"Open Sans Regular", "Arial Unicode MS Regular"})); + assertEquals((String[]) layer.getTextFont().getValue(), (String[]) new String[] {"Open Sans Regular", + "Arial Unicode MS Regular"}); + } + + @Test + public void testTextSize() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new SymbolLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testTextLetterSpacing() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("text-letter-spacing"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(textLetterSpacing(0.3f)); - assertEquals((Float) layer.getTextLetterSpacing().getValue(), (Float) 0.3f); + Timber.i("text-size"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(textSize(0.3f)); + assertEquals((Float) layer.getTextSize().getValue(), (Float) 0.3f); + } + + @Test + public void testTextMaxWidth() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new SymbolLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testTextJustify() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("text-justify"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(textJustify(TEXT_JUSTIFY_LEFT)); - assertEquals((String) layer.getTextJustify().getValue(), (String) TEXT_JUSTIFY_LEFT); + Timber.i("text-max-width"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(textMaxWidth(0.3f)); + assertEquals((Float) layer.getTextMaxWidth().getValue(), (Float) 0.3f); + } + + @Test + public void testTextLineHeight() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new SymbolLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testTextAnchor() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("text-anchor"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(textAnchor(TEXT_ANCHOR_CENTER)); - assertEquals((String) layer.getTextAnchor().getValue(), (String) TEXT_ANCHOR_CENTER); + Timber.i("text-line-height"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(textLineHeight(0.3f)); + assertEquals((Float) layer.getTextLineHeight().getValue(), (Float) 0.3f); + } + + @Test + public void testTextLetterSpacing() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new SymbolLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testTextMaxAngle() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("text-max-angle"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(textMaxAngle(0.3f)); - assertEquals((Float) layer.getTextMaxAngle().getValue(), (Float) 0.3f); + Timber.i("text-letter-spacing"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(textLetterSpacing(0.3f)); + assertEquals((Float) layer.getTextLetterSpacing().getValue(), (Float) 0.3f); + } + + @Test + public void testTextJustify() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new SymbolLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testTextRotate() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("text-rotate"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(textRotate(0.3f)); - assertEquals((Float) layer.getTextRotate().getValue(), (Float) 0.3f); + Timber.i("text-justify"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(textJustify(TEXT_JUSTIFY_LEFT)); + assertEquals((String) layer.getTextJustify().getValue(), (String) TEXT_JUSTIFY_LEFT); + } + + @Test + public void testTextAnchor() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new SymbolLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testTextPadding() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("text-padding"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(textPadding(0.3f)); - assertEquals((Float) layer.getTextPadding().getValue(), (Float) 0.3f); + Timber.i("text-anchor"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(textAnchor(TEXT_ANCHOR_CENTER)); + assertEquals((String) layer.getTextAnchor().getValue(), (String) TEXT_ANCHOR_CENTER); + } + + @Test + public void testTextMaxAngle() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new SymbolLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testTextKeepUpright() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("text-keep-upright"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(textKeepUpright(true)); - assertEquals((Boolean) layer.getTextKeepUpright().getValue(), (Boolean) true); + Timber.i("text-max-angle"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(textMaxAngle(0.3f)); + assertEquals((Float) layer.getTextMaxAngle().getValue(), (Float) 0.3f); + } + + @Test + public void testTextRotate() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new SymbolLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testTextTransform() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("text-transform"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(textTransform(TEXT_TRANSFORM_NONE)); - assertEquals((String) layer.getTextTransform().getValue(), (String) TEXT_TRANSFORM_NONE); + Timber.i("text-rotate"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(textRotate(0.3f)); + assertEquals((Float) layer.getTextRotate().getValue(), (Float) 0.3f); + } + + @Test + public void testTextPadding() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new SymbolLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testTextOffset() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("text-offset"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(textOffset(new Float[]{0f,0f})); - assertEquals((Float[]) layer.getTextOffset().getValue(), (Float[]) new Float[]{0f,0f}); + Timber.i("text-padding"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(textPadding(0.3f)); + assertEquals((Float) layer.getTextPadding().getValue(), (Float) 0.3f); + } + + @Test + public void testTextKeepUpright() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new SymbolLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testTextAllowOverlap() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("text-allow-overlap"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(textAllowOverlap(true)); - assertEquals((Boolean) layer.getTextAllowOverlap().getValue(), (Boolean) true); + Timber.i("text-keep-upright"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(textKeepUpright(true)); + assertEquals((Boolean) layer.getTextKeepUpright().getValue(), (Boolean) true); + } + + @Test + public void testTextTransform() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new SymbolLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testTextIgnorePlacement() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("text-ignore-placement"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(textIgnorePlacement(true)); - assertEquals((Boolean) layer.getTextIgnorePlacement().getValue(), (Boolean) true); + Timber.i("text-transform"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(textTransform(TEXT_TRANSFORM_NONE)); + assertEquals((String) layer.getTextTransform().getValue(), (String) TEXT_TRANSFORM_NONE); + } + + @Test + public void testTextOffset() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new SymbolLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testTextOptional() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("text-optional"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(textOptional(true)); - assertEquals((Boolean) layer.getTextOptional().getValue(), (Boolean) true); + Timber.i("text-offset"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(textOffset(new Float[] {0f, 0f})); + assertEquals((Float[]) layer.getTextOffset().getValue(), (Float[]) new Float[] {0f, 0f}); + } + + @Test + public void testTextAllowOverlap() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new SymbolLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testIconOpacity() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("icon-opacity"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(iconOpacity(0.3f)); - assertEquals((Float) layer.getIconOpacity().getValue(), (Float) 0.3f); + Timber.i("text-allow-overlap"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(textAllowOverlap(true)); + assertEquals((Boolean) layer.getTextAllowOverlap().getValue(), (Boolean) true); + } + + @Test + public void testTextIgnorePlacement() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new SymbolLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testIconColor() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("icon-color"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(iconColor("rgba(0, 0, 0, 1)")); - assertEquals((String) layer.getIconColor().getValue(), (String) "rgba(0, 0, 0, 1)"); + Timber.i("text-ignore-placement"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(textIgnorePlacement(true)); + assertEquals((Boolean) layer.getTextIgnorePlacement().getValue(), (Boolean) true); + } + + @Test + public void testTextOptional() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new SymbolLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testIconColorAsInt() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("icon-color"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(iconColor(Color.RED)); - assertEquals(layer.getIconColorAsInt(), Color.RED); + Timber.i("text-optional"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(textOptional(true)); + assertEquals((Boolean) layer.getTextOptional().getValue(), (Boolean) true); + } + + @Test + public void testIconOpacity() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new SymbolLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testIconHaloColor() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("icon-halo-color"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(iconHaloColor("rgba(0, 0, 0, 1)")); - assertEquals((String) layer.getIconHaloColor().getValue(), (String) "rgba(0, 0, 0, 1)"); + Timber.i("icon-opacity"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(iconOpacity(0.3f)); + assertEquals((Float) layer.getIconOpacity().getValue(), (Float) 0.3f); + } + + @Test + public void testIconColor() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new SymbolLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testIconHaloColorAsInt() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("icon-halo-color"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(iconHaloColor(Color.RED)); - assertEquals(layer.getIconHaloColorAsInt(), Color.RED); + Timber.i("icon-color"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(iconColor("rgba(0, 0, 0, 1)")); + assertEquals((String) layer.getIconColor().getValue(), (String) "rgba(0, 0, 0, 1)"); + } + + @Test + public void testIconColorAsInt() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new SymbolLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testIconHaloWidth() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("icon-halo-width"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(iconHaloWidth(0.3f)); - assertEquals((Float) layer.getIconHaloWidth().getValue(), (Float) 0.3f); + Timber.i("icon-color"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(iconColor(Color.RED)); + assertEquals(layer.getIconColorAsInt(), Color.RED); + } + + @Test + public void testIconHaloColor() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new SymbolLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testIconHaloBlur() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("icon-halo-blur"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(iconHaloBlur(0.3f)); - assertEquals((Float) layer.getIconHaloBlur().getValue(), (Float) 0.3f); + Timber.i("icon-halo-color"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(iconHaloColor("rgba(0, 0, 0, 1)")); + assertEquals((String) layer.getIconHaloColor().getValue(), (String) "rgba(0, 0, 0, 1)"); + } + + @Test + public void testIconHaloColorAsInt() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new SymbolLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testIconTranslate() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("icon-translate"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(iconTranslate(new Float[]{0f,0f})); - assertEquals((Float[]) layer.getIconTranslate().getValue(), (Float[]) new Float[]{0f,0f}); + Timber.i("icon-halo-color"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(iconHaloColor(Color.RED)); + assertEquals(layer.getIconHaloColorAsInt(), Color.RED); + } + + @Test + public void testIconHaloWidth() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new SymbolLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testIconTranslateAnchor() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("icon-translate-anchor"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(iconTranslateAnchor(ICON_TRANSLATE_ANCHOR_MAP)); - assertEquals((String) layer.getIconTranslateAnchor().getValue(), (String) ICON_TRANSLATE_ANCHOR_MAP); + Timber.i("icon-halo-width"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(iconHaloWidth(0.3f)); + assertEquals((Float) layer.getIconHaloWidth().getValue(), (Float) 0.3f); + } + + @Test + public void testIconHaloBlur() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new SymbolLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testTextOpacity() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("text-opacity"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(textOpacity(0.3f)); - assertEquals((Float) layer.getTextOpacity().getValue(), (Float) 0.3f); + Timber.i("icon-halo-blur"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(iconHaloBlur(0.3f)); + assertEquals((Float) layer.getIconHaloBlur().getValue(), (Float) 0.3f); + } + + @Test + public void testIconTranslate() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new SymbolLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testTextColor() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("text-color"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(textColor("rgba(0, 0, 0, 1)")); - assertEquals((String) layer.getTextColor().getValue(), (String) "rgba(0, 0, 0, 1)"); + Timber.i("icon-translate"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(iconTranslate(new Float[] {0f, 0f})); + assertEquals((Float[]) layer.getIconTranslate().getValue(), (Float[]) new Float[] {0f, 0f}); + } + + @Test + public void testIconTranslateAnchor() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new SymbolLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testTextColorAsInt() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("text-color"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(textColor(Color.RED)); - assertEquals(layer.getTextColorAsInt(), Color.RED); + Timber.i("icon-translate-anchor"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(iconTranslateAnchor(ICON_TRANSLATE_ANCHOR_MAP)); + assertEquals((String) layer.getIconTranslateAnchor().getValue(), (String) ICON_TRANSLATE_ANCHOR_MAP); + } + + @Test + public void testTextOpacity() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new SymbolLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testTextHaloColor() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("text-halo-color"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(textHaloColor("rgba(0, 0, 0, 1)")); - assertEquals((String) layer.getTextHaloColor().getValue(), (String) "rgba(0, 0, 0, 1)"); + Timber.i("text-opacity"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(textOpacity(0.3f)); + assertEquals((Float) layer.getTextOpacity().getValue(), (Float) 0.3f); + } + + @Test + public void testTextColor() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new SymbolLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testTextHaloColorAsInt() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("text-halo-color"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(textHaloColor(Color.RED)); - assertEquals(layer.getTextHaloColorAsInt(), Color.RED); + Timber.i("text-color"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(textColor("rgba(0, 0, 0, 1)")); + assertEquals((String) layer.getTextColor().getValue(), (String) "rgba(0, 0, 0, 1)"); + } + + @Test + public void testTextColorAsInt() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new SymbolLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testTextHaloWidth() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("text-halo-width"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(textHaloWidth(0.3f)); - assertEquals((Float) layer.getTextHaloWidth().getValue(), (Float) 0.3f); + Timber.i("text-color"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(textColor(Color.RED)); + assertEquals(layer.getTextColorAsInt(), Color.RED); + } + + @Test + public void testTextHaloColor() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new SymbolLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testTextHaloBlur() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("text-halo-blur"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(textHaloBlur(0.3f)); - assertEquals((Float) layer.getTextHaloBlur().getValue(), (Float) 0.3f); + Timber.i("text-halo-color"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(textHaloColor("rgba(0, 0, 0, 1)")); + assertEquals((String) layer.getTextHaloColor().getValue(), (String) "rgba(0, 0, 0, 1)"); + } + + @Test + public void testTextHaloColorAsInt() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new SymbolLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testTextTranslate() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("text-translate"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(textTranslate(new Float[]{0f,0f})); - assertEquals((Float[]) layer.getTextTranslate().getValue(), (Float[]) new Float[]{0f,0f}); + Timber.i("text-halo-color"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(textHaloColor(Color.RED)); + assertEquals(layer.getTextHaloColorAsInt(), Color.RED); + } + + @Test + public void testTextHaloWidth() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new SymbolLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testTextTranslateAnchor() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("text-translate-anchor"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(textTranslateAnchor(TEXT_TRANSLATE_ANCHOR_MAP)); - assertEquals((String) layer.getTextTranslateAnchor().getValue(), (String) TEXT_TRANSLATE_ANCHOR_MAP); + Timber.i("text-halo-width"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(textHaloWidth(0.3f)); + assertEquals((Float) layer.getTextHaloWidth().getValue(), (Float) 0.3f); + } + + @Test + public void testTextHaloBlur() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new SymbolLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } + Timber.i("text-halo-blur"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(textHaloBlur(0.3f)); + assertEquals((Float) layer.getTextHaloBlur().getValue(), (Float) 0.3f); + } + + @Test + public void testTextTranslate() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new SymbolLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); + } + Timber.i("text-translate"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(textTranslate(new Float[] {0f, 0f})); + assertEquals((Float[]) layer.getTextTranslate().getValue(), (Float[]) new Float[] {0f, 0f}); + } + + @Test + public void testTextTranslateAnchor() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new SymbolLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); + } + Timber.i("text-translate-anchor"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(textTranslateAnchor(TEXT_TRANSLATE_ANCHOR_MAP)); + assertEquals((String) layer.getTextTranslateAnchor().getValue(), (String) TEXT_TRANSLATE_ANCHOR_MAP); + } - @After - public void unregisterIntentServiceIdlingResource() { - Espresso.unregisterIdlingResources(idlingResource); - } + @After + public void unregisterIntentServiceIdlingResource() { + Espresso.unregisterIdlingResources(idlingResource); + } } diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/SymbolLayerTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/SymbolLayerTest.java index 81ea514bcd..f4c50a2ffb 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 @@ -1,11 +1,10 @@ -// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make android-style-code`. package com.mapbox.mapboxsdk.testapp.style; +// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make android-style-code`. import android.graphics.Color; import android.support.test.espresso.Espresso; import android.support.test.rule.ActivityTestRule; import android.support.test.runner.AndroidJUnit4; -import timber.log.Timber; import com.mapbox.mapboxsdk.maps.MapboxMap; import com.mapbox.mapboxsdk.style.layers.SymbolLayer; @@ -19,9 +18,71 @@ import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; -import static org.junit.Assert.*; -import static com.mapbox.mapboxsdk.style.layers.Property.*; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*; +import timber.log.Timber; + +import static com.mapbox.mapboxsdk.style.layers.Property.ICON_ROTATION_ALIGNMENT_MAP; +import static com.mapbox.mapboxsdk.style.layers.Property.ICON_TEXT_FIT_NONE; +import static com.mapbox.mapboxsdk.style.layers.Property.ICON_TRANSLATE_ANCHOR_MAP; +import static com.mapbox.mapboxsdk.style.layers.Property.NONE; +import static com.mapbox.mapboxsdk.style.layers.Property.SYMBOL_PLACEMENT_POINT; +import static com.mapbox.mapboxsdk.style.layers.Property.TEXT_ANCHOR_CENTER; +import static com.mapbox.mapboxsdk.style.layers.Property.TEXT_JUSTIFY_LEFT; +import static com.mapbox.mapboxsdk.style.layers.Property.TEXT_PITCH_ALIGNMENT_MAP; +import static com.mapbox.mapboxsdk.style.layers.Property.TEXT_ROTATION_ALIGNMENT_MAP; +import static com.mapbox.mapboxsdk.style.layers.Property.TEXT_TRANSFORM_NONE; +import static com.mapbox.mapboxsdk.style.layers.Property.TEXT_TRANSLATE_ANCHOR_MAP; +import static com.mapbox.mapboxsdk.style.layers.Property.VISIBLE; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconAllowOverlap; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconColor; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconHaloBlur; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconHaloColor; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconHaloWidth; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconIgnorePlacement; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconImage; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconKeepUpright; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconOffset; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconOpacity; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconOptional; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconPadding; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconRotate; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconRotationAlignment; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconSize; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconTextFit; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconTextFitPadding; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconTranslate; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconTranslateAnchor; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.symbolAvoidEdges; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.symbolPlacement; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.symbolSpacing; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textAllowOverlap; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textAnchor; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textColor; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textField; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textFont; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textHaloBlur; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textHaloColor; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textHaloWidth; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textIgnorePlacement; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textJustify; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textKeepUpright; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textLetterSpacing; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textLineHeight; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textMaxAngle; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textMaxWidth; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textOffset; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textOpacity; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textOptional; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textPadding; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textPitchAlignment; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textRotate; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textRotationAlignment; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textSize; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textTransform; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textTranslate; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textTranslateAnchor; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.visibility; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; /** * Basic smoke tests for SymbolLayer @@ -29,1193 +90,1194 @@ import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*; @RunWith(AndroidJUnit4.class) public class SymbolLayerTest extends BaseStyleTest { - @Rule - public final ActivityTestRule rule = new ActivityTestRule<>(RuntimeStyleTestActivity.class); + @Rule + public final ActivityTestRule rule = new ActivityTestRule<>(RuntimeStyleTestActivity.class); - private SymbolLayer layer; + private SymbolLayer layer; - private OnMapReadyIdlingResource idlingResource; + private OnMapReadyIdlingResource idlingResource; - private MapboxMap mapboxMap; + private MapboxMap mapboxMap; - @Before - public void setup() { - idlingResource = new OnMapReadyIdlingResource(rule.getActivity()); - Espresso.registerIdlingResources(idlingResource); - } + @Before + public void setup() { + idlingResource = new OnMapReadyIdlingResource(rule.getActivity()); + Espresso.registerIdlingResources(idlingResource); + } - @Test - public void testSetVisibility() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("visibility"); - assertNotNull(layer); - - //Get initial - assertEquals(layer.getVisibility().getValue(), VISIBLE); - - //Set - layer.setProperties(visibility(NONE)); - assertEquals(layer.getVisibility().getValue(), NONE); - } + @Test + public void testSetVisibility() { + checkViewIsDisplayed(R.id.mapView); - @Test - public void testSymbolPlacement() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("symbol-placement"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(symbolPlacement(SYMBOL_PLACEMENT_POINT)); - assertEquals((String) layer.getSymbolPlacement().getValue(), (String) SYMBOL_PLACEMENT_POINT); - } + mapboxMap = rule.getActivity().getMapboxMap(); - @Test - public void testSymbolSpacing() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("symbol-spacing"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(symbolSpacing(0.3f)); - assertEquals((Float) layer.getSymbolSpacing().getValue(), (Float) 0.3f); + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new SymbolLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testSymbolAvoidEdges() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("symbol-avoid-edges"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(symbolAvoidEdges(true)); - assertEquals((Boolean) layer.getSymbolAvoidEdges().getValue(), (Boolean) true); + Timber.i("visibility"); + assertNotNull(layer); + + //Get initial + assertEquals(layer.getVisibility().getValue(), VISIBLE); + + //Set + layer.setProperties(visibility(NONE)); + assertEquals(layer.getVisibility().getValue(), NONE); + } + + @Test + public void testSymbolPlacement() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new SymbolLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testIconAllowOverlap() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("icon-allow-overlap"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(iconAllowOverlap(true)); - assertEquals((Boolean) layer.getIconAllowOverlap().getValue(), (Boolean) true); + Timber.i("symbol-placement"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(symbolPlacement(SYMBOL_PLACEMENT_POINT)); + assertEquals((String) layer.getSymbolPlacement().getValue(), (String) SYMBOL_PLACEMENT_POINT); + } + + @Test + public void testSymbolSpacing() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new SymbolLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testIconIgnorePlacement() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("icon-ignore-placement"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(iconIgnorePlacement(true)); - assertEquals((Boolean) layer.getIconIgnorePlacement().getValue(), (Boolean) true); + Timber.i("symbol-spacing"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(symbolSpacing(0.3f)); + assertEquals((Float) layer.getSymbolSpacing().getValue(), (Float) 0.3f); + } + + @Test + public void testSymbolAvoidEdges() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new SymbolLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testIconOptional() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("icon-optional"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(iconOptional(true)); - assertEquals((Boolean) layer.getIconOptional().getValue(), (Boolean) true); + Timber.i("symbol-avoid-edges"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(symbolAvoidEdges(true)); + assertEquals((Boolean) layer.getSymbolAvoidEdges().getValue(), (Boolean) true); + } + + @Test + public void testIconAllowOverlap() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new SymbolLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testIconRotationAlignment() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("icon-rotation-alignment"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(iconRotationAlignment(ICON_ROTATION_ALIGNMENT_MAP)); - assertEquals((String) layer.getIconRotationAlignment().getValue(), (String) ICON_ROTATION_ALIGNMENT_MAP); + Timber.i("icon-allow-overlap"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(iconAllowOverlap(true)); + assertEquals((Boolean) layer.getIconAllowOverlap().getValue(), (Boolean) true); + } + + @Test + public void testIconIgnorePlacement() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new SymbolLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testIconSize() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("icon-size"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(iconSize(0.3f)); - assertEquals((Float) layer.getIconSize().getValue(), (Float) 0.3f); + Timber.i("icon-ignore-placement"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(iconIgnorePlacement(true)); + assertEquals((Boolean) layer.getIconIgnorePlacement().getValue(), (Boolean) true); + } + + @Test + public void testIconOptional() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new SymbolLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testIconTextFit() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("icon-text-fit"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(iconTextFit(ICON_TEXT_FIT_NONE)); - assertEquals((String) layer.getIconTextFit().getValue(), (String) ICON_TEXT_FIT_NONE); + Timber.i("icon-optional"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(iconOptional(true)); + assertEquals((Boolean) layer.getIconOptional().getValue(), (Boolean) true); + } + + @Test + public void testIconRotationAlignment() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new SymbolLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testIconTextFitPadding() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("icon-text-fit-padding"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(iconTextFitPadding(new Float[]{0f,0f,0f,0f})); - assertEquals((Float[]) layer.getIconTextFitPadding().getValue(), (Float[]) new Float[]{0f,0f,0f,0f}); + Timber.i("icon-rotation-alignment"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(iconRotationAlignment(ICON_ROTATION_ALIGNMENT_MAP)); + assertEquals((String) layer.getIconRotationAlignment().getValue(), (String) ICON_ROTATION_ALIGNMENT_MAP); + } + + @Test + public void testIconSize() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new SymbolLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testIconImage() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("icon-image"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(iconImage("undefined")); - assertEquals((String) layer.getIconImage().getValue(), (String) "undefined"); + Timber.i("icon-size"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(iconSize(0.3f)); + assertEquals((Float) layer.getIconSize().getValue(), (Float) 0.3f); + } + + @Test + public void testIconTextFit() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new SymbolLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testIconRotate() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("icon-rotate"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(iconRotate(0.3f)); - assertEquals((Float) layer.getIconRotate().getValue(), (Float) 0.3f); + Timber.i("icon-text-fit"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(iconTextFit(ICON_TEXT_FIT_NONE)); + assertEquals((String) layer.getIconTextFit().getValue(), (String) ICON_TEXT_FIT_NONE); + } + + @Test + public void testIconTextFitPadding() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new SymbolLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testIconPadding() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("icon-padding"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(iconPadding(0.3f)); - assertEquals((Float) layer.getIconPadding().getValue(), (Float) 0.3f); + Timber.i("icon-text-fit-padding"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(iconTextFitPadding(new Float[] {0f, 0f, 0f, 0f})); + assertEquals((Float[]) layer.getIconTextFitPadding().getValue(), (Float[]) new Float[] {0f, 0f, 0f, 0f}); + } + + @Test + public void testIconImage() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new SymbolLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testIconKeepUpright() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("icon-keep-upright"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(iconKeepUpright(true)); - assertEquals((Boolean) layer.getIconKeepUpright().getValue(), (Boolean) true); + Timber.i("icon-image"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(iconImage("undefined")); + assertEquals((String) layer.getIconImage().getValue(), (String) "undefined"); + } + + @Test + public void testIconRotate() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new SymbolLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testIconOffset() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("icon-offset"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(iconOffset(new Float[]{0f,0f})); - assertEquals((Float[]) layer.getIconOffset().getValue(), (Float[]) new Float[]{0f,0f}); + Timber.i("icon-rotate"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(iconRotate(0.3f)); + assertEquals((Float) layer.getIconRotate().getValue(), (Float) 0.3f); + } + + @Test + public void testIconPadding() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new SymbolLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testTextPitchAlignment() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("text-pitch-alignment"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(textPitchAlignment(TEXT_PITCH_ALIGNMENT_MAP)); - assertEquals((String) layer.getTextPitchAlignment().getValue(), (String) TEXT_PITCH_ALIGNMENT_MAP); + Timber.i("icon-padding"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(iconPadding(0.3f)); + assertEquals((Float) layer.getIconPadding().getValue(), (Float) 0.3f); + } + + @Test + public void testIconKeepUpright() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new SymbolLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testTextRotationAlignment() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("text-rotation-alignment"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(textRotationAlignment(TEXT_ROTATION_ALIGNMENT_MAP)); - assertEquals((String) layer.getTextRotationAlignment().getValue(), (String) TEXT_ROTATION_ALIGNMENT_MAP); + Timber.i("icon-keep-upright"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(iconKeepUpright(true)); + assertEquals((Boolean) layer.getIconKeepUpright().getValue(), (Boolean) true); + } + + @Test + public void testIconOffset() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new SymbolLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testTextField() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("text-field"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(textField("")); - assertEquals((String) layer.getTextField().getValue(), (String) ""); + Timber.i("icon-offset"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(iconOffset(new Float[] {0f, 0f})); + assertEquals((Float[]) layer.getIconOffset().getValue(), (Float[]) new Float[] {0f, 0f}); + } + + @Test + public void testTextPitchAlignment() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new SymbolLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testTextFont() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("text-font"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(textFont(new String[]{"Open Sans Regular", "Arial Unicode MS Regular"})); - assertEquals((String[]) layer.getTextFont().getValue(), (String[]) new String[]{"Open Sans Regular", "Arial Unicode MS Regular"}); + Timber.i("text-pitch-alignment"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(textPitchAlignment(TEXT_PITCH_ALIGNMENT_MAP)); + assertEquals((String) layer.getTextPitchAlignment().getValue(), (String) TEXT_PITCH_ALIGNMENT_MAP); + } + + @Test + public void testTextRotationAlignment() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new SymbolLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testTextSize() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("text-size"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(textSize(0.3f)); - assertEquals((Float) layer.getTextSize().getValue(), (Float) 0.3f); + Timber.i("text-rotation-alignment"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(textRotationAlignment(TEXT_ROTATION_ALIGNMENT_MAP)); + assertEquals((String) layer.getTextRotationAlignment().getValue(), (String) TEXT_ROTATION_ALIGNMENT_MAP); + } + + @Test + public void testTextField() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new SymbolLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testTextMaxWidth() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("text-max-width"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(textMaxWidth(0.3f)); - assertEquals((Float) layer.getTextMaxWidth().getValue(), (Float) 0.3f); + Timber.i("text-field"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(textField("")); + assertEquals((String) layer.getTextField().getValue(), (String) ""); + } + + @Test + public void testTextFont() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new SymbolLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testTextLineHeight() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("text-line-height"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(textLineHeight(0.3f)); - assertEquals((Float) layer.getTextLineHeight().getValue(), (Float) 0.3f); + Timber.i("text-font"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(textFont(new String[] {"Open Sans Regular", "Arial Unicode MS Regular"})); + assertEquals((String[]) layer.getTextFont().getValue(), (String[]) new String[] {"Open Sans Regular", + "Arial Unicode MS Regular"}); + } + + @Test + public void testTextSize() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new SymbolLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testTextLetterSpacing() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("text-letter-spacing"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(textLetterSpacing(0.3f)); - assertEquals((Float) layer.getTextLetterSpacing().getValue(), (Float) 0.3f); + Timber.i("text-size"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(textSize(0.3f)); + assertEquals((Float) layer.getTextSize().getValue(), (Float) 0.3f); + } + + @Test + public void testTextMaxWidth() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new SymbolLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testTextJustify() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("text-justify"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(textJustify(TEXT_JUSTIFY_LEFT)); - assertEquals((String) layer.getTextJustify().getValue(), (String) TEXT_JUSTIFY_LEFT); + Timber.i("text-max-width"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(textMaxWidth(0.3f)); + assertEquals((Float) layer.getTextMaxWidth().getValue(), (Float) 0.3f); + } + + @Test + public void testTextLineHeight() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new SymbolLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testTextAnchor() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("text-anchor"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(textAnchor(TEXT_ANCHOR_CENTER)); - assertEquals((String) layer.getTextAnchor().getValue(), (String) TEXT_ANCHOR_CENTER); + Timber.i("text-line-height"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(textLineHeight(0.3f)); + assertEquals((Float) layer.getTextLineHeight().getValue(), (Float) 0.3f); + } + + @Test + public void testTextLetterSpacing() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new SymbolLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testTextMaxAngle() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("text-max-angle"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(textMaxAngle(0.3f)); - assertEquals((Float) layer.getTextMaxAngle().getValue(), (Float) 0.3f); + Timber.i("text-letter-spacing"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(textLetterSpacing(0.3f)); + assertEquals((Float) layer.getTextLetterSpacing().getValue(), (Float) 0.3f); + } + + @Test + public void testTextJustify() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new SymbolLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testTextRotate() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("text-rotate"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(textRotate(0.3f)); - assertEquals((Float) layer.getTextRotate().getValue(), (Float) 0.3f); + Timber.i("text-justify"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(textJustify(TEXT_JUSTIFY_LEFT)); + assertEquals((String) layer.getTextJustify().getValue(), (String) TEXT_JUSTIFY_LEFT); + } + + @Test + public void testTextAnchor() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new SymbolLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testTextPadding() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("text-padding"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(textPadding(0.3f)); - assertEquals((Float) layer.getTextPadding().getValue(), (Float) 0.3f); + Timber.i("text-anchor"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(textAnchor(TEXT_ANCHOR_CENTER)); + assertEquals((String) layer.getTextAnchor().getValue(), (String) TEXT_ANCHOR_CENTER); + } + + @Test + public void testTextMaxAngle() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new SymbolLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testTextKeepUpright() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("text-keep-upright"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(textKeepUpright(true)); - assertEquals((Boolean) layer.getTextKeepUpright().getValue(), (Boolean) true); + Timber.i("text-max-angle"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(textMaxAngle(0.3f)); + assertEquals((Float) layer.getTextMaxAngle().getValue(), (Float) 0.3f); + } + + @Test + public void testTextRotate() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new SymbolLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testTextTransform() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("text-transform"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(textTransform(TEXT_TRANSFORM_NONE)); - assertEquals((String) layer.getTextTransform().getValue(), (String) TEXT_TRANSFORM_NONE); + Timber.i("text-rotate"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(textRotate(0.3f)); + assertEquals((Float) layer.getTextRotate().getValue(), (Float) 0.3f); + } + + @Test + public void testTextPadding() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new SymbolLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testTextOffset() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("text-offset"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(textOffset(new Float[]{0f,0f})); - assertEquals((Float[]) layer.getTextOffset().getValue(), (Float[]) new Float[]{0f,0f}); + Timber.i("text-padding"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(textPadding(0.3f)); + assertEquals((Float) layer.getTextPadding().getValue(), (Float) 0.3f); + } + + @Test + public void testTextKeepUpright() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new SymbolLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testTextAllowOverlap() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("text-allow-overlap"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(textAllowOverlap(true)); - assertEquals((Boolean) layer.getTextAllowOverlap().getValue(), (Boolean) true); + Timber.i("text-keep-upright"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(textKeepUpright(true)); + assertEquals((Boolean) layer.getTextKeepUpright().getValue(), (Boolean) true); + } + + @Test + public void testTextTransform() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new SymbolLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testTextIgnorePlacement() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("text-ignore-placement"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(textIgnorePlacement(true)); - assertEquals((Boolean) layer.getTextIgnorePlacement().getValue(), (Boolean) true); + Timber.i("text-transform"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(textTransform(TEXT_TRANSFORM_NONE)); + assertEquals((String) layer.getTextTransform().getValue(), (String) TEXT_TRANSFORM_NONE); + } + + @Test + public void testTextOffset() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new SymbolLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testTextOptional() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("text-optional"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(textOptional(true)); - assertEquals((Boolean) layer.getTextOptional().getValue(), (Boolean) true); + Timber.i("text-offset"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(textOffset(new Float[] {0f, 0f})); + assertEquals((Float[]) layer.getTextOffset().getValue(), (Float[]) new Float[] {0f, 0f}); + } + + @Test + public void testTextAllowOverlap() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new SymbolLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testIconOpacity() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("icon-opacity"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(iconOpacity(0.3f)); - assertEquals((Float) layer.getIconOpacity().getValue(), (Float) 0.3f); + Timber.i("text-allow-overlap"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(textAllowOverlap(true)); + assertEquals((Boolean) layer.getTextAllowOverlap().getValue(), (Boolean) true); + } + + @Test + public void testTextIgnorePlacement() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new SymbolLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testIconColor() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("icon-color"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(iconColor("rgba(0, 0, 0, 1)")); - assertEquals((String) layer.getIconColor().getValue(), (String) "rgba(0, 0, 0, 1)"); + Timber.i("text-ignore-placement"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(textIgnorePlacement(true)); + assertEquals((Boolean) layer.getTextIgnorePlacement().getValue(), (Boolean) true); + } + + @Test + public void testTextOptional() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new SymbolLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testIconColorAsInt() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("icon-color"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(iconColor(Color.RED)); - assertEquals(layer.getIconColorAsInt(), Color.RED); + Timber.i("text-optional"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(textOptional(true)); + assertEquals((Boolean) layer.getTextOptional().getValue(), (Boolean) true); + } + + @Test + public void testIconOpacity() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new SymbolLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testIconHaloColor() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("icon-halo-color"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(iconHaloColor("rgba(0, 0, 0, 1)")); - assertEquals((String) layer.getIconHaloColor().getValue(), (String) "rgba(0, 0, 0, 1)"); + Timber.i("icon-opacity"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(iconOpacity(0.3f)); + assertEquals((Float) layer.getIconOpacity().getValue(), (Float) 0.3f); + } + + @Test + public void testIconColor() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new SymbolLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testIconHaloColorAsInt() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("icon-halo-color"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(iconHaloColor(Color.RED)); - assertEquals(layer.getIconHaloColorAsInt(), Color.RED); + Timber.i("icon-color"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(iconColor("rgba(0, 0, 0, 1)")); + assertEquals((String) layer.getIconColor().getValue(), (String) "rgba(0, 0, 0, 1)"); + } + + @Test + public void testIconColorAsInt() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new SymbolLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testIconHaloWidth() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("icon-halo-width"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(iconHaloWidth(0.3f)); - assertEquals((Float) layer.getIconHaloWidth().getValue(), (Float) 0.3f); + Timber.i("icon-color"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(iconColor(Color.RED)); + assertEquals(layer.getIconColorAsInt(), Color.RED); + } + + @Test + public void testIconHaloColor() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new SymbolLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testIconHaloBlur() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("icon-halo-blur"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(iconHaloBlur(0.3f)); - assertEquals((Float) layer.getIconHaloBlur().getValue(), (Float) 0.3f); + Timber.i("icon-halo-color"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(iconHaloColor("rgba(0, 0, 0, 1)")); + assertEquals((String) layer.getIconHaloColor().getValue(), (String) "rgba(0, 0, 0, 1)"); + } + + @Test + public void testIconHaloColorAsInt() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new SymbolLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testIconTranslate() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("icon-translate"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(iconTranslate(new Float[]{0f,0f})); - assertEquals((Float[]) layer.getIconTranslate().getValue(), (Float[]) new Float[]{0f,0f}); + Timber.i("icon-halo-color"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(iconHaloColor(Color.RED)); + assertEquals(layer.getIconHaloColorAsInt(), Color.RED); + } + + @Test + public void testIconHaloWidth() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new SymbolLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testIconTranslateAnchor() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("icon-translate-anchor"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(iconTranslateAnchor(ICON_TRANSLATE_ANCHOR_MAP)); - assertEquals((String) layer.getIconTranslateAnchor().getValue(), (String) ICON_TRANSLATE_ANCHOR_MAP); + Timber.i("icon-halo-width"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(iconHaloWidth(0.3f)); + assertEquals((Float) layer.getIconHaloWidth().getValue(), (Float) 0.3f); + } + + @Test + public void testIconHaloBlur() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new SymbolLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testTextOpacity() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("text-opacity"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(textOpacity(0.3f)); - assertEquals((Float) layer.getTextOpacity().getValue(), (Float) 0.3f); + Timber.i("icon-halo-blur"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(iconHaloBlur(0.3f)); + assertEquals((Float) layer.getIconHaloBlur().getValue(), (Float) 0.3f); + } + + @Test + public void testIconTranslate() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new SymbolLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testTextColor() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("text-color"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(textColor("rgba(0, 0, 0, 1)")); - assertEquals((String) layer.getTextColor().getValue(), (String) "rgba(0, 0, 0, 1)"); + Timber.i("icon-translate"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(iconTranslate(new Float[] {0f, 0f})); + assertEquals((Float[]) layer.getIconTranslate().getValue(), (Float[]) new Float[] {0f, 0f}); + } + + @Test + public void testIconTranslateAnchor() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new SymbolLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testTextColorAsInt() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("text-color"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(textColor(Color.RED)); - assertEquals(layer.getTextColorAsInt(), Color.RED); + Timber.i("icon-translate-anchor"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(iconTranslateAnchor(ICON_TRANSLATE_ANCHOR_MAP)); + assertEquals((String) layer.getIconTranslateAnchor().getValue(), (String) ICON_TRANSLATE_ANCHOR_MAP); + } + + @Test + public void testTextOpacity() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new SymbolLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testTextHaloColor() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("text-halo-color"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(textHaloColor("rgba(0, 0, 0, 1)")); - assertEquals((String) layer.getTextHaloColor().getValue(), (String) "rgba(0, 0, 0, 1)"); + Timber.i("text-opacity"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(textOpacity(0.3f)); + assertEquals((Float) layer.getTextOpacity().getValue(), (Float) 0.3f); + } + + @Test + public void testTextColor() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new SymbolLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testTextHaloColorAsInt() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("text-halo-color"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(textHaloColor(Color.RED)); - assertEquals(layer.getTextHaloColorAsInt(), Color.RED); + Timber.i("text-color"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(textColor("rgba(0, 0, 0, 1)")); + assertEquals((String) layer.getTextColor().getValue(), (String) "rgba(0, 0, 0, 1)"); + } + + @Test + public void testTextColorAsInt() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new SymbolLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testTextHaloWidth() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("text-halo-width"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(textHaloWidth(0.3f)); - assertEquals((Float) layer.getTextHaloWidth().getValue(), (Float) 0.3f); + Timber.i("text-color"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(textColor(Color.RED)); + assertEquals(layer.getTextColorAsInt(), Color.RED); + } + + @Test + public void testTextHaloColor() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new SymbolLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testTextHaloBlur() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("text-halo-blur"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(textHaloBlur(0.3f)); - assertEquals((Float) layer.getTextHaloBlur().getValue(), (Float) 0.3f); + Timber.i("text-halo-color"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(textHaloColor("rgba(0, 0, 0, 1)")); + assertEquals((String) layer.getTextHaloColor().getValue(), (String) "rgba(0, 0, 0, 1)"); + } + + @Test + public void testTextHaloColorAsInt() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new SymbolLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testTextTranslate() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("text-translate"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(textTranslate(new Float[]{0f,0f})); - assertEquals((Float[]) layer.getTextTranslate().getValue(), (Float[]) new Float[]{0f,0f}); + Timber.i("text-halo-color"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(textHaloColor(Color.RED)); + assertEquals(layer.getTextHaloColorAsInt(), Color.RED); + } + + @Test + public void testTextHaloWidth() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new SymbolLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } - - @Test - public void testTextTranslateAnchor() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("text-translate-anchor"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(textTranslateAnchor(TEXT_TRANSLATE_ANCHOR_MAP)); - assertEquals((String) layer.getTextTranslateAnchor().getValue(), (String) TEXT_TRANSLATE_ANCHOR_MAP); + Timber.i("text-halo-width"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(textHaloWidth(0.3f)); + assertEquals((Float) layer.getTextHaloWidth().getValue(), (Float) 0.3f); + } + + @Test + public void testTextHaloBlur() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new SymbolLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); } + Timber.i("text-halo-blur"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(textHaloBlur(0.3f)); + assertEquals((Float) layer.getTextHaloBlur().getValue(), (Float) 0.3f); + } + + @Test + public void testTextTranslate() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new SymbolLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); + } + Timber.i("text-translate"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(textTranslate(new Float[] {0f, 0f})); + assertEquals((Float[]) layer.getTextTranslate().getValue(), (Float[]) new Float[] {0f, 0f}); + } + + @Test + public void testTextTranslateAnchor() { + checkViewIsDisplayed(R.id.mapView); + + mapboxMap = rule.getActivity().getMapboxMap(); + + if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { + Timber.i("Adding layer"); + layer = new SymbolLayer("my-layer", "composite"); + layer.setSourceLayer("composite"); + mapboxMap.addLayer(layer); + //Layer reference is now stale, get new reference + layer = mapboxMap.getLayerAs("my-layer"); + } + Timber.i("text-translate-anchor"); + assertNotNull(layer); + + //Set and Get + layer.setProperties(textTranslateAnchor(TEXT_TRANSLATE_ANCHOR_MAP)); + assertEquals((String) layer.getTextTranslateAnchor().getValue(), (String) TEXT_TRANSLATE_ANCHOR_MAP); + } - @After - public void unregisterIntentServiceIdlingResource() { - Espresso.unregisterIdlingResources(idlingResource); - } + @After + public void unregisterIntentServiceIdlingResource() { + Espresso.unregisterIdlingResources(idlingResource); + } } diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/utils/DrawerUtils.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/utils/DrawerUtils.java index 8d8905fdf4..d9ced47369 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/utils/DrawerUtils.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/utils/DrawerUtils.java @@ -15,15 +15,15 @@ import static android.support.test.espresso.matcher.ViewMatchers.withContentDesc public class DrawerUtils { - private final static String HOME_BUTTON_STRING = "Navigate up"; + private static final String HOME_BUTTON_STRING = "Navigate up"; - public static void openDrawer(){ - onView(withContentDescription(HOME_BUTTON_STRING)).perform(click()); - } + public static void openDrawer() { + onView(withContentDescription(HOME_BUTTON_STRING)).perform(click()); + } - public static void clickItem(@StringRes int txtId){ - Espresso.onView(Matchers.allOf(ViewMatchers.withId(R.id.design_menu_item_text), - ViewMatchers.hasSibling(ViewMatchers.withText(txtId)))).perform(ViewActions.click()); - } + public static void clickItem(@StringRes int txtId) { + Espresso.onView(Matchers.allOf(ViewMatchers.withId(R.id.design_menu_item_text), + ViewMatchers.hasSibling(ViewMatchers.withText(txtId)))).perform(ViewActions.click()); + } } diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/utils/GestureUtils.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/utils/GestureUtils.java index 114fbc549e..3376f5eda4 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/utils/GestureUtils.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/utils/GestureUtils.java @@ -8,8 +8,8 @@ import static android.support.test.espresso.matcher.ViewMatchers.withId; public class GestureUtils { - public static void doubleClickGesture(@IdRes int id){ - onView(withId(id)).perform(doubleClick()); - } + public static void doubleClickGesture(@IdRes int id) { + onView(withId(id)).perform(doubleClick()); + } } diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/utils/OnMapReadyIdlingResource.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/utils/OnMapReadyIdlingResource.java index f00c76132c..6e582c6a3a 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/utils/OnMapReadyIdlingResource.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/utils/OnMapReadyIdlingResource.java @@ -2,6 +2,7 @@ package com.mapbox.mapboxsdk.testapp.utils; import android.app.Activity; import android.support.test.espresso.IdlingResource; + import timber.log.Timber; import com.mapbox.mapboxsdk.maps.MapboxMap; @@ -10,47 +11,47 @@ import java.lang.reflect.Field; public class OnMapReadyIdlingResource implements IdlingResource { - private final Activity activity; - private MapboxMap mapboxMap; - private IdlingResource.ResourceCallback resourceCallback; + private final Activity activity; + private MapboxMap mapboxMap; + private IdlingResource.ResourceCallback resourceCallback; - public OnMapReadyIdlingResource(Activity activity) { - this.activity = activity; - } + public OnMapReadyIdlingResource(Activity activity) { + this.activity = activity; + } - @Override - public String getName() { - return getClass().getSimpleName(); - } + @Override + public String getName() { + return getClass().getSimpleName(); + } - @Override - public boolean isIdleNow() { - boolean idle = isMapboxMapReady(); - if (idle && resourceCallback != null) { - resourceCallback.onTransitionToIdle(); - } - return idle; + @Override + public boolean isIdleNow() { + boolean idle = isMapboxMapReady(); + if (idle && resourceCallback != null) { + resourceCallback.onTransitionToIdle(); } - - @Override - public void registerIdleTransitionCallback(ResourceCallback resourceCallback) { - this.resourceCallback = resourceCallback; + return idle; + } + + @Override + public void registerIdleTransitionCallback(ResourceCallback resourceCallback) { + this.resourceCallback = resourceCallback; + } + + private boolean isMapboxMapReady() { + try { + Field field = activity.getClass().getDeclaredField("mapboxMap"); + field.setAccessible(true); + mapboxMap = (MapboxMap) field.get(activity); + Timber.e("isMapboxReady called with value " + (mapboxMap != null)); + return mapboxMap != null; + } catch (Exception exception) { + Timber.e("could not reflect", exception); + return false; } + } - private boolean isMapboxMapReady() { - try { - Field field = activity.getClass().getDeclaredField("mapboxMap"); - field.setAccessible(true); - mapboxMap = (MapboxMap) field.get(activity); - Timber.e("isMapboxReady called with value " + (mapboxMap != null)); - return mapboxMap != null; - } catch (Exception e) { - Timber.e("could not reflect", e); - return false; - } - } - - public MapboxMap getMapboxMap() { - return mapboxMap; - } + public MapboxMap getMapboxMap() { + return mapboxMap; + } } diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/utils/ScreenshotUtil.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/utils/ScreenshotUtil.java index 84bfa2c8c3..77bfc519bf 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/utils/ScreenshotUtil.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/utils/ScreenshotUtil.java @@ -4,7 +4,9 @@ import android.app.Activity; import android.graphics.Bitmap; import android.graphics.Canvas; import android.os.Environment; + import timber.log.Timber; + import android.view.TextureView; import android.view.View; import android.view.ViewGroup; @@ -23,112 +25,113 @@ import java.util.UUID; */ public class ScreenshotUtil { - // Where to store the files. This path is required by AWS Device Farm: - // http://docs.aws.amazon.com/devicefarm/latest/developerguide/test-types-android-instrumentation.html#test-types-android-instrumentation-screenshots - private static final String SCREENSHOT_FOLDER = "test-screenshots"; + // Where to store the files. This path is required by AWS Device Farm: + // http://docs.aws.amazon.com/devicefarm/latest/developerguide/test-types-android-instrumentation.html + // #test-types-android-instrumentation-screenshots + private static final String SCREENSHOT_FOLDER = "test-screenshots"; - // Image type and quality - private static final String DEFAULT_IMAGE_EXTENSION = ".png"; - private static final Bitmap.CompressFormat DEFAULT_IMAGE_FORMAT = Bitmap.CompressFormat.PNG; - private static final int DEFAULT_IMAGE_QUALITY = 100; + // Image type and quality + private static final String DEFAULT_IMAGE_EXTENSION = ".png"; + private static final Bitmap.CompressFormat DEFAULT_IMAGE_FORMAT = Bitmap.CompressFormat.PNG; + private static final int DEFAULT_IMAGE_QUALITY = 100; - public static void take(Activity activity, String testName) { + public static void take(Activity activity, String testName) { - // Check if storage is available - if (!isExternalStorageWritable()) { - Timber.d("External storage is not available."); - return; - } + // Check if storage is available + if (!isExternalStorageWritable()) { + Timber.d("External storage is not available."); + return; + } - // Get a bitmap from the activity root view. When the drawing cache is enabled, -// // the next call to getDrawingCache() will draw the view in a bitmap. - View rootView = activity.getWindow().getDecorView().getRootView(); -// rootView.setDrawingCacheEnabled(true);r -// rootView.setDrawingCacheEnabled(false); - - Bitmap bitmap = null; - - // Add the SurfaceView bit (see getAllTextureViews() below) - List tilingViews = getAllTextureViews(rootView); - if (tilingViews.size() > 0) { - bitmap = Bitmap.createBitmap(tilingViews.get(0).getHeight(),tilingViews.get(0).getWidth(), Bitmap.Config.ARGB_8888); - Canvas canvas = new Canvas(bitmap); - for (TextureView TextureView : tilingViews) { - Bitmap b = TextureView.getBitmap(TextureView.getWidth(), TextureView.getHeight()); - int[] location = new int[2]; - TextureView.getLocationInWindow(location); - int[] location2 = new int[2]; - TextureView.getLocationOnScreen(location2); - canvas.drawBitmap(b, 0,0, null); - } - } + // Get a bitmap from the activity root view. When the drawing cache is enabled, + // the next call to getDrawingCache() will draw the view in a bitmap. + View rootView = activity.getWindow().getDecorView().getRootView(); + // rootView.setDrawingCacheEnabled(true);r + // rootView.setDrawingCacheEnabled(false); + + Bitmap bitmap = null; + + // Add the SurfaceView bit (see getAllTextureViews() below) + List tilingViews = getAllTextureViews(rootView); + if (tilingViews.size() > 0) { + bitmap = Bitmap.createBitmap(tilingViews.get(0).getHeight(), tilingViews.get(0).getWidth(), + Bitmap.Config.ARGB_8888); + Canvas canvas = new Canvas(bitmap); + for (TextureView TextureView : tilingViews) { + Bitmap b = TextureView.getBitmap(TextureView.getWidth(), TextureView.getHeight()); + int[] location = new int[2]; + TextureView.getLocationInWindow(location); + int[] location2 = new int[2]; + TextureView.getLocationOnScreen(location2); + canvas.drawBitmap(b, 0, 0, null); + } + } - // Save the bitmap in external storage - String uniqueAbsolutePath = getUniqueAbsolutePath(testName); - File outputFile = new File(uniqueAbsolutePath); - OutputStream outputStream = null; + // Save the bitmap in external storage + String uniqueAbsolutePath = getUniqueAbsolutePath(testName); + File outputFile = new File(uniqueAbsolutePath); + OutputStream outputStream = null; + try { + outputStream = new FileOutputStream(outputFile); + bitmap.compress(DEFAULT_IMAGE_FORMAT, DEFAULT_IMAGE_QUALITY, outputStream); + outputStream.flush(); + } catch (Exception exception) { + + exception.printStackTrace(); + } finally { + if (outputStream != null) { try { - outputStream = new FileOutputStream(outputFile); - bitmap.compress(DEFAULT_IMAGE_FORMAT, DEFAULT_IMAGE_QUALITY, outputStream); - outputStream.flush(); - } catch (Exception e) { - - e.printStackTrace(); - } finally { - if (outputStream != null) { - try { - outputStream.close(); - } catch (IOException e) { - e.printStackTrace(); - } - } + outputStream.close(); + } catch (IOException ioException) { + ioException.printStackTrace(); } + } } - - /* - * The classic way of taking a screenshot (above) doesn't work with TextureView, this fixes it: - * http://stackoverflow.com/questions/19704060/screen-capture-textureview-is-black-using-drawingcache - */ - - public static List getAllTextureViews(View view) - { - List tilingViews = new ArrayList(); - if (view instanceof TextureView) { - tilingViews.add((TextureView)view); - } else if(view instanceof ViewGroup) { - ViewGroup viewGroup = (ViewGroup)view; - for (int i = 0; i < viewGroup.getChildCount(); i++) { - tilingViews.addAll(getAllTextureViews(viewGroup.getChildAt(i))); - } - } - - return tilingViews; + } + + /* + * The classic way of taking a screenshot (above) doesn't work with TextureView, this fixes it: + * http://stackoverflow.com/questions/19704060/screen-capture-textureview-is-black-using-drawingcache + */ + + public static List getAllTextureViews(View view) { + List tilingViews = new ArrayList(); + if (view instanceof TextureView) { + tilingViews.add((TextureView) view); + } else if (view instanceof ViewGroup) { + ViewGroup viewGroup = (ViewGroup) view; + for (int i = 0; i < viewGroup.getChildCount(); i++) { + tilingViews.addAll(getAllTextureViews(viewGroup.getChildAt(i))); + } } - /* - * Utils - */ + return tilingViews; + } - public static boolean isExternalStorageWritable() { - // Checks if external storage is available for read and write - String state = Environment.getExternalStorageState(); - return Environment.MEDIA_MOUNTED.equals(state); - } + /* + * Utils + */ - private static String getUniqueAbsolutePath(String testName) { - // A screenshot after every test vs. manual tests - String filename = UUID.randomUUID().toString() + DEFAULT_IMAGE_EXTENSION; - if (testName != null && !testName.isEmpty()) { - filename = testName + DEFAULT_IMAGE_EXTENSION; - } + public static boolean isExternalStorageWritable() { + // Checks if external storage is available for read and write + String state = Environment.getExternalStorageState(); + return Environment.MEDIA_MOUNTED.equals(state); + } - String externalPath = Environment.getExternalStorageDirectory().toString(); - String path = externalPath + File.separator + SCREENSHOT_FOLDER; - File dir = new File(path); - dir.mkdirs(); - path += File.separator + filename; - Timber.d("Screenshot path: " + path); - return path; + private static String getUniqueAbsolutePath(String testName) { + // A screenshot after every test vs. manual tests + String filename = UUID.randomUUID().toString() + DEFAULT_IMAGE_EXTENSION; + if (testName != null && !testName.isEmpty()) { + filename = testName + DEFAULT_IMAGE_EXTENSION; } + String externalPath = Environment.getExternalStorageDirectory().toString(); + String path = externalPath + File.separator + SCREENSHOT_FOLDER; + File dir = new File(path); + dir.mkdirs(); + path += File.separator + filename; + Timber.d("Screenshot path: " + path); + return path; + } + } diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/utils/TestConstants.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/utils/TestConstants.java index ef46da43ee..965f5d1443 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/utils/TestConstants.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/utils/TestConstants.java @@ -4,15 +4,15 @@ import com.mapbox.mapboxsdk.constants.MapboxConstants; public class TestConstants { - public static final long ANIMATION_TEST_TIME = MapboxConstants.ANIMATION_DURATION * 2; + public static final long ANIMATION_TEST_TIME = MapboxConstants.ANIMATION_DURATION * 2; - public static final double LAT_LNG_DELTA_LARGE = 0.1; - public static final double LAT_LNG_DELTA = 0.01; - public static final double BEARING_DELTA = 0.1; - public static final double TILT_DELTA = 0.1; - public static final double ZOOM_DELTA = 0.3; + public static final double LAT_LNG_DELTA_LARGE = 0.1; + public static final double LAT_LNG_DELTA = 0.01; + public static final double BEARING_DELTA = 0.1; + public static final double TILT_DELTA = 0.1; + public static final double ZOOM_DELTA = 0.3; - public static final String TEXT_MARKER_TEXT = "Text"; - public static final String TEXT_MARKER_TITLE = "Marker"; - public static final String TEXT_MARKER_SNIPPET = "Snippet"; + public static final String TEXT_MARKER_TEXT = "Text"; + public static final String TEXT_MARKER_TITLE = "Marker"; + public static final String TEXT_MARKER_SNIPPET = "Snippet"; } diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/utils/ViewUtils.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/utils/ViewUtils.java index 188e75edc7..5c4d5a03c3 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/utils/ViewUtils.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/utils/ViewUtils.java @@ -10,13 +10,13 @@ import static android.support.test.espresso.matcher.ViewMatchers.withId; public class ViewUtils { - public static void clickView(@IdRes int viewRes) { - onView(withId(viewRes)) - .perform(click()); - } + public static void clickView(@IdRes int viewRes) { + onView(withId(viewRes)) + .perform(click()); + } - public static void checkViewIsDisplayed(int id) { - onView(withId(id)) - .check(matches(isDisplayed())); - } + public static void checkViewIsDisplayed(int id) { + onView(withId(id)) + .check(matches(isDisplayed())); + } } -- cgit v1.2.1