Merge "Wait for taskbar to become visible after closing launcher in tests" into sc-v2-dev
This commit is contained in:
@@ -67,6 +67,7 @@ import androidx.annotation.BinderThread;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.UiThread;
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
import androidx.annotation.WorkerThread;
|
||||
|
||||
import com.android.launcher3.BaseDraggingActivity;
|
||||
@@ -301,17 +302,26 @@ public class TouchInteractionService extends Service implements PluginListener<O
|
||||
|
||||
private static boolean sConnected = false;
|
||||
private static boolean sIsInitialized = false;
|
||||
private static TouchInteractionService sInstance;
|
||||
private RotationTouchHelper mRotationTouchHelper;
|
||||
|
||||
public static boolean isConnected() {
|
||||
return sConnected;
|
||||
}
|
||||
|
||||
|
||||
public static boolean isInitialized() {
|
||||
return sIsInitialized;
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
@Nullable
|
||||
public static TaskbarManager getTaskbarManagerForTesting() {
|
||||
if (sInstance == null) {
|
||||
return null;
|
||||
}
|
||||
return sInstance.mTaskbarManager;
|
||||
}
|
||||
|
||||
private final AbsSwipeUpHandler.Factory mLauncherSwipeHandlerFactory =
|
||||
this::createLauncherSwipeHandler;
|
||||
private final AbsSwipeUpHandler.Factory mFallbackSwipeHandlerFactory =
|
||||
@@ -355,6 +365,7 @@ public class TouchInteractionService extends Service implements PluginListener<O
|
||||
mDeviceState.runOnUserUnlocked(mTaskbarManager::onUserUnlocked);
|
||||
ProtoTracer.INSTANCE.get(this).add(this);
|
||||
sConnected = true;
|
||||
sInstance = this;
|
||||
}
|
||||
|
||||
private void disposeEventHandlers() {
|
||||
@@ -512,6 +523,7 @@ public class TouchInteractionService extends Service implements PluginListener<O
|
||||
|
||||
mTaskbarManager.destroy();
|
||||
sConnected = false;
|
||||
sInstance = null;
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,12 @@ import androidx.test.filters.LargeTest;
|
||||
import androidx.test.runner.AndroidJUnit4;
|
||||
|
||||
import com.android.launcher3.Launcher;
|
||||
import com.android.launcher3.taskbar.TaskbarActivityContext;
|
||||
import com.android.launcher3.taskbar.TaskbarDragLayer;
|
||||
import com.android.launcher3.taskbar.TaskbarManager;
|
||||
import com.android.launcher3.taskbar.TaskbarView;
|
||||
import com.android.launcher3.ui.TaplTestsLauncher3;
|
||||
import com.android.launcher3.ui.TestViewHelpers;
|
||||
import com.android.launcher3.util.RaceConditionReproducer;
|
||||
import com.android.quickstep.NavigationModeSwitchRule.Mode;
|
||||
import com.android.quickstep.NavigationModeSwitchRule.NavigationModeSwitch;
|
||||
@@ -85,7 +90,7 @@ public class StartLauncherViaGestureTests extends AbstractQuickStepTest {
|
||||
public void testStressPressHome() {
|
||||
for (int i = 0; i < STRESS_REPEAT_COUNT; ++i) {
|
||||
// Destroy Launcher activity.
|
||||
closeLauncherActivity();
|
||||
destroyLauncherActivityAndWaitForTaskbarVisible();
|
||||
|
||||
// The test action.
|
||||
mLauncher.pressHome();
|
||||
@@ -97,12 +102,41 @@ public class StartLauncherViaGestureTests extends AbstractQuickStepTest {
|
||||
public void testStressSwipeToOverview() {
|
||||
for (int i = 0; i < STRESS_REPEAT_COUNT; ++i) {
|
||||
// Destroy Launcher activity.
|
||||
closeLauncherActivity();
|
||||
destroyLauncherActivityAndWaitForTaskbarVisible();
|
||||
|
||||
// The test action.
|
||||
mLauncher.getBackground().switchToOverview();
|
||||
}
|
||||
closeLauncherActivity();
|
||||
destroyLauncherActivityAndWaitForTaskbarVisible();
|
||||
mLauncher.pressHome();
|
||||
}
|
||||
|
||||
private void destroyLauncherActivityAndWaitForTaskbarVisible() {
|
||||
closeLauncherActivity();
|
||||
|
||||
// After Launcher is destroyed, calculator app started in setup() will be launched, wait for
|
||||
// taskbar to settle before further interaction if it's a tablet.
|
||||
if (!mLauncher.isTablet()) {
|
||||
return;
|
||||
}
|
||||
|
||||
waitForLauncherCondition(
|
||||
"Taskbar not yet visible", launcher -> {
|
||||
TaskbarManager taskbarManager =
|
||||
TouchInteractionService.getTaskbarManagerForTesting();
|
||||
if (taskbarManager == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
TaskbarActivityContext taskbarActivityContext =
|
||||
taskbarManager.getCurrentActivityContext();
|
||||
if (taskbarActivityContext == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
TaskbarDragLayer taskbarDragLayer = taskbarActivityContext.getDragLayer();
|
||||
return TestViewHelpers.findChildView(taskbarDragLayer,
|
||||
view -> view instanceof TaskbarView && view.isVisibleToUser()) != null;
|
||||
}, DEFAULT_UI_TIMEOUT);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -745,7 +745,6 @@ public final class LauncherInstrumentation {
|
||||
dumpViewHierarchy();
|
||||
action = "swiping up to home";
|
||||
|
||||
final boolean launcherIsVisible = isLauncherVisible();
|
||||
swipeToState(
|
||||
displaySize.x / 2, displaySize.y - 1,
|
||||
displaySize.x / 2, 0,
|
||||
@@ -753,9 +752,6 @@ public final class LauncherInstrumentation {
|
||||
launcherWasVisible
|
||||
? GestureScope.INSIDE_TO_OUTSIDE
|
||||
: GestureScope.OUTSIDE_WITH_PILFER);
|
||||
// b/193653850: launcherWasVisible is a flaky indicator.
|
||||
log("launcherWasVisible: " + launcherWasVisible + ", launcherIsVisible: "
|
||||
+ launcherIsVisible);
|
||||
}
|
||||
} else {
|
||||
log("Hierarchy before clicking home:");
|
||||
|
||||
Reference in New Issue
Block a user