Loading src/com/android/settings/dashboard/profileselector/ProfileSelectFragment.java +2 −2 Original line number Original line Diff line number Diff line Loading @@ -323,7 +323,7 @@ public abstract class ProfileSelectFragment extends DashboardFragment { fragments.add(personalFragment); fragments.add(personalFragment); if (managedProfileInfoProvider.getManagedProfile(context) != null) { if (managedProfileInfoProvider.getManagedProfile(context) != null) { final Bundle workOnly = bundle != null ? bundle : new Bundle(); final Bundle workOnly = bundle != null ? bundle.deepCopy() : new Bundle(); workOnly.putInt(EXTRA_PROFILE, ProfileType.WORK); workOnly.putInt(EXTRA_PROFILE, ProfileType.WORK); final Fragment workFragment = final Fragment workFragment = workFragmentConstructor.constructAndGetFragment(); workFragmentConstructor.constructAndGetFragment(); Loading @@ -333,7 +333,7 @@ public abstract class ProfileSelectFragment extends DashboardFragment { if (Flags.allowPrivateProfile() if (Flags.allowPrivateProfile() && !privateSpaceInfoProvider.isPrivateSpaceLocked(context)) { && !privateSpaceInfoProvider.isPrivateSpaceLocked(context)) { final Bundle privateOnly = bundle != null ? bundle : new Bundle(); final Bundle privateOnly = bundle != null ? bundle.deepCopy() : new Bundle(); privateOnly.putInt(EXTRA_PROFILE, ProfileType.PRIVATE); privateOnly.putInt(EXTRA_PROFILE, ProfileType.PRIVATE); final Fragment privateFragment = final Fragment privateFragment = privateFragmentConstructor.constructAndGetFragment(); privateFragmentConstructor.constructAndGetFragment(); Loading tests/robotests/src/com/android/settings/dashboard/profileselector/ProfileSelectFragmentTest.java +32 −0 Original line number Original line Diff line number Diff line Loading @@ -18,6 +18,7 @@ package com.android.settings.dashboard.profileselector; import static android.content.Intent.EXTRA_USER_ID; 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.PERSONAL_TAB; import static com.android.settings.dashboard.profileselector.ProfileSelectFragment.PRIVATE_TAB; import static com.android.settings.dashboard.profileselector.ProfileSelectFragment.PRIVATE_TAB; import static com.android.settings.dashboard.profileselector.ProfileSelectFragment.WORK_TAB; import static com.android.settings.dashboard.profileselector.ProfileSelectFragment.WORK_TAB; Loading Loading @@ -255,6 +256,37 @@ public class ProfileSelectFragmentTest { assertThat(fragments).hasLength(3); 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 { public static class TestProfileSelectFragment extends ProfileSelectFragment { @Override @Override Loading Loading
src/com/android/settings/dashboard/profileselector/ProfileSelectFragment.java +2 −2 Original line number Original line Diff line number Diff line Loading @@ -323,7 +323,7 @@ public abstract class ProfileSelectFragment extends DashboardFragment { fragments.add(personalFragment); fragments.add(personalFragment); if (managedProfileInfoProvider.getManagedProfile(context) != null) { if (managedProfileInfoProvider.getManagedProfile(context) != null) { final Bundle workOnly = bundle != null ? bundle : new Bundle(); final Bundle workOnly = bundle != null ? bundle.deepCopy() : new Bundle(); workOnly.putInt(EXTRA_PROFILE, ProfileType.WORK); workOnly.putInt(EXTRA_PROFILE, ProfileType.WORK); final Fragment workFragment = final Fragment workFragment = workFragmentConstructor.constructAndGetFragment(); workFragmentConstructor.constructAndGetFragment(); Loading @@ -333,7 +333,7 @@ public abstract class ProfileSelectFragment extends DashboardFragment { if (Flags.allowPrivateProfile() if (Flags.allowPrivateProfile() && !privateSpaceInfoProvider.isPrivateSpaceLocked(context)) { && !privateSpaceInfoProvider.isPrivateSpaceLocked(context)) { final Bundle privateOnly = bundle != null ? bundle : new Bundle(); final Bundle privateOnly = bundle != null ? bundle.deepCopy() : new Bundle(); privateOnly.putInt(EXTRA_PROFILE, ProfileType.PRIVATE); privateOnly.putInt(EXTRA_PROFILE, ProfileType.PRIVATE); final Fragment privateFragment = final Fragment privateFragment = privateFragmentConstructor.constructAndGetFragment(); privateFragmentConstructor.constructAndGetFragment(); Loading
tests/robotests/src/com/android/settings/dashboard/profileselector/ProfileSelectFragmentTest.java +32 −0 Original line number Original line Diff line number Diff line Loading @@ -18,6 +18,7 @@ package com.android.settings.dashboard.profileselector; import static android.content.Intent.EXTRA_USER_ID; 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.PERSONAL_TAB; import static com.android.settings.dashboard.profileselector.ProfileSelectFragment.PRIVATE_TAB; import static com.android.settings.dashboard.profileselector.ProfileSelectFragment.PRIVATE_TAB; import static com.android.settings.dashboard.profileselector.ProfileSelectFragment.WORK_TAB; import static com.android.settings.dashboard.profileselector.ProfileSelectFragment.WORK_TAB; Loading Loading @@ -255,6 +256,37 @@ public class ProfileSelectFragmentTest { assertThat(fragments).hasLength(3); 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 { public static class TestProfileSelectFragment extends ProfileSelectFragment { @Override @Override Loading