summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
author Jay Thomas Sullivan <jaysullivan@google.com> 2025-02-24 11:45:04 -0800
committer Jay Sullivan <jaysullivan@google.com> 2025-03-05 19:12:33 -0800
commit21547ac5946bcc8f5726be8eabeac7d2db0b6107 (patch)
tree546372fe52d4675df2ca1b19e17e28492de8b378 /tests
parent9e66d4181747bd918dc702cd9ee224dc57fd028e (diff)
Assume tests in RoleManagerTest
This adds "assume"s to two tests: - removeSmsRoleHolderThenPermissionIsRevoked - requestRoleThenBlockRequestRoleDialogByRestrictedSettingDialog ...which will cause the tests to end with "ASSUMPTION_FAILED" in the case that the device has no default SMS app when the test starts. This scenario currently happens on GSI builds, showing up as a failed test. This also adds "assume"s to: - openDefaultAppListThenIsNotDefaultAppInList ...which has a flaw that occurs when the installer test helper app takes on any default app roles automatically, which may occur if the role has no holder when the test starts. Fix: 365796249 Test: atest RoleManagerTest Flag: TEST_ONLY Relnote: N/A LOW_COVERAGE_REASON=TEST_ONLY Change-Id: Ia5355189e026cd1fd9bc8a10a2b34dfb63c6cfe8
Diffstat (limited to 'tests')
-rw-r--r--tests/cts/role/src/android/app/role/cts/RoleManagerTest.java18
1 files changed, 14 insertions, 4 deletions
diff --git a/tests/cts/role/src/android/app/role/cts/RoleManagerTest.java b/tests/cts/role/src/android/app/role/cts/RoleManagerTest.java
index bf1e32676..d935eac5c 100644
--- a/tests/cts/role/src/android/app/role/cts/RoleManagerTest.java
+++ b/tests/cts/role/src/android/app/role/cts/RoleManagerTest.java
@@ -47,7 +47,6 @@ import android.os.Build;
import android.os.Process;
import android.os.UserHandle;
import android.permission.flags.Flags;
-import android.platform.test.annotations.RequiresFlagsDisabled;
import android.platform.test.annotations.RequiresFlagsEnabled;
import android.platform.test.flag.junit.CheckFlagsRule;
import android.platform.test.flag.junit.DeviceFlagsValueProvider;
@@ -106,7 +105,6 @@ public class RoleManagerTest {
private static final String ROLE_NAME = RoleManager.ROLE_BROWSER;
private static final String ROLE_PHONE_NAME = RoleManager.ROLE_DIALER;
- private static final String ROLE_SMS_NAME = RoleManager.ROLE_SMS;
private static final String PROFILE_GROUP_EXCLUSIVE_ROLE_NAME =
RoleManager.ROLE_RESERVED_FOR_TESTING_PROFILE_GROUP_EXCLUSIVITY;
private static final String ROLE_SHORT_LABEL = "Browser app";
@@ -286,8 +284,11 @@ public class RoleManagerTest {
@RequiresFlagsEnabled(Flags.FLAG_ENHANCED_CONFIRMATION_MODE_APIS_ENABLED)
@FlakyTest(bugId = 288468003, detail = "CtsRoleTestCases is breaching 20min SLO")
public void requestRoleThenBlockRequestRoleDialogByRestrictedSettingDialog() throws Exception {
- assumeTrue(sRoleManager.isRoleAvailable(RoleManager.ROLE_SMS));
assumeFalse(sIsWatch || sIsAutomotive || sIsTelevision);
+ assumeTrue(sRoleManager.isRoleAvailable(RoleManager.ROLE_SMS));
+ assumeFalse(callWithShellPermissionIdentity(
+ () -> getRoleHolders(RoleManager.ROLE_SMS)).contains(APP_PACKAGE_NAME));
+
// TODO: b/388960315 - Remove wait after addressing race condition
runWithShellPermissionIdentity(
() -> waitForEnhancedConfirmationRestrictedAppOpMode(sContext, APP_PACKAGE_NAME,
@@ -296,7 +297,7 @@ public class RoleManagerTest {
() -> setEnhancedConfirmationRestrictedAppOpMode(sContext, APP_PACKAGE_NAME,
AppOpsManager.MODE_ERRORED));
- requestRole(ROLE_SMS_NAME);
+ requestRole(RoleManager.ROLE_SMS);
waitFindObject(ENHANCED_CONFIRMATION_DIALOG_SELECTOR, TIMEOUT_MILLIS);
pressBack();
@@ -827,6 +828,13 @@ public class RoleManagerTest {
@FlakyTest
@Test
public void openDefaultAppListThenIsNotDefaultAppInList() throws Exception {
+ assumeFalse(callWithShellPermissionIdentity(
+ () -> getRoleHolders(RoleManager.ROLE_BROWSER)).contains(APP_PACKAGE_NAME));
+ assumeFalse(callWithShellPermissionIdentity(
+ () -> getRoleHolders(RoleManager.ROLE_DIALER)).contains(APP_PACKAGE_NAME));
+ assumeFalse(callWithShellPermissionIdentity(
+ () -> getRoleHolders(RoleManager.ROLE_SMS)).contains(APP_PACKAGE_NAME));
+
sContext.startActivity(new Intent(Settings.ACTION_MANAGE_DEFAULT_APPS_SETTINGS)
.addCategory(Intent.CATEGORY_DEFAULT)
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK));
@@ -1191,6 +1199,8 @@ public class RoleManagerTest {
@Test
public void removeSmsRoleHolderThenPermissionIsRevoked() throws Exception {
assumeTrue(sRoleManager.isRoleAvailable(RoleManager.ROLE_SMS));
+ assumeFalse(callWithShellPermissionIdentity(
+ () -> getRoleHolders(RoleManager.ROLE_SMS)).contains(APP_PACKAGE_NAME));
String smsRoleHolder = getRoleHolders(RoleManager.ROLE_SMS).get(0);
addRoleHolder(RoleManager.ROLE_SMS, APP_PACKAGE_NAME);