1 /* 2 * Copyright (c) 2024 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 INPUT_WINDOWS_MANAGER_MOCK_H 17 #define INPUT_WINDOWS_MANAGER_MOCK_H 18 19 #include <gmock/gmock.h> 20 #include "nocopyable.h" 21 22 #include "i_input_windows_manager.h" 23 24 namespace OHOS { 25 namespace MMI { 26 class InputWindowsManagerMock final : public IInputWindowsManager { 27 public: 28 InputWindowsManagerMock() = default; 29 ~InputWindowsManagerMock() = default; 30 DISALLOW_COPY_AND_MOVE(InputWindowsManagerMock); 31 Init(UDSServer &)32 void Init(UDSServer&) override {} JudgeCaramaInFore()33 bool JudgeCaramaInFore() override 34 { 35 return true; 36 } 37 MOCK_METHOD(int32_t, GetClientFd, (std::shared_ptr<PointerEvent>)); 38 MOCK_METHOD(int32_t, GetClientFd, (std::shared_ptr<PointerEvent>, int32_t)); UpdateDisplayInfo(DisplayGroupInfo &)39 void UpdateDisplayInfo(DisplayGroupInfo&) override {} UpdateDisplayInfoExtIfNeed(DisplayGroupInfo &,bool)40 void UpdateDisplayInfoExtIfNeed(DisplayGroupInfo&, bool) override {} UpdateWindowInfo(const WindowGroupInfo &)41 void UpdateWindowInfo(const WindowGroupInfo&) override {} 42 #if defined(OHOS_BUILD_ENABLE_POINTER) && defined(OHOS_BUILD_ENABLE_POINTER_DRAWING) SetWindowPointerStyle(WindowArea area,int32_t,int32_t)43 void SetWindowPointerStyle(WindowArea area, int32_t, int32_t) override {} 44 #endif // OHOS_BUILD_ENABLE_POINTER && OHOS_BUILD_ENABLE_POINTER_DRAWING 45 MOCK_METHOD(int32_t, ClearWindowPointerStyle, (int32_t, int32_t)); Dump(int32_t,const std::vector<std::string> &)46 void Dump(int32_t, const std::vector<std::string>&) override {} 47 MOCK_METHOD(int32_t, GetWindowPid, (int32_t), (const)); 48 MOCK_METHOD(int32_t, SetMouseCaptureMode, (int32_t, bool)); 49 MOCK_METHOD(bool, GetMouseIsCaptureMode, (), (const)); 50 MOCK_METHOD(int32_t, GetDisplayBindInfo, (DisplayBindInfos&)); 51 MOCK_METHOD(int32_t, SetDisplayBind, (int32_t, int32_t, std::string&)); 52 MOCK_METHOD(int32_t, AppendExtraData, (const ExtraData&)); 53 MOCK_METHOD(bool, IsWindowVisible, (int32_t)); 54 MOCK_METHOD(ExtraData, GetExtraData, (), (const)); 55 MOCK_METHOD(const std::vector<WindowInfo>&, GetWindowGroupInfoByDisplayId, (int32_t), (const)); 56 MOCK_METHOD((std::pair<double, double>), TransformWindowXY, (const WindowInfo&, double, double), (const)); 57 MOCK_METHOD((std::pair<double, double>), TransformDisplayXY, (const DisplayInfo&, double, double), (const)); ClearTargetWindowId(int32_t pointerId)58 void ClearTargetWindowId(int32_t pointerId) override {} 59 MOCK_METHOD(bool, CheckPidInSession, (int32_t)); 60 MOCK_METHOD(int32_t, GetCurrentUserId, ()); 61 62 #ifdef OHOS_BUILD_ENABLE_KEYBOARD 63 MOCK_METHOD((std::vector<std::pair<int32_t, TargetInfo>>), UpdateTarget, (std::shared_ptr<KeyEvent>)); 64 MOCK_METHOD(void, HandleKeyEventWindowId, (std::shared_ptr<KeyEvent>)); 65 #endif // OHOS_BUILD_ENABLE_KEYBOARD 66 67 MOCK_METHOD(int32_t, CheckWindowIdPermissionByPid, (int32_t, int32_t)); 68 MOCK_METHOD(void, SetFoldState, ()); 69 70 #if defined(OHOS_BUILD_ENABLE_POINTER) || defined(OHOS_BUILD_ENABLE_TOUCH) 71 MOCK_METHOD(MouseLocation, GetMouseInfo, ()); 72 MOCK_METHOD(CursorPosition, GetCursorPos, ()); 73 MOCK_METHOD(CursorPosition, ResetCursorPos, ()); UpdateAndAdjustMouseLocation(int32_t &,double &,double &,bool)74 void UpdateAndAdjustMouseLocation(int32_t&, double&, double&, bool) override {} 75 #endif // OHOS_BUILD_ENABLE_POINTER || OHOS_BUILD_ENABLE_TOUCH 76 77 #ifdef OHOS_BUILD_ENABLE_POINTER 78 MOCK_METHOD(int32_t, SetHoverScrollState, (bool)); 79 MOCK_METHOD(bool, GetHoverScrollState, (), (const)); 80 #endif // OHOS_BUILD_ENABLE_POINTER 81 82 #if defined(OHOS_BUILD_ENABLE_POINTER) || defined(OHOS_BUILD_ENABLE_TOUCH) 83 MOCK_METHOD(bool, IsMouseSimulate, (), (const)); 84 MOCK_METHOD(int32_t, SetPointerStyle, (int32_t, int32_t, PointerStyle, bool)); 85 MOCK_METHOD(int32_t, GetPointerStyle, (int32_t, int32_t, PointerStyle&, bool), (const)); 86 void DispatchPointer(int32_t pointerAction, int32_t windowId = -1) override {} SendPointerEvent(int32_t pointerAction)87 void SendPointerEvent(int32_t pointerAction) override {} 88 #endif // OHOS_BUILD_ENABLE_POINTER || OHOS_BUILD_ENABLE_TOUCH 89 90 #ifdef OHOS_BUILD_ENABLE_POINTER 91 #ifdef OHOS_BUILD_ENABLE_POINTER_DRAWING 92 MOCK_METHOD(bool, IsNeedRefreshLayer, (int32_t)); 93 #endif // OHOS_BUILD_ENABLE_POINTER_DRAWING 94 #endif //OHOS_BUILD_ENABLE_POINTER 95 96 #ifdef OHOS_BUILD_ENABLE_TOUCH 97 MOCK_METHOD(bool, TouchPointToDisplayPoint, (int32_t, struct libinput_event_touch*, EventTouch&, int32_t&)); 98 MOCK_METHOD(bool, CalculateTipPoint, (struct libinput_event_tablet_tool*, int32_t&, PhysicalCoordinate&), (const)); 99 MOCK_METHOD(const DisplayInfo*, GetDefaultDisplayInfo, (), (const)); 100 MOCK_METHOD(void, ReverseXY, (int32_t&, int32_t&)); 101 MOCK_METHOD(void, SendCancelEventWhenLock, ()); 102 #endif // OHOS_BUILD_ENABLE_TOUCH 103 104 #if defined(OHOS_BUILD_ENABLE_POINTER) || defined(OHOS_BUILD_ENABLE_TOUCH) DrawTouchGraphic(std::shared_ptr<PointerEvent>)105 void DrawTouchGraphic(std::shared_ptr<PointerEvent>) override {} 106 MOCK_METHOD(int32_t, UpdateTargetPointer, (std::shared_ptr<PointerEvent>)); 107 MOCK_METHOD(const DisplayInfo*, GetPhysicalDisplay, (int32_t), (const)); 108 #endif // OHOS_BUILD_ENABLE_POINTER || OHOS_BUILD_ENABLE_TOUCH 109 110 #if defined(OHOS_BUILD_ENABLE_POINTER) || defined(OHOS_BUILD_ENABLE_TOUCH) UpdatePointerChangeAreas()111 void UpdatePointerChangeAreas() override {} 112 #endif // OHOS_BUILD_ENABLE_POINTER || OHOS_BUILD_ENABLE_TOUCH 113 114 MOCK_METHOD(std::optional<WindowInfo>, GetWindowAndDisplayInfo, (int32_t, int32_t)); SetWindowStateNotifyPid(int32_t pid)115 void SetWindowStateNotifyPid(int32_t pid) override {} GetWindowStateNotifyPid()116 int32_t GetWindowStateNotifyPid() override { return 0; } GetPidByWindowId(int32_t pid)117 int32_t GetPidByWindowId(int32_t pid) override { return 0; } GetCancelEventFlag(std::shared_ptr<PointerEvent> pointerEvent)118 bool GetCancelEventFlag(std::shared_ptr<PointerEvent> pointerEvent) { return false; } 119 MOCK_METHOD(int32_t, SetPixelMapData, (int32_t infoId, void *pixelMap), (override)); 120 GetTargetWindowIds(int32_t,int32_t,std::vector<int32_t> &)121 void GetTargetWindowIds(int32_t, int32_t, std::vector<int32_t>&) override {} 122 MOCK_METHOD(int32_t, SetCurrentUser, (int32_t)); 123 MOCK_METHOD(DisplayMode, GetDisplayMode, (), (const)); 124 #ifdef OHOS_BUILD_ENABLE_ANCO 125 MOCK_METHOD(int32_t, AncoAddChannel, (sptr<IAncoChannel>)); 126 MOCK_METHOD(int32_t, AncoRemoveChannel, (sptr<IAncoChannel>)); 127 MOCK_METHOD(void, CleanShellWindowIds, ()); 128 MOCK_METHOD(bool, IsKnuckleOnAncoWindow, (std::shared_ptr<PointerEvent>)); 129 #endif // OHOS_BUILD_ENABLE_ANCO 130 131 static std::shared_ptr<InputWindowsManagerMock> GetInstance(); 132 133 private: 134 static std::mutex mutex_; 135 static std::shared_ptr<InputWindowsManagerMock> instance_; 136 }; 137 138 #define WIN_MGR_MOCK ::OHOS::MMI::InputWindowsManagerMock::GetInstance() 139 } // namespace MMI 140 } // namespace OHOS 141 #endif // INPUT_WINDOWS_MANAGER_MOCK_H 142