• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
16 #ifndef MOCK_DISTRIBUTED_SCHED_H
17 #define MOCK_DISTRIBUTED_SCHED_H
18 
19 #include "distributed_sched_stub.h"
20 
21 namespace OHOS {
22 namespace DistributedSchedule {
23 class MockDistributedSched : public DistributedSchedStub {
24 public:
25     explicit MockDistributedSched(bool expectedTrue = false)
26     {
27         expectedTrue_ = expectedTrue;
28     }
29     ~MockDistributedSched() = default;
30 
31     int32_t StartRemoteAbility(const OHOS::AAFwk::Want& want, int32_t callerUid, int32_t requestCode,
32         uint32_t accessToken) override;
33     int32_t StartAbilityFromRemote(const OHOS::AAFwk::Want& want,
34         const OHOS::AppExecFwk::AbilityInfo& abilityInfo, int32_t requestCode, const CallerInfo& callerInfo,
35         const AccountInfo& accountInfo) override;
36     int32_t SendResultFromRemote(OHOS::AAFwk::Want& want, int32_t requestCode, const CallerInfo& callerInfo,
37         const AccountInfo& accountInfo, int32_t resultCode) override;
38     int32_t ContinueMission(const std::string& srcDeviceId, const std::string& dstDeviceId, int32_t missionId,
39         const sptr<IRemoteObject>& callback, const OHOS::AAFwk::WantParams& wantParams) override;
40     int32_t StartContinuation(const OHOS::AAFwk::Want& want, int32_t missionId, int32_t callerUid,
41         int32_t status, uint32_t accessToken) override;
42     void NotifyCompleteContinuation(const std::u16string& devId, int32_t sessionId, bool isSuccess) override;
43     int32_t NotifyContinuationResultFromRemote(int32_t sessionId, bool isSuccess, const std::string dstInfo) override;
44     int32_t ConnectRemoteAbility(const OHOS::AAFwk::Want& want, const sptr<IRemoteObject>& connect,
45         int32_t callerUid, int32_t callerPid, uint32_t accessToken) override;
46     int32_t DisconnectRemoteAbility(const sptr<IRemoteObject>& connect, int32_t callerUid,
47         uint32_t accessToken) override;
48     int32_t ConnectAbilityFromRemote(const OHOS::AAFwk::Want& want, const AppExecFwk::AbilityInfo& abilityInfo,
49         const sptr<IRemoteObject>& connect, const CallerInfo& callerInfo, const AccountInfo& accountInfo) override;
50     int32_t DisconnectAbilityFromRemote(const sptr<IRemoteObject>& connect,
51         int32_t uid, const std::string& sourceDeviceId) override;
52     int32_t NotifyProcessDiedFromRemote(const CallerInfo& callerInfo) override;
53 #ifdef SUPPORT_DISTRIBUTED_MISSION_MANAGER
54     int32_t StartSyncRemoteMissions(const std::string& devId, bool fixConflict, int64_t tag,
55         int32_t callingUid) override;
56     int32_t RegisterMissionListener(const std::u16string& devId, const sptr<IRemoteObject>& obj,
57         int32_t callingUid) override;
58     int32_t UnRegisterMissionListener(const std::u16string& devId, const sptr<IRemoteObject>& obj) override;
59     int32_t GetMissionInfos(const std::string& deviceId, int32_t numMissions,
60         std::vector<AAFwk::MissionInfo>& missionInfos) override;
61     int32_t GetRemoteMissionSnapshotInfo(const std::string& networkId, int32_t missionId,
62         std::unique_ptr<AAFwk::MissionSnapshot>& missionSnapshot) override;
63     int32_t NotifyMissionsChangedFromRemote(const std::vector<DstbMissionInfo>& missionInfos,
64         const CallerInfo& callerInfo) override;
65     int32_t StartSyncMissionsFromRemote(const CallerInfo& callerInfo,
66         std::vector<DstbMissionInfo>& missionInfos) override;
67     int32_t StopSyncMissionsFromRemote(const CallerInfo& callerInfo) override;
68     int32_t StopSyncRemoteMissions(const std::string& devId, int32_t callingUid) override;
69     int32_t SetMissionContinueState(const int32_t missionId, const OHOS::AAFwk::ContinueState &state,
70         int32_t callingUid) override;
71 #endif
72     int32_t StartRemoteAbilityByCall(const OHOS::AAFwk::Want& want, const sptr<IRemoteObject>& connect,
73         int32_t callerUid, int32_t callerPid, uint32_t accessToken) override;
74     int32_t ReleaseRemoteAbility(const sptr<IRemoteObject>& connect,
75         const AppExecFwk::ElementName &element) override;
76     int32_t StartAbilityByCallFromRemote(const OHOS::AAFwk::Want& want, const sptr<IRemoteObject>& connect,
77         const CallerInfo& callerInfo, const AccountInfo& accountInfo) override;
78     int32_t ReleaseAbilityFromRemote(const sptr<IRemoteObject>& connect, const AppExecFwk::ElementName &element,
79         const CallerInfo& callerInfo) override;
80     int32_t NotifyStateChangedFromRemote(int32_t abilityState, int32_t missionId,
81         const AppExecFwk::ElementName& element) override;
82     int32_t GetDistributedComponentList(std::vector<std::string>& distributedComponents) override;
83 #ifdef SUPPORT_DISTRIBUTED_FORM_SHARE
84     int32_t StartRemoteShareForm(const std::string& remoteDeviceId,
85         const OHOS::AppExecFwk::FormShareInfo& formShareInfo) override;
86     int32_t StartShareFormFromRemote(
87         const std::string& remoteDeviceId, const OHOS::AppExecFwk::FormShareInfo& formShareInfo) override;
88 #endif
89     int32_t StartRemoteFreeInstall(const OHOS::AAFwk::Want& want, int32_t callerUid, int32_t requestCode,
90         uint32_t accessToken, const sptr<IRemoteObject>& callback) override;
91     int32_t StartFreeInstallFromRemote(const FreeInstallInfo& info, int64_t taskId) override;
92     int32_t NotifyCompleteFreeInstallFromRemote(int64_t taskId, int32_t resultCode) override;
93     int32_t NotifyCompleteFreeInstall(const FreeInstallInfo& info, int64_t taskId, int32_t resultCode);
94     int32_t StopRemoteExtensionAbility(
95         const OHOS::AAFwk::Want& want, int32_t callerUid, uint32_t accessToken, int32_t extensionType) override;
96     int32_t StopExtensionAbilityFromRemote(const OHOS::AAFwk::Want& want,
97         const CallerInfo& callerInfo, const AccountInfo& accountInfo, int32_t extensionType) override;
98 #ifdef DMSFWK_INTERACTIVE_ADAPTER
99     bool CheckRemoteOsType(const std::string& netwokId) override;
100     int32_t StartRemoteAbilityAdapter(const OHOS::AAFwk::Want& want, int32_t callerUid, int32_t requestCode,
101         uint32_t accessToken);
102     int32_t ConnectRemoteAbilityAdapter(const OHOS::AAFwk::Want& want, const sptr<IRemoteObject>& connect,
103         int32_t callerUid, int32_t callerPid, uint32_t accessToken);
104     int32_t StartAbilityFromRemoteAdapter(MessageParcel& data, MessageParcel& reply) override;
105     int32_t StopAbilityFromRemoteAdapter(MessageParcel& data, MessageParcel& reply) override;
106     int32_t ConnectAbilityFromRemoteAdapter(MessageParcel& data, MessageParcel& reply) override;
107     int32_t DisconnectAbilityFromRemoteAdapter(MessageParcel& data, MessageParcel& reply) override;
108     int32_t NotifyAbilityLifecycleChangedFromRemoteAdapter(MessageParcel& data, MessageParcel& reply) override;
109 #endif
110 
111 private:
112     bool expectedTrue_ = false;
113 };
114 } // namespace DistributedSchedule
115 } // namespace OHOS
116 
117 #endif // MOCK_DISTRIBUTED_SCHED_H
118