Search in sources :

Example 26 with Preference

use of androidx.preference.Preference in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class RegionPreferenceControllerTest method updateState_matchCountryName.

@Test
public void updateState_matchCountryName() {
    Preference preference = new Preference(mActivity);
    RegionPreferenceController controller = new RegionPreferenceController(mActivity);
    controller.setRegionId("US");
    controller.updateState(preference);
    assertThat(controller.getSummary()).isEqualTo("United States");
    assertThat(preference.getSummary()).isEqualTo("United States");
}
Also used : Preference(androidx.preference.Preference) Test(org.junit.Test)

Example 27 with Preference

use of androidx.preference.Preference in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class AutomaticStorageManagerSwitchBarControllerTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    mContext = spy(RuntimeEnvironment.application);
    mSwitchBar = new SwitchBar(mContext);
    mMetricsFeatureProvider = FakeFeatureFactory.setupForTest().getMetricsFeatureProvider();
    mPreference = new Preference(mContext);
    mController = new AutomaticStorageManagerSwitchBarController(mContext, mSwitchBar, mMetricsFeatureProvider, mPreference, mFragmentManager);
}
Also used : SwitchBar(com.android.settings.widget.SwitchBar) Preference(androidx.preference.Preference) Before(org.junit.Before)

Example 28 with Preference

use of androidx.preference.Preference in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class SecondaryUserControllerTest method controllerAddsSecondaryUser.

@Test
public void controllerAddsSecondaryUser() {
    mPrimaryUser.name = TEST_NAME;
    mController.displayPreference(mScreen);
    final ArgumentCaptor<Preference> argumentCaptor = ArgumentCaptor.forClass(Preference.class);
    verify(mGroup).addPreference(argumentCaptor.capture());
    final Preference preference = argumentCaptor.getValue();
    assertThat(preference.getTitle()).isEqualTo(TEST_NAME);
}
Also used : Preference(androidx.preference.Preference) Test(org.junit.Test)

Example 29 with Preference

use of androidx.preference.Preference in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class SecondaryUserControllerTest method controllerUpdatesPreferenceOnAcceptingResult.

@Test
public void controllerUpdatesPreferenceOnAcceptingResult() {
    mPrimaryUser.name = TEST_NAME;
    mPrimaryUser.id = 10;
    mController.displayPreference(mScreen);
    final StorageAsyncLoader.AppsStorageResult userResult = new StorageAsyncLoader.AppsStorageResult();
    final SparseArray<StorageAsyncLoader.AppsStorageResult> result = new SparseArray<>();
    userResult.externalStats = new StorageStatsSource.ExternalStorageStats(MEGABYTE_IN_BYTES * 30, MEGABYTE_IN_BYTES * 10, MEGABYTE_IN_BYTES * 10, MEGABYTE_IN_BYTES * 10, 0);
    result.put(10, userResult);
    mController.handleResult(result);
    final ArgumentCaptor<Preference> argumentCaptor = ArgumentCaptor.forClass(Preference.class);
    verify(mGroup).addPreference(argumentCaptor.capture());
    final Preference preference = argumentCaptor.getValue();
    assertThat(preference.getSummary()).isEqualTo("0.03 GB");
}
Also used : SparseArray(android.util.SparseArray) Preference(androidx.preference.Preference) StorageStatsSource(com.android.settingslib.applications.StorageStatsSource) Test(org.junit.Test)

Example 30 with Preference

use of androidx.preference.Preference in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class SecurityPatchLevelPreferenceControllerTest method onClick_noActivityIntent_shouldDoNothing.

@Test
public void onClick_noActivityIntent_shouldDoNothing() {
    when(mPackageManager.queryIntentActivities(any(), anyInt())).thenReturn(Collections.emptyList());
    mController = new SecurityPatchLevelPreferenceController(mContext, "key");
    ReflectionHelpers.setField(mController, "mPackageManager", mPackageManager);
    final Preference pref = new Preference(mContext);
    pref.setKey(mController.getPreferenceKey());
    mController.handlePreferenceTreeClick(pref);
    verify(mContext, never()).startActivity(any());
}
Also used : Preference(androidx.preference.Preference) Test(org.junit.Test)

Aggregations

Preference (androidx.preference.Preference)860 Test (org.junit.Test)343 Before (org.junit.Before)164 Intent (android.content.Intent)81 PreferenceScreen (androidx.preference.PreferenceScreen)81 NotificationChannel (android.app.NotificationChannel)77 SwitchPreference (androidx.preference.SwitchPreference)75 RestrictedSwitchPreference (com.android.settingslib.RestrictedSwitchPreference)69 Context (android.content.Context)60 ArrayList (java.util.ArrayList)50 NotificationBackend (com.android.settings.notification.NotificationBackend)45 ListPreference (androidx.preference.ListPreference)41 Tile (com.android.settingslib.drawer.Tile)40 PreferenceCategory (androidx.preference.PreferenceCategory)39 PreferenceManager (androidx.preference.PreferenceManager)39 Activity (android.app.Activity)27 UserHandle (android.os.UserHandle)27 FooterPreference (com.android.settingslib.widget.FooterPreference)27 PackageManager (android.content.pm.PackageManager)26 Bundle (android.os.Bundle)24