diff options
author | Yu Shan Emily Lau <yslau@google.com> | 2011-02-25 20:07:24 -0800 |
---|---|---|
committer | Yu Shan Emily Lau <yslau@google.com> | 2011-02-25 20:20:53 -0800 |
commit | 62f755ac65cb40f231a7fa0695724ae01975d01c (patch) | |
tree | db0dba0ed2b5037eebd6d730a1580044bb8159ba /media/tests | |
parent | e86c12c9e489e7f04c49a7733fc4014668e012e2 (diff) | |
download | frameworks_base-62f755ac65cb40f231a7fa0695724ae01975d01c.zip frameworks_base-62f755ac65cb40f231a7fa0695724ae01975d01c.tar.gz frameworks_base-62f755ac65cb40f231a7fa0695724ae01975d01c.tar.bz2 |
Remove the hard coded media recorder test cases.
Add the native heap dump catpure functionality.
Change-Id: I434ff886152cbb9b2b9a4e39c75bfd016e0e50a0
Diffstat (limited to 'media/tests')
4 files changed, 88 insertions, 177 deletions
diff --git a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/MediaFrameworkPerfTestRunner.java b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/MediaFrameworkPerfTestRunner.java index 988b229..a6cf355 100755 --- a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/MediaFrameworkPerfTestRunner.java +++ b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/MediaFrameworkPerfTestRunner.java @@ -21,9 +21,10 @@ import com.android.mediaframeworktest.performance.MediaPlayerPerformance; import com.android.mediaframeworktest.performance.VideoEditorPerformance; import junit.framework.TestSuite; +import android.os.Bundle; import android.test.InstrumentationTestRunner; import android.test.InstrumentationTestSuite; - +import android.util.Log; /** * Instrumentation Test Runner for all MediaPlayer tests. @@ -36,19 +37,30 @@ import android.test.InstrumentationTestSuite; public class MediaFrameworkPerfTestRunner extends InstrumentationTestRunner { + public static boolean mGetNativeHeapDump = false; + + + @Override + public TestSuite getAllTests() { + TestSuite suite = new InstrumentationTestSuite(this); + suite.addTestSuite(MediaPlayerPerformance.class); + /* Video Editor performance Test cases */ + suite.addTestSuite(VideoEditorPerformance.class); + return suite; + } - @Override - public TestSuite getAllTests() { - TestSuite suite = new InstrumentationTestSuite(this); - suite.addTestSuite(MediaPlayerPerformance.class); - /*Video Editor performance Test cases*/ - suite.addTestSuite(VideoEditorPerformance.class); - return suite; - } + @Override + public ClassLoader getLoader() { + return MediaFrameworkTestRunner.class.getClassLoader(); + } - @Override - public ClassLoader getLoader() { - return MediaFrameworkTestRunner.class.getClassLoader(); - } + @Override + public void onCreate(Bundle icicle) { + super.onCreate(icicle); + String get_heap_dump = (String) icicle.get("get_heap_dump"); + if (get_heap_dump != null) { + mGetNativeHeapDump = true; + } + } } diff --git a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/MediaTestUtil.java b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/MediaTestUtil.java new file mode 100755 index 0000000..0183b5d --- /dev/null +++ b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/MediaTestUtil.java @@ -0,0 +1,45 @@ +/* + * Copyright (C) 2011 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.mediaframeworktest; + +import java.io.FileOutputStream; + +import android.os.Debug; +import android.os.Environment; + +/** + * + * Utilities for media framework test. + * + */ +public class MediaTestUtil { + private MediaTestUtil(){ + } + + private static final String STORAGE_PATH = + Environment.getExternalStorageDirectory().toString(); + + //Catpure the heapdump for memory leaksage analysis\ + public static void getNativeHeapDump (String name) throws Exception { + System.gc(); + System.runFinalization(); + Thread.sleep(1000); + FileOutputStream o = new FileOutputStream(STORAGE_PATH + '/' +name + ".dump"); + Debug.dumpNativeHeap(o.getFD()); + o.close(); + } +}
\ No newline at end of file diff --git a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/MediaRecorderTest.java b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/MediaRecorderTest.java index ce6db68..82df669 100644 --- a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/MediaRecorderTest.java +++ b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/MediaRecorderTest.java @@ -28,7 +28,7 @@ import android.media.MediaRecorder; import android.media.EncoderCapabilities; import android.media.EncoderCapabilities.VideoEncoderCap; import android.media.EncoderCapabilities.AudioEncoderCap; -import android.test.ActivityInstrumentationTestCase; +import android.test.ActivityInstrumentationTestCase2; import android.util.Log; import android.view.SurfaceHolder; import android.view.SurfaceView; @@ -42,7 +42,7 @@ import java.util.List; /** * Junit / Instrumentation test case for the media recorder api */ -public class MediaRecorderTest extends ActivityInstrumentationTestCase<MediaFrameworkTest> { +public class MediaRecorderTest extends ActivityInstrumentationTestCase2<MediaFrameworkTest> { private String TAG = "MediaRecorderTest"; private int mOutputDuration =0; private int mOutputVideoWidth = 0; @@ -62,9 +62,9 @@ public class MediaRecorderTest extends ActivityInstrumentationTestCase<MediaFram } protected void setUp() throws Exception { - super.setUp(); - Log.v(TAG,"create the media recorder"); + getActivity(); mRecorder = new MediaRecorder(); + super.setUp(); } private void recordVideo(int frameRate, int width, int height, @@ -199,8 +199,6 @@ public class MediaRecorderTest extends ActivityInstrumentationTestCase<MediaFram return false; } - - private void getOutputVideoProperty(String outputFilePath) { MediaPlayer mediaPlayer = new MediaPlayer(); try { @@ -215,8 +213,6 @@ public class MediaRecorderTest extends ActivityInstrumentationTestCase<MediaFram Thread.sleep(1000); mOutputVideoHeight = mediaPlayer.getVideoHeight(); mOutputVideoWidth = mediaPlayer.getVideoWidth(); - //mOutputVideoHeight = CodecTest.videoHeight(outputFilePath); - //mOutputVideoWidth = CodecTest.videoWidth(outputFilePath); mediaPlayer.release(); } catch (Exception e) { Log.v(TAG, e.toString()); @@ -224,11 +220,6 @@ public class MediaRecorderTest extends ActivityInstrumentationTestCase<MediaFram } } - private void removeFile(String filePath) { - File fileRemove = new File(filePath); - fileRemove.delete(); - } - private boolean validateVideo(String filePath, int width, int height) { boolean validVideo = false; getOutputVideoProperty(filePath); @@ -237,72 +228,9 @@ public class MediaRecorderTest extends ActivityInstrumentationTestCase<MediaFram validVideo = true; } Log.v(TAG, "width = " + mOutputVideoWidth + " height = " + mOutputVideoHeight + " Duration = " + mOutputDuration); - //removeFile(filePath); return validVideo; } - - - //Format: HVGA h263 - @Suppress - public void testHVGAH263() throws Exception { - boolean videoRecordedResult = false; - recordVideo(15, 480, 320, MediaRecorder.VideoEncoder.H263, - MediaRecorder.OutputFormat.THREE_GPP, MediaNames.RECORDED_HVGA_H263, false); - videoRecordedResult = validateVideo(MediaNames.RECORDED_HVGA_H263, 480, 320); - assertTrue("HVGAH263", videoRecordedResult); - } - - //Format: QVGA h263 - @Suppress - public void testQVGAH263() throws Exception { - boolean videoRecordedResult = false; - recordVideo(15, 320, 240, MediaRecorder.VideoEncoder.H263, - MediaRecorder.OutputFormat.THREE_GPP, MediaNames.RECORDED_QVGA_H263, false); - videoRecordedResult = validateVideo(MediaNames.RECORDED_QVGA_H263, 320, 240); - assertTrue("QVGAH263", videoRecordedResult); - } - - //Format: SQVGA h263 - @Suppress - public void testSQVGAH263() throws Exception { - boolean videoRecordedResult = false; - recordVideo(15, 240, 160, MediaRecorder.VideoEncoder.H263, - MediaRecorder.OutputFormat.THREE_GPP, MediaNames.RECORDED_SQVGA_H263, false); - videoRecordedResult = validateVideo(MediaNames.RECORDED_SQVGA_H263, 240, 160); - assertTrue("SQVGAH263", videoRecordedResult); - } - - //Format: QCIF h263 - @LargeTest - public void testQCIFH263() throws Exception { - boolean videoRecordedResult = false; - recordVideo(15, 176, 144, MediaRecorder.VideoEncoder.H263, - MediaRecorder.OutputFormat.THREE_GPP, MediaNames.RECORDED_QCIF_H263, false); - videoRecordedResult = validateVideo(MediaNames.RECORDED_QCIF_H263, 176, 144); - assertTrue("QCIFH263", videoRecordedResult); - } - - //Format: CIF h263 - @LargeTest - public void testCIFH263() throws Exception { - boolean videoRecordedResult = false; - recordVideo(15, 352, 288, MediaRecorder.VideoEncoder.H263, - MediaRecorder.OutputFormat.THREE_GPP, MediaNames.RECORDED_CIF_H263, false); - videoRecordedResult = validateVideo(MediaNames.RECORDED_CIF_H263, 352, 288); - assertTrue("CIFH263", videoRecordedResult); - } - - - - @LargeTest - public void testVideoOnly() throws Exception { - boolean videoRecordedResult = false; - recordVideo(15, 176, 144, MediaRecorder.VideoEncoder.H263, - MediaRecorder.OutputFormat.MPEG_4, MediaNames.RECORDED_VIDEO_3GP, true); - videoRecordedResult = validateVideo(MediaNames.RECORDED_VIDEO_3GP, 176, 144); - assertTrue("QCIFH263 Video Only", videoRecordedResult); - } - + @LargeTest /* * This test case set the camera in portrait mode. @@ -332,74 +260,6 @@ public class MediaRecorderTest extends ActivityInstrumentationTestCase<MediaFram assertTrue("PortraitH263", videoRecordedResult); } - @Suppress - public void testHVGAMP4() throws Exception { - boolean videoRecordedResult = false; - recordVideo(15, 480, 320, MediaRecorder.VideoEncoder.MPEG_4_SP, - MediaRecorder.OutputFormat.MPEG_4, MediaNames.RECORDED_HVGA_MP4, false); - videoRecordedResult = validateVideo(MediaNames.RECORDED_HVGA_MP4, 480, 320); - assertTrue("HVGAMP4", videoRecordedResult); - } - - @Suppress - public void testQVGAMP4() throws Exception { - boolean videoRecordedResult = false; - recordVideo(15, 320, 240, MediaRecorder.VideoEncoder.MPEG_4_SP, - MediaRecorder.OutputFormat.MPEG_4, MediaNames.RECORDED_QVGA_MP4, false); - videoRecordedResult = validateVideo(MediaNames.RECORDED_QVGA_MP4, 320, 240); - assertTrue("QVGAMP4", videoRecordedResult); - } - - @Suppress - public void testSQVGAMP4() throws Exception { - boolean videoRecordedResult = false; - recordVideo(15, 240, 160, MediaRecorder.VideoEncoder.MPEG_4_SP, - MediaRecorder.OutputFormat.MPEG_4, MediaNames.RECORDED_SQVGA_MP4, false); - videoRecordedResult = validateVideo(MediaNames.RECORDED_SQVGA_MP4, 240, 160); - assertTrue("SQVGAMP4", videoRecordedResult); - } - - //Format: QCIF MP4 - @LargeTest - public void testQCIFMP4() throws Exception { - boolean videoRecordedResult = false; - recordVideo(15, 176, 144, MediaRecorder.VideoEncoder.MPEG_4_SP, - MediaRecorder.OutputFormat.MPEG_4, MediaNames.RECORDED_QCIF_MP4, false); - videoRecordedResult = validateVideo(MediaNames.RECORDED_QCIF_MP4, 176, 144); - assertTrue("QCIFMP4", videoRecordedResult); - } - - - //Format: CIF MP4 - @LargeTest - public void testCIFMP4() throws Exception { - boolean videoRecordedResult = false; - recordVideo(15, 352, 288, MediaRecorder.VideoEncoder.MPEG_4_SP, - MediaRecorder.OutputFormat.MPEG_4, MediaNames.RECORDED_CIF_MP4, false); - videoRecordedResult = validateVideo(MediaNames.RECORDED_CIF_MP4, 352, 288); - assertTrue("CIFMP4", videoRecordedResult); - } - - - //Format: CIF MP4 output format 3gpp - @LargeTest - public void testCIFMP43GPP() throws Exception { - boolean videoRecordedResult = false; - recordVideo(15, 352, 288, MediaRecorder.VideoEncoder.MPEG_4_SP, - MediaRecorder.OutputFormat.THREE_GPP, MediaNames.RECORDED_VIDEO_3GP, false); - videoRecordedResult = validateVideo(MediaNames.RECORDED_VIDEO_3GP, 352, 288); - assertTrue("CIFMP4 3GPP", videoRecordedResult); - } - - @LargeTest - public void testQCIFH2633GPP() throws Exception { - boolean videoRecordedResult = false; - recordVideo(15, 176, 144, MediaRecorder.VideoEncoder.H263, - MediaRecorder.OutputFormat.THREE_GPP, MediaNames.RECORDED_VIDEO_3GP, false); - videoRecordedResult = validateVideo(MediaNames.RECORDED_VIDEO_3GP, 176, 144); - assertTrue("QCIFH263 3GPP", videoRecordedResult); - } - @LargeTest public void testInvalidVideoPath() throws Exception { boolean isTestInvalidVideoPathSuccessful = false; @@ -408,23 +268,6 @@ public class MediaRecorderTest extends ActivityInstrumentationTestCase<MediaFram assertTrue("Invalid outputFile Path", isTestInvalidVideoPathSuccessful); } - @Suppress - public void testInvalidVideoSize() throws Exception { - boolean isTestInvalidVideoSizeSuccessful = false; - isTestInvalidVideoSizeSuccessful = invalidRecordSetting(15, 800, 600, MediaRecorder.VideoEncoder.H263, - MediaRecorder.OutputFormat.THREE_GPP, MediaNames.RECORDED_VIDEO_3GP, false); - assertTrue("Invalid video Size", isTestInvalidVideoSizeSuccessful); - } - - @Suppress - @LargeTest - public void testInvalidFrameRate() throws Exception { - boolean isTestInvalidFrameRateSuccessful = false; - isTestInvalidFrameRateSuccessful = invalidRecordSetting(50, 176, 144, MediaRecorder.VideoEncoder.H263, - MediaRecorder.OutputFormat.THREE_GPP, MediaNames.RECORDED_VIDEO_3GP, false); - assertTrue("Invalid FrameRate", isTestInvalidFrameRateSuccessful); - } - @LargeTest //test cases for the new codec public void testDeviceSpecificCodec() throws Exception { 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 0e3029b..34affa7 100644 --- a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/performance/MediaPlayerPerformance.java +++ b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/performance/MediaPlayerPerformance.java @@ -17,7 +17,9 @@ package com.android.mediaframeworktest.performance; import com.android.mediaframeworktest.MediaFrameworkTest; +import com.android.mediaframeworktest.MediaFrameworkPerfTestRunner; import com.android.mediaframeworktest.MediaNames; +import com.android.mediaframeworktest.MediaTestUtil; import android.database.sqlite.SQLiteDatabase; import android.hardware.Camera; @@ -27,7 +29,7 @@ import android.media.MediaRecorder; import android.os.ConditionVariable; import android.os.Looper; import android.os.SystemClock; -import android.test.ActivityInstrumentationTestCase; +import android.test.ActivityInstrumentationTestCase2; import android.test.suitebuilder.annotation.LargeTest; import android.test.suitebuilder.annotation.Suppress; import android.util.Log; @@ -52,7 +54,7 @@ import android.hardware.Camera.PreviewCallback; * Junit / Instrumentation - performance measurement for media player and * recorder */ -public class MediaPlayerPerformance extends ActivityInstrumentationTestCase<MediaFrameworkTest> { +public class MediaPlayerPerformance extends ActivityInstrumentationTestCase2<MediaFrameworkTest> { private String TAG = "MediaPlayerPerformance"; @@ -87,6 +89,15 @@ public class MediaPlayerPerformance extends ActivityInstrumentationTestCase<Medi protected void setUp() throws Exception { super.setUp(); + getActivity(); + if (MediaFrameworkPerfTestRunner.mGetNativeHeapDump) + MediaTestUtil.getNativeHeapDump(this.getName() + "_before"); + } + + protected void tearDown() throws Exception { + super.tearDown(); + if (MediaFrameworkPerfTestRunner.mGetNativeHeapDump) + MediaTestUtil.getNativeHeapDump(this.getName() + "_after"); } public void createDB() { |