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