use of androidx.preference.Preference in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class AccountDetailDashboardFragmentTest method refreshDashboardTiles_HasAccountType_shouldAddAccountNameToIntent.
@Test
public void refreshDashboardTiles_HasAccountType_shouldAddAccountNameToIntent() {
final DashboardFeatureProviderImpl dashboardFeatureProvider = new DashboardFeatureProviderImpl(mContext);
final PackageManager packageManager = mock(PackageManager.class);
ReflectionHelpers.setField(dashboardFeatureProvider, "mPackageManager", packageManager);
when(packageManager.resolveActivity(any(Intent.class), anyInt())).thenReturn(mock(ResolveInfo.class));
final Tile tile = new Tile(mActivityInfo, CategoryKey.CATEGORY_ACCOUNT_DETAIL);
mActivityInfo.metaData.putString(META_DATA_PREFERENCE_KEYHINT, "key");
mActivityInfo.metaData.putString(METADATA_CATEGORY, CategoryKey.CATEGORY_ACCOUNT);
mActivityInfo.metaData.putString(METADATA_ACCOUNT_TYPE, "com.abc");
mActivityInfo.metaData.putString(META_DATA_PREFERENCE_TITLE, "summary");
mActivityInfo.metaData.putString("com.android.settings.intent.action", Intent.ACTION_ASSIST);
tile.userHandle = null;
mFragment.displayTile(tile);
final FragmentActivity activity = Robolectric.setupActivity(FragmentActivity.class);
final Preference preference = new Preference(mContext);
dashboardFeatureProvider.bindPreferenceToTile(activity, false, /* forceRoundedIcon */
MetricsProto.MetricsEvent.DASHBOARD_SUMMARY, preference, tile, null, /* key */
Preference.DEFAULT_ORDER);
assertThat(preference.getKey()).isEqualTo(tile.getKey(mContext));
preference.performClick();
final Intent intent = Shadows.shadowOf(activity).getNextStartedActivityForResult().intent;
assertThat(intent.getStringExtra("extra.accountName")).isEqualTo("name1@abc.com");
}
use of androidx.preference.Preference in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class AccountPreferenceControllerTest method onResume_twoAccountsOfSameType_shouldAddThreePreferences.
@Test
public void onResume_twoAccountsOfSameType_shouldAddThreePreferences() {
final List<UserInfo> infos = new ArrayList<>();
infos.add(new UserInfo(1, "user 1", 0));
when(mUserManager.isManagedProfile()).thenReturn(false);
when(mUserManager.isRestrictedProfile()).thenReturn(false);
when(mUserManager.getProfiles(anyInt())).thenReturn(infos);
Account[] accounts = { new Account("Account1", "com.acct1") };
when(mAccountManager.getAccountsAsUser(anyInt())).thenReturn(accounts);
Account[] accountType1 = { new Account("Account11", "com.acct1"), new Account("Account12", "com.acct1") };
when(mAccountManager.getAccountsByTypeAsUser(eq("com.acct1"), any(UserHandle.class))).thenReturn(accountType1);
AuthenticatorDescription[] authDescs = { new AuthenticatorDescription("com.acct1", "com.android.settings", R.string.account_settings_title, 0, 0, 0, false) };
when(mAccountManager.getAuthenticatorTypesAsUser(anyInt())).thenReturn(authDescs);
AccessiblePreferenceCategory preferenceGroup = mock(AccessiblePreferenceCategory.class);
when(preferenceGroup.getPreferenceManager()).thenReturn(mock(PreferenceManager.class));
when(mAccountHelper.createAccessiblePreferenceCategory(any(Context.class))).thenReturn(preferenceGroup);
mController.onResume();
// should add 2 individual account and the Add account preference
verify(preferenceGroup, times(3)).addPreference(any(Preference.class));
}
use of androidx.preference.Preference in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class EmergencyInfoPreferenceControllerTest method handlePreferenceTreeClick_shouldStartActivity.
@Test
public void handlePreferenceTreeClick_shouldStartActivity() {
final ShadowApplication application = ShadowApplication.getInstance();
final Activity activity = Robolectric.setupActivity(Activity.class);
final Preference preference = new Preference(activity);
preference.setKey("emergency_info");
mController = new EmergencyInfoPreferenceController(activity, preference.getKey());
mController.handlePreferenceTreeClick(preference);
assertThat(application.getNextStartedActivity().getAction()).isEqualTo("android.settings.EDIT_EMERGENCY_INFO");
}
use of androidx.preference.Preference in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class EmergencyInfoPreferenceControllerTest method setUp.
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
mController = new EmergencyInfoPreferenceController(mContext, "test_key");
mPreference = new Preference(Robolectric.setupActivity(Activity.class));
mPreference.setKey(mController.getPreferenceKey());
when(mScreen.findPreference(mPreference.getKey())).thenReturn(mPreference);
when(mContext.getResources().getBoolean(R.bool.config_show_emergency_info_in_device_info)).thenReturn(true);
}
use of androidx.preference.Preference in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class AllAppsInfoPreferenceControllerTest method setUp.
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
final Context context = spy(RuntimeEnvironment.application);
final Preference preference = new Preference(context);
doReturn(mUserManager).when(context).getSystemService(Context.USER_SERVICE);
when(mUserManager.getProfileIdsWithDisabled(anyInt())).thenReturn(new int[] {});
mController = new AllAppsInfoPreferenceController(context, "test_key");
mController.mPreference = preference;
}
Aggregations