2 * Copyright (c) 2021 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/internal/text/cursor-helper-functions.h>
24 #include <dali-toolkit/dali-toolkit.h>
25 #include <toolkit-text-utils.h>
29 using namespace Toolkit;
32 // Tests the following functions.
34 // LineIndex GetClosestLine( VisualModelPtr visualModel,
37 // CharacterIndex GetClosestCursorIndex( VisualModelPtr visualModel,
38 // LogicalModelPtr logicalModel,
39 // MetricsPtr metrics,
42 // CharacterHitTest::Mode mode,
43 // bool& isCharacterHit )
45 //////////////////////////////////////////////////////////
49 const std::string DEFAULT_FONT_DIR( "/resources/fonts" );
50 const unsigned int DEFAULT_FONT_SIZE = 1152u;
52 struct GetClosestLineData
54 std::string description; ///< Description of the test.
55 std::string text; ///< Input text.
56 unsigned int numberOfTests; ///< The number of tests.
57 float* visualY; ///< The visual 'y' position for each test.
58 LineIndex* lineIndex; ///< The expected line index for each test.
59 bool* isLineHit; ///< The expected line hit value for each test.
62 struct GetClosestCursorIndexData
64 std::string description; ///< Description of the test.
65 std::string text; ///< Input text.
66 unsigned int numberOfTests; ///< The number of tests.
67 float* visualX; ///< The visual 'x' position for each test.
68 float* visualY; ///< The visual 'y' position for each test.
69 CharacterHitTest::Mode* mode; ///< The type of hit test.
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,
131 LogicalModelPtr logicalModel = textModel->mLogicalModel;
132 VisualModelPtr visualModel = textModel->mVisualModel;
134 for( unsigned int index = 0; index < data.numberOfTests; ++index )
136 bool isLineHit = false;
137 const LineIndex lineIndex = GetClosestLine( visualModel,
141 if( lineIndex != data.lineIndex[index] )
143 std::cout << " test " << index << " failed. Different line index : " << lineIndex << ", expected : " << data.lineIndex[index] << std::endl;
146 if( isLineHit != data.isLineHit[index] )
148 std::cout << " test " << index << " failed. Different line hit value : " << isLineHit << ", expected : " << data.isLineHit[index] << std::endl;
156 bool GetClosestCursorIndexTest( const GetClosestCursorIndexData& data )
158 std::cout << " testing : " << data.description << std::endl;
160 // 1) Create the model.
163 Size textArea(400.f, 600.f);
166 Vector<FontDescriptionRun> fontDescriptionRuns;
167 LayoutOptions options;
168 CreateTextModel( data.text,
178 Toolkit::DevelText::EllipsisPosition::END,
181 LogicalModelPtr logicalModel = textModel->mLogicalModel;
182 VisualModelPtr visualModel = textModel->mVisualModel;
184 for( unsigned int index = 0; index < data.numberOfTests; ++index )
186 bool isCharacterHit = false;
187 const CharacterIndex logicalCursorIndex = GetClosestCursorIndex( visualModel,
195 if( logicalCursorIndex != data.logicalIndex[index] )
197 std::cout << " test " << index << " failed. Different logical cursor index : " << logicalCursorIndex << ", expected : " << data.logicalIndex[index] << std::endl;
200 if( isCharacterHit != data.isCharacterHit[index] )
202 std::cout << " test " << index << " failed. Different character hit value : " << isCharacterHit << ", expected : " << data.isCharacterHit[index] << std::endl;
210 bool GetCursorPositionTest( const GetCursorPositionData& data )
212 std::cout << " testing : " << data.description << std::endl;
214 // 1) Create the model.
217 Size textArea(400.f, 600.f);
220 Vector<FontDescriptionRun> fontDescriptionRuns;
221 LayoutOptions options;
222 CreateTextModel( data.text,
232 Toolkit::DevelText::EllipsisPosition::END,
235 LogicalModelPtr logicalModel = textModel->mLogicalModel;
236 VisualModelPtr visualModel = textModel->mVisualModel;
238 GetCursorPositionParameters parameters;
239 parameters.visualModel = visualModel;
240 parameters.logicalModel = logicalModel;
241 parameters.metrics = metrics;
242 parameters.isMultiline = true;
244 for( unsigned int index = 0; index < data.numberOfTests; ++index )
246 CursorInfo cursorInfo;
247 parameters.logical = data.logicalIndex[index];
249 GetCursorPosition( parameters,
250 0.f,// Since this test case is not testing the primary cursor height, the default font line height can be set to 0.f.
253 if( floor(cursorInfo.primaryPosition.x) != data.visualX[index] )
255 std::cout << " test " << index << " failed. Different 'x' cursor position : " << cursorInfo.primaryPosition.x << ", expected : " << data.visualX[index] << std::endl;
258 if( floor(cursorInfo.primaryPosition.y) != data.visualY[index] )
260 std::cout << " test " << index << " failed. Different 'y' cursor position : " << cursorInfo.primaryPosition.y << ", expected : " << data.visualY[index] << std::endl;
268 bool FindSelectionIndicesTest( const FindSelectionIndicesData& data )
270 std::cout << " testing : " << data.description << std::endl;
272 // 1) Create the model.
275 Size textArea(400.f, 600.f);
278 Vector<FontDescriptionRun> fontDescriptionRuns;
279 LayoutOptions options;
280 CreateTextModel( data.text,
290 Toolkit::DevelText::EllipsisPosition::END,
293 LogicalModelPtr logicalModel = textModel->mLogicalModel;
294 VisualModelPtr visualModel = textModel->mVisualModel;
296 for( unsigned int index = 0; index < data.numberOfTests; ++index )
298 CharacterIndex startIndex = 0;
299 CharacterIndex endIndex = 0;
300 CharacterIndex noTextHitIndex = 0;
301 const bool found = FindSelectionIndices( visualModel,
310 if( found != data.found[index] )
312 std::cout << " test " << index << " failed. Different found value : " << found << ", expected : " << data.found[index] << std::endl;
315 if( startIndex != data.startIndex[index] )
317 std::cout << " test " << index << " failed. Different start index : " << startIndex << ", expected : " << data.startIndex[index] << std::endl;
320 if( endIndex != data.endIndex[index] )
322 std::cout << " test " << index << " failed. Different end index : " << endIndex << ", expected : " << data.endIndex[index] << std::endl;
325 if( noTextHitIndex != data.noTextHitIndex[index] )
327 std::cout << " test " << index << " failed. Different no text hit index : " << noTextHitIndex << ", expected : " << data.noTextHitIndex[index] << std::endl;
334 bool PrimaryCursorHeightTest( const PrimaryCursorHeightData& data )
336 std::cout << " testing : " << data.description << std::endl;
338 // 1) Create the model.
341 Size textArea(400.f, 600.f);
344 Vector<FontDescriptionRun> fontDescriptionRuns;
346 const std::string fontFamily( "DejaVuSans" );
348 // Set a known font description
349 FontDescriptionRun fontDescriptionRun1;
350 fontDescriptionRun1.characterRun.characterIndex = 0u;
351 fontDescriptionRun1.characterRun.numberOfCharacters = 13u;
352 fontDescriptionRun1.familyLength = fontFamily.size();
353 fontDescriptionRun1.familyName = new char[fontDescriptionRun1.familyLength];
354 memcpy( fontDescriptionRun1.familyName, fontFamily.c_str(), fontDescriptionRun1.familyLength );
355 fontDescriptionRun1.familyDefined = true;
356 fontDescriptionRun1.weightDefined = false;
357 fontDescriptionRun1.widthDefined = false;
358 fontDescriptionRun1.slantDefined = false;
359 fontDescriptionRun1.sizeDefined = true;
360 fontDescriptionRun1.size = 768u;//Font size = 12.0f (768/64 = 12)
362 fontDescriptionRuns.PushBack( fontDescriptionRun1 );
364 LayoutOptions options;
365 CreateTextModel( data.text,
375 Toolkit::DevelText::EllipsisPosition::END,
378 LogicalModelPtr logicalModel = textModel->mLogicalModel;
379 VisualModelPtr visualModel = textModel->mVisualModel;
381 GetCursorPositionParameters parameters;
382 parameters.visualModel = visualModel;
383 parameters.logicalModel = logicalModel;
384 parameters.metrics = metrics;
385 parameters.isMultiline = true;
387 for( unsigned int index = 0; index < data.numberOfTests; ++index )
389 CursorInfo cursorInfo;
390 parameters.logical = data.logicalIndex[index];
393 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
394 fontClient.SetDpi( 93u, 93u );
396 char* pathNamePtr = get_current_dir_name();
397 const std::string pathName( pathNamePtr );
400 FontId fontID = fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSans.ttf" );
402 Text::FontMetrics fontMetrics;
403 MetricsPtr mMetrics = Metrics::New(fontClient);
404 mMetrics->GetFontMetrics(fontID, fontMetrics);
405 float defaultFontLineHeight = (fontMetrics.ascender - fontMetrics.descender);
407 GetCursorPosition( parameters,
408 defaultFontLineHeight,
411 if( floor(cursorInfo.primaryCursorHeight) != data.heights[index] )
413 std::cout << " test " << index << " failed. Different primaryCursorHeight : " << cursorInfo.primaryCursorHeight << ", expected : " << data.heights[index] << std::endl;
423 //////////////////////////////////////////////////////////
425 // UtcDaliGetClosestLine
426 // UtcDaliGetClosestCursorIndex
427 // UtcDaliGetCursorPosition
428 // UtcDaliFindSelectionIndices
429 // UtcDaliPrimaryCursorHeight
431 //////////////////////////////////////////////////////////
433 int UtcDaliGetClosestLine(void)
435 tet_infoline(" UtcDaliGetClosestLine");
437 float visualY01[] = { -4.f, 3.f, 1000.f };
438 LineIndex lineIndices01[] = { 0, 0, 0 };
439 bool isLineHit01[] = { false, false, false };
441 float visualY02[] = { -4.f, 3.f, 1000.f };
442 LineIndex lineIndices02[] = { 0, 0, 0 };
443 bool isLineHit02[] = { false, true, false };
445 float visualY03[] = { -4.f, 11.f, 30.f, 51.f, 68.f, 87.f, 109.f, 130.f };
446 LineIndex lineIndices03[] = { 0, 0, 1u, 2u, 3u, 4u, 5u, 5u };
447 bool isLineHit03[] = { false, true, true, true, true, true, true, false };
449 struct GetClosestLineData data[] =
469 "abcשנבdefגקכghiעיןjklחלךmnoצמםpqrפרףstuדאוvwxה"
470 "סתyzטזץabcשנבdefגקכghiעיןjklחלךmnoצמםpqrפרףstuד"
471 "אוvwxהסתyzטזץabcשנבdefגקכghiעיןjklחלךmnoצמםpqr"
472 "פרףstuדאוvwxהסתyzטזץabcשנבdefגקכghiעיןjklחלךmno"
473 "צמםpqrפרףstuדאוvwxהסתyzטזץabcשנבdefגקכghiעיןjkl"
474 "חלךmnoצמםpqrפרףstuדאוvwxהסתyzטזץ",
481 const unsigned int numberOfTests = 3u;
483 for( unsigned int index = 0; index < numberOfTests; ++index )
485 ToolkitTestApplication application;
486 if( !GetClosestLineTest( data[index] ) )
488 tet_result(TET_FAIL);
492 tet_result(TET_PASS);
496 int UtcDaliGetClosestCursorIndex(void)
498 tet_infoline(" UtcDaliGetClosestCursorIndex");
500 float visualX01[] = { -100.f };
501 float visualY01[] = { -100.f };
502 CharacterHitTest::Mode mode01[] = { CharacterHitTest::TAP };
503 CharacterIndex logicalIndex01[] = { 0 };
504 bool isCharacterHit01[] = { false };
506 float visualX02[] = { -100.f, 1000.f, 60.f, 79.f, 83.f, 148.f, 99.f };
507 float visualY02[] = { -100.f, 1000.f, 12.f, 12.f, 12.f, 12.f, 12.f };
508 CharacterHitTest::Mode mode02[] = { CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP };
509 CharacterIndex logicalIndex02[] = { 0, 21u, 7u, 10u, 10u, 14u, 12u };
510 bool isCharacterHit02[] = { false, false, true, true, true, true, true };
512 float visualX03[] = { 19.f, 104.f, -2.f, 127.f };
513 float visualY03[] = { 12.f, 12.f, 12.f, 12.f };
514 CharacterHitTest::Mode mode03[] = { CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP };
515 CharacterIndex logicalIndex03[] = { 3u, 13u, 0, 18u };
516 bool isCharacterHit03[] = { true, true, false, false };
523 // different الأربعاء \n
524 float visualX04[] = { -100.f, 40.f, 44.f, 85.f, 500.f,
525 500.f, 367.f, 359.f, 329.f, -100.f,
526 -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,
528 30.f, 30.f, 30.f, 30.f, 30.f,
529 50.f, 50.f, 50.f, 50.f, 50.f, 50.f, 50.f };
530 CharacterHitTest::Mode mode04[] = { CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP,
531 CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP,
532 CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP };
533 CharacterIndex logicalIndex04[] = { 0, 5u, 6u, 11u, 11u,
534 12u, 16u, 17u, 21u, 21u,
535 22u, 25u, 30u, 32u, 35u, 34u, 40u,
537 bool isCharacterHit04[] = { false, true, true, true, false,
538 false, true, true, true, false,
539 false, true, true, true, true, true, false };
542 // abcשנבdefג קכghiעיןjk lחלךmnoצמם pqrפרףstuד אוvwxה
544 // סתyz טזץabcשנבd efגקכghiעי ןjklחלךmno צמםpqrפרףstuד
545 // 93 100 110 120 130 139
546 // אוvwxהס תyzטזץabcש נבdefגקכgh iעיןjklחלך mnoצמםpqr
547 // 139 150 160 170 180 186
548 // פרףstuדאוvw xהסתyzטזץa bcשנבdefגק כghiעיןjkl חלךmno
549 // 186 190 200 210 220 233
550 // צמםp qrפרףstuדא וvwxהסתyzט זץabcשנבde fגקכghiעיןjkl
551 // 233 240 250 260 265
552 // חלךmnoצ מםpqrפרףst uדאוvwxהסת yzטזץ
554 float visualX05[] = { -100.f, 96.f, 155.f, 250.f, 344.f, 500.f,
555 -100.f, 36.f, 124.f, 190.f, 280.f, 500.f,
556 -100.f, 56.f, 158.f, 237.f, 303.f, 500.f,
557 -100.f, 98.f, 184.f, 261.f, 337.f, 500.f,
558 -100.f, 40.f, 113.f, 223.f, 302.f, 500.f,
559 -100.f, 82.f, 160.f, 253.f, 500.f };
560 float visualY05[] = { -100.f, 12.f, 12.f, 12.f, 12.f, 12.f,
561 30.f, 30.f, 30.f, 30.f, 30.f, 30.f,
562 50.f, 50.f, 50.f, 50.f, 50.f, 50.f,
563 67.f, 67.f, 67.f, 67.f, 67.f, 67.f,
564 87.f, 87.f, 87.f, 87.f, 87.f, 87.f,
565 107.f, 107.f, 107.f, 107.f, 107.f };
566 CharacterHitTest::Mode mode05[] = { CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP,
567 CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP,
568 CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP,
569 CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP,
570 CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP,
571 CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP };
572 CharacterIndex logicalIndex05[] = { 0, 10u, 19u, 28u, 39u, 44u,
573 45u, 48u, 59u, 66u, 78u, 87u,
574 89u, 96u, 106u, 115u, 124u, 133u,
575 134u, 145u, 154u, 162u, 171u, 179u,
576 180u, 184u, 191u, 203u, 212u,
577 221u, 222u, 233u, 241u, 251u, 265u };
578 bool isCharacterHit05[] = { false, true, true, true, true, false,
579 false, true, true, true, true, false,
580 false, true, true, true, true, false,
581 false, true, true, true, true, false,
582 false, true, true, true, true, false,
583 false, true, true, true, false };
586 // שנבabcגקכd efעיןghiחל ךjklצמםmno פרףpqrדאוs tuהסתv
588 // wxטז ץyzשנבabcג קכdefעיןgh iחלךjklצמם mnoפרףpqrדאוs
589 // 93 100 110 120 130 139
590 // tuהסתvw xטזץyzשנבa bcגקכdefעי ןghiחלךjkl צמםmnoפרף
591 // 139 150 160 170 180 186
592 // pqrדאוstuהס תvwxטזץyzש נבabcגקכde fעיןghiחלך jklצמם
593 // 186 190 200 210 220 232
594 // mnoפ רףpqrדאוst uהסתvwxטזץ yzשנבabcגק כdefעיןghiחל
595 // 232 240 250 260 265
596 // ךjklצמםm noפרףpqrדא וstuהסתvwx טזץyz
598 float visualX06[] = { 500.f, 307.f, 237.f, 148.f, 55.f, -100.f,
599 500.f, 362.f, 276.f, 213.f, 121.f, -100.f,
600 500.f, 344.f, 238.f, 167.f, 93.f, -100.f,
601 500.f, 306.f, 216.f, 142.f, 58.f, -100.f,
602 500.f, 355.f, 279.f, 182.f, 92.f, -100.f,
603 500.f, 326.f, 238.f, 150.f, -100.f };
604 float visualY06[] = { -100.f, 12.f, 12.f, 12.f, 12.f, 12.f,
605 30.f, 30.f, 30.f, 30.f, 30.f, 30.f,
606 50.f, 50.f, 50.f, 50.f, 50.f, 50.f,
607 67.f, 67.f, 67.f, 67.f, 67.f, 67.f,
608 87.f, 87.f, 87.f, 87.f, 87.f, 87.f,
609 107.f, 107.f, 107.f, 107.f, 107.f };
610 CharacterHitTest::Mode mode06[] = { CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP,
611 CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP,
612 CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP,
613 CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP,
614 CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP,
615 CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP };
616 CharacterIndex logicalIndex06[] = { 0, 11u, 19u, 28u, 39u, 44u,
617 45u, 48u, 57u, 65u, 78u, 87u,
618 89u, 96u, 107u, 114u, 124u, 133u,
619 134u, 144u, 154u, 162u, 171u, 178u,
620 179u, 185u, 192u, 203u, 212u, 221u,
621 222u, 232u, 240u, 251u, 265u };
622 bool isCharacterHit06[] = { false, true, true, true, true, false,
623 false, true, true, true, true, false,
624 false, true, true, true, true, false,
625 false, true, true, true, true, false,
626 false, true, true, true, true, false,
627 false, true, true, true, false };
629 float visualX07[] = { 395.f };
630 float visualY07[] = { 12.f };
631 CharacterHitTest::Mode mode07[] = { CharacterHitTest::TAP };
632 CharacterIndex logicalIndex07[] = { 1u };
633 bool isCharacterHit07[] = { true };
635 float visualX08[] = { 7.f };
636 float visualY08[] = { 12.f };
637 CharacterHitTest::Mode mode08[] = { CharacterHitTest::TAP };
638 CharacterIndex logicalIndex08[] = { 1u };
639 bool isCharacterHit08[] = { true };
641 struct GetClosestCursorIndexData data[] =
655 "Hello world שלום עולם",
664 "Single line with ligatures",
665 "different الأربعاء",
674 "Multiline. Single line paragraphs",
677 "different الأربعاء\n",
686 "Multiline. Single bidirectional paragraph, starts LTR, wrapped lines",
687 "abcשנבdefגקכghiעיןjklחלךmnoצמםpqrפרףstuדאוvwxה"
688 "סתyzטזץabcשנבdefגקכghiעיןjklחלךmnoצמםpqrפרףstuד"
689 "אוvwxהסתyzטזץabcשנבdefגקכghiעיןjklחלךmnoצמםpqr"
690 "פרףstuדאוvwxהסתyzטזץabcשנבdefגקכghiעיןjklחלךmno"
691 "צמםpqrפרףstuדאוvwxהסתyzטזץabcשנבdefגקכghiעיןjkl"
692 "חלךmnoצמםpqrפרףstuדאוvwxהסתyzטזץ",
701 "Multiline. Single bidirectional paragraph, starts RTL, wrapped lines",
702 "שנבabcגקכdefעיןghiחלךjklצמםmnoפרףpqrדאוstuהסתv"
703 "wxטזץyzשנבabcגקכdefעיןghiחלךjklצמםmnoפרףpqrדאוs"
704 "tuהסתvwxטזץyzשנבabcגקכdefעיןghiחלךjklצמםmnoפרף"
705 "pqrדאוstuהסתvwxטזץyzשנבabcגקכdefעיןghiחלךjklצמם"
706 "mnoפרףpqrדאוstuהסתvwxטזץyzשנבabcגקכdefעיןghiחל"
707 "ךjklצמםmnoפרףpqrדאוstuהסתvwxטזץyz",
716 "Testing complex characters. Arabic ligatures",
717 "الأَبْجَدِيَّة العَرَبِيَّة",
726 "Testing complex characters. Latin ligatures",
736 const unsigned int numberOfTests = 8u;
738 for( unsigned int index = 0; index < numberOfTests; ++index )
740 ToolkitTestApplication application;
741 if( !GetClosestCursorIndexTest( data[index] ) )
743 tet_result(TET_FAIL);
747 tet_result(TET_PASS);
751 int UtcDaliGetCursorPosition(void)
753 tet_infoline(" UtcDaliGetCursorPosition");
755 float visualX08[] = { 5.f };
756 float visualY08[] = { 0.f };
757 CharacterIndex logicalIndex08[] = { 1u };
759 struct GetCursorPositionData data[] =
762 "Testing complex characters. Latin ligatures",
770 const unsigned int numberOfTests = 1u;
772 for( unsigned int index = 0; index < numberOfTests; ++index )
774 ToolkitTestApplication application;
775 if( !GetCursorPositionTest( data[index] ) )
777 tet_result(TET_FAIL);
781 tet_result(TET_PASS);
785 int UtcDaliFindSelectionIndices(void)
787 tet_infoline(" UtcDaliFindSelectionIndices");
789 float visualX01[] = { -100.f };
790 float visualY01[] = { -100.f };
791 bool found01[] = { false };
792 CharacterIndex startIndex01[] = { 0 };
793 CharacterIndex endIndex01[] = { 0 };
794 CharacterIndex noHitText01[] = { 0 };
796 float visualX02[] = { -100.f, 1000.f, 1000.f };
797 float visualY02[] = { -100.f, 12.f, 1000.f };
798 bool found02[] = { false, false, false };
799 CharacterIndex startIndex02[] = { 0, 6u, 6u };
800 CharacterIndex endIndex02[] = { 5u, 11u, 11u };
801 CharacterIndex noHitText02[] = { 0, 11u, 11u };
803 float visualX03[] = { 70.f };
804 float visualY03[] = { 12.f };
805 bool found03[] = { true };
806 CharacterIndex startIndex03[] = { 6u };
807 CharacterIndex endIndex03[] = { 11u };
808 CharacterIndex noHitText03[] = { 0u };
810 float visualX04[] = { 131.f };
811 float visualY04[] = { 12.f };
812 bool found04[] = { true };
813 CharacterIndex startIndex04[] = { 12u };
814 CharacterIndex endIndex04[] = { 16u };
815 CharacterIndex noHitText04[] = { 0u };
817 float visualX05[] = { 0.f };
818 float visualY05[] = { 12.f };
819 bool found05[] = { true };
820 CharacterIndex startIndex05[] = { 0 };
821 CharacterIndex endIndex05[] = { 1u };
822 CharacterIndex noHitText05[] = { 0 };
824 float visualX06[] = { 10.f };
825 float visualY06[] = { 12.f };
826 bool found06[] = { true };
827 CharacterIndex startIndex06[] = { 0 };
828 CharacterIndex endIndex06[] = { 1u };
829 CharacterIndex noHitText06[] = { 0u };
831 struct FindSelectionIndicesData data[] =
845 "touch out of text's boundaries",
867 "touch on the new paragraph character at the end of line",
868 "Hello world demo\n",
878 "touch on a white space character. is the unique character of the line",
889 "touch on a white space character. is between two words",
900 const unsigned int numberOfTests = 6u;
902 for( unsigned int index = 0; index < numberOfTests; ++index )
904 ToolkitTestApplication application;
905 if( !FindSelectionIndicesTest( data[index] ) )
907 tet_result(TET_FAIL);
911 tet_result(TET_PASS);
915 int UtcDaliPrimaryCursorHeight(void)
917 tet_infoline(" UtcDaliPrimaryCursorHeight");
919 float heights[] = { 19.f };
920 CharacterIndex logicalIndex[] = { 1u };
922 struct PrimaryCursorHeightData data[] =
925 "Testing primary cursor height when line spacing is used.",
932 const unsigned int numberOfTests = 1u;
934 for( unsigned int index = 0; index < numberOfTests; ++index )
936 ToolkitTestApplication application;
937 if( !PrimaryCursorHeightTest( data[index] ) )
939 tet_result(TET_FAIL);
943 tet_result(TET_PASS);