1 /*
2  * Copyright (c) 2021-2024 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 #define private public
16 
17 #include <fcntl.h>
18 #include <fstream>
19 #include <future>
20 #include <gtest/gtest.h>
21 
22 #include "accesstoken_kit.h"
23 #include "app_log_wrapper.h"
24 #include "bundle_constants.h"
25 #include "bundle_event_callback_host.h"
26 #include "bundle_installer_proxy.h"
27 #include "bundle_mgr_proxy.h"
28 #include "bundle_resource_info.h"
29 #include "bundle_resource_proxy.h"
30 #include "bundle_status_callback_host.h"
31 #include "bundle_pack_info.h"
32 #include "bundle_user_info.h"
33 #include "clean_cache_callback_host.h"
34 #include "common_tool.h"
35 #include "extension_ability_info.h"
36 #include "form_info.h"
37 #include "permission_define.h"
38 #include "iservice_registry.h"
39 #include "launcher_ability_resource_info.h"
40 #include "nativetoken_kit.h"
41 #include "nlohmann/json.hpp"
42 #include "status_receiver_host.h"
43 #include "system_ability_definition.h"
44 #include "testConfigParser.h"
45 #include "token_setproc.h"
46 
47 using OHOS::AAFwk::Want;
48 using namespace testing::ext;
49 using namespace std::chrono_literals;
50 
51 namespace {
52 const std::string THIRD_BUNDLE_PATH = "/data/test/bms_bundle/";
53 const std::string EMPTY_BUNDLE_NAME = "";
54 const std::string BASE_BUNDLE_NAME = "com.third.hiworld.example";
55 const std::string BASE_MODULE_NAME = "testability1";
56 const std::string BASE_ABILITY_NAME = "bmsThirdBundle_A1";
57 const std::string SYSTEM_SETTINGS_BUNDLE_NAME = "com.ohos.settings";
58 const std::string BUNDLE_DATA_ROOT_PATH = "/data/app/el2/100/base/";
59 const std::string ERROR_INSTALL_FAILED = "install failed!";
60 const std::string ERROR_UNINSTALL_FAILED = "uninstall failed!";
61 const std::string MSG_SUCCESS = "[SUCCESS]";
62 const std::string OPERATION_FAILED = "Failure";
63 const std::string OPERATION_SUCCESS = "Success";
64 const std::string APPID = "com.third.hiworld.example1_BNtg4JBClbl92Rgc3jm/"
65     "RfcAdrHXaM8F0QOiwVEhnV5ebE5jNIYnAx+weFRT3QTyUjRNdhmc2aAzWyi+5t5CoBM=";
66 const std::string FINGER_PRINT = "8E93863FC32EE238060BF69A9B37E2608FFFB21F93C862DD511CBAC9F30024B5";
67 const std::string BUNDLE25_APPID = "com.third.hiworld.example2_"
68     "BNtg4JBClbl92Rgc3jm/RfcAdrHXaM8F0QOiwVEhnV5ebE5jNIYnAx+weFRT3QTyUjRNdhmc2aAzWyi+5t5CoBM=";
69 const std::string DEFAULT_APP_BUNDLE_NAME = "com.test.defaultApp";
70 const std::string DEFAULT_APP_MODULE_NAME = "module01";
71 const std::string DEFAULT_APP_VIDEO = "VIDEO";
72 const std::string DEVICE_ID = "deviceID";
73 const std::string ROUTER_MAP_TEST_HAP = "/data/test/bms_bundle/hapIncludeso1.hap";
74 const std::string ROUTER_MAP_TEST_BUNDLE_NAME = "com.example.testhapso1";
75 const std::string ROUTER_INDEX_ZERO_URL = "DynamicPage1";
76 const std::string ROUTER_INDEX_ZERO_MDOULE_NAME = "entry";
77 const std::string ROUTER_INDEX_ZERO_PATH = "entry/src/index";
78 const std::string ROUTER_INDEX_ZERO_BUILD_FUNCTION = "myFunction";
79 const std::string ROUTER_INDEX_ONE_URL = "DynamicPage2";
80 const std::string ROUTER_INDEX_ONE_BUILD_FUNCTION = "myBuilder";
81 const std::string CONTROL_MESSAGE = "msg1_cantRun";
82 const std::string CURRENT_DEVICE_ID = "PHONE-001";
83 const std::string EMPTY_STRING = "";
84 const int COMPATIBLEVERSION = 3;
85 const int TARGETVERSION = 3;
86 const int32_t USERID = 100;
87 const int32_t RESID = 16777218;
88 const int32_t HUNDRED_USERID = 20010037;
89 const int32_t INVALIED_ID = -1;
90 const int32_t ZERO_SIZE = 0;
91 const int32_t PERMS_INDEX_ZERO = 0;
92 const int32_t PERMS_INDEX_ONE = 1;
93 const int32_t PERMS_INDEX_TWO = 2;
94 const int32_t PERMS_INDEX_THREE = 3;
95 const int32_t PERMS_INDEX_FORE = 4;
96 const int32_t PERMS_INDEX_FIVE = 5;
97 const int32_t PERMS_INDEX_SIX = 6;
98 const int32_t PERMS_INDEX_SEVEN = 7;
99 const int32_t PERMS_INDEX_EIGHT = 8;
100 const int32_t PERMS_INDEX_NINE = 9;
101 const size_t ODID_LENGTH = 36;
102 const int32_t TEST_INSTALLER_UID = 100;
103 const int32_t TEST_APP_INDEX1 = 1;
104 const int32_t TEST_APP_INDEX2 = 2;
105 }  // namespace
106 
107 namespace OHOS {
108 namespace AppExecFwk {
109 class BundleEventCallbackImpl : public BundleEventCallbackHost {
110 public:
111     BundleEventCallbackImpl();
112     virtual ~BundleEventCallbackImpl() override;
113     virtual void OnReceiveEvent(const EventFwk::CommonEventData eventData) override;
114 
115 private:
116     DISALLOW_COPY_AND_MOVE(BundleEventCallbackImpl);
117 };
118 
BundleEventCallbackImpl()119 BundleEventCallbackImpl::BundleEventCallbackImpl()
120 {
121     APP_LOGI("create bundle event instance");
122 }
123 
~BundleEventCallbackImpl()124 BundleEventCallbackImpl::~BundleEventCallbackImpl()
125 {
126     APP_LOGI("destroy bundle event instance");
127 }
128 
OnReceiveEvent(const EventFwk::CommonEventData eventData)129 void BundleEventCallbackImpl::OnReceiveEvent(const EventFwk::CommonEventData eventData)
130 {
131     const Want &want = eventData.GetWant();
132     std::string action = want.GetAction();
133     std::string bundleName = want.GetElement().GetBundleName();
134     std::cout << "action : " << action << std::endl;
135     std::cout << "bundleName : " << bundleName << std::endl;
136 }
137 
138 class BundleStatusCallbackImpl : public BundleStatusCallbackHost {
139 public:
140     BundleStatusCallbackImpl();
141     virtual ~BundleStatusCallbackImpl() override;
142     virtual void OnBundleStateChanged(const uint8_t installType, const int32_t resultCode, const std::string &resultMsg,
143         const std::string &bundleName) override;
OnBundleAdded(const std::string & bundleName,const int userId)144     virtual void OnBundleAdded(const std::string &bundleName, const int userId) override {};
OnBundleUpdated(const std::string & bundleName,const int userId)145     virtual void OnBundleUpdated(const std::string &bundleName, const int userId) override {};
OnBundleRemoved(const std::string & bundleName,const int userId)146     virtual void OnBundleRemoved(const std::string &bundleName, const int userId) override {};
147 
148 private:
149     DISALLOW_COPY_AND_MOVE(BundleStatusCallbackImpl);
150 };
151 
BundleStatusCallbackImpl()152 BundleStatusCallbackImpl::BundleStatusCallbackImpl()
153 {
154     APP_LOGI("create bundle status instance");
155 }
156 
~BundleStatusCallbackImpl()157 BundleStatusCallbackImpl::~BundleStatusCallbackImpl()
158 {
159     APP_LOGI("destroy bundle status instance");
160 }
161 
OnBundleStateChanged(const uint8_t installType,const int32_t resultCode,const std::string & resultMsg,const std::string & bundleName)162 void BundleStatusCallbackImpl::OnBundleStateChanged(
163     const uint8_t installType, const int32_t resultCode, const std::string &resultMsg, const std::string &bundleName)
164 {
165     APP_LOGI("BMS_Kit_St OnBundleStateChanged results are %{public}d, %{public}d, %{public}s, %{public}s",
166         installType,
167         resultCode,
168         resultMsg.c_str(),
169         bundleName.c_str());
170 }
171 
172 class CleanCacheCallBackImpl : public CleanCacheCallbackHost {
173 public:
174     CleanCacheCallBackImpl();
175     virtual ~CleanCacheCallBackImpl() override;
176 
177     virtual void OnCleanCacheFinished(bool succeeded) override;
178     bool GetSucceededResult() const;
179 
180 private:
181     mutable std::promise<bool> resultSucceededSignal_;
182     DISALLOW_COPY_AND_MOVE(CleanCacheCallBackImpl);
183 };
184 
CleanCacheCallBackImpl()185 CleanCacheCallBackImpl::CleanCacheCallBackImpl()
186 {
187     APP_LOGI("create bundle status instance");
188 }
189 
~CleanCacheCallBackImpl()190 CleanCacheCallBackImpl::~CleanCacheCallBackImpl()
191 {
192     APP_LOGI("destroy bundle status instance");
193 }
194 
OnCleanCacheFinished(bool succeeded)195 void CleanCacheCallBackImpl::OnCleanCacheFinished(bool succeeded)
196 {
197     APP_LOGI("BMS_Kit_St OnCleanCacheFinished results are %{public}d", succeeded);
198     resultSucceededSignal_.set_value(succeeded);
199 }
200 
GetSucceededResult() const201 bool CleanCacheCallBackImpl::GetSucceededResult() const
202 {
203     auto future = resultSucceededSignal_.get_future();
204     future.wait();
205     return future.get();
206 }
207 
208 class StatusReceiverImpl : public StatusReceiverHost {
209 public:
210     StatusReceiverImpl();
211     virtual ~StatusReceiverImpl();
212     virtual void OnStatusNotify(const int progress) override;
213     virtual void OnFinished(const int32_t resultCode, const std::string &resultMsg) override;
214     std::string GetResultMsg() const;
215 
216 private:
217     mutable std::promise<std::string> resultMsgSignal_;
218     int iProgress_ = 0;
219 
220     DISALLOW_COPY_AND_MOVE(StatusReceiverImpl);
221 };
222 
StatusReceiverImpl()223 StatusReceiverImpl::StatusReceiverImpl()
224 {
225     APP_LOGI("create status receiver instance");
226 }
227 
~StatusReceiverImpl()228 StatusReceiverImpl::~StatusReceiverImpl()
229 {
230     APP_LOGI("destroy status receiver instance");
231 }
232 
OnFinished(const int32_t resultCode,const std::string & resultMsg)233 void StatusReceiverImpl::OnFinished(const int32_t resultCode, const std::string &resultMsg)
234 {
235     APP_LOGD("OnFinished result is %{public}d, %{public}s", resultCode, resultMsg.c_str());
236     resultMsgSignal_.set_value(resultMsg);
237 }
OnStatusNotify(const int progress)238 void StatusReceiverImpl::OnStatusNotify(const int progress)
239 {
240     EXPECT_GT(progress, iProgress_);
241     iProgress_ = progress;
242     APP_LOGI("OnStatusNotify progress:%{public}d", progress);
243 }
244 
GetResultMsg() const245 std::string StatusReceiverImpl::GetResultMsg() const
246 {
247     auto future = resultMsgSignal_.get_future();
248     future.wait();
249     std::string resultMsg = future.get();
250     if (resultMsg == MSG_SUCCESS) {
251         return OPERATION_SUCCESS;
252     } else {
253         return OPERATION_FAILED + resultMsg;
254     }
255 }
256 
257 class ActsBmsKitSystemTest : public testing::Test {
258 public:
259     static void SetUpTestCase();
260     static void TearDownTestCase();
261     void SetUp();
262     void TearDown();
263     void StartProcess();
264     static void Install(
265         const std::string &bundleFilePath, const InstallFlag installFlag, std::vector<std::string> &resvec);
266     static void Install(
267         const std::string &bundleFilePath, const InstallParam &installParam, std::vector<std::string> &resvec);
268     static void Uninstall(const std::string &bundleName, std::vector<std::string> &resvec);
269     static void HapUninstall(
270         const std::string &bundleName, const std::string &modulePackage, std::vector<std::string> &resvec);
271     static sptr<BundleMgrProxy> GetBundleMgrProxy();
272     static sptr<IBundleInstaller> GetInstallerProxy();
273     void CheckBundleInfo(const uint32_t index, BundleInfo &bundleInfo) const;
274     void CheckBaseBundleInfo(uint32_t index, const BundleInfo &bundleInfo) const;
275     void CreateDir(const std::string &path) const;
276     void CheckFileExist(const std::string &bundleName) const;
277     void CheckFileExist(const std::string &bundleName, const std::string &modulePackage) const;
278     void CheckFileNonExist(const std::string &bundleName) const;
279     void CheckFileNonExist(const std::string &bundleName, const std::string &modulePackage) const;
280     static StressTestLevel stLevel_;
281 };
282 StressTestLevel ActsBmsKitSystemTest::stLevel_{};
283 
SetUpTestCase()284 void ActsBmsKitSystemTest::SetUpTestCase()
285 {
286     TestConfigParser tcp;
287     tcp.ParseFromFile4StressTest(STRESS_TEST_CONFIG_FILE_PATH, stLevel_);
288     std::cout << "stress test level : "
289               << "BMS : " << stLevel_.BMSLevel << std::endl;
290 }
291 
TearDownTestCase()292 void ActsBmsKitSystemTest::TearDownTestCase()
293 {
294     std::cout << "BmsInstallSystemTest TearDownTestCase" << std::endl;
295 }
296 
SetUp()297 void ActsBmsKitSystemTest::SetUp()
298 {}
299 
TearDown()300 void ActsBmsKitSystemTest::TearDown()
301 {}
302 
StartProcess()303 void ActsBmsKitSystemTest::StartProcess()
304 {
305     const int32_t permsNum = 10;
306     uint64_t tokenId;
307     const char *perms[permsNum];
308     perms[PERMS_INDEX_ZERO] = "ohos.permission.GET_DEFAULT_APPLICATION";
309     perms[PERMS_INDEX_ONE] = "ohos.permission.INSTALL_BUNDLE";
310     perms[PERMS_INDEX_TWO] = "ohos.permission.SET_DEFAULT_APPLICATION";
311     perms[PERMS_INDEX_THREE] = "ohos.permission.GET_INSTALLED_BUNDLE_LIST";
312     perms[PERMS_INDEX_FORE] = "ohos.permission.CHANGE_ABILITY_ENABLED_STATE";
313     perms[PERMS_INDEX_FIVE] = "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED";
314     perms[PERMS_INDEX_SIX] = "ohos.permission.CHANGE_BUNDLE_UNINSTALL_STATE";
315     perms[PERMS_INDEX_SEVEN] = "ohos.permission.INSTALL_CLONE_BUNDLE";
316     perms[PERMS_INDEX_EIGHT] = "ohos.permission.UNINSTALL_CLONE_BUNDLE";
317     perms[PERMS_INDEX_NINE] = "ohos.permission.LISTEN_BUNDLE_CHANGE";
318     NativeTokenInfoParams infoInstance = {
319         .dcapsNum = 0,
320         .permsNum = permsNum,
321         .aclsNum = 0,
322         .dcaps = NULL,
323         .perms = perms,
324         .acls = NULL,
325         .processName = "kit_system_test",
326         .aplStr = "system_core",
327     };
328     tokenId = GetAccessTokenId(&infoInstance);
329     SetSelfTokenID(tokenId);
330     OHOS::Security::AccessToken::AccessTokenKit::ReloadNativeTokenInfo();
331 }
332 
Install(const std::string & bundleFilePath,const InstallFlag installFlag,std::vector<std::string> & resvec)333 void ActsBmsKitSystemTest::Install(
334     const std::string &bundleFilePath, const InstallFlag installFlag, std::vector<std::string> &resvec)
335 {
336     sptr<IBundleInstaller> installerProxy = GetInstallerProxy();
337     if (!installerProxy) {
338         APP_LOGE("get bundle installer failed.");
339         resvec.push_back(ERROR_INSTALL_FAILED);
340         return;
341     }
342     InstallParam installParam;
343     installParam.installFlag = installFlag;
344     installParam.userId = USERID;
345     sptr<StatusReceiverImpl> statusReceiver = (new (std::nothrow) StatusReceiverImpl());
346     EXPECT_NE(statusReceiver, nullptr);
347     installerProxy->Install(bundleFilePath, installParam, statusReceiver);
348     resvec.push_back(statusReceiver->GetResultMsg());
349 }
350 
Install(const std::string & bundleFilePath,const InstallParam & installParam,std::vector<std::string> & resvec)351 void ActsBmsKitSystemTest::Install(
352     const std::string &bundleFilePath, const InstallParam &installParam, std::vector<std::string> &resvec)
353 {
354     sptr<IBundleInstaller> installerProxy = GetInstallerProxy();
355     if (!installerProxy) {
356         APP_LOGE("get bundle installer failed.");
357         resvec.push_back(ERROR_INSTALL_FAILED);
358         return;
359     }
360     sptr<StatusReceiverImpl> statusReceiver = (new (std::nothrow) StatusReceiverImpl());
361     EXPECT_NE(statusReceiver, nullptr);
362     installerProxy->Install(bundleFilePath, installParam, statusReceiver);
363     resvec.push_back(statusReceiver->GetResultMsg());
364 }
365 
Uninstall(const std::string & bundleName,std::vector<std::string> & resvec)366 void ActsBmsKitSystemTest::Uninstall(const std::string &bundleName, std::vector<std::string> &resvec)
367 {
368     sptr<IBundleInstaller> installerProxy = GetInstallerProxy();
369     if (!installerProxy) {
370         APP_LOGE("get bundle installer failed.");
371         resvec.push_back(ERROR_UNINSTALL_FAILED);
372         return;
373     }
374 
375     if (bundleName.empty()) {
376         APP_LOGE("bundelname is null.");
377         resvec.push_back(ERROR_UNINSTALL_FAILED);
378     } else {
379         InstallParam installParam;
380         installParam.userId = USERID;
381         sptr<StatusReceiverImpl> statusReceiver = (new (std::nothrow) StatusReceiverImpl());
382         EXPECT_NE(statusReceiver, nullptr);
383         installerProxy->Uninstall(bundleName, installParam, statusReceiver);
384         resvec.push_back(statusReceiver->GetResultMsg());
385     }
386 }
387 
HapUninstall(const std::string & bundleName,const std::string & modulePackage,std::vector<std::string> & resvec)388 void ActsBmsKitSystemTest::HapUninstall(
389     const std::string &bundleName, const std::string &modulePackage, std::vector<std::string> &resvec)
390 {
391     sptr<IBundleInstaller> installerProxy = GetInstallerProxy();
392     if (!installerProxy) {
393         APP_LOGE("get bundle installer failed.");
394         resvec.push_back(ERROR_UNINSTALL_FAILED);
395         return;
396     }
397 
398     if (bundleName.empty()) {
399         APP_LOGE("bundelname is null.");
400         resvec.push_back(ERROR_UNINSTALL_FAILED);
401     } else {
402         InstallParam installParam;
403         installParam.userId = USERID;
404         sptr<StatusReceiverImpl> statusReceiver = (new (std::nothrow) StatusReceiverImpl());
405         EXPECT_NE(statusReceiver, nullptr);
406         installerProxy->Uninstall(bundleName, modulePackage, installParam, statusReceiver);
407         resvec.push_back(statusReceiver->GetResultMsg());
408     }
409 }
410 
GetBundleMgrProxy()411 sptr<BundleMgrProxy> ActsBmsKitSystemTest::GetBundleMgrProxy()
412 {
413     sptr<ISystemAbilityManager> systemAbilityManager =
414         SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
415     if (!systemAbilityManager) {
416         APP_LOGE("fail to get system ability mgr.");
417         return nullptr;
418     }
419 
420     sptr<IRemoteObject> remoteObject = systemAbilityManager->GetSystemAbility(BUNDLE_MGR_SERVICE_SYS_ABILITY_ID);
421     if (!remoteObject) {
422         APP_LOGE("fail to get bundle manager proxy.");
423         return nullptr;
424     }
425 
426     APP_LOGI("get bundle manager proxy success.");
427     return iface_cast<BundleMgrProxy>(remoteObject);
428 }
429 
GetInstallerProxy()430 sptr<IBundleInstaller> ActsBmsKitSystemTest::GetInstallerProxy()
431 {
432     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
433     if (!bundleMgrProxy) {
434         APP_LOGE("bundle mgr proxy is nullptr.");
435         return nullptr;
436     }
437 
438     sptr<IBundleInstaller> installerProxy = bundleMgrProxy->GetBundleInstaller();
439     if (!installerProxy) {
440         APP_LOGE("fail to get bundle installer proxy.");
441         return nullptr;
442     }
443 
444     APP_LOGI("get bundle installer proxy success.");
445     return installerProxy;
446 }
447 
CheckFileExist(const std::string & bundleName) const448 void ActsBmsKitSystemTest::CheckFileExist(const std::string &bundleName) const
449 {
450     int bundleDataExist = access((BUNDLE_DATA_ROOT_PATH + bundleName).c_str(), F_OK);
451     EXPECT_EQ(bundleDataExist, 0) << "the bundle data dir doesn't exist: " << bundleName;
452 }
453 
CheckFileExist(const std::string & bundleName,const std::string & modulePackage) const454 void ActsBmsKitSystemTest::CheckFileExist(const std::string &bundleName, const std::string &modulePackage) const
455 {
456     int bundleDataExist = access((BUNDLE_DATA_ROOT_PATH + bundleName + "/" + modulePackage).c_str(), F_OK);
457     EXPECT_EQ(bundleDataExist, 0) << "the bundle data dir doesn't exist: " << bundleName;
458 }
459 
CheckFileNonExist(const std::string & bundleName) const460 void ActsBmsKitSystemTest::CheckFileNonExist(const std::string &bundleName) const
461 {
462     int bundleDataExist = access((BUNDLE_DATA_ROOT_PATH + bundleName).c_str(), F_OK);
463     EXPECT_NE(bundleDataExist, 0) << "the bundle data dir exists: " << bundleName;
464 }
465 
CheckFileNonExist(const std::string & bundleName,const std::string & modulePackage) const466 void ActsBmsKitSystemTest::CheckFileNonExist(const std::string &bundleName, const std::string &modulePackage) const
467 {
468     int bundleDataExist = access((BUNDLE_DATA_ROOT_PATH + bundleName + "/" + modulePackage).c_str(), F_OK);
469     EXPECT_NE(bundleDataExist, 0) << "the bundle data dir exists: " << bundleName;
470 }
471 
CheckBundleInfo(const uint32_t index,BundleInfo & bundleInfo) const472 void ActsBmsKitSystemTest::CheckBundleInfo(const uint32_t index, BundleInfo &bundleInfo) const
473 {
474     EXPECT_EQ(bundleInfo.name, BASE_BUNDLE_NAME + std::to_string(index));
475     EXPECT_GE(bundleInfo.uid, Constants::BASE_USER_RANGE);
476     EXPECT_EQ(bundleInfo.vendor, "example");
477     EXPECT_EQ(bundleInfo.versionCode, index);
478     std::string strVersion = std::to_string(index) + ".0";
479     EXPECT_EQ(bundleInfo.versionName, strVersion);
480     EXPECT_EQ(bundleInfo.jointUserId, "");
481     EXPECT_EQ(bundleInfo.compatibleVersion, COMPATIBLEVERSION);
482     EXPECT_EQ(bundleInfo.targetVersion, TARGETVERSION);
483     std::vector<AbilityInfo> abilities = bundleInfo.abilityInfos;
484     for (auto iter = abilities.begin(); iter != abilities.end(); iter++) {
485         EXPECT_EQ(iter->bundleName, BASE_BUNDLE_NAME + std::to_string(index));
486         EXPECT_EQ(iter->description, "");
487         EXPECT_EQ(iter->label, "bmsThirdBundle_A2 Ability");
488         EXPECT_EQ(iter->moduleName, "testability");
489         std::cout << "abilityInfo-moduleName:" << iter->moduleName << std::endl;
490         EXPECT_EQ(iter->uri, "");
491         EXPECT_EQ(iter->visible, true);
492         int iLaunchMode = (int)iter->launchMode;
493         EXPECT_EQ(iLaunchMode, 0);
494         int iOrientation = (int)iter->orientation;
495         EXPECT_EQ(iOrientation, 0);
496         int iType = (int)iter->type;
497         EXPECT_EQ(iType, 1);
498     }
499     ApplicationInfo applicationInfo = bundleInfo.applicationInfo;
500     EXPECT_EQ(applicationInfo.name, (BASE_BUNDLE_NAME + std::to_string(index)));
501     EXPECT_EQ(applicationInfo.supportedModes, 0);
502     for (auto appModuleInfo : applicationInfo.moduleInfos) {
503         std::cout << "applicationInfo-moduleName:" << appModuleInfo.moduleName << std::endl;
504         std::cout << "applicationInfo-moduleSourceDir:" << appModuleInfo.moduleSourceDir << std::endl;
505     }
506     std::cout << "applicationInfo-entryDir:" << applicationInfo.entryDir << std::endl;
507 }
508 
CheckBaseBundleInfo(uint32_t index,const BundleInfo & bundleInfo) const509 void ActsBmsKitSystemTest::CheckBaseBundleInfo(uint32_t index, const BundleInfo &bundleInfo) const
510 {
511     EXPECT_EQ(bundleInfo.name, BASE_BUNDLE_NAME + std::to_string(index));
512     EXPECT_EQ(bundleInfo.vendor, "example");
513     EXPECT_EQ(bundleInfo.versionCode, index);
514     std::string strVersion = std::to_string(index) + ".0";
515     EXPECT_EQ(bundleInfo.versionName, strVersion);
516     EXPECT_EQ(bundleInfo.jointUserId, "");
517     EXPECT_EQ(bundleInfo.targetVersion, TARGETVERSION);
518 }
519 
CreateDir(const std::string & path) const520 void ActsBmsKitSystemTest::CreateDir(const std::string &path) const
521 {
522     if (access(path.c_str(), F_OK) != 0) {
523         if (mkdir(path.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) != 0) {
524             APP_LOGE("CreateDir:%{private}s error", path.c_str());
525         }
526     }
527 }
528 
529 /**
530  * @tc.number: GetBundleInfo_0100
531  * @tc.name: test query bundle information
532  * @tc.desc: 1.under '/data/test/bms_bundle',there is a hap
533  *           2.install the hap
534  *           3.query bundleInfo
535  */
536 HWTEST_F(ActsBmsKitSystemTest, GetBundleInfo_0100, Function | MediumTest | Level1)
537 {
538     std::cout << "START GetBundleInfo_0100" << std::endl;
539     std::vector<std::string> resvec;
540     std::string bundleFilePath = THIRD_BUNDLE_PATH + "bmsThirdBundle24.hap";
541     std::string appName = BASE_BUNDLE_NAME + "1";
542     Install(bundleFilePath, InstallFlag::REPLACE_EXISTING, resvec);
543     CommonTool commonTool;
544     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
545     ASSERT_NE(bundleMgrProxy, nullptr);
546 
547     BundleInfo bundleInfo;
548     bool getInfoResult = bundleMgrProxy->GetBundleInfo(appName, 0, bundleInfo, USERID);
549     EXPECT_TRUE(getInfoResult);
550     CheckBundleInfo(1, bundleInfo);
551     resvec.clear();
552     Uninstall(appName, resvec);
553     std::string uninstallResult = commonTool.VectorToStr(resvec);
554     EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!";
555 
556     std::cout << "END GetBundleInfo_0100" << std::endl;
557 }
558 
559 /**
560  * @tc.number: GetBundleInfo_0200
561  * @tc.name: test query bundle information
562  * @tc.desc: 1.under '/data/test/bms_bundle',there is a hap
563  *           2.install the hap
564  *           3.query bundleInfo
565  */
566 HWTEST_F(ActsBmsKitSystemTest, GetBundleInfo_0200, Function | MediumTest | Level1)
567 {
568     std::cout << "START GetBundleInfo_0200" << std::endl;
569     std::vector<std::string> resvec;
570     std::string bundleFilePath = THIRD_BUNDLE_PATH + "bmsThirdBundle25.hap";
571     std::string appName = BASE_BUNDLE_NAME + "2";
572     Install(bundleFilePath, InstallFlag::REPLACE_EXISTING, resvec);
573     CommonTool commonTool;
574     std::string installResult = commonTool.VectorToStr(resvec);
575     EXPECT_EQ(installResult, "Success") << "install fail!";
576     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
577     ASSERT_NE(bundleMgrProxy, nullptr);
578 
579     BundleInfo bundleInfo;
580     bool getInfoResult =
581         bundleMgrProxy->GetBundleInfo(appName, BundleFlag::GET_BUNDLE_WITH_ABILITIES, bundleInfo, USERID);
582     EXPECT_TRUE(getInfoResult);
583     EXPECT_EQ(bundleInfo.name, appName);
584     resvec.clear();
585     Uninstall(appName, resvec);
586     std::string uninstallResult = commonTool.VectorToStr(resvec);
587     EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!";
588 
589     std::cout << "END GetBundleInfo_0200" << std::endl;
590 }
591 
592 /**
593  * @tc.number: GetBundleInfo_0300
594  * @tc.name: test query bundle information
595  * @tc.desc: 1.under '/data/test/bms_bundle',there is a hap
596  *           2.install the hap
597  *           3.query bundleInfo
598  */
599 HWTEST_F(ActsBmsKitSystemTest, GetBundleInfo_0300, Function | MediumTest | Level1)
600 {
601     std::cout << "START GetBundleInfo_0300" << std::endl;
602     std::vector<std::string> resvec;
603     std::string bundleFilePath = THIRD_BUNDLE_PATH + "bmsThirdBundle26.hap";
604     std::string appName = BASE_BUNDLE_NAME + "3";
605     Install(bundleFilePath, InstallFlag::REPLACE_EXISTING, resvec);
606 
607     CommonTool commonTool;
608     std::string installResult = commonTool.VectorToStr(resvec);
609     EXPECT_EQ(installResult, "Success") << "install fail!";
610     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
611     ASSERT_NE(bundleMgrProxy, nullptr);
612 
613     BundleInfo bundleInfo;
614     bool getInfoResult =
615         bundleMgrProxy->GetBundleInfo(appName, BundleFlag::GET_BUNDLE_WITH_ABILITIES, bundleInfo, USERID);
616     EXPECT_TRUE(getInfoResult);
617     EXPECT_EQ(bundleInfo.name, appName);
618     resvec.clear();
619     Uninstall(appName, resvec);
620     std::string uninstallResult = commonTool.VectorToStr(resvec);
621     EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!";
622     std::cout << "END GetBundleInfo_0300" << std::endl;
623 }
624 
625 /**
626  * @tc.number: GetBundleInfo_0500
627  * @tc.name: test query bundle information
628  * @tc.desc: 1.under '/data/test/bms_bundle',there is a hap
629  *           2.install the hap
630  *           3.query bundleInfo
631  */
632 HWTEST_F(ActsBmsKitSystemTest, GetBundleInfo_0500, Function | MediumTest | Level1)
633 {
634     std::cout << "START GetBundleInfo_0500" << std::endl;
635     bool result = false;
636     for (int i = 1; i <= stLevel_.BMSLevel; i++) {
637         std::vector<std::string> resvec;
638         std::string bundleFilePath = THIRD_BUNDLE_PATH + "bmsThirdBundle28.rpk";
639         std::string appName = BASE_BUNDLE_NAME + "5";
640         Install(bundleFilePath, InstallFlag::REPLACE_EXISTING, resvec);
641 
642         CommonTool commonTool;
643         std::string installResult = commonTool.VectorToStr(resvec);
644         EXPECT_EQ(installResult, "Failure[ERR_INSTALL_INVALID_HAP_NAME]");
645         sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
646         ASSERT_NE(bundleMgrProxy, nullptr);
647 
648         BundleInfo bundleInfo;
649         bool getInfoResult =
650             bundleMgrProxy->GetBundleInfo(appName, BundleFlag::GET_BUNDLE_WITH_ABILITIES, bundleInfo, USERID);
651         EXPECT_FALSE(getInfoResult);
652         if (getInfoResult) {
653             APP_LOGI("GetBundleInfo_0500 failed - cycle count: %{public}d", i);
654             break;
655         }
656         result = true;
657     }
658 
659     if (result && stLevel_.BMSLevel > 1) {
660         APP_LOGI("GetBundleInfo_0500 success - cycle count: %{public}d", stLevel_.BMSLevel);
661     }
662     EXPECT_TRUE(result);
663     std::cout << "END GetBundleInfo_0500" << std::endl;
664 }
665 
666 /**
667  * @tc.number: GetBundleInfo_0600
668  * @tc.name: test query bundle information
669  * @tc.desc: 1.under '/data/test/bms_bundle',there is a hap
670  *           2.install the hap
671  *           3.query bundleInfo with wrong appname
672  */
673 HWTEST_F(ActsBmsKitSystemTest, GetBundleInfo_0600, Function | MediumTest | Level2)
674 {
675     std::cout << "START GetBundleInfo_0600" << std::endl;
676     bool result = false;
677     for (int i = 1; i <= stLevel_.BMSLevel; i++) {
678         std::vector<std::string> resvec;
679         std::string bundleFilePath = THIRD_BUNDLE_PATH + "bmsThirdBundle1.hap";
680         std::string appName = BASE_BUNDLE_NAME + "1";
681         Install(bundleFilePath, InstallFlag::REPLACE_EXISTING, resvec);
682 
683         CommonTool commonTool;
684         std::string installResult = commonTool.VectorToStr(resvec);
685         EXPECT_EQ(installResult, "Success") << "install fail!";
686         sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
687         ASSERT_NE(bundleMgrProxy, nullptr);
688 
689         appName = BASE_BUNDLE_NAME + "e";
690         BundleInfo bundleInfo;
691         bool getInfoResult = bundleMgrProxy->GetBundleInfo(appName, BundleFlag::GET_BUNDLE_DEFAULT, bundleInfo, USERID);
692         EXPECT_FALSE(getInfoResult);
693         resvec.clear();
694         appName = BASE_BUNDLE_NAME + "1";
695         Uninstall(appName, resvec);
696         std::string uninstallResult = commonTool.VectorToStr(resvec);
697         EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!";
698 
699         if (getInfoResult) {
700             APP_LOGI("GetBundleInfo_0600 failed - cycle count: %{public}d", i);
701             break;
702         }
703         result = true;
704     }
705 
706     if (result && stLevel_.BMSLevel > 1) {
707         APP_LOGI("GetBundleInfo_0600 success - cycle count: %{public}d", stLevel_.BMSLevel);
708     }
709     EXPECT_TRUE(result);
710     std::cout << "END GetBundleInfo_0600" << std::endl;
711 }
712 
713 /**
714  * @tc.number: GetBundleInfo_0800
715  * @tc.name: test query bundle information
716  * @tc.desc: 1.under '/system/app/',there is a hap
717  *           2.install the hap
718  *           3.query bundleInfo
719  */
720 HWTEST_F(ActsBmsKitSystemTest, GetBundleInfo_0800, Function | MediumTest | Level1)
721 {
722     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
723     ASSERT_NE(bundleMgrProxy, nullptr);
724 
725     BundleInfo bundleInfo;
726     bool getInfoResult = bundleMgrProxy->GetBundleInfo("", BundleFlag::GET_BUNDLE_DEFAULT, bundleInfo, USERID);
727     EXPECT_FALSE(getInfoResult);
728 }
729 
730 /**
731  * @tc.number: GetBundleInfo_0900
732  * @tc.name: test query bundle information
733  * @tc.desc: 1.under '/system/app/',there is a hap
734  *           2.bundlename is null
735  *           3.query bundleInfo
736  */
737 HWTEST_F(ActsBmsKitSystemTest, GetBundleInfo_0900, Function | MediumTest | Level1)
738 {
739     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
740     ASSERT_NE(bundleMgrProxy, nullptr);
741 
742     BundleInfo bundleInfo;
743     int32_t flags = 1;
744     bool getInfoResult = bundleMgrProxy->GetBundleInfo("", flags, bundleInfo, USERID);
745     EXPECT_FALSE(getInfoResult);
746 }
747 
748 /**
749  * @tc.number: GetBundleInfo_1000
750  * @tc.name: test query bundle information
751  * @tc.desc: 1.install the hap that contains router map json profile
752  *           2.query bundleInfo
753  */
754 HWTEST_F(ActsBmsKitSystemTest, GetBundleInfo_1000, Function | MediumTest | Level1)
755 {
756     std::cout << "START GetBundleInfo_1000" << std::endl;
757     std::vector<std::string> resvec;
758     Install(ROUTER_MAP_TEST_HAP, InstallFlag::REPLACE_EXISTING, resvec);
759     CommonTool commonTool;
760     std::string installResult = commonTool.VectorToStr(resvec);
761     EXPECT_EQ(installResult, "Success") << "install fail!";
762     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
763     ASSERT_NE(bundleMgrProxy, nullptr);
764 
765     BundleInfo bundleInfo;
766     bool getInfoResult = bundleMgrProxy->GetBundleInfo(ROUTER_MAP_TEST_BUNDLE_NAME,
767         static_cast<int32_t>(BundleFlag::GET_BUNDLE_WITH_ROUTER_MAP), bundleInfo, USERID);
768     EXPECT_TRUE(getInfoResult);
769     ASSERT_FALSE(bundleInfo.hapModuleInfos.empty());
770     ASSERT_EQ(bundleInfo.hapModuleInfos[PERMS_INDEX_ZERO].routerArray.size(), PERMS_INDEX_TWO);
771     EXPECT_EQ(bundleInfo.hapModuleInfos[PERMS_INDEX_ZERO].routerArray[PERMS_INDEX_ZERO].name, ROUTER_INDEX_ZERO_URL);
772     EXPECT_EQ(bundleInfo.hapModuleInfos[PERMS_INDEX_ZERO].routerArray[PERMS_INDEX_ZERO].pageSourceFile,
773         ROUTER_INDEX_ZERO_PATH);
774     EXPECT_EQ(bundleInfo.hapModuleInfos[PERMS_INDEX_ZERO].routerArray[PERMS_INDEX_ZERO].buildFunction,
775         ROUTER_INDEX_ZERO_BUILD_FUNCTION);
776 
777     EXPECT_EQ(bundleInfo.hapModuleInfos[PERMS_INDEX_ZERO].routerArray[PERMS_INDEX_ONE].name, ROUTER_INDEX_ONE_URL);
778     EXPECT_EQ(bundleInfo.hapModuleInfos[PERMS_INDEX_ZERO].routerArray[PERMS_INDEX_ONE].pageSourceFile,
779         ROUTER_INDEX_ZERO_PATH);
780     EXPECT_EQ(bundleInfo.hapModuleInfos[PERMS_INDEX_ZERO].routerArray[PERMS_INDEX_ONE].buildFunction,
781         ROUTER_INDEX_ONE_BUILD_FUNCTION);
782     EXPECT_EQ(bundleInfo.hapModuleInfos[PERMS_INDEX_ZERO].routerArray[PERMS_INDEX_ONE].data.size(), 2);
783     resvec.clear();
784     Uninstall(ROUTER_MAP_TEST_BUNDLE_NAME, resvec);
785     std::string uninstallResult = commonTool.VectorToStr(resvec);
786     EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!";
787 
788     std::cout << "END GetBundleInfo_1000" << std::endl;
789 }
790 
791 /**
792  * @tc.number: GetBundleInfo_1100
793  * @tc.name: test query bundle information
794  * @tc.desc: 1.install the hap that does not contain router map json profile
795  *           2.query bundleInfo
796  */
797 HWTEST_F(ActsBmsKitSystemTest, GetBundleInfo_1100, Function | MediumTest | Level1)
798 {
799     std::cout << "START GetBundleInfo_1100" << std::endl;
800     std::vector<std::string> resvec;
801     std::string bundleFilePath = THIRD_BUNDLE_PATH + "bmsThirdBundle24.hap";
802     std::string appName = BASE_BUNDLE_NAME + "1";
803     Install(bundleFilePath, InstallFlag::REPLACE_EXISTING, resvec);
804     CommonTool commonTool;
805     std::string installResult = commonTool.VectorToStr(resvec);
806     EXPECT_EQ(installResult, "Success") << "install fail!";
807     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
808     ASSERT_NE(bundleMgrProxy, nullptr);
809 
810     BundleInfo bundleInfo;
811     bool getInfoResult = bundleMgrProxy->GetBundleInfo(appName,
812         static_cast<int32_t>(BundleFlag::GET_BUNDLE_WITH_ROUTER_MAP), bundleInfo, USERID);
813     EXPECT_TRUE(getInfoResult);
814     ASSERT_FALSE(bundleInfo.hapModuleInfos.empty());
815     EXPECT_TRUE(bundleInfo.hapModuleInfos[PERMS_INDEX_ZERO].routerArray.empty());
816     resvec.clear();
817     Uninstall(appName, resvec);
818     std::string uninstallResult = commonTool.VectorToStr(resvec);
819     EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!";
820 
821     std::cout << "END GetBundleInfo_1100" << std::endl;
822 }
823 
824 /**
825  * @tc.number: GetBundleInfoV9_0010
826  * @tc.name: test query bundle information
827  * @tc.desc: 1.under '/data/test/bms_bundle',there is a hap
828  *           2.install the hap
829  *           3.query bundleInfo failed for wrong BundleName
830  */
831 HWTEST_F(ActsBmsKitSystemTest, GetBundleInfoV9_0010, Function | MediumTest | Level1)
832 {
833     std::cout << "START GetBundleInfoV9_0010" << std::endl;
834     std::vector<std::string> resvec;
835     std::string bundleFilePath = THIRD_BUNDLE_PATH + "bmsThirdBundle1.hap";
836     std::string appName = BASE_BUNDLE_NAME + "1";
837     Install(bundleFilePath, InstallFlag::REPLACE_EXISTING, resvec);
838     CommonTool commonTool;
839     std::string installResult = commonTool.VectorToStr(resvec);
840     EXPECT_EQ(installResult, "Success") << "install fail!";
841     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
842     ASSERT_NE(bundleMgrProxy, nullptr);
843 
844     BundleInfo bundleInfo;
845     auto getInfoResult = bundleMgrProxy->GetBundleInfoV9("",
846         static_cast<int32_t>(GetBundleInfoFlag::GET_BUNDLE_INFO_DEFAULT), bundleInfo, USERID);
847     EXPECT_EQ(getInfoResult, ERR_BUNDLE_MANAGER_BUNDLE_NOT_EXIST);
848     resvec.clear();
849     Uninstall(appName, resvec);
850     std::string uninstallResult = commonTool.VectorToStr(resvec);
851     EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!";
852 
853     std::cout << "END GetBundleInfoV9_0010" << std::endl;
854 }
855 
856 /**
857  * @tc.number: GetBundleInfoV9_0011
858  * @tc.name: test query bundle information
859  * @tc.desc: 1.under '/data/test/bms_bundle',there is a hap
860  *           2.install the hap
861  *           3.query bundleInfo failed for wrong UserId
862  */
863 HWTEST_F(ActsBmsKitSystemTest, GetBundleInfoV9_0011, Function | MediumTest | Level1)
864 {
865     std::cout << "START GetBundleInfoV9_0011" << std::endl;
866     std::vector<std::string> resvec;
867     std::string bundleFilePath = THIRD_BUNDLE_PATH + "bmsThirdBundle24.hap";
868     std::string appName = BASE_BUNDLE_NAME + "1";
869     Install(bundleFilePath, InstallFlag::REPLACE_EXISTING, resvec);
870     CommonTool commonTool;
871     std::string installResult = commonTool.VectorToStr(resvec);
872     EXPECT_EQ(installResult, "Success") << "install fail!";
873     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
874     ASSERT_NE(bundleMgrProxy, nullptr);
875 
876     BundleInfo bundleInfo;
877     auto getInfoResult = bundleMgrProxy->GetBundleInfoV9(appName,
878         static_cast<int32_t>(GetBundleInfoFlag::GET_BUNDLE_INFO_DEFAULT), bundleInfo, 99);
879     EXPECT_EQ(getInfoResult, ERR_BUNDLE_MANAGER_INVALID_USER_ID);
880     resvec.clear();
881     Uninstall(appName, resvec);
882     std::string uninstallResult = commonTool.VectorToStr(resvec);
883     EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!";
884 
885     std::cout << "END GetBundleInfoV9_0011" << std::endl;
886 }
887 
888 /**
889  * @tc.number: GetBundleInfoV9_0012
890  * @tc.name: test query bundle information
891  * @tc.desc: 1.under '/data/test/bms_bundle',there is a hap
892  *           2.install the hap
893  *           3.query default bundleInfo successfully
894  */
895 HWTEST_F(ActsBmsKitSystemTest, GetBundleInfoV9_0012, Function | MediumTest | Level1)
896 {
897     std::cout << "START GetBundleInfoV9_0012" << std::endl;
898     std::vector<std::string> resvec;
899     std::string bundleFilePath = THIRD_BUNDLE_PATH + "bmsThirdBundle24.hap";
900     std::string appName = BASE_BUNDLE_NAME + "1";
901     Install(bundleFilePath, InstallFlag::REPLACE_EXISTING, resvec);
902     CommonTool commonTool;
903     std::string installResult = commonTool.VectorToStr(resvec);
904     EXPECT_EQ(installResult, "Success") << "install fail!";
905     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
906     ASSERT_NE(bundleMgrProxy, nullptr);
907 
908     BundleInfo bundleInfo;
909     auto getInfoResult = bundleMgrProxy->GetBundleInfoV9(appName,
910         static_cast<int32_t>(GetBundleInfoFlag::GET_BUNDLE_INFO_DEFAULT), bundleInfo, USERID);
911     EXPECT_EQ(getInfoResult, ERR_OK);
912     CheckBaseBundleInfo(1, bundleInfo);
913     resvec.clear();
914     Uninstall(appName, resvec);
915     std::string uninstallResult = commonTool.VectorToStr(resvec);
916     EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!";
917 
918     std::cout << "END GetBundleInfoV9_0012" << std::endl;
919 }
920 
921 /**
922  * @tc.number: GetBundleInfoV9_0013
923  * @tc.name: test query bundle information
924  * @tc.desc: 1.under '/data/test/bms_bundle',there is a hap
925  *           2.install the hap
926  *           3.query default bundleInfo and applicationInfo successfully
927  */
928 HWTEST_F(ActsBmsKitSystemTest, GetBundleInfoV9_0013, Function | MediumTest | Level1)
929 {
930     std::cout << "START GetBundleInfoV9_0013" << std::endl;
931     std::vector<std::string> resvec;
932     std::string bundleFilePath = THIRD_BUNDLE_PATH + "bmsThirdBundle24.hap";
933     std::string appName = BASE_BUNDLE_NAME + "1";
934     Install(bundleFilePath, InstallFlag::REPLACE_EXISTING, resvec);
935     CommonTool commonTool;
936     std::string installResult = commonTool.VectorToStr(resvec);
937     EXPECT_EQ(installResult, "Success") << "install fail!";
938     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
939     ASSERT_NE(bundleMgrProxy, nullptr);
940 
941     BundleInfo bundleInfo;
942     auto getInfoResult = bundleMgrProxy->GetBundleInfoV9(appName,
943         static_cast<int32_t>(GetBundleInfoFlag::GET_BUNDLE_INFO_WITH_APPLICATION), bundleInfo, USERID);
944     EXPECT_EQ(getInfoResult, ERR_OK);
945     CheckBaseBundleInfo(1, bundleInfo);
946     EXPECT_EQ(bundleInfo.applicationInfo.name, appName);
947     resvec.clear();
948     Uninstall(appName, resvec);
949     std::string uninstallResult = commonTool.VectorToStr(resvec);
950     EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!";
951 
952     std::cout << "END GetBundleInfoV9_0013" << std::endl;
953 }
954 
955 /**
956  * @tc.number: GetBundleInfoV9_0014
957  * @tc.name: test query bundle information
958  * @tc.desc: 1.under '/data/test/bms_bundle',there is a hap
959  *           2.install the hap
960  *           3.query default bundleInfo and hapModuleInfos successfully
961  */
962 HWTEST_F(ActsBmsKitSystemTest, GetBundleInfoV9_0014, Function | MediumTest | Level1)
963 {
964     std::cout << "START GetBundleInfoV9_0014" << std::endl;
965     std::vector<std::string> resvec;
966     std::string bundleFilePath = THIRD_BUNDLE_PATH + "bmsThirdBundle24.hap";
967     std::string appName = BASE_BUNDLE_NAME + "1";
968     Install(bundleFilePath, InstallFlag::REPLACE_EXISTING, resvec);
969     CommonTool commonTool;
970     std::string installResult = commonTool.VectorToStr(resvec);
971     EXPECT_EQ(installResult, "Success") << "install fail!";
972     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
973     ASSERT_NE(bundleMgrProxy, nullptr);
974 
975     BundleInfo bundleInfo;
976     auto getInfoResult = bundleMgrProxy->GetBundleInfoV9(appName,
977         static_cast<int32_t>(GetBundleInfoFlag::GET_BUNDLE_INFO_WITH_HAP_MODULE), bundleInfo, USERID);
978     EXPECT_EQ(getInfoResult, ERR_OK);
979     CheckBaseBundleInfo(1, bundleInfo);
980     EXPECT_FALSE(bundleInfo.hapModuleInfos.empty());
981     resvec.clear();
982     Uninstall(appName, resvec);
983     std::string uninstallResult = commonTool.VectorToStr(resvec);
984     EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!";
985 
986     std::cout << "END GetBundleInfoV9_0014" << std::endl;
987 }
988 
989 /**
990  * @tc.number: GetBundleInfoV9_0015
991  * @tc.name: test query bundle information
992  * @tc.desc: 1.under '/data/test/bms_bundle',there is a hap
993  *           2.install the hap
994  *           3.get abilityInfo successfully
995  */
996 HWTEST_F(ActsBmsKitSystemTest, GetBundleInfoV9_0015, Function | MediumTest | Level1)
997 {
998     std::cout << "START GetBundleInfoV9_0015" << std::endl;
999     std::vector<std::string> resvec;
1000     std::string bundleFilePath = THIRD_BUNDLE_PATH + "bmsThirdBundle24.hap";
1001     std::string appName = BASE_BUNDLE_NAME + "1";
1002     Install(bundleFilePath, InstallFlag::REPLACE_EXISTING, resvec);
1003     CommonTool commonTool;
1004     std::string installResult = commonTool.VectorToStr(resvec);
1005     EXPECT_EQ(installResult, "Success") << "install fail!";
1006     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
1007     ASSERT_NE(bundleMgrProxy, nullptr);
1008 
1009     BundleInfo bundleInfo;
1010     auto getInfoResult = bundleMgrProxy->GetBundleInfoV9(appName,
1011         static_cast<int32_t>(GetBundleInfoFlag::GET_BUNDLE_INFO_WITH_HAP_MODULE) |
1012         static_cast<int32_t>(GetBundleInfoFlag::GET_BUNDLE_INFO_WITH_ABILITY), bundleInfo, USERID);
1013     EXPECT_EQ(getInfoResult, ERR_OK);
1014     CheckBaseBundleInfo(1, bundleInfo);
1015     EXPECT_FALSE(bundleInfo.hapModuleInfos.empty());
1016     resvec.clear();
1017     Uninstall(appName, resvec);
1018     std::string uninstallResult = commonTool.VectorToStr(resvec);
1019     EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!";
1020 
1021     std::cout << "END GetBundleInfoV9_0015" << std::endl;
1022 }
1023 
1024 /**
1025  * @tc.number: GetBundleInfoV9_0016
1026  * @tc.name: test query bundle information
1027  * @tc.desc: 1.under '/data/test/bms_bundle',there is a hap
1028  *           2.install the hap
1029  *           3.get extensionInfos successfully
1030  */
1031 HWTEST_F(ActsBmsKitSystemTest, GetBundleInfoV9_0016, Function | MediumTest | Level1)
1032 {
1033     std::cout << "START GetBundleInfoV9_0016" << std::endl;
1034     std::vector<std::string> resvec;
1035     std::string bundleFilePath = THIRD_BUNDLE_PATH + "bundleClient1.hap";
1036     std::string appName = "com.example.ohosproject.hmservice";
1037     Install(bundleFilePath, InstallFlag::REPLACE_EXISTING, resvec);
1038     CommonTool commonTool;
1039     std::string installResult = commonTool.VectorToStr(resvec);
1040     EXPECT_EQ(installResult, "Success") << "install fail!";
1041     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
1042     ASSERT_NE(bundleMgrProxy, nullptr);
1043 
1044     BundleInfo bundleInfo;
1045     auto getInfoResult = bundleMgrProxy->GetBundleInfoV9(appName,
1046         static_cast<int32_t>(GetBundleInfoFlag::GET_BUNDLE_INFO_WITH_HAP_MODULE) |
1047         static_cast<int32_t>(GetBundleInfoFlag::GET_BUNDLE_INFO_WITH_EXTENSION_ABILITY), bundleInfo, USERID);
1048     EXPECT_EQ(getInfoResult, ERR_OK);
1049     EXPECT_EQ(bundleInfo.name, appName);
1050     EXPECT_FALSE(bundleInfo.hapModuleInfos.empty());
1051     EXPECT_FALSE(bundleInfo.hapModuleInfos[0].appEnvironments.empty());
1052     resvec.clear();
1053     Uninstall(appName, resvec);
1054     std::string uninstallResult = commonTool.VectorToStr(resvec);
1055     EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!";
1056 
1057     std::cout << "END GetBundleInfoV9_0016" << std::endl;
1058 }
1059 
1060 /**
1061  * @tc.number: GetBundleInfoV9_0017
1062  * @tc.name: test query bundle information
1063  * @tc.desc: 1.under '/data/test/bms_bundle',there is a hap
1064  *           2.install the hap
1065  *           3.get reqPermissions, defPermissions and reqPermissionDetails successfully
1066  */
1067 HWTEST_F(ActsBmsKitSystemTest, GetBundleInfoV9_0017, Function | MediumTest | Level1)
1068 {
1069     std::cout << "START GetBundleInfoV9_0017" << std::endl;
1070     std::vector<std::string> resvec;
1071     std::string bundleFilePath = THIRD_BUNDLE_PATH + "bundleClient1.hap";
1072     std::string appName = "com.example.ohosproject.hmservice";
1073     Install(bundleFilePath, InstallFlag::REPLACE_EXISTING, resvec);
1074     CommonTool commonTool;
1075     std::string installResult = commonTool.VectorToStr(resvec);
1076     EXPECT_EQ(installResult, "Success") << "install fail!";
1077     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
1078     ASSERT_NE(bundleMgrProxy, nullptr);
1079 
1080     BundleInfo bundleInfo;
1081     auto getInfoResult = bundleMgrProxy->GetBundleInfoV9(appName,
1082         static_cast<int32_t>(GetBundleInfoFlag::GET_BUNDLE_INFO_WITH_REQUESTED_PERMISSION), bundleInfo, USERID);
1083     EXPECT_EQ(getInfoResult, ERR_OK);
1084     EXPECT_EQ(bundleInfo.name, appName);
1085     EXPECT_GT(bundleInfo.reqPermissions.size(), 0);
1086     resvec.clear();
1087     Uninstall(appName, resvec);
1088     std::string uninstallResult = commonTool.VectorToStr(resvec);
1089     EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!";
1090 
1091     std::cout << "END GetBundleInfoV9_0017" << std::endl;
1092 }
1093 
1094 /**
1095  * @tc.number: GetBundleInfoV9_0018
1096  * @tc.name: test query bundle information
1097  * @tc.desc: 1.under '/data/test/bms_bundle',there is a hap
1098  *           2.install the hap
1099  *           3.get applicationInfo which contain metadata successfully
1100  */
1101 HWTEST_F(ActsBmsKitSystemTest, GetBundleInfoV9_0018, Function | MediumTest | Level1)
1102 {
1103     std::cout << "START GetBundleInfoV9_0018" << std::endl;
1104     std::vector<std::string> resvec;
1105     std::string bundleFilePath = THIRD_BUNDLE_PATH + "bundleClient1.hap";
1106     std::string appName = "com.example.ohosproject.hmservice";
1107     Install(bundleFilePath, InstallFlag::REPLACE_EXISTING, resvec);
1108     CommonTool commonTool;
1109     std::string installResult = commonTool.VectorToStr(resvec);
1110     EXPECT_EQ(installResult, "Success") << "install fail!";
1111     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
1112     ASSERT_NE(bundleMgrProxy, nullptr);
1113 
1114     BundleInfo bundleInfo;
1115     auto getInfoResult = bundleMgrProxy->GetBundleInfoV9(appName,
1116         static_cast<int32_t>(GetBundleInfoFlag::GET_BUNDLE_INFO_WITH_APPLICATION) |
1117         static_cast<int32_t>(GetBundleInfoFlag::GET_BUNDLE_INFO_WITH_METADATA), bundleInfo, USERID);
1118     EXPECT_EQ(getInfoResult, ERR_OK);
1119     EXPECT_EQ(bundleInfo.name, appName);
1120     EXPECT_EQ(bundleInfo.applicationInfo.name, appName);
1121     EXPECT_FALSE(bundleInfo.applicationInfo.metadata.empty());
1122     EXPECT_FALSE(bundleInfo.applicationInfo.appEnvironments.empty());
1123     resvec.clear();
1124     Uninstall(appName, resvec);
1125     std::string uninstallResult = commonTool.VectorToStr(resvec);
1126     EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!";
1127 
1128     std::cout << "END GetBundleInfoV9_0018" << std::endl;
1129 }
1130 
1131 /**
1132  * @tc.number: GetBundleInfoV9_0019
1133  * @tc.name: test query bundle information
1134  * @tc.desc: 1.under '/data/test/bms_bundle',there is a hap
1135  *           2.install the hap
1136  *           3.get hapModuleInfos which contain metadata successfully
1137  */
1138 HWTEST_F(ActsBmsKitSystemTest, GetBundleInfoV9_0019, Function | MediumTest | Level1)
1139 {
1140     std::cout << "START GetBundleInfoV9_0019" << std::endl;
1141     std::vector<std::string> resvec;
1142     std::string bundleFilePath = THIRD_BUNDLE_PATH + "bundleClient1.hap";
1143     std::string appName = "com.example.ohosproject.hmservice";
1144     Install(bundleFilePath, InstallFlag::REPLACE_EXISTING, resvec);
1145     CommonTool commonTool;
1146     std::string installResult = commonTool.VectorToStr(resvec);
1147     EXPECT_EQ(installResult, "Success") << "install fail!";
1148     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
1149     ASSERT_NE(bundleMgrProxy, nullptr);
1150 
1151     BundleInfo bundleInfo;
1152     auto getInfoResult = bundleMgrProxy->GetBundleInfoV9(appName,
1153         static_cast<int32_t>(GetBundleInfoFlag::GET_BUNDLE_INFO_WITH_HAP_MODULE) |
1154         static_cast<int32_t>(GetBundleInfoFlag::GET_BUNDLE_INFO_WITH_METADATA), bundleInfo, USERID);
1155     EXPECT_EQ(getInfoResult, ERR_OK);
1156     EXPECT_EQ(bundleInfo.name, appName);
1157     resvec.clear();
1158     Uninstall(appName, resvec);
1159     std::string uninstallResult = commonTool.VectorToStr(resvec);
1160     EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!";
1161 
1162     std::cout << "END GetBundleInfoV9_0019" << std::endl;
1163 }
1164 
1165 /**
1166  * @tc.number: GetBundleInfoV9_0020
1167  * @tc.name: test query bundle information
1168  * @tc.desc: 1.under '/data/test/bms_bundle',there is a hap
1169  *           2.install the hap
1170  *           3.get abilityInfo which contain metadata successfully
1171  */
1172 HWTEST_F(ActsBmsKitSystemTest, GetBundleInfoV9_0020, Function | MediumTest | Level1)
1173 {
1174     std::cout << "START GetBundleInfoV9_0020" << std::endl;
1175     std::vector<std::string> resvec;
1176     std::string bundleFilePath = THIRD_BUNDLE_PATH + "bundleClient1.hap";
1177     std::string appName = "com.example.ohosproject.hmservice";
1178     Install(bundleFilePath, InstallFlag::REPLACE_EXISTING, resvec);
1179     CommonTool commonTool;
1180     std::string installResult = commonTool.VectorToStr(resvec);
1181     EXPECT_EQ(installResult, "Success") << "install fail!";
1182     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
1183     ASSERT_NE(bundleMgrProxy, nullptr);
1184 
1185     BundleInfo bundleInfo;
1186     auto getInfoResult = bundleMgrProxy->GetBundleInfoV9(appName,
1187         static_cast<int32_t>(GetBundleInfoFlag::GET_BUNDLE_INFO_WITH_HAP_MODULE) |
1188         static_cast<int32_t>(GetBundleInfoFlag::GET_BUNDLE_INFO_WITH_ABILITY) |
1189         static_cast<int32_t>(GetBundleInfoFlag::GET_BUNDLE_INFO_WITH_METADATA), bundleInfo, USERID);
1190     EXPECT_EQ(getInfoResult, ERR_OK);
1191     EXPECT_EQ(bundleInfo.name, appName);
1192     resvec.clear();
1193     Uninstall(appName, resvec);
1194     std::string uninstallResult = commonTool.VectorToStr(resvec);
1195     EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!";
1196 
1197     std::cout << "END GetBundleInfoV9_0020" << std::endl;
1198 }
1199 
1200 /**
1201  * @tc.number: GetBundleInfoV9_0021
1202  * @tc.name: test query bundle information
1203  * @tc.desc: 1.under '/data/test/bms_bundle',there is a hap
1204  *           2.install the hap
1205  *           3.get extensionInfos which contain metadata successfully
1206  */
1207 HWTEST_F(ActsBmsKitSystemTest, GetBundleInfoV9_0021, Function | MediumTest | Level1)
1208 {
1209     std::cout << "START GetBundleInfoV9_0021" << std::endl;
1210     std::vector<std::string> resvec;
1211     std::string bundleFilePath = THIRD_BUNDLE_PATH + "bundleClient1.hap";
1212     std::string appName = "com.example.ohosproject.hmservice";
1213     Install(bundleFilePath, InstallFlag::REPLACE_EXISTING, resvec);
1214     CommonTool commonTool;
1215     std::string installResult = commonTool.VectorToStr(resvec);
1216     EXPECT_EQ(installResult, "Success") << "install fail!";
1217     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
1218     ASSERT_NE(bundleMgrProxy, nullptr);
1219 
1220     BundleInfo bundleInfo;
1221     auto getInfoResult = bundleMgrProxy->GetBundleInfoV9(appName,
1222         static_cast<int32_t>(GetBundleInfoFlag::GET_BUNDLE_INFO_WITH_HAP_MODULE) |
1223         static_cast<int32_t>(GetBundleInfoFlag::GET_BUNDLE_INFO_WITH_EXTENSION_ABILITY) |
1224         static_cast<int32_t>(GetBundleInfoFlag::GET_BUNDLE_INFO_WITH_METADATA), bundleInfo, USERID);
1225     EXPECT_EQ(getInfoResult, ERR_OK);
1226     EXPECT_EQ(bundleInfo.name, appName);
1227     resvec.clear();
1228     Uninstall(appName, resvec);
1229     std::string uninstallResult = commonTool.VectorToStr(resvec);
1230     EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!";
1231 
1232     std::cout << "END GetBundleInfoV9_0021" << std::endl;
1233 }
1234 
1235 /**
1236  * @tc.number: GetBundleInfoV9_0022
1237  * @tc.name: test query bundle information
1238  * @tc.desc: 1.under '/data/test/bms_bundle',there is a hap
1239  *           2.install the hap
1240  *           3.get disabled bundleInfo successfully
1241  */
1242 HWTEST_F(ActsBmsKitSystemTest, GetBundleInfoV9_0022, Function | MediumTest | Level1)
1243 {
1244     std::cout << "START GetBundleInfoV9_0022" << std::endl;
1245     std::vector<std::string> resvec;
1246     std::string bundleFilePath = THIRD_BUNDLE_PATH + "bundleClient1.hap";
1247     std::string appName = "com.example.ohosproject.hmservice";
1248     Install(bundleFilePath, InstallFlag::REPLACE_EXISTING, resvec);
1249     CommonTool commonTool;
1250     std::string installResult = commonTool.VectorToStr(resvec);
1251     EXPECT_EQ(installResult, "Success") << "install fail!";
1252     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
1253     ASSERT_NE(bundleMgrProxy, nullptr);
1254 
1255     BundleInfo bundleInfo;
1256     auto setResult = bundleMgrProxy->SetApplicationEnabled(appName, false, USERID);
1257     EXPECT_EQ(setResult, ERR_OK);
1258     auto getInfoResult = bundleMgrProxy->GetBundleInfoV9(appName,
1259         static_cast<int32_t>(GetBundleInfoFlag::GET_BUNDLE_INFO_WITH_DISABLE), bundleInfo, USERID);
1260     EXPECT_EQ(getInfoResult, ERR_OK);
1261     EXPECT_EQ(bundleInfo.name, appName);
1262     auto resetResult = bundleMgrProxy->SetApplicationEnabled(appName, true, USERID);
1263     EXPECT_EQ(resetResult, ERR_OK);
1264     resvec.clear();
1265     Uninstall(appName, resvec);
1266     std::string uninstallResult = commonTool.VectorToStr(resvec);
1267     EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!";
1268 
1269     std::cout << "END GetBundleInfoV9_0022" << std::endl;
1270 }
1271 
1272 /**
1273  * @tc.number: GetBundleInfoV9_0023
1274  * @tc.name: test query bundle information
1275  * @tc.desc: 1.under '/data/test/bms_bundle',there is a hap
1276  *           2.install the hap
1277  *           3.get bundleInfo which contain signatureInfo successfully
1278  */
1279 HWTEST_F(ActsBmsKitSystemTest, GetBundleInfoV9_0023, Function | MediumTest | Level1)
1280 {
1281     std::cout << "START GetBundleInfoV9_0023" << std::endl;
1282     std::vector<std::string> resvec;
1283     std::string bundleFilePath = THIRD_BUNDLE_PATH + "bmsThirdBundle24.hap";
1284     std::string appName = BASE_BUNDLE_NAME + "1";
1285     Install(bundleFilePath, InstallFlag::REPLACE_EXISTING, resvec);
1286     CommonTool commonTool;
1287     std::string installResult = commonTool.VectorToStr(resvec);
1288     EXPECT_EQ(installResult, "Success") << "install fail!";
1289     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
1290     ASSERT_NE(bundleMgrProxy, nullptr);
1291 
1292     BundleInfo bundleInfo;
1293     auto getInfoResult = bundleMgrProxy->GetBundleInfoV9(appName,
1294         static_cast<int32_t>(GetBundleInfoFlag::GET_BUNDLE_INFO_WITH_SIGNATURE_INFO), bundleInfo, USERID);
1295     EXPECT_EQ(getInfoResult, ERR_OK);
1296     EXPECT_EQ(bundleInfo.name, appName);
1297     EXPECT_EQ(bundleInfo.signatureInfo.appId, APPID);
1298     resvec.clear();
1299     Uninstall(appName, resvec);
1300     std::string uninstallResult = commonTool.VectorToStr(resvec);
1301     EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!";
1302 
1303     std::cout << "END GetBundleInfoV9_0023" << std::endl;
1304 }
1305 
1306 /**
1307  * @tc.number: GetBundleInfoV9_0024
1308  * @tc.name: test query bundle information
1309  * @tc.desc: 1.install the hap that contains router map json profile
1310  *           2.query bundleInfo
1311  */
1312 HWTEST_F(ActsBmsKitSystemTest, GetBundleInfoV9_0024, Function | MediumTest | Level1)
1313 {
1314     std::cout << "START GetBundleInfoV9_0024" << std::endl;
1315     std::vector<std::string> resvec;
1316     Install(ROUTER_MAP_TEST_HAP, InstallFlag::REPLACE_EXISTING, resvec);
1317     CommonTool commonTool;
1318     std::string installResult = commonTool.VectorToStr(resvec);
1319     EXPECT_EQ(installResult, "Success") << "install fail!";
1320     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
1321     ASSERT_NE(bundleMgrProxy, nullptr);
1322 
1323     BundleInfo bundleInfo;
1324     auto getInfoResult = bundleMgrProxy->GetBundleInfoV9(ROUTER_MAP_TEST_BUNDLE_NAME,
1325         static_cast<int32_t>(GetBundleInfoFlag::GET_BUNDLE_INFO_WITH_HAP_MODULE) |
1326         static_cast<int32_t>(GetBundleInfoFlag::GET_BUNDLE_INFO_WITH_ROUTER_MAP), bundleInfo, USERID);
1327     EXPECT_EQ(getInfoResult, ERR_OK);
1328     ASSERT_FALSE(bundleInfo.hapModuleInfos.empty());
1329     ASSERT_EQ(bundleInfo.hapModuleInfos[PERMS_INDEX_ZERO].routerArray.size(), PERMS_INDEX_TWO);
1330     EXPECT_EQ(bundleInfo.hapModuleInfos[PERMS_INDEX_ZERO].routerArray[PERMS_INDEX_ZERO].name, ROUTER_INDEX_ZERO_URL);
1331     EXPECT_EQ(bundleInfo.hapModuleInfos[PERMS_INDEX_ZERO].routerArray[PERMS_INDEX_ZERO].pageSourceFile,
1332         ROUTER_INDEX_ZERO_PATH);
1333     EXPECT_EQ(bundleInfo.hapModuleInfos[PERMS_INDEX_ZERO].routerArray[PERMS_INDEX_ZERO].buildFunction,
1334         ROUTER_INDEX_ZERO_BUILD_FUNCTION);
1335 
1336     EXPECT_EQ(bundleInfo.hapModuleInfos[PERMS_INDEX_ZERO].routerArray[PERMS_INDEX_ONE].name, ROUTER_INDEX_ONE_URL);
1337     EXPECT_EQ(bundleInfo.hapModuleInfos[PERMS_INDEX_ZERO].routerArray[PERMS_INDEX_ONE].pageSourceFile,
1338         ROUTER_INDEX_ZERO_PATH);
1339     EXPECT_EQ(bundleInfo.hapModuleInfos[PERMS_INDEX_ZERO].routerArray[PERMS_INDEX_ONE].buildFunction,
1340         ROUTER_INDEX_ONE_BUILD_FUNCTION);
1341     EXPECT_EQ(bundleInfo.hapModuleInfos[PERMS_INDEX_ZERO].routerArray[PERMS_INDEX_ONE].data.size(), 2);
1342     resvec.clear();
1343     Uninstall(ROUTER_MAP_TEST_BUNDLE_NAME, resvec);
1344     std::string uninstallResult = commonTool.VectorToStr(resvec);
1345     EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!";
1346 
1347     std::cout << "END GetBundleInfoV9_0024" << std::endl;
1348 }
1349 
1350 /**
1351  * @tc.number: GetBundleInfoV9_0025
1352  * @tc.name: test query bundle information
1353  * @tc.desc: 1.install the hap that does not contain router map json profile
1354  *           2.query bundleInfo
1355  */
1356 HWTEST_F(ActsBmsKitSystemTest, GetBundleInfoV9_0025, Function | MediumTest | Level1)
1357 {
1358     std::cout << "START GetBundleInfoV9_0025" << std::endl;
1359     std::vector<std::string> resvec;
1360     std::string bundleFilePath = THIRD_BUNDLE_PATH + "bmsThirdBundle24.hap";
1361     std::string appName = BASE_BUNDLE_NAME + "1";
1362     Install(bundleFilePath, InstallFlag::REPLACE_EXISTING, resvec);
1363     CommonTool commonTool;
1364     std::string installResult = commonTool.VectorToStr(resvec);
1365     EXPECT_EQ(installResult, "Success") << "install fail!";
1366     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
1367     ASSERT_NE(bundleMgrProxy, nullptr);
1368 
1369     BundleInfo bundleInfo;
1370     auto getInfoResult = bundleMgrProxy->GetBundleInfoV9(appName,
1371         static_cast<int32_t>(GetBundleInfoFlag::GET_BUNDLE_INFO_WITH_HAP_MODULE) |
1372         static_cast<int32_t>(GetBundleInfoFlag::GET_BUNDLE_INFO_WITH_ROUTER_MAP), bundleInfo, USERID);
1373     EXPECT_EQ(getInfoResult, ERR_OK);
1374     ASSERT_FALSE(bundleInfo.hapModuleInfos.empty());
1375     EXPECT_TRUE(bundleInfo.hapModuleInfos[PERMS_INDEX_ZERO].routerArray.empty());
1376     resvec.clear();
1377     Uninstall(appName, resvec);
1378     std::string uninstallResult = commonTool.VectorToStr(resvec);
1379     EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!";
1380 
1381     std::cout << "END GetBundleInfoV9_0025" << std::endl;
1382 }
1383 
1384 /**
1385  * @tc.number: GetBundleInfos_0100
1386  * @tc.name: test query bundleinfos
1387  * @tc.desc: 1.under '/data/test/bms_bundle',there exist three bundles
1388  *           2.install the bundles
1389  *           3.query all bundleinfos
1390  */
1391 HWTEST_F(ActsBmsKitSystemTest, GetBundleInfos_0100, Function | MediumTest | Level1)
1392 {
1393     std::cout << "START GetBundleInfos_0100" << std::endl;
1394     bool result = false;
1395     for (int i = 1; i <= stLevel_.BMSLevel; i++) {
1396         CommonTool commonTool;
1397         std::string installResult;
1398         for (int i = 6; i < 9; i++) {
1399             std::vector<std::string> resvec;
1400             std::string hapFilePath = THIRD_BUNDLE_PATH + "bmsThirdBundle" + std::to_string(i) + ".hap";
1401             Install(hapFilePath, InstallFlag::REPLACE_EXISTING, resvec);
1402             installResult = commonTool.VectorToStr(resvec);
1403             EXPECT_EQ(installResult, "Success") << "install fail!";
1404         }
1405         sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
1406         ASSERT_NE(bundleMgrProxy, nullptr);
1407 
1408         std::vector<BundleInfo> bundleInfos;
1409         bool getInfoResult = bundleMgrProxy->GetBundleInfos(0, bundleInfos, USERID);
1410         EXPECT_TRUE(getInfoResult);
1411 
1412         bool isSubStrExist = false;
1413         for (int i = 1; i <= 3; i++) {
1414             std::string appName = BASE_BUNDLE_NAME + std::to_string(i);
1415             for (auto iter = bundleInfos.begin(); iter != bundleInfos.end(); iter++) {
1416                 if (IsSubStr(iter->name, appName)) {
1417                     isSubStrExist = true;
1418                     break;
1419                 }
1420             }
1421             EXPECT_TRUE(isSubStrExist);
1422             std::vector<std::string> resvec2;
1423             Uninstall(appName, resvec2);
1424             std::string uninstallResult = commonTool.VectorToStr(resvec2);
1425             EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!";
1426         }
1427         if (!getInfoResult) {
1428             APP_LOGI("GetBundleInfos_0100 failed - cycle count: %{public}d", i);
1429             break;
1430         }
1431         result = true;
1432     }
1433 
1434     if (result && stLevel_.BMSLevel > 1) {
1435         APP_LOGI("GetBundleInfos_0100 success - cycle count: %{public}d", stLevel_.BMSLevel);
1436     }
1437     EXPECT_TRUE(result);
1438     std::cout << "END GetBundleInfos_0100" << std::endl;
1439 }
1440 
1441 /**
1442  * @tc.number: GetBundleInfos_0200
1443  * @tc.name: test query bundleinfos
1444  * @tc.desc: 1.under '/system/app/bms_bundle',there exist some hap
1445  *           2.query all bundleinfos
1446  */
1447 HWTEST_F(ActsBmsKitSystemTest, GetBundleInfos_0200, Function | MediumTest | Level1)
1448 {
1449     std::cout << "START GetBundleInfos_0200" << std::endl;
1450     for (int i = 1; i <= stLevel_.BMSLevel; i++) {
1451         sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
1452         ASSERT_NE(bundleMgrProxy, nullptr);
1453 
1454         std::vector<BundleInfo> bundleInfos;
1455         bool getInfoResult = bundleMgrProxy->GetBundleInfos(BundleFlag::GET_BUNDLE_DEFAULT, bundleInfos, USERID);
1456         EXPECT_TRUE(getInfoResult);
1457     }
1458     std::cout << "END GetBundleInfos_0200" << std::endl;
1459 }
1460 
1461 /**
1462  * @tc.number: GetBundleInfos_0300
1463  * @tc.name: test query bundleinfos
1464  * @tc.desc: 1.under '/system/app/bms_bundle',there exist some hap
1465  *           2.query all bundleinfos
1466  */
1467 HWTEST_F(ActsBmsKitSystemTest, GetBundleInfos_0300, Function | MediumTest | Level1)
1468 {
1469     std::cout << "START GetBundleInfos_0300" << std::endl;
1470     for (int i = 1; i <= stLevel_.BMSLevel; i++) {
1471         sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
1472         ASSERT_NE(bundleMgrProxy, nullptr);
1473 
1474         std::vector<BundleInfo> bundleInfos;
1475         bool getInfoResult = bundleMgrProxy->GetBundleInfos(BundleFlag::GET_BUNDLE_DEFAULT, bundleInfos, INVALIED_ID);
1476         EXPECT_FALSE(getInfoResult);
1477     }
1478     std::cout << "END GetBundleInfos_0300" << std::endl;
1479 }
1480 
1481 /**
1482  * @tc.number: GetBundleInfosV9_0100
1483  * @tc.name: test query bundleinfos
1484  * @tc.desc: 1.under '/data/test/bms_bundle',there exist three bundles
1485  *           2.install the bundles
1486  *           3.query all bundleinfos failed for wrong UserId
1487  */
1488 HWTEST_F(ActsBmsKitSystemTest, GetBundleInfosV9_0100, Function | MediumTest | Level1)
1489 {
1490     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
1491     ASSERT_NE(bundleMgrProxy, nullptr);
1492 
1493     std::vector<BundleInfo> bundleInfos;
1494     auto getInfoResult = bundleMgrProxy->GetBundleInfosV9(
1495         static_cast<int32_t>(GetBundleInfoFlag::GET_BUNDLE_INFO_DEFAULT), bundleInfos, Constants::INVALID_USERID);
1496     EXPECT_EQ(getInfoResult, ERR_BUNDLE_MANAGER_PERMISSION_DENIED);
1497 }
1498 
1499 /**
1500  * @tc.number: GetApplicationInfo_0100
1501  * @tc.name: test query application information
1502  * EnvConditions: system running normally
1503  * @tc.desc: 1.under '/data/test/bms_bundle',there is a hap
1504  *           2.install the hap
1505  *           3.query appinfo
1506  */
1507 HWTEST_F(ActsBmsKitSystemTest, GetApplicationInfo_0100, Function | MediumTest | Level1)
1508 {
1509     std::cout << "START GetApplicationInfo_0100" << std::endl;
1510     bool result = false;
1511     for (int i = 1; i <= stLevel_.BMSLevel; i++) {
1512         std::vector<std::string> resvec;
1513         std::string bundleFilePath = THIRD_BUNDLE_PATH + "bmsThirdBundle1.hap";
1514         std::string appName = BASE_BUNDLE_NAME + "1";
1515         Install(bundleFilePath, InstallFlag::REPLACE_EXISTING, resvec);
1516 
1517         CommonTool commonTool;
1518         std::string installResult = commonTool.VectorToStr(resvec);
1519         EXPECT_EQ(installResult, "Success") << "install fail!";
1520 
1521         sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
1522         ASSERT_NE(bundleMgrProxy, nullptr);
1523 
1524         ApplicationInfo appInfo;
1525         bool getInfoResult =
1526             bundleMgrProxy->GetApplicationInfo(appName, 0, USERID, appInfo);
1527         EXPECT_TRUE(getInfoResult);
1528         EXPECT_EQ(appInfo.name, appName);
1529         resvec.clear();
1530         Uninstall(appName, resvec);
1531         std::string uninstallResult = commonTool.VectorToStr(resvec);
1532         EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!";
1533 
1534         if (!getInfoResult) {
1535             APP_LOGI("GetApplicationInfo_0100 failed - cycle count: %{public}d", i);
1536             break;
1537         }
1538         result = true;
1539     }
1540 
1541     if (result && stLevel_.BMSLevel > 1) {
1542         APP_LOGI("GetApplicationInfo_0100 success - cycle count: %{public}d", stLevel_.BMSLevel);
1543     }
1544     EXPECT_TRUE(result);
1545     std::cout << "END GetApplicationInfo_0100" << std::endl;
1546 }
1547 
1548 /**
1549  * @tc.number: GetApplicationInfo_0200
1550  * @tc.name: test query application information
1551  * @tc.desc: 1.under '/data/test/bms_bundle',there is a hap
1552  *           2.install the hap
1553  *           3.query appinfo with permission
1554  */
1555 HWTEST_F(ActsBmsKitSystemTest, GetApplicationInfo_0200, Function | MediumTest | Level1)
1556 {
1557     std::cout << "START GetApplicationInfo_0200" << std::endl;
1558     bool result = false;
1559     for (int i = 1; i <= stLevel_.BMSLevel; i++) {
1560         std::vector<std::string> resvec;
1561         std::string bundleFilePath = THIRD_BUNDLE_PATH + "bmsThirdBundle1.hap";
1562         std::string appName = BASE_BUNDLE_NAME + "1";
1563         Install(bundleFilePath, InstallFlag::REPLACE_EXISTING, resvec);
1564 
1565         CommonTool commonTool;
1566         std::string installResult = commonTool.VectorToStr(resvec);
1567         EXPECT_EQ(installResult, "Success") << "install fail!";
1568 
1569         sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
1570         ASSERT_NE(bundleMgrProxy, nullptr);
1571 
1572         ApplicationInfo appInfo;
1573         bool getInfoResult = bundleMgrProxy->GetApplicationInfo(
1574             appName, ApplicationFlag::GET_APPLICATION_INFO_WITH_PERMISSION, USERID, appInfo);
1575         std::string permission = commonTool.VectorToStr(appInfo.permissions);
1576         EXPECT_TRUE(getInfoResult);
1577         resvec.clear();
1578         Uninstall(appName, resvec);
1579         std::string uninstallResult = commonTool.VectorToStr(resvec);
1580         EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!";
1581 
1582         if (!getInfoResult) {
1583             APP_LOGI("GetApplicationInfo_0200 failed - cycle count: %{public}d", i);
1584             break;
1585         }
1586         result = true;
1587     }
1588 
1589     if (result && stLevel_.BMSLevel > 1) {
1590         APP_LOGI("GetApplicationInfo_0200 success - cycle count: %{public}d", stLevel_.BMSLevel);
1591     }
1592     EXPECT_TRUE(result);
1593     std::cout << "END GetApplicationInfo_0200" << std::endl;
1594 }
1595 
1596 /**
1597  * @tc.number: GetApplicationInfo_0300
1598  * @tc.name: test query application information
1599  * @tc.desc: 1.under '/data/test/bms_bundle',there is a hap
1600  *           2.install the hap
1601  *           3.query appInfo with wrong appname
1602  */
1603 HWTEST_F(ActsBmsKitSystemTest, GetApplicationInfo_0300, Function | MediumTest | Level2)
1604 {
1605     std::cout << "START GetApplicationInfo_0300" << std::endl;
1606     bool result = false;
1607     for (int i = 1; i <= stLevel_.BMSLevel; i++) {
1608         std::vector<std::string> resvec;
1609         std::string bundleFilePath = THIRD_BUNDLE_PATH + "bmsThirdBundle1.hap";
1610         std::string appName = BASE_BUNDLE_NAME + "1";
1611         Install(bundleFilePath, InstallFlag::REPLACE_EXISTING, resvec);
1612 
1613         CommonTool commonTool;
1614         std::string installResult = commonTool.VectorToStr(resvec);
1615         EXPECT_EQ(installResult, "Success") << "install fail!";
1616 
1617         sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
1618         ASSERT_NE(bundleMgrProxy, nullptr);
1619 
1620         ApplicationInfo appInfo;
1621         appName = BASE_BUNDLE_NAME + "e";
1622         bool getInfoResult =
1623             bundleMgrProxy->GetApplicationInfo(appName, ApplicationFlag::GET_BASIC_APPLICATION_INFO, USERID, appInfo);
1624         EXPECT_FALSE(getInfoResult);
1625         resvec.clear();
1626         appName = BASE_BUNDLE_NAME + "1";
1627         Uninstall(appName, resvec);
1628         std::string uninstallResult = commonTool.VectorToStr(resvec);
1629         EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!";
1630 
1631         if (getInfoResult) {
1632             APP_LOGI("GetApplicationInfo_0300 failed - cycle count: %{public}d", i);
1633             break;
1634         }
1635         result = true;
1636     }
1637 
1638     if (result && stLevel_.BMSLevel > 1) {
1639         APP_LOGI("GetApplicationInfo_0300 success - cycle count: %{public}d", stLevel_.BMSLevel);
1640     }
1641     EXPECT_TRUE(result);
1642     std::cout << "END GetApplicationInfo_0300" << std::endl;
1643 }
1644 
1645 /**
1646  * @tc.number: GetApplicationInfo_0400
1647  * @tc.name: test GetApplicationInfo interface
1648  * @tc.desc: 1.under '/data/test/bms_bundle',there is a hap
1649  *           2.install the hap
1650  *           3.call GetApplicationInfo
1651  */
1652 HWTEST_F(ActsBmsKitSystemTest, GetApplicationInfo_0400, Function | MediumTest | Level1)
1653 {
1654     std::cout << "START GetApplicationInfo_0400" << std::endl;
1655     bool result = false;
1656     for (int i = 1; i <= stLevel_.BMSLevel; i++) {
1657         std::vector<std::string> resvec;
1658         std::string bundleFilePath = THIRD_BUNDLE_PATH + "bmsThirdBundle3.hap";
1659         std::string appName = BASE_BUNDLE_NAME + "1";
1660         Install(bundleFilePath, InstallFlag::REPLACE_EXISTING, resvec);
1661 
1662         CommonTool commonTool;
1663         std::string installResult = commonTool.VectorToStr(resvec);
1664         EXPECT_EQ(installResult, "Success") << "install fail!";
1665 
1666         sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
1667         ASSERT_NE(bundleMgrProxy, nullptr);
1668 
1669         ApplicationInfo appInfo;
1670         bool getInfoResult =
1671             bundleMgrProxy->GetApplicationInfo(appName, ApplicationFlag::GET_BASIC_APPLICATION_INFO, USERID, appInfo);
1672         EXPECT_TRUE(getInfoResult);
1673         EXPECT_EQ(appInfo.name, appName);
1674         resvec.clear();
1675         Uninstall(appName, resvec);
1676         std::string uninstallResult = commonTool.VectorToStr(resvec);
1677         EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!";
1678 
1679         if (!getInfoResult) {
1680             APP_LOGI("GetApplicationInfo_0400 failed - cycle count: %{public}d", i);
1681             break;
1682         }
1683         result = true;
1684     }
1685 
1686     if (result && stLevel_.BMSLevel > 1) {
1687         APP_LOGI("GetApplicationInfo_0400 success - cycle count: %{public}d", stLevel_.BMSLevel);
1688     }
1689     EXPECT_TRUE(result);
1690     std::cout << "END GetApplicationInfo_0400" << std::endl;
1691 }
1692 
1693 /**
1694  * @tc.number: GetApplicationInfo_0500
1695  * @tc.name: test GetApplicationInfo interface
1696  * @tc.desc: 1.under '/system/app',there is a hap
1697  *           2.install the hap
1698  *           3.call GetApplicationInfo
1699  */
1700 HWTEST_F(ActsBmsKitSystemTest, GetApplicationInfo_0500, Function | MediumTest | Level1)
1701 {
1702     std::cout << "START GetApplicationInfo_0500" << std::endl;
1703     CommonTool commonTool;
1704     std::vector<std::string> resvec;
1705     std::string bundleFilePath = THIRD_BUNDLE_PATH + "bmsThirdBundle1.hap";
1706     std::string appName = BASE_BUNDLE_NAME + "1";
1707     Install(bundleFilePath, InstallFlag::REPLACE_EXISTING, resvec);
1708 
1709     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
1710     ASSERT_NE(bundleMgrProxy, nullptr);
1711 
1712     ApplicationInfo appInfo;
1713     bool getInfoResult = bundleMgrProxy->GetApplicationInfo(
1714         appName, ApplicationFlag::GET_BASIC_APPLICATION_INFO, USERID, appInfo);
1715     EXPECT_TRUE(getInfoResult);
1716     EXPECT_EQ(appInfo.name, appName);
1717 
1718     resvec.clear();
1719     Uninstall(appName, resvec);
1720     std::string uninstallResult = commonTool.VectorToStr(resvec);
1721     EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!";
1722     std::cout << "END GetApplicationInfo_0500" << std::endl;
1723 }
1724 
1725 /**
1726  * @tc.number: GetApplicationInfo_0600
1727  * @tc.name: test GetApplicationInfo interface
1728  * @tc.desc: 1.under '/data/test/bms_bundle',there is a hap
1729  *           2.install the hap
1730  *           3.uninstall the hap
1731  *           4.call GetApplicationInfo to get application info
1732  */
1733 HWTEST_F(ActsBmsKitSystemTest, GetApplicationInfo_0600, Function | MediumTest | Level1)
1734 {
1735     std::cout << "START GetApplicationInfo_0600" << std::endl;
1736     bool result = false;
1737     for (int i = 1; i <= stLevel_.BMSLevel; i++) {
1738         std::vector<std::string> resvec;
1739         std::string bundleFilePath = THIRD_BUNDLE_PATH + "bmsThirdBundle1.hap";
1740         std::string appName = BASE_BUNDLE_NAME + "1";
1741         Install(bundleFilePath, InstallFlag::REPLACE_EXISTING, resvec);
1742 
1743         CommonTool commonTool;
1744         std::string installResult = commonTool.VectorToStr(resvec);
1745         EXPECT_EQ(installResult, "Success") << "install fail!";
1746 
1747         resvec.clear();
1748         Uninstall(appName, resvec);
1749         std::string uninstallResult = commonTool.VectorToStr(resvec);
1750         EXPECT_EQ(uninstallResult, "Success");
1751 
1752         sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
1753         ASSERT_NE(bundleMgrProxy, nullptr);
1754 
1755         ApplicationInfo appInfo;
1756         bool getInfoResult =
1757             bundleMgrProxy->GetApplicationInfo(appName, ApplicationFlag::GET_BASIC_APPLICATION_INFO, USERID, appInfo);
1758         EXPECT_FALSE(getInfoResult);
1759         if (getInfoResult) {
1760             APP_LOGI("GetApplicationInfo_0600 failed - cycle count: %{public}d", i);
1761             break;
1762         }
1763         result = true;
1764     }
1765 
1766     if (result && stLevel_.BMSLevel > 1) {
1767         APP_LOGI("GetApplicationInfo_0600 success - cycle count: %{public}d", stLevel_.BMSLevel);
1768     }
1769     EXPECT_TRUE(result);
1770     std::cout << "END GetApplicationInfo_0600" << std::endl;
1771 }
1772 
1773 /**
1774  * @tc.number: GetApplicationInfo_0700
1775  * @tc.name: test GetApplicationInfo interface
1776  * @tc.desc: 1.under '/data/test/bms_bundle',there is a hap
1777  *           2.install the hap
1778  *           3.uninstall the hap
1779  *           4.call GetApplicationInfo to get application info
1780  */
1781 HWTEST_F(ActsBmsKitSystemTest, GetApplicationInfo_0700, Function | MediumTest | Level1)
1782 {
1783     std::cout << "START GetApplicationInfo_0700" << std::endl;
1784     bool result = false;
1785     for (int i = 1; i <= stLevel_.BMSLevel; i++) {
1786         std::vector<std::string> resvec;
1787         std::string bundleFilePath = THIRD_BUNDLE_PATH + "bmsThirdBundle1.hap";
1788         std::string appName = BASE_BUNDLE_NAME + "1";
1789         Install(bundleFilePath, InstallFlag::REPLACE_EXISTING, resvec);
1790         CommonTool commonTool;
1791         std::string installResult = commonTool.VectorToStr(resvec);
1792         EXPECT_EQ(installResult, "Success") << "install fail!";
1793 
1794         ApplicationInfo appInfo;
1795         sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
1796         ASSERT_NE(bundleMgrProxy, nullptr);
1797 
1798         bool getInfoResult =
1799             bundleMgrProxy->GetApplicationInfo(appName, 0, USERID, appInfo);
1800         EXPECT_TRUE(getInfoResult);
1801         EXPECT_EQ(appInfo.flags, 0);
1802 
1803         resvec.clear();
1804         Uninstall(appName, resvec);
1805         std::string uninstallResult = commonTool.VectorToStr(resvec);
1806         EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!";
1807         if (!getInfoResult) {
1808             APP_LOGI("GetApplicationInfo_0700 failed - cycle count: %{public}d", i);
1809             break;
1810         }
1811         result = true;
1812     }
1813 
1814     if (result && stLevel_.BMSLevel > 1) {
1815         APP_LOGI("GetApplicationInfo_0700 success - cycle count: %{public}d", stLevel_.BMSLevel);
1816     }
1817     EXPECT_TRUE(result);
1818     std::cout << "END GetApplicationInfo_0700" << std::endl;
1819 }
1820 
1821 /**
1822  * @tc.number: GetApplicationInfo_0800
1823  * @tc.name: test GetApplicationInfo interface
1824  * @tc.desc: 1.under '/data/test/bms_bundle',there is a hap
1825  *           2.install the hap
1826  *           3.uninstall the hap
1827  *           4.call GetApplicationInfo to get application info
1828  */
1829 HWTEST_F(ActsBmsKitSystemTest, GetApplicationInfo_0800, Function | MediumTest | Level1)
1830 {
1831     ApplicationInfo appInfo;
1832     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
1833     ASSERT_NE(bundleMgrProxy, nullptr);
1834 
1835     bool getInfoResult =
1836         bundleMgrProxy->GetApplicationInfo("", 0, USERID, appInfo);
1837     EXPECT_FALSE(getInfoResult);
1838 }
1839 
1840 /**
1841  * @tc.number: GetApplicationInfoV9_0100
1842  * @tc.name: test query application information
1843  * @tc.desc: 1.under '/data/test/bms_bundle',there is a hap
1844  *           2.install the hap
1845  *           3.query default ApplicationInfo
1846  */
1847 HWTEST_F(ActsBmsKitSystemTest, GetApplicationInfoV9_0100, Function | MediumTest | Level1)
1848 {
1849     std::cout << "START GetApplicationInfoV9_0100" << std::endl;
1850 
1851     std::vector<std::string> resvec;
1852     std::string bundleFilePath = THIRD_BUNDLE_PATH + "bmsThirdBundle1.hap";
1853     std::string appName = BASE_BUNDLE_NAME + "1";
1854     Install(bundleFilePath, InstallFlag::REPLACE_EXISTING, resvec);
1855     CommonTool commonTool;
1856     std::string installResult = commonTool.VectorToStr(resvec);
1857     EXPECT_EQ(installResult, "Success") << "install fail!";
1858 
1859     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
1860     ASSERT_NE(bundleMgrProxy, nullptr);
1861 
1862     ApplicationInfo appInfo;
1863     auto getInfoResult = bundleMgrProxy->GetApplicationInfoV9(
1864         appName, static_cast<int32_t>(GetApplicationFlag::GET_APPLICATION_INFO_DEFAULT), USERID, appInfo);
1865     EXPECT_EQ(getInfoResult, ERR_OK);
1866     EXPECT_EQ(appInfo.name, appName);
1867 
1868     resvec.clear();
1869     Uninstall(appName, resvec);
1870     std::string uninstallResult = commonTool.VectorToStr(resvec);
1871     EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!";
1872 
1873     std::cout << "END GetApplicationInfoV9_0100" << std::endl;
1874 }
1875 
1876 /**
1877  * @tc.number: GetApplicationInfoV9_0200
1878  * @tc.name: test query application information
1879  * @tc.desc: 1.under '/data/test/bms_bundle',there is a hap
1880  *           2.install the hap
1881  *           3.fail to query ApplicationInfo for wrong bundleName
1882  */
1883 HWTEST_F(ActsBmsKitSystemTest, GetApplicationInfoV9_0200, Function | MediumTest | Level1)
1884 {
1885     std::cout << "START GetApplicationInfoV9_0200" << std::endl;
1886 
1887     std::vector<std::string> resvec;
1888     std::string bundleFilePath = THIRD_BUNDLE_PATH + "bmsThirdBundle1.hap";
1889     std::string appName = BASE_BUNDLE_NAME + "1";
1890     Install(bundleFilePath, InstallFlag::REPLACE_EXISTING, resvec);
1891     CommonTool commonTool;
1892     std::string installResult = commonTool.VectorToStr(resvec);
1893     EXPECT_EQ(installResult, "Success") << "install fail!";
1894 
1895     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
1896     ASSERT_NE(bundleMgrProxy, nullptr);
1897 
1898     ApplicationInfo appInfo;
1899     auto getInfoResult = bundleMgrProxy->GetApplicationInfoV9(
1900         "", static_cast<int32_t>(GetApplicationFlag::GET_APPLICATION_INFO_DEFAULT), USERID, appInfo);
1901     EXPECT_EQ(getInfoResult, ERR_BUNDLE_MANAGER_BUNDLE_NOT_EXIST);
1902 
1903     resvec.clear();
1904     Uninstall(appName, resvec);
1905     std::string uninstallResult = commonTool.VectorToStr(resvec);
1906     EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!";
1907 
1908     std::cout << "END GetApplicationInfoV9_0200" << std::endl;
1909 }
1910 
1911 /**
1912  * @tc.number: GetApplicationInfoV9_0300
1913  * @tc.name: test query application information
1914  * @tc.desc: 1.under '/data/test/bms_bundle',there is a hap
1915  *           2.install the hap
1916  *           3.fail to query ApplicationInfo for wrong UserId
1917  */
1918 HWTEST_F(ActsBmsKitSystemTest, GetApplicationInfoV9_0300, Function | MediumTest | Level1)
1919 {
1920     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
1921     ASSERT_NE(bundleMgrProxy, nullptr);
1922 
1923     ApplicationInfo appInfo;
1924     auto getInfoResult = bundleMgrProxy->GetApplicationInfoV9(
1925         "appName", static_cast<int32_t>(GetApplicationFlag::GET_APPLICATION_INFO_DEFAULT),
1926             Constants::INVALID_USERID, appInfo);
1927     EXPECT_EQ(getInfoResult, ERR_BUNDLE_MANAGER_INVALID_USER_ID);
1928 }
1929 
1930 /**
1931  * @tc.number: GetApplicationInfoV9_0400
1932  * @tc.name: test query application information
1933  * @tc.desc: 1.under '/data/test/bms_bundle',there is a hap
1934  *           2.install the hap
1935  *           3.get ApplicationInfo with permissions
1936  */
1937 HWTEST_F(ActsBmsKitSystemTest, GetApplicationInfoV9_0400, Function | MediumTest | Level1)
1938 {
1939     std::cout << "START GetApplicationInfoV9_0400" << std::endl;
1940 
1941     std::vector<std::string> resvec;
1942     std::string bundleFilePath = THIRD_BUNDLE_PATH + "bundleClient1.hap";
1943     std::string appName = "com.example.ohosproject.hmservice";
1944     Install(bundleFilePath, InstallFlag::REPLACE_EXISTING, resvec);
1945     CommonTool commonTool;
1946     std::string installResult = commonTool.VectorToStr(resvec);
1947     EXPECT_EQ(installResult, "Success") << "install fail!";
1948 
1949     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
1950     ASSERT_NE(bundleMgrProxy, nullptr);
1951 
1952     ApplicationInfo appInfo;
1953     auto getInfoResult = bundleMgrProxy->GetApplicationInfoV9(
1954         appName, static_cast<int32_t>(GetApplicationFlag::GET_APPLICATION_INFO_WITH_PERMISSION), USERID, appInfo);
1955     EXPECT_EQ(getInfoResult, ERR_OK);
1956     EXPECT_EQ(appInfo.name, appName);
1957     EXPECT_FALSE(appInfo.permissions.empty());
1958     resvec.clear();
1959     Uninstall(appName, resvec);
1960     std::string uninstallResult = commonTool.VectorToStr(resvec);
1961     EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!";
1962 
1963     std::cout << "END GetApplicationInfoV9_0400" << std::endl;
1964 }
1965 
1966 /**
1967  * @tc.number: GetApplicationInfoV9_0500
1968  * @tc.name: test query application information
1969  * @tc.desc: 1.under '/data/test/bms_bundle',there is a hap
1970  *           2.install the hap
1971  *           3.get ApplicationInfo with metadata
1972  */
1973 HWTEST_F(ActsBmsKitSystemTest, GetApplicationInfoV9_0500, Function | MediumTest | Level1)
1974 {
1975     std::cout << "START GetApplicationInfoV9_0500" << std::endl;
1976 
1977     std::vector<std::string> resvec;
1978     std::string bundleFilePath = THIRD_BUNDLE_PATH + "bundleClient1.hap";
1979     std::string appName = "com.example.ohosproject.hmservice";
1980     Install(bundleFilePath, InstallFlag::REPLACE_EXISTING, resvec);
1981     CommonTool commonTool;
1982     std::string installResult = commonTool.VectorToStr(resvec);
1983     EXPECT_EQ(installResult, "Success") << "install fail!";
1984 
1985     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
1986     ASSERT_NE(bundleMgrProxy, nullptr);
1987 
1988     ApplicationInfo appInfo;
1989     auto getInfoResult = bundleMgrProxy->GetApplicationInfoV9(
1990         appName, static_cast<int32_t>(GetApplicationFlag::GET_APPLICATION_INFO_WITH_METADATA), USERID, appInfo);
1991     EXPECT_EQ(getInfoResult, ERR_OK);
1992     EXPECT_EQ(appInfo.name, appName);
1993     EXPECT_FALSE(appInfo.metadata.empty());
1994 
1995     resvec.clear();
1996     Uninstall(appName, resvec);
1997     std::string uninstallResult = commonTool.VectorToStr(resvec);
1998     EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!";
1999 
2000     std::cout << "END GetApplicationInfoV9_0500" << std::endl;
2001 }
2002 
2003 /**
2004  * @tc.number: GetApplicationInfos_0100
2005  * @tc.name: test query applicationinfos
2006  * @tc.desc: 1.under '/data/test/bms_bundle',there exist three bundles
2007  *           2.install these bundles
2008  *           3.query all appinfos
2009  */
2010 HWTEST_F(ActsBmsKitSystemTest, GetApplicationInfos_0100, Function | MediumTest | Level1)
2011 {
2012     std::cout << "START GetApplicationInfos_0100" << std::endl;
2013     bool result = false;
2014     for (int i = 1; i <= stLevel_.BMSLevel; i++) {
2015         CommonTool commonTool;
2016         sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
2017         ASSERT_NE(bundleMgrProxy, nullptr);
2018 
2019         std::string installResult;
2020         for (int i = 6; i <= 8; i++) {
2021             std::vector<std::string> resvec;
2022             std::string hapFilePath = THIRD_BUNDLE_PATH + "bmsThirdBundle" + std::to_string(i) + ".hap";
2023             std::string appName = BASE_BUNDLE_NAME + std::to_string(i - 5);
2024             Install(hapFilePath, InstallFlag::REPLACE_EXISTING, resvec);
2025             installResult = commonTool.VectorToStr(resvec);
2026             EXPECT_EQ(installResult, "Success") << "install fail!";
2027 
2028             std::vector<ApplicationInfo> appInfos;
2029             int32_t flags = 8;
2030             bool getInfoResult = bundleMgrProxy->GetApplicationInfos(flags, USERID, appInfos);
2031             EXPECT_TRUE(getInfoResult);
2032             resvec.clear();
2033             Uninstall(appName, resvec);
2034             std::string uninstallResult = commonTool.VectorToStr(resvec);
2035             EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!";
2036 
2037             bool isSubStrExist = false;
2038             for (auto iter = appInfos.begin(); iter != appInfos.end(); iter++) {
2039                 if (IsSubStr(iter->name, appName)) {
2040                     isSubStrExist = true;
2041                     break;
2042                 }
2043             }
2044             EXPECT_TRUE(isSubStrExist);
2045             if (!getInfoResult) {
2046                 APP_LOGI("GetApplicationInfos_0100 failed - cycle count: %{public}d", i);
2047                 break;
2048             }
2049             result = true;
2050         }
2051     }
2052 
2053     if (result && stLevel_.BMSLevel > 1) {
2054         APP_LOGI("GetApplicationInfos_0100 success - cycle count: %{public}d", stLevel_.BMSLevel);
2055     }
2056     EXPECT_TRUE(result);
2057     std::cout << "END GetApplicationInfos_0100" << std::endl;
2058 }
2059 
2060 /**
2061  * @tc.number: GetApplicationInfos_0200
2062  * @tc.name: test query applicationinfos
2063  * @tc.desc: 1.there are some system-app installed in system
2064  *           2.query all appinfos
2065  */
2066 HWTEST_F(ActsBmsKitSystemTest, GetApplicationInfos_0200, Function | MediumTest | Level1)
2067 {
2068     std::cout << "START GetApplicationInfos_0200" << std::endl;
2069     for (int i = 1; i <= stLevel_.BMSLevel; i++) {
2070         sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
2071         ASSERT_NE(bundleMgrProxy, nullptr);
2072 
2073         std::vector<ApplicationInfo> appInfos;
2074         bool getInfoResult =
2075             bundleMgrProxy->GetApplicationInfos(
2076                 ApplicationFlag::GET_APPLICATION_INFO_WITH_PERMISSION, USERID, appInfos);
2077         EXPECT_TRUE(getInfoResult);
2078     }
2079     std::cout << "END GetApplicationInfos_0200" << std::endl;
2080 }
2081 
2082 /**
2083  * @tc.number: GetApplicationInfos_0300
2084  * @tc.name: test query applicationinfos
2085  * @tc.desc: 1.there are some system-app installed in system
2086  *           2.query all appinfos
2087  */
2088 HWTEST_F(ActsBmsKitSystemTest, GetApplicationInfos_0300, Function | MediumTest | Level1)
2089 {
2090     std::cout << "START GetApplicationInfos_0300" << std::endl;
2091     for (int i = 1; i <= stLevel_.BMSLevel; i++) {
2092         sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
2093         ASSERT_NE(bundleMgrProxy, nullptr);
2094 
2095         std::vector<ApplicationInfo> appInfos;
2096         bool getInfoResult =
2097             bundleMgrProxy->GetApplicationInfos(
2098                 ApplicationFlag::GET_APPLICATION_INFO_WITH_PERMISSION, INVALIED_ID, appInfos);
2099         EXPECT_FALSE(getInfoResult);
2100     }
2101     std::cout << "END GetApplicationInfos_0300" << std::endl;
2102 }
2103 
2104 /**
2105  * @tc.number: GetApplicationInfosV9_0100
2106  * @tc.name: test query applicationinfos
2107  * @tc.desc: 1.fail to query all appinfos for permission denied
2108  */
2109 HWTEST_F(ActsBmsKitSystemTest, GetApplicationInfosV9_0100, Function | MediumTest | Level1)
2110 {
2111     std::cout << "START GetApplicationInfosV9_0100" << std::endl;
2112     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
2113     ASSERT_NE(bundleMgrProxy, nullptr);
2114 
2115     std::vector<ApplicationInfo> appInfos;
2116     auto getInfoResult = bundleMgrProxy->GetApplicationInfosV9(
2117         static_cast<int32_t>(GetApplicationFlag::GET_APPLICATION_INFO_DEFAULT),
2118             Constants::INVALID_USERID, appInfos);
2119     EXPECT_EQ(getInfoResult, ERR_BUNDLE_MANAGER_PERMISSION_DENIED);
2120     std::cout << "END GetApplicationInfosV9_0100" << std::endl;
2121 }
2122 
2123 /**
2124  * @tc.number: GetBundleArchiveInfo_0100
2125  * @tc.name: test query archive information
2126  * @tc.desc: 1.under '/data/test/bms_bundle',there is a hap
2127  *           2.query archive information without an ability information
2128  */
2129 HWTEST_F(ActsBmsKitSystemTest, GetBundleArchiveInfo_0100, Function | MediumTest | Level1)
2130 {
2131     std::cout << "START GetBundleArchiveInfo_0100" << std::endl;
2132     bool result = false;
2133     for (int i = 1; i <= stLevel_.BMSLevel; i++) {
2134         std::string hapFilePath = THIRD_BUNDLE_PATH + "bmsThirdBundle3.hap";
2135         std::string appName = BASE_BUNDLE_NAME + "1";
2136         int32_t flag = 0;
2137 
2138         BundleInfo bundleInfo;
2139         sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
2140         ASSERT_NE(bundleMgrProxy, nullptr);
2141 
2142         bool getInfoResult =
2143             bundleMgrProxy->GetBundleArchiveInfo(hapFilePath, flag, bundleInfo);
2144         EXPECT_TRUE(getInfoResult);
2145         EXPECT_EQ(bundleInfo.name, appName);
2146         std::string version = "1.0";
2147         EXPECT_EQ(bundleInfo.versionName, version);
2148 
2149         if (!getInfoResult) {
2150             APP_LOGI("GetBundleArchiveInfo_0100 failed - cycle count: %{public}d", i);
2151             break;
2152         }
2153         result = true;
2154     }
2155 
2156     if (result && stLevel_.BMSLevel > 1) {
2157         APP_LOGI("GetBundleArchiveInfo_0100 success - cycle count: %{public}d", stLevel_.BMSLevel);
2158     }
2159     EXPECT_TRUE(result);
2160     std::cout << "END GetBundleArchiveInfo_0100" << std::endl;
2161 }
2162 
2163 /**
2164  * @tc.number: GetBundleArchiveInfo_0200
2165  * @tc.name: test query archive information
2166  * @tc.desc: 1.under '/data/test/bms_bundle',there is a hap
2167  *           2.query archive with ability information
2168  */
2169 HWTEST_F(ActsBmsKitSystemTest, GetBundleArchiveInfo_0200, Function | MediumTest | Level1)
2170 {
2171     std::cout << "START GetBundleArchiveInfo_0200" << std::endl;
2172     bool result = false;
2173     for (int i = 1; i <= stLevel_.BMSLevel; i++) {
2174         std::string hapFilePath = THIRD_BUNDLE_PATH + "bmsThirdBundle1.hap";
2175         std::string abilityName = BASE_ABILITY_NAME;
2176         std::string appName = BASE_BUNDLE_NAME + "1";
2177 
2178         BundleInfo bundleInfo;
2179         sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
2180         ASSERT_NE(bundleMgrProxy, nullptr);
2181 
2182         bool getInfoResult =
2183             bundleMgrProxy->GetBundleArchiveInfo(hapFilePath, BundleFlag::GET_BUNDLE_WITH_ABILITIES, bundleInfo);
2184         EXPECT_TRUE(getInfoResult);
2185         EXPECT_EQ(bundleInfo.name, appName);
2186         std::string version = "1.0";
2187         EXPECT_EQ(bundleInfo.versionName, version);
2188 
2189         bool isSubStrExist = false;
2190         for (auto abilityInfo : bundleInfo.abilityInfos) {
2191             if (IsSubStr(abilityInfo.name, abilityName)) {
2192                 isSubStrExist = true;
2193                 break;
2194             }
2195         }
2196         EXPECT_TRUE(isSubStrExist);
2197 
2198         if (!getInfoResult) {
2199             APP_LOGI("GetBundleArchiveInfo_0200 failed - cycle count: %{public}d", i);
2200             break;
2201         }
2202         result = true;
2203     }
2204 
2205     if (result && stLevel_.BMSLevel > 1) {
2206         APP_LOGI("GetBundleArchiveInfo_0200 success - cycle count: %{public}d", stLevel_.BMSLevel);
2207     }
2208     EXPECT_TRUE(result);
2209     std::cout << "END GetBundleArchiveInfo_0200" << std::endl;
2210 }
2211 
2212 /**
2213  * @tc.number: GetBundleArchiveInfo_0300
2214  * @tc.name: test query hap information
2215  * @tc.desc: 1.under '/data/test/bms_bundle',there is a hap
2216  *           2.query hap information with wrong name
2217  */
2218 HWTEST_F(ActsBmsKitSystemTest, GetBundleArchiveInfo_0300, Function | MediumTest | Level2)
2219 {
2220     std::cout << "START GetBundleArchiveInfo_0300" << std::endl;
2221     bool result = false;
2222     for (int i = 1; i <= stLevel_.BMSLevel; i++) {
2223         BundleInfo bundleInfo;
2224         sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
2225         ASSERT_NE(bundleMgrProxy, nullptr);
2226 
2227         std::string hapFilePath = THIRD_BUNDLE_PATH + "tt.hap";
2228         bool getInfoResult =
2229             bundleMgrProxy->GetBundleArchiveInfo(hapFilePath, BundleFlag::GET_BUNDLE_DEFAULT, bundleInfo);
2230         EXPECT_FALSE(getInfoResult);
2231 
2232         if (getInfoResult) {
2233             APP_LOGI("GetBundleArchiveInfo_0300 failed - cycle count: %{public}d", i);
2234             break;
2235         }
2236         result = true;
2237     }
2238 
2239     if (result && stLevel_.BMSLevel > 1) {
2240         APP_LOGI("GetBundleArchiveInfo_0300 success - cycle count: %{public}d", stLevel_.BMSLevel);
2241     }
2242     EXPECT_TRUE(result);
2243     std::cout << "END GetBundleArchiveInfo_0300" << std::endl;
2244 }
2245 
2246 /**
2247  * @tc.number: GetBundleArchiveInfo_0400
2248  * @tc.name: test query archive information
2249  * @tc.desc: 1.under '/data/test/bms_bundle',there is a hap
2250  *           2.query archive information failed without empty path
2251  */
2252 HWTEST_F(ActsBmsKitSystemTest, GetBundleArchiveInfo_0400, Function | MediumTest | Level1)
2253 {
2254     std::cout << "START GetBundleArchiveInfo_0400" << std::endl;
2255     std::string appName = BASE_BUNDLE_NAME + "1";
2256     int32_t flag = 0;
2257 
2258     BundleInfo bundleInfo;
2259     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
2260     ASSERT_NE(bundleMgrProxy, nullptr);
2261 
2262     bool getInfoResult =
2263         bundleMgrProxy->GetBundleArchiveInfo("", flag, bundleInfo);
2264     EXPECT_FALSE(getInfoResult);
2265     bool getInfoResult1 =
2266         bundleMgrProxy->GetBundleArchiveInfo("", BundleFlag::GET_BUNDLE_DEFAULT, bundleInfo);
2267     EXPECT_FALSE(getInfoResult1);
2268     std::cout << "END GetBundleArchiveInfo_0400" << std::endl;
2269 }
2270 
2271 /**
2272  * @tc.number: GetBundleArchiveInfo_0500
2273  * @tc.name: test query  ".rpk" information
2274  * @tc.desc: 1.under '/data/test/bms_bundle',there is a hap with invalid suffix
2275  *           2.query the archive information
2276  */
2277 HWTEST_F(ActsBmsKitSystemTest, GetBundleArchiveInfo_0500, Function | MediumTest | Level2)
2278 {
2279     std::cout << "START GetBundleArchiveInfo_0500" << std::endl;
2280     bool result = false;
2281     for (int i = 1; i <= stLevel_.BMSLevel; i++) {
2282         std::string hapFilePath = THIRD_BUNDLE_PATH + "bmsThirdBundle28.rpk";
2283 
2284         BundleInfo bundleInfo;
2285         sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
2286         ASSERT_NE(bundleMgrProxy, nullptr);
2287 
2288         bool getInfoResult =
2289             bundleMgrProxy->GetBundleArchiveInfo(hapFilePath, BundleFlag::GET_BUNDLE_DEFAULT, bundleInfo);
2290         EXPECT_FALSE(getInfoResult);
2291 
2292         if (getInfoResult) {
2293             APP_LOGI("GetBundleArchiveInfo_0500 failed - cycle count: %{public}d", i);
2294             break;
2295         }
2296         result = true;
2297     }
2298 
2299     if (result && stLevel_.BMSLevel > 1) {
2300         APP_LOGI("GetBundleArchiveInfo_0500 success - cycle count: %{public}d", stLevel_.BMSLevel);
2301     }
2302     EXPECT_TRUE(result);
2303     std::cout << "END GetBundleArchiveInfo_0500" << std::endl;
2304 }
2305 
2306 /**
2307  * @tc.number: GetUidByBundleName_0100
2308  * @tc.name: test query UID
2309  * @tc.desc: 1.under '/data/test/bms_bundle',there is a hap
2310  *           2.install the hap
2311  *           3.query UID by bundleName
2312  */
2313 HWTEST_F(ActsBmsKitSystemTest, GetUidByBundleName_0100, Function | MediumTest | Level1)
2314 {
2315     std::cout << "START GetUidByBundleName_0100" << std::endl;
2316     bool result = false;
2317     for (int i = 1; i <= stLevel_.BMSLevel; i++) {
2318         std::vector<std::string> resvec;
2319         std::string hapFilePath = THIRD_BUNDLE_PATH + "bmsThirdBundle1.hap";
2320         std::string bundleName = BASE_BUNDLE_NAME + "1";
2321         Install(hapFilePath, InstallFlag::REPLACE_EXISTING, resvec);
2322 
2323         CommonTool commonTool;
2324         std::string installResult = commonTool.VectorToStr(resvec);
2325         EXPECT_EQ(installResult, "Success") << "install fail!";
2326         sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
2327         ASSERT_NE(bundleMgrProxy, nullptr);
2328 
2329         int uid = bundleMgrProxy->GetUidByBundleName(bundleName, USERID);
2330         EXPECT_GE(uid, Constants::BASE_USER_RANGE);
2331         resvec.clear();
2332         Uninstall(bundleName, resvec);
2333         std::string uninstallResult = commonTool.VectorToStr(resvec);
2334         EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!";
2335 
2336         if (uid == Constants::INVALID_UID) {
2337             APP_LOGI("GetUidByBundleName_0100 failed - cycle count: %{public}d", i);
2338             break;
2339         }
2340         result = true;
2341     }
2342 
2343     if (result && stLevel_.BMSLevel > 1) {
2344         APP_LOGI("GetUidByBundleName_0100 success - cycle count: %{public}d", stLevel_.BMSLevel);
2345     }
2346     EXPECT_TRUE(result);
2347     std::cout << "END GetUidByBundleName_0100" << std::endl;
2348 }
2349 
2350 /**
2351  * @tc.number: GetUidByBundleName_0200
2352  * @tc.name: test query UID
2353  * @tc.desc: 1.under '/data/test/bms_bundle',there is a hap
2354  *           2.install the hap
2355  *           3.query UID by bundleName with wrong userid
2356  */
2357 HWTEST_F(ActsBmsKitSystemTest, GetUidByBundleName_0200, Function | MediumTest | Level1)
2358 {
2359     std::cout << "START GetUidByBundleName_0200" << std::endl;
2360     bool result = false;
2361     for (int i = 1; i <= stLevel_.BMSLevel; i++) {
2362         std::vector<std::string> resvec;
2363         std::string hapFilePath = THIRD_BUNDLE_PATH + "bmsThirdBundle1.hap";
2364         std::string bundleName = BASE_BUNDLE_NAME + "1";
2365         Install(hapFilePath, InstallFlag::REPLACE_EXISTING, resvec);
2366 
2367         CommonTool commonTool;
2368         std::string installResult = commonTool.VectorToStr(resvec);
2369         EXPECT_EQ(installResult, "Success") << "install fail!";
2370         sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
2371         ASSERT_NE(bundleMgrProxy, nullptr);
2372 
2373         int userId = Constants::INVALID_USERID;
2374         int uid = bundleMgrProxy->GetUidByBundleName(bundleName, userId);
2375         EXPECT_EQ(uid, Constants::INVALID_USERID);
2376         resvec.clear();
2377         Uninstall(bundleName, resvec);
2378         std::string uninstallResult = commonTool.VectorToStr(resvec);
2379         EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!";
2380 
2381         if (uid != Constants::INVALID_UID) {
2382             APP_LOGI("GetUidByBundleName_0200 failed - cycle count: %{public}d", i);
2383             break;
2384         }
2385         result = true;
2386     }
2387 
2388     if (result && stLevel_.BMSLevel > 1) {
2389         APP_LOGI("GetUidByBundleName_0200 success - cycle count: %{public}d", stLevel_.BMSLevel);
2390     }
2391     EXPECT_TRUE(result);
2392     std::cout << "END GetUidByBundleName_0200" << std::endl;
2393 }
2394 
2395 /**
2396  * @tc.number: GetUidByBundleName_0300
2397  * @tc.name: test query UID
2398  * @tc.desc: 1.under '/data/test/bms_bundle',there is a hap
2399  *           2.install the hap
2400  *           3.query UID by wrong bundleName
2401  */
2402 HWTEST_F(ActsBmsKitSystemTest, GetUidByBundleName_0300, Function | MediumTest | Level2)
2403 {
2404     std::cout << "START GetUidByBundleName_0300" << std::endl;
2405     bool result = false;
2406     for (int i = 1; i <= stLevel_.BMSLevel; i++) {
2407         std::vector<std::string> resvec;
2408         std::string hapFilePath = THIRD_BUNDLE_PATH + "bmsThirdBundle1.hap";
2409         std::string bundleName = BASE_BUNDLE_NAME + "1";
2410         Install(hapFilePath, InstallFlag::REPLACE_EXISTING, resvec);
2411 
2412         CommonTool commonTool;
2413         int userId = Constants::DEFAULT_USERID;
2414         std::string installResult = commonTool.VectorToStr(resvec);
2415         EXPECT_EQ(installResult, "Success") << "install fail!";
2416         sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
2417         ASSERT_NE(bundleMgrProxy, nullptr);
2418 
2419         bundleName = BASE_BUNDLE_NAME + "e";
2420         int uid = bundleMgrProxy->GetUidByBundleName(bundleName, userId);
2421         EXPECT_EQ(uid, Constants::INVALID_UID);
2422 
2423         resvec.clear();
2424         bundleName = BASE_BUNDLE_NAME + "1";
2425         Uninstall(bundleName, resvec);
2426         std::string uninstallResult = commonTool.VectorToStr(resvec);
2427         EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!";
2428 
2429         if (uid != Constants::INVALID_UID) {
2430             APP_LOGI("GetUidByBundleName_0300 failed - cycle count: %{public}d", i);
2431             break;
2432         }
2433         result = true;
2434     }
2435 
2436     if (result && stLevel_.BMSLevel > 1) {
2437         APP_LOGI("GetUidByBundleName_0300 success - cycle count: %{public}d", stLevel_.BMSLevel);
2438     }
2439     EXPECT_TRUE(result);
2440     std::cout << "END GetUidByBundleName_0300" << std::endl;
2441 }
2442 
2443 /**
2444  * @tc.number: GetUidByBundleName_0400
2445  * @tc.name: test GetUidByBundleName interface
2446  * @tc.desc: 1.under '/system/app',there is a hap
2447  *           2.call GetUidByBundleName
2448  */
2449 HWTEST_F(ActsBmsKitSystemTest, GetUidByBundleName_0400, Function | MediumTest | Level1)
2450 {
2451     std::cout << "START GetUidByBundleName_0400" << std::endl;
2452     CommonTool commonTool;
2453     std::vector<std::string> resvec;
2454     std::string bundleFilePath = THIRD_BUNDLE_PATH + "bmsThirdBundle1.hap";
2455     std::string appName = BASE_BUNDLE_NAME + "1";
2456     Install(bundleFilePath, InstallFlag::REPLACE_EXISTING, resvec);
2457 
2458     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
2459     ASSERT_NE(bundleMgrProxy, nullptr);
2460 
2461     int uid = bundleMgrProxy->GetUidByBundleName(appName, USERID);
2462     EXPECT_GE(uid, Constants::BASE_USER_RANGE);
2463 
2464     resvec.clear();
2465     Uninstall(appName, resvec);
2466     std::string uninstallResult = commonTool.VectorToStr(resvec);
2467     EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!";
2468     std::cout << "END GetUidByBundleName_0400" << std::endl;
2469 }
2470 
2471 /**
2472  * @tc.number: GetUidByBundleName_0500
2473  * @tc.name: test query UID
2474  * @tc.desc: 1.under '/data/test/bms_bundle',there is a hap
2475  *           2.install the hap
2476  *           3.query UID by empty bundleName
2477  */
2478 HWTEST_F(ActsBmsKitSystemTest, GetUidByBundleName_0500, Function | MediumTest | Level1)
2479 {
2480     std::cout << "START GetUidByBundleName_0500" << std::endl;
2481     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
2482     ASSERT_NE(bundleMgrProxy, nullptr);
2483 
2484     std::string bundleName = "";
2485     int uid = bundleMgrProxy->GetUidByBundleName(bundleName, USERID);
2486     EXPECT_EQ(uid, Constants::INVALID_UID);
2487     std::cout << "END GetUidByBundleName_0500" << std::endl;
2488 }
2489 
2490 /**
2491  * @tc.number: GetUidByBundleName_0600
2492  * @tc.name: test query UID
2493  * @tc.desc: 1.under '/data/test/bms_bundle',there is a hap
2494  *           2.install the hap
2495  *           3.query UID by empty bundleName
2496  */
2497 HWTEST_F(ActsBmsKitSystemTest, GetUidByBundleName_0600, Function | MediumTest | Level1)
2498 {
2499     std::cout << "START GetUidByBundleName_0600" << std::endl;
2500     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
2501     ASSERT_NE(bundleMgrProxy, nullptr);
2502 
2503     std::string bundleName = "";
2504     int uid = bundleMgrProxy->GetUidByBundleName(bundleName, USERID, 0);
2505     EXPECT_EQ(uid, Constants::INVALID_UID);
2506     std::cout << "END GetUidByBundleName_0600" << std::endl;
2507 }
2508 
2509 /**
2510  * @tc.number: GetAppType_0100
2511  * @tc.name: test GetAppType interface
2512  * @tc.desc: 1.under '/data/test/bms_bundle',there is a hap
2513  *           2.install the hap
2514  *           3.call GetAppType
2515  */
2516 HWTEST_F(ActsBmsKitSystemTest, GetAppType_0100, Function | MediumTest | Level1)
2517 {
2518     std::cout << "START GetAppType_0100" << std::endl;
2519     bool result = false;
2520     for (int i = 1; i <= stLevel_.BMSLevel; i++) {
2521         std::vector<std::string> resvec;
2522         std::string bundleFilePath = THIRD_BUNDLE_PATH + "bmsThirdBundle1.hap";
2523         std::string appName = BASE_BUNDLE_NAME + "1";
2524         Install(bundleFilePath, InstallFlag::REPLACE_EXISTING, resvec);
2525 
2526         CommonTool commonTool;
2527         std::string installResult = commonTool.VectorToStr(resvec);
2528         EXPECT_EQ(installResult, "Success") << "install fail!";
2529         sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
2530         ASSERT_NE(bundleMgrProxy, nullptr);
2531 
2532         std::string appType = bundleMgrProxy->GetAppType(appName);
2533         EXPECT_EQ(appType, EMPTY_STRING);
2534         resvec.clear();
2535         Uninstall(appName, resvec);
2536         std::string uninstallResult = commonTool.VectorToStr(resvec);
2537         EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!";
2538 
2539         if (std::strcmp(appType.c_str(), "") != 0) {
2540             APP_LOGI("GetAppType_0100 failed - cycle count: %{public}d", i);
2541             break;
2542         }
2543         result = true;
2544     }
2545 
2546     if (result && stLevel_.BMSLevel > 1) {
2547         APP_LOGI("GetAppType_0100 success - cycle count: %{public}d", stLevel_.BMSLevel);
2548     }
2549     EXPECT_TRUE(result);
2550     std::cout << "END GetAppType_0100" << std::endl;
2551 }
2552 
2553 /**
2554  * @tc.number: GetAppType_0200
2555  * @tc.name: test GetAppType interface
2556  * @tc.desc: 1.under '/system/app/',there is a hap
2557  *           2.install the hap
2558  *           3.call GetAppType
2559  */
2560 HWTEST_F(ActsBmsKitSystemTest, GetAppType_0200, Function | MediumTest | Level1)
2561 {
2562     std::cout << "START GetAppType_0200" << std::endl;
2563     bool result = false;
2564     for (int i = 1; i <= stLevel_.BMSLevel; i++) {
2565         std::vector<std::string> resvec;
2566         sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
2567         ASSERT_NE(bundleMgrProxy, nullptr);
2568 
2569         std::string appType = bundleMgrProxy->GetAppType(SYSTEM_SETTINGS_BUNDLE_NAME);
2570         EXPECT_EQ(appType, EMPTY_STRING);
2571 
2572         if (std::strcmp(appType.c_str(), "") != 0) {
2573             APP_LOGI("GetAppType_0200 failed - cycle count: %{public}d", i);
2574             break;
2575         }
2576         result = true;
2577     }
2578 
2579     if (result && stLevel_.BMSLevel > 1) {
2580         APP_LOGI("GetAppType_0200 success - cycle count: %{public}d", stLevel_.BMSLevel);
2581     }
2582     EXPECT_TRUE(result);
2583     std::cout << "END GetAppType_0200" << std::endl;
2584 }
2585 
2586 /**
2587  * @tc.number: GetAppType_0300
2588  * @tc.name: test GetAppType interface
2589  * @tc.desc: 1.under '/data/test/bms_bundle',there is a hap
2590  *           2.install the hap
2591  *           3.call GetAppType by wrong appName
2592  */
2593 HWTEST_F(ActsBmsKitSystemTest, GetAppType_0300, Function | MediumTest | Level2)
2594 {
2595     std::cout << "START GetAppType_0300" << std::endl;
2596     bool result = false;
2597     for (int i = 1; i <= stLevel_.BMSLevel; i++) {
2598         std::vector<std::string> resvec;
2599         std::string bundleFilePath = THIRD_BUNDLE_PATH + "bmsThirdBundle1.hap";
2600         std::string appName = BASE_BUNDLE_NAME + "1";
2601         std::string errName = BASE_BUNDLE_NAME + "e";
2602         Install(bundleFilePath, InstallFlag::REPLACE_EXISTING, resvec);
2603 
2604         CommonTool commonTool;
2605         std::string installResult = commonTool.VectorToStr(resvec);
2606         EXPECT_EQ(installResult, "Success") << "install fail!";
2607         sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
2608         ASSERT_NE(bundleMgrProxy, nullptr);
2609 
2610         std::string appType = bundleMgrProxy->GetAppType(errName);
2611         EXPECT_EQ(appType, EMPTY_STRING);
2612         resvec.clear();
2613         Uninstall(appName, resvec);
2614         std::string uninstallResult = commonTool.VectorToStr(resvec);
2615         EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!";
2616 
2617         if (std::strcmp(appType.c_str(), (EMPTY_STRING).c_str()) != 0) {
2618             APP_LOGI("GetAppType_0300 failed - cycle count: %{public}d", i);
2619             break;
2620         }
2621         result = true;
2622     }
2623 
2624     if (result && stLevel_.BMSLevel > 1) {
2625         APP_LOGI("GetAppType_0300 success - cycle count: %{public}d", stLevel_.BMSLevel);
2626     }
2627     EXPECT_TRUE(result);
2628     std::cout << "END GetAppType_0300" << std::endl;
2629 }
2630 
2631 /**
2632  * @tc.number: GetAppType_0400
2633  * @tc.name: test GetAppType interface
2634  * @tc.desc: 1.under '/data/test/bms_bundle',there is a hap
2635  *           2.install the hap
2636  *           3.call GetAppType by empty appName
2637  */
2638 HWTEST_F(ActsBmsKitSystemTest, GetAppType_0400, Function | MediumTest | Level2)
2639 {
2640         sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
2641         ASSERT_NE(bundleMgrProxy, nullptr);
2642 
2643         std::string appType = bundleMgrProxy->GetAppType("");
2644         EXPECT_EQ(appType, EMPTY_STRING);
2645 }
2646 
2647 /**
2648  * @tc.number: GetAppType_0500
2649  * @tc.name: test GetAppType interface
2650  * @tc.desc: 1.under '/data/test/bms_bundle',there is a hap with invalid suffix
2651  *           2.install the hap
2652  *           3.call GetAppType
2653  */
2654 HWTEST_F(ActsBmsKitSystemTest, GetAppType_0500, Function | MediumTest | Level2)
2655 {
2656     std::cout << "START GetAppType_0500" << std::endl;
2657     bool result = false;
2658     for (int i = 1; i <= stLevel_.BMSLevel; i++) {
2659         std::vector<std::string> resvec;
2660         std::string bundleFilePath = THIRD_BUNDLE_PATH + "bmsThirdBundle28.rpk";
2661         std::string appName = BASE_BUNDLE_NAME + "5";
2662         Install(bundleFilePath, InstallFlag::REPLACE_EXISTING, resvec);
2663 
2664         CommonTool commonTool;
2665         std::string installResult = commonTool.VectorToStr(resvec);
2666         EXPECT_NE(installResult, "Success");
2667         sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
2668         ASSERT_NE(bundleMgrProxy, nullptr);
2669 
2670         std::string appType = bundleMgrProxy->GetAppType(appName);
2671         EXPECT_EQ(appType, EMPTY_STRING);
2672 
2673         if (std::strcmp(appType.c_str(), (EMPTY_STRING).c_str()) != 0) {
2674             APP_LOGI("GetAppType_0500 failed - cycle count: %{public}d", i);
2675             break;
2676         }
2677         result = true;
2678     }
2679 
2680     if (result && stLevel_.BMSLevel > 1) {
2681         APP_LOGI("GetAppType_0500 success - cycle count: %{public}d", stLevel_.BMSLevel);
2682     }
2683     EXPECT_TRUE(result);
2684     std::cout << "END GetAppType_0500" << std::endl;
2685 }
2686 
2687 /**
2688  * @tc.number: GetAbilityLabel_0100
2689  * @tc.name: test GetAbilityLabel interface
2690  * @tc.desc: 1.under '/data/test/bms_bundle',there is a hap
2691  *           2.install the hap
2692  *           3.call GetAbilityLabel
2693  */
2694 HWTEST_F(ActsBmsKitSystemTest, GetAbilityLabel_0100, Function | MediumTest | Level1)
2695 {
2696     std::cout << "START GetAbilityLabel_0100" << std::endl;
2697     bool result = false;
2698     for (int i = 1; i <= stLevel_.BMSLevel; i++) {
2699         std::vector<std::string> resvec;
2700         std::string bundleFilePath = THIRD_BUNDLE_PATH + "bmsThirdBundle1.hap";
2701         std::string appName = BASE_BUNDLE_NAME + "1";
2702         std::string abilityName = BASE_ABILITY_NAME;
2703         std::string label = "$string:MainAbility_label";
2704         Install(bundleFilePath, InstallFlag::REPLACE_EXISTING, resvec);
2705 
2706         CommonTool commonTool;
2707         std::string installResult = commonTool.VectorToStr(resvec);
2708         EXPECT_EQ(installResult, "Success") << "install fail!";
2709         sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
2710         ASSERT_NE(bundleMgrProxy, nullptr);
2711 
2712         std::string abilityLabel = bundleMgrProxy->GetAbilityLabel(appName, abilityName);
2713         ErrCode abilityLabel1 = bundleMgrProxy->GetAbilityLabel(appName, abilityName, BASE_MODULE_NAME, label);
2714         EXPECT_NE(abilityLabel, "EMPTY_STRING");
2715         EXPECT_NE(abilityLabel1, ERR_OK);
2716         resvec.clear();
2717         Uninstall(appName, resvec);
2718         std::string uninstallResult = commonTool.VectorToStr(resvec);
2719         EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!";
2720 
2721         if (std::strcmp(abilityLabel.c_str(), "EMPTY_STRING") == 0) {
2722             APP_LOGI("GetAbilityLabel_0100 failed - cycle count: %{public}d", i);
2723             break;
2724         }
2725         result = true;
2726     }
2727 
2728     if (result && stLevel_.BMSLevel > 1) {
2729         APP_LOGI("GetAbilityLabel_0100 success - cycle count: %{public}d", stLevel_.BMSLevel);
2730     }
2731     EXPECT_TRUE(result);
2732     std::cout << "END GetAbilityLabel_0100" << std::endl;
2733 }
2734 
2735 /**
2736  * @tc.number: GetAbilityLabel_0300
2737  * @tc.name: test GetAbilityLabel interface
2738  * @tc.desc: 1.under '/data/test/bms_bundle',there is a hap
2739  *           2.install the hap
2740  *           3.call GetAbilityLabel with wrong appName
2741  */
2742 HWTEST_F(ActsBmsKitSystemTest, GetAbilityLabel_0300, Function | MediumTest | Level1)
2743 {
2744     std::cout << "START GetAbilityLabel_0300" << std::endl;
2745     bool result = false;
2746     for (int i = 1; i <= stLevel_.BMSLevel; i++) {
2747         std::vector<std::string> resvec;
2748         std::string bundleFilePath = THIRD_BUNDLE_PATH + "bmsThirdBundle1.hap";
2749         std::string appName = BASE_BUNDLE_NAME + "1";
2750         std::string abilityName = BASE_ABILITY_NAME;
2751         std::string label = "$string:MainAbility_label";
2752         Install(bundleFilePath, InstallFlag::REPLACE_EXISTING, resvec);
2753 
2754         CommonTool commonTool;
2755         std::string installResult = commonTool.VectorToStr(resvec);
2756         EXPECT_EQ(installResult, "Success") << "install fail!";
2757         sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
2758         ASSERT_NE(bundleMgrProxy, nullptr);
2759 
2760         std::string errAppName = BASE_BUNDLE_NAME + "e";
2761         std::string abilityLabel = bundleMgrProxy->GetAbilityLabel(errAppName, abilityName);
2762         ErrCode abilityLabel1 = bundleMgrProxy->GetAbilityLabel("", abilityName, BASE_MODULE_NAME, label);
2763         EXPECT_EQ(abilityLabel, EMPTY_STRING);
2764         EXPECT_NE(abilityLabel1, ERR_OK);
2765         resvec.clear();
2766         Uninstall(appName, resvec);
2767         std::string uninstallResult = commonTool.VectorToStr(resvec);
2768         EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!";
2769 
2770         if (std::strcmp(abilityLabel.c_str(), (EMPTY_STRING).c_str()) != 0) {
2771             APP_LOGI("GetAbilityLabel_0300 failed - cycle count: %{public}d", i);
2772             break;
2773         }
2774         result = true;
2775     }
2776 
2777     if (result && stLevel_.BMSLevel > 1) {
2778         APP_LOGI("GetAbilityLabel_0300 success - cycle count: %{public}d", stLevel_.BMSLevel);
2779     }
2780     EXPECT_TRUE(result);
2781     std::cout << "END GetAbilityLabel_0300" << std::endl;
2782 }
2783 
2784 /**
2785  * @tc.number: GetAbilityLabel_0400
2786  * @tc.name: test GetAbilityLabel interface
2787  * @tc.desc: 1.under '/data/test/bms_bundle',there is a hap
2788  *           2.install the hap
2789  *           3.call GetAbilityLabel with wrong abilityname
2790  */
2791 HWTEST_F(ActsBmsKitSystemTest, GetAbilityLabel_0400, Function | MediumTest | Level1)
2792 {
2793     std::cout << "START GetAbilityLabel_0400" << std::endl;
2794     bool result = false;
2795     for (int i = 1; i <= stLevel_.BMSLevel; i++) {
2796         std::vector<std::string> resvec;
2797         std::string bundleFilePath = THIRD_BUNDLE_PATH + "bmsThirdBundle1.hap";
2798         std::string appName = BASE_BUNDLE_NAME + "1";
2799         std::string errAbilityName = "MainAbility";
2800         Install(bundleFilePath, InstallFlag::REPLACE_EXISTING, resvec);
2801 
2802         CommonTool commonTool;
2803         std::string installResult = commonTool.VectorToStr(resvec);
2804         EXPECT_EQ(installResult, "Success") << "install fail!";
2805         sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
2806         ASSERT_NE(bundleMgrProxy, nullptr);
2807 
2808         std::string abilityLabel = bundleMgrProxy->GetAbilityLabel(appName, errAbilityName);
2809         EXPECT_EQ(abilityLabel, EMPTY_STRING);
2810         resvec.clear();
2811         Uninstall(appName, resvec);
2812         std::string uninstallResult = commonTool.VectorToStr(resvec);
2813         EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!";
2814 
2815         if (std::strcmp(abilityLabel.c_str(), (EMPTY_STRING).c_str()) != 0) {
2816             APP_LOGI("GetAbilityLabel_0400 failed - cycle count: %{public}d", i);
2817             break;
2818         }
2819         result = true;
2820     }
2821 
2822     if (result && stLevel_.BMSLevel > 1) {
2823         APP_LOGI("GetAbilityLabel_0400 success - cycle count: %{public}d", stLevel_.BMSLevel);
2824     }
2825     EXPECT_TRUE(result);
2826     std::cout << "END GetAbilityLabel_0400" << std::endl;
2827 }
2828 
2829 /**
2830  * @tc.number: GetAbilityLabel_0500
2831  * @tc.name: test GetAbilityLabel interface
2832  * @tc.desc: 1.under '/data/test/bms_bundle',there is a hap
2833  *           2.install the hap
2834  *           3.call GetAbilityLabel with empty abilityname
2835  */
2836 HWTEST_F(ActsBmsKitSystemTest, GetAbilityLabel_0500, Function | MediumTest | Level1)
2837 {
2838     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
2839     ASSERT_NE(bundleMgrProxy, nullptr);
2840 
2841     std::string abilityLabel = bundleMgrProxy->GetAbilityLabel("", "");
2842     EXPECT_EQ(abilityLabel, EMPTY_STRING);
2843 }
2844 
2845 /**
2846  * @tc.number: GetAbilityLabel_0600
2847  * @tc.name: test GetAbilityLabel interface
2848  * @tc.desc: 1.under '/data/test/bms_bundle',there is a hap with invalid suffix
2849  *           2.install the hap
2850  *           3.call GetAbilityLabel
2851  */
2852 HWTEST_F(ActsBmsKitSystemTest, GetAbilityLabel_0600, Function | MediumTest | Level2)
2853 {
2854     std::cout << "START GetAbilityLabel_0600" << std::endl;
2855     bool result = false;
2856     for (int i = 1; i <= stLevel_.BMSLevel; i++) {
2857         std::vector<std::string> resvec;
2858         std::string bundleFilePath = THIRD_BUNDLE_PATH + "bmsThirdBundle28.rpk";
2859         std::string appName = BASE_BUNDLE_NAME + "5";
2860         std::string abilityName = "MainAbility";
2861         Install(bundleFilePath, InstallFlag::REPLACE_EXISTING, resvec);
2862 
2863         CommonTool commonTool;
2864         std::string installResult = commonTool.VectorToStr(resvec);
2865         EXPECT_NE(installResult, "Success");
2866         sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
2867         ASSERT_NE(bundleMgrProxy, nullptr);
2868 
2869         std::string abilityLabel = bundleMgrProxy->GetAbilityLabel(appName, abilityName);
2870         EXPECT_EQ(abilityLabel, EMPTY_STRING);
2871 
2872         if (std::strcmp(abilityLabel.c_str(), (EMPTY_STRING).c_str()) != 0) {
2873             APP_LOGI("GetAbilityLabel_0600 failed - cycle count: %{public}d", i);
2874             break;
2875         }
2876         result = true;
2877     }
2878 
2879     if (result && stLevel_.BMSLevel > 1) {
2880         APP_LOGI("GetAbilityLabel_0600 success - cycle count: %{public}d", stLevel_.BMSLevel);
2881     }
2882     EXPECT_TRUE(result);
2883     std::cout << "END GetAbilityLabel_0600" << std::endl;
2884 }
2885 
2886 /**
2887  * @tc.number: GetHapModuleInfo_0100
2888  * @tc.name: test GetHapModuleInfo interface
2889  * @tc.desc: 1.under '/data/test/bms_bundle',there is a hap with one ability
2890  *           2.install the hap
2891  *           3.call GetHapModuleInfo
2892  */
2893 HWTEST_F(ActsBmsKitSystemTest, GetHapModuleInfo_0100, Function | MediumTest | Level1)
2894 {
2895     std::cout << "START GetHapModuleInfo_0100" << std::endl;
2896     bool result = false;
2897     for (int i = 1; i <= stLevel_.BMSLevel; i++) {
2898         std::vector<std::string> resvec;
2899         std::string bundleFilePath = THIRD_BUNDLE_PATH + "bmsThirdBundle1.hap";
2900         std::string appName = BASE_BUNDLE_NAME + "1";
2901         Install(bundleFilePath, InstallFlag::REPLACE_EXISTING, resvec);
2902 
2903         CommonTool commonTool;
2904         std::string installResult = commonTool.VectorToStr(resvec);
2905         EXPECT_EQ(installResult, "Success") << "install fail!";
2906 
2907         AbilityInfo abilityInfo;
2908         abilityInfo.bundleName = appName;
2909         abilityInfo.package = BASE_BUNDLE_NAME + ".h1";
2910         HapModuleInfo hapModuleInfo;
2911         sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
2912         ASSERT_NE(bundleMgrProxy, nullptr);
2913 
2914         bool queryResult = bundleMgrProxy->GetHapModuleInfo(abilityInfo, USERID, hapModuleInfo);
2915         EXPECT_TRUE(queryResult);
2916 
2917         EXPECT_EQ(hapModuleInfo.name, "bmsThirdBundle1");
2918         EXPECT_EQ(hapModuleInfo.moduleName, BASE_MODULE_NAME);
2919         EXPECT_EQ(hapModuleInfo.description, "");
2920 
2921         resvec.clear();
2922         Uninstall(appName, resvec);
2923         std::string uninstallResult = commonTool.VectorToStr(resvec);
2924         EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!";
2925 
2926         if (!queryResult) {
2927             APP_LOGI("GetHapModuleInfo_0100 failed - cycle count: %{public}d", i);
2928             break;
2929         }
2930         result = true;
2931     }
2932 
2933     if (result && stLevel_.BMSLevel > 1) {
2934         APP_LOGI("GetHapModuleInfo_0100 success - cycle count: %{public}d", stLevel_.BMSLevel);
2935     }
2936     EXPECT_TRUE(result);
2937     std::cout << "END GetHapModuleInfo_0100" << std::endl;
2938 }
2939 
2940 /**
2941  * @tc.number: GetHapModuleInfo_0200
2942  * @tc.name: test GetHapModuleInfo interface
2943  * @tc.desc: 1.under '/data/test/bms_bundle',there is a hap with two abilities
2944  *           2.install the hap
2945  *           3.call GetHapModuleInfo
2946  */
2947 HWTEST_F(ActsBmsKitSystemTest, GetHapModuleInfo_0200, Function | MediumTest | Level1)
2948 {
2949     std::cout << "START GetHapModuleInfo_0200" << std::endl;
2950     bool result = false;
2951     for (int i = 1; i <= stLevel_.BMSLevel; i++) {
2952         std::vector<std::string> resvec;
2953         std::string bundleFilePath = THIRD_BUNDLE_PATH + "bmsThirdBundle2.hap";
2954         std::string appName = BASE_BUNDLE_NAME + "1";
2955         Install(bundleFilePath, InstallFlag::REPLACE_EXISTING, resvec);
2956         CommonTool commonTool;
2957         EXPECT_EQ(commonTool.VectorToStr(resvec), "Success") << "install fail!";
2958         AbilityInfo abilityInfo;
2959         abilityInfo.bundleName = appName;
2960         abilityInfo.package = BASE_BUNDLE_NAME + ".h1";
2961         HapModuleInfo hapModuleInfo;
2962         sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
2963         ASSERT_NE(bundleMgrProxy, nullptr);
2964 
2965         bool queryResult = bundleMgrProxy->GetHapModuleInfo(abilityInfo, hapModuleInfo);
2966         EXPECT_TRUE(queryResult);
2967         EXPECT_EQ(hapModuleInfo.name, "bmsThirdBundle2");
2968         EXPECT_EQ(hapModuleInfo.moduleName, "testability");
2969         bool isSubStrExist = false;
2970         for (int i = 1; i <= 2; i++) {
2971             std::string abilityName = "" + std::to_string(i);
2972             for (auto hapModuleInfo : hapModuleInfo.abilityInfos) {
2973                 if (IsSubStr(hapModuleInfo.name, abilityName)) {
2974                     isSubStrExist = true;
2975                     break;
2976                 }
2977             }
2978             EXPECT_TRUE(isSubStrExist);
2979         }
2980         resvec.clear();
2981         Uninstall(appName, resvec);
2982         EXPECT_EQ(commonTool.VectorToStr(resvec), "Success") << "uninstall fail!";
2983 
2984         if (!queryResult) {
2985             APP_LOGI("GetHapModuleInfo_0200 failed - cycle count: %{public}d", i);
2986             break;
2987         }
2988         result = true;
2989     }
2990     if (result && stLevel_.BMSLevel > 1) {
2991         APP_LOGI("GetHapModuleInfo_0200 success - cycle count: %{public}d", stLevel_.BMSLevel);
2992     }
2993     EXPECT_TRUE(result);
2994     std::cout << "END GetHapModuleInfo_0200" << std::endl;
2995 }
2996 
2997 /**
2998  * @tc.number: GetHapModuleInfo_0300
2999  * @tc.name: test GetHapModuleInfo interface
3000  * @tc.desc: 1.under '/data/test/bms_bundle',there is a hap without an ability
3001  *           2.install the hap
3002  *           3.call GetHapModuleInfo
3003  */
3004 HWTEST_F(ActsBmsKitSystemTest, GetHapModuleInfo_0300, Function | MediumTest | Level1)
3005 {
3006     std::cout << "START GetHapModuleInfo_0300" << std::endl;
3007     bool result = false;
3008     for (int i = 1; i <= stLevel_.BMSLevel; i++) {
3009         std::vector<std::string> resvec;
3010         std::string bundleFilePath = THIRD_BUNDLE_PATH + "bmsThirdBundle3.hap";
3011         std::string appName = BASE_BUNDLE_NAME + "1";
3012         Install(bundleFilePath, InstallFlag::REPLACE_EXISTING, resvec);
3013 
3014         CommonTool commonTool;
3015         std::string installResult = commonTool.VectorToStr(resvec);
3016         EXPECT_EQ(installResult, "Success") << "install fail!";
3017 
3018         AbilityInfo abilityInfo;
3019         abilityInfo.bundleName = appName;
3020         abilityInfo.package = BASE_BUNDLE_NAME + ".h1";
3021         HapModuleInfo hapModuleInfo;
3022         sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
3023         ASSERT_NE(bundleMgrProxy, nullptr);
3024 
3025         bool queryResult = bundleMgrProxy->GetHapModuleInfo(abilityInfo, hapModuleInfo);
3026         EXPECT_TRUE(queryResult);
3027         EXPECT_EQ(hapModuleInfo.name, "bmsThirdBundle3");
3028         EXPECT_EQ(hapModuleInfo.moduleName, "testability3");
3029         resvec.clear();
3030 
3031         Uninstall(appName, resvec);
3032         std::string uninstallResult = commonTool.VectorToStr(resvec);
3033         EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!";
3034 
3035         if (!queryResult) {
3036             APP_LOGI("GetHapModuleInfo_0300 failed - cycle count: %{public}d", i);
3037             break;
3038         }
3039         result = true;
3040     }
3041 
3042     if (result && stLevel_.BMSLevel > 1) {
3043         APP_LOGI("GetHapModuleInfo_0300 success - cycle count: %{public}d", stLevel_.BMSLevel);
3044     }
3045     EXPECT_TRUE(result);
3046     std::cout << "END GetHapModuleInfo_0300" << std::endl;
3047 }
3048 
3049 /**
3050  * @tc.number: GetHapModuleInfo_0400
3051  * @tc.name: test GetHapModuleInfo interface
3052  * @tc.desc: 1.under '/data/test/bms_bundle',there is a hap
3053  *           2.install the hap
3054  *           3.use error bundleName to get moduleInfo
3055  */
3056 HWTEST_F(ActsBmsKitSystemTest, GetHapModuleInfo_0400, Function | MediumTest | Level1)
3057 {
3058     std::cout << "START GetHapModuleInfo_0400" << std::endl;
3059     bool result = false;
3060     for (int i = 1; i <= stLevel_.BMSLevel; i++) {
3061         std::vector<std::string> resvec;
3062         std::string bundleFilePath = THIRD_BUNDLE_PATH + "bmsThirdBundle7.hap";
3063         std::string appName = BASE_BUNDLE_NAME + "2";
3064         Install(bundleFilePath, InstallFlag::REPLACE_EXISTING, resvec);
3065 
3066         CommonTool commonTool;
3067         std::string installResult = commonTool.VectorToStr(resvec);
3068         EXPECT_EQ(installResult, "Success") << "install fail!";
3069 
3070         AbilityInfo abilityInfo;
3071         abilityInfo.bundleName = "error_bundleName";
3072         abilityInfo.package = BASE_BUNDLE_NAME + ".h2";
3073         HapModuleInfo hapModuleInfo;
3074 
3075         sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
3076         ASSERT_NE(bundleMgrProxy, nullptr);
3077 
3078         bool queryResult = bundleMgrProxy->GetHapModuleInfo(abilityInfo, hapModuleInfo);
3079         EXPECT_FALSE(queryResult);
3080         resvec.clear();
3081         Uninstall(appName, resvec);
3082         std::string uninstallResult = commonTool.VectorToStr(resvec);
3083         EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!";
3084 
3085         if (queryResult) {
3086             APP_LOGI("GetHapModuleInfo_0400 failed - cycle count: %{public}d", i);
3087             break;
3088         }
3089         result = true;
3090     }
3091 
3092     if (result && stLevel_.BMSLevel > 1) {
3093         APP_LOGI("GetHapModuleInfo_0400 success - cycle count: %{public}d", stLevel_.BMSLevel);
3094     }
3095     EXPECT_TRUE(result);
3096     std::cout << "END GetHapModuleInfo_0400" << std::endl;
3097 }
3098 
3099 /**
3100  * @tc.number: GetHapModuleInfo_0500
3101  * @tc.name: test GetHapModuleInfo interface
3102  * @tc.desc: 1.under '/data/test/bms_bundle',there is a hap
3103  *           2.install the hap
3104  *           3.use empty bundleName to get moduleInfo
3105  */
3106 HWTEST_F(ActsBmsKitSystemTest, GetHapModuleInfo_0500, Function | MediumTest | Level1)
3107 {
3108     AbilityInfo abilityInfo;
3109     abilityInfo.bundleName = "";
3110     abilityInfo.package = BASE_BUNDLE_NAME + ".h2";
3111     HapModuleInfo hapModuleInfo;
3112 
3113     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
3114     ASSERT_NE(bundleMgrProxy, nullptr);
3115 
3116     bool queryResult = bundleMgrProxy->GetHapModuleInfo(abilityInfo, hapModuleInfo);
3117     EXPECT_FALSE(queryResult);
3118 }
3119 
3120 /**
3121  * @tc.number: GetHapModuleInfo_0600
3122  * @tc.name: test GetHapModuleInfo interface
3123  * @tc.desc: 1.under '/data/test/bms_bundle',there is a hap with invalid suffix
3124  *           2.install the hap
3125  *           3.call GetHapModuleInfo
3126  */
3127 HWTEST_F(ActsBmsKitSystemTest, GetHapModuleInfo_0600, Function | MediumTest | Level2)
3128 {
3129     std::cout << "START GetHapModuleInfo_0600" << std::endl;
3130     bool result = false;
3131     for (int i = 1; i <= stLevel_.BMSLevel; i++) {
3132         std::vector<std::string> resvec;
3133         std::string bundleFilePath = THIRD_BUNDLE_PATH + "bmsThirdBundle28.rpk";
3134         std::string appName = BASE_BUNDLE_NAME + "5";
3135         Install(bundleFilePath, InstallFlag::REPLACE_EXISTING, resvec);
3136 
3137         CommonTool commonTool;
3138         std::string installResult = commonTool.VectorToStr(resvec);
3139         EXPECT_NE(installResult, "Success") << "install fail!";
3140 
3141         AbilityInfo abilityInfo;
3142         abilityInfo.bundleName = appName;
3143         abilityInfo.package = BASE_BUNDLE_NAME + ".h2";
3144         HapModuleInfo hapModuleInfo;
3145         sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
3146         ASSERT_NE(bundleMgrProxy, nullptr);
3147 
3148         bool queryResult = bundleMgrProxy->GetHapModuleInfo(abilityInfo, hapModuleInfo);
3149         EXPECT_FALSE(queryResult);
3150 
3151         if (queryResult) {
3152             APP_LOGI("GetHapModuleInfo_0600 failed - cycle count: %{public}d", i);
3153             break;
3154         }
3155         result = true;
3156     }
3157 
3158     if (result && stLevel_.BMSLevel > 1) {
3159         APP_LOGI("GetHapModuleInfo_0600 success - cycle count: %{public}d", stLevel_.BMSLevel);
3160     }
3161     EXPECT_TRUE(result);
3162     std::cout << "END GetHapModuleInfo_0600" << std::endl;
3163 }
3164 
3165 /**
3166  * @tc.number: GetHapModuleInfo_0700
3167  * @tc.name: test GetHapModuleInfo interface
3168  * @tc.desc: 1.under '/data/test/bms_bundle',there is a hap
3169  *           2.install the hap
3170  *           3.use empty package to get moduleInfo
3171  */
3172 HWTEST_F(ActsBmsKitSystemTest, GetHapModuleInfo_0700, Function | MediumTest | Level1)
3173 {
3174     AbilityInfo abilityInfo;
3175     abilityInfo.bundleName = THIRD_BUNDLE_PATH + "bmsThirdBundle7.hap";
3176     abilityInfo.package = "";
3177     HapModuleInfo hapModuleInfo;
3178 
3179     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
3180     ASSERT_NE(bundleMgrProxy, nullptr);
3181 
3182     bool queryResult = bundleMgrProxy->GetHapModuleInfo(abilityInfo, hapModuleInfo);
3183     EXPECT_FALSE(queryResult);
3184 }
3185 
3186 /**
3187  * @tc.number: GetHapModuleInfo_0800
3188  * @tc.name: test GetHapModuleInfo interface
3189  * @tc.desc: 1.bundleName and package is null
3190  */
3191 HWTEST_F(ActsBmsKitSystemTest, GetHapModuleInfo_0800, Function | MediumTest | Level1)
3192 {
3193     AbilityInfo abilityInfo;
3194     abilityInfo.bundleName = "";
3195     abilityInfo.package = "package";
3196     HapModuleInfo hapModuleInfo;
3197 
3198     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
3199     ASSERT_NE(bundleMgrProxy, nullptr);
3200 
3201     bool queryResult = bundleMgrProxy->GetHapModuleInfo(abilityInfo, hapModuleInfo);
3202     EXPECT_FALSE(queryResult);
3203 
3204     abilityInfo.bundleName = "bundleName";
3205     abilityInfo.package = "";
3206 
3207     queryResult = bundleMgrProxy->GetHapModuleInfo(abilityInfo, hapModuleInfo);
3208     EXPECT_FALSE(queryResult);
3209 }
3210 
3211 
3212 /**
3213  * @tc.number: GetHapModuleInfo_0900
3214  * @tc.name: test GetHapModuleInfo interface
3215  * @tc.desc: 1.under '/data/test/bms_bundle',there is a hap with one ability
3216  *           2.install the hap
3217  *           3.call GetHapModuleInfo
3218  */
3219 HWTEST_F(ActsBmsKitSystemTest, GetHapModuleInfo_0900, Function | MediumTest | Level1)
3220 {
3221     std::cout << "START GetHapModuleInfo_0900" << std::endl;
3222     AbilityInfo abilityInfo;
3223     abilityInfo.bundleName = EMPTY_BUNDLE_NAME;
3224     abilityInfo.package = EMPTY_BUNDLE_NAME;
3225     HapModuleInfo hapModuleInfo;
3226     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
3227     ASSERT_NE(bundleMgrProxy, nullptr);
3228 
3229     bool queryResult = bundleMgrProxy->GetHapModuleInfo(abilityInfo, USERID, hapModuleInfo);
3230     EXPECT_FALSE(queryResult);
3231     std::cout << "END GetHapModuleInfo_0900" << std::endl;
3232 }
3233 
3234 /**
3235  * @tc.number: GetLaunchWantForBundle_0100
3236  * @tc.name: test GetLaunchWantForBundle interface
3237  * @tc.desc: 1.bundleNameis null
3238  */
3239 HWTEST_F(ActsBmsKitSystemTest, GetLaunchWantForBundle_0100, Function | MediumTest | Level1)
3240 {
3241     std::string bundleName = "";
3242     Want want;
3243 
3244     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
3245     ASSERT_NE(bundleMgrProxy, nullptr);
3246 
3247     auto queryResult = bundleMgrProxy->GetLaunchWantForBundle(bundleName, want, USERID);
3248     EXPECT_NE(queryResult, ERR_OK);
3249 }
3250 
3251 /**
3252  * @tc.number: Callback_0100
3253  * @tc.name: 1.test RegisterBundleStatusCallback interface
3254  *           2.test UnregisterBundleStatusCallback interface
3255  * @tc.desc: 1.under '/data/test/bms_bundle',there exists a normal hap
3256  *           2.call RegisterBundleStatusCallback
3257  *           3.install the hap
3258  *           4.call UnregisterBundleStatusCallback
3259  */
3260 HWTEST_F(ActsBmsKitSystemTest, Callback_0100, Function | MediumTest | Level1)
3261 {
3262     StartProcess();
3263     std::cout << "START Callback_0100" << std::endl;
3264     bool result = false;
3265     for (int i = 1; i <= stLevel_.BMSLevel; i++) {
3266         std::vector<std::string> resvec;
3267         std::string bundleFilePath = THIRD_BUNDLE_PATH + "bmsThirdBundle1.hap";
3268         std::string appName = BASE_BUNDLE_NAME + "1";
3269 
3270         CommonTool commonTool;
3271         sptr<BundleStatusCallbackImpl> bundleStatusCallback = (new (std::nothrow) BundleStatusCallbackImpl());
3272         EXPECT_NE(bundleStatusCallback, nullptr);
3273         bundleStatusCallback->SetBundleName(appName);
3274         sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
3275         ASSERT_NE(bundleMgrProxy, nullptr);
3276 
3277         bundleMgrProxy->RegisterBundleStatusCallback(bundleStatusCallback);
3278         Install(bundleFilePath, InstallFlag::REPLACE_EXISTING, resvec);
3279         std::string installResult = commonTool.VectorToStr(resvec);
3280         EXPECT_EQ(installResult, "Success") << "install fail!";
3281 
3282         bool unRegResult = bundleMgrProxy->UnregisterBundleStatusCallback();
3283         EXPECT_TRUE(unRegResult);
3284 
3285         resvec.clear();
3286         Uninstall(appName, resvec);
3287         std::string uninstallResult = commonTool.VectorToStr(resvec);
3288         EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!";
3289 
3290         if (!unRegResult) {
3291             APP_LOGI("Callback_0100 failed - cycle count: %{public}d", i);
3292             break;
3293         }
3294         result = true;
3295     }
3296 
3297     if (result && stLevel_.BMSLevel > 1) {
3298         APP_LOGI("Callback_0100 success - cycle count: %{public}d", stLevel_.BMSLevel);
3299     }
3300     EXPECT_TRUE(result);
3301     std::cout << "END Callback_0100" << std::endl;
3302 }
3303 
3304 /**
3305  * @tc.number: Callback_0300
3306  * @tc.name: 1.test RegisterBundleStatusCallback interface
3307  *           2.test UnregisterBundleStatusCallback interface
3308  * @tc.desc: 1.under '/data/test/bms_bundle',there exists two bundles,one's version is
3309  *                    higher than the other
3310  *           2.call RegisterBundleStatusCallback
3311  *           3.install the hap
3312  *           4.upgrade the hap
3313  *           5.call UnregisterBundleStatusCallback
3314  */
3315 HWTEST_F(ActsBmsKitSystemTest, Callback_0300, Function | MediumTest | Level1)
3316 {
3317     StartProcess();
3318     std::cout << "START Callback_0300" << std::endl;
3319     bool result = false;
3320     for (int i = 1; i <= stLevel_.BMSLevel; i++) {
3321         std::vector<std::string> resvec;
3322         std::string firstFilePath = THIRD_BUNDLE_PATH + "bmsThirdBundle7.hap";
3323         std::string appName = BASE_BUNDLE_NAME + "2";
3324         std::string secondFilePath = THIRD_BUNDLE_PATH + "bmsThirdBundle9.hap";
3325 
3326         CommonTool commonTool;
3327         sptr<BundleStatusCallbackImpl> bundleStatusCallback = (new (std::nothrow) BundleStatusCallbackImpl());
3328         EXPECT_NE(bundleStatusCallback, nullptr);
3329         bundleStatusCallback->SetBundleName(appName);
3330         sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
3331         ASSERT_NE(bundleMgrProxy, nullptr);
3332 
3333         bundleMgrProxy->RegisterBundleStatusCallback(bundleStatusCallback);
3334         Install(firstFilePath, InstallFlag::REPLACE_EXISTING, resvec);
3335         std::string installResult = commonTool.VectorToStr(resvec);
3336         EXPECT_EQ(installResult, "Success") << "install fail!";
3337 
3338         resvec.clear();
3339         Install(secondFilePath, InstallFlag::REPLACE_EXISTING, resvec);
3340         std::string upgradeResult = commonTool.VectorToStr(resvec);
3341         EXPECT_EQ(upgradeResult, "Success") << "upgrade fail!";
3342         bool unRegResult = bundleMgrProxy->UnregisterBundleStatusCallback();
3343         EXPECT_TRUE(unRegResult);
3344 
3345         std::vector<std::string> resvec2;
3346         Uninstall(appName, resvec2);
3347         std::string uninstallResult = commonTool.VectorToStr(resvec2);
3348         EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!";
3349 
3350         if (!unRegResult) {
3351             APP_LOGI("Callback_0300 failed - cycle count: %{public}d", i);
3352             break;
3353         }
3354         result = true;
3355     }
3356 
3357     if (result && stLevel_.BMSLevel > 1) {
3358         APP_LOGI("Callback_0300 success - cycle count: %{public}d", stLevel_.BMSLevel);
3359     }
3360     EXPECT_TRUE(result);
3361     std::cout << "END Callback_0300" << std::endl;
3362 }
3363 
3364 /**
3365  * @tc.number: Callback_0400
3366  * @tc.name: 1.test RegisterBundleStatusCallback interface
3367  *           2.test UnregisterBundleStatusCallback interface
3368  * @tc.desc: 1.under '/data/test/bms_bundle',there exists two bundles,one's version is
3369  *                    equal than the other
3370  *           2.call RegisterBundleStatusCallback
3371  *           3.install the hap
3372  *           4.upgrade the hap
3373  *           5.call UnregisterBundleStatusCallback
3374  */
3375 HWTEST_F(ActsBmsKitSystemTest, Callback_0400, Function | MediumTest | Level1)
3376 {
3377     StartProcess();
3378     std::cout << "START Callback_0400" << std::endl;
3379     bool result = false;
3380     for (int i = 1; i <= stLevel_.BMSLevel; i++) {
3381         std::vector<std::string> resvec;
3382         std::string firstFilePath = THIRD_BUNDLE_PATH + "bmsThirdBundle7.hap";
3383         std::string appName = BASE_BUNDLE_NAME + "2";
3384         std::string secondFilePath = THIRD_BUNDLE_PATH + "bmsThirdBundle10.hap";
3385 
3386         CommonTool commonTool;
3387         sptr<BundleStatusCallbackImpl> bundleStatusCallback = (new (std::nothrow) BundleStatusCallbackImpl());
3388         EXPECT_NE(bundleStatusCallback, nullptr);
3389         bundleStatusCallback->SetBundleName(appName);
3390         sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
3391         ASSERT_NE(bundleMgrProxy, nullptr);
3392 
3393         bundleMgrProxy->RegisterBundleStatusCallback(bundleStatusCallback);
3394         Install(firstFilePath, InstallFlag::REPLACE_EXISTING, resvec);
3395         std::string installResult = commonTool.VectorToStr(resvec);
3396         EXPECT_EQ(installResult, "Success") << "install fail!";
3397 
3398         resvec.clear();
3399         Install(secondFilePath, InstallFlag::REPLACE_EXISTING, resvec);
3400         std::string upgradeResult = commonTool.VectorToStr(resvec);
3401         EXPECT_EQ(upgradeResult, "Success") << "upgrade fail!";
3402         bool unRegResult = bundleMgrProxy->UnregisterBundleStatusCallback();
3403         EXPECT_TRUE(unRegResult);
3404 
3405         std::vector<std::string> resvec2;
3406         Uninstall(appName, resvec2);
3407         std::string uninstallResult = commonTool.VectorToStr(resvec2);
3408         EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!";
3409 
3410         if (!unRegResult) {
3411             APP_LOGI("Callback_0400 failed - cycle count: %{public}d", i);
3412             break;
3413         }
3414         result = true;
3415     }
3416 
3417     if (result && stLevel_.BMSLevel > 1) {
3418         APP_LOGI("Callback_0400 success - cycle count: %{public}d", stLevel_.BMSLevel);
3419     }
3420     EXPECT_TRUE(result);
3421     std::cout << "END Callback_0400" << std::endl;
3422 }
3423 
3424 /**
3425  * @tc.number: Callback_0500
3426  * @tc.name: 1.test RegisterBundleStatusCallback interface
3427  *           2.test UnregisterBundleStatusCallback interface
3428  * @tc.desc: 1.under '/data/test/bms_bundle',there exists two bundles,one's version is
3429  *                    lower than the other
3430  *           2.call RegisterBundleStatusCallback
3431  *           3.install the hap
3432  *           4.upgrade the hap
3433  *           5.call UnregisterBundleStatusCallback
3434  */
3435 HWTEST_F(ActsBmsKitSystemTest, Callback_0500, Function | MediumTest | Level1)
3436 {
3437     StartProcess();
3438     std::cout << "START Callback_0500" << std::endl;
3439     bool result = false;
3440     for (int i = 1; i <= stLevel_.BMSLevel; i++) {
3441         std::vector<std::string> resvec;
3442         std::string firstFilePath = THIRD_BUNDLE_PATH + "bmsThirdBundle9.hap";
3443         std::string appName = BASE_BUNDLE_NAME + "2";
3444         std::string secondFilePath = THIRD_BUNDLE_PATH + "bmsThirdBundle10.hap";
3445 
3446         CommonTool commonTool;
3447         sptr<BundleStatusCallbackImpl> bundleStatusCallback = (new (std::nothrow) BundleStatusCallbackImpl());
3448         EXPECT_NE(bundleStatusCallback, nullptr);
3449         bundleStatusCallback->SetBundleName(appName);
3450         sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
3451         ASSERT_NE(bundleMgrProxy, nullptr);
3452 
3453         bundleMgrProxy->RegisterBundleStatusCallback(bundleStatusCallback);
3454         Install(firstFilePath, InstallFlag::REPLACE_EXISTING, resvec);
3455         std::string installResult = commonTool.VectorToStr(resvec);
3456         EXPECT_EQ(installResult, "Success") << "install fail!";
3457 
3458         resvec.clear();
3459         Install(secondFilePath, InstallFlag::REPLACE_EXISTING, resvec);
3460         std::string upgradeResult = commonTool.VectorToStr(resvec);
3461         EXPECT_NE(upgradeResult, "Success") << "upgrade success!";
3462         bool unRegResult = bundleMgrProxy->UnregisterBundleStatusCallback();
3463         EXPECT_TRUE(unRegResult);
3464 
3465         std::vector<std::string> resvec2;
3466         Uninstall(appName, resvec2);
3467         std::string uninstallResult = commonTool.VectorToStr(resvec2);
3468         EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!";
3469 
3470         if (!unRegResult) {
3471             APP_LOGI("Callback_0500 failed - cycle count: %{public}d", i);
3472             break;
3473         }
3474         result = true;
3475     }
3476 
3477     if (result && stLevel_.BMSLevel > 1) {
3478         APP_LOGI("Callback_0500 success - cycle count: %{public}d", stLevel_.BMSLevel);
3479     }
3480     EXPECT_TRUE(result);
3481     std::cout << "END Callback_0500" << std::endl;
3482 }
3483 
3484 /**
3485  * @tc.number: Callback_0600
3486  * @tc.name: 1.test RegisterBundleStatusCallback interface
3487  *           2.test ClearBundleStatusCallback interface
3488  * @tc.desc: 1.under '/data/test/bms_bundle',there is a hap
3489  *           2.call RegisterBundleStatusCallback
3490  *           3.install the hap
3491  *           4.call ClearBundleStatusCallback
3492  */
3493 HWTEST_F(ActsBmsKitSystemTest, Callback_0600, Function | MediumTest | Level1)
3494 {
3495     StartProcess();
3496     std::cout << "START Callback_0600" << std::endl;
3497     bool result = false;
3498     for (int i = 1; i <= stLevel_.BMSLevel; i++) {
3499         std::vector<std::string> resvec;
3500         std::string filePath = THIRD_BUNDLE_PATH + "bmsThirdBundle1.hap";
3501         std::string appName = BASE_BUNDLE_NAME + "1";
3502 
3503         CommonTool commonTool;
3504         sptr<BundleStatusCallbackImpl> bundleStatusCallback = (new (std::nothrow) BundleStatusCallbackImpl());
3505         EXPECT_NE(bundleStatusCallback, nullptr);
3506         bundleStatusCallback->SetBundleName(appName);
3507         sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
3508         ASSERT_NE(bundleMgrProxy, nullptr);
3509 
3510         bundleMgrProxy->RegisterBundleStatusCallback(bundleStatusCallback);
3511         Install(filePath, InstallFlag::REPLACE_EXISTING, resvec);
3512         std::string installResult = commonTool.VectorToStr(resvec);
3513         EXPECT_EQ(installResult, "Success") << "install fail!";
3514         bool clearResult = bundleMgrProxy->ClearBundleStatusCallback(bundleStatusCallback);
3515         EXPECT_TRUE(clearResult);
3516         resvec.clear();
3517         Uninstall(appName, resvec);
3518         std::string uninstallResult = commonTool.VectorToStr(resvec);
3519         EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!";
3520 
3521         if (!clearResult) {
3522             APP_LOGI("Callback_0600 failed - cycle count: %{public}d", i);
3523             break;
3524         }
3525         result = true;
3526     }
3527 
3528     if (result && stLevel_.BMSLevel > 1) {
3529         APP_LOGI("Callback_0600 success - cycle count: %{public}d", stLevel_.BMSLevel);
3530     }
3531     EXPECT_TRUE(result);
3532     std::cout << "END Callback_0600" << std::endl;
3533 }
3534 
3535 /**
3536  * @tc.number: Callback_0700
3537  * @tc.name: 1.test RegisterBundleStatusCallback interface
3538  *           2.test ClearBundleStatusCallback interface
3539  * @tc.desc: 1.under '/data/test/bms_bundle',there 1exists two bundles
3540  *           2.call RegisterBundleStatusCallback
3541  *           3.install the first hap
3542  *           4.call RegisterBundleStatusCallback
3543  *           5.install the second hap
3544  *           6.call ClearBundleStatusCallback
3545  */
3546 HWTEST_F(ActsBmsKitSystemTest, Callback_0700, Function | MediumTest | Level1)
3547 {
3548     StartProcess();
3549     std::cout << "START Callback_0700" << std::endl;
3550     bool result = false;
3551     for (int i = 1; i <= stLevel_.BMSLevel; i++) {
3552         std::vector<std::string> resvec;
3553         std::string firstFilePath = THIRD_BUNDLE_PATH + "bmsThirdBundle1.hap";
3554         std::string firstAppName = BASE_BUNDLE_NAME + "1";
3555         std::string secondFilePath = THIRD_BUNDLE_PATH + "bmsThirdBundle7.hap";
3556         std::string secondAppName = BASE_BUNDLE_NAME + "2";
3557         CommonTool commonTool;
3558         sptr<BundleStatusCallbackImpl> firstBundleStatusCallback = (new (std::nothrow) BundleStatusCallbackImpl());
3559         EXPECT_NE(firstBundleStatusCallback, nullptr);
3560         firstBundleStatusCallback->SetBundleName(firstAppName);
3561         sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
3562         ASSERT_NE(bundleMgrProxy, nullptr);
3563 
3564         bundleMgrProxy->RegisterBundleStatusCallback(firstBundleStatusCallback);
3565         Install(firstFilePath, InstallFlag::REPLACE_EXISTING, resvec);
3566         EXPECT_EQ(commonTool.VectorToStr(resvec), "Success") << "install fail!";
3567         resvec.clear();
3568         sptr<BundleStatusCallbackImpl> secondBundleStatusCallback = (new (std::nothrow) BundleStatusCallbackImpl());
3569         EXPECT_NE(secondBundleStatusCallback, nullptr);
3570         secondBundleStatusCallback->SetBundleName(secondAppName);
3571         bundleMgrProxy->RegisterBundleStatusCallback(secondBundleStatusCallback);
3572         Install(secondFilePath, InstallFlag::REPLACE_EXISTING, resvec);
3573         EXPECT_EQ(commonTool.VectorToStr(resvec), "Success") << "install fail!";
3574         bool clearResult = bundleMgrProxy->ClearBundleStatusCallback(firstBundleStatusCallback);
3575         EXPECT_TRUE(clearResult);
3576         std::vector<std::string> resvec2;
3577         Uninstall(firstAppName, resvec2);
3578         EXPECT_EQ(commonTool.VectorToStr(resvec2), "Success") << "uninstall fail!";
3579         resvec2.clear();
3580         Uninstall(secondAppName, resvec2);
3581         EXPECT_EQ(commonTool.VectorToStr(resvec2), "Success") << "uninstall fail!";
3582         if (!clearResult) {
3583             APP_LOGI("Callback_0700 failed - cycle count: %{public}d", i);
3584             break;
3585         }
3586         result = true;
3587     }
3588     if (result && stLevel_.BMSLevel > 1) {
3589         APP_LOGI("Callback_0700 success - cycle count: %{public}d", stLevel_.BMSLevel);
3590     }
3591     EXPECT_TRUE(result);
3592     std::cout << "END Callback_0700" << std::endl;
3593 }
3594 
3595 /**
3596  * @tc.number: Callback_0800
3597  * @tc.name: 1.test RegisterBundleStatusCallback interface
3598  *           2.test ClearBundleStatusCallback interface
3599  * @tc.desc: 1.under '/data/test/bms_bundle',there exists two bundles
3600  *           2.call RegisterBundleStatusCallback
3601  *           3.install the first hap
3602  *           4.call RegisterBundleStatusCallback
3603  *           5.install the second hap
3604  *           6.call ClearBundleStatusCallback
3605  */
3606 HWTEST_F(ActsBmsKitSystemTest, Callback_0800, Function | MediumTest | Level1)
3607 {
3608     StartProcess();
3609     std::cout << "START Callback_0800" << std::endl;
3610     bool result = false;
3611     for (int i = 1; i <= stLevel_.BMSLevel; i++) {
3612         std::vector<std::string> resvec;
3613         std::string firstFilePath = THIRD_BUNDLE_PATH + "bmsThirdBundle1.hap";
3614         std::string firstAppName = BASE_BUNDLE_NAME + "1";
3615         std::string secondFilePath = THIRD_BUNDLE_PATH + "bmsThirdBundle7.hap";
3616         std::string secondAppName = BASE_BUNDLE_NAME + "2";
3617         CommonTool commonTool;
3618         sptr<BundleStatusCallbackImpl> firstBundleStatusCallback = (new (std::nothrow) BundleStatusCallbackImpl());
3619         EXPECT_NE(firstBundleStatusCallback, nullptr);
3620         firstBundleStatusCallback->SetBundleName(firstAppName);
3621         sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
3622         ASSERT_NE(bundleMgrProxy, nullptr);
3623 
3624         bundleMgrProxy->RegisterBundleStatusCallback(firstBundleStatusCallback);
3625         Install(firstFilePath, InstallFlag::REPLACE_EXISTING, resvec);
3626         std::string firstinstallResult = commonTool.VectorToStr(resvec);
3627         EXPECT_EQ(firstinstallResult, "Success") << "install fail!";
3628         resvec.clear();
3629         sptr<BundleStatusCallbackImpl> secondBundleStatusCallback = (new (std::nothrow) BundleStatusCallbackImpl());
3630         EXPECT_NE(secondBundleStatusCallback, nullptr);
3631         secondBundleStatusCallback->SetBundleName(secondAppName);
3632         bundleMgrProxy->RegisterBundleStatusCallback(secondBundleStatusCallback);
3633         Install(secondFilePath, InstallFlag::REPLACE_EXISTING, resvec);
3634         std::string secondinstallResult = commonTool.VectorToStr(resvec);
3635         EXPECT_EQ(secondinstallResult, "Success") << "install fail!";
3636         bool clearResult = bundleMgrProxy->ClearBundleStatusCallback(secondBundleStatusCallback);
3637         EXPECT_TRUE(clearResult);
3638         std::vector<std::string> resvec2;
3639         Uninstall(firstAppName, resvec2);
3640         EXPECT_EQ(commonTool.VectorToStr(resvec2), "Success") << "uninstall fail!";
3641         resvec2.clear();
3642         Uninstall(secondAppName, resvec2);
3643         EXPECT_EQ(commonTool.VectorToStr(resvec2), "Success") << "uninstall fail!";
3644         if (!clearResult) {
3645             APP_LOGI("Callback_0800 failed - cycle count: %{public}d", i);
3646             break;
3647         }
3648         result = true;
3649     }
3650     if (result && stLevel_.BMSLevel > 1) {
3651         APP_LOGI("Callback_0800 success - cycle count: %{public}d", stLevel_.BMSLevel);
3652     }
3653     EXPECT_TRUE(result);
3654     std::cout << "END Callback_0800" << std::endl;
3655 }
3656 
3657 /**
3658  * @tc.number: Callback_0900
3659  * @tc.name: 1.test RegisterBundleStatusCallback interface
3660  *           2.test ClearBundleStatusCallback interface
3661  * @tc.desc: 1.under '/data/test/bms_bundle',there exists two bundles
3662  *           2.call RegisterBundleStatusCallback
3663  *           3.install the first hap
3664  *           4.call RegisterBundleStatusCallback
3665  *           5.install the second hap
3666  *           6.call ClearBundleStatusCallback
3667  *           7.call ClearBundleStatusCallback
3668  */
3669 HWTEST_F(ActsBmsKitSystemTest, Callback_0900, Function | MediumTest | Level1)
3670 {
3671     StartProcess();
3672     std::cout << "START Callback_0900" << std::endl;
3673     bool result = false;
3674     for (int i = 1; i <= stLevel_.BMSLevel; i++) {
3675         std::vector<std::string> resvec;
3676         std::string firstFilePath = THIRD_BUNDLE_PATH + "bmsThirdBundle1.hap";
3677         std::string firstAppName = BASE_BUNDLE_NAME + "1";
3678         std::string secondFilePath = THIRD_BUNDLE_PATH + "bmsThirdBundle7.hap";
3679         std::string secondAppName = BASE_BUNDLE_NAME + "2";
3680         CommonTool commonTool;
3681         sptr<BundleStatusCallbackImpl> firstBundleStatusCallback = (new (std::nothrow) BundleStatusCallbackImpl());
3682         EXPECT_NE(firstBundleStatusCallback, nullptr);
3683         firstBundleStatusCallback->SetBundleName(firstAppName);
3684         sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
3685         ASSERT_NE(bundleMgrProxy, nullptr);
3686 
3687         bundleMgrProxy->RegisterBundleStatusCallback(firstBundleStatusCallback);
3688         Install(firstFilePath, InstallFlag::REPLACE_EXISTING, resvec);
3689         EXPECT_EQ(commonTool.VectorToStr(resvec), "Success") << "install fail!";
3690         resvec.clear();
3691         sptr<BundleStatusCallbackImpl> secondBundleStatusCallback = (new (std::nothrow) BundleStatusCallbackImpl());
3692         EXPECT_NE(secondBundleStatusCallback, nullptr);
3693         secondBundleStatusCallback->SetBundleName(secondAppName);
3694         bundleMgrProxy->RegisterBundleStatusCallback(secondBundleStatusCallback);
3695         Install(secondFilePath, InstallFlag::REPLACE_EXISTING, resvec);
3696         EXPECT_EQ(commonTool.VectorToStr(resvec), "Success") << "install fail!";
3697         bool clearResult1 = bundleMgrProxy->ClearBundleStatusCallback(firstBundleStatusCallback);
3698         EXPECT_TRUE(clearResult1);
3699         bool clearResult2 = bundleMgrProxy->ClearBundleStatusCallback(secondBundleStatusCallback);
3700         EXPECT_TRUE(clearResult2);
3701         std::vector<std::string> resvec2;
3702         Uninstall(firstAppName, resvec2);
3703         EXPECT_EQ(commonTool.VectorToStr(resvec2), "Success") << "uninstall fail!";
3704         resvec2.clear();
3705         Uninstall(secondAppName, resvec2);
3706         EXPECT_EQ(commonTool.VectorToStr(resvec2), "Success") << "uninstall fail!";
3707         if (!clearResult1 && !clearResult2) {
3708             APP_LOGI("Callback_0900 failed - cycle count: %{public}d", i);
3709             break;
3710         }
3711         result = true;
3712     }
3713     if (result && stLevel_.BMSLevel > 1) {
3714         APP_LOGI("Callback_0900 success - cycle count: %{public}d", stLevel_.BMSLevel);
3715     }
3716     EXPECT_TRUE(result);
3717     std::cout << "END Callback_0900" << std::endl;
3718 }
3719 
3720 /**
3721  * @tc.number: Callback_1000
3722  * @tc.name: Test SetBundleName
3723  * @tc.desc: 1.Test the SetBundleName of IBundleStatusCallback
3724  */
3725 HWTEST_F(ActsBmsKitSystemTest, Callback_1000, Function | MediumTest | Level1)
3726 {
3727     StartProcess();
3728     sptr<IBundleStatusCallback> callBack = (new (std::nothrow) BundleStatusCallbackImpl());
3729     EXPECT_NE(callBack, nullptr);
3730     callBack->SetBundleName(BASE_BUNDLE_NAME);
3731     std::string ret = callBack->GetBundleName();
3732     EXPECT_EQ(ret, BASE_BUNDLE_NAME);
3733 }
3734 
3735 /**
3736  * @tc.number: Callback_1100
3737  * @tc.name: 1.test RegisterBundleStatusCallback interface
3738  * @tc.desc: 1.install the first hap
3739  *           4.call RegisterBundleStatusCallback
3740  */
3741 HWTEST_F(ActsBmsKitSystemTest, Callback_1100, Function | MediumTest | Level1)
3742 {
3743     StartProcess();
3744     sptr<BundleStatusCallbackImpl> firstBundleStatusCallback = (new (std::nothrow) BundleStatusCallbackImpl());
3745     EXPECT_NE(firstBundleStatusCallback, nullptr);
3746     firstBundleStatusCallback->SetBundleName("");
3747 
3748     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
3749     ASSERT_NE(bundleMgrProxy, nullptr);
3750 
3751     bool res = bundleMgrProxy->RegisterBundleStatusCallback(firstBundleStatusCallback);
3752     EXPECT_EQ(res, false);
3753 
3754     res = bundleMgrProxy->RegisterBundleStatusCallback(nullptr);
3755     EXPECT_EQ(res, false);
3756 
3757     res = bundleMgrProxy->ClearBundleStatusCallback(nullptr);
3758     EXPECT_EQ(res, false);
3759 }
3760 
3761 /**
3762  * @tc.number: QueryAbilityInfo_0100
3763  * @tc.name: test QueryAbilityInfo interface
3764  * @tc.desc: 1.under '/data/test/bms_bundle',there is a hap
3765  *           2.install the hap
3766  *           3.call QueryAbilityInfo
3767  */
3768 HWTEST_F(ActsBmsKitSystemTest, QueryAbilityInfo_0100, Function | MediumTest | Level1)
3769 {
3770     std::cout << "START QueryAbilityInfo_0100" << std::endl;
3771     bool result = false;
3772     for (int i = 1; i <= stLevel_.BMSLevel; i++) {
3773         std::vector<std::string> resvec;
3774         std::string bundleFilePath = THIRD_BUNDLE_PATH + "bmsThirdBundle1.hap";
3775         std::string appName = BASE_BUNDLE_NAME + "1";
3776         std::string abilityName = BASE_ABILITY_NAME;
3777         Install(bundleFilePath, InstallFlag::REPLACE_EXISTING, resvec);
3778 
3779         CommonTool commonTool;
3780         std::string installResult = commonTool.VectorToStr(resvec);
3781         EXPECT_EQ(installResult, "Success") << "install fail!";
3782 
3783         Want want;
3784         ElementName name;
3785         name.SetAbilityName(abilityName);
3786         name.SetBundleName(appName);
3787         want.SetElement(name);
3788 
3789         AbilityInfo abilityInfo;
3790         sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
3791         ASSERT_NE(bundleMgrProxy, nullptr);
3792 
3793         int32_t flags = 4;
3794         bool queryResult = bundleMgrProxy->QueryAbilityInfo(want, flags, USERID, abilityInfo);
3795         EXPECT_TRUE(queryResult);
3796         EXPECT_EQ(abilityInfo.name, abilityName);
3797         EXPECT_EQ(abilityInfo.bundleName, appName);
3798 
3799         resvec.clear();
3800         Uninstall(appName, resvec);
3801         std::string uninstallResult = commonTool.VectorToStr(resvec);
3802         EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!";
3803 
3804         if (!queryResult) {
3805             APP_LOGI("QueryAbilityInfo_0100 failed - cycle count: %{public}d", i);
3806             break;
3807         }
3808         result = true;
3809     }
3810 
3811     if (result && stLevel_.BMSLevel > 1) {
3812         APP_LOGI("QueryAbilityInfo_0100 success - cycle count: %{public}d", stLevel_.BMSLevel);
3813     }
3814     EXPECT_TRUE(result);
3815     std::cout << "END QueryAbilityInfo_0100" << std::endl;
3816 }
3817 
3818 /**
3819  * @tc.number: QueryAbilityInfo_0200
3820  * @tc.name: QueryAbilityInfo
3821  * @tc.desc: query data then verify
3822  */
3823 HWTEST_F(ActsBmsKitSystemTest, QueryAbilityInfo_0200, Function | MediumTest | Level0)
3824 {
3825     std::cout << "START QueryAbilityInfo_0200" << std::endl;
3826     bool result = false;
3827     for (int i = 1; i <= stLevel_.BMSLevel; i++) {
3828         std::vector<std::string> resvec;
3829         std::string bundleFilePath = THIRD_BUNDLE_PATH + "bmsThirdBundle3.hap";
3830         std::string appName = BASE_BUNDLE_NAME + "1";
3831         std::string abilityName = BASE_ABILITY_NAME;
3832         Install(bundleFilePath, InstallFlag::REPLACE_EXISTING, resvec);
3833 
3834         CommonTool commonTool;
3835         std::string installResult = commonTool.VectorToStr(resvec);
3836         EXPECT_EQ(installResult, "Success") << "install fail!";
3837 
3838         Want want;
3839         ElementName name;
3840         name.SetBundleName("xxx");
3841         want.SetElement(name);
3842 
3843         AbilityInfo abilityInfo;
3844         sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
3845         ASSERT_NE(bundleMgrProxy, nullptr);
3846 
3847         bool queryResult =
3848         bundleMgrProxy->QueryAbilityInfo(want, GET_ABILITY_INFO_WITH_APPLICATION, USERID, abilityInfo);
3849         EXPECT_FALSE(queryResult);
3850 
3851         resvec.clear();
3852         Uninstall(appName, resvec);
3853         std::string uninstallResult = commonTool.VectorToStr(resvec);
3854         EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!";
3855 
3856         if (queryResult) {
3857             APP_LOGI("QueryAbilityInfo_0200 failed - cycle count: %{public}d", i);
3858             break;
3859         }
3860         result = true;
3861     }
3862 
3863     if (result && stLevel_.BMSLevel > 1) {
3864         APP_LOGI("QueryAbilityInfo_0200 success - cycle count: %{public}d", stLevel_.BMSLevel);
3865     }
3866     EXPECT_TRUE(result);
3867     std::cout << "END QueryAbilityInfo_0200" << std::endl;
3868 }
3869 
3870 /**
3871  * @tc.number: QueryAbilityInfo_0300
3872  * @tc.name: test QueryAbilityInfo interface
3873  * @tc.desc: 1.under '/data/test/bms_bundle',there is a hap
3874  *           2.install the hap
3875  *           3.call QueryAbilityInfo
3876  */
3877 HWTEST_F(ActsBmsKitSystemTest, QueryAbilityInfo_0300, Function | MediumTest | Level1)
3878 {
3879     std::cout << "START QueryAbilityInfo_0300" << std::endl;
3880     bool result = false;
3881     for (int i = 1; i <= stLevel_.BMSLevel; i++) {
3882         std::vector<std::string> resvec;
3883         std::string bundleFilePath = THIRD_BUNDLE_PATH + "bmsThirdBundle1.hap";
3884         std::string appName = BASE_BUNDLE_NAME + "1";
3885         std::string abilityName = BASE_ABILITY_NAME;
3886         Install(bundleFilePath, InstallFlag::REPLACE_EXISTING, resvec);
3887 
3888         CommonTool commonTool;
3889         std::string installResult = commonTool.VectorToStr(resvec);
3890         EXPECT_EQ(installResult, "Success") << "install fail!";
3891 
3892         Want want;
3893         ElementName name;
3894         name.SetAbilityName(abilityName);
3895         name.SetBundleName(appName);
3896         want.SetElement(name);
3897 
3898         AbilityInfo abilityInfo;
3899         sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
3900         ASSERT_NE(bundleMgrProxy, nullptr);
3901 
3902         bool queryResult =
3903             bundleMgrProxy->QueryAbilityInfo(want, GET_ABILITY_INFO_WITH_APPLICATION, USERID, abilityInfo);
3904         EXPECT_TRUE(queryResult);
3905         EXPECT_EQ(abilityInfo.targetAbility, "");
3906 
3907         resvec.clear();
3908         Uninstall(appName, resvec);
3909         std::string uninstallResult = commonTool.VectorToStr(resvec);
3910         EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!";
3911 
3912         if (!queryResult) {
3913             APP_LOGI("QueryAbilityInfo_0100 failed - cycle count: %{public}d", i);
3914             break;
3915         }
3916         result = true;
3917     }
3918 
3919     if (result && stLevel_.BMSLevel > 1) {
3920         APP_LOGI("QueryAbilityInfo_0300 succecc - cycle count: %{public}d", stLevel_.BMSLevel);
3921     }
3922     EXPECT_TRUE(result);
3923     std::cout << "END QueryAbilityInfo_0300" << std::endl;
3924 }
3925 
3926 /**
3927  * @tc.number: QueryAbilityInfo_0400
3928  * @tc.name: test QueryAbilityInfo interface
3929  * @tc.desc: 1.under '/data/test/bms_bundle',there is a hap
3930  *           2.install the hap
3931  *           3.call QueryAbilityInfo
3932  */
3933 HWTEST_F(ActsBmsKitSystemTest, QueryAbilityInfo_0400, Function | MediumTest | Level1)
3934 {
3935     std::cout << "START QueryAbilityInfo_0400" << std::endl;
3936     bool result = false;
3937     for (int i = 1; i <= stLevel_.BMSLevel; i++) {
3938         std::vector<std::string> resvec;
3939         std::string bundleFilePath = THIRD_BUNDLE_PATH + "bmsThirdBundle1.hap";
3940         std::string appName = BASE_BUNDLE_NAME + "1";
3941         std::string abilityName = BASE_ABILITY_NAME;
3942         Install(bundleFilePath, InstallFlag::REPLACE_EXISTING, resvec);
3943 
3944         CommonTool commonTool;
3945         std::string installResult = commonTool.VectorToStr(resvec);
3946         EXPECT_EQ(installResult, "Success") << "install fail!";
3947 
3948         Want want;
3949         ElementName name;
3950         name.SetAbilityName(abilityName);
3951         name.SetBundleName(appName);
3952         want.SetElement(name);
3953 
3954         AbilityInfo abilityInfo;
3955         sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
3956         ASSERT_NE(bundleMgrProxy, nullptr);
3957 
3958         bool queryResult =
3959             bundleMgrProxy->QueryAbilityInfo(
3960                 want, GET_ABILITY_INFO_WITH_APPLICATION, USERID, abilityInfo, nullptr);
3961         EXPECT_FALSE(queryResult);
3962 
3963         resvec.clear();
3964         Uninstall(appName, resvec);
3965         std::string uninstallResult = commonTool.VectorToStr(resvec);
3966         EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!";
3967 
3968         if (!queryResult) {
3969             APP_LOGI("QueryAbilityInfo_0100 failed - cycle count: %{public}d", i);
3970             break;
3971         }
3972         result = true;
3973     }
3974 
3975     if (result && stLevel_.BMSLevel > 1) {
3976         APP_LOGI("QueryAbilityInfo_0400 succecc - cycle count: %{public}d", stLevel_.BMSLevel);
3977     }
3978     EXPECT_FALSE(result);
3979     std::cout << "END QueryAbilityInfo_0400" << std::endl;
3980 }
3981 
3982 /**
3983  * @tc.number: QueryAbilityInfo_0500
3984  * @tc.name: test QueryAbilityInfo interface
3985  * @tc.desc: 1.under '/data/test/bms_bundle',there is a hap
3986  *           2.install the hap
3987  *           3.call QueryAbilityInfo
3988  */
3989 HWTEST_F(ActsBmsKitSystemTest, QueryAbilityInfo_0500, Function | MediumTest | Level1)
3990 {
3991     std::vector<std::string> resvec;
3992     std::string bundleFilePath = THIRD_BUNDLE_PATH + "bmsThirdBundle1.hap";
3993     std::string appName = BASE_BUNDLE_NAME + "1";
3994     std::string abilityName = BASE_ABILITY_NAME;
3995     Install(bundleFilePath, InstallFlag::REPLACE_EXISTING, resvec);
3996 
3997     CommonTool commonTool;
3998     std::string installResult = commonTool.VectorToStr(resvec);
3999     EXPECT_EQ(installResult, "Success") << "install fail!";
4000 
4001     Want want;
4002     ElementName name;
4003     name.SetAbilityName(abilityName);
4004     name.SetBundleName(appName);
4005     want.SetElement(name);
4006     sptr<IRemoteObject> callBack;
4007     int32_t flags = 0;
4008 
4009     AbilityInfo abilityInfo;
4010     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
4011     ASSERT_NE(bundleMgrProxy, nullptr);
4012 
4013     bool queryResult =
4014         bundleMgrProxy->QueryAbilityInfo(
4015             want, flags, USERID, abilityInfo, callBack);
4016     EXPECT_FALSE(queryResult);
4017 
4018     resvec.clear();
4019     Uninstall(appName, resvec);
4020     std::string uninstallResult = commonTool.VectorToStr(resvec);
4021     EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!";
4022 }
4023 
4024 /**
4025  * @tc.number: QueryAbilityInfo_0600
4026  * @tc.name: test QueryAbilityInfo interface
4027  * @tc.desc: 1.under '/data/test/bms_bundle',there is a hap
4028  *           2.install the hap
4029  *           3.call QueryAbilityInfo
4030  */
4031 HWTEST_F(ActsBmsKitSystemTest, QueryAbilityInfo_0600, Function | MediumTest | Level1)
4032 {
4033     std::cout << "START QueryAbilityInfo_0600" << std::endl;
4034     std::vector<std::string> resvec;
4035     std::string bundleFilePath = THIRD_BUNDLE_PATH + "bmsThirdBundle1.hap";
4036     std::string appName = BASE_BUNDLE_NAME + "1";
4037     std::string abilityName = BASE_ABILITY_NAME;
4038     Install(bundleFilePath, InstallFlag::REPLACE_EXISTING, resvec);
4039 
4040     CommonTool commonTool;
4041     std::string installResult = commonTool.VectorToStr(resvec);
4042     EXPECT_EQ(installResult, "Success") << "install fail!";
4043 
4044     Want want;
4045     ElementName name;
4046     name.SetAbilityName(abilityName);
4047     name.SetBundleName(appName);
4048     want.SetElement(name);
4049 
4050     AbilityInfo abilityInfo;
4051     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
4052     ASSERT_NE(bundleMgrProxy, nullptr);
4053 
4054     int32_t flags = 4;
4055     sptr<ISystemAbilityManager> systemAbilityManager =
4056         SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
4057 
4058     sptr<IRemoteObject> remoteObject = systemAbilityManager->GetSystemAbility(BUNDLE_MGR_SERVICE_SYS_ABILITY_ID);
4059     bool queryResult = bundleMgrProxy->QueryAbilityInfo(want, flags, USERID, abilityInfo, remoteObject);
4060     EXPECT_TRUE(queryResult);
4061 
4062     resvec.clear();
4063     Uninstall(appName, resvec);
4064     std::string uninstallResult = commonTool.VectorToStr(resvec);
4065     EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!";
4066     std::cout << "END QueryAbilityInfo_0600" << std::endl;
4067 }
4068 
4069 /**
4070  * @tc.number: GetBundleInfosByMetaData_0100
4071  * @tc.name: test GetBundleInfosByMetaData interface
4072  * @tc.desc: 1.under '/data/test/bms_bundle',there is a hap
4073  *           2.install the hap
4074  *           3.call GetBundleInfosByMetaData
4075  */
4076 HWTEST_F(ActsBmsKitSystemTest, GetBundleInfosByMetaData_0100, Function | MediumTest | Level1)
4077 {
4078     std::cout << "START GetBundleInfosByMetaData_0100" << std::endl;
4079     bool result = false;
4080     for (int i = 1; i <= stLevel_.BMSLevel; i++) {
4081         std::vector<std::string> resvec;
4082         std::string bundleFilePath = THIRD_BUNDLE_PATH + "bmsThirdBundle17.hap";
4083         std::string appName = "com.third.hiworld.example6";
4084 
4085         Install(bundleFilePath, InstallFlag::REPLACE_EXISTING, resvec);
4086 
4087         CommonTool commonTool;
4088         std::string installResult = commonTool.VectorToStr(resvec);
4089         EXPECT_EQ(installResult, "Success") << "install fail!";
4090 
4091         std::vector<BundleInfo> bundleInfos;
4092 
4093         std::string metadata = "string";
4094         sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
4095         ASSERT_NE(bundleMgrProxy, nullptr);
4096 
4097         bool getResult = bundleMgrProxy->GetBundleInfosByMetaData(metadata, bundleInfos);
4098         EXPECT_TRUE(getResult);
4099 
4100         resvec.clear();
4101         Uninstall(appName, resvec);
4102         std::string uninstallResult = commonTool.VectorToStr(resvec);
4103         EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!";
4104 
4105         if (!getResult) {
4106             APP_LOGI("GetBundleInfosByMetaData_0100 failed - cycle count: %{public}d", i);
4107             break;
4108         }
4109         result = true;
4110     }
4111 
4112     if (result && stLevel_.BMSLevel > 1) {
4113         APP_LOGI("GetBundleInfosByMetaData_0100 success - cycle count: %{public}d", stLevel_.BMSLevel);
4114     }
4115     EXPECT_TRUE(result);
4116     std::cout << "END GetBundleInfosByMetaData_0100" << std::endl;
4117 }
4118 
4119 /**
4120  * @tc.number: GetBundleInfosByMetaData_0200
4121  * @tc.name: test GetBundleInfosByMetaData interface
4122  * @tc.desc: 1.call GetBundleInfosByMetaData
4123  */
4124 HWTEST_F(ActsBmsKitSystemTest, GetBundleInfosByMetaData_0200, Function | MediumTest | Level1)
4125 {
4126     std::cout << "START GetBundleInfosByMetaData_0200" << std::endl;
4127     bool result = false;
4128     for (int i = 1; i <= stLevel_.BMSLevel; i++) {
4129         std::vector<BundleInfo> bundleInfos;
4130         std::string metadata = "not_exist";
4131         sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
4132         ASSERT_NE(bundleMgrProxy, nullptr);
4133 
4134         bool getResult = bundleMgrProxy->GetBundleInfosByMetaData(metadata, bundleInfos);
4135         EXPECT_FALSE(getResult);
4136         if (getResult) {
4137             APP_LOGI("GetBundleInfosByMetaData_0200 failed - cycle count: %{public}d", i);
4138             break;
4139         }
4140         result = true;
4141     }
4142 
4143     if (result && stLevel_.BMSLevel > 1) {
4144         APP_LOGI("GetBundleInfosByMetaData_0200 success - cycle count: %{public}d", stLevel_.BMSLevel);
4145     }
4146     EXPECT_TRUE(result);
4147     std::cout << "END GetBundleInfosByMetaData_0200" << std::endl;
4148 }
4149 
4150 /**
4151  * @tc.number: GetBundleInfosByMetaData_0300
4152  * @tc.name: test GetBundleInfosByMetaData interface
4153  * @tc.desc: 1.call GetBundleInfosByMetaData
4154  */
4155 HWTEST_F(ActsBmsKitSystemTest, GetBundleInfosByMetaData_0300, Function | MediumTest | Level1)
4156 {
4157     std::vector<BundleInfo> bundleInfos;
4158     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
4159     ASSERT_NE(bundleMgrProxy, nullptr);
4160 
4161     bool getResult = bundleMgrProxy->GetBundleInfosByMetaData("", bundleInfos);
4162     EXPECT_FALSE(getResult);
4163 }
4164 
4165 /**
4166  * @tc.number: AbilityDump_0100
4167  * @tc.name: Dump
4168  * @tc.desc: 1.under '/data/test/bms_bundle',there exists a hap
4169  *           2.install the hap
4170  *           3.call "QueryAbilityInfo" kit
4171  *           4.Dump abilityInfo
4172  */
4173 HWTEST_F(ActsBmsKitSystemTest, AbilityDump_0100, Function | MediumTest | Level0)
4174 {
4175     std::cout << "START AbilityDump_0100" << std::endl;
4176     bool result = false;
4177     for (int i = 1; i <= stLevel_.BMSLevel; i++) {
4178         std::vector<std::string> resvec;
4179         std::string bundleFilePath = THIRD_BUNDLE_PATH + "bmsThirdBundle1.hap";
4180         std::string appName = BASE_BUNDLE_NAME + "1";
4181         std::string abilityName = BASE_ABILITY_NAME;
4182         Install(bundleFilePath, InstallFlag::REPLACE_EXISTING, resvec);
4183         CommonTool commonTool;
4184         EXPECT_EQ(commonTool.VectorToStr(resvec), "Success") << "install fail!";
4185         Want want;
4186         ElementName name;
4187         name.SetAbilityName(abilityName);
4188         name.SetBundleName(appName);
4189         want.SetElement(name);
4190 
4191         AbilityInfo abilityInfo;
4192         sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
4193         ASSERT_NE(bundleMgrProxy, nullptr);
4194 
4195         bool queryResult =
4196             bundleMgrProxy->QueryAbilityInfo(want, GET_ABILITY_INFO_WITH_APPLICATION, USERID, abilityInfo);
4197         EXPECT_EQ(abilityInfo.name, abilityName);
4198         EXPECT_TRUE(queryResult);
4199         std::string path = "/data/test/abilityInfo.txt";
4200         std::ofstream file(path);
4201         file.close();
4202         int fd = open(path.c_str(), O_WRONLY | O_CLOEXEC);
4203         EXPECT_NE(fd, -1) << "open file error";
4204         std::string prefix = "[ability]";
4205         abilityInfo.Dump(prefix, fd);
4206         long length = lseek(fd, 0, SEEK_END);
4207         EXPECT_GT(length, 0);
4208         close(fd);
4209         resvec.clear();
4210         Uninstall(appName, resvec);
4211         EXPECT_EQ(commonTool.VectorToStr(resvec), "Success") << "uninstall fail!";
4212         if (!queryResult) {
4213             APP_LOGI("AbilityDump_0100 failed - cycle count: %{public}d", i);
4214             break;
4215         }
4216         result = true;
4217     }
4218     if (result && stLevel_.BMSLevel > 1) {
4219         APP_LOGI("AbilityDump_0100 success - cycle count: %{public}d", stLevel_.BMSLevel);
4220     }
4221     EXPECT_TRUE(result);
4222     std::cout << "END AbilityDump_0100" << std::endl;
4223 }
4224 
4225 /**
4226  * @tc.number: AbilityDump_0200
4227  * @tc.name: Dump
4228  * @tc.desc: 1.under '/data/test/bms_bundle',there exists a hap
4229  *           2.fd is -1
4230  *           3.Dump abilityInfo failed
4231  */
4232 HWTEST_F(ActsBmsKitSystemTest, AbilityDump_0200, Function | MediumTest | Level0)
4233 {
4234     AbilityInfo abilityInfo;
4235     std::string path = "/data/test/abilityInfo.txt";
4236     std::ofstream file(path);
4237     file.close();
4238     int fd = INVALIED_ID;
4239     std::string prefix = "[ability]";
4240     abilityInfo.Dump(prefix, fd);
4241     long length = lseek(fd, 0, SEEK_END);
4242     EXPECT_EQ(length, INVALIED_ID);
4243     close(fd);
4244 }
4245 
4246 /**
4247  * @tc.number: ApplicationInfoDump_0100
4248  * @tc.name: Dump
4249  * @tc.desc: 1.under '/data/test/bms_bundle',there exists a hap
4250  *           2.install the hap
4251  *           3.call "GetApplicationInfo" kit
4252  *           4.Dump appInfo
4253  */
4254 HWTEST_F(ActsBmsKitSystemTest, ApplicationInfoDump_0100, Function | MediumTest | Level1)
4255 {
4256     std::cout << "START ApplicationInfoDump_0100" << std::endl;
4257     bool result = false;
4258     for (int i = 1; i <= stLevel_.BMSLevel; i++) {
4259         std::vector<std::string> resvec;
4260         std::string bundleFilePath = THIRD_BUNDLE_PATH + "bmsThirdBundle1.hap";
4261         std::string appName = BASE_BUNDLE_NAME + "1";
4262         Install(bundleFilePath, InstallFlag::REPLACE_EXISTING, resvec);
4263 
4264         CommonTool commonTool;
4265         std::string installResult = commonTool.VectorToStr(resvec);
4266         EXPECT_EQ(installResult, "Success") << "install fail!";
4267 
4268         ApplicationInfo appInfo;
4269         sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
4270         ASSERT_NE(bundleMgrProxy, nullptr);
4271 
4272         bool getInfoResult =
4273             bundleMgrProxy->GetApplicationInfo(appName, 0, USERID, appInfo);
4274         EXPECT_TRUE(getInfoResult);
4275         EXPECT_EQ(appInfo.name, appName);
4276 
4277         std::string path = "/data/test/appInfo.txt";
4278         std::ofstream file(path);
4279         file.close();
4280         int fd = open(path.c_str(), O_WRONLY | O_CLOEXEC);
4281         EXPECT_NE(fd, -1) << "open file error";
4282         std::string prefix = "[appInfo]";
4283         appInfo.Dump(prefix, fd);
4284         long length = lseek(fd, 0, SEEK_END);
4285         EXPECT_GT(length, 0);
4286         close(fd);
4287 
4288         resvec.clear();
4289         Uninstall(appName, resvec);
4290         std::string uninstallResult = commonTool.VectorToStr(resvec);
4291         EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!";
4292 
4293         if (!getInfoResult) {
4294             APP_LOGI("ApplicationInfoDump_0100 failed - cycle count: %{public}d", i);
4295             break;
4296         }
4297         result = true;
4298     }
4299 
4300     if (result && stLevel_.BMSLevel > 1) {
4301         APP_LOGI("ApplicationInfoDump_0100 success - cycle count: %{public}d", stLevel_.BMSLevel);
4302     }
4303     EXPECT_TRUE(result);
4304     std::cout << "END ApplicationInfoDump_0100" << std::endl;
4305 }
4306 
4307 /**
4308  * @tc.number: ApplicationInfoDump_0200
4309  * @tc.name: Dump
4310  * @tc.desc: 1.under '/data/test/bms_bundle',there exists a hap
4311  *           2.fd is -1
4312  *           3.Dump info failed
4313  */
4314 HWTEST_F(ActsBmsKitSystemTest, ApplicationInfoDump_0200, Function | MediumTest | Level0)
4315 {
4316     ApplicationInfo info;
4317     std::string path = "/data/test/abilityInfo.txt";
4318     std::ofstream file(path);
4319     file.close();
4320     int fd = INVALIED_ID;
4321     std::string prefix = "[ability]";
4322     info.Dump(prefix, fd);
4323     long length = lseek(fd, ZERO_SIZE, SEEK_END);
4324     EXPECT_EQ(length, INVALIED_ID);
4325     close(fd);
4326 }
4327 
4328 /**
4329  * @tc.number: ApplicationInfoDump_0100
4330  * @tc.name: Dump
4331  * @tc.desc: 1.under '/data/test/bms_bundle',there exists a hap
4332  *           2.install the hap
4333  *           3.call "GetApplicationInfo" kit
4334  *           4.Dump appInfo
4335  */
4336 HWTEST_F(ActsBmsKitSystemTest, BundleUserInfoDump_0100, Function | MediumTest | Level1)
4337 {
4338     BundleUserInfo appInfo;
4339     std::string path = "/data/test/appInfo.txt";
4340     std::ofstream file(path);
4341     file.close();
4342     int fd = open(path.c_str(), O_WRONLY | O_CLOEXEC);
4343     EXPECT_NE(fd, INVALIED_ID) << "open file error";
4344     std::string prefix = "[appInfo]";
4345     appInfo.Dump(prefix, fd);
4346     long length = lseek(fd, ZERO_SIZE, SEEK_END);
4347     EXPECT_GT(length, ZERO_SIZE);
4348     close(fd);
4349 }
4350 
4351 /**
4352  * @tc.number: BundleUserInfoDump_0200
4353  * @tc.name: Dump
4354  * @tc.desc: 1.under '/data/test/bms_bundle',there exists a hap
4355  *           2.install the hap
4356  *           3.call "GetApplicationInfo" kit
4357  *           4.Dump appInfo
4358  */
4359 HWTEST_F(ActsBmsKitSystemTest, BundleUserInfoDump_0200, Function | MediumTest | Level1)
4360 {
4361     BundleUserInfo appInfo;
4362     std::string path = "/data/test/appInfo.txt";
4363     std::ofstream file(path);
4364     file.close();
4365     int fd = INVALIED_ID;
4366     std::string prefix = "[appInfo]";
4367     appInfo.Dump(prefix, fd);
4368     long length = lseek(fd, ZERO_SIZE, SEEK_END);
4369     EXPECT_EQ(length, INVALIED_ID);
4370 }
4371 
4372 /**
4373  * @tc.number: Errors_0100
4374  * @tc.name: test error hap
4375  * @tc.desc: 1.under '/data/test/bms_bundle',there exists an error hap
4376  *           2.install the hap
4377  *           3.get ERR_INSTALL_ALREADY_EXIST
4378  */
4379 HWTEST_F(ActsBmsKitSystemTest, Errors_0100, Function | MediumTest | Level1)
4380 {
4381     std::cout << "Errors_0100" << std::endl;
4382     bool result = false;
4383     for (int i = 1; i <= stLevel_.BMSLevel; i++) {
4384         std::vector<std::string> resvec;
4385         std::string bundleFilePath = THIRD_BUNDLE_PATH + "bmsThirdBundle1.hap";
4386         std::string appName = BASE_BUNDLE_NAME + "1";
4387         Install(bundleFilePath, InstallFlag::NORMAL, resvec);
4388 
4389         CommonTool commonTool;
4390 
4391         std::string installResult = commonTool.VectorToStr(resvec);
4392         EXPECT_EQ(installResult, "Success") << "install fail!";
4393 
4394         resvec.clear();
4395         Install(bundleFilePath, InstallFlag::NORMAL, resvec);
4396         installResult = commonTool.VectorToStr(resvec);
4397         EXPECT_EQ(installResult, "Failure[ERR_INSTALL_ALREADY_EXIST]");
4398 
4399         std::vector<std::string> resvec2;
4400         Uninstall(appName, resvec2);
4401         std::string uninstallResult = commonTool.VectorToStr(resvec2);
4402         EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!";
4403 
4404         if (std::strcmp(installResult.c_str(), "Success") == 0) {
4405             APP_LOGI("Errors_0100 failed - cycle count: %{public}d", i);
4406             break;
4407         }
4408         result = true;
4409     }
4410 
4411     if (result && stLevel_.BMSLevel > 1) {
4412         APP_LOGI("Errors_0100 success - cycle count: %{public}d", stLevel_.BMSLevel);
4413     }
4414     EXPECT_TRUE(result);
4415     std::cout << "Errors_0100" << std::endl;
4416 }
4417 
4418 /**
4419  * @tc.number: Errors_0200
4420  * @tc.name: test error hap
4421  * @tc.desc: 1.under '/data/test/bms_bundle',there exists an error hap
4422  *           2.install the hap
4423  *           3.get ERR_INSTALL_VERSION_DOWNGRADE
4424  */
4425 HWTEST_F(ActsBmsKitSystemTest, Errors_0200, Function | MediumTest | Level1)
4426 {
4427     std::cout << "Errors_0200" << std::endl;
4428     bool result = false;
4429     for (int i = 1; i <= stLevel_.BMSLevel; i++) {
4430         std::string bundleFilePath = THIRD_BUNDLE_PATH + "bmsThirdBundle9.hap";
4431         std::string bundleName = BASE_BUNDLE_NAME + "2";
4432         std::vector<std::string> resvec;
4433         Install(bundleFilePath, InstallFlag::REPLACE_EXISTING, resvec);
4434         CommonTool commonTool;
4435         std::string installResult = commonTool.VectorToStr(resvec);
4436         EXPECT_EQ(installResult, "Success") << "install fail!";
4437 
4438         resvec.clear();
4439         bundleFilePath = THIRD_BUNDLE_PATH + "bmsThirdBundle7.hap";
4440         Install(bundleFilePath, InstallFlag::REPLACE_EXISTING, resvec);
4441         installResult = commonTool.VectorToStr(resvec);
4442         EXPECT_EQ(installResult, "Failure[ERR_INSTALL_VERSION_DOWNGRADE]");
4443 
4444         std::vector<std::string> resvec2;
4445         Uninstall(bundleName, resvec2);
4446         std::string uninstallResult = commonTool.VectorToStr(resvec2);
4447         EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!";
4448 
4449         if (std::strcmp(installResult.c_str(), "Success") == 0) {
4450             APP_LOGI("Errors_0200 failed - cycle count: %{public}d", i);
4451             break;
4452         }
4453         result = true;
4454     }
4455 
4456     if (result && stLevel_.BMSLevel > 1) {
4457         APP_LOGI("Errors_0200 success - cycle count: %{public}d", stLevel_.BMSLevel);
4458     }
4459     EXPECT_TRUE(result);
4460     std::cout << "Errors_0200" << std::endl;
4461 }
4462 
4463 /**
4464  * @tc.number: Errors_0500
4465  * @tc.name: test error hap
4466  * @tc.desc: 1.under '/data/test/bms_bundle',there exists a invalid hap
4467  *           2.install the hap
4468  *           3.get ERR_INSTALL_INVALID_HAP_NAME
4469  */
4470 HWTEST_F(ActsBmsKitSystemTest, Errors_0500, Function | MediumTest | Level1)
4471 {
4472     std::cout << "Errors_0500" << std::endl;
4473     bool result = false;
4474     for (int i = 1; i <= stLevel_.BMSLevel; i++) {
4475         std::vector<std::string> resvec;
4476         std::string bundleFilePath = THIRD_BUNDLE_PATH + "bmsThirdBundle12.rpk";
4477         Install(bundleFilePath, InstallFlag::REPLACE_EXISTING, resvec);
4478 
4479         CommonTool commonTool;
4480         std::string installResult = commonTool.VectorToStr(resvec);
4481         EXPECT_EQ(installResult, "Failure[ERR_INSTALL_INVALID_HAP_NAME]");
4482         if (std::strcmp(installResult.c_str(), "Success") == 0) {
4483             APP_LOGI("Errors_0500 failed - cycle count: %{public}d", i);
4484             break;
4485         }
4486         result = true;
4487     }
4488 
4489     if (result && stLevel_.BMSLevel > 1) {
4490         APP_LOGI("Errors_0500 success - cycle count: %{public}d", stLevel_.BMSLevel);
4491     }
4492     EXPECT_TRUE(result);
4493     std::cout << "Errors_0500" << std::endl;
4494 }
4495 
4496 /**
4497  * @tc.number: Errors_0600
4498  * @tc.name: test error hap
4499  * @tc.desc: 1.under '/data/test/bms_bundle',there exists an error hap
4500  *           2.install the hap
4501  *           3.get MSG_ERR_INSTALL_FILE_PATH_INVALID
4502  */
4503 HWTEST_F(ActsBmsKitSystemTest, Errors_0600, Function | MediumTest | Level1)
4504 {
4505     std::cout << "Errors_0600" << std::endl;
4506     bool result = false;
4507     for (int i = 1; i <= stLevel_.BMSLevel; i++) {
4508         std::vector<std::string> resvec;
4509         std::string bundleFilePath = THIRD_BUNDLE_PATH + "e.hap";
4510         std::string appName = BASE_BUNDLE_NAME + "1";
4511         Install(bundleFilePath, InstallFlag::REPLACE_EXISTING, resvec);
4512 
4513         CommonTool commonTool;
4514 
4515         std::string installResult = commonTool.VectorToStr(resvec);
4516         EXPECT_EQ(installResult, "Failure[MSG_ERR_INSTALL_FILE_PATH_INVALID]");
4517         if (std::strcmp(installResult.c_str(), "Success") == 0) {
4518             APP_LOGI("Errors_0600 failed - cycle count: %{public}d", i);
4519             break;
4520         }
4521         result = true;
4522     }
4523 
4524     if (result && stLevel_.BMSLevel > 1) {
4525         APP_LOGI("Errors_0600 success - cycle count: %{public}d", stLevel_.BMSLevel);
4526     }
4527     EXPECT_TRUE(result);
4528     std::cout << "Errors_0600" << std::endl;
4529 }
4530 
4531 /**
4532  * @tc.number: Errors_0700
4533  * @tc.name: test error hap
4534  * @tc.desc: 1.under '/data/test/bms_bundle',there exists an error hap
4535  *           2.install the hap
4536  *           3.uninstall hap with wrong appName
4537  *           4.get ERR_UNINSTALL_MISSING_INSTALLED_BUNDLE
4538  */
4539 HWTEST_F(ActsBmsKitSystemTest, Errors_0700, Function | MediumTest | Level1)
4540 {
4541     std::cout << "Errors_0700" << std::endl;
4542     bool result = false;
4543     for (int i = 1; i <= stLevel_.BMSLevel; i++) {
4544         std::vector<std::string> resvec;
4545         std::string bundleFilePath = THIRD_BUNDLE_PATH + "bmsThirdBundle1.hap";
4546         std::string appName = BASE_BUNDLE_NAME + "1";
4547         Install(bundleFilePath, InstallFlag::REPLACE_EXISTING, resvec);
4548 
4549         CommonTool commonTool;
4550 
4551         std::string installResult = commonTool.VectorToStr(resvec);
4552         EXPECT_EQ(installResult, "Success") << "install fail!";
4553 
4554         resvec.clear();
4555         appName = BASE_BUNDLE_NAME + "1";
4556         Uninstall(appName, resvec);
4557         std::string uninstallResult = commonTool.VectorToStr(resvec);
4558         EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!";
4559 
4560         std::vector<std::string> resvec2;
4561         appName = BASE_BUNDLE_NAME + "e";
4562         Uninstall(appName, resvec2);
4563         uninstallResult = commonTool.VectorToStr(resvec2);
4564         EXPECT_EQ(uninstallResult, "Failure[ERR_UNINSTALL_MISSING_INSTALLED_BUNDLE]");
4565 
4566         if (std::strcmp(uninstallResult.c_str(), "Success") == 0) {
4567             APP_LOGI("Errors_0700 failed - cycle count: %{public}d", i);
4568             break;
4569         }
4570         result = true;
4571     }
4572 
4573     if (result && stLevel_.BMSLevel > 1) {
4574         APP_LOGI("Errors_0700 success - cycle count: %{public}d", stLevel_.BMSLevel);
4575     }
4576     EXPECT_TRUE(result);
4577     std::cout << "Errors_0700" << std::endl;
4578 }
4579 
4580 /**
4581  * @tc.number: Errors_0800
4582  * @tc.name: test error hap
4583  * @tc.desc: 1.under '/data/test/bms_bundle',there exists an error hap
4584  *           2.install the hap
4585  *           3.uninstall hap twice
4586  *           4.get ERR_UNINSTALL_MISSING_INSTALLED_BUNDLE
4587  */
4588 HWTEST_F(ActsBmsKitSystemTest, Errors_0800, Function | MediumTest | Level1)
4589 {
4590     std::cout << "Errors_0800" << std::endl;
4591     bool result = false;
4592     for (int i = 1; i <= stLevel_.BMSLevel; i++) {
4593         std::vector<std::string> resvec;
4594         std::string bundleFilePath = THIRD_BUNDLE_PATH + "bmsThirdBundle1.hap";
4595         std::string appName = BASE_BUNDLE_NAME + "1";
4596         Install(bundleFilePath, InstallFlag::REPLACE_EXISTING, resvec);
4597 
4598         CommonTool commonTool;
4599 
4600         std::string installResult = commonTool.VectorToStr(resvec);
4601         EXPECT_EQ(installResult, "Success") << "install fail!";
4602 
4603         resvec.clear();
4604         Uninstall(appName, resvec);
4605         std::string uninstallResult = commonTool.VectorToStr(resvec);
4606         EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!";
4607 
4608         resvec.clear();
4609         Uninstall(appName, resvec);
4610         uninstallResult = commonTool.VectorToStr(resvec);
4611         EXPECT_EQ(uninstallResult, "Failure[ERR_UNINSTALL_MISSING_INSTALLED_BUNDLE]");
4612         if (std::strcmp(uninstallResult.c_str(), "Success") == 0) {
4613             APP_LOGI("Errors_0800 failed - cycle count: %{public}d", i);
4614             break;
4615         }
4616         result = true;
4617     }
4618 
4619     if (result && stLevel_.BMSLevel > 1) {
4620         APP_LOGI("Errors_0800 success - cycle count: %{public}d", stLevel_.BMSLevel);
4621     }
4622     EXPECT_TRUE(result);
4623     std::cout << "Errors_0800" << std::endl;
4624 }
4625 
4626 /**
4627  * @tc.number: Errors_0900
4628  * @tc.name: test error hap
4629  * @tc.desc: 1.under '/data/test/bms_bundle',there not exists a hap
4630  *           2.uninstall the hap
4631  *           3.get MSG_ERR_UNINSTALL_SYSTEM_APP_ERROR
4632  */
4633 HWTEST_F(ActsBmsKitSystemTest, Errors_0900, Function | MediumTest | Level1)
4634 {
4635     std::cout << "Errors_0900" << std::endl;
4636     bool result = false;
4637     for (int i = 1; i <= stLevel_.BMSLevel; i++) {
4638         std::vector<std::string> resvec;
4639         std::string appName = "com.ohos.systemui";
4640         CommonTool commonTool;
4641 
4642         Uninstall(appName, resvec);
4643         std::string uninstallResult = commonTool.VectorToStr(resvec);
4644         EXPECT_NE(uninstallResult, "Success");
4645         if (std::strcmp(uninstallResult.c_str(), "Success") == 0) {
4646             APP_LOGI("Errors_0900 failed - cycle count: %{public}d", i);
4647             break;
4648         }
4649         result = true;
4650     }
4651 
4652     if (result && stLevel_.BMSLevel > 1) {
4653         APP_LOGI("Errors_0900 success - cycle count: %{public}d", stLevel_.BMSLevel);
4654     }
4655     EXPECT_TRUE(result);
4656     std::cout << "Errors_0900" << std::endl;
4657 }
4658 
4659 /**
4660  * @tc.number: ApplicationInfo_0100
4661  * @tc.name: struct ApplicationInfo
4662  * @tc.desc: 1.under '/data/test/bms_bundle',there exists a hap
4663  *           2.install the hap
4664  *           3.call dump
4665  *           4.check the appInfo in file
4666  */
4667 HWTEST_F(ActsBmsKitSystemTest, ApplicationInfo_0100, Function | MediumTest | Level1)
4668 {
4669     std::cout << "START ApplicationInfo_0100" << std::endl;
4670     bool result = false;
4671     for (int i = 1; i <= stLevel_.BMSLevel; i++) {
4672         std::vector<std::string> resvec;
4673         std::string appName = BASE_BUNDLE_NAME + "1";
4674         Install(THIRD_BUNDLE_PATH + "bmsThirdBundle1.hap", InstallFlag::REPLACE_EXISTING, resvec);
4675         CommonTool commonTool;
4676         EXPECT_EQ(commonTool.VectorToStr(resvec), "Success") << "install fail!";
4677         ApplicationInfo appInfo;
4678         sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
4679         ASSERT_NE(bundleMgrProxy, nullptr);
4680 
4681         bool getInfoResult =
4682             bundleMgrProxy->GetApplicationInfo(appName, ApplicationFlag::GET_BASIC_APPLICATION_INFO, USERID, appInfo);
4683         EXPECT_TRUE(getInfoResult);
4684         EXPECT_EQ(appInfo.name, appName);
4685         ApplicationInfo *pAppInfo = &appInfo;
4686         std::string path = "/data/test/pAppInfo_01.txt";
4687         std::ofstream file(path);
4688         file.close();
4689         int fd = open(path.c_str(), O_RDWR);
4690         EXPECT_NE(fd, -1) << "open file error";
4691         pAppInfo->Dump("[pAppInfo]", fd);
4692         long length = lseek(fd, 0, SEEK_END);
4693         lseek(fd, 0, SEEK_SET);
4694         std::string strAppInfo;
4695         strAppInfo.resize(length - 1);
4696         ssize_t retVal = read(fd, strAppInfo.data(), length);
4697         EXPECT_GT(retVal, 0);
4698         EXPECT_TRUE(IsSubStr(strAppInfo, appName));
4699         close(fd);
4700         resvec.clear();
4701         Uninstall(appName, resvec);
4702         EXPECT_EQ(commonTool.VectorToStr(resvec), "Success") << "uninstall fail!";
4703         if (retVal <= 0) {
4704             APP_LOGI("ApplicationInfo_0100 failed - cycle count: %{public}d", i);
4705             break;
4706         }
4707         result = true;
4708     }
4709     if (result && stLevel_.BMSLevel > 1) {
4710         APP_LOGI("ApplicationInfo_0100 success - cycle count: %{public}d", stLevel_.BMSLevel);
4711     }
4712     EXPECT_TRUE(result);
4713     std::cout << "END ApplicationInfo_0100" << std::endl;
4714 }
4715 
4716 /**
4717  * @tc.number: ApplicationInfo_0200
4718  * @tc.name: struct ApplicationInfo
4719  * @tc.desc: 1.init appInfo structure
4720  *           2.Dump the pAppInfo
4721  */
4722 HWTEST_F(ActsBmsKitSystemTest, ApplicationInfo_0200, Function | MediumTest | Level1)
4723 {
4724     std::cout << "START ApplicationInfo_0200" << std::endl;
4725     bool result = false;
4726     for (int i = 1; i <= stLevel_.BMSLevel; i++) {
4727         ApplicationInfo appInfo;
4728         appInfo.bundleName = "com.third.hiworld.example_02";
4729         appInfo.label = "bmsThirdBundle_A1 Ability";
4730         appInfo.description = "example helloworld";
4731         appInfo.deviceId = CURRENT_DEVICE_ID;
4732         appInfo.isSystemApp = false;
4733 
4734         ApplicationInfo *pAppInfo = &appInfo;
4735         std::string path = "/data/test/pAppInfo_02.txt";
4736         std::ofstream file(path);
4737         file.close();
4738         int fd = open(path.c_str(), O_RDWR | O_CLOEXEC);
4739         EXPECT_NE(fd, -1) << "open file error";
4740         std::string prefix = "[pAppInfo]";
4741         pAppInfo->Dump(prefix, fd);
4742         long length = lseek(fd, 0, SEEK_END);
4743         lseek(fd, 0, SEEK_SET);
4744         std::string strAppInfo;
4745         strAppInfo.resize(length - 1);
4746         ssize_t retVal = read(fd, strAppInfo.data(), length);
4747         EXPECT_GT(retVal, 0);
4748         EXPECT_TRUE(IsSubStr(strAppInfo, appInfo.bundleName));
4749         EXPECT_TRUE(IsSubStr(strAppInfo, appInfo.label));
4750         EXPECT_TRUE(IsSubStr(strAppInfo, appInfo.description));
4751         close(fd);
4752 
4753         if (retVal <= 0) {
4754             APP_LOGI("ApplicationInfo_0200 failed - cycle count: %{public}d", i);
4755             break;
4756         }
4757         result = true;
4758     }
4759 
4760     if (result && stLevel_.BMSLevel > 1) {
4761         APP_LOGI("ApplicationInfo_0200 success - cycle count: %{public}d", stLevel_.BMSLevel);
4762     }
4763     EXPECT_TRUE(result);
4764     std::cout << "END ApplicationInfo_0200" << std::endl;
4765 }
4766 
4767 /**
4768  * @tc.number: QueryKeepAliveBundleInfos_0100
4769  * @tc.name: test QueryKeepAliveBundleInfos interface
4770  * @tc.desc: 1.under '/data/test/bms_bundle',there is a hap,whose keepAlive-property's value is true
4771  *           2.install the hap
4772  *           3.call QueryKeepAliveBundleInfos
4773  */
4774 HWTEST_F(ActsBmsKitSystemTest, QueryKeepAliveBundleInfos_0100, Function | MediumTest | Level1)
4775 {
4776     std::cout << "START QueryKeepAliveBundleInfos_0100" << std::endl;
4777     std::vector<std::string> resvec;
4778     std::string bundleFilePath = THIRD_BUNDLE_PATH + "bmsThirdBundle1.hap";
4779     std::string appName = BASE_BUNDLE_NAME + "1";
4780     Install(bundleFilePath, InstallFlag::REPLACE_EXISTING, resvec);
4781 
4782     CommonTool commonTool;
4783     std::string installResult = commonTool.VectorToStr(resvec);
4784     EXPECT_EQ(installResult, "Success") << "install fail!";
4785 
4786     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
4787     ASSERT_NE(bundleMgrProxy, nullptr);
4788 
4789     std::vector<BundleInfo> bundleInfos;
4790     bool result = bundleMgrProxy->QueryKeepAliveBundleInfos(bundleInfos);
4791     EXPECT_TRUE(result);
4792 
4793     resvec.clear();
4794     Uninstall(appName, resvec);
4795     std::string uninstallResult = commonTool.VectorToStr(resvec);
4796     EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!";
4797     std::cout << "END QueryKeepAliveBundleInfos_0100" << std::endl;
4798 }
4799 
4800 /**
4801  * @tc.number: QueryKeepAliveBundleInfos_0200
4802  * @tc.name: test QueryKeepAliveBundleInfos interface
4803  * @tc.desc: 1.under '/data/test/bms_bundle',there is a hap,whose keepAlive-property's value is false
4804  *           2.install the hap
4805  *           3.call QueryKeepAliveBundleInfos
4806  */
4807 HWTEST_F(ActsBmsKitSystemTest, QueryKeepAliveBundleInfos_0200, Function | MediumTest | Level2)
4808 {
4809     std::cout << "START QueryKeepAliveBundleInfos_0100" << std::endl;
4810     std::vector<std::string> resvec;
4811     std::string bundleFilePath = THIRD_BUNDLE_PATH + "bmsThirdBundle2.hap";
4812     std::string appName = BASE_BUNDLE_NAME + "1";
4813     Install(bundleFilePath, InstallFlag::REPLACE_EXISTING, resvec);
4814 
4815     CommonTool commonTool;
4816     std::string installResult = commonTool.VectorToStr(resvec);
4817     EXPECT_EQ(installResult, "Success") << "install fail!";
4818 
4819     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
4820     ASSERT_NE(bundleMgrProxy, nullptr);
4821 
4822     std::vector<BundleInfo> bundleInfos;
4823     bool result = bundleMgrProxy->QueryKeepAliveBundleInfos(bundleInfos);
4824     EXPECT_TRUE(result);
4825 
4826     resvec.clear();
4827     Uninstall(appName, resvec);
4828     std::string uninstallResult = commonTool.VectorToStr(resvec);
4829     EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!";
4830     std::cout << "END QueryKeepAliveBundleInfos_0100" << std::endl;
4831 }
4832 
4833 /**
4834  * @tc.number: Uninstall_KeepData_0100
4835  * @tc.name: test whether to keep user data when the app is uninstalled
4836  * @tc.desc: 1.under '/data/test/bms_bundle',there is a hap
4837  *           2.install the hap
4838  *           3.uninstall the hap
4839  */
4840 HWTEST_F(ActsBmsKitSystemTest, Uninstall_KeepData_0100, Function | MediumTest | Level2)
4841 {
4842     std::cout << "START Uninstall_KeepData_0100" << std::endl;
4843     std::string bundleFilePath = THIRD_BUNDLE_PATH + "bmsThirdBundle1.hap";
4844 
4845     sptr<IBundleInstaller> installerProxy = GetInstallerProxy();
4846     if (!installerProxy) {
4847         APP_LOGE("get bundle installer failed.");
4848         EXPECT_EQ(installerProxy, nullptr);
4849     }
4850     InstallParam installParam;
4851     installParam.installFlag = InstallFlag::REPLACE_EXISTING;
4852     installParam.userId = USERID;
4853     installParam.isKeepData = false;
4854     sptr<StatusReceiverImpl> statusReceiver = (new (std::nothrow) StatusReceiverImpl());
4855     EXPECT_NE(statusReceiver, nullptr);
4856     installerProxy->Install(bundleFilePath, installParam, statusReceiver);
4857     std::string installMsg = statusReceiver->GetResultMsg();
4858     EXPECT_EQ(installMsg, "Success") << "install fail!";
4859     std::string appName = BASE_BUNDLE_NAME + "1";
4860 
4861     std::vector<std::string> resvec;
4862     Uninstall(appName, resvec);
4863     CommonTool commonTool;
4864     std::string uninstallResult = commonTool.VectorToStr(resvec);
4865     EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!";
4866     CheckFileNonExist(appName);
4867     std::cout << "END Uninstall_KeepData_0100" << std::endl;
4868 }
4869 
4870 /**
4871  * @tc.number: Uninstall_KeepData_0200
4872  * @tc.name: test whether to keep user data when the app is uninstalled
4873  * @tc.desc: 1.under '/data/test/bms_bundle',there is a hap
4874  *           2.install the hap
4875  *           3.uninstall the hap
4876  */
4877 HWTEST_F(ActsBmsKitSystemTest, Uninstall_KeepData_0200, Function | MediumTest | Level2)
4878 {
4879     std::cout << "START Uninstall_KeepData_0200" << std::endl;
4880     std::string bundleFilePath = THIRD_BUNDLE_PATH + "bmsThirdBundle2.hap";
4881 
4882     sptr<IBundleInstaller> installerProxy = GetInstallerProxy();
4883     if (!installerProxy) {
4884         APP_LOGE("get bundle installer failed.");
4885         EXPECT_EQ(installerProxy, nullptr);
4886     }
4887     InstallParam installParam;
4888     installParam.installFlag = InstallFlag::REPLACE_EXISTING;
4889     installParam.userId = USERID;
4890     installParam.isKeepData = true;
4891     sptr<StatusReceiverImpl> statusReceiver = (new (std::nothrow) StatusReceiverImpl());
4892     EXPECT_NE(statusReceiver, nullptr);
4893     installerProxy->Install(bundleFilePath, installParam, statusReceiver);
4894     std::string installMsg = statusReceiver->GetResultMsg();
4895     EXPECT_EQ(installMsg, "Success") << "install fail!";
4896     std::string appName = BASE_BUNDLE_NAME + "1";
4897 
4898     std::vector<std::string> resvec;
4899     Uninstall(appName, resvec);
4900     CommonTool commonTool;
4901     std::string uninstallResult = commonTool.VectorToStr(resvec);
4902     EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!";
4903     std::cout << "END Uninstall_KeepData_0200" << std::endl;
4904 }
4905 
4906 /**
4907  * @tc.number: Uninstall_KeepData_0300
4908  * @tc.name: test whether to keep user data when the hap is uninstalled
4909  * @tc.desc: 1.under '/data/test/bms_bundle',there is a hap
4910  *           2.install the hap
4911  *           3.uninstall the hap
4912  */
4913 HWTEST_F(ActsBmsKitSystemTest, Uninstall_KeepData_0300, Function | MediumTest | Level2)
4914 {
4915     std::cout << "START Uninstall_KeepData_0300" << std::endl;
4916     std::string bundleFilePath = THIRD_BUNDLE_PATH + "bmsThirdBundle2.hap";
4917 
4918     sptr<IBundleInstaller> installerProxy = GetInstallerProxy();
4919     if (!installerProxy) {
4920         APP_LOGE("get bundle installer failed.");
4921         EXPECT_EQ(installerProxy, nullptr);
4922     }
4923     InstallParam installParam;
4924     installParam.installFlag = InstallFlag::REPLACE_EXISTING;
4925     installParam.userId = USERID;
4926     installParam.isKeepData = false;
4927     sptr<StatusReceiverImpl> statusReceiver = (new (std::nothrow) StatusReceiverImpl());
4928     EXPECT_NE(statusReceiver, nullptr);
4929     installerProxy->Install(bundleFilePath, installParam, statusReceiver);
4930     std::string installMsg = statusReceiver->GetResultMsg();
4931     EXPECT_EQ(installMsg, "Success") << "install fail!";
4932 
4933     bundleFilePath = THIRD_BUNDLE_PATH + "bmsThirdBundle4.hap";
4934     sptr<StatusReceiverImpl> statusReceiver2 = (new (std::nothrow) StatusReceiverImpl());
4935     EXPECT_NE(statusReceiver2, nullptr);
4936     installerProxy->Install(bundleFilePath, installParam, statusReceiver2);
4937     installMsg = statusReceiver2->GetResultMsg();
4938     EXPECT_EQ(installMsg, "Success") << "install fail!";
4939 
4940     std::string appName = BASE_BUNDLE_NAME + "1";
4941 
4942     std::vector<std::string> resvec;
4943     std::string bundleName = BASE_BUNDLE_NAME + "1";
4944     std::string modulePackage = BASE_BUNDLE_NAME + ".h1";
4945     HapUninstall(bundleName, modulePackage, resvec);
4946     CommonTool commonTool;
4947     std::string uninstallResult = commonTool.VectorToStr(resvec);
4948     EXPECT_EQ(uninstallResult, "Success") << "uninstall hap fail!";
4949     resvec.clear();
4950     Uninstall(appName, resvec);
4951     uninstallResult = commonTool.VectorToStr(resvec);
4952     EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!";
4953     std::cout << "END Uninstall_KeepData_0300" << std::endl;
4954 }
4955 
4956 /**
4957  * @tc.number: Uninstall_KeepData_0400
4958  * @tc.name: test whether to keep user data when the hap is uninstalled
4959  * @tc.desc: 1.under '/data/test/bms_bundle',there is a hap
4960  *           2.install the hap
4961  *           3.uninstall the hap
4962  */
4963 HWTEST_F(ActsBmsKitSystemTest, Uninstall_KeepData_0400, Function | MediumTest | Level2)
4964 {
4965     std::cout << "START Uninstall_KeepData_0400" << std::endl;
4966     std::string bundleFilePath = THIRD_BUNDLE_PATH + "bmsThirdBundle2.hap";
4967 
4968     sptr<IBundleInstaller> installerProxy = GetInstallerProxy();
4969     if (!installerProxy) {
4970         APP_LOGE("get bundle installer failed.");
4971         EXPECT_EQ(installerProxy, nullptr);
4972     }
4973     InstallParam installParam;
4974     installParam.installFlag = InstallFlag::REPLACE_EXISTING;
4975     installParam.userId = USERID;
4976     installParam.isKeepData = true;
4977     sptr<StatusReceiverImpl> statusReceiver = (new (std::nothrow) StatusReceiverImpl());
4978     EXPECT_NE(statusReceiver, nullptr);
4979     installerProxy->Install(bundleFilePath, installParam, statusReceiver);
4980     std::string installMsg = statusReceiver->GetResultMsg();
4981     EXPECT_EQ(installMsg, "Success") << "install fail!";
4982 
4983     bundleFilePath = THIRD_BUNDLE_PATH + "bmsThirdBundle4.hap";
4984     sptr<StatusReceiverImpl> statusReceiver2 = (new (std::nothrow) StatusReceiverImpl());
4985     EXPECT_NE(statusReceiver2, nullptr);
4986     installerProxy->Install(bundleFilePath, installParam, statusReceiver2);
4987     installMsg = statusReceiver2->GetResultMsg();
4988     EXPECT_EQ(installMsg, "Success") << "install fail!";
4989 
4990     std::string appName = BASE_BUNDLE_NAME + "1";
4991     std::vector<std::string> resvec;
4992     std::string bundleName = BASE_BUNDLE_NAME + "1";
4993     std::string modulePackage = BASE_BUNDLE_NAME + ".h1";
4994     HapUninstall(bundleName, modulePackage, resvec);
4995     CommonTool commonTool;
4996     std::string uninstallResult = commonTool.VectorToStr(resvec);
4997     EXPECT_EQ(uninstallResult, "Success") << "uninstall hap fail!";
4998     resvec.clear();
4999     Uninstall(appName, resvec);
5000     uninstallResult = commonTool.VectorToStr(resvec);
5001     EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!";
5002     std::cout << "END Uninstall_KeepData_0400" << std::endl;
5003 }
5004 
5005 /**
5006  * @tc.number: GetBundlesForUid_0100
5007  * @tc.name: test GetBundlesForUid interface
5008  * @tc.desc: 1.under '/data/test/bms_bundle',there exist three bundles
5009  *           2.install these apps
5010  *           3.query all bundles by uid
5011  */
5012 HWTEST_F(ActsBmsKitSystemTest, GetBundlesForUid_0100, Function | MediumTest | Level1)
5013 {
5014     std::cout << "START GetBundlesForUid_0100" << std::endl;
5015     bool result = false;
5016     for (int i = 1; i <= stLevel_.BMSLevel; i++) {
5017         sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
5018         ASSERT_NE(bundleMgrProxy, nullptr);
5019 
5020         CommonTool commonTool;
5021         for (int i = 6; i <= 8; i++) {
5022             std::vector<std::string> resvec;
5023             std::string hapFilePath = THIRD_BUNDLE_PATH + "bmsThirdBundle" + std::to_string(i) + ".hap";
5024             Install(hapFilePath, InstallFlag::REPLACE_EXISTING, resvec);
5025             EXPECT_EQ(commonTool.VectorToStr(resvec), "Success") << "install fail!";
5026         }
5027         bool ret;
5028         for (int i = 1; i <= 3; i++) {
5029             std::string appName = BASE_BUNDLE_NAME + std::to_string(i);
5030             BundleInfo bundleInfo;
5031             bundleMgrProxy->GetBundleInfo(appName, BundleFlag::GET_BUNDLE_DEFAULT, bundleInfo, USERID);
5032             std::vector<std::string> bundleNames;
5033             ret = bundleMgrProxy->GetBundlesForUid(bundleInfo.uid, bundleNames);
5034             EXPECT_TRUE(ret);
5035         }
5036         for (int i = 1; i <= 3; i++) {
5037             std::vector<std::string> resvec;
5038             std::string appName = BASE_BUNDLE_NAME + std::to_string(i);
5039             Uninstall(appName, resvec);
5040             EXPECT_EQ(commonTool.VectorToStr(resvec), "Success") << "uninstall fail!";
5041         }
5042         if (!ret) {
5043             APP_LOGI("GetBundlesForUid_0100 failed - cycle count: %{public}d", i);
5044             break;
5045         }
5046         result = true;
5047     }
5048     if (result && stLevel_.BMSLevel > 1) {
5049         APP_LOGI("GetBundlesForUid_0100 success - cycle count: %{public}d", stLevel_.BMSLevel);
5050     }
5051     EXPECT_TRUE(result);
5052     std::cout << "END GetBundlesForUid_0100" << std::endl;
5053 }
5054 
5055 /**
5056  * @tc.number: GetBundlesForUid_0200
5057  * @tc.name: test GetBundlesForUid interface
5058  * @tc.desc: 1.under '/data/test/bms_bundle',there is a bundle
5059  *           2.install the hap
5060  *           3.query bundles by wrong uid
5061  */
5062 HWTEST_F(ActsBmsKitSystemTest, GetBundlesForUid_0200, Function | MediumTest | Level2)
5063 {
5064     std::cout << "START GetBundlesForUid_0200" << std::endl;
5065     bool result = false;
5066     for (int i = 1; i <= stLevel_.BMSLevel; i++) {
5067         sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
5068         ASSERT_NE(bundleMgrProxy, nullptr);
5069 
5070         std::vector<std::string> bundleNames;
5071         bool ret = bundleMgrProxy->GetBundlesForUid(Constants::INVALID_UID, bundleNames);
5072         EXPECT_FALSE(ret);
5073         if (ret) {
5074             APP_LOGI("GetBundlesForUid_0200 failed - cycle count: %{public}d", i);
5075             break;
5076         }
5077         result = true;
5078     }
5079     if (result && stLevel_.BMSLevel > 1) {
5080         APP_LOGI("GetBundlesForUid_0200 success - cycle count: %{public}d", stLevel_.BMSLevel);
5081     }
5082     EXPECT_TRUE(result);
5083     std::cout << "END GetBundlesForUid_0200" << std::endl;
5084 }
5085 
5086 /**
5087  * @tc.number: GetBundlesForUid_0300
5088  * @tc.name: test GetBundlesForUid interface
5089  * @tc.desc: 1.query bundles by uid
5090  */
5091 HWTEST_F(ActsBmsKitSystemTest, GetBundlesForUid_0300, Function | MediumTest | Level1)
5092 {
5093     std::cout << "START GetBundlesForUid_0300" << std::endl;
5094     CommonTool commonTool;
5095     std::vector<std::string> resvec;
5096     std::string bundleFilePath = THIRD_BUNDLE_PATH + "bmsThirdBundle1.hap";
5097     std::string appName = BASE_BUNDLE_NAME + "1";
5098     Install(bundleFilePath, InstallFlag::REPLACE_EXISTING, resvec);
5099     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
5100     ASSERT_NE(bundleMgrProxy, nullptr);
5101 
5102     BundleInfo bundleInfo;
5103     bundleMgrProxy->GetBundleInfo(appName, BundleFlag::GET_BUNDLE_DEFAULT, bundleInfo, USERID);
5104     int uid = bundleInfo.uid;
5105     std::vector<std::string> bundleNames;
5106     bool ret = bundleMgrProxy->GetBundlesForUid(uid, bundleNames);
5107     EXPECT_TRUE(ret);
5108     for (auto bundleName : bundleNames) {
5109         EXPECT_EQ(bundleName, appName);
5110     }
5111 
5112     resvec.clear();
5113     Uninstall(appName, resvec);
5114     std::string uninstallResult = commonTool.VectorToStr(resvec);
5115     EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!";
5116     std::cout << "END GetBundlesForUid_0300" << std::endl;
5117 }
5118 
5119 /**
5120  * @tc.number: GetNameForUid_0100
5121  * @tc.name: test GetNameForUid interface
5122  * @tc.desc: 1.under '/data/test/bms_bundle',there are two apps
5123  *           2.install fist hap
5124  *           3.get first hap name by uid
5125  *           4.uninstall first hap
5126  *           5.install second hap
5127  *           6.install first hap
5128  *           7.get first hap name by uid
5129  */
5130 HWTEST_F(ActsBmsKitSystemTest, GetNameForUid_0100, Function | MediumTest | Level1)
5131 {
5132     std::cout << "START GetNameForUid_0100" << std::endl;
5133     bool result = false;
5134     for (int i = 1; i <= stLevel_.BMSLevel; i++) {
5135         CommonTool commonTool;
5136         std::vector<std::string> resvec;
5137         std::string name1, name2;
5138         Install(THIRD_BUNDLE_PATH + "bmsThirdBundle6.hap", InstallFlag::REPLACE_EXISTING, resvec);
5139         EXPECT_EQ(commonTool.VectorToStr(resvec), "Success") << "install fail!";
5140         resvec.clear();
5141         sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
5142         ASSERT_NE(bundleMgrProxy, nullptr);
5143 
5144         BundleInfo bundleInfo1;
5145         bundleMgrProxy->GetBundleInfo(BASE_BUNDLE_NAME + '1', BundleFlag::GET_BUNDLE_DEFAULT, bundleInfo1, USERID);
5146         ErrCode ret = bundleMgrProxy->GetNameForUid(bundleInfo1.uid, name1);
5147         EXPECT_EQ(ret, ERR_OK);
5148         Uninstall(BASE_BUNDLE_NAME + '1', resvec);
5149         EXPECT_EQ(commonTool.VectorToStr(resvec), "Success") << "uninstall fail!";
5150         resvec.clear();
5151         Install(THIRD_BUNDLE_PATH + "bmsThirdBundle7.hap", InstallFlag::REPLACE_EXISTING, resvec);
5152         EXPECT_EQ(commonTool.VectorToStr(resvec), "Success") << "install fail!";
5153         resvec.clear();
5154         Install(THIRD_BUNDLE_PATH + "bmsThirdBundle6.hap", InstallFlag::REPLACE_EXISTING, resvec);
5155         EXPECT_EQ(commonTool.VectorToStr(resvec), "Success") << "install fail!";
5156         BundleInfo bundleInfo2;
5157         bundleMgrProxy->GetBundleInfo(BASE_BUNDLE_NAME + '1', BundleFlag::GET_BUNDLE_DEFAULT, bundleInfo2, USERID);
5158         ret = bundleMgrProxy->GetNameForUid(bundleInfo2.uid, name2);
5159         EXPECT_EQ(ret, ERR_OK);
5160         EXPECT_NE(bundleInfo1.uid, bundleInfo2.uid);
5161         EXPECT_EQ(name1, name2);
5162         for (int i = 1; i <= 2; i++) {
5163             std::string appName = BASE_BUNDLE_NAME + std::to_string(i);
5164             std::vector<std::string> resvec2;
5165             Uninstall(appName, resvec2);
5166             EXPECT_EQ(commonTool.VectorToStr(resvec2), "Success") << "uninstall fail!";
5167         }
5168         if (ret != ERR_OK) {
5169             APP_LOGI("GetNameForUid_0100 failed - cycle count: %{public}d", i);
5170             break;
5171         }
5172         result = true;
5173     }
5174     if (result && stLevel_.BMSLevel > 1) {
5175         APP_LOGI("GetNameForUid_0100 success - cycle count: %{public}d", stLevel_.BMSLevel);
5176     }
5177     EXPECT_TRUE(result);
5178     std::cout << "END GetNameForUid_0100" << std::endl;
5179 }
5180 
5181 /**
5182  * @tc.number: GetNameForUid_0200
5183  * @tc.name: test GetNameForUid interface
5184  * @tc.desc: 1.under '/data/test/bms_bundle',there is a hap
5185  *           2.install the hap
5186  *           3.get name by wrong uid
5187  */
5188 HWTEST_F(ActsBmsKitSystemTest, GetNameForUid_0200, Function | MediumTest | Level2)
5189 {
5190     std::cout << "START GetNameForUid_0200" << std::endl;
5191     bool result = false;
5192     for (int i = 1; i <= stLevel_.BMSLevel; i++) {
5193         CommonTool commonTool;
5194         std::string installResult;
5195         std::vector<std::string> resvec;
5196         std::string bundleFilePath = THIRD_BUNDLE_PATH + "bmsThirdBundle1.hap";
5197         std::string appName = BASE_BUNDLE_NAME + '1';
5198         Install(bundleFilePath, InstallFlag::REPLACE_EXISTING, resvec);
5199         installResult = commonTool.VectorToStr(resvec);
5200         EXPECT_EQ(installResult, "Success") << "install fail!";
5201         sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
5202         ASSERT_NE(bundleMgrProxy, nullptr);
5203 
5204         BundleInfo bundleInfo;
5205         bundleMgrProxy->GetBundleInfo(appName, BundleFlag::GET_BUNDLE_DEFAULT, bundleInfo);
5206         std::string name;
5207         ErrCode ret = bundleMgrProxy->GetNameForUid(Constants::INVALID_UID, name);
5208         EXPECT_NE(ret, ERR_OK);
5209         resvec.clear();
5210         Uninstall(appName, resvec);
5211         EXPECT_EQ(commonTool.VectorToStr(resvec), "Success") << "uninstall fail!";
5212         if (ret != ERR_OK) {
5213             APP_LOGI("GetNameForUid_0200 failed - cycle count: %{public}d", i);
5214             break;
5215         }
5216         result = true;
5217     }
5218 
5219     if (result && stLevel_.BMSLevel > 1) {
5220         APP_LOGI("GetNameForUid_0200 success - cycle count: %{public}d", stLevel_.BMSLevel);
5221     }
5222     EXPECT_FALSE(result);
5223     std::cout << "END GetNameForUid_0200" << std::endl;
5224 }
5225 
5226 /**
5227  * @tc.number: GetNameForUid_0300
5228  * @tc.name: test GetNameForUid interface
5229  * @tc.desc: 1.get name by uid
5230  */
5231 HWTEST_F(ActsBmsKitSystemTest, GetNameForUid_0300, Function | MediumTest | Level1)
5232 {
5233     std::cout << "START GetNameForUid_0300" << std::endl;
5234     CommonTool commonTool;
5235     std::vector<std::string> resvec;
5236     std::string bundleFilePath = THIRD_BUNDLE_PATH + "bmsThirdBundle1.hap";
5237     std::string appName = BASE_BUNDLE_NAME + "1";
5238     Install(bundleFilePath, InstallFlag::REPLACE_EXISTING, resvec);
5239     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
5240     ASSERT_NE(bundleMgrProxy, nullptr);
5241 
5242     BundleInfo bundleInfo;
5243     bundleMgrProxy->GetBundleInfo(appName, BundleFlag::GET_BUNDLE_DEFAULT, bundleInfo, USERID);
5244     std::string name;
5245     ErrCode ret = bundleMgrProxy->GetNameForUid(bundleInfo.uid, name);
5246     EXPECT_EQ(ret, ERR_OK);
5247     EXPECT_EQ(name, appName);
5248 
5249     resvec.clear();
5250     Uninstall(appName, resvec);
5251     std::string uninstallResult = commonTool.VectorToStr(resvec);
5252     EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!";
5253     std::cout << "END GetNameForUid_0300" << std::endl;
5254 }
5255 
5256 /**
5257  * @tc.number: GetAppIdByBundleName_0100
5258  * @tc.name: test GetAppIdByBundleName proxy
5259  * @tc.desc: 1.get AppId by BundleName
5260  */
5261 HWTEST_F(ActsBmsKitSystemTest, GetAppIdByBundleName_0100, Function | MediumTest | Level1)
5262 {
5263     std::cout << "START GetAppIdByBundleName_0100" << std::endl;
5264     std::vector<std::string> resvec;
5265     std::string bundleFilePath = THIRD_BUNDLE_PATH + "bmsThirdBundle1.hap";
5266     std::string appName = BASE_BUNDLE_NAME + "1";
5267     Install(bundleFilePath, InstallFlag::REPLACE_EXISTING, resvec);
5268     CommonTool commonTool;
5269     std::string installResult = commonTool.VectorToStr(resvec);
5270     EXPECT_EQ(installResult, "Success") << "install fail!";
5271 
5272     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
5273     ASSERT_NE(bundleMgrProxy, nullptr);
5274 
5275     auto ret = bundleMgrProxy->GetAppIdByBundleName(appName, USERID);
5276     EXPECT_EQ(ret, APPID);
5277 
5278     resvec.clear();
5279     Uninstall(appName, resvec);
5280     std::string uninstallResult = commonTool.VectorToStr(resvec);
5281     EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!";
5282     std::cout << "END GetAppIdByBundleName_0100" << std::endl;
5283 }
5284 
5285 /**
5286  * @tc.number: GetAppIdByBundleName_0200
5287  * @tc.name: test GetAppIdByBundleName proxy
5288  * @tc.desc: 1.get AppId failed by empty BundleName
5289  */
5290 HWTEST_F(ActsBmsKitSystemTest, GetAppIdByBundleName_0200, Function | MediumTest | Level1)
5291 {
5292     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
5293     ASSERT_NE(bundleMgrProxy, nullptr);
5294 
5295     auto ret = bundleMgrProxy->GetAppIdByBundleName("", USERID);
5296     EXPECT_NE(ret, APPID);
5297 }
5298 
5299 /**
5300  * @tc.number: GetBundleGidsByUid_0100
5301  * @tc.name: test GetBundleGidsByUid proxy
5302  * @tc.desc: 1.get BundleGids by uid
5303  */
5304 HWTEST_F(ActsBmsKitSystemTest, GetBundleGidsByUid_0100, Function | MediumTest | Level1)
5305 {
5306     std::cout << "START GetBundleGidsByUid_0100" << std::endl;
5307     std::vector<std::string> resvec;
5308     std::string bundleFilePath = THIRD_BUNDLE_PATH + "bmsThirdBundle1.hap";
5309     std::string appName = BASE_BUNDLE_NAME + "1";
5310     Install(bundleFilePath, InstallFlag::REPLACE_EXISTING, resvec);
5311     CommonTool commonTool;
5312     std::string installResult = commonTool.VectorToStr(resvec);
5313     EXPECT_EQ(installResult, "Success") << "install fail!";
5314 
5315     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
5316     ASSERT_NE(bundleMgrProxy, nullptr);
5317 
5318     std::vector<int> gids;
5319     BundleInfo bundleInfo;
5320     bundleMgrProxy->GetBundleInfo(appName, BundleFlag::GET_BUNDLE_DEFAULT, bundleInfo, USERID);
5321     bool ret = bundleMgrProxy->GetBundleGidsByUid(appName, bundleInfo.uid, gids);
5322     EXPECT_TRUE(ret);
5323 
5324     resvec.clear();
5325     Uninstall(appName, resvec);
5326     std::string uninstallResult = commonTool.VectorToStr(resvec);
5327     EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!";
5328     std::cout << "END GetBundleGidsByUid_0100" << std::endl;
5329 }
5330 
5331 /**
5332  * @tc.number: GetBundleGids_0100
5333  * @tc.name: test GetBundleGids proxy
5334  * @tc.desc: 1.get BundleGids
5335  */
5336 HWTEST_F(ActsBmsKitSystemTest, GetBundleGids_0100, Function | MediumTest | Level1)
5337 {
5338     std::cout << "START GetBundleGids_0100" << std::endl;
5339     std::vector<std::string> resvec;
5340     std::string bundleFilePath = THIRD_BUNDLE_PATH + "bmsThirdBundle1.hap";
5341     std::string appName = BASE_BUNDLE_NAME + "1";
5342     Install(bundleFilePath, InstallFlag::REPLACE_EXISTING, resvec);
5343     CommonTool commonTool;
5344     std::string installResult = commonTool.VectorToStr(resvec);
5345     EXPECT_EQ(installResult, "Success") << "install fail!";
5346 
5347     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
5348     ASSERT_NE(bundleMgrProxy, nullptr);
5349 
5350     std::vector<int> gids;
5351     bool ret = bundleMgrProxy->GetBundleGids(appName, gids);
5352     EXPECT_FALSE(ret);
5353 
5354     resvec.clear();
5355     Uninstall(appName, resvec);
5356     std::string uninstallResult = commonTool.VectorToStr(resvec);
5357     EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!";
5358     std::cout << "END GetBundleGids_0100" << std::endl;
5359 }
5360 
5361 /**
5362  * @tc.number: GetBundleGids_0200
5363  * @tc.name: test GetBundleGids proxy
5364  * @tc.desc: 1.get BundleGids
5365  */
5366 HWTEST_F(ActsBmsKitSystemTest, GetBundleGids_0200, Function | MediumTest | Level1)
5367 {
5368     std::cout << "START GetBundleGids_0100" << std::endl;
5369     std::vector<std::string> resvec;
5370     std::string bundleFilePath = THIRD_BUNDLE_PATH + "bmsThirdBundle1.hap";
5371     std::string appName = BASE_BUNDLE_NAME + "1";
5372     Install(bundleFilePath, InstallFlag::REPLACE_EXISTING, resvec);
5373     CommonTool commonTool;
5374     std::string installResult = commonTool.VectorToStr(resvec);
5375     EXPECT_EQ(installResult, "Success") << "install fail!";
5376 
5377     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
5378     ASSERT_NE(bundleMgrProxy, nullptr);
5379 
5380     std::vector<int> gids;
5381     int uid = bundleMgrProxy->GetUidByBundleName(appName, USERID);
5382     bool ret = bundleMgrProxy->GetBundleGidsByUid(appName, uid, gids);
5383     EXPECT_TRUE(ret);
5384 
5385     resvec.clear();
5386     Uninstall(appName, resvec);
5387     std::string uninstallResult = commonTool.VectorToStr(resvec);
5388     EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!";
5389     std::cout << "END GetBundleGids_0100" << std::endl;
5390 }
5391 
5392 /**
5393  * @tc.number: CheckIsSystemAppByUid_0100
5394  * @tc.name: test CheckIsSystemAppByUid proxy
5395  * @tc.desc: 1.get check  system app by uid
5396  */
5397 HWTEST_F(ActsBmsKitSystemTest, CheckIsSystemAppByUid_0100, Function | MediumTest | Level1)
5398 {
5399     std::cout << "START CheckIsSystemAppByUid_0100" << std::endl;
5400     std::vector<std::string> resvec;
5401     std::string bundleFilePath = THIRD_BUNDLE_PATH + "bmsThirdBundle1.hap";
5402     std::string appName = BASE_BUNDLE_NAME + "1";
5403     Install(bundleFilePath, InstallFlag::REPLACE_EXISTING, resvec);
5404     CommonTool commonTool;
5405     std::string installResult = commonTool.VectorToStr(resvec);
5406     EXPECT_EQ(installResult, "Success") << "install fail!";
5407 
5408     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
5409     ASSERT_NE(bundleMgrProxy, nullptr);
5410 
5411     std::vector<int> gids;
5412     BundleInfo bundleInfo;
5413     bundleMgrProxy->GetBundleInfo(appName, BundleFlag::GET_BUNDLE_DEFAULT, bundleInfo, USERID);
5414     bool ret = bundleMgrProxy->CheckIsSystemAppByUid(bundleInfo.uid);
5415     EXPECT_TRUE(ret);
5416 
5417     resvec.clear();
5418     Uninstall(appName, resvec);
5419     std::string uninstallResult = commonTool.VectorToStr(resvec);
5420     EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!";
5421     std::cout << "END CheckIsSystemAppByUid_0100" << std::endl;
5422 }
5423 
5424 /**
5425  * @tc.number: QueryAbilityInfos_0100
5426  * @tc.name: test QueryAbilityInfos proxy
5427  * @tc.desc: 1.query ability infos
5428  */
5429 HWTEST_F(ActsBmsKitSystemTest, QueryAbilityInfos_0100, Function | MediumTest | Level1)
5430 {
5431     std::cout << "START QueryAbilityInfos_0100" << std::endl;
5432     std::vector<std::string> resvec;
5433     std::string bundleFilePath = THIRD_BUNDLE_PATH + "bmsThirdBundle1.hap";
5434     std::string appName = BASE_BUNDLE_NAME + "1";
5435     std::string abilityName = BASE_ABILITY_NAME;
5436     Install(bundleFilePath, InstallFlag::REPLACE_EXISTING, resvec);
5437     CommonTool commonTool;
5438     std::string installResult = commonTool.VectorToStr(resvec);
5439     EXPECT_EQ(installResult, "Success") << "install fail!";
5440 
5441     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
5442     ASSERT_NE(bundleMgrProxy, nullptr);
5443 
5444     Want want;
5445     ElementName name;
5446     name.SetAbilityName(abilityName);
5447     name.SetBundleName(appName);
5448     want.SetElement(name);
5449     std::vector<AbilityInfo> AbilityInfo;
5450     auto ret = bundleMgrProxy->QueryAbilityInfos(want, GET_ABILITY_INFO_DEFAULT, USERID, AbilityInfo);
5451     EXPECT_TRUE(ret);
5452 
5453     resvec.clear();
5454     Uninstall(appName, resvec);
5455     std::string uninstallResult = commonTool.VectorToStr(resvec);
5456     EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!";
5457     std::cout << "END QueryAbilityInfos_0100" << std::endl;
5458 }
5459 
5460 /**
5461  * @tc.number: QueryAbilityInfos_0200
5462  * @tc.name: test QueryAbilityInfos proxy
5463  * @tc.desc: 1.query ability infos
5464  */
5465 HWTEST_F(ActsBmsKitSystemTest, QueryAbilityInfos_0200, Function | MediumTest | Level1)
5466 {
5467     std::cout << "START QueryAbilityInfos_0100" << std::endl;
5468     std::vector<std::string> resvec;
5469     std::string bundleFilePath = THIRD_BUNDLE_PATH + "bmsThirdBundle1.hap";
5470     std::string appName = BASE_BUNDLE_NAME + "1";
5471     std::string abilityName = BASE_ABILITY_NAME;
5472     Install(bundleFilePath, InstallFlag::REPLACE_EXISTING, resvec);
5473     CommonTool commonTool;
5474     std::string installResult = commonTool.VectorToStr(resvec);
5475     EXPECT_EQ(installResult, "Success") << "install fail!";
5476 
5477     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
5478     ASSERT_NE(bundleMgrProxy, nullptr);
5479 
5480     Want want;
5481     ElementName name;
5482     name.SetAbilityName(abilityName);
5483     name.SetBundleName(appName);
5484     want.SetElement(name);
5485     std::vector<AbilityInfo> AbilityInfo;
5486     auto ret = bundleMgrProxy->QueryAbilityInfos(want, AbilityInfo);
5487     EXPECT_FALSE(ret);
5488 
5489     resvec.clear();
5490     Uninstall(appName, resvec);
5491     std::string uninstallResult = commonTool.VectorToStr(resvec);
5492     EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!";
5493     std::cout << "END QueryAbilityInfos_0200" << std::endl;
5494 }
5495 
5496 /**
5497  * @tc.number: QueryAbilityInfos_0300
5498  * @tc.name: test QueryAbilityInfos proxy
5499  * @tc.desc: 1.install clone app
5500  *           2.query main and clone app's ability infos
5501  */
5502 HWTEST_F(ActsBmsKitSystemTest, QueryAbilityInfos_0300, Function | MediumTest | Level1)
5503 {
5504     StartProcess();
5505     std::cout << "START QueryAbilityInfos_0300" << std::endl;
5506     std::vector<std::string> resvec;
5507     std::string bundleFilePath = THIRD_BUNDLE_PATH + "bundleClient1.hap";
5508     std::string appName = "com.example.ohosproject.hmservice";
5509     Install(bundleFilePath, InstallFlag::REPLACE_EXISTING, resvec);
5510     CommonTool commonTool;
5511     std::string installResult = commonTool.VectorToStr(resvec);
5512     EXPECT_EQ(installResult, "Success") << "install fail!";
5513 
5514     sptr<IBundleInstaller> installerProxy = GetInstallerProxy();
5515     ASSERT_NE(installerProxy, nullptr);
5516     int appIndex1 = TEST_APP_INDEX1;
5517     ErrCode ret = installerProxy->InstallCloneApp(appName, USERID, appIndex1);
5518     EXPECT_EQ(ret, ERR_OK);
5519     int appIndex2 = TEST_APP_INDEX2;
5520     ret = installerProxy->InstallCloneApp(appName, USERID, appIndex2);
5521     EXPECT_EQ(ret, ERR_OK);
5522 
5523     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
5524     ASSERT_NE(bundleMgrProxy, nullptr);
5525 
5526     std::string abilityName = "MainAbility";
5527     Want want;
5528     ElementName name;
5529     name.SetAbilityName(abilityName);
5530     name.SetBundleName(appName);
5531     want.SetElement(name);
5532     std::vector<AbilityInfo> abilityInfos;
5533     auto queryRes = bundleMgrProxy->QueryAbilityInfos(want, GET_ABILITY_INFO_DEFAULT, USERID, abilityInfos);
5534     EXPECT_TRUE(queryRes);
5535     size_t expectedSize = 3;
5536     EXPECT_EQ(abilityInfos.size(), expectedSize);
5537     int index = 0;
5538     for (const auto &item : abilityInfos) {
5539         EXPECT_EQ(item.appIndex, index++);
5540     }
5541 
5542     ret = installerProxy->UninstallCloneApp(appName, USERID, appIndex2);
5543     EXPECT_EQ(ret, ERR_OK);
5544     ret = installerProxy->UninstallCloneApp(appName, USERID, appIndex1);
5545     EXPECT_EQ(ret, ERR_OK);
5546 
5547     resvec.clear();
5548     Uninstall(appName, resvec);
5549     std::string uninstallResult = commonTool.VectorToStr(resvec);
5550     EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!";
5551     std::cout << "END QueryAbilityInfos_0300" << std::endl;
5552 }
5553 
5554 /**
5555  * @tc.number: QueryAbilityInfosV9_0100
5556  * @tc.name: test QueryAbilityInfosV9 proxy
5557  * @tc.desc: 1.query ability infos
5558  */
5559 HWTEST_F(ActsBmsKitSystemTest, QueryAbilityInfosV9_0100, Function | MediumTest | Level1)
5560 {
5561     std::cout << "START QueryAbilityInfos_0100" << std::endl;
5562     std::vector<std::string> resvec;
5563     std::string bundleFilePath = THIRD_BUNDLE_PATH + "bmsThirdBundle1.hap";
5564     std::string appName = BASE_BUNDLE_NAME + "1";
5565     std::string abilityName = BASE_ABILITY_NAME;
5566     Install(bundleFilePath, InstallFlag::REPLACE_EXISTING, resvec);
5567     CommonTool commonTool;
5568     std::string installResult = commonTool.VectorToStr(resvec);
5569     EXPECT_EQ(installResult, "Success") << "install fail!";
5570 
5571     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
5572     ASSERT_NE(bundleMgrProxy, nullptr);
5573 
5574     Want want;
5575     ElementName name;
5576     name.SetAbilityName(abilityName);
5577     name.SetBundleName(appName);
5578     want.SetElement(name);
5579     std::vector<AbilityInfo> AbilityInfo;
5580     auto ret = bundleMgrProxy->QueryAbilityInfosV9(want, static_cast<int32_t>(
5581         GetAbilityInfoFlag::GET_ABILITY_INFO_DEFAULT), USERID, AbilityInfo);
5582     EXPECT_EQ(ret, ERR_OK);
5583 
5584     resvec.clear();
5585     Uninstall(appName, resvec);
5586     std::string uninstallResult = commonTool.VectorToStr(resvec);
5587     EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!";
5588     std::cout << "END QueryAbilityInfos_0100" << std::endl;
5589 }
5590 
5591 /**
5592  * @tc.number: QueryAbilityInfosV9_0200
5593  * @tc.name: test QueryAbilityInfosV9 proxy
5594  * @tc.desc: 1.query ability infos
5595  */
5596 HWTEST_F(ActsBmsKitSystemTest, QueryAbilityInfosV9_0200, Function | MediumTest | Level1)
5597 {
5598     StartProcess();
5599     std::cout << "START QueryAbilityInfosV9_0200" << std::endl;
5600     std::vector<std::string> resvec;
5601     std::string bundleFilePath = THIRD_BUNDLE_PATH + "bundleClient1.hap";
5602     std::string appName = "com.example.ohosproject.hmservice";
5603     Install(bundleFilePath, InstallFlag::REPLACE_EXISTING, resvec);
5604     CommonTool commonTool;
5605     std::string installResult = commonTool.VectorToStr(resvec);
5606     EXPECT_EQ(installResult, "Success") << "install fail!";
5607 
5608     sptr<IBundleInstaller> installerProxy = GetInstallerProxy();
5609     ASSERT_NE(installerProxy, nullptr);
5610     int appIndex1 = TEST_APP_INDEX1;
5611     ErrCode ret = installerProxy->InstallCloneApp(appName, USERID, appIndex1);
5612     EXPECT_EQ(ret, ERR_OK);
5613     int appIndex2 = TEST_APP_INDEX2;
5614     ret = installerProxy->InstallCloneApp(appName, USERID, appIndex2);
5615     EXPECT_EQ(ret, ERR_OK);
5616 
5617     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
5618     ASSERT_NE(bundleMgrProxy, nullptr);
5619 
5620     std::string abilityName = "MainAbility";
5621     Want want;
5622     ElementName name;
5623     name.SetAbilityName(abilityName);
5624     name.SetBundleName(appName);
5625     want.SetElement(name);
5626     std::vector<AbilityInfo> abilityInfos;
5627     ret = bundleMgrProxy->QueryAbilityInfosV9(want, static_cast<int32_t>(
5628         GetAbilityInfoFlag::GET_ABILITY_INFO_DEFAULT), USERID, abilityInfos);
5629     EXPECT_EQ(ret, ERR_OK);
5630     size_t expectedSize = 3;
5631     EXPECT_EQ(abilityInfos.size(), expectedSize);
5632     int index = 0;
5633     for (const auto &item : abilityInfos) {
5634         EXPECT_EQ(item.appIndex, index++);
5635     }
5636 
5637     ret = installerProxy->UninstallCloneApp(appName, USERID, appIndex2);
5638     EXPECT_EQ(ret, ERR_OK);
5639     ret = installerProxy->UninstallCloneApp(appName, USERID, appIndex1);
5640     EXPECT_EQ(ret, ERR_OK);
5641 
5642     resvec.clear();
5643     Uninstall(appName, resvec);
5644     std::string uninstallResult = commonTool.VectorToStr(resvec);
5645     EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!";
5646     std::cout << "END QueryAbilityInfosV9_0200" << std::endl;
5647 }
5648 
5649 /**
5650  * @tc.number: QueryAllAbilityInfos_0100
5651  * @tc.name: test QueryAllAbilityInfos proxy
5652  * @tc.desc: 1.query all ability infos
5653  */
5654 HWTEST_F(ActsBmsKitSystemTest, QueryAllAbilityInfos_0100, Function | MediumTest | Level1)
5655 {
5656     std::cout << "START QueryAllAbilityInfos_0100" << std::endl;
5657     std::vector<std::string> resvec;
5658     std::string bundleFilePath = THIRD_BUNDLE_PATH + "bmsThirdBundle1.hap";
5659     std::string appName = BASE_BUNDLE_NAME + "1";
5660     std::string abilityName = BASE_ABILITY_NAME;
5661     Install(bundleFilePath, InstallFlag::REPLACE_EXISTING, resvec);
5662     CommonTool commonTool;
5663     std::string installResult = commonTool.VectorToStr(resvec);
5664     EXPECT_EQ(installResult, "Success") << "install fail!";
5665 
5666     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
5667     ASSERT_NE(bundleMgrProxy, nullptr);
5668 
5669     Want want;
5670     ElementName name;
5671     name.SetAbilityName(abilityName);
5672     name.SetBundleName(appName);
5673     want.SetElement(name);
5674     std::vector<AbilityInfo> AbilityInfo;
5675     auto ret = bundleMgrProxy->QueryAllAbilityInfos(want, USERID, AbilityInfo);
5676     EXPECT_TRUE(ret);
5677 
5678     resvec.clear();
5679     Uninstall(appName, resvec);
5680     std::string uninstallResult = commonTool.VectorToStr(resvec);
5681     EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!";
5682     std::cout << "END QueryAllAbilityInfos_0100" << std::endl;
5683 }
5684 
5685 /**
5686  * @tc.number: GetAppPrivilegeLevel_0100
5687  * @tc.name: test GetAppPrivilegeLevel interface
5688  * @tc.desc: 1.get app privilege level
5689  *           2.the level is system_core
5690  */
5691 HWTEST_F(ActsBmsKitSystemTest, GetAppPrivilegeLevel_0100, Function | MediumTest | Level1)
5692 {
5693     std::cout << "START GetAppPrivilegeLevel_0100" << std::endl;
5694     std::vector<std::string> resvec;
5695     std::string bundleFilePath = THIRD_BUNDLE_PATH + "bmsThirdBundle1.hap";
5696     std::string appName = BASE_BUNDLE_NAME + "1";
5697     Install(bundleFilePath, InstallFlag::REPLACE_EXISTING, resvec);
5698     CommonTool commonTool;
5699     std::string installResult = commonTool.VectorToStr(resvec);
5700     EXPECT_EQ(installResult, "Success") << "install fail!";
5701 
5702     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
5703     ASSERT_NE(bundleMgrProxy, nullptr);
5704 
5705     auto ret = bundleMgrProxy->GetAppPrivilegeLevel(appName, USERID);
5706     EXPECT_EQ(ret, "system_core");
5707 
5708     resvec.clear();
5709     Uninstall(appName, resvec);
5710     std::string uninstallResult = commonTool.VectorToStr(resvec);
5711     EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!";
5712     std::cout << "END GetAppPrivilegeLevel_0100" << std::endl;
5713 }
5714 
5715 /**
5716  * @tc.number: GetAppPrivilegeLevel_0200
5717  * @tc.name: test GetAppPrivilegeLevel interface
5718  * @tc.desc: 1.get app privilege level failed by empty bundle name
5719  */
5720 HWTEST_F(ActsBmsKitSystemTest, GetAppPrivilegeLevel_0200, Function | MediumTest | Level1)
5721 {
5722     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
5723     ASSERT_NE(bundleMgrProxy, nullptr);
5724 
5725     auto ret = bundleMgrProxy->GetAppPrivilegeLevel("", USERID);
5726     EXPECT_NE(ret, "system_core");
5727 }
5728 
5729 /**
5730  * @tc.number: GetAbilityInfo_0100
5731  * @tc.name: test GetAbilityInfo proxy
5732  * @tc.desc: 1.get ability info fail by empty abilityName
5733  */
5734 HWTEST_F(ActsBmsKitSystemTest, GetAbilityInfo_0100, Function | MediumTest | Level1)
5735 {
5736     std::cout << "START GetAbilityInfo_0100" << std::endl;
5737     std::vector<std::string> resvec;
5738     std::string bundleFilePath = THIRD_BUNDLE_PATH + "bmsThirdBundle1.hap";
5739     std::string appName = BASE_BUNDLE_NAME + "1";
5740     Install(bundleFilePath, InstallFlag::REPLACE_EXISTING, resvec);
5741     CommonTool commonTool;
5742     std::string installResult = commonTool.VectorToStr(resvec);
5743     EXPECT_EQ(installResult, "Success") << "install fail!";
5744 
5745     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
5746     ASSERT_NE(bundleMgrProxy, nullptr);
5747 
5748     AbilityInfo abilityInfo;
5749     bool ret = bundleMgrProxy->GetAbilityInfo(appName, "", abilityInfo);
5750     EXPECT_FALSE(ret);
5751 
5752     resvec.clear();
5753     Uninstall(appName, resvec);
5754     std::string uninstallResult = commonTool.VectorToStr(resvec);
5755     EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!";
5756     std::cout << "END GetAbilityInfo_0100" << std::endl;
5757 }
5758 
5759 /**
5760  * @tc.number: GetBundlePackInfo_0100
5761  * @tc.name: test can get the pack info by uri
5762  * @tc.desc: 1.system run normally
5763  *           2.get pack info successfully
5764  */
5765 HWTEST_F(ActsBmsKitSystemTest, GetBundlePackInfo_0100, Function | SmallTest | Level1)
5766 {
5767     std::cout << "START GetAbilityInfo_0100" << std::endl;
5768     std::vector<std::string> resvec;
5769     std::string bundleFilePath = THIRD_BUNDLE_PATH + "bmsThirdBundle1.hap";
5770     std::string appName = BASE_BUNDLE_NAME + "1";
5771     Install(bundleFilePath, InstallFlag::REPLACE_EXISTING, resvec);
5772     CommonTool commonTool;
5773     std::string installResult = commonTool.VectorToStr(resvec);
5774     EXPECT_EQ(installResult, "Success") << "install fail!";
5775 
5776     BundlePackInfo bundlePackInfo;
5777     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
5778     ASSERT_NE(bundleMgrProxy, nullptr);
5779     auto testRet = bundleMgrProxy->GetBundlePackInfo(
5780         appName, GET_PACK_INFO_ALL, bundlePackInfo, USERID);
5781     EXPECT_EQ(testRet, ERR_OK);
5782 
5783     resvec.clear();
5784     Uninstall(appName, resvec);
5785     std::string uninstallResult = commonTool.VectorToStr(resvec);
5786     EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!";
5787     std::cout << "END GetBundlePackInfo_0100" << std::endl;
5788 }
5789 
5790 /**
5791  * @tc.number: GetBundlePackInfo_0200
5792  * @tc.name: test can get the pack info by uri
5793  * @tc.desc: 1.system run normally
5794  *           2.get pack info successfully
5795  */
5796 HWTEST_F(ActsBmsKitSystemTest, GetBundlePackInfo_0200, Function | SmallTest | Level1)
5797 {
5798     std::cout << "START GetBundlePackInfo_0200" << std::endl;
5799     std::vector<std::string> resvec;
5800     std::string bundleFilePath = THIRD_BUNDLE_PATH + "bmsThirdBundle1.hap";
5801     std::string appName = BASE_BUNDLE_NAME + "1";
5802     Install(bundleFilePath, InstallFlag::REPLACE_EXISTING, resvec);
5803     CommonTool commonTool;
5804     std::string installResult = commonTool.VectorToStr(resvec);
5805     EXPECT_EQ(installResult, "Success") << "install fail!";
5806 
5807     BundlePackInfo bundlePackInfo;
5808     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
5809     ASSERT_NE(bundleMgrProxy, nullptr);
5810     auto testRet = bundleMgrProxy->GetBundlePackInfo(
5811         appName, BundleFlag::GET_BUNDLE_DEFAULT, bundlePackInfo, USERID);
5812     EXPECT_EQ(ERR_OK, testRet);
5813 
5814     resvec.clear();
5815     Uninstall(appName, resvec);
5816     std::string uninstallResult = commonTool.VectorToStr(resvec);
5817     EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!";
5818     std::cout << "END GetBundlePackInfo_0200" << std::endl;
5819 }
5820 
5821 /**
5822  * @tc.number: GetBundlePackInfo_0300
5823  * @tc.name: test can get the pack info by uri
5824  * @tc.desc: 1.system run normally
5825  *           2.get pack info failed by empty bundle name
5826  */
5827 HWTEST_F(ActsBmsKitSystemTest, GetBundlePackInfo_0300, Function | SmallTest | Level1)
5828 {
5829     BundlePackInfo bundlePackInfo;
5830     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
5831     ASSERT_NE(bundleMgrProxy, nullptr);
5832     int32_t flag = 0;
5833     ErrCode testRet = bundleMgrProxy->GetBundlePackInfo(
5834         "", BundleFlag::GET_BUNDLE_DEFAULT, bundlePackInfo, USERID);
5835     EXPECT_NE(ERR_OK, testRet);
5836     ErrCode testRet1 = bundleMgrProxy->GetBundlePackInfo(
5837         "", flag, bundlePackInfo, USERID);
5838     EXPECT_NE(ERR_OK, testRet1);
5839 }
5840 
5841 /**
5842  * @tc.number: ImplicitQueryInfoByPriority_0100
5843  * @tc.name: test can implicit query Infos by priority
5844  * @tc.desc: 1.system run normally
5845  *           2.implicit query Infos by priority failed
5846  */
5847 HWTEST_F(ActsBmsKitSystemTest, ImplicitQueryInfoByPriority_0100, Function | SmallTest | Level1)
5848 {
5849     std::cout << "START ImplicitQueryInfoByPriority_0100" << std::endl;
5850     std::vector<std::string> resvec;
5851     std::string bundleFilePath = THIRD_BUNDLE_PATH + "bmsThirdBundle1.hap";
5852     std::string appName = BASE_BUNDLE_NAME + "1";
5853     Install(bundleFilePath, InstallFlag::REPLACE_EXISTING, resvec);
5854     CommonTool commonTool;
5855     std::string installResult = commonTool.VectorToStr(resvec);
5856     EXPECT_EQ(installResult, "Success") << "install fail!";
5857 
5858     AbilityInfo abilityInfo;
5859     ExtensionAbilityInfo extensionAbilityInfo;
5860     Want want;
5861     ElementName name;
5862     name.SetAbilityName(BASE_ABILITY_NAME);
5863     name.SetBundleName(appName);
5864     want.SetElement(name);
5865 
5866     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
5867     ASSERT_NE(bundleMgrProxy, nullptr);
5868     bool testRet = bundleMgrProxy->ImplicitQueryInfoByPriority(
5869         want, BundleFlag::GET_BUNDLE_DEFAULT, USERID, abilityInfo, extensionAbilityInfo);
5870     EXPECT_EQ(false, testRet);
5871 
5872     resvec.clear();
5873     Uninstall(appName, resvec);
5874     std::string uninstallResult = commonTool.VectorToStr(resvec);
5875     EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!";
5876     std::cout << "END ImplicitQueryInfoByPriority_0100" << std::endl;
5877 }
5878 
5879 /**
5880  * @tc.number: ImplicitQueryInfos_0100
5881  * @tc.name: test can Implicit query Infos
5882  * @tc.desc: 1.system run normally
5883  *           2.query Infos failed
5884  */
5885 HWTEST_F(ActsBmsKitSystemTest, ImplicitQueryInfos_0100, Function | SmallTest | Level1)
5886 {
5887     std::cout << "START ImplicitQueryInfos_0100" << std::endl;
5888     std::vector<std::string> resvec;
5889     std::string bundleFilePath = THIRD_BUNDLE_PATH + "bmsThirdBundle1.hap";
5890     std::string appName = BASE_BUNDLE_NAME + "1";
5891     Install(bundleFilePath, InstallFlag::REPLACE_EXISTING, resvec);
5892     CommonTool commonTool;
5893     std::string installResult = commonTool.VectorToStr(resvec);
5894     EXPECT_EQ(installResult, "Success") << "install fail!";
5895 
5896     std::vector<AbilityInfo> abilityInfos;
5897     std::vector<ExtensionAbilityInfo> extensionInfos;
5898     bool findDefaultApp = false;
5899     Want want;
5900     ElementName name;
5901     name.SetAbilityName(BASE_ABILITY_NAME);
5902     name.SetBundleName(appName);
5903     want.SetElement(name);
5904 
5905     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
5906     ASSERT_NE(bundleMgrProxy, nullptr);
5907     bool testRet = bundleMgrProxy->ImplicitQueryInfos(
5908         want, BundleFlag::GET_BUNDLE_DEFAULT, USERID, true, abilityInfos, extensionInfos, findDefaultApp);
5909     EXPECT_EQ(false, testRet);
5910     EXPECT_EQ(findDefaultApp, false);
5911 
5912     resvec.clear();
5913     Uninstall(appName, resvec);
5914     std::string uninstallResult = commonTool.VectorToStr(resvec);
5915     EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!";
5916     std::cout << "END ImplicitQueryInfos_0100" << std::endl;
5917 }
5918 
5919 /**
5920  * @tc.number: GetAllDependentModuleNames_0100
5921  * @tc.name: test can get all dependent module names
5922  * @tc.desc: 1.system run normally
5923  *           2.get all dependent module names
5924  */
5925 HWTEST_F(ActsBmsKitSystemTest, GetAllDependentModuleNames_0100, Function | SmallTest | Level1)
5926 {
5927     std::cout << "START GetAllDependentModuleNames_0100" << std::endl;
5928     std::vector<std::string> resvec;
5929     std::string bundleFilePath = THIRD_BUNDLE_PATH + "bmsThirdBundle1.hap";
5930     std::string appName = BASE_BUNDLE_NAME + "1";
5931     Install(bundleFilePath, InstallFlag::REPLACE_EXISTING, resvec);
5932     CommonTool commonTool;
5933     std::string installResult = commonTool.VectorToStr(resvec);
5934     EXPECT_EQ(installResult, "Success") << "install fail!";
5935 
5936     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
5937     ASSERT_NE(bundleMgrProxy, nullptr);
5938     std::vector<std::string> dependentModuleName;
5939     auto res = bundleMgrProxy->GetAllDependentModuleNames(appName, BASE_MODULE_NAME, dependentModuleName);
5940     EXPECT_TRUE(res);
5941     EXPECT_TRUE(dependentModuleName.empty());
5942 
5943     resvec.clear();
5944     Uninstall(appName, resvec);
5945     std::string uninstallResult = commonTool.VectorToStr(resvec);
5946     EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!";
5947     std::cout << "END GetAllDependentModuleNames_0100" << std::endl;
5948 }
5949 
5950 /**
5951  * @tc.number: GetAllDependentModuleNames_0200
5952  * @tc.name: test can get all dependent module names
5953  * @tc.desc: 1.system run normally
5954  *           2.get all dependent module names failed by empty bundle name
5955  */
5956 HWTEST_F(ActsBmsKitSystemTest, GetAllDependentModuleNames_0200, Function | SmallTest | Level1)
5957 {
5958     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
5959     ASSERT_NE(bundleMgrProxy, nullptr);
5960     std::vector<std::string> dependentModuleName;
5961     auto res = bundleMgrProxy->GetAllDependentModuleNames("", BASE_MODULE_NAME, dependentModuleName);
5962     EXPECT_FALSE(res);
5963 
5964     res = bundleMgrProxy->GetAllDependentModuleNames(BASE_BUNDLE_NAME, "", dependentModuleName);
5965     EXPECT_FALSE(res);
5966 
5967     res = bundleMgrProxy->GetAllDependentModuleNames("", "", dependentModuleName);
5968     EXPECT_FALSE(res);
5969 }
5970 
5971 /**
5972  * @tc.number: GetModuleUpgradeFlag_0100
5973  * @tc.name: test can get the module upgrade flag
5974  * @tc.desc: 1.system run normally
5975  *           2.set module upgrade flag successfully
5976  *           3.get module upgrade flag successfully
5977  */
5978 HWTEST_F(ActsBmsKitSystemTest, GetModuleUpgradeFlag_0100, Function | SmallTest | Level1)
5979 {
5980     std::cout << "START GetModuleUpgradeFlag_0100" << std::endl;
5981     std::vector<std::string> resvec;
5982     std::string bundleFilePath = THIRD_BUNDLE_PATH + "bmsThirdBundle1.hap";
5983     std::string appName = BASE_BUNDLE_NAME + "1";
5984     Install(bundleFilePath, InstallFlag::REPLACE_EXISTING, resvec);
5985     CommonTool commonTool;
5986     std::string installResult = commonTool.VectorToStr(resvec);
5987     EXPECT_EQ(installResult, "Success") << "install fail!";
5988 
5989     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
5990     ASSERT_NE(bundleMgrProxy, nullptr);
5991     auto result = bundleMgrProxy->SetModuleUpgradeFlag(appName, BASE_MODULE_NAME, 1);
5992     EXPECT_TRUE(result == ERR_OK);
5993     auto res = bundleMgrProxy->GetModuleUpgradeFlag(appName, BASE_MODULE_NAME);
5994     EXPECT_TRUE(res);
5995 
5996     resvec.clear();
5997     Uninstall(appName, resvec);
5998     std::string uninstallResult = commonTool.VectorToStr(resvec);
5999     EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!";
6000     std::cout << "END GetModuleUpgradeFlag_0100" << std::endl;
6001 }
6002 
6003 /**
6004  * @tc.number: GetModuleUpgradeFlag_0200
6005  * @tc.name: test can get the module upgrade flag
6006  * @tc.desc: 1.system run normally
6007  *           2.set module upgrade flag failed
6008  *           3.get module upgrade flag failed
6009  */
6010 HWTEST_F(ActsBmsKitSystemTest, GetModuleUpgradeFlag_0200, Function | SmallTest | Level1)
6011 {
6012     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
6013     ASSERT_NE(bundleMgrProxy, nullptr);
6014     ErrCode result = bundleMgrProxy->SetModuleUpgradeFlag("", BASE_MODULE_NAME, 1);
6015     EXPECT_NE(result, ERR_OK);
6016     ErrCode result1 = bundleMgrProxy->SetModuleUpgradeFlag(BASE_BUNDLE_NAME, "", 1);
6017     EXPECT_NE(result1, ERR_OK);
6018     bool res = bundleMgrProxy->GetModuleUpgradeFlag("", BASE_MODULE_NAME);
6019     EXPECT_FALSE(res);
6020 
6021     res = bundleMgrProxy->GetModuleUpgradeFlag(BASE_BUNDLE_NAME, "");
6022     EXPECT_FALSE(res);
6023 
6024     res = bundleMgrProxy->GetModuleUpgradeFlag("", "");
6025     EXPECT_FALSE(res);
6026 }
6027 
6028 /**
6029  * @tc.number: ObtainCallingBundleName_0100
6030  * @tc.name: test can get the calling bundle name
6031  * @tc.desc: 1.system run normally
6032  *           2.get calling bundle name failed
6033  */
6034 HWTEST_F(ActsBmsKitSystemTest, ObtainCallingBundleName_0100, Function | SmallTest | Level1)
6035 {
6036     std::cout << "START ObtainCallingBundleName_0100" << std::endl;
6037     std::vector<std::string> resvec;
6038     std::string bundleFilePath = THIRD_BUNDLE_PATH + "bmsThirdBundle1.hap";
6039     std::string appName = BASE_BUNDLE_NAME + "1";
6040     Install(bundleFilePath, InstallFlag::REPLACE_EXISTING, resvec);
6041     CommonTool commonTool;
6042     std::string installResult = commonTool.VectorToStr(resvec);
6043     EXPECT_EQ(installResult, "Success") << "install fail!";
6044 
6045     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
6046     ASSERT_NE(bundleMgrProxy, nullptr);
6047     auto res = bundleMgrProxy->ObtainCallingBundleName(appName);
6048     EXPECT_FALSE(res);
6049 
6050     resvec.clear();
6051     Uninstall(appName, resvec);
6052     std::string uninstallResult = commonTool.VectorToStr(resvec);
6053     EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!";
6054     std::cout << "END ObtainCallingBundleName_0100" << std::endl;
6055 }
6056 
6057 /**
6058  * @tc.number: ObtainCallingBundleName_0200
6059  * @tc.name: test can get the calling bundle name
6060  * @tc.desc: 1.system run normally
6061  *           2.get calling bundle name failed by empty bundle name
6062  */
6063 HWTEST_F(ActsBmsKitSystemTest, ObtainCallingBundleName_0200, Function | SmallTest | Level1)
6064 {
6065     std::string appName = "";
6066     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
6067     ASSERT_NE(bundleMgrProxy, nullptr);
6068     auto res = bundleMgrProxy->ObtainCallingBundleName(appName);
6069     EXPECT_FALSE(res);
6070 }
6071 
6072 /**
6073  * @tc.number: GetBundleStats_0100
6074  * @tc.name: test can get the bundle stats info
6075  * @tc.desc: 1.system run normally
6076  *           2.get bundle stats info successfully
6077  */
6078 HWTEST_F(ActsBmsKitSystemTest, GetBundleStats_0100, Function | SmallTest | Level1)
6079 {
6080     std::cout << "START GetBundleStats_0100" << std::endl;
6081     std::vector<std::string> resvec;
6082     std::string bundleFilePath = THIRD_BUNDLE_PATH + "bmsThirdBundle1.hap";
6083     std::string appName = BASE_BUNDLE_NAME + "1";
6084     Install(bundleFilePath, InstallFlag::REPLACE_EXISTING, resvec);
6085     CommonTool commonTool;
6086     std::string installResult = commonTool.VectorToStr(resvec);
6087     EXPECT_EQ(installResult, "Success") << "install fail!";
6088 
6089     std::vector<int64_t> bundleStats;
6090     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
6091     ASSERT_NE(bundleMgrProxy, nullptr);
6092     auto res = bundleMgrProxy->GetBundleStats(appName, USERID, bundleStats);
6093     EXPECT_TRUE(res);
6094 
6095     resvec.clear();
6096     Uninstall(appName, resvec);
6097     std::string uninstallResult = commonTool.VectorToStr(resvec);
6098     EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!";
6099     std::cout << "END GetBundleStats_0100" << std::endl;
6100 }
6101 
6102 /**
6103  * @tc.number: GetBundleStats_0200
6104  * @tc.name: test can get the bundle stats info
6105  * @tc.desc: 1.system run normally
6106  *           2.install the clone app
6107  *           3.get bundle stats info with appIndex successfully
6108  */
6109 HWTEST_F(ActsBmsKitSystemTest, GetBundleStats_0200, Function | SmallTest | Level1)
6110 {
6111     StartProcess();
6112     std::cout << "START GetBundleStats_0200" << std::endl;
6113     std::vector<std::string> resvec;
6114     std::string bundleFilePath = THIRD_BUNDLE_PATH + "bundleClient1.hap";
6115     std::string appName = "com.example.ohosproject.hmservice";
6116     Install(bundleFilePath, InstallFlag::REPLACE_EXISTING, resvec);
6117     CommonTool commonTool;
6118     std::string installResult = commonTool.VectorToStr(resvec);
6119     EXPECT_EQ(installResult, "Success") << "install fail!";
6120 
6121     sptr<IBundleInstaller> installerProxy = GetInstallerProxy();
6122     ASSERT_NE(installerProxy, nullptr);
6123     int appIndex1 = TEST_APP_INDEX1;
6124     ErrCode ret = installerProxy->InstallCloneApp(appName, USERID, appIndex1);
6125     EXPECT_EQ(ret, ERR_OK);
6126 
6127     std::vector<int64_t> bundleStats;
6128     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
6129     ASSERT_NE(bundleMgrProxy, nullptr);
6130     auto res = bundleMgrProxy->GetBundleStats(appName, USERID, bundleStats, appIndex1);
6131     EXPECT_TRUE(res);
6132 
6133     ret = installerProxy->UninstallCloneApp(appName, USERID, appIndex1);
6134     EXPECT_EQ(ret, ERR_OK);
6135 
6136     resvec.clear();
6137     Uninstall(appName, resvec);
6138     std::string uninstallResult = commonTool.VectorToStr(resvec);
6139     EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!";
6140     std::cout << "END GetBundleStats_0200" << std::endl;
6141 }
6142 /**
6143  * @tc.number: GetStringById_0100
6144  * @tc.name: test can get the string info
6145  * @tc.desc: 1.system run normally
6146  *           2.get empty info
6147  */
6148 HWTEST_F(ActsBmsKitSystemTest, GetStringById_0100, Function | SmallTest | Level1)
6149 {
6150     std::cout << "START GetStringById" << std::endl;
6151     std::vector<std::string> resvec;
6152     std::string bundleFilePath = THIRD_BUNDLE_PATH + "bmsThirdBundle1.hap";
6153     std::string appName = BASE_BUNDLE_NAME + "1";
6154     Install(bundleFilePath, InstallFlag::REPLACE_EXISTING, resvec);
6155     CommonTool commonTool;
6156     std::string installResult = commonTool.VectorToStr(resvec);
6157     EXPECT_EQ(installResult, "Success") << "install fail!";
6158 
6159     std::vector<int64_t> bundleStats;
6160     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
6161     ASSERT_NE(bundleMgrProxy, nullptr);
6162     auto res = bundleMgrProxy->GetStringById(appName, BASE_MODULE_NAME, RESID, USERID);
6163     EXPECT_EQ(res, "");
6164 
6165     resvec.clear();
6166     Uninstall(appName, resvec);
6167     std::string uninstallResult = commonTool.VectorToStr(resvec);
6168     EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!";
6169     std::cout << "END GetStringById" << std::endl;
6170 }
6171 
6172 /**
6173  * @tc.number: GetStringById_0200
6174  * @tc.name: test can get the string info
6175  * @tc.desc: 1.system run normally
6176  *           2.get empty info failed by empty bundle name
6177  */
6178 HWTEST_F(ActsBmsKitSystemTest, GetStringById_0200, Function | SmallTest | Level1)
6179 {
6180     std::vector<int64_t> bundleStats;
6181     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
6182     ASSERT_NE(bundleMgrProxy, nullptr);
6183     auto res = bundleMgrProxy->GetStringById("", BASE_MODULE_NAME, RESID, USERID);
6184     EXPECT_EQ(res, "");
6185 
6186     res = bundleMgrProxy->GetStringById(BASE_MODULE_NAME, "", RESID, USERID);
6187     EXPECT_EQ(res, "");
6188 
6189     res = bundleMgrProxy->GetStringById("", "", RESID, USERID);
6190     EXPECT_EQ(res, "");
6191 }
6192 
6193 /**
6194  * @tc.number: GetIconById_0100
6195  * @tc.name: test can get the icon info
6196  * @tc.desc: 1.system run normally
6197  *           2.get GetIconById info successfully
6198  */
6199 HWTEST_F(ActsBmsKitSystemTest, GetIconById_0100, Function | SmallTest | Level1)
6200 {
6201     std::cout << "START GetIconById_0100" << std::endl;
6202     std::vector<std::string> resvec;
6203     std::string bundleFilePath = THIRD_BUNDLE_PATH + "bmsThirdBundle1.hap";
6204     std::string appName = BASE_BUNDLE_NAME + "1";
6205     Install(bundleFilePath, InstallFlag::REPLACE_EXISTING, resvec);
6206     CommonTool commonTool;
6207     std::string installResult = commonTool.VectorToStr(resvec);
6208     EXPECT_EQ(installResult, "Success") << "install fail!";
6209 
6210     std::vector<int64_t> bundleStats;
6211     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
6212     ASSERT_NE(bundleMgrProxy, nullptr);
6213     auto res = bundleMgrProxy->GetIconById(appName, BASE_MODULE_NAME, RESID, 0, USERID);
6214     EXPECT_NE(res, "");
6215 
6216     resvec.clear();
6217     Uninstall(appName, resvec);
6218     std::string uninstallResult = commonTool.VectorToStr(resvec);
6219     EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!";
6220     std::cout << "END GetIconById_0100" << std::endl;
6221 }
6222 
6223 /**
6224  * @tc.number: GetIconById_0200
6225  * @tc.name: test can get the icon info
6226  * @tc.desc: 1.system run normally
6227  *           2.get GetIconById info failed by empty bundle name
6228  */
6229 HWTEST_F(ActsBmsKitSystemTest, GetIconById_0200, Function | SmallTest | Level1)
6230 {
6231     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
6232     ASSERT_NE(bundleMgrProxy, nullptr);
6233     auto res = bundleMgrProxy->GetIconById("", BASE_MODULE_NAME, RESID, 0, USERID);
6234     EXPECT_EQ(res, EMPTY_STRING);
6235 
6236     res = bundleMgrProxy->GetIconById(BASE_MODULE_NAME, "", RESID, 0, USERID);
6237     EXPECT_EQ(res, EMPTY_STRING);
6238 
6239     res = bundleMgrProxy->GetIconById("", "", RESID, 0, USERID);
6240     EXPECT_EQ(res, EMPTY_STRING);
6241 }
6242 
6243 /**
6244  * @tc.number: GetPermissionDef_0100
6245  * @tc.name: test GetPermissionDef proxy
6246  * @tc.desc: 1.system run normally
6247  *           2.get permission info successfully
6248  */
6249 HWTEST_F(ActsBmsKitSystemTest, GetPermissionDef_0100, Function | SmallTest | Level1)
6250 {
6251     PermissionDef permissionDef;
6252     std::string permissionName = "ohos.permission.READ_CALENDAR";
6253     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
6254     ASSERT_NE(bundleMgrProxy, nullptr);
6255     int32_t ret = bundleMgrProxy->GetPermissionDef(permissionName, permissionDef);
6256     EXPECT_EQ(permissionDef.permissionName, permissionName);
6257     EXPECT_EQ(ret, ERR_OK);
6258 }
6259 
6260 /**
6261  * @tc.number: GetPermissionDef_0200
6262  * @tc.name: test GetPermissionDef proxy
6263  * @tc.desc: 1.system run normally
6264  *           2.get permission info failed by empty name
6265  */
6266 HWTEST_F(ActsBmsKitSystemTest, GetPermissionDef_0200, Function | SmallTest | Level1)
6267 {
6268     PermissionDef permissionDef;
6269     std::string permissionName = "";
6270     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
6271     ASSERT_NE(bundleMgrProxy, nullptr);
6272     int32_t ret = bundleMgrProxy->GetPermissionDef(permissionName, permissionDef);
6273     EXPECT_EQ(permissionDef.permissionName, permissionName);
6274     EXPECT_NE(ret, ERR_OK);
6275 }
6276 
6277 /**
6278  * @tc.number: SetDebugMode_0100
6279  * @tc.name: test SetDebugMode proxy
6280  * @tc.desc: 1.system run normally
6281  *           2.set debug mode successfully
6282  */
6283 HWTEST_F(ActsBmsKitSystemTest, SetDebugMode_0100, Function | SmallTest | Level1)
6284 {
6285     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
6286     ASSERT_NE(bundleMgrProxy, nullptr);
6287     auto res = bundleMgrProxy->SetDebugMode(true);
6288     EXPECT_EQ(res, ERR_OK);
6289 }
6290 
6291 /**
6292  * @tc.number: GetDefaultAppProxy_0100
6293  * @tc.name: test GetDefaultAppProxy proxy
6294  * @tc.desc: 1.system run normally
6295  *           2.test GetDefaultAppProxy
6296  */
6297 HWTEST_F(ActsBmsKitSystemTest, GetDefaultAppProxy_0100, Function | SmallTest | Level1)
6298 {
6299     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
6300     ASSERT_NE(bundleMgrProxy, nullptr);
6301     sptr<IDefaultApp> getDefaultAppProxy = bundleMgrProxy->GetDefaultAppProxy();
6302     bool isDefaultApp = false;
6303     ErrCode res = getDefaultAppProxy->IsDefaultApplication("", isDefaultApp);
6304     EXPECT_EQ(res, ERR_OK);
6305     EXPECT_FALSE(isDefaultApp);
6306 }
6307 
6308 /**
6309  * @tc.number: GetDefaultAppProxy_0400
6310  * @tc.name: test GetDefaultAppProxy proxy
6311  * @tc.desc: 1.system run normally
6312  *           2.test GetDefaultApplication failed
6313  */
6314 HWTEST_F(ActsBmsKitSystemTest, GetDefaultAppProxy_0400, Function | SmallTest | Level1)
6315 {
6316     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
6317     ASSERT_NE(bundleMgrProxy, nullptr);
6318     sptr<IDefaultApp> getDefaultAppProxy = bundleMgrProxy->GetDefaultAppProxy();
6319     BundleInfo bundleInfo;
6320     ErrCode result = getDefaultAppProxy->GetDefaultApplication(USERID, "", bundleInfo);
6321     EXPECT_NE(result, ERR_OK);
6322 }
6323 
6324 /**
6325  * @tc.number: GetDefaultAppProxy_0500
6326  * @tc.name: test GetDefaultAppProxy proxy
6327  * @tc.desc: 1.system run normally
6328  *           2.test ResetDefaultApplication failed
6329  */
6330 HWTEST_F(ActsBmsKitSystemTest, GetDefaultAppProxy_0500, Function | SmallTest | Level1)
6331 {
6332     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
6333     ASSERT_NE(bundleMgrProxy, nullptr);
6334     sptr<IDefaultApp> getDefaultAppProxy = bundleMgrProxy->GetDefaultAppProxy();
6335     ErrCode result = getDefaultAppProxy->ResetDefaultApplication(USERID, "");
6336     EXPECT_NE(result, ERR_OK);
6337 }
6338 /**
6339  * @tc.number: CheckAbilityEnabled_0100
6340  * @tc.name: test SetAbilityEnabled and IsAbilityEnabled proxy
6341  * @tc.desc: 1.system run normally
6342  *           2.set ability enabled
6343  *           3.get ability enabled
6344  */
6345 HWTEST_F(ActsBmsKitSystemTest, CheckAbilityEnabled_0100, Function | SmallTest | Level1)
6346 {
6347     std::cout << "START GetUdidByNetworkId_0100" << std::endl;
6348     std::vector<std::string> resvec;
6349     std::string bundleFilePath = THIRD_BUNDLE_PATH + "bmsThirdBundle1.hap";
6350     std::string appName = BASE_BUNDLE_NAME + "1";
6351     Install(bundleFilePath, InstallFlag::REPLACE_EXISTING, resvec);
6352     CommonTool commonTool;
6353     std::string installResult = commonTool.VectorToStr(resvec);
6354     EXPECT_EQ(installResult, "Success") << "install fail!";
6355 
6356     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
6357     ASSERT_NE(bundleMgrProxy, nullptr);
6358 
6359     AbilityInfo abilityInfo;
6360     abilityInfo.name = BASE_ABILITY_NAME;
6361     abilityInfo.bundleName = appName;
6362     abilityInfo.moduleName = BASE_MODULE_NAME;
6363     int32_t testRet = bundleMgrProxy->SetAbilityEnabled(abilityInfo, false, USERID);
6364     EXPECT_EQ(0, testRet);
6365     bool isEnable = false;
6366     int32_t testRet1 = bundleMgrProxy->IsAbilityEnabled(abilityInfo, isEnable);
6367     EXPECT_NE(0, testRet1);
6368 
6369     resvec.clear();
6370     Uninstall(appName, resvec);
6371     std::string uninstallResult = commonTool.VectorToStr(resvec);
6372     EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!";
6373     std::cout << "END GetUdidByNetworkId_0100" << std::endl;
6374 }
6375 
6376 /**
6377  * @tc.number: CheckAbilityEnabled_0200
6378  * @tc.name: test SetAbilityEnabled and IsAbilityEnabled proxy
6379  * @tc.desc: 1.system run normally
6380  *           2.set ability failed
6381  */
6382 HWTEST_F(ActsBmsKitSystemTest, CheckAbilityEnabled_0200, Function | SmallTest | Level1)
6383 {
6384     std::cout << "START GetUdidByNetworkId_0100" << std::endl;
6385     std::vector<std::string> resvec;
6386     std::string bundleFilePath = THIRD_BUNDLE_PATH + "bmsThirdBundle1.hap";
6387     std::string appName = BASE_BUNDLE_NAME + "1";
6388     Install(bundleFilePath, InstallFlag::REPLACE_EXISTING, resvec);
6389     CommonTool commonTool;
6390     std::string installResult = commonTool.VectorToStr(resvec);
6391     EXPECT_EQ(installResult, "Success") << "install fail!";
6392 
6393     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
6394     ASSERT_NE(bundleMgrProxy, nullptr);
6395 
6396     AbilityInfo abilityInfo;
6397     abilityInfo.name = BASE_ABILITY_NAME;
6398     abilityInfo.bundleName = "";
6399     abilityInfo.moduleName = BASE_MODULE_NAME;
6400     int32_t testRet = bundleMgrProxy->SetAbilityEnabled(abilityInfo, false, USERID);
6401     EXPECT_NE(0, testRet);
6402 
6403     resvec.clear();
6404     Uninstall(appName, resvec);
6405     std::string uninstallResult = commonTool.VectorToStr(resvec);
6406     EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!";
6407     std::cout << "END GetUdidByNetworkId_0100" << std::endl;
6408 }
6409 
6410 /**
6411  * @tc.number: CheckAbilityEnabled_0300
6412  * @tc.name: test SetAbilityEnabled and IsAbilityEnabled proxy
6413  * @tc.desc: 1.system run normally
6414  *           2.set ability failed
6415  *           3.get ability failed
6416  */
6417 HWTEST_F(ActsBmsKitSystemTest, CheckAbilityEnabled_0300, Function | SmallTest | Level1)
6418 {
6419     std::cout << "START GetUdidByNetworkId_0100" << std::endl;
6420     std::vector<std::string> resvec;
6421     std::string bundleFilePath = THIRD_BUNDLE_PATH + "bmsThirdBundle1.hap";
6422     std::string appName = BASE_BUNDLE_NAME + "1";
6423     Install(bundleFilePath, InstallFlag::REPLACE_EXISTING, resvec);
6424     CommonTool commonTool;
6425     std::string installResult = commonTool.VectorToStr(resvec);
6426     EXPECT_EQ(installResult, "Success") << "install fail!";
6427 
6428     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
6429     ASSERT_NE(bundleMgrProxy, nullptr);
6430 
6431     AbilityInfo abilityInfo;
6432     abilityInfo.name = "";
6433     abilityInfo.bundleName = appName;
6434     abilityInfo.moduleName = BASE_MODULE_NAME;
6435     int32_t testRet = bundleMgrProxy->SetAbilityEnabled(abilityInfo, false, USERID);
6436     EXPECT_NE(0, testRet);
6437     bool isEnable = false;
6438     int32_t testRet1 = bundleMgrProxy->IsAbilityEnabled(abilityInfo, isEnable);
6439     EXPECT_NE(0, testRet1);
6440 
6441     resvec.clear();
6442     Uninstall(appName, resvec);
6443     std::string uninstallResult = commonTool.VectorToStr(resvec);
6444     EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!";
6445     std::cout << "END GetUdidByNetworkId_0100" << std::endl;
6446 }
6447 
6448 /**
6449  * @tc.number: CheckAbilityEnabled_0400
6450  * @tc.name: test SetAbilityEnabled and IsAbilityEnabled proxy
6451  * @tc.desc: 1.system run normally
6452  *           2.set ability failed
6453  *           3.get ability failed
6454  */
6455 HWTEST_F(ActsBmsKitSystemTest, CheckAbilityEnabled_0400, Function | SmallTest | Level1)
6456 {
6457     std::cout << "START GetUdidByNetworkId_0100" << std::endl;
6458     std::vector<std::string> resvec;
6459     std::string bundleFilePath = THIRD_BUNDLE_PATH + "bmsThirdBundle1.hap";
6460     std::string appName = BASE_BUNDLE_NAME + "1";
6461     Install(bundleFilePath, InstallFlag::REPLACE_EXISTING, resvec);
6462     CommonTool commonTool;
6463     std::string installResult = commonTool.VectorToStr(resvec);
6464     EXPECT_EQ(installResult, "Success") << "install fail!";
6465 
6466     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
6467     ASSERT_NE(bundleMgrProxy, nullptr);
6468 
6469     AbilityInfo abilityInfo;
6470     abilityInfo.name = "";
6471     abilityInfo.bundleName = "";
6472     abilityInfo.moduleName = BASE_MODULE_NAME;
6473     int32_t testRet = bundleMgrProxy->SetAbilityEnabled(abilityInfo, false, USERID);
6474     EXPECT_NE(0, testRet);
6475     bool isEnable = false;
6476     int32_t testRet1 = bundleMgrProxy->IsAbilityEnabled(abilityInfo, isEnable);
6477     EXPECT_NE(0, testRet1);
6478 
6479     resvec.clear();
6480     Uninstall(appName, resvec);
6481     std::string uninstallResult = commonTool.VectorToStr(resvec);
6482     EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!";
6483     std::cout << "END GetUdidByNetworkId_0100" << std::endl;
6484 }
6485 
6486 /**
6487  * @tc.number: CheckCloneAbilityEnabled_0100
6488  * @tc.name: test SetCloneAbilityEnabled and IsCloneAbilityEnabled proxy
6489  * @tc.desc: 1.system run normally
6490  *           2.set ability enabled
6491  *           3.get ability enabled
6492  */
6493 HWTEST_F(ActsBmsKitSystemTest, CheckCloneAbilityEnabled_0100, Function | SmallTest | Level1)
6494 {
6495     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
6496     ASSERT_NE(bundleMgrProxy, nullptr);
6497 
6498     AbilityInfo abilityInfo;
6499     abilityInfo.name = BASE_ABILITY_NAME;
6500     abilityInfo.bundleName = ROUTER_MAP_TEST_BUNDLE_NAME;
6501     abilityInfo.moduleName = BASE_MODULE_NAME;
6502     int32_t testRet = bundleMgrProxy->SetCloneAbilityEnabled(abilityInfo, 1, false, USERID);
6503     EXPECT_NE(0, testRet);
6504     bool isEnable = false;
6505     int32_t testRet1 = bundleMgrProxy->IsCloneAbilityEnabled(abilityInfo, 1, isEnable);
6506     EXPECT_NE(0, testRet1);
6507 }
6508 
6509 /**
6510  * @tc.number: CheckCloneApplicationEnabled_0100
6511  * @tc.name: test SetCloneAbilityEnabled and IsCloneAbilityEnabled proxy
6512  * @tc.desc: 1.system run normally
6513  *           2.set ability enabled
6514  *           3.get ability enabled
6515  */
6516 HWTEST_F(ActsBmsKitSystemTest, CheckCloneApplicationEnabled_0100, Function | SmallTest | Level1)
6517 {
6518     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
6519     ASSERT_NE(bundleMgrProxy, nullptr);
6520 
6521     int32_t testRet = bundleMgrProxy->SetCloneApplicationEnabled(BASE_ABILITY_NAME, 1, false, USERID);
6522     EXPECT_NE(0, testRet);
6523     bool isEnable = false;
6524     int32_t testRet1 = bundleMgrProxy->IsCloneApplicationEnabled(BASE_ABILITY_NAME, 1, isEnable);
6525     EXPECT_NE(0, testRet1);
6526 }
6527 
6528 /**
6529  * @tc.number: GetAllBundleInfoByDeveloperId_0001
6530  * @tc.name: test query bundle information
6531  * @tc.desc: 1.get information failed
6532  */
6533 HWTEST_F(ActsBmsKitSystemTest, GetAllBundleInfoByDeveloperId_0001, Function | MediumTest | Level1)
6534 {
6535     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
6536     ASSERT_NE(bundleMgrProxy, nullptr);
6537     std::string developerId = "testDev";
6538     std::vector<BundleInfo> bundleInfos;
6539     auto res = bundleMgrProxy->GetAllBundleInfoByDeveloperId(developerId, bundleInfos, USERID);
6540     EXPECT_NE(res, ERR_OK);
6541     EXPECT_TRUE(bundleInfos.empty());
6542 }
6543 
6544 /**
6545  * @tc.number: GetDeveloperIds_0001
6546  * @tc.name: test query bundle information
6547  * @tc.desc: 1.get information failed
6548  */
6549 HWTEST_F(ActsBmsKitSystemTest, GetDeveloperIds_0001, Function | MediumTest | Level1)
6550 {
6551     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
6552     ASSERT_NE(bundleMgrProxy, nullptr);
6553     std::string appDistributionType = "invalidType";
6554     std::vector<std::string> developerIdList;
6555     auto res = bundleMgrProxy->GetDeveloperIds(appDistributionType, developerIdList, USERID);
6556     EXPECT_EQ(res, ERR_OK);
6557     EXPECT_TRUE(developerIdList.empty());
6558 }
6559 
6560 /**
6561  * @tc.number: GetExtendResourceManager_0100
6562  * @tc.name: test GetExtendResourceManager proxy
6563  * @tc.desc: GetExtendResourceManager success
6564  */
6565 HWTEST_F(ActsBmsKitSystemTest, GetExtendResourceManager_0100, Function | MediumTest | Level1)
6566 {
6567     auto bundleMgrProxy = GetBundleMgrProxy();
6568     sptr<IExtendResourceManager> extendResourceManagerProxy = bundleMgrProxy->GetExtendResourceManager();
6569     EXPECT_NE(extendResourceManagerProxy, nullptr);
6570 }
6571 
6572 /**
6573  * @tc.number: QueryCloneAbilityInfo_0100
6574  * @tc.name: test QueryCloneAbilityInfo proxy
6575  * @tc.desc: QueryCloneAbilityInfo param error
6576  */
6577 HWTEST_F(ActsBmsKitSystemTest, QueryCloneAbilityInfo_0100, Function | MediumTest | Level1)
6578 {
6579     auto bundleMgrProxy = GetBundleMgrProxy();
6580     const ElementName element;
6581     int32_t flags = 0;
6582     int32_t appIndex  = 0;
6583     AbilityInfo abilityInfo;
6584     int32_t userId = Constants::START_USERID;
6585     ErrCode res = bundleMgrProxy->QueryCloneAbilityInfo(element, flags, appIndex, abilityInfo, userId);
6586     EXPECT_EQ(res, ERR_APPEXECFWK_CLONE_QUERY_PARAM_ERROR);
6587 }
6588 
6589 /**
6590  * @tc.number: UninstallAndRecover_0100
6591  * @tc.name: test UninstallAndRecover proxy
6592  * @tc.desc: UninstallAndRecover return false
6593  */
6594 HWTEST_F(ActsBmsKitSystemTest, UninstallAndRecover_0100, Function | MediumTest | Level1)
6595 {
6596     sptr<IBundleInstaller> installerProxy = GetInstallerProxy();
6597     InstallParam installParam;
6598     installParam.installFlag = InstallFlag::NORMAL;
6599     installParam.userId = TEST_INSTALLER_UID;
6600     std::string bundleName = BASE_BUNDLE_NAME;
6601     sptr<IStatusReceiver> statusReceiver = nullptr;
6602     bool res = installerProxy->UninstallAndRecover(bundleName, installParam, statusReceiver);
6603     EXPECT_EQ(res, false);
6604 }
6605 
6606 /**
6607  * @tc.number: UninstallAndRecover_0200
6608  * @tc.name: test UninstallAndRecover proxy
6609  * @tc.desc: UninstallAndRecover return false
6610  */
6611 HWTEST_F(ActsBmsKitSystemTest, UninstallAndRecover_0200, Function | MediumTest | Level1)
6612 {
6613     sptr<IBundleInstaller> installerProxy = GetInstallerProxy();
6614     InstallParam installParam;
6615     installParam.installFlag = InstallFlag::NORMAL;
6616     installParam.userId = TEST_INSTALLER_UID;
6617     std::string bundleName = BASE_BUNDLE_NAME;
6618     sptr<IStatusReceiver> statusReceiver;
6619     bool res = installerProxy->UninstallAndRecover(bundleName, installParam, statusReceiver);
6620     EXPECT_EQ(res, false);
6621 }
6622 
6623 /**
6624  * @tc.number: InstallCloneApp_0100
6625  * @tc.name: test InstallCloneApp proxy
6626  * @tc.desc: InstallCloneApp param error
6627  */
6628 HWTEST_F(ActsBmsKitSystemTest, InstallCloneApp_0100, Function | MediumTest | Level1)
6629 {
6630     sptr<IBundleInstaller> installerProxy = GetInstallerProxy();
6631     ASSERT_NE(installerProxy, nullptr);
6632     std::string bundleName = "";
6633     int32_t appIndex = TEST_APP_INDEX1;
6634     ErrCode ret = installerProxy->InstallCloneApp(bundleName, TEST_INSTALLER_UID, appIndex);
6635     EXPECT_EQ(ret, ERR_APPEXECFWK_CLONE_INSTALL_PARAM_ERROR);
6636 }
6637 
6638 /**
6639  * @tc.number: BatchGetBundleInfo_0100
6640  * @tc.name: test BatchGetBundleInfo proxy
6641  * @tc.desc: BatchGetBundleInfo bundlenames
6642  */
6643 HWTEST_F(ActsBmsKitSystemTest, BatchGetBundleInfo_0100, Function | MediumTest | Level1)
6644 {
6645     std::vector<std::string> resvec;
6646     std::string bundleFilePath = THIRD_BUNDLE_PATH + "bmsThirdBundle1.hap";
6647     std::string appName = BASE_BUNDLE_NAME + "1";
6648     Install(bundleFilePath, InstallFlag::REPLACE_EXISTING, resvec);
6649     CommonTool commonTool;
6650     std::string installResult = commonTool.VectorToStr(resvec);
6651     EXPECT_EQ(installResult, "Success") << "install fail!";
6652 
6653     std::vector<std::string> bundleNames;
6654     bundleNames.push_back(appName);
6655     std::vector<BundleInfo> bundleInfos;
6656     int32_t flag = static_cast<int32_t>(BundleFlag::GET_BUNDLE_DEFAULT);
6657     auto bundleMgrProxy = GetBundleMgrProxy();
6658     ErrCode res = bundleMgrProxy->BatchGetBundleInfo(bundleNames, flag, bundleInfos, USERID);
6659     EXPECT_EQ(res, ERR_OK);
6660 
6661     resvec.clear();
6662     Uninstall(appName, resvec);
6663     std::string uninstallResult = commonTool.VectorToStr(resvec);
6664     EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!";
6665 }
6666 
6667 /**
6668  * @tc.number: BatchGetBundleInfo_0200
6669  * @tc.name: test BatchGetBundleInfo proxy
6670  * @tc.desc: BatchGetBundleInfo wants
6671  */
6672 HWTEST_F(ActsBmsKitSystemTest, BatchGetBundleInfo_0200, Function | MediumTest | Level1)
6673 {
6674     std::vector<std::string> resvec;
6675     std::string bundleFilePath = THIRD_BUNDLE_PATH + "bmsThirdBundle1.hap";
6676     std::string appName = BASE_BUNDLE_NAME + "1";
6677     Install(bundleFilePath, InstallFlag::REPLACE_EXISTING, resvec);
6678     CommonTool commonTool;
6679     std::string installResult = commonTool.VectorToStr(resvec);
6680     EXPECT_EQ(installResult, "Success") << "install fail!";
6681 
6682     Want want;
6683     ElementName name;
6684     name.SetBundleName(appName);
6685     want.SetElement(name);
6686     std::vector<Want> wants;
6687     wants.push_back(want);
6688     std::vector<BundleInfo> bundleInfos;
6689     int32_t flag = static_cast<int32_t>(BundleFlag::GET_BUNDLE_DEFAULT);
6690     auto bundleMgrProxy = GetBundleMgrProxy();
6691     ErrCode res = bundleMgrProxy->BatchGetBundleInfo(wants, flag, bundleInfos, USERID);
6692     EXPECT_EQ(res, ERR_OK);
6693 
6694     resvec.clear();
6695     Uninstall(appName, resvec);
6696     std::string uninstallResult = commonTool.VectorToStr(resvec);
6697     EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!";
6698 }
6699 
6700 /**
6701  * @tc.number: BatchQueryAbilityInfos_0100
6702  * @tc.name: test BatchQueryAbilityInfos proxy
6703  * @tc.desc: BatchGetBundleInfo wants
6704  */
6705 HWTEST_F(ActsBmsKitSystemTest, BatchQueryAbilityInfos_0100, Function | MediumTest | Level1)
6706 {
6707     std::vector<std::string> resvec;
6708     std::string bundleFilePath = THIRD_BUNDLE_PATH + "bmsThirdBundle1.hap";
6709     std::string appName = BASE_BUNDLE_NAME + "1";
6710     std::string abilityName = BASE_ABILITY_NAME;
6711     Install(bundleFilePath, InstallFlag::REPLACE_EXISTING, resvec);
6712     CommonTool commonTool;
6713     std::string installResult = commonTool.VectorToStr(resvec);
6714     EXPECT_EQ(installResult, "Success") << "install fail!";
6715 
6716     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
6717     ASSERT_NE(bundleMgrProxy, nullptr);
6718 
6719     Want want;
6720     ElementName name;
6721     name.SetAbilityName(abilityName);
6722     name.SetBundleName(appName);
6723     want.SetElement(name);
6724     std::vector<Want> wants;
6725     wants.push_back(want);
6726     std::vector<AbilityInfo> AbilityInfo;
6727     auto ret = bundleMgrProxy->BatchQueryAbilityInfos(wants, static_cast<int32_t>(
6728         GetAbilityInfoFlag::GET_ABILITY_INFO_DEFAULT), USERID, AbilityInfo);
6729     EXPECT_EQ(ret, ERR_OK);
6730 
6731     resvec.clear();
6732     Uninstall(appName, resvec);
6733     std::string uninstallResult = commonTool.VectorToStr(resvec);
6734     EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!";
6735 }
6736 
6737 /**
6738  * @tc.number: GetAllBundleStats_0100
6739  * @tc.name: test GetAllBundleStats proxy
6740  * @tc.desc: get bundle stats
6741  */
6742 HWTEST_F(ActsBmsKitSystemTest, GetAllBundleStats_0100, Function | MediumTest | Level1)
6743 {
6744     auto bundleMgrProxy = GetBundleMgrProxy();
6745     std::vector<int64_t> bundleStats;
6746     ErrCode res = bundleMgrProxy->GetAllBundleStats(USERID, bundleStats);
6747     EXPECT_TRUE(res);
6748 }
6749 
6750 /**
6751  * @tc.number: GetBundleUserMgr_0100
6752  * @tc.name: test GetBundleUserMgr proxy
6753  * @tc.desc: 1.system run normally
6754  *           2.GetBundleUserMgr is not nullptr
6755  */
6756 HWTEST_F(ActsBmsKitSystemTest, GetBundleUserMgr_0100, Function | SmallTest | Level1)
6757 {
6758     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
6759     ASSERT_NE(bundleMgrProxy, nullptr);
6760     sptr<IBundleUserMgr> getBundleUserMgr = bundleMgrProxy->GetBundleUserMgr();
6761     if (!getBundleUserMgr) {
6762         APP_LOGE("getBundleUserMgr is nullptr.");
6763         EXPECT_EQ(getBundleUserMgr, nullptr);
6764     }
6765 }
6766 
6767 /**
6768  * @tc.number: QueryExtensionAbilityInfosV9_0100
6769  * @tc.name: test QueryExtensionAbilityInfosV9 proxy
6770  * @tc.desc: 1.system run normally
6771  *           2.extension not found
6772  */
6773 HWTEST_F(ActsBmsKitSystemTest, QueryExtensionAbilityInfosV9_0100, Function | SmallTest | Level1)
6774 {
6775     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
6776     ASSERT_NE(bundleMgrProxy, nullptr);
6777     Want want;
6778     int32_t flags = 0;
6779     int32_t userId = 100;
6780     std::vector<ExtensionAbilityInfo> extensions;
6781     ErrCode ret = bundleMgrProxy->QueryExtensionAbilityInfosV9(want, flags, userId, extensions);
6782     EXPECT_NE(ret, ERR_OK);
6783 }
6784 
6785 /**
6786  * @tc.number: QueryExtensionAbilityInfosV9_0200
6787  * @tc.name: test QueryExtensionAbilityInfosV9 proxy
6788  * @tc.desc: 1.system run normally
6789  *           2.extension not found
6790  */
6791 HWTEST_F(ActsBmsKitSystemTest, QueryExtensionAbilityInfosV9_0200, Function | SmallTest | Level1)
6792 {
6793     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
6794     ASSERT_NE(bundleMgrProxy, nullptr);
6795     Want want;
6796     int32_t flags = 0;
6797     int32_t userId = 100;
6798     std::vector<ExtensionAbilityInfo> extensions;
6799     ErrCode ret = bundleMgrProxy->QueryExtensionAbilityInfosV9(want, flags, userId, extensions);
6800     EXPECT_NE(ret, ERR_OK);
6801 }
6802 
6803 /**
6804  * @tc.number: QueryExtensionAbilityInfosV9_0300
6805  * @tc.name: test QueryExtensionAbilityInfosV9 proxy
6806  * @tc.desc: 1.system run normally
6807  *           2.return ERR_OK
6808  */
6809 HWTEST_F(ActsBmsKitSystemTest, QueryExtensionAbilityInfosV9_0300, Function | SmallTest | Level1)
6810 {
6811     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
6812     ASSERT_NE(bundleMgrProxy, nullptr);
6813     Want want;
6814     want.SetAction("action.system.home");
6815     int32_t flags = 0;
6816     int32_t userId = 100;
6817     std::vector<ExtensionAbilityInfo> extensionInfos;
6818     ErrCode ret = bundleMgrProxy->QueryExtensionAbilityInfosV9(want, flags, userId, extensionInfos);
6819     EXPECT_EQ(ret, ERR_OK);
6820 }
6821 
6822 /**
6823  * @tc.number: QueryExtensionAbilityInfosV9_0400
6824  * @tc.name: test QueryExtensionAbilityInfosV9 proxy
6825  * @tc.desc: 1.system run normally
6826  *           2.return ERR_OK
6827  */
6828 HWTEST_F(ActsBmsKitSystemTest, QueryExtensionAbilityInfosV9_0400, Function | SmallTest | Level1)
6829 {
6830     auto name = std::string("QueryExtensionAbilityInfos_0001");
6831     GTEST_LOG_(INFO) << name << " start";
6832     std::string bundleFilePath = "/data/test/bms_bundle/bundleClient1.hap";
6833     std::vector<std::string> resvec;
6834     Install(bundleFilePath, InstallFlag::REPLACE_EXISTING, resvec);
6835     CommonTool commonTool;
6836     std::string installResult = commonTool.VectorToStr(resvec);
6837     EXPECT_EQ(installResult, "Success") << "install fail!";
6838 
6839     std::vector<ExtensionAbilityInfo> infos;
6840     OHOS::AAFwk::Want want;
6841     ElementName element;
6842     element.SetBundleName("com.example.ohosproject.hmservice");
6843     element.SetModuleName("entry_phone");
6844     element.SetAbilityName("Form");
6845     want.SetElement(element);
6846     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
6847     ASSERT_NE(bundleMgrProxy, nullptr);
6848     ErrCode ret = bundleMgrProxy->QueryExtensionAbilityInfosV9(want, ExtensionAbilityType::FORM,
6849         ExtensionAbilityInfoFlag::GET_EXTENSION_INFO_DEFAULT, USERID, infos);
6850     EXPECT_EQ(ret, ERR_OK);
6851     EXPECT_EQ(1, infos.size());
6852 
6853     resvec.clear();
6854     Uninstall("com.example.ohosproject.hmservice", resvec);
6855     std::string uninstallResult = commonTool.VectorToStr(resvec);
6856     EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!";
6857     std::cout << "END GetUdidByNetworkId_0100" << std::endl;
6858 }
6859 
6860 /**
6861  * @tc.number: UpgradeAtomicService_0100
6862  * @tc.name: test UpgradeAtomicService proxy
6863  * @tc.desc: 1.system run normally
6864  */
6865 HWTEST_F(ActsBmsKitSystemTest, UpgradeAtomicService_0100, Function | SmallTest | Level1)
6866 {
6867     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
6868     ASSERT_NE(bundleMgrProxy, nullptr);
6869     Want want;
6870     int32_t userId = 100;
6871     bundleMgrProxy->UpgradeAtomicService(want, userId);
6872 }
6873 
6874 /**
6875  * @tc.number: QueryAbilityInfosByUri_0100
6876  * @tc.name: test QueryAbilityInfosByUri proxy
6877  * @tc.desc: 1.system run normally
6878  *           2.ability not found
6879  */
6880 HWTEST_F(ActsBmsKitSystemTest, QueryAbilityInfosByUri_0100, Function | SmallTest | Level1)
6881 {
6882     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
6883     ASSERT_NE(bundleMgrProxy, nullptr);
6884     std::string uri = "invalid";
6885     std::vector<AbilityInfo> abilityInfos;
6886     bool ret = bundleMgrProxy->QueryAbilityInfosByUri(uri, abilityInfos);
6887     EXPECT_FALSE(ret);
6888 }
6889 
6890 /**
6891  * @tc.number: GetAbilityLabel_0200
6892  * @tc.name: test GetAbilityLabel proxy
6893  * @tc.desc: 1.system run normally
6894  *           2.ability label not found
6895  */
6896 HWTEST_F(ActsBmsKitSystemTest, GetAbilityLabel_0200, Function | SmallTest | Level1)
6897 {
6898     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
6899     ASSERT_NE(bundleMgrProxy, nullptr);
6900     std::string bundleName = "invalid";
6901     std::string abilityName = "invalid";
6902     std::string ret = bundleMgrProxy->GetAbilityLabel(bundleName, abilityName);
6903     EXPECT_EQ(ret, "");
6904 }
6905 
6906 /**
6907  * @tc.number: IsApplicationEnabled_0100
6908  * @tc.name: test IsApplicationEnabled proxy
6909  * @tc.desc: 1.system run normally
6910  *           2.return false
6911  */
6912 HWTEST_F(ActsBmsKitSystemTest, IsApplicationEnabled_0100, Function | SmallTest | Level1)
6913 {
6914     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
6915     ASSERT_NE(bundleMgrProxy, nullptr);
6916     std::string bundleName = "invalid";
6917     bool isEnable = false;
6918     ErrCode ret = bundleMgrProxy->IsApplicationEnabled(bundleName, isEnable);
6919     EXPECT_NE(ret, ERR_OK);
6920 }
6921 
6922 /**
6923  * @tc.number: IsModuleRemovable_0100
6924  * @tc.name: test IsModuleRemovable proxy
6925  * @tc.desc: 1.system run normally
6926  *           2.return false
6927  */
6928 HWTEST_F(ActsBmsKitSystemTest, IsModuleRemovable_0100, Function | SmallTest | Level1)
6929 {
6930     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
6931     ASSERT_NE(bundleMgrProxy, nullptr);
6932     std::string bundleName = "invalid";
6933     std::string moduleName = "invalid";
6934     bool isRemovable = false;
6935     ErrCode ret = bundleMgrProxy->IsModuleRemovable(bundleName, moduleName, isRemovable);
6936     EXPECT_NE(ret, ERR_OK);
6937 }
6938 
6939 /**
6940  * @tc.number: IsModuleRemovable_0100
6941  * @tc.name: test IsModuleRemovable proxy
6942  * @tc.desc: 1.system run normally
6943  *           2.return false
6944  */
6945 HWTEST_F(ActsBmsKitSystemTest, IsModuleRemovable_0200, Function | SmallTest | Level1)
6946 {
6947     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
6948     ASSERT_NE(bundleMgrProxy, nullptr);
6949     std::string moduleName = "invalid";
6950     bool isRemovable = false;
6951     ErrCode ret = bundleMgrProxy->IsModuleRemovable("", moduleName, isRemovable);
6952     EXPECT_EQ(ret, ERR_BUNDLE_MANAGER_BUNDLE_NOT_EXIST);
6953 }
6954 
6955 /**
6956  * @tc.number: IsModuleRemovable_0100
6957  * @tc.name: test IsModuleRemovable proxy
6958  * @tc.desc: 1.system run normally
6959  *           2.return false
6960  */
6961 HWTEST_F(ActsBmsKitSystemTest, IsModuleRemovable_0300, Function | SmallTest | Level1)
6962 {
6963     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
6964     ASSERT_NE(bundleMgrProxy, nullptr);
6965     std::string bundleName = "invalid";
6966     bool isRemovable = false;
6967     ErrCode ret = bundleMgrProxy->IsModuleRemovable(bundleName, "", isRemovable);
6968     EXPECT_EQ(ret, ERR_BUNDLE_MANAGER_MODULE_NOT_EXIST);
6969 }
6970 
6971 /**
6972  * @tc.number: SetModuleRemovable_0100
6973  * @tc.name: test SetModuleRemovable proxy
6974  * @tc.desc: 1.system run normally
6975  *           2.return false
6976  */
6977 HWTEST_F(ActsBmsKitSystemTest, SetModuleRemovable_0100, Function | SmallTest | Level1)
6978 {
6979     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
6980     ASSERT_NE(bundleMgrProxy, nullptr);
6981     std::string bundleName = "invalid";
6982     std::string moduleName = "invalid";
6983     bool ret = bundleMgrProxy->SetModuleRemovable(bundleName, moduleName, true);
6984     EXPECT_FALSE(ret);
6985 }
6986 
6987 /**
6988  * @tc.number: SetModuleRemovable_0200
6989  * @tc.name: test SetModuleRemovable proxy
6990  * @tc.desc: 1.system run normally
6991  *           2.return false
6992  */
6993 HWTEST_F(ActsBmsKitSystemTest, SetModuleRemovable_0200, Function | SmallTest | Level1)
6994 {
6995     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
6996     ASSERT_NE(bundleMgrProxy, nullptr);
6997     std::string moduleName = "invalid";
6998     bool ret = bundleMgrProxy->SetModuleRemovable("", moduleName, true);
6999     EXPECT_FALSE(ret);
7000 }
7001 
7002 /**
7003  * @tc.number: SetModuleRemovable_0300
7004  * @tc.name: test SetModuleRemovable proxy
7005  * @tc.desc: 1.system run normally
7006  *           2.return false
7007  */
7008 HWTEST_F(ActsBmsKitSystemTest, SetModuleRemovable_0300, Function | SmallTest | Level1)
7009 {
7010     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
7011     ASSERT_NE(bundleMgrProxy, nullptr);
7012     std::string bundleName = "invalid";
7013     bool ret = bundleMgrProxy->SetModuleRemovable(bundleName, "", true);
7014     EXPECT_FALSE(ret);
7015 }
7016 
7017 /**
7018  * @tc.number: SetApplicationEnabled_0100
7019  * @tc.name: test SetApplicationEnabled proxy
7020  * @tc.desc: 1.system run normally
7021  *           2.return false
7022  */
7023 HWTEST_F(ActsBmsKitSystemTest, SetApplicationEnabled_0100, Function | SmallTest | Level1)
7024 {
7025     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
7026     ASSERT_NE(bundleMgrProxy, nullptr);
7027     std::string bundleName = "invalid";
7028     int32_t userId = 100;
7029     ErrCode ret = bundleMgrProxy->SetApplicationEnabled(bundleName, true, userId);
7030     EXPECT_NE(ret, ERR_OK);
7031 }
7032 
7033 /**
7034  * @tc.number: GetAbilityInfo_0200
7035  * @tc.name: test GetAbilityInfo proxy
7036  * @tc.desc: 1.system run normally
7037  *           2.return false
7038  */
7039 HWTEST_F(ActsBmsKitSystemTest, GetAbilityInfo_0200, Function | SmallTest | Level1)
7040 {
7041     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
7042     ASSERT_NE(bundleMgrProxy, nullptr);
7043     std::string bundleName = "";
7044     std::string abilityName = "invalid";
7045     AbilityInfo abilityInfo;
7046     bool ret = bundleMgrProxy->GetAbilityInfo(bundleName, abilityName, abilityInfo);
7047     EXPECT_FALSE(ret);
7048 }
7049 
7050 /**
7051  * @tc.number: GetAbilityInfo_0300
7052  * @tc.name: test GetAbilityInfo proxy
7053  * @tc.desc: 1.system run normally
7054  *           2.return false
7055  */
7056 HWTEST_F(ActsBmsKitSystemTest, GetAbilityInfo_0300, Function | SmallTest | Level1)
7057 {
7058     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
7059     ASSERT_NE(bundleMgrProxy, nullptr);
7060     std::string bundleName = "";
7061     std::string moduleName = "invalid";
7062     std::string abilityName = "invalid";
7063     AbilityInfo abilityInfo;
7064     bool ret = bundleMgrProxy->GetAbilityInfo(bundleName, moduleName, abilityName, abilityInfo);
7065     EXPECT_FALSE(ret);
7066 }
7067 
7068 /**
7069  * @tc.number: GetAbilityInfo_0400
7070  * @tc.name: test GetAbilityInfo proxy
7071  * @tc.desc: 1.system run normally
7072  *           2.return false
7073  */
7074 HWTEST_F(ActsBmsKitSystemTest, GetAbilityInfo_0400, Function | SmallTest | Level1)
7075 {
7076     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
7077     ASSERT_NE(bundleMgrProxy, nullptr);
7078     std::vector<std::string> resvec;
7079     CommonTool commonTool;
7080     std::string bundleFilePath = THIRD_BUNDLE_PATH + "bmsThirdBundle24.hap";
7081     Install(bundleFilePath, InstallFlag::REPLACE_EXISTING, resvec);
7082     std::string installResult = commonTool.VectorToStr(resvec);
7083     EXPECT_EQ(installResult, "Success") << "install fail!";
7084     std::string bundleName = BASE_BUNDLE_NAME + "1";
7085     std::string abilityName = BASE_ABILITY_NAME;
7086     AbilityInfo abilityInfo;
7087     bool ret = bundleMgrProxy->GetAbilityInfo(bundleName, abilityName, abilityInfo);
7088     EXPECT_FALSE(ret);
7089     resvec.clear();
7090     Uninstall(bundleName, resvec);
7091     std::string uninstallResult = commonTool.VectorToStr(resvec);
7092     EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!";
7093 }
7094 
7095 /**
7096  * @tc.number: GetAbilityInfo_0500
7097  * @tc.name: test GetAbilityInfo proxy
7098  * @tc.desc: 1.system run normally
7099  *           2.return false
7100  */
7101 HWTEST_F(ActsBmsKitSystemTest, GetAbilityInfo_0500, Function | SmallTest | Level1)
7102 {
7103     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
7104     ASSERT_NE(bundleMgrProxy, nullptr);
7105     std::vector<std::string> resvec;
7106     CommonTool commonTool;
7107     std::string bundleFilePath = THIRD_BUNDLE_PATH + "bmsThirdBundle24.hap";
7108     Install(bundleFilePath, InstallFlag::REPLACE_EXISTING, resvec);
7109     std::string installResult = commonTool.VectorToStr(resvec);
7110     EXPECT_EQ(installResult, "Success") << "install fail!";
7111     std::string bundleName = BASE_BUNDLE_NAME + "1";
7112     std::string moduleName = BASE_MODULE_NAME;
7113     std::string abilityName = BASE_ABILITY_NAME;
7114     AbilityInfo abilityInfo;
7115     bool ret = bundleMgrProxy->GetAbilityInfo(bundleName, moduleName, abilityName, abilityInfo);
7116     EXPECT_FALSE(ret);
7117     resvec.clear();
7118     Uninstall(bundleName, resvec);
7119     std::string uninstallResult = commonTool.VectorToStr(resvec);
7120     EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!";
7121 }
7122 
7123 /**
7124  * @tc.number: GetFormsInfoByApp_0100
7125  * @tc.name: test GetFormsInfoByApp proxy
7126  * @tc.desc: 1.system run normally
7127  *           2.return false
7128  */
7129 HWTEST_F(ActsBmsKitSystemTest, GetFormsInfoByApp_0100, Function | SmallTest | Level1)
7130 {
7131     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
7132     ASSERT_NE(bundleMgrProxy, nullptr);
7133     std::string bundleName = BASE_BUNDLE_NAME;
7134     std::vector<FormInfo> formInfos;
7135     bool ret = bundleMgrProxy->GetFormsInfoByApp(bundleName, formInfos);
7136     EXPECT_FALSE(ret);
7137 }
7138 
7139 /**
7140  * @tc.number: GetFormsInfoByApp_0200
7141  * @tc.name: test GetFormsInfoByApp proxy
7142  * @tc.desc: 1.system run normally
7143  *           2.return false
7144  */
7145 HWTEST_F(ActsBmsKitSystemTest, GetFormsInfoByApp_0200, Function | SmallTest | Level1)
7146 {
7147     std::vector<std::string> resvec;
7148     std::string bundleFilePath = THIRD_BUNDLE_PATH + "bmsThirdBundle1.hap";
7149     std::string appName = BASE_BUNDLE_NAME + "1";
7150     Install(bundleFilePath, InstallFlag::REPLACE_EXISTING, resvec);
7151     CommonTool commonTool;
7152     std::string installResult = commonTool.VectorToStr(resvec);
7153     EXPECT_EQ(installResult, "Success") << "install fail!";
7154     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
7155     ASSERT_NE(bundleMgrProxy, nullptr);
7156 
7157     std::vector<FormInfo> formInfos;
7158     bool ret = bundleMgrProxy->GetFormsInfoByApp(appName, formInfos);
7159     EXPECT_TRUE(ret);
7160 
7161     resvec.clear();
7162     Uninstall(appName, resvec);
7163     std::string uninstallResult = commonTool.VectorToStr(resvec);
7164     EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!";
7165 }
7166 
7167 /**
7168  * @tc.number: GetDistributedBundleInfo_0100
7169  * @tc.name: test GetDistributedBundleInfo proxy
7170  * @tc.desc: 1.system run normally
7171  *           2.return false
7172  */
7173 HWTEST_F(ActsBmsKitSystemTest, GetDistributedBundleInfo_0100, Function | SmallTest | Level1)
7174 {
7175     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
7176     ASSERT_NE(bundleMgrProxy, nullptr);
7177     std::string networkId1 = "";
7178     std::string bundleName1 = "";
7179     std::string networkId2 = "100";
7180     std::string bundleName2 = BASE_BUNDLE_NAME;
7181     DistributedBundleInfo distributedBundleInfo;
7182     bool ret = bundleMgrProxy->GetDistributedBundleInfo(networkId1, bundleName1, distributedBundleInfo);
7183     EXPECT_FALSE(ret);
7184     ret = bundleMgrProxy->GetDistributedBundleInfo(networkId2, bundleName1, distributedBundleInfo);
7185     EXPECT_FALSE(ret);
7186     ret = bundleMgrProxy->GetDistributedBundleInfo(networkId1, bundleName2, distributedBundleInfo);
7187     EXPECT_FALSE(ret);
7188     ret = bundleMgrProxy->GetDistributedBundleInfo(networkId2, bundleName2, distributedBundleInfo);
7189     EXPECT_FALSE(ret);
7190 }
7191 
7192 /**
7193  * @tc.number: GetSandboxBundleInfo_0100
7194  * @tc.name: test GetSandboxBundleInfo proxy
7195  * @tc.desc: 1.system run normally
7196  *           2.return false
7197  */
7198 HWTEST_F(ActsBmsKitSystemTest, GetSandboxBundleInfo_0100, Function | SmallTest | Level1)
7199 {
7200     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
7201     ASSERT_NE(bundleMgrProxy, nullptr);
7202     std::string bundleName1 = "";
7203     std::string bundleName2 = BASE_BUNDLE_NAME;
7204     int32_t appIndex1 = 0;
7205     int32_t appIndex2 = 100;
7206     BundleInfo info;
7207     auto ret = bundleMgrProxy->GetSandboxBundleInfo(bundleName1, appIndex1, USERID, info);
7208     EXPECT_NE(ret, ERR_OK);
7209     ret = bundleMgrProxy->GetSandboxBundleInfo(bundleName2, appIndex1, USERID, info);
7210     EXPECT_NE(ret, ERR_OK);
7211     ret = bundleMgrProxy->GetSandboxBundleInfo(bundleName1, appIndex2, USERID, info);
7212     EXPECT_NE(ret, ERR_OK);
7213 }
7214 
7215 /**
7216  * @tc.number: GetFormsInfoByModule_0100
7217  * @tc.name: test GetFormsInfoByModule proxy
7218  * @tc.desc: 1.system run normally
7219  *           2.return false
7220  */
7221 HWTEST_F(ActsBmsKitSystemTest, GetFormsInfoByModule_0100, Function | SmallTest | Level1)
7222 {
7223     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
7224     ASSERT_NE(bundleMgrProxy, nullptr);
7225     std::string bundleName = "invalid";
7226     std::string moduleName = "invalid";
7227     std::vector<FormInfo> formInfos;
7228     bool ret = bundleMgrProxy->GetFormsInfoByModule(bundleName, moduleName, formInfos);
7229     EXPECT_FALSE(ret);
7230 }
7231 
7232 /**
7233  * @tc.number: ImplicitQueryInfoByPriority_0200
7234  * @tc.name: test ImplicitQueryInfoByPriority proxy
7235  * @tc.desc: 1.system run normally
7236  *           2.return true
7237  */
7238 HWTEST_F(ActsBmsKitSystemTest, ImplicitQueryInfoByPriority_0200, Function | SmallTest | Level1)
7239 {
7240     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
7241     ASSERT_NE(bundleMgrProxy, nullptr);
7242     Want want;
7243     want.SetAction("action.system.home");
7244     want.AddEntity("entity.system.home");
7245     int32_t flags = 0;
7246     int32_t userId = 100;
7247     AbilityInfo abilityInfo;
7248     ExtensionAbilityInfo extensionInfo;
7249     bool ret = bundleMgrProxy->ImplicitQueryInfoByPriority(want, flags, userId, abilityInfo, extensionInfo);
7250     EXPECT_TRUE(ret);
7251     ret = !abilityInfo.name.empty() || !extensionInfo.name.empty();
7252     EXPECT_TRUE(ret);
7253 }
7254 
7255 /**
7256  * @tc.number: ImplicitQueryInfos_0200
7257  * @tc.name: test ImplicitQueryInfos proxy
7258  * @tc.desc: 1.system run normally
7259  *           2.return true
7260  */
7261 HWTEST_F(ActsBmsKitSystemTest, ImplicitQueryInfos_0200, Function | SmallTest | Level1)
7262 {
7263     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
7264     ASSERT_NE(bundleMgrProxy, nullptr);
7265     Want want;
7266     want.SetAction("action.system.home");
7267     want.AddEntity("entity.system.home");
7268     int32_t flags = 0;
7269     int32_t userId = 100;
7270     std::vector<AbilityInfo> abilityInfos;
7271     std::vector<ExtensionAbilityInfo> extensionInfos;
7272     bool findDefaultApp = false;
7273     bool ret = bundleMgrProxy->ImplicitQueryInfos(want, flags, userId, true, abilityInfos, extensionInfos,
7274         findDefaultApp);
7275     EXPECT_TRUE(ret);
7276     EXPECT_EQ(findDefaultApp, false);
7277 
7278     ret = !abilityInfos.empty() || !extensionInfos.empty();
7279     EXPECT_TRUE(ret);
7280 }
7281 
7282 /**
7283  * @tc.number: GetAppControlProxy_0100
7284  * @tc.name: test GetAppControlProxy proxy
7285  * @tc.desc: 1.system run normally
7286  *           2.proxy not null
7287  */
7288 HWTEST_F(ActsBmsKitSystemTest, GetAppControlProxy_0100, Function | SmallTest | Level1)
7289 {
7290     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
7291     ASSERT_NE(bundleMgrProxy, nullptr);
7292     sptr<IAppControlMgr> appControlMgr = bundleMgrProxy->GetAppControlProxy();
7293     EXPECT_NE(appControlMgr, nullptr);
7294 }
7295 
7296 /**
7297  * @tc.number: GetSandboxAbilityInfo_0100
7298  * @tc.name: test GetSandboxAbilityInfo proxy
7299  * @tc.desc: 1.system run normally
7300  *           2.return not ERR_OK
7301  */
7302 HWTEST_F(ActsBmsKitSystemTest, GetSandboxAbilityInfo_0100, Function | SmallTest | Level1)
7303 {
7304     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
7305     ASSERT_NE(bundleMgrProxy, nullptr);
7306     Want want;
7307     int32_t appIndex = TEST_APP_INDEX1;
7308     int32_t flags = 0;
7309     int32_t userId = 100;
7310     AbilityInfo abilityInfo;
7311     ErrCode ret = bundleMgrProxy->GetSandboxAbilityInfo(want, appIndex, flags, userId, abilityInfo);
7312     EXPECT_NE(ret, ERR_OK);
7313     int32_t appIndex1 = 0;
7314     ret = bundleMgrProxy->GetSandboxAbilityInfo(want, appIndex1, flags, userId, abilityInfo);
7315     EXPECT_NE(ret, ERR_OK);
7316     int32_t appIndex2 = 1000;
7317     ret = bundleMgrProxy->GetSandboxAbilityInfo(want, appIndex2, flags, userId, abilityInfo);
7318     EXPECT_NE(ret, ERR_OK);
7319 }
7320 
7321 /**
7322  * @tc.number: GetSandboxExtAbilityInfos_0100
7323  * @tc.name: test GetSandboxExtAbilityInfos proxy
7324  * @tc.desc: 1.system run normally
7325  *           2.return not ERR_OK
7326  */
7327 HWTEST_F(ActsBmsKitSystemTest, GetSandboxExtAbilityInfos_0100, Function | SmallTest | Level1)
7328 {
7329     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
7330     ASSERT_NE(bundleMgrProxy, nullptr);
7331     Want want;
7332     int32_t appIndex = TEST_APP_INDEX1;
7333     int32_t flags = 0;
7334     int32_t userId = 100;
7335     std::vector<ExtensionAbilityInfo> extensionInfos;
7336     ErrCode ret = bundleMgrProxy->GetSandboxExtAbilityInfos(want, appIndex, flags, userId, extensionInfos);
7337     EXPECT_NE(ret, ERR_OK);
7338     int32_t appIndex1 = 0;
7339     ret = bundleMgrProxy->GetSandboxExtAbilityInfos(want, appIndex1, flags, userId, extensionInfos);
7340     EXPECT_NE(ret, ERR_OK);
7341     int32_t appIndex2 = 1000;
7342     ret = bundleMgrProxy->GetSandboxExtAbilityInfos(want, appIndex2, flags, userId, extensionInfos);
7343     EXPECT_NE(ret, ERR_OK);
7344 }
7345 
7346 /**
7347  * @tc.number: GetSandboxHapModuleInfo_0100
7348  * @tc.name: test GetSandboxHapModuleInfo proxy
7349  * @tc.desc: 1.system run normally
7350  *           2.return not ERR_OK
7351  */
7352 HWTEST_F(ActsBmsKitSystemTest, GetSandboxHapModuleInfo_0100, Function | SmallTest | Level1)
7353 {
7354     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
7355     ASSERT_NE(bundleMgrProxy, nullptr);
7356     AbilityInfo abilityInfo;
7357     int32_t appIndex = TEST_APP_INDEX1;
7358     int32_t userId = 100;
7359     HapModuleInfo hapModuleInfo;
7360     ErrCode ret = bundleMgrProxy->GetSandboxHapModuleInfo(abilityInfo, appIndex, userId, hapModuleInfo);
7361     EXPECT_NE(ret, ERR_OK);
7362     int32_t appIndex1 = 0;
7363     ret = bundleMgrProxy->GetSandboxHapModuleInfo(abilityInfo, appIndex1, userId, hapModuleInfo);
7364     EXPECT_NE(ret, ERR_OK);
7365     int32_t appIndex2 = 1000;
7366     ret = bundleMgrProxy->GetSandboxHapModuleInfo(abilityInfo, appIndex2, userId, hapModuleInfo);
7367     EXPECT_NE(ret, ERR_OK);
7368 }
7369 
7370 /**
7371  * @tc.number: GetMediaData_0100
7372  * @tc.name: test GetMediaData proxy
7373  * @tc.desc: 1.system run normally
7374  *           2.return not ERR_OK
7375  */
7376 HWTEST_F(ActsBmsKitSystemTest, GetMediaData_0100, Function | SmallTest | Level1)
7377 {
7378     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
7379     ASSERT_NE(bundleMgrProxy, nullptr);
7380     std::string bundleName = "";
7381     std::string moduleName = "invalid";
7382     std::string abilityName = "invalid";
7383     std::unique_ptr<uint8_t[]> mediaDataPtr = nullptr;
7384     size_t len = 0;
7385     ErrCode ret = bundleMgrProxy->GetMediaData(bundleName, moduleName, abilityName, mediaDataPtr, len);
7386     EXPECT_NE(ret, ERR_OK);
7387 }
7388 
7389 /**
7390  * @tc.number: GetMediaData_0200
7391  * @tc.name: test GetMediaData proxy
7392  * @tc.desc: 1.system run normally
7393  *           2.return not ERR_OK
7394  */
7395 HWTEST_F(ActsBmsKitSystemTest, GetMediaData_0200, Function | SmallTest | Level1)
7396 {
7397     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
7398     ASSERT_NE(bundleMgrProxy, nullptr);
7399     std::string bundleName = "invalid";
7400     std::string moduleName = "";
7401     std::string abilityName = "invalid";
7402     std::unique_ptr<uint8_t[]> mediaDataPtr = nullptr;
7403     size_t len = 0;
7404     ErrCode ret = bundleMgrProxy->GetMediaData(bundleName, moduleName, abilityName, mediaDataPtr, len);
7405     EXPECT_NE(ret, ERR_OK);
7406 }
7407 
7408 /**
7409  * @tc.number: GetMediaData_0300
7410  * @tc.name: test GetMediaData proxy
7411  * @tc.desc: 1.system run normally
7412  *           2.return not ERR_OK
7413  */
7414 HWTEST_F(ActsBmsKitSystemTest, GetMediaData_0300, Function | SmallTest | Level1)
7415 {
7416     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
7417     ASSERT_NE(bundleMgrProxy, nullptr);
7418     std::string bundleName = "invalid";
7419     std::string moduleName = "invalid";
7420     std::string abilityName = "invalid";
7421     std::unique_ptr<uint8_t[]> mediaDataPtr = nullptr;
7422     size_t len = 0;
7423     ErrCode ret = bundleMgrProxy->GetMediaData(bundleName, moduleName, abilityName, mediaDataPtr, len);
7424     EXPECT_NE(ret, ERR_OK);
7425 }
7426 
7427 /**
7428  * @tc.number: GetBundleArchiveInfoV9_0100
7429  * @tc.name: test query archive information
7430  * @tc.desc: 1.under '/data/test/bms_bundle',there is a hap
7431  *           2.query archive information without an ability information
7432  */
7433 HWTEST_F(ActsBmsKitSystemTest, GetBundleArchiveInfoV9_0100, Function | MediumTest | Level1)
7434 {
7435     std::cout << "START GetBundleArchiveInfoV9_0100" << std::endl;
7436     std::string hapFilePath = THIRD_BUNDLE_PATH + "bmsThirdBundle3.hap";
7437     std::string appName = BASE_BUNDLE_NAME + "1";
7438 
7439     BundleInfo bundleInfo;
7440     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
7441     ASSERT_NE(bundleMgrProxy, nullptr);
7442 
7443     ErrCode getInfoResult =
7444         bundleMgrProxy->GetBundleArchiveInfoV9(hapFilePath, 0, bundleInfo);
7445     EXPECT_EQ(getInfoResult, ERR_OK);
7446     EXPECT_EQ(bundleInfo.name, appName);
7447     std::cout << "END GetBundleArchiveInfoV9_0100" << std::endl;
7448 }
7449 
7450 /**
7451  * @tc.number: GetBundleArchiveInfoV9_0200
7452  * @tc.name: test query archive information
7453  * @tc.desc: 1.under '/data/test/bms_bundle',there is a hap
7454  *           2.query archive information without an ability information
7455  */
7456 HWTEST_F(ActsBmsKitSystemTest, GetBundleArchiveInfoV9_0200, Function | MediumTest | Level1)
7457 {
7458     std::cout << "START GetBundleArchiveInfoV9_0200" << std::endl;
7459     BundleInfo bundleInfo;
7460     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
7461     ASSERT_NE(bundleMgrProxy, nullptr);
7462 
7463     ErrCode getInfoResult =
7464         bundleMgrProxy->GetBundleArchiveInfoV9("", 0, bundleInfo);
7465     EXPECT_EQ(getInfoResult, ERR_BUNDLE_MANAGER_INVALID_HAP_PATH);
7466     std::cout << "END GetBundleArchiveInfoV9_0200" << std::endl;
7467 }
7468 
7469 /**
7470  * @tc.number: GetBundleArchiveInfoV9_0300
7471  * @tc.name: test query archive information
7472  * @tc.desc: 1.under '/data/test/bms_bundle',there is a hap
7473  *           2.query archive information with signature information
7474  */
7475 HWTEST_F(ActsBmsKitSystemTest, GetBundleArchiveInfoV9_0300, Function | MediumTest | Level1)
7476 {
7477     std::cout << "START GetBundleArchiveInfoV9_0300" << std::endl;
7478     BundleInfo bundleInfo;
7479     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
7480     ASSERT_NE(bundleMgrProxy, nullptr);
7481 
7482     std::string hapFilePath = THIRD_BUNDLE_PATH + "bmsThirdBundle3.hap";
7483     ErrCode getInfoResult = bundleMgrProxy->GetBundleArchiveInfoV9(hapFilePath,
7484         static_cast<int32_t>(GetBundleInfoFlag::GET_BUNDLE_INFO_WITH_SIGNATURE_INFO) |
7485         static_cast<int32_t>(GetBundleInfoFlag::GET_BUNDLE_INFO_WITH_APPLICATION), bundleInfo);
7486     EXPECT_EQ(getInfoResult, ERR_OK);
7487     EXPECT_EQ(bundleInfo.signatureInfo.appId, APPID);
7488     EXPECT_EQ(bundleInfo.signatureInfo.fingerprint, FINGER_PRINT);
7489     EXPECT_EQ(bundleInfo.signatureInfo.appIdentifier, "");
7490     EXPECT_EQ(bundleInfo.applicationInfo.appPrivilegeLevel, "system_core");
7491     EXPECT_EQ(bundleInfo.applicationInfo.appProvisionType, "release");
7492     EXPECT_EQ(bundleInfo.applicationInfo.appDistributionType, "os_integration");
7493     std::cout << "END GetBundleArchiveInfoV9_0300" << std::endl;
7494 }
7495 
7496 /**
7497  * @tc.number: GetShortcutInfoV9_0100
7498  * @tc.name: test query archive information
7499  * @tc.desc: 1.under '/data/test/bms_bundle',there is a hap
7500  *           2.query archive information without an ability information
7501  */
7502 HWTEST_F(ActsBmsKitSystemTest, GetShortcutInfoV9_0100, Function | MediumTest | Level1)
7503 {
7504     APP_LOGD("START GetShortcutInfoV9_010");
7505     int32_t originUid = geteuid();
7506     seteuid(HUNDRED_USERID);
7507     std::vector<std::string> resvec;
7508     std::string bundleFilePath = THIRD_BUNDLE_PATH + "bundleClient1.hap";
7509     std::string appName = "com.example.ohosproject.hmservice";
7510     Install(bundleFilePath, InstallFlag::REPLACE_EXISTING, resvec);
7511     CommonTool commonTool;
7512     std::string installResult = commonTool.VectorToStr(resvec);
7513     EXPECT_EQ(installResult, "Success") << "install fail!";
7514     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
7515     ASSERT_NE(bundleMgrProxy, nullptr);
7516 
7517     std::vector<ShortcutInfo> shortcutInfos;
7518     ErrCode testRet = bundleMgrProxy->GetShortcutInfoV9(appName, shortcutInfos);
7519     EXPECT_EQ(testRet, ERR_OK);
7520 
7521     BundleInfo bundleInfo;
7522     bundleMgrProxy->GetBundleInfo(appName, BundleFlag::GET_BUNDLE_DEFAULT, bundleInfo, USERID);
7523     int uid = bundleInfo.uid;
7524     std::string callingBundleName;
7525     bundleMgrProxy->GetNameForUid(uid, callingBundleName);
7526     testRet = bundleMgrProxy->GetShortcutInfoV9(callingBundleName, shortcutInfos);
7527     EXPECT_EQ(testRet, ERR_OK);
7528 
7529     resvec.clear();
7530     Uninstall(appName, resvec);
7531     std::string uninstallResult = commonTool.VectorToStr(resvec);
7532     EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!";
7533     seteuid(originUid);
7534     APP_LOGD("END GetShortcutInfoV9_010");
7535 }
7536 
7537 /**
7538  * @tc.number: GetShortcutInfoV9_0200
7539  * @tc.name: test query archive information
7540  * @tc.desc: 1.under '/data/test/bms_bundle',there is a hap
7541  *           2.query archive information without an ability information
7542  */
7543 HWTEST_F(ActsBmsKitSystemTest, GetShortcutInfoV9_0200, Function | MediumTest | Level1)
7544 {
7545     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
7546     ASSERT_NE(bundleMgrProxy, nullptr);
7547 
7548     std::vector<ShortcutInfo> shortcutInfos;
7549     ErrCode testRet = bundleMgrProxy->GetShortcutInfoV9("", shortcutInfos);
7550     EXPECT_EQ(testRet, ERR_BUNDLE_MANAGER_BUNDLE_NOT_EXIST);
7551 }
7552 
7553 /**
7554  * @tc.number: GetShortcutInfoV9_0300
7555  * @tc.name: test GetShortcutInfoV9 proxy
7556  * @tc.desc: 1.system run normally
7557  *           2.get udid info failed by wrong hap
7558  */
7559 HWTEST_F(ActsBmsKitSystemTest, GetShortcutInfoV9_0300, Function | SmallTest | Level1)
7560 {
7561     std::cout << "START GetShortcutInfoV9_0300" << std::endl;
7562     std::vector<std::string> resvec;
7563     std::string bundleFilePath = THIRD_BUNDLE_PATH + "bmsThirdBundle1.hap";
7564     std::string appName = BASE_BUNDLE_NAME + "1";
7565     Install(bundleFilePath, InstallFlag::REPLACE_EXISTING, resvec);
7566     CommonTool commonTool;
7567     std::string installResult = commonTool.VectorToStr(resvec);
7568     EXPECT_EQ(installResult, "Success") << "install fail!";
7569 
7570     std::vector<ShortcutInfo> shortcutInfos;
7571     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
7572     ASSERT_NE(bundleMgrProxy, nullptr);
7573     ErrCode testRet = bundleMgrProxy->GetShortcutInfoV9(appName, shortcutInfos);
7574     EXPECT_NE(testRet, ERR_OK);
7575 
7576     resvec.clear();
7577     Uninstall(appName, resvec);
7578     std::string uninstallResult = commonTool.VectorToStr(resvec);
7579     EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!";
7580     std::cout << "END GetShortcutInfoV9_0300" << std::endl;
7581 }
7582 
7583 /**
7584  * @tc.number: event_callback_0100
7585  * @tc.name: 1.test RegisterBundleEventCallback interface
7586  *           2.test UnregisterBundleEventCallback interface
7587  * @tc.desc: 1. success condition
7588  */
7589 HWTEST_F(ActsBmsKitSystemTest, event_callback_0100, Function | MediumTest | Level1)
7590 {
7591     std::cout << "begin to test event_callback_0100" << std::endl;
7592     int32_t originUid = geteuid();
7593     seteuid(Constants::FOUNDATION_UID);
7594 
7595     sptr<BundleEventCallbackImpl> callback = (new (std::nothrow) BundleEventCallbackImpl());
7596     EXPECT_NE(callback, nullptr);
7597     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
7598     ASSERT_NE(bundleMgrProxy, nullptr);
7599     bool re = bundleMgrProxy->RegisterBundleEventCallback(callback);
7600     EXPECT_TRUE(re);
7601 
7602     std::vector<std::string> resvec;
7603     std::string bundleFilePath = THIRD_BUNDLE_PATH + "bmsThirdBundle1.hap";
7604     std::string appName = BASE_BUNDLE_NAME + "1";
7605     CommonTool commonTool;
7606     Install(bundleFilePath, InstallFlag::REPLACE_EXISTING, resvec);
7607     std::string installResult = commonTool.VectorToStr(resvec);
7608     EXPECT_EQ(installResult, "Success") << "install fail!";
7609     resvec.clear();
7610     Uninstall(appName, resvec);
7611     std::string uninstallResult = commonTool.VectorToStr(resvec);
7612     EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!";
7613 
7614     re = bundleMgrProxy->UnregisterBundleEventCallback(callback);
7615     EXPECT_TRUE(re);
7616 
7617     seteuid(originUid);
7618     std::cout << "test event_callback_0100 done" << std::endl;
7619 }
7620 
7621 /**
7622  * @tc.number: event_callback_0200
7623  * @tc.name: 1.test RegisterBundleEventCallback interface
7624  *           2.test UnregisterBundleEventCallback interface
7625  * @tc.desc: 1. failed condition, uid verify failed
7626  */
7627 HWTEST_F(ActsBmsKitSystemTest, event_callback_0200, Function | MediumTest | Level1)
7628 {
7629     std::cout << "begin to test event_callback_0200" << std::endl;
7630     sptr<BundleEventCallbackImpl> callback = (new (std::nothrow) BundleEventCallbackImpl());
7631     EXPECT_NE(callback, nullptr);
7632     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
7633     ASSERT_NE(bundleMgrProxy, nullptr);
7634 
7635     bool re = bundleMgrProxy->RegisterBundleEventCallback(callback);
7636     EXPECT_FALSE(re);
7637 
7638     re = bundleMgrProxy->UnregisterBundleEventCallback(callback);
7639     EXPECT_FALSE(re);
7640     std::cout << "test event_callback_0200 done" << std::endl;
7641 }
7642 
7643 /**
7644  * @tc.number: event_callback_0300
7645  * @tc.name: 1.test RegisterBundleEventCallback interface
7646  *           2.test UnregisterBundleEventCallback interface
7647  * @tc.desc: 1. failed condition, invalid param
7648  */
7649 HWTEST_F(ActsBmsKitSystemTest, event_callback_0300, Function | MediumTest | Level1)
7650 {
7651     std::cout << "begin to test event_callback_0300" << std::endl;
7652     sptr<BundleEventCallbackImpl> callback = nullptr;
7653     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
7654     ASSERT_NE(bundleMgrProxy, nullptr);
7655 
7656     bool re = bundleMgrProxy->RegisterBundleEventCallback(callback);
7657     EXPECT_FALSE(re);
7658 
7659     re = bundleMgrProxy->UnregisterBundleEventCallback(callback);
7660     EXPECT_FALSE(re);
7661     std::cout << "test event_callback_0300 done" << std::endl;
7662 }
7663 
7664 /**
7665  * @tc.number: bundle_installer_0100
7666  * @tc.name: 1.test Install interface
7667  * @tc.desc: 1. failed condition, return false
7668  */
7669 HWTEST_F(ActsBmsKitSystemTest, bundle_installer_0100, Function | MediumTest | Level1)
7670 {
7671     std::cout << "begin to test bundle_installer_0100" << std::endl;
7672     sptr<IRemoteObject> object;
7673     BundleInstallerProxy installerProxy(object);
7674     std::string bundlePath = THIRD_BUNDLE_PATH + "bmsThirdBundle24.hap";
7675     InstallParam installParam;
7676     sptr<IStatusReceiver> statusReceiver = nullptr;
7677     auto res = installerProxy.Install(bundlePath, installParam, statusReceiver);
7678     EXPECT_FALSE(res);
7679     std::cout << "test bundle_installer_0100 done" << std::endl;
7680 }
7681 
7682 /**
7683  * @tc.number: bundle_installer_0200
7684  * @tc.name: 1.test Install interface
7685  * @tc.desc: 1. failed condition, return false
7686  */
7687 HWTEST_F(ActsBmsKitSystemTest, bundle_installer_0200, Function | MediumTest | Level1)
7688 {
7689     std::cout << "begin to test bundle_installer_0200" << std::endl;
7690     sptr<IRemoteObject> object;
7691     BundleInstallerProxy installerProxy(object);
7692     std::vector<std::string> bundlePaths;
7693     bundlePaths.push_back(THIRD_BUNDLE_PATH + "bmsThirdBundle24.hap");
7694     bundlePaths.push_back(THIRD_BUNDLE_PATH + "bmsThirdBundle1.hap");
7695     InstallParam installParam;
7696     sptr<IStatusReceiver> statusReceiver = nullptr;
7697     auto res = installerProxy.Install(bundlePaths, installParam, statusReceiver);
7698     EXPECT_FALSE(res);
7699     std::cout << "test bundle_installer_0200 done" << std::endl;
7700 }
7701 
7702 /**
7703  * @tc.number: bundle_installer_0300
7704  * @tc.name: 1.test Recover interface
7705  * @tc.desc: 1. failed condition, return false
7706  */
7707 HWTEST_F(ActsBmsKitSystemTest, bundle_installer_0300, Function | MediumTest | Level1)
7708 {
7709     std::cout << "begin to test bundle_installer_0300" << std::endl;
7710     sptr<IRemoteObject> object;
7711     BundleInstallerProxy installerProxy(object);
7712     std::string bundlePath = THIRD_BUNDLE_PATH + "bmsThirdBundle24.hap";
7713     InstallParam installParam;
7714     sptr<IStatusReceiver> statusReceiver = nullptr;
7715     auto res = installerProxy.Recover(bundlePath, installParam, statusReceiver);
7716     EXPECT_FALSE(res);
7717     std::cout << "test bundle_installer_0300 done" << std::endl;
7718 }
7719 
7720 /**
7721  * @tc.number: bundle_installer_0400
7722  * @tc.name: 1.test Uninstall interface
7723  * @tc.desc: 1. failed condition, return false
7724  */
7725 HWTEST_F(ActsBmsKitSystemTest, bundle_installer_0400, Function | MediumTest | Level1)
7726 {
7727     std::cout << "begin to test bundle_installer_0400" << std::endl;
7728     sptr<IRemoteObject> object;
7729     BundleInstallerProxy installerProxy(object);
7730     std::string bundlePath = THIRD_BUNDLE_PATH + "bmsThirdBundle24.hap";
7731     InstallParam installParam;
7732     sptr<IStatusReceiver> statusReceiver = nullptr;
7733     auto res = installerProxy.Uninstall(bundlePath, installParam, statusReceiver);
7734     EXPECT_FALSE(res);
7735     std::cout << "test bundle_installer_0400 done" << std::endl;
7736 }
7737 
7738 /**
7739  * @tc.number: bundle_installer_0500
7740  * @tc.name: 1.test Uninstall interface
7741  * @tc.desc: 1. failed condition, return false
7742  */
7743 HWTEST_F(ActsBmsKitSystemTest, bundle_installer_0500, Function | MediumTest | Level1)
7744 {
7745     std::cout << "begin to test bundle_installer_0500" << std::endl;
7746     sptr<IRemoteObject> object;
7747     BundleInstallerProxy installerProxy(object);
7748     std::string bundlePath = THIRD_BUNDLE_PATH + "bmsThirdBundle24.hap";
7749     std::string modulePackage = BASE_MODULE_NAME;
7750     InstallParam installParam;
7751     sptr<IStatusReceiver> statusReceiver = nullptr;
7752     auto res = installerProxy.Uninstall(bundlePath, modulePackage, installParam, statusReceiver);
7753     EXPECT_FALSE(res);
7754     std::cout << "test bundle_installer_0500 done" << std::endl;
7755 }
7756 
7757 /**
7758  * @tc.number: bundle_installer_0600
7759  * @tc.name: 1.test InstallSandboxApp interface
7760  * @tc.desc: 1. failed condition, return false
7761  */
7762 HWTEST_F(ActsBmsKitSystemTest, bundle_installer_0600, Function | MediumTest | Level1)
7763 {
7764     std::cout << "begin to test bundle_installer_0600" << std::endl;
7765     sptr<IRemoteObject> object;
7766     BundleInstallerProxy installerProxy(object);
7767     std::string bundlePath = THIRD_BUNDLE_PATH + "bmsThirdBundle24.hap";
7768     int32_t dlpType = 1;
7769     int32_t userId = 100;
7770     int32_t appIndex = TEST_APP_INDEX1;
7771     auto res = installerProxy.InstallSandboxApp(bundlePath, dlpType, userId, appIndex);
7772     EXPECT_EQ(res, ERR_APPEXECFWK_SANDBOX_INSTALL_SEND_REQUEST_ERROR);
7773     std::cout << "test bundle_installer_0600 done" << std::endl;
7774 }
7775 
7776 /**
7777  * @tc.number: bundle_installer_0700
7778  * @tc.name: 1.test UninstallSandboxApp interface
7779  * @tc.desc: 1. failed condition, return false
7780  */
7781 HWTEST_F(ActsBmsKitSystemTest, bundle_installer_0700, Function | MediumTest | Level1)
7782 {
7783     std::cout << "begin to test bundle_installer_0700" << std::endl;
7784     sptr<IRemoteObject> object;
7785     BundleInstallerProxy installerProxy(object);
7786     std::string bundlePath = THIRD_BUNDLE_PATH + "bmsThirdBundle24.hap";
7787     int32_t dlpType = 1;
7788     int32_t userId = 100;
7789     auto res = installerProxy.UninstallSandboxApp(bundlePath, dlpType, userId);
7790     EXPECT_EQ(res, ERR_APPEXECFWK_SANDBOX_INSTALL_SEND_REQUEST_ERROR);
7791     std::cout << "test bundle_installer_0700 done" << std::endl;
7792 }
7793 
7794 /**
7795  * @tc.number: bundle_installer_0800
7796  * @tc.name: 1.test Uninstall interface
7797  * @tc.desc: 1. failed condition, return false
7798  */
7799 HWTEST_F(ActsBmsKitSystemTest, bundle_installer_0800, Function | MediumTest | Level1)
7800 {
7801     std::cout << "begin to test bundle_installer_0800" << std::endl;
7802     sptr<IRemoteObject> object;
7803     BundleInstallerProxy installerProxy(object);
7804     std::string bundlePath = THIRD_BUNDLE_PATH + "bmsThirdBundle24.hap";
7805     std::string modulePackage = BASE_MODULE_NAME;
7806     UninstallParam uninstallParam;
7807     sptr<IStatusReceiver> statusReceiver = nullptr;
7808     auto res = installerProxy.Uninstall(uninstallParam, statusReceiver);
7809     EXPECT_FALSE(res);
7810     std::cout << "test bundle_installer_0800 done" << std::endl;
7811 }
7812 
7813 /**
7814  * @tc.number: CleanBundleCacheFiles_0100
7815  * @tc.name: test CleanBundleCacheFiles proxy
7816  * @tc.desc: 1.system run normally
7817  *           2.get udid info failed by wrong hap
7818  */
7819 HWTEST_F(ActsBmsKitSystemTest, CleanBundleCacheFiles_0100, Function | SmallTest | Level1)
7820 {
7821     sptr<ICleanCacheCallback> cleanCacheCallback;
7822     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
7823     ASSERT_NE(bundleMgrProxy, nullptr);
7824     ErrCode testRet = bundleMgrProxy->CleanBundleCacheFiles("", cleanCacheCallback, USERID);
7825     EXPECT_EQ(testRet, ERR_BUNDLE_MANAGER_BUNDLE_NOT_EXIST);
7826 }
7827 
7828 /**
7829  * @tc.number: CleanBundleCacheFiles_0200
7830  * @tc.name: test CleanBundleCacheFiles proxy
7831  * @tc.desc: 1.system run normally
7832  *           2.get udid info failed by wrong hap
7833  */
7834 HWTEST_F(ActsBmsKitSystemTest, CleanBundleCacheFiles_0200, Function | SmallTest | Level1)
7835 {
7836     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
7837     ASSERT_NE(bundleMgrProxy, nullptr);
7838     ErrCode testRet = bundleMgrProxy->CleanBundleCacheFiles("bundleName", nullptr, USERID);
7839     EXPECT_EQ(testRet, ERR_BUNDLE_MANAGER_PARAM_ERROR);
7840 }
7841 
7842 /**
7843  * @tc.number: CheckAbilityEnableInstall_0100
7844  * @tc.name: test CheckAbilityEnableInstall proxy
7845  * @tc.desc: 1.system run normally
7846  */
7847 HWTEST_F(ActsBmsKitSystemTest, CheckAbilityEnableInstall_0100, Function | SmallTest | Level1)
7848 {
7849     Want want;
7850     int32_t missionId = 0;
7851     sptr<IRemoteObject> callback;
7852     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
7853     ASSERT_NE(bundleMgrProxy, nullptr);
7854     bool testRet = bundleMgrProxy->CheckAbilityEnableInstall(want, missionId, USERID, callback);
7855     EXPECT_EQ(testRet, false);
7856 }
7857 
7858 /**
7859  * @tc.number: CheckAbilityEnableInstall_0200
7860  * @tc.name: test CheckAbilityEnableInstall proxy
7861  * @tc.desc: 1.system run normally
7862  */
7863 HWTEST_F(ActsBmsKitSystemTest, CheckAbilityEnableInstall_0200, Function | SmallTest | Level1)
7864 {
7865     Want want;
7866     OHOS::AppExecFwk::ElementName elementName;
7867     elementName.SetDeviceID(DEVICE_ID);
7868     elementName.SetBundleName(BASE_BUNDLE_NAME);
7869     want.SetElement(elementName);
7870     int32_t missionId = 0;
7871     sptr<IRemoteObject> callback;
7872     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
7873     ASSERT_NE(bundleMgrProxy, nullptr);
7874     bool testRet = bundleMgrProxy->CheckAbilityEnableInstall(want, missionId, USERID, callback);
7875     EXPECT_EQ(testRet, false);
7876 }
7877 
7878 /**
7879  * @tc.number: GetBundleInfoForSelf_0100
7880  * @tc.name: get bundle info for self
7881  * @tc.desc: 1.system run normally
7882  *           2.get bundle info for self success
7883  */
7884 HWTEST_F(ActsBmsKitSystemTest, GetBundleInfoForSelf_0100, Function | MediumTest | Level1)
7885 {
7886     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
7887     ASSERT_NE(bundleMgrProxy, nullptr);
7888 
7889     BundleInfo bundleInfo;
7890     int32_t flags = 1;
7891     bool getInfoResult = bundleMgrProxy->GetBundleInfoForSelf(flags, bundleInfo);
7892     EXPECT_TRUE(getInfoResult);
7893 }
7894 
7895 /**
7896  * @tc.number: GetBundleInfoForSelf_0200
7897  * @tc.name: get bundle info for self
7898  * @tc.desc: 1.system run normally
7899  *           2.get bundle info for self success
7900  */
7901 HWTEST_F(ActsBmsKitSystemTest, GetBundleInfoForSelf_0200, Function | MediumTest | Level1)
7902 {
7903     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
7904     ASSERT_NE(bundleMgrProxy, nullptr);
7905 
7906     BundleInfo bundleInfo;
7907     int32_t flags = BundleFlag::GET_BUNDLE_DEFAULT;
7908     bool getInfoResult = bundleMgrProxy->GetBundleInfoForSelf(flags, bundleInfo);
7909     EXPECT_TRUE(getInfoResult);
7910 }
7911 
7912 /**
7913  * @tc.number: VerifySystemApi_0100
7914  * @tc.name: test VerifySystemApi proxy
7915  * @tc.desc: 1.system run normally
7916  *           2.verify system api
7917  */
7918 HWTEST_F(ActsBmsKitSystemTest, VerifySystemApi_0100, Function | SmallTest | Level1)
7919 {
7920     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
7921     ASSERT_NE(bundleMgrProxy, nullptr);
7922     int32_t beginApiVersion = 1;
7923     auto res = bundleMgrProxy->VerifySystemApi(beginApiVersion);
7924     EXPECT_EQ(res, true);
7925 }
7926 
7927 /**
7928  * @tc.number: CheckNeedPreload_0100
7929  * @tc.name: test CheckNeedPreload
7930  * @tc.desc: 1.system run normally
7931  *           2.test failed
7932  */
7933 HWTEST_F(ActsBmsKitSystemTest, CheckNeedPreload_0100, Function | SmallTest | Level1)
7934 {
7935     ModuleInfo moduleInfo1;
7936     std::string name1 = "testCheckNeedPreload1";
7937     moduleInfo1.preloads.push_back(name1);
7938     moduleInfo1.moduleName = "testCheckNeedPreload1";
7939 
7940     ApplicationInfo applicationInfo;
7941     applicationInfo.moduleInfos.push_back(moduleInfo1);
7942 
7943     std::string moduleName = "testCheckNeedPreload";
7944     bool res = applicationInfo.CheckNeedPreload(moduleName);
7945     EXPECT_EQ(res, false);
7946 
7947     moduleName = "testCheckNeedPreload1";
7948     res = applicationInfo.CheckNeedPreload(moduleName);
7949     EXPECT_EQ(res, false);
7950 }
7951 
7952 /**
7953  * @tc.number: CheckNeedPreload_0200
7954  * @tc.name: test CheckNeedPreload
7955  * @tc.desc: 1.system run normally
7956  *           2.test successed
7957  */
7958 HWTEST_F(ActsBmsKitSystemTest, CheckNeedPreload_0200, Function | SmallTest | Level1)
7959 {
7960     ModuleInfo moduleInfo1;
7961     std::string name1 = "testCheckNeedPreload1";
7962     std::string name2 = "testCheckNeedPreload2";
7963     moduleInfo1.preloads.push_back(name1);
7964     moduleInfo1.preloads.push_back(name2);
7965     moduleInfo1.moduleName = "testCheckNeedPreload1";
7966 
7967     ApplicationInfo applicationInfo;
7968     applicationInfo.moduleInfos.push_back(moduleInfo1);
7969 
7970     std::string moduleName = "testCheckNeedPreload1";
7971     bool res = applicationInfo.CheckNeedPreload(moduleName);
7972     EXPECT_EQ(res, true);
7973 }
7974 
7975 /**
7976  * @tc.number: SilentInstall_0100
7977  * @tc.name: test SilentInstall proxy
7978  * @tc.desc: 1.system run normally
7979  */
7980 HWTEST_F(ActsBmsKitSystemTest, SilentInstall_0100, Function | SmallTest | Level1)
7981 {
7982     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
7983     ASSERT_NE(bundleMgrProxy, nullptr);
7984     Want want;
7985     want.SetAction("action.system.home");
7986     want.AddEntity("entity.system.home");
7987     bool ret = bundleMgrProxy->SilentInstall(want, USERID, nullptr);
7988     EXPECT_FALSE(ret);
7989 }
7990 
7991 /**
7992  * @tc.number: SilentInstall_0200
7993  * @tc.name: test SilentInstall proxy
7994  * @tc.desc: 1.system run normally
7995  */
7996 HWTEST_F(ActsBmsKitSystemTest, SilentInstall_0200, Function | MediumTest | Level1)
7997 {
7998     std::cout << "START SilentInstall_0200" << std::endl;
7999     std::vector<std::string> resvec;
8000     std::string bundleFilePath = THIRD_BUNDLE_PATH + "bmsThirdBundle1.hap";
8001     std::string appName = BASE_BUNDLE_NAME + "1";
8002     std::string abilityName = BASE_ABILITY_NAME;
8003     Install(bundleFilePath, InstallFlag::REPLACE_EXISTING, resvec);
8004 
8005     CommonTool commonTool;
8006     std::string installResult = commonTool.VectorToStr(resvec);
8007     EXPECT_EQ(installResult, "Success") << "install fail!";
8008 
8009     Want want;
8010     ElementName name;
8011     name.SetAbilityName(abilityName);
8012     name.SetBundleName(appName);
8013     want.SetElement(name);
8014 
8015     AbilityInfo abilityInfo;
8016     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
8017     ASSERT_NE(bundleMgrProxy, nullptr);
8018 
8019     sptr<ISystemAbilityManager> systemAbilityManager =
8020         SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
8021 
8022     sptr<IRemoteObject> remoteObject = systemAbilityManager->GetSystemAbility(BUNDLE_MGR_SERVICE_SYS_ABILITY_ID);
8023     bool queryResult = bundleMgrProxy->SilentInstall(want, USERID, remoteObject);
8024     EXPECT_TRUE(queryResult);
8025 
8026     resvec.clear();
8027     Uninstall(appName, resvec);
8028     std::string uninstallResult = commonTool.VectorToStr(resvec);
8029     EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!";
8030     std::cout << "END SilentInstall_0200" << std::endl;
8031 }
8032 
8033 /**
8034  * @tc.number: ProcessPreload_0100
8035  * @tc.name: test ProcessPreload proxy
8036  * @tc.desc: 1.system run normally
8037  */
8038 HWTEST_F(ActsBmsKitSystemTest, ProcessPreload_0100, Function | SmallTest | Level1)
8039 {
8040     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
8041     ASSERT_NE(bundleMgrProxy, nullptr);
8042     Want want;
8043     want.SetElementName("", BASE_ABILITY_NAME, BASE_ABILITY_NAME, BASE_MODULE_NAME);
8044     bool res = bundleMgrProxy->ProcessPreload(want);
8045     EXPECT_FALSE(res);
8046 }
8047 
8048 /**
8049  * @tc.number: GetAllSharedBundleInfo_0100
8050  * @tc.name: test GetAllSharedBundleInfo proxy
8051  * @tc.desc: 1.system run normally
8052  */
8053 HWTEST_F(ActsBmsKitSystemTest, GetAllSharedBundleInfo_0100, Function | SmallTest | Level1)
8054 {
8055     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
8056     ASSERT_NE(bundleMgrProxy, nullptr);
8057     std::vector<SharedBundleInfo> sharedBundles;
8058     ErrCode ret = bundleMgrProxy->GetAllSharedBundleInfo(sharedBundles);
8059     EXPECT_EQ(ret, ERR_OK);
8060 }
8061 
8062 /**
8063  * @tc.number: GetDependentBundleInfo_0100
8064  * @tc.name: test GetDependentBundleInfo proxy
8065  * @tc.desc: 1.system run normally
8066  */
8067 HWTEST_F(ActsBmsKitSystemTest, GetDependentBundleInfo_0100, Function | SmallTest | Level1)
8068 {
8069     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
8070     ASSERT_NE(bundleMgrProxy, nullptr);
8071     BundleInfo info;
8072     ErrCode ret = bundleMgrProxy->GetDependentBundleInfo(BASE_BUNDLE_NAME, info);
8073     EXPECT_EQ(ret, ERR_BUNDLE_MANAGER_PERMISSION_DENIED);
8074 }
8075 
8076 /**
8077  * @tc.number: GetUidByDebugBundleName_0100
8078  * @tc.name: test GetUidByDebugBundleName proxy
8079  * @tc.desc: 1.system run normally
8080  */
8081 HWTEST_F(ActsBmsKitSystemTest, GetUidByDebugBundleName_0100, Function | SmallTest | Level1)
8082 {
8083     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
8084     ASSERT_NE(bundleMgrProxy, nullptr);
8085     int uid = 0;
8086     int ret = bundleMgrProxy->GetUidByDebugBundleName(BASE_BUNDLE_NAME, uid);
8087     EXPECT_EQ(ret, INVALIED_ID);
8088 }
8089 
8090 /**
8091  * @tc.number: GetUidByDebugBundleName_0200
8092  * @tc.name: test GetUidByDebugBundleName proxy
8093  * @tc.desc: 1.system run normally
8094  */
8095 HWTEST_F(ActsBmsKitSystemTest, GetUidByDebugBundleName_0200, Function | SmallTest | Level1)
8096 {
8097     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
8098     ASSERT_NE(bundleMgrProxy, nullptr);
8099     int uid = 0;
8100     int ret = bundleMgrProxy->GetUidByDebugBundleName(EMPTY_BUNDLE_NAME, uid);
8101     EXPECT_EQ(ret, INVALIED_ID);
8102 }
8103 
8104 /**
8105  * @tc.number: GetSharedBundleInfo_0100
8106  * @tc.name: test GetSharedBundleInfo proxy
8107  * @tc.desc: 1.system run normally
8108  */
8109 HWTEST_F(ActsBmsKitSystemTest, GetSharedBundleInfo_0100, Function | SmallTest | Level1)
8110 {
8111     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
8112     ASSERT_NE(bundleMgrProxy, nullptr);
8113     std::vector<SharedBundleInfo> sharedBundles;
8114     ErrCode ret = bundleMgrProxy->GetSharedBundleInfo(
8115         BASE_BUNDLE_NAME, BASE_MODULE_NAME, sharedBundles);
8116     EXPECT_EQ(ret, ERR_BUNDLE_MANAGER_BUNDLE_NOT_EXIST);
8117 }
8118 
8119 /**
8120  * @tc.number: GetAppProvisionInfo_0001
8121  * @tc.name: test GetAppProvisionInfo proxy
8122  * @tc.desc: 1.system run normally
8123  */
8124 HWTEST_F(ActsBmsKitSystemTest, GetAppProvisionInfo_0001, Function | SmallTest | Level1)
8125 {
8126     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
8127     ASSERT_NE(bundleMgrProxy, nullptr);
8128     if (!bundleMgrProxy) {
8129         EXPECT_NE(bundleMgrProxy, nullptr);
8130     } else {
8131         AppProvisionInfo appProvisionInfo;
8132         ErrCode ret = bundleMgrProxy->GetAppProvisionInfo(BASE_BUNDLE_NAME, USERID, appProvisionInfo);
8133         EXPECT_EQ(ret, ERR_BUNDLE_MANAGER_BUNDLE_NOT_EXIST);
8134     }
8135 }
8136 
8137 /**
8138  * @tc.number: GetAppProvisionInfo_0002
8139  * @tc.name: test GetAppProvisionInfo proxy
8140  * @tc.desc: 1.system run normally
8141  */
8142 HWTEST_F(ActsBmsKitSystemTest, GetAppProvisionInfo_0002, Function | SmallTest | Level1)
8143 {
8144     std::vector<std::string> resvec;
8145     std::string bundleFilePath = THIRD_BUNDLE_PATH + "bmsThirdBundle1.hap";
8146     std::string appName = BASE_BUNDLE_NAME + "1";
8147     Install(bundleFilePath, InstallFlag::REPLACE_EXISTING, resvec);
8148     CommonTool commonTool;
8149     std::string installResult = commonTool.VectorToStr(resvec);
8150     EXPECT_EQ(installResult, "Success") << "install fail!";
8151     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
8152     ASSERT_NE(bundleMgrProxy, nullptr);
8153 
8154     AppProvisionInfo appProvisionInfo;
8155     ErrCode ret = bundleMgrProxy->GetAppProvisionInfo(appName, INVALIED_ID, appProvisionInfo);
8156     EXPECT_EQ(ret, ERR_BUNDLE_MANAGER_INVALID_USER_ID);
8157     EXPECT_TRUE(appProvisionInfo.apl.empty());
8158     ret = bundleMgrProxy->GetAppProvisionInfo(appName, USERID, appProvisionInfo);
8159     EXPECT_EQ(ret, ERR_OK);
8160     EXPECT_FALSE(appProvisionInfo.apl.empty());
8161 
8162     resvec.clear();
8163     Uninstall(appName, resvec);
8164     std::string uninstallResult = commonTool.VectorToStr(resvec);
8165     EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!";
8166 }
8167 
8168 /**
8169  * @tc.number: GetSpecifiedDistributionType_0001
8170  * @tc.name: test GetSpecifiedDistributionType proxy
8171  * @tc.desc: 1.system run normally
8172  */
8173 HWTEST_F(ActsBmsKitSystemTest, GetSpecifiedDistributionType_0001, Function | SmallTest | Level1)
8174 {
8175     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
8176     ASSERT_NE(bundleMgrProxy, nullptr);
8177     if (!bundleMgrProxy) {
8178         EXPECT_NE(bundleMgrProxy, nullptr);
8179     } else {
8180         std::string specifiedDistributionType;
8181         ErrCode ret = bundleMgrProxy->GetSpecifiedDistributionType(BASE_BUNDLE_NAME, specifiedDistributionType);
8182         EXPECT_EQ(ret, ERR_BUNDLE_MANAGER_BUNDLE_NOT_EXIST);
8183     }
8184 }
8185 
8186 /**
8187  * @tc.number: GetSpecifiedDistributionType_0002
8188  * @tc.name: test GetSpecifiedDistributionType proxy
8189  * @tc.desc: 1.system run normally
8190  */
8191 HWTEST_F(ActsBmsKitSystemTest, GetSpecifiedDistributionType_0002, Function | SmallTest | Level1)
8192 {
8193     std::vector<std::string> resvec;
8194     std::string bundleFilePath = THIRD_BUNDLE_PATH + "bmsThirdBundle1.hap";
8195     std::string appName = BASE_BUNDLE_NAME + "1";
8196     Install(bundleFilePath, InstallFlag::REPLACE_EXISTING, resvec);
8197     CommonTool commonTool;
8198     std::string installResult = commonTool.VectorToStr(resvec);
8199     EXPECT_EQ(installResult, "Success") << "install fail!";
8200     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
8201     ASSERT_NE(bundleMgrProxy, nullptr);
8202 
8203     std::string specifiedDistributionType;
8204     auto ret = bundleMgrProxy->GetSpecifiedDistributionType(appName, specifiedDistributionType);
8205     EXPECT_EQ(ret, ERR_OK);
8206 
8207     resvec.clear();
8208     Uninstall(appName, resvec);
8209     std::string uninstallResult = commonTool.VectorToStr(resvec);
8210     EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!";
8211 }
8212 
8213 /**
8214  * @tc.number: GetAdditionalInfo_0001
8215  * @tc.name: test GetAdditionalInfo proxy
8216  * @tc.desc: 1.system run normally
8217  */
8218 HWTEST_F(ActsBmsKitSystemTest, GetAdditionalInfo_0001, Function | SmallTest | Level1)
8219 {
8220     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
8221     ASSERT_NE(bundleMgrProxy, nullptr);
8222     if (!bundleMgrProxy) {
8223         EXPECT_NE(bundleMgrProxy, nullptr);
8224     } else {
8225         std::string additionalInfo;
8226         ErrCode ret = bundleMgrProxy->GetAdditionalInfo(BASE_BUNDLE_NAME, additionalInfo);
8227         EXPECT_EQ(ret, ERR_BUNDLE_MANAGER_BUNDLE_NOT_EXIST);
8228     }
8229 }
8230 
8231 /**
8232  * @tc.number: GetAllProxyDataInfos_0100
8233  * @tc.name: test GetAllProxyDataInfos proxy
8234  * @tc.desc: 1.system run normally
8235  */
8236 HWTEST_F(ActsBmsKitSystemTest, GetAllProxyDataInfos_0100, Function | SmallTest | Level1)
8237 {
8238     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
8239     ASSERT_NE(bundleMgrProxy, nullptr);
8240     std::vector<ProxyData> proxyDatas;
8241     ErrCode ret = bundleMgrProxy->GetAllProxyDataInfos(proxyDatas);
8242     EXPECT_EQ(ret, ERR_OK);
8243 }
8244 
8245 /**
8246  * @tc.number: GetProxyDataInfos_0100
8247  * @tc.name: test GetProxyDataInfos proxy
8248  * @tc.desc: 1.system run normally
8249  */
8250 HWTEST_F(ActsBmsKitSystemTest, GetProxyDataInfos_0100, Function | SmallTest | Level1)
8251 {
8252     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
8253     ASSERT_NE(bundleMgrProxy, nullptr);
8254     std::vector<ProxyData> proxyDatas;
8255     ErrCode ret = bundleMgrProxy->GetProxyDataInfos(
8256         BASE_BUNDLE_NAME, BASE_MODULE_NAME, proxyDatas);
8257     EXPECT_EQ(ret, ERR_BUNDLE_MANAGER_BUNDLE_NOT_EXIST);
8258 }
8259 
8260 /**
8261  * @tc.number: GetProxyDataInfos_0200
8262  * @tc.name: test GetProxyDataInfos proxy
8263  * @tc.desc: 1.system run normally
8264  */
8265 HWTEST_F(ActsBmsKitSystemTest, GetProxyDataInfos_0200, Function | SmallTest | Level1)
8266 {
8267     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
8268     ASSERT_NE(bundleMgrProxy, nullptr);
8269     std::vector<ProxyData> proxyDatas;
8270     ErrCode ret = bundleMgrProxy->GetProxyDataInfos(
8271         "", BASE_MODULE_NAME, proxyDatas);
8272     EXPECT_EQ(ret, ERR_BUNDLE_MANAGER_PARAM_ERROR);
8273 }
8274 
8275 /**
8276  * @tc.number: GetAdditionalInfo_0002
8277  * @tc.name: test GetAdditionalInfo proxy
8278  * @tc.desc: 1.system run normally
8279  */
8280 HWTEST_F(ActsBmsKitSystemTest, GetAdditionalInfo_0002, Function | SmallTest | Level1)
8281 {
8282     std::cout << "START GetAdditionalInfo_0002" << std::endl;
8283     std::vector<std::string> resvec;
8284     std::string bundleFilePath = THIRD_BUNDLE_PATH + "bmsThirdBundle1.hap";
8285     std::string appName = BASE_BUNDLE_NAME + "1";
8286     Install(bundleFilePath, InstallFlag::REPLACE_EXISTING, resvec);
8287     CommonTool commonTool;
8288     std::string installResult = commonTool.VectorToStr(resvec);
8289     EXPECT_EQ(installResult, "Success") << "install fail!";
8290     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
8291     ASSERT_NE(bundleMgrProxy, nullptr);
8292 
8293     std::string additionalInfo;
8294     auto ret = bundleMgrProxy->GetAdditionalInfo(appName, additionalInfo);
8295     EXPECT_EQ(ret, ERR_OK);
8296 
8297     resvec.clear();
8298     Uninstall(appName, resvec);
8299     std::string uninstallResult = commonTool.VectorToStr(resvec);
8300     EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!";
8301 
8302     std::cout << "END GetAdditionalInfo_0002" << std::endl;
8303 }
8304 
8305 /**
8306  * @tc.number: GetAdditionalInfo_0003
8307  * @tc.name: test GetAdditionalInfo proxy
8308  * @tc.desc: 1.system run normally
8309  *           2.SetAdditionalInfo and SetSpecifiedDistributionType
8310  */
8311 HWTEST_F(ActsBmsKitSystemTest, GetAdditionalInfo_0003, Function | SmallTest | Level1)
8312 {
8313     std::vector<std::string> resvec;
8314     std::string bundleFilePath = THIRD_BUNDLE_PATH + "bmsThirdBundle1.hap";
8315     std::string appName = BASE_BUNDLE_NAME + "1";
8316     InstallParam installParam;
8317     installParam.userId = USERID;
8318     installParam.installFlag = InstallFlag::REPLACE_EXISTING;
8319     installParam.specifiedDistributionType = "specifiedDistributionType";
8320     installParam.additionalInfo = "additionalInfo";
8321     Install(bundleFilePath, installParam, resvec);
8322     CommonTool commonTool;
8323     std::string installResult = commonTool.VectorToStr(resvec);
8324     EXPECT_EQ(installResult, "Success") << "install fail!";
8325     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
8326     ASSERT_NE(bundleMgrProxy, nullptr);
8327 
8328     std::string additionalInfo;
8329     ErrCode ret = bundleMgrProxy->GetAdditionalInfo(appName, additionalInfo);
8330     EXPECT_EQ(ret, ERR_OK);
8331     EXPECT_EQ(installParam.additionalInfo, additionalInfo);
8332     std::string specifiedDistributionType;
8333     ret = bundleMgrProxy->GetSpecifiedDistributionType(appName, specifiedDistributionType);
8334     EXPECT_EQ(ret, ERR_OK);
8335     EXPECT_EQ(installParam.specifiedDistributionType, specifiedDistributionType);
8336 
8337     resvec.clear();
8338     Uninstall(appName, resvec);
8339     std::string uninstallResult = commonTool.VectorToStr(resvec);
8340     EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!";
8341 }
8342 
8343 /**
8344  * @tc.number: GetAdditionalInfo_0004
8345  * @tc.name: test  GetAdditionalInfo proxy
8346  * @tc.desc: 1.system run normally
8347  *           2.2.SetAdditionalInfo and SetSpecifiedDistributionType
8348  */
8349 HWTEST_F(ActsBmsKitSystemTest, GetAdditionalInfo_0004, Function | SmallTest | Level1)
8350 {
8351     std::vector<std::string> resvec;
8352     std::string bundleFilePath = THIRD_BUNDLE_PATH + "bmsThirdBundle1.hap";
8353     std::string appName = BASE_BUNDLE_NAME + "1";
8354     InstallParam installParam;
8355     installParam.userId = USERID;
8356     installParam.installFlag = InstallFlag::REPLACE_EXISTING;
8357     installParam.specifiedDistributionType = "specifiedDistributionType";
8358     installParam.additionalInfo = "additionalInfo";
8359     Install(bundleFilePath, installParam, resvec);
8360     CommonTool commonTool;
8361     std::string installResult = commonTool.VectorToStr(resvec);
8362     EXPECT_EQ(installResult, "Success") << "install fail!";
8363 
8364     // update hap
8365     installParam.installFlag = InstallFlag::REPLACE_EXISTING;
8366     installParam.additionalInfo = "modify additionalInfo";
8367     resvec.clear();
8368     Install(bundleFilePath, installParam, resvec);
8369     installResult = commonTool.VectorToStr(resvec);
8370     EXPECT_EQ(installResult, "Success") << "install fail!";
8371 
8372     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
8373     ASSERT_NE(bundleMgrProxy, nullptr);
8374     std::string additionalInfo;
8375     ErrCode ret = bundleMgrProxy->GetAdditionalInfo(appName, additionalInfo);
8376     EXPECT_EQ(ret, ERR_OK);
8377     EXPECT_EQ(installParam.additionalInfo, additionalInfo);
8378     std::string specifiedDistributionType;
8379     ret = bundleMgrProxy->GetSpecifiedDistributionType(appName, specifiedDistributionType);
8380     EXPECT_EQ(ret, ERR_OK);
8381     EXPECT_EQ(installParam.specifiedDistributionType, specifiedDistributionType);
8382     resvec.clear();
8383     Uninstall(appName, resvec);
8384     std::string uninstallResult = commonTool.VectorToStr(resvec);
8385     EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!";
8386 }
8387 
8388 /**
8389  * @tc.number: DumpInfos_0001
8390  * @tc.name: test  DumpInfos proxy
8391  * @tc.desc: 1.system run normally
8392  */
8393 HWTEST_F(ActsBmsKitSystemTest, DumpInfos_0001, Function | SmallTest | Level1)
8394 {
8395     std::cout << "START GetAdditionalInfo_0002" << std::endl;
8396     std::vector<std::string> resvec;
8397     std::string bundleFilePath = THIRD_BUNDLE_PATH + "bmsThirdBundle1.hap";
8398     std::string appName = BASE_BUNDLE_NAME + "1";
8399     Install(bundleFilePath, InstallFlag::REPLACE_EXISTING, resvec);
8400     CommonTool commonTool;
8401     std::string installResult = commonTool.VectorToStr(resvec);
8402     EXPECT_EQ(installResult, "Success") << "install fail!";
8403     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
8404     ASSERT_NE(bundleMgrProxy, nullptr);
8405 
8406     std::string result;
8407     auto ret = bundleMgrProxy->DumpInfos(DumpFlag::DUMP_BUNDLE_INFO, appName, USERID, result);
8408     EXPECT_EQ(ret, true);
8409 
8410     resvec.clear();
8411     Uninstall(appName, resvec);
8412     std::string uninstallResult = commonTool.VectorToStr(resvec);
8413     EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!";
8414 
8415     std::cout << "END GetAdditionalInfo_0002" << std::endl;
8416 }
8417 
8418 /**
8419  * @tc.number: GetOverlayManagerProxy_0100
8420  * @tc.name: test GetFormsInfoByModule proxy
8421  * @tc.desc: 1.system run normally
8422  *           2.return true
8423  */
8424 HWTEST_F(ActsBmsKitSystemTest, GetOverlayManagerProxy_0100, Function | SmallTest | Level1)
8425 {
8426     std::vector<std::string> resvec;
8427     std::string bundleFilePath = THIRD_BUNDLE_PATH + "bmsThirdBundle1.hap";
8428     std::string appName = BASE_BUNDLE_NAME + "1";
8429     Install(bundleFilePath, InstallFlag::REPLACE_EXISTING, resvec);
8430     CommonTool commonTool;
8431     std::string installResult = commonTool.VectorToStr(resvec);
8432     EXPECT_EQ(installResult, "Success") << "install fail!";
8433     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
8434     ASSERT_NE(bundleMgrProxy, nullptr);
8435     sptr<IOverlayManager> ret = bundleMgrProxy->GetOverlayManagerProxy();
8436     EXPECT_NE(ret, nullptr);
8437     resvec.clear();
8438     Uninstall(appName, resvec);
8439     std::string uninstallResult = commonTool.VectorToStr(resvec);
8440     EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!";
8441 }
8442 
8443 /**
8444  * @tc.number: QueryAppGalleryBundleName_0100
8445  * @tc.name: test BundleMgr proxy
8446  * @tc.desc: 1.system run normally
8447  *           2.return true
8448  */
8449 HWTEST_F(ActsBmsKitSystemTest, QueryAppGalleryBundleName_0100, Function | SmallTest | Level1)
8450 {
8451     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
8452     ASSERT_NE(bundleMgrProxy, nullptr);
8453     std::string bundleName;
8454     bool ret = bundleMgrProxy->QueryAppGalleryBundleName(bundleName);
8455     #ifdef USE_KIT_STSTEM
8456     EXPECT_TRUE(ret);
8457     #else
8458     EXPECT_FALSE(ret);
8459     #endif
8460 }
8461 
8462 /**
8463  * @tc.number: ResetAOTCompileStatus_0100
8464  * @tc.name: ResetAOTCompileStatus testcase
8465  * @tc.desc: 1.bundleName and moduleName exist, call ResetAOTCompileStatus
8466  *           2.return ERR_OK
8467  */
8468 HWTEST_F(ActsBmsKitSystemTest, ResetAOTCompileStatus_0100, Function | SmallTest | Level1)
8469 {
8470     APP_LOGI("ResetAOTCompileStatus_0100 begin");
8471     // install
8472     std::vector<std::string> resvec;
8473     std::string bundleFilePath = THIRD_BUNDLE_PATH + "bundleClient1.hap";
8474     Install(bundleFilePath, InstallFlag::REPLACE_EXISTING, resvec);
8475     CommonTool commonTool;
8476     std::string installResult = commonTool.VectorToStr(resvec);
8477     EXPECT_EQ(installResult, "Success") << "install fail!";
8478 
8479     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
8480     ASSERT_NE(bundleMgrProxy, nullptr);
8481     std::string bundleName = "com.example.ohosproject.hmservice";
8482     std::string moduleName = "entry_phone";
8483     int32_t triggerMode = 0;
8484 
8485     int32_t originUid = geteuid();
8486     int32_t uid = bundleMgrProxy->GetUidByBundleName(bundleName, USERID);
8487     APP_LOGI("uid : %{public}d", uid);
8488     seteuid(uid);
8489     // success testcase
8490     ErrCode ret = bundleMgrProxy->ResetAOTCompileStatus(bundleName, moduleName, triggerMode);
8491     EXPECT_EQ(ret, ERR_OK);
8492     // moduleName not exist testcase
8493     moduleName = "notExistModuleName";
8494     ret = bundleMgrProxy->ResetAOTCompileStatus(bundleName, moduleName, triggerMode);
8495     EXPECT_EQ(ret, ERR_BUNDLE_MANAGER_MODULE_NOT_EXIST);
8496     seteuid(originUid);
8497     // uninstall
8498     resvec.clear();
8499     Uninstall(bundleName, resvec);
8500     std::string uninstallResult = commonTool.VectorToStr(resvec);
8501     EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!";
8502     APP_LOGI("ResetAOTCompileStatus_0100 end");
8503 }
8504 
8505 /**
8506  * @tc.number: ResetAOTCompileStatus_0200
8507  * @tc.name: failed testcase, invalid param
8508  * @tc.desc: 1.call ResetAOTCompileStatus
8509  *           2.return ERR_BUNDLE_MANAGER_INVALID_PARAMETER
8510  */
8511 HWTEST_F(ActsBmsKitSystemTest, ResetAOTCompileStatus_0200, Function | SmallTest | Level1)
8512 {
8513     APP_LOGI("ResetAOTCompileStatus_0200 begin");
8514     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
8515     ASSERT_NE(bundleMgrProxy, nullptr);
8516 
8517     std::string bundleName = "bundleName";
8518     std::string moduleName = "moduleName";
8519     int32_t triggerMode = 0;
8520 
8521     ErrCode ret = bundleMgrProxy->ResetAOTCompileStatus(EMPTY_STRING, moduleName, triggerMode);
8522     EXPECT_EQ(ret, ERR_BUNDLE_MANAGER_INVALID_PARAMETER);
8523     ret = bundleMgrProxy->ResetAOTCompileStatus(bundleName, EMPTY_STRING, triggerMode);
8524     EXPECT_EQ(ret, ERR_BUNDLE_MANAGER_INVALID_PARAMETER);
8525     APP_LOGI("ResetAOTCompileStatus_0200 end");
8526 }
8527 
8528 /**
8529  * @tc.number: ResetAOTCompileStatus_0300
8530  * @tc.name: failed testcase, invalid calling uid
8531  * @tc.desc: 1.call ResetAOTCompileStatus
8532  *           2.return ERR_BUNDLE_MANAGER_PERMISSION_DENIED
8533  */
8534 HWTEST_F(ActsBmsKitSystemTest, ResetAOTCompileStatus_0300, Function | SmallTest | Level1)
8535 {
8536     APP_LOGI("ResetAOTCompileStatus_0300 begin");
8537     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
8538     ASSERT_NE(bundleMgrProxy, nullptr);
8539 
8540     std::string bundleName = "bundleName";
8541     std::string moduleName = "moduleName";
8542     int32_t triggerMode = 0;
8543     ErrCode ret = bundleMgrProxy->ResetAOTCompileStatus(bundleName, moduleName, triggerMode);
8544     EXPECT_EQ(ret, ERR_BUNDLE_MANAGER_PERMISSION_DENIED);
8545 
8546     int32_t originUid = geteuid();
8547     int32_t invalidUid = 1234567;
8548     seteuid(invalidUid);
8549 
8550     ret = bundleMgrProxy->ResetAOTCompileStatus(bundleName, moduleName, triggerMode);
8551     EXPECT_EQ(ret, ERR_BUNDLE_MANAGER_PERMISSION_DENIED);
8552     seteuid(originUid);
8553     APP_LOGI("ResetAOTCompileStatus_0300 end");
8554 }
8555 
8556 /**
8557  * @tc.number: GetJsonProfile_0100
8558  * @tc.name: test BundleMgrProxy
8559  * @tc.desc: 1.call GetJsonProfile
8560  *           2.return ERR_BUNDLE_MANAGER_PARAM_ERROR
8561  */
8562 HWTEST_F(ActsBmsKitSystemTest, GetJsonProfile_0100, Function | SmallTest | Level1)
8563 {
8564     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
8565     ASSERT_NE(bundleMgrProxy, nullptr);
8566 
8567     std::string profile;
8568     ErrCode ret = bundleMgrProxy->GetJsonProfile(ProfileType::INTENT_PROFILE, "", BASE_MODULE_NAME, profile);
8569     EXPECT_EQ(ret, ERR_BUNDLE_MANAGER_PARAM_ERROR);
8570 }
8571 
8572 /**
8573  * @tc.number: GetJsonProfile_0200
8574  * @tc.name: test BundleMgrProxy
8575  * @tc.desc: 1.call GetJsonProfile
8576  *           2.return ERR_APPEXECFWK_PARCEL_ERROR
8577  */
8578 HWTEST_F(ActsBmsKitSystemTest, GetJsonProfile_0200, Function | SmallTest | Level1)
8579 {
8580     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
8581     ASSERT_NE(bundleMgrProxy, nullptr);
8582 
8583     std::string profile;
8584     ErrCode ret = bundleMgrProxy->GetJsonProfile(
8585         ProfileType::INTENT_PROFILE, BASE_BUNDLE_NAME, BASE_MODULE_NAME, profile);
8586     EXPECT_EQ(ret, ERR_BUNDLE_MANAGER_BUNDLE_NOT_EXIST);
8587 }
8588 
8589 /**
8590  * @tc.number: QueryExtensionAbilityInfosWithTypeName_0100
8591  * @tc.name: test BundleMgrProxy
8592  * @tc.desc: 1.call QueryExtensionAbilityInfosWithTypeName
8593  *           2.return ERR_APPEXECFWK_PARCEL_ERROR
8594  */
8595 HWTEST_F(ActsBmsKitSystemTest, QueryExtensionAbilityInfosWithTypeName_0100, Function | SmallTest | Level1)
8596 {
8597     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
8598     ASSERT_NE(bundleMgrProxy, nullptr);
8599 
8600     Want want;
8601     int32_t flag = 0;
8602     std::vector<ExtensionAbilityInfo> extensionInfos;
8603     ErrCode ret = bundleMgrProxy->QueryExtensionAbilityInfosWithTypeName(want, "", flag, USERID, extensionInfos);
8604     EXPECT_EQ(ret, ERR_BUNDLE_MANAGER_ABILITY_NOT_EXIST);
8605 }
8606 
8607 /**
8608  * @tc.number: GetBundleResourceInfo_0001
8609  * @tc.name: test BundleMgrProxy
8610  * @tc.desc: 1.call GetBundleResourceInfo
8611  */
8612 HWTEST_F(ActsBmsKitSystemTest, GetBundleResourceInfo_0001, Function | SmallTest | Level1)
8613 {
8614     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
8615     EXPECT_NE(bundleMgrProxy, nullptr);
8616     if (bundleMgrProxy != nullptr) {
8617         auto proxy = bundleMgrProxy->GetBundleResourceProxy();
8618         EXPECT_NE(proxy, nullptr);
8619         if (proxy != nullptr) {
8620             BundleResourceInfo info;
8621             ErrCode ret = proxy->GetBundleResourceInfo(EMPTY_BUNDLE_NAME,
8622                 static_cast<uint32_t>(ResourceFlag::GET_RESOURCE_INFO_ALL), info);
8623             EXPECT_EQ(ret, ERR_BUNDLE_MANAGER_PARAM_ERROR);
8624             ret = proxy->GetBundleResourceInfo(BASE_MODULE_NAME,
8625                 static_cast<uint32_t>(ResourceFlag::GET_RESOURCE_INFO_ALL), info);
8626             EXPECT_EQ(ret, ERR_BUNDLE_MANAGER_PERMISSION_DENIED);
8627         }
8628     }
8629 }
8630 
8631 /**
8632  * @tc.number: GetLauncherAbilityResourceInfo_0001
8633  * @tc.name: test BundleMgrProxy
8634  * @tc.desc: 1.call GetLauncherAbilityResourceInfo
8635  */
8636 HWTEST_F(ActsBmsKitSystemTest, GetLauncherAbilityResourceInfo_0001, Function | SmallTest | Level1)
8637 {
8638     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
8639     EXPECT_NE(bundleMgrProxy, nullptr);
8640     if (bundleMgrProxy != nullptr) {
8641         auto proxy = bundleMgrProxy->GetBundleResourceProxy();
8642         EXPECT_NE(proxy, nullptr);
8643         if (proxy != nullptr) {
8644             std::vector<LauncherAbilityResourceInfo> infos;
8645             ErrCode ret = proxy->GetLauncherAbilityResourceInfo(EMPTY_BUNDLE_NAME,
8646                 static_cast<uint32_t>(ResourceFlag::GET_RESOURCE_INFO_ALL), infos);
8647             EXPECT_EQ(ret, ERR_BUNDLE_MANAGER_PARAM_ERROR);
8648             ret = proxy->GetLauncherAbilityResourceInfo(BASE_MODULE_NAME,
8649                 static_cast<uint32_t>(ResourceFlag::GET_RESOURCE_INFO_ALL), infos);
8650             EXPECT_EQ(ret, ERR_BUNDLE_MANAGER_PERMISSION_DENIED);
8651         }
8652     }
8653 }
8654 
8655 /**
8656  * @tc.number: GetAllBundleResourceInfo_0001
8657  * @tc.name: test BundleMgrProxy
8658  * @tc.desc: 1.call GetAllBundleResourceInfo
8659  */
8660 HWTEST_F(ActsBmsKitSystemTest, GetAllBundleResourceInfo_0001, Function | SmallTest | Level1)
8661 {
8662     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
8663     EXPECT_NE(bundleMgrProxy, nullptr);
8664     if (bundleMgrProxy != nullptr) {
8665         auto proxy = bundleMgrProxy->GetBundleResourceProxy();
8666         EXPECT_NE(proxy, nullptr);
8667         if (proxy != nullptr) {
8668             std::vector<BundleResourceInfo> info;
8669             ErrCode ret = proxy->GetAllBundleResourceInfo(
8670                 static_cast<uint32_t>(ResourceFlag::GET_RESOURCE_INFO_ALL), info);
8671             EXPECT_EQ(ret, ERR_BUNDLE_MANAGER_PERMISSION_DENIED);
8672         }
8673     }
8674 }
8675 
8676 /**
8677  * @tc.number: GetAllLauncherAbilityResourceInfo_0001
8678  * @tc.name: test BundleMgrProxy
8679  * @tc.desc: 1.call GetALLLauncherAbilityResourceInfo
8680  */
8681 HWTEST_F(ActsBmsKitSystemTest, GetAllLauncherAbilityResourceInfo_0001, Function | SmallTest | Level1)
8682 {
8683     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
8684     EXPECT_NE(bundleMgrProxy, nullptr);
8685     if (bundleMgrProxy != nullptr) {
8686         auto proxy = bundleMgrProxy->GetBundleResourceProxy();
8687         EXPECT_NE(proxy, nullptr);
8688         if (proxy != nullptr) {
8689             std::vector<LauncherAbilityResourceInfo> infos;
8690             ErrCode ret = proxy->GetAllLauncherAbilityResourceInfo(
8691                 static_cast<uint32_t>(ResourceFlag::GET_RESOURCE_INFO_ALL), infos);
8692             EXPECT_EQ(ret, ERR_BUNDLE_MANAGER_PERMISSION_DENIED);
8693         }
8694     }
8695 }
8696 
8697 /**
8698  * @tc.number: SendRequest_0001
8699  * @tc.name: test BundleMgrProxy
8700  * @tc.desc: 1.call SendRequest
8701  */
8702 HWTEST_F(ActsBmsKitSystemTest, SendRequest_0001, Function | SmallTest | Level1)
8703 {
8704     sptr<IRemoteObject> object;
8705     BundleResourceProxy resourceProxy(object);
8706     MessageParcel data;
8707     MessageParcel reply;
8708     bool ret = resourceProxy.SendRequest(BundleResourceInterfaceCode::GET_BUNDLE_RESOURCE_INFO, data, reply);
8709     EXPECT_FALSE(ret);
8710 }
8711 
8712 /**
8713  * @tc.number: GetDefaultAppProxy_0200
8714  * @tc.name: test GetDefaultAppProxy proxy
8715  * @tc.desc: 1.system run normally
8716  */
8717 HWTEST_F(ActsBmsKitSystemTest, GetDefaultAppProxy_0200, Function | SmallTest | Level1)
8718 {
8719     StartProcess();
8720     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
8721     ASSERT_NE(bundleMgrProxy, nullptr);
8722     sptr<IDefaultApp> getDefaultAppProxy = bundleMgrProxy->GetDefaultAppProxy();
8723     AAFwk::Want want;
8724     ElementName elementName(
8725         "", DEFAULT_APP_BUNDLE_NAME, DEFAULT_APP_MODULE_NAME, DEFAULT_APP_VIDEO);
8726     want.SetElement(elementName);
8727     ErrCode res = getDefaultAppProxy->SetDefaultApplication(USERID, DEFAULT_APP_VIDEO, want);
8728     EXPECT_NE(res, ERR_OK);
8729     BundleInfo bundleInfo;
8730     res = getDefaultAppProxy->GetDefaultApplication(USERID, DEFAULT_APP_VIDEO, bundleInfo);
8731     EXPECT_NE(res, ERR_OK);
8732     res = getDefaultAppProxy->ResetDefaultApplication(USERID, DEFAULT_APP_VIDEO);
8733     EXPECT_EQ(res, ERR_OK);
8734 }
8735 
8736 /**
8737  * @tc.number: GetApplicationInfos_0200
8738  * @tc.name: test query applicationinfos
8739  * @tc.desc: 1.under '/data/test/bms_bundle',there exist three bundles
8740  *           2.install these bundles
8741  *           3.query all appinfos
8742  */
8743 HWTEST_F(ActsBmsKitSystemTest, GetApplicationInfosV9_0200, Function | MediumTest | Level1)
8744 {
8745     std::cout << "START GetApplicationInfosV9_0200" << std::endl;
8746     CommonTool commonTool;
8747     std::string installResult;
8748     for (int i = 6; i < 9; i++) {
8749         std::vector<std::string> resvec;
8750         std::string hapFilePath = THIRD_BUNDLE_PATH + "bmsThirdBundle" + std::to_string(i) + ".hap";
8751         Install(hapFilePath, InstallFlag::REPLACE_EXISTING, resvec);
8752         installResult = commonTool.VectorToStr(resvec);
8753         EXPECT_EQ(installResult, "Success") << "install fail!";
8754     }
8755     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
8756     ASSERT_NE(bundleMgrProxy, nullptr);
8757 
8758     std::vector<ApplicationInfo> appInfos;
8759     auto getInfoResult = bundleMgrProxy->GetApplicationInfosV9(
8760         static_cast<int32_t>(GetApplicationFlag::GET_APPLICATION_INFO_DEFAULT), USERID, appInfos);
8761     EXPECT_EQ(getInfoResult, ERR_OK);
8762 
8763     bool isSubStrExist = false;
8764     for (int i = 1; i <= 3; i++) {
8765         std::string appName = BASE_BUNDLE_NAME + std::to_string(i);
8766         for (auto iter = appInfos.begin(); iter != appInfos.end(); iter++) {
8767             if (IsSubStr(iter->name, appName)) {
8768                 isSubStrExist = true;
8769                 break;
8770             }
8771         }
8772         EXPECT_TRUE(isSubStrExist);
8773         std::vector<std::string> resvec2;
8774         Uninstall(appName, resvec2);
8775         std::string uninstallResult = commonTool.VectorToStr(resvec2);
8776         EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!";
8777     }
8778     std::cout << "END GetApplicationInfosV9_0200" << std::endl;
8779 }
8780 
8781 /**
8782  * @tc.number: GetApplicationInfos_0300
8783  * @tc.name: test query applicationinfos
8784  * @tc.desc: 1.under '/data/test/bms_bundle',there exist three bundles
8785  *           2.install these bundles
8786  *           3.query all disabled appinfos
8787  */
8788 HWTEST_F(ActsBmsKitSystemTest, GetApplicationInfosV9_0300, Function | MediumTest | Level1)
8789 {
8790     std::cout << "START GetApplicationInfosV9_0300" << std::endl;
8791     CommonTool commonTool;
8792     std::string installResult;
8793     for (int i = 6; i < 9; i++) {
8794         std::vector<std::string> resvec;
8795         std::string hapFilePath = THIRD_BUNDLE_PATH + "bmsThirdBundle" + std::to_string(i) + ".hap";
8796         Install(hapFilePath, InstallFlag::REPLACE_EXISTING, resvec);
8797         installResult = commonTool.VectorToStr(resvec);
8798         EXPECT_EQ(installResult, "Success") << "install fail!";
8799     }
8800     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
8801     ASSERT_NE(bundleMgrProxy, nullptr);
8802 
8803     for (int i = 1; i <= 3; i++) {
8804         std::string appName = BASE_BUNDLE_NAME + std::to_string(i);
8805         auto setAppResult = bundleMgrProxy->SetApplicationEnabled(appName, false, USERID);
8806         EXPECT_EQ(setAppResult, ERR_OK);
8807     }
8808     std::vector<ApplicationInfo> appInfos;
8809     auto getInfoResult = bundleMgrProxy->GetApplicationInfosV9(
8810         static_cast<int32_t>(GetApplicationFlag::GET_APPLICATION_INFO_WITH_DISABLE), USERID, appInfos);
8811     EXPECT_EQ(getInfoResult, ERR_OK);
8812 
8813     bool isSubStrExist = false;
8814     for (int i = 1; i <= 3; i++) {
8815         std::string appName = BASE_BUNDLE_NAME + std::to_string(i);
8816         for (auto iter = appInfos.begin(); iter != appInfos.end(); iter++) {
8817             if (IsSubStr(iter->name, appName)) {
8818                 isSubStrExist = true;
8819                 break;
8820             }
8821         }
8822         EXPECT_TRUE(isSubStrExist);
8823         std::vector<std::string> resvec2;
8824         Uninstall(appName, resvec2);
8825         std::string uninstallResult = commonTool.VectorToStr(resvec2);
8826         EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!";
8827     }
8828     std::cout << "END GetApplicationInfosV9_0300" << std::endl;
8829 }
8830 
8831 /**
8832  * @tc.number: CanOpenLink_0001
8833  * @tc.name: test CanOpenLink interface
8834  * @tc.desc: 1.under '/data/test/bms_bundle',there is a hap
8835  *           2.install the app
8836  *           3.call CanOpenLink
8837  */
8838 HWTEST_F(ActsBmsKitSystemTest, CanOpenLink_0001, Function | MediumTest | Level1)
8839 {
8840     std::cout << "START CanOpenLink_0001" << std::endl;
8841     std::vector<std::string> resvec;
8842     std::string bundleFilePath = THIRD_BUNDLE_PATH + "bundleClient1.hap";
8843     std::string appName = "com.example.ohosproject.hmservice";
8844     Install(bundleFilePath, InstallFlag::REPLACE_EXISTING, resvec);
8845     CommonTool commonTool;
8846     std::string installResult = commonTool.VectorToStr(resvec);
8847     EXPECT_EQ(installResult, "Success") << "install fail!";
8848 
8849     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
8850     ASSERT_NE(bundleMgrProxy, nullptr);
8851 
8852     BundleInfo bundleInfo;
8853     bundleMgrProxy->GetBundleInfo(appName, BundleFlag::GET_BUNDLE_DEFAULT, bundleInfo, USERID);
8854     setuid(bundleInfo.uid);
8855 
8856     std::string link = "http://";
8857     bool canOpen = false;
8858     auto queryResult =
8859         bundleMgrProxy->CanOpenLink(link, canOpen);
8860 
8861     setuid(Constants::ROOT_UID);
8862 
8863     EXPECT_EQ(queryResult, ERR_OK);
8864     EXPECT_TRUE(canOpen);
8865 
8866     resvec.clear();
8867     Uninstall(appName, resvec);
8868     std::string uninstallResult = commonTool.VectorToStr(resvec);
8869     EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!";
8870 
8871     std::cout << "END CanOpenLink_0001" << std::endl;
8872 }
8873 
8874 /**
8875  * @tc.number: CanOpenLink_0002
8876  * @tc.name: test CanOpenLink interface
8877  * @tc.desc: 1.under '/data/test/bms_bundle',there is a hap
8878  *           2.install the app
8879  *           3.call CanOpenLink
8880  */
8881 HWTEST_F(ActsBmsKitSystemTest, CanOpenLink_0002, Function | MediumTest | Level1)
8882 {
8883     std::cout << "START CanOpenLink_0002" << std::endl;
8884     std::vector<std::string> resvec;
8885     std::string bundleFilePath = THIRD_BUNDLE_PATH + "bundleClient1.hap";
8886     std::string appName = "com.example.ohosproject.hmservice";
8887     Install(bundleFilePath, InstallFlag::REPLACE_EXISTING, resvec);
8888     CommonTool commonTool;
8889     std::string installResult = commonTool.VectorToStr(resvec);
8890     EXPECT_EQ(installResult, "Success") << "install fail!";
8891 
8892     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
8893     ASSERT_NE(bundleMgrProxy, nullptr);
8894 
8895     BundleInfo bundleInfo;
8896     bundleMgrProxy->GetBundleInfo(appName, BundleFlag::GET_BUNDLE_DEFAULT, bundleInfo, USERID);
8897     setuid(bundleInfo.uid);
8898 
8899     std::string link = "welink://";
8900     bool canOpen = false;
8901     auto queryResult =
8902         bundleMgrProxy->CanOpenLink(link, canOpen);
8903 
8904     setuid(Constants::ROOT_UID);
8905 
8906     EXPECT_EQ(queryResult, ERR_OK);
8907     EXPECT_FALSE(canOpen);
8908 
8909     resvec.clear();
8910     Uninstall(appName, resvec);
8911     std::string uninstallResult = commonTool.VectorToStr(resvec);
8912     EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!";
8913 
8914     std::cout << "END CanOpenLink_0002" << std::endl;
8915 }
8916 
8917 /**
8918  * @tc.number: CanOpenLink_0003
8919  * @tc.name: test CanOpenLink interface
8920  * @tc.desc: 1.under '/data/test/bms_bundle',there is a hap
8921  *           2.install the app
8922  *           3.call CanOpenLink
8923  */
8924 HWTEST_F(ActsBmsKitSystemTest, CanOpenLink_0003, Function | MediumTest | Level1)
8925 {
8926     std::cout << "START CanOpenLink_0003" << std::endl;
8927     std::vector<std::string> resvec;
8928     std::string bundleFilePath = THIRD_BUNDLE_PATH + "bundleClient1.hap";
8929     std::string appName = "com.example.ohosproject.hmservice";
8930     Install(bundleFilePath, InstallFlag::REPLACE_EXISTING, resvec);
8931     CommonTool commonTool;
8932     std::string installResult = commonTool.VectorToStr(resvec);
8933     EXPECT_EQ(installResult, "Success") << "install fail!";
8934 
8935     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
8936     ASSERT_NE(bundleMgrProxy, nullptr);
8937 
8938     BundleInfo bundleInfo;
8939     bundleMgrProxy->GetBundleInfo(appName, BundleFlag::GET_BUNDLE_DEFAULT, bundleInfo, USERID);
8940     setuid(bundleInfo.uid);
8941 
8942     std::string link = "https://";
8943     bool canOpen = false;
8944     auto queryResult =
8945         bundleMgrProxy->CanOpenLink(link, canOpen);
8946 
8947     setuid(Constants::ROOT_UID);
8948 
8949     EXPECT_NE(queryResult, ERR_OK);
8950     EXPECT_FALSE(canOpen);
8951 
8952     resvec.clear();
8953     Uninstall(appName, resvec);
8954     std::string uninstallResult = commonTool.VectorToStr(resvec);
8955     EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!";
8956 
8957     std::cout << "END CanOpenLink_0003" << std::endl;
8958 }
8959 
8960 /**
8961  * @tc.number: GetOdid_0001
8962  * @tc.name: test GetOdid interface
8963  * @tc.desc: 1.under '/data/test/bms_bundle',there is a hap
8964  *           2.install the app
8965  *           3.call GetOdid
8966  */
8967 HWTEST_F(ActsBmsKitSystemTest, GetOdid_0001, Function | MediumTest | Level1)
8968 {
8969     std::cout << "START GetOdid_0001" << std::endl;
8970     std::vector<std::string> resvec;
8971     std::string bundleFilePath = THIRD_BUNDLE_PATH + "bundleClient1.hap";
8972     std::string appName = "com.example.ohosproject.hmservice";
8973     Install(bundleFilePath, InstallFlag::REPLACE_EXISTING, resvec);
8974     CommonTool commonTool;
8975     std::string installResult = commonTool.VectorToStr(resvec);
8976     EXPECT_EQ(installResult, "Success") << "install fail!";
8977 
8978     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
8979     ASSERT_NE(bundleMgrProxy, nullptr);
8980 
8981     BundleInfo bundleInfo;
8982     bundleMgrProxy->GetBundleInfo(appName, BundleFlag::GET_BUNDLE_DEFAULT, bundleInfo, USERID);
8983 
8984     setuid(bundleInfo.uid);
8985     std::string odid;
8986     auto queryResult = bundleMgrProxy->GetOdid(odid);
8987     setuid(Constants::ROOT_UID);
8988 
8989     EXPECT_EQ(queryResult, ERR_OK);
8990     EXPECT_EQ(odid.size(), ODID_LENGTH);
8991 
8992     resvec.clear();
8993     Uninstall(appName, resvec);
8994     std::string uninstallResult = commonTool.VectorToStr(resvec);
8995     EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!";
8996 
8997     std::cout << "END GetOdid_0001" << std::endl;
8998 }
8999 
9000 /**
9001  * @tc.number: GetOdid_0002
9002  * @tc.name: test GetOdid interface
9003  * @tc.desc: GetOdid failed for calling uid is invalid
9004  */
9005 HWTEST_F(ActsBmsKitSystemTest, GetOdid_0002, Function | MediumTest | Level1)
9006 {
9007     std::cout << "START GetOdid_0002" << std::endl;
9008     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
9009     ASSERT_NE(bundleMgrProxy, nullptr);
9010 
9011     std::string odid;
9012     auto queryResult = bundleMgrProxy->GetOdid(odid);
9013 
9014     EXPECT_NE(queryResult, ERR_OK);
9015     EXPECT_TRUE(odid.empty());
9016 
9017     std::cout << "END GetOdid_0002" << std::endl;
9018 }
9019 
9020 /**
9021  * @tc.number: AppControlCache_0001
9022  * @tc.name: test app control cache
9023  * @tc.desc: test app control cache
9024  */
9025 HWTEST_F(ActsBmsKitSystemTest, AppControlCache_0001, Function | MediumTest | Level1)
9026 {
9027     std::cout << "START AppControlCache_0001" << std::endl;
9028     std::vector<std::string> resvec;
9029     std::string bundleFilePath = THIRD_BUNDLE_PATH + "bmsThirdBundle24.hap";
9030     std::string appName = BASE_BUNDLE_NAME + "1";
9031     Install(bundleFilePath, InstallFlag::REPLACE_EXISTING, resvec);
9032     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
9033     sptr<IAppControlMgr> appControlProxy = bundleMgrProxy->GetAppControlProxy();
9034     setuid(3057);
9035     std::vector<AppRunningControlRule> controlRules;
9036     AppRunningControlRule controlRule;
9037     controlRule.appId = APPID;
9038     controlRule.controlMessage = CONTROL_MESSAGE;
9039     controlRules.emplace_back(controlRule);
9040     ErrCode res = appControlProxy->AddAppRunningControlRule(controlRules, USERID);
9041     EXPECT_EQ(res, ERR_OK);
9042     setuid(5523);
9043     AppRunningControlRuleResult controlRuleResult;
9044     res = appControlProxy->GetAppRunningControlRule(appName, USERID, controlRuleResult);
9045     EXPECT_EQ(res, ERR_OK);
9046     EXPECT_EQ(controlRuleResult.controlMessage, CONTROL_MESSAGE);
9047     setuid(3057);
9048     res = appControlProxy->DeleteAppRunningControlRule(USERID);
9049     EXPECT_EQ(res, ERR_OK);
9050     setuid(5523);
9051     AppRunningControlRuleResult controlRuleResult2;
9052     res = appControlProxy->GetAppRunningControlRule(appName, USERID, controlRuleResult2);
9053     EXPECT_EQ(res, ERR_BUNDLE_MANAGER_BUNDLE_NOT_SET_CONTROL);
9054     EXPECT_EQ(controlRuleResult2.controlMessage, "");
9055     Uninstall(appName, resvec);
9056     std::cout << "END AppControlCache_0001" << std::endl;
9057 }
9058 
9059 /**
9060  * @tc.number: SwitchUninstallState_0001
9061  * @tc.name: test SwitchUninstallState interface
9062  * @tc.desc: 1.under '/data/test/bms_bundle',there is a hap
9063  *           2.install the app
9064  *           3.call SwitchUninstallState
9065  */
9066 HWTEST_F(ActsBmsKitSystemTest, SwitchUninstallState_0001, Function | MediumTest | Level1)
9067 {
9068     std::cout << "START SwitchUninstallState_0001" << std::endl;
9069     std::vector<std::string> resvec;
9070     std::string bundleFilePath = THIRD_BUNDLE_PATH + "bundleClient1.hap";
9071     std::string appName = "com.example.ohosproject.hmservice";
9072     Install(bundleFilePath, InstallFlag::REPLACE_EXISTING, resvec);
9073     CommonTool commonTool;
9074     std::string installResult = commonTool.VectorToStr(resvec);
9075     EXPECT_EQ(installResult, "Success") << "install fail!";
9076 
9077     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
9078     ASSERT_NE(bundleMgrProxy, nullptr);
9079 
9080     auto queryResult = bundleMgrProxy->SwitchUninstallState(appName, false);
9081     EXPECT_EQ(queryResult, ERR_OK);
9082 
9083     resvec.clear();
9084     Uninstall(appName, resvec);
9085     std::string uninstallResult = commonTool.VectorToStr(resvec);
9086     EXPECT_NE(uninstallResult, "Success");
9087 
9088     queryResult = bundleMgrProxy->SwitchUninstallState(appName, true);
9089     EXPECT_EQ(queryResult, ERR_OK);
9090 
9091     resvec.clear();
9092     Uninstall(appName, resvec);
9093     uninstallResult = commonTool.VectorToStr(resvec);
9094     EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!";
9095 
9096     std::cout << "END SwitchUninstallState_0001" << std::endl;
9097 }
9098 
9099 /**
9100  * @tc.number: SwitchUninstallState_0002
9101  * @tc.name: test SwitchUninstallState interface
9102  * @tc.desc: SwitchUninstallState failed for bundleName is empty
9103  */
9104 HWTEST_F(ActsBmsKitSystemTest, SwitchUninstallState_0002, Function | MediumTest | Level1)
9105 {
9106     std::cout << "START SwitchUninstallState_0002" << std::endl;
9107     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
9108     ASSERT_NE(bundleMgrProxy, nullptr);
9109 
9110     auto queryResult = bundleMgrProxy->SwitchUninstallState("", false);
9111     EXPECT_NE(queryResult, ERR_OK);
9112 
9113     std::cout << "END SwitchUninstallState_0002" << std::endl;
9114 }
9115 
9116 /**
9117  * @tc.number: QueryAbilityInfoByContinueType_0001
9118  * @tc.name: test query ability information
9119  * @tc.desc: 1.under '/data/test/bms_bundle',there is a hap
9120  *           2.install the hap
9121  *           3.get ability successfully
9122  */
9123 HWTEST_F(ActsBmsKitSystemTest, QueryAbilityInfoByContinueType_0001, Function | MediumTest | Level1)
9124 {
9125     std::cout << "START QueryAbilityInfoByContinueType_0001" << std::endl;
9126     std::vector<std::string> resvec;
9127     std::string bundleFilePath = THIRD_BUNDLE_PATH + "bundleClient1.hap";
9128     std::string appName = "com.example.ohosproject.hmservice";
9129     Install(bundleFilePath, InstallFlag::REPLACE_EXISTING, resvec);
9130     CommonTool commonTool;
9131     std::string installResult = commonTool.VectorToStr(resvec);
9132     EXPECT_EQ(installResult, "Success") << "install fail!";
9133     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
9134     ASSERT_NE(bundleMgrProxy, nullptr);
9135 
9136     std::string continueType = "BROWSER";
9137     AbilityInfo abilityInfo;
9138     auto getInfoResult = bundleMgrProxy->QueryAbilityInfoByContinueType(appName, continueType, abilityInfo, USERID);
9139     EXPECT_EQ(getInfoResult, ERR_OK);
9140     EXPECT_EQ(abilityInfo.bundleName, appName);
9141     EXPECT_EQ(abilityInfo.continueType[0], continueType);
9142     resvec.clear();
9143     Uninstall(appName, resvec);
9144     std::string uninstallResult = commonTool.VectorToStr(resvec);
9145     EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!";
9146 
9147     std::cout << "END QueryAbilityInfoByContinueType_0001" << std::endl;
9148 }
9149 
9150 /**
9151  * @tc.number: QueryAbilityInfoByContinueType_0002
9152  * @tc.name: test query ability information
9153  * @tc.desc: 1.under '/data/test/bms_bundle',there is a hap
9154  *           2.install the hap
9155  *           3.get ability failed
9156  */
9157 HWTEST_F(ActsBmsKitSystemTest, QueryAbilityInfoByContinueType_0002, Function | MediumTest | Level1)
9158 {
9159     std::cout << "START QueryAbilityInfoByContinueType_0002" << std::endl;
9160     std::vector<std::string> resvec;
9161     std::string bundleFilePath = THIRD_BUNDLE_PATH + "bundleClient1.hap";
9162     std::string appName = "com.example.ohosproject.hmservice";
9163     Install(bundleFilePath, InstallFlag::REPLACE_EXISTING, resvec);
9164     CommonTool commonTool;
9165     std::string installResult = commonTool.VectorToStr(resvec);
9166     EXPECT_EQ(installResult, "Success") << "install fail!";
9167     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
9168     ASSERT_NE(bundleMgrProxy, nullptr);
9169 
9170     std::string continueType = "BROWSER1";
9171     AbilityInfo abilityInfo;
9172     auto getInfoResult = bundleMgrProxy->QueryAbilityInfoByContinueType(appName, continueType, abilityInfo, USERID);
9173     EXPECT_EQ(getInfoResult, ERR_BUNDLE_MANAGER_ABILITY_NOT_EXIST);
9174     resvec.clear();
9175     Uninstall(appName, resvec);
9176     std::string uninstallResult = commonTool.VectorToStr(resvec);
9177     EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!";
9178 
9179     std::cout << "END QueryAbilityInfoByContinueType_0002" << std::endl;
9180 }
9181 
9182 /**
9183  * @tc.number: QueryAbilityInfoByContinueType_0003
9184  * @tc.name: test query ability information
9185  * @tc.desc: 1.under '/data/test/bms_bundle',there is a hap
9186  *           2.install the hap
9187  *           3.get ability failed
9188  */
9189 HWTEST_F(ActsBmsKitSystemTest, QueryAbilityInfoByContinueType_0003, Function | MediumTest | Level1)
9190 {
9191     std::cout << "START QueryAbilityInfoByContinueType_0003" << std::endl;
9192     std::vector<std::string> resvec;
9193     std::string bundleFilePath = THIRD_BUNDLE_PATH + "bundleClient1.hap";
9194     std::string appName = "com.example.ohosproject.hmservice";
9195     Install(bundleFilePath, InstallFlag::REPLACE_EXISTING, resvec);
9196     CommonTool commonTool;
9197     std::string installResult = commonTool.VectorToStr(resvec);
9198     EXPECT_EQ(installResult, "Success") << "install fail!";
9199     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
9200     ASSERT_NE(bundleMgrProxy, nullptr);
9201 
9202     std::string continueType = "BROWSER";
9203     AbilityInfo abilityInfo;
9204     auto getInfoResult = bundleMgrProxy->QueryAbilityInfoByContinueType(appName, continueType, abilityInfo, 110);
9205     EXPECT_EQ(getInfoResult, ERR_BUNDLE_MANAGER_INVALID_USER_ID);
9206     resvec.clear();
9207     Uninstall(appName, resvec);
9208     std::string uninstallResult = commonTool.VectorToStr(resvec);
9209     EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!";
9210 
9211     std::cout << "END QueryAbilityInfoByContinueType_0003" << std::endl;
9212 }
9213 
9214 /**
9215  * @tc.number: QueryAbilityInfoByContinueType_0004
9216  * @tc.name: test query ability information
9217  * @tc.desc: 1.under '/data/test/bms_bundle',there is a hap
9218  *           2.install the hap
9219  *           3.get ability failed
9220  */
9221 HWTEST_F(ActsBmsKitSystemTest, QueryAbilityInfoByContinueType_0004, Function | MediumTest | Level1)
9222 {
9223     std::cout << "START QueryAbilityInfoByContinueType_0004" << std::endl;
9224     std::vector<std::string> resvec;
9225     std::string bundleFilePath = THIRD_BUNDLE_PATH + "bundleClient1.hap";
9226     std::string appName = "com.example.ohosproject.hmservice";
9227     Install(bundleFilePath, InstallFlag::REPLACE_EXISTING, resvec);
9228     CommonTool commonTool;
9229     std::string installResult = commonTool.VectorToStr(resvec);
9230     EXPECT_EQ(installResult, "Success") << "install fail!";
9231     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
9232     ASSERT_NE(bundleMgrProxy, nullptr);
9233 
9234     std::string continueType = "BROWSER";
9235     AbilityInfo abilityInfo;
9236     auto getInfoResult = bundleMgrProxy->QueryAbilityInfoByContinueType("appName", continueType, abilityInfo, USERID);
9237     EXPECT_EQ(getInfoResult, ERR_BUNDLE_MANAGER_BUNDLE_NOT_EXIST);
9238     resvec.clear();
9239     Uninstall(appName, resvec);
9240     std::string uninstallResult = commonTool.VectorToStr(resvec);
9241     EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!";
9242 
9243     std::cout << "END QueryAbilityInfoByContinueType_0004" << std::endl;
9244 }
9245 
9246 /**
9247  * @tc.number: InstallCloneAppTest001_AppNotExist
9248  * @tc.name: test install clone app failed: app not exists
9249  * @tc.desc: 1.use a invalid bundleName when install clone app
9250  *           2.get the result
9251  */
9252 HWTEST_F(ActsBmsKitSystemTest, InstallCloneAppTest001_AppNotExist, Function | MediumTest | Level1)
9253 {
9254     StartProcess();
9255     sptr<IBundleInstaller> installerProxy = GetInstallerProxy();
9256     if (!installerProxy) {
9257         APP_LOGE("get bundle installer Failure.");
9258         return;
9259     }
9260     const std::string bundleName = "ohos.samples.appnotfound";
9261     const int32_t userId = 100;
9262     int32_t appIndex = TEST_APP_INDEX1;
9263     auto result = installerProxy->InstallCloneApp(bundleName, userId, appIndex);
9264 
9265     EXPECT_TRUE(result == ERR_APPEXECFWK_CLONE_INSTALL_APP_NOT_EXISTED
9266         || result == ERR_APPEXECFWK_PERMISSION_DENIED);
9267 }
9268 
9269 /**
9270  * @tc.number: InstallCloneAppTest002_UserNotFound
9271  * @tc.name: test install clone app failed: user not exists
9272  * @tc.desc: 1.use a userId not in system when install clone app
9273  *           2.get the result
9274  */
9275 HWTEST_F(ActsBmsKitSystemTest, InstallCloneAppTest002_UserNotFound, Function | MediumTest | Level1)
9276 {
9277     sptr<IBundleInstaller> installerProxy = GetInstallerProxy();
9278     if (!installerProxy) {
9279         APP_LOGE("get bundle installer Failure.");
9280         return;
9281     }
9282     const std::string bundleName = "ohos.samples.etsclock";
9283     const int32_t userId = 200; // ensure userId 200 not in system
9284     int32_t appIndex = TEST_APP_INDEX1;
9285     auto result = installerProxy->InstallCloneApp(bundleName, userId, appIndex);
9286     EXPECT_TRUE(result == ERR_APPEXECFWK_CLONE_INSTALL_USER_NOT_EXIST
9287         || result == ERR_APPEXECFWK_PERMISSION_DENIED || result == ERR_APPEXECFWK_CLONE_INSTALL_APP_NOT_EXISTED);
9288 }
9289 
9290 /**
9291  * @tc.number: GetCloneAppIndexes_0001
9292  * @tc.name: test query clone app's indexes
9293  * @tc.desc: 1.under '/data/test/bms_bundle',there is a hap
9294  *           2.install the clone app
9295  *           3.get clone app's indexes
9296  */
9297 HWTEST_F(ActsBmsKitSystemTest, GetCloneAppIndexes_0001, Function | MediumTest | Level1)
9298 {
9299     std::cout << "START GetCloneAppIndexes_0001" << std::endl;
9300     std::vector<std::string> resvec;
9301     std::string bundleFilePath = THIRD_BUNDLE_PATH + "bundleClient1.hap";
9302     std::string appName = "com.example.ohosproject.hmservice";
9303     Install(bundleFilePath, InstallFlag::REPLACE_EXISTING, resvec);
9304     CommonTool commonTool;
9305     std::string installResult = commonTool.VectorToStr(resvec);
9306     EXPECT_EQ(installResult, "Success") << "install fail!";
9307 
9308     int32_t appIndex = TEST_APP_INDEX1;
9309     sptr<IBundleInstaller> installerProxy = GetInstallerProxy();
9310     ASSERT_NE(installerProxy, nullptr);
9311     ErrCode ret = installerProxy->InstallCloneApp(appName, USERID, appIndex);
9312     EXPECT_EQ(ret, ERR_OK);
9313 
9314     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
9315     ASSERT_NE(bundleMgrProxy, nullptr);
9316     std::vector<int32_t> appIndexes;
9317     ret = bundleMgrProxy->GetCloneAppIndexes(appName, appIndexes, USERID);
9318     EXPECT_EQ(ret, ERR_OK) << "GetCloneAppIndexes fail!";
9319     EXPECT_EQ(appIndexes.size(), 1);
9320 
9321     ret = installerProxy->UninstallCloneApp(appName, USERID, appIndex);
9322     EXPECT_EQ(ret, ERR_OK);
9323 
9324     resvec.clear();
9325     Uninstall(appName, resvec);
9326     std::string uninstallResult = commonTool.VectorToStr(resvec);
9327     EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!";
9328 
9329     std::cout << "END GetCloneAppIndexes_0001" << std::endl;
9330 }
9331 
9332 /**
9333  * @tc.number: GetNameAndIndexForUid_0100
9334  * @tc.name: test get name and appIndex by uid
9335  * @tc.desc: 1.get bundleName and appIndex by uid
9336  */
9337 HWTEST_F(ActsBmsKitSystemTest, GetNameAndIndexForUid_0100, Function | MediumTest | Level1)
9338 {
9339     std::cout << "START GetNameAndIndexForUid_0100" << std::endl;
9340     CommonTool commonTool;
9341     std::vector<std::string> resvec;
9342     std::string bundleFilePath = THIRD_BUNDLE_PATH + "bundleClient1.hap";
9343     std::string appName = "com.example.ohosproject.hmservice";
9344     Install(bundleFilePath, InstallFlag::REPLACE_EXISTING, resvec);
9345     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
9346     ASSERT_NE(bundleMgrProxy, nullptr);
9347 
9348     BundleInfo bundleInfo;
9349     bundleMgrProxy->GetBundleInfo(appName, BundleFlag::GET_BUNDLE_DEFAULT, bundleInfo, USERID);
9350 
9351     std::string name;
9352     int32_t testAppIndex = -1;
9353     ErrCode ret = bundleMgrProxy->GetNameAndIndexForUid(bundleInfo.uid, name, testAppIndex);
9354     EXPECT_EQ(ret, ERR_OK);
9355     EXPECT_EQ(name, appName);
9356     EXPECT_EQ(testAppIndex, 0);
9357 
9358     resvec.clear();
9359     Uninstall(appName, resvec);
9360     std::string uninstallResult = commonTool.VectorToStr(resvec);
9361     EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!";
9362     std::cout << "END GetNameAndIndexForUid_0100" << std::endl;
9363 }
9364 
9365 /**
9366  * @tc.number: AddResourceInfoByBundleName_0001
9367  * @tc.name: test BundleResourceProxy
9368  * @tc.desc: 1.call AddResourceInfoByBundleName
9369  */
9370 HWTEST_F(ActsBmsKitSystemTest, AddResourceInfoByBundleName_0001, Function | SmallTest | Level1)
9371 {
9372     APP_LOGD("AddResourceInfoByBundleName_0001 start");
9373     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
9374     EXPECT_NE(bundleMgrProxy, nullptr);
9375     if (bundleMgrProxy != nullptr) {
9376         std::cout << "START AddResourceInfoByBundleName_0001 bundleMgrProxy is null" << std::endl;
9377         auto proxy = bundleMgrProxy->GetBundleResourceProxy();
9378         EXPECT_NE(proxy, nullptr);
9379         if (proxy != nullptr) {
9380             std::cout << "START AddResourceInfoByBundleName_0001 proxy is null" << std::endl;
9381             ErrCode ret = proxy->AddResourceInfoByBundleName(EMPTY_BUNDLE_NAME, USERID);
9382             EXPECT_EQ(ret, ERR_BUNDLE_MANAGER_INVALID_PARAMETER);
9383             ret = proxy->AddResourceInfoByBundleName(BASE_BUNDLE_NAME, -USERID);
9384             EXPECT_EQ(ret, ERR_BUNDLE_MANAGER_INVALID_USER_ID);
9385             ret = proxy->AddResourceInfoByBundleName(BASE_BUNDLE_NAME, USERID);
9386             EXPECT_EQ(ret, ERR_BUNDLE_MANAGER_PERMISSION_DENIED);
9387         } else {
9388             APP_LOGE("AddResourceInfoByBundleName_0001 proxy is null");
9389         }
9390     } else {
9391         APP_LOGE("AddResourceInfoByBundleName_0001 bundleMgrProxy is null");
9392     }
9393     APP_LOGD("AddResourceInfoByBundleName_0001 end");
9394 }
9395 
9396 /**
9397  * @tc.number: AddResourceInfoByAbility_0001
9398  * @tc.name: test BundleResourceProxy
9399  * @tc.desc: 1.call AddResourceInfoByAbility
9400  */
9401 HWTEST_F(ActsBmsKitSystemTest, AddResourceInfoByAbility_0001, Function | SmallTest | Level1)
9402 {
9403     APP_LOGD("AddResourceInfoByAbility_0001 start");
9404     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
9405     EXPECT_NE(bundleMgrProxy, nullptr);
9406     if (bundleMgrProxy != nullptr) {
9407         std::cout << "AddResourceInfoByAbility_0001 bundleMgrProxy is null" << std::endl;
9408         auto proxy = bundleMgrProxy->GetBundleResourceProxy();
9409         EXPECT_NE(proxy, nullptr);
9410         if (proxy != nullptr) {
9411             std::cout << "AddResourceInfoByAbility_0001 proxy is null" << std::endl;
9412             ErrCode ret = proxy->AddResourceInfoByAbility(EMPTY_BUNDLE_NAME, BASE_MODULE_NAME, BASE_ABILITY_NAME,
9413                 USERID);
9414             EXPECT_EQ(ret, ERR_BUNDLE_MANAGER_INVALID_PARAMETER);
9415             ret = proxy->AddResourceInfoByAbility(BASE_BUNDLE_NAME, "", BASE_ABILITY_NAME, USERID);
9416             EXPECT_EQ(ret, ERR_BUNDLE_MANAGER_INVALID_PARAMETER);
9417             ret = proxy->AddResourceInfoByAbility(BASE_BUNDLE_NAME, BASE_MODULE_NAME, "", USERID);
9418             EXPECT_EQ(ret, ERR_BUNDLE_MANAGER_INVALID_PARAMETER);
9419             ret = proxy->AddResourceInfoByAbility(BASE_BUNDLE_NAME, BASE_MODULE_NAME, BASE_ABILITY_NAME, -USERID);
9420             EXPECT_EQ(ret, ERR_BUNDLE_MANAGER_INVALID_USER_ID);
9421             ret = proxy->AddResourceInfoByAbility(BASE_BUNDLE_NAME, BASE_MODULE_NAME, BASE_ABILITY_NAME, USERID);
9422             EXPECT_EQ(ret, ERR_BUNDLE_MANAGER_PERMISSION_DENIED);
9423         } else {
9424             APP_LOGE("AddResourceInfoByAbility_0001 proxy is null");
9425         }
9426     } else {
9427         APP_LOGE("AddResourceInfoByAbility_0001 bundleMgrProxy is null");
9428     }
9429     APP_LOGD("AddResourceInfoByAbility_0001 end");
9430 }
9431 
9432 /**
9433  * @tc.number: DeleteResourceInfo_0001
9434  * @tc.name: test BundleResourceProxy
9435  * @tc.desc: 1.call DeleteResourceInfo
9436  */
9437 HWTEST_F(ActsBmsKitSystemTest, DeleteResourceInfo_0001, Function | SmallTest | Level1)
9438 {
9439     APP_LOGD("DeleteResourceInfo_0001 start");
9440     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
9441     EXPECT_NE(bundleMgrProxy, nullptr);
9442     if (bundleMgrProxy != nullptr) {
9443         auto proxy = bundleMgrProxy->GetBundleResourceProxy();
9444         EXPECT_NE(proxy, nullptr);
9445         if (proxy != nullptr) {
9446             ErrCode ret = proxy->DeleteResourceInfo("");
9447             EXPECT_EQ(ret, ERR_BUNDLE_MANAGER_INVALID_PARAMETER);
9448             ret = proxy->DeleteResourceInfo(BASE_BUNDLE_NAME);
9449             EXPECT_EQ(ret, ERR_BUNDLE_MANAGER_PERMISSION_DENIED);
9450         } else {
9451             APP_LOGE("DeleteResourceInfo_0001 proxy is null");
9452         }
9453     } else {
9454         APP_LOGE("DeleteResourceInfo_0001 bundleMgrProxy is null");
9455     }
9456     APP_LOGD("DeleteResourceInfo_0001 end");
9457 }
9458 
9459 /**
9460  * @tc.number: GetOdidByBundleName_0001
9461  * @tc.name: test GetOdidByBundleName interface
9462  * @tc.desc: 1.under '/data/test/bms_bundle',there is a hap
9463  *           2.install the app
9464  *           3.call GetOdidByBundleName
9465  */
9466 HWTEST_F(ActsBmsKitSystemTest, GetOdidByBundleName_0001, Function | MediumTest | Level1)
9467 {
9468 std::cout << "START GetOdidByBundleName_0001" << std::endl;
9469 std::vector<std::string> resvec;
9470 std::string bundleFilePath = THIRD_BUNDLE_PATH + "bundleClient1.hap";
9471 std::string appName = "com.example.ohosproject.hmservice";
9472 Install(bundleFilePath, InstallFlag::REPLACE_EXISTING, resvec);
9473 CommonTool commonTool;
9474 std::string installResult = commonTool.VectorToStr(resvec);
9475 EXPECT_EQ(installResult, "Success") << "install fail!";
9476 
9477 sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
9478 ASSERT_NE(bundleMgrProxy, nullptr);
9479 
9480 std::string odid;
9481 auto queryResult = bundleMgrProxy->GetOdidByBundleName(appName, odid);
9482 
9483 EXPECT_EQ(queryResult, ERR_OK);
9484 EXPECT_EQ(odid.size(), ODID_LENGTH);
9485 
9486 resvec.clear();
9487 Uninstall(appName, resvec);
9488 std::string uninstallResult = commonTool.VectorToStr(resvec);
9489 EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!";
9490 
9491 std::cout << "END GetOdidByBundleName_0001" << std::endl;
9492 }
9493 
9494 /**
9495  * @tc.number: GetOdidByBundleName_0002
9496  * @tc.name: test GetOdidByBundleName interface
9497  * @tc.desc: GetOdid failed for calling bundle name is invalid
9498  */
9499 HWTEST_F(ActsBmsKitSystemTest, GetOdidByBundleName_0002, Function | MediumTest | Level1)
9500 {
9501 std::cout << "START GetOdidByBundleName_0002" << std::endl;
9502 sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
9503 ASSERT_NE(bundleMgrProxy, nullptr);
9504 
9505 std::string odid;
9506 auto queryResult = bundleMgrProxy->GetOdidByBundleName("", odid);
9507 
9508 EXPECT_NE(queryResult, ERR_OK);
9509 EXPECT_TRUE(odid.empty());
9510 
9511 std::cout << "END GetOdidByBundleName_0002" << std::endl;
9512 }
9513 
9514 /**
9515  * @tc.number: GetCompatibleDeviceType_0001
9516  * @tc.name: test GetCompatibleDeviceType interface
9517  * @tc.desc: 1.under '/data/test/bms_bundle',there is a hap
9518  *           2.install the app
9519  *           3.call GetCompatibleDeviceType
9520  */
9521 HWTEST_F(ActsBmsKitSystemTest, GetCompatibleDeviceType_0001, Function | MediumTest | Level1)
9522 {
9523     std::cout << "START GetCompatibleDeviceType_0001" << std::endl;
9524     std::vector<std::string> resvec;
9525     std::string bundleFilePath = THIRD_BUNDLE_PATH + "bundleClient1.hap";
9526     std::string appName = "com.example.ohosproject.hmservice";
9527     Install(bundleFilePath, InstallFlag::REPLACE_EXISTING, resvec);
9528     CommonTool commonTool;
9529     std::string installResult = commonTool.VectorToStr(resvec);
9530     EXPECT_EQ(installResult, "Success") << "install fail!";
9531 
9532     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
9533     ASSERT_NE(bundleMgrProxy, nullptr);
9534 
9535     std::string deviceType;
9536     auto queryResult = bundleMgrProxy->GetCompatibleDeviceType(appName, deviceType);
9537 
9538     EXPECT_EQ(queryResult, ERR_OK);
9539 
9540     resvec.clear();
9541     Uninstall(appName, resvec);
9542     std::string uninstallResult = commonTool.VectorToStr(resvec);
9543     EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!";
9544     std::cout << "END GetCompatibleDeviceType_0001" << std::endl;
9545 }
9546 
9547 /**
9548  * @tc.number: GetCompatibleDeviceType_0002
9549  * @tc.name: test GetCompatibleDeviceType interface
9550  * @tc.desc: GetCompatibleDeviceType failed for calling bundle name is invalid
9551  */
9552 HWTEST_F(ActsBmsKitSystemTest, GetCompatibleDeviceType_0002, Function | MediumTest | Level1)
9553 {
9554     std::cout << "START GetCompatibleDeviceType_0002" << std::endl;
9555     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
9556     ASSERT_NE(bundleMgrProxy, nullptr);
9557 
9558     std::string deviceType;
9559     auto queryResult = bundleMgrProxy->GetCompatibleDeviceType("", deviceType);
9560 
9561     EXPECT_EQ(queryResult, ERR_OK);
9562     std::cout << "END GetCompatibleDeviceType_0002" << std::endl;
9563 }
9564 
9565 /**
9566  * @tc.number: GetSignatureInfoByBundleName_0100
9567  * @tc.name: test GetSignatureInfoByBundleName interface
9568  * @tc.desc: 1.ret is ERR_OK
9569  */
9570 HWTEST_F(ActsBmsKitSystemTest, GetSignatureInfoByBundleName_0100, Function | MediumTest | Level1)
9571 {
9572     std::cout << "START GetSignatureInfoByBundleName_0100" << std::endl;
9573     std::vector<std::string> resvec;
9574     std::string bundleFilePath = THIRD_BUNDLE_PATH + "bmsThirdBundle25.hap";
9575     std::string appName = BASE_BUNDLE_NAME + "2";
9576     Install(bundleFilePath, InstallFlag::REPLACE_EXISTING, resvec);
9577     CommonTool commonTool;
9578     std::string installResult = commonTool.VectorToStr(resvec);
9579     EXPECT_EQ(installResult, "Success") << "install fail!";
9580 
9581     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
9582     ASSERT_NE(bundleMgrProxy, nullptr);
9583     setuid(5523);
9584 
9585     SignatureInfo info;
9586     ErrCode ret = bundleMgrProxy->GetSignatureInfoByBundleName(appName, info);
9587     EXPECT_EQ(ret, ERR_OK);
9588     EXPECT_EQ(info.appId, BUNDLE25_APPID);
9589     EXPECT_EQ(info.fingerprint, FINGER_PRINT);
9590     EXPECT_EQ(info.appIdentifier, "");
9591 
9592     setuid(Constants::ROOT_UID);
9593 
9594     resvec.clear();
9595     Uninstall(appName, resvec);
9596     std::string uninstallResult = commonTool.VectorToStr(resvec);
9597     EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!";
9598 
9599     std::cout << "END GetSignatureInfoByBundleName_0100" << std::endl;
9600 }
9601 
9602 /**
9603  * @tc.number: GetSignatureInfoByBundleName_0200
9604  * @tc.name: test GetSignatureInfoByBundleName interface
9605  * @tc.desc: 1.ret is no permission
9606  */
9607 HWTEST_F(ActsBmsKitSystemTest, GetSignatureInfoByBundleName_0200, Function | MediumTest | Level1)
9608 {
9609     std::cout << "START GetSignatureInfoByBundleName_0200" << std::endl;
9610 
9611     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
9612     ASSERT_NE(bundleMgrProxy, nullptr);
9613 
9614     SignatureInfo info;
9615     ErrCode ret = bundleMgrProxy->GetSignatureInfoByBundleName(DEFAULT_APP_BUNDLE_NAME, info);
9616     EXPECT_EQ(ret, ERR_BUNDLE_MANAGER_PERMISSION_DENIED);
9617 
9618     std::cout << "END GetSignatureInfoByBundleName_0200" << std::endl;
9619 }
9620 
9621 /**
9622  * @tc.number: IsBundleInstalled_0001
9623  * @tc.name: test IsBundleInstalled interface
9624  * @tc.desc: 1. bundle not exist
9625  */
9626 HWTEST_F(ActsBmsKitSystemTest, IsBundleInstalled_0001, Function | MediumTest | Level1)
9627 {
9628     std::cout << "START IsBundleInstalled_0001" << std::endl;
9629 
9630     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
9631     EXPECT_NE(bundleMgrProxy, nullptr);
9632     if (bundleMgrProxy != nullptr) {
9633         bool isBundleInstalled = false;
9634         ErrCode ret = bundleMgrProxy->IsBundleInstalled(DEFAULT_APP_BUNDLE_NAME, 0, 0, isBundleInstalled);
9635         EXPECT_EQ(ret, ERR_OK);
9636         EXPECT_FALSE(isBundleInstalled);
9637     }
9638 
9639     std::cout << "END IsBundleInstalled_0001" << std::endl;
9640 }
9641 
9642 /**
9643  * @tc.number: IsBundleInstalled_0002
9644  * @tc.name: test IsBundleInstalled interface
9645  * @tc.desc: 1. bundle exist
9646  */
9647 HWTEST_F(ActsBmsKitSystemTest, IsBundleInstalled_0002, Function | MediumTest | Level1)
9648 {
9649     std::cout << "START IsBundleInstalled_0002" << std::endl;
9650 
9651     std::vector<std::string> resvec;
9652     std::string bundleFilePath = THIRD_BUNDLE_PATH + "bmsThirdBundle25.hap";
9653     std::string appName = BASE_BUNDLE_NAME + "2";
9654     Install(bundleFilePath, InstallFlag::REPLACE_EXISTING, resvec);
9655     CommonTool commonTool;
9656     std::string installResult = commonTool.VectorToStr(resvec);
9657     EXPECT_EQ(installResult, "Success") << "install fail!";
9658 
9659     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
9660     EXPECT_NE(bundleMgrProxy, nullptr);
9661     if (bundleMgrProxy != nullptr) {
9662         bool isBundleInstalled = false;
9663         ErrCode ret = bundleMgrProxy->IsBundleInstalled(appName, 200, 0, isBundleInstalled);
9664         EXPECT_EQ(ret, ERR_BUNDLE_MANAGER_INVALID_USER_ID);
9665         EXPECT_FALSE(isBundleInstalled);
9666 
9667         ret = bundleMgrProxy->IsBundleInstalled(appName, 100, 0, isBundleInstalled);
9668         EXPECT_EQ(ret, ERR_OK);
9669         EXPECT_TRUE(isBundleInstalled);
9670 
9671         isBundleInstalled = false;
9672         ret = bundleMgrProxy->IsBundleInstalled(appName, 100, 3000, isBundleInstalled);
9673         EXPECT_EQ(ret, ERR_APPEXECFWK_CLONE_INSTALL_INVALID_APP_INDEX);
9674         EXPECT_FALSE(isBundleInstalled);
9675 
9676         ret = bundleMgrProxy->IsBundleInstalled(appName, 100, -3000, isBundleInstalled);
9677         EXPECT_EQ(ret, ERR_APPEXECFWK_CLONE_INSTALL_INVALID_APP_INDEX);
9678         EXPECT_FALSE(isBundleInstalled);
9679 
9680         ret = bundleMgrProxy->IsBundleInstalled(appName, 100, 1, isBundleInstalled);
9681         EXPECT_EQ(ret, ERR_OK);
9682         EXPECT_FALSE(isBundleInstalled);
9683     }
9684     resvec.clear();
9685     Uninstall(appName, resvec);
9686     std::string uninstallResult = commonTool.VectorToStr(resvec);
9687     EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!";
9688     std::cout << "END IsBundleInstalled_0002" << std::endl;
9689 }
9690 
9691 /**
9692  * @tc.number: GetAllBundleDirs_0001
9693  * @tc.name: test GetAllBundleDirs interface
9694  * @tc.desc: 1. call GetAllBundleDirs
9695  */
9696 HWTEST_F(ActsBmsKitSystemTest, GetAllBundleDirs_0001, Function | MediumTest | Level1)
9697 {
9698     std::cout << "START GetAllBundleDirs_0001" << std::endl;
9699     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
9700     EXPECT_NE(bundleMgrProxy, nullptr);
9701     if (bundleMgrProxy != nullptr) {
9702         std::vector<BundleDir> bundleDirs;
9703         ErrCode ret = bundleMgrProxy->GetAllBundleDirs(0, bundleDirs);
9704         EXPECT_EQ(ret, ERR_OK);
9705         ret = bundleMgrProxy->GetAllBundleDirs(200, bundleDirs);
9706         EXPECT_EQ(ret, ERR_BUNDLE_MANAGER_INVALID_USER_ID);
9707     }
9708     std::cout << "END GetAllBundleDirs_0001" << std::endl;
9709 }
9710 
9711 /**
9712  * @tc.number: GetBundleNameByAppId_0001
9713  * @tc.name: test GetBundleNameByAppId interface
9714  * @tc.desc: GetBundleNameByAppId failed for calling bundle name is invalid
9715  */
9716 HWTEST_F(ActsBmsKitSystemTest, GetBundleNameByAppId_0001, Function | MediumTest | Level1)
9717 {
9718     std::cout << "START GetBundleNameByAppId_0001" << std::endl;
9719     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
9720     ASSERT_NE(bundleMgrProxy, nullptr);
9721     std::string bundleName;
9722     auto queryResult = bundleMgrProxy->GetBundleNameByAppId("", bundleName);
9723     EXPECT_EQ(queryResult, ERR_APPEXECFWK_INSTALL_PARAM_ERROR);
9724     std::cout << "END GetBundleNameByAppId_0001" << std::endl;
9725 }
9726 
9727 /**
9728  * @tc.number: GetBundleNameByAppId_0002
9729  * @tc.name: test GetBundleNameByAppId interface
9730  * @tc.desc: 1.under '/data/test/bms_bundle',there is a hap
9731  *           2.install the app
9732  *           3.call GetBundleNameByAppId
9733  */
9734 HWTEST_F(ActsBmsKitSystemTest, GetBundleNameByAppId_0002, Function | MediumTest | Level1)
9735 {
9736     std::cout << "START GetBundleNameByAppId_0002" << std::endl;
9737     std::vector<std::string> resvec;
9738     std::string bundleFilePath = THIRD_BUNDLE_PATH + "bundleClient1.hap";
9739     std::string appName = "com.example.ohosproject.hmservice";
9740     Install(bundleFilePath, InstallFlag::REPLACE_EXISTING, resvec);
9741     CommonTool commonTool;
9742     std::string installResult = commonTool.VectorToStr(resvec);
9743     EXPECT_EQ(installResult, "Success") << "install fail!";
9744 
9745     sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
9746     ASSERT_NE(bundleMgrProxy, nullptr);
9747 
9748     std::string bundleName;
9749     std::string appId = appName +
9750         "_BNtg4JBClbl92Rgc3jm/RfcAdrHXaM8F0QOiwVEhnV5ebE5jNIYnAx+weFRT3QTyUjRNdhmc2aAzWyi+5t5CoBM=";
9751     auto queryResult = bundleMgrProxy->GetBundleNameByAppId(appId, bundleName);
9752 
9753     EXPECT_EQ(queryResult, ERR_OK);
9754 
9755     resvec.clear();
9756     Uninstall(appName, resvec);
9757     std::string uninstallResult = commonTool.VectorToStr(resvec);
9758     EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!";
9759     std::cout << "END GetBundleNameByAppId_0002" << std::endl;
9760 }
9761 }  // namespace AppExecFwk
9762 }  // namespace OHOS