diff options
author | Zhuoyao Zhang <zhuoyao@google.com> | 2018-02-14 23:07:33 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2018-02-14 23:07:33 +0000 |
commit | f78a54413271b454ca0e8c6ac3b347d1b7419711 (patch) | |
tree | 380ae7d9a26bb7c6a21dcd340135f9c4516a32f8 /contexthub/1.0 | |
parent | aa58c926f8a5f1c31b02286046769b08466218a0 (diff) | |
parent | dc117b5c6048d5c7e8632ceb0866d1bf08ff88fc (diff) | |
download | android_hardware_interfaces-f78a54413271b454ca0e8c6ac3b347d1b7419711.tar.gz android_hardware_interfaces-f78a54413271b454ca0e8c6ac3b347d1b7419711.tar.bz2 android_hardware_interfaces-f78a54413271b454ca0e8c6ac3b347d1b7419711.zip |
Merge "Convert contexthub hal test to use VtsHalHidlTargetTestEnvBase" am: bd98b61b2c am: 5cc68bc013
am: dc117b5c60
Change-Id: I674b67e839fc172961ed8ef8db6ed110ce33dbe9
Diffstat (limited to 'contexthub/1.0')
-rw-r--r-- | contexthub/1.0/vts/functional/VtsHalContexthubV1_0TargetTest.cpp | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/contexthub/1.0/vts/functional/VtsHalContexthubV1_0TargetTest.cpp b/contexthub/1.0/vts/functional/VtsHalContexthubV1_0TargetTest.cpp index 5672824d4..749215209 100644 --- a/contexthub/1.0/vts/functional/VtsHalContexthubV1_0TargetTest.cpp +++ b/contexthub/1.0/vts/functional/VtsHalContexthubV1_0TargetTest.cpp @@ -17,6 +17,7 @@ #define LOG_TAG "contexthub_hidl_hal_test" #include <VtsHalHidlTargetTestBase.h> +#include <VtsHalHidlTargetTestEnvBase.h> #include <android-base/logging.h> #include <android/hardware/contexthub/1.0/IContexthub.h> #include <android/hardware/contexthub/1.0/IContexthubCallback.h> @@ -92,12 +93,27 @@ std::vector<uint32_t> getHubIds() { return hubIds; } +// Test environment for Contexthub HIDL HAL. +class ContexthubHidlEnvironment : public ::testing::VtsHalHidlTargetTestEnvBase { + public: + // get the test environment singleton + static ContexthubHidlEnvironment* Instance() { + static ContexthubHidlEnvironment* instance = new ContexthubHidlEnvironment; + return instance; + } + + virtual void registerTestServices() override { registerTestService<IContexthub>(); } + private: + ContexthubHidlEnvironment() {} +}; + // Base test fixture that initializes the HAL and makes the context hub API // handle available class ContexthubHidlTestBase : public ::testing::VtsHalHidlTargetTestBase { public: virtual void SetUp() override { - hubApi = ::testing::VtsHalHidlTargetTestBase::getService<IContexthub>(); + hubApi = ::testing::VtsHalHidlTargetTestBase::getService<IContexthub>( + ContexthubHidlEnvironment::Instance()->getServiceName<IContexthub>()); ASSERT_NE(hubApi, nullptr); // getHubs() must be called at least once for proper initialization of the @@ -381,7 +397,11 @@ INSTANTIATE_TEST_CASE_P(HubIdSpecificTests, ContexthubTxnTest, } // anonymous namespace int main(int argc, char **argv) { + ::testing::AddGlobalTestEnvironment(ContexthubHidlEnvironment::Instance()); ::testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); + ContexthubHidlEnvironment::Instance()->init(&argc, argv); + int status = RUN_ALL_TESTS(); + ALOGI ("Test result = %d", status); + return status; } |