### Question:
IllustrationVideoView extends TextureView implements Animatable,
        SurfaceTextureListener,
        OnPreparedListener,
        OnSeekCompleteListener,
        OnInfoListener,
        OnErrorListener { @Override public void start() { if (prepared && mMediaPlayer != null && !mMediaPlayer.isPlaying()) { mMediaPlayer.start(); } } IllustrationVideoView(Context context, AttributeSet attrs); void setVideoResource(@RawRes int videoResId, String videoResPackageName); void setVideoResource(@RawRes int resId); @Override void onWindowFocusChanged(boolean hasWindowFocus); void release(); @Override void onSurfaceTextureAvailable(SurfaceTexture surfaceTexture, int width, int height); @Override void onSurfaceTextureSizeChanged(SurfaceTexture surfaceTexture, int width, int height); @Override boolean onSurfaceTextureDestroyed(SurfaceTexture surfaceTexture); @Override void onSurfaceTextureUpdated(SurfaceTexture surfaceTexture); @Override void start(); @Override void stop(); @Override boolean isRunning(); @Override boolean onInfo(MediaPlayer mp, int what, int extra); @Override void onPrepared(MediaPlayer mp); @Override void onSeekComplete(MediaPlayer mp); int getCurrentPosition(); @Override boolean onError(MediaPlayer mediaPlayer, int what, int extra);  }### Answer:
@Test public void prepareVideo_shouldSetAspectRatio() { createDefaultView(); ReflectionHelpers.setField(getShadowMediaPlayer(), "videoWidth", 720); ReflectionHelpers.setField(getShadowMediaPlayer(), "videoHeight", 1280); Robolectric.flushForegroundThreadScheduler(); view.start(); view.measure( View.MeasureSpec.makeMeasureSpec(720, View.MeasureSpec.EXACTLY), View.MeasureSpec.makeMeasureSpec(720, View.MeasureSpec.EXACTLY)); final float aspectRatio = (float) view.getMeasuredHeight() / view.getMeasuredWidth(); assertThat(aspectRatio).isWithin(0.001f).of(1280f / 720f); }
@Test public void prepareVideo_zeroHeight_shouldSetAspectRatioToZero() { createDefaultView(); ReflectionHelpers.setField(getShadowMediaPlayer(), "videoWidth", 720); ReflectionHelpers.setField(getShadowMediaPlayer(), "videoHeight", 0); Robolectric.flushForegroundThreadScheduler(); view.start(); final float aspectRatio = (float) view.getHeight() / view.getWidth(); assertThat(aspectRatio).isEqualTo(0.0f); }