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,
121 // 2) Clear the paragraphs.
122 Vector<ParagraphRun>& paragraphs = logicalModel->mParagraphInfo;
123 ClearCharacterRuns( data.index,
124 data.index + data.numberOfCharacters - 1u,
127 // 3) Call the LogicalModel::CreateParagraphInfo() method
128 logicalModel->CreateParagraphInfo( data.index,
129 data.numberOfCharacters );
131 // 4) Compare the results.
132 if( data.numberOfParagraphs != paragraphs.Count() )
134 std::cout << " Different number of paragraphs : " << paragraphs.Count() << ", expected : " << data.numberOfParagraphs << std::endl;
138 unsigned int index = 0u;
139 for( Vector<ParagraphRun>::ConstIterator it = paragraphs.Begin(),
140 endIt = paragraphs.End();
144 const ParagraphRun& paragraph( *it );
146 if( data.indices[index] != paragraph.characterRun.characterIndex )
148 std::cout << " Different character index for paragraph : " << index << ", " << paragraph.characterRun.characterIndex << ", expected : " << data.indices[index] << std::endl;
151 if( data.numberOfCharactersPerParagraph[index] != paragraph.characterRun.numberOfCharacters )
153 std::cout << " Different number of characters for paragraph : " << index << ", " << paragraph.characterRun.numberOfCharacters << ", expected : " << data.numberOfCharactersPerParagraph[index] << std::endl;
161 bool FindParagraphTest( const FindParagraphData& data )
163 // 1) Create the model.
164 LogicalModelPtr logicalModel;
165 VisualModelPtr visualModel;
167 Size textArea(100.f, 60.f);
170 Vector<FontDescriptionRun> fontDescriptionRuns;
171 LayoutOptions options;
172 CreateTextModel( data.text,
182 // 2) Find the paragraphs.
183 Vector<ParagraphRunIndex> paragraphs;
184 logicalModel->FindParagraphs( data.index, data.numberOfCharacters, paragraphs );
186 // 3) compare the results.
187 if( data.numberOfParagraphs != paragraphs.Count() )
192 unsigned int index = 0u;
193 for( Vector<ParagraphRunIndex>::ConstIterator it = paragraphs.Begin(),
194 endIt = paragraphs.End();
198 const ParagraphRunIndex paragraphIndex = *it;
200 if( paragraphIndex != data.paragraphs[index] )
209 bool FetchBidirectionalLineInfoTest( const FetchBidirectionalLineInfoData& data )
211 std::cout << " testing : " << data.description << std::endl;
213 LogicalModelPtr logicalModel;
214 VisualModelPtr visualModel;
216 Size textArea( 100.f, 300.f );
219 // Create the model with the whole text.
220 const Vector<FontDescriptionRun> fontDescriptions;
221 const LayoutOptions options;
222 CreateTextModel( data.text,
232 for( unsigned int index = 0; index < data.numberOfTests; ++index )
234 const bool fetched = logicalModel->FetchBidirectionalLineInfo( data.characterIndex[index] );
236 if( fetched != data.fetched[index] )
238 std::cout << " Different fetched result : " << fetched << ", expected : " << data.fetched[index] << std::endl;
244 if( logicalModel->mBidirectionalLineIndex != data.bidiLineIndex[index] )
246 std::cout << " Different bidi line index : " << logicalModel->mBidirectionalLineIndex << ", expected : " << data.bidiLineIndex << std::endl;
255 bool GetLogicalCharacterIndexTest( const GetLogicalCharacterIndexData& data )
257 std::cout << " testing : " << data.description << std::endl;
259 LogicalModelPtr logicalModel;
260 VisualModelPtr visualModel;
264 // Create the model with the whole text.
265 const Vector<FontDescriptionRun> fontDescriptions;
266 const LayoutOptions options;
267 CreateTextModel( data.text,
277 for( unsigned int index = 0u; index < data.numberOfIndices; ++index )
279 // Check the current cached bidi line index. (Check it before call the GetLogicalCharacterIndex() method )
280 if( data.cachedBidiLine[index] != logicalModel->mBidirectionalLineIndex )
282 std::cout << " index : " << index << ", different cached bidi index : " << logicalModel->mBidirectionalLineIndex << ", expected : " << data.cachedBidiLine[index] << std::endl;
286 const bool fetched = logicalModel->FetchBidirectionalLineInfo( index );
287 const Character logicalIndex = fetched ? logicalModel->GetLogicalCharacterIndex( index ) : index;
289 if( data.visualToLogical[index] != logicalIndex )
291 std::cout << " visual index : " << index << ", different logical index : " << logicalIndex << ", expected : " << data.visualToLogical[index] << std::endl;
298 bool GetLogicalCursorIndexTest( const GetLogicalCursorIndexData& data )
300 std::cout << " testing : " << data.description << std::endl;
302 LogicalModelPtr logicalModel;
303 VisualModelPtr visualModel;
307 // Create the model with the whole text.
308 const Vector<FontDescriptionRun> fontDescriptions;
309 const LayoutOptions options;
310 CreateTextModel( data.text,
320 for( unsigned int index = 0u; index < data.numberOfIndices; ++index )
322 const bool fetched = logicalModel->FetchBidirectionalLineInfo( data.characterIndex[index] );
324 if( logicalModel->mBidirectionalLineIndex != data.cachedBidiLine[index] )
326 std::cout << " test : " << index << ", different cached line index : " << logicalModel->mBidirectionalLineIndex << ", expected : " << data.cachedBidiLine[index] << std::endl;
330 const CharacterIndex visualCharacterIndex = data.visualCursorIndex[index];
331 const CharacterIndex logicalCursorIndex = fetched ? logicalModel->GetLogicalCursorIndex( visualCharacterIndex ) : visualCharacterIndex;
333 if( logicalCursorIndex != data.logicalCursorIndex[index] )
335 std::cout << " test : " << index << ", visual index : " << visualCharacterIndex << ", different logical cursor index : " << logicalCursorIndex << ", expected : " << data.logicalCursorIndex[index] << std::endl;
345 //////////////////////////////////////////////////////////
347 // UtcDaliCreateParagraph
348 // UtcDaliFindParagraph
349 // UtcDaliFetchBidirectionalLineInfo
350 // UtcDaliGetLogicalCharacterIndex
351 // UtcDaliGetLogicalCursorIndex
353 //////////////////////////////////////////////////////////
355 int UtcDaliCreateParagraph(void)
357 tet_infoline(" UtcDaliCreateParagraph");
359 unsigned int paragraphsIndices01[] = { 0u };
360 unsigned int paragraphsNumberOfCharacters01[] = { 0u };
361 unsigned int paragraphsIndices02[] = { 0u, 12u, 17u };
362 unsigned int paragraphsNumberOfCharacters02[] = { 12u, 5u, 1u };
363 unsigned int paragraphsIndices03[] = { 0u, 12u, 17u, 34u };
364 unsigned int paragraphsNumberOfCharacters03[] = { 12u, 5u, 17u ,1u };
366 struct CreateParagraphData data[] =
375 paragraphsNumberOfCharacters01,
379 "Hello world\ndemo\n\n",
384 paragraphsNumberOfCharacters02,
387 "Some paragraphs. Update the initial paragraphs.",
388 "Hello world\ndemo\nhello world demo\n\n",
393 paragraphsNumberOfCharacters03,
396 "Some paragraphs. Update the mid paragraphs.",
397 "Hello world\ndemo\nhello world demo\n\n",
402 paragraphsNumberOfCharacters03,
405 "Some paragraphs. Update the final paragraphs.",
406 "Hello world\ndemo\nhello world demo\n\n",
411 paragraphsNumberOfCharacters03,
414 const unsigned int numberOfTests = 5u;
416 for( unsigned int index = 0u; index < numberOfTests; ++index )
418 ToolkitTestApplication application;
419 if( !CreateParagraphTest( data[index] ) )
421 tet_result(TET_FAIL);
425 tet_result(TET_PASS);
429 int UtcDaliFindParagraph(void)
431 tet_infoline(" UtcDaliFindParagraph");
433 unsigned int paragraphs01[] = {};
434 unsigned int paragraphs02[] = { 0u, 1u, 2u };
435 unsigned int paragraphs03[] = { 0u };
436 unsigned int paragraphs04[] = { 1u };
437 unsigned int paragraphs05[] = { 0u, 1u, 2u };
439 struct FindParagraphData data[] =
451 "Hello world\ndemo\n\n",
459 "Hello world\ndemo\n\n",
467 "Hello world\ndemo\n\n",
475 "Hello world\ndemo\n\n",
482 const unsigned int numberOfTests = 5u;
484 for( unsigned int index = 0u; index < numberOfTests; ++index )
486 ToolkitTestApplication application;
487 if( !FindParagraphTest( data[index] ) )
489 tet_result(TET_FAIL);
493 tet_result(TET_PASS);
497 int UtcDaliFetchBidirectionalLineInfo(void)
499 tet_infoline(" UtcDaliFetchBidirectionalLineInfo");
501 unsigned int logicalIndex01[] = { 0u };
502 bool fetched01[] = { false };
503 unsigned int bidiLine01[] = { 0u };
505 unsigned int logicalIndex02[] = { 3u };
506 bool fetched02[] = { false };
507 unsigned int bidiLine02[] = { 0u };
509 unsigned int logicalIndex03[] = { 0u, 11u, 12u, 21u, 22u, 33u, 34u, 43u, 44u, 54u};
510 bool fetched03[] = { false, false, true, true, false, false, true, true, false, false };
511 unsigned int bidiLine03[] = { 0u, 0u, 0u, 0u, 0u, 0u, 1u, 1u, 0u, 0u };
513 struct FetchBidirectionalLineInfoData data[] =
533 "Hello world\nשלום עולם\nhello world\nשלום עולם\nhello world",
540 const unsigned int numberOfTests = 3u;
542 for( unsigned int index = 0u; index < numberOfTests; ++index )
544 ToolkitTestApplication application;
545 if( !FetchBidirectionalLineInfoTest( data[index] ) )
547 tet_result(TET_FAIL);
551 tet_result(TET_PASS);
555 int UtcDaliGetLogicalCharacterIndex(void)
557 tet_infoline(" UtcDaliSetVisualToLogicalMap");
559 unsigned int visualToLogical01[] = {};
560 unsigned int cachedBidiLine01[] = {};
561 unsigned int visualToLogical02[] = { 0u, 1u, 2u, 3u, 4u, 5u, 6u, 7u, 8u, 9u, 10u };
562 unsigned int cachedBidiLine02[] = { 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u };
563 unsigned int visualToLogical03[] = { 12u, 11u, 10u, 9u, 8u, 7u, 6u, 5u, 4u, 3u, 2u, 1u, 0u };
564 unsigned int cachedBidiLine03[] = { 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u };
566 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 };
567 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,
568 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,
569 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 };
572 // LO H e l l o _ w o r l d , _ م ر ح ب ا _ ب ا ل ع ا ل م , _ h e l l o _ w o r l d \n
573 // 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
574 // VO H e l l o _ w o r l d , _ م ل ا ع ل ا ب _ ا ب ح ر م , _ h e l l o _ w o r l d \n
575 // 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
577 // LO م ر ح ب ا _ ب ا ل ع ا ل م , _ h e l l o _ w o r l d , _ م ر ح ب ا _ ب ا ل ع ا ل م \n
578 // 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
579 // VO \n م ل ا ع ل ا ب _ ا ب ح ر م _ , h e l l o _ w o r l d _ , م ل ا ع ل ا ب _ ا ب ح ر م
580 // 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
582 // LO م ر ح ب ا _ ب ا ل ع ا ل م \n
583 // 82 83 84 85 86 87 88 89 90 91 92 93 94 95
584 // VO \n م ل ا ع ل ا ب _ ا ب ح ر م
585 // 95 94 93 92 91 90 89 88 87 86 85 84 83 82
588 // LO h e l l o _ w o r l d
589 // 96 97 98 99 100 101 102 103 104 105 106
590 // VO h e l l o _ w o r l d
591 // 96 97 98 99 100 101 102 103 104 105 106
593 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 };
594 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 };
597 // LO H e l l o _ w o r l d , _ م ر ح ب ا _ ب ا ل ع ا ل م , _
598 // 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
599 // VO H e l l o _ w o r l d , _ م ل ا ع ل ا ب _ ا ب ح ر م , _
600 // 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
602 // LO h e l l o _ w o r l d \n
603 // 28 29 30 31 32 33 34 35 36 37 38 39
604 // VO h e l l o _ w o r l d \n
605 // 28 29 30 31 32 33 34 35 36 37 38 39
607 // LO م ر ح ب ا _ ب ا ل ع ا ل م , _ h e l l o _ w o r l d , _
608 // 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
609 // VO _ , h e l l o _ w o r l d _ , م ل ا ع ل ا ب _ ا ب ح ر م
610 // 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
612 // LO م ر ح ب ا _ ب ا ل ع ا ل م \n
613 // 68 69 70 71 72 73 74 75 76 77 78 79 80 81
614 // VO \n م ل ا ع ل ا ب _ ا ب ح ر م
615 // 81 80 79 78 77 76 75 74 73 72 71 70 69 68
617 // LO م ر ح ب ا _ ب ا ل ع ا ل م \n
618 // 82 83 84 85 86 87 88 89 90 91 92 93 94 95
619 // VO \n م ل ا ع ل ا ب _ ا ب ح ر م
620 // 95 94 93 92 91 90 89 88 87 86 85 84 83 82
623 // LO h e l l o _ w o r l d
624 // 96 97 98 99 100 101 102 103 104 105 106
625 // VO h e l l o _ w o r l d
626 // 96 97 98 99 100 101 102 103 104 105 106
628 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 };
629 unsigned int cachedBidiLine06[] = { 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
630 0u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u,
631 1u, 2u, 2u, 2u, 2u, 2u, 2u, 2u, 2u, 2u, 2u, 2u,
632 2u, 3u, 3u, 3u, 3u, 3u, 3u, 3u, 3u, 3u, 3u, 3u, 3u, 3u, 3u,
633 3u, 4u, 4u, 4u, 4u, 4u, 4u, 4u, 4u, 4u, 4u, 4u, 4u,
634 4u, 5u, 5u, 5u, 5u, 5u, 5u, 5u, 5u, 5u, 5u, 5u, 5u, 5u,
635 5u, 6u, 6u, 6u, 6u, 6u, 6u, 6u, 6u, 6u, 6u, 6u, 6u, 6u,
636 6u, 6u, 6u, 6u, 6u, 6u, 6u, 6u, 6u, 6u, 6u };
639 // LO H e l l o _ w o r l d , _
640 // 0 1 2 3 4 5 6 7 8 9 10 11 12
641 // VO H e l l o _ w o r l d , _
642 // 0 1 2 3 4 5 6 7 8 9 10 11 12
644 // LO م ر ح ب ا _ ب ا ل ع ا ل م , _
645 // 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
646 // VO م ل ا ع ل ا ب _ ا ب ح ر م , _
647 // 25 24 23 22 21 20 19 18 17 16 15 14 13 26 27
649 // LO h e l l o _ w o r l d \n
650 // 28 29 30 31 32 33 34 35 36 37 38 39
651 // VO h e l l o _ w o r l d \n
652 // 28 29 30 31 32 33 34 35 36 37 38 39
654 // LO م ر ح ب ا _ ب ا ل ع ا ل م , _
655 // 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
656 // VO _ , م ل ا ع ل ا ب _ ا ب ح ر م
657 // 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40
659 // LO h e l l o _ w o r l d , _
660 // 55 56 57 58 59 60 61 62 63 64 65 66 67
661 // VO _ , h e l l o _ w o r l d
662 // 67 66 55 56 57 58 59 60 61 62 63 64 65
664 // LO م ر ح ب ا _ ب ا ل ع ا ل م \n
665 // 68 69 70 71 72 73 74 75 76 77 78 79 80 81
666 // VO \n م ل ا ع ل ا ب _ ا ب ح ر م
667 // 81 80 79 78 77 76 75 74 73 72 71 70 69 68
669 // LO م ر ح ب ا _ ب ا ل ع ا ل م \n
670 // 82 83 84 85 86 87 88 89 90 91 92 93 94 95
671 // VO \n م ل ا ع ل ا ب _ ا ب ح ر م
672 // 95 94 93 92 91 90 89 88 87 86 85 84 83 82
675 // LO h e l l o _ w o r l d
676 // 96 97 98 99 100 101 102 103 104 105 106
677 // VO h e l l o _ w o r l d
678 // 96 97 98 99 100 101 102 103 104 105 106
680 struct GetLogicalCharacterIndexData data[] =
683 "Zero characters text",
685 Size( 300.f, 300.f ),
691 "Left to right text only",
693 Size( 300.f, 300.f ),
699 "Right to left text only",
701 Size( 300.f, 300.f ),
707 "Mix of left to right and right to left text.",
708 "Hello world, مرحبا بالعالم, hello world\nمرحبا بالعالم, hello world, مرحبا بالعالم\nمرحبا بالعالم\nhello world",
709 Size( 300.f, 300.f ),
715 "Mix of left to right and right to left text.",
716 "Hello world, مرحبا بالعالم, hello world\nمرحبا بالعالم, hello world, مرحبا بالعالم\nمرحبا بالعالم\nhello world",
717 Size( 200.f, 400.f ),
723 "Mix of left to right and right to left text.",
724 "Hello world, مرحبا بالعالم, hello world\nمرحبا بالعالم, hello world, مرحبا بالعالم\nمرحبا بالعالم\nhello world",
725 Size( 100.f, 600.f ),
731 const unsigned int numberOfTests = 6u;
733 for( unsigned int index = 0u; index < numberOfTests; ++index )
735 ToolkitTestApplication application;
736 if( !GetLogicalCharacterIndexTest( data[index] ) )
738 tet_result(TET_FAIL);
742 tet_result(TET_PASS);
746 int UtcDaliGetLogicalCursorIndex(void)
748 tet_infoline(" UtcDaliGetLogicalCursorIndex");
750 unsigned int visualIndex01[] = { 10u };
751 unsigned int characterIndex01[] = { 0u };
752 unsigned int logicalIndex01[] = { 10u };
753 unsigned int bidirectionalLineIndex01[] = { 0u };
759 unsigned int visualIndex02[] = { 0u, 16u, 11u, 12u };
760 unsigned int characterIndex02[] = { 0u, 0u, 0u, 0u };
761 unsigned int logicalIndex02[] = { 0u, 16u, 11u, 12u };
762 unsigned int bidirectionalLineIndex02[] = { 0u, 0u, 0u, 0u };
765 // LO H e l l o _ w o r l d \n
766 // 0 1 2 3 4 5 6 7 8 9 10 11 12
767 // VO H e l l o _ w o r l d \n
769 // LO ש ל ו ם _ ע ו ל ם \n
770 // 12 13 14 15 16 17 18 19 20 21 22
771 // VO \n ם ל ו ע _ ם ו ל ש
773 // LO h e l l o _ w o r l d _ ש ל ו ם _ ע ו ל ם \n
774 // 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
775 // VO h e l l o _ w o r l d _ ם ל ו ע _ ם ו ל ש \n
777 // LO ש ל ו ם _ ע ו ל ם _ h e l l o _ w o r l d \n
778 // 44 45 46 47 48 49 50 51 52 52 54 55 56 57 58 59 60 61 62 63 64 65 66
779 // VO \n h e l l o _ w o r l d _ ם ל ו ע _ ם ו ל ש
781 unsigned int visualIndex03[] = { 0u, 1u, 2u, 3u, 4u, 5u, 6u, 7u, 8u, 9u, 10u, 11u,
782 13u, 14u, 15u, 16u, 17u, 18u, 19u, 20u, 21u, 22u,
783 22u, 23u, 24u, 25u, 26u, 27u, 28u, 29u, 30u, 31u, 32u, 33u, 34u, 35u, 36u, 37u, 38u, 39u, 40u, 41u, 42u, 43u,
784 45u, 46u, 47u, 48u, 49u, 50u, 51u, 52u, 53u, 54u, 55u, 56u, 57u, 58u, 59u, 60u, 61u, 62u, 63u, 64u, 65u, 66u };
786 unsigned int characterIndex03[] = { 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
787 12u, 12u, 12u, 12u, 12u, 12u, 12u, 12u, 12u, 12u,
788 22u, 22u, 22u, 22u, 22u, 22u, 22u, 22u, 22u, 22u, 22u, 22u, 22u, 22u, 22u, 22u, 22u, 22u, 22u, 22u, 22u, 22u,
789 44u, 44u, 44u, 44u, 44u, 44u, 44u, 44u, 44u, 44u, 44u, 44u, 44u, 44u, 44u, 44u, 44u, 44u, 44u, 44u, 44u, 44u};
791 unsigned int logicalIndex03[] = { 0u, 1u, 2u, 3u, 4u, 5u, 6u, 7u, 8u, 9u, 10u, 11u,
792 21u, 20u, 19u, 18u, 17u, 16u, 15u, 14u, 13u, 12u,
793 22u, 23u, 24u, 25u, 26u, 27u, 28u, 29u, 30u, 31u, 32u, 33u, 34u, 42u, 41u, 40u, 39u, 38u, 37u, 36u, 35u, 43u,
794 65u, 55u, 56u, 57u, 58u, 59u, 60u, 61u, 62u, 63u, 64u, 54u, 53u, 52u, 51u, 50u, 49u, 48u, 47u, 46u, 45u, 44u };
796 unsigned int bidirectionalLineIndex03[] = { 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
797 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
798 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u,
799 2u, 2u, 2u, 2u, 2u, 2u, 2u, 2u, 2u, 2u, 2u, 2u, 2u, 2u, 2u, 2u, 2u, 2u, 2u, 2u, 2u, 2u };
802 // LO ש ל ו ם _ ע ו ל ם \n
803 // 0 1 2 3 4 5 6 7 8 9 10
804 // VO \n ם ל ו ע _ ם ו ל ש
806 // h e l l o _ w o r l d \n
807 // LO 10 11 12 13 14 15 16 17 18 19 20 21 22
808 // h e l l o _ w o r l d \n
810 // ש ל ו ם _ ע ו ל ם _ h e l l o _ w o r l d \n
811 // LO 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
812 // \n h e l l o _ w o r l d _ ם ל ו ע _ ם ו ל ש
814 // h e l l o _ w o r l d _ ש ל ו ם _ ע ו ל ם \n
815 // LO 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
816 // h e l l o _ w o r l d _ ם ל ו ע _ ם ו ל ש \n
818 unsigned int visualIndex04[] = { 1u, 2u, 3u, 4u, 5u, 6u, 7u, 8u, 9u, 10u,
819 10u, 12u, 13u, 14u, 15u, 16u, 17u, 18u, 19u, 20u, 21u,
820 23u, 24u, 25u, 26u, 27u, 28u, 29u, 30u, 31u, 32u, 33u, 34u, 35u, 36u, 37u, 38u, 39u, 40u, 41u, 42u, 43u, 44u,
821 44u, 45u, 46u, 47u, 48u, 49u, 50u, 51u, 52u, 53u, 54u, 55u, 56u, 57u, 58u, 59u, 60u, 61u, 62u, 63u, 64u, 65u };
823 unsigned int characterIndex04[] = { 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
824 10u, 10u, 10u, 10u, 10u, 10u, 10u, 10u, 10u, 10u, 10u,
825 22u, 22u, 22u, 22u, 22u, 22u, 22u, 22u, 22u, 22u, 22u, 22u, 22u, 22u, 22u, 22u, 22u, 22u, 22u, 22u, 22u, 22u,
826 44u, 44u, 44u, 44u, 44u, 44u, 44u, 44u, 44u, 44u, 44u, 44u, 44u, 44u, 44u, 44u, 44u, 44u, 44u, 44u, 44u, 44u };
828 unsigned int logicalIndex04[] = { 9u, 8u, 7u, 6u, 5u, 4u, 3u, 2u, 1u, 0u,
829 10u, 12u, 13u, 14u, 15u, 16u, 17u, 18u, 19u, 20u, 21u,
830 43u, 33u, 34u, 35u, 36u, 37u, 38u, 39u, 40u, 41u, 42u, 32u, 31u, 30u, 29u, 28u, 27u, 26u, 25u, 24u, 23u, 22u,
831 44u, 45u, 46u, 47u, 48u, 49u, 50u, 51u, 52u, 53u, 54u, 55u, 56u, 64u, 63u, 62u, 61u, 60u, 59u, 58u, 57u, 65u };
833 unsigned int bidirectionalLineIndex04[] = { 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
834 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
835 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u,
836 2u, 2u, 2u, 2u, 2u, 2u, 2u, 2u, 2u, 2u, 2u, 2u, 2u, 2u, 2u, 2u, 2u, 2u, 2u, 2u, 2u, 2u };
839 // LO A B C D E F G H I J K
840 // 0 1 2 3 4 5 6 7 8 9 10 11
844 unsigned int visualIndex05[] = { 0u, 1u, 2u, 3u, 4u, 5u, 6u, 7u, 8u, 9u, 10u,
845 11u, 12u, 13u, 14u };
847 unsigned int characterIndex05[] = { 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
848 11u, 11u, 11u, 11u };
850 unsigned int logicalIndex05[] = { 0u, 1u, 2u, 3u, 4u, 5u, 6u, 7u, 8u, 9u, 10u,
851 11u, 12u, 13u, 14u };
853 unsigned int bidirectionalLineIndex05[] = { 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
856 // LO ק ר א ט ו ן ם פ ש ד ג
857 // 0 1 2 3 4 5 6 7 8 9 10 11
858 // VO ג ד ש פ ם ן ו ט א ר ק
864 unsigned int visualIndex06[] = { 1u, 2u, 3u, 4u, 5u, 6u, 7u, 8u, 9u, 10u, 11u,
865 11u, 12u, 13u, 14u, 15u, 16u };
867 unsigned int characterIndex06[] = { 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
868 12u, 12u, 12u, 12u, 12u, 12u };
870 unsigned int logicalIndex06[] = { 10u, 9u, 8u, 7u, 6u, 5u, 4u, 3u, 2u, 1u, 0u,
871 16u, 15u, 14u, 13u, 12u, 11u };
873 unsigned int bidirectionalLineIndex06[] = { 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
874 1u, 1u, 1u, 1u, 1u, 1u };
876 struct GetLogicalCursorIndexData data[] =
879 "Zero characters text",
881 Size( 300.f, 300.f ),
886 bidirectionalLineIndex01,
889 "All left to right text 01.",
891 Size( 300.f, 300.f ),
896 bidirectionalLineIndex02,
899 "bidirectional text 01.",
900 "Hello world\nשלום עולם\nhello world שלום עולם\nשלום עולם hello world\n",
901 Size( 300.f, 300.f ),
906 bidirectionalLineIndex03,
909 "bidirectional text 02.",
910 "שלום עולם\nhello world\nשלום עולם hello world\nhello world שלום עולם\n",
911 Size( 300.f, 300.f ),
916 bidirectionalLineIndex04,
921 Size( 100.f, 300.f ),
926 bidirectionalLineIndex05,
929 "bidirectional text 03.",
931 Size( 100.f, 300.f ),
936 bidirectionalLineIndex06,
939 const unsigned int numberOfTests = 6u;
941 for( unsigned int index = 0u; index < numberOfTests; ++index )
943 ToolkitTestApplication application;
944 if( !GetLogicalCursorIndexTest( data[index] ) )
946 tet_result(TET_FAIL);
950 tet_result(TET_PASS);