Merge "Sync AsyncTaskManager code with adaptor" into devel/master
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / utc-Dali-TextField.cpp
index 63eac09..5f33099 100644 (file)
@@ -2982,7 +2982,8 @@ int utcDaliTextFieldEvent08(void)
   tet_infoline(" utcDaliTextFieldEvent08");
 
   Dali::Clipboard clipboard = Clipboard::Get();
-  clipboard.SetItem("testTextFieldEvent");
+  Dali::Clipboard::ClipData data("text/plain;charset=utf-8", "testTextFieldEvent");
+  clipboard.SetData(data);
 
   // Checks Longpress when only place holder text
 
@@ -4789,7 +4790,7 @@ int utcDaliTextFieldGeometryEllipsisStart(void)
   Vector<Vector2> expectedPositions;
 
   expectedPositions.PushBack(Vector2(14, 0));
-  expectedSizes.PushBack(Vector2(106, 25));
+  expectedSizes.PushBack(Vector2(107, 25));
 
   TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
 
@@ -4836,7 +4837,7 @@ int utcDaliTextFieldGeometryEllipsisEnd(void)
   Vector<Vector2> expectedPositions;
 
   expectedPositions.PushBack(Vector2(-2, 0));
-  expectedSizes.PushBack(Vector2(122, 25));
+  expectedSizes.PushBack(Vector2(123, 25));
 
   TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
 
@@ -4881,7 +4882,7 @@ int utcDaliTextFieldGeometryRTL(void)
   Vector<Vector2> expectedPositions;
 
   expectedPositions.PushBack(Vector2(38, 0));
-  expectedSizes.PushBack(Vector2(73, 25));
+  expectedSizes.PushBack(Vector2(75, 25));
 
   TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
 
@@ -4926,7 +4927,7 @@ int utcDaliTextFieldGeometryGlyphMiddle(void)
   Vector<Vector2> expectedPositions;
 
   expectedPositions.PushBack(Vector2(6, 0));
-  expectedSizes.PushBack(Vector2(124, 25));
+  expectedSizes.PushBack(Vector2(125, 25));
 
   TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
 
@@ -5786,3 +5787,37 @@ int utcDaliTextFieldPanGesturePropagation(void)
 
   END_TEST;
 }
+
+int utcDaliTextFieldGetTextBoundingRectangle(void)
+{
+  ToolkitTestApplication application;
+  tet_infoline(" utcDaliTextFieldGeometryEllipsisMiddle");
+
+  TextField field = TextField::New();
+  DALI_TEST_CHECK(field);
+
+  application.GetScene().Add(field);
+
+  field.SetProperty(TextField::Property::POINT_SIZE, 7.f);
+  field.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
+  field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
+  field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
+  field.SetProperty(TextField::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 = DevelTextField::GetTextBoundingRectangle(field, startIndex, endIndex);
+  Rect<> expectedTextBoundingRectangle = {0, 0, 100, 25};
+
+  TestTextGeometryUtils::CheckRectGeometryResult(textBoundingRectangle, expectedTextBoundingRectangle);
+
+  END_TEST;
+}
\ No newline at end of file