Rect<> lineGeometry = TextGeometry::GetLineBoundingRectangle(label, 1);
- Rect<> expectedLineGeometry = {0, 16, 420, 16};
+ Rect<> expectedLineGeometry = {0, 16, 418, 16};
TestTextGeometryUtils::CheckRectGeometryResult(lineGeometry, expectedLineGeometry);
Rect<> lineGeometry = TextGeometry::GetLineBoundingRectangle(field, 0);
- Rect<> expectedLineGeometry = {0, 0, 163, 36};
+ Rect<> expectedLineGeometry = {0, 0, 162, 36};
TestTextGeometryUtils::CheckRectGeometryResult(lineGeometry, expectedLineGeometry);
Rect<> lineGeometry = TextGeometry::GetLineBoundingRectangle(label, 1);
- Rect<> expectedLineGeometry = {0, 56, 420, 56};
+ Rect<> expectedLineGeometry = {0, 56, 418, 56};
TestTextGeometryUtils::CheckRectGeometryResult(lineGeometry, expectedLineGeometry);
Rect<> lineGeometry = TextGeometry::GetLineBoundingRectangle(label, 1);
- Rect<> expectedLineGeometry = {0, 36, 420, 36};
+ Rect<> expectedLineGeometry = {0, 36, 418, 36};
TestTextGeometryUtils::CheckRectGeometryResult(lineGeometry, expectedLineGeometry);
Rect<> lineGeometry = TextGeometry::GetLineBoundingRectangle(label, 1);
- Rect<> expectedLineGeometry = {0, 36, 420, 36};
+ Rect<> expectedLineGeometry = {0, 36, 418, 36};
TestTextGeometryUtils::CheckRectGeometryResult(lineGeometry, expectedLineGeometry);
Rect<> lineGeometry = TextGeometry::GetLineBoundingRectangle(label, 1);
- Rect<> expectedLineGeometry = {0, 36, 420, 36};
+ Rect<> expectedLineGeometry = {0, 36, 418, 36};
TestTextGeometryUtils::CheckRectGeometryResult(lineGeometry, expectedLineGeometry);
Rect<> lineGeometry = TextGeometry::GetLineBoundingRectangle(label, 1);
- Rect<> expectedLineGeometry = {0, 36, 420, 36};
+ Rect<> expectedLineGeometry = {0, 36, 418, 36};
TestTextGeometryUtils::CheckRectGeometryResult(lineGeometry, expectedLineGeometry);
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 <<std::endl;
+
+ Rect<> expectedCharacterGeometry = {13.0f, 16.0f, 19.0f, 16.0f};
+ std::cout<< " expectedCharacterGeometry " << characterGeometry <<std::endl;
+
+ std:: cout << "if" << (characterGeometry == expectedCharacterGeometry) <<std::endl;
+ TestTextGeometryUtils::CheckRectGeometryResult(characterGeometry, expectedCharacterGeometry);
+
+ END_TEST;
+}
+
+int UtcDaliTextGeometryGetCharacterBoundingRectangleEditor(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline("UtcDaliTextGeometryGetCharacterBoundingRectangleEditor");
+
+ 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, "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(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