1 /* 2 * Copyright (c) 2025 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 BASE_POWERMGR_BATTERY_MOCK_SA_MANAGER 17 #define BASE_POWERMGR_BATTERY_MOCK_SA_MANAGER 18 #include <gmock/gmock.h> 19 #include <gtest/gtest.h> 20 #include "if_system_ability_manager.h" 21 #include "iremote_object.h" 22 #include "iremote_stub.h" 23 24 namespace OHOS { 25 class MockSystemAbilityManager : public IRemoteStub<ISystemAbilityManager> { 26 public: MockSystemAbilityManager()27 MockSystemAbilityManager() {}; ~MockSystemAbilityManager()28 virtual ~MockSystemAbilityManager() {}; 29 30 MOCK_METHOD1(ListSystemAbilities, std::vector<std::u16string>(unsigned int)); 31 MOCK_METHOD1(GetSystemAbility, sptr<IRemoteObject>(int32_t)); 32 MOCK_METHOD2(GetSystemAbility, sptr<IRemoteObject>(int32_t, const std::string &)); 33 MOCK_METHOD1(CheckSystemAbility, sptr<IRemoteObject>(int32_t)); 34 MOCK_METHOD2(CheckSystemAbility, sptr<IRemoteObject>(int32_t, const std::string &)); 35 MOCK_METHOD2(CheckSystemAbility, sptr<IRemoteObject>(int32_t, bool &)); 36 MOCK_METHOD1(RemoveSystemAbility, int32_t(int32_t)); 37 MOCK_METHOD2(SubscribeSystemAbility, int32_t(int32_t, const sptr<ISystemAbilityStatusChange> &)); 38 MOCK_METHOD2(UnSubscribeSystemAbility, int32_t(int32_t, const sptr<ISystemAbilityStatusChange> &)); 39 MOCK_METHOD2(AddOnDemandSystemAbilityInfo, int32_t(int32_t, const std::u16string &)); 40 MOCK_METHOD3(AddSystemAbility, int32_t(int32_t, const sptr<IRemoteObject> &, const SAExtraProp &)); 41 MOCK_METHOD2(AddSystemProcess, int32_t(const std::u16string &, const sptr<IRemoteObject> &)); 42 MOCK_METHOD2(LoadSystemAbility, sptr<IRemoteObject>(int32_t, int32_t)); 43 MOCK_METHOD2(LoadSystemAbility, int32_t(int32_t, const sptr<ISystemAbilityLoadCallback> &)); 44 MOCK_METHOD3(LoadSystemAbility, int32_t(int32_t, const std::string &, const sptr<ISystemAbilityLoadCallback> &)); 45 MOCK_METHOD1(UnloadSystemAbility, int32_t(int32_t)); 46 MOCK_METHOD1(CancelUnloadSystemAbility, int32_t(int32_t)); 47 MOCK_METHOD1(GetRunningSystemProcess, int32_t(std::list<SystemProcessInfo> &)); 48 MOCK_METHOD1(SubscribeSystemProcess, int32_t(const sptr<ISystemProcessStatusChange> &)); 49 MOCK_METHOD4(SendStrategy, int32_t(int32_t, std::vector<int32_t> &, int32_t, std::string &)); 50 MOCK_METHOD1(UnSubscribeSystemProcess, int32_t(const sptr<ISystemProcessStatusChange> &)); 51 MOCK_METHOD2(GetOnDemandReasonExtraData, int32_t(int64_t, MessageParcel &)); 52 MOCK_METHOD2(GetSystemProcessInfo, int32_t(int32_t, SystemProcessInfo &)); 53 MOCK_METHOD3(GetOnDemandPolicy, int32_t(int32_t, OnDemandPolicyType, std::vector<SystemAbilityOnDemandEvent> &)); 54 MOCK_METHOD3( 55 UpdateOnDemandPolicy, int32_t(int32_t, OnDemandPolicyType, const std::vector<SystemAbilityOnDemandEvent> &)); 56 MOCK_METHOD1(GetOnDemandSystemAbilityIds, int32_t(std::vector<int32_t> &)); 57 MOCK_METHOD0(UnloadAllIdleSystemAbility, int32_t()); 58 MOCK_METHOD2(GetExtensionSaIds, int32_t(const std::string&, std::vector<int32_t> &)); 59 MOCK_METHOD2(GetExtensionRunningSaList, int32_t(const std::string&, std::vector<sptr<IRemoteObject>>&)); 60 MOCK_METHOD2(GetRunningSaExtensionInfoList, int32_t(const std::string&, std::vector<SaExtensionInfo>&)); 61 MOCK_METHOD3(GetCommonEventExtraDataIdlist, int32_t(int32_t, std::vector<int64_t>&, const std::string&)); 62 private: 63 sptr<IRemoteObject> remoteObj_; 64 }; 65 66 class SystemAbilityManagerClient { 67 public: 68 static SystemAbilityManagerClient& GetInstance(); 69 MOCK_METHOD0(GetSystemAbilityManager, sptr<ISystemAbilityManager>()); 70 private: 71 sptr<MockSystemAbilityManager> MockSystemAbilityManager_; 72 }; 73 } 74 #endif