[android] #3760 - parity with Google Maps SDK
[android] #3760 - added missing methods for UiSettings, updated tests and test app to reflect this change [android] #3760 - typo fix
This commit is contained in:
@@ -1,7 +1,5 @@
|
||||
package com.mapbox.mapboxsdk.maps;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import com.mapbox.mapboxsdk.annotations.Marker;
|
||||
import com.mapbox.mapboxsdk.annotations.MarkerOptions;
|
||||
import com.mapbox.mapboxsdk.camera.CameraPosition;
|
||||
@@ -9,8 +7,6 @@ import com.mapbox.mapboxsdk.camera.CameraPosition;
|
||||
import com.mapbox.mapboxsdk.camera.CameraUpdateFactory;
|
||||
import com.mapbox.mapboxsdk.constants.Style;
|
||||
import com.mapbox.mapboxsdk.geometry.LatLng;
|
||||
import com.mapbox.mapboxsdk.maps.MapView;
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
@@ -18,8 +14,6 @@ import org.mockito.InjectMocks;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
@@ -51,78 +45,6 @@ public class MapboxMapTest {
|
||||
assertNotNull("mMapboxMap should not be null", mMapboxMap);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCompassEnabled() {
|
||||
mMapboxMap.setCompassEnabled(true);
|
||||
assertTrue("CompassEnabled should be true", mMapboxMap.isCompassEnabled());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCompassDisabled() {
|
||||
mMapboxMap.setCompassEnabled(false);
|
||||
assertFalse("CompassbEnabled should be false", mMapboxMap.isCompassEnabled());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testScrollEnabled() {
|
||||
mMapboxMap.setScrollEnabled(true);
|
||||
assertTrue("ScrollEnabled should be true", mMapboxMap.isScrollEnabled());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testScrollDisabled() {
|
||||
mMapboxMap.setScrollEnabled(false);
|
||||
assertFalse("ScrollEnabled should be false", mMapboxMap.isScrollEnabled());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRotateEnabled() {
|
||||
mMapboxMap.setRotateEnabled(true);
|
||||
assertTrue("RotateEnabled should be true", mMapboxMap.isRotateEnabled());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRotateDisabled() {
|
||||
mMapboxMap.setRotateEnabled(false);
|
||||
assertFalse("RotateDisabled should be false", mMapboxMap.isRotateEnabled());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testZoomEnabled() {
|
||||
mMapboxMap.setZoomEnabled(true);
|
||||
assertTrue("ZoomEnabled should be true", mMapboxMap.isZoomEnabled());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testZoomDisabled() {
|
||||
mMapboxMap.setZoomEnabled(false);
|
||||
assertFalse("ZoomEnabled should be false", mMapboxMap.isZoomEnabled());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testZoomControlsEnabled() {
|
||||
mMapboxMap.setZoomControlsEnabled(true);
|
||||
assertTrue("ZoomControlsEnabled should be true", mMapboxMap.isZoomControlsEnabled());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testZoomControlsDisabled() {
|
||||
mMapboxMap.setZoomControlsEnabled(false);
|
||||
assertFalse("ZoomControlsEnabled should be false", mMapboxMap.isZoomControlsEnabled());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTiltEnabled() {
|
||||
mMapboxMap.setTiltEnabled(true);
|
||||
assertTrue("TiltEnabled should be true", mMapboxMap.isTiltEnabled());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTiltDisabled() {
|
||||
mMapboxMap.setTiltEnabled(false);
|
||||
assertFalse("TiltEnabled should be false", mMapboxMap.isTiltEnabled());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConcurrentInfoWindowEnabled() {
|
||||
mMapboxMap.setAllowConcurrentMultipleOpenInfoWindows(true);
|
||||
@@ -185,7 +107,7 @@ public class MapboxMapTest {
|
||||
public void testAnimateCamera() {
|
||||
CameraPosition position = new CameraPosition.Builder().bearing(1).tilt(2).zoom(3).target(new LatLng(4, 5)).build();
|
||||
mMapboxMap.animateCamera(CameraUpdateFactory.newCameraPosition(position));
|
||||
assertEquals("CameraPosition should be same", position , mMapboxMap.getCameraPosition());
|
||||
assertEquals("CameraPosition should be same", position, mMapboxMap.getCameraPosition());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -199,7 +121,7 @@ public class MapboxMapTest {
|
||||
public void testAnimateCameraWithDurationParameter() {
|
||||
CameraPosition position = new CameraPosition.Builder().bearing(1).tilt(2).zoom(3).target(new LatLng(4, 5)).build();
|
||||
mMapboxMap.animateCamera(CameraUpdateFactory.newCameraPosition(position), 0);
|
||||
assertEquals("CameraPosition should be same",position, mMapboxMap.getCameraPosition());
|
||||
assertEquals("CameraPosition should be same", position, mMapboxMap.getCameraPosition());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -0,0 +1,215 @@
|
||||
package com.mapbox.mapboxsdk.maps;
|
||||
|
||||
import android.view.Gravity;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.mockito.InjectMocks;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
public class UiSettingsTest {
|
||||
|
||||
private MapboxMap mMapboxMap;
|
||||
|
||||
@InjectMocks
|
||||
MapView mMapView = mock(MapView.class);
|
||||
|
||||
@Before
|
||||
public void beforeTest() {
|
||||
mMapboxMap = new MapboxMap(mMapView);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSanity() {
|
||||
UiSettings uiSettings = new UiSettings(mMapboxMap);
|
||||
assertNotNull("uiSettings should not be null", uiSettings);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCompassEnabled() {
|
||||
UiSettings uiSettings = new UiSettings(mMapboxMap);
|
||||
uiSettings.setCompassEnabled(true);
|
||||
assertEquals("Compass should be enabled", true, uiSettings.isCompassEnabled());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCompassDisabled() {
|
||||
UiSettings uiSettings = new UiSettings(mMapboxMap);
|
||||
uiSettings.setCompassEnabled(false);
|
||||
assertEquals("Compass should be disabled", false, uiSettings.isCompassEnabled());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCompassGravity() {
|
||||
UiSettings uiSettings = new UiSettings(mMapboxMap);
|
||||
uiSettings.setCompassGravity(Gravity.LEFT);
|
||||
assertEquals("Compass gravity should be same", Gravity.LEFT, uiSettings.getCompassGravity());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCompassMargins() {
|
||||
UiSettings uiSettings = new UiSettings(mMapboxMap);
|
||||
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 testLogoEnabled() {
|
||||
UiSettings uiSettings = new UiSettings(mMapboxMap);
|
||||
uiSettings.setLogoEnabled(true);
|
||||
assertEquals("Logo should be enabled", true, uiSettings.isLogoEnabled());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLogoDisabled() {
|
||||
UiSettings uiSettings = new UiSettings(mMapboxMap);
|
||||
uiSettings.setLogoEnabled(false);
|
||||
assertEquals("Logo should be disabled", false, uiSettings.isLogoEnabled());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLogoGravity() {
|
||||
UiSettings uiSettings = new UiSettings(mMapboxMap);
|
||||
uiSettings.setLogoGravity(Gravity.RIGHT);
|
||||
assertEquals("Logo gravity should be same", Gravity.RIGHT, uiSettings.getLogoGravity());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLogoMargins() {
|
||||
UiSettings uiSettings = new UiSettings(mMapboxMap);
|
||||
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() {
|
||||
UiSettings uiSettings = new UiSettings(mMapboxMap);
|
||||
uiSettings.setAttributionEnabled(true);
|
||||
assertEquals("Attribution should be enabled", true, uiSettings.isAttributionEnabled());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAttributionDisabled() {
|
||||
UiSettings uiSettings = new UiSettings(mMapboxMap);
|
||||
uiSettings.setAttributionEnabled(false);
|
||||
assertEquals("Attribution should be disabled", false, uiSettings.isLogoEnabled());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAttributionGravity() {
|
||||
UiSettings uiSettings = new UiSettings(mMapboxMap);
|
||||
uiSettings.setAttributionGravity(Gravity.RIGHT);
|
||||
assertEquals("Attribution gravity should be same", Gravity.RIGHT, uiSettings.getAttributionGravity());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAttributionMargins() {
|
||||
UiSettings uiSettings = new UiSettings(mMapboxMap);
|
||||
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 uiSettings = new UiSettings(mMapboxMap);
|
||||
uiSettings.setRotateGesturesEnabled(true);
|
||||
assertEquals("Rotate gesture should be enabled", true, uiSettings.isRotateGesturesEnabled());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRotateGesturesDisabled() {
|
||||
UiSettings uiSettings = new UiSettings(mMapboxMap);
|
||||
uiSettings.setRotateGesturesEnabled(false);
|
||||
assertEquals("Rotate gesture should be disabled", false, uiSettings.isRotateGesturesEnabled());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTiltGesturesEnabled() {
|
||||
UiSettings uiSettings = new UiSettings(mMapboxMap);
|
||||
uiSettings.setTiltGesturesEnabled(true);
|
||||
assertEquals("Tilt gesture should be enabled", true, uiSettings.isTiltGesturesEnabled());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTiltGesturesDisabled() {
|
||||
UiSettings uiSettings = new UiSettings(mMapboxMap);
|
||||
uiSettings.setTiltGesturesEnabled(false);
|
||||
assertEquals("Tilt gesture should be disabled", false, uiSettings.isTiltGesturesEnabled());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testZoomGesturesEnabled() {
|
||||
UiSettings uiSettings = new UiSettings(mMapboxMap);
|
||||
uiSettings.setZoomGesturesEnabled(true);
|
||||
assertEquals("Zoom gesture should be enabled", true, uiSettings.isZoomGesturesEnabled());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testZoomGesturesDisabled() {
|
||||
UiSettings uiSettings = new UiSettings(mMapboxMap);
|
||||
uiSettings.setZoomGesturesEnabled(false);
|
||||
assertEquals("Zoom gesture should be disabled", false, uiSettings.isZoomGesturesEnabled());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testZoomControlsEnabled() {
|
||||
UiSettings uiSettings = new UiSettings(mMapboxMap);
|
||||
uiSettings.setZoomControlsEnabled(true);
|
||||
assertEquals("Zoom controls should be enabled", true, uiSettings.isZoomControlsEnabled());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testZoomControlsDisabled() {
|
||||
UiSettings uiSettings = new UiSettings(mMapboxMap);
|
||||
uiSettings.setZoomControlsEnabled(false);
|
||||
assertEquals("Zoom controls should be disabled", false, uiSettings.isZoomControlsEnabled());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testScrollGesturesEnabled() {
|
||||
UiSettings uiSettings = new UiSettings(mMapboxMap);
|
||||
uiSettings.setScrollGesturesEnabled(true);
|
||||
assertEquals("Scroll gesture should be enabled", true, uiSettings.isScrollGesturesEnabled());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testScrollGesturesDisabled() {
|
||||
UiSettings uiSettings = new UiSettings(mMapboxMap);
|
||||
uiSettings.setScrollGesturesEnabled(false);
|
||||
assertEquals("Scroll gesture should be disabled", false, uiSettings.isScrollGesturesEnabled());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAllGesturesEnabled() {
|
||||
UiSettings uiSettings = new UiSettings(mMapboxMap);
|
||||
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 uiSettings = new UiSettings(mMapboxMap);
|
||||
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());
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user