Merge "Do not show Choose Profile dialog for clone user."

This commit is contained in:
Ankita Vyas
2022-11-15 11:13:26 +00:00
committed by Android (Google) Code Review
2 changed files with 20 additions and 1 deletions

View File

@@ -53,6 +53,7 @@ public class ProfileSelectDialogTest {
private static final UserHandle NORMAL_USER = new UserHandle(1111);
private static final UserHandle REMOVED_USER = new UserHandle(2222);
private static final UserHandle CLONE_USER = new UserHandle(3333);
@Spy
private Context mContext = ApplicationProvider.getApplicationContext();
@@ -101,6 +102,22 @@ public class ProfileSelectDialogTest {
verify(mUserManager, times(2)).getUserInfo(REMOVED_USER.getIdentifier());
}
@Test
public void updateUserHandlesIfNeeded_removesCloneProfile() {
final UserInfo userInfo = new UserInfo(CLONE_USER.getIdentifier(), "clone_user", null,
UserInfo.FLAG_PROFILE, UserManager.USER_TYPE_PROFILE_CLONE);
when(mUserManager.getUserInfo(CLONE_USER.getIdentifier())).thenReturn(userInfo);
final Tile tile = new ActivityTile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE);
tile.userHandle.add(CLONE_USER);
tile.userHandle.add(NORMAL_USER);
ProfileSelectDialog.updateUserHandlesIfNeeded(mContext, tile);
assertThat(tile.userHandle).hasSize(1);
assertThat(tile.userHandle.get(0).getIdentifier()).isEqualTo(NORMAL_USER.getIdentifier());
verify(mUserManager, times(1)).getUserInfo(CLONE_USER.getIdentifier());
}
@Test
public void createDialog_showsCorrectTitle() {
mContext.setTheme(R.style.Theme_AppCompat);