From 5c58bc6f658be51faef1203fb49bc645fe04ff8c Mon Sep 17 00:00:00 2001 From: Zhuoyao Zhang Date: Thu, 22 Feb 2018 21:59:28 -0800 Subject: [PATCH] Convert tv input hal test to use VtsHalHidlTargetTestEnvBase Bug: 64203181 Test: make vts vts-tradefed run vts -m VtsHalTvInputV1_0Target Change-Id: I53e870bbae00930af6502acf0029c5b3ff4c7315 --- .../VtsHalTvInputV1_0TargetTest.cpp | 30 ++++++++++++------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/tv/input/1.0/vts/functional/VtsHalTvInputV1_0TargetTest.cpp b/tv/input/1.0/vts/functional/VtsHalTvInputV1_0TargetTest.cpp index 0d5110e837..573a1d6cb5 100644 --- a/tv/input/1.0/vts/functional/VtsHalTvInputV1_0TargetTest.cpp +++ b/tv/input/1.0/vts/functional/VtsHalTvInputV1_0TargetTest.cpp @@ -42,11 +42,27 @@ using ::android::sp; #define WAIT_FOR_EVENT_TIMEOUT 5 #define DEFAULT_ID INT32_MIN +// Test environment for TvInput HIDL HAL. +class TvInputHidlEnvironment : public ::testing::VtsHalHidlTargetTestEnvBase { + public: + // get the test environment singleton + static TvInputHidlEnvironment* Instance() { + static TvInputHidlEnvironment* instance = new TvInputHidlEnvironment; + return instance; + } + + virtual void registerTestServices() override { registerTestService(); } + + private: + TvInputHidlEnvironment() {} +}; + /* The main test class for TV Input HIDL HAL. */ class TvInputHidlTest : public ::testing::VtsHalHidlTargetTestBase { public: virtual void SetUp() override { - tv_input_ = ::testing::VtsHalHidlTargetTestBase::getService(); + tv_input_ = ::testing::VtsHalHidlTargetTestBase::getService( + TvInputHidlEnvironment::Instance()->getServiceName()); ASSERT_NE(tv_input_, nullptr); tv_input_callback_ = new TvInputCallback(*this); ASSERT_NE(tv_input_callback_, nullptr); @@ -187,15 +203,6 @@ class TvInputHidlTest : public ::testing::VtsHalHidlTargetTestBase { }; -/* A class for test environment setup. */ -class TvInputHidlEnvironment : public ::testing::Environment { - public: - virtual void SetUp() {} - virtual void TearDown() {} - - private: -}; - /* * GetStreamConfigTest: * Calls updateStreamConfigurations() for each existing device @@ -354,8 +361,9 @@ TEST_F(TvInputHidlTest, CloseStreamBeforeOpenTest) { } int main(int argc, char **argv) { - ::testing::AddGlobalTestEnvironment(new TvInputHidlEnvironment); + ::testing::AddGlobalTestEnvironment(TvInputHidlEnvironment::Instance()); ::testing::InitGoogleTest(&argc, argv); + TvInputHidlEnvironment::Instance()->init(&argc, argv); int status = RUN_ALL_TESTS(); ALOGI("Test result = %d", status); return status;