summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorvadimt <vadimt@google.com>2019-04-04 13:16:17 -0700
committervadimt <vadimt@google.com>2019-04-04 13:20:34 -0700
commit24eb1c9c89f26f2371cc26c1eaa4e647820f2f0b (patch)
tree0684493d3a505ee095c7919a9beefc5ef57302a5 /tests
parent077df72acca237385f52b3557b70c30e3cb5d0b9 (diff)
downloadandroid_packages_apps_Trebuchet-24eb1c9c89f26f2371cc26c1eaa4e647820f2f0b.tar.gz
android_packages_apps_Trebuchet-24eb1c9c89f26f2371cc26c1eaa4e647820f2f0b.tar.bz2
android_packages_apps_Trebuchet-24eb1c9c89f26f2371cc26c1eaa4e647820f2f0b.zip
Not using magic constant for edge sensitivity
+Some cleanup in TAPL Change-Id: I886a6c4abacf8b806ee5507e633ec21f2e7ad1d4
Diffstat (limited to 'tests')
-rw-r--r--tests/tapl/com/android/launcher3/tapl/BaseOverview.java6
-rw-r--r--tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java46
-rw-r--r--tests/tapl/com/android/launcher3/tapl/Workspace.java6
3 files changed, 17 insertions, 41 deletions
diff --git a/tests/tapl/com/android/launcher3/tapl/BaseOverview.java b/tests/tapl/com/android/launcher3/tapl/BaseOverview.java
index 420518809..74a17ce34 100644
--- a/tests/tapl/com/android/launcher3/tapl/BaseOverview.java
+++ b/tests/tapl/com/android/launcher3/tapl/BaseOverview.java
@@ -48,8 +48,7 @@ public class BaseOverview extends LauncherInstrumentation.VisibleContainer {
mLauncher.addContextLayer("want to fling forward in overview")) {
LauncherInstrumentation.log("Overview.flingForward before fling");
final UiObject2 overview = verifyActiveContainer();
- final int margin = (int) (50 * mLauncher.getDisplayDensity()) + 1;
- overview.setGestureMargins(margin, 0, 0, 0);
+ overview.setGestureMargins(mLauncher.getEdgeSensitivityWidth(), 0, 0, 0);
overview.fling(Direction.LEFT, (int) (FLING_SPEED * mLauncher.getDisplayDensity()));
mLauncher.waitForIdle();
verifyActiveContainer();
@@ -86,8 +85,7 @@ public class BaseOverview extends LauncherInstrumentation.VisibleContainer {
mLauncher.addContextLayer("want to fling backward in overview")) {
LauncherInstrumentation.log("Overview.flingBackward before fling");
final UiObject2 overview = verifyActiveContainer();
- final int margin = (int) (50 * mLauncher.getDisplayDensity()) + 1;
- overview.setGestureMargins(0, 0, margin, 0);
+ overview.setGestureMargins(0, 0, mLauncher.getEdgeSensitivityWidth(), 0);
overview.fling(Direction.RIGHT, (int) (FLING_SPEED * mLauncher.getDisplayDensity()));
mLauncher.waitForIdle();
verifyActiveContainer();
diff --git a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
index ef3cb1f8d..c72f7d0b6 100644
--- a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
+++ b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
@@ -22,7 +22,6 @@ import android.app.UiAutomation;
import android.content.ContentResolver;
import android.content.Context;
import android.content.pm.PackageManager;
-import android.content.res.Resources;
import android.graphics.Point;
import android.net.Uri;
import android.os.Build;
@@ -65,8 +64,6 @@ import java.util.concurrent.TimeoutException;
public final class LauncherInstrumentation {
private static final String TAG = "Tapl";
- private static final String NAV_BAR_INTERACTION_MODE_RES_NAME =
- "config_navBarInteractionMode";
private static final int ZERO_BUTTON_STEPS_FROM_BACKGROUND_TO_HOME = 20;
// Types for launcher containers that the user is interacting with. "Background" is a
@@ -175,11 +172,11 @@ public final class LauncherInstrumentation {
// Workaround, use constructed context because both the instrumentation context and the
// app context are not constructed with resources that take overlays into account
final Context ctx = baseContext.createPackageContext("android", 0);
- if (isGesturalMode(ctx)) {
+ if (QuickStepContract.isGesturalMode(ctx)) {
return NavigationModel.ZERO_BUTTON;
- } else if (isSwipeUpMode(ctx)) {
+ } else if (QuickStepContract.isSwipeUpMode(ctx)) {
return NavigationModel.TWO_BUTTON;
- } else if (isLegacyMode(ctx)) {
+ } else if (QuickStepContract.isLegacyMode(ctx)) {
return NavigationModel.THREE_BUTTON;
} else {
fail("Can't detect navigation mode");
@@ -610,37 +607,20 @@ public final class LauncherInstrumentation {
}
}
- public static boolean isGesturalMode(Context context) {
- return QuickStepContract.isGesturalMode(
- getSystemIntegerRes(context, NAV_BAR_INTERACTION_MODE_RES_NAME));
- }
-
- public static boolean isSwipeUpMode(Context context) {
- return QuickStepContract.isSwipeUpMode(
- getSystemIntegerRes(context, NAV_BAR_INTERACTION_MODE_RES_NAME));
- }
-
- public static boolean isLegacyMode(Context context) {
- return QuickStepContract.isLegacyMode(
- getSystemIntegerRes(context, NAV_BAR_INTERACTION_MODE_RES_NAME));
- }
-
- private static int getSystemIntegerRes(Context context, String resName) {
- Resources res = context.getResources();
- int resId = res.getIdentifier(resName, "integer", "android");
-
- if (resId != 0) {
- return res.getInteger(resId);
- } else {
- Log.e(TAG, "Failed to get system resource ID. Incompatible framework version?");
- return -1;
- }
- }
-
static void sleep(int duration) {
try {
Thread.sleep(duration);
} catch (InterruptedException e) {
}
}
+
+ int getEdgeSensitivityWidth() {
+ try {
+ return QuickStepContract.getEdgeSensitivityWidth(
+ mInstrumentation.getTargetContext().createPackageContext("android", 0)) + 1;
+ } catch (PackageManager.NameNotFoundException e) {
+ fail("Can't get edge sensitivity: " + e);
+ return 0;
+ }
+ }
} \ No newline at end of file
diff --git a/tests/tapl/com/android/launcher3/tapl/Workspace.java b/tests/tapl/com/android/launcher3/tapl/Workspace.java
index 68b007e2c..f04afa05f 100644
--- a/tests/tapl/com/android/launcher3/tapl/Workspace.java
+++ b/tests/tapl/com/android/launcher3/tapl/Workspace.java
@@ -148,8 +148,7 @@ public final class Workspace extends Home {
*/
public void flingForward() {
final UiObject2 workspace = verifyActiveContainer();
- final int margin = (int) (50 * mLauncher.getDisplayDensity()) + 1;
- workspace.setGestureMargins(0, 0, margin, 0);
+ workspace.setGestureMargins(0, 0, mLauncher.getEdgeSensitivityWidth(), 0);
workspace.fling(Direction.RIGHT, (int) (FLING_SPEED * mLauncher.getDisplayDensity()));
mLauncher.waitForIdle();
verifyActiveContainer();
@@ -161,8 +160,7 @@ public final class Workspace extends Home {
*/
public void flingBackward() {
final UiObject2 workspace = verifyActiveContainer();
- final int margin = (int) (50 * mLauncher.getDisplayDensity()) + 1;
- workspace.setGestureMargins(margin, 0, 0, 0);
+ workspace.setGestureMargins(mLauncher.getEdgeSensitivityWidth(), 0, 0, 0);
workspace.fling(Direction.LEFT, (int) (FLING_SPEED * mLauncher.getDisplayDensity()));
mLauncher.waitForIdle();
verifyActiveContainer();