Search in sources :

Example 6 with ListPreference

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

the class BluetoothSnoopLogPreferenceControllerTest method setup.

@Before
public void setup() {
    MockitoAnnotations.initMocks(this);
    doReturn(mSpyResources).when(mSpyContext).getResources();
    // Get XML values without mock
    // Setup test list preference using XML values
    mPreference = new ListPreference(mSpyContext);
    mPreference.setEntries(R.array.bt_hci_snoop_log_entries);
    mPreference.setEntryValues(R.array.bt_hci_snoop_log_values);
    // Init the actual controller
    mController = new BluetoothSnoopLogPreferenceController(mSpyContext);
    // Construct preference in the controller via a mocked preference screen object
    when(mPreferenceScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
    mController.displayPreference(mPreferenceScreen);
    mListValues = mPreference.getEntryValues();
    mListEntries = mPreference.getEntries();
}
Also used : ListPreference(androidx.preference.ListPreference) Before(org.junit.Before)

Example 7 with ListPreference

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

the class ApnEditorTest method setMockPreference.

private void setMockPreference(Context context) {
    mApnEditorUT.mName = new EditTextPreference(context);
    mApnEditorUT.mApn = new EditTextPreference(context);
    mApnEditorUT.mProxy = new EditTextPreference(context);
    mApnEditorUT.mPort = new EditTextPreference(context);
    mApnEditorUT.mUser = new EditTextPreference(context);
    mApnEditorUT.mServer = new EditTextPreference(context);
    mApnEditorUT.mPassword = new EditTextPreference(context);
    mApnEditorUT.mMmsc = new EditTextPreference(context);
    mApnEditorUT.mMcc = new EditTextPreference(context);
    mApnEditorUT.mMnc = new EditTextPreference(context);
    mApnEditorUT.mMmsProxy = new EditTextPreference(context);
    mApnEditorUT.mMmsPort = new EditTextPreference(context);
    mApnEditorUT.mAuthType = new ListPreference(context);
    mApnEditorUT.mApnType = new EditTextPreference(context);
    mApnEditorUT.mProtocol = new ListPreference(context);
    mApnEditorUT.mRoamingProtocol = new ListPreference(context);
    mApnEditorUT.mCarrierEnabled = new SwitchPreference(context);
    mApnEditorUT.mBearerMulti = new MultiSelectListPreference(context);
    mApnEditorUT.mMvnoType = new ListPreference(context);
    mApnEditorUT.mMvnoMatchData = new EditTextPreference(context);
}
Also used : SwitchPreference(androidx.preference.SwitchPreference) MultiSelectListPreference(androidx.preference.MultiSelectListPreference) EditTextPreference(androidx.preference.EditTextPreference) MultiSelectListPreference(androidx.preference.MultiSelectListPreference) ListPreference(androidx.preference.ListPreference)

Example 8 with ListPreference

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

the class SwipeDirectionPreferenceControllerTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    mContext = RuntimeEnvironment.application;
    mController = new SwipeDirectionPreferenceController(mContext, KEY);
    mPreference = new ListPreference(RuntimeEnvironment.application);
    mPreference.setKey(mController.getPreferenceKey());
    when(mScreen.findPreference(mPreference.getKey())).thenReturn(mPreference);
}
Also used : ListPreference(androidx.preference.ListPreference) Before(org.junit.Before)

Example 9 with ListPreference

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

the class ThemePreferenceControllerTest method testUpdateState_withStaticOverlay.

@Test
public void testUpdateState_withStaticOverlay() throws Exception {
    OverlayInfo info1 = new OverlayInfo("com.android.Theme1", "android", "", OverlayInfo.CATEGORY_THEME, "", OverlayInfo.STATE_ENABLED, 0, 0, true);
    OverlayInfo info2 = new OverlayInfo("com.android.Theme2", "android", "", OverlayInfo.CATEGORY_THEME, "", OverlayInfo.STATE_ENABLED, 0, 0, true);
    when(mMockPackageManager.getApplicationInfo(any(), anyInt())).thenAnswer(inv -> {
        ApplicationInfo info = mock(ApplicationInfo.class);
        if ("com.android.Theme1".equals(inv.getArguments()[0])) {
            when(info.loadLabel(any())).thenReturn("Theme1");
        } else {
            when(info.loadLabel(any())).thenReturn("Theme2");
        }
        return info;
    });
    PackageInfo pi = mock(PackageInfo.class);
    when(pi.isStaticOverlayPackage()).thenReturn(true);
    when(mMockPackageManager.getPackageInfo(eq("com.android.Theme1"), anyInt())).thenReturn(pi);
    when(mMockPackageManager.getPackageInfo(eq("com.android.Theme2"), anyInt())).thenReturn(new PackageInfo());
    when(mMockOverlayManager.getOverlayInfosForTarget(any(), anyInt())).thenReturn(list(info1, info2));
    ListPreference pref = mock(ListPreference.class);
    mPreferenceController.updateState(pref);
    ArgumentCaptor<String[]> arg = ArgumentCaptor.forClass(String[].class);
    verify(pref).setEntries(arg.capture());
    CharSequence[] entries = arg.getValue();
    assertThat(entries).asList().containsExactly("Theme2");
    verify(pref).setEntryValues(arg.capture());
    CharSequence[] entryValues = arg.getValue();
    assertThat(entryValues).asList().containsExactly("com.android.Theme2");
    verify(pref).setValue(eq("com.android.Theme2"));
}
Also used : PackageInfo(android.content.pm.PackageInfo) OverlayInfo(android.content.om.OverlayInfo) ApplicationInfo(android.content.pm.ApplicationInfo) ListPreference(androidx.preference.ListPreference) Matchers.anyString(org.mockito.Matchers.anyString) SmallTest(androidx.test.filters.SmallTest) Test(org.junit.Test)

Example 10 with ListPreference

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

the class WifiTetherApBandPreferenceController method updateDisplay.

@Override
public void updateDisplay() {
    final WifiConfiguration config = mWifiManager.getWifiApConfiguration();
    if (config == null) {
        mBandIndex = 0;
        Log.d(TAG, "Updating band index to 0 because no config");
    } else if (is5GhzBandSupported()) {
        mBandIndex = validateSelection(config.apBand);
        Log.d(TAG, "Updating band index to " + mBandIndex);
    } else {
        config.apBand = 0;
        mWifiManager.setWifiApConfiguration(config);
        mBandIndex = config.apBand;
        Log.d(TAG, "5Ghz not supported, updating band index to " + mBandIndex);
    }
    ListPreference preference = (ListPreference) mPreference;
    preference.setEntries(mBandSummaries);
    preference.setEntryValues(mBandEntries);
    if (!is5GhzBandSupported()) {
        preference.setEnabled(false);
        preference.setSummary(R.string.wifi_ap_choose_2G);
    } else {
        preference.setValue(Integer.toString(config.apBand));
        preference.setSummary(getConfigSummary());
    }
}
Also used : WifiConfiguration(android.net.wifi.WifiConfiguration) ListPreference(androidx.preference.ListPreference)

Aggregations

ListPreference (androidx.preference.ListPreference)170 Test (org.junit.Test)24 Before (org.junit.Before)23 Preference (androidx.preference.Preference)20 EditTextPreference (androidx.preference.EditTextPreference)10 PreferenceScreen (androidx.preference.PreferenceScreen)10 SwitchPreference (androidx.preference.SwitchPreference)9 Context (android.content.Context)8 ContentResolver (android.content.ContentResolver)7 Intent (android.content.Intent)7 PersistableBundle (android.os.PersistableBundle)6 MultiSelectListPreference (androidx.preference.MultiSelectListPreference)6 Resources (android.content.res.Resources)5 Bundle (android.os.Bundle)5 RemoteException (android.os.RemoteException)5 RestrictionEntry (android.content.RestrictionEntry)4 OverlayInfo (android.content.om.OverlayInfo)4 ApplicationInfo (android.content.pm.ApplicationInfo)4 PackageInfo (android.content.pm.PackageInfo)4 WifiConfiguration (android.net.wifi.WifiConfiguration)4