Merge "Reducing usage of magic constants in TAPL's widgets (fling back)" into ub-launcher3-qt-qpr1-dev
diff --git a/src/com/android/launcher3/InstallShortcutReceiver.java b/src/com/android/launcher3/InstallShortcutReceiver.java
index 670cd28..f19c602 100644
--- a/src/com/android/launcher3/InstallShortcutReceiver.java
+++ b/src/com/android/launcher3/InstallShortcutReceiver.java
@@ -631,6 +631,11 @@
}
private static WorkspaceItemInfo createWorkspaceItemInfo(Intent data, LauncherAppState app) {
+ if (data == null) {
+ Log.e(TAG, "Can't construct WorkspaceItemInfo with null data");
+ return null;
+ }
+
Intent intent = data.getParcelableExtra(Intent.EXTRA_SHORTCUT_INTENT);
String name = data.getStringExtra(Intent.EXTRA_SHORTCUT_NAME);
Parcelable bitmap = data.getParcelableExtra(Intent.EXTRA_SHORTCUT_ICON);
diff --git a/tests/src/com/android/launcher3/util/rule/TestStabilityRule.java b/tests/src/com/android/launcher3/util/rule/TestStabilityRule.java
index 8feadbe..d7f41bf 100644
--- a/tests/src/com/android/launcher3/util/rule/TestStabilityRule.java
+++ b/tests/src/com/android/launcher3/util/rule/TestStabilityRule.java
@@ -40,8 +40,8 @@
+ "(?<local>(BuildFromAndroidStudio|"
+ "([0-9]+|[A-Z])-eng\\.[a-z]+\\.[0-9]+\\.[0-9]+))|"
+ "(?<presubmit>([0-9]+|[A-Z])-P[0-9]+)|"
- + "(?<postsubmit>([0-9]+|[A-Z])+-[0-9]+|"
- + "(?<platform>([0-9]+|[A-Z])+))"
+ + "(?<postsubmit>([0-9]+|[A-Z])-[0-9]+)|"
+ + "(?<platform>[0-9]+|[A-Z])"
+ ")$");
private static final Pattern PLATFORM_BUILD =
Pattern.compile("^("
@@ -61,70 +61,7 @@
return new Statement() {
@Override
public void evaluate() throws Throwable {
- final String launcherVersion =
- getInstrumentation().
- getContext().
- getPackageManager().
- getPackageInfo(
- UiDevice.getInstance(getInstrumentation()).
- getLauncherPackageName(),
- 0).
- versionName;
-
- final Matcher launcherBuildMatcher = LAUNCHER_BUILD.matcher(launcherVersion);
-
- boolean launcherLocalBuild = false;
- boolean launcherUnbundledPresubmit = false;
- boolean launcherUnbundledPostsubmit = false;
- boolean launcherPlatform = false;
-
- if (!launcherBuildMatcher.find()) {
- Log.e(TAG, "Match not found");
- } else if (launcherBuildMatcher.group("local") != null) {
- launcherLocalBuild = true;
- } else if (launcherBuildMatcher.group("presubmit") != null) {
- launcherUnbundledPresubmit = true;
- } else if (launcherBuildMatcher.group("postsubmit") != null) {
- launcherUnbundledPostsubmit = true;
- } else if (launcherBuildMatcher.group("platform") != null) {
- launcherPlatform = true;
- } else {
- Log.e(TAG, "ERROR1");
- }
-
- boolean platformLocalBuild = false;
- boolean platformPresubmit = false;
- boolean platformPostsubmit = false;
-
- final String platformVersion = Build.VERSION.INCREMENTAL;
- final Matcher platformBuildMatcher = PLATFORM_BUILD.matcher(platformVersion);
- if (!platformBuildMatcher.find()) {
- Log.e(TAG, "Match not found");
- } else if (platformBuildMatcher.group("commandLine") != null) {
- platformLocalBuild = true;
- } else if (platformBuildMatcher.group("presubmit") != null) {
- platformPresubmit = true;
- } else if (platformBuildMatcher.group("postsubmit") != null) {
- platformPostsubmit = true;
- } else {
- Log.e(TAG, "ERROR2");
- }
-
- Log.d(TAG, "Launcher: " + launcherVersion + ", platform: " + platformVersion);
-
- if (launcherLocalBuild && (platformLocalBuild || platformPostsubmit)) {
- Log.d(TAG, "LOCAL RUN");
- } else if (launcherUnbundledPresubmit && platformPostsubmit) {
- Log.d(TAG, "UNBUNDLED PRESUBMIT");
- } else if (launcherUnbundledPostsubmit && platformPostsubmit) {
- Log.d(TAG, "UNBUNDLED POSTSUBMIT");
- } else if (launcherPlatform && platformPresubmit) {
- Log.d(TAG, "PLATFORM PRESUBMIT");
- } else if (launcherPlatform && platformPostsubmit) {
- Log.d(TAG, "PLATFORM POSTSUBMIT");
- } else {
- Log.e(TAG, "ERROR3");
- }
+ getRunFlavor();
base.evaluate();
}
@@ -133,4 +70,50 @@
return base;
}
}
+
+ private static void getRunFlavor() throws Exception {
+ final String launcherVersion = getInstrumentation().
+ getContext().
+ getPackageManager().
+ getPackageInfo(
+ UiDevice.getInstance(getInstrumentation()).
+ getLauncherPackageName(),
+ 0).
+ versionName;
+
+ final Matcher launcherBuildMatcher = LAUNCHER_BUILD.matcher(launcherVersion);
+
+ if (!launcherBuildMatcher.find()) {
+ Log.e(TAG, "Match not found");
+ }
+
+ final String platformVersion = Build.VERSION.INCREMENTAL;
+ final Matcher platformBuildMatcher = PLATFORM_BUILD.matcher(platformVersion);
+
+ if (!platformBuildMatcher.find()) {
+ Log.e(TAG, "Match not found");
+ }
+
+ Log.d(TAG, "Launcher: " + launcherVersion + ", platform: " + platformVersion);
+
+ if (launcherBuildMatcher.group("local") != null && (
+ platformBuildMatcher.group("commandLine") != null ||
+ platformBuildMatcher.group("postsubmit") != null)) {
+ Log.d(TAG, "LOCAL RUN");
+ } else if (launcherBuildMatcher.group("presubmit") != null
+ && platformBuildMatcher.group("postsubmit") != null) {
+ Log.d(TAG, "UNBUNDLED PRESUBMIT");
+ } else if (launcherBuildMatcher.group("postsubmit") != null
+ && platformBuildMatcher.group("postsubmit") != null) {
+ Log.d(TAG, "UNBUNDLED POSTSUBMIT");
+ } else if (launcherBuildMatcher.group("platform") != null
+ && platformBuildMatcher.group("presubmit") != null) {
+ Log.d(TAG, "PLATFORM PRESUBMIT");
+ } else if (launcherBuildMatcher.group("platform") != null
+ && platformBuildMatcher.group("postsubmit") != null) {
+ Log.d(TAG, "PLATFORM POSTSUBMIT");
+ } else {
+ Log.e(TAG, "ERROR3");
+ }
+ }
}
diff --git a/tests/tapl/com/android/launcher3/tapl/Widgets.java b/tests/tapl/com/android/launcher3/tapl/Widgets.java
index 6593bb1..2a04d46 100644
--- a/tests/tapl/com/android/launcher3/tapl/Widgets.java
+++ b/tests/tapl/com/android/launcher3/tapl/Widgets.java
@@ -48,7 +48,12 @@
"want to fling forward in widgets")) {
LauncherInstrumentation.log("Widgets.flingForward enter");
final UiObject2 widgetsContainer = verifyActiveContainer();
- mLauncher.scroll(widgetsContainer, Direction.DOWN, 1f, MARGINS, FLING_STEPS);
+ final int margin = widgetsContainer.getVisibleBounds().bottom -
+ mLauncher.getRealDisplaySize().y +
+ ResourceUtils.getNavbarSize(
+ ResourceUtils.NAVBAR_BOTTOM_GESTURE_SIZE, mLauncher.getResources());
+ mLauncher.scroll(
+ widgetsContainer, Direction.DOWN, 1f, new Rect(0, 0, 0, margin), FLING_STEPS);
try (LauncherInstrumentation.Closable c1 = mLauncher.addContextLayer("flung forward")) {
verifyActiveContainer();
}