fixing tests to match new abstraction
This change will let us move from activity to other parent views for recent viewss Change-Id: I2424d94f799f87b2d2262da96b289aac6dfadee9
This commit is contained in:
@@ -95,7 +95,7 @@ import java.util.function.Supplier;
|
||||
/**
|
||||
* Base class for all instrumentation tests providing various utility methods.
|
||||
*/
|
||||
public abstract class AbstractLauncherUiTest {
|
||||
public abstract class AbstractLauncherUiTest<LAUNCHER_TYPE extends Launcher> {
|
||||
|
||||
public static final long DEFAULT_ACTIVITY_TIMEOUT = TimeUnit.SECONDS.toMillis(10);
|
||||
public static final long DEFAULT_BROADCAST_TIMEOUT_SECS = 5;
|
||||
@@ -251,7 +251,7 @@ public abstract class AbstractLauncherUiTest {
|
||||
final ViewCaptureRule viewCaptureRule = new ViewCaptureRule(
|
||||
Launcher.ACTIVITY_TRACKER::getCreatedActivity);
|
||||
final RuleChain inner = RuleChain
|
||||
.outerRule(new PortraitLandscapeRunner(this))
|
||||
.outerRule(new PortraitLandscapeRunner<LAUNCHER_TYPE>(this))
|
||||
.around(new FailureWatcher(mLauncher, viewCaptureRule::getViewCaptureData))
|
||||
// .around(viewCaptureRule) // b/315482167
|
||||
.around(new TestIsolationRule(mLauncher, true));
|
||||
@@ -426,12 +426,12 @@ public abstract class AbstractLauncherUiTest {
|
||||
}
|
||||
}
|
||||
|
||||
protected <T> T getFromLauncher(Function<Launcher, T> f) {
|
||||
protected <T> T getFromLauncher(Function<LAUNCHER_TYPE, T> f) {
|
||||
if (!TestHelpers.isInLauncherProcess()) return null;
|
||||
return getOnUiThread(() -> f.apply(Launcher.ACTIVITY_TRACKER.getCreatedActivity()));
|
||||
}
|
||||
|
||||
protected void executeOnLauncher(Consumer<Launcher> f) {
|
||||
protected void executeOnLauncher(Consumer<LAUNCHER_TYPE> f) {
|
||||
getFromLauncher(launcher -> {
|
||||
f.accept(launcher);
|
||||
return null;
|
||||
@@ -441,7 +441,7 @@ public abstract class AbstractLauncherUiTest {
|
||||
// Execute an action on Launcher, but forgive it when launcher is null.
|
||||
// Launcher can be null if teardown is happening after a failed setup step where launcher
|
||||
// activity failed to be created.
|
||||
protected void executeOnLauncherInTearDown(Consumer<Launcher> f) {
|
||||
protected void executeOnLauncherInTearDown(Consumer<LAUNCHER_TYPE> f) {
|
||||
executeOnLauncher(launcher -> {
|
||||
if (launcher != null) f.accept(launcher);
|
||||
});
|
||||
@@ -469,20 +469,20 @@ public abstract class AbstractLauncherUiTest {
|
||||
// Cannot be used in TaplTests after injecting any gesture using Tapl because this can hide
|
||||
// flakiness.
|
||||
protected void waitForLauncherCondition(String
|
||||
message, Function<Launcher, Boolean> condition) {
|
||||
message, Function<LAUNCHER_TYPE, Boolean> condition) {
|
||||
waitForLauncherCondition(message, condition, DEFAULT_ACTIVITY_TIMEOUT);
|
||||
}
|
||||
|
||||
// Cannot be used in TaplTests after injecting any gesture using Tapl because this can hide
|
||||
// flakiness.
|
||||
protected <T> T getOnceNotNull(String message, Function<Launcher, T> f) {
|
||||
protected <O> O getOnceNotNull(String message, Function<LAUNCHER_TYPE, O> f) {
|
||||
return getOnceNotNull(message, f, DEFAULT_ACTIVITY_TIMEOUT);
|
||||
}
|
||||
|
||||
// Cannot be used in TaplTests after injecting any gesture using Tapl because this can hide
|
||||
// flakiness.
|
||||
protected void waitForLauncherCondition(
|
||||
String message, Function<Launcher, Boolean> condition, long timeout) {
|
||||
String message, Function<LAUNCHER_TYPE, Boolean> condition, long timeout) {
|
||||
verifyKeyguardInvisible();
|
||||
if (!TestHelpers.isInLauncherProcess()) return;
|
||||
Wait.atMost(message, () -> getFromLauncher(condition), timeout, mLauncher);
|
||||
@@ -490,7 +490,7 @@ public abstract class AbstractLauncherUiTest {
|
||||
|
||||
// Cannot be used in TaplTests after injecting any gesture using Tapl because this can hide
|
||||
// flakiness.
|
||||
protected <T> T getOnceNotNull(String message, Function<Launcher, T> f, long timeout) {
|
||||
protected <T> T getOnceNotNull(String message, Function<LAUNCHER_TYPE, T> f, long timeout) {
|
||||
if (!TestHelpers.isInLauncherProcess()) return null;
|
||||
|
||||
final Object[] output = new Object[1];
|
||||
@@ -506,7 +506,7 @@ public abstract class AbstractLauncherUiTest {
|
||||
// flakiness.
|
||||
protected void waitForLauncherCondition(
|
||||
String message,
|
||||
Runnable testThreadAction, Function<Launcher, Boolean> condition,
|
||||
Runnable testThreadAction, Function<LAUNCHER_TYPE, Boolean> condition,
|
||||
long timeout) {
|
||||
if (!TestHelpers.isInLauncherProcess()) return;
|
||||
Wait.atMost(message, () -> {
|
||||
@@ -648,7 +648,7 @@ public abstract class AbstractLauncherUiTest {
|
||||
"Launcher still active", launcher -> launcher == null, DEFAULT_UI_TIMEOUT);
|
||||
}
|
||||
|
||||
protected boolean isInLaunchedApp(Launcher launcher) {
|
||||
protected boolean isInLaunchedApp(LAUNCHER_TYPE launcher) {
|
||||
return launcher == null || !launcher.hasBeenResumed();
|
||||
}
|
||||
|
||||
@@ -658,11 +658,11 @@ public abstract class AbstractLauncherUiTest {
|
||||
launcher -> launcher.getStateManager().getState() == state.get());
|
||||
}
|
||||
|
||||
protected int getAllAppsScroll(Launcher launcher) {
|
||||
protected int getAllAppsScroll(LAUNCHER_TYPE launcher) {
|
||||
return launcher.getAppsView().getActiveRecyclerView().computeVerticalScrollOffset();
|
||||
}
|
||||
|
||||
protected void onLauncherActivityClose(Launcher launcher) {
|
||||
protected void onLauncherActivityClose(LAUNCHER_TYPE launcher) {
|
||||
}
|
||||
|
||||
protected HomeAppIcon createShortcutInCenterIfNotExist(String name) {
|
||||
|
||||
Reference in New Issue
Block a user