Adds checkstyle to CI (#7442)
* adds checkstyle to CI * fixed gradlew path * resolved testapp checkstyle violations * added back mapboxMap variable for test * checkstyle annotations * checkstyle SDK round 1 * maps package checkstyle * rest of SDK checkstyle * checkstyle gesture library * checkstyle test * finished rest of test checkstyle * resolved all checkstyle errors * fixed class name * removed old test file * fixed camera postion test * fixed native crash
This commit is contained in:
@@ -7,27 +7,27 @@ import com.mapbox.mapboxsdk.geometry.LatLng;
|
||||
*/
|
||||
public class MapViewUtils {
|
||||
|
||||
public static void setDirection(MapboxMap mapboxMap, float direction) {
|
||||
mapboxMap.getTransform().setBearing(direction);
|
||||
}
|
||||
public static void setDirection(MapboxMap mapboxMap, float direction) {
|
||||
mapboxMap.getTransform().setBearing(direction);
|
||||
}
|
||||
|
||||
public static float getDirection(MapboxMap mapboxMap) {
|
||||
return (float) mapboxMap.getTransform().getBearing();
|
||||
}
|
||||
public static float getDirection(MapboxMap mapboxMap) {
|
||||
return (float) mapboxMap.getTransform().getBearing();
|
||||
}
|
||||
|
||||
public static void setTilt(MapboxMap mapboxMap, float tilt) {
|
||||
mapboxMap.getTransform().setTilt((double) tilt);
|
||||
}
|
||||
public static void setTilt(MapboxMap mapboxMap, float tilt) {
|
||||
mapboxMap.getTransform().setTilt((double) tilt);
|
||||
}
|
||||
|
||||
public static float getTilt(MapboxMap mapboxMap) {
|
||||
return (float) mapboxMap.getTransform().getTilt();
|
||||
}
|
||||
public static float getTilt(MapboxMap mapboxMap) {
|
||||
return (float) mapboxMap.getTransform().getTilt();
|
||||
}
|
||||
|
||||
public static void setLatLng(MapboxMap mapboxMap, LatLng latLng) {
|
||||
mapboxMap.getTransform().setCenterCoordinate(latLng);
|
||||
}
|
||||
public static void setLatLng(MapboxMap mapboxMap, LatLng latLng) {
|
||||
mapboxMap.getTransform().setCenterCoordinate(latLng);
|
||||
}
|
||||
|
||||
public static LatLng getLatLng(MapboxMap mapboxMap) {
|
||||
return mapboxMap.getTransform().getCenterCoordinate();
|
||||
}
|
||||
public static LatLng getLatLng(MapboxMap mapboxMap) {
|
||||
return mapboxMap.getTransform().getCenterCoordinate();
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -4,6 +4,7 @@ import android.app.Activity;
|
||||
import android.support.test.espresso.Espresso;
|
||||
import android.support.test.espresso.IdlingResourceTimeoutException;
|
||||
import android.support.test.rule.ActivityTestRule;
|
||||
|
||||
import timber.log.Timber;
|
||||
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
@@ -22,49 +23,50 @@ import static android.support.test.espresso.matcher.ViewMatchers.withId;
|
||||
|
||||
public abstract class BaseActivityTest {
|
||||
|
||||
@Rule
|
||||
public ActivityTestRule<Activity> rule = new ActivityTestRule<>(getActivityClass());
|
||||
protected MapboxMap mapboxMap;
|
||||
protected OnMapReadyIdlingResource idlingResource;
|
||||
@Rule
|
||||
public ActivityTestRule<Activity> rule = new ActivityTestRule<>(getActivityClass());
|
||||
protected MapboxMap mapboxMap;
|
||||
protected OnMapReadyIdlingResource idlingResource;
|
||||
|
||||
@Before
|
||||
public void beforeTest() {
|
||||
try {
|
||||
Timber.e("@Before test: register idle resource");
|
||||
idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
|
||||
Espresso.registerIdlingResources(idlingResource);
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
mapboxMap = idlingResource.getMapboxMap();
|
||||
} catch (IdlingResourceTimeoutException e) {
|
||||
Timber.e("Idling resource timed out. Couldn't not validate if map is ready.");
|
||||
throw new RuntimeException("Could not start test for " + getActivityClass().getSimpleName() + ".\n" +
|
||||
"The ViewHierarchy doesn't contain a view with resource id = R.id.mapView or \n" +
|
||||
"the Activity doesn't contain an instance variable with a name equal to mapboxMap.\n" +
|
||||
"You can resolve this issue be implementing the requirements above or\n add " + getActivityClass().getSimpleName() + " to the excludeActivities array in `generate-test-code.js`.\n");
|
||||
}
|
||||
@Before
|
||||
public void beforeTest() {
|
||||
try {
|
||||
Timber.e("@Before test: register idle resource");
|
||||
idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
|
||||
Espresso.registerIdlingResources(idlingResource);
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
mapboxMap = idlingResource.getMapboxMap();
|
||||
} catch (IdlingResourceTimeoutException idlingResourceTimeoutException) {
|
||||
Timber.e("Idling resource timed out. Couldn't not validate if map is ready.");
|
||||
throw new RuntimeException("Could not start test for " + getActivityClass().getSimpleName() + ".\n"
|
||||
+ "The ViewHierarchy doesn't contain a view with resource id = R.id.mapView or \n"
|
||||
+ "the Activity doesn't contain an instance variable with a name equal to mapboxMap.\n"
|
||||
+ "You can resolve this issue be implementing the requirements above or\n add "
|
||||
+ getActivityClass().getSimpleName() + " to the excludeActivities array in `generate-test-code.js`.\n");
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract Class getActivityClass();
|
||||
protected abstract Class getActivityClass();
|
||||
|
||||
protected void checkViewIsDisplayed(int id) {
|
||||
onView(withId(id))
|
||||
.check(matches(isDisplayed()));
|
||||
}
|
||||
protected void checkViewIsDisplayed(int id) {
|
||||
onView(withId(id))
|
||||
.check(matches(isDisplayed()));
|
||||
}
|
||||
|
||||
protected void takeScreenshot(final String name) {
|
||||
final Activity activity = rule.getActivity();
|
||||
activity.runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
ScreenshotUtil.take(activity, name);
|
||||
}
|
||||
});
|
||||
}
|
||||
protected void takeScreenshot(final String name) {
|
||||
final Activity activity = rule.getActivity();
|
||||
activity.runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
ScreenshotUtil.take(activity, name);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@After
|
||||
public void afterTest() {
|
||||
Timber.e("@After test: unregister idle resource");
|
||||
Espresso.unregisterIdlingResources(idlingResource);
|
||||
}
|
||||
@After
|
||||
public void afterTest() {
|
||||
Timber.e("@After test: unregister idle resource");
|
||||
Espresso.unregisterIdlingResources(idlingResource);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -32,111 +32,111 @@ import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class MarkerTest {
|
||||
|
||||
@Rule
|
||||
public final ActivityTestRule<EspressoTestActivity> rule = new ActivityTestRule<>(EspressoTestActivity.class);
|
||||
@Rule
|
||||
public final ActivityTestRule<EspressoTestActivity> rule = new ActivityTestRule<>(EspressoTestActivity.class);
|
||||
|
||||
private OnMapReadyIdlingResource idlingResource;
|
||||
private Marker marker;
|
||||
private OnMapReadyIdlingResource idlingResource;
|
||||
private Marker marker;
|
||||
|
||||
@Before
|
||||
public void registerIdlingResource() {
|
||||
idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
|
||||
Espresso.registerIdlingResources(idlingResource);
|
||||
@Before
|
||||
public void registerIdlingResource() {
|
||||
idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
|
||||
Espresso.registerIdlingResources(idlingResource);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void addMarkerTest() {
|
||||
ViewUtils.checkViewIsDisplayed(R.id.mapView);
|
||||
MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
|
||||
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);
|
||||
|
||||
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());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void showInfoWindowTest() {
|
||||
ViewUtils.checkViewIsDisplayed(R.id.mapView);
|
||||
MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
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));
|
||||
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;
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void addMarkerTest() {
|
||||
ViewUtils.checkViewIsDisplayed(R.id.mapView);
|
||||
MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
|
||||
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);
|
||||
|
||||
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());
|
||||
@Override
|
||||
public Matcher<View> getConstraints() {
|
||||
return isDisplayed();
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void showInfoWindowTest(){
|
||||
ViewUtils.checkViewIsDisplayed(R.id.mapView);
|
||||
MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
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));
|
||||
onView(withText(TestConstants.TEXT_MARKER_TITLE)).check(matches(isDisplayed()));
|
||||
onView(withText(TestConstants.TEXT_MARKER_SNIPPET)).check(matches(isDisplayed()));
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return getClass().getSimpleName();
|
||||
}
|
||||
|
||||
private class AddMarkerAction implements ViewAction {
|
||||
@Override
|
||||
public void perform(UiController uiController, View view) {
|
||||
marker = mapboxMap.addMarker(options);
|
||||
}
|
||||
}
|
||||
|
||||
private MapboxMap mapboxMap;
|
||||
private MarkerOptions options;
|
||||
private class ShowInfoWindowAction implements ViewAction {
|
||||
|
||||
AddMarkerAction(MapboxMap map, MarkerOptions markerOptions) {
|
||||
mapboxMap = map;
|
||||
options = markerOptions;
|
||||
}
|
||||
private MapboxMap mapboxMap;
|
||||
|
||||
@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);
|
||||
}
|
||||
ShowInfoWindowAction(MapboxMap map) {
|
||||
mapboxMap = map;
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
}
|
||||
@Override
|
||||
public Matcher<View> getConstraints() {
|
||||
return isDisplayed();
|
||||
}
|
||||
|
||||
|
||||
@After
|
||||
public void unregisterIdlingResource() {
|
||||
Espresso.unregisterIdlingResources(idlingResource);
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return getClass().getSimpleName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void perform(UiController uiController, View view) {
|
||||
mapboxMap.selectMarker(marker);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@After
|
||||
public void unregisterIdlingResource() {
|
||||
Espresso.unregisterIdlingResources(idlingResource);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,114 +33,115 @@ import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class MarkerViewTest {
|
||||
|
||||
@Rule
|
||||
public final ActivityTestRule<EspressoTestActivity> rule = new ActivityTestRule<>(EspressoTestActivity.class);
|
||||
@Rule
|
||||
public final ActivityTestRule<EspressoTestActivity> rule = new ActivityTestRule<>(EspressoTestActivity.class);
|
||||
|
||||
private OnMapReadyIdlingResource idlingResource;
|
||||
private Marker marker;
|
||||
private OnMapReadyIdlingResource idlingResource;
|
||||
private Marker marker;
|
||||
|
||||
@Before
|
||||
public void registerIdlingResource() {
|
||||
idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
|
||||
Espresso.registerIdlingResources(idlingResource);
|
||||
@Before
|
||||
public void registerIdlingResource() {
|
||||
idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
|
||||
Espresso.registerIdlingResources(idlingResource);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void addMarkerViewTest() {
|
||||
ViewUtils.checkViewIsDisplayed(R.id.mapView);
|
||||
MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
|
||||
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());
|
||||
onView(withText(TestConstants.TEXT_MARKER_TEXT)).check(matches(isDisplayed()));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void showInfoWindowTest() {
|
||||
ViewUtils.checkViewIsDisplayed(R.id.mapView);
|
||||
MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
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));
|
||||
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;
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void addMarkerViewTest() {
|
||||
ViewUtils.checkViewIsDisplayed(R.id.mapView);
|
||||
MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
|
||||
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());
|
||||
onView(withText(TestConstants.TEXT_MARKER_TEXT)).check(matches(isDisplayed()));
|
||||
@Override
|
||||
public Matcher<View> getConstraints() {
|
||||
return isDisplayed();
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void showInfoWindowTest() {
|
||||
ViewUtils.checkViewIsDisplayed(R.id.mapView);
|
||||
MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
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));
|
||||
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()));
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return getClass().getSimpleName();
|
||||
}
|
||||
|
||||
private class AddTextMarkerViewAction implements ViewAction {
|
||||
@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 MapboxMap mapboxMap;
|
||||
private TextMarkerViewOptions options;
|
||||
private class ShowInfoWindowAction implements ViewAction {
|
||||
|
||||
AddTextMarkerViewAction(MapboxMap map, TextMarkerViewOptions markerOptions) {
|
||||
mapboxMap = map;
|
||||
options = markerOptions;
|
||||
}
|
||||
private MapboxMap mapboxMap;
|
||||
|
||||
@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);
|
||||
}
|
||||
ShowInfoWindowAction(MapboxMap map) {
|
||||
mapboxMap = map;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
@Override
|
||||
public Matcher<View> getConstraints() {
|
||||
return isDisplayed();
|
||||
}
|
||||
|
||||
@After
|
||||
public void unregisterIdlingResource() {
|
||||
Espresso.unregisterIdlingResources(idlingResource);
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return getClass().getSimpleName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void perform(UiController uiController, View view) {
|
||||
mapboxMap.selectMarker(marker);
|
||||
uiController.loopMainThreadForAtLeast(250);
|
||||
}
|
||||
}
|
||||
|
||||
@After
|
||||
public void unregisterIdlingResource() {
|
||||
Espresso.unregisterIdlingResources(idlingResource);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,75 +30,76 @@ import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class PolygonTest {
|
||||
|
||||
@Rule
|
||||
public final ActivityTestRule<EspressoTestActivity> rule = new ActivityTestRule<>(EspressoTestActivity.class);
|
||||
@Rule
|
||||
public final ActivityTestRule<EspressoTestActivity> rule = new ActivityTestRule<>(EspressoTestActivity.class);
|
||||
|
||||
private OnMapReadyIdlingResource idlingResource;
|
||||
private Polygon polygon;
|
||||
private OnMapReadyIdlingResource idlingResource;
|
||||
private Polygon polygon;
|
||||
|
||||
@Before
|
||||
public void registerIdlingResource() {
|
||||
idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
|
||||
Espresso.registerIdlingResources(idlingResource);
|
||||
@Before
|
||||
public void registerIdlingResource() {
|
||||
idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
|
||||
Espresso.registerIdlingResources(idlingResource);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
/** native crash **/
|
||||
public void addPolygonTest() {
|
||||
ViewUtils.checkViewIsDisplayed(R.id.mapView);
|
||||
final MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
|
||||
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());
|
||||
|
||||
final PolygonOptions options = new PolygonOptions();
|
||||
options.strokeColor(Color.BLUE);
|
||||
options.fillColor(Color.RED);
|
||||
options.add(latLngOne);
|
||||
options.add(latLngTwo);
|
||||
options.add(latLngThree);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore /** native crash **/
|
||||
public void addPolygonTest() {
|
||||
ViewUtils.checkViewIsDisplayed(R.id.mapView);
|
||||
final MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
|
||||
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());
|
||||
|
||||
final PolygonOptions options = new PolygonOptions();
|
||||
options.strokeColor(Color.BLUE);
|
||||
options.fillColor(Color.RED);
|
||||
options.add(latLngOne);
|
||||
options.add(latLngTwo);
|
||||
options.add(latLngThree);
|
||||
|
||||
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());
|
||||
@Override
|
||||
public Matcher<View> getConstraints() {
|
||||
return isDisplayed();
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return getClass().getSimpleName();
|
||||
}
|
||||
|
||||
@After
|
||||
public void unregisterIdlingResource() {
|
||||
Espresso.unregisterIdlingResources(idlingResource);
|
||||
@Override
|
||||
public void perform(UiController uiController, View view) {
|
||||
polygon = mapboxMap.addPolygon(options);
|
||||
}
|
||||
}
|
||||
|
||||
@After
|
||||
public void unregisterIdlingResource() {
|
||||
Espresso.unregisterIdlingResources(idlingResource);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,71 +30,71 @@ import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class PolylineTest {
|
||||
|
||||
@Rule
|
||||
public final ActivityTestRule<EspressoTestActivity> rule = new ActivityTestRule<>(EspressoTestActivity.class);
|
||||
@Rule
|
||||
public final ActivityTestRule<EspressoTestActivity> rule = new ActivityTestRule<>(EspressoTestActivity.class);
|
||||
|
||||
private OnMapReadyIdlingResource idlingResource;
|
||||
private Polyline polyline;
|
||||
private OnMapReadyIdlingResource idlingResource;
|
||||
private Polyline polyline;
|
||||
|
||||
@Before
|
||||
public void registerIdlingResource() {
|
||||
idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
|
||||
Espresso.registerIdlingResources(idlingResource);
|
||||
@Before
|
||||
public void registerIdlingResource() {
|
||||
idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
|
||||
Espresso.registerIdlingResources(idlingResource);
|
||||
}
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
public void addPolylineTest() {
|
||||
ViewUtils.checkViewIsDisplayed(R.id.mapView);
|
||||
final MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
|
||||
LatLng latLngOne = new LatLng();
|
||||
LatLng latLngTwo = new LatLng(1, 0);
|
||||
|
||||
assertEquals("Polygons should be empty", 0, mapboxMap.getPolygons().size());
|
||||
|
||||
final PolylineOptions options = new PolylineOptions();
|
||||
options.color(Color.BLUE);
|
||||
options.add(latLngOne);
|
||||
options.add(latLngTwo);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
public void addPolylineTest() {
|
||||
ViewUtils.checkViewIsDisplayed(R.id.mapView);
|
||||
final MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
|
||||
LatLng latLngOne = new LatLng();
|
||||
LatLng latLngTwo = new LatLng(1, 0);
|
||||
|
||||
assertEquals("Polygons should be empty", 0, mapboxMap.getPolygons().size());
|
||||
|
||||
final PolylineOptions options = new PolylineOptions();
|
||||
options.color(Color.BLUE);
|
||||
options.add(latLngOne);
|
||||
options.add(latLngTwo);
|
||||
|
||||
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());
|
||||
@Override
|
||||
public Matcher<View> getConstraints() {
|
||||
return isDisplayed();
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return getClass().getSimpleName();
|
||||
}
|
||||
|
||||
@After
|
||||
public void unregisterIdlingResource() {
|
||||
Espresso.unregisterIdlingResources(idlingResource);
|
||||
@Override
|
||||
public void perform(UiController uiController, View view) {
|
||||
polyline = mapboxMap.addPolyline(options);
|
||||
}
|
||||
}
|
||||
|
||||
@After
|
||||
public void unregisterIdlingResource() {
|
||||
Espresso.unregisterIdlingResources(idlingResource);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,6 @@ 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.constants.MapboxConstants;
|
||||
import com.mapbox.mapboxsdk.geometry.LatLng;
|
||||
import com.mapbox.mapboxsdk.geometry.LatLngBounds;
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
@@ -33,206 +32,222 @@ import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class CameraAnimateTest {
|
||||
|
||||
@Rule
|
||||
public final ActivityTestRule<EspressoTestActivity> rule = new ActivityTestRule<>(EspressoTestActivity.class);
|
||||
@Rule
|
||||
public final ActivityTestRule<EspressoTestActivity> rule = new ActivityTestRule<>(EspressoTestActivity.class);
|
||||
|
||||
private OnMapReadyIdlingResource idlingResource;
|
||||
private OnMapReadyIdlingResource idlingResource;
|
||||
|
||||
@Before
|
||||
public void registerIdlingResource() {
|
||||
idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
|
||||
Espresso.registerIdlingResources(idlingResource);
|
||||
@Before
|
||||
public void registerIdlingResource() {
|
||||
idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
|
||||
Espresso.registerIdlingResources(idlingResource);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAnimateToCameraPositionTarget() {
|
||||
ViewUtils.checkViewIsDisplayed(R.id.mapView);
|
||||
final MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
/*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);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAnimateToCameraPositionTargetZoom() {
|
||||
ViewUtils.checkViewIsDisplayed(R.id.mapView);
|
||||
final MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAnimateToCameraPosition() {
|
||||
ViewUtils.checkViewIsDisplayed(R.id.mapView);
|
||||
final MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAnimateToBounds() {
|
||||
ViewUtils.checkViewIsDisplayed(R.id.mapView);
|
||||
final MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAnimateToMoveBy() {
|
||||
ViewUtils.checkViewIsDisplayed(R.id.mapView);
|
||||
final MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAnimateToZoomIn() {
|
||||
ViewUtils.checkViewIsDisplayed(R.id.mapView);
|
||||
final MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
/*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);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAnimateToZoomOut() {
|
||||
ViewUtils.checkViewIsDisplayed(R.id.mapView);
|
||||
final MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
/*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);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAnimateToZoomBy() {
|
||||
ViewUtils.checkViewIsDisplayed(R.id.mapView);
|
||||
final MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
/*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);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAnimateToZoomTo() {
|
||||
ViewUtils.checkViewIsDisplayed(R.id.mapView);
|
||||
final MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
/*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);
|
||||
}
|
||||
|
||||
@After
|
||||
public void unregisterIdlingResource() {
|
||||
Espresso.unregisterIdlingResources(idlingResource);
|
||||
}
|
||||
|
||||
private class AnimateCameraAction implements ViewAction {
|
||||
|
||||
private MapboxMap mapboxMap;
|
||||
private CameraUpdate cameraUpdate;
|
||||
|
||||
AnimateCameraAction(MapboxMap map, CameraUpdate update) {
|
||||
mapboxMap = map;
|
||||
cameraUpdate = update;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAnimateToCameraPositionTarget() {
|
||||
ViewUtils.checkViewIsDisplayed(R.id.mapView);
|
||||
final MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
/*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);
|
||||
@Override
|
||||
public Matcher<View> getConstraints() {
|
||||
return isDisplayed();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAnimateToCameraPositionTargetZoom() {
|
||||
ViewUtils.checkViewIsDisplayed(R.id.mapView);
|
||||
final MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
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);
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return getClass().getSimpleName();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAnimateToCameraPosition() {
|
||||
ViewUtils.checkViewIsDisplayed(R.id.mapView);
|
||||
final MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAnimateToBounds() {
|
||||
ViewUtils.checkViewIsDisplayed(R.id.mapView);
|
||||
final MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAnimateToMoveBy() {
|
||||
ViewUtils.checkViewIsDisplayed(R.id.mapView);
|
||||
final MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAnimateToZoomIn() {
|
||||
ViewUtils.checkViewIsDisplayed(R.id.mapView);
|
||||
final MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
/*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);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAnimateToZoomOut() {
|
||||
ViewUtils.checkViewIsDisplayed(R.id.mapView);
|
||||
final MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
/*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);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAnimateToZoomBy() {
|
||||
ViewUtils.checkViewIsDisplayed(R.id.mapView);
|
||||
final MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
/*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);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAnimateToZoomTo() {
|
||||
ViewUtils.checkViewIsDisplayed(R.id.mapView);
|
||||
final MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
/*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);
|
||||
}
|
||||
|
||||
@After
|
||||
public void unregisterIdlingResource() {
|
||||
Espresso.unregisterIdlingResources(idlingResource);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
@Override
|
||||
public void perform(UiController uiController, View view) {
|
||||
mapboxMap.animateCamera(cameraUpdate);
|
||||
uiController.loopMainThreadForAtLeast(TestConstants.ANIMATION_TEST_TIME);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,6 @@ 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.constants.MapboxConstants;
|
||||
import com.mapbox.mapboxsdk.geometry.LatLng;
|
||||
import com.mapbox.mapboxsdk.geometry.LatLngBounds;
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
@@ -33,206 +32,221 @@ import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class CameraEaseTest {
|
||||
|
||||
@Rule
|
||||
public final ActivityTestRule<EspressoTestActivity> rule = new ActivityTestRule<>(EspressoTestActivity.class);
|
||||
@Rule
|
||||
public final ActivityTestRule<EspressoTestActivity> rule = new ActivityTestRule<>(EspressoTestActivity.class);
|
||||
|
||||
private OnMapReadyIdlingResource idlingResource;
|
||||
private OnMapReadyIdlingResource idlingResource;
|
||||
|
||||
@Before
|
||||
public void registerIdlingResource() {
|
||||
idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
|
||||
Espresso.registerIdlingResources(idlingResource);
|
||||
@Before
|
||||
public void registerIdlingResource() {
|
||||
idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
|
||||
Espresso.registerIdlingResources(idlingResource);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEaseToCameraPositionTarget() {
|
||||
ViewUtils.checkViewIsDisplayed(R.id.mapView);
|
||||
final MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
/*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);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEaseToCameraPositionTargetZoom() {
|
||||
ViewUtils.checkViewIsDisplayed(R.id.mapView);
|
||||
final MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEaseToCameraPosition() {
|
||||
ViewUtils.checkViewIsDisplayed(R.id.mapView);
|
||||
final MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEaseToBounds() {
|
||||
ViewUtils.checkViewIsDisplayed(R.id.mapView);
|
||||
final MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEaseToMoveBy() {
|
||||
ViewUtils.checkViewIsDisplayed(R.id.mapView);
|
||||
final MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEaseToZoomIn() {
|
||||
ViewUtils.checkViewIsDisplayed(R.id.mapView);
|
||||
final MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
/*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);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEaseToZoomOut() {
|
||||
ViewUtils.checkViewIsDisplayed(R.id.mapView);
|
||||
final MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
/*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);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEaseToZoomBy() {
|
||||
ViewUtils.checkViewIsDisplayed(R.id.mapView);
|
||||
final MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
/*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);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEaseToZoomTo() {
|
||||
ViewUtils.checkViewIsDisplayed(R.id.mapView);
|
||||
final MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
/*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);
|
||||
}
|
||||
|
||||
@After
|
||||
public void unregisterIdlingResource() {
|
||||
Espresso.unregisterIdlingResources(idlingResource);
|
||||
}
|
||||
|
||||
private class EaseCameraAction implements ViewAction {
|
||||
|
||||
private MapboxMap mapboxMap;
|
||||
private CameraUpdate cameraUpdate;
|
||||
|
||||
EaseCameraAction(MapboxMap map, CameraUpdate update) {
|
||||
mapboxMap = map;
|
||||
cameraUpdate = update;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEaseToCameraPositionTarget() {
|
||||
ViewUtils.checkViewIsDisplayed(R.id.mapView);
|
||||
final MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
/*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);
|
||||
@Override
|
||||
public Matcher<View> getConstraints() {
|
||||
return isDisplayed();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEaseToCameraPositionTargetZoom() {
|
||||
ViewUtils.checkViewIsDisplayed(R.id.mapView);
|
||||
final MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
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);
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return getClass().getSimpleName();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEaseToCameraPosition() {
|
||||
ViewUtils.checkViewIsDisplayed(R.id.mapView);
|
||||
final MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEaseToBounds() {
|
||||
ViewUtils.checkViewIsDisplayed(R.id.mapView);
|
||||
final MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEaseToMoveBy() {
|
||||
ViewUtils.checkViewIsDisplayed(R.id.mapView);
|
||||
final MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEaseToZoomIn() {
|
||||
ViewUtils.checkViewIsDisplayed(R.id.mapView);
|
||||
final MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
/*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);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEaseToZoomOut() {
|
||||
ViewUtils.checkViewIsDisplayed(R.id.mapView);
|
||||
final MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
/*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);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEaseToZoomBy() {
|
||||
ViewUtils.checkViewIsDisplayed(R.id.mapView);
|
||||
final MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
/*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);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEaseToZoomTo() {
|
||||
ViewUtils.checkViewIsDisplayed(R.id.mapView);
|
||||
final MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
/*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);
|
||||
}
|
||||
|
||||
@After
|
||||
public void unregisterIdlingResource() {
|
||||
Espresso.unregisterIdlingResources(idlingResource);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
@Override
|
||||
public void perform(UiController uiController, View view) {
|
||||
mapboxMap.easeCamera(cameraUpdate);
|
||||
uiController.loopMainThreadForAtLeast(TestConstants.ANIMATION_TEST_TIME);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,167 +0,0 @@
|
||||
package com.mapbox.mapboxsdk.testapp.camera;
|
||||
|
||||
import android.support.test.espresso.Espresso;
|
||||
import android.support.test.espresso.UiController;
|
||||
import android.support.test.espresso.ViewAction;
|
||||
import android.support.test.rule.ActivityTestRule;
|
||||
import android.view.View;
|
||||
|
||||
import com.mapbox.mapboxsdk.camera.CameraPosition;
|
||||
import com.mapbox.mapboxsdk.geometry.LatLng;
|
||||
import com.mapbox.mapboxsdk.maps.MapView;
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
import com.mapbox.mapboxsdk.maps.MapViewUtils;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
import com.mapbox.mapboxsdk.testapp.activity.espresso.EspressoTestActivity;
|
||||
import com.mapbox.mapboxsdk.testapp.utils.OnMapReadyIdlingResource;
|
||||
import com.mapbox.mapboxsdk.testapp.utils.TestConstants;
|
||||
import com.mapbox.mapboxsdk.testapp.utils.ViewUtils;
|
||||
|
||||
import org.hamcrest.Matcher;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
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 org.junit.Assert.assertEquals;
|
||||
|
||||
/**
|
||||
* Tests camera transformations that aren't part of our public API
|
||||
*/
|
||||
public class CameraInternalAPITest {
|
||||
|
||||
@Rule
|
||||
public final ActivityTestRule<EspressoTestActivity> rule = new ActivityTestRule<>(EspressoTestActivity.class);
|
||||
|
||||
private OnMapReadyIdlingResource idlingResource;
|
||||
|
||||
@Before
|
||||
public void registerIdlingResource() {
|
||||
idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
|
||||
Espresso.registerIdlingResources(idlingResource);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBearing() {
|
||||
ViewUtils.checkViewIsDisplayed(R.id.mapView);
|
||||
EspressoTestActivity activity = rule.getActivity();
|
||||
MapboxMap mapboxMap = activity.getMapboxMap();
|
||||
|
||||
CameraPosition initialPosition = new CameraPosition.Builder().target(new LatLng()).zoom(1).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 BearingAction(mapboxMap));
|
||||
assertEquals("Bearing should match", 45.1f, MapViewUtils.getDirection(mapboxMap), TestConstants.BEARING_DELTA);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTilt() {
|
||||
ViewUtils.checkViewIsDisplayed(R.id.mapView);
|
||||
EspressoTestActivity activity = rule.getActivity();
|
||||
MapboxMap mapboxMap = activity.getMapboxMap();
|
||||
|
||||
CameraPosition initialPosition = new CameraPosition.Builder().target(new LatLng()).zoom(1).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 TiltAction(mapboxMap));
|
||||
assertEquals("Tilt should match", 40.0f, MapViewUtils.getTilt(mapboxMap), TestConstants.TILT_DELTA);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLatLng() {
|
||||
ViewUtils.checkViewIsDisplayed(R.id.mapView);
|
||||
EspressoTestActivity activity = rule.getActivity();
|
||||
MapboxMap mapboxMap = activity.getMapboxMap();
|
||||
|
||||
CameraPosition initialPosition = new CameraPosition.Builder().target(new LatLng()).zoom(1).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 LatLngAction(mapboxMap));
|
||||
LatLng centerCoordinate = MapViewUtils.getLatLng(mapboxMap);
|
||||
assertEquals("Latitude should match", 1.1f, centerCoordinate.getLatitude(), TestConstants.LAT_LNG_DELTA);
|
||||
assertEquals("Longitude should match", 2.2f, centerCoordinate.getLongitude(), TestConstants.LAT_LNG_DELTA);
|
||||
}
|
||||
|
||||
@After
|
||||
public void unregisterIdlingResource() {
|
||||
Espresso.unregisterIdlingResources(idlingResource);
|
||||
}
|
||||
|
||||
private class BearingAction implements ViewAction {
|
||||
|
||||
private MapboxMap mapboxMap;
|
||||
|
||||
BearingAction(MapboxMap mapboxMap) {
|
||||
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) {
|
||||
MapViewUtils.setDirection(mapboxMap, -45.1f);
|
||||
}
|
||||
}
|
||||
|
||||
private class TiltAction implements ViewAction {
|
||||
|
||||
private MapboxMap mapboxMap;
|
||||
|
||||
TiltAction(MapboxMap mapboxMap) {
|
||||
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) {
|
||||
MapViewUtils.setTilt(mapboxMap, 40.0f);
|
||||
}
|
||||
}
|
||||
|
||||
private class LatLngAction implements ViewAction {
|
||||
|
||||
private MapboxMap mapboxMap;
|
||||
|
||||
LatLngAction(MapboxMap mapboxMap) {
|
||||
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) {
|
||||
MapViewUtils.setLatLng(mapboxMap, new LatLng(1.1, 2.2));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,169 @@
|
||||
package com.mapbox.mapboxsdk.testapp.camera;
|
||||
|
||||
import android.support.test.espresso.Espresso;
|
||||
import android.support.test.espresso.UiController;
|
||||
import android.support.test.espresso.ViewAction;
|
||||
import android.support.test.rule.ActivityTestRule;
|
||||
import android.view.View;
|
||||
|
||||
import com.mapbox.mapboxsdk.camera.CameraPosition;
|
||||
import com.mapbox.mapboxsdk.geometry.LatLng;
|
||||
import com.mapbox.mapboxsdk.maps.MapViewUtils;
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
import com.mapbox.mapboxsdk.testapp.activity.espresso.EspressoTestActivity;
|
||||
import com.mapbox.mapboxsdk.testapp.utils.OnMapReadyIdlingResource;
|
||||
import com.mapbox.mapboxsdk.testapp.utils.TestConstants;
|
||||
import com.mapbox.mapboxsdk.testapp.utils.ViewUtils;
|
||||
|
||||
import org.hamcrest.Matcher;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
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 org.junit.Assert.assertEquals;
|
||||
|
||||
/**
|
||||
* Tests camera transformations that aren't part of our public API
|
||||
*/
|
||||
public class CameraInternalApiTest {
|
||||
|
||||
@Rule
|
||||
public final ActivityTestRule<EspressoTestActivity> rule = new ActivityTestRule<>(EspressoTestActivity.class);
|
||||
|
||||
private OnMapReadyIdlingResource idlingResource;
|
||||
|
||||
@Before
|
||||
public void registerIdlingResource() {
|
||||
idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
|
||||
Espresso.registerIdlingResources(idlingResource);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBearing() {
|
||||
ViewUtils.checkViewIsDisplayed(R.id.mapView);
|
||||
EspressoTestActivity activity = rule.getActivity();
|
||||
MapboxMap mapboxMap = activity.getMapboxMap();
|
||||
|
||||
CameraPosition initialPosition = new
|
||||
CameraPosition.Builder().target(new LatLng()).zoom(1).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 BearingAction(mapboxMap));
|
||||
assertEquals("Bearing should match", 45.1f, MapViewUtils.getDirection(mapboxMap), TestConstants.BEARING_DELTA);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTilt() {
|
||||
ViewUtils.checkViewIsDisplayed(R.id.mapView);
|
||||
EspressoTestActivity activity = rule.getActivity();
|
||||
MapboxMap mapboxMap = activity.getMapboxMap();
|
||||
|
||||
CameraPosition initialPosition = new CameraPosition.Builder().target(
|
||||
new LatLng()).zoom(1).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 TiltAction(mapboxMap));
|
||||
assertEquals("Tilt should match", 40.0f, MapViewUtils.getTilt(mapboxMap), TestConstants.TILT_DELTA);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLatLng() {
|
||||
ViewUtils.checkViewIsDisplayed(R.id.mapView);
|
||||
EspressoTestActivity activity = rule.getActivity();
|
||||
MapboxMap mapboxMap = activity.getMapboxMap();
|
||||
|
||||
CameraPosition initialPosition = new CameraPosition.Builder().target(
|
||||
new LatLng()).zoom(1).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 LatLngAction(mapboxMap));
|
||||
LatLng centerCoordinate = MapViewUtils.getLatLng(mapboxMap);
|
||||
assertEquals("Latitude should match", 1.1f, centerCoordinate.getLatitude(), TestConstants.LAT_LNG_DELTA);
|
||||
assertEquals("Longitude should match", 2.2f, centerCoordinate.getLongitude(), TestConstants.LAT_LNG_DELTA);
|
||||
}
|
||||
|
||||
@After
|
||||
public void unregisterIdlingResource() {
|
||||
Espresso.unregisterIdlingResources(idlingResource);
|
||||
}
|
||||
|
||||
private class BearingAction implements ViewAction {
|
||||
|
||||
private MapboxMap mapboxMap;
|
||||
|
||||
BearingAction(MapboxMap mapboxMap) {
|
||||
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) {
|
||||
MapViewUtils.setDirection(mapboxMap, -45.1f);
|
||||
}
|
||||
}
|
||||
|
||||
private class TiltAction implements ViewAction {
|
||||
|
||||
private MapboxMap mapboxMap;
|
||||
|
||||
TiltAction(MapboxMap mapboxMap) {
|
||||
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) {
|
||||
MapViewUtils.setTilt(mapboxMap, 40.0f);
|
||||
}
|
||||
}
|
||||
|
||||
private class LatLngAction implements ViewAction {
|
||||
|
||||
private MapboxMap mapboxMap;
|
||||
|
||||
LatLngAction(MapboxMap mapboxMap) {
|
||||
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) {
|
||||
MapViewUtils.setLatLng(mapboxMap, new LatLng(1.1, 2.2));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -29,209 +29,224 @@ 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 org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class CameraMoveTest {
|
||||
|
||||
@Rule
|
||||
public final ActivityTestRule<EspressoTestActivity> rule = new ActivityTestRule<>(EspressoTestActivity.class);
|
||||
|
||||
private OnMapReadyIdlingResource idlingResource;
|
||||
@Rule
|
||||
public final ActivityTestRule<EspressoTestActivity> rule = new ActivityTestRule<>(EspressoTestActivity.class);
|
||||
|
||||
@Before
|
||||
public void registerIdlingResource() {
|
||||
idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
|
||||
Espresso.registerIdlingResources(idlingResource);
|
||||
private OnMapReadyIdlingResource idlingResource;
|
||||
|
||||
@Before
|
||||
public void registerIdlingResource() {
|
||||
idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
|
||||
Espresso.registerIdlingResources(idlingResource);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMoveToCameraPositionTarget() {
|
||||
ViewUtils.checkViewIsDisplayed(R.id.mapView);
|
||||
final MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
/*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);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMoveToCameraPositionTargetZoom() {
|
||||
ViewUtils.checkViewIsDisplayed(R.id.mapView);
|
||||
final MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMoveToCameraPosition() {
|
||||
ViewUtils.checkViewIsDisplayed(R.id.mapView);
|
||||
final MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMoveToBounds() {
|
||||
ViewUtils.checkViewIsDisplayed(R.id.mapView);
|
||||
final MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMoveToMoveBy() {
|
||||
ViewUtils.checkViewIsDisplayed(R.id.mapView);
|
||||
final MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMoveToZoomIn() {
|
||||
ViewUtils.checkViewIsDisplayed(R.id.mapView);
|
||||
final MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
/*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);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMoveToZoomOut() {
|
||||
ViewUtils.checkViewIsDisplayed(R.id.mapView);
|
||||
final MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
/*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);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMoveToZoomBy() {
|
||||
ViewUtils.checkViewIsDisplayed(R.id.mapView);
|
||||
final MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
/*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);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMoveToZoomTo() {
|
||||
ViewUtils.checkViewIsDisplayed(R.id.mapView);
|
||||
final MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
/*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);
|
||||
}
|
||||
|
||||
@After
|
||||
public void unregisterIdlingResource() {
|
||||
Espresso.unregisterIdlingResources(idlingResource);
|
||||
}
|
||||
|
||||
private class MoveCameraAction implements ViewAction {
|
||||
|
||||
private MapboxMap mapboxMap;
|
||||
private CameraUpdate cameraUpdate;
|
||||
|
||||
MoveCameraAction(MapboxMap map, CameraUpdate update) {
|
||||
mapboxMap = map;
|
||||
cameraUpdate = update;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMoveToCameraPositionTarget() {
|
||||
ViewUtils.checkViewIsDisplayed(R.id.mapView);
|
||||
final MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
/*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);
|
||||
@Override
|
||||
public Matcher<View> getConstraints() {
|
||||
return isDisplayed();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMoveToCameraPositionTargetZoom() {
|
||||
ViewUtils.checkViewIsDisplayed(R.id.mapView);
|
||||
final MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
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);
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return getClass().getSimpleName();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMoveToCameraPosition() {
|
||||
ViewUtils.checkViewIsDisplayed(R.id.mapView);
|
||||
final MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMoveToBounds() {
|
||||
ViewUtils.checkViewIsDisplayed(R.id.mapView);
|
||||
final MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMoveToMoveBy() {
|
||||
ViewUtils.checkViewIsDisplayed(R.id.mapView);
|
||||
final MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMoveToZoomIn() {
|
||||
ViewUtils.checkViewIsDisplayed(R.id.mapView);
|
||||
final MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
/*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);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMoveToZoomOut() {
|
||||
ViewUtils.checkViewIsDisplayed(R.id.mapView);
|
||||
final MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
/*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);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMoveToZoomBy() {
|
||||
ViewUtils.checkViewIsDisplayed(R.id.mapView);
|
||||
final MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
/*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);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMoveToZoomTo() {
|
||||
ViewUtils.checkViewIsDisplayed(R.id.mapView);
|
||||
final MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
/*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);
|
||||
}
|
||||
|
||||
@After
|
||||
public void unregisterIdlingResource() {
|
||||
Espresso.unregisterIdlingResources(idlingResource);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
@Override
|
||||
public void perform(UiController uiController, View view) {
|
||||
mapboxMap.moveCamera(cameraUpdate);
|
||||
uiController.loopMainThreadForAtLeast(100);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,32 +29,33 @@ import static org.hamcrest.Matchers.not;
|
||||
*/
|
||||
public class QueryRenderedFeaturesBoxCountTest {
|
||||
|
||||
@Rule
|
||||
public final ActivityTestRule<QueryRenderedFeaturesBoxCountActivity> rule = new ActivityTestRule<>(QueryRenderedFeaturesBoxCountActivity.class);
|
||||
@Rule
|
||||
public final ActivityTestRule<QueryRenderedFeaturesBoxCountActivity> rule =
|
||||
new ActivityTestRule<>(QueryRenderedFeaturesBoxCountActivity.class);
|
||||
|
||||
private OnMapReadyIdlingResource idlingResource;
|
||||
private OnMapReadyIdlingResource idlingResource;
|
||||
|
||||
@Before
|
||||
public void registerIdlingResource() {
|
||||
idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
|
||||
Espresso.registerIdlingResources(idlingResource);
|
||||
}
|
||||
@Before
|
||||
public void registerIdlingResource() {
|
||||
idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
|
||||
Espresso.registerIdlingResources(idlingResource);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void testCountFeatures() {
|
||||
// click on box to query map
|
||||
onView(withId(R.id.selection_box)).perform(click());
|
||||
@Test
|
||||
@Ignore
|
||||
public void testCountFeatures() {
|
||||
// click on box to query map
|
||||
onView(withId(R.id.selection_box)).perform(click());
|
||||
|
||||
// validate if toast is shown
|
||||
onView(withText("149 features in box"))
|
||||
.inRoot(withDecorView(not(is(rule.getActivity().getWindow().getDecorView()))))
|
||||
.check(matches(isDisplayed()));
|
||||
}
|
||||
// validate if toast is shown
|
||||
onView(withText("149 features in box"))
|
||||
.inRoot(withDecorView(not(is(rule.getActivity().getWindow().getDecorView()))))
|
||||
.check(matches(isDisplayed()));
|
||||
}
|
||||
|
||||
@After
|
||||
public void unregisterIdlingResource() {
|
||||
Espresso.unregisterIdlingResources(idlingResource);
|
||||
}
|
||||
@After
|
||||
public void unregisterIdlingResource() {
|
||||
Espresso.unregisterIdlingResources(idlingResource);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -34,47 +34,48 @@ import static org.hamcrest.Matchers.not;
|
||||
*/
|
||||
public class QueryRenderedFeaturesHighlightTest {
|
||||
|
||||
@Rule
|
||||
public final ActivityTestRule<QueryRenderedFeaturesBoxHighlightActivity> rule = new ActivityTestRule<>(QueryRenderedFeaturesBoxHighlightActivity.class);
|
||||
@Rule
|
||||
public final ActivityTestRule<QueryRenderedFeaturesBoxHighlightActivity> rule =
|
||||
new ActivityTestRule<>(QueryRenderedFeaturesBoxHighlightActivity.class);
|
||||
|
||||
private OnMapReadyIdlingResource idlingResource;
|
||||
private OnMapReadyIdlingResource idlingResource;
|
||||
|
||||
@Before
|
||||
public void registerIdlingResource() {
|
||||
idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
|
||||
Espresso.registerIdlingResources(idlingResource);
|
||||
}
|
||||
@Before
|
||||
public void registerIdlingResource() {
|
||||
idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
|
||||
Espresso.registerIdlingResources(idlingResource);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void testCountFeatures() {
|
||||
// click on box to query map
|
||||
onView(withId(R.id.selection_box)).perform(click());
|
||||
@Test
|
||||
@Ignore
|
||||
public void testCountFeatures() {
|
||||
// click on box to query map
|
||||
onView(withId(R.id.selection_box)).perform(click());
|
||||
|
||||
// validate if toast is shown
|
||||
onView(withText("50 features in box"))
|
||||
.inRoot(withDecorView(not(is(rule.getActivity().getWindow().getDecorView()))))
|
||||
.check(matches(isDisplayed()));
|
||||
}
|
||||
// validate if toast is shown
|
||||
onView(withText("50 features in box"))
|
||||
.inRoot(withDecorView(not(is(rule.getActivity().getWindow().getDecorView()))))
|
||||
.check(matches(isDisplayed()));
|
||||
}
|
||||
|
||||
@After
|
||||
public void unregisterIdlingResource() {
|
||||
Espresso.unregisterIdlingResources(idlingResource);
|
||||
}
|
||||
@After
|
||||
public void unregisterIdlingResource() {
|
||||
Espresso.unregisterIdlingResources(idlingResource);
|
||||
}
|
||||
|
||||
private static ViewAction clickXY(final float x, final float y) {
|
||||
return new GeneralClickAction(
|
||||
Tap.SINGLE,
|
||||
new CoordinatesProvider() {
|
||||
@Override
|
||||
public float[] calculateCoordinates(View view) {
|
||||
final int[] screenPos = new int[2];
|
||||
view.getLocationOnScreen(screenPos);
|
||||
final float screenX = screenPos[0] + x;
|
||||
final float screenY = screenPos[1] + y;
|
||||
return new float[]{screenX, screenY};
|
||||
}
|
||||
},
|
||||
Press.FINGER);
|
||||
}
|
||||
private static ViewAction clickXY(final float x, final float y) {
|
||||
return new GeneralClickAction(
|
||||
Tap.SINGLE,
|
||||
new CoordinatesProvider() {
|
||||
@Override
|
||||
public float[] calculateCoordinates(View view) {
|
||||
final int[] screenPos = new int[2];
|
||||
view.getLocationOnScreen(screenPos);
|
||||
final float screenX = screenPos[0] + x;
|
||||
final float screenY = screenPos[1] + y;
|
||||
return new float[] {screenX, screenY};
|
||||
}
|
||||
},
|
||||
Press.FINGER);
|
||||
}
|
||||
}
|
||||
@@ -33,45 +33,46 @@ import static android.support.test.espresso.matcher.ViewMatchers.withText;
|
||||
*/
|
||||
public class QueryRenderedFeaturesPropertiesTest {
|
||||
|
||||
@Rule
|
||||
public final ActivityTestRule<QueryRenderedFeaturesPropertiesActivity> rule = new ActivityTestRule<>(QueryRenderedFeaturesPropertiesActivity.class);
|
||||
@Rule
|
||||
public final ActivityTestRule<QueryRenderedFeaturesPropertiesActivity> rule =
|
||||
new ActivityTestRule<>(QueryRenderedFeaturesPropertiesActivity.class);
|
||||
|
||||
private OnMapReadyIdlingResource idlingResource;
|
||||
private OnMapReadyIdlingResource idlingResource;
|
||||
|
||||
@Before
|
||||
public void registerIdlingResource() {
|
||||
idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
|
||||
Espresso.registerIdlingResources(idlingResource);
|
||||
}
|
||||
@Before
|
||||
public void registerIdlingResource() {
|
||||
idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
|
||||
Espresso.registerIdlingResources(idlingResource);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void testCountFeatures() {
|
||||
MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
|
||||
LatLng centerScreen = mapboxMap.getCameraPosition().target;
|
||||
PointF centerPixel = mapboxMap.getProjection().toScreenLocation(centerScreen);
|
||||
onView(withId(R.id.mapView)).perform(clickXY(centerPixel.x, centerPixel.y));
|
||||
onView(withText("Found 4 features")).check(matches(isDisplayed()));
|
||||
}
|
||||
@Test
|
||||
@Ignore
|
||||
public void testCountFeatures() {
|
||||
MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
|
||||
LatLng centerScreen = mapboxMap.getCameraPosition().target;
|
||||
PointF centerPixel = mapboxMap.getProjection().toScreenLocation(centerScreen);
|
||||
onView(withId(R.id.mapView)).perform(clickXY(centerPixel.x, centerPixel.y));
|
||||
onView(withText("Found 4 features")).check(matches(isDisplayed()));
|
||||
}
|
||||
|
||||
@After
|
||||
public void unregisterIdlingResource() {
|
||||
Espresso.unregisterIdlingResources(idlingResource);
|
||||
}
|
||||
@After
|
||||
public void unregisterIdlingResource() {
|
||||
Espresso.unregisterIdlingResources(idlingResource);
|
||||
}
|
||||
|
||||
private static ViewAction clickXY(final float x, final float y) {
|
||||
return new GeneralClickAction(
|
||||
Tap.SINGLE,
|
||||
new CoordinatesProvider() {
|
||||
@Override
|
||||
public float[] calculateCoordinates(View view) {
|
||||
final int[] screenPos = new int[2];
|
||||
view.getLocationOnScreen(screenPos);
|
||||
final float screenX = screenPos[0] + x;
|
||||
final float screenY = screenPos[1] + y;
|
||||
return new float[]{screenX, screenY};
|
||||
}
|
||||
},
|
||||
Press.FINGER);
|
||||
}
|
||||
private static ViewAction clickXY(final float x, final float y) {
|
||||
return new GeneralClickAction(
|
||||
Tap.SINGLE,
|
||||
new CoordinatesProvider() {
|
||||
@Override
|
||||
public float[] calculateCoordinates(View view) {
|
||||
final int[] screenPos = new int[2];
|
||||
view.getLocationOnScreen(screenPos);
|
||||
final float screenX = screenPos[0] + x;
|
||||
final float screenY = screenPos[1] + y;
|
||||
return new float[] {screenX, screenY};
|
||||
}
|
||||
},
|
||||
Press.FINGER);
|
||||
}
|
||||
}
|
||||
@@ -29,33 +29,34 @@ import static org.hamcrest.Matchers.not;
|
||||
*/
|
||||
public class QueryRenderedSymbolBoxCountTest {
|
||||
|
||||
@Rule
|
||||
public final ActivityTestRule<QueryRenderedFeaturesBoxSymbolCountActivity> rule = new ActivityTestRule<>(QueryRenderedFeaturesBoxSymbolCountActivity.class);
|
||||
@Rule
|
||||
public final ActivityTestRule<QueryRenderedFeaturesBoxSymbolCountActivity> rule =
|
||||
new ActivityTestRule<>(QueryRenderedFeaturesBoxSymbolCountActivity.class);
|
||||
|
||||
private OnMapReadyIdlingResource idlingResource;
|
||||
private OnMapReadyIdlingResource idlingResource;
|
||||
|
||||
@Before
|
||||
public void registerIdlingResource() {
|
||||
idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
|
||||
Espresso.registerIdlingResources(idlingResource);
|
||||
}
|
||||
@Before
|
||||
public void registerIdlingResource() {
|
||||
idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
|
||||
Espresso.registerIdlingResources(idlingResource);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void testCountSymbols() {
|
||||
// click on box to query map
|
||||
onView(withId(R.id.selection_box)).perform(click());
|
||||
@Test
|
||||
@Ignore
|
||||
public void testCountSymbols() {
|
||||
// click on box to query map
|
||||
onView(withId(R.id.selection_box)).perform(click());
|
||||
|
||||
// validate if toast is shown
|
||||
onView(withText("2 features in box"))
|
||||
.inRoot(withDecorView(not(is(rule.getActivity().getWindow().getDecorView()))))
|
||||
.check(matches(isDisplayed()));
|
||||
}
|
||||
// validate if toast is shown
|
||||
onView(withText("2 features in box"))
|
||||
.inRoot(withDecorView(not(is(rule.getActivity().getWindow().getDecorView()))))
|
||||
.check(matches(isDisplayed()));
|
||||
}
|
||||
|
||||
@After
|
||||
public void unregisterIdlingResource() {
|
||||
Espresso.unregisterIdlingResources(idlingResource);
|
||||
}
|
||||
@After
|
||||
public void unregisterIdlingResource() {
|
||||
Espresso.unregisterIdlingResources(idlingResource);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -37,120 +37,120 @@ import static org.hamcrest.core.IsNot.not;
|
||||
|
||||
public class AttributionTest {
|
||||
|
||||
@Rule
|
||||
public final ActivityTestRule<EspressoTestActivity> rule = new ActivityTestRule<>(EspressoTestActivity.class);
|
||||
@Rule
|
||||
public final ActivityTestRule<EspressoTestActivity> rule = new ActivityTestRule<>(EspressoTestActivity.class);
|
||||
|
||||
private OnMapReadyIdlingResource idlingResource;
|
||||
private OnMapReadyIdlingResource idlingResource;
|
||||
|
||||
private String[] dialogTexts;
|
||||
private String[] dialogLinks;
|
||||
private String[] dialogTexts;
|
||||
private String[] dialogLinks;
|
||||
|
||||
@Before
|
||||
public void beforeTest() {
|
||||
idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
|
||||
Espresso.registerIdlingResources(idlingResource);
|
||||
Intents.init();
|
||||
dialogTexts = rule.getActivity().getResources().getStringArray(R.array.mapbox_attribution_names);
|
||||
dialogLinks = rule.getActivity().getResources().getStringArray(R.array.mapbox_attribution_links);
|
||||
@Before
|
||||
public void beforeTest() {
|
||||
idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
|
||||
Espresso.registerIdlingResources(idlingResource);
|
||||
Intents.init();
|
||||
dialogTexts = rule.getActivity().getResources().getStringArray(R.array.mapbox_attribution_names);
|
||||
dialogLinks = rule.getActivity().getResources().getStringArray(R.array.mapbox_attribution_links);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDisabled() {
|
||||
ViewUtils.checkViewIsDisplayed(R.id.mapView);
|
||||
MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
// Default
|
||||
onView(withId(R.id.attributionView)).check(matches(isDisplayed()));
|
||||
|
||||
// Disabled
|
||||
onView(withId(R.id.attributionView))
|
||||
.perform(new DisableAction(mapboxMap))
|
||||
.check(matches(not(isDisplayed())));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMapboxLink() {
|
||||
ViewUtils.checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
// click on View to open dialog
|
||||
onView(withId(R.id.attributionView)).perform(click());
|
||||
onView(withText(R.string.mapbox_attributionsDialogTitle)).check(matches(isDisplayed()));
|
||||
|
||||
// click on link and validate browser opening
|
||||
Matcher<Intent> expectedIntent = allOf(hasAction(Intent.ACTION_VIEW), hasData(Uri.parse(dialogLinks[0])));
|
||||
intending(expectedIntent).respondWith(new Instrumentation.ActivityResult(0, null));
|
||||
onView(withText(dialogTexts[0])).perform(click());
|
||||
intended(expectedIntent);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOpenStreetMapLink() {
|
||||
ViewUtils.checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
// click on View to open dialog
|
||||
onView(withId(R.id.attributionView)).perform(click());
|
||||
onView(withText(R.string.mapbox_attributionsDialogTitle)).check(matches(isDisplayed()));
|
||||
|
||||
// click on link and validate browser opening
|
||||
Matcher<Intent> expectedIntent = allOf(hasAction(Intent.ACTION_VIEW), hasData(Uri.parse(dialogLinks[1])));
|
||||
intending(expectedIntent).respondWith(new Instrumentation.ActivityResult(0, null));
|
||||
onView(withText(dialogTexts[1])).perform(click());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testImproveMapLink() {
|
||||
ViewUtils.checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
// click on View to open dialog
|
||||
onView(withId(R.id.attributionView)).perform(click());
|
||||
onView(withText(R.string.mapbox_attributionsDialogTitle)).check(matches(isDisplayed()));
|
||||
|
||||
// click on Mapbox link and validate browser opening
|
||||
Matcher<Intent> expectedIntent = allOf(hasAction(Intent.ACTION_VIEW), hasData(Uri.parse(dialogLinks[3])));
|
||||
intending(expectedIntent).respondWith(new Instrumentation.ActivityResult(0, null));
|
||||
onView(withText(dialogTexts[3])).perform(click());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTelemetryDialog() {
|
||||
ViewUtils.checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
// click on View to open dialog
|
||||
onView(withId(R.id.attributionView)).perform(click());
|
||||
onView(withText(R.string.mapbox_attributionsDialogTitle)).check(matches(isDisplayed()));
|
||||
|
||||
// click on item to open second dialog
|
||||
onView(withText(dialogTexts[3])).perform(click());
|
||||
onView(withText(R.string.mapbox_attributionTelemetryTitle)).check(matches(isDisplayed()));
|
||||
}
|
||||
|
||||
@After
|
||||
public void afterTest() {
|
||||
Intents.release();
|
||||
Espresso.unregisterIdlingResources(idlingResource);
|
||||
}
|
||||
|
||||
private class DisableAction implements ViewAction {
|
||||
|
||||
private MapboxMap mapboxMap;
|
||||
|
||||
DisableAction(MapboxMap map) {
|
||||
mapboxMap = map;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDisabled() {
|
||||
ViewUtils.checkViewIsDisplayed(R.id.mapView);
|
||||
MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
// Default
|
||||
onView(withId(R.id.attributionView)).check(matches(isDisplayed()));
|
||||
|
||||
// Disabled
|
||||
onView(withId(R.id.attributionView))
|
||||
.perform(new DisableAction(mapboxMap))
|
||||
.check(matches(not(isDisplayed())));
|
||||
@Override
|
||||
public Matcher<View> getConstraints() {
|
||||
return isDisplayed();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMapboxLink() {
|
||||
ViewUtils.checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
// click on View to open dialog
|
||||
onView(withId(R.id.attributionView)).perform(click());
|
||||
onView(withText(R.string.mapbox_attributionsDialogTitle)).check(matches(isDisplayed()));
|
||||
|
||||
// click on link and validate browser opening
|
||||
Matcher<Intent> expectedIntent = allOf(hasAction(Intent.ACTION_VIEW), hasData(Uri.parse(dialogLinks[0])));
|
||||
intending(expectedIntent).respondWith(new Instrumentation.ActivityResult(0, null));
|
||||
onView(withText(dialogTexts[0])).perform(click());
|
||||
intended(expectedIntent);
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return getClass().getSimpleName();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOpenStreetMapLink() {
|
||||
ViewUtils.checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
// click on View to open dialog
|
||||
onView(withId(R.id.attributionView)).perform(click());
|
||||
onView(withText(R.string.mapbox_attributionsDialogTitle)).check(matches(isDisplayed()));
|
||||
|
||||
// click on link and validate browser opening
|
||||
Matcher<Intent> expectedIntent = allOf(hasAction(Intent.ACTION_VIEW), hasData(Uri.parse(dialogLinks[1])));
|
||||
intending(expectedIntent).respondWith(new Instrumentation.ActivityResult(0, null));
|
||||
onView(withText(dialogTexts[1])).perform(click());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testImproveMapLink() {
|
||||
ViewUtils.checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
// click on View to open dialog
|
||||
onView(withId(R.id.attributionView)).perform(click());
|
||||
onView(withText(R.string.mapbox_attributionsDialogTitle)).check(matches(isDisplayed()));
|
||||
|
||||
// click on Mapbox link and validate browser opening
|
||||
Matcher<Intent> expectedIntent = allOf(hasAction(Intent.ACTION_VIEW), hasData(Uri.parse(dialogLinks[3])));
|
||||
intending(expectedIntent).respondWith(new Instrumentation.ActivityResult(0, null));
|
||||
onView(withText(dialogTexts[3])).perform(click());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTelemetryDialog() {
|
||||
ViewUtils.checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
// click on View to open dialog
|
||||
onView(withId(R.id.attributionView)).perform(click());
|
||||
onView(withText(R.string.mapbox_attributionsDialogTitle)).check(matches(isDisplayed()));
|
||||
|
||||
// click on item to open second dialog
|
||||
onView(withText(dialogTexts[3])).perform(click());
|
||||
onView(withText(R.string.mapbox_attributionTelemetryTitle)).check(matches(isDisplayed()));
|
||||
}
|
||||
|
||||
@After
|
||||
public void afterTest() {
|
||||
Intents.release();
|
||||
Espresso.unregisterIdlingResources(idlingResource);
|
||||
}
|
||||
|
||||
private class DisableAction implements ViewAction {
|
||||
|
||||
private MapboxMap mapboxMap;
|
||||
|
||||
DisableAction(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.getUiSettings().setAttributionEnabled(false);
|
||||
}
|
||||
@Override
|
||||
public void perform(UiController uiController, View view) {
|
||||
mapboxMap.getUiSettings().setAttributionEnabled(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,120 +34,120 @@ import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class CompassViewTest {
|
||||
|
||||
@Rule
|
||||
public final ActivityTestRule<EspressoTestActivity> rule = new ActivityTestRule<>(EspressoTestActivity.class);
|
||||
@Rule
|
||||
public final ActivityTestRule<EspressoTestActivity> rule = new ActivityTestRule<>(EspressoTestActivity.class);
|
||||
|
||||
private OnMapReadyIdlingResource idlingResource;
|
||||
private OnMapReadyIdlingResource idlingResource;
|
||||
|
||||
@Before
|
||||
public void registerIdlingResource() {
|
||||
idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
|
||||
Espresso.registerIdlingResources(idlingResource);
|
||||
@Before
|
||||
public void registerIdlingResource() {
|
||||
idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
|
||||
Espresso.registerIdlingResources(idlingResource);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDefault() {
|
||||
ViewUtils.checkViewIsDisplayed(R.id.mapView);
|
||||
onView(withId(R.id.compassView)).check(matches(not(isDisplayed())));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testVisible() {
|
||||
ViewUtils.checkViewIsDisplayed(R.id.mapView);
|
||||
MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
onView(withId(R.id.mapView)).perform(new MoveCameraAction(mapboxMap,
|
||||
CameraUpdateFactory.newCameraPosition(
|
||||
new CameraPosition.Builder()
|
||||
.bearing(45)
|
||||
.zoom(1)
|
||||
.target(new LatLng())
|
||||
.build()
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
onView(withId(R.id.compassView)).check(matches(isDisplayed()));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore // 10-31-2016 click action is not working
|
||||
public void testClick() {
|
||||
ViewUtils.checkViewIsDisplayed(R.id.mapView);
|
||||
MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
onView(withId(R.id.mapView)).perform(new MoveCameraAction(mapboxMap,
|
||||
CameraUpdateFactory.newCameraPosition(
|
||||
new CameraPosition.Builder()
|
||||
.bearing(45)
|
||||
.zoom(1)
|
||||
.target(new LatLng())
|
||||
.build()
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
onView(withId(R.id.compassView)).perform(click());
|
||||
onView(withId(R.id.mapView)).perform(new WaitAction(3000));
|
||||
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);
|
||||
}
|
||||
|
||||
@After
|
||||
public void unregisterIdlingResource() {
|
||||
Espresso.unregisterIdlingResources(idlingResource);
|
||||
}
|
||||
|
||||
private class WaitAction implements ViewAction {
|
||||
|
||||
private long waitTime;
|
||||
|
||||
WaitAction(long waitTime) {
|
||||
this.waitTime = waitTime;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDefault() {
|
||||
ViewUtils.checkViewIsDisplayed(R.id.mapView);
|
||||
onView(withId(R.id.compassView)).check(matches(not(isDisplayed())));
|
||||
@Override
|
||||
public Matcher<View> getConstraints() {
|
||||
return isDisplayed();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testVisible(){
|
||||
ViewUtils.checkViewIsDisplayed(R.id.mapView);
|
||||
MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
onView(withId(R.id.mapView)).perform(new MoveCameraAction(mapboxMap,
|
||||
CameraUpdateFactory.newCameraPosition(
|
||||
new CameraPosition.Builder()
|
||||
.bearing(45)
|
||||
.zoom(1)
|
||||
.target(new LatLng())
|
||||
.build()
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
onView(withId(R.id.compassView)).check(matches(isDisplayed()));
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return getClass().getSimpleName();
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore // 10-31-2016 click action is not working
|
||||
public void testClick() {
|
||||
ViewUtils.checkViewIsDisplayed(R.id.mapView);
|
||||
MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
|
||||
@Override
|
||||
public void perform(UiController uiController, View view) {
|
||||
uiController.loopMainThreadForAtLeast(waitTime);
|
||||
}
|
||||
}
|
||||
|
||||
onView(withId(R.id.mapView)).perform(new MoveCameraAction(mapboxMap,
|
||||
CameraUpdateFactory.newCameraPosition(
|
||||
new CameraPosition.Builder()
|
||||
.bearing(45)
|
||||
.zoom(1)
|
||||
.target(new LatLng())
|
||||
.build()
|
||||
)
|
||||
)
|
||||
);
|
||||
private class MoveCameraAction implements ViewAction {
|
||||
|
||||
onView(withId(R.id.compassView)).perform(click());
|
||||
onView(withId(R.id.mapView)).perform(new WaitAction(3000));
|
||||
onView(withId(R.id.compassView)).check(matches(not(isDisplayed())));
|
||||
private MapboxMap mapboxMap;
|
||||
private CameraUpdate cameraUpdate;
|
||||
|
||||
CameraPosition cameraPosition = mapboxMap.getCameraPosition();
|
||||
assertEquals("Camera bearing should face north, ", 0, cameraPosition.bearing, TestConstants.BEARING_DELTA);
|
||||
MoveCameraAction(MapboxMap map, CameraUpdate update) {
|
||||
mapboxMap = map;
|
||||
cameraUpdate = update;
|
||||
}
|
||||
|
||||
@After
|
||||
public void unregisterIdlingResource() {
|
||||
Espresso.unregisterIdlingResources(idlingResource);
|
||||
@Override
|
||||
public Matcher<View> getConstraints() {
|
||||
return isDisplayed();
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return getClass().getSimpleName();
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
@Override
|
||||
public void perform(UiController uiController, View view) {
|
||||
mapboxMap.moveCamera(cameraUpdate);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -26,59 +26,59 @@ import static org.hamcrest.Matchers.not;
|
||||
|
||||
public class LogoTest {
|
||||
|
||||
@Rule
|
||||
public final ActivityTestRule<EspressoTestActivity> rule = new ActivityTestRule<>(EspressoTestActivity.class);
|
||||
@Rule
|
||||
public final ActivityTestRule<EspressoTestActivity> rule = new ActivityTestRule<>(EspressoTestActivity.class);
|
||||
|
||||
private OnMapReadyIdlingResource idlingResource;
|
||||
private OnMapReadyIdlingResource idlingResource;
|
||||
|
||||
@Before
|
||||
public void registerIdlingResource() {
|
||||
idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
|
||||
Espresso.registerIdlingResources(idlingResource);
|
||||
@Before
|
||||
public void registerIdlingResource() {
|
||||
idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
|
||||
Espresso.registerIdlingResources(idlingResource);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDefault() {
|
||||
ViewUtils.checkViewIsDisplayed(R.id.mapView);
|
||||
onView(withId(R.id.logoView)).check(matches(isDisplayed()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDisabled() {
|
||||
ViewUtils.checkViewIsDisplayed(R.id.mapView);
|
||||
MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
onView(withId(R.id.logoView))
|
||||
.perform(new DisableAction(mapboxMap))
|
||||
.check(matches(not(isDisplayed())));
|
||||
}
|
||||
|
||||
@After
|
||||
public void unregisterIdlingResource() {
|
||||
Espresso.unregisterIdlingResources(idlingResource);
|
||||
}
|
||||
|
||||
private class DisableAction implements ViewAction {
|
||||
|
||||
private MapboxMap mapboxMap;
|
||||
|
||||
DisableAction(MapboxMap map) {
|
||||
mapboxMap = map;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDefault() {
|
||||
ViewUtils.checkViewIsDisplayed(R.id.mapView);
|
||||
onView(withId(R.id.logoView)).check(matches(isDisplayed()));
|
||||
@Override
|
||||
public Matcher<View> getConstraints() {
|
||||
return isDisplayed();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDisabled() {
|
||||
ViewUtils.checkViewIsDisplayed(R.id.mapView);
|
||||
MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
onView(withId(R.id.logoView))
|
||||
.perform(new DisableAction(mapboxMap))
|
||||
.check(matches(not(isDisplayed())));
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return getClass().getSimpleName();
|
||||
}
|
||||
|
||||
@After
|
||||
public void unregisterIdlingResource() {
|
||||
Espresso.unregisterIdlingResources(idlingResource);
|
||||
}
|
||||
|
||||
private class DisableAction implements ViewAction {
|
||||
|
||||
private MapboxMap mapboxMap;
|
||||
|
||||
DisableAction(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.getUiSettings().setLogoEnabled(false);
|
||||
}
|
||||
@Override
|
||||
public void perform(UiController uiController, View view) {
|
||||
mapboxMap.getUiSettings().setLogoEnabled(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,192 +51,196 @@ import static org.hamcrest.Matchers.not;
|
||||
*/
|
||||
public class MyLocationViewTest {
|
||||
|
||||
@Rule
|
||||
public final ActivityTestRule<EspressoTestActivity> rule = new ActivityTestRule<>(EspressoTestActivity.class);
|
||||
@Rule
|
||||
public final ActivityTestRule<EspressoTestActivity> rule = new ActivityTestRule<>(EspressoTestActivity.class);
|
||||
|
||||
private OnMapReadyIdlingResource idlingResource;
|
||||
private OnMapReadyIdlingResource idlingResource;
|
||||
|
||||
@Before
|
||||
public void beforeTest() {
|
||||
idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
|
||||
Espresso.registerIdlingResources(idlingResource);
|
||||
@Before
|
||||
public void beforeTest() {
|
||||
idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
|
||||
Espresso.registerIdlingResources(idlingResource);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore // requires runtime permissions, disabled for CI
|
||||
public void testEnabled() {
|
||||
ViewUtils.checkViewIsDisplayed(R.id.mapView);
|
||||
MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
|
||||
onView(withId(R.id.userLocationView)).check(matches(not(isDisplayed())));
|
||||
onView(withId(R.id.mapView)).perform(new ToggleLocationAction(mapboxMap, true));
|
||||
onView(withId(R.id.userLocationView)).check(matches(isDisplayed()));
|
||||
onView(withId(R.id.mapView)).perform(new ToggleLocationAction(mapboxMap, false));
|
||||
onView(withId(R.id.userLocationView)).check(matches(not(isDisplayed())));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
// requires runtime permissions, disabled for CI + issue with android.support.test.espresso.AppNotIdleException:
|
||||
// Looped for 5049 iterations over 60 SECONDS.
|
||||
public void testTracking() {
|
||||
ViewUtils.checkViewIsDisplayed(R.id.mapView);
|
||||
MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
|
||||
onView(withId(R.id.userLocationView)).check(matches(not(isDisplayed())));
|
||||
onView(withId(R.id.mapView)).perform(new EnableLocationTrackingAction(mapboxMap));
|
||||
onView(withId(R.id.userLocationView)).check(matches(isDisplayed()));
|
||||
onView(withId(R.id.userLocationView)).check(matches(new DrawableMatcher(mapboxMap,
|
||||
R.drawable.mapbox_mylocation_icon_default, false)));
|
||||
onView(withId(R.id.mapView)).perform(new EnableCompassBearingTrackingAction(mapboxMap));
|
||||
onView(withId(R.id.userLocationView)).check(matches(new DrawableMatcher(mapboxMap,
|
||||
R.drawable.mapbox_mylocation_icon_bearing, true)));
|
||||
}
|
||||
|
||||
@After
|
||||
public void afterTest() {
|
||||
Espresso.unregisterIdlingResources(idlingResource);
|
||||
}
|
||||
|
||||
private class ToggleLocationAction implements ViewAction {
|
||||
|
||||
private MapboxMap mapboxMap;
|
||||
private boolean isEnabled;
|
||||
|
||||
ToggleLocationAction(MapboxMap map, boolean enable) {
|
||||
mapboxMap = map;
|
||||
isEnabled = enable;
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore // requires runtime permissions, disabled for CI
|
||||
public void testEnabled() {
|
||||
ViewUtils.checkViewIsDisplayed(R.id.mapView);
|
||||
MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
|
||||
onView(withId(R.id.userLocationView)).check(matches(not(isDisplayed())));
|
||||
onView(withId(R.id.mapView)).perform(new ToggleLocationAction(mapboxMap, true));
|
||||
onView(withId(R.id.userLocationView)).check(matches(isDisplayed()));
|
||||
onView(withId(R.id.mapView)).perform(new ToggleLocationAction(mapboxMap, false));
|
||||
onView(withId(R.id.userLocationView)).check(matches(not(isDisplayed())));
|
||||
@Override
|
||||
public Matcher<View> getConstraints() {
|
||||
return isDisplayed();
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore // requires runtime permissions, disabled for CI + issue with android.support.test.espresso.AppNotIdleException: Looped for 5049 iterations over 60 SECONDS.
|
||||
public void testTracking() {
|
||||
ViewUtils.checkViewIsDisplayed(R.id.mapView);
|
||||
MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
|
||||
onView(withId(R.id.userLocationView)).check(matches(not(isDisplayed())));
|
||||
onView(withId(R.id.mapView)).perform(new EnableLocationTrackingAction(mapboxMap));
|
||||
onView(withId(R.id.userLocationView)).check(matches(isDisplayed()));
|
||||
onView(withId(R.id.userLocationView)).check(matches(new DrawableMatcher(mapboxMap, R.drawable.mapbox_mylocation_icon_default, false)));
|
||||
onView(withId(R.id.mapView)).perform(new EnableCompassBearingTrackingAction(mapboxMap));
|
||||
onView(withId(R.id.userLocationView)).check(matches(new DrawableMatcher(mapboxMap, R.drawable.mapbox_mylocation_icon_bearing, true)));
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return getClass().getSimpleName();
|
||||
}
|
||||
|
||||
@After
|
||||
public void afterTest() {
|
||||
Espresso.unregisterIdlingResources(idlingResource);
|
||||
@Override
|
||||
public void perform(UiController uiController, View view) {
|
||||
if (isEnabled) {
|
||||
// move camera above user location
|
||||
mapboxMap.moveCamera(
|
||||
CameraUpdateFactory.newCameraPosition(
|
||||
new CameraPosition.Builder()
|
||||
.target(new LatLng(LocationServices.getLocationServices(view.getContext()).getLastLocation()))
|
||||
.build()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
// show loction on screen
|
||||
mapboxMap.setMyLocationEnabled(isEnabled);
|
||||
}
|
||||
}
|
||||
|
||||
private class EnableLocationTrackingAction implements ViewAction {
|
||||
|
||||
private MapboxMap mapboxMap;
|
||||
|
||||
EnableLocationTrackingAction(MapboxMap map) {
|
||||
mapboxMap = map;
|
||||
}
|
||||
|
||||
private class ToggleLocationAction implements ViewAction {
|
||||
|
||||
private MapboxMap mapboxMap;
|
||||
private boolean isEnabled;
|
||||
|
||||
ToggleLocationAction(MapboxMap map, boolean enable) {
|
||||
mapboxMap = map;
|
||||
isEnabled = enable;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Matcher<View> getConstraints() {
|
||||
return isDisplayed();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return getClass().getSimpleName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void perform(UiController uiController, View view) {
|
||||
if (isEnabled) {
|
||||
// move camera above user location
|
||||
mapboxMap.moveCamera(
|
||||
CameraUpdateFactory.newCameraPosition(
|
||||
new CameraPosition.Builder()
|
||||
.target(new LatLng(LocationServices.getLocationServices(view.getContext()).getLastLocation()))
|
||||
.build()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
// show loction on screen
|
||||
mapboxMap.setMyLocationEnabled(isEnabled);
|
||||
}
|
||||
@Override
|
||||
public Matcher<View> getConstraints() {
|
||||
return isDisplayed();
|
||||
}
|
||||
|
||||
private class EnableLocationTrackingAction implements ViewAction {
|
||||
|
||||
private MapboxMap mapboxMap;
|
||||
|
||||
EnableLocationTrackingAction(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.getTrackingSettings().setMyLocationTrackingMode(MyLocationTracking.TRACKING_FOLLOW);
|
||||
}
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return getClass().getSimpleName();
|
||||
}
|
||||
|
||||
private class EnableCompassBearingTrackingAction implements ViewAction {
|
||||
@Override
|
||||
public void perform(UiController uiController, View view) {
|
||||
mapboxMap.getTrackingSettings().setMyLocationTrackingMode(MyLocationTracking.TRACKING_FOLLOW);
|
||||
}
|
||||
}
|
||||
|
||||
private MapboxMap mapboxMap;
|
||||
private class EnableCompassBearingTrackingAction implements ViewAction {
|
||||
|
||||
EnableCompassBearingTrackingAction(MapboxMap map) {
|
||||
mapboxMap = map;
|
||||
}
|
||||
private MapboxMap mapboxMap;
|
||||
|
||||
@Override
|
||||
public Matcher<View> getConstraints() {
|
||||
return isDisplayed();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return getClass().getSimpleName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void perform(UiController uiController, View view) {
|
||||
mapboxMap.getTrackingSettings().setMyBearingTrackingMode(MyBearingTracking.COMPASS);
|
||||
// wait for next compass update cycle
|
||||
uiController.loopMainThreadForAtLeast(500);
|
||||
}
|
||||
EnableCompassBearingTrackingAction(MapboxMap map) {
|
||||
mapboxMap = map;
|
||||
}
|
||||
|
||||
private class DrawableMatcher extends TypeSafeMatcher<View> {
|
||||
|
||||
private MapboxMap mapboxMap;
|
||||
private boolean isBearingDrawable;
|
||||
private final int expectedId;
|
||||
|
||||
DrawableMatcher(MapboxMap mapboxMap, int expectedId, boolean isBearingDrawable) {
|
||||
super(MyLocationView.class);
|
||||
this.mapboxMap = mapboxMap;
|
||||
this.expectedId = expectedId;
|
||||
this.isBearingDrawable = isBearingDrawable;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean matchesSafely(View target) {
|
||||
Drawable currentDrawable = isBearingDrawable ?
|
||||
mapboxMap.getMyLocationViewSettings().getForegroundBearingDrawable() :
|
||||
mapboxMap.getMyLocationViewSettings().getForegroundDrawable();
|
||||
|
||||
Resources resources = target.getContext().getResources();
|
||||
Drawable expectedDrawable = resources.getDrawable(expectedId);
|
||||
return areDrawablesIdentical(currentDrawable, expectedDrawable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void describeTo(Description description) {
|
||||
description.appendText("trying to match MyLocationView drawable to " + expectedId);
|
||||
}
|
||||
|
||||
boolean areDrawablesIdentical(Drawable drawableA, Drawable drawableB) {
|
||||
Drawable.ConstantState stateA = drawableA.getConstantState();
|
||||
Drawable.ConstantState stateB = drawableB.getConstantState();
|
||||
return (stateA != null && stateB != null && stateA.equals(stateB))
|
||||
|| getBitmap(drawableA).sameAs(getBitmap(drawableB));
|
||||
}
|
||||
|
||||
Bitmap getBitmap(Drawable drawable) {
|
||||
Bitmap result;
|
||||
if (drawable instanceof BitmapDrawable) {
|
||||
result = ((BitmapDrawable) drawable).getBitmap();
|
||||
} else {
|
||||
int width = drawable.getIntrinsicWidth();
|
||||
int height = drawable.getIntrinsicHeight();
|
||||
// Some drawables have no intrinsic width - e.g. solid colours.
|
||||
if (width <= 0) {
|
||||
width = 1;
|
||||
}
|
||||
if (height <= 0) {
|
||||
height = 1;
|
||||
}
|
||||
|
||||
result = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
|
||||
Canvas canvas = new Canvas(result);
|
||||
drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
|
||||
drawable.draw(canvas);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@Override
|
||||
public Matcher<View> getConstraints() {
|
||||
return isDisplayed();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return getClass().getSimpleName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void perform(UiController uiController, View view) {
|
||||
mapboxMap.getTrackingSettings().setMyBearingTrackingMode(MyBearingTracking.COMPASS);
|
||||
// wait for next compass update cycle
|
||||
uiController.loopMainThreadForAtLeast(500);
|
||||
}
|
||||
}
|
||||
|
||||
private class DrawableMatcher extends TypeSafeMatcher<View> {
|
||||
|
||||
private MapboxMap mapboxMap;
|
||||
private boolean isBearingDrawable;
|
||||
private final int expectedId;
|
||||
|
||||
DrawableMatcher(MapboxMap mapboxMap, int expectedId, boolean isBearingDrawable) {
|
||||
super(MyLocationView.class);
|
||||
this.mapboxMap = mapboxMap;
|
||||
this.expectedId = expectedId;
|
||||
this.isBearingDrawable = isBearingDrawable;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean matchesSafely(View target) {
|
||||
Drawable currentDrawable = isBearingDrawable
|
||||
? mapboxMap.getMyLocationViewSettings().getForegroundBearingDrawable() :
|
||||
mapboxMap.getMyLocationViewSettings().getForegroundDrawable();
|
||||
|
||||
Resources resources = target.getContext().getResources();
|
||||
Drawable expectedDrawable = resources.getDrawable(expectedId);
|
||||
return areDrawablesIdentical(currentDrawable, expectedDrawable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void describeTo(Description description) {
|
||||
description.appendText("trying to match MyLocationView drawable to " + expectedId);
|
||||
}
|
||||
|
||||
boolean areDrawablesIdentical(Drawable drawableA, Drawable drawableB) {
|
||||
Drawable.ConstantState stateA = drawableA.getConstantState();
|
||||
Drawable.ConstantState stateB = drawableB.getConstantState();
|
||||
return (stateA != null && stateB != null && stateA.equals(stateB))
|
||||
|| getBitmap(drawableA).sameAs(getBitmap(drawableB));
|
||||
}
|
||||
|
||||
Bitmap getBitmap(Drawable drawable) {
|
||||
Bitmap result;
|
||||
if (drawable instanceof BitmapDrawable) {
|
||||
result = ((BitmapDrawable) drawable).getBitmap();
|
||||
} else {
|
||||
int width = drawable.getIntrinsicWidth();
|
||||
int height = drawable.getIntrinsicHeight();
|
||||
// Some drawables have no intrinsic width - e.g. solid colours.
|
||||
if (width <= 0) {
|
||||
width = 1;
|
||||
}
|
||||
if (height <= 0) {
|
||||
height = 1;
|
||||
}
|
||||
|
||||
result = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
|
||||
Canvas canvas = new Canvas(result);
|
||||
drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
|
||||
drawable.draw(canvas);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make style-code-android`.
|
||||
package com.mapbox.mapboxsdk.testapp.style;
|
||||
// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make style-code-android`.
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.support.test.espresso.Espresso;
|
||||
import android.support.test.rule.ActivityTestRule;
|
||||
import android.support.test.runner.AndroidJUnit4;
|
||||
import timber.log.Timber;
|
||||
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
import com.mapbox.mapboxsdk.style.layers.BackgroundLayer;
|
||||
@@ -19,9 +18,16 @@ import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static com.mapbox.mapboxsdk.style.layers.Property.*;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*;
|
||||
import timber.log.Timber;
|
||||
|
||||
import static com.mapbox.mapboxsdk.style.layers.Property.NONE;
|
||||
import static com.mapbox.mapboxsdk.style.layers.Property.VISIBLE;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.backgroundColor;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.backgroundOpacity;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.backgroundPattern;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.visibility;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
/**
|
||||
* Basic smoke tests for BackgroundLayer
|
||||
@@ -29,107 +35,107 @@ import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*;
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class BackgroundLayerStyleTest extends BaseStyleTest {
|
||||
|
||||
@Rule
|
||||
public final ActivityTestRule<RuntimeStyleTestActivity> rule = new ActivityTestRule<>(RuntimeStyleTestActivity.class);
|
||||
@Rule
|
||||
public final ActivityTestRule<RuntimeStyleTestActivity> rule = new ActivityTestRule<>(RuntimeStyleTestActivity.class);
|
||||
|
||||
private BackgroundLayer layer;
|
||||
private BackgroundLayer layer;
|
||||
|
||||
private OnMapReadyIdlingResource idlingResource;
|
||||
private OnMapReadyIdlingResource idlingResource;
|
||||
|
||||
private MapboxMap mapboxMap;
|
||||
private MapboxMap mapboxMap;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
|
||||
Espresso.registerIdlingResources(idlingResource);
|
||||
}
|
||||
@Before
|
||||
public void setup() {
|
||||
idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
|
||||
Espresso.registerIdlingResources(idlingResource);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetVisibility() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
@Test
|
||||
public void testSetVisibility() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
Timber.i("Retrieving layer");
|
||||
layer = mapboxMap.getLayerAs("background");
|
||||
Timber.i("visibility");
|
||||
assertNotNull(layer);
|
||||
Timber.i("Retrieving layer");
|
||||
layer = mapboxMap.getLayerAs("background");
|
||||
Timber.i("visibility");
|
||||
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
|
||||
public void testBackgroundColor() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
@Test
|
||||
public void testBackgroundColor() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
Timber.i("Retrieving layer");
|
||||
layer = mapboxMap.getLayerAs("background");
|
||||
Timber.i("background-color");
|
||||
assertNotNull(layer);
|
||||
Timber.i("Retrieving layer");
|
||||
layer = mapboxMap.getLayerAs("background");
|
||||
Timber.i("background-color");
|
||||
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
|
||||
public void testBackgroundColorAsInt() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
@Test
|
||||
public void testBackgroundColorAsInt() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
Timber.i("Retrieving layer");
|
||||
layer = mapboxMap.getLayerAs("background");
|
||||
Timber.i("background-color");
|
||||
assertNotNull(layer);
|
||||
Timber.i("Retrieving layer");
|
||||
layer = mapboxMap.getLayerAs("background");
|
||||
Timber.i("background-color");
|
||||
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
|
||||
public void testBackgroundPattern() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
@Test
|
||||
public void testBackgroundPattern() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
Timber.i("Retrieving layer");
|
||||
layer = mapboxMap.getLayerAs("background");
|
||||
Timber.i("background-pattern");
|
||||
assertNotNull(layer);
|
||||
Timber.i("Retrieving layer");
|
||||
layer = mapboxMap.getLayerAs("background");
|
||||
Timber.i("background-pattern");
|
||||
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
|
||||
public void testBackgroundOpacity() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
@Test
|
||||
public void testBackgroundOpacity() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
Timber.i("Retrieving layer");
|
||||
layer = mapboxMap.getLayerAs("background");
|
||||
Timber.i("background-opacity");
|
||||
assertNotNull(layer);
|
||||
Timber.i("Retrieving layer");
|
||||
layer = mapboxMap.getLayerAs("background");
|
||||
Timber.i("background-opacity");
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
@After
|
||||
public void unregisterIntentServiceIdlingResource() {
|
||||
Espresso.unregisterIdlingResources(idlingResource);
|
||||
}
|
||||
@After
|
||||
public void unregisterIntentServiceIdlingResource() {
|
||||
Espresso.unregisterIdlingResources(idlingResource);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make android-style-code`.
|
||||
package com.mapbox.mapboxsdk.testapp.style;
|
||||
// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make android-style-code`.
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.support.test.espresso.Espresso;
|
||||
import android.support.test.rule.ActivityTestRule;
|
||||
import android.support.test.runner.AndroidJUnit4;
|
||||
import timber.log.Timber;
|
||||
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
import com.mapbox.mapboxsdk.style.layers.BackgroundLayer;
|
||||
@@ -19,9 +18,16 @@ import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static com.mapbox.mapboxsdk.style.layers.Property.*;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*;
|
||||
import timber.log.Timber;
|
||||
|
||||
import static com.mapbox.mapboxsdk.style.layers.Property.NONE;
|
||||
import static com.mapbox.mapboxsdk.style.layers.Property.VISIBLE;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.backgroundColor;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.backgroundOpacity;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.backgroundPattern;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.visibility;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
/**
|
||||
* Basic smoke tests for BackgroundLayer
|
||||
@@ -29,107 +35,107 @@ import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*;
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class BackgroundLayerTest extends BaseStyleTest {
|
||||
|
||||
@Rule
|
||||
public final ActivityTestRule<RuntimeStyleTestActivity> rule = new ActivityTestRule<>(RuntimeStyleTestActivity.class);
|
||||
@Rule
|
||||
public final ActivityTestRule<RuntimeStyleTestActivity> rule = new ActivityTestRule<>(RuntimeStyleTestActivity.class);
|
||||
|
||||
private BackgroundLayer layer;
|
||||
private BackgroundLayer layer;
|
||||
|
||||
private OnMapReadyIdlingResource idlingResource;
|
||||
private OnMapReadyIdlingResource idlingResource;
|
||||
|
||||
private MapboxMap mapboxMap;
|
||||
private MapboxMap mapboxMap;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
|
||||
Espresso.registerIdlingResources(idlingResource);
|
||||
}
|
||||
@Before
|
||||
public void setup() {
|
||||
idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
|
||||
Espresso.registerIdlingResources(idlingResource);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetVisibility() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
@Test
|
||||
public void testSetVisibility() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
Timber.i("Retrieving layer");
|
||||
layer = mapboxMap.getLayerAs("background");
|
||||
Timber.i("visibility");
|
||||
assertNotNull(layer);
|
||||
Timber.i("Retrieving layer");
|
||||
layer = mapboxMap.getLayerAs("background");
|
||||
Timber.i("visibility");
|
||||
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
|
||||
public void testBackgroundColor() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
@Test
|
||||
public void testBackgroundColor() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
Timber.i("Retrieving layer");
|
||||
layer = mapboxMap.getLayerAs("background");
|
||||
Timber.i("background-color");
|
||||
assertNotNull(layer);
|
||||
Timber.i("Retrieving layer");
|
||||
layer = mapboxMap.getLayerAs("background");
|
||||
Timber.i("background-color");
|
||||
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
|
||||
public void testBackgroundColorAsInt() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
@Test
|
||||
public void testBackgroundColorAsInt() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
Timber.i("Retrieving layer");
|
||||
layer = mapboxMap.getLayerAs("background");
|
||||
Timber.i("background-color");
|
||||
assertNotNull(layer);
|
||||
Timber.i("Retrieving layer");
|
||||
layer = mapboxMap.getLayerAs("background");
|
||||
Timber.i("background-color");
|
||||
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
|
||||
public void testBackgroundPattern() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
@Test
|
||||
public void testBackgroundPattern() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
Timber.i("Retrieving layer");
|
||||
layer = mapboxMap.getLayerAs("background");
|
||||
Timber.i("background-pattern");
|
||||
assertNotNull(layer);
|
||||
Timber.i("Retrieving layer");
|
||||
layer = mapboxMap.getLayerAs("background");
|
||||
Timber.i("background-pattern");
|
||||
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
|
||||
public void testBackgroundOpacity() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
@Test
|
||||
public void testBackgroundOpacity() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
Timber.i("Retrieving layer");
|
||||
layer = mapboxMap.getLayerAs("background");
|
||||
Timber.i("background-opacity");
|
||||
assertNotNull(layer);
|
||||
Timber.i("Retrieving layer");
|
||||
layer = mapboxMap.getLayerAs("background");
|
||||
Timber.i("background-opacity");
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
@After
|
||||
public void unregisterIntentServiceIdlingResource() {
|
||||
Espresso.unregisterIdlingResources(idlingResource);
|
||||
}
|
||||
@After
|
||||
public void unregisterIntentServiceIdlingResource() {
|
||||
Espresso.unregisterIdlingResources(idlingResource);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,31 +14,31 @@ import static android.support.test.espresso.matcher.ViewMatchers.withId;
|
||||
*/
|
||||
public class BaseStyleTest {
|
||||
|
||||
protected final static String HOME_BUTTON_STRING = "Navigate up";
|
||||
protected static final String HOME_BUTTON_STRING = "Navigate up";
|
||||
|
||||
/*
|
||||
* Shortcuts for common UI tests
|
||||
*/
|
||||
/*
|
||||
* Shortcuts for common UI tests
|
||||
*/
|
||||
|
||||
protected void checkViewIsDisplayed(int id) {
|
||||
onView(withId(id))
|
||||
.check(matches(isDisplayed()));
|
||||
}
|
||||
protected void checkViewIsDisplayed(int id) {
|
||||
onView(withId(id))
|
||||
.check(matches(isDisplayed()));
|
||||
}
|
||||
|
||||
/*
|
||||
* Screenshots logic
|
||||
*/
|
||||
/*
|
||||
* Screenshots logic
|
||||
*/
|
||||
|
||||
protected void takeNamedScreenshot(final Activity activity, final String name) {
|
||||
protected void takeNamedScreenshot(final Activity activity, final String name) {
|
||||
|
||||
// Screenshots need to be taken on the UI thread
|
||||
activity.runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
ScreenshotUtil.take(activity, name);
|
||||
}
|
||||
});
|
||||
// Screenshots need to be taken on the UI thread
|
||||
activity.runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
ScreenshotUtil.take(activity, name);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make style-code-android`.
|
||||
package com.mapbox.mapboxsdk.testapp.style;
|
||||
// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make style-code-android`.
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.support.test.espresso.Espresso;
|
||||
import android.support.test.rule.ActivityTestRule;
|
||||
import android.support.test.runner.AndroidJUnit4;
|
||||
import timber.log.Timber;
|
||||
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
import com.mapbox.mapboxsdk.style.layers.CircleLayer;
|
||||
@@ -19,9 +18,22 @@ import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static com.mapbox.mapboxsdk.style.layers.Property.*;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*;
|
||||
import timber.log.Timber;
|
||||
|
||||
import static com.mapbox.mapboxsdk.style.layers.Property.CIRCLE_PITCH_SCALE_MAP;
|
||||
import static com.mapbox.mapboxsdk.style.layers.Property.CIRCLE_TRANSLATE_ANCHOR_MAP;
|
||||
import static com.mapbox.mapboxsdk.style.layers.Property.NONE;
|
||||
import static com.mapbox.mapboxsdk.style.layers.Property.VISIBLE;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.circleBlur;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.circleColor;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.circleOpacity;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.circlePitchScale;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.circleRadius;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.circleTranslate;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.circleTranslateAnchor;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.visibility;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
/**
|
||||
* Basic smoke tests for CircleLayer
|
||||
@@ -29,225 +41,225 @@ import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*;
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class CircleLayerStyleTest extends BaseStyleTest {
|
||||
|
||||
@Rule
|
||||
public final ActivityTestRule<RuntimeStyleTestActivity> rule = new ActivityTestRule<>(RuntimeStyleTestActivity.class);
|
||||
@Rule
|
||||
public final ActivityTestRule<RuntimeStyleTestActivity> rule = new ActivityTestRule<>(RuntimeStyleTestActivity.class);
|
||||
|
||||
private CircleLayer layer;
|
||||
private CircleLayer layer;
|
||||
|
||||
private OnMapReadyIdlingResource idlingResource;
|
||||
private OnMapReadyIdlingResource idlingResource;
|
||||
|
||||
private MapboxMap mapboxMap;
|
||||
private MapboxMap mapboxMap;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
|
||||
Espresso.registerIdlingResources(idlingResource);
|
||||
@Before
|
||||
public void setup() {
|
||||
idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
|
||||
Espresso.registerIdlingResources(idlingResource);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetVisibility() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new CircleLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("visibility");
|
||||
assertNotNull(layer);
|
||||
|
||||
@Test
|
||||
public void testSetVisibility() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
//Get initial
|
||||
assertEquals(layer.getVisibility().getValue(), VISIBLE);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
//Set
|
||||
layer.setProperties(visibility(NONE));
|
||||
assertEquals(layer.getVisibility().getValue(), NONE);
|
||||
}
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new CircleLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("visibility");
|
||||
assertNotNull(layer);
|
||||
@Test
|
||||
public void testCircleRadius() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
//Get initial
|
||||
assertEquals(layer.getVisibility().getValue(), VISIBLE);
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
//Set
|
||||
layer.setProperties(visibility(NONE));
|
||||
assertEquals(layer.getVisibility().getValue(), NONE);
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new CircleLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("circle-radius");
|
||||
assertNotNull(layer);
|
||||
|
||||
@Test
|
||||
public void testCircleRadius() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
//Set and Get
|
||||
layer.setProperties(circleRadius(0.3f));
|
||||
assertEquals((Float) layer.getCircleRadius().getValue(), (Float) 0.3f);
|
||||
}
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
@Test
|
||||
public void testCircleColor() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new CircleLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("circle-radius");
|
||||
assertNotNull(layer);
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
//Set and Get
|
||||
layer.setProperties(circleRadius(0.3f));
|
||||
assertEquals((Float) layer.getCircleRadius().getValue(), (Float) 0.3f);
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new CircleLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("circle-color");
|
||||
assertNotNull(layer);
|
||||
|
||||
@Test
|
||||
public void testCircleColor() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
//Set and Get
|
||||
layer.setProperties(circleColor("rgba(0, 0, 0, 1)"));
|
||||
assertEquals((String) layer.getCircleColor().getValue(), (String) "rgba(0, 0, 0, 1)");
|
||||
}
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
@Test
|
||||
public void testCircleColorAsInt() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new CircleLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("circle-color");
|
||||
assertNotNull(layer);
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
//Set and Get
|
||||
layer.setProperties(circleColor("rgba(0, 0, 0, 1)"));
|
||||
assertEquals((String) layer.getCircleColor().getValue(), (String) "rgba(0, 0, 0, 1)");
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new CircleLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("circle-color");
|
||||
assertNotNull(layer);
|
||||
|
||||
@Test
|
||||
public void testCircleColorAsInt() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
//Set and Get
|
||||
layer.setProperties(circleColor(Color.RED));
|
||||
assertEquals(layer.getCircleColorAsInt(), Color.RED);
|
||||
}
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
@Test
|
||||
public void testCircleBlur() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new CircleLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("circle-color");
|
||||
assertNotNull(layer);
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
//Set and Get
|
||||
layer.setProperties(circleColor(Color.RED));
|
||||
assertEquals(layer.getCircleColorAsInt(), Color.RED);
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new CircleLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("circle-blur");
|
||||
assertNotNull(layer);
|
||||
|
||||
@Test
|
||||
public void testCircleBlur() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
//Set and Get
|
||||
layer.setProperties(circleBlur(0.3f));
|
||||
assertEquals((Float) layer.getCircleBlur().getValue(), (Float) 0.3f);
|
||||
}
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
@Test
|
||||
public void testCircleOpacity() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new CircleLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("circle-blur");
|
||||
assertNotNull(layer);
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
//Set and Get
|
||||
layer.setProperties(circleBlur(0.3f));
|
||||
assertEquals((Float) layer.getCircleBlur().getValue(), (Float) 0.3f);
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new CircleLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("circle-opacity");
|
||||
assertNotNull(layer);
|
||||
|
||||
@Test
|
||||
public void testCircleOpacity() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
//Set and Get
|
||||
layer.setProperties(circleOpacity(0.3f));
|
||||
assertEquals((Float) layer.getCircleOpacity().getValue(), (Float) 0.3f);
|
||||
}
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
@Test
|
||||
public void testCircleTranslate() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new CircleLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("circle-opacity");
|
||||
assertNotNull(layer);
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
//Set and Get
|
||||
layer.setProperties(circleOpacity(0.3f));
|
||||
assertEquals((Float) layer.getCircleOpacity().getValue(), (Float) 0.3f);
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new CircleLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("circle-translate");
|
||||
assertNotNull(layer);
|
||||
|
||||
@Test
|
||||
public void testCircleTranslate() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
//Set and Get
|
||||
layer.setProperties(circleTranslate(new Float[] {0f, 0f}));
|
||||
assertEquals((Float[]) layer.getCircleTranslate().getValue(), (Float[]) new Float[] {0f, 0f});
|
||||
}
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
@Test
|
||||
public void testCircleTranslateAnchor() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new CircleLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("circle-translate");
|
||||
assertNotNull(layer);
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
//Set and Get
|
||||
layer.setProperties(circleTranslate(new Float[]{0f,0f}));
|
||||
assertEquals((Float[]) layer.getCircleTranslate().getValue(), (Float[]) new Float[]{0f,0f});
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new CircleLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("circle-translate-anchor");
|
||||
assertNotNull(layer);
|
||||
|
||||
@Test
|
||||
public void testCircleTranslateAnchor() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
//Set and Get
|
||||
layer.setProperties(circleTranslateAnchor(CIRCLE_TRANSLATE_ANCHOR_MAP));
|
||||
assertEquals((String) layer.getCircleTranslateAnchor().getValue(), (String) CIRCLE_TRANSLATE_ANCHOR_MAP);
|
||||
}
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
@Test
|
||||
public void testCirclePitchScale() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new CircleLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("circle-translate-anchor");
|
||||
assertNotNull(layer);
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
//Set and Get
|
||||
layer.setProperties(circleTranslateAnchor(CIRCLE_TRANSLATE_ANCHOR_MAP));
|
||||
assertEquals((String) layer.getCircleTranslateAnchor().getValue(), (String) CIRCLE_TRANSLATE_ANCHOR_MAP);
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new CircleLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("circle-pitch-scale");
|
||||
assertNotNull(layer);
|
||||
|
||||
@Test
|
||||
public void testCirclePitchScale() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new CircleLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("circle-pitch-scale");
|
||||
assertNotNull(layer);
|
||||
|
||||
//Set and Get
|
||||
layer.setProperties(circlePitchScale(CIRCLE_PITCH_SCALE_MAP));
|
||||
assertEquals((String) layer.getCirclePitchScale().getValue(), (String) CIRCLE_PITCH_SCALE_MAP);
|
||||
}
|
||||
//Set and Get
|
||||
layer.setProperties(circlePitchScale(CIRCLE_PITCH_SCALE_MAP));
|
||||
assertEquals((String) layer.getCirclePitchScale().getValue(), (String) CIRCLE_PITCH_SCALE_MAP);
|
||||
}
|
||||
|
||||
|
||||
@After
|
||||
public void unregisterIntentServiceIdlingResource() {
|
||||
Espresso.unregisterIdlingResources(idlingResource);
|
||||
}
|
||||
@After
|
||||
public void unregisterIntentServiceIdlingResource() {
|
||||
Espresso.unregisterIdlingResources(idlingResource);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make android-style-code`.
|
||||
package com.mapbox.mapboxsdk.testapp.style;
|
||||
// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make android-style-code`.
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.support.test.espresso.Espresso;
|
||||
import android.support.test.rule.ActivityTestRule;
|
||||
import android.support.test.runner.AndroidJUnit4;
|
||||
import timber.log.Timber;
|
||||
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
import com.mapbox.mapboxsdk.style.layers.CircleLayer;
|
||||
@@ -19,9 +18,25 @@ import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static com.mapbox.mapboxsdk.style.layers.Property.*;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*;
|
||||
import timber.log.Timber;
|
||||
|
||||
import static com.mapbox.mapboxsdk.style.layers.Property.CIRCLE_PITCH_SCALE_MAP;
|
||||
import static com.mapbox.mapboxsdk.style.layers.Property.CIRCLE_TRANSLATE_ANCHOR_MAP;
|
||||
import static com.mapbox.mapboxsdk.style.layers.Property.NONE;
|
||||
import static com.mapbox.mapboxsdk.style.layers.Property.VISIBLE;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.circleBlur;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.circleColor;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.circleOpacity;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.circlePitchScale;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.circleRadius;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.circleStrokeColor;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.circleStrokeOpacity;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.circleStrokeWidth;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.circleTranslate;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.circleTranslateAnchor;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.visibility;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
/**
|
||||
* Basic smoke tests for CircleLayer
|
||||
@@ -29,313 +44,313 @@ import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*;
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class CircleLayerTest extends BaseStyleTest {
|
||||
|
||||
@Rule
|
||||
public final ActivityTestRule<RuntimeStyleTestActivity> rule = new ActivityTestRule<>(RuntimeStyleTestActivity.class);
|
||||
@Rule
|
||||
public final ActivityTestRule<RuntimeStyleTestActivity> rule = new ActivityTestRule<>(RuntimeStyleTestActivity.class);
|
||||
|
||||
private CircleLayer layer;
|
||||
private CircleLayer layer;
|
||||
|
||||
private OnMapReadyIdlingResource idlingResource;
|
||||
private OnMapReadyIdlingResource idlingResource;
|
||||
|
||||
private MapboxMap mapboxMap;
|
||||
private MapboxMap mapboxMap;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
|
||||
Espresso.registerIdlingResources(idlingResource);
|
||||
@Before
|
||||
public void setup() {
|
||||
idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
|
||||
Espresso.registerIdlingResources(idlingResource);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetVisibility() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new CircleLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("visibility");
|
||||
assertNotNull(layer);
|
||||
|
||||
@Test
|
||||
public void testSetVisibility() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
//Get initial
|
||||
assertEquals(layer.getVisibility().getValue(), VISIBLE);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
//Set
|
||||
layer.setProperties(visibility(NONE));
|
||||
assertEquals(layer.getVisibility().getValue(), NONE);
|
||||
}
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new CircleLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("visibility");
|
||||
assertNotNull(layer);
|
||||
@Test
|
||||
public void testCircleRadius() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
//Get initial
|
||||
assertEquals(layer.getVisibility().getValue(), VISIBLE);
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
//Set
|
||||
layer.setProperties(visibility(NONE));
|
||||
assertEquals(layer.getVisibility().getValue(), NONE);
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new CircleLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("circle-radius");
|
||||
assertNotNull(layer);
|
||||
|
||||
@Test
|
||||
public void testCircleRadius() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
//Set and Get
|
||||
layer.setProperties(circleRadius(0.3f));
|
||||
assertEquals((Float) layer.getCircleRadius().getValue(), (Float) 0.3f);
|
||||
}
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
@Test
|
||||
public void testCircleColor() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new CircleLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("circle-radius");
|
||||
assertNotNull(layer);
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
//Set and Get
|
||||
layer.setProperties(circleRadius(0.3f));
|
||||
assertEquals((Float) layer.getCircleRadius().getValue(), (Float) 0.3f);
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new CircleLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("circle-color");
|
||||
assertNotNull(layer);
|
||||
|
||||
@Test
|
||||
public void testCircleColor() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
//Set and Get
|
||||
layer.setProperties(circleColor("rgba(0, 0, 0, 1)"));
|
||||
assertEquals((String) layer.getCircleColor().getValue(), (String) "rgba(0, 0, 0, 1)");
|
||||
}
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
@Test
|
||||
public void testCircleColorAsInt() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new CircleLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("circle-color");
|
||||
assertNotNull(layer);
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
//Set and Get
|
||||
layer.setProperties(circleColor("rgba(0, 0, 0, 1)"));
|
||||
assertEquals((String) layer.getCircleColor().getValue(), (String) "rgba(0, 0, 0, 1)");
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new CircleLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("circle-color");
|
||||
assertNotNull(layer);
|
||||
|
||||
@Test
|
||||
public void testCircleColorAsInt() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
//Set and Get
|
||||
layer.setProperties(circleColor(Color.RED));
|
||||
assertEquals(layer.getCircleColorAsInt(), Color.RED);
|
||||
}
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
@Test
|
||||
public void testCircleBlur() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new CircleLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("circle-color");
|
||||
assertNotNull(layer);
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
//Set and Get
|
||||
layer.setProperties(circleColor(Color.RED));
|
||||
assertEquals(layer.getCircleColorAsInt(), Color.RED);
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new CircleLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("circle-blur");
|
||||
assertNotNull(layer);
|
||||
|
||||
@Test
|
||||
public void testCircleBlur() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
//Set and Get
|
||||
layer.setProperties(circleBlur(0.3f));
|
||||
assertEquals((Float) layer.getCircleBlur().getValue(), (Float) 0.3f);
|
||||
}
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
@Test
|
||||
public void testCircleOpacity() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new CircleLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("circle-blur");
|
||||
assertNotNull(layer);
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
//Set and Get
|
||||
layer.setProperties(circleBlur(0.3f));
|
||||
assertEquals((Float) layer.getCircleBlur().getValue(), (Float) 0.3f);
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new CircleLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("circle-opacity");
|
||||
assertNotNull(layer);
|
||||
|
||||
@Test
|
||||
public void testCircleOpacity() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
//Set and Get
|
||||
layer.setProperties(circleOpacity(0.3f));
|
||||
assertEquals((Float) layer.getCircleOpacity().getValue(), (Float) 0.3f);
|
||||
}
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
@Test
|
||||
public void testCircleTranslate() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new CircleLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("circle-opacity");
|
||||
assertNotNull(layer);
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
//Set and Get
|
||||
layer.setProperties(circleOpacity(0.3f));
|
||||
assertEquals((Float) layer.getCircleOpacity().getValue(), (Float) 0.3f);
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new CircleLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("circle-translate");
|
||||
assertNotNull(layer);
|
||||
|
||||
@Test
|
||||
public void testCircleTranslate() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
//Set and Get
|
||||
layer.setProperties(circleTranslate(new Float[] {0f, 0f}));
|
||||
assertEquals((Float[]) layer.getCircleTranslate().getValue(), (Float[]) new Float[] {0f, 0f});
|
||||
}
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
@Test
|
||||
public void testCircleTranslateAnchor() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new CircleLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("circle-translate");
|
||||
assertNotNull(layer);
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
//Set and Get
|
||||
layer.setProperties(circleTranslate(new Float[]{0f,0f}));
|
||||
assertEquals((Float[]) layer.getCircleTranslate().getValue(), (Float[]) new Float[]{0f,0f});
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new CircleLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("circle-translate-anchor");
|
||||
assertNotNull(layer);
|
||||
|
||||
@Test
|
||||
public void testCircleTranslateAnchor() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
//Set and Get
|
||||
layer.setProperties(circleTranslateAnchor(CIRCLE_TRANSLATE_ANCHOR_MAP));
|
||||
assertEquals((String) layer.getCircleTranslateAnchor().getValue(), (String) CIRCLE_TRANSLATE_ANCHOR_MAP);
|
||||
}
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
@Test
|
||||
public void testCirclePitchScale() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new CircleLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("circle-translate-anchor");
|
||||
assertNotNull(layer);
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
//Set and Get
|
||||
layer.setProperties(circleTranslateAnchor(CIRCLE_TRANSLATE_ANCHOR_MAP));
|
||||
assertEquals((String) layer.getCircleTranslateAnchor().getValue(), (String) CIRCLE_TRANSLATE_ANCHOR_MAP);
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new CircleLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("circle-pitch-scale");
|
||||
assertNotNull(layer);
|
||||
|
||||
@Test
|
||||
public void testCirclePitchScale() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
//Set and Get
|
||||
layer.setProperties(circlePitchScale(CIRCLE_PITCH_SCALE_MAP));
|
||||
assertEquals((String) layer.getCirclePitchScale().getValue(), (String) CIRCLE_PITCH_SCALE_MAP);
|
||||
}
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
@Test
|
||||
public void testCircleStrokeWidth() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new CircleLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("circle-pitch-scale");
|
||||
assertNotNull(layer);
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
//Set and Get
|
||||
layer.setProperties(circlePitchScale(CIRCLE_PITCH_SCALE_MAP));
|
||||
assertEquals((String) layer.getCirclePitchScale().getValue(), (String) CIRCLE_PITCH_SCALE_MAP);
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new CircleLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("circle-stroke-width");
|
||||
assertNotNull(layer);
|
||||
|
||||
@Test
|
||||
public void testCircleStrokeWidth() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
//Set and Get
|
||||
layer.setProperties(circleStrokeWidth(0.3f));
|
||||
assertEquals((Float) layer.getCircleStrokeWidth().getValue(), (Float) 0.3f);
|
||||
}
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
@Test
|
||||
public void testCircleStrokeColor() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new CircleLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("circle-stroke-width");
|
||||
assertNotNull(layer);
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
//Set and Get
|
||||
layer.setProperties(circleStrokeWidth(0.3f));
|
||||
assertEquals((Float) layer.getCircleStrokeWidth().getValue(), (Float) 0.3f);
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new CircleLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("circle-stroke-color");
|
||||
assertNotNull(layer);
|
||||
|
||||
@Test
|
||||
public void testCircleStrokeColor() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
//Set and Get
|
||||
layer.setProperties(circleStrokeColor("rgba(0, 0, 0, 1)"));
|
||||
assertEquals((String) layer.getCircleStrokeColor().getValue(), (String) "rgba(0, 0, 0, 1)");
|
||||
}
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
@Test
|
||||
public void testCircleStrokeColorAsInt() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new CircleLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("circle-stroke-color");
|
||||
assertNotNull(layer);
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
//Set and Get
|
||||
layer.setProperties(circleStrokeColor("rgba(0, 0, 0, 1)"));
|
||||
assertEquals((String) layer.getCircleStrokeColor().getValue(), (String) "rgba(0, 0, 0, 1)");
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new CircleLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("circle-stroke-color");
|
||||
assertNotNull(layer);
|
||||
|
||||
@Test
|
||||
public void testCircleStrokeColorAsInt() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
//Set and Get
|
||||
layer.setProperties(circleStrokeColor(Color.RED));
|
||||
assertEquals(layer.getCircleStrokeColorAsInt(), Color.RED);
|
||||
}
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
@Test
|
||||
public void testCircleStrokeOpacity() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new CircleLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("circle-stroke-color");
|
||||
assertNotNull(layer);
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
//Set and Get
|
||||
layer.setProperties(circleStrokeColor(Color.RED));
|
||||
assertEquals(layer.getCircleStrokeColorAsInt(), Color.RED);
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new CircleLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("circle-stroke-opacity");
|
||||
assertNotNull(layer);
|
||||
|
||||
@Test
|
||||
public void testCircleStrokeOpacity() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new CircleLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("circle-stroke-opacity");
|
||||
assertNotNull(layer);
|
||||
|
||||
//Set and Get
|
||||
layer.setProperties(circleStrokeOpacity(0.3f));
|
||||
assertEquals((Float) layer.getCircleStrokeOpacity().getValue(), (Float) 0.3f);
|
||||
}
|
||||
//Set and Get
|
||||
layer.setProperties(circleStrokeOpacity(0.3f));
|
||||
assertEquals((Float) layer.getCircleStrokeOpacity().getValue(), (Float) 0.3f);
|
||||
}
|
||||
|
||||
|
||||
@After
|
||||
public void unregisterIntentServiceIdlingResource() {
|
||||
Espresso.unregisterIdlingResources(idlingResource);
|
||||
}
|
||||
@After
|
||||
public void unregisterIntentServiceIdlingResource() {
|
||||
Espresso.unregisterIdlingResources(idlingResource);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make style-code-android`.
|
||||
package com.mapbox.mapboxsdk.testapp.style;
|
||||
// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make style-code-android`.
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.support.test.espresso.Espresso;
|
||||
import android.support.test.rule.ActivityTestRule;
|
||||
import android.support.test.runner.AndroidJUnit4;
|
||||
import timber.log.Timber;
|
||||
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
import com.mapbox.mapboxsdk.style.layers.FillLayer;
|
||||
@@ -19,9 +18,21 @@ import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static com.mapbox.mapboxsdk.style.layers.Property.*;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*;
|
||||
import timber.log.Timber;
|
||||
|
||||
import static com.mapbox.mapboxsdk.style.layers.Property.FILL_TRANSLATE_ANCHOR_MAP;
|
||||
import static com.mapbox.mapboxsdk.style.layers.Property.NONE;
|
||||
import static com.mapbox.mapboxsdk.style.layers.Property.VISIBLE;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillAntialias;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillColor;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillOpacity;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillOutlineColor;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillPattern;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillTranslate;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillTranslateAnchor;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.visibility;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
/**
|
||||
* Basic smoke tests for FillLayer
|
||||
@@ -29,247 +40,247 @@ import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*;
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class FillLayerStyleTest extends BaseStyleTest {
|
||||
|
||||
@Rule
|
||||
public final ActivityTestRule<RuntimeStyleTestActivity> rule = new ActivityTestRule<>(RuntimeStyleTestActivity.class);
|
||||
@Rule
|
||||
public final ActivityTestRule<RuntimeStyleTestActivity> rule = new ActivityTestRule<>(RuntimeStyleTestActivity.class);
|
||||
|
||||
private FillLayer layer;
|
||||
private FillLayer layer;
|
||||
|
||||
private OnMapReadyIdlingResource idlingResource;
|
||||
private OnMapReadyIdlingResource idlingResource;
|
||||
|
||||
private MapboxMap mapboxMap;
|
||||
private MapboxMap mapboxMap;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
|
||||
Espresso.registerIdlingResources(idlingResource);
|
||||
@Before
|
||||
public void setup() {
|
||||
idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
|
||||
Espresso.registerIdlingResources(idlingResource);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetVisibility() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new FillLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("visibility");
|
||||
assertNotNull(layer);
|
||||
|
||||
@Test
|
||||
public void testSetVisibility() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
//Get initial
|
||||
assertEquals(layer.getVisibility().getValue(), VISIBLE);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
//Set
|
||||
layer.setProperties(visibility(NONE));
|
||||
assertEquals(layer.getVisibility().getValue(), NONE);
|
||||
}
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new FillLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("visibility");
|
||||
assertNotNull(layer);
|
||||
@Test
|
||||
public void testFillAntialias() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
//Get initial
|
||||
assertEquals(layer.getVisibility().getValue(), VISIBLE);
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
//Set
|
||||
layer.setProperties(visibility(NONE));
|
||||
assertEquals(layer.getVisibility().getValue(), NONE);
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new FillLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("fill-antialias");
|
||||
assertNotNull(layer);
|
||||
|
||||
@Test
|
||||
public void testFillAntialias() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
//Set and Get
|
||||
layer.setProperties(fillAntialias(true));
|
||||
assertEquals((Boolean) layer.getFillAntialias().getValue(), (Boolean) true);
|
||||
}
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
@Test
|
||||
public void testFillOpacity() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new FillLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("fill-antialias");
|
||||
assertNotNull(layer);
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
//Set and Get
|
||||
layer.setProperties(fillAntialias(true));
|
||||
assertEquals((Boolean) layer.getFillAntialias().getValue(), (Boolean) true);
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new FillLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("fill-opacity");
|
||||
assertNotNull(layer);
|
||||
|
||||
@Test
|
||||
public void testFillOpacity() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
//Set and Get
|
||||
layer.setProperties(fillOpacity(0.3f));
|
||||
assertEquals((Float) layer.getFillOpacity().getValue(), (Float) 0.3f);
|
||||
}
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
@Test
|
||||
public void testFillColor() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new FillLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("fill-opacity");
|
||||
assertNotNull(layer);
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
//Set and Get
|
||||
layer.setProperties(fillOpacity(0.3f));
|
||||
assertEquals((Float) layer.getFillOpacity().getValue(), (Float) 0.3f);
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new FillLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("fill-color");
|
||||
assertNotNull(layer);
|
||||
|
||||
@Test
|
||||
public void testFillColor() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
//Set and Get
|
||||
layer.setProperties(fillColor("rgba(0, 0, 0, 1)"));
|
||||
assertEquals((String) layer.getFillColor().getValue(), (String) "rgba(0, 0, 0, 1)");
|
||||
}
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
@Test
|
||||
public void testFillColorAsInt() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new FillLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("fill-color");
|
||||
assertNotNull(layer);
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
//Set and Get
|
||||
layer.setProperties(fillColor("rgba(0, 0, 0, 1)"));
|
||||
assertEquals((String) layer.getFillColor().getValue(), (String) "rgba(0, 0, 0, 1)");
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new FillLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("fill-color");
|
||||
assertNotNull(layer);
|
||||
|
||||
@Test
|
||||
public void testFillColorAsInt() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
//Set and Get
|
||||
layer.setProperties(fillColor(Color.RED));
|
||||
assertEquals(layer.getFillColorAsInt(), Color.RED);
|
||||
}
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
@Test
|
||||
public void testFillOutlineColor() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new FillLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("fill-color");
|
||||
assertNotNull(layer);
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
//Set and Get
|
||||
layer.setProperties(fillColor(Color.RED));
|
||||
assertEquals(layer.getFillColorAsInt(), Color.RED);
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new FillLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("fill-outline-color");
|
||||
assertNotNull(layer);
|
||||
|
||||
@Test
|
||||
public void testFillOutlineColor() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
//Set and Get
|
||||
layer.setProperties(fillOutlineColor("rgba(0, 0, 0, 1)"));
|
||||
assertEquals((String) layer.getFillOutlineColor().getValue(), (String) "rgba(0, 0, 0, 1)");
|
||||
}
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
@Test
|
||||
public void testFillOutlineColorAsInt() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new FillLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("fill-outline-color");
|
||||
assertNotNull(layer);
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
//Set and Get
|
||||
layer.setProperties(fillOutlineColor("rgba(0, 0, 0, 1)"));
|
||||
assertEquals((String) layer.getFillOutlineColor().getValue(), (String) "rgba(0, 0, 0, 1)");
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new FillLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("fill-outline-color");
|
||||
assertNotNull(layer);
|
||||
|
||||
@Test
|
||||
public void testFillOutlineColorAsInt() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
//Set and Get
|
||||
layer.setProperties(fillOutlineColor(Color.RED));
|
||||
assertEquals(layer.getFillOutlineColorAsInt(), Color.RED);
|
||||
}
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
@Test
|
||||
public void testFillTranslate() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new FillLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("fill-outline-color");
|
||||
assertNotNull(layer);
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
//Set and Get
|
||||
layer.setProperties(fillOutlineColor(Color.RED));
|
||||
assertEquals(layer.getFillOutlineColorAsInt(), Color.RED);
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new FillLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("fill-translate");
|
||||
assertNotNull(layer);
|
||||
|
||||
@Test
|
||||
public void testFillTranslate() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
//Set and Get
|
||||
layer.setProperties(fillTranslate(new Float[] {0f, 0f}));
|
||||
assertEquals((Float[]) layer.getFillTranslate().getValue(), (Float[]) new Float[] {0f, 0f});
|
||||
}
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
@Test
|
||||
public void testFillTranslateAnchor() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new FillLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("fill-translate");
|
||||
assertNotNull(layer);
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
//Set and Get
|
||||
layer.setProperties(fillTranslate(new Float[]{0f,0f}));
|
||||
assertEquals((Float[]) layer.getFillTranslate().getValue(), (Float[]) new Float[]{0f,0f});
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new FillLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("fill-translate-anchor");
|
||||
assertNotNull(layer);
|
||||
|
||||
@Test
|
||||
public void testFillTranslateAnchor() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
//Set and Get
|
||||
layer.setProperties(fillTranslateAnchor(FILL_TRANSLATE_ANCHOR_MAP));
|
||||
assertEquals((String) layer.getFillTranslateAnchor().getValue(), (String) FILL_TRANSLATE_ANCHOR_MAP);
|
||||
}
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
@Test
|
||||
public void testFillPattern() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new FillLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("fill-translate-anchor");
|
||||
assertNotNull(layer);
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
//Set and Get
|
||||
layer.setProperties(fillTranslateAnchor(FILL_TRANSLATE_ANCHOR_MAP));
|
||||
assertEquals((String) layer.getFillTranslateAnchor().getValue(), (String) FILL_TRANSLATE_ANCHOR_MAP);
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new FillLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("fill-pattern");
|
||||
assertNotNull(layer);
|
||||
|
||||
@Test
|
||||
public void testFillPattern() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new FillLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("fill-pattern");
|
||||
assertNotNull(layer);
|
||||
|
||||
//Set and Get
|
||||
layer.setProperties(fillPattern("pedestrian-polygon"));
|
||||
assertEquals((String) layer.getFillPattern().getValue(), (String) "pedestrian-polygon");
|
||||
}
|
||||
//Set and Get
|
||||
layer.setProperties(fillPattern("pedestrian-polygon"));
|
||||
assertEquals((String) layer.getFillPattern().getValue(), (String) "pedestrian-polygon");
|
||||
}
|
||||
|
||||
|
||||
@After
|
||||
public void unregisterIntentServiceIdlingResource() {
|
||||
Espresso.unregisterIdlingResources(idlingResource);
|
||||
}
|
||||
@After
|
||||
public void unregisterIntentServiceIdlingResource() {
|
||||
Espresso.unregisterIdlingResources(idlingResource);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make android-style-code`.
|
||||
package com.mapbox.mapboxsdk.testapp.style;
|
||||
// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make android-style-code`.
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.support.test.espresso.Espresso;
|
||||
import android.support.test.rule.ActivityTestRule;
|
||||
import android.support.test.runner.AndroidJUnit4;
|
||||
import timber.log.Timber;
|
||||
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
import com.mapbox.mapboxsdk.style.layers.FillLayer;
|
||||
@@ -19,9 +18,21 @@ import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static com.mapbox.mapboxsdk.style.layers.Property.*;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*;
|
||||
import timber.log.Timber;
|
||||
|
||||
import static com.mapbox.mapboxsdk.style.layers.Property.FILL_TRANSLATE_ANCHOR_MAP;
|
||||
import static com.mapbox.mapboxsdk.style.layers.Property.NONE;
|
||||
import static com.mapbox.mapboxsdk.style.layers.Property.VISIBLE;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillAntialias;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillColor;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillOpacity;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillOutlineColor;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillPattern;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillTranslate;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillTranslateAnchor;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.visibility;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
/**
|
||||
* Basic smoke tests for FillLayer
|
||||
@@ -29,247 +40,247 @@ import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*;
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class FillLayerTest extends BaseStyleTest {
|
||||
|
||||
@Rule
|
||||
public final ActivityTestRule<RuntimeStyleTestActivity> rule = new ActivityTestRule<>(RuntimeStyleTestActivity.class);
|
||||
@Rule
|
||||
public final ActivityTestRule<RuntimeStyleTestActivity> rule = new ActivityTestRule<>(RuntimeStyleTestActivity.class);
|
||||
|
||||
private FillLayer layer;
|
||||
private FillLayer layer;
|
||||
|
||||
private OnMapReadyIdlingResource idlingResource;
|
||||
private OnMapReadyIdlingResource idlingResource;
|
||||
|
||||
private MapboxMap mapboxMap;
|
||||
private MapboxMap mapboxMap;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
|
||||
Espresso.registerIdlingResources(idlingResource);
|
||||
@Before
|
||||
public void setup() {
|
||||
idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
|
||||
Espresso.registerIdlingResources(idlingResource);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetVisibility() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new FillLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("visibility");
|
||||
assertNotNull(layer);
|
||||
|
||||
@Test
|
||||
public void testSetVisibility() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
//Get initial
|
||||
assertEquals(layer.getVisibility().getValue(), VISIBLE);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
//Set
|
||||
layer.setProperties(visibility(NONE));
|
||||
assertEquals(layer.getVisibility().getValue(), NONE);
|
||||
}
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new FillLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("visibility");
|
||||
assertNotNull(layer);
|
||||
@Test
|
||||
public void testFillAntialias() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
//Get initial
|
||||
assertEquals(layer.getVisibility().getValue(), VISIBLE);
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
//Set
|
||||
layer.setProperties(visibility(NONE));
|
||||
assertEquals(layer.getVisibility().getValue(), NONE);
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new FillLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("fill-antialias");
|
||||
assertNotNull(layer);
|
||||
|
||||
@Test
|
||||
public void testFillAntialias() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
//Set and Get
|
||||
layer.setProperties(fillAntialias(true));
|
||||
assertEquals((Boolean) layer.getFillAntialias().getValue(), (Boolean) true);
|
||||
}
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
@Test
|
||||
public void testFillOpacity() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new FillLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("fill-antialias");
|
||||
assertNotNull(layer);
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
//Set and Get
|
||||
layer.setProperties(fillAntialias(true));
|
||||
assertEquals((Boolean) layer.getFillAntialias().getValue(), (Boolean) true);
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new FillLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("fill-opacity");
|
||||
assertNotNull(layer);
|
||||
|
||||
@Test
|
||||
public void testFillOpacity() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
//Set and Get
|
||||
layer.setProperties(fillOpacity(0.3f));
|
||||
assertEquals((Float) layer.getFillOpacity().getValue(), (Float) 0.3f);
|
||||
}
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
@Test
|
||||
public void testFillColor() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new FillLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("fill-opacity");
|
||||
assertNotNull(layer);
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
//Set and Get
|
||||
layer.setProperties(fillOpacity(0.3f));
|
||||
assertEquals((Float) layer.getFillOpacity().getValue(), (Float) 0.3f);
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new FillLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("fill-color");
|
||||
assertNotNull(layer);
|
||||
|
||||
@Test
|
||||
public void testFillColor() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
//Set and Get
|
||||
layer.setProperties(fillColor("rgba(0, 0, 0, 1)"));
|
||||
assertEquals((String) layer.getFillColor().getValue(), (String) "rgba(0, 0, 0, 1)");
|
||||
}
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
@Test
|
||||
public void testFillColorAsInt() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new FillLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("fill-color");
|
||||
assertNotNull(layer);
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
//Set and Get
|
||||
layer.setProperties(fillColor("rgba(0, 0, 0, 1)"));
|
||||
assertEquals((String) layer.getFillColor().getValue(), (String) "rgba(0, 0, 0, 1)");
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new FillLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("fill-color");
|
||||
assertNotNull(layer);
|
||||
|
||||
@Test
|
||||
public void testFillColorAsInt() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
//Set and Get
|
||||
layer.setProperties(fillColor(Color.RED));
|
||||
assertEquals(layer.getFillColorAsInt(), Color.RED);
|
||||
}
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
@Test
|
||||
public void testFillOutlineColor() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new FillLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("fill-color");
|
||||
assertNotNull(layer);
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
//Set and Get
|
||||
layer.setProperties(fillColor(Color.RED));
|
||||
assertEquals(layer.getFillColorAsInt(), Color.RED);
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new FillLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("fill-outline-color");
|
||||
assertNotNull(layer);
|
||||
|
||||
@Test
|
||||
public void testFillOutlineColor() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
//Set and Get
|
||||
layer.setProperties(fillOutlineColor("rgba(0, 0, 0, 1)"));
|
||||
assertEquals((String) layer.getFillOutlineColor().getValue(), (String) "rgba(0, 0, 0, 1)");
|
||||
}
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
@Test
|
||||
public void testFillOutlineColorAsInt() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new FillLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("fill-outline-color");
|
||||
assertNotNull(layer);
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
//Set and Get
|
||||
layer.setProperties(fillOutlineColor("rgba(0, 0, 0, 1)"));
|
||||
assertEquals((String) layer.getFillOutlineColor().getValue(), (String) "rgba(0, 0, 0, 1)");
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new FillLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("fill-outline-color");
|
||||
assertNotNull(layer);
|
||||
|
||||
@Test
|
||||
public void testFillOutlineColorAsInt() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
//Set and Get
|
||||
layer.setProperties(fillOutlineColor(Color.RED));
|
||||
assertEquals(layer.getFillOutlineColorAsInt(), Color.RED);
|
||||
}
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
@Test
|
||||
public void testFillTranslate() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new FillLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("fill-outline-color");
|
||||
assertNotNull(layer);
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
//Set and Get
|
||||
layer.setProperties(fillOutlineColor(Color.RED));
|
||||
assertEquals(layer.getFillOutlineColorAsInt(), Color.RED);
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new FillLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("fill-translate");
|
||||
assertNotNull(layer);
|
||||
|
||||
@Test
|
||||
public void testFillTranslate() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
//Set and Get
|
||||
layer.setProperties(fillTranslate(new Float[] {0f, 0f}));
|
||||
assertEquals((Float[]) layer.getFillTranslate().getValue(), (Float[]) new Float[] {0f, 0f});
|
||||
}
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
@Test
|
||||
public void testFillTranslateAnchor() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new FillLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("fill-translate");
|
||||
assertNotNull(layer);
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
//Set and Get
|
||||
layer.setProperties(fillTranslate(new Float[]{0f,0f}));
|
||||
assertEquals((Float[]) layer.getFillTranslate().getValue(), (Float[]) new Float[]{0f,0f});
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new FillLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("fill-translate-anchor");
|
||||
assertNotNull(layer);
|
||||
|
||||
@Test
|
||||
public void testFillTranslateAnchor() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
//Set and Get
|
||||
layer.setProperties(fillTranslateAnchor(FILL_TRANSLATE_ANCHOR_MAP));
|
||||
assertEquals((String) layer.getFillTranslateAnchor().getValue(), (String) FILL_TRANSLATE_ANCHOR_MAP);
|
||||
}
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
@Test
|
||||
public void testFillPattern() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new FillLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("fill-translate-anchor");
|
||||
assertNotNull(layer);
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
//Set and Get
|
||||
layer.setProperties(fillTranslateAnchor(FILL_TRANSLATE_ANCHOR_MAP));
|
||||
assertEquals((String) layer.getFillTranslateAnchor().getValue(), (String) FILL_TRANSLATE_ANCHOR_MAP);
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new FillLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("fill-pattern");
|
||||
assertNotNull(layer);
|
||||
|
||||
@Test
|
||||
public void testFillPattern() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new FillLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("fill-pattern");
|
||||
assertNotNull(layer);
|
||||
|
||||
//Set and Get
|
||||
layer.setProperties(fillPattern("pedestrian-polygon"));
|
||||
assertEquals((String) layer.getFillPattern().getValue(), (String) "pedestrian-polygon");
|
||||
}
|
||||
//Set and Get
|
||||
layer.setProperties(fillPattern("pedestrian-polygon"));
|
||||
assertEquals((String) layer.getFillPattern().getValue(), (String) "pedestrian-polygon");
|
||||
}
|
||||
|
||||
|
||||
@After
|
||||
public void unregisterIntentServiceIdlingResource() {
|
||||
Espresso.unregisterIdlingResources(idlingResource);
|
||||
}
|
||||
@After
|
||||
public void unregisterIntentServiceIdlingResource() {
|
||||
Espresso.unregisterIdlingResources(idlingResource);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make style-code-android`.
|
||||
package com.mapbox.mapboxsdk.testapp.style;
|
||||
// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make style-code-android`.
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.support.test.espresso.Espresso;
|
||||
import android.support.test.rule.ActivityTestRule;
|
||||
import android.support.test.runner.AndroidJUnit4;
|
||||
import timber.log.Timber;
|
||||
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
import com.mapbox.mapboxsdk.style.layers.LineLayer;
|
||||
@@ -19,9 +18,30 @@ import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static com.mapbox.mapboxsdk.style.layers.Property.*;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*;
|
||||
import timber.log.Timber;
|
||||
|
||||
import static com.mapbox.mapboxsdk.style.layers.Property.LINE_CAP_BUTT;
|
||||
import static com.mapbox.mapboxsdk.style.layers.Property.LINE_JOIN_BEVEL;
|
||||
import static com.mapbox.mapboxsdk.style.layers.Property.LINE_TRANSLATE_ANCHOR_MAP;
|
||||
import static com.mapbox.mapboxsdk.style.layers.Property.NONE;
|
||||
import static com.mapbox.mapboxsdk.style.layers.Property.VISIBLE;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineBlur;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineCap;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineColor;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineDasharray;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineGapWidth;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineJoin;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineMiterLimit;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineOffset;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineOpacity;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.linePattern;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineRoundLimit;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineTranslate;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineTranslateAnchor;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineWidth;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.visibility;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
/**
|
||||
* Basic smoke tests for LineLayer
|
||||
@@ -29,379 +49,379 @@ import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*;
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class LineLayerStyleTest extends BaseStyleTest {
|
||||
|
||||
@Rule
|
||||
public final ActivityTestRule<RuntimeStyleTestActivity> rule = new ActivityTestRule<>(RuntimeStyleTestActivity.class);
|
||||
@Rule
|
||||
public final ActivityTestRule<RuntimeStyleTestActivity> rule = new ActivityTestRule<>(RuntimeStyleTestActivity.class);
|
||||
|
||||
private LineLayer layer;
|
||||
private LineLayer layer;
|
||||
|
||||
private OnMapReadyIdlingResource idlingResource;
|
||||
private OnMapReadyIdlingResource idlingResource;
|
||||
|
||||
private MapboxMap mapboxMap;
|
||||
private MapboxMap mapboxMap;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
|
||||
Espresso.registerIdlingResources(idlingResource);
|
||||
@Before
|
||||
public void setup() {
|
||||
idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
|
||||
Espresso.registerIdlingResources(idlingResource);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetVisibility() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new LineLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("visibility");
|
||||
assertNotNull(layer);
|
||||
|
||||
@Test
|
||||
public void testSetVisibility() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
//Get initial
|
||||
assertEquals(layer.getVisibility().getValue(), VISIBLE);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
//Set
|
||||
layer.setProperties(visibility(NONE));
|
||||
assertEquals(layer.getVisibility().getValue(), NONE);
|
||||
}
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new LineLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("visibility");
|
||||
assertNotNull(layer);
|
||||
@Test
|
||||
public void testLineCap() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
//Get initial
|
||||
assertEquals(layer.getVisibility().getValue(), VISIBLE);
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
//Set
|
||||
layer.setProperties(visibility(NONE));
|
||||
assertEquals(layer.getVisibility().getValue(), NONE);
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new LineLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("line-cap");
|
||||
assertNotNull(layer);
|
||||
|
||||
@Test
|
||||
public void testLineCap() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
//Set and Get
|
||||
layer.setProperties(lineCap(LINE_CAP_BUTT));
|
||||
assertEquals((String) layer.getLineCap().getValue(), (String) LINE_CAP_BUTT);
|
||||
}
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
@Test
|
||||
public void testLineJoin() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new LineLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("line-cap");
|
||||
assertNotNull(layer);
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
//Set and Get
|
||||
layer.setProperties(lineCap(LINE_CAP_BUTT));
|
||||
assertEquals((String) layer.getLineCap().getValue(), (String) LINE_CAP_BUTT);
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new LineLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("line-join");
|
||||
assertNotNull(layer);
|
||||
|
||||
@Test
|
||||
public void testLineJoin() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
//Set and Get
|
||||
layer.setProperties(lineJoin(LINE_JOIN_BEVEL));
|
||||
assertEquals((String) layer.getLineJoin().getValue(), (String) LINE_JOIN_BEVEL);
|
||||
}
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
@Test
|
||||
public void testLineMiterLimit() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new LineLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("line-join");
|
||||
assertNotNull(layer);
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
//Set and Get
|
||||
layer.setProperties(lineJoin(LINE_JOIN_BEVEL));
|
||||
assertEquals((String) layer.getLineJoin().getValue(), (String) LINE_JOIN_BEVEL);
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new LineLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("line-miter-limit");
|
||||
assertNotNull(layer);
|
||||
|
||||
@Test
|
||||
public void testLineMiterLimit() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
//Set and Get
|
||||
layer.setProperties(lineMiterLimit(0.3f));
|
||||
assertEquals((Float) layer.getLineMiterLimit().getValue(), (Float) 0.3f);
|
||||
}
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
@Test
|
||||
public void testLineRoundLimit() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new LineLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("line-miter-limit");
|
||||
assertNotNull(layer);
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
//Set and Get
|
||||
layer.setProperties(lineMiterLimit(0.3f));
|
||||
assertEquals((Float) layer.getLineMiterLimit().getValue(), (Float) 0.3f);
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new LineLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("line-round-limit");
|
||||
assertNotNull(layer);
|
||||
|
||||
@Test
|
||||
public void testLineRoundLimit() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
//Set and Get
|
||||
layer.setProperties(lineRoundLimit(0.3f));
|
||||
assertEquals((Float) layer.getLineRoundLimit().getValue(), (Float) 0.3f);
|
||||
}
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
@Test
|
||||
public void testLineOpacity() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new LineLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("line-round-limit");
|
||||
assertNotNull(layer);
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
//Set and Get
|
||||
layer.setProperties(lineRoundLimit(0.3f));
|
||||
assertEquals((Float) layer.getLineRoundLimit().getValue(), (Float) 0.3f);
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new LineLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("line-opacity");
|
||||
assertNotNull(layer);
|
||||
|
||||
@Test
|
||||
public void testLineOpacity() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
//Set and Get
|
||||
layer.setProperties(lineOpacity(0.3f));
|
||||
assertEquals((Float) layer.getLineOpacity().getValue(), (Float) 0.3f);
|
||||
}
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
@Test
|
||||
public void testLineColor() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new LineLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("line-opacity");
|
||||
assertNotNull(layer);
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
//Set and Get
|
||||
layer.setProperties(lineOpacity(0.3f));
|
||||
assertEquals((Float) layer.getLineOpacity().getValue(), (Float) 0.3f);
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new LineLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("line-color");
|
||||
assertNotNull(layer);
|
||||
|
||||
@Test
|
||||
public void testLineColor() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
//Set and Get
|
||||
layer.setProperties(lineColor("rgba(0, 0, 0, 1)"));
|
||||
assertEquals((String) layer.getLineColor().getValue(), (String) "rgba(0, 0, 0, 1)");
|
||||
}
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
@Test
|
||||
public void testLineColorAsInt() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new LineLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("line-color");
|
||||
assertNotNull(layer);
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
//Set and Get
|
||||
layer.setProperties(lineColor("rgba(0, 0, 0, 1)"));
|
||||
assertEquals((String) layer.getLineColor().getValue(), (String) "rgba(0, 0, 0, 1)");
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new LineLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("line-color");
|
||||
assertNotNull(layer);
|
||||
|
||||
@Test
|
||||
public void testLineColorAsInt() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
//Set and Get
|
||||
layer.setProperties(lineColor(Color.RED));
|
||||
assertEquals(layer.getLineColorAsInt(), Color.RED);
|
||||
}
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
@Test
|
||||
public void testLineTranslate() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new LineLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("line-color");
|
||||
assertNotNull(layer);
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
//Set and Get
|
||||
layer.setProperties(lineColor(Color.RED));
|
||||
assertEquals(layer.getLineColorAsInt(), Color.RED);
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new LineLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("line-translate");
|
||||
assertNotNull(layer);
|
||||
|
||||
@Test
|
||||
public void testLineTranslate() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
//Set and Get
|
||||
layer.setProperties(lineTranslate(new Float[] {0f, 0f}));
|
||||
assertEquals((Float[]) layer.getLineTranslate().getValue(), (Float[]) new Float[] {0f, 0f});
|
||||
}
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
@Test
|
||||
public void testLineTranslateAnchor() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new LineLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("line-translate");
|
||||
assertNotNull(layer);
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
//Set and Get
|
||||
layer.setProperties(lineTranslate(new Float[]{0f,0f}));
|
||||
assertEquals((Float[]) layer.getLineTranslate().getValue(), (Float[]) new Float[]{0f,0f});
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new LineLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("line-translate-anchor");
|
||||
assertNotNull(layer);
|
||||
|
||||
@Test
|
||||
public void testLineTranslateAnchor() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
//Set and Get
|
||||
layer.setProperties(lineTranslateAnchor(LINE_TRANSLATE_ANCHOR_MAP));
|
||||
assertEquals((String) layer.getLineTranslateAnchor().getValue(), (String) LINE_TRANSLATE_ANCHOR_MAP);
|
||||
}
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
@Test
|
||||
public void testLineWidth() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new LineLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("line-translate-anchor");
|
||||
assertNotNull(layer);
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
//Set and Get
|
||||
layer.setProperties(lineTranslateAnchor(LINE_TRANSLATE_ANCHOR_MAP));
|
||||
assertEquals((String) layer.getLineTranslateAnchor().getValue(), (String) LINE_TRANSLATE_ANCHOR_MAP);
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new LineLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("line-width");
|
||||
assertNotNull(layer);
|
||||
|
||||
@Test
|
||||
public void testLineWidth() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
//Set and Get
|
||||
layer.setProperties(lineWidth(0.3f));
|
||||
assertEquals((Float) layer.getLineWidth().getValue(), (Float) 0.3f);
|
||||
}
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
@Test
|
||||
public void testLineGapWidth() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new LineLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("line-width");
|
||||
assertNotNull(layer);
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
//Set and Get
|
||||
layer.setProperties(lineWidth(0.3f));
|
||||
assertEquals((Float) layer.getLineWidth().getValue(), (Float) 0.3f);
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new LineLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("line-gap-width");
|
||||
assertNotNull(layer);
|
||||
|
||||
@Test
|
||||
public void testLineGapWidth() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
//Set and Get
|
||||
layer.setProperties(lineGapWidth(0.3f));
|
||||
assertEquals((Float) layer.getLineGapWidth().getValue(), (Float) 0.3f);
|
||||
}
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
@Test
|
||||
public void testLineOffset() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new LineLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("line-gap-width");
|
||||
assertNotNull(layer);
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
//Set and Get
|
||||
layer.setProperties(lineGapWidth(0.3f));
|
||||
assertEquals((Float) layer.getLineGapWidth().getValue(), (Float) 0.3f);
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new LineLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("line-offset");
|
||||
assertNotNull(layer);
|
||||
|
||||
@Test
|
||||
public void testLineOffset() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
//Set and Get
|
||||
layer.setProperties(lineOffset(0.3f));
|
||||
assertEquals((Float) layer.getLineOffset().getValue(), (Float) 0.3f);
|
||||
}
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
@Test
|
||||
public void testLineBlur() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new LineLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("line-offset");
|
||||
assertNotNull(layer);
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
//Set and Get
|
||||
layer.setProperties(lineOffset(0.3f));
|
||||
assertEquals((Float) layer.getLineOffset().getValue(), (Float) 0.3f);
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new LineLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("line-blur");
|
||||
assertNotNull(layer);
|
||||
|
||||
@Test
|
||||
public void testLineBlur() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
//Set and Get
|
||||
layer.setProperties(lineBlur(0.3f));
|
||||
assertEquals((Float) layer.getLineBlur().getValue(), (Float) 0.3f);
|
||||
}
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
@Test
|
||||
public void testLineDasharray() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new LineLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("line-blur");
|
||||
assertNotNull(layer);
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
//Set and Get
|
||||
layer.setProperties(lineBlur(0.3f));
|
||||
assertEquals((Float) layer.getLineBlur().getValue(), (Float) 0.3f);
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new LineLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("line-dasharray");
|
||||
assertNotNull(layer);
|
||||
|
||||
@Test
|
||||
public void testLineDasharray() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
//Set and Get
|
||||
layer.setProperties(lineDasharray(new Float[] {}));
|
||||
assertEquals((Float[]) layer.getLineDasharray().getValue(), (Float[]) new Float[] {});
|
||||
}
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
@Test
|
||||
public void testLinePattern() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new LineLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("line-dasharray");
|
||||
assertNotNull(layer);
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
//Set and Get
|
||||
layer.setProperties(lineDasharray(new Float[]{}));
|
||||
assertEquals((Float[]) layer.getLineDasharray().getValue(), (Float[]) new Float[]{});
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new LineLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("line-pattern");
|
||||
assertNotNull(layer);
|
||||
|
||||
@Test
|
||||
public void testLinePattern() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new LineLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("line-pattern");
|
||||
assertNotNull(layer);
|
||||
|
||||
//Set and Get
|
||||
layer.setProperties(linePattern("pedestrian-polygon"));
|
||||
assertEquals((String) layer.getLinePattern().getValue(), (String) "pedestrian-polygon");
|
||||
}
|
||||
//Set and Get
|
||||
layer.setProperties(linePattern("pedestrian-polygon"));
|
||||
assertEquals((String) layer.getLinePattern().getValue(), (String) "pedestrian-polygon");
|
||||
}
|
||||
|
||||
|
||||
@After
|
||||
public void unregisterIntentServiceIdlingResource() {
|
||||
Espresso.unregisterIdlingResources(idlingResource);
|
||||
}
|
||||
@After
|
||||
public void unregisterIntentServiceIdlingResource() {
|
||||
Espresso.unregisterIdlingResources(idlingResource);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make android-style-code`.
|
||||
package com.mapbox.mapboxsdk.testapp.style;
|
||||
// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make android-style-code`.
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.support.test.espresso.Espresso;
|
||||
import android.support.test.rule.ActivityTestRule;
|
||||
import android.support.test.runner.AndroidJUnit4;
|
||||
import timber.log.Timber;
|
||||
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
import com.mapbox.mapboxsdk.style.layers.LineLayer;
|
||||
@@ -19,9 +18,30 @@ import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static com.mapbox.mapboxsdk.style.layers.Property.*;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*;
|
||||
import timber.log.Timber;
|
||||
|
||||
import static com.mapbox.mapboxsdk.style.layers.Property.LINE_CAP_BUTT;
|
||||
import static com.mapbox.mapboxsdk.style.layers.Property.LINE_JOIN_BEVEL;
|
||||
import static com.mapbox.mapboxsdk.style.layers.Property.LINE_TRANSLATE_ANCHOR_MAP;
|
||||
import static com.mapbox.mapboxsdk.style.layers.Property.NONE;
|
||||
import static com.mapbox.mapboxsdk.style.layers.Property.VISIBLE;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineBlur;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineCap;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineColor;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineDasharray;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineGapWidth;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineJoin;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineMiterLimit;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineOffset;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineOpacity;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.linePattern;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineRoundLimit;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineTranslate;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineTranslateAnchor;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineWidth;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.visibility;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
/**
|
||||
* Basic smoke tests for LineLayer
|
||||
@@ -29,379 +49,379 @@ import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*;
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class LineLayerTest extends BaseStyleTest {
|
||||
|
||||
@Rule
|
||||
public final ActivityTestRule<RuntimeStyleTestActivity> rule = new ActivityTestRule<>(RuntimeStyleTestActivity.class);
|
||||
@Rule
|
||||
public final ActivityTestRule<RuntimeStyleTestActivity> rule = new ActivityTestRule<>(RuntimeStyleTestActivity.class);
|
||||
|
||||
private LineLayer layer;
|
||||
private LineLayer layer;
|
||||
|
||||
private OnMapReadyIdlingResource idlingResource;
|
||||
private OnMapReadyIdlingResource idlingResource;
|
||||
|
||||
private MapboxMap mapboxMap;
|
||||
private MapboxMap mapboxMap;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
|
||||
Espresso.registerIdlingResources(idlingResource);
|
||||
@Before
|
||||
public void setup() {
|
||||
idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
|
||||
Espresso.registerIdlingResources(idlingResource);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetVisibility() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new LineLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("visibility");
|
||||
assertNotNull(layer);
|
||||
|
||||
@Test
|
||||
public void testSetVisibility() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
//Get initial
|
||||
assertEquals(layer.getVisibility().getValue(), VISIBLE);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
//Set
|
||||
layer.setProperties(visibility(NONE));
|
||||
assertEquals(layer.getVisibility().getValue(), NONE);
|
||||
}
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new LineLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("visibility");
|
||||
assertNotNull(layer);
|
||||
@Test
|
||||
public void testLineCap() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
//Get initial
|
||||
assertEquals(layer.getVisibility().getValue(), VISIBLE);
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
//Set
|
||||
layer.setProperties(visibility(NONE));
|
||||
assertEquals(layer.getVisibility().getValue(), NONE);
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new LineLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("line-cap");
|
||||
assertNotNull(layer);
|
||||
|
||||
@Test
|
||||
public void testLineCap() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
//Set and Get
|
||||
layer.setProperties(lineCap(LINE_CAP_BUTT));
|
||||
assertEquals((String) layer.getLineCap().getValue(), (String) LINE_CAP_BUTT);
|
||||
}
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
@Test
|
||||
public void testLineJoin() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new LineLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("line-cap");
|
||||
assertNotNull(layer);
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
//Set and Get
|
||||
layer.setProperties(lineCap(LINE_CAP_BUTT));
|
||||
assertEquals((String) layer.getLineCap().getValue(), (String) LINE_CAP_BUTT);
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new LineLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("line-join");
|
||||
assertNotNull(layer);
|
||||
|
||||
@Test
|
||||
public void testLineJoin() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
//Set and Get
|
||||
layer.setProperties(lineJoin(LINE_JOIN_BEVEL));
|
||||
assertEquals((String) layer.getLineJoin().getValue(), (String) LINE_JOIN_BEVEL);
|
||||
}
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
@Test
|
||||
public void testLineMiterLimit() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new LineLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("line-join");
|
||||
assertNotNull(layer);
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
//Set and Get
|
||||
layer.setProperties(lineJoin(LINE_JOIN_BEVEL));
|
||||
assertEquals((String) layer.getLineJoin().getValue(), (String) LINE_JOIN_BEVEL);
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new LineLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("line-miter-limit");
|
||||
assertNotNull(layer);
|
||||
|
||||
@Test
|
||||
public void testLineMiterLimit() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
//Set and Get
|
||||
layer.setProperties(lineMiterLimit(0.3f));
|
||||
assertEquals((Float) layer.getLineMiterLimit().getValue(), (Float) 0.3f);
|
||||
}
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
@Test
|
||||
public void testLineRoundLimit() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new LineLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("line-miter-limit");
|
||||
assertNotNull(layer);
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
//Set and Get
|
||||
layer.setProperties(lineMiterLimit(0.3f));
|
||||
assertEquals((Float) layer.getLineMiterLimit().getValue(), (Float) 0.3f);
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new LineLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("line-round-limit");
|
||||
assertNotNull(layer);
|
||||
|
||||
@Test
|
||||
public void testLineRoundLimit() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
//Set and Get
|
||||
layer.setProperties(lineRoundLimit(0.3f));
|
||||
assertEquals((Float) layer.getLineRoundLimit().getValue(), (Float) 0.3f);
|
||||
}
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
@Test
|
||||
public void testLineOpacity() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new LineLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("line-round-limit");
|
||||
assertNotNull(layer);
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
//Set and Get
|
||||
layer.setProperties(lineRoundLimit(0.3f));
|
||||
assertEquals((Float) layer.getLineRoundLimit().getValue(), (Float) 0.3f);
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new LineLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("line-opacity");
|
||||
assertNotNull(layer);
|
||||
|
||||
@Test
|
||||
public void testLineOpacity() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
//Set and Get
|
||||
layer.setProperties(lineOpacity(0.3f));
|
||||
assertEquals((Float) layer.getLineOpacity().getValue(), (Float) 0.3f);
|
||||
}
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
@Test
|
||||
public void testLineColor() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new LineLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("line-opacity");
|
||||
assertNotNull(layer);
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
//Set and Get
|
||||
layer.setProperties(lineOpacity(0.3f));
|
||||
assertEquals((Float) layer.getLineOpacity().getValue(), (Float) 0.3f);
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new LineLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("line-color");
|
||||
assertNotNull(layer);
|
||||
|
||||
@Test
|
||||
public void testLineColor() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
//Set and Get
|
||||
layer.setProperties(lineColor("rgba(0, 0, 0, 1)"));
|
||||
assertEquals((String) layer.getLineColor().getValue(), (String) "rgba(0, 0, 0, 1)");
|
||||
}
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
@Test
|
||||
public void testLineColorAsInt() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new LineLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("line-color");
|
||||
assertNotNull(layer);
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
//Set and Get
|
||||
layer.setProperties(lineColor("rgba(0, 0, 0, 1)"));
|
||||
assertEquals((String) layer.getLineColor().getValue(), (String) "rgba(0, 0, 0, 1)");
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new LineLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("line-color");
|
||||
assertNotNull(layer);
|
||||
|
||||
@Test
|
||||
public void testLineColorAsInt() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
//Set and Get
|
||||
layer.setProperties(lineColor(Color.RED));
|
||||
assertEquals(layer.getLineColorAsInt(), Color.RED);
|
||||
}
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
@Test
|
||||
public void testLineTranslate() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new LineLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("line-color");
|
||||
assertNotNull(layer);
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
//Set and Get
|
||||
layer.setProperties(lineColor(Color.RED));
|
||||
assertEquals(layer.getLineColorAsInt(), Color.RED);
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new LineLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("line-translate");
|
||||
assertNotNull(layer);
|
||||
|
||||
@Test
|
||||
public void testLineTranslate() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
//Set and Get
|
||||
layer.setProperties(lineTranslate(new Float[] {0f, 0f}));
|
||||
assertEquals((Float[]) layer.getLineTranslate().getValue(), (Float[]) new Float[] {0f, 0f});
|
||||
}
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
@Test
|
||||
public void testLineTranslateAnchor() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new LineLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("line-translate");
|
||||
assertNotNull(layer);
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
//Set and Get
|
||||
layer.setProperties(lineTranslate(new Float[]{0f,0f}));
|
||||
assertEquals((Float[]) layer.getLineTranslate().getValue(), (Float[]) new Float[]{0f,0f});
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new LineLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("line-translate-anchor");
|
||||
assertNotNull(layer);
|
||||
|
||||
@Test
|
||||
public void testLineTranslateAnchor() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
//Set and Get
|
||||
layer.setProperties(lineTranslateAnchor(LINE_TRANSLATE_ANCHOR_MAP));
|
||||
assertEquals((String) layer.getLineTranslateAnchor().getValue(), (String) LINE_TRANSLATE_ANCHOR_MAP);
|
||||
}
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
@Test
|
||||
public void testLineWidth() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new LineLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("line-translate-anchor");
|
||||
assertNotNull(layer);
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
//Set and Get
|
||||
layer.setProperties(lineTranslateAnchor(LINE_TRANSLATE_ANCHOR_MAP));
|
||||
assertEquals((String) layer.getLineTranslateAnchor().getValue(), (String) LINE_TRANSLATE_ANCHOR_MAP);
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new LineLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("line-width");
|
||||
assertNotNull(layer);
|
||||
|
||||
@Test
|
||||
public void testLineWidth() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
//Set and Get
|
||||
layer.setProperties(lineWidth(0.3f));
|
||||
assertEquals((Float) layer.getLineWidth().getValue(), (Float) 0.3f);
|
||||
}
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
@Test
|
||||
public void testLineGapWidth() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new LineLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("line-width");
|
||||
assertNotNull(layer);
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
//Set and Get
|
||||
layer.setProperties(lineWidth(0.3f));
|
||||
assertEquals((Float) layer.getLineWidth().getValue(), (Float) 0.3f);
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new LineLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("line-gap-width");
|
||||
assertNotNull(layer);
|
||||
|
||||
@Test
|
||||
public void testLineGapWidth() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
//Set and Get
|
||||
layer.setProperties(lineGapWidth(0.3f));
|
||||
assertEquals((Float) layer.getLineGapWidth().getValue(), (Float) 0.3f);
|
||||
}
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
@Test
|
||||
public void testLineOffset() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new LineLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("line-gap-width");
|
||||
assertNotNull(layer);
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
//Set and Get
|
||||
layer.setProperties(lineGapWidth(0.3f));
|
||||
assertEquals((Float) layer.getLineGapWidth().getValue(), (Float) 0.3f);
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new LineLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("line-offset");
|
||||
assertNotNull(layer);
|
||||
|
||||
@Test
|
||||
public void testLineOffset() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
//Set and Get
|
||||
layer.setProperties(lineOffset(0.3f));
|
||||
assertEquals((Float) layer.getLineOffset().getValue(), (Float) 0.3f);
|
||||
}
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
@Test
|
||||
public void testLineBlur() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new LineLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("line-offset");
|
||||
assertNotNull(layer);
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
//Set and Get
|
||||
layer.setProperties(lineOffset(0.3f));
|
||||
assertEquals((Float) layer.getLineOffset().getValue(), (Float) 0.3f);
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new LineLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("line-blur");
|
||||
assertNotNull(layer);
|
||||
|
||||
@Test
|
||||
public void testLineBlur() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
//Set and Get
|
||||
layer.setProperties(lineBlur(0.3f));
|
||||
assertEquals((Float) layer.getLineBlur().getValue(), (Float) 0.3f);
|
||||
}
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
@Test
|
||||
public void testLineDasharray() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new LineLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("line-blur");
|
||||
assertNotNull(layer);
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
//Set and Get
|
||||
layer.setProperties(lineBlur(0.3f));
|
||||
assertEquals((Float) layer.getLineBlur().getValue(), (Float) 0.3f);
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new LineLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("line-dasharray");
|
||||
assertNotNull(layer);
|
||||
|
||||
@Test
|
||||
public void testLineDasharray() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
//Set and Get
|
||||
layer.setProperties(lineDasharray(new Float[] {}));
|
||||
assertEquals((Float[]) layer.getLineDasharray().getValue(), (Float[]) new Float[] {});
|
||||
}
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
@Test
|
||||
public void testLinePattern() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new LineLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("line-dasharray");
|
||||
assertNotNull(layer);
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
//Set and Get
|
||||
layer.setProperties(lineDasharray(new Float[]{}));
|
||||
assertEquals((Float[]) layer.getLineDasharray().getValue(), (Float[]) new Float[]{});
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new LineLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("line-pattern");
|
||||
assertNotNull(layer);
|
||||
|
||||
@Test
|
||||
public void testLinePattern() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new LineLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("line-pattern");
|
||||
assertNotNull(layer);
|
||||
|
||||
//Set and Get
|
||||
layer.setProperties(linePattern("pedestrian-polygon"));
|
||||
assertEquals((String) layer.getLinePattern().getValue(), (String) "pedestrian-polygon");
|
||||
}
|
||||
//Set and Get
|
||||
layer.setProperties(linePattern("pedestrian-polygon"));
|
||||
assertEquals((String) layer.getLinePattern().getValue(), (String) "pedestrian-polygon");
|
||||
}
|
||||
|
||||
|
||||
@After
|
||||
public void unregisterIntentServiceIdlingResource() {
|
||||
Espresso.unregisterIdlingResources(idlingResource);
|
||||
}
|
||||
@After
|
||||
public void unregisterIntentServiceIdlingResource() {
|
||||
Espresso.unregisterIdlingResources(idlingResource);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make style-code-android`.
|
||||
package com.mapbox.mapboxsdk.testapp.style;
|
||||
// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make style-code-android`.
|
||||
|
||||
import android.support.test.espresso.Espresso;
|
||||
import android.support.test.rule.ActivityTestRule;
|
||||
import android.support.test.runner.AndroidJUnit4;
|
||||
import timber.log.Timber;
|
||||
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
import com.mapbox.mapboxsdk.style.layers.RasterLayer;
|
||||
@@ -18,9 +17,20 @@ import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static com.mapbox.mapboxsdk.style.layers.Property.*;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*;
|
||||
import timber.log.Timber;
|
||||
|
||||
import static com.mapbox.mapboxsdk.style.layers.Property.NONE;
|
||||
import static com.mapbox.mapboxsdk.style.layers.Property.VISIBLE;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.rasterBrightnessMax;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.rasterBrightnessMin;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.rasterContrast;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.rasterFadeDuration;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.rasterHueRotate;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.rasterOpacity;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.rasterSaturation;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.visibility;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
/**
|
||||
* Basic smoke tests for RasterLayer
|
||||
@@ -28,203 +38,203 @@ import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*;
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class RasterLayerStyleTest extends BaseStyleTest {
|
||||
|
||||
@Rule
|
||||
public final ActivityTestRule<RuntimeStyleTestActivity> rule = new ActivityTestRule<>(RuntimeStyleTestActivity.class);
|
||||
@Rule
|
||||
public final ActivityTestRule<RuntimeStyleTestActivity> rule = new ActivityTestRule<>(RuntimeStyleTestActivity.class);
|
||||
|
||||
private RasterLayer layer;
|
||||
private RasterLayer layer;
|
||||
|
||||
private OnMapReadyIdlingResource idlingResource;
|
||||
private OnMapReadyIdlingResource idlingResource;
|
||||
|
||||
private MapboxMap mapboxMap;
|
||||
private MapboxMap mapboxMap;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
|
||||
Espresso.registerIdlingResources(idlingResource);
|
||||
@Before
|
||||
public void setup() {
|
||||
idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
|
||||
Espresso.registerIdlingResources(idlingResource);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetVisibility() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
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");
|
||||
}
|
||||
Timber.i("visibility");
|
||||
assertNotNull(layer);
|
||||
|
||||
@Test
|
||||
public void testSetVisibility() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
//Get initial
|
||||
assertEquals(layer.getVisibility().getValue(), VISIBLE);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
//Set
|
||||
layer.setProperties(visibility(NONE));
|
||||
assertEquals(layer.getVisibility().getValue(), NONE);
|
||||
}
|
||||
|
||||
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");
|
||||
}
|
||||
Timber.i("visibility");
|
||||
assertNotNull(layer);
|
||||
@Test
|
||||
public void testRasterOpacity() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
//Get initial
|
||||
assertEquals(layer.getVisibility().getValue(), VISIBLE);
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
//Set
|
||||
layer.setProperties(visibility(NONE));
|
||||
assertEquals(layer.getVisibility().getValue(), NONE);
|
||||
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");
|
||||
}
|
||||
Timber.i("raster-opacity");
|
||||
assertNotNull(layer);
|
||||
|
||||
@Test
|
||||
public void testRasterOpacity() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
//Set and Get
|
||||
layer.setProperties(rasterOpacity(0.3f));
|
||||
assertEquals((Float) layer.getRasterOpacity().getValue(), (Float) 0.3f);
|
||||
}
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
@Test
|
||||
public void testRasterHueRotate() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
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");
|
||||
}
|
||||
Timber.i("raster-opacity");
|
||||
assertNotNull(layer);
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
//Set and Get
|
||||
layer.setProperties(rasterOpacity(0.3f));
|
||||
assertEquals((Float) layer.getRasterOpacity().getValue(), (Float) 0.3f);
|
||||
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");
|
||||
}
|
||||
Timber.i("raster-hue-rotate");
|
||||
assertNotNull(layer);
|
||||
|
||||
@Test
|
||||
public void testRasterHueRotate() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
//Set and Get
|
||||
layer.setProperties(rasterHueRotate(0.3f));
|
||||
assertEquals((Float) layer.getRasterHueRotate().getValue(), (Float) 0.3f);
|
||||
}
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
@Test
|
||||
public void testRasterBrightnessMin() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
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");
|
||||
}
|
||||
Timber.i("raster-hue-rotate");
|
||||
assertNotNull(layer);
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
//Set and Get
|
||||
layer.setProperties(rasterHueRotate(0.3f));
|
||||
assertEquals((Float) layer.getRasterHueRotate().getValue(), (Float) 0.3f);
|
||||
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");
|
||||
}
|
||||
Timber.i("raster-brightness-min");
|
||||
assertNotNull(layer);
|
||||
|
||||
@Test
|
||||
public void testRasterBrightnessMin() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
//Set and Get
|
||||
layer.setProperties(rasterBrightnessMin(0.3f));
|
||||
assertEquals((Float) layer.getRasterBrightnessMin().getValue(), (Float) 0.3f);
|
||||
}
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
@Test
|
||||
public void testRasterBrightnessMax() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
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");
|
||||
}
|
||||
Timber.i("raster-brightness-min");
|
||||
assertNotNull(layer);
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
//Set and Get
|
||||
layer.setProperties(rasterBrightnessMin(0.3f));
|
||||
assertEquals((Float) layer.getRasterBrightnessMin().getValue(), (Float) 0.3f);
|
||||
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");
|
||||
}
|
||||
Timber.i("raster-brightness-max");
|
||||
assertNotNull(layer);
|
||||
|
||||
@Test
|
||||
public void testRasterBrightnessMax() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
//Set and Get
|
||||
layer.setProperties(rasterBrightnessMax(0.3f));
|
||||
assertEquals((Float) layer.getRasterBrightnessMax().getValue(), (Float) 0.3f);
|
||||
}
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
@Test
|
||||
public void testRasterSaturation() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
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");
|
||||
}
|
||||
Timber.i("raster-brightness-max");
|
||||
assertNotNull(layer);
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
//Set and Get
|
||||
layer.setProperties(rasterBrightnessMax(0.3f));
|
||||
assertEquals((Float) layer.getRasterBrightnessMax().getValue(), (Float) 0.3f);
|
||||
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");
|
||||
}
|
||||
Timber.i("raster-saturation");
|
||||
assertNotNull(layer);
|
||||
|
||||
@Test
|
||||
public void testRasterSaturation() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
//Set and Get
|
||||
layer.setProperties(rasterSaturation(0.3f));
|
||||
assertEquals((Float) layer.getRasterSaturation().getValue(), (Float) 0.3f);
|
||||
}
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
@Test
|
||||
public void testRasterContrast() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
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");
|
||||
}
|
||||
Timber.i("raster-saturation");
|
||||
assertNotNull(layer);
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
//Set and Get
|
||||
layer.setProperties(rasterSaturation(0.3f));
|
||||
assertEquals((Float) layer.getRasterSaturation().getValue(), (Float) 0.3f);
|
||||
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");
|
||||
}
|
||||
Timber.i("raster-contrast");
|
||||
assertNotNull(layer);
|
||||
|
||||
@Test
|
||||
public void testRasterContrast() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
//Set and Get
|
||||
layer.setProperties(rasterContrast(0.3f));
|
||||
assertEquals((Float) layer.getRasterContrast().getValue(), (Float) 0.3f);
|
||||
}
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
@Test
|
||||
public void testRasterFadeDuration() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
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");
|
||||
}
|
||||
Timber.i("raster-contrast");
|
||||
assertNotNull(layer);
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
//Set and Get
|
||||
layer.setProperties(rasterContrast(0.3f));
|
||||
assertEquals((Float) layer.getRasterContrast().getValue(), (Float) 0.3f);
|
||||
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");
|
||||
}
|
||||
Timber.i("raster-fade-duration");
|
||||
assertNotNull(layer);
|
||||
|
||||
@Test
|
||||
public void testRasterFadeDuration() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
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");
|
||||
}
|
||||
Timber.i("raster-fade-duration");
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
@After
|
||||
public void unregisterIntentServiceIdlingResource() {
|
||||
Espresso.unregisterIdlingResources(idlingResource);
|
||||
}
|
||||
@After
|
||||
public void unregisterIntentServiceIdlingResource() {
|
||||
Espresso.unregisterIdlingResources(idlingResource);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make android-style-code`.
|
||||
package com.mapbox.mapboxsdk.testapp.style;
|
||||
// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make android-style-code`.
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.support.test.espresso.Espresso;
|
||||
import android.support.test.rule.ActivityTestRule;
|
||||
import android.support.test.runner.AndroidJUnit4;
|
||||
import timber.log.Timber;
|
||||
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
import com.mapbox.mapboxsdk.style.layers.RasterLayer;
|
||||
@@ -19,9 +17,20 @@ import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static com.mapbox.mapboxsdk.style.layers.Property.*;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*;
|
||||
import timber.log.Timber;
|
||||
|
||||
import static com.mapbox.mapboxsdk.style.layers.Property.NONE;
|
||||
import static com.mapbox.mapboxsdk.style.layers.Property.VISIBLE;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.rasterBrightnessMax;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.rasterBrightnessMin;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.rasterContrast;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.rasterFadeDuration;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.rasterHueRotate;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.rasterOpacity;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.rasterSaturation;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.visibility;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
/**
|
||||
* Basic smoke tests for RasterLayer
|
||||
@@ -29,203 +38,203 @@ import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*;
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class RasterLayerTest extends BaseStyleTest {
|
||||
|
||||
@Rule
|
||||
public final ActivityTestRule<RuntimeStyleTestActivity> rule = new ActivityTestRule<>(RuntimeStyleTestActivity.class);
|
||||
@Rule
|
||||
public final ActivityTestRule<RuntimeStyleTestActivity> rule = new ActivityTestRule<>(RuntimeStyleTestActivity.class);
|
||||
|
||||
private RasterLayer layer;
|
||||
private RasterLayer layer;
|
||||
|
||||
private OnMapReadyIdlingResource idlingResource;
|
||||
private OnMapReadyIdlingResource idlingResource;
|
||||
|
||||
private MapboxMap mapboxMap;
|
||||
private MapboxMap mapboxMap;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
|
||||
Espresso.registerIdlingResources(idlingResource);
|
||||
@Before
|
||||
public void setup() {
|
||||
idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
|
||||
Espresso.registerIdlingResources(idlingResource);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetVisibility() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
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");
|
||||
}
|
||||
Timber.i("visibility");
|
||||
assertNotNull(layer);
|
||||
|
||||
@Test
|
||||
public void testSetVisibility() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
//Get initial
|
||||
assertEquals(layer.getVisibility().getValue(), VISIBLE);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
//Set
|
||||
layer.setProperties(visibility(NONE));
|
||||
assertEquals(layer.getVisibility().getValue(), NONE);
|
||||
}
|
||||
|
||||
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");
|
||||
}
|
||||
Timber.i("visibility");
|
||||
assertNotNull(layer);
|
||||
@Test
|
||||
public void testRasterOpacity() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
//Get initial
|
||||
assertEquals(layer.getVisibility().getValue(), VISIBLE);
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
//Set
|
||||
layer.setProperties(visibility(NONE));
|
||||
assertEquals(layer.getVisibility().getValue(), NONE);
|
||||
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");
|
||||
}
|
||||
Timber.i("raster-opacity");
|
||||
assertNotNull(layer);
|
||||
|
||||
@Test
|
||||
public void testRasterOpacity() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
//Set and Get
|
||||
layer.setProperties(rasterOpacity(0.3f));
|
||||
assertEquals((Float) layer.getRasterOpacity().getValue(), (Float) 0.3f);
|
||||
}
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
@Test
|
||||
public void testRasterHueRotate() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
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");
|
||||
}
|
||||
Timber.i("raster-opacity");
|
||||
assertNotNull(layer);
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
//Set and Get
|
||||
layer.setProperties(rasterOpacity(0.3f));
|
||||
assertEquals((Float) layer.getRasterOpacity().getValue(), (Float) 0.3f);
|
||||
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");
|
||||
}
|
||||
Timber.i("raster-hue-rotate");
|
||||
assertNotNull(layer);
|
||||
|
||||
@Test
|
||||
public void testRasterHueRotate() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
//Set and Get
|
||||
layer.setProperties(rasterHueRotate(0.3f));
|
||||
assertEquals((Float) layer.getRasterHueRotate().getValue(), (Float) 0.3f);
|
||||
}
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
@Test
|
||||
public void testRasterBrightnessMin() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
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");
|
||||
}
|
||||
Timber.i("raster-hue-rotate");
|
||||
assertNotNull(layer);
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
//Set and Get
|
||||
layer.setProperties(rasterHueRotate(0.3f));
|
||||
assertEquals((Float) layer.getRasterHueRotate().getValue(), (Float) 0.3f);
|
||||
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");
|
||||
}
|
||||
Timber.i("raster-brightness-min");
|
||||
assertNotNull(layer);
|
||||
|
||||
@Test
|
||||
public void testRasterBrightnessMin() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
//Set and Get
|
||||
layer.setProperties(rasterBrightnessMin(0.3f));
|
||||
assertEquals((Float) layer.getRasterBrightnessMin().getValue(), (Float) 0.3f);
|
||||
}
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
@Test
|
||||
public void testRasterBrightnessMax() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
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");
|
||||
}
|
||||
Timber.i("raster-brightness-min");
|
||||
assertNotNull(layer);
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
//Set and Get
|
||||
layer.setProperties(rasterBrightnessMin(0.3f));
|
||||
assertEquals((Float) layer.getRasterBrightnessMin().getValue(), (Float) 0.3f);
|
||||
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");
|
||||
}
|
||||
Timber.i("raster-brightness-max");
|
||||
assertNotNull(layer);
|
||||
|
||||
@Test
|
||||
public void testRasterBrightnessMax() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
//Set and Get
|
||||
layer.setProperties(rasterBrightnessMax(0.3f));
|
||||
assertEquals((Float) layer.getRasterBrightnessMax().getValue(), (Float) 0.3f);
|
||||
}
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
@Test
|
||||
public void testRasterSaturation() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
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");
|
||||
}
|
||||
Timber.i("raster-brightness-max");
|
||||
assertNotNull(layer);
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
//Set and Get
|
||||
layer.setProperties(rasterBrightnessMax(0.3f));
|
||||
assertEquals((Float) layer.getRasterBrightnessMax().getValue(), (Float) 0.3f);
|
||||
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");
|
||||
}
|
||||
Timber.i("raster-saturation");
|
||||
assertNotNull(layer);
|
||||
|
||||
@Test
|
||||
public void testRasterSaturation() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
//Set and Get
|
||||
layer.setProperties(rasterSaturation(0.3f));
|
||||
assertEquals((Float) layer.getRasterSaturation().getValue(), (Float) 0.3f);
|
||||
}
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
@Test
|
||||
public void testRasterContrast() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
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");
|
||||
}
|
||||
Timber.i("raster-saturation");
|
||||
assertNotNull(layer);
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
//Set and Get
|
||||
layer.setProperties(rasterSaturation(0.3f));
|
||||
assertEquals((Float) layer.getRasterSaturation().getValue(), (Float) 0.3f);
|
||||
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");
|
||||
}
|
||||
Timber.i("raster-contrast");
|
||||
assertNotNull(layer);
|
||||
|
||||
@Test
|
||||
public void testRasterContrast() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
//Set and Get
|
||||
layer.setProperties(rasterContrast(0.3f));
|
||||
assertEquals((Float) layer.getRasterContrast().getValue(), (Float) 0.3f);
|
||||
}
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
@Test
|
||||
public void testRasterFadeDuration() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
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");
|
||||
}
|
||||
Timber.i("raster-contrast");
|
||||
assertNotNull(layer);
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
//Set and Get
|
||||
layer.setProperties(rasterContrast(0.3f));
|
||||
assertEquals((Float) layer.getRasterContrast().getValue(), (Float) 0.3f);
|
||||
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");
|
||||
}
|
||||
Timber.i("raster-fade-duration");
|
||||
assertNotNull(layer);
|
||||
|
||||
@Test
|
||||
public void testRasterFadeDuration() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
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");
|
||||
}
|
||||
Timber.i("raster-fade-duration");
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
@After
|
||||
public void unregisterIntentServiceIdlingResource() {
|
||||
Espresso.unregisterIdlingResources(idlingResource);
|
||||
}
|
||||
@After
|
||||
public void unregisterIntentServiceIdlingResource() {
|
||||
Espresso.unregisterIdlingResources(idlingResource);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ 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;
|
||||
@@ -22,39 +23,39 @@ import org.junit.runner.RunWith;
|
||||
*/
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class RuntimeStyleBackgroundLayerTest
|
||||
extends ActivityInstrumentationTestCase2<RuntimeStyleTestActivity> {
|
||||
extends ActivityInstrumentationTestCase2<RuntimeStyleTestActivity> {
|
||||
|
||||
public RuntimeStyleBackgroundLayerTest() {
|
||||
super(RuntimeStyleTestActivity.class);
|
||||
}
|
||||
public RuntimeStyleBackgroundLayerTest() {
|
||||
super(RuntimeStyleTestActivity.class);
|
||||
}
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
super.setUp();
|
||||
injectInstrumentation(InstrumentationRegistry.getInstrumentation());
|
||||
}
|
||||
@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);
|
||||
@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);
|
||||
//Get initial
|
||||
assertEquals(layer.getVisibility().getValue(), Property.VISIBLE);
|
||||
|
||||
//Set
|
||||
layer.setProperties(PropertyFactory.visibility(Property.NONE));
|
||||
assertEquals(layer.getVisibility().getValue(), Property.NONE);
|
||||
}
|
||||
});
|
||||
}
|
||||
//Set
|
||||
layer.setProperties(PropertyFactory.visibility(Property.NONE));
|
||||
assertEquals(layer.getVisibility().getValue(), Property.NONE);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() throws Exception {
|
||||
super.tearDown();
|
||||
}
|
||||
@After
|
||||
public void tearDown() throws Exception {
|
||||
super.tearDown();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,157 +45,157 @@ import static org.junit.Assert.assertNull;
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class RuntimeStyleTests {
|
||||
|
||||
@Rule
|
||||
public final ActivityTestRule<RuntimeStyleTestActivity> rule = new ActivityTestRule<>(RuntimeStyleTestActivity.class);
|
||||
@Rule
|
||||
public final ActivityTestRule<RuntimeStyleTestActivity> rule = new ActivityTestRule<>(RuntimeStyleTestActivity.class);
|
||||
|
||||
private OnMapReadyIdlingResource idlingResource;
|
||||
private OnMapReadyIdlingResource idlingResource;
|
||||
|
||||
@Before
|
||||
public void registerIdlingResource() {
|
||||
idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
|
||||
Espresso.registerIdlingResources(idlingResource);
|
||||
@Before
|
||||
public void registerIdlingResource() {
|
||||
idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
|
||||
Espresso.registerIdlingResources(idlingResource);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetAddRemoveLayer() {
|
||||
ViewUtils.checkViewIsDisplayed(R.id.mapView);
|
||||
onView(withId(R.id.mapView)).perform(new AddRemoveLayerAction());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAddRemoveSource() {
|
||||
ViewUtils.checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
|
||||
mapboxMap.addSource(new VectorSource("my-source", "mapbox://mapbox.mapbox-terrain-v2"));
|
||||
try {
|
||||
mapboxMap.removeSource("my-source");
|
||||
} catch (NoSuchSourceException noSuchSourceException) {
|
||||
// it's ok..
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetAddRemoveLayer() {
|
||||
ViewUtils.checkViewIsDisplayed(R.id.mapView);
|
||||
onView(withId(R.id.mapView)).perform(new AddRemoveLayerAction());
|
||||
onView(withId(R.id.mapView)).perform(new AddRemoveSourceAction());
|
||||
}
|
||||
|
||||
private class AddRemoveLayerAction implements ViewAction {
|
||||
|
||||
@Override
|
||||
public Matcher<View> getConstraints() {
|
||||
return isDisplayed();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAddRemoveSource() {
|
||||
ViewUtils.checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
|
||||
mapboxMap.addSource(new VectorSource("my-source", "mapbox://mapbox.mapbox-terrain-v2"));
|
||||
try {
|
||||
mapboxMap.removeSource("my-source");
|
||||
} catch (NoSuchSourceException e) {
|
||||
// it's ok..
|
||||
}
|
||||
|
||||
onView(withId(R.id.mapView)).perform(new AddRemoveSourceAction());
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return getClass().getSimpleName();
|
||||
}
|
||||
|
||||
private class AddRemoveLayerAction implements ViewAction {
|
||||
@Override
|
||||
public void perform(UiController uiController, View view) {
|
||||
MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
@Override
|
||||
public Matcher<View> getConstraints() {
|
||||
return isDisplayed();
|
||||
}
|
||||
//Get initial
|
||||
assertNotNull(mapboxMap.getLayer("building"));
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return getClass().getSimpleName();
|
||||
}
|
||||
//Remove
|
||||
try {
|
||||
mapboxMap.removeLayer("building");
|
||||
} catch (NoSuchLayerException noSuchSourceException) {
|
||||
fail("Definitively exists: " + noSuchSourceException.getMessage());
|
||||
}
|
||||
assertNull(mapboxMap.getLayer("building"));
|
||||
|
||||
@Override
|
||||
public void perform(UiController uiController, View view) {
|
||||
MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
|
||||
//Add
|
||||
FillLayer layer = new FillLayer("building", "composite");
|
||||
layer.setSourceLayer("building");
|
||||
mapboxMap.addLayer(layer);
|
||||
assertNotNull(mapboxMap.getLayer("building"));
|
||||
|
||||
//Get initial
|
||||
assertNotNull(mapboxMap.getLayer("building"));
|
||||
//Assure the reference still works
|
||||
layer.setProperties(PropertyFactory.visibility(Property.VISIBLE));
|
||||
|
||||
//Remove
|
||||
try {
|
||||
mapboxMap.removeLayer("building");
|
||||
} catch (NoSuchLayerException e) {
|
||||
fail("Definitively exists: " + e.getMessage());
|
||||
}
|
||||
assertNull(mapboxMap.getLayer("building"));
|
||||
//Remove, preserving the reference
|
||||
try {
|
||||
mapboxMap.removeLayer(layer);
|
||||
} catch (NoSuchLayerException noSuchSourceException) {
|
||||
fail("Definitively exists: " + noSuchSourceException.getMessage());
|
||||
}
|
||||
|
||||
//Add
|
||||
FillLayer layer = new FillLayer("building", "composite");
|
||||
layer.setSourceLayer("building");
|
||||
mapboxMap.addLayer(layer);
|
||||
assertNotNull(mapboxMap.getLayer("building"));
|
||||
//Property setters should still work
|
||||
layer.setProperties(PropertyFactory.fillColor(Color.RED));
|
||||
|
||||
//Assure the reference still works
|
||||
layer.setProperties(PropertyFactory.visibility(Property.VISIBLE));
|
||||
//Re-add the reference...
|
||||
mapboxMap.addLayer(layer);
|
||||
|
||||
//Remove, preserving the reference
|
||||
try {
|
||||
mapboxMap.removeLayer(layer);
|
||||
} catch (NoSuchLayerException e) {
|
||||
fail("Definitively exists: " + e.getMessage());
|
||||
}
|
||||
//Ensure it's there
|
||||
Assert.assertNotNull(mapboxMap.getLayer(layer.getId()));
|
||||
|
||||
//Property setters should still work
|
||||
layer.setProperties(PropertyFactory.fillColor(Color.RED));
|
||||
//Test adding a duplicate layer
|
||||
try {
|
||||
mapboxMap.addLayer(new FillLayer("building", "composite"));
|
||||
fail("Should not have been allowed to add a layer with a duplicate id");
|
||||
} catch (CannotAddLayerException cannotAddLayerException) {
|
||||
//OK
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Re-add the reference...
|
||||
mapboxMap.addLayer(layer);
|
||||
private class AddRemoveSourceAction implements ViewAction {
|
||||
|
||||
//Ensure it's there
|
||||
Assert.assertNotNull(mapboxMap.getLayer(layer.getId()));
|
||||
|
||||
//Test adding a duplicate layer
|
||||
try {
|
||||
mapboxMap.addLayer(new FillLayer("building", "composite"));
|
||||
fail("Should not have been allowed to add a layer with a duplicate id");
|
||||
} catch (CannotAddLayerException e) {
|
||||
//OK
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public Matcher<View> getConstraints() {
|
||||
return isDisplayed();
|
||||
}
|
||||
|
||||
private class AddRemoveSourceAction implements ViewAction {
|
||||
|
||||
@Override
|
||||
public Matcher<View> getConstraints() {
|
||||
return isDisplayed();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return getClass().getSimpleName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void perform(UiController uiController, View view) {
|
||||
MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
//Add initial source
|
||||
mapboxMap.addSource(new VectorSource("my-source", "mapbox://mapbox.mapbox-terrain-v2"));
|
||||
|
||||
//Remove
|
||||
try {
|
||||
mapboxMap.removeSource("my-source");
|
||||
} catch (NoSuchSourceException e) {
|
||||
fail("Definitively exists: " + e.getMessage());
|
||||
}
|
||||
assertNull(mapboxMap.getLayer("my-source"));
|
||||
|
||||
//Add
|
||||
Source source = new VectorSource("my-source", "mapbox://mapbox.mapbox-terrain-v2");
|
||||
mapboxMap.addSource(source);
|
||||
|
||||
//Remove, preserving the reference
|
||||
try {
|
||||
mapboxMap.removeSource(source);
|
||||
} catch (NoSuchSourceException e) {
|
||||
fail("Definitively exists: " + e.getMessage());
|
||||
}
|
||||
|
||||
//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 e) {
|
||||
//OK
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return getClass().getSimpleName();
|
||||
}
|
||||
|
||||
@After
|
||||
public void unregisterIntentServiceIdlingResource() {
|
||||
Espresso.unregisterIdlingResources(idlingResource);
|
||||
@Override
|
||||
public void perform(UiController uiController, View view) {
|
||||
MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
//Add initial source
|
||||
mapboxMap.addSource(new VectorSource("my-source", "mapbox://mapbox.mapbox-terrain-v2"));
|
||||
|
||||
//Remove
|
||||
try {
|
||||
mapboxMap.removeSource("my-source");
|
||||
} catch (NoSuchSourceException noSuchSourceException) {
|
||||
fail("Definitively exists: " + noSuchSourceException.getMessage());
|
||||
}
|
||||
assertNull(mapboxMap.getLayer("my-source"));
|
||||
|
||||
//Add
|
||||
Source source = new VectorSource("my-source", "mapbox://mapbox.mapbox-terrain-v2");
|
||||
mapboxMap.addSource(source);
|
||||
|
||||
//Remove, preserving the reference
|
||||
try {
|
||||
mapboxMap.removeSource(source);
|
||||
} catch (NoSuchSourceException noSuchSourceException) {
|
||||
fail("Definitively exists: " + noSuchSourceException.getMessage());
|
||||
}
|
||||
|
||||
//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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,25 +20,26 @@ import org.junit.runner.RunWith;
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class RuntimeStyleTimingTests extends BaseStyleTest {
|
||||
|
||||
@Rule
|
||||
public final ActivityTestRule<RuntimeStyleTimingTestActivity> rule = new ActivityTestRule<>(RuntimeStyleTimingTestActivity.class);
|
||||
@Rule
|
||||
public final ActivityTestRule<RuntimeStyleTimingTestActivity> rule =
|
||||
new ActivityTestRule<>(RuntimeStyleTimingTestActivity.class);
|
||||
|
||||
private OnMapReadyIdlingResource idlingResource;
|
||||
private OnMapReadyIdlingResource idlingResource;
|
||||
|
||||
@Before
|
||||
public void registerIdlingResource() {
|
||||
idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
|
||||
Espresso.registerIdlingResources(idlingResource);
|
||||
}
|
||||
@Before
|
||||
public void registerIdlingResource() {
|
||||
idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
|
||||
Espresso.registerIdlingResources(idlingResource);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetAddRemoveLayer() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
//We're good if it didn't crash
|
||||
}
|
||||
@Test
|
||||
public void testGetAddRemoveLayer() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
//We're good if it didn't crash
|
||||
}
|
||||
|
||||
@After
|
||||
public void unregisterIntentServiceIdlingResource() {
|
||||
Espresso.unregisterIdlingResources(idlingResource);
|
||||
}
|
||||
@After
|
||||
public void unregisterIntentServiceIdlingResource() {
|
||||
Espresso.unregisterIdlingResources(idlingResource);
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -15,15 +15,15 @@ import static android.support.test.espresso.matcher.ViewMatchers.withContentDesc
|
||||
|
||||
public class DrawerUtils {
|
||||
|
||||
private final static String HOME_BUTTON_STRING = "Navigate up";
|
||||
private static final String HOME_BUTTON_STRING = "Navigate up";
|
||||
|
||||
public static void openDrawer(){
|
||||
onView(withContentDescription(HOME_BUTTON_STRING)).perform(click());
|
||||
}
|
||||
public static void openDrawer() {
|
||||
onView(withContentDescription(HOME_BUTTON_STRING)).perform(click());
|
||||
}
|
||||
|
||||
public static void clickItem(@StringRes int txtId){
|
||||
Espresso.onView(Matchers.allOf(ViewMatchers.withId(R.id.design_menu_item_text),
|
||||
ViewMatchers.hasSibling(ViewMatchers.withText(txtId)))).perform(ViewActions.click());
|
||||
}
|
||||
public static void clickItem(@StringRes int txtId) {
|
||||
Espresso.onView(Matchers.allOf(ViewMatchers.withId(R.id.design_menu_item_text),
|
||||
ViewMatchers.hasSibling(ViewMatchers.withText(txtId)))).perform(ViewActions.click());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -8,8 +8,8 @@ import static android.support.test.espresso.matcher.ViewMatchers.withId;
|
||||
|
||||
public class GestureUtils {
|
||||
|
||||
public static void doubleClickGesture(@IdRes int id){
|
||||
onView(withId(id)).perform(doubleClick());
|
||||
}
|
||||
public static void doubleClickGesture(@IdRes int id) {
|
||||
onView(withId(id)).perform(doubleClick());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.mapbox.mapboxsdk.testapp.utils;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.support.test.espresso.IdlingResource;
|
||||
|
||||
import timber.log.Timber;
|
||||
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
@@ -10,47 +11,47 @@ import java.lang.reflect.Field;
|
||||
|
||||
public class OnMapReadyIdlingResource implements IdlingResource {
|
||||
|
||||
private final Activity activity;
|
||||
private MapboxMap mapboxMap;
|
||||
private IdlingResource.ResourceCallback resourceCallback;
|
||||
private final Activity activity;
|
||||
private MapboxMap mapboxMap;
|
||||
private IdlingResource.ResourceCallback resourceCallback;
|
||||
|
||||
public OnMapReadyIdlingResource(Activity activity) {
|
||||
this.activity = activity;
|
||||
}
|
||||
public OnMapReadyIdlingResource(Activity activity) {
|
||||
this.activity = activity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return getClass().getSimpleName();
|
||||
}
|
||||
@Override
|
||||
public String getName() {
|
||||
return getClass().getSimpleName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isIdleNow() {
|
||||
boolean idle = isMapboxMapReady();
|
||||
if (idle && resourceCallback != null) {
|
||||
resourceCallback.onTransitionToIdle();
|
||||
}
|
||||
return idle;
|
||||
@Override
|
||||
public boolean isIdleNow() {
|
||||
boolean idle = isMapboxMapReady();
|
||||
if (idle && resourceCallback != null) {
|
||||
resourceCallback.onTransitionToIdle();
|
||||
}
|
||||
return idle;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerIdleTransitionCallback(ResourceCallback resourceCallback) {
|
||||
this.resourceCallback = resourceCallback;
|
||||
}
|
||||
@Override
|
||||
public void registerIdleTransitionCallback(ResourceCallback resourceCallback) {
|
||||
this.resourceCallback = resourceCallback;
|
||||
}
|
||||
|
||||
private boolean isMapboxMapReady() {
|
||||
try {
|
||||
Field field = activity.getClass().getDeclaredField("mapboxMap");
|
||||
field.setAccessible(true);
|
||||
mapboxMap = (MapboxMap) field.get(activity);
|
||||
Timber.e("isMapboxReady called with value " + (mapboxMap != null));
|
||||
return mapboxMap != null;
|
||||
} catch (Exception e) {
|
||||
Timber.e("could not reflect", e);
|
||||
return false;
|
||||
}
|
||||
private boolean isMapboxMapReady() {
|
||||
try {
|
||||
Field field = activity.getClass().getDeclaredField("mapboxMap");
|
||||
field.setAccessible(true);
|
||||
mapboxMap = (MapboxMap) field.get(activity);
|
||||
Timber.e("isMapboxReady called with value " + (mapboxMap != null));
|
||||
return mapboxMap != null;
|
||||
} catch (Exception exception) {
|
||||
Timber.e("could not reflect", exception);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public MapboxMap getMapboxMap() {
|
||||
return mapboxMap;
|
||||
}
|
||||
public MapboxMap getMapboxMap() {
|
||||
return mapboxMap;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,9 @@ import android.app.Activity;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Canvas;
|
||||
import android.os.Environment;
|
||||
|
||||
import timber.log.Timber;
|
||||
|
||||
import android.view.TextureView;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
@@ -23,112 +25,113 @@ import java.util.UUID;
|
||||
*/
|
||||
public class ScreenshotUtil {
|
||||
|
||||
// Where to store the files. This path is required by AWS Device Farm:
|
||||
// http://docs.aws.amazon.com/devicefarm/latest/developerguide/test-types-android-instrumentation.html#test-types-android-instrumentation-screenshots
|
||||
private static final String SCREENSHOT_FOLDER = "test-screenshots";
|
||||
// Where to store the files. This path is required by AWS Device Farm:
|
||||
// http://docs.aws.amazon.com/devicefarm/latest/developerguide/test-types-android-instrumentation.html
|
||||
// #test-types-android-instrumentation-screenshots
|
||||
private static final String SCREENSHOT_FOLDER = "test-screenshots";
|
||||
|
||||
// Image type and quality
|
||||
private static final String DEFAULT_IMAGE_EXTENSION = ".png";
|
||||
private static final Bitmap.CompressFormat DEFAULT_IMAGE_FORMAT = Bitmap.CompressFormat.PNG;
|
||||
private static final int DEFAULT_IMAGE_QUALITY = 100;
|
||||
// Image type and quality
|
||||
private static final String DEFAULT_IMAGE_EXTENSION = ".png";
|
||||
private static final Bitmap.CompressFormat DEFAULT_IMAGE_FORMAT = Bitmap.CompressFormat.PNG;
|
||||
private static final int DEFAULT_IMAGE_QUALITY = 100;
|
||||
|
||||
public static void take(Activity activity, String testName) {
|
||||
public static void take(Activity activity, String testName) {
|
||||
|
||||
// Check if storage is available
|
||||
if (!isExternalStorageWritable()) {
|
||||
Timber.d("External storage is not available.");
|
||||
return;
|
||||
}
|
||||
// Check if storage is available
|
||||
if (!isExternalStorageWritable()) {
|
||||
Timber.d("External storage is not available.");
|
||||
return;
|
||||
}
|
||||
|
||||
// Get a bitmap from the activity root view. When the drawing cache is enabled,
|
||||
// // the next call to getDrawingCache() will draw the view in a bitmap.
|
||||
View rootView = activity.getWindow().getDecorView().getRootView();
|
||||
// rootView.setDrawingCacheEnabled(true);r
|
||||
// rootView.setDrawingCacheEnabled(false);
|
||||
// Get a bitmap from the activity root view. When the drawing cache is enabled,
|
||||
// the next call to getDrawingCache() will draw the view in a bitmap.
|
||||
View rootView = activity.getWindow().getDecorView().getRootView();
|
||||
// rootView.setDrawingCacheEnabled(true);r
|
||||
// rootView.setDrawingCacheEnabled(false);
|
||||
|
||||
Bitmap bitmap = null;
|
||||
Bitmap bitmap = null;
|
||||
|
||||
// Add the SurfaceView bit (see getAllTextureViews() below)
|
||||
List<TextureView> tilingViews = getAllTextureViews(rootView);
|
||||
if (tilingViews.size() > 0) {
|
||||
bitmap = Bitmap.createBitmap(tilingViews.get(0).getHeight(),tilingViews.get(0).getWidth(), Bitmap.Config.ARGB_8888);
|
||||
Canvas canvas = new Canvas(bitmap);
|
||||
for (TextureView TextureView : tilingViews) {
|
||||
Bitmap b = TextureView.getBitmap(TextureView.getWidth(), TextureView.getHeight());
|
||||
int[] location = new int[2];
|
||||
TextureView.getLocationInWindow(location);
|
||||
int[] location2 = new int[2];
|
||||
TextureView.getLocationOnScreen(location2);
|
||||
canvas.drawBitmap(b, 0,0, null);
|
||||
}
|
||||
}
|
||||
// Add the SurfaceView bit (see getAllTextureViews() below)
|
||||
List<TextureView> tilingViews = getAllTextureViews(rootView);
|
||||
if (tilingViews.size() > 0) {
|
||||
bitmap = Bitmap.createBitmap(tilingViews.get(0).getHeight(), tilingViews.get(0).getWidth(),
|
||||
Bitmap.Config.ARGB_8888);
|
||||
Canvas canvas = new Canvas(bitmap);
|
||||
for (TextureView TextureView : tilingViews) {
|
||||
Bitmap b = TextureView.getBitmap(TextureView.getWidth(), TextureView.getHeight());
|
||||
int[] location = new int[2];
|
||||
TextureView.getLocationInWindow(location);
|
||||
int[] location2 = new int[2];
|
||||
TextureView.getLocationOnScreen(location2);
|
||||
canvas.drawBitmap(b, 0, 0, null);
|
||||
}
|
||||
}
|
||||
|
||||
// Save the bitmap in external storage
|
||||
String uniqueAbsolutePath = getUniqueAbsolutePath(testName);
|
||||
File outputFile = new File(uniqueAbsolutePath);
|
||||
OutputStream outputStream = null;
|
||||
// Save the bitmap in external storage
|
||||
String uniqueAbsolutePath = getUniqueAbsolutePath(testName);
|
||||
File outputFile = new File(uniqueAbsolutePath);
|
||||
OutputStream outputStream = null;
|
||||
try {
|
||||
outputStream = new FileOutputStream(outputFile);
|
||||
bitmap.compress(DEFAULT_IMAGE_FORMAT, DEFAULT_IMAGE_QUALITY, outputStream);
|
||||
outputStream.flush();
|
||||
} catch (Exception exception) {
|
||||
|
||||
exception.printStackTrace();
|
||||
} finally {
|
||||
if (outputStream != null) {
|
||||
try {
|
||||
outputStream = new FileOutputStream(outputFile);
|
||||
bitmap.compress(DEFAULT_IMAGE_FORMAT, DEFAULT_IMAGE_QUALITY, outputStream);
|
||||
outputStream.flush();
|
||||
} catch (Exception e) {
|
||||
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if (outputStream != null) {
|
||||
try {
|
||||
outputStream.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
outputStream.close();
|
||||
} catch (IOException ioException) {
|
||||
ioException.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* The classic way of taking a screenshot (above) doesn't work with TextureView, this fixes it:
|
||||
* http://stackoverflow.com/questions/19704060/screen-capture-textureview-is-black-using-drawingcache
|
||||
*/
|
||||
|
||||
public static List<TextureView> getAllTextureViews(View view) {
|
||||
List<TextureView> tilingViews = new ArrayList<TextureView>();
|
||||
if (view instanceof TextureView) {
|
||||
tilingViews.add((TextureView) view);
|
||||
} else if (view instanceof ViewGroup) {
|
||||
ViewGroup viewGroup = (ViewGroup) view;
|
||||
for (int i = 0; i < viewGroup.getChildCount(); i++) {
|
||||
tilingViews.addAll(getAllTextureViews(viewGroup.getChildAt(i)));
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* The classic way of taking a screenshot (above) doesn't work with TextureView, this fixes it:
|
||||
* http://stackoverflow.com/questions/19704060/screen-capture-textureview-is-black-using-drawingcache
|
||||
*/
|
||||
return tilingViews;
|
||||
}
|
||||
|
||||
public static List<TextureView> getAllTextureViews(View view)
|
||||
{
|
||||
List<TextureView> tilingViews = new ArrayList<TextureView>();
|
||||
if (view instanceof TextureView) {
|
||||
tilingViews.add((TextureView)view);
|
||||
} else if(view instanceof ViewGroup) {
|
||||
ViewGroup viewGroup = (ViewGroup)view;
|
||||
for (int i = 0; i < viewGroup.getChildCount(); i++) {
|
||||
tilingViews.addAll(getAllTextureViews(viewGroup.getChildAt(i)));
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Utils
|
||||
*/
|
||||
|
||||
return tilingViews;
|
||||
public static boolean isExternalStorageWritable() {
|
||||
// Checks if external storage is available for read and write
|
||||
String state = Environment.getExternalStorageState();
|
||||
return Environment.MEDIA_MOUNTED.equals(state);
|
||||
}
|
||||
|
||||
private static String getUniqueAbsolutePath(String testName) {
|
||||
// A screenshot after every test vs. manual tests
|
||||
String filename = UUID.randomUUID().toString() + DEFAULT_IMAGE_EXTENSION;
|
||||
if (testName != null && !testName.isEmpty()) {
|
||||
filename = testName + DEFAULT_IMAGE_EXTENSION;
|
||||
}
|
||||
|
||||
/*
|
||||
* Utils
|
||||
*/
|
||||
|
||||
public static boolean isExternalStorageWritable() {
|
||||
// Checks if external storage is available for read and write
|
||||
String state = Environment.getExternalStorageState();
|
||||
return Environment.MEDIA_MOUNTED.equals(state);
|
||||
}
|
||||
|
||||
private static String getUniqueAbsolutePath(String testName) {
|
||||
// A screenshot after every test vs. manual tests
|
||||
String filename = UUID.randomUUID().toString() + DEFAULT_IMAGE_EXTENSION;
|
||||
if (testName != null && !testName.isEmpty()) {
|
||||
filename = testName + DEFAULT_IMAGE_EXTENSION;
|
||||
}
|
||||
|
||||
String externalPath = Environment.getExternalStorageDirectory().toString();
|
||||
String path = externalPath + File.separator + SCREENSHOT_FOLDER;
|
||||
File dir = new File(path);
|
||||
dir.mkdirs();
|
||||
path += File.separator + filename;
|
||||
Timber.d("Screenshot path: " + path);
|
||||
return path;
|
||||
}
|
||||
String externalPath = Environment.getExternalStorageDirectory().toString();
|
||||
String path = externalPath + File.separator + SCREENSHOT_FOLDER;
|
||||
File dir = new File(path);
|
||||
dir.mkdirs();
|
||||
path += File.separator + filename;
|
||||
Timber.d("Screenshot path: " + path);
|
||||
return path;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -4,15 +4,15 @@ import com.mapbox.mapboxsdk.constants.MapboxConstants;
|
||||
|
||||
public class TestConstants {
|
||||
|
||||
public static final long ANIMATION_TEST_TIME = MapboxConstants.ANIMATION_DURATION * 2;
|
||||
public static final long ANIMATION_TEST_TIME = MapboxConstants.ANIMATION_DURATION * 2;
|
||||
|
||||
public static final double LAT_LNG_DELTA_LARGE = 0.1;
|
||||
public static final double LAT_LNG_DELTA = 0.01;
|
||||
public static final double BEARING_DELTA = 0.1;
|
||||
public static final double TILT_DELTA = 0.1;
|
||||
public static final double ZOOM_DELTA = 0.3;
|
||||
public static final double LAT_LNG_DELTA_LARGE = 0.1;
|
||||
public static final double LAT_LNG_DELTA = 0.01;
|
||||
public static final double BEARING_DELTA = 0.1;
|
||||
public static final double TILT_DELTA = 0.1;
|
||||
public static final double ZOOM_DELTA = 0.3;
|
||||
|
||||
public static final String TEXT_MARKER_TEXT = "Text";
|
||||
public static final String TEXT_MARKER_TITLE = "Marker";
|
||||
public static final String TEXT_MARKER_SNIPPET = "Snippet";
|
||||
public static final String TEXT_MARKER_TEXT = "Text";
|
||||
public static final String TEXT_MARKER_TITLE = "Marker";
|
||||
public static final String TEXT_MARKER_SNIPPET = "Snippet";
|
||||
}
|
||||
|
||||
@@ -10,13 +10,13 @@ import static android.support.test.espresso.matcher.ViewMatchers.withId;
|
||||
|
||||
public class ViewUtils {
|
||||
|
||||
public static void clickView(@IdRes int viewRes) {
|
||||
onView(withId(viewRes))
|
||||
.perform(click());
|
||||
}
|
||||
public static void clickView(@IdRes int viewRes) {
|
||||
onView(withId(viewRes))
|
||||
.perform(click());
|
||||
}
|
||||
|
||||
public static void checkViewIsDisplayed(int id) {
|
||||
onView(withId(id))
|
||||
.check(matches(isDisplayed()));
|
||||
}
|
||||
public static void checkViewIsDisplayed(int id) {
|
||||
onView(withId(id))
|
||||
.check(matches(isDisplayed()));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user