Yifan Hong | 69c2254 | 2017-10-03 17:40:24 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2017 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
Yifan Hong | f86271d | 2017-11-06 12:52:20 -0800 | [diff] [blame] | 17 | #define LOG_TAG "health_hidl_hal_test" |
Yifan Hong | 69c2254 | 2017-10-03 17:40:24 -0700 | [diff] [blame] | 18 | |
| 19 | #include <mutex> |
Yifan Hong | 03b2a34 | 2019-03-08 11:37:33 -0800 | [diff] [blame] | 20 | #include <set> |
| 21 | #include <string> |
Yifan Hong | 69c2254 | 2017-10-03 17:40:24 -0700 | [diff] [blame] | 22 | |
Yifan Hong | 69c2254 | 2017-10-03 17:40:24 -0700 | [diff] [blame] | 23 | #include <android-base/logging.h> |
| 24 | #include <android/hardware/health/2.0/IHealth.h> |
| 25 | #include <android/hardware/health/2.0/types.h> |
Yifan Hong | e6807dd | 2019-03-07 13:04:33 -0800 | [diff] [blame] | 26 | #include <gflags/gflags.h> |
nelsonli | 4da3ca5 | 2019-12-10 17:17:09 +0800 | [diff] [blame] | 27 | #include <gtest/gtest.h> |
| 28 | #include <hidl/GtestPrinter.h> |
| 29 | #include <hidl/ServiceManagement.h> |
| 30 | #include <log/log.h> |
Yifan Hong | 69c2254 | 2017-10-03 17:40:24 -0700 | [diff] [blame] | 31 | |
| 32 | using ::testing::AssertionFailure; |
| 33 | using ::testing::AssertionResult; |
| 34 | using ::testing::AssertionSuccess; |
Yifan Hong | 69c2254 | 2017-10-03 17:40:24 -0700 | [diff] [blame] | 35 | |
Yifan Hong | e6807dd | 2019-03-07 13:04:33 -0800 | [diff] [blame] | 36 | DEFINE_bool(force, false, "Force test healthd even when the default instance is present."); |
| 37 | |
Yifan Hong | 69c2254 | 2017-10-03 17:40:24 -0700 | [diff] [blame] | 38 | namespace android { |
| 39 | namespace hardware { |
| 40 | namespace health { |
| 41 | namespace V2_0 { |
| 42 | |
| 43 | using V1_0::BatteryStatus; |
Yifan Hong | 69c2254 | 2017-10-03 17:40:24 -0700 | [diff] [blame] | 44 | |
nelsonli | 4da3ca5 | 2019-12-10 17:17:09 +0800 | [diff] [blame] | 45 | class HealthHidlTest : public ::testing::TestWithParam<std::string> { |
Yifan Hong | 69c2254 | 2017-10-03 17:40:24 -0700 | [diff] [blame] | 46 | public: |
| 47 | virtual void SetUp() override { |
nelsonli | 4da3ca5 | 2019-12-10 17:17:09 +0800 | [diff] [blame] | 48 | std::string serviceName = GetParam(); |
Yifan Hong | e6807dd | 2019-03-07 13:04:33 -0800 | [diff] [blame] | 49 | |
| 50 | if (serviceName == "backup" && !FLAGS_force && |
nelsonli | 4da3ca5 | 2019-12-10 17:17:09 +0800 | [diff] [blame] | 51 | IHealth::getService() != nullptr) { |
Yifan Hong | e6807dd | 2019-03-07 13:04:33 -0800 | [diff] [blame] | 52 | LOG(INFO) << "Skipping tests on healthd because the default instance is present. " |
| 53 | << "Use --force if you really want to test healthd."; |
| 54 | GTEST_SKIP(); |
| 55 | } |
| 56 | |
Yifan Hong | 69c2254 | 2017-10-03 17:40:24 -0700 | [diff] [blame] | 57 | LOG(INFO) << "get service with name:" << serviceName; |
| 58 | ASSERT_FALSE(serviceName.empty()); |
nelsonli | 4da3ca5 | 2019-12-10 17:17:09 +0800 | [diff] [blame] | 59 | mHealth = IHealth::getService(serviceName); |
Yifan Hong | 69c2254 | 2017-10-03 17:40:24 -0700 | [diff] [blame] | 60 | ASSERT_NE(mHealth, nullptr); |
| 61 | } |
| 62 | |
| 63 | sp<IHealth> mHealth; |
| 64 | }; |
| 65 | |
| 66 | class Callback : public IHealthInfoCallback { |
Yifan Hong | 69c2254 | 2017-10-03 17:40:24 -0700 | [diff] [blame] | 67 | public: |
Hridya Valsaraju | d31932a | 2018-01-17 23:09:24 -0800 | [diff] [blame] | 68 | Return<void> healthInfoChanged(const HealthInfo&) override { |
Yifan Hong | d6ea57e | 2017-11-20 14:41:09 -0800 | [diff] [blame] | 69 | std::lock_guard<std::mutex> lock(mMutex); |
| 70 | mInvoked = true; |
| 71 | mInvokedNotify.notify_all(); |
Yifan Hong | 69c2254 | 2017-10-03 17:40:24 -0700 | [diff] [blame] | 72 | return Void(); |
| 73 | } |
Yifan Hong | d6ea57e | 2017-11-20 14:41:09 -0800 | [diff] [blame] | 74 | template <typename R, typename P> |
| 75 | bool waitInvoke(std::chrono::duration<R, P> duration) { |
Yifan Hong | 69c2254 | 2017-10-03 17:40:24 -0700 | [diff] [blame] | 76 | std::unique_lock<std::mutex> lock(mMutex); |
Yifan Hong | d6ea57e | 2017-11-20 14:41:09 -0800 | [diff] [blame] | 77 | bool r = mInvokedNotify.wait_for(lock, duration, [this] { return this->mInvoked; }); |
| 78 | mInvoked = false; |
| 79 | return r; |
Yifan Hong | 69c2254 | 2017-10-03 17:40:24 -0700 | [diff] [blame] | 80 | } |
Yifan Hong | 69c2254 | 2017-10-03 17:40:24 -0700 | [diff] [blame] | 81 | private: |
| 82 | std::mutex mMutex; |
Yifan Hong | d6ea57e | 2017-11-20 14:41:09 -0800 | [diff] [blame] | 83 | std::condition_variable mInvokedNotify; |
| 84 | bool mInvoked = false; |
Yifan Hong | 69c2254 | 2017-10-03 17:40:24 -0700 | [diff] [blame] | 85 | }; |
| 86 | |
| 87 | #define ASSERT_OK(r) ASSERT_TRUE(isOk(r)) |
| 88 | #define EXPECT_OK(r) EXPECT_TRUE(isOk(r)) |
| 89 | template <typename T> |
| 90 | AssertionResult isOk(const Return<T>& r) { |
| 91 | return r.isOk() ? AssertionSuccess() : (AssertionFailure() << r.description()); |
| 92 | } |
| 93 | |
| 94 | #define ASSERT_ALL_OK(r) ASSERT_TRUE(isAllOk(r)) |
| 95 | // Both isOk() and Result::SUCCESS |
| 96 | AssertionResult isAllOk(const Return<Result>& r) { |
| 97 | if (!r.isOk()) { |
| 98 | return AssertionFailure() << r.description(); |
| 99 | } |
| 100 | if (static_cast<Result>(r) != Result::SUCCESS) { |
| 101 | return AssertionFailure() << toString(static_cast<Result>(r)); |
| 102 | } |
| 103 | return AssertionSuccess(); |
| 104 | } |
| 105 | |
| 106 | /** |
| 107 | * Test whether callbacks work. Tested functions are IHealth::registerCallback, |
| 108 | * unregisterCallback, and update. |
| 109 | */ |
nelsonli | 4da3ca5 | 2019-12-10 17:17:09 +0800 | [diff] [blame] | 110 | TEST_P(HealthHidlTest, Callbacks) { |
Yifan Hong | 69c2254 | 2017-10-03 17:40:24 -0700 | [diff] [blame] | 111 | using namespace std::chrono_literals; |
Yifan Hong | d6ea57e | 2017-11-20 14:41:09 -0800 | [diff] [blame] | 112 | sp<Callback> firstCallback = new Callback(); |
| 113 | sp<Callback> secondCallback = new Callback(); |
Yifan Hong | 69c2254 | 2017-10-03 17:40:24 -0700 | [diff] [blame] | 114 | |
| 115 | ASSERT_ALL_OK(mHealth->registerCallback(firstCallback)); |
| 116 | ASSERT_ALL_OK(mHealth->registerCallback(secondCallback)); |
| 117 | |
Yifan Hong | d6ea57e | 2017-11-20 14:41:09 -0800 | [diff] [blame] | 118 | // registerCallback may or may not invoke the callback immediately, so the test needs |
| 119 | // to wait for the invocation. If the implementation chooses not to invoke the callback |
| 120 | // immediately, just wait for some time. |
| 121 | firstCallback->waitInvoke(200ms); |
| 122 | secondCallback->waitInvoke(200ms); |
Yifan Hong | 69c2254 | 2017-10-03 17:40:24 -0700 | [diff] [blame] | 123 | |
Yifan Hong | d6ea57e | 2017-11-20 14:41:09 -0800 | [diff] [blame] | 124 | // assert that the first callback is invoked when update is called. |
Yifan Hong | 69c2254 | 2017-10-03 17:40:24 -0700 | [diff] [blame] | 125 | ASSERT_ALL_OK(mHealth->update()); |
| 126 | |
Yifan Hong | d6ea57e | 2017-11-20 14:41:09 -0800 | [diff] [blame] | 127 | ASSERT_TRUE(firstCallback->waitInvoke(1s)); |
| 128 | ASSERT_TRUE(secondCallback->waitInvoke(1s)); |
Yifan Hong | 69c2254 | 2017-10-03 17:40:24 -0700 | [diff] [blame] | 129 | |
| 130 | ASSERT_ALL_OK(mHealth->unregisterCallback(firstCallback)); |
| 131 | |
Yifan Hong | d6ea57e | 2017-11-20 14:41:09 -0800 | [diff] [blame] | 132 | // clear any potentially pending callbacks result from wakealarm / kernel events |
| 133 | // If there is none, just wait for some time. |
| 134 | firstCallback->waitInvoke(200ms); |
| 135 | secondCallback->waitInvoke(200ms); |
Yifan Hong | 69c2254 | 2017-10-03 17:40:24 -0700 | [diff] [blame] | 136 | |
Yifan Hong | d6ea57e | 2017-11-20 14:41:09 -0800 | [diff] [blame] | 137 | // assert that the second callback is still invoked even though the first is unregistered. |
Yifan Hong | 69c2254 | 2017-10-03 17:40:24 -0700 | [diff] [blame] | 138 | ASSERT_ALL_OK(mHealth->update()); |
| 139 | |
Yifan Hong | d6ea57e | 2017-11-20 14:41:09 -0800 | [diff] [blame] | 140 | ASSERT_FALSE(firstCallback->waitInvoke(200ms)); |
| 141 | ASSERT_TRUE(secondCallback->waitInvoke(1s)); |
Yifan Hong | 69c2254 | 2017-10-03 17:40:24 -0700 | [diff] [blame] | 142 | |
| 143 | ASSERT_ALL_OK(mHealth->unregisterCallback(secondCallback)); |
Yifan Hong | 69c2254 | 2017-10-03 17:40:24 -0700 | [diff] [blame] | 144 | } |
| 145 | |
nelsonli | 4da3ca5 | 2019-12-10 17:17:09 +0800 | [diff] [blame] | 146 | TEST_P(HealthHidlTest, UnregisterNonExistentCallback) { |
Yifan Hong | d6ea57e | 2017-11-20 14:41:09 -0800 | [diff] [blame] | 147 | sp<Callback> callback = new Callback(); |
Yifan Hong | 69c2254 | 2017-10-03 17:40:24 -0700 | [diff] [blame] | 148 | auto ret = mHealth->unregisterCallback(callback); |
| 149 | ASSERT_OK(ret); |
| 150 | ASSERT_EQ(Result::NOT_FOUND, static_cast<Result>(ret)) << "Actual: " << toString(ret); |
| 151 | } |
| 152 | |
| 153 | /** |
| 154 | * Pass the test if: |
| 155 | * - Property is not supported (res == NOT_SUPPORTED) |
| 156 | * - Result is success, and predicate is true |
| 157 | * @param res the Result value. |
| 158 | * @param valueStr the string representation for actual value (for error message) |
| 159 | * @param pred a predicate that test whether the value is valid |
| 160 | */ |
| 161 | #define EXPECT_VALID_OR_UNSUPPORTED_PROP(res, valueStr, pred) \ |
| 162 | EXPECT_TRUE(isPropertyOk(res, valueStr, pred, #pred)) |
| 163 | |
| 164 | AssertionResult isPropertyOk(Result res, const std::string& valueStr, bool pred, |
| 165 | const std::string& predStr) { |
| 166 | if (res == Result::SUCCESS) { |
| 167 | if (pred) { |
| 168 | return AssertionSuccess(); |
| 169 | } |
| 170 | return AssertionFailure() << "value doesn't match.\nActual: " << valueStr |
| 171 | << "\nExpected: " << predStr; |
| 172 | } |
| 173 | if (res == Result::NOT_SUPPORTED) { |
| 174 | return AssertionSuccess(); |
| 175 | } |
| 176 | return AssertionFailure() << "Result is not SUCCESS or NOT_SUPPORTED: " << toString(res); |
| 177 | } |
| 178 | |
Hridya Valsaraju | 2120ecc | 2017-12-20 13:27:52 -0800 | [diff] [blame] | 179 | bool verifyStorageInfo(const hidl_vec<struct StorageInfo>& info) { |
| 180 | for (size_t i = 0; i < info.size(); i++) { |
| 181 | if (!(0 <= info[i].eol && info[i].eol <= 3 && 0 <= info[i].lifetimeA && |
| 182 | info[i].lifetimeA <= 0x0B && 0 <= info[i].lifetimeB && info[i].lifetimeB <= 0x0B)) { |
| 183 | return false; |
| 184 | } |
| 185 | } |
| 186 | |
| 187 | return true; |
| 188 | } |
| 189 | |
Hridya Valsaraju | 87e2960 | 2018-01-12 17:46:22 -0800 | [diff] [blame] | 190 | template <typename T> |
| 191 | bool verifyEnum(T value) { |
Steven Moreland | c90461c | 2018-05-01 16:54:09 -0700 | [diff] [blame] | 192 | for (auto it : hidl_enum_range<T>()) { |
Hridya Valsaraju | 87e2960 | 2018-01-12 17:46:22 -0800 | [diff] [blame] | 193 | if (it == value) { |
| 194 | return true; |
| 195 | } |
| 196 | } |
| 197 | |
| 198 | return false; |
| 199 | } |
| 200 | |
| 201 | bool verifyHealthInfo(const HealthInfo& health_info) { |
Hridya Valsaraju | 075c182 | 2018-04-03 11:19:08 -0700 | [diff] [blame] | 202 | if (!verifyStorageInfo(health_info.storageInfos)) { |
Hridya Valsaraju | 87e2960 | 2018-01-12 17:46:22 -0800 | [diff] [blame] | 203 | return false; |
| 204 | } |
| 205 | |
| 206 | using V1_0::BatteryStatus; |
| 207 | using V1_0::BatteryHealth; |
| 208 | |
Robin Lee | ac5a0d3 | 2019-10-09 15:48:17 +0200 | [diff] [blame] | 209 | if (!((health_info.legacy.batteryCurrent != INT32_MIN) && |
Hridya Valsaraju | 87e2960 | 2018-01-12 17:46:22 -0800 | [diff] [blame] | 210 | (0 <= health_info.legacy.batteryLevel && health_info.legacy.batteryLevel <= 100) && |
| 211 | verifyEnum<BatteryHealth>(health_info.legacy.batteryHealth) && |
Hridya Valsaraju | 87e2960 | 2018-01-12 17:46:22 -0800 | [diff] [blame] | 212 | verifyEnum<BatteryStatus>(health_info.legacy.batteryStatus))) { |
| 213 | return false; |
| 214 | } |
| 215 | |
Robin Lee | ac5a0d3 | 2019-10-09 15:48:17 +0200 | [diff] [blame] | 216 | if (health_info.legacy.batteryPresent) { |
| 217 | // If a battery is present, the battery status must be known. |
| 218 | if (!((health_info.legacy.batteryChargeCounter > 0) && |
| 219 | (health_info.legacy.batteryStatus != BatteryStatus::UNKNOWN))) { |
| 220 | return false; |
| 221 | } |
| 222 | } |
| 223 | |
Hridya Valsaraju | 87e2960 | 2018-01-12 17:46:22 -0800 | [diff] [blame] | 224 | return true; |
| 225 | } |
| 226 | |
| 227 | /* |
Yifan Hong | 26c1200 | 2018-10-02 14:52:02 -0700 | [diff] [blame] | 228 | * Tests the values returned by getChargeCounter() from interface IHealth. |
Hridya Valsaraju | 87e2960 | 2018-01-12 17:46:22 -0800 | [diff] [blame] | 229 | */ |
nelsonli | 4da3ca5 | 2019-12-10 17:17:09 +0800 | [diff] [blame] | 230 | TEST_P(HealthHidlTest, getChargeCounter) { |
Yifan Hong | 69c2254 | 2017-10-03 17:40:24 -0700 | [diff] [blame] | 231 | EXPECT_OK(mHealth->getChargeCounter([](auto result, auto value) { |
| 232 | EXPECT_VALID_OR_UNSUPPORTED_PROP(result, std::to_string(value), value > 0); |
| 233 | })); |
Yifan Hong | 26c1200 | 2018-10-02 14:52:02 -0700 | [diff] [blame] | 234 | } |
| 235 | |
| 236 | /* |
| 237 | * Tests the values returned by getCurrentNow() from interface IHealth. |
| 238 | */ |
nelsonli | 4da3ca5 | 2019-12-10 17:17:09 +0800 | [diff] [blame] | 239 | TEST_P(HealthHidlTest, getCurrentNow) { |
Yifan Hong | 69c2254 | 2017-10-03 17:40:24 -0700 | [diff] [blame] | 240 | EXPECT_OK(mHealth->getCurrentNow([](auto result, auto value) { |
| 241 | EXPECT_VALID_OR_UNSUPPORTED_PROP(result, std::to_string(value), value != INT32_MIN); |
| 242 | })); |
Yifan Hong | 26c1200 | 2018-10-02 14:52:02 -0700 | [diff] [blame] | 243 | } |
| 244 | |
| 245 | /* |
| 246 | * Tests the values returned by getCurrentAverage() from interface IHealth. |
| 247 | */ |
nelsonli | 4da3ca5 | 2019-12-10 17:17:09 +0800 | [diff] [blame] | 248 | TEST_P(HealthHidlTest, getCurrentAverage) { |
Yifan Hong | 69c2254 | 2017-10-03 17:40:24 -0700 | [diff] [blame] | 249 | EXPECT_OK(mHealth->getCurrentAverage([](auto result, auto value) { |
| 250 | EXPECT_VALID_OR_UNSUPPORTED_PROP(result, std::to_string(value), value != INT32_MIN); |
| 251 | })); |
Yifan Hong | 26c1200 | 2018-10-02 14:52:02 -0700 | [diff] [blame] | 252 | } |
| 253 | |
| 254 | /* |
| 255 | * Tests the values returned by getCapacity() from interface IHealth. |
| 256 | */ |
nelsonli | 4da3ca5 | 2019-12-10 17:17:09 +0800 | [diff] [blame] | 257 | TEST_P(HealthHidlTest, getCapacity) { |
Yifan Hong | 69c2254 | 2017-10-03 17:40:24 -0700 | [diff] [blame] | 258 | EXPECT_OK(mHealth->getCapacity([](auto result, auto value) { |
| 259 | EXPECT_VALID_OR_UNSUPPORTED_PROP(result, std::to_string(value), 0 <= value && value <= 100); |
| 260 | })); |
Yifan Hong | 26c1200 | 2018-10-02 14:52:02 -0700 | [diff] [blame] | 261 | } |
| 262 | |
| 263 | /* |
| 264 | * Tests the values returned by getEnergyCounter() from interface IHealth. |
| 265 | */ |
nelsonli | 4da3ca5 | 2019-12-10 17:17:09 +0800 | [diff] [blame] | 266 | TEST_P(HealthHidlTest, getEnergyCounter) { |
Yifan Hong | 69c2254 | 2017-10-03 17:40:24 -0700 | [diff] [blame] | 267 | EXPECT_OK(mHealth->getEnergyCounter([](auto result, auto value) { |
| 268 | EXPECT_VALID_OR_UNSUPPORTED_PROP(result, std::to_string(value), value != INT64_MIN); |
| 269 | })); |
Yifan Hong | 26c1200 | 2018-10-02 14:52:02 -0700 | [diff] [blame] | 270 | } |
| 271 | |
| 272 | /* |
| 273 | * Tests the values returned by getChargeStatus() from interface IHealth. |
| 274 | */ |
nelsonli | 4da3ca5 | 2019-12-10 17:17:09 +0800 | [diff] [blame] | 275 | TEST_P(HealthHidlTest, getChargeStatus) { |
Yifan Hong | 69c2254 | 2017-10-03 17:40:24 -0700 | [diff] [blame] | 276 | EXPECT_OK(mHealth->getChargeStatus([](auto result, auto value) { |
Yifan Hong | 5ac6f5b | 2020-01-27 16:20:49 -0800 | [diff] [blame] | 277 | EXPECT_VALID_OR_UNSUPPORTED_PROP(result, toString(value), verifyEnum<BatteryStatus>(value)); |
Yifan Hong | 69c2254 | 2017-10-03 17:40:24 -0700 | [diff] [blame] | 278 | })); |
Yifan Hong | 26c1200 | 2018-10-02 14:52:02 -0700 | [diff] [blame] | 279 | } |
| 280 | |
| 281 | /* |
| 282 | * Tests the values returned by getStorageInfo() from interface IHealth. |
| 283 | */ |
nelsonli | 4da3ca5 | 2019-12-10 17:17:09 +0800 | [diff] [blame] | 284 | TEST_P(HealthHidlTest, getStorageInfo) { |
Hridya Valsaraju | 2120ecc | 2017-12-20 13:27:52 -0800 | [diff] [blame] | 285 | EXPECT_OK(mHealth->getStorageInfo([](auto result, auto& value) { |
Hridya Valsaraju | 87e2960 | 2018-01-12 17:46:22 -0800 | [diff] [blame] | 286 | EXPECT_VALID_OR_UNSUPPORTED_PROP(result, toString(value), verifyStorageInfo(value)); |
Hridya Valsaraju | 2120ecc | 2017-12-20 13:27:52 -0800 | [diff] [blame] | 287 | })); |
Yifan Hong | 26c1200 | 2018-10-02 14:52:02 -0700 | [diff] [blame] | 288 | } |
| 289 | |
| 290 | /* |
| 291 | * Tests the values returned by getDiskStats() from interface IHealth. |
| 292 | */ |
nelsonli | 4da3ca5 | 2019-12-10 17:17:09 +0800 | [diff] [blame] | 293 | TEST_P(HealthHidlTest, getDiskStats) { |
Hridya Valsaraju | 2120ecc | 2017-12-20 13:27:52 -0800 | [diff] [blame] | 294 | EXPECT_OK(mHealth->getDiskStats([](auto result, auto& value) { |
Hridya Valsaraju | 075c182 | 2018-04-03 11:19:08 -0700 | [diff] [blame] | 295 | EXPECT_VALID_OR_UNSUPPORTED_PROP(result, toString(value), true); |
Hridya Valsaraju | 2120ecc | 2017-12-20 13:27:52 -0800 | [diff] [blame] | 296 | })); |
Yifan Hong | 26c1200 | 2018-10-02 14:52:02 -0700 | [diff] [blame] | 297 | } |
| 298 | |
| 299 | /* |
| 300 | * Tests the values returned by getHealthInfo() from interface IHealth. |
| 301 | */ |
nelsonli | 4da3ca5 | 2019-12-10 17:17:09 +0800 | [diff] [blame] | 302 | TEST_P(HealthHidlTest, getHealthInfo) { |
Hridya Valsaraju | 87e2960 | 2018-01-12 17:46:22 -0800 | [diff] [blame] | 303 | EXPECT_OK(mHealth->getHealthInfo([](auto result, auto& value) { |
| 304 | EXPECT_VALID_OR_UNSUPPORTED_PROP(result, toString(value), verifyHealthInfo(value)); |
| 305 | })); |
Yifan Hong | 69c2254 | 2017-10-03 17:40:24 -0700 | [diff] [blame] | 306 | } |
| 307 | |
nelsonli | 4da3ca5 | 2019-12-10 17:17:09 +0800 | [diff] [blame] | 308 | INSTANTIATE_TEST_SUITE_P( |
| 309 | PerInstance, HealthHidlTest, |
| 310 | testing::ValuesIn(android::hardware::getAllHalInstanceNames(IHealth::descriptor)), |
| 311 | android::hardware::PrintInstanceNameToString); |
Yifan Hong | 69c2254 | 2017-10-03 17:40:24 -0700 | [diff] [blame] | 312 | } // namespace V2_0 |
| 313 | } // namespace health |
| 314 | } // namespace hardware |
| 315 | } // namespace android |
| 316 | |
| 317 | int main(int argc, char** argv) { |
Yifan Hong | 69c2254 | 2017-10-03 17:40:24 -0700 | [diff] [blame] | 318 | ::testing::InitGoogleTest(&argc, argv); |
Yifan Hong | e6807dd | 2019-03-07 13:04:33 -0800 | [diff] [blame] | 319 | gflags::ParseCommandLineFlags(&argc, &argv, true /* remove flags */); |
nelsonli | 4da3ca5 | 2019-12-10 17:17:09 +0800 | [diff] [blame] | 320 | return RUN_ALL_TESTS(); |
Yifan Hong | 69c2254 | 2017-10-03 17:40:24 -0700 | [diff] [blame] | 321 | } |