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/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/maps/MapTouchListenersTest.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/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/maps/MapTouchListenersTest.java')
-rw-r--r-- | platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/maps/MapTouchListenersTest.java | 95 |
1 files changed, 95 insertions, 0 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 new file mode 100644 index 0000000000..eeb00355bd --- /dev/null +++ b/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/maps/MapTouchListenersTest.java @@ -0,0 +1,95 @@ +package com.mapbox.mapboxsdk.maps; + +import android.graphics.PointF; + +import com.mapbox.mapboxsdk.geometry.LatLng; + +import org.junit.Test; + +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +public class MapTouchListenersTest { + + @Test + public void onMapClickListenerTest() 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.OnMapClickListener listener = mock(MapboxMap.OnMapClickListener.class); + mapGestureDetector.addOnMapClickListener(listener); + mapGestureDetector.notifyOnMapClickListeners(pointF); + verify(listener, times(1)).onMapClick(latLng); + + mapGestureDetector.removeOnMapClickListener(listener); + mapGestureDetector.notifyOnMapClickListeners(pointF); + verify(listener, times(1)).onMapClick(latLng); + } + + @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); + verify(listener, times(1)).onMapLongClick(latLng); + + mapGestureDetector.removeOnMapLongClickListener(listener); + mapGestureDetector.notifyOnMapLongClickListeners(pointF); + verify(listener, times(1)).onMapLongClick(latLng); + } + + @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(); + verify(listener, times(1)).onFling(); + + mapGestureDetector.removeOnFlingListener(listener); + mapGestureDetector.notifyOnFlingListeners(); + verify(listener, times(1)).onFling(); + } + + @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(); + verify(listener, times(1)).onScroll(); + + mapGestureDetector.removeOnScrollListener(listener); + mapGestureDetector.notifyOnScrollListeners(); + verify(listener, times(1)).onScroll(); + } +} |