Simplifying switching to home for some tests
Change-Id: I696d0267a2c36a18080396657bed07f7b1654a7d
This commit is contained in:
parent
59b5b3f2a2
commit
d91cec72fe
|
@ -88,7 +88,7 @@ public class AppPredictionsUITests extends AbstractQuickStepTest {
|
|||
*/
|
||||
@Test
|
||||
public void testPredictionExistsInAllApps() {
|
||||
mActivityMonitor.startLauncher();
|
||||
mDevice.pressHome();
|
||||
mLauncher.pressHome().switchToAllApps();
|
||||
|
||||
// Dispatch an update
|
||||
|
@ -103,7 +103,7 @@ public class AppPredictionsUITests extends AbstractQuickStepTest {
|
|||
*/
|
||||
@Test
|
||||
public void testPredictionsDeferredUntilHome() {
|
||||
mActivityMonitor.startLauncher();
|
||||
mDevice.pressHome();
|
||||
sendPredictionUpdate(mSampleApp1, mSampleApp2);
|
||||
mLauncher.pressHome().switchToAllApps();
|
||||
waitForLauncherCondition("Predictions were not updated in loading state",
|
||||
|
@ -120,7 +120,7 @@ public class AppPredictionsUITests extends AbstractQuickStepTest {
|
|||
|
||||
@Test
|
||||
public void testPredictionsDisabled() {
|
||||
mActivityMonitor.startLauncher();
|
||||
mDevice.pressHome();
|
||||
sendPredictionUpdate();
|
||||
mLauncher.pressHome().switchToAllApps();
|
||||
|
||||
|
|
|
@ -72,7 +72,7 @@ public class DefaultLayoutProviderTest extends AbstractLauncherUiTest {
|
|||
writeLayout(new LauncherLayoutBuilder().atHotseat(0).putApp(SETTINGS_APP, SETTINGS_APP));
|
||||
|
||||
// Launch the home activity
|
||||
mActivityMonitor.startLauncher();
|
||||
mDevice.pressHome();
|
||||
waitForModelLoaded();
|
||||
|
||||
mLauncher.getWorkspace().getHotseatAppIcon(getSettingsApp().getLabel().toString());
|
||||
|
@ -88,7 +88,7 @@ public class DefaultLayoutProviderTest extends AbstractLauncherUiTest {
|
|||
info.getComponent().getClassName(), 2, 2));
|
||||
|
||||
// Launch the home activity
|
||||
mActivityMonitor.startLauncher();
|
||||
mDevice.pressHome();
|
||||
waitForModelLoaded();
|
||||
|
||||
// Verify widget present
|
||||
|
@ -105,7 +105,7 @@ public class DefaultLayoutProviderTest extends AbstractLauncherUiTest {
|
|||
.build());
|
||||
|
||||
// Launch the home activity
|
||||
mActivityMonitor.startLauncher();
|
||||
mDevice.pressHome();
|
||||
waitForModelLoaded();
|
||||
|
||||
mLauncher.getWorkspace().getHotseatFolder("Folder: Copy");
|
||||
|
|
|
@ -53,7 +53,7 @@ public class WorkTabTest extends AbstractLauncherUiTest {
|
|||
|
||||
@Test
|
||||
public void workTabExists() {
|
||||
mActivityMonitor.startLauncher();
|
||||
mDevice.pressHome();
|
||||
|
||||
executeOnLauncher(launcher -> launcher.getStateManager().goToState(ALL_APPS));
|
||||
|
||||
|
|
|
@ -98,7 +98,7 @@ public class AddConfigWidgetTest extends AbstractLauncherUiTest {
|
|||
lockRotation(true);
|
||||
|
||||
clearHomescreen();
|
||||
mActivityMonitor.startLauncher();
|
||||
mDevice.pressHome();
|
||||
|
||||
final Widgets widgets = mLauncher.getWorkspace().openAllWidgets();
|
||||
|
||||
|
|
|
@ -55,7 +55,7 @@ public class AddWidgetTest extends AbstractLauncherUiTest {
|
|||
|
||||
private void performTest() throws Throwable {
|
||||
clearHomescreen();
|
||||
mActivityMonitor.startLauncher();
|
||||
mDevice.pressHome();
|
||||
|
||||
final LauncherAppWidgetProviderInfo widgetInfo =
|
||||
TestViewHelpers.findWidgetProvider(this, false /* hasConfigureScreen */);
|
||||
|
|
|
@ -267,7 +267,7 @@ public class BindWidgetTest extends AbstractLauncherUiTest {
|
|||
resetLoaderState();
|
||||
|
||||
// Launch the home activity
|
||||
mActivityMonitor.startLauncher();
|
||||
mDevice.pressHome();
|
||||
waitForModelLoaded();
|
||||
}
|
||||
|
||||
|
|
|
@ -131,7 +131,7 @@ public class RequestPinItemTest extends AbstractLauncherUiTest {
|
|||
lockRotation(true);
|
||||
|
||||
clearHomescreen();
|
||||
mActivityMonitor.startLauncher();
|
||||
mDevice.pressHome();
|
||||
|
||||
// Open Pin item activity
|
||||
BlockingBroadcastReceiver openMonitor = new BlockingBroadcastReceiver(
|
||||
|
|
|
@ -15,11 +15,6 @@
|
|||
*/
|
||||
package com.android.launcher3.util.rule;
|
||||
|
||||
import static com.android.launcher3.tapl.TestHelpers.getHomeIntentInPackage;
|
||||
|
||||
import static androidx.test.InstrumentationRegistry.getInstrumentation;
|
||||
import static androidx.test.InstrumentationRegistry.getTargetContext;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.Application;
|
||||
import android.app.Application.ActivityLifecycleCallbacks;
|
||||
|
@ -52,26 +47,15 @@ public class LauncherActivityRule implements TestRule {
|
|||
}
|
||||
|
||||
public Callable<Boolean> itemExists(final ItemOperator op) {
|
||||
return new Callable<Boolean>() {
|
||||
|
||||
@Override
|
||||
public Boolean call() throws Exception {
|
||||
Launcher launcher = getActivity();
|
||||
if (launcher == null) {
|
||||
return false;
|
||||
}
|
||||
return launcher.getWorkspace().getFirstMatch(op) != null;
|
||||
return () -> {
|
||||
Launcher launcher = getActivity();
|
||||
if (launcher == null) {
|
||||
return false;
|
||||
}
|
||||
return launcher.getWorkspace().getFirstMatch(op) != null;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts the launcher activity in the target package.
|
||||
*/
|
||||
public void startLauncher() {
|
||||
getInstrumentation().startActivitySync(getHomeIntentInPackage(getTargetContext()));
|
||||
}
|
||||
|
||||
private class MyStatement extends Statement implements ActivityLifecycleCallbacks {
|
||||
|
||||
private final Statement mBase;
|
||||
|
|
Loading…
Reference in New Issue