Change LauncherState to Supplier<LauncherState> in tests

This prevents the test from statically initializing LauncherState and
all its static dependencies, which might lead to runtime exceptions in
out-of-proc tests.

Change-Id: I0e4e09dfb31a8b256c2c0c0b3d1d2ecd0cc92230
This commit is contained in:
Tony Wickham
2020-01-28 12:00:14 -08:00
parent 8f76378bf5
commit 8a054061ef
5 changed files with 42 additions and 31 deletions

View File

@@ -84,6 +84,7 @@ import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Supplier;
/**
* Base class for all instrumentation tests providing various utility methods.
@@ -281,9 +282,9 @@ public abstract class AbstractLauncherUiTest {
// Cannot be used in TaplTests between a Tapl call injecting a gesture and a tapl call expecting
// the results of that gesture because the wait can hide flakeness.
protected void waitForState(String message, LauncherState state) {
protected void waitForState(String message, Supplier<LauncherState> state) {
waitForLauncherCondition(message,
launcher -> launcher.getStateManager().getCurrentStableState() == state);
launcher -> launcher.getStateManager().getCurrentStableState() == state.get());
}
protected void waitForResumed(String message) {
@@ -430,9 +431,9 @@ public abstract class AbstractLauncherUiTest {
return !launcher.hasBeenResumed();
}
protected boolean isInState(LauncherState state) {
protected boolean isInState(Supplier<LauncherState> state) {
if (!TestHelpers.isInLauncherProcess()) return true;
return getFromLauncher(launcher -> launcher.getStateManager().getState() == state);
return getFromLauncher(launcher -> launcher.getStateManager().getState() == state.get());
}
protected int getAllAppsScroll(Launcher launcher) {