diff --git a/frameworks/core/components_ng/pattern/swiper/swiper_pattern.cpp b/frameworks/core/components_ng/pattern/swiper/swiper_pattern.cpp index 3b1b4881cc3e29287281dfaf4bdde11452a735ee..e4dda6b70198ce9cc813a5258fa1495affdca0e2 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 788ad7c555b9ce5e89df6ac0fefd3543c4d017ec..d02efec6f309f4606b44cd3ddc9d50be43872e3f 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 a9df43cd5e18536fad9f8394570692b594e7a5ed..c6b544eb1bbd6ee47737a0298c540c3d342e437d 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 2fb215a04a1beb4b2659c40a5e3fd102e716d7e2..56a71e931f1118fef10636cb96b7116666feb6d5 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