use of com.android.settings.dashboard.SummaryLoader in project android_packages_apps_Settings by SudaMod.
the class LanguageAndInputSettingsTest method testSummary_shouldSetToCurrentImeName.
@Test
@Config(shadows = { ShadowSecureSettings.class })
public void testSummary_shouldSetToCurrentImeName() {
final Activity activity = mock(Activity.class);
final SummaryLoader loader = mock(SummaryLoader.class);
final ComponentName componentName = new ComponentName("pkg", "cls");
final ContentResolver cr = activity.getContentResolver();
Settings.Secure.putString(cr, Settings.Secure.DEFAULT_INPUT_METHOD, componentName.flattenToString());
when(activity.getSystemService(Context.INPUT_METHOD_SERVICE)).thenReturn(mInputMethodManager);
when(activity.getPackageManager()).thenReturn(mPackageManager);
final List<InputMethodInfo> imis = new ArrayList<>();
imis.add(mock(InputMethodInfo.class));
when(imis.get(0).getPackageName()).thenReturn(componentName.getPackageName());
when(mInputMethodManager.getInputMethodList()).thenReturn(imis);
SummaryLoader.SummaryProvider provider = mFragment.SUMMARY_PROVIDER_FACTORY.createSummaryProvider(activity, loader);
provider.setListening(true);
verify(imis.get(0)).loadLabel(mPackageManager);
verify(loader).setSummary(provider, null);
}
use of com.android.settings.dashboard.SummaryLoader in project android_packages_apps_Settings by SudaMod.
the class StorageSettingsTest method updateSummary_shouldDisplayUsedPercentAndFreeSpace.
@Test
public void updateSummary_shouldDisplayUsedPercentAndFreeSpace() throws Exception {
final SummaryLoader loader = mock(SummaryLoader.class);
final SummaryLoader.SummaryProvider provider = StorageSettings.SUMMARY_PROVIDER_FACTORY.createSummaryProvider(mActivity, loader);
final VolumeInfo volumeInfo = mVolumes.get(0);
when(volumeInfo.isMountedReadable()).thenReturn(true);
when(volumeInfo.getType()).thenReturn(VolumeInfo.TYPE_PRIVATE);
when(mStorageManagerVolumeProvider.getTotalBytes(nullable(StorageStatsManager.class), nullable(VolumeInfo.class))).thenReturn(500L);
when(mStorageManagerVolumeProvider.getFreeBytes(nullable(StorageStatsManager.class), nullable(VolumeInfo.class))).thenReturn(0L);
ReflectionHelpers.setField(provider, "mStorageManagerVolumeProvider", mStorageManagerVolumeProvider);
ReflectionHelpers.setField(provider, "mContext", RuntimeEnvironment.application);
provider.setListening(true);
final String percentage = NumberFormat.getPercentInstance().format(1);
final String freeSpace = Formatter.formatFileSize(RuntimeEnvironment.application, 0);
verify(loader).setSummary(provider, RuntimeEnvironment.application.getString(R.string.storage_summary, percentage, freeSpace));
}
use of com.android.settings.dashboard.SummaryLoader in project android_packages_apps_Settings by SudaMod.
the class DefaultAppSettingsTest method setListening_shouldUpdateSummary.
@Test
public void setListening_shouldUpdateSummary() {
final SummaryLoader summaryLoader = mock(SummaryLoader.class);
final DefaultAppSettings.SummaryProvider summaryProvider = new DefaultAppSettings.SummaryProvider(mContext, summaryLoader);
final DefaultSmsPreferenceController defaultSms = mock(DefaultSmsPreferenceController.class);
final DefaultBrowserPreferenceController defaultBrowser = mock(DefaultBrowserPreferenceController.class);
final DefaultPhonePreferenceController defaultPhone = mock(DefaultPhonePreferenceController.class);
ReflectionHelpers.setField(summaryProvider, "mDefaultSmsPreferenceController", defaultSms);
ReflectionHelpers.setField(summaryProvider, "mDefaultBrowserPreferenceController", defaultBrowser);
ReflectionHelpers.setField(summaryProvider, "mDefaultPhonePreferenceController", defaultPhone);
// all available
when(defaultSms.getDefaultAppLabel()).thenReturn("Sms1");
when(defaultBrowser.getDefaultAppLabel()).thenReturn("Browser1");
when(defaultPhone.getDefaultAppLabel()).thenReturn("Phone1");
summaryProvider.setListening(true);
verify(summaryLoader).setSummary(summaryProvider, "Sms1, Browser1, Phone1");
// 2 available
when(defaultSms.getDefaultAppLabel()).thenReturn(null);
when(defaultBrowser.getDefaultAppLabel()).thenReturn("Browser1");
when(defaultPhone.getDefaultAppLabel()).thenReturn("Phone1");
summaryProvider.setListening(true);
verify(summaryLoader).setSummary(summaryProvider, "Browser1, Phone1");
when(defaultSms.getDefaultAppLabel()).thenReturn("Sms1");
when(defaultBrowser.getDefaultAppLabel()).thenReturn(null);
when(defaultPhone.getDefaultAppLabel()).thenReturn("Phone1");
summaryProvider.setListening(true);
verify(summaryLoader).setSummary(summaryProvider, "Sms1, Phone1");
when(defaultSms.getDefaultAppLabel()).thenReturn("Sms1");
when(defaultBrowser.getDefaultAppLabel()).thenReturn("Browser1");
when(defaultPhone.getDefaultAppLabel()).thenReturn(null);
summaryProvider.setListening(true);
verify(summaryLoader).setSummary(summaryProvider, "Sms1, Browser1");
// 1 available
when(defaultSms.getDefaultAppLabel()).thenReturn(null);
when(defaultBrowser.getDefaultAppLabel()).thenReturn("Browser1");
when(defaultPhone.getDefaultAppLabel()).thenReturn(null);
summaryProvider.setListening(true);
verify(summaryLoader).setSummary(summaryProvider, "Browser1");
when(defaultSms.getDefaultAppLabel()).thenReturn("Sms1");
when(defaultBrowser.getDefaultAppLabel()).thenReturn(null);
when(defaultPhone.getDefaultAppLabel()).thenReturn(null);
summaryProvider.setListening(true);
verify(summaryLoader).setSummary(summaryProvider, "Sms1");
when(defaultSms.getDefaultAppLabel()).thenReturn(null);
when(defaultBrowser.getDefaultAppLabel()).thenReturn(null);
when(defaultPhone.getDefaultAppLabel()).thenReturn("Phone1");
summaryProvider.setListening(true);
verify(summaryLoader).setSummary(summaryProvider, "Phone1");
// None available
when(defaultSms.getDefaultAppLabel()).thenReturn(null);
when(defaultBrowser.getDefaultAppLabel()).thenReturn(null);
when(defaultPhone.getDefaultAppLabel()).thenReturn(null);
summaryProvider.setListening(true);
verify(summaryLoader, never()).setSummary(summaryProvider, eq(anyString()));
}
use of com.android.settings.dashboard.SummaryLoader in project android_packages_apps_Settings by SudaMod.
the class ConnectedDeviceDashboardFragmentTest method testSummaryProvider_hasNfc_shouldReturnNfcSummary.
@Test
public void testSummaryProvider_hasNfc_shouldReturnNfcSummary() {
final NfcManager nfcManager = mock(NfcManager.class);
final SummaryLoader summaryLoader = mock(SummaryLoader.class);
when(mContext.getApplicationContext()).thenReturn(mContext);
when(mContext.getSystemService(NFC_SERVICE)).thenReturn(nfcManager);
when(nfcManager.getDefaultAdapter()).thenReturn(mock(NfcAdapter.class));
SummaryLoader.SummaryProvider provider = new ConnectedDeviceDashboardFragment.SummaryProvider(mContext, summaryLoader);
provider.setListening(false);
verifyZeroInteractions(summaryLoader);
provider.setListening(true);
verify(mContext).getString(R.string.connected_devices_dashboard_summary);
}
use of com.android.settings.dashboard.SummaryLoader in project android_packages_apps_Settings by SudaMod.
the class ConnectedDeviceDashboardFragmentTest method testSummaryProvider_noNfc_shouldReturnNoNfcSummary.
@Test
public void testSummaryProvider_noNfc_shouldReturnNoNfcSummary() {
final SummaryLoader summaryLoader = mock(SummaryLoader.class);
when(mContext.getApplicationContext()).thenReturn(mContext);
when(mContext.getSystemService(NFC_SERVICE)).thenReturn(null);
SummaryLoader.SummaryProvider provider = new ConnectedDeviceDashboardFragment.SummaryProvider(mContext, summaryLoader);
provider.setListening(false);
verifyZeroInteractions(summaryLoader);
provider.setListening(true);
verify(mContext).getString(R.string.connected_devices_dashboard_no_nfc_summary);
}
Aggregations