1 /*
2 * Copyright (c) 2025 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16 #include <gtest/gtest.h>
17 #include "bundle_mgr_helper.h"
18
19 using namespace testing;
20 using namespace testing::ext;
21
22 namespace OHOS {
23 namespace AppExecFwk {
24 class BundleMgrHelperSecondTest : public testing::Test {
25 public:
26 static void SetUpTestCase();
27 static void TearDownTestCase();
28 void SetUp() override;
29 void TearDown() override;
30 static std::shared_ptr<BundleMgrHelper> bundleMgrHelper;
31 };
32
33 std::shared_ptr<BundleMgrHelper> BundleMgrHelperSecondTest::bundleMgrHelper =
34 DelayedSingleton<BundleMgrHelper>::GetInstance();
35
SetUpTestCase(void)36 void BundleMgrHelperSecondTest::SetUpTestCase(void)
37 {}
38
TearDownTestCase(void)39 void BundleMgrHelperSecondTest::TearDownTestCase(void)
40 {}
41
SetUp()42 void BundleMgrHelperSecondTest::SetUp()
43 {}
44
TearDown()45 void BundleMgrHelperSecondTest::TearDown()
46 {}
47
48 /**
49 * @tc.name: BundleMgrHelperSecondTest_GetNameAndIndexForUid_001
50 * @tc.desc: GetNameAndIndexForUid
51 * @tc.type: FUNC
52 */
53 HWTEST_F(BundleMgrHelperSecondTest, BundleMgrHelperSecondTest_GetNameAndIndexForUid_001, TestSize.Level1)
54 {
55 std::string bundleName = "bundleName";
56 int32_t uid = 1;
57 int32_t appIndex = 1;
58 auto ret = bundleMgrHelper->GetNameAndIndexForUid(uid, bundleName, appIndex);
59 EXPECT_NE(ret, ERR_APPEXECFWK_SERVICE_INTERNAL_ERROR);
60 }
61
62 /**
63 * @tc.name: BundleMgrHelperSecondTest_GetAppIdByBundleName_001
64 * @tc.desc: GetAppIdByBundleName
65 * @tc.type: FUNC
66 */
67 HWTEST_F(BundleMgrHelperSecondTest, BundleMgrHelperSecondTest_GetAppIdByBundleName_001, TestSize.Level1)
68 {
69 std::string bundleName = "";
70 int32_t userId = 1;
71 auto ret = bundleMgrHelper->GetAppIdByBundleName(bundleName, userId);
72 EXPECT_EQ(ret, "");
73 }
74
75 /**
76 * @tc.name: BundleMgrHelperSecondTest_GetStringById_001
77 * @tc.desc: GetStringById
78 * @tc.type: FUNC
79 */
80 HWTEST_F(BundleMgrHelperSecondTest, BundleMgrHelperSecondTest_GetAbilityLabel_001, TestSize.Level1)
81 {
82 std::string bundleName = "bundleName";
83 std::string moduleName = "moduleName";
84 uint32_t resId= 3;
85 int32_t userId = 1;
86 auto ret = bundleMgrHelper->GetStringById(bundleName, moduleName, resId, userId);
87 EXPECT_EQ(ret, "");
88 }
89
90 /**
91 * @tc.name: BundleMgrHelperSecondTest_GetDataDir_001
92 * @tc.desc: GetDataDir
93 * @tc.type: FUNC
94 */
95 HWTEST_F(BundleMgrHelperSecondTest, BundleMgrHelperSecondTest_GetDataDir_001, TestSize.Level1)
96 {
97 std::string bundleName = "bundleName";
98 int32_t appIndex = 1;
99 auto ret = bundleMgrHelper->GetDataDir(bundleName, appIndex);
100 EXPECT_NE(ret, "");
101 }
102
103 /**
104 * @tc.name: BundleMgrHelperSecondTest_GetPluginInfoForTarget_001
105 * @tc.desc: GetDataDir
106 * @tc.type: FUNC
107 */
108 HWTEST_F(BundleMgrHelperSecondTest, BundleMgrHelperSecondTest_GetPluginInfoForTarget_001, TestSize.Level1)
109 {
110 std::string hostBundleName = "hostBundleName";
111 std::string pluginBundleName = "pluginBundleName";
112 AppExecFwk::PluginBundleInfo pluginBundleInfo;
113 auto ret = bundleMgrHelper->GetPluginInfoForTarget(hostBundleName, pluginBundleName, 0, pluginBundleInfo);
114 EXPECT_NE(ret, ERR_OK);
115 }
116 } // namespace AppExecFwk
117 } // namespace OHOS