Arthur Ishiguro | 4e916c3 | 2021-08-12 12:47:03 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2021 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 | #include <aidl/Gtest.h> |
| 17 | #include <aidl/Vintf.h> |
| 18 | |
| 19 | #include "VtsHalContexthubUtilsCommon.h" |
| 20 | |
| 21 | #include <android/hardware/contexthub/BnContextHub.h> |
| 22 | #include <android/hardware/contexthub/BnContextHubCallback.h> |
| 23 | #include <android/hardware/contexthub/IContextHub.h> |
| 24 | #include <android/hardware/contexthub/IContextHubCallback.h> |
| 25 | #include <binder/IServiceManager.h> |
| 26 | #include <binder/ProcessState.h> |
| 27 | #include <log/log.h> |
| 28 | |
| 29 | #include <cinttypes> |
| 30 | #include <future> |
| 31 | |
| 32 | using ::android::ProcessState; |
| 33 | using ::android::sp; |
| 34 | using ::android::String16; |
| 35 | using ::android::binder::Status; |
| 36 | using ::android::hardware::contexthub::AsyncEventType; |
| 37 | using ::android::hardware::contexthub::ContextHubInfo; |
| 38 | using ::android::hardware::contexthub::ContextHubMessage; |
Arthur Ishiguro | 065a9a5 | 2021-11-19 00:24:45 +0000 | [diff] [blame] | 39 | using ::android::hardware::contexthub::HostEndpointInfo; |
Arthur Ishiguro | 4e916c3 | 2021-08-12 12:47:03 -0700 | [diff] [blame] | 40 | using ::android::hardware::contexthub::IContextHub; |
| 41 | using ::android::hardware::contexthub::IContextHubCallbackDefault; |
| 42 | using ::android::hardware::contexthub::NanoappBinary; |
| 43 | using ::android::hardware::contexthub::NanoappInfo; |
Arthur Ishiguro | 0810307 | 2021-12-09 18:30:49 +0000 | [diff] [blame] | 44 | using ::android::hardware::contexthub::NanoappRpcService; |
Arthur Ishiguro | 4e916c3 | 2021-08-12 12:47:03 -0700 | [diff] [blame] | 45 | using ::android::hardware::contexthub::Setting; |
| 46 | using ::android::hardware::contexthub::vts_utils::kNonExistentAppId; |
| 47 | using ::android::hardware::contexthub::vts_utils::waitForCallback; |
| 48 | |
| 49 | class ContextHubAidl : public testing::TestWithParam<std::tuple<std::string, int32_t>> { |
| 50 | public: |
| 51 | virtual void SetUp() override { |
| 52 | contextHub = android::waitForDeclaredService<IContextHub>( |
| 53 | String16(std::get<0>(GetParam()).c_str())); |
| 54 | ASSERT_NE(contextHub, nullptr); |
| 55 | } |
| 56 | |
| 57 | uint32_t getHubId() { return std::get<1>(GetParam()); } |
| 58 | |
| 59 | void testSettingChanged(Setting setting); |
| 60 | |
| 61 | sp<IContextHub> contextHub; |
| 62 | }; |
| 63 | |
| 64 | TEST_P(ContextHubAidl, TestGetHubs) { |
| 65 | std::vector<ContextHubInfo> hubs; |
| 66 | ASSERT_TRUE(contextHub->getContextHubs(&hubs).isOk()); |
| 67 | |
| 68 | ALOGD("System reports %zu hubs", hubs.size()); |
| 69 | |
| 70 | for (const ContextHubInfo& hub : hubs) { |
| 71 | ALOGD("Checking hub ID %" PRIu32, hub.id); |
| 72 | |
| 73 | EXPECT_GT(hub.name.size(), 0); |
| 74 | EXPECT_GT(hub.vendor.size(), 0); |
| 75 | EXPECT_GT(hub.toolchain.size(), 0); |
| 76 | EXPECT_GT(hub.peakMips, 0); |
| 77 | EXPECT_GT(hub.chrePlatformId, 0); |
| 78 | EXPECT_GT(hub.chreApiMajorVersion, 0); |
Arthur Ishiguro | 6471f61 | 2021-10-28 21:59:55 +0000 | [diff] [blame] | 79 | EXPECT_GE(hub.chreApiMinorVersion, 0); |
| 80 | EXPECT_GE(hub.chrePatchVersion, 0); |
Arthur Ishiguro | 4e916c3 | 2021-08-12 12:47:03 -0700 | [diff] [blame] | 81 | |
| 82 | // Minimum 128 byte MTU as required by CHRE API v1.0 |
| 83 | EXPECT_GE(hub.maxSupportedMessageLengthBytes, UINT32_C(128)); |
| 84 | } |
| 85 | } |
| 86 | |
Arthur Ishiguro | e6b540d | 2021-10-29 16:01:35 +0000 | [diff] [blame] | 87 | class EmptyContextHubCallback : public android::hardware::contexthub::BnContextHubCallback { |
| 88 | public: |
| 89 | Status handleNanoappInfo(const std::vector<NanoappInfo>& /* appInfo */) override { |
| 90 | return Status::ok(); |
| 91 | } |
| 92 | |
| 93 | Status handleContextHubMessage(const ContextHubMessage& /* msg */, |
| 94 | const std::vector<String16>& /* msgContentPerms */) override { |
| 95 | return Status::ok(); |
| 96 | } |
| 97 | |
| 98 | Status handleContextHubAsyncEvent(AsyncEventType /* evt */) override { return Status::ok(); } |
| 99 | |
| 100 | Status handleTransactionResult(int32_t /* transactionId */, bool /* success */) override { |
| 101 | return Status::ok(); |
| 102 | } |
Anthony Stange | 7344af9 | 2022-12-22 14:21:31 +0000 | [diff] [blame] | 103 | |
| 104 | Status handleNanSessionRequest(bool /* enable */) override { return Status::ok(); } |
Arthur Ishiguro | e6b540d | 2021-10-29 16:01:35 +0000 | [diff] [blame] | 105 | }; |
| 106 | |
Arthur Ishiguro | 4e916c3 | 2021-08-12 12:47:03 -0700 | [diff] [blame] | 107 | TEST_P(ContextHubAidl, TestRegisterCallback) { |
Arthur Ishiguro | e6b540d | 2021-10-29 16:01:35 +0000 | [diff] [blame] | 108 | sp<EmptyContextHubCallback> cb = sp<EmptyContextHubCallback>::make(); |
Arthur Ishiguro | 070f47d | 2022-01-06 22:42:10 +0000 | [diff] [blame] | 109 | ASSERT_TRUE(contextHub->registerCallback(getHubId(), cb).isOk()); |
Arthur Ishiguro | 4e916c3 | 2021-08-12 12:47:03 -0700 | [diff] [blame] | 110 | } |
| 111 | |
| 112 | TEST_P(ContextHubAidl, TestRegisterNullCallback) { |
Arthur Ishiguro | 070f47d | 2022-01-06 22:42:10 +0000 | [diff] [blame] | 113 | ASSERT_TRUE(contextHub->registerCallback(getHubId(), nullptr).isOk()); |
Arthur Ishiguro | 4e916c3 | 2021-08-12 12:47:03 -0700 | [diff] [blame] | 114 | } |
| 115 | |
| 116 | // Helper callback that puts the async appInfo callback data into a promise |
| 117 | class QueryAppsCallback : public android::hardware::contexthub::BnContextHubCallback { |
| 118 | public: |
| 119 | Status handleNanoappInfo(const std::vector<NanoappInfo>& appInfo) override { |
| 120 | ALOGD("Got app info callback with %zu apps", appInfo.size()); |
| 121 | promise.set_value(appInfo); |
| 122 | return Status::ok(); |
| 123 | } |
| 124 | |
| 125 | Status handleContextHubMessage(const ContextHubMessage& /* msg */, |
| 126 | const std::vector<String16>& /* msgContentPerms */) override { |
| 127 | return Status::ok(); |
| 128 | } |
| 129 | |
| 130 | Status handleContextHubAsyncEvent(AsyncEventType /* evt */) override { return Status::ok(); } |
| 131 | |
| 132 | Status handleTransactionResult(int32_t /* transactionId */, bool /* success */) override { |
| 133 | return Status::ok(); |
| 134 | } |
| 135 | |
Anthony Stange | 7344af9 | 2022-12-22 14:21:31 +0000 | [diff] [blame] | 136 | Status handleNanSessionRequest(bool /* enable */) override { return Status::ok(); } |
| 137 | |
Arthur Ishiguro | 4e916c3 | 2021-08-12 12:47:03 -0700 | [diff] [blame] | 138 | std::promise<std::vector<NanoappInfo>> promise; |
| 139 | }; |
| 140 | |
| 141 | // Calls queryApps() and checks the returned metadata |
| 142 | TEST_P(ContextHubAidl, TestQueryApps) { |
| 143 | sp<QueryAppsCallback> cb = sp<QueryAppsCallback>::make(); |
Arthur Ishiguro | 070f47d | 2022-01-06 22:42:10 +0000 | [diff] [blame] | 144 | ASSERT_TRUE(contextHub->registerCallback(getHubId(), cb).isOk()); |
| 145 | ASSERT_TRUE(contextHub->queryNanoapps(getHubId()).isOk()); |
Arthur Ishiguro | 4e916c3 | 2021-08-12 12:47:03 -0700 | [diff] [blame] | 146 | |
| 147 | std::vector<NanoappInfo> appInfoList; |
| 148 | ASSERT_TRUE(waitForCallback(cb->promise.get_future(), &appInfoList)); |
| 149 | for (const NanoappInfo& appInfo : appInfoList) { |
| 150 | EXPECT_NE(appInfo.nanoappId, UINT64_C(0)); |
| 151 | EXPECT_NE(appInfo.nanoappId, kNonExistentAppId); |
Arthur Ishiguro | 0810307 | 2021-12-09 18:30:49 +0000 | [diff] [blame] | 152 | |
| 153 | // Verify services are unique. |
| 154 | std::set<uint64_t> existingServiceIds; |
| 155 | for (const NanoappRpcService& rpcService : appInfo.rpcServices) { |
| 156 | EXPECT_NE(rpcService.id, UINT64_C(0)); |
| 157 | EXPECT_EQ(existingServiceIds.count(rpcService.id), 0); |
| 158 | existingServiceIds.insert(rpcService.id); |
| 159 | } |
Arthur Ishiguro | 4e916c3 | 2021-08-12 12:47:03 -0700 | [diff] [blame] | 160 | } |
| 161 | } |
| 162 | |
Arthur Ishiguro | fd5e65c | 2022-11-08 16:49:47 +0000 | [diff] [blame] | 163 | // Calls getPreloadedNanoapps() and verifies there are preloaded nanoapps |
| 164 | TEST_P(ContextHubAidl, TestGetPreloadedNanoapps) { |
| 165 | std::vector<int64_t> preloadedNanoappIds; |
| 166 | Status status = contextHub->getPreloadedNanoappIds(&preloadedNanoappIds); |
| 167 | if (status.exceptionCode() == Status::EX_UNSUPPORTED_OPERATION || |
| 168 | status.transactionError() == android::UNKNOWN_TRANSACTION) { |
| 169 | return; // not supported -> old API; or not implemented |
| 170 | } |
| 171 | |
| 172 | ASSERT_TRUE(status.isOk()); |
| 173 | ASSERT_FALSE(preloadedNanoappIds.empty()); |
| 174 | } |
| 175 | |
Arthur Ishiguro | 4e916c3 | 2021-08-12 12:47:03 -0700 | [diff] [blame] | 176 | // Helper callback that puts the TransactionResult for the expectedTransactionId into a |
| 177 | // promise |
| 178 | class TransactionResultCallback : public android::hardware::contexthub::BnContextHubCallback { |
| 179 | public: |
| 180 | Status handleNanoappInfo(const std::vector<NanoappInfo>& /* appInfo */) override { |
| 181 | return Status::ok(); |
| 182 | } |
| 183 | |
| 184 | Status handleContextHubMessage(const ContextHubMessage& /* msg */, |
| 185 | const std::vector<String16>& /* msgContentPerms */) override { |
| 186 | return Status::ok(); |
| 187 | } |
| 188 | |
| 189 | Status handleContextHubAsyncEvent(AsyncEventType /* evt */) override { return Status::ok(); } |
| 190 | |
| 191 | Status handleTransactionResult(int32_t transactionId, bool success) override { |
| 192 | ALOGD("Got transaction result callback for transactionId %" PRIu32 " (expecting %" PRIu32 |
| 193 | ") with success %d", |
| 194 | transactionId, expectedTransactionId, success); |
| 195 | if (transactionId == expectedTransactionId) { |
| 196 | promise.set_value(success); |
| 197 | } |
| 198 | return Status::ok(); |
| 199 | } |
| 200 | |
Anthony Stange | 7344af9 | 2022-12-22 14:21:31 +0000 | [diff] [blame] | 201 | Status handleNanSessionRequest(bool /* enable */) override { return Status::ok(); } |
| 202 | |
Arthur Ishiguro | 4e916c3 | 2021-08-12 12:47:03 -0700 | [diff] [blame] | 203 | uint32_t expectedTransactionId = 0; |
| 204 | std::promise<bool> promise; |
| 205 | }; |
| 206 | |
| 207 | // Parameterized fixture that sets the callback to TransactionResultCallback |
| 208 | class ContextHubTransactionTest : public ContextHubAidl { |
| 209 | public: |
| 210 | virtual void SetUp() override { |
| 211 | ContextHubAidl::SetUp(); |
Arthur Ishiguro | 070f47d | 2022-01-06 22:42:10 +0000 | [diff] [blame] | 212 | ASSERT_TRUE(contextHub->registerCallback(getHubId(), cb).isOk()); |
Arthur Ishiguro | 4e916c3 | 2021-08-12 12:47:03 -0700 | [diff] [blame] | 213 | } |
| 214 | |
| 215 | sp<TransactionResultCallback> cb = sp<TransactionResultCallback>::make(); |
| 216 | }; |
| 217 | |
| 218 | TEST_P(ContextHubTransactionTest, TestSendMessageToNonExistentNanoapp) { |
| 219 | ContextHubMessage message; |
| 220 | message.nanoappId = kNonExistentAppId; |
| 221 | message.messageType = 1; |
| 222 | message.messageBody.resize(4); |
| 223 | std::fill(message.messageBody.begin(), message.messageBody.end(), 0); |
| 224 | |
| 225 | ALOGD("Sending message to non-existent nanoapp"); |
Arthur Ishiguro | 070f47d | 2022-01-06 22:42:10 +0000 | [diff] [blame] | 226 | ASSERT_TRUE(contextHub->sendMessageToHub(getHubId(), message).isOk()); |
Arthur Ishiguro | 4e916c3 | 2021-08-12 12:47:03 -0700 | [diff] [blame] | 227 | } |
| 228 | |
| 229 | TEST_P(ContextHubTransactionTest, TestLoadEmptyNanoapp) { |
| 230 | cb->expectedTransactionId = 0123; |
| 231 | NanoappBinary emptyApp; |
| 232 | |
| 233 | emptyApp.nanoappId = kNonExistentAppId; |
| 234 | emptyApp.nanoappVersion = 1; |
| 235 | emptyApp.flags = 0; |
| 236 | emptyApp.targetChreApiMajorVersion = 1; |
| 237 | emptyApp.targetChreApiMinorVersion = 0; |
| 238 | |
| 239 | ALOGD("Loading empty nanoapp"); |
Arthur Ishiguro | 070f47d | 2022-01-06 22:42:10 +0000 | [diff] [blame] | 240 | bool success = contextHub->loadNanoapp(getHubId(), emptyApp, cb->expectedTransactionId).isOk(); |
Arthur Ishiguro | 4e916c3 | 2021-08-12 12:47:03 -0700 | [diff] [blame] | 241 | if (success) { |
| 242 | bool transactionSuccess; |
| 243 | ASSERT_TRUE(waitForCallback(cb->promise.get_future(), &transactionSuccess)); |
| 244 | ASSERT_FALSE(transactionSuccess); |
| 245 | } |
| 246 | } |
| 247 | |
| 248 | TEST_P(ContextHubTransactionTest, TestUnloadNonexistentNanoapp) { |
| 249 | cb->expectedTransactionId = 1234; |
| 250 | |
| 251 | ALOGD("Unloading nonexistent nanoapp"); |
Arthur Ishiguro | 070f47d | 2022-01-06 22:42:10 +0000 | [diff] [blame] | 252 | bool success = |
| 253 | contextHub->unloadNanoapp(getHubId(), kNonExistentAppId, cb->expectedTransactionId) |
| 254 | .isOk(); |
Arthur Ishiguro | 4e916c3 | 2021-08-12 12:47:03 -0700 | [diff] [blame] | 255 | if (success) { |
| 256 | bool transactionSuccess; |
| 257 | ASSERT_TRUE(waitForCallback(cb->promise.get_future(), &transactionSuccess)); |
| 258 | ASSERT_FALSE(transactionSuccess); |
| 259 | } |
| 260 | } |
| 261 | |
| 262 | TEST_P(ContextHubTransactionTest, TestEnableNonexistentNanoapp) { |
| 263 | cb->expectedTransactionId = 2345; |
| 264 | |
| 265 | ALOGD("Enabling nonexistent nanoapp"); |
Arthur Ishiguro | 070f47d | 2022-01-06 22:42:10 +0000 | [diff] [blame] | 266 | bool success = |
| 267 | contextHub->enableNanoapp(getHubId(), kNonExistentAppId, cb->expectedTransactionId) |
| 268 | .isOk(); |
Arthur Ishiguro | 4e916c3 | 2021-08-12 12:47:03 -0700 | [diff] [blame] | 269 | if (success) { |
| 270 | bool transactionSuccess; |
| 271 | ASSERT_TRUE(waitForCallback(cb->promise.get_future(), &transactionSuccess)); |
| 272 | ASSERT_FALSE(transactionSuccess); |
| 273 | } |
| 274 | } |
| 275 | |
| 276 | TEST_P(ContextHubTransactionTest, TestDisableNonexistentNanoapp) { |
| 277 | cb->expectedTransactionId = 3456; |
| 278 | |
| 279 | ALOGD("Disabling nonexistent nanoapp"); |
Arthur Ishiguro | 070f47d | 2022-01-06 22:42:10 +0000 | [diff] [blame] | 280 | bool success = |
| 281 | contextHub->disableNanoapp(getHubId(), kNonExistentAppId, cb->expectedTransactionId) |
| 282 | .isOk(); |
Arthur Ishiguro | 4e916c3 | 2021-08-12 12:47:03 -0700 | [diff] [blame] | 283 | if (success) { |
| 284 | bool transactionSuccess; |
| 285 | ASSERT_TRUE(waitForCallback(cb->promise.get_future(), &transactionSuccess)); |
| 286 | ASSERT_FALSE(transactionSuccess); |
| 287 | } |
| 288 | } |
| 289 | |
| 290 | void ContextHubAidl::testSettingChanged(Setting setting) { |
| 291 | // In VTS, we only test that sending the values doesn't cause things to blow up - GTS tests |
| 292 | // verify the expected E2E behavior in CHRE |
Arthur Ishiguro | e6b540d | 2021-10-29 16:01:35 +0000 | [diff] [blame] | 293 | sp<EmptyContextHubCallback> cb = sp<EmptyContextHubCallback>::make(); |
Arthur Ishiguro | 070f47d | 2022-01-06 22:42:10 +0000 | [diff] [blame] | 294 | ASSERT_TRUE(contextHub->registerCallback(getHubId(), cb).isOk()); |
Arthur Ishiguro | 4e916c3 | 2021-08-12 12:47:03 -0700 | [diff] [blame] | 295 | |
| 296 | ASSERT_TRUE(contextHub->onSettingChanged(setting, true /* enabled */).isOk()); |
| 297 | ASSERT_TRUE(contextHub->onSettingChanged(setting, false /* enabled */).isOk()); |
| 298 | |
Arthur Ishiguro | 070f47d | 2022-01-06 22:42:10 +0000 | [diff] [blame] | 299 | ASSERT_TRUE(contextHub->registerCallback(getHubId(), nullptr).isOk()); |
Arthur Ishiguro | 4e916c3 | 2021-08-12 12:47:03 -0700 | [diff] [blame] | 300 | } |
| 301 | |
| 302 | TEST_P(ContextHubAidl, TestOnLocationSettingChanged) { |
| 303 | testSettingChanged(Setting::LOCATION); |
| 304 | } |
| 305 | |
| 306 | TEST_P(ContextHubAidl, TestOnWifiMainSettingChanged) { |
| 307 | testSettingChanged(Setting::WIFI_MAIN); |
| 308 | } |
| 309 | |
| 310 | TEST_P(ContextHubAidl, TestOnWifiScanningSettingChanged) { |
| 311 | testSettingChanged(Setting::WIFI_SCANNING); |
| 312 | } |
| 313 | |
| 314 | TEST_P(ContextHubAidl, TestOnAirplaneModeSettingChanged) { |
| 315 | testSettingChanged(Setting::AIRPLANE_MODE); |
| 316 | } |
| 317 | |
| 318 | TEST_P(ContextHubAidl, TestOnMicrophoneSettingChanged) { |
| 319 | testSettingChanged(Setting::MICROPHONE); |
| 320 | } |
| 321 | |
Anthony | a6b6500 | 2022-01-20 20:49:10 +0000 | [diff] [blame] | 322 | TEST_P(ContextHubAidl, TestOnBtMainSettingChanged) { |
| 323 | testSettingChanged(Setting::BT_MAIN); |
| 324 | } |
| 325 | |
| 326 | TEST_P(ContextHubAidl, TestOnBtScanningSettingChanged) { |
| 327 | testSettingChanged(Setting::BT_SCANNING); |
| 328 | } |
| 329 | |
Arthur Ishiguro | 4e916c3 | 2021-08-12 12:47:03 -0700 | [diff] [blame] | 330 | std::vector<std::tuple<std::string, int32_t>> generateContextHubMapping() { |
| 331 | std::vector<std::tuple<std::string, int32_t>> tuples; |
| 332 | auto contextHubAidlNames = android::getAidlHalInstanceNames(IContextHub::descriptor); |
| 333 | std::vector<ContextHubInfo> contextHubInfos; |
| 334 | |
| 335 | for (int i = 0; i < contextHubAidlNames.size(); i++) { |
| 336 | auto contextHubName = contextHubAidlNames[i].c_str(); |
| 337 | auto contextHub = android::waitForDeclaredService<IContextHub>(String16(contextHubName)); |
| 338 | if (contextHub->getContextHubs(&contextHubInfos).isOk()) { |
| 339 | for (auto& info : contextHubInfos) { |
| 340 | tuples.push_back(std::make_tuple(contextHubName, info.id)); |
| 341 | } |
| 342 | } |
| 343 | } |
| 344 | |
| 345 | return tuples; |
| 346 | } |
| 347 | |
Arthur Ishiguro | 065a9a5 | 2021-11-19 00:24:45 +0000 | [diff] [blame] | 348 | TEST_P(ContextHubAidl, TestHostConnection) { |
| 349 | constexpr char16_t kHostEndpointId = 1; |
| 350 | HostEndpointInfo hostEndpointInfo; |
| 351 | hostEndpointInfo.hostEndpointId = kHostEndpointId; |
| 352 | |
| 353 | ASSERT_TRUE(contextHub->onHostEndpointConnected(hostEndpointInfo).isOk()); |
| 354 | ASSERT_TRUE(contextHub->onHostEndpointDisconnected(kHostEndpointId).isOk()); |
| 355 | } |
| 356 | |
| 357 | TEST_P(ContextHubAidl, TestInvalidHostConnection) { |
| 358 | constexpr char16_t kHostEndpointId = 1; |
| 359 | |
Arthur Ishiguro | 5dba921 | 2022-02-01 17:03:32 +0000 | [diff] [blame] | 360 | ASSERT_TRUE(contextHub->onHostEndpointDisconnected(kHostEndpointId).isOk()); |
Arthur Ishiguro | 065a9a5 | 2021-11-19 00:24:45 +0000 | [diff] [blame] | 361 | } |
| 362 | |
Anthony Stange | 7344af9 | 2022-12-22 14:21:31 +0000 | [diff] [blame] | 363 | TEST_P(ContextHubAidl, TestNanSessionStateChange) { |
| 364 | ASSERT_TRUE(contextHub->onNanSessionStateChanged(true /*state*/).isOk()); |
| 365 | ASSERT_TRUE(contextHub->onNanSessionStateChanged(false /*state*/).isOk()); |
| 366 | } |
| 367 | |
Arthur Ishiguro | 4e916c3 | 2021-08-12 12:47:03 -0700 | [diff] [blame] | 368 | std::string PrintGeneratedTest(const testing::TestParamInfo<ContextHubAidl::ParamType>& info) { |
| 369 | return std::string("CONTEXT_HUB_ID_") + std::to_string(std::get<1>(info.param)); |
| 370 | } |
| 371 | |
| 372 | GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(ContextHubAidl); |
| 373 | INSTANTIATE_TEST_SUITE_P(ContextHub, ContextHubAidl, testing::ValuesIn(generateContextHubMapping()), |
| 374 | PrintGeneratedTest); |
| 375 | |
| 376 | GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(ContextHubTransactionTest); |
| 377 | INSTANTIATE_TEST_SUITE_P(ContextHub, ContextHubTransactionTest, |
| 378 | testing::ValuesIn(generateContextHubMapping()), PrintGeneratedTest); |
| 379 | |
| 380 | int main(int argc, char** argv) { |
| 381 | ::testing::InitGoogleTest(&argc, argv); |
| 382 | ProcessState::self()->setThreadPoolMaxThreadCount(1); |
| 383 | ProcessState::self()->startThreadPool(); |
| 384 | return RUN_ALL_TESTS(); |
| 385 | } |