Run Virtualizer test only when effect is available
Check whether the Virtualizer effect type is available
before attempting to run any test.
Bug 17496497
Change-Id: Ifbbfbb1f92421a14f35ed0eb1250489a58cc9e3e
diff --git a/tests/tests/media/src/android/media/cts/VirtualizerTest.java b/tests/tests/media/src/android/media/cts/VirtualizerTest.java
index 3d18c47..cac97b3 100644
--- a/tests/tests/media/src/android/media/cts/VirtualizerTest.java
+++ b/tests/tests/media/src/android/media/cts/VirtualizerTest.java
@@ -53,6 +53,10 @@
//Test case 0.0: test constructor and release
public void test0_0ConstructorAndRelease() throws Exception {
+ if (!isVirtualizerAvailable()) {
+ return;
+ }
+
Virtualizer eq = null;
try {
eq = new Virtualizer(0, 0);
@@ -80,6 +84,10 @@
//Test case 1.0: test strength
public void test1_0Strength() throws Exception {
+ if (!isVirtualizerAvailable()) {
+ return;
+ }
+
getVirtualizer(0);
try {
if (mVirtualizer.getStrengthSupported()) {
@@ -108,6 +116,10 @@
//Test case 1.1: test properties
public void test1_1Properties() throws Exception {
+ if (!isVirtualizerAvailable()) {
+ return;
+ }
+
getVirtualizer(0);
try {
Virtualizer.Settings settings = mVirtualizer.getProperties();
@@ -141,6 +153,10 @@
//Test case 1.2: test setStrength() throws exception after release
public void test1_2SetStrengthAfterRelease() throws Exception {
+ if (!isVirtualizerAvailable()) {
+ return;
+ }
+
getVirtualizer(0);
mVirtualizer.release();
try {
@@ -158,6 +174,10 @@
//Test case 2.0: test setEnabled() and getEnabled() in valid state
public void test2_0SetEnabledGetEnabled() throws Exception {
+ if (!isVirtualizerAvailable()) {
+ return;
+ }
+
getVirtualizer(0);
try {
mVirtualizer.setEnabled(true);
@@ -173,6 +193,10 @@
//Test case 2.1: test setEnabled() throws exception after release
public void test2_1SetEnabledAfterRelease() throws Exception {
+ if (!isVirtualizerAvailable()) {
+ return;
+ }
+
getVirtualizer(0);
mVirtualizer.release();
try {
@@ -190,6 +214,10 @@
//Test case 3.0: test control status listener
public void test3_0ControlStatusListener() throws Exception {
+ if (!isVirtualizerAvailable()) {
+ return;
+ }
+
synchronized(mLock) {
mHasControl = true;
mInitialized = false;
@@ -212,6 +240,10 @@
//Test case 3.1: test enable status listener
public void test3_1EnableStatusListener() throws Exception {
+ if (!isVirtualizerAvailable()) {
+ return;
+ }
+
synchronized(mLock) {
mInitialized = false;
createListenerLooper(false, true, false);
@@ -236,6 +268,10 @@
//Test case 3.2: test parameter changed listener
public void test3_2ParameterChangedListener() throws Exception {
+ if (!isVirtualizerAvailable()) {
+ return;
+ }
+
synchronized(mLock) {
mInitialized = false;
createListenerLooper(false, false, true);
@@ -263,6 +299,10 @@
// private methods
//----------------------------------
+ private boolean isVirtualizerAvailable() {
+ return AudioEffect.isEffectTypeAvailable(AudioEffect.EFFECT_TYPE_VIRTUALIZER);
+ }
+
private void getVirtualizer(int session) {
if (mVirtualizer == null || session != mSession) {
if (session != mSession && mVirtualizer != null) {