/* * Copyright (c) 2024 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef INPUT_WINDOWS_MANAGER_MOCK_H #define INPUT_WINDOWS_MANAGER_MOCK_H #include #include "nocopyable.h" #include "i_input_windows_manager.h" namespace OHOS { namespace MMI { class InputWindowsManagerMock final : public IInputWindowsManager { public: InputWindowsManagerMock() = default; ~InputWindowsManagerMock() = default; DISALLOW_COPY_AND_MOVE(InputWindowsManagerMock); void Init(UDSServer&) override {} bool JudgeCaramaInFore() override { return true; } MOCK_METHOD(int32_t, GetClientFd, (std::shared_ptr)); MOCK_METHOD(int32_t, GetClientFd, (std::shared_ptr, int32_t)); MOCK_METHOD(bool, AdjustFingerFlag, (std::shared_ptr)); void UpdateDisplayInfo(DisplayGroupInfo&) override {} void UpdateDisplayInfoExtIfNeed(DisplayGroupInfo&, bool) override {} void UpdateWindowInfo(const WindowGroupInfo&) override {} #if defined(OHOS_BUILD_ENABLE_POINTER) && defined(OHOS_BUILD_ENABLE_POINTER_DRAWING) void SetWindowPointerStyle(WindowArea area, int32_t, int32_t) override {} #endif // OHOS_BUILD_ENABLE_POINTER && OHOS_BUILD_ENABLE_POINTER_DRAWING MOCK_METHOD(int32_t, ClearWindowPointerStyle, (int32_t, int32_t)); void Dump(int32_t, const std::vector&) override {} MOCK_METHOD(int32_t, GetWindowPid, (int32_t), (const)); MOCK_METHOD(int32_t, SetMouseCaptureMode, (int32_t, bool)); MOCK_METHOD(bool, GetMouseIsCaptureMode, (), (const)); MOCK_METHOD(int32_t, GetDisplayBindInfo, (DisplayBindInfos&)); MOCK_METHOD(int32_t, SetDisplayBind, (int32_t, int32_t, std::string&)); MOCK_METHOD(int32_t, AppendExtraData, (const ExtraData&)); MOCK_METHOD(bool, IsWindowVisible, (int32_t)); MOCK_METHOD(ExtraData, GetExtraData, (), (const)); MOCK_METHOD(const std::vector&, GetWindowGroupInfoByDisplayId, (int32_t), (const)); MOCK_METHOD((std::pair), TransformWindowXY, (const WindowInfo&, double, double), (const)); MOCK_METHOD((std::pair), TransformDisplayXY, (const DisplayInfo&, double, double), (const)); void ClearTargetWindowId(int32_t pointerId) override {} MOCK_METHOD(bool, CheckPidInSession, (int32_t)); MOCK_METHOD(int32_t, GetCurrentUserId, ()); #ifdef OHOS_BUILD_ENABLE_KEYBOARD MOCK_METHOD((std::vector>), UpdateTarget, (std::shared_ptr)); MOCK_METHOD(void, HandleKeyEventWindowId, (std::shared_ptr)); #endif // OHOS_BUILD_ENABLE_KEYBOARD MOCK_METHOD(int32_t, CheckWindowIdPermissionByPid, (int32_t, int32_t)); MOCK_METHOD(void, SetFoldState, ()); #if defined(OHOS_BUILD_ENABLE_POINTER) || defined(OHOS_BUILD_ENABLE_TOUCH) MOCK_METHOD(MouseLocation, GetMouseInfo, ()); MOCK_METHOD(CursorPosition, GetCursorPos, ()); MOCK_METHOD(CursorPosition, ResetCursorPos, ()); void UpdateAndAdjustMouseLocation(int32_t&, double&, double&, bool) override {} #endif // OHOS_BUILD_ENABLE_POINTER || OHOS_BUILD_ENABLE_TOUCH #ifdef OHOS_BUILD_ENABLE_POINTER MOCK_METHOD(int32_t, SetHoverScrollState, (bool)); MOCK_METHOD(bool, GetHoverScrollState, (), (const)); #endif // OHOS_BUILD_ENABLE_POINTER #if defined(OHOS_BUILD_ENABLE_POINTER) || defined(OHOS_BUILD_ENABLE_TOUCH) MOCK_METHOD(bool, IsMouseSimulate, (), (const)); MOCK_METHOD(bool, HasMouseHideFlag, (), (const)); MOCK_METHOD(int32_t, SetPointerStyle, (int32_t, int32_t, PointerStyle, bool)); MOCK_METHOD(int32_t, GetPointerStyle, (int32_t, int32_t, PointerStyle&, bool), (const)); void DispatchPointer(int32_t pointerAction, int32_t windowId = -1) override {} void SendPointerEvent(int32_t pointerAction) override {} #endif // OHOS_BUILD_ENABLE_POINTER || OHOS_BUILD_ENABLE_TOUCH #ifdef OHOS_BUILD_ENABLE_POINTER #ifdef OHOS_BUILD_ENABLE_POINTER_DRAWING MOCK_METHOD(bool, IsNeedRefreshLayer, (int32_t)); #endif // OHOS_BUILD_ENABLE_POINTER_DRAWING #endif //OHOS_BUILD_ENABLE_POINTER #ifdef OHOS_BUILD_ENABLE_TOUCH MOCK_METHOD(bool, TouchPointToDisplayPoint, (int32_t, struct libinput_event_touch*, EventTouch&, int32_t&)); MOCK_METHOD(bool, CalculateTipPoint, (struct libinput_event_tablet_tool*, int32_t&, PhysicalCoordinate&), (const)); MOCK_METHOD(const DisplayInfo*, GetDefaultDisplayInfo, (), (const)); MOCK_METHOD(void, ReverseXY, (int32_t&, int32_t&)); MOCK_METHOD(void, SendCancelEventWhenLock, ()); MOCK_METHOD(void, FoldScreenRotation, (std::shared_ptr)); #endif // OHOS_BUILD_ENABLE_TOUCH #if defined(OHOS_BUILD_ENABLE_POINTER) || defined(OHOS_BUILD_ENABLE_TOUCH) void DrawTouchGraphic(std::shared_ptr) override {} MOCK_METHOD(int32_t, UpdateTargetPointer, (std::shared_ptr)); MOCK_METHOD(const DisplayInfo*, GetPhysicalDisplay, (int32_t), (const)); #endif // OHOS_BUILD_ENABLE_POINTER || OHOS_BUILD_ENABLE_TOUCH #if defined(OHOS_BUILD_ENABLE_POINTER) || defined(OHOS_BUILD_ENABLE_TOUCH) void UpdatePointerChangeAreas() override {} #endif // OHOS_BUILD_ENABLE_POINTER || OHOS_BUILD_ENABLE_TOUCH MOCK_METHOD(std::optional, GetWindowAndDisplayInfo, (int32_t, int32_t)); void SetWindowStateNotifyPid(int32_t pid) override {} int32_t GetWindowStateNotifyPid() override { return 0; } int32_t GetPidByWindowId(int32_t pid) override { return 0; } bool GetCancelEventFlag(std::shared_ptr pointerEvent) { return false; } MOCK_METHOD(int32_t, SetPixelMapData, (int32_t infoId, void *pixelMap), (override)); void GetTargetWindowIds(int32_t, int32_t, std::vector&) override {} MOCK_METHOD(int32_t, SetCurrentUser, (int32_t)); MOCK_METHOD(DisplayMode, GetDisplayMode, (), (const)); #ifdef OHOS_BUILD_ENABLE_ANCO MOCK_METHOD(int32_t, AncoAddChannel, (sptr)); MOCK_METHOD(int32_t, AncoRemoveChannel, (sptr)); MOCK_METHOD(void, CleanShellWindowIds, ()); MOCK_METHOD(bool, IsKnuckleOnAncoWindow, (std::shared_ptr)); #endif // OHOS_BUILD_ENABLE_ANCO static std::shared_ptr GetInstance(); private: static std::mutex mutex_; static std::shared_ptr instance_; }; #define WIN_MGR_MOCK ::OHOS::MMI::InputWindowsManagerMock::GetInstance() } // namespace MMI } // namespace OHOS #endif // INPUT_WINDOWS_MANAGER_MOCK_H