1 /*
2 * Copyright (C) 2016 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
17 #include <android-base/logging.h>
18
19 #include <VtsHalHidlTargetTestBase.h>
20
21 #include <android/hardware/wifi/supplicant/1.0/ISupplicantP2pIface.h>
22
23 #include "supplicant_hidl_call_util.h"
24 #include "supplicant_hidl_test_utils.h"
25
26 using ::android::sp;
27 using ::android::hardware::hidl_array;
28 using ::android::hardware::hidl_string;
29 using ::android::hardware::hidl_vec;
30 using ::android::hardware::Return;
31 using ::android::hardware::Void;
32 using ::android::hardware::wifi::supplicant::V1_0::IfaceType;
33 using ::android::hardware::wifi::supplicant::V1_0::ISupplicantP2pIface;
34 using ::android::hardware::wifi::supplicant::V1_0::ISupplicantP2pIfaceCallback;
35 using ::android::hardware::wifi::supplicant::V1_0::SupplicantNetworkId;
36 using ::android::hardware::wifi::supplicant::V1_0::SupplicantStatus;
37 using ::android::hardware::wifi::supplicant::V1_0::SupplicantStatusCode;
38
39 namespace {
40 constexpr uint8_t kTestSsidPostfix[] = {'t', 'e', 's', 't'};
41 constexpr uint8_t kTestMacAddr[] = {0x56, 0x67, 0x67, 0xf4, 0x56, 0x92};
42 constexpr uint8_t kTestPeerMacAddr[] = {0x56, 0x67, 0x55, 0xf4, 0x56, 0x92};
43 constexpr uint8_t kTestBonjourServiceQuery[] = {'t', 'e', 's', 't', 'q',
44 'u', 'e', 'r', 'y'};
45 constexpr uint8_t kTestBonjourServiceResponse[] = {
46 't', 'e', 's', 't', 'r', 'e', 's', 'p', 'o', 'n', 's', 'e'};
47 constexpr uint8_t kTestWfdDeviceInfo[] = {[0 ... 5] = 0x01};
48 constexpr char kTestConnectPin[] = "34556665";
49 constexpr char kTestGroupIfName[] = "TestGroup";
50 constexpr char kTestWpsDeviceName[] = "TestWpsDeviceName";
51 constexpr char kTestWpsManufacturer[] = "TestManufacturer";
52 constexpr char kTestWpsModelName[] = "TestModelName";
53 constexpr char kTestWpsModelNumber[] = "TestModelNumber";
54 constexpr char kTestWpsSerialNumber[] = "TestSerialNumber";
55 constexpr char kTestUpnpServiceName[] = "TestServiceName";
56 constexpr uint8_t kTestWpsDeviceType[] = {[0 ... 7] = 0x01};
57 constexpr uint16_t kTestWpsConfigMethods = 0xffff;
58 constexpr uint32_t kTestConnectGoIntent = 6;
59 constexpr uint32_t kTestFindTimeout = 5;
60 constexpr uint32_t kTestSetGroupIdleTimeout = 6;
61 constexpr uint32_t kTestChannel = 1;
62 constexpr uint32_t kTestOperatingClass = 81;
63 constexpr uint32_t kTestFreqRange[] = {2412, 2432};
64 constexpr uint32_t kTestExtListenPeriod = 400;
65 constexpr uint32_t kTestExtListenInterval = 400;
66 constexpr SupplicantNetworkId kTestNetworkId = 5;
67 } // namespace
68
69 class SupplicantP2pIfaceHidlTest : public ::testing::VtsHalHidlTargetTestBase {
70 public:
SetUp()71 virtual void SetUp() override {
72 startSupplicantAndWaitForHidlService();
73 EXPECT_TRUE(turnOnExcessiveLogging());
74 p2p_iface_ = getSupplicantP2pIface();
75 ASSERT_NE(p2p_iface_.get(), nullptr);
76
77 memcpy(mac_addr_.data(), kTestMacAddr, mac_addr_.size());
78 memcpy(peer_mac_addr_.data(), kTestPeerMacAddr, peer_mac_addr_.size());
79 }
80
TearDown()81 virtual void TearDown() override { stopSupplicant(); }
82
83 protected:
84 // ISupplicantP2pIface object used for all tests in this fixture.
85 sp<ISupplicantP2pIface> p2p_iface_;
86 // MAC address to use for various tests.
87 std::array<uint8_t, 6> mac_addr_;
88 std::array<uint8_t, 6> peer_mac_addr_;
89 };
90
91 class IfaceCallback : public ISupplicantP2pIfaceCallback {
onNetworkAdded(uint32_t)92 Return<void> onNetworkAdded(uint32_t /* id */) override { return Void(); }
onNetworkRemoved(uint32_t)93 Return<void> onNetworkRemoved(uint32_t /* id */) override { return Void(); }
onDeviceFound(const hidl_array<uint8_t,6> &,const hidl_array<uint8_t,6> &,const hidl_array<uint8_t,8> &,const hidl_string &,uint16_t,uint8_t,uint32_t,const hidl_array<uint8_t,6> &)94 Return<void> onDeviceFound(
95 const hidl_array<uint8_t, 6>& /* srcAddress */,
96 const hidl_array<uint8_t, 6>& /* p2pDeviceAddress */,
97 const hidl_array<uint8_t, 8>& /* primaryDeviceType */,
98 const hidl_string& /* deviceName */, uint16_t /* configMethods */,
99 uint8_t /* deviceCapabilities */, uint32_t /* groupCapabilities */,
100 const hidl_array<uint8_t, 6>& /* wfdDeviceInfo */) override {
101 return Void();
102 }
onDeviceLost(const hidl_array<uint8_t,6> &)103 Return<void> onDeviceLost(
104 const hidl_array<uint8_t, 6>& /* p2pDeviceAddress */) override {
105 return Void();
106 }
onFindStopped()107 Return<void> onFindStopped() override { return Void(); }
onGoNegotiationRequest(const hidl_array<uint8_t,6> &,ISupplicantP2pIfaceCallback::WpsDevPasswordId)108 Return<void> onGoNegotiationRequest(
109 const hidl_array<uint8_t, 6>& /* srcAddress */,
110 ISupplicantP2pIfaceCallback::WpsDevPasswordId /* passwordId */)
111 override {
112 return Void();
113 }
onGoNegotiationCompleted(ISupplicantP2pIfaceCallback::P2pStatusCode)114 Return<void> onGoNegotiationCompleted(
115 ISupplicantP2pIfaceCallback::P2pStatusCode /* status */) override {
116 return Void();
117 }
onGroupFormationSuccess()118 Return<void> onGroupFormationSuccess() override { return Void(); }
onGroupFormationFailure(const hidl_string &)119 Return<void> onGroupFormationFailure(
120 const hidl_string& /* failureReason */) override {
121 return Void();
122 }
onGroupStarted(const hidl_string &,bool,const hidl_vec<uint8_t> &,uint32_t,const hidl_array<uint8_t,32> &,const hidl_string &,const hidl_array<uint8_t,6> &,bool)123 Return<void> onGroupStarted(
124 const hidl_string& /* groupIfname */, bool /* isGo */,
125 const hidl_vec<uint8_t>& /* ssid */, uint32_t /* frequency */,
126 const hidl_array<uint8_t, 32>& /* psk */,
127 const hidl_string& /* passphrase */,
128 const hidl_array<uint8_t, 6>& /* goDeviceAddress */,
129 bool /* isPersistent */) override {
130 return Void();
131 }
onGroupRemoved(const hidl_string &,bool)132 Return<void> onGroupRemoved(const hidl_string& /* groupIfname */,
133 bool /* isGo */) override {
134 return Void();
135 }
onInvitationReceived(const hidl_array<uint8_t,6> &,const hidl_array<uint8_t,6> &,const hidl_array<uint8_t,6> &,uint32_t,uint32_t)136 Return<void> onInvitationReceived(
137 const hidl_array<uint8_t, 6>& /* srcAddress */,
138 const hidl_array<uint8_t, 6>& /* goDeviceAddress */,
139 const hidl_array<uint8_t, 6>& /* bssid */,
140 uint32_t /* persistentNetworkId */,
141 uint32_t /* operatingFrequency */) override {
142 return Void();
143 }
onInvitationResult(const hidl_array<uint8_t,6> &,ISupplicantP2pIfaceCallback::P2pStatusCode)144 Return<void> onInvitationResult(
145 const hidl_array<uint8_t, 6>& /* bssid */,
146 ISupplicantP2pIfaceCallback::P2pStatusCode /* status */) override {
147 return Void();
148 }
onProvisionDiscoveryCompleted(const hidl_array<uint8_t,6> &,bool,ISupplicantP2pIfaceCallback::P2pProvDiscStatusCode,uint16_t,const hidl_string &)149 Return<void> onProvisionDiscoveryCompleted(
150 const hidl_array<uint8_t, 6>& /* p2pDeviceAddress */,
151 bool /* isRequest */,
152 ISupplicantP2pIfaceCallback::P2pProvDiscStatusCode /* status */,
153 uint16_t /* configMethods */,
154 const hidl_string& /* generatedPin */) override {
155 return Void();
156 }
onServiceDiscoveryResponse(const hidl_array<uint8_t,6> &,uint16_t,const hidl_vec<uint8_t> &)157 Return<void> onServiceDiscoveryResponse(
158 const hidl_array<uint8_t, 6>& /* srcAddress */,
159 uint16_t /* updateIndicator */,
160 const hidl_vec<uint8_t>& /* tlvs */) override {
161 return Void();
162 }
onStaAuthorized(const hidl_array<uint8_t,6> &,const hidl_array<uint8_t,6> &)163 Return<void> onStaAuthorized(
164 const hidl_array<uint8_t, 6>& /* srcAddress */,
165 const hidl_array<uint8_t, 6>& /* p2pDeviceAddress */) override {
166 return Void();
167 }
onStaDeauthorized(const hidl_array<uint8_t,6> &,const hidl_array<uint8_t,6> &)168 Return<void> onStaDeauthorized(
169 const hidl_array<uint8_t, 6>& /* srcAddress */,
170 const hidl_array<uint8_t, 6>& /* p2pDeviceAddress */) override {
171 return Void();
172 }
173 };
174
175 /*
176 * Create:
177 * Ensures that an instance of the ISupplicantP2pIface proxy object is
178 * successfully created.
179 */
TEST(SupplicantP2pIfaceHidlTestNoFixture,Create)180 TEST(SupplicantP2pIfaceHidlTestNoFixture, Create) {
181 startSupplicantAndWaitForHidlService();
182 EXPECT_NE(nullptr, getSupplicantP2pIface().get());
183 stopSupplicant();
184 }
185
186 /*
187 * RegisterCallback
188 */
TEST_F(SupplicantP2pIfaceHidlTest,RegisterCallback)189 TEST_F(SupplicantP2pIfaceHidlTest, RegisterCallback) {
190 p2p_iface_->registerCallback(
191 new IfaceCallback(), [](const SupplicantStatus& status) {
192 EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code);
193 });
194 }
195
196 /*
197 * GetName
198 */
TEST_F(SupplicantP2pIfaceHidlTest,GetName)199 TEST_F(SupplicantP2pIfaceHidlTest, GetName) {
200 const auto& status_and_interface_name = HIDL_INVOKE(p2p_iface_, getName);
201 EXPECT_EQ(SupplicantStatusCode::SUCCESS,
202 status_and_interface_name.first.code);
203 EXPECT_FALSE(std::string(status_and_interface_name.second).empty());
204 }
205
206 /*
207 * GetType
208 */
TEST_F(SupplicantP2pIfaceHidlTest,GetType)209 TEST_F(SupplicantP2pIfaceHidlTest, GetType) {
210 const auto& status_and_interface_type = HIDL_INVOKE(p2p_iface_, getType);
211 EXPECT_EQ(SupplicantStatusCode::SUCCESS,
212 status_and_interface_type.first.code);
213 EXPECT_EQ(status_and_interface_type.second, IfaceType::P2P);
214 }
215
216 /*
217 * GetDeviceAddress
218 */
TEST_F(SupplicantP2pIfaceHidlTest,GetDeviceAddress)219 TEST_F(SupplicantP2pIfaceHidlTest, GetDeviceAddress) {
220 p2p_iface_->getDeviceAddress(
221 [](const SupplicantStatus& status,
222 const hidl_array<uint8_t, 6>& /* mac_addr */) {
223 EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code);
224 });
225 }
226
227 /*
228 * SetSsidPostfix
229 */
TEST_F(SupplicantP2pIfaceHidlTest,SetSsidPostfix)230 TEST_F(SupplicantP2pIfaceHidlTest, SetSsidPostfix) {
231 std::vector<uint8_t> ssid(kTestSsidPostfix,
232 kTestSsidPostfix + sizeof(kTestSsidPostfix));
233 p2p_iface_->setSsidPostfix(ssid, [](const SupplicantStatus& status) {
234 EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code);
235 });
236 }
237
238 /*
239 * Find
240 */
TEST_F(SupplicantP2pIfaceHidlTest,Find)241 TEST_F(SupplicantP2pIfaceHidlTest, Find) {
242 p2p_iface_->find(kTestFindTimeout, [](const SupplicantStatus& status) {
243 EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code);
244 });
245 }
246
247 /*
248 * StopFind
249 */
TEST_F(SupplicantP2pIfaceHidlTest,StopFind)250 TEST_F(SupplicantP2pIfaceHidlTest, StopFind) {
251 p2p_iface_->find(kTestFindTimeout, [](const SupplicantStatus& status) {
252 EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code);
253 });
254
255 p2p_iface_->stopFind([](const SupplicantStatus& status) {
256 EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code);
257 });
258 }
259
260 /*
261 * Flush
262 */
TEST_F(SupplicantP2pIfaceHidlTest,Flush)263 TEST_F(SupplicantP2pIfaceHidlTest, Flush) {
264 p2p_iface_->flush([](const SupplicantStatus& status) {
265 EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code);
266 });
267 }
268
269 /*
270 * Connect
271 */
TEST_F(SupplicantP2pIfaceHidlTest,Connect)272 TEST_F(SupplicantP2pIfaceHidlTest, Connect) {
273 p2p_iface_->connect(
274 mac_addr_, ISupplicantP2pIface::WpsProvisionMethod::PBC,
275 kTestConnectPin, false, false, kTestConnectGoIntent,
276 [](const SupplicantStatus& status, const hidl_string& /* pin */) {
277 // This is not going to work with fake values.
278 EXPECT_EQ(SupplicantStatusCode::FAILURE_UNKNOWN, status.code);
279 });
280 }
281
282 /*
283 * CancelConnect
284 */
TEST_F(SupplicantP2pIfaceHidlTest,CancelConnect)285 TEST_F(SupplicantP2pIfaceHidlTest, CancelConnect) {
286 p2p_iface_->connect(
287 mac_addr_, ISupplicantP2pIface::WpsProvisionMethod::PBC,
288 kTestConnectPin, false, false, kTestConnectGoIntent,
289 [](const SupplicantStatus& status, const hidl_string& /* pin */) {
290 // This is not going to work with fake values.
291 EXPECT_EQ(SupplicantStatusCode::FAILURE_UNKNOWN, status.code);
292 });
293
294 p2p_iface_->cancelConnect([](const SupplicantStatus& status) {
295 EXPECT_EQ(SupplicantStatusCode::FAILURE_UNKNOWN, status.code);
296 });
297 }
298
299 /*
300 * ProvisionDiscovery
301 */
TEST_F(SupplicantP2pIfaceHidlTest,ProvisionDiscovery)302 TEST_F(SupplicantP2pIfaceHidlTest, ProvisionDiscovery) {
303 p2p_iface_->provisionDiscovery(
304 mac_addr_, ISupplicantP2pIface::WpsProvisionMethod::PBC,
305 [](const SupplicantStatus& status) {
306 // This is not going to work with fake values.
307 EXPECT_EQ(SupplicantStatusCode::FAILURE_UNKNOWN, status.code);
308 });
309 }
310
311 /*
312 * AddGroup
313 */
TEST_F(SupplicantP2pIfaceHidlTest,AddGroup)314 TEST_F(SupplicantP2pIfaceHidlTest, AddGroup) {
315 p2p_iface_->addGroup(false, kTestNetworkId,
316 [](const SupplicantStatus& /* status */) {
317 // TODO: Figure out the initialization sequence for
318 // this to work.
319 // EXPECT_EQ(SupplicantStatusCode::SUCCESS,
320 // status.code);
321 });
322 }
323
324 /*
325 * RemoveGroup
326 */
TEST_F(SupplicantP2pIfaceHidlTest,RemoveGroup)327 TEST_F(SupplicantP2pIfaceHidlTest, RemoveGroup) {
328 // This is not going to work with fake values.
329 EXPECT_NE(SupplicantStatusCode::SUCCESS,
330 HIDL_INVOKE(p2p_iface_, removeGroup, kTestGroupIfName).code);
331 }
332
333 /*
334 * Reject
335 */
TEST_F(SupplicantP2pIfaceHidlTest,Reject)336 TEST_F(SupplicantP2pIfaceHidlTest, Reject) {
337 p2p_iface_->reject(mac_addr_, [](const SupplicantStatus& status) {
338 // This is not going to work with fake values.
339 EXPECT_EQ(SupplicantStatusCode::FAILURE_UNKNOWN, status.code);
340 });
341 }
342
343 /*
344 * Invite
345 */
TEST_F(SupplicantP2pIfaceHidlTest,Invite)346 TEST_F(SupplicantP2pIfaceHidlTest, Invite) {
347 p2p_iface_->invite(kTestGroupIfName, mac_addr_, peer_mac_addr_,
348 [](const SupplicantStatus& status) {
349 // This is not going to work with fake values.
350 EXPECT_EQ(SupplicantStatusCode::FAILURE_UNKNOWN,
351 status.code);
352 });
353 }
354
355 /*
356 * Reinvoke
357 */
TEST_F(SupplicantP2pIfaceHidlTest,Reinvoke)358 TEST_F(SupplicantP2pIfaceHidlTest, Reinvoke) {
359 p2p_iface_->reinvoke(
360 kTestNetworkId, mac_addr_, [](const SupplicantStatus& status) {
361 // This is not going to work with fake values.
362 EXPECT_EQ(SupplicantStatusCode::FAILURE_NETWORK_UNKNOWN,
363 status.code);
364 });
365 }
366
367 /*
368 * ConfigureExtListen
369 */
TEST_F(SupplicantP2pIfaceHidlTest,ConfigureExtListen)370 TEST_F(SupplicantP2pIfaceHidlTest, ConfigureExtListen) {
371 p2p_iface_->configureExtListen(kTestExtListenPeriod, kTestExtListenInterval,
372 [](const SupplicantStatus& status) {
373 EXPECT_EQ(SupplicantStatusCode::SUCCESS,
374 status.code);
375 });
376 }
377
378 /*
379 * SetListenChannel
380 */
TEST_F(SupplicantP2pIfaceHidlTest,SetListenChannel)381 TEST_F(SupplicantP2pIfaceHidlTest, SetListenChannel) {
382 p2p_iface_->setListenChannel(
383 kTestChannel, kTestOperatingClass, [](const SupplicantStatus& status) {
384 EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code);
385 });
386 }
387
388 /*
389 * SetDisallowedFrequencies
390 */
TEST_F(SupplicantP2pIfaceHidlTest,SetDisallowedFrequencies)391 TEST_F(SupplicantP2pIfaceHidlTest, SetDisallowedFrequencies) {
392 std::vector<ISupplicantP2pIface::FreqRange> ranges = {
393 {kTestFreqRange[0], kTestFreqRange[1]}};
394 p2p_iface_->setDisallowedFrequencies(
395 ranges, [](const SupplicantStatus& status) {
396 EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code);
397 });
398 }
399
400 /*
401 * GetSsid
402 */
TEST_F(SupplicantP2pIfaceHidlTest,GetSsid)403 TEST_F(SupplicantP2pIfaceHidlTest, GetSsid) {
404 std::array<uint8_t, 6> mac_addr;
405 memcpy(mac_addr.data(), kTestMacAddr, mac_addr.size());
406 p2p_iface_->getSsid(mac_addr, [](const SupplicantStatus& status,
407 const hidl_vec<uint8_t>& /* ssid */) {
408 // This is not going to work with fake values.
409 EXPECT_EQ(SupplicantStatusCode::FAILURE_UNKNOWN, status.code);
410 });
411 }
412
413 /*
414 * GetGroupCapability
415 */
TEST_F(SupplicantP2pIfaceHidlTest,GetGroupCapability)416 TEST_F(SupplicantP2pIfaceHidlTest, GetGroupCapability) {
417 std::array<uint8_t, 6> mac_addr;
418 memcpy(mac_addr.data(), kTestMacAddr, mac_addr.size());
419 p2p_iface_->getGroupCapability(
420 mac_addr, [](const SupplicantStatus& status, uint32_t /* caps */) {
421 // This is not going to work with fake values.
422 EXPECT_EQ(SupplicantStatusCode::FAILURE_UNKNOWN, status.code);
423 });
424 }
425
426 /*
427 * FlushServices
428 */
TEST_F(SupplicantP2pIfaceHidlTest,FlushServices)429 TEST_F(SupplicantP2pIfaceHidlTest, FlushServices) {
430 p2p_iface_->flushServices([](const SupplicantStatus& status) {
431 EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code);
432 });
433 }
434
435 /*
436 * SetMiracastMode
437 */
TEST_F(SupplicantP2pIfaceHidlTest,SetMiracastMode)438 TEST_F(SupplicantP2pIfaceHidlTest, SetMiracastMode) {
439 p2p_iface_->setMiracastMode(ISupplicantP2pIface::MiracastMode::DISABLED,
440 [](const SupplicantStatus& status) {
441 EXPECT_EQ(SupplicantStatusCode::SUCCESS,
442 status.code);
443 });
444 p2p_iface_->setMiracastMode(ISupplicantP2pIface::MiracastMode::SOURCE,
445 [](const SupplicantStatus& status) {
446 EXPECT_EQ(SupplicantStatusCode::SUCCESS,
447 status.code);
448 });
449 p2p_iface_->setMiracastMode(ISupplicantP2pIface::MiracastMode::SINK,
450 [](const SupplicantStatus& status) {
451 EXPECT_EQ(SupplicantStatusCode::SUCCESS,
452 status.code);
453 });
454 }
455
456 /*
457 * SetGroupIdle
458 */
TEST_F(SupplicantP2pIfaceHidlTest,SetGroupIdle)459 TEST_F(SupplicantP2pIfaceHidlTest, SetGroupIdle) {
460 // This is not going to work with fake values.
461 EXPECT_NE(SupplicantStatusCode::SUCCESS,
462 HIDL_INVOKE(p2p_iface_, setGroupIdle, kTestGroupIfName,
463 kTestSetGroupIdleTimeout)
464 .code);
465 }
466
467 /*
468 * SetPowerSave
469 */
TEST_F(SupplicantP2pIfaceHidlTest,SetPowerSave)470 TEST_F(SupplicantP2pIfaceHidlTest, SetPowerSave) {
471 // This is not going to work with fake values.
472 EXPECT_NE(
473 SupplicantStatusCode::SUCCESS,
474 HIDL_INVOKE(p2p_iface_, setPowerSave, kTestGroupIfName, true).code);
475 // This is not going to work with fake values.
476 EXPECT_NE(
477 SupplicantStatusCode::SUCCESS,
478 HIDL_INVOKE(p2p_iface_, setPowerSave, kTestGroupIfName, false).code);
479 }
480
481 /*
482 * SetWpsDeviceName
483 */
TEST_F(SupplicantP2pIfaceHidlTest,SetWpsDeviceName)484 TEST_F(SupplicantP2pIfaceHidlTest, SetWpsDeviceName) {
485 EXPECT_EQ(
486 SupplicantStatusCode::SUCCESS,
487 HIDL_INVOKE(p2p_iface_, setWpsDeviceName, kTestWpsDeviceName).code);
488 }
489
490 /*
491 * SetWpsDeviceType
492 */
TEST_F(SupplicantP2pIfaceHidlTest,SetWpsDeviceType)493 TEST_F(SupplicantP2pIfaceHidlTest, SetWpsDeviceType) {
494 EXPECT_EQ(
495 SupplicantStatusCode::SUCCESS,
496 HIDL_INVOKE(p2p_iface_, setWpsDeviceType, kTestWpsDeviceType).code);
497 }
498
499 /*
500 * SetWpsManufacturer
501 */
TEST_F(SupplicantP2pIfaceHidlTest,SetWpsManufacturer)502 TEST_F(SupplicantP2pIfaceHidlTest, SetWpsManufacturer) {
503 EXPECT_EQ(
504 SupplicantStatusCode::SUCCESS,
505 HIDL_INVOKE(p2p_iface_, setWpsManufacturer, kTestWpsManufacturer).code);
506 }
507
508 /*
509 * SetWpsModelName
510 */
TEST_F(SupplicantP2pIfaceHidlTest,SetWpsModelName)511 TEST_F(SupplicantP2pIfaceHidlTest, SetWpsModelName) {
512 EXPECT_EQ(SupplicantStatusCode::SUCCESS,
513 HIDL_INVOKE(p2p_iface_, setWpsModelName, kTestWpsModelName).code);
514 }
515
516 /*
517 * SetWpsModelNumber
518 */
TEST_F(SupplicantP2pIfaceHidlTest,SetWpsModelNumber)519 TEST_F(SupplicantP2pIfaceHidlTest, SetWpsModelNumber) {
520 EXPECT_EQ(
521 SupplicantStatusCode::SUCCESS,
522 HIDL_INVOKE(p2p_iface_, setWpsModelNumber, kTestWpsModelNumber).code);
523 }
524
525 /*
526 * SetWpsSerialNumber
527 */
TEST_F(SupplicantP2pIfaceHidlTest,SetWpsSerialNumber)528 TEST_F(SupplicantP2pIfaceHidlTest, SetWpsSerialNumber) {
529 EXPECT_EQ(
530 SupplicantStatusCode::SUCCESS,
531 HIDL_INVOKE(p2p_iface_, setWpsSerialNumber, kTestWpsSerialNumber).code);
532 }
533
534 /*
535 * SetWpsConfigMethods
536 */
TEST_F(SupplicantP2pIfaceHidlTest,SetWpsConfigMethods)537 TEST_F(SupplicantP2pIfaceHidlTest, SetWpsConfigMethods) {
538 EXPECT_EQ(
539 SupplicantStatusCode::SUCCESS,
540 HIDL_INVOKE(p2p_iface_, setWpsConfigMethods, kTestWpsConfigMethods)
541 .code);
542 }
543
544 /*
545 * AddAndRemoveBonjourService
546 * This tests that we are able to add a bonjour service, and we can remove it
547 * by using the same query data.
548 * This also tests that removeBonjourSerive() returns error when there is no
549 * existing bonjour service with the same query data.
550 */
TEST_F(SupplicantP2pIfaceHidlTest,AddAndRemoveBonjourService)551 TEST_F(SupplicantP2pIfaceHidlTest, AddAndRemoveBonjourService) {
552 EXPECT_EQ(SupplicantStatusCode::SUCCESS,
553 HIDL_INVOKE(
554 p2p_iface_, addBonjourService,
555 std::vector<uint8_t>(kTestBonjourServiceQuery,
556 kTestBonjourServiceQuery +
557 sizeof(kTestBonjourServiceQuery)),
558 std::vector<uint8_t>(kTestBonjourServiceResponse,
559 kTestBonjourServiceResponse +
560 sizeof(kTestBonjourServiceResponse)))
561 .code);
562 EXPECT_EQ(
563 SupplicantStatusCode::SUCCESS,
564 HIDL_INVOKE(p2p_iface_, removeBonjourService,
565 std::vector<uint8_t>(kTestBonjourServiceQuery,
566 kTestBonjourServiceQuery +
567 sizeof(kTestBonjourServiceQuery)))
568 .code);
569 // This will fail because boujour service with kTestBonjourServiceQuery was
570 // already removed.
571 EXPECT_NE(
572 SupplicantStatusCode::SUCCESS,
573 HIDL_INVOKE(p2p_iface_, removeBonjourService,
574 std::vector<uint8_t>(kTestBonjourServiceQuery,
575 kTestBonjourServiceQuery +
576 sizeof(kTestBonjourServiceQuery)))
577 .code);
578 }
579
580 /*
581 * AddAndRemoveUpnpService
582 * This tests that we are able to add a upnp service, and we can remove it
583 * by using the same service name.
584 * This also tests that removeUpnpService() returns error when there is no
585 * exsiting upnp service with the same service name.
586 */
TEST_F(SupplicantP2pIfaceHidlTest,AddAndRemoveUpnpService)587 TEST_F(SupplicantP2pIfaceHidlTest, AddAndRemoveUpnpService) {
588 EXPECT_EQ(SupplicantStatusCode::SUCCESS,
589 HIDL_INVOKE(p2p_iface_, addUpnpService, 0 /* version */,
590 kTestUpnpServiceName)
591 .code);
592 EXPECT_EQ(SupplicantStatusCode::SUCCESS,
593 HIDL_INVOKE(p2p_iface_, removeUpnpService, 0 /* version */,
594 kTestUpnpServiceName)
595 .code);
596 // This will fail because Upnp service with kTestUpnpServiceName was
597 // already removed.
598 EXPECT_NE(SupplicantStatusCode::SUCCESS,
599 HIDL_INVOKE(p2p_iface_, removeUpnpService, 0 /* version */,
600 kTestUpnpServiceName)
601 .code);
602 }
603
604 /*
605 * EnableWfd
606 */
TEST_F(SupplicantP2pIfaceHidlTest,EnableWfd)607 TEST_F(SupplicantP2pIfaceHidlTest, EnableWfd) {
608 EXPECT_EQ(SupplicantStatusCode::SUCCESS,
609 HIDL_INVOKE(p2p_iface_, enableWfd, true).code);
610 EXPECT_EQ(SupplicantStatusCode::SUCCESS,
611 HIDL_INVOKE(p2p_iface_, enableWfd, false).code);
612 }
613
614 /*
615 * SetWfdDeviceInfo
616 */
TEST_F(SupplicantP2pIfaceHidlTest,SetWfdDeviceInfo)617 TEST_F(SupplicantP2pIfaceHidlTest, SetWfdDeviceInfo) {
618 EXPECT_EQ(
619 SupplicantStatusCode::SUCCESS,
620 HIDL_INVOKE(p2p_iface_, setWfdDeviceInfo, kTestWfdDeviceInfo).code);
621 }
622