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.
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.
111 bool SetBidirectionalInfoTest( const SetBidirectionalInfoData& data )
113 // 1) Create the model.
114 LogicalModelPtr logicalModel = LogicalModel::New();
115 VisualModelPtr visualModel = VisualModel::New();
116 Size textArea(100.f, 60.f);
120 const Vector<FontDescriptionRun> fontDescriptions;
121 const LayoutOptions options;
122 CreateTextModel( data.text,
130 // 2) Clear the bidirectional paragraph info data.
131 Vector<BidirectionalParagraphInfoRun>& bidirectionalInfo = logicalModel->mBidirectionalParagraphInfo;
132 if( 0u != data.numberOfCharacters )
134 ClearCharacterRuns( data.startIndex,
135 data.startIndex + data.numberOfCharacters - 1u,
139 // 3) Call the SetBidirectionalInfo() function.
140 SetBidirectionalInfo( logicalModel->mText,
141 logicalModel->mScriptRuns,
142 logicalModel->mLineBreakInfo,
144 data.numberOfCharacters,
147 // 4) Compare with the expected results.
148 TextAbstraction::BidirectionalSupport bidirectionalSupport = TextAbstraction::BidirectionalSupport::Get();
150 if( data.numberOfParagraphs != bidirectionalInfo.Count() )
152 // Different number of expected bidirectional paragraphs.
153 std::cout << " Different number of bidi paragraphs : " << bidirectionalInfo.Count() << ", expected : " << data.numberOfParagraphs << std::endl;
157 for( unsigned int index = 0u; index < data.numberOfParagraphs; ++index )
159 const BidirectionalParagraphInfoRun& run = bidirectionalInfo[index];
161 const CharacterDirection direction = bidirectionalSupport.GetParagraphDirection( run.bidirectionalInfoIndex );
162 if( direction != data.directions[index] )
164 std::cout << " Different direction" << std::endl;
165 std::cout << " paragraph : " << index << std::endl;
166 std::cout << " index : " << run.characterRun.characterIndex << ", num chars : " << run.characterRun.numberOfCharacters << ", direction : " << direction << std::endl;
167 std::cout << " expected, index : " << data.indices[index] << ", num chars : " << data.numberOfParagraphCharacters[index] << ", direction : " << data.directions[index] << std::endl;
171 if( run.characterRun.characterIndex != data.indices[index] )
173 std::cout << " Different index" << std::endl;
174 std::cout << " paragraph : " << index << std::endl;
175 std::cout << " index : " << run.characterRun.characterIndex << ", num chars : " << run.characterRun.numberOfCharacters << ", direction : " << direction << std::endl;
176 std::cout << " expected, index : " << data.indices[index] << ", num chars : " << data.numberOfParagraphCharacters[index] << ", direction : " << data.directions[index] << std::endl;
179 if( run.characterRun.numberOfCharacters != data.numberOfParagraphCharacters[index] )
181 std::cout << " Different number of characters" << std::endl;
182 std::cout << " paragraph : " << index << std::endl;
183 std::cout << " index : " << run.characterRun.characterIndex << ", num chars : " << run.characterRun.numberOfCharacters << ", direction : " << direction << std::endl;
184 std::cout << " expected, index : " << data.indices[index] << ", num chars : " << data.numberOfParagraphCharacters[index] << ", direction : " << data.directions[index] << std::endl;
193 * @brief Frees previously allocated bidirectional resources.
195 * @param[in] bidirectionalLineInfo Bidirectional info per line.
196 * @param[in] startIndex Index to the first line with bidirectional info to be freed.
197 * @param[in] endIndex Index to the last line with bidirectional info to be freed.
199 void FreeBidirectionalLineInfoResources( Vector<BidirectionalLineInfoRun> bidirectionalLineInfo,
203 // Free the allocated memory used to store the conversion table in the bidirectional line info run.
204 for( Vector<BidirectionalLineInfoRun>::Iterator it = bidirectionalLineInfo.Begin() + startIndex,
205 endIt = bidirectionalLineInfo.Begin() + endIndex;
209 BidirectionalLineInfoRun& bidiLineInfo = *it;
211 free( bidiLineInfo.visualToLogicalMap );
215 bool ReorderLinesTest( const ReorderLinesData& data )
217 // 1) Create the model.
218 LogicalModelPtr logicalModel = LogicalModel::New();
219 VisualModelPtr visualModel = VisualModel::New();
220 Size textArea(100.f, 300.f);
224 const Vector<FontDescriptionRun> fontDescriptions;
225 const LayoutOptions options;
226 CreateTextModel( data.text,
234 // 2) Clear the bidirectional line info data.
235 uint32_t startRemoveIndex = logicalModel->mBidirectionalLineInfo.Count();
236 uint32_t endRemoveIndex = startRemoveIndex;
237 ClearCharacterRuns( data.startIndex,
238 data.startIndex + data.numberOfCharacters - 1u,
239 logicalModel->mBidirectionalLineInfo,
243 // Index to the first index to be removed.
245 FreeBidirectionalLineInfoResources( logicalModel->mBidirectionalLineInfo, startRemoveIndex, endRemoveIndex );
246 BidirectionalLineInfoRun* bidiLineBuffer = logicalModel->mBidirectionalLineInfo.Begin();
247 logicalModel->mBidirectionalLineInfo.Erase( bidiLineBuffer + startRemoveIndex,
248 bidiLineBuffer + endRemoveIndex );
250 // 3) Call the function ReorderLines()
252 ReorderLines( logicalModel->mBidirectionalParagraphInfo,
254 data.numberOfCharacters,
256 logicalModel->mBidirectionalLineInfo );
258 // 4) Compare the results.
260 if( data.numberOfLineInfo != logicalModel->mBidirectionalLineInfo.Count() )
262 // Different number of bidirectional lines.
263 std::cout << " different number of bidi lines : " << logicalModel->mBidirectionalLineInfo.Count() << ", expected : " << data.numberOfLineInfo << std::endl;
264 for( unsigned int index = 0u; index < logicalModel->mBidirectionalLineInfo.Count(); ++index )
266 const BidirectionalLineInfoRun& run = logicalModel->mBidirectionalLineInfo[index];
267 const BidiLineData& bidiLineData = data.bidiLineData[index];
269 std::cout << " bidi line : " << index << ", index : " << run.characterRun.characterIndex << ", num chars : " << run.characterRun.numberOfCharacters << std::endl;
270 std::cout << " expected index : " << bidiLineData.characterIndex << ", num chars : " << bidiLineData.numberOfCharacters << std::endl;
275 for( unsigned int index = 0u; index < data.numberOfLineInfo; ++index )
277 const BidirectionalLineInfoRun& run = logicalModel->mBidirectionalLineInfo[index];
278 const BidiLineData& bidiLineData = data.bidiLineData[index];
280 if( bidiLineData.characterIndex != run.characterRun.characterIndex )
282 std::cout << " bidi line : " << index << ", index : " << run.characterRun.characterIndex << ", num chars : " << run.characterRun.numberOfCharacters << std::endl;
283 std::cout << " expected index : " << bidiLineData.characterIndex << ", num chars : " << bidiLineData.numberOfCharacters << std::endl;
286 if( bidiLineData.numberOfCharacters != run.characterRun.numberOfCharacters )
288 std::cout << " bidi line : " << index << ", index : " << run.characterRun.characterIndex << ", num chars : " << run.characterRun.numberOfCharacters << std::endl;
289 std::cout << " expected index : " << bidiLineData.characterIndex << ", num chars : " << bidiLineData.numberOfCharacters << std::endl;
293 for( unsigned int i = 0u; i < run.characterRun.numberOfCharacters; ++i )
295 if( bidiLineData.visualToLogical[i] != run.visualToLogicalMap[i] )
297 std::cout << " v2l : ";
298 for( unsigned int i = 0u; i < run.characterRun.numberOfCharacters; ++i )
300 std::cout << run.visualToLogicalMap[i] << " ";
302 std::cout << std::endl;
303 std::cout << " expected v2l : ";
304 for( unsigned int i = 0u; i < run.characterRun.numberOfCharacters; ++i )
306 std::cout << bidiLineData.visualToLogical[i] << " ";
308 std::cout << std::endl;
315 if( data.numberOfLines != visualModel->mLines.Count() )
317 std::cout << "Different number of lines : " << visualModel->mLines.Count() << ", expected : " << data.numberOfLines << std::endl;
319 unsigned int index = 0u;
320 for( Vector<LineRun>::ConstIterator it = visualModel->mLines.Begin(),
321 endIt = visualModel->mLines.End();
325 const LineRun& line = *it;
327 if( line.direction != *( data.lineDirections + index ) )
329 std::cout << " Different line direction : " << line.direction << ", expected : " << *( data.lineDirections + index ) << std::endl;
338 bool GetMirroredTextTest( const GetMirroredTextData& data )
340 // 1) Create the model.
341 LogicalModelPtr logicalModel = LogicalModel::New();
342 VisualModelPtr visualModel = VisualModel::New();
343 Size textArea(100.f, 60.f);
347 const Vector<FontDescriptionRun> fontDescriptions;
348 const LayoutOptions options;
349 CreateTextModel( data.text,
357 // 2) Call the GetMirroredText() function for the whole text
358 Vector<Character> mirroredText;
359 bool mirrored = false;
360 mirrored = GetMirroredText( logicalModel->mText,
361 logicalModel->mCharacterDirections,
362 logicalModel->mBidirectionalParagraphInfo,
364 logicalModel->mText.Count(),
367 // 3) Call the GetMirroredText() function for the given index + number of characters
368 mirrored = GetMirroredText( logicalModel->mText,
369 logicalModel->mCharacterDirections,
370 logicalModel->mBidirectionalParagraphInfo,
372 data.numberOfCharacters,
375 // 4) Compare the results.
378 std::string mirroredString;
379 Utf32ToUtf8( mirroredText.Begin(),
380 mirroredText.Count(),
383 if( !mirrored && ( mirroredString != data.text ) )
385 std::cout << " No mirrored text and mirroredString != data.text." << std::endl;
386 std::cout << " mirrored string : [" << mirroredString << "]" << std::endl;
387 std::cout << " text : [" << data.text << "]" << std::endl;
391 if( mirrored && ( mirroredString == data.text ) )
393 std::cout << " Mirrored text and mirroredString == data.text." << std::endl;
394 std::cout << " mirrored string : [" << mirroredString << "]" << std::endl;
395 std::cout << " text : [" << data.text << "]" << std::endl;
399 if( mirrored && ( mirroredString != data.mirroredText ) )
401 std::cout << " Mirrored text and mirroredString != data.mirroredText." << std::endl;
402 std::cout << " mirrored string : [" << mirroredString << "]" << std::endl;
403 std::cout << " text : [" << data.mirroredText << "]" << std::endl;
410 bool GetCharactersDirectionTest( const GetCharactersDirectionData& data )
412 // 1) Create the model.
413 LogicalModelPtr logicalModel = LogicalModel::New();
414 VisualModelPtr visualModel = VisualModel::New();
415 Size textArea(100.f, 60.f);
419 const Vector<FontDescriptionRun> fontDescriptions;
420 const LayoutOptions options;
421 CreateTextModel( data.text,
429 Vector<BidirectionalParagraphInfoRun>& bidirectionalInfo = logicalModel->mBidirectionalParagraphInfo;
431 // 2) Clear the direction info data.
432 Vector<CharacterDirection>& directions = logicalModel->mCharacterDirections;
434 directions.Erase( directions.Begin() + data.startIndex,
435 directions.Begin() + data.startIndex + data.numberOfCharacters );
437 // 3) Call GetCharactersDirection() function.
439 GetCharactersDirection( bidirectionalInfo,
440 logicalModel->mText.Count(),
442 data.numberOfCharacters,
445 for( unsigned int index = 0u; index < logicalModel->mText.Count(); ++index )
447 if( data.directions[index] != directions[index] )
458 //////////////////////////////////////////////////////////
460 int UtcDaliSetBidirectionalInfo(void)
462 ToolkitTestApplication application;
463 tet_infoline(" UtcDaliSetBidirectionalInfo");
465 unsigned int indices01[] = {};
466 unsigned int numberOfCharacters01[] = {};
467 bool direction01[] = {};
468 unsigned int indices02[] = {};
469 unsigned int numberOfCharacters02[] = {};
470 bool direction02[] = {};
471 unsigned int indices03[] = { 17u, 48u };
472 unsigned int numberOfCharacters03[] = { 14u, 14u };
473 bool direction03[] = { true, true };
474 unsigned int indices04[] = { 17u, 31u, 79u };
475 unsigned int numberOfCharacters04[] = { 14u, 48u, 31u };
476 bool direction04[] = { true, false, true };
477 unsigned int indices05[] = { 17u, 41u, 117u };
478 unsigned int numberOfCharacters05[] = { 24u, 76u, 49u };
479 bool direction05[] = { true, false, true };
480 unsigned int indices06[] = { 17u, 48u };
481 unsigned int numberOfCharacters06[] = { 14u, 14u };
482 bool direction06[] = { true, true };
483 unsigned int indices07[] = { 17u, 31u, 79u };
484 unsigned int numberOfCharacters07[] = { 14u, 48u, 31u };
485 bool direction07[] = { true, false, true };
486 unsigned int indices08[] = { 17u, 41u, 117u };
487 unsigned int numberOfCharacters08[] = { 24u, 76u, 49u };
488 bool direction08[] = { true, false, true };
490 struct SetBidirectionalInfoData data[] =
499 numberOfCharacters01,
503 "Some left to right paragraphs",
504 "Hello world\ndemo\n\n",
509 numberOfCharacters02,
513 "A mix of left to right and right to left paragraphs.",
514 "Hello world demo\nمرحبا بالعالم\nhello world demo\nمرحبا بالعالم\nhello world demo",
519 numberOfCharacters03,
523 "A mix of left to right and right to left paragraphs. Paragraphs also contain a mix of bidirectional text.",
524 "Hello world demo\nمرحبا بالعالم\nhello world demo مرحبا بالعالم hello world demo\nمرحبا hello world demo بالعالم\nhello world demo",
529 numberOfCharacters04,
533 "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.",
534 "Hello world demo\nمرحبا שלום עולם بالعالم\nhello world שלום بالعالم עולם demo مرحبا שלום עולם بالعالم hello world demo\nمرحبا hello שלום بالعالم עולם world demo بالعالم\nhello world demo",
539 numberOfCharacters05,
543 "A mix of left to right and right to left paragraphs. Updates a left to right paragraph.",
544 "Hello world demo\nمرحبا بالعالم\nhello world demo\nمرحبا بالعالم\nhello world demo",
549 numberOfCharacters06,
553 "A mix of left to right and right to left paragraphs. Paragraphs also contain a mix of bidirectional text.",
554 "Hello world demo\nمرحبا بالعالم\nhello world demo مرحبا بالعالم hello world demo\nمرحبا hello world demo بالعالم\nhello world demo",
559 numberOfCharacters07,
563 "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.",
564 "Hello world demo\nمرحبا שלום עולם بالعالم\nhello world שלום بالعالم עולם demo مرحبا שלום עולם بالعالم hello world demo\nمرحبا hello שלום بالعالم עולם world demo بالعالم\nhello world demo",
569 numberOfCharacters08,
573 "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.",
574 "Hello world demo\nمرحبا שלום עולם بالعالم\nhello world שלום بالعالم עולם demo مرحبا שלום עולם بالعالم hello world demo\nمرحبا hello שלום بالعالم עולם world demo بالعالم\nhello world demo",
579 numberOfCharacters08,
583 "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",
584 "Hello world demo\nمرحبا שלום עולם بالعالم\nhello world שלום بالعالم עולם demo مرحبا שלום עולם بالعالم hello world demo\nمرحبا hello שלום بالعالم עולם world demo بالعالم\nhello world demo",
589 numberOfCharacters08,
593 const unsigned int numberOfTests = 10u;
595 for( unsigned int index = 0u; index < numberOfTests; ++index )
597 if( !SetBidirectionalInfoTest( data[index] ) )
599 tet_result(TET_FAIL);
603 tet_result(TET_PASS);
607 int UtcDaliReorderLines(void)
609 ToolkitTestApplication application;
610 tet_infoline(" UtcDaliSetBidirectionalInfo");
612 unsigned int visualToLogical0301[] = { 0u, 1u, 2u, 3u, 4u, 5u, 9u, 8u, 7u, 6u, 10u };
613 unsigned int visualToLogical0302[] = { 3u, 2u, 1u, 0u, 4u, 5u, 6u, 7u, 8u, 9u, 10u };
614 unsigned int visualToLogical0303[] = { 0u, 1u, 2u, 3u, 4u };
615 unsigned int visualToLogical0304[] = { 12u, 11u, 10u, 9u, 8u, 7u, 6u, 5u, 4u, 3u, 2u, 1u, 0u };
616 unsigned int visualToLogical0305[] = { 10u, 9u, 8u, 7u, 6u, 5u, 4u, 3u, 2u, 1u, 0u };
617 unsigned int visualToLogical0306[] = { 9u, 8u, 7u, 6u, 5u, 4u, 3u, 2u, 1u, 0u };
618 unsigned int visualToLogical0307[] = { 13u, 8u, 9u, 10u, 11u, 12u, 7u, 6u, 5u, 4u, 3u, 2u, 1u, 0u };
619 unsigned int visualToLogical0308[] = { 5u, 0u, 1u, 2u, 3u, 4u };
620 unsigned int visualToLogical0309[] = { 0u, 1u, 2u, 3u, 4u, 5u, 9u, 8u, 7u, 6u, 10u };
621 unsigned int visualToLogical0310[] = { 3u, 2u, 1u, 0u, 4u, 5u, 6u, 7u, 8u, 9u, 10u };
622 unsigned int visualToLogical0311[] = { 0u, 1u, 2u, 3u, 4u };
623 unsigned int visualToLogical0312[] = { 12u, 11u, 10u, 9u, 8u, 7u, 6u, 5u, 4u, 3u, 2u, 1u, 0u };
624 unsigned int visualToLogical0313[] = { 10u, 9u, 8u, 7u, 6u, 5u, 4u, 3u, 2u, 1u, 0u };
625 unsigned int visualToLogical0314[] = { 9u, 8u, 7u, 6u, 5u, 4u, 3u, 2u, 1u, 0u };
626 unsigned int visualToLogical0315[] = { 13u, 8u, 9u, 10u, 11u, 12u, 7u, 6u, 5u, 4u, 3u, 2u, 1u, 0u };
627 unsigned int visualToLogical0316[] = { 0u, 1u, 2u, 3u, 4u };
629 BidiLineData bidiLine01[] = {};
630 BidiLineData bidiLine02[] = {};
631 BidiLineData bidiLine03[] = {
714 bool directions02[] = { false, false, false, false, false, false };
715 bool directions03[] = { false, false, false, false, false, true, true, true, true, true, false, false, false, false, false, true, true, true, true, true };
717 struct ReorderLinesData data[] =
730 "Left to right text only.",
731 "Hello world demo\nhello world demo\nhello world demo.",
740 "Bidirectional paragraphs.",
741 "Hello world demo\nhello שלום עולם world demo\nשלום بالعالم עולם مرحبا שלום עולם بالعالم hello world\nHello world demo\nhello שלום עולם world demo\nשלום بالعالم עולם مرحبا שלום עולם بالعالم hello world",
750 "Bidirectional paragraphs. Update initial paragraphs.",
751 "Hello world demo\nhello שלום עולם world demo\nשלום بالعالم עולם مرحبا שלום עולם بالعالم hello world\nHello world demo\nhello שלום עולם world demo\nשלום بالعالم עולם مرحبا שלום עולם بالعالم hello world",
760 "Bidirectional paragraphs. Update middle paragraphs.",
761 "Hello world demo\nhello שלום עולם world demo\nשלום بالعالم עולם مرحبا שלום עולם بالعالم hello world\nHello world demo\nhello שלום עולם world demo\nשלום بالعالم עולם مرحبا שלום עולם بالعالم hello world",
770 "Bidirectional paragraphs. Update final paragraphs.",
771 "Hello world demo\nhello שלום עולם world demo\nשלום بالعالم עולם مرحبا שלום עולם بالعالم hello world\nHello world demo\nhello שלום עולם world demo\nשלום بالعالم עולם مرحبا שלום עולם بالعالم hello world",
780 const unsigned int numberOfTests = 6u;
782 for( unsigned int index = 0u; index < numberOfTests; ++index )
784 if( !ReorderLinesTest( data[index] ) )
786 tet_result(TET_FAIL);
790 tet_result(TET_PASS);
794 int UtcDaliGetMirroredText(void)
796 ToolkitTestApplication application;
797 tet_infoline(" UtcDaliGetMirroredText");
799 struct GetMirroredTextData data[] =
809 "Left to right characters only.",
810 "Hello world\nhello world demo.",
813 "Hello world\nhello world demo."
816 "Right to left characters but with no characters to mirror.",
817 "שלום עולם\nمرحبا بالعالم",
820 "שלום עולם\nمرحبا بالعالم"
823 "Right to left characters with some characters to mirror.",
824 "שלום עולם\n(مرحبا بالعالم)",
827 "שלום עולם\n)مرحبا بالعالم("
830 "Right to left characters with some characters to mirror. Update last paragraph.",
831 "שלום עולם\n(مرحبا بالعالم)",
834 "שלום עולם\n)مرحبا بالعالم("
837 "Mix of bidirectional text. With more paragraphs.",
838 "Hello world demo\nhello world\nhello world (مرحبا بالعالم שלום) עולם\nשלום مرحبا بالعالم עולם (hello) مرحبا بالعالم world"
839 " مرحبا بالعالم שלום עולם hello world hello world\nبالعالم שלום (hello) world demo (עולם)\nשלום (مرحبا بالعالم עולם) (hello)",
842 "Hello world demo\nhello world\nhello world (مرحبا بالعالم שלום( עולם\nשלום مرحبا بالعالم עולם )hello( مرحبا بالعالم world"
843 " مرحبا بالعالم שלום עולם hello world hello world\nبالعالم שלום )hello) world demo )עולם(\nשלום )مرحبا بالعالم עולם( )hello("
846 "Mix of bidirectional text. With more paragraphs. Update middle paragraphs.",
847 "Hello world demo\nhello world\nhello world (مرحبا بالعالم שלום) עולם\nשלום مرحبا بالعالم עולם (hello) مرحبا بالعالم world"
848 " مرحبا بالعالم שלום עולם hello world hello world\nبالعالم שלום (hello) world demo (עולם)\nשלום (مرحبا بالعالم עולם) (hello)",
851 "Hello world demo\nhello world\nhello world (مرحبا بالعالم שלום( עולם\nשלום مرحبا بالعالم עולם (hello) مرحبا بالعالم world"
852 " مرحبا بالعالم שלום עולם hello world hello world\nبالعالم שלום (hello) world demo (עולם)\nשלום (مرحبا بالعالم עולם) (hello)"
855 "Mix of bidirectional text. With more paragraphs. Update middle paragraphs (2).",
856 "Hello world demo\nhello world\nhello world (مرحبا بالعالم שלום) עולם\nשלום مرحبا بالعالم עולם (hello) مرحبا بالعالم world"
857 " مرحبا بالعالم שלום עולם hello world hello world\nبالعالم שלום (hello) world demo (עולם)\nשלום (مرحبا بالعالم עולם) (hello)",
860 "Hello world demo\nhello world\nhello world (مرحبا بالعالم שלום) עולם\nשלום مرحبا بالعالم עולם )hello( مرحبا بالعالم world"
861 " مرحبا بالعالم שלום עולם hello world hello world\nبالعالم שלום (hello) world demo (עולם)\nשלום (مرحبا بالعالم עולם) (hello)"
864 const unsigned int numberOfTests = 8u;
866 for( unsigned int index = 0u; index < numberOfTests; ++index )
868 if( !GetMirroredTextTest( data[index] ) )
870 tet_result(TET_FAIL);
874 tet_result(TET_PASS);
878 int UtcDaliGetCharactersDirection(void)
880 ToolkitTestApplication application;
881 tet_infoline(" UtcDaliGetCharactersDirection");
883 bool directions01[] = {};
884 bool directions02[] = {
885 false, false, false, false, false, false, false, false, false, false,
886 false, false, false, false, false, false, false, false, false, false,
887 false, false, false, false, false, false, false, false };
888 bool directions03[] = {
889 true, true, true, true, true, true, true, true, true, true,
890 true, true, true, true, true, true, true, true, true };
891 bool directions04[] = {
892 false, false, false, false, false, false, false, false, false, false,
893 false, false, false, false, false, false, false, false, false, false,
894 false, false, false, false, true, true, true, true, true, true,
895 true, true, true, false, true, true, true, true, true, true,
896 true, true, true, true, false, false, false, false, false, false,
897 false, false, false, false, false };
898 bool directions05[] = {
899 false, false, false, false, false, false, false, false, false, false,
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, false, false,
903 false, true, true, true, true, true, true, true, true, true,
904 true, true, true, true, true, true, true, true, true, true,
905 true, true, true, true, false, true, true, true, true, true,
906 true, true, true, true, true, true, true, true, true, true,
907 true, true, true, true, true, true, true, true, true, false,
908 false, false, false, false, true, true, true, true, true, true,
909 true, true, true, true, true, true, true, true, true, false,
910 false, false, false, false, true, true, true, true, true, true,
911 true, true, true, true, true, true, true, true, true, true,
912 true, true, true, true, true, true, true, true, true, false,
913 false, false, false, false, false, false, false, false, false, false,
914 false, false, false, false, false, false, false, false, false, false,
915 false, false, true, true, true, true, true, true, true, true,
916 true, true, true, true, true, true, false, false, false, false,
917 false, false, false, false, false, false, false, false, false, false,
918 false, false, true, true, true, true, true, true, true, true,
919 true, true, true, true, true, true, true, true, true, true,
920 true, true, true, true, true, true, true, true, true, true,
921 true, true, false, false, false, false, false };
923 struct GetCharactersDirectionData data[] =
933 "Left to right characters only",
934 "Hello world\nhello world demo",
940 "Right to left characters only",
941 "שלום עולם\nשלום עולם",
947 "Mix of bidirectional text",
948 "Hello world\nhello world שלום עולם\nשלום עולם hello world",
954 "Mix of bidirectional text. With more paragraphs.",
955 "Hello world demo\nhello world\nhello world مرحبا بالعالم שלום עולם\nשלום مرحبا بالعالم עולם hello مرحبا بالعالم world"
956 " مرحبا بالعالم שלום עולם hello world hello world\nبالعالم שלום hello world demo עולם\nשלום مرحبا بالعالم עולם hello",
962 "Mix of bidirectional text. With more paragraphs. Update first paragraph.",
963 "Hello world demo\nhello world\nhello world مرحبا بالعالم שלום עולם\nשלום مرحبا بالعالم עולם hello مرحبا بالعالم world"
964 " مرحبا بالعالم שלום עולם hello world hello world\nبالعالم שלום hello world demo עולם\nשלום مرحبا بالعالم עולם hello",
970 "Mix of bidirectional text. With more paragraphs. Update from character 29",
971 "Hello world demo\nhello world\nhello world مرحبا بالعالم שלום עולם\nשלום مرحبا بالعالم עולם hello مرحبا بالعالم world"
972 " مرحبا بالعالم שלום עולם hello world hello world\nبالعالم שלום hello world demo עולם\nשלום مرحبا بالعالم עולם hello",
978 "Mix of bidirectional text. With more paragraphs. Update from character 163",
979 "Hello world demo\nhello world\nhello world مرحبا بالعالم שלום עולם\nשלום مرحبا بالعالم עולם hello مرحبا بالعالم world"
980 " مرحبا بالعالم שלום עולם hello world hello world\nبالعالم שלום hello world demo עולם\nשלום مرحبا بالعالم עולם hello",
986 const unsigned int numberOfTests = 8u;
988 for( unsigned int index = 0u; index < numberOfTests; ++index )
990 if( !GetCharactersDirectionTest( data[index] ) )
992 tet_result(TET_FAIL);
996 tet_result(TET_PASS);