From d198ea4c094bf2bbba559a8f7f4e4303440441ab Mon Sep 17 00:00:00 2001 From: Zhuoyao Zhang Date: Thu, 8 Feb 2018 20:46:32 -0800 Subject: [PATCH] Convert configstore hal test to use VtsHalHidlTargetTestEnvBase Bug: 64203181 Test: make vts vts-tradefed run vts -m VtsHalConfigstoreV1_0Target Change-Id: I4ba993d41e285df790c267e84b484f1564047e1e --- .../VtsHalConfigstoreV1_0TargetTest.cpp | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/configstore/1.0/vts/functional/VtsHalConfigstoreV1_0TargetTest.cpp b/configstore/1.0/vts/functional/VtsHalConfigstoreV1_0TargetTest.cpp index e501580935..a1676be2b7 100644 --- a/configstore/1.0/vts/functional/VtsHalConfigstoreV1_0TargetTest.cpp +++ b/configstore/1.0/vts/functional/VtsHalConfigstoreV1_0TargetTest.cpp @@ -17,6 +17,7 @@ #define LOG_TAG "ConfigstoreHidlHalTest" #include +#include #include #include #include @@ -34,13 +35,25 @@ using ::android::sp; #define ASSERT_OK(ret) ASSERT_TRUE(ret.isOk()) #define EXPECT_OK(ret) EXPECT_TRUE(ret.isOk()) +// Test environment for Configstore HIDL HAL. +class ConfigstoreHidlEnvironment : public ::testing::VtsHalHidlTargetTestEnvBase { + public: + // get the test environment singleton + static ConfigstoreHidlEnvironment* Instance() { + static ConfigstoreHidlEnvironment* instance = new ConfigstoreHidlEnvironment; + return instance; + } + + virtual void registerTestServices() override { registerTestService(); } +}; + class ConfigstoreHidlTest : public ::testing::VtsHalHidlTargetTestBase { public: sp sfConfigs; virtual void SetUp() override { - sfConfigs = ::testing::VtsHalHidlTargetTestBase::getService< - ISurfaceFlingerConfigs>(); + sfConfigs = ::testing::VtsHalHidlTargetTestBase::getService( + ConfigstoreHidlEnvironment::Instance()->getServiceName()); ASSERT_NE(sfConfigs, nullptr); } @@ -119,7 +132,9 @@ TEST_F(ConfigstoreHidlTest, TestSameReturnValue) { } int main(int argc, char** argv) { + ::testing::AddGlobalTestEnvironment(ConfigstoreHidlEnvironment::Instance()); ::testing::InitGoogleTest(&argc, argv); + ConfigstoreHidlEnvironment::Instance()->init(&argc, argv); int status = RUN_ALL_TESTS(); LOG(INFO) << "Test result = " << status; return status;