Reordering UserLifecycleTests in prep for more

Will add more tests. Want the profile tests together. To make review
easier, moving a test away from the profile tests.

Test: N/A
Change-Id: Idf757414dd35acb46a41701a3981cdf37a7779eb
This commit is contained in:
Bookatz
2019-04-11 09:22:49 -07:00
parent 4d037c7a3b
commit 5df3c64c9b

View File

@@ -211,6 +211,38 @@ public class UserLifecycleTests {
}
}
@Test
public void ephemeralUserStopped() throws Exception {
while (mRunner.keepRunning()) {
mRunner.pauseTiming();
final int startUser = mAm.getCurrentUser();
final UserInfo userInfo = mUm.createUser("TestUser",
UserInfo.FLAG_EPHEMERAL | UserInfo.FLAG_DEMO);
switchUser(userInfo.id);
final CountDownLatch latch = new CountDownLatch(1);
InstrumentationRegistry.getContext().registerReceiver(new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
if (Intent.ACTION_USER_STOPPED.equals(intent.getAction()) && intent.getIntExtra(
Intent.EXTRA_USER_HANDLE, UserHandle.USER_NULL) == userInfo.id) {
latch.countDown();
}
}
}, new IntentFilter(Intent.ACTION_USER_STOPPED));
final CountDownLatch switchLatch = new CountDownLatch(1);
registerUserSwitchObserver(switchLatch, null, startUser);
mRunner.resumeTiming();
mAm.switchUser(startUser);
latch.await(TIMEOUT_IN_SECOND, TimeUnit.SECONDS);
mRunner.pauseTiming();
switchLatch.await(TIMEOUT_IN_SECOND, TimeUnit.SECONDS);
removeUser(userInfo.id);
mRunner.resumeTiming();
}
}
@Test
public void managedProfileUnlock() throws Exception {
while (mRunner.keepRunning()) {
@@ -258,37 +290,6 @@ public class UserLifecycleTests {
}
}
@Test
public void ephemeralUserStopped() throws Exception {
while (mRunner.keepRunning()) {
mRunner.pauseTiming();
final int startUser = mAm.getCurrentUser();
final UserInfo userInfo = mUm.createUser("TestUser",
UserInfo.FLAG_EPHEMERAL | UserInfo.FLAG_DEMO);
switchUser(userInfo.id);
final CountDownLatch latch = new CountDownLatch(1);
InstrumentationRegistry.getContext().registerReceiver(new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
if (Intent.ACTION_USER_STOPPED.equals(intent.getAction()) && intent.getIntExtra(
Intent.EXTRA_USER_HANDLE, UserHandle.USER_NULL) == userInfo.id) {
latch.countDown();
}
}
}, new IntentFilter(Intent.ACTION_USER_STOPPED));
final CountDownLatch switchLatch = new CountDownLatch(1);
registerUserSwitchObserver(switchLatch, null, startUser);
mRunner.resumeTiming();
mAm.switchUser(startUser);
latch.await(TIMEOUT_IN_SECOND, TimeUnit.SECONDS);
mRunner.pauseTiming();
switchLatch.await(TIMEOUT_IN_SECOND, TimeUnit.SECONDS);
removeUser(userInfo.id);
mRunner.resumeTiming();
}
}
@Test
public void managedProfileStopped() throws Exception {