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