diff options
author | nelsonli <nelsonli@google.com> | 2019-10-22 16:55:30 +0800 |
---|---|---|
committer | Nelson Li <nelsonli@google.com> | 2019-10-24 07:36:20 +0000 |
commit | 9e281efcfce957e8d9ba7081be9de46a86fefa8e (patch) | |
tree | edae7b5633217aa780ff6088aeb8633ac521c0ab /configstore | |
parent | 475414d8effc7ed81bc8c534823edb23bd41a565 (diff) |
[vts-core] add VtsHalConfigstoreV1_0TargetTest to vts-core
Convert VtsHalConfigstoreV1_0TargetTest to be parameterized test
and add it to vts-core
Bug: 142397658
Test: $atest VtsHalConfigstoreV1_0TargetTest
Change-Id: If65ce7afbe23eca95f62c6b231abf78d9ada616e
Diffstat (limited to 'configstore')
-rw-r--r-- | configstore/1.0/vts/functional/Android.bp | 2 | ||||
-rw-r--r-- | configstore/1.0/vts/functional/VtsHalConfigstoreV1_0TargetTest.cpp | 40 |
2 files changed, 13 insertions, 29 deletions
diff --git a/configstore/1.0/vts/functional/Android.bp b/configstore/1.0/vts/functional/Android.bp index 008b59d00a..31d4b1c9d9 100644 --- a/configstore/1.0/vts/functional/Android.bp +++ b/configstore/1.0/vts/functional/Android.bp @@ -19,6 +19,6 @@ cc_test { defaults: ["VtsHalTargetTestDefaults"], srcs: ["VtsHalConfigstoreV1_0TargetTest.cpp"], static_libs: ["android.hardware.configstore@1.0"], - test_suites: ["general-tests"], + test_suites: ["general-tests", "vts-core"], } diff --git a/configstore/1.0/vts/functional/VtsHalConfigstoreV1_0TargetTest.cpp b/configstore/1.0/vts/functional/VtsHalConfigstoreV1_0TargetTest.cpp index 70b5830c77..8a1a313bd6 100644 --- a/configstore/1.0/vts/functional/VtsHalConfigstoreV1_0TargetTest.cpp +++ b/configstore/1.0/vts/functional/VtsHalConfigstoreV1_0TargetTest.cpp @@ -16,11 +16,12 @@ #define LOG_TAG "ConfigstoreHidlHalTest" -#include <VtsHalHidlTargetTestBase.h> -#include <VtsHalHidlTargetTestEnvBase.h> #include <android-base/logging.h> #include <android/hardware/configstore/1.0/ISurfaceFlingerConfigs.h> #include <android/hardware/configstore/1.0/types.h> +#include <gtest/gtest.h> +#include <hidl/GtestPrinter.h> +#include <hidl/ServiceManagement.h> #include <unistd.h> using ::android::hardware::configstore::V1_0::ISurfaceFlingerConfigs; @@ -35,25 +36,12 @@ 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<ISurfaceFlingerConfigs>(); } -}; - -class ConfigstoreHidlTest : public ::testing::VtsHalHidlTargetTestBase { +class ConfigstoreHidlTest : public ::testing::TestWithParam<std::string> { public: sp<ISurfaceFlingerConfigs> sfConfigs; virtual void SetUp() override { - sfConfigs = ::testing::VtsHalHidlTargetTestBase::getService<ISurfaceFlingerConfigs>( - ConfigstoreHidlEnvironment::Instance()->getServiceName<ISurfaceFlingerConfigs>()); + sfConfigs = ISurfaceFlingerConfigs::getService(GetParam()); ASSERT_NE(sfConfigs, nullptr); } @@ -63,7 +51,7 @@ class ConfigstoreHidlTest : public ::testing::VtsHalHidlTargetTestBase { /** * Ensure all ISurfaceFlingerConfigs.hal function calls are successful. */ -TEST_F(ConfigstoreHidlTest, TestFunctionCalls) { +TEST_P(ConfigstoreHidlTest, TestFunctionCalls) { bool tmp; Return<void> status = sfConfigs->vsyncEventPhaseOffsetNs( @@ -118,7 +106,7 @@ TEST_F(ConfigstoreHidlTest, TestFunctionCalls) { /** * Ensure repeated call to the same function returns the same result. */ -TEST_F(ConfigstoreHidlTest, TestSameReturnValue) { +TEST_P(ConfigstoreHidlTest, TestSameReturnValue) { int64_t original_ret; Return<void> status = sfConfigs->vsyncEventPhaseOffsetNs( [&original_ret](OptionalInt64 arg) { original_ret = arg.value; }); @@ -135,7 +123,7 @@ TEST_F(ConfigstoreHidlTest, TestSameReturnValue) { * Make sure the constrains of hasWideColorDisplay, hasHDRDisplay * are enforced. */ -TEST_F(ConfigstoreHidlTest, TestColorConstrainsBasic) { +TEST_P(ConfigstoreHidlTest, TestColorConstrainsBasic) { bool hasWideColorDisplay; bool hasHDRDisplay; @@ -152,11 +140,7 @@ TEST_F(ConfigstoreHidlTest, TestColorConstrainsBasic) { } } -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; -} +INSTANTIATE_TEST_SUITE_P( + PerInstance, ConfigstoreHidlTest, + testing::ValuesIn(android::hardware::getAllHalInstanceNames(ISurfaceFlingerConfigs::descriptor)), + android::hardware::PrintInstanceNameToString); |