DO NOT MERGE audio effects tests: fix tests in instant mode
commit edcb713a relies on CtsMediaAudioTestCases.apk to have permission
MODIFY_AUDIO_SETTINGS which is niot true whne running in instant mode.
Skip the tests if global effects are present and we are in instant mode.
Also migrate tests to Junit4.
Bug: 317747577
Test: run cts --enable-parameterized-modules --module-parameter instant_app -m CtsMediaAudioTestCases -t android.media.audio.cts.BassBoostTest
Change-Id: I53767b4304c6c3d293d5d80bd5aed6143877d9e1
Merged-In: I53767b4304c6c3d293d5d80bd5aed6143877d9e1
diff --git a/tests/tests/media/audio/src/android/media/audio/cts/AudioEffectTest.java b/tests/tests/media/audio/src/android/media/audio/cts/AudioEffectTest.java
index 8d91822..50c7386 100644
--- a/tests/tests/media/audio/src/android/media/audio/cts/AudioEffectTest.java
+++ b/tests/tests/media/audio/src/android/media/audio/cts/AudioEffectTest.java
@@ -18,6 +18,12 @@
import android.media.audio.cts.R;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
import android.content.res.AssetFileDescriptor;
import android.media.audiofx.AudioEffect;
import android.media.AudioFormat;
@@ -30,11 +36,13 @@
import android.media.MediaPlayer;
import android.media.MediaRecorder;
import android.media.cts.NonMediaMainlineTest;
-
import android.os.Looper;
import android.platform.test.annotations.AppModeFull;
import android.test.AndroidTestCase;
import android.util.Log;
+
+import org.junit.Test;
+
import java.util.UUID;
@AppModeFull(reason = "Dynamic congic not supported")
@@ -64,7 +72,7 @@
//----------------------------------
@Override
- protected void tearDown() throws Exception {
+ public void tearDown() throws Exception {
super.tearDown();
releaseEffect();
terminateMediaPlayerLooper();
@@ -76,6 +84,7 @@
//----------------------------------
//Test case 0.0: test queryEffects() and platfrom at least provides an Equalizer
+ @Test
public void test0_0QueryEffects() throws Exception {
AudioEffect.Descriptor[] desc = AudioEffect.queryEffects();
@@ -133,6 +142,7 @@
// Note: This test was removed because it used hidden api's.
//Test case 1.3: test getEnabled() failure when called on released effect
+ @Test
public void test1_3GetEnabledAfterRelease() throws Exception {
try {
AudioEffect effect = new AudioEffect(AudioEffect.EFFECT_TYPE_EQUALIZER,
@@ -155,10 +165,11 @@
}
//Test case 1.4: test contructor on mediaPlayer audio session
+ @Test
public void test1_4InsertOnMediaPlayer() throws Exception {
MediaPlayer mp = new MediaPlayer();
assertNotNull("could not create mediaplayer", mp);
- AssetFileDescriptor afd = mContext.getResources().openRawResourceFd(R.raw.testmp3);
+ AssetFileDescriptor afd = getContext().getResources().openRawResourceFd(R.raw.testmp3);
try {
mp.setDataSource(afd.getFileDescriptor(), afd.getStartOffset(), afd.getLength());
} finally {
@@ -177,6 +188,7 @@
}
//Test case 1.5: test auxiliary effect attachement on MediaPlayer
+ @Test
public void test1_5AuxiliaryOnMediaPlayer() throws Exception {
if (!isPresetReverbAvailable()) {
return;
@@ -187,7 +199,7 @@
waitForLooperInitialization_l();
mError = 0;
- AssetFileDescriptor afd = mContext.getResources().openRawResourceFd(R.raw.testmp3);
+ AssetFileDescriptor afd = getContext().getResources().openRawResourceFd(R.raw.testmp3);
try {
mMediaPlayer.setDataSource(afd.getFileDescriptor(),
afd.getStartOffset(),
@@ -215,6 +227,7 @@
}
//Test case 1.6: test auxiliary effect attachement failure before setDatasource
+ @Test
public void test1_6AuxiliaryOnMediaPlayerFailure() throws Exception {
if (!isPresetReverbAvailable()) {
return;
@@ -249,6 +262,7 @@
//Test case 1.7: test auxiliary effect attachement on AudioTrack
+ @Test
public void test1_7AuxiliaryOnAudioTrack() throws Exception {
if (!isPresetReverbAvailable()) {
return;
@@ -293,6 +307,7 @@
//Test case 2.0: test setEnabled() and getEnabled() in valid state
+ @Test
public void test2_0SetEnabledGetEnabled() throws Exception {
try {
AudioEffect effect = new AudioEffect(AudioEffect.EFFECT_TYPE_EQUALIZER,
@@ -320,6 +335,7 @@
}
//Test case 2.1: test setEnabled() throws exception after release
+ @Test
public void test2_1SetEnabledAfterRelease() throws Exception {
try {
AudioEffect effect = new AudioEffect(AudioEffect.EFFECT_TYPE_EQUALIZER,
@@ -346,6 +362,7 @@
//----------------------------------
//Test case 3.0: test setParameter(byte[], byte[]) / getParameter(byte[], byte[])
+ @Test
public void test3_0SetParameterByteArrayByteArray() throws Exception {
if (!isPresetReverbAvailable()) {
return;
@@ -380,6 +397,7 @@
}
//Test case 3.1: test setParameter(int, int) / getParameter(int, int[])
+ @Test
public void test3_1SetParameterIntInt() throws Exception {
if (!isEnvReverbAvailable()) {
return;
@@ -414,6 +432,7 @@
}
//Test case 3.2: test setParameter(int, short) / getParameter(int, short[])
+ @Test
public void test3_2SetParameterIntShort() throws Exception {
if (!isPresetReverbAvailable()) {
return;
@@ -446,6 +465,7 @@
}
//Test case 3.3: test setParameter(int, byte[]) / getParameter(int, byte[])
+ @Test
public void test3_3SetParameterIntByteArray() throws Exception {
if (!isEnvReverbAvailable()) {
return;
@@ -482,6 +502,7 @@
}
//Test case 3.4: test setParameter(int[], int[]) / getParameter(int[], int[])
+ @Test
public void test3_4SetParameterIntArrayIntArray() throws Exception {
if (!isEnvReverbAvailable()) {
return;
@@ -519,6 +540,7 @@
//Test case 3.5: test setParameter(int[], short[]) / getParameter(int[], short[])
+ @Test
public void test3_5SetParameterIntArrayShortArray() throws Exception {
if (!isPresetReverbAvailable()) {
return;
@@ -553,6 +575,7 @@
}
//Test case 3.6: test setParameter(int[], byte[]) / getParameter(int[], byte[])
+ @Test
public void test3_6SetParameterIntArrayByteArray() throws Exception {
if (!isEnvReverbAvailable()) {
return;
@@ -590,6 +613,7 @@
}
//Test case 3.7: test setParameter() throws exception after release()
+ @Test
public void test3_7SetParameterAfterRelease() throws Exception {
if (!isPresetReverbAvailable()) {
return;
@@ -618,6 +642,7 @@
}
//Test case 3.8: test getParameter() throws exception after release()
+ @Test
public void test3_8GetParameterAfterRelease() throws Exception {
if (!isPresetReverbAvailable()) {
return;
@@ -651,6 +676,7 @@
//----------------------------------
//Test case 4.0: test control passed to higher priority client
+ @Test
public void test4_0setEnabledLowerPriority() throws Exception {
AudioEffect effect1 = null;
AudioEffect effect2 = null;
@@ -689,6 +715,7 @@
}
//Test case 4.1: test control passed to higher priority client
+ @Test
public void test4_1setParameterLowerPriority() throws Exception {
if (!isPresetReverbAvailable()) {
return;
@@ -741,6 +768,7 @@
}
//Test case 4.2: test control status listener
+ @Test
public void test4_2ControlStatusListener() throws Exception {
if (!isPresetReverbAvailable()) {
return;
@@ -766,6 +794,7 @@
}
//Test case 4.3: test enable status listener
+ @Test
public void test4_3EnableStatusListener() throws Exception {
if (!isPresetReverbAvailable()) {
return;
@@ -795,6 +824,7 @@
}
//Test case 4.4: test parameter changed listener
+ @Test
public void test4_4ParameterChangedListener() throws Exception {
if (!isPresetReverbAvailable()) {
return;
@@ -831,6 +861,7 @@
//Test case 5.0: test command method
+ @Test
public void test5_0Command() throws Exception {
if (!isPresetReverbAvailable()) {
return;
diff --git a/tests/tests/media/audio/src/android/media/audio/cts/BassBoostTest.java b/tests/tests/media/audio/src/android/media/audio/cts/BassBoostTest.java
index c45bec0..aacfe57 100644
--- a/tests/tests/media/audio/src/android/media/audio/cts/BassBoostTest.java
+++ b/tests/tests/media/audio/src/android/media/audio/cts/BassBoostTest.java
@@ -16,6 +16,12 @@
package android.media.audio.cts;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
import android.media.audiofx.AudioEffect;
import android.media.AudioFormat;
import android.media.AudioManager;
@@ -25,6 +31,8 @@
import android.test.AndroidTestCase;
import android.util.Log;
+import org.junit.Test;
+
@NonMediaMainlineTest
public class BassBoostTest extends PostProcTestBase {
@@ -47,6 +55,7 @@
//----------------------------------
//Test case 0.0: test constructor and release
+ @Test
public void test0_0ConstructorAndRelease() throws Exception {
if (!isBassBoostAvailable()) {
return;
@@ -77,6 +86,7 @@
//----------------------------------
//Test case 1.0: test strength
+ @Test
public void test1_0Strength() throws Exception {
if (!isBassBoostAvailable()) {
return;
@@ -109,6 +119,7 @@
}
//Test case 1.1: test properties
+ @Test
public void test1_1Properties() throws Exception {
if (!isBassBoostAvailable()) {
return;
@@ -146,6 +157,7 @@
}
//Test case 1.2: test setStrength() throws exception after release
+ @Test
public void test1_2SetStrengthAfterRelease() throws Exception {
if (!isBassBoostAvailable()) {
return;
@@ -167,6 +179,7 @@
//----------------------------------
//Test case 2.0: test setEnabled() and getEnabled() in valid state
+ @Test
public void test2_0SetEnabledGetEnabled() throws Exception {
if (!isBassBoostAvailable()) {
return;
@@ -186,6 +199,7 @@
}
//Test case 2.1: test setEnabled() throws exception after release
+ @Test
public void test2_1SetEnabledAfterRelease() throws Exception {
if (!isBassBoostAvailable()) {
return;
@@ -207,6 +221,7 @@
//----------------------------------
//Test case 3.0: test control status listener
+ @Test
public void test3_0ControlStatusListener() throws Exception {
if (!isBassBoostAvailable()) {
return;
@@ -232,6 +247,7 @@
}
//Test case 3.1: test enable status listener
+ @Test
public void test3_1EnableStatusListener() throws Exception {
if (!isBassBoostAvailable()) {
return;
@@ -259,6 +275,7 @@
}
//Test case 3.2: test parameter changed listener
+ @Test
public void test3_2ParameterChangedListener() throws Exception {
if (!isBassBoostAvailable()) {
return;
diff --git a/tests/tests/media/audio/src/android/media/audio/cts/DynamicsProcessingTest.java b/tests/tests/media/audio/src/android/media/audio/cts/DynamicsProcessingTest.java
index 2caca2b..e10d805 100644
--- a/tests/tests/media/audio/src/android/media/audio/cts/DynamicsProcessingTest.java
+++ b/tests/tests/media/audio/src/android/media/audio/cts/DynamicsProcessingTest.java
@@ -18,6 +18,10 @@
import android.media.audio.cts.R;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
import android.content.Context;
import android.media.AudioFormat;
import android.media.AudioManager;
@@ -36,6 +40,8 @@
import android.test.AndroidTestCase;
import android.util.Log;
+import org.junit.Test;
+
public class DynamicsProcessingTest extends PostProcTestBase {
private static final String TAG = "DynamicsProcessingTest";
@@ -71,6 +77,7 @@
// Test case 0.0: test constructor and release
@AppModeFull(reason = "Fails for instant but not enough to block the release")
+ @Test
public void test0_0ConstructorAndRelease() throws Exception {
if (!hasAudioOutput()) {
return;
@@ -89,6 +96,7 @@
}
}
+ @Test
public void test0_1ConstructorWithConfigAndRelease() throws Exception {
if (!hasAudioOutput()) {
return;
@@ -104,6 +112,7 @@
// 1 - create with parameters
// ----------------------------------
+ @Test
public void test1_0ParametersEngine() throws Exception {
if (!hasAudioOutput()) {
return;
@@ -131,6 +140,7 @@
}
}
+ @Test
public void test1_1ParametersChannel() throws Exception {
if (!hasAudioOutput()) {
return;
@@ -151,6 +161,7 @@
}
}
+ @Test
public void test1_2ParametersPreEq() throws Exception {
if (!hasAudioOutput()) {
return;
@@ -171,6 +182,7 @@
}
}
+ @Test
public void test1_3ParametersMbc() throws Exception {
if (!hasAudioOutput()) {
return;
@@ -190,6 +202,7 @@
}
}
+ @Test
public void test1_4ParametersPostEq() throws Exception {
if (!hasAudioOutput()) {
return;
@@ -209,6 +222,7 @@
}
}
+ @Test
public void test1_5ParametersLimiter() throws Exception {
if (!hasAudioOutput()) {
return;
@@ -226,6 +240,7 @@
}
}
+ @Test
public void test1_6Channel_perStage() throws Exception {
if (!hasAudioOutput()) {
return;
@@ -323,6 +338,7 @@
}
+ @Test
public void test1_7Channel_perBand() throws Exception {
if (!hasAudioOutput()) {
return;
@@ -391,6 +407,7 @@
}
}
+ @Test
public void test1_8Channel_setAllChannelsTo() throws Exception {
if (!hasAudioOutput()) {
return;
@@ -447,6 +464,7 @@
}
}
+ @Test
public void test1_9Channel_setChannelTo() throws Exception {
if (!hasAudioOutput()) {
return;
@@ -520,6 +538,7 @@
// 2 - config builder tests
// ----------------------------------
+ @Test
public void test2_0ConfigBasic() throws Exception {
if (!hasAudioOutput()) {
return;
@@ -543,9 +562,10 @@
assertEquals("isLimiterInUse is different", DEFAULT_LIMITER_IN_USE,
config.isLimiterInUse());
assertEquals("getPreferredFrameDuration is different", DEFAULT_FRAME_DURATION,
- config.getPreferredFrameDuration());
+ config.getPreferredFrameDuration(), EPSILON);
}
+ @Test
public void test2_1ConfigChannel() throws Exception {
if (!hasAudioOutput()) {
return;
@@ -635,6 +655,7 @@
}
}
+ @Test
public void test2_2ConfigChannel_perStage() throws Exception {
if (!hasAudioOutput()) {
return;
@@ -724,6 +745,7 @@
}
}
+ @Test
public void test2_3ConfigChannel_perBand() throws Exception {
if (!hasAudioOutput()) {
return;
@@ -780,6 +802,7 @@
}
}
+ @Test
public void test2_4Channel_perStage() throws Exception {
if (!hasAudioOutput()) {
return;
@@ -843,6 +866,7 @@
}
+ @Test
public void test2_5Channel_perBand() throws Exception {
if (!hasAudioOutput()) {
return;
@@ -886,6 +910,7 @@
TEST_GAIN2, channel.getPostEqBand(TEST_BAND_INDEX).getGain(), EPSILON);
}
+ @Test
public void test2_6Eq() throws Exception {
if (!hasAudioOutput()) {
return;
@@ -935,6 +960,7 @@
}
}
+ @Test
public void test2_7Mbc() throws Exception {
if (!hasAudioOutput()) {
return;
@@ -1033,6 +1059,7 @@
}
}
+ @Test
public void test2_8Limiter() throws Exception {
if (!hasAudioOutput()) {
return;
@@ -1096,6 +1123,7 @@
newPostGain, limiter.getPostGain(), EPSILON);
}
+ @Test
public void test2_9BandStage() throws Exception {
if (!hasAudioOutput()) {
return;
@@ -1115,6 +1143,7 @@
assertEquals("bandStage enabled is different", !enabled, bandStage.isEnabled());
}
+ @Test
public void test2_10Stage() throws Exception {
if (!hasAudioOutput()) {
return;
@@ -1133,6 +1162,7 @@
assertEquals("stage enabled is different", !enabled, stage.isEnabled());
}
+ @Test
public void test2_11BandBase() throws Exception {
if (!hasAudioOutput()) {
return;
@@ -1156,6 +1186,7 @@
newFrequency, bandBase.getCutoffFrequency(), EPSILON);
}
+ @Test
public void test2_12Channel() throws Exception {
if (!hasAudioOutput()) {
return;
@@ -1192,6 +1223,7 @@
// 3 - Builder
// ----------------------------------
+ @Test
public void test3_0Builder_stagesAllChannels() throws Exception {
if (!hasAudioOutput()) {
return;
@@ -1245,6 +1277,7 @@
}
}
+ @Test
public void test3_1Builder_stagesByChannelIndex() throws Exception {
if (!hasAudioOutput()) {
return;
@@ -1315,6 +1348,7 @@
}
}
+ @Test
public void test3_2Builder_setAllChannelsTo() throws Exception {
if (!hasAudioOutput()) {
return;
@@ -1371,6 +1405,7 @@
}
}
+ @Test
public void test3_3Builder_setChannelTo() throws Exception {
if (!hasAudioOutput()) {
return;
diff --git a/tests/tests/media/audio/src/android/media/audio/cts/EnvReverbTest.java b/tests/tests/media/audio/src/android/media/audio/cts/EnvReverbTest.java
index 46bf786..b258781 100644
--- a/tests/tests/media/audio/src/android/media/audio/cts/EnvReverbTest.java
+++ b/tests/tests/media/audio/src/android/media/audio/cts/EnvReverbTest.java
@@ -16,6 +16,12 @@
package android.media.audio.cts;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
import android.media.audiofx.AudioEffect;
import android.media.AudioFormat;
import android.media.AudioManager;
@@ -26,6 +32,8 @@
import android.test.AndroidTestCase;
import android.util.Log;
+import org.junit.Test;
+
@NonMediaMainlineTest
@AppModeFull(reason = "Fails in instant mode")
public class EnvReverbTest extends PostProcTestBase {
@@ -49,6 +57,7 @@
//----------------------------------
//Test case 0.0: test constructor and release
+ @Test
public void test0_0ConstructorAndRelease() throws Exception {
if (!isEnvReverbAvailable()) {
return;
@@ -78,6 +87,7 @@
//----------------------------------
//Test case 1.0: test room level and room HF level
+ @Test
public void test1_0Room() throws Exception {
if (!isEnvReverbAvailable()) {
return;
@@ -112,6 +122,7 @@
}
//Test case 1.1: test decay time and ratio
+ @Test
public void test1_1Decay() throws Exception {
if (!isEnvReverbAvailable()) {
return;
@@ -146,6 +157,7 @@
//Test case 1.2: test reverb level and delay
+ @Test
public void test1_2Reverb() throws Exception {
if (!isEnvReverbAvailable()) {
return;
@@ -182,6 +194,7 @@
}
//Test case 1.3: test early reflections level and delay
+ @Test
public void test1_3Reflections() throws Exception {
if (!isEnvReverbAvailable()) {
return;
@@ -223,6 +236,7 @@
}
//Test case 1.4: test diffusion and density
+ @Test
public void test1_4DiffusionAndDensity() throws Exception {
if (!isEnvReverbAvailable()) {
return;
@@ -257,6 +271,7 @@
}
//Test case 1.5: test properties
+ @Test
public void test1_5Properties() throws Exception {
if (!isEnvReverbAvailable()) {
return;
@@ -289,6 +304,7 @@
//----------------------------------
//Test case 2.0: test setEnabled() and getEnabled() in valid state
+ @Test
public void test2_0SetEnabledGetEnabled() throws Exception {
if (!isEnvReverbAvailable()) {
return;
@@ -307,6 +323,7 @@
}
//Test case 2.1: test setEnabled() throws exception after release
+ @Test
public void test2_1SetEnabledAfterRelease() throws Exception {
if (!isEnvReverbAvailable()) {
return;
@@ -328,6 +345,7 @@
//----------------------------------
//Test case 3.0: test control status listener
+ @Test
public void test3_0ControlStatusListener() throws Exception {
if (!isEnvReverbAvailable()) {
return;
@@ -353,6 +371,7 @@
}
//Test case 3.1: test enable status listener
+ @Test
public void test3_1EnableStatusListener() throws Exception {
if (!isEnvReverbAvailable()) {
return;
@@ -380,6 +399,7 @@
}
//Test case 3.2: test parameter changed listener
+ @Test
public void test3_2ParameterChangedListener() throws Exception {
if (!isEnvReverbAvailable()) {
return;
diff --git a/tests/tests/media/audio/src/android/media/audio/cts/EqualizerTest.java b/tests/tests/media/audio/src/android/media/audio/cts/EqualizerTest.java
index a45e1ce..220c43f 100644
--- a/tests/tests/media/audio/src/android/media/audio/cts/EqualizerTest.java
+++ b/tests/tests/media/audio/src/android/media/audio/cts/EqualizerTest.java
@@ -16,6 +16,12 @@
package android.media.audio.cts;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
import android.media.audiofx.AudioEffect;
import android.media.AudioFormat;
import android.media.AudioManager;
@@ -25,6 +31,8 @@
import android.test.AndroidTestCase;
import android.util.Log;
+import org.junit.Test;
+
@NonMediaMainlineTest
public class EqualizerTest extends PostProcTestBase {
@@ -50,6 +58,7 @@
//----------------------------------
//Test case 0.0: test constructor and release
+ @Test
public void test0_0ConstructorAndRelease() throws Exception {
Equalizer eq = null;
try {
@@ -76,6 +85,7 @@
//----------------------------------
//Test case 1.0: test setBandLevel() and getBandLevel()
+ @Test
public void test1_0BandLevel() throws Exception {
getEqualizer(getSessionId());
try {
@@ -105,6 +115,7 @@
}
//Test case 1.1: test band frequency
+ @Test
public void test1_1BandFrequency() throws Exception {
getEqualizer(getSessionId());
try {
@@ -130,6 +141,7 @@
}
//Test case 1.2: test presets
+ @Test
public void test1_2Presets() throws Exception {
getEqualizer(getSessionId());
try {
@@ -155,6 +167,7 @@
}
//Test case 1.3: test properties
+ @Test
public void test1_3Properties() throws Exception {
getEqualizer(getSessionId());
try {
@@ -186,6 +199,7 @@
}
//Test case 1.4: test setBandLevel() throws exception after release
+ @Test
public void test1_4SetBandLevelAfterRelease() throws Exception {
getEqualizer(getSessionId());
mEqualizer.release();
@@ -203,6 +217,7 @@
//----------------------------------
//Test case 2.0: test setEnabled() and getEnabled() in valid state
+ @Test
public void test2_0SetEnabledGetEnabled() throws Exception {
getEqualizer(getSessionId());
try {
@@ -219,6 +234,7 @@
}
//Test case 2.1: test setEnabled() throws exception after release
+ @Test
public void test2_1SetEnabledAfterRelease() throws Exception {
getEqualizer(getSessionId());
mEqualizer.release();
@@ -236,6 +252,7 @@
//----------------------------------
//Test case 3.0: test control status listener
+ @Test
public void test3_0ControlStatusListener() throws Exception {
synchronized(mLock) {
mHasControl = true;
@@ -258,6 +275,7 @@
}
//Test case 3.1: test enable status listener
+ @Test
public void test3_1EnableStatusListener() throws Exception {
synchronized(mLock) {
mInitialized = false;
@@ -282,6 +300,7 @@
}
//Test case 3.2: test parameter changed listener
+ @Test
public void test3_2ParameterChangedListener() throws Exception {
synchronized(mLock) {
mInitialized = false;
diff --git a/tests/tests/media/audio/src/android/media/audio/cts/HapticGeneratorTest.java b/tests/tests/media/audio/src/android/media/audio/cts/HapticGeneratorTest.java
index 0463e35..b1a400b 100644
--- a/tests/tests/media/audio/src/android/media/audio/cts/HapticGeneratorTest.java
+++ b/tests/tests/media/audio/src/android/media/audio/cts/HapticGeneratorTest.java
@@ -16,10 +16,16 @@
package android.media.audio.cts;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
import android.media.AudioManager;
import android.media.audiofx.HapticGenerator;
import android.media.cts.NonMediaMainlineTest;
+import org.junit.Test;
+
@NonMediaMainlineTest
public class HapticGeneratorTest extends PostProcTestBase {
@@ -34,6 +40,7 @@
//----------------------------------
//Test case 0.0: test constructor and release
+ @Test
public void test0_0ConstructorAndRelease() throws Exception {
if (!HapticGenerator.isAvailable()) {
// HapticGenerator will only be created on devices supporting haptic playback
@@ -45,6 +52,7 @@
}
// Test case 0.1: test constructor and close
+ @Test
public void test0_1ConstructorAndClose() throws Exception {
if (!HapticGenerator.isAvailable()) {
// HapticGenerator will only be created on devices supporting haptic playback
@@ -60,6 +68,7 @@
//----------------------------------
//Test case 1.0: test setEnabled() and getEnabled() in valid state
+ @Test
public void test1_0SetEnabledGetEnabled() throws Exception {
if (!HapticGenerator.isAvailable()) {
// HapticGenerator will only be created on devices supporting haptic playback
diff --git a/tests/tests/media/audio/src/android/media/audio/cts/LoudnessEnhancerTest.java b/tests/tests/media/audio/src/android/media/audio/cts/LoudnessEnhancerTest.java
index ef43381..4e2f682 100644
--- a/tests/tests/media/audio/src/android/media/audio/cts/LoudnessEnhancerTest.java
+++ b/tests/tests/media/audio/src/android/media/audio/cts/LoudnessEnhancerTest.java
@@ -16,28 +16,38 @@
package android.media.audio.cts;
-import android.media.audio.cts.R;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
import android.content.Context;
-import android.media.audiofx.AudioEffect;
import android.media.AudioFormat;
import android.media.AudioManager;
import android.media.MediaPlayer;
+import android.media.audio.cts.R;
+import android.media.audiofx.AudioEffect;
import android.media.audiofx.LoudnessEnhancer;
-import android.platform.test.annotations.AppModeFull;
-import java.util.UUID;
import android.media.audiofx.Visualizer;
import android.media.audiofx.Visualizer.MeasurementPeakRms;
+import android.platform.test.annotations.AppModeFull;
import android.os.Looper;
import android.test.AndroidTestCase;
import android.util.Log;
+import org.junit.Test;
+
+import java.util.UUID;
+
@AppModeFull(reason = "Dynamic config disabled.")
public class LoudnessEnhancerTest extends PostProcTestBase {
private String TAG = "LoudnessEnhancerTest";
private LoudnessEnhancer mLE;
+ private static final float EPSILON = 0.00001f;
+
//-----------------------------------------------------------------
// LOUDNESS ENHANCER TESTS:
//----------------------------------
@@ -47,6 +57,7 @@
//----------------------------------
//Test case 0.0: test constructor and release
+ @Test
public void test0_0ConstructorAndRelease() throws Exception {
if (!hasAudioOutput()) {
return;
@@ -67,6 +78,7 @@
//----------------------------------
//Test case 1.0: test set/get target gain
+ @Test
public void test1_0TargetGain() throws Exception {
if (!hasAudioOutput()) {
return;
@@ -74,9 +86,11 @@
getLoudnessEnhancer(0);
try {
mLE.setTargetGain(0);
- assertEquals("target gain differs from value set", 0.0f, mLE.getTargetGain());
+ assertEquals("target gain differs from value set",
+ 0.0f, mLE.getTargetGain(), EPSILON);
mLE.setTargetGain(800);
- assertEquals("target gain differs from value set", 800.0f, mLE.getTargetGain());
+ assertEquals("target gain differs from value set",
+ 800.0f, mLE.getTargetGain(), EPSILON);
} catch (IllegalArgumentException e) {
fail("target gain illegal argument");
} catch (UnsupportedOperationException e) {
@@ -93,6 +107,7 @@
//----------------------------------
//Test case 2.0: test setEnabled() and getEnabled() in valid state
+ @Test
public void test2_0SetEnabledGetEnabled() throws Exception {
if (!hasAudioOutput()) {
return;
@@ -112,6 +127,7 @@
}
//Test case 2.1: test setEnabled() throws exception after release
+ @Test
public void test2_1SetEnabledAfterRelease() throws Exception {
if (!hasAudioOutput()) {
return;
@@ -133,6 +149,7 @@
//----------------------------------
//Test case 3.0: test loudness gain change in audio
+ @Test
public void test3_0MeasureGainChange() throws Exception {
if (!hasAudioOutput()) {
return;
@@ -195,7 +212,7 @@
//run for a new set of 3 seconds, get new measurement
mLE.setTargetGain(LOUDNESS_GAIN);
assertEquals("target gain differs from value set", (float)LOUDNESS_GAIN,
- mLE.getTargetGain());
+ mLE.getTargetGain(), EPSILON);
mLE.setEnabled(true);
@@ -257,4 +274,4 @@
mLE = null;
}
}
-}
\ No newline at end of file
+}
diff --git a/tests/tests/media/audio/src/android/media/audio/cts/PostProcTestBase.java b/tests/tests/media/audio/src/android/media/audio/cts/PostProcTestBase.java
index 8296138..6328d30 100644
--- a/tests/tests/media/audio/src/android/media/audio/cts/PostProcTestBase.java
+++ b/tests/tests/media/audio/src/android/media/audio/cts/PostProcTestBase.java
@@ -16,21 +16,32 @@
package android.media.audio.cts;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assume.assumeFalse;
+
import android.content.Context;
import android.content.pm.PackageManager;
import android.media.AudioManager;
import android.media.audiofx.AudioEffect;
import android.os.Looper;
-import android.test.AndroidTestCase;
+
+import androidx.test.InstrumentationRegistry;
+import androidx.test.runner.AndroidJUnit4;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.runner.RunWith;
import java.lang.Boolean;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
-public class PostProcTestBase extends AndroidTestCase {
+@RunWith(AndroidJUnit4.class)
+public class PostProcTestBase {
private static final int CONTROL_PRIORITY = 100;
-
protected int mSession = -1;
protected boolean mHasControl = false;
protected boolean mIsEnabled = false;
@@ -43,14 +54,17 @@
private Map<UUID, Boolean> mOriginalEffectState = new HashMap<>();
+ protected static Context getContext() {
+ return InstrumentationRegistry.getInstrumentation().getContext();
+ }
+
/**
* All potential effects under test are disabled at setup.
* Initial state is backuped, restored in tearDown
* @throws Exception
*/
- @Override
- protected void setUp() throws Exception {
- super.setUp();
+ @Before
+ public void setUp() throws Exception {
final UUID[] effectTypes = {
AudioEffect.EFFECT_TYPE_BASS_BOOST,
@@ -76,13 +90,15 @@
} catch (IllegalStateException e) {
} catch (IllegalArgumentException e) {
} catch (UnsupportedOperationException e) {
+ } catch (RuntimeException e) {
+ assumeFalse("skipping for instant",
+ getContext().getPackageManager().isInstantApp());
}
}
}
- @Override
- protected void tearDown() throws Exception {
- super.tearDown();
+ @After
+ public void tearDown() throws Exception {
for (Map.Entry<UUID, Boolean> entry : mOriginalEffectState.entrySet()) {
try {
AudioEffect effect = new AudioEffect(entry.getKey(),
diff --git a/tests/tests/media/audio/src/android/media/audio/cts/PresetReverbTest.java b/tests/tests/media/audio/src/android/media/audio/cts/PresetReverbTest.java
index b3c32db..603398a 100644
--- a/tests/tests/media/audio/src/android/media/audio/cts/PresetReverbTest.java
+++ b/tests/tests/media/audio/src/android/media/audio/cts/PresetReverbTest.java
@@ -16,9 +16,15 @@
package android.media.audio.cts;
-import android.media.audiofx.AudioEffect;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
import android.media.AudioFormat;
import android.media.AudioManager;
+import android.media.audiofx.AudioEffect;
import android.media.audiofx.PresetReverb;
import android.media.cts.NonMediaMainlineTest;
import android.os.Looper;
@@ -26,6 +32,8 @@
import android.test.AndroidTestCase;
import android.util.Log;
+import org.junit.Test;
+
@NonMediaMainlineTest
@AppModeFull(reason = "TODO: evaluate and port to instant")
public class PresetReverbTest extends PostProcTestBase {
@@ -48,6 +56,7 @@
//----------------------------------
//Test case 0.0: test constructor and release
+ @Test
public void test0_0ConstructorAndRelease() throws Exception {
if (!isPresetReverbAvailable()) {
return;
@@ -76,6 +85,7 @@
//----------------------------------
//Test case 1.0: test presets
+ @Test
public void test1_0Presets() throws Exception {
if (!isPresetReverbAvailable()) {
return;
@@ -100,6 +110,7 @@
}
//Test case 1.1: test properties
+ @Test
public void test1_1Properties() throws Exception {
if (!isPresetReverbAvailable()) {
return;
@@ -131,6 +142,7 @@
//----------------------------------
//Test case 2.0: test setEnabled() and getEnabled() in valid state
+ @Test
public void test2_0SetEnabledGetEnabled() throws Exception {
if (!isPresetReverbAvailable()) {
return;
@@ -149,6 +161,7 @@
}
//Test case 2.1: test setEnabled() throws exception after release
+ @Test
public void test2_1SetEnabledAfterRelease() throws Exception {
if (!isPresetReverbAvailable()) {
return;
@@ -169,6 +182,7 @@
//----------------------------------
//Test case 3.0: test control status listener
+ @Test
public void test3_0ControlStatusListener() throws Exception {
if (!isPresetReverbAvailable()) {
return;
@@ -194,6 +208,7 @@
}
//Test case 3.1: test enable status listener
+ @Test
public void test3_1EnableStatusListener() throws Exception {
if (!isPresetReverbAvailable()) {
return;
@@ -221,6 +236,7 @@
}
//Test case 3.2: test parameter changed listener
+ @Test
public void test3_2ParameterChangedListener() throws Exception {
if (!isPresetReverbAvailable()) {
return;
diff --git a/tests/tests/media/audio/src/android/media/audio/cts/VirtualizerTest.java b/tests/tests/media/audio/src/android/media/audio/cts/VirtualizerTest.java
index 7392d35..99d949a3 100644
--- a/tests/tests/media/audio/src/android/media/audio/cts/VirtualizerTest.java
+++ b/tests/tests/media/audio/src/android/media/audio/cts/VirtualizerTest.java
@@ -16,9 +16,16 @@
package android.media.audio.cts;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
import android.content.Context;
-import android.media.audiofx.AudioEffect;
import android.media.AudioFormat;
+import android.media.audio.cts.R;
+import android.media.audiofx.AudioEffect;
import android.media.audiofx.Virtualizer;
import android.media.cts.NonMediaMainlineTest;
import android.os.Looper;
@@ -26,7 +33,7 @@
import android.test.AndroidTestCase;
import android.util.Log;
-import android.media.audio.cts.R;
+import org.junit.Test;
import java.util.Arrays;
@@ -53,6 +60,7 @@
//----------------------------------
//Test case 0.0: test constructor and release
+ @Test
public void test0_0ConstructorAndRelease() throws Exception {
if (!isVirtualizerAvailable()) {
return;
@@ -83,6 +91,7 @@
//----------------------------------
//Test case 1.0: test strength
+ @Test
public void test1_0Strength() throws Exception {
if (!isVirtualizerAvailable()) {
return;
@@ -115,6 +124,7 @@
}
//Test case 1.1: test properties
+ @Test
public void test1_1Properties() throws Exception {
if (!isVirtualizerAvailable()) {
return;
@@ -152,6 +162,7 @@
}
//Test case 1.2: test setStrength() throws exception after release
+ @Test
public void test1_2SetStrengthAfterRelease() throws Exception {
if (!isVirtualizerAvailable()) {
return;
@@ -173,6 +184,7 @@
//----------------------------------
//Test case 2.0: test setEnabled() and getEnabled() in valid state
+ @Test
public void test2_0SetEnabledGetEnabled() throws Exception {
if (!isVirtualizerAvailable()) {
return;
@@ -192,6 +204,7 @@
}
//Test case 2.1: test setEnabled() throws exception after release
+ @Test
public void test2_1SetEnabledAfterRelease() throws Exception {
if (!isVirtualizerAvailable()) {
return;
@@ -213,6 +226,7 @@
//----------------------------------
//Test case 3.0: test control status listener
+ @Test
public void test3_0ControlStatusListener() throws Exception {
if (!isVirtualizerAvailable()) {
return;
@@ -239,6 +253,7 @@
}
//Test case 3.1: test enable status listener
+ @Test
public void test3_1EnableStatusListener() throws Exception {
if (!isVirtualizerAvailable()) {
return;
@@ -267,6 +282,7 @@
}
//Test case 3.2: test parameter changed listener
+ @Test
public void test3_2ParameterChangedListener() throws Exception {
if (!isVirtualizerAvailable()) {
return;
@@ -303,6 +319,7 @@
// combinations must be supported, otherwise the effect doesn't really qualify as
// a virtualizer: AudioFormat.CHANNEL_OUT_STEREO or the quad and 5.1 side/back variants,
// in VIRTUALIZATION_MODE_BINAURAL or VIRTUALIZATION_MODE_TRANSAURAL
+ @Test
public void test4_0FormatModeQuery() throws Exception {
if (!isVirtualizerAvailable()) {
return;
@@ -343,6 +360,7 @@
//Test case 4.1: test that the capabilities reported by Virtualizer.canVirtualize(int,int)
// matches those returned by Virtualizer.getSpeakerAngles(int, int, int[])
+ @Test
public void test4_1SpeakerAnglesCapaMatchesFormatModeCapa() throws Exception {
if (!isVirtualizerAvailable()) {
return;
@@ -386,6 +404,7 @@
//Test case 4.2: test forcing virtualization mode: at least binaural or transaural must be
// supported
+ @Test
public void test4_2VirtualizationMode() throws Exception {
if (!isVirtualizerAvailable()) {
return;
@@ -415,6 +434,7 @@
}
//Test case 4.3: test disabling virtualization maps to VIRTUALIZATION_MODE_OFF
+ @Test
public void test4_3DisablingVirtualizationOff() throws Exception {
if (!isVirtualizerAvailable()) {
return;
@@ -438,6 +458,7 @@
}
//Test case 4.4: test forcing virtualization mode to AUTO
+ @Test
public void test4_4VirtualizationModeAuto() throws Exception {
if (!isVirtualizerAvailable()) {
return;
@@ -462,6 +483,7 @@
}
//Test case 4.5: test for consistent capabilities if virtualizer is enabled or disabled
+ @Test
public void test4_5ConsistentCapabilitiesWithEnabledDisabled() throws Exception {
if (!isVirtualizerAvailable()) {
return;
diff --git a/tests/tests/media/audio/src/android/media/audio/cts/VisualizerTest.java b/tests/tests/media/audio/src/android/media/audio/cts/VisualizerTest.java
index 851ec9c0..17dac03 100644
--- a/tests/tests/media/audio/src/android/media/audio/cts/VisualizerTest.java
+++ b/tests/tests/media/audio/src/android/media/audio/cts/VisualizerTest.java
@@ -16,21 +16,28 @@
package android.media.audio.cts;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
import android.content.Context;
-import android.media.audiofx.AudioEffect;
import android.media.AudioFormat;
import android.media.AudioManager;
import android.media.MediaPlayer;
import android.media.audio.cts.R;
+import android.media.audiofx.AudioEffect;
import android.media.audiofx.Visualizer;
import android.media.audiofx.Visualizer.MeasurementPeakRms;
import android.media.cts.Preconditions;
import android.os.Looper;
import android.platform.test.annotations.AppModeFull;
import android.test.AndroidTestCase;
+import android.util.Log;
+
+import org.junit.Test;
import java.util.UUID;
-import android.util.Log;
@AppModeFull(reason = "TODO: evaluate and port to instant")
public class VisualizerTest extends PostProcTestBase {
@@ -57,6 +64,7 @@
//----------------------------------
//Test case 0.0: test constructor and release
+ @Test
public void test0_0ConstructorAndRelease() throws Exception {
Visualizer visualizer = null;
try {
@@ -78,6 +86,7 @@
//----------------------------------
//Test case 1.0: capture rates
+ @Test
public void test1_0CaptureRates() throws Exception {
getVisualizer(0);
try {
@@ -97,6 +106,7 @@
}
//Test case 1.1: test capture size
+ @Test
public void test1_1CaptureSize() throws Exception {
getVisualizer(0);
try {
@@ -127,6 +137,7 @@
//----------------------------------
//Test case 2.0: test capture in polling mode
+ @Test
public void test2_0PollingCapture() throws Exception {
if (!hasAudioOutput()) {
Log.w(TAG,"AUDIO_OUTPUT feature not found. This system might not have a valid "
@@ -159,6 +170,7 @@
}
//Test case 2.1: test capture with listener
+ @Test
public void test2_1ListenerCapture() throws Exception {
if (!hasAudioOutput()) {
Log.w(TAG,"AUDIO_OUTPUT feature not found. This system might not have a valid "
@@ -225,6 +237,7 @@
//----------------------------------
//Test case 3.0: test setting NONE measurement mode
+ @Test
public void test3_0MeasurementModeNone() throws Exception {
if (!hasAudioOutput()) {
return;
@@ -257,6 +270,7 @@
//----------------------------------
//Test case 4.0: test setting peak / RMS measurement mode
+ @Test
public void test4_0MeasurementModePeakRms() throws Exception {
if (!hasAudioOutput()) {
return;
@@ -285,6 +299,7 @@
}
//Test case 4.1: test measurement of peak / RMS
+ @Test
public void test4_1MeasurePeakRms() throws Exception {
if (!hasAudioOutput()) {
return;
@@ -358,6 +373,7 @@
}
//Test case 4.2: test measurement of peak / RMS in Long MP3
+ @Test
public void test4_2MeasurePeakRmsLongMP3() throws Exception {
if (!hasAudioOutput()) {
return;