summaryrefslogtreecommitdiff
path: root/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/maps/MapTouchListenersTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/maps/MapTouchListenersTest.java')
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/maps/MapTouchListenersTest.java132
1 files changed, 102 insertions, 30 deletions
diff --git a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/maps/MapTouchListenersTest.java b/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/maps/MapTouchListenersTest.java
index eeb00355bd..5de55f47c9 100644
--- a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/maps/MapTouchListenersTest.java
+++ b/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/maps/MapTouchListenersTest.java
@@ -2,8 +2,13 @@ package com.mapbox.mapboxsdk.maps;
import android.graphics.PointF;
+import com.mapbox.android.gestures.MoveGestureDetector;
+import com.mapbox.android.gestures.RotateGestureDetector;
+import com.mapbox.android.gestures.ShoveGestureDetector;
+import com.mapbox.android.gestures.StandardScaleGestureDetector;
import com.mapbox.mapboxsdk.geometry.LatLng;
+import org.junit.Before;
import org.junit.Test;
import static org.mockito.Mockito.mock;
@@ -13,16 +18,23 @@ import static org.mockito.Mockito.when;
public class MapTouchListenersTest {
- @Test
- public void onMapClickListenerTest() throws Exception {
- LatLng latLng = new LatLng();
- PointF pointF = new PointF();
+ private MapGestureDetector mapGestureDetector;
+ private LatLng latLng;
+ private PointF pointF;
+
+ @Before
+ public void setUp() throws Exception {
+ latLng = new LatLng();
+ pointF = new PointF();
Projection projection = mock(Projection.class);
when(projection.fromScreenLocation(pointF)).thenReturn(latLng);
- MapGestureDetector mapGestureDetector = new MapGestureDetector(null,
- null, projection, null, null, null, null);
+ mapGestureDetector = new MapGestureDetector(null,
+ null, projection, null, null, null);
+ }
+ @Test
+ public void onMapClickListenerTest() throws Exception {
MapboxMap.OnMapClickListener listener = mock(MapboxMap.OnMapClickListener.class);
mapGestureDetector.addOnMapClickListener(listener);
mapGestureDetector.notifyOnMapClickListeners(pointF);
@@ -35,14 +47,6 @@ public class MapTouchListenersTest {
@Test
public void onMapLongClickListenerTest() throws Exception {
- LatLng latLng = new LatLng();
- PointF pointF = new PointF();
-
- Projection projection = mock(Projection.class);
- when(projection.fromScreenLocation(pointF)).thenReturn(latLng);
- MapGestureDetector mapGestureDetector = new MapGestureDetector(null,
- null, projection, null, null, null, null);
-
MapboxMap.OnMapLongClickListener listener = mock(MapboxMap.OnMapLongClickListener.class);
mapGestureDetector.addOnMapLongClickListener(listener);
mapGestureDetector.notifyOnMapLongClickListeners(pointF);
@@ -55,14 +59,6 @@ public class MapTouchListenersTest {
@Test
public void onFlingListenerTest() throws Exception {
- LatLng latLng = new LatLng();
- PointF pointF = new PointF();
-
- Projection projection = mock(Projection.class);
- when(projection.fromScreenLocation(pointF)).thenReturn(latLng);
- MapGestureDetector mapGestureDetector = new MapGestureDetector(null,
- null, projection, null, null, null, null);
-
MapboxMap.OnFlingListener listener = mock(MapboxMap.OnFlingListener.class);
mapGestureDetector.addOnFlingListener(listener);
mapGestureDetector.notifyOnFlingListeners();
@@ -75,14 +71,6 @@ public class MapTouchListenersTest {
@Test
public void onScrollListenerTest() throws Exception {
- LatLng latLng = new LatLng();
- PointF pointF = new PointF();
-
- Projection projection = mock(Projection.class);
- when(projection.fromScreenLocation(pointF)).thenReturn(latLng);
- MapGestureDetector mapGestureDetector = new MapGestureDetector(null,
- null, projection, null, null, null, null);
-
MapboxMap.OnScrollListener listener = mock(MapboxMap.OnScrollListener.class);
mapGestureDetector.addOnScrollListener(listener);
mapGestureDetector.notifyOnScrollListeners();
@@ -92,4 +80,88 @@ public class MapTouchListenersTest {
mapGestureDetector.notifyOnScrollListeners();
verify(listener, times(1)).onScroll();
}
+
+ @Test
+ public void onMoveListenerTest() throws Exception {
+ MapboxMap.OnMoveListener listener = mock(MapboxMap.OnMoveListener.class);
+ MoveGestureDetector detector = mock(MoveGestureDetector.class);
+ mapGestureDetector.addOnMoveListener(listener);
+ mapGestureDetector.notifyOnMoveBeginListeners(detector);
+ mapGestureDetector.notifyOnMoveListeners(detector);
+ mapGestureDetector.notifyOnMoveEndListeners(detector);
+ verify(listener, times(1)).onMoveBegin(detector);
+ verify(listener, times(1)).onMove(detector);
+ verify(listener, times(1)).onMoveEnd(detector);
+
+ mapGestureDetector.removeOnMoveListener(listener);
+ mapGestureDetector.notifyOnMoveBeginListeners(detector);
+ mapGestureDetector.notifyOnMoveListeners(detector);
+ mapGestureDetector.notifyOnMoveEndListeners(detector);
+ verify(listener, times(1)).onMoveBegin(detector);
+ verify(listener, times(1)).onMove(detector);
+ verify(listener, times(1)).onMoveEnd(detector);
+ }
+
+ @Test
+ public void onRotateListenerTest() throws Exception {
+ MapboxMap.OnRotateListener listener = mock(MapboxMap.OnRotateListener.class);
+ RotateGestureDetector detector = mock(RotateGestureDetector.class);
+ mapGestureDetector.addOnRotateListener(listener);
+ mapGestureDetector.notifyOnRotateBeginListeners(detector);
+ mapGestureDetector.notifyOnRotateListeners(detector);
+ mapGestureDetector.notifyOnRotateEndListeners(detector);
+ verify(listener, times(1)).onRotateBegin(detector);
+ verify(listener, times(1)).onRotate(detector);
+ verify(listener, times(1)).onRotateEnd(detector);
+
+ mapGestureDetector.removeOnRotateListener(listener);
+ mapGestureDetector.notifyOnRotateBeginListeners(detector);
+ mapGestureDetector.notifyOnRotateListeners(detector);
+ mapGestureDetector.notifyOnRotateEndListeners(detector);
+ verify(listener, times(1)).onRotateBegin(detector);
+ verify(listener, times(1)).onRotate(detector);
+ verify(listener, times(1)).onRotateEnd(detector);
+ }
+
+ @Test
+ public void onScaleListenerTest() throws Exception {
+ MapboxMap.OnScaleListener listener = mock(MapboxMap.OnScaleListener.class);
+ StandardScaleGestureDetector detector = mock(StandardScaleGestureDetector.class);
+ mapGestureDetector.addOnScaleListener(listener);
+ mapGestureDetector.notifyOnScaleBeginListeners(detector);
+ mapGestureDetector.notifyOnScaleListeners(detector);
+ mapGestureDetector.notifyOnScaleEndListeners(detector);
+ verify(listener, times(1)).onScaleBegin(detector);
+ verify(listener, times(1)).onScale(detector);
+ verify(listener, times(1)).onScaleEnd(detector);
+
+ mapGestureDetector.removeOnScaleListener(listener);
+ mapGestureDetector.notifyOnScaleBeginListeners(detector);
+ mapGestureDetector.notifyOnScaleListeners(detector);
+ mapGestureDetector.notifyOnScaleEndListeners(detector);
+ verify(listener, times(1)).onScaleBegin(detector);
+ verify(listener, times(1)).onScale(detector);
+ verify(listener, times(1)).onScaleEnd(detector);
+ }
+
+ @Test
+ public void onShoveListenerTest() throws Exception {
+ MapboxMap.OnShoveListener listener = mock(MapboxMap.OnShoveListener.class);
+ ShoveGestureDetector detector = mock(ShoveGestureDetector.class);
+ mapGestureDetector.addShoveListener(listener);
+ mapGestureDetector.notifyOnShoveBeginListeners(detector);
+ mapGestureDetector.notifyOnShoveListeners(detector);
+ mapGestureDetector.notifyOnShoveEndListeners(detector);
+ verify(listener, times(1)).onShoveBegin(detector);
+ verify(listener, times(1)).onShove(detector);
+ verify(listener, times(1)).onShoveEnd(detector);
+
+ mapGestureDetector.removeShoveListener(listener);
+ mapGestureDetector.notifyOnShoveBeginListeners(detector);
+ mapGestureDetector.notifyOnShoveListeners(detector);
+ mapGestureDetector.notifyOnShoveEndListeners(detector);
+ verify(listener, times(1)).onShoveBegin(detector);
+ verify(listener, times(1)).onShove(detector);
+ verify(listener, times(1)).onShoveEnd(detector);
+ }
}