diff options
author | James Dong <jdong@google.com> | 2012-05-30 20:35:03 -0700 |
---|---|---|
committer | James Dong <jdong@google.com> | 2012-05-30 20:36:12 -0700 |
commit | 7b996d19afcc7030400b515a665d28523a44bb18 (patch) | |
tree | ce9b9a2b7a11d7ac5b0446ca028e0faaef8afd16 /media/tests/MediaFrameworkTest | |
parent | 7f6519691fdd8062a090de74cfc5d2a906f9e5f6 (diff) | |
download | frameworks_base-7b996d19afcc7030400b515a665d28523a44bb18.zip frameworks_base-7b996d19afcc7030400b515a665d28523a44bb18.tar.gz frameworks_base-7b996d19afcc7030400b515a665d28523a44bb18.tar.bz2 |
Fix a test case failure when there is no back-facing camera on a device
Change-Id: I427b2e03b266ff2d92c6fe64f732a256d285020e
related-to-bug: 6538628
Diffstat (limited to 'media/tests/MediaFrameworkTest')
-rw-r--r-- | media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/stress/MediaRecorderStressTest.java | 104 |
1 files changed, 53 insertions, 51 deletions
diff --git a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/stress/MediaRecorderStressTest.java b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/stress/MediaRecorderStressTest.java index 62462bd..6995c60 100644 --- a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/stress/MediaRecorderStressTest.java +++ b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/stress/MediaRecorderStressTest.java @@ -415,59 +415,61 @@ public class MediaRecorderStressTest extends ActivityInstrumentationTestCase2<Me output.write("Total number of loops: " + NUMBER_OF_TIME_LAPSE_LOOPS + "\n"); try { - output.write("No of loop: "); - for (int i = 0; i < NUMBER_OF_TIME_LAPSE_LOOPS; i++) { - filename = OUTPUT_FILE + i + OUTPUT_FILE_EXT; - Log.v(TAG, filename); - runOnLooper(new Runnable() { - @Override - public void run() { - mRecorder = new MediaRecorder(); + for (int j = 0, n = Camera.getNumberOfCameras(); j < n; j++) { + output.write("No of loop: camera " + j); + for (int i = 0; i < NUMBER_OF_TIME_LAPSE_LOOPS; i++) { + filename = OUTPUT_FILE + j + "_" + i + OUTPUT_FILE_EXT; + Log.v(TAG, filename); + runOnLooper(new Runnable() { + @Override + public void run() { + mRecorder = new MediaRecorder(); + } + }); + + // Set callback + mRecorder.setOnErrorListener(mRecorderErrorCallback); + + // Set video source + mRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA); + + // Set camcorder profile for time lapse + CamcorderProfile profile = + CamcorderProfile.get(j, CamcorderProfile.QUALITY_TIME_LAPSE_HIGH); + mRecorder.setProfile(profile); + + // Set the timelapse setting; 0.1 = 10 sec timelapse, 0.5 = 2 sec timelapse, etc. + // http://developer.android.com/guide/topics/media/camera.html#time-lapse-video + mRecorder.setCaptureRate(captureRate); + + // Set output file + mRecorder.setOutputFile(filename); + + // Set the preview display + Log.v(TAG, "mediaRecorder setPreviewDisplay"); + mRecorder.setPreviewDisplay(mSurfaceHolder.getSurface()); + + mRecorder.prepare(); + mRecorder.start(); + Thread.sleep(record_duration); + Log.v(TAG, "Before stop"); + mRecorder.stop(); + mRecorder.release(); + + // Start the playback + MediaPlayer mp = new MediaPlayer(); + mp.setDataSource(filename); + mp.setDisplay(mSurfaceHolder); + mp.prepare(); + mp.start(); + Thread.sleep(TIME_LAPSE_PLAYBACK_WAIT_TIME); + mp.release(); + validateRecordedVideo(filename); + if (remove_video) { + removeRecordedVideo(filename); } - }); - - // Set callback - mRecorder.setOnErrorListener(mRecorderErrorCallback); - - // Set video source - mRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA); - - // Set camcorder profile for time lapse - CamcorderProfile profile = - CamcorderProfile.get(CamcorderProfile.QUALITY_TIME_LAPSE_HIGH); - mRecorder.setProfile(profile); - - // Set the timelapse setting; 0.1 = 10 sec timelapse, 0.5 = 2 sec timelapse, etc. - // http://developer.android.com/guide/topics/media/camera.html#time-lapse-video - mRecorder.setCaptureRate(captureRate); - - // Set output file - mRecorder.setOutputFile(filename); - - // Set the preview display - Log.v(TAG, "mediaRecorder setPreviewDisplay"); - mRecorder.setPreviewDisplay(mSurfaceHolder.getSurface()); - - mRecorder.prepare(); - mRecorder.start(); - Thread.sleep(record_duration); - Log.v(TAG, "Before stop"); - mRecorder.stop(); - mRecorder.release(); - - // Start the playback - MediaPlayer mp = new MediaPlayer(); - mp.setDataSource(filename); - mp.setDisplay(mSurfaceHolder); - mp.prepare(); - mp.start(); - Thread.sleep(TIME_LAPSE_PLAYBACK_WAIT_TIME); - mp.release(); - validateRecordedVideo(filename); - if(remove_video) { - removeRecordedVideo(filename); + output.write(", " + i); } - output.write(", " + i); } } catch (IllegalStateException e) { |