!4428 新增TDD用例【接口覆盖率】

Merge pull request !4428 from 耿文广/master
This commit is contained in:
openharmony_ci 2023-07-24 12:22:08 +00:00 committed by Gitee
commit d2fd796fb8
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 177 additions and 0 deletions

View File

@ -95,6 +95,11 @@ private:
static std::shared_ptr<BundleMgrService> bundleMgrService_;
};
class BundleMgrExtTest : public BundleMgrExt {
public:
bool CheckApiInfo(const BundleInfo& bundleInfo);
};
std::shared_ptr<BundleMgrService> BmsExtensionDataMgrTest::bundleMgrService_ =
DelayedSingleton<BundleMgrService>::GetInstance();
@ -125,6 +130,11 @@ const std::shared_ptr<BundleDataMgr> 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<AbilityInfo> 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<AbilityInfo> 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<BundleInfo> 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<AbilityInfo> 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<AbilityInfo> 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<BundleInfo> bundleInfos;
ErrCode res = bundleMgrExtTest.GetBundleInfos(flags, bundleInfos, userId);
EXPECT_EQ(res, ERR_BUNDLE_MANAGER_INSTALL_FAILED_BUNDLE_EXTENSION_NOT_EXISTED);
}
} // OHOS

View File

@ -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> bundleMgrProxy = GetBundleMgrProxy();
ASSERT_NE(bundleMgrProxy, nullptr);
std::string bundleName;
bool ret = bundleMgrProxy->QueryAppGalleryBundleName(bundleName);
EXPECT_FALSE(ret);
}
} // namespace AppExecFwk
} // namespace OHOS