Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 74596aaa authored by Yu Shan Emily Lau's avatar Yu Shan Emily Lau Committed by Android (Google) Code Review
Browse files

Merge "Add the checking for the camcorder profile." into klp-dev

parents 9f78d309 c8d07567
Loading
Loading
Loading
Loading
+55 −43
Original line number Diff line number Diff line
@@ -86,9 +86,9 @@ public class MediaPlayerPerformance extends ActivityInstrumentationTestCase2<Med
    private Writer mProcMemWriter;
    private Writer mMemWriter;

    private CamcorderProfile mCamcorderProfile = CamcorderProfile.get(CAMERA_ID);
    private int mVideoWidth = mCamcorderProfile.videoFrameWidth;
    private int mVideoHeight = mCamcorderProfile.videoFrameHeight;
    private CamcorderProfile mCamcorderProfile;
    private int mVideoWidth;
    private int mVideoHeight;

    Camera mCamera;

@@ -99,6 +99,12 @@ public class MediaPlayerPerformance extends ActivityInstrumentationTestCase2<Med
    @Override
    protected void setUp() throws Exception {
        super.setUp();
        //Check if the device support the camcorder
        CamcorderProfile mCamcorderProfile = CamcorderProfile.get(CAMERA_ID);
        if (mCamcorderProfile != null) {
            mVideoWidth = mCamcorderProfile.videoFrameWidth;
            mVideoHeight = mCamcorderProfile.videoFrameHeight;
        }
        //Insert a 2 second before launching the test activity. This is
        //the workaround for the race condition of requesting the updated surface.
        Thread.sleep(2000);
@@ -332,7 +338,7 @@ public class MediaPlayerPerformance extends ActivityInstrumentationTestCase2<Med
        // USER     PID   PPID  VSIZE  RSS     WCHAN    PC         NAME
        // media     131   1     13676  4796  ffffffff 400b1bd0 S media.log
        // media     219   131   37768  6892  ffffffff 400b236c S /system/bin/mediaserver
        String memusage = poList[2].concat("\n");
        String memusage = poList[poList.length-1].concat("\n");
        return memusage;
    }

@@ -410,9 +416,11 @@ public class MediaPlayerPerformance extends ActivityInstrumentationTestCase2<Med
    // Test case 4: Capture the memory usage after every 20 video only recorded
    @LargeTest
    public void testH263RecordVideoOnlyMemoryUsage() throws Exception {
        if (mCamcorderProfile != null) {
            boolean memoryResult = false;
            mStartPid = getMediaserverPid();
        int frameRate = MediaProfileReader.getMaxFrameRateForCodec(MediaRecorder.VideoEncoder.H263);
            int frameRate = MediaProfileReader
                    .getMaxFrameRateForCodec(MediaRecorder.VideoEncoder.H263);
            assertTrue("H263 video recording frame rate", frameRate != -1);
            for (int i = 0; i < NUM_STRESS_LOOP; i++) {
                assertTrue(stressVideoRecord(frameRate, mVideoWidth, mVideoHeight,
@@ -424,12 +432,13 @@ public class MediaPlayerPerformance extends ActivityInstrumentationTestCase2<Med
            memoryResult = validateMemoryResult(mStartPid, mStartMemory, ENCODER_LIMIT);
            assertTrue("H263 record only memory test", memoryResult);
        }
    }

    // Test case 5: Capture the memory usage after every 20 video only recorded
    @LargeTest
    public void testMpeg4RecordVideoOnlyMemoryUsage() throws Exception {
        if (mCamcorderProfile != null) {
            boolean memoryResult = false;

            mStartPid = getMediaserverPid();
            int frameRate = MediaProfileReader.getMaxFrameRateForCodec
                    (MediaRecorder.VideoEncoder.MPEG_4_SP);
@@ -444,15 +453,17 @@ public class MediaPlayerPerformance extends ActivityInstrumentationTestCase2<Med
            memoryResult = validateMemoryResult(mStartPid, mStartMemory, ENCODER_LIMIT);
            assertTrue("mpeg4 record only memory test", memoryResult);
        }
    }

    // Test case 6: Capture the memory usage after every 20 video and audio
    // recorded
    @LargeTest
    public void testRecordVideoAudioMemoryUsage() throws Exception {
        if (mCamcorderProfile != null) {
            boolean memoryResult = false;

            mStartPid = getMediaserverPid();
        int frameRate = MediaProfileReader.getMaxFrameRateForCodec(MediaRecorder.VideoEncoder.H263);
            int frameRate = MediaProfileReader
                    .getMaxFrameRateForCodec(MediaRecorder.VideoEncoder.H263);
            assertTrue("H263 video recording frame rate", frameRate != -1);
            for (int i = 0; i < NUM_STRESS_LOOP; i++) {
                assertTrue(stressVideoRecord(frameRate, mVideoWidth, mVideoHeight,
@@ -464,6 +475,7 @@ public class MediaPlayerPerformance extends ActivityInstrumentationTestCase2<Med
            memoryResult = validateMemoryResult(mStartPid, mStartMemory, ENCODER_LIMIT);
            assertTrue("H263 audio video record memory test", memoryResult);
        }
    }

    // Test case 7: Capture the memory usage after every 20 audio only recorded
    @LargeTest