X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=automated-tests%2Fsrc%2Fdali-toolkit-internal%2Futc-Dali-TextLabel-internal.cpp;h=31de85066b1b157ca5548f3136d2c1407f4c8564;hb=HEAD;hp=feed97c5e39e5815a92119c027a7163caafc7a54;hpb=ee33f54bcefdc59971ffa428e6f8e4bdd31b94ed;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/automated-tests/src/dali-toolkit-internal/utc-Dali-TextLabel-internal.cpp b/automated-tests/src/dali-toolkit-internal/utc-Dali-TextLabel-internal.cpp index feed97c..31de850 100644 --- a/automated-tests/src/dali-toolkit-internal/utc-Dali-TextLabel-internal.cpp +++ b/automated-tests/src/dali-toolkit-internal/utc-Dali-TextLabel-internal.cpp @@ -22,10 +22,10 @@ #include #include +#include +#include #include #include -#include -#include using namespace Dali; using namespace Toolkit; @@ -46,12 +46,12 @@ int UtcDaliTextLabelMarkupUnderline(void) application.SendNotification(); application.Render(); - uint32_t expectedNumberOfUnderlinedGlyphs = 5u; + uint32_t expectedNumberOfUnderlineRuns = 2u; Toolkit::Internal::TextLabel& textLabelImpl = GetImpl(textLabel); const Text::Length numberOfUnderlineRuns = textLabelImpl.GetTextController()->GetTextModel()->GetNumberOfUnderlineRuns(); - DALI_TEST_EQUALS(numberOfUnderlineRuns, expectedNumberOfUnderlinedGlyphs, TEST_LOCATION); + DALI_TEST_EQUALS(numberOfUnderlineRuns, expectedNumberOfUnderlineRuns, TEST_LOCATION); Vector underlineRuns; underlineRuns.Resize(numberOfUnderlineRuns); @@ -59,12 +59,11 @@ int UtcDaliTextLabelMarkupUnderline(void) //ABC are underlined DALI_TEST_EQUALS(underlineRuns[0u].glyphRun.glyphIndex, 0u, TEST_LOCATION); - DALI_TEST_EQUALS(underlineRuns[1u].glyphRun.glyphIndex, 1u, TEST_LOCATION); - DALI_TEST_EQUALS(underlineRuns[2u].glyphRun.glyphIndex, 2u, TEST_LOCATION); + DALI_TEST_EQUALS(underlineRuns[0u].glyphRun.numberOfGlyphs, 3u, TEST_LOCATION); //GH are underlined - DALI_TEST_EQUALS(underlineRuns[3u].glyphRun.glyphIndex, 5u, TEST_LOCATION); - DALI_TEST_EQUALS(underlineRuns[4u].glyphRun.glyphIndex, 6u, TEST_LOCATION); + DALI_TEST_EQUALS(underlineRuns[1u].glyphRun.glyphIndex, 5u, TEST_LOCATION); + DALI_TEST_EQUALS(underlineRuns[1u].glyphRun.numberOfGlyphs, 2u, TEST_LOCATION); END_TEST; } @@ -97,13 +96,12 @@ int UtcDaliTextLabelMarkupUnderlineAttributes(void) application.SendNotification(); application.Render(); - const uint32_t NUMBER_OF_CASES = 9u; - uint32_t expectedNumberOfUnderlinedGlyphs = 36u; + const uint32_t expectedNumberOfUnderlineRuns = 9u; Toolkit::Internal::TextLabel& textLabelImpl = GetImpl(textLabel); const Text::Length numberOfUnderlineRuns = textLabelImpl.GetTextController()->GetTextModel()->GetNumberOfUnderlineRuns(); - DALI_TEST_EQUALS(numberOfUnderlineRuns, expectedNumberOfUnderlinedGlyphs, TEST_LOCATION); + DALI_TEST_EQUALS(numberOfUnderlineRuns, expectedNumberOfUnderlineRuns, TEST_LOCATION); Vector underlineRuns; underlineRuns.Resize(numberOfUnderlineRuns); @@ -112,20 +110,16 @@ int UtcDaliTextLabelMarkupUnderlineAttributes(void) struct DataOfCase { std::string title; - uint32_t startIndex; - uint32_t endIndex; - GlyphIndex startGlyphIndex; - GlyphIndex endGlyphIndex; + GlyphIndex glyphIndex; + Length numberOfGlyphs; UnderlineStyleProperties properties; }; DataOfCase data[] = { //ABC1 {"ABC1", - 0u, - 3u, 5u, - 8u, + 4u, { Text::Underline::SOLID, Color::BLACK, @@ -141,10 +135,8 @@ int UtcDaliTextLabelMarkupUnderlineAttributes(void) //ABC2 {"ABC2", - 4u, - 7u, 13u, - 16u, + 4u, { Text::Underline::SOLID, Color::BLACK, @@ -160,10 +152,8 @@ int UtcDaliTextLabelMarkupUnderlineAttributes(void) //ABC3 {"ABC3", - 8u, - 11u, 21u, - 24u, + 4u, { Text::Underline::DASHED, Color::BLACK, @@ -179,10 +169,8 @@ int UtcDaliTextLabelMarkupUnderlineAttributes(void) //ABC4 {"ABC4", - 12u, - 15u, 29u, - 32u, + 4u, { Text::Underline::DOUBLE, Color::BLACK, @@ -198,10 +186,8 @@ int UtcDaliTextLabelMarkupUnderlineAttributes(void) //ABC5 {"ABC5", - 16u, - 19u, 37u, - 40u, + 4u, { Text::Underline::SOLID, Color::GREEN, @@ -217,10 +203,8 @@ int UtcDaliTextLabelMarkupUnderlineAttributes(void) //ABC6 {"ABC6", - 20u, - 23u, 45u, - 48u, + 4u, { Text::Underline::SOLID, Color::BLACK, @@ -236,10 +220,8 @@ int UtcDaliTextLabelMarkupUnderlineAttributes(void) //ABC7 {"ABC7", - 24u, - 27u, 53u, - 56u, + 4u, { Text::Underline::DASHED, Color::BLACK, @@ -255,10 +237,8 @@ int UtcDaliTextLabelMarkupUnderlineAttributes(void) //ABC8 {"ABC8", - 28u, - 31u, 61u, - 64u, + 4u, { Text::Underline::DASHED, Color::BLACK, @@ -274,10 +254,8 @@ int UtcDaliTextLabelMarkupUnderlineAttributes(void) // {"", - 32u, - 35u, 69u, - 72u, + 4u, { Text::Underline::DASHED, Color::BLUE, @@ -293,14 +271,12 @@ int UtcDaliTextLabelMarkupUnderlineAttributes(void) }; - for(uint32_t i = 0; i < NUMBER_OF_CASES; i++) + for(uint32_t i = 0; i < expectedNumberOfUnderlineRuns; i++) { tet_infoline(data[i].title.c_str()); - DALI_TEST_EQUALS(underlineRuns[data[i].startIndex].glyphRun.glyphIndex, data[i].startGlyphIndex, TEST_LOCATION); - DALI_TEST_EQUALS(underlineRuns[data[i].endIndex].glyphRun.glyphIndex, data[i].endGlyphIndex, TEST_LOCATION); - - DALI_TEST_CHECK(data[i].properties == underlineRuns[data[i].startIndex].properties); - DALI_TEST_CHECK(data[i].properties == underlineRuns[data[i].endIndex].properties); + 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; @@ -324,9 +300,7 @@ int UtcDaliTextLabelMarkupSpanUnderline(void) "ABC6then" "ABC7then" "ABC8then" - "ABC9end" - - ; + "ABC9end"; textLabel.SetProperty(TextLabel::Property::TEXT, testText); textLabel.SetProperty(TextLabel ::Property::ENABLE_MARKUP, true); @@ -334,13 +308,12 @@ int UtcDaliTextLabelMarkupSpanUnderline(void) application.SendNotification(); application.Render(); - const uint32_t NUMBER_OF_CASES = 8u; - uint32_t expectedNumberOfUnderlinedGlyphs = 32u; + const uint32_t expectedNumberOfUnderlineRuns = 8u; Toolkit::Internal::TextLabel& textLabelImpl = GetImpl(textLabel); const Text::Length numberOfUnderlineRuns = textLabelImpl.GetTextController()->GetTextModel()->GetNumberOfUnderlineRuns(); - DALI_TEST_EQUALS(numberOfUnderlineRuns, expectedNumberOfUnderlinedGlyphs, TEST_LOCATION); + DALI_TEST_EQUALS(numberOfUnderlineRuns, expectedNumberOfUnderlineRuns, TEST_LOCATION); Vector underlineRuns; underlineRuns.Resize(numberOfUnderlineRuns); @@ -349,20 +322,16 @@ int UtcDaliTextLabelMarkupSpanUnderline(void) struct DataOfCase { std::string title; - uint32_t startIndex; - uint32_t endIndex; - GlyphIndex startGlyphIndex; - GlyphIndex endGlyphIndex; + GlyphIndex glyphIndex; + Length numberOfGlyphs; UnderlineStyleProperties properties; }; DataOfCase data[] = { - + //ABC2 {"ABC2", - 0u, - 3u, 13u, - 16u, + 4u, { Text::Underline::SOLID, Color::BLACK, @@ -376,11 +345,10 @@ int UtcDaliTextLabelMarkupSpanUnderline(void) false, }}, + //ABC3 {"ABC3", - 4u, - 7u, 21u, - 24u, + 4u, { Text::Underline::DASHED, Color::BLACK, @@ -394,11 +362,10 @@ int UtcDaliTextLabelMarkupSpanUnderline(void) false, }}, + //ABC4 {"ABC4", - 8u, - 11u, 29u, - 32u, + 4u, { Text::Underline::DOUBLE, Color::BLACK, @@ -412,11 +379,10 @@ int UtcDaliTextLabelMarkupSpanUnderline(void) false, }}, + //ABC5 {"ABC5", - 12u, - 15u, 37u, - 40u, + 4u, { Text::Underline::SOLID, Color::GREEN, @@ -430,11 +396,10 @@ int UtcDaliTextLabelMarkupSpanUnderline(void) false, }}, + //ABC6 {"ABC6", - 16u, - 19u, 45u, - 48u, + 4u, { Text::Underline::SOLID, Color::BLACK, @@ -448,11 +413,10 @@ int UtcDaliTextLabelMarkupSpanUnderline(void) false, }}, + //ABC7 {"ABC7", - 20u, - 23u, 53u, - 56u, + 4u, { Text::Underline::DASHED, Color::BLACK, @@ -466,11 +430,10 @@ int UtcDaliTextLabelMarkupSpanUnderline(void) false, }}, + //ABC8 {"ABC8", - 24u, - 27u, 61u, - 64u, + 4u, { Text::Underline::DASHED, Color::BLACK, @@ -484,11 +447,10 @@ int UtcDaliTextLabelMarkupSpanUnderline(void) true, }}, + // {"ABC9", - 28u, - 31u, 69u, - 72u, + 4u, { Text::Underline::DASHED, Color::BLUE, @@ -504,14 +466,334 @@ int UtcDaliTextLabelMarkupSpanUnderline(void) }; - for(uint32_t i = 0; i < NUMBER_OF_CASES; i++) + 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 UtcDaliTextLabelMarkupNestedUnderlineTags(void) +{ + ToolkitTestApplication application; + tet_infoline(" UtcDaliTextLabelMarkupNestedUnderlineTags "); + + TextLabel textLabel = TextLabel::New(); + + application.GetScene().Add(textLabel); + + std::string testText = "startABXYZCDEend"; + + textLabel.SetProperty(TextLabel::Property::TEXT, testText); + textLabel.SetProperty(TextLabel ::Property::ENABLE_MARKUP, true); + + application.SendNotification(); + application.Render(); + + const uint32_t expectedNumberOfUnderlineRuns = 2u; + + Toolkit::Internal::TextLabel& textLabelImpl = GetImpl(textLabel); + const Text::Length numberOfUnderlineRuns = textLabelImpl.GetTextController()->GetTextModel()->GetNumberOfUnderlineRuns(); + + DALI_TEST_EQUALS(numberOfUnderlineRuns, expectedNumberOfUnderlineRuns, TEST_LOCATION); + + Vector underlineRuns; + underlineRuns.Resize(numberOfUnderlineRuns); + textLabelImpl.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 UtcDaliTextLabelMarkupNestedStrikethroughTags(void) +{ + ToolkitTestApplication application; + tet_infoline(" UtcDaliTextLabelMarkupNestedStrikethroughTags "); + + TextLabel textLabel = TextLabel::New(); + + application.GetScene().Add(textLabel); + + std::string testText = "startABXYZCDEend"; + + textLabel.SetProperty(TextLabel::Property::TEXT, testText); + textLabel.SetProperty(TextLabel ::Property::ENABLE_MARKUP, true); + + application.SendNotification(); + application.Render(); + + const uint32_t expectedNumberOfStrikethroughRuns = 2u; + + Toolkit::Internal::TextLabel& textLabelImpl = GetImpl(textLabel); + const Text::Length numberOfStrikethroughRuns = textLabelImpl.GetTextController()->GetTextModel()->GetNumberOfStrikethroughRuns(); + + DALI_TEST_EQUALS(numberOfStrikethroughRuns, expectedNumberOfStrikethroughRuns, TEST_LOCATION); + + Vector strikethroughRuns; + strikethroughRuns.Resize(numberOfStrikethroughRuns); + textLabelImpl.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 UtcDaliTextLabelMarkupStrikethroughAttributes(void) +{ + ToolkitTestApplication application; + tet_infoline(" UtcDaliTextLabelMarkupStrikethroughAttributes "); + + TextLabel textLabel = TextLabel::New(); + + application.GetScene().Add(textLabel); + + std::string testText = + "startABC1then" + "ABC2then" + "ABC3then" + "ABC4end"; + + textLabel.SetProperty(TextLabel::Property::TEXT, testText); + textLabel.SetProperty(TextLabel ::Property::ENABLE_MARKUP, true); + + application.SendNotification(); + application.Render(); + + const uint32_t expectedNumberOfStrikethroughRuns = 4u; + + Toolkit::Internal::TextLabel& textLabelImpl = GetImpl(textLabel); + const Text::Length numberOfStrikethroughRuns = textLabelImpl.GetTextController()->GetTextModel()->GetNumberOfStrikethroughRuns(); + + DALI_TEST_EQUALS(numberOfStrikethroughRuns, expectedNumberOfStrikethroughRuns, TEST_LOCATION); + + Vector strikethroughRuns; + strikethroughRuns.Resize(numberOfStrikethroughRuns); + textLabelImpl.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(underlineRuns[data[i].startIndex].glyphRun.glyphIndex, data[i].startGlyphIndex, TEST_LOCATION); - DALI_TEST_EQUALS(underlineRuns[data[i].endIndex].glyphRun.glyphIndex, data[i].endGlyphIndex, TEST_LOCATION); + 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 UtcDaliTextLabelMarkupSpanStrikethrough(void) +{ + ToolkitTestApplication application; + tet_infoline(" UtcDaliTextLabelMarkupSpanStrikethrough "); + + TextLabel textLabel = TextLabel::New(); + + application.GetScene().Add(textLabel); + + std::string testText = + "startABC1then" + "ABC2then" + "ABC3then" + "ABC4end"; + + textLabel.SetProperty(TextLabel::Property::TEXT, testText); + textLabel.SetProperty(TextLabel ::Property::ENABLE_MARKUP, true); + + application.SendNotification(); + application.Render(); + + const uint32_t expectedNumberOfStrikethroughRuns = 3u; + + Toolkit::Internal::TextLabel& textLabelImpl = GetImpl(textLabel); + const Text::Length numberOfStrikethroughRuns = textLabelImpl.GetTextController()->GetTextModel()->GetNumberOfStrikethroughRuns(); + + DALI_TEST_EQUALS(numberOfStrikethroughRuns, expectedNumberOfStrikethroughRuns, TEST_LOCATION); + + Vector strikethroughRuns; + strikethroughRuns.Resize(numberOfStrikethroughRuns); + textLabelImpl.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}}, - DALI_TEST_CHECK(data[i].properties == underlineRuns[data[i].startIndex].properties); - DALI_TEST_CHECK(data[i].properties == underlineRuns[data[i].endIndex].properties); + {"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; @@ -548,6 +830,37 @@ int UtcDaliTextLabelBackgroundTag(void) END_TEST; } +int UtcDaliTextLabelSpanBackgroundTag(void) +{ + ToolkitTestApplication application; + tet_infoline("UtcDaliTextLabelSpanBackgroundTag\n"); + + TextLabel label = TextLabel::New(); + DALI_TEST_CHECK(label); + + label.SetProperty(TextLabel ::Property::ENABLE_MARKUP, true); + label.SetProperty(TextLabel::Property::TEXT, "He World"); + application.GetScene().Add(label); + application.SendNotification(); + application.Render(); + + Toolkit::Internal::TextLabel& labelImpl = GetImpl(label); + const ColorIndex* const backgroundColorIndicesBuffer = labelImpl.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 UtcDaliToolkitTextlabelEllipsisInternalAPIs(void) { ToolkitTestApplication application; @@ -695,18 +1008,18 @@ int UtcDaliTextLabelMarkupStrikethrough(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_EQUALS(strikethroughRuns[0u].color.r, 1u, TEST_LOCATION); - DALI_TEST_EQUALS(strikethroughRuns[0u].color.g, 0u, TEST_LOCATION); - DALI_TEST_EQUALS(strikethroughRuns[0u].color.b, 0u, TEST_LOCATION); + DALI_TEST_CHECK(strikethroughRuns[0u].properties.colorDefined); + DALI_TEST_EQUALS(strikethroughRuns[0u].properties.color.r, 1u, TEST_LOCATION); + DALI_TEST_EQUALS(strikethroughRuns[0u].properties.color.g, 0u, TEST_LOCATION); + DALI_TEST_EQUALS(strikethroughRuns[0u].properties.color.b, 0u, TEST_LOCATION); //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_EQUALS(strikethroughRuns[1u].color.r, 0u, TEST_LOCATION); - DALI_TEST_EQUALS(strikethroughRuns[1u].color.g, 1u, TEST_LOCATION); - DALI_TEST_EQUALS(strikethroughRuns[1u].color.b, 0u, TEST_LOCATION); + DALI_TEST_CHECK(strikethroughRuns[1u].properties.colorDefined); + DALI_TEST_EQUALS(strikethroughRuns[1u].properties.color.r, 0u, TEST_LOCATION); + DALI_TEST_EQUALS(strikethroughRuns[1u].properties.color.g, 1u, TEST_LOCATION); + DALI_TEST_EQUALS(strikethroughRuns[1u].properties.color.b, 0u, TEST_LOCATION); END_TEST; } @@ -908,3 +1221,143 @@ int UtcDaliTextLabelMarkupParagraphTagAlignAttribute(void) END_TEST; } + +int UtcDaliTextLabelMarkupCharacterSpacingTag(void) +{ + ToolkitTestApplication application; + tet_infoline(" UtcDaliTextLabelMarkupCharacterSpacingTag "); + + const Length EXPECTED_NUMBER_OF_GLYPHS = 21u; + + const float expandedCharSpacing = 10.0f; + const float condensedCharSpacing = -5.0f; + + TextLabel textLabel = TextLabel::New(); + + textLabel.SetProperty(TextLabel::Property::TEXT, "ABC EF\nABC EF\nABC EF\n"); + textLabel.SetProperty(TextLabel ::Property::ENABLE_MARKUP, true); + textLabel.SetProperty(TextLabel::Property::MULTI_LINE, true); + + application.GetScene().Add(textLabel); + + application.SendNotification(); + application.Render(); + + Toolkit::Internal::TextLabel& textLabelImpl = GetImpl(textLabel); + Text::ViewInterface& view = textLabelImpl.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 UtcDaliTextLabelMarkupSpanCharacterSpacing(void) +{ + ToolkitTestApplication application; + tet_infoline(" UtcDaliTextLabelMarkupSpanCharacterSpacing "); + + 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"; + + TextLabel textLabel = TextLabel::New(); + + textLabel.SetProperty(TextLabel::Property::TEXT, testText); + textLabel.SetProperty(TextLabel ::Property::ENABLE_MARKUP, true); + textLabel.SetProperty(TextLabel::Property::MULTI_LINE, true); + + application.GetScene().Add(textLabel); + + application.SendNotification(); + application.Render(); + + Toolkit::Internal::TextLabel& textLabelImpl = GetImpl(textLabel); + Text::ViewInterface& view = textLabelImpl.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 UtcDaliTextLabelLocaleChange(void) +{ + ToolkitTestApplication application; + tet_infoline(" UtcDaliTextLabelLocaleChange "); + + Adaptor &adaptor = application.GetAdaptor(); + TextLabel textLabel = TextLabel::New(); + application.GetScene().Add(textLabel); + + application.SendNotification(); + application.Render(); + + std::string newLocale = "label_TEST"; + adaptor.LocaleChangedSignal().Emit(newLocale); + + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS(newLocale.data(), GetImpl(textLabel).GetLocale(), TEST_LOCATION); + + END_TEST; +} \ No newline at end of file