1 /*
2 * Copyright (c) 2023 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16 #include <gtest/gtest.h>
17 #include <memory>
18
19 #include "cloud_sync_common.h"
20
21 namespace OHOS {
22 namespace FileManagement::CloudSync {
23 using namespace testing::ext;
24 using namespace testing;
25 using namespace std;
26 constexpr uint32_t MAX_MAP_SIZE = 1024;
27 class CloudSyncCommonTest : public testing::Test {
28 public:
29 static void SetUpTestCase(void);
30 static void TearDownTestCase(void);
31 void SetUp();
32 void TearDown();
33 static inline std::shared_ptr<ParcelMock> parcel_{nullptr};
34 };
35
SetUpTestCase(void)36 void CloudSyncCommonTest::SetUpTestCase(void)
37 {
38 parcel_ = std::make_shared<ParcelMock>();
39 IParcel::parcel_ = parcel_;
40 std::cout << "SetUpTestCase" << std::endl;
41 }
42
TearDownTestCase(void)43 void CloudSyncCommonTest::TearDownTestCase(void)
44 {
45 parcel_ = nullptr;
46 IParcel::parcel_ = nullptr;
47 std::cout << "TearDownTestCase" << std::endl;
48 }
49
SetUp(void)50 void CloudSyncCommonTest::SetUp(void)
51 {
52 std::cout << "SetUp" << std::endl;
53 }
54
TearDown(void)55 void CloudSyncCommonTest::TearDown(void)
56 {
57 std::cout << "TearDown" << std::endl;
58 }
59
60 /*
61 * @tc.name: Marshalling
62 * @tc.desc: Verify the Marshalling function.
63 * @tc.type: FUNC
64 * @tc.require: I6H5MH
65 */
66 HWTEST_F(CloudSyncCommonTest, Marshalling, TestSize.Level1)
67 {
68 GTEST_LOG_(INFO) << "Marshalling Start";
69 try {
70 SwitchDataObj switchDataObj;
71 Parcel parcel;
72 EXPECT_CALL(*parcel_, WriteUint32(_)).WillOnce(Return(false));
73 auto res = switchDataObj.Marshalling(parcel);
74 EXPECT_TRUE(!res);
75 } catch (...) {
76 EXPECT_TRUE(false);
77 GTEST_LOG_(INFO) << " Marshalling FAILED";
78 }
79 GTEST_LOG_(INFO) << "Marshalling End";
80 }
81
82 /*
83 * @tc.name: Marshalling001
84 * @tc.desc: Verify the Marshalling001 function.
85 * @tc.type: FUNC
86 * @tc.require: I6H5MH
87 */
88 HWTEST_F(CloudSyncCommonTest, Marshalling001, TestSize.Level1)
89 {
90 GTEST_LOG_(INFO) << "Marshalling001 Start";
91 try {
92 SwitchDataObj switchDataObj;
93 switchDataObj.switchData.insert(std::make_pair("1", false));
94 Parcel parcel;
95 EXPECT_CALL(*parcel_, WriteUint32(_)).WillOnce(Return(true));
96 EXPECT_CALL(*parcel_, WriteString(_)).WillOnce(Return(false));
97 auto res = switchDataObj.Marshalling(parcel);
98 EXPECT_TRUE(!res);
99
100 EXPECT_CALL(*parcel_, WriteUint32(_)).WillOnce(Return(true));
101 EXPECT_CALL(*parcel_, WriteString(_)).WillOnce(Return(true));
102 EXPECT_CALL(*parcel_, WriteBool(_)).WillOnce(Return(true));
103 res = switchDataObj.Marshalling(parcel);
104 EXPECT_TRUE(res);
105 } catch (...) {
106 EXPECT_TRUE(false);
107 GTEST_LOG_(INFO) << " Marshalling001 FAILED";
108 }
109 GTEST_LOG_(INFO) << "Marshalling001 End";
110 }
111
112 /*
113 * @tc.name: Marshalling002
114 * @tc.desc: Verify the Marshalling002 function.
115 * @tc.type: FUNC
116 * @tc.require: I6H5MH
117 */
118 HWTEST_F(CloudSyncCommonTest, Marshalling002, TestSize.Level1)
119 {
120 GTEST_LOG_(INFO) << "Marshalling002 Start";
121 try {
122 SwitchDataObj switchDataObj;
123 switchDataObj.switchData.insert(std::make_pair("1", false));
124 Parcel parcel;
125
126 EXPECT_CALL(*parcel_, WriteUint32(_)).WillOnce(Return(true));
127 EXPECT_CALL(*parcel_, WriteString(_)).WillOnce(Return(true));
128 EXPECT_CALL(*parcel_, WriteBool(_)).WillOnce(Return(false));
129 auto res = switchDataObj.Marshalling(parcel);
130 EXPECT_TRUE(!res);
131 } catch (...) {
132 EXPECT_TRUE(false);
133 GTEST_LOG_(INFO) << " Marshalling002 FAILED";
134 }
135 GTEST_LOG_(INFO) << "Marshalling002 End";
136 }
137
138 /*
139 * @tc.name: Marshalling003
140 * @tc.desc: Verify the Marshalling003 function.
141 * @tc.type: FUNC
142 * @tc.require: I6H5MH
143 */
144 HWTEST_F(CloudSyncCommonTest, Marshalling003, TestSize.Level1)
145 {
146 GTEST_LOG_(INFO) << "Marshalling003 Start";
147 try {
148 DownloadProgressObj downloadProgressObj;
149 Parcel parcel;
150 EXPECT_CALL(*parcel_, WriteString(_)).WillOnce(Return(false));
151 auto res = downloadProgressObj.Marshalling(parcel);
152 EXPECT_TRUE(!res);
153
154 EXPECT_CALL(*parcel_, WriteString(_)).WillOnce(Return(true));
155 EXPECT_CALL(*parcel_, WriteInt32(_)).WillOnce(Return(false));
156 res = downloadProgressObj.Marshalling(parcel);
157 EXPECT_TRUE(!res);
158
159 EXPECT_CALL(*parcel_, WriteString(_)).WillOnce(Return(true));
160 EXPECT_CALL(*parcel_, WriteInt32(_)).WillOnce(Return(true));
161 EXPECT_CALL(*parcel_, WriteInt64(_)).WillOnce(Return(false));
162 res = downloadProgressObj.Marshalling(parcel);
163 EXPECT_TRUE(!res);
164
165 EXPECT_CALL(*parcel_, WriteString(_)).WillOnce(Return(true));
166 EXPECT_CALL(*parcel_, WriteInt32(_)).WillOnce(Return(true));
167 EXPECT_CALL(*parcel_, WriteInt64(_)).WillOnce(Return(true)).WillOnce(Return(false));
168 res = downloadProgressObj.Marshalling(parcel);
169 EXPECT_TRUE(!res);
170 } catch (...) {
171 EXPECT_TRUE(false);
172 GTEST_LOG_(INFO) << " Marshalling003 FAILED";
173 }
174 GTEST_LOG_(INFO) << "Marshalling003 End";
175 }
176
177 /*
178 * @tc.name: Marshalling004
179 * @tc.desc: Verify the Marshalling004 function.
180 * @tc.type: FUNC
181 * @tc.require: I6H5MH
182 */
183 HWTEST_F(CloudSyncCommonTest, Marshalling004, TestSize.Level1)
184 {
185 GTEST_LOG_(INFO) << "Marshalling004 Start";
186 try {
187 CleanOptions cleanOptions;
188 cleanOptions.appActionsData.insert(std::make_pair("1", 0));
189 Parcel parcel;
190 EXPECT_CALL(*parcel_, WriteUint32(_)).WillOnce(Return(false));
191 auto res = cleanOptions.Marshalling(parcel);
192 EXPECT_TRUE(!res);
193
194 EXPECT_CALL(*parcel_, WriteUint32(_)).WillOnce(Return(true));
195 EXPECT_CALL(*parcel_, WriteString(_)).WillOnce(Return(true));
196 EXPECT_CALL(*parcel_, WriteInt32(_)).WillOnce(Return(true));
197 res = cleanOptions.Marshalling(parcel);
198 EXPECT_TRUE(res);
199 } catch (...) {
200 EXPECT_TRUE(false);
201 GTEST_LOG_(INFO) << " Marshalling004 FAILED";
202 }
203 GTEST_LOG_(INFO) << "Marshalling004 End";
204 }
205
206 /*
207 * @tc.name: Marshalling005
208 * @tc.desc: Verify the Marshalling005 function.
209 * @tc.type: FUNC
210 * @tc.require: I6H5MH
211 */
212 HWTEST_F(CloudSyncCommonTest, Marshalling005, TestSize.Level1)
213 {
214 GTEST_LOG_(INFO) << "Marshalling005 Start";
215 try {
216 CleanOptions cleanOptions;
217 cleanOptions.appActionsData.insert(std::make_pair("1", 0));
218 Parcel parcel;
219 EXPECT_CALL(*parcel_, WriteUint32(_)).WillOnce(Return(false));
220 auto res = cleanOptions.Marshalling(parcel);
221 EXPECT_TRUE(!res);
222
223 EXPECT_CALL(*parcel_, WriteUint32(_)).WillOnce(Return(true));
224 EXPECT_CALL(*parcel_, WriteString(_)).WillOnce(Return(false));
225 res = cleanOptions.Marshalling(parcel);
226 EXPECT_TRUE(!res);
227 } catch (...) {
228 EXPECT_TRUE(false);
229 GTEST_LOG_(INFO) << " Marshalling005 FAILED";
230 }
231 GTEST_LOG_(INFO) << "Marshalling005 End";
232 }
233
234 /*
235 * @tc.name: Marshalling006
236 * @tc.desc: Verify the Marshalling006 function.
237 * @tc.type: FUNC
238 * @tc.require: I6H5MH
239 */
240 HWTEST_F(CloudSyncCommonTest, Marshalling006, TestSize.Level1)
241 {
242 GTEST_LOG_(INFO) << "Marshalling006 Start";
243 try {
244 CleanOptions cleanOptions;
245 cleanOptions.appActionsData.insert(std::make_pair("1", 0));
246 Parcel parcel;
247 EXPECT_CALL(*parcel_, WriteUint32(_)).WillOnce(Return(false));
248 auto res = cleanOptions.Marshalling(parcel);
249 EXPECT_TRUE(!res);
250
251 EXPECT_CALL(*parcel_, WriteUint32(_)).WillOnce(Return(true));
252 EXPECT_CALL(*parcel_, WriteString(_)).WillOnce(Return(true));
253 EXPECT_CALL(*parcel_, WriteString(_)).WillOnce(Return(false));
254 res = cleanOptions.Marshalling(parcel);
255 EXPECT_TRUE(!res);
256 } catch (...) {
257 EXPECT_TRUE(false);
258 GTEST_LOG_(INFO) << " Marshalling006 FAILED";
259 }
260 GTEST_LOG_(INFO) << "Marshalling006 End";
261 }
262
263 /*
264 * @tc.name: Marshalling010
265 * @tc.desc: Verify the Marshalling010 function.
266 * @tc.type: FUNC
267 * @tc.require: ICEU6Z
268 */
269 HWTEST_F(CloudSyncCommonTest, Marshalling010, TestSize.Level1)
270 {
271 GTEST_LOG_(INFO) << "Marshalling010 Start";
272 try {
273 DownloadProgressObj downloadProgressObj;
274 Parcel parcel;
275
276 EXPECT_CALL(*parcel_, WriteString(_)).WillOnce(Return(true));
277 EXPECT_CALL(*parcel_, WriteInt32(_)).WillOnce(Return(true)).WillOnce(Return(false));
278 EXPECT_CALL(*parcel_, WriteInt64(_)).WillOnce(Return(true)).WillOnce(Return(true));
279 bool res = downloadProgressObj.Marshalling(parcel);
280 EXPECT_TRUE(!res);
281
282 EXPECT_CALL(*parcel_, WriteString(_)).WillOnce(Return(true));
283 EXPECT_CALL(*parcel_, WriteInt32(_)).WillOnce(Return(true)).WillOnce(Return(true));
284 EXPECT_CALL(*parcel_, WriteInt64(_)).WillOnce(Return(true))
285 .WillOnce(Return(true)).WillOnce(Return(false));
286 res = downloadProgressObj.Marshalling(parcel);
287 EXPECT_TRUE(!res);
288
289 EXPECT_CALL(*parcel_, WriteString(_)).WillOnce(Return(true));
290 EXPECT_CALL(*parcel_, WriteInt32(_)).WillOnce(Return(true)).WillOnce(Return(true));
291 EXPECT_CALL(*parcel_, WriteInt64(_)).WillOnce(Return(true))
292 .WillOnce(Return(true)).WillOnce(Return(true))
293 .WillOnce(Return(false));
294 res = downloadProgressObj.Marshalling(parcel);
295 EXPECT_TRUE(!res);
296
297 EXPECT_CALL(*parcel_, WriteString(_)).WillOnce(Return(true));
298 EXPECT_CALL(*parcel_, WriteInt32(_)).WillOnce(Return(true)).WillOnce(Return(true));
299 EXPECT_CALL(*parcel_, WriteInt64(_)).WillOnce(Return(true))
300 .WillOnce(Return(true)).WillOnce(Return(true))
301 .WillOnce(Return(true)).WillOnce(Return(false));
302 res = downloadProgressObj.Marshalling(parcel);
303 EXPECT_TRUE(!res);
304
305 EXPECT_CALL(*parcel_, WriteString(_)).WillOnce(Return(true));
306 EXPECT_CALL(*parcel_, WriteInt32(_)).WillOnce(Return(true)).WillOnce(Return(true));
307 EXPECT_CALL(*parcel_, WriteInt64(_)).WillOnce(Return(true))
308 .WillOnce(Return(true)).WillOnce(Return(true))
309 .WillOnce(Return(true)).WillOnce(Return(true)).WillOnce(Return(false));
310 res = downloadProgressObj.Marshalling(parcel);
311 EXPECT_TRUE(!res);
312 } catch (...) {
313 EXPECT_TRUE(false);
314 GTEST_LOG_(INFO) << " Marshalling010 FAILED";
315 }
316 GTEST_LOG_(INFO) << "Marshalling010 End";
317 }
318
319 /*
320 * @tc.name: Marshalling011
321 * @tc.desc: Verify the Marshalling011 function.
322 * @tc.type: FUNC
323 * @tc.require: ICEU6Z
324 */
325 HWTEST_F(CloudSyncCommonTest, Marshalling011, TestSize.Level1)
326 {
327 GTEST_LOG_(INFO) << "Marshalling011 Start";
328 try {
329 DownloadProgressObj downloadProgressObj;
330 Parcel parcel;
331
332 EXPECT_CALL(*parcel_, WriteString(_)).WillOnce(Return(true));
333 EXPECT_CALL(*parcel_, WriteInt32(_)).WillOnce(Return(true)).WillOnce(Return(true));
334 EXPECT_CALL(*parcel_, WriteInt64(_)).WillOnce(Return(true))
335 .WillOnce(Return(true)).WillOnce(Return(true))
336 .WillOnce(Return(true)).WillOnce(Return(true))
337 .WillOnce(Return(true)).WillOnce(Return(false));
338 bool res = downloadProgressObj.Marshalling(parcel);
339 EXPECT_TRUE(!res);
340
341 EXPECT_CALL(*parcel_, WriteString(_)).WillOnce(Return(true));
342 EXPECT_CALL(*parcel_, WriteInt32(_)).WillOnce(Return(true)).WillOnce(Return(true));
343 EXPECT_CALL(*parcel_, WriteInt64(_)).WillOnce(Return(true))
344 .WillOnce(Return(true)).WillOnce(Return(true))
345 .WillOnce(Return(true)).WillOnce(Return(true))
346 .WillOnce(Return(true)).WillOnce(Return(true)).WillOnce(Return(false));
347 res = downloadProgressObj.Marshalling(parcel);
348 EXPECT_TRUE(!res);
349
350 EXPECT_CALL(*parcel_, WriteString(_)).WillOnce(Return(true));
351 EXPECT_CALL(*parcel_, WriteInt32(_)).WillOnce(Return(true))
352 .WillOnce(Return(true)).WillOnce(Return(false));
353 EXPECT_CALL(*parcel_, WriteInt64(_)).WillOnce(Return(true))
354 .WillOnce(Return(true)).WillOnce(Return(true))
355 .WillOnce(Return(true)).WillOnce(Return(true))
356 .WillOnce(Return(true)).WillOnce(Return(true)).WillOnce(Return(true));
357 res = downloadProgressObj.Marshalling(parcel);
358 EXPECT_TRUE(!res);
359
360 EXPECT_CALL(*parcel_, WriteString(_)).WillOnce(Return(true));
361 EXPECT_CALL(*parcel_, WriteInt32(_)).WillOnce(Return(true))
362 .WillOnce(Return(true)).WillOnce(Return(true));
363 EXPECT_CALL(*parcel_, WriteInt64(_)).WillOnce(Return(true))
364 .WillOnce(Return(true)).WillOnce(Return(true))
365 .WillOnce(Return(true)).WillOnce(Return(true))
366 .WillOnce(Return(true)).WillOnce(Return(true)).WillOnce(Return(true));
367 res = downloadProgressObj.Marshalling(parcel);
368 EXPECT_TRUE(res);
369 } catch (...) {
370 EXPECT_TRUE(false);
371 GTEST_LOG_(INFO) << " Marshalling011 FAILED";
372 }
373 GTEST_LOG_(INFO) << "Marshalling011 End";
374 }
375
376 /*
377 * @tc.name: Marshalling009
378 * @tc.desc: Verify the Marshalling009 function.
379 * @tc.type: FUNC
380 * @tc.require: I6H5MH
381 */
382 HWTEST_F(CloudSyncCommonTest, Marshalling009, TestSize.Level1)
383 {
384 GTEST_LOG_(INFO) << "Marshalling009 Start";
385 try {
386 DowngradeProgress progress;
387 Parcel parcel;
388 EXPECT_CALL(*parcel_, WriteInt32(_)).WillOnce(Return(false));
389 auto res = progress.Marshalling(parcel);
390 EXPECT_TRUE(!res);
391
392 EXPECT_CALL(*parcel_, WriteInt32(_)).WillOnce(Return(true));
393 EXPECT_CALL(*parcel_, WriteInt32(_)).WillOnce(Return(false));
394 res = progress.Marshalling(parcel);
395 EXPECT_TRUE(!res);
396
397 EXPECT_CALL(*parcel_, WriteInt32(_)).WillOnce(Return(true)).WillOnce(Return(true));
398 EXPECT_CALL(*parcel_, WriteInt64(_)).WillOnce(Return(false));
399 res = progress.Marshalling(parcel);
400 EXPECT_TRUE(!res);
401
402 EXPECT_CALL(*parcel_, WriteInt32(_)).WillOnce(Return(true)).WillOnce(Return(true));
403 EXPECT_CALL(*parcel_, WriteInt64(_)).WillOnce(Return(true));
404 EXPECT_CALL(*parcel_, WriteInt64(_)).WillOnce(Return(false));
405 res = progress.Marshalling(parcel);
406 EXPECT_TRUE(!res);
407
408 EXPECT_CALL(*parcel_, WriteInt32(_)).WillOnce(Return(true)).WillOnce(Return(true)).WillOnce(Return(false));
409 EXPECT_CALL(*parcel_, WriteInt64(_)).WillOnce(Return(true)).WillOnce(Return(true));
410 res = progress.Marshalling(parcel);
411 EXPECT_TRUE(!res);
412
413 EXPECT_CALL(*parcel_, WriteInt32(_)).WillOnce(Return(true)).WillOnce(Return(true))
414 .WillOnce(Return(true)).WillOnce(Return(false));
415 EXPECT_CALL(*parcel_, WriteInt64(_)).WillOnce(Return(true)).WillOnce(Return(true));
416 res = progress.Marshalling(parcel);
417 EXPECT_TRUE(!res);
418
419 EXPECT_CALL(*parcel_, WriteInt32(_)).WillOnce(Return(true)).WillOnce(Return(true))
420 .WillOnce(Return(true)).WillOnce(Return(true)).WillOnce(Return(false));
421 EXPECT_CALL(*parcel_, WriteInt64(_)).WillOnce(Return(true)).WillOnce(Return(true));
422 res = progress.Marshalling(parcel);
423 EXPECT_TRUE(!res);
424
425 EXPECT_CALL(*parcel_, WriteInt32(_)).WillOnce(Return(true)).WillOnce(Return(true))
426 .WillOnce(Return(true)).WillOnce(Return(true)).WillOnce(Return(true));
427 EXPECT_CALL(*parcel_, WriteInt64(_)).WillOnce(Return(true)).WillOnce(Return(true));
428 res = progress.Marshalling(parcel);
429 EXPECT_TRUE(res);
430 } catch (...) {
431 EXPECT_TRUE(false);
432 GTEST_LOG_(INFO) << " Marshalling009 FAILED";
433 }
434 GTEST_LOG_(INFO) << "Marshalling009 End";
435 }
436
437 /*
438 * @tc.name: Marshalling008
439 * @tc.desc: Verify the Marshalling008 function.
440 * @tc.type: FUNC
441 * @tc.require: I6H5MH
442 */
443 HWTEST_F(CloudSyncCommonTest, Marshalling008, TestSize.Level1)
444 {
445 GTEST_LOG_(INFO) << "Marshalling008 Start";
446 try {
447 CloudFileInfo fileInfo;
448 Parcel parcel;
449 EXPECT_CALL(*parcel_, WriteInt32(_)).WillOnce(Return(false));
450 auto res = fileInfo.Marshalling(parcel);
451 EXPECT_TRUE(!res);
452
453 EXPECT_CALL(*parcel_, WriteInt32(_)).WillOnce(Return(true));
454 EXPECT_CALL(*parcel_, WriteInt64(_)).WillOnce(Return(false));
455 res = fileInfo.Marshalling(parcel);
456 EXPECT_TRUE(!res);
457
458 EXPECT_CALL(*parcel_, WriteInt32(_)).WillOnce(Return(true)).WillOnce(Return(false));
459 EXPECT_CALL(*parcel_, WriteInt64(_)).WillOnce(Return(true));
460 res = fileInfo.Marshalling(parcel);
461 EXPECT_TRUE(!res);
462
463 EXPECT_CALL(*parcel_, WriteInt32(_)).WillOnce(Return(true)).WillOnce(Return(true));
464 EXPECT_CALL(*parcel_, WriteInt64(_)).WillOnce(Return(true)).WillOnce(Return(false));
465 res = fileInfo.Marshalling(parcel);
466 EXPECT_TRUE(!res);
467
468 EXPECT_CALL(*parcel_, WriteInt32(_)).WillOnce(Return(true)).WillOnce(Return(true)).WillOnce(Return(false));
469 EXPECT_CALL(*parcel_, WriteInt64(_)).WillOnce(Return(true)).WillOnce(Return(true));
470 res = fileInfo.Marshalling(parcel);
471 EXPECT_TRUE(!res);
472
473 EXPECT_CALL(*parcel_, WriteInt32(_)).WillOnce(Return(true)).WillOnce(Return(true)).WillOnce(Return(true));
474 EXPECT_CALL(*parcel_, WriteInt64(_)).WillOnce(Return(true)).WillOnce(Return(true)).WillOnce(Return(false));
475 res = fileInfo.Marshalling(parcel);
476 EXPECT_TRUE(!res);
477
478 EXPECT_CALL(*parcel_, WriteInt32(_)).WillOnce(Return(true)).WillOnce(Return(true)).WillOnce(Return(true));
479 EXPECT_CALL(*parcel_, WriteInt64(_)).WillOnce(Return(true)).WillOnce(Return(true)).WillOnce(Return(true));
480 res = fileInfo.Marshalling(parcel);
481 EXPECT_TRUE(res);
482 } catch (...) {
483 EXPECT_TRUE(false);
484 GTEST_LOG_(INFO) << " Marshalling008 FAILED";
485 }
486 GTEST_LOG_(INFO) << "Marshalling008 End";
487 }
488
489 /*
490 * @tc.name: Unmarshalling001
491 * @tc.desc: Verify the Unmarshalling001 function.
492 * @tc.type: FUNC
493 * @tc.require: I6H5MH
494 */
495 HWTEST_F(CloudSyncCommonTest, Unmarshalling001, TestSize.Level1)
496 {
497 GTEST_LOG_(INFO) << "Unmarshalling001 Start";
498 try {
499 auto switchDataObj = make_shared<SwitchDataObj>();
500 Parcel parcel;
501 EXPECT_CALL(*parcel_, ReadUint32(_)).WillOnce(Return(false));
502 auto res = switchDataObj->Unmarshalling(parcel);
503 EXPECT_TRUE(res == nullptr);
504 } catch (...) {
505 EXPECT_TRUE(false);
506 GTEST_LOG_(INFO) << " Unmarshalling001 FAILED";
507 }
508 GTEST_LOG_(INFO) << "Unmarshalling001 End";
509 }
510
511 /*
512 * @tc.name: Unmarshalling002
513 * @tc.desc: Verify the Unmarshalling002 function.
514 * @tc.type: FUNC
515 * @tc.require: I6H5MH
516 */
517 HWTEST_F(CloudSyncCommonTest, Unmarshalling002, TestSize.Level1)
518 {
519 GTEST_LOG_(INFO) << "Unmarshalling002 Start";
520 try {
521 auto downloadProgressObj = make_shared<DownloadProgressObj>();
522 Parcel parcel;
523 EXPECT_CALL(*parcel_, ReadString(_)).WillOnce(Return(false));
524 auto res = downloadProgressObj->Unmarshalling(parcel);
525 EXPECT_TRUE(res == nullptr);
526 } catch (...) {
527 EXPECT_TRUE(false);
528 GTEST_LOG_(INFO) << " Unmarshalling002 FAILED";
529 }
530 GTEST_LOG_(INFO) << "Unmarshalling002 End";
531 }
532
533 /*
534 * @tc.name: Unmarshalling003
535 * @tc.desc: Verify the Unmarshalling003 function.
536 * @tc.type: FUNC
537 * @tc.require: I6H5MH
538 */
539 HWTEST_F(CloudSyncCommonTest, Unmarshalling003, TestSize.Level1)
540 {
541 GTEST_LOG_(INFO) << "Unmarshalling003 Start";
542 try {
543 auto cleanOptions = make_shared<CleanOptions>();
544 Parcel parcel;
545 EXPECT_CALL(*parcel_, ReadUint32(_)).WillOnce(Return(false));
546 auto res = cleanOptions->Unmarshalling(parcel);
547 EXPECT_TRUE(res == nullptr);
548 } catch (...) {
549 EXPECT_TRUE(false);
550 GTEST_LOG_(INFO) << " Unmarshalling003 FAILED";
551 }
552 GTEST_LOG_(INFO) << "Unmarshalling003 End";
553 }
554
555 /*
556 * @tc.name: Unmarshalling004
557 * @tc.desc: Verify the Unmarshalling004 function.
558 * @tc.type: FUNC
559 * @tc.require: I6H5MH
560 */
561 HWTEST_F(CloudSyncCommonTest, Unmarshalling004, TestSize.Level1)
562 {
563 GTEST_LOG_(INFO) << "Unmarshalling004 Start";
564 try {
565 auto progress = make_shared<DowngradeProgress>();
566 Parcel parcel;
567 EXPECT_CALL(*parcel_, ReadInt32(_)).WillOnce(Return(false));
568 auto res = progress->Unmarshalling(parcel);
569 EXPECT_TRUE(res == nullptr);
570 } catch (...) {
571 EXPECT_TRUE(false);
572 GTEST_LOG_(INFO) << " Unmarshalling004 FAILED";
573 }
574 GTEST_LOG_(INFO) << "Unmarshalling004 End";
575 }
576
577 /*
578 * @tc.name: Unmarshalling005
579 * @tc.desc: Verify the Unmarshalling005 function.
580 * @tc.type: FUNC
581 * @tc.require: I6H5MH
582 */
583 HWTEST_F(CloudSyncCommonTest, Unmarshalling005, TestSize.Level1)
584 {
585 GTEST_LOG_(INFO) << "Unmarshalling005 Start";
586 try {
587 auto fileInfo = make_shared<CloudFileInfo>();
588 Parcel parcel;
589 EXPECT_CALL(*parcel_, ReadInt32(_)).WillOnce(Return(false));
590 auto res = fileInfo->Unmarshalling(parcel);
591 EXPECT_TRUE(res == nullptr);
592 } catch (...) {
593 EXPECT_TRUE(false);
594 GTEST_LOG_(INFO) << " Unmarshalling005 FAILED";
595 }
596 GTEST_LOG_(INFO) << "Unmarshalling005 End";
597 }
598
599 /*
600 * @tc.name: ReadFromParcel001
601 * @tc.desc: Verify the ReadFromParcel001 function.
602 * @tc.type: FUNC
603 * @tc.require: I6H5MH
604 */
605 HWTEST_F(CloudSyncCommonTest, ReadFromParcel001, TestSize.Level1)
606 {
607 GTEST_LOG_(INFO) << "ReadFromParcel001 Start";
608 try {
609 SwitchDataObj switchDataObj;
610 Parcel parcel;
611 EXPECT_CALL(*parcel_, ReadUint32(_)).WillOnce(Return(false));
612 auto res = switchDataObj.ReadFromParcel(parcel);
613 EXPECT_TRUE(!res);
614 } catch (...) {
615 EXPECT_TRUE(false);
616 GTEST_LOG_(INFO) << " ReadFromParcel001 FAILED";
617 }
618 GTEST_LOG_(INFO) << "ReadFromParcel001 End";
619 }
620
621 /*
622 * @tc.name: ReadFromParcel002
623 * @tc.desc: Verify the ReadFromParcel002 function.
624 * @tc.type: FUNC
625 * @tc.require: I6H5MH
626 */
627 HWTEST_F(CloudSyncCommonTest, ReadFromParcel002, TestSize.Level1)
628 {
629 GTEST_LOG_(INFO) << "ReadFromParcel002 Start";
630 try {
631 SwitchDataObj switchDataObj;
632 Parcel parcel;
633 EXPECT_CALL(*parcel_, ReadUint32(_)).WillOnce(DoAll(SetArgReferee<0>(MAX_MAP_SIZE + 1), Return(true)));
634 auto res = switchDataObj.ReadFromParcel(parcel);
635 EXPECT_TRUE(!res);
636 } catch (...) {
637 EXPECT_TRUE(false);
638 GTEST_LOG_(INFO) << " ReadFromParcel002 FAILED";
639 }
640 GTEST_LOG_(INFO) << "ReadFromParcel002 End";
641 }
642
643 /*
644 * @tc.name: ReadFromParcel003
645 * @tc.desc: Verify the ReadFromParcel003 function.
646 * @tc.type: FUNC
647 * @tc.require: I6H5MH
648 */
649 HWTEST_F(CloudSyncCommonTest, ReadFromParcel003, TestSize.Level1)
650 {
651 GTEST_LOG_(INFO) << "ReadFromParcel003 Start";
652 try {
653 SwitchDataObj switchDataObj;
654 Parcel parcel;
655 EXPECT_CALL(*parcel_, ReadUint32(_)).WillOnce(DoAll(SetArgReferee<0>(1), Return(true)));
656 EXPECT_CALL(*parcel_, ReadString(_)).WillOnce(Return(false));
657 auto res = switchDataObj.ReadFromParcel(parcel);
658 EXPECT_TRUE(!res);
659
660 EXPECT_CALL(*parcel_, ReadUint32(_)).WillOnce(DoAll(SetArgReferee<0>(1), Return(true)));
661 EXPECT_CALL(*parcel_, ReadString(_)).WillOnce(Return(true));
662 EXPECT_CALL(*parcel_, ReadBool(_)).WillOnce(Return(false));
663 res = switchDataObj.ReadFromParcel(parcel);
664 EXPECT_TRUE(!res);
665
666 EXPECT_CALL(*parcel_, ReadUint32(_)).WillOnce(Return(true));
667 EXPECT_CALL(*parcel_, ReadString(_)).WillOnce(DoAll(SetArgReferee<0>("123"), Return(true)));
668 EXPECT_CALL(*parcel_, ReadBool(_)).WillOnce(DoAll(SetArgReferee<0>(false), Return(true)));
669 res = switchDataObj.ReadFromParcel(parcel);
670 EXPECT_TRUE(res);
671 } catch (...) {
672 EXPECT_TRUE(false);
673 GTEST_LOG_(INFO) << " ReadFromParcel003 FAILED";
674 }
675 GTEST_LOG_(INFO) << "ReadFromParcel003 End";
676 }
677
678 /*
679 * @tc.name: ReadFromParcel004
680 * @tc.desc: Verify the ReadFromParcel004 function.
681 * @tc.type: FUNC
682 * @tc.require: I6H5MH
683 */
684 HWTEST_F(CloudSyncCommonTest, ReadFromParcel004, TestSize.Level1)
685 {
686 GTEST_LOG_(INFO) << "ReadFromParcel004 Start";
687 try {
688 CleanOptions cleanOptions;
689 Parcel parcel;
690 EXPECT_CALL(*parcel_, ReadUint32(_)).WillOnce(Return(false));
691 auto res = cleanOptions.ReadFromParcel(parcel);
692 EXPECT_TRUE(!res);
693 } catch (...) {
694 EXPECT_TRUE(false);
695 GTEST_LOG_(INFO) << " ReadFromParcel004 FAILED";
696 }
697 GTEST_LOG_(INFO) << "ReadFromParcel004 End";
698 }
699
700 /*
701 * @tc.name: ReadFromParcel005
702 * @tc.desc: Verify the ReadFromParcel005 function.
703 * @tc.type: FUNC
704 * @tc.require: I6H5MH
705 */
706 HWTEST_F(CloudSyncCommonTest, ReadFromParcel005, TestSize.Level1)
707 {
708 GTEST_LOG_(INFO) << "ReadFromParcel005 Start";
709 try {
710 CleanOptions cleanOptions;
711 Parcel parcel;
712 EXPECT_CALL(*parcel_, ReadUint32(_)).WillOnce(DoAll(SetArgReferee<0>(MAX_MAP_SIZE + 1), Return(true)));
713 auto res = cleanOptions.ReadFromParcel(parcel);
714 EXPECT_TRUE(!res);
715 } catch (...) {
716 EXPECT_TRUE(false);
717 GTEST_LOG_(INFO) << " ReadFromParcel005 FAILED";
718 }
719 GTEST_LOG_(INFO) << "ReadFromParcel005 End";
720 }
721
722 /*
723 * @tc.name: ReadFromParcel006
724 * @tc.desc: Verify the ReadFromParcel006 function.
725 * @tc.type: FUNC
726 * @tc.require: I6H5MH
727 */
728 HWTEST_F(CloudSyncCommonTest, ReadFromParcel006, TestSize.Level1)
729 {
730 GTEST_LOG_(INFO) << "ReadFromParcel006 Start";
731 try {
732 CleanOptions cleanOptions;
733 Parcel parcel;
734
735 EXPECT_CALL(*parcel_, ReadUint32(_)).WillOnce(DoAll(SetArgReferee<0>(1), Return(true)));
736 EXPECT_CALL(*parcel_, ReadString(_)).WillOnce(Return(false));
737 bool res = cleanOptions.ReadFromParcel(parcel);
738 EXPECT_TRUE(!res);
739
740 EXPECT_CALL(*parcel_, ReadUint32(_)).WillOnce(DoAll(SetArgReferee<0>(1), Return(true)));
741 EXPECT_CALL(*parcel_, ReadString(_)).WillOnce(Return(true));
742 EXPECT_CALL(*parcel_, ReadInt32(_)).WillOnce(Return(false));
743 res = cleanOptions.ReadFromParcel(parcel);
744 EXPECT_TRUE(!res);
745
746 EXPECT_CALL(*parcel_, ReadUint32(_)).WillOnce(DoAll(SetArgReferee<0>(1), Return(true)));
747 EXPECT_CALL(*parcel_, ReadString(_)).WillOnce(DoAll(SetArgReferee<0>("123"), Return(true)));
748 EXPECT_CALL(*parcel_, ReadInt32(_)).WillOnce(DoAll(SetArgReferee<0>(1), Return(true)));
749 res = cleanOptions.ReadFromParcel(parcel);
750 EXPECT_TRUE(res);
751 } catch (...) {
752 EXPECT_TRUE(false);
753 GTEST_LOG_(INFO) << " ReadFromParcel006 FAILED";
754 }
755 GTEST_LOG_(INFO) << "ReadFromParcel006 End";
756 }
757
758 /*
759 * @tc.name: ReadFromParcel007
760 * @tc.desc: Verify the ReadFromParcel007 function.
761 * @tc.type: FUNC
762 * @tc.require: I6H5MH
763 */
764 HWTEST_F(CloudSyncCommonTest, ReadFromParcel007, TestSize.Level1)
765 {
766 GTEST_LOG_(INFO) << "ReadFromParcel007 Start";
767 try {
768 DownloadProgressObj downloadProgressObj;
769 Parcel parcel;
770 EXPECT_CALL(*parcel_, ReadString(_)).WillOnce(Return(false));
771 auto res = downloadProgressObj.ReadFromParcel(parcel);
772 EXPECT_TRUE(!res);
773
774 EXPECT_CALL(*parcel_, ReadString(_)).WillOnce(Return(true));
775 EXPECT_CALL(*parcel_, ReadInt32(_)).WillOnce(Return(false));
776 res = downloadProgressObj.ReadFromParcel(parcel);
777 EXPECT_TRUE(!res);
778
779 EXPECT_CALL(*parcel_, ReadString(_)).WillOnce(Return(true));
780 EXPECT_CALL(*parcel_, ReadInt32(_)).WillOnce(Return(true));
781 EXPECT_CALL(*parcel_, ReadInt64(_)).WillOnce(Return(false));
782 EXPECT_TRUE(!res);
783
784 EXPECT_CALL(*parcel_, ReadString(_)).WillOnce(Return(true));
785 EXPECT_CALL(*parcel_, ReadInt32(_)).WillOnce(Return(true));
786 EXPECT_CALL(*parcel_, ReadInt64(_)).WillOnce(Return(true)).WillOnce(Return(false));
787 EXPECT_TRUE(!res);
788
789 EXPECT_CALL(*parcel_, ReadString(_)).WillOnce(Return(true));
790 EXPECT_CALL(*parcel_, ReadInt32(_)).WillOnce(Return(true)).WillOnce(Return(false));
791 EXPECT_CALL(*parcel_, ReadInt64(_)).WillOnce(Return(true)).WillOnce(Return(true));
792 res = downloadProgressObj.ReadFromParcel(parcel);
793 EXPECT_TRUE(!res);
794
795 EXPECT_CALL(*parcel_, ReadString(_)).WillOnce(Return(true));
796 EXPECT_CALL(*parcel_, ReadInt32(_)).WillOnce(Return(true)).WillOnce(Return(true));
797 EXPECT_CALL(*parcel_, ReadInt64(_)).WillOnce(Return(true)).WillOnce(Return(true)).WillOnce(Return(false));
798 res = downloadProgressObj.ReadFromParcel(parcel);
799 EXPECT_TRUE(!res);
800 } catch (...) {
801 EXPECT_TRUE(false);
802 GTEST_LOG_(INFO) << " ReadFromParcel007 FAILED";
803 }
804 GTEST_LOG_(INFO) << "ReadFromParcel007 End";
805 }
806
807 /*
808 * @tc.name: to_string
809 * @tc.desc: Verify the to_string function.
810 * @tc.type: FUNC
811 * @tc.require: I6H5MH
812 */
813 HWTEST_F(CloudSyncCommonTest, to_string, TestSize.Level1)
814 {
815 GTEST_LOG_(INFO) << "to_string Start";
816 try {
817 DownloadProgressObj downloadProgressObj;
818 auto res = downloadProgressObj.to_string();
819 std::string expectStr =
820 "DownloadProgressObj [path: ******** state: 0 downloaded: 0 total: 0 downloadErrorType: 0 "
821 "downloadId: 0 batchState: 0 batchDownloadSize: 0 batchTotalSize: 0 "
822 "batchSuccNum: 0 batchFailNum: 0 batchTotalNum: 0]";
823 EXPECT_EQ(res, expectStr);
824 } catch (...) {
825 EXPECT_TRUE(false);
826 GTEST_LOG_(INFO) << " to_string FAILED";
827 }
828 GTEST_LOG_(INFO) << "to_string End";
829 }
830
831 /*
832 * @tc.name: to_string
833 * @tc.desc: Verify the to_string function.
834 * @tc.type: FUNC
835 * @tc.require: I6H5MH
836 */
837 HWTEST_F(CloudSyncCommonTest, DowngradeProgress_to_string, TestSize.Level1)
838 {
839 GTEST_LOG_(INFO) << "to_string Start";
840 try {
841 DowngradeProgress progress;
842 auto res = progress.to_string();
843 progress.state = DowngradeProgress::RUNNING;
844 progress.stopReason = DowngradeProgress::NO_STOP;
845 progress.downloadedSize = 0;
846 progress.totalSize = 0;
847 progress.successfulCount = 0;
848 progress.failedCount = 0;
849 progress.totalCount = 0;
850
851 std::string expectStr =
852 "DowngradeProgress [DownloadState: 0 downloadStopReason: 0 downloadedSize: 0 totalSize: 0 "
853 "successfulCount: 0 failedCount: 0 totalCount: 0]";
854 EXPECT_EQ(res, expectStr);
855 } catch (...) {
856 EXPECT_TRUE(false);
857 GTEST_LOG_(INFO) << " to_string FAILED";
858 }
859 GTEST_LOG_(INFO) << "to_string End";
860 }
861
862 /*
863 * @tc.name: ReadFromParcel00
864 * @tc.desc: Verify the ReadFromParcel00 function.
865 * @tc.type: FUNC
866 * @tc.require: I6H5MH
867 */
868 HWTEST_F(CloudSyncCommonTest, ReadFromParcel00, TestSize.Level1)
869 {
870 GTEST_LOG_(INFO) << "ReadFromParcel00 Start";
871 try {
872 AssetInfoObj assetInfo;
873 Parcel parcel;
874 bool returnValues[5] = {true, true, true, true, true};
875 int callCount = 0;
876
__anon41fa3f050102() 877 EXPECT_CALL(*parcel_, ReadString(_)).Times(5).WillRepeatedly(Invoke([&]() {
878 return returnValues[callCount++];
879 }));
880 auto res = assetInfo.ReadFromParcel(parcel);
881 EXPECT_TRUE(res);
882 } catch (...) {
883 EXPECT_TRUE(false);
884 GTEST_LOG_(INFO) << " ReadFromParcel00 FAILED";
885 }
886 GTEST_LOG_(INFO) << "ReadFromParcel00 End";
887 }
888
889 /*
890 * @tc.name: ReadFromParcel100
891 * @tc.desc: Verify the ReadFromParcel function.
892 * @tc.type: FUNC
893 * @tc.require: I6H5MH
894 */
895 HWTEST_F(CloudSyncCommonTest, ReadFromParcel100, TestSize.Level1)
896 {
897 GTEST_LOG_(INFO) << "ReadFromParcel100 Start";
898 try {
899 DowngradeProgress progress;
900 Parcel parcel;
901 EXPECT_CALL(*parcel_, ReadInt32(_)).WillOnce(Return(false));
902 auto res = progress.ReadFromParcel(parcel);
903 EXPECT_TRUE(!res);
904
905 EXPECT_CALL(*parcel_, ReadInt32(_)).WillOnce(Return(true)).WillOnce(Return(false));
906 res = progress.ReadFromParcel(parcel);
907 EXPECT_TRUE(!res);
908
909 EXPECT_CALL(*parcel_, ReadInt32(_)).WillOnce(Return(true)).WillOnce(Return(true));
910 EXPECT_CALL(*parcel_, ReadInt64(_)).WillOnce(Return(false));
911 res = progress.ReadFromParcel(parcel);
912 EXPECT_TRUE(!res);
913
914 EXPECT_CALL(*parcel_, ReadInt32(_)).WillOnce(Return(true)).WillOnce(Return(true));
915 EXPECT_CALL(*parcel_, ReadInt64(_)).WillOnce(Return(true)).WillOnce(Return(false));
916 res = progress.ReadFromParcel(parcel);
917 EXPECT_TRUE(!res);
918
919 EXPECT_CALL(*parcel_, ReadInt32(_)).WillOnce(Return(true)).WillOnce(Return(true)).WillOnce(Return(false));
920 EXPECT_CALL(*parcel_, ReadInt64(_)).WillOnce(Return(true)).WillOnce(Return(true));
921 res = progress.ReadFromParcel(parcel);
922 EXPECT_TRUE(!res);
923
924 EXPECT_CALL(*parcel_, ReadInt32(_)).WillOnce(Return(true)).WillOnce(Return(true))
925 .WillOnce(Return(true)).WillOnce(Return(false));
926 EXPECT_CALL(*parcel_, ReadInt64(_)).WillOnce(Return(true)).WillOnce(Return(true));
927 res = progress.ReadFromParcel(parcel);
928 EXPECT_TRUE(!res);
929
930 EXPECT_CALL(*parcel_, ReadInt32(_)).WillOnce(Return(true)).WillOnce(Return(true))
931 .WillOnce(Return(true)).WillOnce(Return(true)).WillOnce(Return(false));
932 EXPECT_CALL(*parcel_, ReadInt64(_)).WillOnce(Return(true)).WillOnce(Return(true));
933 res = progress.ReadFromParcel(parcel);
934 EXPECT_TRUE(!res);
935
936 EXPECT_CALL(*parcel_, ReadInt32(_)).WillOnce(Return(true)).WillOnce(Return(true))
937 .WillOnce(Return(true)).WillOnce(Return(true)).WillOnce(Return(true));
938 EXPECT_CALL(*parcel_, ReadInt64(_)).WillOnce(Return(true)).WillOnce(Return(true));
939 res = progress.ReadFromParcel(parcel);
940 EXPECT_TRUE(res);
941 } catch (...) {
942 EXPECT_TRUE(false);
943 GTEST_LOG_(INFO) << " ReadFromParcel100 FAILED";
944 }
945 GTEST_LOG_(INFO) << "ReadFromParcel100 End";
946 }
947
948 /*
949 * @tc.name: ReadFromParcel101
950 * @tc.desc: Verify the ReadFromParcel function.
951 * @tc.type: FUNC
952 * @tc.require: I6H5MH
953 */
954 HWTEST_F(CloudSyncCommonTest, ReadFromParcel101, TestSize.Level1)
955 {
956 GTEST_LOG_(INFO) << "ReadFromParcel101 Start";
957 try {
958 CloudFileInfo finleInfo;
959 Parcel parcel;
960 EXPECT_CALL(*parcel_, ReadInt32(_)).WillOnce(Return(false));
961 auto res = finleInfo.ReadFromParcel(parcel);
962 EXPECT_TRUE(!res);
963
964 EXPECT_CALL(*parcel_, ReadInt32(_)).WillOnce(Return(true));
965 EXPECT_CALL(*parcel_, ReadInt64(_)).WillOnce(Return(false));
966 res = finleInfo.ReadFromParcel(parcel);
967 EXPECT_TRUE(!res);
968
969 EXPECT_CALL(*parcel_, ReadInt32(_)).WillOnce(Return(true)).WillOnce(Return(false));
970 EXPECT_CALL(*parcel_, ReadInt64(_)).WillOnce(Return(true));
971 res = finleInfo.ReadFromParcel(parcel);
972 EXPECT_TRUE(!res);
973
974 EXPECT_CALL(*parcel_, ReadInt32(_)).WillOnce(Return(true)).WillOnce(Return(true));
975 EXPECT_CALL(*parcel_, ReadInt64(_)).WillOnce(Return(true)).WillOnce(Return(false));
976 res = finleInfo.ReadFromParcel(parcel);
977 EXPECT_TRUE(!res);
978
979 EXPECT_CALL(*parcel_, ReadInt32(_)).WillOnce(Return(true)).WillOnce(Return(true)).WillOnce(Return(false));
980 EXPECT_CALL(*parcel_, ReadInt64(_)).WillOnce(Return(true)).WillOnce(Return(true));
981 res = finleInfo.ReadFromParcel(parcel);
982 EXPECT_TRUE(!res);
983
984 EXPECT_CALL(*parcel_, ReadInt32(_)).WillOnce(Return(true)).WillOnce(Return(true)).WillOnce(Return(true));
985 EXPECT_CALL(*parcel_, ReadInt64(_)).WillOnce(Return(true)).WillOnce(Return(true)).WillOnce(Return(false));
986 res = finleInfo.ReadFromParcel(parcel);
987 EXPECT_TRUE(!res);
988
989 EXPECT_CALL(*parcel_, ReadInt32(_)).WillOnce(Return(true)).WillOnce(Return(true)).WillOnce(Return(true));
990 EXPECT_CALL(*parcel_, ReadInt64(_)).WillOnce(Return(true)).WillOnce(Return(true)).WillOnce(Return(true));
991 res = finleInfo.ReadFromParcel(parcel);
992 EXPECT_TRUE(res);
993 } catch (...) {
994 EXPECT_TRUE(false);
995 GTEST_LOG_(INFO) << " ReadFromParcel101 FAILED";
996 }
997 GTEST_LOG_(INFO) << "ReadFromParcel101 End";
998 }
999
1000 /*
1001 * @tc.name: Marshalling007
1002 * @tc.desc: Verify the Marshalling007 function.
1003 * @tc.type: FUNC
1004 * @tc.require: I6H5MH
1005 */
1006 HWTEST_F(CloudSyncCommonTest, Marshalling007, TestSize.Level1)
1007 {
1008 GTEST_LOG_(INFO) << "Marshalling007 Start";
1009 try {
1010 AssetInfoObj assetInfo;
1011 Parcel parcel;
1012 bool returnValues[5] = {true, true, true, true, true};
1013 int callCount = 0;
1014
__anon41fa3f050202() 1015 EXPECT_CALL(*parcel_, WriteString(_)).Times(5).WillRepeatedly(Invoke([&]() {
1016 return returnValues[callCount++];
1017 }));
1018 auto res = assetInfo.Marshalling(parcel);
1019 EXPECT_TRUE(res);
1020 } catch (...) {
1021 EXPECT_TRUE(false);
1022 GTEST_LOG_(INFO) << " Marshalling007 FAILED";
1023 }
1024 GTEST_LOG_(INFO) << "Marshalling007 End";
1025 }
1026
1027 /*
1028 * @tc.name: Unmarshalling
1029 * @tc.desc: Verify the Unmarshalling function.
1030 * @tc.type: FUNC
1031 * @tc.require: I6H5MH
1032 */
1033 HWTEST_F(CloudSyncCommonTest, Unmarshalling, TestSize.Level1)
1034 {
1035 GTEST_LOG_(INFO) << "Unmarshalling Start";
1036 try {
1037 auto assetInfo = make_shared<AssetInfoObj>();
1038 Parcel parcel;
1039 bool returnValues[5] = {true, true, true, true, true};
1040 int callCount = 0;
1041
__anon41fa3f050302() 1042 EXPECT_CALL(*parcel_, ReadString(_)).Times(5).WillRepeatedly(Invoke([&]() {
1043 return returnValues[callCount++];
1044 }));
1045 auto res = assetInfo->Unmarshalling(parcel);
1046 EXPECT_TRUE(res != nullptr);
1047 } catch (...) {
1048 EXPECT_TRUE(false);
1049 GTEST_LOG_(INFO) << " Unmarshalling FAILED";
1050 }
1051 GTEST_LOG_(INFO) << "Unmarshalling End";
1052 }
1053
1054 /*
1055 * @tc.name: Unmarshalling
1056 * @tc.desc: Verify the Unmarshalling function.
1057 * @tc.type: FUNC
1058 * @tc.require: I6H5MH
1059 */
1060 HWTEST_F(CloudSyncCommonTest, UnmarshallingTest1, TestSize.Level1)
1061 {
1062 GTEST_LOG_(INFO) << "UnmarshallingTest1 Start";
1063 try {
1064 auto Info = make_shared<DentryFileInfoObj>();
1065 Parcel parcel;
1066 bool returnValues[4] = {true, true, true, true};
1067 int callCount = 0;
1068
__anon41fa3f050402() 1069 EXPECT_CALL(*parcel_, ReadString(_)).Times(4).WillRepeatedly(Invoke([&]() {
1070 return returnValues[callCount++];
1071 }));
1072 EXPECT_CALL(*parcel_, ReadInt64(_)).WillOnce(Return(true)).WillOnce(Return(true));
1073 auto res = Info->Unmarshalling(parcel);
1074 EXPECT_TRUE(res != nullptr);
1075 } catch (...) {
1076 EXPECT_TRUE(false);
1077 GTEST_LOG_(INFO) << " UnmarshallingTest1 FAILED";
1078 }
1079 GTEST_LOG_(INFO) << "UnmarshallingTest1 End";
1080 }
1081
1082 /*
1083 * @tc.name: Unmarshalling
1084 * @tc.desc: Verify the Unmarshalling function.
1085 * @tc.type: FUNC
1086 * @tc.require: I6H5MH
1087 */
1088 HWTEST_F(CloudSyncCommonTest, UnmarshallingTest2, TestSize.Level1)
1089 {
1090 GTEST_LOG_(INFO) << "UnmarshallingTest2 Start";
1091 try {
1092 auto Info = make_shared<CleanFileInfoObj>();
1093 Parcel parcel;
1094 bool returnValues[3] = {true, true, true};
1095 int callCount = 0;
1096
__anon41fa3f050502() 1097 EXPECT_CALL(*parcel_, ReadString(_)).Times(3).WillRepeatedly(Invoke([&]() {
1098 return returnValues[callCount++];
1099 }));
1100 EXPECT_CALL(*parcel_, ReadInt64(_)).WillOnce(Return(true)).WillOnce(Return(true));
1101 EXPECT_CALL(*parcel_, ReadStringVector(_)).WillOnce(Return(true));
1102 auto res = Info->Unmarshalling(parcel);
1103 EXPECT_TRUE(res != nullptr);
1104 } catch (...) {
1105 EXPECT_TRUE(false);
1106 GTEST_LOG_(INFO) << " UnmarshallingTest2 FAILED";
1107 }
1108 GTEST_LOG_(INFO) << "UnmarshallingTest2 End";
1109 }
1110
1111 /*
1112 * @tc.name: Marshalling
1113 * @tc.desc: Verify the HistoryVersion::Marshalling function.
1114 * @tc.type: FUNC
1115 * @tc.require: ICGORT
1116 */
1117 HWTEST_F(CloudSyncCommonTest, MarshallingTest001, TestSize.Level1)
1118 {
1119 GTEST_LOG_(INFO) << "MarshallingTest001 Start";
1120 try {
1121 auto version = make_shared<HistoryVersion>();
1122 Parcel parcel;
1123
1124 EXPECT_CALL(*parcel_, WriteInt64(_)).WillOnce(Return(false));
1125 auto res = version->Marshalling(parcel);
1126 EXPECT_FALSE(res);
1127
1128 EXPECT_CALL(*parcel_, WriteInt64(_)).WillOnce(Return(true));
1129 EXPECT_CALL(*parcel_, WriteUint64(_)).WillOnce(Return(false));
1130 res = version->Marshalling(parcel);
1131 EXPECT_FALSE(res);
1132
1133 EXPECT_CALL(*parcel_, WriteInt64(_)).WillOnce(Return(true));
1134 EXPECT_CALL(*parcel_, WriteUint64(_)).WillOnce(Return(true)).WillOnce(Return(false));
1135 res = version->Marshalling(parcel);
1136 EXPECT_FALSE(res);
1137
1138 EXPECT_CALL(*parcel_, WriteInt64(_)).WillOnce(Return(true));
1139 EXPECT_CALL(*parcel_, WriteUint64(_)).WillOnce(Return(true)).WillOnce(Return(true));
1140 EXPECT_CALL(*parcel_, WriteString(_)).WillOnce(Return(false));
1141 res = version->Marshalling(parcel);
1142 EXPECT_FALSE(res);
1143 } catch (...) {
1144 EXPECT_TRUE(false);
1145 GTEST_LOG_(INFO) << " MarshallingTest001 FAILED";
1146 }
1147 GTEST_LOG_(INFO) << "MarshallingTest001 End";
1148 }
1149
1150 /*
1151 * @tc.name: Marshalling
1152 * @tc.desc: Verify the HistoryVersion::Marshalling function.
1153 * @tc.type: FUNC
1154 * @tc.require: ICGORT
1155 */
1156 HWTEST_F(CloudSyncCommonTest, MarshallingTest002, TestSize.Level1)
1157 {
1158 GTEST_LOG_(INFO) << "MarshallingTest002 Start";
1159 try {
1160 auto version = make_shared<HistoryVersion>();
1161 Parcel parcel;
1162
1163 EXPECT_CALL(*parcel_, WriteInt64(_)).WillOnce(Return(true));
1164 EXPECT_CALL(*parcel_, WriteUint64(_)).WillOnce(Return(true)).WillOnce(Return(true));
1165 EXPECT_CALL(*parcel_, WriteString(_)).WillOnce(Return(true)).WillOnce(Return(false));
1166 auto res = version->Marshalling(parcel);
1167 EXPECT_FALSE(res);
1168
1169 EXPECT_CALL(*parcel_, WriteInt64(_)).WillOnce(Return(true));
1170 EXPECT_CALL(*parcel_, WriteUint64(_)).WillOnce(Return(true)).WillOnce(Return(true));
1171 EXPECT_CALL(*parcel_, WriteString(_)).WillOnce(Return(true)).WillOnce(Return(true));
1172 EXPECT_CALL(*parcel_, WriteBool(_)).WillOnce(Return(false));
1173 res = version->Marshalling(parcel);
1174 EXPECT_FALSE(res);
1175
1176 EXPECT_CALL(*parcel_, WriteInt64(_)).WillOnce(Return(true));
1177 EXPECT_CALL(*parcel_, WriteUint64(_)).WillOnce(Return(true)).WillOnce(Return(true));
1178 EXPECT_CALL(*parcel_, WriteString(_)).WillOnce(Return(true)).WillOnce(Return(true));
1179 EXPECT_CALL(*parcel_, WriteBool(_)).WillOnce(Return(true));
1180 res = version->Marshalling(parcel);
1181 EXPECT_TRUE(res);
1182 } catch (...) {
1183 EXPECT_TRUE(false);
1184 GTEST_LOG_(INFO) << " MarshallingTest002 FAILED";
1185 }
1186 GTEST_LOG_(INFO) << "MarshallingTest002 End";
1187 }
1188
1189 /*
1190 * @tc.name: Unmarshalling
1191 * @tc.desc: Verify the HistoryVersion::Unmarshalling function.
1192 * @tc.type: FUNC
1193 * @tc.require: ICGORT
1194 */
1195 HWTEST_F(CloudSyncCommonTest, UnmarshallingTest001, TestSize.Level1)
1196 {
1197 GTEST_LOG_(INFO) << "UnmarshallingTest001 Start";
1198 try {
1199 auto version = make_shared<HistoryVersion>();
1200 Parcel parcel;
1201
1202 EXPECT_CALL(*parcel_, ReadInt64(_)).WillOnce(Return(false));
1203 auto res = version->Unmarshalling(parcel);
1204 EXPECT_TRUE(res == nullptr);
1205 } catch (...) {
1206 EXPECT_TRUE(false);
1207 GTEST_LOG_(INFO) << " UnmarshallingTest001 FAILED";
1208 }
1209 GTEST_LOG_(INFO) << "UnmarshallingTest001 End";
1210 }
1211
1212 /*
1213 * @tc.name: Unmarshalling
1214 * @tc.desc: Verify the HistoryVersion::Unmarshalling function.
1215 * @tc.type: FUNC
1216 * @tc.require: 待补充 ICGORT
1217 */
1218 HWTEST_F(CloudSyncCommonTest, UnmarshallingTest002, TestSize.Level1)
1219 {
1220 GTEST_LOG_(INFO) << "UnmarshallingTest002 Start";
1221 try {
1222 auto version = make_shared<HistoryVersion>();
1223 Parcel parcel;
1224
1225 EXPECT_CALL(*parcel_, ReadInt64(_)).WillOnce(Return(true));
1226 EXPECT_CALL(*parcel_, ReadUint64(_)).WillOnce(Return(true)).WillOnce(Return(true));
1227 EXPECT_CALL(*parcel_, ReadString(_)).WillOnce(Return(true)).WillOnce(Return(true));
1228 EXPECT_CALL(*parcel_, ReadBool(_)).WillOnce(Return(true));
1229 auto res = version->Unmarshalling(parcel);
1230 EXPECT_TRUE(res != nullptr);
1231 } catch (...) {
1232 EXPECT_TRUE(false);
1233 GTEST_LOG_(INFO) << " UnmarshallingTest002 FAILED";
1234 }
1235 GTEST_LOG_(INFO) << "UnmarshallingTest002 End";
1236 }
1237
1238 /*
1239 * @tc.name: ReadFromParcel
1240 * @tc.desc: Verify the HistoryVersion::ReadFromParcel function.
1241 * @tc.type: FUNC
1242 * @tc.require: ICGORT
1243 */
1244 HWTEST_F(CloudSyncCommonTest, ReadFromParcelTest001, TestSize.Level1)
1245 {
1246 GTEST_LOG_(INFO) << "ReadFromParcelTest001 Start";
1247 try {
1248 auto version = make_shared<HistoryVersion>();
1249 Parcel parcel;
1250
1251 EXPECT_CALL(*parcel_, ReadInt64(_)).WillOnce(Return(false));
1252 auto res = version->ReadFromParcel(parcel);
1253 EXPECT_FALSE(res);
1254
1255 EXPECT_CALL(*parcel_, ReadInt64(_)).WillOnce(Return(true));
1256 EXPECT_CALL(*parcel_, ReadUint64(_)).WillOnce(Return(false));
1257 res = version->ReadFromParcel(parcel);
1258 EXPECT_FALSE(res);
1259
1260 EXPECT_CALL(*parcel_, ReadInt64(_)).WillOnce(Return(true));
1261 EXPECT_CALL(*parcel_, ReadUint64(_)).WillOnce(Return(true)).WillOnce(Return(false));
1262 res = version->ReadFromParcel(parcel);
1263 EXPECT_FALSE(res);
1264
1265 EXPECT_CALL(*parcel_, ReadInt64(_)).WillOnce(Return(true));
1266 EXPECT_CALL(*parcel_, ReadUint64(_)).WillOnce(Return(true)).WillOnce(Return(true));
1267 EXPECT_CALL(*parcel_, ReadString(_)).WillOnce(Return(false));
1268 res = version->ReadFromParcel(parcel);
1269 EXPECT_FALSE(res);
1270 } catch (...) {
1271 EXPECT_TRUE(false);
1272 GTEST_LOG_(INFO) << " ReadFromParcelTest001 FAILED";
1273 }
1274 GTEST_LOG_(INFO) << "ReadFromParcelTest001 End";
1275 }
1276
1277 /*
1278 * @tc.name: ReadFromParcel
1279 * @tc.desc: Verify the HistoryVersion::ReadFromParcel function.
1280 * @tc.type: FUNC
1281 * @tc.require: ICGORT
1282 */
1283 HWTEST_F(CloudSyncCommonTest, ReadFromParcelTest002, TestSize.Level1)
1284 {
1285 GTEST_LOG_(INFO) << "ReadFromParcelTest002 Start";
1286 try {
1287 auto version = make_shared<HistoryVersion>();
1288 Parcel parcel;
1289
1290 EXPECT_CALL(*parcel_, ReadInt64(_)).WillOnce(Return(true));
1291 EXPECT_CALL(*parcel_, ReadUint64(_)).WillOnce(Return(true)).WillOnce(Return(true));
1292 EXPECT_CALL(*parcel_, ReadString(_)).WillOnce(Return(true)).WillOnce(Return(false));
1293 auto res = version->ReadFromParcel(parcel);
1294 EXPECT_FALSE(res);
1295
1296 EXPECT_CALL(*parcel_, ReadInt64(_)).WillOnce(Return(true));
1297 EXPECT_CALL(*parcel_, ReadUint64(_)).WillOnce(Return(true)).WillOnce(Return(true));
1298 EXPECT_CALL(*parcel_, ReadString(_)).WillOnce(Return(true)).WillOnce(Return(true));
1299 EXPECT_CALL(*parcel_, ReadBool(_)).WillOnce(Return(false));
1300 res = version->ReadFromParcel(parcel);
1301 EXPECT_FALSE(res);
1302
1303 EXPECT_CALL(*parcel_, ReadInt64(_)).WillOnce(Return(true));
1304 EXPECT_CALL(*parcel_, ReadUint64(_)).WillOnce(Return(true)).WillOnce(Return(true));
1305 EXPECT_CALL(*parcel_, ReadString(_)).WillOnce(Return(true)).WillOnce(Return(true));
1306 EXPECT_CALL(*parcel_, ReadBool(_)).WillOnce(Return(true));
1307 res = version->ReadFromParcel(parcel);
1308 EXPECT_TRUE(res);
1309 } catch (...) {
1310 EXPECT_TRUE(false);
1311 GTEST_LOG_(INFO) << " ReadFromParcelTest002 FAILED";
1312 }
1313 GTEST_LOG_(INFO) << "ReadFromParcelTest002 End";
1314 }
1315 } // namespace FileManagement::CloudSync
1316 } // namespace OHOS
1317