Add support for testing in portrait mode

Bug: 110103162
Test: TaplTests
Change-Id: I7f633405c04984ea8f04acdc6dd4ad21019d3409
This commit is contained in:
Vadim Tryshev
2018-09-21 14:31:21 -07:00
parent e583a064fa
commit 802a28946c
4 changed files with 40 additions and 25 deletions

View File

@@ -52,7 +52,6 @@ import com.android.launcher3.compat.LauncherAppsCompat;
import com.android.launcher3.tapl.LauncherInstrumentation;
import com.android.launcher3.testcomponent.AppWidgetNoConfig;
import com.android.launcher3.testcomponent.AppWidgetWithConfig;
import com.android.launcher3.util.Condition;
import com.android.launcher3.util.Wait;
import com.android.launcher3.util.rule.LauncherActivityRule;
@@ -79,20 +78,23 @@ public abstract class AbstractLauncherUiTest {
public static final long DEFAULT_WORKER_TIMEOUT_SECS = 5;
protected MainThreadExecutor mMainThreadExecutor = new MainThreadExecutor();
protected UiDevice mDevice;
protected LauncherInstrumentation mLauncher;
protected final UiDevice mDevice;
protected final LauncherInstrumentation mLauncher;
protected Context mTargetContext;
protected String mTargetPackage;
private static final String TAG = "AbstractLauncherUiTest";
protected AbstractLauncherUiTest() {
mDevice = UiDevice.getInstance(getInstrumentation());
mLauncher = new LauncherInstrumentation(getInstrumentation());
}
@Rule
public LauncherActivityRule mActivityMonitor = new LauncherActivityRule();
@Before
public void setUp() throws Exception {
mDevice = UiDevice.getInstance(getInstrumentation());
mLauncher = new LauncherInstrumentation(getInstrumentation());
mTargetContext = InstrumentationRegistry.getTargetContext();
mTargetPackage = mTargetContext.getPackageName();
mDevice.executeShellCommand("settings put global heads_up_notifications_enabled 0");
@@ -285,12 +287,7 @@ public abstract class AbstractLauncherUiTest {
// flakiness.
protected boolean waitForLauncherCondition(
Function<Launcher, Boolean> condition, long timeout) {
return Wait.atMost(new Condition() {
@Override
public boolean isTrue() {
return getFromLauncher(condition);
}
}, timeout);
return Wait.atMost(() -> getFromLauncher(condition), timeout);
}
/**