diff options
Diffstat (limited to 'platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/annotations')
4 files changed, 311 insertions, 309 deletions
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/annotations/MarkerTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/annotations/MarkerTest.java index 36e943b7ff..77025c8fa5 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/annotations/MarkerTest.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/annotations/MarkerTest.java @@ -32,111 +32,111 @@ import static org.junit.Assert.assertEquals; public class MarkerTest { - @Rule - public final ActivityTestRule<EspressoTestActivity> rule = new ActivityTestRule<>(EspressoTestActivity.class); - - private OnMapReadyIdlingResource idlingResource; - private Marker marker; - - @Before - public void registerIdlingResource() { - idlingResource = new OnMapReadyIdlingResource(rule.getActivity()); - Espresso.registerIdlingResources(idlingResource); + @Rule + public final ActivityTestRule<EspressoTestActivity> rule = new ActivityTestRule<>(EspressoTestActivity.class); + + private OnMapReadyIdlingResource idlingResource; + private Marker marker; + + @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 { - - private MapboxMap mapboxMap; - private MarkerOptions options; - - AddMarkerAction(MapboxMap map, MarkerOptions markerOptions) { - mapboxMap = map; - options = markerOptions; - } - - @Override - public Matcher<View> getConstraints() { - return isDisplayed(); - } - - @Override - public String getDescription() { - return getClass().getSimpleName(); - } - - @Override - public void perform(UiController uiController, View view) { - marker = mapboxMap.addMarker(options); - } + @Override + public void perform(UiController uiController, View view) { + marker = mapboxMap.addMarker(options); } + } - private class ShowInfoWindowAction implements ViewAction { + private class ShowInfoWindowAction implements ViewAction { - private MapboxMap mapboxMap; + private MapboxMap mapboxMap; - ShowInfoWindowAction(MapboxMap map) { - mapboxMap = map; - } + ShowInfoWindowAction(MapboxMap map) { + mapboxMap = map; + } - @Override - public Matcher<View> getConstraints() { - return isDisplayed(); - } + @Override + public Matcher<View> getConstraints() { + return isDisplayed(); + } - @Override - public String getDescription() { - return getClass().getSimpleName(); - } + @Override + public String getDescription() { + return getClass().getSimpleName(); + } - @Override - public void perform(UiController uiController, View view) { - mapboxMap.selectMarker(marker); + @Override + public void perform(UiController uiController, View view) { + mapboxMap.selectMarker(marker); - } } + } - @After - public void unregisterIdlingResource() { - Espresso.unregisterIdlingResources(idlingResource); - } + @After + public void unregisterIdlingResource() { + Espresso.unregisterIdlingResources(idlingResource); + } } diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/annotations/MarkerViewTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/annotations/MarkerViewTest.java index 09f707c4b5..9351ed1c10 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/annotations/MarkerViewTest.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/annotations/MarkerViewTest.java @@ -33,114 +33,115 @@ import static org.junit.Assert.assertEquals; public class MarkerViewTest { - @Rule - public final ActivityTestRule<EspressoTestActivity> rule = new ActivityTestRule<>(EspressoTestActivity.class); - - private OnMapReadyIdlingResource idlingResource; - private Marker marker; - - @Before - public void registerIdlingResource() { - idlingResource = new OnMapReadyIdlingResource(rule.getActivity()); - Espresso.registerIdlingResources(idlingResource); + @Rule + public final ActivityTestRule<EspressoTestActivity> rule = new ActivityTestRule<>(EspressoTestActivity.class); + + private OnMapReadyIdlingResource idlingResource; + private Marker marker; + + @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 { - - private MapboxMap mapboxMap; - private TextMarkerViewOptions options; - - AddTextMarkerViewAction(MapboxMap map, TextMarkerViewOptions markerOptions) { - mapboxMap = map; - options = markerOptions; - } - - @Override - public Matcher<View> getConstraints() { - return isDisplayed(); - } - - @Override - public String getDescription() { - return getClass().getSimpleName(); - } - - @Override - public void perform(UiController uiController, View view) { - mapboxMap.getMarkerViewManager().addMarkerViewAdapter(new MarkerViewActivity.TextAdapter(view.getContext(), mapboxMap)); - marker = mapboxMap.addMarker(options); - uiController.loopMainThreadForAtLeast(250); - } + @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 class ShowInfoWindowAction implements ViewAction { - - private MapboxMap mapboxMap; + private class ShowInfoWindowAction implements ViewAction { - ShowInfoWindowAction(MapboxMap map) { - mapboxMap = map; - } + private MapboxMap mapboxMap; - @Override - public Matcher<View> getConstraints() { - return isDisplayed(); - } + ShowInfoWindowAction(MapboxMap map) { + mapboxMap = map; + } - @Override - public String getDescription() { - return getClass().getSimpleName(); - } + @Override + public Matcher<View> getConstraints() { + return isDisplayed(); + } - @Override - public void perform(UiController uiController, View view) { - mapboxMap.selectMarker(marker); - uiController.loopMainThreadForAtLeast(250); - } + @Override + public String getDescription() { + return getClass().getSimpleName(); } - @After - public void unregisterIdlingResource() { - Espresso.unregisterIdlingResources(idlingResource); + @Override + public void perform(UiController uiController, View view) { + mapboxMap.selectMarker(marker); + uiController.loopMainThreadForAtLeast(250); } + } + + @After + public void unregisterIdlingResource() { + Espresso.unregisterIdlingResources(idlingResource); + } } diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/annotations/PolygonTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/annotations/PolygonTest.java index 366e1851b8..24b9b3bf01 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/annotations/PolygonTest.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/annotations/PolygonTest.java @@ -30,75 +30,76 @@ import static org.junit.Assert.assertEquals; public class PolygonTest { - @Rule - public final ActivityTestRule<EspressoTestActivity> rule = new ActivityTestRule<>(EspressoTestActivity.class); - - private OnMapReadyIdlingResource idlingResource; - private Polygon polygon; - - @Before - public void registerIdlingResource() { - idlingResource = new OnMapReadyIdlingResource(rule.getActivity()); - Espresso.registerIdlingResources(idlingResource); + @Rule + public final ActivityTestRule<EspressoTestActivity> rule = new ActivityTestRule<>(EspressoTestActivity.class); + + private OnMapReadyIdlingResource idlingResource; + private Polygon polygon; + + @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); + } } diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/annotations/PolylineTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/annotations/PolylineTest.java index eb273b8cf9..607a4ad263 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/annotations/PolylineTest.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/annotations/PolylineTest.java @@ -30,71 +30,71 @@ import static org.junit.Assert.assertEquals; public class PolylineTest { - @Rule - public final ActivityTestRule<EspressoTestActivity> rule = new ActivityTestRule<>(EspressoTestActivity.class); - - private OnMapReadyIdlingResource idlingResource; - private Polyline polyline; - - @Before - public void registerIdlingResource() { - idlingResource = new OnMapReadyIdlingResource(rule.getActivity()); - Espresso.registerIdlingResources(idlingResource); + @Rule + public final ActivityTestRule<EspressoTestActivity> rule = new ActivityTestRule<>(EspressoTestActivity.class); + + private OnMapReadyIdlingResource idlingResource; + private Polyline polyline; + + @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); + } } |