From: ANZ1217 Date: Wed, 11 Sep 2024 09:59:25 +0000 (+0900) Subject: [Tizen] Fix background color does not change when background markup is changed X-Git-Tag: accepted/tizen/7.0/unified/20240924.164220~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8cdb3b0f0ba991f81d47f78bf4a4017b51e33b86;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git [Tizen] Fix background color does not change when background markup is changed Change-Id: I53d2e081f8963f113033b4e7f6c01a8040e6f555 --- diff --git a/automated-tests/src/dali-toolkit-internal/utc-Dali-TextField-internal.cpp b/automated-tests/src/dali-toolkit-internal/utc-Dali-TextField-internal.cpp index 06eefbc356..ffb5a9d3d1 100644 --- a/automated-tests/src/dali-toolkit-internal/utc-Dali-TextField-internal.cpp +++ b/automated-tests/src/dali-toolkit-internal/utc-Dali-TextField-internal.cpp @@ -51,6 +51,9 @@ int UtcDaliTextFieldMultipleBackgroundText(void) ControllerPtr controller = textFieldImpl.GetTextController(); Controller::Impl& controllerImpl = Controller::Impl::GetImplementation(*controller.Get()); + // Check the case where there is only one character in the text + controller->SetText("S"); + // Add multiple background colors for the text. ColorRun backgroundColorRun1; backgroundColorRun1.characterRun.characterIndex = 0u; @@ -70,19 +73,16 @@ int UtcDaliTextFieldMultipleBackgroundText(void) backgroundColorRun3.color = Color::GREEN; controllerImpl.mModel->mLogicalModel->mBackgroundColorRuns.PushBack(backgroundColorRun3); - // Check the case where there is only one character in the text - controller->SetText("S"); - application.SendNotification(); application.Render(); // The offscreen root actor should have one child: the renderable. Actor stencil = textField.GetChildAt(0u); - DALI_TEST_CHECK(stencil.GetChildCount() == 1u); + DALI_TEST_EQUALS(stencil.GetChildCount(), 1u, TEST_LOCATION); // The renderable actor should have two children: the text and the background. Actor renderableActor = stencil.GetChildAt(0u); - DALI_TEST_CHECK(renderableActor.GetChildCount() == 2u); + DALI_TEST_EQUALS(renderableActor.GetChildCount(), 2u, TEST_LOCATION); // Check that the background is created Actor backgroundActor = renderableActor.GetChildAt(0u); @@ -92,6 +92,14 @@ int UtcDaliTextFieldMultipleBackgroundText(void) // Change the text to contain more characters controller->SetText("Text Multiple Background Test"); + // After SetText, BackgroundColorRun should be empty. + DALI_TEST_CHECK(controllerImpl.mModel->mLogicalModel->mBackgroundColorRuns.Empty()); + + // Add multiple background colors for the text. + controllerImpl.mModel->mLogicalModel->mBackgroundColorRuns.PushBack(backgroundColorRun1); + controllerImpl.mModel->mLogicalModel->mBackgroundColorRuns.PushBack(backgroundColorRun2); + controllerImpl.mModel->mLogicalModel->mBackgroundColorRuns.PushBack(backgroundColorRun3); + application.SendNotification(); application.Render(); @@ -102,9 +110,9 @@ int UtcDaliTextFieldMultipleBackgroundText(void) application.Render(); // Now the offscreen root actor should have four children: the renderable, the clipped cursor, the highlight, and the background. - DALI_TEST_CHECK(stencil.GetChildCount() == 4u); + DALI_TEST_EQUALS(stencil.GetChildCount(), 4u, TEST_LOCATION); // The renderable actor should have one child only: the text - DALI_TEST_CHECK(renderableActor.GetChildCount() == 1u); + DALI_TEST_EQUALS(renderableActor.GetChildCount(), 1u, TEST_LOCATION); // The background should now be lowered below the highlight backgroundActor = stencil.GetChildAt(0u); diff --git a/dali-toolkit/internal/text/controller/text-controller-impl.cpp b/dali-toolkit/internal/text/controller/text-controller-impl.cpp index a173bb2b71..146d17d696 100644 --- a/dali-toolkit/internal/text/controller/text-controller-impl.cpp +++ b/dali-toolkit/internal/text/controller/text-controller-impl.cpp @@ -2028,6 +2028,7 @@ void Controller::Impl::ClearFontData() void Controller::Impl::ClearStyleData() { mModel->mLogicalModel->mColorRuns.Clear(); + mModel->mLogicalModel->mBackgroundColorRuns.Clear(); mModel->mLogicalModel->ClearFontDescriptionRuns(); mModel->mLogicalModel->ClearStrikethroughRuns(); mModel->mLogicalModel->ClearUnderlineRuns();