ImageVisual Action::Reload added
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit-internal / utc-Dali-Text-Cursor.cpp
1 /*
2  * Copyright (c) 2017 Samsung Electronics Co., Ltd.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  *
16  */
17
18 #include <iostream>
19
20 #include <stdlib.h>
21
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>
26
27
28 using namespace Dali;
29 using namespace Toolkit;
30 using namespace Text;
31
32 // Tests the following functions.
33 //
34 // LineIndex GetClosestLine( VisualModelPtr visualModel,
35 //                           float visualY,
36 //                           bool& isLineHit )
37 // CharacterIndex GetClosestCursorIndex( VisualModelPtr visualModel,
38 //                                       LogicalModelPtr logicalModel,
39 //                                       MetricsPtr metrics,
40 //                                       float visualX,
41 //                                       float visualY,
42 //                                       CharacterHitTest::Mode mode,
43 //                                       bool& isCharacterHit )
44
45 //////////////////////////////////////////////////////////
46
47 namespace
48 {
49
50 struct GetClosestLineData
51 {
52   std::string    description;                    ///< Description of the test.
53   std::string    text;                           ///< Input text.
54   unsigned int   numberOfTests;                  ///< The number of tests.
55   float*         visualY;                        ///< The visual 'y' position for each test.
56   LineIndex*     lineIndex;                      ///< The expected line index for each test.
57   bool*          isLineHit;                      ///< The expected line hit value for each test.
58 };
59
60 struct GetClosestCursorIndexData
61 {
62   std::string             description;           ///< Description of the test.
63   std::string             text;                  ///< Input text.
64   unsigned int            numberOfTests;         ///< The number of tests.
65   float*                  visualX;               ///< The visual 'x' position for each test.
66   float*                  visualY;               ///< The visual 'y' position for each test.
67   CharacterHitTest::Mode* mode;                  ///< The type of hit test.
68   CharacterIndex*         logicalIndex;          ///< The expected logical cursor index for each test.
69   bool*                   isCharacterHit;        ///< The expected character hit value for each test.
70 };
71
72 struct GetCursorPositionData
73 {
74   std::string     description;                    ///< Description of the test.
75   std::string     text;                           ///< Input text.
76   unsigned int    numberOfTests;                  ///< The number of tests.
77   CharacterIndex* logicalIndex;                   ///< The logical cursor index for each test.
78   float*          visualX;                        ///< The expected visual 'x' position for each test.
79   float*          visualY;                        ///< The expected visual 'y' position for each test.
80 };
81
82 struct FindSelectionIndicesData
83 {
84   std::string     description;                    ///< Description of the test.
85   std::string     text;                           ///< Input text.
86   unsigned int    numberOfTests;                  ///< The number of tests.
87   float*          visualX;                        ///< The visual 'x' position for each test.
88   float*          visualY;                        ///< The visual 'y' position for each test.
89   bool*           found;                          ///< Whether selection indices are found.
90   CharacterIndex* startIndex;                     ///< The expected start cursor index for each test.
91   CharacterIndex* endIndex;                       ///< The expected end cursor index for each test.
92   CharacterIndex* noTextHitIndex;                 ///< The expected character index when there is no hit.
93 };
94
95 bool GetClosestLineTest( const GetClosestLineData& data )
96 {
97   std::cout << "  testing : " << data.description << std::endl;
98
99   // 1) Create the model.
100   LogicalModelPtr logicalModel;
101   VisualModelPtr visualModel;
102   MetricsPtr metrics;
103   Size textArea(400.f, 600.f);
104   Size layoutSize;
105
106   Vector<FontDescriptionRun> fontDescriptionRuns;
107   LayoutOptions options;
108   CreateTextModel( data.text,
109                    textArea,
110                    fontDescriptionRuns,
111                    options,
112                    layoutSize,
113                    logicalModel,
114                    visualModel,
115                    metrics );
116
117   for( unsigned int index = 0; index < data.numberOfTests; ++index )
118   {
119     bool isLineHit = false;
120     const LineIndex lineIndex = GetClosestLine( visualModel,
121                                                 data.visualY[index],
122                                                 isLineHit );
123
124     if( lineIndex != data.lineIndex[index] )
125     {
126       std::cout << "  test " << index << " failed. Different line index : " << lineIndex << ", expected : " << data.lineIndex[index] << std::endl;
127       return false;
128     }
129     if( isLineHit != data.isLineHit[index] )
130     {
131       std::cout << "  test " << index << " failed. Different line hit value : " << isLineHit << ", expected : " << data.isLineHit[index] << std::endl;
132       return false;
133     }
134   }
135
136   return true;
137 }
138
139 bool GetClosestCursorIndexTest( const GetClosestCursorIndexData& data )
140 {
141   std::cout << "  testing : " << data.description << std::endl;
142
143   // 1) Create the model.
144   LogicalModelPtr logicalModel;
145   VisualModelPtr visualModel;
146   MetricsPtr metrics;
147   Size textArea(400.f, 600.f);
148   Size layoutSize;
149
150   Vector<FontDescriptionRun> fontDescriptionRuns;
151   LayoutOptions options;
152   CreateTextModel( data.text,
153                    textArea,
154                    fontDescriptionRuns,
155                    options,
156                    layoutSize,
157                    logicalModel,
158                    visualModel,
159                    metrics );
160
161   for( unsigned int index = 0; index < data.numberOfTests; ++index )
162   {
163     bool isCharacterHit = false;
164     const CharacterIndex logicalCursorIndex = GetClosestCursorIndex( visualModel,
165                                                                      logicalModel,
166                                                                      metrics,
167                                                                      data.visualX[index],
168                                                                      data.visualY[index],
169                                                                      data.mode[index],
170                                                                      isCharacterHit );
171
172     if( logicalCursorIndex != data.logicalIndex[index] )
173     {
174       std::cout << "  test " << index << " failed. Different logical cursor index : " << logicalCursorIndex << ", expected : " << data.logicalIndex[index] << std::endl;
175       return false;
176     }
177     if( isCharacterHit != data.isCharacterHit[index] )
178     {
179       std::cout << "  test " << index << " failed. Different character hit value : " << isCharacterHit << ", expected : " << data.isCharacterHit[index] << std::endl;
180       return false;
181     }
182   }
183
184   return true;
185 }
186
187 bool GetCursorPositionTest( const GetCursorPositionData& data )
188 {
189   std::cout << "  testing : " << data.description << std::endl;
190
191   // 1) Create the model.
192   LogicalModelPtr logicalModel;
193   VisualModelPtr visualModel;
194   MetricsPtr metrics;
195   Size textArea(400.f, 600.f);
196   Size layoutSize;
197
198   Vector<FontDescriptionRun> fontDescriptionRuns;
199   LayoutOptions options;
200   CreateTextModel( data.text,
201                    textArea,
202                    fontDescriptionRuns,
203                    options,
204                    layoutSize,
205                    logicalModel,
206                    visualModel,
207                    metrics );
208
209   GetCursorPositionParameters parameters;
210   parameters.visualModel = visualModel;
211   parameters.logicalModel = logicalModel;
212   parameters.metrics = metrics;
213   parameters.isMultiline = true;
214
215   for( unsigned int index = 0; index < data.numberOfTests; ++index )
216   {
217     CursorInfo cursorInfo;
218     parameters.logical = data.logicalIndex[index];
219
220     GetCursorPosition( parameters,
221                        cursorInfo );
222
223     if( cursorInfo.primaryPosition.x != data.visualX[index] )
224     {
225       std::cout << "  test " << index << " failed. Different 'x' cursor position : " << cursorInfo.primaryPosition.x << ", expected : " << data.visualX[index] << std::endl;
226       return false;
227     }
228     if( cursorInfo.primaryPosition.y != data.visualY[index] )
229     {
230       std::cout << "  test " << index << " failed. Different 'y' cursor position : " << cursorInfo.primaryPosition.y << ", expected : " << data.visualY[index] << std::endl;
231        return false;
232     }
233   }
234
235   return true;
236 }
237
238 bool FindSelectionIndicesTest( const FindSelectionIndicesData& data )
239 {
240   std::cout << "  testing : " << data.description << std::endl;
241
242   // 1) Create the model.
243   LogicalModelPtr logicalModel;
244   VisualModelPtr visualModel;
245   MetricsPtr metrics;
246   Size textArea(400.f, 600.f);
247   Size layoutSize;
248
249   Vector<FontDescriptionRun> fontDescriptionRuns;
250   LayoutOptions options;
251   CreateTextModel( data.text,
252                    textArea,
253                    fontDescriptionRuns,
254                    options,
255                    layoutSize,
256                    logicalModel,
257                    visualModel,
258                    metrics );
259
260   for( unsigned int index = 0; index < data.numberOfTests; ++index )
261   {
262     CharacterIndex startIndex = 0;
263     CharacterIndex endIndex = 0;
264     CharacterIndex noTextHitIndex = 0;
265     const bool found = FindSelectionIndices( visualModel,
266                                              logicalModel,
267                                              metrics,
268                                              data.visualX[index],
269                                              data.visualY[index],
270                                              startIndex,
271                                              endIndex,
272                                              noTextHitIndex );
273
274     if( found != data.found[index] )
275     {
276       std::cout << "  test " << index << " failed. Different found value : " << found << ", expected : " <<  data.found[index] << std::endl;
277       return false;
278     }
279     if( startIndex != data.startIndex[index] )
280     {
281       std::cout << "  test " << index << " failed. Different start index : " << startIndex << ", expected : " << data.startIndex[index] << std::endl;
282       return false;
283     }
284     if( endIndex != data.endIndex[index] )
285     {
286       std::cout << "  test " << index << " failed. Different end index : " << endIndex << ", expected : " << data.endIndex[index] << std::endl;
287       return false;
288     }
289     if( noTextHitIndex != data.noTextHitIndex[index] )
290     {
291       std::cout << "  test " << index << " failed. Different no text hit index : " << noTextHitIndex << ", expected : " << data.noTextHitIndex[index] << std::endl;
292       return false;
293     }
294   }
295   return true;
296 }
297
298 } // namespace
299
300 //////////////////////////////////////////////////////////
301 //
302 // UtcDaliGetClosestLine
303 // UtcDaliGetClosestCursorIndex
304 //
305 //////////////////////////////////////////////////////////
306
307 int UtcDaliGetClosestLine(void)
308 {
309   tet_infoline(" UtcDaliGetClosestLine");
310
311   float visualY01[] = { -4.f, 3.f, 1000.f };
312   LineIndex lineIndices01[] = { 0, 0, 0 };
313   bool isLineHit01[] = { false, false, false };
314
315   float visualY02[] = { -4.f, 3.f, 1000.f };
316   LineIndex lineIndices02[] = { 0, 0, 0 };
317   bool isLineHit02[] = { false, true, false };
318
319   float visualY03[] = { -4.f, 11.f, 30.f, 51.f, 68.f, 87.f, 109.f, 130.f };
320   LineIndex lineIndices03[] = { 0, 0, 1u, 2u, 3u, 4u, 5u, 5u };
321   bool isLineHit03[] = { false, true, true, true, true, true, true, false };
322
323   struct GetClosestLineData data[] =
324   {
325     {
326       "void text.",
327       "",
328       3u,
329       visualY01,
330       lineIndices01,
331       isLineHit01
332     },
333     {
334       "Single line text.",
335       "hello world",
336       3u,
337       visualY02,
338       lineIndices02,
339       isLineHit02
340     },
341     {
342       "Multi-line text.",
343       "abcשנבdefגקכghiעיןjklחלךmnoצמםpqrפרףstuדאוvwxה"
344       "סתyzטזץabcשנבdefגקכghiעיןjklחלךmnoצמםpqrפרףstuד"
345       "אוvwxהסתyzטזץabcשנבdefגקכghiעיןjklחלךmnoצמםpqr"
346       "פרףstuדאוvwxהסתyzטזץabcשנבdefגקכghiעיןjklחלךmno"
347       "צמםpqrפרףstuדאוvwxהסתyzטזץabcשנבdefגקכghiעיןjkl"
348       "חלךmnoצמםpqrפרףstuדאוvwxהסתyzטזץ",
349       8u,
350       visualY03,
351       lineIndices03,
352       isLineHit03
353     }
354   };
355   const unsigned int numberOfTests = 3u;
356
357   for( unsigned int index = 0; index < numberOfTests; ++index )
358   {
359     ToolkitTestApplication application;
360     if( !GetClosestLineTest( data[index] ) )
361     {
362       tet_result(TET_FAIL);
363     }
364   }
365
366   tet_result(TET_PASS);
367   END_TEST;
368 }
369
370 int UtcDaliGetClosestCursorIndex(void)
371 {
372   tet_infoline(" UtcDaliGetClosestCursorIndex");
373
374   float visualX01[] = { -100.f };
375   float visualY01[] = { -100.f };
376   CharacterHitTest::Mode mode01[] = { CharacterHitTest::TAP };
377   CharacterIndex logicalIndex01[] = { 0 };
378   bool isCharacterHit01[] = { false };
379
380   float visualX02[] = { -100.f, 1000.f, 60.f, 79.f, 83.f, 148.f, 99.f };
381   float visualY02[] = { -100.f, 1000.f, 12.f, 12.f, 12.f, 12.f, 12.f };
382   CharacterHitTest::Mode mode02[] = { CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP };
383   CharacterIndex logicalIndex02[] = { 0, 21u, 7u, 10u, 11u, 13u, 20u };
384   bool isCharacterHit02[] = { false, false, true, true, true, true, true  };
385
386   float visualX03[] = { 19.f, 104.f, -2.f, 127.f };
387   float visualY03[] = { 12.f, 12.f, 12.f, 12.f };
388   CharacterHitTest::Mode mode03[] = { CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP };
389   CharacterIndex logicalIndex03[] = { 3u, 12u, 0, 18u };
390   bool isCharacterHit03[] = { true, true, false, false };
391
392   //  0     5 _ 6     11  12
393   //   Hello     world  \n
394   // 12    16 _ 17    21   22
395   //   שלום       עולם  \n
396   // 22         31_32      40  41
397   //   different     الأربعاء  \n
398   float visualX04[] = { -100.f, 40.f, 44.f, 85.f, 500.f,
399                          500.f, 367.f, 359.f, 329.f, -100.f,
400                         -100.f, 19.f, 64.f, 72.f, 104.f, 111.f, 500.f};
401   float visualY04[] = { -100.f, 12.f, 12.f, 12.f, 12.f,
402                           30.f, 30.f, 30.f, 30.f, 30.f,
403                           50.f, 50.f, 50.f, 50.f, 50.f, 50.f, 50.f };
404   CharacterHitTest::Mode mode04[] = { CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP,
405                                       CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP,
406                                       CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP };
407   CharacterIndex logicalIndex04[] = {    0,  5u,  6u, 11u, 11u,
408                                        12u, 16u, 17u, 21u, 21u,
409                                        22u, 25u, 31u, 32u, 34u, 40u, 40u,
410                                        41u };
411   bool isCharacterHit04[] = { false, true, true, false, false,
412                               false, true, true, true, false,
413                               false, true, true, true, true, true, false };
414
415   //   0           10           20            30           40      46
416   //    abcשנבdefג   קכghiעיןjk   lחלךmnoצמם   pqrפרףstuד   אוvwxה
417   //  46     50            60            70           80               93
418   //    סתyz   טזץabcשנבd    efגקכghiעי    ןjklחלךmno   צמםpqrפרףstuד
419   //  93       100           110          120         130          139
420   //    אוvwxהס   תyzטזץabcש   נבdefגקכgh   iעיןjklחלך   mnoצמםpqr
421   // 139           150           160           170          180       186
422   //    פרףstuדאוvw   xהסתyzטזץa   bcשנבdefגק    כghiעיןjkl    חלךmno
423   // 186     190           200           210          220            233
424   //    צמםp   qrפרףstuדא    וvwxהסתyzט   זץabcשנבde   fגקכghiעיןjkl
425   // 233        240            250           260     265
426   //    חלךmnoצ    מםpqrפרףst   uדאוvwxהסת    yzטזץ
427
428   float visualX05[] = { -100.f, 96.f, 155.f, 250.f, 344.f, 500.f,
429                         -100.f, 36.f, 124.f, 190.f, 280.f, 500.f,
430                         -100.f, 56.f, 158.f, 237.f, 303.f, 500.f,
431                         -100.f, 98.f, 184.f, 261.f, 337.f, 500.f,
432                         -100.f, 40.f, 113.f, 223.f, 302.f, 500.f,
433                         -100.f, 82.f, 160.f, 253.f, 500.f };
434   float visualY05[] = { -100.f, 12.f, 12.f, 12.f, 12.f, 12.f,
435                         30.f, 30.f, 30.f, 30.f, 30.f, 30.f,
436                         50.f, 50.f, 50.f, 50.f, 50.f, 50.f,
437                         67.f, 67.f, 67.f, 67.f, 67.f, 67.f,
438                         87.f, 87.f, 87.f, 87.f, 87.f, 87.f,
439                         107.f, 107.f, 107.f, 107.f, 107.f };
440   CharacterHitTest::Mode mode05[] = { CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP,
441                                       CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP,
442                                       CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP,
443                                       CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP,
444                                       CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP,
445                                       CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP };
446   CharacterIndex logicalIndex05[] = {    0,  10u,  20u,  30u,  40u,  45u,
447                                        46u,  50u,  60u,  70u,  80u,  92u,
448                                        93u, 100u, 110u, 120u, 130u, 138u,
449                                       139u, 150u, 160u, 170u, 180u, 185u,
450                                       186u, 190u, 200u, 210u, 220u, 232u,
451                                       233u, 240u, 250u, 260u, 265u };
452   bool isCharacterHit05[] = { false, true, true, true, true, false,
453                               false, true, true, true, true, false,
454                               false, true, true, true, true, false,
455                               false, true, true, true, true, false,
456                               false, true, true, true, true, false,
457                               false, true, true, true, false };
458
459   //   0            10           20           30           40        46
460   //    שנבabcגקכd    efעיןghiחל   ךjklצמםmno   פרףpqrדאוs   tuהסתv
461   //  46     50           60          70            80              93
462   //    wxטז   ץyzשנבabcג   קכdefעיןgh   iחלךjklצמם   mnoפרףpqrדאוs
463   //  93        100          110          120           130           139
464   //    tuהסתvw   xטזץyzשנבa   bcגקכdefעי    ןghiחלךjkl    צמםmnoפרף
465   // 139           150           160          170         180       186
466   //    pqrדאוstuהס   תvwxטזץyzש   נבabcגקכde   fעיןghiחלך   jklצמם
467   // 186    190          200           210           220            232
468   //    mnoפ   רףpqrדאוst   uהסתvwxטזץ   yzשנבabcגק    כdefעיןghiחל
469   // 232         240           250           260     265
470   //    ךjklצמםm   noפרףpqrדא    וstuהסתvwx   טזץyz
471
472   float visualX06[] = { 500.f, 307.f, 237.f, 148.f, 55.f, -100.f,
473                         500.f, 362.f, 276.f, 213.f, 121.f, -100.f,
474                         500.f, 344.f, 238.f, 167.f, 93.f, -100.f,
475                         500.f, 306.f, 216.f, 142.f, 58.f, -100.f,
476                         500.f, 355.f, 279.f, 182.f, 92.f, -100.f,
477                         500.f, 326.f, 238.f, 150.f, -100.f };
478   float visualY06[] = { -100.f, 12.f, 12.f, 12.f, 12.f, 12.f,
479                         30.f, 30.f, 30.f, 30.f, 30.f, 30.f,
480                         50.f, 50.f, 50.f, 50.f, 50.f, 50.f,
481                         67.f, 67.f, 67.f, 67.f, 67.f, 67.f,
482                         87.f, 87.f, 87.f, 87.f, 87.f, 87.f,
483                         107.f, 107.f, 107.f, 107.f, 107.f };
484   CharacterHitTest::Mode mode06[] = { CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP,
485                                       CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP,
486                                       CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP,
487                                       CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP,
488                                       CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP,
489                                       CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP, CharacterHitTest::TAP };
490   CharacterIndex logicalIndex06[] = {    0,  10u,  20u,  30u,  40u,  45u,
491                                        46u,  50u,  60u,  70u,  80u,  92u,
492                                        93u, 100u, 110u, 120u, 130u, 138u,
493                                       139u, 150u, 160u, 170u, 180u, 185u,
494                                       186u, 190u, 200u, 210u, 220u, 231u,
495                                       232u, 240u, 250u, 260u, 265u  };
496   bool isCharacterHit06[] = { false, true, true, true, true, false,
497                               false, true, true, true, true, false,
498                               false, true, true, true, true, false,
499                               false, true, true, true, true, false,
500                               false, true, true, true, true, false,
501                               false, true, true, true, false };
502
503   float visualX07[] = { 395.f };
504   float visualY07[] = { 12.f };
505   CharacterHitTest::Mode mode07[] = { CharacterHitTest::TAP };
506   CharacterIndex logicalIndex07[] = { 1u };
507   bool isCharacterHit07[] = { true };
508
509   float visualX08[] = { 7.f };
510   float visualY08[] = { 12.f };
511   CharacterHitTest::Mode mode08[] = { CharacterHitTest::TAP };
512   CharacterIndex logicalIndex08[] = { 1u };
513   bool isCharacterHit08[] = { true };
514
515   struct GetClosestCursorIndexData data[] =
516   {
517     {
518       "Void text.",
519       "",
520       1u,
521       visualX01,
522       visualY01,
523       mode01,
524       logicalIndex01,
525       isCharacterHit01
526     },
527     {
528       "Single line text.",
529       "Hello world שלום עולם",
530       7u,
531       visualX02,
532       visualY02,
533       mode02,
534       logicalIndex02,
535       isCharacterHit02
536     },
537     {
538       "Single line with ligatures",
539       "different الأربعاء",
540       4u,
541       visualX03,
542       visualY03,
543       mode03,
544       logicalIndex03,
545       isCharacterHit03
546     },
547     {
548       "Multiline. Single line paragraphs",
549       "Hello world\n"
550       "שלום עולם\n"
551       "different الأربعاء\n",
552       17u,
553       visualX04,
554       visualY04,
555       mode04,
556       logicalIndex04,
557       isCharacterHit04
558     },
559     {
560       "Multiline. Single bidirectional paragraph, starts LTR, wrapped lines",
561       "abcשנבdefגקכghiעיןjklחלךmnoצמםpqrפרףstuדאוvwxה"
562       "סתyzטזץabcשנבdefגקכghiעיןjklחלךmnoצמםpqrפרףstuד"
563       "אוvwxהסתyzטזץabcשנבdefגקכghiעיןjklחלךmnoצמםpqr"
564       "פרףstuדאוvwxהסתyzטזץabcשנבdefגקכghiעיןjklחלךmno"
565       "צמםpqrפרףstuדאוvwxהסתyzטזץabcשנבdefגקכghiעיןjkl"
566       "חלךmnoצמםpqrפרףstuדאוvwxהסתyzטזץ",
567       35u,
568       visualX05,
569       visualY05,
570       mode05,
571       logicalIndex05,
572       isCharacterHit05
573     },
574     {
575       "Multiline. Single bidirectional paragraph, starts RTL, wrapped lines",
576       "שנבabcגקכdefעיןghiחלךjklצמםmnoפרףpqrדאוstuהסתv"
577       "wxטזץyzשנבabcגקכdefעיןghiחלךjklצמםmnoפרףpqrדאוs"
578       "tuהסתvwxטזץyzשנבabcגקכdefעיןghiחלךjklצמםmnoפרף"
579       "pqrדאוstuהסתvwxטזץyzשנבabcגקכdefעיןghiחלךjklצמם"
580       "mnoפרףpqrדאוstuהסתvwxטזץyzשנבabcגקכdefעיןghiחל"
581       "ךjklצמםmnoפרףpqrדאוstuהסתvwxטזץyz",
582       35u,
583       visualX06,
584       visualY06,
585       mode06,
586       logicalIndex06,
587       isCharacterHit06
588     },
589     {
590       "Testing complex characters. Arabic ligatures",
591       "الأَبْجَدِيَّة العَرَبِيَّة",
592       1u,
593       visualX07,
594       visualY07,
595       mode07,
596       logicalIndex07,
597       isCharacterHit07
598     },
599     {
600       "Testing complex characters. Latin ligatures",
601       "fi ligature",
602       1u,
603       visualX08,
604       visualY08,
605       mode08,
606       logicalIndex08,
607       isCharacterHit08
608     }
609   };
610   const unsigned int numberOfTests = 8u;
611
612   for( unsigned int index = 0; index < numberOfTests; ++index )
613   {
614     ToolkitTestApplication application;
615     if( !GetClosestCursorIndexTest( data[index] ) )
616     {
617       tet_result(TET_FAIL);
618     }
619   }
620
621   tet_result(TET_PASS);
622   END_TEST;
623 }
624
625 int UtcDaliGetCursorPosition(void)
626 {
627   tet_infoline(" UtcDaliGetCursorPosition");
628
629   float visualX08[] = { 5.f };
630   float visualY08[] = { 0.f };
631   CharacterIndex logicalIndex08[] = { 1u };
632
633   struct GetCursorPositionData data[] =
634   {
635     {
636       "Testing complex characters. Latin ligatures",
637       "fi ligature",
638       1u,
639       logicalIndex08,
640       visualX08,
641       visualY08,
642     }
643   };
644   const unsigned int numberOfTests = 1u;
645
646   for( unsigned int index = 0; index < numberOfTests; ++index )
647   {
648     ToolkitTestApplication application;
649     if( !GetCursorPositionTest( data[index] ) )
650     {
651       tet_result(TET_FAIL);
652     }
653   }
654
655   tet_result(TET_PASS);
656   END_TEST;
657 }
658
659 int UtcDaliFindSelectionIndices(void)
660 {
661   tet_infoline(" UtcDaliFindSelectionIndices");
662
663   float visualX01[] = { -100.f };
664   float visualY01[] = { -100.f };
665   bool found01[] = { false };
666   CharacterIndex startIndex01[] = { 0 };
667   CharacterIndex endIndex01[] = { 0 };
668   CharacterIndex noHitText01[] = { 0 };
669
670   float visualX02[] = { -100.f, 1000.f, 1000.f };
671   float visualY02[] = { -100.f, 12.f, 1000.f };
672   bool found02[] = { false, false, false };
673   CharacterIndex startIndex02[] = { 0, 6u, 6u };
674   CharacterIndex endIndex02[] = { 5u, 11u, 11u };
675   CharacterIndex noHitText02[] = { 0, 11u, 11u };
676
677   float visualX03[] = { 70.f };
678   float visualY03[] = { 12.f };
679   bool found03[] = { true };
680   CharacterIndex startIndex03[] = { 6u };
681   CharacterIndex endIndex03[] = { 11u };
682   CharacterIndex noHitText03[] = { 0u };
683
684   float visualX04[] = { 132.f };
685   float visualY04[] = { 12.f };
686   bool found04[] = { true };
687   CharacterIndex startIndex04[] = { 12u };
688   CharacterIndex endIndex04[] = { 16u };
689   CharacterIndex noHitText04[] = { 0u };
690
691   float visualX05[] = { 1.f };
692   float visualY05[] = { 12.f };
693   bool found05[] = { true };
694   CharacterIndex startIndex05[] = { 0 };
695   CharacterIndex endIndex05[] = { 1u };
696   CharacterIndex noHitText05[] = { 0 };
697
698   float visualX06[] = { 10.f };
699   float visualY06[] = { 12.f };
700   bool found06[] = { true };
701   CharacterIndex startIndex06[] = { 0 };
702   CharacterIndex endIndex06[] = { 1u };
703   CharacterIndex noHitText06[] = { 0u };
704
705   struct FindSelectionIndicesData data[] =
706   {
707     {
708       "void text",
709       "",
710       1u,
711       visualX01,
712       visualY01,
713       found01,
714       startIndex01,
715       endIndex01,
716       noHitText01
717     },
718     {
719       "touch out of text's boundaries",
720       "Hello world",
721       3u,
722       visualX02,
723       visualY02,
724       found02,
725       startIndex02,
726       endIndex02,
727       noHitText02
728     },
729     {
730       "touch on the text",
731       "Hello world demo",
732       1u,
733       visualX03,
734       visualY03,
735       found03,
736       startIndex03,
737       endIndex03,
738       noHitText03
739     },
740     {
741       "touch on the new paragraph character at the end of line",
742       "Hello world demo\n",
743       1u,
744       visualX04,
745       visualY04,
746       found04,
747       startIndex04,
748       endIndex04,
749       noHitText04
750     },
751     {
752       "touch on a white space character. is the unique character of the line",
753       " ",
754       1u,
755       visualX05,
756       visualY05,
757       found05,
758       startIndex05,
759       endIndex05,
760       noHitText05
761     },
762     {
763       "touch on a white space character. is between two words",
764       "h ello",
765       1u,
766       visualX06,
767       visualY06,
768       found06,
769       startIndex06,
770       endIndex06,
771       noHitText06
772     },
773   };
774   const unsigned int numberOfTests = 6u;
775
776   for( unsigned int index = 0; index < numberOfTests; ++index )
777   {
778     ToolkitTestApplication application;
779     if( !FindSelectionIndicesTest( data[index] ) )
780     {
781       tet_result(TET_FAIL);
782     }
783   }
784
785   tet_result(TET_PASS);
786   END_TEST;
787 }