Convert VtsHalThermalV*TargetTest to be parameterized test

Bug: 142397658
Test: atest
Change-Id: I5846cab420671e7c3d2bfe80034a7b612ec2e47b
diff --git a/thermal/1.1/vts/functional/Android.bp b/thermal/1.1/vts/functional/Android.bp
index 9a16c30..2c43d79 100644
--- a/thermal/1.1/vts/functional/Android.bp
+++ b/thermal/1.1/vts/functional/Android.bp
@@ -22,6 +22,5 @@
         "android.hardware.thermal@1.0",
         "android.hardware.thermal@1.1",
     ],
-    test_suites: ["general-tests"],
+    test_suites: ["general-tests", "vts-core"],
 }
-
diff --git a/thermal/1.1/vts/functional/VtsHalThermalV1_1TargetTest.cpp b/thermal/1.1/vts/functional/VtsHalThermalV1_1TargetTest.cpp
index 91c8b6e..bc7b2ee 100644
--- a/thermal/1.1/vts/functional/VtsHalThermalV1_1TargetTest.cpp
+++ b/thermal/1.1/vts/functional/VtsHalThermalV1_1TargetTest.cpp
@@ -17,10 +17,11 @@
 #include <android/hardware/thermal/1.1/IThermal.h>
 #include <android/hardware/thermal/1.1/IThermalCallback.h>
 #include <android/hardware/thermal/1.0/types.h>
+#include <gtest/gtest.h>
+#include <hidl/GtestPrinter.h>
+#include <hidl/ServiceManagement.h>
 
 #include <VtsHalHidlTargetCallbackBase.h>
-#include <VtsHalHidlTargetTestBase.h>
-#include <VtsHalHidlTargetTestEnvBase.h>
 
 using ::android::hardware::thermal::V1_0::Temperature;
 using ::android::hardware::thermal::V1_0::TemperatureType;
@@ -63,26 +64,11 @@
     }
 };
 
-// Test environment for Thermal HIDL HAL.
-class ThermalHidlEnvironment : public ::testing::VtsHalHidlTargetTestEnvBase {
-   public:
-    // get the test environment singleton
-    static ThermalHidlEnvironment* Instance() {
-        static ThermalHidlEnvironment* instance = new ThermalHidlEnvironment;
-        return instance;
-    }
-
-    virtual void registerTestServices() override { registerTestService<IThermal>(); }
-   private:
-    ThermalHidlEnvironment() {}
-};
-
 // The main test class for THERMAL HIDL HAL 1.1.
-class ThermalHidlTest : public ::testing::VtsHalHidlTargetTestBase {
+class ThermalHidlTest : public testing::TestWithParam<std::string> {
    public:
     virtual void SetUp() override {
-        mThermal = ::testing::VtsHalHidlTargetTestBase::getService<IThermal>(
-            ThermalHidlEnvironment::Instance()->getServiceName<IThermal>());
+        mThermal = IThermal::getService(GetParam());
         ASSERT_NE(mThermal, nullptr);
         mThermalCallback = new(std::nothrow) ThermalCallback();
         ASSERT_NE(mThermalCallback, nullptr);
@@ -104,7 +90,7 @@
 // This just calls into and back from our local ThermalCallback impl.
 // Note: a real thermal throttling event from the Thermal HAL could be
 // inadvertently received here.
-TEST_F(ThermalHidlTest, NotifyThrottlingTest) {
+TEST_P(ThermalHidlTest, NotifyThrottlingTest) {
     auto ret = mThermalCallback->notifyThrottling(true, kThrottleTemp);
     ASSERT_TRUE(ret.isOk());
     auto res = mThermalCallback->WaitForCallback(kCallbackNameNotifyThrottling);
@@ -114,11 +100,7 @@
     EXPECT_EQ(kThrottleTemp, res.args->temperature);
 }
 
-int main(int argc, char** argv) {
-    ::testing::AddGlobalTestEnvironment(ThermalHidlEnvironment::Instance());
-    ::testing::InitGoogleTest(&argc, argv);
-    ThermalHidlEnvironment::Instance()->init(&argc, argv);
-    int status = RUN_ALL_TESTS();
-    cout << "Test result = " << status << std::endl;
-    return status;
-}
+INSTANTIATE_TEST_SUITE_P(
+        PerInstance, ThermalHidlTest,
+        testing::ValuesIn(android::hardware::getAllHalInstanceNames(IThermal::descriptor)),
+        android::hardware::PrintInstanceNameToString);
\ No newline at end of file