Attempting to fix flakes in AllAppsIconToHomeTest

Pressing an icon in AllApps doesn't show a context menu.

The flake doesn't repro locally, the suspects are:
1. Too short wait time
2. App being partially covered by navbar.

Hence the fixes.

This patch is temporary, and will be replaced with a permanent one when
this will be converted to TAPL.

Test: AllAppsIconToHomeTest
Change-Id: I0a03ff8827a5bc7940af3ec956d4b62330a16c66
This commit is contained in:
Vadim Tryshev
2018-09-26 18:15:42 -07:00
parent 9f2e997b30
commit 43524d0daa

View File

@@ -17,6 +17,7 @@ package com.android.launcher3.ui;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.fail;
import android.app.Instrumentation;
import android.content.BroadcastReceiver;
@@ -74,7 +75,7 @@ public abstract class AbstractLauncherUiTest {
public static final long DEFAULT_BROADCAST_TIMEOUT_SECS = 5;
public static final long SHORT_UI_TIMEOUT= 300;
public static final long DEFAULT_UI_TIMEOUT = 3000;
public static final long DEFAULT_UI_TIMEOUT = 10000;
public static final long DEFAULT_WORKER_TIMEOUT_SECS = 5;
protected MainThreadExecutor mMainThreadExecutor = new MainThreadExecutor();
@@ -151,16 +152,20 @@ public abstract class AbstractLauncherUiTest {
* @return the matching object.
*/
protected UiObject2 scrollAndFind(UiObject2 container, BySelector condition) {
do {
container.setGestureMargins(0, 0, 0, 200);
int i = 0;
for (; ; ) {
// findObject can only execute after spring settles.
mDevice.wait(Until.findObject(condition), SHORT_UI_TIMEOUT);
UiObject2 widget = container.findObject(condition);
if (widget != null && widget.getVisibleBounds().intersects(
0, 0, mDevice.getDisplayWidth(), mDevice.getDisplayHeight())) {
0, 0, mDevice.getDisplayWidth(), mDevice.getDisplayHeight() - 200)) {
return widget;
}
} while (container.scroll(Direction.DOWN, 1f));
return container.findObject(condition);
if (++i > 40) fail("Too many attempts");
container.scroll(Direction.DOWN, 1f);
}
}
/**