Stop using JUnit3 test suite builders for sensor tests.
b/17783158

Change-Id: I574185942110785aff92691c6de3be1dfb8a8a32
diff --git a/tests/expectations/knownfailures.txt b/tests/expectations/knownfailures.txt
index 5ce84f7..012f4fd 100644
--- a/tests/expectations/knownfailures.txt
+++ b/tests/expectations/knownfailures.txt
@@ -158,7 +158,15 @@
     "android.hardware.cts.SensorBatchingTests#testGeomagneticRotationVector_50hz_flush",
     "android.hardware.cts.SensorIntegrationTests#testSensorsWithSeveralClients",
     "android.hardware.cts.SensorIntegrationTests#testSensorsMovingRates",
-    "android.hardware.cts.SensorIntegrationTests#testSensorStoppingInteraction",
+    "android.hardware.cts.SensorIntegrationTests#testAccelerometerAccelerometerStopping",
+    "android.hardware.cts.SensorIntegrationTests#testAccelerometerGyroscopeStopping",
+    "android.hardware.cts.SensorIntegrationTests#testAccelerometerMagneticFieldStopping",
+    "android.hardware.cts.SensorIntegrationTests#testGyroscopeAccelerometerStopping",
+    "android.hardware.cts.SensorIntegrationTests#testGyroscopeGyroscopeStopping",
+    "android.hardware.cts.SensorIntegrationTests#testGyroscopeMagneticFieldStopping",
+    "android.hardware.cts.SensorIntegrationTests#testMagneticFieldAccelerometerStopping",
+    "android.hardware.cts.SensorIntegrationTests#testMagneticFieldGyroscopeStopping",
+    "android.hardware.cts.SensorIntegrationTests#testMagneticFieldMagneticFieldStopping",
     "android.hardware.cts.SingleSensorTests#testSensorProperties",
     "android.hardware.cts.SingleSensorTests#testAccelerometer_fastest",
     "android.hardware.cts.SingleSensorTests#testAccelerometer_100hz",
diff --git a/tests/tests/hardware/src/android/hardware/cts/SensorIntegrationTests.java b/tests/tests/hardware/src/android/hardware/cts/SensorIntegrationTests.java
index 3c9eef9..88e6cce 100644
--- a/tests/tests/hardware/src/android/hardware/cts/SensorIntegrationTests.java
+++ b/tests/tests/hardware/src/android/hardware/cts/SensorIntegrationTests.java
@@ -15,9 +15,6 @@
  */
 package android.hardware.cts;
 
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
 import android.content.Context;
 import android.hardware.Sensor;
 import android.hardware.SensorManager;
@@ -44,25 +41,6 @@
     private static final String TAG = "SensorIntegrationTests";
 
     /**
-     * Builder for the test suite.
-     * This is the method that will build dynamically the set of test cases to execute.
-     * Each 'base' test case is composed by three parts:
-     * - the matrix definition
-     * - the test method that will execute the test case
-     * - a static method that will combine both and add test case instances to the test suite
-     */
-    public static Test suite() {
-        TestSuite testSuite = new TestSuite();
-
-        // add test generation routines
-        addTestToSuite(testSuite, "testSensorsWithSeveralClients");
-        addTestToSuite(testSuite, "testSensorsMovingRates");
-        createStoppingTestCases(testSuite);
-
-        return testSuite;
-    }
-
-    /**
      * This test focuses in the interaction of continuous and batching clients for the same Sensor
      * under test. The verification ensures that sensor clients can interact with the System and
      * not affect other clients in the way.
@@ -183,24 +161,41 @@
      * Regress:
      * - b/10641388
      */
-    private int mSensorTypeTester;
-    private int mSensorTypeTestee;
 
-    private static void createStoppingTestCases(TestSuite testSuite) {
-        int sensorTypes[] = {
-                Sensor.TYPE_ACCELEROMETER,
-                Sensor.TYPE_GYROSCOPE,
-                Sensor.TYPE_MAGNETIC_FIELD};
+    public void testAccelerometerAccelerometerStopping()  throws Throwable {
+        verifySensorStoppingInteraction(Sensor.TYPE_ACCELEROMETER, Sensor.TYPE_ACCELEROMETER);
+    }
 
-        for(int sensorTypeTester : sensorTypes) {
-            for(int sensorTypeTestee : sensorTypes) {
-                SensorIntegrationTests test = new SensorIntegrationTests();
-                test.mSensorTypeTester = sensorTypeTester;
-                test.mSensorTypeTestee = sensorTypeTestee;
-                test.setName("testSensorStoppingInteraction");
-                testSuite.addTest(test);
-            }
-        }
+    public void testAccelerometerGyroscopeStopping()  throws Throwable {
+        verifySensorStoppingInteraction(Sensor.TYPE_ACCELEROMETER, Sensor.TYPE_GYROSCOPE);
+    }
+
+    public void testAccelerometerMagneticFieldStopping()  throws Throwable {
+        verifySensorStoppingInteraction(Sensor.TYPE_ACCELEROMETER, Sensor.TYPE_MAGNETIC_FIELD);
+    }
+
+    public void testGyroscopeAccelerometerStopping()  throws Throwable {
+        verifySensorStoppingInteraction(Sensor.TYPE_GYROSCOPE, Sensor.TYPE_ACCELEROMETER);
+    }
+
+    public void testGyroscopeGyroscopeStopping()  throws Throwable {
+        verifySensorStoppingInteraction(Sensor.TYPE_GYROSCOPE, Sensor.TYPE_GYROSCOPE);
+    }
+
+    public void testGyroscopeMagneticFieldStopping()  throws Throwable {
+        verifySensorStoppingInteraction(Sensor.TYPE_GYROSCOPE, Sensor.TYPE_MAGNETIC_FIELD);
+    }
+
+    public void testMagneticFieldAccelerometerStopping()  throws Throwable {
+        verifySensorStoppingInteraction(Sensor.TYPE_MAGNETIC_FIELD, Sensor.TYPE_ACCELEROMETER);
+    }
+
+    public void testMagneticFieldGyroscopeStopping()  throws Throwable {
+        verifySensorStoppingInteraction(Sensor.TYPE_MAGNETIC_FIELD, Sensor.TYPE_GYROSCOPE);
+    }
+
+    public void testMagneticFieldMagneticFieldStopping()  throws Throwable {
+        verifySensorStoppingInteraction(Sensor.TYPE_MAGNETIC_FIELD, Sensor.TYPE_MAGNETIC_FIELD);
     }
 
     /**
@@ -223,12 +218,14 @@
      * It is important to look at the internals of the Sensor HAL to identify how the interaction
      * of several clients can lead to the failing state.
      */
-    public void testSensorStoppingInteraction() throws Throwable {
+    public void verifySensorStoppingInteraction(
+            int sensorTypeTestee,
+            int sensorTypeTester) throws Throwable {
         Context context = getContext();
 
         TestSensorEnvironment testerEnvironment = new TestSensorEnvironment(
                 context,
-                mSensorTypeTester,
+                sensorTypeTester,
                 shouldEmulateSensorUnderLoad(),
                 SensorManager.SENSOR_DELAY_FASTEST);
         TestSensorOperation tester =
@@ -237,7 +234,7 @@
 
         TestSensorEnvironment testeeEnvironment = new TestSensorEnvironment(
                 context,
-                mSensorTypeTestee,
+                sensorTypeTestee,
                 shouldEmulateSensorUnderLoad(),
                 SensorManager.SENSOR_DELAY_FASTEST);
         VerifiableSensorOperation testee =
@@ -278,10 +275,4 @@
                 mGenerator.nextInt(5) + 1);
         return reportLatency;
     }
-
-    private static void addTestToSuite(TestSuite testSuite, String testName) {
-        SensorIntegrationTests test = new SensorIntegrationTests();
-        test.setName(testName);
-        testSuite.addTest(test);
-    }
 }