Search in sources :

Example 21 with PreferenceManager

use of androidx.preference.PreferenceManager in project android_packages_apps_Settings by omnirom.

the class NetworkProviderSimsCategoryControllerTest method setUp.

@Before
public void setUp() throws Exception {
    MockitoAnnotations.initMocks(this);
    mContext = spy(ApplicationProvider.getApplicationContext());
    if (Looper.myLooper() == null) {
        Looper.prepare();
    }
    mPreferenceManager = new PreferenceManager(mContext);
    mPreferenceScreen = mPreferenceManager.createPreferenceScreen(mContext);
    mPreferenceCategory = new PreferenceCategory(mContext);
    mPreferenceCategory.setKey(KEY_PREFERENCE_CATEGORY_SIM);
    mPreferenceScreen.addPreference(mPreferenceCategory);
    mCategoryController = new NetworkProviderSimsCategoryController(mContext, KEY_PREFERENCE_CATEGORY_SIM, mLifecycle);
}
Also used : PreferenceCategory(androidx.preference.PreferenceCategory) PreferenceManager(androidx.preference.PreferenceManager) Before(org.junit.Before)

Example 22 with PreferenceManager

use of androidx.preference.PreferenceManager in project android_packages_apps_Settings by omnirom.

the class ConnectedEthernetNetworkControllerTest method setUp.

@Before
public void setUp() {
    mContext = spy(ApplicationProvider.getApplicationContext());
    when(mContext.getSystemService(ConnectivityManager.class)).thenReturn(mock(ConnectivityManager.class));
    when(mContext.getSystemService(Context.WIFI_SERVICE)).thenReturn(mock(WifiManager.class));
    mController = new ConnectedEthernetNetworkController(mContext, mock(Lifecycle.class));
    if (Looper.myLooper() == null) {
        Looper.prepare();
    }
    final PreferenceManager preferenceManager = new PreferenceManager(mContext);
    mScreen = preferenceManager.createPreferenceScreen(mContext);
    mPreference = new Preference(mContext);
    mPreference.setKey(ConnectedEthernetNetworkController.KEY);
    mScreen.addPreference(mPreference);
}
Also used : WifiManager(android.net.wifi.WifiManager) Preference(androidx.preference.Preference) ConnectivityManager(android.net.ConnectivityManager) PreferenceManager(androidx.preference.PreferenceManager) Before(org.junit.Before)

Example 23 with PreferenceManager

use of androidx.preference.PreferenceManager in project android_packages_apps_Settings by omnirom.

the class StorageUsageProgressBarPreferenceControllerTest method setUp.

@Before
public void setUp() throws Exception {
    if (Looper.myLooper() == null) {
        Looper.prepare();
    }
    MockitoAnnotations.initMocks(this);
    mContext = spy(ApplicationProvider.getApplicationContext());
    when(mContext.getSystemService(StorageStatsManager.class)).thenReturn(mStorageStatsManager);
    mController = new FakeStorageUsageProgressBarPreferenceController(mContext, "key");
    final PreferenceManager preferenceManager = new PreferenceManager(mContext);
    mPreferenceScreen = preferenceManager.createPreferenceScreen(mContext);
    final UsageProgressBarPreference usageProgressBarPreference = new UsageProgressBarPreference(mContext);
    usageProgressBarPreference.setKey(mController.getPreferenceKey());
    mPreferenceScreen.addPreference(usageProgressBarPreference);
}
Also used : UsageProgressBarPreference(com.android.settingslib.widget.UsageProgressBarPreference) PreferenceManager(androidx.preference.PreferenceManager) Before(org.junit.Before)

Example 24 with PreferenceManager

use of androidx.preference.PreferenceManager in project android_packages_apps_Settings by omnirom.

the class ChooseAccountPreferenceControllerTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    mContext = RuntimeEnvironment.application;
    mController = spy(new ChooseAccountPreferenceController(mContext, "controller_key"));
    mActivity = Robolectric.setupActivity(FragmentActivity.class);
    mPreferenceManager = new PreferenceManager(mContext);
    mPreferenceScreen = mPreferenceManager.createPreferenceScreen(mContext);
}
Also used : FragmentActivity(androidx.fragment.app.FragmentActivity) PreferenceManager(androidx.preference.PreferenceManager) Before(org.junit.Before)

Example 25 with PreferenceManager

use of androidx.preference.PreferenceManager in project android_packages_apps_Settings by omnirom.

the class PaymentSettingsTest method isShowEmptyImage_hasVisiblePreference_returnFalse.

@Test
public void isShowEmptyImage_hasVisiblePreference_returnFalse() {
    final PaymentSettings paymentSettings = new PaymentSettings();
    final PreferenceManager preferenceManager = new PreferenceManager(mContext);
    final PreferenceScreen screen = preferenceManager.createPreferenceScreen(mContext);
    final Preference preference1 = new Preference(mContext);
    screen.addPreference(preference1);
    final Preference preference2 = new Preference(mContext);
    screen.addPreference(preference2);
    assertThat(paymentSettings.isShowEmptyImage(screen)).isFalse();
}
Also used : PreferenceScreen(androidx.preference.PreferenceScreen) Preference(androidx.preference.Preference) PreferenceManager(androidx.preference.PreferenceManager) Test(org.junit.Test)

Aggregations

PreferenceManager (androidx.preference.PreferenceManager)87 Before (org.junit.Before)67 Preference (androidx.preference.Preference)23 PreferenceCategory (androidx.preference.PreferenceCategory)22 PreferenceScreen (androidx.preference.PreferenceScreen)19 Test (org.junit.Test)18 Lifecycle (com.android.settingslib.core.lifecycle.Lifecycle)15 Context (android.content.Context)5 LifecycleRegistry (androidx.lifecycle.LifecycleRegistry)5 ArrayList (java.util.ArrayList)5 NotificationChannel (android.app.NotificationChannel)4 ShortcutInfo (android.content.pm.ShortcutInfo)4 View (android.view.View)4 NotificationChannelGroup (android.app.NotificationChannelGroup)3 ConversationChannel (android.app.people.ConversationChannel)3 PackageInfo (android.content.pm.PackageInfo)3 PersistableBundle (android.os.PersistableBundle)3 BluetoothManager (android.bluetooth.BluetoothManager)2 SoftApConfiguration (android.net.wifi.SoftApConfiguration)2 WifiManager (android.net.wifi.WifiManager)2