From 4092bb3dc9ba04bef18dffac202addce287926af Mon Sep 17 00:00:00 2001 From: zhaoyuan17 Date: Thu, 28 Oct 2021 18:58:13 +0000 Subject: [PATCH] Delete BMS ut Signed-off-by: zhaoyuan17 --- services/bundlemgr/test/BUILD.gn | 1 - .../bms_bundle_installer_test.cpp | 253 --------- .../bms_bundle_kit_service_test.cpp | 365 +++++++----- .../bms_bundle_parser_test.cpp | 106 +--- .../bms_bundle_permission_test.cpp | 175 +++--- .../bms_bundle_uninstaller_test.cpp | 289 ---------- .../unittest/bms_bundle_updater_test/BUILD.gn | 93 --- .../bms_bundle_updater_test.cpp | 532 ------------------ .../bms_data_mgr_test/bms_data_mgr_test.cpp | 30 - .../bms_install_daemon_test.cpp | 62 +- 10 files changed, 304 insertions(+), 1602 deletions(-) delete mode 100755 services/bundlemgr/test/unittest/bms_bundle_updater_test/BUILD.gn delete mode 100755 services/bundlemgr/test/unittest/bms_bundle_updater_test/bms_bundle_updater_test.cpp diff --git a/services/bundlemgr/test/BUILD.gn b/services/bundlemgr/test/BUILD.gn index 7d4582a6d7..504939840f 100644 --- a/services/bundlemgr/test/BUILD.gn +++ b/services/bundlemgr/test/BUILD.gn @@ -44,7 +44,6 @@ group("unittest") { "unittest/bms_bundle_parser_test:unittest", "unittest/bms_bundle_permission_test:unittest", "unittest/bms_bundle_uninstaller_test:unittest", - "unittest/bms_bundle_updater_test:unittest", "unittest/bms_data_mgr_test:unittest", "unittest/bms_install_daemon_test:unittest", "unittest/bms_service_bundle_scan_test:unittest", diff --git a/services/bundlemgr/test/unittest/bms_bundle_installer_test/bms_bundle_installer_test.cpp b/services/bundlemgr/test/unittest/bms_bundle_installer_test/bms_bundle_installer_test.cpp index 58cc1e42ef..d418082c06 100755 --- a/services/bundlemgr/test/unittest/bms_bundle_installer_test/bms_bundle_installer_test.cpp +++ b/services/bundlemgr/test/unittest/bms_bundle_installer_test/bms_bundle_installer_test.cpp @@ -251,21 +251,6 @@ void BmsBundleInstallerTest::ClearBundleInfoInDb() EXPECT_TRUE(result) << "the bundle info in db clear fail: " << BUNDLE_NAME; } -/** - * @tc.number: SystemInstall_0100 - * @tc.name: test the right system bundle file can be installed - * @tc.desc: 1.the system bundle file exists - * 2.the system bundle can be installed successfully and can get the bundle info - */ -HWTEST_F(BmsBundleInstallerTest, SystemInstall_0100, Function | SmallTest | Level0) -{ - std::string bundleFile = RESOURCE_ROOT_PATH + RIGHT_BUNDLE; - bool result = InstallSystemBundle(bundleFile); - EXPECT_TRUE(result) << "the bundle file install failed: " << bundleFile; - CheckFileExist(); - ClearBundleInfoInDb(); -} - /** * @tc.number: SystemInstall_0200 * @tc.name: test the wrong system bundle file can't be installed @@ -349,71 +334,6 @@ HWTEST_F(BmsBundleInstallerTest, SystemInstall_0700, Function | SmallTest | Leve EXPECT_FALSE(result); } -/** - * @tc.number: SystemUpdateData_0100 - * @tc.name: test the right bundle file can be installed and update its info to bms - * @tc.desc: 1.the system bundle is available - * 2.the right bundle can be installed and update its info to bms - */ -HWTEST_F(BmsBundleInstallerTest, SystemUpdateData_0100, Function | SmallTest | Level0) -{ - ApplicationInfo info; - auto dataMgr = GetBundleDataMgr(); - EXPECT_NE(dataMgr, nullptr); - bool result = dataMgr->GetApplicationInfo(BUNDLE_NAME, ApplicationFlag::GET_BASIC_APPLICATION_INFO, USERID, info); - EXPECT_FALSE(result); - std::string bundleFile = RESOURCE_ROOT_PATH + RIGHT_BUNDLE; - bool installResult = InstallSystemBundle(bundleFile); - EXPECT_TRUE(installResult); - result = dataMgr->GetApplicationInfo(BUNDLE_NAME, ApplicationFlag::GET_BASIC_APPLICATION_INFO, USERID, info); - EXPECT_TRUE(result); - EXPECT_EQ(info.name, BUNDLE_NAME); - ClearBundleInfoInDb(); -} - -/** - * @tc.number: SystemUpdateData_0200 - * @tc.name: test the wrong bundle file can't be installed and its info will not updated to bms - * @tc.desc: 1.the system bundle is wrong - * 2.the wrong bundle can't be installed and its info will not updated to bms - */ -HWTEST_F(BmsBundleInstallerTest, SystemUpdateData_0200, Function | SmallTest | Level0) -{ - ApplicationInfo info; - auto dataMgr = GetBundleDataMgr(); - EXPECT_NE(dataMgr, nullptr); - bool result = dataMgr->GetApplicationInfo(BUNDLE_NAME, ApplicationFlag::GET_BASIC_APPLICATION_INFO, USERID, info); - EXPECT_FALSE(result); - std::string wrongBundleName = RESOURCE_ROOT_PATH + WRONG_BUNDLE_NAME; - bool installResult = InstallSystemBundle(wrongBundleName); - EXPECT_FALSE(installResult); - result = dataMgr->GetApplicationInfo(BUNDLE_NAME, ApplicationFlag::GET_BASIC_APPLICATION_INFO, USERID, info); - EXPECT_FALSE(result); -} - -/** - * @tc.number: SystemUpdateData_0300 - * @tc.name: test the already installed bundle can't be reinstalled and update its info to bms - * @tc.desc: 1.the bundle is already installed - * 2.the already installed bundle can't be reinstalled and update its info to bms - */ -HWTEST_F(BmsBundleInstallerTest, SystemUpdateData_0300, Function | SmallTest | Level0) -{ - auto dataMgr = GetBundleDataMgr(); - EXPECT_NE(dataMgr, nullptr); - // prepare already install information. - std::string bundleFile = RESOURCE_ROOT_PATH + RIGHT_BUNDLE; - bool firstInstall = InstallSystemBundle(bundleFile); - EXPECT_TRUE(firstInstall); - ApplicationInfo info; - auto result = dataMgr->GetApplicationInfo(BUNDLE_NAME, ApplicationFlag::GET_BASIC_APPLICATION_INFO, USERID, info); - EXPECT_TRUE(result); - EXPECT_EQ(info.name, BUNDLE_NAME); - bool secondInstall = InstallSystemBundle(bundleFile); - EXPECT_FALSE(secondInstall); - ClearBundleInfoInDb(); -} - /** * @tc.number: SystemUpdateData_0400 * @tc.name: test the already installing bundle can't be reinstalled and update its info to bms @@ -434,25 +354,6 @@ HWTEST_F(BmsBundleInstallerTest, SystemUpdateData_0400, Function | SmallTest | L dataMgr->UpdateBundleInstallState(BUNDLE_NAME, InstallState::INSTALL_FAIL); } -/** - * @tc.number: CreateInstallTask_0100 - * @tc.name: test the installer manager can create task - * @tc.desc: 1.the bundle file exists - * 2.the bundle can be installed successfully - */ -HWTEST_F(BmsBundleInstallerTest, CreateInstallTask_0100, Function | SmallTest | Level0) -{ - CreateInstallerManager(); - sptr receiver = new (std::nothrow) MockStatusReceiver(); - EXPECT_NE(receiver, nullptr); - InstallParam installParam; - std::string bundleFile = RESOURCE_ROOT_PATH + RIGHT_BUNDLE; - GetBundleInstallerManager()->CreateInstallTask(bundleFile, installParam, receiver); - ErrCode result = receiver->GetResultCode(); - EXPECT_EQ(ERR_OK, result); - ClearBundleInfoInDb(); -} - /** * @tc.number: CreateInstallTask_0200 * @tc.name: test the installer manager can not create task while bundle invalid @@ -471,29 +372,6 @@ HWTEST_F(BmsBundleInstallerTest, CreateInstallTask_0200, Function | SmallTest | EXPECT_NE(ERR_OK, result); } -/** - * @tc.number: CreateUninstallTask_0100 - * @tc.name: test the installer manager can create task - * @tc.desc: 1.the bundle file exists - * 2.the bundle can be install and uninstalled successfully - */ -HWTEST_F(BmsBundleInstallerTest, CreateUninstallTask_0100, Function | SmallTest | Level0) -{ - CreateInstallerManager(); - sptr receiver = new (std::nothrow) MockStatusReceiver(); - EXPECT_NE(receiver, nullptr); - InstallParam installParam; - std::string bundleFile = RESOURCE_ROOT_PATH + RIGHT_BUNDLE; - GetBundleInstallerManager()->CreateInstallTask(bundleFile, installParam, receiver); - ErrCode result = receiver->GetResultCode(); - EXPECT_EQ(ERR_OK, result); - - sptr unReceiver = new (std::nothrow) MockStatusReceiver(); - GetBundleInstallerManager()->CreateUninstallTask(BUNDLE_NAME, installParam, unReceiver); - result = unReceiver->GetResultCode(); - EXPECT_EQ(ERR_OK, result); -} - /** * @tc.number: CreateUninstallTask_0200 * @tc.name: test the installer manager can not create task while bundle invalid @@ -512,21 +390,6 @@ HWTEST_F(BmsBundleInstallerTest, CreateUninstallTask_0200, Function | SmallTest EXPECT_NE(ERR_OK, result); } -/** - * @tc.number: ThirdPartyInstall_0100 - * @tc.name: test the right third party bundle file can be installed - * @tc.desc: 1.the third party bundle file exists - * 2.the third party bundle can be installed successfully and can get the bundle info - */ -HWTEST_F(BmsBundleInstallerTest, ThirdPartyInstall_0100, Function | SmallTest | Level0) -{ - std::string bundleFile = RESOURCE_ROOT_PATH + RIGHT_BUNDLE; - ErrCode result = InstallThirdPartyBundle(bundleFile); - EXPECT_EQ(result, ERR_OK); - CheckFileExist(); - ClearBundleInfoInDb(); -} - /** * @tc.number: ThirdPartyInstall_0200 * @tc.name: test the wrong third party bundle file can't be installed @@ -568,20 +431,6 @@ HWTEST_F(BmsBundleInstallerTest, ThirdPartyInstall_0400, Function | SmallTest | CheckFileNonExist(); } -/** - * @tc.number: ThirdPartyInstall_0500 - * @tc.name: test the error format bundle file can't be installed - * @tc.desc: 1.the third party bundle format is error - * 2.the third party bundle can't be installed and the result is fail - */ -HWTEST_F(BmsBundleInstallerTest, ThirdPartyInstall_0500, Function | SmallTest | Level0) -{ - std::string errorFormat = RESOURCE_ROOT_PATH + FORMAT_ERROR_BUNDLE; - ErrCode result = InstallThirdPartyBundle(errorFormat); - EXPECT_EQ(result, ERR_APPEXECFWK_PARSE_NO_PROFILE); - CheckFileNonExist(); -} - /** * @tc.number: ThirdPartyInstall_0600 * @tc.name: test the bundle file with invalid path will cause the result of install failure @@ -596,42 +445,6 @@ HWTEST_F(BmsBundleInstallerTest, ThirdPartyInstall_0600, Function | SmallTest | CheckFileNonExist(); } -/** - * @tc.number: ThirdPartyInstall_0700 - * @tc.name: test the install will fail when installd service has error - * @tc.desc: 1.the installd service has error - * 2.the install result is fail - */ -HWTEST_F(BmsBundleInstallerTest, ThirdPartyInstall_0700, Function | SmallTest | Level0) -{ - StopInstalldService(); - std::string bundleFile = RESOURCE_ROOT_PATH + RIGHT_BUNDLE; - ErrCode result = InstallThirdPartyBundle(bundleFile); - EXPECT_EQ(result, ERR_APPEXECFWK_INSTALLD_GET_PROXY_ERROR); -} - -/** - * @tc.number: ThirdPartyUpdateData_0100 - * @tc.name: test the right bundle file can be installed and update its info to bms - * @tc.desc: 1.the ThirdParty bundle is available - * 2.the right bundle can be installed and update its info to bms - */ -HWTEST_F(BmsBundleInstallerTest, ThirdPartyUpdateData_0100, Function | SmallTest | Level0) -{ - ApplicationInfo info; - auto dataMgr = GetBundleDataMgr(); - EXPECT_NE(dataMgr, nullptr); - bool result = dataMgr->GetApplicationInfo(BUNDLE_NAME, ApplicationFlag::GET_BASIC_APPLICATION_INFO, USERID, info); - EXPECT_FALSE(result); - std::string bundleFile = RESOURCE_ROOT_PATH + RIGHT_BUNDLE; - ErrCode installResult = InstallThirdPartyBundle(bundleFile); - EXPECT_EQ(installResult, ERR_OK); - result = dataMgr->GetApplicationInfo(BUNDLE_NAME, ApplicationFlag::GET_BASIC_APPLICATION_INFO, USERID, info); - EXPECT_TRUE(result); - EXPECT_EQ(info.name, BUNDLE_NAME); - ClearBundleInfoInDb(); -} - /** * @tc.number: ThirdPartyUpdateData_0200 * @tc.name: test the wrong bundle file can't be installed and its info will not updated to bms @@ -650,70 +463,4 @@ HWTEST_F(BmsBundleInstallerTest, ThirdPartyUpdateData_0200, Function | SmallTest EXPECT_EQ(installResult, ERR_APPEXECFWK_INSTALL_INVALID_HAP_NAME); result = dataMgr->GetApplicationInfo(BUNDLE_NAME, ApplicationFlag::GET_BASIC_APPLICATION_INFO, USERID, info); EXPECT_FALSE(result); -} - -/** - * @tc.number: ThirdPartyUpdateData_0300 - * @tc.name: test the already installed bundle can't be reinstalled and update its info to bms - * @tc.desc: 1.the bundle is already installed - * 2.the already installed bundle can't be reinstalled and update its info to bms - */ -HWTEST_F(BmsBundleInstallerTest, ThirdPartyUpdateData_0300, Function | SmallTest | Level0) -{ - auto dataMgr = GetBundleDataMgr(); - EXPECT_NE(dataMgr, nullptr); - // prepare already install information. - std::string bundleFile = RESOURCE_ROOT_PATH + RIGHT_BUNDLE; - ErrCode firstInstall = InstallThirdPartyBundle(bundleFile); - EXPECT_EQ(firstInstall, ERR_OK); - ApplicationInfo info; - auto result = dataMgr->GetApplicationInfo(BUNDLE_NAME, ApplicationFlag::GET_BASIC_APPLICATION_INFO, USERID, info); - EXPECT_TRUE(result); - EXPECT_EQ(info.name, BUNDLE_NAME); - ErrCode secondInstall = InstallThirdPartyBundle(bundleFile); - EXPECT_EQ(secondInstall, ERR_APPEXECFWK_INSTALL_ALREADY_EXIST); - ClearBundleInfoInDb(); -} - -/** - * @tc.number: ThirdPartyUpdateData_0400 - * @tc.name: test the already installed bundle can be reinstalled and update its info to bms - * @tc.desc: 1.the bundle is already installed - * 2.the already installed bundle can be reinstalled and update its info to bms - */ -HWTEST_F(BmsBundleInstallerTest, ThirdPartyUpdateData_0400, Function | SmallTest | Level0) -{ - auto dataMgr = GetBundleDataMgr(); - EXPECT_NE(dataMgr, nullptr); - // prepare already install information. - std::string bundleFile = RESOURCE_ROOT_PATH + RIGHT_BUNDLE; - ErrCode firstInstall = InstallThirdPartyBundle(bundleFile); - EXPECT_EQ(firstInstall, ERR_OK); - ApplicationInfo info; - auto result = dataMgr->GetApplicationInfo(BUNDLE_NAME, ApplicationFlag::GET_BASIC_APPLICATION_INFO, USERID, info); - EXPECT_TRUE(result); - EXPECT_EQ(info.name, BUNDLE_NAME); - ErrCode secondInstall = UpdateThirdPartyBundle(bundleFile); - EXPECT_EQ(secondInstall, ERR_OK); - ClearBundleInfoInDb(); -} - -/** - * @tc.number: ThirdPartyUpdateData_0500 - * @tc.name: test the already installing bundle can't be reinstalled and update its info to bms - * @tc.desc: 1.the bundle is already installing - * 2.the already installing bundle can't be reinstalled and update its info to bms - */ -HWTEST_F(BmsBundleInstallerTest, ThirdPartyUpdateData_0500, Function | SmallTest | Level0) -{ - // prepare already install information. - auto dataMgr = GetBundleDataMgr(); - EXPECT_NE(dataMgr, nullptr); - dataMgr->UpdateBundleInstallState(BUNDLE_NAME, InstallState::INSTALL_START); - // begin to reinstall package - std::string bundleFile = RESOURCE_ROOT_PATH + RIGHT_BUNDLE; - ErrCode installResult = InstallThirdPartyBundle(bundleFile); - EXPECT_EQ(installResult, ERR_APPEXECFWK_INSTALL_STATE_ERROR); - // reset the install state - dataMgr->UpdateBundleInstallState(BUNDLE_NAME, InstallState::INSTALL_FAIL); } \ No newline at end of file diff --git a/services/bundlemgr/test/unittest/bms_bundle_kit_service_test/bms_bundle_kit_service_test.cpp b/services/bundlemgr/test/unittest/bms_bundle_kit_service_test/bms_bundle_kit_service_test.cpp index 967887d6b1..27414c53f7 100755 --- a/services/bundlemgr/test/unittest/bms_bundle_kit_service_test/bms_bundle_kit_service_test.cpp +++ b/services/bundlemgr/test/unittest/bms_bundle_kit_service_test/bms_bundle_kit_service_test.cpp @@ -124,6 +124,8 @@ const std::string FORM_PORTRAIT_LAYOUTS1 = "port1"; const std::string FORM_PORTRAIT_LAYOUTS2 = "port2"; const std::string FORM_LANDSCAPE_LAYOUTS1 = "land1"; const std::string FORM_LANDSCAPE_LAYOUTS2 = "land2"; +const std::string FORM_LAYOUT = "page/card/index"; +constexpr int32_t FORM_JS_WINDOW_DESIGNWIDTH = 720; const std::string SHORTCUT_TEST_ID = "shortcutTestId"; const std::string SHORTCUT_DEMO_ID = "shortcutDemoId"; const std::string SHORTCUT_HOST_ABILITY = "hostAbility"; @@ -163,6 +165,8 @@ public: const std::string &bundleName, const uint32_t permissionSize, const ApplicationInfo &appInfo) const; void CheckAbilityInfo( const std::string &bundleName, const std::string &abilityName, const AbilityInfo &appInfo) const; + void CheckAbilityInfos( + const std::string &bundleName, const std::string &abilityName, const std::vector &appInfo) const; void CheckCompatibleApplicationInfo( const std::string &bundleName, const uint32_t permissionSize, const CompatibleApplicationInfo &appInfo) const; void CheckCompatibleAbilityInfo( @@ -247,23 +251,23 @@ void BmsBundleKitServiceTest::MockInstallBundle( moduleInfo.colorMode = COLOR_MODE; AppExecFwk::Parameters parameters { - "description", - "name", + "description", + "name", "type" }; AppExecFwk::Results results { - "description", - "name", + "description", + "name", "type" }; AppExecFwk::CustomizeData customizeData { - "name", - "value", + "name", + "value", "extra" }; MetaData metaData { - {parameters}, - {results}, + {parameters}, + {results}, {customizeData} }; moduleInfo.metaData = metaData; @@ -279,12 +283,12 @@ void BmsBundleKitServiceTest::MockInstallBundle( // for launch ability if (bundleName == BUNDLE_NAME_TEST) { AppExecFwk::SkillUri uri { - URI_SCHEME, + URI_SCHEME, URI_HOST }; Skill skill { - {ACTION}, - {ENTITY}, + {ACTION}, + {ENTITY}, {uri} }; std::vector skills; @@ -340,6 +344,9 @@ FormInfo BmsBundleKitServiceTest::MockFormInfo( formInfo.scheduledUpateTime = FORM_SCHEDULED_UPDATE_TIME; formInfo.updateEnabled = true; formInfo.jsComponentName = FORM_JS_COMPONENT_NAME; + formInfo.layout = FORM_LAYOUT; + formInfo.window.autoDesignWidth = true; + formInfo.window.designWidth = FORM_JS_WINDOW_DESIGNWIDTH; for (auto &info : formInfo.customizeDatas) { info.name = FORM_CUSTOMIZE_DATAS_NAME; info.value = FORM_CUSTOMIZE_DATAS_VALUE; @@ -408,23 +415,23 @@ AbilityInfo BmsBundleKitServiceTest::MockAbilityInfo( abilityInfo.supportPipMode = false; abilityInfo.targetAbility = TARGET_ABILITY; AppExecFwk::Parameters parameters { - "description", - "name", + "description", + "name", "type" }; AppExecFwk::Results results { - "description", - "name", + "description", + "name", "type" }; AppExecFwk::CustomizeData customizeData { - "name", - "value", + "name", + "value", "extra" }; MetaData metaData { - {parameters}, - {results}, + {parameters}, + {results}, {customizeData} }; abilityInfo.metaData = metaData; @@ -543,6 +550,45 @@ void BmsBundleKitServiceTest::CheckAbilityInfo( } } +void BmsBundleKitServiceTest::CheckAbilityInfos( + const std::string &bundleName, const std::string &abilityName, const std::vector &abilityInfos) const +{ + for (auto abilityInfo : abilityInfos) { + EXPECT_EQ(abilityName, abilityInfo.name); + EXPECT_EQ(bundleName, abilityInfo.bundleName); + EXPECT_EQ(LABEL, abilityInfo.label); + EXPECT_EQ(DESCRIPTION, abilityInfo.description); + EXPECT_EQ(DEVICE_ID, abilityInfo.deviceId); + EXPECT_EQ(THEME, abilityInfo.theme); + EXPECT_EQ(ICON_PATH, abilityInfo.iconPath); + EXPECT_EQ(CODE_PATH, abilityInfo.codePath); + EXPECT_EQ(ORIENTATION, abilityInfo.orientation); + EXPECT_EQ(LAUNCH_MODE, abilityInfo.launchMode); + EXPECT_EQ(URI, abilityInfo.uri); + EXPECT_EQ(false, abilityInfo.supportPipMode); + EXPECT_EQ(TARGET_ABILITY, abilityInfo.targetAbility); + EXPECT_EQ(CONFIG_CHANGES, abilityInfo.configChanges); + EXPECT_EQ(FORM_ENTITY, abilityInfo.formEntity); + EXPECT_EQ(DEFAULT_FORM_HEIGHT, abilityInfo.defaultFormHeight); + EXPECT_EQ(DEFAULT_FORM_WIDTH, abilityInfo.defaultFormWidth); + for (auto &info : abilityInfo.metaData.customizeData) { + EXPECT_EQ(info.name, META_DATA_NAME); + EXPECT_EQ(info.value, META_DATA_VALUE); + EXPECT_EQ(info.extra, META_DATA_EXTRA); + } + for (auto &info : abilityInfo.metaData.parameters) { + EXPECT_EQ(info.description, META_DATA_DESCRIPTION); + EXPECT_EQ(info.name, META_DATA_NAME); + EXPECT_EQ(info.type, META_DATA_TYPE); + } + for (auto &info : abilityInfo.metaData.results) { + EXPECT_EQ(info.description, META_DATA_DESCRIPTION); + EXPECT_EQ(info.name, META_DATA_NAME); + EXPECT_EQ(info.type, META_DATA_TYPE); + } + } +} + void BmsBundleKitServiceTest::CheckCompatibleAbilityInfo( const std::string &bundleName, const std::string &abilityName, const CompatibleAbilityInfo &abilityInfo) const { @@ -719,6 +765,9 @@ void BmsBundleKitServiceTest::CheckFormInfoTest(const std::vector &for EXPECT_EQ(info.name, FORM_CUSTOMIZE_DATAS_NAME); EXPECT_EQ(info.value, FORM_CUSTOMIZE_DATAS_VALUE); } + EXPECT_EQ(formInfo.layout, FORM_LAYOUT); + EXPECT_EQ(formInfo.window.designWidth, FORM_JS_WINDOW_DESIGNWIDTH); + EXPECT_EQ(formInfo.window.autoDesignWidth, true); } } @@ -745,6 +794,8 @@ void BmsBundleKitServiceTest::CheckFormInfoDemo(const std::vector &for EXPECT_EQ(formInfo.scheduledUpateTime, FORM_SCHEDULED_UPDATE_TIME); EXPECT_EQ(formInfo.jsComponentName, FORM_JS_COMPONENT_NAME); EXPECT_EQ(formInfo.updateEnabled, true); + EXPECT_EQ(formInfo.layout, FORM_LAYOUT); + EXPECT_EQ(formInfo.window.designWidth, FORM_JS_WINDOW_DESIGNWIDTH); for (auto &info : formInfo.customizeDatas) { EXPECT_EQ(info.name, FORM_CUSTOMIZE_DATAS_NAME); EXPECT_EQ(info.value, FORM_CUSTOMIZE_DATAS_VALUE); @@ -928,19 +979,6 @@ HWTEST_F(BmsBundleKitServiceTest, GetBundleInfos_0200, Function | SmallTest | Le MockUninstallBundle(BUNDLE_NAME_DEMO); } -/** - * @tc.number: GetBundleInfos_0300 - * @tc.name: test can not get the installed bundles's bundle info with no bundle - * @tc.desc: 1.system run normally - * 2.get all installed bundle info failed - */ -HWTEST_F(BmsBundleKitServiceTest, GetBundleInfos_0300, Function | SmallTest | Level1) -{ - std::vector bundleInfos; - bool ret = GetBundleDataMgr()->GetBundleInfos(BundleFlag::GET_BUNDLE_WITH_ABILITIES, bundleInfos); - EXPECT_FALSE(ret); -} - /** * @tc.number: GetApplicationInfo_0100 * @tc.name: test can get the appName's application info @@ -1088,20 +1126,6 @@ HWTEST_F(BmsBundleKitServiceTest, GetApplicationInfos_0200, Function | SmallTest MockUninstallBundle(BUNDLE_NAME_DEMO); } -/** - * @tc.number: GetApplicationInfos_0300 - * @tc.name: test can not get the installed bundles's bundle info with no bundle - * @tc.desc: 1.system run normally - * 2.get all installed bundle info failed - */ -HWTEST_F(BmsBundleKitServiceTest, GetApplicationInfos_0300, Function | SmallTest | Level1) -{ - std::vector appInfos; - bool ret = GetBundleDataMgr()->GetApplicationInfos( - ApplicationFlag::GET_APPLICATION_INFO_WITH_PERMS, DEFAULT_USER_ID_TEST, appInfos); - EXPECT_FALSE(ret); -} - /** * @tc.number: GetAbilityLabel_0100 * @tc.name: test can get the ability's label by bundleName and abilityName @@ -1219,6 +1243,116 @@ HWTEST_F(BmsBundleKitServiceTest, QueryAbilityInfo_0300, Function | SmallTest | EXPECT_EQ(false, testRet); } +/** + * @tc.number: QueryAbilityInfos_0100 + * @tc.name: test can get the ability info of list by want + * @tc.desc: 1.system run normally + * 2.get ability info successfully + */ +HWTEST_F(BmsBundleKitServiceTest, QueryAbilityInfos_0100, Function | SmallTest | Level1) +{ + MockInstallBundle(BUNDLE_NAME_TEST, MODULE_NAME_TEST, ABILITY_NAME_TEST); + Want want; + want.SetElementName(BUNDLE_NAME_TEST, ABILITY_NAME_TEST); + std::vector result; + bool testRet = GetBundleDataMgr()->QueryAbilityInfos(want, result); + EXPECT_EQ(true, testRet); + CheckAbilityInfos(BUNDLE_NAME_TEST, ABILITY_NAME_TEST, result); + + MockUninstallBundle(BUNDLE_NAME_TEST); +} + +/** + * @tc.number: QueryAbilityInfos_0200 + * @tc.name: test can not get the ability info by want in which bundle name is wrong + * @tc.desc: 1.system run normally + * 2.get ability info failed + */ +HWTEST_F(BmsBundleKitServiceTest, QueryAbilityInfos_0200, Function | SmallTest | Level1) +{ + MockInstallBundle(BUNDLE_NAME_TEST, MODULE_NAME_TEST, ABILITY_NAME_TEST); + + Want want; + want.SetElementName(BUNDLE_NAME_DEMO, ABILITY_NAME_TEST); + std::vector result; + bool testRet = GetBundleDataMgr()->QueryAbilityInfos(want, result); + EXPECT_EQ(false, testRet); + + MockUninstallBundle(BUNDLE_NAME_TEST); +} + +/** + * @tc.number: QueryAbilityInfos_0300 + * @tc.name: test can not get the ability info by want which bundle doesn't exist + * @tc.desc: 1.system run normally + * 2.get ability info failed + */ +HWTEST_F(BmsBundleKitServiceTest, QueryAbilityInfos_0300, Function | SmallTest | Level1) +{ + Want want; + want.SetElementName(BUNDLE_NAME_TEST, ABILITY_NAME_TEST); + std::vector result; + bool testRet = GetBundleDataMgr()->QueryAbilityInfos(want, result); + EXPECT_EQ(false, testRet); +} + +/** + * @tc.number: QueryAbilityInfosForClone_0100 + * @tc.name: test can get the ability info of list by want + * @tc.desc: 1.system run normally + * 2.get ability info successfully + */ +HWTEST_F(BmsBundleKitServiceTest, QueryAbilityInfosForClone_0100, Function | SmallTest | Level1) +{ + MockInstallBundle(BUNDLE_NAME_TEST, MODULE_NAME_TEST, ABILITY_NAME_TEST); + Want want; + want.SetElementName(BUNDLE_NAME_TEST, ABILITY_NAME_TEST); + std::vector result; + bool testRet = GetBundleDataMgr()->QueryAbilityInfosForClone(want, result); + EXPECT_EQ(true, testRet); + CheckAbilityInfos(BUNDLE_NAME_TEST, ABILITY_NAME_TEST, result); + + MockUninstallBundle(BUNDLE_NAME_TEST); +} + +/** + * @tc.number: QueryAbilityInfosForClone_0200 + * @tc.name: test can not get the ability info by want in which element name is wrong + * @tc.desc: 1.system run normally + * 2.get ability info failed + */ +HWTEST_F(BmsBundleKitServiceTest, QueryAbilityInfosForClone_0200, Function | SmallTest | Level1) +{ + MockInstallBundle(BUNDLE_NAME_TEST, MODULE_NAME_TEST, ABILITY_NAME_TEST); + + Want want; + want.SetElementName(BUNDLE_NAME_DEMO, ABILITY_NAME_TEST); + std::vector result; + bool testRet = GetBundleDataMgr()->QueryAbilityInfosForClone(want, result); + EXPECT_EQ(false, testRet); + + want.SetElementName(BUNDLE_NAME_TEST, ABILITY_NAME_DEMO); + testRet = GetBundleDataMgr()->QueryAbilityInfosForClone(want, result); + EXPECT_EQ(false, testRet); + + MockUninstallBundle(BUNDLE_NAME_TEST); +} + +/** + * @tc.number: QueryAbilityInfosForClone_0300 + * @tc.name: test can not get the ability info by want which bundle doesn't exist + * @tc.desc: 1.system run normally + * 2.get ability info failed + */ +HWTEST_F(BmsBundleKitServiceTest, QueryAbilityInfosForClone_0300, Function | SmallTest | Level1) +{ + Want want; + want.SetElementName(BUNDLE_NAME_TEST, ABILITY_NAME_TEST); + std::vector result; + bool testRet = GetBundleDataMgr()->QueryAbilityInfosForClone(want, result); + EXPECT_EQ(false, testRet); +} + /** * @tc.number: GetLaunchWantForBundle_0100 * @tc.name: test can get the launch want of a bundle @@ -1317,19 +1451,6 @@ HWTEST_F(BmsBundleKitServiceTest, GetBundleList_0100, Function | SmallTest | Lev MockUninstallBundle(BUNDLE_NAME_DEMO); } -/** - * @tc.number: GetBundleList_0200 - * @tc.name: test can get the no bundle names with no bundle installed - * @tc.desc: 1.system run normally - * 2.get installed bundle names failed - */ -HWTEST_F(BmsBundleKitServiceTest, GetBundleList_0200, Function | SmallTest | Level1) -{ - std::vector testResult; - bool testRet = GetBundleDataMgr()->GetBundleList(testResult); - EXPECT_FALSE(testRet); -} - /** * @tc.number: GetBundleNameForUid_0100 * @tc.name: test can get the bundle names with bundle installed @@ -1535,31 +1656,6 @@ HWTEST_F(BmsBundleKitServiceTest, DUMP_0300, Function | SmallTest | Level1) MockUninstallBundle(BUNDLE_NAME_DEMO); } -/** - * @tc.number: DUMP_0400 - * @tc.name: Dump with no bundle in system - * @tc.desc: 1.system run normally - * 2.dump empty message with the dump command - */ -HWTEST_F(BmsBundleKitServiceTest, DUMP_0400, Function | SmallTest | Level0) -{ - auto hostImpl = std::make_unique(); - std::string allBundleInfos; - bool infoRet = hostImpl->DumpInfos(DumpFlag::DUMP_ALL_BUNDLE_INFO, EMPTY_STRING, allBundleInfos); - EXPECT_FALSE(infoRet); - EXPECT_EQ(std::string::npos, allBundleInfos.find(BUNDLE_NAME_TEST)); - - std::string bundleInfo; - bool infoRet1 = hostImpl->DumpInfos(DumpFlag::DUMP_BUNDLE_INFO, BUNDLE_NAME_TEST, bundleInfo); - EXPECT_FALSE(infoRet1); - EXPECT_EQ(EMPTY_STRING, bundleInfo); - - std::string emptyInfo; - bool emptyRet = hostImpl->DumpInfos(DumpFlag::DUMP_BUNDLE_INFO, EMPTY_STRING, emptyInfo); - EXPECT_FALSE(emptyRet); - EXPECT_EQ(EMPTY_STRING, emptyInfo); -} - /** * @tc.number: QueryAbilityInfoByUri_0100 * @tc.name: test can get the ability info by uri @@ -1681,25 +1777,6 @@ HWTEST_F(BmsBundleKitServiceTest, QueryKeepAliveBundleInfos_0200, Function | Sma EXPECT_EQ(false, ret); } -/** - * @tc.number: GetBundleArchiveInfo_0100 - * @tc.name: test can get the bundle archive info - * @tc.desc: 1.system run normally - * 2.get the bundle archive info successfully - */ -HWTEST_F(BmsBundleKitServiceTest, GetBundleArchiveInfo_0100, Function | SmallTest | Level1) -{ - MockInstallBundle(BUNDLE_NAME_TEST, MODULE_NAME_TEST, ABILITY_NAME_TEST); - - auto hostImpl = std::make_unique(); - BundleInfo testResult; - bool listRet = hostImpl->GetBundleArchiveInfo(HAP_FILE_PATH, BundleFlag::GET_BUNDLE_DEFAULT, testResult); - EXPECT_TRUE(listRet); - CheckBundleArchiveInfo(BUNDLE_NAME_TEST, MODULE_NAME_TEST, ABILITY_SIZE_ZERO, testResult); - - MockUninstallBundle(BUNDLE_NAME_TEST); -} - /** * @tc.number: GetBundleArchiveInfo_0200 * @tc.name: test can not get the bundle archive info by empty hap file path @@ -1736,25 +1813,6 @@ HWTEST_F(BmsBundleKitServiceTest, GetBundleArchiveInfo_0300, Function | SmallTes MockUninstallBundle(BUNDLE_NAME_TEST); } -/** - * @tc.number: GetBundleArchiveInfo_0400 - * @tc.name: test can get the bundle archive info - * @tc.desc: 1.system run normally - * 2.get the bundle archive info successfully for GET_BUNDLE_WITH_ABILITIES - */ -HWTEST_F(BmsBundleKitServiceTest, GetBundleArchiveInfo_0400, Function | SmallTest | Level1) -{ - MockInstallBundle(BUNDLE_NAME_TEST, MODULE_NAME_TEST, ABILITY_NAME_TEST); - - auto hostImpl = std::make_unique(); - BundleInfo testResult; - bool listRet = hostImpl->GetBundleArchiveInfo(HAP_FILE_PATH, BundleFlag::GET_BUNDLE_WITH_ABILITIES, testResult); - EXPECT_TRUE(listRet); - CheckBundleArchiveInfo(BUNDLE_NAME_TEST, MODULE_NAME_TEST, ABILITY_SIZE_ONE, testResult); - - MockUninstallBundle(BUNDLE_NAME_TEST); -} - /** * @tc.number: GetHapModuleInfo_0100 * @tc.name: test can get the hap module info @@ -2887,68 +2945,75 @@ HWTEST_F(BmsBundleKitServiceTest, GetUsageRecords_0100, Function | SmallTest | L } /** - * @tc.number: GetUsageRecords_0200 + * @tc.number: GetUsageRecords_0300 * @tc.name: test can get usage records by notify activity life status - * @tc.desc: 1.no other ability have been activitied - * 2.can get two bundle usage records + * @tc.desc: 1.can get usage records called two notify activity */ -HWTEST_F(BmsBundleKitServiceTest, GetUsageRecords_0200, Function | SmallTest | Level1) +HWTEST_F(BmsBundleKitServiceTest, GetUsageRecords_0300, Function | SmallTest | Level1) { MockInstallBundle(BUNDLE_NAME_TEST, MODULE_NAME_TEST, ABILITY_NAME_TEST); - MockInstallBundle(BUNDLE_NAME_DEMO, MODULE_NAME_DEMO, ABILITY_NAME_DEMO); int64_t time = std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count(); auto ret = GetBundleDataMgr()->NotifyActivityLifeStatus(BUNDLE_NAME_TEST, ABILITY_NAME_TEST, time); - auto ret1 = GetBundleDataMgr()->NotifyActivityLifeStatus(BUNDLE_NAME_DEMO, ABILITY_NAME_DEMO, time); + auto ret1 = GetBundleDataMgr()->NotifyActivityLifeStatus(BUNDLE_NAME_TEST, ABILITY_NAME_TEST, time); EXPECT_TRUE(ret); EXPECT_TRUE(ret1); std::vector records; auto result = GetBundleDataMgr()->GetUsageRecords(100, records); EXPECT_TRUE(result); - size_t size = 2; - EXPECT_EQ(records.size(), size); auto iter = std::find_if(records.begin(), records.end(), [](const auto &item) { return (item.bundleName == BUNDLE_NAME_TEST && item.name == MODULE_NAME_TEST && item.abilityName == ABILITY_NAME_TEST); }); EXPECT_NE(iter, records.end()); - uint32_t count = 1; + uint32_t count = 2; EXPECT_EQ(iter->launchedCount, count); InnerBundleInfo innerBundleInfo1; - InnerBundleInfo innerBundleInfo2; MockInnerBundleInfo(BUNDLE_NAME_TEST, MODULE_NAME_TEST, ABILITY_NAME_TEST, innerBundleInfo1); - MockInnerBundleInfo(BUNDLE_NAME_DEMO, ABILITY_NAME_DEMO, ABILITY_NAME_DEMO, innerBundleInfo2); ModuleUsageRecordStorage moduleUsageRecordStorage; moduleUsageRecordStorage.DeleteUsageRecord(innerBundleInfo1, 0); - moduleUsageRecordStorage.DeleteUsageRecord(innerBundleInfo2, 0); MockUninstallBundle(BUNDLE_NAME_TEST); - MockUninstallBundle(BUNDLE_NAME_DEMO); } /** - * @tc.number: GetUsageRecords_0300 - * @tc.name: test can get usage records by notify activity life status - * @tc.desc: 1.can get usage records called two notify activity + * @tc.number: GetUsageRecords_0400 + * @tc.name: test can't get usage records if maxNum is Less than 0. + * @tc.desc: 1.can't get usage records. */ -HWTEST_F(BmsBundleKitServiceTest, GetUsageRecords_0300, Function | SmallTest | Level1) +HWTEST_F(BmsBundleKitServiceTest, GetUsageRecords_0400, Function | SmallTest | Level1) { MockInstallBundle(BUNDLE_NAME_TEST, MODULE_NAME_TEST, ABILITY_NAME_TEST); int64_t time = std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count(); auto ret = GetBundleDataMgr()->NotifyActivityLifeStatus(BUNDLE_NAME_TEST, ABILITY_NAME_TEST, time); - auto ret1 = GetBundleDataMgr()->NotifyActivityLifeStatus(BUNDLE_NAME_TEST, ABILITY_NAME_TEST, time); EXPECT_TRUE(ret); - EXPECT_TRUE(ret1); std::vector records; - auto result = GetBundleDataMgr()->GetUsageRecords(100, records); - EXPECT_TRUE(result); - auto iter = std::find_if(records.begin(), records.end(), [](const auto &item) { - return (item.bundleName == BUNDLE_NAME_TEST && item.name == MODULE_NAME_TEST && - item.abilityName == ABILITY_NAME_TEST); - }); - EXPECT_NE(iter, records.end()); - uint32_t count = 2; - EXPECT_EQ(iter->launchedCount, count); + auto result = GetBundleDataMgr()->GetUsageRecords(-1, records); + EXPECT_FALSE(result); + EXPECT_EQ(records.size(), 0); + InnerBundleInfo innerBundleInfo1; + MockInnerBundleInfo(BUNDLE_NAME_TEST, MODULE_NAME_TEST, ABILITY_NAME_TEST, innerBundleInfo1); + ModuleUsageRecordStorage moduleUsageRecordStorage; + moduleUsageRecordStorage.DeleteUsageRecord(innerBundleInfo1, 0); + MockUninstallBundle(BUNDLE_NAME_TEST); +} + +/** + * @tc.number: GetUsageRecords_0500 + * @tc.name: test can't get usage records if maxNum is more than 1000. + * @tc.desc: 1.can't get usage records. + */ +HWTEST_F(BmsBundleKitServiceTest, GetUsageRecords_0500, Function | SmallTest | Level1) +{ + MockInstallBundle(BUNDLE_NAME_TEST, MODULE_NAME_TEST, ABILITY_NAME_TEST); + int64_t time = + std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count(); + auto ret = GetBundleDataMgr()->NotifyActivityLifeStatus(BUNDLE_NAME_TEST, ABILITY_NAME_TEST, time); + EXPECT_TRUE(ret); + std::vector records; + auto result = GetBundleDataMgr()->GetUsageRecords(1001, records); + EXPECT_FALSE(result); + EXPECT_EQ(records.size(), 0); InnerBundleInfo innerBundleInfo1; MockInnerBundleInfo(BUNDLE_NAME_TEST, MODULE_NAME_TEST, ABILITY_NAME_TEST, innerBundleInfo1); ModuleUsageRecordStorage moduleUsageRecordStorage; diff --git a/services/bundlemgr/test/unittest/bms_bundle_parser_test/bms_bundle_parser_test.cpp b/services/bundlemgr/test/unittest/bms_bundle_parser_test/bms_bundle_parser_test.cpp index f00af36b41..78bff906bd 100755 --- a/services/bundlemgr/test/unittest/bms_bundle_parser_test/bms_bundle_parser_test.cpp +++ b/services/bundlemgr/test/unittest/bms_bundle_parser_test/bms_bundle_parser_test.cpp @@ -118,6 +118,11 @@ const nlohmann::json CONFIG_JSON = R"( "portraitLayouts": [ "$layout:ability_form" ], + "layout": "pages/card/index", + "window": { + "designWidth": 720, + "autoDesignWidth": true + }, "formVisibleNotify": true, "deepLink": "ability://com.example.myapplication.fa/.MainAbility", "formConfigAbility": "ability://com.example.myapplication.fa/.MainAbility", @@ -408,33 +413,6 @@ void BmsBundleParserTest::CheckProfileShortcut(const nlohmann::json &checkedProf EXPECT_EQ(result, ERR_APPEXECFWK_PARSE_PROFILE_MISSING_PROP) << profileFileBuffer.str(); } -/** - * @tc.number: BmsBundleParser - * Function: BundleParser - * @tc.name: parse bundle package by config.json - * @tc.desc: 1. system running normally - * 2. test bundle package can be parse to InnerBundleInfo successfully - */ -HWTEST_F(BmsBundleParserTest, TestParse_0100, Function | SmallTest | Level0) -{ - BundleParser bundleParser; - InnerBundleInfo innerBundleInfo; - pathStream_ << RESOURCE_ROOT_PATH << NEW_APP << INSTALL_FILE_SUFFIX; - ErrCode result = bundleParser.Parse(pathStream_.str(), innerBundleInfo); - BundleInfo bundleInfo = innerBundleInfo.GetBaseBundleInfo(); - EXPECT_EQ(result, ERR_OK); - EXPECT_EQ(bundleInfo.name, "com.example.hiworld.himusic"); - EXPECT_EQ(bundleInfo.label, "HiMusic"); - EXPECT_EQ(bundleInfo.description, ""); - EXPECT_EQ(bundleInfo.vendor, "example"); - uint32_t versionCode = 2; - EXPECT_EQ(bundleInfo.versionCode, versionCode); - EXPECT_EQ(bundleInfo.versionName, "2.0"); - EXPECT_EQ(bundleInfo.minSdkVersion, 0); - EXPECT_EQ(bundleInfo.maxSdkVersion, 0); - EXPECT_EQ(bundleInfo.mainEntry, ""); -} - /** * @tc.number: TestParse_0200 * @tc.name: parse bundle package by config.json @@ -450,50 +428,6 @@ HWTEST_F(BmsBundleParserTest, TestParse_0200, Function | SmallTest | Level0) EXPECT_EQ(result, ERR_APPEXECFWK_PARSE_UNEXPECTED); } -/** - * @tc.number: TestParse_0300 - * @tc.name: parse bundle package by config.json - * @tc.desc: 1. system running normally - * 2. test parse bundle failed when the file is a break zip - */ -HWTEST_F(BmsBundleParserTest, TestParse_0300, Function | SmallTest | Level0) -{ - BundleParser bundleParser; - InnerBundleInfo innerBundleInfo; - pathStream_ << RESOURCE_ROOT_PATH << BREAK_ZIP << INSTALL_FILE_SUFFIX; - ErrCode result = bundleParser.Parse(pathStream_.str(), innerBundleInfo); - EXPECT_EQ(result, ERR_APPEXECFWK_PARSE_NO_PROFILE); -} - -/** - * @tc.number: TestParse_0400 - * @tc.name: parse bundle package by config.json - * @tc.desc: 1. test parse bundle failed when the config.json is not exist in the zip - */ -HWTEST_F(BmsBundleParserTest, TestParse_0400, Function | SmallTest | Level0) -{ - BundleParser bundleParser; - InnerBundleInfo innerBundleInfo; - pathStream_ << RESOURCE_ROOT_PATH << NO_PROFILE << INSTALL_FILE_SUFFIX; - ErrCode result = bundleParser.Parse(pathStream_.str(), innerBundleInfo); - EXPECT_EQ(result, ERR_APPEXECFWK_PARSE_NO_PROFILE); -} - -/** - * @tc.number: TestParse_0500 - * @tc.name: parse bundle package by config.json - * @tc.desc: 1. system running normally - * 2. test parse bundle failed when the config.json has format error - */ -HWTEST_F(BmsBundleParserTest, TestParse_0500, Function | SmallTest | Level0) -{ - BundleParser bundleParser; - InnerBundleInfo innerBundleInfo; - pathStream_ << RESOURCE_ROOT_PATH << FORMAT_ERROR_PROFILE << INSTALL_FILE_SUFFIX; - ErrCode result = bundleParser.Parse(pathStream_.str(), innerBundleInfo); - EXPECT_EQ(result, ERR_APPEXECFWK_PARSE_PROFILE_MISSING_PROP); -} - /** * @tc.number: TestParse_0600 * @tc.name: parse bundle package by config.json @@ -701,36 +635,6 @@ HWTEST_F(BmsBundleParserTest, TestParse_1300, Function | SmallTest | Level0) EXPECT_EQ(result, ERR_APPEXECFWK_PARSE_UNEXPECTED); } -/** - * @tc.number: TestParse_1400 - * @tc.name: parse bundle package by config.json - * @tc.desc: 1. system running normally - * 2. test parse bundle failed when the config.json has format MISSING - */ -HWTEST_F(BmsBundleParserTest, TestParse_1400, Function | SmallTest | Level0) -{ - BundleParser bundleParser; - InnerBundleInfo innerBundleInfo; - pathStream_ << RESOURCE_ROOT_PATH << FORMAT_MISSING_PROFILE << INSTALL_FILE_SUFFIX; - ErrCode result = bundleParser.Parse(pathStream_.str(), innerBundleInfo); - EXPECT_EQ(result, ERR_APPEXECFWK_PARSE_PROFILE_MISSING_PROP); -} - -/** - * @tc.number: TestParse_1500 - * @tc.name: parse bundle package by config.json - * @tc.desc: 1. system running normally - * 2. test parse bundle failed when the config.json is nothing json - */ -HWTEST_F(BmsBundleParserTest, TestParse_1500, Function | SmallTest | Level0) -{ - BundleParser bundleParser; - InnerBundleInfo innerBundleInfo; - pathStream_ << RESOURCE_ROOT_PATH << NOTHING_CONFIG << INSTALL_FILE_SUFFIX; - ErrCode result = bundleParser.Parse(pathStream_.str(), innerBundleInfo); - EXPECT_EQ(result, ERR_APPEXECFWK_PARSE_BAD_PROFILE); -} - /** * @tc.number: TestParse_1600 * @tc.name: parse bundle package by config.json diff --git a/services/bundlemgr/test/unittest/bms_bundle_permission_test/bms_bundle_permission_test.cpp b/services/bundlemgr/test/unittest/bms_bundle_permission_test/bms_bundle_permission_test.cpp index e0e103aabe..c00936d352 100644 --- a/services/bundlemgr/test/unittest/bms_bundle_permission_test/bms_bundle_permission_test.cpp +++ b/services/bundlemgr/test/unittest/bms_bundle_permission_test/bms_bundle_permission_test.cpp @@ -420,23 +420,23 @@ void BmsBundlePermissionTest::MockDefPermissionBundleSystemGrant(InnerBundleInfo moduleInfo.description = BUNDLE_DESCRIPTION; AppExecFwk::Parameters parameters { - "description", - "name", + "description", + "name", "type" }; AppExecFwk::Results results { - "description", - "name", + "description", + "name", "type" }; AppExecFwk::CustomizeData customizeData { - "name", - "value", + "name", + "value", "extra" }; MetaData metaData { - {parameters}, - {results}, + {parameters}, + {results}, {customizeData} }; moduleInfo.metaData = metaData; @@ -480,23 +480,23 @@ void BmsBundlePermissionTest::MockUpdateDefPermissionBundleSystemGrant(InnerBund moduleInfo.description = BUNDLE_DESCRIPTION; AppExecFwk::Parameters parameters { - "description", - "name", + "description", + "name", "type" }; AppExecFwk::Results results { - "description", - "name", + "description", + "name", "type" }; AppExecFwk::CustomizeData customizeData { - "name", - "value", + "name", + "value", "extra" }; MetaData metaData { - {parameters}, - {results}, + {parameters}, + {results}, {customizeData} }; moduleInfo.metaData = metaData; @@ -540,23 +540,23 @@ void BmsBundlePermissionTest::MockDefPermissionBundleTestReqpermission(InnerBund moduleInfo.description = BUNDLE_DESCRIPTION; AppExecFwk::Parameters parameters { - "description", - "name", + "description", + "name", "type" }; AppExecFwk::Results results { - "description", - "name", + "description", + "name", "type" }; AppExecFwk::CustomizeData customizeData { - "name", - "value", + "name", + "value", "extra" }; MetaData metaData { - {parameters}, - {results}, + {parameters}, + {results}, {customizeData} }; moduleInfo.metaData = metaData; @@ -599,23 +599,23 @@ void BmsBundlePermissionTest::MockNoDefPermissionBundle(InnerBundleInfo &innerbu moduleInfo.description = BUNDLE_DESCRIPTION; AppExecFwk::Parameters parameters { - "description", - "name", + "description", + "name", "type" }; AppExecFwk::Results results { - "description", - "name", + "description", + "name", "type" }; AppExecFwk::CustomizeData customizeData { - "name", - "value", + "name", + "value", "extra" }; MetaData metaData { - {parameters}, - {results}, + {parameters}, + {results}, {customizeData} }; moduleInfo.metaData = metaData; @@ -659,23 +659,23 @@ void BmsBundlePermissionTest::MockNoAvailableScopeDefPermissionBundle(InnerBundl moduleInfo.description = BUNDLE_DESCRIPTION; AppExecFwk::Parameters parameters { - "description", - "name", + "description", + "name", "type" }; AppExecFwk::Results results { - "description", - "name", + "description", + "name", "type" }; AppExecFwk::CustomizeData customizeData { - "name", - "value", + "name", + "value", "extra" }; MetaData metaData { - {parameters}, - {results}, + {parameters}, + {results}, {customizeData} }; moduleInfo.metaData = metaData; @@ -724,23 +724,23 @@ void BmsBundlePermissionTest::MockDefPermissionBundleUserGrant(InnerBundleInfo & moduleInfo.description = BUNDLE_DESCRIPTION; AppExecFwk::Parameters parameters { - "description", - "name", + "description", + "name", "type" }; AppExecFwk::Results results { - "description", - "name", + "description", + "name", "type" }; AppExecFwk::CustomizeData customizeData { - "name", - "value", + "name", + "value", "extra" }; MetaData metaData { - {parameters}, - {results}, + {parameters}, + {results}, {customizeData} }; moduleInfo.metaData = metaData; @@ -785,23 +785,23 @@ void BmsBundlePermissionTest::MockSameDefPermissionNameBundleSystemGrant(InnerBu moduleInfo.description = BUNDLE_DESCRIPTION; AppExecFwk::Parameters parameters { - "description", - "name", + "description", + "name", "type" }; AppExecFwk::Results results { - "description", - "name", + "description", + "name", "type" }; AppExecFwk::CustomizeData customizeData { - "name", - "value", + "name", + "value", "extra" }; MetaData metaData { - {parameters}, - {results}, + {parameters}, + {results}, {customizeData} }; moduleInfo.metaData = metaData; @@ -845,23 +845,23 @@ void BmsBundlePermissionTest::MockDefPermissionBundleSame(InnerBundleInfo &inner moduleInfo.description = BUNDLE_DESCRIPTION; AppExecFwk::Parameters parameters { - "description", - "name", + "description", + "name", "type" }; AppExecFwk::Results results { - "description", - "name", + "description", + "name", "type" }; AppExecFwk::CustomizeData customizeData { - "name", - "value", + "name", + "value", "extra" }; MetaData metaData { - {parameters}, - {results}, + {parameters}, + {results}, {customizeData} }; moduleInfo.metaData = metaData; @@ -906,23 +906,23 @@ void BmsBundlePermissionTest::MockReqPermissionBundle(InnerBundleInfo &innerbund moduleInfo.description = BUNDLE_DESCRIPTION; AppExecFwk::Parameters parameters { - "description", - "name", + "description", + "name", "type" }; AppExecFwk::Results results { - "description", - "name", + "description", + "name", "type" }; AppExecFwk::CustomizeData customizeData { - "name", - "value", + "name", + "value", "extra" }; MetaData metaData { - {parameters}, - {results}, + {parameters}, + {results}, {customizeData} }; moduleInfo.metaData = metaData; @@ -966,23 +966,23 @@ void BmsBundlePermissionTest::MockOtherReqPermissionBundle(InnerBundleInfo &inne moduleInfo.description = BUNDLE_DESCRIPTION; AppExecFwk::Parameters parameters { - "description", - "name", + "description", + "name", "type" }; AppExecFwk::Results results { - "description", - "name", + "description", + "name", "type" }; AppExecFwk::CustomizeData customizeData { - "name", - "value", + "name", + "value", "extra" }; MetaData metaData { - {parameters}, - {results}, + {parameters}, + {results}, {customizeData} }; moduleInfo.metaData = metaData; @@ -1060,21 +1060,6 @@ void BmsBundlePermissionTest::CheckErrPermissionDef( EXPECT_NE(permissionDef.descriptionId, permDef.descriptionId); } -/** - * @tc.number: BmsBundlePermissionTest - * Function: PermissionTest - * @tc.name: test can add install Permission - * @tc.desc: 1. system running normally - * 2. test bundle package have verify can install successfully - */ -HWTEST_F(BmsBundlePermissionTest, HapVerify_0100, Function | SmallTest | Level0) -{ - - Verify::HapVerifyResult hapVerifyResult; - bool result = BundleVerifyMgr::HapVerify(HAP_FILE_PATH, hapVerifyResult); - EXPECT_EQ(result, true); -} - /** * @tc.number: BmsBundlePermissionTest * Function: PermissionTest diff --git a/services/bundlemgr/test/unittest/bms_bundle_uninstaller_test/bms_bundle_uninstaller_test.cpp b/services/bundlemgr/test/unittest/bms_bundle_uninstaller_test/bms_bundle_uninstaller_test.cpp index 3ab3580bd5..3f103c9deb 100755 --- a/services/bundlemgr/test/unittest/bms_bundle_uninstaller_test/bms_bundle_uninstaller_test.cpp +++ b/services/bundlemgr/test/unittest/bms_bundle_uninstaller_test/bms_bundle_uninstaller_test.cpp @@ -320,25 +320,6 @@ void BmsBundleUninstallerTest::DeleteInstallFiles() bundleMgrService_ = DelayedSingleton::GetInstance(); } -/** - * @tc.number: Bundle_Uninstall_0100 - * @tc.name: test the installed bundle can be uninstalled - * @tc.desc: 1. the bundle is already installed - * 2. the installed bundle can be uninstalled successfully - */ -HWTEST_F(BmsBundleUninstallerTest, Bundle_Uninstall_0100, Function | SmallTest | Level0) -{ - ErrCode installResult = InstallBundle(BUNDLE_FILE_PATH); - EXPECT_EQ(installResult, ERR_OK); - CheckBundleInfoExist(); - CheckFileExist(); - - ErrCode uninstallResult = UninstallBundle(BUNDLE_NAME); - EXPECT_EQ(uninstallResult, ERR_OK); - CheckFileNonExist(); - CheckBundleInfoNonExist(); -} - /** * @tc.number: Bundle_Uninstall_0200 * @tc.name: test the empty bundle name will return fail @@ -363,125 +344,6 @@ HWTEST_F(BmsBundleUninstallerTest, Bundle_Uninstall_0300, Function | SmallTest | EXPECT_EQ(result, ERR_APPEXECFWK_UNINSTALL_MISSING_INSTALLED_BUNDLE); } -/** - * @tc.number: Bundle_Uninstall_0400 - * @tc.name: test the bundle mgr service error case - * @tc.desc: 1. the bundle mgr service error - * 2. the uninstall operation will return fail and the next uninstall operation will success after restart - * bundle mgr service - */ -HWTEST_F(BmsBundleUninstallerTest, Bundle_Uninstall_0400, Function | SmallTest | Level0) -{ - ErrCode installResult = InstallBundle(BUNDLE_FILE_PATH); - EXPECT_EQ(installResult, ERR_OK); - CheckFileExist(); - CheckBundleInfoExist(); - - StopBundleService(); - ErrCode secondResult = UninstallBundle(BUNDLE_NAME); - EXPECT_EQ(secondResult, ERR_APPEXECFWK_UNINSTALL_BUNDLE_MGR_SERVICE_ERROR); - CheckFileExist(); - StartBundleService(); - CheckBundleInfoExist(); - - ErrCode thirdResult = UninstallBundle(BUNDLE_NAME); - EXPECT_EQ(thirdResult, ERR_OK); - CheckFileNonExist(); - CheckBundleInfoNonExist(); -} - -/** - * @tc.number: Bundle_Uninstall_0500 - * @tc.name: test the installd service error - * @tc.desc: 1. the installd service error - * 2. the uninstall operation will return fail. - */ -HWTEST_F(BmsBundleUninstallerTest, Bundle_Uninstall_0500, Function | SmallTest | Level0) -{ - ErrCode installResult = InstallBundle(BUNDLE_FILE_PATH); - EXPECT_EQ(installResult, ERR_OK); - CheckFileExist(); - CheckBundleInfoExist(); - - StopInstalldService(); - ErrCode uninstallResult = UninstallBundle(BUNDLE_NAME); - EXPECT_EQ(uninstallResult, ERR_APPEXECFWK_INSTALLD_GET_PROXY_ERROR); - CheckFileExist(); - - StartInstalldService(); - CheckFileExist(); - DeleteInstallFiles(); -} - -/** - * @tc.number: Bundle_Uninstall_0600 - * @tc.name: test when status receiver is null will not uninstall bundle - * @tc.desc: 1. the status receiver is null - * 2. the uninstall bundle operation will not execute when status receiver is null - */ -HWTEST_F(BmsBundleUninstallerTest, Bundle_Uninstall_0600, Function | SmallTest | Level1) -{ - ErrCode installResult = InstallBundle(BUNDLE_FILE_PATH); - EXPECT_EQ(installResult, ERR_OK); - CheckFileExist(); - CheckBundleInfoExist(); - - InstallParam installParam; - installParam.installFlag = InstallFlag::NORMAL; - auto bms = GetBundleMgrService(); - EXPECT_NE(bms, nullptr); - auto installer = bms->GetBundleInstaller(); - EXPECT_NE(installer, nullptr); - bool result = installer->Uninstall(BUNDLE_NAME, installParam, nullptr); - EXPECT_FALSE(result); - - std::this_thread::sleep_for(100ms); - CheckFileExist(); - CheckBundleInfoExist(); - DeleteInstallFiles(); -} - -/** - * @tc.number: Bundle_Uninstall_0700 - * @tc.name: test the installed system bundle can't be uninstalled - * @tc.desc: 1. the system bundle is already installed - * 2. the installed system bundle can't be uninstalled - */ -HWTEST_F(BmsBundleUninstallerTest, Bundle_Uninstall_0700, Function | SmallTest | Level0) -{ - auto installer = std::make_unique(BUNDLE_FILE_PATH); - EXPECT_NE(installer, nullptr); - bool installResult = installer->InstallSystemBundle(Constants::AppType::SYSTEM_APP); - EXPECT_EQ(installResult, true); - CheckFileExist(); - CheckBundleInfoExist(); - - ErrCode uninstallResult = UninstallBundle(BUNDLE_NAME); - EXPECT_EQ(uninstallResult, ERR_APPEXECFWK_UNINSTALL_SYSTEM_APP_ERROR); - CheckFileExist(); - CheckBundleInfoExist(); - DeleteInstallFiles(); -} - -/** - * @tc.number: Module_Uninstall_0100 - * @tc.name: test the installed Module can be uninstalled - * @tc.desc: 1. the Module is already installed - * 2. the installed Module can be uninstalled successfully - */ -HWTEST_F(BmsBundleUninstallerTest, Module_Uninstall_0100, Function | SmallTest | Level0) -{ - ErrCode installResult = InstallBundle(BUNDLE_FILE_PATH); - EXPECT_EQ(installResult, ERR_OK); - CheckBundleInfoExist(); - CheckFileExist(); - - ErrCode uninstallResult = UninstallModule(BUNDLE_NAME, MODULE_PACKAGE); - EXPECT_EQ(uninstallResult, ERR_OK); - CheckFileNonExist(); - CheckBundleInfoNonExist(); -} - /** * @tc.number: Module_Uninstall_0200 * @tc.name: test the installed Module can be uninstalled @@ -504,155 +366,4 @@ HWTEST_F(BmsBundleUninstallerTest, Module_Uninstall_0300, Function | SmallTest | { ErrCode result = UninstallModule(BUNDLE_NAME, ERROR_MODULE_PACKAGE_NAME); EXPECT_EQ(result, ERR_APPEXECFWK_UNINSTALL_MISSING_INSTALLED_BUNDLE); -} - -/** - * @tc.number: Module_Uninstall_0400 - * @tc.name: test the bundle mgr service error case. - * @tc.desc: 1. the bundle mgr service error. - * 2. the uninstall operation will return fail and the next uninstall operation will success after - * restart bundle mgr service. - */ -HWTEST_F(BmsBundleUninstallerTest, Module_Uninstall_0400, Function | SmallTest | Level0) -{ - ErrCode installResult = InstallBundle(BUNDLE_FILE_PATH); - EXPECT_EQ(installResult, ERR_OK); - CheckFileExist(); - CheckBundleInfoExist(); - - StopBundleService(); - ErrCode secondResult = UninstallModule(BUNDLE_NAME, MODULE_PACKAGE); - EXPECT_EQ(secondResult, ERR_APPEXECFWK_UNINSTALL_BUNDLE_MGR_SERVICE_ERROR); - CheckFileExist(); - StartBundleService(); - CheckBundleInfoExist(); - - ErrCode thirdResult = UninstallModule(BUNDLE_NAME, MODULE_PACKAGE); - EXPECT_EQ(thirdResult, ERR_OK); - CheckFileNonExist(); - CheckBundleInfoNonExist(); -} - -/** - * @tc.number: Module_Uninstall_0500 - * @tc.name: test the installd service error case. - * @tc.desc: 1. the installd service error. - * 2. the uninstall module operation will return fail. - */ -HWTEST_F(BmsBundleUninstallerTest, Module_Uninstall_0500, Function | SmallTest | Level0) -{ - ErrCode installResult = InstallBundle(BUNDLE_FILE_PATH); - EXPECT_EQ(installResult, ERR_OK); - CheckFileExist(); - CheckBundleInfoExist(); - - StopInstalldService(); - ErrCode uninstallResult = UninstallModule(BUNDLE_NAME, MODULE_PACKAGE); - EXPECT_EQ(uninstallResult, ERR_APPEXECFWK_INSTALLD_GET_PROXY_ERROR); - CheckFileExist(); - - StartInstalldService(); - CheckFileExist(); - DeleteInstallFiles(); -} - -/** - * @tc.number: Module_Uninstall_0600 - * @tc.name: test when status receiver is null will not uninstall Module. - * @tc.desc: 1. the status receiver is null. - * 2. the uninstall Module operation will not execute when status receiver is null. - */ -HWTEST_F(BmsBundleUninstallerTest, Module_Uninstall_0600, Function | SmallTest | Level1) -{ - ErrCode installResult = InstallBundle(BUNDLE_FILE_PATH); - EXPECT_EQ(installResult, ERR_OK); - CheckFileExist(); - CheckBundleInfoExist(); - - InstallParam installParam; - installParam.installFlag = InstallFlag::NORMAL; - auto bms = GetBundleMgrService(); - EXPECT_NE(bms, nullptr); - auto installer = bms->GetBundleInstaller(); - EXPECT_NE(installer, nullptr); - bool result = installer->Uninstall(BUNDLE_NAME, MODULE_PACKAGE, installParam, nullptr); - EXPECT_FALSE(result); - - std::this_thread::sleep_for(100ms); - CheckFileExist(); - CheckBundleInfoExist(); - DeleteInstallFiles(); -} - -/** - * @tc.number: Module_Uninstall_0700 - * @tc.name: test the installed system bundle can't be uninstalled. - * @tc.desc: 1. the system bundle is already installed. - * 2. the installed system bundle can't be uninstalled. - */ -HWTEST_F(BmsBundleUninstallerTest, Module_Uninstall_0700, Function | SmallTest | Level0) -{ - auto installer = std::make_unique(BUNDLE_FILE_PATH); - EXPECT_NE(installer, nullptr); - bool installResult = installer->InstallSystemBundle(Constants::AppType::SYSTEM_APP); - EXPECT_EQ(installResult, true); - CheckFileExist(); - CheckBundleInfoExist(); - - ErrCode uninstallResult = UninstallModule(BUNDLE_NAME, MODULE_PACKAGE); - EXPECT_EQ(uninstallResult, ERR_APPEXECFWK_UNINSTALL_SYSTEM_APP_ERROR); - CheckFileExist(); - CheckBundleInfoExist(); - DeleteInstallFiles(); -} - -/** - * @tc.number: Module_Uninstall_0800 - * @tc.name: test the installed Module can be uninstalled. - * @tc.desc: 1. the two Module is already installed. - * 2. the installed one Module can be uninstalled successfully. - */ -HWTEST_F(BmsBundleUninstallerTest, Module_Uninstall_0800, Function | SmallTest | Level0) -{ - ErrCode installResult = InstallBundle(BUNDLE_FILE_PATH); - EXPECT_EQ(installResult, ERR_OK); - ErrCode installResult1 = InstallBundle(BUNDLE_FILE_PATH1); - EXPECT_EQ(installResult1, ERR_OK); - CheckBundleInfoExist(); - CheckFileExist(); - CheckModuleFileExist(); - CheckModuleFileExist1(); - - ErrCode uninstallResult = UninstallModule(BUNDLE_NAME, MODULE_PACKAGE); - EXPECT_EQ(uninstallResult, ERR_OK); - CheckModuleFileNonExist(); - CheckModuleFileExist1(); - CheckBundleInfoExist(); - DeleteInstallFiles(); -} - -/** - * @tc.number: Module_Uninstall_0900 - * @tc.name: test the installed Module can be uninstalled. - * @tc.desc: 1. the two Module is already installed. - * 2. the installed two Module can be uninstalled successfully. - */ -HWTEST_F(BmsBundleUninstallerTest, Module_Uninstall_0900, Function | SmallTest | Level0) -{ - ErrCode installResult = InstallBundle(BUNDLE_FILE_PATH); - EXPECT_EQ(installResult, ERR_OK); - ErrCode installResult1 = InstallBundle(BUNDLE_FILE_PATH1); - EXPECT_EQ(installResult1, ERR_OK); - CheckBundleInfoExist(); - CheckFileExist(); - CheckModuleFileExist(); - CheckModuleFileExist1(); - - ErrCode uninstallResult = UninstallModule(BUNDLE_NAME, MODULE_PACKAGE); - EXPECT_EQ(uninstallResult, ERR_OK); - ErrCode uninstallResult1 = UninstallModule(BUNDLE_NAME, MODULE_PACKAGE1); - EXPECT_EQ(uninstallResult1, ERR_OK); - CheckFileNonExist(); - CheckBundleInfoNonExist(); - DeleteInstallFiles(); } \ No newline at end of file diff --git a/services/bundlemgr/test/unittest/bms_bundle_updater_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_bundle_updater_test/BUILD.gn deleted file mode 100755 index 88c04eceb2..0000000000 --- a/services/bundlemgr/test/unittest/bms_bundle_updater_test/BUILD.gn +++ /dev/null @@ -1,93 +0,0 @@ -# Copyright (c) 2021 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import("//build/test.gni") -import("//foundation/appexecfwk/standard/appexecfwk.gni") -import( - "//foundation/appexecfwk/standard/services/bundlemgr/appexecfwk_bundlemgr.gni") - -config("private_config") { - include_dirs = [ - "${services_path}/bundlemgr/test/mock/include", - "${services_path}/test/moduletest/utils/include", - ] -} - -module_output_path = "appexecfwk_standard/bundlemgrservice" - -ohos_unittest("BmsBundleUpdaterTest") { - module_out_path = module_output_path - include_dirs = [ "//third_party/jsoncpp/include" ] - sources = [ - "${services_path}/bundlemgr/src/bundle_data_mgr.cpp", - "${services_path}/bundlemgr/src/bundle_data_storage_database.cpp", - "${services_path}/bundlemgr/src/bundle_mgr_host_impl.cpp", - "${services_path}/bundlemgr/src/bundle_mgr_service.cpp", - "${services_path}/bundlemgr/src/bundle_mgr_service_event_handler.cpp", - "${services_path}/bundlemgr/src/bundle_scanner.cpp", - "${services_path}/bundlemgr/src/bundle_status_callback_death_recipient.cpp", - "${services_path}/bundlemgr/src/installd/installd_host_impl.cpp", - "${services_path}/bundlemgr/src/installd/installd_operator.cpp", - "${services_path}/bundlemgr/src/installd/installd_service.cpp", - "${services_path}/bundlemgr/src/kvstore_death_recipient_callback.cpp", - "${services_path}/bundlemgr/src/module_usage_data_storage.cpp", - "${services_path}/bundlemgr/src/permission_changed_death_recipient.cpp", - ] - - sources += [ - "${services_path}/bundlemgr/test/mock/src/mock_status_receiver.cpp", - "${services_path}/bundlemgr/test/mock/src/system_ability_helper.cpp", - "${services_path}/test/moduletest/utils/src/common_tool.cpp", - ] - - sources += bundle_install_sources - - sources += [ "bms_bundle_updater_test.cpp" ] - - configs = [ - ":private_config", - "${libs_path}/libeventhandler:libeventhandler_config", - "${services_path}/bundlemgr/test:bundlemgr_test_config", - ] - cflags = [] - if (target_cpu == "arm") { - cflags += [ "-DBINDER_IPC_32BIT" ] - } - deps = [ - "${appexecfwk_path}/interfaces/innerkits/appexecfwk_core:appexecfwk_core", - "${libs_path}/libeventhandler:libeventhandler_target", - "//base/security/appverify/interfaces/innerkits/appverify:libhapverify", - "//base/security/permission/interfaces/innerkits/permission_standard/permissionsdk:libpermissionsdk_standard", - "//foundation/aafwk/standard/interfaces/innerkits/base:base", - "//foundation/aafwk/standard/interfaces/innerkits/want:want", - "//foundation/distributeddatamgr/distributeddatamgr/interfaces/innerkits/distributeddata:distributeddata_inner", - "//foundation/distributedschedule/safwk/interfaces/innerkits/safwk:system_ability_fwk", - "//third_party/googletest:gtest_main", - "//third_party/jsoncpp:jsoncpp", - "//utils/native/base:utils", - ] - - deps += bundle_install_deps - - external_deps = [ - "ces_standard:cesfwk_innerkits", - "hiviewdfx_hilog_native:libhilog", - "ipc:ipc_core", - ] -} - -group("unittest") { - testonly = true - - deps = [ ":BmsBundleUpdaterTest" ] -} diff --git a/services/bundlemgr/test/unittest/bms_bundle_updater_test/bms_bundle_updater_test.cpp b/services/bundlemgr/test/unittest/bms_bundle_updater_test/bms_bundle_updater_test.cpp deleted file mode 100755 index c305f3712c..0000000000 --- a/services/bundlemgr/test/unittest/bms_bundle_updater_test/bms_bundle_updater_test.cpp +++ /dev/null @@ -1,532 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include -#include -#include - -#include "directory_ex.h" -#include "appexecfwk_errors.h" -#include "common_tool.h" -#include "bundle_info.h" -#include "bundle_installer_host.h" -#include "bundle_mgr_service.h" -#include "installd/installd_service.h" -#include "installd_client.h" -#include "mock_status_receiver.h" - -using namespace testing::ext; -using namespace std::chrono_literals; -using namespace OHOS; -using namespace OHOS::AppExecFwk; - -namespace { - -const std::string PACKAGE_NAME = "com.example.l3jsdemo"; -const std::string BUNDLE_NAME = "com.example.l3jsdemo"; -const std::string ERROR_BUNDLE_NAME = "com.example.bundle.update.error"; -const std::string BUNDLE_FILE_DIR = "/data/test/resource/bms/update_bundle/"; -const std::string V1_BUNDLE = "version1.hap"; -const std::string V2_BUNDLE = "version2.hap"; -const std::string V3_BUNDLE = "version3.hap"; -const std::string ERROR_FORMART_BUNDLE = "format_error_profile.hap"; -const std::string BUNDLE_DATA_DIR = "/data/accounts/account_0/appdata/com.example.l3jsdemo"; -const std::string BUNDLE_CODE_DIR = "/data/accounts/account_0/applications/com.example.l3jsdemo"; -const std::string ROOT_DIR = "/data/accounts"; -const std::string PROFILE_FILE = "config.json"; -const std::string SEPARATOR = "/"; -const std::chrono::seconds SLEEP_TIME {2}; -const int32_t ROOT_UID = 0; -const int32_t USERID = 0; -const uint32_t VERSION_1 = 1; -const uint32_t VERSION_2 = 2; -const uint32_t VERSION_3 = 3; -const int32_t MAX_TRY_TIMES = 1000; - -} // namespace - -class BmsBundleUpdaterTest : public testing::Test { -public: - static void SetUpTestCase(); - static void TearDownTestCase(); - void SetUp(); - void TearDown(); - - const std::shared_ptr GetBundleDataMgr() const; - ErrCode InstallBundle(const std::string &bundlePath) const; - ErrCode UninstallBundle(const std::string &bundleName) const; - ErrCode UpdateBundle(const std::string &bundlePath) const; - ErrCode UpdateBundle(const std::string &bundlePath, const bool needCheckInfo) const; - - void StopInstalldService() const; - void StartInstalldService() const; - void StopBundleService() const; - - void CheckFileExist() const; - bool CheckApplicationInfo() const; - bool CheckBundleInfo(const uint32_t versionCode, const bool needCheckVersion) const; - -private: - std::shared_ptr installdService_ = std::make_unique(); - std::shared_ptr bundleMgrService_ = DelayedSingleton::GetInstance(); -}; - -void BmsBundleUpdaterTest::SetUpTestCase() -{ - if (access(ROOT_DIR.c_str(), F_OK) != 0) { - bool result = OHOS::ForceCreateDirectory(ROOT_DIR); - EXPECT_TRUE(result) << "fail to create root dir"; - } - if (chown(ROOT_DIR.c_str(), ROOT_UID, ROOT_UID) != 0) { - EXPECT_TRUE(false) << "fail to change root dir own ship"; - } - if (chmod(ROOT_DIR.c_str(), S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH) != 0) { - EXPECT_TRUE(false) << "fail to change root dir mode"; - } -} - -void BmsBundleUpdaterTest::TearDownTestCase() -{} - -void BmsBundleUpdaterTest::SetUp() -{ - installdService_->Start(); - if (!DelayedSingleton::GetInstance()->IsServiceReady()) { - DelayedSingleton::GetInstance()->OnStart(); - } -} - -void BmsBundleUpdaterTest::TearDown() -{ - // reset the case. - UninstallBundle(BUNDLE_NAME); - - StopInstalldService(); - StopBundleService(); - - // clear files. - OHOS::ForceRemoveDirectory(BUNDLE_DATA_DIR); - OHOS::ForceRemoveDirectory(BUNDLE_CODE_DIR); -} - -const std::shared_ptr BmsBundleUpdaterTest::GetBundleDataMgr() const -{ - return bundleMgrService_->GetDataMgr(); -} - -ErrCode BmsBundleUpdaterTest::InstallBundle(const std::string &bundlePath) const -{ - auto installer = DelayedSingleton::GetInstance()->GetBundleInstaller(); - if (!installer) { - EXPECT_FALSE(true) << "the installer is nullptr"; - return ERR_APPEXECFWK_INSTALL_INTERNAL_ERROR; - } - - sptr receiver = new (std::nothrow) MockStatusReceiver(); - if (!receiver) { - EXPECT_FALSE(true) << "the receiver is nullptr"; - return ERR_APPEXECFWK_INSTALL_INTERNAL_ERROR; - } - InstallParam installParam; - installParam.installFlag = InstallFlag::NORMAL; - bool result = installer->Install(bundlePath, installParam, receiver); - EXPECT_TRUE(result); - return receiver->GetResultCode(); -} - -ErrCode BmsBundleUpdaterTest::UninstallBundle(const std::string &bundleName) const -{ - auto installer = DelayedSingleton::GetInstance()->GetBundleInstaller(); - if (!installer) { - EXPECT_FALSE(true) << "the installer is nullptr"; - return ERR_APPEXECFWK_INSTALL_INTERNAL_ERROR; - } - - sptr receiver = new (std::nothrow) MockStatusReceiver(); - if (!receiver) { - EXPECT_FALSE(true) << "the receiver is nullptr"; - return ERR_APPEXECFWK_INSTALL_INTERNAL_ERROR; - } - InstallParam installParam; - installParam.installFlag = InstallFlag::NORMAL; - bool result = installer->Uninstall(bundleName, installParam, receiver); - EXPECT_TRUE(result); - return receiver->GetResultCode(); -} - -ErrCode BmsBundleUpdaterTest::UpdateBundle(const std::string &bundlePath) const -{ - auto installer = DelayedSingleton::GetInstance()->GetBundleInstaller(); - if (!installer) { - EXPECT_FALSE(true) << "the installer is nullptr"; - return ERR_APPEXECFWK_INSTALL_INTERNAL_ERROR; - } - - sptr receiver = new (std::nothrow) MockStatusReceiver(); - if (!receiver) { - EXPECT_FALSE(true) << "the receiver is nullptr"; - return ERR_APPEXECFWK_INSTALL_INTERNAL_ERROR; - } - InstallParam installParam; - installParam.installFlag = InstallFlag::REPLACE_EXISTING; - bool result = installer->Install(bundlePath, installParam, receiver); - EXPECT_TRUE(result); - return receiver->GetResultCode(); -} - -ErrCode BmsBundleUpdaterTest::UpdateBundle(const std::string &bundlePath, const bool needCheckInfo) const -{ - auto installer = DelayedSingleton::GetInstance()->GetBundleInstaller(); - if (!installer) { - EXPECT_FALSE(true) << "the installer is nullptr"; - return ERR_APPEXECFWK_INSTALL_INTERNAL_ERROR; - } - sptr receiver = new (std::nothrow) MockStatusReceiver(); - if (!receiver) { - EXPECT_FALSE(true) << "the receiver is nullptr"; - return ERR_APPEXECFWK_INSTALL_INTERNAL_ERROR; - } - InstallParam installParam; - installParam.installFlag = InstallFlag::REPLACE_EXISTING; - bool result = installer->Install(bundlePath, installParam, receiver); - EXPECT_TRUE(result); - - // check can not access the application info between updating. - if (needCheckInfo) { - bool isBlock = false; - for (int32_t i = 0; i < MAX_TRY_TIMES; i++) { - std::this_thread::sleep_for(10ms); - bool isExist = CheckApplicationInfo(); - if (!isExist) { - isBlock = true; - break; - } - } - if (!isBlock) { - EXPECT_FALSE(true) << "the bundle info is not disable during updating"; - return ERR_APPEXECFWK_INSTALL_BUNDLE_MGR_SERVICE_ERROR; - } - } - - return receiver->GetResultCode(); -} - -void BmsBundleUpdaterTest::StopInstalldService() const -{ - installdService_->Stop(); - InstalldClient::GetInstance()->ResetInstalldProxy(); -} - -void BmsBundleUpdaterTest::StartInstalldService() const -{ - installdService_->Start(); -} - -void BmsBundleUpdaterTest::StopBundleService() const -{ - DelayedSingleton::GetInstance()->OnStop(); -} - -void BmsBundleUpdaterTest::CheckFileExist() const -{ - CommonTool tool; - bool isCodeExist = tool.CheckFilePathISExist(BUNDLE_CODE_DIR + SEPARATOR + PACKAGE_NAME); - EXPECT_TRUE(isCodeExist); - bool isDataExist = tool.CheckFilePathISExist(BUNDLE_DATA_DIR + SEPARATOR + PACKAGE_NAME); - EXPECT_TRUE(isDataExist); -} - -bool BmsBundleUpdaterTest::CheckBundleInfo(const uint32_t versionCode, const bool needCheckVersion) const -{ - BundleInfo info; - auto dataMgr = GetBundleDataMgr(); - if (dataMgr == nullptr) { - return false; - } - bool isExist = dataMgr->GetBundleInfo(BUNDLE_NAME, BundleFlag::GET_BUNDLE_DEFAULT, info); - if (!isExist) { - return false; - } - if (needCheckVersion) { - if (info.versionCode != versionCode) { - return false; - } - } - return true; -} - -bool BmsBundleUpdaterTest::CheckApplicationInfo() const -{ - ApplicationInfo info; - auto dataMgr = GetBundleDataMgr(); - if (dataMgr == nullptr) { - return false; - } - bool result = dataMgr->GetApplicationInfo(PACKAGE_NAME, ApplicationFlag::GET_BASIC_APPLICATION_INFO, USERID, info); - return result; -} - -/** - * @tc.number: Update_0100 - * @tc.name: test the same version bundle can be reinstalled - * @tc.desc: 1. the bundle is already installed - * 2. the same version bundle can be reinstalled successfully - */ -HWTEST_F(BmsBundleUpdaterTest, Update_0100, Function | SmallTest | Level2) -{ - ErrCode installResult = InstallBundle(BUNDLE_FILE_DIR + V1_BUNDLE); - EXPECT_EQ(installResult, ERR_OK); - CommonTool tool; - long codeDirFirstCreateTime = tool.GetFileBuildTime(BUNDLE_CODE_DIR.c_str()); - long dataDirFirstCreateTime = tool.GetFileBuildTime(BUNDLE_DATA_DIR.c_str()); - - // need to wait for 1s since the file create time counts in second unit. - std::this_thread::sleep_for(SLEEP_TIME); - - ErrCode updateResult = UpdateBundle(BUNDLE_FILE_DIR + V2_BUNDLE, true); - EXPECT_EQ(updateResult, ERR_OK); - - long codeDirSecondCreateTime = tool.GetFileBuildTime(BUNDLE_CODE_DIR.c_str()); - long dataDirSecondCreateTime = tool.GetFileBuildTime(BUNDLE_DATA_DIR.c_str()); - EXPECT_EQ(dataDirFirstCreateTime, dataDirSecondCreateTime); - EXPECT_NE(codeDirFirstCreateTime, codeDirSecondCreateTime); - - bool isExist = CheckBundleInfo(VERSION_2, true); - EXPECT_TRUE(isExist); -} - -/** - * @tc.number: Update_0200 - * @tc.name: test the larger version bundle can be updated - * @tc.desc: 1. the bundle is already installed - * 2. the larger version bundle can be updated successfully - */ -HWTEST_F(BmsBundleUpdaterTest, Update_0200, Function | SmallTest | Level1) -{ - ErrCode installResult = InstallBundle(BUNDLE_FILE_DIR + V2_BUNDLE); - EXPECT_EQ(installResult, ERR_OK); - - ErrCode updateResult = UpdateBundle(BUNDLE_FILE_DIR + V3_BUNDLE); - EXPECT_EQ(updateResult, ERR_OK); - CheckFileExist(); - - bool result = CheckBundleInfo(VERSION_3, true); - EXPECT_TRUE(result); -} - -/** - * @tc.number: Update_0300 - * @tc.name: test the empty path can't be updated - * @tc.desc: 1. the bundle file path is empty - * 2. the bundle can't be updated and the result is fail - */ -HWTEST_F(BmsBundleUpdaterTest, Update_0300, Function | SmallTest | Level0) -{ - ErrCode installResult = InstallBundle(BUNDLE_FILE_DIR + V1_BUNDLE); - EXPECT_EQ(installResult, ERR_OK); - - ErrCode updateResult = UpdateBundle(""); - EXPECT_EQ(updateResult, ERR_APPEXECFWK_INSTALL_FILE_PATH_INVALID); -} - -/** - * @tc.number: Update_0400 - * @tc.name: test the wrong path can't be updated - * @tc.desc: 1. the bundle file path is wrong - * 2. the bundle can't be updated and the result is fail - */ -HWTEST_F(BmsBundleUpdaterTest, Update_0400, Function | SmallTest | Level0) -{ - ErrCode installResult = InstallBundle(BUNDLE_FILE_DIR + V1_BUNDLE); - EXPECT_EQ(installResult, ERR_OK); - - ErrCode updateResult = UpdateBundle(BUNDLE_FILE_DIR + ERROR_BUNDLE_NAME); - EXPECT_EQ(updateResult, ERR_APPEXECFWK_INSTALL_INVALID_HAP_NAME); -} - -/** - * @tc.number: Update_0500 - * @tc.name: test the wrong format bundle can't be updated - * @tc.desc: 1. the bundle file is wrong format - * 2. the bundle can't be updated and the result is fail - */ -HWTEST_F(BmsBundleUpdaterTest, Update_0500, Function | SmallTest | Level0) -{ - ErrCode installResult = InstallBundle(BUNDLE_FILE_DIR + V1_BUNDLE); - EXPECT_EQ(installResult, ERR_OK); - - ErrCode updateResult = UpdateBundle(BUNDLE_FILE_DIR + ERROR_FORMART_BUNDLE); - EXPECT_EQ(updateResult, ERR_APPEXECFWK_PARSE_NO_PROFILE); -} - -/** - * @tc.number: Update_0600 - * @tc.name: test the lower version bundle can't be updated - * @tc.desc: 1. the bundle file is the lower version - * 2. the bundle can't be updated and the result is fail - */ -HWTEST_F(BmsBundleUpdaterTest, Update_0600, Function | SmallTest | Level0) -{ - ErrCode installResult = InstallBundle(BUNDLE_FILE_DIR + V2_BUNDLE); - EXPECT_EQ(installResult, ERR_OK); - - ErrCode updateResult = UpdateBundle(BUNDLE_FILE_DIR + V1_BUNDLE); - EXPECT_EQ(updateResult, ERR_APPEXECFWK_INSTALL_VERSION_DOWNGRADE); -} - -/** - * @tc.number: Update_0700 - * @tc.name: test the installd service error case - * @tc.desc: 1. the installd service error - * 2. the update operation will return fail and the next install operation will success after restart installd - * service - */ -HWTEST_F(BmsBundleUpdaterTest, Update_0700, Function | SmallTest | Level1) -{ - ErrCode installResult = InstallBundle(BUNDLE_FILE_DIR + V1_BUNDLE); - EXPECT_EQ(installResult, ERR_OK); - - StopInstalldService(); - ErrCode updateResult = UpdateBundle(BUNDLE_FILE_DIR + V3_BUNDLE); - EXPECT_EQ(updateResult, ERR_APPEXECFWK_INSTALLD_GET_PROXY_ERROR); - - BundleInfo info; - auto dataMgr = GetBundleDataMgr(); - EXPECT_NE(dataMgr, nullptr); - bool isInfoExist = dataMgr->GetBundleInfo(BUNDLE_NAME, BundleFlag::GET_BUNDLE_DEFAULT, info); - EXPECT_TRUE(isInfoExist); - EXPECT_EQ(info.versionCode, VERSION_1); - - StartInstalldService(); - updateResult = UpdateBundle(BUNDLE_FILE_DIR + V3_BUNDLE); - EXPECT_EQ(updateResult, ERR_OK); - EXPECT_EQ(info.versionCode, VERSION_1); - CheckFileExist(); -} - -/** - * @tc.number: Update_0800 - * @tc.name: test the bundle mgr service error case - * @tc.desc: 1. the bundle mgr service error - * 2. the update operation will return fail and the next install operation will success after restart bundle - * mgr service - */ -HWTEST_F(BmsBundleUpdaterTest, Update_0800, Function | SmallTest | Level1) -{ - ErrCode installResult = InstallBundle(BUNDLE_FILE_DIR + V1_BUNDLE); - EXPECT_EQ(installResult, ERR_OK); - - StopBundleService(); - DelayedSingleton::DestroyInstance(); - - sptr installer = new (std::nothrow) BundleInstallerHost(); - EXPECT_NE(installer, nullptr); - installer->Init(); - sptr receiver = new (std::nothrow) MockStatusReceiver(); - EXPECT_NE(receiver, nullptr); - InstallParam installParam; - installParam.installFlag = InstallFlag::REPLACE_EXISTING; - installer->Install(BUNDLE_FILE_DIR + V3_BUNDLE, installParam, receiver); - ErrCode result = receiver->GetResultCode(); - EXPECT_EQ(result, ERR_APPEXECFWK_INSTALL_BUNDLE_MGR_SERVICE_ERROR); - - DelayedSingleton::GetInstance()->OnStart(); - BundleInfo info; - auto dataMgr = GetBundleDataMgr(); - EXPECT_NE(dataMgr, nullptr); - bool isInfoExist = dataMgr->GetBundleInfo(BUNDLE_NAME, BundleFlag::GET_BUNDLE_DEFAULT, info); - EXPECT_TRUE(isInfoExist); - EXPECT_EQ(info.versionCode, VERSION_1); - - ErrCode updateResult = UpdateBundle(BUNDLE_FILE_DIR + V3_BUNDLE); - EXPECT_EQ(updateResult, ERR_OK); - CheckFileExist(); -} - -/** - * @tc.number: Update_0900 - * @tc.name: test when status receiver is null will not update bundle - * @tc.desc: 1. the status receiver is null - * 2. the update bundle operation will not execute when status receiver is null - */ -HWTEST_F(BmsBundleUpdaterTest, Update_0900, Function | SmallTest | Level2) -{ - ErrCode installResult = InstallBundle(BUNDLE_FILE_DIR + V1_BUNDLE); - EXPECT_EQ(installResult, ERR_OK); - CommonTool tool; - long codeDirFirstCreateTime = tool.GetFileBuildTime(BUNDLE_CODE_DIR.c_str()); - long dataDirFirstCreateTime = tool.GetFileBuildTime(BUNDLE_DATA_DIR.c_str()); - - auto installer = DelayedSingleton::GetInstance()->GetBundleInstaller(); - EXPECT_FALSE(!installer); - InstallParam installParam; - installParam.installFlag = InstallFlag::REPLACE_EXISTING; - installer->Install(BUNDLE_FILE_DIR + V2_BUNDLE, installParam, nullptr); - - std::this_thread::sleep_for(50ms); - - long codeDirSecondCreateTime = tool.GetFileBuildTime(BUNDLE_CODE_DIR.c_str()); - long dataDirSecondCreateTime = tool.GetFileBuildTime(BUNDLE_DATA_DIR.c_str()); - - EXPECT_EQ(dataDirFirstCreateTime, dataDirSecondCreateTime); - EXPECT_EQ(codeDirFirstCreateTime, codeDirSecondCreateTime); - - bool isExist = CheckBundleInfo(VERSION_1, true); - EXPECT_TRUE(isExist); -} - -/** - * @tc.number: Update_1000 - * @tc.name: test the larger version bundle can be installed continuously - * @tc.desc: 1. the bundle is already installed - * 2. the larger version bundle can be installed continuously - */ -HWTEST_F(BmsBundleUpdaterTest, Update_1000, Function | SmallTest | Level2) -{ - ErrCode installResult = InstallBundle(BUNDLE_FILE_DIR + V1_BUNDLE); - EXPECT_EQ(installResult, ERR_OK); - CommonTool tool; - long codeDirFirstCreateTime = tool.GetFileBuildTime(BUNDLE_CODE_DIR.c_str()); - long dataDirFirstCreateTime = tool.GetFileBuildTime(BUNDLE_DATA_DIR.c_str()); - - // need to wait for 1s since the file create time counts in second unit. - std::this_thread::sleep_for(SLEEP_TIME); - - ErrCode updateResult = UpdateBundle(BUNDLE_FILE_DIR + V2_BUNDLE); - EXPECT_EQ(updateResult, ERR_OK); - - long codeDirSecondCreateTime = tool.GetFileBuildTime(BUNDLE_CODE_DIR.c_str()); - long dataDirSecondCreateTime = tool.GetFileBuildTime(BUNDLE_DATA_DIR.c_str()); - EXPECT_EQ(dataDirFirstCreateTime, dataDirSecondCreateTime); - EXPECT_NE(codeDirFirstCreateTime, codeDirSecondCreateTime); - - bool isExist = CheckBundleInfo(VERSION_2, true); - EXPECT_TRUE(isExist); - - std::this_thread::sleep_for(SLEEP_TIME); - - updateResult = UpdateBundle(BUNDLE_FILE_DIR + V3_BUNDLE); - EXPECT_EQ(updateResult, ERR_OK); - - long codeDirThirdCreateTime = tool.GetFileBuildTime(BUNDLE_CODE_DIR.c_str()); - long dataDirThirdCreateTime = tool.GetFileBuildTime(BUNDLE_DATA_DIR.c_str()); - EXPECT_EQ(dataDirSecondCreateTime, dataDirThirdCreateTime); - EXPECT_NE(codeDirSecondCreateTime, codeDirThirdCreateTime); - - isExist = CheckBundleInfo(VERSION_3, true); - EXPECT_TRUE(isExist); -} diff --git a/services/bundlemgr/test/unittest/bms_data_mgr_test/bms_data_mgr_test.cpp b/services/bundlemgr/test/unittest/bms_data_mgr_test/bms_data_mgr_test.cpp index f276ed52dc..1f93b728ed 100755 --- a/services/bundlemgr/test/unittest/bms_data_mgr_test/bms_data_mgr_test.cpp +++ b/services/bundlemgr/test/unittest/bms_data_mgr_test/bms_data_mgr_test.cpp @@ -484,36 +484,6 @@ HWTEST_F(BmsDataMgrTest, UpdateInstallState_2000, Function | SmallTest | Level0) EXPECT_FALSE(ret1); } -/** - * @tc.number: LoadDataFromPersistentStorage_0100 - * @tc.name: LoadDataFromPersistentStorage - * @tc.desc: 1. NA - * 2. load data from persistent storage - */ -HWTEST_F(BmsDataMgrTest, LoadDataFromPersistentStorage_0100, Function | SmallTest | Level0) -{ - auto dataMgr = GetDataMgr(); - EXPECT_NE(dataMgr, nullptr); - bool ret1 = dataMgr->LoadDataFromPersistentStorage(); - EXPECT_FALSE(ret1); - - InnerBundleInfo info; - BundleInfo bundleInfo; - bundleInfo.name = BUNDLE_NAME; - bundleInfo.applicationInfo.name = APP_NAME; - ApplicationInfo applicationInfo; - applicationInfo.name = BUNDLE_NAME; - info.SetBaseBundleInfo(bundleInfo); - info.SetBaseApplicationInfo(applicationInfo); - - std::shared_ptr dataStorage_ = std::make_shared(); - dataStorage_->SaveStorageBundleInfo(Constants::CURRENT_DEVICE_ID, info); - - bool ret2 = dataMgr->LoadDataFromPersistentStorage(); - EXPECT_TRUE(ret2); - dataStorage_->DeleteStorageBundleInfo(Constants::CURRENT_DEVICE_ID, info); -} - /** * @tc.number: AddBundleInfo_0100 * @tc.name: AddBundleInfo diff --git a/services/bundlemgr/test/unittest/bms_install_daemon_test/bms_install_daemon_test.cpp b/services/bundlemgr/test/unittest/bms_install_daemon_test/bms_install_daemon_test.cpp index b8c87eb818..4b15320c5b 100755 --- a/services/bundlemgr/test/unittest/bms_install_daemon_test/bms_install_daemon_test.cpp +++ b/services/bundlemgr/test/unittest/bms_install_daemon_test/bms_install_daemon_test.cpp @@ -376,7 +376,7 @@ HWTEST_F(BmsInstallDaemonTest, BundleDataDir_0100, Function | SmallTest | Level0 /** * @tc.number: BundleDataDir_0200 * @tc.name: test the create and clean bundle data dir function of installd service -* @tc.desc: 1. the service is already initialized +* @tc.desc: 1. the service is already initialized * 2. the bundle data dir of the right code dir can be created and clean */ HWTEST_F(BmsInstallDaemonTest, BundleDataDir_0200, Function | SmallTest | Level0) @@ -447,27 +447,9 @@ HWTEST_F(BmsInstallDaemonTest, BundleDataDir_0600, Function | SmallTest | Level0 EXPECT_FALSE(dirExist); } -/** -* @tc.number: ExtractBundleFile_0100 -* @tc.name: test the ExtractBundleFile function of installd service with flag system bundle -* @tc.desc: 1. the bundle file is available and the target dir exists -* 2. the origin file exists and the extracted file exists -*/ -HWTEST_F(BmsInstallDaemonTest, ExtractBundleFile_0100, Function | SmallTest | Level0) -{ - CreateBundleDir(BUNDLE_CODE_DIR); - bool dirExist = CheckBundleDirExist(); - EXPECT_TRUE(dirExist); - auto bundleFile = BUNDLE_FILE; - int result = ExtractModuleFiles(bundleFile, TEMP_DIR); - EXPECT_EQ(result, 0); - int result1 = RenameModuleDir(TEMP_DIR, MODULE_DIR); - EXPECT_EQ(result1, 0); -} - /** * @tc.number: ExtractBundleFile_0200 -* @tc.name: test the ExtractBundleFile function of installd service +* @tc.name: test the ExtractBundleFile function of installd service * @tc.desc: 1. the bundle file is illegal * 2. the bundle file can't be extracted and the extracted file does not exists */ @@ -482,7 +464,7 @@ HWTEST_F(BmsInstallDaemonTest, ExtractBundleFile_0200, Function | SmallTest | Le /** * @tc.number: ExtractBundleFile_0300 -* @tc.name: test the ExtractBundleFile function of installd service +* @tc.name: test the ExtractBundleFile function of installd service * @tc.desc: 1. the temp dir does not exist * 2. the bundle file can't be extracted and the extracted file does not exists */ @@ -494,40 +476,4 @@ HWTEST_F(BmsInstallDaemonTest, ExtractBundleFile_0300, Function | SmallTest | Le auto bundleFile = BUNDLE_FILE; int result = ExtractModuleFiles(bundleFile, ""); EXPECT_EQ(result, ERR_APPEXECFWK_INSTALLD_PARAM_ERROR); -} - -/** -* @tc.number: ExtractBundleFile_0400 -* @tc.name: test the ExtractBundleFile function of installd service -* @tc.desc: 1. the old path does not exist -* 2. the bundle file can't be extracted and the extracted file does not exists -*/ -HWTEST_F(BmsInstallDaemonTest, ExtractBundleFile_0400, Function | SmallTest | Level0) -{ - CreateBundleDir(BUNDLE_CODE_DIR); - bool dirExist = CheckBundleDirExist(); - EXPECT_TRUE(dirExist); - auto bundleFile = BUNDLE_FILE; - int result = ExtractModuleFiles(bundleFile, TEMP_DIR); - EXPECT_EQ(result, 0); - int result1 = RenameModuleDir("", MODULE_DIR); - EXPECT_EQ(result1, ERR_APPEXECFWK_INSTALLD_PARAM_ERROR); -} - -/** -* @tc.number: ExtractBundleFile_0500 -* @tc.name: test the ExtractBundleFile function of installd service -* @tc.desc: 1. the new path does not exist -* 2. the bundle file can't be extracted and the extracted file does not exists -*/ -HWTEST_F(BmsInstallDaemonTest, ExtractBundleFile_0500, Function | SmallTest | Level0) -{ - CreateBundleDir(BUNDLE_CODE_DIR); - bool dirExist = CheckBundleDirExist(); - EXPECT_TRUE(dirExist); - auto bundleFile = BUNDLE_FILE; - int result = ExtractModuleFiles(bundleFile, TEMP_DIR); - EXPECT_EQ(result, 0); - int result1 = RenameModuleDir(TEMP_DIR, ""); - EXPECT_EQ(result1, ERR_APPEXECFWK_INSTALLD_PARAM_ERROR); -} +} \ No newline at end of file -- Gitee