Merge "Convert VtsHalAudioControlV1_0TargetTest to parameterized gtest" into rvc-dev am: cebc574331 am: 83eab5456f am: 7ed8fac8c2

Change-Id: Ib7f60c04c3084cab151a8a15285866df82759dbc
diff --git a/automotive/audiocontrol/1.0/vts/functional/Android.bp b/automotive/audiocontrol/1.0/vts/functional/Android.bp
index 3cb6340..1bb8e88 100644
--- a/automotive/audiocontrol/1.0/vts/functional/Android.bp
+++ b/automotive/audiocontrol/1.0/vts/functional/Android.bp
@@ -25,5 +25,8 @@
     static_libs: [
         "android.hardware.automotive.audiocontrol@1.0",
     ],
-    test_suites: ["general-tests"],
+    test_suites: [
+        "general-tests",
+        "vts",
+    ],
 }
diff --git a/automotive/audiocontrol/1.0/vts/functional/VtsHalAudioControlV1_0TargetTest.cpp b/automotive/audiocontrol/1.0/vts/functional/VtsHalAudioControlV1_0TargetTest.cpp
index fc0deb9..de1ec02 100644
--- a/automotive/audiocontrol/1.0/vts/functional/VtsHalAudioControlV1_0TargetTest.cpp
+++ b/automotive/audiocontrol/1.0/vts/functional/VtsHalAudioControlV1_0TargetTest.cpp
@@ -25,11 +25,12 @@
 #include <utils/Errors.h>
 #include <utils/StrongPointer.h>
 
-#include <android/hardware/automotive/audiocontrol/1.0/types.h>
 #include <android/hardware/automotive/audiocontrol/1.0/IAudioControl.h>
+#include <android/hardware/automotive/audiocontrol/1.0/types.h>
 #include <android/log.h>
-
-#include <VtsHalHidlTargetTestBase.h>
+#include <gtest/gtest.h>
+#include <hidl/GtestPrinter.h>
+#include <hidl/ServiceManagement.h>
 
 using namespace ::android::hardware::automotive::audiocontrol::V1_0;
 using ::android::hardware::Return;
@@ -40,30 +41,12 @@
 using ::android::hardware::hidl_vec;
 using ::android::sp;
 
-
-// Boiler plate for test harness
-class CarAudioControlHidlEnvironment : public ::testing::VtsHalHidlTargetTestEnvBase {
-   public:
-    // get the test environment singleton
-    static CarAudioControlHidlEnvironment* Instance() {
-        static CarAudioControlHidlEnvironment* instance = new CarAudioControlHidlEnvironment;
-        return instance;
-    }
-
-    virtual void registerTestServices() override { registerTestService<IAudioControl>(); }
-   private:
-    CarAudioControlHidlEnvironment() {}
-};
-
-
 // The main test class for the automotive AudioControl HAL
-class CarAudioControlHidlTest : public ::testing::VtsHalHidlTargetTestBase {
-public:
+class CarAudioControlHidlTest : public ::testing::TestWithParam<std::string> {
+  public:
     virtual void SetUp() override {
         // Make sure we can connect to the driver
-        pAudioControl = ::testing::VtsHalHidlTargetTestBase::getService<IAudioControl>(
-                                    CarAudioControlHidlEnvironment::Instance()->
-                                    getServiceName<IAudioControl>());
+        pAudioControl = IAudioControl::getService(GetParam());
         ASSERT_NE(pAudioControl.get(), nullptr);
     }
 
@@ -82,7 +65,7 @@
  * fader actually works.  The only thing we can do is exercise the HAL and if the HAL crashes,
  * we _might_ get a test failure if that breaks the connection to the driver.
  */
-TEST_F(CarAudioControlHidlTest, FaderExercise) {
+TEST_P(CarAudioControlHidlTest, FaderExercise) {
     ALOGI("Fader exercise test (silent)");
 
     // Set the fader all the way to the back
@@ -104,7 +87,7 @@
 /*
  * Balance exercise test.
  */
-TEST_F(CarAudioControlHidlTest, BalanceExercise) {
+TEST_P(CarAudioControlHidlTest, BalanceExercise) {
     ALOGI("Balance exercise test (silent)");
 
     // Set the balance all the way to the left
@@ -126,7 +109,7 @@
 /*
  * Context mapping test.
  */
-TEST_F(CarAudioControlHidlTest, ContextMapping) {
+TEST_P(CarAudioControlHidlTest, ContextMapping) {
     ALOGI("Context mapping test");
 
     int bus = -1;
@@ -156,3 +139,8 @@
     bus = pAudioControl->getBusForContext((ContextNumber)~0);
     EXPECT_EQ(bus, -1);
 }
+
+INSTANTIATE_TEST_SUITE_P(
+        PerInstance, CarAudioControlHidlTest,
+        testing::ValuesIn(android::hardware::getAllHalInstanceNames(IAudioControl::descriptor)),
+        android::hardware::PrintInstanceNameToString);
\ No newline at end of file