use of com.android.settings.dashboard.SummaryLoader in project android_packages_apps_Settings by LineageOS.
the class UserAndAccountDashboardFragmentTest method updateSummary_shouldDisplaySignedInUser.
@Test
public void updateSummary_shouldDisplaySignedInUser() {
final Activity activity = mock(Activity.class);
final SummaryLoader loader = mock(SummaryLoader.class);
final UserInfo userInfo = new UserInfo();
userInfo.name = "test_name";
when(activity.getSystemService(UserManager.class)).thenReturn(mUserManager);
when(mUserManager.getUserInfo(anyInt())).thenReturn(userInfo);
final SummaryLoader.SummaryProvider provider = mFragment.SUMMARY_PROVIDER_FACTORY.createSummaryProvider(activity, loader);
provider.setListening(true);
verify(activity).getString(R.string.users_and_accounts_summary, userInfo.name);
}
use of com.android.settings.dashboard.SummaryLoader in project android_packages_apps_Settings by LineageOS.
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 LineageOS.
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 LineageOS.
the class NetworkDashboardFragmentTest method testSummaryProvider_hasMobileAndHotspot_shouldReturnMobileSummary.
@Test
public void testSummaryProvider_hasMobileAndHotspot_shouldReturnMobileSummary() {
final MobileNetworkPreferenceController mobileNetworkPreferenceController = mock(MobileNetworkPreferenceController.class);
final TetherPreferenceController tetherPreferenceController = mock(TetherPreferenceController.class);
final SummaryLoader summaryLoader = mock(SummaryLoader.class);
final SummaryLoader.SummaryProvider provider = new NetworkDashboardFragment.SummaryProvider(mContext, summaryLoader, mobileNetworkPreferenceController, tetherPreferenceController);
provider.setListening(false);
verifyZeroInteractions(summaryLoader);
when(mobileNetworkPreferenceController.isAvailable()).thenReturn(true);
when(tetherPreferenceController.isAvailable()).thenReturn(true);
provider.setListening(true);
verify(mContext).getString(R.string.wifi_settings_title);
verify(mContext).getString(R.string.network_dashboard_summary_data_usage);
verify(mContext).getString(R.string.network_dashboard_summary_hotspot);
verify(mContext).getString(R.string.network_dashboard_summary_mobile);
verify(mContext, times(3)).getString(R.string.join_many_items_middle, null, null);
}
use of com.android.settings.dashboard.SummaryLoader in project android_packages_apps_Settings by LineageOS.
the class NetworkDashboardFragmentTest method testSummaryProvider_noMobileOrHotspot_shouldReturnSimpleSummary.
@Test
public void testSummaryProvider_noMobileOrHotspot_shouldReturnSimpleSummary() {
final MobileNetworkPreferenceController mobileNetworkPreferenceController = mock(MobileNetworkPreferenceController.class);
final TetherPreferenceController tetherPreferenceController = mock(TetherPreferenceController.class);
final SummaryLoader summaryLoader = mock(SummaryLoader.class);
final SummaryLoader.SummaryProvider provider = new NetworkDashboardFragment.SummaryProvider(mContext, summaryLoader, mobileNetworkPreferenceController, tetherPreferenceController);
provider.setListening(false);
verifyZeroInteractions(summaryLoader);
when(mobileNetworkPreferenceController.isAvailable()).thenReturn(false);
when(tetherPreferenceController.isAvailable()).thenReturn(false);
provider.setListening(true);
verify(mContext).getString(R.string.wifi_settings_title);
verify(mContext).getString(R.string.network_dashboard_summary_data_usage);
verify(mContext).getString(R.string.join_many_items_middle, null, null);
}
Aggregations