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-editor-impl.h>
25 #include <dali-toolkit/internal/text/rendering/atlas/atlas-glyph-manager.h>
26 #include <dali-toolkit/internal/text/text-controller-impl.h>
27 #include <dali-toolkit/internal/text/text-controller.h>
30 using namespace Toolkit;
33 int UtcDaliTextEditorSelectText(void)
35 ToolkitTestApplication application;
36 tet_infoline("UtcDaliTextEditorSelectText");
38 // Create a text editor
39 TextEditor textEditor = TextEditor::New();
40 textEditor.SetProperty(Actor::Property::SIZE, Vector2(400.f, 60.f));
41 textEditor.SetProperty(TextEditor::Property::TEXT, "Hello World");
43 // Add the text editor to the stage
44 application.GetScene().Add(textEditor);
46 application.SendNotification();
49 Toolkit::Internal::TextEditor& textEditorImpl = GetImpl(textEditor);
51 application.SendNotification();
54 // Highlight the whole text
55 textEditorImpl.SelectWholeText();
57 application.SendNotification();
60 std::string selectedText = textEditorImpl.GetSelectedText();
61 DALI_TEST_CHECK(selectedText == "Hello World");
64 textEditorImpl.SelectNone();
66 application.SendNotification();
69 selectedText = textEditorImpl.GetSelectedText();
70 DALI_TEST_CHECK(selectedText == "");
75 int UtcDaliTextEditorMarkupUnderline(void)
77 ToolkitTestApplication application;
78 tet_infoline(" UtcDaliTextEditorMarkupUnderline ");
80 TextEditor textEditor = TextEditor::New();
82 application.GetScene().Add(textEditor);
84 textEditor.SetProperty(TextEditor::Property::TEXT, "<u>ABC</u>EF<u>GH</u>");
85 textEditor.SetProperty(TextEditor ::Property::ENABLE_MARKUP, true);
87 application.SendNotification();
90 uint32_t expectedNumberOfUnderlinedGlyphs = 5u;
92 Toolkit::Internal::TextEditor& textEditorImpl = GetImpl(textEditor);
93 const Text::Length numberOfUnderlineRuns = textEditorImpl.GetTextController()->GetTextModel()->GetNumberOfUnderlineRuns();
95 DALI_TEST_EQUALS(numberOfUnderlineRuns, expectedNumberOfUnderlinedGlyphs, TEST_LOCATION);
97 Vector<UnderlinedGlyphRun> underlineRuns;
98 underlineRuns.Resize(numberOfUnderlineRuns);
99 textEditorImpl.GetTextController()->GetTextModel()->GetUnderlineRuns(underlineRuns.Begin(), 0u, numberOfUnderlineRuns);
102 DALI_TEST_EQUALS(underlineRuns[0u].glyphRun.glyphIndex, 0u, TEST_LOCATION);
103 DALI_TEST_EQUALS(underlineRuns[1u].glyphRun.glyphIndex, 1u, TEST_LOCATION);
104 DALI_TEST_EQUALS(underlineRuns[2u].glyphRun.glyphIndex, 2u, TEST_LOCATION);
107 DALI_TEST_EQUALS(underlineRuns[3u].glyphRun.glyphIndex, 5u, TEST_LOCATION);
108 DALI_TEST_EQUALS(underlineRuns[4u].glyphRun.glyphIndex, 6u, TEST_LOCATION);
113 int UtcDaliTextEditorMarkupUnderlineAttributes(void)
115 ToolkitTestApplication application;
116 tet_infoline(" UtcDaliTextEditorMarkupUnderlineAttributes ");
118 TextEditor textEditor = TextEditor::New();
120 application.GetScene().Add(textEditor);
122 std::string testText =
123 "start<u>ABC1</u>then"
124 "<u type='solid'>ABC2</u>then"
125 "<u type='dashed'>ABC3</u>then"
126 "<u type='double'>ABC4</u>then"
127 "<u color='green'>ABC5</u>then"
128 "<u height='5.0f'>ABC6</u>then"
129 "<u type='dashed' dash-gap='3.0f'>ABC7</u>then"
130 "<u type='dashed' dash-width='4.0f'>ABC8</u>then"
131 "<u color='blue' type='dashed' height='4.0f' dash-gap='2.0f' dash-width='3.0f'>ABC9</u>end"
135 textEditor.SetProperty(TextEditor::Property::TEXT, testText);
136 textEditor.SetProperty(TextEditor ::Property::ENABLE_MARKUP, true);
138 application.SendNotification();
139 application.Render();
141 const uint32_t NUMBER_OF_CASES = 9u;
142 uint32_t expectedNumberOfUnderlinedGlyphs = 36u;
144 Toolkit::Internal::TextEditor& textEditorImpl = GetImpl(textEditor);
145 const Text::Length numberOfUnderlineRuns = textEditorImpl.GetTextController()->GetTextModel()->GetNumberOfUnderlineRuns();
147 DALI_TEST_EQUALS(numberOfUnderlineRuns, expectedNumberOfUnderlinedGlyphs, TEST_LOCATION);
149 Vector<UnderlinedGlyphRun> underlineRuns;
150 underlineRuns.Resize(numberOfUnderlineRuns);
151 textEditorImpl.GetTextController()->GetTextModel()->GetUnderlineRuns(underlineRuns.Begin(), 0u, numberOfUnderlineRuns);
158 GlyphIndex startGlyphIndex;
159 GlyphIndex endGlyphIndex;
160 UnderlineStyleProperties properties;
171 Text::Underline::SOLID,
183 //<u type='solid'>ABC2</u>
184 {"<u type='solid'>ABC2</u>",
190 Text::Underline::SOLID,
202 //<u type='dashed'>ABC3</u>
203 {"<u type='dashed'>ABC3</u>",
209 Text::Underline::DASHED,
221 //<u type='double'>ABC4</u>
222 {"<u type='double'>ABC4</u>",
228 Text::Underline::DOUBLE,
240 //<u color='green'>ABC5</u>
241 {"<u color='green'>ABC5</u>",
247 Text::Underline::SOLID,
259 //<u height='5.0f'>ABC6</u>
260 {"<u height='5.0f'>ABC6</u>",
266 Text::Underline::SOLID,
278 //<u type='dashed' dash-gap='3.0f'>ABC7</u>
279 {"<u type='dashed' dash-gap='3.0f'>ABC7</u>",
285 Text::Underline::DASHED,
297 //<u type='dashed' dash-width='4.0f'>ABC8</u>
298 {"<u type='dashed' dash-width='4.0f'>ABC8</u>",
304 Text::Underline::DASHED,
316 //<u color='blue' type='dashed' height='4.0f' dash-gap='2.0f' dash-width='3.0f'>
317 {"<u color='blue' type='dashed' height='4.0f' dash-gap='2.0f' dash-width='3.0f'>",
323 Text::Underline::DASHED,
337 for(uint32_t i = 0; i < NUMBER_OF_CASES; i++)
339 tet_infoline(data[i].title.c_str());
340 DALI_TEST_EQUALS(underlineRuns[data[i].startIndex].glyphRun.glyphIndex, data[i].startGlyphIndex, TEST_LOCATION);
341 DALI_TEST_EQUALS(underlineRuns[data[i].endIndex].glyphRun.glyphIndex, data[i].endGlyphIndex, TEST_LOCATION);
343 DALI_TEST_CHECK(data[i].properties == underlineRuns[data[i].startIndex].properties);
344 DALI_TEST_CHECK(data[i].properties == underlineRuns[data[i].endIndex].properties);
350 int UtcDaliTextEditorMarkupSpanUnderline(void)
352 ToolkitTestApplication application;
353 tet_infoline(" UtcDaliTextEditorMarkupSpanUnderline ");
355 TextEditor textEditor = TextEditor::New();
357 application.GetScene().Add(textEditor);
359 std::string testText =
360 "start<span font-size='45' font-family='DejaVu Sans' font-width='condensed' font-slant='italic' text-color='red'>ABC1</span>then"
361 "<span font-size='45' font-family='DejaVu Sans' font-width='condensed' font-slant='italic' text-color='red' u-type='solid'>ABC2</span>then"
362 "<span font-size='45' font-family='DejaVu Sans' font-width='condensed' font-slant='italic' text-color='red' u-type='dashed'>ABC3</span>then"
363 "<span font-size='45' font-family='DejaVu Sans' font-width='condensed' font-slant='italic' text-color='red' u-type='double'>ABC4</span>then"
364 "<span font-size='45' font-family='DejaVu Sans' font-width='condensed' font-slant='italic' text-color='red' u-color='green'>ABC5</span>then"
365 "<span font-size='45' font-family='DejaVu Sans' font-width='condensed' font-slant='italic' text-color='red' u-height='5.0f'>ABC6</span>then"
366 "<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"
367 "<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"
368 "<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"
372 textEditor.SetProperty(TextEditor::Property::TEXT, testText);
373 textEditor.SetProperty(TextEditor ::Property::ENABLE_MARKUP, true);
375 application.SendNotification();
376 application.Render();
378 const uint32_t NUMBER_OF_CASES = 8u;
379 uint32_t expectedNumberOfUnderlinedGlyphs = 32u;
381 Toolkit::Internal::TextEditor& textEditorImpl = GetImpl(textEditor);
382 const Text::Length numberOfUnderlineRuns = textEditorImpl.GetTextController()->GetTextModel()->GetNumberOfUnderlineRuns();
384 DALI_TEST_EQUALS(numberOfUnderlineRuns, expectedNumberOfUnderlinedGlyphs, TEST_LOCATION);
386 Vector<UnderlinedGlyphRun> underlineRuns;
387 underlineRuns.Resize(numberOfUnderlineRuns);
388 textEditorImpl.GetTextController()->GetTextModel()->GetUnderlineRuns(underlineRuns.Begin(), 0u, numberOfUnderlineRuns);
395 GlyphIndex startGlyphIndex;
396 GlyphIndex endGlyphIndex;
397 UnderlineStyleProperties properties;
402 {"<span font-size='45' font-family='DejaVu Sans' font-width='condensed' font-slant='italic' text-color='red' u-type='solid'>ABC2</span>",
408 Text::Underline::SOLID,
420 {"<span font-size='45' font-family='DejaVu Sans' font-width='condensed' font-slant='italic' text-color='red' u-type='dashed'>ABC3</span>",
426 Text::Underline::DASHED,
438 {"<span font-size='45' font-family='DejaVu Sans' font-width='condensed' font-slant='italic' text-color='red' u-type='double'>ABC4</span>",
444 Text::Underline::DOUBLE,
456 {"<span font-size='45' font-family='DejaVu Sans' font-width='condensed' font-slant='italic' text-color='red' u-color='green'>ABC5</span>",
462 Text::Underline::SOLID,
474 {"<span font-size='45' font-family='DejaVu Sans' font-width='condensed' font-slant='italic' text-color='red' u-height='5.0f'>ABC6</span>",
480 Text::Underline::SOLID,
492 {"<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>",
498 Text::Underline::DASHED,
510 {"<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>",
516 Text::Underline::DASHED,
528 {"<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>",
534 Text::Underline::DASHED,
548 for(uint32_t i = 0; i < NUMBER_OF_CASES; i++)
550 tet_infoline(data[i].title.c_str());
551 DALI_TEST_EQUALS(underlineRuns[data[i].startIndex].glyphRun.glyphIndex, data[i].startGlyphIndex, TEST_LOCATION);
552 DALI_TEST_EQUALS(underlineRuns[data[i].endIndex].glyphRun.glyphIndex, data[i].endGlyphIndex, TEST_LOCATION);
554 DALI_TEST_CHECK(data[i].properties == underlineRuns[data[i].startIndex].properties);
555 DALI_TEST_CHECK(data[i].properties == underlineRuns[data[i].endIndex].properties);
561 int UtcDaliTextEditorFontPointSizeLargerThanAtlas(void)
563 ToolkitTestApplication application;
564 tet_infoline(" UtcDaliTextEditorFontPointSizeLargerThanAtlas ");
566 // Create a text editor
567 TextEditor textEditor = TextEditor::New();
568 //Set size to avoid automatic eliding
569 textEditor.SetProperty(Actor::Property::SIZE, Vector2(1025, 1025));
570 //Set very large font-size using point-size
571 textEditor.SetProperty(TextEditor::Property::POINT_SIZE, 1000);
572 //Specify font-family
573 textEditor.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
574 //Set text to check if appear or not
575 textEditor.SetProperty(TextEditor::Property::TEXT, "A");
577 application.GetScene().Add(textEditor);
579 application.SendNotification();
580 application.Render();
582 //Check if Glyph is added to AtlasGlyphManger or not
583 int countAtlas = AtlasGlyphManager::Get().GetMetrics().mAtlasMetrics.mAtlasCount;
584 DALI_TEST_EQUALS(countAtlas, 1, TEST_LOCATION);
589 int UtcDaliTextEditorFontPointSizeLargerThanAtlasPlaceholderCase(void)
591 ToolkitTestApplication application;
592 tet_infoline(" UtcDaliTextEditorFontPointSizeLargerThanAtlasPlaceholderCase ");
594 //Set Map of placeholder: text, font-family and point-size
595 Property::Map placeholderMapSet;
596 placeholderMapSet["text"] = "A";
597 placeholderMapSet["fontFamily"] = "DejaVu Sans";
598 placeholderMapSet["pixelSize"] = 1000.0f;
600 // Create a text editor
601 TextEditor textEditor = TextEditor::New();
602 //Set size to avoid automatic eliding
603 textEditor.SetProperty(Actor::Property::SIZE, Vector2(1025, 1025));
605 textEditor.SetProperty(TextEditor::Property::PLACEHOLDER, placeholderMapSet);
607 application.GetScene().Add(textEditor);
609 application.SendNotification();
610 application.Render();
612 //Check if Glyph is added to AtlasGlyphManger or not
613 int countAtlas = AtlasGlyphManager::Get().GetMetrics().mAtlasMetrics.mAtlasCount;
614 DALI_TEST_EQUALS(countAtlas, 1, TEST_LOCATION);
619 int UtcDaliTextEditorBackgroundTag(void)
621 ToolkitTestApplication application;
622 tet_infoline("UtcDaliTextEditorBackgroundTag\n");
624 TextEditor editor = TextEditor::New();
625 DALI_TEST_CHECK(editor);
627 editor.SetProperty(TextEditor ::Property::ENABLE_MARKUP, true);
628 editor.SetProperty(TextEditor::Property::TEXT, "H<background color='red'>e</background> Worl<background color='yellow'>d</background>");
629 application.GetScene().Add(editor);
630 application.SendNotification();
631 application.Render();
633 Toolkit::Internal::TextEditor& editorImpl = GetImpl(editor);
634 const ColorIndex* const backgroundColorIndicesBuffer = editorImpl.GetTextController()->GetTextModel()->GetBackgroundColorIndices();
636 DALI_TEST_CHECK(backgroundColorIndicesBuffer);
639 DALI_TEST_EQUALS(backgroundColorIndicesBuffer[0], 0u, TEST_LOCATION);
642 DALI_TEST_EQUALS(backgroundColorIndicesBuffer[1], 1u, TEST_LOCATION);
645 DALI_TEST_EQUALS(backgroundColorIndicesBuffer[7], 2u, TEST_LOCATION);
650 int UtcDaliTextEditorTextWithSpan(void)
652 ToolkitTestApplication application;
653 tet_infoline("UtcDaliTextEditorTextWithSpan\n");
655 TextEditor editor = TextEditor::New();
656 DALI_TEST_CHECK(editor);
658 editor.SetProperty(TextEditor ::Property::ENABLE_MARKUP, true);
659 editor.SetProperty(TextEditor::Property::TEXT, "Hello Span");
660 application.GetScene().Add(editor);
662 application.SendNotification();
663 application.Render();
665 Vector3 originalSize = editor.GetNaturalSize();
666 editor.SetProperty(TextEditor::Property::TEXT, "H<span font-size='45' font-family='DejaVu Sans' font-width='condensed' font-slant='italic' text-color='red'>ello</span> Span");
668 application.SendNotification();
669 application.Render();
671 Vector3 spanSize = editor.GetNaturalSize();
673 DALI_TEST_GREATER(spanSize.width, originalSize.width, TEST_LOCATION);
675 Toolkit::Internal::TextEditor& editorImpl = GetImpl(editor);
676 const ColorIndex* const colorIndicesBuffer1 = editorImpl.GetTextController()->GetTextModel()->GetColorIndices();
678 DALI_TEST_CHECK(colorIndicesBuffer1);
681 DALI_TEST_EQUALS(colorIndicesBuffer1[0], 0u, TEST_LOCATION);
684 DALI_TEST_EQUALS(colorIndicesBuffer1[1], 1u, TEST_LOCATION);
687 DALI_TEST_EQUALS(colorIndicesBuffer1[6], 0u, TEST_LOCATION);
689 editor.SetProperty(TextEditor::Property::TEXT, "<span font-size='45'>H</span>ello <span text-color='red'>S</span>pan");
691 application.SendNotification();
692 application.Render();
694 const ColorIndex* const colorIndicesBuffer2 = editorImpl.GetTextController()->GetTextModel()->GetColorIndices();
696 DALI_TEST_CHECK(colorIndicesBuffer2);
699 DALI_TEST_EQUALS(colorIndicesBuffer2[0], 0u, TEST_LOCATION);
702 DALI_TEST_EQUALS(colorIndicesBuffer2[1], 0u, TEST_LOCATION);
705 DALI_TEST_EQUALS(colorIndicesBuffer2[6], 1u, TEST_LOCATION);
708 DALI_TEST_EQUALS(colorIndicesBuffer2[7], 0u, TEST_LOCATION);
713 int UtcDaliTextEditorControlBackgroundColor(void)
715 ToolkitTestApplication application;
716 tet_infoline(" UtcDaliTextEditorControlBackgroundColor\n");
718 TextEditor editor = TextEditor::New();
719 DALI_TEST_CHECK(editor);
721 Vector4 backgroundColor;
723 editor.SetProperty(TextEditor::Property::TEXT, "Background Color");
724 application.GetScene().Add(editor);
725 application.SendNotification();
726 application.Render();
728 Toolkit::Internal::TextEditor& editorImpl = GetImpl(editor);
729 ControllerPtr controller = editorImpl.GetTextController();
730 Controller::Impl& controllerImpl = Controller::Impl::GetImplementation(*controller.Get());
732 // Default color is transparent
733 controllerImpl.mEditableControlInterface->GetControlBackgroundColor(backgroundColor);
734 DALI_TEST_EQUALS(backgroundColor, Color::TRANSPARENT, TEST_LOCATION);
736 // Set background color to red
737 editor.SetBackgroundColor(Color::RED);
738 application.SendNotification();
739 application.Render();
742 controllerImpl.mEditableControlInterface->GetControlBackgroundColor(backgroundColor);
743 DALI_TEST_EQUALS(backgroundColor, Color::RED, TEST_LOCATION);
748 int UtcDaliTextEditorTextPositionWithMinLineAndBigFont(void)
750 ToolkitTestApplication application;
751 tet_infoline(" UtcDaliTextEditorTextPositionWithMinLine ");
753 TextEditor textEditor = TextEditor::New();
755 textEditor.SetProperty(TextEditor::Property::TEXT, "<span font-size='45'>H</span>\ni");
756 textEditor.SetProperty(DevelTextEditor::Property::MIN_LINE_SIZE, 50);
757 textEditor.SetProperty(TextEditor ::Property::ENABLE_MARKUP, true);
759 application.GetScene().Add(textEditor);
761 application.SendNotification();
762 application.Render();
764 Toolkit::Internal::TextEditor& textEditorImpl = GetImpl(textEditor);
765 Text::ViewInterface& view = textEditorImpl.GetTextController()->GetView();
767 Length numberOfGlyphs = view.GetNumberOfGlyphs();
769 DALI_TEST_EQUALS(numberOfGlyphs, 3u, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
771 Vector<GlyphInfo> glyphs;
772 glyphs.Resize(numberOfGlyphs);
774 Vector<Vector2> positions;
775 positions.Resize(numberOfGlyphs);
777 float alignmentOffset = 0u;
778 numberOfGlyphs = view.GetGlyphs(glyphs.Begin(),
784 DALI_TEST_EQUALS(positions[2].y, 165.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
789 int UtcDaliTextEditorMarkupStrikethrough(void)
791 ToolkitTestApplication application;
792 tet_infoline(" UtcDaliTextEditorMarkupStrikethrough ");
794 TextEditor textEditor = TextEditor::New();
796 application.GetScene().Add(textEditor);
798 textEditor.SetProperty(TextEditor::Property::TEXT, "<s>ABC</s>EF<s color='red'>GH</s>");
799 textEditor.SetProperty(TextEditor ::Property::ENABLE_MARKUP, true);
801 application.SendNotification();
802 application.Render();
804 uint32_t expectedNumberOfStrikethroughGlyphs = 2u;
806 Toolkit::Internal::TextEditor& textEditorImpl = GetImpl(textEditor);
807 const Text::Length numberOfStrikethroughRuns = textEditorImpl.GetTextController()->GetTextModel()->GetNumberOfStrikethroughRuns();
809 DALI_TEST_EQUALS(numberOfStrikethroughRuns, expectedNumberOfStrikethroughGlyphs, TEST_LOCATION);
811 Vector<StrikethroughGlyphRun> strikethroughRuns;
812 strikethroughRuns.Resize(numberOfStrikethroughRuns);
813 textEditorImpl.GetTextController()->GetTextModel()->GetStrikethroughRuns(strikethroughRuns.Begin(), 0u, numberOfStrikethroughRuns);
815 //ABC have strikethrough
816 DALI_TEST_EQUALS(strikethroughRuns[0u].glyphRun.glyphIndex, 0u, TEST_LOCATION);
817 DALI_TEST_EQUALS(strikethroughRuns[0u].glyphRun.numberOfGlyphs, 3u, TEST_LOCATION);
818 DALI_TEST_CHECK(!strikethroughRuns[0u].isColorSet);
820 //GH have strikethrough
821 DALI_TEST_EQUALS(strikethroughRuns[1u].glyphRun.glyphIndex, 5u, TEST_LOCATION);
822 DALI_TEST_EQUALS(strikethroughRuns[1u].glyphRun.numberOfGlyphs, 2u, TEST_LOCATION);
823 DALI_TEST_CHECK(strikethroughRuns[1u].isColorSet);
828 int UtcDaliTextEditorMarkupStrikethroughNoEndTag(void)
830 ToolkitTestApplication application;
831 tet_infoline(" UtcDaliTextEditorMarkupStrikethroughNoEndTag ");
833 TextEditor textEditor = TextEditor::New();
835 application.GetScene().Add(textEditor);
837 textEditor.SetProperty(TextEditor::Property::TEXT, "<s>ABC");
838 textEditor.SetProperty(TextEditor ::Property::ENABLE_MARKUP, true);
840 application.SendNotification();
841 application.Render();
843 uint32_t expectedNumberOfStrikethroughGlyphs = 0u;
845 Toolkit::Internal::TextEditor& textEditorImpl = GetImpl(textEditor);
846 Text::Length numberOfStrikethroughRuns = textEditorImpl.GetTextController()->GetTextModel()->GetNumberOfStrikethroughRuns();
848 DALI_TEST_EQUALS(numberOfStrikethroughRuns, expectedNumberOfStrikethroughGlyphs, TEST_LOCATION);
853 int UtcDaliTextEditorMarkupParagraphTag(void)
856 ToolkitTestApplication application;
857 tet_infoline(" UtcDaliTextEditorMarkupParagraphTag ");
859 TextEditor textEditor = TextEditor::New();
860 application.GetScene().Add(textEditor);
862 textEditor.SetProperty(TextEditor::Property::TEXT, "text one <p>Paragraph two</p> text three <p>Paragraph four</p> text five");
863 textEditor.SetProperty(TextEditor ::Property::ENABLE_MARKUP, true);
865 application.SendNotification();
866 application.Render();
868 uint32_t expectedNumberOfBoundedParagraphRuns = 2u;
870 Toolkit::Internal::TextEditor& textEditorImpl = GetImpl(textEditor);
871 const Text::Length numberOfBoundedParagraphRuns = textEditorImpl.GetTextController()->GetTextModel()->GetNumberOfBoundedParagraphRuns();
872 DALI_TEST_EQUALS(numberOfBoundedParagraphRuns, expectedNumberOfBoundedParagraphRuns, TEST_LOCATION);
874 const Vector<BoundedParagraphRun>& boundedParagraphRuns = textEditorImpl.GetTextController()->GetTextModel()->GetBoundedParagraphRuns();
876 //<p>Paragraph two</p>
877 DALI_TEST_EQUALS(boundedParagraphRuns[0u].characterRun.characterIndex, 10u, TEST_LOCATION);
878 DALI_TEST_EQUALS(boundedParagraphRuns[0u].characterRun.numberOfCharacters, 14u, TEST_LOCATION);
880 //<p>Paragraph four</p>
881 DALI_TEST_EQUALS(boundedParagraphRuns[1u].characterRun.characterIndex, 37u, TEST_LOCATION);
882 DALI_TEST_EQUALS(boundedParagraphRuns[1u].characterRun.numberOfCharacters, 15u, TEST_LOCATION);
887 int UtcDaliTextEditorMarkupParagraphTagAlignAttribute(void)
889 ToolkitTestApplication application;
890 tet_infoline(" UtcDaliTextEditorMarkupParagraphTagAlignAttribute ");
892 // Apply alignment for each type on property level on three paragraphs and in-between text.
893 // Apply align in markup on the three paragraphs (each one a type).
894 // Using the same text to gain similar results from both the property level and the markup.
895 // Compare line alignment between the property level and the markup.
897 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>";
898 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>";
900 //Set size to avoid automatic eliding
901 Vector2 controllerSize = Vector2(1025, 1025);
903 TextEditor textEditorBeginAlign = TextEditor::New();
904 TextEditor textEditorCenterAlign = TextEditor::New();
905 TextEditor textEditorEndAlign = TextEditor::New();
906 TextEditor textEditorMultiAlign = TextEditor::New();
908 application.GetScene().Add(textEditorBeginAlign);
909 application.GetScene().Add(textEditorCenterAlign);
910 application.GetScene().Add(textEditorEndAlign);
911 application.GetScene().Add(textEditorMultiAlign);
913 textEditorBeginAlign.SetProperty(TextEditor::Property::TEXT, textAlignOnPropertyLevel);
914 textEditorBeginAlign.SetProperty(TextEditor ::Property::ENABLE_MARKUP, true);
915 textEditorBeginAlign.SetProperty(DevelTextEditor::Property::ELLIPSIS, false);
916 textEditorBeginAlign.SetProperty(TextEditor::Property::HORIZONTAL_ALIGNMENT, Dali::Toolkit::Text::HorizontalAlignment::BEGIN);
917 textEditorBeginAlign.SetProperty(Actor::Property::SIZE, controllerSize);
919 textEditorCenterAlign.SetProperty(TextEditor::Property::TEXT, textAlignOnPropertyLevel);
920 textEditorCenterAlign.SetProperty(TextEditor ::Property::ENABLE_MARKUP, true);
921 textEditorCenterAlign.SetProperty(DevelTextEditor::Property::ELLIPSIS, false);
922 textEditorCenterAlign.SetProperty(TextEditor::Property::HORIZONTAL_ALIGNMENT, Dali::Toolkit::Text::HorizontalAlignment::CENTER);
923 textEditorCenterAlign.SetProperty(Actor::Property::SIZE, controllerSize);
925 textEditorEndAlign.SetProperty(TextEditor::Property::TEXT, textAlignOnPropertyLevel);
926 textEditorEndAlign.SetProperty(TextEditor ::Property::ENABLE_MARKUP, true);
927 textEditorEndAlign.SetProperty(DevelTextEditor::Property::ELLIPSIS, false);
928 textEditorEndAlign.SetProperty(TextEditor::Property::HORIZONTAL_ALIGNMENT, Dali::Toolkit::Text::HorizontalAlignment::END);
929 textEditorEndAlign.SetProperty(Actor::Property::SIZE, controllerSize);
931 textEditorMultiAlign.SetProperty(TextEditor::Property::TEXT, textAlignInMarkup);
932 textEditorMultiAlign.SetProperty(TextEditor ::Property::ENABLE_MARKUP, true);
933 textEditorMultiAlign.SetProperty(DevelTextEditor::Property::ELLIPSIS, false);
934 textEditorMultiAlign.SetProperty(TextEditor::Property::HORIZONTAL_ALIGNMENT, Dali::Toolkit::Text::HorizontalAlignment::CENTER);
935 textEditorMultiAlign.SetProperty(Actor::Property::SIZE, controllerSize);
937 application.SendNotification();
938 application.Render();
940 uint32_t expectedNumberOfBoundedParagraphRuns = 4u;
941 uint32_t expectedNumberOfLines = 7u;
943 Toolkit::Internal::TextEditor& textEditorMultiAlignImpl = GetImpl(textEditorMultiAlign);
944 Toolkit::Internal::TextEditor& textEditorBeginAlignImpl = GetImpl(textEditorBeginAlign);
945 Toolkit::Internal::TextEditor& textEditorCenterAlignImpl = GetImpl(textEditorCenterAlign);
946 Toolkit::Internal::TextEditor& textEditorEndAlignImpl = GetImpl(textEditorEndAlign);
948 const Text::Length numberOfBoundedParagraphRuns = textEditorMultiAlignImpl.GetTextController()->GetTextModel()->GetNumberOfBoundedParagraphRuns();
949 DALI_TEST_EQUALS(numberOfBoundedParagraphRuns, expectedNumberOfBoundedParagraphRuns, TEST_LOCATION);
951 DALI_TEST_EQUALS(textEditorMultiAlignImpl.GetTextController()->GetTextModel()->GetNumberOfLines(), expectedNumberOfLines, TEST_LOCATION);
952 DALI_TEST_CHECK(textEditorMultiAlignImpl.GetTextController()->GetTextModel()->GetLines());
954 DALI_TEST_EQUALS(textEditorBeginAlignImpl.GetTextController()->GetTextModel()->GetNumberOfLines(), expectedNumberOfLines, TEST_LOCATION);
955 DALI_TEST_CHECK(textEditorBeginAlignImpl.GetTextController()->GetTextModel()->GetLines());
957 DALI_TEST_EQUALS(textEditorCenterAlignImpl.GetTextController()->GetTextModel()->GetNumberOfLines(), expectedNumberOfLines, TEST_LOCATION);
958 DALI_TEST_CHECK(textEditorCenterAlignImpl.GetTextController()->GetTextModel()->GetLines());
960 DALI_TEST_EQUALS(textEditorEndAlignImpl.GetTextController()->GetTextModel()->GetNumberOfLines(), expectedNumberOfLines, TEST_LOCATION);
961 DALI_TEST_CHECK(textEditorEndAlignImpl.GetTextController()->GetTextModel()->GetLines());
963 const uint32_t LINE_INDEX_ALIGN_END = 1u;
964 const uint32_t LINE_INDEX_ALIGN_CENTER = 3u;
965 const uint32_t LINE_INDEX_ALIGN_BEGIN = 5u;
966 const uint32_t LINE_INDEX_OUTSIDE_1 = 0u;
967 const uint32_t LINE_INDEX_OUTSIDE_2 = 2u;
968 const uint32_t LINE_INDEX_OUTSIDE_3 = 4u;
969 const uint32_t LINE_INDEX_PARAGRAPH = 6u;
971 //<p align='end'>Paragraph end</p>
972 const LineRun& lineEndFromMultiAlign = *(textEditorMultiAlignImpl.GetTextController()->GetTextModel()->GetLines() + LINE_INDEX_ALIGN_END);
973 const LineRun& lineEndFromEndAlign = *(textEditorEndAlignImpl.GetTextController()->GetTextModel()->GetLines() + LINE_INDEX_ALIGN_END);
974 tet_infoline(" UtcDaliTextEditorMarkupParagraphTagAlignAttribute - <p align='end'>Paragraph end</p>");
975 DALI_TEST_EQUALS(lineEndFromMultiAlign.alignmentOffset, lineEndFromEndAlign.alignmentOffset, TEST_LOCATION);
976 DALI_TEST_EQUALS(lineEndFromMultiAlign.width, lineEndFromEndAlign.width, TEST_LOCATION);
978 //<p align='center'>Paragraph center</p>
979 const LineRun& lineCenterFromMultiAlign = *(textEditorMultiAlignImpl.GetTextController()->GetTextModel()->GetLines() + LINE_INDEX_ALIGN_CENTER);
980 const LineRun& lineEndFromCenterAlign = *(textEditorCenterAlignImpl.GetTextController()->GetTextModel()->GetLines() + LINE_INDEX_ALIGN_CENTER);
981 tet_infoline(" UtcDaliTextEditorMarkupParagraphTagAlignAttribute - <p align='center'>Paragraph center</p>");
982 DALI_TEST_EQUALS(lineCenterFromMultiAlign.alignmentOffset, lineEndFromCenterAlign.alignmentOffset, TEST_LOCATION);
983 DALI_TEST_EQUALS(lineCenterFromMultiAlign.width, lineEndFromCenterAlign.width, TEST_LOCATION);
985 //<p align='begin' >Paragraph begin</p>
986 const LineRun& lineBeginFromMultiAlign = *(textEditorMultiAlignImpl.GetTextController()->GetTextModel()->GetLines() + LINE_INDEX_ALIGN_BEGIN);
987 const LineRun& lineEndFromBeginAlign = *(textEditorBeginAlignImpl.GetTextController()->GetTextModel()->GetLines() + LINE_INDEX_ALIGN_BEGIN);
988 tet_infoline(" UtcDaliTextEditorMarkupParagraphTagAlignAttribute - <p align='begin' >Paragraph begin</p>");
989 DALI_TEST_EQUALS(lineBeginFromMultiAlign.alignmentOffset, lineEndFromBeginAlign.alignmentOffset, TEST_LOCATION);
990 DALI_TEST_EQUALS(lineBeginFromMultiAlign.width, lineEndFromBeginAlign.width, TEST_LOCATION);
993 const LineRun& lineOutsideOneFromMultiAlign = *(textEditorMultiAlignImpl.GetTextController()->GetTextModel()->GetLines() + LINE_INDEX_OUTSIDE_1);
994 const LineRun& lineOutsideOneFromCenterAlign = *(textEditorCenterAlignImpl.GetTextController()->GetTextModel()->GetLines() + LINE_INDEX_OUTSIDE_1);
995 tet_infoline(" UtcDaliTextEditorMarkupParagraphTagAlignAttribute - text outside one");
996 DALI_TEST_EQUALS(lineOutsideOneFromMultiAlign.alignmentOffset, lineOutsideOneFromCenterAlign.alignmentOffset, TEST_LOCATION);
997 DALI_TEST_EQUALS(lineOutsideOneFromMultiAlign.width, lineOutsideOneFromCenterAlign.width, TEST_LOCATION);
999 const LineRun& lineOutsideTwoFromMultiAlign = *(textEditorMultiAlignImpl.GetTextController()->GetTextModel()->GetLines() + LINE_INDEX_OUTSIDE_2);
1000 const LineRun& lineOutsideTwoFromCenterAlign = *(textEditorCenterAlignImpl.GetTextController()->GetTextModel()->GetLines() + LINE_INDEX_OUTSIDE_2);
1001 tet_infoline(" UtcDaliTextEditorMarkupParagraphTagAlignAttribute - text outside two");
1002 DALI_TEST_EQUALS(lineOutsideTwoFromMultiAlign.alignmentOffset, lineOutsideTwoFromCenterAlign.alignmentOffset, TEST_LOCATION);
1003 DALI_TEST_EQUALS(lineOutsideTwoFromMultiAlign.width, lineOutsideTwoFromCenterAlign.width, TEST_LOCATION);
1005 const LineRun& lineOutsideThreeFromMultiAlign = *(textEditorMultiAlignImpl.GetTextController()->GetTextModel()->GetLines() + LINE_INDEX_OUTSIDE_3);
1006 const LineRun& lineOutsideThreeFromCenterAlign = *(textEditorCenterAlignImpl.GetTextController()->GetTextModel()->GetLines() + LINE_INDEX_OUTSIDE_3);
1007 tet_infoline(" UtcDaliTextEditorMarkupParagraphTagAlignAttribute - text outside three");
1008 DALI_TEST_EQUALS(lineOutsideThreeFromMultiAlign.alignmentOffset, lineOutsideThreeFromCenterAlign.alignmentOffset, TEST_LOCATION);
1009 DALI_TEST_EQUALS(lineOutsideThreeFromMultiAlign.width, lineOutsideThreeFromCenterAlign.width, TEST_LOCATION);
1011 const LineRun& lineParagraphFromMultiAlign = *(textEditorMultiAlignImpl.GetTextController()->GetTextModel()->GetLines() + LINE_INDEX_PARAGRAPH);
1012 const LineRun& lineParagraphFromCenterAlign = *(textEditorCenterAlignImpl.GetTextController()->GetTextModel()->GetLines() + LINE_INDEX_PARAGRAPH);
1013 tet_infoline(" UtcDaliTextEditorMarkupParagraphTagAlignAttribute - <p>Paragraph property alignment</p>");
1014 DALI_TEST_EQUALS(lineParagraphFromMultiAlign.alignmentOffset, lineParagraphFromCenterAlign.alignmentOffset, TEST_LOCATION);
1015 DALI_TEST_EQUALS(lineParagraphFromMultiAlign.width, lineParagraphFromCenterAlign.width, TEST_LOCATION);