• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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>));
40     MOCK_METHOD(void, PrintEnterEventInfo, (std::shared_ptr<PointerEvent>));
41     MOCK_METHOD(bool, IsFocusedSession, (int32_t), (const));
UpdateDisplayInfo(DisplayGroupInfo &)42     void UpdateDisplayInfo(DisplayGroupInfo&) override {}
UpdateDisplayInfoExtIfNeed(DisplayGroupInfo &,bool)43     void UpdateDisplayInfoExtIfNeed(DisplayGroupInfo&, bool) override {}
UpdateWindowInfo(const WindowGroupInfo &)44     void UpdateWindowInfo(const WindowGroupInfo&) override {}
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 
60 #ifdef OHOS_BUILD_ENABLE_KEYBOARD
61     MOCK_METHOD((std::vector<std::pair<int32_t, TargetInfo>>), UpdateTarget, (std::shared_ptr<KeyEvent>));
62     MOCK_METHOD(void, HandleKeyEventWindowId, (std::shared_ptr<KeyEvent>));
63 #endif // OHOS_BUILD_ENABLE_KEYBOARD
64 
65     MOCK_METHOD(int32_t, CheckWindowIdPermissionByPid, (int32_t, int32_t));
66     MOCK_METHOD(int32_t, GetCurrentUserId, ());
67     MOCK_METHOD(void, SetFoldState, ());
68     MOCK_METHOD(bool, CheckAppFocused, (int32_t));
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     MOCK_METHOD(bool, IsMouseSimulate, ());
81     MOCK_METHOD(bool, HasMouseHideFlag, ());
82     MOCK_METHOD(bool, SelectPointerChangeArea, (int32_t, int32_t, int32_t));
83 #endif // OHOS_BUILD_ENABLE_POINTER
84 
85 #if defined(OHOS_BUILD_ENABLE_POINTER) || defined(OHOS_BUILD_ENABLE_TOUCH)
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 {}
UpdatePointerDrawingManagerWindowInfo()90     void UpdatePointerDrawingManagerWindowInfo() override {}
91 #endif // OHOS_BUILD_ENABLE_POINTER || OHOS_BUILD_ENABLE_TOUCH
92 
93 #ifdef OHOS_BUILD_ENABLE_POINTER
94 #ifdef OHOS_BUILD_ENABLE_POINTER_DRAWING
95     MOCK_METHOD(bool, IsNeedRefreshLayer, (int32_t));
96 #endif // OHOS_BUILD_ENABLE_POINTER_DRAWING
97 #endif //OHOS_BUILD_ENABLE_POINTER
98 
99 #ifdef OHOS_BUILD_ENABLE_TOUCH
100     MOCK_METHOD(bool, TouchPointToDisplayPoint, (int32_t, struct libinput_event_touch*, EventTouch&, int32_t&, bool));
101     MOCK_METHOD(bool, CalculateTipPoint, (struct libinput_event_tablet_tool*, int32_t&, PhysicalCoordinate&), (const));
102     MOCK_METHOD(const DisplayInfo*, GetDefaultDisplayInfo, (), (const));
103     MOCK_METHOD(void, ReverseXY, (int32_t&, int32_t&));
104     MOCK_METHOD(void, SendCancelEventWhenLock, ());
105     MOCK_METHOD(void, FoldScreenRotation, (std::shared_ptr<PointerEvent>));
106 #endif // OHOS_BUILD_ENABLE_TOUCH
107 
108 #if defined(OHOS_BUILD_ENABLE_POINTER) || defined(OHOS_BUILD_ENABLE_TOUCH)
DrawTouchGraphic(std::shared_ptr<PointerEvent>)109     void DrawTouchGraphic(std::shared_ptr<PointerEvent>) override {}
110     MOCK_METHOD(int32_t, UpdateTargetPointer, (std::shared_ptr<PointerEvent>));
111     MOCK_METHOD(const DisplayInfo*, GetPhysicalDisplay, (int32_t), (const));
112 #endif // OHOS_BUILD_ENABLE_POINTER || OHOS_BUILD_ENABLE_TOUCH
113 
114 #if defined(OHOS_BUILD_ENABLE_POINTER) || defined(OHOS_BUILD_ENABLE_TOUCH)
UpdatePointerChangeAreas()115     void UpdatePointerChangeAreas() override {}
116 #endif // OHOS_BUILD_ENABLE_POINTER || OHOS_BUILD_ENABLE_TOUCH
117 
118     MOCK_METHOD(std::optional<WindowInfo>, GetWindowAndDisplayInfo, (int32_t, int32_t));
SetWindowStateNotifyPid(int32_t pid)119     void SetWindowStateNotifyPid(int32_t pid) override {}
GetWindowStateNotifyPid()120     int32_t GetWindowStateNotifyPid() override { return 0; }
GetPidByWindowId(int32_t pid)121     int32_t GetPidByWindowId(int32_t pid) override { return 0; }
GetCancelEventFlag(std::shared_ptr<PointerEvent> pointerEvent)122     bool GetCancelEventFlag(std::shared_ptr<PointerEvent> pointerEvent) { return false; }
123     MOCK_METHOD(int32_t, SetPixelMapData, (int32_t infoId, void *pixelMap), (override));
124 
GetTargetWindowIds(int32_t,int32_t,std::vector<int32_t> &)125     void GetTargetWindowIds(int32_t, int32_t, std::vector<int32_t>&) override {}
126     MOCK_METHOD(int32_t, SetCurrentUser, (int32_t));
127     MOCK_METHOD(DisplayMode, GetDisplayMode, (), (const));
128 #ifdef OHOS_BUILD_ENABLE_ANCO
129     MOCK_METHOD(int32_t, AncoAddChannel, (sptr<IAncoChannel>));
130     MOCK_METHOD(int32_t, AncoRemoveChannel, (sptr<IAncoChannel>));
131     MOCK_METHOD(void, CleanShellWindowIds, ());
132     MOCK_METHOD(bool, IsKnuckleOnAncoWindow, (std::shared_ptr<PointerEvent>));
133     MOCK_METHOD(int32_t, SyncKnuckleStatus, (bool));
134 #endif // OHOS_BUILD_ENABLE_ANCO
135 #if defined(OHOS_BUILD_ENABLE_POINTER) || defined(OHOS_BUILD_ENABLE_TOUCH)
136     MOCK_METHOD(int32_t, ShiftAppPointerEvent, (const ShiftWindowParam&, bool));
137 #endif // OHOS_BUILD_ENABLE_POINTER || OHOS_BUILD_ENABLE_TOUCH
138 #ifdef OHOS_BUILD_ENABLE_HARDWARE_CURSOR
139     MOCK_METHOD(bool, IsSupported, ());
140 #endif // OHOS_BUILD_ENABLE_HARDWARE_CURSOR
141 #if defined(OHOS_BUILD_ENABLE_TOUCH) && defined(OHOS_BUILD_ENABLE_MONITOR)
142     MOCK_METHOD(void, AttachTouchGestureMgr, (std::shared_ptr<TouchGestureManager>));
143     MOCK_METHOD(void, CancelAllTouches, (std::shared_ptr<PointerEvent>));
144 #endif // defined(OHOS_BUILD_ENABLE_TOUCH) && defined(OHOS_BUILD_ENABLE_MONITOR)
145 #ifdef OHOS_BUILD_ENABLE_TOUCH
146     MOCK_METHOD(std::shared_ptr<PointerEvent>, GetLastPointerEventForGesture, ());
147 #endif // OHOS_BUILD_ENABLE_TOUCH
148 
149     static std::shared_ptr<InputWindowsManagerMock> GetInstance();
150 
151 private:
152     static std::mutex mutex_;
153     static std::shared_ptr<InputWindowsManagerMock> instance_;
154 };
155 
156 #define WIN_MGR_MOCK ::OHOS::MMI::InputWindowsManagerMock::GetInstance()
157 } // namespace MMI
158 } // namespace OHOS
159 #endif // INPUT_WINDOWS_MANAGER_MOCK_H
160