[update] pull in latest for gl-native
This commit is contained in:
@@ -0,0 +1,99 @@
|
||||
package com.mapbox.mapboxsdk.maps;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.mapbox.mapboxsdk.camera.CameraPosition;
|
||||
import com.mapbox.mapboxsdk.geometry.LatLng;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.InjectMocks;
|
||||
import org.robolectric.RobolectricTestRunner;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
public class AttributionDialogManagerTest {
|
||||
@InjectMocks
|
||||
Context context = mock(Context.class);
|
||||
|
||||
@InjectMocks
|
||||
MapboxMap mapboxMap = mock(MapboxMap.class);
|
||||
|
||||
@InjectMocks
|
||||
Style style = mock(Style.class);
|
||||
|
||||
private AttributionDialogManager attributionDialogManager;
|
||||
private CameraPosition cameraPosition;
|
||||
|
||||
private static final String ASSERT_MAPBOX_TOKEN = "TestAccessToken";
|
||||
|
||||
private static final String ASSERT_MAPBOX_STYLE_URI = "mapbox://styles/mapbox/streets-v11";
|
||||
private static final String ASSERT_MAPBOX_LOCAL_STYLE_URI = "asset://style.json";
|
||||
|
||||
private static final String ASSERT_MAPBOX_PACKAGE_NAME = "com.mapbox.attributionmanagertest";
|
||||
|
||||
private static final String ASSERT_MAPBOX_FEEDBACK_FINAL_URL =
|
||||
"https://apps.mapbox.com/feedback?referrer=com.mapbox.attributionmanagertest&"
|
||||
+ "access_token=TestAccessToken&owner=mapbox&id=streets-v11"
|
||||
+ "#/22.200001/11.100000/12.000000/24.000000/5";
|
||||
private static final String ASSERT_MAPBOX_FEEDHACK_FINAL_URL_LOCAL_STYLE =
|
||||
"https://apps.mapbox.com/feedback?referrer=com.mapbox.attributionmanagertest&"
|
||||
+ "access_token=TestAccessToken#/22.200001/11.100000/12.000000/24.000000/5";
|
||||
private static final String ASSERT_MAPBOX_FEEDBACL_FINAL_URL_NULL_CAMERA_POSITION =
|
||||
"https://apps.mapbox.com/feedback?referrer=com.mapbox.attributionmanagertest&access_token=TestAccessToken";
|
||||
|
||||
@Before
|
||||
public void beforeTest() {
|
||||
attributionDialogManager = new AttributionDialogManager(context, mapboxMap);
|
||||
cameraPosition = new CameraPosition.Builder(CameraPosition.DEFAULT)
|
||||
.tilt(5.0f).zoom(12).bearing(24.0f).target(new LatLng(11.1f, 22.2f)).build();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSanity() {
|
||||
assertNotNull("AttributionDialogManager should not be null", attributionDialogManager);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBuildMapFeedbackMapUrl() {
|
||||
when(context.getApplicationContext()).thenReturn(context);
|
||||
when(context.getPackageName()).thenReturn(ASSERT_MAPBOX_PACKAGE_NAME);
|
||||
when(style.getUri()).thenReturn(ASSERT_MAPBOX_STYLE_URI);
|
||||
when(mapboxMap.getCameraPosition()).thenReturn(cameraPosition);
|
||||
when(mapboxMap.getStyle()).thenReturn(style);
|
||||
|
||||
Assert.assertEquals(ASSERT_MAPBOX_FEEDBACK_FINAL_URL,
|
||||
attributionDialogManager.buildMapFeedbackMapUrl(ASSERT_MAPBOX_TOKEN));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBuildMapFeedbackMapUrlWithLocalStyleJson() {
|
||||
when(context.getApplicationContext()).thenReturn(context);
|
||||
when(context.getPackageName()).thenReturn(ASSERT_MAPBOX_PACKAGE_NAME);
|
||||
when(style.getUri()).thenReturn(ASSERT_MAPBOX_LOCAL_STYLE_URI);
|
||||
when(mapboxMap.getCameraPosition()).thenReturn(cameraPosition);
|
||||
when(mapboxMap.getStyle()).thenReturn(style);
|
||||
|
||||
Assert.assertEquals(ASSERT_MAPBOX_FEEDHACK_FINAL_URL_LOCAL_STYLE,
|
||||
attributionDialogManager.buildMapFeedbackMapUrl(ASSERT_MAPBOX_TOKEN));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBuildMapFeedbackMapUrlWithNullCameraPosition() {
|
||||
when(context.getApplicationContext()).thenReturn(context);
|
||||
when(context.getPackageName()).thenReturn(ASSERT_MAPBOX_PACKAGE_NAME);
|
||||
when(style.getUri()).thenReturn(ASSERT_MAPBOX_LOCAL_STYLE_URI);
|
||||
when(mapboxMap.getCameraPosition()).thenReturn(null);
|
||||
when(mapboxMap.getStyle()).thenReturn(style);
|
||||
|
||||
Assert.assertEquals(ASSERT_MAPBOX_FEEDBACL_FINAL_URL_NULL_CAMERA_POSITION,
|
||||
attributionDialogManager.buildMapFeedbackMapUrl(ASSERT_MAPBOX_TOKEN));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -167,6 +167,16 @@ public class MapboxMapOptionsTest {
|
||||
assertFalse(new MapboxMapOptions().setPrefetchesTiles(false).getPrefetchesTiles());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPrefetchZoomDelta() {
|
||||
// Default value
|
||||
assertEquals(4, new MapboxMapOptions().getPrefetchZoomDelta());
|
||||
|
||||
// Check mutations
|
||||
assertEquals(5, new MapboxMapOptions().setPrefetchZoomDelta(5).getPrefetchZoomDelta());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testCrossSourceCollisions() {
|
||||
// Default value
|
||||
|
||||
@@ -126,6 +126,18 @@ class MapboxMapTest {
|
||||
verify { nativeMapView.prefetchTiles = true }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testGetPrefetchZoomDelta() {
|
||||
every { nativeMapView.prefetchZoomDelta } answers { 3 }
|
||||
assertEquals(3, mapboxMap.prefetchZoomDelta)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testSetPrefetchZoomDelta() {
|
||||
mapboxMap.prefetchZoomDelta = 2
|
||||
verify { nativeMapView.prefetchZoomDelta = 2 }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testCameraForLatLngBounds() {
|
||||
val bounds = LatLngBounds.Builder().include(LatLng()).include(LatLng(1.0, 1.0)).build()
|
||||
|
||||
@@ -5,6 +5,7 @@ import android.view.View;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import com.mapbox.mapboxsdk.camera.CameraPosition;
|
||||
import com.mapbox.mapboxsdk.maps.widgets.CompassView;
|
||||
|
||||
import org.junit.Before;
|
||||
@@ -17,6 +18,7 @@ import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
public class UiSettingsTest {
|
||||
|
||||
@@ -412,4 +414,20 @@ public class UiSettingsTest {
|
||||
assertEquals("Zoom rate should be 0.83f", 0.83f,
|
||||
uiSettings.getZoomRate(), 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateWhenCompassViewNotHidden() {
|
||||
CameraPosition cameraPosition = new CameraPosition.Builder(CameraPosition.DEFAULT).bearing(24.0f).build();
|
||||
when(compassView.isHidden()).thenReturn(false);
|
||||
uiSettings.update(cameraPosition);
|
||||
verify(compassView).update(-24.0f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateWhenCompassViewHidden() {
|
||||
CameraPosition cameraPosition = new CameraPosition.Builder(CameraPosition.DEFAULT).bearing(24.0f).build();
|
||||
when(compassView.isHidden()).thenReturn(true);
|
||||
uiSettings.update(cameraPosition);
|
||||
verify(compassView).update(-24.0f);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user