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