/* * Copyright (c) 2022-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef OHOS_ABILITY_RUNTIME_MOCK_ABILITY_MANAGER_STUB_H #define OHOS_ABILITY_RUNTIME_MOCK_ABILITY_MANAGER_STUB_H #include "gmock/gmock.h" #include "string_ex.h" #include "ability_manager_errors.h" #include "ability_manager_stub.h" namespace OHOS { namespace AAFwk { class MockAbilityManagerStub : public AbilityManagerStub { public: int StartAbility(const Want& want, int32_t userId = DEFAULT_INVAL_VALUE, int requestCode = -1); MOCK_METHOD4(StartAbility, int(const Want& want, const sptr& callerToken, int32_t userId, int requestCode)); MOCK_METHOD5(StartAbilityAsCaller, int(const Want &want, const sptr &callerToken, sptr asCallerSourceToken, int32_t userId, int requestCode)); MOCK_METHOD3(TerminateAbility, int(const sptr& token, int resultCode, const Want* resultWant)); MOCK_METHOD3(TerminateUIExtensionAbility, int(const sptr &extensionSessionInfo, int resultCode, const Want* resultWant)); int CloseAbility(const sptr& token, int resultCode = DEFAULT_INVAL_VALUE, const Want* resultWant = nullptr) override { return 0; } int MinimizeAbility(const sptr& token, bool fromUser = false) override { return 0; } int MinimizeUIExtensionAbility(const sptr &extensionSessionInfo, bool fromUser = false) override { return 0; } MOCK_METHOD4(ConnectAbility, int(const Want& want, const sptr& connect, const sptr& callerToken, int32_t userId)); MOCK_METHOD1(DisconnectAbility, int(sptr connect)); MOCK_METHOD3(AcquireDataAbility, sptr(const Uri& uri, bool tryBind, const sptr& callerToken)); MOCK_METHOD2( ReleaseDataAbility, int(sptr dataAbilityScheduler, const sptr& callerToken)); MOCK_METHOD2(AttachAbilityThread, int(const sptr& scheduler, const sptr& token)); MOCK_METHOD3(AbilityTransitionDone, int(const sptr& token, int state, const PacMap&)); MOCK_METHOD2( ScheduleConnectAbilityDone, int(const sptr& token, const sptr& remoteObject)); MOCK_METHOD1(ScheduleDisconnectAbilityDone, int(const sptr& token)); MOCK_METHOD1(ScheduleCommandAbilityDone, int(const sptr& token)); MOCK_METHOD4(ScheduleCommandAbilityWindowDone, int(const sptr &token, const sptr &sessionInfo, WindowCommand winCmd, AbilityCommand abilityCmd)); void DumpState(const std::string& args, std::vector& state); int StopServiceAbility(const Want& want, int32_t userId = DEFAULT_INVAL_VALUE, const sptr &token = nullptr); MOCK_METHOD2(KillProcess, int(const std::string& bundleName, const bool clearPageStack)); MOCK_METHOD2(UninstallApp, int(const std::string& bundleName, int32_t uid)); MOCK_METHOD3(UninstallApp, int32_t(const std::string& bundleName, int32_t uid, int32_t appIndex)); MOCK_METHOD3( GetWantSender, sptr(const WantSenderInfo& wantSenderInfo, const sptr& callerToken, int32_t uid)); MOCK_METHOD2(SendWantSender, int(sptr target, const SenderInfo& senderInfo)); MOCK_METHOD1(CancelWantSender, void(const sptr& sender)); MOCK_METHOD1(GetPendingWantUid, int(const sptr& target)); MOCK_METHOD1(GetPendingWantUserId, int(const sptr& target)); MOCK_METHOD1(GetPendingWantBundleName, std::string(const sptr& target)); MOCK_METHOD1(GetPendingWantCode, int(const sptr& target)); MOCK_METHOD1(GetPendingWantType, int(const sptr& target)); MOCK_METHOD2(RegisterCancelListener, void(const sptr& sender, const sptr& receiver)); MOCK_METHOD2(UnregisterCancelListener, void(const sptr& sender, const sptr& receiver)); MOCK_METHOD2(GetPendingRequestWant, int(const sptr& target, std::shared_ptr& want)); MOCK_METHOD5(StartAbility, int(const Want& want, const AbilityStartSetting& abilityStartSetting, const sptr& callerToken, int32_t userId, int requestCode)); MOCK_METHOD4(StartAbilityByInsightIntent, int32_t(const Want& want, const sptr& callerToken, uint64_t intentId, int32_t userId)); MOCK_METHOD1(GetMissionIdByToken, int32_t(const sptr& token)); MOCK_METHOD1(GetPendinTerminateAbilityTestgRequestWant, void(int id)); MOCK_METHOD3(StartContinuation, int(const Want& want, const sptr& abilityToken, int32_t status)); MOCK_METHOD2(NotifyContinuationResult, int(int32_t missionId, int32_t result)); MOCK_METHOD5(ContinueMission, int(const std::string& srcDeviceId, const std::string& dstDeviceId, int32_t missionId, const sptr& callBack, AAFwk::WantParams& wantParams)); MOCK_METHOD3(ContinueAbility, int(const std::string& deviceId, int32_t missionId, uint32_t versionCode)); MOCK_METHOD3(NotifyCompleteContinuation, void(const std::string& deviceId, int32_t sessionId, bool isSuccess)); MOCK_METHOD1(LockMissionForCleanup, int(int32_t missionId)); MOCK_METHOD1(UnlockMissionForCleanup, int(int32_t missionId)); MOCK_METHOD1(RegisterMissionListener, int(const sptr& listener)); MOCK_METHOD1(UnRegisterMissionListener, int(const sptr& listener)); MOCK_METHOD3( GetMissionInfos, int(const std::string& deviceId, int32_t numMax, std::vector& missionInfos)); MOCK_METHOD3(GetMissionInfo, int(const std::string& deviceId, int32_t missionId, MissionInfo& missionInfo)); MOCK_METHOD1(CleanMission, int(int32_t missionId)); MOCK_METHOD0(CleanAllMissions, int()); MOCK_METHOD1(MoveMissionToFront, int(int32_t missionId)); MOCK_METHOD2(MoveMissionToFront, int(int32_t missionId, const StartOptions& startOptions)); MOCK_METHOD2(MoveMissionsToForeground, int(const std::vector& missionIds, int32_t topMissionId)); MOCK_METHOD2(MoveMissionsToBackground, int(const std::vector& missionIds, std::vector& result)); MOCK_METHOD2(SetMissionContinueState, int(const sptr& token, const AAFwk::ContinueState& state)); MOCK_METHOD2(SetMissionLabel, int(const sptr& token, const std::string& label)); MOCK_METHOD2(SetMissionIcon, int(const sptr& token, const std::shared_ptr& icon)); MOCK_METHOD1(GetAbilityRunningInfos, int(std::vector& info)); MOCK_METHOD2(GetExtensionRunningInfos, int(int upperLimit, std::vector& info)); MOCK_METHOD1(GetProcessRunningInfos, int(std::vector& info)); MOCK_METHOD2(GetWantSenderInfo, int(const sptr& target, std::shared_ptr& info)); MOCK_METHOD2(AcquireShareData, int32_t(const int32_t &missionId, const sptr &shareData)); MOCK_METHOD4(ShareDataDone, int32_t(const sptr &token, const int32_t &resultCode, const int32_t &uniqueId, WantParams &wantParam)); MOCK_METHOD2(GetAbilityTokenByCalleeObj, void(const sptr &callStub, sptr &token)); virtual int StartAbility( const Want& want, const StartOptions& startOptions, const sptr& callerToken, int32_t userId = DEFAULT_INVAL_VALUE, int requestCode = DEFAULT_INVAL_VALUE) { return 0; } virtual int StartAbilityAsCaller( const Want& want, const StartOptions& startOptions, const sptr& callerToken, sptr asCallerSourceToken, int32_t userId = DEFAULT_INVAL_VALUE, int requestCode = DEFAULT_INVAL_VALUE) { return 0; } int StartUser(int userId, sptr callback) override { return 0; } int StopUser(int userId, const sptr& callback) override { return 0; } int LogoutUser(int32_t userId) override { return 0; } int StartSyncRemoteMissions(const std::string& devId, bool fixConflict, int64_t tag) override { return 0; } int StopSyncRemoteMissions(const std::string& devId) override { return 0; } int RegisterMissionListener(const std::string& deviceId, const sptr& listener) override { return 0; } int UnRegisterMissionListener(const std::string& deviceId, const sptr& listener) override { return 0; } int32_t ReportDrawnCompleted(const sptr& callerToken) override { return 0; } virtual int StartAbilityByCall(const Want& want, const sptr& connect, const sptr& callerToken, int32_t userId = DEFAULT_INVAL_VALUE) { return 0; } virtual int ReleaseCall(const sptr& connect, const AppExecFwk::ElementName& element) { return 0; } virtual int GetMissionSnapshot(const std::string& deviceId, int32_t missionId, MissionSnapshot& snapshot, bool isLowResolution) { return 0; } virtual int RegisterSnapshotHandler(const sptr& handler) { return 0; } int RegisterWindowManagerServiceHandler(const sptr& handler, bool animationEnabled = true) override { return 0; } virtual int32_t GetForegroundUIAbilities(std::vector &list) { return 0; } void CompleteFirstFrameDrawing(const sptr& abilityToken) override {} int SetAbilityController(const sptr& abilityController, bool imAStabilityTest) override { return 0; } bool IsRunningInStabilityTest() override { return true; } void DumpSysState( const std::string& args, std::vector& info, bool isClient, bool isUserID, int UserID) override {} MOCK_METHOD2(StartUserTest, int(const Want& want, const sptr& observer)); int FinishUserTest( const std::string& msg, const int64_t& resultCode, const std::string& bundleName) override { return 0; } int GetTopAbility(sptr& token) override { return 0; } int DelegatorDoAbilityForeground(const sptr& token) override { return 0; } int DelegatorDoAbilityBackground(const sptr& token) override { return 0; } int32_t SetApplicationAutoStartupByEDM(const AutoStartupInfo &info, bool flag) override { return 0; } int32_t CancelApplicationAutoStartupByEDM(const AutoStartupInfo &info, bool flag) override { return 0; } #ifdef ABILITY_COMMAND_FOR_TEST MOCK_METHOD2(ForceTimeoutForTest, int(const std::string& abilityName, const std::string& state)); #endif MOCK_METHOD2(IsValidMissionIds, int32_t(const std::vector&, std::vector&)); MOCK_METHOD1(RegisterAppDebugListener, int32_t(sptr listener)); MOCK_METHOD1(UnregisterAppDebugListener, int32_t(sptr listener)); MOCK_METHOD1(AttachAppDebug, int32_t(const std::string &bundleName)); MOCK_METHOD1(DetachAppDebug, int32_t(const std::string &bundleName)); MOCK_METHOD3(ExecuteIntent, int32_t(uint64_t key, const sptr &callerToken, const InsightIntentExecuteParam ¶m)); MOCK_METHOD3(ExecuteInsightIntentDone, int32_t(const sptr &token, uint64_t intentId, const InsightIntentExecuteResult &result)); MOCK_METHOD5(StartAbilityWithSpecifyTokenId, int(const Want& want, const sptr& callerToken, uint32_t specifyTokenId, int32_t userId, int requestCode)); public: std::string powerState_; }; } // namespace AAFwk } // namespace OHOS #endif // OHOS_ABILITY_RUNTIME_MOCK_ABILITY_MANAGER_STUB_H