diff options
Diffstat (limited to 'platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp')
76 files changed, 7545 insertions, 6040 deletions
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 b00255a6c7..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,9 +4,9 @@ import android.app.Activity; import android.support.test.espresso.Espresso; import android.support.test.espresso.IdlingResourceTimeoutException; import android.support.test.rule.ActivityTestRule; -import android.util.Log; -import com.mapbox.mapboxsdk.constants.MapboxConstants; +import timber.log.Timber; + import com.mapbox.mapboxsdk.maps.MapboxMap; import com.mapbox.mapboxsdk.testapp.R; import com.mapbox.mapboxsdk.testapp.utils.OnMapReadyIdlingResource; @@ -23,49 +23,50 @@ import static android.support.test.espresso.matcher.ViewMatchers.withId; public abstract class BaseActivityTest { - @Rule - public ActivityTestRule<Activity> rule = new ActivityTestRule<>(getActivityClass()); - protected MapboxMap mapboxMap; - protected OnMapReadyIdlingResource idlingResource; + @Rule + public ActivityTestRule<Activity> rule = new ActivityTestRule<>(getActivityClass()); + protected MapboxMap mapboxMap; + protected OnMapReadyIdlingResource idlingResource; - @Before - public void beforeTest() { - try { - Log.e(MapboxConstants.TAG, "@Before test: register idle resource"); - idlingResource = new OnMapReadyIdlingResource(rule.getActivity()); - Espresso.registerIdlingResources(idlingResource); - checkViewIsDisplayed(R.id.mapView); - mapboxMap = idlingResource.getMapboxMap(); - } catch (IdlingResourceTimeoutException e) { - Log.e(MapboxConstants.TAG, "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() { - Log.e(MapboxConstants.TAG, "@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/activity/gen/annotation/AddRemoveMarkerActivityTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/annotation/AddRemoveMarkerActivityTest.java deleted file mode 100644 index 76ee101904..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/annotation/AddRemoveMarkerActivityTest.java +++ /dev/null @@ -1,33 +0,0 @@ -// This file is generated. Edit android/platform/scripts/generate-test-code.js, then run `make generate-test-android`. -package com.mapbox.mapboxsdk.testapp.activity.gen.annotation; - -import android.support.test.runner.AndroidJUnit4; - -import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest; -import com.mapbox.mapboxsdk.testapp.R; -import com.mapbox.mapboxsdk.testapp.activity.annotation.AddRemoveMarkerActivity; - -import org.junit.Test; -import org.junit.runner.RunWith; - -import static android.support.test.espresso.Espresso.onView; -import static android.support.test.espresso.assertion.ViewAssertions.matches; -import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed; -import static android.support.test.espresso.matcher.ViewMatchers.withId; - -/** - * Sanity test for AddRemoveMarkerActivity - */ -@RunWith(AndroidJUnit4.class) -public class AddRemoveMarkerActivityTest extends BaseActivityTest { - - @Test - public void testSanity() { - onView(withId(R.id.mapView)).check(matches(isDisplayed())); - } - - @Override - protected Class getActivityClass() { - return AddRemoveMarkerActivity.class; - } -} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/annotation/BulkMarkerActivityTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/annotation/BulkMarkerActivityTest.java deleted file mode 100644 index 33bfb23b25..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/annotation/BulkMarkerActivityTest.java +++ /dev/null @@ -1,33 +0,0 @@ -// This file is generated. Edit android/platform/scripts/generate-test-code.js, then run `make generate-test-android`. -package com.mapbox.mapboxsdk.testapp.activity.gen.annotation; - -import android.support.test.runner.AndroidJUnit4; - -import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest; -import com.mapbox.mapboxsdk.testapp.R; -import com.mapbox.mapboxsdk.testapp.activity.annotation.BulkMarkerActivity; - -import org.junit.Test; -import org.junit.runner.RunWith; - -import static android.support.test.espresso.Espresso.onView; -import static android.support.test.espresso.assertion.ViewAssertions.matches; -import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed; -import static android.support.test.espresso.matcher.ViewMatchers.withId; - -/** - * Sanity test for BulkMarkerActivity - */ -@RunWith(AndroidJUnit4.class) -public class BulkMarkerActivityTest extends BaseActivityTest { - - @Test - public void testSanity() { - onView(withId(R.id.mapView)).check(matches(isDisplayed())); - } - - @Override - protected Class getActivityClass() { - return BulkMarkerActivity.class; - } -} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/annotation/DynamicMarkerChangeActivityTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/annotation/DynamicMarkerChangeActivityTest.java deleted file mode 100644 index 040affafda..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/annotation/DynamicMarkerChangeActivityTest.java +++ /dev/null @@ -1,33 +0,0 @@ -// This file is generated. Edit android/platform/scripts/generate-test-code.js, then run `make generate-test-android`. -package com.mapbox.mapboxsdk.testapp.activity.gen.annotation; - -import android.support.test.runner.AndroidJUnit4; - -import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest; -import com.mapbox.mapboxsdk.testapp.R; -import com.mapbox.mapboxsdk.testapp.activity.annotation.DynamicMarkerChangeActivity; - -import org.junit.Test; -import org.junit.runner.RunWith; - -import static android.support.test.espresso.Espresso.onView; -import static android.support.test.espresso.assertion.ViewAssertions.matches; -import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed; -import static android.support.test.espresso.matcher.ViewMatchers.withId; - -/** - * Sanity test for DynamicMarkerChangeActivity - */ -@RunWith(AndroidJUnit4.class) -public class DynamicMarkerChangeActivityTest extends BaseActivityTest { - - @Test - public void testSanity() { - onView(withId(R.id.mapView)).check(matches(isDisplayed())); - } - - @Override - protected Class getActivityClass() { - return DynamicMarkerChangeActivity.class; - } -} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/annotation/MarkerViewActivityTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/annotation/MarkerViewActivityTest.java deleted file mode 100644 index 9a0b66d8bc..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/annotation/MarkerViewActivityTest.java +++ /dev/null @@ -1,33 +0,0 @@ -// This file is generated. Edit android/platform/scripts/generate-test-code.js, then run `make generate-test-android`. -package com.mapbox.mapboxsdk.testapp.activity.gen.annotation; - -import android.support.test.runner.AndroidJUnit4; - -import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest; -import com.mapbox.mapboxsdk.testapp.R; -import com.mapbox.mapboxsdk.testapp.activity.annotation.MarkerViewActivity; - -import org.junit.Test; -import org.junit.runner.RunWith; - -import static android.support.test.espresso.Espresso.onView; -import static android.support.test.espresso.assertion.ViewAssertions.matches; -import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed; -import static android.support.test.espresso.matcher.ViewMatchers.withId; - -/** - * Sanity test for MarkerViewActivity - */ -@RunWith(AndroidJUnit4.class) -public class MarkerViewActivityTest extends BaseActivityTest { - - @Test - public void testSanity() { - onView(withId(R.id.mapView)).check(matches(isDisplayed())); - } - - @Override - protected Class getActivityClass() { - return MarkerViewActivity.class; - } -} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/annotation/MarkerViewScaleActivityTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/annotation/MarkerViewScaleActivityTest.java deleted file mode 100644 index 373b2d3d10..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/annotation/MarkerViewScaleActivityTest.java +++ /dev/null @@ -1,33 +0,0 @@ -// This file is generated. Edit android/platform/scripts/generate-test-code.js, then run `make generate-test-android`. -package com.mapbox.mapboxsdk.testapp.activity.gen.annotation; - -import android.support.test.runner.AndroidJUnit4; - -import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest; -import com.mapbox.mapboxsdk.testapp.R; -import com.mapbox.mapboxsdk.testapp.activity.annotation.MarkerViewScaleActivity; - -import org.junit.Test; -import org.junit.runner.RunWith; - -import static android.support.test.espresso.Espresso.onView; -import static android.support.test.espresso.assertion.ViewAssertions.matches; -import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed; -import static android.support.test.espresso.matcher.ViewMatchers.withId; - -/** - * Sanity test for MarkerViewScaleActivity - */ -@RunWith(AndroidJUnit4.class) -public class MarkerViewScaleActivityTest extends BaseActivityTest { - - @Test - public void testSanity() { - onView(withId(R.id.mapView)).check(matches(isDisplayed())); - } - - @Override - protected Class getActivityClass() { - return MarkerViewScaleActivity.class; - } -} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/annotation/PolygonActivityTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/annotation/PolygonActivityTest.java deleted file mode 100644 index 9569b7880b..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/annotation/PolygonActivityTest.java +++ /dev/null @@ -1,33 +0,0 @@ -// This file is generated. Edit android/platform/scripts/generate-test-code.js, then run `make generate-test-android`. -package com.mapbox.mapboxsdk.testapp.activity.gen.annotation; - -import android.support.test.runner.AndroidJUnit4; - -import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest; -import com.mapbox.mapboxsdk.testapp.R; -import com.mapbox.mapboxsdk.testapp.activity.annotation.PolygonActivity; - -import org.junit.Test; -import org.junit.runner.RunWith; - -import static android.support.test.espresso.Espresso.onView; -import static android.support.test.espresso.assertion.ViewAssertions.matches; -import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed; -import static android.support.test.espresso.matcher.ViewMatchers.withId; - -/** - * Sanity test for PolygonActivity - */ -@RunWith(AndroidJUnit4.class) -public class PolygonActivityTest extends BaseActivityTest { - - @Test - public void testSanity() { - onView(withId(R.id.mapView)).check(matches(isDisplayed())); - } - - @Override - protected Class getActivityClass() { - return PolygonActivity.class; - } -} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/annotation/PolylineActivityTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/annotation/PolylineActivityTest.java deleted file mode 100644 index 32f099cbc8..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/annotation/PolylineActivityTest.java +++ /dev/null @@ -1,33 +0,0 @@ -// This file is generated. Edit android/platform/scripts/generate-test-code.js, then run `make generate-test-android`. -package com.mapbox.mapboxsdk.testapp.activity.gen.annotation; - -import android.support.test.runner.AndroidJUnit4; - -import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest; -import com.mapbox.mapboxsdk.testapp.R; -import com.mapbox.mapboxsdk.testapp.activity.annotation.PolylineActivity; - -import org.junit.Test; -import org.junit.runner.RunWith; - -import static android.support.test.espresso.Espresso.onView; -import static android.support.test.espresso.assertion.ViewAssertions.matches; -import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed; -import static android.support.test.espresso.matcher.ViewMatchers.withId; - -/** - * Sanity test for PolylineActivity - */ -@RunWith(AndroidJUnit4.class) -public class PolylineActivityTest extends BaseActivityTest { - - @Test - public void testSanity() { - onView(withId(R.id.mapView)).check(matches(isDisplayed())); - } - - @Override - protected Class getActivityClass() { - return PolylineActivity.class; - } -} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/annotation/PressForMarkerActivityTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/annotation/PressForMarkerActivityTest.java deleted file mode 100644 index 3475a47263..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/annotation/PressForMarkerActivityTest.java +++ /dev/null @@ -1,33 +0,0 @@ -// This file is generated. Edit android/platform/scripts/generate-test-code.js, then run `make generate-test-android`. -package com.mapbox.mapboxsdk.testapp.activity.gen.annotation; - -import android.support.test.runner.AndroidJUnit4; - -import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest; -import com.mapbox.mapboxsdk.testapp.R; -import com.mapbox.mapboxsdk.testapp.activity.annotation.PressForMarkerActivity; - -import org.junit.Test; -import org.junit.runner.RunWith; - -import static android.support.test.espresso.Espresso.onView; -import static android.support.test.espresso.assertion.ViewAssertions.matches; -import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed; -import static android.support.test.espresso.matcher.ViewMatchers.withId; - -/** - * Sanity test for PressForMarkerActivity - */ -@RunWith(AndroidJUnit4.class) -public class PressForMarkerActivityTest extends BaseActivityTest { - - @Test - public void testSanity() { - onView(withId(R.id.mapView)).check(matches(isDisplayed())); - } - - @Override - protected Class getActivityClass() { - return PressForMarkerActivity.class; - } -} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/camera/CameraAnimationTypeActivityTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/camera/CameraAnimationTypeActivityTest.java deleted file mode 100644 index a4ee61de4d..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/camera/CameraAnimationTypeActivityTest.java +++ /dev/null @@ -1,33 +0,0 @@ -// This file is generated. Edit android/platform/scripts/generate-test-code.js, then run `make generate-test-android`. -package com.mapbox.mapboxsdk.testapp.activity.gen.camera; - -import android.support.test.runner.AndroidJUnit4; - -import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest; -import com.mapbox.mapboxsdk.testapp.R; -import com.mapbox.mapboxsdk.testapp.activity.camera.CameraAnimationTypeActivity; - -import org.junit.Test; -import org.junit.runner.RunWith; - -import static android.support.test.espresso.Espresso.onView; -import static android.support.test.espresso.assertion.ViewAssertions.matches; -import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed; -import static android.support.test.espresso.matcher.ViewMatchers.withId; - -/** - * Sanity test for CameraAnimationTypeActivity - */ -@RunWith(AndroidJUnit4.class) -public class CameraAnimationTypeActivityTest extends BaseActivityTest { - - @Test - public void testSanity() { - onView(withId(R.id.mapView)).check(matches(isDisplayed())); - } - - @Override - protected Class getActivityClass() { - return CameraAnimationTypeActivity.class; - } -} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/camera/CameraPositionActivityTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/camera/CameraPositionActivityTest.java deleted file mode 100644 index 784488668c..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/camera/CameraPositionActivityTest.java +++ /dev/null @@ -1,33 +0,0 @@ -// This file is generated. Edit android/platform/scripts/generate-test-code.js, then run `make generate-test-android`. -package com.mapbox.mapboxsdk.testapp.activity.gen.camera; - -import android.support.test.runner.AndroidJUnit4; - -import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest; -import com.mapbox.mapboxsdk.testapp.R; -import com.mapbox.mapboxsdk.testapp.activity.camera.CameraPositionActivity; - -import org.junit.Test; -import org.junit.runner.RunWith; - -import static android.support.test.espresso.Espresso.onView; -import static android.support.test.espresso.assertion.ViewAssertions.matches; -import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed; -import static android.support.test.espresso.matcher.ViewMatchers.withId; - -/** - * Sanity test for CameraPositionActivity - */ -@RunWith(AndroidJUnit4.class) -public class CameraPositionActivityTest extends BaseActivityTest { - - @Test - public void testSanity() { - onView(withId(R.id.mapView)).check(matches(isDisplayed())); - } - - @Override - protected Class getActivityClass() { - return CameraPositionActivity.class; - } -} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/camera/LatLngBoundsActivityTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/camera/LatLngBoundsActivityTest.java deleted file mode 100644 index f0b061a1c5..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/camera/LatLngBoundsActivityTest.java +++ /dev/null @@ -1,33 +0,0 @@ -// This file is generated. Edit android/platform/scripts/generate-test-code.js, then run `make generate-test-android`. -package com.mapbox.mapboxsdk.testapp.activity.gen.camera; - -import android.support.test.runner.AndroidJUnit4; - -import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest; -import com.mapbox.mapboxsdk.testapp.R; -import com.mapbox.mapboxsdk.testapp.activity.camera.LatLngBoundsActivity; - -import org.junit.Test; -import org.junit.runner.RunWith; - -import static android.support.test.espresso.Espresso.onView; -import static android.support.test.espresso.assertion.ViewAssertions.matches; -import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed; -import static android.support.test.espresso.matcher.ViewMatchers.withId; - -/** - * Sanity test for LatLngBoundsActivity - */ -@RunWith(AndroidJUnit4.class) -public class LatLngBoundsActivityTest extends BaseActivityTest { - - @Test - public void testSanity() { - onView(withId(R.id.mapView)).check(matches(isDisplayed())); - } - - @Override - protected Class getActivityClass() { - return LatLngBoundsActivity.class; - } -} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/camera/ManualZoomActivityTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/camera/ManualZoomActivityTest.java deleted file mode 100644 index 2a50f5f820..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/camera/ManualZoomActivityTest.java +++ /dev/null @@ -1,33 +0,0 @@ -// This file is generated. Edit android/platform/scripts/generate-test-code.js, then run `make generate-test-android`. -package com.mapbox.mapboxsdk.testapp.activity.gen.camera; - -import android.support.test.runner.AndroidJUnit4; - -import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest; -import com.mapbox.mapboxsdk.testapp.R; -import com.mapbox.mapboxsdk.testapp.activity.camera.ManualZoomActivity; - -import org.junit.Test; -import org.junit.runner.RunWith; - -import static android.support.test.espresso.Espresso.onView; -import static android.support.test.espresso.assertion.ViewAssertions.matches; -import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed; -import static android.support.test.espresso.matcher.ViewMatchers.withId; - -/** - * Sanity test for ManualZoomActivity - */ -@RunWith(AndroidJUnit4.class) -public class ManualZoomActivityTest extends BaseActivityTest { - - @Test - public void testSanity() { - onView(withId(R.id.mapView)).check(matches(isDisplayed())); - } - - @Override - protected Class getActivityClass() { - return ManualZoomActivity.class; - } -} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/camera/MaxMinZoomActivityTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/camera/MaxMinZoomActivityTest.java deleted file mode 100644 index cb63bb8838..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/camera/MaxMinZoomActivityTest.java +++ /dev/null @@ -1,33 +0,0 @@ -// This file is generated. Edit android/platform/scripts/generate-test-code.js, then run `make generate-test-android`. -package com.mapbox.mapboxsdk.testapp.activity.gen.camera; - -import android.support.test.runner.AndroidJUnit4; - -import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest; -import com.mapbox.mapboxsdk.testapp.R; -import com.mapbox.mapboxsdk.testapp.activity.camera.MaxMinZoomActivity; - -import org.junit.Test; -import org.junit.runner.RunWith; - -import static android.support.test.espresso.Espresso.onView; -import static android.support.test.espresso.assertion.ViewAssertions.matches; -import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed; -import static android.support.test.espresso.matcher.ViewMatchers.withId; - -/** - * Sanity test for MaxMinZoomActivity - */ -@RunWith(AndroidJUnit4.class) -public class MaxMinZoomActivityTest extends BaseActivityTest { - - @Test - public void testSanity() { - onView(withId(R.id.mapView)).check(matches(isDisplayed())); - } - - @Override - protected Class getActivityClass() { - return MaxMinZoomActivity.class; - } -} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/camera/ScrollByActivityTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/camera/ScrollByActivityTest.java deleted file mode 100644 index ce594efd1f..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/camera/ScrollByActivityTest.java +++ /dev/null @@ -1,33 +0,0 @@ -// This file is generated. Edit android/platform/scripts/generate-test-code.js, then run `make generate-test-android`. -package com.mapbox.mapboxsdk.testapp.activity.gen.camera; - -import android.support.test.runner.AndroidJUnit4; - -import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest; -import com.mapbox.mapboxsdk.testapp.R; -import com.mapbox.mapboxsdk.testapp.activity.camera.ScrollByActivity; - -import org.junit.Test; -import org.junit.runner.RunWith; - -import static android.support.test.espresso.Espresso.onView; -import static android.support.test.espresso.assertion.ViewAssertions.matches; -import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed; -import static android.support.test.espresso.matcher.ViewMatchers.withId; - -/** - * Sanity test for ScrollByActivity - */ -@RunWith(AndroidJUnit4.class) -public class ScrollByActivityTest extends BaseActivityTest { - - @Test - public void testSanity() { - onView(withId(R.id.mapView)).check(matches(isDisplayed())); - } - - @Override - protected Class getActivityClass() { - return ScrollByActivity.class; - } -} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/customlayer/CustomLayerActivityTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/customlayer/CustomLayerActivityTest.java deleted file mode 100644 index 56c2eae817..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/customlayer/CustomLayerActivityTest.java +++ /dev/null @@ -1,33 +0,0 @@ -// This file is generated. Edit android/platform/scripts/generate-test-code.js, then run `make generate-test-android`. -package com.mapbox.mapboxsdk.testapp.activity.gen.customlayer; - -import android.support.test.runner.AndroidJUnit4; - -import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest; -import com.mapbox.mapboxsdk.testapp.R; -import com.mapbox.mapboxsdk.testapp.activity.customlayer.CustomLayerActivity; - -import org.junit.Test; -import org.junit.runner.RunWith; - -import static android.support.test.espresso.Espresso.onView; -import static android.support.test.espresso.assertion.ViewAssertions.matches; -import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed; -import static android.support.test.espresso.matcher.ViewMatchers.withId; - -/** - * Sanity test for CustomLayerActivity - */ -@RunWith(AndroidJUnit4.class) -public class CustomLayerActivityTest extends BaseActivityTest { - - @Test - public void testSanity() { - onView(withId(R.id.mapView)).check(matches(isDisplayed())); - } - - @Override - protected Class getActivityClass() { - return CustomLayerActivity.class; - } -} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/directions/DirectionsActivityTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/directions/DirectionsActivityTest.java deleted file mode 100644 index 379c57e55a..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/directions/DirectionsActivityTest.java +++ /dev/null @@ -1,33 +0,0 @@ -// This file is generated. Edit android/platform/scripts/generate-test-code.js, then run `make generate-test-android`. -package com.mapbox.mapboxsdk.testapp.activity.gen.directions; - -import android.support.test.runner.AndroidJUnit4; - -import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest; -import com.mapbox.mapboxsdk.testapp.R; -import com.mapbox.mapboxsdk.testapp.activity.directions.DirectionsActivity; - -import org.junit.Test; -import org.junit.runner.RunWith; - -import static android.support.test.espresso.Espresso.onView; -import static android.support.test.espresso.assertion.ViewAssertions.matches; -import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed; -import static android.support.test.espresso.matcher.ViewMatchers.withId; - -/** - * Sanity test for DirectionsActivity - */ -@RunWith(AndroidJUnit4.class) -public class DirectionsActivityTest extends BaseActivityTest { - - @Test - public void testSanity() { - onView(withId(R.id.mapView)).check(matches(isDisplayed())); - } - - @Override - protected Class getActivityClass() { - return DirectionsActivity.class; - } -} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/feature/QueryRenderedFeaturesBoxCountActivityTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/feature/QueryRenderedFeaturesBoxCountActivityTest.java deleted file mode 100644 index c4a71d8279..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/feature/QueryRenderedFeaturesBoxCountActivityTest.java +++ /dev/null @@ -1,33 +0,0 @@ -// This file is generated. Edit android/platform/scripts/generate-test-code.js, then run `make generate-test-android`. -package com.mapbox.mapboxsdk.testapp.activity.gen.feature; - -import android.support.test.runner.AndroidJUnit4; - -import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest; -import com.mapbox.mapboxsdk.testapp.R; -import com.mapbox.mapboxsdk.testapp.activity.feature.QueryRenderedFeaturesBoxCountActivity; - -import org.junit.Test; -import org.junit.runner.RunWith; - -import static android.support.test.espresso.Espresso.onView; -import static android.support.test.espresso.assertion.ViewAssertions.matches; -import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed; -import static android.support.test.espresso.matcher.ViewMatchers.withId; - -/** - * Sanity test for QueryRenderedFeaturesBoxCountActivity - */ -@RunWith(AndroidJUnit4.class) -public class QueryRenderedFeaturesBoxCountActivityTest extends BaseActivityTest { - - @Test - public void testSanity() { - onView(withId(R.id.mapView)).check(matches(isDisplayed())); - } - - @Override - protected Class getActivityClass() { - return QueryRenderedFeaturesBoxCountActivity.class; - } -} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/feature/QueryRenderedFeaturesPropertiesActivityTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/feature/QueryRenderedFeaturesPropertiesActivityTest.java deleted file mode 100644 index 8a474fb9bf..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/feature/QueryRenderedFeaturesPropertiesActivityTest.java +++ /dev/null @@ -1,33 +0,0 @@ -// This file is generated. Edit android/platform/scripts/generate-test-code.js, then run `make generate-test-android`. -package com.mapbox.mapboxsdk.testapp.activity.gen.feature; - -import android.support.test.runner.AndroidJUnit4; - -import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest; -import com.mapbox.mapboxsdk.testapp.R; -import com.mapbox.mapboxsdk.testapp.activity.feature.QueryRenderedFeaturesPropertiesActivity; - -import org.junit.Test; -import org.junit.runner.RunWith; - -import static android.support.test.espresso.Espresso.onView; -import static android.support.test.espresso.assertion.ViewAssertions.matches; -import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed; -import static android.support.test.espresso.matcher.ViewMatchers.withId; - -/** - * Sanity test for QueryRenderedFeaturesPropertiesActivity - */ -@RunWith(AndroidJUnit4.class) -public class QueryRenderedFeaturesPropertiesActivityTest extends BaseActivityTest { - - @Test - public void testSanity() { - onView(withId(R.id.mapView)).check(matches(isDisplayed())); - } - - @Override - protected Class getActivityClass() { - return QueryRenderedFeaturesPropertiesActivity.class; - } -} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/geocoding/GeocoderActivityTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/geocoding/GeocoderActivityTest.java deleted file mode 100644 index 05d1f29547..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/geocoding/GeocoderActivityTest.java +++ /dev/null @@ -1,33 +0,0 @@ -// This file is generated. Edit android/platform/scripts/generate-test-code.js, then run `make generate-test-android`. -package com.mapbox.mapboxsdk.testapp.activity.gen.geocoding; - -import android.support.test.runner.AndroidJUnit4; - -import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest; -import com.mapbox.mapboxsdk.testapp.R; -import com.mapbox.mapboxsdk.testapp.activity.geocoding.GeocoderActivity; - -import org.junit.Test; -import org.junit.runner.RunWith; - -import static android.support.test.espresso.Espresso.onView; -import static android.support.test.espresso.assertion.ViewAssertions.matches; -import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed; -import static android.support.test.espresso.matcher.ViewMatchers.withId; - -/** - * Sanity test for GeocoderActivity - */ -@RunWith(AndroidJUnit4.class) -public class GeocoderActivityTest extends BaseActivityTest { - - @Test - public void testSanity() { - onView(withId(R.id.mapView)).check(matches(isDisplayed())); - } - - @Override - protected Class getActivityClass() { - return GeocoderActivity.class; - } -} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/imagegenerator/PrintActivityTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/imagegenerator/PrintActivityTest.java deleted file mode 100644 index c14cc413cf..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/imagegenerator/PrintActivityTest.java +++ /dev/null @@ -1,33 +0,0 @@ -// This file is generated. Edit android/platform/scripts/generate-test-code.js, then run `make generate-test-android`. -package com.mapbox.mapboxsdk.testapp.activity.gen.imagegenerator; - -import android.support.test.runner.AndroidJUnit4; - -import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest; -import com.mapbox.mapboxsdk.testapp.R; -import com.mapbox.mapboxsdk.testapp.activity.imagegenerator.PrintActivity; - -import org.junit.Test; -import org.junit.runner.RunWith; - -import static android.support.test.espresso.Espresso.onView; -import static android.support.test.espresso.assertion.ViewAssertions.matches; -import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed; -import static android.support.test.espresso.matcher.ViewMatchers.withId; - -/** - * Sanity test for PrintActivity - */ -@RunWith(AndroidJUnit4.class) -public class PrintActivityTest extends BaseActivityTest { - - @Test - public void testSanity() { - onView(withId(R.id.mapView)).check(matches(isDisplayed())); - } - - @Override - protected Class getActivityClass() { - return PrintActivity.class; - } -} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/infowindow/DynamicInfoWindowAdapterActivityTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/infowindow/DynamicInfoWindowAdapterActivityTest.java deleted file mode 100644 index b7a8245795..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/infowindow/DynamicInfoWindowAdapterActivityTest.java +++ /dev/null @@ -1,33 +0,0 @@ -// This file is generated. Edit android/platform/scripts/generate-test-code.js, then run `make generate-test-android`. -package com.mapbox.mapboxsdk.testapp.activity.gen.infowindow; - -import android.support.test.runner.AndroidJUnit4; - -import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest; -import com.mapbox.mapboxsdk.testapp.R; -import com.mapbox.mapboxsdk.testapp.activity.infowindow.DynamicInfoWindowAdapterActivity; - -import org.junit.Test; -import org.junit.runner.RunWith; - -import static android.support.test.espresso.Espresso.onView; -import static android.support.test.espresso.assertion.ViewAssertions.matches; -import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed; -import static android.support.test.espresso.matcher.ViewMatchers.withId; - -/** - * Sanity test for DynamicInfoWindowAdapterActivity - */ -@RunWith(AndroidJUnit4.class) -public class DynamicInfoWindowAdapterActivityTest extends BaseActivityTest { - - @Test - public void testSanity() { - onView(withId(R.id.mapView)).check(matches(isDisplayed())); - } - - @Override - protected Class getActivityClass() { - return DynamicInfoWindowAdapterActivity.class; - } -} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/infowindow/InfoWindowActivityTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/infowindow/InfoWindowActivityTest.java deleted file mode 100644 index 5ba4d56a03..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/infowindow/InfoWindowActivityTest.java +++ /dev/null @@ -1,33 +0,0 @@ -// This file is generated. Edit android/platform/scripts/generate-test-code.js, then run `make generate-test-android`. -package com.mapbox.mapboxsdk.testapp.activity.gen.infowindow; - -import android.support.test.runner.AndroidJUnit4; - -import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest; -import com.mapbox.mapboxsdk.testapp.R; -import com.mapbox.mapboxsdk.testapp.activity.infowindow.InfoWindowActivity; - -import org.junit.Test; -import org.junit.runner.RunWith; - -import static android.support.test.espresso.Espresso.onView; -import static android.support.test.espresso.assertion.ViewAssertions.matches; -import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed; -import static android.support.test.espresso.matcher.ViewMatchers.withId; - -/** - * Sanity test for InfoWindowActivity - */ -@RunWith(AndroidJUnit4.class) -public class InfoWindowActivityTest extends BaseActivityTest { - - @Test - public void testSanity() { - onView(withId(R.id.mapView)).check(matches(isDisplayed())); - } - - @Override - protected Class getActivityClass() { - return InfoWindowActivity.class; - } -} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/infowindow/InfoWindowAdapterActivityTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/infowindow/InfoWindowAdapterActivityTest.java deleted file mode 100644 index 7071874435..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/infowindow/InfoWindowAdapterActivityTest.java +++ /dev/null @@ -1,33 +0,0 @@ -// This file is generated. Edit android/platform/scripts/generate-test-code.js, then run `make generate-test-android`. -package com.mapbox.mapboxsdk.testapp.activity.gen.infowindow; - -import android.support.test.runner.AndroidJUnit4; - -import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest; -import com.mapbox.mapboxsdk.testapp.R; -import com.mapbox.mapboxsdk.testapp.activity.infowindow.InfoWindowAdapterActivity; - -import org.junit.Test; -import org.junit.runner.RunWith; - -import static android.support.test.espresso.Espresso.onView; -import static android.support.test.espresso.assertion.ViewAssertions.matches; -import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed; -import static android.support.test.espresso.matcher.ViewMatchers.withId; - -/** - * Sanity test for InfoWindowAdapterActivity - */ -@RunWith(AndroidJUnit4.class) -public class InfoWindowAdapterActivityTest extends BaseActivityTest { - - @Test - public void testSanity() { - onView(withId(R.id.mapView)).check(matches(isDisplayed())); - } - - @Override - protected Class getActivityClass() { - return InfoWindowAdapterActivity.class; - } -} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/maplayout/DebugModeActivityTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/maplayout/DebugModeActivityTest.java deleted file mode 100644 index 5764d364e0..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/maplayout/DebugModeActivityTest.java +++ /dev/null @@ -1,33 +0,0 @@ -// This file is generated. Edit android/platform/scripts/generate-test-code.js, then run `make generate-test-android`. -package com.mapbox.mapboxsdk.testapp.activity.gen.maplayout; - -import android.support.test.runner.AndroidJUnit4; - -import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest; -import com.mapbox.mapboxsdk.testapp.R; -import com.mapbox.mapboxsdk.testapp.activity.maplayout.DebugModeActivity; - -import org.junit.Test; -import org.junit.runner.RunWith; - -import static android.support.test.espresso.Espresso.onView; -import static android.support.test.espresso.assertion.ViewAssertions.matches; -import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed; -import static android.support.test.espresso.matcher.ViewMatchers.withId; - -/** - * Sanity test for DebugModeActivity - */ -@RunWith(AndroidJUnit4.class) -public class DebugModeActivityTest extends BaseActivityTest { - - @Test - public void testSanity() { - onView(withId(R.id.mapView)).check(matches(isDisplayed())); - } - - @Override - protected Class getActivityClass() { - return DebugModeActivity.class; - } -} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/maplayout/MapPaddingActivityTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/maplayout/MapPaddingActivityTest.java deleted file mode 100644 index 3f94b11246..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/maplayout/MapPaddingActivityTest.java +++ /dev/null @@ -1,33 +0,0 @@ -// This file is generated. Edit android/platform/scripts/generate-test-code.js, then run `make generate-test-android`. -package com.mapbox.mapboxsdk.testapp.activity.gen.maplayout; - -import android.support.test.runner.AndroidJUnit4; - -import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest; -import com.mapbox.mapboxsdk.testapp.R; -import com.mapbox.mapboxsdk.testapp.activity.maplayout.MapPaddingActivity; - -import org.junit.Test; -import org.junit.runner.RunWith; - -import static android.support.test.espresso.Espresso.onView; -import static android.support.test.espresso.assertion.ViewAssertions.matches; -import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed; -import static android.support.test.espresso.matcher.ViewMatchers.withId; - -/** - * Sanity test for MapPaddingActivity - */ -@RunWith(AndroidJUnit4.class) -public class MapPaddingActivityTest extends BaseActivityTest { - - @Test - public void testSanity() { - onView(withId(R.id.mapView)).check(matches(isDisplayed())); - } - - @Override - protected Class getActivityClass() { - return MapPaddingActivity.class; - } -} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/maplayout/SurfaceViewMediaControlActivityTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/maplayout/SurfaceViewMediaControlActivityTest.java deleted file mode 100644 index a52a4b0edb..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/maplayout/SurfaceViewMediaControlActivityTest.java +++ /dev/null @@ -1,33 +0,0 @@ -// This file is generated. Edit android/platform/scripts/generate-test-code.js, then run `make generate-test-android`. -package com.mapbox.mapboxsdk.testapp.activity.gen.maplayout; - -import android.support.test.runner.AndroidJUnit4; - -import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest; -import com.mapbox.mapboxsdk.testapp.R; -import com.mapbox.mapboxsdk.testapp.activity.maplayout.SurfaceViewMediaControlActivity; - -import org.junit.Test; -import org.junit.runner.RunWith; - -import static android.support.test.espresso.Espresso.onView; -import static android.support.test.espresso.assertion.ViewAssertions.matches; -import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed; -import static android.support.test.espresso.matcher.ViewMatchers.withId; - -/** - * Sanity test for SurfaceViewMediaControlActivity - */ -@RunWith(AndroidJUnit4.class) -public class SurfaceViewMediaControlActivityTest extends BaseActivityTest { - - @Test - public void testSanity() { - onView(withId(R.id.mapView)).check(matches(isDisplayed())); - } - - @Override - protected Class getActivityClass() { - return SurfaceViewMediaControlActivity.class; - } -} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/maplayout/VideoViewActivityTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/maplayout/VideoViewActivityTest.java deleted file mode 100644 index fb9330f0f4..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/maplayout/VideoViewActivityTest.java +++ /dev/null @@ -1,33 +0,0 @@ -// This file is generated. Edit android/platform/scripts/generate-test-code.js, then run `make generate-test-android`. -package com.mapbox.mapboxsdk.testapp.activity.gen.maplayout; - -import android.support.test.runner.AndroidJUnit4; - -import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest; -import com.mapbox.mapboxsdk.testapp.R; -import com.mapbox.mapboxsdk.testapp.activity.maplayout.VideoViewActivity; - -import org.junit.Test; -import org.junit.runner.RunWith; - -import static android.support.test.espresso.Espresso.onView; -import static android.support.test.espresso.assertion.ViewAssertions.matches; -import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed; -import static android.support.test.espresso.matcher.ViewMatchers.withId; - -/** - * Sanity test for VideoViewActivity - */ -@RunWith(AndroidJUnit4.class) -public class VideoViewActivityTest extends BaseActivityTest { - - @Test - public void testSanity() { - onView(withId(R.id.mapView)).check(matches(isDisplayed())); - } - - @Override - protected Class getActivityClass() { - return VideoViewActivity.class; - } -} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/offline/OfflineActivityTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/offline/OfflineActivityTest.java deleted file mode 100644 index 00a953f37e..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/offline/OfflineActivityTest.java +++ /dev/null @@ -1,33 +0,0 @@ -// This file is generated. Edit android/platform/scripts/generate-test-code.js, then run `make generate-test-android`. -package com.mapbox.mapboxsdk.testapp.activity.gen.offline; - -import android.support.test.runner.AndroidJUnit4; - -import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest; -import com.mapbox.mapboxsdk.testapp.R; -import com.mapbox.mapboxsdk.testapp.activity.offline.OfflineActivity; - -import org.junit.Test; -import org.junit.runner.RunWith; - -import static android.support.test.espresso.Espresso.onView; -import static android.support.test.espresso.assertion.ViewAssertions.matches; -import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed; -import static android.support.test.espresso.matcher.ViewMatchers.withId; - -/** - * Sanity test for OfflineActivity - */ -@RunWith(AndroidJUnit4.class) -public class OfflineActivityTest extends BaseActivityTest { - - @Test - public void testSanity() { - onView(withId(R.id.mapView)).check(matches(isDisplayed())); - } - - @Override - protected Class getActivityClass() { - return OfflineActivity.class; - } -} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/style/CircleLayerActivityTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/style/CircleLayerActivityTest.java deleted file mode 100644 index 5299f2e716..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/style/CircleLayerActivityTest.java +++ /dev/null @@ -1,33 +0,0 @@ -// This file is generated. Edit android/platform/scripts/generate-test-code.js, then run `make generate-test-android`. -package com.mapbox.mapboxsdk.testapp.activity.gen.style; - -import android.support.test.runner.AndroidJUnit4; - -import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest; -import com.mapbox.mapboxsdk.testapp.R; -import com.mapbox.mapboxsdk.testapp.activity.style.CircleLayerActivity; - -import org.junit.Test; -import org.junit.runner.RunWith; - -import static android.support.test.espresso.Espresso.onView; -import static android.support.test.espresso.assertion.ViewAssertions.matches; -import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed; -import static android.support.test.espresso.matcher.ViewMatchers.withId; - -/** - * Sanity test for CircleLayerActivity - */ -@RunWith(AndroidJUnit4.class) -public class CircleLayerActivityTest extends BaseActivityTest { - - @Test - public void testSanity() { - onView(withId(R.id.mapView)).check(matches(isDisplayed())); - } - - @Override - protected Class getActivityClass() { - return CircleLayerActivity.class; - } -} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/style/CustomSpriteActivityTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/style/CustomSpriteActivityTest.java deleted file mode 100644 index 5e482b2b38..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/style/CustomSpriteActivityTest.java +++ /dev/null @@ -1,33 +0,0 @@ -// This file is generated. Edit android/platform/scripts/generate-test-code.js, then run `make generate-test-android`. -package com.mapbox.mapboxsdk.testapp.activity.gen.style; - -import android.support.test.runner.AndroidJUnit4; - -import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest; -import com.mapbox.mapboxsdk.testapp.R; -import com.mapbox.mapboxsdk.testapp.activity.style.CustomSpriteActivity; - -import org.junit.Test; -import org.junit.runner.RunWith; - -import static android.support.test.espresso.Espresso.onView; -import static android.support.test.espresso.assertion.ViewAssertions.matches; -import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed; -import static android.support.test.espresso.matcher.ViewMatchers.withId; - -/** - * Sanity test for CustomSpriteActivity - */ -@RunWith(AndroidJUnit4.class) -public class CustomSpriteActivityTest extends BaseActivityTest { - - @Test - public void testSanity() { - onView(withId(R.id.mapView)).check(matches(isDisplayed())); - } - - @Override - protected Class getActivityClass() { - return CustomSpriteActivity.class; - } -} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/style/RuntimeStyleActivityTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/style/RuntimeStyleActivityTest.java deleted file mode 100644 index 37d5f64e8c..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/style/RuntimeStyleActivityTest.java +++ /dev/null @@ -1,33 +0,0 @@ -// This file is generated. Edit android/platform/scripts/generate-test-code.js, then run `make generate-test-android`. -package com.mapbox.mapboxsdk.testapp.activity.gen.style; - -import android.support.test.runner.AndroidJUnit4; - -import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest; -import com.mapbox.mapboxsdk.testapp.R; -import com.mapbox.mapboxsdk.testapp.activity.style.RuntimeStyleActivity; - -import org.junit.Test; -import org.junit.runner.RunWith; - -import static android.support.test.espresso.Espresso.onView; -import static android.support.test.espresso.assertion.ViewAssertions.matches; -import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed; -import static android.support.test.espresso.matcher.ViewMatchers.withId; - -/** - * Sanity test for RuntimeStyleActivity - */ -@RunWith(AndroidJUnit4.class) -public class RuntimeStyleActivityTest extends BaseActivityTest { - - @Test - public void testSanity() { - onView(withId(R.id.mapView)).check(matches(isDisplayed())); - } - - @Override - protected Class getActivityClass() { - return RuntimeStyleActivity.class; - } -} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/style/RuntimeStyleTimingTestActivityTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/style/RuntimeStyleTimingTestActivityTest.java deleted file mode 100644 index 7320b8527c..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/style/RuntimeStyleTimingTestActivityTest.java +++ /dev/null @@ -1,33 +0,0 @@ -// This file is generated. Edit android/platform/scripts/generate-test-code.js, then run `make generate-test-android`. -package com.mapbox.mapboxsdk.testapp.activity.gen.style; - -import android.support.test.runner.AndroidJUnit4; - -import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest; -import com.mapbox.mapboxsdk.testapp.R; -import com.mapbox.mapboxsdk.testapp.activity.style.RuntimeStyleTimingTestActivity; - -import org.junit.Test; -import org.junit.runner.RunWith; - -import static android.support.test.espresso.Espresso.onView; -import static android.support.test.espresso.assertion.ViewAssertions.matches; -import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed; -import static android.support.test.espresso.matcher.ViewMatchers.withId; - -/** - * Sanity test for RuntimeStyleTimingTestActivity - */ -@RunWith(AndroidJUnit4.class) -public class RuntimeStyleTimingTestActivityTest extends BaseActivityTest { - - @Test - public void testSanity() { - onView(withId(R.id.mapView)).check(matches(isDisplayed())); - } - - @Override - protected Class getActivityClass() { - return RuntimeStyleTimingTestActivity.class; - } -} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/style/StyleFileActivityTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/style/StyleFileActivityTest.java deleted file mode 100644 index 29116b85cb..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/style/StyleFileActivityTest.java +++ /dev/null @@ -1,33 +0,0 @@ -// This file is generated. Edit android/platform/scripts/generate-test-code.js, then run `make generate-test-android`. -package com.mapbox.mapboxsdk.testapp.activity.gen.style; - -import android.support.test.runner.AndroidJUnit4; - -import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest; -import com.mapbox.mapboxsdk.testapp.R; -import com.mapbox.mapboxsdk.testapp.activity.style.StyleFileActivity; - -import org.junit.Test; -import org.junit.runner.RunWith; - -import static android.support.test.espresso.Espresso.onView; -import static android.support.test.espresso.assertion.ViewAssertions.matches; -import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed; -import static android.support.test.espresso.matcher.ViewMatchers.withId; - -/** - * Sanity test for StyleFileActivity - */ -@RunWith(AndroidJUnit4.class) -public class StyleFileActivityTest extends BaseActivityTest { - - @Test - public void testSanity() { - onView(withId(R.id.mapView)).check(matches(isDisplayed())); - } - - @Override - protected Class getActivityClass() { - return StyleFileActivity.class; - } -} 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 new file mode 100644 index 0000000000..77025c8fa5 --- /dev/null +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/annotations/MarkerTest.java @@ -0,0 +1,142 @@ +package com.mapbox.mapboxsdk.testapp.annotations; + +import android.support.test.espresso.Espresso; +import android.support.test.espresso.UiController; +import android.support.test.espresso.ViewAction; +import android.support.test.rule.ActivityTestRule; +import android.view.View; + +import com.mapbox.mapboxsdk.annotations.Marker; +import com.mapbox.mapboxsdk.annotations.MarkerOptions; +import com.mapbox.mapboxsdk.geometry.LatLng; +import com.mapbox.mapboxsdk.maps.MapboxMap; +import com.mapbox.mapboxsdk.testapp.R; +import com.mapbox.mapboxsdk.testapp.activity.espresso.EspressoTestActivity; +import com.mapbox.mapboxsdk.testapp.utils.OnMapReadyIdlingResource; +import com.mapbox.mapboxsdk.testapp.utils.TestConstants; +import com.mapbox.mapboxsdk.testapp.utils.ViewUtils; + +import org.hamcrest.Matcher; +import org.junit.After; +import org.junit.Before; +import org.junit.Ignore; +import org.junit.Rule; +import org.junit.Test; + +import static android.support.test.espresso.Espresso.onView; +import static android.support.test.espresso.assertion.ViewAssertions.matches; +import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed; +import static android.support.test.espresso.matcher.ViewMatchers.withId; +import static android.support.test.espresso.matcher.ViewMatchers.withText; +import static org.junit.Assert.assertEquals; + +public class MarkerTest { + + @Rule + public final ActivityTestRule<EspressoTestActivity> rule = new ActivityTestRule<>(EspressoTestActivity.class); + + private OnMapReadyIdlingResource idlingResource; + private Marker marker; + + @Before + public void registerIdlingResource() { + idlingResource = new OnMapReadyIdlingResource(rule.getActivity()); + Espresso.registerIdlingResources(idlingResource); + } + + @Test + @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; + } + + @Override + public Matcher<View> getConstraints() { + return isDisplayed(); + } + + @Override + public String getDescription() { + return getClass().getSimpleName(); + } + + @Override + public void perform(UiController uiController, View view) { + marker = mapboxMap.addMarker(options); + } + } + + private class ShowInfoWindowAction implements ViewAction { + + private MapboxMap mapboxMap; + + ShowInfoWindowAction(MapboxMap map) { + mapboxMap = map; + } + + @Override + public Matcher<View> getConstraints() { + return isDisplayed(); + } + + @Override + public String getDescription() { + return getClass().getSimpleName(); + } + + @Override + public void perform(UiController uiController, View view) { + mapboxMap.selectMarker(marker); + + } + } + + + @After + public void unregisterIdlingResource() { + Espresso.unregisterIdlingResources(idlingResource); + } +} 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 new file mode 100644 index 0000000000..9351ed1c10 --- /dev/null +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/annotations/MarkerViewTest.java @@ -0,0 +1,147 @@ +package com.mapbox.mapboxsdk.testapp.annotations; + +import android.support.test.espresso.Espresso; +import android.support.test.espresso.UiController; +import android.support.test.espresso.ViewAction; +import android.support.test.rule.ActivityTestRule; +import android.view.View; + +import com.mapbox.mapboxsdk.annotations.Marker; +import com.mapbox.mapboxsdk.geometry.LatLng; +import com.mapbox.mapboxsdk.maps.MapboxMap; +import com.mapbox.mapboxsdk.testapp.R; +import com.mapbox.mapboxsdk.testapp.activity.annotation.MarkerViewActivity; +import com.mapbox.mapboxsdk.testapp.activity.espresso.EspressoTestActivity; +import com.mapbox.mapboxsdk.testapp.model.annotations.TextMarkerViewOptions; +import com.mapbox.mapboxsdk.testapp.utils.OnMapReadyIdlingResource; +import com.mapbox.mapboxsdk.testapp.utils.TestConstants; +import com.mapbox.mapboxsdk.testapp.utils.ViewUtils; + +import org.hamcrest.Matcher; +import org.junit.After; +import org.junit.Before; +import org.junit.Ignore; +import org.junit.Rule; +import org.junit.Test; + +import static android.support.test.espresso.Espresso.onView; +import static android.support.test.espresso.assertion.ViewAssertions.matches; +import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed; +import static android.support.test.espresso.matcher.ViewMatchers.withId; +import static android.support.test.espresso.matcher.ViewMatchers.withText; +import static org.junit.Assert.assertEquals; + +public class MarkerViewTest { + + @Rule + public final ActivityTestRule<EspressoTestActivity> rule = new ActivityTestRule<>(EspressoTestActivity.class); + + private OnMapReadyIdlingResource idlingResource; + private Marker marker; + + @Before + public void registerIdlingResource() { + idlingResource = new OnMapReadyIdlingResource(rule.getActivity()); + Espresso.registerIdlingResources(idlingResource); + } + + @Test + @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; + } + + @Override + public Matcher<View> getConstraints() { + return isDisplayed(); + } + + @Override + public String getDescription() { + return getClass().getSimpleName(); + } + + @Override + public void perform(UiController uiController, View view) { + mapboxMap.getMarkerViewManager().addMarkerViewAdapter( + new MarkerViewActivity.TextAdapter(view.getContext(), mapboxMap)); + marker = mapboxMap.addMarker(options); + uiController.loopMainThreadForAtLeast(250); + } + } + + private class ShowInfoWindowAction implements ViewAction { + + private MapboxMap mapboxMap; + + ShowInfoWindowAction(MapboxMap map) { + mapboxMap = map; + } + + @Override + public Matcher<View> getConstraints() { + return isDisplayed(); + } + + @Override + public String getDescription() { + return getClass().getSimpleName(); + } + + @Override + public void perform(UiController uiController, View view) { + mapboxMap.selectMarker(marker); + uiController.loopMainThreadForAtLeast(250); + } + } + + @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 new file mode 100644 index 0000000000..24b9b3bf01 --- /dev/null +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/annotations/PolygonTest.java @@ -0,0 +1,105 @@ +package com.mapbox.mapboxsdk.testapp.annotations; + +import android.graphics.Color; +import android.support.test.espresso.Espresso; +import android.support.test.espresso.UiController; +import android.support.test.espresso.ViewAction; +import android.support.test.rule.ActivityTestRule; +import android.view.View; + +import com.mapbox.mapboxsdk.annotations.Polygon; +import com.mapbox.mapboxsdk.annotations.PolygonOptions; +import com.mapbox.mapboxsdk.geometry.LatLng; +import com.mapbox.mapboxsdk.maps.MapboxMap; +import com.mapbox.mapboxsdk.testapp.R; +import com.mapbox.mapboxsdk.testapp.activity.espresso.EspressoTestActivity; +import com.mapbox.mapboxsdk.testapp.utils.OnMapReadyIdlingResource; +import com.mapbox.mapboxsdk.testapp.utils.ViewUtils; + +import org.hamcrest.Matcher; +import org.junit.After; +import org.junit.Before; +import org.junit.Ignore; +import org.junit.Rule; +import org.junit.Test; + +import static android.support.test.espresso.Espresso.onView; +import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed; +import static android.support.test.espresso.matcher.ViewMatchers.withId; +import static org.junit.Assert.assertEquals; + +public class PolygonTest { + + @Rule + public final ActivityTestRule<EspressoTestActivity> rule = new ActivityTestRule<>(EspressoTestActivity.class); + + private OnMapReadyIdlingResource idlingResource; + private Polygon polygon; + + @Before + public void registerIdlingResource() { + idlingResource = new OnMapReadyIdlingResource(rule.getActivity()); + Espresso.registerIdlingResources(idlingResource); + } + + @Test + @Ignore + /** native crash **/ + public void addPolygonTest() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + final MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); + LatLng latLngOne = new LatLng(); + LatLng latLngTwo = new LatLng(1, 0); + LatLng latLngThree = new LatLng(1, 1); + + assertEquals("Polygons should be empty", 0, mapboxMap.getPolygons().size()); + + final PolygonOptions options = new PolygonOptions(); + options.strokeColor(Color.BLUE); + options.fillColor(Color.RED); + options.add(latLngOne); + options.add(latLngTwo); + options.add(latLngThree); + + onView(withId(R.id.mapView)).perform(new AddPolygonAction(mapboxMap, options)); + + assertEquals("Polygons should be 1", 1, mapboxMap.getPolygons().size()); + assertEquals("Polygon id should be 0", 0, polygon.getId()); + assertEquals("Polygon points size should match", 3, polygon.getPoints().size()); + assertEquals("Polygon stroke color should match", Color.BLUE, polygon.getStrokeColor()); + assertEquals("Polygon target should match", Color.RED, polygon.getFillColor()); + mapboxMap.clear(); + assertEquals("Polygons should be empty", 0, mapboxMap.getPolygons().size()); + } + + private class AddPolygonAction implements ViewAction { + + private MapboxMap mapboxMap; + private PolygonOptions options; + + AddPolygonAction(MapboxMap map, PolygonOptions polygonOptions) { + mapboxMap = map; + options = polygonOptions; + } + + @Override + public Matcher<View> getConstraints() { + return isDisplayed(); + } + + @Override + public String getDescription() { + return getClass().getSimpleName(); + } + + @Override + public void perform(UiController uiController, View view) { + polygon = mapboxMap.addPolygon(options); + } + } + + @After + public void unregisterIdlingResource() { + Espresso.unregisterIdlingResources(idlingResource); + } +} 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 new file mode 100644 index 0000000000..607a4ad263 --- /dev/null +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/annotations/PolylineTest.java @@ -0,0 +1,100 @@ +package com.mapbox.mapboxsdk.testapp.annotations; + +import android.graphics.Color; +import android.support.test.espresso.Espresso; +import android.support.test.espresso.UiController; +import android.support.test.espresso.ViewAction; +import android.support.test.rule.ActivityTestRule; +import android.view.View; + +import com.mapbox.mapboxsdk.annotations.Polyline; +import com.mapbox.mapboxsdk.annotations.PolylineOptions; +import com.mapbox.mapboxsdk.geometry.LatLng; +import com.mapbox.mapboxsdk.maps.MapboxMap; +import com.mapbox.mapboxsdk.testapp.R; +import com.mapbox.mapboxsdk.testapp.activity.espresso.EspressoTestActivity; +import com.mapbox.mapboxsdk.testapp.utils.OnMapReadyIdlingResource; +import com.mapbox.mapboxsdk.testapp.utils.ViewUtils; + +import org.hamcrest.Matcher; +import org.junit.After; +import org.junit.Before; +import org.junit.Ignore; +import org.junit.Rule; +import org.junit.Test; + +import static android.support.test.espresso.Espresso.onView; +import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed; +import static android.support.test.espresso.matcher.ViewMatchers.withId; +import static org.junit.Assert.assertEquals; + +public class PolylineTest { + + @Rule + public final ActivityTestRule<EspressoTestActivity> rule = new ActivityTestRule<>(EspressoTestActivity.class); + + private OnMapReadyIdlingResource idlingResource; + private Polyline polyline; + + @Before + public void registerIdlingResource() { + idlingResource = new OnMapReadyIdlingResource(rule.getActivity()); + Espresso.registerIdlingResources(idlingResource); + } + + @Ignore + @Test + public void addPolylineTest() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + final MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); + LatLng latLngOne = new LatLng(); + LatLng latLngTwo = new LatLng(1, 0); + + assertEquals("Polygons should be empty", 0, mapboxMap.getPolygons().size()); + + final PolylineOptions options = new PolylineOptions(); + options.color(Color.BLUE); + options.add(latLngOne); + options.add(latLngTwo); + + onView(withId(R.id.mapView)).perform(new AddPolyLineAction(mapboxMap, options)); + + assertEquals("Polylines should be 1", 1, mapboxMap.getPolylines().size()); + assertEquals("Polyline id should be 0", 0, polyline.getId()); + assertEquals("Polyline points size should match", 2, polyline.getPoints().size()); + assertEquals("Polyline stroke color should match", Color.BLUE, polyline.getColor()); + mapboxMap.clear(); + assertEquals("Polyline should be empty", 0, mapboxMap.getPolylines().size()); + } + + private class AddPolyLineAction implements ViewAction { + + private MapboxMap mapboxMap; + private PolylineOptions options; + + AddPolyLineAction(MapboxMap map, PolylineOptions polylineOptions) { + mapboxMap = map; + options = polylineOptions; + } + + @Override + public Matcher<View> getConstraints() { + return isDisplayed(); + } + + @Override + public String getDescription() { + return getClass().getSimpleName(); + } + + @Override + public void perform(UiController uiController, View view) { + polyline = mapboxMap.addPolyline(options); + } + } + + @After + public void unregisterIdlingResource() { + Espresso.unregisterIdlingResources(idlingResource); + } +} 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 new file mode 100644 index 0000000000..5ead54eb7b --- /dev/null +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/camera/CameraAnimateTest.java @@ -0,0 +1,253 @@ +package com.mapbox.mapboxsdk.testapp.camera; + +import android.graphics.PointF; +import android.support.test.espresso.Espresso; +import android.support.test.espresso.UiController; +import android.support.test.espresso.ViewAction; +import android.support.test.rule.ActivityTestRule; +import android.view.View; + +import com.mapbox.mapboxsdk.camera.CameraPosition; +import com.mapbox.mapboxsdk.camera.CameraUpdate; +import com.mapbox.mapboxsdk.camera.CameraUpdateFactory; +import com.mapbox.mapboxsdk.geometry.LatLng; +import com.mapbox.mapboxsdk.geometry.LatLngBounds; +import com.mapbox.mapboxsdk.maps.MapboxMap; +import com.mapbox.mapboxsdk.testapp.R; +import com.mapbox.mapboxsdk.testapp.activity.espresso.EspressoTestActivity; +import com.mapbox.mapboxsdk.testapp.utils.OnMapReadyIdlingResource; +import com.mapbox.mapboxsdk.testapp.utils.TestConstants; +import com.mapbox.mapboxsdk.testapp.utils.ViewUtils; + +import org.hamcrest.Matcher; +import org.junit.After; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; + +import static android.support.test.espresso.Espresso.onView; +import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed; +import static android.support.test.espresso.matcher.ViewMatchers.withId; +import static org.junit.Assert.assertEquals; + +public class CameraAnimateTest { + + @Rule + public final ActivityTestRule<EspressoTestActivity> rule = new ActivityTestRule<>(EspressoTestActivity.class); + + private OnMapReadyIdlingResource idlingResource; + + @Before + public void registerIdlingResource() { + idlingResource = new OnMapReadyIdlingResource(rule.getActivity()); + Espresso.registerIdlingResources(idlingResource); + } + + @Test + public void testAnimateToCameraPositionTarget() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + final MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); + + /*TODO remove zoom #6474*/ + float zoom = 1.0f; + LatLng moveTarget = new LatLng(1, 1); + + CameraPosition initialPosition = new CameraPosition.Builder().target( + new LatLng()).zoom(zoom).bearing(0).tilt(0).build(); + CameraPosition cameraPosition = mapboxMap.getCameraPosition(); + assertEquals("Default camera position should match default", cameraPosition, initialPosition); + + onView(withId(R.id.mapView)).perform(new AnimateCameraAction(mapboxMap, CameraUpdateFactory.newLatLng(moveTarget))); + cameraPosition = mapboxMap.getCameraPosition(); + assertEquals("Moved camera position latitude should match", cameraPosition.target.getLatitude(), + moveTarget.getLatitude(), TestConstants.LAT_LNG_DELTA); + assertEquals("Moved camera position longitude should match", cameraPosition.target.getLongitude(), + moveTarget.getLongitude(), TestConstants.LAT_LNG_DELTA); + } + + @Test + public void testAnimateToCameraPositionTargetZoom() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + final MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); + + final float moveZoom = 15.5f; + final LatLng moveTarget = new LatLng(1.0000000001, 1.0000000003); + + onView(withId(R.id.mapView)).perform(new AnimateCameraAction(mapboxMap, + CameraUpdateFactory.newLatLngZoom(moveTarget, moveZoom))); + CameraPosition cameraPosition = mapboxMap.getCameraPosition(); + assertEquals("Moved camera position latitude should match", cameraPosition.target.getLatitude(), + moveTarget.getLatitude(), TestConstants.LAT_LNG_DELTA); + assertEquals("Moved camera position longitude should match", cameraPosition.target.getLongitude(), + moveTarget.getLongitude(), TestConstants.LAT_LNG_DELTA); + assertEquals("Moved zoom should match", cameraPosition.zoom, moveZoom, TestConstants.ZOOM_DELTA); + } + + @Test + public void testAnimateToCameraPosition() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + final MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); + + final LatLng moveTarget = new LatLng(1.0000000001, 1.0000000003); + final float moveZoom = 15.5f; + final float moveTilt = 45.5f; + final float moveBearing = 12.5f; + + onView(withId(R.id.mapView)).perform( + new AnimateCameraAction(mapboxMap, CameraUpdateFactory.newCameraPosition( + new CameraPosition.Builder() + .target(moveTarget) + .zoom(moveZoom) + .tilt(moveTilt) + .bearing(moveBearing) + .build())) + ); + + CameraPosition cameraPosition = mapboxMap.getCameraPosition(); + assertEquals("Moved camera position latitude should match", cameraPosition.target.getLatitude(), + moveTarget.getLatitude(), TestConstants.LAT_LNG_DELTA); + assertEquals("Moved camera position longitude should match", cameraPosition.target.getLongitude(), + moveTarget.getLongitude(), TestConstants.LAT_LNG_DELTA); + assertEquals("Moved zoom should match", cameraPosition.zoom, moveZoom, TestConstants.ZOOM_DELTA); + assertEquals("Moved zoom should match", cameraPosition.tilt, moveTilt, TestConstants.TILT_DELTA); + assertEquals("Moved bearing should match", cameraPosition.bearing, moveBearing, TestConstants.BEARING_DELTA); + } + + @Test + public void testAnimateToBounds() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + final MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); + + final LatLng centerBounds = new LatLng(1, 1); + LatLng cornerOne = new LatLng(); + LatLng cornerTwo = new LatLng(2, 2); + + final LatLngBounds.Builder builder = new LatLngBounds.Builder(); + builder.include(cornerOne); + builder.include(cornerTwo); + + onView(withId(R.id.mapView)).perform(new AnimateCameraAction(mapboxMap, + CameraUpdateFactory.newLatLngBounds(builder.build(), 0))); + + CameraPosition cameraPosition = mapboxMap.getCameraPosition(); + assertEquals("Moved camera position latitude should match center bounds", + cameraPosition.target.getLatitude(), + centerBounds.getLatitude(), + TestConstants.LAT_LNG_DELTA); + + assertEquals("Moved camera position longitude should match center bounds", + cameraPosition.target.getLongitude(), + centerBounds.getLongitude(), + TestConstants.LAT_LNG_DELTA); + } + + @Test + public void testAnimateToMoveBy() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + final MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); + + final PointF centerPoint = mapboxMap.getProjection().toScreenLocation(mapboxMap.getCameraPosition().target); + final LatLng moveTarget = new LatLng(2, 2); + final PointF moveTargetPoint = mapboxMap.getProjection().toScreenLocation(moveTarget); + + onView(withId(R.id.mapView)).perform(new AnimateCameraAction(mapboxMap, CameraUpdateFactory.scrollBy( + moveTargetPoint.x - centerPoint.x, moveTargetPoint.y - centerPoint.y))); + + CameraPosition cameraPosition = mapboxMap.getCameraPosition(); + assertEquals("Moved camera position latitude should match", cameraPosition.target.getLatitude(), + moveTarget.getLatitude(), TestConstants.LAT_LNG_DELTA_LARGE); + assertEquals("Moved camera position longitude should match", cameraPosition.target.getLongitude(), + moveTarget.getLongitude(), TestConstants.LAT_LNG_DELTA_LARGE); + } + + @Test + public void testAnimateToZoomIn() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + final MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); + + /*TODO fix zoom #6474*/ + float zoom = 1.0f; + + onView(withId(R.id.mapView)).perform(new AnimateCameraAction(mapboxMap, CameraUpdateFactory.zoomIn())); + CameraPosition cameraPosition = mapboxMap.getCameraPosition(); + assertEquals("Moved camera zoom should match moved camera zoom", cameraPosition.zoom, zoom + 1, + TestConstants.ZOOM_DELTA); + } + + @Test + public void testAnimateToZoomOut() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + final MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); + + /*TODO fix zoom #6474*/ + float zoom = 10.0f; + onView(withId(R.id.mapView)).perform(new AnimateCameraAction(mapboxMap, + CameraUpdateFactory.newLatLngZoom(new LatLng(), zoom))); + onView(withId(R.id.mapView)).perform(new AnimateCameraAction(mapboxMap, CameraUpdateFactory.zoomOut())); + CameraPosition cameraPosition = mapboxMap.getCameraPosition(); + assertEquals("Moved camera zoom should match moved camera zoom", cameraPosition.zoom, zoom - 1, + TestConstants.ZOOM_DELTA); + } + + @Test + public void testAnimateToZoomBy() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + final MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); + + /*TODO fix zoom #6474*/ + float zoom = 1.0f; + final float zoomBy = 2.45f; + + onView(withId(R.id.mapView)).perform(new AnimateCameraAction(mapboxMap, CameraUpdateFactory.zoomBy(zoomBy))); + CameraPosition cameraPosition = mapboxMap.getCameraPosition(); + assertEquals("Moved camera zoom should match moved camera zoom", cameraPosition.zoom, zoom + zoomBy, + TestConstants.ZOOM_DELTA); + } + + @Test + public void testAnimateToZoomTo() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + final MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); + + /*TODO fix zoom #6474*/ + final float zoomTo = 2.45f; + + onView(withId(R.id.mapView)).perform(new AnimateCameraAction(mapboxMap, CameraUpdateFactory.zoomTo(zoomTo))); + CameraPosition cameraPosition = mapboxMap.getCameraPosition(); + assertEquals("Moved camera zoom should match moved camera zoom", cameraPosition.zoom, zoomTo, + TestConstants.ZOOM_DELTA); + } + + @After + public void unregisterIdlingResource() { + Espresso.unregisterIdlingResources(idlingResource); + } + + private class AnimateCameraAction implements ViewAction { + + private MapboxMap mapboxMap; + private CameraUpdate cameraUpdate; + + AnimateCameraAction(MapboxMap map, CameraUpdate update) { + mapboxMap = map; + cameraUpdate = update; + } + + @Override + public Matcher<View> getConstraints() { + return isDisplayed(); + } + + @Override + public String getDescription() { + return getClass().getSimpleName(); + } + + @Override + public void perform(UiController uiController, View view) { + mapboxMap.animateCamera(cameraUpdate); + uiController.loopMainThreadForAtLeast(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 new file mode 100644 index 0000000000..22af72cebb --- /dev/null +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/camera/CameraEaseTest.java @@ -0,0 +1,252 @@ +package com.mapbox.mapboxsdk.testapp.camera; + +import android.graphics.PointF; +import android.support.test.espresso.Espresso; +import android.support.test.espresso.UiController; +import android.support.test.espresso.ViewAction; +import android.support.test.rule.ActivityTestRule; +import android.view.View; + +import com.mapbox.mapboxsdk.camera.CameraPosition; +import com.mapbox.mapboxsdk.camera.CameraUpdate; +import com.mapbox.mapboxsdk.camera.CameraUpdateFactory; +import com.mapbox.mapboxsdk.geometry.LatLng; +import com.mapbox.mapboxsdk.geometry.LatLngBounds; +import com.mapbox.mapboxsdk.maps.MapboxMap; +import com.mapbox.mapboxsdk.testapp.R; +import com.mapbox.mapboxsdk.testapp.activity.espresso.EspressoTestActivity; +import com.mapbox.mapboxsdk.testapp.utils.OnMapReadyIdlingResource; +import com.mapbox.mapboxsdk.testapp.utils.TestConstants; +import com.mapbox.mapboxsdk.testapp.utils.ViewUtils; + +import org.hamcrest.Matcher; +import org.junit.After; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; + +import static android.support.test.espresso.Espresso.onView; +import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed; +import static android.support.test.espresso.matcher.ViewMatchers.withId; +import static org.junit.Assert.assertEquals; + +public class CameraEaseTest { + + @Rule + public final ActivityTestRule<EspressoTestActivity> rule = new ActivityTestRule<>(EspressoTestActivity.class); + + private OnMapReadyIdlingResource idlingResource; + + @Before + public void registerIdlingResource() { + idlingResource = new OnMapReadyIdlingResource(rule.getActivity()); + Espresso.registerIdlingResources(idlingResource); + } + + @Test + public void testEaseToCameraPositionTarget() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + final MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); + + /*TODO remove zoom #6474*/ + float zoom = 1.0f; + LatLng moveTarget = new LatLng(1, 1); + + CameraPosition initialPosition = new CameraPosition.Builder().target( + new LatLng()).zoom(zoom).bearing(0).tilt(0).build(); + CameraPosition cameraPosition = mapboxMap.getCameraPosition(); + assertEquals("Default camera position should match default", cameraPosition, initialPosition); + + onView(withId(R.id.mapView)).perform(new EaseCameraAction(mapboxMap, CameraUpdateFactory.newLatLng(moveTarget))); + cameraPosition = mapboxMap.getCameraPosition(); + assertEquals("Moved camera position latitude should match", cameraPosition.target.getLatitude(), + moveTarget.getLatitude(), TestConstants.LAT_LNG_DELTA); + assertEquals("Moved camera position longitude should match", cameraPosition.target.getLongitude(), + moveTarget.getLongitude(), TestConstants.LAT_LNG_DELTA); + } + + @Test + public void testEaseToCameraPositionTargetZoom() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + final MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); + + final float moveZoom = 15.5f; + final LatLng moveTarget = new LatLng(1.0000000001, 1.0000000003); + + onView(withId(R.id.mapView)).perform(new EaseCameraAction(mapboxMap, + CameraUpdateFactory.newLatLngZoom(moveTarget, moveZoom))); + CameraPosition cameraPosition = mapboxMap.getCameraPosition(); + assertEquals("Moved camera position latitude should match", cameraPosition.target.getLatitude(), + moveTarget.getLatitude(), TestConstants.LAT_LNG_DELTA); + assertEquals("Moved camera position longitude should match", cameraPosition.target.getLongitude(), + moveTarget.getLongitude(), TestConstants.LAT_LNG_DELTA); + assertEquals("Moved zoom should match", cameraPosition.zoom, moveZoom, TestConstants.ZOOM_DELTA); + } + + @Test + public void testEaseToCameraPosition() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + final MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); + + final LatLng moveTarget = new LatLng(1.0000000001, 1.0000000003); + final float moveZoom = 15.5f; + final float moveTilt = 45.5f; + final float moveBearing = 12.5f; + + onView(withId(R.id.mapView)).perform( + new EaseCameraAction(mapboxMap, CameraUpdateFactory.newCameraPosition( + new CameraPosition.Builder() + .target(moveTarget) + .zoom(moveZoom) + .tilt(moveTilt) + .bearing(moveBearing) + .build())) + ); + + CameraPosition cameraPosition = mapboxMap.getCameraPosition(); + assertEquals("Moved camera position latitude should match", cameraPosition.target.getLatitude(), + moveTarget.getLatitude(), TestConstants.LAT_LNG_DELTA); + assertEquals("Moved camera position longitude should match", cameraPosition.target.getLongitude(), + moveTarget.getLongitude(), TestConstants.LAT_LNG_DELTA); + assertEquals("Moved zoom should match", cameraPosition.zoom, moveZoom, TestConstants.ZOOM_DELTA); + assertEquals("Moved zoom should match", cameraPosition.tilt, moveTilt, TestConstants.TILT_DELTA); + assertEquals("Moved bearing should match", cameraPosition.bearing, moveBearing, TestConstants.BEARING_DELTA); + } + + @Test + public void testEaseToBounds() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + final MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); + + final LatLng centerBounds = new LatLng(1, 1); + LatLng cornerOne = new LatLng(); + LatLng cornerTwo = new LatLng(2, 2); + + final LatLngBounds.Builder builder = new LatLngBounds.Builder(); + builder.include(cornerOne); + builder.include(cornerTwo); + + onView(withId(R.id.mapView)).perform(new EaseCameraAction(mapboxMap, + CameraUpdateFactory.newLatLngBounds(builder.build(), 0))); + + CameraPosition cameraPosition = mapboxMap.getCameraPosition(); + assertEquals("Moved camera position latitude should match center bounds", + cameraPosition.target.getLatitude(), + centerBounds.getLatitude(), + TestConstants.LAT_LNG_DELTA); + + assertEquals("Moved camera position longitude should match center bounds", + cameraPosition.target.getLongitude(), + centerBounds.getLongitude(), + TestConstants.LAT_LNG_DELTA); + } + + @Test + public void testEaseToMoveBy() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + final MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); + + final PointF centerPoint = mapboxMap.getProjection().toScreenLocation(mapboxMap.getCameraPosition().target); + final LatLng moveTarget = new LatLng(2, 2); + final PointF moveTargetPoint = mapboxMap.getProjection().toScreenLocation(moveTarget); + + onView(withId(R.id.mapView)).perform(new EaseCameraAction(mapboxMap, CameraUpdateFactory.scrollBy( + moveTargetPoint.x - centerPoint.x, moveTargetPoint.y - centerPoint.y))); + + CameraPosition cameraPosition = mapboxMap.getCameraPosition(); + assertEquals("Moved camera position latitude should match", cameraPosition.target.getLatitude(), + moveTarget.getLatitude(), TestConstants.LAT_LNG_DELTA_LARGE); + assertEquals("Moved camera position longitude should match", cameraPosition.target.getLongitude(), + moveTarget.getLongitude(), TestConstants.LAT_LNG_DELTA_LARGE); + } + + @Test + public void testEaseToZoomIn() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + final MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); + + /*TODO fix zoom #6474*/ + float zoom = 1.0f; + + onView(withId(R.id.mapView)).perform(new EaseCameraAction(mapboxMap, CameraUpdateFactory.zoomIn())); + CameraPosition cameraPosition = mapboxMap.getCameraPosition(); + assertEquals("Moved camera zoom should match moved camera zoom", cameraPosition.zoom, zoom + 1, + TestConstants.ZOOM_DELTA); + } + + @Test + public void testEaseToZoomOut() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + final MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); + + /*TODO fix zoom #6474*/ + float zoom = 10.0f; + onView(withId(R.id.mapView)).perform(new EaseCameraAction(mapboxMap, + CameraUpdateFactory.newLatLngZoom(new LatLng(), zoom))); + onView(withId(R.id.mapView)).perform(new EaseCameraAction(mapboxMap, CameraUpdateFactory.zoomOut())); + CameraPosition cameraPosition = mapboxMap.getCameraPosition(); + assertEquals("Moved camera zoom should match moved camera zoom", 9, cameraPosition.zoom, TestConstants.ZOOM_DELTA); + } + + @Test + public void testEaseToZoomBy() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + final MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); + + /*TODO fix zoom #6474*/ + float zoom = 1.0f; + final float zoomBy = 2.45f; + + onView(withId(R.id.mapView)).perform(new EaseCameraAction(mapboxMap, CameraUpdateFactory.zoomBy(zoomBy))); + CameraPosition cameraPosition = mapboxMap.getCameraPosition(); + assertEquals("Moved camera zoom should match moved camera zoom", cameraPosition.zoom, zoom + zoomBy, + TestConstants.ZOOM_DELTA); + } + + @Test + public void testEaseToZoomTo() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + final MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); + + /*TODO fix zoom #6474*/ + final float zoomTo = 2.45f; + + onView(withId(R.id.mapView)).perform(new EaseCameraAction(mapboxMap, CameraUpdateFactory.zoomTo(zoomTo))); + CameraPosition cameraPosition = mapboxMap.getCameraPosition(); + assertEquals("Moved camera zoom should match moved camera zoom", cameraPosition.zoom, zoomTo, + TestConstants.ZOOM_DELTA); + } + + @After + public void unregisterIdlingResource() { + Espresso.unregisterIdlingResources(idlingResource); + } + + private class EaseCameraAction implements ViewAction { + + private MapboxMap mapboxMap; + private CameraUpdate cameraUpdate; + + EaseCameraAction(MapboxMap map, CameraUpdate update) { + mapboxMap = map; + cameraUpdate = update; + } + + @Override + public Matcher<View> getConstraints() { + return isDisplayed(); + } + + @Override + public String getDescription() { + return getClass().getSimpleName(); + } + + @Override + public void perform(UiController uiController, View view) { + mapboxMap.easeCamera(cameraUpdate); + uiController.loopMainThreadForAtLeast(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 new file mode 100644 index 0000000000..3ca61f7e9d --- /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<EspressoTestActivity> rule = new ActivityTestRule<>(EspressoTestActivity.class); + + private OnMapReadyIdlingResource idlingResource; + + @Before + public void registerIdlingResource() { + idlingResource = new OnMapReadyIdlingResource(rule.getActivity()); + Espresso.registerIdlingResources(idlingResource); + } + + @Test + public void testBearing() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + EspressoTestActivity activity = rule.getActivity(); + MapboxMap mapboxMap = activity.getMapboxMap(); + + CameraPosition initialPosition = new + CameraPosition.Builder().target(new LatLng()).zoom(1).bearing(0).tilt(0).build(); + CameraPosition cameraPosition = mapboxMap.getCameraPosition(); + assertEquals("Default camera position should match default", cameraPosition, initialPosition); + + 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<View> 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<View> 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<View> 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)); + } + } +}
\ No newline at end of file diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/camera/CameraMoveTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/camera/CameraMoveTest.java new file mode 100644 index 0000000000..b3a7fe0d11 --- /dev/null +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/camera/CameraMoveTest.java @@ -0,0 +1,252 @@ +package com.mapbox.mapboxsdk.testapp.camera; + +import android.graphics.PointF; +import android.support.test.espresso.Espresso; +import android.support.test.espresso.UiController; +import android.support.test.espresso.ViewAction; +import android.support.test.rule.ActivityTestRule; +import android.view.View; + +import com.mapbox.mapboxsdk.camera.CameraPosition; +import com.mapbox.mapboxsdk.camera.CameraUpdate; +import com.mapbox.mapboxsdk.camera.CameraUpdateFactory; +import com.mapbox.mapboxsdk.geometry.LatLng; +import com.mapbox.mapboxsdk.geometry.LatLngBounds; +import com.mapbox.mapboxsdk.maps.MapboxMap; +import com.mapbox.mapboxsdk.testapp.R; +import com.mapbox.mapboxsdk.testapp.activity.espresso.EspressoTestActivity; +import com.mapbox.mapboxsdk.testapp.utils.OnMapReadyIdlingResource; +import com.mapbox.mapboxsdk.testapp.utils.TestConstants; +import com.mapbox.mapboxsdk.testapp.utils.ViewUtils; + +import org.hamcrest.Matcher; +import org.junit.After; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; + +import static android.support.test.espresso.Espresso.onView; +import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed; +import static android.support.test.espresso.matcher.ViewMatchers.withId; +import static org.junit.Assert.assertEquals; + +public class CameraMoveTest { + + @Rule + public final ActivityTestRule<EspressoTestActivity> rule = new ActivityTestRule<>(EspressoTestActivity.class); + + private OnMapReadyIdlingResource idlingResource; + + @Before + public void registerIdlingResource() { + idlingResource = new OnMapReadyIdlingResource(rule.getActivity()); + Espresso.registerIdlingResources(idlingResource); + } + + @Test + public void testMoveToCameraPositionTarget() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + final MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); + + /*TODO remove zoom #6474*/ + float zoom = 1.0f; + LatLng moveTarget = new LatLng(1, 1); + + CameraPosition initialPosition = new CameraPosition.Builder().target( + new LatLng()).zoom(zoom).bearing(0).tilt(0).build(); + CameraPosition cameraPosition = mapboxMap.getCameraPosition(); + assertEquals("Default camera position should match default", cameraPosition, initialPosition); + + onView(withId(R.id.mapView)).perform(new MoveCameraAction(mapboxMap, CameraUpdateFactory.newLatLng(moveTarget))); + cameraPosition = mapboxMap.getCameraPosition(); + assertEquals("Moved camera position latitude should match", cameraPosition.target.getLatitude(), + moveTarget.getLatitude(), TestConstants.LAT_LNG_DELTA); + assertEquals("Moved camera position longitude should match", cameraPosition.target.getLongitude(), + moveTarget.getLongitude(), TestConstants.LAT_LNG_DELTA); + } + + @Test + public void testMoveToCameraPositionTargetZoom() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + final MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); + + final float moveZoom = 15.5f; + final LatLng moveTarget = new LatLng(1.0000000001, 1.0000000003); + + onView(withId(R.id.mapView)).perform(new MoveCameraAction(mapboxMap, + CameraUpdateFactory.newLatLngZoom(moveTarget, moveZoom))); + CameraPosition cameraPosition = mapboxMap.getCameraPosition(); + assertEquals("Moved camera position latitude should match", cameraPosition.target.getLatitude(), + moveTarget.getLatitude(), TestConstants.LAT_LNG_DELTA); + assertEquals("Moved camera position longitude should match", cameraPosition.target.getLongitude(), + moveTarget.getLongitude(), TestConstants.LAT_LNG_DELTA); + assertEquals("Moved zoom should match", cameraPosition.zoom, moveZoom, TestConstants.ZOOM_DELTA); + } + + @Test + public void testMoveToCameraPosition() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + final MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); + + final LatLng moveTarget = new LatLng(1.0000000001, 1.0000000003); + final float moveZoom = 15.5f; + final float moveTilt = 45.5f; + final float moveBearing = 12.5f; + + onView(withId(R.id.mapView)).perform( + new MoveCameraAction(mapboxMap, CameraUpdateFactory.newCameraPosition( + new CameraPosition.Builder() + .target(moveTarget) + .zoom(moveZoom) + .tilt(moveTilt) + .bearing(moveBearing) + .build())) + ); + + CameraPosition cameraPosition = mapboxMap.getCameraPosition(); + assertEquals("Moved camera position latitude should match", cameraPosition.target.getLatitude(), + moveTarget.getLatitude(), TestConstants.LAT_LNG_DELTA); + assertEquals("Moved camera position longitude should match", cameraPosition.target.getLongitude(), + moveTarget.getLongitude(), TestConstants.LAT_LNG_DELTA); + assertEquals("Moved zoom should match", cameraPosition.zoom, moveZoom, TestConstants.ZOOM_DELTA); + assertEquals("Moved zoom should match", cameraPosition.tilt, moveTilt, TestConstants.TILT_DELTA); + assertEquals("Moved bearing should match", cameraPosition.bearing, moveBearing, TestConstants.BEARING_DELTA); + } + + @Test + public void testMoveToBounds() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + final MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); + + final LatLng centerBounds = new LatLng(1, 1); + LatLng cornerOne = new LatLng(); + LatLng cornerTwo = new LatLng(2, 2); + + final LatLngBounds.Builder builder = new LatLngBounds.Builder(); + builder.include(cornerOne); + builder.include(cornerTwo); + + onView(withId(R.id.mapView)).perform(new MoveCameraAction(mapboxMap, + CameraUpdateFactory.newLatLngBounds(builder.build(), 0))); + + CameraPosition cameraPosition = mapboxMap.getCameraPosition(); + assertEquals("Moved camera position latitude should match center bounds", + cameraPosition.target.getLatitude(), + centerBounds.getLatitude(), + TestConstants.LAT_LNG_DELTA); + + assertEquals("Moved camera position longitude should match center bounds", + cameraPosition.target.getLongitude(), + centerBounds.getLongitude(), + TestConstants.LAT_LNG_DELTA); + } + + @Test + public void testMoveToMoveBy() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + final MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); + + final PointF centerPoint = mapboxMap.getProjection().toScreenLocation(mapboxMap.getCameraPosition().target); + final LatLng moveTarget = new LatLng(2, 2); + final PointF moveTargetPoint = mapboxMap.getProjection().toScreenLocation(moveTarget); + + onView(withId(R.id.mapView)).perform(new MoveCameraAction(mapboxMap, CameraUpdateFactory.scrollBy( + moveTargetPoint.x - centerPoint.x, moveTargetPoint.y - centerPoint.y))); + + CameraPosition cameraPosition = mapboxMap.getCameraPosition(); + assertEquals("Moved camera position latitude should match", cameraPosition.target.getLatitude(), + moveTarget.getLatitude(), TestConstants.LAT_LNG_DELTA_LARGE); + assertEquals("Moved camera position longitude should match", cameraPosition.target.getLongitude(), + moveTarget.getLongitude(), TestConstants.LAT_LNG_DELTA_LARGE); + } + + @Test + public void testMoveToZoomIn() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + final MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); + + /*TODO fix zoom #6474*/ + float zoom = 1.0f; + + onView(withId(R.id.mapView)).perform(new MoveCameraAction(mapboxMap, CameraUpdateFactory.zoomIn())); + CameraPosition cameraPosition = mapboxMap.getCameraPosition(); + assertEquals("Moved camera zoom should match moved camera zoom", cameraPosition.zoom, zoom + 1, + TestConstants.ZOOM_DELTA); + } + + @Test + public void testMoveToZoomOut() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + final MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); + + /*TODO fix zoom #6474*/ + float zoom = 10.0f; + onView(withId(R.id.mapView)).perform(new MoveCameraAction(mapboxMap, + CameraUpdateFactory.newLatLngZoom(new LatLng(), zoom))); + onView(withId(R.id.mapView)).perform(new MoveCameraAction(mapboxMap, CameraUpdateFactory.zoomOut())); + CameraPosition cameraPosition = mapboxMap.getCameraPosition(); + assertEquals("Moved camera zoom should match moved camera zoom", cameraPosition.zoom, zoom - 1, + TestConstants.ZOOM_DELTA); + } + + @Test + public void testMoveToZoomBy() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + final MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); + + /*TODO fix zoom #6474*/ + float zoom = 1.0f; + final float zoomBy = 2.45f; + + onView(withId(R.id.mapView)).perform(new MoveCameraAction(mapboxMap, CameraUpdateFactory.zoomBy(zoomBy))); + CameraPosition cameraPosition = mapboxMap.getCameraPosition(); + assertEquals("Moved camera zoom should match moved camera zoom", cameraPosition.zoom, zoom + zoomBy, + TestConstants.ZOOM_DELTA); + } + + @Test + public void testMoveToZoomTo() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + final MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); + + /*TODO fix zoom #6474*/ + final float zoomTo = 2.45f; + + onView(withId(R.id.mapView)).perform(new MoveCameraAction(mapboxMap, CameraUpdateFactory.zoomTo(zoomTo))); + CameraPosition cameraPosition = mapboxMap.getCameraPosition(); + assertEquals("Moved camera zoom should match moved camera zoom", cameraPosition.zoom, zoomTo, + TestConstants.ZOOM_DELTA); + } + + @After + public void unregisterIdlingResource() { + Espresso.unregisterIdlingResources(idlingResource); + } + + private class MoveCameraAction implements ViewAction { + + private MapboxMap mapboxMap; + private CameraUpdate cameraUpdate; + + MoveCameraAction(MapboxMap map, CameraUpdate update) { + mapboxMap = map; + cameraUpdate = update; + } + + @Override + public Matcher<View> getConstraints() { + return isDisplayed(); + } + + @Override + public String getDescription() { + return getClass().getSimpleName(); + } + + @Override + public void perform(UiController uiController, View view) { + mapboxMap.moveCamera(cameraUpdate); + uiController.loopMainThreadForAtLeast(100); + } + } +} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/camera/RotateActivityTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/camera/RotateActivityTest.java deleted file mode 100644 index edef97027e..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/camera/RotateActivityTest.java +++ /dev/null @@ -1,62 +0,0 @@ -package com.mapbox.mapboxsdk.testapp.camera; - -import android.support.test.espresso.UiController; -import android.support.test.espresso.ViewAction; -import android.view.View; - -import com.mapbox.mapboxsdk.maps.MapView; -import com.mapbox.mapboxsdk.maps.MapboxMapUtils; -import com.mapbox.mapboxsdk.testapp.R; -import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest; -import com.mapbox.mapboxsdk.testapp.activity.infowindow.InfoWindowActivity; - -import org.hamcrest.Matcher; -import org.junit.Test; - -import static android.support.test.espresso.Espresso.onView; -import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed; -import static android.support.test.espresso.matcher.ViewMatchers.withId; - -public class RotateActivityTest extends BaseActivityTest { - - @Test - // longer testing change second param - public void testRotate() { - onView(withId(R.id.mapView)).perform(new RotateAction(0, 1)); - } - - @Override - public Class getActivityClass() { - return InfoWindowActivity.class; - } - - private class RotateAction implements ViewAction { - - private float startDegree; - private float endDegree; - - public RotateAction(float startDegree, float endDegree) { - this.startDegree = startDegree; - this.endDegree = endDegree; - } - - @Override - public Matcher<View> getConstraints() { - return isDisplayed(); - } - - @Override - public String getDescription() { - return "rotateAction"; - } - - @Override - public void perform(UiController uiController, View view) { - uiController.loopMainThreadForAtLeast(500); - for (float i = startDegree; i < endDegree; i++) { - MapboxMapUtils.setDirection((MapView) view, i); - uiController.loopMainThreadForAtLeast(1); - } - } - } -} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/camera/TiltActivityTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/camera/TiltActivityTest.java deleted file mode 100644 index 8f21f60fb0..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/camera/TiltActivityTest.java +++ /dev/null @@ -1,62 +0,0 @@ -package com.mapbox.mapboxsdk.testapp.camera; - -import android.support.test.espresso.UiController; -import android.support.test.espresso.ViewAction; -import android.view.View; - -import com.mapbox.mapboxsdk.maps.MapView; -import com.mapbox.mapboxsdk.maps.MapboxMapUtils; -import com.mapbox.mapboxsdk.testapp.R; -import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest; -import com.mapbox.mapboxsdk.testapp.activity.annotation.DynamicMarkerChangeActivity; - -import org.hamcrest.Matcher; -import org.junit.Test; - -import static android.support.test.espresso.Espresso.onView; -import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed; -import static android.support.test.espresso.matcher.ViewMatchers.withId; - -public class TiltActivityTest extends BaseActivityTest { - - @Test - // longer testing change param - public void testTilt() { - onView(withId(R.id.mapView)).perform(new TiltAction(0, 1)); - } - - @Override - public Class getActivityClass() { - return DynamicMarkerChangeActivity.class; - } - - private class TiltAction implements ViewAction { - - private float startDegree; - private float endDegree; - - public TiltAction(float startDegree, float endDegree) { - this.startDegree = startDegree; - this.endDegree = endDegree; - } - - @Override - public Matcher<View> getConstraints() { - return isDisplayed(); - } - - @Override - public String getDescription() { - return "tiltAction"; - } - - @Override - public void perform(UiController uiController, View view) { - uiController.loopMainThreadForAtLeast(500); - for (float i = startDegree; i < endDegree; i++) { - MapboxMapUtils.setTilt((MapView) view, i); - uiController.loopMainThreadForAtLeast(1); - } - } - } -} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/camera/ZoomActivityTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/camera/ZoomActivityTest.java deleted file mode 100644 index 700e8f6c5c..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/camera/ZoomActivityTest.java +++ /dev/null @@ -1,71 +0,0 @@ -package com.mapbox.mapboxsdk.testapp.camera; - -import android.support.test.espresso.UiController; -import android.support.test.espresso.ViewAction; -import android.view.View; - -import com.mapbox.mapboxsdk.camera.CameraPosition; -import com.mapbox.mapboxsdk.camera.CameraUpdateFactory; -import com.mapbox.mapboxsdk.constants.MapboxConstants; -import com.mapbox.mapboxsdk.geometry.LatLng; -import com.mapbox.mapboxsdk.testapp.R; -import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest; -import com.mapbox.mapboxsdk.testapp.activity.maplayout.DebugModeActivity; - -import org.hamcrest.Matcher; -import org.junit.Test; - -import static android.support.test.espresso.Espresso.onView; -import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed; -import static android.support.test.espresso.matcher.ViewMatchers.withId; - -public class ZoomActivityTest extends BaseActivityTest { - - @Test - // longer testing increase second param - public void testZoom() throws Exception { - onView(withId(R.id.mapView)).perform(new ZoomAction(MapboxConstants.MINIMUM_ZOOM, MapboxConstants.MINIMUM_ZOOM - 1)); - } - - @Override - public Class getActivityClass() { - return DebugModeActivity.class; - } - - private class ZoomAction implements ViewAction { - - private float fromZoom; - private float toZoom; - - public ZoomAction(float fromZoom, float toZoom) { - this.fromZoom = fromZoom; - this.toZoom = toZoom; - } - - @Override - public Matcher<View> getConstraints() { - return isDisplayed(); - } - - @Override - public String getDescription() { - return "zoomAction"; - } - - @Override - public void perform(UiController uiController, View view) { - // move camera above denver - mapboxMap.moveCamera(CameraUpdateFactory.newCameraPosition( - new CameraPosition.Builder() - .target(new LatLng(39.749750, -104.949559)) - .build())); - - uiController.loopMainThreadForAtLeast(500); - - for (float i = fromZoom; i < toZoom; i++) { - mapboxMap.animateCamera(CameraUpdateFactory.zoomTo(i)); - uiController.loopMainThreadForAtLeast(200); - } - } - } -} 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 new file mode 100644 index 0000000000..b4be73be7a --- /dev/null +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/feature/QueryRenderedFeaturesBoxCountTest.java @@ -0,0 +1,61 @@ +package com.mapbox.mapboxsdk.testapp.feature; + +import android.support.test.espresso.Espresso; +import android.support.test.rule.ActivityTestRule; + +import com.mapbox.mapboxsdk.testapp.R; +import com.mapbox.mapboxsdk.testapp.activity.feature.QueryRenderedFeaturesBoxCountActivity; +import com.mapbox.mapboxsdk.testapp.utils.OnMapReadyIdlingResource; + +import org.junit.After; +import org.junit.Before; +import org.junit.Ignore; +import org.junit.Rule; +import org.junit.Test; + +import static android.support.test.espresso.Espresso.onView; +import static android.support.test.espresso.action.ViewActions.click; +import static android.support.test.espresso.assertion.ViewAssertions.matches; +import static android.support.test.espresso.matcher.RootMatchers.withDecorView; +import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed; +import static android.support.test.espresso.matcher.ViewMatchers.withId; +import static android.support.test.espresso.matcher.ViewMatchers.withText; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.not; + +/** + * Instrumentation test to validate if clicking on the blue rectangle from + * QueryRenderedFeaturesBoxSymbolCountActivity shows a Toast that 149 features were found. + */ +public class QueryRenderedFeaturesBoxCountTest { + + @Rule + public final ActivityTestRule<QueryRenderedFeaturesBoxCountActivity> 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 new file mode 100644 index 0000000000..b8cd46e612 --- /dev/null +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/feature/QueryRenderedFeaturesHighlightTest.java @@ -0,0 +1,81 @@ +package com.mapbox.mapboxsdk.testapp.feature; + +import android.support.test.espresso.Espresso; +import android.support.test.espresso.ViewAction; +import android.support.test.espresso.action.CoordinatesProvider; +import android.support.test.espresso.action.GeneralClickAction; +import android.support.test.espresso.action.Press; +import android.support.test.espresso.action.Tap; +import android.support.test.rule.ActivityTestRule; +import android.view.View; + +import com.mapbox.mapboxsdk.testapp.R; +import com.mapbox.mapboxsdk.testapp.activity.feature.QueryRenderedFeaturesBoxHighlightActivity; +import com.mapbox.mapboxsdk.testapp.utils.OnMapReadyIdlingResource; + +import org.junit.After; +import org.junit.Before; +import org.junit.Ignore; +import org.junit.Rule; +import org.junit.Test; + +import static android.support.test.espresso.Espresso.onView; +import static android.support.test.espresso.action.ViewActions.click; +import static android.support.test.espresso.assertion.ViewAssertions.matches; +import static android.support.test.espresso.matcher.RootMatchers.withDecorView; +import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed; +import static android.support.test.espresso.matcher.ViewMatchers.withId; +import static android.support.test.espresso.matcher.ViewMatchers.withText; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.not; + +/** + * Instrumentation test to validate if clicking box on screen highlights features. + */ +public class QueryRenderedFeaturesHighlightTest { + + @Rule + public final ActivityTestRule<QueryRenderedFeaturesBoxHighlightActivity> rule = + new ActivityTestRule<>(QueryRenderedFeaturesBoxHighlightActivity.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("50 features in box")) + .inRoot(withDecorView(not(is(rule.getActivity().getWindow().getDecorView())))) + .check(matches(isDisplayed())); + } + + @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); + } +}
\ 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 new file mode 100644 index 0000000000..3b86397603 --- /dev/null +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/feature/QueryRenderedFeaturesPropertiesTest.java @@ -0,0 +1,78 @@ +package com.mapbox.mapboxsdk.testapp.feature; + +import android.graphics.PointF; +import android.support.test.espresso.Espresso; +import android.support.test.espresso.ViewAction; +import android.support.test.espresso.action.CoordinatesProvider; +import android.support.test.espresso.action.GeneralClickAction; +import android.support.test.espresso.action.Press; +import android.support.test.espresso.action.Tap; +import android.support.test.rule.ActivityTestRule; +import android.view.View; + +import com.mapbox.mapboxsdk.geometry.LatLng; +import com.mapbox.mapboxsdk.maps.MapboxMap; +import com.mapbox.mapboxsdk.testapp.R; +import com.mapbox.mapboxsdk.testapp.activity.feature.QueryRenderedFeaturesPropertiesActivity; +import com.mapbox.mapboxsdk.testapp.utils.OnMapReadyIdlingResource; + +import org.junit.After; +import org.junit.Before; +import org.junit.Ignore; +import org.junit.Rule; +import org.junit.Test; + +import static android.support.test.espresso.Espresso.onView; +import static android.support.test.espresso.assertion.ViewAssertions.matches; +import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed; +import static android.support.test.espresso.matcher.ViewMatchers.withId; +import static android.support.test.espresso.matcher.ViewMatchers.withText; + +/** + * Instrumentation test to validate if clicking center of screen returns the correct features. + */ +public class QueryRenderedFeaturesPropertiesTest { + + @Rule + public final ActivityTestRule<QueryRenderedFeaturesPropertiesActivity> rule = + new ActivityTestRule<>(QueryRenderedFeaturesPropertiesActivity.class); + + private OnMapReadyIdlingResource 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())); + } + + @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); + } +}
\ 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 new file mode 100644 index 0000000000..ea80e8689a --- /dev/null +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/feature/QueryRenderedSymbolBoxCountTest.java @@ -0,0 +1,62 @@ +package com.mapbox.mapboxsdk.testapp.feature; + +import android.support.test.espresso.Espresso; +import android.support.test.rule.ActivityTestRule; + +import com.mapbox.mapboxsdk.testapp.R; +import com.mapbox.mapboxsdk.testapp.activity.feature.QueryRenderedFeaturesBoxSymbolCountActivity; +import com.mapbox.mapboxsdk.testapp.utils.OnMapReadyIdlingResource; + +import org.junit.After; +import org.junit.Before; +import org.junit.Ignore; +import org.junit.Rule; +import org.junit.Test; + +import static android.support.test.espresso.Espresso.onView; +import static android.support.test.espresso.action.ViewActions.click; +import static android.support.test.espresso.assertion.ViewAssertions.matches; +import static android.support.test.espresso.matcher.RootMatchers.withDecorView; +import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed; +import static android.support.test.espresso.matcher.ViewMatchers.withId; +import static android.support.test.espresso.matcher.ViewMatchers.withText; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.not; + +/** + * Instrumentation test to validate if clicking on the blue rectangle from + * QueryRenderedFeaturesBoxSymbolCountActivity shows a Toast that 2 symbols were found. + */ +public class QueryRenderedSymbolBoxCountTest { + + @Rule + public final ActivityTestRule<QueryRenderedFeaturesBoxSymbolCountActivity> 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 new file mode 100644 index 0000000000..fa1451092a --- /dev/null +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/widgets/AttributionTest.java @@ -0,0 +1,156 @@ +package com.mapbox.mapboxsdk.testapp.maps.widgets; + +import android.app.Instrumentation; +import android.content.Intent; +import android.net.Uri; +import android.support.test.espresso.Espresso; +import android.support.test.espresso.UiController; +import android.support.test.espresso.ViewAction; +import android.support.test.espresso.intent.Intents; +import android.support.test.rule.ActivityTestRule; +import android.view.View; + +import com.mapbox.mapboxsdk.maps.MapboxMap; +import com.mapbox.mapboxsdk.testapp.R; +import com.mapbox.mapboxsdk.testapp.activity.espresso.EspressoTestActivity; +import com.mapbox.mapboxsdk.testapp.utils.OnMapReadyIdlingResource; +import com.mapbox.mapboxsdk.testapp.utils.ViewUtils; + +import org.hamcrest.Matcher; +import org.junit.After; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; + +import static android.support.test.espresso.Espresso.onView; +import static android.support.test.espresso.action.ViewActions.click; +import static android.support.test.espresso.assertion.ViewAssertions.matches; +import static android.support.test.espresso.intent.Intents.intended; +import static android.support.test.espresso.intent.Intents.intending; +import static android.support.test.espresso.intent.matcher.IntentMatchers.hasAction; +import static android.support.test.espresso.intent.matcher.IntentMatchers.hasData; +import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed; +import static android.support.test.espresso.matcher.ViewMatchers.withId; +import static android.support.test.espresso.matcher.ViewMatchers.withText; +import static org.hamcrest.Matchers.allOf; +import static org.hamcrest.core.IsNot.not; + +public class AttributionTest { + + @Rule + public final ActivityTestRule<EspressoTestActivity> rule = new ActivityTestRule<>(EspressoTestActivity.class); + + private OnMapReadyIdlingResource idlingResource; + + private String[] dialogTexts; + private String[] dialogLinks; + + @Before + public void beforeTest() { + idlingResource = new OnMapReadyIdlingResource(rule.getActivity()); + Espresso.registerIdlingResources(idlingResource); + Intents.init(); + dialogTexts = rule.getActivity().getResources().getStringArray(R.array.mapbox_attribution_names); + dialogLinks = rule.getActivity().getResources().getStringArray(R.array.mapbox_attribution_links); + } + + @Test + public void testDisabled() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); + + // Default + onView(withId(R.id.attributionView)).check(matches(isDisplayed())); + + // Disabled + onView(withId(R.id.attributionView)) + .perform(new DisableAction(mapboxMap)) + .check(matches(not(isDisplayed()))); + } + + @Test + public void testMapboxLink() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + + // click on View to open dialog + onView(withId(R.id.attributionView)).perform(click()); + onView(withText(R.string.mapbox_attributionsDialogTitle)).check(matches(isDisplayed())); + + // click on link and validate browser opening + Matcher<Intent> expectedIntent = allOf(hasAction(Intent.ACTION_VIEW), hasData(Uri.parse(dialogLinks[0]))); + intending(expectedIntent).respondWith(new Instrumentation.ActivityResult(0, null)); + onView(withText(dialogTexts[0])).perform(click()); + intended(expectedIntent); + } + + @Test + public void testOpenStreetMapLink() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + + // click on View to open dialog + onView(withId(R.id.attributionView)).perform(click()); + onView(withText(R.string.mapbox_attributionsDialogTitle)).check(matches(isDisplayed())); + + // click on link and validate browser opening + Matcher<Intent> expectedIntent = allOf(hasAction(Intent.ACTION_VIEW), hasData(Uri.parse(dialogLinks[1]))); + intending(expectedIntent).respondWith(new Instrumentation.ActivityResult(0, null)); + onView(withText(dialogTexts[1])).perform(click()); + } + + @Test + public void testImproveMapLink() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + + // click on View to open dialog + onView(withId(R.id.attributionView)).perform(click()); + onView(withText(R.string.mapbox_attributionsDialogTitle)).check(matches(isDisplayed())); + + // click on Mapbox link and validate browser opening + Matcher<Intent> expectedIntent = allOf(hasAction(Intent.ACTION_VIEW), hasData(Uri.parse(dialogLinks[3]))); + intending(expectedIntent).respondWith(new Instrumentation.ActivityResult(0, null)); + onView(withText(dialogTexts[3])).perform(click()); + } + + @Test + public void testTelemetryDialog() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + + // click on View to open dialog + onView(withId(R.id.attributionView)).perform(click()); + onView(withText(R.string.mapbox_attributionsDialogTitle)).check(matches(isDisplayed())); + + // click on item to open second dialog + onView(withText(dialogTexts[3])).perform(click()); + onView(withText(R.string.mapbox_attributionTelemetryTitle)).check(matches(isDisplayed())); + } + + @After + public void afterTest() { + Intents.release(); + Espresso.unregisterIdlingResources(idlingResource); + } + + private class DisableAction implements ViewAction { + + private MapboxMap mapboxMap; + + DisableAction(MapboxMap map) { + mapboxMap = map; + } + + @Override + public Matcher<View> getConstraints() { + return isDisplayed(); + } + + @Override + public String getDescription() { + return getClass().getSimpleName(); + } + + @Override + public void perform(UiController uiController, View view) { + mapboxMap.getUiSettings().setAttributionEnabled(false); + } + } +} 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 new file mode 100644 index 0000000000..02fec41f65 --- /dev/null +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/widgets/CompassViewTest.java @@ -0,0 +1,153 @@ +package com.mapbox.mapboxsdk.testapp.maps.widgets; + +import android.support.test.espresso.Espresso; +import android.support.test.espresso.UiController; +import android.support.test.espresso.ViewAction; +import android.support.test.rule.ActivityTestRule; +import android.view.View; + +import com.mapbox.mapboxsdk.camera.CameraPosition; +import com.mapbox.mapboxsdk.camera.CameraUpdate; +import com.mapbox.mapboxsdk.camera.CameraUpdateFactory; +import com.mapbox.mapboxsdk.geometry.LatLng; +import com.mapbox.mapboxsdk.maps.MapboxMap; +import com.mapbox.mapboxsdk.testapp.R; +import com.mapbox.mapboxsdk.testapp.activity.espresso.EspressoTestActivity; +import com.mapbox.mapboxsdk.testapp.utils.OnMapReadyIdlingResource; +import com.mapbox.mapboxsdk.testapp.utils.TestConstants; +import com.mapbox.mapboxsdk.testapp.utils.ViewUtils; + +import org.hamcrest.Matcher; +import org.junit.After; +import org.junit.Before; +import org.junit.Ignore; +import org.junit.Rule; +import org.junit.Test; + +import static android.support.test.espresso.Espresso.onView; +import static android.support.test.espresso.action.ViewActions.click; +import static android.support.test.espresso.assertion.ViewAssertions.matches; +import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed; +import static android.support.test.espresso.matcher.ViewMatchers.withId; +import static org.hamcrest.Matchers.not; +import static org.junit.Assert.assertEquals; + +public class CompassViewTest { + + @Rule + public final ActivityTestRule<EspressoTestActivity> rule = new ActivityTestRule<>(EspressoTestActivity.class); + + private OnMapReadyIdlingResource idlingResource; + + @Before + public void registerIdlingResource() { + idlingResource = new OnMapReadyIdlingResource(rule.getActivity()); + Espresso.registerIdlingResources(idlingResource); + } + + @Test + public void testDefault() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + onView(withId(R.id.compassView)).check(matches(not(isDisplayed()))); + } + + @Test + public void testVisible() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); + + onView(withId(R.id.mapView)).perform(new MoveCameraAction(mapboxMap, + CameraUpdateFactory.newCameraPosition( + new CameraPosition.Builder() + .bearing(45) + .zoom(1) + .target(new LatLng()) + .build() + ) + ) + ); + + onView(withId(R.id.compassView)).check(matches(isDisplayed())); + } + + @Test + @Ignore // 10-31-2016 click action is not working + public void testClick() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); + + onView(withId(R.id.mapView)).perform(new MoveCameraAction(mapboxMap, + CameraUpdateFactory.newCameraPosition( + new CameraPosition.Builder() + .bearing(45) + .zoom(1) + .target(new LatLng()) + .build() + ) + ) + ); + + onView(withId(R.id.compassView)).perform(click()); + onView(withId(R.id.mapView)).perform(new WaitAction(3000)); + onView(withId(R.id.compassView)).check(matches(not(isDisplayed()))); + + CameraPosition cameraPosition = mapboxMap.getCameraPosition(); + assertEquals("Camera bearing should face north, ", 0, cameraPosition.bearing, TestConstants.BEARING_DELTA); + } + + @After + public void unregisterIdlingResource() { + Espresso.unregisterIdlingResources(idlingResource); + } + + private class WaitAction implements ViewAction { + + private long waitTime; + + WaitAction(long waitTime) { + this.waitTime = waitTime; + } + + @Override + public Matcher<View> getConstraints() { + return isDisplayed(); + } + + @Override + public String getDescription() { + return getClass().getSimpleName(); + } + + @Override + public void perform(UiController uiController, View view) { + uiController.loopMainThreadForAtLeast(waitTime); + } + } + + private class MoveCameraAction implements ViewAction { + + private MapboxMap mapboxMap; + private CameraUpdate cameraUpdate; + + MoveCameraAction(MapboxMap map, CameraUpdate update) { + mapboxMap = map; + cameraUpdate = update; + } + + @Override + public Matcher<View> getConstraints() { + return isDisplayed(); + } + + @Override + public String getDescription() { + return getClass().getSimpleName(); + } + + @Override + public void perform(UiController uiController, View view) { + mapboxMap.moveCamera(cameraUpdate); + } + } +} + 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 new file mode 100644 index 0000000000..f12b2bf160 --- /dev/null +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/widgets/LogoTest.java @@ -0,0 +1,84 @@ +package com.mapbox.mapboxsdk.testapp.maps.widgets; + +import android.support.test.espresso.Espresso; +import android.support.test.espresso.UiController; +import android.support.test.espresso.ViewAction; +import android.support.test.rule.ActivityTestRule; +import android.view.View; + +import com.mapbox.mapboxsdk.maps.MapboxMap; +import com.mapbox.mapboxsdk.testapp.R; +import com.mapbox.mapboxsdk.testapp.activity.espresso.EspressoTestActivity; +import com.mapbox.mapboxsdk.testapp.utils.OnMapReadyIdlingResource; +import com.mapbox.mapboxsdk.testapp.utils.ViewUtils; + +import org.hamcrest.Matcher; +import org.junit.After; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; + +import static android.support.test.espresso.Espresso.onView; +import static android.support.test.espresso.assertion.ViewAssertions.matches; +import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed; +import static android.support.test.espresso.matcher.ViewMatchers.withId; +import static org.hamcrest.Matchers.not; + +public class LogoTest { + + @Rule + public final ActivityTestRule<EspressoTestActivity> rule = new ActivityTestRule<>(EspressoTestActivity.class); + + private OnMapReadyIdlingResource idlingResource; + + @Before + public void registerIdlingResource() { + idlingResource = new OnMapReadyIdlingResource(rule.getActivity()); + Espresso.registerIdlingResources(idlingResource); + } + + @Test + public void testDefault() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + onView(withId(R.id.logoView)).check(matches(isDisplayed())); + } + + @Test + public void testDisabled() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); + + onView(withId(R.id.logoView)) + .perform(new DisableAction(mapboxMap)) + .check(matches(not(isDisplayed()))); + } + + @After + public void unregisterIdlingResource() { + Espresso.unregisterIdlingResources(idlingResource); + } + + private class DisableAction implements ViewAction { + + private MapboxMap mapboxMap; + + DisableAction(MapboxMap map) { + mapboxMap = map; + } + + @Override + public Matcher<View> getConstraints() { + return isDisplayed(); + } + + @Override + public String getDescription() { + return getClass().getSimpleName(); + } + + @Override + public void perform(UiController uiController, View view) { + mapboxMap.getUiSettings().setLogoEnabled(false); + } + } +} 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 new file mode 100644 index 0000000000..ac10d11922 --- /dev/null +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/widgets/MyLocationViewTest.java @@ -0,0 +1,246 @@ +package com.mapbox.mapboxsdk.testapp.maps.widgets; + +import android.content.res.Resources; +import android.graphics.Bitmap; +import android.graphics.Canvas; +import android.graphics.drawable.BitmapDrawable; +import android.graphics.drawable.Drawable; +import android.support.test.espresso.Espresso; +import android.support.test.espresso.UiController; +import android.support.test.espresso.ViewAction; +import android.support.test.rule.ActivityTestRule; +import android.view.View; + +import com.mapbox.mapboxsdk.camera.CameraPosition; +import com.mapbox.mapboxsdk.camera.CameraUpdateFactory; +import com.mapbox.mapboxsdk.constants.MyBearingTracking; +import com.mapbox.mapboxsdk.constants.MyLocationTracking; +import com.mapbox.mapboxsdk.geometry.LatLng; +import com.mapbox.mapboxsdk.location.LocationServices; +import com.mapbox.mapboxsdk.maps.MapboxMap; +import com.mapbox.mapboxsdk.maps.widgets.MyLocationView; +import com.mapbox.mapboxsdk.testapp.R; +import com.mapbox.mapboxsdk.testapp.activity.espresso.EspressoTestActivity; +import com.mapbox.mapboxsdk.testapp.utils.OnMapReadyIdlingResource; +import com.mapbox.mapboxsdk.testapp.utils.ViewUtils; + +import org.hamcrest.Description; +import org.hamcrest.Matcher; +import org.hamcrest.TypeSafeMatcher; +import org.junit.After; +import org.junit.Before; +import org.junit.Ignore; +import org.junit.Rule; +import org.junit.Test; + +import static android.support.test.espresso.Espresso.onView; +import static android.support.test.espresso.assertion.ViewAssertions.matches; +import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed; +import static android.support.test.espresso.matcher.ViewMatchers.withId; +import static org.hamcrest.Matchers.not; + +/** + * Experimental MyLocationView tests, + * requires application to be granted with runtime location permissions. + * <p> + * Tests for enabling and disabling the {@link MyLocationView}. + * Tests for enabling tracking modes and if the correct default images are shown when toggling + * {@link com.mapbox.mapboxsdk.maps.TrackingSettings#setMyLocationTrackingMode(int)} & + * {@link com.mapbox.mapboxsdk.maps.TrackingSettings#setMyBearingTrackingMode(int)}. + * </p> + */ +public class MyLocationViewTest { + + @Rule + public final ActivityTestRule<EspressoTestActivity> rule = new ActivityTestRule<>(EspressoTestActivity.class); + + private OnMapReadyIdlingResource idlingResource; + + @Before + public void beforeTest() { + idlingResource = new OnMapReadyIdlingResource(rule.getActivity()); + Espresso.registerIdlingResources(idlingResource); + } + + @Test + @Ignore // requires runtime permissions, disabled for CI + public void testEnabled() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); + onView(withId(R.id.userLocationView)).check(matches(not(isDisplayed()))); + onView(withId(R.id.mapView)).perform(new ToggleLocationAction(mapboxMap, true)); + onView(withId(R.id.userLocationView)).check(matches(isDisplayed())); + onView(withId(R.id.mapView)).perform(new ToggleLocationAction(mapboxMap, false)); + onView(withId(R.id.userLocationView)).check(matches(not(isDisplayed()))); + } + + @Test + @Ignore + // requires runtime permissions, disabled for CI + issue with android.support.test.espresso.AppNotIdleException: + // Looped for 5049 iterations over 60 SECONDS. + public void testTracking() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); + onView(withId(R.id.userLocationView)).check(matches(not(isDisplayed()))); + onView(withId(R.id.mapView)).perform(new EnableLocationTrackingAction(mapboxMap)); + onView(withId(R.id.userLocationView)).check(matches(isDisplayed())); + onView(withId(R.id.userLocationView)).check(matches(new DrawableMatcher(mapboxMap, + R.drawable.mapbox_mylocation_icon_default, false))); + onView(withId(R.id.mapView)).perform(new EnableCompassBearingTrackingAction(mapboxMap)); + onView(withId(R.id.userLocationView)).check(matches(new DrawableMatcher(mapboxMap, + R.drawable.mapbox_mylocation_icon_bearing, true))); + } + + @After + public void afterTest() { + Espresso.unregisterIdlingResources(idlingResource); + } + + private class ToggleLocationAction implements ViewAction { + + private MapboxMap mapboxMap; + private boolean isEnabled; + + ToggleLocationAction(MapboxMap map, boolean enable) { + mapboxMap = map; + isEnabled = enable; + } + + @Override + public Matcher<View> getConstraints() { + return isDisplayed(); + } + + @Override + public String getDescription() { + return getClass().getSimpleName(); + } + + @Override + public void perform(UiController uiController, View view) { + if (isEnabled) { + // move camera above user location + mapboxMap.moveCamera( + CameraUpdateFactory.newCameraPosition( + new CameraPosition.Builder() + .target(new LatLng(LocationServices.getLocationServices(view.getContext()).getLastLocation())) + .build() + ) + ); + } + + // show loction on screen + mapboxMap.setMyLocationEnabled(isEnabled); + } + } + + private class EnableLocationTrackingAction implements ViewAction { + + private MapboxMap mapboxMap; + + EnableLocationTrackingAction(MapboxMap map) { + mapboxMap = map; + } + + @Override + public Matcher<View> getConstraints() { + return isDisplayed(); + } + + @Override + public String getDescription() { + return getClass().getSimpleName(); + } + + @Override + public void perform(UiController uiController, View view) { + mapboxMap.getTrackingSettings().setMyLocationTrackingMode(MyLocationTracking.TRACKING_FOLLOW); + } + } + + private class EnableCompassBearingTrackingAction implements ViewAction { + + private MapboxMap mapboxMap; + + EnableCompassBearingTrackingAction(MapboxMap map) { + mapboxMap = map; + } + + @Override + public Matcher<View> getConstraints() { + return isDisplayed(); + } + + @Override + public String getDescription() { + return getClass().getSimpleName(); + } + + @Override + public void perform(UiController uiController, View view) { + mapboxMap.getTrackingSettings().setMyBearingTrackingMode(MyBearingTracking.COMPASS); + // wait for next compass update cycle + uiController.loopMainThreadForAtLeast(500); + } + } + + private class DrawableMatcher extends TypeSafeMatcher<View> { + + private MapboxMap mapboxMap; + private boolean isBearingDrawable; + private final int expectedId; + + DrawableMatcher(MapboxMap mapboxMap, int expectedId, boolean isBearingDrawable) { + super(MyLocationView.class); + this.mapboxMap = mapboxMap; + this.expectedId = expectedId; + this.isBearingDrawable = isBearingDrawable; + } + + @Override + protected boolean matchesSafely(View target) { + Drawable currentDrawable = isBearingDrawable + ? mapboxMap.getMyLocationViewSettings().getForegroundBearingDrawable() : + mapboxMap.getMyLocationViewSettings().getForegroundDrawable(); + + Resources resources = target.getContext().getResources(); + Drawable expectedDrawable = resources.getDrawable(expectedId); + return areDrawablesIdentical(currentDrawable, expectedDrawable); + } + + @Override + public void describeTo(Description description) { + description.appendText("trying to match MyLocationView drawable to " + expectedId); + } + + boolean areDrawablesIdentical(Drawable drawableA, Drawable drawableB) { + Drawable.ConstantState stateA = drawableA.getConstantState(); + Drawable.ConstantState stateB = drawableB.getConstantState(); + return (stateA != null && stateB != null && stateA.equals(stateB)) + || getBitmap(drawableA).sameAs(getBitmap(drawableB)); + } + + Bitmap getBitmap(Drawable drawable) { + Bitmap result; + if (drawable instanceof BitmapDrawable) { + result = ((BitmapDrawable) drawable).getBitmap(); + } else { + int width = drawable.getIntrinsicWidth(); + int height = drawable.getIntrinsicHeight(); + // Some drawables have no intrinsic width - e.g. solid colours. + if (width <= 0) { + width = 1; + } + if (height <= 0) { + height = 1; + } + + result = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); + Canvas canvas = new Canvas(result); + drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight()); + drawable.draw(canvas); + } + return result; + } + } +} 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 d4c00c5f05..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 android.util.Log; import com.mapbox.mapboxsdk.maps.MapboxMap; import com.mapbox.mapboxsdk.style.layers.BackgroundLayer; @@ -19,118 +18,124 @@ 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 */ @RunWith(AndroidJUnit4.class) public class BackgroundLayerStyleTest extends BaseStyleTest { - private static final String TAG = BackgroundLayerStyleTest.class.getSimpleName(); - @Rule - public final ActivityTestRule<RuntimeStyleTestActivity> rule = new ActivityTestRule<>(RuntimeStyleTestActivity.class); + @Rule + public final ActivityTestRule<RuntimeStyleTestActivity> 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(); - Log.i(TAG, "Retrieving layer"); - layer = mapboxMap.getLayerAs("background"); - Log.i(TAG, "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(); - Log.i(TAG, "Retrieving layer"); - layer = mapboxMap.getLayerAs("background"); - Log.i(TAG, "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(); - Log.i(TAG, "Retrieving layer"); - layer = mapboxMap.getLayerAs("background"); - Log.i(TAG, "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(); - Log.i(TAG, "Retrieving layer"); - layer = mapboxMap.getLayerAs("background"); - Log.i(TAG, "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(); - Log.i(TAG, "Retrieving layer"); - layer = mapboxMap.getLayerAs("background"); - Log.i(TAG, "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 b56c8f648f..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 style-code-android`. 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 android.util.Log; import com.mapbox.mapboxsdk.maps.MapboxMap; import com.mapbox.mapboxsdk.style.layers.BackgroundLayer; @@ -19,118 +18,124 @@ 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 */ @RunWith(AndroidJUnit4.class) public class BackgroundLayerTest extends BaseStyleTest { - private static final String TAG = BackgroundLayerTest.class.getSimpleName(); - @Rule - public final ActivityTestRule<RuntimeStyleTestActivity> rule = new ActivityTestRule<>(RuntimeStyleTestActivity.class); + @Rule + public final ActivityTestRule<RuntimeStyleTestActivity> 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(); - Log.i(TAG, "Retrieving layer"); - layer = mapboxMap.getLayerAs("background"); - Log.i(TAG, "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(); - Log.i(TAG, "Retrieving layer"); - layer = mapboxMap.getLayerAs("background"); - Log.i(TAG, "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(); - Log.i(TAG, "Retrieving layer"); - layer = mapboxMap.getLayerAs("background"); - Log.i(TAG, "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(); - Log.i(TAG, "Retrieving layer"); - layer = mapboxMap.getLayerAs("background"); - Log.i(TAG, "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(); - Log.i(TAG, "Retrieving layer"); - layer = mapboxMap.getLayerAs("background"); - Log.i(TAG, "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 a7301962d1..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 android.util.Log; import com.mapbox.mapboxsdk.maps.MapboxMap; import com.mapbox.mapboxsdk.style.layers.CircleLayer; @@ -19,236 +18,248 @@ 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 */ @RunWith(AndroidJUnit4.class) public class CircleLayerStyleTest extends BaseStyleTest { - private static final String TAG = CircleLayerStyleTest.class.getSimpleName(); - @Rule - public final ActivityTestRule<RuntimeStyleTestActivity> rule = new ActivityTestRule<>(RuntimeStyleTestActivity.class); + @Rule + public final ActivityTestRule<RuntimeStyleTestActivity> 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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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 8b0f1af17b..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 style-code-android`. 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 android.util.Log; import com.mapbox.mapboxsdk.maps.MapboxMap; import com.mapbox.mapboxsdk.style.layers.CircleLayer; @@ -19,236 +18,339 @@ 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 */ @RunWith(AndroidJUnit4.class) public class CircleLayerTest extends BaseStyleTest { - private static final String TAG = CircleLayerTest.class.getSimpleName(); - @Rule - public final ActivityTestRule<RuntimeStyleTestActivity> rule = new ActivityTestRule<>(RuntimeStyleTestActivity.class); + @Rule + public final ActivityTestRule<RuntimeStyleTestActivity> 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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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); + } + + @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); + } + + @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 46ad1da879..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 android.util.Log; import com.mapbox.mapboxsdk.maps.MapboxMap; import com.mapbox.mapboxsdk.style.layers.FillLayer; @@ -19,258 +18,269 @@ 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 */ @RunWith(AndroidJUnit4.class) public class FillLayerStyleTest extends BaseStyleTest { - private static final String TAG = FillLayerStyleTest.class.getSimpleName(); - @Rule - public final ActivityTestRule<RuntimeStyleTestActivity> rule = new ActivityTestRule<>(RuntimeStyleTestActivity.class); + @Rule + public final ActivityTestRule<RuntimeStyleTestActivity> 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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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 593d444bc4..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 style-code-android`. 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 android.util.Log; import com.mapbox.mapboxsdk.maps.MapboxMap; import com.mapbox.mapboxsdk.style.layers.FillLayer; @@ -19,258 +18,269 @@ 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 */ @RunWith(AndroidJUnit4.class) public class FillLayerTest extends BaseStyleTest { - private static final String TAG = FillLayerTest.class.getSimpleName(); - @Rule - public final ActivityTestRule<RuntimeStyleTestActivity> rule = new ActivityTestRule<>(RuntimeStyleTestActivity.class); + @Rule + public final ActivityTestRule<RuntimeStyleTestActivity> 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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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 09c1ae797d..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 android.util.Log; import com.mapbox.mapboxsdk.maps.MapboxMap; import com.mapbox.mapboxsdk.style.layers.LineLayer; @@ -19,390 +18,410 @@ 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 */ @RunWith(AndroidJUnit4.class) public class LineLayerStyleTest extends BaseStyleTest { - private static final String TAG = LineLayerStyleTest.class.getSimpleName(); - @Rule - public final ActivityTestRule<RuntimeStyleTestActivity> rule = new ActivityTestRule<>(RuntimeStyleTestActivity.class); + @Rule + public final ActivityTestRule<RuntimeStyleTestActivity> 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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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 15fd35f0a8..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 style-code-android`. 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 android.util.Log; import com.mapbox.mapboxsdk.maps.MapboxMap; import com.mapbox.mapboxsdk.style.layers.LineLayer; @@ -19,390 +18,410 @@ 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 */ @RunWith(AndroidJUnit4.class) public class LineLayerTest extends BaseStyleTest { - private static final String TAG = LineLayerTest.class.getSimpleName(); - @Rule - public final ActivityTestRule<RuntimeStyleTestActivity> rule = new ActivityTestRule<>(RuntimeStyleTestActivity.class); + @Rule + public final ActivityTestRule<RuntimeStyleTestActivity> 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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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 2baddd6fa1..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 android.util.Log; import com.mapbox.mapboxsdk.maps.MapboxMap; import com.mapbox.mapboxsdk.style.layers.RasterLayer; @@ -18,214 +17,224 @@ 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 */ @RunWith(AndroidJUnit4.class) public class RasterLayerStyleTest extends BaseStyleTest { - private static final String TAG = RasterLayerStyleTest.class.getSimpleName(); - @Rule - public final ActivityTestRule<RuntimeStyleTestActivity> rule = new ActivityTestRule<>(RuntimeStyleTestActivity.class); + @Rule + public final ActivityTestRule<RuntimeStyleTestActivity> 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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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 b64c9a244c..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 style-code-android`. 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 android.util.Log; import com.mapbox.mapboxsdk.maps.MapboxMap; import com.mapbox.mapboxsdk.style.layers.RasterLayer; @@ -19,214 +17,224 @@ 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 */ @RunWith(AndroidJUnit4.class) public class RasterLayerTest extends BaseStyleTest { - private static final String TAG = RasterLayerTest.class.getSimpleName(); - @Rule - public final ActivityTestRule<RuntimeStyleTestActivity> rule = new ActivityTestRule<>(RuntimeStyleTestActivity.class); + @Rule + public final ActivityTestRule<RuntimeStyleTestActivity> 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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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 f562a5d8a3..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,7 +3,8 @@ package com.mapbox.mapboxsdk.testapp.style; import android.support.test.InstrumentationRegistry; import android.support.test.runner.AndroidJUnit4; import android.test.ActivityInstrumentationTestCase2; -import android.util.Log; + +import timber.log.Timber; import com.mapbox.mapboxsdk.maps.MapboxMap; import com.mapbox.mapboxsdk.maps.OnMapReadyCallback; @@ -22,40 +23,39 @@ import org.junit.runner.RunWith; */ @RunWith(AndroidJUnit4.class) public class RuntimeStyleBackgroundLayerTest - extends ActivityInstrumentationTestCase2<RuntimeStyleTestActivity> { - private static final String TAG = RuntimeStyleBackgroundLayerTest.class.getSimpleName(); - - 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) { - Log.i(TAG, "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<RuntimeStyleTestActivity> { + + public RuntimeStyleBackgroundLayerTest() { + super(RuntimeStyleTestActivity.class); + } + + @Before + public void setUp() throws Exception { + super.setUp(); + injectInstrumentation(InstrumentationRegistry.getInstrumentation()); + } + + @Test + public void testSetVisibility() { + getActivity().mapView.getMapAsync(new OnMapReadyCallback() { + @Override + public void onMapReady(MapboxMap mapboxMap) { + Timber.i("visibility"); + BackgroundLayer layer = mapboxMap.getLayerAs("background"); + assertNotNull(layer); + + //Get initial + assertEquals(layer.getVisibility().getValue(), Property.VISIBLE); + + //Set + layer.setProperties(PropertyFactory.visibility(Property.NONE)); + assertEquals(layer.getVisibility().getValue(), Property.NONE); + } + }); + } + + @After + public void tearDown() throws Exception { + super.tearDown(); + } } diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/RuntimeStyleTests.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/RuntimeStyleTests.java index 783601b1dd..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 @@ -1,100 +1,201 @@ package com.mapbox.mapboxsdk.testapp.style; +import android.graphics.Color; import android.support.test.espresso.Espresso; +import android.support.test.espresso.UiController; +import android.support.test.espresso.ViewAction; import android.support.test.rule.ActivityTestRule; import android.support.test.runner.AndroidJUnit4; +import android.view.View; import com.mapbox.mapboxsdk.maps.MapboxMap; +import com.mapbox.mapboxsdk.style.layers.CannotAddLayerException; import com.mapbox.mapboxsdk.style.layers.FillLayer; import com.mapbox.mapboxsdk.style.layers.NoSuchLayerException; import com.mapbox.mapboxsdk.style.layers.Property; import com.mapbox.mapboxsdk.style.layers.PropertyFactory; +import com.mapbox.mapboxsdk.style.sources.CannotAddSourceException; import com.mapbox.mapboxsdk.style.sources.NoSuchSourceException; +import com.mapbox.mapboxsdk.style.sources.Source; import com.mapbox.mapboxsdk.style.sources.VectorSource; import com.mapbox.mapboxsdk.testapp.R; import com.mapbox.mapboxsdk.testapp.activity.style.RuntimeStyleTestActivity; import com.mapbox.mapboxsdk.testapp.utils.OnMapReadyIdlingResource; +import com.mapbox.mapboxsdk.testapp.utils.ViewUtils; +import junit.framework.Assert; + +import org.hamcrest.Matcher; import org.junit.After; import org.junit.Before; -import org.junit.Ignore; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; -import static org.junit.Assert.assertFalse; +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 junit.framework.Assert.fail; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; /** * Basic smoke tests for Layer and Source */ @RunWith(AndroidJUnit4.class) -public class RuntimeStyleTests extends BaseStyleTest { +public class RuntimeStyleTests { + + @Rule + public final ActivityTestRule<RuntimeStyleTestActivity> rule = new ActivityTestRule<>(RuntimeStyleTestActivity.class); + + 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 class AddRemoveLayerAction implements ViewAction { - @Rule - public final ActivityTestRule<RuntimeStyleTestActivity> rule = new ActivityTestRule<>(RuntimeStyleTestActivity.class); + @Override + public Matcher<View> getConstraints() { + return isDisplayed(); + } - private OnMapReadyIdlingResource idlingResource; + @Override + public String getDescription() { + return getClass().getSimpleName(); + } - @Before - public void registerIdlingResource() { - idlingResource = new OnMapReadyIdlingResource(rule.getActivity()); - Espresso.registerIdlingResources(idlingResource); + @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 + } } + } - /** - * TODO fix failing test - */ - @Test - @Ignore - public void testGetAddRemoveLayer() { - checkViewIsDisplayed(R.id.mapView); - - MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); - - //Get initial - assertNotNull(mapboxMap.getLayer("building")); - - //Remove - try { - mapboxMap.removeLayer("building"); - } catch (NoSuchLayerException e) { - assertFalse(true); - } - assertNull(mapboxMap.getLayer("building")); - - //Add - FillLayer layer = new FillLayer("building", "composite"); - layer.setSourceLayer("building"); - mapboxMap.addLayer(layer); - - assertNotNull(mapboxMap.getLayer("building")); - - try { - layer.setProperties(PropertyFactory.visibility(Property.VISIBLE)); - assertTrue("Never reached as the reference is invalid after adding", false); - } catch (Exception e) { - //Expected, reference is no longer valid - } + private class AddRemoveSourceAction implements ViewAction { + + @Override + public Matcher<View> getConstraints() { + return isDisplayed(); } - @Test - public void testAddRemoveSource() { - 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 e) { - // it's ok.. - } + @Override + public String getDescription() { + return getClass().getSimpleName(); } - @After - public void unregisterIntentServiceIdlingResource() { - Espresso.unregisterIdlingResources(idlingResource); + @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); + } } 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<RuntimeStyleTimingTestActivity> 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<RuntimeStyleTimingTestActivity> 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 7132705ca9..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 android.util.Log; import com.mapbox.mapboxsdk.maps.MapboxMap; import com.mapbox.mapboxsdk.style.layers.SymbolLayer; @@ -19,1204 +18,1266 @@ 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 */ @RunWith(AndroidJUnit4.class) public class SymbolLayerStyleTest extends BaseStyleTest { - private static final String TAG = SymbolLayerStyleTest.class.getSimpleName(); - @Rule - public final ActivityTestRule<RuntimeStyleTestActivity> rule = new ActivityTestRule<>(RuntimeStyleTestActivity.class); + @Rule + public final ActivityTestRule<RuntimeStyleTestActivity> 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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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 5bc3f597c1..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 style-code-android`. 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 android.util.Log; import com.mapbox.mapboxsdk.maps.MapboxMap; import com.mapbox.mapboxsdk.style.layers.SymbolLayer; @@ -19,1204 +18,1266 @@ 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 */ @RunWith(AndroidJUnit4.class) public class SymbolLayerTest extends BaseStyleTest { - private static final String TAG = SymbolLayerTest.class.getSimpleName(); - @Rule - public final ActivityTestRule<RuntimeStyleTestActivity> rule = new ActivityTestRule<>(RuntimeStyleTestActivity.class); + @Rule + public final ActivityTestRule<RuntimeStyleTestActivity> 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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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) { - Log.i(TAG, "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"); - } - Log.i(TAG, "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/layer.junit.ejs b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/layer.junit.ejs index bc0d22bb25..3b81b0805b 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/layer.junit.ejs +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/layer.junit.ejs @@ -2,14 +2,14 @@ const type = locals.type; const properties = locals.properties; -%> -// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make style-code-android`. +// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make android-style-code`. package com.mapbox.mapboxsdk.testapp.style; import android.graphics.Color; import android.support.test.espresso.Espresso; import android.support.test.rule.ActivityTestRule; import android.support.test.runner.AndroidJUnit4; -import android.util.Log; +import timber.log.Timber; import com.mapbox.mapboxsdk.maps.MapboxMap; import com.mapbox.mapboxsdk.style.layers.<%- camelize(type) %>Layer; @@ -32,7 +32,6 @@ import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*; */ @RunWith(AndroidJUnit4.class) public class <%- camelize(type) %>LayerTest extends BaseStyleTest { - private static final String TAG = <%- camelize(type) %>LayerTest.class.getSimpleName(); @Rule public final ActivityTestRule<RuntimeStyleTestActivity> rule = new ActivityTestRule<>(RuntimeStyleTestActivity.class); @@ -56,11 +55,11 @@ public class <%- camelize(type) %>LayerTest extends BaseStyleTest { mapboxMap = rule.getActivity().getMapboxMap(); <% if (type === 'background') { -%> - Log.i(TAG, "Retrieving layer"); + Timber.i("Retrieving layer"); layer = mapboxMap.getLayerAs("background"); <% } else { -%> if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Log.i(TAG, "Adding layer"); + Timber.i("Adding layer"); layer = new <%- camelize(type) %>Layer("my-layer", "composite"); layer.setSourceLayer("composite"); mapboxMap.addLayer(layer); @@ -68,7 +67,7 @@ public class <%- camelize(type) %>LayerTest extends BaseStyleTest { layer = mapboxMap.getLayerAs("my-layer"); } <% } -%> - Log.i(TAG, "visibility"); + Timber.i("visibility"); assertNotNull(layer); //Get initial @@ -87,11 +86,11 @@ public class <%- camelize(type) %>LayerTest extends BaseStyleTest { mapboxMap = rule.getActivity().getMapboxMap(); <% if (type === 'background') { -%> - Log.i(TAG, "Retrieving layer"); + Timber.i("Retrieving layer"); layer = mapboxMap.getLayerAs("background"); <% } else { -%> if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Log.i(TAG, "Adding layer"); + Timber.i("Adding layer"); layer = new <%- camelize(type) %>Layer("my-layer", "composite"); layer.setSourceLayer("composite"); mapboxMap.addLayer(layer); @@ -99,7 +98,7 @@ public class <%- camelize(type) %>LayerTest extends BaseStyleTest { layer = mapboxMap.getLayerAs("my-layer"); } <% } -%> - Log.i(TAG, "<%- property.name %>"); + Timber.i("<%- property.name %>"); assertNotNull(layer); //Set and Get @@ -115,11 +114,11 @@ public class <%- camelize(type) %>LayerTest extends BaseStyleTest { mapboxMap = rule.getActivity().getMapboxMap(); <% if (type === 'background') { -%> - Log.i(TAG, "Retrieving layer"); + Timber.i("Retrieving layer"); layer = mapboxMap.getLayerAs("background"); <% } else { -%> if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Log.i(TAG, "Adding layer"); + Timber.i("Adding layer"); layer = new <%- camelize(type) %>Layer("my-layer", "composite"); layer.setSourceLayer("composite"); mapboxMap.addLayer(layer); @@ -127,7 +126,7 @@ public class <%- camelize(type) %>LayerTest extends BaseStyleTest { layer = mapboxMap.getLayerAs("my-layer"); } <% } -%> - Log.i(TAG, "<%- property.name %>"); + Timber.i("<%- property.name %>"); assertNotNull(layer); //Set and Get 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 c966f61f8c..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,56 +2,56 @@ package com.mapbox.mapboxsdk.testapp.utils; import android.app.Activity; import android.support.test.espresso.IdlingResource; -import android.util.Log; -import com.mapbox.mapboxsdk.constants.MapboxConstants; +import timber.log.Timber; + import com.mapbox.mapboxsdk.maps.MapboxMap; 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); - Log.e(MapboxConstants.TAG, "isMapboxReady called with value " + (mapboxMap != null)); - return mapboxMap != null; - } catch (Exception e) { - Log.e(MapboxConstants.TAG, "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 8fedf38619..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 android.util.Log; + +import timber.log.Timber; + import android.view.TextureView; import android.view.View; import android.view.ViewGroup; @@ -23,114 +25,113 @@ import java.util.UUID; */ public class ScreenshotUtil { - private static final String LOG_TAG = ScreenshotUtil.class.getName(); + // 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()) { - Log.d(LOG_TAG, "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<TextureView> 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<TextureView> 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<TextureView> getAllTextureViews(View view) - { - List<TextureView> tilingViews = new ArrayList<TextureView>(); - 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<TextureView> getAllTextureViews(View view) { + List<TextureView> tilingViews = new ArrayList<TextureView>(); + 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; - Log.d(LOG_TAG, "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 new file mode 100644 index 0000000000..965f5d1443 --- /dev/null +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/utils/TestConstants.java @@ -0,0 +1,18 @@ +package com.mapbox.mapboxsdk.testapp.utils; + +import com.mapbox.mapboxsdk.constants.MapboxConstants; + +public class TestConstants { + + public static final long ANIMATION_TEST_TIME = MapboxConstants.ANIMATION_DURATION * 2; + + public static final double LAT_LNG_DELTA_LARGE = 0.1; + public static final double LAT_LNG_DELTA = 0.01; + public static final double BEARING_DELTA = 0.1; + public static final double TILT_DELTA = 0.1; + public static final double ZOOM_DELTA = 0.3; + + public static final 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 01ee3e9b9f..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 @@ -4,12 +4,19 @@ import android.support.annotation.IdRes; import static android.support.test.espresso.Espresso.onView; import static android.support.test.espresso.action.ViewActions.click; +import static android.support.test.espresso.assertion.ViewAssertions.matches; +import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed; import static android.support.test.espresso.matcher.ViewMatchers.withId; public class ViewUtils { - 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())); + } } |