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-utils.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;
104 VisualModelPtr visualModel;
106 Size textArea(100.f, 60.f);
109 Vector<FontDescriptionRun> fontDescriptionRuns;
110 LayoutOptions options;
111 CreateTextModel( data.text,
120 // 2) Clear the paragraphs.
121 Vector<ParagraphRun>& paragraphs = logicalModel->mParagraphInfo;
122 ClearCharacterRuns( data.index,
123 data.index + data.numberOfCharacters - 1u,
126 // 3) Call the LogicalModel::CreateParagraphInfo() method
127 logicalModel->CreateParagraphInfo( data.index,
128 data.numberOfCharacters );
130 // 4) Compare the results.
131 if( data.numberOfParagraphs != paragraphs.Count() )
133 std::cout << " Different number of paragraphs : " << paragraphs.Count() << ", expected : " << data.numberOfParagraphs << std::endl;
137 unsigned int index = 0u;
138 for( Vector<ParagraphRun>::ConstIterator it = paragraphs.Begin(),
139 endIt = paragraphs.End();
143 const ParagraphRun& paragraph( *it );
145 if( data.indices[index] != paragraph.characterRun.characterIndex )
147 std::cout << " Different character index for paragraph : " << index << ", " << paragraph.characterRun.characterIndex << ", expected : " << data.indices[index] << std::endl;
150 if( data.numberOfCharactersPerParagraph[index] != paragraph.characterRun.numberOfCharacters )
152 std::cout << " Different number of characters for paragraph : " << index << ", " << paragraph.characterRun.numberOfCharacters << ", expected : " << data.numberOfCharactersPerParagraph[index] << std::endl;
160 bool FindParagraphTest( const FindParagraphData& data )
162 // 1) Create the model.
163 LogicalModelPtr logicalModel;
164 VisualModelPtr visualModel;
166 Size textArea(100.f, 60.f);
169 Vector<FontDescriptionRun> fontDescriptionRuns;
170 LayoutOptions options;
171 CreateTextModel( data.text,
180 // 2) Find the paragraphs.
181 Vector<ParagraphRunIndex> paragraphs;
182 logicalModel->FindParagraphs( data.index, data.numberOfCharacters, paragraphs );
184 // 3) compare the results.
185 if( data.numberOfParagraphs != paragraphs.Count() )
190 unsigned int index = 0u;
191 for( Vector<ParagraphRunIndex>::ConstIterator it = paragraphs.Begin(),
192 endIt = paragraphs.End();
196 const ParagraphRunIndex paragraphIndex = *it;
198 if( paragraphIndex != data.paragraphs[index] )
207 bool FetchBidirectionalLineInfoTest( const FetchBidirectionalLineInfoData& data )
209 std::cout << " testing : " << data.description << std::endl;
211 LogicalModelPtr logicalModel;
212 VisualModelPtr visualModel;
214 Size textArea( 100.f, 300.f );
217 // Create the model with the whole text.
218 const Vector<FontDescriptionRun> fontDescriptions;
219 const LayoutOptions options;
220 CreateTextModel( data.text,
229 for( unsigned int index = 0; index < data.numberOfTests; ++index )
231 const bool fetched = logicalModel->FetchBidirectionalLineInfo( data.characterIndex[index] );
233 if( fetched != data.fetched[index] )
235 std::cout << " Different fetched result : " << fetched << ", expected : " << data.fetched[index] << std::endl;
241 if( logicalModel->mBidirectionalLineIndex != data.bidiLineIndex[index] )
243 std::cout << " Different bidi line index : " << logicalModel->mBidirectionalLineIndex << ", expected : " << data.bidiLineIndex << std::endl;
252 bool GetLogicalCharacterIndexTest( const GetLogicalCharacterIndexData& data )
254 std::cout << " testing : " << data.description << std::endl;
256 LogicalModelPtr logicalModel;
257 VisualModelPtr visualModel;
261 // Create the model with the whole text.
262 const Vector<FontDescriptionRun> fontDescriptions;
263 const LayoutOptions options;
264 CreateTextModel( data.text,
273 for( unsigned int index = 0u; index < data.numberOfIndices; ++index )
275 // Check the current cached bidi line index. (Check it before call the GetLogicalCharacterIndex() method )
276 if( data.cachedBidiLine[index] != logicalModel->mBidirectionalLineIndex )
278 std::cout << " index : " << index << ", different cached bidi index : " << logicalModel->mBidirectionalLineIndex << ", expected : " << data.cachedBidiLine[index] << std::endl;
282 const bool fetched = logicalModel->FetchBidirectionalLineInfo( index );
283 const Character logicalIndex = fetched ? logicalModel->GetLogicalCharacterIndex( index ) : index;
285 if( data.visualToLogical[index] != logicalIndex )
287 std::cout << " visual index : " << index << ", different logical index : " << logicalIndex << ", expected : " << data.visualToLogical[index] << std::endl;
294 bool GetLogicalCursorIndexTest( const GetLogicalCursorIndexData& data )
296 std::cout << " testing : " << data.description << std::endl;
298 LogicalModelPtr logicalModel;
299 VisualModelPtr visualModel;
303 // Create the model with the whole text.
304 const Vector<FontDescriptionRun> fontDescriptions;
305 const LayoutOptions options;
306 CreateTextModel( data.text,
315 for( unsigned int index = 0u; index < data.numberOfIndices; ++index )
317 const bool fetched = logicalModel->FetchBidirectionalLineInfo( data.characterIndex[index] );
319 if( logicalModel->mBidirectionalLineIndex != data.cachedBidiLine[index] )
321 std::cout << " test : " << index << ", different cached line index : " << logicalModel->mBidirectionalLineIndex << ", expected : " << data.cachedBidiLine[index] << std::endl;
325 const CharacterIndex visualCharacterIndex = data.visualCursorIndex[index];
326 const CharacterIndex logicalCursorIndex = fetched ? logicalModel->GetLogicalCursorIndex( visualCharacterIndex ) : visualCharacterIndex;
328 if( logicalCursorIndex != data.logicalCursorIndex[index] )
330 std::cout << " test : " << index << ", visual index : " << visualCharacterIndex << ", different logical cursor index : " << logicalCursorIndex << ", expected : " << data.logicalCursorIndex[index] << std::endl;
340 //////////////////////////////////////////////////////////
342 // UtcDaliCreateParagraph
343 // UtcDaliFindParagraph
344 // UtcDaliFetchBidirectionalLineInfo
345 // UtcDaliGetLogicalCharacterIndex
346 // UtcDaliGetLogicalCursorIndex
348 //////////////////////////////////////////////////////////
350 int UtcDaliCreateParagraph(void)
352 tet_infoline(" UtcDaliCreateParagraph");
354 unsigned int paragraphsIndices01[] = { 0u };
355 unsigned int paragraphsNumberOfCharacters01[] = { 0u };
356 unsigned int paragraphsIndices02[] = { 0u, 12u, 17u };
357 unsigned int paragraphsNumberOfCharacters02[] = { 12u, 5u, 1u };
358 unsigned int paragraphsIndices03[] = { 0u, 12u, 17u, 34u };
359 unsigned int paragraphsNumberOfCharacters03[] = { 12u, 5u, 17u ,1u };
361 struct CreateParagraphData data[] =
370 paragraphsNumberOfCharacters01,
374 "Hello world\ndemo\n\n",
379 paragraphsNumberOfCharacters02,
382 "Some paragraphs. Update the initial paragraphs.",
383 "Hello world\ndemo\nhello world demo\n\n",
388 paragraphsNumberOfCharacters03,
391 "Some paragraphs. Update the mid paragraphs.",
392 "Hello world\ndemo\nhello world demo\n\n",
397 paragraphsNumberOfCharacters03,
400 "Some paragraphs. Update the final paragraphs.",
401 "Hello world\ndemo\nhello world demo\n\n",
406 paragraphsNumberOfCharacters03,
409 const unsigned int numberOfTests = 5u;
411 for( unsigned int index = 0u; index < numberOfTests; ++index )
413 ToolkitTestApplication application;
414 if( !CreateParagraphTest( data[index] ) )
416 tet_result(TET_FAIL);
420 tet_result(TET_PASS);
424 int UtcDaliFindParagraph(void)
426 tet_infoline(" UtcDaliFindParagraph");
428 unsigned int paragraphs01[] = {};
429 unsigned int paragraphs02[] = { 0u, 1u, 2u };
430 unsigned int paragraphs03[] = { 0u };
431 unsigned int paragraphs04[] = { 1u };
432 unsigned int paragraphs05[] = { 0u, 1u, 2u };
434 struct FindParagraphData data[] =
446 "Hello world\ndemo\n\n",
454 "Hello world\ndemo\n\n",
462 "Hello world\ndemo\n\n",
470 "Hello world\ndemo\n\n",
477 const unsigned int numberOfTests = 5u;
479 for( unsigned int index = 0u; index < numberOfTests; ++index )
481 ToolkitTestApplication application;
482 if( !FindParagraphTest( data[index] ) )
484 tet_result(TET_FAIL);
488 tet_result(TET_PASS);
492 int UtcDaliFetchBidirectionalLineInfo(void)
494 tet_infoline(" UtcDaliFetchBidirectionalLineInfo");
496 unsigned int logicalIndex01[] = { 0u };
497 bool fetched01[] = { false };
498 unsigned int bidiLine01[] = { 0u };
500 unsigned int logicalIndex02[] = { 3u };
501 bool fetched02[] = { false };
502 unsigned int bidiLine02[] = { 0u };
504 unsigned int logicalIndex03[] = { 0u, 11u, 12u, 21u, 22u, 33u, 34u, 43u, 44u, 54u};
505 bool fetched03[] = { false, false, true, true, false, false, true, true, false, false };
506 unsigned int bidiLine03[] = { 0u, 0u, 0u, 0u, 0u, 0u, 1u, 1u, 0u, 0u };
508 struct FetchBidirectionalLineInfoData data[] =
528 "Hello world\nשלום עולם\nhello world\nשלום עולם\nhello world",
535 const unsigned int numberOfTests = 3u;
537 for( unsigned int index = 0u; index < numberOfTests; ++index )
539 ToolkitTestApplication application;
540 if( !FetchBidirectionalLineInfoTest( data[index] ) )
542 tet_result(TET_FAIL);
546 tet_result(TET_PASS);
550 int UtcDaliGetLogicalCharacterIndex(void)
552 tet_infoline(" UtcDaliSetVisualToLogicalMap");
554 unsigned int visualToLogical01[] = {};
555 unsigned int cachedBidiLine01[] = {};
556 unsigned int visualToLogical02[] = { 0u, 1u, 2u, 3u, 4u, 5u, 6u, 7u, 8u, 9u, 10u };
557 unsigned int cachedBidiLine02[] = { 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u };
558 unsigned int visualToLogical03[] = { 12u, 11u, 10u, 9u, 8u, 7u, 6u, 5u, 4u, 3u, 2u, 1u, 0u };
559 unsigned int cachedBidiLine03[] = { 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u };
561 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 };
562 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,
563 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,
564 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 };
567 // LO H e l l o _ w o r l d , _ م ر ح ب ا _ ب ا ل ع ا ل م , _ h e l l o _ w o r l d \n
568 // 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
569 // VO H e l l o _ w o r l d , _ م ل ا ع ل ا ب _ ا ب ح ر م , _ h e l l o _ w o r l d \n
570 // 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
572 // LO م ر ح ب ا _ ب ا ل ع ا ل م , _ h e l l o _ w o r l d , _ م ر ح ب ا _ ب ا ل ع ا ل م \n
573 // 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
574 // VO \n م ل ا ع ل ا ب _ ا ب ح ر م _ , h e l l o _ w o r l d _ , م ل ا ع ل ا ب _ ا ب ح ر م
575 // 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
577 // LO م ر ح ب ا _ ب ا ل ع ا ل م \n
578 // 82 83 84 85 86 87 88 89 90 91 92 93 94 95
579 // VO \n م ل ا ع ل ا ب _ ا ب ح ر م
580 // 95 94 93 92 91 90 89 88 87 86 85 84 83 82
583 // LO h e l l o _ w o r l d
584 // 96 97 98 99 100 101 102 103 104 105 106
585 // VO h e l l o _ w o r l d
586 // 96 97 98 99 100 101 102 103 104 105 106
588 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 };
589 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 };
592 // LO H e l l o _ w o r l d , _ م ر ح ب ا _ ب ا ل ع ا ل م , _
593 // 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
594 // VO H e l l o _ w o r l d , _ م ل ا ع ل ا ب _ ا ب ح ر م , _
595 // 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
597 // LO h e l l o _ w o r l d \n
598 // 28 29 30 31 32 33 34 35 36 37 38 39
599 // VO h e l l o _ w o r l d \n
600 // 28 29 30 31 32 33 34 35 36 37 38 39
602 // LO م ر ح ب ا _ ب ا ل ع ا ل م , _ h e l l o _ w o r l d , _
603 // 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
604 // VO _ , h e l l o _ w o r l d _ , م ل ا ع ل ا ب _ ا ب ح ر م
605 // 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
607 // LO م ر ح ب ا _ ب ا ل ع ا ل م \n
608 // 68 69 70 71 72 73 74 75 76 77 78 79 80 81
609 // VO \n م ل ا ع ل ا ب _ ا ب ح ر م
610 // 81 80 79 78 77 76 75 74 73 72 71 70 69 68
612 // LO م ر ح ب ا _ ب ا ل ع ا ل م \n
613 // 82 83 84 85 86 87 88 89 90 91 92 93 94 95
614 // VO \n م ل ا ع ل ا ب _ ا ب ح ر م
615 // 95 94 93 92 91 90 89 88 87 86 85 84 83 82
618 // LO h e l l o _ w o r l d
619 // 96 97 98 99 100 101 102 103 104 105 106
620 // VO h e l l o _ w o r l d
621 // 96 97 98 99 100 101 102 103 104 105 106
623 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 };
624 unsigned int cachedBidiLine06[] = { 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
625 0u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u,
626 1u, 2u, 2u, 2u, 2u, 2u, 2u, 2u, 2u, 2u, 2u, 2u,
627 2u, 3u, 3u, 3u, 3u, 3u, 3u, 3u, 3u, 3u, 3u, 3u, 3u, 3u, 3u,
628 3u, 4u, 4u, 4u, 4u, 4u, 4u, 4u, 4u, 4u, 4u, 4u, 4u,
629 4u, 5u, 5u, 5u, 5u, 5u, 5u, 5u, 5u, 5u, 5u, 5u, 5u, 5u,
630 5u, 6u, 6u, 6u, 6u, 6u, 6u, 6u, 6u, 6u, 6u, 6u, 6u, 6u,
631 6u, 6u, 6u, 6u, 6u, 6u, 6u, 6u, 6u, 6u, 6u };
634 // LO H e l l o _ w o r l d , _
635 // 0 1 2 3 4 5 6 7 8 9 10 11 12
636 // VO H e l l o _ w o r l d , _
637 // 0 1 2 3 4 5 6 7 8 9 10 11 12
639 // LO م ر ح ب ا _ ب ا ل ع ا ل م , _
640 // 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
641 // VO م ل ا ع ل ا ب _ ا ب ح ر م , _
642 // 25 24 23 22 21 20 19 18 17 16 15 14 13 26 27
644 // LO h e l l o _ w o r l d \n
645 // 28 29 30 31 32 33 34 35 36 37 38 39
646 // VO h e l l o _ w o r l d \n
647 // 28 29 30 31 32 33 34 35 36 37 38 39
649 // LO م ر ح ب ا _ ب ا ل ع ا ل م , _
650 // 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
651 // VO _ , م ل ا ع ل ا ب _ ا ب ح ر م
652 // 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40
654 // LO h e l l o _ w o r l d , _
655 // 55 56 57 58 59 60 61 62 63 64 65 66 67
656 // VO _ , h e l l o _ w o r l d
657 // 67 66 55 56 57 58 59 60 61 62 63 64 65
659 // LO م ر ح ب ا _ ب ا ل ع ا ل م \n
660 // 68 69 70 71 72 73 74 75 76 77 78 79 80 81
661 // VO \n م ل ا ع ل ا ب _ ا ب ح ر م
662 // 81 80 79 78 77 76 75 74 73 72 71 70 69 68
664 // LO م ر ح ب ا _ ب ا ل ع ا ل م \n
665 // 82 83 84 85 86 87 88 89 90 91 92 93 94 95
666 // VO \n م ل ا ع ل ا ب _ ا ب ح ر م
667 // 95 94 93 92 91 90 89 88 87 86 85 84 83 82
670 // LO h e l l o _ w o r l d
671 // 96 97 98 99 100 101 102 103 104 105 106
672 // VO h e l l o _ w o r l d
673 // 96 97 98 99 100 101 102 103 104 105 106
675 struct GetLogicalCharacterIndexData data[] =
678 "Zero characters text",
680 Size( 300.f, 300.f ),
686 "Left to right text only",
688 Size( 300.f, 300.f ),
694 "Right to left text only",
696 Size( 300.f, 300.f ),
702 "Mix of left to right and right to left text.",
703 "Hello world, مرحبا بالعالم, hello world\nمرحبا بالعالم, hello world, مرحبا بالعالم\nمرحبا بالعالم\nhello world",
704 Size( 300.f, 300.f ),
710 "Mix of left to right and right to left text.",
711 "Hello world, مرحبا بالعالم, hello world\nمرحبا بالعالم, hello world, مرحبا بالعالم\nمرحبا بالعالم\nhello world",
712 Size( 200.f, 400.f ),
718 "Mix of left to right and right to left text.",
719 "Hello world, مرحبا بالعالم, hello world\nمرحبا بالعالم, hello world, مرحبا بالعالم\nمرحبا بالعالم\nhello world",
720 Size( 100.f, 600.f ),
726 const unsigned int numberOfTests = 6u;
728 for( unsigned int index = 0u; index < numberOfTests; ++index )
730 ToolkitTestApplication application;
731 if( !GetLogicalCharacterIndexTest( data[index] ) )
733 tet_result(TET_FAIL);
737 tet_result(TET_PASS);
741 int UtcDaliGetLogicalCursorIndex(void)
743 tet_infoline(" UtcDaliGetLogicalCursorIndex");
745 unsigned int visualIndex01[] = { 10u };
746 unsigned int characterIndex01[] = { 0u };
747 unsigned int logicalIndex01[] = { 10u };
748 unsigned int bidirectionalLineIndex01[] = { 0u };
754 unsigned int visualIndex02[] = { 0u, 16u, 11u, 12u };
755 unsigned int characterIndex02[] = { 0u, 0u, 0u, 0u };
756 unsigned int logicalIndex02[] = { 0u, 16u, 11u, 12u };
757 unsigned int bidirectionalLineIndex02[] = { 0u, 0u, 0u, 0u };
760 // LO H e l l o _ w o r l d \n
761 // 0 1 2 3 4 5 6 7 8 9 10 11 12
762 // VO H e l l o _ w o r l d \n
764 // LO ש ל ו ם _ ע ו ל ם \n
765 // 12 13 14 15 16 17 18 19 20 21 22
766 // VO \n ם ל ו ע _ ם ו ל ש
768 // LO h e l l o _ w o r l d _ ש ל ו ם _ ע ו ל ם \n
769 // 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
770 // VO h e l l o _ w o r l d _ ם ל ו ע _ ם ו ל ש \n
772 // LO ש ל ו ם _ ע ו ל ם _ h e l l o _ w o r l d \n
773 // 44 45 46 47 48 49 50 51 52 52 54 55 56 57 58 59 60 61 62 63 64 65 66
774 // VO \n h e l l o _ w o r l d _ ם ל ו ע _ ם ו ל ש
776 unsigned int visualIndex03[] = { 0u, 1u, 2u, 3u, 4u, 5u, 6u, 7u, 8u, 9u, 10u, 11u,
777 13u, 14u, 15u, 16u, 17u, 18u, 19u, 20u, 21u, 22u,
778 22u, 23u, 24u, 25u, 26u, 27u, 28u, 29u, 30u, 31u, 32u, 33u, 34u, 35u, 36u, 37u, 38u, 39u, 40u, 41u, 42u, 43u,
779 45u, 46u, 47u, 48u, 49u, 50u, 51u, 52u, 53u, 54u, 55u, 56u, 57u, 58u, 59u, 60u, 61u, 62u, 63u, 64u, 65u, 66u };
781 unsigned int characterIndex03[] = { 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
782 12u, 12u, 12u, 12u, 12u, 12u, 12u, 12u, 12u, 12u,
783 22u, 22u, 22u, 22u, 22u, 22u, 22u, 22u, 22u, 22u, 22u, 22u, 22u, 22u, 22u, 22u, 22u, 22u, 22u, 22u, 22u, 22u,
784 44u, 44u, 44u, 44u, 44u, 44u, 44u, 44u, 44u, 44u, 44u, 44u, 44u, 44u, 44u, 44u, 44u, 44u, 44u, 44u, 44u, 44u};
786 unsigned int logicalIndex03[] = { 0u, 1u, 2u, 3u, 4u, 5u, 6u, 7u, 8u, 9u, 10u, 11u,
787 21u, 20u, 19u, 18u, 17u, 16u, 15u, 14u, 13u, 12u,
788 22u, 23u, 24u, 25u, 26u, 27u, 28u, 29u, 30u, 31u, 32u, 33u, 34u, 42u, 41u, 40u, 39u, 38u, 37u, 36u, 35u, 43u,
789 65u, 55u, 56u, 57u, 58u, 59u, 60u, 61u, 62u, 63u, 64u, 54u, 53u, 52u, 51u, 50u, 49u, 48u, 47u, 46u, 45u, 44u };
791 unsigned int bidirectionalLineIndex03[] = { 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
792 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
793 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u,
794 2u, 2u, 2u, 2u, 2u, 2u, 2u, 2u, 2u, 2u, 2u, 2u, 2u, 2u, 2u, 2u, 2u, 2u, 2u, 2u, 2u, 2u };
797 // LO ש ל ו ם _ ע ו ל ם \n
798 // 0 1 2 3 4 5 6 7 8 9 10
799 // VO \n ם ל ו ע _ ם ו ל ש
801 // h e l l o _ w o r l d \n
802 // LO 10 11 12 13 14 15 16 17 18 19 20 21 22
803 // h e l l o _ w o r l d \n
805 // ש ל ו ם _ ע ו ל ם _ h e l l o _ w o r l d \n
806 // LO 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
807 // \n h e l l o _ w o r l d _ ם ל ו ע _ ם ו ל ש
809 // h e l l o _ w o r l d _ ש ל ו ם _ ע ו ל ם \n
810 // LO 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
811 // h e l l o _ w o r l d _ ם ל ו ע _ ם ו ל ש \n
813 unsigned int visualIndex04[] = { 1u, 2u, 3u, 4u, 5u, 6u, 7u, 8u, 9u, 10u,
814 10u, 12u, 13u, 14u, 15u, 16u, 17u, 18u, 19u, 20u, 21u,
815 23u, 24u, 25u, 26u, 27u, 28u, 29u, 30u, 31u, 32u, 33u, 34u, 35u, 36u, 37u, 38u, 39u, 40u, 41u, 42u, 43u, 44u,
816 44u, 45u, 46u, 47u, 48u, 49u, 50u, 51u, 52u, 53u, 54u, 55u, 56u, 57u, 58u, 59u, 60u, 61u, 62u, 63u, 64u, 65u };
818 unsigned int characterIndex04[] = { 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
819 10u, 10u, 10u, 10u, 10u, 10u, 10u, 10u, 10u, 10u, 10u,
820 22u, 22u, 22u, 22u, 22u, 22u, 22u, 22u, 22u, 22u, 22u, 22u, 22u, 22u, 22u, 22u, 22u, 22u, 22u, 22u, 22u, 22u,
821 44u, 44u, 44u, 44u, 44u, 44u, 44u, 44u, 44u, 44u, 44u, 44u, 44u, 44u, 44u, 44u, 44u, 44u, 44u, 44u, 44u, 44u };
823 unsigned int logicalIndex04[] = { 9u, 8u, 7u, 6u, 5u, 4u, 3u, 2u, 1u, 0u,
824 10u, 12u, 13u, 14u, 15u, 16u, 17u, 18u, 19u, 20u, 21u,
825 43u, 33u, 34u, 35u, 36u, 37u, 38u, 39u, 40u, 41u, 42u, 32u, 31u, 30u, 29u, 28u, 27u, 26u, 25u, 24u, 23u, 22u,
826 44u, 45u, 46u, 47u, 48u, 49u, 50u, 51u, 52u, 53u, 54u, 55u, 56u, 64u, 63u, 62u, 61u, 60u, 59u, 58u, 57u, 65u };
828 unsigned int bidirectionalLineIndex04[] = { 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
829 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
830 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u,
831 2u, 2u, 2u, 2u, 2u, 2u, 2u, 2u, 2u, 2u, 2u, 2u, 2u, 2u, 2u, 2u, 2u, 2u, 2u, 2u, 2u, 2u };
834 // LO A B C D E F G H I J K
835 // 0 1 2 3 4 5 6 7 8 9 10 11
839 unsigned int visualIndex05[] = { 0u, 1u, 2u, 3u, 4u, 5u, 6u, 7u, 8u, 9u, 10u,
840 11u, 12u, 13u, 14u };
842 unsigned int characterIndex05[] = { 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
843 11u, 11u, 11u, 11u };
845 unsigned int logicalIndex05[] = { 0u, 1u, 2u, 3u, 4u, 5u, 6u, 7u, 8u, 9u, 10u,
846 11u, 12u, 13u, 14u };
848 unsigned int bidirectionalLineIndex05[] = { 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
851 // LO ק ר א ט ו ן ם פ ש ד ג
852 // 0 1 2 3 4 5 6 7 8 9 10 11
853 // VO ג ד ש פ ם ן ו ט א ר ק
859 unsigned int visualIndex06[] = { 1u, 2u, 3u, 4u, 5u, 6u, 7u, 8u, 9u, 10u, 11u,
860 11u, 12u, 13u, 14u, 15u, 16u };
862 unsigned int characterIndex06[] = { 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
863 12u, 12u, 12u, 12u, 12u, 12u };
865 unsigned int logicalIndex06[] = { 10u, 9u, 8u, 7u, 6u, 5u, 4u, 3u, 2u, 1u, 0u,
866 16u, 15u, 14u, 13u, 12u, 11u };
868 unsigned int bidirectionalLineIndex06[] = { 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
869 1u, 1u, 1u, 1u, 1u, 1u };
871 struct GetLogicalCursorIndexData data[] =
874 "Zero characters text",
876 Size( 300.f, 300.f ),
881 bidirectionalLineIndex01,
884 "All left to right text 01.",
886 Size( 300.f, 300.f ),
891 bidirectionalLineIndex02,
894 "bidirectional text 01.",
895 "Hello world\nשלום עולם\nhello world שלום עולם\nשלום עולם hello world\n",
896 Size( 300.f, 300.f ),
901 bidirectionalLineIndex03,
904 "bidirectional text 02.",
905 "שלום עולם\nhello world\nשלום עולם hello world\nhello world שלום עולם\n",
906 Size( 300.f, 300.f ),
911 bidirectionalLineIndex04,
916 Size( 100.f, 300.f ),
921 bidirectionalLineIndex05,
924 "bidirectional text 03.",
926 Size( 100.f, 300.f ),
931 bidirectionalLineIndex06,
934 const unsigned int numberOfTests = 6u;
936 for( unsigned int index = 0u; index < numberOfTests; ++index )
938 ToolkitTestApplication application;
939 if( !GetLogicalCursorIndexTest( data[index] ) )
941 tet_result(TET_FAIL);
945 tet_result(TET_PASS);