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 auto ret = bundleMgrHelper->ImplicitQueryInfos(want, flags, userId, withDefault, abilityInfos, extensionInfos);
238 EXPECT_EQ(ret, false);
239 }
240
241 /**
242 * @tc.name: BundleMgrHelperTest_CleanBundleDataFiles_001
243 * @tc.desc: CleanBundleDataFiles
244 * @tc.type: FUNC
245 */
246 HWTEST_F(BundleMgrHelperTest, BundleMgrHelperTest_CleanBundleDataFiles_001, TestSize.Level1)
247 {
248 std::string bundleName;
249 int32_t userId = DEFAULT_USERID;
250 auto ret = bundleMgrHelper->CleanBundleDataFiles(bundleName, userId, 0);
251 EXPECT_EQ(ret, false);
252 }
253
254 /**
255 * @tc.name: BundleMgrHelperTest_QueryDataGroupInfos_001
256 * @tc.desc: QueryDataGroupInfos
257 * @tc.type: FUNC
258 */
259 HWTEST_F(BundleMgrHelperTest, BundleMgrHelperTest_QueryDataGroupInfos_001, TestSize.Level1)
260 {
261 std::string bundleName;
262 int32_t userId = DEFAULT_USERID;
263 std::vector<DataGroupInfo> infos;
264 auto ret = bundleMgrHelper->QueryDataGroupInfos(bundleName, userId, infos);
265 EXPECT_EQ(ret, false);
266 }
267
268 /**
269 * @tc.name: BundleMgrHelperTest_RegisterBundleEventCallback_001
270 * @tc.desc: RegisterBundleEventCallback
271 * @tc.type: FUNC
272 */
273 HWTEST_F(BundleMgrHelperTest, BundleMgrHelperTest_RegisterBundleEventCallback_001, TestSize.Level1)
274 {
275 const sptr<IBundleEventCallback> bundleEventCallback = nullptr;
276 auto ret = bundleMgrHelper->RegisterBundleEventCallback(bundleEventCallback);
277 EXPECT_EQ(ret, false);
278 }
279
280 /**
281 * @tc.name: BundleMgrHelperTest_GetQuickFixManagerProxy_001
282 * @tc.desc: GetQuickFixManagerProxy
283 * @tc.type: FUNC
284 */
285 HWTEST_F(BundleMgrHelperTest, BundleMgrHelperTest_GetQuickFixManagerProxy_001, TestSize.Level1)
286 {
287 auto ret = bundleMgrHelper->GetQuickFixManagerProxy();
288 EXPECT_NE(ret, nullptr);
289 }
290
291 /**
292 * @tc.name: BundleMgrHelperTest_QueryExtensionAbilityInfos_002
293 * @tc.desc: QueryExtensionAbilityInfos
294 * @tc.type: FUNC
295 */
296 HWTEST_F(BundleMgrHelperTest, BundleMgrHelperTest_QueryExtensionAbilityInfos_002, TestSize.Level1)
297 {
298 Want want;
299 int32_t flag = 0;
300 int32_t userId = DEFAULT_USERID;
301 std::vector<ExtensionAbilityInfo> extensionInfos;
302 auto ret = bundleMgrHelper->QueryExtensionAbilityInfos(want, flag, userId, extensionInfos);
303 EXPECT_EQ(ret, false);
304 }
305
306 /**
307 * @tc.name: BundleMgrHelperTest_GetAppControlProxy_001
308 * @tc.desc: GetAppControlProxy
309 * @tc.type: FUNC
310 */
311 HWTEST_F(BundleMgrHelperTest, BundleMgrHelperTest_GetAppControlProxy_001, TestSize.Level1)
312 {
313 auto ret = bundleMgrHelper->GetAppControlProxy();
314 EXPECT_NE(ret, nullptr);
315 }
316
317 /**
318 * @tc.name: BundleMgrHelperTest_QueryExtensionAbilityInfos_001
319 * @tc.desc: QueryExtensionAbilityInfos
320 * @tc.type: FUNC
321 */
322 HWTEST_F(BundleMgrHelperTest, BundleMgrHelperTest_QueryExtensionAbilityInfos_001, TestSize.Level1)
323 {
324 Want want;
325 int32_t flag = 0;
326 int32_t userId = DEFAULT_USERID;
327 std::vector<ExtensionAbilityInfo> extensionInfos;
328 auto ret = bundleMgrHelper->QueryExtensionAbilityInfos(want, flag, userId, extensionInfos);
329 EXPECT_EQ(ret, false);
330 }
331
332 /**
333 * @tc.name: BundleMgrHelperTest_GetApplicationInfo_001
334 * @tc.desc: GetApplicationInfo
335 * @tc.type: FUNC
336 */
337 HWTEST_F(BundleMgrHelperTest, BundleMgrHelperTest_GetApplicationInfo_001, TestSize.Level1)
338 {
339 std::string appName;
340 ApplicationFlag flag = ApplicationFlag::GET_ALL_APPLICATION_INFO;
341 int userId = DEFAULT_USERID;
342 ApplicationInfo appInfo;
343 auto ret = bundleMgrHelper->GetApplicationInfo(appName, flag, userId, appInfo);
344 EXPECT_EQ(ret, false);
345 }
346
347 /**
348 * @tc.name: BundleMgrHelperTest_UnregisterBundleEventCallback_001
349 * @tc.desc: UnregisterBundleEventCallback
350 * @tc.type: FUNC
351 */
352 HWTEST_F(BundleMgrHelperTest, BundleMgrHelperTest_UnregisterBundleEventCallback_001, TestSize.Level1)
353 {
354 sptr<IBundleEventCallback> bundleEventCallback = nullptr;
355 auto ret = bundleMgrHelper->UnregisterBundleEventCallback(bundleEventCallback);
356 EXPECT_EQ(ret, false);
357 }
358
359 /**
360 * @tc.name: BundleMgrHelperTest_QueryExtensionAbilityInfoByUri_001
361 * @tc.desc: QueryExtensionAbilityInfoByUri
362 * @tc.type: FUNC
363 */
364 HWTEST_F(BundleMgrHelperTest, BundleMgrHelperTest_QueryExtensionAbilityInfoByUri_001, TestSize.Level1)
365 {
366 std::string uri;
367 int32_t userId = DEFAULT_USERID;
368 ExtensionAbilityInfo extensionAbilityInfo;
369 auto ret = bundleMgrHelper->QueryExtensionAbilityInfoByUri(uri, userId, extensionAbilityInfo);
370 EXPECT_EQ(ret, false);
371 }
372
373 /**
374 * @tc.name: BundleMgrHelperTest_QueryAbilityInfoByUri_001
375 * @tc.desc: QueryAbilityInfoByUri
376 * @tc.type: FUNC
377 */
378 HWTEST_F(BundleMgrHelperTest, BundleMgrHelperTest_QueryAbilityInfoByUri_001, TestSize.Level1)
379 {
380 std::string abilityUri;
381 int32_t userId = DEFAULT_USERID;
382 AbilityInfo abilityInfo;
383 auto ret = bundleMgrHelper->QueryAbilityInfoByUri(abilityUri, userId, abilityInfo);
384 EXPECT_EQ(ret, false);
385 }
386
387 /**
388 * @tc.name: BundleMgrHelperTest_ImplicitQueryInfoByPriority_001
389 * @tc.desc: ImplicitQueryInfoByPriority
390 * @tc.type: FUNC
391 */
392 HWTEST_F(BundleMgrHelperTest, BundleMgrHelperTest_ImplicitQueryInfoByPriority_001, TestSize.Level1)
393 {
394 Want want;
395 int32_t flags = 0;
396 int32_t userId = DEFAULT_USERID;
397 AbilityInfo abilityInfo;
398 ExtensionAbilityInfo extensionInfo;
399 auto ret = bundleMgrHelper->ImplicitQueryInfoByPriority(want, flags, userId, abilityInfo, extensionInfo);
400 EXPECT_EQ(ret, false);
401 }
402
403 /**
404 * @tc.name: BundleMgrHelperTest_GetBundleInfos_002
405 * @tc.desc: GetBundleInfos
406 * @tc.type: FUNC
407 */
408 HWTEST_F(BundleMgrHelperTest, BundleMgrHelperTest_GetBundleInfos_002, TestSize.Level1)
409 {
410 int32_t flags = 0;
411 std::vector<BundleInfo> bundleInfos;
412 int32_t userId = DEFAULT_USERID;
413 auto ret = bundleMgrHelper->GetBundleInfos(flags, bundleInfos, userId);
414 EXPECT_EQ(ret, true);
415 }
416
417 /**
418 * @tc.name: BundleMgrHelperTest_GetHapModuleInfo_002
419 * @tc.desc: GetHapModuleInfo
420 * @tc.type: FUNC
421 */
422 HWTEST_F(BundleMgrHelperTest, BundleMgrHelperTest_GetHapModuleInfo_002, TestSize.Level1)
423 {
424 AbilityInfo abilityInfo;
425 int32_t userId = DEFAULT_USERID;
426 HapModuleInfo hapModuleInfo;
427 auto ret = bundleMgrHelper->GetHapModuleInfo(abilityInfo, userId, hapModuleInfo);
428 EXPECT_EQ(ret, false);
429 }
430
431 /**
432 * @tc.name: BundleMgrHelperTest_GetUidByBundleName_001
433 * @tc.desc: GetUidByBundleName
434 * @tc.type: FUNC
435 */
436 HWTEST_F(BundleMgrHelperTest, BundleMgrHelperTest_GetUidByBundleName_001, TestSize.Level1)
437 {
438 std::string bundleName;
439 int32_t userId = DEFAULT_USERID;
440 auto ret = bundleMgrHelper->GetUidByBundleName(bundleName, userId, 0);
441 EXPECT_EQ(ret, Constants::INVALID_UID);
442 }
443
444 /**
445 * @tc.name: BundleMgrHelperTest_GetApplicationInfo_002
446 * @tc.desc: GetApplicationInfo
447 * @tc.type: FUNC
448 */
449 HWTEST_F(BundleMgrHelperTest, BundleMgrHelperTest_GetApplicationInfo_002, TestSize.Level1)
450 {
451 std::string appName;
452 int32_t flags = 0;
453 int32_t userId = DEFAULT_USERID;
454 ApplicationInfo appInfo;
455 auto ret = bundleMgrHelper->GetApplicationInfo(appName, flags, userId, appInfo);
456 EXPECT_EQ(ret, false);
457 }
458
459 /**
460 * @tc.name: BundleMgrHelperTest_ProcessPreload_001
461 * @tc.desc: ProcessPreload
462 * @tc.type: FUNC
463 */
464 HWTEST_F(BundleMgrHelperTest, BundleMgrHelperTest_ProcessPreload_001, TestSize.Level1)
465 {
466 Want want;
467 auto ret = bundleMgrHelper->ProcessPreload(want);
468 EXPECT_EQ(ret, false);
469 }
470
471 /**
472 * @tc.name: BundleMgrHelperTest_UpgradeAtomicService_001
473 * @tc.desc: UpgradeAtomicService
474 * @tc.type: FUNC
475 */
476 HWTEST_F(BundleMgrHelperTest, BundleMgrHelperTest_UpgradeAtomicService_001, TestSize.Level1)
477 {
478 Want want;
479 int32_t userId = DEFAULT_USERID;
480 bundleMgrHelper->UpgradeAtomicService(want, userId);
481 EXPECT_NE(bundleMgrHelper->bundleMgr_, nullptr);
482 }
483
484 /**
485 * @tc.name: BundleMgrHelperTest_QueryAbilityInfo_003
486 * @tc.desc: QueryAbilityInfo
487 * @tc.type: FUNC
488 */
489 HWTEST_F(BundleMgrHelperTest, BundleMgrHelperTest_QueryAbilityInfo_003, TestSize.Level1)
490 {
491 Want want;
492 int32_t flags = DEFAULT_USERID;
493 int32_t userId = DEFAULT_USERID;
494 AbilityInfo abilityInfo;
495 auto ret = bundleMgrHelper->QueryAbilityInfo(want, flags, userId, abilityInfo);
496 EXPECT_EQ(ret, false);
497 }
498
499 /**
500 * @tc.name: BundleMgrHelperTest_GetDefaultAppProxy_001
501 * @tc.desc: GetDefaultAppProxy
502 * @tc.type: FUNC
503 */
504 HWTEST_F(BundleMgrHelperTest, BundleMgrHelperTest_GetDefaultAppProxy_001, TestSize.Level1)
505 {
506 auto ret = bundleMgrHelper->GetDefaultAppProxy();
507 EXPECT_NE(ret, nullptr);
508 }
509
510 #ifdef WITH_DLP
511 /**
512 * @tc.name: BundleMgrHelperTest_InstallSandboxApp_001
513 * @tc.desc: InstallSandboxApp
514 * @tc.type: FUNC
515 */
516 HWTEST_F(BundleMgrHelperTest, BundleMgrHelperTest_InstallSandboxApp_001, TestSize.Level1)
517 {
518 std::string bundleName = "";
519 int32_t dlpType = 1;
520 int32_t userId = 1;
521 int32_t appIndex = 1;
522 auto ret = bundleMgrHelper->InstallSandboxApp(bundleName, dlpType, userId, appIndex);
523 EXPECT_EQ(ret, ERR_APPEXECFWK_SANDBOX_INSTALL_PARAM_ERROR);
524 }
525
526 /**
527 * @tc.name: BundleMgrHelperTest_InstallSandboxApp_002
528 * @tc.desc: InstallSandboxApp
529 * @tc.type: FUNC
530 */
531 HWTEST_F(BundleMgrHelperTest, BundleMgrHelperTest_InstallSandboxApp_002, TestSize.Level1)
532 {
533 std::string bundleName = "bundleName";
534 int32_t dlpType = 1;
535 int32_t userId = 1;
536 int32_t appIndex = 1;
537 auto ret = bundleMgrHelper->InstallSandboxApp(bundleName, dlpType, userId, appIndex);
538 EXPECT_EQ(ret, ERR_COD1);
539 }
540 #endif // WITH_DLP
541
542 /**
543 * @tc.name: BundleMgrHelperTest_UninstallSandboxApp_001
544 * @tc.desc: UninstallSandboxApp
545 * @tc.type: FUNC
546 */
547 HWTEST_F(BundleMgrHelperTest, BundleMgrHelperTest_UninstallSandboxApp_001, TestSize.Level1)
548 {
549 std::string bundleName = "";
550 int32_t userId = 1;
551 int32_t appIndex = 1;
552 auto ret = bundleMgrHelper->UninstallSandboxApp(bundleName, userId, appIndex);
553 EXPECT_EQ(ret, ERR_APPEXECFWK_SANDBOX_INSTALL_PARAM_ERROR);
554 }
555
556 /**
557 * @tc.name: BundleMgrHelperTest_UninstallSandboxApp_002
558 * @tc.desc: UninstallSandboxApp
559 * @tc.type: FUNC
560 */
561 HWTEST_F(BundleMgrHelperTest, BundleMgrHelperTest_UninstallSandboxApp_002, TestSize.Level1)
562 {
563 std::string bundleName = "bundleName";
564 int32_t appIndex = 1;
565 int32_t userId = 1;
566 auto ret = bundleMgrHelper->UninstallSandboxApp(bundleName, appIndex, userId);
567 EXPECT_EQ(ret, ERR_APPEXECFWK_SANDBOX_INSTALL_PARAM_ERROR);
568 }
569
570 /**
571 * @tc.name: BundleMgrHelperTest_UninstallSandboxApp_003
572 * @tc.desc: UninstallSandboxApp
573 * @tc.type: FUNC
574 */
575 HWTEST_F(BundleMgrHelperTest, BundleMgrHelperTest_UninstallSandboxApp_003, TestSize.Level1)
576 {
577 std::string bundleName = "bundleName";
578 int32_t userId = 1;
579 int32_t appIndex = -1;
580 auto ret = bundleMgrHelper->UninstallSandboxApp(bundleName, userId, appIndex);
581 EXPECT_EQ(ret, ERR_COD3);
582 }
583
584 /**
585 * @tc.name: BundleMgrHelperTest_GetUninstalledBundleInfo_001
586 * @tc.desc: GetUninstalledBundleInfo
587 * @tc.type: FUNC
588 */
589 HWTEST_F(BundleMgrHelperTest, BundleMgrHelperTest_GetUninstalledBundleInfo_001, TestSize.Level1)
590 {
591 std::string bundleName = "bundleName";
592 BundleInfo bundleInfo;
593 auto ret = bundleMgrHelper->GetUninstalledBundleInfo(bundleName, bundleInfo);
594 EXPECT_EQ(ret, ERR_COD4);
595 }
596
597 /**
598 * @tc.name: BundleMgrHelperTest_GetSandboxBundleInfo_001
599 * @tc.desc: GetSandboxBundleInfo
600 * @tc.type: FUNC
601 */
602 HWTEST_F(BundleMgrHelperTest, BundleMgrHelperTest_GetSandboxBundleInfo_001, TestSize.Level1)
603 {
604 std::string bundleName = "bundleName";
605 int32_t appIndex = -1;
606 int32_t userId = 1;
607 BundleInfo bundleInfo;
608 auto ret = bundleMgrHelper->GetSandboxBundleInfo(bundleName, appIndex, userId, bundleInfo);
609 EXPECT_EQ(ret, ERR_APPEXECFWK_SANDBOX_INSTALL_PARAM_ERROR);
610 }
611
612 /**
613 * @tc.name: BundleMgrHelperTest_GetSandboxBundleInfo_002
614 * @tc.desc: GetSandboxBundleInfo
615 * @tc.type: FUNC
616 */
617 HWTEST_F(BundleMgrHelperTest, BundleMgrHelperTest_GetSandboxBundleInfo_002, TestSize.Level1)
618 {
619 std::string bundleName = "";
620 int32_t appIndex = 10;
621 int32_t userId = 1;
622 BundleInfo bundleInfo;
623 auto ret = bundleMgrHelper->GetSandboxBundleInfo(bundleName, appIndex, userId, bundleInfo);
624 EXPECT_EQ(ret, ERR_APPEXECFWK_SANDBOX_INSTALL_PARAM_ERROR);
625 }
626
627 /**
628 * @tc.name: BundleMgrHelperTest_GetSandboxAbilityInfo_001
629 * @tc.desc: GetSandboxAbilityInfo
630 * @tc.type: FUNC
631 */
632 HWTEST_F(BundleMgrHelperTest, BundleMgrHelperTest_GetSandboxAbilityInfo_001, TestSize.Level1)
633 {
634 Want want;
635 int32_t appIndex = 0;
636 int32_t flags = 1;
637 int32_t userId = 1;
638 AbilityInfo abilityInfo;
639 auto ret = bundleMgrHelper->GetSandboxAbilityInfo(want, appIndex, flags, userId, abilityInfo);
640 EXPECT_EQ(ret, ERR_APPEXECFWK_SANDBOX_INSTALL_PARAM_ERROR);
641 }
642
643 /**
644 * @tc.name: BundleMgrHelperTest_GetSandboxAbilityInfo_002
645 * @tc.desc: GetSandboxAbilityInfo
646 * @tc.type: FUNC
647 */
648 HWTEST_F(BundleMgrHelperTest, BundleMgrHelperTest_GetSandboxAbilityInfo_002, TestSize.Level1)
649 {
650 Want want;
651 int32_t appIndex = FIRST_APP_INDEX;
652 int32_t flags = 1;
653 int32_t userId = 1;
654 AbilityInfo abilityInfo;
655 auto ret = bundleMgrHelper->GetSandboxAbilityInfo(want, appIndex, flags, userId, abilityInfo);
656 EXPECT_EQ(ret, ERR_APPEXECFWK_SANDBOX_INSTALL_PARAM_ERROR);
657 }
658
659 /**
660 * @tc.name: BundleMgrHelperTest_GetSandboxAbilityInfo_003
661 * @tc.desc: GetSandboxAbilityInfo
662 * @tc.type: FUNC
663 */
664 HWTEST_F(BundleMgrHelperTest, BundleMgrHelperTest_GetSandboxAbilityInfo_003, TestSize.Level1)
665 {
666 Want want;
667 int32_t appIndex = SECOND_APP_INDEX;
668 int32_t flags = 1;
669 int32_t userId = 1;
670 AbilityInfo abilityInfo;
671 auto ret = bundleMgrHelper->GetSandboxAbilityInfo(want, appIndex, flags, userId, abilityInfo);
672 EXPECT_EQ(ret, ERR_COD5);
673 }
674
675 /**
676 * @tc.name: BundleMgrHelperTest_GetSandboxExtAbilityInfos_001
677 * @tc.desc: GetSandboxExtAbilityInfos
678 * @tc.type: FUNC
679 */
680 HWTEST_F(BundleMgrHelperTest, BundleMgrHelperTest_GetSandboxExtAbilityInfos_001, TestSize.Level1)
681 {
682 Want want;
683 int32_t appIndex = SECOND_APP_INDEX;
684 int32_t flags = 1;
685 int32_t userId = 1;
686 std::vector<ExtensionAbilityInfo> extensionInfos;
687 auto ret = bundleMgrHelper->GetSandboxExtAbilityInfos(want, appIndex, flags, userId, extensionInfos);
688 EXPECT_EQ(ret, ERR_COD5);
689 }
690
691 /**
692 * @tc.name: BundleMgrHelperTest_GetSandboxHapModuleInfo_001
693 * @tc.desc: GetSandboxHapModuleInfo
694 * @tc.type: FUNC
695 */
696 HWTEST_F(BundleMgrHelperTest, BundleMgrHelperTest_GetSandboxHapModuleInfo_001, TestSize.Level1)
697 {
698 AbilityInfo abilityInfo;
699 int32_t appIndex = 0;
700 int32_t userId = 1;
701 HapModuleInfo hapModuleInfo;
702 auto ret = bundleMgrHelper->GetSandboxHapModuleInfo(abilityInfo, appIndex, userId, hapModuleInfo);
703 EXPECT_EQ(ret, ERR_APPEXECFWK_SANDBOX_INSTALL_PARAM_ERROR);
704 }
705
706 /**
707 * @tc.name: BundleMgrHelperTest_GetSandboxHapModuleInfo_002
708 * @tc.desc: GetSandboxHapModuleInfo
709 * @tc.type: FUNC
710 */
711 HWTEST_F(BundleMgrHelperTest, BundleMgrHelperTest_GetSandboxHapModuleInfo_002, TestSize.Level1)
712 {
713 AbilityInfo abilityInfo;
714 int32_t appIndex = FIRST_APP_INDEX;
715 int32_t userId = 1;
716 HapModuleInfo hapModuleInfo;
717 auto ret = bundleMgrHelper->GetSandboxHapModuleInfo(abilityInfo, appIndex, userId, hapModuleInfo);
718 EXPECT_EQ(ret, ERR_APPEXECFWK_SANDBOX_INSTALL_PARAM_ERROR);
719 }
720
721 /**
722 * @tc.name: BundleMgrHelperTest_GetSandboxHapModuleInfo_003
723 * @tc.desc: GetSandboxHapModuleInfo
724 * @tc.type: FUNC
725 */
726 HWTEST_F(BundleMgrHelperTest, BundleMgrHelperTest_GetSandboxHapModuleInfo_003, TestSize.Level1)
727 {
728 AbilityInfo abilityInfo;
729 int32_t appIndex = SECOND_APP_INDEX;
730 int32_t userId = 1;
731 HapModuleInfo hapModuleInfo;
732 auto ret = bundleMgrHelper->GetSandboxHapModuleInfo(abilityInfo, appIndex, userId, hapModuleInfo);
733 EXPECT_EQ(ret, ERR_COD5);
734 }
735
736 /**
737 * @tc.name: BundleMgrHelperTest_ConnectBundleInstaller_001
738 * @tc.desc: ConnectBundleInstaller
739 * @tc.type: FUNC
740 */
741 HWTEST_F(BundleMgrHelperTest, BundleMgrHelperTest_ConnectBundleInstaller_001, TestSize.Level1)
742 {
743 bundleMgrHelper->OnDeath();
744 auto ret = bundleMgrHelper->ConnectBundleInstaller();
745 EXPECT_NE(ret, nullptr);
746 }
747
748 /**
749 * @tc.name: BundleMgrHelperTest_GetBundleInfoV9_001
750 * @tc.desc: GetBundleInfoV9
751 * @tc.type: FUNC
752 */
753 HWTEST_F(BundleMgrHelperTest, BundleMgrHelperTest_GetBundleInfoV9_001, TestSize.Level1)
754 {
755 std::string bundleName = "bundleName";
756 int32_t flags = 1;
757 BundleInfo bundleInfo;
758 int32_t userId = 1;
759 auto ret = bundleMgrHelper->GetBundleInfoV9(bundleName, flags, bundleInfo, userId);
760 EXPECT_EQ(ret, ERR_COD7);
761 }
762
763 /**
764 * @tc.name: QueryExtensionAbilityInfosOnlyWithTypeName_001
765 * @tc.desc: QueryExtensionAbilityInfosOnlyWithTypeName
766 * @tc.type: FUNC
767 */
768 HWTEST_F(BundleMgrHelperTest, QueryExtensionAbilityInfosOnlyWithTypeName_001, TestSize.Level1)
769 {
770 std::string extensionTypeName = "extensionTypeName";
771 uint32_t flag = 1;
772 int32_t userId = 1;
773 std::vector<ExtensionAbilityInfo> extensionInfos;
774 auto ret = bundleMgrHelper->QueryExtensionAbilityInfosOnlyWithTypeName(extensionTypeName,
775 flag, userId, extensionInfos);
776 EXPECT_EQ(ret, ERR_COD7);
777 }
778
779 /**
780 * @tc.name: GetJsonProfile_001
781 * @tc.desc: GetJsonProfile
782 * @tc.type: FUNC
783 */
784 HWTEST_F(BundleMgrHelperTest, GetJsonProfile_001, TestSize.Level1)
785 {
786 ProfileType profileType = AppExecFwk::PKG_CONTEXT_PROFILE;
787 std::string bundleName = "bundleName";
788 std::string moduleName = "moduleName";
789 std::string profile = "profile";
790 int32_t userId = 1;
791 auto ret = bundleMgrHelper->GetJsonProfile(profileType, bundleName, moduleName, profile, userId);
792 EXPECT_EQ(ret, ERR_COD7);
793 }
794
795 /**
796 * @tc.name: BundleMgrHelperTest_QueryCloneAbilityInfo_001
797 * @tc.desc: QueryCloneAbilityInfo
798 * @tc.type: FUNC
799 */
800 HWTEST_F(BundleMgrHelperTest, BundleMgrHelperTest_QueryCloneAbilityInfo_001, TestSize.Level1)
801 {
802 ElementName element;
803 AbilityInfo abilityInfo;
804 int32_t flags = ABILITY_INFO_FLAG;
805 int32_t appCloneIndex = 1;
806 int32_t userId = DEFAULT_USERID;
807 auto ret = bundleMgrHelper->QueryCloneAbilityInfo(element, flags, appCloneIndex, abilityInfo, userId);
808 EXPECT_NE(ret, ERR_OK);
809 }
810
811 /**
812 * @tc.name: BundleMgrHelperTest_GetCloneBundleInfo_001
813 * @tc.desc: GetCloneBundleInfo
814 * @tc.type: FUNC
815 */
816 HWTEST_F(BundleMgrHelperTest, BundleMgrHelperTest_GetCloneBundleInfo_001, TestSize.Level1)
817 {
818 std::string bundleName;
819 BundleInfo bundleInfo;
820 int32_t flags = 1;
821 int32_t appCloneIndex = 1;
822 int32_t userId = DEFAULT_USERID;
823 auto ret = bundleMgrHelper->GetCloneBundleInfo(bundleName, flags, appCloneIndex, bundleInfo, userId);
824 EXPECT_NE(ret, ERR_OK);
825 }
826
827 /**
828 * @tc.name: BundleMgrHelperTest_GetNameForUid_001
829 * @tc.desc: GetNameForUid
830 * @tc.type: FUNC
831 */
832 HWTEST_F(BundleMgrHelperTest, BundleMgrHelperTest_GetNameForUid_001, TestSize.Level1)
833 {
834 std::string name;
835 int32_t uid = 1;
836 auto ret = bundleMgrHelper->GetNameForUid(uid, name);
837 EXPECT_NE(ret, ERR_OK);
838 }
839
840 /**
841 * @tc.name: BundleMgrHelperTest_GetLaunchWantForBundle_001
842 * @tc.desc: GetLaunchWantForBundle
843 * @tc.type: FUNC
844 */
845 HWTEST_F(BundleMgrHelperTest, BundleMgrHelperTest_GetLaunchWantForBundle_001, TestSize.Level1)
846 {
847 std::string bundleName;
848 Want want;
849 int32_t userId = DEFAULT_USERID;
850 auto ret = bundleMgrHelper->GetLaunchWantForBundle(bundleName, want, userId);
851 EXPECT_NE(ret, ERR_OK);
852 }
853
854 /**
855 * @tc.name: BundleMgrHelperTest_GetSignatureInfoByBundleName_001
856 * @tc.desc: GetSignatureInfoByBundleName
857 * @tc.type: FUNC
858 */
859 HWTEST_F(BundleMgrHelperTest, BundleMgrHelperTest_GetSignatureInfoByBundleName_001, TestSize.Level1)
860 {
861 std::string bundleName;
862 SignatureInfo signatureInfo;
863 auto ret = bundleMgrHelper->GetSignatureInfoByBundleName(bundleName, signatureInfo);
864 EXPECT_NE(ret, ERR_OK);
865 }
866 } // namespace AppExecFwk
867 } // namespace OHOS