@SuppressWarnings("deprecation") private void legacyCheckConnectivity() throws ConnectivityException { NetworkInfo active = getConnectivityManager().getActiveNetworkInfo(); if (active == null || !active.isConnectedOrConnecting()) { throw new NoConnectionException(); } if (getPreferences().isWifiOnly() && isBackgroundTask() && !isConnectedViaWifi()) { throw new RequiresWifiException(); } }
@Before public void before() { initMocks(this); sentNotifications = new ArrayList<NotificationCompat.Builder>(); service = new SmsBackupService() { @Override public Context getApplicationContext() { return RuntimeEnvironment.application; } @Override public Resources getResources() { return getApplicationContext().getResources(); } @Override protected BackupTask getBackupTask() { return backupTask; } @Override protected BackupJobs getBackupJobs() { return backupJobs; } @Override protected Preferences getPreferences() { return preferences; } @Override public int checkPermission(String permission, int pid, int uid) { return PERMISSION_GRANTED; } @Override protected AuthPreferences getAuthPreferences() { return authPreferences; } @Override protected void notifyUser(int icon, NotificationCompat.Builder builder) { sentNotifications.add(builder); } }; shadowConnectivityManager = shadowOf(service.getConnectivityManager()); shadowWifiManager = shadowOf(service.getWifiManager()); service.onCreate(); when(authPreferences.getStoreUri()).thenReturn("imap+ssl+://xoauth:foooo@imap.gmail.com:993"); when(authPreferences.isLoginInformationSet()).thenReturn(true); when(preferences.getBackupContactGroup()).thenReturn(ContactGroup.EVERYBODY); when(preferences.isUseOldScheduler()).thenReturn(true); when(preferences.getDataTypePreferences()).thenReturn(dataTypePreferences); when(dataTypePreferences.enabled()).thenReturn(EnumSet.of(DataType.SMS)); }