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 long broadcastIdentifier, final BaseVideoViewControllerListener baseVideoViewControllerListener);   }
@Test public void onCreate_shouldCreateAndHideCloseButton() throws Exception { initializeSubject(); subject.onCreate(); ImageButton closeButton = getCloseButton(); assertThat(closeButton).isNotNull(); assertThat(getShadowImageButton(closeButton).getOnClickListener()).isNotNull(); assertThat(closeButton.getVisibility()).isEqualTo(GONE); }
@Test public void closeButton_onClick_shouldCallBaseVideoControllerListenerOnFinish() throws Exception { initializeSubject(); subject.onCreate(); ImageButton closeButton = getCloseButton(); getShadowImageButton(closeButton).getOnClickListener().onClick(null); 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); }
@Test public void onErrorListener_shouldBroadcastInterstitialError() throws Exception { Intent expectedIntent = getIntentForActionAndIdentifier(ACTION_INTERSTITIAL_FAIL, testBroadcastIdentifier); initializeSubject(); subject.onCreate(); assertThat(getShadowVideoView().getOnErrorListener().onError(null, 0, 0)).isEqualTo(false); Robolectric.getUiThreadScheduler().unPause(); verify(broadcastReceiver).onReceive(any(Context.class), eq(expectedIntent)); }