diff --git a/services/bundlemgr/test/unittest/bms_data_mgr_test/bms_extension_data_mgr_test.cpp b/services/bundlemgr/test/unittest/bms_data_mgr_test/bms_extension_data_mgr_test.cpp index f3e943df6..398d81d5b 100644 --- a/services/bundlemgr/test/unittest/bms_data_mgr_test/bms_extension_data_mgr_test.cpp +++ b/services/bundlemgr/test/unittest/bms_data_mgr_test/bms_extension_data_mgr_test.cpp @@ -95,6 +95,11 @@ private: static std::shared_ptr bundleMgrService_; }; +class BundleMgrExtTest : public BundleMgrExt { +public: + bool CheckApiInfo(const BundleInfo& bundleInfo); +}; + std::shared_ptr BmsExtensionDataMgrTest::bundleMgrService_ = DelayedSingleton::GetInstance(); @@ -125,6 +130,11 @@ const std::shared_ptr BmsExtensionDataMgrTest::GetDataMgr() const return dataMgr_; } +bool BundleMgrExtTest::CheckApiInfo(const BundleInfo& bundleInfo) +{ + return true; +} + /** * @tc.number: BmsExtensionDataMgr_0001 * @tc.name: CheckApiInfo @@ -169,6 +179,82 @@ HWTEST_F(BmsExtensionDataMgrTest, BmsExtensionDataMgr_0003, Function | SmallTest EXPECT_EQ(res, true); } +/** + * @tc.number: BmsExtensionDataMgr_0004 + * @tc.name: QueryAbilityInfosWithFlag + * @tc.desc: QueryAbilityInfosWithFlag + */ +HWTEST_F(BmsExtensionDataMgrTest, BmsExtensionDataMgr_0004, Function | SmallTest | Level0) +{ + BmsExtensionDataMgr bmsExtensionDataMgr; + Want want; + int32_t userId = 0; + std::vector abilityInfos; + ErrCode res = bmsExtensionDataMgr.QueryAbilityInfos(want, userId, abilityInfos); + EXPECT_EQ(res, ERR_BUNDLE_MANAGER_INSTALL_FAILED_BUNDLE_EXTENSION_NOT_EXISTED); +} + +/** + * @tc.number: BmsExtensionDataMgr_0005 + * @tc.name: QueryAbilityInfosWithFlag + * @tc.desc: QueryAbilityInfosWithFlag + */ +HWTEST_F(BmsExtensionDataMgrTest, BmsExtensionDataMgr_0005, Function | SmallTest | Level0) +{ + BmsExtensionDataMgr bmsExtensionDataMgr; + Want want; + int32_t flags = 0; + int32_t userId = 0; + std::vector abilityInfos; + ErrCode res = bmsExtensionDataMgr.QueryAbilityInfosWithFlag(want, flags, userId, abilityInfos); + EXPECT_EQ(res, ERR_BUNDLE_MANAGER_INSTALL_FAILED_BUNDLE_EXTENSION_NOT_EXISTED); +} + +/** + * @tc.number: BmsExtensionDataMgr_0006 + * @tc.name: GetBundleInfos + * @tc.desc: GetBundleInfos + */ +HWTEST_F(BmsExtensionDataMgrTest, BmsExtensionDataMgr_0006, Function | SmallTest | Level0) +{ + BmsExtensionDataMgr bmsExtensionDataMgr; + int32_t flags = 0; + int32_t userId = 0; + std::vector bundleInfos; + ErrCode res = bmsExtensionDataMgr.GetBundleInfos(flags, bundleInfos, userId); + EXPECT_EQ(res, ERR_BUNDLE_MANAGER_INSTALL_FAILED_BUNDLE_EXTENSION_NOT_EXISTED); +} + +/** + * @tc.number: BmsExtensionDataMgr_0007 + * @tc.name: GetBundleInfo + * @tc.desc: GetBundleInfo + */ +HWTEST_F(BmsExtensionDataMgrTest, BmsExtensionDataMgr_0007, Function | SmallTest | Level0) +{ + BmsExtensionDataMgr bmsExtensionDataMgr; + std::string bundleName; + int32_t flags = 0; + int32_t userId = 0; + BundleInfo bundleInfo; + ErrCode res = bmsExtensionDataMgr.GetBundleInfo(bundleName, flags, userId, bundleInfo); + EXPECT_EQ(res, ERR_BUNDLE_MANAGER_INSTALL_FAILED_BUNDLE_EXTENSION_NOT_EXISTED); +} + +/** + * @tc.number: BmsExtensionDataMgr_0008 + * @tc.name: HapVerify + * @tc.desc: HapVerify + */ +HWTEST_F(BmsExtensionDataMgrTest, BmsExtensionDataMgr_0008, Function | SmallTest | Level0) +{ + BmsExtensionDataMgr bmsExtensionDataMgr; + std::string filePath; + Security::Verify::HapVerifyResult hapVerifyResult; + ErrCode res = bmsExtensionDataMgr.HapVerify(filePath, hapVerifyResult); + EXPECT_EQ(res, ERR_BUNDLEMANAGER_INSTALL_FAILED_SIGNATURE_EXTENSION_NOT_EXISTED); +} + /** * @tc.number: BmsExtensionProfile_0001 * @tc.name: TransformTo @@ -261,4 +347,80 @@ HWTEST_F(BmsExtensionDataMgrTest, BundleMgrExtRegister_0001, Function | SmallTes auto res = BundleMgrExtRegister::GetInstance().GetBundleMgrExt(BUNDLE_EXT_NAME); EXPECT_EQ(res, nullptr); } + +/** + * @tc.number: BundleMgrExt_0001 + * @tc.name: HapVerify + * @tc.desc: HapVerify + */ +HWTEST_F(BmsExtensionDataMgrTest, BundleMgrExt_0001, Function | SmallTest | Level0) +{ + BundleMgrExtTest bundleMgrExtTest; + std::string filePath; + Security::Verify::HapVerifyResult hapVerifyResult; + ErrCode res = bundleMgrExtTest.HapVerify(filePath, hapVerifyResult); + EXPECT_EQ(res, ERR_BUNDLEMANAGER_INSTALL_FAILED_SIGNATURE_EXTENSION_NOT_EXISTED); +} + +/** + * @tc.number: BundleMgrExt_0002 + * @tc.name: QueryAbilityInfos + * @tc.desc: QueryAbilityInfos + */ +HWTEST_F(BmsExtensionDataMgrTest, BundleMgrExt_0002, Function | SmallTest | Level0) +{ + BundleMgrExtTest bundleMgrExtTest; + Want want; + int32_t userId = 0; + std::vector abilityInfos; + ErrCode res = bundleMgrExtTest.QueryAbilityInfos(want, userId, abilityInfos); + EXPECT_EQ(res, ERR_BUNDLE_MANAGER_INSTALL_FAILED_BUNDLE_EXTENSION_NOT_EXISTED); +} + +/** + * @tc.number: BundleMgrExt_0003 + * @tc.name: QueryAbilityInfosWithFlag + * @tc.desc: QueryAbilityInfosWithFlag + */ +HWTEST_F(BmsExtensionDataMgrTest, BundleMgrExt_0003, Function | SmallTest | Level0) +{ + BundleMgrExtTest bundleMgrExtTest; + Want want; + int32_t flags = 0; + int32_t userId = 0; + std::vector abilityInfos; + ErrCode res = bundleMgrExtTest.QueryAbilityInfosWithFlag(want, flags, userId, abilityInfos); + EXPECT_EQ(res, ERR_BUNDLE_MANAGER_INSTALL_FAILED_BUNDLE_EXTENSION_NOT_EXISTED); +} + +/** + * @tc.number: BundleMgrExt_0004 + * @tc.name: GetBundleInfo + * @tc.desc: GetBundleInfo + */ +HWTEST_F(BmsExtensionDataMgrTest, BundleMgrExt_0004, Function | SmallTest | Level0) +{ + BundleMgrExtTest bundleMgrExtTest; + std::string bundleName; + int32_t flags = 0; + int32_t userId = 0; + BundleInfo bundleInfo; + ErrCode res = bundleMgrExtTest.GetBundleInfo(bundleName, flags, userId, bundleInfo); + EXPECT_EQ(res, ERR_BUNDLE_MANAGER_INSTALL_FAILED_BUNDLE_EXTENSION_NOT_EXISTED); +} + +/** + * @tc.number: BundleMgrExt_0005 + * @tc.name: GetBundleInfos + * @tc.desc: GetBundleInfos + */ +HWTEST_F(BmsExtensionDataMgrTest, BundleMgrExt_0005, Function | SmallTest | Level0) +{ + BundleMgrExtTest bundleMgrExtTest; + int32_t flags = 0; + int32_t userId = 0; + std::vector bundleInfos; + ErrCode res = bundleMgrExtTest.GetBundleInfos(flags, bundleInfos, userId); + EXPECT_EQ(res, ERR_BUNDLE_MANAGER_INSTALL_FAILED_BUNDLE_EXTENSION_NOT_EXISTED); +} } // OHOS \ No newline at end of file diff --git a/test/systemtest/common/bms/acts_bms_kit_system_test/acts_bms_kit_system_test.cpp b/test/systemtest/common/bms/acts_bms_kit_system_test/acts_bms_kit_system_test.cpp index c8d08a1ba..f3148f549 100644 --- a/test/systemtest/common/bms/acts_bms_kit_system_test/acts_bms_kit_system_test.cpp +++ b/test/systemtest/common/bms/acts_bms_kit_system_test/acts_bms_kit_system_test.cpp @@ -8129,5 +8129,20 @@ HWTEST_F(ActsBmsKitSystemTest, GetOverlayManagerProxy_0100, Function | SmallTest std::string uninstallResult = commonTool.VectorToStr(resvec); EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!"; } + +/** + * @tc.number: QueryAppGalleryBundleName_0100 + * @tc.name: test BundleMgr proxy + * @tc.desc: 1.system run normally + * 2.return true + */ +HWTEST_F(ActsBmsKitSystemTest, QueryAppGalleryBundleName_0100, Function | SmallTest | Level1) +{ + sptr bundleMgrProxy = GetBundleMgrProxy(); + ASSERT_NE(bundleMgrProxy, nullptr); + std::string bundleName; + bool ret = bundleMgrProxy->QueryAppGalleryBundleName(bundleName); + EXPECT_FALSE(ret); +} } // namespace AppExecFwk } // namespace OHOS \ No newline at end of file