Source:
<code>public void testVideoSurfaceResetting() throws Exception { final int tolerance = 150; final int audioLatencyTolerance = 1000; final int seekPos = 4760; final CountDownLatch seekDone = new CountDownLatch(1); MediaPlayer2.EventCallback ecb = new MediaPlayer2.EventCallback() { @Override public void onCallCompleted( MediaPlayer2 mp, MediaItem2 item, int what, int status) { if (what == MediaPlayer2.CALL_COMPLETED_SEEK_TO) { seekDone.countDown(); } } }; synchronized (mEventCbLock) { mEventCallbacks.add(ecb); } if <START> (!checkLoadResource(R.raw.testvideoh264)) <END> { return; } playLoadedVideo(352, 288, -1); Thread.sleep(SLEEP_TIME); long posBefore = mPlayer.getCurrentPosition(); mPlayer.setSurface(mActivity.getSurfaceHolder2().getSurface()); long posAfter = mPlayer.getCurrentPosition(); assertTrue(mPlayer.getState() == MediaPlayer2.PLAYER_STATE_PLAYING); Thread.sleep(SLEEP_TIME); mPlayer.seekTo(seekPos, MediaPlayer2.SEEK_PREVIOUS_SYNC); seekDone.await(); posAfter = mPlayer.getCurrentPosition(); assertEquals(seekPos, posAfter, tolerance + audioLatencyTolerance); Thread.sleep(SLEEP_TIME / 2); posBefore = mPlayer.getCurrentPosition(); mPlayer.setSurface(null); posAfter = mPlayer.getCurrentPosition(); assertTrue(mPlayer.getState() == MediaPlayer2.PLAYER_STATE_PLAYING); Thread.sleep(SLEEP_TIME); posBefore = mPlayer.getCurrentPosition(); mPlayer.setSurface(mActivity.getSurfaceHolder().getSurface()); posAfter = mPlayer.getCurrentPosition(); assertTrue(mPlayer.getState() == MediaPlayer2.PLAYER_STATE_PLAYING); Thread.sleep(SLEEP_TIME); }</code><technical_language>existing test video files res/raw CTS. existing one? e.g. video_480x360_mp4_h264_1000kbps_25fps_aac_stereo_128kbps_44100hz.mp4</technical_language>

Target:
public void testVideoSurfaceResetting() throws Exception { final int tolerance = 150; final int audioLatencyTolerance = 1000; final int seekPos = 1840; final CountDownLatch seekDone = new CountDownLatch(1); MediaPlayer2.EventCallback ecb = new MediaPlayer2.EventCallback() { @Override public void onCallCompleted( MediaPlayer2 mp, MediaItem2 item, int what, int status) { if (what == MediaPlayer2.CALL_COMPLETED_SEEK_TO) { seekDone.countDown(); } } }; synchronized (mEventCbLock) { mEventCallbacks.add(ecb); } if (!checkLoadResource( R.raw.video_480x360_mp4_h264_500kbps_25fps_aac_stereo_128kbps_44100hz)) { return; } playLoadedVideo(480, 360, -1); Thread.sleep(SLEEP_TIME); long posBefore = mPlayer.getCurrentPosition(); mPlayer.setSurface(mActivity.getSurfaceHolder2().getSurface()); long posAfter = mPlayer.getCurrentPosition(); assertTrue(mPlayer.getState() == MediaPlayer2.PLAYER_STATE_PLAYING); Thread.sleep(SLEEP_TIME); mPlayer.seekTo(seekPos, MediaPlayer2.SEEK_PREVIOUS_SYNC); seekDone.await(); posAfter = mPlayer.getCurrentPosition(); assertEquals(seekPos, posAfter, tolerance + audioLatencyTolerance); Thread.sleep(SLEEP_TIME / 2); posBefore = mPlayer.getCurrentPosition(); mPlayer.setSurface(null); posAfter = mPlayer.getCurrentPosition(); assertTrue(mPlayer.getState() == MediaPlayer2.PLAYER_STATE_PLAYING); Thread.sleep(SLEEP_TIME); posBefore = mPlayer.getCurrentPosition(); mPlayer.setSurface(mActivity.getSurfaceHolder().getSurface()); posAfter = mPlayer.getCurrentPosition(); assertTrue(mPlayer.getState() == MediaPlayer2.PLAYER_STATE_PLAYING); Thread.sleep(SLEEP_TIME); }