VastVideoViewController extends BaseVideoViewController implements DownloadTask.DownloadTaskListener { @Override protected void onCreate() { super.onCreate(); switch (mVastVideoConfiguration.getCustomForceOrientation()) { case FORCE_PORTRAIT: getBaseVideoViewControllerListener().onSetRequestedOrientation(SCREEN_ORIENTATION_PORTRAIT); break; case FORCE_LANDSCAPE: getBaseVideoViewControllerListener().onSetRequestedOrientation(SCREEN_ORIENTATION_LANDSCAPE); break; case DEVICE_ORIENTATION: break; case UNDEFINED: break; default: break; } downloadCompanionAd(); makeTrackingHttpRequest( mVastVideoConfiguration.getImpressionTrackers(), getContext(), BaseEvent.Name.IMPRESSION_REQUEST ); broadcastAction(ACTION_INTERSTITIAL_SHOW); } VastVideoViewController(final Context context,
            final Bundle bundle,
            final long broadcastIdentifier,
            final BaseVideoViewControllerListener baseVideoViewControllerListener); @Override boolean backButtonEnabled(); @Override void onComplete(String url, DownloadResponse downloadResponse);  }
@Test public void onCreate_shouldFireImpressionTracker() throws Exception { initializeSubject(); subject.onCreate(); verify(mockRequestQueue).add(argThat(isUrl("imp"))); }
@Test public void onCreate_shouldBroadcastInterstitialShow() throws Exception { Intent expectedIntent = getIntentForActionAndIdentifier(ACTION_INTERSTITIAL_SHOW, testBroadcastIdentifier); initializeSubject(); Robolectric.getUiThreadScheduler().unPause(); subject.onCreate(); verify(broadcastReceiver).onReceive(any(Context.class), eq(expectedIntent)); }
@Test public void onCreate_whenCustomForceOrientationNotSpecified_shouldForceLandscapeOrientation() throws Exception { VastVideoConfiguration vastVideoConfiguration = new VastVideoConfiguration(); vastVideoConfiguration.setDiskMediaFileUrl("disk_video_path"); bundle.putSerializable(VAST_VIDEO_CONFIGURATION, vastVideoConfiguration); initializeSubject(); subject.onCreate(); verify(baseVideoViewControllerListener).onSetRequestedOrientation(SCREEN_ORIENTATION_LANDSCAPE); }
@Test public void onCreate_whenCustomForceOrientationIsDeviceOrientation_shouldNotForceLandscapeOrientation() throws Exception { VastVideoConfiguration vastVideoConfiguration = new VastVideoConfiguration(); vastVideoConfiguration.setDiskMediaFileUrl("disk_video_path"); vastVideoConfiguration.setCustomForceOrientation(ForceOrientation.DEVICE_ORIENTATION); bundle.putSerializable(VAST_VIDEO_CONFIGURATION, vastVideoConfiguration); initializeSubject(); subject.onCreate(); verify(baseVideoViewControllerListener, never()).onSetRequestedOrientation(anyInt()); }
@Test public void onCreate_whenCustomForceOrientationIsPortraitOrientation_shouldForcePortraitOrientation() throws Exception { VastVideoConfiguration vastVideoConfiguration = new VastVideoConfiguration(); vastVideoConfiguration.setDiskMediaFileUrl("disk_video_path"); vastVideoConfiguration.setCustomForceOrientation(ForceOrientation.FORCE_PORTRAIT); bundle.putSerializable(VAST_VIDEO_CONFIGURATION, vastVideoConfiguration); initializeSubject(); subject.onCreate(); verify(baseVideoViewControllerListener).onSetRequestedOrientation(SCREEN_ORIENTATION_PORTRAIT); }
@Test public void onCreate_whenCustomForceOrientationIsLandscapeOrientation_shouldForceLandscapeOrientation() throws Exception { VastVideoConfiguration vastVideoConfiguration = new VastVideoConfiguration(); vastVideoConfiguration.setDiskMediaFileUrl("disk_video_path"); vastVideoConfiguration.setCustomForceOrientation(ForceOrientation.FORCE_LANDSCAPE); bundle.putSerializable(VAST_VIDEO_CONFIGURATION, vastVideoConfiguration); initializeSubject(); subject.onCreate(); verify(baseVideoViewControllerListener).onSetRequestedOrientation(SCREEN_ORIENTATION_LANDSCAPE); }