Deep copy the existing Arguments
Otherwise we end up using the same bundle for all the fragments. Bug: 304697867 Test: manual Test: atest ProfileSelectFragmentTest Change-Id: Ia31f2440516783c22849593922467756c8c54cb9
This commit is contained in:
@@ -18,6 +18,7 @@ package com.android.settings.dashboard.profileselector;
|
||||
|
||||
import static android.content.Intent.EXTRA_USER_ID;
|
||||
|
||||
import static com.android.settings.dashboard.profileselector.ProfileSelectFragment.EXTRA_PROFILE;
|
||||
import static com.android.settings.dashboard.profileselector.ProfileSelectFragment.PERSONAL_TAB;
|
||||
import static com.android.settings.dashboard.profileselector.ProfileSelectFragment.PRIVATE_TAB;
|
||||
import static com.android.settings.dashboard.profileselector.ProfileSelectFragment.WORK_TAB;
|
||||
@@ -255,6 +256,37 @@ public class ProfileSelectFragmentTest {
|
||||
assertThat(fragments).hasLength(3);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetFragments_whenAvailableBundle_returnsFragmentsWithCorrectBundles() {
|
||||
mSetFlagsRule.enableFlags(Flags.FLAG_ALLOW_PRIVATE_PROFILE);
|
||||
Bundle bundle = new Bundle();
|
||||
Fragment[] fragments = ProfileSelectFragment.getFragments(
|
||||
mContext,
|
||||
bundle,
|
||||
TestProfileSelectFragment::new,
|
||||
TestProfileSelectFragment::new,
|
||||
TestProfileSelectFragment::new,
|
||||
new ProfileSelectFragment.PrivateSpaceInfoProvider() {
|
||||
@Override
|
||||
public boolean isPrivateSpaceLocked(Context context) {
|
||||
return false;
|
||||
}
|
||||
},
|
||||
new ProfileSelectFragment.ManagedProfileInfoProvider() {
|
||||
@Override
|
||||
public UserHandle getManagedProfile(Context context) {
|
||||
return new UserHandle(123);
|
||||
}
|
||||
});
|
||||
assertThat(fragments).hasLength(3);
|
||||
assertThat(fragments[0].getArguments().getInt(EXTRA_PROFILE))
|
||||
.isEqualTo(ProfileSelectFragment.ProfileType.PERSONAL);
|
||||
assertThat(fragments[1].getArguments().getInt(EXTRA_PROFILE))
|
||||
.isEqualTo(ProfileSelectFragment.ProfileType.WORK);
|
||||
assertThat(fragments[2].getArguments().getInt(EXTRA_PROFILE))
|
||||
.isEqualTo(ProfileSelectFragment.ProfileType.PRIVATE);
|
||||
}
|
||||
|
||||
public static class TestProfileSelectFragment extends ProfileSelectFragment {
|
||||
|
||||
@Override
|
||||
|
Reference in New Issue
Block a user