From fa4c671066664bd4672dd3dbeaadce3fc7708df4 Mon Sep 17 00:00:00 2001 From: JW Wang Date: Tue, 15 Oct 2019 16:13:27 +0800 Subject: [PATCH] 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 --- .../tests/rollback/StagedRollbackTest.java | 19 ++++++------------- .../rollback/host/StagedRollbackTest.java | 8 ++++---- 2 files changed, 10 insertions(+), 17 deletions(-) diff --git a/tests/RollbackTest/RollbackTest/src/com/android/tests/rollback/StagedRollbackTest.java b/tests/RollbackTest/RollbackTest/src/com/android/tests/rollback/StagedRollbackTest.java index 9e6ac8ef679b1..c77f850026eae 100644 --- a/tests/RollbackTest/RollbackTest/src/com/android/tests/rollback/StagedRollbackTest.java +++ b/tests/RollbackTest/RollbackTest/src/com/android/tests/rollback/StagedRollbackTest.java @@ -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); diff --git a/tests/RollbackTest/StagedRollbackTest/src/com/android/tests/rollback/host/StagedRollbackTest.java b/tests/RollbackTest/StagedRollbackTest/src/com/android/tests/rollback/host/StagedRollbackTest.java index bc98f06ebc561..9e58e4b039159 100644 --- a/tests/RollbackTest/StagedRollbackTest/src/com/android/tests/rollback/host/StagedRollbackTest.java +++ b/tests/RollbackTest/StagedRollbackTest/src/com/android/tests/rollback/host/StagedRollbackTest.java @@ -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