11package com .mapbox .android .gestures ;
22
3+ import static junit .framework .Assert .assertEquals ;
4+ import static junit .framework .Assert .assertNotNull ;
5+ import static org .junit .Assert .assertTrue ;
6+
7+ import android .view .MotionEvent ;
8+
39import org .junit .Before ;
410import org .junit .Test ;
511import org .junit .runner .RunWith ;
1117import java .util .List ;
1218import java .util .Set ;
1319
14- import static junit .framework .Assert .assertEquals ;
15- import static junit .framework .Assert .assertNotNull ;
16-
1720@ RunWith (RobolectricTestRunner .class )
1821public class AndroidGesturesManagerTest {
1922 private AndroidGesturesManager androidGesturesManager ;
@@ -44,9 +47,9 @@ public void setUp() throws Exception {
4447 mutuallyExclusivesList .add (set3 );
4548
4649 androidGesturesManager =
47- new AndroidGesturesManager (
48- RuntimeEnvironment .application .getApplicationContext (),
49- mutuallyExclusivesList , true );
50+ new AndroidGesturesManager (
51+ RuntimeEnvironment .application .getApplicationContext (),
52+ mutuallyExclusivesList , true );
5053 }
5154
5255 @ Test
@@ -69,4 +72,21 @@ public void setMutuallyExclusivesTest() throws Exception {
6972 androidGesturesManager .setMutuallyExclusiveGestures (mutuallyExclusivesList );
7073 assertEquals (androidGesturesManager .getMutuallyExclusiveGestures (), mutuallyExclusivesList );
7174 }
75+
76+ @ Test
77+ public void onSingleTapModifyDetectorsTest () {
78+ final StandardGestureDetector standardGestureDetector = new StandardGestureDetector (RuntimeEnvironment .getApplication ().getApplicationContext (), androidGesturesManager );
79+
80+ androidGesturesManager .setStandardGestureListener (new StandardGestureDetector .SimpleStandardOnGestureListener () {
81+ @ Override
82+ public boolean onDown (MotionEvent e ) {
83+ androidGesturesManager .getDetectors ().add (standardGestureDetector );
84+ return true ;
85+ }
86+ });
87+
88+ MotionEvent downEvent = TestUtils .INSTANCE .getMotionEvent (MotionEvent .ACTION_DOWN , 0 , 0 , null );
89+ androidGesturesManager .onTouchEvent (downEvent );
90+ assertTrue (androidGesturesManager .getDetectors ().contains (standardGestureDetector ));
91+ }
7292}
0 commit comments