MediaBassBoostTestpublic class MediaBassBoostTest extends android.test.ActivityInstrumentationTestCase2 Junit / Instrumentation test case for the media AudioTrack api |
Fields Summary |
---|
private String | TAG | private static final short | TEST_STRENGTH | private android.media.audiofx.BassBoost | mBassBoost | private int | mSession |
Constructors Summary |
---|
public MediaBassBoostTest()
super("com.android.mediaframeworktest", MediaFrameworkTest.class);
|
Methods Summary |
---|
private static void | assumeTrue(java.lang.String message, boolean cond)
assertTrue("(assume)"+message, cond);
| private void | getBassBoost(int session)
if (mBassBoost == null || session != mSession) {
if (session != mSession && mBassBoost != null) {
mBassBoost.release();
mBassBoost = null;
}
try {
mBassBoost = new BassBoost(0, session);
mSession = session;
} catch (IllegalArgumentException e) {
Log.e(TAG, "getBassBoost() BassBoost not found exception: "+e);
} catch (UnsupportedOperationException e) {
Log.e(TAG, "getBassBoost() Effect library not loaded exception: "+e);
}
}
assertNotNull("could not create mBassBoost", mBassBoost);
| private void | log(java.lang.String testName, java.lang.String message)
Log.v(TAG, "["+testName+"] "+message);
| private void | loge(java.lang.String testName, java.lang.String message)
Log.e(TAG, "["+testName+"] "+message);
| private void | releaseBassBoost()
if (mBassBoost != null) {
mBassBoost.release();
mBassBoost = null;
}
| protected void | setUp()
super.setUp();
| protected void | tearDown()
super.tearDown();
releaseBassBoost();
| public void | test0_0ConstructorAndRelease()
boolean result = false;
String msg = "test1_0ConstructorAndRelease()";
BassBoost bb = null;
try {
bb = new BassBoost(0, 0);
assertNotNull(msg + ": could not create BassBoost", bb);
try {
assertTrue(msg +": invalid effect ID", (bb.getId() != 0));
} catch (IllegalStateException e) {
msg = msg.concat(": BassBoost not initialized");
}
result = true;
} catch (IllegalArgumentException e) {
msg = msg.concat(": BassBoost not found");
} catch (UnsupportedOperationException e) {
msg = msg.concat(": Effect library not loaded");
} finally {
if (bb != null) {
bb.release();
}
}
assertTrue(msg, result);
| public void | test1_0Strength()
boolean result = false;
String msg = "test1_0Strength()";
getBassBoost(0);
try {
if (mBassBoost.getStrengthSupported()) {
mBassBoost.setStrength((short)TEST_STRENGTH);
short strength = mBassBoost.getRoundedStrength();
// allow 10% difference between set strength and rounded strength
assertTrue(msg +": got incorrect strength",
((float)strength > (float)TEST_STRENGTH * 0.9f) &&
((float)strength < (float)TEST_STRENGTH * 1.1f));
} else {
short strength = mBassBoost.getRoundedStrength();
assertTrue(msg +": got incorrect strength", strength >= 0 && strength <= 1000);
}
result = true;
} catch (IllegalArgumentException e) {
msg = msg.concat(": Bad parameter value");
loge(msg, "Bad parameter value");
} catch (UnsupportedOperationException e) {
msg = msg.concat(": get parameter() rejected");
loge(msg, "get parameter() rejected");
} catch (IllegalStateException e) {
msg = msg.concat("get parameter() called in wrong state");
loge(msg, "get parameter() called in wrong state");
} finally {
releaseBassBoost();
}
assertTrue(msg, result);
| public void | test1_1Properties()
boolean result = false;
String msg = "test1_1Properties()";
getBassBoost(0);
try {
BassBoost.Settings settings = mBassBoost.getProperties();
String str = settings.toString();
settings = new BassBoost.Settings(str);
mBassBoost.setProperties(settings);
result = true;
} catch (IllegalArgumentException e) {
msg = msg.concat(": Bad parameter value");
loge(msg, "Bad parameter value");
} catch (UnsupportedOperationException e) {
msg = msg.concat(": get parameter() rejected");
loge(msg, "get parameter() rejected");
} catch (IllegalStateException e) {
msg = msg.concat("get parameter() called in wrong state");
loge(msg, "get parameter() called in wrong state");
} finally {
releaseBassBoost();
}
assertTrue(msg, result);
|
|