add JsRuntime unittest cases for ability_runtime

Signed-off-by: zhangzezhong <zhangzezhong8@huawei-partners.com>
This commit is contained in:
zhangzezhong
2025-04-29 19:56:52 +08:00
parent a1d5d13f2b
commit 309bfe2dfe
2 changed files with 603 additions and 4 deletions
@@ -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>();
jsRuntime->jsEnv_ = std::make_shared<JsEnv::JsEnvironment>();
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>();
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>();
jsRuntime->jsEnv_ = std::make_shared<JsEnv::JsEnvironment>();
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>();
jsRuntime->jsEnv_ = std::make_shared<JsEnv::JsEnvironment>();
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>();
jsRuntime->jsEnv_ = std::make_shared<JsEnv::JsEnvironment>();
napi_env env = {};
jsRuntime->jsEnv_->engine_ = reinterpret_cast<NativeEngine*>(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<AbilityRuntime::JsRuntime>();
std::string moduleName = "PreloadSystemModuleTest";
napi_value object = nullptr;
std::unique_ptr<NativeReference> 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>();
jsRuntime->jsEnv_ = std::make_shared<JsEnv::JsEnvironment>();
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>();
jsRuntime->jsEnv_ = std::make_shared<JsEnv::JsEnvironment>();
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<JsRuntime>();
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<JsRuntime>();
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>();
jsRuntime->jsEnv_ = std::make_shared<JsEnv::JsEnvironment>();
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>();
jsRuntime->jsEnv_ = std::make_shared<JsEnv::JsEnvironment>();
napi_env env = {};
jsRuntime->jsEnv_->engine_ = reinterpret_cast<NativeEngine*>(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<JsRuntime>();
napi_ref ref = nullptr;
napi_value value = {};
napi_env env_ = {};
napi_create_reference(env_, value, 1, &ref);
auto navRef = std::unique_ptr<NativeReference>(reinterpret_cast<NativeReference *>(ref));
std::map<std::string, std::unique_ptr<NativeReference>> preloadObjMap;
preloadObjMap.emplace("PreloadObj", nullptr);
preloadObjMap.emplace("PreloadObj1", std::move(navRef));
jsRuntime->preloadList_ = std::move(preloadObjMap);
std::unique_ptr<NativeReference> 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>();
jsRuntime->jsEnv_ = std::make_shared<JsEnv::JsEnvironment>();
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
@@ -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<UIAbilityLifecycleManager>();
auto sessionInfo = std::make_shared<SessionInfo>();
Rosen::SessionInfo info1;
auto session = std::make_shared<Rosen::Session>(info1);
auto sessionInfo = sptr<SessionInfo>::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<UIAbilityLifecycleManager>();
AbilityRequest abilityRequest;
auto abilityRecord = std::make_shared<AbilityRecord>(
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<UIAbilityLifecycleManager>();
AbilityRequest abilityRequest;
auto abilityRecord = std::make_shared<AbilityRecord>(
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<UIAbilityLifecycleManager>();
std::vector<sptr<IRemoteObject>> tokens = {};
uint32_t tokenId = 0;
std::map<std::string, std::vector<sptr<IRemoteObject>>> 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<UIAbilityLifecycleManager>();
auto prepareTerminateByPidRecords1 = std::make_shared<UIAbilityLifecycleManager::PrepareTerminateByPidRecord>(
1,
"HelloWorld",
false,
0,
false
);
auto prepareTerminateByPidRecords2 = std::make_shared<UIAbilityLifecycleManager::PrepareTerminateByPidRecord>(
2,
"HiWorld",
false,
0,
false
);
mgr->prepareTerminateByPidRecords_.emplace_back(prepareTerminateByPidRecords1);
mgr->prepareTerminateByPidRecords_.emplace_back(prepareTerminateByPidRecords2);
AbilityRequest abilityRequest;
auto abilityRecord = std::make_shared<AbilityRecord>(
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<UIAbilityLifecycleManager>();
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<UIAbilityLifecycleManager>();
AbilityRequest abilityRequest;
auto specifiedRequest = std::make_shared<AAFwk::SpecifiedRequest>(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<UIAbilityLifecycleManager>();
mgr->sessionAbilityMap_.clear();
AbilityRequest abilityRequest;
auto specifiedRequest = std::make_shared<AAFwk::SpecifiedRequest>(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<UIAbilityLifecycleManager>();
int32_t appIndex = 0;
AbilityRequest abilityRequest;
auto abilityRecord = std::make_shared<AbilityRecord>(
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<AAFwk::SpecifiedRequest>(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<UIAbilityLifecycleManager>();
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<UIAbilityLifecycleManager>();
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<UIAbilityLifecycleManager>();
mgr->specifiedRequestList_.clear();
AbilityRequest abilityRequest;
auto request = std::make_shared<SpecifiedRequest>(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<UIAbilityLifecycleManager>();
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<UIAbilityLifecycleManager>();
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<UIAbilityLifecycleManager>();
AAFwk::Want want;
std::string flag = "";
AbilityRequest abilityRequest;
SpecifiedRequest specifiedRequest(1, abilityRequest);
specifiedRequest.persistentId = 1;
auto abilityRecord = std::make_shared<AbilityRecord>(
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