Change test util file
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit-internal / utc-Dali-Text-MultiLanguage.cpp
1 /*
2  * Copyright (c) 2017 Samsung Electronics Co., Ltd.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  *
16  */
17
18 #include <iostream>
19 #include <stdlib.h>
20 #include <unistd.h>
21
22 #include <dali/devel-api/text-abstraction/font-client.h>
23 #include <dali-toolkit/internal/text/character-set-conversion.h>
24 #include <dali-toolkit/internal/text/logical-model-impl.h>
25 #include <dali-toolkit/internal/text/multi-language-helper-functions.h>
26 #include <dali-toolkit/internal/text/multi-language-support.h>
27 #include <dali-toolkit/internal/text/segmentation.h>
28 #include <dali-toolkit/internal/text/text-run-container.h>
29 #include <dali-toolkit-test-suite-utils.h>
30 #include <dali-toolkit/dali-toolkit.h>
31
32 using namespace Dali;
33 using namespace Toolkit;
34 using namespace Text;
35
36 // Tests the following functions with different scripts.
37 //
38 // void MergeFontDescriptions( const Vector<FontDescriptionRun>& fontDescriptions,
39 //                             const TextAbstraction::FontDescription& defaultFontDescription,
40 //                             TextAbstraction::PointSize26Dot6 defaultPointSize,
41 //                             CharacterIndex characterIndex,
42 //                             TextAbstraction::FontDescription& fontDescription,
43 //                             TextAbstraction::PointSize26Dot6& fontPointSize,
44 //                             bool& isDefaultFont );
45 //
46 // Script GetScript( Length index,
47 //                   Vector<ScriptRun>::ConstIterator& scriptRunIt,
48 //                   const Vector<ScriptRun>::ConstIterator& scriptRunEndIt );
49 //
50 // Constructor, destructor and MultilanguageSupport::Get()
51 //
52 // void MultilanguageSupport::SetScripts( const Vector<Character>& text,
53 //                                        CharacterIndex startIndex,
54 //                                        Length numberOfCharacters,
55 //                                        Vector<ScriptRun>& scripts );
56 //
57 // void MultilanguageSupport::ValidateFonts( const Vector<Character>& text,
58 //                                           const Vector<ScriptRun>& scripts,
59 //                                           const Vector<FontDescriptionRun>& fontDescriptions,
60 //                                           const TextAbstraction::FontDescription& defaultFontDescription,
61 //                                           TextAbstraction::PointSize26Dot6 defaultFontPointSize,
62 //                                           CharacterIndex startIndex,
63 //                                           Length numberOfCharacters,
64 //                                           Vector<FontRun>& fonts );
65
66 //////////////////////////////////////////////////////////
67
68 namespace
69 {
70
71 const std::string DEFAULT_FONT_DIR( "/resources/fonts" );
72 const unsigned int EMOJI_FONT_SIZE = 3840u; // 60 * 64
73 const unsigned int NON_DEFAULT_FONT_SIZE = 40u;
74
75 struct MergeFontDescriptionsData
76 {
77   std::string description;                                 ///< Description of the experiment.
78   Vector<FontDescriptionRun> fontDescriptionRuns;          ///< The font description runs.
79   TextAbstraction::FontDescription defaultFontDescription; ///< The default font description.
80   TextAbstraction::PointSize26Dot6 defaultPointSize;       ///< The default point size.
81   unsigned int startIndex;                                 ///< The start index.
82   unsigned int numberOfCharacters;                         ///< The number of characters.
83   Vector<FontId> expectedFontIds;                          ///< The expected font ids.
84   Vector<bool> expectedIsDefault;                          ///< The expected font ids.
85 };
86
87 struct ScriptsData
88 {
89   std::string description;         ///< Description of the experiment.
90   std::string text;                ///< Input text.
91   unsigned int index;              ///< The index of the first character to update the script.
92   unsigned int numberOfCharacters; ///< The numbers of characters to update the script.
93   Vector<ScriptRun> scriptRuns;    ///< Expected script runs.
94 };
95
96 struct ValidateFontsData
97 {
98   std::string                description;         ///< Description of the experiment.
99   std::string                text;                ///< Input text.
100   std::string                defaultFont;         ///< The default font.
101   unsigned int               defaultFontSize;     ///< The default font size.
102   unsigned int               index;               ///< The index of the first character to update the script.
103   unsigned int               numberOfCharacters;  ///< The numbers of characters to update the script.
104   Vector<FontDescriptionRun> fontDescriptionRuns; ///< The font description runs.
105   Vector<FontRun>            fontRuns;            ///< The expected font runs.
106 };
107
108 //////////////////////////////////////////////////////////
109 bool MergeFontDescriptionsTest( const MergeFontDescriptionsData& data )
110 {
111   TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
112
113   Vector<FontId> fontIds;
114   fontIds.Resize( data.startIndex + data.numberOfCharacters, 0u );
115   Vector<bool> isDefaultFont;
116   isDefaultFont.Resize( data.startIndex + data.numberOfCharacters, true );
117
118   for( unsigned int index = data.startIndex; index < data.startIndex + data.numberOfCharacters; ++index )
119   {
120     TextAbstraction::FontDescription fontDescription;
121     TextAbstraction::PointSize26Dot6 fontPointSize = TextAbstraction::FontClient::DEFAULT_POINT_SIZE;
122
123     MergeFontDescriptions( data.fontDescriptionRuns,
124                            data.defaultFontDescription,
125                            data.defaultPointSize,
126                            index,
127                            fontDescription,
128                            fontPointSize,
129                            isDefaultFont[index] );
130
131     if( !isDefaultFont[index] )
132     {
133       fontIds[index] = fontClient.GetFontId( fontDescription, fontPointSize );
134     }
135   }
136
137   if( fontIds.Count() != data.expectedFontIds.Count() )
138   {
139     std::cout << data.description << " Different number of font ids : " << fontIds.Count() << ", expected : " << data.expectedFontIds.Count() << std::endl;
140     return false;
141   }
142
143   for( unsigned int index = 0u; index < fontIds.Count(); ++index )
144   {
145     if( fontIds[index] != data.expectedFontIds[index] )
146     {
147       std::cout << data.description << " Different font id at index : " << index << ", font id : " << fontIds[index] << ", expected : " << data.expectedFontIds[index] << std::endl;
148       std::cout << "           font ids : ";
149       for( unsigned int i=0;i<fontIds.Count();++i)
150       {
151         std::cout << fontIds[i] << " ";
152       }
153       std::cout << std::endl;
154       std::cout << "  expected font ids : ";
155       for( unsigned int i=0;i<data.expectedFontIds.Count();++i)
156       {
157         std::cout << data.expectedFontIds[i] << " ";
158       }
159       std::cout << std::endl;
160       return false;
161     }
162
163     if( isDefaultFont[index] != data.expectedIsDefault[index] )
164     {
165       std::cout << data.description << " Different 'is font default' at index : " << index << ", is font default : " << isDefaultFont[index] << ", expected : " << data.expectedIsDefault[index] << std::endl;
166       return false;
167     }
168   }
169
170   return true;
171 }
172
173 bool ScriptsTest( const ScriptsData& data )
174 {
175   MultilanguageSupport multilanguageSupport = MultilanguageSupport::Get();
176
177   // 1) Convert to utf32
178   Vector<Character> utf32;
179   utf32.Resize( data.text.size() );
180
181   const uint32_t numberOfCharacters = Utf8ToUtf32( reinterpret_cast<const uint8_t* const>( data.text.c_str() ),
182                                                    data.text.size(),
183                                                    &utf32[0u] );
184   utf32.Resize( numberOfCharacters );
185
186   // 2) Set the script info.
187   Vector<ScriptRun> scripts;
188   multilanguageSupport.SetScripts( utf32,
189                                    0u,
190                                    numberOfCharacters,
191                                    scripts );
192
193   if( ( 0u != data.index ) ||
194       ( numberOfCharacters != data.numberOfCharacters ) )
195   {
196     // 3) Clear the scripts.
197     ClearCharacterRuns( data.index,
198                         data.index + data.numberOfCharacters - 1u,
199                         scripts );
200
201     multilanguageSupport.SetScripts( utf32,
202                                      data.index,
203                                      data.numberOfCharacters,
204                                      scripts );
205   }
206
207   // 4) Compare the results.
208
209   tet_printf( "Testing %s\n", data.description.c_str() );
210   if( scripts.Count() != data.scriptRuns.Count() )
211   {
212     tet_printf("ScriptsTest FAIL: different number of scripts. %d, should be %d\n", scripts.Count(), data.scriptRuns.Count() );
213     for( Vector<ScriptRun>::ConstIterator it = scripts.Begin(); it != scripts.End(); ++it)
214     {
215       const ScriptRun& run = *it;
216
217       std::cout << "  index : " << run.characterRun.characterIndex << ", num chars : " << run.characterRun.numberOfCharacters << ", script : [" << TextAbstraction::ScriptName[run.script] << "]" << std::endl;
218     }
219     return false;
220   }
221
222   for( unsigned int index = 0u; index < scripts.Count(); ++index )
223   {
224     const ScriptRun& scriptRun1 = scripts[index];
225     const ScriptRun& scriptRun2 = data.scriptRuns[index];
226
227     if( scriptRun1.characterRun.characterIndex != scriptRun2.characterRun.characterIndex )
228     {
229       tet_printf("ScriptsTest FAIL: different character index. %d, should be %d\n", scriptRun1.characterRun.characterIndex, scriptRun2.characterRun.characterIndex );
230       return false;
231     }
232
233     if( scriptRun1.characterRun.numberOfCharacters != scriptRun2.characterRun.numberOfCharacters )
234     {
235       tet_printf("ScriptsTest FAIL: different number of characters. %d, should be %d\n", scriptRun1.characterRun.numberOfCharacters, scriptRun2.characterRun.numberOfCharacters );
236       return false;
237     }
238
239     if( scriptRun1.script != scriptRun2.script )
240     {
241       tet_printf("ScriptsTest FAIL: script index: %u, different script. %s, should be %s\n", index, TextAbstraction::ScriptName[scriptRun1.script], TextAbstraction::ScriptName[scriptRun2.script] );
242       return false;
243     }
244   }
245
246   return true;
247 }
248
249 bool ValidateFontTest( const ValidateFontsData& data )
250 {
251   MultilanguageSupport multilanguageSupport = MultilanguageSupport::Get();
252   TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
253
254   // 1) Convert to utf32
255   Vector<Character> utf32;
256   utf32.Resize( data.text.size() );
257
258   const uint32_t numberOfCharacters = Utf8ToUtf32( reinterpret_cast<const uint8_t* const>( data.text.c_str() ),
259                                                    data.text.size(),
260                                                    &utf32[0u] );
261   utf32.Resize( numberOfCharacters );
262
263   // 2) Set the script info.
264   Vector<ScriptRun> scripts;
265   multilanguageSupport.SetScripts( utf32,
266                                    0u,
267                                    numberOfCharacters,
268                                    scripts );
269
270   char* pathNamePtr = get_current_dir_name();
271   const std::string pathName( pathNamePtr );
272   free( pathNamePtr );
273
274   // Get the default font id.
275   const FontId defaultFontId = fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + data.defaultFont,
276                                                      data.defaultFontSize );
277   TextAbstraction::FontDescription defaultFontDescription;
278   fontClient.GetDescription( defaultFontId, defaultFontDescription );
279
280   const TextAbstraction::PointSize26Dot6 defaultPointSize = fontClient.GetPointSize( defaultFontId );
281
282   Vector<FontRun> fontRuns;
283
284   // 3) Validate the fonts.
285   multilanguageSupport.ValidateFonts( utf32,
286                                       scripts,
287                                       data.fontDescriptionRuns,
288                                       defaultFontDescription,
289                                       defaultPointSize,
290                                       0u,
291                                       numberOfCharacters,
292                                       fontRuns );
293
294   if( ( 0u != data.index ) ||
295       ( numberOfCharacters != data.numberOfCharacters ) )
296   {
297     // 4) Clear the fonts.
298     ClearCharacterRuns( data.index,
299                         data.index + data.numberOfCharacters - 1u,
300                         fontRuns );
301
302     multilanguageSupport.ValidateFonts( utf32,
303                                         scripts,
304                                         data.fontDescriptionRuns,
305                                         defaultFontDescription,
306                                         defaultPointSize,
307                                         data.index,
308                                         data.numberOfCharacters,
309                                         fontRuns );
310   }
311
312   // 5) Compare the results.
313   if( data.fontRuns.Count() != fontRuns.Count() )
314   {
315     std::cout << "  Different number of font runs : " << fontRuns.Count() << ", expected : " << data.fontRuns.Count() << std::endl;
316     return false;
317   }
318
319
320   for( unsigned int index = 0; index < data.fontRuns.Count(); ++index )
321   {
322     const FontRun& run = fontRuns[index];
323     const FontRun& expectedRun = data.fontRuns[index];
324
325     if( run.characterRun.characterIndex != expectedRun.characterRun.characterIndex )
326     {
327       std::cout << "  character run : " << index << ", index : " << run.characterRun.characterIndex << ", expected : " << expectedRun.characterRun.characterIndex << std::endl;
328       return false;
329     }
330     if( run.characterRun.numberOfCharacters != expectedRun.characterRun.numberOfCharacters )
331     {
332       std::cout << "  character run : " << index << ", num chars : " << run.characterRun.numberOfCharacters << ", expected : " << expectedRun.characterRun.numberOfCharacters << std::endl;
333       return false;
334     }
335     if( run.fontId != expectedRun.fontId )
336     {
337       std::cout << "  character run : " << index << ", font : " << run.fontId << ", expected : " << expectedRun.fontId << std::endl;
338       return false;
339     }
340   }
341
342   return true;
343 }
344
345 } // namespace
346
347 int UtcDaliTextGetScript(void)
348 {
349   ToolkitTestApplication application;
350   tet_infoline(" UtcDaliTextGetScript");
351
352   Script script = TextAbstraction::LATIN;
353
354   // Text with no scripts.
355   Vector<ScriptRun> scriptRuns;
356   Vector<ScriptRun>::ConstIterator scriptRunIt = scriptRuns.Begin();
357   script = GetScript( 0u,
358                       scriptRunIt,
359                       scriptRuns.End() );
360
361   DALI_TEST_CHECK( TextAbstraction::UNKNOWN == script );
362
363   const unsigned int numberOfCharacters = 7u;
364   // Add scripts.
365   ScriptRun scriptRun01 =
366   {
367     {
368       0u,
369       2u,
370     },
371     TextAbstraction::LATIN
372   };
373   ScriptRun scriptRun02 =
374   {
375     {
376       2u,
377       2u,
378     },
379     TextAbstraction::HEBREW
380   };
381   ScriptRun scriptRun03 =
382   {
383     {
384       4u,
385       2u,
386     },
387     TextAbstraction::ARABIC
388   };
389   scriptRuns.PushBack( scriptRun01 );
390   scriptRuns.PushBack( scriptRun02 );
391   scriptRuns.PushBack( scriptRun03 );
392
393   // Expected results
394   TextAbstraction::Script expectedScripts[]=
395   {
396     TextAbstraction::LATIN,
397     TextAbstraction::LATIN,
398     TextAbstraction::HEBREW,
399     TextAbstraction::HEBREW,
400     TextAbstraction::ARABIC,
401     TextAbstraction::ARABIC,
402     TextAbstraction::UNKNOWN
403   };
404
405   scriptRunIt = scriptRuns.Begin();
406   for( unsigned int index = 0u; index < numberOfCharacters; ++index )
407   {
408     script = GetScript( index,
409                         scriptRunIt,
410                         scriptRuns.End() );
411
412     DALI_TEST_CHECK( expectedScripts[index] == script );
413   }
414   DALI_TEST_CHECK( scriptRunIt == scriptRuns.End() );
415
416   tet_result(TET_PASS);
417   END_TEST;
418 }
419
420 int UtcDaliTextMergeFontDescriptions(void)
421 {
422   ToolkitTestApplication application;
423   tet_infoline(" UtcDaliTextMergeFontDescriptions");
424
425   // Load some fonts.
426
427   char* pathNamePtr = get_current_dir_name();
428   const std::string pathName( pathNamePtr );
429   free( pathNamePtr );
430
431   TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
432   fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSans.ttf" );
433   fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf" );
434   fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", NON_DEFAULT_FONT_SIZE );
435   fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf" );
436   fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Italic.ttf" );
437
438   // To test the font width as GetFontId() with the font file path can't cache the width property.
439   TextAbstraction::FontDescription widthDescription;
440   widthDescription.path = "";
441   widthDescription.family = "DejaVu Serif";
442   widthDescription.weight = TextAbstraction::FontWeight::NORMAL;
443   widthDescription.width = TextAbstraction::FontWidth::EXPANDED;
444   widthDescription.slant = TextAbstraction::FontSlant::NORMAL;
445   fontClient.GetFontId( widthDescription );
446
447   // Test.
448
449   TextAbstraction::FontDescription defaultFontDescription01;
450   Vector<FontDescriptionRun> fontDescriptionRuns01;
451   Vector<FontId> expectedFontIds01;
452   Vector<bool> expectedIsFontDefault01;
453
454   TextAbstraction::FontDescription defaultFontDescription02;
455   Vector<FontDescriptionRun> fontDescriptionRuns02;
456   Vector<FontId> expectedFontIds02;
457   expectedFontIds02.PushBack( 0u );
458   expectedFontIds02.PushBack( 0u );
459   Vector<bool> expectedIsFontDefault02;
460   expectedIsFontDefault02.PushBack( true );
461   expectedIsFontDefault02.PushBack( true );
462
463   TextAbstraction::FontDescription defaultFontDescription03;
464   defaultFontDescription03.family = "DejaVu Serif";
465   Vector<FontDescriptionRun> fontDescriptionRuns03;
466
467   FontDescriptionRun fontDescription0301 =
468   {
469     {
470       0u,
471       2u
472     },
473     const_cast<char*>( "DejaVu Sans" ),
474     11u,
475     TextAbstraction::FontWeight::NONE,
476     TextAbstraction::FontWidth::NONE,
477     TextAbstraction::FontSlant::NONE,
478     TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
479     true,
480     false,
481     false,
482     false,
483     false
484   };
485   FontDescriptionRun fontDescription0302 =
486   {
487     {
488       2u,
489       2u
490     },
491     NULL,
492     0u,
493     TextAbstraction::FontWeight::NONE,
494     TextAbstraction::FontWidth::NONE,
495     TextAbstraction::FontSlant::ITALIC,
496     TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
497     false,
498     false,
499     false,
500     true,
501     false
502   };
503   FontDescriptionRun fontDescription0303 =
504   {
505     {
506       4u,
507       2u
508     },
509     NULL,
510     0u,
511     TextAbstraction::FontWeight::BOLD,
512     TextAbstraction::FontWidth::NONE,
513     TextAbstraction::FontSlant::NONE,
514     TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
515     false,
516     true,
517     false,
518     false,
519     false
520   };
521   FontDescriptionRun fontDescription0304 =
522   {
523     {
524       6u,
525       2u
526     },
527     NULL,
528     0u,
529     TextAbstraction::FontWeight::NONE,
530     TextAbstraction::FontWidth::NONE,
531     TextAbstraction::FontSlant::NONE,
532     NON_DEFAULT_FONT_SIZE,
533     false,
534     false,
535     false,
536     false,
537     true
538   };
539   FontDescriptionRun fontDescription0305 =
540   {
541     {
542       8u,
543       2u
544     },
545     NULL,
546     0u,
547     TextAbstraction::FontWeight::NONE,
548     TextAbstraction::FontWidth::EXPANDED,
549     TextAbstraction::FontSlant::NONE,
550     TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
551     false,
552     false,
553     true,
554     false,
555     false
556   };
557
558   fontDescriptionRuns03.PushBack( fontDescription0301 );
559   fontDescriptionRuns03.PushBack( fontDescription0302 );
560   fontDescriptionRuns03.PushBack( fontDescription0303 );
561   fontDescriptionRuns03.PushBack( fontDescription0304 );
562   fontDescriptionRuns03.PushBack( fontDescription0305 );
563
564   Vector<FontId> expectedFontIds03;
565   expectedFontIds03.PushBack( 1u );
566   expectedFontIds03.PushBack( 1u );
567   expectedFontIds03.PushBack( 5u );
568   expectedFontIds03.PushBack( 5u );
569   expectedFontIds03.PushBack( 4u );
570   expectedFontIds03.PushBack( 4u );
571   expectedFontIds03.PushBack( 3u );
572   expectedFontIds03.PushBack( 3u );
573   expectedFontIds03.PushBack( 6u );
574   expectedFontIds03.PushBack( 6u );
575   Vector<bool> expectedIsFontDefault03;
576   expectedIsFontDefault03.PushBack( false );
577   expectedIsFontDefault03.PushBack( false );
578   expectedIsFontDefault03.PushBack( false );
579   expectedIsFontDefault03.PushBack( false );
580   expectedIsFontDefault03.PushBack( false );
581   expectedIsFontDefault03.PushBack( false );
582   expectedIsFontDefault03.PushBack( false );
583   expectedIsFontDefault03.PushBack( false );
584   expectedIsFontDefault03.PushBack( false );
585   expectedIsFontDefault03.PushBack( false );
586
587   const MergeFontDescriptionsData data[] =
588   {
589     {
590       "void text.",
591       fontDescriptionRuns01,
592       defaultFontDescription01,
593       TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
594       0u,
595       0u,
596       expectedFontIds01,
597       expectedIsFontDefault01
598     },
599     {
600       "No description runs.",
601       fontDescriptionRuns02,
602       defaultFontDescription02,
603       TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
604       0u,
605       2u,
606       expectedFontIds02,
607       expectedIsFontDefault02
608     },
609     {
610       "Some description runs.",
611       fontDescriptionRuns03,
612       defaultFontDescription03,
613       TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
614       0u,
615       10u,
616       expectedFontIds03,
617       expectedIsFontDefault03
618     }
619   };
620   const unsigned int numberOfTests = 3u;
621
622   for( unsigned int index = 0u; index < numberOfTests; ++index )
623   {
624     if( !MergeFontDescriptionsTest( data[index] ) )
625     {
626       tet_result(TET_FAIL);
627     }
628   }
629
630   tet_result(TET_PASS);
631   END_TEST;
632 }
633
634 int UtcDaliTextMultiLanguageConstructor(void)
635 {
636   ToolkitTestApplication application;
637   tet_infoline(" UtcDaliTextMultiLanguageConstructor");
638
639   MultilanguageSupport multilanguageSupport;
640   DALI_TEST_CHECK( !multilanguageSupport );
641
642   MultilanguageSupport multilanguageSupport1 = MultilanguageSupport::Get();
643   DALI_TEST_CHECK( multilanguageSupport1 );
644
645   // To increase coverage.
646   MultilanguageSupport multilanguageSupport2 = MultilanguageSupport::Get();
647   DALI_TEST_CHECK( multilanguageSupport2 );
648
649   DALI_TEST_CHECK( multilanguageSupport1 == multilanguageSupport2 );
650
651   tet_result(TET_PASS);
652   END_TEST;
653 }
654
655 int UtcDaliTextMultiLanguageSetScripts(void)
656 {
657   ToolkitTestApplication application;
658   tet_infoline(" UtcDaliTextMultiLanguageSetScripts" );
659
660   // Void text.
661   Vector<ScriptRun> scriptRuns00;
662
663   // Hello world.
664   Vector<ScriptRun> scriptRuns01;
665   ScriptRun scriptRun0100 =
666   {
667     {
668       0u,
669       11u,
670     },
671     TextAbstraction::LATIN
672   };
673   scriptRuns01.PushBack( scriptRun0100 );
674
675   // Mix of LTR '\n'and RTL
676   Vector<ScriptRun> scriptRuns02;
677   ScriptRun scriptRun0200 =
678   {
679     {
680       0u,
681       12u,
682     },
683     TextAbstraction::LATIN
684   };
685   ScriptRun scriptRun0201 =
686   {
687     {
688       12u,
689       13u,
690     },
691     TextAbstraction::ARABIC
692   };
693   scriptRuns02.PushBack( scriptRun0200 );
694   scriptRuns02.PushBack( scriptRun0201 );
695
696   // Mix of RTL '\n'and LTR
697   Vector<ScriptRun> scriptRuns03;
698   ScriptRun scriptRun0300 =
699   {
700     {
701       0u,
702       14u,
703     },
704     TextAbstraction::ARABIC
705   };
706   ScriptRun scriptRun0301 =
707   {
708     {
709       14u,
710       11u,
711     },
712     TextAbstraction::LATIN
713   };
714   scriptRuns03.PushBack( scriptRun0300 );
715   scriptRuns03.PushBack( scriptRun0301 );
716
717   // White spaces. At the beginning of the text.
718   Vector<ScriptRun> scriptRuns04;
719   ScriptRun scriptRun0400 =
720   {
721     {
722       0u,
723       15u,
724     },
725     TextAbstraction::LATIN
726   };
727   scriptRuns04.PushBack( scriptRun0400 );
728
729   // White spaces. At the end of the text.
730   Vector<ScriptRun> scriptRuns05;
731   ScriptRun scriptRun0500 =
732   {
733     {
734       0u,
735       15u,
736     },
737     TextAbstraction::LATIN
738   };
739   scriptRuns05.PushBack( scriptRun0500 );
740
741   // White spaces. At the middle of the text.
742   Vector<ScriptRun> scriptRuns06;
743   ScriptRun scriptRun0600 =
744   {
745     {
746       0u,
747       15u,
748     },
749     TextAbstraction::LATIN
750   };
751   scriptRuns06.PushBack( scriptRun0600 );
752
753   // White spaces between different scripts.
754   Vector<ScriptRun> scriptRuns07;
755   ScriptRun scriptRun0700 =
756   {
757     {
758       0u,
759       8u,
760     },
761     TextAbstraction::LATIN
762   };
763   ScriptRun scriptRun0701 =
764   {
765     {
766       8u,
767       5u,
768     },
769     TextAbstraction::HANGUL
770   };
771   scriptRuns07.PushBack( scriptRun0700 );
772   scriptRuns07.PushBack( scriptRun0701 );
773
774   // White spaces between different scripts and differetn directions. Starting LTR.
775   Vector<ScriptRun> scriptRuns08;
776   ScriptRun scriptRun0800 =
777   {
778     {
779       0u,
780       18u,
781     },
782     TextAbstraction::LATIN
783   };
784   ScriptRun scriptRun0801 =
785   {
786     {
787       18u,
788       14u,
789     },
790     TextAbstraction::ARABIC
791   };
792   ScriptRun scriptRun0802 =
793   {
794     {
795       32u,
796       18u,
797     },
798     TextAbstraction::HANGUL
799   };
800   scriptRuns08.PushBack( scriptRun0800 );
801   scriptRuns08.PushBack( scriptRun0801 );
802   scriptRuns08.PushBack( scriptRun0802 );
803
804   // White spaces between different scripts and differetn directions. Starting RTL.
805   Vector<ScriptRun> scriptRuns09;
806   ScriptRun scriptRun0900 =
807   {
808     {
809       0u,
810       21u,
811     },
812     TextAbstraction::ARABIC
813   };
814   ScriptRun scriptRun0901 =
815   {
816     {
817       21u,
818       16u,
819     },
820     TextAbstraction::LATIN
821   };
822   ScriptRun scriptRun0902 =
823   {
824     {
825       37u,
826       10u,
827     },
828     TextAbstraction::HANGUL
829   };
830   ScriptRun scriptRun0903 =
831   {
832     {
833       47u,
834       20u,
835     },
836     TextAbstraction::ARABIC
837   };
838   scriptRuns09.PushBack( scriptRun0900 );
839   scriptRuns09.PushBack( scriptRun0901 );
840   scriptRuns09.PushBack( scriptRun0902 );
841   scriptRuns09.PushBack( scriptRun0903 );
842
843   // Paragraphs with different directions.
844   Vector<ScriptRun> scriptRuns10;
845   ScriptRun scriptRun1000 =
846   {
847     {
848       0u,
849       20u,
850     },
851     TextAbstraction::ARABIC
852   };
853   ScriptRun scriptRun1001 =
854   {
855     {
856       20u,
857       12u,
858     },
859     TextAbstraction::HEBREW
860   };
861   ScriptRun scriptRun1002 =
862   {
863     {
864       32u,
865       17u,
866     },
867     TextAbstraction::ARABIC
868   };
869   ScriptRun scriptRun1003 =
870   {
871     {
872       49u,
873       18u,
874     },
875     TextAbstraction::LATIN
876   };
877   ScriptRun scriptRun1004 =
878   {
879     {
880       67u,
881       14u,
882     },
883     TextAbstraction::HANGUL
884   };
885   ScriptRun scriptRun1005 =
886   {
887     {
888       81u,
889       19u,
890     },
891     TextAbstraction::ARABIC
892   };
893   ScriptRun scriptRun1006 =
894   {
895     {
896       100u,
897       13u,
898     },
899     TextAbstraction::LATIN
900   };
901   ScriptRun scriptRun1007 =
902   {
903     {
904       113u,
905       16u,
906     },
907     TextAbstraction::HEBREW
908   };
909   ScriptRun scriptRun1008 =
910   {
911     {
912       129u,
913       20u,
914     },
915     TextAbstraction::LATIN
916   };
917   ScriptRun scriptRun1009 =
918   {
919     {
920       149u,
921       14u,
922     },
923     TextAbstraction::ARABIC
924   };
925   ScriptRun scriptRun1010 =
926   {
927     {
928       163u,
929       18u,
930     },
931     TextAbstraction::HANGUL
932   };
933   ScriptRun scriptRun1011 =
934   {
935     {
936       181u,
937       17u,
938     },
939     TextAbstraction::HANGUL
940   };
941   scriptRuns10.PushBack( scriptRun1000 );
942   scriptRuns10.PushBack( scriptRun1001 );
943   scriptRuns10.PushBack( scriptRun1002 );
944   scriptRuns10.PushBack( scriptRun1003 );
945   scriptRuns10.PushBack( scriptRun1004 );
946   scriptRuns10.PushBack( scriptRun1005 );
947   scriptRuns10.PushBack( scriptRun1006 );
948   scriptRuns10.PushBack( scriptRun1007 );
949   scriptRuns10.PushBack( scriptRun1008 );
950   scriptRuns10.PushBack( scriptRun1009 );
951   scriptRuns10.PushBack( scriptRun1010 );
952   scriptRuns10.PushBack( scriptRun1011 );
953
954   // Paragraphs with no scripts mixed with paragraphs with scripts.
955   Vector<ScriptRun> scriptRuns11;
956   ScriptRun scriptRun1100 =
957   {
958     {
959       0u,
960       3u,
961     },
962     TextAbstraction::UNKNOWN
963   };
964   ScriptRun scriptRun1101 =
965   {
966     {
967       3u,
968       3u,
969     },
970     TextAbstraction::UNKNOWN
971   };
972   ScriptRun scriptRun1102 =
973   {
974     {
975       6u,
976       19u,
977     },
978     TextAbstraction::LATIN
979   };
980   ScriptRun scriptRun1103 =
981   {
982     {
983       25u,
984       3u,
985     },
986     TextAbstraction::UNKNOWN
987   };
988   ScriptRun scriptRun1104 =
989   {
990     {
991       28u,
992       3u,
993     },
994     TextAbstraction::UNKNOWN
995   };
996   ScriptRun scriptRun1105 =
997   {
998     {
999       31u,
1000       15u,
1001     },
1002     TextAbstraction::HEBREW
1003   };
1004   ScriptRun scriptRun1106 =
1005   {
1006     {
1007       46u,
1008       2u,
1009     },
1010     TextAbstraction::UNKNOWN
1011   };
1012   ScriptRun scriptRun1107 =
1013   {
1014     {
1015       48u,
1016       2u,
1017     },
1018     TextAbstraction::UNKNOWN
1019   };
1020   ScriptRun scriptRun1108 =
1021   {
1022     {
1023       50u,
1024       2u,
1025     },
1026     TextAbstraction::UNKNOWN
1027   };
1028   scriptRuns11.PushBack( scriptRun1100 );
1029   scriptRuns11.PushBack( scriptRun1101 );
1030   scriptRuns11.PushBack( scriptRun1102 );
1031   scriptRuns11.PushBack( scriptRun1103 );
1032   scriptRuns11.PushBack( scriptRun1104 );
1033   scriptRuns11.PushBack( scriptRun1105 );
1034   scriptRuns11.PushBack( scriptRun1106 );
1035   scriptRuns11.PushBack( scriptRun1107 );
1036   scriptRuns11.PushBack( scriptRun1108 );
1037
1038   // Paragraphs with no scripts.
1039   Vector<ScriptRun> scriptRuns12;
1040   ScriptRun scriptRun1200 =
1041   {
1042     {
1043       0u,
1044       3u,
1045     },
1046     TextAbstraction::UNKNOWN
1047   };
1048   ScriptRun scriptRun1201 =
1049   {
1050     {
1051       3u,
1052       3u,
1053     },
1054     TextAbstraction::UNKNOWN
1055   };
1056   ScriptRun scriptRun1202 =
1057   {
1058     {
1059       6u,
1060       3u,
1061     },
1062     TextAbstraction::UNKNOWN
1063   };
1064   ScriptRun scriptRun1203 =
1065   {
1066     {
1067       9u,
1068       2u,
1069     },
1070     TextAbstraction::UNKNOWN
1071   };
1072   scriptRuns12.PushBack( scriptRun1200 );
1073   scriptRuns12.PushBack( scriptRun1201 );
1074   scriptRuns12.PushBack( scriptRun1202 );
1075   scriptRuns12.PushBack( scriptRun1203 );
1076
1077   Vector<ScriptRun> scriptRuns13;
1078   ScriptRun scriptRun1301 =
1079   {
1080     {
1081       0u,
1082       4u,
1083     },
1084     TextAbstraction::UNKNOWN
1085   };
1086   scriptRuns13.PushBack( scriptRun1301 );
1087
1088   const ScriptsData data[] =
1089   {
1090     {
1091       "void text",
1092       "",
1093       0u,
1094       0u,
1095       scriptRuns00,
1096     },
1097     {
1098       "Easy latin script",
1099       "Hello world",
1100       0u,
1101       11u,
1102       scriptRuns01,
1103     },
1104     {
1105       "Mix of LTR '\\n'and RTL",
1106       "Hello world\nمرحبا بالعالم",
1107       0u,
1108       25u,
1109       scriptRuns02,
1110     },
1111     {
1112       "Update mix of LTR '\\n'and RTL. Update LTR",
1113       "Hello world\nمرحبا بالعالم",
1114       0u,
1115       12u,
1116       scriptRuns02,
1117     },
1118     {
1119       "Update mix of LTR '\\n'and RTL. Update RTL",
1120       "Hello world\nمرحبا بالعالم",
1121       12u,
1122       13u,
1123       scriptRuns02,
1124     },
1125     {
1126       "Mix of RTL '\\n'and LTR",
1127       "مرحبا بالعالم\nHello world",
1128       0u,
1129       25u,
1130       scriptRuns03,
1131     },
1132     {
1133       "Update mix of RTL '\\n'and LTR. Update RTL",
1134       "مرحبا بالعالم\nHello world",
1135       0u,
1136       14u,
1137       scriptRuns03,
1138     },
1139     {
1140       "Update mix of RTL '\\n'and LTR. Update LTR",
1141       "مرحبا بالعالم\nHello world",
1142       14u,
1143       11u,
1144       scriptRuns03,
1145     },
1146     {
1147       "White spaces. At the beginning of the text.",
1148       "    Hello world",
1149       0u,
1150       15u,
1151       scriptRuns04,
1152     },
1153     {
1154       "White spaces. At the end of the text.",
1155       "Hello world    ",
1156       0u,
1157       15u,
1158       scriptRuns05,
1159     },
1160     {
1161       "White spaces. At the middle of the text.",
1162       "Hello     world",
1163       0u,
1164       15u,
1165       scriptRuns06,
1166     },
1167     {
1168       "White spaces between different scripts.",
1169       "  Hel   세계   ",
1170       0u,
1171       13u,
1172       scriptRuns07,
1173     },
1174     {
1175       "White spaces between different scripts and differetn directions. Starting LTR.",
1176       "  Hello   world   مرحبا  بالعالم     안녕하세요   세계   ",
1177       0u,
1178       50u,
1179       scriptRuns08,
1180     },
1181     {
1182       "White spaces between different scripts and differetn directions. Starting RTL.",
1183       "   مرحبا  بالعالم    Hello   world   안녕하세요   세계   مرحبا  بالعالم   ",
1184       0u,
1185       67u,
1186       scriptRuns09
1187     },
1188     {
1189       "Paragraphs with different directions.",
1190       "   مرحبا  بالعالم   שלום עולם   مرحبا  بالعالم  \n "
1191       " Hello   world   안녕하세요   세계   \n "
1192       "  مرحبا  بالعالم  Hello   world    שלום עולם  \n  "
1193       " Hello   world    مرحبا  بالعالم    안녕하세요   세계   \n "
1194       "   안녕하세요   세계   ",
1195       0u,
1196       198u,
1197       scriptRuns10
1198     },
1199     {
1200       "Update paragraphs with different directions. Update initial paragraphs.",
1201       "   مرحبا  بالعالم   שלום עולם   مرحبا  بالعالم  \n "
1202       " Hello   world   안녕하세요   세계   \n "
1203       "  مرحبا  بالعالم  Hello   world    שלום עולם  \n  "
1204       " Hello   world    مرحبا  بالعالم    안녕하세요   세계   \n "
1205       "   안녕하세요   세계   ",
1206       0u,
1207       81u,
1208       scriptRuns10
1209     },
1210     {
1211       "Update paragraphs with different directions. Update middle paragraphs.",
1212       "   مرحبا  بالعالم   שלום עולם   مرحبا  بالعالم  \n "
1213       " Hello   world   안녕하세요   세계   \n "
1214       "  مرحبا  بالعالم  Hello   world    שלום עולם  \n  "
1215       " Hello   world    مرحبا  بالعالم    안녕하세요   세계   \n "
1216       "   안녕하세요   세계   ",
1217       49u,
1218       80u,
1219       scriptRuns10
1220     },
1221     {
1222       "Update paragraphs with different directions. Update final paragraphs.",
1223       "   مرحبا  بالعالم   שלום עולם   مرحبا  بالعالم  \n "
1224       " Hello   world   안녕하세요   세계   \n "
1225       "  مرحبا  بالعالم  Hello   world    שלום עולם  \n  "
1226       " Hello   world    مرحبا  بالعالم    안녕하세요   세계   \n "
1227       "   안녕하세요   세계   ",
1228       129u,
1229       69u,
1230       scriptRuns10
1231     },
1232     {
1233       "Paragraphs with no scripts mixed with paragraphs with scripts.",
1234       "  \n  \n   Hello   world  \n  \n  \n   שלום עולם  \n \n \n  ",
1235       0u,
1236       52u,
1237       scriptRuns11
1238     },
1239     {
1240       "Paragraphs with no scripts.",
1241       "  \n  \n  \n  ",
1242       0u,
1243       11u,
1244       scriptRuns12
1245     },
1246     {
1247       "Update paragraphs with no scripts. Update initial paragraphs.",
1248       "  \n  \n  \n  ",
1249       0u,
1250       3u,
1251       scriptRuns12
1252     },
1253     {
1254       "Update paragraphs with no scripts. Update middle paragraphs.",
1255       "  \n  \n  \n  ",
1256       3u,
1257       6u,
1258       scriptRuns12
1259     },
1260     {
1261       "Update paragraphs with no scripts. Update final paragraphs.",
1262       "  \n  \n  \n  ",
1263       9u,
1264       2u,
1265       scriptRuns12
1266     },
1267     {
1268       "Unknown scripts.",
1269       "ᚩᚯᚱᚸ", // Runic script not currentlu supported.
1270       0u,
1271       4u,
1272       scriptRuns13
1273     }
1274   };
1275   const unsigned int numberOfTests = 24u;
1276
1277   for( unsigned int index = 0u; index < numberOfTests; ++index )
1278   {
1279     if( !ScriptsTest( data[index] ) )
1280     {
1281       tet_result(TET_FAIL);
1282     }
1283   }
1284
1285   tet_result(TET_PASS);
1286   END_TEST;
1287 }
1288
1289 int UtcDaliTextMultiLanguageValidateFonts01(void)
1290 {
1291   ToolkitTestApplication application;
1292   tet_infoline(" UtcDaliTextMultiLanguageValidateFonts");
1293
1294   TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1295
1296   char* pathNamePtr = get_current_dir_name();
1297   const std::string pathName( pathNamePtr );
1298   free( pathNamePtr );
1299
1300   const PointSize26Dot6 pointSize01 = static_cast<PointSize26Dot6>( 21.f * 64.f );
1301   const PointSize26Dot6 pointSize02 = static_cast<PointSize26Dot6>( 35.f * 64.f );
1302
1303   // Load some fonts.
1304   fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/tizen/TizenSansArabicRegular.ttf" );
1305   fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/tizen/TizenSansHebrewRegular.ttf" );
1306   fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/tizen/BreezeColorEmoji.ttf", EMOJI_FONT_SIZE );
1307   fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/tizen/TizenSansRegular.ttf", pointSize01 );
1308   fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/tizen/TizenSansRegular.ttf", pointSize02 );
1309   fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/tizen/TizenSansHebrewRegular.ttf", pointSize01 );
1310   fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/tizen/TizenSansHebrewRegular.ttf", pointSize02 );
1311
1312   // Font id 1 --> TizenSansArabicRegular.ttf
1313   // Font id 2 --> TizenSansHebrewRegular.ttf
1314   // Font id 3 --> BreezeColorEmoji.ttf
1315   // Font id 4 --> TizenSansRegular.ttf, size 8
1316   // Font id 5 --> TizenSansRegular.ttf, size 16
1317   // Font id 6 --> TizenSansHebrewRegular.ttf, size 8
1318   // Font id 7 --> TizenSansHebrewRegular.ttf, size 16
1319   // Font id 8 --> (default)
1320
1321   Vector<FontRun> fontRuns01;
1322   Vector<FontDescriptionRun> fontDescriptions01;
1323
1324   FontRun fontRun0201 =
1325   {
1326     {
1327       0u,
1328       11u
1329     },
1330     8u
1331   };
1332   Vector<FontRun> fontRuns02;
1333   fontRuns02.PushBack( fontRun0201 );
1334
1335   FontDescriptionRun fontDescription0201 =
1336   {
1337     {
1338       0u,
1339       11u
1340     },
1341     const_cast<char*>( "TizenSans" ),
1342     9u,
1343     TextAbstraction::FontWeight::NORMAL,
1344     TextAbstraction::FontWidth::NORMAL,
1345     TextAbstraction::FontSlant::NORMAL,
1346     0u,
1347     true,
1348     false,
1349     false,
1350     false,
1351     false
1352   };
1353   Vector<FontDescriptionRun> fontDescriptions02;
1354   fontDescriptions02.PushBack( fontDescription0201 );
1355
1356   FontRun fontRun0301 =
1357   {
1358     {
1359       0u,
1360       12u
1361     },
1362     8u
1363   };
1364   FontRun fontRun0302 =
1365   {
1366     {
1367       12u,
1368       12u
1369     },
1370     8u
1371   };
1372   FontRun fontRun0303 =
1373   {
1374     {
1375       24u,
1376       4u
1377     },
1378     8u
1379   };
1380   Vector<FontRun> fontRuns03;
1381   fontRuns03.PushBack( fontRun0301 );
1382   fontRuns03.PushBack( fontRun0302 );
1383   fontRuns03.PushBack( fontRun0303 );
1384
1385   Vector<FontDescriptionRun> fontDescriptions03;
1386
1387   FontRun fontRun0701 =
1388   {
1389     {
1390       0u,
1391       4u
1392     },
1393     2u
1394   };
1395   FontRun fontRun0702 =
1396   {
1397     {
1398       4u,
1399       1u
1400     },
1401     8u
1402   };
1403   FontRun fontRun0703 =
1404   {
1405     {
1406       5u,
1407       4u
1408     },
1409     2u
1410   };
1411   Vector<FontRun> fontRuns07;
1412   fontRuns07.PushBack( fontRun0701 );
1413   fontRuns07.PushBack( fontRun0702 );
1414   fontRuns07.PushBack( fontRun0703 );
1415
1416   FontDescriptionRun fontDescription0701 =
1417   {
1418     {
1419       0u,
1420       4u
1421     },
1422     const_cast<char*>( "TizenSansHebrew" ),
1423     15u,
1424     TextAbstraction::FontWeight::NORMAL,
1425     TextAbstraction::FontWidth::NORMAL,
1426     TextAbstraction::FontSlant::NORMAL,
1427     0u,
1428     true,
1429     false,
1430     false,
1431     false,
1432     false
1433   };
1434   FontDescriptionRun fontDescription0702 =
1435   {
1436     {
1437       5u,
1438       4u
1439     },
1440     const_cast<char*>( "TizenSansHebrew" ),
1441     15u,
1442     TextAbstraction::FontWeight::NORMAL,
1443     TextAbstraction::FontWidth::NORMAL,
1444     TextAbstraction::FontSlant::NORMAL,
1445     0u,
1446     true,
1447     false,
1448     false,
1449     false,
1450     false
1451   };
1452   Vector<FontDescriptionRun> fontDescriptions07;
1453   fontDescriptions07.PushBack( fontDescription0701 );
1454   fontDescriptions07.PushBack( fontDescription0702 );
1455
1456   FontRun fontRun0801 =
1457   {
1458     {
1459       0u,
1460       9u
1461     },
1462     2u
1463   };
1464   Vector<FontRun> fontRuns08;
1465   fontRuns08.PushBack( fontRun0801 );
1466
1467   Vector<FontDescriptionRun> fontDescriptions08;
1468
1469   FontRun fontRun0901 =
1470   {
1471     {
1472       0u,
1473       4u
1474     },
1475     3u
1476   };
1477   Vector<FontRun> fontRuns09;
1478   fontRuns09.PushBack( fontRun0901 );
1479
1480   Vector<FontDescriptionRun> fontDescriptions09;
1481   FontDescriptionRun fontDescription0901 =
1482   {
1483     {
1484       0u,
1485       4u
1486     },
1487     const_cast<char*>( "BreezeColorEmoji" ),
1488     16u,
1489     TextAbstraction::FontWeight::NORMAL,
1490     TextAbstraction::FontWidth::NORMAL,
1491     TextAbstraction::FontSlant::NORMAL,
1492     EMOJI_FONT_SIZE,
1493     true,
1494     false,
1495     false,
1496     false,
1497     true
1498   };
1499   fontDescriptions09.PushBack( fontDescription0901 );
1500
1501   FontRun fontRun1001 =
1502   {
1503     {
1504       0u,
1505       13u
1506     },
1507     4u
1508   };
1509   FontRun fontRun1002 =
1510   {
1511     {
1512       13u,
1513       9u
1514     },
1515     6u
1516   };
1517   FontRun fontRun1003 =
1518   {
1519     {
1520       22u,
1521       15u
1522     },
1523     5u
1524   };
1525   FontRun fontRun1004 =
1526   {
1527     {
1528       37u,
1529       9u
1530     },
1531     7u
1532   };
1533   Vector<FontRun> fontRuns10;
1534   fontRuns10.PushBack( fontRun1001 );
1535   fontRuns10.PushBack( fontRun1002 );
1536   fontRuns10.PushBack( fontRun1003 );
1537   fontRuns10.PushBack( fontRun1004 );
1538
1539   FontDescriptionRun fontDescription1001 =
1540   {
1541     {
1542       0u,
1543       13u
1544     },
1545     const_cast<char*>( "TizenSans" ),
1546     9u,
1547     TextAbstraction::FontWeight::NORMAL,
1548     TextAbstraction::FontWidth::NORMAL,
1549     TextAbstraction::FontSlant::NORMAL,
1550     pointSize01,
1551     true,
1552     false,
1553     false,
1554     false,
1555     true
1556   };
1557   FontDescriptionRun fontDescription1002 =
1558   {
1559     {
1560       13u,
1561       9u
1562     },
1563     const_cast<char*>( "TizenSansHebrew" ),
1564     15u,
1565     TextAbstraction::FontWeight::NORMAL,
1566     TextAbstraction::FontWidth::NORMAL,
1567     TextAbstraction::FontSlant::NORMAL,
1568     pointSize01,
1569     true,
1570     false,
1571     false,
1572     false,
1573     true
1574   };
1575   FontDescriptionRun fontDescription1003 =
1576   {
1577     {
1578       22u,
1579       15u
1580     },
1581     const_cast<char*>( "TizenSans" ),
1582     9u,
1583     TextAbstraction::FontWeight::NORMAL,
1584     TextAbstraction::FontWidth::NORMAL,
1585     TextAbstraction::FontSlant::NORMAL,
1586     pointSize02,
1587     true,
1588     false,
1589     false,
1590     false,
1591     true
1592   };
1593   FontDescriptionRun fontDescription1004 =
1594   {
1595     {
1596       37u,
1597       9u
1598     },
1599     const_cast<char*>( "TizenSansHebrew" ),
1600     15u,
1601     TextAbstraction::FontWeight::NORMAL,
1602     TextAbstraction::FontWidth::NORMAL,
1603     TextAbstraction::FontSlant::NORMAL,
1604     pointSize02,
1605     true,
1606     false,
1607     false,
1608     false,
1609     true
1610   };
1611   Vector<FontDescriptionRun> fontDescriptions10;
1612   fontDescriptions10.PushBack( fontDescription1001 );
1613   fontDescriptions10.PushBack( fontDescription1002 );
1614   fontDescriptions10.PushBack( fontDescription1003 );
1615   fontDescriptions10.PushBack( fontDescription1004 );
1616
1617   FontRun fontRun1101 =
1618   {
1619     {
1620       0u,
1621       22u
1622     },
1623     5u
1624   };
1625   Vector<FontRun> fontRuns11;
1626   fontRuns11.PushBack( fontRun1101 );
1627
1628   FontDescriptionRun fontDescription1101 =
1629   {
1630     {
1631       0,
1632       22u
1633     },
1634     const_cast<char*>( "TizenSans" ),
1635     9u,
1636     TextAbstraction::FontWeight::NORMAL,
1637     TextAbstraction::FontWidth::NORMAL,
1638     TextAbstraction::FontSlant::NORMAL,
1639     pointSize02,
1640     true,
1641     false,
1642     false,
1643     false,
1644     true
1645   };
1646   Vector<FontDescriptionRun> fontDescriptions11;
1647   fontDescriptions11.PushBack( fontDescription1101 );
1648
1649   const ValidateFontsData data[] =
1650   {
1651     {
1652       "void text.",
1653       "",
1654       "/tizen/TizenSansRegular.ttf",
1655       TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
1656       0u,
1657       0u,
1658       fontDescriptions01,
1659       fontRuns01
1660     },
1661     {
1662       "Easy latin script.",
1663       "Hello world",
1664       "/tizen/TizenSansRegular.ttf",
1665       TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
1666       0u,
1667       11u,
1668       fontDescriptions02,
1669       fontRuns02
1670     },
1671     {
1672       "Different paragraphs.",
1673       "Hello world\nhello world\ndemo",
1674       "/tizen/TizenSansRegular.ttf",
1675       TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
1676       0u,
1677       28u,
1678       fontDescriptions03,
1679       fontRuns03
1680     },
1681     {
1682       "Different paragraphs. Update the initial paragraph.",
1683       "Hello world\nhello world\ndemo",
1684       "/tizen/TizenSansRegular.ttf",
1685       TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
1686       0u,
1687       12u,
1688       fontDescriptions03,
1689       fontRuns03
1690     },
1691     {
1692       "Different paragraphs. Update the middle paragraph.",
1693       "Hello world\nhello world\ndemo",
1694       "/tizen/TizenSansRegular.ttf",
1695       TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
1696       12u,
1697       12u,
1698       fontDescriptions03,
1699       fontRuns03
1700     },
1701     {
1702       "Different paragraphs. Update the final paragraph.",
1703       "Hello world\nhello world\ndemo",
1704       "/tizen/TizenSansRegular.ttf",
1705       TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
1706       24u,
1707       4u,
1708       fontDescriptions03,
1709       fontRuns03
1710     },
1711     {
1712       "Hebrew text. Default font: latin",
1713       "שלום עולם",
1714       "/tizen/TizenSansRegular.ttf",
1715       TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
1716       0u,
1717       9u,
1718       fontDescriptions07,
1719       fontRuns07
1720     },
1721     {
1722       "Hebrew text. Default font: hebrew",
1723       "שלום עולם",
1724       "/tizen/TizenSansHebrewRegular.ttf",
1725       TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
1726       0u,
1727       9u,
1728       fontDescriptions08,
1729       fontRuns08
1730     },
1731     {
1732       "Emojis",
1733       "\xF0\x9F\x98\x81\xF0\x9F\x98\x82\xF0\x9F\x98\x83\xF0\x9F\x98\x84",
1734       "/tizen/BreezeColorEmoji.ttf",
1735       EMOJI_FONT_SIZE,
1736       0u,
1737       4u,
1738       fontDescriptions09,
1739       fontRuns09
1740     },
1741     {
1742       "Mix text. Default font: latin. Different font sizes",
1743       "Hello world, שלום עולם, hello world, שלום עולם",
1744       "/tizen/TizenSansRegular.ttf",
1745       TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
1746       0u,
1747       46u,
1748       fontDescriptions10,
1749       fontRuns10
1750     },
1751     {
1752       "Unknown script -> changed to LATIN",
1753       "WRC – The Official App",
1754       "/tizen/TizenSansRegular.ttf",
1755       TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
1756       0u,
1757       22u,
1758       fontDescriptions11,
1759       fontRuns11
1760     },
1761   };
1762   const unsigned int numberOfTests = 11u;
1763
1764   for( unsigned int index = 0u; index < numberOfTests; ++index )
1765   {
1766     if( !ValidateFontTest( data[index] ) )
1767     {
1768       tet_result(TET_FAIL);
1769     }
1770   }
1771
1772   tet_result(TET_PASS);
1773   END_TEST;
1774 }