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 <optional>
17 
18 #include "gtest/gtest.h"
19 
20 #define private public
21 #define protected public
22 
23 #include "test/mock/core/pipeline/mock_pipeline_context.h"
24 
25 #include "base/geometry/dimension.h"
26 #include "base/memory/ace_type.h"
27 #include "base/memory/referenced.h"
28 #include "core/components_ng/base/view_stack_processor.h"
29 #include "core/components_ng/layout/layout_property.h"
30 #include "core/components_ng/pattern/grid_col/grid_col_layout_pattern.h"
31 #include "core/components_ng/pattern/grid_col/grid_col_model_ng.h"
32 #include "core/components_ng/pattern/grid_row/grid_row_layout_pattern.h"
33 #include "core/components_ng/pattern/grid_row/grid_row_model_ng.h"
34 
35 using namespace testing;
36 using namespace testing::ext;
37 
38 namespace OHOS::Ace::NG {
39 namespace {
40 const InspectorFilter filter;
41 constexpr float DEFAULT_SPAN_WIDTH = 100.0f;
42 constexpr uint8_t DEFAULT_COLUMNS = 8;
43 constexpr float DEFAULT_GRID_ROW_WIDTH = (DEFAULT_SPAN_WIDTH * DEFAULT_COLUMNS);
44 constexpr uint8_t DEFAULT_OFFSET = 7;
45 constexpr uint8_t DEFAULT_HEIGHT = 10;
46 constexpr uint8_t TEST_ALIGN_HEIGHT = 30;
47 } // namespace
48 
49 class GridRowTestNg : public testing::Test {
50 public:
51     void SetUp() override;
52     void TearDown() override;
53     static void SetUpTestSuite();
54     static void TearDownTestSuite();
55 
56     static RefPtr<LayoutWrapperNode> CreateLayoutWrapperAndLayout(bool needLayout);
57     static void TestGridColWidth(uint8_t span, uint8_t expectWidth);
58     static testing::AssertionResult TestGridColGeometry(
59         uint8_t offset, uint8_t span, uint8_t expectOffsetX, uint8_t expectLines);
60     static OffsetF GetColOffset(RefPtr<LayoutWrapperNode>& layoutWrapper, int32_t index);
61 
62     static RefPtr<FrameNode> rowNode_;
63     static std::vector<RefPtr<FrameNode>> colNodes_;
64     static const int32_t colNum_ = 2;
65 };
66 
SetUpTestSuite()67 void GridRowTestNg::SetUpTestSuite()
68 {
69     /* Create framenode */
70     GridRowModelNG gridRowModelNG;
71     gridRowModelNG.Create();
72     GridColModelNG gridColModelNG;
73     for (int32_t i = 0; i < colNum_; i++) {
74         gridColModelNG.Create();
75         auto frameNode = AceType::DynamicCast<FrameNode>(ViewStackProcessor::GetInstance()->GetMainElementNode());
76         ViewStackProcessor::GetInstance()->Pop();
77         colNodes_.emplace_back(frameNode);
78     }
79     rowNode_ = AceType::DynamicCast<FrameNode>(ViewStackProcessor::GetInstance()->GetMainElementNode());
80     ViewStackProcessor::GetInstance()->PopContainer();
81     MockPipelineContext::SetUp();
82 }
83 
TearDownTestSuite()84 void GridRowTestNg::TearDownTestSuite()
85 {
86     rowNode_->Clean();
87     colNodes_.clear();
88     MockPipelineContext::TearDown();
89 }
90 
SetUp()91 void GridRowTestNg::SetUp()
92 {
93     /* Set default grid-row properties */
94     auto rowLayout = rowNode_->GetLayoutProperty<GridRowLayoutProperty>();
95     rowLayout->UpdateColumns(V2::GridContainerSize(DEFAULT_COLUMNS));
96     rowLayout->UpdateGutter(V2::Gutter());
97     rowLayout->UpdateDirection(V2::GridRowDirection::Row);
98     rowLayout->UpdateSizeType(V2::GridSizeType::UNDEFINED);
99     rowLayout->UpdateBreakPoints(V2::BreakPoints());
100 
101     /* Set default grid-col properties */
102     auto colLayoutFront = colNodes_.front()->GetLayoutProperty<GridColLayoutProperty>();
103     colLayoutFront->UpdateSpan(V2::GridContainerSize(1));
104     colLayoutFront->UpdateOffset(V2::GridContainerSize(DEFAULT_OFFSET));
105     colLayoutFront->UpdateUserDefinedIdealSize(CalcSize(std::nullopt, CalcLength(DEFAULT_HEIGHT)));
106 
107     auto colLayoutBack = colNodes_.back()->GetLayoutProperty<GridColLayoutProperty>();
108     colLayoutBack->UpdateSpan(V2::GridContainerSize(1));
109     colLayoutBack->UpdateOffset(V2::GridContainerSize(0));
110     colLayoutBack->UpdateUserDefinedIdealSize(CalcSize(std::nullopt, CalcLength(DEFAULT_HEIGHT)));
111 
112     MockPipelineContext::GetCurrent()->SetWindowModal(WindowModal::CONTAINER_MODAL);
113     MockPipelineContext::GetCurrent()->windowManager_ = AceType::MakeRefPtr<WindowManager>();
114     MockPipelineContext::GetCurrent()->windowManager_->SetWindowGetModeCallBack(
115         []() -> WindowMode { return WindowMode::WINDOW_MODE_FLOATING; });
116 }
117 
TearDown()118 void GridRowTestNg::TearDown() {}
119 
120 RefPtr<FrameNode> GridRowTestNg::rowNode_;
121 std::vector<RefPtr<FrameNode>> GridRowTestNg::colNodes_;
122 const int32_t GridRowTestNg::colNum_;
123 
CreateLayoutWrapperAndLayout(bool needLayout=false)124 RefPtr<LayoutWrapperNode> GridRowTestNg::CreateLayoutWrapperAndLayout(bool needLayout = false)
125 {
126     auto layoutWrapper = rowNode_->CreateLayoutWrapper();
127     LayoutConstraintF constraint;
128     OptionalSizeF size;
129     size.SetWidth(DEFAULT_GRID_ROW_WIDTH);
130     constraint.UpdateIllegalSelfIdealSizeWithCheck(size);
131     auto layoutProperty = layoutWrapper->GetLayoutProperty();
132     layoutProperty->BuildGridProperty(rowNode_);
133     layoutProperty->UpdateLayoutConstraint(constraint);
134     auto geometryNode = layoutWrapper->GetGeometryNode();
135     geometryNode->SetParentLayoutConstraint(constraint);
136     layoutProperty->UpdateContentConstraint();
137     auto algorithm = layoutWrapper->GetLayoutAlgorithm();
138     algorithm->Measure(AceType::RawPtr(layoutWrapper));
139     if (needLayout) {
140         algorithm->Layout(AceType::RawPtr(layoutWrapper));
141     }
142     return layoutWrapper;
143 }
144 
145 /* Examine grid-col width */
TestGridColWidth(uint8_t span,uint8_t expectWidth)146 void GridRowTestNg::TestGridColWidth(uint8_t span, uint8_t expectWidth)
147 {
148     // first grid-col occupies the first line to constrain the line-height of that line
149     auto colNode = colNodes_.front();
150     auto layoutProperty = colNode->GetLayoutProperty<GridColLayoutProperty>();
151     layoutProperty->UpdateSpan(V2::GridContainerSize(span));
152     layoutProperty->UpdateOffset(V2::GridContainerSize(0));
153 
154     // Check geometry Size
155     auto layoutWrapper = CreateLayoutWrapperAndLayout();
156     auto spanWidth = layoutWrapper->GetOrCreateChildByIndex(0)->GetGeometryNode()->GetFrameSize().Width();
157     EXPECT_EQ(spanWidth, expectWidth * DEFAULT_SPAN_WIDTH);
158 }
159 
160 /* Examine the last grid-col position according to span/offset */
TestGridColGeometry(uint8_t offset,uint8_t span,uint8_t expectOffsetX,uint8_t expectLines)161 testing::AssertionResult GridRowTestNg::TestGridColGeometry(
162     uint8_t offset, uint8_t span, uint8_t expectOffsetX, uint8_t expectLines)
163 {
164     auto firstColNode = colNodes_.front();
165     auto firstColLayoutProperty = firstColNode->GetLayoutProperty<GridColLayoutProperty>();
166     firstColLayoutProperty->UpdateSpan(V2::GridContainerSize(span));
167     firstColLayoutProperty->UpdateOffset(V2::GridContainerSize(offset));
168 
169     auto layoutWrapper = CreateLayoutWrapperAndLayout(true);
170     auto secondColOffset = GetColOffset(layoutWrapper, 1);
171     const OffsetF expectOffset = OffsetF(DEFAULT_SPAN_WIDTH * expectOffsetX, DEFAULT_HEIGHT * expectLines);
172     if (secondColOffset == expectOffset) {
173         return testing::AssertionSuccess();
174     }
175     return testing::AssertionFailure() << "secondColOffset: " << secondColOffset.ToString()
176                                        << " But expect offset: " << expectOffset.ToString();
177 }
178 
GetColOffset(RefPtr<LayoutWrapperNode> & layoutWrapper,int32_t index)179 OffsetF GridRowTestNg::GetColOffset(RefPtr<LayoutWrapperNode>& layoutWrapper, int32_t index)
180 {
181     return layoutWrapper->GetOrCreateChildByIndex(index)->GetGeometryNode()->GetFrameOffset();
182 }
183 
184 /**
185  * @tc.name: Algorithm001
186  * @tc.desc: Test GridRow Measure().
187  * @tc.type: FUNC
188  */
189 HWTEST_F(GridRowTestNg, Algorithm001, TestSize.Level1)
190 {
191     TestGridColWidth(0, 0);
192     TestGridColWidth(1, 1);
193     TestGridColWidth(DEFAULT_COLUMNS + 1, DEFAULT_COLUMNS); // span > columns
194 }
195 
196 /**
197  * @tc.name: Algorithm002
198  * @tc.desc: Test GridRow layout algorithm with different span/offset.
199  * @tc.type: FUNC
200  */
201 HWTEST_F(GridRowTestNg, Algorithm002, TestSize.Level1)
202 {
203     // Set the first col: span + offset == columns
204     // Test second col position
205     EXPECT_TRUE(TestGridColGeometry(2, 6, 0, 1));
206 
207     // span + offset > columns, offset <= columns
208     EXPECT_TRUE(TestGridColGeometry(2, 7, 7, 0));
209 
210     // span < columns, offset > columns
211     EXPECT_TRUE(TestGridColGeometry(9, 2, 3, 0));
212 
213     // span > columns
214     EXPECT_TRUE(TestGridColGeometry(1, 9, 0, 1));
215 }
216 
217 /**
218  * @tc.name: Algorithm003
219  * @tc.desc: Test GridRow layout algorithm with different sizetype.
220  * @tc.type: FUNC
221  */
222 HWTEST_F(GridRowTestNg, Algorithm003, TestSize.Level1)
223 {
224     /* update grid-row columns of LG size */
225     auto layoutProperty = rowNode_->GetLayoutProperty<GridRowLayoutProperty>();
226     constexpr int32_t testColumns = 7;
227     V2::GridContainerSize columns(DEFAULT_COLUMNS);
228     columns.lg = testColumns;
229     layoutProperty->UpdateColumns(columns);
230     layoutProperty->UpdateSizeType(V2::GridSizeType::LG);
231     auto layoutWrapper = CreateLayoutWrapperAndLayout(true);
232     auto frameRect = layoutWrapper->GetOrCreateChildByIndex(0)->GetGeometryNode()->GetFrameRect();
233     float columnWidth = frameRect.Width();
234 
235     // the first grid-col's offset occupies a whole line
236     EXPECT_EQ(columnWidth, DEFAULT_SPAN_WIDTH);
237     EXPECT_EQ(frameRect.GetX(), testColumns * DEFAULT_SPAN_WIDTH);
238 }
239 
240 /**
241  * @tc.name: Algorithm004
242  * @tc.desc: Test GridRow layout algorithm with different gutter.
243  * @tc.type: FUNC
244  */
245 HWTEST_F(GridRowTestNg, Algorithm004, TestSize.Level1)
246 {
247     auto layoutProperty = rowNode_->GetLayoutProperty<GridRowLayoutProperty>();
248     constexpr float gutterVal = 20.0f;
249     layoutProperty->UpdateGutter(V2::Gutter(Dimension(gutterVal)));
250     auto layoutWrapper = CreateLayoutWrapperAndLayout(true);
251     auto frameRect = layoutWrapper->GetOrCreateChildByIndex(0)->GetGeometryNode()->GetFrameRect();
252     float columnWidth = frameRect.Width();
253 
254     // the first grid-col's offset occupies a whole line
255     const float expectColWidth = (DEFAULT_GRID_ROW_WIDTH - (DEFAULT_COLUMNS - 1) * gutterVal) / DEFAULT_COLUMNS;
256     EXPECT_EQ(columnWidth, expectColWidth);
257     EXPECT_EQ(frameRect.GetX(), DEFAULT_GRID_ROW_WIDTH - expectColWidth);
258 }
259 
260 /**
261  * @tc.name: Algorithm005
262  * @tc.desc: Test GridRow layout algorithm with different direction.
263  * @tc.type: FUNC
264  */
265 HWTEST_F(GridRowTestNg, Algorithm005, TestSize.Level1)
266 {
267     /**
268      * @tc.steps: step1. V2::GridRowDirection::Row
269      * @tc.expected: GridCol is sorted from left to right
270      */
271     auto layoutProperty = rowNode_->GetLayoutProperty<GridRowLayoutProperty>();
272     auto direction = layoutProperty->GetDirection();
273     EXPECT_EQ(direction, V2::GridRowDirection::Row);
274     auto layoutWrapper = CreateLayoutWrapperAndLayout(true);
275     auto frameRect = layoutWrapper->GetOrCreateChildByIndex(0)->GetGeometryNode()->GetFrameRect();
276     auto columnWidth = frameRect.Width();
277 
278     EXPECT_EQ(columnWidth, DEFAULT_SPAN_WIDTH);
279     EXPECT_EQ(frameRect.GetX(), DEFAULT_GRID_ROW_WIDTH - DEFAULT_SPAN_WIDTH);
280     EXPECT_EQ(frameRect.GetY(), 0);
281     frameRect = layoutWrapper->GetOrCreateChildByIndex(1)->GetGeometryNode()->GetFrameRect();
282     EXPECT_EQ(frameRect.GetX(), 0);
283     EXPECT_EQ(frameRect.GetY(), DEFAULT_HEIGHT);
284 
285     /**
286      * @tc.steps: step2. V2::GridRowDirection::RowReverse
287      * @tc.expected: GridCol is sorted from right to left
288      */
289     layoutProperty->UpdateDirection(V2::GridRowDirection::RowReverse);
290     layoutWrapper = CreateLayoutWrapperAndLayout(true);
291     frameRect = layoutWrapper->GetOrCreateChildByIndex(0)->GetGeometryNode()->GetFrameRect();
292     columnWidth = frameRect.Width();
293     EXPECT_EQ(columnWidth, DEFAULT_SPAN_WIDTH);
294     EXPECT_EQ(frameRect.GetX(), DEFAULT_GRID_ROW_WIDTH - (DEFAULT_OFFSET + 1) * DEFAULT_SPAN_WIDTH);
295     EXPECT_EQ(frameRect.GetY(), 0);
296     frameRect = layoutWrapper->GetOrCreateChildByIndex(1)->GetGeometryNode()->GetFrameRect();
297     EXPECT_EQ(frameRect.GetX(), (DEFAULT_COLUMNS - 1) * DEFAULT_SPAN_WIDTH);
298     EXPECT_EQ(frameRect.GetY(), DEFAULT_HEIGHT);
299 }
300 
301 /**
302  * @tc.name: Algorithm006
303  * @tc.desc: Test GridCol layout order.
304  * @tc.type: FUNC
305  */
306 HWTEST_F(GridRowTestNg, Algorithm006, TestSize.Level1)
307 {
308     auto colLayoutFront = colNodes_.front()->GetLayoutProperty<GridColLayoutProperty>();
309     colLayoutFront->UpdateOrder(V2::GridContainerSize(6));
310     auto colLayoutBack = colNodes_.back()->GetLayoutProperty<GridColLayoutProperty>();
311     colLayoutBack->UpdateOrder(V2::GridContainerSize(-1));
312     auto layoutWrapper = CreateLayoutWrapperAndLayout(true);
313     auto frameRect = layoutWrapper->GetOrCreateChildByIndex(0)->GetGeometryNode()->GetFrameRect();
314 
315     EXPECT_EQ(frameRect.GetX(), 0);
316     EXPECT_EQ(frameRect.GetY(), DEFAULT_HEIGHT); // because of DEFAULT_OFFSET, the col is at second row
317 }
318 
319 /**
320  * @tc.name: Algorithm007
321  * @tc.desc: Test GridRow layout algorithm with text direction = Reverse,
322  *           System parameter is left to right.
323  * @tc.type: FUNC
324  */
325 HWTEST_F(GridRowTestNg, Algorithm007, TestSize.Level1)
326 {
327     auto pipeLine = PipelineBase::GetCurrentContext();
328     auto layoutProperty = rowNode_->GetLayoutProperty<GridRowLayoutProperty>();
329     // Set RowReverse
330     layoutProperty->UpdateDirection(V2::GridRowDirection::RowReverse);
331     // Set LTR
332     pipeLine->SetIsRightToLeft(false);
333 
334     // get row direction
335     auto direction = layoutProperty->GetDirection();
336     EXPECT_EQ(direction, V2::GridRowDirection::RowReverse);
337     auto isRTL = pipeLine->IsRightToLeft();
338     EXPECT_EQ(isRTL, false);
339 
340     auto layoutWrapper = CreateLayoutWrapperAndLayout(true);
341     auto frameRect = layoutWrapper->GetOrCreateChildByIndex(0)->GetGeometryNode()->GetFrameRect();
342     auto columnWidth = frameRect.Width();
343     EXPECT_EQ(columnWidth, DEFAULT_SPAN_WIDTH);
344     EXPECT_EQ(frameRect.GetX(), DEFAULT_GRID_ROW_WIDTH - DEFAULT_SPAN_WIDTH);
345     EXPECT_EQ(frameRect.GetY(), DEFAULT_HEIGHT);
346     frameRect = layoutWrapper->GetOrCreateChildByIndex(1)->GetGeometryNode()->GetFrameRect();
347     EXPECT_EQ(frameRect.GetX(), (DEFAULT_COLUMNS - 1) * DEFAULT_SPAN_WIDTH);
348     EXPECT_EQ(frameRect.GetY(), 0);
349 }
350 
351 /**
352  * @tc.name: Algorithm008
353  * @tc.desc: Test GridRow layout algorithm with text direction = Row,
354  *           System parameter is right to left.
355  * @tc.type: FUNC
356  */
357 HWTEST_F(GridRowTestNg, Algorithm008, TestSize.Level1)
358 {
359     auto pipeLine = PipelineBase::GetCurrentContext();
360     auto layoutProperty = rowNode_->GetLayoutProperty<GridRowLayoutProperty>();
361 
362     // Set Row
363     layoutProperty->UpdateDirection(V2::GridRowDirection::Row);
364     // Set RTL
365     pipeLine->SetIsRightToLeft(true);
366 
367     // get row direction
368     auto direction = layoutProperty->GetDirection();
369     EXPECT_EQ(direction, V2::GridRowDirection::Row);
370     auto isRTL = pipeLine->IsRightToLeft();
371     EXPECT_EQ(isRTL, true);
372 
373     auto layoutWrapper = CreateLayoutWrapperAndLayout(true);
374     auto frameRect = layoutWrapper->GetOrCreateChildByIndex(0)->GetGeometryNode()->GetFrameRect();
375     auto columnWidth = frameRect.Width();
376     EXPECT_EQ(columnWidth, DEFAULT_SPAN_WIDTH);
377     EXPECT_EQ(frameRect.GetX(), DEFAULT_GRID_ROW_WIDTH - (DEFAULT_OFFSET + 1) * DEFAULT_SPAN_WIDTH);
378     EXPECT_EQ(frameRect.GetY(), DEFAULT_HEIGHT);
379     frameRect = layoutWrapper->GetOrCreateChildByIndex(1)->GetGeometryNode()->GetFrameRect();
380     EXPECT_EQ(frameRect.GetX(), 0);
381     EXPECT_EQ(frameRect.GetY(), 0);
382 }
383 
384 /**
385  * @tc.name: Algorithm009
386  * @tc.desc: Test GridRow layout algorithm with text direction = Reverse,
387  *           Layout direction is auto, System parameter is left to right.
388  * @tc.type: FUNC
389  */
390 HWTEST_F(GridRowTestNg, Algorithm009, TestSize.Level1)
391 {
392     auto pipeLine = PipelineBase::GetCurrentContext();
393     auto layoutProperty = rowNode_->GetLayoutProperty<GridRowLayoutProperty>();
394     // Set RowReverse
395     layoutProperty->UpdateDirection(V2::GridRowDirection::RowReverse);
396     // Set LTR
397     pipeLine->SetIsRightToLeft(false);
398     // Set Layout direction
399     layoutProperty->UpdateLayoutDirection(TextDirection::AUTO);
400 
401     // get row direction
402     auto direction = layoutProperty->GetDirection();
403     EXPECT_EQ(direction, V2::GridRowDirection::RowReverse);
404     auto textDirection = layoutProperty->GetLayoutDirection();
405     EXPECT_EQ(textDirection, TextDirection::AUTO);
406     auto isRTL = pipeLine->IsRightToLeft();
407     EXPECT_EQ(isRTL, false);
408 
409     auto layoutWrapper = CreateLayoutWrapperAndLayout(true);
410     auto frameRect = layoutWrapper->GetOrCreateChildByIndex(0)->GetGeometryNode()->GetFrameRect();
411     auto columnWidth = frameRect.Width();
412     EXPECT_EQ(columnWidth, DEFAULT_SPAN_WIDTH);
413     EXPECT_EQ(frameRect.GetX(), (DEFAULT_COLUMNS - 1) * DEFAULT_SPAN_WIDTH);
414     EXPECT_EQ(frameRect.GetY(), DEFAULT_HEIGHT);
415     frameRect = layoutWrapper->GetOrCreateChildByIndex(1)->GetGeometryNode()->GetFrameRect();
416     EXPECT_EQ(frameRect.GetX(), (DEFAULT_COLUMNS - 1) * DEFAULT_SPAN_WIDTH);
417     EXPECT_EQ(frameRect.GetY(), 0);
418 }
419 
420 /**
421  * @tc.name: Algorithm010
422  * @tc.desc: Test GridRow layout algorithm with text direction = Row,
423  *           Layout direction is auto, System parameter is right to left.
424  * @tc.type: FUNC
425  */
426 HWTEST_F(GridRowTestNg, Algorithm010, TestSize.Level1)
427 {
428     auto pipeLine = PipelineBase::GetCurrentContext();
429     auto layoutProperty = rowNode_->GetLayoutProperty<GridRowLayoutProperty>();
430     // Set Row
431     layoutProperty->UpdateDirection(V2::GridRowDirection::Row);
432     // Set RTL
433     pipeLine->SetIsRightToLeft(true);
434     // Set Layout direction
435     layoutProperty->UpdateLayoutDirection(TextDirection::AUTO);
436 
437     // get row direction
438     auto direction = layoutProperty->GetDirection();
439     EXPECT_EQ(direction, V2::GridRowDirection::Row);
440     auto textDirection = layoutProperty->GetLayoutDirection();
441     EXPECT_EQ(textDirection, TextDirection::AUTO);
442     auto isRTL = pipeLine->IsRightToLeft();
443     EXPECT_EQ(isRTL, true);
444 
445     auto layoutWrapper = CreateLayoutWrapperAndLayout(true);
446     auto frameRect = layoutWrapper->GetOrCreateChildByIndex(0)->GetGeometryNode()->GetFrameRect();
447     auto columnWidth = frameRect.Width();
448     EXPECT_EQ(columnWidth, DEFAULT_SPAN_WIDTH);
449     EXPECT_EQ(frameRect.GetX(), DEFAULT_GRID_ROW_WIDTH - (DEFAULT_OFFSET + 1) * DEFAULT_SPAN_WIDTH);
450     EXPECT_EQ(frameRect.GetY(), DEFAULT_HEIGHT);
451     frameRect = layoutWrapper->GetOrCreateChildByIndex(1)->GetGeometryNode()->GetFrameRect();
452     EXPECT_EQ(frameRect.GetX(), 0);
453     EXPECT_EQ(frameRect.GetY(), 0);
454 }
455 
456 /**
457  * @tc.name: Algorithm011
458  * @tc.desc: Test GridRow layout algorithm with text direction = Row,
459  *           Layout direction is auto, System parameter is left to right.
460  * @tc.type: FUNC
461  */
462 HWTEST_F(GridRowTestNg, Algorithm011, TestSize.Level1)
463 {
464     auto pipeLine = PipelineBase::GetCurrentContext();
465     auto layoutProperty = rowNode_->GetLayoutProperty<GridRowLayoutProperty>();
466     // Set Row
467     layoutProperty->UpdateDirection(V2::GridRowDirection::Row);
468     // Set LTR
469     pipeLine->SetIsRightToLeft(false);
470     // Set Layout direction
471     layoutProperty->UpdateLayoutDirection(TextDirection::AUTO);
472 
473     // get row direction
474     auto direction = layoutProperty->GetDirection();
475     EXPECT_EQ(direction, V2::GridRowDirection::Row);
476     auto textDirection = layoutProperty->GetLayoutDirection();
477     EXPECT_EQ(textDirection, TextDirection::AUTO);
478     auto isRTL = pipeLine->IsRightToLeft();
479     EXPECT_EQ(isRTL, false);
480 
481     auto layoutWrapper = CreateLayoutWrapperAndLayout(true);
482     auto frameRect = layoutWrapper->GetOrCreateChildByIndex(0)->GetGeometryNode()->GetFrameRect();
483     auto columnWidth = frameRect.Width();
484     EXPECT_EQ(columnWidth, DEFAULT_SPAN_WIDTH);
485     EXPECT_EQ(frameRect.GetX(), 0);
486     EXPECT_EQ(frameRect.GetY(), DEFAULT_HEIGHT);
487     frameRect = layoutWrapper->GetOrCreateChildByIndex(1)->GetGeometryNode()->GetFrameRect();
488     EXPECT_EQ(frameRect.GetX(), 0);
489     EXPECT_EQ(frameRect.GetY(), 0);
490 }
491 
492 /**
493  * @tc.name: Algorithm012
494  * @tc.desc: Test GridRow layout algorithm with text direction = RowReverse,
495  *           Layout direction is auto, System parameter is right to left.
496  * @tc.type: FUNC
497  */
498 HWTEST_F(GridRowTestNg, Algorithm012, TestSize.Level1)
499 {
500     auto pipeLine = PipelineBase::GetCurrentContext();
501     auto layoutProperty = rowNode_->GetLayoutProperty<GridRowLayoutProperty>();
502     // Set RowReverse
503     layoutProperty->UpdateDirection(V2::GridRowDirection::RowReverse);
504     // Set RTL
505     pipeLine->SetIsRightToLeft(true);
506     // Set Layout direction
507     layoutProperty->UpdateLayoutDirection(TextDirection::AUTO);
508 
509     // get row direction
510     auto direction = layoutProperty->GetDirection();
511     EXPECT_EQ(direction, V2::GridRowDirection::RowReverse);
512     auto textDirection = layoutProperty->GetLayoutDirection();
513     EXPECT_EQ(textDirection, TextDirection::AUTO);
514     auto isRTL = pipeLine->IsRightToLeft();
515     EXPECT_EQ(isRTL, true);
516 
517     auto layoutWrapper = CreateLayoutWrapperAndLayout(true);
518     auto frameRect = layoutWrapper->GetOrCreateChildByIndex(0)->GetGeometryNode()->GetFrameRect();
519     auto columnWidth = frameRect.Width();
520     EXPECT_EQ(columnWidth, DEFAULT_SPAN_WIDTH);
521     EXPECT_EQ(frameRect.GetX(), DEFAULT_GRID_ROW_WIDTH - DEFAULT_SPAN_WIDTH);
522     EXPECT_EQ(frameRect.GetY(), DEFAULT_HEIGHT);
523     frameRect = layoutWrapper->GetOrCreateChildByIndex(1)->GetGeometryNode()->GetFrameRect();
524     EXPECT_EQ(frameRect.GetX(), DEFAULT_GRID_ROW_WIDTH - DEFAULT_SPAN_WIDTH);
525     EXPECT_EQ(frameRect.GetY(), 0);
526 }
527 
528 /**
529  * @tc.name: ItemAlign001
530  * @tc.desc: Test GridRow layout algorithm with default ItemAlign.
531  * @tc.type: FUNC
532  */
533 HWTEST_F(GridRowTestNg, ItemAlign001, TestSize.Level1)
534 {
535     auto layoutProperty = rowNode_->GetLayoutProperty<GridRowLayoutProperty>();
536     auto direction = layoutProperty->GetDirection();
537     EXPECT_EQ(direction, V2::GridRowDirection::Row);
538     auto itemAlign = layoutProperty->GetAlignItems();
539     EXPECT_FALSE(itemAlign.has_value());
540 
541     /**
542      * @tc.steps: step1. create environment for running process.
543      */
544     auto firstColNode = colNodes_.front();
545     auto firstColLayoutProperty = firstColNode->GetLayoutProperty<GridColLayoutProperty>();
546     firstColLayoutProperty->UpdateSpan(V2::GridContainerSize(1));
547     firstColLayoutProperty->UpdateOffset(V2::GridContainerSize(0));
548     firstColLayoutProperty->UpdateOrder(V2::GridContainerSize());
549     firstColLayoutProperty->UpdateUserDefinedIdealSize(CalcSize(std::nullopt, CalcLength(TEST_ALIGN_HEIGHT)));
550 
551     auto secondColNode = colNodes_.back();
552     auto secondColLayoutProperty = secondColNode->GetLayoutProperty<GridColLayoutProperty>();
553     secondColLayoutProperty->UpdateSpan(V2::GridContainerSize(1));
554     secondColLayoutProperty->UpdateOffset(V2::GridContainerSize(0));
555     secondColLayoutProperty->UpdateOrder(V2::GridContainerSize());
556     secondColLayoutProperty->UpdateUserDefinedIdealSize(CalcSize(std::nullopt, CalcLength(DEFAULT_HEIGHT)));
557 
558     /**
559      * @tc.steps: step2. Running layout function and check the result with expected results.
560      */
561     auto layoutWrapper = CreateLayoutWrapperAndLayout(true);
562     auto frameRect = layoutWrapper->GetOrCreateChildByIndex(0)->GetGeometryNode()->GetFrameRect();
563     auto columnWidth = frameRect.Width();
564     auto columnHeight = frameRect.Height();
565     EXPECT_EQ(frameRect.GetX(), 0);
566     EXPECT_EQ(frameRect.GetY(), 0);
567     EXPECT_EQ(columnWidth, DEFAULT_SPAN_WIDTH);
568     EXPECT_EQ(columnHeight, TEST_ALIGN_HEIGHT);
569 
570     frameRect = layoutWrapper->GetOrCreateChildByIndex(1)->GetGeometryNode()->GetFrameRect();
571     columnWidth = frameRect.Width();
572     columnHeight = frameRect.Height();
573     EXPECT_EQ(frameRect.GetX(), DEFAULT_SPAN_WIDTH);
574     EXPECT_EQ(frameRect.GetY(), 0);
575     EXPECT_EQ(columnWidth, DEFAULT_SPAN_WIDTH);
576     EXPECT_EQ(columnHeight, DEFAULT_HEIGHT);
577 }
578 
579 /**
580  * @tc.name: ItemAlign002
581  * @tc.desc: Test GridRow layout algorithm with ItemAlign.Start.
582  * @tc.type: FUNC
583  */
584 HWTEST_F(GridRowTestNg, ItemAlign002, TestSize.Level1)
585 {
586     auto layoutProperty = rowNode_->GetLayoutProperty<GridRowLayoutProperty>();
587     layoutProperty->UpdateAlignItems(FlexAlign::FLEX_START);
588 
589     /**
590      * @tc.steps: step1. create environment for running process.
591      */
592     auto firstColNode = colNodes_.front();
593     auto firstColLayoutProperty = firstColNode->GetLayoutProperty<GridColLayoutProperty>();
594     firstColLayoutProperty->UpdateSpan(V2::GridContainerSize(1));
595     firstColLayoutProperty->UpdateOffset(V2::GridContainerSize(0));
596     firstColLayoutProperty->UpdateOrder(V2::GridContainerSize());
597     firstColLayoutProperty->UpdateUserDefinedIdealSize(CalcSize(std::nullopt, CalcLength(TEST_ALIGN_HEIGHT)));
598 
599     auto secondColNode = colNodes_.back();
600     auto secondColLayoutProperty = secondColNode->GetLayoutProperty<GridColLayoutProperty>();
601     secondColLayoutProperty->UpdateSpan(V2::GridContainerSize(1));
602     secondColLayoutProperty->UpdateOffset(V2::GridContainerSize(0));
603     secondColLayoutProperty->UpdateOrder(V2::GridContainerSize());
604     secondColLayoutProperty->UpdateUserDefinedIdealSize(CalcSize(std::nullopt, CalcLength(DEFAULT_HEIGHT)));
605 
606     /**
607      * @tc.steps: step2. Running layout function and check the result with expected results.
608      */
609     auto layoutWrapper = CreateLayoutWrapperAndLayout(true);
610     auto frameRect = layoutWrapper->GetOrCreateChildByIndex(0)->GetGeometryNode()->GetFrameRect();
611     auto columnWidth = frameRect.Width();
612     auto columnHeight = frameRect.Height();
613     EXPECT_EQ(frameRect.GetX(), 0);
614     EXPECT_EQ(frameRect.GetY(), 0);
615     EXPECT_EQ(columnWidth, DEFAULT_SPAN_WIDTH);
616     EXPECT_EQ(columnHeight, TEST_ALIGN_HEIGHT);
617 
618     frameRect = layoutWrapper->GetOrCreateChildByIndex(1)->GetGeometryNode()->GetFrameRect();
619     columnWidth = frameRect.Width();
620     columnHeight = frameRect.Height();
621     EXPECT_EQ(frameRect.GetX(), DEFAULT_SPAN_WIDTH);
622     EXPECT_EQ(frameRect.GetY(), 0);
623     EXPECT_EQ(columnWidth, DEFAULT_SPAN_WIDTH);
624     EXPECT_EQ(columnHeight, DEFAULT_HEIGHT);
625 }
626 
627 /**
628  * @tc.name: ItemAlign003
629  * @tc.desc: Test GridRow layout algorithm with ItemAlign.Center.
630  * @tc.type: FUNC
631  */
632 HWTEST_F(GridRowTestNg, ItemAlign003, TestSize.Level1)
633 {
634     auto layoutProperty = rowNode_->GetLayoutProperty<GridRowLayoutProperty>();
635     layoutProperty->UpdateAlignItems(FlexAlign::CENTER);
636 
637     /**
638      * @tc.steps: step1. create environment for running process.
639      */
640     auto firstColNode = colNodes_.front();
641     auto firstColLayoutProperty = firstColNode->GetLayoutProperty<GridColLayoutProperty>();
642     firstColLayoutProperty->UpdateSpan(V2::GridContainerSize(1));
643     firstColLayoutProperty->UpdateOffset(V2::GridContainerSize(0));
644     firstColLayoutProperty->UpdateOrder(V2::GridContainerSize());
645     firstColLayoutProperty->UpdateUserDefinedIdealSize(CalcSize(std::nullopt, CalcLength(TEST_ALIGN_HEIGHT)));
646 
647     auto secondColNode = colNodes_.back();
648     auto secondColLayoutProperty = secondColNode->GetLayoutProperty<GridColLayoutProperty>();
649     secondColLayoutProperty->UpdateSpan(V2::GridContainerSize(1));
650     secondColLayoutProperty->UpdateOffset(V2::GridContainerSize(0));
651     secondColLayoutProperty->UpdateOrder(V2::GridContainerSize());
652     secondColLayoutProperty->UpdateUserDefinedIdealSize(CalcSize(std::nullopt, CalcLength(DEFAULT_HEIGHT)));
653 
654     /**
655      * @tc.steps: step2. Running layout function and check the result with expected results.
656      */
657     auto layoutWrapper = CreateLayoutWrapperAndLayout(true);
658     auto frameRect = layoutWrapper->GetOrCreateChildByIndex(0)->GetGeometryNode()->GetFrameRect();
659     auto columnWidth = frameRect.Width();
660     auto columnHeight = frameRect.Height();
661     EXPECT_EQ(frameRect.GetX(), 0);
662     EXPECT_EQ(frameRect.GetY(), 0);
663     EXPECT_EQ(columnWidth, DEFAULT_SPAN_WIDTH);
664     EXPECT_EQ(columnHeight, TEST_ALIGN_HEIGHT);
665 
666     frameRect = layoutWrapper->GetOrCreateChildByIndex(1)->GetGeometryNode()->GetFrameRect();
667     columnWidth = frameRect.Width();
668     columnHeight = frameRect.Height();
669     EXPECT_EQ(frameRect.GetX(), DEFAULT_SPAN_WIDTH);
670     EXPECT_EQ(frameRect.GetY(), TEST_ALIGN_HEIGHT * 0.5 - DEFAULT_HEIGHT * 0.5);
671     EXPECT_EQ(columnWidth, DEFAULT_SPAN_WIDTH);
672     EXPECT_EQ(columnHeight, DEFAULT_HEIGHT);
673 }
674 
675 /**
676  * @tc.name: ItemAlign004
677  * @tc.desc: Test GridRow layout algorithm with ItemAlign.End.
678  * @tc.type: FUNC
679  */
680 HWTEST_F(GridRowTestNg, ItemAlign004, TestSize.Level1)
681 {
682     auto layoutProperty = rowNode_->GetLayoutProperty<GridRowLayoutProperty>();
683     layoutProperty->UpdateAlignItems(FlexAlign::FLEX_END);
684 
685     /**
686      * @tc.steps: step1. create environment for running process.
687      */
688     auto firstColNode = colNodes_.front();
689     auto firstColLayoutProperty = firstColNode->GetLayoutProperty<GridColLayoutProperty>();
690     firstColLayoutProperty->UpdateSpan(V2::GridContainerSize(1));
691     firstColLayoutProperty->UpdateOffset(V2::GridContainerSize(0));
692     firstColLayoutProperty->UpdateOrder(V2::GridContainerSize());
693     firstColLayoutProperty->UpdateUserDefinedIdealSize(CalcSize(std::nullopt, CalcLength(TEST_ALIGN_HEIGHT)));
694 
695     auto secondColNode = colNodes_.back();
696     auto secondColLayoutProperty = secondColNode->GetLayoutProperty<GridColLayoutProperty>();
697     secondColLayoutProperty->UpdateSpan(V2::GridContainerSize(1));
698     secondColLayoutProperty->UpdateOffset(V2::GridContainerSize(0));
699     secondColLayoutProperty->UpdateOrder(V2::GridContainerSize());
700     secondColLayoutProperty->UpdateUserDefinedIdealSize(CalcSize(std::nullopt, CalcLength(DEFAULT_HEIGHT)));
701 
702     /**
703      * @tc.steps: step2. Running layout function and check the result with expected results.
704      */
705     auto layoutWrapper = CreateLayoutWrapperAndLayout(true);
706     auto frameRect = layoutWrapper->GetOrCreateChildByIndex(0)->GetGeometryNode()->GetFrameRect();
707     auto columnWidth = frameRect.Width();
708     auto columnHeight = frameRect.Height();
709     EXPECT_EQ(frameRect.GetX(), 0);
710     EXPECT_EQ(frameRect.GetY(), 0);
711     EXPECT_EQ(columnWidth, DEFAULT_SPAN_WIDTH);
712     EXPECT_EQ(columnHeight, TEST_ALIGN_HEIGHT);
713 
714     frameRect = layoutWrapper->GetOrCreateChildByIndex(1)->GetGeometryNode()->GetFrameRect();
715     columnWidth = frameRect.Width();
716     columnHeight = frameRect.Height();
717     EXPECT_EQ(frameRect.GetX(), DEFAULT_SPAN_WIDTH);
718     EXPECT_EQ(frameRect.GetY(), TEST_ALIGN_HEIGHT - DEFAULT_HEIGHT);
719     EXPECT_EQ(columnWidth, DEFAULT_SPAN_WIDTH);
720     EXPECT_EQ(columnHeight, DEFAULT_HEIGHT);
721 }
722 
723 /**
724  * @tc.name: ItemAlign005
725  * @tc.desc: Test GridRow layout algorithm with ItemAlign.STRETCH.
726  * @tc.type: FUNC
727  */
728 HWTEST_F(GridRowTestNg, ItemAlign005, TestSize.Level1)
729 {
730     auto layoutProperty = rowNode_->GetLayoutProperty<GridRowLayoutProperty>();
731     layoutProperty->UpdateAlignItems(FlexAlign::STRETCH);
732 
733     /**
734      * @tc.steps: step1. create environment for running process.
735      */
736     auto firstColNode = colNodes_.front();
737     auto firstColLayoutProperty = firstColNode->GetLayoutProperty<GridColLayoutProperty>();
738     firstColLayoutProperty->UpdateSpan(V2::GridContainerSize(1));
739     firstColLayoutProperty->UpdateOffset(V2::GridContainerSize(0));
740     firstColLayoutProperty->UpdateOrder(V2::GridContainerSize());
741     firstColLayoutProperty->UpdateUserDefinedIdealSize(CalcSize(std::nullopt, CalcLength(TEST_ALIGN_HEIGHT)));
742 
743     auto secondColNode = colNodes_.back();
744     auto secondColLayoutProperty = secondColNode->GetLayoutProperty<GridColLayoutProperty>();
745     secondColLayoutProperty->UpdateSpan(V2::GridContainerSize(1));
746     secondColLayoutProperty->UpdateOffset(V2::GridContainerSize(0));
747     secondColLayoutProperty->UpdateOrder(V2::GridContainerSize());
748     secondColLayoutProperty->UpdateUserDefinedIdealSize(CalcSize(std::nullopt, CalcLength(DEFAULT_HEIGHT)));
749 
750     /**
751      * @tc.steps: step2. Running layout function and check the result with expected results.
752      */
753     auto layoutWrapper = CreateLayoutWrapperAndLayout(true);
754     auto frameRect = layoutWrapper->GetOrCreateChildByIndex(0)->GetGeometryNode()->GetFrameRect();
755     auto columnWidth = frameRect.Width();
756     auto columnHeight = frameRect.Height();
757     EXPECT_EQ(frameRect.GetX(), 0);
758     EXPECT_EQ(frameRect.GetY(), 0);
759     EXPECT_EQ(columnWidth, DEFAULT_SPAN_WIDTH);
760     EXPECT_EQ(columnHeight, TEST_ALIGN_HEIGHT);
761 
762     frameRect = layoutWrapper->GetOrCreateChildByIndex(1)->GetGeometryNode()->GetFrameRect();
763     columnWidth = frameRect.Width();
764     columnHeight = frameRect.Height();
765     EXPECT_EQ(frameRect.GetX(), DEFAULT_SPAN_WIDTH);
766     EXPECT_EQ(frameRect.GetY(), 0);
767     EXPECT_EQ(columnWidth, DEFAULT_SPAN_WIDTH);
768     EXPECT_EQ(columnHeight, TEST_ALIGN_HEIGHT);
769 }
770 
771 /**
772  * @tc.name: ItemAlign006
773  * @tc.desc: Test GridRow layout algorithm with diferent direction and default ItemAlign
774  * @tc.type: FUNC
775  */
776 HWTEST_F(GridRowTestNg, ItemAlign006, TestSize.Level1)
777 {
778     auto layoutProperty = rowNode_->GetLayoutProperty<GridRowLayoutProperty>();
779     layoutProperty->ResetAlignItems();
780     auto itemAlign = layoutProperty->GetAlignItems();
781     layoutProperty->UpdateDirection(V2::GridRowDirection::RowReverse);
782     EXPECT_FALSE(itemAlign.has_value());
783 
784     /**
785      * @tc.steps: step1. create environment for running process.
786      */
787     auto firstColNode = colNodes_.front();
788     auto firstColLayoutProperty = firstColNode->GetLayoutProperty<GridColLayoutProperty>();
789     firstColLayoutProperty->UpdateSpan(V2::GridContainerSize(1));
790     firstColLayoutProperty->UpdateOffset(V2::GridContainerSize(0));
791     firstColLayoutProperty->UpdateOrder(V2::GridContainerSize());
792     firstColLayoutProperty->UpdateUserDefinedIdealSize(CalcSize(std::nullopt, CalcLength(TEST_ALIGN_HEIGHT)));
793 
794     auto secondColNode = colNodes_.back();
795     auto secondColLayoutProperty = secondColNode->GetLayoutProperty<GridColLayoutProperty>();
796     secondColLayoutProperty->UpdateSpan(V2::GridContainerSize(1));
797     secondColLayoutProperty->UpdateOffset(V2::GridContainerSize(0));
798     secondColLayoutProperty->UpdateOrder(V2::GridContainerSize());
799     secondColLayoutProperty->UpdateUserDefinedIdealSize(CalcSize(std::nullopt, CalcLength(DEFAULT_HEIGHT)));
800 
801     /**
802      * @tc.steps: step2. Running layout function and check the result with expected results.
803      */
804     auto layoutWrapper = CreateLayoutWrapperAndLayout(true);
805     auto frameRect = layoutWrapper->GetOrCreateChildByIndex(0)->GetGeometryNode()->GetFrameRect();
806     auto columnWidth = frameRect.Width();
807     auto columnHeight = frameRect.Height();
808     EXPECT_EQ(frameRect.GetX(), DEFAULT_GRID_ROW_WIDTH - DEFAULT_SPAN_WIDTH);
809     EXPECT_EQ(frameRect.GetY(), 0);
810     EXPECT_EQ(columnWidth, DEFAULT_SPAN_WIDTH);
811     EXPECT_EQ(columnHeight, TEST_ALIGN_HEIGHT);
812 
813     frameRect = layoutWrapper->GetOrCreateChildByIndex(1)->GetGeometryNode()->GetFrameRect();
814     columnWidth = frameRect.Width();
815     columnHeight = frameRect.Height();
816     EXPECT_EQ(frameRect.GetX(), DEFAULT_GRID_ROW_WIDTH - DEFAULT_SPAN_WIDTH * 2);
817     EXPECT_EQ(frameRect.GetY(), 0);
818     EXPECT_EQ(columnWidth, DEFAULT_SPAN_WIDTH);
819     EXPECT_EQ(columnHeight, DEFAULT_HEIGHT);
820 }
821 
822 /**
823  * @tc.name: ItemAlign007
824  * @tc.desc: Test GridRow layout algorithm with diferent direction and ItemAlign.Start.
825  * @tc.type: FUNC
826  */
827 HWTEST_F(GridRowTestNg, ItemAlign007, TestSize.Level1)
828 {
829     auto layoutProperty = rowNode_->GetLayoutProperty<GridRowLayoutProperty>();
830     layoutProperty->UpdateDirection(V2::GridRowDirection::RowReverse);
831     layoutProperty->UpdateAlignItems(FlexAlign::FLEX_START);
832 
833     /**
834      * @tc.steps: step1. create environment for running process.
835      */
836     auto firstColNode = colNodes_.front();
837     auto firstColLayoutProperty = firstColNode->GetLayoutProperty<GridColLayoutProperty>();
838     firstColLayoutProperty->UpdateSpan(V2::GridContainerSize(1));
839     firstColLayoutProperty->UpdateOffset(V2::GridContainerSize(0));
840     firstColLayoutProperty->UpdateOrder(V2::GridContainerSize());
841     firstColLayoutProperty->UpdateUserDefinedIdealSize(CalcSize(std::nullopt, CalcLength(TEST_ALIGN_HEIGHT)));
842 
843     auto secondColNode = colNodes_.back();
844     auto secondColLayoutProperty = secondColNode->GetLayoutProperty<GridColLayoutProperty>();
845     secondColLayoutProperty->UpdateSpan(V2::GridContainerSize(1));
846     secondColLayoutProperty->UpdateOffset(V2::GridContainerSize(0));
847     secondColLayoutProperty->UpdateOrder(V2::GridContainerSize());
848     secondColLayoutProperty->UpdateUserDefinedIdealSize(CalcSize(std::nullopt, CalcLength(DEFAULT_HEIGHT)));
849 
850     /**
851      * @tc.steps: step2. Running layout function and check the result with expected results.
852      */
853     auto layoutWrapper = CreateLayoutWrapperAndLayout(true);
854     auto frameRect = layoutWrapper->GetOrCreateChildByIndex(0)->GetGeometryNode()->GetFrameRect();
855     auto columnWidth = frameRect.Width();
856     auto columnHeight = frameRect.Height();
857     EXPECT_EQ(frameRect.GetX(), DEFAULT_GRID_ROW_WIDTH - DEFAULT_SPAN_WIDTH);
858     EXPECT_EQ(frameRect.GetY(), 0);
859     EXPECT_EQ(columnWidth, DEFAULT_SPAN_WIDTH);
860     EXPECT_EQ(columnHeight, TEST_ALIGN_HEIGHT);
861 
862     frameRect = layoutWrapper->GetOrCreateChildByIndex(1)->GetGeometryNode()->GetFrameRect();
863     columnWidth = frameRect.Width();
864     columnHeight = frameRect.Height();
865     EXPECT_EQ(frameRect.GetX(), DEFAULT_GRID_ROW_WIDTH - DEFAULT_SPAN_WIDTH * 2);
866     EXPECT_EQ(frameRect.GetY(), 0);
867     EXPECT_EQ(columnWidth, DEFAULT_SPAN_WIDTH);
868     EXPECT_EQ(columnHeight, DEFAULT_HEIGHT);
869 }
870 
871 /**
872  * @tc.name: ItemAlign008
873  * @tc.desc: Test GridRow layout algorithm with diferent direction and ItemAlign.Center.
874  * @tc.type: FUNC
875  */
876 HWTEST_F(GridRowTestNg, ItemAlign008, TestSize.Level1)
877 {
878     auto layoutProperty = rowNode_->GetLayoutProperty<GridRowLayoutProperty>();
879     layoutProperty->UpdateDirection(V2::GridRowDirection::RowReverse);
880     layoutProperty->UpdateAlignItems(FlexAlign::CENTER);
881 
882     /**
883      * @tc.steps: step1. create environment for running process.
884      */
885     auto firstColNode = colNodes_.front();
886     auto firstColLayoutProperty = firstColNode->GetLayoutProperty<GridColLayoutProperty>();
887     firstColLayoutProperty->UpdateSpan(V2::GridContainerSize(1));
888     firstColLayoutProperty->UpdateOffset(V2::GridContainerSize(0));
889     firstColLayoutProperty->UpdateOrder(V2::GridContainerSize());
890     firstColLayoutProperty->UpdateUserDefinedIdealSize(CalcSize(std::nullopt, CalcLength(TEST_ALIGN_HEIGHT)));
891 
892     auto secondColNode = colNodes_.back();
893     auto secondColLayoutProperty = secondColNode->GetLayoutProperty<GridColLayoutProperty>();
894     secondColLayoutProperty->UpdateSpan(V2::GridContainerSize(1));
895     secondColLayoutProperty->UpdateOffset(V2::GridContainerSize(0));
896     secondColLayoutProperty->UpdateOrder(V2::GridContainerSize());
897     secondColLayoutProperty->UpdateUserDefinedIdealSize(CalcSize(std::nullopt, CalcLength(DEFAULT_HEIGHT)));
898 
899     /**
900      * @tc.steps: step2. Running layout function and check the result with expected results.
901      */
902     auto layoutWrapper = CreateLayoutWrapperAndLayout(true);
903     auto frameRect = layoutWrapper->GetOrCreateChildByIndex(0)->GetGeometryNode()->GetFrameRect();
904     auto columnWidth = frameRect.Width();
905     auto columnHeight = frameRect.Height();
906     EXPECT_EQ(frameRect.GetX(), DEFAULT_GRID_ROW_WIDTH - DEFAULT_SPAN_WIDTH);
907     EXPECT_EQ(frameRect.GetY(), 0);
908     EXPECT_EQ(columnWidth, DEFAULT_SPAN_WIDTH);
909     EXPECT_EQ(columnHeight, TEST_ALIGN_HEIGHT);
910 
911     frameRect = layoutWrapper->GetOrCreateChildByIndex(1)->GetGeometryNode()->GetFrameRect();
912     columnWidth = frameRect.Width();
913     columnHeight = frameRect.Height();
914     EXPECT_EQ(frameRect.GetX(), DEFAULT_GRID_ROW_WIDTH - DEFAULT_SPAN_WIDTH * 2);
915     EXPECT_EQ(frameRect.GetY(), TEST_ALIGN_HEIGHT * 0.5 - DEFAULT_HEIGHT * 0.5);
916     EXPECT_EQ(columnWidth, DEFAULT_SPAN_WIDTH);
917     EXPECT_EQ(columnHeight, DEFAULT_HEIGHT);
918 }
919 /**
920  * @tc.name: ItemAlign009
921  * @tc.desc: Test GridRow layout algorithm with ItemAlign.End.
922  * @tc.type: FUNC
923  */
924 HWTEST_F(GridRowTestNg, ItemAlign009, TestSize.Level1)
925 {
926     auto layoutProperty = rowNode_->GetLayoutProperty<GridRowLayoutProperty>();
927     layoutProperty->UpdateDirection(V2::GridRowDirection::RowReverse);
928     layoutProperty->UpdateAlignItems(FlexAlign::FLEX_END);
929 
930     /**
931      * @tc.steps: step1. create environment for running process.
932      */
933     auto firstColNode = colNodes_.front();
934     auto firstColLayoutProperty = firstColNode->GetLayoutProperty<GridColLayoutProperty>();
935     firstColLayoutProperty->UpdateSpan(V2::GridContainerSize(1));
936     firstColLayoutProperty->UpdateOffset(V2::GridContainerSize(0));
937     firstColLayoutProperty->UpdateOrder(V2::GridContainerSize());
938     firstColLayoutProperty->UpdateUserDefinedIdealSize(CalcSize(std::nullopt, CalcLength(TEST_ALIGN_HEIGHT)));
939 
940     auto secondColNode = colNodes_.back();
941     auto secondColLayoutProperty = secondColNode->GetLayoutProperty<GridColLayoutProperty>();
942     secondColLayoutProperty->UpdateSpan(V2::GridContainerSize(1));
943     secondColLayoutProperty->UpdateOffset(V2::GridContainerSize(0));
944     secondColLayoutProperty->UpdateOrder(V2::GridContainerSize());
945     secondColLayoutProperty->UpdateUserDefinedIdealSize(CalcSize(std::nullopt, CalcLength(DEFAULT_HEIGHT)));
946 
947     /**
948      * @tc.steps: step2. Running layout function and check the result with expected results.
949      */
950     auto layoutWrapper = CreateLayoutWrapperAndLayout(true);
951     auto frameRect = layoutWrapper->GetOrCreateChildByIndex(0)->GetGeometryNode()->GetFrameRect();
952     auto columnWidth = frameRect.Width();
953     auto columnHeight = frameRect.Height();
954     EXPECT_EQ(frameRect.GetX(), DEFAULT_GRID_ROW_WIDTH-DEFAULT_SPAN_WIDTH);
955     EXPECT_EQ(frameRect.GetY(), 0);
956     EXPECT_EQ(columnWidth, DEFAULT_SPAN_WIDTH);
957     EXPECT_EQ(columnHeight, TEST_ALIGN_HEIGHT);
958 
959     frameRect = layoutWrapper->GetOrCreateChildByIndex(1)->GetGeometryNode()->GetFrameRect();
960     columnWidth = frameRect.Width();
961     columnHeight = frameRect.Height();
962     EXPECT_EQ(frameRect.GetX(), DEFAULT_GRID_ROW_WIDTH - DEFAULT_SPAN_WIDTH * 2);
963     EXPECT_EQ(frameRect.GetY(), TEST_ALIGN_HEIGHT - DEFAULT_HEIGHT);
964     EXPECT_EQ(columnWidth, DEFAULT_SPAN_WIDTH);
965     EXPECT_EQ(columnHeight, DEFAULT_HEIGHT);
966 }
967 
968 /**
969  * @tc.name: ItemAlign010
970  * @tc.desc: Test GridRow layout algorithm with ItemAlign.STRETCH.
971  * @tc.type: FUNC
972  */
973 HWTEST_F(GridRowTestNg, ItemAlign010, TestSize.Level1)
974 {
975     auto layoutProperty = rowNode_->GetLayoutProperty<GridRowLayoutProperty>();
976     layoutProperty->UpdateDirection(V2::GridRowDirection::RowReverse);
977     layoutProperty->UpdateAlignItems(FlexAlign::STRETCH);
978 
979     /**
980      * @tc.steps: step1. create environment for running process.
981      */
982     auto firstColNode = colNodes_.front();
983     auto firstColLayoutProperty = firstColNode->GetLayoutProperty<GridColLayoutProperty>();
984     firstColLayoutProperty->UpdateSpan(V2::GridContainerSize(1));
985     firstColLayoutProperty->UpdateOffset(V2::GridContainerSize(0));
986     firstColLayoutProperty->UpdateOrder(V2::GridContainerSize());
987     firstColLayoutProperty->UpdateUserDefinedIdealSize(CalcSize(std::nullopt, CalcLength(TEST_ALIGN_HEIGHT)));
988 
989     auto secondColNode = colNodes_.back();
990     auto secondColLayoutProperty = secondColNode->GetLayoutProperty<GridColLayoutProperty>();
991     secondColLayoutProperty->UpdateSpan(V2::GridContainerSize(1));
992     secondColLayoutProperty->UpdateOffset(V2::GridContainerSize(0));
993     secondColLayoutProperty->UpdateOrder(V2::GridContainerSize());
994     secondColLayoutProperty->UpdateUserDefinedIdealSize(CalcSize(std::nullopt, CalcLength(DEFAULT_HEIGHT)));
995 
996     /**
997      * @tc.steps: step2. Running layout function and check the result with expected results.
998      */
999     auto layoutWrapper = CreateLayoutWrapperAndLayout(true);
1000     auto frameRect = layoutWrapper->GetOrCreateChildByIndex(0)->GetGeometryNode()->GetFrameRect();
1001     auto columnWidth = frameRect.Width();
1002     auto columnHeight = frameRect.Height();
1003     EXPECT_EQ(frameRect.GetX(), DEFAULT_GRID_ROW_WIDTH - DEFAULT_SPAN_WIDTH);
1004     EXPECT_EQ(frameRect.GetY(), 0);
1005     EXPECT_EQ(columnWidth, DEFAULT_SPAN_WIDTH);
1006     EXPECT_EQ(columnHeight, TEST_ALIGN_HEIGHT);
1007 
1008     frameRect = layoutWrapper->GetOrCreateChildByIndex(1)->GetGeometryNode()->GetFrameRect();
1009     columnWidth = frameRect.Width();
1010     columnHeight = frameRect.Height();
1011     EXPECT_EQ(frameRect.GetX(), DEFAULT_GRID_ROW_WIDTH - DEFAULT_SPAN_WIDTH  * 2);
1012     EXPECT_EQ(frameRect.GetY(), 0);
1013     EXPECT_EQ(columnWidth, DEFAULT_SPAN_WIDTH);
1014     EXPECT_EQ(columnHeight, TEST_ALIGN_HEIGHT);
1015 }
1016 
1017 /**
1018  * @tc.name: ItemAlign011
1019  * @tc.desc: Test GridRow layout algorithm with diferent offset and default ItemAlign
1020  * @tc.type: FUNC
1021  */
1022 HWTEST_F(GridRowTestNg, ItemAlign011, TestSize.Level1)
1023 {
1024     auto layoutProperty = rowNode_->GetLayoutProperty<GridRowLayoutProperty>();
1025     layoutProperty->ResetAlignItems();
1026     auto itemAlign = layoutProperty->GetAlignItems();
1027     layoutProperty->UpdateDirection(V2::GridRowDirection::Row);
1028     EXPECT_FALSE(itemAlign.has_value());
1029 
1030     /**
1031      * @tc.steps: step1. create environment for running process.
1032      */
1033     auto firstColNode = colNodes_.front();
1034     auto firstColLayoutProperty = firstColNode->GetLayoutProperty<GridColLayoutProperty>();
1035     firstColLayoutProperty->UpdateSpan(V2::GridContainerSize(1));
1036     firstColLayoutProperty->UpdateOffset(V2::GridContainerSize(7));
1037     firstColLayoutProperty->UpdateOrder(V2::GridContainerSize());
1038     firstColLayoutProperty->UpdateUserDefinedIdealSize(CalcSize(std::nullopt, CalcLength(TEST_ALIGN_HEIGHT)));
1039 
1040     auto secondColNode = colNodes_.back();
1041     auto secondColLayoutProperty = secondColNode->GetLayoutProperty<GridColLayoutProperty>();
1042     secondColLayoutProperty->UpdateSpan(V2::GridContainerSize(1));
1043     secondColLayoutProperty->UpdateOffset(V2::GridContainerSize(0));
1044     secondColLayoutProperty->UpdateOrder(V2::GridContainerSize());
1045     secondColLayoutProperty->UpdateUserDefinedIdealSize(CalcSize(std::nullopt, CalcLength(DEFAULT_HEIGHT)));
1046 
1047     /**
1048      * @tc.steps: step2. Running layout function and check the result with expected results.
1049      */
1050     auto layoutWrapper = CreateLayoutWrapperAndLayout(true);
1051     auto frameRect = layoutWrapper->GetOrCreateChildByIndex(0)->GetGeometryNode()->GetFrameRect();
1052     auto columnWidth = frameRect.Width();
1053     auto columnHeight = frameRect.Height();
1054     EXPECT_EQ(frameRect.GetX(), DEFAULT_GRID_ROW_WIDTH - DEFAULT_SPAN_WIDTH);
1055     EXPECT_EQ(frameRect.GetY(), 0);
1056     EXPECT_EQ(columnWidth, DEFAULT_SPAN_WIDTH);
1057     EXPECT_EQ(columnHeight, TEST_ALIGN_HEIGHT);
1058 
1059     frameRect = layoutWrapper->GetOrCreateChildByIndex(1)->GetGeometryNode()->GetFrameRect();
1060     columnWidth = frameRect.Width();
1061     columnHeight = frameRect.Height();
1062     EXPECT_EQ(frameRect.GetX(), 0);
1063     EXPECT_EQ(frameRect.GetY(), TEST_ALIGN_HEIGHT);
1064     EXPECT_EQ(columnWidth, DEFAULT_SPAN_WIDTH);
1065     EXPECT_EQ(columnHeight, DEFAULT_HEIGHT);
1066 }
1067 
1068 /**
1069  * @tc.name: ItemAlign012
1070  * @tc.desc: Test GridRow layout algorithm with different offset and ItemAlign.Start.
1071  * @tc.type: FUNC
1072  */
1073 HWTEST_F(GridRowTestNg, ItemAlign012, TestSize.Level1)
1074 {
1075     auto layoutProperty = rowNode_->GetLayoutProperty<GridRowLayoutProperty>();
1076     layoutProperty->UpdateAlignItems(FlexAlign::FLEX_START);
1077 
1078     /**
1079      * @tc.steps: step1. create environment for running process.
1080      */
1081     auto firstColNode = colNodes_.front();
1082     auto firstColLayoutProperty = firstColNode->GetLayoutProperty<GridColLayoutProperty>();
1083     firstColLayoutProperty->UpdateSpan(V2::GridContainerSize(1));
1084     firstColLayoutProperty->UpdateOffset(V2::GridContainerSize(7));
1085     firstColLayoutProperty->UpdateOrder(V2::GridContainerSize());
1086     firstColLayoutProperty->UpdateUserDefinedIdealSize(CalcSize(std::nullopt, CalcLength(TEST_ALIGN_HEIGHT)));
1087 
1088     auto secondColNode = colNodes_.back();
1089     auto secondColLayoutProperty = secondColNode->GetLayoutProperty<GridColLayoutProperty>();
1090     secondColLayoutProperty->UpdateSpan(V2::GridContainerSize(1));
1091     secondColLayoutProperty->UpdateOffset(V2::GridContainerSize(0));
1092     secondColLayoutProperty->UpdateOrder(V2::GridContainerSize());
1093     secondColLayoutProperty->UpdateUserDefinedIdealSize(CalcSize(std::nullopt, CalcLength(DEFAULT_HEIGHT)));
1094 
1095     /**
1096      * @tc.steps: step2. Running layout function and check the result with expected results.
1097      */
1098     auto layoutWrapper = CreateLayoutWrapperAndLayout(true);
1099     auto frameRect = layoutWrapper->GetOrCreateChildByIndex(0)->GetGeometryNode()->GetFrameRect();
1100     auto columnWidth = frameRect.Width();
1101     auto columnHeight = frameRect.Height();
1102     EXPECT_EQ(frameRect.GetX(), DEFAULT_GRID_ROW_WIDTH - DEFAULT_SPAN_WIDTH);
1103     EXPECT_EQ(frameRect.GetY(), 0);
1104     EXPECT_EQ(columnWidth, DEFAULT_SPAN_WIDTH);
1105     EXPECT_EQ(columnHeight, TEST_ALIGN_HEIGHT);
1106 
1107     frameRect = layoutWrapper->GetOrCreateChildByIndex(1)->GetGeometryNode()->GetFrameRect();
1108     columnWidth = frameRect.Width();
1109     columnHeight = frameRect.Height();
1110     EXPECT_EQ(frameRect.GetX(), 0);
1111     EXPECT_EQ(frameRect.GetY(), TEST_ALIGN_HEIGHT);
1112     EXPECT_EQ(columnWidth, DEFAULT_SPAN_WIDTH);
1113     EXPECT_EQ(columnHeight, DEFAULT_HEIGHT);
1114 }
1115 
1116 /**
1117  * @tc.name: ItemAlign013
1118  * @tc.desc: Test GridRow layout algorithm with different offset and ItemAlign.Center.
1119  * @tc.type: FUNC
1120  */
1121 HWTEST_F(GridRowTestNg, ItemAlign013, TestSize.Level1)
1122 {
1123     auto layoutProperty = rowNode_->GetLayoutProperty<GridRowLayoutProperty>();
1124     layoutProperty->UpdateAlignItems(FlexAlign::CENTER);
1125 
1126     /**
1127      * @tc.steps: step1. create environment for running process.
1128      */
1129     auto firstColNode = colNodes_.front();
1130     auto firstColLayoutProperty = firstColNode->GetLayoutProperty<GridColLayoutProperty>();
1131     firstColLayoutProperty->UpdateSpan(V2::GridContainerSize(1));
1132     firstColLayoutProperty->UpdateOffset(V2::GridContainerSize(7));
1133     firstColLayoutProperty->UpdateOrder(V2::GridContainerSize());
1134     firstColLayoutProperty->UpdateUserDefinedIdealSize(CalcSize(std::nullopt, CalcLength(TEST_ALIGN_HEIGHT)));
1135 
1136     auto secondColNode = colNodes_.back();
1137     auto secondColLayoutProperty = secondColNode->GetLayoutProperty<GridColLayoutProperty>();
1138     secondColLayoutProperty->UpdateSpan(V2::GridContainerSize(1));
1139     secondColLayoutProperty->UpdateOffset(V2::GridContainerSize(0));
1140     secondColLayoutProperty->UpdateOrder(V2::GridContainerSize());
1141     secondColLayoutProperty->UpdateUserDefinedIdealSize(CalcSize(std::nullopt, CalcLength(DEFAULT_HEIGHT)));
1142 
1143     /**
1144      * @tc.steps: step2. Running layout function and check the result with expected results.
1145      */
1146     auto layoutWrapper = CreateLayoutWrapperAndLayout(true);
1147     auto frameRect = layoutWrapper->GetOrCreateChildByIndex(0)->GetGeometryNode()->GetFrameRect();
1148     auto columnWidth = frameRect.Width();
1149     auto columnHeight = frameRect.Height();
1150     EXPECT_EQ(frameRect.GetX(), DEFAULT_GRID_ROW_WIDTH - DEFAULT_SPAN_WIDTH);
1151     EXPECT_EQ(frameRect.GetY(), 0);
1152     EXPECT_EQ(columnWidth, DEFAULT_SPAN_WIDTH);
1153     EXPECT_EQ(columnHeight, TEST_ALIGN_HEIGHT);
1154 
1155     frameRect = layoutWrapper->GetOrCreateChildByIndex(1)->GetGeometryNode()->GetFrameRect();
1156     columnWidth = frameRect.Width();
1157     columnHeight = frameRect.Height();
1158     EXPECT_EQ(frameRect.GetX(), 0);
1159     EXPECT_EQ(frameRect.GetY(), TEST_ALIGN_HEIGHT);
1160     EXPECT_EQ(columnWidth, DEFAULT_SPAN_WIDTH);
1161     EXPECT_EQ(columnHeight, DEFAULT_HEIGHT);
1162 }
1163 
1164 /**
1165  * @tc.name: ItemAlign014
1166  * @tc.desc: Test GridRow layout algorithm with different offset and ItemAlign.End.
1167  * @tc.type: FUNC
1168  */
1169 HWTEST_F(GridRowTestNg, ItemAlign014, TestSize.Level1)
1170 {
1171     auto layoutProperty = rowNode_->GetLayoutProperty<GridRowLayoutProperty>();
1172     layoutProperty->UpdateAlignItems(FlexAlign::FLEX_END);
1173 
1174     /**
1175      * @tc.steps: step1. create environment for running process.
1176      */
1177     auto firstColNode = colNodes_.front();
1178     auto firstColLayoutProperty = firstColNode->GetLayoutProperty<GridColLayoutProperty>();
1179     firstColLayoutProperty->UpdateSpan(V2::GridContainerSize(1));
1180     firstColLayoutProperty->UpdateOffset(V2::GridContainerSize(7));
1181     firstColLayoutProperty->UpdateOrder(V2::GridContainerSize());
1182     firstColLayoutProperty->UpdateUserDefinedIdealSize(CalcSize(std::nullopt, CalcLength(TEST_ALIGN_HEIGHT)));
1183 
1184     auto secondColNode = colNodes_.back();
1185     auto secondColLayoutProperty = secondColNode->GetLayoutProperty<GridColLayoutProperty>();
1186     secondColLayoutProperty->UpdateSpan(V2::GridContainerSize(1));
1187     secondColLayoutProperty->UpdateOffset(V2::GridContainerSize(0));
1188     secondColLayoutProperty->UpdateOrder(V2::GridContainerSize());
1189     secondColLayoutProperty->UpdateUserDefinedIdealSize(CalcSize(std::nullopt, CalcLength(DEFAULT_HEIGHT)));
1190 
1191     /**
1192      * @tc.steps: step2. Running layout function and check the result with expected results.
1193      */
1194     auto layoutWrapper = CreateLayoutWrapperAndLayout(true);
1195     auto frameRect = layoutWrapper->GetOrCreateChildByIndex(0)->GetGeometryNode()->GetFrameRect();
1196     auto columnWidth = frameRect.Width();
1197     auto columnHeight = frameRect.Height();
1198     EXPECT_EQ(frameRect.GetX(), DEFAULT_GRID_ROW_WIDTH - DEFAULT_SPAN_WIDTH);
1199     EXPECT_EQ(frameRect.GetY(), 0);
1200     EXPECT_EQ(columnWidth, DEFAULT_SPAN_WIDTH);
1201     EXPECT_EQ(columnHeight, TEST_ALIGN_HEIGHT);
1202 
1203     frameRect = layoutWrapper->GetOrCreateChildByIndex(1)->GetGeometryNode()->GetFrameRect();
1204     columnWidth = frameRect.Width();
1205     columnHeight = frameRect.Height();
1206     EXPECT_EQ(frameRect.GetX(), 0);
1207     EXPECT_EQ(frameRect.GetY(), TEST_ALIGN_HEIGHT);
1208     EXPECT_EQ(columnWidth, DEFAULT_SPAN_WIDTH);
1209     EXPECT_EQ(columnHeight, DEFAULT_HEIGHT);
1210 }
1211 
1212 /**
1213  * @tc.name: ItemAlign015
1214  * @tc.desc: Test GridRow layout algorithm with different offset and ItemAlign.STRETCH.
1215  * @tc.type: FUNC
1216  */
1217 HWTEST_F(GridRowTestNg, ItemAlign015, TestSize.Level1)
1218 {
1219     auto layoutProperty = rowNode_->GetLayoutProperty<GridRowLayoutProperty>();
1220     layoutProperty->UpdateAlignItems(FlexAlign::STRETCH);
1221 
1222     /**
1223      * @tc.steps: step1. create environment for running process.
1224      */
1225     auto firstColNode = colNodes_.front();
1226     auto firstColLayoutProperty = firstColNode->GetLayoutProperty<GridColLayoutProperty>();
1227     firstColLayoutProperty->UpdateSpan(V2::GridContainerSize(1));
1228     firstColLayoutProperty->UpdateOffset(V2::GridContainerSize(7));
1229     firstColLayoutProperty->UpdateOrder(V2::GridContainerSize());
1230     firstColLayoutProperty->UpdateUserDefinedIdealSize(CalcSize(std::nullopt, CalcLength(TEST_ALIGN_HEIGHT)));
1231 
1232     auto secondColNode = colNodes_.back();
1233     auto secondColLayoutProperty = secondColNode->GetLayoutProperty<GridColLayoutProperty>();
1234     secondColLayoutProperty->UpdateSpan(V2::GridContainerSize(1));
1235     secondColLayoutProperty->UpdateOffset(V2::GridContainerSize(0));
1236     secondColLayoutProperty->UpdateOrder(V2::GridContainerSize());
1237     secondColLayoutProperty->UpdateUserDefinedIdealSize(CalcSize(std::nullopt, CalcLength(DEFAULT_HEIGHT)));
1238 
1239     /**
1240      * @tc.steps: step2. Running layout function and check the result with expected results.
1241      */
1242     auto layoutWrapper = CreateLayoutWrapperAndLayout(true);
1243     auto frameRect = layoutWrapper->GetOrCreateChildByIndex(0)->GetGeometryNode()->GetFrameRect();
1244     auto columnWidth = frameRect.Width();
1245     auto columnHeight = frameRect.Height();
1246     EXPECT_EQ(frameRect.GetX(), DEFAULT_GRID_ROW_WIDTH - DEFAULT_SPAN_WIDTH);
1247     EXPECT_EQ(frameRect.GetY(), 0);
1248     EXPECT_EQ(columnWidth, DEFAULT_SPAN_WIDTH);
1249     EXPECT_EQ(columnHeight, TEST_ALIGN_HEIGHT);
1250 
1251     frameRect = layoutWrapper->GetOrCreateChildByIndex(1)->GetGeometryNode()->GetFrameRect();
1252     columnWidth = frameRect.Width();
1253     columnHeight = frameRect.Height();
1254     EXPECT_EQ(frameRect.GetX(), 0);
1255     EXPECT_EQ(frameRect.GetY(), TEST_ALIGN_HEIGHT);
1256     EXPECT_EQ(columnWidth, DEFAULT_SPAN_WIDTH);
1257     EXPECT_EQ(columnHeight, DEFAULT_HEIGHT);
1258 }
1259 /**
1260  * @tc.name: ItemAlign016
1261  * @tc.desc: Test GridRow layout algorithm with diferent offset, direction and default ItemAlign
1262  * @tc.type: FUNC
1263  */
1264 HWTEST_F(GridRowTestNg, ItemAlign016, TestSize.Level1)
1265 {
1266     auto layoutProperty = rowNode_->GetLayoutProperty<GridRowLayoutProperty>();
1267     layoutProperty->ResetAlignItems();
1268     auto itemAlign = layoutProperty->GetAlignItems();
1269     layoutProperty->UpdateDirection(V2::GridRowDirection::RowReverse);
1270     EXPECT_FALSE(itemAlign.has_value());
1271 
1272     /**
1273      * @tc.steps: step1. create environment for running process.
1274      */
1275     auto firstColNode = colNodes_.front();
1276     auto firstColLayoutProperty = firstColNode->GetLayoutProperty<GridColLayoutProperty>();
1277     firstColLayoutProperty->UpdateSpan(V2::GridContainerSize(1));
1278     firstColLayoutProperty->UpdateOffset(V2::GridContainerSize(7));
1279     firstColLayoutProperty->UpdateOrder(V2::GridContainerSize());
1280     firstColLayoutProperty->UpdateUserDefinedIdealSize(CalcSize(std::nullopt, CalcLength(TEST_ALIGN_HEIGHT)));
1281 
1282     auto secondColNode = colNodes_.back();
1283     auto secondColLayoutProperty = secondColNode->GetLayoutProperty<GridColLayoutProperty>();
1284     secondColLayoutProperty->UpdateSpan(V2::GridContainerSize(1));
1285     secondColLayoutProperty->UpdateOffset(V2::GridContainerSize(0));
1286     secondColLayoutProperty->UpdateOrder(V2::GridContainerSize());
1287     secondColLayoutProperty->UpdateUserDefinedIdealSize(CalcSize(std::nullopt, CalcLength(DEFAULT_HEIGHT)));
1288 
1289     /**
1290      * @tc.steps: step2. Running layout function and check the result with expected results.
1291      */
1292     auto layoutWrapper = CreateLayoutWrapperAndLayout(true);
1293     auto frameRect = layoutWrapper->GetOrCreateChildByIndex(0)->GetGeometryNode()->GetFrameRect();
1294     auto columnWidth = frameRect.Width();
1295     auto columnHeight = frameRect.Height();
1296     EXPECT_EQ(frameRect.GetX(), 0);
1297     EXPECT_EQ(frameRect.GetY(), 0);
1298     EXPECT_EQ(columnWidth, DEFAULT_SPAN_WIDTH);
1299     EXPECT_EQ(columnHeight, TEST_ALIGN_HEIGHT);
1300 
1301     frameRect = layoutWrapper->GetOrCreateChildByIndex(1)->GetGeometryNode()->GetFrameRect();
1302     columnWidth = frameRect.Width();
1303     columnHeight = frameRect.Height();
1304     EXPECT_EQ(frameRect.GetX(), DEFAULT_GRID_ROW_WIDTH - DEFAULT_SPAN_WIDTH);
1305     EXPECT_EQ(frameRect.GetY(), TEST_ALIGN_HEIGHT);
1306     EXPECT_EQ(columnWidth, DEFAULT_SPAN_WIDTH);
1307     EXPECT_EQ(columnHeight, DEFAULT_HEIGHT);
1308 }
1309 
1310 /**
1311  * @tc.name: ItemAlign017
1312  * @tc.desc: Test GridRow layout algorithm with different offset, direction and ItemAlign.Start.
1313  * @tc.type: FUNC
1314  */
1315 HWTEST_F(GridRowTestNg, ItemAlign017, TestSize.Level1)
1316 {
1317     auto layoutProperty = rowNode_->GetLayoutProperty<GridRowLayoutProperty>();
1318     layoutProperty->UpdateDirection(V2::GridRowDirection::RowReverse);
1319     layoutProperty->UpdateAlignItems(FlexAlign::FLEX_START);
1320 
1321     /**
1322      * @tc.steps: step1. create environment for running process.
1323      */
1324     auto firstColNode = colNodes_.front();
1325     auto firstColLayoutProperty = firstColNode->GetLayoutProperty<GridColLayoutProperty>();
1326     firstColLayoutProperty->UpdateSpan(V2::GridContainerSize(1));
1327     firstColLayoutProperty->UpdateOffset(V2::GridContainerSize(7));
1328     firstColLayoutProperty->UpdateOrder(V2::GridContainerSize());
1329     firstColLayoutProperty->UpdateUserDefinedIdealSize(CalcSize(std::nullopt, CalcLength(TEST_ALIGN_HEIGHT)));
1330 
1331     auto secondColNode = colNodes_.back();
1332     auto secondColLayoutProperty = secondColNode->GetLayoutProperty<GridColLayoutProperty>();
1333     secondColLayoutProperty->UpdateSpan(V2::GridContainerSize(1));
1334     secondColLayoutProperty->UpdateOffset(V2::GridContainerSize(0));
1335     secondColLayoutProperty->UpdateOrder(V2::GridContainerSize());
1336     secondColLayoutProperty->UpdateUserDefinedIdealSize(CalcSize(std::nullopt, CalcLength(DEFAULT_HEIGHT)));
1337 
1338     /**
1339      * @tc.steps: step2. Running layout function and check the result with expected results.
1340      */
1341     auto layoutWrapper = CreateLayoutWrapperAndLayout(true);
1342     auto frameRect = layoutWrapper->GetOrCreateChildByIndex(0)->GetGeometryNode()->GetFrameRect();
1343     auto columnWidth = frameRect.Width();
1344     auto columnHeight = frameRect.Height();
1345     EXPECT_EQ(frameRect.GetX(), 0);
1346     EXPECT_EQ(frameRect.GetY(), 0);
1347     EXPECT_EQ(columnWidth, DEFAULT_SPAN_WIDTH);
1348     EXPECT_EQ(columnHeight, TEST_ALIGN_HEIGHT);
1349 
1350     frameRect = layoutWrapper->GetOrCreateChildByIndex(1)->GetGeometryNode()->GetFrameRect();
1351     columnWidth = frameRect.Width();
1352     columnHeight = frameRect.Height();
1353     EXPECT_EQ(frameRect.GetX(), DEFAULT_GRID_ROW_WIDTH - DEFAULT_SPAN_WIDTH);
1354     EXPECT_EQ(frameRect.GetY(), TEST_ALIGN_HEIGHT);
1355     EXPECT_EQ(columnWidth, DEFAULT_SPAN_WIDTH);
1356     EXPECT_EQ(columnHeight, DEFAULT_HEIGHT);
1357 }
1358 
1359 /**
1360  * @tc.name: ItemAlign018
1361  * @tc.desc: Test GridRow layout algorithm with different offset, direction and ItemAlign.Center.
1362  * @tc.type: FUNC
1363  */
1364 HWTEST_F(GridRowTestNg, ItemAlign018, TestSize.Level1)
1365 {
1366     auto layoutProperty = rowNode_->GetLayoutProperty<GridRowLayoutProperty>();
1367     layoutProperty->UpdateDirection(V2::GridRowDirection::RowReverse);
1368     layoutProperty->UpdateAlignItems(FlexAlign::CENTER);
1369 
1370     /**
1371      * @tc.steps: step1. create environment for running process.
1372      */
1373     auto firstColNode = colNodes_.front();
1374     auto firstColLayoutProperty = firstColNode->GetLayoutProperty<GridColLayoutProperty>();
1375     firstColLayoutProperty->UpdateSpan(V2::GridContainerSize(1));
1376     firstColLayoutProperty->UpdateOffset(V2::GridContainerSize(7));
1377     firstColLayoutProperty->UpdateOrder(V2::GridContainerSize());
1378     firstColLayoutProperty->UpdateUserDefinedIdealSize(CalcSize(std::nullopt, CalcLength(TEST_ALIGN_HEIGHT)));
1379 
1380     auto secondColNode = colNodes_.back();
1381     auto secondColLayoutProperty = secondColNode->GetLayoutProperty<GridColLayoutProperty>();
1382     secondColLayoutProperty->UpdateSpan(V2::GridContainerSize(1));
1383     secondColLayoutProperty->UpdateOffset(V2::GridContainerSize(0));
1384     secondColLayoutProperty->UpdateOrder(V2::GridContainerSize());
1385     secondColLayoutProperty->UpdateUserDefinedIdealSize(CalcSize(std::nullopt, CalcLength(DEFAULT_HEIGHT)));
1386 
1387     /**
1388      * @tc.steps: step2. Running layout function and check the result with expected results.
1389      */
1390     auto layoutWrapper = CreateLayoutWrapperAndLayout(true);
1391     auto frameRect = layoutWrapper->GetOrCreateChildByIndex(0)->GetGeometryNode()->GetFrameRect();
1392     auto columnWidth = frameRect.Width();
1393     auto columnHeight = frameRect.Height();
1394     EXPECT_EQ(frameRect.GetX(), 0);
1395     EXPECT_EQ(frameRect.GetY(), 0);
1396     EXPECT_EQ(columnWidth, DEFAULT_SPAN_WIDTH);
1397     EXPECT_EQ(columnHeight, TEST_ALIGN_HEIGHT);
1398 
1399     frameRect = layoutWrapper->GetOrCreateChildByIndex(1)->GetGeometryNode()->GetFrameRect();
1400     columnWidth = frameRect.Width();
1401     columnHeight = frameRect.Height();
1402     EXPECT_EQ(frameRect.GetX(), DEFAULT_GRID_ROW_WIDTH - DEFAULT_SPAN_WIDTH);
1403     EXPECT_EQ(frameRect.GetY(), TEST_ALIGN_HEIGHT);
1404     EXPECT_EQ(columnWidth, DEFAULT_SPAN_WIDTH);
1405     EXPECT_EQ(columnHeight, DEFAULT_HEIGHT);
1406 }
1407 
1408 /**
1409  * @tc.name: ItemAlign019
1410  * @tc.desc: Test GridRow layout algorithm with different offset, direction and ItemAlign.End.
1411  * @tc.type: FUNC
1412  */
1413 HWTEST_F(GridRowTestNg, ItemAlign019, TestSize.Level1)
1414 {
1415     auto layoutProperty = rowNode_->GetLayoutProperty<GridRowLayoutProperty>();
1416     layoutProperty->UpdateDirection(V2::GridRowDirection::RowReverse);
1417     layoutProperty->UpdateAlignItems(FlexAlign::FLEX_END);
1418 
1419     /**
1420      * @tc.steps: step1. create environment for running process.
1421      */
1422     auto firstColNode = colNodes_.front();
1423     auto firstColLayoutProperty = firstColNode->GetLayoutProperty<GridColLayoutProperty>();
1424     firstColLayoutProperty->UpdateSpan(V2::GridContainerSize(1));
1425     firstColLayoutProperty->UpdateOffset(V2::GridContainerSize(7));
1426     firstColLayoutProperty->UpdateOrder(V2::GridContainerSize());
1427     firstColLayoutProperty->UpdateUserDefinedIdealSize(CalcSize(std::nullopt, CalcLength(TEST_ALIGN_HEIGHT)));
1428 
1429     auto secondColNode = colNodes_.back();
1430     auto secondColLayoutProperty = secondColNode->GetLayoutProperty<GridColLayoutProperty>();
1431     secondColLayoutProperty->UpdateSpan(V2::GridContainerSize(1));
1432     secondColLayoutProperty->UpdateOffset(V2::GridContainerSize(0));
1433     secondColLayoutProperty->UpdateOrder(V2::GridContainerSize());
1434     secondColLayoutProperty->UpdateUserDefinedIdealSize(CalcSize(std::nullopt, CalcLength(DEFAULT_HEIGHT)));
1435 
1436     /**
1437      * @tc.steps: step2. Running layout function and check the result with expected results.
1438      */
1439     auto layoutWrapper = CreateLayoutWrapperAndLayout(true);
1440     auto frameRect = layoutWrapper->GetOrCreateChildByIndex(0)->GetGeometryNode()->GetFrameRect();
1441     auto columnWidth = frameRect.Width();
1442     auto columnHeight = frameRect.Height();
1443     EXPECT_EQ(frameRect.GetX(), 0);
1444     EXPECT_EQ(frameRect.GetY(), 0);
1445     EXPECT_EQ(columnWidth, DEFAULT_SPAN_WIDTH);
1446     EXPECT_EQ(columnHeight, TEST_ALIGN_HEIGHT);
1447 
1448     frameRect = layoutWrapper->GetOrCreateChildByIndex(1)->GetGeometryNode()->GetFrameRect();
1449     columnWidth = frameRect.Width();
1450     columnHeight = frameRect.Height();
1451     EXPECT_EQ(frameRect.GetX(), DEFAULT_GRID_ROW_WIDTH - DEFAULT_SPAN_WIDTH);
1452     EXPECT_EQ(frameRect.GetY(), TEST_ALIGN_HEIGHT);
1453     EXPECT_EQ(columnWidth, DEFAULT_SPAN_WIDTH);
1454     EXPECT_EQ(columnHeight, DEFAULT_HEIGHT);
1455 }
1456 
1457 /**
1458  * @tc.name: ItemAlign020
1459  * @tc.desc: Test GridRow layout algorithm with different offset, direction and ItemAlign.STRETCH.
1460  * @tc.type: FUNC
1461  */
1462 HWTEST_F(GridRowTestNg, ItemAlign020, TestSize.Level1)
1463 {
1464     auto layoutProperty = rowNode_->GetLayoutProperty<GridRowLayoutProperty>();
1465     layoutProperty->UpdateDirection(V2::GridRowDirection::RowReverse);
1466     layoutProperty->UpdateAlignItems(FlexAlign::STRETCH);
1467 
1468     /**
1469      * @tc.steps: step1. create environment for running process.
1470      */
1471     auto firstColNode = colNodes_.front();
1472     auto firstColLayoutProperty = firstColNode->GetLayoutProperty<GridColLayoutProperty>();
1473     firstColLayoutProperty->UpdateSpan(V2::GridContainerSize(1));
1474     firstColLayoutProperty->UpdateOffset(V2::GridContainerSize(7));
1475     firstColLayoutProperty->UpdateOrder(V2::GridContainerSize());
1476     firstColLayoutProperty->UpdateUserDefinedIdealSize(CalcSize(std::nullopt, CalcLength(TEST_ALIGN_HEIGHT)));
1477 
1478     auto secondColNode = colNodes_.back();
1479     auto secondColLayoutProperty = secondColNode->GetLayoutProperty<GridColLayoutProperty>();
1480     secondColLayoutProperty->UpdateSpan(V2::GridContainerSize(1));
1481     secondColLayoutProperty->UpdateOffset(V2::GridContainerSize(0));
1482     secondColLayoutProperty->UpdateOrder(V2::GridContainerSize());
1483     secondColLayoutProperty->UpdateUserDefinedIdealSize(CalcSize(std::nullopt, CalcLength(DEFAULT_HEIGHT)));
1484 
1485     /**
1486      * @tc.steps: step2. Running layout function and check the result with expected results.
1487      */
1488     auto layoutWrapper = CreateLayoutWrapperAndLayout(true);
1489     auto frameRect = layoutWrapper->GetOrCreateChildByIndex(0)->GetGeometryNode()->GetFrameRect();
1490     auto columnWidth = frameRect.Width();
1491     auto columnHeight = frameRect.Height();
1492     EXPECT_EQ(frameRect.GetX(), 0);
1493     EXPECT_EQ(frameRect.GetY(), 0);
1494     EXPECT_EQ(columnWidth, DEFAULT_SPAN_WIDTH);
1495     EXPECT_EQ(columnHeight, TEST_ALIGN_HEIGHT);
1496 
1497     frameRect = layoutWrapper->GetOrCreateChildByIndex(1)->GetGeometryNode()->GetFrameRect();
1498     columnWidth = frameRect.Width();
1499     columnHeight = frameRect.Height();
1500     EXPECT_EQ(frameRect.GetX(), DEFAULT_GRID_ROW_WIDTH - DEFAULT_SPAN_WIDTH);
1501     EXPECT_EQ(frameRect.GetY(), TEST_ALIGN_HEIGHT);
1502     EXPECT_EQ(columnWidth, DEFAULT_SPAN_WIDTH);
1503     EXPECT_EQ(columnHeight, DEFAULT_HEIGHT);
1504 }
1505 
1506 /**
1507  * @tc.name: Breakpoint
1508  * @tc.desc: Test GridRow layout algorithm with different breakpoint and
1509  *           trigerring event when breakpoint changes.
1510  * @tc.type: FUNC
1511  */
1512 HWTEST_F(GridRowTestNg, Breakpoint, TestSize.Level1)
1513 {
1514     auto layoutProperty = rowNode_->GetLayoutProperty<GridRowLayoutProperty>();
1515     constexpr int32_t mdCols = 6;
1516     constexpr int32_t lgCols = 4;
1517     V2::GridContainerSize columns(DEFAULT_COLUMNS);
1518     columns.md = mdCols;
1519     columns.lg = lgCols;
1520     layoutProperty->UpdateColumns(columns);
1521 
1522     V2::BreakPoints breakpoints;
1523     breakpoints.reference = V2::BreakPointsReference::ComponentSize;
1524     breakpoints.breakpoints.assign({ "400px", "700px", "1000px" }); // xs sm md lg
1525     layoutProperty->UpdateBreakPoints(breakpoints);
1526 
1527     auto layoutWrapper = CreateLayoutWrapperAndLayout(true);
1528     auto frameRect = layoutWrapper->GetOrCreateChildByIndex(0)->GetGeometryNode()->GetFrameRect();
1529     float columnWidth = frameRect.Width();
1530     EXPECT_EQ(columnWidth, DEFAULT_GRID_ROW_WIDTH / mdCols); // expect md
1531 
1532     auto eventHub = rowNode_->GetEventHub<GridRowEventHub>();
1533     bool eventTriggerFlag = false;
__anon0238344b0302(const std::string& size) 1534     eventHub->SetOnBreakpointChange([&eventTriggerFlag, expectSize = std::string("lg")](const std::string& size) {
1535         eventTriggerFlag = true;
1536         EXPECT_EQ(size, expectSize);
1537     });
1538 
1539     breakpoints.breakpoints.assign({ "100px", "400px", "700px" }); // xs sm md lg
1540     layoutProperty->UpdateBreakPoints(breakpoints);
1541 
1542     layoutWrapper = CreateLayoutWrapperAndLayout(true);
1543     frameRect = layoutWrapper->GetOrCreateChildByIndex(0)->GetGeometryNode()->GetFrameRect();
1544     columnWidth = frameRect.Width();
1545     EXPECT_EQ(columnWidth, DEFAULT_GRID_ROW_WIDTH / lgCols); // expect lg
1546     EXPECT_TRUE(eventTriggerFlag);
1547 }
1548 
1549 /**
1550  * @tc.name: GridRowDefault001
1551  * @tc.desc: Test the default values of GridRow's properties.
1552  * @tc.type: FUNC
1553  */
1554 HWTEST_F(GridRowTestNg, GridRowDefault001, TestSize.Level1)
1555 {
1556     GridRowModelNG gridRowModelNG;
1557     gridRowModelNG.Create();
__anon0238344b0402(const std::string& size) 1558     gridRowModelNG.SetOnBreakPointChange([](const std::string& size) {});
1559     auto frameNode = AceType::DynamicCast<FrameNode>(ViewStackProcessor::GetInstance()->Finish());
1560     EXPECT_NE(frameNode, nullptr);
1561     auto layoutProperty = frameNode->GetLayoutProperty<GridRowLayoutProperty>();
1562     EXPECT_NE(layoutProperty, nullptr);
1563 
1564     auto columns = layoutProperty->GetColumns();
1565     EXPECT_TRUE(columns.has_value());
1566     auto gutter = layoutProperty->GetGutter();
1567     EXPECT_TRUE(gutter.has_value());
1568     auto breakpoints = layoutProperty->GetBreakPoints();
1569     EXPECT_TRUE(breakpoints.has_value());
1570     auto direction = layoutProperty->GetDirection();
1571     EXPECT_TRUE(direction.has_value());
1572 
1573     constexpr int32_t testVal = 7;
1574     layoutProperty->UpdateColumns(V2::GridContainerSize(testVal));
1575     EXPECT_EQ(layoutProperty->GetColumnsValue().xs, testVal);
1576     layoutProperty->UpdateGutter(V2::Gutter(Dimension(testVal)));
1577     EXPECT_EQ(layoutProperty->GetGutterValue().yMd, Dimension(testVal));
1578     V2::BreakPoints breakpointsVal;
1579     breakpointsVal.breakpoints.assign({ "123vp" });
1580     layoutProperty->UpdateBreakPoints(breakpointsVal);
1581     EXPECT_EQ(layoutProperty->GetBreakPointsValue().breakpoints.front(), "123vp");
1582     layoutProperty->UpdateDirection(V2::GridRowDirection::RowReverse);
1583     EXPECT_EQ(layoutProperty->GetDirectionValue(), V2::GridRowDirection::RowReverse);
1584 
1585     // rubbish code for coverity
1586     auto clone = layoutProperty->Clone();
1587     clone.Reset();
1588     auto json = JsonUtil::Create(true);
1589     layoutProperty->ToJsonValue(json, filter);
1590 }
1591 
1592 /**
1593  * @tc.name: GridRowDefault002
1594  * @tc.desc: Test GridRow's properties.
1595  * @tc.type: FUNC
1596  */
1597 HWTEST_F(GridRowTestNg, GridRowDefault002, TestSize.Level1)
1598 {
1599     GridRowModelNG gridRowModelNG;
1600 
1601     auto colVal = Referenced::MakeRefPtr<V2::GridContainerSize>();
1602     auto gutterVal = Referenced::MakeRefPtr<V2::Gutter>();
1603     auto breakpointsVal = Referenced::MakeRefPtr<V2::BreakPoints>();
1604     auto directionVal = V2::GridRowDirection::Row;
1605 
1606     gridRowModelNG.Create(colVal, gutterVal, breakpointsVal, directionVal);
1607     auto frameNode = AceType::DynamicCast<FrameNode>(ViewStackProcessor::GetInstance()->Finish());
1608     EXPECT_NE(frameNode, nullptr);
1609     auto layoutProperty = frameNode->GetLayoutProperty<GridRowLayoutProperty>();
1610     EXPECT_NE(layoutProperty, nullptr);
1611 
1612     auto columns = layoutProperty->GetColumns();
1613     EXPECT_TRUE(columns.has_value());
1614     auto gutter = layoutProperty->GetGutter();
1615     EXPECT_TRUE(gutter.has_value());
1616     auto breakpoints = layoutProperty->GetBreakPoints();
1617     EXPECT_TRUE(breakpoints.has_value());
1618     auto direction = layoutProperty->GetDirection();
1619     EXPECT_TRUE(direction.has_value());
1620 }
1621 
1622 /**
1623  * @tc.name: GridColDefault001
1624  * @tc.desc: Test the default values of GridCol's properties.
1625  * @tc.type: FUNC
1626  */
1627 HWTEST_F(GridRowTestNg, GridColDefault001, TestSize.Level1)
1628 {
1629     GridColModelNG gridColModelNG;
1630     gridColModelNG.Create();
1631     auto frameNode = AceType::DynamicCast<FrameNode>(ViewStackProcessor::GetInstance()->Finish());
1632     EXPECT_NE(frameNode, nullptr);
1633     auto layoutProperty = frameNode->GetLayoutProperty<GridColLayoutProperty>();
1634     EXPECT_NE(layoutProperty, nullptr);
1635 
1636     auto span = layoutProperty->GetSpan();
1637     EXPECT_TRUE(span.has_value());
1638     auto offset = layoutProperty->GetOffset();
1639     EXPECT_TRUE(offset.has_value());
1640     auto order = layoutProperty->GetOrder();
1641     EXPECT_TRUE(order.has_value());
1642 
1643     constexpr int32_t testVal = 7;
1644     layoutProperty->UpdateSpan(V2::GridContainerSize(testVal));
1645     EXPECT_EQ(layoutProperty->GetSpanValue().xs, testVal);
1646     layoutProperty->UpdateOffset(V2::GridContainerSize(testVal));
1647     EXPECT_EQ(layoutProperty->GetOffsetValue().md, testVal);
1648     layoutProperty->UpdateOrder(V2::GridContainerSize(testVal));
1649     EXPECT_EQ(layoutProperty->GetOrderValue().lg, testVal);
1650 
1651     // rubbish code for coverity
1652     auto clone = layoutProperty->Clone();
1653     clone.Reset();
1654     auto json = JsonUtil::Create(true);
1655     layoutProperty->ToJsonValue(json, filter);
1656 }
1657 
1658 /**
1659  * @tc.name: GridColDefault002
1660  * @tc.desc: Test GridCol's properties.
1661  * @tc.type: FUNC
1662  */
1663 HWTEST_F(GridRowTestNg, GridColDefault002, TestSize.Level1)
1664 {
1665     GridColModelNG gridColModelNG;
1666     V2::GridContainerSize spanVal = V2::GridContainerSize(1);
1667     V2::GridContainerSize offsetVal = V2::GridContainerSize(0);
1668     V2::GridContainerSize orderVal = V2::GridContainerSize(0);
1669     gridColModelNG.Create(spanVal, offsetVal, orderVal);
1670     auto frameNode = AceType::DynamicCast<FrameNode>(ViewStackProcessor::GetInstance()->Finish());
1671     EXPECT_NE(frameNode, nullptr);
1672     auto layoutProperty = frameNode->GetLayoutProperty<GridColLayoutProperty>();
1673     EXPECT_NE(layoutProperty, nullptr);
1674 
1675     auto span = layoutProperty->GetSpan();
1676     EXPECT_TRUE(span.has_value());
1677     auto offset = layoutProperty->GetOffset();
1678     EXPECT_TRUE(offset.has_value());
1679     auto order = layoutProperty->GetOrder();
1680     EXPECT_TRUE(order.has_value());
1681 }
1682 } // namespace OHOS::Ace::NG
1683