Check supported by font and find fallback font for common script.
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit-internal / utc-Dali-Text-MultiLanguage.cpp
old mode 100644 (file)
new mode 100755 (executable)
index dbb0e94..559e34e
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2018 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -178,9 +178,11 @@ bool ScriptsTest( const ScriptsData& data )
   Vector<Character> utf32;
   utf32.Resize( data.text.size() );
 
-  const uint32_t numberOfCharacters = Utf8ToUtf32( reinterpret_cast<const uint8_t* const>( data.text.c_str() ),
-                                                   data.text.size(),
-                                                   &utf32[0u] );
+  const uint32_t numberOfCharacters = ( data.text.size() == 0 ) ? 0 :
+    Utf8ToUtf32( reinterpret_cast<const uint8_t* const>( data.text.c_str() ),
+                 data.text.size(),
+                 &utf32[0u] );
+
   utf32.Resize( numberOfCharacters );
 
   // 2) Set the script info.
@@ -255,7 +257,8 @@ bool ValidateFontTest( const ValidateFontsData& data )
   Vector<Character> utf32;
   utf32.Resize( data.text.size() );
 
-  const uint32_t numberOfCharacters = Utf8ToUtf32( reinterpret_cast<const uint8_t* const>( data.text.c_str() ),
+  const uint32_t numberOfCharacters = (data.text.size() == 0 ) ? 0 :
+    Utf8ToUtf32( reinterpret_cast<const uint8_t* const>( data.text.c_str() ),
                                                    data.text.size(),
                                                    &utf32[0u] );
   utf32.Resize( numberOfCharacters );
@@ -1646,6 +1649,94 @@ int UtcDaliTextMultiLanguageValidateFonts01(void)
   Vector<FontDescriptionRun> fontDescriptions11;
   fontDescriptions11.PushBack( fontDescription1101 );
 
+  FontRun fontRun1201 =
+  {
+    {
+      0u,
+      6u
+    },
+    8u
+  };
+  FontRun fontRun1202 =
+  {
+    {
+      6u,
+      1u
+    },
+    9u
+  };
+  FontRun fontRun1203 =
+  {
+    {
+      7u,
+      5u
+    },
+    8u
+  };
+  Vector<FontRun> fontRuns12;
+  fontRuns12.PushBack( fontRun1201 );
+  fontRuns12.PushBack( fontRun1202 );
+  fontRuns12.PushBack( fontRun1203 );
+
+  FontDescriptionRun fontDescription1201 =
+  {
+    {
+      0u,
+      6u
+    },
+    const_cast<char*>( "TizenSans" ),
+    9u,
+    TextAbstraction::FontWeight::NORMAL,
+    TextAbstraction::FontWidth::NORMAL,
+    TextAbstraction::FontSlant::NORMAL,
+    0u,
+    true,
+    false,
+    false,
+    false,
+    false
+  };
+  FontDescriptionRun fontDescription1202 =
+  {
+    {
+      6u,
+      1u
+    },
+    const_cast<char*>( "TizenSans" ),
+    9u,
+    TextAbstraction::FontWeight::NORMAL,
+    TextAbstraction::FontWidth::NORMAL,
+    TextAbstraction::FontSlant::NORMAL,
+    0u,
+    true,
+    false,
+    false,
+    false,
+    false
+  };
+  FontDescriptionRun fontDescription1203 =
+  {
+    {
+      7u,
+      5u
+    },
+    const_cast<char*>( "TizenSans" ),
+    9u,
+    TextAbstraction::FontWeight::NORMAL,
+    TextAbstraction::FontWidth::NORMAL,
+    TextAbstraction::FontSlant::NORMAL,
+    0u,
+    true,
+    false,
+    false,
+    false,
+    false
+  };
+  Vector<FontDescriptionRun> fontDescriptions12;
+  fontDescriptions12.PushBack( fontDescription1201 );
+  fontDescriptions12.PushBack( fontDescription1202 );
+  fontDescriptions12.PushBack( fontDescription1203 );
+
   const ValidateFontsData data[] =
   {
     {
@@ -1758,8 +1849,18 @@ int UtcDaliTextMultiLanguageValidateFonts01(void)
       fontDescriptions11,
       fontRuns11
     },
+    {
+      "Common script.",
+      "Hello \tworld",
+      "/tizen/TizenSansRegular.ttf",
+      TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
+      0u,
+      12u,
+      fontDescriptions12,
+      fontRuns12
+    },
   };
-  const unsigned int numberOfTests = 11u;
+  const unsigned int numberOfTests = 12u;
 
   for( unsigned int index = 0u; index < numberOfTests; ++index )
   {