@Test public void testNotification() throws IOException { Call<HackerNewsItem> call = mock(Call.class); when(call.execute()).thenReturn(Response.success(new TestHnItem(1L) { @Override public boolean isStoryType() { return true; } @Override public String getRawUrl() { return "http: } @Override public long[] getKids() { return new long[]{2L, 3L}; } })); when(TestRestServiceFactory.hnRestService.cachedItem(eq("1"))).thenReturn(call); Call<HackerNewsItem> kid1Call = mock(Call.class); when(kid1Call.execute()).thenReturn(Response.success(new TestHnItem(2L) { @Override public boolean isStoryType() { return false; } })); when(TestRestServiceFactory.hnRestService.cachedItem(eq("2"))).thenReturn(kid1Call); Call<HackerNewsItem> kid2Call = mock(Call.class); when(kid2Call.execute()).thenThrow(IOException.class); when(TestRestServiceFactory.hnRestService.cachedItem(eq("3"))).thenReturn(kid2Call); when(TestRestServiceFactory.hnRestService.networkItem(eq("3"))).thenReturn(kid2Call); PreferenceManager.getDefaultSharedPreferences(service) .edit() .putBoolean(service.getString(R.string.pref_offline_notification), true) .apply(); syncScheduler.scheduleSync(service, "1"); adapter.onPerformSync(mock(Account.class), getLastSyncExtras(), null, null, null); verify(readabilityClient).parse(any(), eq("http: readabilityCallbackCaptor.capture()); readabilityCallbackCaptor.getValue().onResponse(""); ShadowNotificationManager notificationManager = shadowOf((NotificationManager) service .getSystemService(Context.NOTIFICATION_SERVICE)); ShadowNotification shadowNotification = shadowOf(notificationManager.getNotification(1)); assertThat(shadowNotification.getProgress()).isEqualTo(3); assertThat(shadowNotification.getMax()).isEqualTo(104); shadowOf(adapter.syncDelegate.mWebView).getWebChromeClient() .onProgressChanged(adapter.syncDelegate.mWebView, 100); verify(kid2Call).enqueue(callbackCapture.capture()); callbackCapture.getValue().onFailure(null, null); assertThat(notificationManager.getAllNotifications()).isEmpty(); }
@Override public void onPerformSync(Account account, Bundle extras, String authority, ContentProviderClient provider, SyncResult syncResult) { createSyncDelegate().performSync(new SyncDelegate.Job(extras)); }
ItemSyncAdapter extends AbstractThreadedSyncAdapter { @Override public void onPerformSync(Account account, Bundle extras, String authority, ContentProviderClient provider, SyncResult syncResult) { createSyncDelegate().performSync(new SyncDelegate.Job(extras)); } }
ItemSyncAdapter extends AbstractThreadedSyncAdapter { @Override public void onPerformSync(Account account, Bundle extras, String authority, ContentProviderClient provider, SyncResult syncResult) { createSyncDelegate().performSync(new SyncDelegate.Job(extras)); } ItemSyncAdapter(Context context, RestServiceFactory factory,
                           ReadabilityClient readabilityClient); }
ItemSyncAdapter extends AbstractThreadedSyncAdapter { @Override public void onPerformSync(Account account, Bundle extras, String authority, ContentProviderClient provider, SyncResult syncResult) { createSyncDelegate().performSync(new SyncDelegate.Job(extras)); } ItemSyncAdapter(Context context, RestServiceFactory factory,
                           ReadabilityClient readabilityClient); @Override void onPerformSync(Account account, Bundle extras, String authority,
                              ContentProviderClient provider, SyncResult syncResult); }
ItemSyncAdapter extends AbstractThreadedSyncAdapter { @Override public void onPerformSync(Account account, Bundle extras, String authority, ContentProviderClient provider, SyncResult syncResult) { createSyncDelegate().performSync(new SyncDelegate.Job(extras)); } ItemSyncAdapter(Context context, RestServiceFactory factory,
                           ReadabilityClient readabilityClient); @Override void onPerformSync(Account account, Bundle extras, String authority,
                              ContentProviderClient provider, SyncResult syncResult);  }