X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=automated-tests%2Fsrc%2Fdali-toolkit-internal%2Futc-Dali-TextEditor-internal.cpp;h=f768255aa7ffa5cb9859f636219ac69b720ec74e;hp=9445be6d01de1043c52d03b1b0491700febb59ca;hb=c49e595f12e9e56cd7c35262eb52ae1f2d9b685b;hpb=eac3e6ee30183868f1af12addd94e7f2fc467ed7 diff --git a/automated-tests/src/dali-toolkit-internal/utc-Dali-TextEditor-internal.cpp b/automated-tests/src/dali-toolkit-internal/utc-Dali-TextEditor-internal.cpp old mode 100755 new mode 100644 index 9445be6..f768255 --- a/automated-tests/src/dali-toolkit-internal/utc-Dali-TextEditor-internal.cpp +++ b/automated-tests/src/dali-toolkit-internal/utc-Dali-TextEditor-internal.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,15 +15,16 @@ * */ -#include #include +#include #include #include #include -#include +#include #include +#include using namespace Dali; using namespace Toolkit; @@ -32,20 +33,20 @@ using namespace Text; int UtcDaliTextEditorSelectText(void) { ToolkitTestApplication application; - tet_infoline( "UtcDaliTextEditorSelectText" ); + tet_infoline("UtcDaliTextEditorSelectText"); // Create a text editor TextEditor textEditor = TextEditor::New(); - textEditor.SetProperty( Actor::Property::SIZE, Vector2( 400.f, 60.f ) ); - textEditor.SetProperty( TextEditor::Property::TEXT, "Hello World" ); + textEditor.SetProperty(Actor::Property::SIZE, Vector2(400.f, 60.f)); + textEditor.SetProperty(TextEditor::Property::TEXT, "Hello World"); // Add the text editor to the stage - application.GetScene().Add( textEditor ); + application.GetScene().Add(textEditor); application.SendNotification(); application.Render(); - Toolkit::Internal::TextEditor& textEditorImpl = GetImpl( textEditor ); + Toolkit::Internal::TextEditor& textEditorImpl = GetImpl(textEditor); application.SendNotification(); application.Render(); @@ -57,7 +58,7 @@ int UtcDaliTextEditorSelectText(void) application.Render(); std::string selectedText = textEditorImpl.GetSelectedText(); - DALI_TEST_CHECK( selectedText == "Hello World" ); + DALI_TEST_CHECK(selectedText == "Hello World"); // Select None textEditorImpl.SelectNone(); @@ -66,7 +67,1378 @@ int UtcDaliTextEditorSelectText(void) application.Render(); selectedText = textEditorImpl.GetSelectedText(); - DALI_TEST_CHECK( selectedText == "" ); + DALI_TEST_CHECK(selectedText == ""); + + END_TEST; +} + +int UtcDaliTextEditorMarkupUnderline(void) +{ + ToolkitTestApplication application; + tet_infoline(" UtcDaliTextEditorMarkupUnderline "); + + TextEditor textEditor = TextEditor::New(); + + application.GetScene().Add(textEditor); + + textEditor.SetProperty(TextEditor::Property::TEXT, "ABCEFGH"); + textEditor.SetProperty(TextEditor ::Property::ENABLE_MARKUP, true); + + application.SendNotification(); + application.Render(); + + uint32_t expectedNumberOfUnderlineRuns = 2u; + + Toolkit::Internal::TextEditor& textEditorImpl = GetImpl(textEditor); + const Text::Length numberOfUnderlineRuns = textEditorImpl.GetTextController()->GetTextModel()->GetNumberOfUnderlineRuns(); + + DALI_TEST_EQUALS(numberOfUnderlineRuns, expectedNumberOfUnderlineRuns, TEST_LOCATION); + + Vector underlineRuns; + underlineRuns.Resize(numberOfUnderlineRuns); + textEditorImpl.GetTextController()->GetTextModel()->GetUnderlineRuns(underlineRuns.Begin(), 0u, numberOfUnderlineRuns); + + //ABC are underlined + DALI_TEST_EQUALS(underlineRuns[0u].glyphRun.glyphIndex, 0u, TEST_LOCATION); + DALI_TEST_EQUALS(underlineRuns[0u].glyphRun.numberOfGlyphs, 3u, TEST_LOCATION); + + //GH are underlined + DALI_TEST_EQUALS(underlineRuns[1u].glyphRun.glyphIndex, 5u, TEST_LOCATION); + DALI_TEST_EQUALS(underlineRuns[1u].glyphRun.numberOfGlyphs, 2u, TEST_LOCATION); + + END_TEST; +} + +int UtcDaliTextEditorMarkupUnderlineAttributes(void) +{ + ToolkitTestApplication application; + tet_infoline(" UtcDaliTextEditorMarkupUnderlineAttributes "); + + TextEditor textEditor = TextEditor::New(); + + application.GetScene().Add(textEditor); + + std::string testText = + "startABC1then" + "ABC2then" + "ABC3then" + "ABC4then" + "ABC5then" + "ABC6then" + "ABC7then" + "ABC8then" + "ABC9end"; + + textEditor.SetProperty(TextEditor::Property::TEXT, testText); + textEditor.SetProperty(TextEditor ::Property::ENABLE_MARKUP, true); + + application.SendNotification(); + application.Render(); + + const uint32_t expectedNumberOfUnderlineRuns = 9u; + + Toolkit::Internal::TextEditor& textEditorImpl = GetImpl(textEditor); + const Text::Length numberOfUnderlineRuns = textEditorImpl.GetTextController()->GetTextModel()->GetNumberOfUnderlineRuns(); + + DALI_TEST_EQUALS(numberOfUnderlineRuns, expectedNumberOfUnderlineRuns, TEST_LOCATION); + + Vector underlineRuns; + underlineRuns.Resize(numberOfUnderlineRuns); + textEditorImpl.GetTextController()->GetTextModel()->GetUnderlineRuns(underlineRuns.Begin(), 0u, numberOfUnderlineRuns); + + struct DataOfCase + { + std::string title; + GlyphIndex glyphIndex; + Length numberOfGlyphs; + UnderlineStyleProperties properties; + }; + DataOfCase data[] = + { + //ABC1 + {"ABC1", + 5u, + 4u, + { + Text::Underline::SOLID, + Color::BLACK, + 0u, + 1u, + 2u, + false, + false, + false, + false, + false, + }}, + + //ABC2 + {"ABC2", + 13u, + 4u, + { + Text::Underline::SOLID, + Color::BLACK, + 0u, + 1u, + 2u, + true, + false, + false, + false, + false, + }}, + + //ABC3 + {"ABC3", + 21u, + 4u, + { + Text::Underline::DASHED, + Color::BLACK, + 0u, + 1u, + 2u, + true, + false, + false, + false, + false, + }}, + + //ABC4 + {"ABC4", + 29u, + 4u, + { + Text::Underline::DOUBLE, + Color::BLACK, + 0u, + 1u, + 2u, + true, + false, + false, + false, + false, + }}, + + //ABC5 + {"ABC5", + 37u, + 4u, + { + Text::Underline::SOLID, + Color::GREEN, + 0u, + 1u, + 2u, + false, + true, + false, + false, + false, + }}, + + //ABC6 + {"ABC6", + 45u, + 4u, + { + Text::Underline::SOLID, + Color::BLACK, + 5u, + 1u, + 2u, + false, + false, + true, + false, + false, + }}, + + //ABC7 + {"ABC7", + 53u, + 4u, + { + Text::Underline::DASHED, + Color::BLACK, + 0u, + 3u, + 2u, + true, + false, + false, + true, + false, + }}, + + //ABC8 + {"ABC8", + 61u, + 4u, + { + Text::Underline::DASHED, + Color::BLACK, + 0u, + 1u, + 4u, + true, + false, + false, + false, + true, + }}, + + // + {"", + 69u, + 4u, + { + Text::Underline::DASHED, + Color::BLUE, + 4u, + 2u, + 3u, + true, + true, + true, + true, + true, + }}, + + }; + + for(uint32_t i = 0; i < expectedNumberOfUnderlineRuns; i++) + { + tet_infoline(data[i].title.c_str()); + DALI_TEST_EQUALS(underlineRuns[i].glyphRun.glyphIndex, data[i].glyphIndex, TEST_LOCATION); + DALI_TEST_EQUALS(underlineRuns[i].glyphRun.numberOfGlyphs, data[i].numberOfGlyphs, TEST_LOCATION); + DALI_TEST_CHECK(data[i].properties == underlineRuns[i].properties); + } + + END_TEST; +} + +int UtcDaliTextEditorMarkupSpanUnderline(void) +{ + ToolkitTestApplication application; + tet_infoline(" UtcDaliTextEditorMarkupSpanUnderline "); + + TextEditor textEditor = TextEditor::New(); + + application.GetScene().Add(textEditor); + + std::string testText = + "startABC1then" + "ABC2then" + "ABC3then" + "ABC4then" + "ABC5then" + "ABC6then" + "ABC7then" + "ABC8then" + "ABC9end"; + + textEditor.SetProperty(TextEditor::Property::TEXT, testText); + textEditor.SetProperty(TextEditor ::Property::ENABLE_MARKUP, true); + + application.SendNotification(); + application.Render(); + + const uint32_t expectedNumberOfUnderlineRuns = 8u; + + Toolkit::Internal::TextEditor& textEditorImpl = GetImpl(textEditor); + const Text::Length numberOfUnderlineRuns = textEditorImpl.GetTextController()->GetTextModel()->GetNumberOfUnderlineRuns(); + + DALI_TEST_EQUALS(numberOfUnderlineRuns, expectedNumberOfUnderlineRuns, TEST_LOCATION); + + Vector underlineRuns; + underlineRuns.Resize(numberOfUnderlineRuns); + textEditorImpl.GetTextController()->GetTextModel()->GetUnderlineRuns(underlineRuns.Begin(), 0u, numberOfUnderlineRuns); + + struct DataOfCase + { + std::string title; + GlyphIndex glyphIndex; + Length numberOfGlyphs; + UnderlineStyleProperties properties; + }; + DataOfCase data[] = + { + //ABC2 + {"ABC2", + 13u, + 4u, + { + Text::Underline::SOLID, + Color::BLACK, + 0u, + 1u, + 2u, + true, + false, + false, + false, + false, + }}, + + //ABC3 + {"ABC3", + 21u, + 4u, + { + Text::Underline::DASHED, + Color::BLACK, + 0u, + 1u, + 2u, + true, + false, + false, + false, + false, + }}, + + //ABC4 + {"ABC4", + 29u, + 4u, + { + Text::Underline::DOUBLE, + Color::BLACK, + 0u, + 1u, + 2u, + true, + false, + false, + false, + false, + }}, + + //ABC5 + {"ABC5", + 37u, + 4u, + { + Text::Underline::SOLID, + Color::GREEN, + 0u, + 1u, + 2u, + false, + true, + false, + false, + false, + }}, + + //ABC6 + {"ABC6", + 45u, + 4u, + { + Text::Underline::SOLID, + Color::BLACK, + 5u, + 1u, + 2u, + false, + false, + true, + false, + false, + }}, + + //ABC7 + {"ABC7", + 53u, + 4u, + { + Text::Underline::DASHED, + Color::BLACK, + 0u, + 3u, + 2u, + true, + false, + false, + true, + false, + }}, + + //ABC8 + {"ABC8", + 61u, + 4u, + { + Text::Underline::DASHED, + Color::BLACK, + 0u, + 1u, + 4u, + true, + false, + false, + false, + true, + }}, + + // + {"ABC9", + 69u, + 4u, + { + Text::Underline::DASHED, + Color::BLUE, + 4u, + 2u, + 3u, + true, + true, + true, + true, + true, + }}, + + }; + + for(uint32_t i = 0; i < expectedNumberOfUnderlineRuns; i++) + { + tet_infoline(data[i].title.c_str()); + DALI_TEST_EQUALS(underlineRuns[i].glyphRun.glyphIndex, data[i].glyphIndex, TEST_LOCATION); + DALI_TEST_EQUALS(underlineRuns[i].glyphRun.numberOfGlyphs, data[i].numberOfGlyphs, TEST_LOCATION); + DALI_TEST_CHECK(data[i].properties == underlineRuns[i].properties); + } + + END_TEST; +} + +int UtcDaliTextEditorMarkupNestedUnderlineTags(void) +{ + ToolkitTestApplication application; + tet_infoline(" UtcDaliTextEditorMarkupNestedUnderlineTags "); + + TextEditor textEditor = TextEditor::New(); + + application.GetScene().Add(textEditor); + + std::string testText = "startABXYZCDEend"; + + textEditor.SetProperty(TextEditor::Property::TEXT, testText); + textEditor.SetProperty(TextEditor ::Property::ENABLE_MARKUP, true); + + application.SendNotification(); + application.Render(); + + const uint32_t expectedNumberOfUnderlineRuns = 2u; + + Toolkit::Internal::TextEditor& textEditorImpl = GetImpl(textEditor); + const Text::Length numberOfUnderlineRuns = textEditorImpl.GetTextController()->GetTextModel()->GetNumberOfUnderlineRuns(); + + DALI_TEST_EQUALS(numberOfUnderlineRuns, expectedNumberOfUnderlineRuns, TEST_LOCATION); + + Vector underlineRuns; + underlineRuns.Resize(numberOfUnderlineRuns); + textEditorImpl.GetTextController()->GetTextModel()->GetUnderlineRuns(underlineRuns.Begin(), 0u, numberOfUnderlineRuns); + + struct DataOfCase + { + std::string title; + GlyphIndex glyphIndex; + Length numberOfGlyphs; + UnderlineStyleProperties properties; + }; + DataOfCase data[] = + { + //Outter + {"ABXYZCDE", + 5u, + 8u, + { + Text::Underline::SOLID, + Color::GREEN, + 5u, + 1u, + 2u, + false, + true, + true, + false, + false, + }}, + + //Inner + {"XYZ", + 7u, + 3u, + { + Text::Underline::SOLID, + Color::BLUE, + 5u, + 1u, + 2u, + false, + true, + true, + false, + false, + }}, + + }; + + for(uint32_t i = 0; i < expectedNumberOfUnderlineRuns; i++) + { + tet_infoline(data[i].title.c_str()); + DALI_TEST_EQUALS(underlineRuns[i].glyphRun.glyphIndex, data[i].glyphIndex, TEST_LOCATION); + DALI_TEST_EQUALS(underlineRuns[i].glyphRun.numberOfGlyphs, data[i].numberOfGlyphs, TEST_LOCATION); + DALI_TEST_CHECK(data[i].properties == underlineRuns[i].properties); + } + + END_TEST; +} + +int UtcDaliTextEditorMarkupNestedStrikethroughTags(void) +{ + ToolkitTestApplication application; + tet_infoline(" UtcDaliTextEditorMarkupNestedStrikethroughTags "); + + TextEditor textEditor = TextEditor::New(); + + application.GetScene().Add(textEditor); + + std::string testText = "startABXYZCDEend"; + + textEditor.SetProperty(TextEditor::Property::TEXT, testText); + textEditor.SetProperty(TextEditor ::Property::ENABLE_MARKUP, true); + + application.SendNotification(); + application.Render(); + + const uint32_t expectedNumberOfStrikethroughRuns = 2u; + + Toolkit::Internal::TextEditor& textEditorImpl = GetImpl(textEditor); + const Text::Length numberOfStrikethroughRuns = textEditorImpl.GetTextController()->GetTextModel()->GetNumberOfStrikethroughRuns(); + + DALI_TEST_EQUALS(numberOfStrikethroughRuns, expectedNumberOfStrikethroughRuns, TEST_LOCATION); + + Vector strikethroughRuns; + strikethroughRuns.Resize(numberOfStrikethroughRuns); + textEditorImpl.GetTextController()->GetTextModel()->GetStrikethroughRuns(strikethroughRuns.Begin(), 0u, numberOfStrikethroughRuns); + + struct DataOfCase + { + std::string title; + GlyphIndex glyphIndex; + Length numberOfGlyphs; + StrikethroughStyleProperties properties; + }; + DataOfCase data[] = + { + //Outter + {"ABXYZCDE", + 5u, + 8u, + { + Color::GREEN, + 5.0f, + true, + true, + }}, + + //Inner + {"XYZ", + 7u, + 3u, + { + Color::BLUE, + 5.0f, + true, + true, + }}, + + }; + + for(uint32_t i = 0; i < expectedNumberOfStrikethroughRuns; i++) + { + tet_infoline(data[i].title.c_str()); + DALI_TEST_EQUALS(strikethroughRuns[i].glyphRun.glyphIndex, data[i].glyphIndex, TEST_LOCATION); + DALI_TEST_EQUALS(strikethroughRuns[i].glyphRun.numberOfGlyphs, data[i].numberOfGlyphs, TEST_LOCATION); + DALI_TEST_CHECK(data[i].properties == strikethroughRuns[i].properties); + } END_TEST; } + +int UtcDaliTextEditorMarkupStrikethroughAttributes(void) +{ + ToolkitTestApplication application; + tet_infoline(" UtcDaliTextEditorMarkupStrikethroughAttributes "); + + TextEditor textEditor = TextEditor::New(); + + application.GetScene().Add(textEditor); + + std::string testText = + "startABC1then" + "ABC2then" + "ABC3then" + "ABC4end"; + + textEditor.SetProperty(TextEditor::Property::TEXT, testText); + textEditor.SetProperty(TextEditor ::Property::ENABLE_MARKUP, true); + + application.SendNotification(); + application.Render(); + + const uint32_t expectedNumberOfStrikethroughRuns = 4u; + + Toolkit::Internal::TextEditor& textEditorImpl = GetImpl(textEditor); + const Text::Length numberOfStrikethroughRuns = textEditorImpl.GetTextController()->GetTextModel()->GetNumberOfStrikethroughRuns(); + + DALI_TEST_EQUALS(numberOfStrikethroughRuns, expectedNumberOfStrikethroughRuns, TEST_LOCATION); + + Vector strikethroughRuns; + strikethroughRuns.Resize(numberOfStrikethroughRuns); + textEditorImpl.GetTextController()->GetTextModel()->GetStrikethroughRuns(strikethroughRuns.Begin(), 0u, numberOfStrikethroughRuns); + + struct DataOfCase + { + std::string title; + GlyphIndex glyphIndex; + Length numberOfGlyphs; + StrikethroughStyleProperties properties; + }; + DataOfCase data[] = + { + + {"ABC1", + 5u, + 4u, + {Color::BLACK, + 0.0f, + false, + false}}, + + {"ABC2", + 13u, + 4u, + {Color::GREEN, + 0.0f, + true, + false}}, + + {"ABC3", + 21u, + 4u, + {Color::BLACK, + 5.0f, + false, + true}}, + + {"ABC4", + 29u, + 4u, + {Color::BLUE, + 4.0f, + true, + true}}, + + }; + + for(uint32_t i = 0; i < expectedNumberOfStrikethroughRuns; i++) + { + tet_infoline(data[i].title.c_str()); + DALI_TEST_EQUALS(strikethroughRuns[i].glyphRun.glyphIndex, data[i].glyphIndex, TEST_LOCATION); + DALI_TEST_EQUALS(strikethroughRuns[i].glyphRun.numberOfGlyphs, data[i].numberOfGlyphs, TEST_LOCATION); + DALI_TEST_CHECK(data[i].properties == strikethroughRuns[i].properties); + } + + END_TEST; +} + +int UtcDaliTextEditorMarkupSpanStrikethrough(void) +{ + ToolkitTestApplication application; + tet_infoline(" UtcDaliTextEditorMarkupSpanStrikethrough "); + + TextEditor textEditor = TextEditor::New(); + + application.GetScene().Add(textEditor); + + std::string testText = + "startABC1then" + "ABC2then" + "ABC3then" + "ABC4end"; + + textEditor.SetProperty(TextEditor::Property::TEXT, testText); + textEditor.SetProperty(TextEditor ::Property::ENABLE_MARKUP, true); + + application.SendNotification(); + application.Render(); + + const uint32_t expectedNumberOfStrikethroughRuns = 3u; + + Toolkit::Internal::TextEditor& textEditorImpl = GetImpl(textEditor); + const Text::Length numberOfStrikethroughRuns = textEditorImpl.GetTextController()->GetTextModel()->GetNumberOfStrikethroughRuns(); + + DALI_TEST_EQUALS(numberOfStrikethroughRuns, expectedNumberOfStrikethroughRuns, TEST_LOCATION); + + Vector strikethroughRuns; + strikethroughRuns.Resize(numberOfStrikethroughRuns); + textEditorImpl.GetTextController()->GetTextModel()->GetStrikethroughRuns(strikethroughRuns.Begin(), 0u, numberOfStrikethroughRuns); + + struct DataOfCase + { + std::string title; + GlyphIndex glyphIndex; + Length numberOfGlyphs; + StrikethroughStyleProperties properties; + }; + DataOfCase data[] = + { + + {"ABC2then", + 13u, + 4u, + {Color::BLUE, + 0.0f, + true, + false}}, + + {"ABC3then", + 21u, + 4u, + {Color::BLACK, + 2.0f, + false, + true}}, + + {"ABC4", + 29u, + 4u, + {Color::GREEN, + 5.0f, + true, + true}}, + + }; + + for(uint32_t i = 0; i < expectedNumberOfStrikethroughRuns; i++) + { + tet_infoline(data[i].title.c_str()); + DALI_TEST_EQUALS(strikethroughRuns[i].glyphRun.glyphIndex, data[i].glyphIndex, TEST_LOCATION); + DALI_TEST_EQUALS(strikethroughRuns[i].glyphRun.numberOfGlyphs, data[i].numberOfGlyphs, TEST_LOCATION); + DALI_TEST_CHECK(data[i].properties == strikethroughRuns[i].properties); + } + + END_TEST; +} + +int UtcDaliTextEditorFontPointSizeLargerThanAtlas(void) +{ + ToolkitTestApplication application; + tet_infoline(" UtcDaliTextEditorFontPointSizeLargerThanAtlas "); + + // Create a text editor + TextEditor textEditor = TextEditor::New(); + //Set size to avoid automatic eliding + textEditor.SetProperty(Actor::Property::SIZE, Vector2(1025, 1025)); + //Set very large font-size using point-size + textEditor.SetProperty(TextEditor::Property::POINT_SIZE, 1000); + //Specify font-family + textEditor.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVu Sans"); + //Set text to check if appear or not + textEditor.SetProperty(TextEditor::Property::TEXT, "A"); + + application.GetScene().Add(textEditor); + + application.SendNotification(); + application.Render(); + + //Check if Glyph is added to AtlasGlyphManger or not + int countAtlas = AtlasGlyphManager::Get().GetMetrics().mAtlasMetrics.mAtlasCount; + DALI_TEST_EQUALS(countAtlas, 1, TEST_LOCATION); + + END_TEST; +} + +int UtcDaliTextEditorFontPointSizeLargerThanAtlasPlaceholderCase(void) +{ + ToolkitTestApplication application; + tet_infoline(" UtcDaliTextEditorFontPointSizeLargerThanAtlasPlaceholderCase "); + + //Set Map of placeholder: text, font-family and point-size + Property::Map placeholderMapSet; + placeholderMapSet["text"] = "A"; + placeholderMapSet["fontFamily"] = "DejaVu Sans"; + placeholderMapSet["pixelSize"] = 1000.0f; + + // Create a text editor + TextEditor textEditor = TextEditor::New(); + //Set size to avoid automatic eliding + textEditor.SetProperty(Actor::Property::SIZE, Vector2(1025, 1025)); + //Set placeholder + textEditor.SetProperty(TextEditor::Property::PLACEHOLDER, placeholderMapSet); + + application.GetScene().Add(textEditor); + + application.SendNotification(); + application.Render(); + + //Check if Glyph is added to AtlasGlyphManger or not + int countAtlas = AtlasGlyphManager::Get().GetMetrics().mAtlasMetrics.mAtlasCount; + DALI_TEST_EQUALS(countAtlas, 1, TEST_LOCATION); + + END_TEST; +} + +int UtcDaliTextEditorBackgroundTag(void) +{ + ToolkitTestApplication application; + tet_infoline("UtcDaliTextEditorBackgroundTag\n"); + + TextEditor editor = TextEditor::New(); + DALI_TEST_CHECK(editor); + + editor.SetProperty(TextEditor ::Property::ENABLE_MARKUP, true); + editor.SetProperty(TextEditor::Property::TEXT, "He World"); + application.GetScene().Add(editor); + application.SendNotification(); + application.Render(); + + Toolkit::Internal::TextEditor& editorImpl = GetImpl(editor); + const ColorIndex* const backgroundColorIndicesBuffer = editorImpl.GetTextController()->GetTextModel()->GetBackgroundColorIndices(); + + DALI_TEST_CHECK(backgroundColorIndicesBuffer); + + //default color + DALI_TEST_EQUALS(backgroundColorIndicesBuffer[0], 0u, TEST_LOCATION); + + //red color + DALI_TEST_EQUALS(backgroundColorIndicesBuffer[1], 1u, TEST_LOCATION); + + //yellow color + DALI_TEST_EQUALS(backgroundColorIndicesBuffer[7], 2u, TEST_LOCATION); + + END_TEST; +} + +int UtcDaliTextEditorSpanBackgroundTag(void) +{ + ToolkitTestApplication application; + tet_infoline("UtcDaliTextEditorSpanBackgroundTag\n"); + + TextEditor editor = TextEditor::New(); + DALI_TEST_CHECK(editor); + + editor.SetProperty(TextEditor ::Property::ENABLE_MARKUP, true); + editor.SetProperty(TextEditor::Property::TEXT, "He World"); + application.GetScene().Add(editor); + application.SendNotification(); + application.Render(); + + Toolkit::Internal::TextEditor& editorImpl = GetImpl(editor); + const ColorIndex* const backgroundColorIndicesBuffer = editorImpl.GetTextController()->GetTextModel()->GetBackgroundColorIndices(); + + DALI_TEST_CHECK(backgroundColorIndicesBuffer); + + //default color + DALI_TEST_EQUALS(backgroundColorIndicesBuffer[0], 0u, TEST_LOCATION); + + //red color + DALI_TEST_EQUALS(backgroundColorIndicesBuffer[1], 1u, TEST_LOCATION); + + //yellow color + DALI_TEST_EQUALS(backgroundColorIndicesBuffer[7], 2u, TEST_LOCATION); + + END_TEST; +} + +int UtcDaliTextEditorTextWithSpan(void) +{ + ToolkitTestApplication application; + tet_infoline("UtcDaliTextEditorTextWithSpan\n"); + + TextEditor editor = TextEditor::New(); + DALI_TEST_CHECK(editor); + + editor.SetProperty(TextEditor ::Property::ENABLE_MARKUP, true); + editor.SetProperty(TextEditor::Property::TEXT, "Hello Span"); + application.GetScene().Add(editor); + + application.SendNotification(); + application.Render(); + + Vector3 originalSize = editor.GetNaturalSize(); + editor.SetProperty(TextEditor::Property::TEXT, "Hello Span"); + + application.SendNotification(); + application.Render(); + + Vector3 spanSize = editor.GetNaturalSize(); + + DALI_TEST_GREATER(spanSize.width, originalSize.width, TEST_LOCATION); + + Toolkit::Internal::TextEditor& editorImpl = GetImpl(editor); + const ColorIndex* const colorIndicesBuffer1 = editorImpl.GetTextController()->GetTextModel()->GetColorIndices(); + + DALI_TEST_CHECK(colorIndicesBuffer1); + + //default color + DALI_TEST_EQUALS(colorIndicesBuffer1[0], 0u, TEST_LOCATION); + + //span color + DALI_TEST_EQUALS(colorIndicesBuffer1[1], 1u, TEST_LOCATION); + + //default color + DALI_TEST_EQUALS(colorIndicesBuffer1[6], 0u, TEST_LOCATION); + + editor.SetProperty(TextEditor::Property::TEXT, "Hello Span"); + + application.SendNotification(); + application.Render(); + + const ColorIndex* const colorIndicesBuffer2 = editorImpl.GetTextController()->GetTextModel()->GetColorIndices(); + + DALI_TEST_CHECK(colorIndicesBuffer2); + + //default color + DALI_TEST_EQUALS(colorIndicesBuffer2[0], 0u, TEST_LOCATION); + + //default color + DALI_TEST_EQUALS(colorIndicesBuffer2[1], 0u, TEST_LOCATION); + + //span color + DALI_TEST_EQUALS(colorIndicesBuffer2[6], 1u, TEST_LOCATION); + + //default color + DALI_TEST_EQUALS(colorIndicesBuffer2[7], 0u, TEST_LOCATION); + + END_TEST; +} + +int UtcDaliTextEditorControlBackgroundColor(void) +{ + ToolkitTestApplication application; + tet_infoline(" UtcDaliTextEditorControlBackgroundColor\n"); + + TextEditor editor = TextEditor::New(); + DALI_TEST_CHECK(editor); + + Vector4 backgroundColor; + + editor.SetProperty(TextEditor::Property::TEXT, "Background Color"); + application.GetScene().Add(editor); + application.SendNotification(); + application.Render(); + + Toolkit::Internal::TextEditor& editorImpl = GetImpl(editor); + ControllerPtr controller = editorImpl.GetTextController(); + Controller::Impl& controllerImpl = Controller::Impl::GetImplementation(*controller.Get()); + + // Default color is transparent + controllerImpl.mEditableControlInterface->GetControlBackgroundColor(backgroundColor); + DALI_TEST_EQUALS(backgroundColor, Color::TRANSPARENT, TEST_LOCATION); + + // Set background color to red + editor.SetBackgroundColor(Color::RED); + application.SendNotification(); + application.Render(); + + // Should be red + controllerImpl.mEditableControlInterface->GetControlBackgroundColor(backgroundColor); + DALI_TEST_EQUALS(backgroundColor, Color::RED, TEST_LOCATION); + + END_TEST; +} + +int UtcDaliTextEditorTextPositionWithMinLineAndBigFont(void) +{ + ToolkitTestApplication application; + tet_infoline(" UtcDaliTextEditorTextPositionWithMinLine "); + + TextEditor textEditor = TextEditor::New(); + + textEditor.SetProperty(TextEditor::Property::TEXT, "H\ni"); + textEditor.SetProperty(DevelTextEditor::Property::MIN_LINE_SIZE, 50); + textEditor.SetProperty(TextEditor ::Property::ENABLE_MARKUP, true); + + application.GetScene().Add(textEditor); + + application.SendNotification(); + application.Render(); + + Toolkit::Internal::TextEditor& textEditorImpl = GetImpl(textEditor); + Text::ViewInterface& view = textEditorImpl.GetTextController()->GetView(); + + Length numberOfGlyphs = view.GetNumberOfGlyphs(); + + DALI_TEST_EQUALS(numberOfGlyphs, 3u, Math::MACHINE_EPSILON_1000, TEST_LOCATION); + + Vector glyphs; + glyphs.Resize(numberOfGlyphs); + + Vector positions; + positions.Resize(numberOfGlyphs); + + float alignmentOffset = 0u; + numberOfGlyphs = view.GetGlyphs(glyphs.Begin(), + positions.Begin(), + alignmentOffset, + 0u, + numberOfGlyphs); + + DALI_TEST_EQUALS(positions[2].y, 165.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION); + + END_TEST; +} + +int UtcDaliTextEditorMarkupStrikethrough(void) +{ + ToolkitTestApplication application; + tet_infoline(" UtcDaliTextEditorMarkupStrikethrough "); + + TextEditor textEditor = TextEditor::New(); + + application.GetScene().Add(textEditor); + + textEditor.SetProperty(TextEditor::Property::TEXT, "ABCEFGH"); + textEditor.SetProperty(TextEditor ::Property::ENABLE_MARKUP, true); + + application.SendNotification(); + application.Render(); + + uint32_t expectedNumberOfStrikethroughGlyphs = 2u; + + Toolkit::Internal::TextEditor& textEditorImpl = GetImpl(textEditor); + const Text::Length numberOfStrikethroughRuns = textEditorImpl.GetTextController()->GetTextModel()->GetNumberOfStrikethroughRuns(); + + DALI_TEST_EQUALS(numberOfStrikethroughRuns, expectedNumberOfStrikethroughGlyphs, TEST_LOCATION); + + Vector strikethroughRuns; + strikethroughRuns.Resize(numberOfStrikethroughRuns); + textEditorImpl.GetTextController()->GetTextModel()->GetStrikethroughRuns(strikethroughRuns.Begin(), 0u, numberOfStrikethroughRuns); + + //ABC have strikethrough + DALI_TEST_EQUALS(strikethroughRuns[0u].glyphRun.glyphIndex, 0u, TEST_LOCATION); + DALI_TEST_EQUALS(strikethroughRuns[0u].glyphRun.numberOfGlyphs, 3u, TEST_LOCATION); + DALI_TEST_CHECK(!strikethroughRuns[0u].properties.colorDefined); + + //GH have strikethrough + DALI_TEST_EQUALS(strikethroughRuns[1u].glyphRun.glyphIndex, 5u, TEST_LOCATION); + DALI_TEST_EQUALS(strikethroughRuns[1u].glyphRun.numberOfGlyphs, 2u, TEST_LOCATION); + DALI_TEST_CHECK(strikethroughRuns[1u].properties.colorDefined); + + END_TEST; +} + +int UtcDaliTextEditorMarkupStrikethroughNoEndTag(void) +{ + ToolkitTestApplication application; + tet_infoline(" UtcDaliTextEditorMarkupStrikethroughNoEndTag "); + + TextEditor textEditor = TextEditor::New(); + + application.GetScene().Add(textEditor); + + textEditor.SetProperty(TextEditor::Property::TEXT, "ABC"); + textEditor.SetProperty(TextEditor ::Property::ENABLE_MARKUP, true); + + application.SendNotification(); + application.Render(); + + uint32_t expectedNumberOfStrikethroughGlyphs = 0u; + + Toolkit::Internal::TextEditor& textEditorImpl = GetImpl(textEditor); + Text::Length numberOfStrikethroughRuns = textEditorImpl.GetTextController()->GetTextModel()->GetNumberOfStrikethroughRuns(); + + DALI_TEST_EQUALS(numberOfStrikethroughRuns, expectedNumberOfStrikethroughGlyphs, TEST_LOCATION); + + END_TEST; +} + +int UtcDaliTextEditorMarkupParagraphTag(void) + +{ + ToolkitTestApplication application; + tet_infoline(" UtcDaliTextEditorMarkupParagraphTag "); + + TextEditor textEditor = TextEditor::New(); + application.GetScene().Add(textEditor); + + textEditor.SetProperty(TextEditor::Property::TEXT, "text one

Paragraph two

text three

Paragraph four

text five"); + textEditor.SetProperty(TextEditor ::Property::ENABLE_MARKUP, true); + + application.SendNotification(); + application.Render(); + + uint32_t expectedNumberOfBoundedParagraphRuns = 2u; + + Toolkit::Internal::TextEditor& textEditorImpl = GetImpl(textEditor); + const Text::Length numberOfBoundedParagraphRuns = textEditorImpl.GetTextController()->GetTextModel()->GetNumberOfBoundedParagraphRuns(); + DALI_TEST_EQUALS(numberOfBoundedParagraphRuns, expectedNumberOfBoundedParagraphRuns, TEST_LOCATION); + + const Vector& boundedParagraphRuns = textEditorImpl.GetTextController()->GetTextModel()->GetBoundedParagraphRuns(); + + //

Paragraph two

+ DALI_TEST_EQUALS(boundedParagraphRuns[0u].characterRun.characterIndex, 10u, TEST_LOCATION); + DALI_TEST_EQUALS(boundedParagraphRuns[0u].characterRun.numberOfCharacters, 14u, TEST_LOCATION); + + //

Paragraph four

+ DALI_TEST_EQUALS(boundedParagraphRuns[1u].characterRun.characterIndex, 37u, TEST_LOCATION); + DALI_TEST_EQUALS(boundedParagraphRuns[1u].characterRun.numberOfCharacters, 15u, TEST_LOCATION); + + END_TEST; +} + +int UtcDaliTextEditorMarkupParagraphTagAlignAttribute(void) +{ + ToolkitTestApplication application; + tet_infoline(" UtcDaliTextEditorMarkupParagraphTagAlignAttribute "); + + // Apply alignment for each type on property level on three paragraphs and in-between text. + // Apply align in markup on the three paragraphs (each one a type). + // Using the same text to gain similar results from both the property level and the markup. + // Compare line alignment between the property level and the markup. + + std::string textAlignOnPropertyLevel = "text outside

Paragraph end

text outside

Paragraph center

text outside

Paragraph begin

Paragraph property alignment

"; + std::string textAlignInMarkup = "text outside

Paragraph end

text outside

Paragraph center

text outside

Paragraph begin

Paragraph property alignment

"; + + //Set size to avoid automatic eliding + Vector2 controllerSize = Vector2(1025, 1025); + + TextEditor textEditorBeginAlign = TextEditor::New(); + TextEditor textEditorCenterAlign = TextEditor::New(); + TextEditor textEditorEndAlign = TextEditor::New(); + TextEditor textEditorMultiAlign = TextEditor::New(); + + application.GetScene().Add(textEditorBeginAlign); + application.GetScene().Add(textEditorCenterAlign); + application.GetScene().Add(textEditorEndAlign); + application.GetScene().Add(textEditorMultiAlign); + + textEditorBeginAlign.SetProperty(TextEditor::Property::TEXT, textAlignOnPropertyLevel); + textEditorBeginAlign.SetProperty(TextEditor ::Property::ENABLE_MARKUP, true); + textEditorBeginAlign.SetProperty(DevelTextEditor::Property::ELLIPSIS, false); + textEditorBeginAlign.SetProperty(TextEditor::Property::HORIZONTAL_ALIGNMENT, Dali::Toolkit::Text::HorizontalAlignment::BEGIN); + textEditorBeginAlign.SetProperty(Actor::Property::SIZE, controllerSize); + + textEditorCenterAlign.SetProperty(TextEditor::Property::TEXT, textAlignOnPropertyLevel); + textEditorCenterAlign.SetProperty(TextEditor ::Property::ENABLE_MARKUP, true); + textEditorCenterAlign.SetProperty(DevelTextEditor::Property::ELLIPSIS, false); + textEditorCenterAlign.SetProperty(TextEditor::Property::HORIZONTAL_ALIGNMENT, Dali::Toolkit::Text::HorizontalAlignment::CENTER); + textEditorCenterAlign.SetProperty(Actor::Property::SIZE, controllerSize); + + textEditorEndAlign.SetProperty(TextEditor::Property::TEXT, textAlignOnPropertyLevel); + textEditorEndAlign.SetProperty(TextEditor ::Property::ENABLE_MARKUP, true); + textEditorEndAlign.SetProperty(DevelTextEditor::Property::ELLIPSIS, false); + textEditorEndAlign.SetProperty(TextEditor::Property::HORIZONTAL_ALIGNMENT, Dali::Toolkit::Text::HorizontalAlignment::END); + textEditorEndAlign.SetProperty(Actor::Property::SIZE, controllerSize); + + textEditorMultiAlign.SetProperty(TextEditor::Property::TEXT, textAlignInMarkup); + textEditorMultiAlign.SetProperty(TextEditor ::Property::ENABLE_MARKUP, true); + textEditorMultiAlign.SetProperty(DevelTextEditor::Property::ELLIPSIS, false); + textEditorMultiAlign.SetProperty(TextEditor::Property::HORIZONTAL_ALIGNMENT, Dali::Toolkit::Text::HorizontalAlignment::CENTER); + textEditorMultiAlign.SetProperty(Actor::Property::SIZE, controllerSize); + + application.SendNotification(); + application.Render(); + + uint32_t expectedNumberOfBoundedParagraphRuns = 4u; + uint32_t expectedNumberOfLines = 7u; + + Toolkit::Internal::TextEditor& textEditorMultiAlignImpl = GetImpl(textEditorMultiAlign); + Toolkit::Internal::TextEditor& textEditorBeginAlignImpl = GetImpl(textEditorBeginAlign); + Toolkit::Internal::TextEditor& textEditorCenterAlignImpl = GetImpl(textEditorCenterAlign); + Toolkit::Internal::TextEditor& textEditorEndAlignImpl = GetImpl(textEditorEndAlign); + + const Text::Length numberOfBoundedParagraphRuns = textEditorMultiAlignImpl.GetTextController()->GetTextModel()->GetNumberOfBoundedParagraphRuns(); + DALI_TEST_EQUALS(numberOfBoundedParagraphRuns, expectedNumberOfBoundedParagraphRuns, TEST_LOCATION); + + DALI_TEST_EQUALS(textEditorMultiAlignImpl.GetTextController()->GetTextModel()->GetNumberOfLines(), expectedNumberOfLines, TEST_LOCATION); + DALI_TEST_CHECK(textEditorMultiAlignImpl.GetTextController()->GetTextModel()->GetLines()); + + DALI_TEST_EQUALS(textEditorBeginAlignImpl.GetTextController()->GetTextModel()->GetNumberOfLines(), expectedNumberOfLines, TEST_LOCATION); + DALI_TEST_CHECK(textEditorBeginAlignImpl.GetTextController()->GetTextModel()->GetLines()); + + DALI_TEST_EQUALS(textEditorCenterAlignImpl.GetTextController()->GetTextModel()->GetNumberOfLines(), expectedNumberOfLines, TEST_LOCATION); + DALI_TEST_CHECK(textEditorCenterAlignImpl.GetTextController()->GetTextModel()->GetLines()); + + DALI_TEST_EQUALS(textEditorEndAlignImpl.GetTextController()->GetTextModel()->GetNumberOfLines(), expectedNumberOfLines, TEST_LOCATION); + DALI_TEST_CHECK(textEditorEndAlignImpl.GetTextController()->GetTextModel()->GetLines()); + + const uint32_t LINE_INDEX_ALIGN_END = 1u; + const uint32_t LINE_INDEX_ALIGN_CENTER = 3u; + const uint32_t LINE_INDEX_ALIGN_BEGIN = 5u; + const uint32_t LINE_INDEX_OUTSIDE_1 = 0u; + const uint32_t LINE_INDEX_OUTSIDE_2 = 2u; + const uint32_t LINE_INDEX_OUTSIDE_3 = 4u; + const uint32_t LINE_INDEX_PARAGRAPH = 6u; + + //

Paragraph end

+ const LineRun& lineEndFromMultiAlign = *(textEditorMultiAlignImpl.GetTextController()->GetTextModel()->GetLines() + LINE_INDEX_ALIGN_END); + const LineRun& lineEndFromEndAlign = *(textEditorEndAlignImpl.GetTextController()->GetTextModel()->GetLines() + LINE_INDEX_ALIGN_END); + tet_infoline(" UtcDaliTextEditorMarkupParagraphTagAlignAttribute -

Paragraph end

"); + DALI_TEST_EQUALS(lineEndFromMultiAlign.alignmentOffset, lineEndFromEndAlign.alignmentOffset, TEST_LOCATION); + DALI_TEST_EQUALS(lineEndFromMultiAlign.width, lineEndFromEndAlign.width, TEST_LOCATION); + + //

Paragraph center

+ const LineRun& lineCenterFromMultiAlign = *(textEditorMultiAlignImpl.GetTextController()->GetTextModel()->GetLines() + LINE_INDEX_ALIGN_CENTER); + const LineRun& lineEndFromCenterAlign = *(textEditorCenterAlignImpl.GetTextController()->GetTextModel()->GetLines() + LINE_INDEX_ALIGN_CENTER); + tet_infoline(" UtcDaliTextEditorMarkupParagraphTagAlignAttribute -

Paragraph center

"); + DALI_TEST_EQUALS(lineCenterFromMultiAlign.alignmentOffset, lineEndFromCenterAlign.alignmentOffset, TEST_LOCATION); + DALI_TEST_EQUALS(lineCenterFromMultiAlign.width, lineEndFromCenterAlign.width, TEST_LOCATION); + + //

Paragraph begin

+ const LineRun& lineBeginFromMultiAlign = *(textEditorMultiAlignImpl.GetTextController()->GetTextModel()->GetLines() + LINE_INDEX_ALIGN_BEGIN); + const LineRun& lineEndFromBeginAlign = *(textEditorBeginAlignImpl.GetTextController()->GetTextModel()->GetLines() + LINE_INDEX_ALIGN_BEGIN); + tet_infoline(" UtcDaliTextEditorMarkupParagraphTagAlignAttribute -

Paragraph begin

"); + DALI_TEST_EQUALS(lineBeginFromMultiAlign.alignmentOffset, lineEndFromBeginAlign.alignmentOffset, TEST_LOCATION); + DALI_TEST_EQUALS(lineBeginFromMultiAlign.width, lineEndFromBeginAlign.width, TEST_LOCATION); + + //text outside + const LineRun& lineOutsideOneFromMultiAlign = *(textEditorMultiAlignImpl.GetTextController()->GetTextModel()->GetLines() + LINE_INDEX_OUTSIDE_1); + const LineRun& lineOutsideOneFromCenterAlign = *(textEditorCenterAlignImpl.GetTextController()->GetTextModel()->GetLines() + LINE_INDEX_OUTSIDE_1); + tet_infoline(" UtcDaliTextEditorMarkupParagraphTagAlignAttribute - text outside one"); + DALI_TEST_EQUALS(lineOutsideOneFromMultiAlign.alignmentOffset, lineOutsideOneFromCenterAlign.alignmentOffset, TEST_LOCATION); + DALI_TEST_EQUALS(lineOutsideOneFromMultiAlign.width, lineOutsideOneFromCenterAlign.width, TEST_LOCATION); + + const LineRun& lineOutsideTwoFromMultiAlign = *(textEditorMultiAlignImpl.GetTextController()->GetTextModel()->GetLines() + LINE_INDEX_OUTSIDE_2); + const LineRun& lineOutsideTwoFromCenterAlign = *(textEditorCenterAlignImpl.GetTextController()->GetTextModel()->GetLines() + LINE_INDEX_OUTSIDE_2); + tet_infoline(" UtcDaliTextEditorMarkupParagraphTagAlignAttribute - text outside two"); + DALI_TEST_EQUALS(lineOutsideTwoFromMultiAlign.alignmentOffset, lineOutsideTwoFromCenterAlign.alignmentOffset, TEST_LOCATION); + DALI_TEST_EQUALS(lineOutsideTwoFromMultiAlign.width, lineOutsideTwoFromCenterAlign.width, TEST_LOCATION); + + const LineRun& lineOutsideThreeFromMultiAlign = *(textEditorMultiAlignImpl.GetTextController()->GetTextModel()->GetLines() + LINE_INDEX_OUTSIDE_3); + const LineRun& lineOutsideThreeFromCenterAlign = *(textEditorCenterAlignImpl.GetTextController()->GetTextModel()->GetLines() + LINE_INDEX_OUTSIDE_3); + tet_infoline(" UtcDaliTextEditorMarkupParagraphTagAlignAttribute - text outside three"); + DALI_TEST_EQUALS(lineOutsideThreeFromMultiAlign.alignmentOffset, lineOutsideThreeFromCenterAlign.alignmentOffset, TEST_LOCATION); + DALI_TEST_EQUALS(lineOutsideThreeFromMultiAlign.width, lineOutsideThreeFromCenterAlign.width, TEST_LOCATION); + + const LineRun& lineParagraphFromMultiAlign = *(textEditorMultiAlignImpl.GetTextController()->GetTextModel()->GetLines() + LINE_INDEX_PARAGRAPH); + const LineRun& lineParagraphFromCenterAlign = *(textEditorCenterAlignImpl.GetTextController()->GetTextModel()->GetLines() + LINE_INDEX_PARAGRAPH); + tet_infoline(" UtcDaliTextEditorMarkupParagraphTagAlignAttribute -

Paragraph property alignment

"); + DALI_TEST_EQUALS(lineParagraphFromMultiAlign.alignmentOffset, lineParagraphFromCenterAlign.alignmentOffset, TEST_LOCATION); + DALI_TEST_EQUALS(lineParagraphFromMultiAlign.width, lineParagraphFromCenterAlign.width, TEST_LOCATION); + + END_TEST; +} + +int UtcDaliTextEditorMarkupCharacterSpacingTag(void) +{ + ToolkitTestApplication application; + tet_infoline(" UtcDaliTextEditorMarkupCharacterSpacingTag "); + + const Length EXPECTED_NUMBER_OF_GLYPHS = 21u; + + const float expandedCharSpacing = 10.0f; + const float condensedCharSpacing = -5.0f; + + TextEditor textEditor = TextEditor::New(); + + textEditor.SetProperty(TextEditor::Property::TEXT, "ABC EF\nABC EF\nABC EF\n"); + textEditor.SetProperty(TextEditor ::Property::ENABLE_MARKUP, true); + + application.GetScene().Add(textEditor); + + application.SendNotification(); + application.Render(); + + Toolkit::Internal::TextEditor& textEditorImpl = GetImpl(textEditor); + Text::ViewInterface& view = textEditorImpl.GetTextController()->GetView(); + + Length numberOfGlyphs = view.GetNumberOfGlyphs(); + + DALI_TEST_EQUALS(numberOfGlyphs, EXPECTED_NUMBER_OF_GLYPHS, Math::MACHINE_EPSILON_1000, TEST_LOCATION); + + Vector glyphs; + glyphs.Resize(numberOfGlyphs); + + Vector positions; + positions.Resize(numberOfGlyphs); + + float alignmentOffset = 0u; + numberOfGlyphs = view.GetGlyphs(glyphs.Begin(), + positions.Begin(), + alignmentOffset, + 0u, + numberOfGlyphs); + + const Length numberOfGlyphsOneLine = 7u; + for(Length i = 0; i < numberOfGlyphsOneLine - 1u; i++) + { + float diffLineNoCharSpacing = positions[i + 1].x - positions[i].x; + + float diffLineCondensedCharSpacing = positions[numberOfGlyphsOneLine + i + 1].x - positions[numberOfGlyphsOneLine + i].x; + DALI_TEST_EQUALS(diffLineCondensedCharSpacing, diffLineNoCharSpacing + condensedCharSpacing, Math::MACHINE_EPSILON_1000, TEST_LOCATION); + + float diffLineExpandedCharSpacing = positions[2u * numberOfGlyphsOneLine + i + 1].x - positions[2u * numberOfGlyphsOneLine + i].x; + DALI_TEST_EQUALS(diffLineExpandedCharSpacing, diffLineNoCharSpacing + expandedCharSpacing, Math::MACHINE_EPSILON_1000, TEST_LOCATION); + } + + END_TEST; +} + +int UtcDaliTextEditorMarkupSpanCharacterSpacing(void) +{ + ToolkitTestApplication application; + tet_infoline(" UtcDaliTextEditorMarkupSpanCharacterSpacing "); + + const Length EXPECTED_NUMBER_OF_GLYPHS = 21u; + + const float expandedCharSpacing = 10.0f; + const float condensedCharSpacing = -5.0f; + + std::string testText = + "ABC EF\n" + "ABC EF\n" + "ABC EF\n"; + + TextEditor textEditor = TextEditor::New(); + + textEditor.SetProperty(TextEditor::Property::TEXT, testText); + textEditor.SetProperty(TextEditor ::Property::ENABLE_MARKUP, true); + + application.GetScene().Add(textEditor); + + application.SendNotification(); + application.Render(); + + Toolkit::Internal::TextEditor& textEditorImpl = GetImpl(textEditor); + Text::ViewInterface& view = textEditorImpl.GetTextController()->GetView(); + + Length numberOfGlyphs = view.GetNumberOfGlyphs(); + + DALI_TEST_EQUALS(numberOfGlyphs, EXPECTED_NUMBER_OF_GLYPHS, Math::MACHINE_EPSILON_1000, TEST_LOCATION); + + Vector glyphs; + glyphs.Resize(numberOfGlyphs); + + Vector positions; + positions.Resize(numberOfGlyphs); + + float alignmentOffset = 0u; + numberOfGlyphs = view.GetGlyphs(glyphs.Begin(), + positions.Begin(), + alignmentOffset, + 0u, + numberOfGlyphs); + + const Length numberOfGlyphsOneLine = 7u; + for(Length i = 0; i < numberOfGlyphsOneLine - 1u; i++) + { + float diffLineNoCharSpacing = positions[i + 1].x - positions[i].x; + + float diffLineCondensedCharSpacing = positions[numberOfGlyphsOneLine + i + 1].x - positions[numberOfGlyphsOneLine + i].x; + DALI_TEST_EQUALS(diffLineCondensedCharSpacing, diffLineNoCharSpacing + condensedCharSpacing, Math::MACHINE_EPSILON_1000, TEST_LOCATION); + + float diffLineExpandedCharSpacing = positions[2u * numberOfGlyphsOneLine + i + 1].x - positions[2u * numberOfGlyphsOneLine + i].x; + DALI_TEST_EQUALS(diffLineExpandedCharSpacing, diffLineNoCharSpacing + expandedCharSpacing, Math::MACHINE_EPSILON_1000, TEST_LOCATION); + } + + END_TEST; +} \ No newline at end of file