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 OHOS_DISTRIBUTED_HARDWARE_MOCK_COMPONENT_MANAGER_H 17 #define OHOS_DISTRIBUTED_HARDWARE_MOCK_COMPONENT_MANAGER_H 18 19 #include <string> 20 #include <gmock/gmock.h> 21 22 #include "component_manager.h" 23 #include "component_loader.h" 24 namespace OHOS { 25 namespace DistributedHardware { 26 class IComponentManager { 27 public: 28 virtual int32_t CheckDemandStart(const std::string &uuid, const DHType dhType, bool &enableSource) = 0; 29 virtual int32_t ForceDisableSink(const DHDescriptor &dhDescriptor) = 0; 30 virtual int32_t ForceDisableSource(const std::string &networkId, const DHDescriptor &dhDescriptor) = 0; 31 virtual int32_t EnableSink(const DHDescriptor &dhDescriptor, int32_t callingUid, int32_t callingPid) = 0; 32 virtual int32_t EnableSource(const std::string &networkId, 33 const DHDescriptor &dhDescriptor, int32_t callingUid, int32_t callingPid) = 0; 34 virtual int32_t DisableSink(const DHDescriptor &dhDescriptor, int32_t callingUid, int32_t callingPid) = 0; 35 virtual int32_t DisableSource(const std::string &networkId, 36 const DHDescriptor &dhDescriptor, int32_t callingUid, int32_t callingPid) = 0; 37 virtual int32_t CheckSinkConfigStart(const DHType dhType, bool &enableSink) = 0; 38 39 static std::shared_ptr<IComponentManager> GetOrCreateInstance(); 40 static void ReleaseInstance(); 41 public: 42 static std::shared_ptr<IComponentManager> componentManager_; 43 }; 44 45 class MockComponentManager : public IComponentManager { 46 public: 47 virtual ~MockComponentManager() = default; 48 MOCK_METHOD(int32_t, CheckDemandStart, (const std::string&, const DHType, (bool&))); 49 MOCK_METHOD(int32_t, ForceDisableSink, (const DHDescriptor&)); 50 MOCK_METHOD(int32_t, ForceDisableSource, (const std::string&, (const DHDescriptor&))); 51 MOCK_METHOD(int32_t, EnableSink, (const DHDescriptor&, int32_t, int32_t)); 52 MOCK_METHOD(int32_t, EnableSource, (const std::string&, const DHDescriptor&, int32_t, int32_t)); 53 MOCK_METHOD(int32_t, DisableSink, (const DHDescriptor&, int32_t, int32_t)); 54 MOCK_METHOD(int32_t, DisableSource, (const std::string&, const DHDescriptor&, int32_t, int32_t)); 55 MOCK_METHOD(int32_t, CheckSinkConfigStart, (const DHType, bool&)); 56 }; 57 } // namespace DistributedHardware 58 } // namespace OHOS 59 #endif // OHOS_DISTRIBUTED_HARDWARE_MOCK_COMPONENT_MANAGER_H 60