• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 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 <cstdlib>
17 #include <gtest/gtest.h>
18 
19 #define private public
20 #include "app_launch_data.h"
21 #include "main_thread.h"
22 #include "ohos_application.h"
23 #undef private
24 
25 #include "hilog_wrapper.h"
26 #include "if_system_ability_manager.h"
27 #include "iservice_registry.h"
28 #include "mock_bundle_manager.h"
29 #include "process_info.h"
30 #include "quick_fix_callback_stub.h"
31 #include "system_ability_definition.h"
32 #include "sys_mgr_client.h"
33 
34 using namespace testing;
35 using namespace testing::ext;
36 
37 namespace OHOS {
38 namespace AppExecFwk {
39 class QuickFixCallbackImpl : public AppExecFwk::QuickFixCallbackStub {
40 public:
41     QuickFixCallbackImpl() = default;
42     virtual ~QuickFixCallbackImpl() = default;
43 
OnLoadPatchDone(int32_t resultCode,int32_t recordId)44     void OnLoadPatchDone(int32_t resultCode, int32_t recordId) override
45     {
46         HILOG_DEBUG("function called.");
47     }
48 
OnUnloadPatchDone(int32_t resultCode,int32_t recordId)49     void OnUnloadPatchDone(int32_t resultCode, int32_t recordId) override
50     {
51         HILOG_DEBUG("function called.");
52     }
53 
OnReloadPageDone(int32_t resultCode,int32_t recordId)54     void OnReloadPageDone(int32_t resultCode, int32_t recordId) override
55     {
56         HILOG_DEBUG("function called.");
57     }
58 };
59 
60 class MainThreadTest : public testing::Test {
61 public:
62     static void SetUpTestCase();
63     static void TearDownTestCase();
64     void SetUp() override;
65     void TearDown() override;
66 
67     sptr<MainThread> mainThread_ = nullptr;
68 };
69 
SetUpTestCase()70 void MainThreadTest::SetUpTestCase()
71 {
72     sptr<IRemoteObject> bundleObject = new (std::nothrow) BundleMgrService();
73     auto sysMgr = DelayedSingleton<SysMrgClient>::GetInstance();
74     if (sysMgr == nullptr) {
75         GTEST_LOG_(ERROR) << "Failed to get ISystemAbilityManager.";
76         return;
77     }
78 
79     sysMgr->RegisterSystemAbility(BUNDLE_MGR_SERVICE_SYS_ABILITY_ID, bundleObject);
80 }
81 
TearDownTestCase()82 void MainThreadTest::TearDownTestCase()
83 {}
84 
SetUp()85 void MainThreadTest::SetUp()
86 {
87     std::shared_ptr<EventRunner> runner = EventRunner::GetMainEventRunner();
88     ASSERT_NE(runner, nullptr);
89 
90     mainThread_ = sptr<MainThread>(new (std::nothrow) MainThread());
91     ASSERT_NE(mainThread_, nullptr);
92 
93     mainThread_->Init(runner);
94 }
95 
TearDown()96 void MainThreadTest::TearDown()
97 {}
98 
99 /*
100  * Feature: MainThread
101  * Function: GetMainThreadState
102  * SubFunction: NA
103  * FunctionPoints: MainThread GetMainThreadState
104  * EnvConditions: NA
105  * CaseDescription: Verify GetMainThreadState
106  */
107 HWTEST_F(MainThreadTest, GetMainThreadState_0100, TestSize.Level1)
108 {
109     HILOG_INFO("%{public}s start.", __func__);
110     EXPECT_EQ(mainThread_->GetMainThreadState(), MainThreadState::INIT);
111     HILOG_INFO("%{public}s end.", __func__);
112 }
113 
114 /*
115  * Feature: MainThread
116  * Function: SetRunnerStarted
117  * SubFunction: NA
118  * FunctionPoints: MainThread SetRunnerStarted
119  * EnvConditions: NA
120  * CaseDescription: Verify SetRunnerStarted
121  */
122 HWTEST_F(MainThreadTest, SetRunnerStarted_0100, TestSize.Level1)
123 {
124     HILOG_INFO("%{public}s start.", __func__);
125     mainThread_->SetRunnerStarted(true);
126     EXPECT_TRUE(mainThread_->isRunnerStarted_);
127     HILOG_INFO("%{public}s end.", __func__);
128 }
129 
130 /*
131  * Feature: MainThread
132  * Function: GetRunnerStarted
133  * SubFunction: NA
134  * FunctionPoints: MainThread GetRunnerStarted
135  * EnvConditions: NA
136  * CaseDescription: Verify GetRunnerStarted
137  */
138 HWTEST_F(MainThreadTest, GetRunnerStarted_0100, TestSize.Level1)
139 {
140     HILOG_INFO("%{public}s start.", __func__);
141     EXPECT_FALSE(mainThread_->GetRunnerStarted());
142     HILOG_INFO("%{public}s end.", __func__);
143 }
144 
145 /*
146  * Feature: MainThread
147  * Function: GetNewThreadId
148  * SubFunction: NA
149  * FunctionPoints: MainThread GetNewThreadId
150  * EnvConditions: NA
151  * CaseDescription: Verify GetNewThreadId
152  */
153 HWTEST_F(MainThreadTest, GetNewThreadId_0100, TestSize.Level1)
154 {
155     HILOG_INFO("%{public}s start.", __func__);
156     EXPECT_EQ(mainThread_->GetNewThreadId(), -1);
157     HILOG_INFO("%{public}s end.", __func__);
158 }
159 
160 /*
161  * Feature: MainThread
162  * Function: GetApplication
163  * SubFunction: NA
164  * FunctionPoints: MainThread GetApplication
165  * EnvConditions: NA
166  * CaseDescription: Verify GetApplication
167  */
168 HWTEST_F(MainThreadTest, GetApplication_0100, TestSize.Level1)
169 {
170     HILOG_INFO("%{public}s start.", __func__);
171     EXPECT_EQ(mainThread_->GetApplication(), nullptr);
172     HILOG_INFO("%{public}s end.", __func__);
173 }
174 
175 /*
176  * Feature: MainThread
177  * Function: GetApplicationInfo
178  * SubFunction: NA
179  * FunctionPoints: MainThread GetApplicationInfo
180  * EnvConditions: NA
181  * CaseDescription: Verify GetApplicationInfo
182  */
183 HWTEST_F(MainThreadTest, GetApplicationInfo_0100, TestSize.Level1)
184 {
185     HILOG_INFO("%{public}s start.", __func__);
186     EXPECT_EQ(mainThread_->GetApplicationInfo(), nullptr);
187     HILOG_INFO("%{public}s end.", __func__);
188 }
189 
190 /*
191  * Feature: MainThread
192  * Function: GetApplicationImpl
193  * SubFunction: NA
194  * FunctionPoints: MainThread GetApplicationImpl
195  * EnvConditions: NA
196  * CaseDescription: Verify GetApplicationImpl
197  */
198 HWTEST_F(MainThreadTest, GetApplicationImpl_0100, TestSize.Level1)
199 {
200     HILOG_INFO("%{public}s start.", __func__);
201     EXPECT_EQ(mainThread_->GetApplicationImpl(), nullptr);
202     HILOG_INFO("%{public}s end.", __func__);
203 }
204 
205 /*
206  * Feature: MainThread
207  * Function: GetMainHandler
208  * SubFunction: NA
209  * FunctionPoints: MainThread GetMainHandler
210  * EnvConditions: NA
211  * CaseDescription: Verify GetMainHandler
212  */
213 HWTEST_F(MainThreadTest, GetMainHandler_0100, TestSize.Level1)
214 {
215     HILOG_INFO("%{public}s start.", __func__);
216     EXPECT_NE(mainThread_->GetMainHandler(), nullptr);
217     mainThread_->ScheduleForegroundApplication();
218     mainThread_->ScheduleBackgroundApplication();
219     mainThread_->ScheduleTerminateApplication();
220     mainThread_->ScheduleShrinkMemory(1);
221     mainThread_->ScheduleMemoryLevel(1);
222     mainThread_->ScheduleProcessSecurityExit();
223     mainThread_->ScheduleLowMemory();
224     AppLaunchData data;
225     Configuration config;
226     mainThread_->ScheduleLaunchApplication(data, config);
227     HapModuleInfo abilityStage;
228     mainThread_->ScheduleAbilityStage(abilityStage);
229     AbilityInfo info;
230     sptr<IRemoteObject> Token = nullptr;
231     std::shared_ptr<AAFwk::Want> want;
232     mainThread_->ScheduleLaunchAbility(info, Token, want);
233     mainThread_->ScheduleCleanAbility(Token);
234     Profile profile;
235     mainThread_->ScheduleProfileChanged(profile);
236     mainThread_->ScheduleConfigurationUpdated(config);
237     HILOG_INFO("%{public}s end.", __func__);
238 }
239 
240 /*
241  * Feature: MainThread
242  * Function: InitCreate
243  * SubFunction: NA
244  * FunctionPoints: MainThread InitCreate
245  * EnvConditions: NA
246  * CaseDescription: Verify InitCreate
247  */
248 HWTEST_F(MainThreadTest, InitCreate_0100, TestSize.Level1)
249 {
250     HILOG_INFO("%{public}s start.", __func__);
251     std::shared_ptr<ContextDeal> contextDeal;
252     ApplicationInfo appInfo;
253     ProcessInfo processInfo;
254     Profile appProfile;
255     EXPECT_TRUE(mainThread_->InitCreate(contextDeal, appInfo, processInfo, appProfile));
256 
257     mainThread_->watchdog_ = nullptr;
258     EXPECT_TRUE(mainThread_->InitCreate(contextDeal, appInfo, processInfo, appProfile));
259     HILOG_INFO("%{public}s end.", __func__);
260 }
261 
262 /**
263  * @tc.name: ScheduleNotifyLoadRepairPatch_0100
264  * @tc.desc: schedule notify load repair patch.
265  * @tc.type: FUNC
266  * @tc.require: issueI581VW
267  */
268 HWTEST_F(MainThreadTest, ScheduleNotifyLoadRepairPatch_0100, TestSize.Level1)
269 {
270     HILOG_INFO("%{public}s start.", __func__);
271     std::string bundleName;
272     sptr<IQuickFixCallback> callback = new QuickFixCallbackImpl();
273     int32_t recordId = 0;
274     auto ret = mainThread_->ScheduleNotifyLoadRepairPatch(bundleName, callback, recordId);
275     EXPECT_EQ(ret, NO_ERROR);
276     HILOG_INFO("%{public}s end.", __func__);
277 }
278 
279 /**
280  * @tc.name: ScheduleNotifyHotReloadPage_0100
281  * @tc.desc: schedule notify ace hot reload page.
282  * @tc.type: FUNC
283  * @tc.require: issueI581VW
284  */
285 HWTEST_F(MainThreadTest, ScheduleNotifyHotReloadPage_0100, TestSize.Level1)
286 {
287     HILOG_INFO("%{public}s start.", __func__);
288     sptr<IQuickFixCallback> callback = new QuickFixCallbackImpl();
289     int32_t recordId = 0;
290     auto ret = mainThread_->ScheduleNotifyHotReloadPage(callback, recordId);
291     EXPECT_EQ(ret, NO_ERROR);
292     HILOG_INFO("%{public}s end.", __func__);
293 }
294 
295 /**
296  * @tc.name: GetHqfFileAndHapPath_0100
297  * @tc.desc: get patch file and hap path.
298  * @tc.type: FUNC
299  * @tc.require: issueI581VW
300  */
301 HWTEST_F(MainThreadTest, GetHqfFileAndHapPath_0100, TestSize.Level1)
302 {
303     HILOG_INFO("%{public}s start.", __func__);
304     ProcessInfo processInfo("test_quickfix", 1);
305     mainThread_->processInfo_ = std::make_shared<ProcessInfo>(processInfo);
306     std::string bundleName = "com.ohos.quickfix";
307     std::vector<std::pair<std::string, std::string>> fileMap;
308     auto ret = mainThread_->GetHqfFileAndHapPath(bundleName, fileMap);
309     EXPECT_TRUE(ret);
310     HILOG_INFO("%{public}s end.", __func__);
311 }
312 
313 /**
314  * @tc.name: ScheduleNotifyUnLoadRepairPatch_0100
315  * @tc.desc: schedule notify unload repair patch.
316  * @tc.type: FUNC
317  * @tc.require: issueI581VW
318  */
319 HWTEST_F(MainThreadTest, ScheduleNotifyUnLoadRepairPatch_0100, TestSize.Level1)
320 {
321     HILOG_INFO("%{public}s start.", __func__);
322     std::string bundleName;
323     int32_t recordId = 0;
324     sptr<IQuickFixCallback> callback = new QuickFixCallbackImpl();
325     auto ret = mainThread_->ScheduleNotifyUnLoadRepairPatch(bundleName, callback, recordId);
326     EXPECT_EQ(ret, NO_ERROR);
327 
328     mainThread_->mainHandler_ = nullptr;
329     EXPECT_EQ(mainThread_->ScheduleNotifyUnLoadRepairPatch(bundleName, callback, recordId), ERR_INVALID_VALUE);
330     HILOG_INFO("%{public}s end.", __func__);
331 }
332 
333 /**
334  * @tc.name: InitResourceManager_0100
335  * @tc.desc: init resourceManager.
336  * @tc.type: FUNC
337  * @tc.require: issueI581VW
338  */
339 HWTEST_F(MainThreadTest, InitResourceManager_0100, TestSize.Level1)
340 {
341     std::shared_ptr<Global::Resource::ResourceManager> resourceManager(Global::Resource::CreateResourceManager());
342     EXPECT_TRUE(resourceManager != nullptr);
343     AppExecFwk::BundleInfo bundleInfo;
344     Configuration config;
345     bundleInfo.applicationInfo.multiProjects = true;
346     mainThread_->InitResourceManager(resourceManager, bundleInfo, config);
347     EXPECT_TRUE(resourceManager != nullptr);
348     bundleInfo.applicationInfo.multiProjects = false;
349     mainThread_->InitResourceManager(resourceManager, bundleInfo, config);
350     EXPECT_TRUE(resourceManager != nullptr);
351 
352     HapModuleInfo info;
353     info.name = "com.ohos.contactsdataability";
354     info.moduleName = "entry";
355     info.description = "dataability_description";
356     info.iconPath = "$media:icon";
357     info.deviceTypes = {"smartVision"};
358     info.bundleName = "com.ohos.contactsdataability";
359     bundleInfo.hapModuleInfos.push_back(info);
360     bundleInfo.applicationInfo.multiProjects = true;
361     mainThread_->InitResourceManager(resourceManager, bundleInfo, config);
362     EXPECT_TRUE(resourceManager != nullptr);
363 
364     bundleInfo.applicationInfo.multiProjects = false;
365     mainThread_->InitResourceManager(resourceManager, bundleInfo, config);
366     EXPECT_TRUE(resourceManager != nullptr);
367 
368     info.resourcePath = "/data/app/el1/budle/public/com.ohos.contactsdataability"\
369         "/com.ohos.contactsdataability/assets/entry/resources.index";
370     bundleInfo.hapModuleInfos.clear();
371     bundleInfo.hapModuleInfos.push_back(info);
372     mainThread_->InitResourceManager(resourceManager, bundleInfo, config);
373     EXPECT_TRUE(resourceManager != nullptr);
374 
375     info.hapPath = "/system/app/com.ohos.contactsdataability/Contacts_DataAbility.hap";
376     bundleInfo.hapModuleInfos.clear();
377     bundleInfo.hapModuleInfos.push_back(info);
378     mainThread_->InitResourceManager(resourceManager, bundleInfo, config);
379     EXPECT_TRUE(resourceManager != nullptr);
380 
381     info.resourcePath = "";
382     bundleInfo.hapModuleInfos.clear();
383     bundleInfo.hapModuleInfos.push_back(info);
384     mainThread_->InitResourceManager(resourceManager, bundleInfo, config);
385     EXPECT_TRUE(resourceManager != nullptr);
386 }
387 
388 /**
389  * @tc.name: HandleLaunchApplication_0100
390  * @tc.desc: Handle launch application.
391  * @tc.type: FUNC
392  * @tc.require: issueI581VW
393  */
394 HWTEST_F(MainThreadTest, HandleLaunchApplication_0100, TestSize.Level1)
395 {
396     Configuration config;
397     AppLaunchData lanchdata;
398     ProcessInfo processing("TestProcess", 9999);
399     ApplicationInfo appinf;
400     appinf.name = "MockTestApplication";
401     appinf.moduleSourceDirs.push_back("/hos/lib/libabilitydemo_native.z.so");
402     lanchdata.SetApplicationInfo(appinf);
403     lanchdata.SetProcessInfo(processing);
404     mainThread_->HandleLaunchApplication(lanchdata, config);
405     EXPECT_TRUE(mainThread_->application_ != nullptr);
406 
407     lanchdata.SetAppIndex(1);
408     mainThread_->HandleLaunchApplication(lanchdata, config);
409 }
410 
411 /**
412  * @tc.name: SetNativeLibPath_0100
413  * @tc.desc: set native lib path.
414  * @tc.type: FUNC
415  * @tc.require: issueI64MUJ
416  */
417 HWTEST_F(MainThreadTest, SetNativeLibPath_0100, TestSize.Level1)
418 {
419     HILOG_INFO("%{public}s start.", __func__);
420     Configuration config;
421     AppLaunchData launchData;
422     ProcessInfo processInfo("test_quickfix", 9999);
423     ApplicationInfo appInfo;
424     appInfo.name = "MainAbility";
425     appInfo.bundleName = "com.ohos.quickfix";
426     launchData.SetApplicationInfo(appInfo);
427     launchData.SetProcessInfo(processInfo);
428 
429     // SetNativeLibPath is implemented in anonymous space, called by HandleLaunchApplication
430     mainThread_->HandleLaunchApplication(launchData, config);
431     ASSERT_NE(mainThread_->application_, nullptr);
432     EXPECT_NE(mainThread_->application_->abilityRuntimeContext_, nullptr);
433     HILOG_INFO("%{public}s end.", __func__);
434 }
435 
436 /**
437  * @tc.name: ConnectToAppMgr_0100
438  * @tc.desc: ConnectToAppMgr.
439  * @tc.type: FUNC
440  * @tc.require: issueI64MUJ
441  */
442 HWTEST_F(MainThreadTest, ConnectToAppMgr_0100, TestSize.Level1)
443 {
444     HILOG_INFO("%{public}s start.", __func__);
445     EXPECT_TRUE(mainThread_->ConnectToAppMgr());
446     HILOG_INFO("%{public}s end.", __func__);
447 }
448 
449 /**
450  * @tc.name: Attach_0100
451  * @tc.desc: Attach.
452  * @tc.type: FUNC
453  * @tc.require: issueI64MUJ
454  */
455 HWTEST_F(MainThreadTest, Attach_0100, TestSize.Level1)
456 {
457     HILOG_INFO("%{public}s start.", __func__);
458     mainThread_->Attach();
459     EXPECT_EQ(MainThreadState::ATTACH, mainThread_->mainThreadState_);
460     HILOG_INFO("%{public}s end.", __func__);
461 }
462 
463 /**
464  * @tc.name: RemoveAppMgrDeathRecipient_0100
465  * @tc.desc: RemoveAppMgrDeathRecipient.
466  * @tc.type: FUNC
467  * @tc.require: issueI64MUJ
468  */
469 HWTEST_F(MainThreadTest, RemoveAppMgrDeathRecipient_0100, TestSize.Level1)
470 {
471     HILOG_INFO("%{public}s start.", __func__);
472     mainThread_->RemoveAppMgrDeathRecipient();
473     EXPECT_TRUE(mainThread_->ConnectToAppMgr());
474     mainThread_->RemoveAppMgrDeathRecipient();
475     HILOG_INFO("%{public}s end.", __func__);
476 }
477 
478 /**
479  * @tc.name: CheckLaunchApplicationParam_0100
480  * @tc.desc: CheckLaunchApplicationParam.
481  * @tc.type: FUNC
482  * @tc.require: issueI64MUJ
483  */
484 HWTEST_F(MainThreadTest, CheckLaunchApplicationParam_0100, TestSize.Level1)
485 {
486     HILOG_INFO("%{public}s start.", __func__);
487     AppLaunchData appLaunchData;
488     ApplicationInfo appInfo;
489     appInfo.name = "";
490     ProcessInfo processInfo("test", 1);
491     appLaunchData.SetApplicationInfo(appInfo);
492     appLaunchData.SetProcessInfo(processInfo);
493     EXPECT_FALSE(mainThread_->CheckLaunchApplicationParam(appLaunchData));
494     HILOG_INFO("%{public}s end.", __func__);
495 }
496 
497 /**
498  * @tc.name: CheckLaunchApplicationParam_0200
499  * @tc.desc: CheckLaunchApplicationParam.
500  * @tc.type: FUNC
501  * @tc.require: issueI64MUJ
502  */
503 HWTEST_F(MainThreadTest, CheckLaunchApplicationParam_0200, TestSize.Level1)
504 {
505     HILOG_INFO("%{public}s start.", __func__);
506     AppLaunchData appLaunchData;
507     ApplicationInfo appInfo;
508     appInfo.name = "test";
509     ProcessInfo processInfo("", 1);
510     appLaunchData.SetApplicationInfo(appInfo);
511     appLaunchData.SetProcessInfo(processInfo);
512     EXPECT_FALSE(mainThread_->CheckLaunchApplicationParam(appLaunchData));
513 
514     ProcessInfo processInfo2("test", 1);
515     appLaunchData.SetProcessInfo(processInfo2);
516     EXPECT_TRUE(mainThread_->CheckLaunchApplicationParam(appLaunchData));
517     HILOG_INFO("%{public}s end.", __func__);
518 }
519 
520 /**
521  * @tc.name: CheckAbilityItem_0100
522  * @tc.desc: CheckAbilityItem.
523  * @tc.type: FUNC
524  * @tc.require: issueI64MUJ
525  */
526 HWTEST_F(MainThreadTest, CheckAbilityItem_0100, TestSize.Level1)
527 {
528     HILOG_INFO("%{public}s start.", __func__);
529     std::shared_ptr<AbilityInfo> info = std::make_shared<AbilityInfo>();
530     std::shared_ptr<AbilityLocalRecord> record = std::make_shared<AbilityLocalRecord>(info, nullptr);
531     EXPECT_FALSE(mainThread_->CheckAbilityItem(record));
532     HILOG_INFO("%{public}s end.", __func__);
533 }
534 
535 /**
536  * @tc.name: CheckAbilityItem_0200
537  * @tc.desc: CheckAbilityItem.
538  * @tc.type: FUNC
539  * @tc.require: issueI64MUJ
540  */
541 HWTEST_F(MainThreadTest, CheckAbilityItem_0200, TestSize.Level1)
542 {
543     HILOG_INFO("%{public}s start.", __func__);
544     std::shared_ptr<AbilityLocalRecord> record = std::make_shared<AbilityLocalRecord>(nullptr, nullptr);
545     EXPECT_FALSE(mainThread_->CheckAbilityItem(record));
546     HILOG_INFO("%{public}s end.", __func__);
547 }
548 
549 /**
550  * @tc.name: CheckAbilityItem_0300
551  * @tc.desc: CheckAbilityItem.
552  * @tc.type: FUNC
553  * @tc.require: issueI64MUJ
554  */
555 HWTEST_F(MainThreadTest, CheckAbilityItem_0300, TestSize.Level1)
556 {
557     HILOG_INFO("%{public}s start.", __func__);
558     EXPECT_FALSE(mainThread_->CheckAbilityItem(nullptr));
559     HILOG_INFO("%{public}s end.", __func__);
560 }
561 
562 /**
563  * @tc.name: HandleTerminateApplicationLocal_0100
564  * @tc.desc: HandleTerminateApplicationLocal.
565  * @tc.type: FUNC
566  * @tc.require: issueI64MUJ
567  */
568 HWTEST_F(MainThreadTest, HandleTerminateApplicationLocal_0100, TestSize.Level1)
569 {
570     HILOG_INFO("%{public}s start.", __func__);
571     mainThread_->application_ = nullptr;
572     mainThread_->HandleTerminateApplicationLocal();
573     HILOG_INFO("%{public}s end.", __func__);
574 }
575 
576 /**
577  * @tc.name: HandleTerminateApplicationLocal_0200
578  * @tc.desc: HandleTerminateApplicationLocal.
579  * @tc.type: FUNC
580  * @tc.require: issueI64MUJ
581  */
582 HWTEST_F(MainThreadTest, HandleTerminateApplicationLocal_0200, TestSize.Level1)
583 {
584     HILOG_INFO("%{public}s start.", __func__);
585     mainThread_->signalHandler_->SetEventRunner(nullptr);
586     mainThread_->HandleTerminateApplicationLocal();
587     HILOG_INFO("%{public}s end.", __func__);
588 }
589 
590 /**
591  * @tc.name: HandleTerminateApplicationLocal_0300
592  * @tc.desc: HandleTerminateApplicationLocal.
593  * @tc.type: FUNC
594  * @tc.require: issueI64MUJ
595  */
596 HWTEST_F(MainThreadTest, HandleTerminateApplicationLocal_0300, TestSize.Level1)
597 {
598     HILOG_INFO("%{public}s start.", __func__);
599     mainThread_->mainHandler_->SetEventRunner(nullptr);
600     mainThread_->HandleTerminateApplicationLocal();
601     HILOG_INFO("%{public}s end.", __func__);
602 }
603 
604 /**
605  * @tc.name: HandleTerminateApplicationLocal_0400
606  * @tc.desc: HandleTerminateApplicationLocal.
607  * @tc.type: FUNC
608  * @tc.require: issueI64MUJ
609  */
610 HWTEST_F(MainThreadTest, HandleTerminateApplicationLocal_0400, TestSize.Level1)
611 {
612     HILOG_INFO("%{public}s start.", __func__);
613     mainThread_->watchdog_ = nullptr;
614     mainThread_->HandleTerminateApplicationLocal();
615     HILOG_INFO("%{public}s end.", __func__);
616 }
617 
618 /**
619  * @tc.name: HandleProcessSecurityExit_0100
620  * @tc.desc: HandleProcessSecurityExit.
621  * @tc.type: FUNC
622  * @tc.require: issueI64MUJ
623  */
624 HWTEST_F(MainThreadTest, HandleProcessSecurityExit_0100, TestSize.Level1)
625 {
626     HILOG_INFO("%{public}s start.", __func__);
627     mainThread_->abilityRecordMgr_ = nullptr;
628     mainThread_->HandleProcessSecurityExit();
629 
630     std::shared_ptr<ContextDeal> contextDeal;
631     ApplicationInfo appInfo;
632     ProcessInfo processInfo;
633     Profile appProfile;
634     mainThread_->InitCreate(contextDeal, appInfo, processInfo, appProfile);
635     mainThread_->HandleProcessSecurityExit();
636     HILOG_INFO("%{public}s end.", __func__);
637 }
638 
639 /**
640  * @tc.name: HandleProcessSecurityExit_0200
641  * @tc.desc: HandleProcessSecurityExit.
642  * @tc.type: FUNC
643  * @tc.require: issueI64MUJ
644  */
645 HWTEST_F(MainThreadTest, HandleProcessSecurityExit_0200, TestSize.Level1)
646 {
647     HILOG_INFO("%{public}s start.", __func__);
648     mainThread_->HandleProcessSecurityExit();
649     HILOG_INFO("%{public}s end.", __func__);
650 }
651 
652 /**
653  * @tc.name: CheckForHandleLaunchApplication_0100
654  * @tc.desc: CheckForHandleLaunchApplication.
655  * @tc.type: FUNC
656  * @tc.require: issueI64MUJ
657  */
658 HWTEST_F(MainThreadTest, CheckForHandleLaunchApplication_0100, TestSize.Level1)
659 {
660     HILOG_INFO("%{public}s start.", __func__);
661     mainThread_->application_ = nullptr;
662     AppLaunchData appLaunchData;
663     ApplicationInfo appInfo;
664     appInfo.name = "test";
665     ProcessInfo processInfo("test", 1);
666     appLaunchData.SetApplicationInfo(appInfo);
667     appLaunchData.SetProcessInfo(processInfo);
668     EXPECT_TRUE(mainThread_->CheckForHandleLaunchApplication(appLaunchData));
669     HILOG_INFO("%{public}s end.", __func__);
670 }
671 
672 /**
673  * @tc.name: CheckForHandleLaunchApplication_0200
674  * @tc.desc: CheckForHandleLaunchApplication.
675  * @tc.type: FUNC
676  * @tc.require: issueI64MUJ
677  */
678 HWTEST_F(MainThreadTest, CheckForHandleLaunchApplication_0200, TestSize.Level1)
679 {
680     HILOG_INFO("%{public}s start.", __func__);
681     mainThread_->application_ = std::make_shared<OHOSApplication>();
682     AppLaunchData appLaunchData;
683     ApplicationInfo appInfo;
684     appInfo.name = "test";
685     ProcessInfo processInfo("test", 1);
686     appLaunchData.SetApplicationInfo(appInfo);
687     appLaunchData.SetProcessInfo(processInfo);
688     EXPECT_FALSE(mainThread_->CheckForHandleLaunchApplication(appLaunchData));
689     HILOG_INFO("%{public}s end.", __func__);
690 }
691 
692 /**
693  * @tc.name: CheckForHandleLaunchApplication_0300
694  * @tc.desc: CheckForHandleLaunchApplication.
695  * @tc.type: FUNC
696  * @tc.require: issueI64MUJ
697  */
698 HWTEST_F(MainThreadTest, CheckForHandleLaunchApplication_0300, TestSize.Level1)
699 {
700     HILOG_INFO("%{public}s start.", __func__);
701     AppLaunchData appLaunchData;
702     ApplicationInfo appInfo;
703     appInfo.name = "";
704     ProcessInfo processInfo("test", 1);
705     appLaunchData.SetApplicationInfo(appInfo);
706     appLaunchData.SetProcessInfo(processInfo);
707     EXPECT_FALSE(mainThread_->CheckForHandleLaunchApplication(appLaunchData));
708     HILOG_INFO("%{public}s end.", __func__);
709 }
710 
711 /**
712  * @tc.name: HandleAbilityStage_0100
713  * @tc.desc: HandleAbilityStage.
714  * @tc.type: FUNC
715  * @tc.require: issueI64MUJ
716  */
717 HWTEST_F(MainThreadTest, HandleAbilityStage_0100, TestSize.Level1)
718 {
719     HILOG_INFO("%{public}s start.", __func__);
720     HapModuleInfo info;
721     mainThread_->HandleAbilityStage(info);
722     HILOG_INFO("%{public}s end.", __func__);
723 }
724 
725 /**
726  * @tc.name: HandleAbilityStage_0200
727  * @tc.desc: HandleAbilityStage.
728  * @tc.type: FUNC
729  * @tc.require: issueI64MUJ
730  */
731 HWTEST_F(MainThreadTest, HandleAbilityStage_0200, TestSize.Level1)
732 {
733     HILOG_INFO("%{public}s start.", __func__);
734     mainThread_->application_ = nullptr;
735     HapModuleInfo info;
736     mainThread_->HandleAbilityStage(info);
737     HILOG_INFO("%{public}s end.", __func__);
738 }
739 
740 /**
741  * @tc.name: HandleAbilityStage_0300
742  * @tc.desc: HandleAbilityStage.
743  * @tc.type: FUNC
744  * @tc.require: issueI64MUJ
745  */
746 HWTEST_F(MainThreadTest, HandleAbilityStage_0300, TestSize.Level1)
747 {
748     HILOG_INFO("%{public}s start.", __func__);
749     mainThread_->appMgr_ = nullptr;
750     HapModuleInfo info;
751     mainThread_->HandleAbilityStage(info);
752     HILOG_INFO("%{public}s end.", __func__);
753 }
754 
755 /**
756  * @tc.name: HandleAbilityStage_0400
757  * @tc.desc: HandleAbilityStage.
758  * @tc.type: FUNC
759  * @tc.require: issueI64MUJ
760  */
761 HWTEST_F(MainThreadTest, HandleAbilityStage_0400, TestSize.Level1)
762 {
763     HILOG_INFO("%{public}s start.", __func__);
764     mainThread_->applicationImpl_ = nullptr;
765     HapModuleInfo info;
766     mainThread_->HandleAbilityStage(info);
767     HILOG_INFO("%{public}s end.", __func__);
768 }
769 
770 /**
771  * @tc.name: PrepareAbilityDelegator_0100
772  * @tc.desc: PrepareAbilityDelegator.
773  * @tc.type: FUNC
774  * @tc.require: issueI64MUJ
775  */
776 HWTEST_F(MainThreadTest, PrepareAbilityDelegator_0100, TestSize.Level1)
777 {
778     HILOG_INFO("%{public}s start.", __func__);
779     mainThread_->application_ = std::make_shared<OHOSApplication>();
780     std::shared_ptr<UserTestRecord> usertestInfo = std::make_shared<UserTestRecord>();
781     bool isStageBased = true;
782     BundleInfo bundleInfo;
783     EXPECT_TRUE(mainThread_->PrepareAbilityDelegator(usertestInfo, isStageBased, bundleInfo));
784     HILOG_INFO("%{public}s end.", __func__);
785 }
786 
787 /**
788  * @tc.name: PrepareAbilityDelegator_0200
789  * @tc.desc: PrepareAbilityDelegator.
790  * @tc.type: FUNC
791  * @tc.require: issueI64MUJ
792  */
793 HWTEST_F(MainThreadTest, PrepareAbilityDelegator_0200, TestSize.Level1)
794 {
795     HILOG_INFO("%{public}s start.", __func__);
796     bool isStageBased = true;
797     BundleInfo bundleInfo;
798     EXPECT_FALSE(mainThread_->PrepareAbilityDelegator(nullptr, isStageBased, bundleInfo));
799     HILOG_INFO("%{public}s end.", __func__);
800 }
801 
802 /**
803  * @tc.name: PrepareAbilityDelegator_0300
804  * @tc.desc: PrepareAbilityDelegator.
805  * @tc.type: FUNC
806  * @tc.require: issueI64MUJ
807  */
808 HWTEST_F(MainThreadTest, PrepareAbilityDelegator_0300, TestSize.Level1)
809 {
810     HILOG_INFO("%{public}s start.", __func__);
811     mainThread_->application_ = std::make_shared<OHOSApplication>();
812     std::shared_ptr<UserTestRecord> usertestInfo = std::make_shared<UserTestRecord>();
813     bool isStageBased = false;
814     AbilityInfo abilityInfo;
815     HapModuleInfo hapModuleInfo;
816     BundleInfo bundleInfo;
817     hapModuleInfo.abilityInfos.emplace_back(abilityInfo);
818     bundleInfo.hapModuleInfos.emplace_back(hapModuleInfo);
819     EXPECT_TRUE(mainThread_->PrepareAbilityDelegator(usertestInfo, isStageBased, bundleInfo));
820     HILOG_INFO("%{public}s end.", __func__);
821 }
822 
823 /**
824  * @tc.name: PrepareAbilityDelegator_0400
825  * @tc.desc: PrepareAbilityDelegator.
826  * @tc.type: FUNC
827  * @tc.require: issueI64MUJ
828  */
829 HWTEST_F(MainThreadTest, PrepareAbilityDelegator_0400, TestSize.Level1)
830 {
831     HILOG_INFO("%{public}s start.", __func__);
832     mainThread_->application_ = std::make_shared<OHOSApplication>();
833     std::shared_ptr<UserTestRecord> usertestInfo = std::make_shared<UserTestRecord>();
834     bool isStageBased = false;
835     HapModuleInfo hapModuleInfo;
836     BundleInfo bundleInfo;
837     bundleInfo.hapModuleInfos.emplace_back(hapModuleInfo);
838     EXPECT_FALSE(mainThread_->PrepareAbilityDelegator(usertestInfo, isStageBased, bundleInfo));
839     HILOG_INFO("%{public}s end.", __func__);
840 }
841 
842 /**
843  * @tc.name: HandleLaunchAbility_0100
844  * @tc.desc: HandleLaunchAbility.
845  * @tc.type: FUNC
846  * @tc.require: issueI64MUJ
847  */
848 HWTEST_F(MainThreadTest, HandleLaunchAbility_0100, TestSize.Level1)
849 {
850     HILOG_INFO("%{public}s start.", __func__);
851     std::shared_ptr<AbilityLocalRecord> abilityRecord = std::make_shared<AbilityLocalRecord>(nullptr, nullptr);
852     mainThread_->HandleLaunchAbility(abilityRecord);
853     HILOG_INFO("%{public}s end.", __func__);
854 }
855 
856 /**
857  * @tc.name: HandleCleanAbilityLocal_0100
858  * @tc.desc: HandleCleanAbilityLocal.
859  * @tc.type: FUNC
860  * @tc.require: issueI64MUJ
861  */
862 HWTEST_F(MainThreadTest, HandleCleanAbilityLocal_0100, TestSize.Level1)
863 {
864     HILOG_INFO("%{public}s start.", __func__);
865     mainThread_->application_ = nullptr;
866     mainThread_->HandleCleanAbilityLocal(nullptr);
867     HILOG_INFO("%{public}s end.", __func__);
868 }
869 
870 /**
871  * @tc.name: HandleCleanAbilityLocal_0200
872  * @tc.desc: HandleCleanAbilityLocal.
873  * @tc.type: FUNC
874  * @tc.require: issueI64MUJ
875  */
876 HWTEST_F(MainThreadTest, HandleCleanAbilityLocal_0200, TestSize.Level1)
877 {
878     HILOG_INFO("%{public}s start.", __func__);
879     mainThread_->HandleCleanAbilityLocal(nullptr);
880     HILOG_INFO("%{public}s end.", __func__);
881 }
882 
883 /**
884  * @tc.name: HandleForegroundApplication_0100
885  * @tc.desc: HandleForegroundApplication.
886  * @tc.type: FUNC
887  * @tc.require: issueI64MUJ
888  */
889 HWTEST_F(MainThreadTest, HandleForegroundApplication_0100, TestSize.Level1)
890 {
891     HILOG_INFO("%{public}s start.", __func__);
892     mainThread_->HandleForegroundApplication();
893     HILOG_INFO("%{public}s end.", __func__);
894 }
895 
896 /**
897  * @tc.name: HandleForegroundApplication_0200
898  * @tc.desc: HandleForegroundApplication.
899  * @tc.type: FUNC
900  * @tc.require: issueI64MUJ
901  */
902 HWTEST_F(MainThreadTest, HandleForegroundApplication_0200, TestSize.Level1)
903 {
904     HILOG_INFO("%{public}s start.", __func__);
905     mainThread_->application_ = nullptr;
906     mainThread_->HandleForegroundApplication();
907     HILOG_INFO("%{public}s end.", __func__);
908 }
909 
910 /**
911  * @tc.name: HandleForegroundApplication_0300
912  * @tc.desc: HandleForegroundApplication.
913  * @tc.type: FUNC
914  * @tc.require: issueI64MUJ
915  */
916 HWTEST_F(MainThreadTest, HandleForegroundApplication_0300, TestSize.Level1)
917 {
918     HILOG_INFO("%{public}s start.", __func__);
919     mainThread_->appMgr_ = nullptr;
920     mainThread_->HandleForegroundApplication();
921     HILOG_INFO("%{public}s end.", __func__);
922 }
923 
924 /**
925  * @tc.name: HandleBackgroundApplication_0100
926  * @tc.desc: HandleBackgroundApplication.
927  * @tc.type: FUNC
928  * @tc.require: issueI64MUJ
929  */
930 HWTEST_F(MainThreadTest, HandleBackgroundApplication_0100, TestSize.Level1)
931 {
932     HILOG_INFO("%{public}s start.", __func__);
933     mainThread_->HandleBackgroundApplication();
934     HILOG_INFO("%{public}s end.", __func__);
935 }
936 
937 /**
938  * @tc.name: HandleBackgroundApplication_0200
939  * @tc.desc: HandleBackgroundApplication.
940  * @tc.type: FUNC
941  * @tc.require: issueI64MUJ
942  */
943 HWTEST_F(MainThreadTest, HandleBackgroundApplication_0200, TestSize.Level1)
944 {
945     HILOG_INFO("%{public}s start.", __func__);
946     mainThread_->application_ = nullptr;
947     mainThread_->HandleBackgroundApplication();
948     HILOG_INFO("%{public}s end.", __func__);
949 }
950 
951 /**
952  * @tc.name: HandleBackgroundApplication_0300
953  * @tc.desc: HandleBackgroundApplication.
954  * @tc.type: FUNC
955  * @tc.require: issueI64MUJ
956  */
957 HWTEST_F(MainThreadTest, HandleBackgroundApplication_0300, TestSize.Level1)
958 {
959     HILOG_INFO("%{public}s start.", __func__);
960     mainThread_->appMgr_ = nullptr;
961     mainThread_->HandleBackgroundApplication();
962     HILOG_INFO("%{public}s end.", __func__);
963 }
964 
965 /**
966  * @tc.name: HandleTerminateApplication_0100
967  * @tc.desc: HandleTerminateApplication.
968  * @tc.type: FUNC
969  * @tc.require: issueI64MUJ
970  */
971 HWTEST_F(MainThreadTest, HandleTerminateApplication_0100, TestSize.Level1)
972 {
973     HILOG_INFO("%{public}s start.", __func__);
974     mainThread_->HandleTerminateApplication();
975     HILOG_INFO("%{public}s end.", __func__);
976 }
977 
978 /**
979  * @tc.name: HandleTerminateApplication_0200
980  * @tc.desc: HandleTerminateApplication.
981  * @tc.type: FUNC
982  * @tc.require: issueI64MUJ
983  */
984 HWTEST_F(MainThreadTest, HandleTerminateApplication_0200, TestSize.Level1)
985 {
986     HILOG_INFO("%{public}s start.", __func__);
987     mainThread_->application_ = nullptr;
988     mainThread_->HandleTerminateApplication();
989     HILOG_INFO("%{public}s end.", __func__);
990 }
991 
992 /**
993  * @tc.name: HandleTerminateApplication_0300
994  * @tc.desc: HandleTerminateApplication.
995  * @tc.type: FUNC
996  * @tc.require: issueI64MUJ
997  */
998 HWTEST_F(MainThreadTest, HandleTerminateApplication_0300, TestSize.Level1)
999 {
1000     HILOG_INFO("%{public}s start.", __func__);
1001     mainThread_->appMgr_ = nullptr;
1002     mainThread_->HandleTerminateApplication();
1003     HILOG_INFO("%{public}s end.", __func__);
1004 }
1005 
1006 /**
1007  * @tc.name: HandleTerminateApplication_0400
1008  * @tc.desc: HandleTerminateApplication.
1009  * @tc.type: FUNC
1010  * @tc.require: issueI64MUJ
1011  */
1012 HWTEST_F(MainThreadTest, HandleTerminateApplication_0400, TestSize.Level1)
1013 {
1014     HILOG_INFO("%{public}s start.", __func__);
1015     mainThread_->signalHandler_->SetEventRunner(nullptr);
1016     mainThread_->HandleTerminateApplication();
1017     HILOG_INFO("%{public}s end.", __func__);
1018 }
1019 
1020 /**
1021  * @tc.name: HandleTerminateApplication_0500
1022  * @tc.desc: HandleTerminateApplication.
1023  * @tc.type: FUNC
1024  * @tc.require: issueI64MUJ
1025  */
1026 HWTEST_F(MainThreadTest, HandleTerminateApplication_0500, TestSize.Level1)
1027 {
1028     HILOG_INFO("%{public}s start.", __func__);
1029     mainThread_->mainHandler_->SetEventRunner(nullptr);
1030     mainThread_->HandleTerminateApplication();
1031     HILOG_INFO("%{public}s end.", __func__);
1032 }
1033 
1034 /**
1035  * @tc.name: HandleTerminateApplication_0600
1036  * @tc.desc: HandleTerminateApplication.
1037  * @tc.type: FUNC
1038  * @tc.require: issueI64MUJ
1039  */
1040 HWTEST_F(MainThreadTest, HandleTerminateApplication_0600, TestSize.Level1)
1041 {
1042     HILOG_INFO("%{public}s start.", __func__);
1043     mainThread_->watchdog_ = nullptr;
1044     mainThread_->HandleTerminateApplication();
1045     HILOG_INFO("%{public}s end.", __func__);
1046 }
1047 
1048 /**
1049  * @tc.name: HandleShrinkMemory_0100
1050  * @tc.desc: HandleShrinkMemory.
1051  * @tc.type: FUNC
1052  * @tc.require: issueI64MUJ
1053  */
1054 HWTEST_F(MainThreadTest, HandleShrinkMemory_0100, TestSize.Level1)
1055 {
1056     HILOG_INFO("%{public}s start.", __func__);
1057     mainThread_->HandleShrinkMemory(1);
1058     HILOG_INFO("%{public}s end.", __func__);
1059 }
1060 
1061 /**
1062  * @tc.name: HandleShrinkMemory_0200
1063  * @tc.desc: HandleShrinkMemory.
1064  * @tc.type: FUNC
1065  * @tc.require: issueI64MUJ
1066  */
1067 HWTEST_F(MainThreadTest, HandleShrinkMemory_0200, TestSize.Level1)
1068 {
1069     HILOG_INFO("%{public}s start.", __func__);
1070     mainThread_->applicationImpl_ = nullptr;
1071     mainThread_->HandleShrinkMemory(1);
1072     HILOG_INFO("%{public}s end.", __func__);
1073 }
1074 
1075 /**
1076  * @tc.name: HandleMemoryLevel_0100
1077  * @tc.desc: HandleMemoryLevel.
1078  * @tc.type: FUNC
1079  * @tc.require: issueI64MUJ
1080  */
1081 HWTEST_F(MainThreadTest, HandleMemoryLevel_0100, TestSize.Level1)
1082 {
1083     HILOG_INFO("%{public}s start.", __func__);
1084     mainThread_->HandleMemoryLevel(1);
1085     HILOG_INFO("%{public}s end.", __func__);
1086 }
1087 
1088 /**
1089  * @tc.name: HandleMemoryLevel_0200
1090  * @tc.desc: HandleMemoryLevel.
1091  * @tc.type: FUNC
1092  * @tc.require: issueI64MUJ
1093  */
1094 HWTEST_F(MainThreadTest, HandleMemoryLevel_0200, TestSize.Level1)
1095 {
1096     HILOG_INFO("%{public}s start.", __func__);
1097     mainThread_->application_ = nullptr;
1098     mainThread_->HandleMemoryLevel(1);
1099     HILOG_INFO("%{public}s end.", __func__);
1100 }
1101 
1102 /**
1103  * @tc.name: HandleConfigurationUpdated_0100
1104  * @tc.desc: HandleConfigurationUpdated.
1105  * @tc.type: FUNC
1106  * @tc.require: issueI64MUJ
1107  */
1108 HWTEST_F(MainThreadTest, HandleConfigurationUpdated_0100, TestSize.Level1)
1109 {
1110     HILOG_INFO("%{public}s start.", __func__);
1111     Configuration config;
1112     mainThread_->HandleConfigurationUpdated(config);
1113     HILOG_INFO("%{public}s end.", __func__);
1114 }
1115 
1116 /**
1117  * @tc.name: HandleConfigurationUpdated_0200
1118  * @tc.desc: HandleConfigurationUpdated.
1119  * @tc.type: FUNC
1120  * @tc.require: issueI64MUJ
1121  */
1122 HWTEST_F(MainThreadTest, HandleConfigurationUpdated_0200, TestSize.Level1)
1123 {
1124     HILOG_INFO("%{public}s start.", __func__);
1125     mainThread_->applicationImpl_ = nullptr;
1126     Configuration config;
1127     mainThread_->HandleConfigurationUpdated(config);
1128     HILOG_INFO("%{public}s end.", __func__);
1129 }
1130 
1131 /**
1132  * @tc.name: HandleSignal_0100
1133  * @tc.desc: HandleSignal.
1134  * @tc.type: FUNC
1135  * @tc.require: issueI64MUJ
1136  */
1137 HWTEST_F(MainThreadTest, HandleSignal_0100, TestSize.Level1)
1138 {
1139     HILOG_INFO("%{public}s start.", __func__);
1140     constexpr int SIGNAL_JS_HEAP = 39;
1141     mainThread_->HandleSignal(SIGNAL_JS_HEAP);
1142     HILOG_INFO("%{public}s end.", __func__);
1143 }
1144 
1145 /**
1146  * @tc.name: HandleSignal_0200
1147  * @tc.desc: HandleSignal.
1148  * @tc.type: FUNC
1149  * @tc.require: issueI64MUJ
1150  */
1151 HWTEST_F(MainThreadTest, HandleSignal_0200, TestSize.Level1)
1152 {
1153     HILOG_INFO("%{public}s start.", __func__);
1154     constexpr int SIGNAL_JS_HEAP_PRIV = 40;
1155     mainThread_->HandleSignal(SIGNAL_JS_HEAP_PRIV);
1156     HILOG_INFO("%{public}s end.", __func__);
1157 }
1158 
1159 /**
1160  * @tc.name: HandleSignal_0300
1161  * @tc.desc: HandleSignal.
1162  * @tc.type: FUNC
1163  * @tc.require: issueI64MUJ
1164  */
1165 HWTEST_F(MainThreadTest, HandleSignal_0300, TestSize.Level1)
1166 {
1167     HILOG_INFO("%{public}s start.", __func__);
1168     mainThread_->HandleSignal(-1);
1169     HILOG_INFO("%{public}s end.", __func__);
1170 }
1171 
1172 /**
1173  * @tc.name: IsApplicationReady_0100
1174  * @tc.desc: IsApplicationReady.
1175  * @tc.type: FUNC
1176  * @tc.require: issueI64MUJ
1177  */
1178 HWTEST_F(MainThreadTest, IsApplicationReady_0100, TestSize.Level1)
1179 {
1180     HILOG_INFO("%{public}s start.", __func__);
1181     mainThread_->application_ = std::make_shared<OHOSApplication>();
1182     mainThread_->applicationImpl_ = std::make_shared<ApplicationImpl>();
1183     EXPECT_TRUE(mainThread_->IsApplicationReady());
1184     HILOG_INFO("%{public}s end.", __func__);
1185 }
1186 
1187 /**
1188  * @tc.name: IsApplicationReady_0200
1189  * @tc.desc: IsApplicationReady.
1190  * @tc.type: FUNC
1191  * @tc.require: issueI64MUJ
1192  */
1193 HWTEST_F(MainThreadTest, IsApplicationReady_0200, TestSize.Level1)
1194 {
1195     HILOG_INFO("%{public}s start.", __func__);
1196     mainThread_->application_ = nullptr;
1197     mainThread_->applicationImpl_ = std::make_shared<ApplicationImpl>();
1198     EXPECT_FALSE(mainThread_->IsApplicationReady());
1199     HILOG_INFO("%{public}s end.", __func__);
1200 }
1201 
1202 /**
1203  * @tc.name: IsApplicationReady_0300
1204  * @tc.desc: IsApplicationReady.
1205  * @tc.type: FUNC
1206  * @tc.require: issueI64MUJ
1207  */
1208 HWTEST_F(MainThreadTest, IsApplicationReady_0300, TestSize.Level1)
1209 {
1210     HILOG_INFO("%{public}s start.", __func__);
1211     mainThread_->application_ = std::make_shared<OHOSApplication>();
1212     mainThread_->applicationImpl_ = nullptr;
1213     EXPECT_FALSE(mainThread_->IsApplicationReady());
1214     HILOG_INFO("%{public}s end.", __func__);
1215 }
1216 
1217 /**
1218  * @tc.name: CheckFileType_0100
1219  * @tc.desc: CheckFileType.
1220  * @tc.type: FUNC
1221  * @tc.require: issueI64MUJ
1222  */
1223 HWTEST_F(MainThreadTest, CheckFileType_0100, TestSize.Level1)
1224 {
1225     HILOG_INFO("%{public}s start.", __func__);
1226     std::string fileName = "test.testExtension";
1227     std::string extensionName = "testExtension";
1228     EXPECT_FALSE(mainThread_->CheckFileType(fileName, extensionName));
1229     HILOG_INFO("%{public}s end.", __func__);
1230 }
1231 
1232 /**
1233  * @tc.name: CheckFileType_0200
1234  * @tc.desc: CheckFileType.
1235  * @tc.type: FUNC
1236  * @tc.require: issueI64MUJ
1237  */
1238 HWTEST_F(MainThreadTest, CheckFileType_0200, TestSize.Level1)
1239 {
1240     HILOG_INFO("%{public}s start.", __func__);
1241     std::string fileName = "";
1242     std::string extensionName = "testExtension";
1243     EXPECT_FALSE(mainThread_->CheckFileType(fileName, extensionName));
1244     HILOG_INFO("%{public}s end.", __func__);
1245 }
1246 
1247 /**
1248  * @tc.name: CheckFileType_0300
1249  * @tc.desc: CheckFileType.
1250  * @tc.type: FUNC
1251  * @tc.require: issueI64MUJ
1252  */
1253 HWTEST_F(MainThreadTest, CheckFileType_0300, TestSize.Level1)
1254 {
1255     HILOG_INFO("%{public}s start.", __func__);
1256     std::string fileName = "testExtension";
1257     std::string extensionName = "testExtension";
1258     EXPECT_FALSE(mainThread_->CheckFileType(fileName, extensionName));
1259     HILOG_INFO("%{public}s end.", __func__);
1260 }
1261 
1262 /**
1263  * @tc.name: HandleScheduleAcceptWant_0100
1264  * @tc.desc: HandleScheduleAcceptWant.
1265  * @tc.type: FUNC
1266  * @tc.require: issueI64MUJ
1267  */
1268 HWTEST_F(MainThreadTest, HandleScheduleAcceptWant_0100, TestSize.Level1)
1269 {
1270     HILOG_INFO("%{public}s start.", __func__);
1271     Want want;
1272     std::string moduleName;
1273     mainThread_->HandleScheduleAcceptWant(want, moduleName);
1274     HILOG_INFO("%{public}s end.", __func__);
1275 }
1276 
1277 /**
1278  * @tc.name: HandleScheduleAcceptWant_0200
1279  * @tc.desc: HandleScheduleAcceptWant.
1280  * @tc.type: FUNC
1281  * @tc.require: issueI64MUJ
1282  */
1283 HWTEST_F(MainThreadTest, HandleScheduleAcceptWant_0200, TestSize.Level1)
1284 {
1285     HILOG_INFO("%{public}s start.", __func__);
1286     mainThread_->application_ = nullptr;
1287     Want want;
1288     std::string moduleName;
1289     mainThread_->HandleScheduleAcceptWant(want, moduleName);
1290     HILOG_INFO("%{public}s end.", __func__);
1291 }
1292 
1293 /**
1294  * @tc.name: HandleScheduleAcceptWant_0300
1295  * @tc.desc: HandleScheduleAcceptWant.
1296  * @tc.type: FUNC
1297  * @tc.require: issueI64MUJ
1298  */
1299 HWTEST_F(MainThreadTest, HandleScheduleAcceptWant_0300, TestSize.Level1)
1300 {
1301     HILOG_INFO("%{public}s start.", __func__);
1302     mainThread_->appMgr_ = nullptr;
1303     Want want;
1304     std::string moduleName;
1305     mainThread_->HandleScheduleAcceptWant(want, moduleName);
1306     HILOG_INFO("%{public}s end.", __func__);
1307 }
1308 
1309 /**
1310  * @tc.name: HandleScheduleAcceptWant_0400
1311  * @tc.desc: HandleScheduleAcceptWant.
1312  * @tc.type: FUNC
1313  * @tc.require: issueI64MUJ
1314  */
1315 HWTEST_F(MainThreadTest, HandleScheduleAcceptWant_0400, TestSize.Level1)
1316 {
1317     HILOG_INFO("%{public}s start.", __func__);
1318     mainThread_->applicationImpl_ = nullptr;
1319     Want want;
1320     std::string moduleName;
1321     mainThread_->HandleScheduleAcceptWant(want, moduleName);
1322     HILOG_INFO("%{public}s end.", __func__);
1323 }
1324 
1325 #ifdef ABILITY_LIBRARY_LOADER
1326 /*
1327  * Feature: MainThread
1328  * Function: LoadNativeLiabrary
1329  * SubFunction: NA
1330  * FunctionPoints: MainThread LoadNativeLiabrary
1331  * EnvConditions: NA
1332  * CaseDescription: Verify LoadNativeLiabrary
1333  */
1334 HWTEST_F(MainThreadTest, LoadNativeLiabrary_0100, TestSize.Level1)
1335 {
1336     HILOG_INFO("%{public}s start.", __func__);
1337     std::string nativeLibraryPath = "";
1338     mainThread_->LoadNativeLiabrary(nativeLibraryPath);
1339 
1340     nativeLibraryPath = "test/";
1341     mainThread_->LoadNativeLiabrary(nativeLibraryPath);
1342     HILOG_INFO("%{public}s end.", __func__);
1343 }
1344 #endif
1345 
1346 /*
1347  * Feature: MainThread
1348  * Function: TaskTimeoutDetected
1349  * SubFunction: NA
1350  * FunctionPoints: MainThread TaskTimeoutDetected
1351  * EnvConditions: NA
1352  * CaseDescription: Verify TaskTimeoutDetected
1353  */
1354 HWTEST_F(MainThreadTest, TaskTimeoutDetected_0100, TestSize.Level1)
1355 {
1356     HILOG_INFO("%{public}s start.", __func__);
1357     mainThread_->TaskTimeoutDetected(nullptr);
1358 
1359     std::shared_ptr<EventRunner> runner = EventRunner::GetMainEventRunner();
1360     mainThread_->TaskTimeoutDetected(runner);
1361 
1362     mainThread_->mainHandler_.reset();
1363     mainThread_->TaskTimeoutDetected(runner);
1364     HILOG_INFO("%{public}s end.", __func__);
1365 }
1366 
1367 /*
1368  * Feature: MainThread
1369  * Function: HandleDumpHeap
1370  * SubFunction: NA
1371  * FunctionPoints: MainThread HandleDumpHeap
1372  * EnvConditions: NA
1373  * CaseDescription: Verify HandleDumpHeap
1374  */
1375 HWTEST_F(MainThreadTest, HandleDumpHeap_0100, TestSize.Level1)
1376 {
1377     HILOG_INFO("%{public}s start.", __func__);
1378     bool isPrivate = false;
1379     mainThread_->HandleDumpHeap(isPrivate);
1380 
1381     mainThread_->mainHandler_ = nullptr;
1382     mainThread_->HandleDumpHeap(isPrivate);
1383     HILOG_INFO("%{public}s end.", __func__);
1384 }
1385 } // namespace AppExecFwk
1386 } // namespace OHOS