[4.0] Line spacing for TextLabel and vertical line alignment feature
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit-internal / utc-Dali-Text-Typesetter.cpp
index 63f9a22..14f352c 100644 (file)
@@ -35,7 +35,7 @@ using namespace Text;
 namespace
 {
 const std::string DEFAULT_FONT_DIR( "/resources/fonts" );
-const PointSize26Dot6 EMOJI_FONT_SIZE = 62u * 64u;
+const PointSize26Dot6 EMOJI_FONT_SIZE = 3840u; // 60 * 64
 } // namespace
 
 int UtcDaliTextTypesetter(void)
@@ -86,7 +86,7 @@ int UtcDaliTextRenderingControllerRender(void)
   const std::string pathName( pathNamePtr );
   free( pathNamePtr );
 
-  fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/tizen/TizenColorEmoji.ttf", EMOJI_FONT_SIZE );
+  fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/tizen/BreezeColorEmoji.ttf", EMOJI_FONT_SIZE );
   fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/tizen/TizenSansRegular.ttf" );
 
   // Creates a text controller.
@@ -97,7 +97,7 @@ int UtcDaliTextRenderingControllerRender(void)
 
   // Sets the text.
   controller->SetMarkupProcessorEnabled( true );
-  controller->SetText( "<font family='TizenSansRegular'>Hello world </font><font family='TizenColorEmoji'>\xF0\x9F\x98\x81</font>" );
+  controller->SetText( "<font family='TizenSansRegular'>Hello world </font><font family='BreezeColorEmoji'>\xF0\x9F\x98\x81</font>" );
 
   // Creates the text's model and relais-out the text.
   const Size relayoutSize( 120.f, 60.f );
@@ -116,7 +116,7 @@ int UtcDaliTextRenderingControllerRender(void)
   DALI_TEST_EQUALS( Pixel::RGBA8888, bitmap.GetPixelFormat(), TEST_LOCATION );
 
   // Changes vertical alignment.
-  controller->SetVerticalAlignment( Layout::VERTICAL_ALIGN_CENTER );
+  controller->SetVerticalAlignment( Text::VerticalAlignment::CENTER );
   controller->Relayout( relayoutSize );
 
   // Renders the text and creates the final bitmap.
@@ -127,7 +127,7 @@ int UtcDaliTextRenderingControllerRender(void)
   DALI_TEST_EQUALS( 60u, bitmap.GetHeight(), TEST_LOCATION );
   DALI_TEST_EQUALS( Pixel::RGBA8888, bitmap.GetPixelFormat(), TEST_LOCATION );
 
-  controller->SetVerticalAlignment( Layout::VERTICAL_ALIGN_BOTTOM );
+  controller->SetVerticalAlignment( Text::VerticalAlignment::BOTTOM );
   controller->Relayout( relayoutSize );
 
   // Renders the text and creates the final bitmap.
@@ -141,3 +141,57 @@ int UtcDaliTextRenderingControllerRender(void)
   tet_result(TET_PASS);
   END_TEST;
 }
+
+int UtcDaliTextTypesetterVerticalLineAlignment(void)
+{
+  tet_infoline(" UtcDaliTextTypesetter");
+  ToolkitTestApplication application;
+
+  // Creates a text controller.
+  ControllerPtr controller = Controller::New();
+
+  // Configures the text controller similarly to the text-label.
+  ConfigureTextLabel( controller );
+
+  // Sets the text.
+  controller->SetMarkupProcessorEnabled( true );
+  controller->SetText( "<font family='TizenSansRegular'>Hello world</font>" );
+
+  // Creates the text's model and relais-out the text.
+  const Size relayoutSize( 120.f, 60.f );
+  controller->Relayout( relayoutSize );
+
+  // Tests the rendering controller has been created.
+  TypesetterPtr renderingController = Typesetter::New( controller->GetTextModel() );
+  DALI_TEST_CHECK( renderingController );
+
+  {
+    controller->SetVerticalLineAlignment(Dali::Toolkit::DevelText::VerticalLineAlignment::TOP);
+    controller->Relayout(relayoutSize);
+
+    // Renders the text and creates the final bitmap.
+    auto bitmap = renderingController->Render(relayoutSize);
+    DALI_TEST_EQUALS( 60u, bitmap.GetHeight(), TEST_LOCATION );
+  }
+
+  {
+    controller->SetVerticalLineAlignment(Dali::Toolkit::DevelText::VerticalLineAlignment::MIDDLE);
+    controller->Relayout(relayoutSize);
+
+    // Renders the text and creates the final bitmap.
+    auto bitmap = renderingController->Render(relayoutSize);
+    DALI_TEST_EQUALS( 60u, bitmap.GetHeight(), TEST_LOCATION );
+  }
+
+  {
+    controller->SetVerticalLineAlignment(Dali::Toolkit::DevelText::VerticalLineAlignment::BOTTOM);
+    controller->Relayout(relayoutSize);
+
+    // Renders the text and creates the final bitmap.
+    auto bitmap = renderingController->Render(relayoutSize);
+    DALI_TEST_EQUALS( 60u, bitmap.GetHeight(), TEST_LOCATION );
+  }
+
+  tet_result(TET_PASS);
+  END_TEST;
+}
\ No newline at end of file