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=c75f7545b4e0ef989c4515c9b9ae598b97e004f2;hb=c49e595f12e9e56cd7c35262eb52ae1f2d9b685b;hpb=cbae9964e389c6a5cafa3a284f281609a0ed2e60 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 index c75f754..f768255 100644 --- a/automated-tests/src/dali-toolkit-internal/utc-Dali-TextEditor-internal.cpp +++ b/automated-tests/src/dali-toolkit-internal/utc-Dali-TextEditor-internal.cpp @@ -600,6 +600,244 @@ int UtcDaliTextEditorMarkupNestedUnderlineTags(void) 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; @@ -689,6 +927,37 @@ int UtcDaliTextEditorBackgroundTag(void) 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; @@ -857,12 +1126,12 @@ int UtcDaliTextEditorMarkupStrikethrough(void) //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].isColorSet); + 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].isColorSet); + DALI_TEST_CHECK(strikethroughRuns[1u].properties.colorDefined); END_TEST; } @@ -1058,3 +1327,118 @@ int UtcDaliTextEditorMarkupParagraphTagAlignAttribute(void) 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