Convert ir hal test to use VtsHalHidlTargetTestEnvBase
Bug: 64203181
Test: make vts
vts-tradefed run vts -m VtsHalIrV1_0Target
Change-Id: If3f7fcd04ce6d1e2a499a62807e186f36a771748
diff --git a/ir/1.0/vts/functional/VtsHalIrV1_0TargetTest.cpp b/ir/1.0/vts/functional/VtsHalIrV1_0TargetTest.cpp
index a017404..5fd2dd4 100644
--- a/ir/1.0/vts/functional/VtsHalIrV1_0TargetTest.cpp
+++ b/ir/1.0/vts/functional/VtsHalIrV1_0TargetTest.cpp
@@ -22,6 +22,7 @@
#include <android/hardware/ir/1.0/types.h>
#include <VtsHalHidlTargetTestBase.h>
+#include <VtsHalHidlTargetTestEnvBase.h>
#include <algorithm>
using ::android::hardware::ir::V1_0::IConsumerIr;
@@ -30,11 +31,26 @@
using ::android::hardware::Return;
using ::android::sp;
+// Test environment for Ir
+class ConsumerIrHidlEnvironment : public ::testing::VtsHalHidlTargetTestEnvBase {
+ public:
+ // get the test environment singleton
+ static ConsumerIrHidlEnvironment* Instance() {
+ static ConsumerIrHidlEnvironment* instance = new ConsumerIrHidlEnvironment;
+ return instance;
+ }
+
+ virtual void registerTestServices() override { registerTestService<IConsumerIr>(); }
+ private:
+ ConsumerIrHidlEnvironment() {}
+};
+
// The main test class for IR HIDL HAL.
class ConsumerIrHidlTest : public ::testing::VtsHalHidlTargetTestBase {
public:
virtual void SetUp() override {
- ir = ::testing::VtsHalHidlTargetTestBase::getService<IConsumerIr>();
+ ir = ::testing::VtsHalHidlTargetTestBase::getService<IConsumerIr>(
+ ConsumerIrHidlEnvironment::Instance()->getServiceName<IConsumerIr>());
ASSERT_NE(ir, nullptr);
}
@@ -77,7 +93,9 @@
}
int main(int argc, char **argv) {
+ ::testing::AddGlobalTestEnvironment(ConsumerIrHidlEnvironment::Instance());
::testing::InitGoogleTest(&argc, argv);
+ ConsumerIrHidlEnvironment::Instance()->init(&argc, argv);
int status = RUN_ALL_TESTS();
LOG(INFO) << "Test result = " << status;
return status;