4 * Copyright (c) 2022 Samsung Electronics Co., Ltd.
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
24 #include <dali-toolkit-test-suite-utils.h>
25 #include <dali-toolkit/dali-toolkit.h>
26 #include <dali-toolkit/devel-api/controls/text-controls/text-label-devel.h>
27 #include <dali-toolkit/devel-api/controls/text-controls/text-field-devel.h>
28 #include <dali-toolkit/devel-api/controls/text-controls/text-editor-devel.h>
29 #include <dali-toolkit/devel-api/text/bitmap-font.h>
30 #include <dali-toolkit/devel-api/text/rendering-backend.h>
31 #include <dali-toolkit/devel-api/text/text-enumerations-devel.h>
32 #include <dali-toolkit/devel-api/text/text-utils-devel.h>
33 #include <dali-toolkit/devel-api/text/text-geometry-devel.h>
34 #include "test-text-geometry-utils.h"
37 using namespace Toolkit;
40 void dali_textgeometry_startup(void)
42 test_return_value = TET_UNDEF;
45 void dali_textgeometry_cleanup(void)
47 test_return_value = TET_PASS;
50 int UtcDaliTextGeometryGetLineBoundingRectangleLabel(void)
52 ToolkitTestApplication application;
53 tet_infoline("UtcDaliTextGeometryGetLineBoundingRectangleLabel");
55 TextLabel label = TextLabel::New();
56 DALI_TEST_CHECK(label);
58 application.GetScene().Add(label);
60 float lineSpacing = -20.f;
62 label.SetProperty(Actor::Property::SIZE, Vector2(450.0f, 300.f));
63 label.SetProperty(TextLabel::Property::POINT_SIZE, 10.f);
64 label.SetProperty(DevelTextLabel::Property::LINE_SPACING, lineSpacing);
65 label.SetProperty(TextLabel::Property::MULTI_LINE, true);
66 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.");
68 application.SendNotification();
71 Rect<> lineGeometry = TextGeometry::GetLineBoundingRectangle(label, 1);
73 Rect<> expectedLineGeometry = {0, 16, 418, 16};
75 TestTextGeometryUtils::CheckRectGeometryResult(lineGeometry, expectedLineGeometry);
80 int UtcDaliTextGeometryGetLineBoundingRectangleEditor(void)
82 ToolkitTestApplication application;
83 tet_infoline("UtcDaliTextGeometryGetLineBoundingRectangleEditor");
85 TextEditor editor = TextEditor::New();
86 DALI_TEST_CHECK(editor);
88 application.GetScene().Add(editor);
90 editor.SetProperty(Actor::Property::SIZE, Vector2(160.0f, 250.f));
91 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
92 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.");
94 application.SendNotification();
97 Rect<> lineGeometry = TextGeometry::GetLineBoundingRectangle(editor, 0);
99 Rect<> expectedLineGeometry = {0, 0, 91, 36};
101 TestTextGeometryUtils::CheckRectGeometryResult(lineGeometry, expectedLineGeometry);
106 int UtcDaliTextGeometryGetLineBoundingRectangleField(void)
108 ToolkitTestApplication application;
109 tet_infoline("UtcDaliTextGeometryGetLineBoundingRectangleField");
111 TextField field = TextField::New();
112 DALI_TEST_CHECK(field);
114 application.GetScene().Add(field);
116 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
117 field.SetProperty(Actor::Property::SIZE, Vector2(450.0f, 350.f));
118 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
119 field.SetProperty(TextField::Property::TEXT, "مرحبا بالعالم");
121 application.SendNotification();
122 application.Render();
124 Rect<> lineGeometry = TextGeometry::GetLineBoundingRectangle(field, 0);
126 Rect<> expectedLineGeometry = {0, 0, 162, 36};
128 TestTextGeometryUtils::CheckRectGeometryResult(lineGeometry, expectedLineGeometry);
133 int UtcDaliTextGeometryEmptyTextGetLineBoundingRectangleLabel(void)
135 ToolkitTestApplication application;
136 tet_infoline("UtcDaliTextGeometryEmptyTextGetLineBoundingRectangleLabel");
138 TextLabel label = TextLabel::New();
139 DALI_TEST_CHECK(label);
141 application.GetScene().Add(label);
143 label.SetProperty(Actor::Property::SIZE, Vector2(450.0f, 300.f));
144 label.SetProperty(TextLabel::Property::POINT_SIZE, 10.f);
145 label.SetProperty(TextLabel::Property::TEXT, "");
147 application.SendNotification();
148 application.Render();
150 Rect<> lineGeometry = TextGeometry::GetLineBoundingRectangle(label, 0);
152 Rect<> expectedLineGeometry = {0, 0, 0, 0};
154 TestTextGeometryUtils::CheckRectGeometryResult(lineGeometry, expectedLineGeometry);
159 int UtcDaliTextGeometryLineSpacingPositiveGetLineBoundingRectangleLabel(void)
161 ToolkitTestApplication application;
162 tet_infoline("UtcDaliTextGeometryLineSpacingPositiveGetLineBoundingRectangleLabel");
164 TextLabel label = TextLabel::New();
165 DALI_TEST_CHECK(label);
167 application.GetScene().Add(label);
169 float lineSpacing = 20.f;
171 label.SetProperty(Actor::Property::SIZE, Vector2(450.0f, 300.f));
172 label.SetProperty(TextLabel::Property::POINT_SIZE, 10.f);
173 label.SetProperty(DevelTextLabel::Property::LINE_SPACING, lineSpacing);
174 label.SetProperty(TextLabel::Property::MULTI_LINE, true);
175 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.");
177 application.SendNotification();
178 application.Render();
180 Rect<> lineGeometry = TextGeometry::GetLineBoundingRectangle(label, 1);
182 Rect<> expectedLineGeometry = {0, 56, 418, 56};
184 TestTextGeometryUtils::CheckRectGeometryResult(lineGeometry, expectedLineGeometry);
189 int UtcDaliTextGeometryWithVerticalLineAlignmentTopGetLineBoundingRectangleLabel(void)
191 ToolkitTestApplication application;
192 tet_infoline("UtcDaliTextGeometryWithVerticalLineAlignmentTopGetLineBoundingRectangleLabel");
194 TextLabel label = TextLabel::New();
195 DALI_TEST_CHECK(label);
197 application.GetScene().Add(label);
199 label.SetProperty(Actor::Property::SIZE, Vector2(450.0f, 300.f));
200 label.SetProperty(TextLabel::Property::POINT_SIZE, 10.f);
201 label.SetProperty(TextLabel::Property::MULTI_LINE, true);
202 label.SetProperty(Toolkit::TextLabel::Property::VERTICAL_ALIGNMENT, "TOP");
203 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.");
205 application.SendNotification();
206 application.Render();
208 Rect<> lineGeometry = TextGeometry::GetLineBoundingRectangle(label, 1);
210 Rect<> expectedLineGeometry = {0, 36, 418, 36};
212 TestTextGeometryUtils::CheckRectGeometryResult(lineGeometry, expectedLineGeometry);
217 int UtcDaliTextGeometryWithVerticalLineAlignmentBottomGetLineBoundingRectangleLabel(void)
219 ToolkitTestApplication application;
220 tet_infoline("UtcDaliTextGeometryWithVerticalLineAlignmentBottomGetLineBoundingRectangleLabel");
222 TextLabel label = TextLabel::New();
223 DALI_TEST_CHECK(label);
225 application.GetScene().Add(label);
227 label.SetProperty(Actor::Property::SIZE, Vector2(450.0f, 300.f));
228 label.SetProperty(TextLabel::Property::POINT_SIZE, 10.f);
229 label.SetProperty(TextLabel::Property::MULTI_LINE, true);
230 label.SetProperty(Toolkit::TextLabel::Property::VERTICAL_ALIGNMENT, "BOTTOM");
231 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.");
233 application.SendNotification();
234 application.Render();
236 Rect<> lineGeometry = TextGeometry::GetLineBoundingRectangle(label, 1);
238 Rect<> expectedLineGeometry = {0, 36, 418, 36};
240 TestTextGeometryUtils::CheckRectGeometryResult(lineGeometry, expectedLineGeometry);
244 int UtcDaliTextGeometryWithEllipsisMiddleGetLineBoundingRectangleLabel(void)
246 ToolkitTestApplication application;
247 tet_infoline("UtcDaliTextGeometryWithEllipsisMiddleGetLineBoundingRectangleLabel");
249 TextLabel label = TextLabel::New();
250 DALI_TEST_CHECK(label);
252 application.GetScene().Add(label);
254 label.SetProperty(Actor::Property::SIZE, Vector2(450.0f, 300.f));
255 label.SetProperty(TextLabel::Property::POINT_SIZE, 10.f);
256 label.SetProperty(TextLabel::Property::MULTI_LINE, true);
257 label.SetProperty(TextLabel::Property::ELLIPSIS, true);
258 label.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::MIDDLE);
259 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.");
261 application.SendNotification();
262 application.Render();
264 Rect<> lineGeometry = TextGeometry::GetLineBoundingRectangle(label, 1);
266 Rect<> expectedLineGeometry = {0, 36, 418, 36};
268 TestTextGeometryUtils::CheckRectGeometryResult(lineGeometry, expectedLineGeometry);
273 int UtcDaliTextGeometryWithEllipsisStartGetLineBoundingRectangleLabel(void)
275 ToolkitTestApplication application;
276 tet_infoline("UtcDaliTextGeometryWithEllipsisStartGetLineBoundingRectangleLabel");
278 TextLabel label = TextLabel::New();
279 DALI_TEST_CHECK(label);
281 application.GetScene().Add(label);
283 label.SetProperty(Actor::Property::SIZE, Vector2(450.0f, 300.f));
284 label.SetProperty(TextLabel::Property::POINT_SIZE, 10.f);
285 label.SetProperty(TextLabel::Property::MULTI_LINE, true);
286 label.SetProperty(TextLabel::Property::ELLIPSIS, true);
287 label.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::START);
288 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.");
290 application.SendNotification();
291 application.Render();
293 Rect<> lineGeometry = TextGeometry::GetLineBoundingRectangle(label, 1);
295 Rect<> expectedLineGeometry = {0, 36, 418, 36};
297 TestTextGeometryUtils::CheckRectGeometryResult(lineGeometry, expectedLineGeometry);
302 int UtcDaliTextGeometryWithEllipsisEndGetLineBoundingRectangleLabel(void)
304 ToolkitTestApplication application;
305 tet_infoline("UtcDaliTextGeometryWithEllipsisEndGetLineBoundingRectangleLabel");
307 TextLabel label = TextLabel::New();
308 DALI_TEST_CHECK(label);
310 application.GetScene().Add(label);
312 label.SetProperty(Actor::Property::SIZE, Vector2(450.0f, 300.f));
313 label.SetProperty(TextLabel::Property::POINT_SIZE, 10.f);
314 label.SetProperty(TextLabel::Property::MULTI_LINE, true);
315 label.SetProperty(TextLabel::Property::ELLIPSIS, true);
316 label.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::END);
317 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.");
319 application.SendNotification();
320 application.Render();
322 Rect<> lineGeometry = TextGeometry::GetLineBoundingRectangle(label, 1);
324 Rect<> expectedLineGeometry = {0, 36, 418, 36};
326 TestTextGeometryUtils::CheckRectGeometryResult(lineGeometry, expectedLineGeometry);
331 int UtcDaliTextGeometryGetCharacterBoundingRectangleLabel(void)
333 ToolkitTestApplication application;
334 tet_infoline("UtcDaliTextGeometryGetCharacterBoundingRectangleLabel");
336 TextLabel label = TextLabel::New();
337 DALI_TEST_CHECK(label);
339 application.GetScene().Add(label);
341 float lineSpacing = -20.f;
343 label.SetProperty(Actor::Property::SIZE, Vector2(450.0f, 300.f));
344 label.SetProperty(TextLabel::Property::POINT_SIZE, 10.f);
345 label.SetProperty(DevelTextLabel::Property::LINE_SPACING, lineSpacing);
346 label.SetProperty(TextLabel::Property::MULTI_LINE, true);
347 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.");
349 application.SendNotification();
350 application.Render();
352 Rect<> characterGeometry = TextGeometry::GetCharacterBoundingRectangle(label, 1);
354 std::cout << " characterGeometry "<< characterGeometry <<std::endl;
356 Rect<> expectedCharacterGeometry = {13.0f, 16.0f, 19.0f, 16.0f};
357 std::cout<< " expectedCharacterGeometry " << characterGeometry <<std::endl;
359 std:: cout << "if" << (characterGeometry == expectedCharacterGeometry) <<std::endl;
360 TestTextGeometryUtils::CheckRectGeometryResult(characterGeometry, expectedCharacterGeometry);
365 int UtcDaliTextGeometryGetCharacterBoundingRectangleEditor(void)
367 ToolkitTestApplication application;
368 tet_infoline("UtcDaliTextGeometryGetCharacterBoundingRectangleEditor");
370 TextEditor editor = TextEditor::New();
371 DALI_TEST_CHECK(editor);
373 application.GetScene().Add(editor);
375 editor.SetProperty(Actor::Property::SIZE, Vector2(160.0f, 250.f));
376 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
377 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.");
379 application.SendNotification();
380 application.Render();
382 Rect<> characterGeometry = TextGeometry::GetCharacterBoundingRectangle(editor, 1);
384 Rect<> expectedCharacterGeometry = {13.0f, 16.0f, 19.0f, 16.0f};
386 TestTextGeometryUtils::CheckRectGeometryResult(characterGeometry, expectedCharacterGeometry);
391 int UtcDaliTextGeometryGetCharacterBoundingRectangleField(void)
393 ToolkitTestApplication application;
394 tet_infoline("UtcDaliTextGeometryGetCharacterBoundingRectangleField");
396 TextField field = TextField::New();
397 DALI_TEST_CHECK(field);
399 application.GetScene().Add(field);
401 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
402 field.SetProperty(Actor::Property::SIZE, Vector2(450.0f, 350.f));
403 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
404 field.SetProperty(TextField::Property::TEXT, "مرحبا بالعالم");
406 application.SendNotification();
407 application.Render();
409 Rect<> characterGeometry = TextGeometry::GetCharacterBoundingRectangle(field, 0);
411 Rect<> expectedCharacterGeometry = {142.0f, 10.0f, 16.0f, 11.0f};
413 TestTextGeometryUtils::CheckRectGeometryResult(characterGeometry, expectedCharacterGeometry);
419 int UtcDaliTextGeometryEmptyTextGetCharacterBoundingRectangleLabel(void)
421 ToolkitTestApplication application;
422 tet_infoline("UtcDaliTextGeometryEmptyTextGetCharacterBoundingRectangleLabel");
424 TextLabel label = TextLabel::New();
425 DALI_TEST_CHECK(label);
427 application.GetScene().Add(label);
429 label.SetProperty(Actor::Property::SIZE, Vector2(450.0f, 300.f));
430 label.SetProperty(TextLabel::Property::POINT_SIZE, 10.f);
431 label.SetProperty(TextLabel::Property::TEXT, "");
433 application.SendNotification();
434 application.Render();
436 Rect<> charGeometry = TextGeometry::GetCharacterBoundingRectangle(label, 0);
438 Rect<> expectedCharGeometry = {0.0f, 0.0f, 0.0f, 0.0f};
440 TestTextGeometryUtils::CheckRectGeometryResult(charGeometry, expectedCharGeometry);
445 int UtcDaliTextGeometryLineSpacingPositiveGetCharacterBoundingRectangleLabel(void)
447 ToolkitTestApplication application;
448 tet_infoline("UtcDaliTextGeometryLineSpacingPositiveGetCharacterBoundingRectangleLabel");
450 TextLabel label = TextLabel::New();
451 DALI_TEST_CHECK(label);
453 application.GetScene().Add(label);
455 float lineSpacing = 20.f;
457 label.SetProperty(Actor::Property::SIZE, Vector2(450.0f, 300.f));
458 label.SetProperty(TextLabel::Property::POINT_SIZE, 10.f);
459 label.SetProperty(DevelTextLabel::Property::LINE_SPACING, lineSpacing);
460 label.SetProperty(TextLabel::Property::MULTI_LINE, true);
461 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.");
463 application.SendNotification();
464 application.Render();
466 Rect<> charGeometry = TextGeometry::GetCharacterBoundingRectangle(label, 1);
468 Rect<> expectedCharGeometry = {13.0f, 16.0f, 19.0f, 16.0f};
470 TestTextGeometryUtils::CheckRectGeometryResult(charGeometry, expectedCharGeometry);
475 int UtcDaliTextGeometryWithVerticalLineAlignmentTopGetCharacterBoundingRectangleLabel(void)
477 ToolkitTestApplication application;
478 tet_infoline("UtcDaliTextGeometryWithVerticalLineAlignmentTopGetCharacterBoundingRectangleLabel");
480 TextLabel label = TextLabel::New();
481 DALI_TEST_CHECK(label);
483 application.GetScene().Add(label);
485 label.SetProperty(Actor::Property::SIZE, Vector2(450.0f, 300.f));
486 label.SetProperty(TextLabel::Property::POINT_SIZE, 10.f);
487 label.SetProperty(TextLabel::Property::MULTI_LINE, true);
488 label.SetProperty(Toolkit::TextLabel::Property::VERTICAL_ALIGNMENT, "TOP");
489 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.");
491 application.SendNotification();
492 application.Render();
494 Rect<> charGeometry = TextGeometry::GetCharacterBoundingRectangle(label, 1);
496 Rect<> expectedCharGeometry = {13.0, 16.0f, 19.0f, 16.0f};
498 TestTextGeometryUtils::CheckRectGeometryResult(charGeometry, expectedCharGeometry);
503 int UtcDaliTextGeometryWithVerticalLineAlignmentBottomGetCharacterBoundingRectangleLabel(void)
505 ToolkitTestApplication application;
506 tet_infoline("UtcDaliTextGeometryWithVerticalLineAlignmentBottomGetCharacterBoundingRectangleLabel");
508 TextLabel label = TextLabel::New();
509 DALI_TEST_CHECK(label);
511 application.GetScene().Add(label);
513 label.SetProperty(Actor::Property::SIZE, Vector2(450.0f, 300.f));
514 label.SetProperty(TextLabel::Property::POINT_SIZE, 10.f);
515 label.SetProperty(TextLabel::Property::MULTI_LINE, true);
516 label.SetProperty(Toolkit::TextLabel::Property::VERTICAL_ALIGNMENT, "BOTTOM");
517 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.");
519 application.SendNotification();
520 application.Render();
522 Rect<> charGeometry = TextGeometry::GetCharacterBoundingRectangle(label, 1);
524 Rect<> expectedCharGeometry = {13.0, 16.0f, 19.0f, 16.0f};
526 TestTextGeometryUtils::CheckRectGeometryResult(charGeometry, expectedCharGeometry);
531 int UtcDaliTextGeometryGetCharacterIndexAtPositionTextLabel(void)
533 ToolkitTestApplication application;
534 tet_infoline("UtcDaliTextGeometryGetCharacterIndexAtPositionTextLabel");
536 TextLabel label = TextLabel::New();
537 DALI_TEST_CHECK(label);
539 application.GetScene().Add(label);
541 label.SetProperty(Actor::Property::SIZE, Vector2(450.0f, 300.f));
542 label.SetProperty(TextLabel::Property::POINT_SIZE, 10.f);
543 label.SetProperty(TextLabel::Property::TEXT, "sara سارة");
545 application.SendNotification();
546 application.Render();
548 int characterIndex = TextGeometry::GetCharacterIndexAtPosition(label, 1, 1);
550 int expectedCharacterIndex = 0;
552 DALI_TEST_EQUALS(characterIndex, expectedCharacterIndex, TEST_LOCATION);
557 int UtcDaliTextGeometryGetCharacterIndexAtPositionTextEditor(void)
559 ToolkitTestApplication application;
560 tet_infoline("UtcDaliTextGeometryGetCharacterIndexAtPositionTextEditor");
562 TextEditor editor = TextEditor::New();
563 DALI_TEST_CHECK(editor);
565 application.GetScene().Add(editor);
567 editor.SetProperty(Actor::Property::SIZE, Vector2(160.0f, 250.f));
568 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
569 editor.SetProperty(TextEditor::Property::TEXT, "Hello everyone.");
571 application.SendNotification();
572 application.Render();
574 int characterIndex = TextGeometry::GetCharacterIndexAtPosition(editor, 2, 2);
576 int expectedCharacterIndex = 0;
578 DALI_TEST_EQUALS(characterIndex, expectedCharacterIndex, TEST_LOCATION);
583 int UtcDaliTextGeometryGetCharacterIndexAtPositionTextField(void)
585 ToolkitTestApplication application;
586 tet_infoline("UtcDaliTextGeometryGetCharacterIndexAtPositionTextField");
588 TextField field = TextField::New();
589 DALI_TEST_CHECK(field);
591 application.GetScene().Add(field);
593 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
594 field.SetProperty(Actor::Property::SIZE, Vector2(450.0f, 350.f));
595 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
596 field.SetProperty(TextField::Property::TEXT, "مرحبا بالعالم");
598 application.SendNotification();
599 application.Render();
601 int characterIndex = TextGeometry::GetCharacterIndexAtPosition(field, 18.6, 6);
603 int expectedCharacterIndex = 12;
605 DALI_TEST_EQUALS(characterIndex, expectedCharacterIndex, TEST_LOCATION);
610 int UtcDaliTextGeometryGetCharacterIndexAtPositionTextLabelEmptyText(void)
612 ToolkitTestApplication application;
613 tet_infoline("UtcDaliTextGeometryGetCharacterIndexAtPositionTextLabelEmptyText");
615 TextLabel label = TextLabel::New();
616 DALI_TEST_CHECK(label);
618 application.GetScene().Add(label);
620 label.SetProperty(Actor::Property::SIZE, Vector2(450.0f, 300.f));
621 label.SetProperty(TextLabel::Property::POINT_SIZE, 10.f);
622 label.SetProperty(TextLabel::Property::TEXT, "");
624 application.SendNotification();
625 application.Render();
627 int characterIndex = TextGeometry::GetCharacterIndexAtPosition(label, 1, 0);
629 int expectedCharacterIndex = -1;
631 DALI_TEST_EQUALS(characterIndex, expectedCharacterIndex, TEST_LOCATION);
636 int UtcDaliTextGeometryGetCharacterIndexAtPositionLastCharacter(void)
638 ToolkitTestApplication application;
639 tet_infoline("UtcDaliTextGeometryGetCharacterIndexAtPositionLastCharacter");
641 TextLabel label = TextLabel::New();
642 DALI_TEST_CHECK(label);
644 application.GetScene().Add(label);
646 label.SetProperty(Actor::Property::SIZE, Vector2(450.0f, 300.f));
647 label.SetProperty(TextLabel::Property::POINT_SIZE, 10.f);
648 label.SetProperty(TextLabel::Property::TEXT, "Hello");
650 application.SendNotification();
651 application.Render();
653 int characterIndex = TextGeometry::GetCharacterIndexAtPosition(label, 57, 2);
655 int expectedCharacterIndex = 4;
657 DALI_TEST_EQUALS(characterIndex, expectedCharacterIndex, TEST_LOCATION);
662 int UtcDaliTextGeometryGetCharacterIndexAtPositionXExceedsTextWidth(void)
664 ToolkitTestApplication application;
665 tet_infoline("UtcDaliTextGeometryGetCharacterIndexAtPositionXExceedsTextWidth");
667 TextLabel label = TextLabel::New();
668 DALI_TEST_CHECK(label);
670 application.GetScene().Add(label);
672 label.SetProperty(Actor::Property::SIZE, Vector2(450.0f, 300.f));
673 label.SetProperty(TextLabel::Property::POINT_SIZE, 10.f);
674 label.SetProperty(TextLabel::Property::TEXT, "Hello");
676 application.SendNotification();
677 application.Render();
679 int characterIndex = TextGeometry::GetCharacterIndexAtPosition(label, 150, 1);
681 int expectedCharacterIndex = -1;
683 DALI_TEST_EQUALS(characterIndex, expectedCharacterIndex, TEST_LOCATION);