Updates for const->constexpr
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit-internal / utc-Dali-Text-ViewModel.cpp
index fc87193..f243f08 100755 (executable)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2019 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.
@@ -49,14 +49,14 @@ const char* LOREM_IPSUM = "Lorem ipsum dolor sit amet, aeque definiebas ea mei,
   "Aliquip sanctůs delicáta quí ěá, et natum aliquam est?\n"
   "Asšúm sapěret usu ůť.\n"
   "Síť ut apeirián laboramúš percipitur, sůas hařum ín éos?\n";
-const Vector2 LOREM_SCROLL_POSITION( 0.f, -208.f );
-const Length LOREM_NUMBER_OF_LINES = 32u;
+const Vector2 LOREM_SCROLL_POSITION( 0.f, -284.f );
+const Length LOREM_NUMBER_OF_LINES = 36u;
 const Length LOREM_NUMBER_OF_LINES_ELIDED = 21u;
 const Length LOREM_NUMBER_OF_GLYPHS = 632;
-const Length LOREM_NUMBER_OF_GLYPHS_ELIDED = 397u;
+const Length LOREM_NUMBER_OF_GLYPHS_ELIDED = 373u;
 
 // The expected layout size for UtcDaliTextViewModelGetLayoutSize
-const Size LAYOUT_SIZE( 190.f, 48.f );
+const Size LAYOUT_SIZE( 182.f, 45.f );
 
 // The expected color indices for UtcDaliTextViewModelGetColors
 const ColorIndex COLOR_INDICES[] = { 0u, 0u, 0u, 0u, 0u, 0u, 1u, 1u, 1u, 2u, 2u, 2u, 2u, 2u, 1u, 1u, 1u, 1u, 1u, 3u, 1u, 1u, 1u, 0u, 0u, 0u, 0u };
@@ -71,7 +71,6 @@ struct ElideData
   unsigned int numberOfLines;
   unsigned int numberOfGlyphs;
   float*       positions;
-  unsigned int ignoreOfGlyphs;
 };
 
 bool ElideTest( const ElideData& data )
@@ -131,18 +130,18 @@ bool ElideTest( const ElideData& data )
   if( numberOfLines != 0u )
   {
     const LineRun& lastLine = *( model->GetLines() + numberOfLines - 1u );
-    const Length numberOfLastLineGlyphs = data.numberOfGlyphs - lastLine.glyphRun.glyphIndex + data.ignoreOfGlyphs;
+    const Length numberOfLastLineGlyphs = data.numberOfGlyphs - lastLine.glyphRun.glyphIndex;
 
-    std::cout << "  last line alignment offset : " << lastLine.alignmentOffset << std::endl;
+    std::cout << "  last line alignment offset : " << floor(lastLine.alignmentOffset) << std::endl;
 
     for( unsigned int index = 0u; index < numberOfLastLineGlyphs; ++index )
     {
-      if( *( data.positions + index ) != lastLine.alignmentOffset + ( *( layoutBuffer + lastLine.glyphRun.glyphIndex + index ) ).x ) )
+      if( *( data.positions + index ) != floor(lastLine.alignmentOffset + ( *( layoutBuffer + lastLine.glyphRun.glyphIndex + index ) ).x ) )
       {
         std::cout << "  different layout :";
         for( unsigned int i = 0; i < numberOfLastLineGlyphs; ++i )
         {
-          std::cout << " " << ( lastLine.alignmentOffset + ( *( layoutBuffer + lastLine.glyphRun.glyphIndex + i ) ).x );
+          std::cout << " " << floor( lastLine.alignmentOffset + ( *( layoutBuffer + lastLine.glyphRun.glyphIndex + i ) ).x );
         }
         std::cout << std::endl;
         std::cout << "          expected :";
@@ -584,20 +583,17 @@ int UtcDaliTextViewModelElideText02(void)
   Size textSize00( 100.f, 100.f );
 
   Size textSize01( 80.f, 100.f );
-  float positions01[] = { 0.f, 9.f, 17.f, 27.f, 35.f, 37.f, 46.f, 56.f };
+  float positions01[] = { 0.f, 8.f, 16.f, 26.f, 34.f, 43.f, 47.f, 58.f, 64.0f };
 
   Size textSize02( 80.f, 100.f );
-  float positions02[] = { 72.f, 63.f, 54.f, 50.f, 43.f, 38.f, 30.f, 11.f };
+  float positions02[] = { 69.f, 63.f, 58.f, 50.f, 45.f, 41.f, 32.f, 23.f, 9.f };
 
   Size textSize03( 80.f, 100.f );
-  float positions03[] = { 77.f, 76.f, 71.f, 62.f, 59.f, 52.f, 47.f, 42.f, 39.f, 35.f, 32.f, 13.f };
+  float positions03[] = { 54.f, 47.f, 44.f, 41.f, 36.f, 29.f, 25.f, 20.f, 13.f, 8.f, 4.f, 6.f };
 
   Size textSize04( 80.f, 10.f );
   float positions04[] = { 2.f };
 
-  Size textSize05( 180.f, 100.f );
-  float positions05[] = { 0.f, 0.f };
-
   struct ElideData data[] =
   {
     {
@@ -606,35 +602,31 @@ int UtcDaliTextViewModelElideText02(void)
       textSize00,
       0u,
       0u,
-      NULL,
-      0u
+      NULL
     },
     {
       "Latin script",
       "<font family='TizenSans'>Lorem ipsum dolor sit amet, aeque definiebas ea mei, posse iracundia ne cum.</font>",
       textSize01,
       5u,
-      42u,
-      positions01,
-      0u
+      36u,
+      positions01
     },
     {
       "Hebrew script",
       "<font family='TizenSansHebrew'>צעד על לשון המלצת לאחרונה, אם לכאן שנורו סרבול מדע, קרן דת שפות להפוך.</font>",
       textSize02,
       5u,
-      49u,
-      positions02,
-      0u
+      44u,
+      positions02
     },
     {
       "Arabic script",
       "<font family='TizenSansArabic'>عل النفط ديسمبر الإمداد بال, بين وترك شعار هو. لمّ من المبرمة النفط بالسيطرة, أم يتم تحرّك وبغطاء, عدم في لإعادة وإقامة رجوعهم.</font>",
       textSize03,
       5u,
-      79u,
-      positions03,
-      0u
+      62u,
+      positions03
     },
     {
       "Small control size, no line fits.",
@@ -642,20 +634,10 @@ int UtcDaliTextViewModelElideText02(void)
       textSize04,
       1u,
       1u,
-      positions04,
-      0u
-    },
-    {
-      "Include newline character",
-      "<font family='TizenSans'>yesterday\n all\n my troubles\n seemed so far\n\n away now it looks</font>",
-      textSize05,
-      5u,
-      40,
-      positions05,
-      5u
-    },
+      positions04
+    }
   };
-  const unsigned int numberOfTests = 6u;
+  const unsigned int numberOfTests = 5u;
 
   for( unsigned int index = 0u; index < numberOfTests; ++index )
   {