diff options
author | Treehugger Robot <treehugger-gerrit@google.com> | 2021-11-11 16:58:28 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2021-11-11 16:58:28 +0000 |
commit | 9deea6c5e2fc4e78b566aa6122636a47c193a63c (patch) | |
tree | a0558b75b67e15f3642a7bf4d4f6b95ba4d97966 | |
parent | 99b3c0fa89871cf9d41bee9116d8fb55f2a54fca (diff) | |
parent | 130a975ba03bcb8b0a21409301bf171918948795 (diff) | |
download | cts-9deea6c5e2fc4e78b566aa6122636a47c193a63c.tar.gz |
Merge "Fix the CTS#testBroadcastManagedProfileAvailable_withoutCrossProfileAppsOp" into android11-tests-dev am: 130a975ba0
Original change: https://android-review.googlesource.com/c/platform/cts/+/1835085
Change-Id: Ie1adac4bf88e61009051d2b4e0753d404819f029
-rw-r--r-- | hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/QuietModeHostsideTest.java | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/QuietModeHostsideTest.java b/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/QuietModeHostsideTest.java index d157fc0bed6..e1f3901ddb5 100644 --- a/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/QuietModeHostsideTest.java +++ b/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/QuietModeHostsideTest.java @@ -143,9 +143,13 @@ public class QuietModeHostsideTest extends BaseDevicePolicyTest { "testTryEnableQuietMode", mPrimaryUserId, createParams(mProfileId)); + // In case of a necessary log is not captured + // cause of too many logs while waiting idle broadcast, capture log previously. + // This log will be concatenated. + String log = getDevice().executeAdbCommand("logcat", "-d"); waitForBroadcastIdle(); verifyBroadcastSent("android.intent.action.MANAGED_PROFILE_UNAVAILABLE", - /* needPermissions= */ !withCrossProfileAppOps); + /* needPermissions= */ !withCrossProfileAppOps, log); clearLogcat(); runDeviceTestsAsUser( @@ -154,15 +158,17 @@ public class QuietModeHostsideTest extends BaseDevicePolicyTest { "testTryDisableQuietMode", mPrimaryUserId, createParams(mProfileId)); + log = getDevice().executeAdbCommand("logcat", "-d"); waitForBroadcastIdle(); verifyBroadcastSent("android.intent.action.MANAGED_PROFILE_AVAILABLE", - /* needPermissions= */ !withCrossProfileAppOps); + /* needPermissions= */ !withCrossProfileAppOps, log); clearLogcat(); removeUser(mProfileId); + log = getDevice().executeAdbCommand("logcat", "-d"); waitForBroadcastIdle(); verifyBroadcastSent("android.intent.action.MANAGED_PROFILE_REMOVED", - /* needPermissions= */ false); + /* needPermissions= */ false, log); } private void clearLogcat() throws DeviceNotAvailableException { @@ -170,9 +176,10 @@ public class QuietModeHostsideTest extends BaseDevicePolicyTest { getDevice().executeAdbCommand("logcat", "-G", "16M"); } - private void verifyBroadcastSent(String actionName, boolean needPermissions) + private void verifyBroadcastSent(String actionName, boolean needPermissions, String prevLog) throws DeviceNotAvailableException { - final String result = getDevice().executeAdbCommand("logcat", "-d"); + String result = getDevice().executeAdbCommand("logcat", "-d"); + result = prevLog + result; assertThat(result).contains( buildReceivedBroadcastRegex(actionName, "CrossProfileEnabledAppReceiver")); assertThat(result).contains( |