From 42b2f1795fd34a15592f4b7297678cf2d7f5444d Mon Sep 17 00:00:00 2001 From: Hu_ZeQi Date: Sat, 13 Sep 2025 12:55:58 +0800 Subject: [PATCH] Swiper: add UpdateDragFRCSceneInfo trace Signed-off-by: Hu_ZeQi Change-Id: I4b8220fca122f68fa0db742ee7ac0674ef5d4470 --- .../pattern/swiper/swiper_pattern.cpp | 1 + .../overlength_dot_indicator_modifier.cpp | 5 ++- .../overlength_dot_indicator_modifier.h | 1 + ..._overlength_indicator_modifier_test_ng.cpp | 38 +++++++++++++++++++ 4 files changed, 43 insertions(+), 2 deletions(-) diff --git a/frameworks/core/components_ng/pattern/swiper/swiper_pattern.cpp b/frameworks/core/components_ng/pattern/swiper/swiper_pattern.cpp index 3b1b4881cc3..e4dda6b7019 100644 --- a/frameworks/core/components_ng/pattern/swiper/swiper_pattern.cpp +++ b/frameworks/core/components_ng/pattern/swiper/swiper_pattern.cpp @@ -3524,6 +3524,7 @@ void SwiperPattern::HandleDragEnd(double dragVelocity, float mainDelta) dragVelocity = 0.0; } if (!childScrolling_) { + ACE_SCOPED_TRACE("UpdateDragFRCSceneInfo END"); UpdateDragFRCSceneInfo(dragVelocity, SceneStatus::END); } diff --git a/frameworks/core/components_ng/pattern/swiper_indicator/dot_indicator/overlength_dot_indicator_modifier.cpp b/frameworks/core/components_ng/pattern/swiper_indicator/dot_indicator/overlength_dot_indicator_modifier.cpp index 788ad7c555b..d02efec6f30 100644 --- a/frameworks/core/components_ng/pattern/swiper_indicator/dot_indicator/overlength_dot_indicator_modifier.cpp +++ b/frameworks/core/components_ng/pattern/swiper_indicator/dot_indicator/overlength_dot_indicator_modifier.cpp @@ -60,6 +60,7 @@ void OverlengthDotIndicatorModifier::onDraw(DrawingContext& context) PaintBackground(context, contentProperty, maxDisplayCount_, isBindIndicator_); PaintContent(context, contentProperty); + isDrawbackground_ = false; } void OverlengthDotIndicatorModifier::PaintBackground( @@ -176,8 +177,8 @@ void OverlengthDotIndicatorModifier::PaintBlackPoint(DrawingContext& context, Co // new point color paintColor = paintColor.BlendOpacity(contentProperty.newPointOpacity / FULL_ALPHA); } - if (center.GetX() - width * HALF_FLOAT > backgroundStart_ && - center.GetX() + width * HALF_FLOAT < backgroundEnd_) { + if (isDrawbackground_ || (center.GetX() - width * HALF_FLOAT > backgroundStart_ && + center.GetX() + width * HALF_FLOAT < backgroundEnd_)) { PaintUnselectedIndicator(canvas, center, width, height, LinearColor(paintColor)); } } diff --git a/frameworks/core/components_ng/pattern/swiper_indicator/dot_indicator/overlength_dot_indicator_modifier.h b/frameworks/core/components_ng/pattern/swiper_indicator/dot_indicator/overlength_dot_indicator_modifier.h index a9df43cd5e1..c6b544eb1bb 100644 --- a/frameworks/core/components_ng/pattern/swiper_indicator/dot_indicator/overlength_dot_indicator_modifier.h +++ b/frameworks/core/components_ng/pattern/swiper_indicator/dot_indicator/overlength_dot_indicator_modifier.h @@ -282,6 +282,7 @@ private: bool isAutoPlay_ = false; bool isBindIndicator_ = false; bool isLoop_ = true; + bool isDrawbackground_ = false; ACE_DISALLOW_COPY_AND_MOVE(OverlengthDotIndicatorModifier); }; } // namespace OHOS::Ace::NG diff --git a/test/unittest/core/pattern/swiper/swiper_overlength_indicator_modifier_test_ng.cpp b/test/unittest/core/pattern/swiper/swiper_overlength_indicator_modifier_test_ng.cpp index 2fb215a04a1..56a71e931f1 100644 --- a/test/unittest/core/pattern/swiper/swiper_overlength_indicator_modifier_test_ng.cpp +++ b/test/unittest/core/pattern/swiper/swiper_overlength_indicator_modifier_test_ng.cpp @@ -761,6 +761,44 @@ HWTEST_F(SwiperOverLengthIndicatorModifierTestNg, SwiperOverLengthIndicatorGetCo 0.001f); } +/** + * @tc.name: OverlengthDotIndicatorModifier019 + * @tc.desc: Test the PaintBlackPoint method + * @tc.type: FUNC + */ +HWTEST_F(SwiperOverLengthIndicatorModifierTestNg, OverlengthDotIndicatorModifier019, TestSize.Level1) +{ + /** + * @tc.steps: step1. Set OverlengthDotIndicatorModifier attributes and ContentProperty attributes + * @tc.expected: attributes set successfully + */ + DotIndicatorModifier::ContentProperty contentProperty; + contentProperty.vectorBlackPointCenterX = { 100.0f, 200.0f, 300.0f }; + auto vXSize = contentProperty.vectorBlackPointCenterX.size(); + Testing::MockCanvas canvas; + EXPECT_CALL(canvas, AttachBrush(_)).Times(AtMost(vXSize * 2)).WillRepeatedly(ReturnRef(canvas)); + EXPECT_CALL(canvas, DetachBrush()).Times(AtMost(vXSize * 2)).WillRepeatedly(ReturnRef(canvas)); + DrawingContext context { canvas, 100.f, 100.f }; + auto indicatorModifier = AceType::MakeRefPtr(); + indicatorModifier->backgroundStart_ = 50.0f; + indicatorModifier->backgroundEnd_ = 350.0f; + /** + * @tc.steps: step2. Set NearEqual(width, height) and isCustomSize_ true + * @tc.expected: Verify the result and result should be as expected + */ + contentProperty.unselectedIndicatorWidth = { 200.0f, 200.0f, 200.0f }; + contentProperty.unselectedIndicatorHeight = { 200.0f, 200.0f, 200.0f }; + indicatorModifier->isCustomSize_ = true; + indicatorModifier->PaintBlackPoint(context, contentProperty); + + /** + * @tc.steps: step3. Set NearEqual(width, height) and isCustomSize_ false + * @tc.expected: Verify the result and result should be as expected + */ + indicatorModifier->isDrawbackground_ = true; + indicatorModifier->PaintBlackPoint(context, contentProperty); +} + /** * @tc.name: CalcTargetSelectedIndexOnBackward001 * @tc.desc: Test CalcTargetSelectedIndexOnBackward -- Gitee