summaryrefslogtreecommitdiffstats
path: root/media/tests
diff options
context:
space:
mode:
authorThe Android Open Source Project <initial-contribution@android.com>2009-02-20 07:38:31 -0800
committerThe Android Open Source Project <initial-contribution@android.com>2009-02-20 07:38:31 -0800
commit15ab3eae2ec3d73b3e8aa60b33ae41445bf83f4b (patch)
treed03d027a7ed97af616904e02a7b420babf40d44f /media/tests
parent3001a035439d8134a7d70d796376d1dfbff3cdcd (diff)
downloadframeworks_base-15ab3eae2ec3d73b3e8aa60b33ae41445bf83f4b.zip
frameworks_base-15ab3eae2ec3d73b3e8aa60b33ae41445bf83f4b.tar.gz
frameworks_base-15ab3eae2ec3d73b3e8aa60b33ae41445bf83f4b.tar.bz2
auto import from //branches/cupcake/...@132569
Diffstat (limited to 'media/tests')
-rw-r--r--media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/MediaAudioTrackTest.java125
-rw-r--r--media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/TonesAutoTest.java2
-rw-r--r--media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/unit/MediaRecorderPrepareStateUnitTest.java2
-rw-r--r--media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/unit/MediaRecorderSetOutputFileStateUnitTest.java20
-rw-r--r--media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/unit/MediaRecorderStateUnitTestTemplate.java7
5 files changed, 139 insertions, 17 deletions
diff --git a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/MediaAudioTrackTest.java b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/MediaAudioTrackTest.java
index ae6a834..b6a0848 100644
--- a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/MediaAudioTrackTest.java
+++ b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/MediaAudioTrackTest.java
@@ -19,6 +19,8 @@ package com.android.mediaframeworktest.functional;
import com.android.mediaframeworktest.MediaFrameworkTest;
import com.android.mediaframeworktest.MediaNames;
+import android.media.AudioFormat;
+import android.media.AudioManager;
import android.media.AudioTrack;
import android.content.Context;
import android.test.ActivityInstrumentationTestCase2;
@@ -47,12 +49,127 @@ public class MediaAudioTrackTest extends ActivityInstrumentationTestCase2<MediaF
protected void tearDown() throws Exception {
super.tearDown();
}
+
+ //-----------------------------------------------------------------
+ // private class to hold test reslts
+ public class TestResults {
+ public boolean mResult = false;
+ public String mResultLog = "";
+ public TestResults(boolean b, String s) { mResult = b; mResultLog = s; }
+ }
+
+ //-----------------------------------------------------------------
+ // generic test methods
+ public TestResults constructorTestMultiSampleRate(
+ // parameters tested by this method
+ int _inTest_streamType, int _inTest_mode, int _inTest_config,
+ // parameter-dependent expected results
+ int _expected_stateForMode) {
+
+ int[] testSampleRates = {8000, 11025, 12000, 16000, 22050, 24000, 32000, 44100, 48000};
+ String failedRates = "Failure for rate(s): ";
+ boolean localRes, finalRes = true;
+
+ for(int i = 0 ; i < testSampleRates.length ; i++) {
+ //Log.v("MediaAudioTrackTest", "[ constructorTestMultiSampleRate ] testing "+ testSampleRates[i]);
+ AudioTrack track = null;
+ try {
+ track = new AudioTrack(
+ _inTest_streamType,
+ testSampleRates[i],
+ _inTest_config,
+ AudioFormat.ENCODING_PCM_16BIT,
+ AudioTrack.getMinBufferSize(testSampleRates[i],
+ _inTest_config, AudioFormat.ENCODING_PCM_16BIT),//testSampleRates[i]*4
+ _inTest_mode);
+ } catch(IllegalArgumentException iae) {
+ Log.e("MediaAudioTrackTest", "[ constructorTestMultiSampleRate ] exception at SR "
+ + testSampleRates[i]+": \n" + iae);
+ }
+ if(track != null) {
+ localRes = (track.getState() == _expected_stateForMode);
+ track.release();
+ }
+ else {
+ localRes = false;
+ }
+
+ if (!localRes) {
+ //log the error for the test runner
+ failedRates += Integer.toString(testSampleRates[i]) + "Hz ";
+ //log the error for logcat
+ Log.e("MediaAudioTrackTest", "[ constructorTestMultiSampleRate ] failed to construct "
+ +"AudioTrack(streamType="+_inTest_streamType
+ +", sampleRateInHz=" + testSampleRates[i]
+ +", channelConfig=" + _inTest_config
+ +", audioFormat=AudioFormat.ENCODING_PCM_16BIT"
+ +", bufferSizeInBytes=" + AudioTrack.getMinBufferSize(testSampleRates[i],
+ _inTest_config, AudioFormat.ENCODING_PCM_16BIT)
+ +", mode="+ _inTest_mode );
+ //mark test as failed
+ finalRes = false;
+ }
+ }
+ return new TestResults(finalRes, failedRates);
+ }
+
+ //-----------------------------------------------------------------
+ // AUDIOTRACK TESTS:
+ //----------------------------------
+
+ //-----------------------------------------------------------------
+ // AudioTrack constructor and AudioTrack.getMinBufferSize(...)
+ //----------------------------------
- //Test case 1: Set the invalid volume
+ //Test case 1: constructor for streaming AudioTrack, mono, 16bit at misc valid sample rates
+ @MediumTest
+ public void testConstructorMono16MusicStream() throws Exception {
+
+ TestResults res = constructorTestMultiSampleRate(
+ AudioManager.STREAM_MUSIC, AudioTrack.MODE_STREAM,
+ AudioFormat.CHANNEL_CONFIGURATION_MONO,
+ AudioTrack.STATE_INITIALIZED);
+
+ assertTrue("testConstructorMono16MusicStream: " + res.mResultLog, res.mResult);
+ }
+
+
+ //Test case 2: constructor for streaming AudioTrack, stereo, 16bit at misc valid sample rates
@MediumTest
- public void testGetMinVolume() throws Exception {
- //To Do: Create the test case for GetMinVolume
- assertTrue("testGetMinVolume", true);
+ public void testConstructorStereo16MusicStream() throws Exception {
+
+ TestResults res = constructorTestMultiSampleRate(
+ AudioManager.STREAM_MUSIC, AudioTrack.MODE_STREAM,
+ AudioFormat.CHANNEL_CONFIGURATION_STEREO,
+ AudioTrack.STATE_INITIALIZED);
+
+ assertTrue("testConstructorStereo16MusicStream: " + res.mResultLog, res.mResult);
+ }
+
+
+ //Test case 3: constructor for static AudioTrack, mono, 16bit at misc valid sample rates
+ @MediumTest
+ public void testConstructorMono16MusicStatic() throws Exception {
+
+ TestResults res = constructorTestMultiSampleRate(
+ AudioManager.STREAM_MUSIC, AudioTrack.MODE_STATIC,
+ AudioFormat.CHANNEL_CONFIGURATION_MONO,
+ AudioTrack.STATE_NO_STATIC_DATA);
+
+ assertTrue("testConstructorMono16MusicStatic: " + res.mResultLog, res.mResult);
+ }
+
+
+ //Test case 4: constructor for static AudioTrack, stereo, 16bit at misc valid sample rates
+ @MediumTest
+ public void testConstructorStereo16MusicStatic() throws Exception {
+
+ TestResults res = constructorTestMultiSampleRate(
+ AudioManager.STREAM_MUSIC, AudioTrack.MODE_STATIC,
+ AudioFormat.CHANNEL_CONFIGURATION_STEREO,
+ AudioTrack.STATE_NO_STATIC_DATA);
+
+ assertTrue("testConstructorStereo16MusicStatic: " + res.mResultLog, res.mResult);
}
}
diff --git a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/TonesAutoTest.java b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/TonesAutoTest.java
index 0209305..da18e74 100644
--- a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/TonesAutoTest.java
+++ b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/TonesAutoTest.java
@@ -88,7 +88,7 @@ import android.media.AudioManager;
toneGen = new ToneGenerator(AudioManager.STREAM_MUSIC, 100);
- for (type = ToneGenerator.TONE_PROP_BEEP; type <= ToneGenerator.TONE_PROP_PROMPT; type++) {
+ for (type = ToneGenerator.TONE_PROP_BEEP; type <= ToneGenerator.TONE_PROP_BEEP2; type++) {
if (toneGen.startTone(type)) {
Thread.sleep(1000);
toneGen.stopTone();
diff --git a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/unit/MediaRecorderPrepareStateUnitTest.java b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/unit/MediaRecorderPrepareStateUnitTest.java
index dfd544a..134144d 100644
--- a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/unit/MediaRecorderPrepareStateUnitTest.java
+++ b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/unit/MediaRecorderPrepareStateUnitTest.java
@@ -55,7 +55,7 @@ public class MediaRecorderPrepareStateUnitTest extends AndroidTestCase implement
try {
recorder.prepare();
} catch (IOException exception) {
- fail("recorder.prepare() failed");
+ throw new RuntimeException();
}
}
diff --git a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/unit/MediaRecorderSetOutputFileStateUnitTest.java b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/unit/MediaRecorderSetOutputFileStateUnitTest.java
index 50e235b..712a758 100644
--- a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/unit/MediaRecorderSetOutputFileStateUnitTest.java
+++ b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/unit/MediaRecorderSetOutputFileStateUnitTest.java
@@ -29,24 +29,22 @@ public class MediaRecorderSetOutputFileStateUnitTest extends AndroidTestCase imp
private MediaRecorderStateUnitTestTemplate mTestTemplate = new MediaRecorderStateUnitTestTemplate();
/**
* 1. It is valid to call setOutputFile() in the following states:
- * {DataSourceConfigured}.
+ * {DataSourceConfigured, Initial, Initialized, Prepared, Recording, Error}.
* 2. It is invalid to call setOutputFile() in the following states:
- * {Initial, Initialized, Prepared, Recording, Error}
+ * {}
*
* @param stateErrors the MediaRecorderStateErrors to check against.
*/
public void checkStateErrors(MediaRecorderStateErrors stateErrors) {
// Valid states.
assertTrue(!stateErrors.errorInDataSourceConfiguredState);
-
- // Invalid states.
- assertTrue(stateErrors.errorInPreparedState);
- assertTrue(stateErrors.errorInRecordingState);
- assertTrue(stateErrors.errorInErrorState);
- assertTrue(stateErrors.errorInInitialState);
- assertTrue(stateErrors.errorInInitialStateAfterReset);
- assertTrue(stateErrors.errorInInitialStateAfterStop);
- assertTrue(stateErrors.errorInInitializedState);
+ assertTrue(!stateErrors.errorInPreparedState);
+ assertTrue(!stateErrors.errorInRecordingState);
+ assertTrue(!stateErrors.errorInErrorState);
+ assertTrue(!stateErrors.errorInInitialState);
+ assertTrue(!stateErrors.errorInInitialStateAfterReset);
+ assertTrue(!stateErrors.errorInInitialStateAfterStop);
+ assertTrue(!stateErrors.errorInInitializedState);
}
public void invokeMethodUnderTest(MediaRecorder recorder) {
diff --git a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/unit/MediaRecorderStateUnitTestTemplate.java b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/unit/MediaRecorderStateUnitTestTemplate.java
index f350467..9edc9aa 100644
--- a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/unit/MediaRecorderStateUnitTestTemplate.java
+++ b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/unit/MediaRecorderStateUnitTestTemplate.java
@@ -90,9 +90,15 @@ class MediaRecorderStateUnitTestTemplate extends AndroidTestCase {
}
}
+ // FIXME:
+ // In the past, stop() == reset().
+ // However, this is no longer true. The plan is to have a STOPPED state.
+ // and from STOPPED state, start can be called without the need to
+ // do the recording configuration again.
private void setMediaRecorderToInitialStateAfterStop() {
try {
mMediaRecorder.reset();
+/*
mMediaRecorder.setAudioSource(AUDIO_SOURCE);
mMediaRecorder.setOutputFormat(OUTPUT_FORMAT);
mMediaRecorder.setAudioEncoder(AUDIO_ENCODER);
@@ -100,6 +106,7 @@ class MediaRecorderStateUnitTestTemplate extends AndroidTestCase {
mMediaRecorder.prepare();
mMediaRecorder.start();
mMediaRecorder.stop();
+*/
} catch(Exception e) {
fail("setMediaRecorderToInitialStateAfterReset: Exception " + e.getClass().getName() + " was thrown.");
}