summaryrefslogtreecommitdiff
path: root/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/annotations/IconTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/annotations/IconTest.java')
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/annotations/IconTest.java161
1 files changed, 76 insertions, 85 deletions
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/annotations/IconTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/annotations/IconTest.java
index 9fb823a377..559213af3d 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/annotations/IconTest.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/annotations/IconTest.java
@@ -1,6 +1,7 @@
package com.mapbox.mapboxsdk.testapp.annotations;
import android.app.Activity;
+import android.support.test.annotation.UiThreadTest;
import android.support.v4.content.res.ResourcesCompat;
import com.mapbox.mapboxsdk.annotations.Icon;
import com.mapbox.mapboxsdk.annotations.IconFactory;
@@ -31,117 +32,107 @@ public class IconTest extends EspressoTest {
@Before
public void beforeTest() {
super.beforeTest();
- iconMap = new IconManagerResolver(getMapboxMap()).getIconMap();
- }
-
- @Test
- public void testEmpty() {
- assertTrue(iconMap.isEmpty());
+ iconMap = new IconManagerResolver(mapboxMap).getIconMap();
}
@Test
+ @UiThreadTest
public void testAddSameIconMarker() {
validateTestSetup();
- onMapView().perform(getMapboxMapAction((uiController, mapboxMap) -> {
- Icon defaultMarker = IconFactory.getInstance(rule.getActivity()).defaultMarker();
- mapboxMap.addMarker(new MarkerOptions().position(new LatLng()));
- mapboxMap.addMarker(new MarkerOptions().position(new LatLng(1, 1)));
- assertEquals(1, iconMap.size());
- assertEquals(2, iconMap.get(defaultMarker), 0);
- }));
+ Icon defaultMarker = IconFactory.getInstance(rule.getActivity()).defaultMarker();
+ mapboxMap.addMarker(new MarkerOptions().position(new LatLng()));
+ mapboxMap.addMarker(new MarkerOptions().position(new LatLng(1, 1)));
+ assertEquals(1, iconMap.size());
+ assertEquals(2, iconMap.get(defaultMarker), 0);
}
@Test
+ @UiThreadTest
public void testAddDifferentIconMarker() {
validateTestSetup();
- onMapView().perform(getMapboxMapAction((uiController, mapboxMap) -> {
- Icon icon = IconFactory.getInstance(rule.getActivity()).fromResource(R.drawable.mapbox_logo_icon);
- getMapboxMap().addMarker(new MarkerOptions().icon(icon).position(new LatLng()));
- getMapboxMap().addMarker(new MarkerOptions().position(new LatLng(1, 1)));
- assertEquals(iconMap.size(), 2);
- assertTrue(iconMap.containsKey(icon));
- assertTrue(iconMap.get(icon) == 1);
- }));
+ Icon icon = IconFactory.getInstance(rule.getActivity()).fromResource(R.drawable.mapbox_logo_icon);
+ mapboxMap.addMarker(new MarkerOptions().icon(icon).position(new LatLng()));
+ mapboxMap.addMarker(new MarkerOptions().position(new LatLng(1, 1)));
+ assertEquals(iconMap.size(), 2);
+ assertTrue(iconMap.containsKey(icon));
+ assertTrue(iconMap.get(icon) == 1);
}
@Test
+ @UiThreadTest
public void testAddRemoveIconMarker() {
validateTestSetup();
- onMapView().perform(getMapboxMapAction((uiController, mapboxMap) -> {
- Icon icon = IconFactory.getInstance(rule.getActivity()).fromResource(R.drawable.mapbox_logo_icon);
- Marker marker = mapboxMap.addMarker(new MarkerOptions().icon(icon).position(new LatLng()));
- mapboxMap.addMarker(new MarkerOptions().position(new LatLng(1, 1)));
- assertEquals(iconMap.size(), 2);
- assertTrue(iconMap.containsKey(icon));
- assertTrue(iconMap.get(icon) == 1);
-
- mapboxMap.removeMarker(marker);
- assertEquals(iconMap.size(), 1);
- assertFalse(iconMap.containsKey(icon));
- }));
+ Icon icon = IconFactory.getInstance(rule.getActivity()).fromResource(R.drawable.mapbox_logo_icon);
+ Marker marker = mapboxMap.addMarker(new MarkerOptions().icon(icon).position(new LatLng()));
+ mapboxMap.addMarker(new MarkerOptions().position(new LatLng(1, 1)));
+ assertEquals(iconMap.size(), 2);
+ assertTrue(iconMap.containsKey(icon));
+ assertTrue(iconMap.get(icon) == 1);
+
+ mapboxMap.removeMarker(marker);
+ assertEquals(iconMap.size(), 1);
+ assertFalse(iconMap.containsKey(icon));
}
@Test
+ @UiThreadTest
public void testAddRemoveDefaultMarker() {
validateTestSetup();
- onMapView().perform(getMapboxMapAction((uiController, mapboxMap) -> {
- Marker marker = mapboxMap.addMarker(new MarkerOptions().position(new LatLng(1, 1)));
- assertEquals(iconMap.size(), 1);
+ Marker marker = mapboxMap.addMarker(new MarkerOptions().position(new LatLng(1, 1)));
+ assertEquals(iconMap.size(), 1);
- mapboxMap.removeMarker(marker);
- assertEquals(iconMap.size(), 0);
+ mapboxMap.removeMarker(marker);
+ assertEquals(iconMap.size(), 0);
- mapboxMap.addMarker(new MarkerOptions().position(new LatLng()));
- assertEquals(iconMap.size(), 1);
- }));
+ mapboxMap.addMarker(new MarkerOptions().position(new LatLng()));
+ assertEquals(iconMap.size(), 1);
}
@Test
+ @UiThreadTest
public void testAddRemoveMany() {
validateTestSetup();
- onMapView().perform(getMapboxMapAction((uiController, mapboxMap) -> {
- Activity activity = rule.getActivity();
- IconFactory iconFactory = IconFactory.getInstance(activity);
-
- // add 2 default icon markers
- Marker defaultMarkerOne = mapboxMap.addMarker(new MarkerOptions().position(new LatLng(1, 1)));
- Marker defaultMarkerTwo = mapboxMap.addMarker(new MarkerOptions().position(new LatLng(2, 1)));
-
- // add 4 unique icon markers
- mapboxMap.addMarker(new MarkerOptions()
- .icon(iconFactory.fromResource(R.drawable.mapbox_logo_icon))
- .position(new LatLng(3, 1))
- );
- mapboxMap.addMarker(new MarkerOptions()
- .icon(iconFactory.fromResource(R.drawable.mapbox_compass_icon))
- .position(new LatLng(4, 1))
- );
- mapboxMap.addMarker(new MarkerOptions()
- .icon(IconUtils.drawableToIcon(activity, R.drawable.ic_stars,
- ResourcesCompat.getColor(activity.getResources(),
- R.color.blueAccent, activity.getTheme())))
- .position(new LatLng(5, 1))
- );
- mapboxMap.addMarker(new MarkerOptions()
- .icon(iconFactory.fromResource(R.drawable.ic_android))
- .position(new LatLng(6, 1))
- );
-
- assertEquals("Amount of icons should match 5", 5, iconMap.size());
- assertEquals("Refcounter of default marker should match 2", 2, iconMap.get(iconFactory.defaultMarker()), 0);
-
- mapboxMap.removeMarker(defaultMarkerOne);
-
- assertEquals("Amount of icons should match 5", 5, iconMap.size());
- assertEquals("Refcounter of default marker should match 1", 1, iconMap.get(iconFactory.defaultMarker()), 0);
-
- mapboxMap.removeMarker(defaultMarkerTwo);
-
- assertEquals("Amount of icons should match 4", 4, iconMap.size());
- assertNull("DefaultMarker shouldn't exist anymore", iconMap.get(iconFactory.defaultMarker()));
-
- mapboxMap.clear();
- assertEquals("Amount of icons should match 0", 0, iconMap.size());
- }));
+ Activity activity = rule.getActivity();
+ IconFactory iconFactory = IconFactory.getInstance(activity);
+
+ // add 2 default icon markers
+ Marker defaultMarkerOne = mapboxMap.addMarker(new MarkerOptions().position(new LatLng(1, 1)));
+ Marker defaultMarkerTwo = mapboxMap.addMarker(new MarkerOptions().position(new LatLng(2, 1)));
+
+ // add 4 unique icon markers
+ mapboxMap.addMarker(new MarkerOptions()
+ .icon(iconFactory.fromResource(R.drawable.mapbox_logo_icon))
+ .position(new LatLng(3, 1))
+ );
+ mapboxMap.addMarker(new MarkerOptions()
+ .icon(iconFactory.fromResource(R.drawable.mapbox_compass_icon))
+ .position(new LatLng(4, 1))
+ );
+ mapboxMap.addMarker(new MarkerOptions()
+ .icon(IconUtils.drawableToIcon(activity, R.drawable.ic_stars,
+ ResourcesCompat.getColor(activity.getResources(),
+ R.color.blueAccent, activity.getTheme())))
+ .position(new LatLng(5, 1))
+ );
+ mapboxMap.addMarker(new MarkerOptions()
+ .icon(iconFactory.fromResource(R.drawable.ic_android))
+ .position(new LatLng(6, 1))
+ );
+
+ assertEquals("Amount of icons should match 5", 5, iconMap.size());
+ assertEquals("Refcounter of default marker should match 2", 2, iconMap.get(iconFactory.defaultMarker()), 0);
+
+ mapboxMap.removeMarker(defaultMarkerOne);
+
+ assertEquals("Amount of icons should match 5", 5, iconMap.size());
+ assertEquals("Refcounter of default marker should match 1", 1, iconMap.get(iconFactory.defaultMarker()), 0);
+
+ mapboxMap.removeMarker(defaultMarkerTwo);
+
+ assertEquals("Amount of icons should match 4", 4, iconMap.size());
+ assertNull("DefaultMarker shouldn't exist anymore", iconMap.get(iconFactory.defaultMarker()));
+
+ mapboxMap.clear();
+ assertEquals("Amount of icons should match 0", 0, iconMap.size());
}
}