use of androidx.preference.PreferenceManager in project android_packages_apps_Settings by omnirom.
the class PaymentSettingsTest method isShowEmptyImage_hasNoVisiblePreference_returnTrue.
@Test
public void isShowEmptyImage_hasNoVisiblePreference_returnTrue() {
final PaymentSettings paymentSettings = new PaymentSettings();
final PreferenceManager preferenceManager = new PreferenceManager(mContext);
final PreferenceScreen screen = preferenceManager.createPreferenceScreen(mContext);
final Preference preference1 = new Preference(mContext);
preference1.setVisible(false);
screen.addPreference(preference1);
final Preference preference2 = new Preference(mContext);
screen.addPreference(preference2);
preference2.setVisible(false);
assertThat(paymentSettings.isShowEmptyImage(screen)).isTrue();
}
use of androidx.preference.PreferenceManager in project android_packages_apps_Settings by omnirom.
the class PhoneNumberPreferenceControllerTest method setup.
@Before
public void setup() {
MockitoAnnotations.initMocks(this);
mContext = spy(ApplicationProvider.getApplicationContext());
mClipboardManager = (ClipboardManager) spy(mContext.getSystemService(CLIPBOARD_SERVICE));
doReturn(mClipboardManager).when(mContext).getSystemService(CLIPBOARD_SERVICE);
when(mContext.getSystemService(SubscriptionManager.class)).thenReturn(mSubscriptionManager);
when(mContext.getSystemService(TelephonyManager.class)).thenReturn(mTelephonyManager);
mController = spy(new PhoneNumberPreferenceController(mContext, "phone_number"));
if (Looper.myLooper() == null) {
Looper.prepare();
}
final PreferenceManager preferenceManager = new PreferenceManager(mContext);
mScreen = preferenceManager.createPreferenceScreen(mContext);
mPreference = spy(new Preference(mContext));
mPreference.setKey(mController.getPreferenceKey());
mPreference.setVisible(true);
mScreen.addPreference(mPreference);
final String categoryKey = "basic_info_category";
mCategory = new PreferenceCategory(mContext);
mCategory.setKey(categoryKey);
mScreen.addPreference(mCategory);
doReturn(mSubscriptionInfo).when(mController).getSubscriptionInfo(anyInt());
doReturn(mSecondPreference).when(mController).createNewPreference(mContext);
}
use of androidx.preference.PreferenceManager in project android_packages_apps_Settings by omnirom.
the class StorageSelectionPreferenceControllerTest method setUp.
@Before
public void setUp() throws Exception {
if (Looper.myLooper() == null) {
Looper.prepare();
}
mContext = ApplicationProvider.getApplicationContext();
mStorageManager = mContext.getSystemService(StorageManager.class);
mController = new StorageSelectionPreferenceController(mContext, PREFERENCE_KEY);
final PreferenceManager preferenceManager = new PreferenceManager(mContext);
final PreferenceScreen preferenceScreen = preferenceManager.createPreferenceScreen(mContext);
final SettingsSpinnerPreference spinnerPreference = new SettingsSpinnerPreference(mContext);
spinnerPreference.setKey(PREFERENCE_KEY);
preferenceScreen.addPreference(spinnerPreference);
mController.displayPreference(preferenceScreen);
}
use of androidx.preference.PreferenceManager in project android_packages_apps_Settings by omnirom.
the class MobileNetworkSwitchControllerTest method setUp.
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
mContext = spy(ApplicationProvider.getApplicationContext());
when(mContext.getSystemService(SubscriptionManager.class)).thenReturn(mSubscriptionManager);
when(mSubscriptionManager.setSubscriptionEnabled(eq(mSubId), anyBoolean())).thenReturn(true);
when(mSubscription.isEmbedded()).thenReturn(true);
when(mSubscription.getSubscriptionId()).thenReturn(mSubId);
// Most tests want to have 2 available subscriptions so that the switch bar will show.
final SubscriptionInfo sub2 = mock(SubscriptionInfo.class);
when(sub2.getSubscriptionId()).thenReturn(456);
SubscriptionUtil.setAvailableSubscriptionsForTesting(Arrays.asList(mSubscription, sub2));
final String key = "prefKey";
mController = new MobileNetworkSwitchController(mContext, key);
mController.init(mLifecycle, mSubscription.getSubscriptionId());
if (Looper.myLooper() == null) {
Looper.prepare();
}
mPreferenceManager = new PreferenceManager(mContext);
mScreen = mPreferenceManager.createPreferenceScreen(mContext);
mSwitchBar = new SettingsMainSwitchPreference(mContext);
mSwitchBar.setKey(key);
mScreen.addPreference(mSwitchBar);
final LayoutInflater inflater = LayoutInflater.from(mContext);
final View view = inflater.inflate(mSwitchBar.getLayoutResource(), new LinearLayout(mContext), false);
final PreferenceViewHolder holder = PreferenceViewHolder.createInstanceForTests(view);
mSwitchBar.onBindViewHolder(holder);
}
use of androidx.preference.PreferenceManager in project android_packages_apps_Settings by omnirom.
the class NetworkProviderWifiCallingPreferenceControllerTest method setUp.
@Before
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
mContext = spy(ApplicationProvider.getApplicationContext());
mCategoryController = new NetworkProviderWifiCallingPreferenceController(mContext, KEY_PREFERENCE_WFC_CATEGORY) {
@Override
protected NetworkProviderWifiCallingGroup createWifiCallingControllerForSub(Lifecycle lifecycle) {
return mWifiCallingForSubController;
}
};
if (Looper.myLooper() == null) {
Looper.prepare();
}
mPreferenceManager = new PreferenceManager(mContext);
mPreferenceScreen = mPreferenceManager.createPreferenceScreen(mContext);
when(mPreferenceCategory.getKey()).thenReturn(KEY_PREFERENCE_WFC_CATEGORY);
when(mPreferenceCategory.getPreferenceCount()).thenReturn(1);
mPreferenceScreen.addPreference(mPreferenceCategory);
}
Aggregations