From be0b24ccb6c31a1a97e1a7b2b12b884a1628684c Mon Sep 17 00:00:00 2001 From: lanhaoyu Date: Wed, 22 Jan 2025 09:48:12 +0800 Subject: [PATCH] Add TDD Signed-off-by: lanhaoyu --- .../unittest/bundle_mgr_proxy_test/BUILD.gn | 5 +- .../bundle_mgr_proxy_test.cpp | 187 ++++++++++++++++++ .../bundle_mgr_client_system_test.cpp | 18 ++ 3 files changed, 209 insertions(+), 1 deletion(-) diff --git a/interfaces/inner_api/test/unittest/bundle_mgr_proxy_test/BUILD.gn b/interfaces/inner_api/test/unittest/bundle_mgr_proxy_test/BUILD.gn index d4a39ced32..b13dc13b8c 100644 --- a/interfaces/inner_api/test/unittest/bundle_mgr_proxy_test/BUILD.gn +++ b/interfaces/inner_api/test/unittest/bundle_mgr_proxy_test/BUILD.gn @@ -20,7 +20,10 @@ module_output_path = "bundle_framework/appexecfwk" ohos_unittest("BundleMgrProxyTest") { module_out_path = module_output_path use_exceptions = true - include_dirs = [ "${core_path}/include/bundlemgr" ] + include_dirs = [ + "${core_path}/include/bundlemgr", + "${base_path}/include", + ] sources = [ "bundle_mgr_proxy_test.cpp" ] deps = [ diff --git a/interfaces/inner_api/test/unittest/bundle_mgr_proxy_test/bundle_mgr_proxy_test.cpp b/interfaces/inner_api/test/unittest/bundle_mgr_proxy_test/bundle_mgr_proxy_test.cpp index 8e3b25a7dd..34568372da 100644 --- a/interfaces/inner_api/test/unittest/bundle_mgr_proxy_test/bundle_mgr_proxy_test.cpp +++ b/interfaces/inner_api/test/unittest/bundle_mgr_proxy_test/bundle_mgr_proxy_test.cpp @@ -15,6 +15,7 @@ #include +#include "bundle_info.h" #include "bundle_mgr_proxy.h" #include @@ -526,5 +527,191 @@ HWTEST_F(BundleMgrProxyTest, Bundle_Mgr_Proxy_Test_3000, Function | SmallTest | auto ret = bundleMgrProxy.GetBundleNameByAppId(appId, bundleName); EXPECT_EQ(ret, ERR_APPEXECFWK_INSTALL_PARAM_ERROR); } + +/** + * @tc.number: CopyAp_0100 + * @tc.name: test the CopyAp + * @tc.desc: 1. CopyAp + */ +HWTEST_F(BundleMgrProxyTest, CopyAp_0100, Function | SmallTest | Level0) +{ + sptr impl = nullptr; + BundleMgrProxy bundleMgrProxy(impl); + std::string bundleName = "com.ohos.systemui"; + bool isAllBundle = false; + std::vector results; + auto ret = bundleMgrProxy.CopyAp(bundleName, isAllBundle, results); + EXPECT_EQ(ret, ERR_APPEXECFWK_PARCEL_ERROR); +} + +/** + * @tc.number: GetAllFormsInfo_0100 + * @tc.name: test the GetAllFormsInfo + * @tc.desc: 1. GetAllFormsInfo + */ +HWTEST_F(BundleMgrProxyTest, GetAllFormsInfo_0100, Function | SmallTest | Level0) +{ + sptr impl = nullptr; + BundleMgrProxy bundleMgrProxy(impl); + std::vector formInfos; + FormInfo forminfo; + formInfos.push_back(forminfo); + auto ret = bundleMgrProxy.GetAllFormsInfo(formInfos); + EXPECT_EQ(ret, false); +} + +/** + * @tc.number: GetSharedBundleInfoBySelf_0100 + * @tc.name: test the GetSharedBundleInfoBySelf + * @tc.desc: 1. GetSharedBundleInfoBySelf + */ +HWTEST_F(BundleMgrProxyTest, GetSharedBundleInfoBySelf_0100, Function | SmallTest | Level0) +{ + sptr impl = nullptr; + BundleMgrProxy bundleMgrProxy(impl); + std::string bundleName = "com.ohos.systemui"; + SharedBundleInfo sharedBundleInfo; + sharedBundleInfo.name = "sharedBundleInfo"; + SharedModuleInfo sharedModuleInfo; + sharedBundleInfo.sharedModuleInfos.push_back(sharedModuleInfo); + auto ret = bundleMgrProxy.GetSharedBundleInfoBySelf(bundleName, sharedBundleInfo); + EXPECT_EQ(ret, ERR_APPEXECFWK_PARCEL_ERROR); +} + +/** + * @tc.number: GetSharedDependencies_0100 + * @tc.name: test the GetSharedDependencies + * @tc.desc: 1. GetSharedDependencies + */ +HWTEST_F(BundleMgrProxyTest, GetSharedDependencies_0100, Function | SmallTest | Level0) +{ + sptr impl = nullptr; + BundleMgrProxy bundleMgrProxy(impl); + std::string bundleName = "com.ohos.photos"; + std::string moudleName = "module"; + std::vector dependencies; + Dependency dependency; + dependency.bundleName = "com.ohos.systemui"; + dependency.moduleName = "moudle1"; + dependencies.push_back(dependency); + auto ret = bundleMgrProxy.GetSharedDependencies(bundleName, moudleName, dependencies); + EXPECT_EQ(ret, ERR_APPEXECFWK_PARCEL_ERROR); +} + +/** + * @tc.number: SetAdditionalInfo_0100 + * @tc.name: test the SetAdditionalInfo + * @tc.desc: 1. SetAdditionalInfo + */ +HWTEST_F(BundleMgrProxyTest, SetAdditionalInfo_0100, Function | SmallTest | Level0) +{ + sptr impl = nullptr; + BundleMgrProxy bundleMgrProxy(impl); + std::string bundleName = "com.ohos.photos"; + std::string additionalInfo = "additionalInfo"; + auto ret = bundleMgrProxy.SetAdditionalInfo(bundleName, additionalInfo); + EXPECT_EQ(ret, ERR_APPEXECFWK_PARCEL_ERROR); +} + +/** + * @tc.number: CreateBundleDataDirWithEl_0100 + * @tc.name: test the CreateBundleDataDirWithEl + * @tc.desc: 1. CreateBundleDataDirWithEl + */ +HWTEST_F(BundleMgrProxyTest, CreateBundleDataDirWithEl_0100, Function | SmallTest | Level0) +{ + sptr impl = nullptr; + BundleMgrProxy bundleMgrProxy(impl); + int32_t userId = 100; + DataDirEl dirEl = DataDirEl::EL1; + auto ret = bundleMgrProxy.CreateBundleDataDirWithEl(userId, dirEl); + EXPECT_EQ(ret, ERR_APPEXECFWK_PARCEL_ERROR); +} + +/** + * @tc.number: GetLaunchWant_0100 + * @tc.name: test the GetLaunchWant + * @tc.desc: 1. GetLaunchWant + */ +HWTEST_F(BundleMgrProxyTest, GetLaunchWant_0100, Function | SmallTest | Level0) +{ + sptr impl = nullptr; + BundleMgrProxy bundleMgrProxy(impl); + OHOS::AAFwk::Want want; + auto ret = bundleMgrProxy.GetLaunchWant(want); + EXPECT_EQ(ret, ERR_APPEXECFWK_PARCEL_ERROR); +} + +/** + * @tc.number: AddDesktopShortcutInfo_0100 + * @tc.name: test the AddDesktopShortcutInfo + * @tc.desc: 1. AddDesktopShortcutInfo + */ +HWTEST_F(BundleMgrProxyTest, AddDesktopShortcutInfo_0100, Function | SmallTest | Level0) +{ + sptr impl = nullptr; + BundleMgrProxy bundleMgrProxy(impl); + ShortcutInfo shortcutInfo; + shortcutInfo.bundleName = "com.ohos.photos"; + shortcutInfo.moduleName = "moudle"; + shortcutInfo.icon = "icon"; + shortcutInfo.label = "shortCut"; + int32_t userId = 100; + auto ret = bundleMgrProxy.AddDesktopShortcutInfo(shortcutInfo, userId); + EXPECT_EQ(ret, ERR_BUNDLE_MANAGER_IPC_TRANSACTION); +} + +/** + * @tc.number: DeleteDesktopShortcutInfo_0100 + * @tc.name: test the DeleteDesktopShortcutInfo + * @tc.desc: 1. DeleteDesktopShortcutInfo + */ +HWTEST_F(BundleMgrProxyTest, DeleteDesktopShortcutInfo_0100, Function | SmallTest | Level0) +{ + sptr impl = nullptr; + BundleMgrProxy bundleMgrProxy(impl); + ShortcutInfo shortcutInfo; + shortcutInfo.bundleName = "com.ohos.photos"; + shortcutInfo.moduleName = "moudle"; + shortcutInfo.icon = "icon"; + shortcutInfo.label = "shortCut"; + int32_t userId = 100; + auto ret = bundleMgrProxy.DeleteDesktopShortcutInfo(shortcutInfo, userId); + EXPECT_EQ(ret, ERR_BUNDLE_MANAGER_IPC_TRANSACTION); +} + +/** + * @tc.number: GetAllDesktopShortcutInfo_0100 + * @tc.name: test the GetAllDesktopShortcutInfo + * @tc.desc: 1. GetAllDesktopShortcutInfo + */ +HWTEST_F(BundleMgrProxyTest, GetAllDesktopShortcutInfo_0100, Function | SmallTest | Level0) +{ + sptr impl = nullptr; + BundleMgrProxy bundleMgrProxy(impl); + std::vector shortcutInfos; + ShortcutInfo shortcutInfo; + shortcutInfo.bundleName = "com.ohos.photos"; + shortcutInfo.moduleName = "moudle"; + shortcutInfo.icon = "icon"; + shortcutInfo.label = "shortCut"; + shortcutInfos.push_back(shortcutInfo); + int32_t userId = 100; + auto ret = bundleMgrProxy.GetAllDesktopShortcutInfo(userId, shortcutInfos); + EXPECT_EQ(ret, ERR_APPEXECFWK_PARCEL_ERROR); +} + +/** + * @tc.number: SimpleAppInfoUnmarshalling_0100 + * @tc.name: test the SimpleAppInfoUnmarshalling + * @tc.desc: 1. SimpleAppInfoUnmarshalling + */ +HWTEST_F(BundleMgrProxyTest, SimpleAppInfoUnmarshalling_0100, Function | SmallTest | Level0) +{ + SimpleAppInfo info; + Parcel parcel; + auto ret = info.Unmarshalling(parcel); + EXPECT_NE(ret, nullptr); +} } // AppExecFwk } // OHOS diff --git a/test/systemtest/common/bms/bms_client_system_test/bundle_mgr_client_system_test.cpp b/test/systemtest/common/bms/bms_client_system_test/bundle_mgr_client_system_test.cpp index 06a8b085a4..8b33585706 100644 --- a/test/systemtest/common/bms/bms_client_system_test/bundle_mgr_client_system_test.cpp +++ b/test/systemtest/common/bms/bms_client_system_test/bundle_mgr_client_system_test.cpp @@ -2523,5 +2523,23 @@ HWTEST_F(BundleMgrClientSystemTest, GetAllBundleDirs_0002, TestSize.Level1) EXPECT_NE(queryResult, ERR_OK); impl.OnDeath(); } + +/** + * @tc.number: CreateBundleDataDirWithEl_0100 + * @tc.name: test the CreateBundleDataDirWithEl + * @tc.desc: 1. CreateBundleDataDirWithEl + */ +HWTEST_F(BundleMgrClientSystemTest, CreateBundleDataDirWithEl_0100, Function | SmallTest | Level0) +{ + BundleMgrClientImpl impl; + sptr proxy = GetBundleMgrProxy(); + impl.bundleMgr_ = proxy; + impl.Connect(); + int32_t userId = 100; + DataDirEl dirEl = DataDirEl::EL1; + auto ret = impl.CreateBundleDataDirWithEl(userId, dirEl); + EXPECT_EQ(ret, ERR_APPEXECFWK_PARCEL_ERROR); + impl.OnDeath(); +} } // namespace AppExecFwk } // namespace OHOS \ No newline at end of file -- Gitee