mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-02-17 09:38:19 +00:00
Merge "Fix flaky test" into main
This commit is contained in:
@@ -278,7 +278,7 @@ public class OverviewActionsView<T extends OverlayUICallbacks> extends FrameLayo
|
||||
boolean showSingleTaskActions = !mIsGroupedTask;
|
||||
boolean showGroupActions = mIsGroupedTask && mDp.isTablet && mCanSaveAppPair;
|
||||
Log.d(TAG, "updateActionButtonsVisibility() called: showSingleTaskActions = ["
|
||||
+ showSingleTaskActions + ", showGroupActions = [" + showGroupActions + "]");
|
||||
+ showSingleTaskActions + "], showGroupActions = [" + showGroupActions + "]");
|
||||
getActionsAlphas().get(INDEX_GROUPED_ALPHA).setValue(showSingleTaskActions ? 1 : 0);
|
||||
getGroupActionsAlphas().get(INDEX_GROUPED_ALPHA).setValue(showGroupActions ? 1 : 0);
|
||||
}
|
||||
|
||||
@@ -88,6 +88,8 @@ public class TaplOverviewIconTest extends AbstractLauncherUiTest<QuickstepLaunch
|
||||
}
|
||||
|
||||
private void createAndLaunchASplitPair() {
|
||||
clearAllRecentTasks();
|
||||
|
||||
startTestActivity(2);
|
||||
startTestActivity(3);
|
||||
|
||||
|
||||
@@ -33,9 +33,7 @@ import androidx.test.platform.app.InstrumentationRegistry;
|
||||
import com.android.launcher3.tapl.Overview;
|
||||
import com.android.launcher3.tapl.Taskbar;
|
||||
import com.android.launcher3.tapl.TaskbarAppIcon;
|
||||
import com.android.launcher3.ui.PortraitLandscapeRunner.PortraitLandscape;
|
||||
import com.android.launcher3.util.rule.TestStabilityRule;
|
||||
import com.android.quickstep.TaskbarModeSwitchRule.TaskbarModeSwitch;
|
||||
import com.android.wm.shell.Flags;
|
||||
|
||||
import org.junit.After;
|
||||
@@ -74,14 +72,6 @@ public class TaplTestsSplitscreen extends AbstractQuickStepTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@PortraitLandscape
|
||||
public void testSplitFromOverview() {
|
||||
createAndLaunchASplitPair();
|
||||
}
|
||||
|
||||
@Test
|
||||
@PortraitLandscape
|
||||
@TaskbarModeSwitch
|
||||
@TestStabilityRule.Stability(flavors = PLATFORM_POSTSUBMIT | LOCAL) // b/295225524
|
||||
public void testSplitAppFromHomeWithItself() throws Exception {
|
||||
// Currently only tablets have Taskbar in Overview, so test is only active on tablets
|
||||
@@ -152,11 +142,7 @@ public class TaplTestsSplitscreen extends AbstractQuickStepTest {
|
||||
// Currently only tablets have Taskbar in Overview, so test is only active on tablets
|
||||
assumeTrue(mLauncher.isTablet());
|
||||
|
||||
if (!mLauncher.getRecentTasks().isEmpty()) {
|
||||
// Clear all recent tasks
|
||||
mLauncher.goHome().switchToOverview().dismissAllTasks();
|
||||
}
|
||||
|
||||
clearAllRecentTasks();
|
||||
startAppFast(getAppPackageName());
|
||||
|
||||
Overview overview = mLauncher.goHome().switchToOverview();
|
||||
@@ -173,6 +159,8 @@ public class TaplTestsSplitscreen extends AbstractQuickStepTest {
|
||||
}
|
||||
|
||||
private void createAndLaunchASplitPair() {
|
||||
clearAllRecentTasks();
|
||||
|
||||
startTestActivity(2);
|
||||
startTestActivity(3);
|
||||
|
||||
|
||||
@@ -699,4 +699,11 @@ public abstract class AbstractLauncherUiTest<LAUNCHER_TYPE extends Launcher> {
|
||||
UiDevice.getInstance(getInstrumentation()).pressHome();
|
||||
mLauncher.waitForLauncherInitialized();
|
||||
}
|
||||
|
||||
/** Clears all recent tasks */
|
||||
protected void clearAllRecentTasks() {
|
||||
if (!mLauncher.getRecentTasks().isEmpty()) {
|
||||
mLauncher.goHome().switchToOverview().dismissAllTasks();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ import static com.android.launcher3.tapl.OverviewTask.TASK_START_EVENT;
|
||||
import static com.android.launcher3.testing.shared.TestProtocol.NORMAL_STATE_ORDINAL;
|
||||
|
||||
import android.graphics.Rect;
|
||||
import android.util.Log;
|
||||
import android.view.KeyEvent;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
@@ -44,6 +45,7 @@ import java.util.stream.Collectors;
|
||||
* Common overview panel for both Launcher and fallback recents
|
||||
*/
|
||||
public class BaseOverview extends LauncherInstrumentation.VisibleContainer {
|
||||
private static final String TAG = "BaseOverview";
|
||||
protected static final String TASK_RES_ID = "task";
|
||||
private static final Pattern EVENT_ALT_ESC_UP = Pattern.compile(
|
||||
"Key event: KeyEvent.*?action=ACTION_UP.*?keyCode=KEYCODE_ESCAPE.*?metaState=0");
|
||||
@@ -384,25 +386,31 @@ public class BaseOverview extends LauncherInstrumentation.VisibleContainer {
|
||||
|
||||
protected boolean isActionsViewVisible() {
|
||||
if (!hasTasks() || isClearAllVisible()) {
|
||||
Log.d(TAG, "Not expecting an actions bar: no tasks/'Clear all' is visible");
|
||||
return false;
|
||||
}
|
||||
boolean isTablet = mLauncher.isTablet();
|
||||
if (isTablet && mLauncher.isGridOnlyOverviewEnabled()) {
|
||||
Log.d(TAG, "Not expecting an actions bar: device is tablet with grid-only Overview");
|
||||
return false;
|
||||
}
|
||||
OverviewTask task = isTablet ? getFocusedTaskForTablet() : getCurrentTask();
|
||||
if (task == null) {
|
||||
Log.d(TAG, "Not expecting an actions bar: no current task");
|
||||
return false;
|
||||
}
|
||||
// In tablets, if focused task is not in center, overview actions aren't visible.
|
||||
if (isTablet && Math.abs(task.getExactCenterX() - mLauncher.getExactScreenCenterX()) >= 1) {
|
||||
Log.d(TAG, "Not expecting an actions bar: device is tablet and task is not centered");
|
||||
return false;
|
||||
}
|
||||
if (task.isTaskSplit() && (!mLauncher.isAppPairsEnabled() || !isTablet)) {
|
||||
Log.d(TAG, "Not expecting an actions bar: device is phone and task is split");
|
||||
// Overview actions aren't visible for split screen tasks, except for save app pair
|
||||
// button on tablets.
|
||||
return false;
|
||||
}
|
||||
Log.d(TAG, "Expecting an actions bar");
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -447,10 +455,20 @@ public class BaseOverview extends LauncherInstrumentation.VisibleContainer {
|
||||
}
|
||||
|
||||
private void verifyActionsViewVisibility() {
|
||||
// If no running tasks, no need to verify actions view visibility.
|
||||
if (getTasks().isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
boolean isTablet = mLauncher.isTablet();
|
||||
OverviewTask task = isTablet ? getFocusedTaskForTablet() : getCurrentTask();
|
||||
|
||||
try (LauncherInstrumentation.Closable c = mLauncher.addContextLayer(
|
||||
"want to assert overview actions view visibility")) {
|
||||
boolean isTablet = mLauncher.isTablet();
|
||||
OverviewTask task = isTablet ? getFocusedTaskForTablet() : getCurrentTask();
|
||||
"want to assert overview actions view visibility="
|
||||
+ isActionsViewVisible()
|
||||
+ ", focused task is "
|
||||
+ (task == null ? "null" : (task.isTaskSplit() ? "split" : "not split"))
|
||||
)) {
|
||||
|
||||
if (isActionsViewVisible()) {
|
||||
if (task.isTaskSplit()) {
|
||||
|
||||
Reference in New Issue
Block a user