VolumeShaperTest: Use JUnitParamsRunner

This allows splitting a large test into smaller
parameterized tests.

Test: atest VolumeShaperTest
Bug: 212194024
Bug: 212719987
Merged-In: I08da9296dfd59a711e246dd22a95de3eddd17bf6
Change-Id: I08da9296dfd59a711e246dd22a95de3eddd17bf6
diff --git a/tests/tests/media/audio/src/android/media/audio/cts/VolumeShaperTest.java b/tests/tests/media/audio/src/android/media/audio/cts/VolumeShaperTest.java
index f4e2749..5408836 100644
--- a/tests/tests/media/audio/src/android/media/audio/cts/VolumeShaperTest.java
+++ b/tests/tests/media/audio/src/android/media/audio/cts/VolumeShaperTest.java
@@ -16,6 +16,9 @@
 
 package android.media.audio.cts;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
 import static org.testng.Assert.assertThrows;
 
 import android.app.ActivityManager;
@@ -34,15 +37,18 @@
 import android.platform.test.annotations.AppModeFull;
 import android.util.Log;
 
+import androidx.test.InstrumentationRegistry;
 import androidx.test.filters.FlakyTest;
 import androidx.test.filters.LargeTest;
 import androidx.test.filters.SmallTest;
 
-import com.android.compatibility.common.util.CtsAndroidTestCase;
+import org.junit.Test;
+import org.junit.runner.RunWith;
 
-import java.lang.AutoCloseable;
 import java.util.Arrays;
 
+import junitparams.JUnitParamsRunner;
+
 /**
  * VolumeShaperTest is automated using VolumeShaper.getVolume() to verify that a ramp
  * or a duck is at the expected volume level. Listening to some tests is also possible,
@@ -53,7 +59,8 @@
  * adb logcat | grep VolumeShaperTest
  */
 @AppModeFull(reason = "TODO: evaluate and port to instant")
-public class VolumeShaperTest extends CtsAndroidTestCase {
+@RunWith(JUnitParamsRunner.class)
+public class VolumeShaperTest {
     private static final String TAG = "VolumeShaperTest";
 
     // ramp or duck time (duration) used in tests.
@@ -343,6 +350,7 @@
     }
 
     @SmallTest
+    @Test
     public void testVolumeShaperConfigurationBuilder() throws Exception {
         final String TEST_NAME = "testVolumeShaperConfigurationBuilder";
 
@@ -500,6 +508,7 @@
     } // testVolumeShaperConfigurationBuilder
 
     @SmallTest
+    @Test
     public void testVolumeShaperConfigurationParcelable() throws Exception {
         final String TEST_NAME = "testVolumeShaperConfigurationParcelable";
 
@@ -525,6 +534,7 @@
     } // testVolumeShaperConfigurationParcelable
 
     @SmallTest
+    @Test
     public void testVolumeShaperOperationParcelable() throws Exception {
         final String TEST_NAME = "testVolumeShaperOperationParcelable";
 
@@ -553,6 +563,7 @@
     // to crash due to memory or performance issues.  Typically around 16 app based
     // shapers are allowed by the audio server.
     @SmallTest
+    @Test
     public void testMaximumShapers() {
         final String TEST_NAME = "testMaximumShapers";
         if (!hasAudioOutput()) {
@@ -582,18 +593,21 @@
         }
     } // testMaximumShapers
 
+    @Test
     public void testDuckAudioTrack() throws Exception {
         try (Player player = createPlayer(PLAYER_TYPE_AUDIO_TRACK)) {
             runTestDuckPlayer("testDuckAudioTrack", player);
         }
     }
 
+    @Test
     public void testDuckMediaPlayerNonOffloaded() throws Exception {
         try (Player player = createPlayer(PLAYER_TYPE_MEDIA_PLAYER_NON_OFFLOADED)) {
             runTestDuckPlayer("testDuckMediaPlayerNonOffloaded", player);
         }
     }
 
+    @Test
     public void testDuckMediaPlayerOffloaded() throws Exception {
         try (Player player = createPlayer(PLAYER_TYPE_MEDIA_PLAYER_OFFLOADED)) {
             runTestDuckPlayer("testDuckMediaPlayerOffloaded", player);
@@ -618,6 +632,7 @@
     }
 
     @LargeTest
+    @Test
     public void testPlayerRamp() throws Exception {
         final String TEST_NAME = "testPlayerRamp";
         if (!hasAudioOutput()) {
@@ -643,6 +658,7 @@
     } // testPlayerRamp
 
     @FlakyTest
+    @Test
     public void testCornerCaseAudioTrack() throws Exception {
         try (Player player = createPlayer(PLAYER_TYPE_AUDIO_TRACK)) {
             runTestCornerCasePlayer("testCornerCaseAudioTrack", player);
@@ -650,6 +666,7 @@
     }
 
     @FlakyTest
+    @Test
     public void testCornerCaseMediaPlayerNonOffloaded() throws Exception {
         try (Player player = createPlayer(PLAYER_TYPE_MEDIA_PLAYER_NON_OFFLOADED)) {
             runTestCornerCasePlayer("testCornerCaseMediaPlayerNonOffloaded", player);
@@ -657,6 +674,7 @@
     }
 
     @FlakyTest
+    @Test
     public void testCornerCaseMediaPlayerOffloaded() throws Exception {
         try (Player player = createPlayer(PLAYER_TYPE_MEDIA_PLAYER_OFFLOADED)) {
             runTestCornerCasePlayer("testCornerCaseMediaPlayerOffloaded", player);
@@ -704,6 +722,7 @@
 
     @FlakyTest
     @LargeTest
+    @Test
     public void testPlayerCornerCase2() throws Exception {
         final String TEST_NAME = "testPlayerCornerCase2";
         if (!hasAudioOutput()) {
@@ -747,6 +766,7 @@
 
     @FlakyTest
     @LargeTest
+    @Test
     public void testPlayerJoin() throws Exception {
         final String TEST_NAME = "testPlayerJoin";
         if (!hasAudioOutput()) {
@@ -784,6 +804,7 @@
     } // testPlayerJoin
 
     @LargeTest
+    @Test
     public void testPlayerCubicMonotonic() throws Exception {
         final String TEST_NAME = "testPlayerCubicMonotonic";
         if (!hasAudioOutput()) {
@@ -907,18 +928,21 @@
         }
     } // testPlayerCubicMonotonic
 
+    @Test
     public void testStepRampAudioTrack() throws Exception {
         try (Player player = createPlayer(PLAYER_TYPE_AUDIO_TRACK)) {
             runTestStepRampPlayer("testStepRampAudioTrack", player);
         }
     }
 
+    @Test
     public void testStepRampMediaPlayerNonOffloaded() throws Exception {
         try (Player player = createPlayer(PLAYER_TYPE_MEDIA_PLAYER_NON_OFFLOADED)) {
             runTestStepRampPlayer("testStepRampMediaPlayerNonOffloaded", player);
         }
     }
 
+    @Test
     public void testStepRampMediaPlayerOffloaded() throws Exception {
         try (Player player = createPlayer(PLAYER_TYPE_MEDIA_PLAYER_OFFLOADED)) {
             runTestStepRampPlayer("testStepRampMediaPlayerOffloaded", player);
@@ -1045,18 +1069,21 @@
         }
     } // runTestStepRampPlayer
 
+    @Test
     public void testTwoShapersAudioTrack() throws Exception {
         try (Player player = createPlayer(PLAYER_TYPE_AUDIO_TRACK)) {
             runTestTwoShapersPlayer("testTwoShapersAudioTrack", player);
         }
     }
 
+    @Test
     public void testTwoShapersMediaPlayerNonOffloaded() throws Exception {
         try (Player player = createPlayer(PLAYER_TYPE_MEDIA_PLAYER_NON_OFFLOADED)) {
             runTestTwoShapersPlayer("testTwoShapersMediaPlayerNonOffloaded", player);
         }
     }
 
+    @Test
     public void testTwoShapersMediaPlayerOffloaded() throws Exception {
         try (Player player = createPlayer(PLAYER_TYPE_MEDIA_PLAYER_OFFLOADED)) {
             runTestTwoShapersPlayer("testTwoShapersMediaPlayerOffloaded", player);
@@ -1146,6 +1173,7 @@
 
     // tests that shaper advances in the presence of pause and stop (time based after start).
     @LargeTest
+    @Test
     public void testPlayerRunDuringPauseStop() throws Exception {
         final String TEST_NAME = "testPlayerRunDuringPauseStop";
         if (!hasAudioOutput()) {
@@ -1436,4 +1464,8 @@
         assertTrue(testName + " volume should be greater than 0.f",
                 volumeShaper.getVolume() > 0.f);
     } // runStartSyncTest
+
+    private static Context getContext() {
+        return InstrumentationRegistry.getInstrumentation().getTargetContext();
+    }
 }