EffectsVideoCapturepublic class EffectsVideoCapture extends android.test.ActivityInstrumentationTestCase2
Fields Summary |
---|
private static final String | TAG | private static final long | WAIT_FOR_PREVIEW |
Constructors Summary |
---|
public EffectsVideoCapture() // 4 seconds
super(CameraEffectsRecordingSample.class);
|
Methods Summary |
---|
private void | captureVideos(java.lang.String reportTag, android.app.Instrumentation inst)
int total_num_of_videos = 1;
int video_duration = 4 * 1000; // 4 seconds
Log.v(TAG, reportTag);
for (int i = 0; i < total_num_of_videos; i++) {
Thread.sleep(WAIT_FOR_PREVIEW);
// record a video
inst.sendCharacterSync(KeyEvent.KEYCODE_CAMERA);
Thread.sleep(video_duration);
inst.sendCharacterSync(KeyEvent.KEYCODE_CAMERA);
}
| public void | testBackEffectsVideoCapture()
Instrumentation inst = getInstrumentation();
Intent intent = new Intent();
intent.setClass(getInstrumentation().getTargetContext(),
CameraEffectsRecordingSample.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.putExtra("OUTPUT_FILENAME", Environment.getExternalStorageDirectory().toString()
+ "/CameraEffectsRecordingTest.mp4");
Activity act = inst.startActivitySync(intent);
captureVideos("Back Camera Video Capture\n", inst);
act.finish();
// Verification
File file = new File(Environment.getExternalStorageDirectory(),
"CameraEffectsRecordingTest.mp4");
Uri uri = Uri.fromFile(file);
verify(getActivity(), uri);
| private void | verify(android.media.filterfw.samples.CameraEffectsRecordingSample activity, android.net.Uri uri)
assertNotNull(uri);
// Verify the video file
MediaMetadataRetriever retriever = new MediaMetadataRetriever();
retriever.setDataSource(activity, uri);
String duration = retriever.extractMetadata(
MediaMetadataRetriever.METADATA_KEY_DURATION);
assertNotNull(duration);
int durationValue = Integer.parseInt(duration);
Log.v(TAG, "Video duration is " + durationValue);
assertTrue(durationValue > 0);
|
|