1 /*
2 * Copyright (c) 2024 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_ipc_cmd_parser_service.h"
17
18 #include <unistd.h>
19
20 #include "device_manager_ipc_interface_code.h"
21 #include "device_manager_notify.h"
22 #include "dm_anonymous.h"
23 #include "dm_constants.h"
24 #include "dm_device_info.h"
25 #include "ipc_client_manager.h"
26 #include "ipc_cmd_register.h"
27 #include "ipc_create_pin_holder_req.h"
28 #include "ipc_credential_auth_status_req.h"
29 #include "ipc_destroy_pin_holder_req.h"
30 #include "ipc_get_info_by_network_req.h"
31 #include "ipc_get_info_by_network_rsp.h"
32 #include "ipc_get_local_device_info_rsp.h"
33 #include "ipc_get_trustdevice_req.h"
34 #include "ipc_get_trustdevice_rsp.h"
35 #include "ipc_notify_auth_result_req.h"
36 #include "ipc_notify_bind_result_req.h"
37 #include "ipc_notify_credential_req.h"
38 #include "ipc_notify_device_discovery_req.h"
39 #include "ipc_notify_dmfa_result_req.h"
40 #include "ipc_notify_event_req.h"
41 #include "ipc_notify_pin_holder_event_req.h"
42 #include "ipc_notify_publish_result_req.h"
43 #include "ipc_publish_req.h"
44 #include "ipc_register_listener_req.h"
45 #include "ipc_req.h"
46 #include "ipc_set_credential_req.h"
47 #include "ipc_set_credential_rsp.h"
48 #include "ipc_set_useroperation_req.h"
49 #include "ipc_unauthenticate_device_req.h"
50 #include "ipc_unpublish_req.h"
51 #include "json_object.h"
52
53 namespace OHOS {
54 namespace DistributedHardware {
SetUp()55 void IpcCmdParserServiceTest::SetUp()
56 {
57 }
58
TearDown()59 void IpcCmdParserServiceTest::TearDown()
60 {
61 }
62
SetUpTestCase()63 void IpcCmdParserServiceTest::SetUpTestCase()
64 {
65 }
66
TearDownTestCase()67 void IpcCmdParserServiceTest::TearDownTestCase()
68 {
69 }
70
71 namespace {
GetIpcRequestFunc(int32_t cmdCode)72 SetIpcRequestFunc GetIpcRequestFunc(int32_t cmdCode)
73 {
74 SetIpcRequestFunc ptr = nullptr;
75 auto setRequestMapIter = IpcCmdRegister::GetInstance().setIpcRequestFuncMap_.find(cmdCode);
76 if (setRequestMapIter != IpcCmdRegister::GetInstance().setIpcRequestFuncMap_.end()) {
77 ptr = setRequestMapIter->second;
78 }
79 return ptr;
80 }
81
GetResponseFunc(int32_t cmdCode)82 ReadResponseFunc GetResponseFunc(int32_t cmdCode)
83 {
84 auto readResponseMapIter = IpcCmdRegister::GetInstance().readResponseFuncMap_.find(cmdCode);
85 if (readResponseMapIter == IpcCmdRegister::GetInstance().readResponseFuncMap_.end()) {
86 return nullptr;
87 }
88 return readResponseMapIter->second;
89 }
90
GetIpcCmdFunc(int32_t cmdCode)91 OnIpcCmdFunc GetIpcCmdFunc(int32_t cmdCode)
92 {
93 auto onIpcCmdMapIter = IpcCmdRegister::GetInstance().onIpcCmdFuncMap_.find(cmdCode);
94 if (onIpcCmdMapIter == IpcCmdRegister::GetInstance().onIpcCmdFuncMap_.end()) {
95 return nullptr;
96 }
97 return onIpcCmdMapIter->second;
98 }
99
TestIpcRequestFuncReqNull(int32_t cmdCode)100 int32_t TestIpcRequestFuncReqNull(int32_t cmdCode)
101 {
102 MessageParcel data;
103 std::shared_ptr<IpcReq> req = nullptr;
104 int ret = ERR_DM_UNSUPPORTED_IPC_COMMAND;
105 SetIpcRequestFunc ptr = GetIpcRequestFunc(cmdCode);
106 if (ptr) {
107 ret = ptr(req, data);
108 }
109 return ret;
110 }
111
TestReadResponseRspNull(int32_t cmdCode)112 int32_t TestReadResponseRspNull(int32_t cmdCode)
113 {
114 MessageParcel reply;
115 std::shared_ptr<IpcRsp> rsp = nullptr;
116 int ret = ERR_DM_UNSUPPORTED_IPC_COMMAND;
117 ReadResponseFunc ptr = GetResponseFunc(cmdCode);
118 if (ptr) {
119 ret = ptr(reply, rsp);
120 }
121 return ret;
122 }
123
TestReadResponseRspNotNull(int32_t cmdCode)124 int32_t TestReadResponseRspNotNull(int32_t cmdCode)
125 {
126 MessageParcel reply;
127 std::shared_ptr<IpcRsp> rsp = std::make_shared<IpcRsp>();
128 int32_t retCode = 0;
129 reply.WriteInt32(retCode);
130 int ret = ERR_DM_UNSUPPORTED_IPC_COMMAND;
131 ReadResponseFunc ptr = GetResponseFunc(cmdCode);
132 if (ptr) {
133 ret = ptr(reply, rsp);
134 }
135 return ret;
136 }
137
EncodePeerTargetId(const PeerTargetId & targetId,MessageParcel & parcel)138 bool EncodePeerTargetId(const PeerTargetId &targetId, MessageParcel &parcel)
139 {
140 bool bRet = true;
141 bRet = (bRet && parcel.WriteString(targetId.deviceId));
142 bRet = (bRet && parcel.WriteString(targetId.brMac));
143 bRet = (bRet && parcel.WriteString(targetId.bleMac));
144 bRet = (bRet && parcel.WriteString(targetId.wifiIp));
145 bRet = (bRet && parcel.WriteUint16(targetId.wifiPort));
146 return bRet;
147 }
148
149 HWTEST_F(IpcCmdParserServiceTest, SetIpcRequestFunc_001, testing::ext::TestSize.Level0)
150 {
151 int32_t cmdCode = SERVER_DEVICE_STATE_NOTIFY;
152 ASSERT_EQ(ERR_DM_FAILED, TestIpcRequestFuncReqNull(cmdCode));
153 }
154
155 HWTEST_F(IpcCmdParserServiceTest, ReadResponseFunc_001, testing::ext::TestSize.Level0)
156 {
157 int32_t cmdCode = SERVER_DEVICE_STATE_NOTIFY;
158 ASSERT_EQ(ERR_DM_FAILED, TestReadResponseRspNull(cmdCode));
159 }
160
161 HWTEST_F(IpcCmdParserServiceTest, ReadResponseFunc_002, testing::ext::TestSize.Level0)
162 {
163 int32_t cmdCode = SERVER_DEVICE_STATE_NOTIFY;
164 ASSERT_EQ(TestReadResponseRspNotNull(cmdCode), DM_OK);
165 }
166
167 HWTEST_F(IpcCmdParserServiceTest, SetIpcRequestFunc_002, testing::ext::TestSize.Level0)
168 {
169 int32_t cmdCode = SERVER_DEVICE_FOUND;
170 ASSERT_EQ(ERR_DM_FAILED, TestIpcRequestFuncReqNull(cmdCode));
171 }
172
173 HWTEST_F(IpcCmdParserServiceTest, ReadResponseFunc_003, testing::ext::TestSize.Level0)
174 {
175 int32_t cmdCode = SERVER_DEVICE_FOUND;
176 ASSERT_EQ(ERR_DM_FAILED, TestReadResponseRspNull(cmdCode));
177 }
178
179 HWTEST_F(IpcCmdParserServiceTest, ReadResponseFunc_004, testing::ext::TestSize.Level0)
180 {
181 int32_t cmdCode = SERVER_DEVICE_FOUND;
182 ASSERT_EQ(TestReadResponseRspNotNull(cmdCode), DM_OK);
183 }
184
185 HWTEST_F(IpcCmdParserServiceTest, SetIpcRequestFunc_003, testing::ext::TestSize.Level0)
186 {
187 int32_t cmdCode = SERVER_DEVICE_DISCOVERY;
188 ASSERT_EQ(ERR_DM_FAILED, TestIpcRequestFuncReqNull(cmdCode));
189 }
190
191 HWTEST_F(IpcCmdParserServiceTest, ReadResponseFunc_005, testing::ext::TestSize.Level0)
192 {
193 int32_t cmdCode = SERVER_DEVICE_DISCOVERY;
194 ASSERT_EQ(ERR_DM_FAILED, TestReadResponseRspNull(cmdCode));
195 }
196
197 HWTEST_F(IpcCmdParserServiceTest, ReadResponseFunc_006, testing::ext::TestSize.Level0)
198 {
199 int32_t cmdCode = SERVER_DEVICE_DISCOVERY;
200 ASSERT_EQ(TestReadResponseRspNotNull(cmdCode), DM_OK);
201 }
202
203 HWTEST_F(IpcCmdParserServiceTest, SetIpcRequestFunc_004, testing::ext::TestSize.Level0)
204 {
205 int32_t cmdCode = SERVER_DISCOVER_FINISH;
206 ASSERT_EQ(ERR_DM_FAILED, TestIpcRequestFuncReqNull(cmdCode));
207 }
208
209 HWTEST_F(IpcCmdParserServiceTest, ReadResponseFunc_007, testing::ext::TestSize.Level0)
210 {
211 int32_t cmdCode = SERVER_DISCOVER_FINISH;
212 ASSERT_EQ(ERR_DM_FAILED, TestReadResponseRspNull(cmdCode));
213 }
214
215 HWTEST_F(IpcCmdParserServiceTest, ReadResponseFunc_008, testing::ext::TestSize.Level0)
216 {
217 int32_t cmdCode = SERVER_DISCOVER_FINISH;
218 ASSERT_EQ(TestReadResponseRspNotNull(cmdCode), DM_OK);
219 }
220
221 HWTEST_F(IpcCmdParserServiceTest, SetIpcRequestFunc_005, testing::ext::TestSize.Level0)
222 {
223 int32_t cmdCode = SERVER_PUBLISH_FINISH;
224 ASSERT_EQ(ERR_DM_FAILED, TestIpcRequestFuncReqNull(cmdCode));
225 }
226
227 HWTEST_F(IpcCmdParserServiceTest, ReadResponseFunc_009, testing::ext::TestSize.Level0)
228 {
229 int32_t cmdCode = SERVER_PUBLISH_FINISH;
230 ASSERT_EQ(ERR_DM_FAILED, TestReadResponseRspNull(cmdCode));
231 }
232
233 HWTEST_F(IpcCmdParserServiceTest, ReadResponseFunc_010, testing::ext::TestSize.Level0)
234 {
235 int32_t cmdCode = SERVER_PUBLISH_FINISH;
236 ASSERT_EQ(TestReadResponseRspNotNull(cmdCode), DM_OK);
237 }
238
239 HWTEST_F(IpcCmdParserServiceTest, SetIpcRequestFunc_006, testing::ext::TestSize.Level0)
240 {
241 int32_t cmdCode = SERVER_AUTH_RESULT;
242 ASSERT_EQ(ERR_DM_FAILED, TestIpcRequestFuncReqNull(cmdCode));
243 }
244
245 HWTEST_F(IpcCmdParserServiceTest, ReadResponseFunc_011, testing::ext::TestSize.Level0)
246 {
247 int32_t cmdCode = SERVER_AUTH_RESULT;
248 ASSERT_EQ(ERR_DM_FAILED, TestReadResponseRspNull(cmdCode));
249 }
250
251 HWTEST_F(IpcCmdParserServiceTest, ReadResponseFunc_012, testing::ext::TestSize.Level0)
252 {
253 int32_t cmdCode = SERVER_AUTH_RESULT;
254 ASSERT_EQ(TestReadResponseRspNotNull(cmdCode), DM_OK);
255 }
256
257 HWTEST_F(IpcCmdParserServiceTest, SetIpcRequestFunc_007, testing::ext::TestSize.Level0)
258 {
259 int32_t cmdCode = SERVER_DEVICE_FA_NOTIFY;
260 ASSERT_EQ(ERR_DM_FAILED, TestIpcRequestFuncReqNull(cmdCode));
261 }
262
263 HWTEST_F(IpcCmdParserServiceTest, ReadResponseFunc_013, testing::ext::TestSize.Level0)
264 {
265 int32_t cmdCode = SERVER_DEVICE_FA_NOTIFY;
266 ASSERT_EQ(ERR_DM_FAILED, TestReadResponseRspNull(cmdCode));
267 }
268
269 HWTEST_F(IpcCmdParserServiceTest, ReadResponseFunc_014, testing::ext::TestSize.Level0)
270 {
271 int32_t cmdCode = SERVER_DEVICE_FA_NOTIFY;
272 ASSERT_EQ(TestReadResponseRspNotNull(cmdCode), DM_OK);
273 }
274
275 HWTEST_F(IpcCmdParserServiceTest, SetIpcRequestFunc_008, testing::ext::TestSize.Level0)
276 {
277 int32_t cmdCode = SERVER_CREDENTIAL_RESULT;
278 MessageParcel data;
279 std::shared_ptr<IpcNotifyCredentialReq> req = nullptr;
280 int ret = ERR_DM_FAILED;
281 SetIpcRequestFunc ptr = GetIpcRequestFunc(cmdCode);
282 if (ptr) {
283 ret = ptr(req, data);
284 }
285 ASSERT_EQ(ret, ERR_DM_FAILED);
286
287 req = std::make_shared<IpcNotifyCredentialReq>();
288 if (ptr) {
289 ret = ptr(req, data);
290 }
291 ASSERT_EQ(ret, DM_OK);
292 }
293
294 HWTEST_F(IpcCmdParserServiceTest, ReadResponseFunc_015, testing::ext::TestSize.Level0)
295 {
296 int32_t cmdCode = SERVER_CREDENTIAL_RESULT;
297 ASSERT_EQ(ERR_DM_FAILED, TestReadResponseRspNull(cmdCode));
298 }
299
300 HWTEST_F(IpcCmdParserServiceTest, ReadResponseFunc_016, testing::ext::TestSize.Level0)
301 {
302 int32_t cmdCode = SERVER_CREDENTIAL_RESULT;
303 ASSERT_EQ(TestReadResponseRspNotNull(cmdCode), DM_OK);
304 }
305
306 HWTEST_F(IpcCmdParserServiceTest, SetIpcRequestFunc_009, testing::ext::TestSize.Level0)
307 {
308 int32_t cmdCode = BIND_TARGET_RESULT;
309 ASSERT_EQ(ERR_DM_FAILED, TestIpcRequestFuncReqNull(cmdCode));
310 }
311
312 HWTEST_F(IpcCmdParserServiceTest, ReadResponseFunc_017, testing::ext::TestSize.Level0)
313 {
314 int32_t cmdCode = BIND_TARGET_RESULT;
315 ASSERT_EQ(ERR_DM_FAILED, TestReadResponseRspNull(cmdCode));
316 }
317
318 HWTEST_F(IpcCmdParserServiceTest, ReadResponseFunc_018, testing::ext::TestSize.Level0)
319 {
320 int32_t cmdCode = BIND_TARGET_RESULT;
321 ASSERT_EQ(TestReadResponseRspNotNull(cmdCode), DM_OK);
322 }
323
324 HWTEST_F(IpcCmdParserServiceTest, SetIpcRequestFunc_010, testing::ext::TestSize.Level0)
325 {
326 int32_t cmdCode = UNBIND_TARGET_RESULT;
327 ASSERT_EQ(ERR_DM_FAILED, TestIpcRequestFuncReqNull(cmdCode));
328 }
329
330 HWTEST_F(IpcCmdParserServiceTest, ReadResponseFunc_019, testing::ext::TestSize.Level0)
331 {
332 int32_t cmdCode = UNBIND_TARGET_RESULT;
333 ASSERT_EQ(ERR_DM_FAILED, TestReadResponseRspNull(cmdCode));
334 }
335
336 HWTEST_F(IpcCmdParserServiceTest, ReadResponseFunc_020, testing::ext::TestSize.Level0)
337 {
338 int32_t cmdCode = UNBIND_TARGET_RESULT;
339 ASSERT_EQ(TestReadResponseRspNotNull(cmdCode), DM_OK);
340 }
341
342 HWTEST_F(IpcCmdParserServiceTest, SetIpcRequestFunc_011, testing::ext::TestSize.Level0)
343 {
344 int32_t cmdCode = SERVER_CREATE_PIN_HOLDER;
345 MessageParcel data;
346 std::shared_ptr<IpcReq> req = nullptr;
347 int ret = ERR_DM_FAILED;
348 SetIpcRequestFunc ptr = GetIpcRequestFunc(cmdCode);
349 if (ptr) {
350 ret = ptr(req, data);
351 }
352 ASSERT_EQ(ret, ERR_DM_FAILED);
353
354 req = std::make_shared<IpcCreatePinHolderReq>();
355 std::string pkgName = "com.ohos.test";
356 req->SetPkgName(pkgName);
357 if (ptr) {
358 ret = ptr(req, data);
359 }
360 ASSERT_EQ(ret, DM_OK);
361 }
362
363 HWTEST_F(IpcCmdParserServiceTest, ReadResponseFunc_021, testing::ext::TestSize.Level0)
364 {
365 int32_t cmdCode = SERVER_CREATE_PIN_HOLDER;
366 ASSERT_EQ(ERR_DM_FAILED, TestReadResponseRspNull(cmdCode));
367 }
368
369 HWTEST_F(IpcCmdParserServiceTest, ReadResponseFunc_022, testing::ext::TestSize.Level0)
370 {
371 int32_t cmdCode = SERVER_CREATE_PIN_HOLDER;
372 ASSERT_EQ(TestReadResponseRspNotNull(cmdCode), DM_OK);
373 }
374
375 HWTEST_F(IpcCmdParserServiceTest, SetIpcRequestFunc_012, testing::ext::TestSize.Level0)
376 {
377 int32_t cmdCode = SERVER_DESTROY_PIN_HOLDER;
378 MessageParcel data;
379 std::shared_ptr<IpcReq> req = nullptr;
380 int ret = ERR_DM_FAILED;
381 SetIpcRequestFunc ptr = GetIpcRequestFunc(cmdCode);
382 if (ptr) {
383 ret = ptr(req, data);
384 }
385 ASSERT_EQ(ret, ERR_DM_FAILED);
386
387 req = std::make_shared<IpcDestroyPinHolderReq>();
388 std::string pkgName = "com.ohos.test";
389 req->SetPkgName(pkgName);
390 if (ptr) {
391 ret = ptr(req, data);
392 }
393 ASSERT_EQ(ret, DM_OK);
394 }
395
396 HWTEST_F(IpcCmdParserServiceTest, ReadResponseFunc_023, testing::ext::TestSize.Level0)
397 {
398 int32_t cmdCode = SERVER_DESTROY_PIN_HOLDER;
399 ASSERT_EQ(ERR_DM_FAILED, TestReadResponseRspNull(cmdCode));
400 }
401
402 HWTEST_F(IpcCmdParserServiceTest, ReadResponseFunc_024, testing::ext::TestSize.Level0)
403 {
404 int32_t cmdCode = SERVER_DESTROY_PIN_HOLDER;
405 ASSERT_EQ(TestReadResponseRspNotNull(cmdCode), DM_OK);
406 }
407
408 HWTEST_F(IpcCmdParserServiceTest, SetIpcRequestFunc_013, testing::ext::TestSize.Level0)
409 {
410 int32_t cmdCode = SERVER_CREATE_PIN_HOLDER_RESULT;
411 MessageParcel data;
412 std::shared_ptr<IpcReq> req = nullptr;
413 int ret = ERR_DM_FAILED;
414 SetIpcRequestFunc ptr = GetIpcRequestFunc(cmdCode);
415 if (ptr) {
416 ret = ptr(req, data);
417 }
418 ASSERT_EQ(ret, ERR_DM_FAILED);
419
420 req = std::make_shared<IpcNotifyPublishResultReq>();
421 std::string pkgName = "com.ohos.test";
422 req->SetPkgName(pkgName);
423 if (ptr) {
424 ret = ptr(req, data);
425 }
426 ASSERT_EQ(ret, DM_OK);
427 }
428
429 HWTEST_F(IpcCmdParserServiceTest, ReadResponseFunc_025, testing::ext::TestSize.Level0)
430 {
431 int32_t cmdCode = SERVER_CREATE_PIN_HOLDER_RESULT;
432 ASSERT_EQ(ERR_DM_FAILED, TestReadResponseRspNull(cmdCode));
433 }
434
435 HWTEST_F(IpcCmdParserServiceTest, ReadResponseFunc_026, testing::ext::TestSize.Level0)
436 {
437 int32_t cmdCode = SERVER_CREATE_PIN_HOLDER_RESULT;
438 ASSERT_EQ(TestReadResponseRspNotNull(cmdCode), DM_OK);
439 }
440
441 HWTEST_F(IpcCmdParserServiceTest, SetIpcRequestFunc_014, testing::ext::TestSize.Level0)
442 {
443 int32_t cmdCode = SERVER_DESTROY_PIN_HOLDER_RESULT;
444 MessageParcel data;
445 std::shared_ptr<IpcReq> req = nullptr;
446 int ret = ERR_DM_FAILED;
447 SetIpcRequestFunc ptr = GetIpcRequestFunc(cmdCode);
448 if (ptr) {
449 ret = ptr(req, data);
450 }
451 ASSERT_EQ(ret, ERR_DM_FAILED);
452
453 req = std::make_shared<IpcNotifyPublishResultReq>();
454 std::string pkgName = "com.ohos.test";
455 req->SetPkgName(pkgName);
456 if (ptr) {
457 ret = ptr(req, data);
458 }
459 ASSERT_EQ(ret, DM_OK);
460 }
461
462 HWTEST_F(IpcCmdParserServiceTest, ReadResponseFunc_027, testing::ext::TestSize.Level0)
463 {
464 int32_t cmdCode = SERVER_DESTROY_PIN_HOLDER_RESULT;
465 ASSERT_EQ(ERR_DM_FAILED, TestReadResponseRspNull(cmdCode));
466 }
467
468 HWTEST_F(IpcCmdParserServiceTest, ReadResponseFunc_028, testing::ext::TestSize.Level0)
469 {
470 int32_t cmdCode = SERVER_DESTROY_PIN_HOLDER_RESULT;
471 ASSERT_EQ(TestReadResponseRspNotNull(cmdCode), DM_OK);
472 }
473
474 HWTEST_F(IpcCmdParserServiceTest, OnIpcCmdFunc_001, testing::ext::TestSize.Level0)
475 {
476 int32_t cmdCode = BIND_DEVICE;
477 int32_t ret = ERR_DM_UNSUPPORTED_IPC_COMMAND;
478 MessageParcel data;
479 MessageParcel reply;
480 std::string pkgName = "ohos.dm.test";
481 std::string deviceId = "xxx";
482 data.WriteString(pkgName);
483 data.WriteString("");
484 data.WriteString(deviceId);
485 data.WriteInt32(1);
486 OnIpcCmdFunc ptr = GetIpcCmdFunc(cmdCode);
487 if (ptr) {
488 ret = ptr(data, reply);
489 }
490 ASSERT_EQ(ret, DM_OK);
491 }
492
493 HWTEST_F(IpcCmdParserServiceTest, OnIpcCmdFunc_002, testing::ext::TestSize.Level0)
494 {
495 int32_t cmdCode = UNBIND_DEVICE;
496 int32_t ret = ERR_DM_UNSUPPORTED_IPC_COMMAND;
497 MessageParcel data;
498 MessageParcel reply;
499 std::string pkgName = "ohos.dm.test";
500 std::string deviceId = "xxx";
501 data.WriteString(pkgName);
502 data.WriteString(deviceId);
503 OnIpcCmdFunc ptr = GetIpcCmdFunc(cmdCode);
504 if (ptr) {
505 ret = ptr(data, reply);
506 }
507 ASSERT_EQ(ret, DM_OK);
508 }
509
510 HWTEST_F(IpcCmdParserServiceTest, OnIpcCmdFunc_003, testing::ext::TestSize.Level0)
511 {
512 int32_t cmdCode = GET_NETWORKTYPE_BY_NETWORK;
513 int32_t ret = ERR_DM_UNSUPPORTED_IPC_COMMAND;
514 MessageParcel data;
515 MessageParcel reply;
516 std::string pkgName = "ohos.dm.test";
517 std::string networkId = "xxx";
518 data.WriteString(pkgName);
519 data.WriteString(networkId);
520 OnIpcCmdFunc ptr = GetIpcCmdFunc(cmdCode);
521 if (ptr) {
522 ret = ptr(data, reply);
523 }
524 ASSERT_EQ(ret, DM_OK);
525 }
526
527 HWTEST_F(IpcCmdParserServiceTest, OnIpcCmdFunc_004, testing::ext::TestSize.Level0)
528 {
529 int32_t cmdCode = REGISTER_UI_STATE_CALLBACK;
530 int32_t ret = ERR_DM_UNSUPPORTED_IPC_COMMAND;
531 MessageParcel data;
532 MessageParcel reply;
533 std::string pkgName = "ohos.dm.test";
534 data.WriteString(pkgName);
535 OnIpcCmdFunc ptr = GetIpcCmdFunc(cmdCode);
536 if (ptr) {
537 ret = ptr(data, reply);
538 }
539 ASSERT_EQ(ret, DM_OK);
540 }
541
542 HWTEST_F(IpcCmdParserServiceTest, OnIpcCmdFunc_005, testing::ext::TestSize.Level0)
543 {
544 int32_t cmdCode = UNREGISTER_UI_STATE_CALLBACK;
545 int32_t ret = ERR_DM_UNSUPPORTED_IPC_COMMAND;
546 MessageParcel data;
547 MessageParcel reply;
548 std::string pkgName = "ohos.dm.test";
549 data.WriteString(pkgName);
550 OnIpcCmdFunc ptr = GetIpcCmdFunc(cmdCode);
551 if (ptr) {
552 ret = ptr(data, reply);
553 }
554 ASSERT_EQ(ret, DM_OK);
555 }
556
557 HWTEST_F(IpcCmdParserServiceTest, OnIpcCmdFunc_006, testing::ext::TestSize.Level0)
558 {
559 int32_t cmdCode = IMPORT_AUTH_CODE;
560 int32_t ret = ERR_DM_UNSUPPORTED_IPC_COMMAND;
561 MessageParcel data;
562 MessageParcel reply;
563 std::string pkgName = "ohos.dm.test";
564 std::string authCode = "123456";
565 data.WriteString(pkgName);
566 data.WriteString(authCode);
567 OnIpcCmdFunc ptr = GetIpcCmdFunc(cmdCode);
568 if (ptr) {
569 ret = ptr(data, reply);
570 }
571 ASSERT_EQ(ret, DM_OK);
572 }
573
574 HWTEST_F(IpcCmdParserServiceTest, OnIpcCmdFunc_007, testing::ext::TestSize.Level0)
575 {
576 int32_t cmdCode = EXPORT_AUTH_CODE;
577 int32_t ret = ERR_DM_UNSUPPORTED_IPC_COMMAND;
578 MessageParcel data;
579 MessageParcel reply;
580 std::string pkgName = "ohos.dm.test";
581 data.WriteString(pkgName);
582 OnIpcCmdFunc ptr = GetIpcCmdFunc(cmdCode);
583 if (ptr) {
584 ret = ptr(data, reply);
585 }
586 ASSERT_EQ(ret, DM_OK);
587 }
588
589 HWTEST_F(IpcCmdParserServiceTest, OnIpcCmdFunc_008, testing::ext::TestSize.Level0)
590 {
591 int32_t cmdCode = REGISTER_DISCOVERY_CALLBACK;
592 int32_t ret = ERR_DM_UNSUPPORTED_IPC_COMMAND;
593 MessageParcel data;
594 MessageParcel reply;
595 std::string pkgName = "ohos.dm.test";
596 std::string param = "xxx";
597 data.WriteString(pkgName);
598 data.WriteString(param);
599 data.WriteString(param);
600 OnIpcCmdFunc ptr = GetIpcCmdFunc(cmdCode);
601 if (ptr) {
602 ret = ptr(data, reply);
603 }
604 ASSERT_EQ(ret, DM_OK);
605 }
606
607 HWTEST_F(IpcCmdParserServiceTest, OnIpcCmdFunc_009, testing::ext::TestSize.Level0)
608 {
609 int32_t cmdCode = UNREGISTER_DISCOVERY_CALLBACK;
610 int32_t ret = ERR_DM_UNSUPPORTED_IPC_COMMAND;
611 MessageParcel data;
612 MessageParcel reply;
613 std::string pkgName = "ohos.dm.test";
614 std::string param = "xxx";
615 data.WriteString(pkgName);
616 data.WriteString(param);
617 OnIpcCmdFunc ptr = GetIpcCmdFunc(cmdCode);
618 if (ptr) {
619 ret = ptr(data, reply);
620 }
621 ASSERT_EQ(ret, DM_OK);
622 }
623
624 HWTEST_F(IpcCmdParserServiceTest, OnIpcCmdFunc_010, testing::ext::TestSize.Level0)
625 {
626 int32_t cmdCode = START_DISCOVERING;
627 int32_t ret = ERR_DM_UNSUPPORTED_IPC_COMMAND;
628 MessageParcel data;
629 MessageParcel reply;
630 std::string pkgName = "ohos.dm.test";
631 std::string param = "xxx";
632 data.WriteString(pkgName);
633 data.WriteString(param);
634 data.WriteString(param);
635 OnIpcCmdFunc ptr = GetIpcCmdFunc(cmdCode);
636 if (ptr) {
637 ret = ptr(data, reply);
638 }
639 ASSERT_EQ(ret, DM_OK);
640 }
641
642 HWTEST_F(IpcCmdParserServiceTest, OnIpcCmdFunc_011, testing::ext::TestSize.Level0)
643 {
644 int32_t cmdCode = STOP_DISCOVERING;
645 int32_t ret = ERR_DM_UNSUPPORTED_IPC_COMMAND;
646 MessageParcel data;
647 MessageParcel reply;
648 std::string pkgName = "ohos.dm.test";
649 std::string param = "xxx";
650 data.WriteString(pkgName);
651 data.WriteString(param);
652 OnIpcCmdFunc ptr = GetIpcCmdFunc(cmdCode);
653 if (ptr) {
654 ret = ptr(data, reply);
655 }
656 ASSERT_EQ(ret, DM_OK);
657 }
658
659 HWTEST_F(IpcCmdParserServiceTest, OnIpcCmdFunc_012, testing::ext::TestSize.Level0)
660 {
661 int32_t cmdCode = START_ADVERTISING;
662 int32_t ret = ERR_DM_UNSUPPORTED_IPC_COMMAND;
663 MessageParcel data;
664 MessageParcel reply;
665 std::string pkgName = "ohos.dm.test";
666 std::string param = "xxx";
667 data.WriteString(pkgName);
668 data.WriteString(param);
669 OnIpcCmdFunc ptr = GetIpcCmdFunc(cmdCode);
670 if (ptr) {
671 ret = ptr(data, reply);
672 }
673 ASSERT_EQ(ret, DM_OK);
674 }
675
676 HWTEST_F(IpcCmdParserServiceTest, OnIpcCmdFunc_013, testing::ext::TestSize.Level0)
677 {
678 int32_t cmdCode = STOP_ADVERTISING;
679 int32_t ret = ERR_DM_UNSUPPORTED_IPC_COMMAND;
680 MessageParcel data;
681 MessageParcel reply;
682 std::string pkgName = "ohos.dm.test";
683 std::string param = "xxx";
684 data.WriteString(pkgName);
685 data.WriteString(param);
686 OnIpcCmdFunc ptr = GetIpcCmdFunc(cmdCode);
687 if (ptr) {
688 ret = ptr(data, reply);
689 }
690 ASSERT_EQ(ret, DM_OK);
691 }
692
693 HWTEST_F(IpcCmdParserServiceTest, OnIpcCmdFunc_014, testing::ext::TestSize.Level0)
694 {
695 int32_t cmdCode = BIND_TARGET;
696 int32_t ret = ERR_DM_UNSUPPORTED_IPC_COMMAND;
697 MessageParcel data;
698 MessageParcel reply;
699 std::string pkgName = "ohos.dm.test";
700 std::string param = "xxx";
701 data.WriteString(pkgName);
702 PeerTargetId targetId;
703 EncodePeerTargetId(targetId, data);
704 data.WriteString(param);
705 OnIpcCmdFunc ptr = GetIpcCmdFunc(cmdCode);
706 if (ptr) {
707 ret = ptr(data, reply);
708 }
709 ASSERT_EQ(ret, DM_OK);
710 }
711
712 HWTEST_F(IpcCmdParserServiceTest, OnIpcCmdFunc_015, testing::ext::TestSize.Level0)
713 {
714 int32_t cmdCode = UNBIND_TARGET;
715 int32_t ret = ERR_DM_UNSUPPORTED_IPC_COMMAND;
716 MessageParcel data;
717 MessageParcel reply;
718 std::string pkgName = "ohos.dm.test";
719 std::string param = "xxx";
720 data.WriteString(pkgName);
721 PeerTargetId targetId;
722 EncodePeerTargetId(targetId, data);
723 data.WriteString(param);
724 OnIpcCmdFunc ptr = GetIpcCmdFunc(cmdCode);
725 if (ptr) {
726 ret = ptr(data, reply);
727 }
728 ASSERT_EQ(ret, DM_OK);
729 }
730
731 HWTEST_F(IpcCmdParserServiceTest, OnIpcCmdFunc_016, testing::ext::TestSize.Level0)
732 {
733 int32_t cmdCode = REGISTER_PIN_HOLDER_CALLBACK;
734 int32_t ret = ERR_DM_UNSUPPORTED_IPC_COMMAND;
735 MessageParcel data;
736 MessageParcel reply;
737 std::string pkgName = "ohos.dm.test";
738 data.WriteString(pkgName);
739 OnIpcCmdFunc ptr = GetIpcCmdFunc(cmdCode);
740 if (ptr) {
741 ret = ptr(data, reply);
742 }
743 ASSERT_EQ(ret, DM_OK);
744 }
745
746 HWTEST_F(IpcCmdParserServiceTest, OnIpcCmdFunc_017, testing::ext::TestSize.Level0)
747 {
748 int32_t cmdCode = CREATE_PIN_HOLDER;
749 int32_t ret = ERR_DM_UNSUPPORTED_IPC_COMMAND;
750 MessageParcel data;
751 MessageParcel reply;
752 std::string pkgName = "ohos.dm.test";
753 data.WriteString(pkgName);
754 PeerTargetId targetId;
755 EncodePeerTargetId(targetId, data);
756 std::string param = "xxx";
757 data.WriteString(param);
758 data.WriteInt32(1);
759 OnIpcCmdFunc ptr = GetIpcCmdFunc(cmdCode);
760 if (ptr) {
761 ret = ptr(data, reply);
762 }
763 ASSERT_EQ(ret, DM_OK);
764 }
765
766 HWTEST_F(IpcCmdParserServiceTest, OnIpcCmdFunc_018, testing::ext::TestSize.Level0)
767 {
768 int32_t cmdCode = DESTROY_PIN_HOLDER;
769 int32_t ret = ERR_DM_UNSUPPORTED_IPC_COMMAND;
770 MessageParcel data;
771 MessageParcel reply;
772 std::string pkgName = "ohos.dm.test";
773 data.WriteString(pkgName);
774 PeerTargetId targetId;
775 EncodePeerTargetId(targetId, data);
776 std::string param = "xxx";
777 data.WriteString(param);
778 data.WriteString(param);
779 OnIpcCmdFunc ptr = GetIpcCmdFunc(cmdCode);
780 if (ptr) {
781 ret = ptr(data, reply);
782 }
783 ASSERT_EQ(ret, DM_OK);
784 }
785
786 HWTEST_F(IpcCmdParserServiceTest, OnIpcCmdFunc_019, testing::ext::TestSize.Level0)
787 {
788 int32_t cmdCode = DP_ACL_ADD;
789 int32_t ret = ERR_DM_UNSUPPORTED_IPC_COMMAND;
790 MessageParcel data;
791 MessageParcel reply;
792 std::string pkgName = "ohos.dm.test";
793 data.WriteString(pkgName);
794 OnIpcCmdFunc ptr = GetIpcCmdFunc(cmdCode);
795 if (ptr) {
796 ret = ptr(data, reply);
797 }
798 ASSERT_EQ(ret, DM_OK);
799 }
800
801 HWTEST_F(IpcCmdParserServiceTest, OnIpcCmdFunc_020, testing::ext::TestSize.Level0)
802 {
803 int32_t cmdCode = GET_SECURITY_LEVEL;
804 int32_t ret = ERR_DM_UNSUPPORTED_IPC_COMMAND;
805 MessageParcel data;
806 MessageParcel reply;
807 std::string pkgName = "ohos.dm.test";
808 std::string networkId = "xxx";
809 data.WriteString(pkgName);
810 data.WriteString(networkId);
811 OnIpcCmdFunc ptr = GetIpcCmdFunc(cmdCode);
812 if (ptr) {
813 ret = ptr(data, reply);
814 }
815 ASSERT_EQ(ret, DM_OK);
816 }
817
818 HWTEST_F(IpcCmdParserServiceTest, OnIpcCmdFunc_021, testing::ext::TestSize.Level0)
819 {
820 int32_t cmdCode = IS_SAME_ACCOUNT;
821 int32_t ret = ERR_DM_UNSUPPORTED_IPC_COMMAND;
822 MessageParcel data;
823 MessageParcel reply;
824 std::string udid = "xxx";
825 data.WriteString(udid);
826 OnIpcCmdFunc ptr = GetIpcCmdFunc(cmdCode);
827 if (ptr) {
828 ret = ptr(data, reply);
829 }
830 ASSERT_EQ(ret, DM_OK);
831 }
832
833 HWTEST_F(IpcCmdParserServiceTest, OnIpcCmdFunc_022, testing::ext::TestSize.Level0)
834 {
835 int32_t cmdCode = CHECK_API_PERMISSION;
836 int32_t ret = ERR_DM_UNSUPPORTED_IPC_COMMAND;
837 MessageParcel data;
838 MessageParcel reply;
839 data.WriteInt32(1);
840 OnIpcCmdFunc ptr = GetIpcCmdFunc(cmdCode);
841 if (ptr) {
842 ret = ptr(data, reply);
843 }
844 ASSERT_EQ(ret, DM_OK);
845 }
846
847 HWTEST_F(IpcCmdParserServiceTest, OnIpcCmdFunc_023, testing::ext::TestSize.Level0)
848 {
849 int32_t cmdCode = GET_TRUST_DEVICE_LIST;
850 int32_t ret = ERR_DM_UNSUPPORTED_IPC_COMMAND;
851 MessageParcel data;
852 MessageParcel reply;
853 std::string pkgName = "ohos.dm.test";
854 std::string extra = "";
855 bool isRefresh = true;
856 data.WriteString(pkgName);
857 data.WriteString(extra);
858 data.WriteBool(isRefresh);
859 OnIpcCmdFunc ptr = GetIpcCmdFunc(cmdCode);
860 if (ptr) {
861 ret = ptr(data, reply);
862 }
863 ASSERT_EQ(ret, DM_OK);
864 }
865
866 HWTEST_F(IpcCmdParserServiceTest, OnIpcCmdFunc_025, testing::ext::TestSize.Level0)
867 {
868 int32_t cmdCode = REGISTER_DEVICE_MANAGER_LISTENER;
869 int32_t ret = ERR_DM_UNSUPPORTED_IPC_COMMAND;
870 MessageParcel data;
871 MessageParcel reply;
872 std::string pkgName = "pkgName";
873 data.WriteString(pkgName);
874 OnIpcCmdFunc ptr = GetIpcCmdFunc(cmdCode);
875 if (ptr) {
876 ret = ptr(data, reply);
877 }
878 ASSERT_EQ(ret, ERR_DM_POINT_NULL);
879
880 data.WriteString(pkgName);
881 sptr<IRemoteObject> remoteObject = nullptr;
882 data.WriteRemoteObject(remoteObject);
883
884 if (ptr) {
885 ret = ptr(data, reply);
886 }
887 ASSERT_EQ(ret, ERR_DM_POINT_NULL);
888
889 data.WriteString(pkgName);
890 remoteObject = sptr<IpcClientStub>(new IpcClientStub());
891 data.WriteRemoteObject(remoteObject);
892
893 if (ptr) {
894 ret = ptr(data, reply);
895 }
896 ASSERT_EQ(ret, DM_OK);
897 }
898
899 HWTEST_F(IpcCmdParserServiceTest, OnIpcCmdFunc_026, testing::ext::TestSize.Level0)
900 {
901 int32_t cmdCode = UNREGISTER_DEVICE_MANAGER_LISTENER;
902 int32_t ret = ERR_DM_UNSUPPORTED_IPC_COMMAND;
903 MessageParcel data;
904 MessageParcel reply;
905 std::string pkgName = "ohos.dm.test";
906 data.WriteString(pkgName);
907 OnIpcCmdFunc ptr = GetIpcCmdFunc(cmdCode);
908 if (ptr) {
909 ret = ptr(data, reply);
910 }
911 ASSERT_EQ(ret, DM_OK);
912 }
913
914 HWTEST_F(IpcCmdParserServiceTest, OnIpcCmdFunc_030, testing::ext::TestSize.Level0)
915 {
916 int32_t cmdCode = PUBLISH_DEVICE_DISCOVER;
917 int32_t ret = ERR_DM_UNSUPPORTED_IPC_COMMAND;
918 MessageParcel data;
919 MessageParcel reply;
920 std::string pkgName = "ohos.dm.test";
921 DmPublishInfo dmPublishInfo;
922 dmPublishInfo.publishId = 1000;
923 data.WriteString(pkgName);
924 data.WriteRawData(&dmPublishInfo, sizeof(DmPublishInfo));
925 OnIpcCmdFunc ptr = GetIpcCmdFunc(cmdCode);
926 if (ptr) {
927 ret = ptr(data, reply);
928 }
929 ASSERT_EQ(ret, DM_OK);
930 }
931
932 HWTEST_F(IpcCmdParserServiceTest, OnIpcCmdFunc_031, testing::ext::TestSize.Level0)
933 {
934 int32_t cmdCode = UNPUBLISH_DEVICE_DISCOVER;
935 int32_t ret = ERR_DM_UNSUPPORTED_IPC_COMMAND;
936 MessageParcel data;
937 MessageParcel reply;
938 std::string pkgName = "ohos.dm.test";
939 int32_t publishId = 1000;
940 data.WriteString(pkgName);
941 data.WriteInt32(publishId);
942 OnIpcCmdFunc ptr = GetIpcCmdFunc(cmdCode);
943 if (ptr) {
944 ret = ptr(data, reply);
945 }
946 ASSERT_EQ(ret, DM_OK);
947 }
948
949 HWTEST_F(IpcCmdParserServiceTest, OnIpcCmdFunc_032, testing::ext::TestSize.Level0)
950 {
951 int32_t cmdCode = AUTHENTICATE_DEVICE;
952 int32_t ret = ERR_DM_UNSUPPORTED_IPC_COMMAND;
953 MessageParcel data;
954 MessageParcel reply;
955 std::string pkgName = "ohos.dm.test";
956 std::string extra = "";
957 int32_t authType = 1;
958 DmDeviceInfo deviceInfo;
959 std::string deviceId = "12345678";
960 data.WriteString(pkgName);
961 data.WriteString(extra);
962 data.WriteString(deviceId);
963 data.WriteInt32(authType);
964 OnIpcCmdFunc ptr = GetIpcCmdFunc(cmdCode);
965 if (ptr) {
966 ret = ptr(data, reply);
967 }
968 ASSERT_EQ(ret, DM_OK);
969 }
970
971 HWTEST_F(IpcCmdParserServiceTest, OnIpcCmdFunc_033, testing::ext::TestSize.Level0)
972 {
973 int32_t cmdCode = UNAUTHENTICATE_DEVICE;
974 int32_t ret = ERR_DM_UNSUPPORTED_IPC_COMMAND;
975 MessageParcel data;
976 MessageParcel reply;
977 std::string pkgName = "ohos.dm.test";
978 std::string networkId = "12345678";
979 data.WriteString(pkgName);
980 data.WriteString(networkId);
981 OnIpcCmdFunc ptr = GetIpcCmdFunc(cmdCode);
982 if (ptr) {
983 ret = ptr(data, reply);
984 }
985 ASSERT_EQ(ret, DM_OK);
986 }
987
988 HWTEST_F(IpcCmdParserServiceTest, OnIpcCmdFunc_034, testing::ext::TestSize.Level0)
989 {
990 int32_t cmdCode = GET_DEVICE_INFO;
991 int32_t ret = ERR_DM_UNSUPPORTED_IPC_COMMAND;
992 MessageParcel data;
993 MessageParcel reply;
994 std::string pkgName = "ohos.dm.test";
995 std::string networkId = "12345678";
996 data.WriteString(pkgName);
997 data.WriteString(networkId);
998 OnIpcCmdFunc ptr = GetIpcCmdFunc(cmdCode);
999 if (ptr) {
1000 ret = ptr(data, reply);
1001 }
1002 ASSERT_EQ(ret, DM_OK);
1003 }
1004
1005 HWTEST_F(IpcCmdParserServiceTest, OnIpcCmdFunc_035, testing::ext::TestSize.Level0)
1006 {
1007 int32_t cmdCode = GET_LOCAL_DEVICE_INFO;
1008 int32_t ret = ERR_DM_UNSUPPORTED_IPC_COMMAND;
1009 MessageParcel data;
1010 MessageParcel reply;
1011 std::string pkgName = "ohos.dm.test";
1012 data.WriteString(pkgName);
1013 OnIpcCmdFunc ptr = GetIpcCmdFunc(cmdCode);
1014 if (ptr) {
1015 ret = ptr(data, reply);
1016 }
1017 ASSERT_EQ(ret, DM_OK);
1018 }
1019
1020 HWTEST_F(IpcCmdParserServiceTest, OnIpcCmdFunc_040, testing::ext::TestSize.Level0)
1021 {
1022 int32_t cmdCode = GET_UDID_BY_NETWORK;
1023 int32_t ret = ERR_DM_UNSUPPORTED_IPC_COMMAND;
1024 MessageParcel data;
1025 MessageParcel reply;
1026 std::string pkgName = "ohos.dm.test";
1027 std::string netWorkId = "12345678";
1028 data.WriteString(pkgName);
1029 data.WriteString(netWorkId);
1030 OnIpcCmdFunc ptr = GetIpcCmdFunc(cmdCode);
1031 if (ptr) {
1032 ret = ptr(data, reply);
1033 }
1034 ASSERT_EQ(ret, DM_OK);
1035 }
1036
1037 HWTEST_F(IpcCmdParserServiceTest, OnIpcCmdFunc_041, testing::ext::TestSize.Level0)
1038 {
1039 int32_t cmdCode = GET_UUID_BY_NETWORK;
1040 int32_t ret = ERR_DM_UNSUPPORTED_IPC_COMMAND;
1041 MessageParcel data;
1042 MessageParcel reply;
1043 std::string pkgName = "ohos.dm.test";
1044 std::string netWorkId = "12345678";
1045 data.WriteString(pkgName);
1046 data.WriteString(netWorkId);
1047 OnIpcCmdFunc ptr = GetIpcCmdFunc(cmdCode);
1048 if (ptr) {
1049 ret = ptr(data, reply);
1050 }
1051 ASSERT_EQ(ret, DM_OK);
1052 }
1053
1054 HWTEST_F(IpcCmdParserServiceTest, OnIpcCmdFunc_042, testing::ext::TestSize.Level0)
1055 {
1056 int32_t cmdCode = SERVER_USER_AUTH_OPERATION;
1057 int32_t ret = ERR_DM_UNSUPPORTED_IPC_COMMAND;
1058 MessageParcel data;
1059 MessageParcel reply;
1060 std::string pkgName = "ohos.dm.test";
1061 int32_t action = 1;
1062 std::string params = "";
1063 data.WriteString(pkgName);
1064 data.WriteInt32(action);
1065 data.WriteString(params);
1066 OnIpcCmdFunc ptr = GetIpcCmdFunc(cmdCode);
1067 if (ptr) {
1068 ret = ptr(data, reply);
1069 }
1070 ASSERT_EQ(ret, ERR_DM_INPUT_PARA_INVALID);
1071 }
1072
1073 HWTEST_F(IpcCmdParserServiceTest, OnIpcCmdFunc_043, testing::ext::TestSize.Level0)
1074 {
1075 int32_t cmdCode = REQUEST_CREDENTIAL;
1076 int32_t ret = ERR_DM_UNSUPPORTED_IPC_COMMAND;
1077 MessageParcel data;
1078 MessageParcel reply;
1079 std::string pkgName = "ohos.dm.test";
1080 std::string requestJsonStr = "";
1081 data.WriteString(pkgName);
1082 data.WriteString(requestJsonStr);
1083 OnIpcCmdFunc ptr = GetIpcCmdFunc(cmdCode);
1084 if (ptr) {
1085 ret = ptr(data, reply);
1086 }
1087 ASSERT_EQ(ret, DM_OK);
1088 }
1089
1090 HWTEST_F(IpcCmdParserServiceTest, OnIpcCmdFunc_044, testing::ext::TestSize.Level0)
1091 {
1092 int32_t cmdCode = IMPORT_CREDENTIAL;
1093 int32_t ret = ERR_DM_UNSUPPORTED_IPC_COMMAND;
1094 MessageParcel data;
1095 MessageParcel reply;
1096 std::string pkgName = "ohos.dm.test";
1097 std::string credentialInfo = "";
1098 data.WriteString(pkgName);
1099 data.WriteString(credentialInfo);
1100 OnIpcCmdFunc ptr = GetIpcCmdFunc(cmdCode);
1101 if (ptr) {
1102 ret = ptr(data, reply);
1103 }
1104 ASSERT_EQ(ret, DM_OK);
1105 }
1106
1107 HWTEST_F(IpcCmdParserServiceTest, OnIpcCmdFunc_045, testing::ext::TestSize.Level0)
1108 {
1109 int32_t cmdCode = DELETE_CREDENTIAL;
1110 int32_t ret = ERR_DM_UNSUPPORTED_IPC_COMMAND;
1111 MessageParcel data;
1112 MessageParcel reply;
1113 std::string pkgName = "ohos.dm.test";
1114 std::string deleteInfo = "";
1115 data.WriteString(pkgName);
1116 data.WriteString(deleteInfo);
1117 OnIpcCmdFunc ptr = GetIpcCmdFunc(cmdCode);
1118 if (ptr) {
1119 ret = ptr(data, reply);
1120 }
1121 ASSERT_EQ(ret, DM_OK);
1122 }
1123
1124 HWTEST_F(IpcCmdParserServiceTest, OnIpcCmdFunc_046, testing::ext::TestSize.Level0)
1125 {
1126 int32_t cmdCode = SERVER_GET_DMFA_INFO;
1127 int32_t ret = ERR_DM_UNSUPPORTED_IPC_COMMAND;
1128 MessageParcel data;
1129 MessageParcel reply;
1130 std::string pkgName = "ohos.dm.test";
1131 std::string reqJsonStr = "";
1132 data.WriteString(pkgName);
1133 data.WriteString(reqJsonStr);
1134 OnIpcCmdFunc ptr = GetIpcCmdFunc(cmdCode);
1135 if (ptr) {
1136 ret = ptr(data, reply);
1137 }
1138 ASSERT_EQ(ret, DM_OK);
1139 }
1140
1141 HWTEST_F(IpcCmdParserServiceTest, OnIpcCmdFunc_047, testing::ext::TestSize.Level0)
1142 {
1143 int32_t cmdCode = SERVER_GET_DMFA_INFO;
1144 int32_t ret = ERR_DM_UNSUPPORTED_IPC_COMMAND;
1145 MessageParcel data;
1146 MessageParcel reply;
1147 std::string pkgName = "ohos.dm.test";
1148 std::string reqJsonStr = "";
1149 data.WriteString(pkgName);
1150 data.WriteString(reqJsonStr);
1151 OnIpcCmdFunc ptr = GetIpcCmdFunc(cmdCode);
1152 if (ptr) {
1153 ret = ptr(data, reply);
1154 }
1155 ASSERT_EQ(ret, DM_OK);
1156 }
1157
1158 HWTEST_F(IpcCmdParserServiceTest, OnIpcCmdFunc_048, testing::ext::TestSize.Level0)
1159 {
1160 int32_t cmdCode = REGISTER_CREDENTIAL_CALLBACK;
1161 int32_t ret = ERR_DM_UNSUPPORTED_IPC_COMMAND;
1162 MessageParcel data;
1163 MessageParcel reply;
1164 std::string pkgName = "ohos.dm.test";
1165 data.WriteString(pkgName);
1166 OnIpcCmdFunc ptr = GetIpcCmdFunc(cmdCode);
1167 if (ptr) {
1168 ret = ptr(data, reply);
1169 }
1170 ASSERT_EQ(ret, DM_OK);
1171 }
1172
1173 HWTEST_F(IpcCmdParserServiceTest, OnIpcCmdFunc_049, testing::ext::TestSize.Level0)
1174 {
1175 int32_t cmdCode = UNREGISTER_CREDENTIAL_CALLBACK;
1176 int32_t ret = ERR_DM_UNSUPPORTED_IPC_COMMAND;
1177 MessageParcel data;
1178 MessageParcel reply;
1179 std::string pkgName = "ohos.dm.test";
1180 data.WriteString(pkgName);
1181 OnIpcCmdFunc ptr = GetIpcCmdFunc(cmdCode);
1182 if (ptr) {
1183 ret = ptr(data, reply);
1184 }
1185 ASSERT_EQ(ret, DM_OK);
1186 }
1187
1188 HWTEST_F(IpcCmdParserServiceTest, OnIpcCmdFunc_050, testing::ext::TestSize.Level0)
1189 {
1190 int32_t cmdCode = NOTIFY_EVENT;
1191 int32_t ret = ERR_DM_UNSUPPORTED_IPC_COMMAND;
1192 MessageParcel data;
1193 MessageParcel reply;
1194 std::string pkgName = "ohos.dm.test";
1195 int32_t eventId = 1;
1196 std::string event = "";
1197 data.WriteString(pkgName);
1198 data.WriteInt32(eventId);
1199 data.WriteString(event);
1200 OnIpcCmdFunc ptr = GetIpcCmdFunc(cmdCode);
1201 if (ptr) {
1202 ret = ptr(data, reply);
1203 }
1204 ASSERT_EQ(ret, DM_OK);
1205 }
1206
1207 HWTEST_F(IpcCmdParserServiceTest, OnIpcCmdFunc_051, testing::ext::TestSize.Level0)
1208 {
1209 int32_t cmdCode = GET_ENCRYPTED_UUID_BY_NETWOEKID;
1210 int32_t ret = ERR_DM_UNSUPPORTED_IPC_COMMAND;
1211 MessageParcel data;
1212 MessageParcel reply;
1213 std::string pkgName = "ohos.dm.test";
1214 std::string netWorkId = "123456789";
1215 data.WriteString(pkgName);
1216 data.WriteString(netWorkId);
1217 OnIpcCmdFunc ptr = GetIpcCmdFunc(cmdCode);
1218 if (ptr) {
1219 ret = ptr(data, reply);
1220 }
1221 ASSERT_EQ(ret, DM_OK);
1222 }
1223
1224 HWTEST_F(IpcCmdParserServiceTest, OnIpcCmdFunc_052, testing::ext::TestSize.Level0)
1225 {
1226 int32_t cmdCode = GENERATE_ENCRYPTED_UUID;
1227 int32_t ret = ERR_DM_UNSUPPORTED_IPC_COMMAND;
1228 MessageParcel data;
1229 MessageParcel reply;
1230 std::string pkgName = "ohos.dm.test";
1231 std::string uuid = "123456789";
1232 std::string appId = "1234";
1233 data.WriteString(pkgName);
1234 data.WriteString(uuid);
1235 data.WriteString(appId);
1236 OnIpcCmdFunc ptr = GetIpcCmdFunc(cmdCode);
1237 if (ptr) {
1238 ret = ptr(data, reply);
1239 }
1240 ASSERT_EQ(ret, DM_OK);
1241 }
1242
1243 HWTEST_F(IpcCmdParserServiceTest, OnIpcCmdFunc_053, testing::ext::TestSize.Level0)
1244 {
1245 int32_t cmdCode = IMPORT_CREDENTIAL;
1246 int32_t ret = DM_OK;
1247 MessageParcel data;
1248 MessageParcel reply;
1249 std::string pkgName = "ohos.dm.test";
1250 JsonObject jsonObject;
1251 jsonObject[DM_CREDENTIAL_TYPE] = DM_TYPE_OH;
1252 jsonObject[DM_CREDENTIAL_REQJSONSTR] = "";
1253 std::string credentialInfo = SafetyDump(jsonObject);
1254 data.WriteString(pkgName);
1255 data.WriteString(credentialInfo);
1256 OnIpcCmdFunc ptr = GetIpcCmdFunc(cmdCode);
1257 if (ptr) {
1258 ret = ptr(data, reply);
1259 }
1260 ASSERT_EQ(ret, DM_OK);
1261
1262 cmdCode = DELETE_CREDENTIAL;
1263 data.WriteString(pkgName);
1264 data.WriteString(credentialInfo);
1265 OnIpcCmdFunc ptr1 = GetIpcCmdFunc(cmdCode);
1266 if (ptr1) {
1267 ret = ptr1(data, reply);
1268 }
1269 ASSERT_EQ(ret, DM_OK);
1270
1271 cmdCode = REQUEST_CREDENTIAL;
1272 data.WriteString(pkgName);
1273 data.WriteString(credentialInfo);
1274 OnIpcCmdFunc ptr2 = GetIpcCmdFunc(cmdCode);
1275 if (ptr2) {
1276 ret = ptr2(data, reply);
1277 }
1278 ASSERT_EQ(ret, DM_OK);
1279 }
1280
1281 HWTEST_F(IpcCmdParserServiceTest, OnIpcCmdFunc_054, testing::ext::TestSize.Level0)
1282 {
1283 int32_t cmdCode = IMPORT_CREDENTIAL;
1284 int32_t ret = DM_OK;
1285 MessageParcel data;
1286 MessageParcel reply;
1287 std::string pkgName = "ohos.dm.test";
1288 JsonObject jsonObject;
1289 jsonObject[DM_CREDENTIAL_TYPE] = DM_TYPE_MINE;
1290 jsonObject[DM_CREDENTIAL_REQJSONSTR] = "";
1291 std::string credentialInfo = SafetyDump(jsonObject);
1292 data.WriteString(pkgName);
1293 data.WriteString(credentialInfo);
1294 OnIpcCmdFunc ptr = GetIpcCmdFunc(cmdCode);
1295 if (ptr) {
1296 ret = ptr(data, reply);
1297 }
1298 ASSERT_EQ(ret, DM_OK);
1299
1300 cmdCode = DELETE_CREDENTIAL;
1301 data.WriteString(pkgName);
1302 data.WriteString(credentialInfo);
1303 OnIpcCmdFunc ptr1 = GetIpcCmdFunc(cmdCode);
1304 if (ptr1) {
1305 ret = ptr1(data, reply);
1306 }
1307 ASSERT_EQ(ret, DM_OK);
1308
1309 cmdCode = REQUEST_CREDENTIAL;
1310 data.WriteString(pkgName);
1311 data.WriteString(credentialInfo);
1312 OnIpcCmdFunc ptr2 = GetIpcCmdFunc(cmdCode);
1313 if (ptr2) {
1314 ret = ptr2(data, reply);
1315 }
1316 ASSERT_EQ(ret, DM_OK);
1317 }
1318
1319 HWTEST_F(IpcCmdParserServiceTest, SetIpcRequestFunc_016, testing::ext::TestSize.Level0)
1320 {
1321 int32_t cmdCode = SERVER_DEVICE_DISCOVERY;
1322 MessageParcel data;
1323 std::shared_ptr<IpcNotifyDeviceDiscoveryReq> pReq = std::make_shared<IpcNotifyDeviceDiscoveryReq>();
1324 std::string pkgName = "com.ohos.test";
1325 uint16_t subscribeId = 100;
1326 DmDeviceBasicInfo deviceBasicInfo;
1327 pReq->SetPkgName(pkgName);
1328 pReq->SetSubscribeId(subscribeId);
1329 pReq->SetDeviceBasicInfo(deviceBasicInfo);
1330 int ret = ERR_DM_UNSUPPORTED_IPC_COMMAND;
1331 SetIpcRequestFunc ptr = GetIpcRequestFunc(cmdCode);
1332 if (ptr) {
1333 ret = ptr(pReq, data);
1334 }
1335 ASSERT_EQ(DM_OK, ret);
1336 }
1337
1338 HWTEST_F(IpcCmdParserServiceTest, SetIpcRequestFunc_017, testing::ext::TestSize.Level0)
1339 {
1340 int32_t cmdCode = SERVER_AUTH_RESULT;
1341 MessageParcel data;
1342 std::shared_ptr<IpcNotifyAuthResultReq> pReq = std::make_shared<IpcNotifyAuthResultReq>();
1343 std::string pkgName = "com.ohos.test";
1344 std::string deviceId = "112233445";
1345 std::string token = "134354656";
1346 int32_t status = 1;
1347 int32_t reason = 1;
1348 pReq->SetPkgName(pkgName);
1349 pReq->SetDeviceId(deviceId);
1350 pReq->SetToken(token);
1351 pReq->SetStatus(status);
1352 pReq->SetReason(reason);
1353 int ret = ERR_DM_UNSUPPORTED_IPC_COMMAND;
1354 SetIpcRequestFunc ptr = GetIpcRequestFunc(cmdCode);
1355 if (ptr) {
1356 ret = ptr(pReq, data);
1357 }
1358 ASSERT_EQ(DM_OK, ret);
1359 }
1360
1361 HWTEST_F(IpcCmdParserServiceTest, SetIpcRequestFunc_018, testing::ext::TestSize.Level0)
1362 {
1363 int32_t cmdCode = SERVER_DEVICE_FA_NOTIFY;
1364 MessageParcel data;
1365 std::shared_ptr<IpcNotifyDMFAResultReq> pReq = std::make_shared<IpcNotifyDMFAResultReq>();
1366 std::string pkgName = "com.ohos.test";
1367 std::string paramJson = "{}";
1368 pReq->SetPkgName(pkgName);
1369 pReq->SetJsonParam(paramJson);
1370 int ret = ERR_DM_UNSUPPORTED_IPC_COMMAND;
1371 SetIpcRequestFunc ptr = GetIpcRequestFunc(cmdCode);
1372 if (ptr) {
1373 ret = ptr(pReq, data);
1374 }
1375 ASSERT_EQ(DM_OK, ret);
1376 }
1377
1378 HWTEST_F(IpcCmdParserServiceTest, SetIpcRequestFunc_019, testing::ext::TestSize.Level0)
1379 {
1380 int32_t cmdCode = BIND_TARGET_RESULT;
1381 MessageParcel data;
1382 std::shared_ptr<IpcNotifyBindResultReq> pReq = std::make_shared<IpcNotifyBindResultReq>();
1383 std::string pkgName = "com.ohos.test";
1384 PeerTargetId targetId;
1385 int32_t result = 1;
1386 int32_t status = 1;
1387 std::string content = "";
1388 pReq->SetPkgName(pkgName);
1389 pReq->SetPeerTargetId(targetId);
1390 pReq->SetResult(result);
1391 pReq->SetStatus(status);
1392 pReq->SetContent(content);
1393 int ret = ERR_DM_UNSUPPORTED_IPC_COMMAND;
1394 SetIpcRequestFunc ptr = GetIpcRequestFunc(cmdCode);
1395 if (ptr) {
1396 ret = ptr(pReq, data);
1397 }
1398 ASSERT_EQ(DM_OK, ret);
1399 }
1400
1401 HWTEST_F(IpcCmdParserServiceTest, SetIpcRequestFunc_020, testing::ext::TestSize.Level0)
1402 {
1403 int32_t cmdCode = UNBIND_TARGET_RESULT;
1404 MessageParcel data;
1405 std::shared_ptr<IpcNotifyBindResultReq> pReq = std::make_shared<IpcNotifyBindResultReq>();
1406 std::string pkgName = "com.ohos.test";
1407 PeerTargetId targetId;
1408 int32_t result = 1;
1409 std::string content = "";
1410 pReq->SetPkgName(pkgName);
1411 pReq->SetPeerTargetId(targetId);
1412 pReq->SetResult(result);
1413 pReq->SetContent(content);
1414 int ret = ERR_DM_UNSUPPORTED_IPC_COMMAND;
1415 SetIpcRequestFunc ptr = GetIpcRequestFunc(cmdCode);
1416 if (ptr) {
1417 ret = ptr(pReq, data);
1418 }
1419 ASSERT_EQ(DM_OK, ret);
1420 }
1421
1422 HWTEST_F(IpcCmdParserServiceTest, SetIpcRequestFunc_021, testing::ext::TestSize.Level0)
1423 {
1424 int32_t cmdCode = SERVER_ON_PIN_HOLDER_EVENT;
1425 MessageParcel data;
1426 std::shared_ptr<IpcReq> req = nullptr;
1427 int ret = ERR_DM_FAILED;
1428 SetIpcRequestFunc ptr = GetIpcRequestFunc(cmdCode);
1429 if (ptr) {
1430 ret = ptr(req, data);
1431 }
1432 ASSERT_EQ(ret, ERR_DM_FAILED);
1433
1434 req = std::make_shared<IpcNotifyPinHolderEventReq>();
1435 std::string pkgName = "com.ohos.test";
1436 req->SetPkgName(pkgName);
1437 if (ptr) {
1438 ret = ptr(req, data);
1439 }
1440 ASSERT_EQ(ret, DM_OK);
1441 }
1442
1443 HWTEST_F(IpcCmdParserServiceTest, ReadResponseFunc_029, testing::ext::TestSize.Level0)
1444 {
1445 int32_t cmdCode = SERVER_ON_PIN_HOLDER_EVENT;
1446 ASSERT_EQ(ERR_DM_FAILED, TestReadResponseRspNull(cmdCode));
1447 }
1448
1449 HWTEST_F(IpcCmdParserServiceTest, OnIpcCmdFunc_055, testing::ext::TestSize.Level0)
1450 {
1451 int32_t cmdCode = CHECK_ACCESS_CONTROL;
1452 int32_t ret = DM_OK;
1453 MessageParcel data;
1454 MessageParcel reply;
1455 OnIpcCmdFunc ptr = GetIpcCmdFunc(cmdCode);
1456 if (ptr) {
1457 ret = ptr(data, reply);
1458 }
1459 ASSERT_EQ(ret, DM_OK);
1460
1461 cmdCode = CHECK_SAME_ACCOUNT;
1462 OnIpcCmdFunc ptr1 = GetIpcCmdFunc(cmdCode);
1463 if (ptr1) {
1464 ret = ptr1(data, reply);
1465 }
1466 ASSERT_EQ(ret, DM_OK);
1467
1468 cmdCode = SHIFT_LNN_GEAR;
1469 OnIpcCmdFunc ptr2 = GetIpcCmdFunc(cmdCode);
1470 if (ptr2) {
1471 ret = ptr2(data, reply);
1472 }
1473 ASSERT_EQ(ret, DM_OK);
1474 }
1475
1476 HWTEST_F(IpcCmdParserServiceTest, SetIpcRequestFunc_022, testing::ext::TestSize.Level0)
1477 {
1478 int32_t cmdCode = SERVICE_CREDENTIAL_AUTH_STATUS_NOTIFY;
1479 MessageParcel data;
1480 std::shared_ptr<IpcNotifyCredentialAuthStatusReq> req = nullptr;
1481 int ret = ERR_DM_FAILED;
1482 SetIpcRequestFunc ptr = GetIpcRequestFunc(cmdCode);
1483 if (ptr) {
1484 ret = ptr(req, data);
1485 }
1486 ASSERT_EQ(ret, ERR_DM_FAILED);
1487
1488 req = std::make_shared<IpcNotifyCredentialAuthStatusReq>();
1489 std::string pkgName = "com.ohos.test";
1490 std::string deviceList = "test";
1491 uint16_t deviceTypeId = 0x00;
1492 int32_t errcode = -1;
1493 req->SetPkgName(pkgName);
1494 req->SetDeviceList(deviceList);
1495 req->SetDeviceTypeId(deviceTypeId);
1496 req->SetErrCode(errcode);
1497 if (ptr) {
1498 ret = ptr(req, data);
1499 }
1500 ASSERT_EQ(ret, DM_OK);
1501 }
1502
1503 HWTEST_F(IpcCmdParserServiceTest, ReadResponseFunc_030, testing::ext::TestSize.Level0)
1504 {
1505 int32_t cmdCode = SERVICE_CREDENTIAL_AUTH_STATUS_NOTIFY;
1506 ASSERT_EQ(ERR_DM_FAILED, TestReadResponseRspNull(cmdCode));
1507 }
1508 } // namespace
1509 } // namespace DistributedHardware
1510 } // namespace OHOS