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.
115 LogicalModelPtr logicalModel;
116 VisualModelPtr visualModel;
118 Size textArea(100.f, 60.f);
122 const Vector<FontDescriptionRun> fontDescriptions;
123 const LayoutOptions options;
124 CreateTextModel( data.text,
134 // 2) Clear the bidirectional paragraph info data.
135 Vector<BidirectionalParagraphInfoRun>& bidirectionalInfo = logicalModel->mBidirectionalParagraphInfo;
136 if( 0u != data.numberOfCharacters )
138 ClearCharacterRuns( data.startIndex,
139 data.startIndex + data.numberOfCharacters - 1u,
143 // 3) Call the SetBidirectionalInfo() function.
144 SetBidirectionalInfo( logicalModel->mText,
145 logicalModel->mScriptRuns,
146 logicalModel->mLineBreakInfo,
148 data.numberOfCharacters,
151 // 4) Compare with the expected results.
152 TextAbstraction::BidirectionalSupport bidirectionalSupport = TextAbstraction::BidirectionalSupport::Get();
154 if( data.numberOfParagraphs != bidirectionalInfo.Count() )
156 // Different number of expected bidirectional paragraphs.
157 std::cout << " Different number of bidi paragraphs : " << bidirectionalInfo.Count() << ", expected : " << data.numberOfParagraphs << std::endl;
161 for( unsigned int index = 0u; index < data.numberOfParagraphs; ++index )
163 const BidirectionalParagraphInfoRun& run = bidirectionalInfo[index];
165 const CharacterDirection direction = bidirectionalSupport.GetParagraphDirection( run.bidirectionalInfoIndex );
166 if( direction != data.directions[index] )
168 std::cout << " Different direction" << std::endl;
169 std::cout << " paragraph : " << index << std::endl;
170 std::cout << " index : " << run.characterRun.characterIndex << ", num chars : " << run.characterRun.numberOfCharacters << ", direction : " << direction << std::endl;
171 std::cout << " expected, index : " << data.indices[index] << ", num chars : " << data.numberOfParagraphCharacters[index] << ", direction : " << data.directions[index] << std::endl;
175 if( run.characterRun.characterIndex != data.indices[index] )
177 std::cout << " Different index" << std::endl;
178 std::cout << " paragraph : " << index << std::endl;
179 std::cout << " index : " << run.characterRun.characterIndex << ", num chars : " << run.characterRun.numberOfCharacters << ", direction : " << direction << std::endl;
180 std::cout << " expected, index : " << data.indices[index] << ", num chars : " << data.numberOfParagraphCharacters[index] << ", direction : " << data.directions[index] << std::endl;
183 if( run.characterRun.numberOfCharacters != data.numberOfParagraphCharacters[index] )
185 std::cout << " Different number of characters" << std::endl;
186 std::cout << " paragraph : " << index << std::endl;
187 std::cout << " index : " << run.characterRun.characterIndex << ", num chars : " << run.characterRun.numberOfCharacters << ", direction : " << direction << std::endl;
188 std::cout << " expected, index : " << data.indices[index] << ", num chars : " << data.numberOfParagraphCharacters[index] << ", direction : " << data.directions[index] << std::endl;
197 * @brief Frees previously allocated bidirectional resources.
199 * @param[in] bidirectionalLineInfo Bidirectional info per line.
200 * @param[in] startIndex Index to the first line with bidirectional info to be freed.
201 * @param[in] endIndex Index to the last line with bidirectional info to be freed.
203 void FreeBidirectionalLineInfoResources( Vector<BidirectionalLineInfoRun> bidirectionalLineInfo,
207 // Free the allocated memory used to store the conversion table in the bidirectional line info run.
208 for( Vector<BidirectionalLineInfoRun>::Iterator it = bidirectionalLineInfo.Begin() + startIndex,
209 endIt = bidirectionalLineInfo.Begin() + endIndex;
213 BidirectionalLineInfoRun& bidiLineInfo = *it;
215 free( bidiLineInfo.visualToLogicalMap );
219 bool ReorderLinesTest( const ReorderLinesData& data )
221 // 1) Create the model.
222 LogicalModelPtr logicalModel;
223 VisualModelPtr visualModel;
225 Size textArea(100.f, 300.f);
229 const Vector<FontDescriptionRun> fontDescriptions;
230 const LayoutOptions options;
231 CreateTextModel( data.text,
241 // 2) Clear the bidirectional line info data.
242 uint32_t startRemoveIndex = logicalModel->mBidirectionalLineInfo.Count();
243 uint32_t endRemoveIndex = startRemoveIndex;
244 ClearCharacterRuns( data.startIndex,
245 data.startIndex + data.numberOfCharacters - 1u,
246 logicalModel->mBidirectionalLineInfo,
250 // Index to the first index to be removed.
252 FreeBidirectionalLineInfoResources( logicalModel->mBidirectionalLineInfo, startRemoveIndex, endRemoveIndex );
253 BidirectionalLineInfoRun* bidiLineBuffer = logicalModel->mBidirectionalLineInfo.Begin();
254 logicalModel->mBidirectionalLineInfo.Erase( bidiLineBuffer + startRemoveIndex,
255 bidiLineBuffer + endRemoveIndex );
257 // 3) Call the function ReorderLines()
259 ReorderLines( logicalModel->mBidirectionalParagraphInfo,
261 data.numberOfCharacters,
263 logicalModel->mBidirectionalLineInfo );
265 // 4) Compare the results.
267 if( data.numberOfLineInfo != logicalModel->mBidirectionalLineInfo.Count() )
269 // Different number of bidirectional lines.
270 std::cout << " different number of bidi lines : " << logicalModel->mBidirectionalLineInfo.Count() << ", expected : " << data.numberOfLineInfo << std::endl;
271 for( unsigned int index = 0u; index < logicalModel->mBidirectionalLineInfo.Count(); ++index )
273 const BidirectionalLineInfoRun& run = logicalModel->mBidirectionalLineInfo[index];
274 const BidiLineData& bidiLineData = data.bidiLineData[index];
276 std::cout << " bidi line : " << index << ", index : " << run.characterRun.characterIndex << ", num chars : " << run.characterRun.numberOfCharacters << std::endl;
277 std::cout << " expected index : " << bidiLineData.characterIndex << ", num chars : " << bidiLineData.numberOfCharacters << std::endl;
282 for( unsigned int index = 0u; index < data.numberOfLineInfo; ++index )
284 const BidirectionalLineInfoRun& run = logicalModel->mBidirectionalLineInfo[index];
285 const BidiLineData& bidiLineData = data.bidiLineData[index];
287 if( bidiLineData.characterIndex != run.characterRun.characterIndex )
289 std::cout << " bidi line : " << index << ", index : " << run.characterRun.characterIndex << ", num chars : " << run.characterRun.numberOfCharacters << std::endl;
290 std::cout << " expected index : " << bidiLineData.characterIndex << ", num chars : " << bidiLineData.numberOfCharacters << std::endl;
293 if( bidiLineData.numberOfCharacters != run.characterRun.numberOfCharacters )
295 std::cout << " bidi line : " << index << ", index : " << run.characterRun.characterIndex << ", num chars : " << run.characterRun.numberOfCharacters << std::endl;
296 std::cout << " expected index : " << bidiLineData.characterIndex << ", num chars : " << bidiLineData.numberOfCharacters << std::endl;
300 for( unsigned int i = 0u; i < run.characterRun.numberOfCharacters; ++i )
302 if( bidiLineData.visualToLogical[i] != run.visualToLogicalMap[i] )
304 std::cout << " v2l : ";
305 for( unsigned int i = 0u; i < run.characterRun.numberOfCharacters; ++i )
307 std::cout << run.visualToLogicalMap[i] << " ";
309 std::cout << std::endl;
310 std::cout << " expected v2l : ";
311 for( unsigned int i = 0u; i < run.characterRun.numberOfCharacters; ++i )
313 std::cout << bidiLineData.visualToLogical[i] << " ";
315 std::cout << std::endl;
322 if( data.numberOfLines != visualModel->mLines.Count() )
324 std::cout << "Different number of lines : " << visualModel->mLines.Count() << ", expected : " << data.numberOfLines << std::endl;
326 unsigned int index = 0u;
327 for( Vector<LineRun>::ConstIterator it = visualModel->mLines.Begin(),
328 endIt = visualModel->mLines.End();
332 const LineRun& line = *it;
334 if( line.direction != *( data.lineDirections + index ) )
336 std::cout << " Different line direction : " << line.direction << ", expected : " << *( data.lineDirections + index ) << std::endl;
345 bool GetMirroredTextTest( const GetMirroredTextData& data )
347 // 1) Create the model.
348 LogicalModelPtr logicalModel;
349 VisualModelPtr visualModel;
351 Size textArea(100.f, 60.f);
355 const Vector<FontDescriptionRun> fontDescriptions;
356 const LayoutOptions options;
357 CreateTextModel( data.text,
367 // 2) Call the GetMirroredText() function for the whole text
368 Vector<Character> mirroredText;
369 bool mirrored = false;
370 mirrored = GetMirroredText( logicalModel->mText,
371 logicalModel->mCharacterDirections,
372 logicalModel->mBidirectionalParagraphInfo,
374 logicalModel->mText.Count(),
377 // 3) Call the GetMirroredText() function for the given index + number of characters
378 mirrored = GetMirroredText( logicalModel->mText,
379 logicalModel->mCharacterDirections,
380 logicalModel->mBidirectionalParagraphInfo,
382 data.numberOfCharacters,
385 // 4) Compare the results.
388 std::string mirroredString;
389 Utf32ToUtf8( mirroredText.Begin(),
390 mirroredText.Count(),
393 if( !mirrored && ( mirroredString != data.text ) )
395 std::cout << " No mirrored text and mirroredString != data.text." << std::endl;
396 std::cout << " mirrored string : [" << mirroredString << "]" << std::endl;
397 std::cout << " text : [" << data.text << "]" << std::endl;
401 if( mirrored && ( mirroredString == data.text ) )
403 std::cout << " Mirrored text and mirroredString == data.text." << std::endl;
404 std::cout << " mirrored string : [" << mirroredString << "]" << std::endl;
405 std::cout << " text : [" << data.text << "]" << std::endl;
409 if( mirrored && ( mirroredString != data.mirroredText ) )
411 std::cout << " Mirrored text and mirroredString != data.mirroredText." << std::endl;
412 std::cout << " mirrored string : [" << mirroredString << "]" << std::endl;
413 std::cout << " text : [" << data.mirroredText << "]" << std::endl;
420 bool GetCharactersDirectionTest( const GetCharactersDirectionData& data )
422 // 1) Create the model.
423 LogicalModelPtr logicalModel;
424 VisualModelPtr visualModel;
426 Size textArea(100.f, 60.f);
430 const Vector<FontDescriptionRun> fontDescriptions;
431 const LayoutOptions options;
432 CreateTextModel( data.text,
440 data.markupProcessorEnabled );
442 Vector<BidirectionalParagraphInfoRun>& bidirectionalInfo = logicalModel->mBidirectionalParagraphInfo;
444 // 2) Clear the direction info data.
445 Vector<CharacterDirection>& directions = logicalModel->mCharacterDirections;
447 if( directions.Count() >= data.startIndex + data.numberOfCharacters )
449 directions.Erase( directions.Begin() + data.startIndex,
450 directions.Begin() + data.startIndex + data.numberOfCharacters );
453 // 3) Call GetCharactersDirection() function.
455 GetCharactersDirection( bidirectionalInfo,
456 logicalModel->mText.Count(),
458 data.numberOfCharacters,
461 for( unsigned int index = 0u; index < logicalModel->mText.Count(); ++index )
463 if( data.directions[index] != directions[index] )
474 //////////////////////////////////////////////////////////
476 int UtcDaliSetBidirectionalInfo(void)
478 tet_infoline(" UtcDaliSetBidirectionalInfo");
480 unsigned int indices01[] = {};
481 unsigned int numberOfCharacters01[] = {};
482 bool direction01[] = {};
483 unsigned int indices02[] = {};
484 unsigned int numberOfCharacters02[] = {};
485 bool direction02[] = {};
486 unsigned int indices03[] = { 17u, 48u };
487 unsigned int numberOfCharacters03[] = { 14u, 14u };
488 bool direction03[] = { true, true };
489 unsigned int indices04[] = { 17u, 31u, 79u };
490 unsigned int numberOfCharacters04[] = { 14u, 48u, 31u };
491 bool direction04[] = { true, false, true };
492 unsigned int indices05[] = { 17u, 41u, 117u };
493 unsigned int numberOfCharacters05[] = { 24u, 76u, 49u };
494 bool direction05[] = { true, false, true };
495 unsigned int indices06[] = { 17u, 48u };
496 unsigned int numberOfCharacters06[] = { 14u, 14u };
497 bool direction06[] = { true, true };
498 unsigned int indices07[] = { 17u, 31u, 79u };
499 unsigned int numberOfCharacters07[] = { 14u, 48u, 31u };
500 bool direction07[] = { true, false, true };
501 unsigned int indices08[] = { 17u, 41u, 117u };
502 unsigned int numberOfCharacters08[] = { 24u, 76u, 49u };
503 bool direction08[] = { true, false, true };
505 struct SetBidirectionalInfoData data[] =
514 numberOfCharacters01,
518 "Some left to right paragraphs",
519 "Hello world\ndemo\n\n",
524 numberOfCharacters02,
528 "A mix of left to right and right to left paragraphs.",
529 "Hello world demo\nمرحبا بالعالم\nhello world demo\nمرحبا بالعالم\nhello world demo",
534 numberOfCharacters03,
538 "A mix of left to right and right to left paragraphs. Paragraphs also contain a mix of bidirectional text.",
539 "Hello world demo\nمرحبا بالعالم\nhello world demo مرحبا بالعالم hello world demo\nمرحبا hello world demo بالعالم\nhello world demo",
544 numberOfCharacters04,
548 "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.",
549 "Hello world demo\nمرحبا שלום עולם بالعالم\nhello world שלום بالعالم עולם demo مرحبا שלום עולם بالعالم hello world demo\nمرحبا hello שלום بالعالم עולם world demo بالعالم\nhello world demo",
554 numberOfCharacters05,
558 "A mix of left to right and right to left paragraphs. Updates a left to right paragraph.",
559 "Hello world demo\nمرحبا بالعالم\nhello world demo\nمرحبا بالعالم\nhello world demo",
564 numberOfCharacters06,
568 "A mix of left to right and right to left paragraphs. Paragraphs also contain a mix of bidirectional text.",
569 "Hello world demo\nمرحبا بالعالم\nhello world demo مرحبا بالعالم hello world demo\nمرحبا hello world demo بالعالم\nhello world demo",
574 numberOfCharacters07,
578 "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.",
579 "Hello world demo\nمرحبا שלום עולם بالعالم\nhello world שלום بالعالم עולם demo مرحبا שלום עולם بالعالم hello world demo\nمرحبا hello שלום بالعالم עולם world demo بالعالم\nhello world demo",
584 numberOfCharacters08,
588 "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.",
589 "Hello world demo\nمرحبا שלום עולם بالعالم\nhello world שלום بالعالم עולם demo مرحبا שלום עולם بالعالم hello world demo\nمرحبا hello שלום بالعالم עולם world demo بالعالم\nhello world demo",
594 numberOfCharacters08,
598 "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",
599 "Hello world demo\nمرحبا שלום עולם بالعالم\nhello world שלום بالعالم עולם demo مرحبا שלום עולם بالعالم hello world demo\nمرحبا hello שלום بالعالم עולם world demo بالعالم\nhello world demo",
604 numberOfCharacters08,
608 const unsigned int numberOfTests = 10u;
610 for( unsigned int index = 0u; index < numberOfTests; ++index )
612 ToolkitTestApplication application;
613 if( !SetBidirectionalInfoTest( data[index] ) )
615 tet_result(TET_FAIL);
619 tet_result(TET_PASS);
623 int UtcDaliReorderLines(void)
625 tet_infoline(" UtcDaliSetBidirectionalInfo");
627 unsigned int visualToLogical0301[] = { 0u, 1u, 2u, 3u, 4u, 5u, 9u, 8u, 7u, 6u, 10u };
628 unsigned int visualToLogical0302[] = { 3u, 2u, 1u, 0u, 4u, 5u, 6u, 7u, 8u, 9u, 10u };
629 unsigned int visualToLogical0303[] = { 0u, 1u, 2u, 3u, 4u };
630 unsigned int visualToLogical0304[] = { 12u, 11u, 10u, 9u, 8u, 7u, 6u, 5u, 4u, 3u, 2u, 1u, 0u };
631 unsigned int visualToLogical0305[] = { 10u, 9u, 8u, 7u, 6u, 5u, 4u, 3u, 2u, 1u, 0u };
632 unsigned int visualToLogical0306[] = { 9u, 8u, 7u, 6u, 5u, 4u, 3u, 2u, 1u, 0u };
633 unsigned int visualToLogical0307[] = { 13u, 8u, 9u, 10u, 11u, 12u, 7u, 6u, 5u, 4u, 3u, 2u, 1u, 0u };
634 unsigned int visualToLogical0308[] = { 5u, 0u, 1u, 2u, 3u, 4u };
635 unsigned int visualToLogical0309[] = { 0u, 1u, 2u, 3u, 4u, 5u, 9u, 8u, 7u, 6u, 10u };
636 unsigned int visualToLogical0310[] = { 3u, 2u, 1u, 0u, 4u, 5u, 6u, 7u, 8u, 9u, 10u };
637 unsigned int visualToLogical0311[] = { 0u, 1u, 2u, 3u, 4u };
638 unsigned int visualToLogical0312[] = { 12u, 11u, 10u, 9u, 8u, 7u, 6u, 5u, 4u, 3u, 2u, 1u, 0u };
639 unsigned int visualToLogical0313[] = { 10u, 9u, 8u, 7u, 6u, 5u, 4u, 3u, 2u, 1u, 0u };
640 unsigned int visualToLogical0314[] = { 9u, 8u, 7u, 6u, 5u, 4u, 3u, 2u, 1u, 0u };
641 unsigned int visualToLogical0315[] = { 13u, 8u, 9u, 10u, 11u, 12u, 7u, 6u, 5u, 4u, 3u, 2u, 1u, 0u };
642 unsigned int visualToLogical0316[] = { 0u, 1u, 2u, 3u, 4u };
644 BidiLineData bidiLine01[] = {};
645 BidiLineData bidiLine02[] = {};
646 BidiLineData bidiLine03[] = {
729 bool directions02[] = { false, false, false, false, false, false };
730 bool directions03[] = { false, false, false, false, false, true, true, true, true, true, false, false, false, false, false, true, true, true, true, true };
732 struct ReorderLinesData data[] =
745 "Left to right text only.",
746 "Hello world demo\nhello world demo\nhello world demo.",
755 "Bidirectional paragraphs.",
756 "Hello world demo\nhello שלום עולם world demo\nשלום بالعالم עולם مرحبا שלום עולם بالعالم hello world\nHello world demo\nhello שלום עולם world demo\nשלום بالعالم עולם مرحبا שלום עולם بالعالم hello world",
765 "Bidirectional paragraphs. Update initial paragraphs.",
766 "Hello world demo\nhello שלום עולם world demo\nשלום بالعالم עולם مرحبا שלום עולם بالعالم hello world\nHello world demo\nhello שלום עולם world demo\nשלום بالعالم עולם مرحبا שלום עולם بالعالم hello world",
775 "Bidirectional paragraphs. Update middle paragraphs.",
776 "Hello world demo\nhello שלום עולם world demo\nשלום بالعالم עולם مرحبا שלום עולם بالعالم hello world\nHello world demo\nhello שלום עולם world demo\nשלום بالعالم עולם مرحبا שלום עולם بالعالم hello world",
785 "Bidirectional paragraphs. Update final paragraphs.",
786 "Hello world demo\nhello שלום עולם world demo\nשלום بالعالم עולם مرحبا שלום עולם بالعالم hello world\nHello world demo\nhello שלום עולם world demo\nשלום بالعالم עולם مرحبا שלום עולם بالعالم hello world",
795 const unsigned int numberOfTests = 6u;
797 for( unsigned int index = 0u; index < numberOfTests; ++index )
799 ToolkitTestApplication application;
800 if( !ReorderLinesTest( data[index] ) )
802 tet_result(TET_FAIL);
806 tet_result(TET_PASS);
810 int UtcDaliGetMirroredText(void)
812 tet_infoline(" UtcDaliGetMirroredText");
814 struct GetMirroredTextData data[] =
824 "Left to right characters only.",
825 "Hello world\nhello world demo.",
828 "Hello world\nhello world demo."
831 "Right to left characters but with no characters to mirror.",
832 "שלום עולם\nمرحبا بالعالم",
835 "שלום עולם\nمرحبا بالعالم"
838 "Right to left characters with some characters to mirror.",
839 "שלום עולם\n(مرحبا بالعالم)",
842 "שלום עולם\n)مرحبا بالعالم("
845 "Right to left characters with some characters to mirror. Update last paragraph.",
846 "שלום עולם\n(مرحبا بالعالم)",
849 "שלום עולם\n)مرحبا بالعالم("
852 "Mix of bidirectional text. With more paragraphs.",
853 "Hello world demo\nhello world\nhello world (مرحبا بالعالم שלום) עולם\nשלום مرحبا بالعالم עולם (hello) مرحبا بالعالم world"
854 " مرحبا بالعالم שלום עולם hello world hello world\nبالعالم שלום (hello) world demo (עולם)\nשלום (مرحبا بالعالم עולם) (hello)",
857 "Hello world demo\nhello world\nhello world (مرحبا بالعالم שלום( עולם\nשלום مرحبا بالعالم עולם )hello( مرحبا بالعالم world"
858 " مرحبا بالعالم שלום עולם hello world hello world\nبالعالم שלום )hello) world demo )עולם(\nשלום )مرحبا بالعالم עולם( )hello("
861 "Mix of bidirectional text. With more paragraphs. Update middle paragraphs.",
862 "Hello world demo\nhello world\nhello world (مرحبا بالعالم שלום) עולם\nשלום مرحبا بالعالم עולם (hello) مرحبا بالعالم world"
863 " مرحبا بالعالم שלום עולם hello world hello world\nبالعالم שלום (hello) world demo (עולם)\nשלום (مرحبا بالعالم עולם) (hello)",
866 "Hello world demo\nhello world\nhello world (مرحبا بالعالم שלום( עולם\nשלום مرحبا بالعالم עולם (hello) مرحبا بالعالم world"
867 " مرحبا بالعالم שלום עולם hello world hello world\nبالعالم שלום (hello) world demo (עולם)\nשלום (مرحبا بالعالم עולם) (hello)"
870 "Mix of bidirectional text. With more paragraphs. Update middle paragraphs (2).",
871 "Hello world demo\nhello world\nhello world (مرحبا بالعالم שלום) עולם\nשלום مرحبا بالعالم עולם (hello) مرحبا بالعالم world"
872 " مرحبا بالعالم שלום עולם hello world hello world\nبالعالم שלום (hello) world demo (עולם)\nשלום (مرحبا بالعالم עולם) (hello)",
875 "Hello world demo\nhello world\nhello world (مرحبا بالعالم שלום) עולם\nשלום مرحبا بالعالم עולם )hello( مرحبا بالعالم world"
876 " مرحبا بالعالم שלום עולם hello world hello world\nبالعالم שלום (hello) world demo (עולם)\nשלום (مرحبا بالعالم עולם) (hello)"
879 const unsigned int numberOfTests = 8u;
881 for( unsigned int index = 0u; index < numberOfTests; ++index )
883 ToolkitTestApplication application;
884 if( !GetMirroredTextTest( data[index] ) )
886 tet_result(TET_FAIL);
890 tet_result(TET_PASS);
894 int UtcDaliGetCharactersDirection(void)
896 tet_infoline(" UtcDaliGetCharactersDirection");
898 bool directions01[] = {};
899 bool directions02[] = {
900 false, false, false, false, false, false, false, false, false, false,
901 false, false, false, false, false, false, false, false, false, false,
902 false, false, false, false, false, false, false, false };
903 bool directions03[] = {
904 true, true, true, true, true, true, true, true, true, true,
905 true, true, true, true, true, true, true, true, true };
906 bool directions04[] = {
907 false, false, false, false, false, false, false, false, false, false,
908 false, false, false, false, false, false, false, false, false, false,
909 false, false, false, false, true, true, true, true, true, true,
910 true, true, true, false, true, true, true, true, true, true,
911 true, true, true, true, false, false, false, false, false, false,
912 false, false, false, false, false };
913 bool directions05[] = {
914 false, false, false, false, false, false, false, false, false, false,
915 false, false, false, false, false, false, false, false, false, false,
916 false, false, false, false, false, false, false, false, false, false,
917 false, false, false, false, false, false, false, false, false, false,
918 false, true, true, true, true, true, true, true, true, true,
919 true, true, true, true, true, true, true, true, true, true,
920 true, true, true, true, false, true, true, true, true, true,
921 true, true, true, true, true, true, true, true, true, true,
922 true, true, true, true, true, true, true, true, true, false,
923 false, false, false, false, true, true, true, true, true, true,
924 true, true, true, true, true, true, true, true, true, false,
925 false, false, false, false, true, true, true, true, true, true,
926 true, true, true, true, true, true, true, true, true, true,
927 true, true, true, true, true, true, true, true, true, false,
928 false, false, false, false, false, false, false, false, false, false,
929 false, false, false, false, false, false, false, false, false, false,
930 false, false, true, true, true, true, true, true, true, true,
931 true, true, true, true, true, true, false, false, false, false,
932 false, false, false, false, false, false, false, false, false, false,
933 false, false, true, true, true, true, true, true, true, true,
934 true, true, true, true, true, true, true, true, true, true,
935 true, true, true, true, true, true, true, true, true, true,
936 true, true, false, false, false, false, false };
938 bool directions06[] = {
939 true, true, true, true, true, true, true, true, true, true,
940 false, false, false, false, false, false, false, false, false, false,
941 false, false, false, false, false, false };
943 struct GetCharactersDirectionData data[] =
954 "Left to right characters only",
955 "Hello world\nhello world demo",
962 "Right to left characters only",
963 "שלום עולם\nשלום עולם",
970 "Mix of bidirectional text",
971 "Hello world\nhello world שלום עולם\nשלום עולם hello world",
978 "Mix of bidirectional text. With more paragraphs.",
979 "Hello world demo\nhello world\nhello world مرحبا بالعالم שלום עולם\nשלום مرحبا بالعالم עולם hello مرحبا بالعالم world"
980 " مرحبا بالعالم שלום עולם hello world hello world\nبالعالم שלום hello world demo עולם\nשלום مرحبا بالعالم עולם hello",
987 "Mix of bidirectional text. With more paragraphs. Update first paragraph.",
988 "Hello world demo\nhello world\nhello world مرحبا بالعالم שלום עולם\nשלום مرحبا بالعالم עולם hello مرحبا بالعالم world"
989 " مرحبا بالعالم שלום עולם hello world hello world\nبالعالم שלום hello world demo עולם\nשלום مرحبا بالعالم עולם hello",
996 "Mix of bidirectional text. With more paragraphs. Update from character 29",
997 "Hello world demo\nhello world\nhello world مرحبا بالعالم שלום עולם\nשלום مرحبا بالعالم עולם hello مرحبا بالعالم world"
998 " مرحبا بالعالم שלום עולם hello world hello world\nبالعالم שלום hello world demo עולם\nשלום مرحبا بالعالم עולם hello",
1005 "Mix of bidirectional text. With more paragraphs. Update from character 163",
1006 "Hello world demo\nhello world\nhello world مرحبا بالعالم שלום עולם\nשלום مرحبا بالعالم עולם hello مرحبا بالعالم world"
1007 " مرحبا بالعالم שלום עולם hello world hello world\nبالعالم שלום hello world demo עולם\nשלום مرحبا بالعالم עולם hello",
1014 "Mix of bidirectional text. With brackets and LRM",
1015 "שלום עולם ‎(hello)[world]‎",
1022 const unsigned int numberOfTests = 9u;
1024 for( unsigned int index = 0u; index < numberOfTests; ++index )
1026 ToolkitTestApplication application;
1027 if( !GetCharactersDirectionTest( data[index] ) )
1029 tet_result(TET_FAIL);
1033 tet_result(TET_PASS);