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 <dlfcn.h>
17 #include "plugin_mgr.h"
18 #include "res_type.h"
19 #include "plugin_mgr_test.h"
20 #include "socperf_plugin.h"
21 #include "mock_plugin_mgr.h"
22 #include "res_data.h"
23 #include "res_type.h"
24
25 using namespace std;
26 using namespace testing::ext;
27
28 namespace OHOS {
29 namespace ResourceSchedule {
30 namespace {
31 const string LIB_NAME = "libunittest_plugin.z.so";
32 }
33
SetUpTestCase()34 void PluginMgrTest::SetUpTestCase() {}
35
TearDownTestCase()36 void PluginMgrTest::TearDownTestCase() {}
37
SetUp()38 void PluginMgrTest::SetUp()
39 {
40 /**
41 * @tc.setup: initialize the member variable pluginMgr_
42 */
43 pluginMgr_ = make_shared<MockPluginMgr>();
44 }
45
TearDown()46 void PluginMgrTest::TearDown()
47 {
48 /**
49 * @tc.teardown: clear pluginMgr_
50 */
51 pluginMgr_ = nullptr;
52 }
53
GetSubItemValue(std::string PluginName,std::string configName)54 std::string PluginMgrTest::GetSubItemValue(std::string PluginName, std::string configName)
55 {
56 std::string subItemValue;
57 PluginConfig config = pluginMgr_->GetConfig(PluginName, configName);
58 if (config.itemList.size() <= 0) {
59 return "";
60 }
61 for (auto item : config.itemList) {
62 for (auto subItem : item.subItemList) {
63 if (subItem.name == "tag") {
64 subItemValue = subItem.value;
65 }
66 }
67 }
68 return subItemValue;
69 }
70
71 /**
72 * @tc.name: Plugin mgr test Init 001
73 * @tc.desc: Verify if can init success.
74 * @tc.type: FUNC
75 * @tc.require: issueI798UT
76 * @tc.author:xukuan
77 */
78 HWTEST_F(PluginMgrTest, Init001, TestSize.Level1)
79 {
80 pluginMgr_->Init();
81 EXPECT_TRUE(pluginMgr_->initStatus == pluginMgr_->INIT_SUCCESS);
82 EXPECT_EQ(pluginMgr_->pluginLibMap_.size(), 0);
83 }
84
85 /**
86 * @tc.name: Plugin mgr test Init 002
87 * @tc.desc: Verify if can init fault.
88 * @tc.type: FUNC
89 * @tc.require: issueI8VZVN
90 * @tc.author:z30053169
91 */
92 HWTEST_F(PluginMgrTest, Init002, TestSize.Level1)
93 {
94 PluginMgr::GetInstance().pluginSwitch_ = nullptr;
95 pluginMgr_->Init();
96 SUCCEED();
97 }
98
99 /**
100 * @tc.name: Plugin mgr test GetPluginSwitch 001
101 * @tc.desc: Verify if can get pluginSwitch
102 * @tc.type: FUNC
103 * @tc.require: issuesIA7P80
104 * @tc.author:xiaoshun
105 */
106 HWTEST_F(PluginMgrTest, GetPluginSwitch001, TestSize.Level0)
107 {
108 pluginMgr_->Init();
109 auto pluginInfoList = pluginMgr_->pluginSwitch_->GetPluginSwitch();
110 bool result;
111 for (auto pluginInfo : pluginInfoList) {
112 if (pluginInfo.libPath == "libapp_preload_plugin.z.so") {
113 EXPECT_TRUE(pluginInfo.switchOn);
114 } else if (pluginInfo.libPath == "libapp_preload_plugin2.z.so" ||
115 pluginInfo.libPath == "libapp_preload_plugin3.z.so" ||
116 pluginInfo.libPath == "libapp_preload_plugin4.z.so") {
117 EXPECT_TRUE(!pluginInfo.switchOn);
118 }
119 }
120 }
121
122 /**
123 * @tc.name: Plugin mgr test Stop 001
124 * @tc.desc: Verify if can stop success.
125 * @tc.type: FUNC
126 * @tc.require: issueI798UT
127 * @tc.author:xukuan
128 */
129 HWTEST_F(PluginMgrTest, Stop001, TestSize.Level1)
130 {
131 pluginMgr_->Stop();
132 EXPECT_EQ(pluginMgr_->pluginLibMap_.size(), 0);
133 EXPECT_EQ(pluginMgr_->resTypeLibMap_.size(), 0);
134 EXPECT_TRUE(pluginMgr_->configReader_ == nullptr);
135 }
136
137 /**
138 * @tc.name: Plugin mgr test GetConfig 001
139 * @tc.desc: Verify if can get config with wrong env.
140 * @tc.type: FUNC
141 * @tc.require: issueI5WWV3
142 * @tc.author:lice
143 */
144 HWTEST_F(PluginMgrTest, GetConfig001, TestSize.Level1)
145 {
146 PluginConfig config = pluginMgr_->GetConfig("", "");
147 EXPECT_TRUE(config.itemList.empty());
148 }
149
150 /**
151 * @tc.name: Plugin mgr test GetConfig 002
152 * @tc.desc: Verify if can get config with wrong env.
153 * @tc.type: FUNC
154 * @tc.require: issuesIA7P80
155 * @tc.author:lice
156 */
157 HWTEST_F(PluginMgrTest, GetConfig002, TestSize.Level1)
158 {
159 pluginMgr_->Init();
160 std::string subItemValue = GetSubItemValue("demo2", "sample");
161 bool ret = !subItemValue.empty() && subItemValue == "test_sys_prod";
162 EXPECT_TRUE(ret);
163 subItemValue = GetSubItemValue("demo3", "sample");
164 ret = !subItemValue.empty() && subItemValue == "test_sys_prod";
165 EXPECT_TRUE(ret);
166 subItemValue = GetSubItemValue("demo4", "sample");
167 ret = !subItemValue.empty() && subItemValue == "test_system";
168 EXPECT_TRUE(ret);
169 }
170
171 /**
172 * @tc.name: Plugin mgr test GetConfig 003
173 * @tc.desc: Verify if can get config with wrong env.
174 * @tc.type: FUNC
175 * @tc.require: issueI8VZVN
176 * @tc.author:z30053169
177 */
178 HWTEST_F(PluginMgrTest, GetConfig003, TestSize.Level1)
179 {
180 PluginMgr::GetInstance().configReader_ = nullptr;
181 PluginConfig config = pluginMgr_->GetConfig("", "");
182 SUCCEED();
183 }
184
185 /**
186 * @tc.name: Plugin mgr test SubscribeResource 002
187 * @tc.desc: Verify if can SubscribeResource
188 * @tc.type: FUNC
189 * @tc.require: issueI8VZVN
190 * @tc.author:z30053169
191 */
192 HWTEST_F(PluginMgrTest, SubscribeResource002, TestSize.Level1)
193 {
194 PluginMgr::GetInstance().SubscribeResource("", 0);
195 SUCCEED();
196 PluginMgr::GetInstance().SubscribeResource("test", 1);
197 SUCCEED();
198 PluginMgr::GetInstance().UnSubscribeResource("test", 1);
199 SUCCEED();
200 }
201
202 /**
203 * @tc.name: Plugin mgr test UnSubscribeResource 003
204 * @tc.desc: Verify if can SubscribeResource
205 * @tc.type: FUNC
206 * @tc.require: issueI8VZVN
207 * @tc.author:z30053169
208 */
209 HWTEST_F(PluginMgrTest, UnSubscribeResource003, TestSize.Level1)
210 {
211 PluginMgr::GetInstance().UnSubscribeResource("", 0);
212 SUCCEED();
213 PluginMgr::GetInstance().UnSubscribeResource("test", 0);
214 SUCCEED();
215 PluginMgr::GetInstance().SubscribeResource("test1", 1);
216 PluginMgr::GetInstance().SubscribeResource("test2", 1);
217 PluginMgr::GetInstance().UnSubscribeResource("test1", 1);
218 SUCCEED();
219 PluginMgr::GetInstance().UnSubscribeResource("test2", 1);
220 SUCCEED();
221 }
222
223 /**
224 * @tc.name: Plugin mgr test DispatchResource 001
225 * @tc.desc: Verify if can DispatchResource
226 * @tc.type: FUNC
227 * @tc.require: issueI8VZVN
228 * @tc.author:z30053169
229 */
230 HWTEST_F(PluginMgrTest, DispatchResource001, TestSize.Level1)
231 {
232 pluginMgr_->Init();
233 if (pluginMgr_->dispatcher_ == nullptr) {
234 pluginMgr_->dispatcher_ = std::make_shared<AppExecFwk::EventHandler>(
235 AppExecFwk::EventRunner::Create("rssDispatcher"));
236 }
237 nlohmann::json payload;
238 auto data = std::make_shared<ResData>(ResType::RES_TYPE_APP_ABILITY_START,
239 ResType::AppStartType::APP_COLD_START, payload);
240 pluginMgr_->DispatchResource(data);
241 pluginMgr_->DispatchResource(nullptr);
242 SUCCEED();
243 }
244
245 /**
246 * @tc.name: Plugin mgr test DispatchResource 002
247 * @tc.desc: Verify if can DispatchResource
248 * @tc.type: FUNC
249 * @tc.require: issueI8VZVN
250 * @tc.author:z30053169
251 */
252 HWTEST_F(PluginMgrTest, DispatchResource002, TestSize.Level1)
253 {
254 if (PluginMgr::GetInstance().dispatcher_ == nullptr) {
255 PluginMgr::GetInstance().dispatcher_ = std::make_shared<AppExecFwk::EventHandler>(
256 AppExecFwk::EventRunner::Create("rssDispatcher"));
257 }
258 nlohmann::json payload;
259 auto data = std::make_shared<ResData>(ResType::RES_TYPE_APP_ABILITY_START,
260 ResType::AppStartType::APP_COLD_START, payload);
261 PluginMgr::GetInstance().SubscribeResource("", 0);
262 SUCCEED();
263 PluginMgr::GetInstance().SubscribeResource("test", ResType::RES_TYPE_APP_ABILITY_START);
264 SUCCEED();
265 PluginMgr::GetInstance().DispatchResource(data);
266 PluginMgr::GetInstance().UnSubscribeResource("", 0);
267 SUCCEED();
268 }
269
270 /**
271 * @tc.name: Plugin mgr test SubscribeResource 001
272 * @tc.desc: Verify if can stop success.
273 * @tc.type: FUNC
274 * @tc.require: issueI798UT
275 * @tc.author:xukuan
276 */
277 HWTEST_F(PluginMgrTest, SubscribeResource001, TestSize.Level1)
278 {
279 pluginMgr_->Init();
280 pluginMgr_->SubscribeResource(LIB_NAME, ResType::RES_TYPE_SCREEN_STATUS);
281 auto iter = pluginMgr_->resTypeLibMap_.find(ResType::RES_TYPE_SCREEN_STATUS);
282 string libName = iter->second.back();
283 EXPECT_EQ(libName.compare(LIB_NAME), 0);
284 }
285
286 /**
287 * @tc.name: Plugin mgr test Dump 001
288 * @tc.desc: Verify if dump commands is success.
289 * @tc.type: FUNC
290 * @tc.require: issueI5WWV3
291 * @tc.author:lice
292 */
293 HWTEST_F(PluginMgrTest, Dump001, TestSize.Level1)
294 {
295 std::string res;
296 pluginMgr_->Init();
297 pluginMgr_->DumpAllPlugin(res);
298 EXPECT_TRUE(!res.empty());
299 res = "";
300
301 pluginMgr_->LoadPlugin();
302 pluginMgr_->DumpHelpFromPlugin(res);
303 EXPECT_TRUE(res.empty());
304 res = "";
305
306 std::vector<std::string> args;
307 pluginMgr_->DumpOnePlugin(res, LIB_NAME, args);
308 EXPECT_TRUE(!res.empty());
309 res = "";
310
311 args.emplace_back("-h");
312 pluginMgr_->DumpOnePlugin(res, LIB_NAME, args);
313 EXPECT_TRUE(!res.empty());
314 res = "";
315 pluginMgr_->DumpAllPluginConfig(res);
316 EXPECT_TRUE(!res.empty());
317 }
318
319 /**
320 * @tc.name: Plugin mgr test RepairPlugin 001
321 * @tc.desc: Verify if RepairPlugin is success.
322 * @tc.type: FUNC
323 * @tc.require: issueI5WWV3
324 * @tc.author:lice
325 */
326 HWTEST_F(PluginMgrTest, RepairPlugin001, TestSize.Level1)
327 {
328 PluginLib libInfo = pluginMgr_->pluginLibMap_.find(LIB_NAME)->second;
329 pluginMgr_->RepairPlugin(Clock::now(), LIB_NAME, libInfo);
330 EXPECT_TRUE(true);
331 }
332
333 /**
334 * @tc.name: Plugin mgr test UnSubscribeResource 001
335 * @tc.desc: Verify if can stop success.
336 * @tc.type: FUNC
337 * @tc.require: issueI798UT
338 * @tc.author:xukuan
339 */
340 HWTEST_F(PluginMgrTest, UnSubscribeResource001, TestSize.Level1)
341 {
342 pluginMgr_->UnSubscribeResource(LIB_NAME, ResType::RES_TYPE_SCREEN_STATUS);
343 auto iter = pluginMgr_->resTypeLibMap_.find(ResType::RES_TYPE_SCREEN_STATUS);
344 EXPECT_TRUE(iter == pluginMgr_->resTypeLibMap_.end());
345 }
346
347 /*
348 * @tc.name: SocPerfSubTest_DispatchResource_001
349 * @tc.desc: DispatchResource Plugin
350 * @tc.type FUNC
351 * @tc.author:zoujie
352 * @tc.require: issueI5VWUI
353 */
354 HWTEST_F(PluginMgrTest, PluginMgrTest_DispatchResource_001, TestSize.Level1)
355 {
356 nlohmann::json payload;
357 auto data = std::make_shared<ResData>(ResType::RES_TYPE_APP_ABILITY_START,
358 ResType::AppStartType::APP_COLD_START, payload);
359 /* Init */
360 SocPerfPlugin::GetInstance().Init();
361 /* HandleAppAbilityStart */
362 SocPerfPlugin::GetInstance().DispatchResource(data);
363
364 data->value = ResType::AppStartType::APP_WARM_START;
365 SocPerfPlugin::GetInstance().DispatchResource(data);
366
367 /* HandleWindowFocus */
368 data->resType = ResType::RES_TYPE_WINDOW_FOCUS;
369 data->value = ResType::WindowFocusStatus::WINDOW_FOCUS;
370 SocPerfPlugin::GetInstance().DispatchResource(data);
371
372 /* HandleEventClick */
373 data->resType = ResType::RES_TYPE_CLICK_RECOGNIZE;
374 data->value = ResType::ClickEventType::TOUCH_EVENT_DOWN;
375 SocPerfPlugin::GetInstance().DispatchResource(data);
376 data->value = ResType::ClickEventType::TOUCH_EVENT_UP;
377 SocPerfPlugin::GetInstance().DispatchResource(data);
378 data->value = ResType::ClickEventType::CLICK_EVENT;
379 SocPerfPlugin::GetInstance().DispatchResource(data);
380
381 /* HandlePushPage */
382 data->resType = ResType::RES_TYPE_PUSH_PAGE;
383 data->value = ResType::PushPageType::PUSH_PAGE_START;
384 SocPerfPlugin::GetInstance().DispatchResource(data);
385 data->value = ResType::PushPageType::PUSH_PAGE_COMPLETE;
386 SocPerfPlugin::GetInstance().DispatchResource(data);
387
388 /* HandlePopPage */
389 data->resType = ResType::RES_TYPE_POP_PAGE;
390 data->value = 0;
391 SocPerfPlugin::GetInstance().DispatchResource(data);
392
393 /* HandleEventSlide */
394 data->resType = ResType::RES_TYPE_SLIDE_RECOGNIZE;
395 data->value = ResType::SlideEventStatus::SLIDE_EVENT_ON;
396 SocPerfPlugin::GetInstance().DispatchResource(data);
397 data->value = ResType::SlideEventStatus::SLIDE_EVENT_OFF;
398 SocPerfPlugin::GetInstance().DispatchResource(data);
399
400 /* HandleEventWebGesture */
401 data->resType = ResType::RES_TYPE_WEB_GESTURE;
402 data->value = 0;
403 SocPerfPlugin::GetInstance().DispatchResource(data);
404
405 /* HandleResizeWindow */
406 data->resType = ResType::RES_TYPE_RESIZE_WINDOW;
407 data->value = ResType::WindowResizeType::WINDOW_RESIZING;
408 SocPerfPlugin::GetInstance().DispatchResource(data);
409 data->value = ResType::WindowResizeType::WINDOW_RESIZE_STOP;
410 SocPerfPlugin::GetInstance().DispatchResource(data);
411
412 /* HandleMoveWindow */
413 data->resType = ResType::RES_TYPE_MOVE_WINDOW;
414 data->value = ResType::WindowMoveType::WINDOW_MOVING;
415 SocPerfPlugin::GetInstance().DispatchResource(data);
416 data->value = ResType::WindowMoveType::WINDOW_MOVE_STOP;
417 SocPerfPlugin::GetInstance().DispatchResource(data);
418
419 /* DeInit */
420 SocPerfPlugin::GetInstance().Disable();
421 SUCCEED();
422 }
423
424 /*
425 * @tc.name: SocPerfSubTest_DispatchResource_002
426 * @tc.desc: DispatchResource Plugin
427 * @tc.type FUNC
428 * @tc.author:qiunaiguang
429 * @tc.require: issueI6I9QS
430 */
431 HWTEST_F(PluginMgrTest, PluginMgrTest_DispatchResource_002, Function | MediumTest | Level0)
432 {
433 /* Init */
434 SocPerfPlugin::GetInstance().Init();
435
436 nlohmann::json payload;
437 std::shared_ptr<ResData> resData =
438 std::make_shared<ResData>(ResType::RES_TYPE_LOAD_PAGE, ResType::LoadPageType::LOAD_PAGE_START, payload);
439 SocPerfPlugin::GetInstance().HandleLoadPage(resData);
440 resData->value = ResType::LoadPageType::LOAD_PAGE_COMPLETE;
441 SocPerfPlugin::GetInstance().HandleLoadPage(resData);
442 /* DeInit */
443 SocPerfPlugin::GetInstance().Disable();
444 SUCCEED();
445 }
446
447 /*
448 * @tc.name: SocPerfSubTest_DispatchResource_003
449 * @tc.desc: DispatchResource Plugin
450 * @tc.type FUNC
451 * @tc.author:qiunaiguang
452 * @tc.require: issueI6I9QS
453 */
454 HWTEST_F(PluginMgrTest, PluginMgrTest_DispatchResource_003, Function | MediumTest | Level0)
455 {
456 /* Init */
457 SocPerfPlugin::GetInstance().Init();
458 nlohmann::json payload;
459 std::shared_ptr<ResData> resData =
460 std::make_shared<ResData>(ResType::RES_TYPE_SHOW_REMOTE_ANIMATION,
461 ResType::ShowRemoteAnimationStatus::ANIMATION_BEGIN, payload);
462 SocPerfPlugin::GetInstance().HandleRemoteAnimation(resData);
463
464 resData->value = ResType::ShowRemoteAnimationStatus::ANIMATION_END;
465 SocPerfPlugin::GetInstance().HandleRemoteAnimation(resData);
466 /* DeInit */
467 SocPerfPlugin::GetInstance().Disable();
468 SUCCEED();
469 }
470
471 /*
472 * @tc.name: SocPerfSubTest_DispatchResource_004
473 * @tc.desc: DispatchResource Plugin
474 * @tc.type FUNC
475 * @tc.author:qiunaiguang
476 * @tc.require: issueI6I9QS
477 */
478 HWTEST_F(PluginMgrTest, PluginMgrTest_DispatchResource_004, Function | MediumTest | Level0)
479 {
480 /* Init */
481 SocPerfPlugin::GetInstance().Init();
482 SocPerfPlugin::GetInstance().InitFeatureSwitch("socperf_on_demand");
483 SocPerfPlugin::GetInstance().InitFeatureSwitch("test");
484 /* DeInit */
485 SocPerfPlugin::GetInstance().Disable();
486 SUCCEED();
487 }
488
489 /*
490 * @tc.name: SocPerfSubTest_DispatchResource_005
491 * @tc.desc: DispatchResource Plugin
492 * @tc.type FUNC
493 * @tc.author:fangdinggeng
494 * @tc.require: issueI5VWUI
495 */
496 HWTEST_F(PluginMgrTest, PluginMgrTest_DispatchResource_005, TestSize.Level1)
497 {
498 nlohmann::json payload;
499 auto data = std::make_shared<ResData>(ResType::RES_TYPE_DEVICE_MODE_STATUS,
500 ResType::DeviceModeStatus::MODE_ENTER, payload);
501 /* Init */
502 SocPerfPlugin::GetInstance().Init();
503
504 /* HandleDeviceModeStatusChange */
505 data->payload["deviceMode"] = "test";
506 SocPerfPlugin::GetInstance().DispatchResource(data);
507 data->value = ResType::DeviceModeStatus::MODE_QUIT;
508 SocPerfPlugin::GetInstance().DispatchResource(data);
509
510 /* DeInit */
511 SocPerfPlugin::GetInstance().Disable();
512 SUCCEED();
513 }
514
515 /**
516 * @tc.name: Plugin mgr test DumPluginInfoAppend_001
517 * @tc.desc: test the interface DumpluginInfoAppend
518 * @tc.type: FUNC
519 * @tc.require: issueI8VZVN
520 * @tc.author:z30053169
521 */
522 HWTEST_F(PluginMgrTest, DumPluginInfoAppend_001, TestSize.Level1)
523 {
524 string result;
525 PluginInfo info;
526 info.switchOn = false;
527 PluginMgr::GetInstance().DumpPluginInfoAppend(result, info);
528 SUCCEED();
529 }
530
531 /**
532 * @tc.name: Plugin mgr test DispatchResource 003
533 * @tc.desc: test the interface DispatchResource
534 * @tc.type: FUNC
535 * @tc.require: issueI8VZVN
536 * @tc.author:z30053169
537 */
538 HWTEST_F(PluginMgrTest, DispatchResource003, TestSize.Level1)
539 {
540 nlohmann::json payload;
541 PluginMgr::GetInstance().dispatcher_ = nullptr;
542 auto data = std::make_shared<ResData>(ResType::RES_TYPE_APP_ABILITY_START,
543 ResType::AppStartType::APP_COLD_START, payload);
544 PluginMgr::GetInstance().UnSubscribeResource("test", ResType::RES_TYPE_APP_ABILITY_START);
545 PluginMgr::GetInstance().DispatchResource(data);
546 SUCCEED();
547 }
548
549 /**
550 * @tc.name: Plugin mgr test DispatchResource 004
551 * @tc.desc: Verify if can DispatchResource
552 * @tc.type: FUNC
553 * @tc.require: issueI91HSR
554 * @tc.author:baiheng
555 */
556 HWTEST_F(PluginMgrTest, DispatchResource004, TestSize.Level1)
557 {
558 nlohmann::json payload;
559 auto dataNoExtType = std::make_shared<ResData>(ResType::RES_TYPE_KEY_PERF_SCENE,
560 ResType::KeyPerfStatus::ENTER_SCENE, payload);
561 PluginMgr::GetInstance().SubscribeResource("test", 10000);
562 SUCCEED();
563 PluginMgr::GetInstance().DispatchResource(dataNoExtType);
564 SUCCEED();
565 }
566
567 /**
568 * @tc.name: Plugin mgr test DispatchResource 005
569 * @tc.desc: Verify if can DispatchResource
570 * @tc.type: FUNC
571 * @tc.require: issueI91HSR
572 * @tc.author:baiheng
573 */
574 HWTEST_F(PluginMgrTest, DispatchResource005, TestSize.Level1)
575 {
576 nlohmann::json payload;
577 payload["extType"] = "10000";
578 auto dataWithExtType = std::make_shared<ResData>(ResType::RES_TYPE_KEY_PERF_SCENE,
579 ResType::KeyPerfStatus::ENTER_SCENE, payload);
580 PluginMgr::GetInstance().SubscribeResource("test", 10000);
581 SUCCEED();
582 PluginMgr::GetInstance().DispatchResource(dataWithExtType);
583 SUCCEED();
584 }
585
586 /**
587 * @tc.name: Plugin mgr test GetPluginLib 001
588 * @tc.desc: Verify if can get pluginlib with wrong env.
589 * @tc.type: FUNC
590 * @tc.require: issueI9C9JN
591 * @tc.author:xiaoshun
592 */
593 HWTEST_F(PluginMgrTest, GetPluginLib001, TestSize.Level0)
594 {
595 std::shared_ptr<PluginLib> libInfoPtr = pluginMgr_->GetPluginLib("test");
596 EXPECT_TRUE(libInfoPtr == nullptr);
597 }
598
599 /**
600 * @tc.name: Plugin mgr test GetPluginLib 002
601 * @tc.desc: Verify if can get pluginlib
602 * @tc.type: FUNC
603 * @tc.require: issueI9C9JN
604 * @tc.author:xiaoshun
605 */
606 HWTEST_F(PluginMgrTest, GetPluginLib002, TestSize.Level0)
607 {
608 std::shared_ptr<PluginLib> libInfoPtr = pluginMgr_->GetPluginLib("libapp_preload_plugin.z.so");
609 SUCCEED();
610 }
611
612 /**
613 * @tc.name: Plugin mgr test InnerTimeUtil 001
614 * @tc.desc: InnerTimeUtil
615 * @tc.type: FUNC
616 * @tc.require: issueI9C9JN
617 * @tc.author:luolu
618 */
619 HWTEST_F(PluginMgrTest, InnerTimeUtil001, TestSize.Level0)
620 {
621 PluginMgr::InnerTimeUtil innerTimeUtil("test1", "test2");
622 }
623
624 /**
625 * @tc.name: Plugin mgr test LoadPlugin 001
626 * @tc.desc: LoadPlugin
627 * @tc.type: FUNC
628 * @tc.require: issueI9C9JN
629 * @tc.author:luolu
630 */
631 HWTEST_F(PluginMgrTest, LoadPlugin001, TestSize.Level0)
632 {
633 PluginMgr::GetInstance().LoadPlugin();
634 }
635
636 /**
637 * @tc.name: Plugin mgr test SubscribeSyncResource 002
638 * @tc.desc: SubscribeSyncResource
639 * @tc.type: FUNC
640 * @tc.require: issueI9C9JN
641 * @tc.author:luolu
642 */
643 HWTEST_F(PluginMgrTest, SubscribeSyncResource002, TestSize.Level0)
644 {
645 std::string pluginLib;
646 uint32_t resType = 0;
647 PluginMgr::GetInstance().SubscribeSyncResource(pluginLib, resType);
648 PluginMgr::GetInstance().UnSubscribeSyncResource(pluginLib, resType);
649 }
650
651 /**
652 * @tc.name: Plugin mgr test GetConfigReaderStr 001
653 * @tc.desc: Verify if can get ConfigReaderStr.
654 * @tc.type: FUNC
655 */
656 HWTEST_F(PluginMgrTest, GetConfigReaderStr001, TestSize.Level0)
657 {
658 auto configStr = pluginMgr_->GetConfigReaderStr();
659 EXPECT_TRUE(!configStr.empty());
660 }
661
662 /**
663 * @tc.name: Plugin mgr test GetPluginSwitchStr 001
664 * @tc.desc: Verify if can get PluginSwitchStr.
665 * @tc.type: FUNC
666 */
667 HWTEST_F(PluginMgrTest, GetPluginSwitchStr001, TestSize.Level0)
668 {
669 auto switchStr = pluginMgr_->GetPluginSwitchStr();
670 EXPECT_TRUE(!switchStr.empty());
671 }
672
673 /**
674 * @tc.name: Plugin mgr test ParseConfigReader 001
675 * @tc.desc: Verify if can Parse ConfigReader.
676 * @tc.type: FUNC
677 */
678 HWTEST_F(PluginMgrTest, ParseConfigReader001, TestSize.Level0)
679 {
680 pluginMgr_->Init();
681 auto configStrs = pluginMgr_->GetConfigReaderStr();
682 pluginMgr_->ParseConfigReader(configStrs);
683 SUCCEED();
684 }
685
686 /**
687 * @tc.name: Plugin mgr test ParsePluginSwitch 001
688 * @tc.desc: Verify if can Parse PluginSwitch.
689 * @tc.type: FUNC
690 */
691 HWTEST_F(PluginMgrTest, ParsePluginSwitchr001, TestSize.Level0)
692 {
693 pluginMgr_->Init();
694 auto switchStrs = pluginMgr_->GetPluginSwitchStr();
695 pluginMgr_->ParsePluginSwitch(switchStrs);
696 SUCCEED();
697 }
698 } // namespace ResourceSchedule
699 } // namespace OHOS
700