diff --git a/services/bundlemgr/test/unittest/bms_bundle_installer_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_bundle_installer_test/BUILD.gn index 9d251c58fa1efbc5154ff1da000f2cb4871af8a5..3d6c5a0c41b2a8643d0895ff2444d5c0ae554f37 100755 --- a/services/bundlemgr/test/unittest/bms_bundle_installer_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_bundle_installer_test/BUILD.gn @@ -488,6 +488,7 @@ ohos_unittest("BmsMultipleBundleInstallerTest") { "${bundle_framework_path}/test/sceneProject/unittest/test_bundle/first_right:first_right", "${bundle_framework_path}/test/sceneProject/unittest/test_bundle/first_right_compCode:first_right_compCode", "${bundle_framework_path}/test/sceneProject/unittest/test_bundle/first_right_with_diff_moduleType:first_right_with_diff_moduleType", + "${bundle_framework_path}/test/sceneProject/unittest/test_bundle/first_right_with_diff_moduleName:first_right_with_diff_moduleName", "${bundle_framework_path}/test/sceneProject/unittest/test_bundle/fourteenth_right:fourteenth_right", "${bundle_framework_path}/test/sceneProject/unittest/test_bundle/fourth_right:fourth_right", "${bundle_framework_path}/test/sceneProject/unittest/test_bundle/ninth_right:ninth_right", @@ -496,6 +497,7 @@ ohos_unittest("BmsMultipleBundleInstallerTest") { "${bundle_framework_path}/test/sceneProject/unittest/test_bundle/second_backup_right:second_backup_right", "${bundle_framework_path}/test/sceneProject/unittest/test_bundle/second_right:second_right", "${bundle_framework_path}/test/sceneProject/unittest/test_bundle/seventh_right:seventh_right", + "${bundle_framework_path}/test/sceneProject/unittest/test_bundle/second_right_with_same_moduleName:second_right_with_same_moduleName", "${bundle_framework_path}/test/sceneProject/unittest/test_bundle/sixteenth_right:sixteenth_right", "${bundle_framework_path}/test/sceneProject/unittest/test_bundle/sixth_right:sixth_right", "${bundle_framework_path}/test/sceneProject/unittest/test_bundle/tenth_right:tenth_right", diff --git a/services/bundlemgr/test/unittest/bms_bundle_installer_test/bms_multiple_installer_test.cpp b/services/bundlemgr/test/unittest/bms_bundle_installer_test/bms_multiple_installer_test.cpp index f10370c4f4cf8d8908205d11d5a19b5be446cede..c3a72e4e6d90a5ec839ae7c0f8e3238d602c3895 100644 --- a/services/bundlemgr/test/unittest/bms_bundle_installer_test/bms_multiple_installer_test.cpp +++ b/services/bundlemgr/test/unittest/bms_bundle_installer_test/bms_multiple_installer_test.cpp @@ -79,7 +79,9 @@ const std::string WRONG_BUNDLE_NAME = "wrong_bundle_name.ha"; const std::string RIGHT_DIFFERENT_RELEASE_TYPE = "first_diff_release_type.hap"; const std::string RIGHT_COMPATIBLE_VERSION_CODE = "first_right_compCode.hap"; const std::string RIGHT_DIFFERENT_COMPATIBLE_VERSION_CODE = "first_diff_minCompCode.hap"; +const std::string RIGHT_DIFFERENT_MODULE_NAME = "first_right_with_diff_moduleName.hap"; const std::string RIGHT_DIFFERENT_MODULE_TYPE = "first_right_with_diff_moduleType.hap"; +const std::string SECOND_SAME_WITH_MODULE_NAME = "second_right_with_same_moduleName.hap"; const std::string TEST_HAP_DEMO = "testhapdemo.hap"; const std::string TEST_HAP_DEMO_2 = "testhapdemo2.hap"; const std::string TEST_HAP_DEMO_3 = "testhapdemo3.hap"; @@ -1105,6 +1107,32 @@ HWTEST_F(BmsMultipleInstallerTest, MultipleHapsInstall_5200, Function | SmallTes ClearBundleInfo(BUNDLE_NAME); } +/** + * @tc.number: MultipleHapsInstall_5300 + * @tc.name: test to install haps with same moduelName + * @tc.desc: 1.the moduleName is different in the same packageName hap + * 2.the installation result is fail + */ +HWTEST_F(BmsMultipleInstallerTest, MultipleHapsInstall_5300, Function | SmallTest | Level1) +{ + std::vector filePaths; + std::string firstBundleFile = RESOURCE_ROOT_PATH + RIGHT_BUNDLE_FIRST; + filePaths.emplace_back(firstBundleFile); + ErrCode installRes = InstallThirdPartyMultipleBundles(filePaths, true); + EXPECT_EQ(installRes, ERR_OK); + CheckFileExist(); + CheckModuleFileExist(); + + std::string secondBundleFile = RESOURCE_ROOT_PATH + RIGHT_DIFFERENT_MODULE_NAME; + filePaths.clear(); + filePaths.emplace_back(secondBundleFile); + installRes = InstallThirdPartyMultipleBundles(filePaths, true); + EXPECT_EQ(installRes, ERR_APPEXECFWK_INSTALL_INCONSISTENT_MODULE_NAME); + + ClearBundleInfo(BUNDLE_NAME); +} + + /** * @tc.number: MultipleHapsInstall_5400 * @tc.name: test to install haps with same moduelName @@ -1130,6 +1158,31 @@ HWTEST_F(BmsMultipleInstallerTest, MultipleHapsInstall_5400, Function | SmallTes ClearBundleInfo(BUNDLE_NAME); } +/** + * @tc.number: MultipleHapsInstall_5500 + * @tc.name: test to install haps with same moduelName + * @tc.desc: 1.the moduleName is same in the different packageName hap + * 2.the installation result is fail + */ +HWTEST_F(BmsMultipleInstallerTest, MultipleHapsInstall_5500, Function | SmallTest | Level1) +{ + std::vector filePaths; + std::string firstBundleFile = RESOURCE_ROOT_PATH + RIGHT_BUNDLE_FIRST; + filePaths.emplace_back(firstBundleFile); + ErrCode installRes = InstallThirdPartyMultipleBundles(filePaths, true); + EXPECT_EQ(installRes, ERR_OK); + CheckFileExist(); + CheckModuleFileExist(); + + std::string secondBundleFile = RESOURCE_ROOT_PATH + SECOND_SAME_WITH_MODULE_NAME; + filePaths.clear(); + filePaths.emplace_back(secondBundleFile); + installRes = InstallThirdPartyMultipleBundles(filePaths, true); + EXPECT_EQ(installRes, ERR_APPEXECFWK_INSTALL_NOT_UNIQUE_DISTRO_MODULE_NAME); + + ClearBundleInfo(BUNDLE_NAME); +} + /** * @tc.number: MultipleHapsUpdateData_0100 * @tc.name: test to update hap. diff --git a/test/sceneProject/unittest/ohos_test/ohos_test.xml b/test/sceneProject/unittest/ohos_test/ohos_test.xml index e164719e16c2c735576b2cd2835d7f63fcd04e0e..4f7f49e88393e84b98766eaf89ed9fa357602f05 100644 --- a/test/sceneProject/unittest/ohos_test/ohos_test.xml +++ b/test/sceneProject/unittest/ohos_test/ohos_test.xml @@ -232,6 +232,10 @@