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.
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-model.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.
91 struct GetMirroredTextData
93 std::string description; ///< Description of the test.
94 std::string text; ///< Input text.
95 unsigned int startIndex; ///< The index from where the model is updated.
96 unsigned int numberOfCharacters; ///< The number of the characters.
97 std::string mirroredText; ///< The expected result.
100 struct GetCharactersDirectionData
102 std::string description; ///< Description of the test.
103 std::string text; ///< Input text.
104 unsigned int startIndex; ///< The index from where the model is updated.
105 unsigned int numberOfCharacters; ///< The number of characters.
106 bool* directions; ///< The expected directions.
109 bool SetBidirectionalInfoTest( const SetBidirectionalInfoData& data )
111 // 1) Create the model.
112 LogicalModelPtr logicalModel = LogicalModel::New();
113 VisualModelPtr visualModel = VisualModel::New();
114 Size textArea(100.f, 60.f);
118 CreateTextModel( data.text,
124 // 2) Clear the bidirectional paragraph info data.
125 Vector<BidirectionalParagraphInfoRun>& bidirectionalInfo = logicalModel->mBidirectionalParagraphInfo;
126 if( 0u != data.numberOfCharacters )
128 ClearCharacterRuns( data.startIndex,
129 data.startIndex + data.numberOfCharacters - 1u,
133 // 3) Call the SetBidirectionalInfo() function.
134 SetBidirectionalInfo( logicalModel->mText,
135 logicalModel->mScriptRuns,
136 logicalModel->mLineBreakInfo,
138 data.numberOfCharacters,
141 // 4) Compare with the expected results.
142 TextAbstraction::BidirectionalSupport bidirectionalSupport = TextAbstraction::BidirectionalSupport::Get();
144 if( data.numberOfParagraphs != bidirectionalInfo.Count() )
146 // Different number of expected bidirectional paragraphs.
147 std::cout << " Different number of bidi paragraphs : " << bidirectionalInfo.Count() << ", expected : " << data.numberOfParagraphs << std::endl;
151 for( unsigned int index = 0u; index < data.numberOfParagraphs; ++index )
153 const BidirectionalParagraphInfoRun& run = bidirectionalInfo[index];
155 const CharacterDirection direction = bidirectionalSupport.GetParagraphDirection( run.bidirectionalInfoIndex );
156 if( direction != data.directions[index] )
158 std::cout << " Different direction" << std::endl;
159 std::cout << " paragraph : " << index << std::endl;
160 std::cout << " index : " << run.characterRun.characterIndex << ", num chars : " << run.characterRun.numberOfCharacters << ", direction : " << direction << std::endl;
161 std::cout << " expected, index : " << data.indices[index] << ", num chars : " << data.numberOfParagraphCharacters[index] << ", direction : " << data.directions[index] << std::endl;
165 if( run.characterRun.characterIndex != data.indices[index] )
167 std::cout << " Different index" << std::endl;
168 std::cout << " paragraph : " << index << std::endl;
169 std::cout << " index : " << run.characterRun.characterIndex << ", num chars : " << run.characterRun.numberOfCharacters << ", direction : " << direction << std::endl;
170 std::cout << " expected, index : " << data.indices[index] << ", num chars : " << data.numberOfParagraphCharacters[index] << ", direction : " << data.directions[index] << std::endl;
173 if( run.characterRun.numberOfCharacters != data.numberOfParagraphCharacters[index] )
175 std::cout << " Different number of characters" << std::endl;
176 std::cout << " paragraph : " << index << std::endl;
177 std::cout << " index : " << run.characterRun.characterIndex << ", num chars : " << run.characterRun.numberOfCharacters << ", direction : " << direction << std::endl;
178 std::cout << " expected, index : " << data.indices[index] << ", num chars : " << data.numberOfParagraphCharacters[index] << ", direction : " << data.directions[index] << std::endl;
187 * @brief Frees previously allocated bidirectional resources.
189 * @param[in] bidirectionalLineInfo Bidirectional info per line.
190 * @param[in] startIndex Index to the first line with bidirectional info to be freed.
191 * @param[in] endIndex Index to the last line with bidirectional info to be freed.
193 void FreeBidirectionalLineInfoResources( Vector<BidirectionalLineInfoRun> bidirectionalLineInfo,
197 // Free the allocated memory used to store the conversion table in the bidirectional line info run.
198 for( Vector<BidirectionalLineInfoRun>::Iterator it = bidirectionalLineInfo.Begin() + startIndex,
199 endIt = bidirectionalLineInfo.Begin() + endIndex;
203 BidirectionalLineInfoRun& bidiLineInfo = *it;
205 free( bidiLineInfo.visualToLogicalMap );
209 bool ReorderLinesTest( const ReorderLinesData& data )
211 // 1) Create the model.
212 LogicalModelPtr logicalModel = LogicalModel::New();
213 VisualModelPtr visualModel = VisualModel::New();
214 Size textArea(100.f, 300.f);
218 CreateTextModel( data.text,
224 // 2) Clear the bidirectional line info data.
225 uint32_t startRemoveIndex = logicalModel->mBidirectionalLineInfo.Count();
226 uint32_t endRemoveIndex = startRemoveIndex;
227 ClearCharacterRuns( data.startIndex,
228 data.startIndex + data.numberOfCharacters - 1u,
229 logicalModel->mBidirectionalLineInfo,
233 // Index to the first index to be removed.
235 FreeBidirectionalLineInfoResources( logicalModel->mBidirectionalLineInfo, startRemoveIndex, endRemoveIndex );
236 BidirectionalLineInfoRun* bidiLineBuffer = logicalModel->mBidirectionalLineInfo.Begin();
237 logicalModel->mBidirectionalLineInfo.Erase( bidiLineBuffer + startRemoveIndex,
238 bidiLineBuffer + endRemoveIndex );
240 // 3) Call the function ReorderLines()
242 ReorderLines( logicalModel->mBidirectionalParagraphInfo,
244 data.numberOfCharacters,
246 logicalModel->mBidirectionalLineInfo );
248 // 4) Compare the results.
250 if( data.numberOfLineInfo != logicalModel->mBidirectionalLineInfo.Count() )
252 // Different number of bidirectional lines.
253 std::cout << " different number of bidi lines : " << logicalModel->mBidirectionalLineInfo.Count() << ", expected : " << data.numberOfLineInfo << std::endl;
254 for( unsigned int index = 0u; index < logicalModel->mBidirectionalLineInfo.Count(); ++index )
256 const BidirectionalLineInfoRun& run = logicalModel->mBidirectionalLineInfo[index];
257 const BidiLineData& bidiLineData = data.bidiLineData[index];
259 std::cout << " bidi line : " << index << ", index : " << run.characterRun.characterIndex << ", num chars : " << run.characterRun.numberOfCharacters << std::endl;
260 std::cout << " expected index : " << bidiLineData.characterIndex << ", num chars : " << bidiLineData.numberOfCharacters << std::endl;
265 for( unsigned int index = 0u; index < data.numberOfLineInfo; ++index )
267 const BidirectionalLineInfoRun& run = logicalModel->mBidirectionalLineInfo[index];
268 const BidiLineData& bidiLineData = data.bidiLineData[index];
270 if( bidiLineData.characterIndex != run.characterRun.characterIndex )
272 std::cout << " bidi line : " << index << ", index : " << run.characterRun.characterIndex << ", num chars : " << run.characterRun.numberOfCharacters << std::endl;
273 std::cout << " expected index : " << bidiLineData.characterIndex << ", num chars : " << bidiLineData.numberOfCharacters << std::endl;
276 if( bidiLineData.numberOfCharacters != run.characterRun.numberOfCharacters )
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;
283 for( unsigned int i = 0u; i < run.characterRun.numberOfCharacters; ++i )
285 if( bidiLineData.visualToLogical[i] != run.visualToLogicalMap[i] )
287 std::cout << " v2l : ";
288 for( unsigned int i = 0u; i < run.characterRun.numberOfCharacters; ++i )
290 std::cout << run.visualToLogicalMap[i] << " ";
292 std::cout << std::endl;
293 std::cout << " expected v2l : ";
294 for( unsigned int i = 0u; i < run.characterRun.numberOfCharacters; ++i )
296 std::cout << bidiLineData.visualToLogical[i] << " ";
298 std::cout << std::endl;
308 bool GetMirroredTextTest( const GetMirroredTextData& data )
310 // 1) Create the model.
311 LogicalModelPtr logicalModel = LogicalModel::New();
312 VisualModelPtr visualModel = VisualModel::New();
313 Size textArea(100.f, 60.f);
317 CreateTextModel( data.text,
323 // 2) Call the GetMirroredText() function for the whole text
324 Vector<Character> mirroredText;
325 bool mirrored = false;
326 mirrored = GetMirroredText( logicalModel->mText,
327 logicalModel->mCharacterDirections,
328 logicalModel->mBidirectionalParagraphInfo,
330 logicalModel->mText.Count(),
333 // 3) Call the GetMirroredText() function for the given index + number of characters
334 mirrored = GetMirroredText( logicalModel->mText,
335 logicalModel->mCharacterDirections,
336 logicalModel->mBidirectionalParagraphInfo,
338 data.numberOfCharacters,
341 // 4) Compare the results.
344 std::string mirroredString;
345 Utf32ToUtf8( mirroredText.Begin(),
346 mirroredText.Count(),
349 if( !mirrored && ( mirroredString != data.text ) )
351 std::cout << " No mirrored text and mirroredString != data.text." << std::endl;
352 std::cout << " mirrored string : [" << mirroredString << "]" << std::endl;
353 std::cout << " text : [" << data.text << "]" << std::endl;
357 if( mirrored && ( mirroredString == data.text ) )
359 std::cout << " Mirrored text and mirroredString == data.text." << std::endl;
360 std::cout << " mirrored string : [" << mirroredString << "]" << std::endl;
361 std::cout << " text : [" << data.text << "]" << std::endl;
365 if( mirrored && ( mirroredString != data.mirroredText ) )
367 std::cout << " Mirrored text and mirroredString != data.mirroredText." << std::endl;
368 std::cout << " mirrored string : [" << mirroredString << "]" << std::endl;
369 std::cout << " text : [" << data.mirroredText << "]" << std::endl;
376 bool GetCharactersDirectionTest( const GetCharactersDirectionData& data )
378 // 1) Create the model.
379 LogicalModelPtr logicalModel = LogicalModel::New();
380 VisualModelPtr visualModel = VisualModel::New();
381 Size textArea(100.f, 60.f);
385 CreateTextModel( data.text,
391 Vector<BidirectionalParagraphInfoRun>& bidirectionalInfo = logicalModel->mBidirectionalParagraphInfo;
393 // 2) Clear the direction info data.
394 Vector<CharacterDirection>& directions = logicalModel->mCharacterDirections;
396 directions.Erase( directions.Begin() + data.startIndex,
397 directions.Begin() + data.startIndex + data.numberOfCharacters );
399 // 3) Call GetCharactersDirection() function.
401 GetCharactersDirection( bidirectionalInfo,
402 logicalModel->mText.Count(),
404 data.numberOfCharacters,
407 for( unsigned int index = 0u; index < logicalModel->mText.Count(); ++index )
409 if( data.directions[index] != directions[index] )
420 //////////////////////////////////////////////////////////
422 int UtcDaliSetBidirectionalInfo(void)
424 ToolkitTestApplication application;
425 tet_infoline(" UtcDaliSetBidirectionalInfo");
427 unsigned int indices01[] = {};
428 unsigned int numberOfCharacters01[] = {};
429 bool direction01[] = {};
430 unsigned int indices02[] = {};
431 unsigned int numberOfCharacters02[] = {};
432 bool direction02[] = {};
433 unsigned int indices03[] = { 17u, 48u };
434 unsigned int numberOfCharacters03[] = { 14u, 14u };
435 bool direction03[] = { true, true };
436 unsigned int indices04[] = { 17u, 31u, 79u };
437 unsigned int numberOfCharacters04[] = { 14u, 48u, 31u };
438 bool direction04[] = { true, false, true };
439 unsigned int indices05[] = { 17u, 41u, 117u };
440 unsigned int numberOfCharacters05[] = { 24u, 76u, 49u };
441 bool direction05[] = { true, false, true };
442 unsigned int indices06[] = { 17u, 48u };
443 unsigned int numberOfCharacters06[] = { 14u, 14u };
444 bool direction06[] = { true, true };
445 unsigned int indices07[] = { 17u, 31u, 79u };
446 unsigned int numberOfCharacters07[] = { 14u, 48u, 31u };
447 bool direction07[] = { true, false, true };
448 unsigned int indices08[] = { 17u, 41u, 117u };
449 unsigned int numberOfCharacters08[] = { 24u, 76u, 49u };
450 bool direction08[] = { true, false, true };
452 struct SetBidirectionalInfoData data[] =
461 numberOfCharacters01,
465 "Some left to right paragraphs",
466 "Hello world\ndemo\n\n",
471 numberOfCharacters02,
475 "A mix of left to right and right to left paragraphs.",
476 "Hello world demo\nمرحبا بالعالم\nhello world demo\nمرحبا بالعالم\nhello world demo",
481 numberOfCharacters03,
485 "A mix of left to right and right to left paragraphs. Paragraphs also contain a mix of bidirectional text.",
486 "Hello world demo\nمرحبا بالعالم\nhello world demo مرحبا بالعالم hello world demo\nمرحبا hello world demo بالعالم\nhello world demo",
491 numberOfCharacters04,
495 "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.",
496 "Hello world demo\nمرحبا שלום עולם بالعالم\nhello world שלום بالعالم עולם demo مرحبا שלום עולם بالعالم hello world demo\nمرحبا hello שלום بالعالم עולם world demo بالعالم\nhello world demo",
501 numberOfCharacters05,
505 "A mix of left to right and right to left paragraphs. Updates a left to right paragraph.",
506 "Hello world demo\nمرحبا بالعالم\nhello world demo\nمرحبا بالعالم\nhello world demo",
511 numberOfCharacters06,
515 "A mix of left to right and right to left paragraphs. Paragraphs also contain a mix of bidirectional text.",
516 "Hello world demo\nمرحبا بالعالم\nhello world demo مرحبا بالعالم hello world demo\nمرحبا hello world demo بالعالم\nhello world demo",
521 numberOfCharacters07,
525 "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.",
526 "Hello world demo\nمرحبا שלום עולם بالعالم\nhello world שלום بالعالم עולם demo مرحبا שלום עולם بالعالم hello world demo\nمرحبا hello שלום بالعالم עולם world demo بالعالم\nhello world demo",
531 numberOfCharacters08,
535 "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.",
536 "Hello world demo\nمرحبا שלום עולם بالعالم\nhello world שלום بالعالم עולם demo مرحبا שלום עולם بالعالم hello world demo\nمرحبا hello שלום بالعالم עולם world demo بالعالم\nhello world demo",
541 numberOfCharacters08,
545 "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",
546 "Hello world demo\nمرحبا שלום עולם بالعالم\nhello world שלום بالعالم עולם demo مرحبا שלום עולם بالعالم hello world demo\nمرحبا hello שלום بالعالم עולם world demo بالعالم\nhello world demo",
551 numberOfCharacters08,
555 const unsigned int numberOfTests = 10u;
557 for( unsigned int index = 0u; index < numberOfTests; ++index )
559 if( !SetBidirectionalInfoTest( data[index] ) )
561 tet_result(TET_FAIL);
565 tet_result(TET_PASS);
569 int UtcDaliReorderLines(void)
571 ToolkitTestApplication application;
572 tet_infoline(" UtcDaliSetBidirectionalInfo");
574 unsigned int visualToLogical0301[] = { 0u, 1u, 2u, 3u, 4u, 5u, 9u, 8u, 7u, 6u, 10u };
575 unsigned int visualToLogical0302[] = { 3u, 2u, 1u, 0u, 4u, 5u, 6u, 7u, 8u, 9u, 10u };
576 unsigned int visualToLogical0303[] = { 0u, 1u, 2u, 3u, 4u };
577 unsigned int visualToLogical0304[] = { 12u, 11u, 10u, 9u, 8u, 7u, 6u, 5u, 4u, 3u, 2u, 1u, 0u };
578 unsigned int visualToLogical0305[] = { 10u, 9u, 8u, 7u, 6u, 5u, 4u, 3u, 2u, 1u, 0u };
579 unsigned int visualToLogical0306[] = { 9u, 8u, 7u, 6u, 5u, 4u, 3u, 2u, 1u, 0u };
580 unsigned int visualToLogical0307[] = { 13u, 8u, 9u, 10u, 11u, 12u, 7u, 6u, 5u, 4u, 3u, 2u, 1u, 0u };
581 unsigned int visualToLogical0308[] = { 5u, 0u, 1u, 2u, 3u, 4u };
582 unsigned int visualToLogical0309[] = { 0u, 1u, 2u, 3u, 4u, 5u, 9u, 8u, 7u, 6u, 10u };
583 unsigned int visualToLogical0310[] = { 3u, 2u, 1u, 0u, 4u, 5u, 6u, 7u, 8u, 9u, 10u };
584 unsigned int visualToLogical0311[] = { 0u, 1u, 2u, 3u, 4u };
585 unsigned int visualToLogical0312[] = { 12u, 11u, 10u, 9u, 8u, 7u, 6u, 5u, 4u, 3u, 2u, 1u, 0u };
586 unsigned int visualToLogical0313[] = { 10u, 9u, 8u, 7u, 6u, 5u, 4u, 3u, 2u, 1u, 0u };
587 unsigned int visualToLogical0314[] = { 9u, 8u, 7u, 6u, 5u, 4u, 3u, 2u, 1u, 0u };
588 unsigned int visualToLogical0315[] = { 13u, 8u, 9u, 10u, 11u, 12u, 7u, 6u, 5u, 4u, 3u, 2u, 1u, 0u };
589 unsigned int visualToLogical0316[] = { 0u, 1u, 2u, 3u, 4u };
591 BidiLineData bidiLine01[] = {};
592 BidiLineData bidiLine02[] = {};
593 BidiLineData bidiLine03[] = {
676 struct ReorderLinesData data[] =
687 "Left to right text only.",
688 "Hello world demo\nhello world demo\nhello world demo.",
695 "Bidirectional paragraphs.",
696 "Hello world demo\nhello שלום עולם world demo\nשלום بالعالم עולם مرحبا שלום עולם بالعالم hello world\nHello world demo\nhello שלום עולם world demo\nשלום بالعالم עולם مرحبا שלום עולם بالعالم hello world",
703 "Bidirectional paragraphs. Update initial paragraphs.",
704 "Hello world demo\nhello שלום עולם world demo\nשלום بالعالم עולם مرحبا שלום עולם بالعالم hello world\nHello world demo\nhello שלום עולם world demo\nשלום بالعالم עולם مرحبا שלום עולם بالعالم hello world",
711 "Bidirectional paragraphs. Update middle paragraphs.",
712 "Hello world demo\nhello שלום עולם world demo\nשלום بالعالم עולם مرحبا שלום עולם بالعالم hello world\nHello world demo\nhello שלום עולם world demo\nשלום بالعالم עולם مرحبا שלום עולם بالعالم hello world",
719 "Bidirectional paragraphs. Update final paragraphs.",
720 "Hello world demo\nhello שלום עולם world demo\nשלום بالعالم עולם مرحبا שלום עולם بالعالم hello world\nHello world demo\nhello שלום עולם world demo\nשלום بالعالم עולם مرحبا שלום עולם بالعالم hello world",
727 const unsigned int numberOfTests = 6u;
729 for( unsigned int index = 0u; index < numberOfTests; ++index )
731 if( !ReorderLinesTest( data[index] ) )
733 tet_result(TET_FAIL);
737 tet_result(TET_PASS);
741 int UtcDaliGetMirroredText(void)
743 ToolkitTestApplication application;
744 tet_infoline(" UtcDaliGetMirroredText");
746 struct GetMirroredTextData data[] =
756 "Left to right characters only.",
757 "Hello world\nhello world demo.",
760 "Hello world\nhello world demo."
763 "Right to left characters but with no characters to mirror.",
764 "שלום עולם\nمرحبا بالعالم",
767 "שלום עולם\nمرحبا بالعالم"
770 "Right to left characters with some characters to mirror.",
771 "שלום עולם\n(مرحبا بالعالم)",
774 "שלום עולם\n)مرحبا بالعالم("
777 "Right to left characters with some characters to mirror. Update last paragraph.",
778 "שלום עולם\n(مرحبا بالعالم)",
781 "שלום עולם\n)مرحبا بالعالم("
784 "Mix of bidirectional text. With more paragraphs.",
785 "Hello world demo\nhello world\nhello world (مرحبا بالعالم שלום) עולם\nשלום مرحبا بالعالم עולם (hello) مرحبا بالعالم world"
786 " مرحبا بالعالم שלום עולם hello world hello world\nبالعالم שלום (hello) world demo (עולם)\nשלום (مرحبا بالعالم עולם) (hello)",
789 "Hello world demo\nhello world\nhello world (مرحبا بالعالم שלום( עולם\nשלום مرحبا بالعالم עולם )hello( مرحبا بالعالم world"
790 " مرحبا بالعالم שלום עולם hello world hello world\nبالعالم שלום )hello) world demo )עולם(\nשלום )مرحبا بالعالم עולם( )hello("
793 "Mix of bidirectional text. With more paragraphs. Update middle paragraphs.",
794 "Hello world demo\nhello world\nhello world (مرحبا بالعالم שלום) עולם\nשלום مرحبا بالعالم עולם (hello) مرحبا بالعالم world"
795 " مرحبا بالعالم שלום עולם hello world hello world\nبالعالم שלום (hello) world demo (עולם)\nשלום (مرحبا بالعالم עולם) (hello)",
798 "Hello world demo\nhello world\nhello world (مرحبا بالعالم שלום( עולם\nשלום مرحبا بالعالم עולם (hello) مرحبا بالعالم world"
799 " مرحبا بالعالم שלום עולם hello world hello world\nبالعالم שלום (hello) world demo (עולם)\nשלום (مرحبا بالعالم עולם) (hello)"
802 "Mix of bidirectional text. With more paragraphs. Update middle paragraphs (2).",
803 "Hello world demo\nhello world\nhello world (مرحبا بالعالم שלום) עולם\nשלום مرحبا بالعالم עולם (hello) مرحبا بالعالم world"
804 " مرحبا بالعالم שלום עולם hello world hello world\nبالعالم שלום (hello) world demo (עולם)\nשלום (مرحبا بالعالم עולם) (hello)",
807 "Hello world demo\nhello world\nhello world (مرحبا بالعالم שלום) עולם\nשלום مرحبا بالعالم עולם )hello( مرحبا بالعالم world"
808 " مرحبا بالعالم שלום עולם hello world hello world\nبالعالم שלום (hello) world demo (עולם)\nשלום (مرحبا بالعالم עולם) (hello)"
811 const unsigned int numberOfTests = 8u;
813 for( unsigned int index = 0u; index < numberOfTests; ++index )
815 if( !GetMirroredTextTest( data[index] ) )
817 tet_result(TET_FAIL);
821 tet_result(TET_PASS);
825 int UtcDaliGetCharactersDirection(void)
827 ToolkitTestApplication application;
828 tet_infoline(" UtcDaliGetCharactersDirection");
830 bool directions01[] = {};
831 bool directions02[] = {
832 false, false, false, false, false, false, false, false, false, false,
833 false, false, false, false, false, false, false, false, false, false,
834 false, false, false, false, false, false, false, false };
835 bool directions03[] = {
836 true, true, true, true, true, true, true, true, true, true,
837 true, true, true, true, true, true, true, true, true };
838 bool directions04[] = {
839 false, false, false, false, false, false, false, false, false, false,
840 false, false, false, false, false, false, false, false, false, false,
841 false, false, false, false, true, true, true, true, true, true,
842 true, true, true, false, true, true, true, true, true, true,
843 true, true, true, true, false, false, false, false, false, false,
844 false, false, false, false, false };
845 bool directions05[] = {
846 false, false, false, false, false, false, false, false, false, false,
847 false, false, false, false, false, false, false, false, false, false,
848 false, false, false, false, false, false, false, false, false, false,
849 false, false, false, false, false, false, false, false, false, false,
850 false, true, true, true, true, true, true, true, true, true,
851 true, true, true, true, true, true, true, true, true, true,
852 true, true, true, true, false, true, true, true, true, true,
853 true, true, true, true, true, true, true, true, true, true,
854 true, true, true, true, true, true, true, true, true, false,
855 false, false, false, false, true, true, true, true, true, true,
856 true, true, true, true, true, true, true, true, true, false,
857 false, false, false, false, true, true, true, true, true, true,
858 true, true, true, true, true, true, true, true, true, true,
859 true, true, true, true, true, true, true, true, true, false,
860 false, false, false, false, false, false, false, false, false, false,
861 false, false, false, false, false, false, false, false, false, false,
862 false, false, true, true, true, true, true, true, true, true,
863 true, true, true, true, true, true, false, false, false, false,
864 false, false, false, false, false, false, false, false, false, false,
865 false, false, true, true, true, true, true, true, true, true,
866 true, true, true, true, true, true, true, true, true, true,
867 true, true, true, true, true, true, true, true, true, true,
868 true, true, false, false, false, false, false };
870 struct GetCharactersDirectionData data[] =
880 "Left to right characters only",
881 "Hello world\nhello world demo",
887 "Right to left characters only",
888 "שלום עולם\nשלום עולם",
894 "Mix of bidirectional text",
895 "Hello world\nhello world שלום עולם\nשלום עולם hello world",
901 "Mix of bidirectional text. With more paragraphs.",
902 "Hello world demo\nhello world\nhello world مرحبا بالعالم שלום עולם\nשלום مرحبا بالعالم עולם hello مرحبا بالعالم world"
903 " مرحبا بالعالم שלום עולם hello world hello world\nبالعالم שלום hello world demo עולם\nשלום مرحبا بالعالم עולם hello",
909 "Mix of bidirectional text. With more paragraphs. Update first paragraph.",
910 "Hello world demo\nhello world\nhello world مرحبا بالعالم שלום עולם\nשלום مرحبا بالعالم עולם hello مرحبا بالعالم world"
911 " مرحبا بالعالم שלום עולם hello world hello world\nبالعالم שלום hello world demo עולם\nשלום مرحبا بالعالم עולם hello",
917 "Mix of bidirectional text. With more paragraphs. Update from character 29",
918 "Hello world demo\nhello world\nhello world مرحبا بالعالم שלום עולם\nשלום مرحبا بالعالم עולם hello مرحبا بالعالم world"
919 " مرحبا بالعالم שלום עולם hello world hello world\nبالعالم שלום hello world demo עולם\nשלום مرحبا بالعالم עולם hello",
925 "Mix of bidirectional text. With more paragraphs. Update from character 163",
926 "Hello world demo\nhello world\nhello world مرحبا بالعالم שלום עולם\nשלום مرحبا بالعالم עולם hello مرحبا بالعالم world"
927 " مرحبا بالعالم שלום עולם hello world hello world\nبالعالم שלום hello world demo עולם\nשלום مرحبا بالعالم עולם hello",
933 const unsigned int numberOfTests = 8u;
935 for( unsigned int index = 0u; index < numberOfTests; ++index )
937 if( !GetCharactersDirectionTest( data[index] ) )
939 tet_result(TET_FAIL);
943 tet_result(TET_PASS);