diff options
author | Yu Shan Emily Lau <yslau@google.com> | 2011-11-28 19:57:26 -0800 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2011-11-28 19:57:26 -0800 |
commit | 9a8246c8d1ea324b6704bf4fe0b77ade1c2f3639 (patch) | |
tree | 7870060b4752aa7750dd5b8e05be0ec023a0b764 /media/tests | |
parent | 2f9e260185e9c83800ba14fdc7abeb95a399f526 (diff) | |
parent | 77d1ebbd7bd42d849911e680a63eec02e8b444db (diff) | |
download | frameworks_base-9a8246c8d1ea324b6704bf4fe0b77ade1c2f3639.zip frameworks_base-9a8246c8d1ea324b6704bf4fe0b77ade1c2f3639.tar.gz frameworks_base-9a8246c8d1ea324b6704bf4fe0b77ade1c2f3639.tar.bz2 |
am 77d1ebbd: am 4e5d3f2c: Merge "Add the min fps option to set the min fps in the media recorder test. Add the procmem log to the media memory stress test." into ics-mr1
* commit '77d1ebbd7bd42d849911e680a63eec02e8b444db':
Add the min fps option to set the min fps in the media recorder test. Add the procmem log to the media memory stress test.
Diffstat (limited to 'media/tests')
3 files changed, 104 insertions, 65 deletions
diff --git a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/MediaFrameworkTestRunner.java b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/MediaFrameworkTestRunner.java index 3fb2da0..92ac9eb 100755 --- a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/MediaFrameworkTestRunner.java +++ b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/MediaFrameworkTestRunner.java @@ -39,6 +39,7 @@ import com.android.mediaframeworktest.functional.videoeditor.VideoEditorExportTe import com.android.mediaframeworktest.functional.videoeditor.VideoEditorPreviewTest; import junit.framework.TestSuite; +import android.os.Bundle; import android.test.InstrumentationTestRunner; import android.test.InstrumentationTestSuite; @@ -54,6 +55,7 @@ import android.test.InstrumentationTestSuite; public class MediaFrameworkTestRunner extends InstrumentationTestRunner { + public static int mMinCameraFps = 0; @Override public TestSuite getAllTests() { @@ -87,4 +89,16 @@ public class MediaFrameworkTestRunner extends InstrumentationTestRunner { public ClassLoader getLoader() { return MediaFrameworkTestRunner.class.getClassLoader(); } + + @Override + public void onCreate(Bundle icicle) { + super.onCreate(icicle); + + String minCameraFps = (String) icicle.get("min_camera_fps"); + System.out.print("min_camera_" + minCameraFps); + + if (minCameraFps != null ) { + mMinCameraFps = Integer.parseInt(minCameraFps); + } + } } diff --git a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/mediarecorder/MediaRecorderTest.java b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/mediarecorder/MediaRecorderTest.java index b5c8c8c..0684946 100644 --- a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/mediarecorder/MediaRecorderTest.java +++ b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/mediarecorder/MediaRecorderTest.java @@ -33,6 +33,7 @@ import android.util.Log; import android.view.SurfaceHolder; import android.view.SurfaceView; import com.android.mediaframeworktest.MediaProfileReader; +import com.android.mediaframeworktest.MediaFrameworkTestRunner; import android.test.suitebuilder.annotation.LargeTest; import android.test.suitebuilder.annotation.Suppress; @@ -115,9 +116,16 @@ public class MediaRecorderTest extends ActivityInstrumentationTestCase2<MediaFra int audioChannels = highQuality? audioCap.mMaxChannels: audioCap.mMinChannels ; int audioSamplingRate = highQuality? audioCap.mMaxSampleRate: audioCap.mMinSampleRate; + //Overide the fps if the min_camera_fps is set + if (MediaFrameworkTestRunner.mMinCameraFps != 0 && + MediaFrameworkTestRunner.mMinCameraFps > videoFps){ + videoFps = MediaFrameworkTestRunner.mMinCameraFps; + } + if (videoFps < MIN_VIDEO_FPS) { videoFps = MIN_VIDEO_FPS; } + mSurfaceHolder = MediaFrameworkTest.mSurfaceView.getHolder(); String filename = ("/sdcard/" + videoEncoder + "_" + audioEncoder + "_" + highQuality + ".3gp"); try { diff --git a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/performance/MediaPlayerPerformance.java b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/performance/MediaPlayerPerformance.java index 0b887b9..4f6e7d2 100644 --- a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/performance/MediaPlayerPerformance.java +++ b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/performance/MediaPlayerPerformance.java @@ -37,11 +37,13 @@ import android.util.Log; import android.view.SurfaceHolder; import java.util.List; +import java.io.BufferedReader; import java.io.FileDescriptor; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; +import java.io.InputStreamReader; import java.io.Writer; import java.io.File; import java.io.FileWriter; @@ -68,6 +70,8 @@ public class MediaPlayerPerformance extends ActivityInstrumentationTestCase2<Med private static final long MEDIA_STRESS_WAIT_TIME = 5000; //5 seconds private static final String MEDIA_MEMORY_OUTPUT = "/sdcard/mediaMemOutput.txt"; + private static final String MEDIA_PROCMEM_OUTPUT = + "/sdcard/mediaProcmemOutput.txt"; private static int mStartMemory = 0; private static int mEndMemory = 0; @@ -84,6 +88,9 @@ public class MediaPlayerPerformance extends ActivityInstrumentationTestCase2<Med private static int DECODER_LIMIT = 150; private static int CAMERA_LIMIT = 80; + private Writer mProcMemWriter; + private Writer mMemWriter; + private static List<VideoEncoderCap> videoEncoders = MediaProfileReader.getVideoEncoders(); Camera mCamera; @@ -97,12 +104,21 @@ public class MediaPlayerPerformance extends ActivityInstrumentationTestCase2<Med getActivity(); if (MediaFrameworkPerfTestRunner.mGetNativeHeapDump) MediaTestUtil.getNativeHeapDump(this.getName() + "_before"); + + mProcMemWriter = new BufferedWriter(new FileWriter + (new File(MEDIA_PROCMEM_OUTPUT), true)); + mProcMemWriter.write(this.getName() + "\n"); + mMemWriter = new BufferedWriter(new FileWriter + (new File(MEDIA_MEMORY_OUTPUT), true)); + } protected void tearDown() throws Exception { - super.tearDown(); if (MediaFrameworkPerfTestRunner.mGetNativeHeapDump) MediaTestUtil.getNativeHeapDump(this.getName() + "_after"); + mProcMemWriter.close(); + mMemWriter.close(); + super.tearDown(); } private void initializeMessageLooper() { @@ -247,24 +263,39 @@ public class MediaPlayerPerformance extends ActivityInstrumentationTestCase2<Med } //Write the ps output to the file - public void getMemoryWriteToLog(Writer output, int writeCount) { + public void getMemoryWriteToLog(int writeCount) { String memusage = null; try { if (writeCount == 0) { mStartMemory = getMediaserverVsize(); - output.write("Start memory : " + mStartMemory + "\n"); + mMemWriter.write("Start memory : " + mStartMemory + "\n"); } memusage = captureMediaserverInfo(); - output.write(memusage); + mMemWriter.write(memusage); if (writeCount == NUM_STRESS_LOOP - 1) { mEndMemory = getMediaserverVsize(); - output.write("End Memory :" + mEndMemory + "\n"); + mMemWriter.write("End Memory :" + mEndMemory + "\n"); } } catch (Exception e) { e.toString(); } } + public void writeProcmemInfo() throws Exception{ + String cmd = "procmem " + getMediaserverPid(); + Process p = Runtime.getRuntime().exec(cmd); + + InputStream inStream = p.getInputStream(); + InputStreamReader inReader = new InputStreamReader(inStream); + BufferedReader inBuffer = new BufferedReader(inReader); + String s; + while ((s = inBuffer.readLine()) != null) { + mProcMemWriter.write(s); + mProcMemWriter.write("\n"); + } + mProcMemWriter.write("\n\n"); + } + public String captureMediaserverInfo() { String cm = "ps mediaserver"; String memoryUsage = null; @@ -306,7 +337,7 @@ public class MediaPlayerPerformance extends ActivityInstrumentationTestCase2<Med return vsizevalue; } - public boolean validateMemoryResult(int startPid, int startMemory, Writer output, int limit) + public boolean validateMemoryResult(int startPid, int startMemory, int limit) throws Exception { // Wait for 10 seconds to make sure the memory settle. Thread.sleep(10000); @@ -315,11 +346,11 @@ public class MediaPlayerPerformance extends ActivityInstrumentationTestCase2<Med if (memDiff < 0) { memDiff = 0; } - output.write("The total diff = " + memDiff); - output.write("\n\n"); + mMemWriter.write("The total diff = " + memDiff); + mMemWriter.write("\n\n"); // mediaserver crash if (startPid != mEndPid) { - output.write("mediaserver died. Test failed\n"); + mMemWriter.write("mediaserver died. Test failed\n"); return false; } // memory leak greter than the tolerant @@ -331,18 +362,16 @@ public class MediaPlayerPerformance extends ActivityInstrumentationTestCase2<Med @LargeTest public void testH263VideoPlaybackMemoryUsage() throws Exception { boolean memoryResult = false; - mStartPid = getMediaserverPid(); - File h263MemoryOut = new File(MEDIA_MEMORY_OUTPUT); - Writer output = new BufferedWriter(new FileWriter(h263MemoryOut, true)); - output.write("H263 Video Playback Only\n"); + mStartPid = getMediaserverPid(); + mMemWriter.write("H263 Video Playback Only\n"); for (int i = 0; i < NUM_STRESS_LOOP; i++) { mediaStressPlayback(MediaNames.VIDEO_HIGHRES_H263); - getMemoryWriteToLog(output, i); + getMemoryWriteToLog(i); + writeProcmemInfo(); } - output.write("\n"); - memoryResult = validateMemoryResult(mStartPid, mStartMemory, output, DECODER_LIMIT); - output.close(); + mMemWriter.write("\n"); + memoryResult = validateMemoryResult(mStartPid, mStartMemory, DECODER_LIMIT); assertTrue("H263 playback memory test", memoryResult); } @@ -350,18 +379,16 @@ public class MediaPlayerPerformance extends ActivityInstrumentationTestCase2<Med @LargeTest public void testH264VideoPlaybackMemoryUsage() throws Exception { boolean memoryResult = false; - mStartPid = getMediaserverPid(); - File h264MemoryOut = new File(MEDIA_MEMORY_OUTPUT); - Writer output = new BufferedWriter(new FileWriter(h264MemoryOut, true)); - output.write("H264 Video Playback only\n"); + mStartPid = getMediaserverPid(); + mMemWriter.write("H264 Video Playback only\n"); for (int i = 0; i < NUM_STRESS_LOOP; i++) { mediaStressPlayback(MediaNames.VIDEO_H264_AMR); - getMemoryWriteToLog(output, i); + getMemoryWriteToLog(i); + writeProcmemInfo(); } - output.write("\n"); - memoryResult = validateMemoryResult(mStartPid, mStartMemory, output, DECODER_LIMIT); - output.close(); + mMemWriter.write("\n"); + memoryResult = validateMemoryResult(mStartPid, mStartMemory, DECODER_LIMIT); assertTrue("H264 playback memory test", memoryResult); } @@ -369,21 +396,19 @@ public class MediaPlayerPerformance extends ActivityInstrumentationTestCase2<Med @LargeTest public void testH263RecordVideoOnlyMemoryUsage() throws Exception { boolean memoryResult = false; - mStartPid = getMediaserverPid(); - File videoH263RecordOnlyMemoryOut = new File(MEDIA_MEMORY_OUTPUT); - Writer output = new BufferedWriter(new FileWriter(videoH263RecordOnlyMemoryOut, true)); - output.write("H263 video record only\n"); + mStartPid = getMediaserverPid(); + mMemWriter.write("H263 video record only\n"); 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, 352, 288, MediaRecorder.VideoEncoder.H263, MediaRecorder.OutputFormat.MPEG_4, MediaNames.RECORDED_VIDEO_3GP, true)); - getMemoryWriteToLog(output, i); + getMemoryWriteToLog(i); + writeProcmemInfo(); } - output.write("\n"); - memoryResult = validateMemoryResult(mStartPid, mStartMemory, output, ENCODER_LIMIT); - output.close(); + mMemWriter.write("\n"); + memoryResult = validateMemoryResult(mStartPid, mStartMemory, ENCODER_LIMIT); assertTrue("H263 record only memory test", memoryResult); } @@ -391,21 +416,19 @@ public class MediaPlayerPerformance extends ActivityInstrumentationTestCase2<Med @LargeTest public void testMpeg4RecordVideoOnlyMemoryUsage() throws Exception { boolean memoryResult = false; - mStartPid = getMediaserverPid(); - File videoMp4RecordOnlyMemoryOut = new File(MEDIA_MEMORY_OUTPUT); - Writer output = new BufferedWriter(new FileWriter(videoMp4RecordOnlyMemoryOut, true)); - output.write("MPEG4 video record only\n"); + mStartPid = getMediaserverPid(); + mMemWriter.write("MPEG4 video record only\n"); int frameRate = MediaProfileReader.getMaxFrameRateForCodec(MediaRecorder.VideoEncoder.MPEG_4_SP); assertTrue("MPEG4 video recording frame rate", frameRate != -1); for (int i = 0; i < NUM_STRESS_LOOP; i++) { assertTrue(stressVideoRecord(frameRate, 352, 288, MediaRecorder.VideoEncoder.MPEG_4_SP, MediaRecorder.OutputFormat.MPEG_4, MediaNames.RECORDED_VIDEO_3GP, true)); - getMemoryWriteToLog(output, i); + getMemoryWriteToLog(i); + writeProcmemInfo(); } - output.write("\n"); - memoryResult = validateMemoryResult(mStartPid, mStartMemory, output, ENCODER_LIMIT); - output.close(); + mMemWriter.write("\n"); + memoryResult = validateMemoryResult(mStartPid, mStartMemory, ENCODER_LIMIT); assertTrue("mpeg4 record only memory test", memoryResult); } @@ -414,21 +437,19 @@ public class MediaPlayerPerformance extends ActivityInstrumentationTestCase2<Med @LargeTest public void testRecordVideoAudioMemoryUsage() throws Exception { boolean memoryResult = false; - mStartPid = getMediaserverPid(); - File videoRecordAudioMemoryOut = new File(MEDIA_MEMORY_OUTPUT); - Writer output = new BufferedWriter(new FileWriter(videoRecordAudioMemoryOut, true)); + mStartPid = getMediaserverPid(); int frameRate = MediaProfileReader.getMaxFrameRateForCodec(MediaRecorder.VideoEncoder.H263); assertTrue("H263 video recording frame rate", frameRate != -1); - output.write("Audio and h263 video record\n"); + mMemWriter.write("Audio and h263 video record\n"); for (int i = 0; i < NUM_STRESS_LOOP; i++) { assertTrue(stressVideoRecord(frameRate, 352, 288, MediaRecorder.VideoEncoder.H263, MediaRecorder.OutputFormat.MPEG_4, MediaNames.RECORDED_VIDEO_3GP, false)); - getMemoryWriteToLog(output, i); + getMemoryWriteToLog(i); + writeProcmemInfo(); } - output.write("\n"); - memoryResult = validateMemoryResult(mStartPid, mStartMemory, output, ENCODER_LIMIT); - output.close(); + mMemWriter.write("\n"); + memoryResult = validateMemoryResult(mStartPid, mStartMemory, ENCODER_LIMIT); assertTrue("H263 audio video record memory test", memoryResult); } @@ -436,18 +457,16 @@ public class MediaPlayerPerformance extends ActivityInstrumentationTestCase2<Med @LargeTest public void testRecordAudioOnlyMemoryUsage() throws Exception { boolean memoryResult = false; - mStartPid = getMediaserverPid(); - File audioOnlyMemoryOut = new File(MEDIA_MEMORY_OUTPUT); - Writer output = new BufferedWriter(new FileWriter(audioOnlyMemoryOut, true)); - output.write("Audio record only\n"); + mStartPid = getMediaserverPid(); + mMemWriter.write("Audio record only\n"); for (int i = 0; i < NUM_STRESS_LOOP; i++) { stressAudioRecord(MediaNames.RECORDER_OUTPUT); - getMemoryWriteToLog(output, i); + getMemoryWriteToLog(i); + writeProcmemInfo(); } - output.write("\n"); - memoryResult = validateMemoryResult(mStartPid, mStartMemory, output, ENCODER_LIMIT); - output.close(); + mMemWriter.write("\n"); + memoryResult = validateMemoryResult(mStartPid, mStartMemory, ENCODER_LIMIT); assertTrue("audio record only memory test", memoryResult); } @@ -455,18 +474,16 @@ public class MediaPlayerPerformance extends ActivityInstrumentationTestCase2<Med @LargeTest public void testCameraPreviewMemoryUsage() throws Exception { boolean memoryResult = false; - mStartPid = getMediaserverPid(); - File cameraPreviewMemoryOut = new File(MEDIA_MEMORY_OUTPUT); - Writer output = new BufferedWriter(new FileWriter(cameraPreviewMemoryOut, true)); - output.write("Camera Preview Only\n"); + mStartPid = getMediaserverPid(); + mMemWriter.write("Camera Preview Only\n"); for (int i = 0; i < NUM_STRESS_LOOP; i++) { stressCameraPreview(); - getMemoryWriteToLog(output, i); + getMemoryWriteToLog(i); + writeProcmemInfo(); } - output.write("\n"); - memoryResult = validateMemoryResult(mStartPid, mStartMemory, output, CAMERA_LIMIT); - output.close(); + mMemWriter.write("\n"); + memoryResult = validateMemoryResult(mStartPid, mStartMemory, CAMERA_LIMIT); assertTrue("camera preview memory test", memoryResult); } } |