diff options
Diffstat (limited to 'platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/maps')
4 files changed, 607 insertions, 599 deletions
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/maps/MapboxMapOptionsTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/maps/MapboxMapOptionsTest.java index 05d1f2beb1..e0415182de 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/maps/MapboxMapOptionsTest.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/maps/MapboxMapOptionsTest.java @@ -21,169 +21,177 @@ import static org.junit.Assert.assertTrue; public class MapboxMapOptionsTest { - private static final double DELTA = 1e-15; - - @Test - public void testSanity() { - assertNotNull("should not be null", new MapboxMapOptions()); - } - - @Test - public void testDebugEnabled() { - assertFalse(new MapboxMapOptions().getDebugActive()); - assertTrue(new MapboxMapOptions().debugActive(true).getDebugActive()); - assertFalse(new MapboxMapOptions().debugActive(false).getDebugActive()); - } - - @Test - public void testCompassEnabled() { - assertTrue(new MapboxMapOptions().compassEnabled(true).getCompassEnabled()); - assertFalse(new MapboxMapOptions().compassEnabled(false).getCompassEnabled()); - } - - @Test - public void testCompassGravity() { - assertEquals(Gravity.TOP | Gravity.END, new MapboxMapOptions().getCompassGravity()); - assertEquals(Gravity.BOTTOM, new MapboxMapOptions().compassGravity(Gravity.BOTTOM).getCompassGravity()); - assertNotEquals(Gravity.START, new MapboxMapOptions().compassGravity(Gravity.BOTTOM).getCompassGravity()); - } - - @Test - public void testCompassMargins() { - assertTrue(Arrays.equals(new int[]{0, 1, 2, 3}, new MapboxMapOptions().compassMargins(new int[]{0, 1, 2, 3}).getCompassMargins())); - assertFalse(Arrays.equals(new int[]{0, 1, 2, 3}, new MapboxMapOptions().compassMargins(new int[]{0, 0, 0, 0}).getCompassMargins())); - } - - @Test - public void testLogoEnabled() { - assertTrue(new MapboxMapOptions().logoEnabled(true).getLogoEnabled()); - assertFalse(new MapboxMapOptions().logoEnabled(false).getLogoEnabled()); - } - - @Test - public void testLogoGravity() { - assertEquals(Gravity.BOTTOM | Gravity.START, new MapboxMapOptions().getLogoGravity()); - assertEquals(Gravity.BOTTOM, new MapboxMapOptions().logoGravity(Gravity.BOTTOM).getLogoGravity()); - assertNotEquals(Gravity.START, new MapboxMapOptions().logoGravity(Gravity.BOTTOM).getLogoGravity()); - } - - @Test - public void testLogoMargins() { - assertTrue(Arrays.equals(new int[]{0, 1, 2, 3}, new MapboxMapOptions().logoMargins(new int[]{0, 1, 2, 3}).getLogoMargins())); - assertFalse(Arrays.equals(new int[]{0, 1, 2, 3}, new MapboxMapOptions().logoMargins(new int[]{0, 0, 0, 0}).getLogoMargins())); - } - - @Test - public void testAttributionTintColor() { - assertEquals(-1, new MapboxMapOptions().getAttributionTintColor()); - assertEquals(Color.RED, new MapboxMapOptions().attributionTintColor(Color.RED).getAttributionTintColor()); - } - - @Test - public void testAttributionEnabled() { - assertTrue(new MapboxMapOptions().attributionEnabled(true).getAttributionEnabled()); - assertFalse(new MapboxMapOptions().attributionEnabled(false).getAttributionEnabled()); - } - - @Test - public void testAttributionGravity() { - assertEquals(Gravity.BOTTOM, new MapboxMapOptions().getAttributionGravity()); - assertEquals(Gravity.BOTTOM, new MapboxMapOptions().attributionGravity(Gravity.BOTTOM).getAttributionGravity()); - assertNotEquals(Gravity.START, new MapboxMapOptions().attributionGravity(Gravity.BOTTOM).getAttributionGravity()); - } - - @Test - public void testAttributionMargins() { - assertTrue(Arrays.equals(new int[]{0, 1, 2, 3}, new MapboxMapOptions().attributionMargins(new int[]{0, 1, 2, 3}).getAttributionMargins())); - assertFalse(Arrays.equals(new int[]{0, 1, 2, 3}, new MapboxMapOptions().attributionMargins(new int[]{0, 0, 0, 0}).getAttributionMargins())); - } - - @Test - public void testMinZoom() { - assertEquals(MapboxConstants.MINIMUM_ZOOM, new MapboxMapOptions().getMinZoomPreference(), DELTA); - assertEquals(5.0f, new MapboxMapOptions().minZoomPreference(5.0f).getMinZoomPreference(), DELTA); - assertNotEquals(2.0f, new MapboxMapOptions().minZoomPreference(5.0f).getMinZoomPreference(), DELTA); - } - - @Test - public void testMaxZoom() { - assertEquals(MapboxConstants.MAXIMUM_ZOOM, new MapboxMapOptions().getMaxZoomPreference(), DELTA); - assertEquals(5.0f, new MapboxMapOptions().maxZoomPreference(5.0f).getMaxZoomPreference(), DELTA); - assertNotEquals(2.0f, new MapboxMapOptions().maxZoomPreference(5.0f).getMaxZoomPreference(), DELTA); - } - - @Test - public void testLocationEnabled() { - assertFalse(new MapboxMapOptions().getLocationEnabled()); - assertTrue(new MapboxMapOptions().locationEnabled(true).getLocationEnabled()); - assertFalse(new MapboxMapOptions().locationEnabled(false).getLocationEnabled()); - } - - @Test - public void testTiltGesturesEnabled() { - assertTrue(new MapboxMapOptions().getTiltGesturesEnabled()); - assertTrue(new MapboxMapOptions().tiltGesturesEnabled(true).getTiltGesturesEnabled()); - assertFalse(new MapboxMapOptions().tiltGesturesEnabled(false).getTiltGesturesEnabled()); - } - - @Test - public void testScrollGesturesEnabled() { - assertTrue(new MapboxMapOptions().getScrollGesturesEnabled()); - assertTrue(new MapboxMapOptions().scrollGesturesEnabled(true).getScrollGesturesEnabled()); - assertFalse(new MapboxMapOptions().scrollGesturesEnabled(false).getScrollGesturesEnabled()); - } - - @Test - public void testZoomGesturesEnabled() { - assertTrue(new MapboxMapOptions().getZoomGesturesEnabled()); - assertTrue(new MapboxMapOptions().zoomGesturesEnabled(true).getZoomGesturesEnabled()); - assertFalse(new MapboxMapOptions().zoomGesturesEnabled(false).getZoomGesturesEnabled()); - } - - @Test - public void testRotateGesturesEnabled() { - assertTrue(new MapboxMapOptions().getRotateGesturesEnabled()); - assertTrue(new MapboxMapOptions().rotateGesturesEnabled(true).getRotateGesturesEnabled()); - assertFalse(new MapboxMapOptions().rotateGesturesEnabled(false).getRotateGesturesEnabled()); - } - - @Test - public void testZoomControlsEnabled() { - assertFalse(new MapboxMapOptions().getZoomControlsEnabled()); - assertTrue(new MapboxMapOptions().zoomControlsEnabled(true).getZoomControlsEnabled()); - assertFalse(new MapboxMapOptions().zoomControlsEnabled(false).getZoomControlsEnabled()); - } - - @Test - public void testStyleUrl() { - assertEquals(Style.DARK, new MapboxMapOptions().styleUrl(Style.DARK).getStyle()); - assertNotEquals(Style.LIGHT, new MapboxMapOptions().styleUrl(Style.DARK).getStyle()); - assertNull(new MapboxMapOptions().getStyle()); - } - - @Test - public void testCamera() { - CameraPosition position = new CameraPosition.Builder().build(); - assertEquals(new CameraPosition.Builder(position).build(), new MapboxMapOptions().camera(position).getCamera()); - assertNotEquals(new CameraPosition.Builder().target(new LatLng(1, 1)), new MapboxMapOptions().camera(position)); - assertNull(new MapboxMapOptions().getCamera()); - } - - @Test - public void testMyLocationForegroundTint() { - assertEquals(Color.BLUE, new MapboxMapOptions().myLocationForegroundTintColor(Color.BLUE).getMyLocationForegroundTintColor()); - } - - @Test - public void testMyLocationBackgroundTint() { - assertEquals(Color.BLUE, new MapboxMapOptions().myLocationBackgroundTintColor(Color.BLUE).getMyLocationBackgroundTintColor()); - } - - @Test - public void testAccessToken() { - assertNull(new MapboxMapOptions().getAccessToken()); - assertEquals("test", new MapboxMapOptions().accessToken("test").getAccessToken()); - assertNotEquals("nottest", new MapboxMapOptions().accessToken("test").getStyle()); - } + private static final double DELTA = 1e-15; + + @Test + public void testSanity() { + assertNotNull("should not be null", new MapboxMapOptions()); + } + + @Test + public void testDebugEnabled() { + assertFalse(new MapboxMapOptions().getDebugActive()); + assertTrue(new MapboxMapOptions().debugActive(true).getDebugActive()); + assertFalse(new MapboxMapOptions().debugActive(false).getDebugActive()); + } + + @Test + public void testCompassEnabled() { + assertTrue(new MapboxMapOptions().compassEnabled(true).getCompassEnabled()); + assertFalse(new MapboxMapOptions().compassEnabled(false).getCompassEnabled()); + } + + @Test + public void testCompassGravity() { + assertEquals(Gravity.TOP | Gravity.END, new MapboxMapOptions().getCompassGravity()); + assertEquals(Gravity.BOTTOM, new MapboxMapOptions().compassGravity(Gravity.BOTTOM).getCompassGravity()); + assertNotEquals(Gravity.START, new MapboxMapOptions().compassGravity(Gravity.BOTTOM).getCompassGravity()); + } + + @Test + public void testCompassMargins() { + assertTrue(Arrays.equals(new int[] {0, 1, 2, 3}, new MapboxMapOptions().compassMargins( + new int[] {0, 1, 2, 3}).getCompassMargins())); + assertFalse(Arrays.equals(new int[] {0, 1, 2, 3}, new MapboxMapOptions().compassMargins( + new int[] {0, 0, 0, 0}).getCompassMargins())); + } + + @Test + public void testLogoEnabled() { + assertTrue(new MapboxMapOptions().logoEnabled(true).getLogoEnabled()); + assertFalse(new MapboxMapOptions().logoEnabled(false).getLogoEnabled()); + } + + @Test + public void testLogoGravity() { + assertEquals(Gravity.BOTTOM | Gravity.START, new MapboxMapOptions().getLogoGravity()); + assertEquals(Gravity.BOTTOM, new MapboxMapOptions().logoGravity(Gravity.BOTTOM).getLogoGravity()); + assertNotEquals(Gravity.START, new MapboxMapOptions().logoGravity(Gravity.BOTTOM).getLogoGravity()); + } + + @Test + public void testLogoMargins() { + assertTrue(Arrays.equals(new int[] {0, 1, 2, 3}, new MapboxMapOptions().logoMargins( + new int[] {0, 1, 2, 3}).getLogoMargins())); + assertFalse(Arrays.equals(new int[] {0, 1, 2, 3}, new MapboxMapOptions().logoMargins( + new int[] {0, 0, 0, 0}).getLogoMargins())); + } + + @Test + public void testAttributionTintColor() { + assertEquals(-1, new MapboxMapOptions().getAttributionTintColor()); + assertEquals(Color.RED, new MapboxMapOptions().attributionTintColor(Color.RED).getAttributionTintColor()); + } + + @Test + public void testAttributionEnabled() { + assertTrue(new MapboxMapOptions().attributionEnabled(true).getAttributionEnabled()); + assertFalse(new MapboxMapOptions().attributionEnabled(false).getAttributionEnabled()); + } + + @Test + public void testAttributionGravity() { + assertEquals(Gravity.BOTTOM, new MapboxMapOptions().getAttributionGravity()); + assertEquals(Gravity.BOTTOM, new MapboxMapOptions().attributionGravity(Gravity.BOTTOM).getAttributionGravity()); + assertNotEquals(Gravity.START, new MapboxMapOptions().attributionGravity(Gravity.BOTTOM).getAttributionGravity()); + } + + @Test + public void testAttributionMargins() { + assertTrue(Arrays.equals(new int[] {0, 1, 2, 3}, new MapboxMapOptions().attributionMargins( + new int[] {0, 1, 2, 3}).getAttributionMargins())); + assertFalse(Arrays.equals(new int[] {0, 1, 2, 3}, new MapboxMapOptions().attributionMargins( + new int[] {0, 0, 0, 0}).getAttributionMargins())); + } + + @Test + public void testMinZoom() { + assertEquals(MapboxConstants.MINIMUM_ZOOM, new MapboxMapOptions().getMinZoomPreference(), DELTA); + assertEquals(5.0f, new MapboxMapOptions().minZoomPreference(5.0f).getMinZoomPreference(), DELTA); + assertNotEquals(2.0f, new MapboxMapOptions().minZoomPreference(5.0f).getMinZoomPreference(), DELTA); + } + + @Test + public void testMaxZoom() { + assertEquals(MapboxConstants.MAXIMUM_ZOOM, new MapboxMapOptions().getMaxZoomPreference(), DELTA); + assertEquals(5.0f, new MapboxMapOptions().maxZoomPreference(5.0f).getMaxZoomPreference(), DELTA); + assertNotEquals(2.0f, new MapboxMapOptions().maxZoomPreference(5.0f).getMaxZoomPreference(), DELTA); + } + + @Test + public void testLocationEnabled() { + assertFalse(new MapboxMapOptions().getLocationEnabled()); + assertTrue(new MapboxMapOptions().locationEnabled(true).getLocationEnabled()); + assertFalse(new MapboxMapOptions().locationEnabled(false).getLocationEnabled()); + } + + @Test + public void testTiltGesturesEnabled() { + assertTrue(new MapboxMapOptions().getTiltGesturesEnabled()); + assertTrue(new MapboxMapOptions().tiltGesturesEnabled(true).getTiltGesturesEnabled()); + assertFalse(new MapboxMapOptions().tiltGesturesEnabled(false).getTiltGesturesEnabled()); + } + + @Test + public void testScrollGesturesEnabled() { + assertTrue(new MapboxMapOptions().getScrollGesturesEnabled()); + assertTrue(new MapboxMapOptions().scrollGesturesEnabled(true).getScrollGesturesEnabled()); + assertFalse(new MapboxMapOptions().scrollGesturesEnabled(false).getScrollGesturesEnabled()); + } + + @Test + public void testZoomGesturesEnabled() { + assertTrue(new MapboxMapOptions().getZoomGesturesEnabled()); + assertTrue(new MapboxMapOptions().zoomGesturesEnabled(true).getZoomGesturesEnabled()); + assertFalse(new MapboxMapOptions().zoomGesturesEnabled(false).getZoomGesturesEnabled()); + } + + @Test + public void testRotateGesturesEnabled() { + assertTrue(new MapboxMapOptions().getRotateGesturesEnabled()); + assertTrue(new MapboxMapOptions().rotateGesturesEnabled(true).getRotateGesturesEnabled()); + assertFalse(new MapboxMapOptions().rotateGesturesEnabled(false).getRotateGesturesEnabled()); + } + + @Test + public void testZoomControlsEnabled() { + assertFalse(new MapboxMapOptions().getZoomControlsEnabled()); + assertTrue(new MapboxMapOptions().zoomControlsEnabled(true).getZoomControlsEnabled()); + assertFalse(new MapboxMapOptions().zoomControlsEnabled(false).getZoomControlsEnabled()); + } + + @Test + public void testStyleUrl() { + assertEquals(Style.DARK, new MapboxMapOptions().styleUrl(Style.DARK).getStyle()); + assertNotEquals(Style.LIGHT, new MapboxMapOptions().styleUrl(Style.DARK).getStyle()); + assertNull(new MapboxMapOptions().getStyle()); + } + + @Test + public void testCamera() { + CameraPosition position = new CameraPosition.Builder().build(); + assertEquals(new CameraPosition.Builder(position).build(), new MapboxMapOptions().camera(position).getCamera()); + assertNotEquals(new CameraPosition.Builder().target(new LatLng(1, 1)), new MapboxMapOptions().camera(position)); + assertNull(new MapboxMapOptions().getCamera()); + } + + @Test + public void testMyLocationForegroundTint() { + assertEquals(Color.BLUE, + new MapboxMapOptions().myLocationForegroundTintColor(Color.BLUE).getMyLocationForegroundTintColor()); + } + + @Test + public void testMyLocationBackgroundTint() { + assertEquals(Color.BLUE, + new MapboxMapOptions().myLocationBackgroundTintColor(Color.BLUE).getMyLocationBackgroundTintColor()); + } + + @Test + public void testAccessToken() { + assertNull(new MapboxMapOptions().getAccessToken()); + assertEquals("test", new MapboxMapOptions().accessToken("test").getAccessToken()); + assertNotEquals("nottest", new MapboxMapOptions().accessToken("test").getStyle()); + } } diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/maps/TrackingSettingsTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/maps/TrackingSettingsTest.java index 96c2c57084..57f3b942af 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/maps/TrackingSettingsTest.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/maps/TrackingSettingsTest.java @@ -4,7 +4,6 @@ import android.Manifest; import android.content.Context; import android.content.pm.PackageManager; -import com.mapbox.mapboxsdk.constants.MyBearingTracking; import com.mapbox.mapboxsdk.constants.MyLocationTracking; import com.mapbox.mapboxsdk.maps.widgets.MyLocationView; @@ -12,7 +11,6 @@ import org.junit.Before; import org.junit.Test; import org.mockito.InjectMocks; -import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; @@ -23,49 +21,50 @@ import static org.mockito.Mockito.when; public class TrackingSettingsTest { - @InjectMocks - MyLocationView myLocationView = mock(MyLocationView.class); + @InjectMocks + MyLocationView myLocationView = mock(MyLocationView.class); - @InjectMocks - UiSettings uiSettings = mock(UiSettings.class); + @InjectMocks + UiSettings uiSettings = mock(UiSettings.class); - @InjectMocks - FocalPointChangeListener focalPointChangeListener = mock(FocalPointChangeListener.class); + @InjectMocks + FocalPointChangeListener focalPointChangeListener = mock(FocalPointChangeListener.class); - private TrackingSettings trackingSettings; + private TrackingSettings trackingSettings; - @Before - public void beforeTest() { - trackingSettings = new TrackingSettings(myLocationView, uiSettings, focalPointChangeListener); - } + @Before + public void beforeTest() { + trackingSettings = new TrackingSettings(myLocationView, uiSettings, focalPointChangeListener); + } - @Test - public void testSanity() { - assertNotNull("trackingsettings should not be null", trackingSettings); - } - - @Test - public void testDismissTrackingModesOnGesture() { - trackingSettings.setDismissTrackingOnGesture(false); - assertFalse("DismissTrackingOnGesture should be false", trackingSettings.isDismissTrackingOnGesture()); - } + @Test + public void testSanity() { + assertNotNull("trackingsettings should not be null", trackingSettings); + } - @Test - public void testValidateGesturesForTrackingModes() { - trackingSettings.setDismissTrackingOnGesture(false); - trackingSettings.setMyLocationTrackingMode(MyLocationTracking.TRACKING_FOLLOW); - assertFalse("DismissTrackingOnGesture should be false", trackingSettings.isDismissTrackingOnGesture()); - } + @Test + public void testDismissTrackingModesOnGesture() { + trackingSettings.setDismissTrackingOnGesture(false); + assertFalse("DismissTrackingOnGesture should be false", trackingSettings.isDismissTrackingOnGesture()); + } - @Test - public void testMyLocationEnabled() { - // setup mock context to provide accepted location permission - Context context = mock(Context.class); - when(myLocationView.getContext()).thenReturn(context); - when(context.checkPermission(eq(Manifest.permission.ACCESS_COARSE_LOCATION), anyInt(), anyInt())).thenReturn(PackageManager.PERMISSION_GRANTED); + @Test + public void testValidateGesturesForTrackingModes() { + trackingSettings.setDismissTrackingOnGesture(false); + trackingSettings.setMyLocationTrackingMode(MyLocationTracking.TRACKING_FOLLOW); + assertFalse("DismissTrackingOnGesture should be false", trackingSettings.isDismissTrackingOnGesture()); + } - assertFalse("Location should be disabled by default.", trackingSettings.isMyLocationEnabled()); - trackingSettings.setMyLocationEnabled(true); - assertTrue("Location should be enabled", trackingSettings.isMyLocationEnabled()); - } + @Test + public void testMyLocationEnabled() { + // setup mock context to provide accepted location permission + Context context = mock(Context.class); + when(myLocationView.getContext()).thenReturn(context); + when(context.checkPermission(eq(Manifest.permission.ACCESS_COARSE_LOCATION), anyInt(), + anyInt())).thenReturn(PackageManager.PERMISSION_GRANTED); + + assertFalse("Location should be disabled by default.", trackingSettings.isMyLocationEnabled()); + trackingSettings.setMyLocationEnabled(true); + assertTrue("Location should be enabled", trackingSettings.isMyLocationEnabled()); + } } diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/maps/UiSettingsTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/maps/UiSettingsTest.java index 741929b814..1f532255d7 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/maps/UiSettingsTest.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/maps/UiSettingsTest.java @@ -20,321 +20,321 @@ import static org.mockito.Mockito.when; public class UiSettingsTest { - @InjectMocks - Projection projection = mock(Projection.class); - - @InjectMocks - FocalPointChangeListener focalPointChangeListener = mock(FocalPointChangeListener.class); - - @InjectMocks - CompassView compassView = mock(CompassView.class); - - @InjectMocks - ImageView imageView = mock(ImageView.class); - - @InjectMocks - ImageView logoView = mock(ImageView.class); - - @InjectMocks - FrameLayout.LayoutParams layoutParams = mock(FrameLayout.LayoutParams.class); - - private UiSettings uiSettings; - - @Before - public void beforeTest() { - uiSettings = new UiSettings(projection, focalPointChangeListener, compassView, imageView, logoView); - } - - @Test - public void testSanity() { - assertNotNull("uiSettings should not be null", uiSettings); - } - - @Test - public void testCompassEnabled() { - when(compassView.isEnabled()).thenReturn(true); - uiSettings.setCompassEnabled(true); - assertEquals("Compass should be enabled", true, uiSettings.isCompassEnabled()); - } - - @Test - public void testCompassDisabled() { - uiSettings.setCompassEnabled(false); - assertEquals("Compass should be disabled", false, uiSettings.isCompassEnabled()); - } - - @Test - public void testCompassGravity() { - when(compassView.getLayoutParams()).thenReturn(layoutParams); - layoutParams.gravity = Gravity.START; - uiSettings.setCompassGravity(Gravity.START); - assertEquals("Compass gravity should be same", Gravity.START, uiSettings.getCompassGravity()); - } - - @Test - public void testCompassMargins() { - when(projection.getContentPadding()).thenReturn(new int[]{0, 0, 0, 0}); - when(compassView.getLayoutParams()).thenReturn(layoutParams); - layoutParams.leftMargin = 1; - layoutParams.topMargin = 2; - layoutParams.rightMargin = 3; - layoutParams.bottomMargin = 4; - uiSettings.setCompassMargins(1, 2, 3, 4); - assertTrue("Compass margin left should be same", uiSettings.getCompassMarginLeft() == 1); - assertTrue("Compass margin top should be same", uiSettings.getCompassMarginTop() == 2); - assertTrue("Compass margin right should be same", uiSettings.getCompassMarginRight() == 3); - assertTrue("Compass margin bottom should be same", uiSettings.getCompassMarginBottom() == 4); - } - - @Test - public void testCompassFadeWhenFacingNorth() { - when(compassView.isFadeCompassViewFacingNorth()).thenReturn(true); - assertTrue("Compass should fade when facing north by default.", uiSettings.isCompassFadeWhenFacingNorth()); - uiSettings.setCompassFadeFacingNorth(false); - when(compassView.isFadeCompassViewFacingNorth()).thenReturn(false); - assertFalse("Compass fading should be disabled", uiSettings.isCompassFadeWhenFacingNorth()); - } - - @Test - public void testLogoEnabled() { - uiSettings.setLogoEnabled(true); - assertEquals("Logo should be enabled", true, uiSettings.isLogoEnabled()); - } - - @Test - public void testLogoDisabled() { - when(logoView.getVisibility()).thenReturn(View.GONE); - uiSettings.setLogoEnabled(false); - assertEquals("Logo should be disabled", false, uiSettings.isLogoEnabled()); - } - - @Test - public void testLogoGravity() { - layoutParams.gravity = Gravity.END; - when(logoView.getLayoutParams()).thenReturn(layoutParams); - uiSettings.setLogoGravity(Gravity.END); - assertEquals("Logo gravity should be same", Gravity.END, uiSettings.getLogoGravity()); - } - - @Test - public void testLogoMargins() { - when(projection.getContentPadding()).thenReturn(new int[]{0, 0, 0, 0}); - when(logoView.getLayoutParams()).thenReturn(layoutParams); - layoutParams.leftMargin = 1; - layoutParams.topMargin = 2; - layoutParams.rightMargin = 3; - layoutParams.bottomMargin = 4; - uiSettings.setLogoMargins(1, 2, 3, 4); - assertTrue("Compass margin left should be same", uiSettings.getLogoMarginLeft() == 1); - assertTrue("Compass margin top should be same", uiSettings.getLogoMarginTop() == 2); - assertTrue("Compass margin right should be same", uiSettings.getLogoMarginRight() == 3); - assertTrue("Compass margin bottom should be same", uiSettings.getLogoMarginBottom() == 4); - } - - @Test - public void testAttributionEnabled() { - when(imageView.getVisibility()).thenReturn(View.VISIBLE); - uiSettings.setAttributionEnabled(true); - assertEquals("Attribution should be enabled", true, uiSettings.isAttributionEnabled()); - } - - @Test - public void testAttributionDisabled() { - when(imageView.getVisibility()).thenReturn(View.GONE); - uiSettings.setAttributionEnabled(false); - assertEquals("Attribution should be disabled", false, uiSettings.isAttributionEnabled()); - } - - @Test - public void testAttributionGravity() { - when(imageView.getLayoutParams()).thenReturn(layoutParams); - layoutParams.gravity = Gravity.END; - uiSettings.setAttributionGravity(Gravity.END); - assertEquals("Attribution gravity should be same", Gravity.END, uiSettings.getAttributionGravity()); - } - - @Test - public void testAttributionMargins() { - when(imageView.getLayoutParams()).thenReturn(layoutParams); - when(projection.getContentPadding()).thenReturn(new int[]{0, 0, 0, 0}); - layoutParams.leftMargin = 1; - layoutParams.topMargin = 2; - layoutParams.rightMargin = 3; - layoutParams.bottomMargin = 4; - uiSettings.setAttributionMargins(1, 2, 3, 4); - assertTrue("Attribution margin left should be same", uiSettings.getAttributionMarginLeft() == 1); - assertTrue("Attribution margin top should be same", uiSettings.getAttributionMarginTop() == 2); - assertTrue("Attribution margin right should be same", uiSettings.getAttributionMarginRight() == 3); - assertTrue("Attribution margin bottom should be same", uiSettings.getAttributionMarginBottom() == 4); - } - - @Test - public void testRotateGesturesEnabled() { - uiSettings.setRotateGesturesEnabled(true); - assertEquals("Rotate gesture should be enabled", true, uiSettings.isRotateGesturesEnabled()); - } - - @Test - public void testRotateGesturesDisabled() { - uiSettings.setRotateGesturesEnabled(false); - assertEquals("Rotate gesture should be disabled", false, uiSettings.isRotateGesturesEnabled()); - } - - @Test - public void testRotateGestureChange() { - assertEquals("Default state should be true", true, uiSettings.isRotateGestureChangeAllowed()); - uiSettings.setRotateGestureChangeAllowed(false); - assertEquals("State should have been changed", false, uiSettings.isRotateGestureChangeAllowed()); - } - - @Test - public void testRotateGestureChangeAllowed() { - uiSettings.setRotateGesturesEnabled(false); - assertEquals("Rotate gesture should be false", false, uiSettings.isRotateGesturesEnabled()); - uiSettings.setRotateGesturesEnabled(true); - assertEquals("Rotate gesture should be true", true, uiSettings.isRotateGesturesEnabled()); - } - - @Test - public void testRotateGestureChangeDisallowed() { - assertEquals("Rotate gesture should be true", true, uiSettings.isRotateGesturesEnabled()); - uiSettings.setRotateGestureChangeAllowed(false); - uiSettings.setRotateGesturesEnabled(false); - assertEquals("Rotate gesture change should be ignored", true, uiSettings.isRotateGesturesEnabled()); - } - - @Test - public void testTiltGesturesEnabled() { - uiSettings.setTiltGesturesEnabled(true); - assertEquals("Tilt gesture should be enabled", true, uiSettings.isTiltGesturesEnabled()); - } - - @Test - public void testTiltGesturesDisabled() { - uiSettings.setTiltGesturesEnabled(false); - assertEquals("Tilt gesture should be disabled", false, uiSettings.isTiltGesturesEnabled()); - } - - @Test - public void testTiltGestureChange() { - assertEquals("Default state should be true", true, uiSettings.isTiltGestureChangeAllowed()); - uiSettings.setTiltGestureChangeAllowed(false); - assertEquals("State should have been changed", false, uiSettings.isTiltGestureChangeAllowed()); - } - - @Test - public void testTiltGestureChangeAllowed() { - uiSettings.setTiltGesturesEnabled(false); - assertEquals("Tilt gesture should be false", false, uiSettings.isTiltGesturesEnabled()); - uiSettings.setTiltGesturesEnabled(true); - assertEquals("Tilt gesture should be true", true, uiSettings.isTiltGesturesEnabled()); - } - - @Test - public void testTiltGestureChangeDisallowed() { - assertEquals("Tilt gesture should be true", true, uiSettings.isTiltGesturesEnabled()); - uiSettings.setTiltGestureChangeAllowed(false); - uiSettings.setTiltGesturesEnabled(false); - assertEquals("Tilt gesture change should be ignored", true, uiSettings.isTiltGesturesEnabled()); - } - - @Test - public void testZoomGesturesEnabled() { - uiSettings.setZoomGesturesEnabled(true); - assertEquals("Zoom gesture should be enabled", true, uiSettings.isZoomGesturesEnabled()); - } - - @Test - public void testZoomGesturesDisabled() { - uiSettings.setZoomGesturesEnabled(false); - assertEquals("Zoom gesture should be disabled", false, uiSettings.isZoomGesturesEnabled()); - } - - @Test - public void testZoomGestureChange() { - assertEquals("Default state should be true", true, uiSettings.isZoomGestureChangeAllowed()); - uiSettings.setZoomGestureChangeAllowed(false); - assertEquals("State should have been changed", false, uiSettings.isZoomGestureChangeAllowed()); - } - - @Test - public void testZoomGestureChangeAllowed() { - uiSettings.setZoomGesturesEnabled(false); - assertEquals("Zoom gesture should be false", false, uiSettings.isZoomGesturesEnabled()); - uiSettings.setZoomGesturesEnabled(true); - assertEquals("Zoom gesture should be true", true, uiSettings.isZoomGesturesEnabled()); - } - - @Test - public void testZoomGestureChangeDisallowed() { - assertEquals("Zoom gesture should be true", true, uiSettings.isZoomGesturesEnabled()); - uiSettings.setZoomGestureChangeAllowed(false); - uiSettings.setZoomGesturesEnabled(false); - assertEquals("Zooom gesture change should be ignored", true, uiSettings.isZoomGesturesEnabled()); - } - - @Test - public void testZoomControlsEnabled() { - uiSettings.setZoomControlsEnabled(true); - assertEquals("Zoom controls should be enabled", true, uiSettings.isZoomControlsEnabled()); - } - - @Test - public void testZoomControlsDisabled() { - uiSettings.setZoomControlsEnabled(false); - assertEquals("Zoom controls should be disabled", false, uiSettings.isZoomControlsEnabled()); - } - - @Test - public void testScrollGesturesEnabled() { - uiSettings.setScrollGesturesEnabled(true); - assertEquals("Scroll gesture should be enabled", true, uiSettings.isScrollGesturesEnabled()); - } - - @Test - public void testScrollGesturesDisabled() { - uiSettings.setScrollGesturesEnabled(false); - assertEquals("Scroll gesture should be disabled", false, uiSettings.isScrollGesturesEnabled()); - } - - @Test - public void testScrollGestureChange() { - assertEquals("Default state should be true", true, uiSettings.isScrollGestureChangeAllowed()); - uiSettings.setScrollGestureChangeAllowed(false); - assertEquals("State should have been changed", false, uiSettings.isScrollGestureChangeAllowed()); - } - - @Test - public void testScrollGestureChangeAllowed() { - uiSettings.setScrollGesturesEnabled(false); - assertEquals("Scroll gesture should be false", false, uiSettings.isScrollGesturesEnabled()); - uiSettings.setScrollGesturesEnabled(true); - assertEquals("Scroll gesture should be true", true, uiSettings.isScrollGesturesEnabled()); - } - - @Test - public void testScrollGestureChangeDisallowed() { - assertEquals("Scroll gesture should be true", true, uiSettings.isScrollGesturesEnabled()); - uiSettings.setScrollGestureChangeAllowed(false); - uiSettings.setScrollGesturesEnabled(false); - assertEquals("Scroll gesture change should be ignored", true, uiSettings.isScrollGesturesEnabled()); - } - - @Test - public void testAllGesturesEnabled() { - uiSettings.setAllGesturesEnabled(true); - assertEquals("Rotate gesture should be enabled", true, uiSettings.isRotateGesturesEnabled()); - assertEquals("Tilt gesture should be enabled", true, uiSettings.isTiltGesturesEnabled()); - assertEquals("Zoom gesture should be enabled", true, uiSettings.isZoomGesturesEnabled()); - assertEquals("Scroll gesture should be enabled", true, uiSettings.isScrollGesturesEnabled()); - } - - @Test - public void testAllGesturesDisabled() { - uiSettings.setAllGesturesEnabled(false); - assertEquals("Rotate gesture should be enabled", false, uiSettings.isRotateGesturesEnabled()); - assertEquals("Tilt gesture should be disabled", false, uiSettings.isTiltGesturesEnabled()); - assertEquals("Zoom gesture should be disabled", false, uiSettings.isZoomGesturesEnabled()); - assertEquals("Scroll gesture should be disabled", false, uiSettings.isScrollGesturesEnabled()); - } + @InjectMocks + Projection projection = mock(Projection.class); + + @InjectMocks + FocalPointChangeListener focalPointChangeListener = mock(FocalPointChangeListener.class); + + @InjectMocks + CompassView compassView = mock(CompassView.class); + + @InjectMocks + ImageView imageView = mock(ImageView.class); + + @InjectMocks + ImageView logoView = mock(ImageView.class); + + @InjectMocks + FrameLayout.LayoutParams layoutParams = mock(FrameLayout.LayoutParams.class); + + private UiSettings uiSettings; + + @Before + public void beforeTest() { + uiSettings = new UiSettings(projection, focalPointChangeListener, compassView, imageView, logoView); + } + + @Test + public void testSanity() { + assertNotNull("uiSettings should not be null", uiSettings); + } + + @Test + public void testCompassEnabled() { + when(compassView.isEnabled()).thenReturn(true); + uiSettings.setCompassEnabled(true); + assertEquals("Compass should be enabled", true, uiSettings.isCompassEnabled()); + } + + @Test + public void testCompassDisabled() { + uiSettings.setCompassEnabled(false); + assertEquals("Compass should be disabled", false, uiSettings.isCompassEnabled()); + } + + @Test + public void testCompassGravity() { + when(compassView.getLayoutParams()).thenReturn(layoutParams); + layoutParams.gravity = Gravity.START; + uiSettings.setCompassGravity(Gravity.START); + assertEquals("Compass gravity should be same", Gravity.START, uiSettings.getCompassGravity()); + } + + @Test + public void testCompassMargins() { + when(projection.getContentPadding()).thenReturn(new int[] {0, 0, 0, 0}); + when(compassView.getLayoutParams()).thenReturn(layoutParams); + layoutParams.leftMargin = 1; + layoutParams.topMargin = 2; + layoutParams.rightMargin = 3; + layoutParams.bottomMargin = 4; + uiSettings.setCompassMargins(1, 2, 3, 4); + assertTrue("Compass margin left should be same", uiSettings.getCompassMarginLeft() == 1); + assertTrue("Compass margin top should be same", uiSettings.getCompassMarginTop() == 2); + assertTrue("Compass margin right should be same", uiSettings.getCompassMarginRight() == 3); + assertTrue("Compass margin bottom should be same", uiSettings.getCompassMarginBottom() == 4); + } + + @Test + public void testCompassFadeWhenFacingNorth() { + when(compassView.isFadeCompassViewFacingNorth()).thenReturn(true); + assertTrue("Compass should fade when facing north by default.", uiSettings.isCompassFadeWhenFacingNorth()); + uiSettings.setCompassFadeFacingNorth(false); + when(compassView.isFadeCompassViewFacingNorth()).thenReturn(false); + assertFalse("Compass fading should be disabled", uiSettings.isCompassFadeWhenFacingNorth()); + } + + @Test + public void testLogoEnabled() { + uiSettings.setLogoEnabled(true); + assertEquals("Logo should be enabled", true, uiSettings.isLogoEnabled()); + } + + @Test + public void testLogoDisabled() { + when(logoView.getVisibility()).thenReturn(View.GONE); + uiSettings.setLogoEnabled(false); + assertEquals("Logo should be disabled", false, uiSettings.isLogoEnabled()); + } + + @Test + public void testLogoGravity() { + layoutParams.gravity = Gravity.END; + when(logoView.getLayoutParams()).thenReturn(layoutParams); + uiSettings.setLogoGravity(Gravity.END); + assertEquals("Logo gravity should be same", Gravity.END, uiSettings.getLogoGravity()); + } + + @Test + public void testLogoMargins() { + when(projection.getContentPadding()).thenReturn(new int[] {0, 0, 0, 0}); + when(logoView.getLayoutParams()).thenReturn(layoutParams); + layoutParams.leftMargin = 1; + layoutParams.topMargin = 2; + layoutParams.rightMargin = 3; + layoutParams.bottomMargin = 4; + uiSettings.setLogoMargins(1, 2, 3, 4); + assertTrue("Compass margin left should be same", uiSettings.getLogoMarginLeft() == 1); + assertTrue("Compass margin top should be same", uiSettings.getLogoMarginTop() == 2); + assertTrue("Compass margin right should be same", uiSettings.getLogoMarginRight() == 3); + assertTrue("Compass margin bottom should be same", uiSettings.getLogoMarginBottom() == 4); + } + + @Test + public void testAttributionEnabled() { + when(imageView.getVisibility()).thenReturn(View.VISIBLE); + uiSettings.setAttributionEnabled(true); + assertEquals("Attribution should be enabled", true, uiSettings.isAttributionEnabled()); + } + + @Test + public void testAttributionDisabled() { + when(imageView.getVisibility()).thenReturn(View.GONE); + uiSettings.setAttributionEnabled(false); + assertEquals("Attribution should be disabled", false, uiSettings.isAttributionEnabled()); + } + + @Test + public void testAttributionGravity() { + when(imageView.getLayoutParams()).thenReturn(layoutParams); + layoutParams.gravity = Gravity.END; + uiSettings.setAttributionGravity(Gravity.END); + assertEquals("Attribution gravity should be same", Gravity.END, uiSettings.getAttributionGravity()); + } + + @Test + public void testAttributionMargins() { + when(imageView.getLayoutParams()).thenReturn(layoutParams); + when(projection.getContentPadding()).thenReturn(new int[] {0, 0, 0, 0}); + layoutParams.leftMargin = 1; + layoutParams.topMargin = 2; + layoutParams.rightMargin = 3; + layoutParams.bottomMargin = 4; + uiSettings.setAttributionMargins(1, 2, 3, 4); + assertTrue("Attribution margin left should be same", uiSettings.getAttributionMarginLeft() == 1); + assertTrue("Attribution margin top should be same", uiSettings.getAttributionMarginTop() == 2); + assertTrue("Attribution margin right should be same", uiSettings.getAttributionMarginRight() == 3); + assertTrue("Attribution margin bottom should be same", uiSettings.getAttributionMarginBottom() == 4); + } + + @Test + public void testRotateGesturesEnabled() { + uiSettings.setRotateGesturesEnabled(true); + assertEquals("Rotate gesture should be enabled", true, uiSettings.isRotateGesturesEnabled()); + } + + @Test + public void testRotateGesturesDisabled() { + uiSettings.setRotateGesturesEnabled(false); + assertEquals("Rotate gesture should be disabled", false, uiSettings.isRotateGesturesEnabled()); + } + + @Test + public void testRotateGestureChange() { + assertEquals("Default state should be true", true, uiSettings.isRotateGestureChangeAllowed()); + uiSettings.setRotateGestureChangeAllowed(false); + assertEquals("State should have been changed", false, uiSettings.isRotateGestureChangeAllowed()); + } + + @Test + public void testRotateGestureChangeAllowed() { + uiSettings.setRotateGesturesEnabled(false); + assertEquals("Rotate gesture should be false", false, uiSettings.isRotateGesturesEnabled()); + uiSettings.setRotateGesturesEnabled(true); + assertEquals("Rotate gesture should be true", true, uiSettings.isRotateGesturesEnabled()); + } + + @Test + public void testRotateGestureChangeDisallowed() { + assertEquals("Rotate gesture should be true", true, uiSettings.isRotateGesturesEnabled()); + uiSettings.setRotateGestureChangeAllowed(false); + uiSettings.setRotateGesturesEnabled(false); + assertEquals("Rotate gesture change should be ignored", true, uiSettings.isRotateGesturesEnabled()); + } + + @Test + public void testTiltGesturesEnabled() { + uiSettings.setTiltGesturesEnabled(true); + assertEquals("Tilt gesture should be enabled", true, uiSettings.isTiltGesturesEnabled()); + } + + @Test + public void testTiltGesturesDisabled() { + uiSettings.setTiltGesturesEnabled(false); + assertEquals("Tilt gesture should be disabled", false, uiSettings.isTiltGesturesEnabled()); + } + + @Test + public void testTiltGestureChange() { + assertEquals("Default state should be true", true, uiSettings.isTiltGestureChangeAllowed()); + uiSettings.setTiltGestureChangeAllowed(false); + assertEquals("State should have been changed", false, uiSettings.isTiltGestureChangeAllowed()); + } + + @Test + public void testTiltGestureChangeAllowed() { + uiSettings.setTiltGesturesEnabled(false); + assertEquals("Tilt gesture should be false", false, uiSettings.isTiltGesturesEnabled()); + uiSettings.setTiltGesturesEnabled(true); + assertEquals("Tilt gesture should be true", true, uiSettings.isTiltGesturesEnabled()); + } + + @Test + public void testTiltGestureChangeDisallowed() { + assertEquals("Tilt gesture should be true", true, uiSettings.isTiltGesturesEnabled()); + uiSettings.setTiltGestureChangeAllowed(false); + uiSettings.setTiltGesturesEnabled(false); + assertEquals("Tilt gesture change should be ignored", true, uiSettings.isTiltGesturesEnabled()); + } + + @Test + public void testZoomGesturesEnabled() { + uiSettings.setZoomGesturesEnabled(true); + assertEquals("Zoom gesture should be enabled", true, uiSettings.isZoomGesturesEnabled()); + } + + @Test + public void testZoomGesturesDisabled() { + uiSettings.setZoomGesturesEnabled(false); + assertEquals("Zoom gesture should be disabled", false, uiSettings.isZoomGesturesEnabled()); + } + + @Test + public void testZoomGestureChange() { + assertEquals("Default state should be true", true, uiSettings.isZoomGestureChangeAllowed()); + uiSettings.setZoomGestureChangeAllowed(false); + assertEquals("State should have been changed", false, uiSettings.isZoomGestureChangeAllowed()); + } + + @Test + public void testZoomGestureChangeAllowed() { + uiSettings.setZoomGesturesEnabled(false); + assertEquals("Zoom gesture should be false", false, uiSettings.isZoomGesturesEnabled()); + uiSettings.setZoomGesturesEnabled(true); + assertEquals("Zoom gesture should be true", true, uiSettings.isZoomGesturesEnabled()); + } + + @Test + public void testZoomGestureChangeDisallowed() { + assertEquals("Zoom gesture should be true", true, uiSettings.isZoomGesturesEnabled()); + uiSettings.setZoomGestureChangeAllowed(false); + uiSettings.setZoomGesturesEnabled(false); + assertEquals("Zooom gesture change should be ignored", true, uiSettings.isZoomGesturesEnabled()); + } + + @Test + public void testZoomControlsEnabled() { + uiSettings.setZoomControlsEnabled(true); + assertEquals("Zoom controls should be enabled", true, uiSettings.isZoomControlsEnabled()); + } + + @Test + public void testZoomControlsDisabled() { + uiSettings.setZoomControlsEnabled(false); + assertEquals("Zoom controls should be disabled", false, uiSettings.isZoomControlsEnabled()); + } + + @Test + public void testScrollGesturesEnabled() { + uiSettings.setScrollGesturesEnabled(true); + assertEquals("Scroll gesture should be enabled", true, uiSettings.isScrollGesturesEnabled()); + } + + @Test + public void testScrollGesturesDisabled() { + uiSettings.setScrollGesturesEnabled(false); + assertEquals("Scroll gesture should be disabled", false, uiSettings.isScrollGesturesEnabled()); + } + + @Test + public void testScrollGestureChange() { + assertEquals("Default state should be true", true, uiSettings.isScrollGestureChangeAllowed()); + uiSettings.setScrollGestureChangeAllowed(false); + assertEquals("State should have been changed", false, uiSettings.isScrollGestureChangeAllowed()); + } + + @Test + public void testScrollGestureChangeAllowed() { + uiSettings.setScrollGesturesEnabled(false); + assertEquals("Scroll gesture should be false", false, uiSettings.isScrollGesturesEnabled()); + uiSettings.setScrollGesturesEnabled(true); + assertEquals("Scroll gesture should be true", true, uiSettings.isScrollGesturesEnabled()); + } + + @Test + public void testScrollGestureChangeDisallowed() { + assertEquals("Scroll gesture should be true", true, uiSettings.isScrollGesturesEnabled()); + uiSettings.setScrollGestureChangeAllowed(false); + uiSettings.setScrollGesturesEnabled(false); + assertEquals("Scroll gesture change should be ignored", true, uiSettings.isScrollGesturesEnabled()); + } + + @Test + public void testAllGesturesEnabled() { + uiSettings.setAllGesturesEnabled(true); + assertEquals("Rotate gesture should be enabled", true, uiSettings.isRotateGesturesEnabled()); + assertEquals("Tilt gesture should be enabled", true, uiSettings.isTiltGesturesEnabled()); + assertEquals("Zoom gesture should be enabled", true, uiSettings.isZoomGesturesEnabled()); + assertEquals("Scroll gesture should be enabled", true, uiSettings.isScrollGesturesEnabled()); + } + + @Test + public void testAllGesturesDisabled() { + uiSettings.setAllGesturesEnabled(false); + assertEquals("Rotate gesture should be enabled", false, uiSettings.isRotateGesturesEnabled()); + assertEquals("Tilt gesture should be disabled", false, uiSettings.isTiltGesturesEnabled()); + assertEquals("Zoom gesture should be disabled", false, uiSettings.isZoomGesturesEnabled()); + assertEquals("Scroll gesture should be disabled", false, uiSettings.isScrollGesturesEnabled()); + } }
\ No newline at end of file diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationViewSettingsTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationViewSettingsTest.java index 24f28567ba..c9ce19dc85 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationViewSettingsTest.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationViewSettingsTest.java @@ -22,84 +22,85 @@ import static org.mockito.Mockito.when; public class MyLocationViewSettingsTest { - @InjectMocks - Projection projection = mock(Projection.class); - - @InjectMocks - MyLocationView myLocationView = mock(MyLocationView.class); - - @InjectMocks - TrackingSettings trackingSettings = mock(TrackingSettings.class); - - @InjectMocks - FocalPointChangeListener focalPointChangeListener = mock(FocalPointChangeListener.class); - - private MyLocationViewSettings locationViewSettings; - - @Before - public void beforeTest() { - locationViewSettings = new MyLocationViewSettings(myLocationView, projection, focalPointChangeListener); - } - - @Test - public void testSanity() { - assertNotNull("should not be null", locationViewSettings); - } - - @Test - public void testForegroundDrawables() { - Drawable foregroundDrawable = mock(Drawable.class); - Drawable foregroundBearingDrawable = mock(Drawable.class); - Drawable.ConstantState constantState = mock(Drawable.ConstantState.class); - when(foregroundDrawable.getConstantState()).thenReturn(constantState); - when(constantState.newDrawable()).thenReturn(foregroundDrawable); - locationViewSettings.setForegroundDrawable(foregroundDrawable, foregroundBearingDrawable); - assertEquals("foreground should match", foregroundDrawable, locationViewSettings.getForegroundDrawable()); - assertEquals("foreground bearing should match", foregroundBearingDrawable, locationViewSettings.getForegroundBearingDrawable()); - } - - @Test - public void testBackgroundDrawable() { - Drawable backgroundDrawable = mock(Drawable.class); - int[] offset = new int[]{1, 2, 3, 4}; - locationViewSettings.setBackgroundDrawable(backgroundDrawable, offset); - assertEquals("foreground should match", backgroundDrawable, locationViewSettings.getBackgroundDrawable()); - assertTrue("offsets should match", Arrays.equals(offset, locationViewSettings.getBackgroundOffset())); - } - - @Test - public void testForegroundTint() { - int color = Color.RED; - locationViewSettings.setForegroundTintColor(Color.RED); - assertEquals("color should match", color, locationViewSettings.getForegroundTintColor()); - } - - @Test - public void testForegroundTransparentTint() { - int color = Color.TRANSPARENT; - locationViewSettings.setForegroundTintColor(Color.TRANSPARENT); - assertEquals("color should match", color, locationViewSettings.getForegroundTintColor()); - } - - @Test - public void testBackgroundTint() { - int color = Color.RED; - locationViewSettings.setBackgroundTintColor(Color.RED); - assertEquals("color should match", color, locationViewSettings.getBackgroundTintColor()); - } - - @Test - public void testBackgroundTransparentTint() { - int color = Color.TRANSPARENT; - locationViewSettings.setBackgroundTintColor(Color.TRANSPARENT); - assertEquals("color should match", color, locationViewSettings.getBackgroundTintColor()); - } - - @Test - public void testEnabled() { - assertFalse("initial state should be false", locationViewSettings.isEnabled()); - locationViewSettings.setEnabled(true); - assertTrue("state should be true", locationViewSettings.isEnabled()); - } + @InjectMocks + Projection projection = mock(Projection.class); + + @InjectMocks + MyLocationView myLocationView = mock(MyLocationView.class); + + @InjectMocks + TrackingSettings trackingSettings = mock(TrackingSettings.class); + + @InjectMocks + FocalPointChangeListener focalPointChangeListener = mock(FocalPointChangeListener.class); + + private MyLocationViewSettings locationViewSettings; + + @Before + public void beforeTest() { + locationViewSettings = new MyLocationViewSettings(myLocationView, projection, focalPointChangeListener); + } + + @Test + public void testSanity() { + assertNotNull("should not be null", locationViewSettings); + } + + @Test + public void testForegroundDrawables() { + Drawable foregroundDrawable = mock(Drawable.class); + Drawable foregroundBearingDrawable = mock(Drawable.class); + Drawable.ConstantState constantState = mock(Drawable.ConstantState.class); + when(foregroundDrawable.getConstantState()).thenReturn(constantState); + when(constantState.newDrawable()).thenReturn(foregroundDrawable); + locationViewSettings.setForegroundDrawable(foregroundDrawable, foregroundBearingDrawable); + assertEquals("foreground should match", foregroundDrawable, locationViewSettings.getForegroundDrawable()); + assertEquals("foreground bearing should match", foregroundBearingDrawable, + locationViewSettings.getForegroundBearingDrawable()); + } + + @Test + public void testBackgroundDrawable() { + Drawable backgroundDrawable = mock(Drawable.class); + int[] offset = new int[] {1, 2, 3, 4}; + locationViewSettings.setBackgroundDrawable(backgroundDrawable, offset); + assertEquals("foreground should match", backgroundDrawable, locationViewSettings.getBackgroundDrawable()); + assertTrue("offsets should match", Arrays.equals(offset, locationViewSettings.getBackgroundOffset())); + } + + @Test + public void testForegroundTint() { + int color = Color.RED; + locationViewSettings.setForegroundTintColor(Color.RED); + assertEquals("color should match", color, locationViewSettings.getForegroundTintColor()); + } + + @Test + public void testForegroundTransparentTint() { + int color = Color.TRANSPARENT; + locationViewSettings.setForegroundTintColor(Color.TRANSPARENT); + assertEquals("color should match", color, locationViewSettings.getForegroundTintColor()); + } + + @Test + public void testBackgroundTint() { + int color = Color.RED; + locationViewSettings.setBackgroundTintColor(Color.RED); + assertEquals("color should match", color, locationViewSettings.getBackgroundTintColor()); + } + + @Test + public void testBackgroundTransparentTint() { + int color = Color.TRANSPARENT; + locationViewSettings.setBackgroundTintColor(Color.TRANSPARENT); + assertEquals("color should match", color, locationViewSettings.getBackgroundTintColor()); + } + + @Test + public void testEnabled() { + assertFalse("initial state should be false", locationViewSettings.isEnabled()); + locationViewSettings.setEnabled(true); + assertTrue("state should be true", locationViewSettings.isEnabled()); + } } |