Code cleanup: StagedRollbackTest (1/n)

Rename device side methods to testBadApkOnly_PhaseN to show that they
are grouped and coordinated by the host side method testBadApkOnly.

Bug: 142697546
Test: atest StagedRollbackTest
Change-Id: I54f28f545a7bd1fb4859421dbdaf1d95fd7c4a9d
This commit is contained in:
JW Wang
2019-10-15 16:13:27 +08:00
parent b44570bc62
commit fa4c671066
2 changed files with 10 additions and 17 deletions

View File

@@ -92,7 +92,7 @@ public class StagedRollbackTest {
* Enable rollback phase.
*/
@Test
public void testBadApkOnlyEnableRollback() throws Exception {
public void testBadApkOnly_Phase1() throws Exception {
Uninstall.packages(TestApp.A);
assertThat(InstallUtils.getInstalledVersion(TestApp.A)).isEqualTo(-1);
@@ -101,9 +101,6 @@ public class StagedRollbackTest {
InstallUtils.processUserData(TestApp.A);
Install.single(TestApp.ACrashing2).setEnableRollback().setStaged().commit();
// At this point, the host test driver will reboot the device and run
// testBadApkOnlyConfirmEnableRollback().
}
/**
@@ -111,7 +108,7 @@ public class StagedRollbackTest {
* Confirm that rollback was successfully enabled.
*/
@Test
public void testBadApkOnlyConfirmEnableRollback() throws Exception {
public void testBadApkOnly_Phase2() throws Exception {
assertThat(InstallUtils.getInstalledVersion(TestApp.A)).isEqualTo(2);
InstallUtils.processUserData(TestApp.A);
@@ -122,9 +119,6 @@ public class StagedRollbackTest {
assertThat(rollback).packagesContainsExactly(
Rollback.from(TestApp.A2).to(TestApp.A1));
assertThat(rollback.isStaged()).isTrue();
// At this point, the host test driver will run
// testBadApkOnlyTriggerRollback().
}
/**
@@ -133,15 +127,14 @@ public class StagedRollbackTest {
* rebooting the test out from under it.
*/
@Test
public void testBadApkOnlyTriggerRollback() throws Exception {
public void testBadApkOnly_Phase3() throws Exception {
// Crash TestApp.A PackageWatchdog#TRIGGER_FAILURE_COUNT times to trigger rollback
RollbackUtils.sendCrashBroadcast(TestApp.A, 5);
// We expect the device to be rebooted automatically. Wait for that to
// happen. At that point, the host test driver will wait for the
// device to come back up and run testApkOnlyConfirmRollback().
// We expect the device to be rebooted automatically. Wait for that to happen.
Thread.sleep(30 * 1000);
// Raise an error anyway if reboot didn't happen.
fail("watchdog did not trigger reboot");
}
@@ -150,7 +143,7 @@ public class StagedRollbackTest {
* Confirm rollback phase.
*/
@Test
public void testBadApkOnlyConfirmRollback() throws Exception {
public void testBadApkOnly_Phase4() throws Exception {
assertThat(InstallUtils.getInstalledVersion(TestApp.A)).isEqualTo(1);
InstallUtils.processUserData(TestApp.A);

View File

@@ -68,23 +68,23 @@ public class StagedRollbackTest extends BaseHostJUnit4Test {
*/
@Test
public void testBadApkOnly() throws Exception {
runPhase("testBadApkOnlyEnableRollback");
runPhase("testBadApkOnly_Phase1");
getDevice().reboot();
runPhase("testBadApkOnlyConfirmEnableRollback");
runPhase("testBadApkOnly_Phase2");
try {
// This is expected to fail due to the device being rebooted out
// from underneath the test. If this fails for reasons other than
// the device reboot, those failures should result in failure of
// the testApkOnlyConfirmRollback phase.
CLog.logAndDisplay(LogLevel.INFO, "testBadApkOnlyTriggerRollback is expected to fail");
runPhase("testBadApkOnlyTriggerRollback");
runPhase("testBadApkOnly_Phase3");
} catch (AssertionError e) {
// AssertionError is expected.
}
getDevice().waitForDeviceAvailable();
runPhase("testBadApkOnlyConfirmRollback");
runPhase("testBadApkOnly_Phase4");
}
@Test