FileDocCategorySizeDatePackage
EffectsVideoCapture.javaAPI DocAndroid 5.1 API3566Thu Mar 12 22:22:30 GMT 2015android.camera.mediaeffects.tests.functional

EffectsVideoCapture

public 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 voidcaptureVideos(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 voidtestBackEffectsVideoCapture()

        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 voidverify(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);