diff options
author | Yu Shan Emily Lau <yslau@google.com> | 2010-08-10 18:30:44 -0700 |
---|---|---|
committer | Yu Shan Emily Lau <yslau@google.com> | 2010-08-10 20:02:07 -0700 |
commit | fd4a7c83b2c880ba5b75525ebe3f1845903ada76 (patch) | |
tree | 6f51c8d6f83ccf63202c1eefbe88293432e90591 /media/tests | |
parent | 1a140bf65c288fcb1458bbd694c9d6e7a567a0f5 (diff) | |
download | frameworks_base-fd4a7c83b2c880ba5b75525ebe3f1845903ada76.zip frameworks_base-fd4a7c83b2c880ba5b75525ebe3f1845903ada76.tar.gz frameworks_base-fd4a7c83b2c880ba5b75525ebe3f1845903ada76.tar.bz2 |
Add the a power test case which simply do the audio playback. The actual power measurement will be done by another application.
Change-Id: I51008ffdbe60e7e0b298091eb914b74f2d6731f8
Diffstat (limited to 'media/tests')
3 files changed, 136 insertions, 0 deletions
diff --git a/media/tests/MediaFrameworkTest/AndroidManifest.xml b/media/tests/MediaFrameworkTest/AndroidManifest.xml index 246f9fc..f70a145 100644 --- a/media/tests/MediaFrameworkTest/AndroidManifest.xml +++ b/media/tests/MediaFrameworkTest/AndroidManifest.xml @@ -51,4 +51,9 @@ android:label="MediaRecorder stress tests InstrumentationRunner"> </instrumentation> + <instrumentation android:name=".MediaFrameworkPowerTestRunner" + android:targetPackage="com.android.mediaframeworktest" + android:label="Media Power tests InstrumentationRunner"> + </instrumentation> + </manifest> diff --git a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/MediaFrameworkPowerTestRunner.java b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/MediaFrameworkPowerTestRunner.java new file mode 100755 index 0000000..34db4db --- /dev/null +++ b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/MediaFrameworkPowerTestRunner.java @@ -0,0 +1,50 @@ +/* + * Copyright (C) 2010 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 com.android.mediaframeworktest.power.MediaPlayerPowerTest; + +import junit.framework.TestSuite; + +import android.test.InstrumentationTestRunner; +import android.test.InstrumentationTestSuite; + + +/** + * Instrumentation Test Runner for all MediaPlayer tests. + * + * Running all tests: + * + * adb shell am instrument \ + * -w com.android.mediaframeworktest/.MediaFrameworkPowerTestRunner + */ + +public class MediaFrameworkPowerTestRunner extends InstrumentationTestRunner { + + @Override + public TestSuite getAllTests() { + TestSuite suite = new InstrumentationTestSuite(this); + suite.addTestSuite(MediaPlayerPowerTest.class); + return suite; + } + + @Override + public ClassLoader getLoader() { + return MediaFrameworkPowerTestRunner.class.getClassLoader(); + } +} + diff --git a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/power/MediaPlayerPowerTest.java b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/power/MediaPlayerPowerTest.java new file mode 100644 index 0000000..9e91740 --- /dev/null +++ b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/power/MediaPlayerPowerTest.java @@ -0,0 +1,81 @@ +/* + * Copyright (C) 2010 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.power; + +import com.android.mediaframeworktest.MediaFrameworkTest; +import com.android.mediaframeworktest.MediaNames; +import android.media.MediaPlayer; +import android.os.Environment; +import android.test.ActivityInstrumentationTestCase2; +import android.util.Log; + +import java.io.File; + +/** + * Junit / Instrumentation test case for the power measurment the media player + */ +public class MediaPlayerPowerTest extends ActivityInstrumentationTestCase2<MediaFrameworkTest> { + private String TAG = "MediaPlayerPowerTest"; + private String MP3_POWERTEST = + Environment.getExternalStorageDirectory().toString() + "/power_sample_mp3.mp3"; + private String MP3_STREAM = "http://75.17.48.204:10088/power_media/power_sample_mp3.mp3"; + private String OGG_STREAM = "http://75.17.48.204:10088/power_media/power_sample_ogg.mp3"; + private String AAC_STREAM = "http://75.17.48.204:10088/power_media/power_sample_aac.mp3"; + + public MediaPlayerPowerTest() { + super("com.android.mediaframeworktest", MediaFrameworkTest.class); + } + + protected void setUp() throws Exception { + getActivity(); + super.setUp(); + + } + + public void audioPlayback(String filePath) { + try { + MediaPlayer mp = new MediaPlayer(); + mp.setDataSource(filePath); + mp.prepare(); + mp.start(); + Thread.sleep(200000); + mp.stop(); + mp.release(); + } catch (Exception e) { + Log.v(TAG, e.toString()); + assertTrue("MP3 Playback", false); + } + } + + // A very simple test case which start the audio player. + // Power measurment will be done in other application. + public void testPowerLocalMP3Playback() throws Exception { + audioPlayback(MP3_POWERTEST); + } + + public void testPowerStreamMP3Playback() throws Exception { + audioPlayback(MP3_STREAM); + } + + public void testPowerStreamOGGPlayback() throws Exception { + audioPlayback(OGG_STREAM); + } + + public void testPowerStreamAACPlayback() throws Exception { + audioPlayback(AAC_STREAM); + } +} |