[android] - move min/max zoom to transform class, cleanup usage of double vs float, renaming for parity (#7306)
This commit is contained in:
@@ -9,7 +9,6 @@ import android.support.test.espresso.ViewAction;
|
||||
import android.support.test.rule.ActivityTestRule;
|
||||
import android.view.View;
|
||||
|
||||
import com.mapbox.mapboxsdk.annotations.Annotation;
|
||||
import com.mapbox.mapboxsdk.annotations.BaseMarkerOptions;
|
||||
import com.mapbox.mapboxsdk.annotations.Marker;
|
||||
import com.mapbox.mapboxsdk.annotations.MarkerOptions;
|
||||
@@ -23,6 +22,7 @@ import com.mapbox.mapboxsdk.geometry.LatLng;
|
||||
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;
|
||||
@@ -39,7 +39,6 @@ import timber.log.Timber;
|
||||
|
||||
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.withChild;
|
||||
import static android.support.test.espresso.matcher.ViewMatchers.withId;
|
||||
import static junit.framework.TestCase.assertFalse;
|
||||
import static junit.framework.TestCase.assertNotNull;
|
||||
@@ -87,8 +86,8 @@ public class MapboxMapTest {
|
||||
onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
|
||||
@Override
|
||||
public void onViewAction(UiController uiController, View view) {
|
||||
mapboxMap.setMinZoom(10);
|
||||
assertEquals("MinZoom should match", 10, mapboxMap.getMinZoom(), 10);
|
||||
mapboxMap.setMinZoomPreference(10);
|
||||
assertEquals("MinZoom should match", 10, mapboxMap.getMinZoomLevel(), 10);
|
||||
}
|
||||
}));
|
||||
}
|
||||
@@ -101,8 +100,8 @@ public class MapboxMapTest {
|
||||
onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
|
||||
@Override
|
||||
public void onViewAction(UiController uiController, View view) {
|
||||
mapboxMap.setMaxZoom(zoom);
|
||||
assertEquals("MaxZoom should match", zoom, mapboxMap.getMaxZoom(), 10);
|
||||
mapboxMap.setMaxZoomPreference(zoom);
|
||||
assertEquals("MaxZoom should match", zoom, mapboxMap.getMaxZoomLevel(), 10);
|
||||
}
|
||||
}));
|
||||
}
|
||||
@@ -110,9 +109,14 @@ public class MapboxMapTest {
|
||||
@Test
|
||||
public void testInitialZoomLevels() {
|
||||
ViewUtils.checkViewIsDisplayed(R.id.mapView);
|
||||
MapboxMap mapboxMap = activity.getMapboxMap();
|
||||
assertEquals("MaxZoom should match", MapboxConstants.MAXIMUM_ZOOM, mapboxMap.getMaxZoom(), 0);
|
||||
assertEquals("MinZoom should match", MapboxConstants.MINIMUM_ZOOM, mapboxMap.getMinZoom(), 0);
|
||||
final MapboxMap mapboxMap = activity.getMapboxMap();
|
||||
onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
|
||||
@Override
|
||||
public void onViewAction(UiController uiController, View view) {
|
||||
assertEquals("MaxZoom should match", MapboxConstants.MAXIMUM_ZOOM, mapboxMap.getMaxZoomLevel(), TestConstants.ZOOM_DELTA);
|
||||
assertEquals("MinZoom should match", MapboxConstants.MINIMUM_ZOOM, mapboxMap.getMinZoomLevel(), TestConstants.ZOOM_DELTA);
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
@@ -10,7 +10,7 @@ public class TestConstants {
|
||||
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.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";
|
||||
|
||||
@@ -39,8 +39,8 @@ public class MaxMinZoomActivity extends AppCompatActivity implements OnMapReadyC
|
||||
@Override
|
||||
public void onMapReady(MapboxMap map) {
|
||||
mapboxMap = map;
|
||||
mapboxMap.setMinZoom(3);
|
||||
mapboxMap.setMaxZoom(5);
|
||||
mapboxMap.setMinZoomPreference(3);
|
||||
mapboxMap.setMaxZoomPreference(5);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -51,8 +51,8 @@ public class MapFragmentActivity extends AppCompatActivity implements OnMapReady
|
||||
|
||||
LatLng dc = new LatLng(38.90252, -77.02291);
|
||||
|
||||
options.minZoom(9);
|
||||
options.maxZoom(11);
|
||||
options.minZoomPreference(9);
|
||||
options.maxZoomPreference(11);
|
||||
options.camera(new CameraPosition.Builder()
|
||||
.target(dc)
|
||||
.zoom(11)
|
||||
|
||||
@@ -54,8 +54,8 @@ public class SupportMapFragmentActivity extends AppCompatActivity implements OnM
|
||||
|
||||
LatLng dc = new LatLng(38.90252, -77.02291);
|
||||
|
||||
options.minZoom(9);
|
||||
options.maxZoom(11);
|
||||
options.minZoomPreference(9);
|
||||
options.maxZoomPreference(11);
|
||||
options.camera(new CameraPosition.Builder()
|
||||
.target(dc)
|
||||
.zoom(11)
|
||||
|
||||
@@ -247,7 +247,7 @@ public class OfflineActivity extends AppCompatActivity
|
||||
// Definition
|
||||
LatLngBounds bounds = mapboxMap.getProjection().getVisibleRegion().latLngBounds;
|
||||
double minZoom = mapboxMap.getCameraPosition().zoom;
|
||||
double maxZoom = mapboxMap.getMaxZoom();
|
||||
double maxZoom = mapboxMap.getMaxZoomLevel();
|
||||
float pixelRatio = this.getResources().getDisplayMetrics().density;
|
||||
OfflineTilePyramidRegionDefinition definition = new OfflineTilePyramidRegionDefinition(
|
||||
STYLE_URL, bounds, minZoom, maxZoom, pixelRatio);
|
||||
|
||||
@@ -7,7 +7,6 @@ import com.mapbox.mapboxsdk.camera.CameraPosition;
|
||||
import com.mapbox.mapboxsdk.constants.MapboxConstants;
|
||||
import com.mapbox.mapboxsdk.constants.Style;
|
||||
import com.mapbox.mapboxsdk.geometry.LatLng;
|
||||
import com.mapbox.mapboxsdk.utils.MockParcel;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
@@ -22,6 +21,8 @@ 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());
|
||||
@@ -99,16 +100,16 @@ public class MapboxMapOptionsTest {
|
||||
|
||||
@Test
|
||||
public void testMinZoom() {
|
||||
assertEquals(MapboxConstants.MINIMUM_ZOOM, new MapboxMapOptions().getMinZoom());
|
||||
assertEquals(5.0f, new MapboxMapOptions().minZoom(5.0f).getMinZoom());
|
||||
assertNotEquals(2.0f, new MapboxMapOptions().minZoom(5.0f).getMinZoom());
|
||||
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().getMaxZoom());
|
||||
assertEquals(5.0f, new MapboxMapOptions().maxZoom(5.0f).getMaxZoom());
|
||||
assertNotEquals(2.0f, new MapboxMapOptions().maxZoom(5.0f).getMaxZoom());
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user