@Test
public void dataTransfer_withRemoteSource_isReported() throws IOException {

  TestSource testSource = new TestSource(/* isNetwork= */ true);
  TestTransferListener transferListener = new TestTransferListener();
  testSource.addTransferListener(transferListener);
  DataSpec dataSpec = new DataSpec(Uri.EMPTY);
  testSource.open(dataSpec);
  testSource.read(/* buffer= */ null, /* offset= */ 0, /* readLength= */ 100);
  testSource.close();
  assertThat(transferListener.lastTransferInitializingSource).isSameInstanceAs(testSource);
  assertThat(transferListener.lastTransferStartSource).isSameInstanceAs(testSource);
  assertThat(transferListener.lastBytesTransferredSource).isSameInstanceAs(testSource);
  assertThat(transferListener.lastTransferEndSource).isSameInstanceAs(testSource);
  assertThat(transferListener.lastTransferInitializingDataSpec).isEqualTo(dataSpec);
  assertThat(transferListener.lastTransferStartDataSpec).isEqualTo(dataSpec);
  assertThat(transferListener.lastBytesTransferredDataSpec).isEqualTo(dataSpec);
  assertThat(transferListener.lastTransferEndDataSpec).isEqualTo(dataSpec);
  assertThat(transferListener.lastTransferInitializingIsNetwork).isEqualTo(true);
  assertThat(transferListener.lastTransferStartIsNetwork).isEqualTo(true);
  assertThat(transferListener.lastBytesTransferredIsNetwork).isEqualTo(true);
  assertThat(transferListener.lastTransferEndIsNetwork).isEqualTo(true);
  assertThat(transferListener.lastBytesTransferred).isEqualTo(100);
}