From 309bfe2dfe818b835bb401ec6eb4ea16cb454ec4 Mon Sep 17 00:00:00 2001 From: zhangzezhong Date: Tue, 29 Apr 2025 19:56:52 +0800 Subject: [PATCH] add JsRuntime unittest cases for ability_runtime Signed-off-by: zhangzezhong --- .../unittest/runtime_test/js_runtime_test.cpp | 327 ++++++++++++++++++ ..._ability_lifecycle_manager_second_test.cpp | 280 ++++++++++++++- 2 files changed, 603 insertions(+), 4 deletions(-) diff --git a/test/unittest/runtime_test/js_runtime_test.cpp b/test/unittest/runtime_test/js_runtime_test.cpp index fdbd5aa75c..bf472b6177 100755 --- a/test/unittest/runtime_test/js_runtime_test.cpp +++ b/test/unittest/runtime_test/js_runtime_test.cpp @@ -1526,5 +1526,332 @@ HWTEST_F(JsRuntimeTest, StartProfiler_0100, TestSize.Level1) EXPECT_EQ(jsRuntime->jsEnv_, nullptr); TAG_LOGI(AAFwkTag::TEST, "StartProfiler_0100 end"); } + +/** + * @tc.name: LoadScript_0200 + * @tc.desc: LoadScript + * @tc.type: FUNC + */ +HWTEST_F(JsRuntimeTest, LoadScript_0200, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "LoadScript_0200 start"); + + auto jsRuntime = std::make_unique(); + jsRuntime->jsEnv_ = std::make_shared(); + jsRuntime->jsEnv_->engine_ = nullptr; + + auto ret = jsRuntime->LoadScript("MyPath", nullptr, false); + EXPECT_EQ(ret, false); + + jsRuntime.reset(); + std::this_thread::sleep_for(std::chrono::milliseconds(200)); + TAG_LOGI(AAFwkTag::TEST, "LoadScript_0200 end"); +} + +/** + * @tc.name: LoadScript_0300 + * @tc.desc: LoadScript + * @tc.type: FUNC + */ +HWTEST_F(JsRuntimeTest, LoadScript_0300, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "LoadScript_0300 start"); + + auto jsRuntime = std::make_unique(); + jsRuntime->jsEnv_ = nullptr; + + auto ret = jsRuntime->LoadScript("MyPath", nullptr, 0, false, ""); + EXPECT_EQ(ret, false); + + jsRuntime.reset(); + std::this_thread::sleep_for(std::chrono::milliseconds(200)); + TAG_LOGI(AAFwkTag::TEST, "LoadScript_0300 end"); +} + +/** + * @tc.name: LoadScript_0400 + * @tc.desc: LoadScript + * @tc.type: FUNC + */ +HWTEST_F(JsRuntimeTest, LoadScript_0400, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "LoadScript_0400 start"); + + auto jsRuntime = std::make_unique(); + jsRuntime->jsEnv_ = std::make_shared(); + jsRuntime->isOhmUrl_ = true; + jsRuntime->moduleName_ = "moduleName"; + + auto ret = jsRuntime->LoadScript("MyPath", nullptr, 0, false, ""); + EXPECT_EQ(ret, false); + + jsRuntime.reset(); + std::this_thread::sleep_for(std::chrono::milliseconds(200)); + TAG_LOGI(AAFwkTag::TEST, "LoadScript_0400 end"); +} + +/** + * @tc.name: LoadScript_0500 + * @tc.desc: LoadScript + * @tc.type: FUNC + */ +HWTEST_F(JsRuntimeTest, LoadScript_0500, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "LoadScript_0500 start"); + + auto jsRuntime = std::make_unique(); + jsRuntime->jsEnv_ = std::make_shared(); + jsRuntime->isOhmUrl_ = false; + jsRuntime->moduleName_ = "moduleName"; + + auto ret = jsRuntime->LoadScript("MyPath", nullptr, 0, false, ""); + EXPECT_EQ(ret, false); + + jsRuntime.reset(); + std::this_thread::sleep_for(std::chrono::milliseconds(200)); + TAG_LOGI(AAFwkTag::TEST, "LoadScript_0500 end"); +} + +/** + * @tc.name: LoadSystemModuleByEngine_0200 + * @tc.desc: LoadSystemModuleByEngine + * @tc.type: FUNC + */ +HWTEST_F(JsRuntimeTest, LoadSystemModuleByEngine_0200, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "LoadSystemModuleByEngine_0200 start"); + + auto jsRuntime = std::make_unique(); + jsRuntime->jsEnv_ = std::make_shared(); + napi_env env = {}; + jsRuntime->jsEnv_->engine_ = reinterpret_cast(env); + + auto ret = jsRuntime->LoadSystemModuleByEngine(env, "", nullptr, 0); + EXPECT_EQ(ret, nullptr); + + jsRuntime.reset(); + std::this_thread::sleep_for(std::chrono::milliseconds(200)); + TAG_LOGI(AAFwkTag::TEST, "LoadSystemModuleByEngine_0200 end"); +} + +/** + * @tc.name: Deinitialize_0200 + * @tc.desc: Deinitialize + * @tc.type: FUNC + */ +HWTEST_F(JsRuntimeTest, Deinitialize_0200, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "Deinitialize_0200 start"); + + auto jsRuntime = std::make_unique(); + std::string moduleName = "PreloadSystemModuleTest"; + napi_value object = nullptr; + std::unique_ptr nativeRef = jsRuntime->LoadSystemModule(moduleName, &object, 0); + jsRuntime->modules_.emplace("moduleName", nativeRef.get()); + jsRuntime->jsEnv_ = nullptr; + + jsRuntime->Deinitialize(); + EXPECT_EQ(jsRuntime->modules_.size(), 0); + + jsRuntime.reset(); + std::this_thread::sleep_for(std::chrono::milliseconds(200)); + TAG_LOGI(AAFwkTag::TEST, "Deinitialize_0200 end"); +} + +/** + * @tc.name: RunScript_0200 + * @tc.desc: RunScript + * @tc.type: FUNC + */ +HWTEST_F(JsRuntimeTest, RunScript_0200, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "RunScript_0200 start"); + + auto jsRuntime = std::make_unique(); + jsRuntime->jsEnv_ = std::make_shared(); + panda::RuntimeOption pandaOption; + jsRuntime->jsEnv_->vm_ = panda::JSNApi::CreateJSVM(pandaOption); + + auto ret = jsRuntime->RunScript("", "", false); + EXPECT_EQ(ret, false); + + jsRuntime.reset(); + std::this_thread::sleep_for(std::chrono::milliseconds(200)); + TAG_LOGI(AAFwkTag::TEST, "RunScript_0200 end"); +} + +/** + * @tc.name: RunScript_0300 + * @tc.desc: RunScript + * @tc.type: FUNC + */ +HWTEST_F(JsRuntimeTest, RunScript_0300, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "RunScript_0300 start"); + + auto jsRuntime = std::make_unique(); + jsRuntime->jsEnv_ = std::make_shared(); + panda::RuntimeOption pandaOption; + jsRuntime->jsEnv_->vm_ = panda::JSNApi::CreateJSVM(pandaOption); + + auto ret = jsRuntime->RunScript("MockPath", "", true); + EXPECT_EQ(ret, false); + + jsRuntime.reset(); + std::this_thread::sleep_for(std::chrono::milliseconds(200)); + TAG_LOGI(AAFwkTag::TEST, "RunScript_0300 end"); +} + +/** + * @tc.name: RunSandboxScript_0300 + * @tc.desc: RunSandboxScript + * @tc.type: FUNC + */ +HWTEST_F(JsRuntimeTest, RunSandboxScript_0300, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "RunSandboxScript_0300 start"); + + auto jsRuntime = std::make_unique(); + std::string bundleName(PATH_MAX, 'a'); + const std::string& codePath = bundleName; + const std::string& modulePath = ""; + std::string fileName = ""; + jsRuntime->codePath_ = codePath; + + auto ret = jsRuntime->RunSandboxScript(modulePath, fileName); + EXPECT_EQ(ret, false); + + jsRuntime.reset(); + std::this_thread::sleep_for(std::chrono::milliseconds(200)); + TAG_LOGI(AAFwkTag::TEST, "RunSandboxScript_0300 end"); +} + +/** + * @tc.name: RunSandboxScript_0300 + * @tc.desc: RunSandboxScript + * @tc.type: FUNC + */ +HWTEST_F(JsRuntimeTest, RunSandboxScript_0400, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "RunSandboxScript_0400 start"); + + auto jsRuntime = std::make_unique(); + std::string bundleName(PATH_MAX, 'a'); + const std::string& codePath = bundleName; + const std::string& modulePath = ""; + std::string fileName = "HelloWorld"; + jsRuntime->codePath_ = codePath; + + auto ret = jsRuntime->RunSandboxScript(modulePath, fileName); + EXPECT_EQ(ret, false); + + jsRuntime.reset(); + std::this_thread::sleep_for(std::chrono::milliseconds(200)); + TAG_LOGI(AAFwkTag::TEST, "RunSandboxScript_0400 end"); +} + +/** + * @tc.name: RemoveTask_0300 + * @tc.desc: RemoveTask + * @tc.type: FUNC + */ +HWTEST_F(JsRuntimeTest, RemoveTask_0300, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "RemoveTask_0300 start"); + + auto jsRuntime = std::make_unique(); + jsRuntime->jsEnv_ = std::make_shared(); + std::string taskName = "removeTask003"; + bool taskExecuted = false; + auto task = [taskName, &taskExecuted]() { + TAG_LOGI(AAFwkTag::TEST, "%{public}s called.", taskName.c_str()); + taskExecuted = true; + }; + int64_t delayTime = 20; + jsRuntime->PostTask(task, taskName, delayTime); + jsRuntime->RemoveTask(taskName); + std::this_thread::sleep_for(std::chrono::milliseconds(1000)); + EXPECT_EQ(taskExecuted, false); + + jsRuntime.reset(); + std::this_thread::sleep_for(std::chrono::milliseconds(200)); + TAG_LOGI(AAFwkTag::TEST, "RemoveTask_0300 end"); +} + +/** + * @tc.name: SuspendVM_0200 + * @tc.desc: SuspendVM + * @tc.type: FUNC + */ +HWTEST_F(JsRuntimeTest, SuspendVM_0200, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "SuspendVM_0200 start"); + + auto jsRuntime = std::make_unique(); + jsRuntime->jsEnv_ = std::make_shared(); + napi_env env = {}; + jsRuntime->jsEnv_->engine_ = reinterpret_cast(env); + auto ret = jsRuntime->SuspendVM(3); + EXPECT_EQ(ret, false); + + jsRuntime.reset(); + std::this_thread::sleep_for(std::chrono::milliseconds(200)); + TAG_LOGI(AAFwkTag::TEST, "SuspendVM_0200 end"); +} + +/** + * @tc.name: PopPreloadObj_0100 + * @tc.desc: PopPreloadObj + * @tc.type: FUNC + */ +HWTEST_F(JsRuntimeTest, PopPreloadObj_0100, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "PopPreloadObj_0100 start"); + + auto jsRuntime = std::make_unique(); + napi_ref ref = nullptr; + napi_value value = {}; + napi_env env_ = {}; + napi_create_reference(env_, value, 1, &ref); + auto navRef = std::unique_ptr(reinterpret_cast(ref)); + std::map> preloadObjMap; + preloadObjMap.emplace("PreloadObj", nullptr); + preloadObjMap.emplace("PreloadObj1", std::move(navRef)); + jsRuntime->preloadList_ = std::move(preloadObjMap); + + std::unique_ptr obj = nullptr; + auto ret = jsRuntime->PopPreloadObj("PreloadObj", obj); + EXPECT_EQ(ret, false); + EXPECT_EQ(obj, nullptr); + EXPECT_EQ(jsRuntime->preloadList_.size(), 1); + + jsRuntime.reset(); + std::this_thread::sleep_for(std::chrono::milliseconds(200)); + TAG_LOGI(AAFwkTag::TEST, "PopPreloadObj_0100 end"); +} + +/** + * @tc.name: UpdateModuleNameAndAssetPath_0400 + * @tc.desc: UpdateModuleNameAndAssetPath + * @tc.type: FUNC + */ +HWTEST_F(JsRuntimeTest, UpdateModuleNameAndAssetPath_0400, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "UpdateModuleNameAndAssetPath_0400 start"); + + auto jsRuntime = std::make_unique(); + jsRuntime->jsEnv_ = std::make_shared(); + jsRuntime->isBundle_ = false; + panda::RuntimeOption pandaOption; + jsRuntime->jsEnv_->vm_ = panda::JSNApi::CreateJSVM(pandaOption); + jsRuntime->moduleName_ = ""; + + jsRuntime->UpdateModuleNameAndAssetPath("moduleName"); + EXPECT_EQ(jsRuntime->moduleName_, "moduleName"); + + jsRuntime.reset(); + std::this_thread::sleep_for(std::chrono::milliseconds(200)); + TAG_LOGI(AAFwkTag::TEST, "UpdateModuleNameAndAssetPath_0400 end"); +} } // namespace AbilityRuntime } // namespace OHOS \ No newline at end of file diff --git a/test/unittest/ui_ability_lifecycle_manager_second_test/ui_ability_lifecycle_manager_second_test.cpp b/test/unittest/ui_ability_lifecycle_manager_second_test/ui_ability_lifecycle_manager_second_test.cpp index 0969e5e989..53f0f0d37d 100644 --- a/test/unittest/ui_ability_lifecycle_manager_second_test/ui_ability_lifecycle_manager_second_test.cpp +++ b/test/unittest/ui_ability_lifecycle_manager_second_test/ui_ability_lifecycle_manager_second_test.cpp @@ -20,6 +20,7 @@ #define private public #define protected public #include "ability_record.h" +#include "app_mgr_util.h" #include "scene_board/ui_ability_lifecycle_manager.h" #undef protected #undef private @@ -766,16 +767,287 @@ HWTEST_F(UIAbilityLifecycleManagerSecondTest, PrepareCloseUIAbility_001, TestSiz HWTEST_F(UIAbilityLifecycleManagerSecondTest, NotifySCBToHandleAtomicServiceException_001, TestSize.Level1) { auto mgr = std::make_shared(); - auto sessionInfo = std::make_shared(); - Rosen::SessionInfo info1; - auto session = std::make_shared(info1); + auto sessionInfo = sptr::MakeSptr(); sessionInfo->sessionToken = nullptr; sessionInfo->errorCode = 0; std::string errorReason = ""; - mgr->NotifySCBToHandleAtomicServiceException(nullptr, 5, errorReason); + mgr->NotifySCBToHandleAtomicServiceException(sessionInfo, 5, errorReason); EXPECT_EQ(sessionInfo->errorCode, 0); } + +/** + * @tc.name: UIAbilityLifecycleManager_PrepareTerminateAbilityDone_0100 + * @tc.desc: PrepareTerminateAbilityDone + * @tc.type: FUNC + */ +HWTEST_F(UIAbilityLifecycleManagerSecondTest, PrepareTerminateAbilityDone_001, TestSize.Level1) +{ + auto mgr = std::make_shared(); + AbilityRequest abilityRequest; + auto abilityRecord = std::make_shared( + abilityRequest.want, abilityRequest.abilityInfo, abilityRequest.appInfo, abilityRequest.requestCode); + abilityRecord->isPrepareTerminate_ = true; + + mgr->PrepareTerminateAbilityDone(abilityRecord, false); + EXPECT_EQ(abilityRecord->isPrepareTerminate_, true); +} + +/** + * @tc.name: UIAbilityLifecycleManager_PrepareTerminateAbilityDone_0200 + * @tc.desc: PrepareTerminateAbilityDone + * @tc.type: FUNC + */ +HWTEST_F(UIAbilityLifecycleManagerSecondTest, PrepareTerminateAbilityDone_002, TestSize.Level1) +{ + auto mgr = std::make_shared(); + AbilityRequest abilityRequest; + auto abilityRecord = std::make_shared( + abilityRequest.want, abilityRequest.abilityInfo, abilityRequest.appInfo, abilityRequest.requestCode); + abilityRecord->isPrepareTerminate_ = true; + abilityRecord->isPrepareTerminateAbilityCalled_.store(true); + + mgr->PrepareTerminateAbilityDone(abilityRecord, false); + EXPECT_EQ(abilityRecord->isPrepareTerminate_, false); +} + +/** + * @tc.name: UIAbilityLifecycleManager_CheckPrepareTerminateTokens_0100 + * @tc.desc: CheckPrepareTerminateTokens + * @tc.type: FUNC + */ +HWTEST_F(UIAbilityLifecycleManagerSecondTest, CheckPrepareTerminateTokens_001, TestSize.Level1) +{ + auto mgr = std::make_shared(); + std::vector> tokens = {}; + uint32_t tokenId = 0; + std::map>> tokensPerModuleName = {}; + AppUtils::isStartOptionsWithAnimation_ = true; + + auto ret = mgr->CheckPrepareTerminateTokens(tokens, tokenId, tokensPerModuleName); + EXPECT_EQ(ret, false); +} + +/** + * @tc.name: UIAbilityLifecycleManager_CancelPrepareTerminate_0100 + * @tc.desc: CancelPrepareTerminate + * @tc.type: FUNC + */ +HWTEST_F(UIAbilityLifecycleManagerSecondTest, CancelPrepareTerminate_001, TestSize.Level1) +{ + auto mgr = std::make_shared(); + auto prepareTerminateByPidRecords1 = std::make_shared( + 1, + "HelloWorld", + false, + 0, + false + ); + auto prepareTerminateByPidRecords2 = std::make_shared( + 2, + "HiWorld", + false, + 0, + false + ); + mgr->prepareTerminateByPidRecords_.emplace_back(prepareTerminateByPidRecords1); + mgr->prepareTerminateByPidRecords_.emplace_back(prepareTerminateByPidRecords2); + AbilityRequest abilityRequest; + auto abilityRecord = std::make_shared( + abilityRequest.want, abilityRequest.abilityInfo, abilityRequest.appInfo, abilityRequest.requestCode); + abilityRecord->pid_ = 1; + abilityRecord->abilityInfo_.moduleName = "HelloWorld"; + + mgr->CancelPrepareTerminate(abilityRecord); + auto recordSize = mgr->prepareTerminateByPidRecords_.size(); + EXPECT_EQ(recordSize, 1); +} + +/** + * @tc.name: UIAbilityLifecycleManager_CleanUIAbility_0100 + * @tc.desc: CleanUIAbility + * @tc.type: FUNC + */ +HWTEST_F(UIAbilityLifecycleManagerSecondTest, CleanUIAbility_001, TestSize.Level1) +{ + auto mgr = std::make_shared(); + + auto ret = mgr->CleanUIAbility(nullptr); + EXPECT_EQ(ret, ERR_INVALID_VALUE); +} + +/** + * @tc.name: UIAbilityLifecycleManager_TryProcessHookModule_0400 + * @tc.desc: TryProcessHookModule + * @tc.type: FUNC + */ +HWTEST_F(UIAbilityLifecycleManagerSecondTest, TryProcessHookModule_004, TestSize.Level1) +{ + auto mgr = std::make_shared(); + AbilityRequest abilityRequest; + auto specifiedRequest = std::make_shared(100, abilityRequest); + + auto ret = mgr->TryProcessHookModule(*specifiedRequest, false); + EXPECT_EQ(ret, false); +} + +/** + * @tc.name: UIAbilityLifecycleManager_TryProcessHookModule_0500 + * @tc.desc: TryProcessHookModule + * @tc.type: FUNC + */ +HWTEST_F(UIAbilityLifecycleManagerSecondTest, TryProcessHookModule_005, TestSize.Level1) +{ + auto mgr = std::make_shared(); + mgr->sessionAbilityMap_.clear(); + AbilityRequest abilityRequest; + auto specifiedRequest = std::make_shared(100, abilityRequest); + + auto ret = mgr->TryProcessHookModule(*specifiedRequest, true); + EXPECT_EQ(ret, false); +} + +/** + * @tc.name: UIAbilityLifecycleManager_TryProcessHookModule_0600 + * @tc.desc: TryProcessHookModule + * @tc.type: FUNC + */ +HWTEST_F(UIAbilityLifecycleManagerSecondTest, TryProcessHookModule_006, TestSize.Level1) +{ + auto mgr = std::make_shared(); + + int32_t appIndex = 0; + AbilityRequest abilityRequest; + auto abilityRecord = std::make_shared( + abilityRequest.want, abilityRequest.abilityInfo, abilityRequest.appInfo, abilityRequest.requestCode); + abilityRecord->SetIsHook(true); + abilityRecord->SetHookOff(false); + abilityRecord->abilityInfo_.bundleName = "HelloWorld"; + abilityRecord->abilityInfo_.moduleName = "HelloWorld"; + abilityRecord->SetInstanceKey("HelloWorld"); + + mgr->sessionAbilityMap_.clear(); + mgr->sessionAbilityMap_.emplace(1, abilityRecord); + + AbilityRequest abilityRequest2; + abilityRequest2.abilityInfo.bundleName = "HelloWorld"; + abilityRequest2.abilityInfo.moduleName = "HelloWorld"; + abilityRequest2.want.SetParam(Want::APP_INSTANCE_KEY, std::string("HelloWorld")); + AbilityRuntime::StartupUtil::GetAppIndex(abilityRequest2.want, appIndex); + abilityRecord->SetAppIndex(appIndex); + + auto specifiedRequest = std::make_shared(100, abilityRequest2); + + auto ret = mgr->TryProcessHookModule(*specifiedRequest, true); + EXPECT_EQ(ret, true); +} + +/** + * @tc.name: UIAbilityLifecycleManager_RemoveAbilityRequest_0100 + * @tc.desc: RemoveAbilityRequest + * @tc.type: FUNC + */ +HWTEST_F(UIAbilityLifecycleManagerSecondTest, RemoveAbilityRequest_001, TestSize.Level1) +{ + auto mgr = std::make_shared(); + mgr->startAbilityCheckMap_.clear(); + mgr->startAbilityCheckMap_.emplace(1, nullptr); + mgr->startAbilityCheckMap_.emplace(3, nullptr); + mgr->startAbilityCheckMap_.emplace(5, nullptr); + + mgr->RemoveAbilityRequest(5); + EXPECT_EQ(mgr->startAbilityCheckMap_.size(), 2); +} + +/** + * @tc.name: UIAbilityLifecycleManager_AddSpecifiedRequest_0100 + * @tc.desc: AddSpecifiedRequest + * @tc.type: FUNC + */ +HWTEST_F(UIAbilityLifecycleManagerSecondTest, AddSpecifiedRequest_001, TestSize.Level1) +{ + auto mgr = std::make_shared(); + mgr->specifiedRequestList_.clear(); + + mgr->AddSpecifiedRequest(nullptr); + EXPECT_EQ(mgr->specifiedRequestList_.size(), 0); +} + +/** + * @tc.name: UIAbilityLifecycleManager_AddSpecifiedRequest_0200 + * @tc.desc: AddSpecifiedRequest + * @tc.type: FUNC + */ +HWTEST_F(UIAbilityLifecycleManagerSecondTest, AddSpecifiedRequest_002, TestSize.Level1) +{ + auto mgr = std::make_shared(); + mgr->specifiedRequestList_.clear(); + + AbilityRequest abilityRequest; + auto request = std::make_shared(1, abilityRequest); + + mgr->AddSpecifiedRequest(request); + EXPECT_EQ(mgr->specifiedRequestList_.size(), 1); +} + +/** + * @tc.name: UIAbilityLifecycleManager_IsSpecifiedModuleLoaded_0200 + * @tc.desc: IsSpecifiedModuleLoaded + * @tc.type: FUNC + */ +HWTEST_F(UIAbilityLifecycleManagerSecondTest, IsSpecifiedModuleLoaded_002, TestSize.Level1) +{ + auto mgr = std::make_shared(); + AppMgrUtil::appMgr_= nullptr; + AbilityRequest abilityRequest; + + auto ret = mgr->IsSpecifiedModuleLoaded(abilityRequest); + EXPECT_EQ(ret, false); +} + +/** + * @tc.name: UIAbilityLifecycleManager_HandleColdAcceptWantDone_0100 + * @tc.desc: HandleColdAcceptWantDone + * @tc.type: FUNC + */ +HWTEST_F(UIAbilityLifecycleManagerSecondTest, HandleColdAcceptWantDone_001, TestSize.Level1) +{ + auto mgr = std::make_shared(); + AAFwk::Want want; + std::string flag = ""; + AbilityRequest abilityRequest; + SpecifiedRequest specifiedRequest(1, abilityRequest); + + mgr->sessionAbilityMap_.clear(); + + auto ret = mgr->HandleColdAcceptWantDone(want, flag, specifiedRequest); + EXPECT_EQ(ret, false); +} + +/** + * @tc.name: UIAbilityLifecycleManager_HandleColdAcceptWantDone_0200 + * @tc.desc: HandleColdAcceptWantDone + * @tc.type: FUNC + */ +HWTEST_F(UIAbilityLifecycleManagerSecondTest, HandleColdAcceptWantDone_002, TestSize.Level1) +{ + auto mgr = std::make_shared(); + AAFwk::Want want; + std::string flag = ""; + AbilityRequest abilityRequest; + SpecifiedRequest specifiedRequest(1, abilityRequest); + specifiedRequest.persistentId = 1; + + auto abilityRecord = std::make_shared( + abilityRequest.want, abilityRequest.abilityInfo, abilityRequest.appInfo, abilityRequest.requestCode); + abilityRecord->specifiedFlag_ = ""; + + mgr->sessionAbilityMap_.clear(); + mgr->sessionAbilityMap_.emplace(1, abilityRecord); + + auto ret = mgr->HandleColdAcceptWantDone(want, flag, specifiedRequest); + EXPECT_EQ(ret, true); +} } // namespace AAFwk } // namespace OHOS \ No newline at end of file