am 0e80e56e: am cd91c24f: Add AAC test to SoundPoolTest - Change the original code to get file/resource names from member functions. (SoundPool is changed to abstract class) - SoundPoolAacTest implements those functions to provide AAC clips - SoundPoolOggTest for Og
* commit '0e80e56e90fe23671d799c61cdf52d48e152abc3':
Add AAC test to SoundPoolTest - Change the original code to get file/resource names from member functions. (SoundPool is changed to abstract class) - SoundPoolAacTest implements those functions to provide AAC clips - SoundPoolOggTest for Ogg - new aac clips in mp4 container added (converted from the original ogg)
diff --git a/tests/res/raw/a_4_aac.mp4 b/tests/res/raw/a_4_aac.mp4
new file mode 100644
index 0000000..05a776f
--- /dev/null
+++ b/tests/res/raw/a_4_aac.mp4
Binary files differ
diff --git a/tests/res/raw/b_5_aac.mp4 b/tests/res/raw/b_5_aac.mp4
new file mode 100644
index 0000000..9bce44d
--- /dev/null
+++ b/tests/res/raw/b_5_aac.mp4
Binary files differ
diff --git a/tests/res/raw/c_sharp_5_aac.mp4 b/tests/res/raw/c_sharp_5_aac.mp4
new file mode 100644
index 0000000..1e7f988
--- /dev/null
+++ b/tests/res/raw/c_sharp_5_aac.mp4
Binary files differ
diff --git a/tests/res/raw/e_5_aac.mp4 b/tests/res/raw/e_5_aac.mp4
new file mode 100644
index 0000000..95bad2a
--- /dev/null
+++ b/tests/res/raw/e_5_aac.mp4
Binary files differ
diff --git a/tests/res/raw/g_sharp_5_aac.mp4 b/tests/res/raw/g_sharp_5_aac.mp4
new file mode 100644
index 0000000..a357912
--- /dev/null
+++ b/tests/res/raw/g_sharp_5_aac.mp4
Binary files differ
diff --git a/tests/tests/media/src/android/media/cts/SoundPoolAacTest.java b/tests/tests/media/src/android/media/cts/SoundPoolAacTest.java
new file mode 100644
index 0000000..edd4d58
--- /dev/null
+++ b/tests/tests/media/src/android/media/cts/SoundPoolAacTest.java
@@ -0,0 +1,52 @@
+/*
+ * 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 android.media.cts;
+
+import com.android.cts.stub.R;
+
+public class SoundPoolAacTest extends SoundPoolTest {
+
+ @Override
+ protected int getSoundA() {
+ return R.raw.a_4_aac;
+ }
+
+ @Override
+ protected int getSoundCs() {
+ return R.raw.c_sharp_5_aac;
+ }
+
+ @Override
+ protected int getSoundE() {
+ return R.raw.e_5_aac;
+ }
+
+ @Override
+ protected int getSoundB() {
+ return R.raw.b_5_aac;
+ }
+
+ @Override
+ protected int getSoundGs() {
+ return R.raw.g_sharp_5_aac;
+ }
+
+ @Override
+ protected String getFileName() {
+ return "a_4_aac.mp4";
+ }
+}
diff --git a/tests/tests/media/src/android/media/cts/SoundPoolOggTest.java b/tests/tests/media/src/android/media/cts/SoundPoolOggTest.java
new file mode 100644
index 0000000..14bb47e
--- /dev/null
+++ b/tests/tests/media/src/android/media/cts/SoundPoolOggTest.java
@@ -0,0 +1,52 @@
+/*
+ * 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 android.media.cts;
+
+import com.android.cts.stub.R;
+
+public class SoundPoolOggTest extends SoundPoolTest {
+
+ @Override
+ protected int getSoundA() {
+ return R.raw.a_4;
+ }
+
+ @Override
+ protected int getSoundCs() {
+ return R.raw.c_sharp_5;
+ }
+
+ @Override
+ protected int getSoundE() {
+ return R.raw.e_5;
+ }
+
+ @Override
+ protected int getSoundB() {
+ return R.raw.b_5;
+ }
+
+ @Override
+ protected int getSoundGs() {
+ return R.raw.g_sharp_5;
+ }
+
+ @Override
+ protected String getFileName() {
+ return "a_4.ogg";
+ }
+}
diff --git a/tests/tests/media/src/android/media/cts/SoundPoolTest.java b/tests/tests/media/src/android/media/cts/SoundPoolTest.java
index 2764c8b..d5b33b4 100644
--- a/tests/tests/media/src/android/media/cts/SoundPoolTest.java
+++ b/tests/tests/media/src/android/media/cts/SoundPoolTest.java
@@ -36,29 +36,46 @@
import java.io.InputStream;
@TestTargetClass(SoundPool.class)
-public class SoundPoolTest extends AndroidTestCase {
+abstract class SoundPoolTest extends AndroidTestCase {
private static final int SOUNDPOOL_STREAMS = 4;
- private static final int SOUND_A = R.raw.a_4;
- private static final int SOUND_CS = R.raw.c_sharp_5;
- private static final int SOUND_E = R.raw.e_5;
- private static final int SOUND_B = R.raw.b_5;
- private static final int SOUND_GS = R.raw.g_sharp_5;
private static final int PRIORITY = 1;
private static final int LOUD = 20;
private static final int QUIET = LOUD / 2;
private static final int SILENT = 0;
-
- private static final int[] SOUNDS = { SOUND_A, SOUND_CS, SOUND_E, SOUND_B, SOUND_GS };
-
- private static final String FILE_NAME = "a_4.ogg";
private File mFile;
private SoundPool mSoundPool;
+ /**
+ * function to return resource ID for A4 sound.
+ * should be implemented by child class
+ * @return resource ID
+ */
+ protected abstract int getSoundA();
+
+ protected abstract int getSoundCs();
+
+ protected abstract int getSoundE();
+
+ protected abstract int getSoundB();
+
+ protected abstract int getSoundGs();
+
+ protected abstract String getFileName();
+
+ private int[] getSounds() {
+ int[] sounds = { getSoundA(),
+ getSoundCs(),
+ getSoundE(),
+ getSoundB(),
+ getSoundGs() };
+ return sounds;
+ }
+
@Override
protected void setUp() throws Exception {
super.setUp();
- mFile = new File(mContext.getFilesDir(), FILE_NAME);
+ mFile = new File(mContext.getFilesDir(), getFileName());
}
@Override
@@ -110,12 +127,12 @@
public void testLoad() throws Exception {
int srcQuality = 100;
mSoundPool = new SoundPool(SOUNDPOOL_STREAMS, AudioManager.STREAM_MUSIC, srcQuality);
- int sampleId1 = mSoundPool.load(mContext, SOUND_A, PRIORITY);
+ int sampleId1 = mSoundPool.load(mContext, getSoundA(), PRIORITY);
waitUntilLoaded(sampleId1);
// should return true, but returns false
mSoundPool.unload(sampleId1);
- AssetFileDescriptor afd = mContext.getResources().openRawResourceFd(SOUND_CS);
+ AssetFileDescriptor afd = mContext.getResources().openRawResourceFd(getSoundCs());
int sampleId2;
sampleId2 = mSoundPool.load(afd, PRIORITY);
waitUntilLoaded(sampleId2);
@@ -141,7 +158,7 @@
FileOutputStream fOutput = null;
try {
fOutput = new FileOutputStream(f);
- InputStream is = mContext.getResources().openRawResource(SOUND_A);
+ InputStream is = mContext.getResources().openRawResource(getSoundA());
byte[] buffer = new byte[1024];
int length = is.read(buffer);
while (length != -1) {
@@ -211,7 +228,7 @@
public void testSoundPoolOp() throws Exception {
int srcQuality = 100;
mSoundPool = new SoundPool(SOUNDPOOL_STREAMS, AudioManager.STREAM_MUSIC, srcQuality);
- int sampleID = loadSampleSync(SOUND_A, PRIORITY);
+ int sampleID = loadSampleSync(getSoundA(), PRIORITY);
int waitMsec = 1000;
float leftVolume = SILENT;
@@ -276,8 +293,8 @@
public void testMultiSound() throws Exception {
int srcQuality = 100;
mSoundPool = new SoundPool(SOUNDPOOL_STREAMS, AudioManager.STREAM_MUSIC, srcQuality);
- int sampleID1 = loadSampleSync(SOUND_A, PRIORITY);
- int sampleID2 = loadSampleSync(SOUND_CS, PRIORITY);
+ int sampleID1 = loadSampleSync(getSoundA(), PRIORITY);
+ int sampleID2 = loadSampleSync(getSoundCs(), PRIORITY);
long waitMsec = 1000;
Thread.sleep(waitMsec);
@@ -317,10 +334,11 @@
})
public void testLoadMore() throws Exception {
mSoundPool = new SoundPool(SOUNDPOOL_STREAMS, AudioManager.STREAM_MUSIC, 0);
- int[] soundIds = new int[SOUNDS.length];
- int[] streamIds = new int[SOUNDS.length];
- for (int i = 0; i < SOUNDS.length; i++) {
- soundIds[i] = loadSampleSync(SOUNDS[i], PRIORITY);
+ int[] sounds = getSounds();
+ int[] soundIds = new int[sounds.length];
+ int[] streamIds = new int[sounds.length];
+ for (int i = 0; i < sounds.length; i++) {
+ soundIds[i] = loadSampleSync(sounds[i], PRIORITY);
System.out.println("load: " + soundIds[i]);
}
for (int i = 0; i < soundIds.length; i++) {