Adding tests for AudioAttribute AudioUsage converters
Bug: 171572311
Test: atest AudioAttributesTest
Change-Id: I5cb13331e1b6fcfdf13e0a5649f25c2cf9f5b0bf
Merged-In: I5cb13331e1b6fcfdf13e0a5649f25c2cf9f5b0bf
diff --git a/tests/tests/media/src/android/media/cts/AudioAttributesTest.java b/tests/tests/media/src/android/media/cts/AudioAttributesTest.java
index e44dc3a..f4e86eb 100644
--- a/tests/tests/media/src/android/media/cts/AudioAttributesTest.java
+++ b/tests/tests/media/src/android/media/cts/AudioAttributesTest.java
@@ -19,6 +19,7 @@
import static org.testng.Assert.assertThrows;
import static org.testng.Assert.expectThrows;
+import android.audio.policy.configuration.V7_0.AudioUsage;
import android.media.AudioAttributes;
import android.media.AudioManager;
import android.os.Parcel;
@@ -200,6 +201,27 @@
assertEquals(attr1, attr2);
}
+ // -----------------------------------------------------------------
+ // audio_policy_configuration.xsd converter tests
+ // ----------------------------------
+ public void testXsdStringToUsage_returnsCorrectUsage() {
+ int usage = AudioAttributes.xsdStringToUsage(AudioUsage.AUDIO_USAGE_MEDIA.toString());
+
+ assertEquals(AudioAttributes.USAGE_MEDIA, usage);
+ }
+
+ public void testXsdStringToUsage_withUnsupportedString_returnsUnknownUsage() {
+ int usage = AudioAttributes.xsdStringToUsage("not a usage");
+
+ assertEquals(AudioAttributes.USAGE_UNKNOWN, usage);
+ }
+
+ public void testUsageToXsdString_returnsCorrectString() {
+ String xsdUsage = AudioAttributes.usageToXsdString(AudioAttributes.USAGE_MEDIA);
+
+ assertEquals(AudioUsage.AUDIO_USAGE_MEDIA.toString(), xsdUsage);
+ }
+
// -------------------------------------------------------------------
// Reflection helpers for accessing system usage methods and fields
// -------------------------------------------------------------------