summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorSunny Goyal <sunnygoyal@google.com>2017-07-14 00:02:27 -0700
committerSunny Goyal <sunnygoyal@google.com>2017-07-20 01:33:10 -0700
commitb72d8b2c8b999f3842dc7b0d93bb1a816b6204b9 (patch)
treeb20bd154d07c5b169dd5745ffd12812b6c17baac /tests
parentf567ee8f42cab072f10002302d85e99083122481 (diff)
downloadandroid_packages_apps_Trebuchet-b72d8b2c8b999f3842dc7b0d93bb1a816b6204b9.tar.gz
android_packages_apps_Trebuchet-b72d8b2c8b999f3842dc7b0d93bb1a816b6204b9.tar.bz2
android_packages_apps_Trebuchet-b72d8b2c8b999f3842dc7b0d93bb1a816b6204b9.zip
Using common fling detection logic for notification and all-apps
> Refactoring SwipeDetector to both allow vertical and horizontal swipes > Using SwipeDetector and common overscroll effect for notification swipes instead of a separate logic Change-Id: Ib706ee179811ade59ddb68184e1c202365d147c4
Diffstat (limited to 'tests')
-rw-r--r--tests/src/com/android/launcher3/touch/SwipeDetectorTest.java33
1 files changed, 26 insertions, 7 deletions
diff --git a/tests/src/com/android/launcher3/touch/SwipeDetectorTest.java b/tests/src/com/android/launcher3/touch/SwipeDetectorTest.java
index 8724704ed..ff83131d1 100644
--- a/tests/src/com/android/launcher3/touch/SwipeDetectorTest.java
+++ b/tests/src/com/android/launcher3/touch/SwipeDetectorTest.java
@@ -15,7 +15,6 @@
*/
package com.android.launcher3.touch;
-import android.content.Context;
import android.support.test.InstrumentationRegistry;
import android.support.test.filters.SmallTest;
import android.support.test.runner.AndroidJUnit4;
@@ -33,11 +32,12 @@ import org.mockito.MockitoAnnotations;
import static org.mockito.Matchers.anyBoolean;
import static org.mockito.Matchers.anyFloat;
+import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
@SmallTest
@RunWith(AndroidJUnit4.class)
-public class SwipeDetectorTest{
+public class SwipeDetectorTest {
private static final String TAG = SwipeDetectorTest.class.getSimpleName();
public static void L(String s, Object... parts) {
@@ -54,22 +54,22 @@ public class SwipeDetectorTest{
@Before
public void setup() {
MockitoAnnotations.initMocks(this);
- Context context = InstrumentationRegistry.getTargetContext();
- mDetector = new SwipeDetector(context);
mGenerator = new TouchEventGenerator(new TouchEventGenerator.Listener() {
@Override
public void onTouchEvent(MotionEvent event) {
mDetector.onTouchEvent(event);
}
});
- mDetector.setListener(mMockListener);
+
+ mDetector = new SwipeDetector(mTouchSlop, mMockListener, SwipeDetector.VERTICAL);
mDetector.setDetectableScrollConditions(SwipeDetector.DIRECTION_BOTH, false);
- mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();
+ mTouchSlop = ViewConfiguration.get(InstrumentationRegistry.getTargetContext())
+ .getScaledTouchSlop();
L("mTouchSlop=", mTouchSlop);
}
@Test
- public void testDragStart() throws Exception {
+ public void testDragStart_vertical() throws Exception {
mGenerator.put(0, 100, 100);
mGenerator.move(0, 100, 100 + mTouchSlop);
// TODO: actually calculate the following parameters and do exact value checks.
@@ -77,6 +77,25 @@ public class SwipeDetectorTest{
}
@Test
+ public void testDragStart_failed() throws Exception {
+ mGenerator.put(0, 100, 100);
+ mGenerator.move(0, 100 + mTouchSlop, 100);
+ // TODO: actually calculate the following parameters and do exact value checks.
+ verify(mMockListener, never()).onDragStart(anyBoolean());
+ }
+
+ @Test
+ public void testDragStart_horizontal() throws Exception {
+ mDetector = new SwipeDetector(mTouchSlop, mMockListener, SwipeDetector.HORIZONTAL);
+ mDetector.setDetectableScrollConditions(SwipeDetector.DIRECTION_BOTH, false);
+
+ mGenerator.put(0, 100, 100);
+ mGenerator.move(0, 100 + mTouchSlop, 100);
+ // TODO: actually calculate the following parameters and do exact value checks.
+ verify(mMockListener).onDragStart(anyBoolean());
+ }
+
+ @Test
public void testDrag() throws Exception {
mGenerator.put(0, 100, 100);
mGenerator.move(0, 100, 100 + mTouchSlop);