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 "dsched_continue_event_test.h"
17
18 #include "distributed_sched_utils.h"
19 #include "dms_constant.h"
20 #include "dsched_continue_event.h"
21 #include "dtbschedmgr_log.h"
22 #include "test_log.h"
23
24 using namespace testing;
25 using namespace testing::ext;
26
27 namespace OHOS {
28 namespace DistributedSchedule {
29 const char* EXTRO_INFO_JSON_KEY_ACCESS_TOKEN = "accessTokenID";
30 const char* DMS_VERSION_ID = "dmsVersion";
31
SetUpTestCase()32 void DSchedContinueEventTest::SetUpTestCase()
33 {
34 DTEST_LOG << "DSchedContinueEventTest::SetUpTestCase" << std::endl;
35 }
36
TearDownTestCase()37 void DSchedContinueEventTest::TearDownTestCase()
38 {
39 DTEST_LOG << "DSchedContinueEventTest::TearDownTestCase" << std::endl;
40 }
41
TearDown()42 void DSchedContinueEventTest::TearDown()
43 {
44 DTEST_LOG << "DSchedContinueEventTest::TearDown" << std::endl;
45 }
46
SetUp()47 void DSchedContinueEventTest::SetUp()
48 {
49 DTEST_LOG << "DSchedContinueEventTest::SetUp" << std::endl;
50 }
51
52 /**
53 * @tc.name: DSchedContinueEventTest_001_1
54 * @tc.desc: DSchedContinueCmdBase Marshal and Unmarshal
55 * @tc.type: FUNC
56 */
57 HWTEST_F(DSchedContinueEventTest, DSchedContinueEventTest_001_1, TestSize.Level0)
58 {
59 DTEST_LOG << "DSchedContinueEventTest DSchedContinueEventTest_001_1 begin" << std::endl;
60 DSchedContinueCmdBase cmd;
61 cmd.version_ = 0;
62 cmd.serviceType_ = 0;
63 cmd.subServiceType_ = 0;
64 cmd.command_ = 0;
65 cmd.srcDeviceId_ = "123";
66 cmd.srcBundleName_ = "test";
67 cmd.dstDeviceId_ = "test";
68 cmd.dstBundleName_ = "test";
69 cmd.continueType_ = "test";
70 cmd.continueByType_ = 0;
71 cmd.sourceMissionId_ = 0;
72 cmd.dmsVersion_ = 0;
73
74 std::string cmdStr;
75 int32_t ret = cmd.Marshal(cmdStr);
76 EXPECT_EQ(ret, ERR_OK);
77 ret = cmd.Unmarshal(cmdStr);
78 EXPECT_EQ(ret, ERR_OK);
79 DTEST_LOG << "DSchedContinueEventTest DSchedContinueEventTest_001_1 end ret:" << ret << std::endl;
80 }
81
82 /**
83 * @tc.name: DSchedContinueEventTest_002_1
84 * @tc.desc: DSchedContinueStartCmd Marshal and Unmarshal
85 * @tc.type: FUNC
86 */
87 HWTEST_F(DSchedContinueEventTest, DSchedContinueEventTest_002_1, TestSize.Level0)
88 {
89 DTEST_LOG << "DSchedContinueEventTest DSchedContinueEventTest_002_1 begin" << std::endl;
90 DSchedContinueStartCmd cmd;
91 cmd.version_ = 0;
92 cmd.serviceType_ = 0;
93 cmd.subServiceType_ = 0;
94 cmd.command_ = 0;
95 cmd.srcDeviceId_ = "123";
96 cmd.srcBundleName_ = "test";
97 cmd.dstDeviceId_ = "test";
98 cmd.dstBundleName_ = "test";
99 cmd.continueType_ = "test";
100 cmd.continueByType_ = 0;
101 cmd.sourceMissionId_ = 0;
102 cmd.dmsVersion_ = 0;
103
104 cmd.direction_ = 0;
105 cmd.appVersion_ = 0;
106 DistributedWantParams wantParams;
107 cmd.wantParams_ = wantParams;
108
109 std::string cmdStr;
110 int32_t ret = cmd.Marshal(cmdStr);
111 EXPECT_EQ(ret, ERR_OK);
112 ret = cmd.Unmarshal(cmdStr);
113 EXPECT_EQ(ret, ERR_OK);
114 DTEST_LOG << "DSchedContinueEventTest DSchedContinueEventTest_002_1 end ret:" << ret << std::endl;
115 }
116
117 /**
118 * @tc.name: DSchedContinueEventTest_003_1
119 * @tc.desc: DSchedContinueDataCmd Marshal and Unmarshal
120 * @tc.type: FUNC
121 */
122 HWTEST_F(DSchedContinueEventTest, DSchedContinueEventTest_003_1, TestSize.Level0)
123 {
124 DTEST_LOG << "DSchedContinueEventTest DSchedContinueEventTest_003_1 begin" << std::endl;
125 DSchedContinueDataCmd cmd;
126 cmd.version_ = 0;
127 cmd.serviceType_ = 0;
128 cmd.subServiceType_ = 0;
129 cmd.command_ = 0;
130 cmd.srcDeviceId_ = "123";
131 cmd.srcBundleName_ = "test";
132 cmd.dstDeviceId_ = "test";
133 cmd.dstBundleName_ = "test";
134 cmd.continueType_ = "test";
135 cmd.continueByType_ = 0;
136 cmd.sourceMissionId_ = 0;
137 cmd.dmsVersion_ = 0;
138
139 OHOS::AAFwk::Want want;
140 cmd.want_ = want;
141 AppExecFwk::CompatibleAbilityInfo abilityInfo;
142 cmd.abilityInfo_ = abilityInfo;
143 cmd.requestCode_ = 0;
144 CallerInfo callerInfo;
145 cmd.callerInfo_ = callerInfo;
146 IDistributedSched::AccountInfo accountInfo;
147 cmd.accountInfo_ = accountInfo;
148
149 std::string cmdStr;
150 int32_t ret = cmd.Marshal(cmdStr);
151 EXPECT_EQ(ret, ERR_OK);
152 ret = cmd.Unmarshal(cmdStr);
153 EXPECT_EQ(ret, ERR_OK);
154 DTEST_LOG << "DSchedContinueEventTest DSchedContinueEventTest_003_1 end ret:" << ret << std::endl;
155 }
156
157 /**
158 * @tc.name: DSchedContinueEventTest_004_1
159 * @tc.desc: DSchedContinueReplyCmd Marshal and Unmarshal
160 * @tc.type: FUNC
161 */
162 HWTEST_F(DSchedContinueEventTest, DSchedContinueEventTest_004_1, TestSize.Level0)
163 {
164 DTEST_LOG << "DSchedContinueEventTest DSchedContinueEventTest_004_1 begin" << std::endl;
165 DSchedContinueReplyCmd cmd;
166 cmd.version_ = 0;
167 cmd.serviceType_ = 0;
168 cmd.subServiceType_ = 0;
169 cmd.command_ = 0;
170 cmd.srcDeviceId_ = "123";
171 cmd.srcBundleName_ = "test";
172 cmd.dstDeviceId_ = "test";
173 cmd.dstBundleName_ = "test";
174 cmd.continueType_ = "test";
175 cmd.continueByType_ = 0;
176 cmd.sourceMissionId_ = 0;
177 cmd.dmsVersion_ = 0;
178
179 cmd.replyCmd_ = 0;
180 cmd.appVersion_ = 0;
181 cmd.result_ = 0;
182 cmd.reason_ = "reason";
183
184 std::string cmdStr;
185 int32_t ret = cmd.Marshal(cmdStr);
186 EXPECT_EQ(ret, ERR_OK);
187 ret = cmd.Unmarshal(cmdStr);
188 EXPECT_EQ(ret, ERR_OK);
189 DTEST_LOG << "DSchedContinueEventTest DSchedContinueEventTest_004_1 end ret:" << ret << std::endl;
190 }
191
192 /**
193 * @tc.name: DSchedContinueEventTest_005_1
194 * @tc.desc: DSchedContinueEndCmd Marshal and Unmarshal
195 * @tc.type: FUNC
196 */
197 HWTEST_F(DSchedContinueEventTest, DSchedContinueEventTest_005_1, TestSize.Level0)
198 {
199 DTEST_LOG << "DSchedContinueEventTest DSchedContinueEventTest_005_1 begin" << std::endl;
200 DSchedContinueEndCmd cmd;
201 cmd.version_ = 0;
202 cmd.serviceType_ = 0;
203 cmd.subServiceType_ = 0;
204 cmd.command_ = 0;
205 cmd.srcDeviceId_ = "123";
206 cmd.srcBundleName_ = "test";
207 cmd.dstDeviceId_ = "test";
208 cmd.dstBundleName_ = "test";
209 cmd.continueType_ = "test";
210 cmd.continueByType_ = 0;
211 cmd.sourceMissionId_ = 0;
212 cmd.dmsVersion_ = 0;
213
214 cmd.result_ = 0;
215
216 std::string cmdStr;
217 int32_t ret = cmd.Marshal(cmdStr);
218 EXPECT_EQ(ret, ERR_OK);
219 ret = cmd.Unmarshal(cmdStr);
220 EXPECT_EQ(ret, ERR_OK);
221 DTEST_LOG << "DSchedContinueEventTest DSchedContinueEventTest_005_1 end ret:" << ret << std::endl;
222 }
223
224 /**
225 * @tc.name: DSchedContinueEventTest_006_1
226 * @tc.desc: DSchedContinueDataCmd Unmarshal
227 * @tc.type: FUNC
228 */
229 HWTEST_F(DSchedContinueEventTest, DSchedContinueEventTest_006_1, TestSize.Level0)
230 {
231 DTEST_LOG << "DSchedContinueEventTest DSchedContinueEventTest_006_1 begin" << std::endl;
232 DSchedContinueDataCmd cmd;
233 std::string cmdStr = "test";
234 auto ret = cmd.Unmarshal(cmdStr);
235 EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
236
237 cJSON *rootValue = cJSON_CreateObject();
238 ASSERT_NE(rootValue, nullptr);
239 cJSON_AddNumberToObject(rootValue, "BaseCmd", 0);
240 char *data = cJSON_Print(rootValue);
241 if (data == nullptr) {
242 cJSON_Delete(rootValue);
243 ASSERT_FALSE(true);
244 }
245 cmdStr = std::string(data);
246 ret = cmd.Unmarshal(cmdStr);
247 EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
248 cJSON_free(data);
249
250 cJSON_DeleteItemFromObject(rootValue, "BaseCmd");
251 cJSON_AddStringToObject(rootValue, "BaseCmd", "test");
252 data = cJSON_Print(rootValue);
253 if (data == nullptr) {
254 cJSON_Delete(rootValue);
255 ASSERT_FALSE(true);
256 }
257 cmdStr = std::string(data);
258 ret = cmd.Unmarshal(cmdStr);
259 EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
260 cJSON_Delete(rootValue);
261 cJSON_free(data);
262 DTEST_LOG << "DSchedContinueEventTest DSchedContinueEventTest_006_1 end ret:" << ret << std::endl;
263 }
264
265 /**
266 * @tc.name: DSchedContinueEventTest_007_1
267 * @tc.desc: DSchedContinueDataCmd Unmarshal
268 * @tc.type: FUNC
269 */
270 HWTEST_F(DSchedContinueEventTest, DSchedContinueEventTest_007_1, TestSize.Level0)
271 {
272 DTEST_LOG << "DSchedContinueEventTest DSchedContinueEventTest_007_1 begin" << std::endl;
273 DSchedContinueDataCmd cmd;
274 cJSON *rootValue = cJSON_CreateObject();
275 ASSERT_NE(rootValue, nullptr);
276 std::string baseJsonStr;
277 DSchedContinueCmdBase baseCmd;
278 if (baseCmd.Marshal(baseJsonStr) != ERR_OK) {
279 cJSON_Delete(rootValue);
280 ASSERT_FALSE(true);
281 }
282
283 cJSON_AddStringToObject(rootValue, "BaseCmd", baseJsonStr.c_str());
284 Parcel wantParcel;
285 OHOS::AAFwk::Want want;
286 if (!want.Marshalling(wantParcel)) {
287 cJSON_Delete(rootValue);
288 ASSERT_FALSE(true);
289 }
290 std::string wantStr = ParcelToBase64Str(wantParcel);
291 cJSON_AddStringToObject(rootValue, "Want", wantStr.c_str());
292 cJSON_AddNumberToObject(rootValue, "AbilityInfo", 0);
293 auto data = cJSON_Print(rootValue);
294 if (data == nullptr) {
295 cJSON_Delete(rootValue);
296 ASSERT_FALSE(true);
297 }
298 auto cmdStr = std::string(data);
299 auto ret = cmd.Unmarshal(cmdStr);
300 EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
301 cJSON_free(data);
302
303 cJSON_DeleteItemFromObject(rootValue, "AbilityInfo");
304 cJSON_AddStringToObject(rootValue, "AbilityInfo", "test");
305 data = cJSON_Print(rootValue);
306 if (data == nullptr) {
307 cJSON_Delete(rootValue);
308 ASSERT_FALSE(true);
309 }
310 cmdStr = std::string(data);
311 ret = cmd.Unmarshal(cmdStr);
312 EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
313 cJSON_Delete(rootValue);
314 DTEST_LOG << "DSchedContinueEventTest DSchedContinueEventTest_007_1 end ret:" << ret << std::endl;
315 }
316
317 /**
318 * @tc.name: DSchedContinueEventTest_011_1
319 * @tc.desc: DSchedContinueDataCmd UnmarshalWantParcel
320 * @tc.type: FUNC
321 */
322 HWTEST_F(DSchedContinueEventTest, DSchedContinueEventTest_011_1, TestSize.Level0)
323 {
324 DTEST_LOG << "DSchedContinueEventTest DSchedContinueEventTest_011_1 begin" << std::endl;
325 cJSON *rootValue = nullptr;
326 DSchedContinueDataCmd cmd;
327 auto ret = cmd.UnmarshalWantParcel(rootValue);
328 EXPECT_FALSE(ret);
329
330 rootValue = cJSON_CreateObject();
331 ASSERT_NE(rootValue, nullptr);
332 ret = cmd.UnmarshalWantParcel(rootValue);
333 EXPECT_FALSE(ret);
334
335 cJSON_AddNumberToObject(rootValue, "Want", 0);
336 ret = cmd.UnmarshalWantParcel(rootValue);
337 EXPECT_FALSE(ret);
338
339 cJSON_DeleteItemFromObject(rootValue, "Want");
340 cJSON_AddStringToObject(rootValue, "Want", "test");
341 ret = cmd.UnmarshalWantParcel(rootValue);
342 EXPECT_FALSE(ret);
343
344 cJSON_DeleteItemFromObject(rootValue, "Want");
345 Parcel wantParcel;
346 if (!cmd.want_.Marshalling(wantParcel)) {
347 cJSON_Delete(rootValue);
348 ASSERT_FALSE(true);
349 }
350 std::string wantStr = ParcelToBase64Str(wantParcel);
351 cJSON_AddStringToObject(rootValue, "Want", wantStr.c_str());
352 ret = cmd.UnmarshalWantParcel(rootValue);
353 EXPECT_TRUE(ret);
354 cJSON_Delete(rootValue);
355 DTEST_LOG << "DSchedContinueEventTest DSchedContinueEventTest_008_1 end ret:" << ret << std::endl;
356 }
357
358 /**
359 * @tc.name: DSchedContinueDataCmd_UnmarshalParcel_001
360 * @tc.desc: DSchedContinueDataCmd UnmarshalParcel
361 * @tc.type: FUNC
362 */
363 HWTEST_F(DSchedContinueEventTest, DSchedContinueDataCmd_UnmarshalParcel_001, TestSize.Level0)
364 {
365 DTEST_LOG << "DSchedContinueEventTest DSchedContinueDataCmd_UnmarshalParcel_001 begin" << std::endl;
366 DSchedContinueDataCmd cmd;
367 std::string jsonStr = "test";
368 auto ret = cmd.UnmarshalParcel(jsonStr);
369 EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
370
371 auto rootValue = cJSON_CreateObject();
372 ASSERT_NE(rootValue, nullptr);
373 char *data = cJSON_Print(rootValue);
374 if (data == nullptr) {
375 cJSON_Delete(rootValue);
376 ASSERT_TRUE(false);
377 }
378
379 jsonStr = std::string(data);
380 ret = cmd.UnmarshalParcel(jsonStr);
381 EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
382 cJSON_free(data);
383
384 Parcel wantParcel;
385 if (!cmd.want_.Marshalling(wantParcel)) {
386 cJSON_Delete(rootValue);
387 ASSERT_FALSE(true);
388 }
389 std::string wantStr = ParcelToBase64Str(wantParcel);
390 cJSON_AddStringToObject(rootValue, "Want", wantStr.c_str());
391 data = cJSON_Print(rootValue);
392 if (data == nullptr) {
393 cJSON_Delete(rootValue);
394 ASSERT_TRUE(false);
395 }
396
397 jsonStr = std::string(data);
398 ret = cmd.UnmarshalParcel(jsonStr);
399 EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
400 cJSON_free(data);
401
402 cJSON_AddNumberToObject(rootValue, "AbilityInfo", 0);
403 data = cJSON_Print(rootValue);
404 if (data == nullptr) {
405 cJSON_Delete(rootValue);
406 ASSERT_TRUE(false);
407 }
408
409 jsonStr = std::string(data);
410 ret = cmd.UnmarshalParcel(jsonStr);
411 EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
412 cJSON_Delete(rootValue);
413 DTEST_LOG << "DSchedContinueEventTest DSchedContinueDataCmd_UnmarshalParcel_001 end ret:" << ret << std::endl;
414 }
415
416 /**
417 * @tc.name: DSchedContinueDataCmd_UnmarshalParcel_002
418 * @tc.desc: DSchedContinueDataCmd UnmarshalParcel
419 * @tc.type: FUNC
420 */
421 HWTEST_F(DSchedContinueEventTest, DSchedContinueDataCmd_UnmarshalParcel_002, TestSize.Level0)
422 {
423 DTEST_LOG << "DSchedContinueEventTest DSchedContinueDataCmd_UnmarshalParcel_002 begin" << std::endl;
424 DSchedContinueDataCmd cmd;
425 auto rootValue = cJSON_CreateObject();
426 ASSERT_NE(rootValue, nullptr);
427 char *data = cJSON_Print(rootValue);
428 if (data == nullptr) {
429 cJSON_Delete(rootValue);
430 ASSERT_TRUE(false);
431 }
432
433 Parcel wantParcel;
434 if (!cmd.want_.Marshalling(wantParcel)) {
435 cJSON_Delete(rootValue);
436 ASSERT_FALSE(true);
437 }
438 std::string wantStr = ParcelToBase64Str(wantParcel);
439 cJSON_AddStringToObject(rootValue, "Want", wantStr.c_str());
440 cJSON_AddStringToObject(rootValue, "AbilityInfo", "test");
441
442 auto jsonStr = std::string(data);
443 auto ret = cmd.UnmarshalParcel(jsonStr);
444 EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
445 cJSON_free(data);
446
447 cJSON_DeleteItemFromObject(rootValue, "AbilityInfo");
448 Parcel abilityParcel;
449 if (!cmd.abilityInfo_.Marshalling(abilityParcel)) {
450 cJSON_Delete(rootValue);
451 ASSERT_TRUE(false);
452 }
453 std::string abilityInfoStr = ParcelToBase64Str(abilityParcel);
454 cJSON_AddStringToObject(rootValue, "AbilityInfo", abilityInfoStr.c_str());
455 data = cJSON_Print(rootValue);
456 if (data == nullptr) {
457 cJSON_Delete(rootValue);
458 ASSERT_TRUE(false);
459 }
460
461 jsonStr = std::string(data);
462 ret = cmd.UnmarshalParcel(jsonStr);
463 EXPECT_EQ(ret, ERR_OK);
464 cJSON_free(data);
465 cJSON_Delete(rootValue);
466 DTEST_LOG << "DSchedContinueEventTest DSchedContinueDataCmd_UnmarshalParcel_002 end ret:" << ret << std::endl;
467 }
468
469 /**
470 * @tc.name: UnmarshalCallerInfo_001
471 * @tc.desc: DSchedContinueDataCmd UnmarshalCallerInfo
472 * @tc.type: FUNC
473 */
474 HWTEST_F(DSchedContinueEventTest, UnmarshalCallerInfo_001, TestSize.Level0)
475 {
476 DTEST_LOG << "DSchedContinueEventTest UnmarshalCallerInfo_001 begin" << std::endl;
477 DSchedContinueDataCmd cmd;
478 std::string jsonStr = "test";
479 auto ret = cmd.UnmarshalCallerInfo(jsonStr);
480 EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
481
482 auto rootValue = cJSON_CreateObject();
483 ASSERT_NE(rootValue, nullptr);
484 cJSON_AddStringToObject(rootValue, "Uid", "test");
485 char *data = cJSON_Print(rootValue);
486 if (data == nullptr) {
487 cJSON_Delete(rootValue);
488 ASSERT_TRUE(false);
489 }
490
491 jsonStr = std::string(data);
492 ret = cmd.UnmarshalCallerInfo(jsonStr);
493 EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
494 cJSON_free(data);
495
496 cJSON_AddNumberToObject(rootValue, "SourceDeviceId", 0);
497 data = cJSON_Print(rootValue);
498 if (data == nullptr) {
499 cJSON_Delete(rootValue);
500 ASSERT_TRUE(false);
501 }
502
503 jsonStr = std::string(data);
504 ret = cmd.UnmarshalCallerInfo(jsonStr);
505 EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
506 cJSON_free(data);
507 cJSON_Delete(rootValue);
508 DTEST_LOG << "DSchedContinueEventTest UnmarshalCallerInfo_001 end ret:" << ret << std::endl;
509 }
510
511 /**
512 * @tc.name: UnmarshalCallerInfo_002
513 * @tc.desc: DSchedContinueDataCmd UnmarshalCallerInfo_002
514 * @tc.type: FUNC
515 */
516 HWTEST_F(DSchedContinueEventTest, UnmarshalCallerInfo_002, TestSize.Level0)
517 {
518 DTEST_LOG << "DSchedContinueEventTest UnmarshalCallerInfo_002 begin" << std::endl;
519 DSchedContinueDataCmd cmd;
520 auto rootValue = cJSON_CreateObject();
521 ASSERT_NE(rootValue, nullptr);
522 cJSON_AddStringToObject(rootValue, "SourceDeviceId", "SourceDeviceId");
523 cJSON_AddStringToObject(rootValue, "CallerAppId", "CallerAppId");
524 char *data = cJSON_Print(rootValue);
525 if (data == nullptr) {
526 cJSON_Delete(rootValue);
527 ASSERT_TRUE(false);
528 }
529
530 auto jsonStr = std::string(data);
531 auto ret = cmd.UnmarshalCallerInfo(jsonStr);
532 EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
533 cJSON_free(data);
534
535 cJSON_AddStringToObject(rootValue, "Uid", "Uid");
536 data = cJSON_Print(rootValue);
537 if (data == nullptr) {
538 cJSON_Delete(rootValue);
539 ASSERT_TRUE(false);
540 }
541
542 jsonStr = std::string(data);
543 ret = cmd.UnmarshalCallerInfo(jsonStr);
544 EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
545 cJSON_free(data);
546 cJSON_Delete(rootValue);
547 DTEST_LOG << "DSchedContinueEventTest UnmarshalCallerInfo_002 end ret:" << ret << std::endl;
548 }
549
550 /**
551 * @tc.name: UnmarshalCallerInfo_003
552 * @tc.desc: DSchedContinueDataCmd UnmarshalCallerInfo_003
553 * @tc.type: FUNC
554 */
555 HWTEST_F(DSchedContinueEventTest, UnmarshalCallerInfo_003, TestSize.Level0)
556 {
557 DTEST_LOG << "DSchedContinueEventTest UnmarshalCallerInfo_003 begin" << std::endl;
558 DSchedContinueDataCmd cmd;
559 auto rootValue = cJSON_CreateObject();
560 ASSERT_NE(rootValue, nullptr);
561 cJSON_AddNumberToObject(rootValue, "Uid", 0);
562 cJSON_AddNumberToObject(rootValue, "Pid", 0);
563 cJSON_AddNumberToObject(rootValue, "CallerType", 0);
564 cJSON_AddStringToObject(rootValue, "SourceDeviceId", "SourceDeviceId");
565 cJSON_AddNumberToObject(rootValue, "Duid", 0);
566 cJSON_AddStringToObject(rootValue, "CallerAppId", "CallerAppId");
567 char *data = cJSON_Print(rootValue);
568 if (data == nullptr) {
569 cJSON_Delete(rootValue);
570 ASSERT_TRUE(false);
571 }
572
573 auto jsonStr = std::string(data);
574 auto ret = cmd.UnmarshalCallerInfo(jsonStr);
575 EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
576 cJSON_free(data);
577 cJSON_Delete(rootValue);
578 DTEST_LOG << "DSchedContinueEventTest UnmarshalCallerInfo_003 end ret:" << ret << std::endl;
579 }
580
581 /**
582 * @tc.name: UnmarshalCallerInfoExtra_001
583 * @tc.desc: DSchedContinueDataCmd UnmarshalCallerInfoExtra_001
584 * @tc.type: FUNC
585 */
586 HWTEST_F(DSchedContinueEventTest, UnmarshalCallerInfoExtra_001, TestSize.Level0)
587 {
588 DTEST_LOG << "DSchedContinueEventTest UnmarshalCallerInfoExtra_001 begin" << std::endl;
589 std::string jsonStr = "test";
590 DSchedContinueDataCmd cmd;
591 auto ret = cmd.UnmarshalCallerInfo(jsonStr);
592 EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
593
594 auto rootValue = cJSON_CreateObject();
595 ASSERT_NE(rootValue, nullptr);
596 cJSON *bundleNames = cJSON_CreateArray();
597 if (bundleNames == nullptr) {
598 cJSON_Delete(rootValue);
599 ASSERT_TRUE(false);
600 }
601
602 cJSON *bundleName = cJSON_CreateNumber(0);
603 if (bundleName == nullptr) {
604 cJSON_Delete(rootValue);
605 cJSON_Delete(bundleNames);
606 ASSERT_TRUE(false);
607 }
608
609 cJSON_AddItemToArray(bundleNames, bundleName);
610 cJSON_AddItemToObject(rootValue, "BundleNames", bundleNames);
611 char *data = cJSON_Print(rootValue);
612 if (data == nullptr) {
613 cJSON_Delete(rootValue);
614 ASSERT_TRUE(false);
615 }
616
617 jsonStr = std::string(data);
618 ret = cmd.UnmarshalCallerInfoExtra(jsonStr);
619 EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
620 cJSON_free(data);
621 cJSON_Delete(rootValue);
622 DTEST_LOG << "DSchedContinueEventTest UnmarshalCallerInfoExtra_001 end ret:" << ret << std::endl;
623 }
624
625 /**
626 * @tc.name: UnmarshalCallerInfoExtra_002
627 * @tc.desc: DSchedContinueDataCmd UnmarshalCallerInfoExtra_002
628 * @tc.type: FUNC
629 */
630 HWTEST_F(DSchedContinueEventTest, UnmarshalCallerInfoExtra_002, TestSize.Level0)
631 {
632 DTEST_LOG << "DSchedContinueEventTest UnmarshalCallerInfoExtra_002 begin" << std::endl;
633 DSchedContinueDataCmd cmd;
634 auto rootValue = cJSON_CreateObject();
635 ASSERT_NE(rootValue, nullptr);
636 cJSON *bundleNames = cJSON_CreateArray();
637 if (bundleNames == nullptr) {
638 cJSON_Delete(rootValue);
639 ASSERT_TRUE(false);
640 }
641
642 cJSON *bundleName = cJSON_CreateString("test");
643 if (bundleName == nullptr) {
644 cJSON_Delete(rootValue);
645 cJSON_Delete(bundleNames);
646 ASSERT_TRUE(false);
647 }
648
649 cJSON_AddItemToArray(bundleNames, bundleName);
650 cJSON_AddItemToObject(rootValue, "BundleNames", bundleNames);
651 char *data = cJSON_Print(rootValue);
652 if (data == nullptr) {
653 cJSON_Delete(rootValue);
654 ASSERT_TRUE(false);
655 }
656
657 auto jsonStr = std::string(data);
658 auto ret = cmd.UnmarshalCallerInfoExtra(jsonStr);
659 EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
660 cJSON_free(data);
661 cJSON_Delete(rootValue);
662 DTEST_LOG << "DSchedContinueEventTest UnmarshalCallerInfoExtra_002 end ret:" << ret << std::endl;
663 }
664
665 /**
666 * @tc.name: UnmarshalCallerInfoExtra_003
667 * @tc.desc: DSchedContinueDataCmd UnmarshalCallerInfoExtra_003
668 * @tc.type: FUNC
669 */
670 HWTEST_F(DSchedContinueEventTest, UnmarshalCallerInfoExtra_003, TestSize.Level0)
671 {
672 DTEST_LOG << "DSchedContinueEventTest UnmarshalCallerInfoExtra_003 begin" << std::endl;
673 DSchedContinueDataCmd cmd;
674 auto rootValue = cJSON_CreateObject();
675 ASSERT_NE(rootValue, nullptr);
676
677 cJSON_AddNumberToObject(rootValue, "ExtraInfo", 0);
678 char *data = cJSON_Print(rootValue);
679 if (data == nullptr) {
680 cJSON_Delete(rootValue);
681 ASSERT_TRUE(false);
682 }
683
684 auto jsonStr = std::string(data);
685 auto ret = cmd.UnmarshalCallerInfoExtra(jsonStr);
686 EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
687 cJSON_free(data);
688
689 cJSON_DeleteItemFromObject(rootValue, "ExtraInfo");
690 cJSON_AddStringToObject(rootValue, "ExtraInfo", "test");
691 data = cJSON_Print(rootValue);
692 if (data == nullptr) {
693 cJSON_Delete(rootValue);
694 ASSERT_TRUE(false);
695 }
696
697 jsonStr = std::string(data);
698 ret = cmd.UnmarshalCallerInfoExtra(jsonStr);
699 EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
700 cJSON_free(data);
701 cJSON_Delete(rootValue);
702 DTEST_LOG << "DSchedContinueEventTest UnmarshalCallerInfoExtra_003 end ret:" << ret << std::endl;
703 }
704
705 /**
706 * @tc.name: UnmarshalCallerInfoExtra_004
707 * @tc.desc: DSchedContinueDataCmd UnmarshalCallerInfoExtra_004
708 * @tc.type: FUNC
709 */
710 HWTEST_F(DSchedContinueEventTest, UnmarshalCallerInfoExtra_004, TestSize.Level0)
711 {
712 DTEST_LOG << "DSchedContinueEventTest UnmarshalCallerInfoExtra_004 begin" << std::endl;
713 DSchedContinueDataCmd cmd;
714 auto rootValue = cJSON_CreateObject();
715 ASSERT_NE(rootValue, nullptr);
716
717 nlohmann::json extraInfoJson;
718 extraInfoJson["test"] = "test";
719 std::string testStr = extraInfoJson.dump();
720 cJSON_AddStringToObject(rootValue, "ExtraInfo", testStr.c_str());
721 auto data = cJSON_Print(rootValue);
722 if (data == nullptr) {
723 cJSON_Delete(rootValue);
724 ASSERT_TRUE(false);
725 }
726
727 auto jsonStr = std::string(data);
728 auto ret = cmd.UnmarshalCallerInfoExtra(jsonStr);
729 EXPECT_EQ(ret, ERR_OK);
730 cJSON_free(data);
731
732 extraInfoJson[EXTRO_INFO_JSON_KEY_ACCESS_TOKEN] = "test";
733 testStr = extraInfoJson.dump();
734 cJSON_DeleteItemFromObject(rootValue, "ExtraInfo");
735 cJSON_AddStringToObject(rootValue, "ExtraInfo", testStr.c_str());
736 data = cJSON_Print(rootValue);
737 if (data == nullptr) {
738 cJSON_Delete(rootValue);
739 ASSERT_TRUE(false);
740 }
741
742 jsonStr = std::string(data);
743 ret = cmd.UnmarshalCallerInfoExtra(jsonStr);
744 EXPECT_EQ(ret, ERR_OK);
745 cJSON_free(data);
746 cJSON_Delete(rootValue);
747 DTEST_LOG << "DSchedContinueEventTest UnmarshalCallerInfoExtra_004 end ret:" << ret << std::endl;
748 }
749
750 /**
751 * @tc.name: UnmarshalCallerInfoExtra_005
752 * @tc.desc: DSchedContinueDataCmd UnmarshalCallerInfoExtra_005
753 * @tc.type: FUNC
754 */
755 HWTEST_F(DSchedContinueEventTest, UnmarshalCallerInfoExtra_005, TestSize.Level0)
756 {
757 DTEST_LOG << "DSchedContinueEventTest UnmarshalCallerInfoExtra_005 begin" << std::endl;
758 DSchedContinueDataCmd cmd;
759 auto rootValue = cJSON_CreateObject();
760 ASSERT_NE(rootValue, nullptr);
761
762 nlohmann::json extraInfoJson;
763 extraInfoJson[EXTRO_INFO_JSON_KEY_ACCESS_TOKEN] = 1;
764 std::string testStr = extraInfoJson.dump();
765 cJSON_AddStringToObject(rootValue, "ExtraInfo", testStr.c_str());
766 auto data = cJSON_Print(rootValue);
767 if (data == nullptr) {
768 cJSON_Delete(rootValue);
769 ASSERT_TRUE(false);
770 }
771
772 auto jsonStr = std::string(data);
773 auto ret = cmd.UnmarshalCallerInfoExtra(jsonStr);
774 EXPECT_EQ(ret, ERR_OK);
775 cJSON_free(data);
776
777 extraInfoJson[DMS_VERSION_ID] = 1;
778 testStr = extraInfoJson.dump();
779 cJSON_DeleteItemFromObject(rootValue, "ExtraInfo");
780 cJSON_AddStringToObject(rootValue, "ExtraInfo", testStr.c_str());
781 data = cJSON_Print(rootValue);
782 if (data == nullptr) {
783 cJSON_Delete(rootValue);
784 ASSERT_TRUE(false);
785 }
786
787 jsonStr = std::string(data);
788 ret = cmd.UnmarshalCallerInfoExtra(jsonStr);
789 EXPECT_EQ(ret, ERR_OK);
790 cJSON_free(data);
791
792 extraInfoJson[DMS_VERSION_ID] = "test";
793 testStr = extraInfoJson.dump();
794 cJSON_DeleteItemFromObject(rootValue, "ExtraInfo");
795 cJSON_AddStringToObject(rootValue, "ExtraInfo", testStr.c_str());
796 data = cJSON_Print(rootValue);
797 if (data == nullptr) {
798 cJSON_Delete(rootValue);
799 ASSERT_TRUE(false);
800 }
801
802 jsonStr = std::string(data);
803 ret = cmd.UnmarshalCallerInfoExtra(jsonStr);
804 EXPECT_EQ(ret, ERR_OK);
805 cJSON_free(data);
806 cJSON_Delete(rootValue);
807 DTEST_LOG << "DSchedContinueEventTest UnmarshalCallerInfoExtra_005 end ret:" << ret << std::endl;
808 }
809
810 /**
811 * @tc.name: UnmarshalAccountInfo_001
812 * @tc.desc: DSchedContinueDataCmd UnmarshalAccountInfo_001
813 * @tc.type: FUNC
814 */
815 HWTEST_F(DSchedContinueEventTest, UnmarshalAccountInfo_001, TestSize.Level0)
816 {
817 DTEST_LOG << "DSchedContinueEventTest UnmarshalAccountInfo_001 begin" << std::endl;
818 std::string jsonStr = "test";
819 DSchedContinueDataCmd cmd;
820 auto ret = cmd.UnmarshalAccountInfo(jsonStr);
821 EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
822
823 auto rootValue = cJSON_CreateObject();
824 ASSERT_NE(rootValue, nullptr);
825 char *data = cJSON_Print(rootValue);
826 if (data == nullptr) {
827 cJSON_Delete(rootValue);
828 ASSERT_TRUE(false);
829 }
830
831 jsonStr = std::string(data);
832 ret = cmd.UnmarshalAccountInfo(jsonStr);
833 EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
834 cJSON_free(data);
835
836 cJSON_AddStringToObject(rootValue, "AccountType", "AccountType");
837 data = cJSON_Print(rootValue);
838 if (data == nullptr) {
839 cJSON_Delete(rootValue);
840 ASSERT_TRUE(false);
841 }
842
843 jsonStr = std::string(data);
844 ret = cmd.UnmarshalAccountInfo(jsonStr);
845 EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
846
847 cJSON_DeleteItemFromObject(rootValue, "AccountType");
848 cJSON_AddNumberToObject(rootValue, "AccountType", 0);
849 cJSON_AddNumberToObject(rootValue, "groupIdList", 0);
850 data = cJSON_Print(rootValue);
851 if (data == nullptr) {
852 cJSON_Delete(rootValue);
853 ASSERT_TRUE(false);
854 }
855
856 jsonStr = std::string(data);
857 ret = cmd.UnmarshalAccountInfo(jsonStr);
858 EXPECT_EQ(ret, ERR_OK);
859 cJSON_Delete(rootValue);
860 DTEST_LOG << "DSchedContinueEventTest UnmarshalAccountInfo_001 end ret:" << ret << std::endl;
861 }
862
863 /**
864 * @tc.name: UnmarshalAccountInfo_002
865 * @tc.desc: DSchedContinueDataCmd UnmarshalAccountInfo_002
866 * @tc.type: FUNC
867 */
868 HWTEST_F(DSchedContinueEventTest, UnmarshalAccountInfo_002, TestSize.Level0)
869 {
870 DTEST_LOG << "DSchedContinueEventTest UnmarshalAccountInfo_002 begin" << std::endl;
871 auto rootValue = cJSON_CreateObject();
872 ASSERT_NE(rootValue, nullptr);
873 cJSON_AddNumberToObject(rootValue, "AccountType", 0);
874 cJSON *groupIdList = cJSON_CreateArray();
875 if (groupIdList == nullptr) {
876 cJSON_Delete(rootValue);
877 ASSERT_TRUE(false);
878 }
879
880 cJSON *groupId = cJSON_CreateNumber(0);
881 if (groupId == nullptr) {
882 cJSON_Delete(rootValue);
883 cJSON_Delete(groupIdList);
884 ASSERT_TRUE(false);
885 }
886
887 cJSON_AddItemToArray(groupIdList, groupId);
888 cJSON_AddItemToObject(rootValue, "groupIdList", groupIdList);
889 char *data = cJSON_Print(rootValue);
890 if (data == nullptr) {
891 cJSON_Delete(rootValue);
892 ASSERT_TRUE(false);
893 }
894
895 auto jsonStr = std::string(data);
896 DSchedContinueDataCmd cmd;
897 auto ret = cmd.UnmarshalAccountInfo(jsonStr);
898 EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
899 cJSON_free(data);
900 cJSON_Delete(rootValue);
901 DTEST_LOG << "DSchedContinueEventTest UnmarshalAccountInfo_002 end ret:" << ret << std::endl;
902 }
903
904 /**
905 * @tc.name: UnmarshalAccountInfo_003
906 * @tc.desc: DSchedContinueDataCmd UnmarshalAccountInfo_003
907 * @tc.type: FUNC
908 */
909 HWTEST_F(DSchedContinueEventTest, UnmarshalAccountInfo_003, TestSize.Level0)
910 {
911 DTEST_LOG << "DSchedContinueEventTest UnmarshalAccountInfo_003 begin" << std::endl;
912 DSchedContinueDataCmd cmd;
913 auto rootValue = cJSON_CreateObject();
914 ASSERT_NE(rootValue, nullptr);
915 cJSON_AddNumberToObject(rootValue, "AccountType", 0);
916 cJSON *groupIdList = cJSON_CreateArray();
917 if (groupIdList == nullptr) {
918 cJSON_Delete(rootValue);
919 ASSERT_TRUE(false);
920 }
921
922 cJSON *groupId = cJSON_CreateString("test");
923 if (groupId == nullptr) {
924 cJSON_Delete(rootValue);
925 cJSON_Delete(groupIdList);
926 ASSERT_TRUE(false);
927 }
928
929 cJSON_AddItemToArray(groupIdList, groupId);
930 cJSON_AddItemToObject(rootValue, "groupIdList", groupIdList);
931 char *data = cJSON_Print(rootValue);
932 if (data == nullptr) {
933 cJSON_Delete(rootValue);
934 ASSERT_TRUE(false);
935 }
936
937 auto jsonStr = std::string(data);
938 auto ret = cmd.UnmarshalAccountInfo(jsonStr);
939 EXPECT_EQ(ret, ERR_OK);
940 cJSON_free(data);
941 cJSON_Delete(rootValue);
942 DTEST_LOG << "DSchedContinueEventTest UnmarshalAccountInfo_003 end ret:" << ret << std::endl;
943 }
944
945 /**
946 * @tc.name: UnmarshalAccountInfo_004
947 * @tc.desc: DSchedContinueDataCmd UnmarshalAccountInfo_004
948 * @tc.type: FUNC
949 */
950 HWTEST_F(DSchedContinueEventTest, UnmarshalAccountInfo_004, TestSize.Level0)
951 {
952 DTEST_LOG << "DSchedContinueEventTest UnmarshalAccountInfo_004 begin" << std::endl;
953 DSchedContinueDataCmd cmd;
954 auto rootValue = cJSON_CreateObject();
955 ASSERT_NE(rootValue, nullptr);
956 cJSON_AddNumberToObject(rootValue, "AccountType", 0);
957 char *data = cJSON_Print(rootValue);
958 if (data == nullptr) {
959 cJSON_Delete(rootValue);
960 ASSERT_TRUE(false);
961 }
962
963 auto jsonStr = std::string(data);
964 auto ret = cmd.UnmarshalAccountInfo(jsonStr);
965 EXPECT_EQ(ret, ERR_OK);
966 cJSON_free(data);
967
968 cJSON_AddNumberToObject(rootValue, Constants::EXTRO_INFO_JSON_KEY_ACCOUNT_ID.c_str(), 0);
969 data = cJSON_Print(rootValue);
970 if (data == nullptr) {
971 cJSON_Delete(rootValue);
972 ASSERT_TRUE(false);
973 }
974
975 jsonStr = std::string(data);
976 ret = cmd.UnmarshalAccountInfo(jsonStr);
977 EXPECT_EQ(ret, ERR_OK);
978 cJSON_free(data);
979
980 cJSON_DeleteItemFromObject(rootValue, Constants::EXTRO_INFO_JSON_KEY_ACCOUNT_ID.c_str());
981 cJSON_AddStringToObject(rootValue, Constants::EXTRO_INFO_JSON_KEY_ACCOUNT_ID.c_str(), "test");
982 data = cJSON_Print(rootValue);
983 if (data == nullptr) {
984 cJSON_Delete(rootValue);
985 ASSERT_TRUE(false);
986 }
987
988 jsonStr = std::string(data);
989 ret = cmd.UnmarshalAccountInfo(jsonStr);
990 EXPECT_EQ(ret, ERR_OK);
991 cJSON_free(data);
992 cJSON_Delete(rootValue);
993 DTEST_LOG << "DSchedContinueEventTest UnmarshalAccountInfo_004 end ret:" << ret << std::endl;
994 }
995
996 /**
997 * @tc.name: UnmarshalAccountInfo_005
998 * @tc.desc: DSchedContinueDataCmd UnmarshalAccountInfo_005
999 * @tc.type: FUNC
1000 */
1001 HWTEST_F(DSchedContinueEventTest, UnmarshalAccountInfo_005, TestSize.Level0)
1002 {
1003 DTEST_LOG << "DSchedContinueEventTest UnmarshalAccountInfo_005 begin" << std::endl;
1004 DSchedContinueDataCmd cmd;
1005 auto rootValue = cJSON_CreateObject();
1006 ASSERT_NE(rootValue, nullptr);
1007 cJSON_AddNumberToObject(rootValue, "AccountType", 0);
1008 cJSON_AddStringToObject(rootValue, Constants::EXTRO_INFO_JSON_KEY_ACCOUNT_ID.c_str(), "test");
1009 cJSON_AddStringToObject(rootValue, Constants::EXTRO_INFO_JSON_KEY_USERID_ID.c_str(), "test");
1010 char *data = cJSON_Print(rootValue);
1011 if (data == nullptr) {
1012 cJSON_Delete(rootValue);
1013 ASSERT_TRUE(false);
1014 }
1015
1016 auto jsonStr = std::string(data);
1017 auto ret = cmd.UnmarshalAccountInfo(jsonStr);
1018 EXPECT_EQ(ret, ERR_OK);
1019 cJSON_free(data);
1020
1021 cJSON_DeleteItemFromObject(rootValue, Constants::EXTRO_INFO_JSON_KEY_USERID_ID.c_str());
1022 cJSON_AddNumberToObject(rootValue, Constants::EXTRO_INFO_JSON_KEY_USERID_ID.c_str(), 0);
1023 data = cJSON_Print(rootValue);
1024 if (data == nullptr) {
1025 cJSON_Delete(rootValue);
1026 ASSERT_TRUE(false);
1027 }
1028
1029 jsonStr = std::string(data);
1030 ret = cmd.UnmarshalAccountInfo(jsonStr);
1031 EXPECT_EQ(ret, ERR_OK);
1032 cJSON_free(data);
1033 cJSON_Delete(rootValue);
1034 DTEST_LOG << "DSchedContinueEventTest UnmarshalAccountInfo_005 end ret:" << ret << std::endl;
1035 }
1036
1037 /**
1038 * @tc.name: DSchedContinueReplyCmd_Unmarshal_001
1039 * @tc.desc: DSchedContinueReplyCmd Unmarshal
1040 * @tc.type: FUNC
1041 */
1042 HWTEST_F(DSchedContinueEventTest, DSchedContinueReplyCmd_Unmarshal_001, TestSize.Level0)
1043 {
1044 DTEST_LOG << "DSchedContinueEventTest DSchedContinueReplyCmd_Unmarshal_001 begin" << std::endl;
1045 std::string jsonStr = "test";
1046 DSchedContinueReplyCmd cmd;
1047 auto ret = cmd.Unmarshal(jsonStr);
1048 EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
1049
1050 auto rootValue = cJSON_CreateObject();
1051 ASSERT_NE(rootValue, nullptr);
1052 char *data = cJSON_Print(rootValue);
1053 if (data == nullptr) {
1054 cJSON_Delete(rootValue);
1055 ASSERT_TRUE(false);
1056 }
1057
1058 jsonStr = std::string(data);
1059 ret = cmd.Unmarshal(jsonStr);
1060 EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
1061 cJSON_free(data);
1062
1063 cJSON_AddNumberToObject(rootValue, "BaseCmd", 0);
1064 data = cJSON_Print(rootValue);
1065 if (data == nullptr) {
1066 cJSON_Delete(rootValue);
1067 ASSERT_TRUE(false);
1068 }
1069
1070 jsonStr = std::string(data);
1071 ret = cmd.Unmarshal(jsonStr);
1072 EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
1073
1074 cJSON_DeleteItemFromObject(rootValue, "BaseCmd");
1075 cJSON_AddStringToObject(rootValue, "BaseCmd", "test");
1076 data = cJSON_Print(rootValue);
1077 if (data == nullptr) {
1078 cJSON_Delete(rootValue);
1079 ASSERT_TRUE(false);
1080 }
1081
1082 jsonStr = std::string(data);
1083 ret = cmd.Unmarshal(jsonStr);
1084 EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
1085 cJSON_free(data);
1086 cJSON_Delete(rootValue);
1087 DTEST_LOG << "DSchedContinueEventTest DSchedContinueReplyCmd_Unmarshal_001 end ret:" << ret << std::endl;
1088 }
1089
1090 /**
1091 * @tc.name: DSchedContinueReplyCmd_Unmarshal_002
1092 * @tc.desc: DSchedContinueReplyCmd Unmarshal
1093 * @tc.type: FUNC
1094 */
1095 HWTEST_F(DSchedContinueEventTest, DSchedContinueReplyCmd_Unmarshal_002, TestSize.Level0)
1096 {
1097 DTEST_LOG << "DSchedContinueEventTest DSchedContinueReplyCmd_Unmarshal_002 begin" << std::endl;
1098 DSchedContinueReplyCmd cmd;
1099 cJSON *rootValue = cJSON_CreateObject();
1100 ASSERT_NE(rootValue, nullptr);
1101
1102 std::string baseJsonStr;
1103 DSchedContinueCmdBase baseCmd;
1104 if (baseCmd.Marshal(baseJsonStr) != ERR_OK) {
1105 cJSON_Delete(rootValue);
1106 ASSERT_TRUE(false);
1107 }
1108 cJSON_AddStringToObject(rootValue, "BaseCmd", baseJsonStr.c_str());
1109
1110 char *data = cJSON_Print(rootValue);
1111 if (data == nullptr) {
1112 cJSON_Delete(rootValue);
1113 ASSERT_TRUE(false);
1114 }
1115 auto jsonStr = std::string(data);
1116 auto ret = cmd.Unmarshal(jsonStr);
1117 EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
1118 cJSON_free(data);
1119
1120 cJSON_AddStringToObject(rootValue, "ReplyCmd", "test");
1121 data = cJSON_Print(rootValue);
1122 if (data == nullptr) {
1123 cJSON_Delete(rootValue);
1124 ASSERT_TRUE(false);
1125 }
1126
1127 jsonStr = std::string(data);
1128 ret = cmd.Unmarshal(jsonStr);
1129 EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
1130 cJSON_free(data);
1131 cJSON_Delete(rootValue);
1132 DTEST_LOG << "DSchedContinueEventTest DSchedContinueReplyCmd_Unmarshal_002 end ret:" << ret << std::endl;
1133 }
1134
1135 /**
1136 * @tc.name: DSchedContinueReplyCmd_Unmarshal_003
1137 * @tc.desc: DSchedContinueReplyCmd Unmarshal
1138 * @tc.type: FUNC
1139 */
1140 HWTEST_F(DSchedContinueEventTest, DSchedContinueReplyCmd_Unmarshal_003, TestSize.Level0)
1141 {
1142 DTEST_LOG << "DSchedContinueEventTest DSchedContinueReplyCmd_Unmarshal_003 begin" << std::endl;
1143 DSchedContinueReplyCmd cmd;
1144 cJSON *rootValue = cJSON_CreateObject();
1145 ASSERT_NE(rootValue, nullptr);
1146
1147 std::string baseJsonStr;
1148 DSchedContinueCmdBase baseCmd;
1149 if (baseCmd.Marshal(baseJsonStr) != ERR_OK) {
1150 cJSON_Delete(rootValue);
1151 ASSERT_TRUE(false);
1152 }
1153 cJSON_AddStringToObject(rootValue, "BaseCmd", baseJsonStr.c_str());
1154
1155 char *data = cJSON_Print(rootValue);
1156 if (data == nullptr) {
1157 cJSON_Delete(rootValue);
1158 ASSERT_TRUE(false);
1159 }
1160 auto jsonStr = std::string(data);
1161 auto ret = cmd.Unmarshal(jsonStr);
1162 EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
1163 cJSON_free(data);
1164
1165 cJSON_AddNumberToObject(rootValue, "ReplyCmd", 0);
1166 cJSON_AddNumberToObject(rootValue, "AppVersion", 0);
1167 cJSON_AddNumberToObject(rootValue, "Result", 0);
1168 data = cJSON_Print(rootValue);
1169 if (data == nullptr) {
1170 cJSON_Delete(rootValue);
1171 ASSERT_TRUE(false);
1172 }
1173
1174 jsonStr = std::string(data);
1175 ret = cmd.Unmarshal(jsonStr);
1176 EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
1177 cJSON_free(data);
1178
1179 cJSON_AddNumberToObject(rootValue, "Reason", 0);
1180 data = cJSON_Print(rootValue);
1181 if (data == nullptr) {
1182 cJSON_Delete(rootValue);
1183 ASSERT_TRUE(false);
1184 }
1185
1186 jsonStr = std::string(data);
1187 ret = cmd.Unmarshal(jsonStr);
1188 EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
1189 cJSON_free(data);
1190 cJSON_Delete(rootValue);
1191 DTEST_LOG << "DSchedContinueEventTest DSchedContinueReplyCmd_Unmarshal_003 end ret:" << ret << std::endl;
1192 }
1193
1194 /**
1195 * @tc.name: DSchedContinueEndCmd_Unmarshal_001
1196 * @tc.desc: DSchedContinueEndCmd Unmarshal
1197 * @tc.type: FUNC
1198 */
1199 HWTEST_F(DSchedContinueEventTest, DSchedContinueEndCmd_Unmarshal_001, TestSize.Level0)
1200 {
1201 DTEST_LOG << "DSchedContinueEventTest DSchedContinueEndCmd_Unmarshal_001 begin" << std::endl;
1202 std::string jsonStr = "test";
1203 DSchedContinueEndCmd cmd;
1204 auto ret = cmd.Unmarshal(jsonStr);
1205 EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
1206
1207 auto rootValue = cJSON_CreateObject();
1208 ASSERT_NE(rootValue, nullptr);
1209 char *data = cJSON_Print(rootValue);
1210 if (data == nullptr) {
1211 cJSON_Delete(rootValue);
1212 ASSERT_TRUE(false);
1213 }
1214
1215 jsonStr = std::string(data);
1216 ret = cmd.Unmarshal(jsonStr);
1217 EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
1218 cJSON_free(data);
1219
1220 cJSON_AddNumberToObject(rootValue, "BaseCmd", 0);
1221 data = cJSON_Print(rootValue);
1222 if (data == nullptr) {
1223 cJSON_Delete(rootValue);
1224 ASSERT_TRUE(false);
1225 }
1226
1227 jsonStr = std::string(data);
1228 ret = cmd.Unmarshal(jsonStr);
1229 EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
1230
1231 cJSON_DeleteItemFromObject(rootValue, "BaseCmd");
1232 cJSON_AddStringToObject(rootValue, "BaseCmd", "test");
1233 data = cJSON_Print(rootValue);
1234 if (data == nullptr) {
1235 cJSON_Delete(rootValue);
1236 ASSERT_TRUE(false);
1237 }
1238
1239 jsonStr = std::string(data);
1240 ret = cmd.Unmarshal(jsonStr);
1241 EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
1242 cJSON_free(data);
1243 cJSON_Delete(rootValue);
1244 DTEST_LOG << "DSchedContinueEventTest DSchedContinueEndCmd_Unmarshal_001 end ret:" << ret << std::endl;
1245 }
1246
1247 /**
1248 * @tc.name: DSchedContinueEndCmd_Unmarshal_002
1249 * @tc.desc: DSchedContinueEndCmd Unmarshal
1250 * @tc.type: FUNC
1251 */
1252 HWTEST_F(DSchedContinueEventTest, DSchedContinueEndCmd_Unmarshal_002, TestSize.Level0)
1253 {
1254 DTEST_LOG << "DSchedContinueEventTest DSchedContinueEndCmd_Unmarshal_002 begin" << std::endl;
1255 DSchedContinueEndCmd cmd;
1256 cJSON *rootValue = cJSON_CreateObject();
1257 ASSERT_NE(rootValue, nullptr);
1258
1259 std::string baseJsonStr;
1260 DSchedContinueCmdBase baseCmd;
1261 if (baseCmd.Marshal(baseJsonStr) != ERR_OK) {
1262 cJSON_Delete(rootValue);
1263 ASSERT_TRUE(false);
1264 }
1265 cJSON_AddStringToObject(rootValue, "BaseCmd", baseJsonStr.c_str());
1266
1267 char *data = cJSON_Print(rootValue);
1268 if (data == nullptr) {
1269 cJSON_Delete(rootValue);
1270 ASSERT_TRUE(false);
1271 }
1272 auto jsonStr = std::string(data);
1273 auto ret = cmd.Unmarshal(jsonStr);
1274 EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
1275 cJSON_free(data);
1276
1277 cJSON_AddStringToObject(rootValue, "Result", "Result");
1278 data = cJSON_Print(rootValue);
1279 if (data == nullptr) {
1280 cJSON_Delete(rootValue);
1281 ASSERT_TRUE(false);
1282 }
1283
1284 jsonStr = std::string(data);
1285 ret = cmd.Unmarshal(jsonStr);
1286 EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
1287 cJSON_free(data);
1288 cJSON_Delete(rootValue);
1289 DTEST_LOG << "DSchedContinueEventTest DSchedContinueEndCmd_Unmarshal_002 end ret:" << ret << std::endl;
1290 }
1291
1292 /**
1293 * @tc.name: DSchedContinueStartCmd_Unmarshal_001
1294 * @tc.desc: DSchedContinueStartCmd Unmarshal
1295 * @tc.type: FUNC
1296 */
1297 HWTEST_F(DSchedContinueEventTest, DSchedContinueStartCmd_Unmarshal_001, TestSize.Level0)
1298 {
1299 DTEST_LOG << "DSchedContinueEventTest DSchedContinueStartCmd_Unmarshal_001 begin" << std::endl;
1300 std::string jsonStr = "test";
1301 DSchedContinueStartCmd cmd;
1302 auto ret = cmd.Unmarshal(jsonStr);
1303 EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
1304
1305 auto rootValue = cJSON_CreateObject();
1306 ASSERT_NE(rootValue, nullptr);
1307 char *data = cJSON_Print(rootValue);
1308 if (data == nullptr) {
1309 cJSON_Delete(rootValue);
1310 ASSERT_TRUE(false);
1311 }
1312
1313 jsonStr = std::string(data);
1314 ret = cmd.Unmarshal(jsonStr);
1315 EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
1316 cJSON_free(data);
1317
1318 cJSON_AddNumberToObject(rootValue, "BaseCmd", 0);
1319 data = cJSON_Print(rootValue);
1320 if (data == nullptr) {
1321 cJSON_Delete(rootValue);
1322 ASSERT_TRUE(false);
1323 }
1324
1325 jsonStr = std::string(data);
1326 ret = cmd.Unmarshal(jsonStr);
1327 EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
1328
1329 cJSON_DeleteItemFromObject(rootValue, "BaseCmd");
1330 cJSON_AddStringToObject(rootValue, "BaseCmd", "test");
1331 data = cJSON_Print(rootValue);
1332 if (data == nullptr) {
1333 cJSON_Delete(rootValue);
1334 ASSERT_TRUE(false);
1335 }
1336
1337 jsonStr = std::string(data);
1338 ret = cmd.Unmarshal(jsonStr);
1339 EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
1340 cJSON_free(data);
1341 cJSON_Delete(rootValue);
1342 DTEST_LOG << "DSchedContinueEventTest DSchedContinueStartCmd_Unmarshal_001 end ret:" << ret << std::endl;
1343 }
1344
1345 /**
1346 * @tc.name: DSchedContinueStartCmd_Unmarshal_002
1347 * @tc.desc: DSchedContinueStartCmd Unmarshal
1348 * @tc.type: FUNC
1349 */
1350 HWTEST_F(DSchedContinueEventTest, DSchedContinueStartCmd_Unmarshal_002, TestSize.Level0)
1351 {
1352 DTEST_LOG << "DSchedContinueEventTest DSchedContinueStartCmd_Unmarshal_002 begin" << std::endl;
1353 DSchedContinueStartCmd cmd;
1354 cJSON *rootValue = cJSON_CreateObject();
1355 ASSERT_NE(rootValue, nullptr);
1356
1357 std::string baseJsonStr;
1358 DSchedContinueCmdBase baseCmd;
1359 if (baseCmd.Marshal(baseJsonStr) != ERR_OK) {
1360 cJSON_Delete(rootValue);
1361 ASSERT_TRUE(false);
1362 }
1363 cJSON_AddStringToObject(rootValue, "BaseCmd", baseJsonStr.c_str());
1364
1365 char *data = cJSON_Print(rootValue);
1366 if (data == nullptr) {
1367 cJSON_Delete(rootValue);
1368 ASSERT_TRUE(false);
1369 }
1370 auto jsonStr = std::string(data);
1371 auto ret = cmd.Unmarshal(jsonStr);
1372 EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
1373 cJSON_free(data);
1374
1375 cJSON_AddStringToObject(rootValue, "Direction", "Direction");
1376 data = cJSON_Print(rootValue);
1377 if (data == nullptr) {
1378 cJSON_Delete(rootValue);
1379 ASSERT_TRUE(false);
1380 }
1381
1382 jsonStr = std::string(data);
1383 ret = cmd.Unmarshal(jsonStr);
1384 EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
1385 cJSON_free(data);
1386 cJSON_Delete(rootValue);
1387 DTEST_LOG << "DSchedContinueEventTest DSchedContinueStartCmd_Unmarshal_002 end ret:" << ret << std::endl;
1388 }
1389
1390 /**
1391 * @tc.name: DSchedContinueStartCmd_Unmarshal_003
1392 * @tc.desc: DSchedContinueStartCmd Unmarshal
1393 * @tc.type: FUNC
1394 */
1395 HWTEST_F(DSchedContinueEventTest, DSchedContinueStartCmd_Unmarshal_003, TestSize.Level0)
1396 {
1397 DTEST_LOG << "DSchedContinueEventTest DSchedContinueStartCmd_Unmarshal_003 begin" << std::endl;
1398 DSchedContinueStartCmd cmd;
1399 cJSON *rootValue = cJSON_CreateObject();
1400 ASSERT_NE(rootValue, nullptr);
1401
1402 std::string baseJsonStr;
1403 DSchedContinueCmdBase baseCmd;
1404 if (baseCmd.Marshal(baseJsonStr) != ERR_OK) {
1405 cJSON_Delete(rootValue);
1406 ASSERT_TRUE(false);
1407 }
1408 cJSON_AddStringToObject(rootValue, "BaseCmd", baseJsonStr.c_str());
1409 cJSON_AddNumberToObject(rootValue, "Direction", 0);
1410
1411 char *data = cJSON_Print(rootValue);
1412 if (data == nullptr) {
1413 cJSON_Delete(rootValue);
1414 ASSERT_TRUE(false);
1415 }
1416 auto jsonStr = std::string(data);
1417 auto ret = cmd.Unmarshal(jsonStr);
1418 EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
1419 cJSON_free(data);
1420
1421 cJSON_AddStringToObject(rootValue, "AppVersion", "AppVersion");
1422 data = cJSON_Print(rootValue);
1423 if (data == nullptr) {
1424 cJSON_Delete(rootValue);
1425 ASSERT_TRUE(false);
1426 }
1427
1428 jsonStr = std::string(data);
1429 ret = cmd.Unmarshal(jsonStr);
1430 EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
1431 cJSON_free(data);
1432 cJSON_Delete(rootValue);
1433 DTEST_LOG << "DSchedContinueEventTest DSchedContinueStartCmd_Unmarshal_003 end ret:" << ret << std::endl;
1434 }
1435
1436 /**
1437 * @tc.name: DSchedContinueStartCmd_Unmarshal_004
1438 * @tc.desc: DSchedContinueStartCmd Unmarshal
1439 * @tc.type: FUNC
1440 */
1441 HWTEST_F(DSchedContinueEventTest, DSchedContinueStartCmd_Unmarshal_004, TestSize.Level0)
1442 {
1443 DTEST_LOG << "DSchedContinueEventTest DSchedContinueStartCmd_Unmarshal_004 begin" << std::endl;
1444 DSchedContinueStartCmd cmd;
1445 cJSON *rootValue = cJSON_CreateObject();
1446 ASSERT_NE(rootValue, nullptr);
1447
1448 std::string baseJsonStr;
1449 DSchedContinueCmdBase baseCmd;
1450 if (baseCmd.Marshal(baseJsonStr) != ERR_OK) {
1451 cJSON_Delete(rootValue);
1452 ASSERT_TRUE(false);
1453 }
1454 cJSON_AddStringToObject(rootValue, "BaseCmd", baseJsonStr.c_str());
1455 cJSON_AddNumberToObject(rootValue, "Direction", 0);
1456 cJSON_AddNumberToObject(rootValue, "AppVersion", 0);
1457
1458 char *data = cJSON_Print(rootValue);
1459 if (data == nullptr) {
1460 cJSON_Delete(rootValue);
1461 ASSERT_TRUE(false);
1462 }
1463 auto jsonStr = std::string(data);
1464 auto ret = cmd.Unmarshal(jsonStr);
1465 EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
1466 cJSON_free(data);
1467
1468 cJSON_AddNumberToObject(rootValue, "WantParams", 0);
1469 data = cJSON_Print(rootValue);
1470 if (data == nullptr) {
1471 cJSON_Delete(rootValue);
1472 ASSERT_TRUE(false);
1473 }
1474
1475 jsonStr = std::string(data);
1476 ret = cmd.Unmarshal(jsonStr);
1477 EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
1478 cJSON_free(data);
1479 cJSON_Delete(rootValue);
1480 DTEST_LOG << "DSchedContinueEventTest DSchedContinueStartCmd_Unmarshal_004 end ret:" << ret << std::endl;
1481 }
1482
1483 /**
1484 * @tc.name: DSchedContinueStartCmd_Unmarshal_005
1485 * @tc.desc: DSchedContinueStartCmd Unmarshal
1486 * @tc.type: FUNC
1487 */
1488 HWTEST_F(DSchedContinueEventTest, DSchedContinueStartCmd_Unmarshal_005, TestSize.Level0)
1489 {
1490 DTEST_LOG << "DSchedContinueEventTest DSchedContinueStartCmd_Unmarshal_005 begin" << std::endl;
1491 DSchedContinueStartCmd cmd;
1492 cJSON *rootValue = cJSON_CreateObject();
1493 ASSERT_NE(rootValue, nullptr);
1494
1495 std::string baseJsonStr;
1496 DSchedContinueCmdBase baseCmd;
1497 if (baseCmd.Marshal(baseJsonStr) != ERR_OK) {
1498 cJSON_Delete(rootValue);
1499 ASSERT_TRUE(false);
1500 }
1501 cJSON_AddStringToObject(rootValue, "BaseCmd", baseJsonStr.c_str());
1502 cJSON_AddNumberToObject(rootValue, "Direction", 0);
1503 cJSON_AddNumberToObject(rootValue, "AppVersion", 0);
1504 cJSON_AddStringToObject(rootValue, "WantParams", "test");
1505
1506 char *data = cJSON_Print(rootValue);
1507 if (data == nullptr) {
1508 cJSON_Delete(rootValue);
1509 ASSERT_TRUE(false);
1510 }
1511 auto jsonStr = std::string(data);
1512 auto ret = cmd.Unmarshal(jsonStr);
1513 EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
1514 cJSON_free(data);
1515
1516 cJSON_DeleteItemFromObject(rootValue, "WantParams");
1517 Parcel parcel;
1518 std::string wantParamsStr = ParcelToBase64Str(parcel);
1519 cJSON_AddStringToObject(rootValue, "WantParams", wantParamsStr.c_str());
1520 data = cJSON_Print(rootValue);
1521 if (data == nullptr) {
1522 cJSON_Delete(rootValue);
1523 ASSERT_TRUE(false);
1524 }
1525
1526 jsonStr = std::string(data);
1527 ret = cmd.Unmarshal(jsonStr);
1528 EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
1529 cJSON_free(data);
1530 cJSON_Delete(rootValue);
1531 DTEST_LOG << "DSchedContinueEventTest DSchedContinueStartCmd_Unmarshal_005 end ret:" << ret << std::endl;
1532 }
1533
1534 /**
1535 * @tc.name: DSchedContinueCmdBase_Unmarshal_001
1536 * @tc.desc: DSchedContinueCmdBase Unmarshal
1537 * @tc.type: FUNC
1538 */
1539 HWTEST_F(DSchedContinueEventTest, DSchedContinueCmdBase_Unmarshal_001, TestSize.Level0)
1540 {
1541 DTEST_LOG << "DSchedContinueEventTest DSchedContinueCmdBase_Unmarshal_001 begin" << std::endl;
1542 std::string jsonStr = "test";
1543 DSchedContinueCmdBase cmd;
1544 auto ret = cmd.Unmarshal(jsonStr);
1545 EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
1546
1547 cJSON *rootValue = cJSON_CreateObject();
1548 ASSERT_NE(rootValue, nullptr);
1549
1550 char *data = cJSON_Print(rootValue);
1551 if (data == nullptr) {
1552 cJSON_Delete(rootValue);
1553 ASSERT_TRUE(false);
1554 }
1555 jsonStr = std::string(data);
1556 ret = cmd.Unmarshal(jsonStr);
1557 EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
1558 cJSON_free(data);
1559
1560 cJSON_AddStringToObject(rootValue, "Version", "Version");
1561 data = cJSON_Print(rootValue);
1562 if (data == nullptr) {
1563 cJSON_Delete(rootValue);
1564 ASSERT_TRUE(false);
1565 }
1566
1567 jsonStr = std::string(data);
1568 ret = cmd.Unmarshal(jsonStr);
1569 EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
1570 cJSON_free(data);
1571 cJSON_Delete(rootValue);
1572 DTEST_LOG << "DSchedContinueEventTest DSchedContinueCmdBase_Unmarshal_001 end ret:" << ret << std::endl;
1573 }
1574
1575 /**
1576 * @tc.name: DSchedContinueCmdBase_Unmarshal_002
1577 * @tc.desc: DSchedContinueCmdBase Unmarshal
1578 * @tc.type: FUNC
1579 */
1580 HWTEST_F(DSchedContinueEventTest, DSchedContinueCmdBase_Unmarshal_002, TestSize.Level0)
1581 {
1582 DTEST_LOG << "DSchedContinueEventTest DSchedContinueCmdBase_Unmarshal_002 begin" << std::endl;
1583 DSchedContinueCmdBase cmd;
1584 cJSON *rootValue = cJSON_CreateObject();
1585 ASSERT_NE(rootValue, nullptr);
1586 cJSON_AddNumberToObject(rootValue, "Version", 0);
1587 cJSON_AddNumberToObject(rootValue, "ServiceType", 0);
1588 cJSON_AddNumberToObject(rootValue, "SubServiceType", 0);
1589 cJSON_AddNumberToObject(rootValue, "ContinueByType", 0);
1590 cJSON_AddNumberToObject(rootValue, "SourceMissionId", 0);
1591 cJSON_AddNumberToObject(rootValue, "DmsVersion", 0);
1592
1593 char *data = cJSON_Print(rootValue);
1594 if (data == nullptr) {
1595 cJSON_Delete(rootValue);
1596 ASSERT_TRUE(false);
1597 }
1598 auto jsonStr = std::string(data);
1599 auto ret = cmd.Unmarshal(jsonStr);
1600 EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
1601 cJSON_free(data);
1602
1603 cJSON_AddNumberToObject(rootValue, "SrcDeviceId", 0);
1604 data = cJSON_Print(rootValue);
1605 if (data == nullptr) {
1606 cJSON_Delete(rootValue);
1607 ASSERT_TRUE(false);
1608 }
1609
1610 jsonStr = std::string(data);
1611 ret = cmd.Unmarshal(jsonStr);
1612 EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
1613 cJSON_free(data);
1614 cJSON_Delete(rootValue);
1615 DTEST_LOG << "DSchedContinueEventTest DSchedContinueCmdBase_Unmarshal_002 end ret:" << ret << std::endl;
1616 }
1617
1618 /**
1619 * @tc.name: DSchedContinueCmdBase_Unmarshal_003
1620 * @tc.desc: DSchedContinueCmdBase Unmarshal
1621 * @tc.type: FUNC
1622 */
1623 HWTEST_F(DSchedContinueEventTest, DSchedContinueCmdBase_Unmarshal_003, TestSize.Level0)
1624 {
1625 DTEST_LOG << "DSchedContinueEventTest DSchedContinueCmdBase_Unmarshal_003 begin" << std::endl;
1626 DSchedContinueCmdBase cmd;
1627 cJSON *rootValue = cJSON_CreateObject();
1628 ASSERT_NE(rootValue, nullptr);
1629 cJSON_AddNumberToObject(rootValue, "Version", 0);
1630 cJSON_AddNumberToObject(rootValue, "ServiceType", 0);
1631 cJSON_AddNumberToObject(rootValue, "SubServiceType", 0);
1632 cJSON_AddNumberToObject(rootValue, "ContinueByType", 0);
1633 cJSON_AddNumberToObject(rootValue, "SourceMissionId", 0);
1634 cJSON_AddNumberToObject(rootValue, "DmsVersion", 0);
1635 cJSON_AddStringToObject(rootValue, "SrcDeviceId", "SrcDeviceId");
1636 cJSON_AddStringToObject(rootValue, "SrcBundleName", "SrcBundleName");
1637 cJSON_AddStringToObject(rootValue, "DstDeviceId", "DstDeviceId");
1638 cJSON_AddStringToObject(rootValue, "DstBundleName", "DstBundleName");
1639 cJSON_AddStringToObject(rootValue, "ContinueType", "ContinueType");
1640
1641 char *data = cJSON_Print(rootValue);
1642 if (data == nullptr) {
1643 cJSON_Delete(rootValue);
1644 ASSERT_TRUE(false);
1645 }
1646 auto jsonStr = std::string(data);
1647 auto ret = cmd.Unmarshal(jsonStr);
1648 EXPECT_EQ(ret, ERR_OK);
1649 cJSON_free(data);
1650
1651 cJSON_AddNumberToObject(rootValue, "SrcDeveloperId", 0);
1652 data = cJSON_Print(rootValue);
1653 if (data == nullptr) {
1654 cJSON_Delete(rootValue);
1655 ASSERT_TRUE(false);
1656 }
1657
1658 jsonStr = std::string(data);
1659 ret = cmd.Unmarshal(jsonStr);
1660 EXPECT_EQ(ret, ERR_OK);
1661 cJSON_free(data);
1662 cJSON_Delete(rootValue);
1663 DTEST_LOG << "DSchedContinueEventTest DSchedContinueCmdBase_Unmarshal_003 end ret:" << ret << std::endl;
1664 }
1665 }
1666 }
1667