diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/src/com/android/launcher3/touch/SingleAxisSwipeDetectorTest.java (renamed from tests/src/com/android/launcher3/touch/SwipeDetectorTest.java) | 44 |
1 files changed, 25 insertions, 19 deletions
diff --git a/tests/src/com/android/launcher3/touch/SwipeDetectorTest.java b/tests/src/com/android/launcher3/touch/SingleAxisSwipeDetectorTest.java index f209fae97..5174e4dab 100644 --- a/tests/src/com/android/launcher3/touch/SwipeDetectorTest.java +++ b/tests/src/com/android/launcher3/touch/SingleAxisSwipeDetectorTest.java @@ -15,6 +15,12 @@ */ package com.android.launcher3.touch; +import static com.android.launcher3.touch.SingleAxisSwipeDetector.DIRECTION_BOTH; +import static com.android.launcher3.touch.SingleAxisSwipeDetector.DIRECTION_NEGATIVE; +import static com.android.launcher3.touch.SingleAxisSwipeDetector.DIRECTION_POSITIVE; +import static com.android.launcher3.touch.SingleAxisSwipeDetector.HORIZONTAL; +import static com.android.launcher3.touch.SingleAxisSwipeDetector.VERTICAL; + import static org.mockito.Matchers.anyBoolean; import static org.mockito.Matchers.anyFloat; import static org.mockito.Matchers.anyObject; @@ -39,19 +45,19 @@ import org.mockito.MockitoAnnotations; @SmallTest @RunWith(AndroidJUnit4.class) -public class SwipeDetectorTest { +public class SingleAxisSwipeDetectorTest { - private static final String TAG = SwipeDetectorTest.class.getSimpleName(); + private static final String TAG = SingleAxisSwipeDetectorTest.class.getSimpleName(); public static void L(String s, Object... parts) { Log.d(TAG, (parts.length == 0) ? s : String.format(s, parts)); } private TouchEventGenerator mGenerator; - private SwipeDetector mDetector; + private SingleAxisSwipeDetector mDetector; private int mTouchSlop; @Mock - private SwipeDetector.Listener mMockListener; + private SingleAxisSwipeDetector.Listener mMockListener; @Mock private ViewConfiguration mMockConfig; @@ -65,8 +71,8 @@ public class SwipeDetectorTest { doReturn(orgConfig.getScaledMaximumFlingVelocity()).when(mMockConfig) .getScaledMaximumFlingVelocity(); - mDetector = new SwipeDetector(mMockConfig, mMockListener, SwipeDetector.VERTICAL, false); - mDetector.setDetectableScrollConditions(SwipeDetector.DIRECTION_BOTH, false); + mDetector = new SingleAxisSwipeDetector(mMockConfig, mMockListener, VERTICAL, false); + mDetector.setDetectableScrollConditions(DIRECTION_BOTH, false); mTouchSlop = orgConfig.getScaledTouchSlop(); doReturn(mTouchSlop).when(mMockConfig).getScaledTouchSlop(); @@ -75,8 +81,8 @@ public class SwipeDetectorTest { @Test public void testDragStart_verticalPositive() { - mDetector = new SwipeDetector(mMockConfig, mMockListener, SwipeDetector.VERTICAL, false); - mDetector.setDetectableScrollConditions(SwipeDetector.DIRECTION_POSITIVE, false); + mDetector = new SingleAxisSwipeDetector(mMockConfig, mMockListener, VERTICAL, false); + mDetector.setDetectableScrollConditions(DIRECTION_POSITIVE, false); mGenerator.put(0, 100, 100); mGenerator.move(0, 100, 100 - mTouchSlop); // TODO: actually calculate the following parameters and do exact value checks. @@ -85,8 +91,8 @@ public class SwipeDetectorTest { @Test public void testDragStart_verticalNegative() { - mDetector = new SwipeDetector(mMockConfig, mMockListener, SwipeDetector.VERTICAL, false); - mDetector.setDetectableScrollConditions(SwipeDetector.DIRECTION_NEGATIVE, false); + mDetector = new SingleAxisSwipeDetector(mMockConfig, mMockListener, VERTICAL, false); + mDetector.setDetectableScrollConditions(DIRECTION_NEGATIVE, false); mGenerator.put(0, 100, 100); mGenerator.move(0, 100, 100 + mTouchSlop); // TODO: actually calculate the following parameters and do exact value checks. @@ -103,8 +109,8 @@ public class SwipeDetectorTest { @Test public void testDragStart_horizontalPositive() { - mDetector = new SwipeDetector(mMockConfig, mMockListener, SwipeDetector.HORIZONTAL, false); - mDetector.setDetectableScrollConditions(SwipeDetector.DIRECTION_POSITIVE, false); + mDetector = new SingleAxisSwipeDetector(mMockConfig, mMockListener, HORIZONTAL, false); + mDetector.setDetectableScrollConditions(DIRECTION_POSITIVE, false); mGenerator.put(0, 100, 100); mGenerator.move(0, 100 + mTouchSlop, 100); @@ -114,8 +120,8 @@ public class SwipeDetectorTest { @Test public void testDragStart_horizontalNegative() { - mDetector = new SwipeDetector(mMockConfig, mMockListener, SwipeDetector.HORIZONTAL, false); - mDetector.setDetectableScrollConditions(SwipeDetector.DIRECTION_NEGATIVE, false); + mDetector = new SingleAxisSwipeDetector(mMockConfig, mMockListener, HORIZONTAL, false); + mDetector.setDetectableScrollConditions(DIRECTION_NEGATIVE, false); mGenerator.put(0, 100, 100); mGenerator.move(0, 100 - mTouchSlop, 100); @@ -125,8 +131,8 @@ public class SwipeDetectorTest { @Test public void testDragStart_horizontalRtlPositive() { - mDetector = new SwipeDetector(mMockConfig, mMockListener, SwipeDetector.HORIZONTAL, true); - mDetector.setDetectableScrollConditions(SwipeDetector.DIRECTION_POSITIVE, false); + mDetector = new SingleAxisSwipeDetector(mMockConfig, mMockListener, HORIZONTAL, true); + mDetector.setDetectableScrollConditions(DIRECTION_POSITIVE, false); mGenerator.put(0, 100, 100); mGenerator.move(0, 100 - mTouchSlop, 100); @@ -136,8 +142,8 @@ public class SwipeDetectorTest { @Test public void testDragStart_horizontalRtlNegative() { - mDetector = new SwipeDetector(mMockConfig, mMockListener, SwipeDetector.HORIZONTAL, true); - mDetector.setDetectableScrollConditions(SwipeDetector.DIRECTION_NEGATIVE, false); + mDetector = new SingleAxisSwipeDetector(mMockConfig, mMockListener, HORIZONTAL, true); + mDetector.setDetectableScrollConditions(DIRECTION_NEGATIVE, false); mGenerator.put(0, 100, 100); mGenerator.move(0, 100 + mTouchSlop, 100); @@ -160,6 +166,6 @@ public class SwipeDetectorTest { mGenerator.move(0, 100, 100 + mTouchSlop * 2); mGenerator.lift(0); // TODO: actually calculate the following parameters and do exact value checks. - verify(mMockListener).onDragEnd(anyFloat(), anyBoolean()); + verify(mMockListener).onDragEnd(anyFloat()); } } |