[android] - run MapboxMap invocations to ui thread for instrumentation tests (#9198)
This commit is contained in:
@@ -13,6 +13,7 @@ task checkstyle(type: Checkstyle) {
|
||||
include '**/*.java'
|
||||
exclude '**/gen/**'
|
||||
exclude '**/style/*LayerTest.java'
|
||||
exclude '**/style/LightTest.java'
|
||||
classpath = files()
|
||||
ignoreFailures = false
|
||||
}
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
package com.mapbox.mapboxsdk.testapp.action;
|
||||
|
||||
import android.support.test.espresso.UiController;
|
||||
import android.support.test.espresso.ViewAction;
|
||||
import android.view.View;
|
||||
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
|
||||
import org.hamcrest.Matcher;
|
||||
|
||||
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.withId;
|
||||
|
||||
public class MapboxMapAction implements ViewAction {
|
||||
|
||||
private OnInvokeActionListener invokeViewAction;
|
||||
private MapboxMap mapboxMap;
|
||||
|
||||
private MapboxMapAction(OnInvokeActionListener invokeViewAction, MapboxMap mapboxMap) {
|
||||
this.invokeViewAction = invokeViewAction;
|
||||
this.mapboxMap = mapboxMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Matcher<View> getConstraints() {
|
||||
return isDisplayed();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return getClass().getSimpleName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void perform(UiController uiController, View view) {
|
||||
invokeViewAction.onInvokeAction(uiController, mapboxMap);
|
||||
}
|
||||
|
||||
public static void invoke(MapboxMap mapboxMap, OnInvokeActionListener invokeViewAction) {
|
||||
onView(withId(android.R.id.content)).perform(new MapboxMapAction(invokeViewAction, mapboxMap));
|
||||
}
|
||||
|
||||
public interface OnInvokeActionListener {
|
||||
void onInvokeAction(UiController uiController, MapboxMap mapboxMap);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,27 +1,24 @@
|
||||
package com.mapbox.mapboxsdk.testapp.annotations;
|
||||
|
||||
import android.support.test.espresso.UiController;
|
||||
import android.support.test.espresso.ViewAction;
|
||||
import android.view.View;
|
||||
|
||||
import com.mapbox.mapboxsdk.annotations.Marker;
|
||||
import com.mapbox.mapboxsdk.annotations.MarkerOptions;
|
||||
import com.mapbox.mapboxsdk.geometry.LatLng;
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
import com.mapbox.mapboxsdk.testapp.action.MapboxMapAction;
|
||||
import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest;
|
||||
import com.mapbox.mapboxsdk.testapp.activity.espresso.EspressoTestActivity;
|
||||
import com.mapbox.mapboxsdk.testapp.utils.TestConstants;
|
||||
|
||||
import org.hamcrest.Matcher;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import static android.support.test.espresso.Espresso.onView;
|
||||
import static android.support.test.espresso.assertion.ViewAssertions.matches;
|
||||
import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed;
|
||||
import static android.support.test.espresso.matcher.ViewMatchers.withId;
|
||||
import static android.support.test.espresso.matcher.ViewMatchers.withText;
|
||||
import static com.mapbox.mapboxsdk.testapp.action.MapboxMapAction.invoke;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class MarkerTest extends BaseActivityTest {
|
||||
@@ -37,87 +34,45 @@ public class MarkerTest extends BaseActivityTest {
|
||||
@Ignore
|
||||
public void addMarkerTest() {
|
||||
validateTestSetup();
|
||||
assertEquals("Markers should be empty", 0, mapboxMap.getMarkers().size());
|
||||
MapboxMapAction.invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertEquals("Markers should be empty", 0, mapboxMap.getMarkers().size());
|
||||
|
||||
MarkerOptions options = new MarkerOptions();
|
||||
options.setPosition(new LatLng());
|
||||
options.setSnippet(TestConstants.TEXT_MARKER_SNIPPET);
|
||||
options.setTitle(TestConstants.TEXT_MARKER_TITLE);
|
||||
MarkerOptions options = new MarkerOptions();
|
||||
options.setPosition(new LatLng());
|
||||
options.setSnippet(TestConstants.TEXT_MARKER_SNIPPET);
|
||||
options.setTitle(TestConstants.TEXT_MARKER_TITLE);
|
||||
marker = mapboxMap.addMarker(options);
|
||||
|
||||
onView(withId(R.id.mapView)).perform(new AddMarkerAction(mapboxMap, options));
|
||||
assertEquals("Markers sze should be 1, ", 1, mapboxMap.getMarkers().size());
|
||||
assertEquals("Marker id should be 0", 0, marker.getId());
|
||||
assertEquals("Marker target should match", new LatLng(), marker.getPosition());
|
||||
assertEquals("Marker snippet should match", TestConstants.TEXT_MARKER_SNIPPET, marker.getSnippet());
|
||||
assertEquals("Marker target should match", TestConstants.TEXT_MARKER_TITLE, marker.getTitle());
|
||||
mapboxMap.clear();
|
||||
assertEquals("Markers should be empty", 0, mapboxMap.getMarkers().size());
|
||||
assertEquals("Markers size should be 1, ", 1, mapboxMap.getMarkers().size());
|
||||
assertEquals("Marker id should be 0", 0, marker.getId());
|
||||
assertEquals("Marker target should match", new LatLng(), marker.getPosition());
|
||||
assertEquals("Marker snippet should match", TestConstants.TEXT_MARKER_SNIPPET, marker.getSnippet());
|
||||
assertEquals("Marker target should match", TestConstants.TEXT_MARKER_TITLE, marker.getTitle());
|
||||
mapboxMap.clear();
|
||||
assertEquals("Markers should be empty", 0, mapboxMap.getMarkers().size());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void showInfoWindowTest() {
|
||||
validateTestSetup();
|
||||
|
||||
final MarkerOptions options = new MarkerOptions();
|
||||
options.setPosition(new LatLng());
|
||||
options.setSnippet(TestConstants.TEXT_MARKER_SNIPPET);
|
||||
options.setTitle(TestConstants.TEXT_MARKER_TITLE);
|
||||
|
||||
onView(withId(R.id.mapView)).perform(new AddMarkerAction(mapboxMap, options));
|
||||
onView(withId(R.id.mapView)).perform(new ShowInfoWindowAction(mapboxMap));
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
final MarkerOptions options = new MarkerOptions();
|
||||
options.setPosition(new LatLng());
|
||||
options.setSnippet(TestConstants.TEXT_MARKER_SNIPPET);
|
||||
options.setTitle(TestConstants.TEXT_MARKER_TITLE);
|
||||
marker = mapboxMap.addMarker(options);
|
||||
mapboxMap.selectMarker(marker);
|
||||
}
|
||||
});
|
||||
onView(withText(TestConstants.TEXT_MARKER_TITLE)).check(matches(isDisplayed()));
|
||||
onView(withText(TestConstants.TEXT_MARKER_SNIPPET)).check(matches(isDisplayed()));
|
||||
}
|
||||
|
||||
private class AddMarkerAction implements ViewAction {
|
||||
|
||||
private MapboxMap mapboxMap;
|
||||
private MarkerOptions options;
|
||||
|
||||
AddMarkerAction(MapboxMap map, MarkerOptions markerOptions) {
|
||||
mapboxMap = map;
|
||||
options = markerOptions;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Matcher<View> getConstraints() {
|
||||
return isDisplayed();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return getClass().getSimpleName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void perform(UiController uiController, View view) {
|
||||
marker = mapboxMap.addMarker(options);
|
||||
}
|
||||
}
|
||||
|
||||
private class ShowInfoWindowAction implements ViewAction {
|
||||
|
||||
private MapboxMap mapboxMap;
|
||||
|
||||
ShowInfoWindowAction(MapboxMap map) {
|
||||
mapboxMap = map;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Matcher<View> getConstraints() {
|
||||
return isDisplayed();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return getClass().getSimpleName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void perform(UiController uiController, View view) {
|
||||
mapboxMap.selectMarker(marker);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,28 +1,25 @@
|
||||
package com.mapbox.mapboxsdk.testapp.annotations;
|
||||
|
||||
import android.support.test.espresso.UiController;
|
||||
import android.support.test.espresso.ViewAction;
|
||||
import android.view.View;
|
||||
|
||||
import com.mapbox.mapboxsdk.annotations.Marker;
|
||||
import com.mapbox.mapboxsdk.geometry.LatLng;
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
import com.mapbox.mapboxsdk.testapp.action.MapboxMapAction;
|
||||
import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest;
|
||||
import com.mapbox.mapboxsdk.testapp.activity.annotation.MarkerViewActivity;
|
||||
import com.mapbox.mapboxsdk.testapp.activity.espresso.EspressoTestActivity;
|
||||
import com.mapbox.mapboxsdk.testapp.model.annotations.TextMarkerViewOptions;
|
||||
import com.mapbox.mapboxsdk.testapp.utils.TestConstants;
|
||||
|
||||
import org.hamcrest.Matcher;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import static android.support.test.espresso.Espresso.onView;
|
||||
import static android.support.test.espresso.assertion.ViewAssertions.matches;
|
||||
import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed;
|
||||
import static android.support.test.espresso.matcher.ViewMatchers.withId;
|
||||
import static android.support.test.espresso.matcher.ViewMatchers.withText;
|
||||
import static com.mapbox.mapboxsdk.testapp.action.MapboxMapAction.invoke;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class MarkerViewTest extends BaseActivityTest {
|
||||
@@ -38,20 +35,26 @@ public class MarkerViewTest extends BaseActivityTest {
|
||||
@Ignore
|
||||
public void addMarkerViewTest() {
|
||||
validateTestSetup();
|
||||
assertEquals("Markers should be empty", 0, mapboxMap.getMarkers().size());
|
||||
addAdapter();
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertEquals("Markers should be empty", 0, mapboxMap.getMarkers().size());
|
||||
|
||||
TextMarkerViewOptions options = new TextMarkerViewOptions();
|
||||
options.text(TestConstants.TEXT_MARKER_TEXT);
|
||||
options.position(new LatLng());
|
||||
options.snippet(TestConstants.TEXT_MARKER_SNIPPET);
|
||||
options.title(TestConstants.TEXT_MARKER_TITLE);
|
||||
|
||||
onView(withId(R.id.mapView)).perform(new AddTextMarkerViewAction(mapboxMap, options));
|
||||
assertEquals("Markers sze should be 1, ", 1, mapboxMap.getMarkers().size());
|
||||
assertEquals("Marker id should be 0", 0, marker.getId());
|
||||
assertEquals("Marker target should match", new LatLng(), marker.getPosition());
|
||||
assertEquals("Marker snippet should match", TestConstants.TEXT_MARKER_SNIPPET, marker.getSnippet());
|
||||
assertEquals("Marker target should match", TestConstants.TEXT_MARKER_TITLE, marker.getTitle());
|
||||
TextMarkerViewOptions options = new TextMarkerViewOptions();
|
||||
options.text(TestConstants.TEXT_MARKER_TEXT);
|
||||
options.position(new LatLng());
|
||||
options.snippet(TestConstants.TEXT_MARKER_SNIPPET);
|
||||
options.title(TestConstants.TEXT_MARKER_TITLE);
|
||||
marker = mapboxMap.addMarker(options);
|
||||
assertEquals("Markers size should be 1, ", 1, mapboxMap.getMarkers().size());
|
||||
assertEquals("Marker id should be 0", 0, marker.getId());
|
||||
assertEquals("Marker target should match", new LatLng(), marker.getPosition());
|
||||
assertEquals("Marker snippet should match", TestConstants.TEXT_MARKER_SNIPPET, marker.getSnippet());
|
||||
assertEquals("Marker target should match", TestConstants.TEXT_MARKER_TITLE, marker.getTitle());
|
||||
uiController.loopMainThreadForAtLeast(500);
|
||||
}
|
||||
});
|
||||
onView(withText(TestConstants.TEXT_MARKER_TEXT)).check(matches(isDisplayed()));
|
||||
}
|
||||
|
||||
@@ -59,71 +62,33 @@ public class MarkerViewTest extends BaseActivityTest {
|
||||
@Ignore
|
||||
public void showInfoWindowTest() {
|
||||
validateTestSetup();
|
||||
|
||||
final TextMarkerViewOptions options = new TextMarkerViewOptions();
|
||||
options.position(new LatLng());
|
||||
options.text(TestConstants.TEXT_MARKER_TEXT);
|
||||
options.snippet(TestConstants.TEXT_MARKER_SNIPPET);
|
||||
options.title(TestConstants.TEXT_MARKER_TITLE);
|
||||
|
||||
onView(withId(R.id.mapView)).perform(new AddTextMarkerViewAction(mapboxMap, options));
|
||||
addAdapter();
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
final TextMarkerViewOptions options = new TextMarkerViewOptions();
|
||||
options.position(new LatLng());
|
||||
options.text(TestConstants.TEXT_MARKER_TEXT);
|
||||
options.snippet(TestConstants.TEXT_MARKER_SNIPPET);
|
||||
options.title(TestConstants.TEXT_MARKER_TITLE);
|
||||
marker = mapboxMap.addMarker(options);
|
||||
uiController.loopMainThreadForAtLeast(500);
|
||||
mapboxMap.selectMarker(marker);
|
||||
}
|
||||
});
|
||||
onView(withText(TestConstants.TEXT_MARKER_TEXT)).check(matches(isDisplayed()));
|
||||
onView(withId(R.id.mapView)).perform(new ShowInfoWindowAction(mapboxMap));
|
||||
onView(withText(TestConstants.TEXT_MARKER_TITLE)).check(matches(isDisplayed()));
|
||||
onView(withText(TestConstants.TEXT_MARKER_SNIPPET)).check(matches(isDisplayed()));
|
||||
}
|
||||
|
||||
private class AddTextMarkerViewAction implements ViewAction {
|
||||
|
||||
private MapboxMap mapboxMap;
|
||||
private TextMarkerViewOptions options;
|
||||
|
||||
AddTextMarkerViewAction(MapboxMap map, TextMarkerViewOptions markerOptions) {
|
||||
mapboxMap = map;
|
||||
options = markerOptions;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Matcher<View> getConstraints() {
|
||||
return isDisplayed();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return getClass().getSimpleName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void perform(UiController uiController, View view) {
|
||||
mapboxMap.getMarkerViewManager().addMarkerViewAdapter(
|
||||
new MarkerViewActivity.TextAdapter(view.getContext(), mapboxMap));
|
||||
marker = mapboxMap.addMarker(options);
|
||||
uiController.loopMainThreadForAtLeast(250);
|
||||
}
|
||||
private void addAdapter() {
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
mapboxMap.getMarkerViewManager().addMarkerViewAdapter(
|
||||
new MarkerViewActivity.TextAdapter(rule.getActivity(), mapboxMap));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private class ShowInfoWindowAction implements ViewAction {
|
||||
|
||||
private MapboxMap mapboxMap;
|
||||
|
||||
ShowInfoWindowAction(MapboxMap map) {
|
||||
mapboxMap = map;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Matcher<View> getConstraints() {
|
||||
return isDisplayed();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return getClass().getSimpleName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void perform(UiController uiController, View view) {
|
||||
mapboxMap.selectMarker(marker);
|
||||
uiController.loopMainThreadForAtLeast(250);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,24 +2,19 @@ package com.mapbox.mapboxsdk.testapp.annotations;
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.support.test.espresso.UiController;
|
||||
import android.support.test.espresso.ViewAction;
|
||||
import android.view.View;
|
||||
|
||||
import com.mapbox.mapboxsdk.annotations.Polygon;
|
||||
import com.mapbox.mapboxsdk.annotations.PolygonOptions;
|
||||
import com.mapbox.mapboxsdk.geometry.LatLng;
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
import com.mapbox.mapboxsdk.testapp.action.MapboxMapAction;
|
||||
import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest;
|
||||
import com.mapbox.mapboxsdk.testapp.activity.espresso.EspressoTestActivity;
|
||||
|
||||
import org.hamcrest.Matcher;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
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.withId;
|
||||
import static com.mapbox.mapboxsdk.testapp.action.MapboxMapAction.invoke;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class PolygonTest extends BaseActivityTest {
|
||||
@@ -29,60 +24,35 @@ public class PolygonTest extends BaseActivityTest {
|
||||
return EspressoTestActivity.class;
|
||||
}
|
||||
|
||||
private Polygon polygon;
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
/** native crash **/
|
||||
public void addPolygonTest() {
|
||||
validateTestSetup();
|
||||
LatLng latLngOne = new LatLng();
|
||||
LatLng latLngTwo = new LatLng(1, 0);
|
||||
LatLng latLngThree = new LatLng(1, 1);
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
LatLng latLngOne = new LatLng();
|
||||
LatLng latLngTwo = new LatLng(1, 0);
|
||||
LatLng latLngThree = new LatLng(1, 1);
|
||||
|
||||
assertEquals("Polygons should be empty", 0, mapboxMap.getPolygons().size());
|
||||
assertEquals("Polygons should be empty", 0, mapboxMap.getPolygons().size());
|
||||
|
||||
final PolygonOptions options = new PolygonOptions();
|
||||
options.strokeColor(Color.BLUE);
|
||||
options.fillColor(Color.RED);
|
||||
options.add(latLngOne);
|
||||
options.add(latLngTwo);
|
||||
options.add(latLngThree);
|
||||
final PolygonOptions options = new PolygonOptions();
|
||||
options.strokeColor(Color.BLUE);
|
||||
options.fillColor(Color.RED);
|
||||
options.add(latLngOne);
|
||||
options.add(latLngTwo);
|
||||
options.add(latLngThree);
|
||||
Polygon polygon = mapboxMap.addPolygon(options);
|
||||
|
||||
onView(withId(R.id.mapView)).perform(new AddPolygonAction(mapboxMap, options));
|
||||
|
||||
assertEquals("Polygons should be 1", 1, mapboxMap.getPolygons().size());
|
||||
assertEquals("Polygon id should be 0", 0, polygon.getId());
|
||||
assertEquals("Polygon points size should match", 3, polygon.getPoints().size());
|
||||
assertEquals("Polygon stroke color should match", Color.BLUE, polygon.getStrokeColor());
|
||||
assertEquals("Polygon target should match", Color.RED, polygon.getFillColor());
|
||||
mapboxMap.clear();
|
||||
assertEquals("Polygons should be empty", 0, mapboxMap.getPolygons().size());
|
||||
}
|
||||
|
||||
private class AddPolygonAction implements ViewAction {
|
||||
|
||||
private MapboxMap mapboxMap;
|
||||
private PolygonOptions options;
|
||||
|
||||
AddPolygonAction(MapboxMap map, PolygonOptions polygonOptions) {
|
||||
mapboxMap = map;
|
||||
options = polygonOptions;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Matcher<View> getConstraints() {
|
||||
return isDisplayed();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return getClass().getSimpleName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void perform(UiController uiController, View view) {
|
||||
polygon = mapboxMap.addPolygon(options);
|
||||
}
|
||||
assertEquals("Polygons should be 1", 1, mapboxMap.getPolygons().size());
|
||||
assertEquals("Polygon id should be 0", 0, polygon.getId());
|
||||
assertEquals("Polygon points size should match", 3, polygon.getPoints().size());
|
||||
assertEquals("Polygon stroke color should match", Color.BLUE, polygon.getStrokeColor());
|
||||
assertEquals("Polygon target should match", Color.RED, polygon.getFillColor());
|
||||
mapboxMap.clear();
|
||||
assertEquals("Polygons should be empty", 0, mapboxMap.getPolygons().size());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,82 +2,53 @@ package com.mapbox.mapboxsdk.testapp.annotations;
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.support.test.espresso.UiController;
|
||||
import android.support.test.espresso.ViewAction;
|
||||
import android.view.View;
|
||||
|
||||
import com.mapbox.mapboxsdk.annotations.Polyline;
|
||||
import com.mapbox.mapboxsdk.annotations.PolylineOptions;
|
||||
import com.mapbox.mapboxsdk.geometry.LatLng;
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
import com.mapbox.mapboxsdk.testapp.action.MapboxMapAction;
|
||||
import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest;
|
||||
import com.mapbox.mapboxsdk.testapp.activity.espresso.EspressoTestActivity;
|
||||
|
||||
import org.hamcrest.Matcher;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
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.withId;
|
||||
import static com.mapbox.mapboxsdk.testapp.action.MapboxMapAction.invoke;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class PolylineTest extends BaseActivityTest {
|
||||
|
||||
private Polyline polyline;
|
||||
|
||||
@Override
|
||||
protected Class getActivityClass() {
|
||||
return EspressoTestActivity.class;
|
||||
}
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
@Ignore
|
||||
public void addPolylineTest() {
|
||||
validateTestSetup();
|
||||
LatLng latLngOne = new LatLng();
|
||||
LatLng latLngTwo = new LatLng(1, 0);
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
LatLng latLngOne = new LatLng();
|
||||
LatLng latLngTwo = new LatLng(1, 0);
|
||||
|
||||
assertEquals("Polygons should be empty", 0, mapboxMap.getPolygons().size());
|
||||
assertEquals("Polygons should be empty", 0, mapboxMap.getPolygons().size());
|
||||
|
||||
final PolylineOptions options = new PolylineOptions();
|
||||
options.color(Color.BLUE);
|
||||
options.add(latLngOne);
|
||||
options.add(latLngTwo);
|
||||
final PolylineOptions options = new PolylineOptions();
|
||||
options.color(Color.BLUE);
|
||||
options.add(latLngOne);
|
||||
options.add(latLngTwo);
|
||||
Polyline polyline = mapboxMap.addPolyline(options);
|
||||
|
||||
onView(withId(R.id.mapView)).perform(new AddPolyLineAction(mapboxMap, options));
|
||||
|
||||
assertEquals("Polylines should be 1", 1, mapboxMap.getPolylines().size());
|
||||
assertEquals("Polyline id should be 0", 0, polyline.getId());
|
||||
assertEquals("Polyline points size should match", 2, polyline.getPoints().size());
|
||||
assertEquals("Polyline stroke color should match", Color.BLUE, polyline.getColor());
|
||||
mapboxMap.clear();
|
||||
assertEquals("Polyline should be empty", 0, mapboxMap.getPolylines().size());
|
||||
}
|
||||
|
||||
private class AddPolyLineAction implements ViewAction {
|
||||
|
||||
private MapboxMap mapboxMap;
|
||||
private PolylineOptions options;
|
||||
|
||||
AddPolyLineAction(MapboxMap map, PolylineOptions polylineOptions) {
|
||||
mapboxMap = map;
|
||||
options = polylineOptions;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Matcher<View> getConstraints() {
|
||||
return isDisplayed();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return getClass().getSimpleName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void perform(UiController uiController, View view) {
|
||||
polyline = mapboxMap.addPolyline(options);
|
||||
}
|
||||
assertEquals("Polylines should be 1", 1, mapboxMap.getPolylines().size());
|
||||
assertEquals("Polyline id should be 0", 0, polyline.getId());
|
||||
assertEquals("Polyline points size should match", 2, polyline.getPoints().size());
|
||||
assertEquals("Polyline stroke color should match", Color.BLUE, polyline.getColor());
|
||||
mapboxMap.clear();
|
||||
assertEquals("Polyline should be empty", 0, mapboxMap.getPolylines().size());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,27 +2,21 @@ package com.mapbox.mapboxsdk.testapp.camera;
|
||||
|
||||
import android.graphics.PointF;
|
||||
import android.support.test.espresso.UiController;
|
||||
import android.support.test.espresso.ViewAction;
|
||||
import android.view.View;
|
||||
|
||||
import com.mapbox.mapboxsdk.camera.CameraPosition;
|
||||
import com.mapbox.mapboxsdk.camera.CameraUpdate;
|
||||
import com.mapbox.mapboxsdk.camera.CameraUpdateFactory;
|
||||
import com.mapbox.mapboxsdk.geometry.LatLng;
|
||||
import com.mapbox.mapboxsdk.geometry.LatLngBounds;
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
import com.mapbox.mapboxsdk.testapp.action.MapboxMapAction;
|
||||
import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest;
|
||||
import com.mapbox.mapboxsdk.testapp.activity.espresso.EspressoTestActivity;
|
||||
import com.mapbox.mapboxsdk.testapp.utils.TestConstants;
|
||||
|
||||
import org.hamcrest.Matcher;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
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.withId;
|
||||
import static com.mapbox.mapboxsdk.testapp.action.MapboxMapAction.invoke;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class CameraAnimateTest extends BaseActivityTest {
|
||||
@@ -36,202 +30,199 @@ public class CameraAnimateTest extends BaseActivityTest {
|
||||
@Ignore
|
||||
public void testAnimateToCameraPositionTarget() {
|
||||
validateTestSetup();
|
||||
|
||||
/*TODO remove zoom #6474*/
|
||||
float zoom = 1.0f;
|
||||
LatLng moveTarget = new LatLng(1, 1);
|
||||
|
||||
CameraPosition initialPosition = new CameraPosition.Builder().target(
|
||||
new LatLng()).zoom(zoom).bearing(0).tilt(0).build();
|
||||
CameraPosition cameraPosition = mapboxMap.getCameraPosition();
|
||||
assertEquals("Default camera position should match default", cameraPosition, initialPosition);
|
||||
|
||||
onView(withId(R.id.mapView)).perform(new AnimateCameraAction(mapboxMap, CameraUpdateFactory.newLatLng(moveTarget)));
|
||||
cameraPosition = mapboxMap.getCameraPosition();
|
||||
assertEquals("Moved camera position latitude should match", cameraPosition.target.getLatitude(),
|
||||
moveTarget.getLatitude(), TestConstants.LAT_LNG_DELTA);
|
||||
assertEquals("Moved camera position longitude should match", cameraPosition.target.getLongitude(),
|
||||
moveTarget.getLongitude(), TestConstants.LAT_LNG_DELTA);
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
float zoom = 1.0f;
|
||||
LatLng moveTarget = new LatLng(1, 1);
|
||||
CameraPosition initialPosition = new CameraPosition.Builder().target(
|
||||
new LatLng()).zoom(zoom).bearing(0).tilt(0).build();
|
||||
CameraPosition cameraPosition = mapboxMap.getCameraPosition();
|
||||
assertEquals("Default camera position should match default", cameraPosition, initialPosition);
|
||||
mapboxMap.animateCamera(CameraUpdateFactory.newLatLng(moveTarget));
|
||||
uiController.loopMainThreadForAtLeast(TestConstants.ANIMATION_TEST_TIME);
|
||||
cameraPosition = mapboxMap.getCameraPosition();
|
||||
assertEquals("Moved camera position latitude should match", cameraPosition.target.getLatitude(),
|
||||
moveTarget.getLatitude(), TestConstants.LAT_LNG_DELTA);
|
||||
assertEquals("Moved camera position longitude should match", cameraPosition.target.getLongitude(),
|
||||
moveTarget.getLongitude(), TestConstants.LAT_LNG_DELTA);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void testAnimateToCameraPositionTargetZoom() {
|
||||
validateTestSetup();
|
||||
|
||||
final float moveZoom = 15.5f;
|
||||
final LatLng moveTarget = new LatLng(1.0000000001, 1.0000000003);
|
||||
|
||||
onView(withId(R.id.mapView)).perform(new AnimateCameraAction(mapboxMap,
|
||||
CameraUpdateFactory.newLatLngZoom(moveTarget, moveZoom)));
|
||||
CameraPosition cameraPosition = mapboxMap.getCameraPosition();
|
||||
assertEquals("Moved camera position latitude should match", cameraPosition.target.getLatitude(),
|
||||
moveTarget.getLatitude(), TestConstants.LAT_LNG_DELTA);
|
||||
assertEquals("Moved camera position longitude should match", cameraPosition.target.getLongitude(),
|
||||
moveTarget.getLongitude(), TestConstants.LAT_LNG_DELTA);
|
||||
assertEquals("Moved zoom should match", cameraPosition.zoom, moveZoom, TestConstants.ZOOM_DELTA);
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
final float moveZoom = 15.5f;
|
||||
final LatLng moveTarget = new LatLng(1.0000000001, 1.0000000003);
|
||||
mapboxMap.animateCamera(CameraUpdateFactory.newLatLngZoom(moveTarget, moveZoom));
|
||||
uiController.loopMainThreadForAtLeast(TestConstants.ANIMATION_TEST_TIME);
|
||||
CameraPosition cameraPosition = mapboxMap.getCameraPosition();
|
||||
assertEquals("Moved camera position latitude should match", cameraPosition.target.getLatitude(),
|
||||
moveTarget.getLatitude(), TestConstants.LAT_LNG_DELTA);
|
||||
assertEquals("Moved camera position longitude should match", cameraPosition.target.getLongitude(),
|
||||
moveTarget.getLongitude(), TestConstants.LAT_LNG_DELTA);
|
||||
assertEquals("Moved zoom should match", cameraPosition.zoom, moveZoom, TestConstants.ZOOM_DELTA);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void testAnimateToCameraPosition() {
|
||||
validateTestSetup();
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
final LatLng moveTarget = new LatLng(1.0000000001, 1.0000000003);
|
||||
final float moveZoom = 15.5f;
|
||||
final float moveTilt = 45.5f;
|
||||
final float moveBearing = 12.5f;
|
||||
|
||||
final LatLng moveTarget = new LatLng(1.0000000001, 1.0000000003);
|
||||
final float moveZoom = 15.5f;
|
||||
final float moveTilt = 45.5f;
|
||||
final float moveBearing = 12.5f;
|
||||
|
||||
onView(withId(R.id.mapView)).perform(
|
||||
new AnimateCameraAction(mapboxMap, CameraUpdateFactory.newCameraPosition(
|
||||
new CameraPosition.Builder()
|
||||
.target(moveTarget)
|
||||
.zoom(moveZoom)
|
||||
.tilt(moveTilt)
|
||||
.bearing(moveBearing)
|
||||
.build()))
|
||||
);
|
||||
|
||||
CameraPosition cameraPosition = mapboxMap.getCameraPosition();
|
||||
assertEquals("Moved camera position latitude should match", cameraPosition.target.getLatitude(),
|
||||
moveTarget.getLatitude(), TestConstants.LAT_LNG_DELTA);
|
||||
assertEquals("Moved camera position longitude should match", cameraPosition.target.getLongitude(),
|
||||
moveTarget.getLongitude(), TestConstants.LAT_LNG_DELTA);
|
||||
assertEquals("Moved zoom should match", cameraPosition.zoom, moveZoom, TestConstants.ZOOM_DELTA);
|
||||
assertEquals("Moved zoom should match", cameraPosition.tilt, moveTilt, TestConstants.TILT_DELTA);
|
||||
assertEquals("Moved bearing should match", cameraPosition.bearing, moveBearing, TestConstants.BEARING_DELTA);
|
||||
mapboxMap.animateCamera(CameraUpdateFactory.newCameraPosition(
|
||||
new CameraPosition.Builder()
|
||||
.target(moveTarget)
|
||||
.zoom(moveZoom)
|
||||
.tilt(moveTilt)
|
||||
.bearing(moveBearing)
|
||||
.build())
|
||||
);
|
||||
uiController.loopMainThreadForAtLeast(TestConstants.ANIMATION_TEST_TIME);
|
||||
CameraPosition cameraPosition = mapboxMap.getCameraPosition();
|
||||
assertEquals("Moved camera position latitude should match", cameraPosition.target.getLatitude(),
|
||||
moveTarget.getLatitude(), TestConstants.LAT_LNG_DELTA);
|
||||
assertEquals("Moved camera position longitude should match", cameraPosition.target.getLongitude(),
|
||||
moveTarget.getLongitude(), TestConstants.LAT_LNG_DELTA);
|
||||
assertEquals("Moved zoom should match", cameraPosition.zoom, moveZoom, TestConstants.ZOOM_DELTA);
|
||||
assertEquals("Moved zoom should match", cameraPosition.tilt, moveTilt, TestConstants.TILT_DELTA);
|
||||
assertEquals("Moved bearing should match", cameraPosition.bearing, moveBearing, TestConstants.BEARING_DELTA);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void testAnimateToBounds() {
|
||||
validateTestSetup();
|
||||
|
||||
final LatLng centerBounds = new LatLng(1, 1);
|
||||
LatLng cornerOne = new LatLng();
|
||||
LatLng cornerTwo = new LatLng(2, 2);
|
||||
|
||||
final LatLngBounds.Builder builder = new LatLngBounds.Builder();
|
||||
builder.include(cornerOne);
|
||||
builder.include(cornerTwo);
|
||||
|
||||
onView(withId(R.id.mapView)).perform(new AnimateCameraAction(mapboxMap,
|
||||
CameraUpdateFactory.newLatLngBounds(builder.build(), 0)));
|
||||
|
||||
CameraPosition cameraPosition = mapboxMap.getCameraPosition();
|
||||
assertEquals("Moved camera position latitude should match center bounds",
|
||||
cameraPosition.target.getLatitude(),
|
||||
centerBounds.getLatitude(),
|
||||
TestConstants.LAT_LNG_DELTA);
|
||||
|
||||
assertEquals("Moved camera position longitude should match center bounds",
|
||||
cameraPosition.target.getLongitude(),
|
||||
centerBounds.getLongitude(),
|
||||
TestConstants.LAT_LNG_DELTA);
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
final LatLng centerBounds = new LatLng(1, 1);
|
||||
LatLng cornerOne = new LatLng();
|
||||
LatLng cornerTwo = new LatLng(2, 2);
|
||||
final LatLngBounds.Builder builder = new LatLngBounds.Builder();
|
||||
builder.include(cornerOne);
|
||||
builder.include(cornerTwo);
|
||||
mapboxMap.animateCamera(CameraUpdateFactory.newLatLngBounds(builder.build(), 0));
|
||||
uiController.loopMainThreadForAtLeast(TestConstants.ANIMATION_TEST_TIME);
|
||||
CameraPosition cameraPosition = mapboxMap.getCameraPosition();
|
||||
assertEquals("Moved camera position latitude should match center bounds",
|
||||
cameraPosition.target.getLatitude(),
|
||||
centerBounds.getLatitude(),
|
||||
TestConstants.LAT_LNG_DELTA);
|
||||
assertEquals("Moved camera position longitude should match center bounds",
|
||||
cameraPosition.target.getLongitude(),
|
||||
centerBounds.getLongitude(),
|
||||
TestConstants.LAT_LNG_DELTA);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void testAnimateToMoveBy() {
|
||||
validateTestSetup();
|
||||
|
||||
final PointF centerPoint = mapboxMap.getProjection().toScreenLocation(mapboxMap.getCameraPosition().target);
|
||||
final LatLng moveTarget = new LatLng(2, 2);
|
||||
final PointF moveTargetPoint = mapboxMap.getProjection().toScreenLocation(moveTarget);
|
||||
|
||||
onView(withId(R.id.mapView)).perform(new AnimateCameraAction(mapboxMap, CameraUpdateFactory.scrollBy(
|
||||
moveTargetPoint.x - centerPoint.x, moveTargetPoint.y - centerPoint.y)));
|
||||
|
||||
CameraPosition cameraPosition = mapboxMap.getCameraPosition();
|
||||
assertEquals("Moved camera position latitude should match", cameraPosition.target.getLatitude(),
|
||||
moveTarget.getLatitude(), TestConstants.LAT_LNG_DELTA_LARGE);
|
||||
assertEquals("Moved camera position longitude should match", cameraPosition.target.getLongitude(),
|
||||
moveTarget.getLongitude(), TestConstants.LAT_LNG_DELTA_LARGE);
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
final PointF centerPoint = mapboxMap.getProjection().toScreenLocation(mapboxMap.getCameraPosition().target);
|
||||
final LatLng moveTarget = new LatLng(2, 2);
|
||||
final PointF moveTargetPoint = mapboxMap.getProjection().toScreenLocation(moveTarget);
|
||||
mapboxMap.animateCamera(CameraUpdateFactory.scrollBy(
|
||||
moveTargetPoint.x - centerPoint.x, moveTargetPoint.y - centerPoint.y));
|
||||
uiController.loopMainThreadForAtLeast(TestConstants.ANIMATION_TEST_TIME);
|
||||
CameraPosition cameraPosition = mapboxMap.getCameraPosition();
|
||||
assertEquals("Moved camera position latitude should match", cameraPosition.target.getLatitude(),
|
||||
moveTarget.getLatitude(), TestConstants.LAT_LNG_DELTA_LARGE);
|
||||
assertEquals("Moved camera position longitude should match", cameraPosition.target.getLongitude(),
|
||||
moveTarget.getLongitude(), TestConstants.LAT_LNG_DELTA_LARGE);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void testAnimateToZoomIn() {
|
||||
validateTestSetup();
|
||||
|
||||
/*TODO fix zoom #6474*/
|
||||
float zoom = 1.0f;
|
||||
|
||||
onView(withId(R.id.mapView)).perform(new AnimateCameraAction(mapboxMap, CameraUpdateFactory.zoomIn()));
|
||||
CameraPosition cameraPosition = mapboxMap.getCameraPosition();
|
||||
assertEquals("Moved camera zoom should match moved camera zoom", cameraPosition.zoom, zoom + 1,
|
||||
TestConstants.ZOOM_DELTA);
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
float zoom = 1.0f;
|
||||
mapboxMap.animateCamera(CameraUpdateFactory.zoomIn());
|
||||
uiController.loopMainThreadForAtLeast(TestConstants.ANIMATION_TEST_TIME);
|
||||
CameraPosition cameraPosition = mapboxMap.getCameraPosition();
|
||||
assertEquals("Moved camera zoom should match moved camera zoom", cameraPosition.zoom, zoom + 1,
|
||||
TestConstants.ZOOM_DELTA);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void testAnimateToZoomOut() {
|
||||
validateTestSetup();
|
||||
|
||||
/*TODO fix zoom #6474*/
|
||||
float zoom = 10.0f;
|
||||
onView(withId(R.id.mapView)).perform(new AnimateCameraAction(mapboxMap,
|
||||
CameraUpdateFactory.newLatLngZoom(new LatLng(), zoom)));
|
||||
onView(withId(R.id.mapView)).perform(new AnimateCameraAction(mapboxMap, CameraUpdateFactory.zoomOut()));
|
||||
CameraPosition cameraPosition = mapboxMap.getCameraPosition();
|
||||
assertEquals("Moved camera zoom should match moved camera zoom", cameraPosition.zoom, zoom - 1,
|
||||
TestConstants.ZOOM_DELTA);
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
float zoom = 10.0f;
|
||||
mapboxMap.animateCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(), zoom));
|
||||
uiController.loopMainThreadForAtLeast(TestConstants.ANIMATION_TEST_TIME);
|
||||
mapboxMap.animateCamera(CameraUpdateFactory.zoomOut());
|
||||
uiController.loopMainThreadForAtLeast(TestConstants.ANIMATION_TEST_TIME);
|
||||
CameraPosition cameraPosition = mapboxMap.getCameraPosition();
|
||||
assertEquals("Moved camera zoom should match moved camera zoom", cameraPosition.zoom, zoom - 1,
|
||||
TestConstants.ZOOM_DELTA);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void testAnimateToZoomBy() {
|
||||
validateTestSetup();
|
||||
|
||||
/*TODO fix zoom #6474*/
|
||||
float zoom = 1.0f;
|
||||
final float zoomBy = 2.45f;
|
||||
|
||||
onView(withId(R.id.mapView)).perform(new AnimateCameraAction(mapboxMap, CameraUpdateFactory.zoomBy(zoomBy)));
|
||||
CameraPosition cameraPosition = mapboxMap.getCameraPosition();
|
||||
assertEquals("Moved camera zoom should match moved camera zoom", cameraPosition.zoom, zoom + zoomBy,
|
||||
TestConstants.ZOOM_DELTA);
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
float zoom = 1.0f;
|
||||
final float zoomBy = 2.45f;
|
||||
mapboxMap.animateCamera(CameraUpdateFactory.zoomBy(zoomBy));
|
||||
uiController.loopMainThreadForAtLeast(TestConstants.ANIMATION_TEST_TIME);
|
||||
CameraPosition cameraPosition = mapboxMap.getCameraPosition();
|
||||
assertEquals("Moved camera zoom should match moved camera zoom", cameraPosition.zoom, zoom + zoomBy,
|
||||
TestConstants.ZOOM_DELTA);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void testAnimateToZoomTo() {
|
||||
validateTestSetup();
|
||||
|
||||
/*TODO fix zoom #6474*/
|
||||
final float zoomTo = 2.45f;
|
||||
|
||||
onView(withId(R.id.mapView)).perform(new AnimateCameraAction(mapboxMap, CameraUpdateFactory.zoomTo(zoomTo)));
|
||||
CameraPosition cameraPosition = mapboxMap.getCameraPosition();
|
||||
assertEquals("Moved camera zoom should match moved camera zoom", cameraPosition.zoom, zoomTo,
|
||||
TestConstants.ZOOM_DELTA);
|
||||
}
|
||||
|
||||
private class AnimateCameraAction implements ViewAction {
|
||||
|
||||
private MapboxMap mapboxMap;
|
||||
private CameraUpdate cameraUpdate;
|
||||
|
||||
AnimateCameraAction(MapboxMap map, CameraUpdate update) {
|
||||
mapboxMap = map;
|
||||
cameraUpdate = update;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Matcher<View> getConstraints() {
|
||||
return isDisplayed();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return getClass().getSimpleName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void perform(UiController uiController, View view) {
|
||||
mapboxMap.animateCamera(cameraUpdate);
|
||||
uiController.loopMainThreadForAtLeast(TestConstants.ANIMATION_TEST_TIME);
|
||||
}
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
final float zoomTo = 2.45f;
|
||||
mapboxMap.animateCamera(CameraUpdateFactory.zoomTo(zoomTo));
|
||||
uiController.loopMainThreadForAtLeast(TestConstants.ANIMATION_TEST_TIME);
|
||||
CameraPosition cameraPosition = mapboxMap.getCameraPosition();
|
||||
assertEquals("Moved camera zoom should match moved camera zoom", cameraPosition.zoom, zoomTo,
|
||||
TestConstants.ZOOM_DELTA);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,27 +2,21 @@ package com.mapbox.mapboxsdk.testapp.camera;
|
||||
|
||||
import android.graphics.PointF;
|
||||
import android.support.test.espresso.UiController;
|
||||
import android.support.test.espresso.ViewAction;
|
||||
import android.view.View;
|
||||
|
||||
import com.mapbox.mapboxsdk.camera.CameraPosition;
|
||||
import com.mapbox.mapboxsdk.camera.CameraUpdate;
|
||||
import com.mapbox.mapboxsdk.camera.CameraUpdateFactory;
|
||||
import com.mapbox.mapboxsdk.geometry.LatLng;
|
||||
import com.mapbox.mapboxsdk.geometry.LatLngBounds;
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
import com.mapbox.mapboxsdk.testapp.action.MapboxMapAction;
|
||||
import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest;
|
||||
import com.mapbox.mapboxsdk.testapp.activity.espresso.EspressoTestActivity;
|
||||
import com.mapbox.mapboxsdk.testapp.utils.TestConstants;
|
||||
|
||||
import org.hamcrest.Matcher;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
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.withId;
|
||||
import static com.mapbox.mapboxsdk.testapp.action.MapboxMapAction.invoke;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class CameraEaseTest extends BaseActivityTest {
|
||||
@@ -36,201 +30,198 @@ public class CameraEaseTest extends BaseActivityTest {
|
||||
@Ignore
|
||||
public void testEaseToCameraPositionTarget() {
|
||||
validateTestSetup();
|
||||
|
||||
/*TODO remove zoom #6474*/
|
||||
float zoom = 1.0f;
|
||||
LatLng moveTarget = new LatLng(1, 1);
|
||||
|
||||
CameraPosition initialPosition = new CameraPosition.Builder().target(
|
||||
new LatLng()).zoom(zoom).bearing(0).tilt(0).build();
|
||||
CameraPosition cameraPosition = mapboxMap.getCameraPosition();
|
||||
assertEquals("Default camera position should match default", cameraPosition, initialPosition);
|
||||
|
||||
onView(withId(R.id.mapView)).perform(new EaseCameraAction(mapboxMap, CameraUpdateFactory.newLatLng(moveTarget)));
|
||||
cameraPosition = mapboxMap.getCameraPosition();
|
||||
assertEquals("Moved camera position latitude should match", cameraPosition.target.getLatitude(),
|
||||
moveTarget.getLatitude(), TestConstants.LAT_LNG_DELTA);
|
||||
assertEquals("Moved camera position longitude should match", cameraPosition.target.getLongitude(),
|
||||
moveTarget.getLongitude(), TestConstants.LAT_LNG_DELTA);
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
float zoom = 1.0f;
|
||||
LatLng moveTarget = new LatLng(1, 1);
|
||||
CameraPosition initialPosition = new CameraPosition.Builder().target(
|
||||
new LatLng()).zoom(zoom).bearing(0).tilt(0).build();
|
||||
CameraPosition cameraPosition = mapboxMap.getCameraPosition();
|
||||
assertEquals("Default camera position should match default", cameraPosition, initialPosition);
|
||||
mapboxMap.easeCamera(CameraUpdateFactory.newLatLng(moveTarget));
|
||||
uiController.loopMainThreadForAtLeast(TestConstants.ANIMATION_TEST_TIME);
|
||||
cameraPosition = mapboxMap.getCameraPosition();
|
||||
assertEquals("Moved camera position latitude should match", cameraPosition.target.getLatitude(),
|
||||
moveTarget.getLatitude(), TestConstants.LAT_LNG_DELTA);
|
||||
assertEquals("Moved camera position longitude should match", cameraPosition.target.getLongitude(),
|
||||
moveTarget.getLongitude(), TestConstants.LAT_LNG_DELTA);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void testEaseToCameraPositionTargetZoom() {
|
||||
validateTestSetup();
|
||||
|
||||
final float moveZoom = 15.5f;
|
||||
final LatLng moveTarget = new LatLng(1.0000000001, 1.0000000003);
|
||||
|
||||
onView(withId(R.id.mapView)).perform(new EaseCameraAction(mapboxMap,
|
||||
CameraUpdateFactory.newLatLngZoom(moveTarget, moveZoom)));
|
||||
CameraPosition cameraPosition = mapboxMap.getCameraPosition();
|
||||
assertEquals("Moved camera position latitude should match", cameraPosition.target.getLatitude(),
|
||||
moveTarget.getLatitude(), TestConstants.LAT_LNG_DELTA);
|
||||
assertEquals("Moved camera position longitude should match", cameraPosition.target.getLongitude(),
|
||||
moveTarget.getLongitude(), TestConstants.LAT_LNG_DELTA);
|
||||
assertEquals("Moved zoom should match", cameraPosition.zoom, moveZoom, TestConstants.ZOOM_DELTA);
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
final float moveZoom = 15.5f;
|
||||
final LatLng moveTarget = new LatLng(1.0000000001, 1.0000000003);
|
||||
mapboxMap.easeCamera(CameraUpdateFactory.newLatLngZoom(moveTarget, moveZoom));
|
||||
uiController.loopMainThreadForAtLeast(TestConstants.ANIMATION_TEST_TIME);
|
||||
CameraPosition cameraPosition = mapboxMap.getCameraPosition();
|
||||
assertEquals("Moved camera position latitude should match", cameraPosition.target.getLatitude(),
|
||||
moveTarget.getLatitude(), TestConstants.LAT_LNG_DELTA);
|
||||
assertEquals("Moved camera position longitude should match", cameraPosition.target.getLongitude(),
|
||||
moveTarget.getLongitude(), TestConstants.LAT_LNG_DELTA);
|
||||
assertEquals("Moved zoom should match", cameraPosition.zoom, moveZoom, TestConstants.ZOOM_DELTA);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void testEaseToCameraPosition() {
|
||||
validateTestSetup();
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
final LatLng moveTarget = new LatLng(1.0000000001, 1.0000000003);
|
||||
final float moveZoom = 15.5f;
|
||||
final float moveTilt = 45.5f;
|
||||
final float moveBearing = 12.5f;
|
||||
|
||||
final LatLng moveTarget = new LatLng(1.0000000001, 1.0000000003);
|
||||
final float moveZoom = 15.5f;
|
||||
final float moveTilt = 45.5f;
|
||||
final float moveBearing = 12.5f;
|
||||
|
||||
onView(withId(R.id.mapView)).perform(
|
||||
new EaseCameraAction(mapboxMap, CameraUpdateFactory.newCameraPosition(
|
||||
new CameraPosition.Builder()
|
||||
.target(moveTarget)
|
||||
.zoom(moveZoom)
|
||||
.tilt(moveTilt)
|
||||
.bearing(moveBearing)
|
||||
.build()))
|
||||
);
|
||||
|
||||
CameraPosition cameraPosition = mapboxMap.getCameraPosition();
|
||||
assertEquals("Moved camera position latitude should match", cameraPosition.target.getLatitude(),
|
||||
moveTarget.getLatitude(), TestConstants.LAT_LNG_DELTA);
|
||||
assertEquals("Moved camera position longitude should match", cameraPosition.target.getLongitude(),
|
||||
moveTarget.getLongitude(), TestConstants.LAT_LNG_DELTA);
|
||||
assertEquals("Moved zoom should match", cameraPosition.zoom, moveZoom, TestConstants.ZOOM_DELTA);
|
||||
assertEquals("Moved zoom should match", cameraPosition.tilt, moveTilt, TestConstants.TILT_DELTA);
|
||||
assertEquals("Moved bearing should match", cameraPosition.bearing, moveBearing, TestConstants.BEARING_DELTA);
|
||||
mapboxMap.easeCamera(CameraUpdateFactory.newCameraPosition(
|
||||
new CameraPosition.Builder()
|
||||
.target(moveTarget)
|
||||
.zoom(moveZoom)
|
||||
.tilt(moveTilt)
|
||||
.bearing(moveBearing)
|
||||
.build())
|
||||
);
|
||||
uiController.loopMainThreadForAtLeast(TestConstants.ANIMATION_TEST_TIME);
|
||||
CameraPosition cameraPosition = mapboxMap.getCameraPosition();
|
||||
assertEquals("Moved camera position latitude should match", cameraPosition.target.getLatitude(),
|
||||
moveTarget.getLatitude(), TestConstants.LAT_LNG_DELTA);
|
||||
assertEquals("Moved camera position longitude should match", cameraPosition.target.getLongitude(),
|
||||
moveTarget.getLongitude(), TestConstants.LAT_LNG_DELTA);
|
||||
assertEquals("Moved zoom should match", cameraPosition.zoom, moveZoom, TestConstants.ZOOM_DELTA);
|
||||
assertEquals("Moved zoom should match", cameraPosition.tilt, moveTilt, TestConstants.TILT_DELTA);
|
||||
assertEquals("Moved bearing should match", cameraPosition.bearing, moveBearing, TestConstants.BEARING_DELTA);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void testEaseToBounds() {
|
||||
validateTestSetup();
|
||||
|
||||
final LatLng centerBounds = new LatLng(1, 1);
|
||||
LatLng cornerOne = new LatLng();
|
||||
LatLng cornerTwo = new LatLng(2, 2);
|
||||
|
||||
final LatLngBounds.Builder builder = new LatLngBounds.Builder();
|
||||
builder.include(cornerOne);
|
||||
builder.include(cornerTwo);
|
||||
|
||||
onView(withId(R.id.mapView)).perform(new EaseCameraAction(mapboxMap,
|
||||
CameraUpdateFactory.newLatLngBounds(builder.build(), 0)));
|
||||
|
||||
CameraPosition cameraPosition = mapboxMap.getCameraPosition();
|
||||
assertEquals("Moved camera position latitude should match center bounds",
|
||||
cameraPosition.target.getLatitude(),
|
||||
centerBounds.getLatitude(),
|
||||
TestConstants.LAT_LNG_DELTA);
|
||||
|
||||
assertEquals("Moved camera position longitude should match center bounds",
|
||||
cameraPosition.target.getLongitude(),
|
||||
centerBounds.getLongitude(),
|
||||
TestConstants.LAT_LNG_DELTA);
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
final LatLng centerBounds = new LatLng(1, 1);
|
||||
LatLng cornerOne = new LatLng();
|
||||
LatLng cornerTwo = new LatLng(2, 2);
|
||||
final LatLngBounds.Builder builder = new LatLngBounds.Builder();
|
||||
builder.include(cornerOne);
|
||||
builder.include(cornerTwo);
|
||||
mapboxMap.easeCamera(CameraUpdateFactory.newLatLngBounds(builder.build(), 0));
|
||||
uiController.loopMainThreadForAtLeast(TestConstants.ANIMATION_TEST_TIME);
|
||||
CameraPosition cameraPosition = mapboxMap.getCameraPosition();
|
||||
assertEquals("Moved camera position latitude should match center bounds",
|
||||
cameraPosition.target.getLatitude(),
|
||||
centerBounds.getLatitude(),
|
||||
TestConstants.LAT_LNG_DELTA);
|
||||
assertEquals("Moved camera position longitude should match center bounds",
|
||||
cameraPosition.target.getLongitude(),
|
||||
centerBounds.getLongitude(),
|
||||
TestConstants.LAT_LNG_DELTA);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void testEaseToMoveBy() {
|
||||
validateTestSetup();
|
||||
|
||||
final PointF centerPoint = mapboxMap.getProjection().toScreenLocation(mapboxMap.getCameraPosition().target);
|
||||
final LatLng moveTarget = new LatLng(2, 2);
|
||||
final PointF moveTargetPoint = mapboxMap.getProjection().toScreenLocation(moveTarget);
|
||||
|
||||
onView(withId(R.id.mapView)).perform(new EaseCameraAction(mapboxMap, CameraUpdateFactory.scrollBy(
|
||||
moveTargetPoint.x - centerPoint.x, moveTargetPoint.y - centerPoint.y)));
|
||||
|
||||
CameraPosition cameraPosition = mapboxMap.getCameraPosition();
|
||||
assertEquals("Moved camera position latitude should match", cameraPosition.target.getLatitude(),
|
||||
moveTarget.getLatitude(), TestConstants.LAT_LNG_DELTA_LARGE);
|
||||
assertEquals("Moved camera position longitude should match", cameraPosition.target.getLongitude(),
|
||||
moveTarget.getLongitude(), TestConstants.LAT_LNG_DELTA_LARGE);
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
final PointF centerPoint = mapboxMap.getProjection().toScreenLocation(mapboxMap.getCameraPosition().target);
|
||||
final LatLng moveTarget = new LatLng(2, 2);
|
||||
final PointF moveTargetPoint = mapboxMap.getProjection().toScreenLocation(moveTarget);
|
||||
mapboxMap.easeCamera(CameraUpdateFactory.scrollBy(
|
||||
moveTargetPoint.x - centerPoint.x, moveTargetPoint.y - centerPoint.y));
|
||||
uiController.loopMainThreadForAtLeast(TestConstants.ANIMATION_TEST_TIME);
|
||||
CameraPosition cameraPosition = mapboxMap.getCameraPosition();
|
||||
assertEquals("Moved camera position latitude should match", cameraPosition.target.getLatitude(),
|
||||
moveTarget.getLatitude(), TestConstants.LAT_LNG_DELTA_LARGE);
|
||||
assertEquals("Moved camera position longitude should match", cameraPosition.target.getLongitude(),
|
||||
moveTarget.getLongitude(), TestConstants.LAT_LNG_DELTA_LARGE);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void testEaseToZoomIn() {
|
||||
validateTestSetup();
|
||||
|
||||
/*TODO fix zoom #6474*/
|
||||
float zoom = 1.0f;
|
||||
|
||||
onView(withId(R.id.mapView)).perform(new EaseCameraAction(mapboxMap, CameraUpdateFactory.zoomIn()));
|
||||
CameraPosition cameraPosition = mapboxMap.getCameraPosition();
|
||||
assertEquals("Moved camera zoom should match moved camera zoom", cameraPosition.zoom, zoom + 1,
|
||||
TestConstants.ZOOM_DELTA);
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
float zoom = 1.0f;
|
||||
mapboxMap.easeCamera(CameraUpdateFactory.zoomIn());
|
||||
uiController.loopMainThreadForAtLeast(TestConstants.ANIMATION_TEST_TIME);
|
||||
CameraPosition cameraPosition = mapboxMap.getCameraPosition();
|
||||
assertEquals("Moved camera zoom should match moved camera zoom", cameraPosition.zoom, zoom + 1,
|
||||
TestConstants.ZOOM_DELTA);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void testEaseToZoomOut() {
|
||||
validateTestSetup();
|
||||
|
||||
/*TODO fix zoom #6474*/
|
||||
float zoom = 10.0f;
|
||||
onView(withId(R.id.mapView)).perform(new EaseCameraAction(mapboxMap,
|
||||
CameraUpdateFactory.newLatLngZoom(new LatLng(), zoom)));
|
||||
onView(withId(R.id.mapView)).perform(new EaseCameraAction(mapboxMap, CameraUpdateFactory.zoomOut()));
|
||||
CameraPosition cameraPosition = mapboxMap.getCameraPosition();
|
||||
assertEquals("Moved camera zoom should match moved camera zoom", 9, cameraPosition.zoom, TestConstants.ZOOM_DELTA);
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
float zoom = 10.0f;
|
||||
mapboxMap.easeCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(), zoom));
|
||||
uiController.loopMainThreadForAtLeast(TestConstants.ANIMATION_TEST_TIME);
|
||||
mapboxMap.easeCamera(CameraUpdateFactory.zoomOut());
|
||||
uiController.loopMainThreadForAtLeast(TestConstants.ANIMATION_TEST_TIME);
|
||||
CameraPosition cameraPosition = mapboxMap.getCameraPosition();
|
||||
assertEquals("Moved camera zoom should match moved camera zoom", cameraPosition.zoom, zoom - 1,
|
||||
TestConstants.ZOOM_DELTA);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void testEaseToZoomBy() {
|
||||
validateTestSetup();
|
||||
|
||||
/*TODO fix zoom #6474*/
|
||||
float zoom = 1.0f;
|
||||
final float zoomBy = 2.45f;
|
||||
|
||||
onView(withId(R.id.mapView)).perform(new EaseCameraAction(mapboxMap, CameraUpdateFactory.zoomBy(zoomBy)));
|
||||
CameraPosition cameraPosition = mapboxMap.getCameraPosition();
|
||||
assertEquals("Moved camera zoom should match moved camera zoom", cameraPosition.zoom, zoom + zoomBy,
|
||||
TestConstants.ZOOM_DELTA);
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
float zoom = 1.0f;
|
||||
final float zoomBy = 2.45f;
|
||||
mapboxMap.easeCamera(CameraUpdateFactory.zoomBy(zoomBy));
|
||||
uiController.loopMainThreadForAtLeast(TestConstants.ANIMATION_TEST_TIME);
|
||||
CameraPosition cameraPosition = mapboxMap.getCameraPosition();
|
||||
assertEquals("Moved camera zoom should match moved camera zoom", cameraPosition.zoom, zoom + zoomBy,
|
||||
TestConstants.ZOOM_DELTA);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void testEaseToZoomTo() {
|
||||
validateTestSetup();
|
||||
|
||||
/*TODO fix zoom #6474*/
|
||||
final float zoomTo = 2.45f;
|
||||
|
||||
onView(withId(R.id.mapView)).perform(new EaseCameraAction(mapboxMap, CameraUpdateFactory.zoomTo(zoomTo)));
|
||||
CameraPosition cameraPosition = mapboxMap.getCameraPosition();
|
||||
assertEquals("Moved camera zoom should match moved camera zoom", cameraPosition.zoom, zoomTo,
|
||||
TestConstants.ZOOM_DELTA);
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
final float zoomTo = 2.45f;
|
||||
mapboxMap.easeCamera(CameraUpdateFactory.zoomTo(zoomTo));
|
||||
uiController.loopMainThreadForAtLeast(TestConstants.ANIMATION_TEST_TIME);
|
||||
CameraPosition cameraPosition = mapboxMap.getCameraPosition();
|
||||
assertEquals("Moved camera zoom should match moved camera zoom", cameraPosition.zoom, zoomTo,
|
||||
TestConstants.ZOOM_DELTA);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private class EaseCameraAction implements ViewAction {
|
||||
|
||||
private MapboxMap mapboxMap;
|
||||
private CameraUpdate cameraUpdate;
|
||||
|
||||
EaseCameraAction(MapboxMap map, CameraUpdate update) {
|
||||
mapboxMap = map;
|
||||
cameraUpdate = update;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Matcher<View> getConstraints() {
|
||||
return isDisplayed();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return getClass().getSimpleName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void perform(UiController uiController, View view) {
|
||||
mapboxMap.easeCamera(cameraUpdate);
|
||||
uiController.loopMainThreadForAtLeast(TestConstants.ANIMATION_TEST_TIME);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,27 +2,21 @@ package com.mapbox.mapboxsdk.testapp.camera;
|
||||
|
||||
import android.graphics.PointF;
|
||||
import android.support.test.espresso.UiController;
|
||||
import android.support.test.espresso.ViewAction;
|
||||
import android.view.View;
|
||||
|
||||
import com.mapbox.mapboxsdk.camera.CameraPosition;
|
||||
import com.mapbox.mapboxsdk.camera.CameraUpdate;
|
||||
import com.mapbox.mapboxsdk.camera.CameraUpdateFactory;
|
||||
import com.mapbox.mapboxsdk.geometry.LatLng;
|
||||
import com.mapbox.mapboxsdk.geometry.LatLngBounds;
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
import com.mapbox.mapboxsdk.testapp.action.MapboxMapAction;
|
||||
import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest;
|
||||
import com.mapbox.mapboxsdk.testapp.activity.espresso.EspressoTestActivity;
|
||||
import com.mapbox.mapboxsdk.testapp.utils.TestConstants;
|
||||
|
||||
import org.hamcrest.Matcher;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
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.withId;
|
||||
import static com.mapbox.mapboxsdk.testapp.action.MapboxMapAction.invoke;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class CameraMoveTest extends BaseActivityTest {
|
||||
@@ -36,201 +30,199 @@ public class CameraMoveTest extends BaseActivityTest {
|
||||
@Ignore
|
||||
public void testMoveToCameraPositionTarget() {
|
||||
validateTestSetup();
|
||||
|
||||
/*TODO remove zoom #6474*/
|
||||
float zoom = 1.0f;
|
||||
LatLng moveTarget = new LatLng(1, 1);
|
||||
|
||||
CameraPosition initialPosition = new CameraPosition.Builder().target(
|
||||
new LatLng()).zoom(zoom).bearing(0).tilt(0).build();
|
||||
CameraPosition cameraPosition = mapboxMap.getCameraPosition();
|
||||
assertEquals("Default camera position should match default", cameraPosition, initialPosition);
|
||||
|
||||
onView(withId(R.id.mapView)).perform(new MoveCameraAction(mapboxMap, CameraUpdateFactory.newLatLng(moveTarget)));
|
||||
cameraPosition = mapboxMap.getCameraPosition();
|
||||
assertEquals("Moved camera position latitude should match", cameraPosition.target.getLatitude(),
|
||||
moveTarget.getLatitude(), TestConstants.LAT_LNG_DELTA);
|
||||
assertEquals("Moved camera position longitude should match", cameraPosition.target.getLongitude(),
|
||||
moveTarget.getLongitude(), TestConstants.LAT_LNG_DELTA);
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
float zoom = 1.0f;
|
||||
LatLng moveTarget = new LatLng(1, 1);
|
||||
CameraPosition initialPosition = new CameraPosition.Builder().target(
|
||||
new LatLng()).zoom(zoom).bearing(0).tilt(0).build();
|
||||
CameraPosition cameraPosition = mapboxMap.getCameraPosition();
|
||||
assertEquals("Default camera position should match default", cameraPosition, initialPosition);
|
||||
mapboxMap.moveCamera(CameraUpdateFactory.newLatLng(moveTarget));
|
||||
uiController.loopMainThreadForAtLeast(TestConstants.ANIMATION_TEST_TIME);
|
||||
cameraPosition = mapboxMap.getCameraPosition();
|
||||
assertEquals("Moved camera position latitude should match", cameraPosition.target.getLatitude(),
|
||||
moveTarget.getLatitude(), TestConstants.LAT_LNG_DELTA);
|
||||
assertEquals("Moved camera position longitude should match", cameraPosition.target.getLongitude(),
|
||||
moveTarget.getLongitude(), TestConstants.LAT_LNG_DELTA);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void testMoveToCameraPositionTargetZoom() {
|
||||
validateTestSetup();
|
||||
|
||||
final float moveZoom = 15.5f;
|
||||
final LatLng moveTarget = new LatLng(1.0000000001, 1.0000000003);
|
||||
|
||||
onView(withId(R.id.mapView)).perform(new MoveCameraAction(mapboxMap,
|
||||
CameraUpdateFactory.newLatLngZoom(moveTarget, moveZoom)));
|
||||
CameraPosition cameraPosition = mapboxMap.getCameraPosition();
|
||||
assertEquals("Moved camera position latitude should match", cameraPosition.target.getLatitude(),
|
||||
moveTarget.getLatitude(), TestConstants.LAT_LNG_DELTA);
|
||||
assertEquals("Moved camera position longitude should match", cameraPosition.target.getLongitude(),
|
||||
moveTarget.getLongitude(), TestConstants.LAT_LNG_DELTA);
|
||||
assertEquals("Moved zoom should match", cameraPosition.zoom, moveZoom, TestConstants.ZOOM_DELTA);
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
final float moveZoom = 15.5f;
|
||||
final LatLng moveTarget = new LatLng(1.0000000001, 1.0000000003);
|
||||
mapboxMap.moveCamera(CameraUpdateFactory.newLatLngZoom(moveTarget, moveZoom));
|
||||
uiController.loopMainThreadForAtLeast(TestConstants.ANIMATION_TEST_TIME);
|
||||
CameraPosition cameraPosition = mapboxMap.getCameraPosition();
|
||||
assertEquals("Moved camera position latitude should match", cameraPosition.target.getLatitude(),
|
||||
moveTarget.getLatitude(), TestConstants.LAT_LNG_DELTA);
|
||||
assertEquals("Moved camera position longitude should match", cameraPosition.target.getLongitude(),
|
||||
moveTarget.getLongitude(), TestConstants.LAT_LNG_DELTA);
|
||||
assertEquals("Moved zoom should match", cameraPosition.zoom, moveZoom, TestConstants.ZOOM_DELTA);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void testMoveToCameraPosition() {
|
||||
validateTestSetup();
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
final LatLng moveTarget = new LatLng(1.0000000001, 1.0000000003);
|
||||
final float moveZoom = 15.5f;
|
||||
final float moveTilt = 45.5f;
|
||||
final float moveBearing = 12.5f;
|
||||
|
||||
final LatLng moveTarget = new LatLng(1.0000000001, 1.0000000003);
|
||||
final float moveZoom = 15.5f;
|
||||
final float moveTilt = 45.5f;
|
||||
final float moveBearing = 12.5f;
|
||||
|
||||
onView(withId(R.id.mapView)).perform(
|
||||
new MoveCameraAction(mapboxMap, CameraUpdateFactory.newCameraPosition(
|
||||
new CameraPosition.Builder()
|
||||
.target(moveTarget)
|
||||
.zoom(moveZoom)
|
||||
.tilt(moveTilt)
|
||||
.bearing(moveBearing)
|
||||
.build()))
|
||||
);
|
||||
|
||||
CameraPosition cameraPosition = mapboxMap.getCameraPosition();
|
||||
assertEquals("Moved camera position latitude should match", cameraPosition.target.getLatitude(),
|
||||
moveTarget.getLatitude(), TestConstants.LAT_LNG_DELTA);
|
||||
assertEquals("Moved camera position longitude should match", cameraPosition.target.getLongitude(),
|
||||
moveTarget.getLongitude(), TestConstants.LAT_LNG_DELTA);
|
||||
assertEquals("Moved zoom should match", cameraPosition.zoom, moveZoom, TestConstants.ZOOM_DELTA);
|
||||
assertEquals("Moved zoom should match", cameraPosition.tilt, moveTilt, TestConstants.TILT_DELTA);
|
||||
assertEquals("Moved bearing should match", cameraPosition.bearing, moveBearing, TestConstants.BEARING_DELTA);
|
||||
mapboxMap.moveCamera(CameraUpdateFactory.newCameraPosition(
|
||||
new CameraPosition.Builder()
|
||||
.target(moveTarget)
|
||||
.zoom(moveZoom)
|
||||
.tilt(moveTilt)
|
||||
.bearing(moveBearing)
|
||||
.build())
|
||||
);
|
||||
uiController.loopMainThreadForAtLeast(TestConstants.ANIMATION_TEST_TIME);
|
||||
CameraPosition cameraPosition = mapboxMap.getCameraPosition();
|
||||
assertEquals("Moved camera position latitude should match", cameraPosition.target.getLatitude(),
|
||||
moveTarget.getLatitude(), TestConstants.LAT_LNG_DELTA);
|
||||
assertEquals("Moved camera position longitude should match", cameraPosition.target.getLongitude(),
|
||||
moveTarget.getLongitude(), TestConstants.LAT_LNG_DELTA);
|
||||
assertEquals("Moved zoom should match", cameraPosition.zoom, moveZoom, TestConstants.ZOOM_DELTA);
|
||||
assertEquals("Moved zoom should match", cameraPosition.tilt, moveTilt, TestConstants.TILT_DELTA);
|
||||
assertEquals("Moved bearing should match", cameraPosition.bearing, moveBearing, TestConstants.BEARING_DELTA);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void testMoveToBounds() {
|
||||
validateTestSetup();
|
||||
|
||||
final LatLng centerBounds = new LatLng(1, 1);
|
||||
LatLng cornerOne = new LatLng();
|
||||
LatLng cornerTwo = new LatLng(2, 2);
|
||||
|
||||
final LatLngBounds.Builder builder = new LatLngBounds.Builder();
|
||||
builder.include(cornerOne);
|
||||
builder.include(cornerTwo);
|
||||
|
||||
onView(withId(R.id.mapView)).perform(new MoveCameraAction(mapboxMap,
|
||||
CameraUpdateFactory.newLatLngBounds(builder.build(), 0)));
|
||||
|
||||
CameraPosition cameraPosition = mapboxMap.getCameraPosition();
|
||||
assertEquals("Moved camera position latitude should match center bounds",
|
||||
cameraPosition.target.getLatitude(),
|
||||
centerBounds.getLatitude(),
|
||||
TestConstants.LAT_LNG_DELTA);
|
||||
|
||||
assertEquals("Moved camera position longitude should match center bounds",
|
||||
cameraPosition.target.getLongitude(),
|
||||
centerBounds.getLongitude(),
|
||||
TestConstants.LAT_LNG_DELTA);
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
final LatLng centerBounds = new LatLng(1, 1);
|
||||
LatLng cornerOne = new LatLng();
|
||||
LatLng cornerTwo = new LatLng(2, 2);
|
||||
final LatLngBounds.Builder builder = new LatLngBounds.Builder();
|
||||
builder.include(cornerOne);
|
||||
builder.include(cornerTwo);
|
||||
mapboxMap.moveCamera(CameraUpdateFactory.newLatLngBounds(builder.build(), 0));
|
||||
uiController.loopMainThreadForAtLeast(TestConstants.ANIMATION_TEST_TIME);
|
||||
CameraPosition cameraPosition = mapboxMap.getCameraPosition();
|
||||
assertEquals("Moved camera position latitude should match center bounds",
|
||||
cameraPosition.target.getLatitude(),
|
||||
centerBounds.getLatitude(),
|
||||
TestConstants.LAT_LNG_DELTA);
|
||||
assertEquals("Moved camera position longitude should match center bounds",
|
||||
cameraPosition.target.getLongitude(),
|
||||
centerBounds.getLongitude(),
|
||||
TestConstants.LAT_LNG_DELTA);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void testMoveToMoveBy() {
|
||||
validateTestSetup();
|
||||
|
||||
final PointF centerPoint = mapboxMap.getProjection().toScreenLocation(mapboxMap.getCameraPosition().target);
|
||||
final LatLng moveTarget = new LatLng(2, 2);
|
||||
final PointF moveTargetPoint = mapboxMap.getProjection().toScreenLocation(moveTarget);
|
||||
|
||||
onView(withId(R.id.mapView)).perform(new MoveCameraAction(mapboxMap, CameraUpdateFactory.scrollBy(
|
||||
moveTargetPoint.x - centerPoint.x, moveTargetPoint.y - centerPoint.y)));
|
||||
|
||||
CameraPosition cameraPosition = mapboxMap.getCameraPosition();
|
||||
assertEquals("Moved camera position latitude should match", cameraPosition.target.getLatitude(),
|
||||
moveTarget.getLatitude(), TestConstants.LAT_LNG_DELTA_LARGE);
|
||||
assertEquals("Moved camera position longitude should match", cameraPosition.target.getLongitude(),
|
||||
moveTarget.getLongitude(), TestConstants.LAT_LNG_DELTA_LARGE);
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
final PointF centerPoint = mapboxMap.getProjection().toScreenLocation(mapboxMap.getCameraPosition().target);
|
||||
final LatLng moveTarget = new LatLng(2, 2);
|
||||
final PointF moveTargetPoint = mapboxMap.getProjection().toScreenLocation(moveTarget);
|
||||
mapboxMap.moveCamera(CameraUpdateFactory.scrollBy(
|
||||
moveTargetPoint.x - centerPoint.x, moveTargetPoint.y - centerPoint.y));
|
||||
uiController.loopMainThreadForAtLeast(TestConstants.ANIMATION_TEST_TIME);
|
||||
CameraPosition cameraPosition = mapboxMap.getCameraPosition();
|
||||
assertEquals("Moved camera position latitude should match", cameraPosition.target.getLatitude(),
|
||||
moveTarget.getLatitude(), TestConstants.LAT_LNG_DELTA_LARGE);
|
||||
assertEquals("Moved camera position longitude should match", cameraPosition.target.getLongitude(),
|
||||
moveTarget.getLongitude(), TestConstants.LAT_LNG_DELTA_LARGE);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void testMoveToZoomIn() {
|
||||
validateTestSetup();
|
||||
|
||||
/*TODO fix zoom #6474*/
|
||||
float zoom = 1.0f;
|
||||
|
||||
onView(withId(R.id.mapView)).perform(new MoveCameraAction(mapboxMap, CameraUpdateFactory.zoomIn()));
|
||||
CameraPosition cameraPosition = mapboxMap.getCameraPosition();
|
||||
assertEquals("Moved camera zoom should match moved camera zoom", cameraPosition.zoom, zoom + 1,
|
||||
TestConstants.ZOOM_DELTA);
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
float zoom = 1.0f;
|
||||
mapboxMap.moveCamera(CameraUpdateFactory.zoomIn());
|
||||
uiController.loopMainThreadForAtLeast(TestConstants.ANIMATION_TEST_TIME);
|
||||
CameraPosition cameraPosition = mapboxMap.getCameraPosition();
|
||||
assertEquals("Moved camera zoom should match moved camera zoom", cameraPosition.zoom, zoom + 1,
|
||||
TestConstants.ZOOM_DELTA);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void testMoveToZoomOut() {
|
||||
validateTestSetup();
|
||||
|
||||
/*TODO fix zoom #6474*/
|
||||
float zoom = 10.0f;
|
||||
onView(withId(R.id.mapView)).perform(new MoveCameraAction(mapboxMap,
|
||||
CameraUpdateFactory.newLatLngZoom(new LatLng(), zoom)));
|
||||
onView(withId(R.id.mapView)).perform(new MoveCameraAction(mapboxMap, CameraUpdateFactory.zoomOut()));
|
||||
CameraPosition cameraPosition = mapboxMap.getCameraPosition();
|
||||
assertEquals("Moved camera zoom should match moved camera zoom", cameraPosition.zoom, zoom - 1,
|
||||
TestConstants.ZOOM_DELTA);
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
float zoom = 10.0f;
|
||||
mapboxMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(), zoom));
|
||||
uiController.loopMainThreadForAtLeast(TestConstants.ANIMATION_TEST_TIME);
|
||||
mapboxMap.moveCamera(CameraUpdateFactory.zoomOut());
|
||||
uiController.loopMainThreadForAtLeast(TestConstants.ANIMATION_TEST_TIME);
|
||||
CameraPosition cameraPosition = mapboxMap.getCameraPosition();
|
||||
assertEquals("Moved camera zoom should match moved camera zoom", cameraPosition.zoom, zoom - 1,
|
||||
TestConstants.ZOOM_DELTA);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void testMoveToZoomBy() {
|
||||
validateTestSetup();
|
||||
|
||||
/*TODO fix zoom #6474*/
|
||||
float zoom = 1.0f;
|
||||
final float zoomBy = 2.45f;
|
||||
|
||||
onView(withId(R.id.mapView)).perform(new MoveCameraAction(mapboxMap, CameraUpdateFactory.zoomBy(zoomBy)));
|
||||
CameraPosition cameraPosition = mapboxMap.getCameraPosition();
|
||||
assertEquals("Moved camera zoom should match moved camera zoom", cameraPosition.zoom, zoom + zoomBy,
|
||||
TestConstants.ZOOM_DELTA);
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
float zoom = 1.0f;
|
||||
final float zoomBy = 2.45f;
|
||||
mapboxMap.moveCamera(CameraUpdateFactory.zoomBy(zoomBy));
|
||||
uiController.loopMainThreadForAtLeast(TestConstants.ANIMATION_TEST_TIME);
|
||||
CameraPosition cameraPosition = mapboxMap.getCameraPosition();
|
||||
assertEquals("Moved camera zoom should match moved camera zoom", cameraPosition.zoom, zoom + zoomBy,
|
||||
TestConstants.ZOOM_DELTA);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void testMoveToZoomTo() {
|
||||
validateTestSetup();
|
||||
|
||||
/*TODO fix zoom #6474*/
|
||||
final float zoomTo = 2.45f;
|
||||
|
||||
onView(withId(R.id.mapView)).perform(new MoveCameraAction(mapboxMap, CameraUpdateFactory.zoomTo(zoomTo)));
|
||||
CameraPosition cameraPosition = mapboxMap.getCameraPosition();
|
||||
assertEquals("Moved camera zoom should match moved camera zoom", cameraPosition.zoom, zoomTo,
|
||||
TestConstants.ZOOM_DELTA);
|
||||
}
|
||||
|
||||
private class MoveCameraAction implements ViewAction {
|
||||
|
||||
private MapboxMap mapboxMap;
|
||||
private CameraUpdate cameraUpdate;
|
||||
|
||||
MoveCameraAction(MapboxMap map, CameraUpdate update) {
|
||||
mapboxMap = map;
|
||||
cameraUpdate = update;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Matcher<View> getConstraints() {
|
||||
return isDisplayed();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return getClass().getSimpleName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void perform(UiController uiController, View view) {
|
||||
mapboxMap.moveCamera(cameraUpdate);
|
||||
uiController.loopMainThreadForAtLeast(100);
|
||||
}
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
final float zoomTo = 2.45f;
|
||||
mapboxMap.moveCamera(CameraUpdateFactory.zoomTo(zoomTo));
|
||||
uiController.loopMainThreadForAtLeast(TestConstants.ANIMATION_TEST_TIME);
|
||||
CameraPosition cameraPosition = mapboxMap.getCameraPosition();
|
||||
assertEquals("Moved camera zoom should match moved camera zoom", cameraPosition.zoom, zoomTo,
|
||||
TestConstants.ZOOM_DELTA);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,20 +1,17 @@
|
||||
package com.mapbox.mapboxsdk.testapp.maps.widgets;
|
||||
|
||||
import android.support.test.espresso.UiController;
|
||||
import android.support.test.espresso.ViewAction;
|
||||
import android.view.View;
|
||||
|
||||
import com.mapbox.mapboxsdk.camera.CameraPosition;
|
||||
import com.mapbox.mapboxsdk.camera.CameraUpdate;
|
||||
import com.mapbox.mapboxsdk.camera.CameraUpdateFactory;
|
||||
import com.mapbox.mapboxsdk.geometry.LatLng;
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
import com.mapbox.mapboxsdk.testapp.action.MapboxMapAction;
|
||||
import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest;
|
||||
import com.mapbox.mapboxsdk.testapp.activity.espresso.EspressoTestActivity;
|
||||
import com.mapbox.mapboxsdk.testapp.utils.TestConstants;
|
||||
|
||||
import org.hamcrest.Matcher;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
@@ -23,6 +20,7 @@ import static android.support.test.espresso.action.ViewActions.click;
|
||||
import static android.support.test.espresso.assertion.ViewAssertions.matches;
|
||||
import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed;
|
||||
import static android.support.test.espresso.matcher.ViewMatchers.withId;
|
||||
import static com.mapbox.mapboxsdk.testapp.action.MapboxMapAction.invoke;
|
||||
import static org.hamcrest.Matchers.not;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
@@ -40,96 +38,51 @@ public class CompassViewTest extends BaseActivityTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void testVisible() {
|
||||
validateTestSetup();
|
||||
|
||||
onView(withId(R.id.mapView)).perform(new MoveCameraAction(mapboxMap,
|
||||
CameraUpdateFactory.newCameraPosition(
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
mapboxMap.moveCamera(CameraUpdateFactory.newCameraPosition(
|
||||
new CameraPosition.Builder()
|
||||
.bearing(45)
|
||||
.zoom(1)
|
||||
.target(new LatLng())
|
||||
.build()
|
||||
)
|
||||
)
|
||||
);
|
||||
waitLoop();
|
||||
));
|
||||
uiController.loopMainThreadForAtLeast(500);
|
||||
}
|
||||
});
|
||||
onView(withId(R.id.compassView)).check(matches(isDisplayed()));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore // 10-31-2016 click action is not working
|
||||
@Ignore
|
||||
public void testClick() {
|
||||
validateTestSetup();
|
||||
|
||||
onView(withId(R.id.mapView)).perform(new MoveCameraAction(mapboxMap,
|
||||
CameraUpdateFactory.newCameraPosition(
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
mapboxMap.moveCamera(CameraUpdateFactory.newCameraPosition(
|
||||
new CameraPosition.Builder()
|
||||
.bearing(45)
|
||||
.zoom(1)
|
||||
.target(new LatLng())
|
||||
.build()
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
waitLoop();
|
||||
));
|
||||
}
|
||||
});
|
||||
onView(withId(R.id.compassView)).perform(click());
|
||||
onView(withId(R.id.mapView)).perform(new WaitAction(3000));
|
||||
waitLoop();
|
||||
onView(withId(R.id.compassView)).check(matches(not(isDisplayed())));
|
||||
|
||||
CameraPosition cameraPosition = mapboxMap.getCameraPosition();
|
||||
assertEquals("Camera bearing should face north, ", 0, cameraPosition.bearing, TestConstants.BEARING_DELTA);
|
||||
}
|
||||
|
||||
private class WaitAction implements ViewAction {
|
||||
|
||||
private long waitTime;
|
||||
|
||||
WaitAction(long waitTime) {
|
||||
this.waitTime = waitTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Matcher<View> getConstraints() {
|
||||
return isDisplayed();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return getClass().getSimpleName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void perform(UiController uiController, View view) {
|
||||
uiController.loopMainThreadForAtLeast(waitTime);
|
||||
}
|
||||
}
|
||||
|
||||
private class MoveCameraAction implements ViewAction {
|
||||
|
||||
private MapboxMap mapboxMap;
|
||||
private CameraUpdate cameraUpdate;
|
||||
|
||||
MoveCameraAction(MapboxMap map, CameraUpdate update) {
|
||||
mapboxMap = map;
|
||||
cameraUpdate = update;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Matcher<View> getConstraints() {
|
||||
return isDisplayed();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return getClass().getSimpleName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void perform(UiController uiController, View view) {
|
||||
mapboxMap.moveCamera(cameraUpdate);
|
||||
}
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
CameraPosition cameraPosition = mapboxMap.getCameraPosition();
|
||||
assertEquals("Camera bearing should face north, ", 0, cameraPosition.bearing, TestConstants.BEARING_DELTA);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
package com.mapbox.mapboxsdk.testapp.style;
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.support.test.espresso.Espresso;
|
||||
import android.support.test.rule.ActivityTestRule;
|
||||
import android.support.test.espresso.UiController;
|
||||
import android.support.test.runner.AndroidJUnit4;
|
||||
|
||||
import timber.log.Timber;
|
||||
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
@@ -19,20 +19,16 @@ import com.mapbox.mapboxsdk.style.functions.stops.IntervalStops;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.Stop;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.Stops;
|
||||
import com.mapbox.mapboxsdk.style.layers.BackgroundLayer;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
import com.mapbox.mapboxsdk.testapp.activity.style.RuntimeStyleTestActivity;
|
||||
import com.mapbox.mapboxsdk.testapp.utils.OnMapReadyIdlingResource;
|
||||
import com.mapbox.mapboxsdk.testapp.action.MapboxMapAction;
|
||||
import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import static com.mapbox.mapboxsdk.style.functions.Function.*;
|
||||
import static com.mapbox.mapboxsdk.style.functions.stops.Stop.stop;
|
||||
import static com.mapbox.mapboxsdk.style.functions.stops.Stops.*;
|
||||
import static com.mapbox.mapboxsdk.testapp.action.MapboxMapAction.invoke;
|
||||
import static org.junit.Assert.*;
|
||||
import static com.mapbox.mapboxsdk.style.layers.Property.*;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*;
|
||||
@@ -53,9 +49,14 @@ public class BackgroundLayerTest extends BaseActivityTest {
|
||||
return EspressoTestActivity.class;
|
||||
}
|
||||
|
||||
private void setupLayer(){
|
||||
private void setupLayer() {
|
||||
Timber.i("Retrieving layer");
|
||||
layer = mapboxMap.getLayerAs("background");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
layer = mapboxMap.getLayerAs("background");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -63,14 +64,19 @@ public class BackgroundLayerTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("Visibility");
|
||||
assertNotNull(layer);
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Get initial
|
||||
assertEquals(layer.getVisibility().getValue(), VISIBLE);
|
||||
// Get initial
|
||||
assertEquals(layer.getVisibility().getValue(), VISIBLE);
|
||||
|
||||
// Set
|
||||
layer.setProperties(visibility(NONE));
|
||||
assertEquals(layer.getVisibility().getValue(), NONE);
|
||||
// Set
|
||||
layer.setProperties(visibility(NONE));
|
||||
assertEquals(layer.getVisibility().getValue(), NONE);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -78,12 +84,17 @@ public class BackgroundLayerTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("background-colorTransitionOptions");
|
||||
assertNotNull(layer);
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
TransitionOptions options = new TransitionOptions(300, 100);
|
||||
layer.setBackgroundColorTransition(options);
|
||||
assertEquals(layer.getBackgroundColorTransition(), options);
|
||||
// Set and Get
|
||||
TransitionOptions options = new TransitionOptions(300, 100);
|
||||
layer.setBackgroundColorTransition(options);
|
||||
assertEquals(layer.getBackgroundColorTransition(), options);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -91,11 +102,16 @@ public class BackgroundLayerTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("background-color");
|
||||
assertNotNull(layer);
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(backgroundColor("rgba(0, 0, 0, 1)"));
|
||||
assertEquals((String) layer.getBackgroundColor().getValue(), (String) "rgba(0, 0, 0, 1)");
|
||||
// Set and Get
|
||||
layer.setProperties(backgroundColor("rgba(0, 0, 0, 1)"));
|
||||
assertEquals((String) layer.getBackgroundColor().getValue(), (String) "rgba(0, 0, 0, 1)");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -103,26 +119,31 @@ public class BackgroundLayerTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("background-color");
|
||||
assertNotNull(layer);
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set
|
||||
layer.setProperties(
|
||||
backgroundColor(
|
||||
zoom(
|
||||
exponential(
|
||||
stop(2, backgroundColor("rgba(0, 0, 0, 1)"))
|
||||
).withBase(0.5f)
|
||||
)
|
||||
)
|
||||
);
|
||||
// Set
|
||||
layer.setProperties(
|
||||
backgroundColor(
|
||||
zoom(
|
||||
exponential(
|
||||
stop(2, backgroundColor("rgba(0, 0, 0, 1)"))
|
||||
).withBase(0.5f)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
// Verify
|
||||
assertNotNull(layer.getBackgroundColor());
|
||||
assertNotNull(layer.getBackgroundColor().getFunction());
|
||||
assertEquals(CameraFunction.class, layer.getBackgroundColor().getFunction().getClass());
|
||||
assertEquals(ExponentialStops.class, layer.getBackgroundColor().getFunction().getStops().getClass());
|
||||
assertEquals(0.5f, ((ExponentialStops) layer.getBackgroundColor().getFunction().getStops()).getBase(), 0.001);
|
||||
assertEquals(1, ((ExponentialStops) layer.getBackgroundColor().getFunction().getStops()).size());
|
||||
// Verify
|
||||
assertNotNull(layer.getBackgroundColor());
|
||||
assertNotNull(layer.getBackgroundColor().getFunction());
|
||||
assertEquals(CameraFunction.class, layer.getBackgroundColor().getFunction().getClass());
|
||||
assertEquals(ExponentialStops.class, layer.getBackgroundColor().getFunction().getStops().getClass());
|
||||
assertEquals(0.5f, ((ExponentialStops) layer.getBackgroundColor().getFunction().getStops()).getBase(), 0.001);
|
||||
assertEquals(1, ((ExponentialStops) layer.getBackgroundColor().getFunction().getStops()).size());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -130,11 +151,16 @@ public class BackgroundLayerTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("background-color");
|
||||
assertNotNull(layer);
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(backgroundColor(Color.RED));
|
||||
assertEquals(layer.getBackgroundColorAsInt(), Color.RED);
|
||||
// Set and Get
|
||||
layer.setProperties(backgroundColor(Color.RED));
|
||||
assertEquals(layer.getBackgroundColorAsInt(), Color.RED);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -142,12 +168,17 @@ public class BackgroundLayerTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("background-patternTransitionOptions");
|
||||
assertNotNull(layer);
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
TransitionOptions options = new TransitionOptions(300, 100);
|
||||
layer.setBackgroundPatternTransition(options);
|
||||
assertEquals(layer.getBackgroundPatternTransition(), options);
|
||||
// Set and Get
|
||||
TransitionOptions options = new TransitionOptions(300, 100);
|
||||
layer.setBackgroundPatternTransition(options);
|
||||
assertEquals(layer.getBackgroundPatternTransition(), options);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -155,11 +186,16 @@ public class BackgroundLayerTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("background-pattern");
|
||||
assertNotNull(layer);
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(backgroundPattern("pedestrian-polygon"));
|
||||
assertEquals((String) layer.getBackgroundPattern().getValue(), (String) "pedestrian-polygon");
|
||||
// Set and Get
|
||||
layer.setProperties(backgroundPattern("pedestrian-polygon"));
|
||||
assertEquals((String) layer.getBackgroundPattern().getValue(), (String) "pedestrian-polygon");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -167,25 +203,30 @@ public class BackgroundLayerTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("background-pattern");
|
||||
assertNotNull(layer);
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set
|
||||
layer.setProperties(
|
||||
backgroundPattern(
|
||||
zoom(
|
||||
interval(
|
||||
stop(2, backgroundPattern("pedestrian-polygon"))
|
||||
// Set
|
||||
layer.setProperties(
|
||||
backgroundPattern(
|
||||
zoom(
|
||||
interval(
|
||||
stop(2, backgroundPattern("pedestrian-polygon"))
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
);
|
||||
|
||||
// Verify
|
||||
assertNotNull(layer.getBackgroundPattern());
|
||||
assertNotNull(layer.getBackgroundPattern().getFunction());
|
||||
assertEquals(CameraFunction.class, layer.getBackgroundPattern().getFunction().getClass());
|
||||
assertEquals(IntervalStops.class, layer.getBackgroundPattern().getFunction().getStops().getClass());
|
||||
assertEquals(1, ((IntervalStops) layer.getBackgroundPattern().getFunction().getStops()).size());
|
||||
// Verify
|
||||
assertNotNull(layer.getBackgroundPattern());
|
||||
assertNotNull(layer.getBackgroundPattern().getFunction());
|
||||
assertEquals(CameraFunction.class, layer.getBackgroundPattern().getFunction().getClass());
|
||||
assertEquals(IntervalStops.class, layer.getBackgroundPattern().getFunction().getStops().getClass());
|
||||
assertEquals(1, ((IntervalStops) layer.getBackgroundPattern().getFunction().getStops()).size());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -193,12 +234,17 @@ public class BackgroundLayerTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("background-opacityTransitionOptions");
|
||||
assertNotNull(layer);
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
TransitionOptions options = new TransitionOptions(300, 100);
|
||||
layer.setBackgroundOpacityTransition(options);
|
||||
assertEquals(layer.getBackgroundOpacityTransition(), options);
|
||||
// Set and Get
|
||||
TransitionOptions options = new TransitionOptions(300, 100);
|
||||
layer.setBackgroundOpacityTransition(options);
|
||||
assertEquals(layer.getBackgroundOpacityTransition(), options);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -206,11 +252,16 @@ public class BackgroundLayerTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("background-opacity");
|
||||
assertNotNull(layer);
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(backgroundOpacity(0.3f));
|
||||
assertEquals((Float) layer.getBackgroundOpacity().getValue(), (Float) 0.3f);
|
||||
// Set and Get
|
||||
layer.setProperties(backgroundOpacity(0.3f));
|
||||
assertEquals((Float) layer.getBackgroundOpacity().getValue(), (Float) 0.3f);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -218,26 +269,31 @@ public class BackgroundLayerTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("background-opacity");
|
||||
assertNotNull(layer);
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set
|
||||
layer.setProperties(
|
||||
backgroundOpacity(
|
||||
zoom(
|
||||
exponential(
|
||||
stop(2, backgroundOpacity(0.3f))
|
||||
).withBase(0.5f)
|
||||
)
|
||||
)
|
||||
);
|
||||
// Set
|
||||
layer.setProperties(
|
||||
backgroundOpacity(
|
||||
zoom(
|
||||
exponential(
|
||||
stop(2, backgroundOpacity(0.3f))
|
||||
).withBase(0.5f)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
// Verify
|
||||
assertNotNull(layer.getBackgroundOpacity());
|
||||
assertNotNull(layer.getBackgroundOpacity().getFunction());
|
||||
assertEquals(CameraFunction.class, layer.getBackgroundOpacity().getFunction().getClass());
|
||||
assertEquals(ExponentialStops.class, layer.getBackgroundOpacity().getFunction().getStops().getClass());
|
||||
assertEquals(0.5f, ((ExponentialStops) layer.getBackgroundOpacity().getFunction().getStops()).getBase(), 0.001);
|
||||
assertEquals(1, ((ExponentialStops) layer.getBackgroundOpacity().getFunction().getStops()).size());
|
||||
// Verify
|
||||
assertNotNull(layer.getBackgroundOpacity());
|
||||
assertNotNull(layer.getBackgroundOpacity().getFunction());
|
||||
assertEquals(CameraFunction.class, layer.getBackgroundOpacity().getFunction().getClass());
|
||||
assertEquals(ExponentialStops.class, layer.getBackgroundOpacity().getFunction().getStops().getClass());
|
||||
assertEquals(0.5f, ((ExponentialStops) layer.getBackgroundOpacity().getFunction().getStops()).getBase(), 0.001);
|
||||
assertEquals(1, ((ExponentialStops) layer.getBackgroundOpacity().getFunction().getStops()).size());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
package com.mapbox.mapboxsdk.testapp.style;
|
||||
|
||||
import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest;
|
||||
import com.mapbox.mapboxsdk.testapp.activity.style.RuntimeStyleTestActivity;
|
||||
|
||||
/**
|
||||
* Base Test class for Style tests
|
||||
*/
|
||||
public class BaseStyleTest extends BaseActivityTest {
|
||||
|
||||
@Override
|
||||
protected Class getActivityClass() {
|
||||
return RuntimeStyleTestActivity.class;
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -6,6 +6,7 @@ import android.support.test.espresso.ViewAction;
|
||||
import android.support.test.runner.AndroidJUnit4;
|
||||
import android.view.View;
|
||||
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
import com.mapbox.mapboxsdk.style.light.Light;
|
||||
import com.mapbox.mapboxsdk.style.functions.Function;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.IdentityStops;
|
||||
@@ -13,6 +14,7 @@ import com.mapbox.mapboxsdk.style.layers.FillExtrusionLayer;
|
||||
import com.mapbox.mapboxsdk.style.layers.TransitionOptions;
|
||||
import com.mapbox.mapboxsdk.style.light.Position;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
import com.mapbox.mapboxsdk.testapp.action.MapboxMapAction;
|
||||
import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest;
|
||||
import com.mapbox.mapboxsdk.testapp.activity.style.FillExtrusionStyleTestActivity;
|
||||
|
||||
@@ -32,6 +34,7 @@ import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillExtrusionCol
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillExtrusionHeight;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillExtrusionOpacity;
|
||||
|
||||
import static com.mapbox.mapboxsdk.testapp.action.MapboxMapAction.invoke;
|
||||
import static junit.framework.Assert.assertEquals;
|
||||
import static junit.framework.Assert.assertNotNull;
|
||||
|
||||
@@ -43,89 +46,120 @@ public class LightTest extends BaseActivityTest {
|
||||
@Test
|
||||
public void testAnchor() {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
setupLight();
|
||||
Timber.i("anchor");
|
||||
assertNotNull(light);
|
||||
// Set and Get
|
||||
light.setAnchor(ANCHOR_MAP);
|
||||
assertEquals("Anchor should match", ANCHOR_MAP, light.getAnchor());
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(light);
|
||||
// Set and Get
|
||||
light.setAnchor(ANCHOR_MAP);
|
||||
assertEquals("Anchor should match", ANCHOR_MAP, light.getAnchor());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPositionTransition() {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
setupLight();
|
||||
Timber.i("positionTransitionOptions");
|
||||
assertNotNull(light);
|
||||
|
||||
// Set and Get
|
||||
TransitionOptions options = new TransitionOptions(300, 100);
|
||||
light.setPositionTransition(options);
|
||||
assertEquals("Transition options should match", options, light.getPositionTransition());
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(light);
|
||||
// Set and Get
|
||||
TransitionOptions options = new TransitionOptions(300, 100);
|
||||
light.setPositionTransition(options);
|
||||
assertEquals("Transition options should match", options, light.getPositionTransition());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPosition() {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
setupLight();
|
||||
Timber.i("position");
|
||||
assertNotNull(light);
|
||||
|
||||
// Set and Get
|
||||
Position position = new Position(1,2,3);
|
||||
light.setPosition(position);
|
||||
assertEquals("Position should match", position, light.getPosition());
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(light);
|
||||
// Set and Get
|
||||
Position position = new Position(1, 2, 3);
|
||||
light.setPosition(position);
|
||||
assertEquals("Position should match", position, light.getPosition());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testColorTransition() {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
setupLight();
|
||||
Timber.i("colorTransitionOptions");
|
||||
assertNotNull(light);
|
||||
|
||||
// Set and Get
|
||||
TransitionOptions options = new TransitionOptions(300, 100);
|
||||
light.setColorTransition(options);
|
||||
assertEquals("Transition options should match", options, light.getColorTransition());
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(light);
|
||||
// Set and Get
|
||||
TransitionOptions options = new TransitionOptions(300, 100);
|
||||
light.setColorTransition(options);
|
||||
assertEquals("Transition options should match", options, light.getColorTransition());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testColor() {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
setupLight();
|
||||
Timber.i("color");
|
||||
assertNotNull(light);
|
||||
// Set and Get
|
||||
light.setColor("rgba(0, 0, 0, 1)");
|
||||
assertEquals("Color should match", "rgba(0, 0, 0, 1)".replaceAll("\\s+",""), light.getColor());
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(light);
|
||||
// Set and Get
|
||||
light.setColor("rgba(0, 0, 0, 1)");
|
||||
assertEquals("Color should match", "rgba(0, 0, 0, 1)".replaceAll("\\s+", ""), light.getColor());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIntensityTransition() {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
setupLight();
|
||||
Timber.i("intensityTransitionOptions");
|
||||
assertNotNull(light);
|
||||
|
||||
// Set and Get
|
||||
TransitionOptions options = new TransitionOptions(300, 100);
|
||||
light.setIntensityTransition(options);
|
||||
assertEquals("Transition options should match", options, light.getIntensityTransition());
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(light);
|
||||
// Set and Get
|
||||
TransitionOptions options = new TransitionOptions(300, 100);
|
||||
light.setIntensityTransition(options);
|
||||
assertEquals("Transition options should match", options, light.getIntensityTransition());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIntensity() {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
setupLight();
|
||||
Timber.i("intensity");
|
||||
assertNotNull(light);
|
||||
// Set and Get
|
||||
light.setIntensity(0.3f);
|
||||
assertEquals("Intensity should match", 0.3f, light.getIntensity());
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(light);
|
||||
// Set and Get
|
||||
light.setIntensity(0.3f);
|
||||
assertEquals("Intensity should match", 0.3f, light.getIntensity());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void setupLayer() {
|
||||
private void setupLight() {
|
||||
onView(withId(R.id.mapView)).perform(new ViewAction() {
|
||||
@Override
|
||||
public Matcher<View> getConstraints() {
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -3,9 +3,9 @@
|
||||
package com.mapbox.mapboxsdk.testapp.style;
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.support.test.espresso.Espresso;
|
||||
import android.support.test.rule.ActivityTestRule;
|
||||
import android.support.test.espresso.UiController;
|
||||
import android.support.test.runner.AndroidJUnit4;
|
||||
|
||||
import timber.log.Timber;
|
||||
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
@@ -19,20 +19,16 @@ import com.mapbox.mapboxsdk.style.functions.stops.IntervalStops;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.Stop;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.Stops;
|
||||
import com.mapbox.mapboxsdk.style.layers.RasterLayer;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
import com.mapbox.mapboxsdk.testapp.activity.style.RuntimeStyleTestActivity;
|
||||
import com.mapbox.mapboxsdk.testapp.utils.OnMapReadyIdlingResource;
|
||||
import com.mapbox.mapboxsdk.testapp.action.MapboxMapAction;
|
||||
import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import static com.mapbox.mapboxsdk.style.functions.Function.*;
|
||||
import static com.mapbox.mapboxsdk.style.functions.stops.Stop.stop;
|
||||
import static com.mapbox.mapboxsdk.style.functions.stops.Stops.*;
|
||||
import static com.mapbox.mapboxsdk.testapp.action.MapboxMapAction.invoke;
|
||||
import static org.junit.Assert.*;
|
||||
import static com.mapbox.mapboxsdk.style.layers.Property.*;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*;
|
||||
@@ -53,15 +49,21 @@ public class RasterLayerTest extends BaseActivityTest {
|
||||
return EspressoTestActivity.class;
|
||||
}
|
||||
|
||||
private void setupLayer(){
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new RasterLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
// Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
private void setupLayer() {
|
||||
Timber.i("Retrieving layer");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new RasterLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
// Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -69,14 +71,19 @@ public class RasterLayerTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("Visibility");
|
||||
assertNotNull(layer);
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Get initial
|
||||
assertEquals(layer.getVisibility().getValue(), VISIBLE);
|
||||
// Get initial
|
||||
assertEquals(layer.getVisibility().getValue(), VISIBLE);
|
||||
|
||||
// Set
|
||||
layer.setProperties(visibility(NONE));
|
||||
assertEquals(layer.getVisibility().getValue(), NONE);
|
||||
// Set
|
||||
layer.setProperties(visibility(NONE));
|
||||
assertEquals(layer.getVisibility().getValue(), NONE);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -84,12 +91,17 @@ public class RasterLayerTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("raster-opacityTransitionOptions");
|
||||
assertNotNull(layer);
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
TransitionOptions options = new TransitionOptions(300, 100);
|
||||
layer.setRasterOpacityTransition(options);
|
||||
assertEquals(layer.getRasterOpacityTransition(), options);
|
||||
// Set and Get
|
||||
TransitionOptions options = new TransitionOptions(300, 100);
|
||||
layer.setRasterOpacityTransition(options);
|
||||
assertEquals(layer.getRasterOpacityTransition(), options);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -97,11 +109,16 @@ public class RasterLayerTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("raster-opacity");
|
||||
assertNotNull(layer);
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(rasterOpacity(0.3f));
|
||||
assertEquals((Float) layer.getRasterOpacity().getValue(), (Float) 0.3f);
|
||||
// Set and Get
|
||||
layer.setProperties(rasterOpacity(0.3f));
|
||||
assertEquals((Float) layer.getRasterOpacity().getValue(), (Float) 0.3f);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -109,26 +126,31 @@ public class RasterLayerTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("raster-opacity");
|
||||
assertNotNull(layer);
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set
|
||||
layer.setProperties(
|
||||
rasterOpacity(
|
||||
zoom(
|
||||
exponential(
|
||||
stop(2, rasterOpacity(0.3f))
|
||||
).withBase(0.5f)
|
||||
)
|
||||
)
|
||||
);
|
||||
// Set
|
||||
layer.setProperties(
|
||||
rasterOpacity(
|
||||
zoom(
|
||||
exponential(
|
||||
stop(2, rasterOpacity(0.3f))
|
||||
).withBase(0.5f)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
// Verify
|
||||
assertNotNull(layer.getRasterOpacity());
|
||||
assertNotNull(layer.getRasterOpacity().getFunction());
|
||||
assertEquals(CameraFunction.class, layer.getRasterOpacity().getFunction().getClass());
|
||||
assertEquals(ExponentialStops.class, layer.getRasterOpacity().getFunction().getStops().getClass());
|
||||
assertEquals(0.5f, ((ExponentialStops) layer.getRasterOpacity().getFunction().getStops()).getBase(), 0.001);
|
||||
assertEquals(1, ((ExponentialStops) layer.getRasterOpacity().getFunction().getStops()).size());
|
||||
// Verify
|
||||
assertNotNull(layer.getRasterOpacity());
|
||||
assertNotNull(layer.getRasterOpacity().getFunction());
|
||||
assertEquals(CameraFunction.class, layer.getRasterOpacity().getFunction().getClass());
|
||||
assertEquals(ExponentialStops.class, layer.getRasterOpacity().getFunction().getStops().getClass());
|
||||
assertEquals(0.5f, ((ExponentialStops) layer.getRasterOpacity().getFunction().getStops()).getBase(), 0.001);
|
||||
assertEquals(1, ((ExponentialStops) layer.getRasterOpacity().getFunction().getStops()).size());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -136,12 +158,17 @@ public class RasterLayerTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("raster-hue-rotateTransitionOptions");
|
||||
assertNotNull(layer);
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
TransitionOptions options = new TransitionOptions(300, 100);
|
||||
layer.setRasterHueRotateTransition(options);
|
||||
assertEquals(layer.getRasterHueRotateTransition(), options);
|
||||
// Set and Get
|
||||
TransitionOptions options = new TransitionOptions(300, 100);
|
||||
layer.setRasterHueRotateTransition(options);
|
||||
assertEquals(layer.getRasterHueRotateTransition(), options);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -149,11 +176,16 @@ public class RasterLayerTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("raster-hue-rotate");
|
||||
assertNotNull(layer);
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(rasterHueRotate(0.3f));
|
||||
assertEquals((Float) layer.getRasterHueRotate().getValue(), (Float) 0.3f);
|
||||
// Set and Get
|
||||
layer.setProperties(rasterHueRotate(0.3f));
|
||||
assertEquals((Float) layer.getRasterHueRotate().getValue(), (Float) 0.3f);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -161,26 +193,31 @@ public class RasterLayerTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("raster-hue-rotate");
|
||||
assertNotNull(layer);
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set
|
||||
layer.setProperties(
|
||||
rasterHueRotate(
|
||||
zoom(
|
||||
exponential(
|
||||
stop(2, rasterHueRotate(0.3f))
|
||||
).withBase(0.5f)
|
||||
)
|
||||
)
|
||||
);
|
||||
// Set
|
||||
layer.setProperties(
|
||||
rasterHueRotate(
|
||||
zoom(
|
||||
exponential(
|
||||
stop(2, rasterHueRotate(0.3f))
|
||||
).withBase(0.5f)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
// Verify
|
||||
assertNotNull(layer.getRasterHueRotate());
|
||||
assertNotNull(layer.getRasterHueRotate().getFunction());
|
||||
assertEquals(CameraFunction.class, layer.getRasterHueRotate().getFunction().getClass());
|
||||
assertEquals(ExponentialStops.class, layer.getRasterHueRotate().getFunction().getStops().getClass());
|
||||
assertEquals(0.5f, ((ExponentialStops) layer.getRasterHueRotate().getFunction().getStops()).getBase(), 0.001);
|
||||
assertEquals(1, ((ExponentialStops) layer.getRasterHueRotate().getFunction().getStops()).size());
|
||||
// Verify
|
||||
assertNotNull(layer.getRasterHueRotate());
|
||||
assertNotNull(layer.getRasterHueRotate().getFunction());
|
||||
assertEquals(CameraFunction.class, layer.getRasterHueRotate().getFunction().getClass());
|
||||
assertEquals(ExponentialStops.class, layer.getRasterHueRotate().getFunction().getStops().getClass());
|
||||
assertEquals(0.5f, ((ExponentialStops) layer.getRasterHueRotate().getFunction().getStops()).getBase(), 0.001);
|
||||
assertEquals(1, ((ExponentialStops) layer.getRasterHueRotate().getFunction().getStops()).size());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -188,12 +225,17 @@ public class RasterLayerTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("raster-brightness-minTransitionOptions");
|
||||
assertNotNull(layer);
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
TransitionOptions options = new TransitionOptions(300, 100);
|
||||
layer.setRasterBrightnessMinTransition(options);
|
||||
assertEquals(layer.getRasterBrightnessMinTransition(), options);
|
||||
// Set and Get
|
||||
TransitionOptions options = new TransitionOptions(300, 100);
|
||||
layer.setRasterBrightnessMinTransition(options);
|
||||
assertEquals(layer.getRasterBrightnessMinTransition(), options);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -201,11 +243,16 @@ public class RasterLayerTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("raster-brightness-min");
|
||||
assertNotNull(layer);
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(rasterBrightnessMin(0.3f));
|
||||
assertEquals((Float) layer.getRasterBrightnessMin().getValue(), (Float) 0.3f);
|
||||
// Set and Get
|
||||
layer.setProperties(rasterBrightnessMin(0.3f));
|
||||
assertEquals((Float) layer.getRasterBrightnessMin().getValue(), (Float) 0.3f);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -213,26 +260,31 @@ public class RasterLayerTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("raster-brightness-min");
|
||||
assertNotNull(layer);
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set
|
||||
layer.setProperties(
|
||||
rasterBrightnessMin(
|
||||
zoom(
|
||||
exponential(
|
||||
stop(2, rasterBrightnessMin(0.3f))
|
||||
).withBase(0.5f)
|
||||
)
|
||||
)
|
||||
);
|
||||
// Set
|
||||
layer.setProperties(
|
||||
rasterBrightnessMin(
|
||||
zoom(
|
||||
exponential(
|
||||
stop(2, rasterBrightnessMin(0.3f))
|
||||
).withBase(0.5f)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
// Verify
|
||||
assertNotNull(layer.getRasterBrightnessMin());
|
||||
assertNotNull(layer.getRasterBrightnessMin().getFunction());
|
||||
assertEquals(CameraFunction.class, layer.getRasterBrightnessMin().getFunction().getClass());
|
||||
assertEquals(ExponentialStops.class, layer.getRasterBrightnessMin().getFunction().getStops().getClass());
|
||||
assertEquals(0.5f, ((ExponentialStops) layer.getRasterBrightnessMin().getFunction().getStops()).getBase(), 0.001);
|
||||
assertEquals(1, ((ExponentialStops) layer.getRasterBrightnessMin().getFunction().getStops()).size());
|
||||
// Verify
|
||||
assertNotNull(layer.getRasterBrightnessMin());
|
||||
assertNotNull(layer.getRasterBrightnessMin().getFunction());
|
||||
assertEquals(CameraFunction.class, layer.getRasterBrightnessMin().getFunction().getClass());
|
||||
assertEquals(ExponentialStops.class, layer.getRasterBrightnessMin().getFunction().getStops().getClass());
|
||||
assertEquals(0.5f, ((ExponentialStops) layer.getRasterBrightnessMin().getFunction().getStops()).getBase(), 0.001);
|
||||
assertEquals(1, ((ExponentialStops) layer.getRasterBrightnessMin().getFunction().getStops()).size());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -240,12 +292,17 @@ public class RasterLayerTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("raster-brightness-maxTransitionOptions");
|
||||
assertNotNull(layer);
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
TransitionOptions options = new TransitionOptions(300, 100);
|
||||
layer.setRasterBrightnessMaxTransition(options);
|
||||
assertEquals(layer.getRasterBrightnessMaxTransition(), options);
|
||||
// Set and Get
|
||||
TransitionOptions options = new TransitionOptions(300, 100);
|
||||
layer.setRasterBrightnessMaxTransition(options);
|
||||
assertEquals(layer.getRasterBrightnessMaxTransition(), options);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -253,11 +310,16 @@ public class RasterLayerTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("raster-brightness-max");
|
||||
assertNotNull(layer);
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(rasterBrightnessMax(0.3f));
|
||||
assertEquals((Float) layer.getRasterBrightnessMax().getValue(), (Float) 0.3f);
|
||||
// Set and Get
|
||||
layer.setProperties(rasterBrightnessMax(0.3f));
|
||||
assertEquals((Float) layer.getRasterBrightnessMax().getValue(), (Float) 0.3f);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -265,26 +327,31 @@ public class RasterLayerTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("raster-brightness-max");
|
||||
assertNotNull(layer);
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set
|
||||
layer.setProperties(
|
||||
rasterBrightnessMax(
|
||||
zoom(
|
||||
exponential(
|
||||
stop(2, rasterBrightnessMax(0.3f))
|
||||
).withBase(0.5f)
|
||||
)
|
||||
)
|
||||
);
|
||||
// Set
|
||||
layer.setProperties(
|
||||
rasterBrightnessMax(
|
||||
zoom(
|
||||
exponential(
|
||||
stop(2, rasterBrightnessMax(0.3f))
|
||||
).withBase(0.5f)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
// Verify
|
||||
assertNotNull(layer.getRasterBrightnessMax());
|
||||
assertNotNull(layer.getRasterBrightnessMax().getFunction());
|
||||
assertEquals(CameraFunction.class, layer.getRasterBrightnessMax().getFunction().getClass());
|
||||
assertEquals(ExponentialStops.class, layer.getRasterBrightnessMax().getFunction().getStops().getClass());
|
||||
assertEquals(0.5f, ((ExponentialStops) layer.getRasterBrightnessMax().getFunction().getStops()).getBase(), 0.001);
|
||||
assertEquals(1, ((ExponentialStops) layer.getRasterBrightnessMax().getFunction().getStops()).size());
|
||||
// Verify
|
||||
assertNotNull(layer.getRasterBrightnessMax());
|
||||
assertNotNull(layer.getRasterBrightnessMax().getFunction());
|
||||
assertEquals(CameraFunction.class, layer.getRasterBrightnessMax().getFunction().getClass());
|
||||
assertEquals(ExponentialStops.class, layer.getRasterBrightnessMax().getFunction().getStops().getClass());
|
||||
assertEquals(0.5f, ((ExponentialStops) layer.getRasterBrightnessMax().getFunction().getStops()).getBase(), 0.001);
|
||||
assertEquals(1, ((ExponentialStops) layer.getRasterBrightnessMax().getFunction().getStops()).size());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -292,12 +359,17 @@ public class RasterLayerTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("raster-saturationTransitionOptions");
|
||||
assertNotNull(layer);
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
TransitionOptions options = new TransitionOptions(300, 100);
|
||||
layer.setRasterSaturationTransition(options);
|
||||
assertEquals(layer.getRasterSaturationTransition(), options);
|
||||
// Set and Get
|
||||
TransitionOptions options = new TransitionOptions(300, 100);
|
||||
layer.setRasterSaturationTransition(options);
|
||||
assertEquals(layer.getRasterSaturationTransition(), options);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -305,11 +377,16 @@ public class RasterLayerTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("raster-saturation");
|
||||
assertNotNull(layer);
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(rasterSaturation(0.3f));
|
||||
assertEquals((Float) layer.getRasterSaturation().getValue(), (Float) 0.3f);
|
||||
// Set and Get
|
||||
layer.setProperties(rasterSaturation(0.3f));
|
||||
assertEquals((Float) layer.getRasterSaturation().getValue(), (Float) 0.3f);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -317,26 +394,31 @@ public class RasterLayerTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("raster-saturation");
|
||||
assertNotNull(layer);
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set
|
||||
layer.setProperties(
|
||||
rasterSaturation(
|
||||
zoom(
|
||||
exponential(
|
||||
stop(2, rasterSaturation(0.3f))
|
||||
).withBase(0.5f)
|
||||
)
|
||||
)
|
||||
);
|
||||
// Set
|
||||
layer.setProperties(
|
||||
rasterSaturation(
|
||||
zoom(
|
||||
exponential(
|
||||
stop(2, rasterSaturation(0.3f))
|
||||
).withBase(0.5f)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
// Verify
|
||||
assertNotNull(layer.getRasterSaturation());
|
||||
assertNotNull(layer.getRasterSaturation().getFunction());
|
||||
assertEquals(CameraFunction.class, layer.getRasterSaturation().getFunction().getClass());
|
||||
assertEquals(ExponentialStops.class, layer.getRasterSaturation().getFunction().getStops().getClass());
|
||||
assertEquals(0.5f, ((ExponentialStops) layer.getRasterSaturation().getFunction().getStops()).getBase(), 0.001);
|
||||
assertEquals(1, ((ExponentialStops) layer.getRasterSaturation().getFunction().getStops()).size());
|
||||
// Verify
|
||||
assertNotNull(layer.getRasterSaturation());
|
||||
assertNotNull(layer.getRasterSaturation().getFunction());
|
||||
assertEquals(CameraFunction.class, layer.getRasterSaturation().getFunction().getClass());
|
||||
assertEquals(ExponentialStops.class, layer.getRasterSaturation().getFunction().getStops().getClass());
|
||||
assertEquals(0.5f, ((ExponentialStops) layer.getRasterSaturation().getFunction().getStops()).getBase(), 0.001);
|
||||
assertEquals(1, ((ExponentialStops) layer.getRasterSaturation().getFunction().getStops()).size());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -344,12 +426,17 @@ public class RasterLayerTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("raster-contrastTransitionOptions");
|
||||
assertNotNull(layer);
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
TransitionOptions options = new TransitionOptions(300, 100);
|
||||
layer.setRasterContrastTransition(options);
|
||||
assertEquals(layer.getRasterContrastTransition(), options);
|
||||
// Set and Get
|
||||
TransitionOptions options = new TransitionOptions(300, 100);
|
||||
layer.setRasterContrastTransition(options);
|
||||
assertEquals(layer.getRasterContrastTransition(), options);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -357,11 +444,16 @@ public class RasterLayerTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("raster-contrast");
|
||||
assertNotNull(layer);
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(rasterContrast(0.3f));
|
||||
assertEquals((Float) layer.getRasterContrast().getValue(), (Float) 0.3f);
|
||||
// Set and Get
|
||||
layer.setProperties(rasterContrast(0.3f));
|
||||
assertEquals((Float) layer.getRasterContrast().getValue(), (Float) 0.3f);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -369,26 +461,31 @@ public class RasterLayerTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("raster-contrast");
|
||||
assertNotNull(layer);
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set
|
||||
layer.setProperties(
|
||||
rasterContrast(
|
||||
zoom(
|
||||
exponential(
|
||||
stop(2, rasterContrast(0.3f))
|
||||
).withBase(0.5f)
|
||||
)
|
||||
)
|
||||
);
|
||||
// Set
|
||||
layer.setProperties(
|
||||
rasterContrast(
|
||||
zoom(
|
||||
exponential(
|
||||
stop(2, rasterContrast(0.3f))
|
||||
).withBase(0.5f)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
// Verify
|
||||
assertNotNull(layer.getRasterContrast());
|
||||
assertNotNull(layer.getRasterContrast().getFunction());
|
||||
assertEquals(CameraFunction.class, layer.getRasterContrast().getFunction().getClass());
|
||||
assertEquals(ExponentialStops.class, layer.getRasterContrast().getFunction().getStops().getClass());
|
||||
assertEquals(0.5f, ((ExponentialStops) layer.getRasterContrast().getFunction().getStops()).getBase(), 0.001);
|
||||
assertEquals(1, ((ExponentialStops) layer.getRasterContrast().getFunction().getStops()).size());
|
||||
// Verify
|
||||
assertNotNull(layer.getRasterContrast());
|
||||
assertNotNull(layer.getRasterContrast().getFunction());
|
||||
assertEquals(CameraFunction.class, layer.getRasterContrast().getFunction().getClass());
|
||||
assertEquals(ExponentialStops.class, layer.getRasterContrast().getFunction().getStops().getClass());
|
||||
assertEquals(0.5f, ((ExponentialStops) layer.getRasterContrast().getFunction().getStops()).getBase(), 0.001);
|
||||
assertEquals(1, ((ExponentialStops) layer.getRasterContrast().getFunction().getStops()).size());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -396,12 +493,17 @@ public class RasterLayerTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("raster-fade-durationTransitionOptions");
|
||||
assertNotNull(layer);
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
TransitionOptions options = new TransitionOptions(300, 100);
|
||||
layer.setRasterFadeDurationTransition(options);
|
||||
assertEquals(layer.getRasterFadeDurationTransition(), options);
|
||||
// Set and Get
|
||||
TransitionOptions options = new TransitionOptions(300, 100);
|
||||
layer.setRasterFadeDurationTransition(options);
|
||||
assertEquals(layer.getRasterFadeDurationTransition(), options);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -409,11 +511,16 @@ public class RasterLayerTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("raster-fade-duration");
|
||||
assertNotNull(layer);
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(rasterFadeDuration(0.3f));
|
||||
assertEquals((Float) layer.getRasterFadeDuration().getValue(), (Float) 0.3f);
|
||||
// Set and Get
|
||||
layer.setProperties(rasterFadeDuration(0.3f));
|
||||
assertEquals((Float) layer.getRasterFadeDuration().getValue(), (Float) 0.3f);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -421,26 +528,31 @@ public class RasterLayerTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("raster-fade-duration");
|
||||
assertNotNull(layer);
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set
|
||||
layer.setProperties(
|
||||
rasterFadeDuration(
|
||||
zoom(
|
||||
exponential(
|
||||
stop(2, rasterFadeDuration(0.3f))
|
||||
).withBase(0.5f)
|
||||
)
|
||||
)
|
||||
);
|
||||
// Set
|
||||
layer.setProperties(
|
||||
rasterFadeDuration(
|
||||
zoom(
|
||||
exponential(
|
||||
stop(2, rasterFadeDuration(0.3f))
|
||||
).withBase(0.5f)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
// Verify
|
||||
assertNotNull(layer.getRasterFadeDuration());
|
||||
assertNotNull(layer.getRasterFadeDuration().getFunction());
|
||||
assertEquals(CameraFunction.class, layer.getRasterFadeDuration().getFunction().getClass());
|
||||
assertEquals(ExponentialStops.class, layer.getRasterFadeDuration().getFunction().getStops().getClass());
|
||||
assertEquals(0.5f, ((ExponentialStops) layer.getRasterFadeDuration().getFunction().getStops()).getBase(), 0.001);
|
||||
assertEquals(1, ((ExponentialStops) layer.getRasterFadeDuration().getFunction().getStops()).size());
|
||||
// Verify
|
||||
assertNotNull(layer.getRasterFadeDuration());
|
||||
assertNotNull(layer.getRasterFadeDuration().getFunction());
|
||||
assertEquals(CameraFunction.class, layer.getRasterFadeDuration().getFunction().getClass());
|
||||
assertEquals(ExponentialStops.class, layer.getRasterFadeDuration().getFunction().getStops().getClass());
|
||||
assertEquals(0.5f, ((ExponentialStops) layer.getRasterFadeDuration().getFunction().getStops()).getBase(), 0.001);
|
||||
assertEquals(1, ((ExponentialStops) layer.getRasterFadeDuration().getFunction().getStops()).size());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,61 +0,0 @@
|
||||
package com.mapbox.mapboxsdk.testapp.style;
|
||||
|
||||
import android.support.test.InstrumentationRegistry;
|
||||
import android.support.test.runner.AndroidJUnit4;
|
||||
import android.test.ActivityInstrumentationTestCase2;
|
||||
|
||||
import timber.log.Timber;
|
||||
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
import com.mapbox.mapboxsdk.maps.OnMapReadyCallback;
|
||||
import com.mapbox.mapboxsdk.style.layers.BackgroundLayer;
|
||||
import com.mapbox.mapboxsdk.style.layers.Property;
|
||||
import com.mapbox.mapboxsdk.style.layers.PropertyFactory;
|
||||
import com.mapbox.mapboxsdk.testapp.activity.style.RuntimeStyleTestActivity;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
/**
|
||||
* Basic smoke tests for BackgroundLayer
|
||||
*/
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class RuntimeStyleBackgroundLayerTest
|
||||
extends ActivityInstrumentationTestCase2<RuntimeStyleTestActivity> {
|
||||
|
||||
public RuntimeStyleBackgroundLayerTest() {
|
||||
super(RuntimeStyleTestActivity.class);
|
||||
}
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
super.setUp();
|
||||
injectInstrumentation(InstrumentationRegistry.getInstrumentation());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetVisibility() {
|
||||
getActivity().mapView.getMapAsync(new OnMapReadyCallback() {
|
||||
@Override
|
||||
public void onMapReady(MapboxMap mapboxMap) {
|
||||
Timber.i("visibility");
|
||||
BackgroundLayer layer = mapboxMap.getLayerAs("background");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Get initial
|
||||
assertEquals(layer.getVisibility().getValue(), Property.VISIBLE);
|
||||
|
||||
// Set
|
||||
layer.setProperties(PropertyFactory.visibility(Property.NONE));
|
||||
assertEquals(layer.getVisibility().getValue(), Property.NONE);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() throws Exception {
|
||||
super.tearDown();
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,7 @@ import android.support.test.espresso.ViewAction;
|
||||
import android.support.test.runner.AndroidJUnit4;
|
||||
import android.view.View;
|
||||
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
import com.mapbox.mapboxsdk.style.layers.CannotAddLayerException;
|
||||
import com.mapbox.mapboxsdk.style.layers.CircleLayer;
|
||||
import com.mapbox.mapboxsdk.style.layers.FillLayer;
|
||||
@@ -21,6 +22,7 @@ import com.mapbox.mapboxsdk.style.sources.RasterSource;
|
||||
import com.mapbox.mapboxsdk.style.sources.Source;
|
||||
import com.mapbox.mapboxsdk.style.sources.VectorSource;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
import com.mapbox.mapboxsdk.testapp.action.MapboxMapAction;
|
||||
import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest;
|
||||
import com.mapbox.mapboxsdk.testapp.activity.style.RuntimeStyleTestActivity;
|
||||
|
||||
@@ -40,6 +42,7 @@ 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.withId;
|
||||
import static com.mapbox.mapboxsdk.testapp.action.MapboxMapAction.invoke;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
@@ -189,39 +192,89 @@ public class RuntimeStyleTests extends BaseActivityTest {
|
||||
@Test
|
||||
public void testAddRemoveSource() {
|
||||
validateTestSetup();
|
||||
mapboxMap.addSource(new VectorSource("my-source", "mapbox://mapbox.mapbox-terrain-v2"));
|
||||
mapboxMap.removeSource("my-source");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
mapboxMap.addSource(new VectorSource("my-source", "mapbox://mapbox.mapbox-terrain-v2"));
|
||||
mapboxMap.removeSource("my-source");
|
||||
|
||||
// Add initial source
|
||||
mapboxMap.addSource(new VectorSource("my-source", "mapbox://mapbox.mapbox-terrain-v2"));
|
||||
|
||||
// Remove
|
||||
Source mySource = mapboxMap.removeSource("my-source");
|
||||
assertNotNull(mySource);
|
||||
assertNull(mapboxMap.getLayer("my-source"));
|
||||
|
||||
// Add
|
||||
Source source = new VectorSource("my-source", "mapbox://mapbox.mapbox-terrain-v2");
|
||||
mapboxMap.addSource(source);
|
||||
|
||||
// Remove, preserving the reference
|
||||
mapboxMap.removeSource(source);
|
||||
|
||||
// Re-add the reference...
|
||||
mapboxMap.addSource(source);
|
||||
|
||||
// Ensure it's there
|
||||
Assert.assertNotNull(mapboxMap.getSource(source.getId()));
|
||||
|
||||
// Test adding a duplicate source
|
||||
try {
|
||||
Source source2 = new VectorSource("my-source", "mapbox://mapbox.mapbox-terrain-v2");
|
||||
mapboxMap.addSource(source2);
|
||||
fail("Should not have been allowed to add a source with a duplicate id");
|
||||
} catch (CannotAddSourceException cannotAddSourceException) {
|
||||
// OK
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
onView(withId(R.id.mapView)).perform(new AddRemoveSourceAction());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testVectorSourceUrlGetter() {
|
||||
validateTestSetup();
|
||||
|
||||
VectorSource source = new VectorSource("my-source", "mapbox://mapbox.mapbox-terrain-v2");
|
||||
mapboxMap.addSource(source);
|
||||
assertEquals("mapbox://mapbox.mapbox-terrain-v2", source.getUrl());
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
VectorSource source = new VectorSource("my-source", "mapbox://mapbox.mapbox-terrain-v2");
|
||||
mapboxMap.addSource(source);
|
||||
assertEquals("mapbox://mapbox.mapbox-terrain-v2", source.getUrl());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRasterSourceUrlGetter() {
|
||||
validateTestSetup();
|
||||
|
||||
RasterSource source = new RasterSource("my-source", "mapbox://mapbox.mapbox-terrain-v2");
|
||||
mapboxMap.addSource(source);
|
||||
assertEquals("mapbox://mapbox.mapbox-terrain-v2", source.getUrl());
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
RasterSource source = new RasterSource("my-source", "mapbox://mapbox.mapbox-terrain-v2");
|
||||
mapboxMap.addSource(source);
|
||||
assertEquals("mapbox://mapbox.mapbox-terrain-v2", source.getUrl());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGeoJsonSourceUrlGetter() throws MalformedURLException {
|
||||
validateTestSetup();
|
||||
|
||||
GeoJsonSource source = new GeoJsonSource("my-source");
|
||||
mapboxMap.addSource(source);
|
||||
assertNull(source.getUrl());
|
||||
source.setUrl(new URL("http://mapbox.com/my-file.json"));
|
||||
assertEquals("http://mapbox.com/my-file.json", source.getUrl());
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
GeoJsonSource source = new GeoJsonSource("my-source");
|
||||
mapboxMap.addSource(source);
|
||||
assertNull(source.getUrl());
|
||||
try {
|
||||
source.setUrl(new URL("http://mapbox.com/my-file.json"));
|
||||
} catch (MalformedURLException exception) {
|
||||
fail();
|
||||
}
|
||||
assertEquals("http://mapbox.com/my-file.json", source.getUrl());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -304,42 +357,6 @@ public class RuntimeStyleTests extends BaseActivityTest {
|
||||
}
|
||||
}
|
||||
|
||||
private class AddRemoveSourceAction extends BaseViewAction {
|
||||
|
||||
@Override
|
||||
public void perform(UiController uiController, View view) {
|
||||
// Add initial source
|
||||
mapboxMap.addSource(new VectorSource("my-source", "mapbox://mapbox.mapbox-terrain-v2"));
|
||||
|
||||
// Remove
|
||||
Source mySource = mapboxMap.removeSource("my-source");
|
||||
assertNotNull(mySource);
|
||||
assertNull(mapboxMap.getLayer("my-source"));
|
||||
|
||||
// Add
|
||||
Source source = new VectorSource("my-source", "mapbox://mapbox.mapbox-terrain-v2");
|
||||
mapboxMap.addSource(source);
|
||||
|
||||
// Remove, preserving the reference
|
||||
mapboxMap.removeSource(source);
|
||||
|
||||
// Re-add the reference...
|
||||
mapboxMap.addSource(source);
|
||||
|
||||
// Ensure it's there
|
||||
Assert.assertNotNull(mapboxMap.getSource(source.getId()));
|
||||
|
||||
// Test adding a duplicate source
|
||||
try {
|
||||
Source source2 = new VectorSource("my-source", "mapbox://mapbox.mapbox-terrain-v2");
|
||||
mapboxMap.addSource(source2);
|
||||
fail("Should not have been allowed to add a source with a duplicate id");
|
||||
} catch (CannotAddSourceException cannotAddSourceException) {
|
||||
// OK
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@After
|
||||
public void unregisterIntentServiceIdlingResource() {
|
||||
Espresso.unregisterIdlingResources(idlingResource);
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -7,9 +7,9 @@
|
||||
package com.mapbox.mapboxsdk.testapp.style;
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.support.test.espresso.Espresso;
|
||||
import android.support.test.rule.ActivityTestRule;
|
||||
import android.support.test.espresso.UiController;
|
||||
import android.support.test.runner.AndroidJUnit4;
|
||||
|
||||
import timber.log.Timber;
|
||||
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
@@ -23,20 +23,16 @@ import com.mapbox.mapboxsdk.style.functions.stops.IntervalStops;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.Stop;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.Stops;
|
||||
import com.mapbox.mapboxsdk.style.layers.<%- camelize(type) %>Layer;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
import com.mapbox.mapboxsdk.testapp.activity.style.RuntimeStyleTestActivity;
|
||||
import com.mapbox.mapboxsdk.testapp.utils.OnMapReadyIdlingResource;
|
||||
import com.mapbox.mapboxsdk.testapp.action.MapboxMapAction;
|
||||
import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import static com.mapbox.mapboxsdk.style.functions.Function.*;
|
||||
import static com.mapbox.mapboxsdk.style.functions.stops.Stop.stop;
|
||||
import static com.mapbox.mapboxsdk.style.functions.stops.Stops.*;
|
||||
import static com.mapbox.mapboxsdk.testapp.action.MapboxMapAction.invoke;
|
||||
import static org.junit.Assert.*;
|
||||
import static com.mapbox.mapboxsdk.style.layers.Property.*;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*;
|
||||
@@ -57,19 +53,30 @@ public class <%- camelize(type) %>LayerTest extends BaseActivityTest {
|
||||
return EspressoTestActivity.class;
|
||||
}
|
||||
|
||||
private void setupLayer(){
|
||||
private void setupLayer() {
|
||||
<% if (type === 'background') { -%>
|
||||
Timber.i("Retrieving layer");
|
||||
layer = mapboxMap.getLayerAs("background");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
layer = mapboxMap.getLayerAs("background");
|
||||
}
|
||||
});
|
||||
<% } else { -%>
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new <%- camelize(type) %>Layer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
// Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("Retrieving layer");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new <%- camelize(type) %>Layer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
// Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
}
|
||||
});
|
||||
<% } -%>
|
||||
}
|
||||
|
||||
@@ -78,14 +85,19 @@ public class <%- camelize(type) %>LayerTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("Visibility");
|
||||
assertNotNull(layer);
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Get initial
|
||||
assertEquals(layer.getVisibility().getValue(), VISIBLE);
|
||||
// Get initial
|
||||
assertEquals(layer.getVisibility().getValue(), VISIBLE);
|
||||
|
||||
// Set
|
||||
layer.setProperties(visibility(NONE));
|
||||
assertEquals(layer.getVisibility().getValue(), NONE);
|
||||
// Set
|
||||
layer.setProperties(visibility(NONE));
|
||||
assertEquals(layer.getVisibility().getValue(), NONE);
|
||||
}
|
||||
});
|
||||
}
|
||||
<% if (!(type === 'background' || type === 'raster')) { -%>
|
||||
|
||||
@@ -94,15 +106,20 @@ public class <%- camelize(type) %>LayerTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("SourceLayer");
|
||||
assertNotNull(layer);
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Get initial
|
||||
assertEquals(layer.getSourceLayer(), "composite");
|
||||
// Get initial
|
||||
assertEquals(layer.getSourceLayer(), "composite");
|
||||
|
||||
// Set
|
||||
final String sourceLayer = "test";
|
||||
layer.setSourceLayer(sourceLayer);
|
||||
assertEquals(layer.getSourceLayer(), sourceLayer);
|
||||
// Set
|
||||
final String sourceLayer = "test";
|
||||
layer.setSourceLayer(sourceLayer);
|
||||
assertEquals(layer.getSourceLayer(), sourceLayer);
|
||||
}
|
||||
});
|
||||
}
|
||||
<% } -%>
|
||||
<% for (const property of properties) { -%>
|
||||
@@ -113,12 +130,17 @@ public class <%- camelize(type) %>LayerTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("<%- property.name %>TransitionOptions");
|
||||
assertNotNull(layer);
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
TransitionOptions options = new TransitionOptions(300, 100);
|
||||
layer.set<%- camelize(property.name) %>Transition(options);
|
||||
assertEquals(layer.get<%- camelize(property.name) %>Transition(), options);
|
||||
// Set and Get
|
||||
TransitionOptions options = new TransitionOptions(300, 100);
|
||||
layer.set<%- camelize(property.name) %>Transition(options);
|
||||
assertEquals(layer.get<%- camelize(property.name) %>Transition(), options);
|
||||
}
|
||||
});
|
||||
}
|
||||
<% } -%>
|
||||
|
||||
@@ -127,11 +149,16 @@ public class <%- camelize(type) %>LayerTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("<%- property.name %>");
|
||||
assertNotNull(layer);
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(<%- camelizeWithLeadingLowercase(property.name) %>(<%- defaultValueJava(property) %>));
|
||||
assertEquals((<%- propertyType(property) %>) layer.get<%- camelize(property.name) %>().getValue(), (<%- propertyType(property) %>) <%- defaultValueJava(property) %>);
|
||||
// Set and Get
|
||||
layer.setProperties(<%- camelizeWithLeadingLowercase(property.name) %>(<%- defaultValueJava(property) %>));
|
||||
assertEquals((<%- propertyType(property) %>) layer.get<%- camelize(property.name) %>().getValue(), (<%- propertyType(property) %>) <%- defaultValueJava(property) %>);
|
||||
}
|
||||
});
|
||||
}
|
||||
<% if (supportsZoomFunction(property)) { -%>
|
||||
|
||||
@@ -140,37 +167,42 @@ public class <%- camelize(type) %>LayerTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("<%- property.name %>");
|
||||
assertNotNull(layer);
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set
|
||||
layer.setProperties(
|
||||
<%- camelizeWithLeadingLowercase(property.name) %>(
|
||||
zoom(
|
||||
// Set
|
||||
layer.setProperties(
|
||||
<%- camelizeWithLeadingLowercase(property.name) %>(
|
||||
zoom(
|
||||
<% if (property.function == 'piecewise-constant') { -%>
|
||||
interval(
|
||||
stop(2, <%- camelizeWithLeadingLowercase(property.name) %>(<%- defaultValueJava(property) %>))
|
||||
interval(
|
||||
stop(2, <%- camelizeWithLeadingLowercase(property.name) %>(<%- defaultValueJava(property) %>))
|
||||
)
|
||||
<% } else { -%>
|
||||
exponential(
|
||||
stop(2, <%- camelizeWithLeadingLowercase(property.name) %>(<%- defaultValueJava(property) %>))
|
||||
).withBase(0.5f)
|
||||
<% } -%>
|
||||
)
|
||||
)
|
||||
<% } else { -%>
|
||||
exponential(
|
||||
stop(2, <%- camelizeWithLeadingLowercase(property.name) %>(<%- defaultValueJava(property) %>))
|
||||
).withBase(0.5f)
|
||||
<% } -%>
|
||||
)
|
||||
)
|
||||
);
|
||||
);
|
||||
|
||||
// Verify
|
||||
assertNotNull(layer.get<%- camelize(property.name) %>());
|
||||
assertNotNull(layer.get<%- camelize(property.name) %>().getFunction());
|
||||
assertEquals(CameraFunction.class, layer.get<%- camelize(property.name) %>().getFunction().getClass());
|
||||
// Verify
|
||||
assertNotNull(layer.get<%- camelize(property.name) %>());
|
||||
assertNotNull(layer.get<%- camelize(property.name) %>().getFunction());
|
||||
assertEquals(CameraFunction.class, layer.get<%- camelize(property.name) %>().getFunction().getClass());
|
||||
<% if (property.function == 'piecewise-constant') { -%>
|
||||
assertEquals(IntervalStops.class, layer.get<%- camelize(property.name) %>().getFunction().getStops().getClass());
|
||||
assertEquals(1, ((IntervalStops) layer.get<%- camelize(property.name) %>().getFunction().getStops()).size());
|
||||
assertEquals(IntervalStops.class, layer.get<%- camelize(property.name) %>().getFunction().getStops().getClass());
|
||||
assertEquals(1, ((IntervalStops) layer.get<%- camelize(property.name) %>().getFunction().getStops()).size());
|
||||
<% } else { -%>
|
||||
assertEquals(ExponentialStops.class, layer.get<%- camelize(property.name) %>().getFunction().getStops().getClass());
|
||||
assertEquals(0.5f, ((ExponentialStops) layer.get<%- camelize(property.name) %>().getFunction().getStops()).getBase(), 0.001);
|
||||
assertEquals(1, ((ExponentialStops) layer.get<%- camelize(property.name) %>().getFunction().getStops()).size());
|
||||
assertEquals(ExponentialStops.class, layer.get<%- camelize(property.name) %>().getFunction().getStops().getClass());
|
||||
assertEquals(0.5f, ((ExponentialStops) layer.get<%- camelize(property.name) %>().getFunction().getStops()).getBase(), 0.001);
|
||||
assertEquals(1, ((ExponentialStops) layer.get<%- camelize(property.name) %>().getFunction().getStops()).size());
|
||||
<% } -%>
|
||||
}
|
||||
});
|
||||
}
|
||||
<% } -%>
|
||||
<% if (supportsPropertyFunction(property)) { -%>
|
||||
@@ -180,19 +212,24 @@ public class <%- camelize(type) %>LayerTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("<%- property.name %>");
|
||||
assertNotNull(layer);
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set
|
||||
layer.setProperties(
|
||||
<%- camelizeWithLeadingLowercase(property.name) %>(property("FeaturePropertyA", Stops.<<%- propertyType(property) %>>identity()))
|
||||
);
|
||||
// Set
|
||||
layer.setProperties(
|
||||
<%- camelizeWithLeadingLowercase(property.name) %>(property("FeaturePropertyA", Stops.<<%- propertyType(property) %>>identity()))
|
||||
);
|
||||
|
||||
// Verify
|
||||
assertNotNull(layer.get<%- camelize(property.name) %>());
|
||||
assertNotNull(layer.get<%- camelize(property.name) %>().getFunction());
|
||||
assertEquals(SourceFunction.class, layer.get<%- camelize(property.name) %>().getFunction().getClass());
|
||||
assertEquals("FeaturePropertyA", ((SourceFunction) layer.get<%- camelize(property.name) %>().getFunction()).getProperty());
|
||||
assertEquals(IdentityStops.class, layer.get<%- camelize(property.name) %>().getFunction().getStops().getClass());
|
||||
// Verify
|
||||
assertNotNull(layer.get<%- camelize(property.name) %>());
|
||||
assertNotNull(layer.get<%- camelize(property.name) %>().getFunction());
|
||||
assertEquals(SourceFunction.class, layer.get<%- camelize(property.name) %>().getFunction().getClass());
|
||||
assertEquals("FeaturePropertyA", ((SourceFunction) layer.get<%- camelize(property.name) %>().getFunction()).getProperty());
|
||||
assertEquals(IdentityStops.class, layer.get<%- camelize(property.name) %>().getFunction().getStops().getClass());
|
||||
}
|
||||
});
|
||||
}
|
||||
<% if (property.function == 'piecewise-constant') { -%>
|
||||
|
||||
@@ -201,30 +238,35 @@ public class <%- camelize(type) %>LayerTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("<%- property.name %>");
|
||||
assertNotNull(layer);
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set
|
||||
layer.setProperties(
|
||||
<%- camelizeWithLeadingLowercase(property.name) %>(
|
||||
property(
|
||||
"FeaturePropertyA",
|
||||
interval(
|
||||
// Set
|
||||
layer.setProperties(
|
||||
<%- camelizeWithLeadingLowercase(property.name) %>(
|
||||
property(
|
||||
"FeaturePropertyA",
|
||||
interval(
|
||||
<% if (property.type == 'color') { -%>
|
||||
stop(Color.RED, <%- camelizeWithLeadingLowercase(property.name) %>(Color.RED))
|
||||
stop(Color.RED, <%- camelizeWithLeadingLowercase(property.name) %>(Color.RED))
|
||||
<% } else {-%>
|
||||
stop(1, <%- camelizeWithLeadingLowercase(property.name) %>(<%- defaultValueJava(property) %>))
|
||||
)
|
||||
stop(1, <%- camelizeWithLeadingLowercase(property.name) %>(<%- defaultValueJava(property) %>))
|
||||
)
|
||||
<% } -%>
|
||||
)
|
||||
)
|
||||
);
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
// Verify
|
||||
assertNotNull(layer.get<%- camelize(property.name) %>());
|
||||
assertNotNull(layer.get<%- camelize(property.name) %>().getFunction());
|
||||
assertEquals(SourceFunction.class, layer.get<%- camelize(property.name) %>().getFunction().getClass());
|
||||
assertEquals("FeaturePropertyA", ((SourceFunction) layer.get<%- camelize(property.name) %>().getFunction()).getProperty());
|
||||
assertEquals(IntervalStops.class, layer.get<%- camelize(property.name) %>().getFunction().getStops().getClass());
|
||||
// Verify
|
||||
assertNotNull(layer.get<%- camelize(property.name) %>());
|
||||
assertNotNull(layer.get<%- camelize(property.name) %>().getFunction());
|
||||
assertEquals(SourceFunction.class, layer.get<%- camelize(property.name) %>().getFunction().getClass());
|
||||
assertEquals("FeaturePropertyA", ((SourceFunction) layer.get<%- camelize(property.name) %>().getFunction()).getProperty());
|
||||
assertEquals(IntervalStops.class, layer.get<%- camelize(property.name) %>().getFunction().getStops().getClass());
|
||||
}
|
||||
});
|
||||
}
|
||||
<% } else if (property.type === 'array') { -%>
|
||||
|
||||
@@ -233,30 +275,35 @@ public class <%- camelize(type) %>LayerTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("<%- property.name %>");
|
||||
assertNotNull(layer);
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set
|
||||
layer.setProperties(
|
||||
<%- camelizeWithLeadingLowercase(property.name) %>(
|
||||
property(
|
||||
"FeaturePropertyA",
|
||||
interval(
|
||||
// Set
|
||||
layer.setProperties(
|
||||
<%- camelizeWithLeadingLowercase(property.name) %>(
|
||||
property(
|
||||
"FeaturePropertyA",
|
||||
interval(
|
||||
<% if (property.type == 'color') { -%>
|
||||
stop(Color.RED, <%- camelizeWithLeadingLowercase(property.name) %>(Color.RED))
|
||||
stop(Color.RED, <%- camelizeWithLeadingLowercase(property.name) %>(Color.RED))
|
||||
<% } else {-%>
|
||||
stop(1, <%- camelizeWithLeadingLowercase(property.name) %>(<%- defaultValueJava(property) %>))
|
||||
stop(1, <%- camelizeWithLeadingLowercase(property.name) %>(<%- defaultValueJava(property) %>))
|
||||
<% } -%>
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
);
|
||||
|
||||
// Verify
|
||||
assertNotNull(layer.get<%- camelize(property.name) %>());
|
||||
assertNotNull(layer.get<%- camelize(property.name) %>().getFunction());
|
||||
assertEquals(SourceFunction.class, layer.get<%- camelize(property.name) %>().getFunction().getClass());
|
||||
assertEquals("FeaturePropertyA", ((SourceFunction) layer.get<%- camelize(property.name) %>().getFunction()).getProperty());
|
||||
assertEquals(IntervalStops.class, layer.get<%- camelize(property.name) %>().getFunction().getStops().getClass());
|
||||
// Verify
|
||||
assertNotNull(layer.get<%- camelize(property.name) %>());
|
||||
assertNotNull(layer.get<%- camelize(property.name) %>().getFunction());
|
||||
assertEquals(SourceFunction.class, layer.get<%- camelize(property.name) %>().getFunction().getClass());
|
||||
assertEquals("FeaturePropertyA", ((SourceFunction) layer.get<%- camelize(property.name) %>().getFunction()).getProperty());
|
||||
assertEquals(IntervalStops.class, layer.get<%- camelize(property.name) %>().getFunction().getStops().getClass());
|
||||
}
|
||||
});
|
||||
}
|
||||
<% } else { -%>
|
||||
|
||||
@@ -265,30 +312,35 @@ public class <%- camelize(type) %>LayerTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("<%- property.name %>");
|
||||
assertNotNull(layer);
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set
|
||||
layer.setProperties(
|
||||
<%- camelizeWithLeadingLowercase(property.name) %>(
|
||||
property(
|
||||
"FeaturePropertyA",
|
||||
exponential(
|
||||
// Set
|
||||
layer.setProperties(
|
||||
<%- camelizeWithLeadingLowercase(property.name) %>(
|
||||
property(
|
||||
"FeaturePropertyA",
|
||||
exponential(
|
||||
<% if (property.type == 'color') { -%>
|
||||
stop(Color.RED, <%- camelizeWithLeadingLowercase(property.name) %>(Color.RED))
|
||||
stop(Color.RED, <%- camelizeWithLeadingLowercase(property.name) %>(Color.RED))
|
||||
<% } else {-%>
|
||||
stop(<%- defaultValueJava(property) %>, <%- camelizeWithLeadingLowercase(property.name) %>(<%- defaultValueJava(property) %>))
|
||||
stop(<%- defaultValueJava(property) %>, <%- camelizeWithLeadingLowercase(property.name) %>(<%- defaultValueJava(property) %>))
|
||||
<% } -%>
|
||||
).withBase(0.5f)
|
||||
)
|
||||
)
|
||||
);
|
||||
).withBase(0.5f)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
// Verify
|
||||
assertNotNull(layer.get<%- camelize(property.name) %>());
|
||||
assertNotNull(layer.get<%- camelize(property.name) %>().getFunction());
|
||||
assertEquals(SourceFunction.class, layer.get<%- camelize(property.name) %>().getFunction().getClass());
|
||||
assertEquals("FeaturePropertyA", ((SourceFunction) layer.get<%- camelize(property.name) %>().getFunction()).getProperty());
|
||||
assertEquals(ExponentialStops.class, layer.get<%- camelize(property.name) %>().getFunction().getStops().getClass());
|
||||
// Verify
|
||||
assertNotNull(layer.get<%- camelize(property.name) %>());
|
||||
assertNotNull(layer.get<%- camelize(property.name) %>().getFunction());
|
||||
assertEquals(SourceFunction.class, layer.get<%- camelize(property.name) %>().getFunction().getClass());
|
||||
assertEquals("FeaturePropertyA", ((SourceFunction) layer.get<%- camelize(property.name) %>().getFunction()).getProperty());
|
||||
assertEquals(ExponentialStops.class, layer.get<%- camelize(property.name) %>().getFunction().getStops().getClass());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -296,39 +348,45 @@ public class <%- camelize(type) %>LayerTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("<%- property.name %>");
|
||||
assertNotNull(layer);
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set
|
||||
layer.setProperties(
|
||||
<%- camelizeWithLeadingLowercase(property.name) %>(
|
||||
property(
|
||||
"FeaturePropertyA",
|
||||
categorical(
|
||||
// Set
|
||||
layer.setProperties(
|
||||
<%- camelizeWithLeadingLowercase(property.name) %>(
|
||||
property(
|
||||
"FeaturePropertyA",
|
||||
categorical(
|
||||
<% if (property.type == 'color') { -%>
|
||||
stop("valueA", <%- camelizeWithLeadingLowercase(property.name) %>(Color.RED))
|
||||
)
|
||||
).withDefaultValue(<%- camelizeWithLeadingLowercase(property.name) %>(Color.GREEN))
|
||||
stop("valueA", <%- camelizeWithLeadingLowercase(property.name) %>(Color.RED))
|
||||
)
|
||||
).withDefaultValue(<%- camelizeWithLeadingLowercase(property.name) %>(Color.GREEN))
|
||||
<% } else {-%>
|
||||
stop(1.0f, <%- camelizeWithLeadingLowercase(property.name) %>(<%- defaultValueJava(property) %>))
|
||||
stop(1.0f, <%- camelizeWithLeadingLowercase(property.name) %>(<%- defaultValueJava(property) %>))
|
||||
)
|
||||
).withDefaultValue(<%- camelizeWithLeadingLowercase(property.name) %>(<%- defaultValueJava(property) %>))
|
||||
<% } -%>
|
||||
)
|
||||
).withDefaultValue(<%- camelizeWithLeadingLowercase(property.name) %>(<%- defaultValueJava(property) %>))
|
||||
<% } -%>
|
||||
)
|
||||
);
|
||||
);
|
||||
|
||||
// Verify
|
||||
assertNotNull(layer.get<%- camelize(property.name) %>());
|
||||
assertNotNull(layer.get<%- camelize(property.name) %>().getFunction());
|
||||
assertEquals(SourceFunction.class, layer.get<%- camelize(property.name) %>().getFunction().getClass());
|
||||
assertEquals("FeaturePropertyA", ((SourceFunction) layer.get<%- camelize(property.name) %>().getFunction()).getProperty());
|
||||
assertEquals(CategoricalStops.class, layer.get<%- camelize(property.name) %>().getFunction().getStops().getClass());
|
||||
assertNotNull(((SourceFunction) layer.get<%- camelize(property.name) %>().getFunction()).getDefaultValue());
|
||||
assertNotNull(((SourceFunction) layer.get<%- camelize(property.name) %>().getFunction()).getDefaultValue().getValue());
|
||||
// Verify
|
||||
assertNotNull(layer.get<%- camelize(property.name) %>());
|
||||
assertNotNull(layer.get<%- camelize(property.name) %>().getFunction());
|
||||
assertEquals(SourceFunction.class, layer.get<%- camelize(property.name) %>().getFunction().getClass());
|
||||
assertEquals("FeaturePropertyA", ((SourceFunction) layer.get<%- camelize(property.name) %>().getFunction()).getProperty());
|
||||
assertEquals(CategoricalStops.class, layer.get<%- camelize(property.name) %>().getFunction().getStops().getClass());
|
||||
assertNotNull(((SourceFunction) layer.get<%- camelize(property.name) %>().getFunction()).getDefaultValue());
|
||||
assertNotNull(((SourceFunction) layer.get<%- camelize(property.name) %>().getFunction()).getDefaultValue().getValue());
|
||||
<% if (property.type === 'color') { -%>
|
||||
assertEquals(Color.GREEN, (int) ((SourceFunction) layer.get<%- camelize(property.name) %>().getFunction()).getDefaultValue().getColorInt());
|
||||
assertEquals(Color.GREEN, (int) ((SourceFunction) layer.get<%- camelize(property.name) %>().getFunction()).getDefaultValue().getColorInt());
|
||||
<% } else { -%>
|
||||
assertEquals(<%- defaultValueJava(property) %>, ((SourceFunction) layer.get<%- camelize(property.name) %>().getFunction()).getDefaultValue().getValue());
|
||||
assertEquals(<%- defaultValueJava(property) %>, ((SourceFunction) layer.get<%- camelize(property.name) %>().getFunction()).getDefaultValue().getValue());
|
||||
<% } -%>
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
<% if (property.type !== 'color') { -%>
|
||||
|
||||
@@ -337,38 +395,43 @@ public class <%- camelize(type) %>LayerTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("<%- property.name %>");
|
||||
assertNotNull(layer);
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set
|
||||
layer.setProperties(
|
||||
<%- camelizeWithLeadingLowercase(property.name) %>(
|
||||
composite(
|
||||
"FeaturePropertyA",
|
||||
exponential(
|
||||
stop(0, 0.3f, <%- camelizeWithLeadingLowercase(property.name) %>(0.9f))
|
||||
).withBase(0.5f)
|
||||
// Set
|
||||
layer.setProperties(
|
||||
<%- camelizeWithLeadingLowercase(property.name) %>(
|
||||
composite(
|
||||
"FeaturePropertyA",
|
||||
exponential(
|
||||
stop(0, 0.3f, <%- camelizeWithLeadingLowercase(property.name) %>(0.9f))
|
||||
).withBase(0.5f)
|
||||
<% if (property.type == 'number') { -%>
|
||||
).withDefaultValue(<%- camelizeWithLeadingLowercase(property.name) %>(<%- defaultValueJava(property) %>))
|
||||
).withDefaultValue(<%- camelizeWithLeadingLowercase(property.name) %>(<%- defaultValueJava(property) %>))
|
||||
<% } else { -%>
|
||||
)
|
||||
)
|
||||
<% } -%>
|
||||
)
|
||||
);
|
||||
)
|
||||
);
|
||||
|
||||
// Verify
|
||||
assertNotNull(layer.get<%- camelize(property.name) %>());
|
||||
assertNotNull(layer.get<%- camelize(property.name) %>().getFunction());
|
||||
assertEquals(CompositeFunction.class, layer.get<%- camelize(property.name) %>().getFunction().getClass());
|
||||
assertEquals("FeaturePropertyA", ((CompositeFunction) layer.get<%- camelize(property.name) %>().getFunction()).getProperty());
|
||||
assertEquals(ExponentialStops.class, layer.get<%- camelize(property.name) %>().getFunction().getStops().getClass());
|
||||
assertEquals(1, ((ExponentialStops) layer.get<%- camelize(property.name) %>().getFunction().getStops()).size());
|
||||
// Verify
|
||||
assertNotNull(layer.get<%- camelize(property.name) %>());
|
||||
assertNotNull(layer.get<%- camelize(property.name) %>().getFunction());
|
||||
assertEquals(CompositeFunction.class, layer.get<%- camelize(property.name) %>().getFunction().getClass());
|
||||
assertEquals("FeaturePropertyA", ((CompositeFunction) layer.get<%- camelize(property.name) %>().getFunction()).getProperty());
|
||||
assertEquals(ExponentialStops.class, layer.get<%- camelize(property.name) %>().getFunction().getStops().getClass());
|
||||
assertEquals(1, ((ExponentialStops) layer.get<%- camelize(property.name) %>().getFunction().getStops()).size());
|
||||
|
||||
ExponentialStops<Stop.CompositeValue<Float, <%- propertyType(property) %>>, <%- propertyType(property) %>> stops =
|
||||
(ExponentialStops<Stop.CompositeValue<Float, <%- propertyType(property) %>>, <%- propertyType(property) %>>) layer.get<%- camelize(property.name) %>().getFunction().getStops();
|
||||
Stop<Stop.CompositeValue<Float, <%- propertyType(property) %>>, <%- propertyType(property) %>> stop = stops.iterator().next();
|
||||
assertEquals(0f, stop.in.zoom, 0.001);
|
||||
assertEquals(0.3f, stop.in.value, 0.001f);
|
||||
assertEquals(0.9f, stop.out, 0.001f);
|
||||
ExponentialStops<Stop.CompositeValue<Float, <%- propertyType(property) %>>, <%- propertyType(property) %>> stops =
|
||||
(ExponentialStops<Stop.CompositeValue<Float, <%- propertyType(property) %>>, <%- propertyType(property) %>>) layer.get<%- camelize(property.name) %>().getFunction().getStops();
|
||||
Stop<Stop.CompositeValue<Float, <%- propertyType(property) %>>, <%- propertyType(property) %>> stop = stops.iterator().next();
|
||||
assertEquals(0f, stop.in.zoom, 0.001);
|
||||
assertEquals(0.3f, stop.in.value, 0.001f);
|
||||
assertEquals(0.9f, stop.out, 0.001f);
|
||||
}
|
||||
});
|
||||
}
|
||||
<% } -%>
|
||||
<% } -%>
|
||||
@@ -380,11 +443,16 @@ public class <%- camelize(type) %>LayerTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("<%- property.name %>");
|
||||
assertNotNull(layer);
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(<%- camelizeWithLeadingLowercase(property.name) %>(Color.RED));
|
||||
assertEquals(layer.get<%- camelize(property.name) %>AsInt(), Color.RED);
|
||||
// Set and Get
|
||||
layer.setProperties(<%- camelizeWithLeadingLowercase(property.name) %>(Color.RED));
|
||||
assertEquals(layer.get<%- camelize(property.name) %>AsInt(), Color.RED);
|
||||
}
|
||||
});
|
||||
}
|
||||
<% } -%>
|
||||
<% } -%>
|
||||
|
||||
@@ -9,6 +9,7 @@ import android.support.test.espresso.ViewAction;
|
||||
import android.support.test.runner.AndroidJUnit4;
|
||||
import android.view.View;
|
||||
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
import com.mapbox.mapboxsdk.style.light.Light;
|
||||
import com.mapbox.mapboxsdk.style.functions.Function;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.IdentityStops;
|
||||
@@ -16,6 +17,7 @@ import com.mapbox.mapboxsdk.style.layers.FillExtrusionLayer;
|
||||
import com.mapbox.mapboxsdk.style.layers.TransitionOptions;
|
||||
import com.mapbox.mapboxsdk.style.light.Position;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
import com.mapbox.mapboxsdk.testapp.action.MapboxMapAction;
|
||||
import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest;
|
||||
import com.mapbox.mapboxsdk.testapp.activity.style.FillExtrusionStyleTestActivity;
|
||||
|
||||
@@ -35,6 +37,7 @@ import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillExtrusionCol
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillExtrusionHeight;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillExtrusionOpacity;
|
||||
|
||||
import static com.mapbox.mapboxsdk.testapp.action.MapboxMapAction.invoke;
|
||||
import static junit.framework.Assert.assertEquals;
|
||||
import static junit.framework.Assert.assertNotNull;
|
||||
|
||||
@@ -48,14 +51,18 @@ public class LightTest extends BaseActivityTest {
|
||||
@Test
|
||||
public void test<%- camelize(property.name) %>Transition() {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
setupLight();
|
||||
Timber.i("<%- property.name %>TransitionOptions");
|
||||
assertNotNull(light);
|
||||
|
||||
// Set and Get
|
||||
TransitionOptions options = new TransitionOptions(300, 100);
|
||||
light.set<%- camelize(property.name) %>Transition(options);
|
||||
assertEquals("Transition options should match", options, light.get<%- camelize(property.name) %>Transition());
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(light);
|
||||
// Set and Get
|
||||
TransitionOptions options = new TransitionOptions(300, 100);
|
||||
light.set<%- camelize(property.name) %>Transition(options);
|
||||
assertEquals("Transition options should match", options, light.get<%- camelize(property.name) %>Transition());
|
||||
}
|
||||
});
|
||||
}
|
||||
<% } -%>
|
||||
<% if (property.name == "position") { -%>
|
||||
@@ -63,35 +70,44 @@ public class LightTest extends BaseActivityTest {
|
||||
@Test
|
||||
public void test<%- camelize(property.name) %>() {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
setupLight();
|
||||
Timber.i("<%- property.name %>");
|
||||
assertNotNull(light);
|
||||
|
||||
// Set and Get
|
||||
Position position = new Position(1,2,3);
|
||||
light.set<%- camelize(property.name) %>(position);
|
||||
assertEquals("Position should match", position, light.get<%- camelize(property.name) %>());
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(light);
|
||||
// Set and Get
|
||||
Position position = new Position(1, 2, 3);
|
||||
light.set<%- camelize(property.name) %>(position);
|
||||
assertEquals("Position should match", position, light.get<%- camelize(property.name) %>());
|
||||
}
|
||||
});
|
||||
}
|
||||
<% } else { -%>
|
||||
|
||||
@Test
|
||||
public void test<%- camelize(property.name) %>() {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
setupLight();
|
||||
Timber.i("<%- property.name %>");
|
||||
assertNotNull(light);
|
||||
// Set and Get
|
||||
light.set<%- camelize(property.name) %>(<%- defaultValueJava(property) %>);
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(light);
|
||||
// Set and Get
|
||||
light.set<%- camelize(property.name) %>(<%- defaultValueJava(property) %>);
|
||||
<% if (property.name == 'color') { -%>
|
||||
assertEquals("<%- camelize(property.name) %> should match", <%- defaultValueJava(property) %>.replaceAll("\\s+",""), light.get<%- camelize(property.name) %>());
|
||||
assertEquals("<%- camelize(property.name) %> should match", <%- defaultValueJava(property) %>.replaceAll("\\s+", ""), light.get<%- camelize(property.name) %>());
|
||||
<% } else { -%>
|
||||
assertEquals("<%- camelize(property.name) %> should match", <%- defaultValueJava(property) %>, light.get<%- camelize(property.name) %>());
|
||||
assertEquals("<%- camelize(property.name) %> should match", <%- defaultValueJava(property) %>, light.get<%- camelize(property.name) %>());
|
||||
<% } -%>
|
||||
}
|
||||
});
|
||||
}
|
||||
<% } -%>
|
||||
<% } -%>
|
||||
|
||||
private void setupLayer() {
|
||||
private void setupLight() {
|
||||
onView(withId(R.id.mapView)).perform(new ViewAction() {
|
||||
@Override
|
||||
public Matcher<View> getConstraints() {
|
||||
|
||||
@@ -167,11 +167,11 @@ global.defaultValueJava = function(property) {
|
||||
case 'string':
|
||||
return '[' + property['default'] + "]";
|
||||
case 'number':
|
||||
var result ='new Float[]{';
|
||||
var result ='new Float[] {';
|
||||
for (var i = 0; i < property.length; i++) {
|
||||
result += "0f";
|
||||
if (i +1 != property.length) {
|
||||
result += ",";
|
||||
result += ", ";
|
||||
}
|
||||
}
|
||||
return result + "}";
|
||||
|
||||
Reference in New Issue
Block a user