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_APP_MGR_CLIENT_H 17 #define MODULETEST_OHOS_ABILITY_RUNTIME_MOCK_APP_MGR_CLIENT_H 18 19 #include <gmock/gmock.h> 20 #include "app_mgr_client.h" 21 #include "param.h" 22 23 namespace OHOS { 24 namespace AppExecFwk { 25 class AppMgrClientMock : public AppMgrClient { 26 public: 27 DECLARE_INTERFACE_DESCRIPTOR(u"AppMgrClientMock"); AppMgrClientMock()28 AppMgrClientMock() 29 {} ~AppMgrClientMock()30 virtual ~AppMgrClientMock() 31 {} 32 MOCK_METHOD0(ConnectAppMgrService, AppMgrResultCode()); 33 MOCK_METHOD1(RegisterAppStateCallback, AppMgrResultCode(const sptr<IAppStateCallback> &callback)); 34 MOCK_METHOD4(LoadAbility, AppMgrResultCode(const AbilityInfo&, const ApplicationInfo&, 35 const AAFwk::Want&, AbilityRuntime::LoadParam)); 36 MOCK_METHOD2(TerminateAbility, AppMgrResultCode(const sptr<IRemoteObject>&, bool)); 37 MOCK_METHOD2(UpdateExtensionState, AppMgrResultCode(const sptr<IRemoteObject> &token, const ExtensionState state)); 38 MOCK_METHOD4(UpdateApplicationInfoInstalled, AppMgrResultCode(const std::string &bundleName, const int uid, 39 const std::string&, bool)); 40 MOCK_METHOD0(UpdateApplicationInfoInstalledDone, AppMgrResultCode()); 41 MOCK_METHOD1(VerifyKillProcessPermission, int32_t(const std::string &bundleName)); 42 MOCK_METHOD3(KillApplication, AppMgrResultCode(const std::string&, const bool clearPageStack, int32_t appIndex)); 43 MOCK_METHOD3(KillApplicationByUid, 44 AppMgrResultCode(const std::string &bundleName, const int uid, const std::string&)); 45 MOCK_METHOD3(ClearUpApplicationData, AppMgrResultCode(const std::string&, int32_t appCloneIndex, int32_t userId)); 46 MOCK_METHOD1(StartupResidentProcess, void(const std::vector<AppExecFwk::BundleInfo> &bundleInfos)); 47 MOCK_METHOD3(StartSpecifiedAbility, void(const AAFwk::Want&, const AppExecFwk::AbilityInfo&, int32_t)); 48 MOCK_METHOD1(GetAllRunningProcesses, AppMgrResultCode(std::vector<RunningProcessInfo> &info)); 49 MOCK_METHOD1(GetAllRenderProcesses, AppMgrResultCode(std::vector<RenderProcessInfo> &info)); 50 MOCK_METHOD1(GetAllChildrenProcesses, AppMgrResultCode(std::vector<ChildProcessInfo> &info)); 51 MOCK_METHOD2(GetProcessRunningInfosByUserId, AppMgrResultCode( 52 std::vector<RunningProcessInfo> &info, int32_t userId)); 53 MOCK_METHOD4(StartUserTestProcess, int( 54 const AAFwk::Want &want, const sptr<IRemoteObject> &observer, const BundleInfo &bundleInfo, int32_t userId)); 55 MOCK_METHOD3(FinishUserTest, int( 56 const std::string &msg, const int64_t &resultCode, const std::string &bundleName)); 57 MOCK_METHOD2(UpdateConfiguration, AppMgrResultCode(const Configuration &config, const int32_t userId)); 58 MOCK_METHOD1(GetConfiguration, AppMgrResultCode(Configuration& config)); 59 MOCK_METHOD2(GetAbilityRecordsByProcessID, int( 60 const int pid, std::vector<sptr<IRemoteObject>> &tokens)); 61 }; 62 } // namespace AppExecFwk 63 } // namespace OHOS 64 #endif // MODULETEST_OHOS_ABILITY_RUNTIME_MOCK_APP_MGR_CLIENT_H 65