1 /*
2  * Copyright (C) 2021-2022 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include <gtest/gtest.h>
17 #include <mutex>
18 #include <thread>
19 
20 #include "bluetooth_a2dp_src.h"
21 #include "bluetooth_def.h"
22 #include "bluetooth_device_class.h"
23 #include "bluetooth_host.h"
24 #include "bluetooth_errorcode.h"
25 
26 using namespace testing::ext;
27 
28 namespace OHOS {
29 namespace Bluetooth {
30 class BluetoothHostObserverCommon : public BluetoothHostObserver {
31 public:
32     BluetoothHostObserverCommon() = default;
33     virtual ~BluetoothHostObserverCommon() = default;
34     static BluetoothHostObserverCommon &GetInstance();
35     void OnStateChanged(const int transport, const int status) override;
36     void OnDiscoveryStateChanged(int status) override;
OnDiscoveryResult(const BluetoothRemoteDevice & device,int rssi,const std::string deviceName,int deviceClass)37     void OnDiscoveryResult(
38         const BluetoothRemoteDevice &device, int rssi, const std::string deviceName, int deviceClass) override{};
OnPairRequested(const BluetoothRemoteDevice & device)39     void OnPairRequested(const BluetoothRemoteDevice &device) override{};
OnPairConfirmed(const BluetoothRemoteDevice & device,int reqType,int number)40     void OnPairConfirmed(const BluetoothRemoteDevice &device, int reqType, int number) override{};
OnDeviceNameChanged(const std::string & deviceName)41     void OnDeviceNameChanged(const std::string &deviceName) override{};
OnScanModeChanged(int mode)42     void OnScanModeChanged(int mode) override{};
OnDeviceAddrChanged(const std::string & address)43     void OnDeviceAddrChanged(const std::string &address) override{};
44 };
45 
GetInstance()46 BluetoothHostObserverCommon &BluetoothHostObserverCommon::GetInstance()
47 {
48     static BluetoothHostObserverCommon instance;
49     return instance;
50 }
51 
OnStateChanged(const int transport,const int status)52 void BluetoothHostObserverCommon::OnStateChanged(const int transport, const int status)
53 {
54     if (transport == BT_TRANSPORT_BLE) {
55         switch (status) {
56             case STATE_TURNING_ON:
57                 GTEST_LOG_(INFO) << "BLE:Turning on ...";
58                 break;
59             case STATE_TURN_ON:
60                 GTEST_LOG_(INFO) << "BLE:Turn on";
61                 break;
62             case STATE_TURNING_OFF:
63                 GTEST_LOG_(INFO) << "BLE:Turning off ...";
64                 break;
65             case STATE_TURN_OFF:
66                 GTEST_LOG_(INFO) << "BLE:Turn off";
67                 break;
68             default:
69                 break;
70         }
71         return;
72     } else {
73         switch (status) {
74             case STATE_TURNING_ON:
75                 GTEST_LOG_(INFO) << "BREDR:Turning on ...";
76                 break;
77             case STATE_TURN_ON:
78                 GTEST_LOG_(INFO) << "BREDR:Turn on";
79                 break;
80             case STATE_TURNING_OFF:
81                 GTEST_LOG_(INFO) << "BREDR:Turning off ...";
82                 break;
83             case STATE_TURN_OFF:
84                 GTEST_LOG_(INFO) << "BREDR:Turn off";
85                 break;
86             default:
87                 break;
88         }
89         return;
90     }
91 }
92 
OnDiscoveryStateChanged(int status)93 void BluetoothHostObserverCommon::OnDiscoveryStateChanged(int status)
94 {
95     switch (status) {
96         case 0x01:
97             GTEST_LOG_(INFO) << "discovery_start";
98             break;
99         case 0x02:
100             GTEST_LOG_(INFO) << "discoverying";
101             break;
102         case 0x03:
103             GTEST_LOG_(INFO) << "discovery_done";
104             break;
105         default:
106             break;
107     }
108 }
109 
110 class HostTest : public testing::Test {
111 public:
HostTest()112     HostTest()
113     {}
~HostTest()114     ~HostTest()
115     {}
116 
117     BluetoothHost *host_;
118     BluetoothHostObserverCommon &btObserver_ = BluetoothHostObserverCommon::GetInstance();
119     static void SetUpTestCase(void);
120     static void TearDownTestCase(void);
121     void SetUp();
122     void TearDown();
123 };
124 
SetUpTestCase(void)125 void HostTest::SetUpTestCase(void)
126 {}
127 
TearDownTestCase(void)128 void HostTest::TearDownTestCase(void)
129 {}
130 
SetUp()131 void HostTest::SetUp()
132 {}
133 
TearDown()134 void HostTest::TearDown()
135 {}
136 
137 /**
138  * @tc.number: Host_ModuleTest_GetRemoteDevice_00100
139  * @tc.name:
140  * @tc.desc:
141  */
142 HWTEST_F(HostTest, Host_ModuleTest_GetRemoteDevice_00100, TestSize.Level1)
143 {
144     GTEST_LOG_(INFO) << "Host_ModuleTest_GetRemoteDevice_00100 start";
145 
146     host_ = &BluetoothHost::GetDefaultHost();
147 
148     BluetoothRemoteDevice device_("00:00:00:00:00:00", BT_TRANSPORT_BREDR);
149     BluetoothRemoteDevice remoteDevice = host_->GetRemoteDevice(device_.GetDeviceAddr(), BT_TRANSPORT_BREDR);
150     EXPECT_EQ(device_.GetDeviceAddr(), remoteDevice.GetDeviceAddr());
151     std::this_thread::sleep_for(std::chrono::seconds(3));
152 
153     GTEST_LOG_(INFO) << "Host_ModuleTest_GetRemoteDevice_00100 end";
154 }
155 
156 /**
157  * @tc.number: Host_ModuleTest_BluetoothFactoryReset_00100
158  * @tc.name:
159  * @tc.desc:
160  */
161 HWTEST_F(HostTest, Host_ModuleTest_BluetoothFactoryReset_00100, TestSize.Level1)
162 {
163     GTEST_LOG_(INFO) << "Host_ModuleTest_BluetoothFactoryReset_00100 start";
164 
165     host_ = &BluetoothHost::GetDefaultHost();
166 
167     GTEST_LOG_(INFO) << "Host_ModuleTest_BluetoothFactoryReset_00100 end";
168 }
169 
170 /**
171  * @tc.number: Host_ModuleTest_GetProfileList_00100
172  * @tc.name:
173  * @tc.desc:
174  */
175 HWTEST_F(HostTest, Host_ModuleTest_GetProfileList_00100, TestSize.Level1)
176 {
177     GTEST_LOG_(INFO) << "Host_ModuleTest_GetProfileList_00100 start";
178 
179     host_ = &BluetoothHost::GetDefaultHost();
180     uint32_t profileSize = 5;
181     EXPECT_NE(host_->GetProfileList().size(), profileSize);
182 
183     GTEST_LOG_(INFO) << "Host_ModuleTest_GetProfileList_00100 end";
184 }
185 
186 /**
187  * @tc.number: Host_ModuleTest_GetMaxNumConnectedAudioDevices_00100
188  * @tc.name:
189  * @tc.desc:
190  */
191 HWTEST_F(HostTest, Host_ModuleTest_GetMaxNumConnectedAudioDevices_00100, TestSize.Level1)
192 {
193     GTEST_LOG_(INFO) << "Host_ModuleTest_GetMaxNumConnectedAudioDevices_00100 start";
194 
195     host_ = &BluetoothHost::GetDefaultHost();
196     EXPECT_EQ(host_->GetMaxNumConnectedAudioDevices(), 6);
197 
198     GTEST_LOG_(INFO) << "Host_ModuleTest_GetMaxNumConnectedAudioDevices_00100 end";
199 }
200 
201 /**
202  * @tc.number: Host_ModuleTest_GetBtProfileConnState_00100
203  * @tc.name:
204  * @tc.desc:
205  */
206 HWTEST_F(HostTest, Host_ModuleTest_GetBtProfileConnState_00100, TestSize.Level1)
207 {
208     GTEST_LOG_(INFO) << "Host_ModuleTest_GetBtProfileConnState_00100 start";
209 
210     host_ = &BluetoothHost::GetDefaultHost();
211     int state = static_cast<int>(BTConnectState::DISCONNECTED);
212     host_->GetBtProfileConnState(PROFILE_ID_GATT_CLIENT, state);
213     EXPECT_EQ(state, (int)BTConnectState::DISCONNECTED);
214 
215     GTEST_LOG_(INFO) << "Host_ModuleTest_GetBtProfileConnState_00100 end";
216 }
217 
218 /**
219  * @tc.number: Host_ModuleTest_GetBtConnectionState_00100
220  * @tc.name:
221  * @tc.desc:
222  */
223 HWTEST_F(HostTest, Host_ModuleTest_GetBtConnectionState_00100, TestSize.Level1)
224 {
225     GTEST_LOG_(INFO) << "Host_ModuleTest_GetBtConnectionState_00100 start";
226 
227     host_ = &BluetoothHost::GetDefaultHost();
228     EXPECT_EQ(host_->GetBtConnectionState(), (int)BTConnectState::DISCONNECTED);
229 
230     GTEST_LOG_(INFO) << "Host_ModuleTest_GetBtConnectionState_00100 end";
231 }
232 
233 /**
234  * @tc.number: Host_ModuleTest_Start_00100
235  * @tc.name:
236  * @tc.desc:
237  */
238 HWTEST_F(HostTest, Host_ModuleTest_Start_00100, TestSize.Level1)
239 {
240     GTEST_LOG_(INFO) << "Host_ModuleTest_Start_00100 start";
241 
242     host_ = &BluetoothHost::GetDefaultHost();
243     host_->Start();
244 
245     GTEST_LOG_(INFO) << "Host_ModuleTest_Start_00100 end";
246 }
247 
248 /**
249  * @tc.number: Host_ModuleTest_Stop_00100
250  * @tc.name:
251  * @tc.desc:
252  */
253 HWTEST_F(HostTest, Host_ModuleTest_Stop_00100, TestSize.Level1)
254 {
255     GTEST_LOG_(INFO) << "Host_ModuleTest_Stop_00100 start";
256 
257     host_ = &BluetoothHost::GetDefaultHost();
258     host_->Stop();
259 
260     GTEST_LOG_(INFO) << "Host_ModuleTest_Stop_00100 end";
261 }
262 
263 /**
264  * @tc.number: Host_ModuleTest_GetLocalAddress_00100
265  * @tc.name:
266  * @tc.desc:
267  */
268 HWTEST_F(HostTest, Host_ModuleTest_GetLocalAddress_00100, TestSize.Level1)
269 {
270     GTEST_LOG_(INFO) << "Host_ModuleTest_GetLocalAddress_00100 start";
271 
272     host_ = &BluetoothHost::GetDefaultHost();
273     std::string addr = "";
274     host_->GetLocalAddress(addr);
275 
276     GTEST_LOG_(INFO) << "Host_ModuleTest_GetLocalAddress_00100 end";
277 }
278 
279 /**
280  * @tc.number: Host_ModuleTest_SetBtScanMode_00200
281  * @tc.name:
282  * @tc.desc:
283  */
284 HWTEST_F(HostTest, Host_ModuleTest_SetBtScanMode_00200, TestSize.Level1)
285 {
286     GTEST_LOG_(INFO) << "Host_ModuleTest_SetBtScanMode_00200 start";
287 
288     const int scanModeInvalid = -1;
289     host_ = &BluetoothHost::GetDefaultHost();
290     bool ret = false;
291     int result = host_->SetBtScanMode(scanModeInvalid, 0);
292     if (result == NO_ERROR) {
293         ret = true;
294     }
295     EXPECT_FALSE(ret);
296 
297     GTEST_LOG_(INFO) << "Host_ModuleTest_SetBtScanMode_00200 end";
298 }
299 
300 /**
301  * @tc.number: Host_ModuleTest_GetBtScanMode_00100
302  * @tc.name:
303  * @tc.desc:
304  */
305 HWTEST_F(HostTest, Host_ModuleTest_GetBondableMode_00100, TestSize.Level1)
306 {
307     GTEST_LOG_(INFO) << "Host_ModuleTest_GetBondableMode_00100 start";
308 
309     host_ = &BluetoothHost::GetDefaultHost();
310 
311     GTEST_LOG_(INFO) << "Host_ModuleTest_GetBondableMode_00100 end";
312 }
313 
314 /**
315  * @tc.number: Host_ModuleTest_GetBtDiscoveryEndMillis_00100
316  * @tc.name:
317  * @tc.desc:
318  */
319 HWTEST_F(HostTest, Host_ModuleTest_GetBtDiscoveryEndMillis_00100, TestSize.Level1)
320 {
321     GTEST_LOG_(INFO) << "Host_ModuleTest_GetBtDiscoveryEndMillis_00100 start";
322 
323     host_ = &BluetoothHost::GetDefaultHost();
324     host_->GetBtDiscoveryEndMillis();
325 
326     GTEST_LOG_(INFO) << "Host_ModuleTest_GetBtDiscoveryEndMillis_00100 end";
327 }
328 
329 /**
330  * @tc.number: Host_ModuleTest_GetPairedDevices_00100
331  * @tc.name:
332  * @tc.desc:
333  */
334 HWTEST_F(HostTest, Host_ModuleTest_GetPairedDevices_00100, TestSize.Level1)
335 {
336     GTEST_LOG_(INFO) << "Host_ModuleTest_GetPairedDevices_00100 start";
337 
338     host_ = &BluetoothHost::GetDefaultHost();
339     std::vector<BluetoothRemoteDevice> remotedeviceList;
340     host_->GetPairedDevices(BT_TRANSPORT_BREDR, remotedeviceList);
341     EXPECT_EQ((int)remotedeviceList.size(), 0);
342 
343     GTEST_LOG_(INFO) << "Host_ModuleTest_GetPairedDevices_00100 end";
344 }
345 
346 /**
347  * @tc.number: Host_ModuleTest_RemovePair_00100
348  * @tc.name:
349  * @tc.desc:
350  */
351 HWTEST_F(HostTest, Host_ModuleTest_RemovePair_00100, TestSize.Level1)
352 {
353     GTEST_LOG_(INFO) << "Host_ModuleTest_RemovePair_00100 start";
354 
355     host_ = &BluetoothHost::GetDefaultHost();
356     BluetoothRemoteDevice device_("00:00:00:00:00:00", BT_TRANSPORT_BREDR);
357 
358     EXPECT_NE(host_->RemovePair(device_), NO_ERROR);
359 
360     GTEST_LOG_(INFO) << "Host_ModuleTest_RemovePair_00100 end";
361 }
362 
363 /**
364  * @tc.number: Host_ModuleTest_IsValidBluetoothAddr_00100
365  * @tc.name:
366  * @tc.desc:
367  */
368 HWTEST_F(HostTest, Host_ModuleTest_IsValidBluetoothAddr_00100, TestSize.Level1)
369 {
370     GTEST_LOG_(INFO) << "Host_ModuleTest_IsValidBluetoothAddr_00100 start";
371 
372     host_ = &BluetoothHost::GetDefaultHost();
373     EXPECT_TRUE(host_->IsValidBluetoothAddr("00:00:00:00:00:00"));
374 
375     GTEST_LOG_(INFO) << "Host_ModuleTest_IsValidBluetoothAddr_00100 end";
376 }
377 
378 /**
379  * @tc.number: Host_ModuleTest_IsValidBluetoothAddr_00200
380  * @tc.name:
381  * @tc.desc:
382  */
383 HWTEST_F(HostTest, Host_ModuleTest_IsValidBluetoothAddr_00200, TestSize.Level1)
384 {
385     GTEST_LOG_(INFO) << "Host_ModuleTest_IsValidBluetoothAddr_00200 start";
386 
387     host_ = &BluetoothHost::GetDefaultHost();
388     EXPECT_FALSE(host_->IsValidBluetoothAddr("00"));
389 
390     GTEST_LOG_(INFO) << "Host_ModuleTest_IsValidBluetoothAddr_00200 end";
391 }
392 
393 /**
394  * @tc.number: Host_ModuleTest_GetPhonebookPermission_00100
395  * @tc.name:
396  * @tc.desc:
397  */
398 HWTEST_F(HostTest, Host_ModuleTest_GetPhonebookPermission_00100, TestSize.Level1)
399 {
400     GTEST_LOG_(INFO) << "Host_ModuleTest_GetPhonebookPermission_00100 start";
401 
402     BluetoothRemoteDevice device_("00:00:00:00:00:00", BT_TRANSPORT_BREDR);
403     EXPECT_FALSE(device_.SetPhonebookPermission(static_cast<int>(BTPermissionType::ACCESS_ALLOWED)));
404     EXPECT_EQ(device_.GetPhonebookPermission(), static_cast<int>(BTPermissionType::ACCESS_UNKNOWN));
405 
406     GTEST_LOG_(INFO) << "Host_ModuleTest_GetPhonebookPermission_00100 end";
407 }
408 
409 /**
410  * @tc.number: Host_ModuleTest_SetPhonebookPermission_00100
411  * @tc.name:
412  * @tc.desc:
413  */
414 HWTEST_F(HostTest, Host_ModuleTest_SetPhonebookPermission_00100, TestSize.Level1)
415 {
416     GTEST_LOG_(INFO) << "Host_ModuleTest_SetPhonebookPermission_00100 start";
417 
418     BluetoothRemoteDevice device_("00:00:00:00:00:00", BT_TRANSPORT_BREDR);
419     EXPECT_FALSE(device_.SetPhonebookPermission(static_cast<int>(BTPermissionType::ACCESS_FORBIDDEN)));
420     EXPECT_EQ(device_.GetPhonebookPermission(), static_cast<int>(BTPermissionType::ACCESS_UNKNOWN));
421 
422     GTEST_LOG_(INFO) << "Host_ModuleTest_SetPhonebookPermission_00100 end";
423 }
424 
425 /**
426  * @tc.number: Host_ModuleTest_GetMessagePermission_00100
427  * @tc.name:
428  * @tc.desc:
429  */
430 HWTEST_F(HostTest, Host_ModuleTest_GetMessagePermission_00100, TestSize.Level1)
431 {
432     GTEST_LOG_(INFO) << "Host_ModuleTest_GetPhonebookPermission_00100 start";
433 
434     BluetoothRemoteDevice device_("00:00:00:00:00:00", BT_TRANSPORT_BREDR);
435     EXPECT_FALSE(device_.SetMessagePermission(static_cast<int>(BTPermissionType::ACCESS_ALLOWED)));
436     EXPECT_EQ(device_.GetMessagePermission(), static_cast<int>(BTPermissionType::ACCESS_UNKNOWN));
437 
438     GTEST_LOG_(INFO) << "Host_ModuleTest_GetMessagePermission_00100 end";
439 }
440 
441 /**
442  * @tc.number: Host_ModuleTest_SetMessagePermission_00100
443  * @tc.name:
444  * @tc.desc:
445  */
446 HWTEST_F(HostTest, Host_ModuleTest_SetMessagePermission_00100, TestSize.Level1)
447 {
448     GTEST_LOG_(INFO) << "Host_ModuleTest_SetMessagePermission_00100 start";
449 
450     BluetoothRemoteDevice device_("00:00:00:00:00:00", BT_TRANSPORT_BREDR);
451     EXPECT_FALSE(device_.SetMessagePermission(static_cast<int>(BTPermissionType::ACCESS_FORBIDDEN)));
452     EXPECT_EQ(device_.GetMessagePermission(), static_cast<int>(BTPermissionType::ACCESS_UNKNOWN));
453 
454     GTEST_LOG_(INFO) << "Host_ModuleTest_SetMessagePermission_00100 end";
455 }
456 
457 /**
458  * @tc.number: Host_ModuleTest_SetMessagePermission_00100
459  * @tc.name:
460  * @tc.desc:
461  */
462 HWTEST_F(HostTest, Host_ModuleTest_GetPowerMode_00100, TestSize.Level1)
463 {
464     GTEST_LOG_(INFO) << "Host_ModuleTest_GetPowerMode_00100 start";
465 
466     BluetoothRemoteDevice device_("00:00:00:00:00:00", BT_TRANSPORT_BREDR);
467     EXPECT_GE(device_.GetPowerMode(), 0);
468 
469     GTEST_LOG_(INFO) << "Host_ModuleTest_GetPowerMode_00100 end";
470 }
471 
472 /**
473  * @tc.number: Host_ModuleTest_GetDeviceAddr_00100
474  * @tc.name:
475  * @tc.desc:
476  */
477 HWTEST_F(HostTest, Host_ModuleTest_GetDeviceAddr_00100, TestSize.Level1)
478 {
479     GTEST_LOG_(INFO) << "Host_ModuleTest_GetDeviceAddr_00100 start";
480 
481     BluetoothRemoteDevice device_("00:00:00:00:00:00", BT_TRANSPORT_BREDR);
482     EXPECT_EQ(device_.GetDeviceAddr(), "00:00:00:00:00:00");
483 
484     GTEST_LOG_(INFO) << "Host_ModuleTest_GetDeviceAddr_00100 end";
485 }
486 
487 /**
488  * @tc.number: Host_ModuleTest_GetDeviceName_00100
489  * @tc.name:
490  * @tc.desc:
491  */
492 HWTEST_F(HostTest, Host_ModuleTest_GetDeviceName_00100, TestSize.Level1)
493 {
494     GTEST_LOG_(INFO) << "Host_ModuleTest_GetDeviceName_00100 start";
495 
496     BluetoothRemoteDevice device_("00:00:00:00:00:00", BT_TRANSPORT_BREDR);
497     EXPECT_TRUE(device_.GetDeviceName().empty());
498 
499     GTEST_LOG_(INFO) << "Host_ModuleTest_GetDeviceName_00100 end";
500 }
501 
502 /**
503  * @tc.number: Host_ModuleTest_GetDeviceAlias_00100
504  * @tc.name:
505  * @tc.desc:
506  */
507 HWTEST_F(HostTest, Host_ModuleTest_GetDeviceAlias_00100, TestSize.Level1)
508 {
509     GTEST_LOG_(INFO) << "Host_ModuleTest_GetDeviceAlias_00100 start";
510 
511     BluetoothRemoteDevice device_("00:00:00:00:00:00", BT_TRANSPORT_BREDR);
512     EXPECT_EQ(device_.GetDeviceAlias(), INVALID_NAME);
513 
514     GTEST_LOG_(INFO) << "Host_ModuleTest_GetDeviceAlias_00100 end";
515 }
516 
517 /**
518  * @tc.number: Host_ModuleTest_SetDeviceAlias_00100
519  * @tc.name:
520  * @tc.desc:
521  */
522 HWTEST_F(HostTest, Host_ModuleTest_SetDeviceAlias_00100, TestSize.Level1)
523 {
524     GTEST_LOG_(INFO) << "Host_ModuleTest_SetDeviceAlias_00100 start";
525 
526     host_ = &BluetoothHost::GetDefaultHost();
527     BluetoothRemoteDevice device_("00:00:00:00:00:00", BT_TRANSPORT_BREDR);
528     device_.SetDeviceAlias("deviceName");
529 
530     GTEST_LOG_(INFO) << "Host_ModuleTest_SetDeviceAlias_00100 end";
531 }
532 
533 /**
534  * @tc.number: Host_ModuleTest_GetDeviceType_00100
535  * @tc.name:
536  * @tc.desc:
537  */
538 HWTEST_F(HostTest, Host_ModuleTest_GetDeviceType_00100, TestSize.Level1)
539 {
540     GTEST_LOG_(INFO) << "Host_ModuleTest_GetDeviceType_00100 start";
541 
542     host_ = &BluetoothHost::GetDefaultHost();
543     BluetoothRemoteDevice device_("00:00:00:00:00:00", BT_TRANSPORT_BREDR);
544     EXPECT_EQ(device_.GetDeviceType(), INVALID_VALUE);
545 
546     GTEST_LOG_(INFO) << "Host_ModuleTest_GetDeviceType_00100 end";
547 }
548 
549 /**
550  * @tc.number: Host_ModuleTest_GetRemoteDeviceBatteryInfo_00100
551  * @tc.name:
552  * @tc.desc:
553  */
554 HWTEST_F(HostTest, Host_ModuleTest_GetRemoteDeviceBatteryInfo_00100, TestSize.Level1)
555 {
556     GTEST_LOG_(INFO) << "Host_ModuleTest_GetRemoteDeviceBatteryInfo_00100 start";
557 
558     DeviceBatteryInfo batteryInfo;
559     BluetoothRemoteDevice device_("00:00:00:00:00:00", INVALID_TYPE);
560     device_.GetRemoteDeviceBatteryInfo(batteryInfo);
561 
562     GTEST_LOG_(INFO) << "Host_ModuleTest_GetRemoteDeviceBatteryInfo_00100 end";
563 }
564 
565 /**
566  * @tc.number: Host_ModuleTest_GetPairState_00100
567  * @tc.name:
568  * @tc.desc:
569  */
570 HWTEST_F(HostTest, Host_ModuleTest_GetPairState_00100, TestSize.Level1)
571 {
572     GTEST_LOG_(INFO) << "Host_ModuleTest_GetPairState_00100 start";
573 
574     BluetoothRemoteDevice device_("00:00:00:00:00:00", BT_TRANSPORT_BREDR);
575     int pairState;
576     device_.GetPairState(pairState);
577 
578     GTEST_LOG_(INFO) << "Host_ModuleTest_GetPairState_00100 end";
579 }
580 
581 /**
582  * @tc.number: Host_ModuleTest_StartPair_00100
583  * @tc.name:
584  * @tc.desc:
585  */
586 HWTEST_F(HostTest, Host_ModuleTest_StartPair_00100, TestSize.Level1)
587 {
588     GTEST_LOG_(INFO) << "Host_ModuleTest_StartPair_00100 start";
589 
590     BluetoothRemoteDevice device_("00:00:00:00:00:00", BT_TRANSPORT_BREDR);
591 
592     GTEST_LOG_(INFO) << "Host_ModuleTest_StartPair_00100 end";
593 }
594 
595 /**
596  * @tc.number: Host_ModuleTest_CancelPairing_00100
597  * @tc.name:
598  * @tc.desc:
599  */
600 HWTEST_F(HostTest, Host_ModuleTest_CancelPairing_00100, TestSize.Level1)
601 {
602     GTEST_LOG_(INFO) << "Host_ModuleTest_CancelPairing_00100 start";
603 
604     BluetoothRemoteDevice device_("00:00:00:00:00:00", BT_TRANSPORT_BREDR);
605     std::this_thread::sleep_for(std::chrono::seconds(12));
606     EXPECT_TRUE(device_.CancelPairing());
607 
608     GTEST_LOG_(INFO) << "Host_ModuleTest_CancelPairing_00100 end";
609 }
610 
611 /**
612  * @tc.number: Host_ModuleTest_IsBondedFromLocal_00100
613  * @tc.name:
614  * @tc.desc:
615  */
616 HWTEST_F(HostTest, Host_ModuleTest_IsBondedFromLocal_00100, TestSize.Level1)
617 {
618     GTEST_LOG_(INFO) << "Host_ModuleTest_IsBondedFromLocal_00100 start";
619 
620     BluetoothRemoteDevice device_("00:00:00:00:00:00", BT_TRANSPORT_BREDR);
621     EXPECT_FALSE(device_.IsBondedFromLocal());
622 
623     GTEST_LOG_(INFO) << "Host_ModuleTest_IsBondedFromLocal_00100 end";
624 }
625 
626 /**
627  * @tc.number: Host_ModuleTest_IsAclConnected_00100
628  * @tc.name:
629  * @tc.desc:
630  */
631 HWTEST_F(HostTest, Host_ModuleTest_IsAclConnected_00100, TestSize.Level1)
632 {
633     GTEST_LOG_(INFO) << "Host_ModuleTest_IsAclConnected_00100 start";
634 
635     BluetoothRemoteDevice device_("00:00:00:00:00:00", BT_TRANSPORT_BREDR);
636     EXPECT_FALSE(device_.IsAclConnected());
637 
638     GTEST_LOG_(INFO) << "Host_ModuleTest_IsAclConnected_00100 end";
639 }
640 
641 /**
642  * @tc.number: Host_ModuleTest_IsAclEncrypted_00100
643  * @tc.name:
644  * @tc.desc:
645  */
646 HWTEST_F(HostTest, Host_ModuleTest_IsAclEncrypted_00100, TestSize.Level1)
647 {
648     GTEST_LOG_(INFO) << "Host_ModuleTest_IsAclEncrypted_00100 start";
649 
650     BluetoothRemoteDevice device_("00:00:00:00:00:00", BT_TRANSPORT_BREDR);
651     EXPECT_FALSE(device_.IsAclEncrypted());
652 
653     GTEST_LOG_(INFO) << "Host_ModuleTest_IsAclEncrypted_00100 end";
654 }
655 
656 /**
657  * @tc.number: Host_ModuleTest_GetDeviceClass_00100
658  * @tc.name:
659  * @tc.desc:
660  */
661 HWTEST_F(HostTest, Host_ModuleTest_GetDeviceClass_00100, TestSize.Level1)
662 {
663     GTEST_LOG_(INFO) << "Host_ModuleTest_GetDeviceClass_00100 start";
664 
665     BluetoothRemoteDevice device_("00:00:00:00:00:00", BT_TRANSPORT_BREDR);
666     int cod = 0;
667     (void)device_.GetDeviceClass(cod);
668     BluetoothDeviceClass getLocalcod = BluetoothDeviceClass(cod);
669     EXPECT_EQ(getLocalcod.GetMajorClass(), getLocalcod.GetMajorClass());
670 
671     GTEST_LOG_(INFO) << "Host_ModuleTest_GetDeviceClass_00100 end";
672 }
673 
674 /**
675  * @tc.number: Host_ModuleTest_GetDeviceClass_00200
676  * @tc.name:
677  * @tc.desc:
678  */
679 HWTEST_F(HostTest, Host_ModuleTest_GetDeviceClass_00200, TestSize.Level1)
680 {
681     GTEST_LOG_(INFO) << "Host_ModuleTest_GetDeviceClass_00200 start";
682 
683     BluetoothRemoteDevice device_("00:00:00:00:00:00", BT_TRANSPORT_BREDR);
684     int cod = 0;
685     (void)device_.GetDeviceClass(cod);
686     BluetoothDeviceClass getLocalcod = BluetoothDeviceClass(cod);
687     EXPECT_EQ(getLocalcod.GetClassOfDevice(), 0);
688     GTEST_LOG_(INFO) << "Host_ModuleTest_GetDeviceClass_00200 end";
689 }
690 
691 /**
692  * @tc.number: Host_ModuleTest_GetDeviceUuids_00100
693  * @tc.name:
694  * @tc.desc:
695  */
696 HWTEST_F(HostTest, Host_ModuleTest_GetDeviceUuids_00100, TestSize.Level1)
697 {
698     GTEST_LOG_(INFO) << "Host_ModuleTest_GetDeviceUuids_00100 start";
699 
700     BluetoothRemoteDevice device_("00:00:00:00:00:00", BT_TRANSPORT_BREDR);
701     std::vector<std::string> uuids {};
702     device_.GetDeviceUuids(uuids);
703     EXPECT_EQ((int)uuids.size(), 0);
704 
705     GTEST_LOG_(INFO) << "Host_ModuleTest_GetDeviceUuids_00100 end";
706 }
707 
708 /**
709  * @tc.number: Host_ModuleTest_SetDevicePin_00100
710  * @tc.name:
711  * @tc.desc:
712  */
713 HWTEST_F(HostTest, Host_ModuleTest_SetDevicePin_00100, TestSize.Level1)
714 {
715     GTEST_LOG_(INFO) << "Host_ModuleTest_SetDevicePin_00100 start";
716 
717     BluetoothRemoteDevice device_("00:00:00:00:00:00", BT_TRANSPORT_BREDR);
718     EXPECT_FALSE(device_.SetDevicePin("000000") == NO_ERROR);
719 
720     GTEST_LOG_(INFO) << "Host_ModuleTest_SetDevicePin_00100 end";
721 }
722 
723 /**
724  * @tc.number: Host_ModuleTest_SetDevicePairingConfirmation_00100
725  * @tc.name:
726  * @tc.desc:
727  */
728 HWTEST_F(HostTest, Host_ModuleTest_SetDevicePairingConfirmation_00100, TestSize.Level1)
729 {
730     GTEST_LOG_(INFO) << "Host_ModuleTest_SetDevicePairingConfirmation_00100 start";
731 
732     BluetoothRemoteDevice device_("00:00:00:00:00:00", BT_TRANSPORT_BREDR);
733     bool ret = false;
734     int result = device_.SetDevicePairingConfirmation(true);
735     if (result == NO_ERROR) {
736         ret = true;
737     }
738     EXPECT_FALSE(ret);
739     bool isSuccess = false;
740     result = device_.SetDevicePairingConfirmation(true);
741     if (result == NO_ERROR) {
742         isSuccess = true;
743     }
744     EXPECT_FALSE(isSuccess);
745 
746     GTEST_LOG_(INFO) << "Host_ModuleTest_SetDevicePairingConfirmation_00100 end";
747 }
748 
749 /**
750  * @tc.number: Host_ModuleTest_SetDevicePasskey_00100
751  * @tc.name:
752  * @tc.desc:
753  */
754 HWTEST_F(HostTest, Host_ModuleTest_SetDevicePasskey_00100, TestSize.Level1)
755 {
756     GTEST_LOG_(INFO) << "Host_ModuleTest_SetDevicePasskey_00100 start";
757 
758     BluetoothRemoteDevice device_("00:00:00:00:00:00", BT_TRANSPORT_BREDR);
759     EXPECT_FALSE(device_.SetDevicePasskey(123456, true));
760     EXPECT_FALSE(device_.SetDevicePasskey(123456, false));
761 
762     GTEST_LOG_(INFO) << "Host_ModuleTest_SetDevicePasskey_00100 end";
763 }
764 
765 /**
766  * @tc.number: Host_ModuleTest_PairRequestReply_00100
767  * @tc.name:
768  * @tc.desc:
769  */
770 HWTEST_F(HostTest, Host_ModuleTest_PairRequestReply_00100, TestSize.Level1)
771 {
772     GTEST_LOG_(INFO) << "Host_ModuleTest_PairRequestReply_00100 start";
773 
774     BluetoothRemoteDevice device_("00:00:00:00:00:00", BT_TRANSPORT_BREDR);
775     EXPECT_FALSE(device_.PairRequestReply(true));
776     EXPECT_FALSE(device_.PairRequestReply(false));
777 
778     GTEST_LOG_(INFO) << "Host_ModuleTest_PairRequestReply_00100 end";
779 }
780 
781 /**
782  * @tc.number: Host_ModuleTest_GetTransportType_00100
783  * @tc.name:
784  * @tc.desc:
785  */
786 HWTEST_F(HostTest, Host_ModuleTest_GetTransportType_00100, TestSize.Level1)
787 {
788     GTEST_LOG_(INFO) << "Host_ModuleTest_GetTransportType_00100 start";
789 
790     BluetoothRemoteDevice device1_("00:00:00:00:00:00", BT_TRANSPORT_BREDR);
791     EXPECT_EQ(device1_.GetTransportType(), BT_TRANSPORT_BREDR);
792 
793     BluetoothRemoteDevice device2_("00:00:00:00:00:01", BT_TRANSPORT_BLE);
794     EXPECT_EQ(device2_.GetTransportType(), BT_TRANSPORT_BLE);
795 
796     GTEST_LOG_(INFO) << "Host_ModuleTest_GetTransportType_00100 end";
797 }
798 
799 /**
800  * @tc.number: Host_ModuleTest_ReadRemoteRssiValue_00100
801  * @tc.name:
802  * @tc.desc:
803  */
804 HWTEST_F(HostTest, Host_ModuleTest_ReadRemoteRssiValue_00100, TestSize.Level1)
805 {
806     GTEST_LOG_(INFO) << "Host_ModuleTest_ReadRemoteRssiValue_00100 start";
807 
808     BluetoothRemoteDevice device_("00:00:00:00:00:00", BT_TRANSPORT_BREDR);
809     EXPECT_FALSE(device_.ReadRemoteRssiValue());
810 
811     GTEST_LOG_(INFO) << "Host_ModuleTest_ReadRemoteRssiValue_00100 end";
812 }
813 
814 /**
815  * @tc.number: Host_ModuleTest_IsValidBluetoothRemoteDevice_00100
816  * @tc.name:
817  * @tc.desc:
818  */
819 HWTEST_F(HostTest, Host_ModuleTest_IsValidBluetoothRemoteDevice_00100, TestSize.Level1)
820 {
821     GTEST_LOG_(INFO) << "Host_ModuleTest_IsValidBluetoothRemoteDevice_00100 start";
822 
823     BluetoothRemoteDevice device0_("00", BT_TRANSPORT_BREDR);
824     EXPECT_FALSE(device0_.IsValidBluetoothRemoteDevice());
825 
826     BluetoothRemoteDevice device1_("00:00:00:00:00:00", 3);
827     EXPECT_FALSE(device1_.IsValidBluetoothRemoteDevice());
828 
829     GTEST_LOG_(INFO) << "Host_ModuleTest_IsValidBluetoothRemoteDevice_00100 end";
830 }
831 }  // namespace Bluetooth
832 }  // namespace OHOS