!700 appspawn 覆盖率

Merge pull request !700 from cheng_jinsong/appspawn_cov
This commit is contained in:
openharmony_ci 2023-07-12 04:51:33 +00:00 committed by Gitee
commit 2c5e4615ee
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 23 additions and 1 deletions

View File

@ -61,6 +61,7 @@ static void GetPreloadModules(const std::string &configName, std::set<std::strin
static void PreloadModule(void)
{
#ifndef APPSPAWN_TEST
OHOS::AbilityRuntime::Runtime::Options options;
options.lang = OHOS::AbilityRuntime::Runtime::Language::JS;
options.loadAce = true;
@ -71,6 +72,7 @@ static void PreloadModule(void)
APPSPAWN_LOGE("LoadExtendLib: Failed to create runtime");
return;
}
#endif
std::set<std::string> modules = {};
CfgFiles *files = GetCfgFiles("etc/appspawn");
if (files == nullptr) {
@ -89,10 +91,14 @@ static void PreloadModule(void)
FreeCfgFiles(files);
for (std::string moduleName : modules) {
APPSPAWN_LOGI("moduleName %{public}s", moduleName.c_str());
#ifndef APPSPAWN_TEST
runtime->PreloadSystemModule(moduleName);
#endif
}
#ifndef APPSPAWN_TEST
// Save preloaded runtime
OHOS::AbilityRuntime::Runtime::SavePreloaded(std::move(runtime));
#endif
}
void LoadExtendLib(AppSpawnContent *content)

View File

@ -558,6 +558,22 @@ HWTEST(AppSpawnStandardTest, App_Spawn_Standard_005, TestSize.Level0)
ret = SetAppSandboxProperty((AppSpawnContent_*)content, &clientExt->client);
EXPECT_EQ(ret, 0);
// APP_NO_SANDBOX
clientExt->property.flags |= APP_NO_SANDBOX;
ret = SetAppSandboxProperty((AppSpawnContent_*)content, &clientExt->client);
EXPECT_EQ(ret, 0);
clientExt->property.flags &= ~APP_NO_SANDBOX;
// bundle name
clientExt->property.hspList.data = strdup("{ \
\"bundles\":[\"test.bundle1\", \"test.bundle2\"], \
\"modules\":[\"module1\", \"module2\"], \
\"versions\":[\"v10001\", \"v10002\"] \
}");
clientExt->property.hspList.totalLength = strlen(clientExt->property.hspList.data);
ret = SetAppSandboxProperty((AppSpawnContent_*)content, &clientExt->client);
EXPECT_EQ(ret, 0);
free(content);
GTEST_LOG_(INFO) << "App_Spawn_Standard_005 end";
}
@ -689,7 +705,7 @@ HWTEST(AppSpawnStandardTest, App_Spawn_Standard_006_4, TestSize.Level0)
{
GTEST_LOG_(INFO) << "App_Spawn_Standard_006_4 start";
SetHapDomainSetcontextResult(-1);
SetParameter("const.appspawn.preload", "false");
AppSpawnContentExt *content = TestClient(APP_COLD_BOOT,
DEFAULT, "com.ohos.medialibrary.medialibrarydata", "test006_2");
ASSERT_TRUE(content != nullptr);