2 * Copyright (c) 2018 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.
21 #include <dali/devel-api/text-abstraction/bidirectional-support.h>
22 #include <dali-toolkit/internal/text/bidirectional-support.h>
23 #include <dali-toolkit/internal/text/character-set-conversion.h>
24 #include <dali-toolkit/internal/text/text-run-container.h>
25 #include <dali-toolkit-test-suite-utils.h>
26 #include <dali-toolkit/dali-toolkit.h>
27 #include <toolkit-text-utils.h>
30 using namespace Toolkit;
33 // Tests the following functions.
35 // void SetBidirectionalInfo( const Vector<Character>& text,
36 // const Vector<ScriptRun>& scripts,
37 // const Vector<LineBreakInfo>& lineBreakInfo,
38 // CharacterIndex startIndex,
39 // Length numberOfCharacters,
40 // Vector<BidirectionalParagraphInfoRun>& bidirectionalInfo )
41 // void ReorderLines( const Vector<BidirectionalParagraphInfoRun>& bidirectionalInfo,
42 // CharacterIndex startIndex,
43 // Length numberOfCharacters,
44 // Vector<LineRun>& lineRuns,
45 // Vector<BidirectionalLineInfoRun>& lineInfoRuns )
46 // bool GetMirroredText( const Vector<Character>& text,
47 // Vector<CharacterDirection>& directions,
48 // const Vector<BidirectionalParagraphInfoRun>& bidirectionalInfo,
49 // CharacterIndex startIndex,
50 // Length numberOfCharacters,
51 // Vector<Character>& mirroredText )
52 // void GetCharactersDirection( const Vector<BidirectionalParagraphInfoRun>& bidirectionalInfo,
53 // CharacterIndex startIndex,
54 // Length numberOfCharacters,
55 // Vector<CharacterDirection>& directions )
57 //////////////////////////////////////////////////////////
62 struct SetBidirectionalInfoData
64 std::string description; ///< Description of the test.
65 std::string text; ///< Input text.
66 unsigned int startIndex; ///< The index from where the model is updated.
67 unsigned int numberOfCharacters; ///< The number of characters to update.
68 unsigned int numberOfParagraphs; ///< The expected number of bidirectional paragraphs.
69 unsigned int* indices; ///< The expected indices to the first character of each paragraph.
70 unsigned int* numberOfParagraphCharacters; ///< The expected number of characters of each paragraph.
71 bool* directions; ///< The expected direction of each paragraph.
76 unsigned int characterIndex;
77 unsigned int numberOfCharacters;
78 unsigned int* visualToLogical;
81 struct ReorderLinesData
83 std::string description; ///< Description of the test.
84 std::string text; ///< Input text.
85 unsigned int startIndex; ///< The index from where the model is updated.
86 unsigned int numberOfCharacters; ///< The number of characters.
87 unsigned int numberOfLineInfo; ///< The number or reordered lines.
88 BidiLineData* bidiLineData; ///< The bidirectional line info.
89 unsigned int numberOfLines; ///< The number of laid-out lines.
90 bool* lineDirections; ///< The directions of the lines.
93 struct GetMirroredTextData
95 std::string description; ///< Description of the test.
96 std::string text; ///< Input text.
97 unsigned int startIndex; ///< The index from where the model is updated.
98 unsigned int numberOfCharacters; ///< The number of the characters.
99 std::string mirroredText; ///< The expected result.
102 struct GetCharactersDirectionData
104 std::string description; ///< Description of the test.
105 std::string text; ///< Input text.
106 unsigned int startIndex; ///< The index from where the model is updated.
107 unsigned int numberOfCharacters; ///< The number of characters.
108 bool* directions; ///< The expected directions.
109 bool markupProcessorEnabled; ///< Enable markup processor to use markup text.
112 bool SetBidirectionalInfoTest( const SetBidirectionalInfoData& data )
114 // 1) Create the model.
117 Size textArea(100.f, 60.f);
121 const Vector<FontDescriptionRun> fontDescriptions;
122 const LayoutOptions options;
123 CreateTextModel( data.text,
132 LogicalModelPtr logicalModel = textModel->mLogicalModel;
133 VisualModelPtr visualModel = textModel->mVisualModel;
135 // 2) Clear the bidirectional paragraph info data.
136 Vector<BidirectionalParagraphInfoRun>& bidirectionalInfo = logicalModel->mBidirectionalParagraphInfo;
137 if( 0u != data.numberOfCharacters )
139 ClearCharacterRuns( data.startIndex,
140 data.startIndex + data.numberOfCharacters - 1u,
144 // 3) Call the SetBidirectionalInfo() function.
145 SetBidirectionalInfo( logicalModel->mText,
146 logicalModel->mScriptRuns,
147 logicalModel->mLineBreakInfo,
149 data.numberOfCharacters,
152 // 4) Compare with the expected results.
153 TextAbstraction::BidirectionalSupport bidirectionalSupport = TextAbstraction::BidirectionalSupport::Get();
155 if( data.numberOfParagraphs != bidirectionalInfo.Count() )
157 // Different number of expected bidirectional paragraphs.
158 std::cout << " Different number of bidi paragraphs : " << bidirectionalInfo.Count() << ", expected : " << data.numberOfParagraphs << std::endl;
162 for( unsigned int index = 0u; index < data.numberOfParagraphs; ++index )
164 const BidirectionalParagraphInfoRun& run = bidirectionalInfo[index];
166 const CharacterDirection direction = bidirectionalSupport.GetParagraphDirection( run.bidirectionalInfoIndex );
167 if( direction != data.directions[index] )
169 std::cout << " Different direction" << std::endl;
170 std::cout << " paragraph : " << index << std::endl;
171 std::cout << " index : " << run.characterRun.characterIndex << ", num chars : " << run.characterRun.numberOfCharacters << ", direction : " << direction << std::endl;
172 std::cout << " expected, index : " << data.indices[index] << ", num chars : " << data.numberOfParagraphCharacters[index] << ", direction : " << data.directions[index] << std::endl;
176 if( run.characterRun.characterIndex != data.indices[index] )
178 std::cout << " Different index" << std::endl;
179 std::cout << " paragraph : " << index << std::endl;
180 std::cout << " index : " << run.characterRun.characterIndex << ", num chars : " << run.characterRun.numberOfCharacters << ", direction : " << direction << std::endl;
181 std::cout << " expected, index : " << data.indices[index] << ", num chars : " << data.numberOfParagraphCharacters[index] << ", direction : " << data.directions[index] << std::endl;
184 if( run.characterRun.numberOfCharacters != data.numberOfParagraphCharacters[index] )
186 std::cout << " Different number of characters" << std::endl;
187 std::cout << " paragraph : " << index << std::endl;
188 std::cout << " index : " << run.characterRun.characterIndex << ", num chars : " << run.characterRun.numberOfCharacters << ", direction : " << direction << std::endl;
189 std::cout << " expected, index : " << data.indices[index] << ", num chars : " << data.numberOfParagraphCharacters[index] << ", direction : " << data.directions[index] << std::endl;
198 * @brief Frees previously allocated bidirectional resources.
200 * @param[in] bidirectionalLineInfo Bidirectional info per line.
201 * @param[in] startIndex Index to the first line with bidirectional info to be freed.
202 * @param[in] endIndex Index to the last line with bidirectional info to be freed.
204 void FreeBidirectionalLineInfoResources( Vector<BidirectionalLineInfoRun> bidirectionalLineInfo,
208 // Free the allocated memory used to store the conversion table in the bidirectional line info run.
209 for( Vector<BidirectionalLineInfoRun>::Iterator it = bidirectionalLineInfo.Begin() + startIndex,
210 endIt = bidirectionalLineInfo.Begin() + endIndex;
214 BidirectionalLineInfoRun& bidiLineInfo = *it;
216 free( bidiLineInfo.visualToLogicalMap );
220 bool ReorderLinesTest( const ReorderLinesData& data )
222 // 1) Create the model.
225 Size textArea(100.f, 300.f);
229 const Vector<FontDescriptionRun> fontDescriptions;
230 const LayoutOptions options;
231 CreateTextModel( data.text,
240 LogicalModelPtr logicalModel = textModel->mLogicalModel;
241 VisualModelPtr visualModel = textModel->mVisualModel;
243 // 2) Clear the bidirectional line info data.
244 uint32_t startRemoveIndex = logicalModel->mBidirectionalLineInfo.Count();
245 uint32_t endRemoveIndex = startRemoveIndex;
246 ClearCharacterRuns( data.startIndex,
247 data.startIndex + data.numberOfCharacters - 1u,
248 logicalModel->mBidirectionalLineInfo,
252 // Index to the first index to be removed.
254 FreeBidirectionalLineInfoResources( logicalModel->mBidirectionalLineInfo, startRemoveIndex, endRemoveIndex );
255 BidirectionalLineInfoRun* bidiLineBuffer = logicalModel->mBidirectionalLineInfo.Begin();
256 logicalModel->mBidirectionalLineInfo.Erase( bidiLineBuffer + startRemoveIndex,
257 bidiLineBuffer + endRemoveIndex );
259 // 3) Call the function ReorderLines()
261 ReorderLines( logicalModel->mBidirectionalParagraphInfo,
263 data.numberOfCharacters,
265 logicalModel->mBidirectionalLineInfo );
267 // 4) Compare the results.
269 if( data.numberOfLineInfo != logicalModel->mBidirectionalLineInfo.Count() )
271 // Different number of bidirectional lines.
272 std::cout << " different number of bidi lines : " << logicalModel->mBidirectionalLineInfo.Count() << ", expected : " << data.numberOfLineInfo << std::endl;
273 for( unsigned int index = 0u; index < logicalModel->mBidirectionalLineInfo.Count(); ++index )
275 const BidirectionalLineInfoRun& run = logicalModel->mBidirectionalLineInfo[index];
276 const BidiLineData& bidiLineData = data.bidiLineData[index];
278 std::cout << " bidi line : " << index << ", index : " << run.characterRun.characterIndex << ", num chars : " << run.characterRun.numberOfCharacters << std::endl;
279 std::cout << " expected index : " << bidiLineData.characterIndex << ", num chars : " << bidiLineData.numberOfCharacters << std::endl;
284 for( unsigned int index = 0u; index < data.numberOfLineInfo; ++index )
286 const BidirectionalLineInfoRun& run = logicalModel->mBidirectionalLineInfo[index];
287 const BidiLineData& bidiLineData = data.bidiLineData[index];
289 if( bidiLineData.characterIndex != run.characterRun.characterIndex )
291 std::cout << " bidi line : " << index << ", index : " << run.characterRun.characterIndex << ", num chars : " << run.characterRun.numberOfCharacters << std::endl;
292 std::cout << " expected index : " << bidiLineData.characterIndex << ", num chars : " << bidiLineData.numberOfCharacters << std::endl;
295 if( bidiLineData.numberOfCharacters != run.characterRun.numberOfCharacters )
297 std::cout << " bidi line : " << index << ", index : " << run.characterRun.characterIndex << ", num chars : " << run.characterRun.numberOfCharacters << std::endl;
298 std::cout << " expected index : " << bidiLineData.characterIndex << ", num chars : " << bidiLineData.numberOfCharacters << std::endl;
302 for( unsigned int i = 0u; i < run.characterRun.numberOfCharacters; ++i )
304 if( bidiLineData.visualToLogical[i] != run.visualToLogicalMap[i] )
306 std::cout << " v2l : ";
307 for( unsigned int i = 0u; i < run.characterRun.numberOfCharacters; ++i )
309 std::cout << run.visualToLogicalMap[i] << " ";
311 std::cout << std::endl;
312 std::cout << " expected v2l : ";
313 for( unsigned int i = 0u; i < run.characterRun.numberOfCharacters; ++i )
315 std::cout << bidiLineData.visualToLogical[i] << " ";
317 std::cout << std::endl;
324 if( data.numberOfLines != visualModel->mLines.Count() )
326 std::cout << "Different number of lines : " << visualModel->mLines.Count() << ", expected : " << data.numberOfLines << std::endl;
328 unsigned int index = 0u;
329 for( Vector<LineRun>::ConstIterator it = visualModel->mLines.Begin(),
330 endIt = visualModel->mLines.End();
334 const LineRun& line = *it;
336 if( line.direction != *( data.lineDirections + index ) )
338 std::cout << " Different line direction : " << line.direction << ", expected : " << *( data.lineDirections + index ) << std::endl;
347 bool GetMirroredTextTest( const GetMirroredTextData& data )
349 // 1) Create the model.
352 Size textArea(100.f, 60.f);
356 const Vector<FontDescriptionRun> fontDescriptions;
357 const LayoutOptions options;
358 CreateTextModel( data.text,
367 LogicalModelPtr logicalModel = textModel->mLogicalModel;
368 VisualModelPtr visualModel = textModel->mVisualModel;
370 // 2) Call the GetMirroredText() function for the whole text
371 Vector<Character> mirroredText;
372 bool mirrored = false;
373 mirrored = GetMirroredText( logicalModel->mText,
374 logicalModel->mCharacterDirections,
375 logicalModel->mBidirectionalParagraphInfo,
377 logicalModel->mText.Count(),
380 // 3) Call the GetMirroredText() function for the given index + number of characters
381 mirrored = GetMirroredText( logicalModel->mText,
382 logicalModel->mCharacterDirections,
383 logicalModel->mBidirectionalParagraphInfo,
385 data.numberOfCharacters,
388 // 4) Compare the results.
391 std::string mirroredString;
392 Utf32ToUtf8( mirroredText.Begin(),
393 mirroredText.Count(),
396 if( !mirrored && ( mirroredString != data.text ) )
398 std::cout << " No mirrored text and mirroredString != data.text." << std::endl;
399 std::cout << " mirrored string : [" << mirroredString << "]" << std::endl;
400 std::cout << " text : [" << data.text << "]" << std::endl;
404 if( mirrored && ( mirroredString == data.text ) )
406 std::cout << " Mirrored text and mirroredString == data.text." << std::endl;
407 std::cout << " mirrored string : [" << mirroredString << "]" << std::endl;
408 std::cout << " text : [" << data.text << "]" << std::endl;
412 if( mirrored && ( mirroredString != data.mirroredText ) )
414 std::cout << " Mirrored text and mirroredString != data.mirroredText." << std::endl;
415 std::cout << " mirrored string : [" << mirroredString << "]" << std::endl;
416 std::cout << " text : [" << data.mirroredText << "]" << std::endl;
423 bool GetCharactersDirectionTest( const GetCharactersDirectionData& data )
425 // 1) Create the model.
428 Size textArea(100.f, 60.f);
432 const Vector<FontDescriptionRun> fontDescriptions;
433 const LayoutOptions options;
434 CreateTextModel( data.text,
441 data.markupProcessorEnabled );
443 LogicalModelPtr logicalModel = textModel->mLogicalModel;
444 VisualModelPtr visualModel = textModel->mVisualModel;
446 Vector<BidirectionalParagraphInfoRun>& bidirectionalInfo = logicalModel->mBidirectionalParagraphInfo;
448 // 2) Clear the direction info data.
449 Vector<CharacterDirection>& directions = logicalModel->mCharacterDirections;
451 if( directions.Count() >= data.startIndex + data.numberOfCharacters )
453 directions.Erase( directions.Begin() + data.startIndex,
454 directions.Begin() + data.startIndex + data.numberOfCharacters );
457 // 3) Call GetCharactersDirection() function.
459 GetCharactersDirection( bidirectionalInfo,
460 logicalModel->mText.Count(),
462 data.numberOfCharacters,
465 for( unsigned int index = 0u; index < logicalModel->mText.Count(); ++index )
467 if( data.directions[index] != directions[index] )
478 //////////////////////////////////////////////////////////
480 int UtcDaliSetBidirectionalInfo(void)
482 tet_infoline(" UtcDaliSetBidirectionalInfo");
484 unsigned int indices01[] = {};
485 unsigned int numberOfCharacters01[] = {};
486 bool direction01[] = {};
487 unsigned int indices02[] = {};
488 unsigned int numberOfCharacters02[] = {};
489 bool direction02[] = {};
490 unsigned int indices03[] = { 17u, 48u };
491 unsigned int numberOfCharacters03[] = { 14u, 14u };
492 bool direction03[] = { true, true };
493 unsigned int indices04[] = { 17u, 31u, 79u };
494 unsigned int numberOfCharacters04[] = { 14u, 48u, 31u };
495 bool direction04[] = { true, false, true };
496 unsigned int indices05[] = { 17u, 41u, 117u };
497 unsigned int numberOfCharacters05[] = { 24u, 76u, 49u };
498 bool direction05[] = { true, false, true };
499 unsigned int indices06[] = { 17u, 48u };
500 unsigned int numberOfCharacters06[] = { 14u, 14u };
501 bool direction06[] = { true, true };
502 unsigned int indices07[] = { 17u, 31u, 79u };
503 unsigned int numberOfCharacters07[] = { 14u, 48u, 31u };
504 bool direction07[] = { true, false, true };
505 unsigned int indices08[] = { 17u, 41u, 117u };
506 unsigned int numberOfCharacters08[] = { 24u, 76u, 49u };
507 bool direction08[] = { true, false, true };
509 struct SetBidirectionalInfoData data[] =
518 numberOfCharacters01,
522 "Some left to right paragraphs",
523 "Hello world\ndemo\n\n",
528 numberOfCharacters02,
532 "A mix of left to right and right to left paragraphs.",
533 "Hello world demo\nمرحبا بالعالم\nhello world demo\nمرحبا بالعالم\nhello world demo",
538 numberOfCharacters03,
542 "A mix of left to right and right to left paragraphs. Paragraphs also contain a mix of bidirectional text.",
543 "Hello world demo\nمرحبا بالعالم\nhello world demo مرحبا بالعالم hello world demo\nمرحبا hello world demo بالعالم\nhello world demo",
548 numberOfCharacters04,
552 "A mix of left to right and right to left paragraphs. Paragraphs also contain a mix of bidirectional text and a mix of right to left scripts.",
553 "Hello world demo\nمرحبا שלום עולם بالعالم\nhello world שלום بالعالم עולם demo مرحبا שלום עולם بالعالم hello world demo\nمرحبا hello שלום بالعالم עולם world demo بالعالم\nhello world demo",
558 numberOfCharacters05,
562 "A mix of left to right and right to left paragraphs. Updates a left to right paragraph.",
563 "Hello world demo\nمرحبا بالعالم\nhello world demo\nمرحبا بالعالم\nhello world demo",
568 numberOfCharacters06,
572 "A mix of left to right and right to left paragraphs. Paragraphs also contain a mix of bidirectional text.",
573 "Hello world demo\nمرحبا بالعالم\nhello world demo مرحبا بالعالم hello world demo\nمرحبا hello world demo بالعالم\nhello world demo",
578 numberOfCharacters07,
582 "A mix of left to right and right to left paragraphs. Paragraphs also contain a mix of bidirectional text and a mix of right to left scripts. Updates initial paragraphs.",
583 "Hello world demo\nمرحبا שלום עולם بالعالم\nhello world שלום بالعالم עולם demo مرحبا שלום עולם بالعالم hello world demo\nمرحبا hello שלום بالعالم עולם world demo بالعالم\nhello world demo",
588 numberOfCharacters08,
592 "A mix of left to right and right to left paragraphs. Paragraphs also contain a mix of bidirectional text and a mix of right to left scripts. Updates mid paragraphs.",
593 "Hello world demo\nمرحبا שלום עולם بالعالم\nhello world שלום بالعالم עולם demo مرحبا שלום עולם بالعالم hello world demo\nمرحبا hello שלום بالعالم עולם world demo بالعالم\nhello world demo",
598 numberOfCharacters08,
602 "A mix of left to right and right to left paragraphs. Paragraphs also contain a mix of bidirectional text and a mix of right to left scripts. Updates from character 85",
603 "Hello world demo\nمرحبا שלום עולם بالعالم\nhello world שלום بالعالم עולם demo مرحبا שלום עולם بالعالم hello world demo\nمرحبا hello שלום بالعالم עולם world demo بالعالم\nhello world demo",
608 numberOfCharacters08,
612 const unsigned int numberOfTests = 10u;
614 for( unsigned int index = 0u; index < numberOfTests; ++index )
616 ToolkitTestApplication application;
617 if( !SetBidirectionalInfoTest( data[index] ) )
619 tet_result(TET_FAIL);
623 tet_result(TET_PASS);
627 int UtcDaliReorderLines(void)
629 tet_infoline(" UtcDaliSetBidirectionalInfo");
631 unsigned int visualToLogical0301[] = { 0u, 1u, 2u, 3u, 4u, 5u, 9u, 8u, 7u, 6u, 10u };
632 unsigned int visualToLogical0302[] = { 3u, 2u, 1u, 0u, 4u, 5u, 6u, 7u, 8u, 9u, 10u };
633 unsigned int visualToLogical0303[] = { 0u, 1u, 2u, 3u, 4u };
634 unsigned int visualToLogical0304[] = { 12u, 11u, 10u, 9u, 8u, 7u, 6u, 5u, 4u, 3u, 2u, 1u, 0u };
635 unsigned int visualToLogical0305[] = { 10u, 9u, 8u, 7u, 6u, 5u, 4u, 3u, 2u, 1u, 0u };
636 unsigned int visualToLogical0306[] = { 9u, 8u, 7u, 6u, 5u, 4u, 3u, 2u, 1u, 0u };
637 unsigned int visualToLogical0307[] = { 13u, 8u, 9u, 10u, 11u, 12u, 7u, 6u, 5u, 4u, 3u, 2u, 1u, 0u };
638 unsigned int visualToLogical0308[] = { 5u, 0u, 1u, 2u, 3u, 4u };
639 unsigned int visualToLogical0309[] = { 0u, 1u, 2u, 3u, 4u, 5u, 9u, 8u, 7u, 6u, 10u };
640 unsigned int visualToLogical0310[] = { 3u, 2u, 1u, 0u, 4u, 5u, 6u, 7u, 8u, 9u, 10u };
641 unsigned int visualToLogical0311[] = { 0u, 1u, 2u, 3u, 4u };
642 unsigned int visualToLogical0312[] = { 12u, 11u, 10u, 9u, 8u, 7u, 6u, 5u, 4u, 3u, 2u, 1u, 0u };
643 unsigned int visualToLogical0313[] = { 10u, 9u, 8u, 7u, 6u, 5u, 4u, 3u, 2u, 1u, 0u };
644 unsigned int visualToLogical0314[] = { 9u, 8u, 7u, 6u, 5u, 4u, 3u, 2u, 1u, 0u };
645 unsigned int visualToLogical0315[] = { 13u, 8u, 9u, 10u, 11u, 12u, 7u, 6u, 5u, 4u, 3u, 2u, 1u, 0u };
646 unsigned int visualToLogical0316[] = { 0u, 1u, 2u, 3u, 4u };
648 BidiLineData bidiLine01[] = {};
649 BidiLineData bidiLine02[] = {};
650 BidiLineData bidiLine03[] = {
733 bool directions02[] = { false, false, false, false, false, false };
734 bool directions03[] = { false, false, false, false, false, true, true, true, true, true, false, false, false, false, false, true, true, true, true, true };
736 struct ReorderLinesData data[] =
749 "Left to right text only.",
750 "Hello world demo\nhello world demo\nhello world demo.",
759 "Bidirectional paragraphs.",
760 "Hello world demo\nhello שלום עולם world demo\nשלום بالعالم עולם مرحبا שלום עולם بالعالم hello world\nHello world demo\nhello שלום עולם world demo\nשלום بالعالم עולם مرحبا שלום עולם بالعالم hello world",
769 "Bidirectional paragraphs. Update initial paragraphs.",
770 "Hello world demo\nhello שלום עולם world demo\nשלום بالعالم עולם مرحبا שלום עולם بالعالم hello world\nHello world demo\nhello שלום עולם world demo\nשלום بالعالم עולם مرحبا שלום עולם بالعالم hello world",
779 "Bidirectional paragraphs. Update middle paragraphs.",
780 "Hello world demo\nhello שלום עולם world demo\nשלום بالعالم עולם مرحبا שלום עולם بالعالم hello world\nHello world demo\nhello שלום עולם world demo\nשלום بالعالم עולם مرحبا שלום עולם بالعالم hello world",
789 "Bidirectional paragraphs. Update final paragraphs.",
790 "Hello world demo\nhello שלום עולם world demo\nשלום بالعالم עולם مرحبا שלום עולם بالعالم hello world\nHello world demo\nhello שלום עולם world demo\nשלום بالعالم עולם مرحبا שלום עולם بالعالم hello world",
799 const unsigned int numberOfTests = 6u;
801 for( unsigned int index = 0u; index < numberOfTests; ++index )
803 ToolkitTestApplication application;
804 if( !ReorderLinesTest( data[index] ) )
806 tet_result(TET_FAIL);
810 tet_result(TET_PASS);
814 int UtcDaliGetMirroredText(void)
816 tet_infoline(" UtcDaliGetMirroredText");
818 struct GetMirroredTextData data[] =
828 "Left to right characters only.",
829 "Hello world\nhello world demo.",
832 "Hello world\nhello world demo."
835 "Right to left characters but with no characters to mirror.",
836 "שלום עולם\nمرحبا بالعالم",
839 "שלום עולם\nمرحبا بالعالم"
842 "Right to left characters with some characters to mirror.",
843 "שלום עולם\n(مرحبا بالعالم)",
846 "שלום עולם\n)مرحبا بالعالم("
849 "Right to left characters with some characters to mirror. Update last paragraph.",
850 "שלום עולם\n(مرحبا بالعالم)",
853 "שלום עולם\n)مرحبا بالعالم("
856 "Mix of bidirectional text. With more paragraphs.",
857 "Hello world demo\nhello world\nhello world (مرحبا بالعالم שלום) עולם\nשלום مرحبا بالعالم עולם (hello) مرحبا بالعالم world"
858 " مرحبا بالعالم שלום עולם hello world hello world\nبالعالم שלום (hello) world demo (עולם)\nשלום (مرحبا بالعالم עולם) (hello)",
861 "Hello world demo\nhello world\nhello world (مرحبا بالعالم שלום( עולם\nשלום مرحبا بالعالم עולם )hello( مرحبا بالعالم world"
862 " مرحبا بالعالم שלום עולם hello world hello world\nبالعالم שלום )hello) world demo )עולם(\nשלום )مرحبا بالعالم עולם( )hello("
865 "Mix of bidirectional text. With more paragraphs. Update middle paragraphs.",
866 "Hello world demo\nhello world\nhello world (مرحبا بالعالم שלום) עולם\nשלום مرحبا بالعالم עולם (hello) مرحبا بالعالم world"
867 " مرحبا بالعالم שלום עולם hello world hello world\nبالعالم שלום (hello) world demo (עולם)\nשלום (مرحبا بالعالم עולם) (hello)",
870 "Hello world demo\nhello world\nhello world (مرحبا بالعالم שלום( עולם\nשלום مرحبا بالعالم עולם (hello) مرحبا بالعالم world"
871 " مرحبا بالعالم שלום עולם hello world hello world\nبالعالم שלום (hello) world demo (עולם)\nשלום (مرحبا بالعالم עולם) (hello)"
874 "Mix of bidirectional text. With more paragraphs. Update middle paragraphs (2).",
875 "Hello world demo\nhello world\nhello world (مرحبا بالعالم שלום) עולם\nשלום مرحبا بالعالم עולם (hello) مرحبا بالعالم world"
876 " مرحبا بالعالم שלום עולם hello world hello world\nبالعالم שלום (hello) world demo (עולם)\nשלום (مرحبا بالعالم עולם) (hello)",
879 "Hello world demo\nhello world\nhello world (مرحبا بالعالم שלום) עולם\nשלום مرحبا بالعالم עולם )hello( مرحبا بالعالم world"
880 " مرحبا بالعالم שלום עולם hello world hello world\nبالعالم שלום (hello) world demo (עולם)\nשלום (مرحبا بالعالم עולם) (hello)"
883 const unsigned int numberOfTests = 8u;
885 for( unsigned int index = 0u; index < numberOfTests; ++index )
887 ToolkitTestApplication application;
888 if( !GetMirroredTextTest( data[index] ) )
890 tet_result(TET_FAIL);
894 tet_result(TET_PASS);
898 int UtcDaliGetCharactersDirection(void)
900 tet_infoline(" UtcDaliGetCharactersDirection");
902 bool directions01[] = {};
903 bool directions02[] = {
904 false, false, false, false, false, false, false, false, false, false,
905 false, false, false, false, false, false, false, false, false, false,
906 false, false, false, false, false, false, false, false };
907 bool directions03[] = {
908 true, true, true, true, true, true, true, true, true, true,
909 true, true, true, true, true, true, true, true, true };
910 bool directions04[] = {
911 false, false, false, false, false, false, false, false, false, false,
912 false, false, false, false, false, false, false, false, false, false,
913 false, false, false, false, true, true, true, true, true, true,
914 true, true, true, false, true, true, true, true, true, true,
915 true, true, true, true, false, false, false, false, false, false,
916 false, false, false, false, false };
917 bool directions05[] = {
918 false, false, false, false, false, false, false, false, false, false,
919 false, false, false, false, false, false, false, false, false, false,
920 false, false, false, false, false, false, false, false, false, false,
921 false, false, false, false, false, false, false, false, false, false,
922 false, true, true, true, true, true, true, true, true, true,
923 true, true, true, true, true, true, true, true, true, true,
924 true, true, true, true, false, true, true, true, true, true,
925 true, true, true, true, true, true, true, true, true, true,
926 true, true, true, true, true, true, true, true, true, false,
927 false, false, false, false, true, true, true, true, true, true,
928 true, true, true, true, true, true, true, true, true, false,
929 false, false, false, false, true, true, true, true, true, true,
930 true, true, true, true, true, true, true, true, true, true,
931 true, true, true, true, true, true, true, true, true, false,
932 false, false, false, false, false, false, false, false, false, false,
933 false, false, false, false, false, false, false, false, false, false,
934 false, false, true, true, true, true, true, true, true, true,
935 true, true, true, true, true, true, false, false, false, false,
936 false, false, false, false, false, false, false, false, false, false,
937 false, false, true, true, true, true, true, true, true, true,
938 true, true, true, true, true, true, true, true, true, true,
939 true, true, true, true, true, true, true, true, true, true,
940 true, true, false, false, false, false, false };
942 bool directions06[] = {
943 true, true, true, true, true, true, true, true, true, true,
944 false, false, false, false, false, false, false, false, false, false,
945 false, false, false, false, false, false };
947 struct GetCharactersDirectionData data[] =
958 "Left to right characters only",
959 "Hello world\nhello world demo",
966 "Right to left characters only",
967 "שלום עולם\nשלום עולם",
974 "Mix of bidirectional text",
975 "Hello world\nhello world שלום עולם\nשלום עולם hello world",
982 "Mix of bidirectional text. With more paragraphs.",
983 "Hello world demo\nhello world\nhello world مرحبا بالعالم שלום עולם\nשלום مرحبا بالعالم עולם hello مرحبا بالعالم world"
984 " مرحبا بالعالم שלום עולם hello world hello world\nبالعالم שלום hello world demo עולם\nשלום مرحبا بالعالم עולם hello",
991 "Mix of bidirectional text. With more paragraphs. Update first paragraph.",
992 "Hello world demo\nhello world\nhello world مرحبا بالعالم שלום עולם\nשלום مرحبا بالعالم עולם hello مرحبا بالعالم world"
993 " مرحبا بالعالم שלום עולם hello world hello world\nبالعالم שלום hello world demo עולם\nשלום مرحبا بالعالم עולם hello",
1000 "Mix of bidirectional text. With more paragraphs. Update from character 29",
1001 "Hello world demo\nhello world\nhello world مرحبا بالعالم שלום עולם\nשלום مرحبا بالعالم עולם hello مرحبا بالعالم world"
1002 " مرحبا بالعالم שלום עולם hello world hello world\nبالعالم שלום hello world demo עולם\nשלום مرحبا بالعالم עולם hello",
1009 "Mix of bidirectional text. With more paragraphs. Update from character 163",
1010 "Hello world demo\nhello world\nhello world مرحبا بالعالم שלום עולם\nשלום مرحبا بالعالم עולם hello مرحبا بالعالم world"
1011 " مرحبا بالعالم שלום עולם hello world hello world\nبالعالم שלום hello world demo עולם\nשלום مرحبا بالعالم עולם hello",
1018 "Mix of bidirectional text. With brackets and LRM",
1019 "שלום עולם ‎(hello)[world]‎",
1026 const unsigned int numberOfTests = 9u;
1028 for( unsigned int index = 0u; index < numberOfTests; ++index )
1030 ToolkitTestApplication application;
1031 if( !GetCharactersDirectionTest( data[index] ) )
1033 tet_result(TET_FAIL);
1037 tet_result(TET_PASS);