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.
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 if( directions.Count() >= data.startIndex + data.numberOfCharacters )
444 directions.Erase( directions.Begin() + data.startIndex,
445 directions.Begin() + data.startIndex + data.numberOfCharacters );
448 // 3) Call GetCharactersDirection() function.
450 GetCharactersDirection( bidirectionalInfo,
451 logicalModel->mText.Count(),
453 data.numberOfCharacters,
456 for( unsigned int index = 0u; index < logicalModel->mText.Count(); ++index )
458 if( data.directions[index] != directions[index] )
469 //////////////////////////////////////////////////////////
471 int UtcDaliSetBidirectionalInfo(void)
473 tet_infoline(" UtcDaliSetBidirectionalInfo");
475 unsigned int indices01[] = {};
476 unsigned int numberOfCharacters01[] = {};
477 bool direction01[] = {};
478 unsigned int indices02[] = {};
479 unsigned int numberOfCharacters02[] = {};
480 bool direction02[] = {};
481 unsigned int indices03[] = { 17u, 48u };
482 unsigned int numberOfCharacters03[] = { 14u, 14u };
483 bool direction03[] = { true, true };
484 unsigned int indices04[] = { 17u, 31u, 79u };
485 unsigned int numberOfCharacters04[] = { 14u, 48u, 31u };
486 bool direction04[] = { true, false, true };
487 unsigned int indices05[] = { 17u, 41u, 117u };
488 unsigned int numberOfCharacters05[] = { 24u, 76u, 49u };
489 bool direction05[] = { true, false, true };
490 unsigned int indices06[] = { 17u, 48u };
491 unsigned int numberOfCharacters06[] = { 14u, 14u };
492 bool direction06[] = { true, true };
493 unsigned int indices07[] = { 17u, 31u, 79u };
494 unsigned int numberOfCharacters07[] = { 14u, 48u, 31u };
495 bool direction07[] = { true, false, true };
496 unsigned int indices08[] = { 17u, 41u, 117u };
497 unsigned int numberOfCharacters08[] = { 24u, 76u, 49u };
498 bool direction08[] = { true, false, true };
500 struct SetBidirectionalInfoData data[] =
509 numberOfCharacters01,
513 "Some left to right paragraphs",
514 "Hello world\ndemo\n\n",
519 numberOfCharacters02,
523 "A mix of left to right and right to left paragraphs.",
524 "Hello world demo\nمرحبا بالعالم\nhello world demo\nمرحبا بالعالم\nhello world demo",
529 numberOfCharacters03,
533 "A mix of left to right and right to left paragraphs. Paragraphs also contain a mix of bidirectional text.",
534 "Hello world demo\nمرحبا بالعالم\nhello world demo مرحبا بالعالم hello world demo\nمرحبا hello world demo بالعالم\nhello world demo",
539 numberOfCharacters04,
543 "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.",
544 "Hello world demo\nمرحبا שלום עולם بالعالم\nhello world שלום بالعالم עולם demo مرحبا שלום עולם بالعالم hello world demo\nمرحبا hello שלום بالعالم עולם world demo بالعالم\nhello world demo",
549 numberOfCharacters05,
553 "A mix of left to right and right to left paragraphs. Updates a left to right paragraph.",
554 "Hello world demo\nمرحبا بالعالم\nhello world demo\nمرحبا بالعالم\nhello world demo",
559 numberOfCharacters06,
563 "A mix of left to right and right to left paragraphs. Paragraphs also contain a mix of bidirectional text.",
564 "Hello world demo\nمرحبا بالعالم\nhello world demo مرحبا بالعالم hello world demo\nمرحبا hello world demo بالعالم\nhello world demo",
569 numberOfCharacters07,
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 initial 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 mid paragraphs.",
584 "Hello world demo\nمرحبا שלום עולם بالعالم\nhello world שלום بالعالم עולם demo مرحبا שלום עולם بالعالم hello world demo\nمرحبا hello שלום بالعالم עולם world demo بالعالم\nhello world demo",
589 numberOfCharacters08,
593 "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",
594 "Hello world demo\nمرحبا שלום עולם بالعالم\nhello world שלום بالعالم עולם demo مرحبا שלום עולם بالعالم hello world demo\nمرحبا hello שלום بالعالم עולם world demo بالعالم\nhello world demo",
599 numberOfCharacters08,
603 const unsigned int numberOfTests = 10u;
605 for( unsigned int index = 0u; index < numberOfTests; ++index )
607 ToolkitTestApplication application;
608 if( !SetBidirectionalInfoTest( data[index] ) )
610 tet_result(TET_FAIL);
614 tet_result(TET_PASS);
618 int UtcDaliReorderLines(void)
620 tet_infoline(" UtcDaliSetBidirectionalInfo");
622 unsigned int visualToLogical0301[] = { 0u, 1u, 2u, 3u, 4u, 5u, 9u, 8u, 7u, 6u, 10u };
623 unsigned int visualToLogical0302[] = { 3u, 2u, 1u, 0u, 4u, 5u, 6u, 7u, 8u, 9u, 10u };
624 unsigned int visualToLogical0303[] = { 0u, 1u, 2u, 3u, 4u };
625 unsigned int visualToLogical0304[] = { 12u, 11u, 10u, 9u, 8u, 7u, 6u, 5u, 4u, 3u, 2u, 1u, 0u };
626 unsigned int visualToLogical0305[] = { 10u, 9u, 8u, 7u, 6u, 5u, 4u, 3u, 2u, 1u, 0u };
627 unsigned int visualToLogical0306[] = { 9u, 8u, 7u, 6u, 5u, 4u, 3u, 2u, 1u, 0u };
628 unsigned int visualToLogical0307[] = { 13u, 8u, 9u, 10u, 11u, 12u, 7u, 6u, 5u, 4u, 3u, 2u, 1u, 0u };
629 unsigned int visualToLogical0308[] = { 5u, 0u, 1u, 2u, 3u, 4u };
630 unsigned int visualToLogical0309[] = { 0u, 1u, 2u, 3u, 4u, 5u, 9u, 8u, 7u, 6u, 10u };
631 unsigned int visualToLogical0310[] = { 3u, 2u, 1u, 0u, 4u, 5u, 6u, 7u, 8u, 9u, 10u };
632 unsigned int visualToLogical0311[] = { 0u, 1u, 2u, 3u, 4u };
633 unsigned int visualToLogical0312[] = { 12u, 11u, 10u, 9u, 8u, 7u, 6u, 5u, 4u, 3u, 2u, 1u, 0u };
634 unsigned int visualToLogical0313[] = { 10u, 9u, 8u, 7u, 6u, 5u, 4u, 3u, 2u, 1u, 0u };
635 unsigned int visualToLogical0314[] = { 9u, 8u, 7u, 6u, 5u, 4u, 3u, 2u, 1u, 0u };
636 unsigned int visualToLogical0315[] = { 13u, 8u, 9u, 10u, 11u, 12u, 7u, 6u, 5u, 4u, 3u, 2u, 1u, 0u };
637 unsigned int visualToLogical0316[] = { 0u, 1u, 2u, 3u, 4u };
639 BidiLineData bidiLine01[] = {};
640 BidiLineData bidiLine02[] = {};
641 BidiLineData bidiLine03[] = {
724 bool directions02[] = { false, false, false, false, false, false };
725 bool directions03[] = { false, false, false, false, false, true, true, true, true, true, false, false, false, false, false, true, true, true, true, true };
727 struct ReorderLinesData data[] =
740 "Left to right text only.",
741 "Hello world demo\nhello world demo\nhello world demo.",
750 "Bidirectional paragraphs.",
751 "Hello world demo\nhello שלום עולם world demo\nשלום بالعالم עולם مرحبا שלום עולם بالعالم hello world\nHello world demo\nhello שלום עולם world demo\nשלום بالعالم עולם مرحبا שלום עולם بالعالم hello world",
760 "Bidirectional paragraphs. Update initial paragraphs.",
761 "Hello world demo\nhello שלום עולם world demo\nשלום بالعالم עולם مرحبا שלום עולם بالعالم hello world\nHello world demo\nhello שלום עולם world demo\nשלום بالعالم עולם مرحبا שלום עולם بالعالم hello world",
770 "Bidirectional paragraphs. Update middle paragraphs.",
771 "Hello world demo\nhello שלום עולם world demo\nשלום بالعالم עולם مرحبا שלום עולם بالعالم hello world\nHello world demo\nhello שלום עולם world demo\nשלום بالعالم עולם مرحبا שלום עולם بالعالم hello world",
780 "Bidirectional paragraphs. Update final paragraphs.",
781 "Hello world demo\nhello שלום עולם world demo\nשלום بالعالم עולם مرحبا שלום עולם بالعالم hello world\nHello world demo\nhello שלום עולם world demo\nשלום بالعالم עולם مرحبا שלום עולם بالعالم hello world",
790 const unsigned int numberOfTests = 6u;
792 for( unsigned int index = 0u; index < numberOfTests; ++index )
794 ToolkitTestApplication application;
795 if( !ReorderLinesTest( data[index] ) )
797 tet_result(TET_FAIL);
801 tet_result(TET_PASS);
805 int UtcDaliGetMirroredText(void)
807 tet_infoline(" UtcDaliGetMirroredText");
809 struct GetMirroredTextData data[] =
819 "Left to right characters only.",
820 "Hello world\nhello world demo.",
823 "Hello world\nhello world demo."
826 "Right to left characters but with no characters to mirror.",
827 "שלום עולם\nمرحبا بالعالم",
830 "שלום עולם\nمرحبا بالعالم"
833 "Right to left characters with some characters to mirror.",
834 "שלום עולם\n(مرحبا بالعالم)",
837 "שלום עולם\n)مرحبا بالعالم("
840 "Right to left characters with some characters to mirror. Update last paragraph.",
841 "שלום עולם\n(مرحبا بالعالم)",
844 "שלום עולם\n)مرحبا بالعالم("
847 "Mix of bidirectional text. With more paragraphs.",
848 "Hello world demo\nhello world\nhello world (مرحبا بالعالم שלום) עולם\nשלום مرحبا بالعالم עולם (hello) مرحبا بالعالم world"
849 " مرحبا بالعالم שלום עולם hello world hello world\nبالعالم שלום (hello) world demo (עולם)\nשלום (مرحبا بالعالم עולם) (hello)",
852 "Hello world demo\nhello world\nhello world (مرحبا بالعالم שלום( עולם\nשלום مرحبا بالعالم עולם )hello( مرحبا بالعالم world"
853 " مرحبا بالعالم שלום עולם hello world hello world\nبالعالم שלום )hello) world demo )עולם(\nשלום )مرحبا بالعالم עולם( )hello("
856 "Mix of bidirectional text. With more paragraphs. Update middle paragraphs.",
857 "Hello world demo\nhello world\nhello world (مرحبا بالعالم שלום) עולם\nשלום مرحبا بالعالم עולם (hello) مرحبا بالعالم world"
858 " مرحبا بالعالم שלום עולם hello world hello world\nبالعالم שלום (hello) world demo (עולם)\nשלום (مرحبا بالعالم עולם) (hello)",
861 "Hello world demo\nhello world\nhello world (مرحبا بالعالم שלום( עולם\nשלום مرحبا بالعالم עולם (hello) مرحبا بالعالم world"
862 " مرحبا بالعالم שלום עולם hello world hello world\nبالعالم שלום (hello) world demo (עולם)\nשלום (مرحبا بالعالم עולם) (hello)"
865 "Mix of bidirectional text. With more paragraphs. Update middle paragraphs (2).",
866 "Hello world demo\nhello world\nhello world (مرحبا بالعالم שלום) עולם\nשלום مرحبا بالعالم עולם (hello) مرحبا بالعالم world"
867 " مرحبا بالعالم שלום עולם hello world hello world\nبالعالم שלום (hello) world demo (עולם)\nשלום (مرحبا بالعالم עולם) (hello)",
870 "Hello world demo\nhello world\nhello world (مرحبا بالعالم שלום) עולם\nשלום مرحبا بالعالم עולם )hello( مرحبا بالعالم world"
871 " مرحبا بالعالم שלום עולם hello world hello world\nبالعالم שלום (hello) world demo (עולם)\nשלום (مرحبا بالعالم עולם) (hello)"
874 const unsigned int numberOfTests = 8u;
876 for( unsigned int index = 0u; index < numberOfTests; ++index )
878 ToolkitTestApplication application;
879 if( !GetMirroredTextTest( data[index] ) )
881 tet_result(TET_FAIL);
885 tet_result(TET_PASS);
889 int UtcDaliGetCharactersDirection(void)
891 tet_infoline(" UtcDaliGetCharactersDirection");
893 bool directions01[] = {};
894 bool directions02[] = {
895 false, false, false, false, false, false, false, false, false, false,
896 false, false, false, false, false, false, false, false, false, false,
897 false, false, false, false, false, false, false, false };
898 bool directions03[] = {
899 true, true, true, true, true, true, true, true, true, true,
900 true, true, true, true, true, true, true, true, true };
901 bool directions04[] = {
902 false, false, false, false, false, false, false, false, false, false,
903 false, false, false, false, false, false, false, false, false, false,
904 false, false, false, false, true, true, true, true, true, true,
905 true, true, true, false, true, true, true, true, true, true,
906 true, true, true, true, false, false, false, false, false, false,
907 false, false, false, false, false };
908 bool directions05[] = {
909 false, false, false, false, false, false, false, false, false, false,
910 false, false, false, false, false, false, false, false, false, false,
911 false, false, false, false, false, false, false, false, false, false,
912 false, false, false, false, false, false, false, false, false, false,
913 false, true, true, true, true, true, true, true, true, true,
914 true, true, true, true, true, true, true, true, true, true,
915 true, true, true, true, false, true, true, true, true, true,
916 true, true, true, true, true, true, true, true, true, true,
917 true, true, true, true, true, true, true, true, true, false,
918 false, false, false, false, true, true, true, true, true, true,
919 true, true, true, true, true, true, true, true, true, false,
920 false, false, false, false, true, 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, false, false, 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, false, false, false, false,
927 false, false, false, false, false, false, false, false, false, false,
928 false, false, true, true, true, true, true, true, true, true,
929 true, true, true, true, true, true, true, true, true, true,
930 true, true, true, true, true, true, true, true, true, true,
931 true, true, false, false, false, false, false };
933 struct GetCharactersDirectionData data[] =
943 "Left to right characters only",
944 "Hello world\nhello world demo",
950 "Right to left characters only",
951 "שלום עולם\nשלום עולם",
957 "Mix of bidirectional text",
958 "Hello world\nhello world שלום עולם\nשלום עולם hello world",
964 "Mix of bidirectional text. With more paragraphs.",
965 "Hello world demo\nhello world\nhello world مرحبا بالعالم שלום עולם\nשלום مرحبا بالعالم עולם hello مرحبا بالعالم world"
966 " مرحبا بالعالم שלום עולם hello world hello world\nبالعالم שלום hello world demo עולם\nשלום مرحبا بالعالم עולם hello",
972 "Mix of bidirectional text. With more paragraphs. Update first paragraph.",
973 "Hello world demo\nhello world\nhello world مرحبا بالعالم שלום עולם\nשלום مرحبا بالعالم עולם hello مرحبا بالعالم world"
974 " مرحبا بالعالم שלום עולם hello world hello world\nبالعالم שלום hello world demo עולם\nשלום مرحبا بالعالم עולם hello",
980 "Mix of bidirectional text. With more paragraphs. Update from character 29",
981 "Hello world demo\nhello world\nhello world مرحبا بالعالم שלום עולם\nשלום مرحبا بالعالم עולם hello مرحبا بالعالم world"
982 " مرحبا بالعالم שלום עולם hello world hello world\nبالعالم שלום hello world demo עולם\nשלום مرحبا بالعالم עולם hello",
988 "Mix of bidirectional text. With more paragraphs. Update from character 163",
989 "Hello world demo\nhello world\nhello world مرحبا بالعالم שלום עולם\nשלום مرحبا بالعالم עולם hello مرحبا بالعالم world"
990 " مرحبا بالعالم שלום עולם hello world hello world\nبالعالم שלום hello world demo עולם\nשלום مرحبا بالعالم עולם hello",
996 const unsigned int numberOfTests = 8u;
998 for( unsigned int index = 0u; index < numberOfTests; ++index )
1000 ToolkitTestApplication application;
1001 if( !GetCharactersDirectionTest( data[index] ) )
1003 tet_result(TET_FAIL);
1007 tet_result(TET_PASS);