summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornelsonli <nelsonli@google.com>2019-10-25 17:24:18 +0800
committerNelson Li <nelsonli@google.com>2019-10-28 07:25:51 +0000
commitcb460b6dae4708f1fe26dd4b8c9b07a0994e07b5 (patch)
treec02d351a1a41491917f0ed79dc4b09fedec4576f
parent6e82d1abd5657c72fc8b29868213372617527294 (diff)
downloadplatform_hardware_interfaces-cb460b6dae4708f1fe26dd4b8c9b07a0994e07b5.tar.gz
platform_hardware_interfaces-cb460b6dae4708f1fe26dd4b8c9b07a0994e07b5.tar.bz2
platform_hardware_interfaces-cb460b6dae4708f1fe26dd4b8c9b07a0994e07b5.zip
[vts-core] add VtsHalHealthV1_0TargetTest to vts-core
Convert VtsHalHealthV1_0TargetTest. to be parameterized test and add it to vts-core Bug: 142397658 Test: $atest VtsHalHealthV1_0TargetTest. Change-Id: I3abfbfe0c20a5fe595f32c4793b2c53f6ad13e28
-rw-r--r--health/1.0/vts/functional/Android.bp2
-rw-r--r--health/1.0/vts/functional/VtsHalHealthV1_0TargetTest.cpp39
2 files changed, 11 insertions, 30 deletions
diff --git a/health/1.0/vts/functional/Android.bp b/health/1.0/vts/functional/Android.bp
index c14dceeb0e..be2d20685a 100644
--- a/health/1.0/vts/functional/Android.bp
+++ b/health/1.0/vts/functional/Android.bp
@@ -19,5 +19,5 @@ cc_test {
defaults: ["VtsHalTargetTestDefaults"],
srcs: ["VtsHalHealthV1_0TargetTest.cpp"],
static_libs: ["android.hardware.health@1.0"],
- test_suites: ["general-tests"],
+ test_suites: ["general-tests", "vts-core"],
}
diff --git a/health/1.0/vts/functional/VtsHalHealthV1_0TargetTest.cpp b/health/1.0/vts/functional/VtsHalHealthV1_0TargetTest.cpp
index 335d15d172..b985a9f500 100644
--- a/health/1.0/vts/functional/VtsHalHealthV1_0TargetTest.cpp
+++ b/health/1.0/vts/functional/VtsHalHealthV1_0TargetTest.cpp
@@ -18,11 +18,11 @@
#include <android/hardware/health/1.0/IHealth.h>
#include <android/hardware/health/1.0/types.h>
+#include <gtest/gtest.h>
+#include <hidl/GtestPrinter.h>
+#include <hidl/ServiceManagement.h>
#include <log/log.h>
-#include <VtsHalHidlTargetTestBase.h>
-#include <VtsHalHidlTargetTestEnvBase.h>
-
using HealthConfig = ::android::hardware::health::V1_0::HealthConfig;
using HealthInfo = ::android::hardware::health::V1_0::HealthInfo;
using IHealth = ::android::hardware::health::V1_0::IHealth;
@@ -30,25 +30,10 @@ using Result = ::android::hardware::health::V1_0::Result;
using ::android::sp;
-// Test environment for Health HIDL HAL.
-class HealthHidlEnvironment : public ::testing::VtsHalHidlTargetTestEnvBase {
- public:
- // get the test environment singleton
- static HealthHidlEnvironment* Instance() {
- static HealthHidlEnvironment* instance = new HealthHidlEnvironment;
- return instance;
- }
-
- virtual void registerTestServices() override { registerTestService<IHealth>(); }
- private:
- HealthHidlEnvironment() {}
-};
-
-class HealthHidlTest : public ::testing::VtsHalHidlTargetTestBase {
+class HealthHidlTest : public ::testing::TestWithParam<std::string> {
public:
virtual void SetUp() override {
- health = ::testing::VtsHalHidlTargetTestBase::getService<IHealth>(
- HealthHidlEnvironment::Instance()->getServiceName<IHealth>());
+ health = IHealth::getService(GetParam());
ASSERT_NE(health, nullptr);
health->init(config,
[&](const auto& halConfigOut) { config = halConfigOut; });
@@ -61,7 +46,7 @@ class HealthHidlTest : public ::testing::VtsHalHidlTargetTestBase {
/**
* Ensure EnergyCounter call returns positive energy counter or NOT_SUPPORTED
*/
-TEST_F(HealthHidlTest, TestEnergyCounter) {
+TEST_P(HealthHidlTest, TestEnergyCounter) {
Result result;
int64_t energy = 0;
health->energyCounter([&](Result ret, int64_t energyOut) {
@@ -73,11 +58,7 @@ TEST_F(HealthHidlTest, TestEnergyCounter) {
ASSERT_TRUE(result != Result::SUCCESS || energy > 0);
}
-int main(int argc, char **argv) {
- ::testing::AddGlobalTestEnvironment(HealthHidlEnvironment::Instance());
- ::testing::InitGoogleTest(&argc, argv);
- HealthHidlEnvironment::Instance()->init(&argc, argv);
- int status = RUN_ALL_TESTS();
- ALOGI("Test result = %d", status);
- return status;
-}
+INSTANTIATE_TEST_SUITE_P(
+ PerInstance, HealthHidlTest,
+ testing::ValuesIn(android::hardware::getAllHalInstanceNames(IHealth::descriptor)),
+ android::hardware::PrintInstanceNameToString);