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