1 /* 2 * Copyright (c) 2021-2022 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 MODULETEST_OHOS_ABILITY_RUNTIME_MOCK_ABILITY_MANAGER_PROXY_H 17 #define MODULETEST_OHOS_ABILITY_RUNTIME_MOCK_ABILITY_MANAGER_PROXY_H 18 19 #include "gmock/gmock.h" 20 #include "ability_manager_interface.h" 21 #include "hilog_wrapper.h" 22 #include "iremote_proxy.h" 23 24 namespace OHOS { 25 namespace AAFwk { 26 class MockAbilityManagerProxy : public IRemoteProxy<IAbilityManager> { 27 public: MockAbilityManagerProxy(const sptr<IRemoteObject> & impl)28 explicit MockAbilityManagerProxy(const sptr<IRemoteObject>& impl) : IRemoteProxy<IAbilityManager>(impl) 29 {} ~MockAbilityManagerProxy()30 virtual ~MockAbilityManagerProxy() 31 {} 32 33 MOCK_METHOD2(StartAbility, int(const Want& want, int requestCode)); 34 MOCK_METHOD3(StartAbility, int(const Want& want, const sptr<IRemoteObject>& callerToken, int requestCode)); 35 MOCK_METHOD6(StartAbilityAsCaller, int(const Want& want, const sptr<IRemoteObject>& callerToken, 36 sptr<IRemoteObject> asCallerSourceToken, int32_t userId, int requestCode, bool isSendDialogResult)); 37 MOCK_METHOD6(StartAbilityAsCaller, int(const Want &want, const StartOptions &startOptions, 38 const sptr<IRemoteObject> &callerToken, sptr<IRemoteObject> asCallerSourceToken, 39 int32_t userId, int requestCode)); 40 41 MOCK_METHOD3(TerminateAbility, int(const sptr<IRemoteObject>& token, int resultCode, const Want* resultWant)); 42 MOCK_METHOD3(ConnectAbility, 43 int(const Want& want, const sptr<IAbilityConnection>& connect, const sptr<IRemoteObject>& callerToken)); 44 MOCK_METHOD1(DisconnectAbility, int(sptr<IAbilityConnection> connect)); 45 MOCK_METHOD3(AcquireDataAbility, sptr<IAbilityScheduler>(const Uri&, bool, const sptr<IRemoteObject>&)); 46 MOCK_METHOD2(ReleaseDataAbility, int(sptr<IAbilityScheduler>, const sptr<IRemoteObject>&)); 47 MOCK_METHOD2(AttachAbilityThread, int(const sptr<IAbilityScheduler>& scheduler, const sptr<IRemoteObject>& token)); 48 MOCK_METHOD2(AbilityTransitionDone, int(const sptr<IRemoteObject>& token, int state)); 49 MOCK_METHOD2( 50 ScheduleConnectAbilityDone, int(const sptr<IRemoteObject>& token, const sptr<IRemoteObject>& remoteObject)); 51 MOCK_METHOD1(ScheduleDisconnectAbilityDone, int(const sptr<IRemoteObject>& token)); 52 MOCK_METHOD1(ScheduleCommandAbilityDone, int(const sptr<IRemoteObject>&)); 53 MOCK_METHOD4(ScheduleCommandAbilityWindowDone, int(const sptr<IRemoteObject> &token, 54 const sptr<SessionInfo> &sessionInfo, WindowCommand winCmd, AbilityCommand abilityCmd)); 55 MOCK_METHOD2(DumpState, void(const std::string& args, std::vector<std::string>& state)); 56 MOCK_METHOD3(StopServiceAbility, int(const Want&, int32_t userId, const sptr<IRemoteObject> &token)); 57 MOCK_METHOD1(GetMissionIdByToken, int32_t(const sptr<IRemoteObject>& token)); 58 MOCK_METHOD1(KillProcess, int(const std::string&)); 59 MOCK_METHOD2(UninstallApp, int(const std::string&, int32_t)); 60 MOCK_METHOD4(OnRemoteRequest, int(uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option)); 61 MOCK_METHOD3(StartAbility, int(const Want& want, const sptr<IRemoteObject>& callerToken, int requestCode)); 62 MOCK_METHOD2( 63 GetWantSender, sptr<IWantSender>(const WantSenderInfo& wantSenderInfo, const sptr<IRemoteObject>& callerToken)); 64 MOCK_METHOD2(SendWantSender, int(sptr<IWantSender> target, const SenderInfo& senderInfo)); 65 MOCK_METHOD1(CancelWantSender, void(const sptr<IWantSender>& sender)); 66 MOCK_METHOD1(GetPendingWantUid, int(const sptr<IWantSender>& target)); 67 MOCK_METHOD1(GetPendingWantBundleName, std::string(const sptr<IWantSender>& target)); 68 MOCK_METHOD1(GetPendingWantCode, int(const sptr<IWantSender>& target)); 69 MOCK_METHOD1(GetPendingWantType, int(const sptr<IWantSender>& target)); 70 MOCK_METHOD2(RegisterCancelListener, void(const sptr<IWantSender>& sender, const sptr<IWantReceiver>& receiver)); 71 MOCK_METHOD2(UnregisterCancelListener, void(const sptr<IWantSender>& sender, const sptr<IWantReceiver>& receiver)); 72 MOCK_METHOD2(GetPendingRequestWant, int(const sptr<IWantSender>& target, std::shared_ptr<Want>& want)); 73 74 MOCK_METHOD1(GetPendingWantUserId, int(const sptr<IWantSender>& target)); 75 MOCK_METHOD2(AcquireShareData, int32_t(const int32_t &missionId, const sptr<IAcquireShareDataCallback> &shareData)); 76 MOCK_METHOD4(ShareDataDone, int32_t(const sptr<IRemoteObject> &token, 77 const int32_t &resultCode, const int32_t &uniqueId, WantParams &wantParam)); SetAbilityController(const sptr<AppExecFwk::IAbilityController> & abilityController,bool imAStabilityTest)78 virtual int SetAbilityController(const sptr<AppExecFwk::IAbilityController>& abilityController, 79 bool imAStabilityTest) override 80 { 81 return 0; 82 } 83 IsRunningInStabilityTest()84 virtual bool IsRunningInStabilityTest() override 85 { 86 return true; 87 } 88 89 public: 90 int id_; 91 }; 92 } // namespace AAFwk 93 } // namespace OHOS 94 #endif // MODULETEST_OHOS_ABILITY_RUNTIME_MOCK_ABILITY_MANAGER_PROXY_H 95