• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_client.h"
17 
18 #include <unistd.h>
19 
20 #include "device_manager_ipc_interface_code.h"
21 #include "ipc_acl_profile_req.h"
22 #include "ipc_bind_device_req.h"
23 #include "ipc_client_manager.h"
24 #include "ipc_cmd_register.h"
25 #include "ipc_common_param_req.h"
26 #include "ipc_create_pin_holder_req.h"
27 #include "ipc_register_listener_req.h"
28 #include "ipc_generate_encrypted_uuid_req.h"
29 #include "ipc_get_device_screen_status_req.h"
30 #include "ipc_get_device_screen_status_rsp.h"
31 #include "ipc_get_info_by_network_req.h"
32 #include "ipc_get_info_by_network_rsp.h"
33 #include "ipc_get_localserviceinfo_rsp.h"
34 #include "ipc_get_trustdevice_req.h"
35 #include "ipc_model_codec.h"
36 #include "ipc_publish_req.h"
37 #include "ipc_unpublish_req.h"
38 #include "ipc_unauthenticate_device_req.h"
39 #include "ipc_unbind_device_req.h"
40 #include "ipc_authenticate_device_req.h"
41 #include "ipc_register_serviceinfo_req.h"
42 #include "ipc_set_credential_req.h"
43 #include "ipc_set_credential_rsp.h"
44 #include "ipc_notify_event_req.h"
45 #include "device_manager_notify.h"
46 #include "ipc_req.h"
47 #include "dm_anonymous.h"
48 #include "dm_device_info.h"
49 #include "dm_constants.h"
50 #include "nlohmann/json.hpp"
51 
52 #define NUM_200 200
53 
54 namespace OHOS {
55 namespace DistributedHardware {
SetUp()56 void IpcCmdParserClientTest::SetUp()
57 {
58 }
59 
TearDown()60 void IpcCmdParserClientTest::TearDown()
61 {
62 }
63 
SetUpTestCase()64 void IpcCmdParserClientTest::SetUpTestCase()
65 {
66 }
67 
TearDownTestCase()68 void IpcCmdParserClientTest::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 
TestReadResponseRspNull(int32_t cmdCode)101 int32_t TestReadResponseRspNull(int32_t cmdCode)
102 {
103     MessageParcel reply;
104     std::shared_ptr<IpcRsp> rsp = nullptr;
105     int ret = ERR_DM_UNSUPPORTED_IPC_COMMAND;
106     ReadResponseFunc ptr = GetResponseFunc(cmdCode);
107     if (ptr) {
108         ret = ptr(reply, rsp);
109     }
110     return ret;
111 }
112 
TestReadResponseRspNotNull(int32_t cmdCode)113 int32_t TestReadResponseRspNotNull(int32_t cmdCode)
114 {
115     MessageParcel reply;
116     std::shared_ptr<IpcRsp> rsp = std::make_shared<IpcRsp>();
117     int32_t retCode = 0;
118     reply.WriteInt32(retCode);
119     int ret = ERR_DM_UNSUPPORTED_IPC_COMMAND;
120     ReadResponseFunc ptr = GetResponseFunc(cmdCode);
121     if (ptr) {
122         ret = ptr(reply, rsp);
123     }
124     return ret;
125 }
126 
EncodePeerTargetId(const PeerTargetId & targetId,MessageParcel & parcel)127 bool EncodePeerTargetId(const PeerTargetId &targetId, MessageParcel &parcel)
128 {
129     bool bRet = true;
130     bRet = (bRet && parcel.WriteString(targetId.deviceId));
131     bRet = (bRet && parcel.WriteString(targetId.brMac));
132     bRet = (bRet && parcel.WriteString(targetId.bleMac));
133     bRet = (bRet && parcel.WriteString(targetId.wifiIp));
134     bRet = (bRet && parcel.WriteUint16(targetId.wifiPort));
135     return bRet;
136 }
137 
TestIpcRequestNull(int32_t cmdCode)138 int32_t TestIpcRequestNull(int32_t cmdCode)
139 {
140     MessageParcel reply;
141     std::shared_ptr<IpcReq> pBaseReq = nullptr;
142     int32_t ret = ERR_DM_UNSUPPORTED_IPC_COMMAND;
143     auto ptr = GetIpcRequestFunc(cmdCode);
144     if (ptr) {
145         ret = ptr(pBaseReq, reply);
146     }
147     return ret;
148 }
149 
150 HWTEST_F(IpcCmdParserClientTest, ReadResponseFunc_001, testing::ext::TestSize.Level0)
151 {
152     int32_t cmdCode = REGISTER_DEVICE_MANAGER_LISTENER;
153     ASSERT_EQ(ERR_DM_FAILED, TestReadResponseRspNull(cmdCode));
154 }
155 
156 HWTEST_F(IpcCmdParserClientTest, ReadResponseFunc_004, testing::ext::TestSize.Level0)
157 {
158     int32_t cmdCode = UNPUBLISH_DEVICE_DISCOVER;
159     ASSERT_EQ(TestReadResponseRspNull(cmdCode), ERR_DM_FAILED);
160 }
161 
162 HWTEST_F(IpcCmdParserClientTest, ReadResponseFunc_005, testing::ext::TestSize.Level0)
163 {
164     int32_t cmdCode = AUTHENTICATE_DEVICE;
165     ASSERT_EQ(TestReadResponseRspNull(cmdCode), ERR_DM_FAILED);
166 }
167 
168 HWTEST_F(IpcCmdParserClientTest, ReadResponseFunc_007, testing::ext::TestSize.Level0)
169 {
170     int32_t cmdCode = BIND_DEVICE;
171     ASSERT_EQ(TestReadResponseRspNull(cmdCode), ERR_DM_FAILED);
172 }
173 
174 HWTEST_F(IpcCmdParserClientTest, ReadResponseFunc_008, testing::ext::TestSize.Level0)
175 {
176     int32_t cmdCode = UNBIND_DEVICE;
177     ASSERT_EQ(TestReadResponseRspNotNull(cmdCode), DM_OK);
178 }
179 
180 HWTEST_F(IpcCmdParserClientTest, ReadResponseFunc_009, testing::ext::TestSize.Level0)
181 {
182     int32_t cmdCode = REGISTER_UI_STATE_CALLBACK;
183     ASSERT_EQ(TestReadResponseRspNotNull(cmdCode), DM_OK);
184 }
185 
186 HWTEST_F(IpcCmdParserClientTest, ReadResponseFunc_010, testing::ext::TestSize.Level0)
187 {
188     int32_t cmdCode = UNREGISTER_UI_STATE_CALLBACK;
189     ASSERT_EQ(TestReadResponseRspNotNull(cmdCode), DM_OK);
190 }
191 
192 HWTEST_F(IpcCmdParserClientTest, ReadResponseFunc_011, testing::ext::TestSize.Level0)
193 {
194     int32_t cmdCode = REGISTER_DISCOVERY_CALLBACK;
195     ASSERT_EQ(TestReadResponseRspNull(cmdCode), ERR_DM_FAILED);
196 }
197 
198 HWTEST_F(IpcCmdParserClientTest, ReadResponseFunc_012, testing::ext::TestSize.Level0)
199 {
200     int32_t cmdCode = REGISTER_DISCOVERY_CALLBACK;
201     ASSERT_EQ(TestReadResponseRspNotNull(cmdCode), DM_OK);
202 }
203 
204 HWTEST_F(IpcCmdParserClientTest, ReadResponseFunc_013, testing::ext::TestSize.Level0)
205 {
206     int32_t cmdCode = UNREGISTER_DISCOVERY_CALLBACK;
207     ASSERT_EQ(TestReadResponseRspNull(cmdCode), ERR_DM_FAILED);
208 }
209 
210 HWTEST_F(IpcCmdParserClientTest, ReadResponseFunc_014, testing::ext::TestSize.Level0)
211 {
212     int32_t cmdCode = UNREGISTER_DISCOVERY_CALLBACK;
213     ASSERT_EQ(TestReadResponseRspNotNull(cmdCode), DM_OK);
214 }
215 
216 HWTEST_F(IpcCmdParserClientTest, ReadResponseFunc_015, testing::ext::TestSize.Level0)
217 {
218     int32_t cmdCode = START_DISCOVERING;
219     ASSERT_EQ(TestReadResponseRspNull(cmdCode), ERR_DM_FAILED);
220 }
221 
222 HWTEST_F(IpcCmdParserClientTest, ReadResponseFunc_016, testing::ext::TestSize.Level0)
223 {
224     int32_t cmdCode = STOP_DISCOVERING;
225     ASSERT_EQ(TestReadResponseRspNull(cmdCode), ERR_DM_FAILED);
226 }
227 
228 HWTEST_F(IpcCmdParserClientTest, ReadResponseFunc_017, testing::ext::TestSize.Level0)
229 {
230     int32_t cmdCode = START_ADVERTISING;
231     ASSERT_EQ(TestReadResponseRspNull(cmdCode), ERR_DM_FAILED);
232 }
233 
234 HWTEST_F(IpcCmdParserClientTest, ReadResponseFunc_018, testing::ext::TestSize.Level0)
235 {
236     int32_t cmdCode = START_ADVERTISING;
237     ASSERT_EQ(TestReadResponseRspNull(cmdCode), ERR_DM_FAILED);
238 }
239 
240 HWTEST_F(IpcCmdParserClientTest, ReadResponseFunc_019, testing::ext::TestSize.Level0)
241 {
242     int32_t cmdCode = START_ADVERTISING;
243     ASSERT_EQ(TestReadResponseRspNotNull(cmdCode), DM_OK);
244 }
245 
246 HWTEST_F(IpcCmdParserClientTest, ReadResponseFunc_020, testing::ext::TestSize.Level0)
247 {
248     int32_t cmdCode = STOP_ADVERTISING;
249     ASSERT_EQ(TestReadResponseRspNull(cmdCode), ERR_DM_FAILED);
250 }
251 
252 HWTEST_F(IpcCmdParserClientTest, ReadResponseFunc_021, testing::ext::TestSize.Level0)
253 {
254     int32_t cmdCode = STOP_ADVERTISING;
255     ASSERT_EQ(TestReadResponseRspNotNull(cmdCode), DM_OK);
256 }
257 
258 HWTEST_F(IpcCmdParserClientTest, ReadResponseFunc_022, testing::ext::TestSize.Level0)
259 {
260     int32_t cmdCode = BIND_TARGET;
261     ASSERT_EQ(TestReadResponseRspNull(cmdCode), ERR_DM_FAILED);
262 }
263 
264 HWTEST_F(IpcCmdParserClientTest, ReadResponseFunc_023, testing::ext::TestSize.Level0)
265 {
266     int32_t cmdCode = UNBIND_TARGET;
267     ASSERT_EQ(TestReadResponseRspNull(cmdCode), ERR_DM_FAILED);
268 }
269 
270 HWTEST_F(IpcCmdParserClientTest, ReadResponseFunc_024, testing::ext::TestSize.Level0)
271 {
272     int32_t cmdCode = CREATE_PIN_HOLDER;
273     ASSERT_EQ(TestReadResponseRspNotNull(cmdCode), DM_OK);
274 }
275 
276 HWTEST_F(IpcCmdParserClientTest, ReadResponseFunc_025, testing::ext::TestSize.Level0)
277 {
278     int32_t cmdCode = DESTROY_PIN_HOLDER;
279     ASSERT_EQ(TestReadResponseRspNotNull(cmdCode), DM_OK);
280 }
281 
282 HWTEST_F(IpcCmdParserClientTest, ReadResponseFunc_026, testing::ext::TestSize.Level0)
283 {
284     int32_t cmdCode = DP_ACL_ADD;
285     ASSERT_EQ(TestReadResponseRspNull(cmdCode), ERR_DM_FAILED);
286 }
287 
288 HWTEST_F(IpcCmdParserClientTest, ReadResponseFunc_027, testing::ext::TestSize.Level0)
289 {
290     int32_t cmdCode = DP_ACL_ADD;
291     ASSERT_EQ(TestReadResponseRspNotNull(cmdCode), DM_OK);
292 }
293 
294 HWTEST_F(IpcCmdParserClientTest, ReadResponseFunc_028, testing::ext::TestSize.Level0)
295 {
296     int32_t cmdCode = IS_SAME_ACCOUNT;
297     ASSERT_EQ(TestReadResponseRspNull(cmdCode), ERR_DM_FAILED);
298 }
299 
300 HWTEST_F(IpcCmdParserClientTest, ReadResponseFunc_029, testing::ext::TestSize.Level0)
301 {
302     int32_t cmdCode = SET_DN_POLICY;
303     ASSERT_EQ(TestReadResponseRspNull(cmdCode), ERR_DM_FAILED);
304 }
305 
306 HWTEST_F(IpcCmdParserClientTest, ReadResponseFunc_030, testing::ext::TestSize.Level0)
307 {
308     int32_t cmdCode = SET_DN_POLICY;
309     ASSERT_EQ(TestReadResponseRspNotNull(cmdCode), DM_OK);
310 }
311 
312 HWTEST_F(IpcCmdParserClientTest, ReadResponseFunc_031, testing::ext::TestSize.Level0)
313 {
314     int32_t cmdCode = SHIFT_LNN_GEAR;
315     ASSERT_EQ(TestReadResponseRspNull(cmdCode), ERR_DM_FAILED);
316 }
317 
318 HWTEST_F(IpcCmdParserClientTest, ReadResponseFunc_032, testing::ext::TestSize.Level0)
319 {
320     int32_t cmdCode = CHECK_SAME_ACCOUNT;
321     ASSERT_EQ(TestReadResponseRspNull(cmdCode), ERR_DM_FAILED);
322 }
323 
324 HWTEST_F(IpcCmdParserClientTest, ReadResponseFunc_033, testing::ext::TestSize.Level0)
325 {
326     int32_t cmdCode = CHECK_ACCESS_CONTROL;
327     ASSERT_EQ(TestReadResponseRspNull(cmdCode), ERR_DM_FAILED);
328 }
329 
330 HWTEST_F(IpcCmdParserClientTest, ReadResponseFunc_034, testing::ext::TestSize.Level0)
331 {
332     int32_t cmdCode = CHECK_API_PERMISSION;
333     ASSERT_EQ(TestReadResponseRspNull(cmdCode), ERR_DM_FAILED);
334 }
335 
336 HWTEST_F(IpcCmdParserClientTest, ReadResponseFunc_081, testing::ext::TestSize.Level0)
337 {
338     int32_t cmdCode = REG_LOCALSERVICE_INFO;
339     ASSERT_EQ(TestReadResponseRspNull(cmdCode), ERR_DM_FAILED);
340 }
341 
342 HWTEST_F(IpcCmdParserClientTest, ReadResponseFunc_082, testing::ext::TestSize.Level0)
343 {
344     int32_t cmdCode = UNREG_LOCALSERVICE_INFO;
345     ASSERT_EQ(TestReadResponseRspNull(cmdCode), ERR_DM_FAILED);
346 }
347 
348 HWTEST_F(IpcCmdParserClientTest, ReadResponseFunc_083, testing::ext::TestSize.Level0)
349 {
350     int32_t cmdCode = UPDATE_LOCALSERVICE_INFO;
351     ASSERT_EQ(TestReadResponseRspNull(cmdCode), ERR_DM_FAILED);
352 }
353 
354 HWTEST_F(IpcCmdParserClientTest, ReadResponseFunc_084, testing::ext::TestSize.Level0)
355 {
356     int32_t cmdCode = GET_SERVICEINFO_BYBUNDLENAME_PINEXCHANGETYPE;
357     ASSERT_EQ(TestReadResponseRspNull(cmdCode), ERR_DM_FAILED);
358 }
359 
360 HWTEST_F(IpcCmdParserClientTest, ReadResponseFunc_087, testing::ext::TestSize.Level0)
361 {
362     int32_t cmdCode = REG_LOCALSERVICE_INFO;
363     ASSERT_EQ(TestReadResponseRspNotNull(cmdCode), DM_OK);
364 }
365 
366 HWTEST_F(IpcCmdParserClientTest, ReadResponseFunc_088, testing::ext::TestSize.Level0)
367 {
368     int32_t cmdCode = UNREG_LOCALSERVICE_INFO;
369     ASSERT_EQ(TestReadResponseRspNotNull(cmdCode), DM_OK);
370 }
371 
372 HWTEST_F(IpcCmdParserClientTest, ReadResponseFunc_089, testing::ext::TestSize.Level0)
373 {
374     int32_t cmdCode = UPDATE_LOCALSERVICE_INFO;
375     ASSERT_EQ(TestReadResponseRspNotNull(cmdCode), DM_OK);
376 }
377 
378 HWTEST_F(IpcCmdParserClientTest, ReadResponseFunc_090, testing::ext::TestSize.Level0)
379 {
380     int32_t cmdCode = GET_SERVICEINFO_BYBUNDLENAME_PINEXCHANGETYPE;
381     MessageParcel reply;
382     std::shared_ptr<IpcGetLocalServiceInfoRsp> rsp = std::make_shared<IpcGetLocalServiceInfoRsp>();
383     int32_t retCode = 0;
384     reply.WriteInt32(retCode);
385     int ret = ERR_DM_UNSUPPORTED_IPC_COMMAND;
386     ReadResponseFunc ptr = GetResponseFunc(cmdCode);
387     if (ptr) {
388         ret = ptr(reply, rsp);
389     }
390     ASSERT_EQ(ret, DM_OK);
391     ASSERT_EQ(rsp->GetErrCode(), ERR_DM_IPC_READ_FAILED);
392 
393     MessageParcel reply2;
394     reply2.WriteInt32(DM_OK);
395     DMLocalServiceInfo info;
396     info.bundleName = "debug";
397     ASSERT_TRUE(IpcModelCodec::EncodeLocalServiceInfo(info, reply2));
398     if (ptr) {
399         ret = ptr(reply2, rsp);
400     }
401     ASSERT_EQ(ret, DM_OK);
402     ASSERT_EQ(rsp->GetErrCode(), DM_OK);
403     ASSERT_TRUE(rsp->GetLocalServiceInfo().bundleName == "debug");
404 }
405 
406 HWTEST_F(IpcCmdParserClientTest, SetIpcRequestFunc_002, testing::ext::TestSize.Level0)
407 {
408     int32_t cmdCode = GET_NETWORKTYPE_BY_NETWORK;
409     MessageParcel data;
410     std::shared_ptr<IpcGetInfoByNetWorkReq> req = std::make_shared<IpcGetInfoByNetWorkReq>();
411     std::string pkgName = "ohos.dm.test";
412     std::string netWorkId = "xxx";
413     req->SetPkgName(pkgName);
414     req->SetNetWorkId(netWorkId);
415     int ret = ERR_DM_UNSUPPORTED_IPC_COMMAND;
416     SetIpcRequestFunc ptr = GetIpcRequestFunc(cmdCode);
417     if (ptr) {
418         ret = ptr(req, data);
419     }
420     ASSERT_EQ(DM_OK, ret);
421 }
422 
423 HWTEST_F(IpcCmdParserClientTest, SetIpcRequestFunc_003, testing::ext::TestSize.Level0)
424 {
425     int32_t cmdCode = UNBIND_DEVICE;
426     MessageParcel data;
427     std::shared_ptr<IpcUnBindDeviceReq> req = std::make_shared<IpcUnBindDeviceReq>();
428     std::string pkgName = "ohos.dm.test";
429     std::string deviceId = "xxx";
430     req->SetPkgName(pkgName);
431     req->SetDeviceId(deviceId);
432     int ret = ERR_DM_UNSUPPORTED_IPC_COMMAND;
433     SetIpcRequestFunc ptr = GetIpcRequestFunc(cmdCode);
434     if (ptr) {
435         ret = ptr(req, data);
436     }
437     ASSERT_EQ(DM_OK, ret);
438 }
439 
440 HWTEST_F(IpcCmdParserClientTest, SetIpcRequestFunc_004, testing::ext::TestSize.Level0)
441 {
442     int32_t cmdCode = GET_NETWORKTYPE_BY_NETWORK;
443     MessageParcel data;
444     std::shared_ptr<IpcGetInfoByNetWorkReq> req = std::make_shared<IpcGetInfoByNetWorkReq>();
445     std::string pkgName = "ohos.dm.test";
446     std::string netWorkId = "xxx";
447     req->SetPkgName(pkgName);
448     req->SetNetWorkId(netWorkId);
449     int ret = ERR_DM_UNSUPPORTED_IPC_COMMAND;
450     SetIpcRequestFunc ptr = GetIpcRequestFunc(cmdCode);
451     if (ptr) {
452         ret = ptr(req, data);
453     }
454     ASSERT_EQ(DM_OK, ret);
455 }
456 
457 HWTEST_F(IpcCmdParserClientTest, SetIpcRequestFunc_005, testing::ext::TestSize.Level0)
458 {
459     int32_t cmdCode = REGISTER_UI_STATE_CALLBACK;
460     MessageParcel data;
461     std::shared_ptr<IpcReq> req = std::make_shared<IpcReq>();
462     std::string pkgName = "ohos.dm.test";
463     req->SetPkgName(pkgName);
464     int ret = ERR_DM_UNSUPPORTED_IPC_COMMAND;
465     SetIpcRequestFunc ptr = GetIpcRequestFunc(cmdCode);
466     if (ptr) {
467         ret = ptr(req, data);
468     }
469     ASSERT_EQ(DM_OK, ret);
470 }
471 
472 HWTEST_F(IpcCmdParserClientTest, SetIpcRequestFunc_006, testing::ext::TestSize.Level0)
473 {
474     int32_t cmdCode = UNREGISTER_UI_STATE_CALLBACK;
475     MessageParcel data;
476     std::shared_ptr<IpcReq> req = std::make_shared<IpcReq>();
477     std::string pkgName = "ohos.dm.test";
478     req->SetPkgName(pkgName);
479     int ret = ERR_DM_UNSUPPORTED_IPC_COMMAND;
480     SetIpcRequestFunc ptr = GetIpcRequestFunc(cmdCode);
481     if (ptr) {
482         ret = ptr(req, data);
483     }
484     ASSERT_EQ(DM_OK, ret);
485 }
486 
487 HWTEST_F(IpcCmdParserClientTest, SetIpcRequestFunc_007, testing::ext::TestSize.Level0)
488 {
489     int32_t cmdCode = REGISTER_DISCOVERY_CALLBACK;
490     MessageParcel data;
491     std::shared_ptr<IpcCommonParamReq> req = std::make_shared<IpcCommonParamReq>();
492     std::string pkgName = "ohos.dm.test";
493     std::string discParaStr = "XXX";
494     std::string filterOpStr = "XXX";
495     req->SetPkgName(pkgName);
496     req->SetFirstParam(discParaStr);
497     req->SetSecondParam(filterOpStr);
498     int ret = ERR_DM_UNSUPPORTED_IPC_COMMAND;
499     SetIpcRequestFunc ptr = GetIpcRequestFunc(cmdCode);
500     if (ptr) {
501         ret = ptr(req, data);
502     }
503     ASSERT_EQ(DM_OK, ret);
504 }
505 
506 HWTEST_F(IpcCmdParserClientTest, SetIpcRequestFunc_008, testing::ext::TestSize.Level0)
507 {
508     int32_t cmdCode = UNREGISTER_DISCOVERY_CALLBACK;
509     MessageParcel data;
510     std::shared_ptr<IpcCommonParamReq> req = std::make_shared<IpcCommonParamReq>();
511     std::string pkgName = "ohos.dm.test";
512     std::string discParaStr = "XXX";
513     req->SetPkgName(pkgName);
514     req->SetFirstParam(discParaStr);
515     int ret = ERR_DM_UNSUPPORTED_IPC_COMMAND;
516     SetIpcRequestFunc ptr = GetIpcRequestFunc(cmdCode);
517     if (ptr) {
518         ret = ptr(req, data);
519     }
520     ASSERT_EQ(DM_OK, ret);
521 }
522 
523 HWTEST_F(IpcCmdParserClientTest, SetIpcRequestFunc_009, testing::ext::TestSize.Level0)
524 {
525     int32_t cmdCode = START_ADVERTISING;
526     MessageParcel data;
527     std::shared_ptr<IpcCommonParamReq> req = std::make_shared<IpcCommonParamReq>();
528     std::string pkgName = "ohos.dm.test";
529     std::string discParaStr = "XXX";
530     req->SetPkgName(pkgName);
531     req->SetFirstParam(discParaStr);
532     int ret = ERR_DM_UNSUPPORTED_IPC_COMMAND;
533     SetIpcRequestFunc ptr = GetIpcRequestFunc(cmdCode);
534     if (ptr) {
535         ret = ptr(req, data);
536     }
537     ASSERT_EQ(DM_OK, ret);
538 }
539 
540 HWTEST_F(IpcCmdParserClientTest, SetIpcRequestFunc_010, testing::ext::TestSize.Level0)
541 {
542     int32_t cmdCode = STOP_ADVERTISING;
543     MessageParcel data;
544     std::shared_ptr<IpcCommonParamReq> req = std::make_shared<IpcCommonParamReq>();
545     std::string pkgName = "ohos.dm.test";
546     std::string discParaStr = "XXX";
547     req->SetPkgName(pkgName);
548     req->SetFirstParam(discParaStr);
549     int ret = ERR_DM_UNSUPPORTED_IPC_COMMAND;
550     SetIpcRequestFunc ptr = GetIpcRequestFunc(cmdCode);
551     if (ptr) {
552         ret = ptr(req, data);
553     }
554     ASSERT_EQ(DM_OK, ret);
555 }
556 
557 HWTEST_F(IpcCmdParserClientTest, SetIpcRequestFunc_011, testing::ext::TestSize.Level0)
558 {
559     int32_t cmdCode = CREATE_PIN_HOLDER;
560     MessageParcel data;
561     std::shared_ptr<IpcCreatePinHolderReq> req = std::make_shared<IpcCreatePinHolderReq>();
562     std::string pkgName = "ohos.dm.test";
563     PeerTargetId targetId;
564     DmPinType pinType = NUMBER_PIN_CODE;
565     std::string payload = "XXX";
566     req->SetPkgName(pkgName);
567     req->SetPeerTargetId(targetId);
568     req->SetPinType(pinType);
569     req->SetPayload(payload);
570     int ret = ERR_DM_UNSUPPORTED_IPC_COMMAND;
571     SetIpcRequestFunc ptr = GetIpcRequestFunc(cmdCode);
572     if (ptr) {
573         ret = ptr(req, data);
574     }
575     ASSERT_EQ(DM_OK, ret);
576 }
577 
578 HWTEST_F(IpcCmdParserClientTest, SetIpcRequestFunc_012, testing::ext::TestSize.Level0)
579 {
580     int32_t cmdCode = DESTROY_PIN_HOLDER;
581     MessageParcel data;
582     std::shared_ptr<IpcCreatePinHolderReq> req = std::make_shared<IpcCreatePinHolderReq>();
583     std::string pkgName = "ohos.dm.test";
584     PeerTargetId targetId;
585     DmPinType pinType = NUMBER_PIN_CODE;
586     std::string payload = "XXX";
587     req->SetPkgName(pkgName);
588     req->SetPeerTargetId(targetId);
589     req->SetPinType(pinType);
590     req->SetPayload(payload);
591     int ret = ERR_DM_UNSUPPORTED_IPC_COMMAND;
592     SetIpcRequestFunc ptr = GetIpcRequestFunc(cmdCode);
593     if (ptr) {
594         ret = ptr(req, data);
595     }
596     ASSERT_EQ(DM_OK, ret);
597 }
598 
599 HWTEST_F(IpcCmdParserClientTest, SetIpcRequestFunc_013, testing::ext::TestSize.Level0)
600 {
601     int32_t cmdCode = DP_ACL_ADD;
602     MessageParcel data;
603     std::shared_ptr<IpcAclProfileReq> req = std::make_shared<IpcAclProfileReq>();
604     std::string udid = "XXX";
605     req->SetStr(udid);
606     int ret = ERR_DM_UNSUPPORTED_IPC_COMMAND;
607     SetIpcRequestFunc ptr = GetIpcRequestFunc(cmdCode);
608     if (ptr) {
609         ret = ptr(req, data);
610     }
611     ASSERT_EQ(DM_OK, ret);
612 }
613 
614 HWTEST_F(IpcCmdParserClientTest, SetIpcRequestFunc_014, testing::ext::TestSize.Level0)
615 {
616     int32_t cmdCode = GET_SECURITY_LEVEL;
617     MessageParcel data;
618     std::shared_ptr<IpcGetInfoByNetWorkReq> req = std::make_shared<IpcGetInfoByNetWorkReq>();
619     std::string networkId = "XXX";
620     std::string pkgName = "ohos.dm.test";
621     req->SetPkgName(pkgName);
622     req->SetNetWorkId(networkId);
623     int ret = ERR_DM_UNSUPPORTED_IPC_COMMAND;
624     SetIpcRequestFunc ptr = GetIpcRequestFunc(cmdCode);
625     if (ptr) {
626         ret = ptr(req, data);
627     }
628     ASSERT_EQ(DM_OK, ret);
629 }
630 
631 HWTEST_F(IpcCmdParserClientTest, SetIpcRequestFunc_015, testing::ext::TestSize.Level0)
632 {
633     int32_t cmdCode = SET_DN_POLICY;
634     MessageParcel data;
635     std::shared_ptr<IpcCommonParamReq> req = std::make_shared<IpcCommonParamReq>();
636     std::string pkgName = "ohos.dm.test";
637     std::string policy = "DM_POLICY_STRATEGY_FOR_BLE:100";
638     req->SetPkgName(pkgName);
639     req->SetFirstParam(policy);
640     int ret = ERR_DM_UNSUPPORTED_IPC_COMMAND;
641     SetIpcRequestFunc ptr = GetIpcRequestFunc(cmdCode);
642     if (ptr) {
643         ret = ptr(req, data);
644     }
645     ASSERT_EQ(DM_OK, ret);
646 }
647 
648 HWTEST_F(IpcCmdParserClientTest, SetIpcRequestFunc_031, testing::ext::TestSize.Level0)
649 {
650     int32_t cmdCode = REG_LOCALSERVICE_INFO;
651     DMLocalServiceInfo serviceInfo;
652     MessageParcel data;
653     std::shared_ptr<IpcRegServiceInfoReq> req = std::make_shared<IpcRegServiceInfoReq>();
654     req->SetLocalServiceInfo(serviceInfo);
655 
656     int ret = ERR_DM_UNSUPPORTED_IPC_COMMAND;
657     SetIpcRequestFunc ptr = GetIpcRequestFunc(cmdCode);
658     if (ptr) {
659         ret = ptr(req, data);
660     }
661     ASSERT_EQ(DM_OK, ret);
662 }
663 
664 HWTEST_F(IpcCmdParserClientTest, SetIpcRequestFunc_032, testing::ext::TestSize.Level0)
665 {
666     int32_t cmdCode = UNREG_LOCALSERVICE_INFO;
667     DMLocalServiceInfo serviceInfo;
668     MessageParcel data;
669     std::shared_ptr<IpcCommonParamReq> req = std::make_shared<IpcCommonParamReq>();
670     req->SetFirstParam(std::string("testbundle"));
671     req->SetInt32Param(100);
672 
673     int ret = ERR_DM_UNSUPPORTED_IPC_COMMAND;
674     SetIpcRequestFunc ptr = GetIpcRequestFunc(cmdCode);
675     if (ptr) {
676         ret = ptr(req, data);
677     }
678     ASSERT_EQ(DM_OK, ret);
679 }
680 
681 HWTEST_F(IpcCmdParserClientTest, SetIpcRequestFunc_033, testing::ext::TestSize.Level0)
682 {
683     int32_t cmdCode = UPDATE_LOCALSERVICE_INFO;
684     DMLocalServiceInfo serviceInfo;
685     MessageParcel data;
686     std::shared_ptr<IpcRegServiceInfoReq> req = std::make_shared<IpcRegServiceInfoReq>();
687     req->SetLocalServiceInfo(serviceInfo);
688 
689     int ret = ERR_DM_UNSUPPORTED_IPC_COMMAND;
690     SetIpcRequestFunc ptr = GetIpcRequestFunc(cmdCode);
691     if (ptr) {
692         ret = ptr(req, data);
693     }
694     ASSERT_EQ(DM_OK, ret);
695 }
696 
697 HWTEST_F(IpcCmdParserClientTest, SetIpcRequestFunc_034, testing::ext::TestSize.Level0)
698 {
699     int32_t cmdCode = GET_SERVICEINFO_BYBUNDLENAME_PINEXCHANGETYPE;
700     DMLocalServiceInfo serviceInfo;
701     MessageParcel data;
702     std::shared_ptr<IpcCommonParamReq> req = std::make_shared<IpcCommonParamReq>();
703     req->SetFirstParam(std::string("testbundle"));
704     req->SetInt32Param(100);
705     int ret = ERR_DM_UNSUPPORTED_IPC_COMMAND;
706     SetIpcRequestFunc ptr = GetIpcRequestFunc(cmdCode);
707     if (ptr) {
708         ret = ptr(req, data);
709     }
710     ASSERT_EQ(DM_OK, ret);
711 }
712 
713 HWTEST_F(IpcCmdParserClientTest, OnIpcCmdFunc_001, testing::ext::TestSize.Level0)
714 {
715     int32_t cmdCode = SERVER_DEVICE_DISCOVERY;
716     int32_t ret = ERR_DM_UNSUPPORTED_IPC_COMMAND;
717     MessageParcel data;
718     MessageParcel reply;
719     std::string pkgName = "ohos.dm.test";
720     int16_t subscribeId = 100;
721     std::string deviceId = "xxx";
722     data.WriteString(pkgName);
723     data.WriteInt16(subscribeId);
724     DmDeviceBasicInfo basicInfo;
725     data.WriteRawData(&basicInfo, sizeof(DmDeviceBasicInfo));
726     OnIpcCmdFunc ptr = GetIpcCmdFunc(cmdCode);
727     if (ptr) {
728         ret = ptr(data, reply);
729     }
730     ASSERT_EQ(ret, DM_OK);
731 }
732 
733 HWTEST_F(IpcCmdParserClientTest, OnIpcCmdFunc_002, testing::ext::TestSize.Level0)
734 {
735     int32_t cmdCode = BIND_TARGET_RESULT;
736     int32_t ret = ERR_DM_UNSUPPORTED_IPC_COMMAND;
737     MessageParcel data;
738     MessageParcel reply;
739     std::string pkgName = "ohos.dm.test";
740     PeerTargetId targetId;
741     int32_t result = 1;
742     int32_t status = 1;
743     std::string content = "XX";
744     data.WriteString(pkgName);
745     EncodePeerTargetId(targetId, data);
746     data.WriteInt32(result);
747     data.WriteInt32(status);
748     data.WriteString(content);
749     OnIpcCmdFunc ptr = GetIpcCmdFunc(cmdCode);
750     if (ptr) {
751         ret = ptr(data, reply);
752     }
753     ASSERT_EQ(ret, DM_OK);
754 }
755 
756 HWTEST_F(IpcCmdParserClientTest, OnIpcCmdFunc_003, testing::ext::TestSize.Level0)
757 {
758     int32_t cmdCode = UNBIND_TARGET_RESULT;
759     int32_t ret = ERR_DM_UNSUPPORTED_IPC_COMMAND;
760     MessageParcel data;
761     MessageParcel reply;
762     std::string pkgName = "ohos.dm.test";
763     PeerTargetId targetId;
764     int32_t result = 1;
765     std::string content = "XX";
766     data.WriteString(pkgName);
767     EncodePeerTargetId(targetId, data);
768     data.WriteInt32(result);
769     data.WriteString(content);
770     OnIpcCmdFunc ptr = GetIpcCmdFunc(cmdCode);
771     if (ptr) {
772         ret = ptr(data, reply);
773     }
774     ASSERT_EQ(ret, DM_OK);
775 }
776 
777 HWTEST_F(IpcCmdParserClientTest, OnIpcCmdFunc_004, testing::ext::TestSize.Level0)
778 {
779     int32_t cmdCode = SERVER_CREATE_PIN_HOLDER;
780     int32_t ret = ERR_DM_UNSUPPORTED_IPC_COMMAND;
781     MessageParcel data;
782     MessageParcel reply;
783     std::string pkgName = "ohos.dm.test";
784     std::string deviceId = "xxx";
785     int32_t pinType = 1;
786     std::string payload = "xx";
787     data.WriteString(pkgName);
788     data.WriteString(deviceId);
789     data.WriteInt32(pinType);
790     data.WriteString(payload);
791     OnIpcCmdFunc ptr = GetIpcCmdFunc(cmdCode);
792     if (ptr) {
793         ret = ptr(data, reply);
794     }
795     ASSERT_EQ(ret, DM_OK);
796 }
797 
798 HWTEST_F(IpcCmdParserClientTest, OnIpcCmdFunc_005, testing::ext::TestSize.Level0)
799 {
800     int32_t cmdCode = SERVER_DESTROY_PIN_HOLDER;
801     int32_t ret = ERR_DM_UNSUPPORTED_IPC_COMMAND;
802     MessageParcel data;
803     MessageParcel reply;
804     std::string pkgName = "ohos.dm.test";
805     int32_t pinType = 1;
806     std::string payload = "xx";
807     data.WriteString(pkgName);
808     data.WriteInt32(pinType);
809     data.WriteString(payload);
810     OnIpcCmdFunc ptr = GetIpcCmdFunc(cmdCode);
811     if (ptr) {
812         ret = ptr(data, reply);
813     }
814     ASSERT_EQ(ret, DM_OK);
815 }
816 
817 HWTEST_F(IpcCmdParserClientTest, OnIpcCmdFunc_006, testing::ext::TestSize.Level0)
818 {
819     int32_t cmdCode = SERVER_CREATE_PIN_HOLDER_RESULT;
820     int32_t ret = ERR_DM_UNSUPPORTED_IPC_COMMAND;
821     MessageParcel data;
822     MessageParcel reply;
823     std::string pkgName = "ohos.dm.test";
824     int32_t result = 1;
825     data.WriteString(pkgName);
826     data.WriteInt32(result);
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(IpcCmdParserClientTest, OnIpcCmdFunc_007, testing::ext::TestSize.Level0)
835 {
836     int32_t cmdCode = SERVER_DESTROY_PIN_HOLDER_RESULT;
837     int32_t ret = ERR_DM_UNSUPPORTED_IPC_COMMAND;
838     MessageParcel data;
839     MessageParcel reply;
840     std::string pkgName = "ohos.dm.test";
841     int32_t result = 1;
842     data.WriteString(pkgName);
843     data.WriteInt32(result);
844     OnIpcCmdFunc ptr = GetIpcCmdFunc(cmdCode);
845     if (ptr) {
846         ret = ptr(data, reply);
847     }
848     ASSERT_EQ(ret, DM_OK);
849 }
850 
851 HWTEST_F(IpcCmdParserClientTest, OnIpcCmdFunc_008, testing::ext::TestSize.Level0)
852 {
853     int32_t cmdCode = SERVER_ON_PIN_HOLDER_EVENT;
854     int32_t ret = ERR_DM_UNSUPPORTED_IPC_COMMAND;
855     MessageParcel data;
856     MessageParcel reply;
857     std::string pkgName = "ohos.dm.test";
858     int32_t result = 1;
859     std::string content = "xxx";
860     int32_t pinHolderEvent = 1;
861     data.WriteString(pkgName);
862     data.WriteInt32(result);
863     data.WriteInt32(pinHolderEvent);
864     data.WriteString(content);
865     OnIpcCmdFunc ptr = GetIpcCmdFunc(cmdCode);
866     if (ptr) {
867         ret = ptr(data, reply);
868     }
869     ASSERT_EQ(ret, DM_OK);
870 }
871 
872 HWTEST_F(IpcCmdParserClientTest, OnIpcCmdFunc_009, testing::ext::TestSize.Level0)
873 {
874     int32_t cmdCode = REMOTE_DEVICE_TRUST_CHANGE;
875     int32_t ret = ERR_DM_UNSUPPORTED_IPC_COMMAND;
876     MessageParcel data;
877     MessageParcel reply;
878     std::string pkgName = "ohos.dm.test";
879     std::string deviceId = "xxx";
880     int32_t authForm = 1;
881     data.WriteString(pkgName);
882     data.WriteString(deviceId);
883     data.WriteInt32(authForm);
884     OnIpcCmdFunc ptr = GetIpcCmdFunc(cmdCode);
885     if (ptr) {
886         ret = ptr(data, reply);
887     }
888     ASSERT_EQ(ret, DM_OK);
889 }
890 
891 HWTEST_F(IpcCmdParserClientTest, OnIpcCmdFunc_010, testing::ext::TestSize.Level0)
892 {
893     auto ptr = GetIpcCmdFunc(SERVER_DEVICE_STATE_NOTIFY);
894     ASSERT_TRUE(ptr != nullptr);
895 
896     MessageParcel reply;
897     MessageParcel data1;
898     data1.WriteString("com.ohos.test");
899     data1.WriteInt32(DEVICE_INFO_READY);
900     size_t deviceSize = sizeof(DmDeviceInfo);
901     data1.WriteRawData(nullptr, deviceSize);
902     EXPECT_EQ(ptr(data1, reply), DM_OK);
903 
904     MessageParcel data2;
905     data2.WriteString("com.ohos.test");
906     data2.WriteInt32(DEVICE_STATE_UNKNOWN);
907     EXPECT_EQ(ptr(data2, reply), DM_OK);
908 }
909 
910 HWTEST_F(IpcCmdParserClientTest, OnIpcCmdFunc_011, testing::ext::TestSize.Level0)
911 {
912     auto ptr = GetIpcCmdFunc(SERVER_DEVICE_SCREEN_STATE_NOTIFY);
913     ASSERT_TRUE(ptr != nullptr);
914 
915     MessageParcel reply;
916     MessageParcel data;
917     EXPECT_EQ(ptr(data, reply), DM_OK);
918 }
919 
920 HWTEST_F(IpcCmdParserClientTest, OnIpcCmdFunc_012, testing::ext::TestSize.Level0)
921 {
922     auto ptr = GetIpcCmdFunc(SERVICE_CREDENTIAL_AUTH_STATUS_NOTIFY);
923     ASSERT_TRUE(ptr != nullptr);
924 
925     MessageParcel reply;
926     MessageParcel data;
927     EXPECT_EQ(ptr(data, reply), DM_OK);
928 }
929 
930 HWTEST_F(IpcCmdParserClientTest, OnIpcCmdFunc_013, testing::ext::TestSize.Level0)
931 {
932     auto ptr = GetIpcCmdFunc(SINK_BIND_TARGET_RESULT);
933     ASSERT_TRUE(ptr != nullptr);
934 
935     MessageParcel reply;
936     MessageParcel data;
937     EXPECT_EQ(ptr(data, reply), DM_OK);
938 }
939 
940 HWTEST_F(IpcCmdParserClientTest, SetIpcRequestFunc_016, testing::ext::TestSize.Level0)
941 {
942     auto ptr = GetIpcRequestFunc(SERVER_GET_DMFA_INFO);
943     ASSERT_TRUE(ptr != nullptr);
944 
945     MessageParcel data;
946     auto req = std::make_shared<IpcSetCredentialReq>();
947     std::string pkgName = "ohos.dm.test";
948     std::string credential = "git:https://gitee.com";
949     req->SetPkgName(pkgName);
950     req->SetCredentialParam(credential);
951     auto ret = ptr(req, data);
952     ASSERT_EQ(DM_OK, ret);
953 }
954 
955 HWTEST_F(IpcCmdParserClientTest, SetIpcRequestFunc_017, testing::ext::TestSize.Level0)
956 {
957     auto ptr = GetIpcRequestFunc(GENERATE_ENCRYPTED_UUID);
958     ASSERT_TRUE(ptr != nullptr);
959 
960     MessageParcel data;
961     auto req = std::make_shared<IpcGenerateEncryptedUuidReq>();
962     std::string pkgName = "ohos.dm.test";
963     std::string uuid = "123456789";
964     std::string appId = "1234";
965     req->SetPkgName(pkgName);
966     req->SetUuid(uuid);
967     req->SetAppId(appId);
968     auto ret = ptr(req, data);
969     ASSERT_EQ(DM_OK, ret);
970 }
971 
972 HWTEST_F(IpcCmdParserClientTest, SetIpcRequestFunc_018, testing::ext::TestSize.Level0)
973 {
974     auto ptr = GetIpcRequestFunc(BIND_DEVICE);
975     ASSERT_TRUE(ptr != nullptr);
976 
977     MessageParcel data;
978     auto req = std::make_shared<IpcBindDeviceReq>();
979     std::string pkgName = "ohos.dm.test";
980     int32_t bindType = 4;
981     std::string deviceId = "oh.myPhone.No1";
982     req->SetPkgName(pkgName);
983     req->SetBindType(bindType);
984     req->SetDeviceId(deviceId);
985     auto ret = ptr(req, data);
986     ASSERT_EQ(DM_OK, ret);
987 }
988 
989 HWTEST_F(IpcCmdParserClientTest, SetIpcRequestFunc_019, testing::ext::TestSize.Level0)
990 {
991     auto ptr = GetIpcRequestFunc(STOP_AUTHENTICATE_DEVICE);
992     ASSERT_TRUE(ptr != nullptr);
993 
994     MessageParcel data;
995     auto req = std::make_shared<IpcCommonParamReq>();
996     std::string pkgName = "ohos.dm.test";
997     req->SetPkgName(pkgName);
998     auto ret = ptr(req, data);
999     ASSERT_EQ(DM_OK, ret);
1000 }
1001 
1002 HWTEST_F(IpcCmdParserClientTest, SetIpcRequestFunc_020, testing::ext::TestSize.Level0)
1003 {
1004     auto ptr = GetIpcRequestFunc(GET_DEVICE_SCREEN_STATUS);
1005     ASSERT_TRUE(ptr != nullptr);
1006 
1007     MessageParcel data;
1008     auto req = std::make_shared<IpcGetDeviceScreenStatusReq>();
1009     std::string pkgName = "ohos.dm.test";
1010     std::string netWorkId = "3a80******fd94";
1011     req->SetPkgName(pkgName);
1012     req->SetNetWorkId(netWorkId);
1013     auto ret = ptr(req, data);
1014     ASSERT_EQ(DM_OK, ret);
1015 }
1016 
1017 HWTEST_F(IpcCmdParserClientTest, SetIpcRequestFunc_021, testing::ext::TestSize.Level0)
1018 {
1019     auto ptr = GetIpcRequestFunc(GET_NETWORKID_BY_UDID);
1020     ASSERT_TRUE(ptr != nullptr);
1021 
1022     MessageParcel data;
1023     auto req = std::make_shared<IpcGetInfoByNetWorkReq>();
1024     std::string pkgName = "ohos.dm.test";
1025     std::string udid = "udid";
1026     req->SetPkgName(pkgName);
1027     req->SetUdid(udid);
1028     auto ret = ptr(req, data);
1029     ASSERT_EQ(DM_OK, ret);
1030 }
1031 
1032 HWTEST_F(IpcCmdParserClientTest, SetIpcRequestFunc_022, testing::ext::TestSize.Level0)
1033 {
1034     auto ptr = GetIpcRequestFunc(REGISTER_DEV_STATE_CALLBACK);
1035     ASSERT_TRUE(ptr != nullptr);
1036 
1037     MessageParcel data;
1038     auto req = std::make_shared<IpcReq>();
1039     std::string pkgName = "ohos.dm.test";
1040     req->SetPkgName(pkgName);
1041     auto ret = ptr(req, data);
1042     ASSERT_EQ(DM_OK, ret);
1043 }
1044 
1045 HWTEST_F(IpcCmdParserClientTest, ReadResponseFunc_035, testing::ext::TestSize.Level0)
1046 {
1047     auto ptr = GetResponseFunc(REQUEST_CREDENTIAL);
1048     ASSERT_TRUE(ptr != nullptr);
1049 
1050     int32_t ret = ERR_DM_UNSUPPORTED_IPC_COMMAND;
1051     MessageParcel data;
1052     std::string credentialReasult = "The credential is created.";
1053     data.WriteInt32(DM_OK);
1054     data.WriteString(credentialReasult);
1055     auto ipcRspInsance = std::make_shared<IpcSetCredentialRsp>();
1056     ret = ptr(data, ipcRspInsance);
1057     ASSERT_EQ(ret, DM_OK);
1058 }
1059 
1060 HWTEST_F(IpcCmdParserClientTest, ReadResponseFunc_036, testing::ext::TestSize.Level0)
1061 {
1062     auto ptr = GetResponseFunc(SERVER_GET_DMFA_INFO);
1063     ASSERT_TRUE(ptr != nullptr);
1064 
1065     int32_t ret = ERR_DM_UNSUPPORTED_IPC_COMMAND;
1066     MessageParcel data;
1067     std::string credentialReasult = "The credential is created.";
1068     data.WriteInt32(DM_OK);
1069     data.WriteString(credentialReasult);
1070     auto ipcRspInsance = std::make_shared<IpcSetCredentialRsp>();
1071     ret = ptr(data, ipcRspInsance);
1072     ASSERT_EQ(ret, DM_OK);
1073 }
1074 
1075 HWTEST_F(IpcCmdParserClientTest, ReadResponseFunc_037, testing::ext::TestSize.Level0)
1076 {
1077     auto ptr = GetResponseFunc(IMPORT_CREDENTIAL);
1078     ASSERT_TRUE(ptr != nullptr);
1079 
1080     JsonObject jsonObject;
1081     jsonObject[DM_CREDENTIAL_TYPE] = DM_TYPE_OH;
1082     std::string message = SafetyDump(jsonObject);
1083 
1084     MessageParcel data;
1085     data.WriteString(message);
1086     data.WriteInt32(DM_OK);
1087     auto ipcRspInsance = std::make_shared<IpcSetCredentialRsp>();
1088     ASSERT_EQ(ptr(data, ipcRspInsance), DM_OK);
1089 }
1090 
1091 HWTEST_F(IpcCmdParserClientTest, ReadResponseFunc_038, testing::ext::TestSize.Level0)
1092 {
1093     auto ptr = GetResponseFunc(IMPORT_CREDENTIAL);
1094     ASSERT_TRUE(ptr != nullptr);
1095 
1096     std::string credential = "git:https://gitee.com";
1097     JsonObject jsonObject;
1098     jsonObject[DM_CREDENTIAL_TYPE] = DM_TYPE_MINE;
1099     jsonObject[DM_CREDENTIAL_RETURNJSONSTR] = credential;
1100     std::string message = SafetyDump(jsonObject);
1101 
1102     MessageParcel data;
1103     data.WriteString(message);
1104     data.WriteInt32(DM_OK);
1105     auto ipcRspInsance = std::make_shared<IpcSetCredentialRsp>();
1106     ASSERT_EQ(ptr(data, ipcRspInsance), DM_OK);
1107 }
1108 
1109 HWTEST_F(IpcCmdParserClientTest, ReadResponseFunc_039, testing::ext::TestSize.Level0)
1110 {
1111     auto ptr = GetResponseFunc(DELETE_CREDENTIAL);
1112     ASSERT_TRUE(ptr != nullptr);
1113 
1114     JsonObject jsonObject;
1115     jsonObject[DM_CREDENTIAL_TYPE] = DM_TYPE_OH;
1116     std::string message = SafetyDump(jsonObject);
1117 
1118     MessageParcel data;
1119     data.WriteString(message);
1120     data.WriteInt32(DM_OK);
1121     auto ipcRspInsance = std::make_shared<IpcSetCredentialRsp>();
1122     ASSERT_EQ(ptr(data, ipcRspInsance), DM_OK);
1123 }
1124 
1125 HWTEST_F(IpcCmdParserClientTest, ReadResponseFunc_040, testing::ext::TestSize.Level0)
1126 {
1127     auto ptr = GetResponseFunc(DELETE_CREDENTIAL);
1128     ASSERT_TRUE(ptr != nullptr);
1129 
1130     std::string credential = "git:https://gitee.com";
1131     JsonObject jsonObject;
1132     jsonObject[DM_CREDENTIAL_TYPE] = DM_TYPE_MINE;
1133     jsonObject[DM_CREDENTIAL_RETURNJSONSTR] = credential;
1134     std::string message = SafetyDump(jsonObject);
1135 
1136     MessageParcel data;
1137     data.WriteString(message);
1138     data.WriteInt32(DM_OK);
1139     auto ipcRspInsance = std::make_shared<IpcSetCredentialRsp>();
1140     ASSERT_EQ(ptr(data, ipcRspInsance), DM_OK);
1141 }
1142 
1143 HWTEST_F(IpcCmdParserClientTest, ReadResponseFunc_041, testing::ext::TestSize.Level0)
1144 {
1145     auto ptr = GetResponseFunc(GENERATE_ENCRYPTED_UUID);
1146     ASSERT_TRUE(ptr != nullptr);
1147 
1148     std::string uuid = "123456789";
1149     MessageParcel data;
1150     data.WriteInt32(DM_OK);
1151     data.WriteString(uuid);
1152     auto ipcRspInsance = std::make_shared<IpcGetInfoByNetWorkRsp>();
1153     ASSERT_EQ(ptr(data, ipcRspInsance), DM_OK);
1154 }
1155 
1156 HWTEST_F(IpcCmdParserClientTest, ReadResponseFunc_042, testing::ext::TestSize.Level0)
1157 {
1158     auto ptr = GetResponseFunc(BIND_DEVICE);
1159     ASSERT_TRUE(ptr != nullptr);
1160 
1161     MessageParcel data;
1162     data.WriteInt32(DM_OK);
1163     auto ipcRspInsance = std::make_shared<IpcRsp>();
1164     ASSERT_EQ(ptr(data, ipcRspInsance), DM_OK);
1165 }
1166 
1167 HWTEST_F(IpcCmdParserClientTest, ReadResponseFunc_043, testing::ext::TestSize.Level0)
1168 {
1169     auto ptr = GetResponseFunc(GET_NETWORKTYPE_BY_NETWORK);
1170     ASSERT_TRUE(ptr != nullptr);
1171 
1172     int32_t wifi = 1;
1173     MessageParcel data;
1174     data.WriteInt32(DM_OK);
1175     data.WriteInt32(wifi);
1176     auto ipcRspInsance = std::make_shared<IpcGetInfoByNetWorkRsp>();
1177     ASSERT_EQ(ptr(data, ipcRspInsance), DM_OK);
1178 }
1179 
1180 HWTEST_F(IpcCmdParserClientTest, ReadResponseFunc_044, testing::ext::TestSize.Level0)
1181 {
1182     auto ptr = GetResponseFunc(STOP_AUTHENTICATE_DEVICE);
1183     ASSERT_TRUE(ptr != nullptr);
1184 
1185     int32_t wifi = 1;
1186     MessageParcel data;
1187     data.WriteInt32(DM_OK);
1188     auto ipcRspInsance = std::make_shared<IpcRsp>();
1189     ASSERT_EQ(ptr(data, ipcRspInsance), DM_OK);
1190 }
1191 
1192 HWTEST_F(IpcCmdParserClientTest, ReadResponseFunc_045, testing::ext::TestSize.Level0)
1193 {
1194     auto ptr = GetResponseFunc(GET_SECURITY_LEVEL);
1195     ASSERT_TRUE(ptr != nullptr);
1196 
1197     int32_t securityLevel = 1;
1198     MessageParcel data;
1199     data.WriteInt32(DM_OK);
1200     data.WriteInt32(securityLevel);
1201     auto ipcRspInsance = std::make_shared<IpcGetInfoByNetWorkRsp>();
1202     ASSERT_EQ(ptr(data, ipcRspInsance), DM_OK);
1203 }
1204 
1205 HWTEST_F(IpcCmdParserClientTest, ReadResponseFunc_046, testing::ext::TestSize.Level0)
1206 {
1207     auto ptr = GetResponseFunc(GET_DEVICE_SCREEN_STATUS);
1208     ASSERT_TRUE(ptr != nullptr);
1209 
1210     int32_t screenStatus = 1;
1211     MessageParcel data;
1212     data.WriteInt32(DM_OK);
1213     data.WriteInt32(screenStatus);
1214     auto ipcRspInsance = std::make_shared<IpcGetDeviceScreenStatusRsp>();
1215     ASSERT_EQ(ptr(data, ipcRspInsance), DM_OK);
1216 }
1217 
1218 HWTEST_F(IpcCmdParserClientTest, ReadResponseFunc_047, testing::ext::TestSize.Level0)
1219 {
1220     auto ptr = GetResponseFunc(GET_NETWORKID_BY_UDID);
1221     ASSERT_TRUE(ptr != nullptr);
1222 
1223     std::string networkId = "3a80******fd94";
1224     MessageParcel data;
1225     data.WriteInt32(DM_OK);
1226     data.WriteString(networkId);
1227     auto ipcRspInsance = std::make_shared<IpcGetInfoByNetWorkRsp>();
1228     ASSERT_EQ(ptr(data, ipcRspInsance), DM_OK);
1229 }
1230 
1231 HWTEST_F(IpcCmdParserClientTest, ReadResponseFunc_048, testing::ext::TestSize.Level0)
1232 {
1233     auto ptr = GetResponseFunc(REGISTER_DEV_STATE_CALLBACK);
1234     ASSERT_TRUE(ptr != nullptr);
1235 
1236     std::string networkId = "3a80******fd94";
1237     MessageParcel data;
1238     data.WriteInt32(DM_OK);
1239     data.WriteString(networkId);
1240     auto ipcRspInsance = std::make_shared<IpcRsp>();
1241     ASSERT_EQ(ptr(data, ipcRspInsance), DM_OK);
1242 }
1243 
1244 HWTEST_F(IpcCmdParserClientTest, TEST_IPC_REQUEST_NULL_001, testing::ext::TestSize.Level2)
1245 {
1246     EXPECT_EQ(TestIpcRequestNull(REGISTER_DEVICE_MANAGER_LISTENER), ERR_DM_FAILED);
1247     EXPECT_EQ(TestIpcRequestNull(UNREGISTER_DEVICE_MANAGER_LISTENER), ERR_DM_FAILED);
1248     EXPECT_EQ(TestIpcRequestNull(GET_TRUST_DEVICE_LIST), ERR_DM_FAILED);
1249     EXPECT_EQ(TestIpcRequestNull(GET_DEVICE_INFO), ERR_DM_FAILED);
1250     EXPECT_EQ(TestIpcRequestNull(GET_LOCAL_DEVICE_INFO), ERR_DM_FAILED);
1251     EXPECT_EQ(TestIpcRequestNull(GET_UDID_BY_NETWORK), ERR_DM_FAILED);
1252     EXPECT_EQ(TestIpcRequestNull(GET_UUID_BY_NETWORK), ERR_DM_FAILED);
1253     EXPECT_EQ(TestIpcRequestNull(PUBLISH_DEVICE_DISCOVER), ERR_DM_FAILED);
1254     EXPECT_EQ(TestIpcRequestNull(UNPUBLISH_DEVICE_DISCOVER), ERR_DM_FAILED);
1255     EXPECT_EQ(TestIpcRequestNull(AUTHENTICATE_DEVICE), ERR_DM_FAILED);
1256     EXPECT_EQ(TestIpcRequestNull(UNAUTHENTICATE_DEVICE), ERR_DM_FAILED);
1257     EXPECT_EQ(TestIpcRequestNull(SERVER_USER_AUTH_OPERATION), ERR_DM_FAILED);
1258     EXPECT_EQ(TestIpcRequestNull(REQUEST_CREDENTIAL), ERR_DM_FAILED);
1259     EXPECT_EQ(TestIpcRequestNull(SERVER_GET_DMFA_INFO), ERR_DM_FAILED);
1260     EXPECT_EQ(TestIpcRequestNull(IMPORT_CREDENTIAL), ERR_DM_FAILED);
1261     EXPECT_EQ(TestIpcRequestNull(DELETE_CREDENTIAL), ERR_DM_FAILED);
1262     EXPECT_EQ(TestIpcRequestNull(REGISTER_CREDENTIAL_CALLBACK), ERR_DM_FAILED);
1263     EXPECT_EQ(TestIpcRequestNull(UNREGISTER_CREDENTIAL_CALLBACK), ERR_DM_FAILED);
1264     EXPECT_EQ(TestIpcRequestNull(NOTIFY_EVENT), ERR_DM_FAILED);
1265     EXPECT_EQ(TestIpcRequestNull(GET_ENCRYPTED_UUID_BY_NETWOEKID), ERR_DM_FAILED);
1266     EXPECT_EQ(TestIpcRequestNull(GENERATE_ENCRYPTED_UUID), ERR_DM_FAILED);
1267     EXPECT_EQ(TestIpcRequestNull(BIND_DEVICE), ERR_DM_FAILED);
1268     EXPECT_EQ(TestIpcRequestNull(UNBIND_DEVICE), ERR_DM_FAILED);
1269     EXPECT_EQ(TestIpcRequestNull(GET_NETWORKTYPE_BY_NETWORK), ERR_DM_FAILED);
1270     EXPECT_EQ(TestIpcRequestNull(REGISTER_UI_STATE_CALLBACK), ERR_DM_FAILED);
1271     EXPECT_EQ(TestIpcRequestNull(UNREGISTER_UI_STATE_CALLBACK), ERR_DM_FAILED);
1272     EXPECT_EQ(TestIpcRequestNull(IMPORT_AUTH_CODE), ERR_DM_FAILED);
1273     EXPECT_EQ(TestIpcRequestNull(REGISTER_DISCOVERY_CALLBACK), ERR_DM_FAILED);
1274     EXPECT_EQ(TestIpcRequestNull(START_DISCOVERING), ERR_DM_FAILED);
1275     EXPECT_EQ(TestIpcRequestNull(STOP_DISCOVERING), ERR_DM_FAILED);
1276     EXPECT_EQ(TestIpcRequestNull(BIND_TARGET), ERR_DM_FAILED);
1277     EXPECT_EQ(TestIpcRequestNull(UNBIND_TARGET), ERR_DM_FAILED);
1278 }
1279 
1280 HWTEST_F(IpcCmdParserClientTest, TEST_IPC_REQUEST_NULL_002, testing::ext::TestSize.Level2)
1281 {
1282     EXPECT_EQ(TestIpcRequestNull(REGISTER_PIN_HOLDER_CALLBACK), ERR_DM_FAILED);
1283     EXPECT_EQ(TestIpcRequestNull(CREATE_PIN_HOLDER), ERR_DM_FAILED);
1284     EXPECT_EQ(TestIpcRequestNull(DESTROY_PIN_HOLDER), ERR_DM_FAILED);
1285     EXPECT_EQ(TestIpcRequestNull(SET_DN_POLICY), ERR_DM_FAILED);
1286     EXPECT_EQ(TestIpcRequestNull(STOP_AUTHENTICATE_DEVICE), ERR_DM_FAILED);
1287     EXPECT_EQ(TestIpcRequestNull(DP_ACL_ADD), ERR_DM_FAILED);
1288     EXPECT_EQ(TestIpcRequestNull(GET_SECURITY_LEVEL), ERR_DM_FAILED);
1289     EXPECT_EQ(TestIpcRequestNull(IS_SAME_ACCOUNT), ERR_DM_FAILED);
1290     EXPECT_EQ(TestIpcRequestNull(CHECK_API_PERMISSION), ERR_DM_FAILED);
1291     EXPECT_EQ(TestIpcRequestNull(CHECK_ACCESS_CONTROL), ERR_DM_FAILED);
1292     EXPECT_EQ(TestIpcRequestNull(CHECK_SAME_ACCOUNT), ERR_DM_FAILED);
1293     EXPECT_EQ(TestIpcRequestNull(SHIFT_LNN_GEAR), ERR_DM_FAILED);
1294     EXPECT_EQ(TestIpcRequestNull(GET_DEVICE_SCREEN_STATUS), ERR_DM_FAILED);
1295     EXPECT_EQ(TestIpcRequestNull(GET_ANONY_LOCAL_UDID), ERR_DM_FAILED);
1296     EXPECT_EQ(TestIpcRequestNull(GET_NETWORKID_BY_UDID), ERR_DM_FAILED);
1297     EXPECT_EQ(TestIpcRequestNull(REGISTER_DEV_STATE_CALLBACK), ERR_DM_FAILED);
1298     EXPECT_EQ(TestIpcRequestNull(SYNC_CALLBACK), ERR_DM_FAILED);
1299 }
1300 
1301 HWTEST_F(IpcCmdParserClientTest, TEST_IPC_REQUEST_NULL_003, testing::ext::TestSize.Level2)
1302 {
1303     EXPECT_EQ(TestIpcRequestNull(REG_LOCALSERVICE_INFO), ERR_DM_FAILED);
1304     EXPECT_EQ(TestIpcRequestNull(UNREG_LOCALSERVICE_INFO), ERR_DM_FAILED);
1305     EXPECT_EQ(TestIpcRequestNull(UPDATE_LOCALSERVICE_INFO), ERR_DM_FAILED);
1306     EXPECT_EQ(TestIpcRequestNull(GET_SERVICEINFO_BYBUNDLENAME_PINEXCHANGETYPE), ERR_DM_FAILED);
1307 }
1308 
1309 HWTEST_F(IpcCmdParserClientTest, TEST_READ_RESPONSE_NULL_001, testing::ext::TestSize.Level2)
1310 {
1311     EXPECT_EQ(TestReadResponseRspNull(UNREGISTER_DEVICE_MANAGER_LISTENER), ERR_DM_FAILED);
1312     EXPECT_EQ(TestReadResponseRspNull(GET_DEVICE_INFO), ERR_DM_FAILED);
1313     EXPECT_EQ(TestReadResponseRspNull(GET_LOCAL_DEVICE_INFO), ERR_DM_FAILED);
1314     EXPECT_EQ(TestReadResponseRspNull(GET_UDID_BY_NETWORK), ERR_DM_FAILED);
1315     EXPECT_EQ(TestReadResponseRspNull(GET_UUID_BY_NETWORK), ERR_DM_FAILED);
1316     EXPECT_EQ(TestReadResponseRspNull(PUBLISH_DEVICE_DISCOVER), ERR_DM_FAILED);
1317     EXPECT_EQ(TestReadResponseRspNull(UNPUBLISH_DEVICE_DISCOVER), ERR_DM_FAILED);
1318     EXPECT_EQ(TestReadResponseRspNull(AUTHENTICATE_DEVICE), ERR_DM_FAILED);
1319     EXPECT_EQ(TestReadResponseRspNull(UNAUTHENTICATE_DEVICE), ERR_DM_FAILED);
1320     EXPECT_EQ(TestReadResponseRspNull(SERVER_USER_AUTH_OPERATION), ERR_DM_FAILED);
1321     EXPECT_EQ(TestReadResponseRspNull(REQUEST_CREDENTIAL), ERR_DM_FAILED);
1322     EXPECT_EQ(TestReadResponseRspNull(SERVER_GET_DMFA_INFO), ERR_DM_FAILED);
1323     EXPECT_EQ(TestReadResponseRspNull(IMPORT_CREDENTIAL), ERR_DM_FAILED);
1324     EXPECT_EQ(TestReadResponseRspNull(DELETE_CREDENTIAL), ERR_DM_FAILED);
1325     EXPECT_EQ(TestReadResponseRspNull(REGISTER_CREDENTIAL_CALLBACK), ERR_DM_FAILED);
1326     EXPECT_EQ(TestReadResponseRspNull(UNREGISTER_CREDENTIAL_CALLBACK), ERR_DM_FAILED);
1327     EXPECT_EQ(TestReadResponseRspNull(NOTIFY_EVENT), ERR_DM_FAILED);
1328     EXPECT_EQ(TestReadResponseRspNull(GET_ENCRYPTED_UUID_BY_NETWOEKID), ERR_DM_FAILED);
1329     EXPECT_EQ(TestReadResponseRspNull(GENERATE_ENCRYPTED_UUID), ERR_DM_FAILED);
1330     EXPECT_EQ(TestReadResponseRspNull(BIND_DEVICE), ERR_DM_FAILED);
1331     EXPECT_EQ(TestReadResponseRspNull(UNBIND_DEVICE), ERR_DM_FAILED);
1332     EXPECT_EQ(TestReadResponseRspNull(GET_NETWORKTYPE_BY_NETWORK), ERR_DM_FAILED);
1333     EXPECT_EQ(TestReadResponseRspNull(REGISTER_UI_STATE_CALLBACK), ERR_DM_FAILED);
1334     EXPECT_EQ(TestReadResponseRspNull(UNREGISTER_UI_STATE_CALLBACK), ERR_DM_FAILED);
1335     EXPECT_EQ(TestReadResponseRspNull(IMPORT_AUTH_CODE), ERR_DM_FAILED);
1336     EXPECT_EQ(TestReadResponseRspNull(EXPORT_AUTH_CODE), ERR_DM_FAILED);
1337     EXPECT_EQ(TestReadResponseRspNull(REGISTER_DISCOVERY_CALLBACK), ERR_DM_FAILED);
1338     EXPECT_EQ(TestReadResponseRspNull(START_DISCOVERING), ERR_DM_FAILED);
1339     EXPECT_EQ(TestReadResponseRspNull(STOP_DISCOVERING), ERR_DM_FAILED);
1340     EXPECT_EQ(TestReadResponseRspNull(REGISTER_PIN_HOLDER_CALLBACK), ERR_DM_FAILED);
1341     EXPECT_EQ(TestReadResponseRspNull(CREATE_PIN_HOLDER), ERR_DM_FAILED);
1342     EXPECT_EQ(TestReadResponseRspNull(DESTROY_PIN_HOLDER), ERR_DM_FAILED);
1343     EXPECT_EQ(TestReadResponseRspNull(STOP_AUTHENTICATE_DEVICE), ERR_DM_FAILED);
1344     EXPECT_EQ(TestReadResponseRspNull(GET_SECURITY_LEVEL), ERR_DM_FAILED);
1345     EXPECT_EQ(TestReadResponseRspNull(CHECK_ACCESS_CONTROL), ERR_DM_FAILED);
1346     EXPECT_EQ(TestReadResponseRspNull(GET_DEVICE_SCREEN_STATUS), ERR_DM_FAILED);
1347     EXPECT_EQ(TestReadResponseRspNull(GET_ANONY_LOCAL_UDID), ERR_DM_FAILED);
1348     EXPECT_EQ(TestReadResponseRspNull(GET_NETWORKID_BY_UDID), ERR_DM_FAILED);
1349     EXPECT_EQ(TestReadResponseRspNull(REGISTER_DEV_STATE_CALLBACK), ERR_DM_FAILED);
1350     EXPECT_EQ(TestReadResponseRspNull(SYNC_CALLBACK), ERR_DM_FAILED);
1351 }
1352 
1353 HWTEST_F(IpcCmdParserClientTest, TEST_READ_RESPONSE_NULL_002, testing::ext::TestSize.Level2)
1354 {
1355     EXPECT_EQ(TestReadResponseRspNull(REG_LOCALSERVICE_INFO), ERR_DM_FAILED);
1356     EXPECT_EQ(TestReadResponseRspNull(UNREG_LOCALSERVICE_INFO), ERR_DM_FAILED);
1357     EXPECT_EQ(TestReadResponseRspNull(UPDATE_LOCALSERVICE_INFO), ERR_DM_FAILED);
1358     EXPECT_EQ(TestReadResponseRspNull(GET_SERVICEINFO_BYBUNDLENAME_PINEXCHANGETYPE), ERR_DM_FAILED);
1359 }
1360 } // namespace
1361 } // namespace DistributedHardware
1362 } // namespace OHOS