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-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.
111 bool SetBidirectionalInfoTest( const SetBidirectionalInfoData& data )
113 // 1) Create the model.
114 LogicalModelPtr logicalModel;
115 VisualModelPtr visualModel;
117 Size textArea(100.f, 60.f);
121 const Vector<FontDescriptionRun> fontDescriptions;
122 const LayoutOptions options;
123 CreateTextModel( data.text,
132 // 2) Clear the bidirectional paragraph info data.
133 Vector<BidirectionalParagraphInfoRun>& bidirectionalInfo = logicalModel->mBidirectionalParagraphInfo;
134 if( 0u != data.numberOfCharacters )
136 ClearCharacterRuns( data.startIndex,
137 data.startIndex + data.numberOfCharacters - 1u,
141 // 3) Call the SetBidirectionalInfo() function.
142 SetBidirectionalInfo( logicalModel->mText,
143 logicalModel->mScriptRuns,
144 logicalModel->mLineBreakInfo,
146 data.numberOfCharacters,
149 // 4) Compare with the expected results.
150 TextAbstraction::BidirectionalSupport bidirectionalSupport = TextAbstraction::BidirectionalSupport::Get();
152 if( data.numberOfParagraphs != bidirectionalInfo.Count() )
154 // Different number of expected bidirectional paragraphs.
155 std::cout << " Different number of bidi paragraphs : " << bidirectionalInfo.Count() << ", expected : " << data.numberOfParagraphs << std::endl;
159 for( unsigned int index = 0u; index < data.numberOfParagraphs; ++index )
161 const BidirectionalParagraphInfoRun& run = bidirectionalInfo[index];
163 const CharacterDirection direction = bidirectionalSupport.GetParagraphDirection( run.bidirectionalInfoIndex );
164 if( direction != data.directions[index] )
166 std::cout << " Different direction" << std::endl;
167 std::cout << " paragraph : " << index << std::endl;
168 std::cout << " index : " << run.characterRun.characterIndex << ", num chars : " << run.characterRun.numberOfCharacters << ", direction : " << direction << std::endl;
169 std::cout << " expected, index : " << data.indices[index] << ", num chars : " << data.numberOfParagraphCharacters[index] << ", direction : " << data.directions[index] << std::endl;
173 if( run.characterRun.characterIndex != data.indices[index] )
175 std::cout << " Different index" << 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;
181 if( run.characterRun.numberOfCharacters != data.numberOfParagraphCharacters[index] )
183 std::cout << " Different number of characters" << std::endl;
184 std::cout << " paragraph : " << index << std::endl;
185 std::cout << " index : " << run.characterRun.characterIndex << ", num chars : " << run.characterRun.numberOfCharacters << ", direction : " << direction << std::endl;
186 std::cout << " expected, index : " << data.indices[index] << ", num chars : " << data.numberOfParagraphCharacters[index] << ", direction : " << data.directions[index] << std::endl;
195 * @brief Frees previously allocated bidirectional resources.
197 * @param[in] bidirectionalLineInfo Bidirectional info per line.
198 * @param[in] startIndex Index to the first line with bidirectional info to be freed.
199 * @param[in] endIndex Index to the last line with bidirectional info to be freed.
201 void FreeBidirectionalLineInfoResources( Vector<BidirectionalLineInfoRun> bidirectionalLineInfo,
205 // Free the allocated memory used to store the conversion table in the bidirectional line info run.
206 for( Vector<BidirectionalLineInfoRun>::Iterator it = bidirectionalLineInfo.Begin() + startIndex,
207 endIt = bidirectionalLineInfo.Begin() + endIndex;
211 BidirectionalLineInfoRun& bidiLineInfo = *it;
213 free( bidiLineInfo.visualToLogicalMap );
217 bool ReorderLinesTest( const ReorderLinesData& data )
219 // 1) Create the model.
220 LogicalModelPtr logicalModel;
221 VisualModelPtr visualModel;
223 Size textArea(100.f, 300.f);
227 const Vector<FontDescriptionRun> fontDescriptions;
228 const LayoutOptions options;
229 CreateTextModel( data.text,
238 // 2) Clear the bidirectional line info data.
239 uint32_t startRemoveIndex = logicalModel->mBidirectionalLineInfo.Count();
240 uint32_t endRemoveIndex = startRemoveIndex;
241 ClearCharacterRuns( data.startIndex,
242 data.startIndex + data.numberOfCharacters - 1u,
243 logicalModel->mBidirectionalLineInfo,
247 // Index to the first index to be removed.
249 FreeBidirectionalLineInfoResources( logicalModel->mBidirectionalLineInfo, startRemoveIndex, endRemoveIndex );
250 BidirectionalLineInfoRun* bidiLineBuffer = logicalModel->mBidirectionalLineInfo.Begin();
251 logicalModel->mBidirectionalLineInfo.Erase( bidiLineBuffer + startRemoveIndex,
252 bidiLineBuffer + endRemoveIndex );
254 // 3) Call the function ReorderLines()
256 ReorderLines( logicalModel->mBidirectionalParagraphInfo,
258 data.numberOfCharacters,
260 logicalModel->mBidirectionalLineInfo );
262 // 4) Compare the results.
264 if( data.numberOfLineInfo != logicalModel->mBidirectionalLineInfo.Count() )
266 // Different number of bidirectional lines.
267 std::cout << " different number of bidi lines : " << logicalModel->mBidirectionalLineInfo.Count() << ", expected : " << data.numberOfLineInfo << std::endl;
268 for( unsigned int index = 0u; index < logicalModel->mBidirectionalLineInfo.Count(); ++index )
270 const BidirectionalLineInfoRun& run = logicalModel->mBidirectionalLineInfo[index];
271 const BidiLineData& bidiLineData = data.bidiLineData[index];
273 std::cout << " bidi line : " << index << ", index : " << run.characterRun.characterIndex << ", num chars : " << run.characterRun.numberOfCharacters << std::endl;
274 std::cout << " expected index : " << bidiLineData.characterIndex << ", num chars : " << bidiLineData.numberOfCharacters << std::endl;
279 for( unsigned int index = 0u; index < data.numberOfLineInfo; ++index )
281 const BidirectionalLineInfoRun& run = logicalModel->mBidirectionalLineInfo[index];
282 const BidiLineData& bidiLineData = data.bidiLineData[index];
284 if( bidiLineData.characterIndex != run.characterRun.characterIndex )
286 std::cout << " bidi line : " << index << ", index : " << run.characterRun.characterIndex << ", num chars : " << run.characterRun.numberOfCharacters << std::endl;
287 std::cout << " expected index : " << bidiLineData.characterIndex << ", num chars : " << bidiLineData.numberOfCharacters << std::endl;
290 if( bidiLineData.numberOfCharacters != run.characterRun.numberOfCharacters )
292 std::cout << " bidi line : " << index << ", index : " << run.characterRun.characterIndex << ", num chars : " << run.characterRun.numberOfCharacters << std::endl;
293 std::cout << " expected index : " << bidiLineData.characterIndex << ", num chars : " << bidiLineData.numberOfCharacters << std::endl;
297 for( unsigned int i = 0u; i < run.characterRun.numberOfCharacters; ++i )
299 if( bidiLineData.visualToLogical[i] != run.visualToLogicalMap[i] )
301 std::cout << " v2l : ";
302 for( unsigned int i = 0u; i < run.characterRun.numberOfCharacters; ++i )
304 std::cout << run.visualToLogicalMap[i] << " ";
306 std::cout << std::endl;
307 std::cout << " expected v2l : ";
308 for( unsigned int i = 0u; i < run.characterRun.numberOfCharacters; ++i )
310 std::cout << bidiLineData.visualToLogical[i] << " ";
312 std::cout << std::endl;
319 if( data.numberOfLines != visualModel->mLines.Count() )
321 std::cout << "Different number of lines : " << visualModel->mLines.Count() << ", expected : " << data.numberOfLines << std::endl;
323 unsigned int index = 0u;
324 for( Vector<LineRun>::ConstIterator it = visualModel->mLines.Begin(),
325 endIt = visualModel->mLines.End();
329 const LineRun& line = *it;
331 if( line.direction != *( data.lineDirections + index ) )
333 std::cout << " Different line direction : " << line.direction << ", expected : " << *( data.lineDirections + index ) << std::endl;
342 bool GetMirroredTextTest( const GetMirroredTextData& data )
344 // 1) Create the model.
345 LogicalModelPtr logicalModel;
346 VisualModelPtr visualModel;
348 Size textArea(100.f, 60.f);
352 const Vector<FontDescriptionRun> fontDescriptions;
353 const LayoutOptions options;
354 CreateTextModel( data.text,
363 // 2) Call the GetMirroredText() function for the whole text
364 Vector<Character> mirroredText;
365 bool mirrored = false;
366 mirrored = GetMirroredText( logicalModel->mText,
367 logicalModel->mCharacterDirections,
368 logicalModel->mBidirectionalParagraphInfo,
370 logicalModel->mText.Count(),
373 // 3) Call the GetMirroredText() function for the given index + number of characters
374 mirrored = GetMirroredText( logicalModel->mText,
375 logicalModel->mCharacterDirections,
376 logicalModel->mBidirectionalParagraphInfo,
378 data.numberOfCharacters,
381 // 4) Compare the results.
384 std::string mirroredString;
385 Utf32ToUtf8( mirroredText.Begin(),
386 mirroredText.Count(),
389 if( !mirrored && ( mirroredString != data.text ) )
391 std::cout << " No mirrored text and mirroredString != data.text." << std::endl;
392 std::cout << " mirrored string : [" << mirroredString << "]" << std::endl;
393 std::cout << " text : [" << data.text << "]" << std::endl;
397 if( mirrored && ( mirroredString == data.text ) )
399 std::cout << " Mirrored text and mirroredString == data.text." << std::endl;
400 std::cout << " mirrored string : [" << mirroredString << "]" << std::endl;
401 std::cout << " text : [" << data.text << "]" << std::endl;
405 if( mirrored && ( mirroredString != data.mirroredText ) )
407 std::cout << " Mirrored text and mirroredString != data.mirroredText." << std::endl;
408 std::cout << " mirrored string : [" << mirroredString << "]" << std::endl;
409 std::cout << " text : [" << data.mirroredText << "]" << std::endl;
416 bool GetCharactersDirectionTest( const GetCharactersDirectionData& data )
418 // 1) Create the model.
419 LogicalModelPtr logicalModel;
420 VisualModelPtr visualModel;
422 Size textArea(100.f, 60.f);
426 const Vector<FontDescriptionRun> fontDescriptions;
427 const LayoutOptions options;
428 CreateTextModel( data.text,
437 Vector<BidirectionalParagraphInfoRun>& bidirectionalInfo = logicalModel->mBidirectionalParagraphInfo;
439 // 2) Clear the direction info data.
440 Vector<CharacterDirection>& directions = logicalModel->mCharacterDirections;
442 directions.Erase( directions.Begin() + data.startIndex,
443 directions.Begin() + data.startIndex + data.numberOfCharacters );
445 // 3) Call GetCharactersDirection() function.
447 GetCharactersDirection( bidirectionalInfo,
448 logicalModel->mText.Count(),
450 data.numberOfCharacters,
453 for( unsigned int index = 0u; index < logicalModel->mText.Count(); ++index )
455 if( data.directions[index] != directions[index] )
466 //////////////////////////////////////////////////////////
468 int UtcDaliSetBidirectionalInfo(void)
470 tet_infoline(" UtcDaliSetBidirectionalInfo");
472 unsigned int indices01[] = {};
473 unsigned int numberOfCharacters01[] = {};
474 bool direction01[] = {};
475 unsigned int indices02[] = {};
476 unsigned int numberOfCharacters02[] = {};
477 bool direction02[] = {};
478 unsigned int indices03[] = { 17u, 48u };
479 unsigned int numberOfCharacters03[] = { 14u, 14u };
480 bool direction03[] = { true, true };
481 unsigned int indices04[] = { 17u, 31u, 79u };
482 unsigned int numberOfCharacters04[] = { 14u, 48u, 31u };
483 bool direction04[] = { true, false, true };
484 unsigned int indices05[] = { 17u, 41u, 117u };
485 unsigned int numberOfCharacters05[] = { 24u, 76u, 49u };
486 bool direction05[] = { true, false, true };
487 unsigned int indices06[] = { 17u, 48u };
488 unsigned int numberOfCharacters06[] = { 14u, 14u };
489 bool direction06[] = { true, true };
490 unsigned int indices07[] = { 17u, 31u, 79u };
491 unsigned int numberOfCharacters07[] = { 14u, 48u, 31u };
492 bool direction07[] = { true, false, true };
493 unsigned int indices08[] = { 17u, 41u, 117u };
494 unsigned int numberOfCharacters08[] = { 24u, 76u, 49u };
495 bool direction08[] = { true, false, true };
497 struct SetBidirectionalInfoData data[] =
506 numberOfCharacters01,
510 "Some left to right paragraphs",
511 "Hello world\ndemo\n\n",
516 numberOfCharacters02,
520 "A mix of left to right and right to left paragraphs.",
521 "Hello world demo\nمرحبا بالعالم\nhello world demo\nمرحبا بالعالم\nhello world demo",
526 numberOfCharacters03,
530 "A mix of left to right and right to left paragraphs. Paragraphs also contain a mix of bidirectional text.",
531 "Hello world demo\nمرحبا بالعالم\nhello world demo مرحبا بالعالم hello world demo\nمرحبا hello world demo بالعالم\nhello world demo",
536 numberOfCharacters04,
540 "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.",
541 "Hello world demo\nمرحبا שלום עולם بالعالم\nhello world שלום بالعالم עולם demo مرحبا שלום עולם بالعالم hello world demo\nمرحبا hello שלום بالعالم עולם world demo بالعالم\nhello world demo",
546 numberOfCharacters05,
550 "A mix of left to right and right to left paragraphs. Updates a left to right paragraph.",
551 "Hello world demo\nمرحبا بالعالم\nhello world demo\nمرحبا بالعالم\nhello world demo",
556 numberOfCharacters06,
560 "A mix of left to right and right to left paragraphs. Paragraphs also contain a mix of bidirectional text.",
561 "Hello world demo\nمرحبا بالعالم\nhello world demo مرحبا بالعالم hello world demo\nمرحبا hello world demo بالعالم\nhello world demo",
566 numberOfCharacters07,
570 "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.",
571 "Hello world demo\nمرحبا שלום עולם بالعالم\nhello world שלום بالعالم עולם demo مرحبا שלום עולם بالعالم hello world demo\nمرحبا hello שלום بالعالم עולם world demo بالعالم\nhello world demo",
576 numberOfCharacters08,
580 "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.",
581 "Hello world demo\nمرحبا שלום עולם بالعالم\nhello world שלום بالعالم עולם demo مرحبا שלום עולם بالعالم hello world demo\nمرحبا hello שלום بالعالم עולם world demo بالعالم\nhello world demo",
586 numberOfCharacters08,
590 "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",
591 "Hello world demo\nمرحبا שלום עולם بالعالم\nhello world שלום بالعالم עולם demo مرحبا שלום עולם بالعالم hello world demo\nمرحبا hello שלום بالعالم עולם world demo بالعالم\nhello world demo",
596 numberOfCharacters08,
600 const unsigned int numberOfTests = 10u;
602 for( unsigned int index = 0u; index < numberOfTests; ++index )
604 ToolkitTestApplication application;
605 if( !SetBidirectionalInfoTest( data[index] ) )
607 tet_result(TET_FAIL);
611 tet_result(TET_PASS);
615 int UtcDaliReorderLines(void)
617 tet_infoline(" UtcDaliSetBidirectionalInfo");
619 unsigned int visualToLogical0301[] = { 0u, 1u, 2u, 3u, 4u, 5u, 9u, 8u, 7u, 6u, 10u };
620 unsigned int visualToLogical0302[] = { 3u, 2u, 1u, 0u, 4u, 5u, 6u, 7u, 8u, 9u, 10u };
621 unsigned int visualToLogical0303[] = { 0u, 1u, 2u, 3u, 4u };
622 unsigned int visualToLogical0304[] = { 12u, 11u, 10u, 9u, 8u, 7u, 6u, 5u, 4u, 3u, 2u, 1u, 0u };
623 unsigned int visualToLogical0305[] = { 10u, 9u, 8u, 7u, 6u, 5u, 4u, 3u, 2u, 1u, 0u };
624 unsigned int visualToLogical0306[] = { 9u, 8u, 7u, 6u, 5u, 4u, 3u, 2u, 1u, 0u };
625 unsigned int visualToLogical0307[] = { 13u, 8u, 9u, 10u, 11u, 12u, 7u, 6u, 5u, 4u, 3u, 2u, 1u, 0u };
626 unsigned int visualToLogical0308[] = { 5u, 0u, 1u, 2u, 3u, 4u };
627 unsigned int visualToLogical0309[] = { 0u, 1u, 2u, 3u, 4u, 5u, 9u, 8u, 7u, 6u, 10u };
628 unsigned int visualToLogical0310[] = { 3u, 2u, 1u, 0u, 4u, 5u, 6u, 7u, 8u, 9u, 10u };
629 unsigned int visualToLogical0311[] = { 0u, 1u, 2u, 3u, 4u };
630 unsigned int visualToLogical0312[] = { 12u, 11u, 10u, 9u, 8u, 7u, 6u, 5u, 4u, 3u, 2u, 1u, 0u };
631 unsigned int visualToLogical0313[] = { 10u, 9u, 8u, 7u, 6u, 5u, 4u, 3u, 2u, 1u, 0u };
632 unsigned int visualToLogical0314[] = { 9u, 8u, 7u, 6u, 5u, 4u, 3u, 2u, 1u, 0u };
633 unsigned int visualToLogical0315[] = { 13u, 8u, 9u, 10u, 11u, 12u, 7u, 6u, 5u, 4u, 3u, 2u, 1u, 0u };
634 unsigned int visualToLogical0316[] = { 0u, 1u, 2u, 3u, 4u };
636 BidiLineData bidiLine01[] = {};
637 BidiLineData bidiLine02[] = {};
638 BidiLineData bidiLine03[] = {
721 bool directions02[] = { false, false, false, false, false, false };
722 bool directions03[] = { false, false, false, false, false, true, true, true, true, true, false, false, false, false, false, true, true, true, true, true };
724 struct ReorderLinesData data[] =
737 "Left to right text only.",
738 "Hello world demo\nhello world demo\nhello world demo.",
747 "Bidirectional paragraphs.",
748 "Hello world demo\nhello שלום עולם world demo\nשלום بالعالم עולם مرحبا שלום עולם بالعالم hello world\nHello world demo\nhello שלום עולם world demo\nשלום بالعالم עולם مرحبا שלום עולם بالعالم hello world",
757 "Bidirectional paragraphs. Update initial paragraphs.",
758 "Hello world demo\nhello שלום עולם world demo\nשלום بالعالم עולם مرحبا שלום עולם بالعالم hello world\nHello world demo\nhello שלום עולם world demo\nשלום بالعالم עולם مرحبا שלום עולם بالعالم hello world",
767 "Bidirectional paragraphs. Update middle paragraphs.",
768 "Hello world demo\nhello שלום עולם world demo\nשלום بالعالم עולם مرحبا שלום עולם بالعالم hello world\nHello world demo\nhello שלום עולם world demo\nשלום بالعالم עולם مرحبا שלום עולם بالعالم hello world",
777 "Bidirectional paragraphs. Update final paragraphs.",
778 "Hello world demo\nhello שלום עולם world demo\nשלום بالعالم עולם مرحبا שלום עולם بالعالم hello world\nHello world demo\nhello שלום עולם world demo\nשלום بالعالم עולם مرحبا שלום עולם بالعالم hello world",
787 const unsigned int numberOfTests = 6u;
789 for( unsigned int index = 0u; index < numberOfTests; ++index )
791 ToolkitTestApplication application;
792 if( !ReorderLinesTest( data[index] ) )
794 tet_result(TET_FAIL);
798 tet_result(TET_PASS);
802 int UtcDaliGetMirroredText(void)
804 tet_infoline(" UtcDaliGetMirroredText");
806 struct GetMirroredTextData data[] =
816 "Left to right characters only.",
817 "Hello world\nhello world demo.",
820 "Hello world\nhello world demo."
823 "Right to left characters but with no characters to mirror.",
824 "שלום עולם\nمرحبا بالعالم",
827 "שלום עולם\nمرحبا بالعالم"
830 "Right to left characters with some characters to mirror.",
831 "שלום עולם\n(مرحبا بالعالم)",
834 "שלום עולם\n)مرحبا بالعالم("
837 "Right to left characters with some characters to mirror. Update last paragraph.",
838 "שלום עולם\n(مرحبا بالعالم)",
841 "שלום עולם\n)مرحبا بالعالم("
844 "Mix of bidirectional text. With more paragraphs.",
845 "Hello world demo\nhello world\nhello world (مرحبا بالعالم שלום) עולם\nשלום مرحبا بالعالم עולם (hello) مرحبا بالعالم world"
846 " مرحبا بالعالم שלום עולם hello world hello world\nبالعالم שלום (hello) world demo (עולם)\nשלום (مرحبا بالعالم עולם) (hello)",
849 "Hello world demo\nhello world\nhello world (مرحبا بالعالم שלום( עולם\nשלום مرحبا بالعالم עולם )hello( مرحبا بالعالم world"
850 " مرحبا بالعالم שלום עולם hello world hello world\nبالعالم שלום )hello) world demo )עולם(\nשלום )مرحبا بالعالم עולם( )hello("
853 "Mix of bidirectional text. With more paragraphs. Update middle paragraphs.",
854 "Hello world demo\nhello world\nhello world (مرحبا بالعالم שלום) עולם\nשלום مرحبا بالعالم עולם (hello) مرحبا بالعالم world"
855 " مرحبا بالعالم שלום עולם hello world hello world\nبالعالم שלום (hello) world demo (עולם)\nשלום (مرحبا بالعالم עולם) (hello)",
858 "Hello world demo\nhello world\nhello world (مرحبا بالعالم שלום( עולם\nשלום مرحبا بالعالم עולם (hello) مرحبا بالعالم world"
859 " مرحبا بالعالم שלום עולם hello world hello world\nبالعالم שלום (hello) world demo (עולם)\nשלום (مرحبا بالعالم עולם) (hello)"
862 "Mix of bidirectional text. With more paragraphs. Update middle paragraphs (2).",
863 "Hello world demo\nhello world\nhello world (مرحبا بالعالم שלום) עולם\nשלום مرحبا بالعالم עולם (hello) مرحبا بالعالم world"
864 " مرحبا بالعالم שלום עולם hello world hello world\nبالعالم שלום (hello) world demo (עולם)\nשלום (مرحبا بالعالم עולם) (hello)",
867 "Hello world demo\nhello world\nhello world (مرحبا بالعالم שלום) עולם\nשלום مرحبا بالعالم עולם )hello( مرحبا بالعالم world"
868 " مرحبا بالعالم שלום עולם hello world hello world\nبالعالم שלום (hello) world demo (עולם)\nשלום (مرحبا بالعالم עולם) (hello)"
871 const unsigned int numberOfTests = 8u;
873 for( unsigned int index = 0u; index < numberOfTests; ++index )
875 ToolkitTestApplication application;
876 if( !GetMirroredTextTest( data[index] ) )
878 tet_result(TET_FAIL);
882 tet_result(TET_PASS);
886 int UtcDaliGetCharactersDirection(void)
888 tet_infoline(" UtcDaliGetCharactersDirection");
890 bool directions01[] = {};
891 bool directions02[] = {
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, false, false, false, false };
895 bool directions03[] = {
896 true, true, true, true, true, true, true, true, true, true,
897 true, true, true, true, true, true, true, true, true };
898 bool directions04[] = {
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, true, true, true, true, true, true,
902 true, true, true, false, true, true, true, true, true, true,
903 true, true, true, true, false, false, false, false, false, false,
904 false, false, false, false, false };
905 bool directions05[] = {
906 false, false, false, false, false, false, false, false, false, false,
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, false, false, false, false, false, false,
910 false, true, true, true, true, true, true, true, true, true,
911 true, true, true, true, true, true, true, true, true, true,
912 true, true, true, true, false, true, true, true, true, true,
913 true, true, true, true, true, true, true, true, true, true,
914 true, true, true, true, true, true, true, true, true, false,
915 false, false, false, false, true, true, true, true, true, true,
916 true, true, true, true, true, true, true, true, true, false,
917 false, false, false, false, true, true, true, true, true, true,
918 true, true, true, true, true, true, true, true, true, true,
919 true, true, true, true, true, true, true, true, true, 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, false, true, true, true, true, true, true, true, true,
923 true, true, true, true, true, true, false, false, false, false,
924 false, false, false, false, false, false, false, false, false, false,
925 false, false, true, true, 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, true,
928 true, true, false, false, false, false, false };
930 struct GetCharactersDirectionData data[] =
940 "Left to right characters only",
941 "Hello world\nhello world demo",
947 "Right to left characters only",
948 "שלום עולם\nשלום עולם",
954 "Mix of bidirectional text",
955 "Hello world\nhello world שלום עולם\nשלום עולם hello world",
961 "Mix of bidirectional text. With more paragraphs.",
962 "Hello world demo\nhello world\nhello world مرحبا بالعالم שלום עולם\nשלום مرحبا بالعالم עולם hello مرحبا بالعالم world"
963 " مرحبا بالعالم שלום עולם hello world hello world\nبالعالم שלום hello world demo עולם\nשלום مرحبا بالعالم עולם hello",
969 "Mix of bidirectional text. With more paragraphs. Update first paragraph.",
970 "Hello world demo\nhello world\nhello world مرحبا بالعالم שלום עולם\nשלום مرحبا بالعالم עולם hello مرحبا بالعالم world"
971 " مرحبا بالعالم שלום עולם hello world hello world\nبالعالم שלום hello world demo עולם\nשלום مرحبا بالعالم עולם hello",
977 "Mix of bidirectional text. With more paragraphs. Update from character 29",
978 "Hello world demo\nhello world\nhello world مرحبا بالعالم שלום עולם\nשלום مرحبا بالعالم עולם hello مرحبا بالعالم world"
979 " مرحبا بالعالم שלום עולם hello world hello world\nبالعالم שלום hello world demo עולם\nשלום مرحبا بالعالم עולם hello",
985 "Mix of bidirectional text. With more paragraphs. Update from character 163",
986 "Hello world demo\nhello world\nhello world مرحبا بالعالم שלום עולם\nשלום مرحبا بالعالم עולם hello مرحبا بالعالم world"
987 " مرحبا بالعالم שלום עולם hello world hello world\nبالعالم שלום hello world demo עולם\nשלום مرحبا بالعالم עולם hello",
993 const unsigned int numberOfTests = 8u;
995 for( unsigned int index = 0u; index < numberOfTests; ++index )
997 ToolkitTestApplication application;
998 if( !GetCharactersDirectionTest( data[index] ) )
1000 tet_result(TET_FAIL);
1004 tet_result(TET_PASS);