1 /* 2 * Copyright (c) 2021 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 FRAMEWORKS_WM_TEST_ST_WINDOW_TEST_UTILS_H 17 #define FRAMEWORKS_WM_TEST_ST_WINDOW_TEST_UTILS_H 18 19 #include "display_manager.h" 20 #include "window.h" 21 #include "window_layout_policy.h" 22 #include "window_option.h" 23 #include "window_scene.h" 24 #include "wm_common.h" 25 26 namespace OHOS { 27 namespace Rosen { 28 struct SplitRects { 29 Rect primaryRect; 30 Rect secondaryRect; 31 Rect dividerRect; 32 }; 33 34 class WindowTestUtils { 35 public: 36 struct TestWindowInfo { 37 std::string name; 38 Rect rect; 39 WindowType type; 40 WindowMode mode; 41 bool needAvoid; 42 bool parentLimit; 43 std::string parentName; 44 bool focusable_ { true }; 45 Orientation orientation_ { Orientation::UNSPECIFIED }; 46 }; 47 static Rect displayRect_; 48 static Rect limitDisplayRect_; 49 static Rect statusBarRect_; 50 static Rect naviBarRect_; 51 static Rect customAppRect_; 52 static Rect customAppDecoRect_; 53 static SplitRects splitRects_; 54 static bool isVerticalDisplay_; 55 static Rect singleTileRect_; 56 static std::vector<Rect> doubleTileRects_; 57 static std::vector<Rect> tripleTileRects_; 58 59 static void InitByDisplayRect(const Rect& screenRect); 60 static sptr<Window> CreateTestWindow(const TestWindowInfo& info); 61 static sptr<Window> CreateStatusBarWindow(); 62 static sptr<Window> CreateNavigationBarWindow(); 63 static sptr<WindowScene> CreateWindowScene(); 64 static bool RectEqualTo(const sptr<Window>& window, const Rect& r); 65 static bool InitSplitRects(); 66 static void UpdateSplitRects(const sptr<Window>& window); 67 static bool RectEqualToRect(const Rect& l, const Rect& r); 68 static Rect GetDefaultFoatingRect(const sptr<Window>& window); 69 static Rect GetLimitedDecoRect(const Rect& rect, float virtualPixelRatio); 70 static Rect CalcLimitedRect(const Rect& rect, float virtualPixelRatio); 71 static Rect GetFloatingLimitedRect(const Rect& rect, float virtualPixelRatio); 72 static void InitTileWindowRects(const sptr<Window>& window); 73 static float GetVirtualPixelRatio(DisplayId displayId); 74 75 private: 76 void UpdateLimitDisplayRect(Rect& avoidRect); 77 void UpdateLimitSplitRects(int32_t divPos); 78 void UpdateLimitSplitRect(Rect& limitSplitRect); 79 AvoidPosType GetAvoidPosType(const Rect& rect); 80 AvoidArea avoidArea_; 81 }; 82 } // namespace ROSEN 83 } // namespace OHOS 84 #endif // FRAMEWORKS_WM_TEST_ST_WINDOW_TEST_UTILS_H 85