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);
}
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);
});
}
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());
}
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());
}
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);
}
Aggregations