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/controller/text-controller.h>
27 #include <dali-toolkit/internal/text/controller/text-controller-impl.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 expectedNumberOfUnderlineRuns = 2u;
92 Toolkit::Internal::TextEditor& textEditorImpl = GetImpl(textEditor);
93 const Text::Length numberOfUnderlineRuns = textEditorImpl.GetTextController()->GetTextModel()->GetNumberOfUnderlineRuns();
95 DALI_TEST_EQUALS(numberOfUnderlineRuns, expectedNumberOfUnderlineRuns, 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[0u].glyphRun.numberOfGlyphs, 3u, TEST_LOCATION);
106 DALI_TEST_EQUALS(underlineRuns[1u].glyphRun.glyphIndex, 5u, TEST_LOCATION);
107 DALI_TEST_EQUALS(underlineRuns[1u].glyphRun.numberOfGlyphs, 2u, TEST_LOCATION);
112 int UtcDaliTextEditorMarkupUnderlineAttributes(void)
114 ToolkitTestApplication application;
115 tet_infoline(" UtcDaliTextEditorMarkupUnderlineAttributes ");
117 TextEditor textEditor = TextEditor::New();
119 application.GetScene().Add(textEditor);
121 std::string testText =
122 "start<u>ABC1</u>then"
123 "<u type='solid'>ABC2</u>then"
124 "<u type='dashed'>ABC3</u>then"
125 "<u type='double'>ABC4</u>then"
126 "<u color='green'>ABC5</u>then"
127 "<u height='5.0f'>ABC6</u>then"
128 "<u type='dashed' dash-gap='3.0f'>ABC7</u>then"
129 "<u type='dashed' dash-width='4.0f'>ABC8</u>then"
130 "<u color='blue' type='dashed' height='4.0f' dash-gap='2.0f' dash-width='3.0f'>ABC9</u>end";
132 textEditor.SetProperty(TextEditor::Property::TEXT, testText);
133 textEditor.SetProperty(TextEditor ::Property::ENABLE_MARKUP, true);
135 application.SendNotification();
136 application.Render();
138 const uint32_t expectedNumberOfUnderlineRuns = 9u;
140 Toolkit::Internal::TextEditor& textEditorImpl = GetImpl(textEditor);
141 const Text::Length numberOfUnderlineRuns = textEditorImpl.GetTextController()->GetTextModel()->GetNumberOfUnderlineRuns();
143 DALI_TEST_EQUALS(numberOfUnderlineRuns, expectedNumberOfUnderlineRuns, TEST_LOCATION);
145 Vector<UnderlinedGlyphRun> underlineRuns;
146 underlineRuns.Resize(numberOfUnderlineRuns);
147 textEditorImpl.GetTextController()->GetTextModel()->GetUnderlineRuns(underlineRuns.Begin(), 0u, numberOfUnderlineRuns);
152 GlyphIndex glyphIndex;
153 Length numberOfGlyphs;
154 UnderlineStyleProperties properties;
163 Text::Underline::SOLID,
175 //<u type='solid'>ABC2</u>
176 {"<u type='solid'>ABC2</u>",
180 Text::Underline::SOLID,
192 //<u type='dashed'>ABC3</u>
193 {"<u type='dashed'>ABC3</u>",
197 Text::Underline::DASHED,
209 //<u type='double'>ABC4</u>
210 {"<u type='double'>ABC4</u>",
214 Text::Underline::DOUBLE,
226 //<u color='green'>ABC5</u>
227 {"<u color='green'>ABC5</u>",
231 Text::Underline::SOLID,
243 //<u height='5.0f'>ABC6</u>
244 {"<u height='5.0f'>ABC6</u>",
248 Text::Underline::SOLID,
260 //<u type='dashed' dash-gap='3.0f'>ABC7</u>
261 {"<u type='dashed' dash-gap='3.0f'>ABC7</u>",
265 Text::Underline::DASHED,
277 //<u type='dashed' dash-width='4.0f'>ABC8</u>
278 {"<u type='dashed' dash-width='4.0f'>ABC8</u>",
282 Text::Underline::DASHED,
294 //<u color='blue' type='dashed' height='4.0f' dash-gap='2.0f' dash-width='3.0f'>
295 {"<u color='blue' type='dashed' height='4.0f' dash-gap='2.0f' dash-width='3.0f'>",
299 Text::Underline::DASHED,
313 for(uint32_t i = 0; i < expectedNumberOfUnderlineRuns; i++)
315 tet_infoline(data[i].title.c_str());
316 DALI_TEST_EQUALS(underlineRuns[i].glyphRun.glyphIndex, data[i].glyphIndex, TEST_LOCATION);
317 DALI_TEST_EQUALS(underlineRuns[i].glyphRun.numberOfGlyphs, data[i].numberOfGlyphs, TEST_LOCATION);
318 DALI_TEST_CHECK(data[i].properties == underlineRuns[i].properties);
324 int UtcDaliTextEditorMarkupSpanUnderline(void)
326 ToolkitTestApplication application;
327 tet_infoline(" UtcDaliTextEditorMarkupSpanUnderline ");
329 TextEditor textEditor = TextEditor::New();
331 application.GetScene().Add(textEditor);
333 std::string testText =
334 "start<span font-size='45' font-family='DejaVu Sans' font-width='condensed' font-slant='italic' text-color='red'>ABC1</span>then"
335 "<span font-size='45' font-family='DejaVu Sans' font-width='condensed' font-slant='italic' text-color='red' u-type='solid'>ABC2</span>then"
336 "<span font-size='45' font-family='DejaVu Sans' font-width='condensed' font-slant='italic' text-color='red' u-type='dashed'>ABC3</span>then"
337 "<span font-size='45' font-family='DejaVu Sans' font-width='condensed' font-slant='italic' text-color='red' u-type='double'>ABC4</span>then"
338 "<span font-size='45' font-family='DejaVu Sans' font-width='condensed' font-slant='italic' text-color='red' u-color='green'>ABC5</span>then"
339 "<span font-size='45' font-family='DejaVu Sans' font-width='condensed' font-slant='italic' text-color='red' u-height='5.0f'>ABC6</span>then"
340 "<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"
341 "<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"
342 "<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";
344 textEditor.SetProperty(TextEditor::Property::TEXT, testText);
345 textEditor.SetProperty(TextEditor ::Property::ENABLE_MARKUP, true);
347 application.SendNotification();
348 application.Render();
350 const uint32_t expectedNumberOfUnderlineRuns = 8u;
352 Toolkit::Internal::TextEditor& textEditorImpl = GetImpl(textEditor);
353 const Text::Length numberOfUnderlineRuns = textEditorImpl.GetTextController()->GetTextModel()->GetNumberOfUnderlineRuns();
355 DALI_TEST_EQUALS(numberOfUnderlineRuns, expectedNumberOfUnderlineRuns, TEST_LOCATION);
357 Vector<UnderlinedGlyphRun> underlineRuns;
358 underlineRuns.Resize(numberOfUnderlineRuns);
359 textEditorImpl.GetTextController()->GetTextModel()->GetUnderlineRuns(underlineRuns.Begin(), 0u, numberOfUnderlineRuns);
364 GlyphIndex glyphIndex;
365 Length numberOfGlyphs;
366 UnderlineStyleProperties properties;
370 //<u type='solid'>ABC2</u>
371 {"<span font-size='45' font-family='DejaVu Sans' font-width='condensed' font-slant='italic' text-color='red' u-type='solid'>ABC2</span>",
375 Text::Underline::SOLID,
387 //<u type='dashed'>ABC3</u>
388 {"<span font-size='45' font-family='DejaVu Sans' font-width='condensed' font-slant='italic' text-color='red' u-type='dashed'>ABC3</span>",
392 Text::Underline::DASHED,
404 //<u type='double'>ABC4</u>
405 {"<span font-size='45' font-family='DejaVu Sans' font-width='condensed' font-slant='italic' text-color='red' u-type='double'>ABC4</span>",
409 Text::Underline::DOUBLE,
421 //<u color='green'>ABC5</u>
422 {"<span font-size='45' font-family='DejaVu Sans' font-width='condensed' font-slant='italic' text-color='red' u-color='green'>ABC5</span>",
426 Text::Underline::SOLID,
438 //<u height='5.0f'>ABC6</u>
439 {"<span font-size='45' font-family='DejaVu Sans' font-width='condensed' font-slant='italic' text-color='red' u-height='5.0f'>ABC6</span>",
443 Text::Underline::SOLID,
455 //<u type='dashed' dash-gap='3.0f'>ABC7</u>
456 {"<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>",
460 Text::Underline::DASHED,
472 //<u type='dashed' dash-width='4.0f'>ABC8</u>
473 {"<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>",
477 Text::Underline::DASHED,
489 //<u color='blue' type='dashed' height='4.0f' dash-gap='2.0f' dash-width='3.0f'>
490 {"<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>",
494 Text::Underline::DASHED,
508 for(uint32_t i = 0; i < expectedNumberOfUnderlineRuns; i++)
510 tet_infoline(data[i].title.c_str());
511 DALI_TEST_EQUALS(underlineRuns[i].glyphRun.glyphIndex, data[i].glyphIndex, TEST_LOCATION);
512 DALI_TEST_EQUALS(underlineRuns[i].glyphRun.numberOfGlyphs, data[i].numberOfGlyphs, TEST_LOCATION);
513 DALI_TEST_CHECK(data[i].properties == underlineRuns[i].properties);
519 int UtcDaliTextEditorMarkupNestedUnderlineTags(void)
521 ToolkitTestApplication application;
522 tet_infoline(" UtcDaliTextEditorMarkupNestedUnderlineTags ");
524 TextEditor textEditor = TextEditor::New();
526 application.GetScene().Add(textEditor);
528 std::string testText = "start<u height='5.0f' color='green' >AB<u color='blue' >XYZ</u>CDE</u>end";
530 textEditor.SetProperty(TextEditor::Property::TEXT, testText);
531 textEditor.SetProperty(TextEditor ::Property::ENABLE_MARKUP, true);
533 application.SendNotification();
534 application.Render();
536 const uint32_t expectedNumberOfUnderlineRuns = 2u;
538 Toolkit::Internal::TextEditor& textEditorImpl = GetImpl(textEditor);
539 const Text::Length numberOfUnderlineRuns = textEditorImpl.GetTextController()->GetTextModel()->GetNumberOfUnderlineRuns();
541 DALI_TEST_EQUALS(numberOfUnderlineRuns, expectedNumberOfUnderlineRuns, TEST_LOCATION);
543 Vector<UnderlinedGlyphRun> underlineRuns;
544 underlineRuns.Resize(numberOfUnderlineRuns);
545 textEditorImpl.GetTextController()->GetTextModel()->GetUnderlineRuns(underlineRuns.Begin(), 0u, numberOfUnderlineRuns);
550 GlyphIndex glyphIndex;
551 Length numberOfGlyphs;
552 UnderlineStyleProperties properties;
557 {"<u height='5.0f' color='green' >AB<u color='blue' >XYZ</u>CDE</u>",
561 Text::Underline::SOLID,
574 {"<u color='blue' >XYZ</u>",
578 Text::Underline::SOLID,
592 for(uint32_t i = 0; i < expectedNumberOfUnderlineRuns; i++)
594 tet_infoline(data[i].title.c_str());
595 DALI_TEST_EQUALS(underlineRuns[i].glyphRun.glyphIndex, data[i].glyphIndex, TEST_LOCATION);
596 DALI_TEST_EQUALS(underlineRuns[i].glyphRun.numberOfGlyphs, data[i].numberOfGlyphs, TEST_LOCATION);
597 DALI_TEST_CHECK(data[i].properties == underlineRuns[i].properties);
603 int UtcDaliTextEditorMarkupNestedStrikethroughTags(void)
605 ToolkitTestApplication application;
606 tet_infoline(" UtcDaliTextEditorMarkupNestedStrikethroughTags ");
608 TextEditor textEditor = TextEditor::New();
610 application.GetScene().Add(textEditor);
612 std::string testText = "start<s height='5.0f' color='green' >AB<s color='blue' >XYZ</s>CDE</s>end";
614 textEditor.SetProperty(TextEditor::Property::TEXT, testText);
615 textEditor.SetProperty(TextEditor ::Property::ENABLE_MARKUP, true);
617 application.SendNotification();
618 application.Render();
620 const uint32_t expectedNumberOfStrikethroughRuns = 2u;
622 Toolkit::Internal::TextEditor& textEditorImpl = GetImpl(textEditor);
623 const Text::Length numberOfStrikethroughRuns = textEditorImpl.GetTextController()->GetTextModel()->GetNumberOfStrikethroughRuns();
625 DALI_TEST_EQUALS(numberOfStrikethroughRuns, expectedNumberOfStrikethroughRuns, TEST_LOCATION);
627 Vector<StrikethroughGlyphRun> strikethroughRuns;
628 strikethroughRuns.Resize(numberOfStrikethroughRuns);
629 textEditorImpl.GetTextController()->GetTextModel()->GetStrikethroughRuns(strikethroughRuns.Begin(), 0u, numberOfStrikethroughRuns);
634 GlyphIndex glyphIndex;
635 Length numberOfGlyphs;
636 StrikethroughStyleProperties properties;
641 {"<s height='5.0f' color='green' >AB<s color='blue' >XYZ</s>CDE</s>",
652 {"<s color='blue' >XYZ</s>",
664 for(uint32_t i = 0; i < expectedNumberOfStrikethroughRuns; i++)
666 tet_infoline(data[i].title.c_str());
667 DALI_TEST_EQUALS(strikethroughRuns[i].glyphRun.glyphIndex, data[i].glyphIndex, TEST_LOCATION);
668 DALI_TEST_EQUALS(strikethroughRuns[i].glyphRun.numberOfGlyphs, data[i].numberOfGlyphs, TEST_LOCATION);
669 DALI_TEST_CHECK(data[i].properties == strikethroughRuns[i].properties);
675 int UtcDaliTextEditorMarkupStrikethroughAttributes(void)
677 ToolkitTestApplication application;
678 tet_infoline(" UtcDaliTextEditorMarkupStrikethroughAttributes ");
680 TextEditor textEditor = TextEditor::New();
682 application.GetScene().Add(textEditor);
684 std::string testText =
685 "start<s>ABC1</s>then"
686 "<s color='green'>ABC2</s>then"
687 "<s height='5.0f'>ABC3</s>then"
688 "<s color='blue' height='4.0f' >ABC4</s>end";
690 textEditor.SetProperty(TextEditor::Property::TEXT, testText);
691 textEditor.SetProperty(TextEditor ::Property::ENABLE_MARKUP, true);
693 application.SendNotification();
694 application.Render();
696 const uint32_t expectedNumberOfStrikethroughRuns = 4u;
698 Toolkit::Internal::TextEditor& textEditorImpl = GetImpl(textEditor);
699 const Text::Length numberOfStrikethroughRuns = textEditorImpl.GetTextController()->GetTextModel()->GetNumberOfStrikethroughRuns();
701 DALI_TEST_EQUALS(numberOfStrikethroughRuns, expectedNumberOfStrikethroughRuns, TEST_LOCATION);
703 Vector<StrikethroughGlyphRun> strikethroughRuns;
704 strikethroughRuns.Resize(numberOfStrikethroughRuns);
705 textEditorImpl.GetTextController()->GetTextModel()->GetStrikethroughRuns(strikethroughRuns.Begin(), 0u, numberOfStrikethroughRuns);
710 GlyphIndex glyphIndex;
711 Length numberOfGlyphs;
712 StrikethroughStyleProperties properties;
725 {"<s color='green'>ABC2</s>",
733 {"<s height='5.0f'>ABC3</s>",
741 {"<s color='blue' height='4.0f' >ABC4</s>",
751 for(uint32_t i = 0; i < expectedNumberOfStrikethroughRuns; i++)
753 tet_infoline(data[i].title.c_str());
754 DALI_TEST_EQUALS(strikethroughRuns[i].glyphRun.glyphIndex, data[i].glyphIndex, TEST_LOCATION);
755 DALI_TEST_EQUALS(strikethroughRuns[i].glyphRun.numberOfGlyphs, data[i].numberOfGlyphs, TEST_LOCATION);
756 DALI_TEST_CHECK(data[i].properties == strikethroughRuns[i].properties);
762 int UtcDaliTextEditorMarkupSpanStrikethrough(void)
764 ToolkitTestApplication application;
765 tet_infoline(" UtcDaliTextEditorMarkupSpanStrikethrough ");
767 TextEditor textEditor = TextEditor::New();
769 application.GetScene().Add(textEditor);
771 std::string testText =
772 "start<span font-size='45' font-family='DejaVu Sans' font-width='condensed' font-slant='italic' text-color='red'>ABC1</span>then"
773 "<span s-color='blue'>ABC2</span>then"
774 "<span s-height='2.0f'>ABC3</span>then"
775 "<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";
777 textEditor.SetProperty(TextEditor::Property::TEXT, testText);
778 textEditor.SetProperty(TextEditor ::Property::ENABLE_MARKUP, true);
780 application.SendNotification();
781 application.Render();
783 const uint32_t expectedNumberOfStrikethroughRuns = 3u;
785 Toolkit::Internal::TextEditor& textEditorImpl = GetImpl(textEditor);
786 const Text::Length numberOfStrikethroughRuns = textEditorImpl.GetTextController()->GetTextModel()->GetNumberOfStrikethroughRuns();
788 DALI_TEST_EQUALS(numberOfStrikethroughRuns, expectedNumberOfStrikethroughRuns, TEST_LOCATION);
790 Vector<StrikethroughGlyphRun> strikethroughRuns;
791 strikethroughRuns.Resize(numberOfStrikethroughRuns);
792 textEditorImpl.GetTextController()->GetTextModel()->GetStrikethroughRuns(strikethroughRuns.Begin(), 0u, numberOfStrikethroughRuns);
797 GlyphIndex glyphIndex;
798 Length numberOfGlyphs;
799 StrikethroughStyleProperties properties;
804 {"<span s-color='blue'>ABC2</span>then",
812 {"<span s-height='2.0f'>ABC3</span>then",
820 {"<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>",
830 for(uint32_t i = 0; i < expectedNumberOfStrikethroughRuns; i++)
832 tet_infoline(data[i].title.c_str());
833 DALI_TEST_EQUALS(strikethroughRuns[i].glyphRun.glyphIndex, data[i].glyphIndex, TEST_LOCATION);
834 DALI_TEST_EQUALS(strikethroughRuns[i].glyphRun.numberOfGlyphs, data[i].numberOfGlyphs, TEST_LOCATION);
835 DALI_TEST_CHECK(data[i].properties == strikethroughRuns[i].properties);
841 int UtcDaliTextEditorFontPointSizeLargerThanAtlas(void)
843 ToolkitTestApplication application;
844 tet_infoline(" UtcDaliTextEditorFontPointSizeLargerThanAtlas ");
846 // Create a text editor
847 TextEditor textEditor = TextEditor::New();
848 //Set size to avoid automatic eliding
849 textEditor.SetProperty(Actor::Property::SIZE, Vector2(1025, 1025));
850 //Set very large font-size using point-size
851 textEditor.SetProperty(TextEditor::Property::POINT_SIZE, 1000);
852 //Specify font-family
853 textEditor.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
854 //Set text to check if appear or not
855 textEditor.SetProperty(TextEditor::Property::TEXT, "A");
857 application.GetScene().Add(textEditor);
859 application.SendNotification();
860 application.Render();
862 //Check if Glyph is added to AtlasGlyphManger or not
863 int countAtlas = AtlasGlyphManager::Get().GetMetrics().mAtlasMetrics.mAtlasCount;
864 DALI_TEST_EQUALS(countAtlas, 1, TEST_LOCATION);
869 int UtcDaliTextEditorFontPointSizeLargerThanAtlasPlaceholderCase(void)
871 ToolkitTestApplication application;
872 tet_infoline(" UtcDaliTextEditorFontPointSizeLargerThanAtlasPlaceholderCase ");
874 //Set Map of placeholder: text, font-family and point-size
875 Property::Map placeholderMapSet;
876 placeholderMapSet["text"] = "A";
877 placeholderMapSet["fontFamily"] = "DejaVu Sans";
878 placeholderMapSet["pixelSize"] = 1000.0f;
880 // Create a text editor
881 TextEditor textEditor = TextEditor::New();
882 //Set size to avoid automatic eliding
883 textEditor.SetProperty(Actor::Property::SIZE, Vector2(1025, 1025));
885 textEditor.SetProperty(TextEditor::Property::PLACEHOLDER, placeholderMapSet);
887 application.GetScene().Add(textEditor);
889 application.SendNotification();
890 application.Render();
892 //Check if Glyph is added to AtlasGlyphManger or not
893 int countAtlas = AtlasGlyphManager::Get().GetMetrics().mAtlasMetrics.mAtlasCount;
894 DALI_TEST_EQUALS(countAtlas, 1, TEST_LOCATION);
899 int UtcDaliTextEditorBackgroundTag(void)
901 ToolkitTestApplication application;
902 tet_infoline("UtcDaliTextEditorBackgroundTag\n");
904 TextEditor editor = TextEditor::New();
905 DALI_TEST_CHECK(editor);
907 editor.SetProperty(TextEditor ::Property::ENABLE_MARKUP, true);
908 editor.SetProperty(TextEditor::Property::TEXT, "H<background color='red'>e</background> Worl<background color='yellow'>d</background>");
909 application.GetScene().Add(editor);
910 application.SendNotification();
911 application.Render();
913 Toolkit::Internal::TextEditor& editorImpl = GetImpl(editor);
914 const ColorIndex* const backgroundColorIndicesBuffer = editorImpl.GetTextController()->GetTextModel()->GetBackgroundColorIndices();
916 DALI_TEST_CHECK(backgroundColorIndicesBuffer);
919 DALI_TEST_EQUALS(backgroundColorIndicesBuffer[0], 0u, TEST_LOCATION);
922 DALI_TEST_EQUALS(backgroundColorIndicesBuffer[1], 1u, TEST_LOCATION);
925 DALI_TEST_EQUALS(backgroundColorIndicesBuffer[7], 2u, TEST_LOCATION);
930 int UtcDaliTextEditorSpanBackgroundTag(void)
932 ToolkitTestApplication application;
933 tet_infoline("UtcDaliTextEditorSpanBackgroundTag\n");
935 TextEditor editor = TextEditor::New();
936 DALI_TEST_CHECK(editor);
938 editor.SetProperty(TextEditor ::Property::ENABLE_MARKUP, true);
939 editor.SetProperty(TextEditor::Property::TEXT, "H<span background-color='red'>e</span> Worl<span background-color='yellow'>d</span>");
940 application.GetScene().Add(editor);
941 application.SendNotification();
942 application.Render();
944 Toolkit::Internal::TextEditor& editorImpl = GetImpl(editor);
945 const ColorIndex* const backgroundColorIndicesBuffer = editorImpl.GetTextController()->GetTextModel()->GetBackgroundColorIndices();
947 DALI_TEST_CHECK(backgroundColorIndicesBuffer);
950 DALI_TEST_EQUALS(backgroundColorIndicesBuffer[0], 0u, TEST_LOCATION);
953 DALI_TEST_EQUALS(backgroundColorIndicesBuffer[1], 1u, TEST_LOCATION);
956 DALI_TEST_EQUALS(backgroundColorIndicesBuffer[7], 2u, TEST_LOCATION);
961 int UtcDaliTextEditorTextWithSpan(void)
963 ToolkitTestApplication application;
964 tet_infoline("UtcDaliTextEditorTextWithSpan\n");
966 TextEditor editor = TextEditor::New();
967 DALI_TEST_CHECK(editor);
969 editor.SetProperty(TextEditor ::Property::ENABLE_MARKUP, true);
970 editor.SetProperty(TextEditor::Property::TEXT, "Hello Span");
971 application.GetScene().Add(editor);
973 application.SendNotification();
974 application.Render();
976 Vector3 originalSize = editor.GetNaturalSize();
977 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");
979 application.SendNotification();
980 application.Render();
982 Vector3 spanSize = editor.GetNaturalSize();
984 DALI_TEST_GREATER(spanSize.width, originalSize.width, TEST_LOCATION);
986 Toolkit::Internal::TextEditor& editorImpl = GetImpl(editor);
987 const ColorIndex* const colorIndicesBuffer1 = editorImpl.GetTextController()->GetTextModel()->GetColorIndices();
989 DALI_TEST_CHECK(colorIndicesBuffer1);
992 DALI_TEST_EQUALS(colorIndicesBuffer1[0], 0u, TEST_LOCATION);
995 DALI_TEST_EQUALS(colorIndicesBuffer1[1], 1u, TEST_LOCATION);
998 DALI_TEST_EQUALS(colorIndicesBuffer1[6], 0u, TEST_LOCATION);
1000 editor.SetProperty(TextEditor::Property::TEXT, "<span font-size='45'>H</span>ello <span text-color='red'>S</span>pan");
1002 application.SendNotification();
1003 application.Render();
1005 const ColorIndex* const colorIndicesBuffer2 = editorImpl.GetTextController()->GetTextModel()->GetColorIndices();
1007 DALI_TEST_CHECK(colorIndicesBuffer2);
1010 DALI_TEST_EQUALS(colorIndicesBuffer2[0], 0u, TEST_LOCATION);
1013 DALI_TEST_EQUALS(colorIndicesBuffer2[1], 0u, TEST_LOCATION);
1016 DALI_TEST_EQUALS(colorIndicesBuffer2[6], 1u, TEST_LOCATION);
1019 DALI_TEST_EQUALS(colorIndicesBuffer2[7], 0u, TEST_LOCATION);
1024 int UtcDaliTextEditorControlBackgroundColor(void)
1026 ToolkitTestApplication application;
1027 tet_infoline(" UtcDaliTextEditorControlBackgroundColor\n");
1029 TextEditor editor = TextEditor::New();
1030 DALI_TEST_CHECK(editor);
1032 Vector4 backgroundColor;
1034 editor.SetProperty(TextEditor::Property::TEXT, "Background Color");
1035 application.GetScene().Add(editor);
1036 application.SendNotification();
1037 application.Render();
1039 Toolkit::Internal::TextEditor& editorImpl = GetImpl(editor);
1040 ControllerPtr controller = editorImpl.GetTextController();
1041 Controller::Impl& controllerImpl = Controller::Impl::GetImplementation(*controller.Get());
1043 // Default color is transparent
1044 controllerImpl.mEditableControlInterface->GetControlBackgroundColor(backgroundColor);
1045 DALI_TEST_EQUALS(backgroundColor, Color::TRANSPARENT, TEST_LOCATION);
1047 // Set background color to red
1048 editor.SetBackgroundColor(Color::RED);
1049 application.SendNotification();
1050 application.Render();
1053 controllerImpl.mEditableControlInterface->GetControlBackgroundColor(backgroundColor);
1054 DALI_TEST_EQUALS(backgroundColor, Color::RED, TEST_LOCATION);
1059 int UtcDaliTextEditorTextPositionWithMinLineAndBigFont(void)
1061 ToolkitTestApplication application;
1062 tet_infoline(" UtcDaliTextEditorTextPositionWithMinLine ");
1064 TextEditor textEditor = TextEditor::New();
1066 textEditor.SetProperty(TextEditor::Property::TEXT, "<span font-size='45'>H</span>\ni");
1067 textEditor.SetProperty(DevelTextEditor::Property::MIN_LINE_SIZE, 50);
1068 textEditor.SetProperty(TextEditor ::Property::ENABLE_MARKUP, true);
1070 application.GetScene().Add(textEditor);
1072 application.SendNotification();
1073 application.Render();
1075 Toolkit::Internal::TextEditor& textEditorImpl = GetImpl(textEditor);
1076 Text::ViewInterface& view = textEditorImpl.GetTextController()->GetView();
1078 Length numberOfGlyphs = view.GetNumberOfGlyphs();
1080 DALI_TEST_EQUALS(numberOfGlyphs, 3u, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
1082 Vector<GlyphInfo> glyphs;
1083 glyphs.Resize(numberOfGlyphs);
1085 Vector<Vector2> positions;
1086 positions.Resize(numberOfGlyphs);
1088 float alignmentOffset = 0u;
1089 numberOfGlyphs = view.GetGlyphs(glyphs.Begin(),
1095 DALI_TEST_EQUALS(positions[2].y, 165.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
1100 int UtcDaliTextEditorMarkupStrikethrough(void)
1102 ToolkitTestApplication application;
1103 tet_infoline(" UtcDaliTextEditorMarkupStrikethrough ");
1105 TextEditor textEditor = TextEditor::New();
1107 application.GetScene().Add(textEditor);
1109 textEditor.SetProperty(TextEditor::Property::TEXT, "<s>ABC</s>EF<s color='red'>GH</s>");
1110 textEditor.SetProperty(TextEditor ::Property::ENABLE_MARKUP, true);
1112 application.SendNotification();
1113 application.Render();
1115 uint32_t expectedNumberOfStrikethroughGlyphs = 2u;
1117 Toolkit::Internal::TextEditor& textEditorImpl = GetImpl(textEditor);
1118 const Text::Length numberOfStrikethroughRuns = textEditorImpl.GetTextController()->GetTextModel()->GetNumberOfStrikethroughRuns();
1120 DALI_TEST_EQUALS(numberOfStrikethroughRuns, expectedNumberOfStrikethroughGlyphs, TEST_LOCATION);
1122 Vector<StrikethroughGlyphRun> strikethroughRuns;
1123 strikethroughRuns.Resize(numberOfStrikethroughRuns);
1124 textEditorImpl.GetTextController()->GetTextModel()->GetStrikethroughRuns(strikethroughRuns.Begin(), 0u, numberOfStrikethroughRuns);
1126 //ABC have strikethrough
1127 DALI_TEST_EQUALS(strikethroughRuns[0u].glyphRun.glyphIndex, 0u, TEST_LOCATION);
1128 DALI_TEST_EQUALS(strikethroughRuns[0u].glyphRun.numberOfGlyphs, 3u, TEST_LOCATION);
1129 DALI_TEST_CHECK(!strikethroughRuns[0u].properties.colorDefined);
1131 //GH have strikethrough
1132 DALI_TEST_EQUALS(strikethroughRuns[1u].glyphRun.glyphIndex, 5u, TEST_LOCATION);
1133 DALI_TEST_EQUALS(strikethroughRuns[1u].glyphRun.numberOfGlyphs, 2u, TEST_LOCATION);
1134 DALI_TEST_CHECK(strikethroughRuns[1u].properties.colorDefined);
1139 int UtcDaliTextEditorMarkupStrikethroughNoEndTag(void)
1141 ToolkitTestApplication application;
1142 tet_infoline(" UtcDaliTextEditorMarkupStrikethroughNoEndTag ");
1144 TextEditor textEditor = TextEditor::New();
1146 application.GetScene().Add(textEditor);
1148 textEditor.SetProperty(TextEditor::Property::TEXT, "<s>ABC");
1149 textEditor.SetProperty(TextEditor ::Property::ENABLE_MARKUP, true);
1151 application.SendNotification();
1152 application.Render();
1154 uint32_t expectedNumberOfStrikethroughGlyphs = 0u;
1156 Toolkit::Internal::TextEditor& textEditorImpl = GetImpl(textEditor);
1157 Text::Length numberOfStrikethroughRuns = textEditorImpl.GetTextController()->GetTextModel()->GetNumberOfStrikethroughRuns();
1159 DALI_TEST_EQUALS(numberOfStrikethroughRuns, expectedNumberOfStrikethroughGlyphs, TEST_LOCATION);
1164 int UtcDaliTextEditorMarkupParagraphTag(void)
1167 ToolkitTestApplication application;
1168 tet_infoline(" UtcDaliTextEditorMarkupParagraphTag ");
1170 TextEditor textEditor = TextEditor::New();
1171 application.GetScene().Add(textEditor);
1173 textEditor.SetProperty(TextEditor::Property::TEXT, "text one <p>Paragraph two</p> text three <p>Paragraph four</p> text five");
1174 textEditor.SetProperty(TextEditor ::Property::ENABLE_MARKUP, true);
1176 application.SendNotification();
1177 application.Render();
1179 uint32_t expectedNumberOfBoundedParagraphRuns = 2u;
1181 Toolkit::Internal::TextEditor& textEditorImpl = GetImpl(textEditor);
1182 const Text::Length numberOfBoundedParagraphRuns = textEditorImpl.GetTextController()->GetTextModel()->GetNumberOfBoundedParagraphRuns();
1183 DALI_TEST_EQUALS(numberOfBoundedParagraphRuns, expectedNumberOfBoundedParagraphRuns, TEST_LOCATION);
1185 const Vector<BoundedParagraphRun>& boundedParagraphRuns = textEditorImpl.GetTextController()->GetTextModel()->GetBoundedParagraphRuns();
1187 //<p>Paragraph two</p>
1188 DALI_TEST_EQUALS(boundedParagraphRuns[0u].characterRun.characterIndex, 10u, TEST_LOCATION);
1189 DALI_TEST_EQUALS(boundedParagraphRuns[0u].characterRun.numberOfCharacters, 14u, TEST_LOCATION);
1191 //<p>Paragraph four</p>
1192 DALI_TEST_EQUALS(boundedParagraphRuns[1u].characterRun.characterIndex, 37u, TEST_LOCATION);
1193 DALI_TEST_EQUALS(boundedParagraphRuns[1u].characterRun.numberOfCharacters, 15u, TEST_LOCATION);
1198 int UtcDaliTextEditorMarkupParagraphTagAlignAttribute(void)
1200 ToolkitTestApplication application;
1201 tet_infoline(" UtcDaliTextEditorMarkupParagraphTagAlignAttribute ");
1203 // Apply alignment for each type on property level on three paragraphs and in-between text.
1204 // Apply align in markup on the three paragraphs (each one a type).
1205 // Using the same text to gain similar results from both the property level and the markup.
1206 // Compare line alignment between the property level and the markup.
1208 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>";
1209 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>";
1211 //Set size to avoid automatic eliding
1212 Vector2 controllerSize = Vector2(1025, 1025);
1214 TextEditor textEditorBeginAlign = TextEditor::New();
1215 TextEditor textEditorCenterAlign = TextEditor::New();
1216 TextEditor textEditorEndAlign = TextEditor::New();
1217 TextEditor textEditorMultiAlign = TextEditor::New();
1219 application.GetScene().Add(textEditorBeginAlign);
1220 application.GetScene().Add(textEditorCenterAlign);
1221 application.GetScene().Add(textEditorEndAlign);
1222 application.GetScene().Add(textEditorMultiAlign);
1224 textEditorBeginAlign.SetProperty(TextEditor::Property::TEXT, textAlignOnPropertyLevel);
1225 textEditorBeginAlign.SetProperty(TextEditor ::Property::ENABLE_MARKUP, true);
1226 textEditorBeginAlign.SetProperty(DevelTextEditor::Property::ELLIPSIS, false);
1227 textEditorBeginAlign.SetProperty(TextEditor::Property::HORIZONTAL_ALIGNMENT, Dali::Toolkit::Text::HorizontalAlignment::BEGIN);
1228 textEditorBeginAlign.SetProperty(Actor::Property::SIZE, controllerSize);
1230 textEditorCenterAlign.SetProperty(TextEditor::Property::TEXT, textAlignOnPropertyLevel);
1231 textEditorCenterAlign.SetProperty(TextEditor ::Property::ENABLE_MARKUP, true);
1232 textEditorCenterAlign.SetProperty(DevelTextEditor::Property::ELLIPSIS, false);
1233 textEditorCenterAlign.SetProperty(TextEditor::Property::HORIZONTAL_ALIGNMENT, Dali::Toolkit::Text::HorizontalAlignment::CENTER);
1234 textEditorCenterAlign.SetProperty(Actor::Property::SIZE, controllerSize);
1236 textEditorEndAlign.SetProperty(TextEditor::Property::TEXT, textAlignOnPropertyLevel);
1237 textEditorEndAlign.SetProperty(TextEditor ::Property::ENABLE_MARKUP, true);
1238 textEditorEndAlign.SetProperty(DevelTextEditor::Property::ELLIPSIS, false);
1239 textEditorEndAlign.SetProperty(TextEditor::Property::HORIZONTAL_ALIGNMENT, Dali::Toolkit::Text::HorizontalAlignment::END);
1240 textEditorEndAlign.SetProperty(Actor::Property::SIZE, controllerSize);
1242 textEditorMultiAlign.SetProperty(TextEditor::Property::TEXT, textAlignInMarkup);
1243 textEditorMultiAlign.SetProperty(TextEditor ::Property::ENABLE_MARKUP, true);
1244 textEditorMultiAlign.SetProperty(DevelTextEditor::Property::ELLIPSIS, false);
1245 textEditorMultiAlign.SetProperty(TextEditor::Property::HORIZONTAL_ALIGNMENT, Dali::Toolkit::Text::HorizontalAlignment::CENTER);
1246 textEditorMultiAlign.SetProperty(Actor::Property::SIZE, controllerSize);
1248 application.SendNotification();
1249 application.Render();
1251 uint32_t expectedNumberOfBoundedParagraphRuns = 4u;
1252 uint32_t expectedNumberOfLines = 7u;
1254 Toolkit::Internal::TextEditor& textEditorMultiAlignImpl = GetImpl(textEditorMultiAlign);
1255 Toolkit::Internal::TextEditor& textEditorBeginAlignImpl = GetImpl(textEditorBeginAlign);
1256 Toolkit::Internal::TextEditor& textEditorCenterAlignImpl = GetImpl(textEditorCenterAlign);
1257 Toolkit::Internal::TextEditor& textEditorEndAlignImpl = GetImpl(textEditorEndAlign);
1259 const Text::Length numberOfBoundedParagraphRuns = textEditorMultiAlignImpl.GetTextController()->GetTextModel()->GetNumberOfBoundedParagraphRuns();
1260 DALI_TEST_EQUALS(numberOfBoundedParagraphRuns, expectedNumberOfBoundedParagraphRuns, TEST_LOCATION);
1262 DALI_TEST_EQUALS(textEditorMultiAlignImpl.GetTextController()->GetTextModel()->GetNumberOfLines(), expectedNumberOfLines, TEST_LOCATION);
1263 DALI_TEST_CHECK(textEditorMultiAlignImpl.GetTextController()->GetTextModel()->GetLines());
1265 DALI_TEST_EQUALS(textEditorBeginAlignImpl.GetTextController()->GetTextModel()->GetNumberOfLines(), expectedNumberOfLines, TEST_LOCATION);
1266 DALI_TEST_CHECK(textEditorBeginAlignImpl.GetTextController()->GetTextModel()->GetLines());
1268 DALI_TEST_EQUALS(textEditorCenterAlignImpl.GetTextController()->GetTextModel()->GetNumberOfLines(), expectedNumberOfLines, TEST_LOCATION);
1269 DALI_TEST_CHECK(textEditorCenterAlignImpl.GetTextController()->GetTextModel()->GetLines());
1271 DALI_TEST_EQUALS(textEditorEndAlignImpl.GetTextController()->GetTextModel()->GetNumberOfLines(), expectedNumberOfLines, TEST_LOCATION);
1272 DALI_TEST_CHECK(textEditorEndAlignImpl.GetTextController()->GetTextModel()->GetLines());
1274 const uint32_t LINE_INDEX_ALIGN_END = 1u;
1275 const uint32_t LINE_INDEX_ALIGN_CENTER = 3u;
1276 const uint32_t LINE_INDEX_ALIGN_BEGIN = 5u;
1277 const uint32_t LINE_INDEX_OUTSIDE_1 = 0u;
1278 const uint32_t LINE_INDEX_OUTSIDE_2 = 2u;
1279 const uint32_t LINE_INDEX_OUTSIDE_3 = 4u;
1280 const uint32_t LINE_INDEX_PARAGRAPH = 6u;
1282 //<p align='end'>Paragraph end</p>
1283 const LineRun& lineEndFromMultiAlign = *(textEditorMultiAlignImpl.GetTextController()->GetTextModel()->GetLines() + LINE_INDEX_ALIGN_END);
1284 const LineRun& lineEndFromEndAlign = *(textEditorEndAlignImpl.GetTextController()->GetTextModel()->GetLines() + LINE_INDEX_ALIGN_END);
1285 tet_infoline(" UtcDaliTextEditorMarkupParagraphTagAlignAttribute - <p align='end'>Paragraph end</p>");
1286 DALI_TEST_EQUALS(lineEndFromMultiAlign.alignmentOffset, lineEndFromEndAlign.alignmentOffset, TEST_LOCATION);
1287 DALI_TEST_EQUALS(lineEndFromMultiAlign.width, lineEndFromEndAlign.width, TEST_LOCATION);
1289 //<p align='center'>Paragraph center</p>
1290 const LineRun& lineCenterFromMultiAlign = *(textEditorMultiAlignImpl.GetTextController()->GetTextModel()->GetLines() + LINE_INDEX_ALIGN_CENTER);
1291 const LineRun& lineEndFromCenterAlign = *(textEditorCenterAlignImpl.GetTextController()->GetTextModel()->GetLines() + LINE_INDEX_ALIGN_CENTER);
1292 tet_infoline(" UtcDaliTextEditorMarkupParagraphTagAlignAttribute - <p align='center'>Paragraph center</p>");
1293 DALI_TEST_EQUALS(lineCenterFromMultiAlign.alignmentOffset, lineEndFromCenterAlign.alignmentOffset, TEST_LOCATION);
1294 DALI_TEST_EQUALS(lineCenterFromMultiAlign.width, lineEndFromCenterAlign.width, TEST_LOCATION);
1296 //<p align='begin' >Paragraph begin</p>
1297 const LineRun& lineBeginFromMultiAlign = *(textEditorMultiAlignImpl.GetTextController()->GetTextModel()->GetLines() + LINE_INDEX_ALIGN_BEGIN);
1298 const LineRun& lineEndFromBeginAlign = *(textEditorBeginAlignImpl.GetTextController()->GetTextModel()->GetLines() + LINE_INDEX_ALIGN_BEGIN);
1299 tet_infoline(" UtcDaliTextEditorMarkupParagraphTagAlignAttribute - <p align='begin' >Paragraph begin</p>");
1300 DALI_TEST_EQUALS(lineBeginFromMultiAlign.alignmentOffset, lineEndFromBeginAlign.alignmentOffset, TEST_LOCATION);
1301 DALI_TEST_EQUALS(lineBeginFromMultiAlign.width, lineEndFromBeginAlign.width, TEST_LOCATION);
1304 const LineRun& lineOutsideOneFromMultiAlign = *(textEditorMultiAlignImpl.GetTextController()->GetTextModel()->GetLines() + LINE_INDEX_OUTSIDE_1);
1305 const LineRun& lineOutsideOneFromCenterAlign = *(textEditorCenterAlignImpl.GetTextController()->GetTextModel()->GetLines() + LINE_INDEX_OUTSIDE_1);
1306 tet_infoline(" UtcDaliTextEditorMarkupParagraphTagAlignAttribute - text outside one");
1307 DALI_TEST_EQUALS(lineOutsideOneFromMultiAlign.alignmentOffset, lineOutsideOneFromCenterAlign.alignmentOffset, TEST_LOCATION);
1308 DALI_TEST_EQUALS(lineOutsideOneFromMultiAlign.width, lineOutsideOneFromCenterAlign.width, TEST_LOCATION);
1310 const LineRun& lineOutsideTwoFromMultiAlign = *(textEditorMultiAlignImpl.GetTextController()->GetTextModel()->GetLines() + LINE_INDEX_OUTSIDE_2);
1311 const LineRun& lineOutsideTwoFromCenterAlign = *(textEditorCenterAlignImpl.GetTextController()->GetTextModel()->GetLines() + LINE_INDEX_OUTSIDE_2);
1312 tet_infoline(" UtcDaliTextEditorMarkupParagraphTagAlignAttribute - text outside two");
1313 DALI_TEST_EQUALS(lineOutsideTwoFromMultiAlign.alignmentOffset, lineOutsideTwoFromCenterAlign.alignmentOffset, TEST_LOCATION);
1314 DALI_TEST_EQUALS(lineOutsideTwoFromMultiAlign.width, lineOutsideTwoFromCenterAlign.width, TEST_LOCATION);
1316 const LineRun& lineOutsideThreeFromMultiAlign = *(textEditorMultiAlignImpl.GetTextController()->GetTextModel()->GetLines() + LINE_INDEX_OUTSIDE_3);
1317 const LineRun& lineOutsideThreeFromCenterAlign = *(textEditorCenterAlignImpl.GetTextController()->GetTextModel()->GetLines() + LINE_INDEX_OUTSIDE_3);
1318 tet_infoline(" UtcDaliTextEditorMarkupParagraphTagAlignAttribute - text outside three");
1319 DALI_TEST_EQUALS(lineOutsideThreeFromMultiAlign.alignmentOffset, lineOutsideThreeFromCenterAlign.alignmentOffset, TEST_LOCATION);
1320 DALI_TEST_EQUALS(lineOutsideThreeFromMultiAlign.width, lineOutsideThreeFromCenterAlign.width, TEST_LOCATION);
1322 const LineRun& lineParagraphFromMultiAlign = *(textEditorMultiAlignImpl.GetTextController()->GetTextModel()->GetLines() + LINE_INDEX_PARAGRAPH);
1323 const LineRun& lineParagraphFromCenterAlign = *(textEditorCenterAlignImpl.GetTextController()->GetTextModel()->GetLines() + LINE_INDEX_PARAGRAPH);
1324 tet_infoline(" UtcDaliTextEditorMarkupParagraphTagAlignAttribute - <p>Paragraph property alignment</p>");
1325 DALI_TEST_EQUALS(lineParagraphFromMultiAlign.alignmentOffset, lineParagraphFromCenterAlign.alignmentOffset, TEST_LOCATION);
1326 DALI_TEST_EQUALS(lineParagraphFromMultiAlign.width, lineParagraphFromCenterAlign.width, TEST_LOCATION);
1331 int UtcDaliTextEditorMarkupCharacterSpacingTag(void)
1333 ToolkitTestApplication application;
1334 tet_infoline(" UtcDaliTextEditorMarkupCharacterSpacingTag ");
1336 const Length EXPECTED_NUMBER_OF_GLYPHS = 21u;
1338 const float expandedCharSpacing = 10.0f;
1339 const float condensedCharSpacing = -5.0f;
1341 TextEditor textEditor = TextEditor::New();
1343 textEditor.SetProperty(TextEditor::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>");
1344 textEditor.SetProperty(TextEditor ::Property::ENABLE_MARKUP, true);
1346 application.GetScene().Add(textEditor);
1348 application.SendNotification();
1349 application.Render();
1351 Toolkit::Internal::TextEditor& textEditorImpl = GetImpl(textEditor);
1352 Text::ViewInterface& view = textEditorImpl.GetTextController()->GetView();
1354 Length numberOfGlyphs = view.GetNumberOfGlyphs();
1356 DALI_TEST_EQUALS(numberOfGlyphs, EXPECTED_NUMBER_OF_GLYPHS, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
1358 Vector<GlyphInfo> glyphs;
1359 glyphs.Resize(numberOfGlyphs);
1361 Vector<Vector2> positions;
1362 positions.Resize(numberOfGlyphs);
1364 float alignmentOffset = 0u;
1365 numberOfGlyphs = view.GetGlyphs(glyphs.Begin(),
1371 const Length numberOfGlyphsOneLine = 7u;
1372 for(Length i = 0; i < numberOfGlyphsOneLine - 1u; i++)
1374 float diffLineNoCharSpacing = positions[i + 1].x - positions[i].x;
1376 float diffLineCondensedCharSpacing = positions[numberOfGlyphsOneLine + i + 1].x - positions[numberOfGlyphsOneLine + i].x;
1377 DALI_TEST_EQUALS(diffLineCondensedCharSpacing, diffLineNoCharSpacing + condensedCharSpacing, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
1379 float diffLineExpandedCharSpacing = positions[2u * numberOfGlyphsOneLine + i + 1].x - positions[2u * numberOfGlyphsOneLine + i].x;
1380 DALI_TEST_EQUALS(diffLineExpandedCharSpacing, diffLineNoCharSpacing + expandedCharSpacing, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
1386 int UtcDaliTextEditorMarkupSpanCharacterSpacing(void)
1388 ToolkitTestApplication application;
1389 tet_infoline(" UtcDaliTextEditorMarkupSpanCharacterSpacing ");
1391 const Length EXPECTED_NUMBER_OF_GLYPHS = 21u;
1393 const float expandedCharSpacing = 10.0f;
1394 const float condensedCharSpacing = -5.0f;
1396 std::string testText =
1397 "<span font-size='20' font-family='DejaVu Sans' font-width='condensed' font-slant='italic' text-color='blue' >ABC EF\n</span>"
1398 "<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>"
1399 "<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>";
1401 TextEditor textEditor = TextEditor::New();
1403 textEditor.SetProperty(TextEditor::Property::TEXT, testText);
1404 textEditor.SetProperty(TextEditor ::Property::ENABLE_MARKUP, true);
1406 application.GetScene().Add(textEditor);
1408 application.SendNotification();
1409 application.Render();
1411 Toolkit::Internal::TextEditor& textEditorImpl = GetImpl(textEditor);
1412 Text::ViewInterface& view = textEditorImpl.GetTextController()->GetView();
1414 Length numberOfGlyphs = view.GetNumberOfGlyphs();
1416 DALI_TEST_EQUALS(numberOfGlyphs, EXPECTED_NUMBER_OF_GLYPHS, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
1418 Vector<GlyphInfo> glyphs;
1419 glyphs.Resize(numberOfGlyphs);
1421 Vector<Vector2> positions;
1422 positions.Resize(numberOfGlyphs);
1424 float alignmentOffset = 0u;
1425 numberOfGlyphs = view.GetGlyphs(glyphs.Begin(),
1431 const Length numberOfGlyphsOneLine = 7u;
1432 for(Length i = 0; i < numberOfGlyphsOneLine - 1u; i++)
1434 float diffLineNoCharSpacing = positions[i + 1].x - positions[i].x;
1436 float diffLineCondensedCharSpacing = positions[numberOfGlyphsOneLine + i + 1].x - positions[numberOfGlyphsOneLine + i].x;
1437 DALI_TEST_EQUALS(diffLineCondensedCharSpacing, diffLineNoCharSpacing + condensedCharSpacing, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
1439 float diffLineExpandedCharSpacing = positions[2u * numberOfGlyphsOneLine + i + 1].x - positions[2u * numberOfGlyphsOneLine + i].x;
1440 DALI_TEST_EQUALS(diffLineExpandedCharSpacing, diffLineNoCharSpacing + expandedCharSpacing, Math::MACHINE_EPSILON_1000, TEST_LOCATION);