@Test public void constructor_shouldAddCloseButtonWidgetToLayoutAndSetToGoneWithOnTouchListeners() throws Exception { initializeSubject(); VastVideoCloseButtonWidget closeButtonWidget = subject.getCloseButtonWidget(); assertThat(closeButtonWidget.getParent()).isEqualTo(subject.getLayout()); assertThat(closeButtonWidget.getVisibility()).isEqualTo(View.GONE); ShadowRelativeLayout closeButtonWidgetShadow = (ShadowRelativeLayout) shadowOf(closeButtonWidget); assertThat(closeButtonWidgetShadow.getOnTouchListener()).isNull(); ShadowImageView closeButtonImageViewShadow = shadowOf(closeButtonWidget.getImageView()); assertThat(closeButtonImageViewShadow.getOnTouchListener()).isNotNull(); ShadowTextView closeButtonTextViewShadow = shadowOf(closeButtonWidget.getTextView()); assertThat(closeButtonTextViewShadow.getOnTouchListener()).isNotNull(); }
@Config(reportSdk = VERSION_CODES.GINGERBREAD) @Test public void onPrepared_beforeGingerbreadMr1_shouldNotSetBlurredLastVideoFrame() throws Exception { VastVideoConfiguration vastVideoConfiguration = new VastVideoConfiguration(); vastVideoConfiguration.setDiskMediaFileUrl("disk_video_path"); bundle.putSerializable(VAST_VIDEO_CONFIGURATION, vastVideoConfiguration); initializeSubject(); getShadowVideoView().getOnPreparedListener().onPrepared(null); assertThat(subject.getBlurredLastVideoFrameImageView().getDrawable()).isNull(); ShadowImageView imageView = shadowOf(subject.getBlurredLastVideoFrameImageView()); assertThat(imageView.getOnTouchListener()).isNull(); }
@Config(reportSdk = VERSION_CODES.GINGERBREAD_MR1) @Test public void onPrepared_atLeastGingerbreadMr1_shouldSetBlurredLastVideoFrame() throws Exception { VastVideoConfiguration vastVideoConfiguration = new VastVideoConfiguration(); vastVideoConfiguration.setDiskMediaFileUrl("disk_video_path"); bundle.putSerializable(VAST_VIDEO_CONFIGURATION, vastVideoConfiguration); initializeSubject(); getShadowVideoView().getOnPreparedListener().onPrepared(null); final ImageView blurredLastVideoFrameImageView = subject.getBlurredLastVideoFrameImageView(); assertThat(blurredLastVideoFrameImageView.getDrawable()).isInstanceOf(BitmapDrawable.class); assertThat(((BitmapDrawable) blurredLastVideoFrameImageView.getDrawable()).getBitmap()).isNotNull(); ShadowImageView imageView = shadowOf(subject.getBlurredLastVideoFrameImageView()); assertThat(imageView.getOnTouchListener()).isNull(); }
@Test public void shouldSetPasswordVisibility() { ShadowImageView shadowPwdImageView = shadowOf(loginActivity.ivVisibilityPwd); assertThat(shadowPwdImageView.getImageResourceId()).isEqualTo(R.drawable.ic_visibility_off); assertThat(loginActivity.etPassword.getInputType()).isEqualTo(InputType.TYPE_CLASS_TEXT | EditorInfo.TYPE_TEXT_VARIATION_PASSWORD); loginActivity.ivVisibilityPwd.performClick(); assertThat(shadowPwdImageView.getImageResourceId()).isEqualTo(R.drawable.ic_visibility); assertThat(loginActivity.etPassword.getInputType()).isEqualTo(InputType.TYPE_CLASS_TEXT | EditorInfo.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD); }
@Test public void shouldSetGivenBitmapWhenBlurredBackgroundIsReady() { //given mDialogWithBlurredBackgroundLauncher.showDialog(dialog); Bitmap bitmap = mock(Bitmap.class); //when mDialogWithBlurredBackgroundLauncher.onBlurringFinish(bitmap); //then ImageView blurLayer = (ImageView) exampleActivity.findViewById(R.id.blurLayer); ShadowImageView shadowImageView = Shadows.shadowOf(blurLayer); assertThat(shadowImageView.getImageBitmap()).isEqualTo(bitmap); }
@Test public void constructor_shouldAddCtaButtonWidgetToLayoutAndSetInvisibleWithOnTouchListeners() throws Exception { initializeSubject(); VastVideoCtaButtonWidget ctaButtonWidget = subject.getCtaButtonWidget(); assertThat(ctaButtonWidget.getParent()).isEqualTo(subject.getLayout()); assertThat(ctaButtonWidget.getVisibility()).isEqualTo(View.INVISIBLE); ShadowImageView ctaButtonWidgetShadow = shadowOf(ctaButtonWidget); assertThat(ctaButtonWidgetShadow.getOnTouchListener()).isNotNull(); assertThat(ctaButtonWidgetShadow.getOnTouchListener()).isEqualTo(getShadowVideoView().getOnTouchListener()); }
@Test public void constructor_shouldAddProgressBarWidgetToLayoutAndSetInvisibleWithNoListeners() throws Exception { initializeSubject(); VastVideoProgressBarWidget progressBarWidget = subject.getProgressBarWidget(); assertThat(progressBarWidget.getParent()).isEqualTo(subject.getLayout()); assertThat(progressBarWidget.getVisibility()).isEqualTo(View.INVISIBLE); ShadowImageView progressBarWidgetShadow = shadowOf(progressBarWidget); assertThat(progressBarWidgetShadow.getOnTouchListener()).isNull(); }
@Test public void constructor_shouldAddRadialCountdownWidgetToLayoutAndSetInvisibleWithNoListeners() throws Exception { initializeSubject(); VastVideoRadialCountdownWidget radialCountdownWidget = subject.getRadialCountdownWidget(); assertThat(radialCountdownWidget.getParent()).isEqualTo(subject.getLayout()); assertThat(radialCountdownWidget.getVisibility()).isEqualTo(View.INVISIBLE); ShadowImageView radialCountdownWidgetShadow = shadowOf(radialCountdownWidget); assertThat(radialCountdownWidgetShadow.getOnTouchListener()).isNull(); }
@Test public void constructor_shouldAddTopGradientWidgetToLayoutAndSetVisibleWithNoListeners() throws Exception { initializeSubject(); VastVideoGradientStripWidget topGradientStripWidget = subject.getTopGradientStripWidget(); assertThat(topGradientStripWidget.getParent()).isEqualTo(subject.getLayout()); assertThat(topGradientStripWidget.getVisibility()).isEqualTo(View.VISIBLE); ShadowImageView topGradientStripWidgetShadow = shadowOf(topGradientStripWidget); assertThat(topGradientStripWidgetShadow.getOnTouchListener()).isNull(); }
@Test public void constructor_shouldAddBottomGradientWidgetToLayoutAndSetVisibleWithNoListeners() throws Exception { initializeSubject(); VastVideoGradientStripWidget bottomGradientStripWidget = subject.getBottomGradientStripWidget(); assertThat(bottomGradientStripWidget.getParent()).isEqualTo(subject.getLayout()); assertThat(bottomGradientStripWidget.getVisibility()).isEqualTo(View.VISIBLE); ShadowImageView bottomGradientStripWidgetShadow = shadowOf(bottomGradientStripWidget); assertThat(bottomGradientStripWidgetShadow.getOnTouchListener()).isNull(); }
@Test public void constructor_shouldAddBlurredLastVideoFrameWidgetToLayoutAndSetInvisibleWithNoListeners() throws Exception { initializeSubject(); ImageView blurredLastVideoFrameImageView = subject.getBlurredLastVideoFrameImageView(); assertThat(blurredLastVideoFrameImageView.getParent()).isEqualTo(subject.getLayout()); assertThat(blurredLastVideoFrameImageView.getVisibility()).isEqualTo(View.INVISIBLE); ShadowImageView blurredLastVideoFrameImageViewShadow = shadowOf(blurredLastVideoFrameImageView); assertThat(blurredLastVideoFrameImageViewShadow.getOnTouchListener()).isNull(); }
public static ShadowImageView shadowOf(ImageView instance) { return (ShadowImageView) shadowOf_(instance); }