X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=automated-tests%2Fsrc%2Fdali-toolkit%2Futc-Dali-TextLabel.cpp;h=5495c9da7a520b1aef2edb4fd77d173162845855;hp=c810939e8f9738b71f57d722ad9777ad00a0b835;hb=HEAD;hpb=03663786ba7fb4e98c30580d436023db6efbbbde diff --git a/automated-tests/src/dali-toolkit/utc-Dali-TextLabel.cpp b/automated-tests/src/dali-toolkit/utc-Dali-TextLabel.cpp index c810939..aed1457 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-TextLabel.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-TextLabel.cpp @@ -76,7 +76,13 @@ const char* const PROPERTY_NAME_AUTO_SCROLL_LOOP_DELAY = "autoScrollLoopDelay"; const char* const PROPERTY_NAME_FONT_SIZE_SCALE = "fontSizeScale"; const char* const PROPERTY_NAME_ENABLE_FONT_SIZE_SCALE = "enableFontSizeScale"; -const char* const PROPERTY_NAME_ELLIPSIS_POSITION = "ellipsisPosition"; +const char* const PROPERTY_NAME_ELLIPSIS_POSITION = "ellipsisPosition"; +const char* const PROPERTY_NAME_ANCHOR_COLOR = "anchorColor"; +const char* const PROPERTY_NAME_ANCHOR_CLICKED_COLOR = "anchorClickedColor"; + +const char* const PROPERTY_NAME_REMOVE_FRONT_INSET = "removeFrontInset"; +const char* const PROPERTY_NAME_REMOVE_BACK_INSET = "removeBackInset"; +const char* const PROPERTY_NAME_REMOVE_CUTOUT = "cutout"; const std::string DEFAULT_FONT_DIR("/resources/fonts"); const unsigned int EMOJI_FONT_SIZE = 3840u; // 60 * 64 @@ -356,6 +362,11 @@ int UtcDaliToolkitTextLabelGetPropertyP(void) DALI_TEST_CHECK(label.GetPropertyIndex(PROPERTY_NAME_ENABLE_FONT_SIZE_SCALE) == DevelTextLabel::Property::ENABLE_FONT_SIZE_SCALE); DALI_TEST_CHECK(label.GetPropertyIndex(PROPERTY_NAME_ELLIPSIS_POSITION) == DevelTextLabel::Property::ELLIPSIS_POSITION); DALI_TEST_CHECK(label.GetPropertyIndex(PROPERTY_NAME_STRIKETHROUGH) == DevelTextLabel::Property::STRIKETHROUGH); + DALI_TEST_CHECK(label.GetPropertyIndex(PROPERTY_NAME_ANCHOR_COLOR) == DevelTextLabel::Property::ANCHOR_COLOR); + DALI_TEST_CHECK(label.GetPropertyIndex(PROPERTY_NAME_ANCHOR_CLICKED_COLOR) == DevelTextLabel::Property::ANCHOR_CLICKED_COLOR); + DALI_TEST_CHECK(label.GetPropertyIndex(PROPERTY_NAME_REMOVE_FRONT_INSET) == DevelTextLabel::Property::REMOVE_FRONT_INSET); + DALI_TEST_CHECK(label.GetPropertyIndex(PROPERTY_NAME_REMOVE_BACK_INSET) == DevelTextLabel::Property::REMOVE_BACK_INSET); + DALI_TEST_CHECK(label.GetPropertyIndex(PROPERTY_NAME_REMOVE_CUTOUT) == DevelTextLabel::Property::CUTOUT); END_TEST; } @@ -464,6 +475,13 @@ int UtcDaliToolkitTextLabelSetPropertyP(void) label.SetProperty(TextLabel::Property::TEXT_COLOR, Color::BLUE); DALI_TEST_EQUALS(label.GetProperty(TextLabel::Property::TEXT_COLOR), Color::BLUE, TEST_LOCATION); + // Check that anchor color can be properly set + label.SetProperty(DevelTextLabel::Property::ANCHOR_COLOR, Color::BLUE); + DALI_TEST_EQUALS(label.GetProperty(DevelTextLabel::Property::ANCHOR_COLOR), Color::BLUE, TEST_LOCATION); + + label.SetProperty(DevelTextLabel::Property::ANCHOR_CLICKED_COLOR, Color::RED); + DALI_TEST_EQUALS(label.GetProperty(DevelTextLabel::Property::ANCHOR_CLICKED_COLOR), Color::RED, TEST_LOCATION); + Property::Map strikethroughMapSet; Property::Map strikethroughMapGet; @@ -644,6 +662,21 @@ int UtcDaliToolkitTextLabelSetPropertyP(void) DALI_TEST_EQUALS(strikethroughMapGet.Count(), strikethroughMapSet.Count(), TEST_LOCATION); DALI_TEST_EQUALS(DaliTestCheckMaps(strikethroughMapGet, strikethroughMapSet), true, TEST_LOCATION); + // Check the transparent strikethrough property for coverage. + strikethroughMapSet.Clear(); + strikethroughMapSet.Insert("enable", true); + strikethroughMapSet.Insert("color", Color::TRANSPARENT); + strikethroughMapSet.Insert("height", 2.0f); + + label.SetProperty(DevelTextLabel::Property::STRIKETHROUGH, strikethroughMapSet); + + application.SendNotification(); + application.Render(); + + strikethroughMapGet = label.GetProperty(DevelTextLabel::Property::STRIKETHROUGH); + DALI_TEST_EQUALS(strikethroughMapGet.Count(), strikethroughMapSet.Count(), TEST_LOCATION); + DALI_TEST_EQUALS(DaliTestCheckMaps(strikethroughMapGet, strikethroughMapSet), true, TEST_LOCATION); + strikethroughMapSet.Clear(); strikethroughMapSet.Insert(Toolkit::DevelText::Strikethrough::Property::ENABLE, true); strikethroughMapSet.Insert(Toolkit::DevelText::Strikethrough::Property::COLOR, Color::RED); @@ -803,6 +836,24 @@ int UtcDaliToolkitTextLabelSetPropertyP(void) DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION); DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION); + // Check the transparent double underline property for coverage. + underlineMapSet.Clear(); + underlineMapSet.Insert("enable", true); + underlineMapSet.Insert("color", Color::TRANSPARENT); + underlineMapSet.Insert("height", 1); + underlineMapSet.Insert("type", Text::Underline::DOUBLE); + underlineMapSet.Insert("dashWidth", 2); + underlineMapSet.Insert("dashGap", 1); + + label.SetProperty(TextLabel::Property::UNDERLINE, underlineMapSet); + + application.SendNotification(); + application.Render(); + + underlineMapGet = label.GetProperty(TextLabel::Property::UNDERLINE); + DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION); + DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION); + underlineMapSet.Clear(); underlineMapSet.Insert(Toolkit::DevelText::Underline::Property::ENABLE, true); underlineMapSet.Insert(Toolkit::DevelText::Underline::Property::COLOR, Color::GREEN); @@ -903,6 +954,8 @@ int UtcDaliToolkitTextLabelSetPropertyP(void) outlineMapSet["color"] = Color::RED; outlineMapSet["width"] = 2.0f; + outlineMapSet["offset"] = Vector2(2.0f, 2.0f); + outlineMapSet["blurRadius"] = 3.0f; label.SetProperty(TextLabel::Property::OUTLINE, outlineMapSet); outlineMapGet = label.GetProperty(TextLabel::Property::OUTLINE); @@ -912,11 +965,14 @@ int UtcDaliToolkitTextLabelSetPropertyP(void) outlineMapSet.Clear(); outlineMapSet[Toolkit::DevelText::Outline::Property::COLOR] = Color::BLUE; outlineMapSet[Toolkit::DevelText::Outline::Property::WIDTH] = 3.0f; + outlineMapSet[Toolkit::DevelText::Outline::Property::OFFSET] = Vector2(3.0f, 3.0f); + outlineMapSet[Toolkit::DevelText::Outline::Property::BLUR_RADIUS] = 4.0f; + label.SetProperty(TextLabel::Property::OUTLINE, outlineMapSet); outlineMapGet = label.GetProperty(TextLabel::Property::OUTLINE); DALI_TEST_EQUALS(outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION); - std::vector outlineIndicesConversionTable = {"color", "width"}; + std::vector outlineIndicesConversionTable = {"color", "width", "offset", "blurRadius"}; DALI_TEST_EQUALS(DaliTestCheckMaps(outlineMapGet, outlineMapSet, outlineIndicesConversionTable), true, TEST_LOCATION); // Check the background property @@ -931,6 +987,19 @@ int UtcDaliToolkitTextLabelSetPropertyP(void) DALI_TEST_EQUALS(backgroundMapGet.Count(), backgroundMapSet.Count(), TEST_LOCATION); DALI_TEST_EQUALS(DaliTestCheckMaps(backgroundMapGet, backgroundMapSet), true, TEST_LOCATION); + // Check the transparent background property for coverage + backgroundMapSet.Clear(); + backgroundMapSet["enable"] = true; + backgroundMapSet["color"] = Color::TRANSPARENT; + label.SetProperty(DevelTextLabel::Property::BACKGROUND, backgroundMapSet); + + application.SendNotification(); + application.Render(); + + backgroundMapGet = label.GetProperty(DevelTextLabel::Property::BACKGROUND); + DALI_TEST_EQUALS(backgroundMapGet.Count(), backgroundMapSet.Count(), TEST_LOCATION); + DALI_TEST_EQUALS(DaliTestCheckMaps(backgroundMapGet, backgroundMapSet), true, TEST_LOCATION); + backgroundMapSet.Clear(); backgroundMapSet[Toolkit::DevelText::Background::Property::ENABLE] = true; backgroundMapSet[Toolkit::DevelText::Background::Property::COLOR] = Color::GREEN; @@ -962,6 +1031,26 @@ int UtcDaliToolkitTextLabelSetPropertyP(void) application.SendNotification(); application.Render(); + // Check Remove Front/Back Inset Property + DALI_TEST_CHECK(label.GetProperty(DevelTextLabel::Property::REMOVE_FRONT_INSET)); + label.SetProperty(DevelTextLabel::Property::REMOVE_FRONT_INSET, false); + DALI_TEST_CHECK(!label.GetProperty(DevelTextLabel::Property::REMOVE_FRONT_INSET)); + + DALI_TEST_CHECK(label.GetProperty(DevelTextLabel::Property::REMOVE_BACK_INSET)); + label.SetProperty(DevelTextLabel::Property::REMOVE_BACK_INSET, false); + DALI_TEST_CHECK(!label.GetProperty(DevelTextLabel::Property::REMOVE_BACK_INSET)); + + application.SendNotification(); + application.Render(); + + // Check cutout Property + DALI_TEST_CHECK(!label.GetProperty(DevelTextLabel::Property::CUTOUT)); + label.SetProperty(DevelTextLabel::Property::CUTOUT, true); + DALI_TEST_CHECK(label.GetProperty(DevelTextLabel::Property::CUTOUT)); + + application.SendNotification(); + application.Render(); + END_TEST; } @@ -1094,27 +1183,33 @@ int UtcDaliToolkitTextLabelEmojisP(void) // EMOJI Sequences case for coverage. std::string emojiSequences = + "Glyphs not included in the font \n" //case for coverage when glyph is not included in the font "Text VS15 ☪︎\n" //text presentation sequence and selector "Color VS16 ☪️\n" //emoji presentation sequence and selector "Default ☪ \n" //default presentation "FamilyManWomanGirlBoy 👨‍👩‍👧‍👦\n" // emoji multi zwj sequence "WomanScientist 👩‍🔬\n" // emoji zwj sequence - "WomanScientistLightSkinTone👩🏻‍🔬 \n" //emoji modifier sequence: skin tone & JWZ - "LeftRightArrowText↔︎\n" //text presentation sequence and selector - "LeftRightArrowEmoji↔️\n" //emoji presentation sequence and selector - "SouthKoreaFlag🇰🇷\n" //emoji flag sequence + "WomanScientistLightSkinTone👩🏻‍🔬 \n" // emoji modifier sequence: skin tone & JWZ + "LeftRightArrowText↔︎\n" // text presentation sequence and selector + "LeftRightArrowEmoji↔️\n" // emoji presentation sequence and selector + "SouthKoreaFlag🇰🇷\n" // emoji flag sequence "JordanFlag🇯🇴\n" // emoji flag sequence - "EnglandFlag🏴󠁧󠁢󠁥󠁮󠁧󠁿\n" //emoji tag sequence like England flag + "EnglandFlag🏴󠁧󠁢󠁥󠁮󠁧󠁿\n" // emoji tag sequence like England flag "Runner 🏃‍➡️ \n" - "VictoryHandMediumLightSkinTone:✌️🏼\n" //emoji modifier sequence: skin tone - "RainbowFlag:🏳️‍🌈 \n" //emoji zwj sequence: Rainbow Flag - "keycap# #️⃣ \n" // fully-qualified emoji keycap sequence - "keycap#_text #⃣ \n" // unqualified emoji keycap sequence - "keycap3 3️⃣ \n" // fully-qualified emoji keycap sequence - "keycap3_text 3⃣ \n" // unqualified emoji keycap sequence - "two adjacent glyphs ☪️️️☪️\n" //This line should be rendered as two adjacent glyphs - "Digit 8️ 8︎ 8\n" // should be rendered according to selector - "Surfing Medium Skin Female: 🏄🏼‍♀️"; // Person Surfing + Medium Skin Tone +? Zero Width Joiner + Female Sign + "VictoryHandMediumLightSkinTone:✌️🏼\n" // emoji modifier sequence: skin tone + "RainbowFlag:🏳️‍🌈 \n" // emoji zwj sequence: Rainbow Flag + "keycap# #️⃣ \n" // fully-qualified emoji keycap sequence + "keycap#_text #⃣ \n" // unqualified emoji keycap sequence + "keycap3 3️⃣ \n" // fully-qualified emoji keycap sequence + "keycap3_text 3⃣ \n" // unqualified emoji keycap sequence + "two adjacent glyphs ☪️️️☪️\n" // This line should be rendered as two adjacent glyphs + "Digit 8️ 8︎ 8\n" // should be rendered according to selector + "Surfing Medium Skin Female: 🏄🏼‍♀️\n" // Person Surfing + Medium Skin Tone +? Zero Width Joiner + Female Sign + "SYMBOLS_NSLCL variation selector: 🅰️🅱️🅲︎🅳︎🅴︎\n" // 1F170 ~ 1F174 with variation selector, text vs emoji + "SYMBOLS_NSLCL with VS15: 🅰︎🅱︎🅲︎🅳︎🅴︎\n" // 1F170 ~ 1F174 with VS15 + "SYMBOLS_NSLCL with VS16: 🅰️🅱️🅲️🅳️🅴️\n" // 1F170 ~ 1F174 with VS16 + + ; label.SetProperty(TextLabel::Property::TEXT, emojiSequences); label.SetProperty(TextLabel::Property::ENABLE_MARKUP, true); @@ -1456,6 +1551,44 @@ int UtcDaliToolkitTextlabelScrollingN(void) const bool enabled = label.GetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL).Get(); DALI_TEST_CHECK(!enabled); + label.SetProperty(TextLabel::Property::MULTI_LINE, false); + label.SetProperty(TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 1); + label.SetProperty(TextLabel::Property::AUTO_SCROLL_SPEED, 9999.0f); + label.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, true); + + try + { + // Render the text. + application.SendNotification(); + application.Render(1000); + + application.GetScene().Remove(label); + application.SendNotification(); + application.Render(); + + DALI_TEST_CHECK(!label.GetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL).Get()); + + label.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, true); + application.GetScene().Add(label); + + application.SendNotification(); + application.Render(); + + DALI_TEST_CHECK(label.GetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL).Get()); + + label.SetProperty(TextLabel::Property::AUTO_SCROLL_STOP_MODE, (Toolkit::TextLabel::AutoScrollStopMode::Type)2); // invalid type + label.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, false); + + application.SendNotification(); + application.Render(); + + DALI_TEST_CHECK(label.GetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL).Get()); + } + catch(...) + { + tet_result(TET_FAIL); + } + END_TEST; } @@ -1671,6 +1804,16 @@ int UtcDaliToolkitTextLabelColorComponents(void) DALI_TEST_EQUALS(drawTrace.FindMethod("DrawArrays"), false, TEST_LOCATION); // Rendering should be skipped + label.SetProperty(DevelTextLabel::Property::CUTOUT, true); + + drawTrace.Reset(); + + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS(drawTrace.FindMethod("DrawArrays"), true, TEST_LOCATION); // When cutout is enabled, should not be skipped + + label.SetProperty(DevelTextLabel::Property::CUTOUT, false); label.SetProperty(TextLabel::Property::TEXT_COLOR, Color::RED); drawTrace.Reset(); @@ -1699,6 +1842,8 @@ int UtcDaliToolkitTextlabelTextStyle01(void) outlineMapSet["color"] = Color::BLUE; outlineMapSet["width"] = 2.0f; + outlineMapSet["offset"] = "2 2"; + outlineMapSet["blurRadius"] = "3"; label.SetProperty(TextLabel::Property::OUTLINE, outlineMapSet); application.SendNotification(); @@ -1923,7 +2068,7 @@ int UtcDaliToolkitTextlabelTextFit(void) application.SendNotification(); application.Render(); - const Vector3 EXPECTED_NATURAL_SIZE(450.0f, 96.0f, 0.0f); + const Vector3 EXPECTED_NATURAL_SIZE(448.0f, 96.0f, 0.0f); DALI_TEST_EQUALS(EXPECTED_NATURAL_SIZE, label.GetNaturalSize(), TEST_LOCATION); DALI_TEST_CHECK(gTextFitChangedCallBackCalled); @@ -1947,6 +2092,197 @@ int UtcDaliToolkitTextlabelTextFit(void) END_TEST; } +int UtcDaliToolkitTextlabelTextFitStressTest(void) +{ + ToolkitTestApplication application; + tet_infoline(" UtcDaliToolkitTextlabelTextFitStressTest"); + TextLabel label = TextLabel::New(); + Vector2 size(460.0f, 100.0f); + label.SetProperty(Actor::Property::SIZE, size); + label.SetProperty(TextLabel::Property::TEXT, "Hello world"); + + // connect to the text git changed signal. + ConnectionTracker* testTracker = new ConnectionTracker(); + DevelTextLabel::TextFitChangedSignal(label).Connect(&TestTextFitChangedCallback); + bool textFitChangedSignal = false; + label.ConnectSignal(testTracker, "textFitChanged", CallbackFunctor(&textFitChangedSignal)); + gTextFitChangedCallBackCalled = false; + + // check point size with veryvery big range + Property::Map textFitMapSet; + textFitMapSet["enable"] = true; + textFitMapSet["minSize"] = 10.f; + textFitMapSet["maxSize"] = 10000.f; + textFitMapSet["stepSize"] = -1.0f; + textFitMapSet["fontSizeType"] = "pointSize"; + + label.SetProperty(Toolkit::DevelTextLabel::Property::TEXT_FIT, textFitMapSet); + label.SetProperty(TextLabel::Property::POINT_SIZE, 120.f); + + application.GetScene().Add(label); + + application.SendNotification(); + application.Render(); + + const Vector3 EXPECTED_NATURAL_SIZE(448.0f, 96.0f, 0.0f); + DALI_TEST_EQUALS(EXPECTED_NATURAL_SIZE, label.GetNaturalSize(), TEST_LOCATION); + + DALI_TEST_CHECK(gTextFitChangedCallBackCalled); + DALI_TEST_CHECK(textFitChangedSignal); + + END_TEST; +} + +int UtcDaliToolkitTextlabelFastTextFitStressTest(void) +{ + ToolkitTestApplication application; + tet_infoline(" UtcDaliToolkitTextlabelFastTextFitStressTest"); + TextLabel label = TextLabel::New(); + label.SetProperty(TextLabel::Property::TEXT, "Hello world"); + label.SetProperty(TextLabel::Property::POINT_SIZE, 120.f); + + // connect to the text git changed signal. + ConnectionTracker* testTracker = new ConnectionTracker(); + DevelTextLabel::TextFitChangedSignal(label).Connect(&TestTextFitChangedCallback); + bool textFitChangedSignal = false; + label.ConnectSignal(testTracker, "textFitChanged", CallbackFunctor(&textFitChangedSignal)); + gTextFitChangedCallBackCalled = false; + + application.GetScene().Add(label); + + // check text label width at range [100, 299] + for(int i=100; i<300; i++) + { + Vector2 size((float)i, 200.f); + label.SetProperty(Actor::Property::SIZE, size); + + // check point size with veryvery big range + Property::Map textFitMapSet; + textFitMapSet["enable"] = true; + textFitMapSet["minSize"] = 10.f; + textFitMapSet["maxSize"] = 10000.f; + textFitMapSet["stepSize"] = -1.0f; + textFitMapSet["fontSizeType"] = "pointSize"; + + label.SetProperty(Toolkit::DevelTextLabel::Property::TEXT_FIT, textFitMapSet); + + application.SendNotification(); + application.Render(); + } + + DALI_TEST_CHECK(gTextFitChangedCallBackCalled); + DALI_TEST_CHECK(textFitChangedSignal); + + END_TEST; +} + +int UtcDaliToolkitTextlabelTextFitMultiLine(void) +{ + ToolkitTestApplication application; + tet_infoline(" UtcDaliToolkitTextlabelTextFitMultiLine"); + TextLabel label = TextLabel::New(); + Vector2 size(500.0f, 100.0f); + label.SetProperty(Actor::Property::SIZE, size); + label.SetProperty(TextLabel::Property::TEXT, "Hello world\nHello world"); + label.SetProperty(TextLabel::Property::MULTI_LINE, true); + + // connect to the text git changed signal. + ConnectionTracker* testTracker = new ConnectionTracker(); + DevelTextLabel::TextFitChangedSignal(label).Connect(&TestTextFitChangedCallback); + bool textFitChangedSignal = false; + label.ConnectSignal(testTracker, "textFitChanged", CallbackFunctor(&textFitChangedSignal)); + gTextFitChangedCallBackCalled = false; + + Property::Map textFitMapSet; + textFitMapSet["enable"] = true; + textFitMapSet["minSize"] = 10.f; + textFitMapSet["maxSize"] = 100.f; + textFitMapSet["stepSize"] = -1.0f; + textFitMapSet["fontSizeType"] = "pointSize"; + + label.SetProperty(Toolkit::DevelTextLabel::Property::TEXT_FIT, textFitMapSet); + label.SetProperty(TextLabel::Property::POINT_SIZE, 120.f); + + application.GetScene().Add(label); + + application.SendNotification(); + application.Render(); + + float textFitFontSize = (label.GetProperty(Dali::Toolkit::DevelTextLabel::Property::TEXT_FIT).Get())["fontSize"].Get(); + DALI_TEST_EQUALS(textFitFontSize, 14.f, TEST_LOCATION); + + DALI_TEST_CHECK(gTextFitChangedCallBackCalled); + DALI_TEST_CHECK(textFitChangedSignal); + + END_TEST; +} + +int UtcDaliToolkitTextlabelTextFitArray(void) +{ + ToolkitTestApplication application; + tet_infoline(" UtcDaliToolkitTextlabelTextFitArray"); + TextLabel label = TextLabel::New(); + Vector2 size(300.0f, 80.0f); + label.SetProperty(Actor::Property::SIZE, size); + label.SetProperty(TextLabel::Property::TEXT, "A Quick Brown Fox Jumps Over The Lazy Dog"); + label.SetProperty(DevelTextLabel::Property::MIN_LINE_SIZE, 80.f); + label.SetProperty(TextLabel::Property::POINT_SIZE, 10.f); + application.GetScene().Add(label); + + // make sorted options. + std::vector fitOptions; + fitOptions.push_back(DevelTextLabel::FitOption(10, 12)); + fitOptions.push_back(DevelTextLabel::FitOption(8, 10)); + fitOptions.push_back(DevelTextLabel::FitOption(6, 8)); + fitOptions.push_back(DevelTextLabel::FitOption(4, 6)); + fitOptions.push_back(DevelTextLabel::FitOption(20, 22)); + fitOptions.push_back(DevelTextLabel::FitOption(22, 24)); + fitOptions.push_back(DevelTextLabel::FitOption(12, 14)); + + DevelTextLabel::SetTextFitArray(label, true, fitOptions); + + application.SendNotification(); + application.Render(); + + bool enable = Dali::Toolkit::DevelTextLabel::IsTextFitArrayEnabled(label); + DALI_TEST_EQUALS(true, enable, TEST_LOCATION); + + std::vector getFitOptions = Dali::Toolkit::DevelTextLabel::GetTextFitArray(label); + size_t numberOfFitOptions = getFitOptions.size(); + DALI_TEST_EQUALS(7u, numberOfFitOptions, TEST_LOCATION); + + const Vector3 EXPECTED_NATURAL_SIZE(276.0f, 16.0f, 0.0f); + DALI_TEST_EQUALS(EXPECTED_NATURAL_SIZE, label.GetNaturalSize(), TEST_LOCATION); + + std::vector emptyFitOptions; + DevelTextLabel::SetTextFitArray(label, false, emptyFitOptions); + + application.SendNotification(); + application.Render(); + + enable = Dali::Toolkit::DevelTextLabel::IsTextFitArrayEnabled(label); + DALI_TEST_EQUALS(false, enable, TEST_LOCATION); + + const Vector3 EXPECTED_NATURAL_SIZE_DISABLE(690.0f, 80.0f, 0.0f); + DALI_TEST_EQUALS(EXPECTED_NATURAL_SIZE_DISABLE, label.GetNaturalSize(), TEST_LOCATION); + + // make unsorted options. + std::vector unorderedFitOptions; + unorderedFitOptions.push_back(DevelTextLabel::FitOption(4, 6)); + unorderedFitOptions.push_back(DevelTextLabel::FitOption(6, 8)); + unorderedFitOptions.push_back(DevelTextLabel::FitOption(8, 10)); + unorderedFitOptions.push_back(DevelTextLabel::FitOption(10, 8)); + + DevelTextLabel::SetTextFitArray(label, true, unorderedFitOptions); + + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS(EXPECTED_NATURAL_SIZE, label.GetNaturalSize(), TEST_LOCATION); + + END_TEST; +} + int UtcDaliToolkitTextlabelMaxTextureSet(void) { ToolkitTestApplication application; @@ -2041,6 +2377,12 @@ int UtcDaliToolkitTextlabelMaxTextureSet(void) // Check if the number of renderers is greater than 1. DALI_TEST_CHECK(label.GetRendererCount() > 1u); + // Coverage test for case of layoutSize is bigger than maxTextureSize + float max_value = static_cast(std::numeric_limits::max()); + label.SetProperty(Actor::Property::SIZE, Vector2(max_value, 30.0f)); + application.SendNotification(); + application.Render(); + END_TEST; } @@ -2237,6 +2579,56 @@ int UtcDaliToolkitTextlabelFontSizeScale(void) END_TEST; } +int UtcDaliToolkitTextlabelAnchorColor(void) +{ + ToolkitTestApplication application; + tet_infoline(" UtcDaliToolkitTextlabelAnchorColor"); + TextLabel label = TextLabel::New(); + DALI_TEST_CHECK(label); + + application.GetScene().Add(label); + + // connect to the anchor clicked signal. + ConnectionTracker* testTracker = new ConnectionTracker(); + DevelTextLabel::AnchorClickedSignal(label).Connect(&TestAnchorClickedCallback); + bool anchorClickedSignal = false; + label.ConnectSignal(testTracker, "anchorClicked", CallbackFunctor(&anchorClickedSignal)); + + gAnchorClickedCallBackCalled = false; + label.SetProperty(TextLabel::Property::TEXT, "TIZEN"); + label.SetProperty(TextLabel::Property::ENABLE_MARKUP, true); + label.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f)); + label.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT); + label.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT); + + // Check that anchor color can be properly set + label.SetProperty(DevelTextLabel::Property::ANCHOR_COLOR, Color::BLUE); + DALI_TEST_EQUALS(label.GetProperty(DevelTextLabel::Property::ANCHOR_COLOR), Color::BLUE, TEST_LOCATION); + + label.SetProperty(DevelTextLabel::Property::ANCHOR_CLICKED_COLOR, Color::RED); + DALI_TEST_EQUALS(label.GetProperty(DevelTextLabel::Property::ANCHOR_CLICKED_COLOR), Color::RED, TEST_LOCATION); + + application.SendNotification(); + application.Render(); + + // Create a tap event to touch the text label. + TestGenerateTap(application, 5.0f, 25.0f, 100); + application.SendNotification(); + application.Render(); + + // Update clicked color + label.SetProperty(DevelTextLabel::Property::ANCHOR_CLICKED_COLOR, Color::BLUE); + DALI_TEST_EQUALS(label.GetProperty(DevelTextLabel::Property::ANCHOR_CLICKED_COLOR), Color::BLUE, TEST_LOCATION); + + application.SendNotification(); + application.Render(); + + DALI_TEST_CHECK(gAnchorClickedCallBackCalled); + DALI_TEST_CHECK(anchorClickedSignal); + + END_TEST; +} + // Positive test for the anchorClicked signal. int UtcDaliToolkitTextlabelAnchorClicked(void) { @@ -2282,7 +2674,7 @@ int UtcDaliToolkitTextlabelAnchorClicked(void) // sets anchor text label.SetProperty(TextLabel::Property::ENABLE_MARKUP, true); - label.SetProperty(TextLabel::Property::TEXT, "TIZEN"); + label.SetProperty(TextLabel::Property::TEXT, "TIZEN"); label.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f)); label.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT); label.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT); @@ -2450,7 +2842,6 @@ int utcDaliTextLabelGeometryRTL(void) label.SetProperty(TextLabel::Property::ENABLE_MARKUP, true); label.SetProperty(TextLabel::Property::MULTI_LINE, true); label.SetProperty(TextLabel::Property::TEXT, "line1 \nline2\nline 3\nالاخيرالسطر"); - // Avoid a crash when core load gl resources. application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE); @@ -2471,16 +2862,16 @@ int utcDaliTextLabelGeometryRTL(void) Vector expectedSizes; Vector expectedPositions; - expectedPositions.PushBack(Vector2(24, 0)); - expectedSizes.PushBack(Vector2(33, 25)); + expectedPositions.PushBack(Vector2(25, 0)); + expectedSizes.PushBack(Vector2(34, 25)); expectedPositions.PushBack(Vector2(-1, 25)); - expectedSizes.PushBack(Vector2(52, 25)); + expectedSizes.PushBack(Vector2(53, 25)); expectedPositions.PushBack(Vector2(-1, 50)); - expectedSizes.PushBack(Vector2(59, 25)); + expectedSizes.PushBack(Vector2(60, 25)); - expectedPositions.PushBack(Vector2(73, 75)); + expectedPositions.PushBack(Vector2(75, 75)); expectedSizes.PushBack(Vector2(37, 25)); TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes); @@ -2526,7 +2917,7 @@ int utcDaliTextLabelGeometryGlyphMiddle(void) Vector expectedPositions; expectedPositions.PushBack(Vector2(6, 0)); - expectedSizes.PushBack(Vector2(124, 25)); + expectedSizes.PushBack(Vector2(125, 25)); TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes); @@ -2575,6 +2966,54 @@ int utcDaliTextLabelGeometryOneGlyph(void) TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes); + positionsList.Clear(); + sizeList.Clear(); + + startIndex = 2; + endIndex = 0; + + positionsList = DevelTextLabel::GetTextPosition(label, startIndex, endIndex); + sizeList = DevelTextLabel::GetTextSize(label, startIndex, endIndex); + + TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes); + + END_TEST; +} + +int utcDaliTextLabelGeometryNullPtr(void) +{ + ToolkitTestApplication application; + tet_infoline("utcDaliTextLabelGeometryNullPtr"); + + TextLabel label = TextLabel::New(); + DALI_TEST_CHECK(label); + + application.GetScene().Add(label); + + label.SetProperty(TextLabel::Property::POINT_SIZE, 7.f); + label.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f)); + label.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT); + label.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT); + label.SetProperty(TextLabel::Property::ENABLE_MARKUP, true); + label.SetProperty(TextLabel::Property::TEXT, ""); + + // Avoid a crash when core load gl resources. + application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE); + + unsigned int expectedCount = 0; + unsigned int startIndex = 0; + unsigned int endIndex = 0; + + Vector positionsList = DevelTextLabel::GetTextPosition(label, startIndex, endIndex); + Vector sizeList = DevelTextLabel::GetTextSize(label, startIndex, endIndex); + + // Render and notify + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION); + DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION); + END_TEST; } @@ -2894,4 +3333,74 @@ int UtcDaliToolkitTextlabelParagraphTag(void) application.Render(); END_TEST; +} + +int utcDaliTextLabelGetTextBoundingRectangle(void) +{ + ToolkitTestApplication application; + tet_infoline(" utcDaliTextLabelGeometryEllipsisMiddle"); + + TextLabel label = TextLabel::New(); + DALI_TEST_CHECK(label); + + application.GetScene().Add(label); + + label.SetProperty(TextLabel::Property::POINT_SIZE, 7.f); + label.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f)); + label.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT); + label.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT); + label.SetProperty(TextLabel::Property::TEXT, "Hello this is the Text Bounding Rectangle TC"); + + // Avoid a crash when core load gl resources. + application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE); + + // Render and notify + application.SendNotification(); + application.Render(); + + unsigned int startIndex = 0; + unsigned int endIndex = 15; + + Rect<> textBoundingRectangle = DevelTextLabel::GetTextBoundingRectangle(label, startIndex, endIndex); + Rect<> expectedTextBoundingRectangle = {0, 0, 100, 25}; + + TestTextGeometryUtils::CheckRectGeometryResult(textBoundingRectangle, expectedTextBoundingRectangle); + + END_TEST; +} + +int utcDaliTextLabelRemoveFrontInset(void) +{ + ToolkitTestApplication application; + tet_infoline(" utcDaliTextLabelRemoveFrontInset"); + + TextLabel label = TextLabel::New(); + DALI_TEST_CHECK(label); + + application.GetScene().Add(label); + application.SendNotification(); + application.Render(); + + DevelTextLabel::SetRemoveFrontInset(label, false); + DALI_TEST_CHECK(!DevelTextLabel::IsRemoveFrontInset(label)); + + END_TEST; +} + +int utcDaliTextLabelRemoveBackInset(void) +{ + ToolkitTestApplication application; + tet_infoline(" utcDaliTextLabelRemoveBackInset"); + + TextLabel label = TextLabel::New(); + DALI_TEST_CHECK(label); + + application.GetScene().Add(label); + application.SendNotification(); + application.Render(); + + DevelTextLabel::SetRemoveBackInset(label, false); + DALI_TEST_CHECK(!DevelTextLabel::IsRemoveBackInset(label)); + + END_TEST; } \ No newline at end of file