diff --git a/services/bundlemgr/test/unittest/bms_bundle_kit_service_test/bms_bundle_data_mgr_test.cpp b/services/bundlemgr/test/unittest/bms_bundle_kit_service_test/bms_bundle_data_mgr_test.cpp index eb4573cc8a262e92b819b041028220f9e2650f7a..6d32e936c20a72a1151e8a3381f798511c40433c 100644 --- a/services/bundlemgr/test/unittest/bms_bundle_kit_service_test/bms_bundle_data_mgr_test.cpp +++ b/services/bundlemgr/test/unittest/bms_bundle_kit_service_test/bms_bundle_data_mgr_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Huawei Device Co., Ltd. + * Copyright (c) 2023-2024 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 @@ -1420,6 +1420,7 @@ HWTEST_F(BmsBundleDataMgrTest, GetBundleStats_0100, Function | SmallTest | Level * @tc.desc: 1.system run normally * 2.check GetBundleSpaceSize failed */ +#ifdef BUNDLE_FRAMEWORK_FREE_INSTALL HWTEST_F(BmsBundleDataMgrTest, GetBundleSpaceSize_0100, Function | SmallTest | Level1) { std::vector bundleStats; @@ -1459,6 +1460,7 @@ HWTEST_F(BmsBundleDataMgrTest, GetAllFreeInstallBundleSpaceSize_0100, Function | MockUninstallBundle(BUNDLE_NAME_TEST); } +#endif /** * @tc.number: QueryKeepAliveBundleInfos_0100 @@ -1696,6 +1698,7 @@ HWTEST_F(BmsBundleDataMgrTest, GenerateUidAndGid_0100, Function | SmallTest | Le GetBundleDataMgr()->bundleInfos_.emplace(BUNDLE_NAME_TEST, innerBundleInfo); bool res = GetBundleDataMgr()->GenerateUidAndGid(innerBundleUserInfo); EXPECT_EQ(res, false); + GetBundleDataMgr()->bundleInfos_.clear(); } /** @@ -1711,7 +1714,25 @@ HWTEST_F(BmsBundleDataMgrTest, GetAllFormsInfo_0100, Function | SmallTest | Leve innerBundleInfo.SetBundleStatus(InnerBundleInfo::BundleStatus::DISABLED); GetBundleDataMgr()->bundleInfos_.emplace(BUNDLE_NAME_TEST, innerBundleInfo); bool res = GetBundleDataMgr()->GetAllFormsInfo(formInfos); + EXPECT_EQ(res, false); + GetBundleDataMgr()->bundleInfos_.clear(); +} + +/** + * @tc.number: GetAllFormsInfo_0200 + * @tc.name: test GetAllFormsInfo + * @tc.desc: 1.system run normally + * 2.check GetAllFormsInfo failed + */ +HWTEST_F(BmsBundleDataMgrTest, GetAllFormsInfo_0200, Function | SmallTest | Level1) +{ + std::vector formInfos; + InnerBundleInfo innerBundleInfo; + innerBundleInfo.SetBundleStatus(InnerBundleInfo::BundleStatus::ENABLED); + GetBundleDataMgr()->bundleInfos_.emplace(BUNDLE_NAME_TEST, innerBundleInfo); + bool res = GetBundleDataMgr()->GetAllFormsInfo(formInfos); EXPECT_EQ(res, true); + GetBundleDataMgr()->bundleInfos_.clear(); } /** @@ -1728,6 +1749,7 @@ HWTEST_F(BmsBundleDataMgrTest, GetFormsInfoByModule_0100, Function | SmallTest | GetBundleDataMgr()->bundleInfos_.emplace(BUNDLE_NAME_TEST, innerBundleInfo); bool res = GetBundleDataMgr()->GetFormsInfoByModule(BUNDLE_NAME_TEST, BUNDLE_NAME_TEST, formInfos); EXPECT_EQ(res, false); + GetBundleDataMgr()->bundleInfos_.clear(); } /** @@ -1858,6 +1880,7 @@ HWTEST_F(BmsBundleDataMgrTest, QueryExtensionAbilityInfos_0300, Function | Small bool ret = GetBundleDataMgr()->QueryExtensionAbilityInfos( ExtensionAbilityType::FORM, USERID, extensionInfo); EXPECT_EQ(ret, true); + EXPECT_TRUE(extensionInfo.empty()); GetBundleDataMgr()->multiUserIdsSet_.clear(); } @@ -1894,23 +1917,6 @@ HWTEST_F(BmsBundleDataMgrTest, ExplicitQueryExtensionInfo_0100, Function | Small GetBundleDataMgr()->multiUserIdsSet_.clear(); } -/** - * @tc.number: ImplicitQueryCurExtensionInfos_0100 - * @tc.name: test ImplicitQueryCurExtensionInfos - * @tc.desc: 1.system run normally - * 2.check ImplicitQueryCurExtensionInfos failed - */ -HWTEST_F(BmsBundleDataMgrTest, ImplicitQueryCurExtensionInfos_0100, Function | SmallTest | Level1) -{ - Want want; - std::vector infos; - int32_t appIndex = 0; - GetBundleDataMgr()->sandboxAppHelper_ = DelayedSingleton::GetInstance(); - bool testRet = GetBundleDataMgr()->ImplicitQueryCurExtensionInfos( - want, GET_ABILITY_INFO_DEFAULT, USERID, infos, appIndex); - EXPECT_EQ(testRet, false); -} - /** * @tc.number: ImplicitQueryCurExtensionInfos_0200 * @tc.name: test ImplicitQueryCurExtensionInfos @@ -1928,6 +1934,10 @@ HWTEST_F(BmsBundleDataMgrTest, ImplicitQueryCurExtensionInfos_0200, Function | S bool testRet = GetBundleDataMgr()->ImplicitQueryCurExtensionInfos( want, GET_ABILITY_INFO_DEFAULT, Constants::INVALID_UID, infos, appIndex); EXPECT_EQ(testRet, false); + GetBundleDataMgr()->sandboxAppHelper_ = nullptr; + bool testRet1 = GetBundleDataMgr()->ImplicitQueryCurExtensionInfos( + want, GET_ABILITY_INFO_DEFAULT, Constants::INVALID_UID, infos, appIndex); + EXPECT_EQ(testRet1, false); } /** @@ -1954,6 +1964,7 @@ HWTEST_F(BmsBundleDataMgrTest, ImplicitQueryCurExtensionInfos_0300, Function | S bool testRet = GetBundleDataMgr()->ImplicitQueryCurExtensionInfos( want, GET_ABILITY_INFO_DEFAULT, USERID, infos, appIndex); EXPECT_EQ(testRet, false); + GetBundleDataMgr()->bundleInfos_.clear(); } /** @@ -1964,34 +1975,6 @@ HWTEST_F(BmsBundleDataMgrTest, ImplicitQueryCurExtensionInfos_0300, Function | S */ HWTEST_F(BmsBundleDataMgrTest, ImplicitQueryCurExtensionInfos_0400, Function | SmallTest | Level1) { - GetBundleDataMgr()->bundleInfos_.clear(); - - Want want; - std::vector infos; - int32_t appIndex = 0; - GetBundleDataMgr()->ImplicitQueryAllExtensionInfos( - want, GET_ABILITY_INFO_DEFAULT, USERID, infos, appIndex); - GetBundleDataMgr()->sandboxAppHelper_ = DelayedSingleton::GetInstance(); - bool testRet = GetBundleDataMgr()->ImplicitQueryCurExtensionInfos( - want, GET_ABILITY_INFO_DEFAULT, USERID, infos, appIndex); - EXPECT_EQ(testRet, false); -} - -/** - * @tc.number: ImplicitQueryCurExtensionInfos_0500 - * @tc.name: test ImplicitQueryCurExtensionInfos - * @tc.desc: 1.system run normally - * 2.check ImplicitQueryCurExtensionInfos failed - */ -HWTEST_F(BmsBundleDataMgrTest, ImplicitQueryCurExtensionInfos_0500, Function | SmallTest | Level1) -{ - InnerBundleInfo innerBundleInfo; - ApplicationInfo applicationInfo; - applicationInfo.bundleName = BUNDLE_NAME_TEST; - innerBundleInfo.SetBaseApplicationInfo(applicationInfo); - innerBundleInfo.SetBundleStatus(InnerBundleInfo::BundleStatus::DISABLED); - GetBundleDataMgr()->bundleInfos_.emplace(BUNDLE_NAME_TEST, innerBundleInfo); - Want want; std::vector infos; int32_t appIndex = 0; @@ -2259,6 +2242,7 @@ HWTEST_F(BmsBundleDataMgrTest, CheckAbilityEnableInstall_0100, Function | Medium * @tc.name: test UpgradeAtomicService * @tc.desc: 1.test UpgradeAtomicService */ +#ifdef BUNDLE_FRAMEWORK_FREE_INSTALL HWTEST_F(BmsBundleDataMgrTest, UpgradeAtomicService_0100, Function | MediumTest | Level1) { AAFwk::Want want; @@ -2267,6 +2251,7 @@ HWTEST_F(BmsBundleDataMgrTest, UpgradeAtomicService_0100, Function | MediumTest bundleMgrHostImpl_->UpgradeAtomicService(want, USERID); ASSERT_NE(ret, nullptr); } +#endif /** * @tc.number: CheckAbilityEnableInstall_0200 @@ -3418,6 +3403,7 @@ HWTEST_F(BmsBundleDataMgrTest, RemoveModuleInfo_0300, Function | SmallTest | Lev std::string key = "key"; info.baseAbilityInfos_.try_emplace(key, abilityInfo); info.RemoveModuleInfo(PACKAGE_NAME); + EXPECT_TRUE(info.innerModuleInfos_.empty()); auto abilityItem = info.baseAbilityInfos_.find("keys"); EXPECT_EQ(abilityItem, info.baseAbilityInfos_.end()); @@ -3441,6 +3427,7 @@ HWTEST_F(BmsBundleDataMgrTest, RemoveModuleInfo_0400, Function | SmallTest | Lev std::string key = "key"; info.skillInfos_.try_emplace(key, skills); info.RemoveModuleInfo(PACKAGE_NAME); + EXPECT_TRUE(info.innerModuleInfos_.empty()); auto skillItem = info.skillInfos_.find("keys"); EXPECT_EQ(skillItem, info.skillInfos_.end()); @@ -3464,6 +3451,7 @@ HWTEST_F(BmsBundleDataMgrTest, RemoveModuleInfo_0500, Function | SmallTest | Lev std::string key = "key"; info.baseExtensionInfos_.try_emplace(key, extensionAbilityInfo); info.RemoveModuleInfo(PACKAGE_NAME); + EXPECT_TRUE(info.innerModuleInfos_.empty()); auto extensionItem = info.baseExtensionInfos_.find("keys"); EXPECT_EQ(extensionItem, info.baseExtensionInfos_.end()); @@ -3487,6 +3475,7 @@ HWTEST_F(BmsBundleDataMgrTest, RemoveModuleInfo_0600, Function | SmallTest | Lev std::string key = "key"; info.extensionSkillInfos_.try_emplace(key, skills); info.RemoveModuleInfo(PACKAGE_NAME); + EXPECT_TRUE(info.innerModuleInfos_.empty()); auto extensionSkillItem = info.extensionSkillInfos_.find("keys"); EXPECT_EQ(extensionSkillItem, info.extensionSkillInfos_.end()); @@ -3530,6 +3519,7 @@ HWTEST_F(BmsBundleDataMgrTest, ProcessBundleWithHapModuleInfoFlag_0100, Function static_cast(GetBundleInfoFlag::GET_BUNDLE_INFO_WITH_HAP_MODULE), bundleInfo, USERID); auto it = info.FindHapModuleInfo(PACKAGE_NAME, USERID); EXPECT_EQ(it->hqfInfo.moduleName, ""); + EXPECT_EQ(it->name, MODULE_NAME1); } /** diff --git a/services/bundlemgr/test/unittest/bms_bundle_mgr_service_death_recipient_test/bms_bundle_mgr_service_death_recipient_test.cpp b/services/bundlemgr/test/unittest/bms_bundle_mgr_service_death_recipient_test/bms_bundle_mgr_service_death_recipient_test.cpp index 8a420183b7cdd2a2b9d043640851b0866f36c179..865c0b39f74b49ac4503aabe8bdf7c84ac59ae29 100644 --- a/services/bundlemgr/test/unittest/bms_bundle_mgr_service_death_recipient_test/bms_bundle_mgr_service_death_recipient_test.cpp +++ b/services/bundlemgr/test/unittest/bms_bundle_mgr_service_death_recipient_test/bms_bundle_mgr_service_death_recipient_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Huawei Device Co., Ltd. + * Copyright (c) 2023-2024 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 @@ -54,20 +54,5 @@ HWTEST_F(BmsBundleMgrServiceDeathRecipientTest, BundleMgrServiceDeathRecipient_0 bundleMgrServiceDeathRecipient.OnRemoteDied(object); EXPECT_EQ(bundleMgrServiceDeathRecipient.deathCallback_, nullptr); } - -/** - * @tc.number: BundleMgrServiceDeathRecipient_002 - * @tc.name: OnRemoteDied - * @tc.desc: When deathCallback_ is empty, Successful case of verifying OnRemoteDied. - */ -HWTEST_F(BmsBundleMgrServiceDeathRecipientTest, BundleMgrServiceDeathRecipient_002, TestSize.Level1) -{ - const wptr object; - const std::function& object)> deathCallback; - BundleMgrServiceDeathRecipient bundleMgrServiceDeathRecipient(deathCallback); - bundleMgrServiceDeathRecipient.deathCallback_ = nullptr; - bundleMgrServiceDeathRecipient.OnRemoteDied(object); - EXPECT_EQ(bundleMgrServiceDeathRecipient.deathCallback_, nullptr); -} } // namespace AppExecFwk } // namespace OHOS \ No newline at end of file diff --git a/services/bundlemgr/test/unittest/bms_bundle_overlay_test/bms_bundle_get_overlay_module_info_test.cpp b/services/bundlemgr/test/unittest/bms_bundle_overlay_test/bms_bundle_get_overlay_module_info_test.cpp index e2c3a52bcbdb78184a9c4fbdfec6622e86c46e2e..83a8a373b64a5487aa1ae4ebd82fbb425448fe8b 100644 --- a/services/bundlemgr/test/unittest/bms_bundle_overlay_test/bms_bundle_get_overlay_module_info_test.cpp +++ b/services/bundlemgr/test/unittest/bms_bundle_overlay_test/bms_bundle_get_overlay_module_info_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Huawei Device Co., Ltd. + * Copyright (c) 2023-2024 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 @@ -403,27 +403,10 @@ HWTEST_F(BmsBundleGetOverlayModuleInfoTest, GetOverlayModuleInfoTest_0900, Funct OverlayModuleInfo overlayModuleInfo; auto res = hostImpl->GetOverlayModuleInfo(TEST_BUNDLE_NAME, TEST_MODULE_NAME_SECOND, overlayModuleInfo, USERID); EXPECT_EQ(res, ERR_BUNDLEMANAGER_OVERLAY_QUERY_FAILED_NON_OVERLAY_MODULE); - RemoveBundleInfo(TEST_BUNDLE_NAME); -} - -/** - * @tc.number: GetOverlayModuleInfoTest_1000 - * @tc.name: test GetOverlayModuleInfo interface in OverlayManagerHostImpl. - * @tc.desc: 1.the specified bundle is not overlay bundle - * 2.get failed. - * @tc.require: issueI6F3H9 - */ -HWTEST_F(BmsBundleGetOverlayModuleInfoTest, GetOverlayModuleInfoTest_1000, Function | SmallTest | Level0) -{ - // get OverlayManagerHostImpl instance - auto hostImpl = std::make_shared(); - EXPECT_NE(hostImpl, nullptr); - - AddOverlayInnerBundleInfo(OverlayType::OVERLAY_INTERNAL_BUNDLE); - - OverlayModuleInfo overlayModuleInfo; - auto res = hostImpl->GetOverlayModuleInfo(TEST_BUNDLE_NAME, TEST_MODULE_NAME_SECOND, overlayModuleInfo, USERID); - EXPECT_EQ(res, ERR_BUNDLEMANAGER_OVERLAY_QUERY_FAILED_NON_OVERLAY_MODULE); + auto res1 = hostImpl->GetOverlayModuleInfo("", TEST_MODULE_NAME_SECOND, overlayModuleInfo, USERID); + EXPECT_EQ(res1, ERR_BUNDLEMANAGER_OVERLAY_QUERY_FAILED_PARAM_ERROR); + auto res2 = hostImpl->GetOverlayModuleInfo(TEST_BUNDLE_NAME, "", overlayModuleInfo, USERID); + EXPECT_EQ(res2, ERR_BUNDLEMANAGER_OVERLAY_QUERY_FAILED_PARAM_ERROR); RemoveBundleInfo(TEST_BUNDLE_NAME); } diff --git a/services/bundlemgr/test/unittest/bms_bundle_overlay_test/bms_bundle_manager_overlay_ipc_test.cpp b/services/bundlemgr/test/unittest/bms_bundle_overlay_test/bms_bundle_manager_overlay_ipc_test.cpp index b6454f65fcd2dd8f5b08f3547c175c7354c5457c..4fcab38233be552b87de8f17e015686b01003125 100644 --- a/services/bundlemgr/test/unittest/bms_bundle_overlay_test/bms_bundle_manager_overlay_ipc_test.cpp +++ b/services/bundlemgr/test/unittest/bms_bundle_overlay_test/bms_bundle_manager_overlay_ipc_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Huawei Device Co., Ltd. + * Copyright (c) 2023-2024 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 @@ -119,25 +119,6 @@ HWTEST_F(BmsBundleManagerIpcTest, BundleManagerOverlayIpcTest_0200, Function | S EXPECT_NE(overlayProxy, nullptr); } -/** - * @tc.number: BundleManagerOverlayIpcTest_0300 - * @tc.name: test GetOverlayManagerProxy interface in BundleMgrProxy. - * @tc.desc: 1.construct BundleMgrProxy instance. - * 2.calling GetOverlayManagerProxy interface by using BundleMgrProxy instance. - * 3.return overlay proxy. - * @tc.require: issueI6F3H9 - */ -HWTEST_F(BmsBundleManagerIpcTest, BundleManagerOverlayIpcTest_0300, Function | SmallTest | Level0) -{ - sptr bundleManagerHostImpl = new (std::nothrow) BundleMgrHostImpl(); - EXPECT_NE(bundleManagerHostImpl, nullptr); - sptr bundleManagerProxy = new (std::nothrow) BundleMgrProxy(bundleManagerHostImpl->AsObject()); - EXPECT_NE(bundleManagerProxy, nullptr); - - auto overlayProxy = bundleManagerProxy->GetOverlayManagerProxy(); - EXPECT_NE(overlayProxy, nullptr); -} - /** * @tc.number: BundleManagerOverlayIpcTest_0400 * @tc.name: test HandleGetOverlayManagerProxy interface in BundleMgrHost. diff --git a/services/bundlemgr/test/unittest/bms_bundle_overlay_test/bms_bundle_overlay_checker_test.cpp b/services/bundlemgr/test/unittest/bms_bundle_overlay_test/bms_bundle_overlay_checker_test.cpp index 580740867d41605b2a239681a77ddfb9116d2a45..78859a028a47d91a54067c0dcf0655aa6ef47c46 100644 --- a/services/bundlemgr/test/unittest/bms_bundle_overlay_test/bms_bundle_overlay_checker_test.cpp +++ b/services/bundlemgr/test/unittest/bms_bundle_overlay_test/bms_bundle_overlay_checker_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Huawei Device Co., Ltd. + * Copyright (c) 2023-2024 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 @@ -1377,24 +1377,30 @@ HWTEST_F(BmsBundleOverlayCheckerTest, OverlayDataMgr_2900, Function | SmallTest moduleInfo.distro.moduleType = Profile::MODULE_TYPE_ENTRY; innerModuleInfos[TEST_PACK_AGE] = moduleInfo; oldInfo.AddInnerModuleInfo(innerModuleInfos); + overlayDataMgr.RemoveOverlayBundleInfo(TEST_BUNDLE_NAME, targetInnerBundleInfo); overlayDataMgr.RemoveOverlayModuleInfo(TEST_BUNDLE_NAME, TEST_PACK_AGE, oldInfo, targetInnerBundleInfo); oldInfo.SetOverlayType(OVERLAY_INTERNAL_BUNDLE); overlayDataMgr.RemoveOverlayModuleInfo(TEST_BUNDLE_NAME, TEST_PACK_AGE, oldInfo, targetInnerBundleInfo); + EXPECT_EQ(oldInfo.GetOverlayType(), OVERLAY_INTERNAL_BUNDLE); oldInfo.SetTargetBundleName(TARGET_MODULE_NAME); overlayDataMgr.RemoveOverlayModuleInfo(TEST_BUNDLE_NAME, TEST_PACK_AGE, oldInfo, targetInnerBundleInfo); + EXPECT_EQ(oldInfo.GetTargetBundleName(), TARGET_MODULE_NAME); oldInfo.SetOverlayType(OVERLAY_EXTERNAL_BUNDLE); overlayDataMgr.RemoveOverlayModuleInfo(TEST_BUNDLE_NAME, TEST_PACK_AGE, oldInfo, targetInnerBundleInfo); + EXPECT_EQ(oldInfo.GetOverlayType(), OVERLAY_EXTERNAL_BUNDLE); oldInfo.SetTargetBundleName(TARGET_MODULE_NAME); overlayDataMgr.RemoveOverlayModuleInfo(TEST_BUNDLE_NAME, TEST_PACK_AGE, oldInfo, targetInnerBundleInfo); + EXPECT_EQ(oldInfo.GetTargetBundleName(), TARGET_MODULE_NAME); oldInfo.SetOverlayType(NON_OVERLAY_TYPE); overlayDataMgr.RemoveOverlayModuleInfo(TEST_BUNDLE_NAME, TEST_PACK_AGE, oldInfo, targetInnerBundleInfo); overlayDataMgr.RemoveOverlayModuleInfo("noExits", TEST_PACK_AGE, oldInfo, targetInnerBundleInfo); + EXPECT_EQ(oldInfo.GetOverlayType(), NON_OVERLAY_TYPE); UninstallBundleInfo(); } @@ -1746,8 +1752,10 @@ HWTEST_F(BmsBundleOverlayCheckerTest, OverlayDataMgr_4200, Function | SmallTest moduleInfo.targetModuleName = TEST_PACK_AGE; innerModuleInfos[TEST_MODULE_NAME] = moduleInfo; oldInfo.AddInnerModuleInfo(innerModuleInfos); + EXPECT_EQ(oldInfo.GetOverlayType(), OVERLAY_INTERNAL_BUNDLE); ClearDataMgr(); + EXPECT_EQ(bundleMgrService_->dataMgr_, nullptr); BuildInternalOverlayConnection(TEST_MODULE_NAME, oldInfo, USERID); ResetDataMgr(); } @@ -2556,10 +2564,13 @@ HWTEST_F(BmsBundleOverlayCheckerTest, TestOverlayByDataMgrFalse_1700, Function | OverlayDataMgr overlayDataMgr; InnerBundleInfo oldInfo; oldInfo.SetOverlayType(OVERLAY_EXTERNAL_BUNDLE); + EXPECT_EQ(oldInfo.GetOverlayType(), OVERLAY_EXTERNAL_BUNDLE); ClearDataMgr(); + EXPECT_EQ(bundleMgrService_->dataMgr_, nullptr); BuildInternalOverlayConnection(TEST_MODULE_NAME, oldInfo, USERID); ResetDataMgr(); + EXPECT_NE(bundleMgrService_->dataMgr_, nullptr); } /** @@ -2575,8 +2586,10 @@ HWTEST_F(BmsBundleOverlayCheckerTest, TestOverlayByDataMgrFalse_1900, Function | InnerBundleInfo targetInnerBundleInfo; ClearDataMgr(); + EXPECT_EQ(bundleMgrService_->dataMgr_, nullptr); RemoveOverlayBundleInfo(TEST_MODULE_NAME, targetInnerBundleInfo); ResetDataMgr(); + EXPECT_NE(bundleMgrService_->dataMgr_, nullptr); } /** @@ -2593,8 +2606,10 @@ HWTEST_F(BmsBundleOverlayCheckerTest, TestOverlayByDataMgrFalse_2300, Function | InnerBundleUserInfo userInfo; ClearDataMgr(); + EXPECT_EQ(bundleMgrService_->dataMgr_, nullptr); AddOverlayModuleStates(newInfo, userInfo); ResetDataMgr(); + EXPECT_NE(bundleMgrService_->dataMgr_, nullptr); } /** diff --git a/services/bundlemgr/test/unittest/bms_bundle_permission_grant_test/bms_bundle_permission_false_test.cpp b/services/bundlemgr/test/unittest/bms_bundle_permission_grant_test/bms_bundle_permission_false_test.cpp index 2e0701116ed0c14c3eba2089e08e50705aa25912..f4825902f4b789ae4e08d0813f09db2cb5289594 100644 --- a/services/bundlemgr/test/unittest/bms_bundle_permission_grant_test/bms_bundle_permission_false_test.cpp +++ b/services/bundlemgr/test/unittest/bms_bundle_permission_grant_test/bms_bundle_permission_false_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Huawei Device Co., Ltd. + * Copyright (c) 2023-2024 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 @@ -764,21 +764,6 @@ HWTEST_F(BmsBundlePermissionFalseTest, BmsBundlePermissionFalseTest_4800, Functi EXPECT_EQ(ret, false); } -/** - * @tc.number: BmsBundlePermissionFalseTest_4900 - * @tc.name: test QueryExtensionAbilityInfos of BundleMgrHostImpl - * @tc.desc: 1. system running normally - * 2. QueryExtensionAbilityInfos false by no permission - */ -HWTEST_F(BmsBundlePermissionFalseTest, BmsBundlePermissionFalseTest_4900, Function | SmallTest | Level0) -{ - Want want; - std::vector extensionInfos; - bool ret = bundleMgrHostImpl_->QueryExtensionAbilityInfos( - want, ExtensionAbilityType::FORM, FLAGS, USERID, extensionInfos); - EXPECT_EQ(ret, false); -} - /** * @tc.number: BmsBundlePermissionFalseTest_5000 * @tc.name: test QueryExtensionAbilityInfos of BundleMgrHostImpl @@ -1435,22 +1420,6 @@ HWTEST_F(BmsBundlePermissionFalseTest, BmsBundlePermissionFalseTest_9500, Functi EXPECT_EQ(ret, false); } -/** - * @tc.number: BmsBundlePermissionFalseTest_9600 - * @tc.name: test Uninstall of BundleInstallerHost - * @tc.desc: 1. system running normally - * 2. Uninstall false by no permission - */ -HWTEST_F(BmsBundlePermissionFalseTest, BmsBundlePermissionFalseTest_9600, Function | SmallTest | Level0) -{ - InstallParam installParam; - sptr statusReceiver = new (std::nothrow) MockStatusReceiver(); - EXPECT_NE(statusReceiver, nullptr); - bundleInstallerHost_->Init(); - bool ret = bundleInstallerHost_->Uninstall(BUNDLE_NAME, installParam, statusReceiver); - EXPECT_EQ(ret, false); -} - /** * @tc.number: BmsBundlePermissionFalseTest_9700 * @tc.name: test Uninstall of BundleInstallerHost diff --git a/services/bundlemgr/test/unittest/bms_bundle_resource_manager_test/bms_bundle_resource_manager_test.cpp b/services/bundlemgr/test/unittest/bms_bundle_resource_manager_test/bms_bundle_resource_manager_test.cpp index d4145941681082e9007d6437d66dde810a05f4a4..6df4b38ce8a02c73b9c8467f02ae052a06f16bc0 100644 --- a/services/bundlemgr/test/unittest/bms_bundle_resource_manager_test/bms_bundle_resource_manager_test.cpp +++ b/services/bundlemgr/test/unittest/bms_bundle_resource_manager_test/bms_bundle_resource_manager_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Huawei Device Co., Ltd. + * Copyright (c) 2022-2024 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 @@ -416,22 +416,6 @@ HWTEST_F(BmsBundleResourceManagerTest, GetIconById_009, Function | SmallTest | L EXPECT_EQ(iconBase64, ""); } -/** - * @tc.name: GetIconById_0010 - * @tc.type: FUNC - * @tc.desc: 1.install the hap - * 2.GetIconById - * @tc.require: issueI5MZ4C - */ -HWTEST_F(BmsBundleResourceManagerTest, GetIconById_0010, Function | SmallTest | Level0) -{ - auto dataMgr = GetBundleDataMgr(); - EXPECT_NE(dataMgr, nullptr); - std::string iconBase64 = - dataMgr->GetIconById(BUNDLE_NAME, MODULE_NAME, ABILITY_ICON_ID, 0, USER_ID); - EXPECT_NE(iconBase64, ""); -} - /** * @tc.name: GetIconById_0011 * @tc.type: FUNC diff --git a/services/bundlemgr/test/unittest/bms_bundle_resource_test/bms_bundle_resource_test.cpp b/services/bundlemgr/test/unittest/bms_bundle_resource_test/bms_bundle_resource_test.cpp index 0c693ce6c95794d767a6da3d9243d77ea5267611..f577f6f49829b3c65e35dad7381467c8f965a0ce 100644 --- a/services/bundlemgr/test/unittest/bms_bundle_resource_test/bms_bundle_resource_test.cpp +++ b/services/bundlemgr/test/unittest/bms_bundle_resource_test/bms_bundle_resource_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022-2023 Huawei Device Co., Ltd. + * Copyright (c) 2023-2024 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 @@ -1648,6 +1648,10 @@ HWTEST_F(BmsBundleResourceTest, BmsBundleResourceTest_0074, Function | SmallTest ans = callback.OnSystemColorModeChanged(colorMode); EXPECT_TRUE(ans); + BundleSystemState::GetInstance().SetSystemColorMode(colorMode); + ans = callback.OnSystemColorModeChanged(colorMode); + EXPECT_TRUE(ans); + BundleSystemState::GetInstance().SetSystemColorMode(oldColorMode); } @@ -1672,7 +1676,7 @@ HWTEST_F(BmsBundleResourceTest, BmsBundleResourceTest_0075, Function | SmallTest ans = callback.OnSystemLanguageChange(oldLanguage); EXPECT_TRUE(ans); - BundleSystemState::GetInstance().SetSystemLanguage(oldLanguage); + BundleSystemState::GetInstance().SetSystemColorMode(oldLanguage); } /** diff --git a/services/bundlemgr/test/unittest/bms_bundle_sandbox_app_test/bms_bundle_sandbox_app_test.cpp b/services/bundlemgr/test/unittest/bms_bundle_sandbox_app_test/bms_bundle_sandbox_app_test.cpp index e87aa9bab71dc267f8dc6e1d9ae49b98fff67aff..60c8870d52389e0d5aec127ed87a0c3c4054e80c 100644 --- a/services/bundlemgr/test/unittest/bms_bundle_sandbox_app_test/bms_bundle_sandbox_app_test.cpp +++ b/services/bundlemgr/test/unittest/bms_bundle_sandbox_app_test/bms_bundle_sandbox_app_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Huawei Device Co., Ltd. + * Copyright (c) 2022-2024 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 @@ -393,15 +393,22 @@ void BmsSandboxAppTest::CheckPathAreNonExisted(const std::string &bundleName, in */ HWTEST_F(BmsSandboxAppTest, BmsSandboxAppInstallTest_0100, Function | SmallTest | Level0) { + std::vector filePaths; + auto bundleFile = RESOURCE_ROOT_PATH + RIGHT_BUNDLE_FIRST; + filePaths.emplace_back(bundleFile); + auto installRes = InstallBundles(filePaths, true); + EXPECT_EQ(installRes, ERR_OK); + int32_t appIndex = 0; auto ret = InstallSandboxApp("", DLP_TYPE_1, USERID, appIndex); EXPECT_EQ(ret, ERR_APPEXECFWK_SANDBOX_INSTALL_PARAM_ERROR); + UninstallBundle(BUNDLE_NAME); } /** * @tc.number: BmsSandboxAppInstallTest_0200 * @tc.name: test anormal input parameters - * @tc.desc: 1.the input dlp type is anormal + * @tc.desc: 1.the input dlp type is anormal INVALID_DLP_TYPE * 2.the sandbox app install failed */ HWTEST_F(BmsSandboxAppTest, BmsSandboxAppInstallTest_0200, Function | SmallTest | Level0) @@ -416,14 +423,13 @@ HWTEST_F(BmsSandboxAppTest, BmsSandboxAppInstallTest_0200, Function | SmallTest auto ret = InstallSandboxApp(BUNDLE_NAME, INVALID_DLP_TYPE, USERID, appIndex); EXPECT_EQ(ret, ERR_APPEXECFWK_SANDBOX_INSTALL_PARAM_ERROR); - auto uninstallRes = UninstallBundle(BUNDLE_NAME); - EXPECT_EQ(uninstallRes, ERR_OK); + UninstallBundle(BUNDLE_NAME); } /** * @tc.number: BmsSandboxAppInstallTest_0300 * @tc.name: test anormal input parameters - * @tc.desc: 1.the input dlp type is anormal + * @tc.desc: 1.the input dlp type is anormal DLP_TYPE_3 * 2.the sandbox app install failed */ HWTEST_F(BmsSandboxAppTest, BmsSandboxAppInstallTest_0300, Function | SmallTest | Level0) @@ -472,9 +478,16 @@ HWTEST_F(BmsSandboxAppTest, BmsSandboxAppInstallTest_0400, Function | SmallTest */ HWTEST_F(BmsSandboxAppTest, BmsSandboxAppInstallTest_0500, Function | SmallTest | Level0) { + std::vector filePaths; + auto bundleFile = RESOURCE_ROOT_PATH + RIGHT_BUNDLE_FIRST; + filePaths.emplace_back(bundleFile); + auto installRes = InstallBundles(filePaths, true); + EXPECT_EQ(installRes, ERR_OK); + int32_t appIndex = 0; auto ret = InstallSandboxApp("", INVALID_DLP_TYPE, USERID, appIndex); EXPECT_EQ(ret, ERR_APPEXECFWK_SANDBOX_INSTALL_PARAM_ERROR); + UninstallBundle(BUNDLE_NAME); } /** @@ -485,11 +498,18 @@ HWTEST_F(BmsSandboxAppTest, BmsSandboxAppInstallTest_0500, Function | SmallTest */ HWTEST_F(BmsSandboxAppTest, BmsSandboxAppInstallTest_0600, Function | SmallTest | Level0) { + std::vector filePaths; + auto bundleFile = RESOURCE_ROOT_PATH + RIGHT_BUNDLE_FIRST; + filePaths.emplace_back(bundleFile); + auto installRes = InstallBundles(filePaths, true); + EXPECT_EQ(installRes, ERR_OK); + int32_t appIndex = 0; auto ret = InstallSandboxApp("", DLP_TYPE_1, INVALID_USERID, appIndex); EXPECT_EQ(ret, ERR_APPEXECFWK_SANDBOX_INSTALL_PARAM_ERROR); ret = InstallSandboxApp("", DLP_TYPE_1, Constants::DEFAULT_USERID - 1, appIndex); EXPECT_EQ(ret, ERR_APPEXECFWK_SANDBOX_INSTALL_PARAM_ERROR); + UninstallBundle(BUNDLE_NAME); } /** @@ -522,9 +542,16 @@ HWTEST_F(BmsSandboxAppTest, BmsSandboxAppInstallTest_0700, Function | SmallTest */ HWTEST_F(BmsSandboxAppTest, BmsSandboxAppInstallTest_0800, Function | SmallTest | Level0) { + std::vector filePaths; + auto bundleFile = RESOURCE_ROOT_PATH + RIGHT_BUNDLE_FIRST; + filePaths.emplace_back(bundleFile); + auto installRes = InstallBundles(filePaths, true); + EXPECT_EQ(installRes, ERR_OK); + int32_t appIndex = 0; auto ret = InstallSandboxApp("", INVALID_DLP_TYPE, INVALID_USERID, appIndex); EXPECT_EQ(ret, ERR_APPEXECFWK_SANDBOX_INSTALL_PARAM_ERROR); + UninstallBundle(BUNDLE_NAME); } /** @@ -587,7 +614,7 @@ HWTEST_F(BmsSandboxAppTest, BmsSandboxAppInstallTest_1100, Function | SmallTest /** * @tc.number: BmsSandboxAppInstallTest_1200 * @tc.name: test original bundle has been installed at other userId - * @tc.desc: 1. the original bundle has been installed at current userId + * @tc.desc: 1. the original bundle has been installed at current userId DLP_TYPE_1 * 2.the sandbox app install successfully */ HWTEST_F(BmsSandboxAppTest, BmsSandboxAppInstallTest_1200, Function | SmallTest | Level1) @@ -611,7 +638,7 @@ HWTEST_F(BmsSandboxAppTest, BmsSandboxAppInstallTest_1200, Function | SmallTest /** * @tc.number: BmsSandboxAppInstallTest_1300 * @tc.name: test original bundle has been installed at other userId - * @tc.desc: 1. the original bundle has been installed at current userId + * @tc.desc: 1. the original bundle has been installed at current userId DLP_TYPE_2 * 2.the sandbox app install successfully */ HWTEST_F(BmsSandboxAppTest, BmsSandboxAppInstallTest_1300, Function | SmallTest | Level1) @@ -915,8 +942,21 @@ HWTEST_F(BmsSandboxAppTest, BmsSandboxAppInstallTest_2100, Function | SmallTest */ HWTEST_F(BmsSandboxAppTest, BmsSandboxAppUnInstallTest_0100, Function | SmallTest | Level0) { - auto ret = UninstallSandboxApp("", APP_INDEX_1, USERID); - EXPECT_EQ(ret, ERR_APPEXECFWK_SANDBOX_INSTALL_PARAM_ERROR); + std::vector filePaths; + auto bundleFile = RESOURCE_ROOT_PATH + RIGHT_BUNDLE_FIRST; + filePaths.emplace_back(bundleFile); + auto installRes = InstallBundles(filePaths, true); + EXPECT_EQ(installRes, ERR_OK); + + int32_t appIndex = 0; + auto ret = InstallSandboxApp(BUNDLE_NAME, DLP_TYPE_1, USERID, appIndex); + EXPECT_EQ(ret, ERR_OK); + EXPECT_EQ(appIndex, APP_INDEX_1); + CheckPathAreExisted(BUNDLE_NAME, APP_INDEX_1); + + auto res = UninstallSandboxApp("", APP_INDEX_1, USERID); + EXPECT_EQ(res, ERR_APPEXECFWK_SANDBOX_INSTALL_PARAM_ERROR); + UninstallBundle(BUNDLE_NAME); } /** @@ -983,8 +1023,21 @@ HWTEST_F(BmsSandboxAppTest, BmsSandboxAppUnInstallTest_0300, Function | SmallTes */ HWTEST_F(BmsSandboxAppTest, BmsSandboxAppUnInstallTest_0400, Function | SmallTest | Level1) { + std::vector filePaths; + auto bundleFile = RESOURCE_ROOT_PATH + RIGHT_BUNDLE_FIRST; + filePaths.emplace_back(bundleFile); + auto installRes = InstallBundles(filePaths, true); + EXPECT_EQ(installRes, ERR_OK); + + int32_t appIndex = 0; + auto ret = InstallSandboxApp(BUNDLE_NAME, DLP_TYPE_1, USERID, appIndex); + EXPECT_EQ(ret, ERR_OK); + EXPECT_EQ(appIndex, APP_INDEX_1); + CheckPathAreExisted(BUNDLE_NAME, APP_INDEX_1); + auto res = UninstallSandboxApp("", INVALID_APP_INDEX, USERID); EXPECT_EQ(res, ERR_APPEXECFWK_SANDBOX_INSTALL_PARAM_ERROR); + UninstallBundle(BUNDLE_NAME); } /** @@ -995,8 +1048,21 @@ HWTEST_F(BmsSandboxAppTest, BmsSandboxAppUnInstallTest_0400, Function | SmallTes */ HWTEST_F(BmsSandboxAppTest, BmsSandboxAppUnInstallTest_0500, Function | SmallTest | Level1) { + std::vector filePaths; + auto bundleFile = RESOURCE_ROOT_PATH + RIGHT_BUNDLE_FIRST; + filePaths.emplace_back(bundleFile); + auto installRes = InstallBundles(filePaths, true); + EXPECT_EQ(installRes, ERR_OK); + + int32_t appIndex = 0; + auto ret = InstallSandboxApp(BUNDLE_NAME, DLP_TYPE_1, USERID, appIndex); + EXPECT_EQ(ret, ERR_OK); + EXPECT_EQ(appIndex, APP_INDEX_1); + CheckPathAreExisted(BUNDLE_NAME, APP_INDEX_1); + auto res = UninstallSandboxApp("", APP_INDEX_1, INVALID_USERID); EXPECT_EQ(res, ERR_APPEXECFWK_SANDBOX_INSTALL_PARAM_ERROR); + UninstallBundle(BUNDLE_NAME); } /** @@ -1034,8 +1100,21 @@ HWTEST_F(BmsSandboxAppTest, BmsSandboxAppUnInstallTest_0600, Function | SmallTes */ HWTEST_F(BmsSandboxAppTest, BmsSandboxAppUnInstallTest_0700, Function | SmallTest | Level1) { + std::vector filePaths; + auto bundleFile = RESOURCE_ROOT_PATH + RIGHT_BUNDLE_FIRST; + filePaths.emplace_back(bundleFile); + auto installRes = InstallBundles(filePaths, true); + EXPECT_EQ(installRes, ERR_OK); + + int32_t appIndex = 0; + auto ret = InstallSandboxApp(BUNDLE_NAME, DLP_TYPE_1, USERID, appIndex); + EXPECT_EQ(ret, ERR_OK); + EXPECT_EQ(appIndex, APP_INDEX_1); + CheckPathAreExisted(BUNDLE_NAME, APP_INDEX_1); + auto res = UninstallSandboxApp("", INVALID_APP_INDEX, INVALID_USERID); EXPECT_EQ(res, ERR_APPEXECFWK_SANDBOX_INSTALL_PARAM_ERROR); + UninstallBundle(BUNDLE_NAME); } /** @@ -1046,8 +1125,21 @@ HWTEST_F(BmsSandboxAppTest, BmsSandboxAppUnInstallTest_0700, Function | SmallTes */ HWTEST_F(BmsSandboxAppTest, BmsSandboxAppUnInstallTest_0800, Function | SmallTest | Level1) { + std::vector filePaths; + auto bundleFile = RESOURCE_ROOT_PATH + RIGHT_BUNDLE_FIRST; + filePaths.emplace_back(bundleFile); + auto installRes = InstallBundles(filePaths, true); + EXPECT_EQ(installRes, ERR_OK); + + int32_t appIndex = 0; + auto ret = InstallSandboxApp(BUNDLE_NAME, DLP_TYPE_1, USERID, appIndex); + EXPECT_EQ(ret, ERR_OK); + EXPECT_EQ(appIndex, APP_INDEX_1); + CheckPathAreExisted(BUNDLE_NAME, APP_INDEX_1); + auto res = UninstallSandboxApp(UNINSTALLED_BUNDLE_NAME, APP_INDEX_1, USERID); EXPECT_EQ(res, ERR_APPEXECFWK_SANDBOX_INSTALL_NO_SANDBOX_APP_INFO); + UninstallBundle(BUNDLE_NAME); } /** @@ -1130,7 +1222,7 @@ HWTEST_F(BmsSandboxAppTest, BmsSandboxAppUnInstallTest_1100, Function | SmallTes /** * @tc.number: BmsSandboxAppUnInstallTest_1200 - * @tc.name: test uninstall sandbox multiple times + * @tc.name: test uninstall sandbox multiple times -BUNDLE_NAME * @tc.desc: 1. uninstall sandbox multiple times * 2. the sandbox app will be uninstalled failed */ @@ -1171,7 +1263,7 @@ HWTEST_F(BmsSandboxAppTest, BmsSandboxAppUnInstallTest_1200, Function | SmallTes /** * @tc.number: BmsSandboxAppUnInstallTest_1300 - * @tc.name: test uninstall sandbox multiple times + * @tc.name: test uninstall sandbox multiple times -OTHER_BUNDLE_NAME * @tc.desc: 1. uninstall sandbox multiple times * 2. the sandbox app will be uninstalled failed */ @@ -1212,7 +1304,7 @@ HWTEST_F(BmsSandboxAppTest, BmsSandboxAppUnInstallTest_1300, Function | SmallTes /** * @tc.number: BmsSandboxAppUnInstallTest_1400 - * @tc.name: test uninstall sandbox multiple times + * @tc.name: test uninstall sandbox multiple times BUNDLE_NAME and OTHER_BUNDLE_NAME * @tc.desc: 1. uninstall sandbox multiple times * 2. the sandbox app will be uninstalled failed */ @@ -1256,7 +1348,7 @@ HWTEST_F(BmsSandboxAppTest, BmsSandboxAppUnInstallTest_1400, Function | SmallTes /** * @tc.number: BmsSandboxAppUnInstallTest_1500 - * @tc.name: test uninstall sandbox multiple times + * @tc.name: test uninstall sandbox multiple times BUNDLE_NAME and OTHER_BUNDLE_NAME * @tc.desc: 1. uninstall sandbox multiple times * 2. the sandbox app will be uninstalled failed */ @@ -1298,35 +1390,10 @@ HWTEST_F(BmsSandboxAppTest, BmsSandboxAppUnInstallTest_1500, Function | SmallTes UninstallBundle(OTHER_BUNDLE_NAME); } -/** - * @tc.number: BmsSandboxAppUnInstallTest_1600 - * @tc.name: InstallSandboxApp - * @tc.desc: 1.Test the interface of InstallSandboxApp - */ -HWTEST_F(BmsSandboxAppTest, BmsSandboxAppUnInstallTest_1600, Function | SmallTest | Level1) -{ - std::vector filePaths; - auto bundleFile = RESOURCE_ROOT_PATH + RIGHT_BUNDLE_FIRST; - filePaths.emplace_back(bundleFile); - auto installRes = InstallBundles(filePaths, true); - EXPECT_EQ(installRes, ERR_OK); - - auto installer = std::make_shared(); - int32_t appIndex = 0; - auto ret = installer->InstallSandboxApp("", DLP_TYPE_1, USERID, appIndex); - EXPECT_EQ(ret, ERR_APPEXECFWK_SANDBOX_INSTALL_PARAM_ERROR); - int32_t userId = Constants::DEFAULT_USERID - 1; - ret = installer->InstallSandboxApp(BUNDLE_NAME, DLP_TYPE_1, userId, appIndex); - EXPECT_EQ(ret, ERR_APPEXECFWK_SANDBOX_INSTALL_PARAM_ERROR); - - auto uninstallRes = UninstallBundle(BUNDLE_NAME); - EXPECT_EQ(uninstallRes, ERR_OK); -} - /** * @tc.number: BmsSandboxAppUnInstallTest_1700 - * @tc.name: InstallSandboxApp - * @tc.desc: 1.Test the interface of InstallSandboxApp + * @tc.name: GetSandboxDataMgr + * @tc.desc: 1.Test the interface of GetSandboxDataMgr */ HWTEST_F(BmsSandboxAppTest, BmsSandboxAppUnInstallTest_1700, Function | SmallTest | Level1) { @@ -1362,8 +1429,8 @@ HWTEST_F(BmsSandboxAppTest, BmsSandboxAppUnInstallTest_1700, Function | SmallTes /** * @tc.number: BmsSandboxAppUnInstallTest_1800 - * @tc.name: InstallSandboxApp - * @tc.desc: 1.Test the interface of InstallSandboxApp + * @tc.name: UninstallAllSandboxApps + * @tc.desc: 1. The main function for sandbox app uninstalling. */ HWTEST_F(BmsSandboxAppTest, BmsSandboxAppUnInstallTest_1800, Function | SmallTest | Level1) { @@ -1743,7 +1810,7 @@ HWTEST_F(BmsSandboxAppTest, BmsGETSandboxAppMSG_1300, Function | SmallTest | Lev /** * @tc.number: GetSandboxHapModuleInfo_0100 - * @tc.name: get sandbox app bundleInfo information + * @tc.name: Install Sandbox App * @tc.desc: 1. install a hap successfully * 2. the sandbox app install successfully * 3. get sandbox app bundleInfo information failed by empty bundlename @@ -1774,10 +1841,8 @@ HWTEST_F(BmsSandboxAppTest, GetSandboxHapModuleInfo_0100, Function | SmallTest | /** * @tc.number: GetSandboxHapModuleInfo_0100 - * @tc.name: get sandbox app bundleInfo information - * @tc.desc: 1. install a hap successfully - * 2. the sandbox app install successfully - * 3. get sandbox app bundleInfo information failed by empty bundlename + * @tc.name: Get Sandbox Hap Module Info + * @tc.desc: By different appIndex,Get SandboxHap ModuleInfo */ HWTEST_F(BmsSandboxAppTest, GetSandboxHapModuleInfo_0200, Function | SmallTest | Level1) { @@ -1794,9 +1859,7 @@ HWTEST_F(BmsSandboxAppTest, GetSandboxHapModuleInfo_0200, Function | SmallTest | /** * @tc.number: GetSandboxHapModuleInfo_0100 * @tc.name: get sandbox app bundleInfo information - * @tc.desc: 1. install a hap successfully - * 2. the sandbox app install successfully - * 3. get sandbox app bundleInfo information failed by empty bundlename + * @tc.desc: By different appIndex,Get SandboxHap ModuleInfo */ HWTEST_F(BmsSandboxAppTest, GetSandboxHapModuleInfo_0300, Function | SmallTest | Level1) { @@ -1810,7 +1873,7 @@ HWTEST_F(BmsSandboxAppTest, GetSandboxHapModuleInfo_0300, Function | SmallTest | /** * @tc.number: GetSandboxHapModuleInfo_0400 - * @tc.name: get sandbox app bundleInfo information + * @tc.name: Get Bundle Sandbox App Helper * @tc.desc: 1. install a hap successfully * 2. the sandbox app install successfully * 3. get sandbox app bundleInfo information failed by empty bundlename @@ -1843,7 +1906,7 @@ HWTEST_F(BmsSandboxAppTest, GetSandboxHapModuleInfo_0400, Function | SmallTest | /** * @tc.number: GetSandboxHapModuleInfo_0500 - * @tc.name: get sandbox app bundleInfo information + * @tc.name: Get Bundle Sandbox App Helper * @tc.desc: 1. install a hap successfully * 2. the sandbox app install successfully * 3. get sandbox app bundleInfo information failed by empty bundlename @@ -1904,9 +1967,7 @@ HWTEST_F(BmsSandboxAppTest, GetInnerBundleInfoByUid_0100, Function | SmallTest | /** * @tc.number: GetInnerBundleInfoByUid_0200 * @tc.name: get sandbox app bundleInfo information - * @tc.desc: 1. install a hap successfully - * 2. the sandbox app install successfully - * 3. get sandbox app bundleInfo information failed by empty bundlename + * @tc.desc: Obtain internal package information by Uid */ HWTEST_F(BmsSandboxAppTest, GetInnerBundleInfoByUid_0200, Function | SmallTest | Level1) { @@ -2083,7 +2144,7 @@ HWTEST_F(BmsSandboxAppTest, GetSandboxAppInfo_0100, Function | SmallTest | Level } /** - * @tc.number: DeleteSandboxAppIndex_001 + * @tc.number: GetSandboxAppInfo_0200 * @tc.name: ConvertResourcePath * @tc.desc: 1.Test the interface of ConvertResourcePath */ @@ -2177,8 +2238,8 @@ HWTEST_F(BmsSandboxAppTest, GetBundleArchiveInfoBySandBoxPath_0200, Function | S /** * @tc.number: GetBundleInfoForSelf_0100 * @tc.name: get sandbox app bundleInfo information - * @tc.desc: 1. save sandbox info successfully - * 2. get sandbox app bundleInfo information failed + * @tc.desc: 1. Obtain internal package information by Uid + * 2. Obtains the BundleInfo based on a given bundle name. * @tc.require: issueI5Y75O */ HWTEST_F(BmsSandboxAppTest, GetBundleInfoForSelf_0100, Function | SmallTest | Level1) 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 34cb5c28f9d9860b033566da3f34fbb946768400..818757879546a6152607f50fd1feb061144ee4cc 100644 --- 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 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2021-2024 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 @@ -325,8 +325,17 @@ ErrCode BmsBundleUninstallerTest::InstallMultipleBundles(const std::vector filePaths; + filePaths.emplace_back(RESOURCE_TEST_PATH); + ErrCode installRes = InstallMultipleBundles(filePaths, true); + EXPECT_EQ(installRes, ERR_OK); + CheckFileExist(); + ErrCode result = UninstallBundle("", USERID); EXPECT_EQ(result, ERR_APPEXECFWK_UNINSTALL_INVALID_NAME); + ErrCode result1 = UninstallBundle(BUNDLE_NAME, INVALID_USERID); + EXPECT_NE(result1, ERR_OK); + ClearBundleInfo(BUNDLE_NAME); } /** @@ -337,8 +346,18 @@ HWTEST_F(BmsBundleUninstallerTest, Bundle_Uninstall_0100, Function | SmallTest | */ HWTEST_F(BmsBundleUninstallerTest, Bundle_Uninstall_0200, Function | SmallTest | Level0) { + std::vector filePaths; + filePaths.emplace_back(RESOURCE_TEST_PATH); + ErrCode installRes = InstallMultipleBundles(filePaths, true); + EXPECT_EQ(installRes, ERR_OK); + CheckFileExist(); + ErrCode result = UninstallBundle(ERROR_BUNDLE_NAME, USERID); EXPECT_EQ(result, ERR_APPEXECFWK_UNINSTALL_MISSING_INSTALLED_BUNDLE); + + ErrCode result1 = UninstallBundle(BUNDLE_NAME, INVALID_USERID); + EXPECT_NE(result1, ERR_OK); + ClearBundleInfo(BUNDLE_NAME); } /** @@ -387,8 +406,17 @@ HWTEST_F(BmsBundleUninstallerTest, Bundle_Uninstall_0400, Function | SmallTest | */ HWTEST_F(BmsBundleUninstallerTest, Module_Uninstall_0100, Function | SmallTest | Level0) { + std::vector filePaths; + filePaths.emplace_back(RESOURCE_TEST_PATH); + ErrCode installRes = InstallMultipleBundles(filePaths, true); + EXPECT_EQ(installRes, ERR_OK); + CheckFileExist(); ErrCode result = UninstallModule("", MODULE_PACKAGE1, USERID); EXPECT_EQ(result, ERR_APPEXECFWK_UNINSTALL_INVALID_NAME); + + installRes = UninstallModule(BUNDLE_NAME, MODULE_PACKAGE1, USERID); + EXPECT_EQ(installRes, ERR_OK); + ClearBundleInfo(BUNDLE_NAME); } /** @@ -399,8 +427,17 @@ HWTEST_F(BmsBundleUninstallerTest, Module_Uninstall_0100, Function | SmallTest | */ HWTEST_F(BmsBundleUninstallerTest, Module_Uninstall_0200, Function | SmallTest | Level0) { + std::vector filePaths; + filePaths.emplace_back(RESOURCE_TEST_PATH); + ErrCode installRes = InstallMultipleBundles(filePaths, true); + EXPECT_EQ(installRes, ERR_OK); + CheckFileExist(); ErrCode result = UninstallModule(ERROR_BUNDLE_NAME, MODULE_PACKAGE1, USERID); EXPECT_EQ(result, ERR_APPEXECFWK_UNINSTALL_MISSING_INSTALLED_BUNDLE); + + installRes = UninstallModule(BUNDLE_NAME, MODULE_PACKAGE1, USERID); + EXPECT_EQ(installRes, ERR_OK); + ClearBundleInfo(BUNDLE_NAME); } /** @@ -411,8 +448,17 @@ HWTEST_F(BmsBundleUninstallerTest, Module_Uninstall_0200, Function | SmallTest | */ HWTEST_F(BmsBundleUninstallerTest, Module_Uninstall_0300, Function | SmallTest | Level0) { + std::vector filePaths; + filePaths.emplace_back(RESOURCE_TEST_PATH); + ErrCode installRes = InstallMultipleBundles(filePaths, true); + EXPECT_EQ(installRes, ERR_OK); + CheckFileExist(); ErrCode result = UninstallModule(BUNDLE_NAME, "", USERID); EXPECT_EQ(result, ERR_APPEXECFWK_UNINSTALL_INVALID_NAME); + + installRes = UninstallModule(BUNDLE_NAME, MODULE_PACKAGE1, USERID); + EXPECT_EQ(installRes, ERR_OK); + ClearBundleInfo(BUNDLE_NAME); } /** @@ -423,8 +469,17 @@ HWTEST_F(BmsBundleUninstallerTest, Module_Uninstall_0300, Function | SmallTest | */ HWTEST_F(BmsBundleUninstallerTest, Module_Uninstall_0400, Function | SmallTest | Level0) { + std::vector filePaths; + filePaths.emplace_back(RESOURCE_TEST_PATH); + ErrCode installRes = InstallMultipleBundles(filePaths, true); + EXPECT_EQ(installRes, ERR_OK); + CheckFileExist(); ErrCode result = UninstallModule(BUNDLE_NAME, ERROR_MODULE_PACKAGE_NAME, USERID); - EXPECT_EQ(result, ERR_APPEXECFWK_UNINSTALL_MISSING_INSTALLED_BUNDLE); + EXPECT_EQ(result, ERR_APPEXECFWK_UNINSTALL_MISSING_INSTALLED_MODULE); + + installRes = UninstallModule(BUNDLE_NAME, MODULE_PACKAGE1, USERID); + EXPECT_EQ(installRes, ERR_OK); + ClearBundleInfo(BUNDLE_NAME); } /** @@ -435,8 +490,17 @@ HWTEST_F(BmsBundleUninstallerTest, Module_Uninstall_0400, Function | SmallTest | */ HWTEST_F(BmsBundleUninstallerTest, Module_Uninstall_0500, Function | SmallTest | Level0) { + std::vector filePaths; + filePaths.emplace_back(RESOURCE_TEST_PATH); + ErrCode installRes = InstallMultipleBundles(filePaths, true); + EXPECT_EQ(installRes, ERR_OK); + CheckFileExist(); ErrCode result = UninstallModule(BUNDLE_NAME, MODULE_PACKAGE1, INVALID_USERID); EXPECT_NE(result, ERR_OK); + + installRes = UninstallModule(BUNDLE_NAME, MODULE_PACKAGE1, USERID); + EXPECT_EQ(installRes, ERR_OK); + ClearBundleInfo(BUNDLE_NAME); } /**