2 * Copyright (c) 2022 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
22 #include <dali-toolkit-test-suite-utils.h>
23 #include <dali-toolkit/dali-toolkit.h>
24 #include <dali-toolkit/internal/text/cursor-helper-functions.h>
25 #include <toolkit-text-utils.h>
28 using namespace Toolkit;
31 // Tests the following functions.
33 // LineIndex GetClosestLine( VisualModelPtr visualModel,
36 // CharacterIndex GetClosestCursorIndex( VisualModelPtr visualModel,
37 // LogicalModelPtr logicalModel,
38 // MetricsPtr metrics,
41 // CharacterHitTest::Mode mode,
42 // bool& isCharacterHit )
44 //////////////////////////////////////////////////////////
48 const std::string DEFAULT_FONT_DIR("/resources/fonts");
49 const unsigned int DEFAULT_FONT_SIZE = 1152u;
51 struct GetClosestLineData
53 std::string description; ///< Description of the test.
54 std::string text; ///< Input text.
55 unsigned int numberOfTests; ///< The number of tests.
56 float* visualY; ///< The visual 'y' position for each test.
57 LineIndex* lineIndex; ///< The expected line index for each test.
58 bool* isLineHit; ///< The expected line hit value for each test.
61 struct GetClosestCursorIndexData
63 std::string description; ///< Description of the test.
64 std::string text; ///< Input text.
65 unsigned int numberOfTests; ///< The number of tests.
66 float* visualX; ///< The visual 'x' position for each test.
67 float* visualY; ///< The visual 'y' position for each test.
68 CharacterHitTest::Mode* mode; ///< The type of hit test.
69 bool markupProcessorEnabled; //< Enable markup processor to use markup text.
70 CharacterIndex* logicalIndex; ///< The expected logical cursor index for each test.
71 bool* isCharacterHit; ///< The expected character hit value for each test.
74 struct GetCursorPositionData
76 std::string description; ///< Description of the test.
77 std::string text; ///< Input text.
78 unsigned int numberOfTests; ///< The number of tests.
79 CharacterIndex* logicalIndex; ///< The logical cursor index for each test.
80 float* visualX; ///< The expected visual 'x' position for each test.
81 float* visualY; ///< The expected visual 'y' position for each test.
84 struct FindSelectionIndicesData
86 std::string description; ///< Description of the test.
87 std::string text; ///< Input text.
88 unsigned int numberOfTests; ///< The number of tests.
89 float* visualX; ///< The visual 'x' position for each test.
90 float* visualY; ///< The visual 'y' position for each test.
91 bool* found; ///< Whether selection indices are found.
92 CharacterIndex* startIndex; ///< The expected start cursor index for each test.
93 CharacterIndex* endIndex; ///< The expected end cursor index for each test.
94 CharacterIndex* noTextHitIndex; ///< The expected character index when there is no hit.
97 struct PrimaryCursorHeightData
99 std::string description; ///< Description of the test.
100 std::string text; ///< Input text.
101 unsigned int numberOfTests; ///< The number of tests.
102 CharacterIndex* logicalIndex; ///< The logical cursor index for each test.
103 float* heights; ///< The expected primary cursor height for each test.
106 bool GetClosestLineTest(const GetClosestLineData& data)
108 std::cout << " testing : " << data.description << std::endl;
110 // 1) Create the model.
113 Size textArea(400.f, 600.f);
116 Vector<FontDescriptionRun> fontDescriptionRuns;
117 LayoutOptions options;
118 CreateTextModel(data.text,
128 Toolkit::DevelText::EllipsisPosition::END,
130 0.0f // characterSpacing
133 LogicalModelPtr logicalModel = textModel->mLogicalModel;
134 VisualModelPtr visualModel = textModel->mVisualModel;
136 for(unsigned int index = 0; index < data.numberOfTests; ++index)
138 bool isLineHit = false;
139 const LineIndex lineIndex = GetClosestLine(visualModel,
143 if(lineIndex != data.lineIndex[index])
145 std::cout << " test " << index << " failed. Different line index : " << lineIndex << ", expected : " << data.lineIndex[index] << std::endl;
148 if(isLineHit != data.isLineHit[index])
150 std::cout << " test " << index << " failed. Different line hit value : " << isLineHit << ", expected : " << data.isLineHit[index] << std::endl;
158 bool GetClosestCursorIndexTest(const GetClosestCursorIndexData& data)
160 std::cout << " testing : " << data.description << std::endl;
162 // 1) Create the model.
165 Size textArea(400.f, 600.f);
168 Vector<FontDescriptionRun> fontDescriptionRuns;
169 LayoutOptions options;
170 CreateTextModel(data.text,
177 data.markupProcessorEnabled,
180 Toolkit::DevelText::EllipsisPosition::END,
182 0.0f // characterSpacing
185 LogicalModelPtr logicalModel = textModel->mLogicalModel;
186 VisualModelPtr visualModel = textModel->mVisualModel;
188 for(unsigned int index = 0; index < data.numberOfTests; ++index)
190 bool isCharacterHit = false;
191 const CharacterIndex logicalCursorIndex = GetClosestCursorIndex(visualModel,
199 if(logicalCursorIndex != data.logicalIndex[index])
201 std::cout << " test " << index << " failed. Different logical cursor index : " << logicalCursorIndex << ", expected : " << data.logicalIndex[index] << std::endl;
204 if(isCharacterHit != data.isCharacterHit[index])
206 std::cout << " test " << index << " failed. Different character hit value : " << isCharacterHit << ", expected : " << data.isCharacterHit[index] << std::endl;
214 bool GetCursorPositionTest(const GetCursorPositionData& data)
216 std::cout << " testing : " << data.description << std::endl;
218 // 1) Create the model.
221 Size textArea(400.f, 600.f);
224 Vector<FontDescriptionRun> fontDescriptionRuns;
225 LayoutOptions options;
226 CreateTextModel(data.text,
236 Toolkit::DevelText::EllipsisPosition::END,
238 0.0f // characterSpacing
241 LogicalModelPtr logicalModel = textModel->mLogicalModel;
242 VisualModelPtr visualModel = textModel->mVisualModel;
244 GetCursorPositionParameters parameters;
245 parameters.visualModel = visualModel;
246 parameters.logicalModel = logicalModel;
247 parameters.metrics = metrics;
248 parameters.isMultiline = true;
250 for(unsigned int index = 0; index < data.numberOfTests; ++index)
252 CursorInfo cursorInfo;
253 parameters.logical = data.logicalIndex[index];
255 GetCursorPosition(parameters,
256 0.f, // Since this test case is not testing the primary cursor height, the default font line height can be set to 0.f.
259 if(floor(cursorInfo.primaryPosition.x) != data.visualX[index])
261 std::cout << " test " << index << " failed. Different 'x' cursor position : " << cursorInfo.primaryPosition.x << ", expected : " << data.visualX[index] << std::endl;
264 if(floor(cursorInfo.primaryPosition.y) != data.visualY[index])
266 std::cout << " test " << index << " failed. Different 'y' cursor position : " << cursorInfo.primaryPosition.y << ", expected : " << data.visualY[index] << std::endl;
274 bool FindSelectionIndicesTest(const FindSelectionIndicesData& data)
276 std::cout << " testing : " << data.description << std::endl;
278 // 1) Create the model.
281 Size textArea(400.f, 600.f);
284 Vector<FontDescriptionRun> fontDescriptionRuns;
285 LayoutOptions options;
286 CreateTextModel(data.text,
296 Toolkit::DevelText::EllipsisPosition::END,
298 0.0f // characterSpacing
301 LogicalModelPtr logicalModel = textModel->mLogicalModel;
302 VisualModelPtr visualModel = textModel->mVisualModel;
304 for(unsigned int index = 0; index < data.numberOfTests; ++index)
306 CharacterIndex startIndex = 0;
307 CharacterIndex endIndex = 0;
308 CharacterIndex noTextHitIndex = 0;
309 const bool found = FindSelectionIndices(visualModel,
318 if(found != data.found[index])
320 std::cout << " test " << index << " failed. Different found value : " << found << ", expected : " << data.found[index] << std::endl;
323 if(startIndex != data.startIndex[index])
325 std::cout << " test " << index << " failed. Different start index : " << startIndex << ", expected : " << data.startIndex[index] << std::endl;
328 if(endIndex != data.endIndex[index])
330 std::cout << " test " << index << " failed. Different end index : " << endIndex << ", expected : " << data.endIndex[index] << std::endl;
333 if(noTextHitIndex != data.noTextHitIndex[index])
335 std::cout << " test " << index << " failed. Different no text hit index : " << noTextHitIndex << ", expected : " << data.noTextHitIndex[index] << std::endl;
342 bool PrimaryCursorHeightTest(const PrimaryCursorHeightData& data)
344 std::cout << " testing : " << data.description << std::endl;
346 // 1) Create the model.
349 Size textArea(400.f, 600.f);
352 Vector<FontDescriptionRun> fontDescriptionRuns;
354 const std::string fontFamily("DejaVuSans");
356 // Set a known font description
357 FontDescriptionRun fontDescriptionRun1;
358 fontDescriptionRun1.characterRun.characterIndex = 0u;
359 fontDescriptionRun1.characterRun.numberOfCharacters = 13u;
360 fontDescriptionRun1.familyLength = fontFamily.size();
361 fontDescriptionRun1.familyName = new char[fontDescriptionRun1.familyLength];
362 memcpy(fontDescriptionRun1.familyName, fontFamily.c_str(), fontDescriptionRun1.familyLength);
363 fontDescriptionRun1.familyDefined = true;
364 fontDescriptionRun1.weightDefined = false;
365 fontDescriptionRun1.widthDefined = false;
366 fontDescriptionRun1.slantDefined = false;
367 fontDescriptionRun1.sizeDefined = true;
368 fontDescriptionRun1.size = 768u; //Font size = 12.0f (768/64 = 12)
370 fontDescriptionRuns.PushBack(fontDescriptionRun1);
372 LayoutOptions options;
373 CreateTextModel(data.text,
383 Toolkit::DevelText::EllipsisPosition::END,
384 50.0f, // lineSpacing
385 50.0f // characterSpacing
388 LogicalModelPtr logicalModel = textModel->mLogicalModel;
389 VisualModelPtr visualModel = textModel->mVisualModel;
391 GetCursorPositionParameters parameters;
392 parameters.visualModel = visualModel;
393 parameters.logicalModel = logicalModel;
394 parameters.metrics = metrics;
395 parameters.isMultiline = true;
397 for(unsigned int index = 0; index < data.numberOfTests; ++index)
399 CursorInfo cursorInfo;
400 parameters.logical = data.logicalIndex[index];
403 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
404 fontClient.SetDpi(93u, 93u);
406 char* pathNamePtr = get_current_dir_name();
407 const std::string pathName(pathNamePtr);
410 FontId fontID = fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSans.ttf");
412 Text::FontMetrics fontMetrics;
413 MetricsPtr mMetrics = Metrics::New(fontClient);
414 mMetrics->GetFontMetrics(fontID, fontMetrics);
415 float defaultFontLineHeight = (fontMetrics.ascender - fontMetrics.descender);
417 GetCursorPosition(parameters,
418 defaultFontLineHeight,
421 if(floor(cursorInfo.primaryCursorHeight) != data.heights[index])
423 std::cout << " test " << index << " failed. Different primaryCursorHeight : " << cursorInfo.primaryCursorHeight << ", expected : " << data.heights[index] << std::endl;
433 //////////////////////////////////////////////////////////
435 // UtcDaliGetClosestLine
436 // UtcDaliGetClosestCursorIndex
437 // UtcDaliGetCursorPosition
438 // UtcDaliFindSelectionIndices
439 // UtcDaliPrimaryCursorHeight
441 //////////////////////////////////////////////////////////
443 int UtcDaliGetClosestLine(void)
445 tet_infoline(" UtcDaliGetClosestLine");
447 float visualY01[] = {-4.f, 3.f, 1000.f};
448 LineIndex lineIndices01[] = {0, 0, 0};
449 bool isLineHit01[] = {false, false, false};
451 float visualY02[] = {-4.f, 3.f, 1000.f};
452 LineIndex lineIndices02[] = {0, 0, 0};
453 bool isLineHit02[] = {false, true, false};
455 float visualY03[] = {-4.f, 11.f, 30.f, 51.f, 68.f, 87.f, 109.f, 130.f};
456 LineIndex lineIndices03[] = {0, 0, 1u, 2u, 3u, 4u, 5u, 5u};
457 bool isLineHit03[] = {false, true, true, true, true, true, true, false};
459 struct GetClosestLineData data[] =
467 {"Single line text.",
474 "abcשנבdefגקכghiעיןjklחלךmnoצמםpqrפרףstuדאוvwxה"
475 "סתyzטזץabcשנבdefגקכghiעיןjklחלךmnoצמםpqrפרףstuד"
476 "אוvwxהסתyzטזץabcשנבdefגקכghiעיןjklחלךmnoצמםpqr"
477 "פרףstuדאוvwxהסתyzטזץabcשנבdefגקכghiעיןjklחלךmno"
478 "צמםpqrפרףstuדאוvwxהסתyzטזץabcשנבdefגקכghiעיןjkl"
479 "חלךmnoצמםpqrפרףstuדאוvwxהסתyzטזץ",
484 const unsigned int numberOfTests = 3u;
486 for(unsigned int index = 0; index < numberOfTests; ++index)
488 ToolkitTestApplication application;
489 if(!GetClosestLineTest(data[index]))
491 tet_result(TET_FAIL);
495 tet_result(TET_PASS);
499 int UtcDaliGetClosestCursorIndex(void)
501 tet_infoline(" UtcDaliGetClosestCursorIndex");
503 float visualX01[] = {-100.f};
504 float visualY01[] = {-100.f};
505 CharacterHitTest::Mode mode01[] = {CharacterHitTest::TAP};
506 CharacterIndex logicalIndex01[] = {0};
507 bool isCharacterHit01[] = {false};
509 float visualX02[] = {-100.f, 1000.f, 60.f, 79.f, 83.f, 148.f, 99.f};
510 float visualY02[] = {-100.f, 1000.f, 12.f, 12.f, 12.f, 12.f, 12.f};
511 CharacterHitTest::Mode mode02[] = {CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP};
512 CharacterIndex logicalIndex02[] = {0, 21u, 7u, 10u, 10u, 14u, 12u};
513 bool isCharacterHit02[] = {false, false, true, true, true, true, true};
515 float visualX03[] = {19.f, 104.f, -2.f, 127.f};
516 float visualY03[] = {12.f, 12.f, 12.f, 12.f};
517 CharacterHitTest::Mode mode03[] = {CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP};
518 CharacterIndex logicalIndex03[] = {3u, 13u, 0, 18u};
519 bool isCharacterHit03[] = {true, true, false, false};
526 // different الأربعاء \n
527 float visualX04[] = {-100.f, 40.f, 44.f, 85.f, 500.f, 500.f, 367.f, 359.f, 329.f, -100.f, -100.f, 19.f, 64.f, 72.f, 104.f, 111.f, 500.f};
528 float visualY04[] = {-100.f, 12.f, 12.f, 12.f, 12.f, 30.f, 30.f, 30.f, 30.f, 30.f, 50.f, 50.f, 50.f, 50.f, 50.f, 50.f, 50.f};
529 CharacterHitTest::Mode mode04[] = {CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP};
530 CharacterIndex logicalIndex04[] = {0, 5u, 6u, 11u, 11u, 12u, 16u, 17u, 21u, 21u, 22u, 25u, 30u, 32u, 35u, 34u, 40u, 41u};
531 bool isCharacterHit04[] = {false, true, true, true, false, false, true, true, true, false, false, true, true, true, true, true, false};
534 // abcשנבdefג קכghiעיןjk lחלךmnoצמם pqrפרףstuד אוvwxה
536 // סתyz טזץabcשנבd efגקכghiעי ןjklחלךmno צמםpqrפרףstuד
537 // 93 100 110 120 130 139
538 // אוvwxהס תyzטזץabcש נבdefגקכgh iעיןjklחלך mnoצמםpqr
539 // 139 150 160 170 180 186
540 // פרףstuדאוvw xהסתyzטזץa bcשנבdefגק כghiעיןjkl חלךmno
541 // 186 190 200 210 220 233
542 // צמםp qrפרףstuדא וvwxהסתyzט זץabcשנבde fגקכghiעיןjkl
543 // 233 240 250 260 265
544 // חלךmnoצ מםpqrפרףst uדאוvwxהסת yzטזץ
546 float visualX05[] = {-100.f, 96.f, 155.f, 250.f, 344.f, 500.f, -100.f, 36.f, 124.f, 190.f, 280.f, 500.f, -100.f, 56.f, 158.f, 237.f, 303.f, 500.f, -100.f, 98.f, 184.f, 261.f, 337.f, 500.f, -100.f, 40.f, 113.f, 223.f, 302.f, 500.f, -100.f, 82.f, 160.f, 253.f, 500.f};
547 float visualY05[] = {-100.f, 12.f, 12.f, 12.f, 12.f, 12.f, 30.f, 30.f, 30.f, 30.f, 30.f, 30.f, 50.f, 50.f, 50.f, 50.f, 50.f, 50.f, 67.f, 67.f, 67.f, 67.f, 67.f, 67.f, 87.f, 87.f, 87.f, 87.f, 87.f, 87.f, 107.f, 107.f, 107.f, 107.f, 107.f};
548 CharacterHitTest::Mode mode05[] = {CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP};
549 CharacterIndex logicalIndex05[] = {0, 10u, 19u, 28u, 39u, 44u, 45u, 48u, 59u, 66u, 78u, 87u, 89u, 96u, 106u, 115u, 124u, 133u, 134u, 145u, 154u, 162u, 171u, 179u, 180u, 184u, 191u, 203u, 212u, 221u, 222u, 233u, 241u, 251u, 265u};
550 bool isCharacterHit05[] = {false, true, true, true, true, false, false, true, true, true, true, false, false, true, true, true, true, false, false, true, true, true, true, false, false, true, true, true, true, false, false, true, true, true, false};
553 // שנבabcגקכd efעיןghiחל ךjklצמםmno פרףpqrדאוs tuהסתv
555 // wxטז ץyzשנבabcג קכdefעיןgh iחלךjklצמם mnoפרףpqrדאוs
556 // 93 100 110 120 130 139
557 // tuהסתvw xטזץyzשנבa bcגקכdefעי ןghiחלךjkl צמםmnoפרף
558 // 139 150 160 170 180 186
559 // pqrדאוstuהס תvwxטזץyzש נבabcגקכde fעיןghiחלך jklצמם
560 // 186 190 200 210 220 232
561 // mnoפ רףpqrדאוst uהסתvwxטזץ yzשנבabcגק כdefעיןghiחל
562 // 232 240 250 260 265
563 // ךjklצמםm noפרףpqrדא וstuהסתvwx טזץyz
565 float visualX06[] = {500.f, 307.f, 237.f, 148.f, 55.f, -100.f, 500.f, 362.f, 276.f, 213.f, 121.f, -100.f, 500.f, 344.f, 238.f, 167.f, 93.f, -100.f, 500.f, 306.f, 216.f, 142.f, 58.f, -100.f, 500.f, 355.f, 279.f, 182.f, 92.f, -100.f, 500.f, 326.f, 238.f, 150.f, -100.f};
566 float visualY06[] = {-100.f, 12.f, 12.f, 12.f, 12.f, 12.f, 30.f, 30.f, 30.f, 30.f, 30.f, 30.f, 50.f, 50.f, 50.f, 50.f, 50.f, 50.f, 67.f, 67.f, 67.f, 67.f, 67.f, 67.f, 87.f, 87.f, 87.f, 87.f, 87.f, 87.f, 107.f, 107.f, 107.f, 107.f, 107.f};
567 CharacterHitTest::Mode mode06[] = {CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP};
568 CharacterIndex logicalIndex06[] = {0, 11u, 19u, 28u, 39u, 44u, 45u, 48u, 57u, 65u, 78u, 87u, 89u, 96u, 107u, 114u, 124u, 133u, 134u, 144u, 154u, 162u, 171u, 178u, 179u, 185u, 192u, 203u, 212u, 221u, 222u, 232u, 240u, 251u, 265u};
569 bool isCharacterHit06[] = {false, true, true, true, true, false, false, true, true, true, true, false, false, true, true, true, true, false, false, true, true, true, true, false, false, true, true, true, true, false, false, true, true, true, false};
571 float visualX07[] = {395.f};
572 float visualY07[] = {12.f};
573 CharacterHitTest::Mode mode07[] = {CharacterHitTest::TAP};
574 CharacterIndex logicalIndex07[] = {1u};
575 bool isCharacterHit07[] = {true};
577 float visualX08[] = {7.f};
578 float visualY08[] = {12.f};
579 CharacterHitTest::Mode mode08[] = {CharacterHitTest::TAP};
580 CharacterIndex logicalIndex08[] = {1u};
581 bool isCharacterHit08[] = {true};
583 float visualX09[] = {9.f};
584 float visualY09[] = {12.f};
585 CharacterHitTest::Mode mode09[] = {CharacterHitTest::TAP};
586 CharacterIndex logicalIndex09[] = {1u};
587 bool isCharacterHit09[] = {true};
589 struct GetClosestCursorIndexData data[] =
601 {"Single line text.",
602 "Hello world שלום עולם",
611 {"Single line with ligatures",
612 "different الأربعاء",
621 {"Multiline. Single line paragraphs",
624 "different الأربعاء\n",
633 {"Multiline. Single bidirectional paragraph, starts LTR, wrapped lines",
634 "abcשנבdefגקכghiעיןjklחלךmnoצמםpqrפרףstuדאוvwxה"
635 "סתyzטזץabcשנבdefגקכghiעיןjklחלךmnoצמםpqrפרףstuד"
636 "אוvwxהסתyzטזץabcשנבdefגקכghiעיןjklחלךmnoצמםpqr"
637 "פרףstuדאוvwxהסתyzטזץabcשנבdefגקכghiעיןjklחלךmno"
638 "צמםpqrפרףstuדאוvwxהסתyzטזץabcשנבdefגקכghiעיןjkl"
639 "חלךmnoצמםpqrפרףstuדאוvwxהסתyzטזץ",
648 {"Multiline. Single bidirectional paragraph, starts RTL, wrapped lines",
649 "שנבabcגקכdefעיןghiחלךjklצמםmnoפרףpqrדאוstuהסתv"
650 "wxטזץyzשנבabcגקכdefעיןghiחלךjklצמםmnoפרףpqrדאוs"
651 "tuהסתvwxטזץyzשנבabcגקכdefעיןghiחלךjklצמםmnoפרף"
652 "pqrדאוstuהסתvwxטזץyzשנבabcגקכdefעיןghiחלךjklצמם"
653 "mnoפרףpqrדאוstuהסתvwxטזץyzשנבabcגקכdefעיןghiחל"
654 "ךjklצמםmnoפרףpqrדאוstuהסתvwxטזץyz",
663 {"Testing complex characters. Arabic ligatures",
664 "الأَبْجَدِيَّة العَرَبِيَّة",
673 {"Testing complex characters. Latin ligatures",
683 {"Testing complex characters. Emoji",
684 "A👨‍👩‍👧‍👦B",
694 const unsigned int numberOfTests = 9u;
696 for(unsigned int index = 0; index < numberOfTests; ++index)
698 ToolkitTestApplication application;
699 if(!GetClosestCursorIndexTest(data[index]))
701 tet_result(TET_FAIL);
705 tet_result(TET_PASS);
709 int UtcDaliGetCursorPosition(void)
711 tet_infoline(" UtcDaliGetCursorPosition");
713 float visualX08[] = {5.f};
714 float visualY08[] = {0.f};
715 CharacterIndex logicalIndex08[] = {1u};
717 struct GetCursorPositionData data[] =
720 "Testing complex characters. Latin ligatures",
727 const unsigned int numberOfTests = 1u;
729 for(unsigned int index = 0; index < numberOfTests; ++index)
731 ToolkitTestApplication application;
732 if(!GetCursorPositionTest(data[index]))
734 tet_result(TET_FAIL);
738 tet_result(TET_PASS);
742 int UtcDaliFindSelectionIndices(void)
744 tet_infoline(" UtcDaliFindSelectionIndices");
746 float visualX01[] = {-100.f};
747 float visualY01[] = {-100.f};
748 bool found01[] = {false};
749 CharacterIndex startIndex01[] = {0};
750 CharacterIndex endIndex01[] = {0};
751 CharacterIndex noHitText01[] = {0};
753 float visualX02[] = {-100.f, 1000.f, 1000.f};
754 float visualY02[] = {-100.f, 12.f, 1000.f};
755 bool found02[] = {false, false, false};
756 CharacterIndex startIndex02[] = {0, 6u, 6u};
757 CharacterIndex endIndex02[] = {5u, 11u, 11u};
758 CharacterIndex noHitText02[] = {0, 11u, 11u};
760 float visualX03[] = {70.f};
761 float visualY03[] = {12.f};
762 bool found03[] = {true};
763 CharacterIndex startIndex03[] = {6u};
764 CharacterIndex endIndex03[] = {11u};
765 CharacterIndex noHitText03[] = {0u};
767 float visualX04[] = {131.f};
768 float visualY04[] = {12.f};
769 bool found04[] = {true};
770 CharacterIndex startIndex04[] = {12u};
771 CharacterIndex endIndex04[] = {16u};
772 CharacterIndex noHitText04[] = {0u};
774 float visualX05[] = {0.f};
775 float visualY05[] = {12.f};
776 bool found05[] = {true};
777 CharacterIndex startIndex05[] = {0};
778 CharacterIndex endIndex05[] = {1u};
779 CharacterIndex noHitText05[] = {0};
781 float visualX06[] = {10.f};
782 float visualY06[] = {12.f};
783 bool found06[] = {true};
784 CharacterIndex startIndex06[] = {0};
785 CharacterIndex endIndex06[] = {1u};
786 CharacterIndex noHitText06[] = {0u};
788 struct FindSelectionIndicesData data[] =
799 {"touch out of text's boundaries",
808 {"touch on the text",
817 {"touch on the new paragraph character at the end of line",
818 "Hello world demo\n",
826 {"touch on a white space character. is the unique character of the line",
835 {"touch on a white space character. is between two words",
845 const unsigned int numberOfTests = 6u;
847 for(unsigned int index = 0; index < numberOfTests; ++index)
849 ToolkitTestApplication application;
850 if(!FindSelectionIndicesTest(data[index]))
852 tet_result(TET_FAIL);
856 tet_result(TET_PASS);
860 int UtcDaliPrimaryCursorHeight(void)
862 tet_infoline(" UtcDaliPrimaryCursorHeight");
864 float heights[] = {19.f};
865 CharacterIndex logicalIndex[] = {1u};
867 struct PrimaryCursorHeightData data[] =
870 "Testing primary cursor height when line spacing is used.",
876 const unsigned int numberOfTests = 1u;
878 for(unsigned int index = 0; index < numberOfTests; ++index)
880 ToolkitTestApplication application;
881 if(!PrimaryCursorHeightTest(data[index]))
883 tet_result(TET_FAIL);
887 tet_result(TET_PASS);