Show a separate tab for the Private Space
This covers all the known Settings pages using the tabbed view model. https://docs.google.com/document/d/1CdjUjAE84-5ZEPRIfw5KYFjLVHtEZxc_sF0w95su8DA/edit?resourcekey=0-dAACT9HRexY1IyoxMmkVlw#heading=h.58jd58rmznte Screenshots: all apps https://screenshot.googleplex.com/3E5Jm7Pi2JfN64r with work tab: https://screenshot.googleplex.com/8egk4yHK5jSENjR PS Apps Special media management apps https://screenshot.googleplex.com/BHHafqW7bgUwSGg with work tab: https://screenshot.googleplex.com/3cocdhruEmCCh5k PS Location Services tab view https://screenshot.googleplex.com/3DqJcT2BFTEpvYT with work tab: https://screenshot.googleplex.com/6Avpx6hxSrdGJw5 PS on screen keyboard tab view https://screenshot.googleplex.com/4FzVNnBWwbUeJNw with work tab: https://screenshot.googleplex.com/8E8UhpWq8PL5nxU PS password account tab view https://screenshot.googleplex.com/6bDR4AKtth2S3EW with work tab: https://screenshot.googleplex.com/9msXV2TdHdJapch PS storage tab view https://screenshot.googleplex.com/5Nk2FTxwdmpEv3B with work tab: https://screenshot.googleplex.com/79tw2EaWZKfMsnC PS appl_languages_work https://screenshot.googleplex.com/3qrREeg3RQdHhhH Bug: 302278487 Test: manual Change-Id: I8cd39170827fbe251bc4075ef306206020b3a022
This commit is contained in:
@@ -19,6 +19,7 @@ package com.android.settings.dashboard.profileselector;
|
||||
import static android.content.Intent.EXTRA_USER_ID;
|
||||
|
||||
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;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
@@ -29,6 +30,9 @@ import static org.mockito.Mockito.when;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.os.Flags;
|
||||
import android.os.UserHandle;
|
||||
import android.platform.test.flag.junit.SetFlagsRule;
|
||||
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
@@ -38,6 +42,7 @@ import com.android.settings.SettingsPreferenceFragmentTest;
|
||||
import com.android.settings.testutils.shadow.ShadowUserManager;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
@@ -60,6 +65,7 @@ public class ProfileSelectFragmentTest {
|
||||
private TestProfileSelectFragment mFragment;
|
||||
private FragmentActivity mActivity;
|
||||
private ShadowUserManager mUserManager;
|
||||
@Rule public final SetFlagsRule mSetFlagsRule = new SetFlagsRule();
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
@@ -85,6 +91,14 @@ public class ProfileSelectFragmentTest {
|
||||
assertThat(mFragment.getTabId(mActivity, bundle)).isEqualTo(WORK_TAB);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getTabId_setArgumentPrivate_setCorrectTab() {
|
||||
final Bundle bundle = new Bundle();
|
||||
bundle.putInt(SettingsActivity.EXTRA_SHOW_FRAGMENT_TAB, PRIVATE_TAB);
|
||||
|
||||
assertThat(mFragment.getTabId(mActivity, bundle)).isEqualTo(PRIVATE_TAB);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getTabId_setArgumentPersonal_setCorrectTab() {
|
||||
final Bundle bundle = new Bundle();
|
||||
@@ -104,6 +118,16 @@ public class ProfileSelectFragmentTest {
|
||||
assertThat(mFragment.getTabId(mActivity, bundle)).isEqualTo(WORK_TAB);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getTabId_setPrivateId_getCorrectTab() {
|
||||
mSetFlagsRule.enableFlags(Flags.FLAG_ALLOW_PRIVATE_PROFILE);
|
||||
final Bundle bundle = new Bundle();
|
||||
bundle.putInt(EXTRA_USER_ID, 11);
|
||||
mUserManager.setPrivateProfile(11, "private", 0);
|
||||
|
||||
assertThat(mFragment.getTabId(mActivity, bundle)).isEqualTo(PRIVATE_TAB);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getTabId_setPersonalId_getCorrectTab() {
|
||||
final Bundle bundle = new Bundle();
|
||||
@@ -124,12 +148,120 @@ public class ProfileSelectFragmentTest {
|
||||
assertThat(mFragment.getTabId(mActivity, null)).isEqualTo(WORK_TAB);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetFragments_whenOnlyPersonal_returnsOneFragment() {
|
||||
mSetFlagsRule.disableFlags(Flags.FLAG_ALLOW_PRIVATE_PROFILE);
|
||||
Fragment[] fragments = ProfileSelectFragment.getFragments(
|
||||
mContext,
|
||||
null /* bundle */,
|
||||
TestProfileSelectFragment::new,
|
||||
TestProfileSelectFragment::new,
|
||||
TestProfileSelectFragment::new);
|
||||
assertThat(fragments).hasLength(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetFragments_whenPrivateDisabled_returnsOneFragment() {
|
||||
Fragment[] fragments = ProfileSelectFragment.getFragments(
|
||||
mContext,
|
||||
null /* bundle */,
|
||||
TestProfileSelectFragment::new,
|
||||
TestProfileSelectFragment::new,
|
||||
TestProfileSelectFragment::new,
|
||||
new ProfileSelectFragment.PrivateSpaceInfoProvider() {
|
||||
@Override
|
||||
public boolean isPrivateSpaceLocked(Context context) {
|
||||
return true;
|
||||
}
|
||||
},
|
||||
new ProfileSelectFragment.ManagedProfileInfoProvider() {
|
||||
@Override
|
||||
public UserHandle getManagedProfile(Context context) {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
assertThat(fragments).hasLength(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetFragments_whenPrivateEnabled_returnsTwoFragments() {
|
||||
mSetFlagsRule.enableFlags(Flags.FLAG_ALLOW_PRIVATE_PROFILE);
|
||||
Fragment[] fragments = ProfileSelectFragment.getFragments(
|
||||
mContext,
|
||||
null /* 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 null;
|
||||
}
|
||||
});
|
||||
assertThat(fragments).hasLength(2);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetFragments_whenManagedProfile_returnsTwoFragments() {
|
||||
mSetFlagsRule.disableFlags(Flags.FLAG_ALLOW_PRIVATE_PROFILE);
|
||||
Fragment[] fragments = ProfileSelectFragment.getFragments(
|
||||
mContext,
|
||||
null /* 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(2);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetFragments_whenAllProfiles_returnsThreeFragments() {
|
||||
mSetFlagsRule.enableFlags(Flags.FLAG_ALLOW_PRIVATE_PROFILE);
|
||||
Fragment[] fragments = ProfileSelectFragment.getFragments(
|
||||
mContext,
|
||||
null /* 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);
|
||||
}
|
||||
|
||||
public static class TestProfileSelectFragment extends ProfileSelectFragment {
|
||||
|
||||
@Override
|
||||
public Fragment[] getFragments() {
|
||||
return new Fragment[]{
|
||||
new SettingsPreferenceFragmentTest.TestFragment(), //0
|
||||
new SettingsPreferenceFragmentTest.TestFragment(),
|
||||
new SettingsPreferenceFragmentTest.TestFragment()
|
||||
};
|
||||
}
|
||||
|
@@ -39,10 +39,12 @@ public class ProfileSelectLocationFragmentTest {
|
||||
|
||||
@Test
|
||||
public void getFragments_containsCorrectBundle() {
|
||||
assertThat(mProfileSelectLocationFragment.getFragments().length).isEqualTo(2);
|
||||
assertThat(mProfileSelectLocationFragment.getFragments().length).isEqualTo(3);
|
||||
assertThat(mProfileSelectLocationFragment.getFragments()[0].getArguments().getInt(
|
||||
EXTRA_PROFILE, -1)).isEqualTo(ProfileSelectFragment.ProfileType.PERSONAL);
|
||||
assertThat(mProfileSelectLocationFragment.getFragments()[1].getArguments().getInt(
|
||||
EXTRA_PROFILE, -1)).isEqualTo(ProfileSelectFragment.ProfileType.WORK);
|
||||
assertThat(mProfileSelectLocationFragment.getFragments()[1].getArguments().getInt(
|
||||
EXTRA_PROFILE, -1)).isEqualTo(ProfileSelectFragment.ProfileType.PRIVATE);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user