summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorvadimt <vadimt@google.com>2019-04-04 13:56:18 -0700
committervadimt <vadimt@google.com>2019-04-04 14:36:53 -0700
commit2a0670890a0b9971d5eada3c3e72507bddb7186c (patch)
tree6e2dff8dc35b0e8c7828463afc849e711ab0e4a6
parent24eb1c9c89f26f2371cc26c1eaa4e647820f2f0b (diff)
downloadandroid_packages_apps_Trebuchet-2a0670890a0b9971d5eada3c3e72507bddb7186c.tar.gz
android_packages_apps_Trebuchet-2a0670890a0b9971d5eada3c3e72507bddb7186c.tar.bz2
android_packages_apps_Trebuchet-2a0670890a0b9971d5eada3c3e72507bddb7186c.zip
Not using system res ids in tests
Change-Id: I3aad2380dd6cd51ee23803cf5164f8b332a62e98
-rw-r--r--quickstep/tests/src/com/android/quickstep/NavigationModeSwitchRule.java7
-rw-r--r--tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java53
2 files changed, 51 insertions, 9 deletions
diff --git a/quickstep/tests/src/com/android/quickstep/NavigationModeSwitchRule.java b/quickstep/tests/src/com/android/quickstep/NavigationModeSwitchRule.java
index 895485ddf..6034791d7 100644
--- a/quickstep/tests/src/com/android/quickstep/NavigationModeSwitchRule.java
+++ b/quickstep/tests/src/com/android/quickstep/NavigationModeSwitchRule.java
@@ -32,7 +32,6 @@ import androidx.test.uiautomator.UiDevice;
import com.android.launcher3.tapl.LauncherInstrumentation;
import com.android.launcher3.tapl.TestHelpers;
-import com.android.systemui.shared.system.QuickStepContract;
import org.junit.Assert;
import org.junit.rules.TestRule;
@@ -78,9 +77,9 @@ public class NavigationModeSwitchRule implements TestRule {
@Override
public void evaluate() throws Throwable {
final Context context = getInstrumentation().getContext();
- final String prevOverlayPkg = QuickStepContract.isGesturalMode(context)
+ final String prevOverlayPkg = LauncherInstrumentation.isGesturalMode(context)
? NAV_BAR_MODE_GESTURAL_OVERLAY
- : QuickStepContract.isSwipeUpMode(context)
+ : LauncherInstrumentation.isSwipeUpMode(context)
? NAV_BAR_MODE_2BUTTON_OVERLAY
: NAV_BAR_MODE_3BUTTON_OVERLAY;
final LauncherInstrumentation.NavigationModel originalMode =
@@ -150,4 +149,4 @@ public class NavigationModeSwitchRule implements TestRule {
return base;
}
}
-} \ No newline at end of file
+}
diff --git a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
index c72f7d0b6..40c488d37 100644
--- a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
+++ b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
@@ -22,6 +22,7 @@ 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;
@@ -172,11 +173,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 (QuickStepContract.isGesturalMode(ctx)) {
+ if (isGesturalMode(ctx)) {
return NavigationModel.ZERO_BUTTON;
- } else if (QuickStepContract.isSwipeUpMode(ctx)) {
+ } else if (isSwipeUpMode(ctx)) {
return NavigationModel.TWO_BUTTON;
- } else if (QuickStepContract.isLegacyMode(ctx)) {
+ } else if (isLegacyMode(ctx)) {
return NavigationModel.THREE_BUTTON;
} else {
fail("Can't detect navigation mode");
@@ -607,6 +608,46 @@ public final class LauncherInstrumentation {
}
}
+ public static boolean isGesturalMode(Context context) {
+ return QuickStepContract.isGesturalMode(getCurrentInteractionMode(context));
+ }
+
+ public static boolean isSwipeUpMode(Context context) {
+ return QuickStepContract.isSwipeUpMode(getCurrentInteractionMode(context));
+ }
+
+ public static boolean isLegacyMode(Context context) {
+ return QuickStepContract.isLegacyMode(getCurrentInteractionMode(context));
+ }
+
+ private static int getCurrentInteractionMode(Context context) {
+ return getSystemIntegerRes(context, "config_navBarInteractionMode");
+ }
+
+ 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;
+ }
+ }
+
+ private static int getSystemDimensionResId(Context context, String resName) {
+ Resources res = context.getResources();
+ int resId = res.getIdentifier(resName, "dimen", "android");
+
+ if (resId != 0) {
+ return 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);
@@ -616,8 +657,10 @@ public final class LauncherInstrumentation {
int getEdgeSensitivityWidth() {
try {
- return QuickStepContract.getEdgeSensitivityWidth(
- mInstrumentation.getTargetContext().createPackageContext("android", 0)) + 1;
+ final Context context = mInstrumentation.getTargetContext().createPackageContext(
+ "android", 0);
+ return context.getResources().getDimensionPixelSize(
+ getSystemDimensionResId(context, "config_backGestureInset")) + 1;
} catch (PackageManager.NameNotFoundException e) {
fail("Can't get edge sensitivity: " + e);
return 0;