X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=automated-tests%2Fsrc%2Fdali-toolkit%2Futc-Dali-TextGeometry.cpp;h=13e8dee1ec50cff4ade3fcda9ad4aa1d13f37cee;hb=0dcf9f8788fc4b48e4b127edcb4a00990e5ff512;hp=34f8d1ec3e0aba111f9eb79d2d9ca5ee71ff0a46;hpb=4b79dd131ba61d94518e4ab89d41eaf634d305c6;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/automated-tests/src/dali-toolkit/utc-Dali-TextGeometry.cpp b/automated-tests/src/dali-toolkit/utc-Dali-TextGeometry.cpp index 34f8d1e..13e8dee 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-TextGeometry.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-TextGeometry.cpp @@ -70,7 +70,7 @@ int UtcDaliTextGeometryGetLineBoundingRectangleLabel(void) Rect<> lineGeometry = TextGeometry::GetLineBoundingRectangle(label, 1); - Rect<> expectedLineGeometry = {0, 16, 420, 16}; + Rect<> expectedLineGeometry = {0, 16, 418, 16}; TestTextGeometryUtils::CheckRectGeometryResult(lineGeometry, expectedLineGeometry); @@ -123,7 +123,7 @@ int UtcDaliTextGeometryGetLineBoundingRectangleField(void) Rect<> lineGeometry = TextGeometry::GetLineBoundingRectangle(field, 0); - Rect<> expectedLineGeometry = {0, 0, 163, 36}; + Rect<> expectedLineGeometry = {0, 0, 162, 36}; TestTextGeometryUtils::CheckRectGeometryResult(lineGeometry, expectedLineGeometry); @@ -179,7 +179,7 @@ int UtcDaliTextGeometryLineSpacingPositiveGetLineBoundingRectangleLabel(void) Rect<> lineGeometry = TextGeometry::GetLineBoundingRectangle(label, 1); - Rect<> expectedLineGeometry = {0, 56, 420, 56}; + Rect<> expectedLineGeometry = {0, 56, 418, 56}; TestTextGeometryUtils::CheckRectGeometryResult(lineGeometry, expectedLineGeometry); @@ -207,7 +207,7 @@ int UtcDaliTextGeometryWithVerticalLineAlignmentTopGetLineBoundingRectangleLabel Rect<> lineGeometry = TextGeometry::GetLineBoundingRectangle(label, 1); - Rect<> expectedLineGeometry = {0, 36, 420, 36}; + Rect<> expectedLineGeometry = {0, 36, 418, 36}; TestTextGeometryUtils::CheckRectGeometryResult(lineGeometry, expectedLineGeometry); @@ -235,7 +235,7 @@ int UtcDaliTextGeometryWithVerticalLineAlignmentBottomGetLineBoundingRectangleLa Rect<> lineGeometry = TextGeometry::GetLineBoundingRectangle(label, 1); - Rect<> expectedLineGeometry = {0, 36, 420, 36}; + Rect<> expectedLineGeometry = {0, 36, 418, 36}; TestTextGeometryUtils::CheckRectGeometryResult(lineGeometry, expectedLineGeometry); @@ -263,7 +263,7 @@ int UtcDaliTextGeometryWithEllipsisMiddleGetLineBoundingRectangleLabel(void) Rect<> lineGeometry = TextGeometry::GetLineBoundingRectangle(label, 1); - Rect<> expectedLineGeometry = {0, 36, 420, 36}; + Rect<> expectedLineGeometry = {0, 36, 418, 36}; TestTextGeometryUtils::CheckRectGeometryResult(lineGeometry, expectedLineGeometry); @@ -292,7 +292,7 @@ int UtcDaliTextGeometryWithEllipsisStartGetLineBoundingRectangleLabel(void) Rect<> lineGeometry = TextGeometry::GetLineBoundingRectangle(label, 1); - Rect<> expectedLineGeometry = {0, 36, 420, 36}; + Rect<> expectedLineGeometry = {0, 36, 418, 36}; TestTextGeometryUtils::CheckRectGeometryResult(lineGeometry, expectedLineGeometry); @@ -321,11 +321,366 @@ int UtcDaliTextGeometryWithEllipsisEndGetLineBoundingRectangleLabel(void) Rect<> lineGeometry = TextGeometry::GetLineBoundingRectangle(label, 1); - Rect<> expectedLineGeometry = {0, 36, 420, 36}; + Rect<> expectedLineGeometry = {0, 36, 418, 36}; TestTextGeometryUtils::CheckRectGeometryResult(lineGeometry, expectedLineGeometry); END_TEST; } +int UtcDaliTextGeometryGetCharacterBoundingRectangleLabel(void) +{ + ToolkitTestApplication application; + tet_infoline("UtcDaliTextGeometryGetCharacterBoundingRectangleLabel"); + + TextLabel label = TextLabel::New(); + DALI_TEST_CHECK(label); + + application.GetScene().Add(label); + + 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, \n consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."); + + application.SendNotification(); + application.Render(); + + Rect<> characterGeometry = TextGeometry::GetCharacterBoundingRectangle(label, 1); + + std::cout << " characterGeometry "<< characterGeometry < expectedCharacterGeometry = {13.0f, 16.0f, 19.0f, 16.0f}; + std::cout<< " expectedCharacterGeometry " << characterGeometry < characterGeometry = TextGeometry::GetCharacterBoundingRectangle(editor, 1); + + Rect<> expectedCharacterGeometry = {13.0f, 16.0f, 19.0f, 16.0f}; + + TestTextGeometryUtils::CheckRectGeometryResult(characterGeometry, expectedCharacterGeometry); + + END_TEST; +} + +int UtcDaliTextGeometryGetCharacterBoundingRectangleField(void) +{ + ToolkitTestApplication application; + tet_infoline("UtcDaliTextGeometryGetCharacterBoundingRectangleField"); + + TextField field = TextField::New(); + DALI_TEST_CHECK(field); + + application.GetScene().Add(field); + + field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER); + field.SetProperty(Actor::Property::SIZE, Vector2(450.0f, 350.f)); + field.SetProperty(TextField::Property::POINT_SIZE, 10.f); + field.SetProperty(TextField::Property::TEXT, "مرحبا بالعالم"); + + application.SendNotification(); + application.Render(); + + Rect<> characterGeometry = TextGeometry::GetCharacterBoundingRectangle(field, 0); + + Rect<> expectedCharacterGeometry = {142.0f, 10.0f, 16.0f, 11.0f}; + + TestTextGeometryUtils::CheckRectGeometryResult(characterGeometry, expectedCharacterGeometry); + + END_TEST; +} +// char tc + +int UtcDaliTextGeometryEmptyTextGetCharacterBoundingRectangleLabel(void) +{ + ToolkitTestApplication application; + tet_infoline("UtcDaliTextGeometryEmptyTextGetCharacterBoundingRectangleLabel"); + TextLabel label = TextLabel::New(); + DALI_TEST_CHECK(label); + + application.GetScene().Add(label); + + label.SetProperty(Actor::Property::SIZE, Vector2(450.0f, 300.f)); + label.SetProperty(TextLabel::Property::POINT_SIZE, 10.f); + label.SetProperty(TextLabel::Property::TEXT, ""); + + application.SendNotification(); + application.Render(); + + Rect<> charGeometry = TextGeometry::GetCharacterBoundingRectangle(label, 0); + + Rect<> expectedCharGeometry = {0.0f, 0.0f, 0.0f, 0.0f}; + + TestTextGeometryUtils::CheckRectGeometryResult(charGeometry, expectedCharGeometry); + + END_TEST; +} + +int UtcDaliTextGeometryLineSpacingPositiveGetCharacterBoundingRectangleLabel(void) +{ + ToolkitTestApplication application; + tet_infoline("UtcDaliTextGeometryLineSpacingPositiveGetCharacterBoundingRectangleLabel"); + + TextLabel label = TextLabel::New(); + DALI_TEST_CHECK(label); + + application.GetScene().Add(label); + + 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, \n consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."); + + application.SendNotification(); + application.Render(); + + Rect<> charGeometry = TextGeometry::GetCharacterBoundingRectangle(label, 1); + + Rect<> expectedCharGeometry = {13.0f, 16.0f, 19.0f, 16.0f}; + + TestTextGeometryUtils::CheckRectGeometryResult(charGeometry, expectedCharGeometry); + + END_TEST; +} + +int UtcDaliTextGeometryWithVerticalLineAlignmentTopGetCharacterBoundingRectangleLabel(void) +{ + ToolkitTestApplication application; + tet_infoline("UtcDaliTextGeometryWithVerticalLineAlignmentTopGetCharacterBoundingRectangleLabel"); + + TextLabel label = TextLabel::New(); + DALI_TEST_CHECK(label); + + application.GetScene().Add(label); + + label.SetProperty(Actor::Property::SIZE, Vector2(450.0f, 300.f)); + label.SetProperty(TextLabel::Property::POINT_SIZE, 10.f); + label.SetProperty(TextLabel::Property::MULTI_LINE, true); + label.SetProperty(Toolkit::TextLabel::Property::VERTICAL_ALIGNMENT, "TOP"); + label.SetProperty(TextLabel::Property::TEXT, "Lorem ipsum dolor sit amet, \n consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."); + + application.SendNotification(); + application.Render(); + + Rect<> charGeometry = TextGeometry::GetCharacterBoundingRectangle(label, 1); + + Rect<> expectedCharGeometry = {13.0, 16.0f, 19.0f, 16.0f}; + + TestTextGeometryUtils::CheckRectGeometryResult(charGeometry, expectedCharGeometry); + + END_TEST; +} + +int UtcDaliTextGeometryWithVerticalLineAlignmentBottomGetCharacterBoundingRectangleLabel(void) +{ + ToolkitTestApplication application; + tet_infoline("UtcDaliTextGeometryWithVerticalLineAlignmentBottomGetCharacterBoundingRectangleLabel"); + + TextLabel label = TextLabel::New(); + DALI_TEST_CHECK(label); + + application.GetScene().Add(label); + + label.SetProperty(Actor::Property::SIZE, Vector2(450.0f, 300.f)); + label.SetProperty(TextLabel::Property::POINT_SIZE, 10.f); + label.SetProperty(TextLabel::Property::MULTI_LINE, true); + label.SetProperty(Toolkit::TextLabel::Property::VERTICAL_ALIGNMENT, "BOTTOM"); + label.SetProperty(TextLabel::Property::TEXT, "Lorem ipsum dolor sit amet, \n consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."); + + application.SendNotification(); + application.Render(); + + Rect<> charGeometry = TextGeometry::GetCharacterBoundingRectangle(label, 1); + + Rect<> expectedCharGeometry = {13.0, 16.0f, 19.0f, 16.0f}; + + TestTextGeometryUtils::CheckRectGeometryResult(charGeometry, expectedCharGeometry); + + END_TEST; +} + +int UtcDaliTextGeometryGetCharacterIndexAtPositionTextLabel(void) +{ + ToolkitTestApplication application; + tet_infoline("UtcDaliTextGeometryGetCharacterIndexAtPositionTextLabel"); + + TextLabel label = TextLabel::New(); + DALI_TEST_CHECK(label); + + application.GetScene().Add(label); + + label.SetProperty(Actor::Property::SIZE, Vector2(450.0f, 300.f)); + label.SetProperty(TextLabel::Property::POINT_SIZE, 10.f); + label.SetProperty(TextLabel::Property::TEXT, "sara سارة"); + + application.SendNotification(); + application.Render(); + + int characterIndex = TextGeometry::GetCharacterIndexAtPosition(label, 1, 1); + + int expectedCharacterIndex = 0; + + DALI_TEST_EQUALS(characterIndex, expectedCharacterIndex, TEST_LOCATION); + + END_TEST; +} + +int UtcDaliTextGeometryGetCharacterIndexAtPositionTextEditor(void) +{ + ToolkitTestApplication application; + tet_infoline("UtcDaliTextGeometryGetCharacterIndexAtPositionTextEditor"); + + TextEditor editor = TextEditor::New(); + DALI_TEST_CHECK(editor); + + application.GetScene().Add(editor); + + editor.SetProperty(Actor::Property::SIZE, Vector2(160.0f, 250.f)); + editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f); + editor.SetProperty(TextEditor::Property::TEXT, "Hello everyone."); + + application.SendNotification(); + application.Render(); + + int characterIndex = TextGeometry::GetCharacterIndexAtPosition(editor, 2, 2); + + int expectedCharacterIndex = 0; + + DALI_TEST_EQUALS(characterIndex, expectedCharacterIndex, TEST_LOCATION); + + END_TEST; +} + +int UtcDaliTextGeometryGetCharacterIndexAtPositionTextField(void) +{ + ToolkitTestApplication application; + tet_infoline("UtcDaliTextGeometryGetCharacterIndexAtPositionTextField"); + + TextField field = TextField::New(); + DALI_TEST_CHECK(field); + + application.GetScene().Add(field); + + field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER); + field.SetProperty(Actor::Property::SIZE, Vector2(450.0f, 350.f)); + field.SetProperty(TextField::Property::POINT_SIZE, 10.f); + field.SetProperty(TextField::Property::TEXT, "مرحبا بالعالم"); + + application.SendNotification(); + application.Render(); + + int characterIndex = TextGeometry::GetCharacterIndexAtPosition(field, 18.6, 6); + + int expectedCharacterIndex = 12; + + DALI_TEST_EQUALS(characterIndex, expectedCharacterIndex, TEST_LOCATION); + + END_TEST; +} + +int UtcDaliTextGeometryGetCharacterIndexAtPositionTextLabelEmptyText(void) +{ + ToolkitTestApplication application; + tet_infoline("UtcDaliTextGeometryGetCharacterIndexAtPositionTextLabelEmptyText"); + + TextLabel label = TextLabel::New(); + DALI_TEST_CHECK(label); + + application.GetScene().Add(label); + + label.SetProperty(Actor::Property::SIZE, Vector2(450.0f, 300.f)); + label.SetProperty(TextLabel::Property::POINT_SIZE, 10.f); + label.SetProperty(TextLabel::Property::TEXT, ""); + + application.SendNotification(); + application.Render(); + + int characterIndex = TextGeometry::GetCharacterIndexAtPosition(label, 1, 0); + + int expectedCharacterIndex = -1; + + DALI_TEST_EQUALS(characterIndex, expectedCharacterIndex, TEST_LOCATION); + + END_TEST; +} + +int UtcDaliTextGeometryGetCharacterIndexAtPositionLastCharacter(void) +{ + ToolkitTestApplication application; + tet_infoline("UtcDaliTextGeometryGetCharacterIndexAtPositionLastCharacter"); + + TextLabel label = TextLabel::New(); + DALI_TEST_CHECK(label); + + application.GetScene().Add(label); + + label.SetProperty(Actor::Property::SIZE, Vector2(450.0f, 300.f)); + label.SetProperty(TextLabel::Property::POINT_SIZE, 10.f); + label.SetProperty(TextLabel::Property::TEXT, "Hello"); + + application.SendNotification(); + application.Render(); + + int characterIndex = TextGeometry::GetCharacterIndexAtPosition(label, 57, 2); + + int expectedCharacterIndex = 4; + + DALI_TEST_EQUALS(characterIndex, expectedCharacterIndex, TEST_LOCATION); + + END_TEST; +} + +int UtcDaliTextGeometryGetCharacterIndexAtPositionXExceedsTextWidth(void) +{ + ToolkitTestApplication application; + tet_infoline("UtcDaliTextGeometryGetCharacterIndexAtPositionXExceedsTextWidth"); + + TextLabel label = TextLabel::New(); + DALI_TEST_CHECK(label); + + application.GetScene().Add(label); + + label.SetProperty(Actor::Property::SIZE, Vector2(450.0f, 300.f)); + label.SetProperty(TextLabel::Property::POINT_SIZE, 10.f); + label.SetProperty(TextLabel::Property::TEXT, "Hello"); + + application.SendNotification(); + application.Render(); + + int characterIndex = TextGeometry::GetCharacterIndexAtPosition(label, 150, 1); + + int expectedCharacterIndex = -1; + + DALI_TEST_EQUALS(characterIndex, expectedCharacterIndex, TEST_LOCATION); + + END_TEST; +} \ No newline at end of file