Improve test isolation in AbstractLauncherUiTests

- Removing suspicious duplicate uses of AbstractLauncherUiTest.initialize to prevent unnecesary launcher restarts
- Adding UiDevice#pressHome to AbstractLauncherUiTests.verifyLauncherState to ensure the next test starts with a known clean state

Flag: EXEMPT test fix
Fixes: 372956489
Test: AbstractLauncherUiTest
Change-Id: Id68ece4ab195a4f6c47aa401eb50a91b8ff70e10
This commit is contained in:
Schneider Victor-Tulias
2024-10-16 10:35:10 -04:00
parent 247bc0461a
commit 07669e9575
4 changed files with 1 additions and 10 deletions
@@ -56,8 +56,6 @@ public class TaplPrivateSpaceTest extends AbstractQuickStepTest {
@Override
public void setUp() throws Exception {
super.setUp();
initialize(this);
createAndStartPrivateProfileUser();
mDevice.pressHome();
@@ -415,6 +415,7 @@ public abstract class AbstractLauncherUiTest<LAUNCHER_TYPE extends Launcher> {
public void verifyLauncherState() {
try {
// Limits UI tests affecting tests running after them.
mDevice.pressHome();
mLauncher.waitForLauncherInitialized();
if (mLauncherPid != 0) {
assertEquals("Launcher crashed, pid mismatch:",
@@ -70,7 +70,6 @@ public class TaplWorkProfileTest extends AbstractLauncherUiTest<Launcher> {
@Override
public void setUp() throws Exception {
super.setUp();
initialize(this);
String output =
mDevice.executeShellCommand(
"pm create-user --profileOf 0 --managed TestProfile");
@@ -32,7 +32,6 @@ import com.android.launcher3.util.TestUtil;
import com.android.launcher3.util.rule.ScreenRecordRule.ScreenRecord;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
/**
@@ -50,12 +49,6 @@ public class TaplWorkspaceTest extends AbstractLauncherUiTest<Launcher> {
return launcher.getWorkspace().getCurrentPage();
}
@Before
public void setUp() throws Exception {
super.setUp();
initialize(this);
}
@After
public void tearDown() throws Exception {
if (mLauncherLayout != null) {