From 26c1200e544fd53ea7e74af316eb346669058c0f Mon Sep 17 00:00:00 2001 From: Yifan Hong Date: Tue, 2 Oct 2018 14:52:02 -0700 Subject: [PATCH] health VTS: split Properties test ... into multiple test cases. Test: run test Change-Id: I2a03a7ab01d2918b746e06f55c2ee6d733ab4021 --- .../functional/VtsHalHealthV2_0TargetTest.cpp | 55 +++++++++++++++++-- 1 file changed, 50 insertions(+), 5 deletions(-) diff --git a/health/2.0/vts/functional/VtsHalHealthV2_0TargetTest.cpp b/health/2.0/vts/functional/VtsHalHealthV2_0TargetTest.cpp index bba4661f74..f895aecfd4 100644 --- a/health/2.0/vts/functional/VtsHalHealthV2_0TargetTest.cpp +++ b/health/2.0/vts/functional/VtsHalHealthV2_0TargetTest.cpp @@ -222,38 +222,83 @@ bool verifyHealthInfo(const HealthInfo& health_info) { } /* - * Tests the values returned by getChargeCounter(), - * getCurrentNow(), getCurrentAverage(), getCapacity(), getEnergyCounter(), - * getChargeStatus(), getStorageInfo(), getDiskStats() and getHealthInfo() from - * interface IHealth. + * Tests the values returned by getChargeCounter() from interface IHealth. */ -TEST_F(HealthHidlTest, Properties) { +TEST_F(HealthHidlTest, getChargeCounter) { EXPECT_OK(mHealth->getChargeCounter([](auto result, auto value) { EXPECT_VALID_OR_UNSUPPORTED_PROP(result, std::to_string(value), value > 0); })); +} + +/* + * Tests the values returned by getCurrentNow() from interface IHealth. + */ +TEST_F(HealthHidlTest, getCurrentNow) { EXPECT_OK(mHealth->getCurrentNow([](auto result, auto value) { EXPECT_VALID_OR_UNSUPPORTED_PROP(result, std::to_string(value), value != INT32_MIN); })); +} + +/* + * Tests the values returned by getCurrentAverage() from interface IHealth. + */ +TEST_F(HealthHidlTest, getCurrentAverage) { EXPECT_OK(mHealth->getCurrentAverage([](auto result, auto value) { EXPECT_VALID_OR_UNSUPPORTED_PROP(result, std::to_string(value), value != INT32_MIN); })); +} + +/* + * Tests the values returned by getCapacity() from interface IHealth. + */ +TEST_F(HealthHidlTest, getCapacity) { EXPECT_OK(mHealth->getCapacity([](auto result, auto value) { EXPECT_VALID_OR_UNSUPPORTED_PROP(result, std::to_string(value), 0 <= value && value <= 100); })); +} + +/* + * Tests the values returned by getEnergyCounter() from interface IHealth. + */ +TEST_F(HealthHidlTest, getEnergyCounter) { EXPECT_OK(mHealth->getEnergyCounter([](auto result, auto value) { EXPECT_VALID_OR_UNSUPPORTED_PROP(result, std::to_string(value), value != INT64_MIN); })); +} + +/* + * Tests the values returned by getChargeStatus() from interface IHealth. + */ +TEST_F(HealthHidlTest, getChargeStatus) { EXPECT_OK(mHealth->getChargeStatus([](auto result, auto value) { EXPECT_VALID_OR_UNSUPPORTED_PROP( result, toString(value), value != BatteryStatus::UNKNOWN && verifyEnum(value)); })); +} + +/* + * Tests the values returned by getStorageInfo() from interface IHealth. + */ +TEST_F(HealthHidlTest, getStorageInfo) { EXPECT_OK(mHealth->getStorageInfo([](auto result, auto& value) { EXPECT_VALID_OR_UNSUPPORTED_PROP(result, toString(value), verifyStorageInfo(value)); })); +} + +/* + * Tests the values returned by getDiskStats() from interface IHealth. + */ +TEST_F(HealthHidlTest, getDiskStats) { EXPECT_OK(mHealth->getDiskStats([](auto result, auto& value) { EXPECT_VALID_OR_UNSUPPORTED_PROP(result, toString(value), true); })); +} + +/* + * Tests the values returned by getHealthInfo() from interface IHealth. + */ +TEST_F(HealthHidlTest, getHealthInfo) { EXPECT_OK(mHealth->getHealthInfo([](auto result, auto& value) { EXPECT_VALID_OR_UNSUPPORTED_PROP(result, toString(value), verifyHealthInfo(value)); }));