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