• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 <functional>
17 #include <gtest/gtest.h>
18 #define private public
19 #include "work_scheduler_service.h"
20 #include "work_status.h"
21 #include "work_bundle_group_change_callback.h"
22 #include "work_scheduler_connection.h"
23 #include "work_queue_event_handler.h"
24 #include "work_event_handler.h"
25 #include "conditions/battery_level_listener.h"
26 #include "common_event_manager.h"
27 #include "common_event_support.h"
28 #include "battery_info.h"
29 #include "conditions/battery_status_listener.h"
30 #include "conditions/charger_listener.h"
31 #include "event_publisher.h"
32 #include "json/json.h"
33 
34 #ifdef DEVICE_USAGE_STATISTICS_ENABLE
35 #include "bundle_active_client.h"
36 #endif
37 #ifdef DEVICE_STANDBY_ENABLE
38 #include "standby_service_client.h"
39 #include "allow_type.h"
40 #endif
41 #ifdef RESOURCESCHEDULE_BGTASKMGR_ENABLE
42 #include "scheduler_bg_task_subscriber.h"
43 #include "background_task_mgr_helper.h"
44 #include "resource_type.h"
45 #endif
46 #include "work_sched_errors.h"
47 #include "work_sched_hilog.h"
48 
49 #ifdef DEVICE_STANDBY_ENABLE
50 namespace OHOS {
51 namespace DevStandbyMgr {
SubscribeStandbyCallback(const sptr<IStandbyServiceSubscriber> & subscriber)52 ErrCode StandbyServiceClient::SubscribeStandbyCallback(const sptr<IStandbyServiceSubscriber>& subscriber)
53 {
54     return ERR_OK;
55 }
56 }
57 }
58 #endif
59 
60 #ifdef RESOURCESCHEDULE_BGTASKMGR_ENABLE
61 namespace OHOS {
62 namespace BackgroundTaskMgr {
SubscribeBackgroundTask(const BackgroundTaskSubscriber & subscriber)63 ErrCode BackgroundTaskMgrHelper::SubscribeBackgroundTask(const BackgroundTaskSubscriber &subscriber)
64 {
65     return ERR_OK;
66 }
67 }
68 }
69 #endif
70 
71 #ifdef DEVICE_USAGE_STATISTICS_ENABLE
72 namespace OHOS {
73 namespace DeviceUsageStats {
RegisterAppGroupCallBack(const sptr<IAppGroupCallback> & observer)74 ErrCode BundleActiveClient::RegisterAppGroupCallBack(const sptr<IAppGroupCallback> &observer)
75 {
76     return ERR_OK;
77 }
78 }
79 }
80 #endif
81 
82 namespace OHOS {
83 namespace WorkScheduler {
IsBaseAbilityReady()84 bool WorkSchedulerService::IsBaseAbilityReady()
85 {
86     return true;
87 }
88 }
89 }
90 
DecStrongRef(void const * obj)91 void OHOS::RefBase::DecStrongRef(void const* obj) {}
92 
93 using namespace testing::ext;
94 namespace OHOS {
95 namespace WorkScheduler {
96 class WorkSchedulerServiceTest : public testing::Test {
97 public:
SetUpTestCase()98     static void SetUpTestCase() {}
TearDownTestCase()99     static void TearDownTestCase() {}
SetUp()100     void SetUp() {}
TearDown()101     void TearDown() {}
102     static std::shared_ptr<WorkSchedulerService> workSchedulerService_;
103 };
104 
105 std::shared_ptr<WorkSchedulerService> WorkSchedulerServiceTest::workSchedulerService_ =
106     DelayedSingleton<WorkSchedulerService>::GetInstance();
107 
108 class MyWorkSchedulerService : public WorkSchedServiceStub {
StartWork(const WorkInfo & workInfo)109     int32_t StartWork(const WorkInfo& workInfo) { return 0; }
StopWork(const WorkInfo & workInfo)110     int32_t StopWork(const WorkInfo& workInfo) { return 0; };
StopAndCancelWork(const WorkInfo & workInfo)111     int32_t StopAndCancelWork(const WorkInfo& workInfo)  { return 0; }
StopAndClearWorks()112     int32_t StopAndClearWorks() { return 0; }
IsLastWorkTimeout(int32_t workId,bool & result)113     int32_t IsLastWorkTimeout(int32_t workId, bool &result) { return 0; }
ObtainAllWorks(std::vector<WorkInfo> & workInfos)114     int32_t ObtainAllWorks(std::vector<WorkInfo>& workInfos) { return 0; }
GetWorkStatus(int32_t workId,WorkInfo & workInfo)115     int32_t GetWorkStatus(int32_t workId, WorkInfo& workInfo) { return 0; }
GetAllRunningWorks(std::vector<WorkInfo> & workInfos)116     int32_t GetAllRunningWorks(std::vector<WorkInfo>& workInfos) { return 0; }
PauseRunningWorks(int32_t uid)117     int32_t PauseRunningWorks(int32_t uid) {return 0; }
ResumePausedWorks(int32_t uid)118     int32_t ResumePausedWorks(int32_t uid) {return 0; }
SetWorkSchedulerConfig(const std::string & configData,int32_t sourceType)119     int32_t SetWorkSchedulerConfig(const std::string &configData, int32_t sourceType) { return 0; }
StopWorkForSA(int32_t saId)120     int32_t StopWorkForSA(int32_t saId) { return 0; }
121 };
122 /**
123  * @tc.name: onStart_001
124  * @tc.desc: Test WorkSchedulerService OnStart.
125  * @tc.type: FUNC
126  * @tc.require: I8ZDJI
127  */
128 HWTEST_F(WorkSchedulerServiceTest, onStart_001, TestSize.Level1)
129 {
130     workSchedulerService_->OnStart();
131     EXPECT_NE(workSchedulerService_, nullptr);
132 }
133 
134 /**
135  * @tc.name: startWork_001
136  * @tc.desc: Test WorkSchedulerService startWork.
137  * @tc.type: FUNC
138  * @tc.require: I8F08T
139  */
140 HWTEST_F(WorkSchedulerServiceTest, startWork_001, TestSize.Level1)
141 {
142     int32_t ret;
143 
144     workSchedulerService_->ready_ = false;
145     WorkInfo workinfo = WorkInfo();
146     ret = workSchedulerService_->StartWork(workinfo);
147     EXPECT_EQ(ret, E_SERVICE_NOT_READY);
148 
149     workSchedulerService_->ready_ = true;
150     ret = workSchedulerService_->StartWork(workinfo);
151     EXPECT_EQ(ret, E_CHECK_WORKINFO_FAILED);
152 
153     workSchedulerService_->checkBundle_ = false;
154     ret = workSchedulerService_->StartWork(workinfo);
155     EXPECT_EQ(ret, E_REPEAT_CYCLE_TIME_ERR);
156 
157     workinfo.RequestStorageLevel(WorkCondition::Storage::STORAGE_LEVEL_LOW_OR_OKAY);
158     ret = workSchedulerService_->StartWork(workinfo);
159     EXPECT_EQ(ret, 0);
160     ret = workSchedulerService_->StartWork(workinfo);
161     EXPECT_EQ(ret, E_ADD_REPEAT_WORK_ERR);
162 }
163 
164 /**
165  * @tc.name: stopWork_001
166  * @tc.desc: Test WorkSchedulerService stopWork.
167  * @tc.type: FUNC
168  * @tc.require: I8F08T
169  */
170 HWTEST_F(WorkSchedulerServiceTest, stopWork_001, TestSize.Level1)
171 {
172     int32_t ret;
173 
174     WS_HILOGI("WorkSchedulerServiceTest.stopWork_001 begin");
175     workSchedulerService_->ready_ = false;
176     workSchedulerService_->checkBundle_ = true;
177     WorkInfo workinfo = WorkInfo();
178     ret = workSchedulerService_->StopWork(workinfo);
179     EXPECT_EQ(ret, E_SERVICE_NOT_READY);
180 
181     workSchedulerService_->ready_ = true;
182     ret = workSchedulerService_->StopWork(workinfo);
183     EXPECT_EQ(ret, E_CHECK_WORKINFO_FAILED);
184 
185     workSchedulerService_->checkBundle_ = false;
186     ret = workSchedulerService_->StopWork(workinfo);
187     EXPECT_EQ(ret, 0);
188     WS_HILOGI("WorkSchedulerServiceTest.stopWork_001 end");
189 }
190 
191 /**
192  * @tc.name: StopAndCancelWork_001
193  * @tc.desc: Test WorkSchedulerService StopAndCancelWork.
194  * @tc.type: FUNC
195  * @tc.require: I8F08T
196  */
197 HWTEST_F(WorkSchedulerServiceTest, StopAndCancelWork_001, TestSize.Level1)
198 {
199     int32_t ret;
200 
201     WS_HILOGI("WorkSchedulerServiceTest.StopAndCancelWork_001 begin");
202     workSchedulerService_->ready_ = false;
203     workSchedulerService_->checkBundle_ = true;
204     WorkInfo workinfo = WorkInfo();
205     ret = workSchedulerService_->StopAndCancelWork(workinfo);
206     EXPECT_EQ(ret, E_SERVICE_NOT_READY);
207 
208     workSchedulerService_->ready_ = true;
209     ret = workSchedulerService_->StopAndCancelWork(workinfo);
210     EXPECT_EQ(ret, E_CHECK_WORKINFO_FAILED);
211 
212     workSchedulerService_->checkBundle_ = false;
213     ret = workSchedulerService_->StopAndCancelWork(workinfo);
214     EXPECT_EQ(ret, 0);
215     WS_HILOGI("WorkSchedulerServiceTest.StopAndCancelWork_001 end");
216 }
217 
218 /**
219  * @tc.name: StopAndClearWorks_001
220  * @tc.desc: Test WorkSchedulerService StopAndClearWorks.
221  * @tc.type: FUNC
222  * @tc.require: I8F08T
223  */
224 HWTEST_F(WorkSchedulerServiceTest, StopAndClearWorks_001, TestSize.Level1)
225 {
226     int32_t ret;
227 
228     WS_HILOGI("WorkSchedulerServiceTest.StopAndClearWorks_001 begin");
229     workSchedulerService_->ready_ = false;
230     workSchedulerService_->checkBundle_ = true;
231     ret = workSchedulerService_->StopAndClearWorks();
232     EXPECT_EQ(ret, E_SERVICE_NOT_READY);
233 
234     workSchedulerService_->ready_ = true;
235     ret = workSchedulerService_->StopAndClearWorks();
236     EXPECT_EQ(ret, 0);
237     WS_HILOGI("WorkSchedulerServiceTest.StopAndClearWorks_001 end");
238 }
239 
240 /**
241  * @tc.name: IsLastWorkTimeout_001
242  * @tc.desc: Test WorkSchedulerService IsLastWorkTimeout.
243  * @tc.type: FUNC
244  * @tc.require: I8F08T
245  */
246 HWTEST_F(WorkSchedulerServiceTest, IsLastWorkTimeout_001, TestSize.Level1)
247 {
248     bool result;
249     auto ret = workSchedulerService_->IsLastWorkTimeout(1, result);
250     EXPECT_EQ(ret, E_WORK_NOT_EXIST_FAILED);
251 }
252 
253 /**
254  * @tc.name: ObtainAllWorks_001
255  * @tc.desc: Test WorkSchedulerService ObtainAllWorks.
256  * @tc.type: FUNC
257  * @tc.require: IA4HTC
258  */
259 HWTEST_F(WorkSchedulerServiceTest, ObtainAllWorks_001, TestSize.Level1)
260 {
261     std::vector<WorkInfo> workInfos;
262     auto ret = workSchedulerService_->ObtainAllWorks(workInfos);
263     EXPECT_EQ(ret, 0);
264 }
265 
266 /**
267  * @tc.name: GetWorkStatus_001
268  * @tc.desc: Test WorkSchedulerService GetWorkStatus.
269  * @tc.type: FUNC
270  * @tc.require: IA4HTC
271  */
272 HWTEST_F(WorkSchedulerServiceTest, GetWorkStatus_001, TestSize.Level1)
273 {
274     WorkInfo workInfo;
275     int32_t workId = 0;
276     auto ret = workSchedulerService_->GetWorkStatus(workId, workInfo);
277     EXPECT_EQ(ret, E_WORK_NOT_EXIST_FAILED);
278 }
279 
280 /**
281  * @tc.name: GetAllRunningWorks_001
282  * @tc.desc: Test WorkSchedulerService GetAllRunningWorks.
283  * @tc.type: FUNC
284  * @tc.require: I8F08T
285  */
286 HWTEST_F(WorkSchedulerServiceTest, GetAllRunningWorks_001, TestSize.Level1)
287 {
288     std::vector<WorkInfo> workInfos;
289 
290     auto ret = workSchedulerService_->GetAllRunningWorks(workInfos);
291     EXPECT_EQ(ret, E_INVALID_PROCESS_NAME);
292 }
293 
294 /**
295  * @tc.name: Datashare_001
296  * @tc.desc: Test Datashare
297  * @tc.type: FUNC
298  * @tc.require: I8ZDJI
299  */
300 HWTEST_F(WorkSchedulerServiceTest, Datashare_001, TestSize.Level1)
301 {
302     WS_HILOGI("====== test begin ====== ");
303     std::vector<std::string> argsInStr;
304     argsInStr.push_back("-k");
305     argsInStr.push_back("settings.power.suspend_sources");
306     std::string result;
307     workSchedulerService_->DumpProcessForEngMode(argsInStr, result);
308     WS_HILOGI("%{public}s", result.c_str());
309     EXPECT_EQ(result.empty(), 0);
310     WS_HILOGI("====== test end ====== ");
311 }
312 
313 HWTEST_F(WorkSchedulerServiceTest, ListenerStart_001, TestSize.Level1)
314 {
315     WS_HILOGI("====== ListenerStart_001 begin====== ");
316     for (auto pair : workSchedulerService_->workQueueManager_->listenerMap_)
317     {
318         pair.second->Start();
319     }
320     std::vector<std::pair<string, string>> infos = {
321         {"event", "info"},
322         {"network", "wifi"},
323         {"network", "disconnect"},
324         {"network", "invalid"},
325         {"charging", "usb"},
326         {"charging", "ac"},
327         {"charging", "wireless"},
328         {"charging", "none"},
329         {"charging", "invalid"},
330         {"storage", "low"},
331         {"storage", "ok"},
332         {"storage", "invalid"},
333         {"batteryStatus", "low"},
334         {"batteryStatus", "ok"},
335         {"batteryStatus", "invalid"},
336     };
337     EventPublisher eventPublisher;
338     for (auto it : infos) {
339         std::string result;
340         std::string eventType = it.first;
341         std::string eventValue = it.second;
342         eventPublisher.Dump(result, eventType, eventValue);
343         WS_HILOGI("%{public}s", result.c_str());
344         EXPECT_EQ(!result.empty(), true);
345     }
346     WS_HILOGI("====== ListenerStart_001 end ====== ");
347 }
348 
349 HWTEST_F(WorkSchedulerServiceTest, Dump_001, TestSize.Level1)
350 {
351     WS_HILOGI("====== WorkSchedulerServiceTest.Dump_001 begin ====== ");
352     std::vector<std::string> argsInStr;
353     std::string result;
354     workSchedulerService_->DumpProcessForEngMode(argsInStr, result);
355     WS_HILOGI("%{public}s", result.c_str());
356 
357     argsInStr.clear();
358     result.clear();
359     argsInStr.push_back("-h");
360     workSchedulerService_->DumpProcessForEngMode(argsInStr, result);
361     WS_HILOGI("%{public}s", result.c_str());
362 
363     result.clear();
364     argsInStr.clear();
365     argsInStr.push_back("-a");
366     workSchedulerService_->DumpProcessForEngMode(argsInStr, result);
367     WS_HILOGI("%{public}s", result.c_str());
368 
369     result.clear();
370     argsInStr.clear();
371     argsInStr.push_back("-x");
372     workSchedulerService_->DumpProcessForEngMode(argsInStr, result);
373     WS_HILOGI("%{public}s", result.c_str());
374 
375     result.clear();
376     argsInStr.clear();
377     argsInStr.push_back("-memory");
378     argsInStr.push_back("100");
379     workSchedulerService_->DumpProcessForEngMode(argsInStr, result);
380     WS_HILOGI("%{public}s", result.c_str());
381 
382     result.clear();
383     argsInStr.clear();
384     argsInStr.push_back("-watchdog_time");
385     argsInStr.push_back("100");
386     workSchedulerService_->DumpProcessForEngMode(argsInStr, result);
387     EXPECT_FALSE(result.empty());
388     WS_HILOGI("%{public}s", result.c_str());
389     WS_HILOGI("====== WorkSchedulerServiceTest.Dump_001 end ====== ");
390 }
391 
392 HWTEST_F(WorkSchedulerServiceTest, Dump_002, TestSize.Level1)
393 {
394     WS_HILOGI("====== WorkSchedulerServiceTest.Dump_002 begin ====== ");
395     std::vector<std::string> argsInStr;
396     std::string result;
397     argsInStr.push_back("-repeat_time_min");
398     argsInStr.push_back("100");
399     workSchedulerService_->DumpProcessForEngMode(argsInStr, result);
400     WS_HILOGI("%{public}s", result.c_str());
401 
402     result.clear();
403     argsInStr.clear();
404     argsInStr.push_back("-min_interval");
405     argsInStr.push_back("100");
406     workSchedulerService_->DumpProcessForEngMode(argsInStr, result);
407     WS_HILOGI("%{public}s", result.c_str());
408 
409     result.clear();
410     argsInStr.clear();
411     argsInStr.push_back("-test");
412     argsInStr.push_back("100");
413     workSchedulerService_->DumpProcessForEngMode(argsInStr, result);
414     WS_HILOGI("%{public}s", result.c_str());
415     EXPECT_EQ(result.empty(), false);
416     WS_HILOGI("====== WorkSchedulerServiceTest.Dump_002 end ====== ");
417 }
418 
419 HWTEST_F(WorkSchedulerServiceTest, Dump_003, TestSize.Level1)
420 {
421     WS_HILOGI("====== WorkSchedulerServiceTest.Dump_003 begin ====== ");
422     std::vector<std::string> argsInStr;
423     std::string result;
424 
425     argsInStr.clear();
426     result.clear();
427     argsInStr.push_back("-d");
428     argsInStr.push_back("storage");
429     argsInStr.push_back("ok");
430     workSchedulerService_->DumpProcessForEngMode(argsInStr, result);
431     WS_HILOGI("%{public}s", result.c_str());
432 
433     argsInStr.clear();
434     result.clear();
435     argsInStr.push_back("-t");
436     argsInStr.push_back("bundlename");
437     argsInStr.push_back("abilityname");
438     workSchedulerService_->DumpProcessForEngMode(argsInStr, result);
439     WS_HILOGI("%{public}s", result.c_str());
440 
441     WorkInfo workinfo = WorkInfo();
442     result.clear();
443     workinfo.RequestStorageLevel(WorkCondition::Storage::STORAGE_LEVEL_LOW_OR_OKAY);
444     workinfo.RefreshUid(2);
445     workinfo.SetElement("bundlename", "abilityname");
446     workSchedulerService_->AddWorkInner(workinfo);
447     workSchedulerService_->DumpProcessForEngMode(argsInStr, result);
448     EXPECT_TRUE(result.empty());
449     WS_HILOGI("%{public}s", result.c_str());
450     WS_HILOGI("====== WorkSchedulerServiceTest.Dump_003 end ====== ");
451 }
452 
453 HWTEST_F(WorkSchedulerServiceTest, Dump_004, TestSize.Level1)
454 {
455     WS_HILOGI("====== WorkSchedulerServiceTest.Dump_004 begin ====== ");
456     std::vector<std::string> argsInStr;
457     std::string result;
458     argsInStr.push_back("-d");
459     argsInStr.push_back("storage");
460     argsInStr.push_back("ok");
461     workSchedulerService_->DumpProcessForEngMode(argsInStr, result);
462     WS_HILOGI("%{public}s", result.c_str());
463 
464     argsInStr.clear();
465     argsInStr.push_back("arg0");
466     argsInStr.push_back("arg1");
467     argsInStr.push_back("arg2");
468     argsInStr.push_back("arg3");
469     argsInStr.push_back("arg4");
470     result.clear();
471     workSchedulerService_->DumpProcessForEngMode(argsInStr, result);
472     WS_HILOGI("%{public}s", result.c_str());
473     EXPECT_EQ(result.empty(), false);
474     WS_HILOGI("====== WorkSchedulerServiceTest.Dump_004 end ====== ");
475 }
476 
477 /**
478  * @tc.name: Dump_005
479  * @tc.desc: Test WorkSchedulerService Dump.
480  * @tc.type: FUNC
481  * @tc.require: I9RYLE
482  */
483 HWTEST_F(WorkSchedulerServiceTest, Dump_005, TestSize.Level1)
484 {
485     WS_HILOGI("====== WorkSchedulerServiceTest.Dump_005 begin ====== ");
486     std::vector<std::string> argsInStr;
487     std::string result;
488     argsInStr.push_back("-count");
489     argsInStr.push_back("1");
490     workSchedulerService_->DumpProcessForEngMode(argsInStr, result);
491     WS_HILOGI("%{public}s", result.c_str());
492     EXPECT_EQ(result.empty(), false);
493     WS_HILOGI("====== WorkSchedulerServiceTest.Dump_005 end ====== ");
494 }
495 
496 /**
497  * @tc.name: Dump_006
498  * @tc.desc: Test WorkSchedulerService Dump.
499  * @tc.type: FUNC
500  * @tc.require: IAHY0B
501  */
502 HWTEST_F(WorkSchedulerServiceTest, Dump_006, TestSize.Level1)
503 {
504     WS_HILOGI("====== WorkSchedulerServiceTest.Dump_006 begin ====== ");
505     std::vector<std::string> argsInStr;
506     std::string result;
507     argsInStr.push_back("-s");
508     workSchedulerService_->DumpProcessForEngMode(argsInStr, result);
509     WS_HILOGI("%{public}s", result.c_str());
510     EXPECT_FALSE(result.empty());
511 
512     argsInStr.clear();
513     result.clear();
514     argsInStr.push_back("-s");
515     argsInStr.push_back("-1");
516     argsInStr.push_back("-1");
517     workSchedulerService_->DumpProcessForEngMode(argsInStr, result);
518     WS_HILOGI("%{public}s", result.c_str());
519     EXPECT_FALSE(result.empty());
520 
521     argsInStr.clear();
522     result.clear();
523     argsInStr.push_back("-s");
524     argsInStr.push_back("1");
525     argsInStr.push_back("200000");
526     workSchedulerService_->DumpProcessForEngMode(argsInStr, result);
527     WS_HILOGI("%{public}s", result.c_str());
528     EXPECT_FALSE(result.empty());
529 
530     argsInStr.clear();
531     result.clear();
532     WorkInfo workinfo = WorkInfo();
533     workinfo.uid_ = 202000;
534     workinfo.workId_ = 1;
535     workinfo.saId_ = 1000;
536     workinfo.residentSa_ = true;
537     workSchedulerService_->AddWorkInner(workinfo);
538     argsInStr.push_back("-s");
539     argsInStr.push_back("1000");
540     argsInStr.push_back("202000");
541     workSchedulerService_->DumpProcessForEngMode(argsInStr, result);
542     WS_HILOGI("%{public}s", result.c_str());
543     EXPECT_FALSE(result.empty());
544     WS_HILOGI("====== WorkSchedulerServiceTest.Dump_006 end ====== ");
545 }
546 
547 /**
548  * @tc.name: Dump_007
549  * @tc.desc: Test WorkSchedulerService Dump.
550  * @tc.type: FUNC
551  * @tc.require: IAJSVG
552  */
553 HWTEST_F(WorkSchedulerServiceTest, Dump_007, TestSize.Level1)
554 {
555     WS_HILOGI("====== WorkSchedulerServiceTest.Dump_007 begin ====== ");
556     std::vector<std::string> argsInStr;
557     std::string result;
558     argsInStr.push_back("-x");
559     argsInStr.push_back("1");
560     argsInStr.push_back("1");
561     workSchedulerService_->DumpProcessForEngMode(argsInStr, result);
562     WS_HILOGI("%{public}s", result.c_str());
563     EXPECT_EQ(result.empty(), false);
564 
565     argsInStr.clear();
566     result.clear();
567     argsInStr.push_back("-x");
568     argsInStr.push_back("1");
569     argsInStr.push_back("p");
570     workSchedulerService_->DumpProcessForEngMode(argsInStr, result);
571     WS_HILOGI("%{public}s", result.c_str());
572     EXPECT_EQ(result.empty(), false);
573 
574     argsInStr.clear();
575     result.clear();
576     argsInStr.push_back("-x");
577     argsInStr.push_back("1");
578     argsInStr.push_back("r");
579     workSchedulerService_->DumpProcessForEngMode(argsInStr, result);
580     WS_HILOGI("%{public}s", result.c_str());
581     EXPECT_EQ(result.empty(), false);
582 
583     argsInStr.clear();
584     result.clear();
585     argsInStr.push_back("-cpu");
586     argsInStr.push_back("1");
587     workSchedulerService_->DumpProcessForEngMode(argsInStr, result);
588     WS_HILOGI("%{public}s", result.c_str());
589     EXPECT_EQ(result.empty(), false);
590     WS_HILOGI("====== WorkSchedulerServiceTest.Dump_007 end ====== ");
591 }
592 
593 /**
594  * @tc.name: Dump_008
595  * @tc.desc: Test WorkSchedulerService Dump.
596  * @tc.type: FUNC
597  * @tc.require: IAJSVG
598  */
599 HWTEST_F(WorkSchedulerServiceTest, Dump_008, TestSize.Level1)
600 {
601     WS_HILOGI("====== WorkSchedulerServiceTest.Dump_008 begin ====== ");
602     std::vector<std::string> argsInStr;
603     std::string result;
604     argsInStr.push_back("-t");
605     argsInStr.push_back("bundlename");
606     argsInStr.push_back("abilityname");
607     workSchedulerService_->DumpProcessForUserMode(argsInStr, result);
608     EXPECT_EQ(result.empty(), true);
609     WS_HILOGI("====== WorkSchedulerServiceTest.Dump_008 end ====== ");
610 }
611 
612 HWTEST_F(WorkSchedulerServiceTest, WorkStandbyStateChangeCallbackTest_001, TestSize.Level1)
613 {
614     WS_HILOGI("====== WorkSchedulerServiceTest.WorkStandbyStateChangeCallbackTest_001 begin ====== ");
615     workSchedulerService_->standbyStateObserver_->OnDeviceIdleMode(true, false);
616     workSchedulerService_->standbyStateObserver_->OnDeviceIdleMode(true, true);
617     workSchedulerService_->standbyStateObserver_->OnDeviceIdleMode(false, true);
618     workSchedulerService_->standbyStateObserver_->OnAllowListChanged(0, "bundlename", 0, true);
619     EXPECT_NE(workSchedulerService_, nullptr);
620     WS_HILOGI("====== WorkSchedulerServiceTest.WorkStandbyStateChangeCallbackTest_001 end ====== ");
621 }
622 
623 HWTEST_F(WorkSchedulerServiceTest, WorkBundleGroupChangeCallback_001, TestSize.Level1)
624 {
625     WS_HILOGI("====== WorkSchedulerServiceTest.WorkBundleGroupChangeCallback_001 begin ====== ");
626     OHOS::DeviceUsageStats::AppGroupCallbackInfo appGroupCallbackInfo1(0, 1, 2, 0, "bundlename");
627     workSchedulerService_->groupObserver_->OnAppGroupChanged(appGroupCallbackInfo1);
628     OHOS::DeviceUsageStats::AppGroupCallbackInfo appGroupCallbackInfo2(0, 2, 1, 0, "bundlename");
629     workSchedulerService_->groupObserver_->OnAppGroupChanged(appGroupCallbackInfo2);
630     EXPECT_NE(workSchedulerService_, nullptr);
631     WS_HILOGI("====== WorkSchedulerServiceTest.WorkBundleGroupChangeCallback_001 end ====== ");
632 }
633 
634 HWTEST_F(WorkSchedulerServiceTest, WorkSchedulerConnection_001, TestSize.Level1)
635 {
636     WS_HILOGI("====== WorkSchedulerServiceTest.WorkSchedulerConnection_001 begin ====== ");
637     auto workinfo = std::make_shared<WorkInfo>();
638     WorkSchedulerConnection conection(workinfo);
639     AppExecFwk::ElementName element;
640     conection.StopWork();
641     conection.OnAbilityDisconnectDone(element, 0);
642     EXPECT_EQ(conection.proxy_, nullptr);
643     WS_HILOGI("====== WorkSchedulerServiceTest.WorkSchedulerConnection_001 end ====== ");
644 }
645 
646 HWTEST_F(WorkSchedulerServiceTest, SchedulerBgTaskSubscriber_001, TestSize.Level1)
647 {
648     WS_HILOGI("====== WorkSchedulerServiceTest.SchedulerBgTaskSubscriber_001 begin ====== ");
649     SchedulerBgTaskSubscriber subscriber;
650     subscriber.OnProcEfficiencyResourcesApply(nullptr);
651     subscriber.OnProcEfficiencyResourcesReset(nullptr);
652     subscriber.OnAppEfficiencyResourcesApply(nullptr);
653     subscriber.OnAppEfficiencyResourcesReset(nullptr);
654 
655     auto resourceInfo = std::make_shared<BackgroundTaskMgr::ResourceCallbackInfo>(0, 0, 0xFFFF, "name");
656     subscriber.OnProcEfficiencyResourcesApply(resourceInfo);
657     subscriber.OnProcEfficiencyResourcesReset(resourceInfo);
658     subscriber.OnAppEfficiencyResourcesApply(resourceInfo);
659     subscriber.OnAppEfficiencyResourcesReset(resourceInfo);
660     EXPECT_EQ(resourceInfo->GetBundleName(), "name");
661     WS_HILOGI("====== WorkSchedulerServiceTest.SchedulerBgTaskSubscriber_001 end ====== ");
662 }
663 
664 HWTEST_F(WorkSchedulerServiceTest, WorkQueueEventHandler_001, TestSize.Level1)
665 {
666     WS_HILOGI("====== WorkSchedulerServiceTest.WorkQueueEventHandler_001 begin ====== ");
667     WorkQueueEventHandler handler(nullptr, nullptr);
668     AppExecFwk::InnerEvent::Pointer event = AppExecFwk::InnerEvent::Get(0);
669     handler.ProcessEvent(event);
670     event = AppExecFwk::InnerEvent::Get(1);
671     handler.ProcessEvent(event);
672     event = AppExecFwk::InnerEvent::Get(2);
673     handler.ProcessEvent(event);
674     EXPECT_TRUE(handler.manager_ == nullptr);
675     WS_HILOGI("====== WorkSchedulerServiceTest.WorkQueueEventHandler_001 end ====== ");
676 }
677 
678 HWTEST_F(WorkSchedulerServiceTest, WorkEventHandler_001, TestSize.Level1)
679 {
680     WS_HILOGI("====== WorkSchedulerServiceTest.WorkEventHandler_001 begin ====== ");
681     WorkEventHandler handler(workSchedulerService_->eventRunner_, workSchedulerService_);
682     AppExecFwk::InnerEvent::Pointer event = AppExecFwk::InnerEvent::Get(0);
683     handler.ProcessEvent(event);
684     event = AppExecFwk::InnerEvent::Get(1);
685     handler.ProcessEvent(event);
686     event = AppExecFwk::InnerEvent::Get(2);
687     handler.ProcessEvent(event);
688     event = AppExecFwk::InnerEvent::Get(3);
689     handler.ProcessEvent(event);
690     event = AppExecFwk::InnerEvent::Get(4);
691     handler.ProcessEvent(event);
692     event = AppExecFwk::InnerEvent::Get(5);
693     handler.ProcessEvent(event);
694     EXPECT_TRUE(workSchedulerService_->eventRunner_ != nullptr);
695     WS_HILOGI("====== WorkSchedulerServiceTest.WorkEventHandler_001 end ====== ");
696 }
697 
698 HWTEST_F(WorkSchedulerServiceTest, BatteryLevelListener_001, TestSize.Level1)
699 {
700     WS_HILOGI("====== WorkSchedulerServiceTest.BatteryLevelListener_001 begin ====== ");
701 
702     BatteryLevelListener batteryLevelListener(workSchedulerService_->workQueueManager_, workSchedulerService_);
703 
704     batteryLevelListener.Start();
705     EXPECT_NE(batteryLevelListener.commonEventSubscriber, nullptr);
706 
707     EventFwk::CommonEventData data;
708     batteryLevelListener.commonEventSubscriber->OnReceiveEvent(data);
709 
710     EventFwk::Want want;
711     want.SetAction(EventFwk::CommonEventSupport::COMMON_EVENT_BATTERY_CHANGED);
712     data.SetWant(want);
713     batteryLevelListener.commonEventSubscriber->OnReceiveEvent(data);
714 
715     want.SetParam(PowerMgr::BatteryInfo::COMMON_EVENT_KEY_CAPACITY, 20);
716     data.SetWant(want);
717     batteryLevelListener.commonEventSubscriber->OnReceiveEvent(data);
718     batteryLevelListener.Stop();
719 
720     WS_HILOGI("====== WorkSchedulerServiceTest.BatteryLevelListener_001 end ====== ");
721 }
722 
723 HWTEST_F(WorkSchedulerServiceTest, BatteryStatusListener_001, TestSize.Level1)
724 {
725     WS_HILOGI("====== WorkSchedulerServiceTest.BatteryStatusListener_001 begin ====== ");
726     BatteryStatusListener batteryStatusListener(workSchedulerService_->workQueueManager_);
727 
728     batteryStatusListener.Start();
729     EXPECT_NE(batteryStatusListener.commonEventSubscriber, nullptr);
730 
731     EventFwk::CommonEventData data;
732     batteryStatusListener.commonEventSubscriber->OnReceiveEvent(data);
733 
734     EventFwk::Want want;
735     want.SetAction(EventFwk::CommonEventSupport::COMMON_EVENT_BATTERY_LOW);
736     data.SetWant(want);
737     batteryStatusListener.commonEventSubscriber->OnReceiveEvent(data);
738 
739     want.SetAction(EventFwk::CommonEventSupport::COMMON_EVENT_BATTERY_OKAY);
740     data.SetWant(want);
741     batteryStatusListener.commonEventSubscriber->OnReceiveEvent(data);
742     batteryStatusListener.Stop();
743 
744     WS_HILOGI("====== WorkSchedulerServiceTest.BatteryStatusListener_001 end ====== ");
745 }
746 
747 HWTEST_F(WorkSchedulerServiceTest, ChargerListener_001, TestSize.Level1)
748 {
749     WS_HILOGI("====== WorkSchedulerServiceTest.ChargerListener_001 begin ====== ");
750     ChargerListener chargerListener(workSchedulerService_->workQueueManager_);
751 
752     chargerListener.Start();
753     EXPECT_NE(chargerListener.commonEventSubscriber, nullptr);
754 
755     EventFwk::CommonEventData data;
756     chargerListener.commonEventSubscriber->OnReceiveEvent(data);
757 
758     EventFwk::Want want;
759     want.SetAction(EventFwk::CommonEventSupport::COMMON_EVENT_POWER_CONNECTED);
760     data.SetWant(want);
761     data.SetCode(static_cast<uint32_t>(PowerMgr::BatteryPluggedType::PLUGGED_TYPE_AC));
762     chargerListener.commonEventSubscriber->OnReceiveEvent(data);
763 
764     data.SetCode(static_cast<uint32_t>(PowerMgr::BatteryPluggedType::PLUGGED_TYPE_USB));
765     chargerListener.commonEventSubscriber->OnReceiveEvent(data);
766 
767 
768     data.SetCode(static_cast<uint32_t>(PowerMgr::BatteryPluggedType::PLUGGED_TYPE_WIRELESS));
769     chargerListener.commonEventSubscriber->OnReceiveEvent(data);
770 
771     want.SetAction(EventFwk::CommonEventSupport::COMMON_EVENT_POWER_DISCONNECTED);
772     data.SetWant(want);
773     data.SetCode(static_cast<uint32_t>(PowerMgr::BatteryPluggedType::PLUGGED_TYPE_NONE));
774     chargerListener.commonEventSubscriber->OnReceiveEvent(data);
775     chargerListener.Stop();
776 
777     WS_HILOGI("====== WorkSchedulerServiceTest.ChargerListener_001 end ====== ");
778 }
779 
780 HWTEST_F(WorkSchedulerServiceTest, ListenerStop_001, TestSize.Level1)
781 {
782     WS_HILOGI("====== ListenerStop_001 begin====== ");
783     for (auto pair : workSchedulerService_->workQueueManager_->listenerMap_)
784     {
785         pair.second->Stop();
786     }
787     workSchedulerService_->workQueueManager_->listenerMap_.clear();
788     EXPECT_TRUE(workSchedulerService_->workQueueManager_->listenerMap_.size() == 0);
789     WS_HILOGI("====== ListenerStop_001 end ====== ");
790 }
791 
792 HWTEST_F(WorkSchedulerServiceTest, WorkSchedServiceStub_001, TestSize.Level1)
793 {
794     MyWorkSchedulerService s;
795     MessageParcel data, reply;
796     MessageOption option;
797     const int size = 11;
798     for (int i = 0; i < size; i++) {
799         s.OnRemoteRequest(i, data, reply, option);
800         WorkInfo info;
801         info.Marshalling(data);
802         s.OnRemoteRequest(i, data, reply, option);
803     }
804     int32_t ret = s.OnRemoteRequest(0, data, reply, option);
805     EXPECT_TRUE(ret != ERR_OK);
806 }
807 
808 /**
809  * @tc.name: SendEvent_001
810  * @tc.desc: Test WorkSchedulerService SendEvent.
811  * @tc.type: FUNC
812  * @tc.require: I9J0A7
813  */
814 HWTEST_F(WorkSchedulerServiceTest, SendEvent_001, TestSize.Level1)
815 {
816     int32_t initDelay = 2 * 1000;
817     workSchedulerService_->GetHandler()->
818         SendEvent(AppExecFwk::InnerEvent::Get(WorkEventHandler::SERVICE_INIT_MSG, 0), initDelay);
819     EXPECT_TRUE(workSchedulerService_->ready_);
820 }
821 
822 /**
823  * @tc.name: GetJsonFromFile_001
824  * @tc.desc: Test WorkSchedulerService GetJsonFromFile.
825  * @tc.type: FUNC
826  * @tc.require: I9J0A7
827  */
828 HWTEST_F(WorkSchedulerServiceTest, GetJsonFromFile_001, TestSize.Level1)
829 {
830     Json::Value root;
831     const char* path = "/a/b/c";
832     bool ret = workSchedulerService_->GetJsonFromFile(path, root);
833     EXPECT_FALSE(ret);
834 }
835 
836 /**
837  * @tc.name: GetAppIndexAndBundleNameByUid_001
838  * @tc.desc: Test WorkSchedulerService GetAppIndexAndBundleNameByUid.
839  * @tc.type: FUNC
840  * @tc.require: I9TL53
841  */
842 HWTEST_F(WorkSchedulerServiceTest, GetAppIndexAndBundleNameByUid_001, TestSize.Level1)
843 {
844     int32_t appIndex;
845     std::string bundleName;
846     int32_t uid = 1;
847     bool ret = workSchedulerService_->GetAppIndexAndBundleNameByUid(uid, appIndex, bundleName);
848     EXPECT_FALSE(ret);
849 }
850 
851 /**
852  * @tc.name: LoadSa_001
853  * @tc.desc: Test WorkSchedulerService LoadSa.
854  * @tc.type: FUNC
855  * @tc.require: IAHY0B
856  */
857 HWTEST_F(WorkSchedulerServiceTest, LoadSa_001, TestSize.Level1)
858 {
859     std::shared_ptr<WorkInfo> workInfo_ = std::make_shared<WorkInfo>();
860     workInfo_->SetWorkId(-1);
861     std::string bundleName = "com.example.workStatus";
862     std::string abilityName = "workStatusAbility";
863     workInfo_->SetElement(bundleName, abilityName);
864     workInfo_->RequestPersisted(false);
865     time_t baseTime;
866     (void)time(&baseTime);
867     workInfo_->RequestBaseTime(baseTime);
868     std::shared_ptr<WorkStatus> workStatus_ = std::make_shared<WorkStatus>(*(workInfo_.get()), -1);
869 
870     workSchedulerService_->ready_ = false;
871     workSchedulerService_->LoadSa(workStatus_, "");
872 
873     workSchedulerService_->ready_ = true;
874     workSchedulerService_->LoadSa(workStatus_, "");
875 
876     workInfo_->saId_ = 401;
877     workSchedulerService_->LoadSa(workStatus_, "");
878 
879     workInfo_->residentSa_ = true;
880     workSchedulerService_->LoadSa(workStatus_, "");
881 
882     workInfo_->saId_ = 5300;
883     workSchedulerService_->LoadSa(workStatus_, "");
884 
885     workInfo_->residentSa_ = false;
886     bool ret = workSchedulerService_->LoadSa(workStatus_, "");
887     EXPECT_FALSE(ret);
888 }
889 
890 /**
891  * @tc.name: CheckExtensionInfos_001
892  * @tc.desc: Test WorkSchedulerService CheckExtensionInfos.
893  * @tc.type: FUNC
894  * @tc.require: IAJSVG
895  */
896 HWTEST_F(WorkSchedulerServiceTest, CheckExtensionInfos_001, TestSize.Level1)
897 {
898     int32_t uid = 1;
899     WorkInfo workInfo = WorkInfo();
900     workInfo.SetWorkId(1);
901     workInfo.SetElement("bundleName", "abilityName");
902     bool ret = workSchedulerService_->CheckExtensionInfos(workInfo, uid);
903     EXPECT_TRUE(ret);
904 }
905 
906 /**
907  * @tc.name: InitBgTaskSubscriber_001
908  * @tc.desc: Test WorkSchedulerService InitBgTaskSubscriber.
909  * @tc.type: FUNC
910  * @tc.require: IAJSVG
911  */
912 HWTEST_F(WorkSchedulerServiceTest, InitBgTaskSubscriber_001, TestSize.Level1)
913 {
914     bool ret = workSchedulerService_->InitBgTaskSubscriber();
915     EXPECT_TRUE(ret);
916 }
917 
918 /**
919  * @tc.name: AllowDump_001
920  * @tc.desc: Test WorkSchedulerService AllowDump.
921  * @tc.type: FUNC
922  * @tc.require: IAJSVG
923  */
924 HWTEST_F(WorkSchedulerServiceTest, AllowDump_001, TestSize.Level1)
925 {
926     bool ret = workSchedulerService_->AllowDump();
927     EXPECT_FALSE(ret);
928 }
929 
930 /**
931  * @tc.name: UpdateWorkBeforeRealStart_001
932  * @tc.desc: Test WorkSchedulerService UpdateWorkBeforeRealStart.
933  * @tc.type: FUNC
934  * @tc.require: IAJSVG
935  */
936 HWTEST_F(WorkSchedulerServiceTest, UpdateWorkBeforeRealStart_001, TestSize.Level1)
937 {
938     std::shared_ptr<WorkStatus> workStatus = nullptr;
939     workSchedulerService_->UpdateWorkBeforeRealStart(workStatus);
940 
941     WorkInfo workInfo = WorkInfo();
942     workStatus = std::make_shared<WorkStatus>(workInfo, 1);
943     workStatus->conditionMap_.clear();
944     workSchedulerService_->UpdateWorkBeforeRealStart(workStatus);
945 
946     std::shared_ptr<Condition> repeatCycle = std::make_shared<Condition>();
947     repeatCycle->boolVal = true;
948     workStatus->conditionMap_.emplace(WorkCondition::Type::TIMER, repeatCycle);
949     workSchedulerService_->UpdateWorkBeforeRealStart(workStatus);
950     EXPECT_TRUE(repeatCycle->intVal == 0);
951 }
952 
953 /**
954  * @tc.name: CheckEffiResApplyInfo_001
955  * @tc.desc: Test WorkSchedulerService CheckEffiResApplyInfo.
956  * @tc.type: FUNC
957  * @tc.require: IAJSVG
958  */
959 HWTEST_F(WorkSchedulerServiceTest, CheckEffiResApplyInfo_001, TestSize.Level1)
960 {
961     bool ret = workSchedulerService_->CheckEffiResApplyInfo(1);
962     EXPECT_FALSE(ret);
963 }
964 
965 /**
966  * @tc.name: PauseRunningWorks_001
967  * @tc.desc: Test WorkSchedulerService PauseRunningWorks.
968  * @tc.type: FUNC
969  * @tc.require: IAJSVG
970  */
971 HWTEST_F(WorkSchedulerServiceTest, PauseRunningWorks_001, TestSize.Level1)
972 {
973     workSchedulerService_->TriggerWorkIfConditionReady();
974     int32_t ret = workSchedulerService_->PauseRunningWorks(1);
975     EXPECT_TRUE(ret == E_INVALID_PROCESS_NAME);
976     ret = workSchedulerService_->ResumePausedWorks(1);
977     EXPECT_TRUE(ret == E_INVALID_PROCESS_NAME);
978 }
979 
980 /**
981  * @tc.name: OnAddSystemAbility_001
982  * @tc.desc: Test WorkSchedulerService OnAddSystemAbility.
983  * @tc.type: FUNC
984  * @tc.require: IAJSVG
985  */
986 HWTEST_F(WorkSchedulerServiceTest, OnAddSystemAbility_001, TestSize.Level1)
987 {
988     std::string deviceId;
989     int32_t DEVICE_STANDBY_SERVICE_SYSTEM_ABILITY_ID = 1914;
990     int32_t DEVICE_USAGE_STATISTICS_SYS_ABILITY_ID = 1907;
991     workSchedulerService_->groupObserver_ = nullptr;
992     workSchedulerService_->OnAddSystemAbility(DEVICE_USAGE_STATISTICS_SYS_ABILITY_ID, deviceId);
993     EXPECT_TRUE(workSchedulerService_->groupObserver_ != nullptr);
994     workSchedulerService_->OnRemoveSystemAbility(DEVICE_USAGE_STATISTICS_SYS_ABILITY_ID, deviceId);
995     EXPECT_TRUE(workSchedulerService_->groupObserver_ == nullptr);
996 
997     workSchedulerService_->standbyStateObserver_ = nullptr;
998     workSchedulerService_->OnAddSystemAbility(DEVICE_STANDBY_SERVICE_SYSTEM_ABILITY_ID, deviceId);
999     EXPECT_TRUE(workSchedulerService_->standbyStateObserver_ != nullptr);
1000     workSchedulerService_->OnRemoveSystemAbility(DEVICE_STANDBY_SERVICE_SYSTEM_ABILITY_ID, deviceId);
1001     EXPECT_TRUE(workSchedulerService_->standbyStateObserver_ == nullptr);
1002 }
1003 
1004 /**
1005  * @tc.name: IsDebugApp_001
1006  * @tc.desc: Test WorkSchedulerService IsDebugApp.
1007  * @tc.type: FUNC
1008  * @tc.require: IAJSVG
1009  */
1010 HWTEST_F(WorkSchedulerServiceTest, IsDebugApp_001, TestSize.Level1)
1011 {
1012     bool ret = workSchedulerService_->IsDebugApp("bundleName");
1013     EXPECT_FALSE(ret);
1014 }
1015 
1016 /**
1017  * @tc.name: IsExemptionBundle_001
1018  * @tc.desc: Test WorkSchedulerService IsExemptionBundle.
1019  * @tc.type: FUNC
1020  * @tc.require: IAJSVG
1021  */
1022 HWTEST_F(WorkSchedulerServiceTest, IsExemptionBundle_001, TestSize.Level1)
1023 {
1024     workSchedulerService_->exemptionBundles_.clear();
1025     std::string bundleName = "com.demo.bundle";
1026     bool ret = workSchedulerService_->IsExemptionBundle(bundleName);
1027     EXPECT_FALSE(ret);
1028 }
1029 
1030 /**
1031  * @tc.name: IsExemptionBundle_002
1032  * @tc.desc: Test WorkSchedulerService IsExemptionBundle.
1033  * @tc.type: FUNC
1034  * @tc.require: IAJSVG
1035  */
1036 HWTEST_F(WorkSchedulerServiceTest, IsExemptionBundle_002, TestSize.Level1)
1037 {
1038     std::string bundleName = "com.demo.bundle";
1039     workSchedulerService_->exemptionBundles_.clear();
1040     workSchedulerService_->exemptionBundles_.insert(bundleName);
1041     bool ret = workSchedulerService_->IsExemptionBundle(bundleName);
1042     EXPECT_TRUE(ret);
1043 }
1044 
1045 /**
1046  * @tc.name: IsExemptionBundle_003
1047  * @tc.desc: Test WorkSchedulerService IsExemptionBundle.
1048  * @tc.type: FUNC
1049  * @tc.require: IAJSVG
1050  */
1051 HWTEST_F(WorkSchedulerServiceTest, IsExemptionBundle_003, TestSize.Level1)
1052 {
1053     std::string bundleName = "com.demo.bundle";
1054     workSchedulerService_->exemptionBundles_.clear();
1055     workSchedulerService_->exemptionBundles_.insert("com.demo.bundle1");
1056     bool ret = workSchedulerService_->IsExemptionBundle(bundleName);
1057     EXPECT_FALSE(ret);
1058 }
1059 
1060 /**
1061  * @tc.name: DumpExemptionBundles_001
1062  * @tc.desc: Test WorkSchedulerService DumpExemptionBundles.
1063  * @tc.type: FUNC
1064  * @tc.require: IAJSVG
1065  */
1066 HWTEST_F(WorkSchedulerServiceTest, DumpExemptionBundles_001, TestSize.Level1)
1067 {
1068     workSchedulerService_->exemptionBundles_.clear();
1069     std::string ret = workSchedulerService_->DumpExemptionBundles();
1070     EXPECT_TRUE(ret == "[]");
1071 }
1072 
1073 /**
1074  * @tc.name: DumpExemptionBundles_002
1075  * @tc.desc: Test WorkSchedulerService DumpExemptionBundles.
1076  * @tc.type: FUNC
1077  * @tc.require: IAJSVG
1078  */
1079 HWTEST_F(WorkSchedulerServiceTest, DumpExemptionBundles_002, TestSize.Level1)
1080 {
1081     workSchedulerService_->exemptionBundles_.insert("com.demo.bundle1");
1082     std::string ret = workSchedulerService_->DumpExemptionBundles();
1083     EXPECT_FALSE(ret.empty());
1084 }
1085 
1086 /**
1087  * @tc.name: LoadExemptionBundlesFromFile_001
1088  * @tc.desc: Test WorkSchedulerService LoadExemptionBundlesFromFile.
1089  * @tc.type: FUNC
1090  * @tc.require: IAJSVG
1091  */
1092 HWTEST_F(WorkSchedulerServiceTest, LoadExemptionBundlesFromFile_001, TestSize.Level1)
1093 {
1094     workSchedulerService_->exemptionBundles_.clear();
1095     const char* path = nullptr;
1096     workSchedulerService_->LoadExemptionBundlesFromFile(path);
1097     EXPECT_TRUE(workSchedulerService_->exemptionBundles_.empty());
1098 }
1099 
1100 /**
1101  * @tc.name: LoadExemptionBundlesFromFile_002
1102  * @tc.desc: Test WorkSchedulerService LoadExemptionBundlesFromFile.
1103  * @tc.type: FUNC
1104  * @tc.require: IAJSVG
1105  */
1106 HWTEST_F(WorkSchedulerServiceTest, LoadExemptionBundlesFromFile_002, TestSize.Level1)
1107 {
1108     workSchedulerService_->exemptionBundles_.clear();
1109     const char *path = "/a/b/c";
1110     workSchedulerService_->LoadExemptionBundlesFromFile(path);
1111     EXPECT_TRUE(workSchedulerService_->exemptionBundles_.empty());
1112 }
1113 
1114 /**
1115  * @tc.name: IsPreinstalledBundle_001
1116  * @tc.desc: Test WorkSchedulerService IsPreinstalledBundle.
1117  * @tc.type: FUNC
1118  * @tc.require: IAJSVG
1119  */
1120 HWTEST_F(WorkSchedulerServiceTest, IsPreinstalledBundle_001, TestSize.Level1)
1121 {
1122     workSchedulerService_->preinstalledBundles_.clear();
1123     std::string bundleName = "com.demo.bundle";
1124     bool ret = workSchedulerService_->IsPreinstalledBundle(bundleName);
1125     EXPECT_FALSE(ret);
1126 }
1127 
1128 /**
1129  * @tc.name: IsPreinstalledBundle_002
1130  * @tc.desc: Test WorkSchedulerService IsPreinstalledBundle.
1131  * @tc.type: FUNC
1132  * @tc.require: IAJSVG
1133  */
1134 HWTEST_F(WorkSchedulerServiceTest, IsPreinstalledBundle_002, TestSize.Level1)
1135 {
1136     workSchedulerService_->preinstalledBundles_.clear();
1137     std::string bundleName = "com.demo.bundle";
1138     workSchedulerService_->preinstalledBundles_.insert(bundleName);
1139     bool ret = workSchedulerService_->IsPreinstalledBundle(bundleName);
1140     EXPECT_TRUE(ret);
1141 }
1142 
1143 /**
1144  * @tc.name: IsPreinstalledBundle_003
1145  * @tc.desc: Test WorkSchedulerService IsPreinstalledBundle.
1146  * @tc.type: FUNC
1147  * @tc.require: IAJSVG
1148  */
1149 HWTEST_F(WorkSchedulerServiceTest, IsPreinstalledBundle_003, TestSize.Level1)
1150 {
1151     workSchedulerService_->preinstalledBundles_.clear();
1152     std::string bundleName = "com.demo.bundle";
1153     workSchedulerService_->preinstalledBundles_.insert("com.demo.bundle1");
1154     bool ret = workSchedulerService_->IsPreinstalledBundle(bundleName);
1155     EXPECT_FALSE(ret);
1156 }
1157 
1158 /**
1159  * @tc.name: LoadMinRepeatTimeFromFile_001
1160  * @tc.desc: Test WorkSchedulerService LoadMinRepeatTimeFromFile.
1161  * @tc.type: FUNC
1162  * @tc.require: IBB60P
1163  */
1164 HWTEST_F(WorkSchedulerServiceTest, LoadMinRepeatTimeFromFile_001, TestSize.Level1)
1165 {
1166     workSchedulerService_->specialMap_.clear();
1167     const char* path = nullptr;
1168     workSchedulerService_->LoadMinRepeatTimeFromFile(path);
1169     EXPECT_TRUE(workSchedulerService_->specialMap_.empty());
1170 }
1171 
1172 /**
1173  * @tc.name: LoadMinRepeatTimeFromFile_002
1174  * @tc.desc: Test WorkSchedulerService LoadMinRepeatTimeFromFile.
1175  * @tc.type: FUNC
1176  * @tc.require: IBB60P
1177  */
1178 HWTEST_F(WorkSchedulerServiceTest, LoadMinRepeatTimeFromFile_002, TestSize.Level1)
1179 {
1180     workSchedulerService_->specialMap_.clear();
1181     const char *path = "/a/b/c";
1182     workSchedulerService_->LoadMinRepeatTimeFromFile(path);
1183     EXPECT_TRUE(workSchedulerService_->specialMap_.empty());
1184 }
1185 }
1186 }