• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 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 
18 #define private public
19 #include "bundle_mgr_helper.h"
20 #undef private
21 
22 using namespace testing;
23 using namespace testing::ext;
24 
25 namespace OHOS {
26 namespace AppExecFwk {
27 namespace {
28 const int32_t ABILITY_INFO_FLAG = 4;
29 const int32_t DEFAULT_USERID = 100;
30 const int32_t FIRST_APP_INDEX = 1000;
31 const int32_t SECOND_APP_INDEX = 2000;
32 #ifdef WITH_DLP
33 const int32_t ERR_COD1 = 8519801;
34 #endif // WITH_DLP
35 const int32_t ERR_COD3 = 8519802;
36 const int32_t ERR_COD4 = 8519921;
37 const int32_t ERR_COD5 = 8519816;
38 const int32_t ERR_COD7 = 8521219;
39 } // namespace
40 
41 class BundleMgrHelperTest : public testing::Test {
42 public:
43     static void SetUpTestCase();
44     static void TearDownTestCase();
45     void SetUp() override;
46     void TearDown() override;
47     static std::shared_ptr<BundleMgrHelper> bundleMgrHelper;
48 };
49 
50 std::shared_ptr<BundleMgrHelper> BundleMgrHelperTest::bundleMgrHelper =
51     DelayedSingleton<BundleMgrHelper>::GetInstance();
52 
SetUpTestCase(void)53 void BundleMgrHelperTest::SetUpTestCase(void)
54 {}
55 
TearDownTestCase(void)56 void BundleMgrHelperTest::TearDownTestCase(void)
57 {}
58 
SetUp()59 void BundleMgrHelperTest::SetUp()
60 {}
61 
TearDown()62 void BundleMgrHelperTest::TearDown()
63 {}
64 
65 /**
66  * @tc.name: BundleMgrHelperTest_GetBundleInfo_001
67  * @tc.desc: GetBundleInfo
68  * @tc.type: FUNC
69  */
70 HWTEST_F(BundleMgrHelperTest, BundleMgrHelperTest_GetBundleInfo_001, TestSize.Level1)
71 {
72     std::string bundleName = "ohos.global.systemres";
73     int32_t flags = 0;
74     BundleInfo bundleInfo;
75     int32_t userId = DEFAULT_USERID;
76     auto ret = bundleMgrHelper->GetBundleInfo(bundleName, flags, bundleInfo, userId);
77     EXPECT_EQ(ret, true);
78 }
79 
80 /**
81  * @tc.name: BundleMgrHelperTest_GetHapModuleInfo_001
82  * @tc.desc: GetHapModuleInfo
83  * @tc.type: FUNC
84  */
85 HWTEST_F(BundleMgrHelperTest, BundleMgrHelperTest_GetHapModuleInfo_001, TestSize.Level1)
86 {
87     AbilityInfo abilityInfo;
88     HapModuleInfo hapModuleInfo;
89     auto ret = bundleMgrHelper->GetHapModuleInfo(abilityInfo, hapModuleInfo);
90     EXPECT_EQ(ret, false);
91 }
92 
93 /**
94  * @tc.name: BundleMgrHelperTest_GetAbilityLabel_001
95  * @tc.desc: GetAbilityLabel
96  * @tc.type: FUNC
97  */
98 HWTEST_F(BundleMgrHelperTest, BundleMgrHelperTest_GetAbilityLabel_001, TestSize.Level1)
99 {
100     std::string bundleName;
101     std::string abilityName;
102     auto ret = bundleMgrHelper->GetAbilityLabel(bundleName, abilityName);
103     EXPECT_EQ(ret, "");
104 }
105 
106 /**
107  * @tc.name: BundleMgrHelperTest_GetAppType_001
108  * @tc.desc: GetAppType
109  * @tc.type: FUNC
110  */
111 HWTEST_F(BundleMgrHelperTest, BundleMgrHelperTest_GetAppType_001, TestSize.Level1)
112 {
113     std::string bundleName;
114     auto ret = bundleMgrHelper->GetAppType(bundleName);
115     EXPECT_EQ(ret, "");
116 }
117 
118 /**
119  * @tc.name: BundleMgrHelperTest_GetBaseSharedBundleInfos_001
120  * @tc.desc: GetBaseSharedBundleInfos
121  * @tc.type: FUNC
122  */
123 HWTEST_F(BundleMgrHelperTest, BundleMgrHelperTest_GetBaseSharedBundleInfos_001, TestSize.Level1)
124 {
125     std::string bundleName;
126     std::vector<BaseSharedBundleInfo> baseSharedBundleInfos;
127     auto ret = bundleMgrHelper->GetBaseSharedBundleInfos(bundleName, baseSharedBundleInfos);
128     EXPECT_NE(ret, ERR_OK);
129 }
130 
131 /**
132  * @tc.name: BundleMgrHelperTest_GetBundleInfoForSelf_001
133  * @tc.desc: GetBundleInfoForSelf
134  * @tc.type: FUNC
135  */
136 HWTEST_F(BundleMgrHelperTest, BundleMgrHelperTest_GetBundleInfoForSelf_001, TestSize.Level1)
137 {
138     int32_t flags = 0;
139     BundleInfo bundleInfo;
140     auto ret = bundleMgrHelper->GetBundleInfoForSelf(flags, bundleInfo);
141     EXPECT_NE(ret, ERR_OK);
142 }
143 
144 /**
145  * @tc.name: BundleMgrHelperTest_GetDependentBundleInfo_001
146  * @tc.desc: GetDependentBundleInfo
147  * @tc.type: FUNC
148  */
149 HWTEST_F(BundleMgrHelperTest, BundleMgrHelperTest_GetDependentBundleInfo_001, TestSize.Level1)
150 {
151     std::string sharedBundleName;
152     BundleInfo sharedBundleInfo;
153     auto ret = bundleMgrHelper->GetDependentBundleInfo(sharedBundleName, sharedBundleInfo);
154     EXPECT_NE(ret, ERR_OK);
155 }
156 
157 /**
158  * @tc.name: BundleMgrHelperTest_GetGroupDir_001
159  * @tc.desc: GetGroupDir
160  * @tc.type: FUNC
161  */
162 HWTEST_F(BundleMgrHelperTest, BundleMgrHelperTest_GetGroupDir_001, TestSize.Level1)
163 {
164     std::string dataGroupId;
165     std::string dir;
166     auto ret = bundleMgrHelper->GetGroupDir(dataGroupId, dir);
167     EXPECT_EQ(ret, false);
168 }
169 
170 /**
171  * @tc.name: BundleMgrHelperTest_GetOverlayManagerProxy_001
172  * @tc.desc: GetOverlayManagerProxy
173  * @tc.type: FUNC
174  */
175 HWTEST_F(BundleMgrHelperTest, BundleMgrHelperTest_GetOverlayManagerProxy_001, TestSize.Level1)
176 {
177     auto ret = bundleMgrHelper->GetOverlayManagerProxy();
178     EXPECT_NE(ret, nullptr);
179 }
180 
181 /**
182  * @tc.name: BundleMgrHelperTest_QueryAbilityInfo_002
183  * @tc.desc: QueryAbilityInfo
184  * @tc.type: FUNC
185  */
186 HWTEST_F(BundleMgrHelperTest, BundleMgrHelperTest_QueryAbilityInfo_002, TestSize.Level1)
187 {
188     Want want;
189     AbilityInfo abilityInfo;
190     auto ret = bundleMgrHelper->QueryAbilityInfo(want, abilityInfo);
191     EXPECT_EQ(ret, false);
192 }
193 
194 /**
195  * @tc.name: BundleMgrHelperTest_QueryAbilityInfo_001
196  * @tc.desc: QueryAbilityInfo
197  * @tc.type: FUNC
198  */
199 HWTEST_F(BundleMgrHelperTest, BundleMgrHelperTest_QueryAbilityInfo_001, TestSize.Level1)
200 {
201     Want want;
202     int32_t flags = 0;
203     int32_t userId = DEFAULT_USERID;
204     AbilityInfo abilityInfo;
205     const sptr<IRemoteObject> callBack = nullptr;
206     auto ret = bundleMgrHelper->QueryAbilityInfo(want, flags, userId, abilityInfo, callBack);
207     EXPECT_EQ(ret, false);
208 }
209 
210 /**
211  * @tc.name: BundleMgrHelperTest_GetBundleInfos_001
212  * @tc.desc: GetBundleInfos
213  * @tc.type: FUNC
214  */
215 HWTEST_F(BundleMgrHelperTest, BundleMgrHelperTest_GetBundleInfos_001, TestSize.Level1)
216 {
217     BundleFlag flag = BundleFlag::GET_BUNDLE_WITH_ABILITIES;
218     std::vector<BundleInfo> bundleInfos;
219     int32_t userId = DEFAULT_USERID;
220     auto ret = bundleMgrHelper->GetBundleInfos(flag, bundleInfos, userId);
221     EXPECT_EQ(ret, true);
222 }
223 
224 /**
225  * @tc.name: BundleMgrHelperTest_ImplicitQueryInfos_001
226  * @tc.desc: ImplicitQueryInfos
227  * @tc.type: FUNC
228  */
229 HWTEST_F(BundleMgrHelperTest, BundleMgrHelperTest_ImplicitQueryInfos_001, TestSize.Level1)
230 {
231     Want want;
232     int32_t flags = 0;
233     int32_t userId = DEFAULT_USERID;
234     bool withDefault = false;
235     std::vector<AbilityInfo> abilityInfos;
236     std::vector<ExtensionAbilityInfo> extensionInfos;
237     bool findDefaultApp = false;
238     auto ret = bundleMgrHelper->ImplicitQueryInfos(want, flags, userId, withDefault, abilityInfos, extensionInfos,
239         findDefaultApp);
240     EXPECT_EQ(ret, false);
241 }
242 
243 /**
244  * @tc.name: BundleMgrHelperTest_CleanBundleDataFiles_001
245  * @tc.desc: CleanBundleDataFiles
246  * @tc.type: FUNC
247  */
248 HWTEST_F(BundleMgrHelperTest, BundleMgrHelperTest_CleanBundleDataFiles_001, TestSize.Level1)
249 {
250     std::string bundleName;
251     int32_t userId = DEFAULT_USERID;
252     auto ret = bundleMgrHelper->CleanBundleDataFiles(bundleName, userId, 0);
253     EXPECT_EQ(ret, false);
254 }
255 
256 /**
257  * @tc.name: BundleMgrHelperTest_QueryDataGroupInfos_001
258  * @tc.desc: QueryDataGroupInfos
259  * @tc.type: FUNC
260  */
261 HWTEST_F(BundleMgrHelperTest, BundleMgrHelperTest_QueryDataGroupInfos_001, TestSize.Level1)
262 {
263     std::string bundleName;
264     int32_t userId = DEFAULT_USERID;
265     std::vector<DataGroupInfo> infos;
266     auto ret = bundleMgrHelper->QueryDataGroupInfos(bundleName, userId, infos);
267     EXPECT_EQ(ret, false);
268 }
269 
270 /**
271  * @tc.name: BundleMgrHelperTest_RegisterBundleEventCallback_001
272  * @tc.desc: RegisterBundleEventCallback
273  * @tc.type: FUNC
274  */
275 HWTEST_F(BundleMgrHelperTest, BundleMgrHelperTest_RegisterBundleEventCallback_001, TestSize.Level1)
276 {
277     const sptr<IBundleEventCallback> bundleEventCallback = nullptr;
278     auto ret = bundleMgrHelper->RegisterBundleEventCallback(bundleEventCallback);
279     EXPECT_EQ(ret, false);
280 }
281 
282 /**
283  * @tc.name: BundleMgrHelperTest_GetQuickFixManagerProxy_001
284  * @tc.desc: GetQuickFixManagerProxy
285  * @tc.type: FUNC
286  */
287 HWTEST_F(BundleMgrHelperTest, BundleMgrHelperTest_GetQuickFixManagerProxy_001, TestSize.Level1)
288 {
289     auto ret = bundleMgrHelper->GetQuickFixManagerProxy();
290     EXPECT_NE(ret, nullptr);
291 }
292 
293 /**
294  * @tc.name: BundleMgrHelperTest_QueryExtensionAbilityInfos_002
295  * @tc.desc: QueryExtensionAbilityInfos
296  * @tc.type: FUNC
297  */
298 HWTEST_F(BundleMgrHelperTest, BundleMgrHelperTest_QueryExtensionAbilityInfos_002, TestSize.Level1)
299 {
300     Want want;
301     int32_t flag = 0;
302     int32_t userId = DEFAULT_USERID;
303     std::vector<ExtensionAbilityInfo> extensionInfos;
304     auto ret = bundleMgrHelper->QueryExtensionAbilityInfos(want, flag, userId, extensionInfos);
305     EXPECT_EQ(ret, false);
306 }
307 
308 /**
309  * @tc.name: BundleMgrHelperTest_GetAppControlProxy_001
310  * @tc.desc: GetAppControlProxy
311  * @tc.type: FUNC
312  */
313 HWTEST_F(BundleMgrHelperTest, BundleMgrHelperTest_GetAppControlProxy_001, TestSize.Level1)
314 {
315     auto ret = bundleMgrHelper->GetAppControlProxy();
316     EXPECT_NE(ret, nullptr);
317 }
318 
319 /**
320  * @tc.name: BundleMgrHelperTest_QueryExtensionAbilityInfos_001
321  * @tc.desc: QueryExtensionAbilityInfos
322  * @tc.type: FUNC
323  */
324 HWTEST_F(BundleMgrHelperTest, BundleMgrHelperTest_QueryExtensionAbilityInfos_001, TestSize.Level1)
325 {
326     Want want;
327     int32_t flag = 0;
328     int32_t userId = DEFAULT_USERID;
329     std::vector<ExtensionAbilityInfo> extensionInfos;
330     auto ret = bundleMgrHelper->QueryExtensionAbilityInfos(want, flag, userId, extensionInfos);
331     EXPECT_EQ(ret, false);
332 }
333 
334 /**
335  * @tc.name: BundleMgrHelperTest_GetApplicationInfo_001
336  * @tc.desc: GetApplicationInfo
337  * @tc.type: FUNC
338  */
339 HWTEST_F(BundleMgrHelperTest, BundleMgrHelperTest_GetApplicationInfo_001, TestSize.Level1)
340 {
341     std::string appName;
342     ApplicationFlag flag = ApplicationFlag::GET_ALL_APPLICATION_INFO;
343     int userId = DEFAULT_USERID;
344     ApplicationInfo appInfo;
345     auto ret = bundleMgrHelper->GetApplicationInfo(appName, flag, userId, appInfo);
346     EXPECT_EQ(ret, false);
347 }
348 
349 /**
350  * @tc.name: BundleMgrHelperTest_UnregisterBundleEventCallback_001
351  * @tc.desc: UnregisterBundleEventCallback
352  * @tc.type: FUNC
353  */
354 HWTEST_F(BundleMgrHelperTest, BundleMgrHelperTest_UnregisterBundleEventCallback_001, TestSize.Level1)
355 {
356     sptr<IBundleEventCallback> bundleEventCallback = nullptr;
357     auto ret = bundleMgrHelper->UnregisterBundleEventCallback(bundleEventCallback);
358     EXPECT_EQ(ret, false);
359 }
360 
361 /**
362  * @tc.name: BundleMgrHelperTest_QueryExtensionAbilityInfoByUri_001
363  * @tc.desc: QueryExtensionAbilityInfoByUri
364  * @tc.type: FUNC
365  */
366 HWTEST_F(BundleMgrHelperTest, BundleMgrHelperTest_QueryExtensionAbilityInfoByUri_001, TestSize.Level1)
367 {
368     std::string uri;
369     int32_t userId = DEFAULT_USERID;
370     ExtensionAbilityInfo extensionAbilityInfo;
371     auto ret = bundleMgrHelper->QueryExtensionAbilityInfoByUri(uri, userId, extensionAbilityInfo);
372     EXPECT_EQ(ret, false);
373 }
374 
375 /**
376  * @tc.name: BundleMgrHelperTest_QueryAbilityInfoByUri_001
377  * @tc.desc: QueryAbilityInfoByUri
378  * @tc.type: FUNC
379  */
380 HWTEST_F(BundleMgrHelperTest, BundleMgrHelperTest_QueryAbilityInfoByUri_001, TestSize.Level1)
381 {
382     std::string abilityUri;
383     int32_t userId = DEFAULT_USERID;
384     AbilityInfo abilityInfo;
385     auto ret = bundleMgrHelper->QueryAbilityInfoByUri(abilityUri, userId, abilityInfo);
386     EXPECT_EQ(ret, false);
387 }
388 
389 /**
390  * @tc.name: BundleMgrHelperTest_ImplicitQueryInfoByPriority_001
391  * @tc.desc: ImplicitQueryInfoByPriority
392  * @tc.type: FUNC
393  */
394 HWTEST_F(BundleMgrHelperTest, BundleMgrHelperTest_ImplicitQueryInfoByPriority_001, TestSize.Level1)
395 {
396     Want want;
397     int32_t flags = 0;
398     int32_t userId = DEFAULT_USERID;
399     AbilityInfo abilityInfo;
400     ExtensionAbilityInfo extensionInfo;
401     auto ret = bundleMgrHelper->ImplicitQueryInfoByPriority(want, flags, userId, abilityInfo, extensionInfo);
402     EXPECT_EQ(ret, false);
403 }
404 
405 /**
406  * @tc.name: BundleMgrHelperTest_GetBundleInfos_002
407  * @tc.desc: GetBundleInfos
408  * @tc.type: FUNC
409  */
410 HWTEST_F(BundleMgrHelperTest, BundleMgrHelperTest_GetBundleInfos_002, TestSize.Level1)
411 {
412     int32_t flags = 0;
413     std::vector<BundleInfo> bundleInfos;
414     int32_t userId = DEFAULT_USERID;
415     auto ret = bundleMgrHelper->GetBundleInfos(flags, bundleInfos, userId);
416     EXPECT_EQ(ret, true);
417 }
418 
419 /**
420  * @tc.name: BundleMgrHelperTest_GetHapModuleInfo_002
421  * @tc.desc: GetHapModuleInfo
422  * @tc.type: FUNC
423  */
424 HWTEST_F(BundleMgrHelperTest, BundleMgrHelperTest_GetHapModuleInfo_002, TestSize.Level1)
425 {
426     AbilityInfo abilityInfo;
427     int32_t userId = DEFAULT_USERID;
428     HapModuleInfo hapModuleInfo;
429     auto ret = bundleMgrHelper->GetHapModuleInfo(abilityInfo, userId, hapModuleInfo);
430     EXPECT_EQ(ret, false);
431 }
432 
433 /**
434  * @tc.name: BundleMgrHelperTest_GetUidByBundleName_001
435  * @tc.desc: GetUidByBundleName
436  * @tc.type: FUNC
437  */
438 HWTEST_F(BundleMgrHelperTest, BundleMgrHelperTest_GetUidByBundleName_001, TestSize.Level1)
439 {
440     std::string bundleName;
441     int32_t userId = DEFAULT_USERID;
442     auto ret = bundleMgrHelper->GetUidByBundleName(bundleName, userId, 0);
443     EXPECT_EQ(ret, Constants::INVALID_UID);
444 }
445 
446 /**
447  * @tc.name: BundleMgrHelperTest_GetApplicationInfo_002
448  * @tc.desc: GetApplicationInfo
449  * @tc.type: FUNC
450  */
451 HWTEST_F(BundleMgrHelperTest, BundleMgrHelperTest_GetApplicationInfo_002, TestSize.Level1)
452 {
453     std::string appName;
454     int32_t flags = 0;
455     int32_t userId = DEFAULT_USERID;
456     ApplicationInfo appInfo;
457     auto ret = bundleMgrHelper->GetApplicationInfo(appName, flags, userId, appInfo);
458     EXPECT_EQ(ret, false);
459 }
460 
461 /**
462  * @tc.name: BundleMgrHelperTest_ProcessPreload_001
463  * @tc.desc: ProcessPreload
464  * @tc.type: FUNC
465  */
466 HWTEST_F(BundleMgrHelperTest, BundleMgrHelperTest_ProcessPreload_001, TestSize.Level1)
467 {
468     Want want;
469     auto ret = bundleMgrHelper->ProcessPreload(want);
470     EXPECT_EQ(ret, false);
471 }
472 
473 /**
474  * @tc.name: BundleMgrHelperTest_UpgradeAtomicService_001
475  * @tc.desc: UpgradeAtomicService
476  * @tc.type: FUNC
477  */
478 HWTEST_F(BundleMgrHelperTest, BundleMgrHelperTest_UpgradeAtomicService_001, TestSize.Level1)
479 {
480     Want want;
481     int32_t userId = DEFAULT_USERID;
482     bundleMgrHelper->UpgradeAtomicService(want, userId);
483     EXPECT_NE(bundleMgrHelper->bundleMgr_, nullptr);
484 }
485 
486 /**
487  * @tc.name: BundleMgrHelperTest_QueryAbilityInfo_003
488  * @tc.desc: QueryAbilityInfo
489  * @tc.type: FUNC
490  */
491 HWTEST_F(BundleMgrHelperTest, BundleMgrHelperTest_QueryAbilityInfo_003, TestSize.Level1)
492 {
493     Want want;
494     int32_t flags = DEFAULT_USERID;
495     int32_t userId = DEFAULT_USERID;
496     AbilityInfo abilityInfo;
497     auto ret = bundleMgrHelper->QueryAbilityInfo(want, flags, userId, abilityInfo);
498     EXPECT_EQ(ret, false);
499 }
500 
501 /**
502  * @tc.name: BundleMgrHelperTest_GetDefaultAppProxy_001
503  * @tc.desc: GetDefaultAppProxy
504  * @tc.type: FUNC
505  */
506 HWTEST_F(BundleMgrHelperTest, BundleMgrHelperTest_GetDefaultAppProxy_001, TestSize.Level1)
507 {
508     auto ret = bundleMgrHelper->GetDefaultAppProxy();
509     EXPECT_NE(ret, nullptr);
510 }
511 
512 #ifdef WITH_DLP
513 /**
514  * @tc.name: BundleMgrHelperTest_InstallSandboxApp_001
515  * @tc.desc: InstallSandboxApp
516  * @tc.type: FUNC
517  */
518 HWTEST_F(BundleMgrHelperTest, BundleMgrHelperTest_InstallSandboxApp_001, TestSize.Level1)
519 {
520     std::string bundleName = "";
521     int32_t dlpType = 1;
522     int32_t userId = 1;
523     int32_t appIndex = 1;
524     auto ret = bundleMgrHelper->InstallSandboxApp(bundleName, dlpType, userId, appIndex);
525     EXPECT_EQ(ret, ERR_APPEXECFWK_SANDBOX_INSTALL_PARAM_ERROR);
526 }
527 
528 /**
529  * @tc.name: BundleMgrHelperTest_InstallSandboxApp_002
530  * @tc.desc: InstallSandboxApp
531  * @tc.type: FUNC
532  */
533 HWTEST_F(BundleMgrHelperTest, BundleMgrHelperTest_InstallSandboxApp_002, TestSize.Level1)
534 {
535     std::string bundleName = "bundleName";
536     int32_t dlpType = 1;
537     int32_t userId = 1;
538     int32_t appIndex = 1;
539     auto ret = bundleMgrHelper->InstallSandboxApp(bundleName, dlpType, userId, appIndex);
540     EXPECT_EQ(ret, ERR_COD1);
541 }
542 #endif // WITH_DLP
543 
544 /**
545  * @tc.name: BundleMgrHelperTest_UninstallSandboxApp_001
546  * @tc.desc: UninstallSandboxApp
547  * @tc.type: FUNC
548  */
549 HWTEST_F(BundleMgrHelperTest, BundleMgrHelperTest_UninstallSandboxApp_001, TestSize.Level1)
550 {
551     std::string bundleName = "";
552     int32_t userId = 1;
553     int32_t appIndex = 1;
554     auto ret = bundleMgrHelper->UninstallSandboxApp(bundleName, userId, appIndex);
555     EXPECT_EQ(ret, ERR_APPEXECFWK_SANDBOX_INSTALL_PARAM_ERROR);
556 }
557 
558 /**
559  * @tc.name: BundleMgrHelperTest_UninstallSandboxApp_002
560  * @tc.desc: UninstallSandboxApp
561  * @tc.type: FUNC
562  */
563 HWTEST_F(BundleMgrHelperTest, BundleMgrHelperTest_UninstallSandboxApp_002, TestSize.Level1)
564 {
565     std::string bundleName = "bundleName";
566     int32_t appIndex = 1;
567     int32_t userId = 1;
568     auto ret = bundleMgrHelper->UninstallSandboxApp(bundleName, appIndex, userId);
569     EXPECT_EQ(ret, ERR_APPEXECFWK_SANDBOX_INSTALL_PARAM_ERROR);
570 }
571 
572 /**
573  * @tc.name: BundleMgrHelperTest_UninstallSandboxApp_003
574  * @tc.desc: UninstallSandboxApp
575  * @tc.type: FUNC
576  */
577 HWTEST_F(BundleMgrHelperTest, BundleMgrHelperTest_UninstallSandboxApp_003, TestSize.Level1)
578 {
579     std::string bundleName = "bundleName";
580     int32_t userId = 1;
581     int32_t appIndex = -1;
582     auto ret = bundleMgrHelper->UninstallSandboxApp(bundleName, userId, appIndex);
583     EXPECT_EQ(ret, ERR_COD3);
584 }
585 
586 /**
587  * @tc.name: BundleMgrHelperTest_GetUninstalledBundleInfo_001
588  * @tc.desc: GetUninstalledBundleInfo
589  * @tc.type: FUNC
590  */
591 HWTEST_F(BundleMgrHelperTest, BundleMgrHelperTest_GetUninstalledBundleInfo_001, TestSize.Level1)
592 {
593     std::string bundleName = "bundleName";
594     BundleInfo bundleInfo;
595     auto ret = bundleMgrHelper->GetUninstalledBundleInfo(bundleName, bundleInfo);
596     EXPECT_EQ(ret, ERR_COD4);
597 }
598 
599 /**
600  * @tc.name: BundleMgrHelperTest_GetSandboxBundleInfo_001
601  * @tc.desc: GetSandboxBundleInfo
602  * @tc.type: FUNC
603  */
604 HWTEST_F(BundleMgrHelperTest, BundleMgrHelperTest_GetSandboxBundleInfo_001, TestSize.Level1)
605 {
606     std::string bundleName = "bundleName";
607     int32_t appIndex = -1;
608     int32_t userId = 1;
609     BundleInfo bundleInfo;
610     auto ret = bundleMgrHelper->GetSandboxBundleInfo(bundleName, appIndex, userId, bundleInfo);
611     EXPECT_EQ(ret, ERR_APPEXECFWK_SANDBOX_INSTALL_PARAM_ERROR);
612 }
613 
614 /**
615  * @tc.name: BundleMgrHelperTest_GetSandboxBundleInfo_002
616  * @tc.desc: GetSandboxBundleInfo
617  * @tc.type: FUNC
618  */
619 HWTEST_F(BundleMgrHelperTest, BundleMgrHelperTest_GetSandboxBundleInfo_002, TestSize.Level1)
620 {
621     std::string bundleName = "";
622     int32_t appIndex = 10;
623     int32_t userId = 1;
624     BundleInfo bundleInfo;
625     auto ret = bundleMgrHelper->GetSandboxBundleInfo(bundleName, appIndex, userId, bundleInfo);
626     EXPECT_EQ(ret, ERR_APPEXECFWK_SANDBOX_INSTALL_PARAM_ERROR);
627 }
628 
629 /**
630  * @tc.name: BundleMgrHelperTest_GetSandboxAbilityInfo_001
631  * @tc.desc: GetSandboxAbilityInfo
632  * @tc.type: FUNC
633  */
634 HWTEST_F(BundleMgrHelperTest, BundleMgrHelperTest_GetSandboxAbilityInfo_001, TestSize.Level1)
635 {
636     Want want;
637     int32_t appIndex = 0;
638     int32_t flags = 1;
639     int32_t userId = 1;
640     AbilityInfo abilityInfo;
641     auto ret = bundleMgrHelper->GetSandboxAbilityInfo(want, appIndex, flags, userId, abilityInfo);
642     EXPECT_EQ(ret, ERR_APPEXECFWK_SANDBOX_INSTALL_PARAM_ERROR);
643 }
644 
645 /**
646  * @tc.name: BundleMgrHelperTest_GetSandboxAbilityInfo_002
647  * @tc.desc: GetSandboxAbilityInfo
648  * @tc.type: FUNC
649  */
650 HWTEST_F(BundleMgrHelperTest, BundleMgrHelperTest_GetSandboxAbilityInfo_002, TestSize.Level1)
651 {
652     Want want;
653     int32_t appIndex = FIRST_APP_INDEX;
654     int32_t flags = 1;
655     int32_t userId = 1;
656     AbilityInfo abilityInfo;
657     auto ret = bundleMgrHelper->GetSandboxAbilityInfo(want, appIndex, flags, userId, abilityInfo);
658     EXPECT_EQ(ret, ERR_APPEXECFWK_SANDBOX_INSTALL_PARAM_ERROR);
659 }
660 
661 /**
662  * @tc.name: BundleMgrHelperTest_GetSandboxAbilityInfo_003
663  * @tc.desc: GetSandboxAbilityInfo
664  * @tc.type: FUNC
665  */
666 HWTEST_F(BundleMgrHelperTest, BundleMgrHelperTest_GetSandboxAbilityInfo_003, TestSize.Level1)
667 {
668     Want want;
669     int32_t appIndex = SECOND_APP_INDEX;
670     int32_t flags = 1;
671     int32_t userId = 1;
672     AbilityInfo abilityInfo;
673     auto ret = bundleMgrHelper->GetSandboxAbilityInfo(want, appIndex, flags, userId, abilityInfo);
674     EXPECT_EQ(ret, ERR_COD5);
675 }
676 
677 /**
678  * @tc.name: BundleMgrHelperTest_GetSandboxExtAbilityInfos_001
679  * @tc.desc: GetSandboxExtAbilityInfos
680  * @tc.type: FUNC
681  */
682 HWTEST_F(BundleMgrHelperTest, BundleMgrHelperTest_GetSandboxExtAbilityInfos_001, TestSize.Level1)
683 {
684     Want want;
685     int32_t appIndex = SECOND_APP_INDEX;
686     int32_t flags = 1;
687     int32_t userId = 1;
688     std::vector<ExtensionAbilityInfo> extensionInfos;
689     auto ret = bundleMgrHelper->GetSandboxExtAbilityInfos(want, appIndex, flags, userId, extensionInfos);
690     EXPECT_EQ(ret, ERR_COD5);
691 }
692 
693 /**
694  * @tc.name: BundleMgrHelperTest_GetSandboxHapModuleInfo_001
695  * @tc.desc: GetSandboxHapModuleInfo
696  * @tc.type: FUNC
697  */
698 HWTEST_F(BundleMgrHelperTest, BundleMgrHelperTest_GetSandboxHapModuleInfo_001, TestSize.Level1)
699 {
700     AbilityInfo abilityInfo;
701     int32_t appIndex = 0;
702     int32_t userId = 1;
703     HapModuleInfo hapModuleInfo;
704     auto ret = bundleMgrHelper->GetSandboxHapModuleInfo(abilityInfo, appIndex, userId, hapModuleInfo);
705     EXPECT_EQ(ret, ERR_APPEXECFWK_SANDBOX_INSTALL_PARAM_ERROR);
706 }
707 
708 /**
709  * @tc.name: BundleMgrHelperTest_GetSandboxHapModuleInfo_002
710  * @tc.desc: GetSandboxHapModuleInfo
711  * @tc.type: FUNC
712  */
713 HWTEST_F(BundleMgrHelperTest, BundleMgrHelperTest_GetSandboxHapModuleInfo_002, TestSize.Level1)
714 {
715     AbilityInfo abilityInfo;
716     int32_t appIndex = FIRST_APP_INDEX;
717     int32_t userId = 1;
718     HapModuleInfo hapModuleInfo;
719     auto ret = bundleMgrHelper->GetSandboxHapModuleInfo(abilityInfo, appIndex, userId, hapModuleInfo);
720     EXPECT_EQ(ret, ERR_APPEXECFWK_SANDBOX_INSTALL_PARAM_ERROR);
721 }
722 
723 /**
724  * @tc.name: BundleMgrHelperTest_GetSandboxHapModuleInfo_003
725  * @tc.desc: GetSandboxHapModuleInfo
726  * @tc.type: FUNC
727  */
728 HWTEST_F(BundleMgrHelperTest, BundleMgrHelperTest_GetSandboxHapModuleInfo_003, TestSize.Level1)
729 {
730     AbilityInfo abilityInfo;
731     int32_t appIndex = SECOND_APP_INDEX;
732     int32_t userId = 1;
733     HapModuleInfo hapModuleInfo;
734     auto ret = bundleMgrHelper->GetSandboxHapModuleInfo(abilityInfo, appIndex, userId, hapModuleInfo);
735     EXPECT_EQ(ret, ERR_COD5);
736 }
737 
738 /**
739  * @tc.name: BundleMgrHelperTest_ConnectBundleInstaller_001
740  * @tc.desc: ConnectBundleInstaller
741  * @tc.type: FUNC
742  */
743 HWTEST_F(BundleMgrHelperTest, BundleMgrHelperTest_ConnectBundleInstaller_001, TestSize.Level1)
744 {
745     bundleMgrHelper->OnDeath();
746     auto ret = bundleMgrHelper->ConnectBundleInstaller();
747     EXPECT_NE(ret, nullptr);
748 }
749 
750 /**
751  * @tc.name: BundleMgrHelperTest_GetBundleInfoV9_001
752  * @tc.desc: GetBundleInfoV9
753  * @tc.type: FUNC
754  */
755 HWTEST_F(BundleMgrHelperTest, BundleMgrHelperTest_GetBundleInfoV9_001, TestSize.Level1)
756 {
757     std::string bundleName = "bundleName";
758     int32_t flags = 1;
759     BundleInfo bundleInfo;
760     int32_t userId = 1;
761     auto ret = bundleMgrHelper->GetBundleInfoV9(bundleName, flags, bundleInfo, userId);
762     EXPECT_EQ(ret, ERR_COD7);
763 }
764 
765 /**
766  * @tc.name: QueryExtensionAbilityInfosOnlyWithTypeName_001
767  * @tc.desc: QueryExtensionAbilityInfosOnlyWithTypeName
768  * @tc.type: FUNC
769  */
770 HWTEST_F(BundleMgrHelperTest, QueryExtensionAbilityInfosOnlyWithTypeName_001, TestSize.Level1)
771 {
772     std::string extensionTypeName = "extensionTypeName";
773     uint32_t flag = 1;
774     int32_t userId = 1;
775     std::vector<ExtensionAbilityInfo> extensionInfos;
776     auto ret = bundleMgrHelper->QueryExtensionAbilityInfosOnlyWithTypeName(extensionTypeName,
777         flag, userId, extensionInfos);
778     EXPECT_EQ(ret, ERR_COD7);
779 }
780 
781 /**
782  * @tc.name: GetJsonProfile_001
783  * @tc.desc: GetJsonProfile
784  * @tc.type: FUNC
785  */
786 HWTEST_F(BundleMgrHelperTest, GetJsonProfile_001, TestSize.Level1)
787 {
788     ProfileType profileType = AppExecFwk::PKG_CONTEXT_PROFILE;
789     std::string bundleName = "bundleName";
790     std::string moduleName = "moduleName";
791     std::string profile = "profile";
792     int32_t userId = 1;
793     auto ret = bundleMgrHelper->GetJsonProfile(profileType, bundleName, moduleName, profile, userId);
794     EXPECT_EQ(ret, ERR_COD7);
795 }
796 
797 /**
798  * @tc.name: BundleMgrHelperTest_QueryCloneAbilityInfo_001
799  * @tc.desc: QueryCloneAbilityInfo
800  * @tc.type: FUNC
801  */
802 HWTEST_F(BundleMgrHelperTest, BundleMgrHelperTest_QueryCloneAbilityInfo_001, TestSize.Level1)
803 {
804     ElementName element;
805     AbilityInfo abilityInfo;
806     int32_t flags = ABILITY_INFO_FLAG;
807     int32_t appCloneIndex = 1;
808     int32_t userId = DEFAULT_USERID;
809     auto ret = bundleMgrHelper->QueryCloneAbilityInfo(element, flags, appCloneIndex, abilityInfo, userId);
810     EXPECT_NE(ret, ERR_OK);
811 }
812 
813 /**
814  * @tc.name: BundleMgrHelperTest_GetCloneBundleInfo_001
815  * @tc.desc: GetCloneBundleInfo
816  * @tc.type: FUNC
817  */
818 HWTEST_F(BundleMgrHelperTest, BundleMgrHelperTest_GetCloneBundleInfo_001, TestSize.Level1)
819 {
820     std::string bundleName;
821     BundleInfo bundleInfo;
822     int32_t flags = 1;
823     int32_t appCloneIndex = 1;
824     int32_t userId = DEFAULT_USERID;
825     auto ret = bundleMgrHelper->GetCloneBundleInfo(bundleName, flags, appCloneIndex, bundleInfo, userId);
826     EXPECT_NE(ret, ERR_OK);
827 }
828 
829 /**
830  * @tc.name: BundleMgrHelperTest_GetNameForUid_001
831  * @tc.desc: GetNameForUid
832  * @tc.type: FUNC
833  */
834 HWTEST_F(BundleMgrHelperTest, BundleMgrHelperTest_GetNameForUid_001, TestSize.Level1)
835 {
836     std::string name;
837     int32_t uid = 1;
838     auto ret = bundleMgrHelper->GetNameForUid(uid, name);
839     EXPECT_NE(ret, ERR_OK);
840 }
841 
842 /**
843  * @tc.name: BundleMgrHelperTest_GetLaunchWantForBundle_001
844  * @tc.desc: GetLaunchWantForBundle
845  * @tc.type: FUNC
846  */
847 HWTEST_F(BundleMgrHelperTest, BundleMgrHelperTest_GetLaunchWantForBundle_001, TestSize.Level1)
848 {
849     std::string bundleName;
850     Want want;
851     int32_t userId = DEFAULT_USERID;
852     auto ret = bundleMgrHelper->GetLaunchWantForBundle(bundleName, want, userId);
853     EXPECT_NE(ret, ERR_OK);
854 }
855 
856 /**
857  * @tc.name: BundleMgrHelperTest_GetSignatureInfoByBundleName_001
858  * @tc.desc: GetSignatureInfoByBundleName
859  * @tc.type: FUNC
860  */
861 HWTEST_F(BundleMgrHelperTest, BundleMgrHelperTest_GetSignatureInfoByBundleName_001, TestSize.Level1)
862 {
863     std::string bundleName;
864     SignatureInfo signatureInfo;
865     auto ret = bundleMgrHelper->GetSignatureInfoByBundleName(bundleName, signatureInfo);
866     EXPECT_NE(ret, ERR_OK);
867 }
868 
869 /**
870  * @tc.name: BundleMgrHelperTest_GetAppProvisionInfo_001
871  * @tc.desc: GetAppProvisionInfo
872  * @tc.type: FUNC
873  */
874 HWTEST_F(BundleMgrHelperTest, BundleMgrHelperTest_GetAppProvisionInfo_001, TestSize.Level1)
875 {
876     std::string bundleName;
877     int32_t userId = DEFAULT_USERID;
878     AppExecFwk::AppProvisionInfo info;
879     auto ret = bundleMgrHelper->GetAppProvisionInfo(bundleName, userId, info);
880     EXPECT_NE(ret, ERR_OK);
881 }
882 }  // namespace AppExecFwk
883 }  // namespace OHOS