### Question:
VideoView2 extends BaseLayout { @RestrictTo(LIBRARY_GROUP) public void setVideoPath(String path) { mImpl.setVideoUri(Uri.parse(path)); } VideoView2(@NonNull Context context);  VideoView2(@NonNull Context context, @Nullable AttributeSet attrs);  VideoView2(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr); void setMediaControlView2(MediaControlView2 mediaControlView, long intervalMs); MediaControlView2 getMediaControlView2(); @RestrictTo(LIBRARY_GROUP) void setMediaMetadata(MediaMetadata2 metadata); @RestrictTo(LIBRARY_GROUP) MediaMetadata2 getMediaMetadata(); @RestrictTo(LIBRARY_GROUP) MediaControllerCompat getMediaController(); @RestrictTo(LIBRARY_GROUP) SessionToken2 getMediaSessionToken(); void setSubtitleEnabled(boolean enable); boolean isSubtitleEnabled(); void setSpeed(float speed); float getSpeed(); void setAudioFocusRequest(int focusGain); void setAudioAttributes(@NonNull AudioAttributes attributes); @RestrictTo(LIBRARY_GROUP) void setAudioAttributes(@NonNull AudioAttributesCompat attributes); @RestrictTo(LIBRARY_GROUP) void setVideoPath(String path); @RestrictTo(LIBRARY_GROUP) void setVideoUri(Uri uri); void setVideoUri(Uri uri, @Nullable Map<String, String> headers); @RestrictTo(LIBRARY_GROUP) void setMediaItem(@NonNull MediaItem2 mediaItem); @RestrictTo(LIBRARY_GROUP) void setDataSource(@NonNull DataSourceDesc dataSource); void setViewType(@ViewType int viewType); @ViewType int getViewType(); @RestrictTo(LIBRARY_GROUP) void setCustomActions(List<PlaybackStateCompat.CustomAction> actionList,
            Executor executor, OnCustomActionListener listener); @VisibleForTesting @RestrictTo(LIBRARY_GROUP) void setOnViewTypeChangedListener(OnViewTypeChangedListener l); @Override void onAttachedToWindow(); @Override void onDetachedFromWindow(); @Override CharSequence getAccessibilityClassName(); @Override boolean onTouchEvent(MotionEvent ev); @Override boolean onTrackballEvent(MotionEvent ev); @Override boolean dispatchTouchEvent(MotionEvent ev); @Override void onMeasure(int widthMeasureSpec, int heightMeasureSpec); static final int VIEW_TYPE_SURFACEVIEW; static final int VIEW_TYPE_TEXTUREVIEW; }### Answer:
@Test public void testPlayVideo() throws Throwable { if (!hasCodec()) { Log.i(TAG, "SKIPPING testPlayVideo(): codec is not supported"); return; } final MediaControllerCompat.Callback mockControllerCallback = mock(MediaControllerCompat.Callback.class); final MediaControllerCompat.Callback callbackHelper = new MediaControllerCompat.Callback() { @Override public void onPlaybackStateChanged(PlaybackStateCompat state) { mockControllerCallback.onPlaybackStateChanged(state); } }; mActivityRule.runOnUiThread(new Runnable() { @Override public void run() { mController.registerCallback(callbackHelper); mVideoView.setVideoPath(mVideoPath); mController.getTransportControls().play(); } }); ArgumentCaptor<PlaybackStateCompat> someState = ArgumentCaptor.forClass(PlaybackStateCompat.class); verify(mockControllerCallback, timeout(TIME_OUT).atLeast(3)).onPlaybackStateChanged( someState.capture()); List<PlaybackStateCompat> states = someState.getAllValues(); assertEquals(PlaybackStateCompat.STATE_PAUSED, states.get(0).getState()); assertEquals(PlaybackStateCompat.STATE_PLAYING, states.get(1).getState()); assertEquals(PlaybackStateCompat.STATE_STOPPED, states.get(2).getState()); }