2 * Copyright (c) 2022 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
21 #include <dali-toolkit-test-suite-utils.h>
22 #include <dali-toolkit/dali-toolkit.h>
24 #include <dali-toolkit/internal/controls/text-controls/text-label-impl.h>
25 #include <dali-toolkit/internal/text/rendering/text-typesetter.h>
26 #include <dali-toolkit/internal/text/rendering/view-model.h>
27 #include <dali-toolkit/internal/text/text-controller-impl.h>
28 #include <dali-toolkit/internal/text/text-controller.h>
31 using namespace Toolkit;
34 int UtcDaliTextLabelMarkupUnderline(void)
36 ToolkitTestApplication application;
37 tet_infoline(" UtcDaliTextLabelMarkupUnderline ");
39 TextLabel textLabel = TextLabel::New();
41 application.GetScene().Add(textLabel);
43 textLabel.SetProperty(TextLabel::Property::TEXT, "<u>ABC</u>EF<u>GH</u>");
44 textLabel.SetProperty(TextLabel ::Property::ENABLE_MARKUP, true);
46 application.SendNotification();
49 uint32_t expectedNumberOfUnderlineRuns = 2u;
51 Toolkit::Internal::TextLabel& textLabelImpl = GetImpl(textLabel);
52 const Text::Length numberOfUnderlineRuns = textLabelImpl.GetTextController()->GetTextModel()->GetNumberOfUnderlineRuns();
54 DALI_TEST_EQUALS(numberOfUnderlineRuns, expectedNumberOfUnderlineRuns, TEST_LOCATION);
56 Vector<UnderlinedGlyphRun> underlineRuns;
57 underlineRuns.Resize(numberOfUnderlineRuns);
58 textLabelImpl.GetTextController()->GetTextModel()->GetUnderlineRuns(underlineRuns.Begin(), 0u, numberOfUnderlineRuns);
61 DALI_TEST_EQUALS(underlineRuns[0u].glyphRun.glyphIndex, 0u, TEST_LOCATION);
62 DALI_TEST_EQUALS(underlineRuns[0u].glyphRun.numberOfGlyphs, 3u, TEST_LOCATION);
65 DALI_TEST_EQUALS(underlineRuns[1u].glyphRun.glyphIndex, 5u, TEST_LOCATION);
66 DALI_TEST_EQUALS(underlineRuns[1u].glyphRun.numberOfGlyphs, 2u, TEST_LOCATION);
71 int UtcDaliTextLabelMarkupUnderlineAttributes(void)
73 ToolkitTestApplication application;
74 tet_infoline(" UtcDaliTextLabelMarkupUnderlineAttributes ");
76 TextLabel textLabel = TextLabel::New();
78 application.GetScene().Add(textLabel);
80 std::string testText =
81 "start<u>ABC1</u>then"
82 "<u type='solid'>ABC2</u>then"
83 "<u type='dashed'>ABC3</u>then"
84 "<u type='double'>ABC4</u>then"
85 "<u color='green'>ABC5</u>then"
86 "<u height='5.0f'>ABC6</u>then"
87 "<u type='dashed' dash-gap='3.0f'>ABC7</u>then"
88 "<u type='dashed' dash-width='4.0f'>ABC8</u>then"
89 "<u color='blue' type='dashed' height='4.0f' dash-gap='2.0f' dash-width='3.0f'>ABC9</u>end"
93 textLabel.SetProperty(TextLabel::Property::TEXT, testText);
94 textLabel.SetProperty(TextLabel ::Property::ENABLE_MARKUP, true);
96 application.SendNotification();
99 const uint32_t expectedNumberOfUnderlineRuns = 9u;
101 Toolkit::Internal::TextLabel& textLabelImpl = GetImpl(textLabel);
102 const Text::Length numberOfUnderlineRuns = textLabelImpl.GetTextController()->GetTextModel()->GetNumberOfUnderlineRuns();
104 DALI_TEST_EQUALS(numberOfUnderlineRuns, expectedNumberOfUnderlineRuns, TEST_LOCATION);
106 Vector<UnderlinedGlyphRun> underlineRuns;
107 underlineRuns.Resize(numberOfUnderlineRuns);
108 textLabelImpl.GetTextController()->GetTextModel()->GetUnderlineRuns(underlineRuns.Begin(), 0u, numberOfUnderlineRuns);
113 GlyphIndex glyphIndex;
114 Length numberOfGlyphs;
115 UnderlineStyleProperties properties;
124 Text::Underline::SOLID,
136 //<u type='solid'>ABC2</u>
137 {"<u type='solid'>ABC2</u>",
141 Text::Underline::SOLID,
153 //<u type='dashed'>ABC3</u>
154 {"<u type='dashed'>ABC3</u>",
158 Text::Underline::DASHED,
170 //<u type='double'>ABC4</u>
171 {"<u type='double'>ABC4</u>",
175 Text::Underline::DOUBLE,
187 //<u color='green'>ABC5</u>
188 {"<u color='green'>ABC5</u>",
192 Text::Underline::SOLID,
204 //<u height='5.0f'>ABC6</u>
205 {"<u height='5.0f'>ABC6</u>",
209 Text::Underline::SOLID,
221 //<u type='dashed' dash-gap='3.0f'>ABC7</u>
222 {"<u type='dashed' dash-gap='3.0f'>ABC7</u>",
226 Text::Underline::DASHED,
238 //<u type='dashed' dash-width='4.0f'>ABC8</u>
239 {"<u type='dashed' dash-width='4.0f'>ABC8</u>",
243 Text::Underline::DASHED,
255 //<u color='blue' type='dashed' height='4.0f' dash-gap='2.0f' dash-width='3.0f'>
256 {"<u color='blue' type='dashed' height='4.0f' dash-gap='2.0f' dash-width='3.0f'>",
260 Text::Underline::DASHED,
274 for(uint32_t i = 0; i < expectedNumberOfUnderlineRuns; i++)
276 tet_infoline(data[i].title.c_str());
277 DALI_TEST_EQUALS(underlineRuns[i].glyphRun.glyphIndex, data[i].glyphIndex, TEST_LOCATION);
278 DALI_TEST_EQUALS(underlineRuns[i].glyphRun.numberOfGlyphs, data[i].numberOfGlyphs, TEST_LOCATION);
279 DALI_TEST_CHECK(data[i].properties == underlineRuns[i].properties);
285 int UtcDaliTextLabelMarkupSpanUnderline(void)
287 ToolkitTestApplication application;
288 tet_infoline(" UtcDaliTextLabelMarkupSpanUnderline ");
290 TextLabel textLabel = TextLabel::New();
292 application.GetScene().Add(textLabel);
294 std::string testText =
295 "start<span font-size='45' font-family='DejaVu Sans' font-width='condensed' font-slant='italic' text-color='red'>ABC1</span>then"
296 "<span font-size='45' font-family='DejaVu Sans' font-width='condensed' font-slant='italic' text-color='red' u-type='solid'>ABC2</span>then"
297 "<span font-size='45' font-family='DejaVu Sans' font-width='condensed' font-slant='italic' text-color='red' u-type='dashed'>ABC3</span>then"
298 "<span font-size='45' font-family='DejaVu Sans' font-width='condensed' font-slant='italic' text-color='red' u-type='double'>ABC4</span>then"
299 "<span font-size='45' font-family='DejaVu Sans' font-width='condensed' font-slant='italic' text-color='red' u-color='green'>ABC5</span>then"
300 "<span font-size='45' font-family='DejaVu Sans' font-width='condensed' font-slant='italic' text-color='red' u-height='5.0f'>ABC6</span>then"
301 "<span font-size='45' font-family='DejaVu Sans' font-width='condensed' font-slant='italic' text-color='red' u-type='dashed' u-dash-gap='3.0f'>ABC7</span>then"
302 "<span font-size='45' font-family='DejaVu Sans' font-width='condensed' font-slant='italic' text-color='red' u-type='dashed' u-dash-width='4.0f'>ABC8</span>then"
303 "<span font-size='45' font-family='DejaVu Sans' font-width='condensed' font-slant='italic' text-color='red' u-color='blue' u-type='dashed' u-height='4.0f' u-dash-gap='2.0f' u-dash-width='3.0f'>ABC9</span>end";
305 textLabel.SetProperty(TextLabel::Property::TEXT, testText);
306 textLabel.SetProperty(TextLabel ::Property::ENABLE_MARKUP, true);
308 application.SendNotification();
309 application.Render();
311 const uint32_t expectedNumberOfUnderlineRuns = 8u;
313 Toolkit::Internal::TextLabel& textLabelImpl = GetImpl(textLabel);
314 const Text::Length numberOfUnderlineRuns = textLabelImpl.GetTextController()->GetTextModel()->GetNumberOfUnderlineRuns();
316 DALI_TEST_EQUALS(numberOfUnderlineRuns, expectedNumberOfUnderlineRuns, TEST_LOCATION);
318 Vector<UnderlinedGlyphRun> underlineRuns;
319 underlineRuns.Resize(numberOfUnderlineRuns);
320 textLabelImpl.GetTextController()->GetTextModel()->GetUnderlineRuns(underlineRuns.Begin(), 0u, numberOfUnderlineRuns);
325 GlyphIndex glyphIndex;
326 Length numberOfGlyphs;
327 UnderlineStyleProperties properties;
331 //<u type='solid'>ABC2</u>
332 {"<span font-size='45' font-family='DejaVu Sans' font-width='condensed' font-slant='italic' text-color='red' u-type='solid'>ABC2</span>",
336 Text::Underline::SOLID,
348 //<u type='dashed'>ABC3</u>
349 {"<span font-size='45' font-family='DejaVu Sans' font-width='condensed' font-slant='italic' text-color='red' u-type='dashed'>ABC3</span>",
353 Text::Underline::DASHED,
365 //<u type='double'>ABC4</u>
366 {"<span font-size='45' font-family='DejaVu Sans' font-width='condensed' font-slant='italic' text-color='red' u-type='double'>ABC4</span>",
370 Text::Underline::DOUBLE,
382 //<u color='green'>ABC5</u>
383 {"<span font-size='45' font-family='DejaVu Sans' font-width='condensed' font-slant='italic' text-color='red' u-color='green'>ABC5</span>",
387 Text::Underline::SOLID,
399 //<u height='5.0f'>ABC6</u>
400 {"<span font-size='45' font-family='DejaVu Sans' font-width='condensed' font-slant='italic' text-color='red' u-height='5.0f'>ABC6</span>",
404 Text::Underline::SOLID,
416 //<u type='dashed' dash-gap='3.0f'>ABC7</u>
417 {"<span font-size='45' font-family='DejaVu Sans' font-width='condensed' font-slant='italic' text-color='red' u-type='dashed' u-dash-gap='3.0f'>ABC7</span>",
421 Text::Underline::DASHED,
433 //<u type='dashed' dash-width='4.0f'>ABC8</u>
434 {"<span font-size='45' font-family='DejaVu Sans' font-width='condensed' font-slant='italic' text-color='red' u-type='dashed' u-dash-width='4.0f'>ABC8</span>",
438 Text::Underline::DASHED,
450 //<u color='blue' type='dashed' height='4.0f' dash-gap='2.0f' dash-width='3.0f'>
451 {"<span font-size='45' font-family='DejaVu Sans' font-width='condensed' font-slant='italic' text-color='red' u-color='blue' u-type='dashed' u-height='4.0f' u-dash-gap='2.0f' u-dash-width='3.0f'>ABC9</span>",
455 Text::Underline::DASHED,
469 for(uint32_t i = 0; i < expectedNumberOfUnderlineRuns; i++)
471 tet_infoline(data[i].title.c_str());
472 DALI_TEST_EQUALS(underlineRuns[i].glyphRun.glyphIndex, data[i].glyphIndex, TEST_LOCATION);
473 DALI_TEST_EQUALS(underlineRuns[i].glyphRun.numberOfGlyphs, data[i].numberOfGlyphs, TEST_LOCATION);
474 DALI_TEST_CHECK(data[i].properties == underlineRuns[i].properties);
480 int UtcDaliTextLabelMarkupNestedUnderlineTags(void)
482 ToolkitTestApplication application;
483 tet_infoline(" UtcDaliTextLabelMarkupNestedUnderlineTags ");
485 TextLabel textLabel = TextLabel::New();
487 application.GetScene().Add(textLabel);
489 std::string testText = "start<u height='5.0f' color='green' >AB<u color='blue' >XYZ</u>CDE</u>end";
491 textLabel.SetProperty(TextLabel::Property::TEXT, testText);
492 textLabel.SetProperty(TextLabel ::Property::ENABLE_MARKUP, true);
494 application.SendNotification();
495 application.Render();
497 const uint32_t expectedNumberOfUnderlineRuns = 2u;
499 Toolkit::Internal::TextLabel& textLabelImpl = GetImpl(textLabel);
500 const Text::Length numberOfUnderlineRuns = textLabelImpl.GetTextController()->GetTextModel()->GetNumberOfUnderlineRuns();
502 DALI_TEST_EQUALS(numberOfUnderlineRuns, expectedNumberOfUnderlineRuns, TEST_LOCATION);
504 Vector<UnderlinedGlyphRun> underlineRuns;
505 underlineRuns.Resize(numberOfUnderlineRuns);
506 textLabelImpl.GetTextController()->GetTextModel()->GetUnderlineRuns(underlineRuns.Begin(), 0u, numberOfUnderlineRuns);
511 GlyphIndex glyphIndex;
512 Length numberOfGlyphs;
513 UnderlineStyleProperties properties;
518 {"<u height='5.0f' color='green' >AB<u color='blue' >XYZ</u>CDE</u>",
522 Text::Underline::SOLID,
535 {"<u color='blue' >XYZ</u>",
539 Text::Underline::SOLID,
553 for(uint32_t i = 0; i < expectedNumberOfUnderlineRuns; i++)
555 tet_infoline(data[i].title.c_str());
556 DALI_TEST_EQUALS(underlineRuns[i].glyphRun.glyphIndex, data[i].glyphIndex, TEST_LOCATION);
557 DALI_TEST_EQUALS(underlineRuns[i].glyphRun.numberOfGlyphs, data[i].numberOfGlyphs, TEST_LOCATION);
558 DALI_TEST_CHECK(data[i].properties == underlineRuns[i].properties);
564 int UtcDaliTextLabelBackgroundTag(void)
566 ToolkitTestApplication application;
567 tet_infoline("UtcDaliTextLabelBackgroundTag\n");
569 TextLabel label = TextLabel::New();
570 DALI_TEST_CHECK(label);
572 label.SetProperty(TextLabel ::Property::ENABLE_MARKUP, true);
573 label.SetProperty(TextLabel::Property::TEXT, "H<background color='red'>e</background> Worl<background color='yellow'>d</background>");
574 application.GetScene().Add(label);
575 application.SendNotification();
576 application.Render();
578 Toolkit::Internal::TextLabel& labelImpl = GetImpl(label);
579 const ColorIndex* const backgroundColorIndicesBuffer = labelImpl.GetTextController()->GetTextModel()->GetBackgroundColorIndices();
581 DALI_TEST_CHECK(backgroundColorIndicesBuffer);
584 DALI_TEST_EQUALS(backgroundColorIndicesBuffer[0], 0u, TEST_LOCATION);
587 DALI_TEST_EQUALS(backgroundColorIndicesBuffer[1], 1u, TEST_LOCATION);
590 DALI_TEST_EQUALS(backgroundColorIndicesBuffer[7], 2u, TEST_LOCATION);
595 int UtcDaliTextLabelSpanBackgroundTag(void)
597 ToolkitTestApplication application;
598 tet_infoline("UtcDaliTextLabelSpanBackgroundTag\n");
600 TextLabel label = TextLabel::New();
601 DALI_TEST_CHECK(label);
603 label.SetProperty(TextLabel ::Property::ENABLE_MARKUP, true);
604 label.SetProperty(TextLabel::Property::TEXT, "H<span background-color='red'>e</span> Worl<span background-color='yellow'>d</span>");
605 application.GetScene().Add(label);
606 application.SendNotification();
607 application.Render();
609 Toolkit::Internal::TextLabel& labelImpl = GetImpl(label);
610 const ColorIndex* const backgroundColorIndicesBuffer = labelImpl.GetTextController()->GetTextModel()->GetBackgroundColorIndices();
612 DALI_TEST_CHECK(backgroundColorIndicesBuffer);
615 DALI_TEST_EQUALS(backgroundColorIndicesBuffer[0], 0u, TEST_LOCATION);
618 DALI_TEST_EQUALS(backgroundColorIndicesBuffer[1], 1u, TEST_LOCATION);
621 DALI_TEST_EQUALS(backgroundColorIndicesBuffer[7], 2u, TEST_LOCATION);
626 int UtcDaliToolkitTextlabelEllipsisInternalAPIs(void)
628 ToolkitTestApplication application;
629 tet_infoline(" UtcDaliToolkitTextlabelEllipsisInternalAPIs ");
630 TextLabel textLabel = TextLabel::New();
632 Toolkit::Internal::TextLabel& textLabelImpl = GetImpl(textLabel);
633 const ModelInterface* const textModel = textLabelImpl.GetTextController()->GetTextModel();
635 tet_infoline(" UtcDaliToolkitTextlabelEllipsisInternalAPIs - ELLIPSIS Disabled");
636 textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS, false);
637 DALI_TEST_EQUALS(textLabel.GetProperty<bool>(DevelTextLabel::Property::ELLIPSIS), false, TEST_LOCATION);
638 DALI_TEST_CHECK(!(textModel->IsTextElideEnabled()));
640 tet_infoline(" UtcDaliToolkitTextlabelEllipsisInternalAPIs - ELLIPSIS Enabled");
641 textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS, true);
642 DALI_TEST_EQUALS(textLabel.GetProperty<bool>(DevelTextLabel::Property::ELLIPSIS), true, TEST_LOCATION);
643 DALI_TEST_CHECK(textModel->IsTextElideEnabled());
645 tet_infoline(" UtcDaliToolkitTextlabelEllipsisInternalAPIs - GetStartIndexOfElidedGlyphs Default");
646 DALI_TEST_EQUALS(textModel->GetStartIndexOfElidedGlyphs(), 0u, TEST_LOCATION);
648 tet_infoline(" UtcDaliToolkitTextlabelEllipsisInternalAPIs - GetEndIndexOfElidedGlyphs Default");
649 DALI_TEST_EQUALS(textModel->GetEndIndexOfElidedGlyphs(), 0u, TEST_LOCATION);
651 tet_infoline(" UtcDaliToolkitTextlabelEllipsisInternalAPIs - GetFirstMiddleIndexOfElidedGlyphs Default");
652 DALI_TEST_EQUALS(textModel->GetFirstMiddleIndexOfElidedGlyphs(), 0u, TEST_LOCATION);
654 tet_infoline(" UtcDaliToolkitTextlabelEllipsisInternalAPIs - GetSecondMiddleIndexOfElidedGlyphs Default");
655 DALI_TEST_EQUALS(textModel->GetSecondMiddleIndexOfElidedGlyphs(), 0u, TEST_LOCATION);
657 // Tests the rendering controller has been created.
658 TypesetterPtr typesetter = Typesetter::New(textModel);
659 DALI_TEST_CHECK(typesetter);
661 // Tests the view model has been created.
662 ViewModel* model = typesetter->GetViewModel();
664 tet_infoline(" UtcDaliToolkitTextlabelEllipsisInternalAPIs - IsTextElideEnabled ViewModel");
665 DALI_TEST_CHECK(model->IsTextElideEnabled());
667 tet_infoline(" UtcDaliToolkitTextlabelEllipsisInternalAPIs - GetStartIndexOfElidedGlyphs ViewModel");
668 DALI_TEST_EQUALS(model->GetStartIndexOfElidedGlyphs(), 0u, TEST_LOCATION);
670 tet_infoline(" UtcDaliToolkitTextlabelEllipsisInternalAPIs - GetEndIndexOfElidedGlyphs ViewModel");
671 DALI_TEST_EQUALS(model->GetEndIndexOfElidedGlyphs(), 0u, TEST_LOCATION);
673 tet_infoline(" UtcDaliToolkitTextlabelEllipsisInternalAPIs - GetFirstMiddleIndexOfElidedGlyphs ViewModel");
674 DALI_TEST_EQUALS(model->GetFirstMiddleIndexOfElidedGlyphs(), 0u, TEST_LOCATION);
676 tet_infoline(" UtcDaliToolkitTextlabelEllipsisInternalAPIs - GetSecondMiddleIndexOfElidedGlyphs ViewModel");
677 DALI_TEST_EQUALS(model->GetSecondMiddleIndexOfElidedGlyphs(), 0u, TEST_LOCATION);
681 int UtcDaliTextLabelTextWithSpan(void)
683 ToolkitTestApplication application;
684 tet_infoline("UtcDaliTextLabelTextWithSpan\n");
686 TextLabel label = TextLabel::New();
687 DALI_TEST_CHECK(label);
689 label.SetProperty(TextLabel ::Property::ENABLE_MARKUP, true);
690 label.SetProperty(TextLabel::Property::TEXT, "Hello Span");
691 application.GetScene().Add(label);
693 application.SendNotification();
694 application.Render();
696 Vector3 originalSize = label.GetNaturalSize();
697 label.SetProperty(TextLabel::Property::TEXT, "H<span font-size='45' font-family='DejaVu Sans' font-width='condensed' font-slant='italic' text-color='red'>ello</span> Span");
699 application.SendNotification();
700 application.Render();
702 Vector3 spanSize = label.GetNaturalSize();
704 DALI_TEST_GREATER(spanSize.width, originalSize.width, TEST_LOCATION);
706 Toolkit::Internal::TextLabel& labelImpl = GetImpl(label);
707 const ColorIndex* const colorIndicesBuffer1 = labelImpl.GetTextController()->GetTextModel()->GetColorIndices();
709 DALI_TEST_CHECK(colorIndicesBuffer1);
712 DALI_TEST_EQUALS(colorIndicesBuffer1[0], 0u, TEST_LOCATION);
715 DALI_TEST_EQUALS(colorIndicesBuffer1[1], 1u, TEST_LOCATION);
718 DALI_TEST_EQUALS(colorIndicesBuffer1[6], 0u, TEST_LOCATION);
720 label.SetProperty(TextLabel::Property::TEXT, "<span font-size='45'>H</span>ello <span text-color='red'>S</span>pan");
722 application.SendNotification();
723 application.Render();
725 const ColorIndex* const colorIndicesBuffer2 = labelImpl.GetTextController()->GetTextModel()->GetColorIndices();
727 DALI_TEST_CHECK(colorIndicesBuffer2);
730 DALI_TEST_EQUALS(colorIndicesBuffer2[0], 0u, TEST_LOCATION);
733 DALI_TEST_EQUALS(colorIndicesBuffer2[1], 0u, TEST_LOCATION);
736 DALI_TEST_EQUALS(colorIndicesBuffer2[6], 1u, TEST_LOCATION);
739 DALI_TEST_EQUALS(colorIndicesBuffer2[7], 0u, TEST_LOCATION);
744 int UtcDaliTextLabelMarkupStrikethrough(void)
746 ToolkitTestApplication application;
747 tet_infoline(" UtcDaliTextLabelMarkupStrikethrough ");
749 TextLabel textLabel = TextLabel::New();
751 application.GetScene().Add(textLabel);
753 textLabel.SetProperty(TextLabel::Property::TEXT, "<s color='red'>ABC</s>EF<s color='green'>GH</s>");
754 textLabel.SetProperty(TextLabel ::Property::ENABLE_MARKUP, true);
756 application.SendNotification();
757 application.Render();
759 uint32_t expectedNumberOfStrikethroughGlyphs = 2u;
761 Toolkit::Internal::TextLabel& textLabelImpl = GetImpl(textLabel);
762 const Text::Length numberOfStrikethroughRuns = textLabelImpl.GetTextController()->GetTextModel()->GetNumberOfStrikethroughRuns();
764 DALI_TEST_EQUALS(numberOfStrikethroughRuns, expectedNumberOfStrikethroughGlyphs, TEST_LOCATION);
766 Vector<StrikethroughGlyphRun> strikethroughRuns;
767 strikethroughRuns.Resize(numberOfStrikethroughRuns);
768 textLabelImpl.GetTextController()->GetTextModel()->GetStrikethroughRuns(strikethroughRuns.Begin(), 0u, numberOfStrikethroughRuns);
770 //ABC have strikethrough
771 DALI_TEST_EQUALS(strikethroughRuns[0u].glyphRun.glyphIndex, 0u, TEST_LOCATION);
772 DALI_TEST_EQUALS(strikethroughRuns[0u].glyphRun.numberOfGlyphs, 3u, TEST_LOCATION);
773 DALI_TEST_CHECK(strikethroughRuns[0u].isColorSet);
774 DALI_TEST_EQUALS(strikethroughRuns[0u].color.r, 1u, TEST_LOCATION);
775 DALI_TEST_EQUALS(strikethroughRuns[0u].color.g, 0u, TEST_LOCATION);
776 DALI_TEST_EQUALS(strikethroughRuns[0u].color.b, 0u, TEST_LOCATION);
778 //GH have strikethrough
779 DALI_TEST_EQUALS(strikethroughRuns[1u].glyphRun.glyphIndex, 5u, TEST_LOCATION);
780 DALI_TEST_EQUALS(strikethroughRuns[1u].glyphRun.numberOfGlyphs, 2u, TEST_LOCATION);
781 DALI_TEST_CHECK(strikethroughRuns[1u].isColorSet);
782 DALI_TEST_EQUALS(strikethroughRuns[1u].color.r, 0u, TEST_LOCATION);
783 DALI_TEST_EQUALS(strikethroughRuns[1u].color.g, 1u, TEST_LOCATION);
784 DALI_TEST_EQUALS(strikethroughRuns[1u].color.b, 0u, TEST_LOCATION);
789 int UtcDaliTextLabelMarkupStrikethroughNoEndTag(void)
791 ToolkitTestApplication application;
792 tet_infoline(" UtcDaliTextLabelMarkupStrikethroughNoEndTag ");
794 TextLabel textLabel = TextLabel::New();
796 application.GetScene().Add(textLabel);
798 textLabel.SetProperty(TextLabel::Property::TEXT, "<s>ABC");
799 textLabel.SetProperty(TextLabel ::Property::ENABLE_MARKUP, true);
801 application.SendNotification();
802 application.Render();
804 uint32_t expectedNumberOfStrikethroughGlyphs = 0u;
806 Toolkit::Internal::TextLabel& textLabelImpl = GetImpl(textLabel);
807 Text::Length numberOfStrikethroughRuns = textLabelImpl.GetTextController()->GetTextModel()->GetNumberOfStrikethroughRuns();
809 DALI_TEST_EQUALS(numberOfStrikethroughRuns, expectedNumberOfStrikethroughGlyphs, TEST_LOCATION);
814 int UtcDaliTextLabelMarkupParagraphTag(void)
817 ToolkitTestApplication application;
819 tet_infoline(" UtcDaliTextLabelMarkupParagraphTag ");
820 TextLabel textLabel = TextLabel::New();
822 application.GetScene().Add(textLabel);
824 textLabel.SetProperty(TextLabel::Property::TEXT, "text one <p>Paragraph two</p> text three <p>Paragraph four</p> text five");
825 textLabel.SetProperty(TextLabel ::Property::ENABLE_MARKUP, true);
826 textLabel.SetProperty(TextLabel::Property::MULTI_LINE, true);
828 application.SendNotification();
829 application.Render();
831 uint32_t expectedNumberOfBoundedParagraphRuns = 2u;
833 Toolkit::Internal::TextLabel& textLabelImpl = GetImpl(textLabel);
834 const Text::Length numberOfBoundedParagraphRuns = textLabelImpl.GetTextController()->GetTextModel()->GetNumberOfBoundedParagraphRuns();
835 DALI_TEST_EQUALS(numberOfBoundedParagraphRuns, expectedNumberOfBoundedParagraphRuns, TEST_LOCATION);
837 const Vector<BoundedParagraphRun>& boundedParagraphRuns = textLabelImpl.GetTextController()->GetTextModel()->GetBoundedParagraphRuns();
839 //<p>Paragraph two</p>
840 DALI_TEST_EQUALS(boundedParagraphRuns[0u].characterRun.characterIndex, 10u, TEST_LOCATION);
841 DALI_TEST_EQUALS(boundedParagraphRuns[0u].characterRun.numberOfCharacters, 14u, TEST_LOCATION);
843 //<p>Paragraph four</p>
844 DALI_TEST_EQUALS(boundedParagraphRuns[1u].characterRun.characterIndex, 37u, TEST_LOCATION);
845 DALI_TEST_EQUALS(boundedParagraphRuns[1u].characterRun.numberOfCharacters, 15u, TEST_LOCATION);
850 int UtcDaliTextLabelMarkupParagraphTagAlignAttribute(void)
852 ToolkitTestApplication application;
853 tet_infoline(" UtcDaliTextLabelMarkupParagraphTagAlignAttribute ");
855 // Apply alignment for each type on property level on three paragraphs and in-between text.
856 // Apply align in markup on the three paragraphs (each one a type).
857 // Using the same text to gain similar results from both the property level and the markup.
858 // Compare line alignment between the property level and the markup.
860 std::string textAlignOnPropertyLevel = "text outside<p>Paragraph end</p>text outside<p>Paragraph center</p>text outside<p>Paragraph begin</p><p>Paragraph property alignment</p>";
861 std::string textAlignInMarkup = "text outside<p align='end'>Paragraph end</p>text outside<p align='center'>Paragraph center</p>text outside<p align='begin' >Paragraph begin</p><p>Paragraph property alignment</p>";
863 //Set size to avoid automatic eliding
864 Vector2 controllerSize = Vector2(1025, 1025);
866 TextLabel textLabelBeginAlign = TextLabel::New();
867 TextLabel textLabelCenterAlign = TextLabel::New();
868 TextLabel textLabelEndAlign = TextLabel::New();
869 TextLabel textLabelMultiAlign = TextLabel::New();
871 application.GetScene().Add(textLabelBeginAlign);
872 application.GetScene().Add(textLabelCenterAlign);
873 application.GetScene().Add(textLabelEndAlign);
874 application.GetScene().Add(textLabelMultiAlign);
876 textLabelBeginAlign.SetProperty(TextLabel::Property::TEXT, textAlignOnPropertyLevel);
877 textLabelBeginAlign.SetProperty(TextLabel ::Property::ENABLE_MARKUP, true);
878 textLabelBeginAlign.SetProperty(TextLabel::Property::MULTI_LINE, true);
879 textLabelBeginAlign.SetProperty(TextLabel::Property::ELLIPSIS, false);
880 textLabelBeginAlign.SetProperty(TextLabel::Property::HORIZONTAL_ALIGNMENT, Dali::Toolkit::Text::HorizontalAlignment::BEGIN);
881 textLabelBeginAlign.SetProperty(Actor::Property::SIZE, controllerSize);
883 textLabelCenterAlign.SetProperty(TextLabel::Property::TEXT, textAlignOnPropertyLevel);
884 textLabelCenterAlign.SetProperty(TextLabel ::Property::ENABLE_MARKUP, true);
885 textLabelCenterAlign.SetProperty(TextLabel::Property::MULTI_LINE, true);
886 textLabelCenterAlign.SetProperty(TextLabel::Property::ELLIPSIS, false);
887 textLabelCenterAlign.SetProperty(TextLabel::Property::HORIZONTAL_ALIGNMENT, Dali::Toolkit::Text::HorizontalAlignment::CENTER);
888 textLabelCenterAlign.SetProperty(Actor::Property::SIZE, controllerSize);
890 textLabelEndAlign.SetProperty(TextLabel::Property::TEXT, textAlignOnPropertyLevel);
891 textLabelEndAlign.SetProperty(TextLabel ::Property::ENABLE_MARKUP, true);
892 textLabelEndAlign.SetProperty(TextLabel::Property::MULTI_LINE, true);
893 textLabelEndAlign.SetProperty(TextLabel::Property::ELLIPSIS, false);
894 textLabelEndAlign.SetProperty(TextLabel::Property::HORIZONTAL_ALIGNMENT, Dali::Toolkit::Text::HorizontalAlignment::END);
895 textLabelEndAlign.SetProperty(Actor::Property::SIZE, controllerSize);
897 textLabelMultiAlign.SetProperty(TextLabel::Property::TEXT, textAlignInMarkup);
898 textLabelMultiAlign.SetProperty(TextLabel ::Property::ENABLE_MARKUP, true);
899 textLabelMultiAlign.SetProperty(TextLabel::Property::MULTI_LINE, true);
900 textLabelMultiAlign.SetProperty(TextLabel::Property::ELLIPSIS, false);
901 textLabelMultiAlign.SetProperty(TextLabel::Property::HORIZONTAL_ALIGNMENT, Dali::Toolkit::Text::HorizontalAlignment::CENTER);
902 textLabelMultiAlign.SetProperty(Actor::Property::SIZE, controllerSize);
904 application.SendNotification();
905 application.Render();
907 uint32_t expectedNumberOfBoundedParagraphRuns = 4u;
908 uint32_t expectedNumberOfLines = 7u;
910 Toolkit::Internal::TextLabel& textLabelMultiAlignImpl = GetImpl(textLabelMultiAlign);
911 Toolkit::Internal::TextLabel& textLabelBeginAlignImpl = GetImpl(textLabelBeginAlign);
912 Toolkit::Internal::TextLabel& textLabelCenterAlignImpl = GetImpl(textLabelCenterAlign);
913 Toolkit::Internal::TextLabel& textLabelEndAlignImpl = GetImpl(textLabelEndAlign);
915 const Text::Length numberOfBoundedParagraphRuns = textLabelMultiAlignImpl.GetTextController()->GetTextModel()->GetNumberOfBoundedParagraphRuns();
916 DALI_TEST_EQUALS(numberOfBoundedParagraphRuns, expectedNumberOfBoundedParagraphRuns, TEST_LOCATION);
918 DALI_TEST_EQUALS(textLabelMultiAlignImpl.GetTextController()->GetTextModel()->GetNumberOfLines(), expectedNumberOfLines, TEST_LOCATION);
919 DALI_TEST_CHECK(textLabelMultiAlignImpl.GetTextController()->GetTextModel()->GetLines());
921 DALI_TEST_EQUALS(textLabelBeginAlignImpl.GetTextController()->GetTextModel()->GetNumberOfLines(), expectedNumberOfLines, TEST_LOCATION);
922 DALI_TEST_CHECK(textLabelBeginAlignImpl.GetTextController()->GetTextModel()->GetLines());
924 DALI_TEST_EQUALS(textLabelCenterAlignImpl.GetTextController()->GetTextModel()->GetNumberOfLines(), expectedNumberOfLines, TEST_LOCATION);
925 DALI_TEST_CHECK(textLabelCenterAlignImpl.GetTextController()->GetTextModel()->GetLines());
927 DALI_TEST_EQUALS(textLabelEndAlignImpl.GetTextController()->GetTextModel()->GetNumberOfLines(), expectedNumberOfLines, TEST_LOCATION);
928 DALI_TEST_CHECK(textLabelEndAlignImpl.GetTextController()->GetTextModel()->GetLines());
930 const uint32_t LINE_INDEX_ALIGN_END = 1u;
931 const uint32_t LINE_INDEX_ALIGN_CENTER = 3u;
932 const uint32_t LINE_INDEX_ALIGN_BEGIN = 5u;
933 const uint32_t LINE_INDEX_OUTSIDE_1 = 0u;
934 const uint32_t LINE_INDEX_OUTSIDE_2 = 2u;
935 const uint32_t LINE_INDEX_OUTSIDE_3 = 4u;
936 const uint32_t LINE_INDEX_PARAGRAPH = 6u;
938 //<p align='end'>Paragraph end</p>
939 const LineRun& lineEndFromMultiAlign = *(textLabelMultiAlignImpl.GetTextController()->GetTextModel()->GetLines() + LINE_INDEX_ALIGN_END);
940 const LineRun& lineEndFromEndAlign = *(textLabelEndAlignImpl.GetTextController()->GetTextModel()->GetLines() + LINE_INDEX_ALIGN_END);
941 tet_infoline(" UtcDaliTextLabelMarkupParagraphTagAlignAttribute - <p align='end'>Paragraph end</p>");
942 DALI_TEST_EQUALS(lineEndFromMultiAlign.alignmentOffset, lineEndFromEndAlign.alignmentOffset, TEST_LOCATION);
943 DALI_TEST_EQUALS(lineEndFromMultiAlign.width, lineEndFromEndAlign.width, TEST_LOCATION);
945 //<p align='center'>Paragraph center</p>
946 const LineRun& lineCenterFromMultiAlign = *(textLabelMultiAlignImpl.GetTextController()->GetTextModel()->GetLines() + LINE_INDEX_ALIGN_CENTER);
947 const LineRun& lineEndFromCenterAlign = *(textLabelCenterAlignImpl.GetTextController()->GetTextModel()->GetLines() + LINE_INDEX_ALIGN_CENTER);
948 tet_infoline(" UtcDaliTextLabelMarkupParagraphTagAlignAttribute - <p align='center'>Paragraph center</p>");
949 DALI_TEST_EQUALS(lineCenterFromMultiAlign.alignmentOffset, lineEndFromCenterAlign.alignmentOffset, TEST_LOCATION);
950 DALI_TEST_EQUALS(lineCenterFromMultiAlign.width, lineEndFromCenterAlign.width, TEST_LOCATION);
952 //<p align='begin' >Paragraph begin</p>
953 const LineRun& lineBeginFromMultiAlign = *(textLabelMultiAlignImpl.GetTextController()->GetTextModel()->GetLines() + LINE_INDEX_ALIGN_BEGIN);
954 const LineRun& lineEndFromBeginAlign = *(textLabelBeginAlignImpl.GetTextController()->GetTextModel()->GetLines() + LINE_INDEX_ALIGN_BEGIN);
955 tet_infoline(" UtcDaliTextLabelMarkupParagraphTagAlignAttribute - <p align='begin' >Paragraph begin</p>");
956 DALI_TEST_EQUALS(lineBeginFromMultiAlign.alignmentOffset, lineEndFromBeginAlign.alignmentOffset, TEST_LOCATION);
957 DALI_TEST_EQUALS(lineBeginFromMultiAlign.width, lineEndFromBeginAlign.width, TEST_LOCATION);
960 const LineRun& lineOutsideOneFromMultiAlign = *(textLabelMultiAlignImpl.GetTextController()->GetTextModel()->GetLines() + LINE_INDEX_OUTSIDE_1);
961 const LineRun& lineOutsideOneFromCenterAlign = *(textLabelCenterAlignImpl.GetTextController()->GetTextModel()->GetLines() + LINE_INDEX_OUTSIDE_1);
962 tet_infoline(" UtcDaliTextLabelMarkupParagraphTagAlignAttribute - text outside one");
963 DALI_TEST_EQUALS(lineOutsideOneFromMultiAlign.alignmentOffset, lineOutsideOneFromCenterAlign.alignmentOffset, TEST_LOCATION);
964 DALI_TEST_EQUALS(lineOutsideOneFromMultiAlign.width, lineOutsideOneFromCenterAlign.width, TEST_LOCATION);
966 const LineRun& lineOutsideTwoFromMultiAlign = *(textLabelMultiAlignImpl.GetTextController()->GetTextModel()->GetLines() + LINE_INDEX_OUTSIDE_2);
967 const LineRun& lineOutsideTwoFromCenterAlign = *(textLabelCenterAlignImpl.GetTextController()->GetTextModel()->GetLines() + LINE_INDEX_OUTSIDE_2);
968 tet_infoline(" UtcDaliTextLabelMarkupParagraphTagAlignAttribute - text outside two");
969 DALI_TEST_EQUALS(lineOutsideTwoFromMultiAlign.alignmentOffset, lineOutsideTwoFromCenterAlign.alignmentOffset, TEST_LOCATION);
970 DALI_TEST_EQUALS(lineOutsideTwoFromMultiAlign.width, lineOutsideTwoFromCenterAlign.width, TEST_LOCATION);
972 const LineRun& lineOutsideThreeFromMultiAlign = *(textLabelMultiAlignImpl.GetTextController()->GetTextModel()->GetLines() + LINE_INDEX_OUTSIDE_3);
973 const LineRun& lineOutsideThreeFromCenterAlign = *(textLabelCenterAlignImpl.GetTextController()->GetTextModel()->GetLines() + LINE_INDEX_OUTSIDE_3);
974 tet_infoline(" UtcDaliTextLabelMarkupParagraphTagAlignAttribute - text outside three");
975 DALI_TEST_EQUALS(lineOutsideThreeFromMultiAlign.alignmentOffset, lineOutsideThreeFromCenterAlign.alignmentOffset, TEST_LOCATION);
976 DALI_TEST_EQUALS(lineOutsideThreeFromMultiAlign.width, lineOutsideThreeFromCenterAlign.width, TEST_LOCATION);
978 const LineRun& lineParagraphFromMultiAlign = *(textLabelMultiAlignImpl.GetTextController()->GetTextModel()->GetLines() + LINE_INDEX_PARAGRAPH);
979 const LineRun& lineParagraphFromCenterAlign = *(textLabelCenterAlignImpl.GetTextController()->GetTextModel()->GetLines() + LINE_INDEX_PARAGRAPH);
980 tet_infoline(" UtcDaliTextLabelMarkupParagraphTagAlignAttribute - <p>Paragraph property alignment</p>");
981 DALI_TEST_EQUALS(lineParagraphFromMultiAlign.alignmentOffset, lineParagraphFromCenterAlign.alignmentOffset, TEST_LOCATION);
982 DALI_TEST_EQUALS(lineParagraphFromMultiAlign.width, lineParagraphFromCenterAlign.width, TEST_LOCATION);