summaryrefslogtreecommitdiffstats
path: root/tests/src/com/android/launcher3/touch
diff options
context:
space:
mode:
authorTony <twickham@google.com>2019-03-22 19:15:39 -0500
committerTony <twickham@google.com>2019-03-27 19:45:04 -0500
commit101807d8e7169e3b9381e1708b4bd1097aad1bc0 (patch)
tree5db597eacc7062424da6f7a935b37c3ddfe28bcd /tests/src/com/android/launcher3/touch
parente06fef45a43ea2e9ddc426850f12568c7105cdf2 (diff)
downloadandroid_packages_apps_Trebuchet-101807d8e7169e3b9381e1708b4bd1097aad1bc0.tar.gz
android_packages_apps_Trebuchet-101807d8e7169e3b9381e1708b4bd1097aad1bc0.tar.bz2
android_packages_apps_Trebuchet-101807d8e7169e3b9381e1708b4bd1097aad1bc0.zip
Fix SwipeDetector positive vs negative for HORIZONTAL direction
Previously left was considered positive and right considered negative. Now left and down are negative, and right and up are positive. For RTL, left is positive and right is negative. Change-Id: Ia31e8c687c8c2716fc632b2fe88aa8955b934bce
Diffstat (limited to 'tests/src/com/android/launcher3/touch')
-rw-r--r--tests/src/com/android/launcher3/touch/SwipeDetectorTest.java72
1 files changed, 59 insertions, 13 deletions
diff --git a/tests/src/com/android/launcher3/touch/SwipeDetectorTest.java b/tests/src/com/android/launcher3/touch/SwipeDetectorTest.java
index b600473d4..4ebf54c7b 100644
--- a/tests/src/com/android/launcher3/touch/SwipeDetectorTest.java
+++ b/tests/src/com/android/launcher3/touch/SwipeDetectorTest.java
@@ -15,9 +15,12 @@
*/
package com.android.launcher3.touch;
-import androidx.test.InstrumentationRegistry;
-import androidx.test.filters.SmallTest;
-import androidx.test.runner.AndroidJUnit4;
+import static org.mockito.Matchers.anyBoolean;
+import static org.mockito.Matchers.anyFloat;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.verify;
+
import android.util.Log;
import android.view.ViewConfiguration;
@@ -29,11 +32,9 @@ import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
-import static org.mockito.Matchers.anyBoolean;
-import static org.mockito.Matchers.anyFloat;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.never;
-import static org.mockito.Mockito.verify;
+import androidx.test.InstrumentationRegistry;
+import androidx.test.filters.SmallTest;
+import androidx.test.runner.AndroidJUnit4;
@SmallTest
@RunWith(AndroidJUnit4.class)
@@ -63,7 +64,7 @@ public class SwipeDetectorTest {
doReturn(orgConfig.getScaledMaximumFlingVelocity()).when(mMockConfig)
.getScaledMaximumFlingVelocity();
- mDetector = new SwipeDetector(mMockConfig, mMockListener, SwipeDetector.VERTICAL);
+ mDetector = new SwipeDetector(mMockConfig, mMockListener, SwipeDetector.VERTICAL, false);
mDetector.setDetectableScrollConditions(SwipeDetector.DIRECTION_BOTH, false);
mTouchSlop = orgConfig.getScaledTouchSlop();
doReturn(mTouchSlop).when(mMockConfig).getScaledTouchSlop();
@@ -72,7 +73,19 @@ public class SwipeDetectorTest {
}
@Test
- public void testDragStart_vertical() {
+ public void testDragStart_verticalPositive() {
+ mDetector = new SwipeDetector(mMockConfig, mMockListener, SwipeDetector.VERTICAL, false);
+ mDetector.setDetectableScrollConditions(SwipeDetector.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.
+ verify(mMockListener).onDragStart(anyBoolean());
+ }
+
+ @Test
+ public void testDragStart_verticalNegative() {
+ mDetector = new SwipeDetector(mMockConfig, mMockListener, SwipeDetector.VERTICAL, false);
+ mDetector.setDetectableScrollConditions(SwipeDetector.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.
@@ -88,9 +101,42 @@ public class SwipeDetectorTest {
}
@Test
- public void testDragStart_horizontal() {
- mDetector = new SwipeDetector(mMockConfig, mMockListener, SwipeDetector.HORIZONTAL);
- mDetector.setDetectableScrollConditions(SwipeDetector.DIRECTION_BOTH, false);
+ public void testDragStart_horizontalPositive() {
+ mDetector = new SwipeDetector(mMockConfig, mMockListener, SwipeDetector.HORIZONTAL, false);
+ mDetector.setDetectableScrollConditions(SwipeDetector.DIRECTION_POSITIVE, 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 testDragStart_horizontalNegative() {
+ mDetector = new SwipeDetector(mMockConfig, mMockListener, SwipeDetector.HORIZONTAL, false);
+ mDetector.setDetectableScrollConditions(SwipeDetector.DIRECTION_NEGATIVE, 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 testDragStart_horizontalRtlPositive() {
+ mDetector = new SwipeDetector(mMockConfig, mMockListener, SwipeDetector.HORIZONTAL, true);
+ mDetector.setDetectableScrollConditions(SwipeDetector.DIRECTION_POSITIVE, 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 testDragStart_horizontalRtlNegative() {
+ mDetector = new SwipeDetector(mMockConfig, mMockListener, SwipeDetector.HORIZONTAL, true);
+ mDetector.setDetectableScrollConditions(SwipeDetector.DIRECTION_NEGATIVE, false);
mGenerator.put(0, 100, 100);
mGenerator.move(0, 100 + mTouchSlop, 100);