(GCC 6.2) Remove unused functions from automated-tests
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit-internal / utc-Dali-Text-MultiLanguage.cpp
index eea51a6..eba6b05 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 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.
@@ -36,11 +36,12 @@ using namespace Text;
 // Tests the following functions with different scripts.
 //
 // void MergeFontDescriptions( const Vector<FontDescriptionRun>& fontDescriptions,
-//                             Vector<FontId>& fontIds,
 //                             const TextAbstraction::FontDescription& defaultFontDescription,
 //                             TextAbstraction::PointSize26Dot6 defaultPointSize,
-//                             CharacterIndex startIndex,
-//                             Length numberOfCharacters );
+//                             CharacterIndex characterIndex,
+//                             TextAbstraction::FontDescription& fontDescription,
+//                             TextAbstraction::PointSize26Dot6& fontPointSize,
+//                             bool& isDefaultFont );
 //
 // Script GetScript( Length index,
 //                   Vector<ScriptRun>::ConstIterator& scriptRunIt,
@@ -56,7 +57,8 @@ using namespace Text;
 // void MultilanguageSupport::ValidateFonts( const Vector<Character>& text,
 //                                           const Vector<ScriptRun>& scripts,
 //                                           const Vector<FontDescriptionRun>& fontDescriptions,
-//                                           FontId defaultFontId,
+//                                           const TextAbstraction::FontDescription& defaultFontDescription,
+//                                           TextAbstraction::PointSize26Dot6 defaultFontPointSize,
 //                                           CharacterIndex startIndex,
 //                                           Length numberOfCharacters,
 //                                           Vector<FontRun>& fonts );
@@ -79,6 +81,7 @@ struct MergeFontDescriptionsData
   unsigned int startIndex;                                 ///< The start index.
   unsigned int numberOfCharacters;                         ///< The number of characters.
   Vector<FontId> expectedFontIds;                          ///< The expected font ids.
+  Vector<bool> expectedIsDefault;                          ///< The expected font ids.
 };
 
 struct ScriptsData
@@ -103,18 +106,33 @@ struct ValidateFontsData
 };
 
 //////////////////////////////////////////////////////////
-
 bool MergeFontDescriptionsTest( const MergeFontDescriptionsData& data )
 {
+  TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
+
   Vector<FontId> fontIds;
   fontIds.Resize( data.startIndex + data.numberOfCharacters, 0u );
+  Vector<bool> isDefaultFont;
+  isDefaultFont.Resize( data.startIndex + data.numberOfCharacters, true );
 
-  MergeFontDescriptions( data.fontDescriptionRuns,
-                         fontIds,
-                         data.defaultFontDescription,
-                         data.defaultPointSize,
-                         data.startIndex,
-                         data.numberOfCharacters );
+  for( unsigned int index = data.startIndex; index < data.startIndex + data.numberOfCharacters; ++index )
+  {
+    TextAbstraction::FontDescription fontDescription;
+    TextAbstraction::PointSize26Dot6 fontPointSize = TextAbstraction::FontClient::DEFAULT_POINT_SIZE;
+
+    MergeFontDescriptions( data.fontDescriptionRuns,
+                           data.defaultFontDescription,
+                           data.defaultPointSize,
+                           index,
+                           fontDescription,
+                           fontPointSize,
+                           isDefaultFont[index] );
+
+    if( !isDefaultFont[index] )
+    {
+      fontIds[index] = fontClient.GetFontId( fontDescription, fontPointSize );
+    }
+  }
 
   if( fontIds.Count() != data.expectedFontIds.Count() )
   {
@@ -141,6 +159,12 @@ bool MergeFontDescriptionsTest( const MergeFontDescriptionsData& data )
       std::cout << std::endl;
       return false;
     }
+
+    if( isDefaultFont[index] != data.expectedIsDefault[index] )
+    {
+      std::cout << data.description << " Different 'is font default' at index : " << index << ", is font default : " << isDefaultFont[index] << ", expected : " << data.expectedIsDefault[index] << std::endl;
+      return false;
+    }
   }
 
   return true;
@@ -186,6 +210,12 @@ bool ScriptsTest( const ScriptsData& data )
   if( scripts.Count() != data.scriptRuns.Count() )
   {
     tet_printf("ScriptsTest FAIL: different number of scripts. %d, should be %d\n", scripts.Count(), data.scriptRuns.Count() );
+    for( Vector<ScriptRun>::ConstIterator it = scripts.Begin(); it != scripts.End(); ++it)
+    {
+      const ScriptRun& run = *it;
+
+      std::cout << "  index : " << run.characterRun.characterIndex << ", num chars : " << run.characterRun.numberOfCharacters << ", script : [" << TextAbstraction::ScriptName[run.script] << "]" << std::endl;
+    }
     return false;
   }
 
@@ -244,6 +274,10 @@ bool ValidateFontTest( const ValidateFontsData& data )
   // Get the default font id.
   const FontId defaultFontId = fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + data.defaultFont,
                                                      data.defaultFontSize );
+  TextAbstraction::FontDescription defaultFontDescription;
+  fontClient.GetDescription( defaultFontId, defaultFontDescription );
+
+  const TextAbstraction::PointSize26Dot6 defaultPointSize = fontClient.GetPointSize( defaultFontId );
 
   Vector<FontRun> fontRuns;
 
@@ -251,7 +285,8 @@ bool ValidateFontTest( const ValidateFontsData& data )
   multilanguageSupport.ValidateFonts( utf32,
                                       scripts,
                                       data.fontDescriptionRuns,
-                                      defaultFontId,
+                                      defaultFontDescription,
+                                      defaultPointSize,
                                       0u,
                                       numberOfCharacters,
                                       fontRuns );
@@ -267,7 +302,8 @@ bool ValidateFontTest( const ValidateFontsData& data )
     multilanguageSupport.ValidateFonts( utf32,
                                         scripts,
                                         data.fontDescriptionRuns,
-                                        defaultFontId,
+                                        defaultFontDescription,
+                                        defaultPointSize,
                                         data.index,
                                         data.numberOfCharacters,
                                         fontRuns );
@@ -413,12 +449,16 @@ int UtcDaliTextMergeFontDescriptions(void)
   TextAbstraction::FontDescription defaultFontDescription01;
   Vector<FontDescriptionRun> fontDescriptionRuns01;
   Vector<FontId> expectedFontIds01;
+  Vector<bool> expectedIsFontDefault01;
 
   TextAbstraction::FontDescription defaultFontDescription02;
   Vector<FontDescriptionRun> fontDescriptionRuns02;
   Vector<FontId> expectedFontIds02;
   expectedFontIds02.PushBack( 0u );
   expectedFontIds02.PushBack( 0u );
+  Vector<bool> expectedIsFontDefault02;
+  expectedIsFontDefault02.PushBack( true );
+  expectedIsFontDefault02.PushBack( true );
 
   TextAbstraction::FontDescription defaultFontDescription03;
   defaultFontDescription03.family = "DejaVu Serif";
@@ -432,9 +472,9 @@ int UtcDaliTextMergeFontDescriptions(void)
     },
     const_cast<char*>( "DejaVu Sans" ),
     11u,
-    TextAbstraction::FontWeight::NORMAL,
-    TextAbstraction::FontWidth::NORMAL,
-    TextAbstraction::FontSlant::NORMAL,
+    TextAbstraction::FontWeight::NONE,
+    TextAbstraction::FontWidth::NONE,
+    TextAbstraction::FontSlant::NONE,
     TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
     true,
     false,
@@ -450,8 +490,8 @@ int UtcDaliTextMergeFontDescriptions(void)
     },
     NULL,
     0u,
-    TextAbstraction::FontWeight::NORMAL,
-    TextAbstraction::FontWidth::NORMAL,
+    TextAbstraction::FontWeight::NONE,
+    TextAbstraction::FontWidth::NONE,
     TextAbstraction::FontSlant::ITALIC,
     TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
     false,
@@ -469,8 +509,8 @@ int UtcDaliTextMergeFontDescriptions(void)
     NULL,
     0u,
     TextAbstraction::FontWeight::BOLD,
-    TextAbstraction::FontWidth::NORMAL,
-    TextAbstraction::FontSlant::NORMAL,
+    TextAbstraction::FontWidth::NONE,
+    TextAbstraction::FontSlant::NONE,
     TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
     false,
     true,
@@ -486,9 +526,9 @@ int UtcDaliTextMergeFontDescriptions(void)
     },
     NULL,
     0u,
-    TextAbstraction::FontWeight::NORMAL,
-    TextAbstraction::FontWidth::NORMAL,
-    TextAbstraction::FontSlant::NORMAL,
+    TextAbstraction::FontWeight::NONE,
+    TextAbstraction::FontWidth::NONE,
+    TextAbstraction::FontSlant::NONE,
     NON_DEFAULT_FONT_SIZE,
     false,
     false,
@@ -504,9 +544,9 @@ int UtcDaliTextMergeFontDescriptions(void)
     },
     NULL,
     0u,
-    TextAbstraction::FontWeight::NORMAL,
+    TextAbstraction::FontWeight::NONE,
     TextAbstraction::FontWidth::EXPANDED,
-    TextAbstraction::FontSlant::NORMAL,
+    TextAbstraction::FontSlant::NONE,
     TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
     false,
     false,
@@ -532,6 +572,17 @@ int UtcDaliTextMergeFontDescriptions(void)
   expectedFontIds03.PushBack( 3u );
   expectedFontIds03.PushBack( 6u );
   expectedFontIds03.PushBack( 6u );
+  Vector<bool> expectedIsFontDefault03;
+  expectedIsFontDefault03.PushBack( false );
+  expectedIsFontDefault03.PushBack( false );
+  expectedIsFontDefault03.PushBack( false );
+  expectedIsFontDefault03.PushBack( false );
+  expectedIsFontDefault03.PushBack( false );
+  expectedIsFontDefault03.PushBack( false );
+  expectedIsFontDefault03.PushBack( false );
+  expectedIsFontDefault03.PushBack( false );
+  expectedIsFontDefault03.PushBack( false );
+  expectedIsFontDefault03.PushBack( false );
 
   const MergeFontDescriptionsData data[] =
   {
@@ -542,7 +593,8 @@ int UtcDaliTextMergeFontDescriptions(void)
       TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
       0u,
       0u,
-      expectedFontIds01
+      expectedFontIds01,
+      expectedIsFontDefault01
     },
     {
       "No description runs.",
@@ -551,7 +603,8 @@ int UtcDaliTextMergeFontDescriptions(void)
       TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
       0u,
       2u,
-      expectedFontIds02
+      expectedFontIds02,
+      expectedIsFontDefault02
     },
     {
       "Some description runs.",
@@ -560,7 +613,8 @@ int UtcDaliTextMergeFontDescriptions(void)
       TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
       0u,
       10u,
-      expectedFontIds03
+      expectedFontIds03,
+      expectedIsFontDefault03
     }
   };
   const unsigned int numberOfTests = 3u;
@@ -666,7 +720,7 @@ int UtcDaliTextMultiLanguageSetScripts(void)
   {
     {
       0u,
-      16u,
+      15u,
     },
     TextAbstraction::LATIN
   };
@@ -678,7 +732,7 @@ int UtcDaliTextMultiLanguageSetScripts(void)
   {
     {
       0u,
-      16u,
+      15u,
     },
     TextAbstraction::LATIN
   };
@@ -690,7 +744,7 @@ int UtcDaliTextMultiLanguageSetScripts(void)
   {
     {
       0u,
-      16u,
+      15u,
     },
     TextAbstraction::LATIN
   };
@@ -1091,23 +1145,23 @@ int UtcDaliTextMultiLanguageSetScripts(void)
     },
     {
       "White spaces. At the beginning of the text.",
-      "    Hello world.",
+      "    Hello world",
       0u,
-      16u,
+      15u,
       scriptRuns04,
     },
     {
       "White spaces. At the end of the text.",
-      "Hello world.    ",
+      "Hello world    ",
       0u,
-      16u,
+      15u,
       scriptRuns05,
     },
     {
       "White spaces. At the middle of the text.",
-      "Hello     world.",
+      "Hello     world",
       0u,
-      16u,
+      15u,
       scriptRuns06,
     },
     {