• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022-2025 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 #ifndef MOCK_OHOS_ABILITY_RUNTIME_MOCK_ABILITY_DELEGATOR_STUB_H
17 #define MOCK_OHOS_ABILITY_RUNTIME_MOCK_ABILITY_DELEGATOR_STUB_H
18 
19 #include "gmock/gmock.h"
20 
21 #include "string_ex.h"
22 #include "ability_manager_errors.h"
23 #include "ability_manager_stub.h"
24 
25 namespace OHOS {
26 namespace AAFwk {
27 class MockAbilityDelegatorStub : public AbilityManagerStub {
28 public:
29     MockAbilityDelegatorStub();
30     int StartAbility(const Want& want, int32_t userId = DEFAULT_INVAL_VALUE,
31         int requestCode = DEFAULT_INVAL_VALUE) override;
32     MOCK_METHOD4(StartAbility, int(const Want& want, const sptr<IRemoteObject>& callerToken,
33         int32_t userId, int requestCode));
34     MOCK_METHOD5(StartAbilityAsCaller, int(const Want& want, const sptr<IRemoteObject>& callerToken,
35         sptr<IRemoteObject> asCallerSourceToken, int32_t userId, int requestCode));
36     MOCK_METHOD5(StartAbility, int(const Want& want, const AbilityStartSetting& abilityStartSetting,
37         const sptr<IRemoteObject>& callerToken, int32_t userId, int requestCode));
38     MOCK_METHOD4(StartAbilityByInsightIntent, int32_t(const Want& want, const sptr<IRemoteObject>& callerToken,
39         uint64_t intentId, int32_t userId));
40     int StartAbility(const Want& want, const StartOptions& startOptions,
41         const sptr<IRemoteObject>& callerToken, int requestCode = DEFAULT_INVAL_VALUE,
42         int32_t userId = DEFAULT_INVAL_VALUE) override;
43     int StartAbilityAsCaller(const Want& want, const StartOptions& startOptions,
44         const sptr<IRemoteObject>& callerToken, sptr<IRemoteObject> asCallerSourceToken,
45         int requestCode = DEFAULT_INVAL_VALUE, int32_t userId = DEFAULT_INVAL_VALUE) override;
46     MOCK_METHOD3(TerminateAbility, int(const sptr<IRemoteObject>& token, int resultCode, const Want* resultWant));
47     int CloseAbility(const sptr<IRemoteObject>& token, int resultCode = DEFAULT_INVAL_VALUE,
48         const Want* resultWant = nullptr) override;
49     int MinimizeAbility(const sptr<IRemoteObject>& token, bool fromUser = false) override;
50     MOCK_METHOD4(ConnectAbility, int(const Want& want, const sptr<IAbilityConnection>& connect,
51         const sptr<IRemoteObject>& callerToken, int32_t userId));
52     MOCK_METHOD1(DisconnectAbility, int(sptr<IAbilityConnection> connect));
53     MOCK_METHOD3(AcquireDataAbility,
54         sptr<IAbilityScheduler>(const Uri& uri, bool tryBind, const sptr<IRemoteObject>& callerToken));
55     MOCK_METHOD2(
56         ReleaseDataAbility, int(sptr<IAbilityScheduler> dataAbilityScheduler, const sptr<IRemoteObject>& callerToken));
57     MOCK_METHOD2(AddWindowInfo, void(const sptr<IRemoteObject>& token, int32_t windowToken));
58     MOCK_METHOD2(AttachAbilityThread, int(const sptr<IAbilityScheduler>& scheduler, const sptr<IRemoteObject>& token));
59     MOCK_METHOD3(AbilityTransitionDone, int(const sptr<IRemoteObject>& token, int state, const PacMap&));
60     MOCK_METHOD2(
61         ScheduleConnectAbilityDone, int(const sptr<IRemoteObject>& token, const sptr<IRemoteObject>& remoteObject));
62     MOCK_METHOD1(ScheduleDisconnectAbilityDone, int(const sptr<IRemoteObject>& token));
63     MOCK_METHOD1(ScheduleCommandAbilityDone, int(const sptr<IRemoteObject>& token));
64     MOCK_METHOD4(ScheduleCommandAbilityWindowDone, int(const sptr<IRemoteObject> &token,
65         const sptr<SessionInfo> &sessionInfo, WindowCommand winCmd, AbilityCommand abilityCmd));
66     void DumpState(const std::string& args, std::vector<std::string>& state) override;
67     int StopServiceAbility(const Want& want, int32_t userId = DEFAULT_INVAL_VALUE,
68         const sptr<IRemoteObject> &token = nullptr) override;
69     MOCK_METHOD1(MoveMissionToTop, int(int32_t missionId));
70     MOCK_METHOD1(RemoveMission, int(int id));
71     MOCK_METHOD1(RemoveStack, int(int id));
72     MOCK_METHOD3(KillProcess, int(const std::string& bundleName, const bool clearPageStack, int32_t appIndex));
73     MOCK_METHOD2(UninstallApp, int(const std::string& bundleName, int32_t uid));
74     MOCK_METHOD3(UninstallApp, int32_t(const std::string& bundleName, int32_t uid, int32_t appIndex));
75     MOCK_METHOD2(MoveMissionToEnd, int(const sptr<IRemoteObject>& token, const bool nonFirst));
76     MOCK_METHOD1(IsFirstInMission, bool(const sptr<IRemoteObject>& token));
77     MOCK_METHOD4(CompelVerifyPermission, int(const std::string& permission, int pid, int uid, std::string& message));
78     MOCK_METHOD3(
79         GetWantSender, sptr<IWantSender>(const WantSenderInfo& wantSenderInfo, const sptr<IRemoteObject>& callerToken,
80         int32_t uid));
81     MOCK_METHOD2(SendWantSender, int(sptr<IWantSender> target, SenderInfo& senderInfo));
82     MOCK_METHOD1(CancelWantSender, void(const sptr<IWantSender>& sender));
83     MOCK_METHOD1(GetPendingWantUid, int(const sptr<IWantSender>& target));
84     MOCK_METHOD1(GetPendingWantUserId, int(const sptr<IWantSender>& target));
85     MOCK_METHOD1(GetPendingWantBundleName, std::string(const sptr<IWantSender>& target));
86     MOCK_METHOD1(GetPendingWantCode, int(const sptr<IWantSender>& target));
87     MOCK_METHOD1(GetPendingWantType, int(const sptr<IWantSender>& target));
88     MOCK_METHOD2(RegisterCancelListener, void(const sptr<IWantSender>& sender, const sptr<IWantReceiver>& receiver));
89     MOCK_METHOD2(UnregisterCancelListener, void(const sptr<IWantSender>& sender, const sptr<IWantReceiver>& receiver));
90     MOCK_METHOD2(GetPendingRequestWant, int(const sptr<IWantSender>& target, std::shared_ptr<Want>& want));
91     MOCK_METHOD1(LockMission, int(int));
92     MOCK_METHOD1(UnlockMission, int(int));
93     MOCK_METHOD0(GetMissionLockModeState, int());
94     MOCK_METHOD2(
95         ChangeFocusAbility, int(const sptr<IRemoteObject>& lostFocusToken, const sptr<IRemoteObject>& getFocusToken));
96     MOCK_METHOD1(MinimizeMultiWindow, int(int missionId));
97     MOCK_METHOD1(MaximizeMultiWindow, int(int missionId));
98     MOCK_METHOD1(CloseMultiWindow, int(int missionId));
99     MOCK_METHOD1(GetPendinTerminateAbilityTestgRequestWant, void(int id));
100     MOCK_METHOD1(SetShowOnLockScreen, int(bool isAllow));
101     MOCK_METHOD3(StartContinuation, int(const Want& want, const sptr<IRemoteObject>& abilityToken, int32_t status));
102     MOCK_METHOD2(NotifyContinuationResult, int(int32_t missionId, int32_t result));
103     MOCK_METHOD5(ContinueMission, int(const std::string& srcDeviceId, const std::string& dstDeviceId,
104         int32_t missionId, const sptr<IRemoteObject>& callBack, AAFwk::WantParams& wantParams));
105     MOCK_METHOD3(ContinueAbility, int(const std::string& deviceId, int32_t missionId, uint32_t versionCode));
106     MOCK_METHOD3(NotifyCompleteContinuation, void(const std::string& deviceId, int32_t sessionId, bool isSuccess));
107     MOCK_METHOD1(LockMissionForCleanup, int(int32_t missionId));
108     MOCK_METHOD1(UnlockMissionForCleanup, int(int32_t missionId));
109     MOCK_METHOD1(RegisterMissionListener, int(const sptr<IMissionListener>& listener));
110     MOCK_METHOD1(UnRegisterMissionListener, int(const sptr<IMissionListener>& listener));
111     MOCK_METHOD3(
112         GetMissionInfos, int(const std::string& deviceId, int32_t numMax, std::vector<MissionInfo>& missionInfos));
113     MOCK_METHOD3(GetMissionInfo, int(const std::string& deviceId, int32_t missionId, MissionInfo& missionInfo));
114     MOCK_METHOD1(CleanMission, int(int32_t missionId));
115     MOCK_METHOD0(CleanAllMissions, int());
116     MOCK_METHOD1(MoveMissionToFront, int(int32_t missionId));
117     MOCK_METHOD2(MoveMissionToFront, int(int32_t missionId, const StartOptions& startOptions));
118     MOCK_METHOD2(MoveMissionsToForeground, int(const std::vector<int32_t>& missionIds, int32_t topMissionId));
119     MOCK_METHOD2(MoveMissionsToBackground, int(const std::vector<int32_t>& missionIds, std::vector<int32_t>& result));
120     MOCK_METHOD1(GetAbilityRunningInfos, int(std::vector<AbilityRunningInfo>& info));
121     MOCK_METHOD2(GetExtensionRunningInfos, int(int upperLimit, std::vector<ExtensionRunningInfo>& info));
122     MOCK_METHOD1(GetProcessRunningInfos, int(std::vector<AppExecFwk::RunningProcessInfo>& info));
123     MOCK_METHOD2(GetWantSenderInfo, int(const sptr<IWantSender>& target, std::shared_ptr<WantSenderInfo>& info));
124     MOCK_METHOD2(AcquireShareData, int32_t(const int32_t &missionId, const sptr<IAcquireShareDataCallback> &shareData));
125     MOCK_METHOD4(ShareDataDone, int32_t(const sptr<IRemoteObject> &token,
126         const int32_t &resultCode, const int32_t &uniqueId, WantParams &wantParam));
127     MOCK_METHOD2(SetMissionContinueState, int(const sptr<IRemoteObject>& token, const AAFwk::ContinueState& state));
128     int StartUser(int userId, sptr<IUserCallback> callback, bool isAppRecovery) override;
129     int StopUser(int userId, const sptr<IUserCallback>& callback) override;
130     int LogoutUser(int32_t userId, sptr<IUserCallback> callback = nullptr) override;
131     int StartSyncRemoteMissions(const std::string& devId, bool fixConflict, int64_t tag) override;
132     int StopSyncRemoteMissions(const std::string& devId) override;
133     int RegisterMissionListener(const std::string& deviceId,
134         const sptr<IRemoteMissionListener>& listener) override;
135     int UnRegisterMissionListener(const std::string& deviceId,
136         const sptr<IRemoteMissionListener>& listener) override;
137     int StartAbilityByCall(const Want& want, const sptr<IAbilityConnection>& connect,
138         const sptr<IRemoteObject>& callerToken, int32_t accountId = DEFAULT_INVAL_VALUE,
139         bool isSilent = false) override;
140     void CallRequestDone(const sptr<IRemoteObject>& token, const sptr<IRemoteObject>& callStub) override;
141     int ReleaseCall(const sptr<IAbilityConnection>& connect,
142         const AppExecFwk::ElementName& element) override;
143     int GetMissionSnapshot(const std::string& deviceId, int32_t missionId,
144         MissionSnapshot& snapshot, bool isLowResolution) override;
145     int RegisterSnapshotHandler(const sptr<ISnapshotHandler>& handler) override;
146     int SetAbilityController(const sptr<AppExecFwk::IAbilityController>& abilityController,
147         bool imAStabilityTest) override;
148     bool IsRunningInStabilityTest() override;
149     void DumpSysState(
150         const std::string& args, std::vector<std::string>& info, bool isClient, bool isUserID, int UserID) override;
151     int StartUserTest(const Want& want, const sptr<IRemoteObject>& observer) override;
152     int FinishUserTest(
153         const std::string& msg, const int64_t& resultCode, const std::string& bundleName) override;
154     int GetTopAbility(sptr<IRemoteObject>& token) override;
155     int DelegatorDoAbilityForeground(const sptr<IRemoteObject>& token) override;
156     int DelegatorDoAbilityBackground(const sptr<IRemoteObject>& token) override;
157     int32_t ReportDrawnCompleted(const sptr<IRemoteObject>& callerToken) override;
158     int DoAbilityForeground(const sptr<IRemoteObject>& token, uint32_t flag);
159     int DoAbilityBackground(const sptr<IRemoteObject>& token, uint32_t flag);
160     int32_t GetMissionIdByToken(const sptr<IRemoteObject>& token);
161     void GetAbilityTokenByCalleeObj(const sptr<IRemoteObject> &callStub, sptr<IRemoteObject> &token);
SetApplicationAutoStartupByEDM(const AutoStartupInfo & info,bool flag)162     int32_t SetApplicationAutoStartupByEDM(const AutoStartupInfo &info, bool flag) override
163     {
164         return 0;
165     }
166 
CancelApplicationAutoStartupByEDM(const AutoStartupInfo & info,bool flag)167     int32_t CancelApplicationAutoStartupByEDM(const AutoStartupInfo &info, bool flag) override
168     {
169         return 0;
170     }
171 
GetForegroundUIAbilities(std::vector<AppExecFwk::AbilityStateData> & list)172     virtual int32_t GetForegroundUIAbilities(std::vector<AppExecFwk::AbilityStateData> &list)
173     {
174         return 0;
175     }
176 #ifdef ABILITY_COMMAND_FOR_TEST
177     int ForceTimeoutForTest(const std::string& abilityName, const std::string& state) override;
178 #endif
179 #ifdef SUPPORT_GRAPHICS
180     MOCK_METHOD2(SetMissionLabel, int(const sptr<IRemoteObject>& token, const std::string& label));
181     int SetMissionIcon(
182         const sptr<IRemoteObject>& token, const std::shared_ptr<OHOS::Media::PixelMap>& icon) override;
183     int RegisterWindowManagerServiceHandler(const sptr<IWindowManagerServiceHandler>& handler,
184         bool animationEnabled = true);
CompleteFirstFrameDrawing(const sptr<IRemoteObject> & abilityToken)185     void CompleteFirstFrameDrawing(const sptr<IRemoteObject>& abilityToken) override {}
186 #endif
187     MOCK_METHOD2(IsValidMissionIds, int32_t(const std::vector<int32_t>&, std::vector<MissionValidResult>&));
188     MOCK_METHOD1(RegisterAppDebugListener, int32_t(sptr<AppExecFwk::IAppDebugListener> listener));
189     MOCK_METHOD1(UnregisterAppDebugListener, int32_t(sptr<AppExecFwk::IAppDebugListener> listener));
190     MOCK_METHOD2(AttachAppDebug, int32_t(const std::string &bundleName, bool isDebugFromLocal));
191     MOCK_METHOD2(DetachAppDebug, int32_t(const std::string &bundleName, bool isDebugFromLocal));
192     MOCK_METHOD3(ExecuteIntent, int32_t(uint64_t key, const sptr<IRemoteObject> &callerToken,
193         const InsightIntentExecuteParam &param));
194     MOCK_METHOD3(ExecuteInsightIntentDone, int32_t(const sptr<IRemoteObject> &token, uint64_t intentId,
195         const InsightIntentExecuteResult &result));
196     MOCK_METHOD5(StartAbilityWithSpecifyTokenId, int(const Want& want, const sptr<IRemoteObject>& callerToken,
197         uint32_t specifyTokenId, int32_t userId, int requestCode));
198 public:
199     std::string powerState_;
200     static bool finishFlag_;
201 };
202 
203 enum TESTCASE_BRANCH {
204     BRANCH_1 = 1,
205     BRANCH_2 = 2,
206     BRANCH_3 = 3,
207 };
208 
209 class MockAbilityDelegatorStub2 : public AbilityManagerStub {
210 public:
211     MockAbilityDelegatorStub2();
212     int StartAbility(const Want& want, int32_t userId = DEFAULT_INVAL_VALUE, int requestCode = -1) override;
213     MOCK_METHOD4(StartAbility, int(const Want& want, const sptr<IRemoteObject>& callerToken,
214         int32_t userId, int requestCode));
215     MOCK_METHOD5(StartAbilityAsCaller, int(const Want& want, const sptr<IRemoteObject>& callerToken,
216         sptr<IRemoteObject> asCallerSourceToken, int32_t userId, int requestCode));
217     MOCK_METHOD5(StartAbility, int(const Want& want, const AbilityStartSetting& abilityStartSetting,
218         const sptr<IRemoteObject>& callerToken, int32_t userId, int requestCode));
219     MOCK_METHOD4(StartAbilityByInsightIntent, int32_t(const Want& want, const sptr<IRemoteObject>& callerToken,
220         uint64_t intentId, int32_t userId));
221     int StartAbility(const Want& want, const StartOptions& startOptions,
222         const sptr<IRemoteObject>& callerToken, int requestCode = DEFAULT_INVAL_VALUE,
223         int32_t userId = DEFAULT_INVAL_VALUE) override;
224     int StartAbilityAsCaller(const Want& want, const StartOptions& startOptions,
225         const sptr<IRemoteObject>& callerToken, sptr<IRemoteObject> asCallerSourceToken,
226         int requestCode = DEFAULT_INVAL_VALUE, int32_t userId = DEFAULT_INVAL_VALUE) override;
227     MOCK_METHOD3(TerminateAbility, int(const sptr<IRemoteObject>& token, int resultCode, const Want* resultWant));
228     int CloseAbility(const sptr<IRemoteObject>& token, int resultCode = DEFAULT_INVAL_VALUE,
229         const Want* resultWant = nullptr) override;
230     int MinimizeAbility(const sptr<IRemoteObject>& token, bool fromUser = false) override;
231     MOCK_METHOD4(ConnectAbility, int(const Want& want, const sptr<IAbilityConnection>& connect,
232         const sptr<IRemoteObject>& callerToken, int32_t userId));
233     MOCK_METHOD1(DisconnectAbility, int(sptr<IAbilityConnection> connect));
234     MOCK_METHOD3(AcquireDataAbility,
235         sptr<IAbilityScheduler>(const Uri& uri, bool tryBind, const sptr<IRemoteObject>& callerToken));
236     MOCK_METHOD2(
237         ReleaseDataAbility, int(sptr<IAbilityScheduler> dataAbilityScheduler, const sptr<IRemoteObject>& callerToken));
238     MOCK_METHOD2(AddWindowInfo, void(const sptr<IRemoteObject>& token, int32_t windowToken));
239     MOCK_METHOD2(AttachAbilityThread, int(const sptr<IAbilityScheduler>& scheduler, const sptr<IRemoteObject>& token));
240     MOCK_METHOD3(AbilityTransitionDone, int(const sptr<IRemoteObject>& token, int state, const PacMap&));
241     MOCK_METHOD2(
242         ScheduleConnectAbilityDone, int(const sptr<IRemoteObject>& token, const sptr<IRemoteObject>& remoteObject));
243     MOCK_METHOD1(ScheduleDisconnectAbilityDone, int(const sptr<IRemoteObject>& token));
244     MOCK_METHOD1(ScheduleCommandAbilityDone, int(const sptr<IRemoteObject>& token));
245     MOCK_METHOD4(ScheduleCommandAbilityWindowDone, int(const sptr<IRemoteObject> &token,
246         const sptr<SessionInfo> &sessionInfo, WindowCommand winCmd, AbilityCommand abilityCmd));
247     void DumpState(const std::string& args, std::vector<std::string>& state) override;
248     int StopServiceAbility(const Want& want, int32_t userId = DEFAULT_INVAL_VALUE,
249         const sptr<IRemoteObject> &token = nullptr) override;
250     MOCK_METHOD1(MoveMissionToTop, int(int32_t missionId));
251     MOCK_METHOD1(RemoveMission, int(int id));
252     MOCK_METHOD1(RemoveStack, int(int id));
253     MOCK_METHOD3(KillProcess, int(const std::string& bundleName, const bool clearPageStack, int32_t appIndex));
254     MOCK_METHOD2(UninstallApp, int(const std::string& bundleName, int32_t uid));
255     MOCK_METHOD3(UninstallApp, int32_t(const std::string& bundleName, int32_t uid, int32_t appIndex));
256     MOCK_METHOD2(MoveMissionToEnd, int(const sptr<IRemoteObject>& token, const bool nonFirst));
257     MOCK_METHOD1(IsFirstInMission, bool(const sptr<IRemoteObject>& token));
258     MOCK_METHOD4(CompelVerifyPermission, int(const std::string& permission, int pid, int uid, std::string& message));
259     MOCK_METHOD3(
260         GetWantSender, sptr<IWantSender>(const WantSenderInfo& wantSenderInfo, const sptr<IRemoteObject>& callerToken,
261         int32_t uid));
262     MOCK_METHOD2(SendWantSender, int(sptr<IWantSender> target, SenderInfo& senderInfo));
263     MOCK_METHOD1(CancelWantSender, void(const sptr<IWantSender>& sender));
264     MOCK_METHOD1(GetPendingWantUid, int(const sptr<IWantSender>& target));
265     MOCK_METHOD1(GetPendingWantUserId, int(const sptr<IWantSender>& target));
266     MOCK_METHOD1(GetPendingWantBundleName, std::string(const sptr<IWantSender>& target));
267     MOCK_METHOD1(GetPendingWantCode, int(const sptr<IWantSender>& target));
268     MOCK_METHOD1(GetPendingWantType, int(const sptr<IWantSender>& target));
269     MOCK_METHOD2(RegisterCancelListener, void(const sptr<IWantSender>& sender, const sptr<IWantReceiver>& receiver));
270     MOCK_METHOD2(UnregisterCancelListener, void(const sptr<IWantSender>& sender, const sptr<IWantReceiver>& receiver));
271     MOCK_METHOD2(GetPendingRequestWant, int(const sptr<IWantSender>& target, std::shared_ptr<Want>& want));
272     MOCK_METHOD1(LockMission, int(int));
273     MOCK_METHOD1(UnlockMission, int(int));
274     MOCK_METHOD0(GetMissionLockModeState, int());
275     MOCK_METHOD2(
276         ChangeFocusAbility, int(const sptr<IRemoteObject>& lostFocusToken, const sptr<IRemoteObject>& getFocusToken));
277     MOCK_METHOD1(MinimizeMultiWindow, int(int missionId));
278     MOCK_METHOD1(MaximizeMultiWindow, int(int missionId));
279     MOCK_METHOD1(CloseMultiWindow, int(int missionId));
280     MOCK_METHOD1(GetPendinTerminateAbilityTestgRequestWant, void(int id));
281     MOCK_METHOD1(SetShowOnLockScreen, int(bool isAllow));
282     MOCK_METHOD3(StartContinuation, int(const Want& want, const sptr<IRemoteObject>& abilityToken, int32_t status));
283     MOCK_METHOD2(NotifyContinuationResult, int(int32_t missionId, int32_t result));
284     MOCK_METHOD5(ContinueMission, int(const std::string& srcDeviceId, const std::string& dstDeviceId,
285         int32_t missionId, const sptr<IRemoteObject>& callBack, AAFwk::WantParams& wantParams));
286     MOCK_METHOD3(ContinueAbility, int(const std::string& deviceId, int32_t missionId, uint32_t versionCode));
287     MOCK_METHOD3(NotifyCompleteContinuation, void(const std::string& deviceId, int32_t sessionId, bool isSuccess));
288     MOCK_METHOD1(LockMissionForCleanup, int(int32_t missionId));
289     MOCK_METHOD1(UnlockMissionForCleanup, int(int32_t missionId));
290     MOCK_METHOD1(RegisterMissionListener, int(const sptr<IMissionListener>& listener));
291     MOCK_METHOD1(UnRegisterMissionListener, int(const sptr<IMissionListener>& listener));
292     MOCK_METHOD3(
293         GetMissionInfos, int(const std::string& deviceId, int32_t numMax, std::vector<MissionInfo>& missionInfos));
294     MOCK_METHOD3(GetMissionInfo, int(const std::string& deviceId, int32_t missionId, MissionInfo& missionInfo));
295     MOCK_METHOD1(CleanMission, int(int32_t missionId));
296     MOCK_METHOD0(CleanAllMissions, int());
297     MOCK_METHOD1(MoveMissionToFront, int(int32_t missionId));
298     MOCK_METHOD2(MoveMissionToFront, int(int32_t missionId, const StartOptions& startOptions));
299     MOCK_METHOD2(MoveMissionsToForeground, int(const std::vector<int32_t>& missionIds, int32_t topMissionId));
300     MOCK_METHOD2(MoveMissionsToBackground, int(const std::vector<int32_t>& missionIds, std::vector<int32_t>& result));
301     MOCK_METHOD1(GetAbilityRunningInfos, int(std::vector<AbilityRunningInfo>& info));
302     MOCK_METHOD2(GetExtensionRunningInfos, int(int upperLimit, std::vector<ExtensionRunningInfo>& info));
303     MOCK_METHOD1(GetProcessRunningInfos, int(std::vector<AppExecFwk::RunningProcessInfo>& info));
304     MOCK_METHOD2(GetWantSenderInfo, int(const sptr<IWantSender>& target, std::shared_ptr<WantSenderInfo>& info));
305     MOCK_METHOD2(AcquireShareData, int32_t(const int32_t &missionId, const sptr<IAcquireShareDataCallback> &shareData));
306     MOCK_METHOD4(ShareDataDone, int32_t(const sptr<IRemoteObject> &token,
307         const int32_t &resultCode, const int32_t &uniqueId, WantParams &wantParam));
308     MOCK_METHOD2(SetMissionContinueState, int(const sptr<IRemoteObject>& token, const AAFwk::ContinueState& state));
309     int StartUser(int userId, sptr<IUserCallback> callback, bool isAppRecovery) override;
310     int StopUser(int userId, const sptr<IUserCallback>& callback) override;
311     int LogoutUser(int32_t userId, sptr<IUserCallback> callback = nullptr) override;
312     int StartSyncRemoteMissions(const std::string& devId, bool fixConflict, int64_t tag) override;
313     int StopSyncRemoteMissions(const std::string& devId) override;
314     int RegisterMissionListener(const std::string& deviceId,
315         const sptr<IRemoteMissionListener>& listener) override;
316     int UnRegisterMissionListener(const std::string& deviceId,
317         const sptr<IRemoteMissionListener>& listener) override;
318     int StartAbilityByCall(const Want& want, const sptr<IAbilityConnection>& connect,
319         const sptr<IRemoteObject>& callerToken, int32_t accountId = DEFAULT_INVAL_VALUE,
320         bool isSilent = false) override;
321     void CallRequestDone(const sptr<IRemoteObject>& token, const sptr<IRemoteObject>& callStub) override;
GetForegroundUIAbilities(std::vector<AppExecFwk::AbilityStateData> & list)322     virtual int32_t GetForegroundUIAbilities(std::vector<AppExecFwk::AbilityStateData> &list)
323     {
324         return 0;
325     }
326     int ReleaseCall(const sptr<IAbilityConnection>& connect,
327         const AppExecFwk::ElementName& element) override;
328     int GetMissionSnapshot(const std::string& deviceId, int32_t missionId,
329         MissionSnapshot& snapshot, bool isLowResolution) override;
330     int RegisterSnapshotHandler(const sptr<ISnapshotHandler>& handler) override;
331     int SetAbilityController(const sptr<AppExecFwk::IAbilityController>& abilityController,
332         bool imAStabilityTest) override;
333     bool IsRunningInStabilityTest() override;
334     void DumpSysState(
335         const std::string& args, std::vector<std::string>& info, bool isClient, bool isUserID, int UserID) override;
336     int StartUserTest(const Want& want, const sptr<IRemoteObject>& observer) override;
337     int FinishUserTest(
338         const std::string& msg, const int64_t& resultCode, const std::string& bundleName) override;
339     int GetTopAbility(sptr<IRemoteObject>& token) override;
340     AppExecFwk::ElementName GetTopAbility(bool isNeedLocalDeviceId = true) override;
341     int DelegatorDoAbilityForeground(const sptr<IRemoteObject>& token) override;
342     int DelegatorDoAbilityBackground(const sptr<IRemoteObject>& token) override;
343     int32_t ReportDrawnCompleted(const sptr<IRemoteObject>& callerToken) override;
344     int DoAbilityForeground(const sptr<IRemoteObject>& token, uint32_t flag);
345     int DoAbilityBackground(const sptr<IRemoteObject>& token, uint32_t flag);
346     int32_t GetMissionIdByToken(const sptr<IRemoteObject>& token);
347     void GetAbilityTokenByCalleeObj(const sptr<IRemoteObject> &callStub, sptr<IRemoteObject> &token);
SetApplicationAutoStartupByEDM(const AutoStartupInfo & info,bool flag)348     int32_t SetApplicationAutoStartupByEDM(const AutoStartupInfo &info, bool flag) override
349     {
350         return 0;
351     }
352 
CancelApplicationAutoStartupByEDM(const AutoStartupInfo & info,bool flag)353     int32_t CancelApplicationAutoStartupByEDM(const AutoStartupInfo &info, bool flag) override
354     {
355         return 0;
356     }
357 #ifdef ABILITY_COMMAND_FOR_TEST
358     int ForceTimeoutForTest(const std::string& abilityName, const std::string& state) override;
359 #endif
360 #ifdef SUPPORT_GRAPHICS
361     MOCK_METHOD2(SetMissionLabel, int(const sptr<IRemoteObject>& token, const std::string& label));
362     int SetMissionIcon(
363         const sptr<IRemoteObject>& token, const std::shared_ptr<OHOS::Media::PixelMap>& icon) override;
364     int RegisterWindowManagerServiceHandler(const sptr<IWindowManagerServiceHandler>& handler,
365         bool animationEnabled = true);
CompleteFirstFrameDrawing(const sptr<IRemoteObject> & abilityToken)366     void CompleteFirstFrameDrawing(const sptr<IRemoteObject>& abilityToken) override {}
367 #endif
368     MOCK_METHOD2(IsValidMissionIds, int32_t(const std::vector<int32_t>&, std::vector<MissionValidResult>&));
369     MOCK_METHOD1(RegisterAppDebugListener, int32_t(sptr<AppExecFwk::IAppDebugListener> listener));
370     MOCK_METHOD1(UnregisterAppDebugListener, int32_t(sptr<AppExecFwk::IAppDebugListener> listener));
371     MOCK_METHOD2(AttachAppDebug, int32_t(const std::string &bundleName, bool isDebugFromLocal));
372     MOCK_METHOD2(DetachAppDebug, int32_t(const std::string &bundleName, bool isDebugFromLocal));
373     MOCK_METHOD3(ExecuteIntent, int32_t(uint64_t key, const sptr<IRemoteObject> &callerToken,
374         const InsightIntentExecuteParam &param));
375     MOCK_METHOD3(ExecuteInsightIntentDone, int32_t(const sptr<IRemoteObject> &token, uint64_t intentId,
376         const InsightIntentExecuteResult &result));
377     MOCK_METHOD5(StartAbilityWithSpecifyTokenId, int(const Want& want, const sptr<IRemoteObject>& callerToken,
378         uint32_t specifyTokenId, int32_t userId, int requestCode));
379 public:
380     std::string powerState_;
381     static bool finishFlag_;
382     static TESTCASE_BRANCH testcaseBranch_;
383 };
384 }  // namespace AAFwk
385 }  // namespace OHOS
386 
387 #endif  // MOCK_OHOS_ABILITY_RUNTIME_MOCK_ABILITY_DELEGATOR_STUB_H
388