Search in sources :

Example 96 with Preference

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

the class AvailableMediaDeviceGroupControllerTest method onDeviceRemoved_notLastRemove_stillVisible.

@Test
public void onDeviceRemoved_notLastRemove_stillVisible() {
    mPreferenceGroup.setVisible(true);
    mPreferenceGroup.addPreference(mPreference);
    mPreferenceGroup.addPreference(new Preference(mContext));
    mAvailableMediaDeviceGroupController.onDeviceRemoved(mPreference);
    assertThat(mPreferenceGroup.isVisible()).isTrue();
}
Also used : Preference(androidx.preference.Preference) Test(org.junit.Test)

Example 97 with Preference

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

the class BasePreferenceControllerTest method disabledDependentSetting_disabledOnDisplayPreference_preferenceDisabled.

@Test
public void disabledDependentSetting_disabledOnDisplayPreference_preferenceDisabled() {
    final PreferenceScreen screen = mock(PreferenceScreen.class);
    final Preference preference = new Preference(mContext);
    preference.setEnabled(true);
    when(screen.findPreference(anyString())).thenReturn(preference);
    mPreferenceController.setAvailability(DISABLED_DEPENDENT_SETTING);
    mPreferenceController.displayPreference(screen);
    assertThat(preference.isEnabled()).isFalse();
}
Also used : PreferenceScreen(androidx.preference.PreferenceScreen) Preference(androidx.preference.Preference) Test(org.junit.Test)

Example 98 with Preference

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

the class BasePreferenceControllerTest method settingAvailable_disabledOnDisplayPreference_preferenceEnabled.

@Test
public void settingAvailable_disabledOnDisplayPreference_preferenceEnabled() {
    final PreferenceScreen screen = mock(PreferenceScreen.class);
    final Preference preference = new Preference(mContext);
    preference.setEnabled(true);
    when(screen.findPreference(anyString())).thenReturn(preference);
    mPreferenceController.displayPreference(screen);
    assertThat(preference.isEnabled()).isTrue();
}
Also used : PreferenceScreen(androidx.preference.PreferenceScreen) Preference(androidx.preference.Preference) Test(org.junit.Test)

Example 99 with Preference

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

the class AppDataUsageTest method bindData_hasAppUsageData_shouldShowCycleSpinnerAndUpdateUsageSummary.

@Test
public void bindData_hasAppUsageData_shouldShowCycleSpinnerAndUpdateUsageSummary() {
    mFragment = spy(new AppDataUsage());
    final Context context = RuntimeEnvironment.application;
    ReflectionHelpers.setField(mFragment, "mContext", context);
    final long backgroundBytes = 1234L;
    final long foregroundBytes = 5678L;
    final List<NetworkCycleDataForUid> appUsage = new ArrayList<>();
    appUsage.add(new NetworkCycleDataForUid.Builder().setBackgroundUsage(backgroundBytes).setForegroundUsage(foregroundBytes).build());
    ReflectionHelpers.setField(mFragment, "mUsageData", appUsage);
    final Preference backgroundPref = mock(Preference.class);
    ReflectionHelpers.setField(mFragment, "mBackgroundUsage", backgroundPref);
    final Preference foregroundPref = mock(Preference.class);
    ReflectionHelpers.setField(mFragment, "mForegroundUsage", foregroundPref);
    final Preference totalPref = mock(Preference.class);
    ReflectionHelpers.setField(mFragment, "mTotalUsage", totalPref);
    final SpinnerPreference cycle = mock(SpinnerPreference.class);
    ReflectionHelpers.setField(mFragment, "mCycle", cycle);
    mFragment.bindData(0);
    verify(cycle).setVisible(true);
    verify(totalPref).setSummary(DataUsageUtils.formatDataUsage(context, backgroundBytes + foregroundBytes));
    verify(backgroundPref).setSummary(DataUsageUtils.formatDataUsage(context, backgroundBytes));
    verify(foregroundPref).setSummary(DataUsageUtils.formatDataUsage(context, foregroundBytes));
}
Also used : Context(android.content.Context) RestrictedSwitchPreference(com.android.settingslib.RestrictedSwitchPreference) Preference(androidx.preference.Preference) ArrayList(java.util.ArrayList) NetworkCycleDataForUid(com.android.settingslib.net.NetworkCycleDataForUid) Test(org.junit.Test)

Example 100 with Preference

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

the class ConnectedDeviceGroupControllerTest method onDeviceRemoved_notLastRemove_stillVisible.

@Test
public void onDeviceRemoved_notLastRemove_stillVisible() {
    mPreferenceGroup.setVisible(true);
    mPreferenceGroup.addPreference(mPreference);
    mPreferenceGroup.addPreference(new Preference(mContext));
    mConnectedDeviceGroupController.onDeviceRemoved(mPreference);
    assertThat(mPreferenceGroup.isVisible()).isTrue();
}
Also used : Preference(androidx.preference.Preference) Test(org.junit.Test)

Aggregations

Preference (androidx.preference.Preference)863 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)43 PreferenceCategory (androidx.preference.PreferenceCategory)40 Tile (com.android.settingslib.drawer.Tile)40 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