1 /*
2  * Copyright (c) 2022-2023 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 "UTTest_device_manager_notify.h"
17 #include "device_manager_notify.h"
18 #include "dm_device_info.h"
19 #include "ipc_remote_broker.h"
20 #include "iremote_object.h"
21 #include "iservice_registry.h"
22 #include "system_ability_definition.h"
23 #include "ipc_client_manager.h"
24 #include "ipc_set_useroperation_req.h"
25 #include "ipc_rsp.h"
26 #include "ipc_def.h"
27 
28 #include <unistd.h>
29 
30 namespace OHOS {
31 namespace DistributedHardware {
32 namespace {
33 /*
34  * Feature: DeviceManagerNotifyTest OnPublishResult
35  * Function: DeviceManagerNotifyTest
36  * SubFunction: OnPublishResult
37  * FunctionPoints: DeviceManagerNotifyTest OnPublishResult
38  * EnvConditions: OnPublishResult success.
39  * CaseDescription: 1. set pkgName not null
40  *                     set callback not null
41  *                     set publishId not null
42  *                  2. set checkMap null
43  *                  3. call DeviceManagerNotifyTest RegisterPublishCallback with parameter
44  *                  4. Get checkMap from DeviceManagerNotify
45  *                  5. check checkMap not null
46  *                  6. call DeviceManagerNotify OnPublishResult
47  *                  7. check if callback OnPublishResult called.
48  */
49 HWTEST_F(DeviceManagerNotifyTest, OnPublishSuccess1, testing::ext::TestSize.Level0)
50 {
51     // 1. set pkgName not null
52     std::string pkgName = "com.ohos.test";
53     // set callback not null
54     int count = 0;
55     std::shared_ptr<PublishCallback> callback = std::make_shared<PublishCallbackTest>(count);
56     // set publishId not null
57     int32_t publishId = 0;
58     // 2. set checkMap null
59     std::shared_ptr<PublishCallback> checkMap = nullptr;
60     // 3. call DeviceManagerNotifyTest RegisterPublishCallback with parameter
61     DeviceManagerNotify::GetInstance().RegisterPublishCallback(pkgName, publishId, callback);
62     // 4. Get checkMap from DeviceManagerNotify
63     checkMap = DeviceManagerNotify::GetInstance().devicePublishCallbacks_[pkgName][publishId];
64     // 5. check checkMap not null
65     ASSERT_NE(checkMap, nullptr);
66     // 6. call DeviceManagerNotify OnPublishResult
67     DeviceManagerNotify::GetInstance().OnPublishResult(pkgName, publishId, 0);
68     // 7. check if callback OnPublishResult called
69     ASSERT_EQ(count, 1);
70 }
71 
72 /*
73  * Feature: DeviceManagerNotifyTest OnPublishResult
74  * Function: DeviceManagerNotifyTest
75  * SubFunction: OnPublishResult
76  * FunctionPoints: DeviceManagerNotifyTest OnPublishResult
77  * EnvConditions: N/A.
78  * CaseDescription: 1. set pkgName not null
79  *                     set callback not null
80  *                     set publishId not null
81  *                  2. set checkMap null
82  *                  3. call DeviceManagerNotifyTest RegisterPublishCallback with parameter
83  *                  4. Get checkMap from DeviceManagerNotify
84  *                  5. check checkMap not null
85  *                  6. call DeviceManagerNotify OnPublishResult With testPkgName
86  *                  7. check if callback OnPublishResult called.
87  */
88 HWTEST_F(DeviceManagerNotifyTest, OnPublishSuccess2, testing::ext::TestSize.Level0)
89 {
90     // 1. set pkgName not null
91     std::string pkgName = "com.ohos.test";
92     // set callback not null
93     int count = 0;
94     std::shared_ptr<PublishCallback> callback = std::make_shared<PublishCallbackTest>(count);
95     // set publishId not null
96     int32_t publishId = 0;
97     // 2. set checkMap null
98     std::shared_ptr<PublishCallback> checkMap = nullptr;
99     // 3. call DeviceManagerNotifyTest RegisterPublishCallback with parameter
100     DeviceManagerNotify::GetInstance().RegisterPublishCallback(pkgName, publishId, callback);
101     // 4. Get checkMap from DeviceManagerNotify
102     checkMap = DeviceManagerNotify::GetInstance().devicePublishCallbacks_[pkgName][publishId];
103     // 5. check checkMap not null
104     ASSERT_NE(checkMap, nullptr);
105     std::string testPkgName = "com.ohos.test1";
106     // 6. call DeviceManagerNotify OnPublishResult
107     DeviceManagerNotify::GetInstance().OnPublishResult(testPkgName, publishId, 0);
108     // 7. check if callback OnPublishResult called
109     ASSERT_EQ(count, 0);
110 }
111 
112 /*
113  * Feature: DeviceManagerNotifyTest OnPublishResult
114  * Function: DeviceManagerNotifyTest
115  * SubFunction: OnPublishResult
116  * FunctionPoints: DeviceManagerNotifyTest OnPublishResult
117  * EnvConditions: N/A.
118  * CaseDescription: 1. set pkgName not null
119  *                     set callback not null
120  *                     set publishId not null
121  *                  2. set checkMap null
122  *                  3. call DeviceManagerNotifyTest RegisterPublishCallback with parameter
123  *                  4. Get checkMap from DeviceManagerNotify
124  *                  5. check checkMap not null
125  *                  6. call DeviceManagerNotify OnPublishResult With testpublishId
126  *                  7. check if callback OnPublishResult called.
127  */
128 HWTEST_F(DeviceManagerNotifyTest, OnPublishSuccess3, testing::ext::TestSize.Level0)
129 {
130     // 1. set pkgName not null
131     std::string pkgName = "com.ohos.test";
132     // set callback not null
133     int count = 0;
134     std::shared_ptr<PublishCallback> callback = std::make_shared<PublishCallbackTest>(count);
135     // set publishId not null
136     int32_t publishId = 0;
137     // 2. set checkMap null
138     std::shared_ptr<PublishCallback> checkMap = nullptr;
139     // 3. call DeviceManagerNotifyTest RegisterPublishCallback with parameter
140     DeviceManagerNotify::GetInstance().RegisterPublishCallback(pkgName, publishId, callback);
141     // 4. Get checkMap from DeviceManagerNotify
142     checkMap = DeviceManagerNotify::GetInstance().devicePublishCallbacks_[pkgName][publishId];
143     // 5. check checkMap not null
144     ASSERT_NE(checkMap, nullptr);
145     int32_t testpublishId = 1;
146     // 6. call DeviceManagerNotify OnPublishResult
147     DeviceManagerNotify::GetInstance().OnPublishResult(pkgName, testpublishId, 0);
148     // 7. check if callback OnPublishResult called
149     ASSERT_EQ(count, 0);
150 }
151 
152 /*
153  * Feature: DeviceManagerNotifyTest OnPublishResult
154  * Function: DeviceManagerNotifyTest
155  * SubFunction: OnPublishResult Success
156  * FunctionPoints: DeviceManagerNotifyTest OnPublishResult
157  * EnvConditions: N/A.
158  * CaseDescription: 1. set pkgName not null
159  *                     set callback not null
160  *                     set publishId not null
161  *                  2. set checkMap null
162  *                  3. call DeviceManagerNotifyTest RegisterPublishCallback with parameter
163  *                  4. Get checkMap from DeviceManagerNotify
164  *                  5. check checkMap not null
165  *                  6. call DeviceManagerNotify OnPublishResult With testPkgName
166  *                  7. check if callback OnPublishResult called.
167  */
168 HWTEST_F(DeviceManagerNotifyTest, OnPublishSuccess4, testing::ext::TestSize.Level0)
169 {
170     // 1. set pkgName not null
171     std::string pkgName = "com.ohos.test";
172     // set callback not null
173     int count = 0;
174     std::shared_ptr<PublishCallback> callback = std::make_shared<PublishCallbackTest>(count);
175     // set publishId not null
176     int32_t publishId = 0;
177     // 2. set checkMap null
178     std::shared_ptr<PublishCallback> checkMap = nullptr;
179     // 3. call DeviceManagerNotifyTest RegisterPublishCallback with parameter
180     DeviceManagerNotify::GetInstance().RegisterPublishCallback(pkgName, publishId, callback);
181     // 4. Get checkMap from DeviceManagerNotify
182     checkMap = DeviceManagerNotify::GetInstance().devicePublishCallbacks_[pkgName][publishId];
183     // 5. check checkMap not null
184     ASSERT_NE(checkMap, nullptr);
185     std::string testPkgName = "";
186     // 6. call DeviceManagerNotify OnPublishResult
187     DeviceManagerNotify::GetInstance().OnPublishResult(testPkgName, publishId, 0);
188     // 7. check if callback OnPublishResult called
189     ASSERT_EQ(count, 0);
190 }
191 
192 /*
193  * Feature: DeviceManagerNotifyTest OnPublishResult
194  * Function: DeviceManagerNotifyTest
195  * SubFunction: OnPublishResult Success
196  * FunctionPoints: DeviceManagerNotifyTest OnPublishResult
197  * EnvConditions: N/A.
198  * CaseDescription: 1. set pkgName not null
199  *                     set callback not null
200  *                     set subscribeId not null
201  *                  2. set checkMap null
202  *                  3. call DeviceManagerNotifyTest RegisterPublishCallback with parameter
203  *                  4. Get checkMap from DeviceManagerNotify
204  *                  5. check checkMap not null
205  *                  6. call DeviceManagerNotify OnPublishResult With testPkgName
206  *                  7. check if callback OnPublishResult called.
207  */
208 HWTEST_F(DeviceManagerNotifyTest, OnPublishSuccess5, testing::ext::TestSize.Level0)
209 {
210     // 1. set pkgName not null
211     std::string pkgName = "com.ohos.test";
212     // set callback not null
213     int count = 0;
214     std::shared_ptr<PublishCallback> callback = std::make_shared<PublishCallbackTest>(count);
215     // set publishId not null
216     int32_t publishId = 0;
217     // 2. set checkMap null
218     std::shared_ptr<PublishCallback> checkMap = nullptr;
219     // 3. call DeviceManagerNotifyTest RegisterDiscoverCallback with parameter
220     DeviceManagerNotify::GetInstance().RegisterPublishCallback(pkgName, publishId, callback);
221     // 4. Get checkMap from DeviceManagerNotify
222     checkMap = DeviceManagerNotify::GetInstance().devicePublishCallbacks_[pkgName][publishId];
223     // 5. check checkMap not null
224     ASSERT_NE(checkMap, nullptr);
225     std::string testPkgName = "";
226     DeviceManagerNotify::GetInstance().UnRegisterPublishCallback(testPkgName, publishId);
227     // 6. call DeviceManagerNotify OnPublishResult
228     DeviceManagerNotify::GetInstance().OnPublishResult(testPkgName, publishId, 0);
229     // 7. check if callback OnPublishSuccess called
230     ASSERT_EQ(count, 0);
231 }
232 
233 /*
234  * Feature: DeviceManagerNotifyTest OnAuthResult
235  * Function: OnAuthResult
236  * SubFunction: RegisterAuthenticateCallback
237  * FunctionPoints: DeviceManagerNotifyTest OnAuthResult
238  * EnvConditions: OnAuthResult success.
239  * CaseDescription: 1. set pkgName not null
240  *                     set Callback not null
241  *                     set deviceId not null
242  *                  2. set checkMap null
243  *                  3. call DeviceManagerNotifyTest RegisterAuthenticateCallback with parameter
244  *                  4. Get checkMap from DeviceManagerNotify
245  *                  5. check checkMap not null
246  *                  6. call DeviceManagerNotify OnAuthResult
247  *                  7. check if callback OnDiscoverySuccess called
248  */
249 HWTEST_F(DeviceManagerNotifyTest, OnAuthResult1, testing::ext::TestSize.Level0)
250 {
251     // 1. set pkgName not null
252     std::string pkgName = "com.ohos.test";
253     // set callback not null
254     int count = 0;
255     std::shared_ptr<AuthenticateCallback> callback = std::make_shared<AuthenticateCallbackTest>(count);
256     // set subscribeId not null
257     std::string deviceId = "1";
258     // 2. set checkMap null
259     std::shared_ptr<AuthenticateCallback> checkMap = nullptr;
260     // 3. call DeviceManagerNotifyTest RegisterAuthenticateCallback with parameter
261     DeviceManagerNotify::GetInstance().RegisterAuthenticateCallback(pkgName, deviceId, callback);
262     // 4. Get checkMap from DeviceManagerNotify
263     checkMap = DeviceManagerNotify::GetInstance().authenticateCallback_[pkgName][deviceId];
264     // 5. check checkMap not null
265     ASSERT_NE(checkMap, nullptr);
266     // 6. call DeviceManagerNotify OnAuthResult
267     std::string token = "111";
268     uint32_t status = 0;
269     uint32_t reason = 0;
270     DeviceManagerNotify::GetInstance().OnAuthResult(pkgName, deviceId, token, status, reason);
271     // 7. check if callback OnDiscoverySuccess called
272     ASSERT_EQ(count, 1);
273 }
274 
275 /*
276  * Feature: DeviceManagerNotifyTest OnAuthResult
277  * Function: OnAuthResult
278  * SubFunction: RegisterAuthenticateCallback
279  * FunctionPoints: DeviceManagerNotifyTest OnAuthResult
280  * EnvConditions: OnAuthResult success.
281  * CaseDescription: 1. set pkgName not null
282  *                     set Callback not null
283  *                     set deviceId not null
284  *                  2. set checkMap null
285  *                  3. call DeviceManagerNotifyTest RegisterAuthenticateCallback with parameter
286  *                  4. Get checkMap from DeviceManagerNotify
287  *                  5. check checkMap not null
288  *                  6. call DeviceManagerNotify OnAuthResult with testPkgName
289  *                  7. check if callback OnDiscoverySuccess called
290  */
291 HWTEST_F(DeviceManagerNotifyTest, OnAuthResult2, testing::ext::TestSize.Level0)
292 {
293     // 1. set pkgName not null
294     std::string pkgName = "com.ohos.test";
295     // set callback not null
296     int count = 0;
297     std::shared_ptr<AuthenticateCallback> callback = std::make_shared<AuthenticateCallbackTest>(count);
298     // set subscribeId not null
299     std::string deviceId = "1";
300     // 2. set checkMap null
301     std::shared_ptr<AuthenticateCallback> checkMap = nullptr;
302     // 3. call DeviceManagerNotifyTest RegisterAuthenticateCallback with parameter
303     DeviceManagerNotify::GetInstance().RegisterAuthenticateCallback(pkgName, deviceId, callback);
304     // 4. Get checkMap from DeviceManagerNotify
305     checkMap = DeviceManagerNotify::GetInstance().authenticateCallback_[pkgName][deviceId];
306     // 5. check checkMap not null
307     ASSERT_NE(checkMap, nullptr);
308     // 6. call DeviceManagerNotify OnAuthResult
309     std::string testPkgName = "com.ohos.test1";
310     std::string token = "111";
311     uint32_t status = 0;
312     uint32_t reason = 0;
313     DeviceManagerNotify::GetInstance().OnAuthResult(testPkgName, deviceId, token, status, reason);
314     // 7. check if callback OnDiscoverySuccess called
315     ASSERT_EQ(count, 0);
316 }
317 
318 /*
319  * Feature: DeviceManagerNotifyTest OnAuthResult
320  * Function: OnAuthResult
321  * SubFunction: RegisterAuthenticateCallback
322  * FunctionPoints: DeviceManagerNotifyTest OnAuthResult
323  * EnvConditions: OnAuthResult success.
324  * CaseDescription: 1. set pkgName not null
325  *                     set Callback not null
326  *                     set deviceId not null
327  *                  2. set checkMap null
328  *                  3. call DeviceManagerNotifyTest RegisterAuthenticateCallback with parameter
329  *                  4. Get checkMap from DeviceManagerNotify
330  *                  5. check checkMap not null
331  *                  6. call DeviceManagerNotify OnAuthResult with testDeviceId
332  *                  7. check if callback OnDiscoverySuccess called
333  */
334 HWTEST_F(DeviceManagerNotifyTest, OnAuthResult3, testing::ext::TestSize.Level0)
335 {
336     // 1. set pkgName not null
337     std::string pkgName = "com.ohos.test";
338     // set callback not null
339     int count = 0;
340     std::shared_ptr<AuthenticateCallback> callback = std::make_shared<AuthenticateCallbackTest>(count);
341     // set subscribeId not null
342     std::string deviceId = "1";
343     // 2. set checkMap null
344     std::shared_ptr<AuthenticateCallback> checkMap = nullptr;
345     // 3. call DeviceManagerNotifyTest RegisterAuthenticateCallback with parameter
346     DeviceManagerNotify::GetInstance().RegisterAuthenticateCallback(pkgName, deviceId, callback);
347     // 4. Get checkMap from DeviceManagerNotify
348     checkMap = DeviceManagerNotify::GetInstance().authenticateCallback_[pkgName][deviceId];
349     // 5. check checkMap not null
350     ASSERT_NE(checkMap, nullptr);
351     // 6. call DeviceManagerNotify OnAuthResult
352     std::string testDeviceId = "2";
353     std::string token = "111";
354     uint32_t status = 0;
355     uint32_t reason = 0;
356     DeviceManagerNotify::GetInstance().OnAuthResult(pkgName, testDeviceId, token, status, reason);
357     // 7. check if callback OnDiscoverySuccess called
358     ASSERT_EQ(count, 0);
359 }
360 
361 /*
362  * Feature: DeviceManagerNotifyTest OnAuthResult
363  * Function: OnAuthResult
364  * SubFunction: RegisterAuthenticateCallback
365  * FunctionPoints: DeviceManagerNotifyTest OnAuthResult
366  * EnvConditions: OnAuthResult success.
367  * CaseDescription: 1. set pkgName not null
368  *                     set Callback not null
369  *                     set deviceId not null
370  *                  2. set checkMap null
371  *                  3. call DeviceManagerNotifyTest RegisterAuthenticateCallback with parameter
372  *                  4. Get checkMap from DeviceManagerNotify
373  *                  5. check checkMap not null
374  *                  6. call DeviceManagerNotify OnAuthResult
375  *                  7. check if callback OnDiscoverySuccess called
376  */
377 HWTEST_F(DeviceManagerNotifyTest, OnAuthResult4, testing::ext::TestSize.Level0)
378 {
379     // 1. set pkgName not null
380     std::string pkgName = "com.ohos.test";
381     // set callback not null
382     int count = 0;
383     std::shared_ptr<AuthenticateCallback> callback = std::make_shared<AuthenticateCallbackTest>(count);
384     // set subscribeId not null
385     std::string deviceId = "1";
386     // 2. set checkMap null
387     std::shared_ptr<AuthenticateCallback> checkMap = nullptr;
388     // 3. call DeviceManagerNotifyTest RegisterAuthenticateCallback with parameter
389     DeviceManagerNotify::GetInstance().RegisterAuthenticateCallback(pkgName, deviceId, callback);
390     // 4. Get checkMap from DeviceManagerNotify
391     checkMap = DeviceManagerNotify::GetInstance().authenticateCallback_[pkgName][deviceId];
392     // 5. check checkMap not null
393     ASSERT_NE(checkMap, nullptr);
394     // 6. call DeviceManagerNotify OnAuthResult
395     std::string token = "111";
396     uint32_t status = 0;
397     uint32_t reason = 0;
398     DeviceManagerNotify::GetInstance().OnAuthResult(pkgName, deviceId, token, status, reason);
399     // 7. check if callback OnDiscoverySuccess called
400     ASSERT_EQ(count, 1);
401     checkMap = DeviceManagerNotify::GetInstance().authenticateCallback_[pkgName][deviceId];
402     ASSERT_EQ(checkMap, nullptr);
403 }
404 
405 /*
406  * Feature: DeviceManagerNotifyTest OnAuthResult
407  * Function: OnAuthResult
408  * SubFunction: RegisterAuthenticateCallback
409  * FunctionPoints: DeviceManagerNotifyTest OnAuthResult
410  * EnvConditions: OnAuthResult success.
411  * CaseDescription: 1. set pkgName not null
412  *                     set Callback not null
413  *                     set deviceId not null
414  *                  2. set checkMap null
415  *                  3. call DeviceManagerNotifyTest RegisterAuthenticateCallback with parameter
416  *                  4. Get checkMap from DeviceManagerNotify
417  *                  5. check checkMap not null
418  *                  6. call DeviceManagerNotify OnAuthResult
419  *                  7. check if callback OnDiscoverySuccess called
420  */
421 HWTEST_F(DeviceManagerNotifyTest, OnAuthResult5, testing::ext::TestSize.Level0)
422 {
423     // 1. set pkgName not null
424     std::string pkgName = "com.ohos.test";
425     // set callback not null
426     int count = 0;
427     std::shared_ptr<AuthenticateCallback> callback = std::make_shared<AuthenticateCallbackTest>(count);
428     // set subscribeId not null
429     std::string deviceId = "1";
430     // 2. set checkMap null
431     std::shared_ptr<AuthenticateCallback> checkMap = nullptr;
432     // 3. call DeviceManagerNotifyTest RegisterAuthenticateCallback with parameter
433     DeviceManagerNotify::GetInstance().RegisterAuthenticateCallback(pkgName, deviceId, callback);
434     // 4. Get checkMap from DeviceManagerNotify
435     checkMap = DeviceManagerNotify::GetInstance().authenticateCallback_[pkgName][deviceId];
436     // 5. check checkMap not null
437     ASSERT_NE(checkMap, nullptr);
438     // 6. call DeviceManagerNotify OnAuthResult
439     std::string testPkaName = "com.ohos.test1";
440     std::string token = "111";
441     uint32_t status = 0;
442     uint32_t reason = 0;
443     DeviceManagerNotify::GetInstance().OnAuthResult(testPkaName, deviceId, token, status, reason);
444     // 7. check if callback OnDiscoverySuccess called
445     ASSERT_EQ(count, 0);
446     checkMap = DeviceManagerNotify::GetInstance().authenticateCallback_[pkgName][deviceId];
447     ASSERT_NE(checkMap, nullptr);
448 }
449 
450 /*
451  * Feature: DeviceManagerNotifyTest OnAuthResult
452  * Function: OnAuthResult
453  * SubFunction: RegisterAuthenticateCallback
454  * FunctionPoints: DeviceManagerNotifyTest OnAuthResult
455  * EnvConditions: OnAuthResult success.
456  * CaseDescription: 1. set pkgName not null
457  *                     set Callback not null
458  *                     set deviceId not null
459  *                  2. set checkMap null
460  *                  3. call DeviceManagerNotifyTest RegisterAuthenticateCallback with parameter
461  *                  4. Get checkMap from DeviceManagerNotify
462  *                  5. check checkMap not null
463  *                  6. call DeviceManagerNotify OnAuthResult
464  *                  7. check if callback OnDiscoverySuccess called
465  */
466 HWTEST_F(DeviceManagerNotifyTest, OnAuthResult6, testing::ext::TestSize.Level0)
467 {
468     // 1. set pkgName not null
469     std::string pkgName = "com.ohos.test";
470     // set callback not null
471     int count = 0;
472     std::shared_ptr<AuthenticateCallback> callback = std::make_shared<AuthenticateCallbackTest>(count);
473     // set subscribeId not null
474     std::string deviceId = "1";
475     // 2. set checkMap null
476     std::shared_ptr<AuthenticateCallback> checkMap = nullptr;
477     // 3. call DeviceManagerNotifyTest RegisterAuthenticateCallback with parameter
478     DeviceManagerNotify::GetInstance().RegisterAuthenticateCallback(pkgName, deviceId, callback);
479     // 4. Get checkMap from DeviceManagerNotify
480     checkMap = DeviceManagerNotify::GetInstance().authenticateCallback_[pkgName][deviceId];
481     // 5. check checkMap not null
482     ASSERT_NE(checkMap, nullptr);
483     // 6. call DeviceManagerNotify OnAuthResult
484     std::string testDeviceId = "2";
485     std::string token = "111";
486     uint32_t status = 0;
487     uint32_t reason = 0;
488     DeviceManagerNotify::GetInstance().OnAuthResult(pkgName, testDeviceId, token, status, reason);
489     // 7. check if callback OnDiscoverySuccess called
490     ASSERT_EQ(count, 0);
491     checkMap = DeviceManagerNotify::GetInstance().authenticateCallback_[pkgName][deviceId];
492     ASSERT_NE(checkMap, nullptr);
493 }
494 
495 /*
496  * Feature: DeviceManagerNotifyTest OnAuthResult
497  * Function: OnAuthResult
498  * SubFunction: RegisterAuthenticateCallback
499  * FunctionPoints: DeviceManagerNotifyTest OnAuthResult
500  * EnvConditions: OnAuthResult success.
501  * CaseDescription: 1. set pkgName not null
502  *                     set Callback not null
503  *                     set deviceId not null
504  *                  2. set checkMap null
505  *                  3. call DeviceManagerNotifyTest RegisterAuthenticateCallback with parameter
506  *                  4. Get checkMap from DeviceManagerNotify
507  *                  5. check checkMap not null
508  *                  6. call DeviceManagerNotify OnAuthResult
509  *                  7. check if callback OnDiscoverySuccess called
510  */
511 HWTEST_F(DeviceManagerNotifyTest, OnAuthResult7, testing::ext::TestSize.Level0)
512 {
513     // 1. set pkgName not null
514     std::string pkgName = "com.ohos.test";
515     // set callback not null
516     int count = 0;
517     std::shared_ptr<AuthenticateCallback> callback = std::make_shared<AuthenticateCallbackTest>(count);
518     // set subscribeId not null
519     std::string deviceId = "1";
520     // 2. set checkMap null
521     std::shared_ptr<AuthenticateCallback> checkMap = nullptr;
522     // 3. call DeviceManagerNotifyTest RegisterAuthenticateCallback with parameter
523     DeviceManagerNotify::GetInstance().RegisterAuthenticateCallback(pkgName, deviceId, callback);
524     // 4. Get checkMap from DeviceManagerNotify
525     checkMap = DeviceManagerNotify::GetInstance().authenticateCallback_[pkgName][deviceId];
526     // 5. check checkMap not null
527     ASSERT_NE(checkMap, nullptr);
528     // 6. call DeviceManagerNotify OnAuthResult
529     std::string token = "111";
530     uint32_t status = 0;
531     uint32_t reason = 0;
532     DeviceManagerNotify::GetInstance().OnAuthResult(pkgName, deviceId, token, status, reason);
533     // 7. check if callback OnDiscoverySuccess called
534     ASSERT_EQ(count, 1);
535     checkMap = DeviceManagerNotify::GetInstance().authenticateCallback_[pkgName][deviceId];
536     ASSERT_EQ(checkMap, nullptr);
537 }
538 
539 /*
540  * Feature: DeviceManagerNotifyTest OnUiCall
541  * Function: DeviceManagerNotifyTest
542  * SubFunction: OnUiCall
543  * FunctionPoints: DeviceManagerNotifyTest OnUiCall
544  * EnvConditions: OnUiCall success.
545  * CaseDescription: 1. set pkgName not null
546  *                     set dmUiCallback_ not null
547  *                  2. set checkMap null
548  *                  3. call DeviceManagerNotifyTest RegisterDeviceManagerFaCallback with parameter
549  *                  4. Get checkMap from DeviceManagerNotify
550  *                  5. check checkMap not null
551  *                  6. call DeviceManagerNotify OnUiCall
552  *                  7. check if callback OnCheckAuthResult called
553  */
554 HWTEST_F(DeviceManagerNotifyTest, OnUiCall1, testing::ext::TestSize.Level0)
555 {
556     // 1. set pkgName not null
557     std::string pkgName = "com.ohos.test";
558     // set dmUiCallback_ not null
559     int count = 0;
560     std::shared_ptr<DeviceManagerUiCallback> dmUiCallback_ = std::make_shared<DeviceManagerFaCallbackTest>(count);
561     // 2. set checkMap null
562     std::shared_ptr<DeviceManagerUiCallback> checkMap = nullptr;
563     // 3. call DeviceManagerNotifyTest RegisterDeviceManagerFaCallback with parameter
564     DeviceManagerNotify::GetInstance().RegisterDeviceManagerFaCallback(pkgName, dmUiCallback_);
565     // 4. Get checkMap from DeviceManagerNotify
566     checkMap = DeviceManagerNotify::GetInstance().dmUiCallback_[pkgName];
567     // 5. check checkMap not null
568     ASSERT_NE(checkMap, nullptr);
569     // 6. call DeviceManagerNotify OnUiCall
570     std::string paramJson = "trstParamJson";
571     DeviceManagerNotify::GetInstance().OnUiCall(pkgName, paramJson);
572     // 7. check if callback OnCheckAuthResult called
573     ASSERT_EQ(count, 1);
574 }
575 
576 /*
577  * Feature: DeviceManagerNotifyTest OnUiCall
578  * Function: DeviceManagerNotifyTest
579  * SubFunction: OnUiCall
580  * FunctionPoints: DeviceManagerNotifyTest OnUiCall
581  * EnvConditions: OnUiCall success.
582  * CaseDescription: 1. set pkgName not null
583  *                     set dmUiCallback_ not null
584  *                  2. set checkMap null
585  *                  3. call DeviceManagerNotifyTest RegisterDeviceManagerFaCallback with parameter
586  *                  4. Get checkMap from DeviceManagerNotify
587  *                  5. check checkMap not null
588  *                  6. call DeviceManagerNotify OnUiCall with testPkgName
589  *                  7. check if callback OnCheckAuthResult called
590  */
591 HWTEST_F(DeviceManagerNotifyTest, OnUiCall2, testing::ext::TestSize.Level0)
592 {
593     // 1. set pkgName not null
594     std::string pkgName = "com.ohos.test";
595     // set dmUiCallback_ not null
596     int count = 0;
597     std::shared_ptr<DeviceManagerUiCallback> dmUiCallback_ = std::make_shared<DeviceManagerFaCallbackTest>(count);
598     // 2. set checkMap null
599     std::shared_ptr<DeviceManagerUiCallback> checkMap = nullptr;
600     // 3. call DeviceManagerNotifyTest RegisterDeviceManagerFaCallback with parameter
601     DeviceManagerNotify::GetInstance().RegisterDeviceManagerFaCallback(pkgName, dmUiCallback_);
602     // 4. Get checkMap from DeviceManagerNotify
603     checkMap = DeviceManagerNotify::GetInstance().dmUiCallback_[pkgName];
604     // 5. check checkMap not null
605     ASSERT_NE(checkMap, nullptr);
606     // 6. call DeviceManagerNotify OnUiCall
607     std::string testPkgName = "com.ohos.test1";
608     std::string paramJson = "trstParamJson";
609     DeviceManagerNotify::GetInstance().OnUiCall(testPkgName, paramJson);
610     // 7. check if callback OnCheckAuthResult called
611     ASSERT_EQ(count, 0);
612 }
613 
614 /*
615  * Feature: DeviceManagerNotifyTest OnUiCall
616  * Function: DeviceManagerNotifyTest
617  * SubFunction: OnUiCall
618  * FunctionPoints: DeviceManagerNotifyTest OnUiCall
619  * EnvConditions: OnUiCall success.
620  * CaseDescription: 1. set pkgName not null
621  *                     set dmUiCallback_ not null
622  *                  2. set checkMap null
623  *                  3. call DeviceManagerNotifyTest RegisterDeviceManagerFaCallback with parameter
624  *                  4. Get checkMap from DeviceManagerNotify
625  *                  5. check checkMap not null
626  *                  6. call DeviceManagerNotify OnUiCall with testPkgName
627  *                  7. check if callback OnCheckAuthResult called
628  */
629 HWTEST_F(DeviceManagerNotifyTest, OnUiCall3, testing::ext::TestSize.Level0)
630 {
631     // 1. set pkgName not null
632     std::string pkgName = "com.ohos.test";
633     // set dmUiCallback_ not null
634     int count = 0;
635     std::shared_ptr<DeviceManagerUiCallback> dmUiCallback_ = std::make_shared<DeviceManagerFaCallbackTest>(count);
636     // 2. set checkMap null
637     std::shared_ptr<DeviceManagerUiCallback> checkMap = nullptr;
638     // 3. call DeviceManagerNotifyTest RegisterDeviceManagerFaCallback with parameter
639     DeviceManagerNotify::GetInstance().RegisterDeviceManagerFaCallback(pkgName, dmUiCallback_);
640     // 4. Get checkMap from DeviceManagerNotify
641     checkMap = DeviceManagerNotify::GetInstance().dmUiCallback_[pkgName];
642     // 5. check checkMap not null
643     ASSERT_NE(checkMap, nullptr);
644     // 6. call DeviceManagerNotify OnUiCall
645     std::string testPkgName = "";
646     std::string paramJson = "trstParamJson";
647     DeviceManagerNotify::GetInstance().OnUiCall(testPkgName, paramJson);
648     // 7. check if callback OnCheckAuthResult called
649     ASSERT_EQ(count, 0);
650 }
651 
652 /*
653  * Feature: DeviceManagerNotifyTest OnUiCall
654  * Function: DeviceManagerNotifyTest
655  * SubFunction: OnUiCall
656  * FunctionPoints: DeviceManagerNotifyTest OnUiCall
657  * EnvConditions: OnUiCall success.
658  * CaseDescription: 1. set pkgName not null
659  *                     set dmUiCallback_ not null
660  *                  2. set checkMap null
661  *                  3. call DeviceManagerNotifyTest RegisterDeviceManagerFaCallback with parameter
662  *                  4. Get checkMap from DeviceManagerNotify
663  *                  5. check checkMap not null
664  *                  6. call DeviceManagerNotify OnUiCall with testPkgName
665  *                  7. check if callback OnCheckAuthResult called
666  */
667 HWTEST_F(DeviceManagerNotifyTest, OnUiCall4, testing::ext::TestSize.Level0)
668 {
669     // 1. set pkgName not null
670     std::string pkgName = "com.ohos.test";
671     // set dmUiCallback_ not null
672     int count = 0;
673     std::shared_ptr<DeviceManagerUiCallback> dmUiCallback_ = std::make_shared<DeviceManagerFaCallbackTest>(count);
674     // 2. set checkMap null
675     std::shared_ptr<DeviceManagerUiCallback> checkMap = nullptr;
676     // 3. call DeviceManagerNotifyTest RegisterDeviceManagerFaCallback with parameter
677     DeviceManagerNotify::GetInstance().RegisterDeviceManagerFaCallback(pkgName, dmUiCallback_);
678     // 4. Get checkMap from DeviceManagerNotify
679     checkMap = DeviceManagerNotify::GetInstance().dmUiCallback_[pkgName];
680     // 5. check checkMap not null
681     ASSERT_NE(checkMap, nullptr);
682     // 6. call DeviceManagerNotify OnUiCall
683     std::string testPkgName = "com.ohos.test";
684     std::string paramJson = "trstParamJson";
685     DeviceManagerNotify::GetInstance().OnUiCall(testPkgName, paramJson);
686     // 7. check if callback OnCheckAuthResult called
687     ASSERT_EQ(count, 1);
688 }
689 
690 /*
691  * Feature: DeviceManagerNotifyTest OnUiCall
692  * Function: DeviceManagerNotifyTest
693  * SubFunction: OnUiCall
694  * FunctionPoints: DeviceManagerNotifyTest OnUiCall
695  * EnvConditions: OnUiCall success.
696  * CaseDescription: 1. set pkgName not null
697  *                     set dmUiCallback_ not null
698  *                  2. set checkMap null
699  *                  3. call DeviceManagerNotifyTest RegisterDeviceManagerFaCallback with parameter
700  *                  4. Get checkMap from DeviceManagerNotify
701  *                  5. check checkMap not null
702  *                  6. call DeviceManagerNotify OnUiCall with testPkgName
703  *                  7. check if callback OnCheckAuthResult called
704  */
705 HWTEST_F(DeviceManagerNotifyTest, OnUiCall5, testing::ext::TestSize.Level0)
706 {
707     // 1. set pkgName not null
708     std::string pkgName = "";
709     // set dmUiCallback_ not null
710     int count = 0;
711     std::shared_ptr<DeviceManagerUiCallback> dmUiCallback_ = std::make_shared<DeviceManagerFaCallbackTest>(count);
712     // 2. set checkMap null
713     std::shared_ptr<DeviceManagerUiCallback> checkMap = nullptr;
714     // 3. call DeviceManagerNotifyTest RegisterDeviceManagerFaCallback with parameter
715     DeviceManagerNotify::GetInstance().RegisterDeviceManagerFaCallback(pkgName, dmUiCallback_);
716     // 4. Get checkMap from DeviceManagerNotify
717     checkMap = DeviceManagerNotify::GetInstance().dmUiCallback_[pkgName];
718     // 5. check checkMap not null
719     ASSERT_NE(checkMap, nullptr);
720     // 6. call DeviceManagerNotify OnUiCall
721     std::string testPkgName = "";
722     DeviceManagerNotify::GetInstance().UnRegisterDeviceManagerFaCallback(testPkgName);
723     std::string paramJson = "trstParamJson";
724     DeviceManagerNotify::GetInstance().OnUiCall(testPkgName, paramJson);
725     // 7. check if callback OnCheckAuthResult called
726     ASSERT_EQ(count, 0);
727 }
728 
729 /**
730  * @tc.name: OnCredentialResult1
731  * @tc.type: FUNC
732  */
733 HWTEST_F(DeviceManagerNotifyTest, OnCredentialResult1, testing::ext::TestSize.Level0)
734 {
735     std::string pkgName = "";
736     int32_t action = 1;
737     std::string credentialResult = "failed";
738     DeviceManagerNotify::GetInstance().OnCredentialResult(pkgName, action, credentialResult);
739     std::shared_ptr<CredentialCallback> tempCbk;
740     tempCbk = DeviceManagerNotify::GetInstance().credentialCallback_[pkgName];
741     EXPECT_EQ(tempCbk, nullptr);
742 }
743 
744 /**
745  * @tc.name: OnCredentialResult2
746  * @tc.type: FUNC
747  */
748 HWTEST_F(DeviceManagerNotifyTest, OnCredentialResult2, testing::ext::TestSize.Level0)
749 {
750     std::string pkgName = "com.ohos.test";
751     int32_t action = 1;
752     std::string credentialResult = "failed";
753     std::shared_ptr<CredentialCallback> tempCbk = std::make_shared<CredentialCallbackTest>();
754     DeviceManagerNotify::GetInstance().credentialCallback_[pkgName] = tempCbk;
755     DeviceManagerNotify::GetInstance().OnCredentialResult(pkgName, action, credentialResult);
756     int count = DeviceManagerNotify::GetInstance().credentialCallback_.count(pkgName);
757     EXPECT_EQ(count, 1);
758 }
759 
760 /**
761  * @tc.name: OnCredentialResult3
762  * @tc.type: FUNC
763  */
764 HWTEST_F(DeviceManagerNotifyTest, OnCredentialResult3, testing::ext::TestSize.Level0)
765 {
766     std::string pkgName = "com.ohos.test3";
767     int32_t action = 1;
768     std::string credentialResult = "failed";
769     DeviceManagerNotify::GetInstance().credentialCallback_[pkgName] = nullptr;
770     DeviceManagerNotify::GetInstance().OnCredentialResult(pkgName, action, credentialResult);
771     int count = DeviceManagerNotify::GetInstance().credentialCallback_.count(pkgName);
772     EXPECT_EQ(count, 1);
773 }
774 
775 /**
776  * @tc.name: OnCredentialResult4
777  * @tc.type: FUNC
778  */
779 HWTEST_F(DeviceManagerNotifyTest, OnCredentialResult4, testing::ext::TestSize.Level0)
780 {
781     std::string pkgName = "com.ohos.test4";
782     int32_t action = 1;
783     std::string credentialResult = "failed";
784     DeviceManagerNotify::GetInstance().OnCredentialResult(pkgName, action, credentialResult);
785     int count = DeviceManagerNotify::GetInstance().credentialCallback_.count(pkgName);
786     EXPECT_EQ(count, 0);
787 }
788 
789 /**
790  * @tc.name: UnRegisterDeviceStatusCallback1
791  * @tc.type: FUNC
792  */
793 HWTEST_F(DeviceManagerNotifyTest, UnRegisterDeviceStatusCallback1, testing::ext::TestSize.Level0)
794 {
795     std::string pkgName = "com.ohos.test4";
796     DeviceManagerNotify::GetInstance().UnRegisterDeviceStatusCallback(pkgName);
797     EXPECT_EQ(DeviceManagerNotify::GetInstance().deviceStatusCallback_.empty(), true);
798 }
799 
800 /**
801  * @tc.name: UnRegisterDeviceStatusCallback2
802  * @tc.type: FUNC
803  */
804 HWTEST_F(DeviceManagerNotifyTest, UnRegisterDeviceStatusCallback2, testing::ext::TestSize.Level0)
805 {
806     std::string pkgName;
807     DeviceManagerNotify::GetInstance().UnRegisterDeviceStatusCallback(pkgName);
808     EXPECT_EQ(DeviceManagerNotify::GetInstance().deviceStatusCallback_.empty(), true);
809 }
810 
811 /**
812  * @tc.name: RegisterDeviceStatusCallback1
813  * @tc.type: FUNC
814  */
815 HWTEST_F(DeviceManagerNotifyTest, RegisterDeviceStatusCallback1, testing::ext::TestSize.Level0)
816 {
817     std::string pkgName = "com.ohos.test4";
818     std::shared_ptr<DeviceStatusCallback> callback = std::make_shared<DeviceStatusCallbackTest>();
819     DeviceManagerNotify::GetInstance().RegisterDeviceStatusCallback(pkgName, callback);
820     EXPECT_EQ(DeviceManagerNotify::GetInstance().deviceStatusCallback_.empty(), false);
821 }
822 
823 /**
824  * @tc.name: RegisterDeviceStatusCallback2
825  * @tc.type: FUNC
826  */
827 HWTEST_F(DeviceManagerNotifyTest, RegisterDeviceStatusCallback2, testing::ext::TestSize.Level0)
828 {
829     std::string pkgName;
830     std::shared_ptr<DeviceStatusCallback> callback = std::make_shared<DeviceStatusCallbackTest>();
831     DeviceManagerNotify::GetInstance().RegisterDeviceStatusCallback(pkgName, callback);
832     EXPECT_EQ(DeviceManagerNotify::GetInstance().deviceStatusCallback_.empty(), false);
833     DeviceManagerNotify::GetInstance().deviceStatusCallback_.clear();
834 }
835 
836 /**
837  * @tc.name: OnDeviceOnline1
838  * @tc.type: FUNC
839  */
840 HWTEST_F(DeviceManagerNotifyTest, OnDeviceOnline1, testing::ext::TestSize.Level0)
841 {
842     std::string pkgName = "com.ohos.test4";
843     DmDeviceBasicInfo deviceBasicInfo;
844     DeviceManagerNotify::GetInstance().OnDeviceOnline(pkgName, deviceBasicInfo);
845     auto ptr = DeviceManagerNotify::GetInstance().deviceStatusCallback_[pkgName];
846     EXPECT_EQ(ptr, nullptr);
847 }
848 
849 /**
850  * @tc.name: OnDeviceOnline2
851  * @tc.type: FUNC
852  */
853 HWTEST_F(DeviceManagerNotifyTest, OnDeviceOnline2, testing::ext::TestSize.Level0)
854 {
855     std::string pkgName;
856     DmDeviceBasicInfo deviceBasicInfo;
857     DeviceManagerNotify::GetInstance().OnDeviceOnline(pkgName, deviceBasicInfo);
858     auto ptr = DeviceManagerNotify::GetInstance().deviceStatusCallback_[pkgName];
859     EXPECT_EQ(ptr, nullptr);
860 }
861 
862 /**
863  * @tc.name: OnDeviceOffline1
864  * @tc.type: FUNC
865  */
866 HWTEST_F(DeviceManagerNotifyTest, OnDeviceOffline1, testing::ext::TestSize.Level0)
867 {
868     std::string pkgName = "com.ohos.test4";
869     DmDeviceBasicInfo deviceBasicInfo;
870     DeviceManagerNotify::GetInstance().OnDeviceOffline(pkgName, deviceBasicInfo);
871     auto ptr = DeviceManagerNotify::GetInstance().deviceStatusCallback_[pkgName];
872     EXPECT_EQ(ptr, nullptr);
873 }
874 
875 /**
876  * @tc.name: OnDeviceOffline2
877  * @tc.type: FUNC
878  */
879 HWTEST_F(DeviceManagerNotifyTest, OnDeviceOffline2, testing::ext::TestSize.Level0)
880 {
881     std::string pkgName;
882     DmDeviceBasicInfo deviceBasicInfo;
883     DeviceManagerNotify::GetInstance().OnDeviceOffline(pkgName, deviceBasicInfo);
884     auto ptr = DeviceManagerNotify::GetInstance().deviceStatusCallback_[pkgName];
885     EXPECT_EQ(ptr, nullptr);
886 }
887 
888 /**
889  * @tc.name: OnDeviceReady1
890  * @tc.type: FUNC
891  */
892 HWTEST_F(DeviceManagerNotifyTest, OnDeviceReady1, testing::ext::TestSize.Level0)
893 {
894     std::string pkgName = "com.ohos.test4";
895     DmDeviceBasicInfo deviceBasicInfo;
896     DeviceManagerNotify::GetInstance().OnDeviceReady(pkgName, deviceBasicInfo);
897     auto ptr = DeviceManagerNotify::GetInstance().deviceStatusCallback_[pkgName];
898     EXPECT_EQ(ptr, nullptr);
899 }
900 
901 /**
902  * @tc.name: OnDeviceReady2
903  * @tc.type: FUNC
904  */
905 HWTEST_F(DeviceManagerNotifyTest, OnDeviceReady2, testing::ext::TestSize.Level0)
906 {
907     std::string pkgName;
908     DmDeviceBasicInfo deviceBasicInfo;
909     DeviceManagerNotify::GetInstance().OnDeviceReady(pkgName, deviceBasicInfo);
910     auto ptr = DeviceManagerNotify::GetInstance().deviceStatusCallback_[pkgName];
911     EXPECT_EQ(ptr, nullptr);
912 }
913 
914 /**
915  * @tc.name: OnDeviceFound6
916  * @tc.type: FUNC
917  */
918 HWTEST_F(DeviceManagerNotifyTest, OnDeviceFound6, testing::ext::TestSize.Level0)
919 {
920     std::string pkgName = "com.ohos.test4";
921     uint16_t subscribeId = 0;
922     DmDeviceBasicInfo deviceBasicInfo;
923     DeviceManagerNotify::GetInstance().OnDeviceFound(pkgName, subscribeId, deviceBasicInfo);
924     auto map = DeviceManagerNotify::GetInstance().deviceDiscoveryCallbacks_[pkgName];
925     EXPECT_EQ(map.empty(), true);
926 }
927 
928 /**
929  * @tc.name: OnDeviceFound7
930  * @tc.type: FUNC
931  */
932 HWTEST_F(DeviceManagerNotifyTest, OnDeviceFound7, testing::ext::TestSize.Level0)
933 {
934     std::string pkgName;
935     uint16_t subscribeId = 0;
936     DmDeviceBasicInfo deviceBasicInfo;
937     DeviceManagerNotify::GetInstance().OnDeviceFound(pkgName, subscribeId, deviceBasicInfo);
938     auto map = DeviceManagerNotify::GetInstance().deviceDiscoveryCallbacks_[pkgName];
939     EXPECT_EQ(map.empty(), false);
940 }
941 
942 /**
943  * @tc.name: RegisterCredentialCallback_301
944  * @tc.type: FUNC
945  */
946 HWTEST_F(DeviceManagerNotifyTest, RegisterCredentialCallback_301, testing::ext::TestSize.Level0)
947 {
948     std::string pkgName;
949     std::shared_ptr<CredentialCallback> callback = std::make_shared<CredentialCallbackTest>();
950     DeviceManagerNotify::GetInstance().credentialCallback_.clear();
951     DeviceManagerNotify::GetInstance().RegisterCredentialCallback(pkgName, callback);
952     DeviceManagerNotify::GetInstance().UnRegisterCredentialCallback(pkgName);
953     EXPECT_EQ(DeviceManagerNotify::GetInstance().credentialCallback_.empty(), true);
954 }
955 
956 /**
957  * @tc.name: RegisterCredentialCallback_302
958  * @tc.type: FUNC
959  */
960 HWTEST_F(DeviceManagerNotifyTest, RegisterCredentialCallback_302, testing::ext::TestSize.Level0)
961 {
962     std::string pkgName = "pkgName";
963     std::shared_ptr<CredentialCallback> callback = nullptr;
964     DeviceManagerNotify::GetInstance().credentialCallback_.clear();
965     DeviceManagerNotify::GetInstance().RegisterCredentialCallback(pkgName, callback);
966     EXPECT_EQ(DeviceManagerNotify::GetInstance().credentialCallback_.empty(), true);
967 }
968 
969 /**
970  * @tc.name: RegisterCredentialCallback_303
971  * @tc.type: FUNC
972  */
973 HWTEST_F(DeviceManagerNotifyTest, RegisterCredentialCallback_303, testing::ext::TestSize.Level0)
974 {
975     std::string pkgName;
976     std::shared_ptr<CredentialCallback> callback = nullptr;
977     DeviceManagerNotify::GetInstance().credentialCallback_.clear();
978     DeviceManagerNotify::GetInstance().RegisterCredentialCallback(pkgName, callback);
979     EXPECT_EQ(DeviceManagerNotify::GetInstance().credentialCallback_.empty(), true);
980 }
981 
982 /**
983  * @tc.name: RegisterPinHolderCallback_301
984  * @tc.type: FUNC
985  */
986 HWTEST_F(DeviceManagerNotifyTest, RegisterPinHolderCallback_301, testing::ext::TestSize.Level0)
987 {
988     std::string pkgName = "pkgName";
989     std::shared_ptr<PinHolderCallback> callback = nullptr;
990     DeviceManagerNotify::GetInstance().pinHolderCallback_.clear();
991     DeviceManagerNotify::GetInstance().RegisterPinHolderCallback(pkgName, callback);
992     EXPECT_EQ(DeviceManagerNotify::GetInstance().pinHolderCallback_.empty(), true);
993 }
994 
995 /**
996  * @tc.name: RegisterPinHolderCallback_302
997  * @tc.type: FUNC
998  */
999 HWTEST_F(DeviceManagerNotifyTest, RegisterPinHolderCallback_302, testing::ext::TestSize.Level0)
1000 {
1001     std::string pkgName;
1002     std::shared_ptr<PinHolderCallback> callback = nullptr;
1003     DeviceManagerNotify::GetInstance().pinHolderCallback_.clear();
1004     DeviceManagerNotify::GetInstance().RegisterPinHolderCallback(pkgName, callback);
1005     EXPECT_EQ(DeviceManagerNotify::GetInstance().pinHolderCallback_.empty(), true);
1006 }
1007 
1008 /**
1009  * @tc.name: RegisterPinHolderCallback_303
1010  * @tc.type: FUNC
1011  */
1012 HWTEST_F(DeviceManagerNotifyTest, RegisterPinHolderCallback_303, testing::ext::TestSize.Level0)
1013 {
1014     std::string pkgName;
1015     std::shared_ptr<PinHolderCallback> callback = std::make_shared<PinHolderCallbackTest>();
1016     DeviceManagerNotify::GetInstance().pinHolderCallback_.clear();
1017     DeviceManagerNotify::GetInstance().RegisterPinHolderCallback(pkgName, callback);
1018     EXPECT_EQ(DeviceManagerNotify::GetInstance().pinHolderCallback_.empty(), true);
1019 }
1020 } // namespace
1021 
DmInitCallbackTest(int & count)1022 DmInitCallbackTest::DmInitCallbackTest(int &count) : DmInitCallback()
1023 {
1024     count_ = &count;
1025 }
OnRemoteDied()1026 void DmInitCallbackTest::OnRemoteDied()
1027 {
1028     *count_ = *count_ + 1;
1029 }
1030 
DeviceStateCallbackTest(int & count)1031 DeviceStateCallbackTest::DeviceStateCallbackTest(int &count) : DeviceStateCallback()
1032 {
1033     count_ = &count;
1034 }
1035 
OnDeviceOnline(const DmDeviceInfo & deviceInfo)1036 void DeviceStateCallbackTest::OnDeviceOnline(const DmDeviceInfo &deviceInfo)
1037 {
1038     *count_ = *count_ + 1;
1039 }
1040 
OnDeviceReady(const DmDeviceInfo & deviceInfo)1041 void DeviceStateCallbackTest::OnDeviceReady(const DmDeviceInfo &deviceInfo)
1042 {
1043     *count_ = *count_ + 1;
1044 }
1045 
OnDeviceOffline(const DmDeviceInfo & deviceInfo)1046 void DeviceStateCallbackTest::OnDeviceOffline(const DmDeviceInfo &deviceInfo)
1047 {
1048     *count_ = *count_ + 1;
1049 }
1050 
OnDeviceChanged(const DmDeviceInfo & deviceInfo)1051 void DeviceStateCallbackTest::OnDeviceChanged(const DmDeviceInfo &deviceInfo)
1052 {
1053     *count_ = *count_ + 1;
1054 }
1055 
DiscoveryCallbackTest(int & count)1056 DiscoveryCallbackTest::DiscoveryCallbackTest(int &count) : DiscoveryCallback()
1057 {
1058     count_ = &count;
1059 }
1060 
OnDeviceFound(uint16_t subscribeId,const DmDeviceInfo & deviceInfo)1061 void DiscoveryCallbackTest::OnDeviceFound(uint16_t subscribeId, const DmDeviceInfo &deviceInfo)
1062 {
1063     *count_ = *count_ + 1;
1064 }
1065 
OnDiscoveryFailed(uint16_t subscribeId,int32_t failedReason)1066 void DiscoveryCallbackTest::OnDiscoveryFailed(uint16_t subscribeId, int32_t failedReason)
1067 {
1068     *count_ = *count_ + 1;
1069 }
1070 
OnDiscoverySuccess(uint16_t subscribeId)1071 void DiscoveryCallbackTest::OnDiscoverySuccess(uint16_t subscribeId)
1072 {
1073     *count_ = *count_ + 1;
1074 }
1075 
PublishCallbackTest(int & count)1076 PublishCallbackTest::PublishCallbackTest(int &count) : PublishCallback()
1077 {
1078     count_ = &count;
1079 }
1080 
OnPublishResult(int32_t publishId,int32_t failedReason)1081 void PublishCallbackTest::OnPublishResult(int32_t publishId, int32_t failedReason)
1082 {
1083     *count_ = *count_ + 1;
1084 }
1085 
AuthenticateCallbackTest(int & count)1086 AuthenticateCallbackTest::AuthenticateCallbackTest(int &count) : AuthenticateCallback()
1087 {
1088     count_ = &count;
1089 }
1090 
OnAuthResult(const std::string & deviceId,const std::string & token,int32_t status,int32_t reason)1091 void AuthenticateCallbackTest::OnAuthResult(const std::string &deviceId, const std::string &token, int32_t status,
1092     int32_t reason)
1093 {
1094     *count_ = *count_ + 1;
1095 }
1096 
DeviceManagerFaCallbackTest(int & count)1097 DeviceManagerFaCallbackTest::DeviceManagerFaCallbackTest(int &count) : DeviceManagerUiCallback()
1098 {
1099     count_ = &count;
1100 }
1101 
OnCall(const std::string & paramJson)1102 void DeviceManagerFaCallbackTest::OnCall(const std::string &paramJson)
1103 {
1104     *count_ = *count_ + 1;
1105 }
1106 } // namespace DistributedHardware
1107 } // namespace OHOS
1108