2 * Copyright (c) 2016 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/text-run-container.h>
24 #include <dali-toolkit/dali-toolkit.h>
25 #include <toolkit-text-model.h>
29 using namespace Toolkit;
32 // Tests the following functions.
34 // void CreateParagraphInfo( CharacterIndex startIndex,
35 // Length numberOfCharacters );
36 // void FindParagraphs( CharacterIndex index,
37 // Length numberOfCharacters,
38 // Vector<ParagraphRunIndex>& paragraphs );
39 // CharacterIndex GetLogicalCharacterIndex( CharacterIndex visualCharacterIndex ) const;
40 // CharacterIndex GetLogicalCursorIndex( CharacterIndex visualCursorIndex ) const;
42 //////////////////////////////////////////////////////////
46 struct CreateParagraphData
48 std::string description; ///< Description of the test.
49 std::string text; ///< Input text.
50 CharacterIndex index; ///< The first character index.
51 Length numberOfCharacters; ///< The number of characters.
52 unsigned int numberOfParagraphs; ///< The expected number of paragraphs.
53 unsigned int* indices; ///< The expected paragraph info indices.
54 unsigned int* numberOfCharactersPerParagraph; ///< The expected number of characters of each paragraph.
57 struct FindParagraphData
59 std::string description; ///< Description of the test.
60 std::string text; ///< Input text.
61 CharacterIndex index; ///< The first character index.
62 Length numberOfCharacters; ///< The number of characters.
63 unsigned int numberOfParagraphs; ///< The expected number of paragraphs.
64 unsigned int* paragraphs; ///< The expected paragraph info.
67 struct GetLogicalCharacterIndexData
69 std::string description; ///< Description of the test.
70 std::string text; ///< Input text.
71 Size textArea; ///< The text area.
72 unsigned int numberOfIndices; ///< The number of characters to set.
73 unsigned int* visualToLogical; ///< The expected visual to logical conversion table.
74 unsigned int* cachedBidiLine; ///< The cached bidi line index for each character.
77 struct GetLogicalCursorIndexData
79 std::string description; ///< Description of the test.
80 std::string text; ///< Input text.
81 unsigned int numberOfIndices; ///< The number of characters to set.
82 unsigned int* visualCursorIndex; ///< The given cursor visual index.
83 unsigned int* logicalCursorIndex; ///< The expected cursor logical index
84 unsigned int* cachedBidiLine; ///< The cached bidi line index for each character.
87 bool CreateParagraphTest( const CreateParagraphData& data )
89 // 1) Create the model.
90 LogicalModelPtr logicalModel = LogicalModel::New();
91 VisualModelPtr visualModel = VisualModel::New();
92 Size textArea(100.f, 60.f);
95 Vector<FontDescriptionRun> fontDescriptionRuns;
96 LayoutOptions options;
97 CreateTextModel( data.text,
105 // 2) Clear the paragraphs.
106 Vector<ParagraphRun>& paragraphs = logicalModel->mParagraphInfo;
107 ClearCharacterRuns( data.index,
108 data.index + data.numberOfCharacters - 1u,
111 // 3) Call the LogicalModel::CreateParagraphInfo() method
112 logicalModel->CreateParagraphInfo( data.index,
113 data.numberOfCharacters );
115 // 4) Compare the results.
116 if( data.numberOfParagraphs != paragraphs.Count() )
118 std::cout << " Different number of paragraphs : " << paragraphs.Count() << ", expected : " << data.numberOfParagraphs << std::endl;
122 unsigned int index = 0u;
123 for( Vector<ParagraphRun>::ConstIterator it = paragraphs.Begin(),
124 endIt = paragraphs.End();
128 const ParagraphRun& paragraph( *it );
130 if( data.indices[index] != paragraph.characterRun.characterIndex )
132 std::cout << " Different character index for paragraph : " << index << ", " << paragraph.characterRun.characterIndex << ", expected : " << data.indices[index] << std::endl;
135 if( data.numberOfCharactersPerParagraph[index] != paragraph.characterRun.numberOfCharacters )
137 std::cout << " Different number of characters for paragraph : " << index << ", " << paragraph.characterRun.numberOfCharacters << ", expected : " << data.numberOfCharactersPerParagraph[index] << std::endl;
145 bool FindParagraphTest( const FindParagraphData& data )
147 // 1) Create the model.
148 LogicalModelPtr logicalModel = LogicalModel::New();
149 VisualModelPtr visualModel = VisualModel::New();
150 Size textArea(100.f, 60.f);
153 Vector<FontDescriptionRun> fontDescriptionRuns;
154 LayoutOptions options;
155 CreateTextModel( data.text,
163 // 2) Find the paragraphs.
164 Vector<ParagraphRunIndex> paragraphs;
165 logicalModel->FindParagraphs( data.index, data.numberOfCharacters, paragraphs );
167 // 3) compare the results.
168 if( data.numberOfParagraphs != paragraphs.Count() )
173 unsigned int index = 0u;
174 for( Vector<ParagraphRunIndex>::ConstIterator it = paragraphs.Begin(),
175 endIt = paragraphs.End();
179 const ParagraphRunIndex paragraphIndex = *it;
181 if( paragraphIndex != data.paragraphs[index] )
190 bool GetLogicalCharacterIndexTest( const GetLogicalCharacterIndexData& data )
192 std::cout << " testing : " << data.description << std::endl;
194 LogicalModelPtr logicalModel = LogicalModel::New();
195 VisualModelPtr visualModel = VisualModel::New();
198 // Create the model with the whole text.
199 const Vector<FontDescriptionRun> fontDescriptions;
200 const LayoutOptions options;
201 CreateTextModel( data.text,
209 for( unsigned int index = 0u; index < data.numberOfIndices; ++index )
211 // Check the current cached bidi line index. (Check it before call the GetLogicalCharacterIndex() method )
212 if( data.cachedBidiLine[index] != logicalModel->mBidirectionalLineIndex )
214 std::cout << " index : " << index << ", different cached bidi index : " << logicalModel->mBidirectionalLineIndex << ", expected : " << data.cachedBidiLine[index] << std::endl;
218 const Character logicalIndex = logicalModel->GetLogicalCharacterIndex( index );
219 if( data.visualToLogical[index] != logicalIndex )
221 std::cout << " visual index : " << index << ", different logical index : " << logicalIndex << ", expected : " << data.visualToLogical[index] << std::endl;
228 bool GetLogicalCursorIndexTest( const GetLogicalCursorIndexData& data )
230 std::cout << " testing : " << data.description << std::endl;
232 LogicalModelPtr logicalModel = LogicalModel::New();
233 VisualModelPtr visualModel = VisualModel::New();
234 Size textArea( 300.f, 300.f );
237 // Create the model with the whole text.
238 const Vector<FontDescriptionRun> fontDescriptions;
239 const LayoutOptions options;
240 CreateTextModel( data.text,
248 for( unsigned int index = 0u; index < data.numberOfIndices; ++index )
250 if( logicalModel->mBidirectionalLineIndex != data.cachedBidiLine[index] )
252 std::cout << " test : " << index << ", different cached line index : " << logicalModel->mBidirectionalLineIndex << ", expected : " << data.cachedBidiLine[index] << std::endl;
256 const CharacterIndex logicalCursorIndex = logicalModel->GetLogicalCursorIndex( data.visualCursorIndex[index] );
258 if( logicalCursorIndex != data.logicalCursorIndex[index] )
260 std::cout << " test : " << index << ", different logical cursor index : " << logicalCursorIndex << ", expected : " << data.logicalCursorIndex[index] << std::endl;
270 //////////////////////////////////////////////////////////
272 // UtcDaliCreateParagraph
273 // UtcDaliFindParagraph
274 // UtcDaliGetLogicalCharacterIndex
275 // UtcDaliGetLogicalCursorIndex
277 //////////////////////////////////////////////////////////
279 int UtcDaliCreateParagraph(void)
281 ToolkitTestApplication application;
282 tet_infoline(" UtcDaliCreateParagraph");
284 unsigned int paragraphsIndices01[] = { 0u };
285 unsigned int paragraphsNumberOfCharacters01[] = { 0u };
286 unsigned int paragraphsIndices02[] = { 0u, 12u, 17u };
287 unsigned int paragraphsNumberOfCharacters02[] = { 12u, 5u, 1u };
288 unsigned int paragraphsIndices03[] = { 0u, 12u, 17u, 34u };
289 unsigned int paragraphsNumberOfCharacters03[] = { 12u, 5u, 17u ,1u };
291 struct CreateParagraphData data[] =
300 paragraphsNumberOfCharacters01,
304 "Hello world\ndemo\n\n",
309 paragraphsNumberOfCharacters02,
312 "Some paragraphs. Update the initial paragraphs.",
313 "Hello world\ndemo\nhello world demo\n\n",
318 paragraphsNumberOfCharacters03,
321 "Some paragraphs. Update the mid paragraphs.",
322 "Hello world\ndemo\nhello world demo\n\n",
327 paragraphsNumberOfCharacters03,
330 "Some paragraphs. Update the final paragraphs.",
331 "Hello world\ndemo\nhello world demo\n\n",
336 paragraphsNumberOfCharacters03,
339 const unsigned int numberOfTests = 5u;
341 for( unsigned int index = 0u; index < numberOfTests; ++index )
343 // ToolkitTestApplication application;
344 if( !CreateParagraphTest( data[index] ) )
346 tet_result(TET_FAIL);
350 tet_result(TET_PASS);
354 int UtcDaliFindParagraph(void)
356 tet_infoline(" UtcDaliFindParagraph");
358 unsigned int paragraphs01[] = {};
359 unsigned int paragraphs02[] = { 0u, 1u, 2u };
360 unsigned int paragraphs03[] = { 0u };
361 unsigned int paragraphs04[] = { 1u };
362 unsigned int paragraphs05[] = { 0u, 1u, 2u };
364 struct FindParagraphData data[] =
376 "Hello world\ndemo\n\n",
384 "Hello world\ndemo\n\n",
392 "Hello world\ndemo\n\n",
400 "Hello world\ndemo\n\n",
407 const unsigned int numberOfTests = 5u;
409 for( unsigned int index = 0u; index < numberOfTests; ++index )
411 ToolkitTestApplication application;
412 if( !FindParagraphTest( data[index] ) )
414 tet_result(TET_FAIL);
418 tet_result(TET_PASS);
422 int UtcDaliGetLogicalCharacterIndex(void)
424 tet_infoline(" UtcDaliSetVisualToLogicalMap");
426 unsigned int visualToLogical01[] = {};
427 unsigned int cachedBidiLine01[] = {};
428 unsigned int visualToLogical02[] = { 0u, 1u, 2u, 3u, 4u, 5u, 6u, 7u, 8u, 9u, 10u };
429 unsigned int cachedBidiLine02[] = { 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u };
430 unsigned int visualToLogical03[] = { 12u, 11u, 10u, 9u, 8u, 7u, 6u, 5u, 4u, 3u, 2u, 1u, 0u };
431 unsigned int cachedBidiLine03[] = { 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u };
433 unsigned int visualToLogical04[] = { 0u, 1u, 2u, 3u, 4u, 5u, 6u, 7u, 8u, 9u, 10u, 11u, 12u, 25u, 24u, 23u, 22u, 21u, 20u, 19u, 18u, 17u, 16u, 15u, 14u, 13u, 26u, 27u, 28u, 29u, 30u, 31u, 32u, 33u, 34u, 35u, 36u, 37u, 38u, 39u, 81u, 80u, 79u, 78u, 77u, 76u, 75u, 74u, 73u, 72u, 71u, 70u, 69u, 68u, 67u, 66u, 55u, 56u, 57u, 58u, 59u, 60u, 61u, 62u, 63u, 64u, 65u, 54u, 53u, 52u, 51u, 50u, 49u, 48u, 47u, 46u, 45u, 44u, 43u, 42u, 41u, 40u, 95u, 94u, 93u, 92u, 91u, 90u, 89u, 88u, 87u, 86u, 85u, 84u, 83u, 82u, 96u, 97u, 98u, 99u, 100u, 101u, 102u, 103u, 104u, 105u, 106u };
434 unsigned int cachedBidiLine04[] = { 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
435 0u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u,
436 1u, 2u, 2u, 2u, 2u, 2u, 2u, 2u, 2u, 2u, 2u, 2u, 2u, 2u, 2u, 2u, 2u, 2u, 2u, 2u, 2u, 2u, 2u, 2u, 2u };
439 // LO H e l l o _ w o r l d , _ م ر ح ب ا _ ب ا ل ع ا ل م , _ h e l l o _ w o r l d \n
440 // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
441 // VO H e l l o _ w o r l d , _ م ل ا ع ل ا ب _ ا ب ح ر م , _ h e l l o _ w o r l d \n
442 // 0 1 2 3 4 5 6 7 8 9 10 11 12 25 24 23 22 21 20 19 18 17 16 15 14 13 26 27 28 29 30 31 32 33 34 35 36 37 38 39
444 // LO م ر ح ب ا _ ب ا ل ع ا ل م , _ h e l l o _ w o r l d , _ م ر ح ب ا _ ب ا ل ع ا ل م \n
445 // 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
446 // VO \n م ل ا ع ل ا ب _ ا ب ح ر م _ , h e l l o _ w o r l d _ , م ل ا ع ل ا ب _ ا ب ح ر م
447 // 81 80 79 78 77 76 75 74 73 72 71 70 69 68 67 66 55 56 57 58 59 60 61 62 63 64 65 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40
449 // LO م ر ح ب ا _ ب ا ل ع ا ل م \n
450 // 82 83 84 85 86 87 88 89 90 91 92 93 94 95
451 // VO \n م ل ا ع ل ا ب _ ا ب ح ر م
452 // 95 94 93 92 91 90 89 88 87 86 85 84 83 82
455 // LO h e l l o _ w o r l d
456 // 96 97 98 99 100 101 102 103 104 105 106
457 // VO h e l l o _ w o r l d
458 // 96 97 98 99 100 101 102 103 104 105 106
460 unsigned int visualToLogical05[] = { 0u, 1u, 2u, 3u, 4u, 5u, 6u, 7u, 8u, 9u, 10u, 11u, 12u, 25u, 24u, 23u, 22u, 21u, 20u, 19u, 18u, 17u, 16u, 15u, 14u, 13u, 26u, 27u, 28u, 29u, 30u, 31u, 32u, 33u, 34u, 35u, 36u, 37u, 38u, 39u, 67u, 66u, 55u, 56u, 57u, 58u, 59u, 60u, 61u, 62u, 63u, 64u, 65u, 54u, 53u, 52u, 51u, 50u, 49u, 48u, 47u, 46u, 45u, 44u, 43u, 42u, 41u, 40u, 81u, 80u, 79u, 78u, 77u, 76u, 75u, 74u, 73u, 72u, 71u, 70u, 69u, 68u, 95u, 94u, 93u, 92u, 91u, 90u, 89u, 88u, 87u, 86u, 85u, 84u, 83u, 82u, 96u, 97u, 98u, 99u, 100u, 101u, 102u, 103u, 104u, 105u, 106u };
461 unsigned int cachedBidiLine05[] = { 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 2u, 2u, 2u, 2u, 2u, 2u, 2u, 2u, 2u, 2u, 2u, 2u, 2u, 2u, 2u, 2u, 2u, 2u, 2u, 2u, 2u, 2u, 2u, 2u, 2u, 2u, 2u, 2u, 3u, 3u, 3u, 3u, 3u, 3u, 3u, 3u, 3u, 3u, 3u, 3u, 3u, 3u, 4u, 4u, 4u, 4u, 4u, 4u, 4u, 4u, 4u, 4u, 4u, 4u, 4u, 4u, 4u, 4u, 4u, 4u, 4u, 4u, 4u, 4u, 4u, 4u };
464 // LO H e l l o _ w o r l d , _ م ر ح ب ا _ ب ا ل ع ا ل م , _
465 // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
466 // VO H e l l o _ w o r l d , _ م ل ا ع ل ا ب _ ا ب ح ر م , _
467 // 0 1 2 3 4 5 6 7 8 9 10 11 12 25 24 23 22 21 20 19 18 17 16 15 14 13 26 27
469 // LO h e l l o _ w o r l d \n
470 // 28 29 30 31 32 33 34 35 36 37 38 39
471 // VO h e l l o _ w o r l d \n
472 // 28 29 30 31 32 33 34 35 36 37 38 39
474 // LO م ر ح ب ا _ ب ا ل ع ا ل م , _ h e l l o _ w o r l d , _
475 // 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
476 // VO _ , h e l l o _ w o r l d _ , م ل ا ع ل ا ب _ ا ب ح ر م
477 // 67 66 55 56 57 58 59 60 61 62 63 64 65 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40
479 // LO م ر ح ب ا _ ب ا ل ع ا ل م \n
480 // 68 69 70 71 72 73 74 75 76 77 78 79 80 81
481 // VO \n م ل ا ع ل ا ب _ ا ب ح ر م
482 // 81 80 79 78 77 76 75 74 73 72 71 70 69 68
484 // LO م ر ح ب ا _ ب ا ل ع ا ل م \n
485 // 82 83 84 85 86 87 88 89 90 91 92 93 94 95
486 // VO \n م ل ا ع ل ا ب _ ا ب ح ر م
487 // 95 94 93 92 91 90 89 88 87 86 85 84 83 82
490 // LO h e l l o _ w o r l d
491 // 96 97 98 99 100 101 102 103 104 105 106
492 // VO h e l l o _ w o r l d
493 // 96 97 98 99 100 101 102 103 104 105 106
495 unsigned int visualToLogical06[] = { 0u, 1u, 2u, 3u, 4u, 5u, 6u, 7u, 8u, 9u, 10u, 11u, 12u, 25u, 24u, 23u, 22u, 21u, 20u, 19u, 18u, 17u, 16u, 15u, 14u, 13u, 26u, 27u, 28u, 29u, 30u, 31u, 32u, 33u, 34u, 35u, 36u, 37u, 38u, 39u, 54u, 53u, 52u, 51u, 50u, 49u, 48u, 47u, 46u, 45u, 44u, 43u, 42u, 41u, 40u, 67u, 66u, 55u, 56u, 57u, 58u, 59u, 60u, 61u, 62u, 63u, 64u, 65u, 81u, 80u, 79u, 78u, 77u, 76u, 75u, 74u, 73u, 72u, 71u, 70u, 69u, 68u, 95u, 94u, 93u, 92u, 91u, 90u, 89u, 88u, 87u, 86u, 85u, 84u, 83u, 82u, 96u, 97u, 98u, 99u, 100u, 101u, 102u, 103u, 104u, 105u, 106u };
496 unsigned int cachedBidiLine06[] = { 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
497 0u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u,
498 1u, 2u, 2u, 2u, 2u, 2u, 2u, 2u, 2u, 2u, 2u, 2u,
499 2u, 3u, 3u, 3u, 3u, 3u, 3u, 3u, 3u, 3u, 3u, 3u, 3u, 3u, 3u,
500 3u, 4u, 4u, 4u, 4u, 4u, 4u, 4u, 4u, 4u, 4u, 4u, 4u,
501 4u, 5u, 5u, 5u, 5u, 5u, 5u, 5u, 5u, 5u, 5u, 5u, 5u, 5u,
502 5u, 6u, 6u, 6u, 6u, 6u, 6u, 6u, 6u, 6u, 6u, 6u, 6u, 6u,
503 6u, 6u, 6u, 6u, 6u, 6u, 6u, 6u, 6u, 6u, 6u };
506 // LO H e l l o _ w o r l d , _
507 // 0 1 2 3 4 5 6 7 8 9 10 11 12
508 // VO H e l l o _ w o r l d , _
509 // 0 1 2 3 4 5 6 7 8 9 10 11 12
511 // LO م ر ح ب ا _ ب ا ل ع ا ل م , _
512 // 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
513 // VO م ل ا ع ل ا ب _ ا ب ح ر م , _
514 // 25 24 23 22 21 20 19 18 17 16 15 14 13 26 27
516 // LO h e l l o _ w o r l d \n
517 // 28 29 30 31 32 33 34 35 36 37 38 39
518 // VO h e l l o _ w o r l d \n
519 // 28 29 30 31 32 33 34 35 36 37 38 39
521 // LO م ر ح ب ا _ ب ا ل ع ا ل م , _
522 // 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
523 // VO _ , م ل ا ع ل ا ب _ ا ب ح ر م
524 // 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40
526 // LO h e l l o _ w o r l d , _
527 // 55 56 57 58 59 60 61 62 63 64 65 66 67
528 // VO _ , h e l l o _ w o r l d
529 // 67 66 55 56 57 58 59 60 61 62 63 64 65
531 // LO م ر ح ب ا _ ب ا ل ع ا ل م \n
532 // 68 69 70 71 72 73 74 75 76 77 78 79 80 81
533 // VO \n م ل ا ع ل ا ب _ ا ب ح ر م
534 // 81 80 79 78 77 76 75 74 73 72 71 70 69 68
536 // LO م ر ح ب ا _ ب ا ل ع ا ل م \n
537 // 82 83 84 85 86 87 88 89 90 91 92 93 94 95
538 // VO \n م ل ا ع ل ا ب _ ا ب ح ر م
539 // 95 94 93 92 91 90 89 88 87 86 85 84 83 82
542 // LO h e l l o _ w o r l d
543 // 96 97 98 99 100 101 102 103 104 105 106
544 // VO h e l l o _ w o r l d
545 // 96 97 98 99 100 101 102 103 104 105 106
547 struct GetLogicalCharacterIndexData data[] =
550 "Zero characters text",
552 Size( 300.f, 300.f ),
558 "Left to right text only",
560 Size( 300.f, 300.f ),
566 "Right to left text only",
568 Size( 300.f, 300.f ),
574 "Mix of left to right and right to left text.",
575 "Hello world, مرحبا بالعالم, hello world\nمرحبا بالعالم, hello world, مرحبا بالعالم\nمرحبا بالعالم\nhello world",
576 Size( 300.f, 300.f ),
582 "Mix of left to right and right to left text.",
583 "Hello world, مرحبا بالعالم, hello world\nمرحبا بالعالم, hello world, مرحبا بالعالم\nمرحبا بالعالم\nhello world",
584 Size( 200.f, 400.f ),
590 "Mix of left to right and right to left text.",
591 "Hello world, مرحبا بالعالم, hello world\nمرحبا بالعالم, hello world, مرحبا بالعالم\nمرحبا بالعالم\nhello world",
592 Size( 100.f, 600.f ),
598 const unsigned int numberOfTests = 6u;
600 for( unsigned int index = 0u; index < numberOfTests; ++index )
602 ToolkitTestApplication application;
603 if( !GetLogicalCharacterIndexTest( data[index] ) )
605 tet_result(TET_FAIL);
609 tet_result(TET_PASS);
613 int UtcDaliGetLogicalCursorIndex(void)
615 tet_infoline(" UtcDaliGetLogicalCursorIndex");
617 unsigned int visualIndex01[] = { 10u };
618 unsigned int logicalIndex01[] = { 10u };
619 unsigned int bidirectionalLineIndex01[] = { 0u };
621 unsigned int visualIndex02[] = { 0u, 16u, 11u, 12u };
622 unsigned int logicalIndex02[] = { 0u, 16u, 11u, 12u };
623 unsigned int bidirectionalLineIndex02[] = { 0u, 0u, 0u, 0u };
627 // LO H e l l o _ w o r l d , _ \n
628 // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14
629 // VO H e l l o _ w o r l d , _ \n
631 // LO ש ל ו ם _ ע ו ל ם , _ \n
632 // 14 15 16 17 18 19 20 21 22 23 24 25 26
633 // VO \n _ , ם ל ו ע _ ם ו ל ש
635 // LO h e l l o _ w o r l d , _ \n
636 // 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
637 // VO h e l l o _ w o r l d , _ \n
639 // LO h e l l o _ w o r l d , _ ש ל ו ם _ ע ו ל ם \n
640 // 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
641 // VO h e l l o _ w o r l d , _ ם ל ו ע _ ם ו ל ש \n
643 // LO ש ל ו ם _ ע ו ל ם
644 // 63 64 65 66 67 68 69 70 71 72
645 // VO ם ל ו ע _ ם ו ל ש
647 unsigned int visualIndex03[] = { 0u, 18u, 25u, 60u, 54u, 65u, 0u, 18u, 65u, 33u };
648 unsigned int logicalIndex03[] = { 0u, 22u, 15u, 55u, 61u, 70u, 0u, 22u, 70u, 33u };
649 unsigned int bidirectionalLineIndex03[] = { 0u, 0u, 0u, 0u, 1u, 1u, 2u, 2u, 0u, 2u };
652 // LO ש ל ו ם _ ע ו ל ם , _ \n
653 // 0 1 2 3 4 5 6 7 8 9 10 11 12
654 // VO \n , ם ל ו ע _ ם ו ל ש
656 // LO h e l l o _ w o r l d , _ \n
657 // 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
658 // VO h e l l o _ w o r l d , _ \n
660 // LO h e l l o _ w o r l d , _ ש ל ו ם _ ע ו ל ם \n
661 // 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
662 // VO h e l l o _ w o r l d , _ ש ל ו ם _ ע ו ל ם \n
664 // LO ש ל ו ם _ ע ו ל ם , _ \n
665 // 49 50 51 52 53 54 55 56 57 58 59 60 61
666 // VO ם ל ו ע _ ם ו ל ש , \n
668 // LO h e l l o _ w o r l d
669 // 61 62 63 64 65 66 67 68 69 70 71 72
670 // VO h e l l o _ w o r l d
673 unsigned int visualIndex04[] = { 0u };
674 unsigned int logicalIndex04[] = { 72u };
675 unsigned int bidirectionalLineIndex04[] = { 0u };
679 struct GetLogicalCursorIndexData data[] =
682 "Zero characters text",
687 bidirectionalLineIndex01,
690 "All left to right text 01.",
695 bidirectionalLineIndex02,
698 "bidirectional text 01.",
699 "Hello world, \nשלום עולם, \nhello world, \nhello world, שלום עולם\nשלום עולם",
703 bidirectionalLineIndex03,
706 "bidirectional text 02.",
707 "שלום עולם, \nhello world, \nhello world, שלום עולם\nשלום עולם, \nhello world",
711 bidirectionalLineIndex04,
714 const unsigned int numberOfTests = 4u;
716 for( unsigned int index = 0u; index < numberOfTests; ++index )
718 ToolkitTestApplication application;
719 if( !GetLogicalCursorIndexTest( data[index] ) )
721 tet_result(TET_FAIL);
725 tet_result(TET_PASS);