Test app compat overrides added/removed following package update
We're adding a 1 sec wait time after install/uninstall to be on the safe
side even though the test passes without it.
Fix: 194177015
Test: atest com.android.cts.appcompat.AppCompatOverridesServiceTest
Change-Id: Ib771c7eed6d1f1dd969a8c98ad1eaa254952063e
diff --git a/hostsidetests/appcompat/compatchanges/src/com/android/cts/appcompat/AppCompatOverridesServiceTest.java b/hostsidetests/appcompat/compatchanges/src/com/android/cts/appcompat/AppCompatOverridesServiceTest.java
index 0d01008..244082d 100644
--- a/hostsidetests/appcompat/compatchanges/src/com/android/cts/appcompat/AppCompatOverridesServiceTest.java
+++ b/hostsidetests/appcompat/compatchanges/src/com/android/cts/appcompat/AppCompatOverridesServiceTest.java
@@ -27,8 +27,6 @@
* Tests that App Compat overrides are added/removed for a test package via the Device Config flags
* in the 'app_compat_overrides' namespace, following both flag changes and package updates.
*
- * TODO(b/194177015): Test that overrides are added/removed after package in installed/removed.
- *
* <p>Build/Install/Run:
* atest com.android.cts.appcompat.AppCompatOverridesServiceTest
*/
@@ -55,6 +53,8 @@
private static final String FLAG_OWNED_CHANGE_IDS = "owned_change_ids";
private static final String FLAG_REMOVE_OVERRIDES = "remove_overrides";
+ public static final int WAIT_TIME_MS = 1_000;
+
private String initialOwnedChangeIdsValue;
private String initialRemoveOverridesValue;
@@ -83,11 +83,30 @@
restoreFlagValue(FLAG_REMOVE_OVERRIDES, initialRemoveOverridesValue);
}
- public void testPackageOverrideFlagPackageNotInstalled() throws Exception {
+ public void testPackageOverrideFlagPackageInstalledAfterFlagAdded() throws Exception {
putFlagValue(OVERRIDE_PKG, CTS_CHANGE_ID + ":::true");
Change ctsChange = getChange(CTS_CHANGE_ID);
assertThat(ctsChange.hasRawOverrides).isFalse();
+
+ // Now install the app and the override should be applied
+ installPackage(OVERRIDE_PKG_VERSION_1_FILENAME, false);
+ Thread.sleep(WAIT_TIME_MS);
+
+ ctsChange = getChange(CTS_CHANGE_ID);
+ assertThat(ctsChange.hasRawOverrides).isTrue();
+ assertThat(ctsChange.rawOverrideStr).isEqualTo(
+ String.format(OVERRIDE_FORMAT, OVERRIDE_PKG, true));
+ assertThat(ctsChange.hasOverrides).isTrue();
+ assertThat(ctsChange.overridesStr).isEqualTo(
+ String.format(OVERRIDE_FORMAT, OVERRIDE_PKG, true));
+
+ // Now uninstall the app and the override should be applied removed
+ uninstallPackage(OVERRIDE_PKG, false);
+ Thread.sleep(WAIT_TIME_MS);
+
+ ctsChange = getChange(CTS_CHANGE_ID);
+ assertThat(ctsChange.hasRawOverrides).isFalse();
}
public void testPackageOverrideFlagForAllVersions() throws Exception {