1e0dac50fSopenharmony_ci/*
2e0dac50fSopenharmony_ci * Copyright (c) 2021-2022 Huawei Device Co., Ltd.
3e0dac50fSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
4e0dac50fSopenharmony_ci * you may not use this file except in compliance with the License.
5e0dac50fSopenharmony_ci * You may obtain a copy of the License at
6e0dac50fSopenharmony_ci *
7e0dac50fSopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
8e0dac50fSopenharmony_ci *
9e0dac50fSopenharmony_ci * Unless required by applicable law or agreed to in writing, software
10e0dac50fSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
11e0dac50fSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12e0dac50fSopenharmony_ci * See the License for the specific language governing permissions and
13e0dac50fSopenharmony_ci * limitations under the License.
14e0dac50fSopenharmony_ci */
15e0dac50fSopenharmony_ci
16e0dac50fSopenharmony_ci#ifndef FRAMEWORKS_WM_TEST_ST_WINDOW_TEST_UTILS_H
17e0dac50fSopenharmony_ci#define FRAMEWORKS_WM_TEST_ST_WINDOW_TEST_UTILS_H
18e0dac50fSopenharmony_ci
19e0dac50fSopenharmony_ci#include "pointer_event.h"
20e0dac50fSopenharmony_ci#include "display_manager.h"
21e0dac50fSopenharmony_ci#include "window.h"
22e0dac50fSopenharmony_ci#include "window_layout_policy.h"
23e0dac50fSopenharmony_ci#include "window_option.h"
24e0dac50fSopenharmony_ci#include "window_scene.h"
25e0dac50fSopenharmony_ci#include "wm_common.h"
26e0dac50fSopenharmony_ci
27e0dac50fSopenharmony_cinamespace OHOS {
28e0dac50fSopenharmony_cinamespace Rosen {
29e0dac50fSopenharmony_cistruct SplitRects {
30e0dac50fSopenharmony_ci    Rect primaryRect;
31e0dac50fSopenharmony_ci    Rect secondaryRect;
32e0dac50fSopenharmony_ci    Rect dividerRect;
33e0dac50fSopenharmony_ci};
34e0dac50fSopenharmony_ci
35e0dac50fSopenharmony_ciclass WindowTestUtils {
36e0dac50fSopenharmony_cipublic:
37e0dac50fSopenharmony_ci    struct TestWindowInfo {
38e0dac50fSopenharmony_ci        std::string name;
39e0dac50fSopenharmony_ci        Rect rect;
40e0dac50fSopenharmony_ci        WindowType type;
41e0dac50fSopenharmony_ci        WindowMode mode;
42e0dac50fSopenharmony_ci        bool needAvoid;
43e0dac50fSopenharmony_ci        bool parentLimit;
44e0dac50fSopenharmony_ci        bool forbidSplitMove {false};
45e0dac50fSopenharmony_ci        bool showWhenLocked;
46e0dac50fSopenharmony_ci        uint32_t parentId;
47e0dac50fSopenharmony_ci        bool focusable_ { true };
48e0dac50fSopenharmony_ci        Orientation orientation_ { Orientation::UNSPECIFIED };
49e0dac50fSopenharmony_ci    };
50e0dac50fSopenharmony_ci    static Rect displayRect_;
51e0dac50fSopenharmony_ci    static Rect limitDisplayRect_;
52e0dac50fSopenharmony_ci    static Rect statusBarRect_;
53e0dac50fSopenharmony_ci    static Rect naviBarRect_;
54e0dac50fSopenharmony_ci    static Rect customAppRect_;
55e0dac50fSopenharmony_ci    static Rect customAppDecoRect_;
56e0dac50fSopenharmony_ci    static Rect dockWindowRect_;
57e0dac50fSopenharmony_ci    static SplitRects splitRects_;
58e0dac50fSopenharmony_ci    static bool isVerticalDisplay_;
59e0dac50fSopenharmony_ci    static Rect singleTileRect_;
60e0dac50fSopenharmony_ci    static std::vector<Rect> doubleTileRects_;
61e0dac50fSopenharmony_ci    static std::vector<Rect> tripleTileRects_;
62e0dac50fSopenharmony_ci    static AvoidArea systemAvoidArea_;
63e0dac50fSopenharmony_ci
64e0dac50fSopenharmony_ci    static void InitByDisplayRect(const Rect& displayRect);
65e0dac50fSopenharmony_ci    static sptr<Window> CreateTestWindow(const TestWindowInfo& info);
66e0dac50fSopenharmony_ci    static sptr<Window> CreateStatusBarWindow();
67e0dac50fSopenharmony_ci    static sptr<Window> CreateNavigationBarWindow();
68e0dac50fSopenharmony_ci    static sptr<Window> CreateDockWindow();
69e0dac50fSopenharmony_ci    static sptr<WindowScene> CreateWindowScene();
70e0dac50fSopenharmony_ci    static bool RectEqualTo(const sptr<Window>& window, const Rect& r);
71e0dac50fSopenharmony_ci    static bool InitSplitRects();
72e0dac50fSopenharmony_ci    static void UpdateSplitRects(const sptr<Window>& window);
73e0dac50fSopenharmony_ci    static bool RectEqualToRect(const Rect& l, const Rect& r);
74e0dac50fSopenharmony_ci    static Rect GetDefaultFloatingRect(const sptr<Window>& window, bool avoid);
75e0dac50fSopenharmony_ci    static Rect CalcLimitedRect(const Rect& rect, float virtualPixelRatio);
76e0dac50fSopenharmony_ci    static Rect GetDecorateRect(const Rect& rect, float virtualPixelRatio);
77e0dac50fSopenharmony_ci    static Rect GetFloatingLimitedRect(const Rect& rect, float virtualPixelRatio);
78e0dac50fSopenharmony_ci    static void InitTileWindowRects(const sptr<Window>& window, bool avoid);
79e0dac50fSopenharmony_ci    static float GetVirtualPixelRatio(DisplayId displayId);
80e0dac50fSopenharmony_ci    static std::shared_ptr<MMI::PointerEvent> CreatePointerEvent(int32_t posX, int32_t posY, uint32_t pointerId,
81e0dac50fSopenharmony_ci        int32_t pointerAction);
82e0dac50fSopenharmony_ci    static uint32_t GetMaxTileWinNum();
83e0dac50fSopenharmony_ci
84e0dac50fSopenharmony_ciprivate:
85e0dac50fSopenharmony_ci    void UpdateLimitDisplayRect(const Rect& avoidRect);
86e0dac50fSopenharmony_ci    static void UpdateLimitSplitRects(int32_t divPos);
87e0dac50fSopenharmony_ci    static void UpdateLimitSplitRect(Rect& limitSplitRect);
88e0dac50fSopenharmony_ci    static AvoidPosType GetAvoidPosType(const Rect& rect);
89e0dac50fSopenharmony_ci    AvoidArea avoidArea_;
90e0dac50fSopenharmony_ci};
91e0dac50fSopenharmony_ci} // namespace ROSEN
92e0dac50fSopenharmony_ci} // namespace OHOS
93e0dac50fSopenharmony_ci#endif // FRAMEWORKS_WM_TEST_ST_WINDOW_TEST_UTILS_H
94