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