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_manager_impl.h"
20 #include "cloud_sync_service_proxy.h"
21 #include "dfs_error.h"
22 #include "i_cloud_sync_service_mock.h"
23 #include "iservice_registry.h"
24 #include "service_callback_mock.h"
25
26 namespace OHOS {
27 namespace FileManagement::CloudSync {
28 namespace Test {
29 using namespace testing::ext;
30 using namespace testing;
31 using namespace std;
32 constexpr int32_t MAX_FILE_CACHE_NUM = 400;
33 static const int32_t CLEAN_FILE_MAX_SIZE = 200;
34
35 class CloudSyncManagerImplTest : public testing::Test {
36 public:
37 static void SetUpTestCase(void);
38 static void TearDownTestCase(void);
39 void SetUp();
40 void TearDown();
41 std::shared_ptr<CloudSyncManagerImpl> managePtr_ = nullptr;
42 };
43
44 class CloudSyncCallbackDerived : public CloudSyncCallback {
45 public:
OnSyncStateChanged(CloudSyncState state,ErrorType error)46 void OnSyncStateChanged(CloudSyncState state, ErrorType error)
47 {
48 std::cout << "OnSyncStateChanged" << std::endl;
49 }
50 };
51
52 class CloudDownloadCallbackDerived : public CloudDownloadCallback {
53 public:
OnDownloadProcess(const DownloadProgressObj & progress)54 void OnDownloadProcess(const DownloadProgressObj& progress)
55 {
56 std::cout << "OnDownloadProcess" << std::endl;
57 }
58 };
59
SetUpTestCase(void)60 void CloudSyncManagerImplTest::SetUpTestCase(void)
61 {
62 std::cout << "SetUpTestCase" << std::endl;
63 }
64
TearDownTestCase(void)65 void CloudSyncManagerImplTest::TearDownTestCase(void)
66 {
67 std::cout << "TearDownTestCase" << std::endl;
68 }
69
SetUp(void)70 void CloudSyncManagerImplTest::SetUp(void)
71 {
72 managePtr_ = make_shared<CloudSyncManagerImpl>();
73 std::cout << "SetUp" << std::endl;
74 }
75
TearDown(void)76 void CloudSyncManagerImplTest::TearDown(void)
77 {
78 managePtr_ = nullptr;
79 std::cout << "TearDown" << std::endl;
80 }
81
82 /**
83 * @tc.name: RegisterCallbackTest001
84 * @tc.desc: Verify the RegisterCallback function.
85 * @tc.type: FUNC
86 * @tc.require: I6H5MH
87 */
88 HWTEST_F(CloudSyncManagerImplTest, RegisterCallbackTest001, TestSize.Level1)
89 {
90 GTEST_LOG_(INFO) << "RegisterCallbackTest Start";
91 try {
92 auto callback = nullptr;
93 int32_t res = CloudSyncManagerImpl::GetInstance().RegisterCallback(callback);
94 EXPECT_EQ(res, E_INVAL_ARG);
95 } catch (...) {
96 EXPECT_TRUE(false);
97 GTEST_LOG_(INFO) << "RegisterCallbackTest FAILED";
98 }
99 GTEST_LOG_(INFO) << "RegisterCallbackTest End";
100 }
101
102 /**
103 * @tc.name: RegisterCallbackTest002
104 * @tc.desc: Verify the RegisterCallback function.
105 * @tc.type: FUNC
106 * @tc.require: I6H5MH
107 */
108 HWTEST_F(CloudSyncManagerImplTest, RegisterCallbackTest002, TestSize.Level1)
109 {
110 GTEST_LOG_(INFO) << "RegisterCallbackTest Start";
111 try {
112 shared_ptr<CloudSyncCallback> callback = make_shared<CloudSyncCallbackDerived>();
113 int32_t res = CloudSyncManagerImpl::GetInstance().RegisterCallback(callback);
114 EXPECT_EQ(res, E_OK);
115 } catch (...) {
116 EXPECT_TRUE(false);
117 GTEST_LOG_(INFO) << "RegisterCallbackTest FAILED";
118 }
119 GTEST_LOG_(INFO) << "RegisterCallbackTest End";
120 }
121
122 /*
123 * @tc.name: UnRegisterCallbackTest001
124 * @tc.desc: Verify the UnRegisterCallback function.
125 * @tc.type: FUNC
126 * @tc.require: I6H5MH
127 */
128 HWTEST_F(CloudSyncManagerImplTest, UnRegisterCallbackTest001, TestSize.Level1)
129 {
130 GTEST_LOG_(INFO) << "UnRegisterCallbackTest Start";
131 try {
132 string bundleName = "com.ohos.photos";
133 int32_t res = CloudSyncManagerImpl::GetInstance().UnRegisterCallback(bundleName);
134 EXPECT_EQ(res, E_OK);
135 } catch (...) {
136 EXPECT_TRUE(false);
137 GTEST_LOG_(INFO) << "UnRegisterCallbackTest FAILED";
138 }
139 GTEST_LOG_(INFO) << "UnRegisterCallbackTest End";
140 }
141
142 /**
143 * @tc.name: StartSyncTest001
144 * @tc.desc: Verify the StartSync function.
145 * @tc.type: FUNC
146 * @tc.require: I6H5MH
147 */
148 HWTEST_F(CloudSyncManagerImplTest, StartSyncTest001, TestSize.Level1)
149 {
150 GTEST_LOG_(INFO) << "StartSyncTest Start";
151 try {
152 string bundleName = "com.ohos.photos";
153 int32_t res = CloudSyncManagerImpl::GetInstance().StartSync(bundleName);
154 EXPECT_EQ(res, E_OK);
155 } catch (...) {
156 EXPECT_TRUE(false);
157 GTEST_LOG_(INFO) << "StartSyncTest FAILED";
158 }
159 GTEST_LOG_(INFO) << "StartSyncTest End";
160 }
161
162 /**
163 * @tc.name: StartSyncTest002
164 * @tc.desc: Verify the StartSync function.
165 * @tc.type: FUNC
166 * @tc.require: I6H5MH
167 */
168 HWTEST_F(CloudSyncManagerImplTest, StartSyncTest002, TestSize.Level1)
169 {
170 GTEST_LOG_(INFO) << "StartSyncTest Start";
171 try {
172 bool forceFlag = true;
173 string bundleName = "com.ohos.photos";
174 int32_t res = CloudSyncManagerImpl::GetInstance().StartSync(forceFlag, nullptr);
175 EXPECT_EQ(res, E_INVAL_ARG);
176 } catch (...) {
177 EXPECT_TRUE(false);
178 GTEST_LOG_(INFO) << "StartSyncTest FAILED";
179 }
180 GTEST_LOG_(INFO) << "StartSyncTest End";
181 }
182
183 /**
184 * @tc.name: StartSyncTest003
185 * @tc.desc: Verify the StartSync function.
186 * @tc.type: FUNC
187 * @tc.require: I6H5MH
188 */
189 HWTEST_F(CloudSyncManagerImplTest, StartSyncTest003, TestSize.Level1)
190 {
191 GTEST_LOG_(INFO) << "StartSyncTest Start";
192 try {
193 bool forceFlag = true;
194 shared_ptr<CloudSyncCallback> callback = make_shared<CloudSyncCallbackDerived>();
195 string bundleName = "com.ohos.photos";
196 int32_t res = CloudSyncManagerImpl::GetInstance().StartSync(forceFlag, callback);
197 EXPECT_EQ(res, E_OK);
198 } catch (...) {
199 EXPECT_TRUE(false);
200 GTEST_LOG_(INFO) << "StartSyncTest FAILED";
201 }
202 GTEST_LOG_(INFO) << "StartSyncTest End";
203 }
204
205 /**
206 * @tc.name: GetSyncTimeTest001
207 * @tc.desc: Verify the GetSyncTime function.
208 * @tc.type: FUNC
209 * @tc.require: I6H5MH
210 */
211 HWTEST_F(CloudSyncManagerImplTest, GetSyncTimeTest001, TestSize.Level1)
212 {
213 GTEST_LOG_(INFO) << "GetSyncTimeTest Start";
214 try {
215 int64_t syncTime = 0;
216 string bundleName = "com.ohos.photos";
217 int32_t res = CloudSyncManagerImpl::GetInstance().GetSyncTime(syncTime, bundleName);
218 EXPECT_EQ(res, E_OK);
219 } catch (...) {
220 EXPECT_TRUE(false);
221 GTEST_LOG_(INFO) << "GetSyncTimeTest FAILED";
222 }
223 GTEST_LOG_(INFO) << "GetSyncTimeTest End";
224 }
225
226 /**
227 * @tc.name: TriggerSyncTest001
228 * @tc.desc: Verify the TriggerSync function.
229 * @tc.type: FUNC
230 * @tc.require: I6H5MH
231 */
232 HWTEST_F(CloudSyncManagerImplTest, TriggerSyncTest001, TestSize.Level1)
233 {
234 GTEST_LOG_(INFO) << "TriggerSyncTest Start";
235 try {
236 string bundleName = "";
237 int32_t userId = 0;
238 int32_t res = CloudSyncManagerImpl::GetInstance().TriggerSync(bundleName, userId);
239 EXPECT_EQ(res, E_INVAL_ARG);
240 } catch (...) {
241 EXPECT_TRUE(false);
242 GTEST_LOG_(INFO) << "TriggerSyncTest FAILED";
243 }
244 GTEST_LOG_(INFO) << "TriggerSyncTest End";
245 }
246
247 /**
248 * @tc.name: TriggerSyncTest002
249 * @tc.desc: Verify the TriggerSync function.
250 * @tc.type: FUNC
251 * @tc.require: I6H5MH
252 */
253 HWTEST_F(CloudSyncManagerImplTest, TriggerSyncTest002, TestSize.Level1)
254 {
255 GTEST_LOG_(INFO) << "TriggerSyncTest Start";
256 try {
257 string bundleName = "com.ohos.photos";
258 int32_t userId = 100;
259 int32_t res = CloudSyncManagerImpl::GetInstance().TriggerSync(bundleName, userId);
260 EXPECT_EQ(res, E_OK);
261 } catch (...) {
262 EXPECT_TRUE(false);
263 GTEST_LOG_(INFO) << "TriggerSyncTest FAILED";
264 }
265 GTEST_LOG_(INFO) << "TriggerSyncTest End";
266 }
267
268 /*
269 * @tc.name: StopSyncTest
270 * @tc.desc: Verify the StopSync function.
271 * @tc.type: FUNC
272 * @tc.require: I6H5MH
273 */
274 HWTEST_F(CloudSyncManagerImplTest, StopSyncTest, TestSize.Level1)
275 {
276 GTEST_LOG_(INFO) << "StopSyncTest Start";
277 try {
278 string bundleName = "com.ohos.photos";
279 int res = CloudSyncManagerImpl::GetInstance().StopSync(bundleName);
280 EXPECT_EQ(res, E_OK);
281 } catch (...) {
282 EXPECT_TRUE(false);
283 GTEST_LOG_(INFO) << " StopSyncTest FAILED";
284 }
285 GTEST_LOG_(INFO) << "StopSyncTest End";
286 }
287
288 /*
289 * @tc.name: ChangeAppSwitchTest
290 * @tc.desc: Verify the ChangeAppSwitch function.
291 * @tc.type: FUNC
292 * @tc.require: I6H5MH
293 */
294 HWTEST_F(CloudSyncManagerImplTest, ChangeAppSwitchTest, TestSize.Level1)
295 {
296 GTEST_LOG_(INFO) << "ChangeAppSwitchTest Start";
297 try {
298 std::string accoutId = "accoutId";
299 std::string bundleName = "bundleName";
300 bool status = true;
301 auto res = CloudSyncManagerImpl::GetInstance().ChangeAppSwitch(accoutId, bundleName, status);
302 EXPECT_EQ(res, E_OK);
303 } catch (...) {
304 EXPECT_TRUE(false);
305 GTEST_LOG_(INFO) << " ChangeAppSwitchTest FAILED";
306 }
307 GTEST_LOG_(INFO) << "ChangeAppSwitchTest End";
308 }
309
310 /*
311 * @tc.name: NotifyDataChangeTest
312 * @tc.desc: Verify the NotifyDataChange function.
313 * @tc.type: FUNC
314 * @tc.require: I6H5MH
315 */
316 HWTEST_F(CloudSyncManagerImplTest, NotifyDataChangeTest, TestSize.Level1)
317 {
318 GTEST_LOG_(INFO) << "NotifyDataChangeTest Start";
319 try {
320 std::string accoutId = "accoutId";
321 std::string bundleName = "bundleName";
322 auto res = CloudSyncManagerImpl::GetInstance().NotifyDataChange(accoutId, bundleName);
323 EXPECT_EQ(res, E_OK);
324 } catch (...) {
325 EXPECT_TRUE(false);
326 GTEST_LOG_(INFO) << " NotifyDataChangeTest FAILED";
327 }
328 GTEST_LOG_(INFO) << "NotifyDataChangeTest End";
329 }
330
331 /*
332 * @tc.name: NotifyEventChangeTest
333 * @tc.desc: Verify the NotifyEventChange function.
334 * @tc.type: FUNC
335 * @tc.require: I6H5MH
336 */
337 HWTEST_F(CloudSyncManagerImplTest, NotifyEventChangeTest, TestSize.Level1)
338 {
339 GTEST_LOG_(INFO) << "NotifyEventChangeTest Start";
340 try {
341 int32_t userId = 100;
342 std::string eventId = "eventId";
343 std::string extraData = "extraData";
344 auto res = CloudSyncManagerImpl::GetInstance().NotifyEventChange(userId, eventId, extraData);
345 EXPECT_EQ(res, E_OK);
346 } catch (...) {
347 EXPECT_TRUE(false);
348 GTEST_LOG_(INFO) << "NotifyEventChangeTest FAILED";
349 }
350 GTEST_LOG_(INFO) << "NotifyEventChangeTest End";
351 }
352
353 /*
354 * @tc.name: StartDownloadFileTest
355 * @tc.desc: Verify the StartDownloadFile function.
356 * @tc.type: FUNC
357 * @tc.require: I6H5MH
358 */
359 HWTEST_F(CloudSyncManagerImplTest, StartDownloadFileTest, TestSize.Level1)
360 {
361 GTEST_LOG_(INFO) << "NotifyDataChangeTest Start";
362 try {
363 std::string uri = "uri";
364 auto res = CloudSyncManagerImpl::GetInstance().StartDownloadFile(uri);
365 EXPECT_EQ(res, E_OK);
366 } catch (...) {
367 EXPECT_TRUE(false);
368 GTEST_LOG_(INFO) << " StartDownloadFileTest FAILED";
369 }
370 GTEST_LOG_(INFO) << "StartDownloadFileTest End";
371 }
372
373 /*
374 * @tc.name: StartFileCacheTest
375 * @tc.desc: Verify the StartFileCache function.
376 * @tc.type: FUNC
377 * @tc.require: I6H5MH
378 */
379 HWTEST_F(CloudSyncManagerImplTest, StartFileCacheTest, TestSize.Level1)
380 {
381 GTEST_LOG_(INFO) << "StartFileCacheTest Start";
382 try {
383 std::string uri = "uri";
384 auto res = CloudSyncManagerImpl::GetInstance().StartFileCache(uri);
385 EXPECT_EQ(res, E_OK);
386 } catch (...) {
387 EXPECT_TRUE(false);
388 GTEST_LOG_(INFO) << "StartFileCacheTest FAILED";
389 }
390 GTEST_LOG_(INFO) << "StartFileCacheTest End";
391 }
392
393 /*
394 * @tc.name: StopDownloadFileTest
395 * @tc.desc: Verify the StopDownloadFile function.
396 * @tc.type: FUNC
397 * @tc.require: I6H5MH
398 */
399 HWTEST_F(CloudSyncManagerImplTest, StopDownloadFileTest, TestSize.Level1)
400 {
401 GTEST_LOG_(INFO) << "NotifyDataChangeTest Start";
402 try {
403 std::string uri = "uri";
404 auto res = CloudSyncManagerImpl::GetInstance().StopDownloadFile(uri);
405 EXPECT_EQ(res, E_OK);
406 } catch (...) {
407 EXPECT_TRUE(false);
408 GTEST_LOG_(INFO) << " StopDownloadFileTest FAILED";
409 }
410 GTEST_LOG_(INFO) << "StopDownloadFileTest End";
411 }
412
413 /*
414 * @tc.name: RegisterDownloadFileCallbackTest
415 * @tc.desc: Verify the UnregisterDownloadFileCallback function.
416 * @tc.type: FUNC
417 * @tc.require: I6H5MH
418 */
419 HWTEST_F(CloudSyncManagerImplTest, RegisterDownloadFileCallbackTest, TestSize.Level1)
420 {
421 GTEST_LOG_(INFO) << "RegisterDownloadFileCallbackTest Start";
422 try {
423 shared_ptr<CloudDownloadCallback> downloadCallback = make_shared<CloudDownloadCallbackDerived>();
424 auto res = CloudSyncManagerImpl::GetInstance().RegisterDownloadFileCallback(downloadCallback);
425 EXPECT_EQ(res, E_OK);
426 } catch (...) {
427 EXPECT_TRUE(false);
428 GTEST_LOG_(INFO) << " RegisterDownloadFileCallbackTest FAILED";
429 }
430 GTEST_LOG_(INFO) << "RegisterDownloadFileCallbackTest End";
431 }
432
433 /*
434 * @tc.name: UnregisterDownloadFileCallbackTest
435 * @tc.desc: Verify the UnregisterDownloadFileCallback function.
436 * @tc.type: FUNC
437 * @tc.require: I6H5MH
438 */
439 HWTEST_F(CloudSyncManagerImplTest, UnregisterDownloadFileCallbackTest, TestSize.Level1)
440 {
441 GTEST_LOG_(INFO) << "UnregisterDownloadFileCallbackTest Start";
442 try {
443 auto res = CloudSyncManagerImpl::GetInstance().UnregisterDownloadFileCallback();
444 EXPECT_EQ(res, E_OK);
445 } catch (...) {
446 EXPECT_TRUE(false);
447 GTEST_LOG_(INFO) << " UnregisterDownloadFileCallbackTest FAILED";
448 }
449 GTEST_LOG_(INFO) << "UnregisterDownloadFileCallbackTest End";
450 }
451
452 /*
453 * @tc.name: SetDeathRecipientTest
454 * @tc.desc: Verify the SetDeathRecipient function.
455 * @tc.type: FUNC
456 * @tc.require: I6H5MH
457 */
458 HWTEST_F(CloudSyncManagerImplTest, SetDeathRecipientTest, TestSize.Level1)
459 {
460 GTEST_LOG_(INFO) << "SetDeathRecipientTest Start";
461 try {
462 auto CloudSyncServiceProxy = CloudSyncServiceProxy::GetInstance();
463 CloudSyncManagerImpl::GetInstance().SetDeathRecipient(CloudSyncServiceProxy->AsObject());
464 EXPECT_TRUE(true);
465 } catch (...) {
466 EXPECT_TRUE(false);
467 GTEST_LOG_(INFO) << "SetDeathRecipientTest FAILED";
468 }
469 GTEST_LOG_(INFO) << "SetDeathRecipientTest End";
470 }
471
472 /*
473 * @tc.name: EnableCloudTest
474 * @tc.desc: Verify the EnableCloud function.
475 * @tc.type: FUNC
476 * @tc.require: I6H5MH
477 */
478 HWTEST_F(CloudSyncManagerImplTest, EnableCloudTest, TestSize.Level1)
479 {
480 GTEST_LOG_(INFO) << "NotifyDataChangeTest Start";
481 try {
482 std::string accoutId = "accoutId";
483 SwitchDataObj switchData;
484 auto res = CloudSyncManagerImpl::GetInstance().EnableCloud(accoutId, switchData);
485 EXPECT_EQ(res, E_OK);
486 } catch (...) {
487 EXPECT_TRUE(false);
488 GTEST_LOG_(INFO) << " EnableCloudTest FAILED";
489 }
490 GTEST_LOG_(INFO) << "EnableCloudTest End";
491 }
492
493 /*
494 * @tc.name: DisableCloudTest
495 * @tc.desc: Verify the DisableCloud function.
496 * @tc.type: FUNC
497 * @tc.require: I6H5MH
498 */
499 HWTEST_F(CloudSyncManagerImplTest, DisableCloudTest, TestSize.Level1)
500 {
501 GTEST_LOG_(INFO) << "NotifyDataChangeTest Start";
502 try {
503 std::string accoutId = "accoutId";
504 auto res = CloudSyncManagerImpl::GetInstance().DisableCloud(accoutId);
505 EXPECT_EQ(res, E_OK);
506 } catch (...) {
507 EXPECT_TRUE(false);
508 GTEST_LOG_(INFO) << " DisableCloudTest FAILED";
509 }
510 GTEST_LOG_(INFO) << "DisableCloudTest End";
511 }
512
513 /*
514 * @tc.name: CleanTest
515 * @tc.desc: Verify the Clean function.
516 * @tc.type: FUNC
517 * @tc.require: I6H5MH
518 */
519 HWTEST_F(CloudSyncManagerImplTest, CleanTest, TestSize.Level1)
520 {
521 GTEST_LOG_(INFO) << "NotifyDataChangeTest Start";
522 try {
523 std::string accoutId = "accoutId";
524 CleanOptions cleanOptions;
525 auto res = CloudSyncManagerImpl::GetInstance().Clean(accoutId, cleanOptions);
526 EXPECT_EQ(res, E_OK);
527 } catch (...) {
528 EXPECT_TRUE(false);
529 GTEST_LOG_(INFO) << " CleanTest FAILED";
530 }
531 GTEST_LOG_(INFO) << "CleanTest End";
532 }
533
534 /*
535 * @tc.name: CleanCacheTest
536 * @tc.desc: Verify the CleanCache function.
537 * @tc.type: FUNC
538 * @tc.require: I6H5MH
539 */
540 HWTEST_F(CloudSyncManagerImplTest, CleanCacheTest, TestSize.Level1)
541 {
542 GTEST_LOG_(INFO) << "CleanCacheTest Start";
543 try {
544 string uri = "uri";
545 auto res = CloudSyncManagerImpl::GetInstance().CleanCache(uri);
546 EXPECT_EQ(res, E_OK);
547 } catch (...) {
548 EXPECT_TRUE(false);
549 GTEST_LOG_(INFO) << "CleanCacheTest FAILED";
550 }
551 GTEST_LOG_(INFO) << "CleanCacheTest End";
552 }
553
554 HWTEST_F(CloudSyncManagerImplTest, BatchCleanFileTest1, TestSize.Level1)
555 {
556 GTEST_LOG_(INFO) << "BatchCleanFileTest1 Start";
557 try {
558 CleanFileInfo cleanFileInfo;
559 std::vector<CleanFileInfo> fileInfo;
560 fileInfo.emplace_back(cleanFileInfo);
561 std::vector<std::string> failCloudId;
562 auto res = CloudSyncManagerImpl::GetInstance().BatchCleanFile(fileInfo, failCloudId);
563 EXPECT_EQ(res, E_OK);
564 } catch (...) {
565 EXPECT_TRUE(false);
566 GTEST_LOG_(INFO) << "BatchCleanFileTest1 FAILED";
567 }
568 GTEST_LOG_(INFO) << "BatchCleanFileTest1 End";
569 }
570
571 HWTEST_F(CloudSyncManagerImplTest, BatchCleanFileTest2, TestSize.Level1)
572 {
573 GTEST_LOG_(INFO) << "BatchCleanFileTest2 Start";
574 try {
575 CleanFileInfo cleanFileInfo;
576 std::vector<CleanFileInfo> fileInfo;
577 for (int i = 0; i < CLEAN_FILE_MAX_SIZE + 1; i++) {
578 cleanFileInfo.cloudId = to_string(i);
579 fileInfo.emplace_back(cleanFileInfo);
580 }
581 std::vector<std::string> failCloudId;
582 auto res = CloudSyncManagerImpl::GetInstance().BatchCleanFile(fileInfo, failCloudId);
583 EXPECT_EQ(res, E_INVAL_ARG);
584 } catch (...) {
585 EXPECT_TRUE(false);
586 GTEST_LOG_(INFO) << "BatchCleanFileTest2 FAILED";
587 }
588 GTEST_LOG_(INFO) << "BatchCleanFileTest2 End";
589 }
590
591 HWTEST_F(CloudSyncManagerImplTest, ResetCursorTest, TestSize.Level1)
592 {
593 string bundleName = "com.ohos.photos";
594 int res = CloudSyncManagerImpl::GetInstance().ResetCursor(bundleName);
595 EXPECT_EQ(res, E_OK);
596 }
597
598 HWTEST_F(CloudSyncManagerImplTest, StartFileCacheTest001, TestSize.Level1)
599 {
600 std::vector<std::string> uriVec;
601 int64_t downloadId = 0;
602 int32_t res = CloudSyncManagerImpl::GetInstance().StartFileCache(uriVec, downloadId);
603 EXPECT_EQ(res, E_INVAL_ARG);
604 }
605
606 HWTEST_F(CloudSyncManagerImplTest, StartFileCacheTest002, TestSize.Level1)
607 {
608 std::vector<std::string> uriVec(MAX_FILE_CACHE_NUM + 1, "uri");
609 int64_t downloadId = 0;
610 int32_t res = CloudSyncManagerImpl::GetInstance().StartFileCache(uriVec, downloadId);
611 EXPECT_EQ(res, E_EXCEED_MAX_SIZE);
612 }
613
614 HWTEST_F(CloudSyncManagerImplTest, StartFileCacheTest003, TestSize.Level1)
615 {
616 std::vector<std::string> uriVec = {"uri"};
617 int64_t downloadId = 0;
618 int32_t res = CloudSyncManagerImpl::GetInstance().StartFileCache(uriVec, downloadId);
619 EXPECT_EQ(res, E_OK);
620 }
621
622 HWTEST_F(CloudSyncManagerImplTest, StopFileCacheTest, TestSize.Level1)
623 {
624 int64_t downloadId = 0;
625 bool needClean = true;
626 int32_t res = CloudSyncManagerImpl::GetInstance().StopFileCache(downloadId, needClean);
627 EXPECT_EQ(res, E_OK);
628 }
629
630 HWTEST_F(CloudSyncManagerImplTest, ResetProxyCallbackTest, TestSize.Level1)
631 {
632 uint32_t retryCount = 3;
633 string bundleName = "testBundle";
634 auto res = CloudSyncManagerImpl::GetInstance().ResetProxyCallback(retryCount, bundleName);
635 EXPECT_EQ(res, true);
636 }
637
638 HWTEST_F(CloudSyncManagerImplTest, DownloadThumbTest, TestSize.Level1)
639 {
640 int32_t res = CloudSyncManagerImpl::GetInstance().DownloadThumb();
641 EXPECT_EQ(res, E_OK);
642 }
643 } // namespace Test
644 } // namespace FileManagement::CloudSync
645 } // namespace OHOS