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 // bool FetchBidirectionalLineInfo( CharacterIndex characterIndex )
40 // CharacterIndex GetLogicalCharacterIndex( CharacterIndex visualCharacterIndex ) const;
41 // CharacterIndex GetLogicalCursorIndex( CharacterIndex visualCursorIndex ) const;
43 //////////////////////////////////////////////////////////
47 struct CreateParagraphData
49 std::string description; ///< Description of the test.
50 std::string text; ///< Input text.
51 CharacterIndex index; ///< The first character index.
52 Length numberOfCharacters; ///< The number of characters.
53 unsigned int numberOfParagraphs; ///< The expected number of paragraphs.
54 unsigned int* indices; ///< The expected paragraph info indices.
55 unsigned int* numberOfCharactersPerParagraph; ///< The expected number of characters of each paragraph.
58 struct FindParagraphData
60 std::string description; ///< Description of the test.
61 std::string text; ///< Input text.
62 CharacterIndex index; ///< The first character index.
63 Length numberOfCharacters; ///< The number of characters.
64 unsigned int numberOfParagraphs; ///< The expected number of paragraphs.
65 unsigned int* paragraphs; ///< The expected paragraph info.
68 struct FetchBidirectionalLineInfoData
70 std::string description; ///< Description of the test.
71 std::string text; ///< Input text.
72 unsigned int numberOfTests; ///< The number of tests.
73 unsigned int* characterIndex; ///< The logical character index.
74 bool* fetched; ///< Whether the expected bidi line exists.
75 unsigned int* bidiLineIndex; ///< Index to the expected bidi line.
78 struct GetLogicalCharacterIndexData
80 std::string description; ///< Description of the test.
81 std::string text; ///< Input text.
82 Size textArea; ///< The text area.
83 unsigned int numberOfIndices; ///< The number of characters to set.
84 unsigned int* visualToLogical; ///< The expected visual to logical conversion table.
85 unsigned int* cachedBidiLine; ///< The cached bidi line index for each character.
88 struct GetLogicalCursorIndexData
90 std::string description; ///< Description of the test.
91 std::string text; ///< Input text.
92 Size textArea; ///< The text area.
93 unsigned int numberOfIndices; ///< The number of characters to set.
94 unsigned int* visualCursorIndex; ///< The given cursor visual index.
95 unsigned int* characterIndex; ///< Index to the first logical character of the line.
96 unsigned int* logicalCursorIndex; ///< The expected cursor logical index.
97 unsigned int* cachedBidiLine; ///< The cached bidi line index for each character.
100 bool CreateParagraphTest( const CreateParagraphData& data )
102 // 1) Create the model.
103 LogicalModelPtr logicalModel = LogicalModel::New();
104 VisualModelPtr visualModel = VisualModel::New();
105 Size textArea(100.f, 60.f);
108 Vector<FontDescriptionRun> fontDescriptionRuns;
109 LayoutOptions options;
110 CreateTextModel( data.text,
118 // 2) Clear the paragraphs.
119 Vector<ParagraphRun>& paragraphs = logicalModel->mParagraphInfo;
120 ClearCharacterRuns( data.index,
121 data.index + data.numberOfCharacters - 1u,
124 // 3) Call the LogicalModel::CreateParagraphInfo() method
125 logicalModel->CreateParagraphInfo( data.index,
126 data.numberOfCharacters );
128 // 4) Compare the results.
129 if( data.numberOfParagraphs != paragraphs.Count() )
131 std::cout << " Different number of paragraphs : " << paragraphs.Count() << ", expected : " << data.numberOfParagraphs << std::endl;
135 unsigned int index = 0u;
136 for( Vector<ParagraphRun>::ConstIterator it = paragraphs.Begin(),
137 endIt = paragraphs.End();
141 const ParagraphRun& paragraph( *it );
143 if( data.indices[index] != paragraph.characterRun.characterIndex )
145 std::cout << " Different character index for paragraph : " << index << ", " << paragraph.characterRun.characterIndex << ", expected : " << data.indices[index] << std::endl;
148 if( data.numberOfCharactersPerParagraph[index] != paragraph.characterRun.numberOfCharacters )
150 std::cout << " Different number of characters for paragraph : " << index << ", " << paragraph.characterRun.numberOfCharacters << ", expected : " << data.numberOfCharactersPerParagraph[index] << std::endl;
158 bool FindParagraphTest( const FindParagraphData& data )
160 // 1) Create the model.
161 LogicalModelPtr logicalModel = LogicalModel::New();
162 VisualModelPtr visualModel = VisualModel::New();
163 Size textArea(100.f, 60.f);
166 Vector<FontDescriptionRun> fontDescriptionRuns;
167 LayoutOptions options;
168 CreateTextModel( data.text,
176 // 2) Find the paragraphs.
177 Vector<ParagraphRunIndex> paragraphs;
178 logicalModel->FindParagraphs( data.index, data.numberOfCharacters, paragraphs );
180 // 3) compare the results.
181 if( data.numberOfParagraphs != paragraphs.Count() )
186 unsigned int index = 0u;
187 for( Vector<ParagraphRunIndex>::ConstIterator it = paragraphs.Begin(),
188 endIt = paragraphs.End();
192 const ParagraphRunIndex paragraphIndex = *it;
194 if( paragraphIndex != data.paragraphs[index] )
203 bool FetchBidirectionalLineInfoTest( const FetchBidirectionalLineInfoData& data )
205 std::cout << " testing : " << data.description << std::endl;
207 LogicalModelPtr logicalModel = LogicalModel::New();
208 VisualModelPtr visualModel = VisualModel::New();
209 Size textArea( 100.f, 300.f );
212 // Create the model with the whole text.
213 const Vector<FontDescriptionRun> fontDescriptions;
214 const LayoutOptions options;
215 CreateTextModel( data.text,
223 for( unsigned int index = 0; index < data.numberOfTests; ++index )
225 const bool fetched = logicalModel->FetchBidirectionalLineInfo( data.characterIndex[index] );
227 if( fetched != data.fetched[index] )
229 std::cout << " Different fetched result : " << fetched << ", expected : " << data.fetched[index] << std::endl;
235 if( logicalModel->mBidirectionalLineIndex != data.bidiLineIndex[index] )
237 std::cout << " Different bidi line index : " << logicalModel->mBidirectionalLineIndex << ", expected : " << data.bidiLineIndex << std::endl;
246 bool GetLogicalCharacterIndexTest( const GetLogicalCharacterIndexData& data )
248 std::cout << " testing : " << data.description << std::endl;
250 LogicalModelPtr logicalModel = LogicalModel::New();
251 VisualModelPtr visualModel = VisualModel::New();
254 // Create the model with the whole text.
255 const Vector<FontDescriptionRun> fontDescriptions;
256 const LayoutOptions options;
257 CreateTextModel( data.text,
265 for( unsigned int index = 0u; index < data.numberOfIndices; ++index )
267 // Check the current cached bidi line index. (Check it before call the GetLogicalCharacterIndex() method )
268 if( data.cachedBidiLine[index] != logicalModel->mBidirectionalLineIndex )
270 std::cout << " index : " << index << ", different cached bidi index : " << logicalModel->mBidirectionalLineIndex << ", expected : " << data.cachedBidiLine[index] << std::endl;
274 const bool fetched = logicalModel->FetchBidirectionalLineInfo( index );
275 const Character logicalIndex = fetched ? logicalModel->GetLogicalCharacterIndex( index ) : index;
277 if( data.visualToLogical[index] != logicalIndex )
279 std::cout << " visual index : " << index << ", different logical index : " << logicalIndex << ", expected : " << data.visualToLogical[index] << std::endl;
286 bool GetLogicalCursorIndexTest( const GetLogicalCursorIndexData& data )
288 std::cout << " testing : " << data.description << std::endl;
290 LogicalModelPtr logicalModel = LogicalModel::New();
291 VisualModelPtr visualModel = VisualModel::New();
294 // Create the model with the whole text.
295 const Vector<FontDescriptionRun> fontDescriptions;
296 const LayoutOptions options;
297 CreateTextModel( data.text,
305 for( unsigned int index = 0u; index < data.numberOfIndices; ++index )
307 const bool fetched = logicalModel->FetchBidirectionalLineInfo( data.characterIndex[index] );
309 if( logicalModel->mBidirectionalLineIndex != data.cachedBidiLine[index] )
311 std::cout << " test : " << index << ", different cached line index : " << logicalModel->mBidirectionalLineIndex << ", expected : " << data.cachedBidiLine[index] << std::endl;
315 const CharacterIndex visualCharacterIndex = data.visualCursorIndex[index];
316 const CharacterIndex logicalCursorIndex = fetched ? logicalModel->GetLogicalCursorIndex( visualCharacterIndex ) : visualCharacterIndex;
318 if( logicalCursorIndex != data.logicalCursorIndex[index] )
320 std::cout << " test : " << index << ", visual index : " << visualCharacterIndex << ", different logical cursor index : " << logicalCursorIndex << ", expected : " << data.logicalCursorIndex[index] << std::endl;
330 //////////////////////////////////////////////////////////
332 // UtcDaliCreateParagraph
333 // UtcDaliFindParagraph
334 // UtcDaliFetchBidirectionalLineInfo
335 // UtcDaliGetLogicalCharacterIndex
336 // UtcDaliGetLogicalCursorIndex
338 //////////////////////////////////////////////////////////
340 int UtcDaliCreateParagraph(void)
342 tet_infoline(" UtcDaliCreateParagraph");
344 unsigned int paragraphsIndices01[] = { 0u };
345 unsigned int paragraphsNumberOfCharacters01[] = { 0u };
346 unsigned int paragraphsIndices02[] = { 0u, 12u, 17u };
347 unsigned int paragraphsNumberOfCharacters02[] = { 12u, 5u, 1u };
348 unsigned int paragraphsIndices03[] = { 0u, 12u, 17u, 34u };
349 unsigned int paragraphsNumberOfCharacters03[] = { 12u, 5u, 17u ,1u };
351 struct CreateParagraphData data[] =
360 paragraphsNumberOfCharacters01,
364 "Hello world\ndemo\n\n",
369 paragraphsNumberOfCharacters02,
372 "Some paragraphs. Update the initial paragraphs.",
373 "Hello world\ndemo\nhello world demo\n\n",
378 paragraphsNumberOfCharacters03,
381 "Some paragraphs. Update the mid paragraphs.",
382 "Hello world\ndemo\nhello world demo\n\n",
387 paragraphsNumberOfCharacters03,
390 "Some paragraphs. Update the final paragraphs.",
391 "Hello world\ndemo\nhello world demo\n\n",
396 paragraphsNumberOfCharacters03,
399 const unsigned int numberOfTests = 5u;
401 for( unsigned int index = 0u; index < numberOfTests; ++index )
403 ToolkitTestApplication application;
404 if( !CreateParagraphTest( data[index] ) )
406 tet_result(TET_FAIL);
410 tet_result(TET_PASS);
414 int UtcDaliFindParagraph(void)
416 tet_infoline(" UtcDaliFindParagraph");
418 unsigned int paragraphs01[] = {};
419 unsigned int paragraphs02[] = { 0u, 1u, 2u };
420 unsigned int paragraphs03[] = { 0u };
421 unsigned int paragraphs04[] = { 1u };
422 unsigned int paragraphs05[] = { 0u, 1u, 2u };
424 struct FindParagraphData data[] =
436 "Hello world\ndemo\n\n",
444 "Hello world\ndemo\n\n",
452 "Hello world\ndemo\n\n",
460 "Hello world\ndemo\n\n",
467 const unsigned int numberOfTests = 5u;
469 for( unsigned int index = 0u; index < numberOfTests; ++index )
471 ToolkitTestApplication application;
472 if( !FindParagraphTest( data[index] ) )
474 tet_result(TET_FAIL);
478 tet_result(TET_PASS);
482 int UtcDaliFetchBidirectionalLineInfo(void)
484 tet_infoline(" UtcDaliFetchBidirectionalLineInfo");
486 unsigned int logicalIndex01[] = { 0u };
487 bool fetched01[] = { false };
488 unsigned int bidiLine01[] = { 0u };
490 unsigned int logicalIndex02[] = { 3u };
491 bool fetched02[] = { false };
492 unsigned int bidiLine02[] = { 0u };
494 unsigned int logicalIndex03[] = { 0u, 11u, 12u, 21u, 22u, 33u, 34u, 43u, 44u, 54u};
495 bool fetched03[] = { false, false, true, true, false, false, true, true, false, false };
496 unsigned int bidiLine03[] = { 0u, 0u, 0u, 0u, 0u, 0u, 1u, 1u, 0u, 0u };
498 struct FetchBidirectionalLineInfoData data[] =
518 "Hello world\nשלום עולם\nhello world\nשלום עולם\nhello world",
525 const unsigned int numberOfTests = 3u;
527 for( unsigned int index = 0u; index < numberOfTests; ++index )
529 ToolkitTestApplication application;
530 if( !FetchBidirectionalLineInfoTest( data[index] ) )
532 tet_result(TET_FAIL);
536 tet_result(TET_PASS);
540 int UtcDaliGetLogicalCharacterIndex(void)
542 tet_infoline(" UtcDaliSetVisualToLogicalMap");
544 unsigned int visualToLogical01[] = {};
545 unsigned int cachedBidiLine01[] = {};
546 unsigned int visualToLogical02[] = { 0u, 1u, 2u, 3u, 4u, 5u, 6u, 7u, 8u, 9u, 10u };
547 unsigned int cachedBidiLine02[] = { 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u };
548 unsigned int visualToLogical03[] = { 12u, 11u, 10u, 9u, 8u, 7u, 6u, 5u, 4u, 3u, 2u, 1u, 0u };
549 unsigned int cachedBidiLine03[] = { 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u };
551 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 };
552 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,
553 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,
554 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 };
557 // LO H e l l o _ w o r l d , _ م ر ح ب ا _ ب ا ل ع ا ل م , _ h e l l o _ w o r l d \n
558 // 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
559 // VO H e l l o _ w o r l d , _ م ل ا ع ل ا ب _ ا ب ح ر م , _ h e l l o _ w o r l d \n
560 // 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
562 // LO م ر ح ب ا _ ب ا ل ع ا ل م , _ h e l l o _ w o r l d , _ م ر ح ب ا _ ب ا ل ع ا ل م \n
563 // 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
564 // VO \n م ل ا ع ل ا ب _ ا ب ح ر م _ , h e l l o _ w o r l d _ , م ل ا ع ل ا ب _ ا ب ح ر م
565 // 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
567 // LO م ر ح ب ا _ ب ا ل ع ا ل م \n
568 // 82 83 84 85 86 87 88 89 90 91 92 93 94 95
569 // VO \n م ل ا ع ل ا ب _ ا ب ح ر م
570 // 95 94 93 92 91 90 89 88 87 86 85 84 83 82
573 // LO h e l l o _ w o r l d
574 // 96 97 98 99 100 101 102 103 104 105 106
575 // VO h e l l o _ w o r l d
576 // 96 97 98 99 100 101 102 103 104 105 106
578 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 };
579 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 };
582 // LO H e l l o _ w o r l d , _ م ر ح ب ا _ ب ا ل ع ا ل م , _
583 // 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
584 // VO H e l l o _ w o r l d , _ م ل ا ع ل ا ب _ ا ب ح ر م , _
585 // 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
587 // LO h e l l o _ w o r l d \n
588 // 28 29 30 31 32 33 34 35 36 37 38 39
589 // VO h e l l o _ w o r l d \n
590 // 28 29 30 31 32 33 34 35 36 37 38 39
592 // LO م ر ح ب ا _ ب ا ل ع ا ل م , _ h e l l o _ w o r l d , _
593 // 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
594 // VO _ , h e l l o _ w o r l d _ , م ل ا ع ل ا ب _ ا ب ح ر م
595 // 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
597 // LO م ر ح ب ا _ ب ا ل ع ا ل م \n
598 // 68 69 70 71 72 73 74 75 76 77 78 79 80 81
599 // VO \n م ل ا ع ل ا ب _ ا ب ح ر م
600 // 81 80 79 78 77 76 75 74 73 72 71 70 69 68
602 // LO م ر ح ب ا _ ب ا ل ع ا ل م \n
603 // 82 83 84 85 86 87 88 89 90 91 92 93 94 95
604 // VO \n م ل ا ع ل ا ب _ ا ب ح ر م
605 // 95 94 93 92 91 90 89 88 87 86 85 84 83 82
608 // LO h e l l o _ w o r l d
609 // 96 97 98 99 100 101 102 103 104 105 106
610 // VO h e l l o _ w o r l d
611 // 96 97 98 99 100 101 102 103 104 105 106
613 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 };
614 unsigned int cachedBidiLine06[] = { 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
615 0u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u,
616 1u, 2u, 2u, 2u, 2u, 2u, 2u, 2u, 2u, 2u, 2u, 2u,
617 2u, 3u, 3u, 3u, 3u, 3u, 3u, 3u, 3u, 3u, 3u, 3u, 3u, 3u, 3u,
618 3u, 4u, 4u, 4u, 4u, 4u, 4u, 4u, 4u, 4u, 4u, 4u, 4u,
619 4u, 5u, 5u, 5u, 5u, 5u, 5u, 5u, 5u, 5u, 5u, 5u, 5u, 5u,
620 5u, 6u, 6u, 6u, 6u, 6u, 6u, 6u, 6u, 6u, 6u, 6u, 6u, 6u,
621 6u, 6u, 6u, 6u, 6u, 6u, 6u, 6u, 6u, 6u, 6u };
624 // LO H e l l o _ w o r l d , _
625 // 0 1 2 3 4 5 6 7 8 9 10 11 12
626 // VO H e l l o _ w o r l d , _
627 // 0 1 2 3 4 5 6 7 8 9 10 11 12
629 // LO م ر ح ب ا _ ب ا ل ع ا ل م , _
630 // 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
631 // VO م ل ا ع ل ا ب _ ا ب ح ر م , _
632 // 25 24 23 22 21 20 19 18 17 16 15 14 13 26 27
634 // LO h e l l o _ w o r l d \n
635 // 28 29 30 31 32 33 34 35 36 37 38 39
636 // VO h e l l o _ w o r l d \n
637 // 28 29 30 31 32 33 34 35 36 37 38 39
639 // LO م ر ح ب ا _ ب ا ل ع ا ل م , _
640 // 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
641 // VO _ , م ل ا ع ل ا ب _ ا ب ح ر م
642 // 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40
644 // LO h e l l o _ w o r l d , _
645 // 55 56 57 58 59 60 61 62 63 64 65 66 67
646 // VO _ , h e l l o _ w o r l d
647 // 67 66 55 56 57 58 59 60 61 62 63 64 65
649 // LO م ر ح ب ا _ ب ا ل ع ا ل م \n
650 // 68 69 70 71 72 73 74 75 76 77 78 79 80 81
651 // VO \n م ل ا ع ل ا ب _ ا ب ح ر م
652 // 81 80 79 78 77 76 75 74 73 72 71 70 69 68
654 // LO م ر ح ب ا _ ب ا ل ع ا ل م \n
655 // 82 83 84 85 86 87 88 89 90 91 92 93 94 95
656 // VO \n م ل ا ع ل ا ب _ ا ب ح ر م
657 // 95 94 93 92 91 90 89 88 87 86 85 84 83 82
660 // LO h e l l o _ w o r l d
661 // 96 97 98 99 100 101 102 103 104 105 106
662 // VO h e l l o _ w o r l d
663 // 96 97 98 99 100 101 102 103 104 105 106
665 struct GetLogicalCharacterIndexData data[] =
668 "Zero characters text",
670 Size( 300.f, 300.f ),
676 "Left to right text only",
678 Size( 300.f, 300.f ),
684 "Right to left text only",
686 Size( 300.f, 300.f ),
692 "Mix of left to right and right to left text.",
693 "Hello world, مرحبا بالعالم, hello world\nمرحبا بالعالم, hello world, مرحبا بالعالم\nمرحبا بالعالم\nhello world",
694 Size( 300.f, 300.f ),
700 "Mix of left to right and right to left text.",
701 "Hello world, مرحبا بالعالم, hello world\nمرحبا بالعالم, hello world, مرحبا بالعالم\nمرحبا بالعالم\nhello world",
702 Size( 200.f, 400.f ),
708 "Mix of left to right and right to left text.",
709 "Hello world, مرحبا بالعالم, hello world\nمرحبا بالعالم, hello world, مرحبا بالعالم\nمرحبا بالعالم\nhello world",
710 Size( 100.f, 600.f ),
716 const unsigned int numberOfTests = 6u;
718 for( unsigned int index = 0u; index < numberOfTests; ++index )
720 ToolkitTestApplication application;
721 if( !GetLogicalCharacterIndexTest( data[index] ) )
723 tet_result(TET_FAIL);
727 tet_result(TET_PASS);
731 int UtcDaliGetLogicalCursorIndex(void)
733 tet_infoline(" UtcDaliGetLogicalCursorIndex");
735 unsigned int visualIndex01[] = { 10u };
736 unsigned int characterIndex01[] = { 0u };
737 unsigned int logicalIndex01[] = { 10u };
738 unsigned int bidirectionalLineIndex01[] = { 0u };
744 unsigned int visualIndex02[] = { 0u, 16u, 11u, 12u };
745 unsigned int characterIndex02[] = { 0u, 0u, 0u, 0u };
746 unsigned int logicalIndex02[] = { 0u, 16u, 11u, 12u };
747 unsigned int bidirectionalLineIndex02[] = { 0u, 0u, 0u, 0u };
750 // LO H e l l o _ w o r l d \n
751 // 0 1 2 3 4 5 6 7 8 9 10 11 12
752 // VO H e l l o _ w o r l d \n
754 // LO ש ל ו ם _ ע ו ל ם \n
755 // 12 13 14 15 16 17 18 19 20 21 22
756 // VO \n ם ל ו ע _ ם ו ל ש
758 // LO h e l l o _ w o r l d _ ש ל ו ם _ ע ו ל ם \n
759 // 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
760 // VO h e l l o _ w o r l d _ ם ל ו ע _ ם ו ל ש \n
762 // LO ש ל ו ם _ ע ו ל ם _ h e l l o _ w o r l d \n
763 // 44 45 46 47 48 49 50 51 52 52 54 55 56 57 58 59 60 61 62 63 64 65 66
764 // VO \n h e l l o _ w o r l d _ ם ל ו ע _ ם ו ל ש
766 unsigned int visualIndex03[] = { 0u, 1u, 2u, 3u, 4u, 5u, 6u, 7u, 8u, 9u, 10u, 11u,
767 13u, 14u, 15u, 16u, 17u, 18u, 19u, 20u, 21u, 22u,
768 22u, 23u, 24u, 25u, 26u, 27u, 28u, 29u, 30u, 31u, 32u, 33u, 34u, 35u, 36u, 37u, 38u, 39u, 40u, 41u, 42u, 43u,
769 45u, 46u, 47u, 48u, 49u, 50u, 51u, 52u, 53u, 54u, 55u, 56u, 57u, 58u, 59u, 60u, 61u, 62u, 63u, 64u, 65u, 66u };
771 unsigned int characterIndex03[] = { 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
772 12u, 12u, 12u, 12u, 12u, 12u, 12u, 12u, 12u, 12u,
773 22u, 22u, 22u, 22u, 22u, 22u, 22u, 22u, 22u, 22u, 22u, 22u, 22u, 22u, 22u, 22u, 22u, 22u, 22u, 22u, 22u, 22u,
774 44u, 44u, 44u, 44u, 44u, 44u, 44u, 44u, 44u, 44u, 44u, 44u, 44u, 44u, 44u, 44u, 44u, 44u, 44u, 44u, 44u, 44u};
776 unsigned int logicalIndex03[] = { 0u, 1u, 2u, 3u, 4u, 5u, 6u, 7u, 8u, 9u, 10u, 11u,
777 21u, 20u, 19u, 18u, 17u, 16u, 15u, 14u, 13u, 12u,
778 22u, 23u, 24u, 25u, 26u, 27u, 28u, 29u, 30u, 31u, 32u, 33u, 34u, 42u, 41u, 40u, 39u, 38u, 37u, 36u, 35u, 43u,
779 65u, 55u, 56u, 57u, 58u, 59u, 60u, 61u, 62u, 63u, 64u, 54u, 53u, 52u, 51u, 50u, 49u, 48u, 47u, 46u, 45u, 44u };
781 unsigned int bidirectionalLineIndex03[] = { 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
782 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
783 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u,
784 2u, 2u, 2u, 2u, 2u, 2u, 2u, 2u, 2u, 2u, 2u, 2u, 2u, 2u, 2u, 2u, 2u, 2u, 2u, 2u, 2u, 2u };
787 // LO ש ל ו ם _ ע ו ל ם \n
788 // 0 1 2 3 4 5 6 7 8 9 10
789 // VO \n ם ל ו ע _ ם ו ל ש
791 // h e l l o _ w o r l d \n
792 // LO 10 11 12 13 14 15 16 17 18 19 20 21 22
793 // h e l l o _ w o r l d \n
795 // ש ל ו ם _ ע ו ל ם _ h e l l o _ w o r l d \n
796 // LO 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
797 // \n h e l l o _ w o r l d _ ם ל ו ע _ ם ו ל ש
799 // h e l l o _ w o r l d _ ש ל ו ם _ ע ו ל ם \n
800 // LO 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
801 // h e l l o _ w o r l d _ ם ל ו ע _ ם ו ל ש \n
803 unsigned int visualIndex04[] = { 1u, 2u, 3u, 4u, 5u, 6u, 7u, 8u, 9u, 10u,
804 10u, 12u, 13u, 14u, 15u, 16u, 17u, 18u, 19u, 20u, 21u,
805 23u, 24u, 25u, 26u, 27u, 28u, 29u, 30u, 31u, 32u, 33u, 34u, 35u, 36u, 37u, 38u, 39u, 40u, 41u, 42u, 43u, 44u,
806 44u, 45u, 46u, 47u, 48u, 49u, 50u, 51u, 52u, 53u, 54u, 55u, 56u, 57u, 58u, 59u, 60u, 61u, 62u, 63u, 64u, 65u };
808 unsigned int characterIndex04[] = { 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
809 10u, 10u, 10u, 10u, 10u, 10u, 10u, 10u, 10u, 10u, 10u,
810 22u, 22u, 22u, 22u, 22u, 22u, 22u, 22u, 22u, 22u, 22u, 22u, 22u, 22u, 22u, 22u, 22u, 22u, 22u, 22u, 22u, 22u,
811 44u, 44u, 44u, 44u, 44u, 44u, 44u, 44u, 44u, 44u, 44u, 44u, 44u, 44u, 44u, 44u, 44u, 44u, 44u, 44u, 44u, 44u };
813 unsigned int logicalIndex04[] = { 9u, 8u, 7u, 6u, 5u, 4u, 3u, 2u, 1u, 0u,
814 10u, 12u, 13u, 14u, 15u, 16u, 17u, 18u, 19u, 20u, 21u,
815 43u, 33u, 34u, 35u, 36u, 37u, 38u, 39u, 40u, 41u, 42u, 32u, 31u, 30u, 29u, 28u, 27u, 26u, 25u, 24u, 23u, 22u,
816 44u, 45u, 46u, 47u, 48u, 49u, 50u, 51u, 52u, 53u, 54u, 55u, 56u, 64u, 63u, 62u, 61u, 60u, 59u, 58u, 57u, 65u };
818 unsigned int bidirectionalLineIndex04[] = { 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
819 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
820 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u,
821 2u, 2u, 2u, 2u, 2u, 2u, 2u, 2u, 2u, 2u, 2u, 2u, 2u, 2u, 2u, 2u, 2u, 2u, 2u, 2u, 2u, 2u };
824 // LO A B C D E F G H I J K
825 // 0 1 2 3 4 5 6 7 8 9 10 11
829 unsigned int visualIndex05[] = { 0u, 1u, 2u, 3u, 4u, 5u, 6u, 7u, 8u, 9u, 10u,
830 11u, 12u, 13u, 14u };
832 unsigned int characterIndex05[] = { 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
833 11u, 11u, 11u, 11u };
835 unsigned int logicalIndex05[] = { 0u, 1u, 2u, 3u, 4u, 5u, 6u, 7u, 8u, 9u, 10u,
836 11u, 12u, 13u, 14u };
838 unsigned int bidirectionalLineIndex05[] = { 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
841 // LO ק ר א ט ו ן ם פ ש ד ג
842 // 0 1 2 3 4 5 6 7 8 9 10 11
843 // VO ג ד ש פ ם ן ו ט א ר ק
849 unsigned int visualIndex06[] = { 1u, 2u, 3u, 4u, 5u, 6u, 7u, 8u, 9u, 10u, 11u,
850 11u, 12u, 13u, 14u, 15u, 16u };
852 unsigned int characterIndex06[] = { 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
853 12u, 12u, 12u, 12u, 12u, 12u };
855 unsigned int logicalIndex06[] = { 10u, 9u, 8u, 7u, 6u, 5u, 4u, 3u, 2u, 1u, 0u,
856 16u, 15u, 14u, 13u, 12u, 11u };
858 unsigned int bidirectionalLineIndex06[] = { 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
859 1u, 1u, 1u, 1u, 1u, 1u };
861 struct GetLogicalCursorIndexData data[] =
864 "Zero characters text",
866 Size( 300.f, 300.f ),
871 bidirectionalLineIndex01,
874 "All left to right text 01.",
876 Size( 300.f, 300.f ),
881 bidirectionalLineIndex02,
884 "bidirectional text 01.",
885 "Hello world\nשלום עולם\nhello world שלום עולם\nשלום עולם hello world\n",
886 Size( 300.f, 300.f ),
891 bidirectionalLineIndex03,
894 "bidirectional text 02.",
895 "שלום עולם\nhello world\nשלום עולם hello world\nhello world שלום עולם\n",
896 Size( 300.f, 300.f ),
901 bidirectionalLineIndex04,
906 Size( 100.f, 300.f ),
911 bidirectionalLineIndex05,
914 "bidirectional text 03.",
916 Size( 100.f, 300.f ),
921 bidirectionalLineIndex06,
924 const unsigned int numberOfTests = 6u;
926 for( unsigned int index = 0u; index < numberOfTests; ++index )
928 ToolkitTestApplication application;
929 if( !GetLogicalCursorIndexTest( data[index] ) )
931 tet_result(TET_FAIL);
935 tet_result(TET_PASS);