summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNeil Fuller <nfuller@google.com>2017-07-17 14:38:07 +0000
committerandroid-build-merger <android-build-merger@google.com>2017-07-17 14:38:07 +0000
commit6e5eab6e089e212e059b670a86673717e3b038ff (patch)
tree12bbea7db5a08f8ae8c015f3056e0644a4e3e145
parentb38968a611c2939cf02ba08aee0638a3ccd73f4f (diff)
parent970dc35fb3d20f7885f9ae669ef1ca3d3dd2087d (diff)
downloadTimeZoneData-6e5eab6e089e212e059b670a86673717e3b038ff.tar.gz
Merge "Track behavior changes in RulesCheckReceiver" am: 931bde5744
am: 970dc35fb3 Change-Id: Ia01cb30f90e170a4fd0ee246bd3dd9bd5ee129ab
-rw-r--r--testing/xts/src/com/android/timezone/xts/TimeZoneUpdateHostTest.java51
1 files changed, 30 insertions, 21 deletions
diff --git a/testing/xts/src/com/android/timezone/xts/TimeZoneUpdateHostTest.java b/testing/xts/src/com/android/timezone/xts/TimeZoneUpdateHostTest.java
index bdb9676..04e4ff4 100644
--- a/testing/xts/src/com/android/timezone/xts/TimeZoneUpdateHostTest.java
+++ b/testing/xts/src/com/android/timezone/xts/TimeZoneUpdateHostTest.java
@@ -62,6 +62,7 @@ public class TimeZoneUpdateHostTest extends DeviceTestCase {
// These must match equivalent values in RulesManagerService dumpsys code.
private static final String STAGED_OPERATION_NONE = "None";
private static final String STAGED_OPERATION_INSTALL = "Install";
+ private static final String STAGED_OPERATION_UNINSTALL = "Uninstall";
private static final String INSTALL_STATE_INSTALLED = "Installed";
private static final int ALLOWED_BOOT_DELAY = 60000;
@@ -141,20 +142,13 @@ public class TimeZoneUpdateHostTest extends DeviceTestCase {
assertTrue(getTimeZoneDataPackageName() + " not installed",
isPackageInstalled(getTimeZoneDataPackageName()));
- // "1" below is the revision: we assume the device ships with revision 1 and that the
- // /priv-app data matches the system image files.
- String expectedSystemVersion = getSystemRulesVersion() + ",1";
-
+ // Reboot as needed to apply any staged operation.
if (!STAGED_OPERATION_NONE.equals(getStagedOperationType())) {
rebootDeviceAndWaitForRestart();
}
- // A "clean" device can mean no time zone data .apk installed (completely clean) or one
- // where the /system/priv-app version of the time zone data .apk has been installed. What we
- // want is to ensure that any previous test run didn't leave a test .apk installed.
- // The easiest way to do that is to attempt to uninstall the time zone data app and reboot
- // if we were able to uninstall.
-
+ // A "clean" device means no time zone data .apk installed in /data at all, try to get to
+ // that state.
for (int i = 0; i < 2; i++) {
logDeviceTimeZoneState();
@@ -167,13 +161,16 @@ public class TimeZoneUpdateHostTest extends DeviceTestCase {
// for the device to react to the uninstall and reboot. If the time zone update system
// is not configured correctly this is likely to be where tests fail.
- // We expect the device to get to the state "INSTALL", meaning it will try to install
- // the system version of the time zone rules on next boot.
- waitForStagedStatus(STAGED_OPERATION_INSTALL, expectedSystemVersion);
-
- rebootDeviceAndWaitForRestart();
+ // If the package we uninstalled was not valid then there would be nothing installed and
+ // so nothing will be staged by the uninstall. Check and do what it takes to get the
+ // device to having nothing installed again.
+ if (INSTALL_STATE_INSTALLED.equals(getCurrentInstallState())) {
+ // We expect the device to get to the staged state "UNINSTALL", meaning it will try
+ // to revert to no distro installed on next boot.
+ waitForStagedUninstall();
- assertEquals(expectedSystemVersion, getCurrentInstalledVersion());
+ rebootDeviceAndWaitForRestart();
+ }
}
assertActiveRulesVersion(getSystemRulesVersion());
assertEquals(STAGED_OPERATION_NONE, getStagedOperationType());
@@ -191,7 +188,7 @@ public class TimeZoneUpdateHostTest extends DeviceTestCase {
File appFile = getTimeZoneDataApkFile("test1");
installLocalPackageFile(appFile.getAbsolutePath(), "-r");
- waitForStagedStatus(STAGED_OPERATION_INSTALL, test1VersionInfo);
+ waitForStagedInstall(test1VersionInfo);
// Confirm the install state hasn't changed.
assertFalse(test1VersionInfo.equals(getCurrentInstalledVersion()));
@@ -292,13 +289,25 @@ public class TimeZoneUpdateHostTest extends DeviceTestCase {
return getDeviceTimeZoneState(stateType);
}
- private void waitForStagedStatus(String requiredStatus, String versionString) throws Exception {
- waitForCondition(() -> isStagedStatus(requiredStatus, versionString));
+ private void waitForStagedUninstall() throws Exception {
+ waitForCondition(() -> isStagedUninstall());
+ }
+
+ private void waitForStagedInstall(String versionString) throws Exception {
+ waitForCondition(() -> isStagedInstall(versionString));
+ }
+
+ private boolean isStagedUninstall() {
+ try {
+ return getStagedOperationType().equals(STAGED_OPERATION_UNINSTALL);
+ } catch (Exception e) {
+ throw new AssertionError("Failed to read staged status", e);
+ }
}
- private boolean isStagedStatus(String requiredStatus, String versionString) {
+ private boolean isStagedInstall(String versionString) {
try {
- return getStagedOperationType().equals(requiredStatus)
+ return getStagedOperationType().equals(STAGED_OPERATION_INSTALL)
&& getStagedInstallVersion().equals(versionString);
} catch (Exception e) {
throw new AssertionError("Failed to read staged status", e);