From 9547060ac63e66e2ab658cb7fe9bd172c257aa4a Mon Sep 17 00:00:00 2001 From: Jackson Michael Date: Thu, 12 Jan 2023 19:40:09 +0000 Subject: [PATCH] Updating startUser_realistic to waiting for start user callback Instead this test wait for ACTION_USER_STARTED broadcast, will measure time until the callback after start user execution. Bug: 265289462 Test: Manual test Change-Id: Ib6fa26ea6fd17e92d29b511879bdd8c80a219d43 --- .../android/multiuser/UserLifecycleTests.java | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/apct-tests/perftests/multiuser/src/android/multiuser/UserLifecycleTests.java b/apct-tests/perftests/multiuser/src/android/multiuser/UserLifecycleTests.java index b24076af4a17a..9cd575b28dc03 100644 --- a/apct-tests/perftests/multiuser/src/android/multiuser/UserLifecycleTests.java +++ b/apct-tests/perftests/multiuser/src/android/multiuser/UserLifecycleTests.java @@ -16,6 +16,7 @@ package android.multiuser; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; import static org.junit.Assume.assumeTrue; import android.annotation.NonNull; @@ -241,24 +242,27 @@ public class UserLifecycleTests { /** * Tests starting an uninitialized user, with wait times in between iterations. - * Measures the time until ACTION_USER_STARTED is received. + * Measures the time until the ProgressListener callback. */ @Test(timeout = TIMEOUT_MAX_TEST_TIME_MS) public void startUser_realistic() throws RemoteException { while (mRunner.keepRunning()) { mRunner.pauseTiming(); final int userId = createUserNoFlags(); + final ProgressWaiter waiter = new ProgressWaiter(); waitForBroadcastIdle(); - runThenWaitForBroadcasts(userId, () -> { - mRunner.resumeTiming(); - Log.i(TAG, "Starting timer"); + mRunner.resumeTiming(); + Log.i(TAG, "Starting timer"); - mIam.startUserInBackground(userId); - }, Intent.ACTION_USER_STARTED); + final boolean success = mIam.startUserInBackgroundWithListener(userId, waiter) + && waiter.waitForFinish(TIMEOUT_IN_SECOND * 1000); mRunner.pauseTiming(); Log.i(TAG, "Stopping timer"); + + assertTrue("Error: could not start user " + userId, success); + removeUser(userId); waitCoolDownPeriod(); mRunner.resumeTimingForNextIteration();