• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include <gtest/gtest.h>
17 #include "mock_bundle_manager.h"
18 
19 #include "ability_info.h"
20 #include "application_info.h"
21 #include "form_info.h"
22 
23 namespace OHOS {
24 namespace AppExecFwk {
25 const std::string FORM_PROVIDER_BUNDLE_NAME = "com.form.provider.service";
26 const std::string PARAM_PROVIDER_PACKAGE_NAME = "com.form.provider.app.test.abiliy";
27 const std::string PARAM_PROVIDER_MODULE_NAME = "com.form.provider.app.test.abiliy";
28 const std::string FORM_PROVIDER_ABILITY_NAME = "com.form.provider.app.test.abiliy";
29 const std::string FORM_PROVIDER_MODULE_SOURCE_DIR = "";
30 const std::string FORM_JS_COMPOMENT_NAME = "jsComponentName";
31 const std::string PARAM_FORM_NAME = "com.form.name.test";
32 const std::string DEVICE_ID = "ohos-phone1";
33 
GetBundleInfo(const std::string & bundleName,const BundleFlag flag,BundleInfo & bundleInfo,int32_t userId)34 bool BundleMgrProxy::GetBundleInfo(
35     const std::string &bundleName, const BundleFlag flag, BundleInfo &bundleInfo, int32_t userId)
36 {
37     return true;
38 }
39 
GetUidByBundleName(const std::string & bundleName,const int userId)40 int BundleMgrService::GetUidByBundleName(const std::string &bundleName, const int userId)
41 {
42     if (bundleName.compare("com.form.host.app600") == 0) {
43         return 600;
44     }
45     return 0;
46 }
47 
GetAllFormsInfo(std::vector<FormInfo> & formInfo)48 bool BundleMgrProxy::GetAllFormsInfo(std::vector<FormInfo> &formInfo)
49 {
50     return true;
51 }
GetFormsInfoByApp(const std::string & bundleName,std::vector<FormInfo> & formInfo)52 bool BundleMgrProxy::GetFormsInfoByApp(const std::string &bundleName, std::vector<FormInfo> &formInfo)
53 {
54     return true;
55 }
GetFormsInfoByModule(const std::string & bundleName,const std::string & moduleName,std::vector<FormInfo> & formInfo)56 bool BundleMgrProxy::GetFormsInfoByModule(const std::string &bundleName, const std::string &moduleName,
57     std::vector<FormInfo> &formInfo)
58 {
59     return true;
60 }
61 
OnRemoteRequest(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)62 int BundleMgrStub::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option)
63 {
64     return 0;
65 }
66 
QueryAbilityInfo(const AAFwk::Want & want,AbilityInfo & abilityInfo)67 bool BundleMgrService::QueryAbilityInfo(const AAFwk::Want &want, AbilityInfo &abilityInfo)
68 {
69     return true;
70 }
71 
QueryAbilityInfoByUri(const std::string & uri,AbilityInfo & abilityInfo)72 bool BundleMgrService::QueryAbilityInfoByUri(const std::string &uri, AbilityInfo &abilityInfo)
73 {
74     return false;
75 }
76 
GetApplicationInfo(const std::string & appName,const ApplicationFlag flag,const int userId,ApplicationInfo & appInfo)77 bool BundleMgrService::GetApplicationInfo(
78     const std::string &appName, const ApplicationFlag flag, const int userId, ApplicationInfo &appInfo)
79 {
80     return true;
81 }
82 
GetAppType(const std::string & bundleName)83 std::string BundleMgrService::GetAppType(const std::string &bundleName)
84 {
85     return "system";
86 }
87 
GetBundleInfo(const std::string & bundleName,const BundleFlag flag,BundleInfo & bundleInfo,int32_t userId)88 bool BundleMgrService::GetBundleInfo(
89     const std::string &bundleName, const BundleFlag flag, BundleInfo &bundleInfo, int32_t userId)
90 {
91     std::vector<AbilityInfo> abilityInfos;
92     ApplicationInfo applicationInfo;
93     ModuleInfo moduleInfo;
94 
95     moduleInfo.moduleSourceDir = FORM_PROVIDER_MODULE_SOURCE_DIR;
96     moduleInfo.moduleName = PARAM_PROVIDER_MODULE_NAME;
97     bundleInfo.name = bundleName;
98     applicationInfo.bundleName = bundleName;
99     applicationInfo.moduleInfos.emplace_back(moduleInfo);
100     bundleInfo.applicationInfo = applicationInfo;
101 
102     bundleInfo.moduleNames.emplace_back(PARAM_PROVIDER_MODULE_NAME);
103 
104     AbilityInfo abilityInfo;
105     abilityInfo.name = FORM_PROVIDER_ABILITY_NAME;
106     abilityInfo.package = PARAM_PROVIDER_PACKAGE_NAME;
107     abilityInfo.bundleName = bundleName;
108     abilityInfo.moduleName = PARAM_PROVIDER_MODULE_NAME;
109     abilityInfo.deviceId = DEVICE_ID;
110     bundleInfo.abilityInfos.emplace_back(abilityInfo);
111 
112     return true;
113 }
GetBundleGids(const std::string & bundleName,std::vector<int> & gids)114 bool BundleMgrService::GetBundleGids(const std::string &bundleName, std::vector<int> &gids)
115 {
116     return true;
117 }
118 
GetAllFormsInfo(std::vector<FormInfo> & formInfo)119 bool BundleMgrService::GetAllFormsInfo(std::vector<FormInfo> &formInfo)
120 {
121     return true;
122 }
GetFormsInfoByApp(const std::string & bundleName,std::vector<FormInfo> & formInfo)123 bool BundleMgrService::GetFormsInfoByApp(const std::string &bundleName, std::vector<FormInfo> &formInfo)
124 {
125     FormInfo form;
126     form.bundleName = bundleName;
127     form.abilityName = FORM_PROVIDER_ABILITY_NAME;
128     form.moduleName = PARAM_PROVIDER_MODULE_NAME;
129     form.name = PARAM_FORM_NAME;
130     form.updateEnabled = true;
131     form.updateDuration = 1;
132     form.scheduledUpdateTime = "06:06";
133     form.jsComponentName = FORM_JS_COMPOMENT_NAME;
134     form.formVisibleNotify = true;
135     form.supportDimensions = {1, 2};
136     form.defaultDimension = 1;
137     formInfo.emplace_back(form);
138     return true;
139 }
GetFormsInfoByModule(const std::string & bundleName,const std::string & moduleName,std::vector<FormInfo> & formInfo)140 bool BundleMgrService::GetFormsInfoByModule(const std::string &bundleName, const std::string &moduleName,
141     std::vector<FormInfo> &formInfo)
142 {
143     FormInfo form;
144     form.bundleName = bundleName;
145     form.abilityName = FORM_PROVIDER_ABILITY_NAME;
146     form.moduleName = PARAM_PROVIDER_MODULE_NAME;
147     form.name = PARAM_FORM_NAME;
148     form.updateEnabled = true;
149     form.updateDuration = 1;
150     form.scheduledUpdateTime = "06:06";
151     form.jsComponentName = FORM_JS_COMPOMENT_NAME;
152     form.formVisibleNotify = true;
153     form.supportDimensions = {1, 2};
154     form.defaultDimension = 1;
155     formInfo.emplace_back(form);
156     return true;
157 }
158 }  // namespace AppExecFwk
159 }  // namespace OHOS
160