• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022-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 #include "gtest/hwext/gtest-multithread.h"
18 
19 #include <vector>
20 #include "accesstoken_kit.h"
21 #include "ipc_skeleton.h"
22 #include "nativetoken_kit.h"
23 #include "notifier_mgr.h"
24 #include "plugin_mgr.h"
25 #include "res_common_util.h"
26 #include "res_sched_ipc_interface_code.h"
27 #include "res_sched_common_death_recipient.h"
28 #include "res_sched_service.h"
29 #include "res_sched_service_ability.h"
30 #include "res_sched_systemload_notifier_proxy.h"
31 #include "res_sched_systemload_notifier_stub.h"
32 #include "res_type.h"
33 #include "token_setproc.h"
34 
35 namespace OHOS {
36 namespace ResourceSchedule {
37 using namespace std;
38 using namespace testing::ext;
39 using namespace testing::mt;
40 using namespace Security::AccessToken;
41 class ResSchedServiceTest : public testing::Test {
42 public:
43     static void SetUpTestCase(void);
44     static void TearDownTestCase(void);
45     void SetUp();
46     void TearDown();
47 protected:
48     std::shared_ptr<ResSchedService> resSchedService_ = nullptr;
49     std::shared_ptr<ResSchedServiceAbility> resSchedServiceAbility_ = nullptr;
50 };
51 
52 class TestResSchedSystemloadListener : public ResSchedSystemloadNotifierStub {
53 public:
54     TestResSchedSystemloadListener() = default;
55 
OnSystemloadLevel(int32_t level)56     ErrCode OnSystemloadLevel(int32_t level)
57     {
58         testSystemloadLevel = level;
59         return ERR_OK;
60     }
61 
62     static int32_t testSystemloadLevel;
63 };
64 
65 int32_t TestResSchedSystemloadListener::testSystemloadLevel = 0;
66 
SetUpTestCase(void)67 void ResSchedServiceTest::SetUpTestCase(void)
68 {
69     static const char *perms[] = {
70         "ohos.permission.REPORT_RESOURCE_SCHEDULE_EVENT",
71         "ohos.permission.DUMP",
72     };
73     uint64_t tokenId;
74     NativeTokenInfoParams infoInstance = {
75         .dcapsNum = 0,
76         .permsNum = 2,
77         .aclsNum = 0,
78         .dcaps = nullptr,
79         .perms = perms,
80         .acls = nullptr,
81         .processName = "ResSchedServiceTest",
82         .aplStr = "system_core",
83     };
84     tokenId = GetAccessTokenId(&infoInstance);
85     SetSelfTokenID(tokenId);
86     AccessTokenKit::ReloadNativeTokenInfo();
87 }
88 
TearDownTestCase()89 void ResSchedServiceTest::TearDownTestCase() {}
90 
SetUp()91 void ResSchedServiceTest::SetUp()
92 {
93     /**
94      * @tc.setup: initialize the member variable resSchedServiceAbility_
95      */
96     resSchedService_ = make_shared<ResSchedService>();
97     resSchedServiceAbility_ = make_shared<ResSchedServiceAbility>();
98     resSchedService_->InitAllowIpcReportRes();
99 }
100 
TearDown()101 void ResSchedServiceTest::TearDown()
102 {
103     /**
104      * @tc.teardown: clear resSchedServiceAbility_
105      */
106     resSchedService_ = nullptr;
107     resSchedServiceAbility_ = nullptr;
108 }
109 
110 /**
111  * @tc.name: ressched service dump 001
112  * @tc.desc: Verify if ressched service dump commonds is success.
113  * @tc.type: FUNC
114  * @tc.require: issueI5WWV3
115  * @tc.author:lice
116  */
117 HWTEST_F(ResSchedServiceTest, ServiceDump001, Function | MediumTest | Level0)
118 {
119     PluginMgr::GetInstance().Init();
120     std::string result;
121     resSchedService_->DumpAllInfo(result);
122     EXPECT_TRUE(!result.empty());
123 
124     result = "";
125     resSchedService_->DumpUsage(result);
126     EXPECT_TRUE(!result.empty());
127 
128     int32_t wrongFd = -1;
129     std::vector<std::u16string> argsNull;
130     int res = resSchedService_->Dump(wrongFd, argsNull);
131     EXPECT_NE(res, ERR_OK);
132 
133     int32_t correctFd = -1;
134     res = resSchedService_->Dump(correctFd, argsNull);
135 
136     std::vector<std::u16string> argsHelp = {to_utf16("-h")};
137     res = resSchedService_->Dump(correctFd, argsHelp);
138 
139     std::vector<std::u16string> argsAll = {to_utf16("-a")};
140     res = resSchedService_->Dump(correctFd, argsAll);
141 
142     std::vector<std::u16string> argsError = {to_utf16("-e")};
143     res = resSchedService_->Dump(correctFd, argsError);
144 
145     std::vector<std::u16string> argsPlugin = {to_utf16("-p")};
146     res = resSchedService_->Dump(correctFd, argsPlugin);
147 
148     std::vector<std::u16string> argsOnePlugin = {to_utf16("-p"), to_utf16("1")};
149     res = resSchedService_->Dump(correctFd, argsOnePlugin);
150 
151     std::vector<std::u16string> argsOnePlugin1 = {to_utf16("getRunningLockInfo")};
152     res = resSchedService_->Dump(correctFd, argsOnePlugin1);
153 
154     std::vector<std::u16string> argsOnePlugin2 = {to_utf16("getProcessEventInfo")};
155     res = resSchedService_->Dump(correctFd, argsOnePlugin2);
156 
157     std::vector<std::u16string> argsOnePlugin3 = {to_utf16("getProcessWindowInfo")};
158     res = resSchedService_->Dump(correctFd, argsOnePlugin3);
159 
160     std::vector<std::u16string> argsOnePlugin4 = {to_utf16("getSystemloadInfo")};
161     res = resSchedService_->Dump(correctFd, argsOnePlugin4);
162 
163     std::vector<std::u16string> argsOnePlugin5 = {to_utf16("sendDebugToExecutor")};
164     res = resSchedService_->Dump(correctFd, argsOnePlugin5);
165 
166     std::vector<std::u16string> argsOnePlugin6 = {to_utf16("PluginConfig")};
167     res = resSchedService_->Dump(correctFd, argsOnePlugin6);
168 }
169 
ChangeAbilityTask()170 static void ChangeAbilityTask()
171 {
172     std::shared_ptr<ResSchedServiceAbility> resSchedServiceAbility_ = make_shared<ResSchedServiceAbility>();
173     std::string deviceId;
174     resSchedServiceAbility_->OnAddSystemAbility(-1, deviceId);
175     resSchedServiceAbility_->OnRemoveSystemAbility(-1, deviceId);
176 }
177 
178 /**
179  * @tc.name: Ressched service ReportData 001
180  * @tc.desc: Verify if Ressched service ReportData is success.
181  * @tc.type: FUNC
182  * @tc.require: issueI5WWV3
183  * @tc.author:lice
184  */
185 HWTEST_F(ResSchedServiceTest, Report001, Function | MediumTest | Level0)
186 {
187     std::string payload;
188     EXPECT_TRUE(resSchedService_ != nullptr);
189     resSchedService_->ReportData(0, 0, payload);
190     std::string deviceId;
191     int32_t systemAbilityId = -1;
192     resSchedServiceAbility_->OnAddSystemAbility(systemAbilityId, deviceId);
193     resSchedServiceAbility_->OnRemoveSystemAbility(systemAbilityId, deviceId);
194     SET_THREAD_NUM(10);
195     GTEST_RUN_TASK(ChangeAbilityTask);
196 }
197 
198 /**
199  * @tc.name: Ressched service ReportData 002
200  * @tc.desc: Verify if Ressched service ReportData is success.
201  * @tc.type: FUNC
202  * @tc.require: issueIC9NFW
203  * @tc.author:baiheng
204  */
205 HWTEST_F(ResSchedServiceTest, Report003, Function | MediumTest | Level0)
206 {
207     std::string payload;
208     EXPECT_TRUE(resSchedService_ != nullptr);
209     resSchedService_->ReportData(ResType::RES_TYPE_CLICK_RECOGNIZE, ResType::ClickEventType::TOUCH_EVENT_DOWN, payload);
210     resSchedService_->ReportData(ResType::RES_TYPE_PUSH_PAGE, ResType::PushPageType::PUSH_PAGE_START, payload);
211     resSchedService_->ReportData(ResType::RES_TYPE_SLIDE_RECOGNIZE, 0, payload);
212     resSchedService_->ReportData(ResType::RES_TYPE_POP_PAGE, 0, payload);
213     resSchedService_->ReportData(ResType::RES_TYPE_LOAD_PAGE, 0, payload);
214     resSchedService_->ReportData(ResType::RES_TYPE_KEY_EVENT, 0, payload);
215 }
216 
217 /**
218  * @tc.name: Ressched service ReportData 003
219  * @tc.desc: Verify if Ressched service ReportData is success.
220  * @tc.type: FUNC
221  * @tc.require: issueIC9NFW
222  * @tc.author:baiheng
223  */
224 HWTEST_F(ResSchedServiceTest, Report004, Function | MediumTest | Level0)
225 {
226     std::string payload;
227     EXPECT_TRUE(resSchedService_ != nullptr);
228     resSchedService_->ReportData(ResType::SYNC_RES_TYPE_THAW_ONE_APP, 0, payload);
229     resSchedService_->ReportData(ResType::RES_TYPE_REPORT_SCENE_BOARD, 0, payload);
230     resSchedService_->ReportData(ResType::RES_TYPE_SHOW_REMOTE_ANIMATION, 0, payload);
231     resSchedService_->ReportData(ResType::RES_TYPE_MOVE_WINDOW, 0, payload);
232     resSchedService_->ReportData(ResType::RES_TYPE_RESIZE_WINDOW, 0, payload);
233     resSchedService_->ReportData(ResType::RES_TYPE_ONLY_PERF_APP_COLD_START, 0, payload);
234     resSchedService_->ReportData(ResType::RES_TYPE_GESTURE_ANIMATION, 0, payload);
235     resSchedService_->ReportData(ResType::RES_TYPE_SCENE_ROTATION, 0, payload);
236 }
237 
238 /**
239  * @tc.name: Ressched service ReportData 004
240  * @tc.desc: Verify if Ressched service ReportData is success.
241  * @tc.type: FUNC
242  * @tc.require: issueIC9NFW
243  * @tc.author:baiheng
244  */
245 HWTEST_F(ResSchedServiceTest, Report005, Function | MediumTest | Level0)
246 {
247     std::string payload;
248     EXPECT_TRUE(resSchedService_ != nullptr);
249     resSchedService_->ReportData(ResType::RES_TYPE_SCREEN_STATUS, 0, payload);
250     resSchedService_->ReportData(ResType::RES_TYPE_EXTENSION_STATE_CHANGE, 0, payload);
251     resSchedService_->ReportData(ResType::RES_TYPE_PROCESS_STATE_CHANGE, 0, payload);
252     resSchedService_->ReportData(ResType::RES_TYPE_GET_GAME_SCENE_INFO, 0, payload);
253     resSchedService_->ReportData(ResType::RES_TYPE_GAME_INFO_NOTIFY, 0, payload);
254     resSchedService_->ReportData(ResType::SYNC_RES_TYPE_THAW_ONE_APP, 0, payload);
255 }
256 
257 /**
258  * @tc.name: Ressched service StringToJsonObj001
259  * @tc.desc: test StringToJsonObj.
260  * @tc.type: FUNC
261  * @tc.require: issueIC9NFW
262  * @tc.author:baiheng
263  */
264 HWTEST_F(ResSchedServiceTest, StringToJsonObj001, Function | MediumTest | Level0)
265 {
266     std::string payload;
267     EXPECT_TRUE(resSchedService_ != nullptr);
268     resSchedService_->StringToJsonObj("");
269     resSchedService_->StringToJsonObj("{}");
270     resSchedService_->StringToJsonObj("{\"key\":\"value\"}");
271     resSchedService_->StringToJsonObj("aaa");
272 }
273 
274 #ifdef RESOURCE_SCHEDULE_SERVICE_WITH_EXT_RES_ENABLE
275 /**
276  * @tc.name: Ressched service GetExtTypeByResPayload001
277  * @tc.desc: test GetExtTypeByResPayload.
278  * @tc.type: FUNC
279  * @tc.require: issueIC9NFW
280  * @tc.author:baiheng
281  */
282 HWTEST_F(ResSchedServiceTest, GetExtTypeByResPayload001, Function | MediumTest | Level0)
283 {
284     std::string payload;
285     EXPECT_TRUE(resSchedService_ != nullptr);
286     resSchedService_->GetExtTypeByResPayload(payload);
287     payload = "{\"extType\": 1}";
288     resSchedService_->GetExtTypeByResPayload(payload);
289     payload = "{\"extType\": \"-100.00\"}";
290     resSchedService_->GetExtTypeByResPayload(payload);
291     payload = "{\"extType\": \"10000\"}";
292     resSchedService_->GetExtTypeByResPayload(payload);
293 }
294 #endif
295 
296 /**
297  * @tc.name: Ressched service IsAllowedAppPreload001
298  * @tc.desc: test IsAllowedAppPreload.
299  * @tc.type: FUNC
300  * @tc.require: issueIC9NFW
301  * @tc.author:baiheng
302  */
303 HWTEST_F(ResSchedServiceTest, IsAllowedAppPreload001, Function | MediumTest | Level0)
304 {
305     std::string payload;
306     EXPECT_TRUE(resSchedService_ != nullptr);
307     bool res1 = false;
308     int32_t res2 = -1;
309     resSchedService_->IsAllowedAppPreload("test", 0, res1);
310     resSchedService_->LoadAppPreloadPlugin();
311     resSchedService_->IsAllowedLinkJump(false, res2);
312     resSchedService_->IsAllowedLinkJump(true, res2);
313 }
314 
315 /**
316  * @tc.name: ReportSyncEvent
317  * @tc.desc: test func ReportSyncEvent.
318  * @tc.type: FUNC
319  * @tc.require: I9QN9E
320  */
321 HWTEST_F(ResSchedServiceTest, ReportSyncEvent, Function | MediumTest | Level0)
322 {
323     EXPECT_NE(resSchedService_, nullptr);
324     nlohmann::json payload({{"pid", 100}});
325     std::string reply;
326     int32_t ret;
327     resSchedService_->ReportSyncEvent(ResType::SYNC_RES_TYPE_THAW_ONE_APP, 0,
328         payload.dump(-1, ' ', false, nlohmann::detail::error_handler_t::replace),
329         reply, ret);
330     // 事件分发失败,返回err
331     EXPECT_NE(ret, 0);
332 }
333 
ReportTask()334 static void ReportTask()
335 {
336     std::shared_ptr<ResSchedService> resSchedService_ = make_shared<ResSchedService>();
337     std::string payload;
338     EXPECT_TRUE(resSchedService_ != nullptr);
339     resSchedService_->ReportData(0, 0, payload);
340 }
341 
342 /**
343  * @tc.name: Ressched service ReportData 002
344  * @tc.desc: Test Ressched service ReportData in multithreading.
345  * @tc.type: FUNC
346  * @tc.require: issueI7G8VT
347  * @tc.author: nizihao
348  */
349 HWTEST_F(ResSchedServiceTest, Report002, Function | MediumTest | Level0)
350 {
351     SET_THREAD_NUM(10);
352     GTEST_RUN_TASK(ReportTask);
353 }
354 
355 /**
356  * @tc.name: Ressched service KillProcess 001
357  * @tc.desc: test the interface service KillProcess
358  * @tc.type: FUNC
359  * @tc.require: issueI8VZVN
360  * @tc.author:z30053169
361  */
362 HWTEST_F(ResSchedServiceTest, KillProcess001, Function | MediumTest | Level0)
363 {
364     std::string payload;
365     int32_t t;
366     resSchedService_->KillProcess(payload, t);
367     EXPECT_EQ(t, -1);
368 }
369 
370 /**
371  * @tc.name: Ressched service TestResSchedSystemloadListener 001
372  * @tc.desc: test the interface service TestResSchedSystemloadListener
373  * @tc.type: FUNC
374  * @tc.require: issueI97M6C
375  * @tc.author:shanhaiyang
376  */
377 HWTEST_F(ResSchedServiceTest, TestResSchedSystemloadListener001, Function | MediumTest | Level0)
378 {
379     std::shared_ptr<ResSchedService> resSchedService_ = make_shared<ResSchedService>();
380     EXPECT_TRUE(resSchedService_ != nullptr);
381     sptr<IRemoteObject> notifier = new (std::nothrow) TestResSchedSystemloadListener();
382     EXPECT_TRUE(notifier != nullptr);
383     NotifierMgr::GetInstance().Init();
384     resSchedService_->RegisterSystemloadNotifier(notifier);
385     NotifierMgr::GetInstance().OnApplicationStateChange(2, IPCSkeleton::GetCallingPid());
386     resSchedService_->OnDeviceLevelChanged(0, 2);
387     sleep(1);
388     EXPECT_TRUE(TestResSchedSystemloadListener::testSystemloadLevel == 2);
389     resSchedService_->UnRegisterSystemloadNotifier();
390     NotifierMgr::GetInstance().OnApplicationStateChange(4, IPCSkeleton::GetCallingPid());
391     TestResSchedSystemloadListener::testSystemloadLevel = 0;
392 }
393 
394 /**
395  * @tc.name: Ressched service TestResSchedSystemloadListener 002
396  * @tc.desc: test the interface service TestResSchedSystemloadListener
397  * @tc.type: FUNC
398  * @tc.require: issueI97M6C
399  * @tc.author:shanhaiyang
400  */
401 HWTEST_F(ResSchedServiceTest, TestResSchedSystemloadListener002, Function | MediumTest | Level0)
402 {
403     std::shared_ptr<ResSchedService> resSchedService_ = make_shared<ResSchedService>();
404     EXPECT_TRUE(resSchedService_ != nullptr);
405     sptr<IRemoteObject> notifier = new (std::nothrow) TestResSchedSystemloadListener();
406     EXPECT_TRUE(notifier != nullptr);
407     NotifierMgr::GetInstance().Init();
408     resSchedService_->RegisterSystemloadNotifier(notifier);
409     resSchedService_->OnDeviceLevelChanged(0, 2);
410     sleep(1);
411     EXPECT_TRUE(TestResSchedSystemloadListener::testSystemloadLevel == 2);
412     resSchedService_->UnRegisterSystemloadNotifier();
413     TestResSchedSystemloadListener::testSystemloadLevel = 0;
414 }
415 
416 /**
417  * @tc.name: Ressched service TestResSchedSystemloadListener 003
418  * @tc.desc: test the interface service TestResSchedSystemloadListener
419  * @tc.type: FUNC
420  * @tc.require: issueI97M6C
421  * @tc.author:shanhaiyang
422  */
423 HWTEST_F(ResSchedServiceTest, TestResSchedSystemloadListener003, Function | MediumTest | Level0)
424 {
425     std::shared_ptr<ResSchedService> resSchedService_ = make_shared<ResSchedService>();
426     EXPECT_TRUE(resSchedService_ != nullptr);
427     sptr<IRemoteObject> notifier = new (std::nothrow) TestResSchedSystemloadListener();
428     EXPECT_TRUE(notifier != nullptr);
429     NotifierMgr::GetInstance().Init();
430     resSchedService_->RegisterSystemloadNotifier(notifier);
431     NotifierMgr::GetInstance().OnApplicationStateChange(2, 111111);
432     resSchedService_->OnDeviceLevelChanged(0, 2);
433     sleep(1);
434     EXPECT_TRUE(TestResSchedSystemloadListener::testSystemloadLevel == 2);
435     resSchedService_->UnRegisterSystemloadNotifier();
436     NotifierMgr::GetInstance().OnApplicationStateChange(4, 111111);
437     TestResSchedSystemloadListener::testSystemloadLevel = 0;
438 }
439 
440 /**
441  * @tc.name: Ressched service TestResSchedSystemloadListener 004
442  * @tc.desc: test the interface service TestResSchedSystemloadListener
443  * @tc.type: FUNC
444  * @tc.require: issueI97M6C
445  * @tc.author:shanhaiyang
446  */
447 HWTEST_F(ResSchedServiceTest, TestResSchedSystemloadListener004, Function | MediumTest | Level0)
448 {
449     std::shared_ptr<ResSchedService> resSchedService_ = make_shared<ResSchedService>();
450     EXPECT_TRUE(resSchedService_ != nullptr);
451     sptr<IRemoteObject> notifier = new (std::nothrow) TestResSchedSystemloadListener();
452     EXPECT_TRUE(notifier != nullptr);
453     NotifierMgr::GetInstance().Init();
454     std::string cbType = "systemLoadChange";
455     resSchedService_->RegisterSystemloadNotifier(notifier);
456     NotifierMgr::GetInstance().OnApplicationStateChange(2, IPCSkeleton::GetCallingPid());
457     NotifierMgr::GetInstance().OnRemoteNotifierDied(notifier);
458     resSchedService_->OnDeviceLevelChanged(0, 2);
459     sleep(1);
460     EXPECT_TRUE(TestResSchedSystemloadListener::testSystemloadLevel == 0);
461     resSchedService_->UnRegisterSystemloadNotifier();
462     NotifierMgr::GetInstance().OnApplicationStateChange(4, IPCSkeleton::GetCallingPid());
463     TestResSchedSystemloadListener::testSystemloadLevel = 0;
464 }
465 
466 /**
467  * @tc.name: Ressched service RegisterSystemloadNotifier 001
468  * @tc.desc: test the interface service RegisterSystemloadNotifier
469  * @tc.type: FUNC
470  * @tc.require: issueI97M6C
471  * @tc.author:shanhaiyang
472  */
473 HWTEST_F(ResSchedServiceTest, RegisterSystemloadNotifier001, Function | MediumTest | Level0)
474 {
475     std::shared_ptr<ResSchedService> resSchedService_ = make_shared<ResSchedService>();
476     EXPECT_TRUE(resSchedService_ != nullptr);
477     sptr<IRemoteObject> notifier = new (std::nothrow) TestResSchedSystemloadListener();
478     EXPECT_TRUE(notifier != nullptr);
479     NotifierMgr::GetInstance().Init();
480     resSchedService_->RegisterSystemloadNotifier(notifier);
481 }
482 
483 /**
484  * @tc.name: Ressched service RegisterSystemloadNotifier 002
485  * @tc.desc: test the interface service RegisterSystemloadNotifier
486  * @tc.type: FUNC
487  * @tc.require: issueI97M6C
488  * @tc.author:shanhaiyang
489  */
490 HWTEST_F(ResSchedServiceTest, RegisterSystemloadNotifier002, Function | MediumTest | Level0)
491 {
492     std::shared_ptr<ResSchedService> resSchedService_ = make_shared<ResSchedService>();
493     EXPECT_TRUE(resSchedService_ != nullptr);
494     sptr<IRemoteObject> notifier = new (std::nothrow) TestResSchedSystemloadListener();
495     EXPECT_TRUE(notifier != nullptr);
496     NotifierMgr::GetInstance().Init();
497     resSchedService_->RegisterSystemloadNotifier(notifier);
498     resSchedService_->RegisterSystemloadNotifier(notifier);
499 }
500 
501 /**
502  * @tc.name: Ressched service UnRegisterSystemloadNotifier 001
503  * @tc.desc: test the interface service UnRegisterSystemloadNotifier
504  * @tc.type: FUNC
505  * @tc.require: issueI97M6C
506  * @tc.author:shanhaiyang
507  */
508 HWTEST_F(ResSchedServiceTest, UnRegisterSystemloadNotifier001, Function | MediumTest | Level0)
509 {
510     std::shared_ptr<ResSchedService> resSchedService_ = make_shared<ResSchedService>();
511     EXPECT_TRUE(resSchedService_ != nullptr);
512     sptr<IRemoteObject> notifier = new (std::nothrow) TestResSchedSystemloadListener();
513     EXPECT_TRUE(notifier != nullptr);
514     NotifierMgr::GetInstance().Init();
515     resSchedService_->RegisterSystemloadNotifier(notifier);
516     resSchedService_->UnRegisterSystemloadNotifier();
517 }
518 
519 /**
520  * @tc.name: Ressched service UnRegisterSystemloadNotifier 002
521  * @tc.desc: test the interface service UnRegisterSystemloadNotifier
522  * @tc.type: FUNC
523  * @tc.require: issueI97M6C
524  * @tc.author:shanhaiyang
525  */
526 HWTEST_F(ResSchedServiceTest, UnRegisterSystemloadNotifier002, Function | MediumTest | Level0)
527 {
528     std::shared_ptr<ResSchedService> resSchedService_ = make_shared<ResSchedService>();
529     EXPECT_TRUE(resSchedService_ != nullptr);
530     sptr<IRemoteObject> notifier = new (std::nothrow) TestResSchedSystemloadListener();
531     EXPECT_TRUE(notifier != nullptr);
532     NotifierMgr::GetInstance().Init();
533     resSchedService_->UnRegisterSystemloadNotifier();
534 }
535 
536 /**
537  * @tc.name: Ressched service GetSystemloadLevel 001
538  * @tc.desc: test the interface service GetSystemloadLevel
539  * @tc.type: FUNC
540  * @tc.require: issueI97M6C
541  * @tc.author:shanhaiyang
542  */
543 HWTEST_F(ResSchedServiceTest, GetSystemloadLevel001, Function | MediumTest | Level0)
544 {
545     std::shared_ptr<ResSchedService> resSchedService_ = make_shared<ResSchedService>();
546     EXPECT_TRUE(resSchedService_ != nullptr);
547     sptr<IRemoteObject> notifier = new (std::nothrow) TestResSchedSystemloadListener();
548     EXPECT_TRUE(notifier != nullptr);
549     NotifierMgr::GetInstance().Init();
550     resSchedService_->OnDeviceLevelChanged(0, 0);
551     int32_t res;
552     resSchedService_->GetSystemloadLevel(res);
553     EXPECT_TRUE(res == 0);
554 }
555 
556 /**
557  * @tc.name: Ressched service GetSystemloadLevel 002
558  * @tc.desc: test the interface service GetSystemloadLevel
559  * @tc.type: FUNC
560  * @tc.require: issueI97M6C
561  * @tc.author:shanhaiyang
562  */
563 HWTEST_F(ResSchedServiceTest, GetSystemloadLevel002, Function | MediumTest | Level0)
564 {
565     std::shared_ptr<ResSchedService> resSchedService_ = make_shared<ResSchedService>();
566     EXPECT_TRUE(resSchedService_ != nullptr);
567     sptr<IRemoteObject> notifier = new (std::nothrow) TestResSchedSystemloadListener();
568     EXPECT_TRUE(notifier != nullptr);
569     NotifierMgr::GetInstance().Init();
570     resSchedService_->OnDeviceLevelChanged(0, 2);
571     resSchedService_->OnDeviceLevelChanged(1, 5);
572     int32_t res;
573     resSchedService_->GetSystemloadLevel(res);
574     EXPECT_TRUE(res == 2);
575 }
576 
577 class TestResSchedServiceStub : public ResSchedServiceStub {
578 public:
TestResSchedServiceStub()579     TestResSchedServiceStub() : ResSchedServiceStub() {}
580 
ReportData(uint32_t restype,int64_t value,const std::string & payload)581     ErrCode ReportData(uint32_t restype, int64_t value, const std::string& payload) override
582     {
583         return ERR_OK;
584     }
585 
ReportSyncEvent(uint32_t resType,int64_t value,const std::string & payload,std::string & reply,int32_t & resultValue)586     ErrCode ReportSyncEvent(uint32_t resType, int64_t value, const std::string& payload,
587         std::string& reply, int32_t& resultValue) override
588     {
589         return ERR_OK;
590     }
591 
KillProcess(const std::string & payload,int32_t & resultValue)592     ErrCode KillProcess(const std::string& payload, int32_t& resultValue) override
593     {
594         return ERR_OK;
595     }
596 
RegisterSystemloadNotifier(const sptr<IRemoteObject> & notifier)597     ErrCode RegisterSystemloadNotifier(const sptr<IRemoteObject>& notifier) override
598     {
599         return ERR_OK;
600     }
601 
UnRegisterSystemloadNotifier()602     ErrCode UnRegisterSystemloadNotifier() override
603     {
604         return ERR_OK;
605     }
606 
RegisterEventListener(const sptr<IRemoteObject> & listener,uint32_t eventType,uint32_t listenerGroup)607     ErrCode RegisterEventListener(const sptr<IRemoteObject>& listener, uint32_t eventType,
608         uint32_t listenerGroup) override
609     {
610         return ERR_OK;
611     }
612 
UnRegisterEventListener(uint32_t eventType,uint32_t listenerGroup)613     ErrCode UnRegisterEventListener(uint32_t eventType,
614         uint32_t listenerGroup) override
615     {
616         return ERR_OK;
617     }
618 
GetSystemloadLevel(int32_t & resultValue)619     ErrCode GetSystemloadLevel(int32_t& resultValue) override
620     {
621         return ERR_OK;
622     }
623 
IsAllowedAppPreload(const std::string & bundleName,int32_t preloadMode,bool & resultValue)624     ErrCode IsAllowedAppPreload(const std::string& bundleName, int32_t preloadMode, bool& resultValue) override
625     {
626         return ERR_OK;
627     }
628 
IsAllowedLinkJump(bool isAllowedLinkJump,int32_t & resultValue)629     ErrCode IsAllowedLinkJump(bool isAllowedLinkJump, int32_t& resultValue) override
630     {
631         return ERR_OK;
632     }
633 
GetResTypeList(std::set<uint32_t> & resTypeList)634     ErrCode GetResTypeList(std::set<uint32_t>& resTypeList) override
635     {
636         return ERR_OK;
637     }
638 
RegisterSuspendObserver(const sptr<ISuspendStateObserverBase> & observer,int32_t & funcResult)639     ErrCode RegisterSuspendObserver(const sptr<ISuspendStateObserverBase> &observer, int32_t &funcResult) override
640     {
641         return ERR_OK;
642     }
643 
UnregisterSuspendObserver(const sptr<ISuspendStateObserverBase> & observer,int32_t & funcResult)644     ErrCode UnregisterSuspendObserver(const sptr<ISuspendStateObserverBase> &observer, int32_t &funcResult) override
645     {
646         return ERR_OK;
647     }
648 
GetSuspendStateByUid(const int32_t uid,bool & isFrozen,int32_t & funcResult)649     ErrCode GetSuspendStateByUid(const int32_t uid, bool &isFrozen, int32_t &funcResult) override
650     {
651         return ERR_OK;
652     }
653 
GetSuspendStateByPid(const int32_t pid,bool & isFrozen,int32_t & funcResult)654     ErrCode GetSuspendStateByPid(const int32_t pid, bool &isFrozen, int32_t &funcResult) override
655     {
656         return ERR_OK;
657     }
658 };
659 
660 /**
661  * @tc.name: ResSchedServicesStub RemoteRequest 001
662  * @tc.desc: Verify if resschedstub RemoteRequest is success.
663  * @tc.type: FUNC
664  * @tc.require: issueI5WWV3 issueI6D6BM
665  * @tc.author:lice
666  */
667 HWTEST_F(ResSchedServiceTest, RemoteRequest001, Function | MediumTest | Level0)
668 {
669     auto resSchedServiceStub_ = make_shared<TestResSchedServiceStub>();
670     MessageOption option;
671     MessageParcel reply;
672     int32_t res = resSchedServiceStub_->OnRemoteRequest(
673         static_cast<uint32_t>(IResSchedServiceIpcCode::COMMAND_REPORT_DATA), reply, reply, option);
674     EXPECT_TRUE(res);
675     res = resSchedServiceStub_->OnRemoteRequest(
676         static_cast<uint32_t>(IResSchedServiceIpcCode::COMMAND_REPORT_SYNC_EVENT), reply, reply, option);
677     EXPECT_TRUE(res);
678     res = resSchedServiceStub_->OnRemoteRequest(
679         static_cast<uint32_t>(IResSchedServiceIpcCode::COMMAND_KILL_PROCESS), reply, reply, option);
680     EXPECT_TRUE(res);
681     res = resSchedServiceStub_->OnRemoteRequest(0, reply, reply, option);
682     EXPECT_TRUE(res);
683     res = resSchedServiceStub_->OnRemoteRequest(
684         static_cast<uint32_t>(IResSchedServiceIpcCode::COMMAND_REGISTER_SYSTEMLOAD_NOTIFIER), reply, reply, option);
685     EXPECT_TRUE(res);
686     res = resSchedServiceStub_->OnRemoteRequest(
687         static_cast<uint32_t>(IResSchedServiceIpcCode::COMMAND_UN_REGISTER_SYSTEMLOAD_NOTIFIER), reply, reply, option);
688     EXPECT_TRUE(res);
689     res = resSchedServiceStub_->OnRemoteRequest(
690         static_cast<uint32_t>(IResSchedServiceIpcCode::COMMAND_GET_SYSTEMLOAD_LEVEL), reply, reply, option);
691     EXPECT_TRUE(res);
692 }
693 
RemoteRequestTask()694 static void RemoteRequestTask()
695 {
696     auto resSchedServiceStub_ = make_shared<TestResSchedServiceStub>();
697     MessageOption option;
698     MessageParcel reply;
699     int32_t res = resSchedServiceStub_->OnRemoteRequest(
700         static_cast<uint32_t>(IResSchedServiceIpcCode::COMMAND_REPORT_DATA), reply, reply, option);
701     EXPECT_TRUE(res);
702     res = resSchedServiceStub_->OnRemoteRequest(
703         static_cast<uint32_t>(IResSchedServiceIpcCode::COMMAND_KILL_PROCESS), reply, reply, option);
704     EXPECT_TRUE(res);
705     res = resSchedServiceStub_->OnRemoteRequest(0, reply, reply, option);
706     EXPECT_TRUE(res);
707     res = resSchedServiceStub_->OnRemoteRequest(
708         static_cast<uint32_t>(IResSchedServiceIpcCode::COMMAND_REGISTER_SYSTEMLOAD_NOTIFIER), reply, reply, option);
709     EXPECT_TRUE(res);
710     res = resSchedServiceStub_->OnRemoteRequest(
711         static_cast<uint32_t>(IResSchedServiceIpcCode::COMMAND_UN_REGISTER_SYSTEMLOAD_NOTIFIER), reply, reply, option);
712     EXPECT_TRUE(res);
713     res = resSchedServiceStub_->OnRemoteRequest(
714         static_cast<uint32_t>(IResSchedServiceIpcCode::COMMAND_GET_SYSTEMLOAD_LEVEL), reply, reply, option);
715     EXPECT_TRUE(res);
716 }
717 
718 /**
719  * @tc.name: ResSchedServicesStub RemoteRequest 002
720  * @tc.desc: Test resschedstub RemoteRequest in multithreading.
721  * @tc.type: FUNC
722  * @tc.require: issueI7G8VT
723  * @tc.author: nizihao
724  */
725 HWTEST_F(ResSchedServiceTest, RemoteRequest002, Function | MediumTest | Level0)
726 {
727     SET_THREAD_NUM(10);
728     GTEST_RUN_TASK(RemoteRequestTask);
729 }
730 
731 /**
732  * @tc.name: Ressched service GetSystemLoadLevel debug 001
733  * @tc.desc: Test resschedService DumpSetSystemLoad Err Param Num
734  * @tc.type: FUNC
735  * @tc.require: issue#ICQCY1
736  * @tc.author: jiangfeng
737  */
738 HWTEST_F(ResSchedServiceTest, DumpDebugSystemLoad001, Function | MediumTest | Level0)
739 {
740     std::shared_ptr<ResSchedService> resSchedService_ = make_shared<ResSchedService>();
741     EXPECT_TRUE(resSchedService_ != nullptr);
742     sptr<IRemoteObject> notifier = new (std::nothrow) TestResSchedSystemloadListener();
743     EXPECT_TRUE(notifier != nullptr);
744     NotifierMgr::GetInstance().Init();
745     // Err Param Num
746     std::vector<std::string> args = {};
747     std::string result_;
748     resSchedService_->DumpSetSystemLoad(args, result_);
749     EXPECT_TRUE(result_.find("Err setSystemLoadLevel param num") != std::string::npos);
750 }
751 
752 /**
753  * @tc.name: Ressched service GetSystemLoadLevel debug 002
754  * @tc.desc: Test resschedService DumpSetSystemLoad Close Debug
755  * @tc.type: FUNC
756  * @tc.require: issue#ICQCY1
757  * @tc.author: jiangfeng
758  */
759 HWTEST_F(ResSchedServiceTest, DumpDebugSystemLoad002, Function | MediumTest | Level0)
760 {
761     std::shared_ptr<ResSchedService> resSchedService_ = make_shared<ResSchedService>();
762     EXPECT_TRUE(resSchedService_ != nullptr);
763     sptr<IRemoteObject> notifier = new (std::nothrow) TestResSchedSystemloadListener();
764     EXPECT_TRUE(notifier != nullptr);
765     NotifierMgr::GetInstance().Init();
766     // Close Debug
767     std::vector<std::string> args = {"0", "reset"};
768     std::string result_;
769     resSchedService_->DumpSetSystemLoad(args, result_);
770     EXPECT_FALSE(resSchedService_->systemLoadLevelDebugEnable_);
771     EXPECT_EQ(resSchedService_->debugSystemLoadLevel_, 0);
772 }
773 
774 /**
775  * @tc.name: Ressched service GetSystemLoadLevel debug 003
776  * @tc.desc: Test resschedService DumpSetSystemLoad over Maximum
777  * @tc.type: FUNC
778  * @tc.require: issue#ICQCY1
779  * @tc.author: jiangfeng
780  */
781 HWTEST_F(ResSchedServiceTest, DumpDebugSystemLoad003, Function | MediumTest | Level0)
782 {
783     std::shared_ptr<ResSchedService> resSchedService_ = make_shared<ResSchedService>();
784     EXPECT_TRUE(resSchedService_ != nullptr);
785     sptr<IRemoteObject> notifier = new (std::nothrow) TestResSchedSystemloadListener();
786     EXPECT_TRUE(notifier != nullptr);
787     NotifierMgr::GetInstance().Init();
788     // Close Debug
789     std::vector<std::string> args = {"0", "8"};
790     std::string result_;
791     resSchedService_->DumpSetSystemLoad(args, result_);
792     EXPECT_FALSE(resSchedService_->systemLoadLevelDebugEnable_);
793     EXPECT_EQ(resSchedService_->debugSystemLoadLevel_, 0);
794 }
795 
796 /**
797  * @tc.name: Ressched service GetSystemLoadLevel debug 004
798  * @tc.desc: Test resschedService DumpSetSystemLoad err num
799  * @tc.type: FUNC
800  * @tc.require: issue#ICQCY1
801  * @tc.author: jiangfeng
802  */
803 HWTEST_F(ResSchedServiceTest, DumpDebugSystemLoad004, Function | MediumTest | Level0)
804 {
805     std::shared_ptr<ResSchedService> resSchedService_ = make_shared<ResSchedService>();
806     EXPECT_TRUE(resSchedService_ != nullptr);
807     sptr<IRemoteObject> notifier = new (std::nothrow) TestResSchedSystemloadListener();
808     EXPECT_TRUE(notifier != nullptr);
809     NotifierMgr::GetInstance().Init();
810     // Close Debug
811     std::vector<std::string> args = {"0", "-2"};
812     std::string result_;
813     resSchedService_->DumpSetSystemLoad(args, result_);
814     EXPECT_FALSE(resSchedService_->systemLoadLevelDebugEnable_);
815     EXPECT_EQ(resSchedService_->debugSystemLoadLevel_, 0);
816 }
817 
818 /**
819  * @tc.name: Ressched service GetSystemLoadLevel debug 005
820  * @tc.desc: Test resschedService DumpSetSystemLoad valid value(3) and start debug
821  * @tc.type: FUNC
822  * @tc.require: issue#ICQCY1
823  * @tc.author: jiangfeng
824  */
825 HWTEST_F(ResSchedServiceTest, DumpDebugSystemLoad005, Function | MediumTest | Level0)
826 {
827     std::shared_ptr<ResSchedService> resSchedService_ = make_shared<ResSchedService>();
828     EXPECT_TRUE(resSchedService_ != nullptr);
829     sptr<IRemoteObject> notifier = new (std::nothrow) TestResSchedSystemloadListener();
830     EXPECT_TRUE(notifier != nullptr);
831     NotifierMgr::GetInstance().Init();
832     // Close Debug
833     std::vector<std::string> args = {"0", "3"};
834     std::string result_;
835     resSchedService_->DumpSetSystemLoad(args, result_);
836     EXPECT_TRUE(resSchedService_->systemLoadLevelDebugEnable_);
837     EXPECT_EQ(resSchedService_->debugSystemLoadLevel_, 3);
838 }
839 
840 /**
841  * @tc.name: Ressched service GetSystemLoadLevel debug 006
842  * @tc.desc: Test resschedService DumpSetSystemLoad reset
843  * @tc.type: FUNC
844  * @tc.require: issue#ICQCY1
845  * @tc.author: jiangfeng
846  */
847 HWTEST_F(ResSchedServiceTest, DumpDebugSystemLoad006, Function | MediumTest | Level0)
848 {
849     std::shared_ptr<ResSchedService> resSchedService_ = make_shared<ResSchedService>();
850     EXPECT_TRUE(resSchedService_ != nullptr);
851     sptr<IRemoteObject> notifier = new (std::nothrow) TestResSchedSystemloadListener();
852     EXPECT_TRUE(notifier != nullptr);
853     NotifierMgr::GetInstance().Init();
854     // Close Debug
855     std::vector<std::string> args = {"0", "reset"};
856     std::string result_;
857     resSchedService_->DumpSetSystemLoad(args, result_);
858     EXPECT_FALSE(resSchedService_->systemLoadLevelDebugEnable_);
859     EXPECT_EQ(resSchedService_->debugSystemLoadLevel_, 0);
860 }
861 
862 /**
863  * @tc.name: Ressched service GetSystemLoadLevel debug 007
864  * @tc.desc: Pass resschedService Dump func strToIntErr Branch
865  * @tc.type: FUNC
866  * @tc.require: issue#ICQCY1
867  * @tc.author: jiangfeng
868  */
869 HWTEST_F(ResSchedServiceTest, DumpDebugSystemLoad007, Function | MediumTest | Level0)
870 {
871     std::shared_ptr<ResSchedService> resSchedService_ = make_shared<ResSchedService>();
872     EXPECT_TRUE(resSchedService_ != nullptr);
873     sptr<IRemoteObject> notifier = new (std::nothrow) TestResSchedSystemloadListener();
874     EXPECT_TRUE(notifier != nullptr);
875     NotifierMgr::GetInstance().Init();
876 
877     std::vector<std::string> args = {"setSystemLoadLevel", "++"};
878     std::string result_;
879     resSchedService_->DumpSetSystemLoad(args, result_);
880     EXPECT_FALSE(resSchedService_->systemLoadLevelDebugEnable_);
881 }
882 
883 /**
884  * @tc.name: Ressched service OnDeviceLevelChanged Debug 001
885  * @tc.desc: Test OnDeviceLevelChanged when debugReport is false and debugEnable is close
886  * @tc.type: FUNC
887  * @tc.require: issue#ICQCY1
888  * @tc.author: jiangfeng
889  */
890 HWTEST_F(ResSchedServiceTest, OnDeviceLevelChangedDebug001, Function | MediumTest | Level0)
891 {
892     std::shared_ptr<ResSchedService> resSchedService_ = make_shared<ResSchedService>();
893     EXPECT_TRUE(resSchedService_ != nullptr);
894     sptr<IRemoteObject> notifier = new (std::nothrow) TestResSchedSystemloadListener();
895     EXPECT_TRUE(notifier != nullptr);
896     NotifierMgr::GetInstance().Init();
897     int32_t type = static_cast<int32_t>(ResType::DeviceStatus::SYSTEMLOAD_LEVEL);
898     int32_t level = 5;
899     bool debugReport = false;
900 
901     resSchedService_->OnDeviceLevelChanged(type, level, debugReport);
902 
903     EXPECT_EQ(resSchedService_->actualSystemLoadLevel_, level);
904     EXPECT_EQ(resSchedService_->debugSystemLoadLevel_, 0);
905     EXPECT_FALSE(resSchedService_->systemLoadLevelDebugEnable_);
906 }
907 
908 /**
909  * @tc.name: Ressched service OnDeviceLevelChanged Debug 002
910  * @tc.desc: Test OnDeviceLevelChanged when debugReport is false and debugEnable is open
911  * @tc.type: FUNC
912  * @tc.require: issue#ICQCY1
913  * @tc.author: jiangfeng
914  */
915 HWTEST_F(ResSchedServiceTest, OnDeviceLevelChangedDebug002, Function | MediumTest | Level0)
916 {
917     std::shared_ptr<ResSchedService> resSchedService_ = make_shared<ResSchedService>();
918     EXPECT_TRUE(resSchedService_ != nullptr);
919     sptr<IRemoteObject> notifier = new (std::nothrow) TestResSchedSystemloadListener();
920     EXPECT_TRUE(notifier != nullptr);
921     NotifierMgr::GetInstance().Init();
922     int32_t type = static_cast<int32_t>(ResType::DeviceStatus::SYSTEMLOAD_LEVEL);
923     int32_t level = 5;
924     bool debugReport = false;
925     resSchedService_->debugSystemLoadLevel_ = 3;
926     resSchedService_->systemLoadLevelDebugEnable_ = true;
927 
928     resSchedService_->OnDeviceLevelChanged(type, level, debugReport);
929 
930     EXPECT_EQ(resSchedService_->actualSystemLoadLevel_, level);
931     EXPECT_EQ(resSchedService_->debugSystemLoadLevel_, 3);
932     EXPECT_TRUE(resSchedService_->systemLoadLevelDebugEnable_);
933 }
934 
935 /**
936  * @tc.name: Ressched service OnDeviceLevelChanged Debug 003
937  * @tc.desc: Test OnDeviceLevelChanged when debugReport is TRUE and debugEnable is open
938  * @tc.type: FUNC
939  * @tc.require: issue#ICQCY1
940  * @tc.author: jiangfeng
941  */
942 HWTEST_F(ResSchedServiceTest, OnDeviceLevelChangedDebug003, Function | MediumTest | Level0)
943 {
944     std::shared_ptr<ResSchedService> resSchedService_ = make_shared<ResSchedService>();
945     EXPECT_TRUE(resSchedService_ != nullptr);
946     sptr<IRemoteObject> notifier = new (std::nothrow) TestResSchedSystemloadListener();
947     EXPECT_TRUE(notifier != nullptr);
948     NotifierMgr::GetInstance().Init();
949     int32_t type = static_cast<int32_t>(ResType::DeviceStatus::SYSTEMLOAD_LEVEL);
950     int32_t level = 5;
951     bool debugReport = true;
952     resSchedService_->debugSystemLoadLevel_ = 3;
953     resSchedService_->systemLoadLevelDebugEnable_ = true;
954     resSchedService_->OnDeviceLevelChanged(type, level, debugReport);
955 
956     EXPECT_EQ(resSchedService_->actualSystemLoadLevel_, 0); // if debugReport is true, cur variable will not change
957     EXPECT_EQ(resSchedService_->debugSystemLoadLevel_, 3);
958     EXPECT_TRUE(resSchedService_->systemLoadLevelDebugEnable_);
959 }
960 
961 /**
962  * @tc.name: Ressched service OnDeviceLevelChanged Debug 004
963  * @tc.desc: Test other level, Forward directly
964  * @tc.type: FUNC
965  * @tc.require: issue#ICQCY1
966  * @tc.author: jiangfeng
967  */
968 HWTEST_F(ResSchedServiceTest, OnDeviceLevelChangedDebug004, Function | MediumTest | Level0)
969 {
970     std::shared_ptr<ResSchedService> resSchedService_ = make_shared<ResSchedService>();
971     EXPECT_TRUE(resSchedService_ != nullptr);
972     sptr<IRemoteObject> notifier = new (std::nothrow) TestResSchedSystemloadListener();
973     EXPECT_TRUE(notifier != nullptr);
974     NotifierMgr::GetInstance().Init();
975     int32_t type = 100;
976     int32_t level = 5;
977     bool debugReport = false;
978 
979     resSchedService_->OnDeviceLevelChanged(type, level, debugReport);
980     EXPECT_EQ(resSchedService_->actualSystemLoadLevel_, 0); // if debugReport is true, cur variable will not change
981     EXPECT_EQ(resSchedService_->debugSystemLoadLevel_, 0);
982     EXPECT_FALSE(resSchedService_->systemLoadLevelDebugEnable_);
983 }
984 
985 /**
986  * @tc.name: Ressched service GetSystemLoadLevelDebug001
987  * @tc.desc: Test other level, Forward directly
988  * @tc.type: FUNC
989  * @tc.require: issue#ICQCY1
990  * @tc.author: jiangfeng
991  */
992 HWTEST_F(ResSchedServiceTest, GetSystemLoadLevelDebug001, Function | MediumTest | Level0)
993 {
994     std::shared_ptr<ResSchedService> resSchedService_ = make_shared<ResSchedService>();
995     EXPECT_TRUE(resSchedService_ != nullptr);
996     sptr<IRemoteObject> notifier = new (std::nothrow) TestResSchedSystemloadListener();
997     EXPECT_TRUE(notifier != nullptr);
998     NotifierMgr::GetInstance().Init();
999 
1000     resSchedService_->systemLoadLevelDebugEnable_ = true;
1001     resSchedService_->debugSystemLoadLevel_ = 2;
1002     int32_t resultValue = 0;
1003 
1004     resSchedService_->GetSystemloadLevel(resultValue);
1005     EXPECT_EQ(resSchedService_->debugSystemLoadLevel_, resultValue);
1006 }
1007 } // namespace ResourceSchedule
1008 } // namespace OHOS
1009