diff options
author | Langston Smith <langston.smith@mapbox.com> | 2018-01-04 11:15:50 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-01-04 11:15:50 -0800 |
commit | 2ea955d2751ba6459f99a0695e53505c0a11702b (patch) | |
tree | f54450918b634a2eea1bd2c4ebc671bf1bb06106 /platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/annotations/MarkerViewTest.java | |
parent | f2ec6ae326bad79fea2b06a21151a2835522572a (diff) | |
parent | c62b0af24fc76b4bb2eb34100611dd3ee9ee5536 (diff) | |
download | qtlocation-mapboxgl-upstream/ls-android-readme-tweaks.tar.gz |
Merge branch 'master' into ls-android-readme-tweaksupstream/ls-android-readme-tweaks
Diffstat (limited to 'platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/annotations/MarkerViewTest.java')
-rw-r--r-- | platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/annotations/MarkerViewTest.java | 114 |
1 files changed, 32 insertions, 82 deletions
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 bee20c3150..ad153336a4 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 @@ -1,28 +1,21 @@ package com.mapbox.mapboxsdk.testapp.annotations; -import android.support.test.espresso.UiController; -import android.support.test.espresso.ViewAction; -import android.view.View; - import com.mapbox.mapboxsdk.annotations.Marker; import com.mapbox.mapboxsdk.geometry.LatLng; -import com.mapbox.mapboxsdk.maps.MapboxMap; -import com.mapbox.mapboxsdk.testapp.R; import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest; import com.mapbox.mapboxsdk.testapp.activity.annotation.MarkerViewActivity; import com.mapbox.mapboxsdk.testapp.activity.espresso.EspressoTestActivity; import com.mapbox.mapboxsdk.testapp.model.annotations.TextMarkerViewOptions; import com.mapbox.mapboxsdk.testapp.utils.TestConstants; -import org.hamcrest.Matcher; import org.junit.Ignore; import org.junit.Test; import static android.support.test.espresso.Espresso.onView; import static android.support.test.espresso.assertion.ViewAssertions.matches; import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed; -import static android.support.test.espresso.matcher.ViewMatchers.withId; import static android.support.test.espresso.matcher.ViewMatchers.withText; +import static com.mapbox.mapboxsdk.testapp.action.MapboxMapAction.invoke; import static org.junit.Assert.assertEquals; public class MarkerViewTest extends BaseActivityTest { @@ -38,20 +31,23 @@ public class MarkerViewTest extends BaseActivityTest { @Ignore public void addMarkerViewTest() { validateTestSetup(); - 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()); + addAdapter(); + invoke(mapboxMap, (uiController, mapboxMap) -> { + assertEquals("Markers should be empty", 0, mapboxMap.getMarkers().size()); + + TextMarkerViewOptions options = new TextMarkerViewOptions(); + options.text(TestConstants.TEXT_MARKER_TEXT); + options.position(new LatLng()); + options.snippet(TestConstants.TEXT_MARKER_SNIPPET); + options.title(TestConstants.TEXT_MARKER_TITLE); + marker = mapboxMap.addMarker(options); + assertEquals("Markers size should be 1, ", 1, mapboxMap.getMarkers().size()); + assertEquals("Marker id should be 0", 0, marker.getId()); + assertEquals("Marker target should match", new LatLng(), marker.getPosition()); + assertEquals("Marker snippet should match", TestConstants.TEXT_MARKER_SNIPPET, marker.getSnippet()); + assertEquals("Marker target should match", TestConstants.TEXT_MARKER_TITLE, marker.getTitle()); + uiController.loopMainThreadForAtLeast(500); + }); onView(withText(TestConstants.TEXT_MARKER_TEXT)).check(matches(isDisplayed())); } @@ -59,71 +55,25 @@ public class MarkerViewTest extends BaseActivityTest { @Ignore public void showInfoWindowTest() { validateTestSetup(); - - final TextMarkerViewOptions options = new TextMarkerViewOptions(); - options.position(new LatLng()); - options.text(TestConstants.TEXT_MARKER_TEXT); - options.snippet(TestConstants.TEXT_MARKER_SNIPPET); - options.title(TestConstants.TEXT_MARKER_TITLE); - - onView(withId(R.id.mapView)).perform(new AddTextMarkerViewAction(mapboxMap, options)); + addAdapter(); + invoke(mapboxMap, (uiController, mapboxMap) -> { + final TextMarkerViewOptions options = new TextMarkerViewOptions(); + options.position(new LatLng()); + options.text(TestConstants.TEXT_MARKER_TEXT); + options.snippet(TestConstants.TEXT_MARKER_SNIPPET); + options.title(TestConstants.TEXT_MARKER_TITLE); + marker = mapboxMap.addMarker(options); + uiController.loopMainThreadForAtLeast(500); + mapboxMap.selectMarker(marker); + }); onView(withText(TestConstants.TEXT_MARKER_TEXT)).check(matches(isDisplayed())); - onView(withId(R.id.mapView)).perform(new ShowInfoWindowAction(mapboxMap)); onView(withText(TestConstants.TEXT_MARKER_TITLE)).check(matches(isDisplayed())); onView(withText(TestConstants.TEXT_MARKER_SNIPPET)).check(matches(isDisplayed())); } - private class AddTextMarkerViewAction implements ViewAction { - - private MapboxMap mapboxMap; - private TextMarkerViewOptions options; - - AddTextMarkerViewAction(MapboxMap map, TextMarkerViewOptions markerOptions) { - mapboxMap = map; - options = markerOptions; - } - - @Override - public Matcher<View> getConstraints() { - return isDisplayed(); - } - - @Override - public String getDescription() { - return getClass().getSimpleName(); - } - - @Override - public void perform(UiController uiController, View view) { - mapboxMap.getMarkerViewManager().addMarkerViewAdapter( - new MarkerViewActivity.TextAdapter(view.getContext(), mapboxMap)); - marker = mapboxMap.addMarker(options); - uiController.loopMainThreadForAtLeast(250); - } + private void addAdapter() { + invoke(mapboxMap, (uiController, mapboxMap) -> mapboxMap.getMarkerViewManager().addMarkerViewAdapter( + new MarkerViewActivity.TextAdapter(rule.getActivity(), mapboxMap))); } - private class ShowInfoWindowAction implements ViewAction { - - private MapboxMap mapboxMap; - - ShowInfoWindowAction(MapboxMap map) { - mapboxMap = map; - } - - @Override - public Matcher<View> getConstraints() { - return isDisplayed(); - } - - @Override - public String getDescription() { - return getClass().getSimpleName(); - } - - @Override - public void perform(UiController uiController, View view) { - mapboxMap.selectMarker(marker); - uiController.loopMainThreadForAtLeast(250); - } - } } |