MraidVideoViewController extends BaseVideoViewController { @Override protected void onCreate() { super.onCreate(); mButtonSize = Dips.asIntPixels(CLOSE_BUTTON_SIZE, getContext()); mButtonPadding = Dips.asIntPixels(CLOSE_BUTTON_PADDING, getContext()); createInterstitialCloseButton(); mCloseButton.setVisibility(GONE); mVideoView.start(); } MraidVideoViewController(final Context context, final Bundle bundle, final BaseVideoViewControllerListener baseVideoViewControllerListener);   }
@Test public void onCreate_shouldCreateAndHideCloseButton() throws Exception { initializeSubject(); subject.onCreate(); ImageButton closeButton = getCloseButton(); assertThat(closeButton).isNotNull(); assertThat(shadowOf(closeButton).getOnClickListener()).isNotNull(); assertThat(closeButton.getVisibility()).isEqualTo(GONE); }
@Test public void closeButton_onClick_shouldCallBaseVideoControllerListenerOnFinish() throws Exception { initializeSubject(); subject.onCreate(); getCloseButton().performClick(); verify(baseVideoViewControllerListener).onFinish(); }
@Test public void onCompletionListener_shouldCallBaseVideoViewControllerListenerOnFinish() throws Exception { initializeSubject(); subject.onCreate(); getShadowVideoView().getOnCompletionListener().onCompletion(null); verify(baseVideoViewControllerListener).onFinish(); }
@Test public void onCompletionListener_shouldShowCloseButton() throws Exception { initializeSubject(); subject.onCreate(); getShadowVideoView().getOnCompletionListener().onCompletion(null); assertThat(getCloseButton().getVisibility()).isEqualTo(VISIBLE); }
@Test public void onErrorListener_shouldReturnFalseAndNotCallBaseVideoControllerListenerOnFinish() throws Exception { initializeSubject(); subject.onCreate(); assertThat(getShadowVideoView().getOnErrorListener().onError(null, 0, 0)).isEqualTo(false); verify(baseVideoViewControllerListener, never()).onFinish(); }
@Test public void onErrorListener_shouldShowCloseButton() throws Exception { initializeSubject(); subject.onCreate(); assertThat(getShadowVideoView().getOnErrorListener().onError(null, 0, 0)).isEqualTo(false); assertThat(getCloseButton().getVisibility()).isEqualTo(VISIBLE); }