Workaround for failing test & fix scrolling in tests
- Workaround issue where instrumentation will fail to finish an activity
causing the activity to linger longer than expected (leading to issues
with ordering of static resources like the app widget host registration)
- Fix calculation for scrolling the screen, the previous calculation
would result in the gesture starting at the left gesture margin due
to rounding which can trigger a back action instead of the desired
scroll
Bug: 142351228
Change-Id: I34bdb471030518d2b983cac2badd4d8b0e7d571b
diff --git a/quickstep/tests/src/com/android/quickstep/ViewInflationDuringSwipeUp.java b/quickstep/tests/src/com/android/quickstep/ViewInflationDuringSwipeUp.java
index 6726179..8b7c7b7 100644
--- a/quickstep/tests/src/com/android/quickstep/ViewInflationDuringSwipeUp.java
+++ b/quickstep/tests/src/com/android/quickstep/ViewInflationDuringSwipeUp.java
@@ -89,6 +89,14 @@
@Before
public void setUp() throws Exception {
super.setUp();
+
+ // Workaround for b/142351228, when there are no activities, the system may not destroy the
+ // activity correctly for activities under instrumentation, which can leave two concurrent
+ // activities, which changes the order in which the activities are cleaned up (overlapping
+ // stop and start) leading to all sort of issues. To workaround this, ensure that the test
+ // is started only after starting another app.
+ startAppFast(resolveSystemApp(Intent.CATEGORY_APP_CALCULATOR));
+
TaplTestsLauncher3.initialize(this);
mResolver = mTargetContext.getContentResolver();
diff --git a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
index 41a5b49..3248d6a 100644
--- a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
+++ b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
@@ -822,34 +822,26 @@
switch (direction) {
case UP: {
startX = endX = rect.centerX();
- final int vertCenter = rect.centerY();
- final float halfGestureHeight = rect.height() / 2.0f;
- startY = (int) (vertCenter - halfGestureHeight) + 1;
- endY = (int) (vertCenter + halfGestureHeight);
+ startY = rect.top + 1;
+ endY = rect.bottom;
}
break;
case DOWN: {
startX = endX = rect.centerX();
- final int vertCenter = rect.centerY();
- final float halfGestureHeight = rect.height() / 2.0f;
- startY = (int) (vertCenter + halfGestureHeight) - 1;
- endY = (int) (vertCenter - halfGestureHeight);
+ startY = rect.bottom - 1;
+ endY = rect.top;
}
break;
case LEFT: {
startY = endY = rect.centerY();
- final int horizCenter = rect.centerX();
- final float halfGestureWidth = rect.width() / 2.0f;
- startX = (int) (horizCenter - halfGestureWidth) + 1;
- endX = (int) (horizCenter + halfGestureWidth);
+ startX = rect.left + 1;
+ endX = rect.right;
}
break;
case RIGHT: {
startY = endY = rect.centerY();
- final int horizCenter = rect.centerX();
- final float halfGestureWidth = rect.width() / 2.0f;
- startX = (int) (horizCenter + halfGestureWidth) - 1;
- endX = (int) (horizCenter - halfGestureWidth);
+ startX = rect.right - 1;
+ endX = rect.left;
}
break;
default: