Search in sources :

Example 11 with PreferenceManager

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

the class WifiTetherSecurityPreferenceControllerTest method setUp.

@Before
public void setUp() {
    final Context context = spy(ApplicationProvider.getApplicationContext());
    mConfig = new SoftApConfiguration.Builder().setSsid("test_1234").setPassphrase(null, SoftApConfiguration.SECURITY_TYPE_OPEN).build();
    when(context.getSystemService(Context.WIFI_SERVICE)).thenReturn(mWifiManager);
    when(mWifiManager.getSoftApConfiguration()).thenReturn(mConfig);
    mController = new WifiTetherSecurityPreferenceController(context, mListener);
    if (Looper.myLooper() == null) {
        Looper.prepare();
    }
    final PreferenceManager preferenceManager = new PreferenceManager(context);
    final PreferenceScreen screen = preferenceManager.createPreferenceScreen(context);
    mPreference = new ListPreference(context);
    mPreference.setKey(PREF_KEY);
    screen.addPreference(mPreference);
    mController.displayPreference(screen);
}
Also used : Context(android.content.Context) PreferenceScreen(androidx.preference.PreferenceScreen) ListPreference(androidx.preference.ListPreference) PreferenceManager(androidx.preference.PreferenceManager) Before(org.junit.Before)

Example 12 with PreferenceManager

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

the class ChannelListPreferenceControllerTest method setUp.

@Before
public void setUp() throws Exception {
    Instrumentation instrumentation = InstrumentationRegistry.getInstrumentation();
    mContext = instrumentation.getTargetContext();
    instrumentation.runOnMainSync(() -> {
        mBackend = new NotificationBackend();
        mAppRow = mBackend.loadAppRow(mContext, mContext.getPackageManager(), mContext.getApplicationInfo());
        mController = new ChannelListPreferenceController(mContext, mBackend);
        mController.onResume(mAppRow, null, null, null, null, null);
        mPreferenceManager = new PreferenceManager(mContext);
        mPreferenceScreen = mPreferenceManager.createPreferenceScreen(mContext);
        mGroupList = new PreferenceCategory(mContext);
        mPreferenceScreen.addPreference(mGroupList);
    });
}
Also used : NotificationBackend(com.android.settings.notification.NotificationBackend) PreferenceCategory(androidx.preference.PreferenceCategory) Instrumentation(android.app.Instrumentation) PreferenceManager(androidx.preference.PreferenceManager) Before(org.junit.Before)

Example 13 with PreferenceManager

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

the class ConversationListPreferenceControllerTest method testPopulateList_validConversations.

@Test
public void testPopulateList_validConversations() {
    final PreferenceManager preferenceManager = new PreferenceManager(mContext);
    PreferenceScreen ps = preferenceManager.createPreferenceScreen(mContext);
    PreferenceCategory outerContainer = spy(new PreferenceCategory(mContext));
    ps.addPreference(outerContainer);
    ConversationChannelWrapper ccw = new ConversationChannelWrapper();
    ccw.setNotificationChannel(mock(NotificationChannel.class));
    ccw.setPkg("pkg");
    ccw.setUid(1);
    ccw.setShortcutInfo(mock(ShortcutInfo.class));
    ArrayList<ConversationChannelWrapper> list = new ArrayList<>();
    list.add(ccw);
    mController.populateList(list, outerContainer);
    verify(outerContainer, times(1)).addPreference(any());
}
Also used : NotificationChannel(android.app.NotificationChannel) PreferenceScreen(androidx.preference.PreferenceScreen) ShortcutInfo(android.content.pm.ShortcutInfo) PreferenceCategory(androidx.preference.PreferenceCategory) ConversationChannelWrapper(android.service.notification.ConversationChannelWrapper) ArrayList(java.util.ArrayList) PreferenceManager(androidx.preference.PreferenceManager) Test(org.junit.Test)

Example 14 with PreferenceManager

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

the class RecentConversationsPreferenceControllerTest method testPopulateList_validConversations.

@Test
public void testPopulateList_validConversations() {
    final PreferenceManager preferenceManager = new PreferenceManager(mContext);
    PreferenceScreen ps = preferenceManager.createPreferenceScreen(mContext);
    PreferenceCategory outerContainer = spy(new PreferenceCategory(mContext));
    ps.addPreference(outerContainer);
    ConversationChannel ccw = new ConversationChannel(mock(ShortcutInfo.class), 6, new NotificationChannel("hi", "hi", 4), new NotificationChannelGroup("hi", "hi"), 7, false);
    ArrayList<ConversationChannel> list = new ArrayList<>();
    list.add(ccw);
    mController.populateList(list, outerContainer);
    // one for the preference, one for the button ro clear all
    verify(outerContainer, times(2)).addPreference(any());
}
Also used : NotificationChannel(android.app.NotificationChannel) NotificationChannelGroup(android.app.NotificationChannelGroup) PreferenceScreen(androidx.preference.PreferenceScreen) ConversationChannel(android.app.people.ConversationChannel) ShortcutInfo(android.content.pm.ShortcutInfo) PreferenceCategory(androidx.preference.PreferenceCategory) ArrayList(java.util.ArrayList) PreferenceManager(androidx.preference.PreferenceManager) Test(org.junit.Test)

Example 15 with PreferenceManager

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

the class NetworkProviderSimListControllerTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    mContext = spy(ApplicationProvider.getApplicationContext());
    when(mContext.getSystemService(SubscriptionManager.class)).thenReturn(mSubscriptionManager);
    if (Looper.myLooper() == null) {
        Looper.prepare();
    }
    mPreferenceManager = new PreferenceManager(mContext);
    mPreferenceScreen = mPreferenceManager.createPreferenceScreen(mContext);
    mPreference = new Preference(mContext);
    mPreference.setKey(KEY_PREFERENCE_SIM_LIST);
    mController = new MockNetworkProviderSimListController(mContext, mLifecycle);
    mLifecycleRegistry = new LifecycleRegistry(mLifecycleOwner);
    when(mLifecycleOwner.getLifecycle()).thenReturn(mLifecycleRegistry);
}
Also used : LifecycleRegistry(androidx.lifecycle.LifecycleRegistry) Preference(androidx.preference.Preference) PreferenceManager(androidx.preference.PreferenceManager) Before(org.junit.Before)

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