Search in sources :

Example 6 with SummaryLoader

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

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 7 with SummaryLoader

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

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

Example 8 with SummaryLoader

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

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

Example 9 with SummaryLoader

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

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

Example 10 with SummaryLoader

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

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)

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