Further Setter/Getter public API removal from Dali::Actor
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / utc-Dali-Visual.cpp
index 0a86423..a0151d2 100644 (file)
@@ -20,6 +20,7 @@
 
 #include <toolkit-event-thread-callback.h>
 #include <dali-toolkit-test-suite-utils.h>
+#include <dali/devel-api/actors/actor-devel.h>
 #include <dali/devel-api/object/handle-devel.h>
 #include <dali/devel-api/text-abstraction/font-client.h>
 #include <dali-toolkit/devel-api/controls/control-devel.h>
@@ -258,7 +259,7 @@ int UtcDaliVisualSetGetDepthIndex(void)
   Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
   dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
 
-  dummyControl.SetSize(200.f, 200.f);
+  dummyControl.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 200.f ) );
   Stage::GetCurrent().Add( dummyControl );
 
 
@@ -420,7 +421,7 @@ int UtcDaliVisualSetOnOffStage(void)
   Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(actor.GetImplementation());
   dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
 
-  actor.SetSize(200.f, 200.f);
+  actor.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 200.f ) );
 
   application.SendNotification();
   application.Render(0);
@@ -456,7 +457,7 @@ int UtcDaliVisualSetOnOffStage2(void)
   Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(actor.GetImplementation());
   dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
 
-  actor.SetSize(200.f, 200.f);
+  actor.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 200.f ) );
 
   application.SendNotification();
   application.Render(0);
@@ -858,7 +859,7 @@ int UtcDaliVisualGetPropertyMap5(void)
 
   value = resultMap.Find( ImageVisual::Property::FITTING_MODE,   Property::INTEGER );
   DALI_TEST_CHECK( value );
-  DALI_TEST_CHECK( value->Get<int>() == FittingMode::SHRINK_TO_FIT );
+  DALI_TEST_CHECK( value->Get<int>() == FittingMode::DEFAULT );
 
   value = resultMap.Find( ImageVisual::Property::SAMPLING_MODE,   Property::INTEGER );
   DALI_TEST_CHECK( value );
@@ -1817,8 +1818,8 @@ int UtcDaliVisualAnimateBorderVisual01(void)
   DummyControl actor = DummyControl::New(true);
   Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(actor.GetImplementation());
   dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, borderVisual );
-  actor.SetSize(2000, 2000);
-  actor.SetParentOrigin(ParentOrigin::CENTER);
+  actor.SetProperty( Actor::Property::SIZE, Vector2( 2000.f, 2000.f ) );
+  actor.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::CENTER);
   Stage::GetCurrent().Add(actor);
 
   DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION);
@@ -1885,8 +1886,8 @@ int UtcDaliVisualAnimateBorderVisual02(void)
   DummyControl actor = DummyControl::New(true);
   Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(actor.GetImplementation());
   dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, borderVisual );
-  actor.SetSize(2000, 2000);
-  actor.SetParentOrigin(ParentOrigin::CENTER);
+  actor.SetProperty( Actor::Property::SIZE, Vector2( 2000.f, 2000.f ) );
+  actor.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::CENTER);
   Stage::GetCurrent().Add(actor);
 
   DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION);
@@ -1929,8 +1930,8 @@ int UtcDaliVisualAnimateColorVisual(void)
   DummyControl actor = DummyControl::New(true);
   Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(actor.GetImplementation());
   dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, borderVisual );
-  actor.SetSize(2000, 2000);
-  actor.SetParentOrigin(ParentOrigin::CENTER);
+  actor.SetProperty( Actor::Property::SIZE, Vector2( 2000.f, 2000.f ) );
+  actor.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::CENTER);
   Stage::GetCurrent().Add(actor);
 
   DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION);
@@ -1984,9 +1985,9 @@ int UtcDaliVisualAnimatePrimitiveVisual(void)
     DummyControl actor = DummyControl::New(true);
     Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(actor.GetImplementation());
     dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
-    actor.SetSize(2000, 2000);
-    actor.SetParentOrigin(ParentOrigin::CENTER);
-    actor.SetColor(Color::BLACK);
+    actor.SetProperty( Actor::Property::SIZE, Vector2( 2000.f, 2000.f ) );
+    actor.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::CENTER);
+    actor.SetProperty( Actor::Property::COLOR,Color::BLACK);
     Stage::GetCurrent().Add(actor);
 
     DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION);
@@ -2032,7 +2033,7 @@ int UtcDaliVisualAnimatePrimitiveVisual(void)
     application.Render(2001u); // go past end
     application.SendNotification(); // Trigger signals
 
-    DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
+    DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ), Color::WHITE, TEST_LOCATION );
     DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue<Vector4>("uColor", Vector4( 1.0f, 1.0f, 1.0f, TARGET_MIX_COLOR.a ) ), true, TEST_LOCATION );
     DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue<Vector3>("mixColor", Vector3(TARGET_MIX_COLOR) ), true, TEST_LOCATION );
 
@@ -2059,9 +2060,9 @@ int UtcDaliVisualAnimatedGradientVisual01(void)
     DummyControl actor = DummyControl::New(true);
     Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(actor.GetImplementation());
     dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
-    actor.SetSize(2000, 2000);
-    actor.SetParentOrigin(ParentOrigin::CENTER);
-    actor.SetColor(Color::BLACK);
+    actor.SetProperty( Actor::Property::SIZE, Vector2( 2000.f, 2000.f ) );
+    actor.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::CENTER);
+    actor.SetProperty( Actor::Property::COLOR,Color::BLACK);
     Stage::GetCurrent().Add(actor);
 
     application.SendNotification();
@@ -2230,9 +2231,9 @@ int UtcDaliVisualAnimatedGradientVisual02(void)
       DummyControl actor = DummyControl::New( true );
       Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>( actor.GetImplementation() );
       dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
-      actor.SetSize( 2000, 2000 );
-      actor.SetParentOrigin(ParentOrigin::CENTER);
-      actor.SetColor(Color::BLACK);
+      actor.SetProperty( Actor::Property::SIZE, Vector2( 2000.f, 2000.f ) );
+      actor.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::CENTER);
+      actor.SetProperty( Actor::Property::COLOR,Color::BLACK);
       Stage::GetCurrent().Add(actor);
 
       application.SendNotification();
@@ -2504,9 +2505,9 @@ int UtcDaliVisualAnimatedGradientVisual03(void)
       DummyControl actor = DummyControl::New( true );
       Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>( actor.GetImplementation() );
       dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
-      actor.SetSize( 2000, 2000 );
-      actor.SetParentOrigin(ParentOrigin::CENTER);
-      actor.SetColor(Color::BLACK);
+      actor.SetProperty( Actor::Property::SIZE, Vector2( 2000.f, 2000.f ) );
+      actor.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::CENTER);
+      actor.SetProperty( Actor::Property::COLOR,Color::BLACK);
       Stage::GetCurrent().Add(actor);
 
       application.SendNotification();
@@ -2792,8 +2793,8 @@ static void TestTransform( ToolkitTestApplication& application, Visual::Base vis
   //Put the visual on the stage
   DummyControl actor = DummyControl::New(true);
   Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(actor.GetImplementation());
-  actor.SetSize(2000, 2000);
-  actor.SetParentOrigin(ParentOrigin::CENTER);
+  actor.SetProperty( Actor::Property::SIZE, Vector2( 2000.f, 2000.f ) );
+  actor.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::CENTER);
   Stage::GetCurrent().Add(actor);
 
   dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
@@ -3102,8 +3103,8 @@ int UtcDaliNPatchVisualCustomShader(void)
   Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummy.GetImplementation());
   dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
   dummyImpl.SetLayout( DummyControl::Property::TEST_VISUAL, transformMap );
-  dummy.SetSize(2000, 2000);
-  dummy.SetParentOrigin(ParentOrigin::CENTER);
+  dummy.SetProperty( Actor::Property::SIZE, Vector2( 2000.f, 2000.f ) );
+  dummy.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::CENTER);
   Stage::GetCurrent().Add(dummy);
   application.SendNotification();
 
@@ -3184,7 +3185,7 @@ int UtcDaliVisualRendererRemovalAndReAddition(void)
   dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
   DALI_TEST_EQUALS( dummyControl.GetRendererCount(), 0, TEST_LOCATION );
 
-  dummyControl.SetSize(200.f, 200.f);
+  dummyControl.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 200.f ) );
   tet_infoline( "Add control with visual to stage and check renderer count is 1" );
 
   Stage::GetCurrent().Add( dummyControl );
@@ -3246,8 +3247,8 @@ int UtcDaliVisualTextVisualRender(void)
   dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, textVisual );
   DALI_TEST_EQUALS( dummyControl.GetRendererCount(), 0, TEST_LOCATION );
 
-  dummyControl.SetSize(200.f, 200.f);
-  dummyControl.SetParentOrigin( ParentOrigin::CENTER );
+  dummyControl.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 200.f ) );
+  dummyControl.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
 
   Stage::GetCurrent().Add( dummyControl );
   application.SendNotification();
@@ -3269,7 +3270,7 @@ int UtcDaliVisualTextVisualRender(void)
   textVisual.SetDepthIndex( 1 );
 
   dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, textVisual );
-  dummyControl.SetSize( 720.f, 640.f );
+  dummyControl.SetProperty( Actor::Property::SIZE, Vector2( 720.f, 640.f ) );
 
   application.SendNotification(); // force process events to ensure text visual
   // adds renderer to the dummy control in OnRelayout
@@ -3315,8 +3316,8 @@ int UtcDaliVisualTextVisualDisableEnable(void)
   dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, textVisual );
   DALI_TEST_EQUALS( dummyControl.GetRendererCount(), 0, TEST_LOCATION );
 
-  dummyControl.SetSize(200.f, 200.f);
-  dummyControl.SetParentOrigin( ParentOrigin::CENTER );
+  dummyControl.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 200.f ) );
+  dummyControl.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
 
   Stage::GetCurrent().Add( dummyControl );
   application.SendNotification();
@@ -3445,7 +3446,7 @@ int UtcDaliRegisterVisualOrder(void)
   dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL2, anotherTestVisual2Replacement );
   DALI_TEST_EQUALS( anotherTestVisual2Replacement.GetDepthIndex(), 2000, TEST_LOCATION );
 
-  dummyControl.SetSize(200.f, 200.f);
+  dummyControl.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 200.f ) );
   Stage::GetCurrent().Add( dummyControl );
 
   END_TEST;
@@ -3481,7 +3482,7 @@ int UtcDaliRegisterVisualOrder02(void)
   dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL2, testVisual2 );
   DALI_TEST_CHECK( testVisual2.GetDepthIndex() >  testVisual1.GetDepthIndex() );
 
-  dummyControl.SetSize(200.f, 200.f);
+  dummyControl.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 200.f ) );
   Stage::GetCurrent().Add( dummyControl );
 
   END_TEST;
@@ -3518,7 +3519,7 @@ int UtcDaliRegisterVisualWithDepthIndex(void)
   DALI_TEST_EQUALS( testVisual3.GetDepthIndex(), 300, TEST_LOCATION );
   DALI_TEST_EQUALS( DevelControl::IsVisualEnabled( dummyImpl, DummyControl::Property::TEST_VISUAL2 ), true, TEST_LOCATION );
 
-  dummyControl.SetSize(200.f, 200.f);
+  dummyControl.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 200.f ) );
   Stage::GetCurrent().Add( dummyControl );
 
   END_TEST;
@@ -3598,8 +3599,8 @@ int UtcDaliSvgVisualCustomShader(void)
   Impl::DummyControl& dummyImpl = static_cast< Impl::DummyControl& >( dummy.GetImplementation() );
   dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
 
-  dummy.SetSize( 200.f, 200.f );
-  dummy.SetParentOrigin( ParentOrigin::CENTER );
+  dummy.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 200.f ) );
+  dummy.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
   Stage::GetCurrent().Add( dummy );
 
   application.SendNotification();
@@ -3644,8 +3645,8 @@ int UtcDaliVisualRoundedCorner(void)
     Impl::DummyControl& dummyImpl = static_cast< Impl::DummyControl& >( dummy.GetImplementation() );
     dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
 
-    dummy.SetSize( 200.f, 200.f );
-    dummy.SetParentOrigin( ParentOrigin::CENTER );
+    dummy.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 200.f ) );
+    dummy.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
     Stage::GetCurrent().Add( dummy );
 
     application.SendNotification();
@@ -3676,8 +3677,53 @@ int UtcDaliVisualRoundedCorner(void)
     Impl::DummyControl& dummyImpl = static_cast< Impl::DummyControl& >( dummy.GetImplementation() );
     dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
 
-    dummy.SetSize( 200.f, 200.f );
-    dummy.SetParentOrigin( ParentOrigin::CENTER );
+    dummy.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 200.f ) );
+    dummy.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
+    Stage::GetCurrent().Add( dummy );
+
+    application.SendNotification();
+    application.Render();
+
+    application.SendNotification();
+    application.Render();
+
+    DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue< float >( "cornerRadius", cornerRadius ), true, TEST_LOCATION );
+  }
+
+  // gradient visual
+  {
+    VisualFactory factory = VisualFactory::Get();
+    Property::Map properties;
+    float cornerRadius = 30.0f;
+
+    properties[Visual::Property::TYPE] = Visual::GRADIENT;
+    properties[ColorVisual::Property::MIX_COLOR] = Color::BLUE;
+    properties[DevelVisual::Property::CORNER_RADIUS] = cornerRadius;
+    properties[GradientVisual::Property::START_POSITION] = Vector2( 0.5f, 0.5f );
+    properties[GradientVisual::Property::END_POSITION] = Vector2( -0.5f, -0.5f );
+    properties[GradientVisual::Property::UNITS] = GradientVisual::Units::USER_SPACE;
+
+    Property::Array stopOffsets;
+    stopOffsets.PushBack( 0.0f );
+    stopOffsets.PushBack( 0.6f );
+    stopOffsets.PushBack( 1.0f );
+    properties[GradientVisual::Property::STOP_OFFSET] = stopOffsets;
+
+    Property::Array stopColors;
+    stopColors.PushBack( Color::RED );
+    stopColors.PushBack( Color::YELLOW );
+    stopColors.PushBack( Color::GREEN );
+    properties[GradientVisual::Property::STOP_COLOR] = stopColors;
+
+    Visual::Base visual = factory.CreateVisual( properties );
+
+    // trigger creation through setting on stage
+    DummyControl dummy = DummyControl::New( true );
+    Impl::DummyControl& dummyImpl = static_cast< Impl::DummyControl& >( dummy.GetImplementation() );
+    dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
+
+    dummy.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 200.f ) );
+    dummy.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
     Stage::GetCurrent().Add( dummy );
 
     application.SendNotification();
@@ -3712,8 +3758,8 @@ int UtcDaliColorVisualBlurRadius(void)
   Impl::DummyControl& dummyImpl = static_cast< Impl::DummyControl& >( dummy.GetImplementation() );
   dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
 
-  dummy.SetSize( 200.f, 200.f );
-  dummy.SetParentOrigin( ParentOrigin::CENTER );
+  dummy.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 200.f ) );
+  dummy.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
   Stage::GetCurrent().Add( dummy );
 
   application.SendNotification();