VastVideoToolbar extends LinearLayout { void updateDurationWidget(final int remainingTime) { if (remainingTime >= THRESHOLD_FOR_HIDING_VIDEO_DURATION) { mDurationWidget.updateText("Ends in " + getDisplaySeconds(remainingTime) + " seconds"); } else if (remainingTime >= 0) { mDurationWidget.updateText("Thanks for watching"); } } VastVideoToolbar(final Context context);   }
@Test public void updateDurationWidget_shouldShowWhenVideoEnds() throws Exception { final TextView durationWidgetTextView = getDurationWidgetTextView(); assertThat(durationWidgetTextView.getText()).isEqualTo(""); subject.updateDurationWidget(100000); assertThat(durationWidgetTextView.getText()).isEqualTo("Ends in 100 seconds"); subject.updateDurationWidget(99000); assertThat(durationWidgetTextView.getText()).isEqualTo("Ends in 99 seconds"); }
@Test public void updateDurationWidget_whenBelowThresholdForHidingVideoDuration_shouldShowThanksForWatching() throws Exception { final TextView durationWidgetTextView = getDurationWidgetTextView(); assertThat(durationWidgetTextView.getText()).isEqualTo(""); subject.updateDurationWidget(50000); assertThat(durationWidgetTextView.getText()).isEqualTo("Ends in 50 seconds"); subject.updateDurationWidget(200); assertThat(durationWidgetTextView.getText()).isEqualTo("Ends in 1 seconds"); subject.updateDurationWidget(199); assertThat(durationWidgetTextView.getText()).isEqualTo("Thanks for watching"); }
@Test public void updateDurationWidget_whenRemainingTimeIsNegative_shouldDoNothing() throws Exception { final TextView durationWidgetTextView = getDurationWidgetTextView(); assertThat(durationWidgetTextView.getText()).isEqualTo(""); subject.updateDurationWidget(-1); assertThat(durationWidgetTextView.getText()).isEqualTo(""); }