Search in sources :

Example 21 with SummaryLoader

use of com.android.settings.dashboard.SummaryLoader in project platform_packages_apps_Settings by BlissRoms.

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);
}
Also used : NfcManager(android.nfc.NfcManager) SummaryLoader(com.android.settings.dashboard.SummaryLoader) NfcAdapter(android.nfc.NfcAdapter) Test(org.junit.Test)

Example 22 with SummaryLoader

use of com.android.settings.dashboard.SummaryLoader in project android_packages_apps_Settings by omnirom.

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);
}
Also used : SummaryLoader(com.android.settings.dashboard.SummaryLoader) ArrayList(java.util.ArrayList) Activity(android.app.Activity) ComponentName(android.content.ComponentName) InputMethodInfo(android.view.inputmethod.InputMethodInfo) ContentResolver(android.content.ContentResolver) Test(org.junit.Test) Config(org.robolectric.annotation.Config) TestConfig(com.android.settings.TestConfig)

Example 23 with SummaryLoader

use of com.android.settings.dashboard.SummaryLoader in project android_packages_apps_Settings by omnirom.

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);
}
Also used : SummaryLoader(com.android.settings.dashboard.SummaryLoader) Test(org.junit.Test)

Example 24 with SummaryLoader

use of com.android.settings.dashboard.SummaryLoader in project android_packages_apps_Settings by omnirom.

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));
}
Also used : StorageStatsManager(android.app.usage.StorageStatsManager) SummaryLoader(com.android.settings.dashboard.SummaryLoader) VolumeInfo(android.os.storage.VolumeInfo) Test(org.junit.Test)

Example 25 with SummaryLoader

use of com.android.settings.dashboard.SummaryLoader in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class LanguageAndInputSettingsTest method testSummary_shouldSetToCurrentImeName.

@Test
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 = LanguageAndInputSettings.SUMMARY_PROVIDER_FACTORY.createSummaryProvider(activity, loader);
    provider.setListening(true);
    verify(imis.get(0)).loadLabel(mPackageManager);
    verify(loader).setSummary(provider, null);
}
Also used : SummaryLoader(com.android.settings.dashboard.SummaryLoader) ArrayList(java.util.ArrayList) Activity(android.app.Activity) ComponentName(android.content.ComponentName) InputMethodInfo(android.view.inputmethod.InputMethodInfo) ContentResolver(android.content.ContentResolver) Test(org.junit.Test)

Aggregations

SummaryLoader (com.android.settings.dashboard.SummaryLoader)51 Test (org.junit.Test)51 Activity (android.app.Activity)13 ComponentName (android.content.ComponentName)7 ContentResolver (android.content.ContentResolver)7 InputMethodInfo (android.view.inputmethod.InputMethodInfo)7 ArrayList (java.util.ArrayList)7 StorageStatsManager (android.app.usage.StorageStatsManager)6 UserInfo (android.content.pm.UserInfo)6 NfcAdapter (android.nfc.NfcAdapter)6 NfcManager (android.nfc.NfcManager)6 VolumeInfo (android.os.storage.VolumeInfo)6 TestConfig (com.android.settings.TestConfig)6 DefaultBrowserPreferenceController (com.android.settings.applications.defaultapps.DefaultBrowserPreferenceController)6 DefaultPhonePreferenceController (com.android.settings.applications.defaultapps.DefaultPhonePreferenceController)6 DefaultSmsPreferenceController (com.android.settings.applications.defaultapps.DefaultSmsPreferenceController)6 Config (org.robolectric.annotation.Config)6 SummaryProvider (com.android.settings.notification.ConfigureNotificationSettings.SummaryProvider)2