LocalBroadcaster implements DownloadListener { public void onDownloadProgress(String torrentFile, int progress) { broadcast(DownloadProgressBroadcast.createProgressIntent(torrentFile, progress)); } LocalBroadcaster(Context context); void onDownloadStart(String torrentFile); void onDownloadProgress(String torrentFile, int progress); void onDownloadEnd(String torrentFile, int downloadState);  }
@Test public void testOnDownloadProgress() { final String torrentFile = "file"; final int progress = 42; LocalBroadcaster localBroadcaster = new LocalBroadcaster(RuntimeEnvironment.application); localBroadcaster.onDownloadProgress(torrentFile, progress); LocalBroadcastManager localBroadcastManager = LocalBroadcastManager.getInstance(RuntimeEnvironment.application); ShadowLocalBroadcastManager shadowLocalBroadcastManager = Shadows.shadowOf(localBroadcastManager); List<Intent> broadcastIntents = shadowLocalBroadcastManager.getSentBroadcastIntents(); assertThat(broadcastIntents.size()).isEqualTo(1); Intent referenceBroadcast = new DownloadProgressBroadcast() .setTorrentFile(torrentFile) .setProgress(progress) .createIntent(); assertThat(broadcastIntents.get(0).equals(referenceBroadcast)).isTrue(); }