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_METHOD2(TerminateAbilityByCaller, int(const sptr<IRemoteObject> &callerToken, int requestCode)); 36 MOCK_METHOD3(TerminateAbility, int(const sptr<IRemoteObject> &token, int resultCode, const Want *resultWant)); 37 MOCK_METHOD3(ConnectAbility, 38 int(const Want &want, const sptr<IAbilityConnection> &connect, const sptr<IRemoteObject> &callerToken)); 39 MOCK_METHOD1(DisconnectAbility, int(const sptr<IAbilityConnection> &connect)); 40 MOCK_METHOD3(AcquireDataAbility, sptr<IAbilityScheduler>(const Uri &, bool, const sptr<IRemoteObject> &)); 41 MOCK_METHOD2(ReleaseDataAbility, int(sptr<IAbilityScheduler>, const sptr<IRemoteObject> &)); 42 MOCK_METHOD2(AttachAbilityThread, int(const sptr<IAbilityScheduler> &scheduler, const sptr<IRemoteObject> &token)); 43 MOCK_METHOD2(AbilityTransitionDone, int(const sptr<IRemoteObject> &token, int state)); 44 MOCK_METHOD2( 45 ScheduleConnectAbilityDone, int(const sptr<IRemoteObject> &token, const sptr<IRemoteObject> &remoteObject)); 46 MOCK_METHOD1(ScheduleDisconnectAbilityDone, int(const sptr<IRemoteObject> &token)); 47 MOCK_METHOD1(ScheduleCommandAbilityDone, int(const sptr<IRemoteObject> &)); 48 MOCK_METHOD2(DumpState, void(const std::string &args, std::vector<std::string> &state)); 49 MOCK_METHOD2(TerminateAbilityResult, int(const sptr<IRemoteObject> &, int startId)); 50 MOCK_METHOD1(StopServiceAbility, int(const Want &)); 51 MOCK_METHOD1(GetMissionIdByToken, int32_t(const sptr<IRemoteObject> &token)); 52 MOCK_METHOD1(KillProcess, int(const std::string &)); 53 MOCK_METHOD2(UninstallApp, int(const std::string &, int32_t)); 54 MOCK_METHOD4(OnRemoteRequest, int(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option)); 55 MOCK_METHOD2(TerminateAbilityByCaller, int(const sptr<IRemoteObject> &callerToken, int requestCode)); 56 MOCK_METHOD3(StartAbility, int(const Want &want, const sptr<IRemoteObject> &callerToken, int requestCode)); 57 MOCK_METHOD2( 58 GetWantSender, sptr<IWantSender>(const WantSenderInfo &wantSenderInfo, const sptr<IRemoteObject> &callerToken)); 59 MOCK_METHOD2(SendWantSender, int(const sptr<IWantSender> &target, const SenderInfo &senderInfo)); 60 MOCK_METHOD1(CancelWantSender, void(const sptr<IWantSender> &sender)); 61 MOCK_METHOD1(GetPendingWantUid, int(const sptr<IWantSender> &target)); 62 MOCK_METHOD1(GetPendingWantBundleName, std::string(const sptr<IWantSender> &target)); 63 MOCK_METHOD1(GetPendingWantCode, int(const sptr<IWantSender> &target)); 64 MOCK_METHOD1(GetPendingWantType, int(const sptr<IWantSender> &target)); 65 MOCK_METHOD2(RegisterCancelListener, void(const sptr<IWantSender> &sender, const sptr<IWantReceiver> &receiver)); 66 MOCK_METHOD2(UnregisterCancelListener, void(const sptr<IWantSender> &sender, const sptr<IWantReceiver> &receiver)); 67 MOCK_METHOD2(GetPendingRequestWant, int(const sptr<IWantSender> &target, std::shared_ptr<Want> &want)); 68 69 MOCK_METHOD1(GetPendingWantUserId, int(const sptr<IWantSender> &target)); 70 SetAbilityController(const sptr<AppExecFwk::IAbilityController> & abilityController,bool imAStabilityTest)71 virtual int SetAbilityController(const sptr<AppExecFwk::IAbilityController> &abilityController, 72 bool imAStabilityTest) override 73 { 74 return 0; 75 } 76 IsRunningInStabilityTest()77 virtual bool IsRunningInStabilityTest() override 78 { 79 return true; 80 } 81 82 public: 83 int id_; 84 }; 85 } // namespace AAFwk 86 } // namespace OHOS 87 #endif // MODULETEST_OHOS_ABILITY_RUNTIME_MOCK_ABILITY_MANAGER_PROXY_H 88