diff options
author | Zach Pfeffer <zach.pfeffer@linaro.org> | 2011-12-07 15:01:06 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@betelgeuse.canonical.com> | 2011-12-07 15:01:07 +0000 |
commit | cd17abe28baf0f34441c108505d9a5bc442a4f4a (patch) | |
tree | 69acec708c70098712fcaee29e7b0ff211f5c1e8 | |
parent | 0826d0465ec54b12bd0fe65cf4fa5ee20816e915 (diff) | |
parent | dcba4e348783a90ecb238051453c7f2667058b4d (diff) | |
download | base-cd17abe28baf0f34441c108505d9a5bc442a4f4a.tar.gz |
Merge "MediaSamplesTest: add test for play various format media files" into linaro_android_4.0.1
3 files changed, 123 insertions, 6 deletions
diff --git a/media/tests/MediaFrameworkTest/Android.mk b/media/tests/MediaFrameworkTest/Android.mk index 9c45e6e189c4..21e4164e9ca3 100644 --- a/media/tests/MediaFrameworkTest/Android.mk +++ b/media/tests/MediaFrameworkTest/Android.mk @@ -1,12 +1,13 @@ LOCAL_PATH:= $(call my-dir) include $(CLEAR_VARS) -LOCAL_MODULE_TAGS := tests - +LOCAL_MODULE_TAGS := optional LOCAL_SRC_FILES := $(call all-subdir-java-files) +LOCAL_ASSET_FILES := $(call find-subdir-assets assets) LOCAL_JAVA_LIBRARIES := android.test.runner LOCAL_PACKAGE_NAME := mediaframeworktest +LOCAL_CERTIFICATE := shared include $(BUILD_PACKAGE) diff --git a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/MediaFrameworkTestRunner.java b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/MediaFrameworkTestRunner.java index 3fb2da080954..8bd0cf53420b 100755 --- a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/MediaFrameworkTestRunner.java +++ b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/MediaFrameworkTestRunner.java @@ -18,6 +18,7 @@ package com.android.mediaframeworktest; import com.android.mediaframeworktest.functional.CameraTest; import com.android.mediaframeworktest.functional.MediaMetadataTest; +import com.android.mediaframeworktest.functional.MediaSamplesTest; import com.android.mediaframeworktest.functional.MediaMimeTest; import com.android.mediaframeworktest.functional.MediaPlayerInvokeTest; import com.android.mediaframeworktest.functional.mediaplayback.MediaPlayerApiTest; @@ -37,11 +38,14 @@ import com.android.mediaframeworktest.functional.videoeditor.MediaPropertiesTest import com.android.mediaframeworktest.functional.videoeditor.VideoEditorAPITest; import com.android.mediaframeworktest.functional.videoeditor.VideoEditorExportTest; import com.android.mediaframeworktest.functional.videoeditor.VideoEditorPreviewTest; -import junit.framework.TestSuite; +import java.io.File; +import java.util.Arrays; +import android.os.Bundle; +import junit.framework.TestSuite; import android.test.InstrumentationTestRunner; import android.test.InstrumentationTestSuite; - +import android.util.Log; /** * Instrumentation Test Runner for all MediaPlayer tests. @@ -53,11 +57,24 @@ import android.test.InstrumentationTestSuite; */ public class MediaFrameworkTestRunner extends InstrumentationTestRunner { - + public static String mTargetDir = "/sdcard/"; + private static String TAG = "MediaFrameworkTestRunner"; + @Override + public void onCreate (Bundle arguments){ + Log.v(TAG, "step into onCreate"); + String targetDir = (String)arguments.get("targetDir"); + if(targetDir != null){ + Log.v(TAG, "targetDir="+targetDir); + mTargetDir = targetDir; + } + super.onCreate(arguments); + Log.v(TAG, "step out onCreate"); + } @Override public TestSuite getAllTests() { TestSuite suite = new InstrumentationTestSuite(this); +/* suite.addTestSuite(MediaPlayerApiTest.class); suite.addTestSuite(SimTonesTest.class); suite.addTestSuite(MediaMetadataTest.class); @@ -74,15 +91,59 @@ public class MediaFrameworkTestRunner extends InstrumentationTestRunner { suite.addTestSuite(MediaPresetReverbTest.class); suite.addTestSuite(MediaVirtualizerTest.class); suite.addTestSuite(MediaVisualizerTest.class); +*/ /*Test for Video Editor*/ - suite.addTestSuite(MediaItemThumbnailTest.class); +/* suite.addTestSuite(MediaItemThumbnailTest.class); suite.addTestSuite(MediaPropertiesTest.class); suite.addTestSuite(VideoEditorAPITest.class); suite.addTestSuite(VideoEditorExportTest.class); suite.addTestSuite(VideoEditorPreviewTest.class); +*/ + Log.v(TAG, "step into getAllTests"); + + if((mTargetDir != null) && (mTargetDir != "")){ + Log.v(TAG, "before addMMTestCase"); + addMMTestCase(suite, mTargetDir); + } + Log.v(TAG, "step out getAllTests"); return suite; } + public void addMMTestCase(TestSuite suite, String testFilesDir){ + File dir = new File(testFilesDir); + String[] children; + if (dir.isFile()){ + children = new String[]{testFilesDir}; + }else{ + children = dir.list(); + } + if ((children == null) ||(children.length == 0)) { + Log.v(TAG, "This dir is empty:" + testFilesDir); + return; + } else { + Arrays.sort(children); + int length = children.length; + for (int i = 0; i < length; i++) { + String filename = children[i]; + final File subFile = new File(dir + "/" + filename); + if (subFile.isDirectory()){ + Log.v(TAG, "loop directory:" + subFile.getPath()); + addMMTestCase(suite, subFile.getPath()); + }else{ + Log.v(TAG, "add test case:" + subFile.getPath()); + MediaSamplesTest tempTestCase = new MediaSamplesTest(){ + protected void runTest() throws Exception { + testSubPlay(subFile.getPath()); + } + }; + tempTestCase.setName(filename); + suite.addTest(tempTestCase); + } + } + return; + } + } + @Override public ClassLoader getLoader() { return MediaFrameworkTestRunner.class.getClassLoader(); diff --git a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/MediaSamplesTest.java b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/MediaSamplesTest.java new file mode 100644 index 000000000000..180e13155cb8 --- /dev/null +++ b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/MediaSamplesTest.java @@ -0,0 +1,55 @@ +/* + * Copyright (C) 2008 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.functional; + +import com.android.mediaframeworktest.MediaFrameworkTest; +import com.android.mediaframeworktest.MediaNames; +import com.android.mediaframeworktest.MediaProfileReader; + +import android.content.Context; +import android.test.ActivityInstrumentationTestCase; +import android.util.Log; +import android.test.suitebuilder.annotation.LargeTest; +import android.test.suitebuilder.annotation.MediumTest; +import android.test.suitebuilder.annotation.Suppress; + +import java.io.File; +import junit.framework.*; + +/** + * Junit / Instrumentation test case for the media player api + */ +public class MediaSamplesTest extends ActivityInstrumentationTestCase<MediaFrameworkTest> { + private String TAG = "MediaSamplesTest"; + + public MediaSamplesTest() { + super("com.android.mediaframeworktest", MediaFrameworkTest.class); + } + + protected void setUp() throws Exception { + super.setUp(); + } + + public void testSubPlay(String path) throws Exception{ + boolean onCompleteSuccess = false; + Log.v(TAG, + "testSubPlay: file to be played: " + + path); + onCompleteSuccess = CodecTest.playMediaSamples(path); + assertTrue("testSubPlay:" + path, onCompleteSuccess); + } +} |