• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 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 #include <gtest/gtest.h>
17 #include "display_group_controller.h"
18 #include "display_group_info.h"
19 #include "display_manager.h"
20 #include "remote_animation.h"
21 #include "window_helper.h"
22 #include "window_layout_policy.h"
23 #include "window_layout_policy_cascade.h"
24 #include "window_node_container.h"
25 
26 using namespace testing;
27 using namespace testing::ext;
28 
29 namespace OHOS {
30 namespace Rosen {
31 
32 struct WindowInfo {
33     Rect winRect_;
34     WindowType winType_;
35     WindowMode winMode_;
36     WindowSizeChangeReason reason_;
37     DragType dragType_;
38     bool decorEnable_;
39 };
40 
41 class WindowLayoutPolicyTest : public testing::Test {
42 public:
43     static void SetUpTestCase();
44     static void TearDownTestCase();
45     virtual void SetUp() override;
46     virtual void TearDown() override;
47     sptr<WindowNode> CreateWindowNode(const WindowInfo& windowInfo);
48     sptr<DisplayInfo> CreateDisplayInfo(const Rect& displayRect);
49 
50     static WindowInfo windowInfo_;
51     static sptr<WindowNodeContainer> container_;
52     static sptr<DisplayGroupInfo> displayGroupInfo_;
53     static sptr<DisplayInfo> defaultDisplayInfo_;
54     static sptr<DisplayGroupController> displayGroupController_;
55     static sptr<WindowLayoutPolicy> layoutPolicy_;
56 };
57 
58 sptr<WindowNodeContainer> WindowLayoutPolicyTest::container_ = nullptr;
59 sptr<DisplayGroupInfo> WindowLayoutPolicyTest::displayGroupInfo_ = nullptr;
60 sptr<DisplayGroupController> WindowLayoutPolicyTest::displayGroupController_ = nullptr;
61 sptr<WindowLayoutPolicy> WindowLayoutPolicyTest::layoutPolicy_ = nullptr;
62 sptr<DisplayInfo> WindowLayoutPolicyTest::defaultDisplayInfo_ = nullptr;
63 WindowInfo WindowLayoutPolicyTest::windowInfo_ = {
64     .winRect_ = { 0, 0, 0, 0 },
65     .winType_ = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW,
66     .winMode_ = WindowMode::WINDOW_MODE_FLOATING,
67     .reason_ = WindowSizeChangeReason::UNDEFINED,
68     .dragType_ = DragType::DRAG_UNDEFINED,
69     .decorEnable_ = false,
70 };
71 
SetUpTestCase()72 void WindowLayoutPolicyTest::SetUpTestCase()
73 {
74     auto display = DisplayManager::GetInstance().GetDefaultDisplay();
75     ASSERT_TRUE((display != nullptr));
76 
77     defaultDisplayInfo_ = display->GetDisplayInfo();
78     ASSERT_TRUE((defaultDisplayInfo_ != nullptr));
79 
80     windowInfo_ = {
81         .winRect_ = { 0, 0, 0, 0 },
82         .winType_ = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW,
83         .winMode_ = WindowMode::WINDOW_MODE_FLOATING,
84         .reason_ = WindowSizeChangeReason::UNDEFINED,
85         .dragType_ = DragType::DRAG_UNDEFINED,
86         .decorEnable_ = false,
87     };
88 
89     container_ = new WindowNodeContainer(defaultDisplayInfo_, display->GetScreenId());
90     displayGroupInfo_ = container_->displayGroupInfo_;
91     displayGroupController_ = container_->displayGroupController_;
92     layoutPolicy_ = container_->GetLayoutPolicy();
93 }
94 
TearDownTestCase()95 void WindowLayoutPolicyTest::TearDownTestCase()
96 {
97     container_ = nullptr;
98     displayGroupInfo_ = nullptr;
99     defaultDisplayInfo_ = nullptr;
100     displayGroupController_ = nullptr;
101     layoutPolicy_ = nullptr;
102 }
103 
SetUp()104 void WindowLayoutPolicyTest::SetUp()
105 {
106     displayGroupInfo_->AddDisplayInfo(defaultDisplayInfo_);
107 }
108 
TearDown()109 void WindowLayoutPolicyTest::TearDown()
110 {
111     displayGroupInfo_->displayInfosMap_.clear();
112 }
113 
CreateWindowNode(const WindowInfo & windowInfo)114 sptr<WindowNode> WindowLayoutPolicyTest::CreateWindowNode(const WindowInfo& windowInfo)
115 {
116     sptr<WindowProperty> property = new WindowProperty();
117     property->SetWindowType(windowInfo.winType_);
118     property->SetWindowMode(windowInfo.winMode_);
119     property->SetWindowRect(windowInfo.winRect_);
120     property->SetOriginRect(windowInfo.winRect_);
121     property->SetDecorEnable(windowInfo.decorEnable_);
122     sptr<WindowNode> node = new WindowNode(property, nullptr, nullptr);
123     node->SetWindowSizeChangeReason(windowInfo.reason_);
124     node->SetDragType(windowInfo.dragType_);
125     return node;
126 }
127 
CreateDisplayInfo(const Rect & displayRect)128 sptr<DisplayInfo> WindowLayoutPolicyTest::CreateDisplayInfo(const Rect& displayRect)
129 {
130     sptr<DisplayInfo> displayInfo = new DisplayInfo();
131     displayInfo->SetOffsetX(displayRect.posX_);
132     displayInfo->SetOffsetY(displayRect.posY_);
133     displayInfo->SetWidth(displayRect.width_);
134     displayInfo->SetHeight(displayRect.height_);
135     displayInfo->SetDisplayId((defaultDisplayInfo_->GetDisplayId() + 1));
136     return displayInfo;
137 }
138 namespace {
139 /**
140  * @tc.name: CalcEntireWindowHotZone
141  * @tc.desc: calc entire window hot zone
142  * @tc.type: FUNC
143  * @tc.require issueI5LYDC
144  */
145 HWTEST_F(WindowLayoutPolicyTest, CalcEntireWindowHotZone, Function | SmallTest | Level2)
146 {
147     TransformHelper::Vector2 hotZoneScale = {1.f, 1.f}; // ratio 1.0
148     sptr<WindowProperty> property = new WindowProperty();
149 
150     property->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
151     property->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING);
152     sptr<WindowNode> node0 = new WindowNode(property, nullptr, nullptr);
153     Rect winRect = { 50, 100, 400, 500 }; // rect: 50, 100, 400, 500
154     auto actRect0 = layoutPolicy_->CalcEntireWindowHotZone(node0, winRect, 10, 2.f, hotZoneScale); // param: 10, 2.0
155     Rect expRect0 = { 30, 80, 440, 540 }; // rect: 30, 80, 440, 540
156     ASSERT_EQ(expRect0, actRect0);
157 
158     property->SetWindowType(WindowType::WINDOW_TYPE_DOCK_SLICE);
159     sptr<WindowNode> node1 = new WindowNode(property, nullptr, nullptr);
160     auto actRect1 = layoutPolicy_->CalcEntireWindowHotZone(node1, winRect, 10, 2.f, hotZoneScale); // param: 10, 2.0
161     Rect expRect1 = { 30, 100, 440, 500 }; // rect: 30, 100, 440, 500
162     ASSERT_EQ(expRect1, actRect1);
163 
164     property->SetWindowType(WindowType::WINDOW_TYPE_LAUNCHER_RECENT);
165     sptr<WindowNode> node2 = new WindowNode(property, nullptr, nullptr);
166     auto actRect2 = layoutPolicy_->CalcEntireWindowHotZone(node2, winRect, 10, 2.f, hotZoneScale); // param: 10, 2.0
167     Rect expRect2 = displayGroupInfo_->GetDisplayRect(defaultDisplayInfo_->GetDisplayId());;
168     ASSERT_EQ(expRect2, actRect2);
169 }
170 
171 /**
172  * @tc.name: UpdateFloatingWindowSizeForStretchableWindow01
173  * @tc.desc: UpdateFloatingWindowSizeForStretchableWindow test for drag width
174  * @tc.type: FUNC
175  */
176 HWTEST_F(WindowLayoutPolicyTest, UpdateFloatingWindowSizeForStretchableWindow01, Function | SmallTest | Level2)
177 {
178     windowInfo_.winRect_ = { 50, 50, 100, 150 };  // rect: 50, 50, 100, 150
179     windowInfo_.dragType_ = DragType::DRAG_LEFT_OR_RIGHT;
180     windowInfo_.reason_ = WindowSizeChangeReason::DRAG;
181     sptr<WindowNode> node = CreateWindowNode(windowInfo_);
182     Rect newWinRect = { 50, 50, 200, 200 };       // rect: 50, 50, 200, 200
183     layoutPolicy_->UpdateFloatingWindowSizeForStretchableWindow(node, { 0, 0, 0, 0 }, newWinRect);
184     Rect expRect = { 50, 50, 200, 300 };          // rect: 50, 50, 200, 300
185     ASSERT_EQ(expRect, newWinRect);
186 }
187 
188 /**
189  * @tc.name: UpdateFloatingWindowSizeForStretchableWindow02
190  * @tc.desc: UpdateFloatingWindowSizeForStretchableWindow test for drag coner
191  * @tc.type: FUNC
192  */
193 HWTEST_F(WindowLayoutPolicyTest, UpdateFloatingWindowSizeForStretchableWindow02, Function | SmallTest | Level2)
194 {
195     windowInfo_.winRect_ = { 50, 50, 100, 150 }; // rect: 50, 50, 100, 150
196     windowInfo_.dragType_ = DragType::DRAG_LEFT_TOP_CORNER;
197     windowInfo_.reason_ = WindowSizeChangeReason::DRAG;
198     sptr<WindowNode> node = CreateWindowNode(windowInfo_);
199     Rect newWinRect = { 50, 50, 200, 200 };      // rect: 50, 50, 200, 200
200     layoutPolicy_->UpdateFloatingWindowSizeForStretchableWindow(node, { 0, 0, 0, 0 }, newWinRect);
201     Rect expRect = { 50, 50, 200, 300 };         // rect: 50, 50, 200, 300
202     ASSERT_EQ(expRect, newWinRect);
203 }
204 
205 /**
206  * @tc.name: UpdateFloatingWindowSizeForStretchableWindow03
207  * @tc.desc: UpdateFloatingWindowSizeForStretchableWindow test for drag height
208  * @tc.type: FUNC
209  */
210 HWTEST_F(WindowLayoutPolicyTest, UpdateFloatingWindowSizeForStretchableWindow03, Function | SmallTest | Level2)
211 {
212     windowInfo_.winRect_ = { 50, 50, 100, 150 }; // rect: 50, 50, 100, 150
213     windowInfo_.dragType_ = DragType::DRAG_BOTTOM_OR_TOP;
214     windowInfo_.reason_ = WindowSizeChangeReason::DRAG;
215     sptr<WindowNode> node = CreateWindowNode(windowInfo_);
216     Rect newWinRect = { 50, 50, 150, 300 };      // rect: 50, 50, 150, 300
217     layoutPolicy_->UpdateFloatingWindowSizeForStretchableWindow(node, { 0, 0, 0, 0 }, newWinRect);
218     Rect expRect = { 50, 50, 200, 300 };         // rect: 50, 50, 200, 300
219     ASSERT_EQ(expRect, newWinRect);
220 }
221 
222 /**
223  * @tc.name: LimitWindowToBottomRightCorner
224  * @tc.desc: test LimitWindowToBottomRightCorner01
225  * @tc.type: FUNC
226  */
227 HWTEST_F(WindowLayoutPolicyTest, LimitWindowToBottomRightCorner01, Function | SmallTest | Level2)
228 {
229     auto displayRect = displayGroupInfo_->GetDisplayRect(defaultDisplayInfo_->GetDisplayId());
230     ASSERT_FALSE(WindowHelper::IsEmptyRect(displayRect));
231     windowInfo_.winRect_ = {
232         .posX_ = static_cast<int32_t>(displayRect.posX_ + displayRect.width_ * 0.5), // ratio: 0.5
233         .posY_ = displayRect.posY_,
234         .width_ = displayRect.width_,
235         .height_ = displayRect.height_
236     };
237     sptr<WindowNode> node = CreateWindowNode(windowInfo_);
238     ASSERT_TRUE(node != nullptr);
239     layoutPolicy_->LimitWindowToBottomRightCorner(node);
240 
241     Rect winRect = {
242         .posX_ = displayRect.posX_,
243         .posY_ = displayRect.posY_,
244         .width_ = static_cast<uint32_t>(displayRect.width_ * 0.5),  // ratio: 0.5
245         .height_ = static_cast<uint32_t>(displayRect.height_ * 0.5) // ratio: 0.5
246     };
247     node ->SetRequestRect(winRect);
248     layoutPolicy_->LimitWindowToBottomRightCorner(node);
249 }
250 
251 /**
252  * @tc.name: LimitWindowToBottomRightCorner
253  * @tc.desc: test LimitWindowToBottomRightCorner02
254  * @tc.type: FUNC
255  */
256 HWTEST_F(WindowLayoutPolicyTest, LimitWindowToBottomRightCorner02, Function | SmallTest | Level2)
257 {
258     auto displayRect = displayGroupInfo_->GetDisplayRect(defaultDisplayInfo_->GetDisplayId());
259     ASSERT_FALSE(WindowHelper::IsEmptyRect(displayRect));
260     windowInfo_.winRect_ = {
261         .posX_ = static_cast<int32_t>(displayRect.posX_ + displayRect.width_ * 0.5),  // ratio: 0.5
262         .posY_ = static_cast<int32_t>(displayRect.posY_ + displayRect.height_ * 0.5), // ratio: 0.5
263         .width_ = displayRect.width_,
264         .height_ = displayRect.height_
265     };
266     sptr<WindowNode> node = CreateWindowNode(windowInfo_);
267     ASSERT_TRUE(node != nullptr);
268     layoutPolicy_->LimitWindowToBottomRightCorner(node);
269 
270     Rect winRect = {
271         .posX_ = displayRect.posX_,
272         .posY_ = static_cast<int32_t>(displayRect.posY_ + displayRect.height_ * 0.5), // ratio: 0.5
273         .width_ = displayRect.width_,
274         .height_ = displayRect.height_
275     };
276     node ->SetRequestRect(winRect);
277     layoutPolicy_->LimitWindowToBottomRightCorner(node);
278     ASSERT_TRUE(node != nullptr);
279 }
280 
281 /**
282  * @tc.name: LimitWindowToBottomRightCorner
283  * @tc.desc: test LimitWindowToBottomRightCorner03, test childNode
284  * @tc.type: FUNC
285  */
286 HWTEST_F(WindowLayoutPolicyTest, LimitWindowToBottomRightCorner03, Function | SmallTest | Level2)
287 {
288     auto displayRect = displayGroupInfo_->GetDisplayRect(defaultDisplayInfo_->GetDisplayId());
289     ASSERT_FALSE(WindowHelper::IsEmptyRect(displayRect));
290     windowInfo_.winRect_ = {
291         .posX_ = static_cast<int32_t>(displayRect.posX_ + displayRect.width_ * 0.5),  // ratio: 0.5
292         .posY_ = static_cast<int32_t>(displayRect.posY_ + displayRect.height_ * 0.5), // ratio: 0.5
293         .width_ = displayRect.width_,
294         .height_ = displayRect.height_
295     };
296     sptr<WindowNode> parentNode = CreateWindowNode(windowInfo_);
297     sptr<WindowNode> node = CreateWindowNode(windowInfo_);
298     ASSERT_TRUE(parentNode != nullptr);
299     ASSERT_TRUE(node != nullptr);
300     parentNode->children_.push_back(node);
301     layoutPolicy_->LimitWindowToBottomRightCorner(node);
302 }
303 
304 /**
305  * @tc.name: UpdateDisplayGroupRect
306  * @tc.desc: test UpdateDisplayGroupRect
307  * @tc.type: FUNC
308  */
309 HWTEST_F(WindowLayoutPolicyTest, UpdateDisplayGroupRect, Function | SmallTest | Level2)
310 {
311     auto displayRect = displayGroupInfo_->GetDisplayRect(defaultDisplayInfo_->GetDisplayId());
312     ASSERT_FALSE(WindowHelper::IsEmptyRect(displayRect));
313 
314     Rect newDisplayRect = {
315         .posX_ = static_cast<int32_t>(displayRect.posX_ + displayRect.width_),
316         .posY_ = displayRect.posY_,
317         .width_ = 1920, // width:  1920
318         .height_ = 1280 // height: 1080
319     };
320     auto displayInfo = CreateDisplayInfo(newDisplayRect);
321     ASSERT_TRUE(displayInfo != nullptr);
322     displayGroupInfo_->AddDisplayInfo(displayInfo);
323     layoutPolicy_->UpdateDisplayGroupRect();
324 
325     displayGroupInfo_->displayInfosMap_.clear();
326     layoutPolicy_->UpdateDisplayGroupRect();
327 }
328 
329 /**
330  * @tc.name: UpdateDisplayGroupLimitRect
331  * @tc.desc: test UpdateDisplayGroupLimitRect
332  * @tc.type: FUNC
333  */
334 HWTEST_F(WindowLayoutPolicyTest, UpdateDisplayGroupLimitRect, Function | SmallTest | Level2)
335 {
336     auto displayRect = displayGroupInfo_->GetDisplayRect(defaultDisplayInfo_->GetDisplayId());
337     ASSERT_FALSE(WindowHelper::IsEmptyRect(displayRect));
338     Rect newDisplayRect = {
339         .posX_ = static_cast<int32_t>(displayRect.posX_ + displayRect.width_),
340         .posY_ = displayRect.posY_,
341         .width_ = 1920, // width:  1920
342         .height_ = 1280 // height: 1080
343     };
344     auto displayInfo = CreateDisplayInfo(newDisplayRect);
345     ASSERT_TRUE(displayInfo != nullptr);
346     displayGroupInfo_->AddDisplayInfo(displayInfo);
347     auto allDisplayRect = displayGroupInfo_->GetAllDisplayRects();
348     layoutPolicy_->limitRectMap_ = allDisplayRect;
349     layoutPolicy_->UpdateDisplayGroupLimitRect();
350 
351     layoutPolicy_->limitRectMap_.clear();
352     layoutPolicy_->UpdateDisplayGroupLimitRect();
353 }
354 
355 /**
356  * @tc.name: UpdateRectInDisplayGroup
357  * @tc.desc: test UpdateRectInDisplayGroup, test childNode
358  * @tc.type: FUNC
359  */
360 HWTEST_F(WindowLayoutPolicyTest, UpdateRectInDisplayGroup, Function | SmallTest | Level2)
361 {
362     auto displayRect = displayGroupInfo_->GetDisplayRect(defaultDisplayInfo_->GetDisplayId());
363     ASSERT_FALSE(WindowHelper::IsEmptyRect(displayRect));
364     windowInfo_.winRect_ = {
365         .posX_ = static_cast<int32_t>(displayRect.posX_ + displayRect.width_ * 0.5),  // ratio: 0.5
366         .posY_ = static_cast<int32_t>(displayRect.posY_ + displayRect.height_ * 0.5), // ratio: 0.5
367         .width_ = displayRect.width_,
368         .height_ = displayRect.height_
369     };
370     sptr<WindowNode> parentNode = CreateWindowNode(windowInfo_);
371     ASSERT_TRUE(parentNode != nullptr);
372 
373     Rect newDisplayRect = {
374         .posX_ = static_cast<int32_t>(displayRect.posX_ + displayRect.width_),
375         .posY_ = displayRect.posY_,
376         .width_ = 1920, // width:  1920
377         .height_ = 1280 // height: 1080
378     };
379     layoutPolicy_->UpdateRectInDisplayGroup(parentNode, displayRect, newDisplayRect);
380 
381     // create child node
382     sptr<WindowNode> node = CreateWindowNode(windowInfo_);
383     ASSERT_TRUE(node != nullptr);
384     parentNode->children_.push_back(node);
385     layoutPolicy_->UpdateRectInDisplayGroup(parentNode, displayRect, newDisplayRect);
386 }
387 
388 /**
389  * @tc.name: UpdateMultiDisplayFlag
390  * @tc.desc: test UpdateMultiDisplayFlag
391  * @tc.type: FUNC
392  */
393 HWTEST_F(WindowLayoutPolicyTest, UpdateMultiDisplayFlag, Function | SmallTest | Level2)
394 {
395     layoutPolicy_->UpdateMultiDisplayFlag();
396 
397     auto displayRect = displayGroupInfo_->GetDisplayRect(defaultDisplayInfo_->GetDisplayId());
398     ASSERT_FALSE(WindowHelper::IsEmptyRect(displayRect));
399     Rect newDisplayRect = {
400         .posX_ = static_cast<int32_t>(displayRect.posX_ + displayRect.width_),
401         .posY_ = displayRect.posY_,
402         .width_ = 1920, // width:  1920
403         .height_ = 1280 // height: 1080
404     };
405     auto displayInfo = CreateDisplayInfo(newDisplayRect);
406     ASSERT_TRUE(displayInfo != nullptr);
407     displayGroupInfo_->AddDisplayInfo(displayInfo);
408     layoutPolicy_->UpdateMultiDisplayFlag();
409 }
410 
411 /**
412  * @tc.name: UpdateRectInDisplayGroupForAllNodes01
413  * @tc.desc: test UpdateRectInDisplayGroupForAllNodes01
414  * @tc.type: FUNC
415  */
416 HWTEST_F(WindowLayoutPolicyTest, UpdateRectInDisplayGroupForAllNodes01, Function | SmallTest | Level2)
417 {
418     auto displayRect = displayGroupInfo_->GetDisplayRect(defaultDisplayInfo_->GetDisplayId());
419     ASSERT_FALSE(WindowHelper::IsEmptyRect(displayRect));
420     Rect newDisplayRect = {
421         .posX_ = static_cast<int32_t>(displayRect.posX_ + displayRect.width_),
422         .posY_ = displayRect.posY_,
423         .width_ = 1920, // width:  1920
424         .height_ = 1280 // height: 1080
425     };
426 
427     layoutPolicy_->UpdateRectInDisplayGroupForAllNodes(0, displayRect, newDisplayRect);
428 
429     windowInfo_.winRect_ = {
430         .posX_ = static_cast<int32_t>(displayRect.posX_ + displayRect.width_ * 0.5),  // ratio: 0.5
431         .posY_ = static_cast<int32_t>(displayRect.posY_ + displayRect.height_ * 0.5), // ratio: 0.5
432         .width_ = displayRect.width_,
433         .height_ = displayRect.height_
434     };
435     sptr<WindowNode> node = CreateWindowNode(windowInfo_);
436     ASSERT_TRUE(node != nullptr);
437 
438     // Add node on display window tree
439     layoutPolicy_->displayGroupWindowTree_[0][WindowRootNodeType::APP_WINDOW_NODE]->push_back(node);
440     layoutPolicy_->UpdateRectInDisplayGroupForAllNodes(0, displayRect, newDisplayRect);
441 
442     node->isShowingOnMultiDisplays_ = true;
443     layoutPolicy_->UpdateRectInDisplayGroupForAllNodes(0, displayRect, newDisplayRect);
444 }
445 
446 /**
447  * @tc.name: UpdateRectInDisplayGroupForAllNodes02
448  * @tc.desc: test UpdateRectInDisplayGroupForAllNodes
449  * @tc.type: FUNC
450  */
451 HWTEST_F(WindowLayoutPolicyTest, UpdateRectInDisplayGroupForAllNodes02, Function | SmallTest | Level2)
452 {
453     auto displayRect = displayGroupInfo_->GetDisplayRect(defaultDisplayInfo_->GetDisplayId());
454     ASSERT_FALSE(WindowHelper::IsEmptyRect(displayRect));
455     Rect newDisplayRect = {
456         .posX_ = static_cast<int32_t>(displayRect.posX_ + displayRect.width_),
457         .posY_ = displayRect.posY_,
458         .width_ = 1920, // width:  1920
459         .height_ = 1280 // height: 1080
460     };
461 
462     windowInfo_.winRect_ = {
463         .posX_ = static_cast<int32_t>(displayRect.posX_ + displayRect.width_ * 0.5),  // ratio: 0.5
464         .posY_ = static_cast<int32_t>(displayRect.posY_ + displayRect.height_ * 0.5), // ratio: 0.5
465         .width_ = displayRect.width_,
466         .height_ = displayRect.height_
467     };
468 
469     // Add app node on display window tree
470     sptr<WindowNode> node = CreateWindowNode(windowInfo_);
471     ASSERT_TRUE(node != nullptr);
472     node->isShowingOnMultiDisplays_ = true;
473     layoutPolicy_->displayGroupWindowTree_[0][WindowRootNodeType::APP_WINDOW_NODE]->push_back(node);
474     layoutPolicy_->UpdateRectInDisplayGroupForAllNodes(0, displayRect, newDisplayRect);
475 
476     // Add above node on display window tree
477     windowInfo_.winType_ = WindowType::WINDOW_TYPE_FLOAT_CAMERA;
478     sptr<WindowNode> aboveNode = CreateWindowNode(windowInfo_);
479     ASSERT_TRUE(aboveNode != nullptr);
480     layoutPolicy_->displayGroupWindowTree_[0][WindowRootNodeType::ABOVE_WINDOW_NODE]->push_back(aboveNode);
481     layoutPolicy_->UpdateRectInDisplayGroupForAllNodes(0, displayRect, newDisplayRect);
482 }
483 
484 /**
485  * @tc.name: UpdateDisplayRectAndDisplayGroupInfo
486  * @tc.desc: test UpdateDisplayRectAndDisplayGroupInfo
487  * @tc.type: FUNC
488  */
489 HWTEST_F(WindowLayoutPolicyTest, UpdateDisplayRectAndDisplayGroupInfo, Function | SmallTest | Level2)
490 {
491     std::map<DisplayId, Rect> displayRectMap = {};
492     layoutPolicy_->UpdateDisplayRectAndDisplayGroupInfo(displayRectMap);
493     displayRectMap = displayGroupInfo_->GetAllDisplayRects();
494     layoutPolicy_->UpdateDisplayRectAndDisplayGroupInfo(displayRectMap);
495 }
496 
497 /**
498  * @tc.name: ProcessDisplayCreate
499  * @tc.desc: test ProcessDisplayCreate
500  * @tc.type: FUNC
501  */
502 HWTEST_F(WindowLayoutPolicyTest, ProcessDisplayCreate, Function | SmallTest | Level2)
503 {
504     std::map<DisplayId, Rect> newDisplayRectMap = {};
505     layoutPolicy_->ProcessDisplayCreate(0, newDisplayRectMap);
506 
507     layoutPolicy_->ProcessDisplayCreate(1, newDisplayRectMap);
508 
509     auto displayRect = displayGroupInfo_->GetDisplayRect(defaultDisplayInfo_->GetDisplayId());
510     ASSERT_FALSE(WindowHelper::IsEmptyRect(displayRect));
511     newDisplayRectMap.insert(std::make_pair(0, displayRect));
512     Rect newDisplayRect = {
513         .posX_ = static_cast<int32_t>(displayRect.posX_ + displayRect.width_),
514         .posY_ = displayRect.posY_,
515         .width_ = 1920, // width:  1920
516         .height_ = 1280 // height: 1080
517     };
518     newDisplayRectMap.insert(std::make_pair(1, newDisplayRect));
519     layoutPolicy_->ProcessDisplayCreate(1, newDisplayRectMap);
520 
521     auto displayInfo = CreateDisplayInfo(newDisplayRect);
522     ASSERT_TRUE(displayInfo != nullptr);
523 }
524 
525 /**
526  * @tc.name: ProcessDisplayDestroy
527  * @tc.desc: test ProcessDisplayDestroy
528  * @tc.type: FUNC
529  */
530 HWTEST_F(WindowLayoutPolicyTest, ProcessDisplayDestroy, Function | SmallTest | Level2)
531 {
532     std::map<DisplayId, Rect> newDisplayRectMap = {};
533     layoutPolicy_->ProcessDisplayDestroy(0, newDisplayRectMap);
534 
535     layoutPolicy_->ProcessDisplayDestroy(1, newDisplayRectMap);
536 
537     auto displayRect = displayGroupInfo_->GetDisplayRect(defaultDisplayInfo_->GetDisplayId());
538     ASSERT_FALSE(WindowHelper::IsEmptyRect(displayRect));
539 }
540 
541 /**
542  * @tc.name: ProcessDisplaySizeChangeOrRotation
543  * @tc.desc: test ProcessDisplaySizeChangeOrRotation
544  * @tc.type: FUNC
545  */
546 HWTEST_F(WindowLayoutPolicyTest, ProcessDisplaySizeChangeOrRotation, Function | SmallTest | Level2)
547 {
548     std::map<DisplayId, Rect> newDisplayRectMap = {};
549     layoutPolicy_->ProcessDisplayDestroy(0, newDisplayRectMap);
550 
551     layoutPolicy_->ProcessDisplayDestroy(1, newDisplayRectMap);
552 
553     auto displayRect = displayGroupInfo_->GetDisplayRect(defaultDisplayInfo_->GetDisplayId());
554     ASSERT_FALSE(WindowHelper::IsEmptyRect(displayRect));
555 }
556 
557 /**
558  * @tc.name: NotifyAnimationSizeChangeIfNeeded
559  * @tc.desc: test NotifyAnimationSizeChangeIfNeeded
560  * @tc.type: FUNC
561  */
562 HWTEST_F(WindowLayoutPolicyTest, NotifyAnimationSizeChangeIfNeeded, Function | SmallTest | Level2)
563 {
564     layoutPolicy_->NotifyAnimationSizeChangeIfNeeded();
565 }
566 
567 /**
568  * @tc.name: LayoutWindowNode
569  * @tc.desc: test LayoutWindowNode
570  * @tc.type: FUNC
571  */
572 HWTEST_F(WindowLayoutPolicyTest, LayoutWindowNode, Function | SmallTest | Level2)
573 {
574     sptr<WindowNode> node = nullptr;
575     layoutPolicy_->LayoutWindowNode(node);
576 
577     node = CreateWindowNode(windowInfo_);
578     ASSERT_TRUE(node != nullptr);
579     layoutPolicy_->LayoutWindowNode(node);
580 
581     node->parent_ = container_->appWindowNode_;
582     layoutPolicy_->LayoutWindowNode(node);
583 
584     node->currentVisibility_ = true;
585     layoutPolicy_->LayoutWindowNode(node);
586 
587     node->GetWindowProperty()->SetWindowType(WindowType::WINDOW_TYPE_STATUS_BAR);
588     layoutPolicy_->LayoutWindowNode(node);
589 
590     // create child node
591     sptr<WindowNode> child = CreateWindowNode(windowInfo_);
592     ASSERT_TRUE(child != nullptr);
593     node->children_.push_back(child);
594     layoutPolicy_->LayoutWindowNode(node);
595 }
596 
597 /**
598  * @tc.name: UpdateClientRect
599  * @tc.desc: test UpdateClientRect
600  * @tc.type: FUNC
601  */
602 HWTEST_F(WindowLayoutPolicyTest, UpdateClientRect, Function | SmallTest | Level2)
603 {
604     sptr<WindowNode> node = CreateWindowNode(windowInfo_);
605     ASSERT_TRUE(node != nullptr);
606     layoutPolicy_->UpdateClientRect(node->GetWindowRect(), node, WindowSizeChangeReason::MOVE);
607 }
608 
609 /**
610  * @tc.name: UpdateClientRectAndResetReason
611  * @tc.desc: test UpdateClientRectAndResetReason
612  * @tc.type: FUNC
613  */
614 HWTEST_F(WindowLayoutPolicyTest, UpdateClientRectAndResetReason, Function | SmallTest | Level2)
615 {
616     sptr<WindowNode> node = CreateWindowNode(windowInfo_);
617     ASSERT_TRUE(node != nullptr);
618     layoutPolicy_->UpdateClientRectAndResetReason(node, node->GetWindowRect());
619 }
620 
621 /**
622  * @tc.name: RemoveWindowNode
623  * @tc.desc: test RemoveWindowNode
624  * @tc.type: FUNC
625  */
626 HWTEST_F(WindowLayoutPolicyTest, RemoveWindowNode, Function | SmallTest | Level2)
627 {
628     sptr<WindowNode> node = CreateWindowNode(windowInfo_);
629     ASSERT_TRUE(node != nullptr);
630     layoutPolicy_->RemoveWindowNode(node);
631 
632     windowInfo_.winType_ = WindowType::WINDOW_TYPE_NAVIGATION_BAR;
633     sptr<WindowNode> avoidNode = CreateWindowNode(windowInfo_);
634     ASSERT_TRUE(avoidNode != nullptr);
635     layoutPolicy_->RemoveWindowNode(avoidNode);
636 
637     windowInfo_.winType_ = WindowType::WINDOW_TYPE_DOCK_SLICE;
638     sptr<WindowNode> dividerNode = CreateWindowNode(windowInfo_);
639     ASSERT_TRUE(dividerNode != nullptr);
640     layoutPolicy_->RemoveWindowNode(dividerNode);
641 }
642 
643 /**
644  * @tc.name: UpdateWindowNode
645  * @tc.desc: test UpdateWindowNode
646  * @tc.type: FUNC
647  */
648 HWTEST_F(WindowLayoutPolicyTest, UpdateWindowNode, Function | SmallTest | Level2)
649 {
650     auto displayRect = displayGroupInfo_->GetDisplayRect(defaultDisplayInfo_->GetDisplayId());
651     ASSERT_FALSE(WindowHelper::IsEmptyRect(displayRect));
652     windowInfo_.winRect_ = { 0, static_cast<uint32_t>(displayRect.height_ * 0.9), // ratio: 0.9
653         displayRect.width_, static_cast<uint32_t>(displayRect.height_ * 0.1) };   // ratio: 0.1
654     windowInfo_.winType_ = WindowType::WINDOW_TYPE_NAVIGATION_BAR;
655     sptr<WindowNode> avoidNode = CreateWindowNode(windowInfo_);
656     ASSERT_TRUE(avoidNode != nullptr);
657     layoutPolicy_->UpdateWindowNode(avoidNode);
658 }
659 
660 /**
661  * @tc.name: ComputeDecoratedRequestRect
662  * @tc.desc: test ComputeDecoratedRequestRect
663  * @tc.type: FUNC
664  */
665 HWTEST_F(WindowLayoutPolicyTest, ComputeDecoratedRequestRect, Function | SmallTest | Level2)
666 {
667     sptr<WindowNode> node = CreateWindowNode(windowInfo_);
668     ASSERT_TRUE(node != nullptr);
669     layoutPolicy_->ComputeDecoratedRequestRect(node);
670 
671     sptr<WindowNode> node1 = CreateWindowNode(windowInfo_);
672     ASSERT_TRUE(node1 != nullptr);
673     windowInfo_.reason_ = WindowSizeChangeReason::MOVE;
674     layoutPolicy_->ComputeDecoratedRequestRect(node1);
675 
676     windowInfo_.decorEnable_ = true;
677     sptr<WindowNode> node2 = CreateWindowNode(windowInfo_);
678     ASSERT_TRUE(node2 != nullptr);
679     layoutPolicy_->ComputeDecoratedRequestRect(node2);
680 }
681 
682 /**
683  * @tc.name: CalcAndSetNodeHotZone
684  * @tc.desc: test CalcAndSetNodeHotZone
685  * @tc.type: FUNC
686  */
687 HWTEST_F(WindowLayoutPolicyTest, CalcAndSetNodeHotZone, Function | SmallTest | Level2)
688 {
689     sptr<WindowNode> node = CreateWindowNode(windowInfo_);
690     ASSERT_TRUE(node != nullptr);
691     layoutPolicy_->CalcAndSetNodeHotZone(node->GetWindowRect(), node);
692 
693     layoutPolicy_->UpdateLayoutRect(node);
694     layoutPolicy_->CalcAndSetNodeHotZone(node->GetWindowRect(), node);
695 
696     layoutPolicy_->CalcAndSetNodeHotZone(node->GetWindowRect(), node);
697 }
698 
699 /**
700  * @tc.name: FixWindowSizeByRatioIfDragBeyondLimitRegion01
701  * @tc.desc: test FixWindowSizeByRatioIfDragBeyondLimitRegion01
702  * @tc.type: FUNC
703  */
704 HWTEST_F(WindowLayoutPolicyTest, FixWindowSizeByRatioIfDragBeyondLimitRegion01, Function | SmallTest | Level2)
705 {
706     sptr<WindowNode> node = CreateWindowNode(windowInfo_);
707     ASSERT_TRUE(node != nullptr);
708     WindowSizeLimits sizeLimits = { 400, 400, 400, 400, 2.0, 2.0 }; // sizeLimits: 400, 400, 400, 400, 2.0, 2.0
709     node->SetWindowUpdatedSizeLimits(sizeLimits);
710     Rect finalRect;
711     layoutPolicy_->FixWindowSizeByRatioIfDragBeyondLimitRegion(node, finalRect);
712 
713     sizeLimits.maxWidth_ = 800;  // maxWidth: 800
714     node->SetWindowUpdatedSizeLimits(sizeLimits);
715     layoutPolicy_->FixWindowSizeByRatioIfDragBeyondLimitRegion(node, finalRect);
716 
717     sizeLimits.maxWidth_ = 400;  // maxWidth:  400
718     sizeLimits.maxHeight_ = 800; // maxHeight: 800
719     node->SetWindowUpdatedSizeLimits(sizeLimits);
720     layoutPolicy_->FixWindowSizeByRatioIfDragBeyondLimitRegion(node, finalRect);
721 
722     sizeLimits.maxWidth_ = 800;  // maxWidth:  800
723     sizeLimits.maxHeight_ = 800; // maxHeight: 800
724     node->SetWindowUpdatedSizeLimits(sizeLimits);
725     layoutPolicy_->FixWindowSizeByRatioIfDragBeyondLimitRegion(node, finalRect);
726 
727     sizeLimits.maxWidth_ = 800;  // maxWidth:  800
728     sizeLimits.maxHeight_ = 800; // maxHeight: 800
729     node->SetWindowUpdatedSizeLimits(sizeLimits);
730 
731     auto newRect = node->GetWindowRect();
732     newRect.height_ = 400;       // maxHeight: 400
733     node->SetWindowRect(newRect);
734     layoutPolicy_->FixWindowSizeByRatioIfDragBeyondLimitRegion(node, finalRect);
735 
736     newRect = { 200, 200, 500, 200 }; // rect: 200, 200, 500, 200
737     node->SetWindowRect(newRect);
738     layoutPolicy_->FixWindowSizeByRatioIfDragBeyondLimitRegion(node, finalRect);
739 
740     newRect = { 200, 200, 100, 200 }; // rect: 200, 200, 100, 200
741     node->SetWindowRect(newRect);
742     layoutPolicy_->FixWindowSizeByRatioIfDragBeyondLimitRegion(node, finalRect);
743 }
744 
745 /**
746  * @tc.name: FixWindowSizeByRatioIfDragBeyondLimitRegion02
747  * @tc.desc: test FixWindowSizeByRatioIfDragBeyondLimitRegion02
748  * @tc.type: FUNC
749  */
750 HWTEST_F(WindowLayoutPolicyTest, FixWindowSizeByRatioIfDragBeyondLimitRegion02, Function | SmallTest | Level2)
751 {
752     sptr<WindowNode> node = CreateWindowNode(windowInfo_);
753     ASSERT_TRUE(node != nullptr);
754     WindowSizeLimits sizeLimits = { 800, 800, 400, 400, 2.0, 1.0 }; // sizeLimits: 800, 800, 400, 400, 2.0, 1.0
755     node->SetWindowUpdatedSizeLimits(sizeLimits);
756 
757     Rect newRect = { 200, 200, 300, 200 }; // rect: 200, 200, 300, 200
758     Rect finalRect;
759     node->SetWindowRect(newRect);
760     layoutPolicy_->FixWindowSizeByRatioIfDragBeyondLimitRegion(node, finalRect);
761 
762     sizeLimits.minRatio_ = 1.0; // ratio: 1.0
763     sizeLimits.maxRatio_ = 1.0; // ratio: 1.0
764     node->SetWindowUpdatedSizeLimits(sizeLimits);
765     layoutPolicy_->FixWindowSizeByRatioIfDragBeyondLimitRegion(node, finalRect);
766 
767     sizeLimits.minRatio_ = 2.0; // ratio: 2.0
768     sizeLimits.maxRatio_ = 2.0; // ratio: 2.0
769     node->SetWindowUpdatedSizeLimits(sizeLimits);
770     layoutPolicy_->FixWindowSizeByRatioIfDragBeyondLimitRegion(node, finalRect);
771 
772     newRect = { 200, 200, 400, 200 }; // rect: 200, 200, 400, 200
773     node->SetWindowRect(newRect);
774     layoutPolicy_->FixWindowSizeByRatioIfDragBeyondLimitRegion(node, finalRect);
775 
776     auto displayRect = displayGroupInfo_->GetDisplayRect(defaultDisplayInfo_->GetDisplayId());
777     ASSERT_FALSE(WindowHelper::IsEmptyRect(displayRect));
778     layoutPolicy_->limitRectMap_[0] = displayRect;
779 }
780 
781 /**
782  * @tc.name: FixWindowSizeByRatioIfDragBeyondLimitRegion03
783  * @tc.desc: test FixWindowSizeByRatioIfDragBeyondLimitRegion03
784  * @tc.type: FUNC
785  */
786 HWTEST_F(WindowLayoutPolicyTest, FixWindowSizeByRatioIfDragBeyondLimitRegion03, Function | SmallTest | Level2)
787 {
788     sptr<WindowNode> node = CreateWindowNode(windowInfo_);
789     ASSERT_TRUE(node != nullptr);
790     WindowSizeLimits sizeLimits = { 800, 800, 400, 400, 2.0, 1.0 }; // sizeLimits: 800, 800, 400, 400, 2.0, 1.0
791 
792     node->SetWindowUpdatedSizeLimits(sizeLimits);
793 
794     Rect newRect = { 200, 200, 300, 200 }; // rect: 200, 200, 300, 200
795     node->SetWindowRect(newRect);
796 
797     auto displayRect = displayGroupInfo_->GetDisplayRect(defaultDisplayInfo_->GetDisplayId());
798     ASSERT_FALSE(WindowHelper::IsEmptyRect(displayRect));
799     layoutPolicy_->limitRectMap_[0] = displayRect;
800 
801     windowInfo_.winType_ = WindowType::WINDOW_TYPE_LAUNCHER_DOCK;
802     sptr<WindowNode> dockNode = CreateWindowNode(windowInfo_);
803     layoutPolicy_->displayGroupWindowTree_[0][WindowRootNodeType::ABOVE_WINDOW_NODE]->push_back(dockNode);
804 
805     Rect dockWinRect = { 200, 200, 50, 20 }; // rect: 200, 200, 50, 20
806     Rect finalRect;
807     dockNode->SetWindowRect(dockWinRect);
808     layoutPolicy_->FixWindowSizeByRatioIfDragBeyondLimitRegion(node, finalRect);
809 
810     dockWinRect = { 200, 200, 50, (displayRect.height_ - static_cast<uint32_t>(200)) }; // param: 200, 50
811     dockNode->SetWindowRect(dockWinRect);
812     layoutPolicy_->FixWindowSizeByRatioIfDragBeyondLimitRegion(node, finalRect);
813 
814     dockWinRect = { 200, 200, 20, 50 }; // param: 200, 200, 20, 50
815     dockNode->SetWindowRect(dockWinRect);
816     layoutPolicy_->FixWindowSizeByRatioIfDragBeyondLimitRegion(node, finalRect);
817 
818     dockWinRect = { 0, 200, 20, 50 };   // param: 0, 200, 20, 50
819     dockNode->SetWindowRect(dockWinRect);
820     layoutPolicy_->FixWindowSizeByRatioIfDragBeyondLimitRegion(node, finalRect);
821 
822     dockWinRect = { 200, 200, (displayRect.width_ - static_cast<uint32_t>(200)), 50 }; // param: 200, 50
823     dockNode->SetWindowRect(dockWinRect);
824     layoutPolicy_->FixWindowSizeByRatioIfDragBeyondLimitRegion(node, finalRect);
825 
826     dockWinRect = { 200, 200, (displayRect.width_ - static_cast<uint32_t>(100)), 50 }; // param: 200, 100, 50
827     dockNode->SetWindowRect(dockWinRect);
828     layoutPolicy_->FixWindowSizeByRatioIfDragBeyondLimitRegion(node, finalRect);
829 }
830 
831 /**
832  * @tc.name: FixWindowSizeByRatioIfDragBeyondLimitRegion04
833  * @tc.desc: test FixWindowSizeByRatioIfDragBeyondLimitRegion04
834  * @tc.type: FUNC
835  */
836 HWTEST_F(WindowLayoutPolicyTest, FixWindowSizeByRatioIfDragBeyondLimitRegion04, Function | SmallTest | Level2)
837 {
838     sptr<WindowNode> node = CreateWindowNode(windowInfo_);
839     ASSERT_TRUE(node != nullptr);
840     WindowSizeLimits sizeLimits = { 800, 800, 400, 400, 2.0, 1.0 }; // sizeLimits: 800, 800, 400, 400, 2.0, 1.0
841     node->SetWindowUpdatedSizeLimits(sizeLimits);
842 
843     Rect newRect = { 200, 200, 300, 200 }; // rect: 200, 200, 300, 200
844     node->SetWindowRect(newRect);
845 
846     auto displayRect = displayGroupInfo_->GetDisplayRect(defaultDisplayInfo_->GetDisplayId());
847     ASSERT_FALSE(WindowHelper::IsEmptyRect(displayRect));
848     layoutPolicy_->limitRectMap_[0] = displayRect;
849     windowInfo_.winType_ = WindowType::WINDOW_TYPE_LAUNCHER_DOCK;
850     sptr<WindowNode> dockNode = CreateWindowNode(windowInfo_);
851     layoutPolicy_->displayGroupWindowTree_[0][WindowRootNodeType::ABOVE_WINDOW_NODE]->push_back(dockNode);
852 
853     Rect dockWinRect = { 200, (displayRect.height_ * 0.9), // param: 200, 0.9,
854         50, ((displayRect.height_ * 0.1)) };               // param: 50, 0.1
855     dockNode->SetWindowRect(dockWinRect);
856     Rect finalRect;
857     layoutPolicy_->FixWindowSizeByRatioIfDragBeyondLimitRegion(node, finalRect);
858 
859     float virtualPixelRatio = layoutPolicy_->GetVirtualPixelRatio(node->GetDisplayId());
860     uint32_t windowTitleBarH = static_cast<uint32_t>(WINDOW_TITLE_BAR_HEIGHT * virtualPixelRatio);
861     int32_t limitMaxPosX = displayRect.posX_ + static_cast<int32_t>(displayRect.width_ - windowTitleBarH);
862 
863     newRect = { limitMaxPosX, 200, 300, 200 }; // param: 200, 300
864     layoutPolicy_->FixWindowSizeByRatioIfDragBeyondLimitRegion(node, finalRect);
865 
866     newRect = { limitMaxPosX, 200, 200, 200 }; // param: 200
867     layoutPolicy_->FixWindowSizeByRatioIfDragBeyondLimitRegion(node, finalRect);
868 }
869 
870 /**
871  * @tc.name: FixWindowSizeByRatioIfDragBeyondLimitRegion05
872  * @tc.desc: test FixWindowSizeByRatioIfDragBeyondLimitRegion05
873  * @tc.type: FUNC
874  */
875 HWTEST_F(WindowLayoutPolicyTest, FixWindowSizeByRatioIfDragBeyondLimitRegion05, Function | SmallTest | Level2)
876 {
877     sptr<WindowNode> node = CreateWindowNode(windowInfo_);
878     ASSERT_TRUE(node != nullptr);
879     WindowSizeLimits sizeLimits = { 800, 800, 400, 400, 2.0, 1.0 }; // sizeLimits: 800, 800, 400, 400, 2.0, 1.0
880     node->SetWindowUpdatedSizeLimits(sizeLimits);
881 
882     Rect newRect = { 200, 200, 300, 200 }; // rect: 200, 200, 300, 200
883     node->SetWindowRect(newRect);
884 
885     auto displayRect = displayGroupInfo_->GetDisplayRect(defaultDisplayInfo_->GetDisplayId());
886     ASSERT_FALSE(WindowHelper::IsEmptyRect(displayRect));
887     layoutPolicy_->limitRectMap_[0] = displayRect;
888     windowInfo_.winType_ = WindowType::WINDOW_TYPE_LAUNCHER_DOCK;
889     sptr<WindowNode> dockNode = CreateWindowNode(windowInfo_);
890     ASSERT_TRUE(dockNode != nullptr);
891     layoutPolicy_->displayGroupWindowTree_[0][WindowRootNodeType::ABOVE_WINDOW_NODE]->push_back(dockNode);
892 
893     Rect dockWinRect = {
894         0,
895         static_cast<uint32_t>(displayRect.height_ * 0.9), // ratio: 0.9
896         static_cast<uint32_t>(displayRect.height_ * 0.1), // ratio: 0.1
897         static_cast<uint32_t>(displayRect.height_ * 0.1)  // ratio: 0.1
898     };
899     dockNode->SetWindowRect(dockWinRect);
900     Rect finalRect;
901     layoutPolicy_->FixWindowSizeByRatioIfDragBeyondLimitRegion(node, finalRect);
902 
903     float virtualPixelRatio = layoutPolicy_->GetVirtualPixelRatio(node->GetDisplayId());
904     uint32_t windowTitleBarH = static_cast<uint32_t>(WINDOW_TITLE_BAR_HEIGHT * virtualPixelRatio);
905     int32_t limitMinPosX = displayRect.posX_ + static_cast<int32_t>(windowTitleBarH);
906 
907     newRect = { limitMinPosX, 200, 300, 200 }; // rect: 200, 300, 200
908     layoutPolicy_->FixWindowSizeByRatioIfDragBeyondLimitRegion(node, finalRect);
909 
910     newRect = { limitMinPosX, 200, 200, 200 }; // rect: 200, 200, 200
911     layoutPolicy_->FixWindowSizeByRatioIfDragBeyondLimitRegion(node, finalRect);
912 }
913 
914 /**
915  * @tc.name: GetSystemSizeLimits
916  * @tc.desc: test GetSystemSizeLimits
917  * @tc.type: FUNC
918  */
919 HWTEST_F(WindowLayoutPolicyTest, GetSystemSizeLimits, Function | SmallTest | Level2)
920 {
921     auto displayRect = displayGroupInfo_->GetDisplayRect(defaultDisplayInfo_->GetDisplayId());
922     ASSERT_FALSE(WindowHelper::IsEmptyRect(displayRect));
923 
924     sptr<WindowNode> node1 = CreateWindowNode(windowInfo_);
925     ASSERT_TRUE(node1 != nullptr);
926     static_cast<void>(layoutPolicy_->GetSystemSizeLimits(node1, displayRect, 1.0)); // ratio: 1.0
927 
928     windowInfo_.winType_ = WindowType::WINDOW_TYPE_FLOAT_CAMERA;
929     sptr<WindowNode> node2 = CreateWindowNode(windowInfo_);
930     ASSERT_TRUE(node2 != nullptr);
931     static_cast<void>(layoutPolicy_->GetSystemSizeLimits(node2, displayRect, 1.0)); // ratio: 1.0
932 }
933 
934 /**
935  * @tc.name: UpdateWindowSizeLimits
936  * @tc.desc: test UpdateWindowSizeLimits
937  * @tc.type: FUNC
938  */
939 HWTEST_F(WindowLayoutPolicyTest, UpdateWindowSizeLimits, Function | SmallTest | Level2)
940 {
941     auto displayRect = displayGroupInfo_->GetDisplayRect(defaultDisplayInfo_->GetDisplayId());
942     ASSERT_FALSE(WindowHelper::IsEmptyRect(displayRect));
943 
944     sptr<WindowNode> node1 = CreateWindowNode(windowInfo_);
945     ASSERT_TRUE(node1 != nullptr);
946     static_cast<void>(layoutPolicy_->GetSystemSizeLimits(node1, displayRect, 1.0)); // ratio: 1.0
947 
948     windowInfo_.winType_ = WindowType::WINDOW_TYPE_FLOAT_CAMERA;
949     sptr<WindowNode> node2 = CreateWindowNode(windowInfo_);
950     ASSERT_TRUE(node2 != nullptr);
951     static_cast<void>(layoutPolicy_->GetSystemSizeLimits(node2, displayRect, 1.0)); // ratio: 1.0
952 }
953 
954 /**
955  * @tc.name: UpdateFloatingWindowSizeForStretchableWindow04
956  * @tc.desc: test UpdateFloatingWindowSizeForStretchableWindow04
957  * @tc.type: FUNC
958  */
959 HWTEST_F(WindowLayoutPolicyTest, UpdateFloatingWindowSizeForStretchableWindow04, Function | SmallTest | Level2)
960 {
961     auto displayRect = displayGroupInfo_->GetDisplayRect(defaultDisplayInfo_->GetDisplayId());
962     ASSERT_FALSE(WindowHelper::IsEmptyRect(displayRect));
963 
964     sptr<WindowNode> node = CreateWindowNode(windowInfo_);
965     ASSERT_TRUE(node != nullptr);
966     Rect winRect = { 0, 0, 0, 0};
967     layoutPolicy_->UpdateFloatingWindowSizeForStretchableWindow(node, displayRect, winRect);
968 
969     node->SetWindowSizeChangeReason(WindowSizeChangeReason::DRAG);
970     layoutPolicy_->UpdateFloatingWindowSizeForStretchableWindow(node, displayRect, winRect);
971 
972     winRect = { 0, 0, 40, 0 }; // width: 40
973     node->SetOriginRect(winRect);
974     layoutPolicy_->UpdateFloatingWindowSizeForStretchableWindow(node, displayRect, winRect);
975 
976     winRect = { 0, 0, 0, 40 }; // height: 40
977     node->SetOriginRect(winRect);
978     layoutPolicy_->UpdateFloatingWindowSizeForStretchableWindow(node, displayRect, winRect);
979 
980     winRect = { 0, 0, 40, 40 }; // width/height: 40
981     node->SetOriginRect(winRect);
982     layoutPolicy_->UpdateFloatingWindowSizeForStretchableWindow(node, displayRect, winRect);
983 
984     node->SetDragType(DragType::DRAG_LEFT_OR_RIGHT);
985     layoutPolicy_->UpdateFloatingWindowSizeForStretchableWindow(node, displayRect, winRect);
986 
987     node->SetDragType(DragType::DRAG_BOTTOM_OR_TOP);
988     layoutPolicy_->UpdateFloatingWindowSizeForStretchableWindow(node, displayRect, winRect);
989 
990     node->SetDragType(DragType::DRAG_LEFT_TOP_CORNER);
991     layoutPolicy_->UpdateFloatingWindowSizeForStretchableWindow(node, displayRect, winRect);
992 
993     node->SetDragType(DragType::DRAG_RIGHT_TOP_CORNER);
994     layoutPolicy_->UpdateFloatingWindowSizeForStretchableWindow(node, displayRect, winRect);
995 }
996 
997 /**
998  * @tc.name: UpdateFloatingWindowSizeForStretchableWindow05
999  * @tc.desc: test UpdateFloatingWindowSizeForStretchableWindow05
1000  * @tc.type: FUNC
1001  */
1002 HWTEST_F(WindowLayoutPolicyTest, UpdateFloatingWindowSizeForStretchableWindow05, Function | SmallTest | Level2)
1003 {
1004     auto displayRect = displayGroupInfo_->GetDisplayRect(defaultDisplayInfo_->GetDisplayId());
1005     ASSERT_FALSE(WindowHelper::IsEmptyRect(displayRect));
1006 
1007     sptr<WindowNode> node = CreateWindowNode(windowInfo_);
1008     ASSERT_TRUE(node != nullptr);
1009     WindowSizeLimits sizeLimits = { 800, 800, 400, 400, 2.0, 1.0 }; // sizeLimits: 800, 800, 400, 400, 2.0, 1.0
1010     node->SetWindowUpdatedSizeLimits(sizeLimits);
1011 
1012     Rect winRect = { 0, 0, 400, 400 }; // width/height: 400
1013     node->SetOriginRect(winRect);
1014     layoutPolicy_->UpdateFloatingWindowSizeForStretchableWindow(node, displayRect, winRect);
1015 
1016     winRect = { 0, 0, 300, 300 }; // width/height: 300
1017     node->SetOriginRect(winRect);
1018     layoutPolicy_->UpdateFloatingWindowSizeForStretchableWindow(node, displayRect, winRect);
1019 
1020     winRect = { 0, 0, 500, 500 }; // width/height: 500
1021     node->SetOriginRect(winRect);
1022     layoutPolicy_->UpdateFloatingWindowSizeForStretchableWindow(node, displayRect, winRect);
1023 }
1024 
1025 /**
1026  * @tc.name: UpdateFloatingWindowSizeBySizeLimits
1027  * @tc.desc: test UpdateFloatingWindowSizeBySizeLimits
1028  * @tc.type: FUNC
1029  */
1030 HWTEST_F(WindowLayoutPolicyTest, UpdateFloatingWindowSizeBySizeLimits, Function | SmallTest | Level2)
1031 {
1032     auto displayRect = displayGroupInfo_->GetDisplayRect(defaultDisplayInfo_->GetDisplayId());
1033     ASSERT_FALSE(WindowHelper::IsEmptyRect(displayRect));
1034 
1035     sptr<WindowNode> node = CreateWindowNode(windowInfo_);
1036     ASSERT_TRUE(node != nullptr);
1037     WindowSizeLimits sizeLimits = { 800, 400, 800, 400, 2.0, 1.0 }; // sizeLimits: 800, 400, 800, 400, 2.0, 1.0
1038     node->SetWindowUpdatedSizeLimits(sizeLimits);
1039     Rect winRect = { 0, 0, 400, 400 }; // width/height: 400
1040     layoutPolicy_->UpdateFloatingWindowSizeBySizeLimits(node, displayRect, winRect);
1041 
1042     sizeLimits = { 800, 800, 400, 400, 2.0, 1.0 }; // sizeLimits: 800, 800, 400, 400, 2.0, 1.0
1043     node->SetWindowUpdatedSizeLimits(sizeLimits);
1044     winRect = { 0, 0, 400, 400 }; // width/height: 400
1045     layoutPolicy_->UpdateFloatingWindowSizeBySizeLimits(node, displayRect, winRect);
1046 
1047     sizeLimits = { 800, 500, 800, 400, 2.0, 1.0 }; // sizeLimits: 800, 500, 800, 400, 2.0, 1.0
1048     node->SetWindowUpdatedSizeLimits(sizeLimits);
1049     layoutPolicy_->UpdateFloatingWindowSizeBySizeLimits(node, displayRect, winRect);
1050 
1051     sizeLimits = { 800, 400, 600, 400, 2.0, 1.0 }; // sizeLimits: 800, 400, 600, 400, 2.0, 1.0
1052     node->SetWindowUpdatedSizeLimits(sizeLimits);
1053     layoutPolicy_->UpdateFloatingWindowSizeBySizeLimits(node, displayRect, winRect);
1054 
1055     sizeLimits = { 800, 400, 800, 400, 2.0, 1.0 }; // sizeLimits: 800, 400, 800, 400, 2.0, 1.0
1056     node->SetWindowUpdatedSizeLimits(sizeLimits);
1057     layoutPolicy_->UpdateFloatingWindowSizeBySizeLimits(node, displayRect, winRect);
1058 
1059     sizeLimits = { 800, 800, 400, 400, 2.0, 1.0 }; // sizeLimits: 800, 800, 400, 400, 2.0, 1.0
1060     node->SetWindowUpdatedSizeLimits(sizeLimits);
1061     node->SetDragType(DragType::DRAG_BOTTOM_OR_TOP);
1062     layoutPolicy_->UpdateFloatingWindowSizeBySizeLimits(node, displayRect, winRect);
1063 
1064     node->SetDragType(DragType::DRAG_LEFT_OR_RIGHT);
1065     layoutPolicy_->UpdateFloatingWindowSizeBySizeLimits(node, displayRect, winRect);
1066 
1067     node->GetWindowProperty()->SetWindowType(WindowType::WINDOW_TYPE_DRAGGING_EFFECT);
1068     layoutPolicy_->UpdateFloatingWindowSizeBySizeLimits(node, displayRect, winRect);
1069 }
1070 
1071 /**
1072  * @tc.name: LimitFloatingWindowSize
1073  * @tc.desc: test LimitFloatingWindowSize
1074  * @tc.type: FUNC
1075  */
1076 HWTEST_F(WindowLayoutPolicyTest, LimitFloatingWindowSize, Function | SmallTest | Level2)
1077 {
1078     auto displayRect = displayGroupInfo_->GetDisplayRect(defaultDisplayInfo_->GetDisplayId());
1079     ASSERT_FALSE(WindowHelper::IsEmptyRect(displayRect));
1080 
1081     sptr<WindowNode> node = CreateWindowNode(windowInfo_);
1082     ASSERT_TRUE(node != nullptr);
1083     Rect winRect = { 0, 0, 400, 400 }; // width/height: 400
1084     layoutPolicy_->LimitFloatingWindowSize(node, displayRect, winRect);
1085 
1086     node->SetWindowSizeChangeReason(WindowSizeChangeReason::DRAG);
1087     node->SetWindowRect(winRect);
1088     layoutPolicy_->LimitFloatingWindowSize(node, displayRect, winRect);
1089 
1090     Rect newRect = { 10, 0, 400, 400 }; // window rect: 10, 0, 400, 400
1091     layoutPolicy_->LimitFloatingWindowSize(node, displayRect, newRect);
1092 
1093     newRect = { 0, 10, 400, 400 }; // window rect: 0, 10, 400, 400
1094     layoutPolicy_->LimitFloatingWindowSize(node, displayRect, newRect);
1095 
1096     newRect = { 10, 10, 400, 400 }; // window rect: 10, 10, 400, 400
1097     layoutPolicy_->LimitFloatingWindowSize(node, displayRect, newRect);
1098 
1099     node->SetWindowMode(WindowMode::WINDOW_MODE_FULLSCREEN);
1100     layoutPolicy_->LimitFloatingWindowSize(node, displayRect, winRect);
1101 
1102     node->GetWindowProperty()->SetWindowType(WindowType::WINDOW_TYPE_APP_COMPONENT);
1103     layoutPolicy_->LimitFloatingWindowSize(node, displayRect, winRect);
1104 }
1105 
1106 /**
1107  * @tc.name: LimitMainFloatingWindowPosition
1108  * @tc.desc: test LimitMainFloatingWindowPosition
1109  * @tc.type: FUNC
1110  */
1111 HWTEST_F(WindowLayoutPolicyTest, LimitMainFloatingWindowPosition, Function | SmallTest | Level2)
1112 {
1113     sptr<WindowNode> node = CreateWindowNode(windowInfo_);
1114     ASSERT_TRUE(node != nullptr);
1115     Rect winRect = { 0, 0, 400, 400 }; // width/height: 400
1116     node->SetWindowRect(winRect);
1117     node->SetRequestRect(winRect);
1118     winRect.posX_ = 20; // posX: 20
1119     layoutPolicy_->LimitMainFloatingWindowPosition(node, winRect);
1120 
1121     node->SetWindowSizeChangeReason(WindowSizeChangeReason::DRAG);
1122     node->SetWindowRect(winRect);
1123     layoutPolicy_->LimitMainFloatingWindowPosition(node, winRect);
1124 
1125     node->SetWindowMode(WindowMode::WINDOW_MODE_FULLSCREEN);
1126     layoutPolicy_->LimitMainFloatingWindowPosition(node, winRect);
1127 }
1128 
1129 /**
1130  * @tc.name: LimitWindowPositionWhenDrag
1131  * @tc.desc: test LimitWindowPositionWhenDrag
1132  * @tc.type: FUNC
1133  */
1134 HWTEST_F(WindowLayoutPolicyTest, LimitWindowPositionWhenDrag, Function | SmallTest | Level2)
1135 {
1136     auto displayRect = displayGroupInfo_->GetDisplayRect(defaultDisplayInfo_->GetDisplayId());
1137     ASSERT_FALSE(WindowHelper::IsEmptyRect(displayRect));
1138 
1139     sptr<WindowNode> node = CreateWindowNode(windowInfo_);
1140     ASSERT_TRUE(node != nullptr);
1141     Rect winRect = { 0, 0, 400, 400 }; // width/height: 400
1142     node->SetWindowRect(winRect);
1143 
1144     windowInfo_.winType_ = WindowType::WINDOW_TYPE_LAUNCHER_DOCK;
1145     sptr<WindowNode> dockNode = CreateWindowNode(windowInfo_);
1146     layoutPolicy_->displayGroupWindowTree_[0][WindowRootNodeType::ABOVE_WINDOW_NODE]->push_back(dockNode);
1147 
1148     Rect dockWinRect = { 200, 200, 50, 20 };  // 200, 200, 50, 20
1149     dockNode->SetWindowRect(dockWinRect);
1150     layoutPolicy_->LimitWindowPositionWhenDrag(node, winRect);
1151 
1152     dockWinRect = { 200, 200, 50, (displayRect.height_ - static_cast<uint32_t>(200)) }; //param: 200 200 20
1153     dockNode->SetWindowRect(dockWinRect);
1154     layoutPolicy_->LimitWindowPositionWhenDrag(node, winRect);
1155 
1156     dockWinRect = { 200, 200, 20, 50 };   // 200, 200, 20, 50
1157     dockNode->SetWindowRect(dockWinRect);
1158     layoutPolicy_->LimitWindowPositionWhenDrag(node, winRect);
1159 
1160     dockWinRect = { 0, 200, 20, 50 };     // 200, 200, 20, 50
1161     dockNode->SetWindowRect(dockWinRect);
1162     layoutPolicy_->LimitWindowPositionWhenDrag(node, winRect);
1163 }
1164 
1165 /**
1166  * @tc.name: LimitWindowPositionWhenDrag01
1167  * @tc.desc: test LimitWindowPositionWhenDrag01
1168  * @tc.type: FUNC
1169  */
1170 HWTEST_F(WindowLayoutPolicyTest, LimitWindowPositionWhenDrag01, Function | SmallTest | Level2)
1171 {
1172     auto displayRect = displayGroupInfo_->GetDisplayRect(defaultDisplayInfo_->GetDisplayId());
1173     ASSERT_FALSE(WindowHelper::IsEmptyRect(displayRect));
1174 
1175     sptr<WindowNode> node = CreateWindowNode(windowInfo_);
1176     ASSERT_TRUE(node != nullptr);
1177     Rect winRect = { 0, 0, 400, 400 }; // width/height: 400
1178     node->SetWindowRect(winRect);
1179 
1180     layoutPolicy_->limitRectMap_[node->GetDisplayId()] = displayRect;
1181     float virtualPixelRatio = layoutPolicy_->GetVirtualPixelRatio(node->GetDisplayId());
1182     uint32_t windowTitleBarH = static_cast<uint32_t>(WINDOW_TITLE_BAR_HEIGHT * virtualPixelRatio);
1183     int32_t limitMinPosX = displayRect.posX_ + static_cast<int32_t>(windowTitleBarH);
1184     int32_t limitMaxPosX = displayRect.posX_ + static_cast<int32_t>(displayRect.width_ - windowTitleBarH);
1185     int32_t limitMinPosY = displayRect.posY_;
1186     int32_t limitMaxPosY = displayRect.posY_ + static_cast<int32_t>(displayRect.height_ - windowTitleBarH);
1187 
1188     Rect newRect = winRect;
1189     newRect.posX_ = limitMinPosX - newRect.width_ - 1;
1190     layoutPolicy_->LimitWindowPositionWhenDrag(node, newRect);
1191 
1192     newRect.width_ -= 1;
1193     layoutPolicy_->LimitWindowPositionWhenDrag(node, newRect);
1194 
1195     winRect.posX_ = limitMaxPosX + 1;
1196     layoutPolicy_->LimitWindowPositionWhenDrag(node, newRect);
1197 
1198     newRect.width_ = winRect.width_;
1199     layoutPolicy_->LimitWindowPositionWhenDrag(node, newRect);
1200 
1201     newRect.posY_ = limitMaxPosY + 1;
1202     layoutPolicy_->LimitWindowPositionWhenDrag(node, newRect);
1203 
1204     newRect.height_ += 1;
1205     layoutPolicy_->LimitWindowPositionWhenDrag(node, newRect);
1206 
1207     newRect.posY_ = limitMinPosY - 1;
1208     layoutPolicy_->LimitWindowPositionWhenDrag(node, newRect);
1209 
1210     newRect.height_ = winRect.height_;
1211     layoutPolicy_->LimitWindowPositionWhenDrag(node, newRect);
1212 }
1213 
1214 /**
1215  * @tc.name: LimitWindowPositionWhenInitRectOrMove
1216  * @tc.desc: test LimitWindowPositionWhenInitRectOrMove
1217  * @tc.type: FUNC
1218  */
1219 HWTEST_F(WindowLayoutPolicyTest, LimitWindowPositionWhenInitRectOrMove, Function | SmallTest | Level2)
1220 {
1221     auto displayRect = displayGroupInfo_->GetDisplayRect(defaultDisplayInfo_->GetDisplayId());
1222     ASSERT_FALSE(WindowHelper::IsEmptyRect(displayRect));
1223 
1224     sptr<WindowNode> node = CreateWindowNode(windowInfo_);
1225     ASSERT_TRUE(node != nullptr);
1226     Rect winRect = { 0, 0, 400, 400 }; // width/height: 400
1227     node->SetWindowRect(winRect);
1228 
1229     windowInfo_.winType_ = WindowType::WINDOW_TYPE_LAUNCHER_DOCK;
1230     sptr<WindowNode> dockNode = CreateWindowNode(windowInfo_);
1231     ASSERT_TRUE(dockNode != nullptr);
1232     layoutPolicy_->displayGroupWindowTree_[0][WindowRootNodeType::ABOVE_WINDOW_NODE]->push_back(dockNode);
1233 
1234     Rect dockWinRect = { 200, 200, 50, 20 }; // rect : 200, 200, 50, 20
1235     dockNode->SetWindowRect(dockWinRect);
1236     layoutPolicy_->LimitWindowPositionWhenInitRectOrMove(node, winRect);
1237 
1238     dockWinRect = { 200, 200, 50, (displayRect.height_ - static_cast<uint32_t>(200)) }; // param: 200, 50
1239     dockNode->SetWindowRect(dockWinRect);
1240     layoutPolicy_->LimitWindowPositionWhenInitRectOrMove(node, winRect);
1241 
1242     dockWinRect = { 200, 200, 20, 50 }; // rect : 200, 200, 20, 50
1243     dockNode->SetWindowRect(dockWinRect);
1244     layoutPolicy_->LimitWindowPositionWhenInitRectOrMove(node, winRect);
1245 
1246     dockWinRect = { 0, 200, 20, 50 };   // rect : 0, 200, 20, 50
1247     dockNode->SetWindowRect(dockWinRect);
1248     layoutPolicy_->LimitWindowPositionWhenInitRectOrMove(node, winRect);
1249 
1250     node->SetWindowMode(WindowMode::WINDOW_MODE_FULLSCREEN);
1251     layoutPolicy_->LimitWindowPositionWhenInitRectOrMove(node, winRect);
1252 }
1253 
1254 /**
1255  * @tc.name: GetDockWindowShowState
1256  * @tc.desc: test GetDockWindowShowState
1257  * @tc.type: FUNC
1258  */
1259 HWTEST_F(WindowLayoutPolicyTest, GetDockWindowShowState, Function | SmallTest | Level2)
1260 {
1261     auto displayRect = displayGroupInfo_->GetDisplayRect(defaultDisplayInfo_->GetDisplayId());
1262     ASSERT_FALSE(WindowHelper::IsEmptyRect(displayRect));
1263 
1264     Rect dockWinRect = { 200, 200, 50, 20 };  // rect : 200, 200, 50, 20
1265     layoutPolicy_->GetDockWindowShowState(0, dockWinRect);
1266 
1267     windowInfo_.winType_ = WindowType::WINDOW_TYPE_LAUNCHER_DOCK;
1268     sptr<WindowNode> dockNode = CreateWindowNode(windowInfo_);
1269     ASSERT_TRUE(dockNode != nullptr);
1270     layoutPolicy_->displayGroupWindowTree_[0][WindowRootNodeType::ABOVE_WINDOW_NODE]->push_back(dockNode);
1271 
1272     dockNode->SetWindowRect(dockWinRect);
1273     layoutPolicy_->GetDockWindowShowState(0, dockWinRect);
1274 
1275     dockWinRect = { 200, 200, 50, (displayRect.height_ - static_cast<uint32_t>(200)) };  // param : 200, 50
1276     dockNode->SetWindowRect(dockWinRect);
1277     layoutPolicy_->GetDockWindowShowState(0, dockWinRect);
1278 
1279     dockWinRect = { 200, 200, 20, 50 };  // rect : 200, 200, 20, 50
1280     dockNode->SetWindowRect(dockWinRect);
1281     layoutPolicy_->GetDockWindowShowState(0, dockWinRect);
1282 
1283     dockWinRect = { 0, 200, 20, 50 };    // rect : 0, 200, 20, 50
1284     dockNode->SetWindowRect(dockWinRect);
1285     layoutPolicy_->GetDockWindowShowState(0, dockWinRect);
1286 }
1287 
1288 /**
1289  * @tc.name: GetAvoidPosType
1290  * @tc.desc: test GetAvoidPosType
1291  * @tc.type: FUNC
1292  */
1293 HWTEST_F(WindowLayoutPolicyTest, GetAvoidPosType, Function | SmallTest | Level2)
1294 {
1295     auto displayRect = displayGroupInfo_->GetDisplayRect(defaultDisplayInfo_->GetDisplayId());
1296     ASSERT_FALSE(WindowHelper::IsEmptyRect(displayRect));
1297 
1298     Rect winRect = { 200, 200, 50, 20 }; // rect : 200, 200, 50, 20
1299     layoutPolicy_->GetAvoidPosType(winRect, 0);
1300 
1301     layoutPolicy_->GetAvoidPosType(winRect, 1);
1302 
1303     winRect.width_ = displayRect.width_;
1304     layoutPolicy_->GetAvoidPosType(winRect, 0);
1305 
1306     winRect.posY_ = displayRect.posY_;
1307     layoutPolicy_->GetAvoidPosType(winRect, 0);
1308 
1309     winRect.height_ = displayRect.height_;
1310     layoutPolicy_->GetAvoidPosType(winRect, 0);
1311 
1312     winRect.posY_ = displayRect.posY_;
1313     layoutPolicy_->GetAvoidPosType(winRect, 0);
1314 }
1315 
1316 /**
1317  * @tc.name: UpdateLimitRect
1318  * @tc.desc: test UpdateLimitRect
1319  * @tc.type: FUNC
1320  */
1321 HWTEST_F(WindowLayoutPolicyTest, UpdateLimitRect, Function | SmallTest | Level2)
1322 {
1323     auto displayRect = displayGroupInfo_->GetDisplayRect(defaultDisplayInfo_->GetDisplayId());
1324     ASSERT_FALSE(WindowHelper::IsEmptyRect(displayRect));
1325 
1326     Rect limitRect = displayRect;
1327 
1328     sptr<WindowNode> node = CreateWindowNode(windowInfo_);
1329     ASSERT_TRUE(node != nullptr);
1330     Rect avoidRect = { 200, 200, 50, 20 }; // rect : 200, 200, 50, 20
1331     node->SetWindowRect(avoidRect);
1332     layoutPolicy_->UpdateLimitRect(node, limitRect);
1333 
1334     node->GetWindowProperty()->SetWindowType(WindowType::WINDOW_TYPE_NAVIGATION_BAR);
1335     layoutPolicy_->UpdateLimitRect(node, limitRect);
1336 
1337     avoidRect.width_ = displayRect.width_;
1338     node->SetWindowRect(avoidRect);
1339     layoutPolicy_->UpdateLimitRect(node, limitRect);
1340 
1341     avoidRect.posY_ = displayRect.posY_;
1342     node->SetWindowRect(avoidRect);
1343     layoutPolicy_->UpdateLimitRect(node, limitRect);
1344 
1345     avoidRect.height_ = displayRect.height_;
1346     node->SetWindowRect(avoidRect);
1347     layoutPolicy_->UpdateLimitRect(node, limitRect);
1348 
1349     avoidRect.posY_ = displayRect.posY_;
1350     node->SetWindowRect(avoidRect);
1351     layoutPolicy_->UpdateLimitRect(node, limitRect);
1352 }
1353 
1354 /**
1355  * @tc.name: UpdateSurfaceBounds
1356  * @tc.desc: test UpdateSurfaceBounds
1357  * @tc.type: FUNC
1358  */
1359 HWTEST_F(WindowLayoutPolicyTest, UpdateSurfaceBounds, Function | SmallTest | Level2)
1360 {
1361     sptr<WindowNode> node = CreateWindowNode(windowInfo_);
1362     ASSERT_TRUE(node != nullptr);
1363     Rect winRect = { 0, 0, 20, 50 }; // rect : 0, 0, 20, 50
1364     Rect preRect = { 0, 0, 20, 60 }; // rect : 0, 0, 20, 60
1365     layoutPolicy_->UpdateSurfaceBounds(node, winRect, preRect);
1366 
1367     node->SetWindowSizeChangeReason(WindowSizeChangeReason::MAXIMIZE);
1368     layoutPolicy_->UpdateSurfaceBounds(node, winRect, preRect);
1369 
1370     node->SetWindowSizeChangeReason(WindowSizeChangeReason::RECOVER);
1371     layoutPolicy_->UpdateSurfaceBounds(node, winRect, preRect);
1372 
1373     node->SetWindowSizeChangeReason(WindowSizeChangeReason::ROTATION);
1374     layoutPolicy_->UpdateSurfaceBounds(node, winRect, preRect);
1375 
1376     node->SetWindowSizeChangeReason(WindowSizeChangeReason::UNDEFINED);
1377     layoutPolicy_->UpdateSurfaceBounds(node, winRect, preRect);
1378 }
1379 }
1380 }
1381 }
1382