Search in sources :

Example 31 with Preference

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

the class TermsPreferenceControllerTest method setup.

@Before
public void setup() {
    MockitoAnnotations.initMocks(this);
    mContext = spy(RuntimeEnvironment.application);
    mPreference = new Preference(mContext);
    mPreference.setIntent(new Intent());
    when(mContext.getPackageManager()).thenReturn(mPackageManager);
    when(mScreen.findPreference(anyString())).thenReturn(mPreference);
    mController = new TermsPreferenceController(mContext, "pref_key");
    mController.displayPreference(mScreen);
}
Also used : Preference(androidx.preference.Preference) Intent(android.content.Intent) Before(org.junit.Before)

Example 32 with Preference

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

the class WebViewLicensePreferenceControllerTest method setup.

@Before
public void setup() {
    MockitoAnnotations.initMocks(this);
    mContext = spy(RuntimeEnvironment.application);
    mPreference = new Preference(mContext);
    mPreference.setIntent(new Intent());
    when(mContext.getPackageManager()).thenReturn(mPackageManager);
    when(mScreen.findPreference(anyString())).thenReturn(mPreference);
    mController = new WebViewLicensePreferenceController(mContext, "pref_key");
    mController.displayPreference(mScreen);
}
Also used : Preference(androidx.preference.Preference) Intent(android.content.Intent) Before(org.junit.Before)

Example 33 with Preference

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

the class LicensePreferenceControllerTest method setup.

@Before
public void setup() {
    MockitoAnnotations.initMocks(this);
    mContext = spy(RuntimeEnvironment.application);
    mPreference = new Preference(mContext);
    mPreference.setIntent(new Intent());
    when(mContext.getPackageManager()).thenReturn(mPackageManager);
    when(mScreen.findPreference(anyString())).thenReturn(mPreference);
    mController = new LicensePreferenceController(mContext, "pref_key");
    mController.displayPreference(mScreen);
}
Also used : Preference(androidx.preference.Preference) Intent(android.content.Intent) Before(org.junit.Before)

Example 34 with Preference

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

the class ColorModePreferenceFragmentTest method addStaticPreferences_shouldAddPreviewImage.

@Test
public void addStaticPreferences_shouldAddPreviewImage() {
    PreferenceScreen mockPreferenceScreen = mock(PreferenceScreen.class);
    LayoutPreference mockPreview = mock(LayoutPreference.class);
    ArgumentCaptor<Preference> preferenceCaptor = ArgumentCaptor.forClass(Preference.class);
    mFragment.configureAndInstallPreview(mockPreview, mockPreferenceScreen);
    verify(mockPreview, times(1)).setSelectable(false);
    verify(mockPreferenceScreen, times(1)).addPreference(preferenceCaptor.capture());
    assertThat(preferenceCaptor.getValue()).isEqualTo(mockPreview);
}
Also used : LayoutPreference(com.android.settingslib.widget.LayoutPreference) PreferenceScreen(androidx.preference.PreferenceScreen) LayoutPreference(com.android.settingslib.widget.LayoutPreference) Preference(androidx.preference.Preference) Test(org.junit.Test)

Example 35 with Preference

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

the class WallpaperPreferenceControllerTest method handlePreferenceTreeClick_wallpaperOnly.

@Test
public void handlePreferenceTreeClick_wallpaperOnly() {
    mShadowPackageManager.setResolveInfosForIntent(mWallpaperIntent, Lists.newArrayList(mock(ResolveInfo.class)));
    mShadowPackageManager.setResolveInfosForIntent(mStylesAndWallpaperIntent, Lists.newArrayList());
    Preference preference = new Preference(mContext);
    preference.setKey(TEST_KEY);
    mController.handlePreferenceTreeClick(preference);
    assertThat(Shadows.shadowOf(mContext).getNextStartedActivityForResult().intent.getComponent().getClassName()).isEqualTo(mContext.getString(R.string.config_wallpaper_picker_class));
}
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