LoggingMediaHttpUploaderProgressListener implements MediaHttpUploaderProgressListener { @Override public void progressChanged(MediaHttpUploader uploader) throws IOException { progressChanged( uploader.getUploadState(), uploader.getNumBytesUploaded(), System.currentTimeMillis()); } LoggingMediaHttpUploaderProgressListener(String name, long minLoggingInterval); @Override void progressChanged(MediaHttpUploader uploader);  }
@Test public void testLoggingInitiation() { listener.progressChanged(UploadState.INITIATION_STARTED, 0L, 0L); assertThat(getTestCapturedLog()).isEqualTo("FINE: Uploading: NAME"); }
@Test public void testLoggingProgressAfterSixtySeconds() { listener.progressChanged(UploadState.MEDIA_IN_PROGRESS, 10485760L, 60001L); assertThat(getTestCapturedLog()) .isEqualTo( "FINE: Uploading:" + " NAME Average Rate: 0.167 MiB/s, Current Rate: 0.167 MiB/s, Total: 10.000 MiB"); listener.progressChanged(UploadState.MEDIA_IN_PROGRESS, 104857600L, 120002L); assertThat(getTestCapturedLog()) .isEqualTo( "FINE: Uploading:" + " NAME Average Rate: 0.833 MiB/s, Current Rate: 1.500 MiB/s, Total: 100.000 MiB"); }
@Test public void testSkippingLoggingAnInProgressUpdate() { listener.progressChanged(UploadState.MEDIA_IN_PROGRESS, 104857600L, 60000L); assertThat(getTestCapturedLog()).isEmpty(); }
@Test public void testLoggingCompletion() { listener.progressChanged(UploadState.MEDIA_COMPLETE, 104857600L, 60000L); assertThat(getTestCapturedLog()).isEqualTo("FINE: Finished Uploading: NAME"); }
@Test public void testOtherUpdatesIgnored() { listener.progressChanged(UploadState.NOT_STARTED, 0L, 60001L); listener.progressChanged(UploadState.INITIATION_COMPLETE, 0L, 60001L); assertThat(getTestCapturedLog()).isEmpty(); }