Remove non-touch related deprecated APIs
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / utc-Dali-TextLabel.cpp
index 2d6b092..4fa21f8 100755 (executable)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2020 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.
@@ -28,6 +28,7 @@
 #include <dali/devel-api/text-abstraction/font-client.h>
 #include <dali/devel-api/adaptor-framework/image-loading.h>
 #include <dali-toolkit/devel-api/text/bitmap-font.h>
+#include <dali-toolkit/devel-api/text/rendering-backend.h>
 
 using namespace Dali;
 using namespace Toolkit;
@@ -250,7 +251,7 @@ int UtcDaliToolkitTextLabelGetPropertyP(void)
   DALI_TEST_CHECK( label );
 
   // Check Property Indices are correct
-  DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_RENDERING_BACKEND ) == TextLabel::Property::RENDERING_BACKEND );
+  DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_RENDERING_BACKEND ) == DevelTextLabel::Property::RENDERING_BACKEND );
   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_TEXT ) == TextLabel::Property::TEXT );
   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_FONT_FAMILY ) == TextLabel::Property::FONT_FAMILY );
   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_FONT_STYLE ) == TextLabel::Property::FONT_STYLE );
@@ -287,8 +288,8 @@ int UtcDaliToolkitTextLabelSetPropertyP(void)
   Stage::GetCurrent().Add( label );
 
   // Note - we can't check the defaults since the stylesheets are platform-specific
-  label.SetProperty( TextLabel::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
-  DALI_TEST_EQUALS( (Text::RenderingType)label.GetProperty<int>( TextLabel::Property::RENDERING_BACKEND ), Text::RENDERING_SHARED_ATLAS, TEST_LOCATION );
+  label.SetProperty( DevelTextLabel::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS );
+  DALI_TEST_EQUALS( (DevelText::RenderingType)label.GetProperty<int>( DevelTextLabel::Property::RENDERING_BACKEND ), DevelText::RENDERING_SHARED_ATLAS, TEST_LOCATION );
 
   // Check that text can be correctly reset
   label.SetProperty( TextLabel::Property::TEXT, "Setting Text" );
@@ -677,7 +678,7 @@ int UtcDaliToolkitTextlabelAtlasRenderP(void)
   try
   {
     // Render some text with the shared atlas backend
-    label.SetProperty( TextLabel::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
+    label.SetProperty( DevelTextLabel::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS );
     application.SendNotification();
     application.Render();
   }
@@ -689,7 +690,7 @@ int UtcDaliToolkitTextlabelAtlasRenderP(void)
   try
   {
     // Render some text with the shared atlas backend
-    label.SetProperty( TextLabel::Property::RENDERING_BACKEND, Text::RENDERING_VECTOR_BASED );
+    label.SetProperty( DevelTextLabel::Property::RENDERING_BACKEND, DevelText::RENDERING_VECTOR_BASED );
     application.SendNotification();
     application.Render();
   }
@@ -1030,7 +1031,7 @@ int UtcDaliToolkitTextlabelScrollingInterruptedP(void)
   // Avoid a crash when core load gl resources.
   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
   Stage::GetCurrent().Add( label );
-  label.SetSize( 360.0f, 20.f );
+  label.SetProperty( Actor::Property::SIZE, Vector2( 360.0f, 20.f ) );
   // Turn on all the effects
   label.SetProperty( TextLabel::Property::MULTI_LINE, false );
   label.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
@@ -1105,6 +1106,51 @@ int UtcDaliToolkitTextlabelScrollingN(void)
   END_TEST;
 }
 
+int UtcDaliToolkitTextlabelScrollingWithEllipsis(void)
+{
+  ToolkitTestApplication application;
+  tet_infoline(" UtcDaliToolkitTextlabelScrollingWithEllipsis");
+
+  TextLabel label = TextLabel::New("Some text to scroll");
+  DALI_TEST_CHECK( label );
+
+  Stage::GetCurrent().Add( label );
+
+  // Avoid a crash when core load gl resources.
+  application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
+
+  // Turn on all the effects.
+  label.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
+  label.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
+  label.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
+
+  try
+  {
+    // Enable the auto scrolling effect.
+    label.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
+    label.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
+
+    // Disable the ellipsis
+    label.SetProperty( TextLabel::Property::ELLIPSIS, false );
+
+    // Render the text.
+    application.SendNotification();
+    application.Render();
+
+    // Stop auto scrolling
+    label.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
+
+    // Check the ellipsis property
+    DALI_TEST_CHECK( !label.GetProperty<bool>( TextLabel::Property::ELLIPSIS ) );
+  }
+  catch( ... )
+  {
+    tet_result(TET_FAIL);
+  }
+
+  END_TEST;
+}
+
 int UtcDaliToolkitTextlabelEllipsis(void)
 {
   ToolkitTestApplication application;
@@ -1119,9 +1165,9 @@ int UtcDaliToolkitTextlabelEllipsis(void)
   Stage::GetCurrent().Add( label );
 
   // Turn on all the effects
-  label.SetAnchorPoint( AnchorPoint::CENTER );
-  label.SetParentOrigin( ParentOrigin::CENTER );
-  label.SetSize( 360.0f, 10.f );
+  label.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
+  label.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
+  label.SetProperty( Actor::Property::SIZE, Vector2( 360.0f, 10.f ) );
 
   try
   {
@@ -1136,7 +1182,7 @@ int UtcDaliToolkitTextlabelEllipsis(void)
 
   label.SetProperty( TextLabel::Property::TEXT, "Hello world                                        " );
   label.SetProperty( DevelTextLabel::Property::IGNORE_SPACES_AFTER_TEXT, false );
-  label.SetSize( 400.0f, 10.f );
+  label.SetProperty( Actor::Property::SIZE, Vector2( 400.0f, 10.f ) );
 
   try
   {
@@ -1152,7 +1198,7 @@ int UtcDaliToolkitTextlabelEllipsis(void)
 
   label.SetProperty( TextLabel::Property::TEXT, "Hello world" );
   label.SetProperty( DevelTextLabel::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, true );
-  label.SetSize( 400.0f, 10.f );
+  label.SetProperty( Actor::Property::SIZE, Vector2( 400.0f, 10.f ) );
 
   try
   {
@@ -1176,7 +1222,7 @@ int UtcDaliToolkitTextlabelTextWrapMode(void)
   int lineCount =0 ;
 
   TextLabel label = TextLabel::New();
-  label.SetSize( 300.0f, 300.f );
+  label.SetProperty( Actor::Property::SIZE, Vector2( 300.0f, 300.f ) );
   label.SetProperty( TextLabel::Property::TEXT, "Hello world Hello world" );
   label.SetProperty( TextLabel::Property::MULTI_LINE, true );
 
@@ -1251,7 +1297,6 @@ int UtcDaliToolkitTextLabelColorComponents(void)
   label.SetProperty( TextLabel::Property::TEXT_COLOR_ALPHA, 0.6f );
   DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_ALPHA ), 0.6f, TEST_LOCATION );
   DALI_TEST_EQUALS( label.GetProperty< Vector4 >( TextLabel::Property::TEXT_COLOR ), Vector4( 0.0f, 0.0f, 1.0f, 0.6f ), TEST_LOCATION );
-  DALI_TEST_EQUALS( label.GetProperty< Vector4 >( TextLabel::Property::UNUSED_PROPERTY_TEXT_COLOR ), Vector4( 0.0f, 0.0f, 1.0f, 0.6f ), TEST_LOCATION );
 
   // Test a transparent text - Rendering should be skipped.
   label.SetProperty( TextLabel::Property::TEXT, "Hello world Hello world" );
@@ -1294,7 +1339,7 @@ int UtcDaliToolkitTextlabelTextStyle01(void)
   tet_infoline(" UtcDaliToolkitTextlabelTextStyle Setting Outline after Shadow");
 
   TextLabel label = TextLabel::New();
-  label.SetSize( 300.0f, 300.f );
+  label.SetProperty( Actor::Property::SIZE, Vector2( 300.0f, 300.f ) );
   label.SetProperty( TextLabel::Property::TEXT, "Hello world Hello world" );
   label.SetProperty( TextLabel::Property::POINT_SIZE, 12 );
   Stage::GetCurrent().Add( label );
@@ -1481,7 +1526,7 @@ int UtcDaliToolkitTextLabelBitmapFont(void)
   application.Render();
 
   // The text has been rendered if the height of the text-label is the height of the line.
-  DALI_TEST_EQUALS( label.GetCurrentSize().height, 34.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+  DALI_TEST_EQUALS( label.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ).height, 34.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
 
   END_TEST;
 }
@@ -1502,7 +1547,7 @@ int UtcDaliToolkitTextlabelTextFit(void)
   tet_infoline(" UtcDaliToolkitTextlabelTextFit");
   TextLabel label = TextLabel::New();
   Vector2 size( 460.0f, 100.0f );
-  label.SetSize( size );
+  label.SetProperty( Actor::Property::SIZE, size );
   label.SetProperty( TextLabel::Property::TEXT, "Hello world" );
 
   // check point size
@@ -1521,7 +1566,7 @@ int UtcDaliToolkitTextlabelTextFit(void)
   application.SendNotification();
   application.Render();
 
-  const Vector3 EXPECTED_NATURAL_SIZE( 460.0f, 98.0f, 0.0f );
+  const Vector3 EXPECTED_NATURAL_SIZE( 452.0f, 94.0f, 0.0f );
   DALI_TEST_EQUALS( EXPECTED_NATURAL_SIZE, label.GetNaturalSize(), TEST_LOCATION );
 
   // check pixel size
@@ -1579,7 +1624,7 @@ int UtcDaliToolkitTextlabelMaxTextureSet(void)
 
   const int maxTextureSize = Dali::GetMaxTextureSize();
   // Whether the rendered text is greater than maxTextureSize
-  DALI_TEST_CHECK( label.GetCurrentSize().height > maxTextureSize );
+  DALI_TEST_CHECK( label.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ).height > maxTextureSize );
 
   // Check if the number of renderers is greater than 1.
   DALI_TEST_CHECK( label.GetRendererCount() > 1u );