1 /*
2 * Copyright (c) 2022 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16 #include "gtest/gtest.h"
17
18 #define private public
19 #define protected public
20 #include "core/components/test/unittest/mock/mock_render_common.h"
21 #include "core/components/test/unittest/water_flow/water_flow_test_utils.h"
22 #include "core/components_v2/water_flow/water_flow_element.h"
23 #undef private
24 #undef protected
25
26 using namespace testing;
27 using namespace testing::ext;
28 using RenderWaterFlow = OHOS::Ace::V2::RenderWaterFlow;
29 using RenderWaterFlowItem = OHOS::Ace::V2::RenderWaterFlowItem;
30 using WaterFlowComponent = OHOS::Ace::V2::WaterFlowComponent;
31 using WaterFlowItemComponent = OHOS::Ace::V2::WaterFlowItemComponent;
32 using WaterFlowPositionController = OHOS::Ace::V2::WaterFlowPositionController;
33
34 #define CHECK_RENDERNODE_NULL_VOID(ptr) \
35 do { \
36 if (!(ptr)) { \
37 GTEST_LOG_(INFO) << #ptr "is nullptr!"; \
38 return; \
39 } \
40 } while (0)
41
42 namespace OHOS::Ace {
43 constexpr size_t CREATE_FLOWITEM_COUNT = 5;
44 constexpr size_t CREATE_FLOWITEM_MAX_COUNT = 50;
45 constexpr size_t START_INDEX = 0;
46 constexpr double START_POS = 0.0;
47 constexpr size_t TOTAL_COUNT = 5000;
48 const Size FLOW_MAX_SIZE(1000, 1000);
49 const Size FLOW_MIN_SIZE(150, 150);
50 constexpr Dimension MIN_WIDTH = 100.0_px;
51 constexpr Dimension MIN_HEIGHT = 100.0_px;
52 constexpr Dimension MAX_WIDTH = 1000.0_px;
53 constexpr Dimension MAX_HEIGHT = 1000.0_px;
54 constexpr int64_t MICROSEC_TO_NANOSEC = 1000;
55 constexpr int64_t MILLISEC_TO_NANOSEC = 1000000;
56 constexpr double CENTER_POINT = 2.0;
57 constexpr int32_t CACHE_SIZE_SCALE = 3;
58
59 using ConstraintSize = struct {
60 Dimension minWidth;
61 Dimension minHeight;
62 Dimension maxWidth;
63 Dimension maxHeight;
64 };
65
66 class MockWaterFlowElement : public V2::WaterFlowItemGenerator {
67 public:
68 RefPtr<RenderNode> RequestWaterFlowFooter() override;
SetContext(const RefPtr<PipelineContext> & context)69 inline void SetContext(const RefPtr<PipelineContext>& context)
70 {
71 mockContext_ = context;
72 }
73 private:
74 RefPtr<PipelineContext> mockContext_;
75 };
76
RequestWaterFlowFooter()77 RefPtr<RenderNode> MockWaterFlowElement::RequestWaterFlowFooter()
78 {
79 if (mockContext_) {
80 auto item = WaterFlowTestUtils::CreateRenderItem(mockContext_);
81 return item;
82 }
83 return nullptr;
84 }
85
86 class RenderWaterFlowTest : public testing::Test {
87 public:
88 static void SetUpTestCase();
89 static void TearDownTestCase();
90 void SetUp() override;
91 void TearDown() override;
92
93 void CreateRenderWaterFlow(std::string columnsArgs, std::string rowsArgs,
94 FlexDirection direction = FlexDirection::COLUMN, size_t index = 0);
95 void SetItemConstraintSize(RefPtr<Component> component, const ConstraintSize& itemConstraintSize);
96 void SetCallback();
97 RefPtr<PipelineContext> mockContext_;
98 RefPtr<RenderWaterFlow> renderNode_;
99 ConstraintSize itemConstraintSize_ = { MIN_WIDTH, MIN_HEIGHT, MAX_WIDTH, MAX_HEIGHT };
100 };
101
SetUpTestCase()102 void RenderWaterFlowTest::SetUpTestCase() {}
TearDownTestCase()103 void RenderWaterFlowTest::TearDownTestCase() {}
104
SetUp()105 void RenderWaterFlowTest::SetUp()
106 {
107 mockContext_ = MockRenderCommon::GetMockContext();
108 mockContext_->rootWidth_ = 2049.0;
109 renderNode_ = AceType::MakeRefPtr<RenderWaterFlow>();
110 renderNode_->Attach(mockContext_);
111 }
112
TearDown()113 void RenderWaterFlowTest::TearDown()
114 {
115 mockContext_ = nullptr;
116 renderNode_ = nullptr;
117 }
118
SetItemConstraintSize(RefPtr<Component> component,const ConstraintSize & itemConstraintSize)119 void RenderWaterFlowTest::SetItemConstraintSize(RefPtr<Component> component, const ConstraintSize& itemConstraintSize)
120 {
121 auto waterflowComponent = AceType::DynamicCast<WaterFlowComponent>(component);
122 if (waterflowComponent) {
123 waterflowComponent->SetMinWidth(itemConstraintSize.minWidth);
124 waterflowComponent->SetMinHeight(itemConstraintSize.minHeight);
125 waterflowComponent->SetMaxWidth(itemConstraintSize.maxWidth);
126 waterflowComponent->SetMaxHeight(itemConstraintSize.maxHeight);
127 }
128 }
129
CreateRenderWaterFlow(std::string columnsArgs,std::string rowsArgs,FlexDirection direction,size_t index)130 void RenderWaterFlowTest::CreateRenderWaterFlow(std::string columnsArgs, std::string rowsArgs,
131 FlexDirection direction, size_t index)
132 {
133 auto component = WaterFlowTestUtils::CreateComponent(columnsArgs, rowsArgs, direction);
134 auto waterflowComponent = AceType::DynamicCast<WaterFlowComponent>(component);
135 CHECK_RENDERNODE_NULL_VOID(waterflowComponent);
136
137 RefPtr<WaterFlowPositionController> controller = AceType::MakeRefPtr<WaterFlowPositionController>();
138 RefPtr<ScrollBarProxy> scrollBarProxy = AceType::MakeRefPtr<ScrollBarProxy>();
139 waterflowComponent->SetController(controller);
140 waterflowComponent->SetScrollBarProxy(scrollBarProxy);
141 SetItemConstraintSize(waterflowComponent, itemConstraintSize_);
142 CHECK_RENDERNODE_NULL_VOID(renderNode_);
143 SetCallback();
144 renderNode_->Update(waterflowComponent);
145 LayoutParam layoutParam(FLOW_MAX_SIZE, FLOW_MIN_SIZE);
146 renderNode_->SetLayoutParam(layoutParam);
147 renderNode_->GetFlowSize();
148 for (size_t i = 0; i < index; i++) {
149 auto item = WaterFlowTestUtils::CreateRenderItem(mockContext_);
150 auto waterflowItem = AceType::DynamicCast<RenderWaterFlowItem>(item);
151 CHECK_RENDERNODE_NULL_VOID(waterflowItem);
152 renderNode_->AddChildByIndex(i, waterflowItem);
153 }
154 }
155
SetCallback()156 void RenderWaterFlowTest::SetCallback()
157 {
158 CHECK_NULL_VOID(renderNode_);
159 renderNode_->SetBuildChildByIndex([this](size_t index) {
160 auto item = WaterFlowTestUtils::CreateRenderItem(mockContext_);
161 if (!item) {
162 GTEST_LOG_(INFO) << "create renderWaterflowItem failed!";
163 return false;
164 }
165 item->GetChildren().front()->Attach(mockContext_);
166 item->Attach(mockContext_);
167 renderNode_->AddChildByIndex(index, item);
168 return true;
169 });
170 renderNode_->SetDeleteChildByIndex([this](size_t index) {
171 if (renderNode_) {
172 renderNode_->RemoveChildByIndex(index);
173 }
174 });
175 }
176
177 /**
178 * @tc.name: RenderWaterFlowTest_Create_001
179 * @tc.desc: Verify that the rendered object was created successfully.
180 * @tc.type: FUNC
181 * @tc.require: issueI5TFPO
182 */
183 HWTEST_F(RenderWaterFlowTest, RenderWaterFlowTest_Create_001, TestSize.Level1)
184 {
185 CreateRenderWaterFlow("1fr 1fr", "1fr 1fr");
186 CHECK_RENDERNODE_NULL_VOID(renderNode_);
187 auto createRenderNode = renderNode_->Create();
188 EXPECT_TRUE(createRenderNode != nullptr);
189 }
190
191 /**
192 * @tc.name: RenderWaterFlowTest_Update_001
193 * @tc.desc: Verify that the update function is tested normally.
194 * @tc.type: FUNC
195 * @tc.require: issueI5TFPO
196 */
197 HWTEST_F(RenderWaterFlowTest, RenderWaterFlowTest_Update_001, TestSize.Level1)
198 {
199 CreateRenderWaterFlow("1fr 1fr", "1fr 1fr", FlexDirection::COLUMN_REVERSE);
200 CHECK_RENDERNODE_NULL_VOID(renderNode_);
201 EXPECT_TRUE(renderNode_->updateFlag_);
202 EXPECT_TRUE(renderNode_->scrollBarProxy_ != nullptr);
203 EXPECT_EQ(renderNode_->direction_, FlexDirection::COLUMN_REVERSE);
204 EXPECT_EQ(renderNode_->userColGap_.Value(), 100.0);
205 EXPECT_EQ(renderNode_->userRowGap_.Value(), 100.0);
206 EXPECT_EQ(renderNode_->colsArgs_, "1fr 1fr");
207 EXPECT_EQ(renderNode_->rowsArgs_, "1fr 1fr");
208 }
209
210 /**
211 * @tc.name: RenderWaterFlowTest_Update_002
212 * @tc.desc: Verifying exceptions Testing the update function.
213 * @tc.type: FUNC
214 * @tc.require: issueI5TFPO
215 */
216 HWTEST_F(RenderWaterFlowTest, RenderWaterFlowTest_Update_002, TestSize.Level2)
217 {
218 CHECK_RENDERNODE_NULL_VOID(renderNode_);
219 renderNode_->Update(nullptr);
220 EXPECT_TRUE(!(renderNode_->updateFlag_));
221 EXPECT_TRUE(renderNode_->scrollBarProxy_ == nullptr);
222 EXPECT_EQ(renderNode_->userColGap_.Value(), 0.0);
223 EXPECT_EQ(renderNode_->userRowGap_.Value(), 0.0);
224 }
225
226 /**
227 * @tc.name: RenderWaterFlowTest_SetBuildChildByIndex_001
228 * @tc.desc: Verify that the rendernode of the item is created through the SetBuildChildByIndex function.
229 * @tc.type: FUNC
230 * @tc.require: issueI5TFPO
231 */
232 HWTEST_F(RenderWaterFlowTest, RenderWaterFlowTest_SetBuildChildByIndex_001, TestSize.Level1)
233 {
234 CreateRenderWaterFlow("1fr 1fr", "1fr 1fr");
235 CHECK_RENDERNODE_NULL_VOID(renderNode_);
236 EXPECT_TRUE(renderNode_->buildChildByIndex_ != nullptr);
237 EXPECT_TRUE(renderNode_->buildChildByIndex_(START_INDEX));
238 EXPECT_TRUE(!renderNode_->items_.empty());
239 if (renderNode_->deleteChildByIndex_) {
240 renderNode_->deleteChildByIndex_(START_INDEX);
241 EXPECT_TRUE(renderNode_->items_.empty());
242 }
243 }
244
245 /**
246 * @tc.name: RenderWaterFlowTest_SetDeleteChildByIndex_001
247 * @tc.desc: Verify that when calling the SetDeleteChildByIndex function, deleteChildByIndex_ is not empty.
248 * @tc.type: FUNC
249 * @tc.require: issueI5TFPO
250 */
251 HWTEST_F(RenderWaterFlowTest, RenderWaterFlowTest_SetDeleteChildByIndex_001, TestSize.Level1)
252 {
253 CreateRenderWaterFlow("1fr 1fr", "1fr 1fr");
254 CHECK_RENDERNODE_NULL_VOID(renderNode_);
255 EXPECT_TRUE(renderNode_->deleteChildByIndex_ != nullptr);
256 }
257
258 /**
259 * @tc.name: RenderWaterFlowTest_GetTotalCount_001
260 * @tc.desc: Verify GetTotalCount function.
261 * @tc.type: FUNC
262 * @tc.require: issueI5TFPO
263 */
264 HWTEST_F(RenderWaterFlowTest, RenderWaterFlowTest_GetTotalCount_001, TestSize.Level1)
265 {
266 CreateRenderWaterFlow("1fr 1fr", "1fr 1fr");
267 CHECK_RENDERNODE_NULL_VOID(renderNode_);
__anond51a46150302() 268 renderNode_->SetGetTotalCount([]() {
269 return TOTAL_COUNT;
270 });
271 EXPECT_TRUE(renderNode_->getTotalCount_ != nullptr);
272 auto totalCount = renderNode_->getTotalCount_();
273 EXPECT_EQ(totalCount, TOTAL_COUNT);
274 }
275
276 /**
277 * @tc.name: RenderWaterFlowTest_AddChildByIndex_001
278 * @tc.desc: Verify that AddChildByIndex function creates rendernode.
279 * @tc.type: FUNC
280 * @tc.require: issueI5TFPO
281 */
282 HWTEST_F(RenderWaterFlowTest, RenderWaterFlowTest_AddChildByIndex_001, TestSize.Level1)
283 {
284 CreateRenderWaterFlow("1fr 1fr", "1fr 1fr", FlexDirection::COLUMN, CREATE_FLOWITEM_COUNT);
285 CHECK_RENDERNODE_NULL_VOID(renderNode_);
286 EXPECT_EQ(renderNode_->items_.size(), CREATE_FLOWITEM_COUNT);
287 EXPECT_EQ(renderNode_->RenderNode::GetChildren().size(), CREATE_FLOWITEM_COUNT);
288 }
289
290 /**
291 * @tc.name: RenderWaterFlowTest_RemoveChildByIndex_001
292 * @tc.desc: Verify that the RemoveChildByIndex function deletes rendernode.
293 * @tc.type: FUNC
294 * @tc.require: issueI5TFPO
295 */
296 HWTEST_F(RenderWaterFlowTest, RenderWaterFlowTest_RemoveChildByIndex_001, TestSize.Level1)
297 {
298 CreateRenderWaterFlow("1fr 1fr", "1fr 1fr", FlexDirection::COLUMN, CREATE_FLOWITEM_COUNT);
299 CHECK_RENDERNODE_NULL_VOID(renderNode_);
300 EXPECT_EQ(renderNode_->items_.size(), CREATE_FLOWITEM_COUNT);
301 renderNode_->RemoveChildByIndex(CREATE_FLOWITEM_COUNT);
302 EXPECT_EQ(renderNode_->items_.size(), CREATE_FLOWITEM_COUNT);
303 renderNode_->RemoveChildByIndex(CREATE_FLOWITEM_COUNT - 1);
304 EXPECT_EQ(renderNode_->items_.size(), CREATE_FLOWITEM_COUNT - 1);
305 }
306
307 /**
308 * @tc.name: RenderWaterFlowTest_ClearLayout_001
309 * @tc.desc: Fill in items and call clearlayout to clear items.
310 * @tc.type: FUNC
311 * @tc.require: issueI5TFPO
312 */
313 HWTEST_F(RenderWaterFlowTest, RenderWaterFlowTest_ClearLayout_001, TestSize.Level1)
314 {
315 CreateRenderWaterFlow("1fr 1fr", "1fr 1fr", FlexDirection::COLUMN);
316 CHECK_RENDERNODE_NULL_VOID(renderNode_);
317 renderNode_->mainSideEndPos_.push_back(START_POS);
318 renderNode_->mainSideEndPos_.push_back(START_POS);
319 renderNode_->crossSideSize_.push_back(450.0);
320 renderNode_->crossSideSize_.push_back(450.0);
321 auto itemIndex = renderNode_->GetNextSupplyedIndex();
322 auto targetPos = renderNode_->GetTargetPos();
323 renderNode_->CallItemConstraintSize();
324 renderNode_->CallGap();
325 renderNode_->SupplyItems(itemIndex, targetPos);
326 renderNode_->ClearLayout(renderNode_->flowMatrix_.size(), true);
327 EXPECT_TRUE(renderNode_->flowMatrix_.empty());
328 }
329
330 /**
331 * @tc.name: RenderWaterFlowTest_ClearLayout_002
332 * @tc.desc: Fill in items and call clearlayout to clear items of the specified index.
333 * @tc.type: FUNC
334 * @tc.require: issueI5TFPO
335 */
336 HWTEST_F(RenderWaterFlowTest, RenderWaterFlowTest_ClearLayout_002, TestSize.Level1)
337 {
338 CreateRenderWaterFlow("1fr 1fr", "1fr 1fr", FlexDirection::COLUMN, CREATE_FLOWITEM_COUNT);
339 CHECK_RENDERNODE_NULL_VOID(renderNode_);
340
341 renderNode_->InitialFlowProp();
342 auto itemIndex = renderNode_->GetNextSupplyedIndex();
343 auto targetPos = renderNode_->GetTargetPos();
344 renderNode_->SupplyItems(itemIndex, targetPos);
345 renderNode_->ClearLayout(CREATE_FLOWITEM_COUNT - 1);
346 EXPECT_EQ(renderNode_->flowMatrix_.size(), CREATE_FLOWITEM_COUNT - 1);
347 }
348
349 /**
350 * @tc.name: RenderWaterFlowTest_ClearLayout_003
351 * @tc.desc: Call the ClearLayout function to reset the index data of the layout.
352 * @tc.type: FUNC
353 * @tc.require: issueI5TFPO
354 */
355 HWTEST_F(RenderWaterFlowTest, RenderWaterFlowTest_ClearLayout_003, TestSize.Level1)
356 {
357 CreateRenderWaterFlow("1fr 1fr", "1fr 1fr", FlexDirection::COLUMN, CREATE_FLOWITEM_COUNT);
358 CHECK_RENDERNODE_NULL_VOID(renderNode_);
359 renderNode_->crossCount_ = CREATE_FLOWITEM_COUNT;
360 renderNode_->ClearLayout(CREATE_FLOWITEM_COUNT, true);
361 EXPECT_EQ(renderNode_->itemsByCrossIndex_.size(), CREATE_FLOWITEM_COUNT);
362 }
363
364 /**
365 * @tc.name: RenderWaterFlowTest_ClearItems_001
366 * @tc.desc: Verify that the ClearItems function clears the specified items and deletes all items.
367 * @tc.type: FUNC
368 * @tc.require: issueI5TFPO
369 */
370 HWTEST_F(RenderWaterFlowTest, RenderWaterFlowTest_ClearItems_001, TestSize.Level1)
371 {
372 CreateRenderWaterFlow("1fr 1fr", "1fr 1fr", FlexDirection::COLUMN, CREATE_FLOWITEM_COUNT);
373 CHECK_RENDERNODE_NULL_VOID(renderNode_);
374 EXPECT_EQ(renderNode_->items_.size(), CREATE_FLOWITEM_COUNT);
375 renderNode_->ClearItems(CREATE_FLOWITEM_COUNT);
376 EXPECT_EQ(renderNode_->items_.size(), CREATE_FLOWITEM_COUNT);
377 renderNode_->ClearItems();
378 EXPECT_TRUE(renderNode_->items_.empty());
379 }
380
381 /**
382 * @tc.name: RenderWaterFlowTest_OnDataSourceUpdated_001
383 * @tc.desc: Verify that the OnDataSourceUpdated function updates all items.
384 * @tc.type: FUNC
385 * @tc.require: issueI5TFPO
386 */
387 HWTEST_F(RenderWaterFlowTest, RenderWaterFlowTest_OnDataSourceUpdated_001, TestSize.Level1)
388 {
389 CreateRenderWaterFlow("1fr 1fr", "1fr 1fr", FlexDirection::COLUMN, CREATE_FLOWITEM_COUNT);
390 CHECK_RENDERNODE_NULL_VOID(renderNode_);
__anond51a46150402() 391 renderNode_->SetGetTotalCount([]() {
392 return TOTAL_COUNT;
393 });
394 auto itemIndex = renderNode_->GetNextSupplyedIndex();
395 auto targetPos = renderNode_->GetTargetPos();
396 renderNode_->InitialFlowProp();
397 renderNode_->SupplyItems(itemIndex, targetPos);
398 renderNode_->OnDataSourceUpdated(START_INDEX);
399 EXPECT_TRUE(renderNode_->items_.empty());
400 }
401
402 /**
403 * @tc.name: RenderWaterFlowTest_OnDataSourceUpdated_002
404 * @tc.desc: Verify that the OnDataSourceUpdated function updates the items after the specified items.
405 * @tc.type: FUNC
406 * @tc.require: issueI5TFPO
407 */
408 HWTEST_F(RenderWaterFlowTest, RenderWaterFlowTest_OnDataSourceUpdated_002, TestSize.Level1)
409 {
410 CreateRenderWaterFlow("1fr 1fr", "1fr 1fr", FlexDirection::COLUMN, CREATE_FLOWITEM_COUNT);
411 CHECK_RENDERNODE_NULL_VOID(renderNode_);
__anond51a46150502() 412 renderNode_->SetGetTotalCount([]() {
413 return TOTAL_COUNT;
414 });
415 auto itemIndex = renderNode_->GetNextSupplyedIndex();
416 auto targetPos = renderNode_->GetTargetPos();
417 renderNode_->InitialFlowProp();
418 renderNode_->SupplyItems(itemIndex, targetPos);
419 renderNode_->OnDataSourceUpdated(1);
420 EXPECT_EQ(renderNode_->items_.size(), 1);
421 }
422
423 /**
424 * @tc.name: RenderWaterFlowTest_SetTotalCount_001
425 * @tc.desc: Verify that the SetTotalCount function is set to total count.
426 * @tc.type: FUNC
427 * @tc.require: issueI5TFPO
428 */
429 HWTEST_F(RenderWaterFlowTest, RenderWaterFlowTest_SetTotalCount_001, TestSize.Level1)
430 {
431 CreateRenderWaterFlow("1fr 1fr", "1fr 1fr", FlexDirection::COLUMN, CREATE_FLOWITEM_COUNT);
432 CHECK_RENDERNODE_NULL_VOID(renderNode_);
433 EXPECT_EQ(renderNode_->totalCount_, 0);
434 renderNode_->SetTotalCount(0);
435 EXPECT_EQ(renderNode_->totalCount_, 0);
436 renderNode_->SetTotalCount(TOTAL_COUNT);
437 EXPECT_EQ(renderNode_->totalCount_, TOTAL_COUNT);
438 }
439
440 /**
441 * @tc.name: RenderWaterFlowTest_GetEstimatedHeight_001
442 * @tc.desc: Verify that GetEstimatedHeight gets the height of the item layout position in the window.
443 * @tc.type: FUNC
444 * @tc.require: issueI5TFPO
445 */
446 HWTEST_F(RenderWaterFlowTest, RenderWaterFlowTest_GetEstimatedHeight_001, TestSize.Level1)
447 {
448 CreateRenderWaterFlow("1fr 1fr", "1fr 1fr", FlexDirection::COLUMN, CREATE_FLOWITEM_COUNT);
449 CHECK_RENDERNODE_NULL_VOID(renderNode_);
450 renderNode_->mainSideEndPos_.push_back(300.0);
451 renderNode_->mainSideEndPos_.push_back(200.0);
452 renderNode_->crossSideSize_.push_back(450);
453 renderNode_->crossSideSize_.push_back(450);
454 auto estimatedHeight = renderNode_->GetEstimatedHeight();
455 EXPECT_EQ(estimatedHeight, 300);
456 }
457
458 /**
459 * @tc.name: RenderWaterFlowTest_GetEstimatedHeight_002
460 * @tc.desc: Verify that GetEstimatedHeight gets the height of the item layout position outside the viewing window.
461 * @tc.type: FUNC
462 * @tc.require: issueI5TFPO
463 */
464 HWTEST_F(RenderWaterFlowTest, RenderWaterFlowTest_GetEstimatedHeight_002, TestSize.Level1)
465 {
466 CreateRenderWaterFlow("1fr 1fr", "1fr 1fr", FlexDirection::COLUMN, CREATE_FLOWITEM_COUNT);
467 CHECK_RENDERNODE_NULL_VOID(renderNode_);
468 renderNode_->mainSize_ = 10;
469 renderNode_->mainSideEndPos_.push_back(300.0);
470 renderNode_->mainSideEndPos_.push_back(200.0);
471 renderNode_->crossSideSize_.push_back(450);
472 renderNode_->crossSideSize_.push_back(450);
473 auto estimatedHeight = renderNode_->GetEstimatedHeight();
474 EXPECT_EQ(estimatedHeight, 10);
475 }
476
477 /**
478 * @tc.name: RenderWaterFlowTest_ScrollToIndex_001
479 * @tc.desc: Fill in items, and verify that ScrollToIndex finds the specified items outside the window and gets pos.
480 * @tc.type: FUNC
481 * @tc.require: issueI5TFPO
482 */
483 HWTEST_F(RenderWaterFlowTest, RenderWaterFlowTest_ScrollToIndex_001, TestSize.Level1)
484 {
485 CreateRenderWaterFlow("1fr 1fr", "1fr 1fr", FlexDirection::COLUMN, CREATE_FLOWITEM_COUNT);
486 CHECK_RENDERNODE_NULL_VOID(renderNode_);
487 int32_t index = 3;
488 int32_t source = 3;
__anond51a46150602() 489 renderNode_->SetGetTotalCount([]() {
490 return TOTAL_COUNT;
491 });
492 auto itemIndex = renderNode_->GetNextSupplyedIndex();
493 auto targetPos = renderNode_->GetTargetPos();
494 renderNode_->InitialFlowProp();
495 renderNode_->SupplyItems(itemIndex, targetPos);
496 renderNode_->viewportStartPos_ = 1100.0;
497 renderNode_->ScrollToIndex(index, source);
498 auto iter = renderNode_->flowMatrix_.find(index);
499 EXPECT_TRUE(iter != renderNode_->flowMatrix_.end());
500 if (iter != renderNode_->flowMatrix_.end()) {
501 EXPECT_EQ(iter->second.mainPos, 250);
502 }
503 }
504
505 /**
506 * @tc.name: RenderWaterFlowTest_ScrollToIndex_002
507 * @tc.desc: Verify that ScrollToIndex does not find the specified item trigger fill matrix in the layout matrix.
508 * @tc.type: FUNC
509 * @tc.require: issueI5TFPO
510 */
511 HWTEST_F(RenderWaterFlowTest, RenderWaterFlowTest_ScrollToIndex_002, TestSize.Level1)
512 {
513 CreateRenderWaterFlow("1fr 1fr", "1fr 1fr", FlexDirection::COLUMN, CREATE_FLOWITEM_COUNT);
514 CHECK_RENDERNODE_NULL_VOID(renderNode_);
515 int32_t index = 3;
516 int32_t source = 3;
517 renderNode_->InitialFlowProp();
518 renderNode_->viewportStartPos_ = 1100.0;
519 renderNode_->ScrollToIndex(index, source);
520 auto iter = renderNode_->flowMatrix_.find(index);
521 EXPECT_TRUE(iter != renderNode_->flowMatrix_.end());
522 if (iter != renderNode_->flowMatrix_.end()) {
523 EXPECT_EQ(iter->second.mainPos, 250);
524 }
525 }
526
527 /**
528 * @tc.name: RenderWaterFlowTest_ScrollToIndex_002
529 * @tc.desc: Verify that ScrollToIndex does not find the specified item trigger fill matrix in the layout matrix.
530 * @tc.type: FUNC
531 * @tc.require: issueI5TFPO
532 */
533 HWTEST_F(RenderWaterFlowTest, RenderWaterFlowTest_ScrollToIndex_003, TestSize.Level1)
534 {
535 CreateRenderWaterFlow("1fr 1fr", "1fr 1fr", FlexDirection::COLUMN_REVERSE, CREATE_FLOWITEM_COUNT);
536 CHECK_RENDERNODE_NULL_VOID(renderNode_);
537 int32_t index = 3;
538 int32_t source = 3;
539 renderNode_->InitialFlowProp();
540 renderNode_->viewportStartPos_ = 1100.0;
541 renderNode_->ScrollToIndex(index, source);
542 auto iter = renderNode_->flowMatrix_.find(index);
543 EXPECT_TRUE(iter != renderNode_->flowMatrix_.end());
544 if (iter != renderNode_->flowMatrix_.end()) {
545 EXPECT_EQ(iter->second.mainPos, 250);
546 }
547 }
548
549 /**
550 * @tc.name: RenderWaterFlowTest_GetAxis_001
551 * @tc.desc: Verify GetAxis gets the axis direction.
552 * @tc.type: FUNC
553 * @tc.require: issueI5TFPO
554 */
555 HWTEST_F(RenderWaterFlowTest, RenderWaterFlowTest_GetAxis_001, TestSize.Level1)
556 {
557 CHECK_RENDERNODE_NULL_VOID(renderNode_);
558 Axis axis = renderNode_->GetAxis();
559 EXPECT_TRUE(axis == Axis::HORIZONTAL);
560 renderNode_->useScrollable_ = V2::SCROLLABLE::VERTICAL;
561 axis = renderNode_->GetAxis();
562 EXPECT_TRUE(axis == Axis::VERTICAL);
563 }
564
565 /**
566 * @tc.name: RenderWaterFlowTest_GetLastOffset_001
567 * @tc.desc: Verify GetLastOffset gets the last offset.
568 * @tc.type: FUNC
569 * @tc.require: issueI5TFPO
570 */
571 HWTEST_F(RenderWaterFlowTest, RenderWaterFlowTest_GetLastOffset_001, TestSize.Level1)
572 {
573 CHECK_RENDERNODE_NULL_VOID(renderNode_);
574 renderNode_->lastOffset_ = 100.0;
575 EXPECT_TRUE(renderNode_->GetLastOffset().GetX() == 100.0);
576 renderNode_->useScrollable_ = V2::SCROLLABLE::VERTICAL;
577 EXPECT_TRUE(renderNode_->GetLastOffset().GetY() == 100.0);
578 }
579
580 /**
581 * @tc.name: RenderWaterFlowTest_IsAxisScrollable_001
582 * @tc.desc: Verify IsAxisScrollable to determine whether it is scrollable.
583 * @tc.type: FUNC
584 * @tc.require: issueI5TFPO
585 */
586 HWTEST_F(RenderWaterFlowTest, RenderWaterFlowTest_IsAxisScrollable_001, TestSize.Level1)
587 {
588 CreateRenderWaterFlow("1fr 1fr", "1fr 1fr", FlexDirection::COLUMN);
589 CHECK_RENDERNODE_NULL_VOID(renderNode_);
590 auto direction = AxisDirection::UP;
591 renderNode_->reachHead_ = true;
592 EXPECT_FALSE(renderNode_->IsAxisScrollable(direction));
593 }
594
595 /**
596 * @tc.name: RenderWaterFlowTest_IsAxisScrollable_002
597 * @tc.desc: Verify IsAxisScrollable to determine whether it is scrollable.
598 * @tc.type: FUNC
599 * @tc.require: issueI5TFPO
600 */
601 HWTEST_F(RenderWaterFlowTest, RenderWaterFlowTest_IsAxisScrollable_002, TestSize.Level2)
602 {
603 CreateRenderWaterFlow("1fr 1fr", "1fr 1fr", FlexDirection::ROW);
604 CHECK_RENDERNODE_NULL_VOID(renderNode_);
605 auto direction = AxisDirection::LEFT;
606 renderNode_->reachHead_ = true;
607 EXPECT_FALSE(renderNode_->IsAxisScrollable(direction));
608 }
609
610 /**
611 * @tc.name: RenderWaterFlowTest_IsAxisScrollable_003
612 * @tc.desc: Verify IsAxisScrollable to determine whether it is scrollable.
613 * @tc.type: FUNC
614 * @tc.require: issueI5TFPO
615 */
616 HWTEST_F(RenderWaterFlowTest, RenderWaterFlowTest_IsAxisScrollable_003, TestSize.Level2)
617 {
618 CreateRenderWaterFlow("1fr 1fr", "1fr 1fr", FlexDirection::COLUMN_REVERSE);
619 CHECK_RENDERNODE_NULL_VOID(renderNode_);
620 auto direction = AxisDirection::DOWN;
621 renderNode_->reachHead_ = true;
622 EXPECT_FALSE(renderNode_->IsAxisScrollable(direction));
623 }
624
625 /**
626 * @tc.name: RenderWaterFlowTest_IsAxisScrollable_004
627 * @tc.desc: Verify IsAxisScrollable to determine whether it is scrollable.
628 * @tc.type: FUNC
629 * @tc.require: issueI5TFPO
630 */
631 HWTEST_F(RenderWaterFlowTest, RenderWaterFlowTest_IsAxisScrollable_004, TestSize.Level2)
632 {
633 CreateRenderWaterFlow("1fr 1fr", "1fr 1fr", FlexDirection::ROW_REVERSE);
634 CHECK_RENDERNODE_NULL_VOID(renderNode_);
635 auto direction = AxisDirection::RIGHT;
636 renderNode_->reachHead_ = true;
637 EXPECT_FALSE(renderNode_->IsAxisScrollable(direction));
638 }
639
640 /**
641 * @tc.name: RenderWaterFlowTest_IsAxisScrollable_005
642 * @tc.desc: Verify IsAxisScrollable to determine whether it is scrollable.
643 * @tc.type: FUNC
644 * @tc.require: issueI5TFPO
645 */
646 HWTEST_F(RenderWaterFlowTest, RenderWaterFlowTest_IsAxisScrollable_005, TestSize.Level2)
647 {
648 CreateRenderWaterFlow("1fr 1fr", "1fr 1fr", FlexDirection::ROW_REVERSE);
649 CHECK_RENDERNODE_NULL_VOID(renderNode_);
650 auto direction = AxisDirection::NONE;
651 EXPECT_FALSE(renderNode_->IsAxisScrollable(direction));
652 }
653
654 /**
655 * @tc.name: RenderWaterFlowTest_CheckAxisNode_001
656 * @tc.desc: Verify that the CheckAxisNode is converted to a weak pointer.
657 * @tc.type: FUNC
658 * @tc.require: issueI5TFPO
659 */
660 HWTEST_F(RenderWaterFlowTest, RenderWaterFlowTest_CheckAxisNode_001, TestSize.Level1)
661 {
662 CreateRenderWaterFlow("1fr 1fr", "1fr 1fr");
663 CHECK_RENDERNODE_NULL_VOID(renderNode_);
664 EXPECT_TRUE(renderNode_->CheckAxisNode().Upgrade() != nullptr);
665 }
666
667 /**
668 * @tc.name: RenderWaterFlowTest_OnChildAdded_001
669 * @tc.desc: Verify that OnChildAdded sets the location coordinates of the item.
670 * @tc.type: FUNC
671 * @tc.require: issueI5TFPO
672 */
673 HWTEST_F(RenderWaterFlowTest, RenderWaterFlowTest_OnChildAdded_001, TestSize.Level1)
674 {
675 CreateRenderWaterFlow("1fr 1fr", "1fr 1fr", FlexDirection::COLUMN);
676 CHECK_RENDERNODE_NULL_VOID(renderNode_);
677 auto item = WaterFlowTestUtils::CreateRenderItem(mockContext_);
678 CHECK_RENDERNODE_NULL_VOID(item);
679 renderNode_->cacheSize_ = 200.0;
680 renderNode_->OnChildAdded(item);
681 EXPECT_EQ(item->GetPosition().GetX(), renderNode_->crossSize_ / CENTER_POINT);
682 EXPECT_EQ(item->GetPosition().GetY(), renderNode_->cacheSize_ + renderNode_->mainSize_);
683 }
684
685 /**
686 * @tc.name: RenderWaterFlowTest_OnChildAdded_002
687 * @tc.desc: Verify that OnChildAdded sets the location coordinates of the item.
688 * @tc.type: FUNC
689 * @tc.require: issueI5TFPO
690 */
691 HWTEST_F(RenderWaterFlowTest, RenderWaterFlowTest_OnChildAdded_002, TestSize.Level1)
692 {
693 CreateRenderWaterFlow("1fr 1fr", "1fr 1fr", FlexDirection::ROW);
694 CHECK_RENDERNODE_NULL_VOID(renderNode_);
695 auto item = WaterFlowTestUtils::CreateRenderItem(mockContext_);
696 CHECK_RENDERNODE_NULL_VOID(item);
697 renderNode_->cacheSize_ = 200.0;
698 renderNode_->OnChildAdded(item);
699 EXPECT_EQ(item->GetPosition().GetX(), renderNode_->cacheSize_ + renderNode_->mainSize_);
700 EXPECT_EQ(item->GetPosition().GetY(), renderNode_->crossSize_ / CENTER_POINT);
701 }
702
703 /**
704 * @tc.name: RenderWaterFlowTest_OnChildAdded_003
705 * @tc.desc: Verify that OnChildAdded sets the location coordinates of the item.
706 * @tc.type: FUNC
707 * @tc.require: issueI5TFPO
708 */
709 HWTEST_F(RenderWaterFlowTest, RenderWaterFlowTest_OnChildAdded_003, TestSize.Level1)
710 {
711 CreateRenderWaterFlow("1fr 1fr", "1fr 1fr", FlexDirection::COLUMN_REVERSE);
712 CHECK_RENDERNODE_NULL_VOID(renderNode_);
713 auto item = WaterFlowTestUtils::CreateRenderItem(mockContext_);
714 CHECK_RENDERNODE_NULL_VOID(item);
715 renderNode_->cacheSize_ = 200.0;
716 renderNode_->OnChildAdded(item);
717 EXPECT_EQ(item->GetPosition().GetX(), renderNode_->crossSize_ / CENTER_POINT);
718 EXPECT_EQ(item->GetPosition().GetY(), START_POS - renderNode_->cacheSize_);
719 }
720
721 /**
722 * @tc.name: RenderWaterFlowTest_OnChildAdded_004
723 * @tc.desc: Verify that OnChildAdded sets the location coordinates of the item.
724 * @tc.type: FUNC
725 * @tc.require: issueI5TFPO
726 */
727 HWTEST_F(RenderWaterFlowTest, RenderWaterFlowTest_OnChildAdded_004, TestSize.Level1)
728 {
729 CreateRenderWaterFlow("1fr 1fr", "1fr 1fr", FlexDirection::ROW_REVERSE);
730 CHECK_RENDERNODE_NULL_VOID(renderNode_);
731 auto item = WaterFlowTestUtils::CreateRenderItem(mockContext_);
732 CHECK_RENDERNODE_NULL_VOID(item);
733 renderNode_->cacheSize_ = 200.0;
734 renderNode_->OnChildAdded(item);
735 EXPECT_EQ(item->GetPosition().GetX(), START_POS - renderNode_->cacheSize_);
736 EXPECT_EQ(item->GetPosition().GetY(), renderNode_->crossSize_ / CENTER_POINT);
737 }
738
739 /**
740 * @tc.name: RenderWaterFlowTest_HandleAxisEvent_001
741 * @tc.desc: Verify the position offset information of the HandleAxisEvent setting scroll.
742 * @tc.type: FUNC
743 * @tc.require: issueI5TFPO
744 */
745 HWTEST_F(RenderWaterFlowTest, RenderWaterFlowTest_HandleAxisEvent_001, TestSize.Level1)
746 {
747 CHECK_RENDERNODE_NULL_VOID(renderNode_);
748 renderNode_->viewportStartPos_ = START_POS;
749 AxisEvent axisEvent;
750 axisEvent.verticalAxis = 0.0;
751 renderNode_->HandleAxisEvent(axisEvent);
752 EXPECT_EQ(renderNode_->viewportStartPos_, 0.0);
753 axisEvent.horizontalAxis = 0.0;
754 renderNode_->HandleAxisEvent(axisEvent);
755 EXPECT_EQ(renderNode_->viewportStartPos_, 0.0);
756 }
757
758 /**
759 * @tc.name: RenderWaterFlowTest_OnPredictLayout_001
760 * @tc.desc: Verify that the OnPredictLayout function fills the item matrix.
761 * @tc.type: FUNC
762 * @tc.require: issueI5TFPO
763 */
764 HWTEST_F(RenderWaterFlowTest, RenderWaterFlowTest_OnPredictLayout_001, TestSize.Level1)
765 {
766 CreateRenderWaterFlow("1fr 1fr", "1fr 1fr", FlexDirection::COLUMN);
767 CHECK_RENDERNODE_NULL_VOID(renderNode_);
__anond51a46150702() 768 renderNode_->SetGetTotalCount([]() {
769 return TOTAL_COUNT;
770 });
771 renderNode_->InitialFlowProp();
772 renderNode_->OnPredictLayout(4 * MILLISEC_TO_NANOSEC / MICROSEC_TO_NANOSEC);
773 EXPECT_TRUE(!renderNode_->cacheItems_.empty());
774 EXPECT_EQ(renderNode_->dVPStartPosBackup_, renderNode_->viewportStartPos_);
775 EXPECT_EQ(renderNode_->totalCountBack_, TOTAL_COUNT);
776 }
777
778 /**
779 * @tc.name: RenderWaterFlowTest_OnPredictLayout_002
780 * @tc.desc: Verify that the OnPredictLayout function does not fill the item matrix.
781 * @tc.type: FUNC
782 * @tc.require: issueI5TFPO
783 */
784 HWTEST_F(RenderWaterFlowTest, RenderWaterFlowTest_OnPredictLayout_002, TestSize.Level2)
785 {
786 CreateRenderWaterFlow("1fr 1fr", "1fr 1fr", FlexDirection::COLUMN);
787 CHECK_RENDERNODE_NULL_VOID(renderNode_);
__anond51a46150802() 788 renderNode_->SetGetTotalCount([]() {
789 return TOTAL_COUNT;
790 });
791 int64_t deadline = 1;
792 renderNode_->InitialFlowProp();
793 renderNode_->OnPredictLayout(deadline);
794 EXPECT_TRUE(renderNode_->cacheItems_.empty());
795 }
796
797 /**
798 * @tc.name: RenderWaterFlowTest_RequestWaterFlowFooter_001
799 * @tc.desc: Verify that the RequestWaterFlowFooter function requests to create a rendernode node on the element.
800 * @tc.type: FUNC
801 * @tc.require: issueI5TFPO
802 */
803 HWTEST_F(RenderWaterFlowTest, RenderWaterFlowTest_RequestWaterFlowFooter_001, TestSize.Level1)
804 {
805 CreateRenderWaterFlow("1fr 1fr", "1fr 1fr", FlexDirection::ROW_REVERSE);
806 CHECK_RENDERNODE_NULL_VOID(renderNode_);
807 auto waterflowElement = AceType::MakeRefPtr<MockWaterFlowElement>();
808 CHECK_RENDERNODE_NULL_VOID(waterflowElement);
809 waterflowElement->SetContext(mockContext_);
810 WeakPtr<V2::WaterFlowItemGenerator> waterFlowItemGenerator(waterflowElement);
811 renderNode_->RegisterItemGenerator(std::move(waterFlowItemGenerator));
812 renderNode_->RequestWaterFlowFooter();
813 EXPECT_TRUE(renderNode_->footer_ != nullptr);
814 EXPECT_EQ(renderNode_->GetChildren().size(), 1);
815 EXPECT_EQ(renderNode_->footerMaxSize_.Width(), ITEM_WIDTH);
816 EXPECT_EQ(renderNode_->footerMaxSize_.Height(), ITEM_HEIGHT);
817 }
818
819 /**
820 * @tc.name: RenderWaterFlowTest_RequestWaterFlowFooter_002
821 * @tc.desc: Verify that the RequestWaterFlowFooter function requests to create an illegal rendernode node
822 * on the element.
823 * @tc.type: FUNC
824 * @tc.require: issueI5TFPO
825 */
826 HWTEST_F(RenderWaterFlowTest, RenderWaterFlowTest_RequestWaterFlowFooter_002, TestSize.Level2)
827 {
828 CreateRenderWaterFlow("1fr 1fr", "1fr 1fr", FlexDirection::ROW_REVERSE);
829 CHECK_RENDERNODE_NULL_VOID(renderNode_);
830 auto waterflowElement = AceType::MakeRefPtr<MockWaterFlowElement>();
831 CHECK_RENDERNODE_NULL_VOID(waterflowElement);
832 WeakPtr<V2::WaterFlowItemGenerator> waterFlowItemGenerator(waterflowElement);
833 renderNode_->RegisterItemGenerator(std::move(waterFlowItemGenerator));
834 renderNode_->RequestWaterFlowFooter();
835 EXPECT_TRUE(renderNode_->footer_ == nullptr);
836 EXPECT_TRUE(renderNode_->GetChildren().empty());
837 }
838
839 /**
840 * @tc.name: RenderWaterFlowTest_PerformLayout_001
841 * @tc.desc: Verify the layout information of each item in the column direction.
842 * @tc.type: FUNC
843 * @tc.require: issueI5TFPO
844 */
845 HWTEST_F(RenderWaterFlowTest, RenderWaterFlowTest_PerformLayout_001, TestSize.Level1)
846 {
847 CreateRenderWaterFlow("1fr", "1fr", FlexDirection::COLUMN);
848 CHECK_RENDERNODE_NULL_VOID(renderNode_);
849 renderNode_->PerformLayout();
850 EXPECT_EQ(renderNode_->crossSideSize_.size(), 1);
851 size_t index = 0;
852 for (const auto& item : renderNode_->GetChildren()) {
853 EXPECT_TRUE(item->GetPosition() == Offset(
854 START_POS, index * (ITEM_HEIGHT + WaterFlowTestUtils::rowGap.Value())));
855 EXPECT_TRUE(item->GetLayoutSize() == Size(renderNode_->crossSize_, ITEM_HEIGHT));
856 index++;
857 }
858 }
859
860 /**
861 * @tc.name: RenderWaterFlowTest_PerformLayout_002
862 * @tc.desc: Verify the layout information of each item in the column direction.
863 * @tc.type: FUNC
864 * @tc.require: issueI5TFPO
865 */
866 HWTEST_F(RenderWaterFlowTest, RenderWaterFlowTest_PerformLayout_002, TestSize.Level1)
867 {
868 CreateRenderWaterFlow("1fr 1fr", "1fr 1fr", FlexDirection::COLUMN);
869 CHECK_RENDERNODE_NULL_VOID(renderNode_);
870 renderNode_->PerformLayout();
871 EXPECT_EQ(renderNode_->crossSideSize_.size(), 2);
872 size_t index = 0;
873 for (const auto& item : renderNode_->GetChildren()) {
874 EXPECT_TRUE(item->GetPosition() == Offset(
875 index % 2 * 550, index / 2 * (ITEM_HEIGHT + WaterFlowTestUtils::rowGap.Value())));
876 EXPECT_TRUE(item->GetLayoutSize() == Size(
877 (renderNode_->crossSize_ - renderNode_->crossGap_) / CENTER_POINT, ITEM_HEIGHT));
878 index++;
879 }
880 }
881
882 /**
883 * @tc.name: RenderWaterFlowTest_PerformLayout_003
884 * @tc.desc: Verify the layout information of each item in the row direction.
885 * @tc.type: FUNC
886 * @tc.require: issueI5TFPO
887 */
888 HWTEST_F(RenderWaterFlowTest, RenderWaterFlowTest_PerformLayout_003, TestSize.Level1)
889 {
890 CreateRenderWaterFlow("1fr", "1fr", FlexDirection::ROW);
891 CHECK_RENDERNODE_NULL_VOID(renderNode_);
892 renderNode_->PerformLayout();
893 EXPECT_EQ(renderNode_->crossSideSize_.size(), 1);
894 size_t index = 0;
895 for (const auto& item : renderNode_->GetChildren()) {
896 EXPECT_TRUE(item->GetPosition() == Offset(
897 index * (ITEM_WIDTH + WaterFlowTestUtils::columnsGap.Value()), START_POS));
898 EXPECT_TRUE(item->GetLayoutSize() == Size(ITEM_WIDTH, renderNode_->crossSize_));
899 index++;
900 }
901 }
902
903 /**
904 * @tc.name: RenderWaterFlowTest_PerformLayout_004
905 * @tc.desc: Verify the layout information of each item in the row direction.
906 * @tc.type: FUNC
907 * @tc.require: issueI5TFPO
908 */
909 HWTEST_F(RenderWaterFlowTest, RenderWaterFlowTest_PerformLayout_004, TestSize.Level1)
910 {
911 CreateRenderWaterFlow("1fr 1fr", "1fr 1fr", FlexDirection::ROW);
912 CHECK_RENDERNODE_NULL_VOID(renderNode_);
913 renderNode_->PerformLayout();
914 EXPECT_EQ(renderNode_->crossSideSize_.size(), 2);
915 size_t index = 0;
916 for (const auto& item : renderNode_->GetChildren()) {
917 EXPECT_TRUE(item->GetPosition() == Offset(
918 index / 2 * (ITEM_WIDTH + WaterFlowTestUtils::columnsGap.Value()), index % 2 * 550));
919 EXPECT_TRUE(item->GetLayoutSize() == Size(
920 ITEM_WIDTH, (renderNode_->crossSize_ - renderNode_->crossGap_) / CENTER_POINT));
921 index++;
922 }
923 }
924
925 /**
926 * @tc.name: RenderWaterFlowTest_PerformLayout_005
927 * @tc.desc: Verify the layout information of each item in the column_reverse direction.
928 * @tc.type: FUNC
929 * @tc.require: issueI5TFPO
930 */
931 HWTEST_F(RenderWaterFlowTest, RenderWaterFlowTest_PerformLayout_005, TestSize.Level1)
932 {
933 CreateRenderWaterFlow("1fr", "1fr", FlexDirection::COLUMN_REVERSE);
934 CHECK_RENDERNODE_NULL_VOID(renderNode_);
935 renderNode_->PerformLayout();
936 EXPECT_EQ(renderNode_->crossSideSize_.size(), 1);
937 size_t index = 0;
938 for (const auto& item : renderNode_->GetChildren()) {
939 if (index < renderNode_->crossSideSize_.size()) {
940 EXPECT_TRUE(item->GetPosition() == Offset(START_POS, renderNode_->mainSize_ - ITEM_HEIGHT));
941 } else {
942 EXPECT_TRUE(item->GetPosition() == Offset(START_POS, (renderNode_->mainSize_ - ITEM_HEIGHT) -
943 index * (ITEM_HEIGHT + WaterFlowTestUtils::rowGap.Value())));
944 }
945 EXPECT_TRUE(item->GetLayoutSize() == Size(renderNode_->crossSize_, ITEM_HEIGHT));
946 index++;
947 }
948 }
949
950 /**
951 * @tc.name: RenderWaterFlowTest_PerformLayout_006
952 * @tc.desc: Verify the layout information of each item in the column_reverse direction.
953 * @tc.type: FUNC
954 * @tc.require: issueI5TFPO
955 */
956 HWTEST_F(RenderWaterFlowTest, RenderWaterFlowTest_PerformLayout_006, TestSize.Level1)
957 {
958 CreateRenderWaterFlow("1fr 1fr", "1fr 1fr", FlexDirection::COLUMN_REVERSE);
959 CHECK_RENDERNODE_NULL_VOID(renderNode_);
960 renderNode_->PerformLayout();
961 EXPECT_EQ(renderNode_->crossSideSize_.size(), 2);
962 size_t index = 0;
963 for (const auto& item : renderNode_->GetChildren()) {
964 if (index < renderNode_->crossSideSize_.size()) {
965 EXPECT_TRUE(item->GetPosition() == Offset(index % 2 * 550, renderNode_->mainSize_ - ITEM_HEIGHT));
966 } else {
967 EXPECT_TRUE(item->GetPosition() == Offset(index % 2 * 550, renderNode_->mainSize_ - ITEM_HEIGHT -
968 (index / renderNode_->crossSideSize_.size()) * (ITEM_HEIGHT + WaterFlowTestUtils::rowGap.Value())));
969 }
970 EXPECT_TRUE(item->GetLayoutSize() == Size((renderNode_->crossSize_ - renderNode_->crossGap_) / CENTER_POINT,
971 ITEM_HEIGHT));
972 index++;
973 }
974 }
975
976 /**
977 * @tc.name: RenderWaterFlowTest_PerformLayout_007
978 * @tc.desc: Verify the layout information of each item in the row_reverse direction.
979 * @tc.type: FUNC
980 * @tc.require: issueI5TFPO
981 */
982 HWTEST_F(RenderWaterFlowTest, RenderWaterFlowTest_PerformLayout_007, TestSize.Level1)
983 {
984 CreateRenderWaterFlow("1fr", "1fr", FlexDirection::ROW_REVERSE);
985 CHECK_RENDERNODE_NULL_VOID(renderNode_);
986 renderNode_->PerformLayout();
987 EXPECT_EQ(renderNode_->crossSideSize_.size(), 1);
988 size_t index = 0;
989 for (const auto& item : renderNode_->GetChildren()) {
990 if (index < renderNode_->crossSideSize_.size()) {
991 EXPECT_TRUE(item->GetPosition() == Offset((renderNode_->mainSize_) - ITEM_WIDTH, START_POS));
992 } else {
993 EXPECT_TRUE(item->GetPosition() == Offset((renderNode_->mainSize_) - ITEM_WIDTH -
994 index * (ITEM_WIDTH + WaterFlowTestUtils::columnsGap.Value()), START_POS));
995 }
996 EXPECT_TRUE(item->GetLayoutSize() == Size(ITEM_WIDTH, renderNode_->crossSize_));
997 index++;
998 }
999 }
1000
1001 /**
1002 * @tc.name: RenderWaterFlowTest_PerformLayout_008
1003 * @tc.desc: Verify the layout information of each item in the row_reverse direction.
1004 * @tc.type: FUNC
1005 * @tc.require: issueI5TFPO
1006 */
1007 HWTEST_F(RenderWaterFlowTest, RenderWaterFlowTest_PerformLayout_008, TestSize.Level1)
1008 {
1009 CreateRenderWaterFlow("1fr 1fr", "1fr 1fr", FlexDirection::ROW_REVERSE);
1010 CHECK_RENDERNODE_NULL_VOID(renderNode_);
1011 renderNode_->PerformLayout();
1012 EXPECT_EQ(renderNode_->crossSideSize_.size(), 2);
1013 size_t index = 0;
1014 for (const auto& item : renderNode_->GetChildren()) {
1015 if (index < renderNode_->crossSideSize_.size()) {
1016 EXPECT_TRUE(item->GetPosition() == Offset(renderNode_->mainSize_ - ITEM_WIDTH, index % 2 * 550));
1017 } else {
1018 EXPECT_TRUE(item->GetPosition() == Offset((renderNode_->mainSize_) - ITEM_WIDTH -
1019 (index / renderNode_->crossSideSize_.size()) * (ITEM_WIDTH + WaterFlowTestUtils::columnsGap.Value()),
1020 index % 2 * 550));
1021 }
1022 EXPECT_TRUE(item->GetLayoutSize() == Size(ITEM_WIDTH,
1023 (renderNode_->crossSize_ - renderNode_->crossGap_) / CENTER_POINT));
1024 index++;
1025 }
1026 }
1027
1028 /**
1029 * @tc.name: RenderWaterFlowTest_DoJump_001
1030 * @tc.desc: Verify the function that jump the position to be set by parameters.
1031 * @tc.type: FUNC
1032 * @tc.require: issueI5TFPO
1033 */
1034 HWTEST_F(RenderWaterFlowTest, RenderWaterFlowTest_DoJump_001, TestSize.Level1)
1035 {
1036 CreateRenderWaterFlow("1fr 1fr 1fr", "1fr 1fr 1fr", FlexDirection::COLUMN);
1037
1038 EXPECT_TRUE(renderNode_ != nullptr);
1039 double mainSizeOffset = 20.0;
1040 renderNode_->reachHead_ = false;
1041 renderNode_->reachTail_ = false;
1042 renderNode_->DoJump(mainSizeOffset, SCROLL_FROM_UPDATE);
1043 EXPECT_EQ(renderNode_->viewportStartPos_, mainSizeOffset);
1044 }
1045
1046 /**
1047 * @tc.name: RenderWaterFlowTest_SetScrollBarCallback_001
1048 * @tc.desc: Verify the function that set the callbacks of scroll bar.
1049 * @tc.type: FUNC
1050 * @tc.require: issueI5TFPO
1051 */
1052 HWTEST_F(RenderWaterFlowTest, RenderWaterFlowTest_SetScrollBarCallback_001, TestSize.Level1)
1053 {
1054 CreateRenderWaterFlow("1fr", "1fr", FlexDirection::COLUMN);
1055
1056 EXPECT_TRUE(renderNode_ != nullptr);
1057 EXPECT_TRUE(renderNode_->scrollBar_ != nullptr);
1058 EXPECT_TRUE(renderNode_->scrollBar_->barController_ != nullptr);
1059 renderNode_->SetScrollBarCallback();
1060 EXPECT_TRUE(renderNode_->scrollBar_->barController_->callback_ != nullptr);
1061 EXPECT_TRUE(renderNode_->scrollBar_->barController_->barEndCallback_ != nullptr);
1062 EXPECT_TRUE(renderNode_->scrollBar_->barController_->scrollEndCallback_ != nullptr);
1063 }
1064
1065 /**
1066 * @tc.name: RenderWaterFlowTest_InitScrollBarProxy_001
1067 * @tc.desc: Verify the function that initialize the callbacks of scroll bar proxy.
1068 * @tc.type: FUNC
1069 * @tc.require: issueI5TFPO
1070 */
1071 HWTEST_F(RenderWaterFlowTest, RenderWaterFlowTest_InitScrollBarProxy_001, TestSize.Level1)
1072 {
1073 CreateRenderWaterFlow("1fr 1fr 1fr", "1fr 1fr 1fr", FlexDirection::COLUMN);
1074
1075 EXPECT_TRUE(renderNode_ != nullptr);
1076 EXPECT_TRUE(renderNode_->scrollBarProxy_ != nullptr);
1077 renderNode_->InitScrollBarProxy();
1078 EXPECT_TRUE(!renderNode_->scrollBarProxy_->scrollableNodes_.empty());
1079 EXPECT_EQ(renderNode_->scrollBarProxy_->scrollableNodes_.size(), 1);
1080 }
1081
1082 /**
1083 * @tc.name: RenderWaterFlowTest_InitScrollBarProxy_002
1084 * @tc.desc: Verify the function that initialize the callbacks of scroll bar proxy.
1085 * @tc.type: FUNC
1086 * @tc.require: issueI5TFPO
1087 */
1088 HWTEST_F(RenderWaterFlowTest, RenderWaterFlowTest_InitScrollBarProxy_002, TestSize.Level1)
1089 {
1090 CreateRenderWaterFlow("1fr 1fr 1fr", "1fr 1fr 1fr", FlexDirection::COLUMN);
1091
1092 EXPECT_TRUE(renderNode_ != nullptr);
1093 renderNode_->scrollBarProxy_ = nullptr;
1094 renderNode_->InitScrollBarProxy();
1095 EXPECT_TRUE(renderNode_->scrollBarProxy_ == nullptr);
1096 }
1097
1098 /**
1099 * @tc.name: RenderWaterFlowTest_InitScrollBar_001
1100 * @tc.desc: Verify the function that initialize the scroll bar of waterflow.
1101 * @tc.type: FUNC
1102 * @tc.require: issueI5TFPO
1103 */
1104 HWTEST_F(RenderWaterFlowTest, RenderWaterFlowTest_InitScrollBar_001, TestSize.Level1)
1105 {
1106 EXPECT_TRUE(renderNode_ != nullptr);
1107 auto component = WaterFlowTestUtils::CreateComponent("1fr 1fr", "1fr 1fr", FlexDirection::COLUMN);
1108 auto waterflowComponent = AceType::DynamicCast<WaterFlowComponent>(component);
1109 CHECK_RENDERNODE_NULL_VOID(waterflowComponent);
1110 waterflowComponent->SetScrollBarDisplayMode(DisplayMode::OFF);
1111 renderNode_->component_ = waterflowComponent;
1112 EXPECT_TRUE(renderNode_->component_ != nullptr);
1113 CHECK_RENDERNODE_NULL_VOID(renderNode_->component_ != nullptr);
1114 renderNode_->component_->SetController(nullptr);
1115 renderNode_->InitScrollBar();
1116 EXPECT_TRUE(renderNode_->component_->displayMode_ == DisplayMode::OFF);
1117 }
1118
1119 /**
1120 * @tc.name: RenderWaterFlowTest_InitScrollBar_003
1121 * @tc.desc: Verify the function that initialize the scroll bar of waterflow.
1122 * @tc.type: FUNC
1123 * @tc.require: issueI5TFPO
1124 */
1125 HWTEST_F(RenderWaterFlowTest, RenderWaterFlowTest_InitScrollBar_002, TestSize.Level1)
1126 {
1127 EXPECT_TRUE(renderNode_ != nullptr);
1128 renderNode_->component_ = nullptr;
1129 renderNode_->InitScrollBar();
1130 EXPECT_TRUE(renderNode_->scrollBar_ == nullptr);
1131 }
1132
1133 /**
1134 * @tc.name: RenderWaterFlowTest_InitScrollBar_004
1135 * @tc.desc: Verify the function that initialize the scroll bar of waterflow.
1136 * @tc.type: FUNC
1137 * @tc.require: issueI5TFPO
1138 */
1139 HWTEST_F(RenderWaterFlowTest, RenderWaterFlowTest_InitScrollBar_003, TestSize.Level1)
1140 {
1141 EXPECT_TRUE(renderNode_ != nullptr);
1142 renderNode_->Attach(nullptr);
1143 renderNode_->InitScrollBar();
1144 EXPECT_TRUE(renderNode_->scrollBar_ == nullptr);
1145 }
1146
1147 /**
1148 * @tc.name: RenderWaterFlowTest_InitScrollBar_005
1149 * @tc.desc: Verify the function that initialize the scroll bar of waterflow.
1150 * @tc.type: FUNC
1151 * @tc.require: issueI5TFPO
1152 */
1153 HWTEST_F(RenderWaterFlowTest, RenderWaterFlowTest_InitScrollBar_004, TestSize.Level1)
1154 {
1155 CreateRenderWaterFlow("1fr 1fr 1fr", "1fr 1fr 1fr", FlexDirection::COLUMN);
1156
1157 EXPECT_TRUE(renderNode_ != nullptr);
1158 renderNode_->InitScrollBar();
1159 EXPECT_TRUE(renderNode_->scrollBar_ != nullptr);
1160 EXPECT_TRUE(renderNode_->scrollBar_->GetPositionMode() == PositionMode::RIGHT);
1161 }
1162
1163 /**
1164 * @tc.name: RenderWaterFlowTest_InitScrollBar_005
1165 * @tc.desc: Verify the function that initialize the scroll bar of waterflow.
1166 * @tc.type: FUNC
1167 * @tc.require: issueI5TFPO
1168 */
1169 HWTEST_F(RenderWaterFlowTest, RenderWaterFlowTest_InitScrollBar_005, TestSize.Level1)
1170 {
1171 CreateRenderWaterFlow("1fr 1fr 1fr", "1fr 1fr 1fr", FlexDirection::ROW);
1172 EXPECT_TRUE(renderNode_ != nullptr);
1173 EXPECT_TRUE(renderNode_->scrollBar_ != nullptr);
1174 EXPECT_TRUE(renderNode_->scrollBar_->GetPositionMode() == PositionMode::BOTTOM);
1175 }
1176
1177 /**
1178 * @tc.name: RenderWaterFlowTest_DeleteItems_001
1179 * @tc.desc: Verify the function that delete items by index
1180 * @tc.type: FUNC
1181 * @tc.require: issueI5TFPO
1182 */
1183 HWTEST_F(RenderWaterFlowTest, RenderWaterFlowTest_DeleteItems_001, TestSize.Level1)
1184 {
1185 CreateRenderWaterFlow("1fr 1fr 1fr", "1fr 1fr 1fr", FlexDirection::COLUMN, CREATE_FLOWITEM_COUNT);
1186 EXPECT_TRUE(renderNode_ != nullptr);
1187
1188 int size = renderNode_->items_.size();
__anond51a46150902(int32_t index) 1189 renderNode_->SetDeleteChildByIndex([](int32_t index) {});
1190 renderNode_->DeleteItems(START_INDEX);
1191 EXPECT_EQ(renderNode_->items_.size(), (size - 1));
1192 }
1193
1194 /**
1195 * @tc.name: RenderWaterFlowTest_DeleteItems_002
1196 * @tc.desc: Verify the function that delete items by index
1197 * @tc.type: FUNC
1198 * @tc.require: issueI5TFPO
1199 */
1200 HWTEST_F(RenderWaterFlowTest, RenderWaterFlowTest_DeleteItems_002, TestSize.Level2)
1201 {
1202 CreateRenderWaterFlow("1fr 1fr 1fr", "1fr 1fr 1fr", FlexDirection::COLUMN);
1203 EXPECT_TRUE(renderNode_ != nullptr);
1204 renderNode_->deleteChildByIndex_ = nullptr;
1205 EXPECT_TRUE(renderNode_->items_.empty());
1206 renderNode_->DeleteItems(START_INDEX);
1207 EXPECT_TRUE(renderNode_->items_.empty());
1208 }
1209
1210 /**
1211 * @tc.name: RenderWaterFlowTest_DeleteItems_003
1212 * @tc.desc: Verify the function that delete items by index
1213 * @tc.type: FUNC
1214 * @tc.require: issueI5TFPO
1215 */
1216 HWTEST_F(RenderWaterFlowTest, RenderWaterFlowTest_DeleteItems_003, TestSize.Level2)
1217 {
1218 CreateRenderWaterFlow("1fr 1fr 1fr", "1fr 1fr 1fr", FlexDirection::COLUMN);
1219 EXPECT_TRUE(renderNode_ != nullptr);
__anond51a46150a02(int32_t index) 1220 renderNode_->SetDeleteChildByIndex([](int32_t index) {});
1221 EXPECT_TRUE(renderNode_->items_.empty());
1222 renderNode_->DeleteItems(START_INDEX);
1223 EXPECT_TRUE(renderNode_->items_.empty());
1224 }
1225
1226 /**
1227 * @tc.name: RenderWaterFlowTest_DealCache_001
1228 * @tc.desc: Verify the function that delete items which be out of cache area.
1229 * @tc.type: FUNC
1230 * @tc.require: issueI5TFPO
1231 */
1232 HWTEST_F(RenderWaterFlowTest, RenderWaterFlowTest_DealCache_001, TestSize.Level1)
1233 {
1234 CreateRenderWaterFlow("1fr 1fr 1fr", "1fr 1fr 1fr", FlexDirection::COLUMN, CREATE_FLOWITEM_MAX_COUNT);
1235 EXPECT_TRUE(renderNode_ != nullptr);
1236 renderNode_->viewportStartPos_ = 0;
1237 renderNode_->cacheSize_ = 0;
1238 renderNode_->mainSize_ = 0;
1239 auto size = renderNode_->items_.size();
1240 EXPECT_TRUE(size == CREATE_FLOWITEM_MAX_COUNT);
1241 renderNode_->DealCache();
1242 EXPECT_EQ(renderNode_->items_.size(), size);
1243 }
1244
1245 /**
1246 * @tc.name: RenderWaterFlowTest_DealCache_002
1247 * @tc.desc: Verify the function that delete items which be out of cache area.
1248 * @tc.type: FUNC
1249 * @tc.require: issueI5TFPO
1250 */
1251 HWTEST_F(RenderWaterFlowTest, RenderWaterFlowTest_DealCache_002, TestSize.Level1)
1252 {
1253 CreateRenderWaterFlow("1fr 1fr 1fr", "1fr 1fr 1fr", FlexDirection::ROW, CREATE_FLOWITEM_MAX_COUNT);
1254 EXPECT_TRUE(renderNode_ != nullptr);
1255 renderNode_->viewportStartPos_ = 0;
1256 renderNode_->cacheSize_ = 0;
1257 renderNode_->mainSize_ = 0;
1258 auto size = renderNode_->items_.size();
1259 EXPECT_EQ(CREATE_FLOWITEM_MAX_COUNT, size);
1260 renderNode_->DealCache();
1261 EXPECT_EQ(renderNode_->items_.size(), size);
1262 }
1263
1264 /**
1265 * @tc.name: RenderWaterFlowTest_DealCache_003
1266 * @tc.desc: Verify the function that delete items which be out of cache area.
1267 * @tc.type: FUNC
1268 * @tc.require: issueI5TFPO
1269 */
1270 HWTEST_F(RenderWaterFlowTest, RenderWaterFlowTest_DealCache_003, TestSize.Level1)
1271 {
1272 CreateRenderWaterFlow("1fr 1fr 1fr", "1fr 1fr 1fr", FlexDirection::COLUMN_REVERSE, CREATE_FLOWITEM_MAX_COUNT);
1273 EXPECT_TRUE(renderNode_ != nullptr);
1274 renderNode_->viewportStartPos_ = 0;
1275 renderNode_->cacheSize_ = 0;
1276 renderNode_->mainSize_ = 0;
1277 auto size = renderNode_->items_.size();
1278 EXPECT_EQ(CREATE_FLOWITEM_MAX_COUNT, size);
1279 renderNode_->DealCache();
1280 EXPECT_EQ(renderNode_->items_.size(), size);
1281 }
1282
1283 /**
1284 * @tc.name: RenderWaterFlowTest_DealCache_004
1285 * @tc.desc: Verify the function that delete items which be out of cache area.
1286 * @tc.type: FUNC
1287 * @tc.require: issueI5TFPO
1288 */
1289 HWTEST_F(RenderWaterFlowTest, RenderWaterFlowTest_DealCache_004, TestSize.Level1)
1290 {
1291 CreateRenderWaterFlow("1fr 1fr 1fr", "1fr 1fr 1fr", FlexDirection::ROW_REVERSE, CREATE_FLOWITEM_MAX_COUNT);
1292 EXPECT_TRUE(renderNode_ != nullptr);
1293 renderNode_->viewportStartPos_ = 0;
1294 renderNode_->cacheSize_ = 0;
1295 renderNode_->mainSize_ = 0;
1296 auto size = renderNode_->items_.size();
1297 EXPECT_EQ(CREATE_FLOWITEM_MAX_COUNT, size);
1298 renderNode_->DealCache();
1299 EXPECT_EQ(renderNode_->items_.size(), size);
1300 }
1301
1302 /**
1303 * @tc.name: RenderWaterFlowTest_GetCacheTargetPos_001
1304 * @tc.desc: Verify the function that calculate the size (viewport position, cache size, main size)
1305 * @tc.type: FUNC
1306 * @tc.require: issueI5TFPO
1307 */
1308 HWTEST_F(RenderWaterFlowTest, RenderWaterFlowTest_GetCacheTargetPos_001, TestSize.Level1)
1309 {
1310 CreateRenderWaterFlow("1fr 1fr 1fr", "1fr 1fr 1fr", FlexDirection::COLUMN, CREATE_FLOWITEM_MAX_COUNT);
1311 EXPECT_TRUE(renderNode_ != nullptr);
1312 renderNode_->viewportStartPos_ = START_POS;
1313 renderNode_->cacheSize_ = 100;
1314 renderNode_->mainSize_ = 100;
1315 EXPECT_EQ(renderNode_->GetCacheTargetPos(), 200);
1316 }
1317
1318 /**
1319 * @tc.name: RenderWaterFlowTest_GetTargetPos_001
1320 * @tc.desc: Verify the function that calculate the size (viewport position, main size)
1321 * @tc.type: FUNC
1322 * @tc.require: issueI5TFPO
1323 */
1324 HWTEST_F(RenderWaterFlowTest, RenderWaterFlowTest_GetTargetPos_001, TestSize.Level1)
1325 {
1326 CreateRenderWaterFlow("1fr 1fr 1fr", "1fr 1fr 1fr", FlexDirection::COLUMN, CREATE_FLOWITEM_MAX_COUNT);
1327 EXPECT_TRUE(renderNode_ != nullptr);
1328 renderNode_->viewportStartPos_ = START_POS;
1329 renderNode_->targetIndex_ = -1;
1330 renderNode_->mainSize_ = 100;
1331 EXPECT_EQ(renderNode_->GetTargetPos(), 100);
1332 }
1333
1334 /**
1335 * @tc.name: RenderWaterFlowTest_GetTargetPos_002
1336 * @tc.desc: Verify the function that calculate the size (viewport position, main size)
1337 * @tc.type: FUNC
1338 * @tc.require: issueI5TFPO
1339 */
1340 HWTEST_F(RenderWaterFlowTest, RenderWaterFlowTest_GetTargetPos_002, TestSize.Level1)
1341 {
1342 CreateRenderWaterFlow("1fr 1fr 1fr", "1fr 1fr 1fr", FlexDirection::ROW, CREATE_FLOWITEM_MAX_COUNT);
1343 EXPECT_TRUE(renderNode_ != nullptr);
1344 renderNode_->viewportStartPos_ = START_POS;
1345 renderNode_->targetIndex_ = -1;
1346 renderNode_->mainSize_ = 100;
1347 EXPECT_EQ(renderNode_->GetTargetPos(), 100);
1348 }
1349
1350 /**
1351 * @tc.name: RenderWaterFlowTest_GetTargetPos_003
1352 * @tc.desc: Verify the function that calculate the size (viewport position, main size)
1353 * @tc.type: FUNC
1354 * @tc.require: issueI5TFPO
1355 */
1356 HWTEST_F(RenderWaterFlowTest, RenderWaterFlowTest_GetTargetPos_003, TestSize.Level1)
1357 {
1358 CreateRenderWaterFlow("1fr 1fr 1fr", "1fr 1fr 1fr", FlexDirection::COLUMN_REVERSE, CREATE_FLOWITEM_MAX_COUNT);
1359 EXPECT_TRUE(renderNode_ != nullptr);
1360 renderNode_->viewportStartPos_ = 100.0;
1361 renderNode_->targetIndex_ = -1;
1362 renderNode_->mainSize_ = 100.0;
1363 EXPECT_TRUE(renderNode_->GetTargetPos() == 0);
1364 }
1365
1366 /**
1367 * @tc.name: RenderWaterFlowTest_GetTargetPos_004
1368 * @tc.desc: Verify the function that calculate the size (viewport position, main size)
1369 * @tc.type: FUNC
1370 * @tc.require: issueI5TFPO
1371 */
1372 HWTEST_F(RenderWaterFlowTest, RenderWaterFlowTest_GetTargetPos_004, TestSize.Level1)
1373 {
1374 CreateRenderWaterFlow("1fr 1fr 1fr", "1fr 1fr 1fr", FlexDirection::ROW_REVERSE, CREATE_FLOWITEM_MAX_COUNT);
1375 EXPECT_TRUE(renderNode_ != nullptr);
1376 renderNode_->viewportStartPos_ = 100;
1377 renderNode_->targetIndex_ = -1;
1378 renderNode_->mainSize_ = 100;
1379 EXPECT_TRUE(renderNode_->GetTargetPos() == 0);
1380 }
1381
1382 /**
1383 * @tc.name: RenderWaterFlowTest_GetTargetPos_005
1384 * @tc.desc: Verify the function that calculate the size (viewport position, main size)
1385 * @tc.type: FUNC
1386 * @tc.require: issueI5TFPO
1387 */
1388 HWTEST_F(RenderWaterFlowTest, RenderWaterFlowTest_GetTargetPos_005, TestSize.Level1)
1389 {
1390 CreateRenderWaterFlow("1fr 1fr 1fr", "1fr 1fr 1fr", FlexDirection::COLUMN, CREATE_FLOWITEM_MAX_COUNT);
1391 EXPECT_TRUE(renderNode_ != nullptr);
1392 renderNode_->viewportStartPos_ = 0;
1393 renderNode_->targetIndex_ = 0;
1394 renderNode_->mainSize_ = 100;
1395 EXPECT_TRUE(renderNode_->GetTargetPos() == DBL_MAX);
1396 }
1397
1398 /**
1399 * @tc.name: RenderWaterFlowTest_GetTargetPos_006
1400 * @tc.desc: Verify the function that calculate the size (viewport position, main size)
1401 * @tc.type: FUNC
1402 * @tc.require: issueI5TFPO
1403 */
1404 HWTEST_F(RenderWaterFlowTest, RenderWaterFlowTest_GetTargetPos_006, TestSize.Level1)
1405 {
1406 CreateRenderWaterFlow("1fr 1fr 1fr", "1fr 1fr 1fr", FlexDirection::COLUMN, CREATE_FLOWITEM_MAX_COUNT);
1407 EXPECT_TRUE(renderNode_ != nullptr);
1408 renderNode_->viewportStartPos_ = 5005;
1409 renderNode_->targetIndex_ = 0;
1410 renderNode_->mainSize_ = 100;
1411 EXPECT_TRUE(renderNode_->GetTargetPos() == DBL_MAX);
1412 }
1413
1414 /**
1415 * @tc.name: RenderWaterFlowTest_GetTailPos_001
1416 * @tc.desc: Verify the function that calculate the position of last item
1417 * @tc.type: FUNC
1418 * @tc.require: issueI5TFPO
1419 */
1420 HWTEST_F(RenderWaterFlowTest, RenderWaterFlowTest_GetTailPos_001, TestSize.Level1)
1421 {
1422 CreateRenderWaterFlow("1fr 1fr 1fr", "1fr 1fr 1fr", FlexDirection::COLUMN);
1423 EXPECT_TRUE(renderNode_ != nullptr);
1424 EXPECT_TRUE(renderNode_->GetTailPos() == START_POS);
1425 }
1426
1427 /**
1428 * @tc.name: RenderWaterFlowTest_GetTailPos_002
1429 * @tc.desc: Verify the function that calculate the position of last item
1430 * @tc.type: FUNC
1431 * @tc.require: issueI5TFPO
1432 */
1433 HWTEST_F(RenderWaterFlowTest, RenderWaterFlowTest_GetTailPos_002, TestSize.Level1)
1434 {
1435 CreateRenderWaterFlow("1fr 1fr 1fr", "1fr 1fr 1fr", FlexDirection::ROW);
1436 EXPECT_TRUE(renderNode_ != nullptr);
1437 EXPECT_TRUE(renderNode_->GetTailPos() == START_POS);
1438 }
1439
1440 /**
1441 * @tc.name: RenderWaterFlowTest_GetTailPos_003
1442 * @tc.desc: Verify the function that calculate the position of last item
1443 * @tc.type: FUNC
1444 * @tc.require: issueI5TFPO
1445 */
1446 HWTEST_F(RenderWaterFlowTest, RenderWaterFlowTest_GetTailPos_003, TestSize.Level1)
1447 {
1448 CreateRenderWaterFlow("1fr 1fr 1fr", "1fr 1fr 1fr", FlexDirection::COLUMN_REVERSE);
1449 EXPECT_TRUE(renderNode_ != nullptr);
1450 EXPECT_TRUE(renderNode_->GetTailPos() == START_POS);
1451 }
1452
1453 /**
1454 * @tc.name: RenderWaterFlowTest_GetTailPos_004
1455 * @tc.desc: Verify the function that calculate the position of last item
1456 * @tc.type: FUNC
1457 * @tc.require: issueI5TFPO
1458 */
1459 HWTEST_F(RenderWaterFlowTest, RenderWaterFlowTest_GetTailPos_004, TestSize.Level1)
1460 {
1461 CreateRenderWaterFlow("1fr 1fr 1fr", "1fr 1fr 1fr", FlexDirection::ROW_REVERSE);
1462 EXPECT_TRUE(renderNode_ != nullptr);
1463 EXPECT_TRUE(renderNode_->GetTailPos() == START_POS);
1464 }
1465
1466 /**
1467 * @tc.name: RenderWaterFlowTest_GetTailPos_005
1468 * @tc.desc: Verify the function that calculate the position of last item
1469 * @tc.type: FUNC
1470 * @tc.require: issueI5TFPO
1471 */
1472 HWTEST_F(RenderWaterFlowTest, RenderWaterFlowTest_GetTailPos_005, TestSize.Level1)
1473 {
1474 CreateRenderWaterFlow("1fr 1fr 1fr", "1fr 1fr 1fr", FlexDirection::COLUMN, CREATE_FLOWITEM_MAX_COUNT);
1475 EXPECT_TRUE(renderNode_ != nullptr);
__anond51a46150b02() 1476 renderNode_->SetGetTotalCount([this]() {
1477 return renderNode_->flowMatrix_.size() - 1;
1478 });
1479 renderNode_->InitialFlowProp();
1480 auto itemIndex = renderNode_->GetNextSupplyedIndex();
1481 auto targetPos = renderNode_->GetTargetPos();
1482 renderNode_->SupplyItems(itemIndex, targetPos);
1483 EXPECT_GT(renderNode_->GetTailPos(), START_POS);
1484 }
1485
1486 /**
1487 * @tc.name: RenderWaterFlowTest_CheckReachHead_001
1488 * @tc.desc: Verify the function that check the viewport is on the head.
1489 * @tc.type: FUNC
1490 * @tc.require: issueI5TFPO
1491 */
1492 HWTEST_F(RenderWaterFlowTest, RenderWaterFlowTest_CheckReachHead_001, TestSize.Level1)
1493 {
1494 CreateRenderWaterFlow("1fr 1fr 1fr", "1fr 1fr 1fr", FlexDirection::COLUMN, CREATE_FLOWITEM_MAX_COUNT);
1495 EXPECT_TRUE(renderNode_ != nullptr);
1496 renderNode_->viewportStartPos_ = START_POS;
1497 EXPECT_TRUE(renderNode_->CheckReachHead());
1498 }
1499
1500 /**
1501 * @tc.name: RenderWaterFlowTest_CheckReachHead_002
1502 * @tc.desc: Verify the function that check the viewport is on the head.
1503 * @tc.type: FUNC
1504 * @tc.require: issueI5TFPO
1505 */
1506 HWTEST_F(RenderWaterFlowTest, RenderWaterFlowTest_CheckReachHead_002, TestSize.Level1)
1507 {
1508 CreateRenderWaterFlow("1fr 1fr 1fr", "1fr 1fr 1fr", FlexDirection::COLUMN_REVERSE, CREATE_FLOWITEM_MAX_COUNT);
1509 EXPECT_TRUE(renderNode_ != nullptr);
1510 renderNode_->viewportStartPos_ = START_POS;
1511 EXPECT_TRUE(renderNode_->CheckReachHead());
1512 }
1513
1514 /**
1515 * @tc.name: RenderWaterFlowTest_CheckReachHead_003
1516 * @tc.desc: Verify the function that check the viewport is on the head.
1517 * @tc.type: FUNC
1518 * @tc.require: issueI5TFPO
1519 */
1520 HWTEST_F(RenderWaterFlowTest, RenderWaterFlowTest_CheckReachHead_003, TestSize.Level1)
1521 {
1522 CreateRenderWaterFlow("1fr 1fr 1fr", "1fr 1fr 1fr", FlexDirection::ROW, CREATE_FLOWITEM_MAX_COUNT);
1523 EXPECT_TRUE(renderNode_ != nullptr);
1524 renderNode_->viewportStartPos_ = START_POS;
1525 EXPECT_TRUE(renderNode_->CheckReachHead());
1526 }
1527
1528 /**
1529 * @tc.name: RenderWaterFlowTest_CheckReachHead_004
1530 * @tc.desc: Verify the function that check the viewport is on the head.
1531 * @tc.type: FUNC
1532 * @tc.require: issueI5TFPO
1533 */
1534 HWTEST_F(RenderWaterFlowTest, RenderWaterFlowTest_CheckReachHead_004, TestSize.Level1)
1535 {
1536 CreateRenderWaterFlow("1fr 1fr 1fr", "1fr 1fr 1fr", FlexDirection::ROW_REVERSE, CREATE_FLOWITEM_MAX_COUNT);
1537 EXPECT_TRUE(renderNode_ != nullptr);
1538 renderNode_->viewportStartPos_ = START_POS;
1539 EXPECT_TRUE(renderNode_->CheckReachHead());
1540 }
1541
1542 /**
1543 * @tc.name: RenderWaterFlowTest_GetCrossSize_001
1544 * @tc.desc: Verify the function that get the cross size of the selected item
1545 * @tc.type: FUNC
1546 * @tc.require: issueI5TFPO
1547 */
1548 HWTEST_F(RenderWaterFlowTest, RenderWaterFlowTest_GetCrossSize_001, TestSize.Level1)
1549 {
1550 CreateRenderWaterFlow("1fr 1fr 1fr", "1fr 1fr 1fr", FlexDirection::COLUMN, CREATE_FLOWITEM_MAX_COUNT);
1551 EXPECT_TRUE(renderNode_ != nullptr);
1552 EXPECT_EQ(renderNode_->GetCrossSize(nullptr), 0.0);
1553 for (const auto& item : renderNode_->items_) {
1554 EXPECT_EQ(renderNode_->GetCrossSize(item.second), item.second->GetLayoutSize().Width());
1555 }
1556 }
1557
1558 /**
1559 * @tc.name: RenderWaterFlowTest_GetCrossSize_002
1560 * @tc.desc: Verify the function that get the cross size of the selected item
1561 * @tc.type: FUNC
1562 * @tc.require: issueI5TFPO
1563 */
1564 HWTEST_F(RenderWaterFlowTest, RenderWaterFlowTest_GetCrossSize_002, TestSize.Level1)
1565 {
1566 CreateRenderWaterFlow("1fr 1fr 1fr", "1fr 1fr 1fr", FlexDirection::ROW, CREATE_FLOWITEM_MAX_COUNT);
1567 EXPECT_TRUE(renderNode_ != nullptr);
1568 for (const auto& item : renderNode_->items_) {
1569 EXPECT_EQ(renderNode_->GetCrossSize(item.second), item.second->GetLayoutSize().Height());
1570 }
1571 }
1572
1573 /**
1574 * @tc.name: RenderWaterFlowTest_GetCrossSize_003
1575 * @tc.desc: Verify the function that get the cross size of the selected item
1576 * @tc.type: FUNC
1577 * @tc.require: issueI5TFPO
1578 */
1579 HWTEST_F(RenderWaterFlowTest, RenderWaterFlowTest_GetCrossSize_003, TestSize.Level1)
1580 {
1581 CreateRenderWaterFlow("1fr 1fr 1fr", "1fr 1fr 1fr", FlexDirection::COLUMN_REVERSE, CREATE_FLOWITEM_MAX_COUNT);
1582 EXPECT_TRUE(renderNode_ != nullptr);
1583 EXPECT_TRUE(renderNode_->GetCrossSize(nullptr) == 0);
1584 for (const auto& item : renderNode_->items_) {
1585 EXPECT_EQ(renderNode_->GetCrossSize(item.second), item.second->GetLayoutSize().Width());
1586 }
1587 }
1588
1589 /**
1590 * @tc.name: RenderWaterFlowTest_GetCrossSize_004
1591 * @tc.desc: Verify the function that get the cross size of the selected item
1592 * @tc.type: FUNC
1593 * @tc.require: issueI5TFPO
1594 */
1595 HWTEST_F(RenderWaterFlowTest, RenderWaterFlowTest_GetCrossSize_004, TestSize.Level1)
1596 {
1597 CreateRenderWaterFlow("1fr 1fr 1fr", "1fr 1fr 1fr", FlexDirection::ROW_REVERSE, CREATE_FLOWITEM_MAX_COUNT);
1598 EXPECT_TRUE(renderNode_ != nullptr);
1599 for (const auto& item : renderNode_->items_) {
1600 EXPECT_EQ(renderNode_->GetCrossSize(item.second), item.second->GetLayoutSize().Height());
1601 }
1602 }
1603
1604 /**
1605 * @tc.name: RenderWaterFlowTest_GetMainSize_001
1606 * @tc.desc: Verify the function that get the cross size of the selected item
1607 * @tc.type: FUNC
1608 * @tc.require: issueI5TFPO
1609 */
1610 HWTEST_F(RenderWaterFlowTest, RenderWaterFlowTest_GetMainSize_001, TestSize.Level1)
1611 {
1612 CreateRenderWaterFlow("1fr 1fr 1fr", "1fr 1fr 1fr", FlexDirection::COLUMN, CREATE_FLOWITEM_MAX_COUNT);
1613 EXPECT_TRUE(renderNode_ != nullptr);
1614 auto item = renderNode_->items_[START_INDEX];
1615 EXPECT_TRUE(renderNode_->GetMainSize(nullptr) == 0);
1616 EXPECT_TRUE(renderNode_->GetMainSize(item) == item->GetLayoutSize().Height());
1617 }
1618
1619 /**
1620 * @tc.name: RenderWaterFlowTest_GetMainSize_002
1621 * @tc.desc: Verify the function that get the cross size of the selected item
1622 * @tc.type: FUNC
1623 * @tc.require: issueI5TFPO
1624 */
1625 HWTEST_F(RenderWaterFlowTest, RenderWaterFlowTest_GetMainSize_002, TestSize.Level1)
1626 {
1627 CreateRenderWaterFlow("1fr 1fr 1fr", "1fr 1fr 1fr", FlexDirection::ROW, CREATE_FLOWITEM_MAX_COUNT);
1628 EXPECT_TRUE(renderNode_ != nullptr);
1629 auto item = renderNode_->items_[START_INDEX];
1630 EXPECT_TRUE(renderNode_->GetMainSize(item) == item->GetLayoutSize().Width());
1631 }
1632
1633 /**
1634 * @tc.name: RenderWaterFlowTest_GetMainSize_003
1635 * @tc.desc: Verify the function that get the cross size of the selected item
1636 * @tc.type: FUNC
1637 * @tc.require: issueI5TFPO
1638 */
1639 HWTEST_F(RenderWaterFlowTest, RenderWaterFlowTest_GetMainSize_003, TestSize.Level1)
1640 {
1641 CreateRenderWaterFlow("1fr 1fr 1fr", "1fr 1fr 1fr", FlexDirection::COLUMN_REVERSE, CREATE_FLOWITEM_MAX_COUNT);
1642 EXPECT_TRUE(renderNode_ != nullptr);
1643 auto item = renderNode_->items_[START_INDEX];
1644 EXPECT_TRUE(renderNode_->GetMainSize(nullptr) == 0);
1645 EXPECT_TRUE(renderNode_->GetMainSize(item) == item->GetLayoutSize().Height());
1646 }
1647
1648 /**
1649 * @tc.name: RenderWaterFlowTest_GetMainSize_004
1650 * @tc.desc: Verify the function that get the cross size of the selected item
1651 * @tc.type: FUNC
1652 * @tc.require: issueI5TFPO
1653 */
1654 HWTEST_F(RenderWaterFlowTest, RenderWaterFlowTest_GetMainSize_004, TestSize.Level1)
1655 {
1656 CreateRenderWaterFlow("1fr 1fr 1fr", "1fr 1fr 1fr", FlexDirection::ROW_REVERSE, CREATE_FLOWITEM_MAX_COUNT);
1657 EXPECT_TRUE(renderNode_ != nullptr);
1658 auto item = renderNode_->items_[START_INDEX];
1659 EXPECT_TRUE(renderNode_->GetMainSize(item) == item->GetLayoutSize().Width());
1660 }
1661
1662 /**
1663 * @tc.name: RenderWaterFlowTest_GetFlowItemByChild_001
1664 * @tc.desc: Verify the function that get the flow item with child.
1665 * @tc.type: FUNC
1666 * @tc.require: issueI5TFPO
1667 */
1668 HWTEST_F(RenderWaterFlowTest, RenderWaterFlowTest_GetFlowItemByChild_001, TestSize.Level1)
1669 {
1670 CreateRenderWaterFlow("1fr 1fr 1fr", "1fr 1fr 1fr", FlexDirection::COLUMN, CREATE_FLOWITEM_MAX_COUNT);
1671 EXPECT_TRUE(renderNode_ != nullptr);
1672 EXPECT_TRUE(renderNode_->GetFlowItemByChild(nullptr) == nullptr);
1673 auto item = renderNode_->items_[START_INDEX];
1674 EXPECT_TRUE(renderNode_->GetFlowItemByChild(renderNode_) == item);
1675 }
1676
1677 /**
1678 * @tc.name: RenderWaterFlowTest_GetFlowItemByChild_002
1679 * @tc.desc: Verify the function that get the flow item with child.
1680 * @tc.type: FUNC
1681 * @tc.require: issueI5TFPO
1682 */
1683 HWTEST_F(RenderWaterFlowTest, RenderWaterFlowTest_GetFlowItemByChild_002, TestSize.Level1)
1684 {
1685 CreateRenderWaterFlow("1fr 1fr 1fr", "1fr 1fr 1fr", FlexDirection::COLUMN);
1686 EXPECT_TRUE(renderNode_ != nullptr);
1687 EXPECT_TRUE(renderNode_->GetFlowItemByChild(renderNode_) == nullptr);
1688 }
1689
1690 /**
1691 * @tc.name: RenderWaterFlowTest_ConstraintItemSize_001
1692 * @tc.desc: Verify the function that get constrain size of the flow item.
1693 * @tc.type: FUNC
1694 * @tc.require: issueI5TFPO
1695 */
1696 HWTEST_F(RenderWaterFlowTest, RenderWaterFlowTest_ConstraintItemSize_001, TestSize.Level1)
1697 {
1698 V2::FlowStyle flowStyleTest = {0, 0, 30, 50};
1699 CreateRenderWaterFlow("1fr 1fr 1fr", "1fr 1fr 1fr", FlexDirection::COLUMN, CREATE_FLOWITEM_MAX_COUNT);
1700 EXPECT_TRUE(renderNode_ != nullptr);
1701 renderNode_->itemConstraintSize_ = V2::ItemConstraintSize{300, 400, 500, 600};
1702 EXPECT_TRUE(renderNode_->ConstraintItemSize(flowStyleTest, START_INDEX).mainSize == 500);
1703 V2::FlowStyle flowStyleTestMax = {3000, 4000, 5000, 6000};
1704 EXPECT_TRUE(renderNode_->ConstraintItemSize(flowStyleTestMax, START_INDEX).mainSize == 600);
1705 }
1706
1707 /**
1708 * @tc.name: RenderWaterFlowTest_GetCrossEndPos_001
1709 * @tc.desc: Verify the function that get the end position of the selected cross index.
1710 * @tc.type: FUNC
1711 * @tc.require: issueI5TFPO
1712 */
1713 HWTEST_F(RenderWaterFlowTest, RenderWaterFlowTest_GetCrossEndPos_001, TestSize.Level1)
1714 {
1715 CreateRenderWaterFlow("50px 60px 70px 80px", "", FlexDirection::COLUMN, CREATE_FLOWITEM_MAX_COUNT);
1716 EXPECT_TRUE(renderNode_ != nullptr);
1717 renderNode_->InitialFlowProp();
1718 renderNode_->crossGap_ = 0;
1719 EXPECT_TRUE(renderNode_->GetCrossEndPos(4) == 0);
1720 EXPECT_TRUE(renderNode_->GetCrossEndPos(3) == 180);
1721 renderNode_->crossGap_ = 10;
1722 EXPECT_TRUE(renderNode_->GetCrossEndPos(2) == 130);
1723 }
1724
1725 /**
1726 * @tc.name: RenderWaterFlowTest_UpdateMainSideEndPos_001
1727 * @tc.desc: Verify the function that get the end position of the selected cross index.
1728 * @tc.type: FUNC
1729 * @tc.require: issueI5TFPO
1730 */
1731 HWTEST_F(RenderWaterFlowTest, RenderWaterFlowTest_UpdateMainSideEndPos_001, TestSize.Level1)
1732 {
1733 CreateRenderWaterFlow("1fr 1fr 1fr", "", FlexDirection::COLUMN, CREATE_FLOWITEM_MAX_COUNT);
1734 EXPECT_TRUE(renderNode_ != nullptr);
1735 auto itemIndex = renderNode_->GetNextSupplyedIndex();
1736 auto targetPos = renderNode_->GetTargetPos();
1737 renderNode_->InitialFlowProp();
1738 renderNode_->SupplyItems(itemIndex, targetPos);
1739 EXPECT_EQ(renderNode_->mainSideEndPos_.size(), renderNode_->itemsByCrossIndex_.size());
1740 renderNode_->UpdateMainSideEndPos();
1741 EXPECT_FALSE(renderNode_->mainSideEndPos_.empty());
1742 }
1743
1744 /**
1745 * @tc.name: RenderWaterFlowTest_ClearFlowMatrix_001
1746 * @tc.desc: Verify the function that clear the selected item if index > -1, else clear all.
1747 * @tc.type: FUNC
1748 * @tc.require: issueI5TFPO
1749 */
1750 HWTEST_F(RenderWaterFlowTest, RenderWaterFlowTest_ClearFlowMatrix_001, TestSize.Level1)
1751 {
1752 CreateRenderWaterFlow("1fr 1fr 1fr 1fr", "", FlexDirection::COLUMN);
1753 EXPECT_TRUE(renderNode_ != nullptr);
1754 auto targetIndex = 1;
1755 auto itemIndex = renderNode_->GetNextSupplyedIndex();
1756 auto targetPos = renderNode_->GetTargetPos();
1757 renderNode_->InitialFlowProp();
1758 renderNode_->SupplyItems(itemIndex, targetPos);
1759 renderNode_->ClearFlowMatrix(START_INDEX + 1);
1760 EXPECT_EQ(renderNode_->flowMatrix_.size(), targetIndex);
1761 renderNode_->ClearFlowMatrix(START_INDEX, true);
1762 EXPECT_TRUE(renderNode_->flowMatrix_.empty());
1763 }
1764
1765 /**
1766 * @tc.name: RenderWaterFlowTest_ClearItemsByCrossIndex_001
1767 * @tc.desc: Verify the function that clear the selected item if cross index > -1, else clear all.
1768 * @tc.type: FUNC
1769 * @tc.require: issueI5TFPO
1770 */
1771 HWTEST_F(RenderWaterFlowTest, RenderWaterFlowTest_ClearItemsByCrossIndex_001, TestSize.Level1)
1772 {
1773 CreateRenderWaterFlow("1fr 1fr 1fr 1fr", "", FlexDirection::COLUMN, CREATE_FLOWITEM_MAX_COUNT);
1774 EXPECT_TRUE(renderNode_ != nullptr);
1775 int index = 4;
1776 auto itemIndex = renderNode_->GetNextSupplyedIndex();
1777 auto targetPos = renderNode_->GetTargetPos();
1778 renderNode_->InitialFlowProp();
1779 renderNode_->SupplyItems(itemIndex, targetPos);
1780 renderNode_->ClearItemsByCrossIndex(index);
1781 auto cross = renderNode_->itemsByCrossIndex_.begin();
1782 while (cross != renderNode_->itemsByCrossIndex_.end()) {
1783 EXPECT_EQ((*cross).size(), 1);
1784 cross++;
1785 }
1786 renderNode_->ClearItemsByCrossIndex(START_INDEX, true);
1787 EXPECT_EQ(renderNode_->itemsByCrossIndex_.size(), renderNode_->crossCount_);
1788 EXPECT_TRUE(!renderNode_->itemsByCrossIndex_.empty());
1789 for (const auto& itemIndex : renderNode_->itemsByCrossIndex_) {
1790 EXPECT_TRUE(itemIndex.empty());
1791 }
1792 }
1793
1794 /**
1795 * @tc.name: RenderWaterFlowTest_RegisterItemGenerator_001
1796 * @tc.desc: Verify the function that judge itemGenerator_.Upgrade.
1797 * @tc.type: FUNC
1798 * @tc.require: issueI5TFPO
1799 */
1800 HWTEST_F(RenderWaterFlowTest, RenderWaterFlowTest_RegisterItemGenerator_001, TestSize.Level1)
1801 {
1802 RefPtr<V2::WaterFlowItemGenerator> itemgenerator = AceType::MakeRefPtr<V2::WaterFlowItemGenerator>();
1803 renderNode_->RegisterItemGenerator(itemgenerator);
1804 EXPECT_TRUE(renderNode_->itemGenerator_.Upgrade());
1805 }
1806
1807 /**
1808 * @tc.name: RenderWaterFlowTest_HandleScrollEvent_001
1809 * @tc.desc: Verify the function that get the value of map.
1810 * @tc.type: FUNC
1811 * @tc.require: issueI5TFPO
1812 */
1813 HWTEST_F(RenderWaterFlowTest, RenderWaterFlowTest_HandleScrollEvent_001, TestSize.Level1)
1814 {
1815 CreateRenderWaterFlow("1fr 1fr", "1fr 1fr", FlexDirection::COLUMN, CREATE_FLOWITEM_COUNT);
1816 CHECK_RENDERNODE_NULL_VOID(renderNode_);
1817 renderNode_->HandleScrollEvent();
1818 for (auto event : renderNode_->waterflowEventFlags_) {
1819 EXPECT_FALSE(event.second);
1820 }
1821 }
1822
1823 /**
1824 * @tc.name: RenderWaterFlowTest_MakeInnerLayoutParam_001
1825 * @tc.desc: Verify the function that get the value of minsize.
1826 * @tc.type: FUNC
1827 * @tc.require: issueI5TFPO
1828 */
1829 HWTEST_F(RenderWaterFlowTest, RenderWaterFlowTest_MakeInnerLayoutParam_001, TestSize.Level1)
1830 {
1831 CreateRenderWaterFlow("1fr 1fr", "1fr 1fr", FlexDirection::COLUMN, CREATE_FLOWITEM_COUNT);
1832 CHECK_RENDERNODE_NULL_VOID(renderNode_);
1833 renderNode_->InitialFlowProp();
1834 size_t index = 0;
1835 size_t itemIndex = renderNode_->GetNextSupplyedIndex();
1836 double targetPos = renderNode_->GetTargetPos();
1837 renderNode_->SupplyItems(itemIndex, targetPos);
1838 LayoutParam innerLayout;
1839 innerLayout = renderNode_->MakeInnerLayoutParam(index);
1840 auto result = innerLayout.GetMaxSize();
1841 EXPECT_EQ(result.Width(), (renderNode_->crossSize_ - renderNode_->crossGap_) / CENTER_POINT);
1842 }
1843
1844 /**
1845 * @tc.name: RenderWaterFlowTest_SetChildPosition_001
1846 * @tc.desc: Verify the function that value of GetChildPosition after using SetChildPosition.
1847 * @tc.type: FUNC
1848 * @tc.require: issueI5TFPO
1849 */
1850 HWTEST_F(RenderWaterFlowTest, RenderWaterFlowTest_SetChildPosition_001, TestSize.Level1)
1851 {
1852 CreateRenderWaterFlow("1fr 1fr", "1fr 1fr", FlexDirection::COLUMN);
1853 renderNode_->InitialFlowProp();
1854 size_t itemIndex = renderNode_->GetNextSupplyedIndex();
1855 double targetPos = renderNode_->GetTargetPos();
1856 renderNode_->SupplyItems(itemIndex, targetPos);
1857 size_t index = 0;
1858 for (auto& item : renderNode_->items_) {
1859 item.second->SetLayoutSize(Size(160, 160));
1860 renderNode_->SetChildPosition(item.second, index);
1861 EXPECT_TRUE(renderNode_->GetPosition() == Offset(index % 5 * 210, index / 5 * 210));
1862 }
1863 }
1864
1865 /**
1866 * @tc.name: RenderWaterFlowTest_CreateScrollable_001
1867 * @tc.desc: Verify the function that Check whether scrollable_ is nullptr.
1868 * @tc.type: FUNC
1869 * @tc.require: issueI5TFPO
1870 */
1871 HWTEST_F(RenderWaterFlowTest, RenderWaterFlowTest_CreateScrollable_001, TestSize.Level1)
1872 {
1873 CreateRenderWaterFlow("1fr 1fr", "1fr 1fr", FlexDirection::COLUMN, CREATE_FLOWITEM_COUNT);
1874 CHECK_RENDERNODE_NULL_VOID(renderNode_);
1875 renderNode_->CreateScrollable();
1876 EXPECT_TRUE(renderNode_->scrollable_ != nullptr);
1877 }
1878
1879 /**
1880 * @tc.name: RenderWaterFlowTest_OnTouchTestHit_001
1881 * @tc.desc: Verify the function that Check whether scrollable_ is nullptr.
1882 * @tc.require: issueI5TFPO
1883 */
1884 HWTEST_F(RenderWaterFlowTest, RenderWaterFlowTest_OnTouchTestHit_001, TestSize.Level1)
1885 {
1886 CreateRenderWaterFlow("1fr 1fr", "1fr 1fr", FlexDirection::COLUMN, CREATE_FLOWITEM_COUNT);
1887 CHECK_RENDERNODE_NULL_VOID(renderNode_);
1888 TouchRestrict touchRestrict;
1889 TouchTestResult result;
1890 touchRestrict.UpdateForbiddenType(1);
1891 Offset offset(START_POS, START_POS);
1892 renderNode_->OnTouchTestHit(offset, touchRestrict, result);
1893 EXPECT_FALSE(renderNode_->scrollable_ == nullptr);
1894 }
1895
1896 /**
1897 * @tc.name: RenderWaterFlowTest_UpdateScrollPosition_001
1898 * @tc.desc: Verify the function that return value of UpdateScrollPosition.
1899 * @tc.type: FUNC
1900 * @tc.require: issueI5TFPO
1901 */
1902 HWTEST_F(RenderWaterFlowTest, RenderWaterFlowTest_UpdateScrollPosition_001, TestSize.Level1)
1903 {
1904 CreateRenderWaterFlow("1fr 1fr", "1fr 1fr", FlexDirection::COLUMN, CREATE_FLOWITEM_COUNT);
1905 CHECK_RENDERNODE_NULL_VOID(renderNode_);
1906 double offset = 1.0;
1907 int32_t source = 10;
1908 auto result = renderNode_->UpdateScrollPosition(offset, source);
1909 EXPECT_TRUE(result);
1910 }
1911
1912 /**
1913 * @tc.name: RenderWaterFlowTest_CallGap_001
1914 * @tc.desc: Verify the function that find the value of mainGap_.
1915 * @tc.type: FUNC
1916 * @tc.require: issueI5TFPO
1917 */
1918 HWTEST_F(RenderWaterFlowTest, RenderWaterFlowTest_CallGap_001, TestSize.Level1)
1919 {
1920 CreateRenderWaterFlow("1fr 1fr", "1fr 1fr", FlexDirection::COLUMN, CREATE_FLOWITEM_COUNT);
1921 CHECK_RENDERNODE_NULL_VOID(renderNode_);
1922 renderNode_->CallGap();
1923 EXPECT_EQ(renderNode_->mainGap_, 100.0);
1924 }
1925
1926 /**
1927 * @tc.name: RenderWaterFlowTest_CallGap_001
1928 * @tc.desc: Verify the function that find the value of maxCrossSize,maxMainSize,minCrossSize and minMainSize.
1929 * @tc.type: FUNC
1930 * @tc.require: issueI5TFPO
1931 */
1932 HWTEST_F(RenderWaterFlowTest, RenderWaterFlowTest_CallItemConstraintSize_001, TestSize.Level1)
1933 {
1934 CreateRenderWaterFlow("1fr 1fr", "1fr 1fr", FlexDirection::COLUMN);
1935 renderNode_->InitialFlowProp();
1936 renderNode_->CallItemConstraintSize();
1937 EXPECT_EQ(renderNode_->itemConstraintSize_.maxCrossSize, 1000.0);
1938 EXPECT_EQ(renderNode_->itemConstraintSize_.maxMainSize, 1000.0);
1939 EXPECT_EQ(renderNode_->itemConstraintSize_.minCrossSize, 100.0);
1940 EXPECT_EQ(renderNode_->itemConstraintSize_.minMainSize, 100.0);
1941 }
1942
1943 /**
1944 * @tc.name: RenderWaterFlowTest_InitialFlowProp_001
1945 * @tc.desc: Verify the function that value of cacheSize after using InitialFlowProp.
1946 * @tc.type: FUNC
1947 * @tc.require: issueI5TFPO
1948 */
1949 HWTEST_F(RenderWaterFlowTest, RenderWaterFlowTest_InitialFlowProp_001, TestSize.Level1)
1950 {
1951 CreateRenderWaterFlow("1fr 1fr", "1fr 1fr", FlexDirection::COLUMN, CREATE_FLOWITEM_COUNT);
1952 CHECK_RENDERNODE_NULL_VOID(renderNode_);
1953 renderNode_->InitialFlowProp();
1954 EXPECT_EQ(renderNode_->cacheSize_, renderNode_->mainSize_ * CACHE_SIZE_SCALE);
1955 }
1956
1957 /**
1958 * @tc.name: RenderWaterFlowTest_ GetFlowSize_001
1959 * @tc.desc: Verify the function that find the value of mainSize_ and crossSize_.
1960 * @tc.type: FUNC
1961 * @tc.require: issueI5TFPO
1962 */
1963 HWTEST_F(RenderWaterFlowTest, RenderWaterFlowTest_GetFlowSize_001, TestSize.Level1)
1964 {
1965 CreateRenderWaterFlow("1fr 1fr", "1fr 1fr", FlexDirection::COLUMN, CREATE_FLOWITEM_COUNT);
1966 CHECK_RENDERNODE_NULL_VOID(renderNode_);
1967 EXPECT_EQ(renderNode_->mainSize_, 1000.0);
1968 EXPECT_EQ(renderNode_->crossSize_, 1000.0);
1969 EXPECT_EQ(renderNode_->cacheSize_, renderNode_->mainSize_ * CACHE_SIZE_SCALE);
1970 }
1971
1972 /**
1973 * @tc.name: RenderWaterFlowTest_ GetFlowSize_001
1974 * @tc.desc: Verify the function that value of targetIndex_ after using SuppltItems.
1975 * @tc.type: FUNC
1976 * @tc.require: issueI5TFPO
1977 */
1978 HWTEST_F(RenderWaterFlowTest, RenderWaterFlowTest_SupplyItems_001, TestSize.Level1)
1979 {
1980 CreateRenderWaterFlow("1fr 1fr", "1fr 1fr", FlexDirection::COLUMN, CREATE_FLOWITEM_COUNT);
1981 CHECK_RENDERNODE_NULL_VOID(renderNode_);
1982 renderNode_->InitialFlowProp();
1983 size_t itemIndex = renderNode_->GetNextSupplyedIndex();
1984 double targetPos = renderNode_->GetTargetPos();
1985 renderNode_->SupplyItems(itemIndex, targetPos);
1986 for (auto itemMessage : renderNode_->flowMatrix_) {
1987 EXPECT_EQ(itemMessage.second.crossSize, (renderNode_->crossSize_ - renderNode_->crossGap_) / CENTER_POINT);
1988 EXPECT_EQ(itemMessage.second.mainSize, ITEM_HEIGHT);
1989 }
1990 }
1991
1992 /**
1993 * @tc.name: RenderWaterFlowTest_LayoutItems_001
1994 * @tc.desc: Verify the function that value of GetPosition after using LayoutItems.
1995 * @tc.type: FUNC
1996 * @tc.require: issueI5TFPO
1997 */
1998 HWTEST_F(RenderWaterFlowTest, RenderWaterFlowTest_LayoutItems_001, TestSize.Level1)
1999 {
2000 CreateRenderWaterFlow("1fr 1fr", "1fr 1fr", FlexDirection::COLUMN, CREATE_FLOWITEM_COUNT);
2001 CHECK_RENDERNODE_NULL_VOID(renderNode_);
2002 renderNode_->InitialFlowProp();
2003 auto itemIndex = renderNode_->GetNextSupplyedIndex();
2004 auto targetPos = renderNode_->GetTargetPos();
2005 renderNode_->SupplyItems(itemIndex, targetPos);
2006 for (size_t index = 0; index < renderNode_->items_.size(); index++) {
2007 renderNode_->cacheItems_.emplace(index);
2008 }
2009 renderNode_->LayoutItems(renderNode_->cacheItems_);
2010 for (auto itemMessage : renderNode_->items_) {
2011 EXPECT_EQ(itemMessage.second->GetLayoutSize(), Size(
2012 (renderNode_->crossSize_ - renderNode_->crossGap_) / CENTER_POINT, ITEM_HEIGHT));
2013 }
2014 }
2015
2016 /**
2017 * @tc.name: RenderWaterFlowTest_GetFooterSize_001
2018 * @tc.desc: Verify the function that value to width and height.
2019 * @tc.type: FUNC
2020 * @tc.require: issueI5TFPO
2021 */
2022 HWTEST_F(RenderWaterFlowTest, RenderWaterFlowTest_GetFooterSize_001, TestSize.Level1)
2023 {
2024 CreateRenderWaterFlow("1fr 1fr", "1fr 1fr");
2025 CHECK_RENDERNODE_NULL_VOID(renderNode_);
2026 auto waterflowElement = AceType::MakeRefPtr<MockWaterFlowElement>();
2027 CHECK_RENDERNODE_NULL_VOID(waterflowElement);
2028 waterflowElement->SetContext(mockContext_);
2029 WeakPtr<V2::WaterFlowItemGenerator> waterFlowItemGenerator(waterflowElement);
2030 renderNode_->RegisterItemGenerator(std::move(waterFlowItemGenerator));
2031 renderNode_->RequestWaterFlowFooter();
2032 double mainSize = 10.0;
2033 double crossSize = 100.0;
2034 renderNode_->GetFooterSize(mainSize, crossSize);
2035 EXPECT_EQ(renderNode_->footerMaxSize_.Width(), crossSize);
2036 EXPECT_EQ(renderNode_->footerMaxSize_.Height(), mainSize);
2037 }
2038
2039 /**
2040 * @tc.name: RenderWaterFlowTest_SetFooterPosition_001
2041 * @tc.desc: Verify the function that value of GetPosition after using SetFooterPosition.
2042 * @tc.type: FUNC
2043 * @tc.require: issueI5TFPO
2044 */
2045 HWTEST_F(RenderWaterFlowTest, RenderWaterFlowTest_SetFooterPosition_001, TestSize.Level1)
2046 {
2047 CreateRenderWaterFlow("1fr 1fr", "1fr 1fr");
2048 CHECK_RENDERNODE_NULL_VOID(renderNode_);
__anond51a46150c02() 2049 renderNode_->SetGetTotalCount([this]() {
2050 return renderNode_->flowMatrix_.size() - 1;
2051 });
2052 auto waterflowElement = AceType::MakeRefPtr<MockWaterFlowElement>();
2053 CHECK_RENDERNODE_NULL_VOID(waterflowElement);
2054 waterflowElement->SetContext(mockContext_);
2055 WeakPtr<V2::WaterFlowItemGenerator> waterFlowItemGenerator(waterflowElement);
2056 renderNode_->RegisterItemGenerator(std::move(waterFlowItemGenerator));
2057 renderNode_->InitialFlowProp();
2058 auto itemIndex = renderNode_->GetNextSupplyedIndex();
2059 auto targetPos = renderNode_->GetTargetPos();
2060 renderNode_->SupplyItems(itemIndex, targetPos);
2061 renderNode_->footerMaxSize_ = Size(150.0, 150.0);
2062 renderNode_->viewportStartPos_ = 50.0;
2063 renderNode_->SetFooterPosition();
2064 EXPECT_TRUE(renderNode_->footer_->GetPosition() == Offset(
2065 (renderNode_->crossSize_ - renderNode_->footerMaxSize_.Width()) / CENTER_POINT,
2066 renderNode_->mainSize_ - renderNode_->footerMaxSize_.Height()));
2067 }
2068
2069 /**
2070 * @tc.name: RenderWaterFlowTest_SetFooterPosition_002
2071 * @tc.desc: Verify the function that value of GetPosition after using SetFooterPosition.
2072 * @tc.type: FUNC
2073 * @tc.require: issueI5TFPO
2074 */
2075 HWTEST_F(RenderWaterFlowTest, RenderWaterFlowTest_SetFooterPosition_002, TestSize.Level1)
2076 {
2077 CreateRenderWaterFlow("1fr 1fr", "1fr 1fr");
2078 CHECK_RENDERNODE_NULL_VOID(renderNode_);
2079 auto waterflowElement = AceType::MakeRefPtr<MockWaterFlowElement>();
2080 CHECK_RENDERNODE_NULL_VOID(waterflowElement);
2081 waterflowElement->SetContext(mockContext_);
2082 WeakPtr<V2::WaterFlowItemGenerator> waterFlowItemGenerator(waterflowElement);
2083 renderNode_->RegisterItemGenerator(std::move(waterFlowItemGenerator));
2084 renderNode_->RequestWaterFlowFooter();
2085 renderNode_->footerMaxSize_ = Size(150.0, 10.0);
2086 renderNode_->SetFooterPosition();
2087 EXPECT_TRUE(renderNode_->footer_->GetPosition() == Offset((renderNode_->crossSize_ - 150) / CENTER_POINT,
2088 START_POS));
2089 }
2090
2091 /**
2092 * @tc.name: RenderWaterFlowTest_LayoutFooter_001
2093 * @tc.desc: Verify the function that value of GetPosition after using LayoutFooter.
2094 * @tc.type: FUNC
2095 * @tc.require: issueI5TFPO
2096 */
2097 HWTEST_F(RenderWaterFlowTest, RenderWaterFlowTest_LayoutFooter_001, TestSize.Level1)
2098 {
2099 CreateRenderWaterFlow("1fr 1fr", "1fr 1fr");
2100 CHECK_RENDERNODE_NULL_VOID(renderNode_);
__anond51a46150d02() 2101 renderNode_->SetGetTotalCount([this]() {
2102 return renderNode_->flowMatrix_.size() - 1;
2103 });
2104 auto waterflowElement = AceType::MakeRefPtr<MockWaterFlowElement>();
2105 CHECK_RENDERNODE_NULL_VOID(waterflowElement);
2106 waterflowElement->SetContext(mockContext_);
2107 WeakPtr<V2::WaterFlowItemGenerator> waterFlowItemGenerator(waterflowElement);
2108 renderNode_->RegisterItemGenerator(std::move(waterFlowItemGenerator));
2109 renderNode_->InitialFlowProp();
2110 auto itemIndex = renderNode_->GetNextSupplyedIndex();
2111 auto targetPos = renderNode_->GetTargetPos();
2112 renderNode_->SupplyItems(itemIndex, targetPos);
2113 renderNode_->viewportStartPos_ = 50.0;
2114 renderNode_->LayoutFooter();
2115 EXPECT_TRUE(renderNode_->footer_->GetPosition() == Offset(
2116 (renderNode_->crossSize_ - renderNode_->footerMaxSize_.Width()) / CENTER_POINT,
2117 renderNode_->mainSize_ - renderNode_->footerMaxSize_.Height()));
2118 EXPECT_TRUE(renderNode_->footer_->GetLayoutSize() == Size(renderNode_->footerMaxSize_.Width(),
2119 renderNode_->footerMaxSize_.Height()));
2120 }
2121
2122 /**
2123 * @tc.name: RenderWaterFlowTest_GetLastSupplyedIndex_001
2124 * @tc.desc: Verify the function that return value of GetLastSupplyedIndex.
2125 * @tc.type: FUNC
2126 * @tc.require: issueI5TFPO
2127 */
2128 HWTEST_F(RenderWaterFlowTest, RenderWaterFlowTest_GetLastSupplyedIndex_001, TestSize.Level1)
2129 {
2130 CreateRenderWaterFlow("1fr 1fr", "1fr 1fr");
2131 CHECK_RENDERNODE_NULL_VOID(renderNode_);
2132 auto result = renderNode_->GetLastSupplyedIndex();
2133 EXPECT_EQ(result, 0);
2134 renderNode_->InitialFlowProp();
2135 auto itemIndex = renderNode_->GetNextSupplyedIndex();
2136 auto targetPos = renderNode_->GetTargetPos();
2137 renderNode_->SupplyItems(itemIndex, targetPos);
2138 result = renderNode_->GetLastSupplyedIndex();
2139 EXPECT_EQ(result, 7);
2140 }
2141
2142 /**
2143 * @tc.name: RenderWaterFlowTest_GetNextSupplyedIndex_001
2144 * @tc.desc: Verify the function that return value of GetNextSupplyedIndex.
2145 * @tc.type: FUNC
2146 * @tc.require: issueI5TFPO
2147 */
2148 HWTEST_F(RenderWaterFlowTest, RenderWaterFlowTest_GetNextSupplyedIndex_001, TestSize.Level1)
2149 {
2150 CreateRenderWaterFlow("1fr 1fr", "1fr 1fr");
2151 CHECK_RENDERNODE_NULL_VOID(renderNode_);
2152 auto result = renderNode_->GetNextSupplyedIndex();
2153 EXPECT_EQ(result, 0);
2154 renderNode_->InitialFlowProp();
2155 auto itemIndex = renderNode_->GetNextSupplyedIndex();
2156 auto targetPos = renderNode_->GetTargetPos();
2157 renderNode_->SupplyItems(itemIndex, targetPos);
2158 result = renderNode_->GetNextSupplyedIndex();
2159 EXPECT_EQ(result, 8);
2160 }
2161
2162 /**
2163 * @tc.name: RenderWaterFlowTest_GetLastSupplyedMainSize_001
2164 * @tc.desc: Verify the function that return value of GetLastSupplyedMainSize.
2165 * @tc.type: FUNC
2166 * @tc.require: issueI5TFPO
2167 */
2168 HWTEST_F(RenderWaterFlowTest, RenderWaterFlowTest_GetLastSupplyedMainSize_001, TestSize.Level1)
2169 {
2170 CreateRenderWaterFlow("1fr 1fr", "1fr 1fr");
2171 CHECK_RENDERNODE_NULL_VOID(renderNode_);
2172 auto result = renderNode_->GetLastSupplyedMainSize();
2173 EXPECT_EQ(result, 0);
2174 renderNode_->InitialFlowProp();
2175 auto itemIndex = renderNode_->GetNextSupplyedIndex();
2176 auto targetPos = renderNode_->GetTargetPos();
2177 renderNode_->SupplyItems(itemIndex, targetPos);
2178 result = renderNode_->GetLastSupplyedMainSize();
2179 EXPECT_EQ(result, 900.0);
2180 }
2181
2182 /**
2183 * @tc.name: RenderWaterFlowTest_GetLastMainBlankPos_001
2184 * @tc.desc: Verify the function that change the return value of the parameter GetLastMainBlankPos.
2185 * @tc.type: FUNC
2186 * @tc.require: issueI5TFPO
2187 */
2188 HWTEST_F(RenderWaterFlowTest, RenderWaterFlowTest_GetLastMainBlankPos_001, TestSize.Level1)
2189 {
2190 for (size_t i = 0; i < CREATE_FLOWITEM_COUNT; i++) {
2191 renderNode_->mainSideEndPos_.emplace_back(START_POS + i);
2192 }
2193 for (size_t i = 0; i < CREATE_FLOWITEM_COUNT; i++) {
2194 renderNode_->crossSideSize_.emplace_back(START_POS + i);
2195 }
2196 auto result = renderNode_->GetLastMainBlankPos();
2197 EXPECT_EQ(result.GetY(), START_POS);
2198 }
2199
2200 /**
2201 * @tc.name: RenderWaterFlowTest_GetLastMainBlankPos_002
2202 * @tc.desc: Verify the function that return value of GetLastMainBlankPos.
2203 * @tc.type: FUNC
2204 * @tc.require: issueI5TFPO
2205 */
2206 HWTEST_F(RenderWaterFlowTest, RenderWaterFlowTest_GetLastMainBlankPos_002, TestSize.Level1)
2207 {
2208 const double pos = 100.0;
2209 for (size_t i = 0; i < CREATE_FLOWITEM_COUNT; i++) {
2210 renderNode_->mainSideEndPos_.emplace_back(pos - i);
2211 }
2212 for (size_t i = 0; i < CREATE_FLOWITEM_COUNT; i++) {
2213 renderNode_->crossSideSize_.emplace_back(pos + i);
2214 }
2215 auto result = renderNode_->GetLastMainBlankPos();
2216 EXPECT_EQ(result.GetY(), pos - CREATE_FLOWITEM_COUNT + 1);
2217 }
2218
2219 /**
2220 * @tc.name: RenderWaterFlowTest_GetLastMainBlankCross_001
2221 * @tc.desc: Verify the function that return value of GetLastMainBlankCross.
2222 * @tc.type: FUNC
2223 * @tc.require: issueI5TFPO
2224 */
2225 HWTEST_F(RenderWaterFlowTest, RenderWaterFlowTest_GetLastMainBlankCross_001, TestSize.Level1)
2226 {
2227 const double pos = 4.0;
2228 for (size_t i = 0; i < CREATE_FLOWITEM_COUNT; i++) {
2229 renderNode_->mainSideEndPos_.emplace_back(pos - i);
2230 }
2231 auto result = renderNode_->GetLastMainBlankCross();
2232 EXPECT_EQ(result, pos);
2233 }
2234
2235 /**
2236 * @tc.name: RenderWaterFlowTest_GetLastMainBlankCross_002
2237 * @tc.desc: Verify the function that return value of GetLastMainBlankCross.
2238 * @tc.type: FUNC
2239 * @tc.require: issueI5TFPO
2240 */
2241 HWTEST_F(RenderWaterFlowTest, RenderWaterFlowTest_GetLastMainBlankCross_002, TestSize.Level2)
2242 {
2243 CHECK_RENDERNODE_NULL_VOID(renderNode_);
2244 EXPECT_TRUE(renderNode_->mainSideEndPos_.empty());
2245 auto result = renderNode_->GetLastMainBlankCross();
2246 EXPECT_EQ(result, 0);
2247 }
2248
2249 /**
2250 * @tc.name: RenderWaterFlowTest_GetLastMainBlankPos_001
2251 * @tc.desc: Verify the function that change the return value of the parameter GetLastMainPos.
2252 * @tc.type: FUNC
2253 * @tc.require: issueI5TFPO
2254 */
2255 HWTEST_F(RenderWaterFlowTest, RenderWaterFlowTest_GetLastMainPos_001, TestSize.Level1)
2256 {
2257 const double pos = 100.0;
2258 for (size_t i = 0; i < CREATE_FLOWITEM_COUNT; i++) {
2259 renderNode_->mainSideEndPos_.emplace_back(pos + i);
2260 }
2261 for (size_t i = 0; i < CREATE_FLOWITEM_COUNT; i++) {
2262 renderNode_->crossSideSize_.emplace_back(pos + i);
2263 }
2264 auto result = renderNode_->GetLastMainPos();
2265 EXPECT_EQ(result.GetY(), pos + CREATE_FLOWITEM_COUNT - 1);
2266 }
2267
2268 /**
2269 * @tc.name: RenderWaterFlowTest_GetLastMainBlankPos_002
2270 * @tc.desc: Verify the function that change the return value of the parameter GetLastMainPos.
2271 * @tc.type: FUNC
2272 * @tc.require: issueI5TFPO
2273 */
2274 HWTEST_F(RenderWaterFlowTest, RenderWaterFlowTest_GetLastMainPos_002, TestSize.Level1)
2275 {
2276 const double pos = 100.0;
2277 for (size_t i = 0; i < CREATE_FLOWITEM_COUNT; i++) {
2278 renderNode_->mainSideEndPos_.emplace_back(pos - i);
2279 }
2280 for (size_t i = 0; i < CREATE_FLOWITEM_COUNT; i++) {
2281 renderNode_->crossSideSize_.emplace_back(pos + i);
2282 }
2283 auto result = renderNode_->GetLastMainPos();
2284 EXPECT_EQ(result.GetY(), pos);
2285 }
2286 } // namespace OHOS::Ace
2287
2288