From 2cf9dc0dd6257ba4ce0d4d6f1bea696eb12ab466 Mon Sep 17 00:00:00 2001 From: Tobrun Van Nuland Date: Fri, 25 Aug 2017 10:08:54 +0200 Subject: [android] - update style constants, add test --- .../java/com/mapbox/mapboxsdk/constants/Style.java | 37 +++++- .../src/main/res/values/strings.xml | 7 ++ .../testapp/activity/BaseActivityTest.java | 5 + .../testapp/constants/StyleVersionTest.java | 129 +++++++++++++++++++++ 4 files changed, 177 insertions(+), 1 deletion(-) create mode 100644 platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/constants/StyleVersionTest.java diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/constants/Style.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/constants/Style.java index 9943a72e06..ab31dd4097 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/constants/Style.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/constants/Style.java @@ -22,7 +22,8 @@ public class Style { * constants means your map style will always use the latest version and may change as we * improve the style */ - @StringDef( {MAPBOX_STREETS, OUTDOORS, LIGHT, DARK, SATELLITE, SATELLITE_STREETS, TRAFFIC_DAY, TRAFFIC_NIGHT}) + @StringDef( {MAPBOX_STREETS, OUTDOORS, LIGHT, DARK, SATELLITE, SATELLITE_STREETS, TRAFFIC_DAY, TRAFFIC_NIGHT, + NAVIGATION_GUIDANCE_DAY, NAVIGATION_GUIDANCE_NIGHT, NAVIGATION_PREVIEW_DAY, NAVIGATION_PREVIEW_NIGHT}) @Retention(RetentionPolicy.SOURCE) public @interface StyleUrl { } @@ -73,7 +74,10 @@ public class Style { * these select * countries. Using this constant means your map style will always use the latest version and * may change as we improve the style. + * + * @deprecated Use {@link Style#NAVIGATION_PREVIEW_DAY} and {@link Style#NAVIGATION_GUIDANCE_DAY} instead. */ + @Deprecated public static final String TRAFFIC_DAY = "mapbox://styles/mapbox/traffic-day-v2"; /** @@ -82,6 +86,37 @@ public class Style { * these select * countries. Using this constant means your map style will always use the latest version and * may change as we improve the style. + * + * @deprecated Use {@link Style#NAVIGATION_PREVIEW_NIGHT} and {@link Style#NAVIGATION_GUIDANCE_NIGHT} instead. */ + @Deprecated public static final String TRAFFIC_NIGHT = "mapbox://styles/mapbox/traffic-night-v2"; + + /** + * Navigation Preview Day: TBA. + * Using this constant means your map style will always use the latest version and + * may change as we improve the style. + */ + public static final String NAVIGATION_PREVIEW_DAY = "mapbox://styles/mapbox/navigation-preview-day-v2"; + + /** + * Navigation Guidance Day: TBA. + * Using this constant means your map style will always use the latest version and + * may change as we improve the style. + */ + public static final String NAVIGATION_GUIDANCE_DAY = "mapbox://styles/mapbox/navigation-guidance-day-v2"; + + /** + * Navigation Preview Night: TBA. + * Using this constant means your map style will always use the latest version and + * may change as we improve the style. + */ + public static final String NAVIGATION_PREVIEW_NIGHT = "mapbox://styles/mapbox/navigation-preview-night-v2"; + + /** + * Navigation Guidance Night: TBA. + * Using this constant means your map style will always use the latest version and + * may change as we improve the style. + */ + public static final String NAVIGATION_GUIDANCE_NIGHT = "mapbox://styles/mapbox/navigation-guidance-night-v2"; } diff --git a/platform/android/MapboxGLAndroidSDK/src/main/res/values/strings.xml b/platform/android/MapboxGLAndroidSDK/src/main/res/values/strings.xml index 65fb3e14a3..c985381560 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/res/values/strings.xml +++ b/platform/android/MapboxGLAndroidSDK/src/main/res/values/strings.xml @@ -24,6 +24,13 @@ mapbox://styles/mapbox/dark-v9 mapbox://styles/mapbox/satellite-v9 mapbox://styles/mapbox/satellite-streets-v10 + mapbox://styles/mapbox/traffic-day-v2 + mapbox://styles/mapbox/traffic-night-v2 + mapbox://styles/mapbox/navigation-preview-day-v2 + mapbox://styles/mapbox/navigation-guidance-day-v2 + mapbox://styles/mapbox/navigation-preview-night-v2 + mapbox://styles/mapbox/navigation-guidance-night-v2 + 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 c029bc09c4..fa8b0ab895 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/BaseActivityTest.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/BaseActivityTest.java @@ -4,6 +4,7 @@ import android.app.Activity; import android.content.Context; import android.net.ConnectivityManager; import android.net.NetworkInfo; +import android.support.annotation.StringRes; import android.support.test.espresso.Espresso; import android.support.test.espresso.IdlingResourceTimeoutException; import android.support.test.espresso.UiController; @@ -111,5 +112,9 @@ public abstract class BaseActivityTest { uiController.loopMainThreadForAtLeast(loopTime); } } + + protected String getString(@StringRes int styleRes) { + return rule.getActivity().getResources().getString(styleRes); + } } diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/constants/StyleVersionTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/constants/StyleVersionTest.java new file mode 100644 index 0000000000..5d50139517 --- /dev/null +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/constants/StyleVersionTest.java @@ -0,0 +1,129 @@ +package com.mapbox.mapboxsdk.testapp.constants; + +import com.mapbox.mapboxsdk.constants.Style; +import com.mapbox.mapboxsdk.testapp.R; +import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest; +import com.mapbox.mapboxsdk.testapp.activity.espresso.EspressoTestActivity; + +import org.junit.Test; + +import static org.junit.Assert.assertEquals; + +/** + * Verifies if Style.java defined constants match the strings.xml equivalent + */ +public class StyleVersionTest extends BaseActivityTest { + + @Override + protected Class getActivityClass() { + return EspressoTestActivity.class; + } + + @Test + public void mapboxStreets() { + assertEquals( + "Mapbox Streets should match", + Style.MAPBOX_STREETS, + getString(R.string.mapbox_style_mapbox_streets) + ); + } + + @Test + public void satelliteStreets() { + assertEquals( + "Satellite Streets should match", + Style.SATELLITE_STREETS, + getString(R.string.mapbox_style_satellite_streets) + ); + } + + @Test + public void outdoors() { + assertEquals( + "Outdoors should match", + Style.OUTDOORS, + getString(R.string.mapbox_style_outdoors) + ); + } + + @Test + public void satellite() { + assertEquals( + "Satellite should match", + Style.SATELLITE, + getString(R.string.mapbox_style_satellite) + ); + } + + @Test + public void light() { + assertEquals( + "Light should match", + Style.LIGHT, + getString(R.string.mapbox_style_light) + ); + } + + @Test + public void dark() { + assertEquals( + "Dark should match", + Style.DARK, + getString(R.string.mapbox_style_dark) + ); + } + + @Test + public void trafficDay() { + assertEquals( + "Traffic Day should match", + Style.TRAFFIC_DAY, + getString(R.string.mapbox_style_traffic_day) + ); + } + + @Test + public void trafficNight() { + assertEquals( + "Traffic Night should match", + Style.TRAFFIC_NIGHT, + getString(R.string.mapbox_style_traffic_night) + ); + } + + @Test + public void navigationGuidanceDay() { + assertEquals( + "Navigation Guidance Day should match", + Style.NAVIGATION_GUIDANCE_DAY, + getString(R.string.mapbox_style_navigation_guidance_day) + ); + } + + @Test + public void navigationGuidanceNight() { + assertEquals( + "Navigation Guidance Night should match", + Style.NAVIGATION_GUIDANCE_NIGHT, + getString(R.string.mapbox_style_navigation_guidance_night) + ); + } + + @Test + public void navigationPreviewDay() { + assertEquals( + "Navigation Preview Day should match", + Style.NAVIGATION_PREVIEW_DAY, + getString(R.string.mapbox_style_navigation_preview_day) + ); + } + + @Test + public void navigationPreviewNight() { + assertEquals( + "Navigation Preview Night should match", + Style.NAVIGATION_PREVIEW_NIGHT, + getString(R.string.mapbox_style_navigation_preview_night) + ); + } +} -- cgit v1.2.1