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/controller/text-controller-impl.h>
26 #include <dali-toolkit/internal/text/controller/text-controller.h>
27 #include <dali-toolkit/internal/text/rendering/text-typesetter.h>
28 #include <dali-toolkit/internal/text/rendering/view-model.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 UtcDaliTextLabelMarkupNestedStrikethroughTags(void)
566 ToolkitTestApplication application;
567 tet_infoline(" UtcDaliTextLabelMarkupNestedStrikethroughTags ");
569 TextLabel textLabel = TextLabel::New();
571 application.GetScene().Add(textLabel);
573 std::string testText = "start<s height='5.0f' color='green' >AB<s color='blue' >XYZ</s>CDE</s>end";
575 textLabel.SetProperty(TextLabel::Property::TEXT, testText);
576 textLabel.SetProperty(TextLabel ::Property::ENABLE_MARKUP, true);
578 application.SendNotification();
579 application.Render();
581 const uint32_t expectedNumberOfStrikethroughRuns = 2u;
583 Toolkit::Internal::TextLabel& textLabelImpl = GetImpl(textLabel);
584 const Text::Length numberOfStrikethroughRuns = textLabelImpl.GetTextController()->GetTextModel()->GetNumberOfStrikethroughRuns();
586 DALI_TEST_EQUALS(numberOfStrikethroughRuns, expectedNumberOfStrikethroughRuns, TEST_LOCATION);
588 Vector<StrikethroughGlyphRun> strikethroughRuns;
589 strikethroughRuns.Resize(numberOfStrikethroughRuns);
590 textLabelImpl.GetTextController()->GetTextModel()->GetStrikethroughRuns(strikethroughRuns.Begin(), 0u, numberOfStrikethroughRuns);
595 GlyphIndex glyphIndex;
596 Length numberOfGlyphs;
597 StrikethroughStyleProperties properties;
602 {"<s height='5.0f' color='green' >AB<s color='blue' >XYZ</s>CDE</s>",
613 {"<s color='blue' >XYZ</s>",
625 for(uint32_t i = 0; i < expectedNumberOfStrikethroughRuns; i++)
627 tet_infoline(data[i].title.c_str());
628 DALI_TEST_EQUALS(strikethroughRuns[i].glyphRun.glyphIndex, data[i].glyphIndex, TEST_LOCATION);
629 DALI_TEST_EQUALS(strikethroughRuns[i].glyphRun.numberOfGlyphs, data[i].numberOfGlyphs, TEST_LOCATION);
630 DALI_TEST_CHECK(data[i].properties == strikethroughRuns[i].properties);
636 int UtcDaliTextLabelMarkupStrikethroughAttributes(void)
638 ToolkitTestApplication application;
639 tet_infoline(" UtcDaliTextLabelMarkupStrikethroughAttributes ");
641 TextLabel textLabel = TextLabel::New();
643 application.GetScene().Add(textLabel);
645 std::string testText =
646 "start<s>ABC1</s>then"
647 "<s color='green'>ABC2</s>then"
648 "<s height='5.0f'>ABC3</s>then"
649 "<s color='blue' height='4.0f' >ABC4</s>end";
651 textLabel.SetProperty(TextLabel::Property::TEXT, testText);
652 textLabel.SetProperty(TextLabel ::Property::ENABLE_MARKUP, true);
654 application.SendNotification();
655 application.Render();
657 const uint32_t expectedNumberOfStrikethroughRuns = 4u;
659 Toolkit::Internal::TextLabel& textLabelImpl = GetImpl(textLabel);
660 const Text::Length numberOfStrikethroughRuns = textLabelImpl.GetTextController()->GetTextModel()->GetNumberOfStrikethroughRuns();
662 DALI_TEST_EQUALS(numberOfStrikethroughRuns, expectedNumberOfStrikethroughRuns, TEST_LOCATION);
664 Vector<StrikethroughGlyphRun> strikethroughRuns;
665 strikethroughRuns.Resize(numberOfStrikethroughRuns);
666 textLabelImpl.GetTextController()->GetTextModel()->GetStrikethroughRuns(strikethroughRuns.Begin(), 0u, numberOfStrikethroughRuns);
671 GlyphIndex glyphIndex;
672 Length numberOfGlyphs;
673 StrikethroughStyleProperties properties;
686 {"<s color='green'>ABC2</s>",
694 {"<s height='5.0f'>ABC3</s>",
702 {"<s color='blue' height='4.0f' >ABC4</s>",
712 for(uint32_t i = 0; i < expectedNumberOfStrikethroughRuns; i++)
714 tet_infoline(data[i].title.c_str());
715 DALI_TEST_EQUALS(strikethroughRuns[i].glyphRun.glyphIndex, data[i].glyphIndex, TEST_LOCATION);
716 DALI_TEST_EQUALS(strikethroughRuns[i].glyphRun.numberOfGlyphs, data[i].numberOfGlyphs, TEST_LOCATION);
717 DALI_TEST_CHECK(data[i].properties == strikethroughRuns[i].properties);
723 int UtcDaliTextLabelMarkupSpanStrikethrough(void)
725 ToolkitTestApplication application;
726 tet_infoline(" UtcDaliTextLabelMarkupSpanStrikethrough ");
728 TextLabel textLabel = TextLabel::New();
730 application.GetScene().Add(textLabel);
732 std::string testText =
733 "start<span font-size='45' font-family='DejaVu Sans' font-width='condensed' font-slant='italic' text-color='red'>ABC1</span>then"
734 "<span s-color='blue'>ABC2</span>then"
735 "<span s-height='2.0f'>ABC3</span>then"
736 "<span font-size='45' font-family='DejaVu Sans' font-width='condensed' font-slant='italic' text-color='red' s-color='green' s-height='5.0f'>ABC4</span>end";
738 textLabel.SetProperty(TextLabel::Property::TEXT, testText);
739 textLabel.SetProperty(TextLabel ::Property::ENABLE_MARKUP, true);
741 application.SendNotification();
742 application.Render();
744 const uint32_t expectedNumberOfStrikethroughRuns = 3u;
746 Toolkit::Internal::TextLabel& textLabelImpl = GetImpl(textLabel);
747 const Text::Length numberOfStrikethroughRuns = textLabelImpl.GetTextController()->GetTextModel()->GetNumberOfStrikethroughRuns();
749 DALI_TEST_EQUALS(numberOfStrikethroughRuns, expectedNumberOfStrikethroughRuns, TEST_LOCATION);
751 Vector<StrikethroughGlyphRun> strikethroughRuns;
752 strikethroughRuns.Resize(numberOfStrikethroughRuns);
753 textLabelImpl.GetTextController()->GetTextModel()->GetStrikethroughRuns(strikethroughRuns.Begin(), 0u, numberOfStrikethroughRuns);
758 GlyphIndex glyphIndex;
759 Length numberOfGlyphs;
760 StrikethroughStyleProperties properties;
765 {"<span s-color='blue'>ABC2</span>then",
773 {"<span s-height='2.0f'>ABC3</span>then",
781 {"<span font-size='45' font-family='DejaVu Sans' font-width='condensed' font-slant='italic' text-color='red' s-color='green' s-height='5.0f'>ABC4</span>",
791 for(uint32_t i = 0; i < expectedNumberOfStrikethroughRuns; i++)
793 tet_infoline(data[i].title.c_str());
794 DALI_TEST_EQUALS(strikethroughRuns[i].glyphRun.glyphIndex, data[i].glyphIndex, TEST_LOCATION);
795 DALI_TEST_EQUALS(strikethroughRuns[i].glyphRun.numberOfGlyphs, data[i].numberOfGlyphs, TEST_LOCATION);
796 DALI_TEST_CHECK(data[i].properties == strikethroughRuns[i].properties);
802 int UtcDaliTextLabelBackgroundTag(void)
804 ToolkitTestApplication application;
805 tet_infoline("UtcDaliTextLabelBackgroundTag\n");
807 TextLabel label = TextLabel::New();
808 DALI_TEST_CHECK(label);
810 label.SetProperty(TextLabel ::Property::ENABLE_MARKUP, true);
811 label.SetProperty(TextLabel::Property::TEXT, "H<background color='red'>e</background> Worl<background color='yellow'>d</background>");
812 application.GetScene().Add(label);
813 application.SendNotification();
814 application.Render();
816 Toolkit::Internal::TextLabel& labelImpl = GetImpl(label);
817 const ColorIndex* const backgroundColorIndicesBuffer = labelImpl.GetTextController()->GetTextModel()->GetBackgroundColorIndices();
819 DALI_TEST_CHECK(backgroundColorIndicesBuffer);
822 DALI_TEST_EQUALS(backgroundColorIndicesBuffer[0], 0u, TEST_LOCATION);
825 DALI_TEST_EQUALS(backgroundColorIndicesBuffer[1], 1u, TEST_LOCATION);
828 DALI_TEST_EQUALS(backgroundColorIndicesBuffer[7], 2u, TEST_LOCATION);
833 int UtcDaliTextLabelSpanBackgroundTag(void)
835 ToolkitTestApplication application;
836 tet_infoline("UtcDaliTextLabelSpanBackgroundTag\n");
838 TextLabel label = TextLabel::New();
839 DALI_TEST_CHECK(label);
841 label.SetProperty(TextLabel ::Property::ENABLE_MARKUP, true);
842 label.SetProperty(TextLabel::Property::TEXT, "H<span background-color='red'>e</span> Worl<span background-color='yellow'>d</span>");
843 application.GetScene().Add(label);
844 application.SendNotification();
845 application.Render();
847 Toolkit::Internal::TextLabel& labelImpl = GetImpl(label);
848 const ColorIndex* const backgroundColorIndicesBuffer = labelImpl.GetTextController()->GetTextModel()->GetBackgroundColorIndices();
850 DALI_TEST_CHECK(backgroundColorIndicesBuffer);
853 DALI_TEST_EQUALS(backgroundColorIndicesBuffer[0], 0u, TEST_LOCATION);
856 DALI_TEST_EQUALS(backgroundColorIndicesBuffer[1], 1u, TEST_LOCATION);
859 DALI_TEST_EQUALS(backgroundColorIndicesBuffer[7], 2u, TEST_LOCATION);
864 int UtcDaliToolkitTextlabelEllipsisInternalAPIs(void)
866 ToolkitTestApplication application;
867 tet_infoline(" UtcDaliToolkitTextlabelEllipsisInternalAPIs ");
868 TextLabel textLabel = TextLabel::New();
870 Toolkit::Internal::TextLabel& textLabelImpl = GetImpl(textLabel);
871 const ModelInterface* const textModel = textLabelImpl.GetTextController()->GetTextModel();
873 tet_infoline(" UtcDaliToolkitTextlabelEllipsisInternalAPIs - ELLIPSIS Disabled");
874 textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS, false);
875 DALI_TEST_EQUALS(textLabel.GetProperty<bool>(DevelTextLabel::Property::ELLIPSIS), false, TEST_LOCATION);
876 DALI_TEST_CHECK(!(textModel->IsTextElideEnabled()));
878 tet_infoline(" UtcDaliToolkitTextlabelEllipsisInternalAPIs - ELLIPSIS Enabled");
879 textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS, true);
880 DALI_TEST_EQUALS(textLabel.GetProperty<bool>(DevelTextLabel::Property::ELLIPSIS), true, TEST_LOCATION);
881 DALI_TEST_CHECK(textModel->IsTextElideEnabled());
883 tet_infoline(" UtcDaliToolkitTextlabelEllipsisInternalAPIs - GetStartIndexOfElidedGlyphs Default");
884 DALI_TEST_EQUALS(textModel->GetStartIndexOfElidedGlyphs(), 0u, TEST_LOCATION);
886 tet_infoline(" UtcDaliToolkitTextlabelEllipsisInternalAPIs - GetEndIndexOfElidedGlyphs Default");
887 DALI_TEST_EQUALS(textModel->GetEndIndexOfElidedGlyphs(), 0u, TEST_LOCATION);
889 tet_infoline(" UtcDaliToolkitTextlabelEllipsisInternalAPIs - GetFirstMiddleIndexOfElidedGlyphs Default");
890 DALI_TEST_EQUALS(textModel->GetFirstMiddleIndexOfElidedGlyphs(), 0u, TEST_LOCATION);
892 tet_infoline(" UtcDaliToolkitTextlabelEllipsisInternalAPIs - GetSecondMiddleIndexOfElidedGlyphs Default");
893 DALI_TEST_EQUALS(textModel->GetSecondMiddleIndexOfElidedGlyphs(), 0u, TEST_LOCATION);
895 // Tests the rendering controller has been created.
896 TypesetterPtr typesetter = Typesetter::New(textModel);
897 DALI_TEST_CHECK(typesetter);
899 // Tests the view model has been created.
900 ViewModel* model = typesetter->GetViewModel();
902 tet_infoline(" UtcDaliToolkitTextlabelEllipsisInternalAPIs - IsTextElideEnabled ViewModel");
903 DALI_TEST_CHECK(model->IsTextElideEnabled());
905 tet_infoline(" UtcDaliToolkitTextlabelEllipsisInternalAPIs - GetStartIndexOfElidedGlyphs ViewModel");
906 DALI_TEST_EQUALS(model->GetStartIndexOfElidedGlyphs(), 0u, TEST_LOCATION);
908 tet_infoline(" UtcDaliToolkitTextlabelEllipsisInternalAPIs - GetEndIndexOfElidedGlyphs ViewModel");
909 DALI_TEST_EQUALS(model->GetEndIndexOfElidedGlyphs(), 0u, TEST_LOCATION);
911 tet_infoline(" UtcDaliToolkitTextlabelEllipsisInternalAPIs - GetFirstMiddleIndexOfElidedGlyphs ViewModel");
912 DALI_TEST_EQUALS(model->GetFirstMiddleIndexOfElidedGlyphs(), 0u, TEST_LOCATION);
914 tet_infoline(" UtcDaliToolkitTextlabelEllipsisInternalAPIs - GetSecondMiddleIndexOfElidedGlyphs ViewModel");
915 DALI_TEST_EQUALS(model->GetSecondMiddleIndexOfElidedGlyphs(), 0u, TEST_LOCATION);
919 int UtcDaliTextLabelTextWithSpan(void)
921 ToolkitTestApplication application;
922 tet_infoline("UtcDaliTextLabelTextWithSpan\n");
924 TextLabel label = TextLabel::New();
925 DALI_TEST_CHECK(label);
927 label.SetProperty(TextLabel ::Property::ENABLE_MARKUP, true);
928 label.SetProperty(TextLabel::Property::TEXT, "Hello Span");
929 application.GetScene().Add(label);
931 application.SendNotification();
932 application.Render();
934 Vector3 originalSize = label.GetNaturalSize();
935 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");
937 application.SendNotification();
938 application.Render();
940 Vector3 spanSize = label.GetNaturalSize();
942 DALI_TEST_GREATER(spanSize.width, originalSize.width, TEST_LOCATION);
944 Toolkit::Internal::TextLabel& labelImpl = GetImpl(label);
945 const ColorIndex* const colorIndicesBuffer1 = labelImpl.GetTextController()->GetTextModel()->GetColorIndices();
947 DALI_TEST_CHECK(colorIndicesBuffer1);
950 DALI_TEST_EQUALS(colorIndicesBuffer1[0], 0u, TEST_LOCATION);
953 DALI_TEST_EQUALS(colorIndicesBuffer1[1], 1u, TEST_LOCATION);
956 DALI_TEST_EQUALS(colorIndicesBuffer1[6], 0u, TEST_LOCATION);
958 label.SetProperty(TextLabel::Property::TEXT, "<span font-size='45'>H</span>ello <span text-color='red'>S</span>pan");
960 application.SendNotification();
961 application.Render();
963 const ColorIndex* const colorIndicesBuffer2 = labelImpl.GetTextController()->GetTextModel()->GetColorIndices();
965 DALI_TEST_CHECK(colorIndicesBuffer2);
968 DALI_TEST_EQUALS(colorIndicesBuffer2[0], 0u, TEST_LOCATION);
971 DALI_TEST_EQUALS(colorIndicesBuffer2[1], 0u, TEST_LOCATION);
974 DALI_TEST_EQUALS(colorIndicesBuffer2[6], 1u, TEST_LOCATION);
977 DALI_TEST_EQUALS(colorIndicesBuffer2[7], 0u, TEST_LOCATION);
982 int UtcDaliTextLabelMarkupStrikethrough(void)
984 ToolkitTestApplication application;
985 tet_infoline(" UtcDaliTextLabelMarkupStrikethrough ");
987 TextLabel textLabel = TextLabel::New();
989 application.GetScene().Add(textLabel);
991 textLabel.SetProperty(TextLabel::Property::TEXT, "<s color='red'>ABC</s>EF<s color='green'>GH</s>");
992 textLabel.SetProperty(TextLabel ::Property::ENABLE_MARKUP, true);
994 application.SendNotification();
995 application.Render();
997 uint32_t expectedNumberOfStrikethroughGlyphs = 2u;
999 Toolkit::Internal::TextLabel& textLabelImpl = GetImpl(textLabel);
1000 const Text::Length numberOfStrikethroughRuns = textLabelImpl.GetTextController()->GetTextModel()->GetNumberOfStrikethroughRuns();
1002 DALI_TEST_EQUALS(numberOfStrikethroughRuns, expectedNumberOfStrikethroughGlyphs, TEST_LOCATION);
1004 Vector<StrikethroughGlyphRun> strikethroughRuns;
1005 strikethroughRuns.Resize(numberOfStrikethroughRuns);
1006 textLabelImpl.GetTextController()->GetTextModel()->GetStrikethroughRuns(strikethroughRuns.Begin(), 0u, numberOfStrikethroughRuns);
1008 //ABC have strikethrough
1009 DALI_TEST_EQUALS(strikethroughRuns[0u].glyphRun.glyphIndex, 0u, TEST_LOCATION);
1010 DALI_TEST_EQUALS(strikethroughRuns[0u].glyphRun.numberOfGlyphs, 3u, TEST_LOCATION);
1011 DALI_TEST_CHECK(strikethroughRuns[0u].properties.colorDefined);
1012 DALI_TEST_EQUALS(strikethroughRuns[0u].properties.color.r, 1u, TEST_LOCATION);
1013 DALI_TEST_EQUALS(strikethroughRuns[0u].properties.color.g, 0u, TEST_LOCATION);
1014 DALI_TEST_EQUALS(strikethroughRuns[0u].properties.color.b, 0u, TEST_LOCATION);
1016 //GH have strikethrough
1017 DALI_TEST_EQUALS(strikethroughRuns[1u].glyphRun.glyphIndex, 5u, TEST_LOCATION);
1018 DALI_TEST_EQUALS(strikethroughRuns[1u].glyphRun.numberOfGlyphs, 2u, TEST_LOCATION);
1019 DALI_TEST_CHECK(strikethroughRuns[1u].properties.colorDefined);
1020 DALI_TEST_EQUALS(strikethroughRuns[1u].properties.color.r, 0u, TEST_LOCATION);
1021 DALI_TEST_EQUALS(strikethroughRuns[1u].properties.color.g, 1u, TEST_LOCATION);
1022 DALI_TEST_EQUALS(strikethroughRuns[1u].properties.color.b, 0u, TEST_LOCATION);
1027 int UtcDaliTextLabelMarkupStrikethroughNoEndTag(void)
1029 ToolkitTestApplication application;
1030 tet_infoline(" UtcDaliTextLabelMarkupStrikethroughNoEndTag ");
1032 TextLabel textLabel = TextLabel::New();
1034 application.GetScene().Add(textLabel);
1036 textLabel.SetProperty(TextLabel::Property::TEXT, "<s>ABC");
1037 textLabel.SetProperty(TextLabel ::Property::ENABLE_MARKUP, true);
1039 application.SendNotification();
1040 application.Render();
1042 uint32_t expectedNumberOfStrikethroughGlyphs = 0u;
1044 Toolkit::Internal::TextLabel& textLabelImpl = GetImpl(textLabel);
1045 Text::Length numberOfStrikethroughRuns = textLabelImpl.GetTextController()->GetTextModel()->GetNumberOfStrikethroughRuns();
1047 DALI_TEST_EQUALS(numberOfStrikethroughRuns, expectedNumberOfStrikethroughGlyphs, TEST_LOCATION);
1052 int UtcDaliTextLabelMarkupParagraphTag(void)
1055 ToolkitTestApplication application;
1057 tet_infoline(" UtcDaliTextLabelMarkupParagraphTag ");
1058 TextLabel textLabel = TextLabel::New();
1060 application.GetScene().Add(textLabel);
1062 textLabel.SetProperty(TextLabel::Property::TEXT, "text one <p>Paragraph two</p> text three <p>Paragraph four</p> text five");
1063 textLabel.SetProperty(TextLabel ::Property::ENABLE_MARKUP, true);
1064 textLabel.SetProperty(TextLabel::Property::MULTI_LINE, true);
1066 application.SendNotification();
1067 application.Render();
1069 uint32_t expectedNumberOfBoundedParagraphRuns = 2u;
1071 Toolkit::Internal::TextLabel& textLabelImpl = GetImpl(textLabel);
1072 const Text::Length numberOfBoundedParagraphRuns = textLabelImpl.GetTextController()->GetTextModel()->GetNumberOfBoundedParagraphRuns();
1073 DALI_TEST_EQUALS(numberOfBoundedParagraphRuns, expectedNumberOfBoundedParagraphRuns, TEST_LOCATION);
1075 const Vector<BoundedParagraphRun>& boundedParagraphRuns = textLabelImpl.GetTextController()->GetTextModel()->GetBoundedParagraphRuns();
1077 //<p>Paragraph two</p>
1078 DALI_TEST_EQUALS(boundedParagraphRuns[0u].characterRun.characterIndex, 10u, TEST_LOCATION);
1079 DALI_TEST_EQUALS(boundedParagraphRuns[0u].characterRun.numberOfCharacters, 14u, TEST_LOCATION);
1081 //<p>Paragraph four</p>
1082 DALI_TEST_EQUALS(boundedParagraphRuns[1u].characterRun.characterIndex, 37u, TEST_LOCATION);
1083 DALI_TEST_EQUALS(boundedParagraphRuns[1u].characterRun.numberOfCharacters, 15u, TEST_LOCATION);
1088 int UtcDaliTextLabelMarkupParagraphTagAlignAttribute(void)
1090 ToolkitTestApplication application;
1091 tet_infoline(" UtcDaliTextLabelMarkupParagraphTagAlignAttribute ");
1093 // Apply alignment for each type on property level on three paragraphs and in-between text.
1094 // Apply align in markup on the three paragraphs (each one a type).
1095 // Using the same text to gain similar results from both the property level and the markup.
1096 // Compare line alignment between the property level and the markup.
1098 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>";
1099 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>";
1101 //Set size to avoid automatic eliding
1102 Vector2 controllerSize = Vector2(1025, 1025);
1104 TextLabel textLabelBeginAlign = TextLabel::New();
1105 TextLabel textLabelCenterAlign = TextLabel::New();
1106 TextLabel textLabelEndAlign = TextLabel::New();
1107 TextLabel textLabelMultiAlign = TextLabel::New();
1109 application.GetScene().Add(textLabelBeginAlign);
1110 application.GetScene().Add(textLabelCenterAlign);
1111 application.GetScene().Add(textLabelEndAlign);
1112 application.GetScene().Add(textLabelMultiAlign);
1114 textLabelBeginAlign.SetProperty(TextLabel::Property::TEXT, textAlignOnPropertyLevel);
1115 textLabelBeginAlign.SetProperty(TextLabel ::Property::ENABLE_MARKUP, true);
1116 textLabelBeginAlign.SetProperty(TextLabel::Property::MULTI_LINE, true);
1117 textLabelBeginAlign.SetProperty(TextLabel::Property::ELLIPSIS, false);
1118 textLabelBeginAlign.SetProperty(TextLabel::Property::HORIZONTAL_ALIGNMENT, Dali::Toolkit::Text::HorizontalAlignment::BEGIN);
1119 textLabelBeginAlign.SetProperty(Actor::Property::SIZE, controllerSize);
1121 textLabelCenterAlign.SetProperty(TextLabel::Property::TEXT, textAlignOnPropertyLevel);
1122 textLabelCenterAlign.SetProperty(TextLabel ::Property::ENABLE_MARKUP, true);
1123 textLabelCenterAlign.SetProperty(TextLabel::Property::MULTI_LINE, true);
1124 textLabelCenterAlign.SetProperty(TextLabel::Property::ELLIPSIS, false);
1125 textLabelCenterAlign.SetProperty(TextLabel::Property::HORIZONTAL_ALIGNMENT, Dali::Toolkit::Text::HorizontalAlignment::CENTER);
1126 textLabelCenterAlign.SetProperty(Actor::Property::SIZE, controllerSize);
1128 textLabelEndAlign.SetProperty(TextLabel::Property::TEXT, textAlignOnPropertyLevel);
1129 textLabelEndAlign.SetProperty(TextLabel ::Property::ENABLE_MARKUP, true);
1130 textLabelEndAlign.SetProperty(TextLabel::Property::MULTI_LINE, true);
1131 textLabelEndAlign.SetProperty(TextLabel::Property::ELLIPSIS, false);
1132 textLabelEndAlign.SetProperty(TextLabel::Property::HORIZONTAL_ALIGNMENT, Dali::Toolkit::Text::HorizontalAlignment::END);
1133 textLabelEndAlign.SetProperty(Actor::Property::SIZE, controllerSize);
1135 textLabelMultiAlign.SetProperty(TextLabel::Property::TEXT, textAlignInMarkup);
1136 textLabelMultiAlign.SetProperty(TextLabel ::Property::ENABLE_MARKUP, true);
1137 textLabelMultiAlign.SetProperty(TextLabel::Property::MULTI_LINE, true);
1138 textLabelMultiAlign.SetProperty(TextLabel::Property::ELLIPSIS, false);
1139 textLabelMultiAlign.SetProperty(TextLabel::Property::HORIZONTAL_ALIGNMENT, Dali::Toolkit::Text::HorizontalAlignment::CENTER);
1140 textLabelMultiAlign.SetProperty(Actor::Property::SIZE, controllerSize);
1142 application.SendNotification();
1143 application.Render();
1145 uint32_t expectedNumberOfBoundedParagraphRuns = 4u;
1146 uint32_t expectedNumberOfLines = 7u;
1148 Toolkit::Internal::TextLabel& textLabelMultiAlignImpl = GetImpl(textLabelMultiAlign);
1149 Toolkit::Internal::TextLabel& textLabelBeginAlignImpl = GetImpl(textLabelBeginAlign);
1150 Toolkit::Internal::TextLabel& textLabelCenterAlignImpl = GetImpl(textLabelCenterAlign);
1151 Toolkit::Internal::TextLabel& textLabelEndAlignImpl = GetImpl(textLabelEndAlign);
1153 const Text::Length numberOfBoundedParagraphRuns = textLabelMultiAlignImpl.GetTextController()->GetTextModel()->GetNumberOfBoundedParagraphRuns();
1154 DALI_TEST_EQUALS(numberOfBoundedParagraphRuns, expectedNumberOfBoundedParagraphRuns, TEST_LOCATION);
1156 DALI_TEST_EQUALS(textLabelMultiAlignImpl.GetTextController()->GetTextModel()->GetNumberOfLines(), expectedNumberOfLines, TEST_LOCATION);
1157 DALI_TEST_CHECK(textLabelMultiAlignImpl.GetTextController()->GetTextModel()->GetLines());
1159 DALI_TEST_EQUALS(textLabelBeginAlignImpl.GetTextController()->GetTextModel()->GetNumberOfLines(), expectedNumberOfLines, TEST_LOCATION);
1160 DALI_TEST_CHECK(textLabelBeginAlignImpl.GetTextController()->GetTextModel()->GetLines());
1162 DALI_TEST_EQUALS(textLabelCenterAlignImpl.GetTextController()->GetTextModel()->GetNumberOfLines(), expectedNumberOfLines, TEST_LOCATION);
1163 DALI_TEST_CHECK(textLabelCenterAlignImpl.GetTextController()->GetTextModel()->GetLines());
1165 DALI_TEST_EQUALS(textLabelEndAlignImpl.GetTextController()->GetTextModel()->GetNumberOfLines(), expectedNumberOfLines, TEST_LOCATION);
1166 DALI_TEST_CHECK(textLabelEndAlignImpl.GetTextController()->GetTextModel()->GetLines());
1168 const uint32_t LINE_INDEX_ALIGN_END = 1u;
1169 const uint32_t LINE_INDEX_ALIGN_CENTER = 3u;
1170 const uint32_t LINE_INDEX_ALIGN_BEGIN = 5u;
1171 const uint32_t LINE_INDEX_OUTSIDE_1 = 0u;
1172 const uint32_t LINE_INDEX_OUTSIDE_2 = 2u;
1173 const uint32_t LINE_INDEX_OUTSIDE_3 = 4u;
1174 const uint32_t LINE_INDEX_PARAGRAPH = 6u;
1176 //<p align='end'>Paragraph end</p>
1177 const LineRun& lineEndFromMultiAlign = *(textLabelMultiAlignImpl.GetTextController()->GetTextModel()->GetLines() + LINE_INDEX_ALIGN_END);
1178 const LineRun& lineEndFromEndAlign = *(textLabelEndAlignImpl.GetTextController()->GetTextModel()->GetLines() + LINE_INDEX_ALIGN_END);
1179 tet_infoline(" UtcDaliTextLabelMarkupParagraphTagAlignAttribute - <p align='end'>Paragraph end</p>");
1180 DALI_TEST_EQUALS(lineEndFromMultiAlign.alignmentOffset, lineEndFromEndAlign.alignmentOffset, TEST_LOCATION);
1181 DALI_TEST_EQUALS(lineEndFromMultiAlign.width, lineEndFromEndAlign.width, TEST_LOCATION);
1183 //<p align='center'>Paragraph center</p>
1184 const LineRun& lineCenterFromMultiAlign = *(textLabelMultiAlignImpl.GetTextController()->GetTextModel()->GetLines() + LINE_INDEX_ALIGN_CENTER);
1185 const LineRun& lineEndFromCenterAlign = *(textLabelCenterAlignImpl.GetTextController()->GetTextModel()->GetLines() + LINE_INDEX_ALIGN_CENTER);
1186 tet_infoline(" UtcDaliTextLabelMarkupParagraphTagAlignAttribute - <p align='center'>Paragraph center</p>");
1187 DALI_TEST_EQUALS(lineCenterFromMultiAlign.alignmentOffset, lineEndFromCenterAlign.alignmentOffset, TEST_LOCATION);
1188 DALI_TEST_EQUALS(lineCenterFromMultiAlign.width, lineEndFromCenterAlign.width, TEST_LOCATION);
1190 //<p align='begin' >Paragraph begin</p>
1191 const LineRun& lineBeginFromMultiAlign = *(textLabelMultiAlignImpl.GetTextController()->GetTextModel()->GetLines() + LINE_INDEX_ALIGN_BEGIN);
1192 const LineRun& lineEndFromBeginAlign = *(textLabelBeginAlignImpl.GetTextController()->GetTextModel()->GetLines() + LINE_INDEX_ALIGN_BEGIN);
1193 tet_infoline(" UtcDaliTextLabelMarkupParagraphTagAlignAttribute - <p align='begin' >Paragraph begin</p>");
1194 DALI_TEST_EQUALS(lineBeginFromMultiAlign.alignmentOffset, lineEndFromBeginAlign.alignmentOffset, TEST_LOCATION);
1195 DALI_TEST_EQUALS(lineBeginFromMultiAlign.width, lineEndFromBeginAlign.width, TEST_LOCATION);
1198 const LineRun& lineOutsideOneFromMultiAlign = *(textLabelMultiAlignImpl.GetTextController()->GetTextModel()->GetLines() + LINE_INDEX_OUTSIDE_1);
1199 const LineRun& lineOutsideOneFromCenterAlign = *(textLabelCenterAlignImpl.GetTextController()->GetTextModel()->GetLines() + LINE_INDEX_OUTSIDE_1);
1200 tet_infoline(" UtcDaliTextLabelMarkupParagraphTagAlignAttribute - text outside one");
1201 DALI_TEST_EQUALS(lineOutsideOneFromMultiAlign.alignmentOffset, lineOutsideOneFromCenterAlign.alignmentOffset, TEST_LOCATION);
1202 DALI_TEST_EQUALS(lineOutsideOneFromMultiAlign.width, lineOutsideOneFromCenterAlign.width, TEST_LOCATION);
1204 const LineRun& lineOutsideTwoFromMultiAlign = *(textLabelMultiAlignImpl.GetTextController()->GetTextModel()->GetLines() + LINE_INDEX_OUTSIDE_2);
1205 const LineRun& lineOutsideTwoFromCenterAlign = *(textLabelCenterAlignImpl.GetTextController()->GetTextModel()->GetLines() + LINE_INDEX_OUTSIDE_2);
1206 tet_infoline(" UtcDaliTextLabelMarkupParagraphTagAlignAttribute - text outside two");
1207 DALI_TEST_EQUALS(lineOutsideTwoFromMultiAlign.alignmentOffset, lineOutsideTwoFromCenterAlign.alignmentOffset, TEST_LOCATION);
1208 DALI_TEST_EQUALS(lineOutsideTwoFromMultiAlign.width, lineOutsideTwoFromCenterAlign.width, TEST_LOCATION);
1210 const LineRun& lineOutsideThreeFromMultiAlign = *(textLabelMultiAlignImpl.GetTextController()->GetTextModel()->GetLines() + LINE_INDEX_OUTSIDE_3);
1211 const LineRun& lineOutsideThreeFromCenterAlign = *(textLabelCenterAlignImpl.GetTextController()->GetTextModel()->GetLines() + LINE_INDEX_OUTSIDE_3);
1212 tet_infoline(" UtcDaliTextLabelMarkupParagraphTagAlignAttribute - text outside three");
1213 DALI_TEST_EQUALS(lineOutsideThreeFromMultiAlign.alignmentOffset, lineOutsideThreeFromCenterAlign.alignmentOffset, TEST_LOCATION);
1214 DALI_TEST_EQUALS(lineOutsideThreeFromMultiAlign.width, lineOutsideThreeFromCenterAlign.width, TEST_LOCATION);
1216 const LineRun& lineParagraphFromMultiAlign = *(textLabelMultiAlignImpl.GetTextController()->GetTextModel()->GetLines() + LINE_INDEX_PARAGRAPH);
1217 const LineRun& lineParagraphFromCenterAlign = *(textLabelCenterAlignImpl.GetTextController()->GetTextModel()->GetLines() + LINE_INDEX_PARAGRAPH);
1218 tet_infoline(" UtcDaliTextLabelMarkupParagraphTagAlignAttribute - <p>Paragraph property alignment</p>");
1219 DALI_TEST_EQUALS(lineParagraphFromMultiAlign.alignmentOffset, lineParagraphFromCenterAlign.alignmentOffset, TEST_LOCATION);
1220 DALI_TEST_EQUALS(lineParagraphFromMultiAlign.width, lineParagraphFromCenterAlign.width, TEST_LOCATION);
1225 int UtcDaliTextLabelMarkupCharacterSpacingTag(void)
1227 ToolkitTestApplication application;
1228 tet_infoline(" UtcDaliTextLabelMarkupCharacterSpacingTag ");
1230 const Length EXPECTED_NUMBER_OF_GLYPHS = 21u;
1232 const float expandedCharSpacing = 10.0f;
1233 const float condensedCharSpacing = -5.0f;
1235 TextLabel textLabel = TextLabel::New();
1237 textLabel.SetProperty(TextLabel::Property::TEXT, "ABC EF\n<char-spacing value='-5.0f'>ABC EF\n</char-spacing><char-spacing value='10.0f'>ABC EF\n</char-spacing>");
1238 textLabel.SetProperty(TextLabel ::Property::ENABLE_MARKUP, true);
1239 textLabel.SetProperty(TextLabel::Property::MULTI_LINE, true);
1241 application.GetScene().Add(textLabel);
1243 application.SendNotification();
1244 application.Render();
1246 Toolkit::Internal::TextLabel& textLabelImpl = GetImpl(textLabel);
1247 Text::ViewInterface& view = textLabelImpl.GetTextController()->GetView();
1249 Length numberOfGlyphs = view.GetNumberOfGlyphs();
1251 DALI_TEST_EQUALS(numberOfGlyphs, EXPECTED_NUMBER_OF_GLYPHS, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
1253 Vector<GlyphInfo> glyphs;
1254 glyphs.Resize(numberOfGlyphs);
1256 Vector<Vector2> positions;
1257 positions.Resize(numberOfGlyphs);
1259 float alignmentOffset = 0u;
1260 numberOfGlyphs = view.GetGlyphs(glyphs.Begin(),
1266 const Length numberOfGlyphsOneLine = 7u;
1267 for(Length i = 0; i < numberOfGlyphsOneLine - 1u; i++)
1269 float diffLineNoCharSpacing = positions[i + 1].x - positions[i].x;
1271 float diffLineCondensedCharSpacing = positions[numberOfGlyphsOneLine + i + 1].x - positions[numberOfGlyphsOneLine + i].x;
1272 DALI_TEST_EQUALS(diffLineCondensedCharSpacing, diffLineNoCharSpacing + condensedCharSpacing, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
1274 float diffLineExpandedCharSpacing = positions[2u * numberOfGlyphsOneLine + i + 1].x - positions[2u * numberOfGlyphsOneLine + i].x;
1275 DALI_TEST_EQUALS(diffLineExpandedCharSpacing, diffLineNoCharSpacing + expandedCharSpacing, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
1281 int UtcDaliTextLabelMarkupSpanCharacterSpacing(void)
1283 ToolkitTestApplication application;
1284 tet_infoline(" UtcDaliTextLabelMarkupSpanCharacterSpacing ");
1286 const Length EXPECTED_NUMBER_OF_GLYPHS = 21u;
1288 const float expandedCharSpacing = 10.0f;
1289 const float condensedCharSpacing = -5.0f;
1291 std::string testText =
1292 "<span font-size='20' font-family='DejaVu Sans' font-width='condensed' font-slant='italic' text-color='blue' >ABC EF\n</span>"
1293 "<span font-size='20' font-family='DejaVu Sans' font-width='condensed' font-slant='italic' text-color='red' char-space-value='-5.0f'>ABC EF\n</span>"
1294 "<span font-size='20' font-family='DejaVu Sans' font-width='condensed' font-slant='italic' text-color='green' char-space-value='10.0f'>ABC EF\n</span>";
1296 TextLabel textLabel = TextLabel::New();
1298 textLabel.SetProperty(TextLabel::Property::TEXT, testText);
1299 textLabel.SetProperty(TextLabel ::Property::ENABLE_MARKUP, true);
1300 textLabel.SetProperty(TextLabel::Property::MULTI_LINE, true);
1302 application.GetScene().Add(textLabel);
1304 application.SendNotification();
1305 application.Render();
1307 Toolkit::Internal::TextLabel& textLabelImpl = GetImpl(textLabel);
1308 Text::ViewInterface& view = textLabelImpl.GetTextController()->GetView();
1310 Length numberOfGlyphs = view.GetNumberOfGlyphs();
1312 DALI_TEST_EQUALS(numberOfGlyphs, EXPECTED_NUMBER_OF_GLYPHS, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
1314 Vector<GlyphInfo> glyphs;
1315 glyphs.Resize(numberOfGlyphs);
1317 Vector<Vector2> positions;
1318 positions.Resize(numberOfGlyphs);
1320 float alignmentOffset = 0u;
1321 numberOfGlyphs = view.GetGlyphs(glyphs.Begin(),
1327 const Length numberOfGlyphsOneLine = 7u;
1328 for(Length i = 0; i < numberOfGlyphsOneLine - 1u; i++)
1330 float diffLineNoCharSpacing = positions[i + 1].x - positions[i].x;
1332 float diffLineCondensedCharSpacing = positions[numberOfGlyphsOneLine + i + 1].x - positions[numberOfGlyphsOneLine + i].x;
1333 DALI_TEST_EQUALS(diffLineCondensedCharSpacing, diffLineNoCharSpacing + condensedCharSpacing, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
1335 float diffLineExpandedCharSpacing = positions[2u * numberOfGlyphsOneLine + i + 1].x - positions[2u * numberOfGlyphsOneLine + i].x;
1336 DALI_TEST_EQUALS(diffLineExpandedCharSpacing, diffLineNoCharSpacing + expandedCharSpacing, Math::MACHINE_EPSILON_1000, TEST_LOCATION);