diff options
author | Sanjana Sunil <sanjanasunil@google.com> | 2023-05-31 09:53:56 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2023-05-31 09:53:56 +0000 |
commit | 7c3c8f410b81209160d8cd9ae822778bb808ebd0 (patch) | |
tree | 3cabd9da21cfbfe19908acdcbcc4332f02425522 | |
parent | 8844f805ff08a343cec6007fdedefd931540462d (diff) | |
parent | 9076f6fc05a2f9c17671289414b535c37d42b530 (diff) | |
download | AdServices-7c3c8f410b81209160d8cd9ae822778bb808ebd0.tar.gz |
Merge "Wait for user switch to occur in test" into tm-mainline-prod
2 files changed, 12 insertions, 1 deletions
diff --git a/sdksandbox/tests/hostsidetests/src/com/android/tests/sdksandbox/host/SdkSandboxLifecycleHostTest.java b/sdksandbox/tests/hostsidetests/src/com/android/tests/sdksandbox/host/SdkSandboxLifecycleHostTest.java index b0c530831e..327624bd7e 100644 --- a/sdksandbox/tests/hostsidetests/src/com/android/tests/sdksandbox/host/SdkSandboxLifecycleHostTest.java +++ b/sdksandbox/tests/hostsidetests/src/com/android/tests/sdksandbox/host/SdkSandboxLifecycleHostTest.java @@ -139,7 +139,7 @@ public final class SdkSandboxLifecycleHostTest extends BaseHostJUnit4Test { assertThat(processDump).contains(APP_PACKAGE + '\n'); assertThat(processDump).contains(SANDBOX_1_PROCESS_NAME); - getDevice().switchUser(secondaryUserId); + mUserUtils.switchToSecondaryUser(); // Should still see an app/sdk sandbox running. processDump = getDevice().executeAdbCommand("shell", "ps", "-A"); diff --git a/sdksandbox/tests/testutils/src/android/app/sdksandbox/hosttestutils/SecondaryUserUtils.java b/sdksandbox/tests/testutils/src/android/app/sdksandbox/hosttestutils/SecondaryUserUtils.java index 45ef2225e8..52200c7baf 100644 --- a/sdksandbox/tests/testutils/src/android/app/sdksandbox/hosttestutils/SecondaryUserUtils.java +++ b/sdksandbox/tests/testutils/src/android/app/sdksandbox/hosttestutils/SecondaryUserUtils.java @@ -75,6 +75,17 @@ public class SecondaryUserUtils { } } + public void switchToSecondaryUser() throws Exception { + mTest.getDevice().switchUser(mSecondaryUserId); + for (int i = 0; i < NUMBER_OF_POLLS; ++i) { + if (mTest.getDevice().getCurrentUser() == mSecondaryUserId) { + return; + } + Thread.sleep(POLL_INTERVAL_IN_MILLIS); + } + fail("Could not switch to user " + mSecondaryUserId); + } + private void waitForUserDataDeletion(int userId) throws Exception { final String deSdkSandboxDataRootPath = "/data/misc_de/" + userId + "/sdksandbox"; for (int i = 0; i < NUMBER_OF_POLLS; ++i) { |