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=c810939e8f9738b71f57d722ad9777ad00a0b835;hp=95d0689a72a14447fd1be482de788ce1567101d5;hb=cd5b6f3ff9138207df66d93e95a750fa9f56c70b;hpb=895806b4ad86de88dcc731aeb8e3dbe453ce4202 diff --git a/automated-tests/src/dali-toolkit/utc-Dali-TextLabel.cpp b/automated-tests/src/dali-toolkit/utc-Dali-TextLabel.cpp index 95d0689..c810939 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-TextLabel.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-TextLabel.cpp @@ -2525,8 +2525,53 @@ int utcDaliTextLabelGeometryGlyphMiddle(void) Vector expectedSizes; Vector expectedPositions; - expectedPositions.PushBack(Vector2(12, 0)); - expectedSizes.PushBack(Vector2(118, 25)); + expectedPositions.PushBack(Vector2(6, 0)); + expectedSizes.PushBack(Vector2(124, 25)); + + TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes); + + END_TEST; +} + +int utcDaliTextLabelGeometryOneGlyph(void) +{ + ToolkitTestApplication application; + tet_infoline(" utcDaliTextLabelGeometryOneGlyph "); + + 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, "H"); + + // Avoid a crash when core load gl resources. + application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE); + + // Render and notify + application.SendNotification(); + application.Render(); + + unsigned int expectedCount = 1; + unsigned int startIndex = 0; + unsigned int endIndex = 0; + + Vector positionsList = DevelTextLabel::GetTextPosition(label, startIndex, endIndex); + Vector sizeList = DevelTextLabel::GetTextSize(label, startIndex, endIndex); + + DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION); + DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION); + + Vector expectedSizes; + Vector expectedPositions; + + expectedPositions.PushBack(Vector2(-2, 0)); + expectedSizes.PushBack(Vector2(16, 25)); TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes); @@ -2632,6 +2677,94 @@ int UtcDaliToolkitTextLabelStrikethroughGeneration(void) END_TEST; } +int UtcDaliToolkitTextLabelMarkupRelativeLineHeight(void) +{ + ToolkitTestApplication application; + tet_infoline(" UtcDaliToolkitTextLabelMarkupRelativeLineHeight"); + + TextLabel label = TextLabel::New(); + label.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 300.f)); + label.SetProperty(TextLabel::Property::POINT_SIZE, 10); + label.SetProperty(TextLabel::Property::MULTI_LINE, true); + label.SetProperty(TextLabel::Property::TEXT, "line 1\nline 2\nline 3\nline 4\nline 5"); + label.SetProperty(DevelTextLabel::Property::RELATIVE_LINE_SIZE, 1.0f); + label.SetProperty(TextLabel::Property::ELLIPSIS, false); + label.SetProperty(TextLabel::Property::ENABLE_MARKUP, true); + + TextLabel labelSingleLineParagraph = TextLabel::New(); + labelSingleLineParagraph.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 300.f)); + labelSingleLineParagraph.SetProperty(TextLabel::Property::POINT_SIZE, 10); + labelSingleLineParagraph.SetProperty(TextLabel::Property::MULTI_LINE, true); + labelSingleLineParagraph.SetProperty(TextLabel::Property::TEXT, "

line 1

line 2

line 3

line 4

line 5"); + labelSingleLineParagraph.SetProperty(DevelTextLabel::Property::RELATIVE_LINE_SIZE, 1.0f); + labelSingleLineParagraph.SetProperty(TextLabel::Property::ELLIPSIS, false); + labelSingleLineParagraph.SetProperty(TextLabel::Property::ENABLE_MARKUP, true); + + TextLabel labelMultiLineParagraph = TextLabel::New(); + labelMultiLineParagraph.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 300.f)); + labelMultiLineParagraph.SetProperty(TextLabel::Property::POINT_SIZE, 10); + labelMultiLineParagraph.SetProperty(TextLabel::Property::MULTI_LINE, true); + labelMultiLineParagraph.SetProperty(TextLabel::Property::TEXT, "

line 1

line\n2

line 3

line\n4

line 5"); + labelMultiLineParagraph.SetProperty(DevelTextLabel::Property::RELATIVE_LINE_SIZE, 1.0f); + labelMultiLineParagraph.SetProperty(TextLabel::Property::ELLIPSIS, false); + labelMultiLineParagraph.SetProperty(TextLabel::Property::ENABLE_MARKUP, true); + + application.GetScene().Add(label); + application.GetScene().Add(labelSingleLineParagraph); + application.GetScene().Add(labelMultiLineParagraph); + application.SendNotification(); + application.Render(); + + Vector3 naturalSize = label.GetNaturalSize(); + Vector3 relativeSingleNaturalSize = labelSingleLineParagraph.GetNaturalSize(); + Vector3 relativeMultiNaturalSize = labelMultiLineParagraph.GetNaturalSize(); + + float lineSize = naturalSize.y / 5.0f; //total size/number of lines + + //no effect of relative line size for paragraph with single line + DALI_TEST_EQUALS(naturalSize.y, relativeSingleNaturalSize.y, Math::MACHINE_EPSILON_1000, TEST_LOCATION); + + DALI_TEST_EQUALS(lineSize * 8.5f, relativeMultiNaturalSize.y, Math::MACHINE_EPSILON_1000, TEST_LOCATION); + + END_TEST; +} + +int UtcDaliToolkitTextLabelRelativeLineHeight(void) +{ + ToolkitTestApplication application; + tet_infoline(" UtcDaliToolkitTextLabelRelativeLineHeight"); + + TextLabel label = TextLabel::New(); + label.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 300.f)); + label.SetProperty(TextLabel::Property::POINT_SIZE, 10); + label.SetProperty(TextLabel::Property::TEXT, "Hello\nWorld"); + + application.GetScene().Add(label); + application.SendNotification(); + application.Render(); + + Vector3 naturalSize = label.GetNaturalSize(); + + label.SetProperty(DevelTextLabel::Property::RELATIVE_LINE_SIZE, 0.5f); + + application.SendNotification(); + application.Render(); + + Vector3 relativeNaturalSize = label.GetNaturalSize(); + + DALI_TEST_EQUALS(naturalSize.y, relativeNaturalSize.y, TEST_LOCATION); + + label.SetProperty(DevelTextLabel::Property::RELATIVE_LINE_SIZE, 2.0f); + + application.SendNotification(); + application.Render(); + + relativeNaturalSize = label.GetNaturalSize(); + + DALI_TEST_EQUALS(naturalSize.y * 2, relativeNaturalSize.y, TEST_LOCATION); + END_TEST; +} + int UtcDaliTextLabelCharacterSpacing(void) { ToolkitTestApplication application; @@ -2653,4 +2786,112 @@ int UtcDaliTextLabelCharacterSpacing(void) application.Render(); END_TEST; +} + +int UtcDaliTextTextLabelSizeNegativeLineSpacing(void) +{ + ToolkitTestApplication application; + tet_infoline("UtcDaliTextTextLabelSizeNegativeLineSpacing"); + + TextLabel label = TextLabel::New(); + + float lineSpacing = -20.f; + + label.SetProperty(Actor::Property::SIZE, Vector2(450.0f, 300.f)); + label.SetProperty(TextLabel::Property::POINT_SIZE, 10.f); + label.SetProperty(DevelTextLabel::Property::LINE_SPACING, lineSpacing); + label.SetProperty(TextLabel::Property::MULTI_LINE, true); + label.SetProperty(TextLabel::Property::TEXT, "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."); + + application.GetScene().Add(label); + application.SendNotification(); + application.Render(); + + Vector positionsList = DevelTextLabel::GetTextPosition(label, 0, 123); + Vector sizeList = DevelTextLabel::GetTextSize(label, 0, 123); + + Vector2 lastLinePos = positionsList[positionsList.Size() - 1]; + Vector2 lastLineSize = sizeList[sizeList.Size() - 1]; + + DALI_TEST_EQUALS(sizeList[0].y * (sizeList.Size() - 1), lastLinePos.y, Math::MACHINE_EPSILON_1000, TEST_LOCATION); + DALI_TEST_EQUALS(sizeList[0].y - lineSpacing, lastLineSize.y, Math::MACHINE_EPSILON_1000, TEST_LOCATION); + + application.SendNotification(); + application.Render(); + + END_TEST; +} + +int UtcDaliTextLabelNegativeLineSpacingWithEllipsis(void) +{ + ToolkitTestApplication application; + tet_infoline("UtcDaliTextLabelNegativeLineSpacingWithEllipsis"); + + TextLabel label = TextLabel::New(); + + float lineSpacing = -20.f; + + label.SetProperty(Actor::Property::SIZE, Vector2(480.0f, 100.f)); + label.SetProperty(TextLabel::Property::POINT_SIZE, 11.0f); + label.SetProperty(DevelTextLabel::Property::LINE_SPACING, lineSpacing); + label.SetProperty(TextLabel::Property::MULTI_LINE, true); + label.SetProperty(TextLabel::Property::TEXT, "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."); + label.SetProperty(TextLabel::Property::ELLIPSIS, true); + + application.GetScene().Add(label); + application.SendNotification(); + application.Render(); + + Vector sizeList = DevelTextLabel::GetTextSize(label, 0, 123); + + int lineCount = sizeList.Size(); + DALI_TEST_EQUALS(4, lineCount, TEST_LOCATION); + + application.SendNotification(); + application.Render(); + + END_TEST; +} + +int UtcDaliToolkitTextlabelParagraphTag(void) +{ + ToolkitTestApplication application; + tet_infoline(" UtcDaliToolkitTextlabelParagraphTag"); + TextLabel labelNewlineSeparator = TextLabel::New(); + TextLabel labelParagraphTag = TextLabel::New(); + DALI_TEST_CHECK(labelNewlineSeparator); + DALI_TEST_CHECK(labelParagraphTag); + + application.GetScene().Add(labelNewlineSeparator); + application.GetScene().Add(labelParagraphTag); + + //Same utterance uses new-line to split paragraphs should give similar results for paragraph tag. + labelNewlineSeparator.SetProperty(TextLabel::Property::MULTI_LINE, true); + labelNewlineSeparator.SetProperty(TextLabel::Property::ELLIPSIS, false); + labelNewlineSeparator.SetProperty(TextLabel::Property::ENABLE_MARKUP, true); + labelNewlineSeparator.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f)); + labelNewlineSeparator.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT); + labelNewlineSeparator.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT); + labelNewlineSeparator.SetProperty(TextLabel::Property::TEXT, "test paragraph tag \ntest paragraph tag \ntest paragraph tag "); + + labelParagraphTag.SetProperty(TextLabel::Property::MULTI_LINE, true); + labelParagraphTag.SetProperty(TextLabel::Property::ELLIPSIS, false); + labelParagraphTag.SetProperty(TextLabel::Property::ENABLE_MARKUP, true); + labelParagraphTag.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f)); + labelParagraphTag.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT); + labelParagraphTag.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT); + labelParagraphTag.SetProperty(TextLabel::Property::TEXT, "test paragraph tag

test paragraph tag

test paragraph tag "); + + application.SendNotification(); + application.Render(); + + Vector3 textNaturalSizeNewlineSeparator = labelNewlineSeparator.GetNaturalSize(); + Vector3 textNaturalSizeParagraphTag = labelParagraphTag.GetNaturalSize(); + + DALI_TEST_EQUALS(textNaturalSizeNewlineSeparator, textNaturalSizeParagraphTag, TEST_LOCATION); + + application.SendNotification(); + application.Render(); + + END_TEST; } \ No newline at end of file