ScreenShooter { public Bitmap createScreenShot(View view) { return createViewScreenshot(view, false); }  Bitmap createScreenShot(View view); Bitmap createScreenShot(Activity activity);  }
@Test public void shouldCreateScaledScreenShotOfActivityWithoutStatusBar() { ScrenShootedActivityShadow screnShootedActivityShadow = (ScrenShootedActivityShadow) shadowOf(activityToTestScreenshoot); int scaledWindowHeight = (int) (screnShootedActivityShadow.WINDOW_HEIGHT * FoggerConfig.getScreenshotScale()); int scaledWindowWidth = (int) (screnShootedActivityShadow.WINDOW_WIDTH * FoggerConfig.getScreenshotScale()); int scaledStatusBarHeight = extractScaledStatusBarScaledHeight(); Bitmap screenShot = screenShooter.createScreenShot(activityToTestScreenshoot); assertThat(screenShot.getHeight()).isEqualTo(scaledWindowHeight - scaledStatusBarHeight); assertThat(screenShot.getWidth()).isEqualTo(scaledWindowWidth); }
@Test public void shouldCreateScaledScreenshotOfView() { int viewHeight = 400; int viewWidth = 75; int scaledWindowHeight = (int) (viewHeight * FoggerConfig.getScreenshotScale()); int scaledWindowWidth = (int) (viewWidth * FoggerConfig.getScreenshotScale()); View view = createView(viewHeight, viewWidth); Bitmap screenShot = screenShooter.createScreenShot(view); assertThat(screenShot.getHeight()).isEqualTo(scaledWindowHeight); assertThat(screenShot.getWidth()).isEqualTo(scaledWindowWidth); }