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,
198 if(logicalCursorIndex != data.logicalIndex[index])
200 std::cout << " test " << index << " failed. Different logical cursor index : " << logicalCursorIndex << ", expected : " << data.logicalIndex[index] << std::endl;
203 if(isCharacterHit != data.isCharacterHit[index])
205 std::cout << " test " << index << " failed. Different character hit value : " << isCharacterHit << ", expected : " << data.isCharacterHit[index] << std::endl;
213 bool GetCursorPositionTest(const GetCursorPositionData& data)
215 std::cout << " testing : " << data.description << std::endl;
217 // 1) Create the model.
220 Size textArea(400.f, 600.f);
223 Vector<FontDescriptionRun> fontDescriptionRuns;
224 LayoutOptions options;
225 CreateTextModel(data.text,
235 Toolkit::DevelText::EllipsisPosition::END,
237 0.0f // characterSpacing
240 LogicalModelPtr logicalModel = textModel->mLogicalModel;
241 VisualModelPtr visualModel = textModel->mVisualModel;
243 GetCursorPositionParameters parameters;
244 parameters.visualModel = visualModel;
245 parameters.logicalModel = logicalModel;
246 parameters.metrics = metrics;
247 parameters.isMultiline = true;
249 for(unsigned int index = 0; index < data.numberOfTests; ++index)
251 CursorInfo cursorInfo;
252 parameters.logical = data.logicalIndex[index];
254 GetCursorPosition(parameters,
255 0.f, // Since this test case is not testing the primary cursor height, the default font line height can be set to 0.f.
258 if(floor(cursorInfo.primaryPosition.x) != data.visualX[index])
260 std::cout << " test " << index << " failed. Different 'x' cursor position : " << cursorInfo.primaryPosition.x << ", expected : " << data.visualX[index] << std::endl;
263 if(floor(cursorInfo.primaryPosition.y) != data.visualY[index])
265 std::cout << " test " << index << " failed. Different 'y' cursor position : " << cursorInfo.primaryPosition.y << ", expected : " << data.visualY[index] << std::endl;
273 bool FindSelectionIndicesTest(const FindSelectionIndicesData& data)
275 std::cout << " testing : " << data.description << std::endl;
277 // 1) Create the model.
280 Size textArea(400.f, 600.f);
283 Vector<FontDescriptionRun> fontDescriptionRuns;
284 LayoutOptions options;
285 CreateTextModel(data.text,
295 Toolkit::DevelText::EllipsisPosition::END,
297 0.0f // characterSpacing
300 LogicalModelPtr logicalModel = textModel->mLogicalModel;
301 VisualModelPtr visualModel = textModel->mVisualModel;
303 for(unsigned int index = 0; index < data.numberOfTests; ++index)
305 CharacterIndex startIndex = 0;
306 CharacterIndex endIndex = 0;
307 CharacterIndex noTextHitIndex = 0;
308 const bool found = FindSelectionIndices(visualModel,
317 if(found != data.found[index])
319 std::cout << " test " << index << " failed. Different found value : " << found << ", expected : " << data.found[index] << std::endl;
322 if(startIndex != data.startIndex[index])
324 std::cout << " test " << index << " failed. Different start index : " << startIndex << ", expected : " << data.startIndex[index] << std::endl;
327 if(endIndex != data.endIndex[index])
329 std::cout << " test " << index << " failed. Different end index : " << endIndex << ", expected : " << data.endIndex[index] << std::endl;
332 if(noTextHitIndex != data.noTextHitIndex[index])
334 std::cout << " test " << index << " failed. Different no text hit index : " << noTextHitIndex << ", expected : " << data.noTextHitIndex[index] << std::endl;
341 bool PrimaryCursorHeightTest(const PrimaryCursorHeightData& data)
343 std::cout << " testing : " << data.description << std::endl;
345 // 1) Create the model.
348 Size textArea(400.f, 600.f);
351 Vector<FontDescriptionRun> fontDescriptionRuns;
353 const std::string fontFamily("DejaVuSans");
355 // Set a known font description
356 FontDescriptionRun fontDescriptionRun1;
357 fontDescriptionRun1.characterRun.characterIndex = 0u;
358 fontDescriptionRun1.characterRun.numberOfCharacters = 13u;
359 fontDescriptionRun1.familyLength = fontFamily.size();
360 fontDescriptionRun1.familyName = new char[fontDescriptionRun1.familyLength];
361 memcpy(fontDescriptionRun1.familyName, fontFamily.c_str(), fontDescriptionRun1.familyLength);
362 fontDescriptionRun1.familyDefined = true;
363 fontDescriptionRun1.weightDefined = false;
364 fontDescriptionRun1.widthDefined = false;
365 fontDescriptionRun1.slantDefined = false;
366 fontDescriptionRun1.sizeDefined = true;
367 fontDescriptionRun1.size = 768u; //Font size = 12.0f (768/64 = 12)
369 fontDescriptionRuns.PushBack(fontDescriptionRun1);
371 LayoutOptions options;
372 CreateTextModel(data.text,
382 Toolkit::DevelText::EllipsisPosition::END,
383 50.0f, // lineSpacing
384 50.0f // characterSpacing
387 LogicalModelPtr logicalModel = textModel->mLogicalModel;
388 VisualModelPtr visualModel = textModel->mVisualModel;
390 GetCursorPositionParameters parameters;
391 parameters.visualModel = visualModel;
392 parameters.logicalModel = logicalModel;
393 parameters.metrics = metrics;
394 parameters.isMultiline = true;
396 for(unsigned int index = 0; index < data.numberOfTests; ++index)
398 CursorInfo cursorInfo;
399 parameters.logical = data.logicalIndex[index];
402 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
403 fontClient.SetDpi(93u, 93u);
405 char* pathNamePtr = get_current_dir_name();
406 const std::string pathName(pathNamePtr);
409 FontId fontID = fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSans.ttf");
411 Text::FontMetrics fontMetrics;
412 MetricsPtr mMetrics = Metrics::New(fontClient);
413 mMetrics->GetFontMetrics(fontID, fontMetrics);
414 float defaultFontLineHeight = (fontMetrics.ascender - fontMetrics.descender);
416 GetCursorPosition(parameters,
417 defaultFontLineHeight,
420 if(floor(cursorInfo.primaryCursorHeight) != data.heights[index])
422 std::cout << " test " << index << " failed. Different primaryCursorHeight : " << cursorInfo.primaryCursorHeight << ", expected : " << data.heights[index] << std::endl;
432 //////////////////////////////////////////////////////////
434 // UtcDaliGetClosestLine
435 // UtcDaliGetClosestCursorIndex
436 // UtcDaliGetCursorPosition
437 // UtcDaliFindSelectionIndices
438 // UtcDaliPrimaryCursorHeight
440 //////////////////////////////////////////////////////////
442 int UtcDaliGetClosestLine(void)
444 tet_infoline(" UtcDaliGetClosestLine");
446 float visualY01[] = {-4.f, 3.f, 1000.f};
447 LineIndex lineIndices01[] = {0, 0, 0};
448 bool isLineHit01[] = {false, false, false};
450 float visualY02[] = {-4.f, 3.f, 1000.f};
451 LineIndex lineIndices02[] = {0, 0, 0};
452 bool isLineHit02[] = {false, true, false};
454 float visualY03[] = {-4.f, 11.f, 30.f, 51.f, 68.f, 87.f, 109.f, 130.f};
455 LineIndex lineIndices03[] = {0, 0, 1u, 2u, 3u, 4u, 5u, 5u};
456 bool isLineHit03[] = {false, true, true, true, true, true, true, false};
458 struct GetClosestLineData data[] =
466 {"Single line text.",
473 "abcשנבdefגקכghiעיןjklחלךmnoצמםpqrפרףstuדאוvwxה"
474 "סתyzטזץabcשנבdefגקכghiעיןjklחלךmnoצמםpqrפרףstuד"
475 "אוvwxהסתyzטזץabcשנבdefגקכghiעיןjklחלךmnoצמםpqr"
476 "פרףstuדאוvwxהסתyzטזץabcשנבdefגקכghiעיןjklחלךmno"
477 "צמםpqrפרףstuדאוvwxהסתyzטזץabcשנבdefגקכghiעיןjkl"
478 "חלךmnoצמםpqrפרףstuדאוvwxהסתyzטזץ",
483 const unsigned int numberOfTests = 3u;
485 for(unsigned int index = 0; index < numberOfTests; ++index)
487 ToolkitTestApplication application;
488 if(!GetClosestLineTest(data[index]))
490 tet_result(TET_FAIL);
494 tet_result(TET_PASS);
498 int UtcDaliGetClosestCursorIndex(void)
500 tet_infoline(" UtcDaliGetClosestCursorIndex");
502 float visualX01[] = {-100.f};
503 float visualY01[] = {-100.f};
504 CharacterHitTest::Mode mode01[] = {CharacterHitTest::TAP};
505 CharacterIndex logicalIndex01[] = {0};
506 bool isCharacterHit01[] = {false};
508 float visualX02[] = {-100.f, 1000.f, 60.f, 79.f, 83.f, 148.f, 99.f};
509 float visualY02[] = {-100.f, 1000.f, 12.f, 12.f, 12.f, 12.f, 12.f};
510 CharacterHitTest::Mode mode02[] = {CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP};
511 CharacterIndex logicalIndex02[] = {0, 21u, 7u, 10u, 11u, 14u, 20u};
512 bool isCharacterHit02[] = {false, false, true, true, true, true, true};
514 float visualX03[] = {19.f, 104.f, -2.f, 127.f};
515 float visualY03[] = {12.f, 12.f, 12.f, 12.f};
516 CharacterHitTest::Mode mode03[] = {CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP};
517 CharacterIndex logicalIndex03[] = {3u, 13u, 0, 18u};
518 bool isCharacterHit03[] = {true, true, false, false};
525 // different الأربعاء \n
526 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};
527 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};
528 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};
529 CharacterIndex logicalIndex04[] = {0, 5u, 6u, 11u, 11u, 12u, 16u, 17u, 21u, 21u, 22u, 25u, 31u, 32u, 35u, 34u, 40u, 41u};
530 bool isCharacterHit04[] = {false, true, true, true, false, false, true, true, true, false, false, true, true, true, true, true, false};
533 // abcשנבdefג קכghiעיןjk lחלךmnoצמם pqrפרףstuד אוvwxה
535 // סתyz טזץabcשנבd efגקכghiעי ןjklחלךmno צמםpqrפרףstuד
536 // 93 100 110 120 130 139
537 // אוvwxהס תyzטזץabcש נבdefגקכgh iעיןjklחלך mnoצמםpqr
538 // 139 150 160 170 180 186
539 // פרףstuדאוvw xהסתyzטזץa bcשנבdefגק כghiעיןjkl חלךmno
540 // 186 190 200 210 220 233
541 // צמםp qrפרףstuדא וvwxהסתyzט זץabcשנבde fגקכghiעיןjkl
542 // 233 240 250 260 265
543 // חלךmnoצ מםpqrפרףst uדאוvwxהסת yzטזץ
545 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};
546 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};
547 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};
548 CharacterIndex logicalIndex05[] = {0, 10u, 19u, 28u, 41u, 44u, 45u, 49u, 59u, 66u, 78u, 89u, 90u, 97u, 107u, 117u, 126u, 134u, 135u, 147u, 155u, 163u, 172u, 180u, 181u, 185u, 192u, 204u, 213u, 222u, 223u, 234u, 242u, 252u, 265u};
549 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};
552 // שנבabcגקכd efעיןghiחל ךjklצמםmno פרףpqrדאוs tuהסתv
554 // wxטז ץyzשנבabcג קכdefעיןgh iחלךjklצמם mnoפרףpqrדאוs
555 // 93 100 110 120 130 139
556 // tuהסתvw xטזץyzשנבa bcגקכdefעי ןghiחלךjkl צמםmnoפרף
557 // 139 150 160 170 180 186
558 // pqrדאוstuהס תvwxטזץyzש נבabcגקכde fעיןghiחלך jklצמם
559 // 186 190 200 210 220 232
560 // mnoפ רףpqrדאוst uהסתvwxטזץ yzשנבabcגק כdefעיןghiחל
561 // 232 240 250 260 265
562 // ךjklצמםm noפרףpqrדא וstuהסתvwx טזץyz
564 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};
565 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};
566 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};
567 CharacterIndex logicalIndex06[] = {0, 10u, 19u, 28u, 39u, 44u, 45u, 49u, 59u, 66u, 78u, 89u, 90u, 97u, 108u, 117u, 126u, 134u, 135u, 145u, 155u, 163u, 174u, 180u, 181u, 186u, 194u, 204u, 214u, 222u, 224u, 235u, 243u, 252u, 265u};
568 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};
570 float visualX07[] = {395.f};
571 float visualY07[] = {12.f};
572 CharacterHitTest::Mode mode07[] = {CharacterHitTest::TAP};
573 CharacterIndex logicalIndex07[] = {1u};
574 bool isCharacterHit07[] = {true};
576 float visualX08[] = {7.f};
577 float visualY08[] = {12.f};
578 CharacterHitTest::Mode mode08[] = {CharacterHitTest::TAP};
579 CharacterIndex logicalIndex08[] = {1u};
580 bool isCharacterHit08[] = {true};
582 float visualX09[] = {9.f};
583 float visualY09[] = {12.f};
584 CharacterHitTest::Mode mode09[] = {CharacterHitTest::TAP};
585 CharacterIndex logicalIndex09[] = {1u};
586 bool isCharacterHit09[] = {true};
588 struct GetClosestCursorIndexData data[] =
600 {"Single line text.",
601 "Hello world שלום עולם",
610 {"Single line with ligatures",
611 "different الأربعاء",
620 {"Multiline. Single line paragraphs",
623 "different الأربعاء\n",
632 {"Multiline. Single bidirectional paragraph, starts LTR, wrapped lines",
633 "abcשנבdefגקכghiעיןjklחלךmnoצמםpqrפרףstuדאוvwxה"
634 "סתyzטזץabcשנבdefגקכghiעיןjklחלךmnoצמםpqrפרףstuד"
635 "אוvwxהסתyzטזץabcשנבdefגקכghiעיןjklחלךmnoצמםpqr"
636 "פרףstuדאוvwxהסתyzטזץabcשנבdefגקכghiעיןjklחלךmno"
637 "צמםpqrפרףstuדאוvwxהסתyzטזץabcשנבdefגקכghiעיןjkl"
638 "חלךmnoצמםpqrפרףstuדאוvwxהסתyzטזץ",
647 {"Multiline. Single bidirectional paragraph, starts RTL, wrapped lines",
648 "שנבabcגקכdefעיןghiחלךjklצמםmnoפרףpqrדאוstuהסתv"
649 "wxטזץyzשנבabcגקכdefעיןghiחלךjklצמםmnoפרףpqrדאוs"
650 "tuהסתvwxטזץyzשנבabcגקכdefעיןghiחלךjklצמםmnoפרף"
651 "pqrדאוstuהסתvwxטזץyzשנבabcגקכdefעיןghiחלךjklצמם"
652 "mnoפרףpqrדאוstuהסתvwxטזץyzשנבabcגקכdefעיןghiחל"
653 "ךjklצמםmnoפרףpqrדאוstuהסתvwxטזץyz",
662 {"Testing complex characters. Arabic ligatures",
663 "الأَبْجَدِيَّة العَرَبِيَّة",
672 {"Testing complex characters. Latin ligatures",
682 {"Testing complex characters. Emoji",
683 "A👨‍👩‍👧‍👦B",
693 const unsigned int numberOfTests = 9u;
695 for(unsigned int index = 0; index < numberOfTests; ++index)
697 ToolkitTestApplication application;
698 if(!GetClosestCursorIndexTest(data[index]))
700 tet_result(TET_FAIL);
704 tet_result(TET_PASS);
708 int UtcDaliGetCursorPosition(void)
710 tet_infoline(" UtcDaliGetCursorPosition");
712 float visualX08[] = {5.f};
713 float visualY08[] = {0.f};
714 CharacterIndex logicalIndex08[] = {1u};
716 struct GetCursorPositionData data[] =
719 "Testing complex characters. Latin ligatures",
726 const unsigned int numberOfTests = 1u;
728 for(unsigned int index = 0; index < numberOfTests; ++index)
730 ToolkitTestApplication application;
731 if(!GetCursorPositionTest(data[index]))
733 tet_result(TET_FAIL);
737 tet_result(TET_PASS);
741 int UtcDaliFindSelectionIndices(void)
743 tet_infoline(" UtcDaliFindSelectionIndices");
745 float visualX01[] = {-100.f};
746 float visualY01[] = {-100.f};
747 bool found01[] = {false};
748 CharacterIndex startIndex01[] = {0};
749 CharacterIndex endIndex01[] = {0};
750 CharacterIndex noHitText01[] = {0};
752 float visualX02[] = {-100.f, 1000.f, 1000.f};
753 float visualY02[] = {-100.f, 12.f, 1000.f};
754 bool found02[] = {false, false, false};
755 CharacterIndex startIndex02[] = {0, 6u, 6u};
756 CharacterIndex endIndex02[] = {5u, 11u, 11u};
757 CharacterIndex noHitText02[] = {0, 11u, 11u};
759 float visualX03[] = {70.f};
760 float visualY03[] = {12.f};
761 bool found03[] = {true};
762 CharacterIndex startIndex03[] = {6u};
763 CharacterIndex endIndex03[] = {11u};
764 CharacterIndex noHitText03[] = {0u};
766 float visualX04[] = {131.f};
767 float visualY04[] = {12.f};
768 bool found04[] = {true};
769 CharacterIndex startIndex04[] = {12u};
770 CharacterIndex endIndex04[] = {16u};
771 CharacterIndex noHitText04[] = {0u};
773 float visualX05[] = {0.f};
774 float visualY05[] = {12.f};
775 bool found05[] = {true};
776 CharacterIndex startIndex05[] = {0};
777 CharacterIndex endIndex05[] = {1u};
778 CharacterIndex noHitText05[] = {0};
780 float visualX06[] = {10.f};
781 float visualY06[] = {12.f};
782 bool found06[] = {true};
783 CharacterIndex startIndex06[] = {0};
784 CharacterIndex endIndex06[] = {1u};
785 CharacterIndex noHitText06[] = {0u};
787 struct FindSelectionIndicesData data[] =
798 {"touch out of text's boundaries",
807 {"touch on the text",
816 {"touch on the new paragraph character at the end of line",
817 "Hello world demo\n",
825 {"touch on a white space character. is the unique character of the line",
834 {"touch on a white space character. is between two words",
844 const unsigned int numberOfTests = 6u;
846 for(unsigned int index = 0; index < numberOfTests; ++index)
848 ToolkitTestApplication application;
849 if(!FindSelectionIndicesTest(data[index]))
851 tet_result(TET_FAIL);
855 tet_result(TET_PASS);
859 int UtcDaliPrimaryCursorHeight(void)
861 tet_infoline(" UtcDaliPrimaryCursorHeight");
863 float heights[] = {19.f};
864 CharacterIndex logicalIndex[] = {1u};
866 struct PrimaryCursorHeightData data[] =
869 "Testing primary cursor height when line spacing is used.",
875 const unsigned int numberOfTests = 1u;
877 for(unsigned int index = 0; index < numberOfTests; ++index)
879 ToolkitTestApplication application;
880 if(!PrimaryCursorHeightTest(data[index]))
882 tet_result(TET_FAIL);
886 tet_result(TET_PASS);