1885b47fbSopenharmony_ci/*
2885b47fbSopenharmony_ci * Copyright (c) 2021 Huawei Device Co., Ltd.
3885b47fbSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
4885b47fbSopenharmony_ci * you may not use this file except in compliance with the License.
5885b47fbSopenharmony_ci * You may obtain a copy of the License at
6885b47fbSopenharmony_ci *
7885b47fbSopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
8885b47fbSopenharmony_ci *
9885b47fbSopenharmony_ci * Unless required by applicable law or agreed to in writing, software
10885b47fbSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
11885b47fbSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12885b47fbSopenharmony_ci * See the License for the specific language governing permissions and
13885b47fbSopenharmony_ci * limitations under the License.
14885b47fbSopenharmony_ci */
15885b47fbSopenharmony_ci
16885b47fbSopenharmony_ci#include <gtest/gtest.h>
17885b47fbSopenharmony_ci#include "accessibility_common_helper.h"
18885b47fbSopenharmony_ci#include "accessibility_mt_helper.h"
19885b47fbSopenharmony_ci#include "system_ability.h"
20885b47fbSopenharmony_ci
21885b47fbSopenharmony_cinamespace OHOS {
22885b47fbSopenharmony_ciSystemAbility::SystemAbility(bool runOnCreate)
23885b47fbSopenharmony_ci{
24885b47fbSopenharmony_ci    GTEST_LOG_(INFO) << "MOCK SystemAbility SystemAbility";
25885b47fbSopenharmony_ci    isRunning_ = false;
26885b47fbSopenharmony_ci    isRunOnCreate_ = runOnCreate;
27885b47fbSopenharmony_ci    isDistributed_ = false;
28885b47fbSopenharmony_ci    dumpLevel_ = 0;
29885b47fbSopenharmony_ci    capability_ = u"";
30885b47fbSopenharmony_ci}
31885b47fbSopenharmony_ci
32885b47fbSopenharmony_ciSystemAbility::SystemAbility(int32_t systemAbilityId, bool runOnCreate) : SystemAbility(runOnCreate)
33885b47fbSopenharmony_ci{
34885b47fbSopenharmony_ci    GTEST_LOG_(INFO) << "MOCK SystemAbility SystemAbility";
35885b47fbSopenharmony_ci    saId_ = systemAbilityId;
36885b47fbSopenharmony_ci}
37885b47fbSopenharmony_ci
38885b47fbSopenharmony_ciSystemAbility::~SystemAbility()
39885b47fbSopenharmony_ci{
40885b47fbSopenharmony_ci    GTEST_LOG_(INFO) << "MOCK SystemAbility ~SystemAbility";
41885b47fbSopenharmony_ci}
42885b47fbSopenharmony_ci
43885b47fbSopenharmony_cibool SystemAbility::MakeAndRegisterAbility(SystemAbility* systemAbility)
44885b47fbSopenharmony_ci{
45885b47fbSopenharmony_ci    GTEST_LOG_(INFO) << "MOCK SystemAbility MakeAndRegisterAbility";
46885b47fbSopenharmony_ci    (void)systemAbility;
47885b47fbSopenharmony_ci    Accessibility::AccessibilityCommonHelper::GetInstance().SetIsServicePublished(false);
48885b47fbSopenharmony_ci    return true;
49885b47fbSopenharmony_ci}
50885b47fbSopenharmony_ci
51885b47fbSopenharmony_cibool SystemAbility::AddSystemAbilityListener(int32_t systemAbilityId)
52885b47fbSopenharmony_ci{
53885b47fbSopenharmony_ci    GTEST_LOG_(INFO) << "MOCK SystemAbility AddSystemAbilityListener";
54885b47fbSopenharmony_ci    OnAddSystemAbility(systemAbilityId, "");
55885b47fbSopenharmony_ci    return true;
56885b47fbSopenharmony_ci}
57885b47fbSopenharmony_ci
58885b47fbSopenharmony_cibool SystemAbility::RemoveSystemAbilityListener(int32_t systemAbilityId)
59885b47fbSopenharmony_ci{
60885b47fbSopenharmony_ci    GTEST_LOG_(INFO) << "MOCK SystemAbility RemoveSystemAbilityListener";
61885b47fbSopenharmony_ci    (void)systemAbilityId;
62885b47fbSopenharmony_ci    return true;
63885b47fbSopenharmony_ci}
64885b47fbSopenharmony_ci
65885b47fbSopenharmony_cibool SystemAbility::Publish(sptr<IRemoteObject> systemAbility)
66885b47fbSopenharmony_ci{
67885b47fbSopenharmony_ci    GTEST_LOG_(INFO) << "MOCK SystemAbility Publish";
68885b47fbSopenharmony_ci    (void)systemAbility;
69885b47fbSopenharmony_ci    systemAbility.ForceSetRefPtr(nullptr);
70885b47fbSopenharmony_ci    Accessibility::AccessibilityCommonHelper::GetInstance().SetIsServicePublished(true);
71885b47fbSopenharmony_ci    return true;
72885b47fbSopenharmony_ci}
73885b47fbSopenharmony_ci
74885b47fbSopenharmony_civoid SystemAbility::StopAbility(int32_t systemAbilityId)
75885b47fbSopenharmony_ci{
76885b47fbSopenharmony_ci    GTEST_LOG_(INFO) << "MOCK SystemAbility StopAbility";
77885b47fbSopenharmony_ci    return;
78885b47fbSopenharmony_ci}
79885b47fbSopenharmony_ci
80885b47fbSopenharmony_civoid SystemAbility::Start()
81885b47fbSopenharmony_ci{
82885b47fbSopenharmony_ci    GTEST_LOG_(INFO) << "MOCK SystemAbility Start";
83885b47fbSopenharmony_ci    OnStart();
84885b47fbSopenharmony_ci    isRunning_ = true;
85885b47fbSopenharmony_ci}
86885b47fbSopenharmony_ci
87885b47fbSopenharmony_civoid SystemAbility::Stop()
88885b47fbSopenharmony_ci{
89885b47fbSopenharmony_ci    GTEST_LOG_(INFO) << "MOCK SystemAbility Stop";
90885b47fbSopenharmony_ci    if (!isRunning_) {
91885b47fbSopenharmony_ci        return;
92885b47fbSopenharmony_ci    }
93885b47fbSopenharmony_ci
94885b47fbSopenharmony_ci    OnStop();
95885b47fbSopenharmony_ci    isRunning_ = false;
96885b47fbSopenharmony_ci}
97885b47fbSopenharmony_ci
98885b47fbSopenharmony_civoid SystemAbility::SADump()
99885b47fbSopenharmony_ci{
100885b47fbSopenharmony_ci    GTEST_LOG_(INFO) << "MOCK SystemAbility SADump";
101885b47fbSopenharmony_ci    OnDump();
102885b47fbSopenharmony_ci}
103885b47fbSopenharmony_ci
104885b47fbSopenharmony_ciint32_t SystemAbility::GetSystemAbilitId() const
105885b47fbSopenharmony_ci{
106885b47fbSopenharmony_ci    GTEST_LOG_(INFO) << "MOCK SystemAbility GetSystemAbilitId";
107885b47fbSopenharmony_ci    return saId_;
108885b47fbSopenharmony_ci}
109885b47fbSopenharmony_ci
110885b47fbSopenharmony_civoid SystemAbility::SetLibPath(const std::string& libPath)
111885b47fbSopenharmony_ci{
112885b47fbSopenharmony_ci    GTEST_LOG_(INFO) << "MOCK SystemAbility SetLibPath";
113885b47fbSopenharmony_ci    libPath_ = libPath;
114885b47fbSopenharmony_ci}
115885b47fbSopenharmony_ci
116885b47fbSopenharmony_ciconst std::string& SystemAbility::GetLibPath() const
117885b47fbSopenharmony_ci{
118885b47fbSopenharmony_ci    GTEST_LOG_(INFO) << "MOCK SystemAbility GetLibPath";
119885b47fbSopenharmony_ci    return libPath_;
120885b47fbSopenharmony_ci}
121885b47fbSopenharmony_ci
122885b47fbSopenharmony_civoid SystemAbility::SetDependSa(const std::vector<int32_t>& dependSa)
123885b47fbSopenharmony_ci{
124885b47fbSopenharmony_ci    GTEST_LOG_(INFO) << "MOCK SystemAbility SetDependSa";
125885b47fbSopenharmony_ci    dependSa_ = dependSa;
126885b47fbSopenharmony_ci}
127885b47fbSopenharmony_ci
128885b47fbSopenharmony_ciconst std::vector<int32_t>& SystemAbility::GetDependSa() const
129885b47fbSopenharmony_ci{
130885b47fbSopenharmony_ci    GTEST_LOG_(INFO) << "MOCK SystemAbility GetDependSa";
131885b47fbSopenharmony_ci    return dependSa_;
132885b47fbSopenharmony_ci}
133885b47fbSopenharmony_ci
134885b47fbSopenharmony_civoid SystemAbility::SetRunOnCreate(bool isRunOnCreate)
135885b47fbSopenharmony_ci{
136885b47fbSopenharmony_ci    GTEST_LOG_(INFO) << "MOCK SystemAbility SetRunOnCreate";
137885b47fbSopenharmony_ci    isRunOnCreate_ = isRunOnCreate;
138885b47fbSopenharmony_ci}
139885b47fbSopenharmony_ci
140885b47fbSopenharmony_cibool SystemAbility::IsRunOnCreate() const
141885b47fbSopenharmony_ci{
142885b47fbSopenharmony_ci    GTEST_LOG_(INFO) << "MOCK SystemAbility IsRunOnCreate";
143885b47fbSopenharmony_ci    return isRunOnCreate_;
144885b47fbSopenharmony_ci}
145885b47fbSopenharmony_ci
146885b47fbSopenharmony_civoid SystemAbility::SetDistributed(bool isDistributed)
147885b47fbSopenharmony_ci{
148885b47fbSopenharmony_ci    GTEST_LOG_(INFO) << "MOCK SystemAbility SetDistributed";
149885b47fbSopenharmony_ci    isDistributed_ = isDistributed;
150885b47fbSopenharmony_ci}
151885b47fbSopenharmony_ci
152885b47fbSopenharmony_cibool SystemAbility::GetDistributed() const
153885b47fbSopenharmony_ci{
154885b47fbSopenharmony_ci    GTEST_LOG_(INFO) << "MOCK SystemAbility GetDistributed";
155885b47fbSopenharmony_ci    return isDistributed_;
156885b47fbSopenharmony_ci}
157885b47fbSopenharmony_ci
158885b47fbSopenharmony_cibool SystemAbility::GetRunningStatus() const
159885b47fbSopenharmony_ci{
160885b47fbSopenharmony_ci    GTEST_LOG_(INFO) << "MOCK SystemAbility GetRunningStatus";
161885b47fbSopenharmony_ci    return isRunning_;
162885b47fbSopenharmony_ci}
163885b47fbSopenharmony_ci
164885b47fbSopenharmony_civoid SystemAbility::SetDumpLevel(uint32_t dumpLevel)
165885b47fbSopenharmony_ci{
166885b47fbSopenharmony_ci    GTEST_LOG_(INFO) << "MOCK SystemAbility SetDumpLevel";
167885b47fbSopenharmony_ci    dumpLevel_ = dumpLevel;
168885b47fbSopenharmony_ci}
169885b47fbSopenharmony_ci
170885b47fbSopenharmony_ciuint32_t SystemAbility::GetDumpLevel() const
171885b47fbSopenharmony_ci{
172885b47fbSopenharmony_ci    GTEST_LOG_(INFO) << "MOCK SystemAbility GetDumpLevel";
173885b47fbSopenharmony_ci    return dumpLevel_;
174885b47fbSopenharmony_ci}
175885b47fbSopenharmony_ci
176885b47fbSopenharmony_civoid SystemAbility::SetDependTimeout(int32_t dependTimeout)
177885b47fbSopenharmony_ci{
178885b47fbSopenharmony_ci    GTEST_LOG_(INFO) << "MOCK SystemAbility SetDependTimeout";
179885b47fbSopenharmony_ci    (void)dependTimeout;
180885b47fbSopenharmony_ci}
181885b47fbSopenharmony_ci
182885b47fbSopenharmony_ciint32_t SystemAbility::GetDependTimeout() const
183885b47fbSopenharmony_ci{
184885b47fbSopenharmony_ci    GTEST_LOG_(INFO) << "MOCK SystemAbility GetDependTimeout";
185885b47fbSopenharmony_ci    return dependTimeout_;
186885b47fbSopenharmony_ci}
187885b47fbSopenharmony_ci
188885b47fbSopenharmony_ci// The details should be implemented by subclass
189885b47fbSopenharmony_civoid SystemAbility::OnDump()
190885b47fbSopenharmony_ci{
191885b47fbSopenharmony_ci    GTEST_LOG_(INFO) << "MOCK SystemAbility OnDump";
192885b47fbSopenharmony_ci}
193885b47fbSopenharmony_ci
194885b47fbSopenharmony_ci// The details should be implemented by subclass
195885b47fbSopenharmony_civoid SystemAbility::OnStart()
196885b47fbSopenharmony_ci{
197885b47fbSopenharmony_ci    GTEST_LOG_(INFO) << "MOCK SystemAbility OnStart";
198885b47fbSopenharmony_ci}
199885b47fbSopenharmony_ci
200885b47fbSopenharmony_ciint32_t SystemAbility::OnExtension(const std::string& extension, MessageParcel& data, MessageParcel& reply)
201885b47fbSopenharmony_ci{
202885b47fbSopenharmony_ci    GTEST_LOG_(INFO) << "MOCK SystemAbility OnExtension";
203885b47fbSopenharmony_ci    return 0;
204885b47fbSopenharmony_ci}
205885b47fbSopenharmony_ci
206885b47fbSopenharmony_civoid SystemAbility::OnStart(const SystemAbilityOnDemandReason& startReason)
207885b47fbSopenharmony_ci{
208885b47fbSopenharmony_ci    GTEST_LOG_(INFO) << "MOCK SystemAbility OnStart";
209885b47fbSopenharmony_ci}
210885b47fbSopenharmony_ci
211885b47fbSopenharmony_ciint32_t SystemAbility::OnIdle(const SystemAbilityOnDemandReason& idleReason)
212885b47fbSopenharmony_ci{
213885b47fbSopenharmony_ci    GTEST_LOG_(INFO) << "MOCK SystemAbility OnIdle";
214885b47fbSopenharmony_ci    return 0;
215885b47fbSopenharmony_ci}
216885b47fbSopenharmony_ci
217885b47fbSopenharmony_civoid SystemAbility::OnActive(const SystemAbilityOnDemandReason& activeReason)
218885b47fbSopenharmony_ci{
219885b47fbSopenharmony_ci    GTEST_LOG_(INFO) << "MOCK SystemAbility OnActive";
220885b47fbSopenharmony_ci}
221885b47fbSopenharmony_ci
222885b47fbSopenharmony_ci// The details should be implemented by subclass
223885b47fbSopenharmony_civoid SystemAbility::OnStop()
224885b47fbSopenharmony_ci{
225885b47fbSopenharmony_ci    GTEST_LOG_(INFO) << "MOCK SystemAbility OnStop";
226885b47fbSopenharmony_ci}
227885b47fbSopenharmony_ci
228885b47fbSopenharmony_civoid SystemAbility::OnStop(const SystemAbilityOnDemandReason& stopReason)
229885b47fbSopenharmony_ci{
230885b47fbSopenharmony_ci    GTEST_LOG_(INFO) << "MOCK SystemAbility OnStop";
231885b47fbSopenharmony_ci}
232885b47fbSopenharmony_ci
233885b47fbSopenharmony_ci// The details should be implemented by subclass
234885b47fbSopenharmony_civoid SystemAbility::OnAddSystemAbility(int32_t systemAbilityId, const std::string& deviceId)
235885b47fbSopenharmony_ci{
236885b47fbSopenharmony_ci    GTEST_LOG_(INFO) << "MOCK SystemAbility OnAddSystemAbility";
237885b47fbSopenharmony_ci    (void)systemAbilityId;
238885b47fbSopenharmony_ci    (void)deviceId;
239885b47fbSopenharmony_ci}
240885b47fbSopenharmony_ci
241885b47fbSopenharmony_ci// The details should be implemented by subclass
242885b47fbSopenharmony_civoid SystemAbility::OnRemoveSystemAbility(int32_t systemAbilityId, const std::string& deviceId)
243885b47fbSopenharmony_ci{
244885b47fbSopenharmony_ci    GTEST_LOG_(INFO) << "MOCK SystemAbility OnRemoveSystemAbility";
245885b47fbSopenharmony_ci    (void)systemAbilityId;
246885b47fbSopenharmony_ci    (void)deviceId;
247885b47fbSopenharmony_ci}
248885b47fbSopenharmony_ci
249885b47fbSopenharmony_cisptr<IRemoteObject> SystemAbility::GetSystemAbility(int32_t systemAbilityId)
250885b47fbSopenharmony_ci{
251885b47fbSopenharmony_ci    GTEST_LOG_(INFO) << "MOCK SystemAbility GetSystemAbility";
252885b47fbSopenharmony_ci    (void)systemAbilityId;
253885b47fbSopenharmony_ci    return nullptr;
254885b47fbSopenharmony_ci}
255885b47fbSopenharmony_ci
256885b47fbSopenharmony_civoid SystemAbility::SetCapability(const std::u16string& capability)
257885b47fbSopenharmony_ci{
258885b47fbSopenharmony_ci    GTEST_LOG_(INFO) << "MOCK SystemAbility SetCapability";
259885b47fbSopenharmony_ci    capability_ = capability;
260885b47fbSopenharmony_ci}
261885b47fbSopenharmony_ci
262885b47fbSopenharmony_ciconst std::u16string& SystemAbility::GetCapability() const
263885b47fbSopenharmony_ci{
264885b47fbSopenharmony_ci    GTEST_LOG_(INFO) << "MOCK SystemAbility GetCapability";
265885b47fbSopenharmony_ci    return capability_;
266885b47fbSopenharmony_ci}
267885b47fbSopenharmony_ci
268885b47fbSopenharmony_civoid SystemAbility::SetPermission(const std::u16string& permission)
269885b47fbSopenharmony_ci{
270885b47fbSopenharmony_ci    GTEST_LOG_(INFO) << "MOCK SystemAbility SetPermission";
271885b47fbSopenharmony_ci    permission_ = permission;
272885b47fbSopenharmony_ci}
273885b47fbSopenharmony_ci
274885b47fbSopenharmony_ci// The details should be implemented by subclass
275885b47fbSopenharmony_civoid SystemAbility::OnDeviceLevelChanged(int32_t type, int32_t level, std::string& action)
276885b47fbSopenharmony_ci{
277885b47fbSopenharmony_ci    GTEST_LOG_(INFO) << "MOCK SystemAbility OnDeviceLevelChanged";
278885b47fbSopenharmony_ci    (void)type;
279885b47fbSopenharmony_ci    (void)level;
280885b47fbSopenharmony_ci    (void)action;
281885b47fbSopenharmony_ci}
282885b47fbSopenharmony_ci}
283