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 MMI_INPUT_DEVICE_MANAGER_MOCK_H 17 #define MMI_INPUT_DEVICE_MANAGER_MOCK_H 18 #include <memory> 19 #include <vector> 20 #include <gmock/gmock.h> 21 #include "device_observer.h" 22 #include "libinput.h" 23 24 namespace OHOS { 25 namespace MMI { 26 class IInputDeviceManager { 27 public: 28 IInputDeviceManager() = default; 29 virtual ~IInputDeviceManager() = default; 30 31 virtual bool IsRemoteInputDevice(int32_t deviceId) const = 0; 32 virtual int32_t FindInputDeviceId(struct libinput_device* inputDevice) = 0; 33 virtual void Attach(std::shared_ptr<IDeviceObserver> observer) = 0; 34 virtual void Detach(std::shared_ptr<IDeviceObserver> observer) = 0; 35 virtual void GetMultiKeyboardDevice(std::vector<struct libinput_device*> &inputDevice) = 0; 36 }; 37 38 class InputDeviceManagerMock final : public IInputDeviceManager { 39 public: 40 InputDeviceManagerMock() = default; 41 ~InputDeviceManagerMock() override = default; 42 43 MOCK_METHOD(bool, IsRemoteInputDevice, (int32_t), (const)); 44 MOCK_METHOD(int32_t, FindInputDeviceId, (struct libinput_device*)); 45 MOCK_METHOD(void, Attach, (std::shared_ptr<IDeviceObserver>)); 46 MOCK_METHOD(void, Detach, (std::shared_ptr<IDeviceObserver>)); 47 MOCK_METHOD(void, GetMultiKeyboardDevice, (std::vector<struct libinput_device*>&)); 48 49 static std::shared_ptr<InputDeviceManagerMock> GetInstance(); 50 static void ReleaseInstance(); 51 52 private: 53 static std::shared_ptr<InputDeviceManagerMock> instance_; 54 }; 55 56 #define INPUT_DEV_MGR InputDeviceManagerMock::GetInstance() 57 } // namespace MMI 58 } // namespace OHOS 59 #endif // MMI_INPUT_DEVICE_MANAGER_MOCK_H