Merge "Add ApplyCustomFragmentPrefix" into devel/master
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit-internal / utc-Dali-VisualModel.cpp
index 18faa9e..2453771 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
@@ -21,7 +21,7 @@
 
 #include <dali-toolkit-test-suite-utils.h>
 #include <dali-toolkit/dali-toolkit.h>
-#include <toolkit-text-model.h>
+#include <toolkit-text-utils.h>
 
 
 using namespace Dali;
@@ -65,25 +65,39 @@ struct SetCharacterToGlyphData
 bool SetGlyphsPerCharacterTest( const SetGlyphsPerCharacterData& data )
 {
   // 1) Create the model.
-  LogicalModelPtr logicalModel = LogicalModel::New();
-  VisualModelPtr visualModel = VisualModel::New();
+  ModelPtr textModel;
+  MetricsPtr metrics;
   Size textArea(100.f, 60.f);
   Size layoutSize;
 
+  const Vector<FontDescriptionRun> fontDescriptions;
+  const LayoutOptions options;
   CreateTextModel( data.text,
                    textArea,
+                   fontDescriptions,
+                   options,
                    layoutSize,
-                   logicalModel,
-                   visualModel );
+                   textModel,
+                   metrics,
+                   false,
+                   LineWrap::WORD,
+                   false,
+                   Toolkit::DevelText::EllipsisPosition::END );
+
+  LogicalModelPtr logicalModel = textModel->mLogicalModel;
+  VisualModelPtr visualModel = textModel->mVisualModel;
 
-  // 2) Clear the model.
   Vector<GlyphIndex>& charactersToGlyph = visualModel->mCharactersToGlyph;
   Vector<Length>& glyphsPerCharacter = visualModel->mGlyphsPerCharacter;
 
+  // 2) Clear the model.
+
+  GlyphIndex startGlyphIndex = 0u;
   if( 0u != charactersToGlyph.Count() )
   {
     // The number of glyphs to be removed.
     const Length numberOfGlyphs = charactersToGlyph[data.startIndex + data.numberOfCharacters - 1u] + glyphsPerCharacter[data.startIndex + data.numberOfCharacters - 1u] - charactersToGlyph[data.startIndex];
+    startGlyphIndex = charactersToGlyph[data.startIndex];
 
     charactersToGlyph.Erase( charactersToGlyph.Begin() + data.startIndex,
                              charactersToGlyph.Begin() + data.startIndex + data.numberOfCharacters );
@@ -102,6 +116,7 @@ bool SetGlyphsPerCharacterTest( const SetGlyphsPerCharacterData& data )
 
   // 3) Call the CreateGlyphsPerCharacterTable() function
   visualModel->CreateGlyphsPerCharacterTable( data.startIndex,
+                                              startGlyphIndex,
                                               data.numberOfCharacters );
 
   // 4) Compare the results.
@@ -137,25 +152,39 @@ bool SetGlyphsPerCharacterTest( const SetGlyphsPerCharacterData& data )
 bool SetCharacterToGlyphTest( const SetCharacterToGlyphData& data )
 {
   // 1) Create the model.
-  LogicalModelPtr logicalModel = LogicalModel::New();
-  VisualModelPtr visualModel = VisualModel::New();
+  ModelPtr textModel;
+  MetricsPtr metrics;
   Size textArea(100.f, 60.f);
   Size layoutSize;
 
+  const Vector<FontDescriptionRun> fontDescriptions;
+  const LayoutOptions options;
   CreateTextModel( data.text,
                    textArea,
+                   fontDescriptions,
+                   options,
                    layoutSize,
-                   logicalModel,
-                   visualModel );
+                   textModel,
+                   metrics,
+                   false,
+                   LineWrap::WORD,
+                   false,
+                   Toolkit::DevelText::EllipsisPosition::END );
+
+  LogicalModelPtr logicalModel = textModel->mLogicalModel;
+  VisualModelPtr visualModel = textModel->mVisualModel;
 
-  // 2) Clear the model.
   Vector<GlyphIndex>& charactersToGlyph = visualModel->mCharactersToGlyph;
   Vector<Length>& glyphsPerCharacter = visualModel->mGlyphsPerCharacter;
 
+  // 2) Clear the model.
+
+  GlyphIndex startGlyphIndex = 0u;
   if( 0u != charactersToGlyph.Count() )
   {
     // The number of glyphs to be removed.
     const Length numberOfGlyphs = charactersToGlyph[data.startIndex + data.numberOfCharacters - 1u] + glyphsPerCharacter[data.startIndex + data.numberOfCharacters - 1u] - charactersToGlyph[data.startIndex];
+    startGlyphIndex = charactersToGlyph[data.startIndex];
 
     charactersToGlyph.Erase( charactersToGlyph.Begin() + data.startIndex,
                              charactersToGlyph.Begin() + data.startIndex + data.numberOfCharacters );
@@ -172,6 +201,7 @@ bool SetCharacterToGlyphTest( const SetCharacterToGlyphData& data )
 
   // 3) Call the CreateCharacterToGlyphTable() function
   visualModel->CreateCharacterToGlyphTable( data.startIndex,
+                                            startGlyphIndex,
                                             data.numberOfCharacters );
 
   // 4) Compare the results.
@@ -210,7 +240,6 @@ bool SetCharacterToGlyphTest( const SetCharacterToGlyphData& data )
 
 int UtcDaliSetGlyphsPerCharacter(void)
 {
-  ToolkitTestApplication application;
   tet_infoline(" UtcDaliSetGlyphsPerCharacter");
 
   Length glyphsPerCharacter02[] = { 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u };
@@ -277,6 +306,7 @@ int UtcDaliSetGlyphsPerCharacter(void)
 
   for( unsigned int index = 0u; index < numberOfTests; ++index )
   {
+    ToolkitTestApplication application;
     if( !SetGlyphsPerCharacterTest( data[index] ) )
     {
       tet_result(TET_FAIL);
@@ -289,7 +319,6 @@ int UtcDaliSetGlyphsPerCharacter(void)
 
 int UtcDaliSetCharacterToGlyph(void)
 {
-  ToolkitTestApplication application;
   tet_infoline(" UtcDaliSetGlyphsPerCharacter");
 
   GlyphIndex glyphIndices02[] = { 0u, 1u, 2u, 3u, 4u, 5u, 6u, 7u, 8u, 9u, 10u };
@@ -354,6 +383,7 @@ int UtcDaliSetCharacterToGlyph(void)
 
   for( unsigned int index = 0u; index < numberOfTests; ++index )
   {
+    ToolkitTestApplication application;
     if( !SetCharacterToGlyphTest( data[index] ) )
     {
       tet_result(TET_FAIL);