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 <gtest/gtest.h>
17
18 #include "cloud_sync_common.h"
19 #include "dfs_error.h"
20 #include "cycle_task.h"
21 #include "cycle_task_runner.h"
22 #include "tasks/database_backup_task.h"
23 #include "tasks/optimize_cache_task.h"
24 #include "tasks/optimize_storage_task.h"
25 #include "tasks/periodic_check_task.h"
26 #include "tasks/save_subscription_task.h"
27 #include "tasks/report_statistics_task.h"
28 #include "utils_log.h"
29 #include "cloud_file_kit_mock.cpp"
30
31 namespace OHOS {
32 namespace FileManagement::CloudSync {
33 namespace Test {
34 using namespace testing::ext;
35 using namespace std;
36 using namespace testing;
37
38 std::shared_ptr<CloudFile::DataSyncManager> g_dataSyncManagerPtr_;
39
40 class SubCycleTask : public CycleTask {
41 public:
SubCycleTask(std::string taskName,std::set<std::string> bundleNames,int32_t intervalTime,std::shared_ptr<CloudFile::DataSyncManager> dataSyncManager)42 SubCycleTask(std::string taskName,
43 std::set<std::string> bundleNames,
44 int32_t intervalTime,
45 std::shared_ptr<CloudFile::DataSyncManager> dataSyncManager)
46 :CycleTask(taskName, bundleNames, intervalTime, dataSyncManager)
47 {}
RunTaskForBundle(int32_t userId,std::string bundleName)48 int32_t RunTaskForBundle(int32_t userId, std::string bundleName) override
49 {
50 return 0;
51 }
52 };
53
54 class CloudSyncServiceCycleTaskTest : public testing::Test {
55 public:
56 static void SetUpTestCase(void);
57 static void TearDownTestCase(void);
58 void SetUp();
59 void TearDown();
60 static inline shared_ptr<CloudFileKitMock> ability = make_shared<CloudFileKitMock>();
61 };
62
SetUpTestCase(void)63 void CloudSyncServiceCycleTaskTest::SetUpTestCase(void)
64 {
65 std::cout << "SetUpTestCase" << std::endl;
66 if (g_dataSyncManagerPtr_ == nullptr) {
67 g_dataSyncManagerPtr_ = make_shared<CloudFile::DataSyncManager>();
68 }
69 }
70
TearDownTestCase(void)71 void CloudSyncServiceCycleTaskTest::TearDownTestCase(void)
72 {
73 ability = nullptr;
74 std::cout << "TearDownTestCase" << std::endl;
75 }
76
SetUp(void)77 void CloudSyncServiceCycleTaskTest::SetUp(void)
78 {
79 std::cout << "SetUp" << std::endl;
80 }
81
TearDown(void)82 void CloudSyncServiceCycleTaskTest::TearDown(void)
83 {
84 std::cout << "TearDown" << std::endl;
85 }
86
87 /**
88 * @tc.name: RunTaskForBundleTest001
89 * @tc.desc: Verify the RunTaskForBundle function
90 * @tc.type: FUNC
91 * @tc.require: IB3SWZ
92 */
93 HWTEST_F(CloudSyncServiceCycleTaskTest, RunTaskForBundleTest001, TestSize.Level1)
94 {
95 GTEST_LOG_(INFO) << "RunTaskForBundleTest001 start";
96 try {
97 string bundleName = "com.ohos.photos";
98 int32_t userId = 100;
99 EXPECT_NE(g_dataSyncManagerPtr_, nullptr);
100 shared_ptr<DatabaseBackupTask> task = make_shared<DatabaseBackupTask>(g_dataSyncManagerPtr_);
101 int32_t ret = task->RunTaskForBundle(userId, bundleName);
102 EXPECT_NE(ret, 0);
103 } catch (...) {
104 EXPECT_TRUE(false);
105 GTEST_LOG_(INFO) << "RunTaskForBundleTest001 FAILED";
106 }
107 GTEST_LOG_(INFO) << "RunTaskForBundleTest001 end";
108 }
109
110 /**
111 * @tc.name: RunTaskForBundleTest002
112 * @tc.desc: Verify the RunTaskForBundle function
113 * @tc.type: FUNC
114 * @tc.require: IB3SWZ
115 */
116 HWTEST_F(CloudSyncServiceCycleTaskTest, RunTaskForBundleTest002, TestSize.Level1)
117 {
118 GTEST_LOG_(INFO) << "RunTaskForBundleTest002 start";
119 try {
120 string bundleName = "com.ohos.photos";
121 int32_t userId = 100;
122 EXPECT_NE(g_dataSyncManagerPtr_, nullptr);
123 shared_ptr<OptimizeStorageTask> task = make_shared<OptimizeStorageTask>(g_dataSyncManagerPtr_);
124 int32_t ret = task->RunTaskForBundle(userId, bundleName);
125 EXPECT_NE(ret, 0);
126 } catch (...) {
127 EXPECT_TRUE(false);
128 GTEST_LOG_(INFO) << "RunTaskForBundleTest002 FAILED";
129 }
130 GTEST_LOG_(INFO) << "RunTaskForBundleTest002 end";
131 }
132
133 /**
134 * @tc.name: RunTaskForBundleTest003
135 * @tc.desc: Verify the RunTaskForBundle function
136 * @tc.type: FUNC
137 * @tc.require: IB3SWZ
138 */
139 HWTEST_F(CloudSyncServiceCycleTaskTest, RunTaskForBundleTest003, TestSize.Level1)
140 {
141 GTEST_LOG_(INFO) << "RunTaskForBundleTest003 start";
142 try {
143 string bundleName = "com.ohos.photos";
144 int32_t userId = 100;
145 EXPECT_NE(g_dataSyncManagerPtr_, nullptr);
146 shared_ptr<PeriodicCheckTask> task = make_shared<PeriodicCheckTask>(g_dataSyncManagerPtr_);
147 int32_t ret = task->RunTaskForBundle(userId, bundleName);
148 EXPECT_NE(ret, 0);
149 } catch (...) {
150 EXPECT_TRUE(false);
151 GTEST_LOG_(INFO) << "RunTaskForBundleTest003 FAILED";
152 }
153 GTEST_LOG_(INFO) << "RunTaskForBundleTest003 end";
154 }
155
156 /**
157 * @tc.name: RunTaskForBundleTest004
158 * @tc.desc: Verify the RunTaskForBundle function
159 * @tc.type: FUNC
160 * @tc.require: IB3SWZ
161 */
162 HWTEST_F(CloudSyncServiceCycleTaskTest, RunTaskForBundleTest004, TestSize.Level1)
163 {
164 GTEST_LOG_(INFO) << "RunTaskForBundleTest004 start";
165 try {
166 string bundleName = "com.ohos.photos";
167 int32_t userId = 100;
168 EXPECT_NE(g_dataSyncManagerPtr_, nullptr);
169 shared_ptr<ReportStatisticsTask> task = make_shared<ReportStatisticsTask>(g_dataSyncManagerPtr_);
170 int32_t ret = task->RunTaskForBundle(userId, bundleName);
171 EXPECT_EQ(ret, 0);
172 } catch (...) {
173 EXPECT_TRUE(false);
174 GTEST_LOG_(INFO) << "RunTaskForBundleTest004 FAILED";
175 }
176 GTEST_LOG_(INFO) << "RunTaskForBundleTest004 end";
177 }
178
179 /**
180 * @tc.name: RunTaskForBundleTest005
181 * @tc.desc: Verify the RunTaskForBundle function
182 * @tc.type: FUNC
183 * @tc.require: IB3SWZ
184 */
185 HWTEST_F(CloudSyncServiceCycleTaskTest, RunTaskForBundleTest005, TestSize.Level1)
186 {
187 GTEST_LOG_(INFO) << "RunTaskForBundleTest005 start";
188 try {
189 string bundleName = "com.ohos.photos";
190 int32_t userId = 100;
191 EXPECT_NE(g_dataSyncManagerPtr_, nullptr);
192 shared_ptr<SaveSubscriptionTask> task = make_shared<SaveSubscriptionTask>(g_dataSyncManagerPtr_);
193 int32_t ret = task->RunTaskForBundle(userId, bundleName);
194 EXPECT_NE(ret, 0);
195 } catch (...) {
196 EXPECT_TRUE(false);
197 GTEST_LOG_(INFO) << "RunTaskForBundleTest005 FAILED";
198 }
199 GTEST_LOG_(INFO) << "RunTaskForBundleTest005 end";
200 }
201
202 /**
203 * @tc.name: InitTasksTest001
204 * @tc.desc: Verify the InitTasks function
205 * @tc.type: FUNC
206 * @tc.require: IB3SWZ
207 */
208 HWTEST_F(CloudSyncServiceCycleTaskTest, InitTasksTest001, TestSize.Level1)
209 {
210 GTEST_LOG_(INFO) << "InitTasksTest001 start";
211 try {
212 EXPECT_NE(g_dataSyncManagerPtr_, nullptr);
213 shared_ptr<CycleTaskRunner> taskRunner = make_shared<CycleTaskRunner>(g_dataSyncManagerPtr_);
214 taskRunner->InitTasks();
215 } catch (...) {
216 EXPECT_TRUE(false);
217 GTEST_LOG_(INFO) << "InitTasksTest001 FAILED";
218 }
219 GTEST_LOG_(INFO) << "InitTasksTest001 end";
220 }
221
222 /**
223 * @tc.name: StartTaskTest001
224 * @tc.desc: Verify the StartTask function
225 * @tc.type: FUNC
226 * @tc.require: IB3SWZ
227 */
228 HWTEST_F(CloudSyncServiceCycleTaskTest, StartTaskTest001, TestSize.Level1)
229 {
230 GTEST_LOG_(INFO) << "StartTaskTest001 start";
231 try {
232 EXPECT_NE(g_dataSyncManagerPtr_, nullptr);
233 shared_ptr<CycleTaskRunner> taskRunner = make_shared<CycleTaskRunner>(g_dataSyncManagerPtr_);
234 GTEST_LOG_(INFO) << "StartTaskTest001 userId_:" << taskRunner->userId_;
235 taskRunner->StartTask();
236 } catch (...) {
237 EXPECT_TRUE(false);
238 GTEST_LOG_(INFO) << "StartTaskTest001 FAILED";
239 }
240 GTEST_LOG_(INFO) << "StartTaskTest001 end";
241 }
242
243 /**
244 * @tc.name: SetRunableBundleNamesTest001
245 * @tc.desc: Verify the SetRunableBundleNames function
246 * @tc.type: FUNC
247 * @tc.require: IB3SWZ
248 */
249 HWTEST_F(CloudSyncServiceCycleTaskTest, SetRunableBundleNamesTest001, TestSize.Level1)
250 {
251 GTEST_LOG_(INFO) << "SetRunableBundleNamesTest001 start";
252 try {
253 EXPECT_NE(g_dataSyncManagerPtr_, nullptr);
254 shared_ptr<CycleTaskRunner> taskRunner = make_shared<CycleTaskRunner>(g_dataSyncManagerPtr_);
255 taskRunner->SetRunableBundleNames();
256 } catch (...) {
257 EXPECT_TRUE(false);
258 GTEST_LOG_(INFO) << "SetRunableBundleNamesTest001 FAILED";
259 }
260 GTEST_LOG_(INFO) << "SetRunableBundleNamesTest001 end";
261 }
262
263 /*
264 * @tc.name: RunTaskForBundlTest
265 * @tc.desc: Verify the RunTaskForBundl function.
266 * @tc.type: FUNC
267 * @tc.require: I6H5MH
268 */
269 HWTEST_F(CloudSyncServiceCycleTaskTest, RunTaskForBundleTest006, TestSize.Level1)
270 {
271 GTEST_LOG_(INFO) << "RunTaskForBundleTest006 start";
272 try {
273 string bundleName = "com.ohos.photos";
274 int32_t userId = 100;
275 EXPECT_NE(g_dataSyncManagerPtr_, nullptr);
276 shared_ptr<OptimizeCacheTask> task = make_shared<OptimizeCacheTask>(g_dataSyncManagerPtr_);
277 int32_t ret = task->RunTaskForBundle(userId, bundleName);
278
279 EXPECT_EQ(ret, 0);
280 } catch (...) {
281 EXPECT_TRUE(false);
282 GTEST_LOG_(INFO) << "RunTaskForBundleTest006 FAILED";
283 }
284 GTEST_LOG_(INFO) << "RunTaskForBundleTest006 end";
285 }
286
287 /*
288 * @tc.name: CleanCacheTest
289 * @tc.desc: Verify the CleanCache function.
290 * @tc.type: FUNC
291 * @tc.require: I6H5MH
292 */
293 HWTEST_F(CloudSyncServiceCycleTaskTest, RunTaskForBundleTest007, TestSize.Level1)
294 {
295 GTEST_LOG_(INFO) << "RunTaskForBundleTest007 start";
296 try {
297 string bundleName = "com.ohos.photos";
298 int32_t userId = 100;
299 CloudFile::CloudFileKit::instance_ = ability.get();
300 EXPECT_NE(g_dataSyncManagerPtr_, nullptr);
301 shared_ptr<OptimizeStorageTask> task = make_shared<OptimizeStorageTask>(g_dataSyncManagerPtr_);
302 int32_t ret = task->RunTaskForBundle(userId, bundleName);
303
304 EXPECT_EQ(ret, 0);
305 } catch (...) {
306 EXPECT_TRUE(false);
307 GTEST_LOG_(INFO) << "RunTaskForBundleTest007 FAILED";
308 }
309 GTEST_LOG_(INFO) << "RunTaskForBundleTest007 end";
310 }
311
312 /*
313 * @tc.name: CleanCacheTest
314 * @tc.desc: Verify the CleanCache function.
315 * @tc.type: FUNC
316 * @tc.require: I6H5MH
317 */
318 HWTEST_F(CloudSyncServiceCycleTaskTest, RunTaskForBundleTest008, TestSize.Level1)
319 {
320 GTEST_LOG_(INFO) << "RunTaskForBundleTest008 start";
321 try {
322 string bundleName = "com.ohos.photos";
323 int32_t userId = 100;
324 CloudFile::CloudFileKit::instance_ = ability.get();
325 EXPECT_CALL(*ability, GetAppConfigParams(_, _, _)).WillOnce(Return(E_OK));
326 shared_ptr<OptimizeStorageTask> task = make_shared<OptimizeStorageTask>(g_dataSyncManagerPtr_);
327 int32_t ret = task->RunTaskForBundle(userId, bundleName);
328
329 EXPECT_EQ(ret, 0);
330 } catch (...) {
331 EXPECT_TRUE(false);
332 GTEST_LOG_(INFO) << "RunTaskForBundleTest008 FAILED";
333 }
334 GTEST_LOG_(INFO) << "RunTaskForBundleTest008 end";
335 }
336
337 /*
338 * @tc.name: CleanCacheTest
339 * @tc.desc: Verify the CleanCache function.
340 * @tc.type: FUNC
341 * @tc.require: I6H5MH
342 */
343 HWTEST_F(CloudSyncServiceCycleTaskTest, RunTaskForBundleTest009, TestSize.Level1)
344 {
345 GTEST_LOG_(INFO) << "RunTaskForBundleTest009 start";
346 try {
347 string bundleName = "com.ohos.photos";
348 int32_t userId = 100;
349 CloudFile::CloudFileKit::instance_ = ability.get();
350 shared_ptr<SaveSubscriptionTask> task = make_shared<SaveSubscriptionTask>(g_dataSyncManagerPtr_);
351 int32_t ret = task->RunTaskForBundle(userId, bundleName);
352
353 EXPECT_EQ(ret, 0);
354 } catch (...) {
355 EXPECT_TRUE(false);
356 GTEST_LOG_(INFO) << "RunTaskForBundleTest009 FAILED";
357 }
358 GTEST_LOG_(INFO) << "RunTaskForBundleTest009 end";
359 }
360
361 /*
362 * @tc.name: CycleTaskRunnerTest
363 * @tc.desc: Verify the CycleTaskRunner function.
364 * @tc.type: FUNC
365 * @tc.require: I6H5MH
366 */
367 HWTEST_F(CloudSyncServiceCycleTaskTest, CycleTaskRunnerTest001, TestSize.Level1)
368 {
369 GTEST_LOG_(INFO) << "CycleTaskRunnerTest001 start";
370 try {
371 shared_ptr<CloudFile::DataSyncManager> dataSyncManager = nullptr;
372 CycleTaskRunner cycleTaskRunner(dataSyncManager);
373 auto res = cycleTaskRunner.dataSyncManager_;
374 EXPECT_EQ(res, nullptr);
375 } catch (...) {
376 EXPECT_TRUE(false);
377 GTEST_LOG_(INFO) << "CycleTaskRunnerTest001 FAILED";
378 }
379 GTEST_LOG_(INFO) << "CycleTaskRunnerTest001 end";
380 }
381
382 /*
383 * @tc.name: SetLastRunTimeTest001
384 * @tc.desc: Verify the SetLastRunTime function.
385 * @tc.type: FUNC
386 * @tc.require: I6H5MH
387 */
388 HWTEST_F(CloudSyncServiceCycleTaskTest, SetLastRunTimeTest001, TestSize.Level1)
389 {
390 GTEST_LOG_(INFO) << "SetLastRunTimeTest001 start";
391 try {
392 std::string taskName;
393 std::set<std::string> bundleNames;
394 int32_t intervalTime = 0;
395 std::shared_ptr<CloudFile::DataSyncManager> dataSyncManager = nullptr;
396
397 CycleTask *sycTask = new SubCycleTask(taskName, bundleNames, intervalTime, dataSyncManager);
398
399 std::time_t time = std::time(nullptr);
400 sycTask->SetLastRunTime(time);
401 EXPECT_EQ(sycTask->cloudPrefImpl_, nullptr);
402 delete sycTask;
403 } catch (...) {
404 EXPECT_TRUE(false);
405 GTEST_LOG_(INFO) << "SetLastRunTimeTest001 FAILED";
406 }
407 GTEST_LOG_(INFO) << "SetLastRunTimeTest001 end";
408 }
409
410 /*
411 * @tc.name: SetLastRunTimeTest002
412 * @tc.desc: Verify the SetLastRunTime function.
413 * @tc.type: FUNC
414 * @tc.require: I6H5MH
415 */
416 HWTEST_F(CloudSyncServiceCycleTaskTest, SetLastRunTimeTest002, TestSize.Level1)
417 {
418 GTEST_LOG_(INFO) << "SetLastRunTimeTest002 start";
419 try {
420 std::string taskName;
421 std::set<std::string> bundleNames;
422 int32_t intervalTime = 0;
423 std::shared_ptr<CloudFile::DataSyncManager> dataSyncManager = nullptr;
424
425 CycleTask *sycTask = new SubCycleTask(taskName, bundleNames, intervalTime, dataSyncManager);
426
427 sycTask->cloudPrefImpl_ = std::make_unique<CloudPrefImpl>("");
428 std::time_t time = std::time(nullptr);
429 sycTask->SetLastRunTime(time);
430 EXPECT_NE(sycTask->cloudPrefImpl_, nullptr);
431 delete sycTask;
432 } catch (...) {
433 EXPECT_TRUE(false);
434 GTEST_LOG_(INFO) << "SetLastRunTimeTest002 FAILED";
435 }
436 GTEST_LOG_(INFO) << "SetLastRunTimeTest002 end";
437 }
438
439 /*
440 * @tc.name: GetLastRunTimeTest001
441 * @tc.desc: Verify the GetLastRunTime function.
442 * @tc.type: FUNC
443 * @tc.require: I6H5MH
444 */
445 HWTEST_F(CloudSyncServiceCycleTaskTest, GetLastRunTimeTest001, TestSize.Level1)
446 {
447 GTEST_LOG_(INFO) << "GetLastRunTimeTest001 start";
448 try {
449 std::string taskName;
450 std::set<std::string> bundleNames;
451 int32_t intervalTime = 0;
452 std::shared_ptr<CloudFile::DataSyncManager> dataSyncManager = nullptr;
453
454 CycleTask *sycTask = new SubCycleTask(taskName, bundleNames, intervalTime, dataSyncManager);
455
456 std::time_t time = std::time(nullptr);
457 sycTask->GetLastRunTime(time);
458 EXPECT_EQ(sycTask->cloudPrefImpl_, nullptr);
459 delete sycTask;
460 } catch (...) {
461 EXPECT_TRUE(false);
462 GTEST_LOG_(INFO) << "GetLastRunTimeTest001 FAILED";
463 }
464 GTEST_LOG_(INFO) << "GetLastRunTimeTest001 end";
465 }
466
467 /*
468 * @tc.name: GetLastRunTimeTest002
469 * @tc.desc: Verify the GetLastRunTime function.
470 * @tc.type: FUNC
471 * @tc.require: I6H5MH
472 */
473 HWTEST_F(CloudSyncServiceCycleTaskTest, GetLastRunTimeTest002, TestSize.Level1)
474 {
475 GTEST_LOG_(INFO) << "GetLastRunTimeTest002 start";
476 try {
477 std::string taskName;
478 std::set<std::string> bundleNames;
479 int32_t intervalTime = 0;
480 std::shared_ptr<CloudFile::DataSyncManager> dataSyncManager = nullptr;
481
482 CycleTask *sycTask = new SubCycleTask(taskName, bundleNames, intervalTime, dataSyncManager);
483
484 sycTask->cloudPrefImpl_ = std::make_unique<CloudPrefImpl>("");
485 std::time_t time = std::time(nullptr);
486 sycTask->GetLastRunTime(time);
487 EXPECT_NE(sycTask->cloudPrefImpl_, nullptr);
488 delete sycTask;
489 } catch (...) {
490 EXPECT_TRUE(false);
491 GTEST_LOG_(INFO) << "GetLastRunTimeTest002 FAILED";
492 }
493 GTEST_LOG_(INFO) << "GetLastRunTimeTest002 end";
494 }
495
496 /*
497 * @tc.name: IsEligibleToRunTest001
498 * @tc.desc: Verify the IsEligibleToRun function.
499 * @tc.type: FUNC
500 * @tc.require: I6H5MH
501 */
502 HWTEST_F(CloudSyncServiceCycleTaskTest, IsEligibleToRunTest001, TestSize.Level1)
503 {
504 GTEST_LOG_(INFO) << "IsEligibleToRunTest001 start";
505 try {
506 std::string taskName;
507 std::set<std::string> bundleNames;
508 int32_t intervalTime = 0;
509 std::shared_ptr<CloudFile::DataSyncManager> dataSyncManager = nullptr;
510 CycleTask *sycTask = new SubCycleTask(taskName, bundleNames, intervalTime, dataSyncManager);
511
512 std::time_t currentTime = std::time(nullptr);
513 std::string bundleName;
514 bool res = sycTask->IsEligibleToRun(currentTime, bundleName);
515 EXPECT_EQ(res, true);
516 delete sycTask;
517 } catch (...) {
518 EXPECT_TRUE(false);
519 GTEST_LOG_(INFO) << "IsEligibleToRunTest001 FAILED";
520 }
521 GTEST_LOG_(INFO) << "IsEligibleToRunTest001 end";
522 }
523
524 /*
525 * @tc.name: IsEligibleToRunTest002
526 * @tc.desc: Verify the IsEligibleToRun function.
527 * @tc.type: FUNC
528 * @tc.require: I6H5MH
529 */
530 HWTEST_F(CloudSyncServiceCycleTaskTest, IsEligibleToRunTest002, TestSize.Level1)
531 {
532 GTEST_LOG_(INFO) << "IsEligibleToRunTest002 start";
533 try {
534 std::string taskName;
535 std::set<std::string> bundleNames = {"test"};
536 int32_t intervalTime = 0;
537 std::shared_ptr<CloudFile::DataSyncManager> dataSyncManager = nullptr;
538 CycleTask *sycTask = new SubCycleTask(taskName, bundleNames, intervalTime, dataSyncManager);
539
540 std::time_t currentTime = std::time(nullptr);
541 std::string bundleName = "";
542 bool res = sycTask->IsEligibleToRun(currentTime, bundleName);
543 EXPECT_EQ(res, false);
544 delete sycTask;
545 } catch (...) {
546 EXPECT_TRUE(false);
547 GTEST_LOG_(INFO) << "IsEligibleToRunTest002 FAILED";
548 }
549 GTEST_LOG_(INFO) << "IsEligibleToRunTest002 end";
550 }
551
552 /*
553 * @tc.name: RunTaskTest001
554 * @tc.desc: Verify the RunTask function.
555 * @tc.type: FUNC
556 * @tc.require: I6H5MH
557 */
558 HWTEST_F(CloudSyncServiceCycleTaskTest, RunTaskTest001, TestSize.Level1)
559 {
560 GTEST_LOG_(INFO) << "RunTaskTest001 start";
561 try {
562 std::string taskName;
563 std::set<std::string> bundleNames = {"test"};
564 int32_t intervalTime = 0;
565 std::shared_ptr<CloudFile::DataSyncManager> dataSyncManager = nullptr;
566 CycleTask *sycTask = new SubCycleTask(taskName, bundleNames, intervalTime, dataSyncManager);
567
568 int32_t userId = 0;
569 sycTask->RunTask(userId);
570 EXPECT_EQ(sycTask->runnableBundleNames_, nullptr);
571 delete sycTask;
572 } catch (...) {
573 EXPECT_TRUE(false);
574 GTEST_LOG_(INFO) << "RunTaskTest001 FAILED";
575 }
576 GTEST_LOG_(INFO) << "RunTaskTest001 end";
577 }
578 }
579 }
580 }