Swiper: UpdateOffsetAfterPropertyAnimation changes to use CreateLayoutTask interface to update layout

Signed-off-by: Hu_zq <huzeqi@huawei.com>
Change-Id: Ic2d205c5bacacedeadaaf5b7f38c46c40d3e2dc1
This commit is contained in:
Hu_zq 2024-08-11 00:05:14 +08:00
parent 2ec66c6736
commit 7aad44404f
2 changed files with 4 additions and 70 deletions

View File

@ -3133,10 +3133,10 @@ void SwiperPattern::PlayPropertyTranslateAnimation(
void SwiperPattern::UpdateOffsetAfterPropertyAnimation(float offset)
{
UpdateCurrentOffset(offset);
auto pipeline = PipelineContext::GetCurrentContext();
if (pipeline) {
pipeline->FlushUITasks();
}
auto host = GetHost();
CHECK_NULL_VOID(host);
host->SetLayoutDirtyMarked(true);
host->CreateLayoutTask();
}
void SwiperPattern::OnPropertyTranslateAnimationFinish(const OffsetF& offset)

View File

@ -1786,72 +1786,6 @@ HWTEST_F(SwiperTestNg, SwipeCaptureLayoutInfo001, TestSize.Level1)
}
}
/**
* @tc.name: SwipeCaptureLayoutInfo002
* @tc.desc: Test check itemPosition map info
* @tc.type: FUNC
*/
HWTEST_F(SwiperTestNg, SwipeCaptureLayoutInfo002, TestSize.Level1)
{
/**
* @tc.steps: step1. create swiper witch need the capture
*/
InitCaptureTest();
frameNode_->MarkDirtyNode(PROPERTY_UPDATE_MEASURE_SELF);
FlushLayoutTask(frameNode_);
/**
* @tc.steps: step2. capture in left, target index change to equal to first item index in itemPosition
* current index 0, target index to 0, 3'|3' 0 1 2 3|3 to 3'|3' 0 1 2 3|3
*/
pattern_->targetIndex_ = 0;
frameNode_->MarkDirtyNode(PROPERTY_UPDATE_MEASURE_SELF);
FlushLayoutTask(frameNode_);
EXPECT_EQ(pattern_->leftCaptureIndex_, 3);
auto leftCaptureNode = AceType::DynamicCast<FrameNode>(
frameNode_->GetChildAtIndex(frameNode_->GetChildIndexById(pattern_->GetLeftCaptureId())));
EXPECT_NE(leftCaptureNode, nullptr);
if (leftCaptureNode) {
auto size = leftCaptureNode->GetGeometryNode()->GetFrameRect();
auto offset = leftCaptureNode->GetGeometryNode()->GetFrameOffset();
EXPECT_EQ(offset.GetX(), CAPTURE_MARGIN_SIZE - size.Width());
}
/**
* @tc.steps: step3. capture in left, target index change to smaller than first item index in itemPosition
* current index 0, target index to -1, 3'|3' 0 1 2 3|3 to 3|3 0 1 2 3'|3'
*/
pattern_->targetIndex_ = -1;
frameNode_->MarkDirtyNode(PROPERTY_UPDATE_MEASURE_SELF);
FlushLayoutTask(frameNode_);
// isCaptureReverse_ change to true
EXPECT_TRUE(pattern_->isCaptureReverse_);
EXPECT_EQ(pattern_->leftCaptureIndex_, 3);
auto rightCaptureNode = AceType::DynamicCast<FrameNode>(
frameNode_->GetChildAtIndex(frameNode_->GetChildIndexById(pattern_->GetRightCaptureId())));
EXPECT_NE(rightCaptureNode, nullptr);
if (rightCaptureNode) {
auto offset = leftCaptureNode->GetGeometryNode()->GetFrameOffset();
EXPECT_EQ(offset.GetX(), SWIPER_WIDTH - CAPTURE_MARGIN_SIZE);
}
/**
* @tc.steps: step4. capture in left, target index change to larger than first item index in itemPosition
* current index 0, target index to 1, 3|3 0 1 2 3'|3' to 3'|3' 0 1 2 3|3
*/
pattern_->targetIndex_ = 1;
frameNode_->MarkDirtyNode(PROPERTY_UPDATE_MEASURE_SELF);
FlushLayoutTask(frameNode_);
// isCaptureReverse_ change to true
EXPECT_FALSE(pattern_->isCaptureReverse_);
EXPECT_EQ(pattern_->leftCaptureIndex_, 3);
leftCaptureNode = AceType::DynamicCast<FrameNode>(
frameNode_->GetChildAtIndex(frameNode_->GetChildIndexById(pattern_->GetLeftCaptureId())));
EXPECT_NE(leftCaptureNode, nullptr);
if (leftCaptureNode) {
auto size = leftCaptureNode->GetGeometryNode()->GetFrameRect();
auto offset = leftCaptureNode->GetGeometryNode()->GetFrameOffset();
EXPECT_EQ(offset.GetX(), CAPTURE_MARGIN_SIZE - size.Width());
}
}
/**
* @tc.name: FadeOverScroll001
* @tc.desc: Test SwiperPattern FadeOverScroll