Remove non-public APIs of Animation
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / utc-Dali-ControlImpl.cpp
index 5d0e4ab..3d0a489 100644 (file)
@@ -21,6 +21,7 @@
 // Need to override adaptor classes for toolkit test harness, so include
 // test harness headers before dali headers.
 #include <dali-toolkit-test-suite-utils.h>
+#include "toolkit-style-monitor.h"
 
 #include <dali.h>
 #include <dali-toolkit/dali-toolkit.h>
@@ -217,7 +218,8 @@ int UtcDaliControlImplOnGestureMethods(void)
   // Check gesture actually happens
   {
     DummyControl dummy = DummyControl::New(true);
-    dummy.SetSize( Vector3(100.0f, 100.0f, 100.0f) );
+    dummy.SetRelayoutEnabled( true );
+    dummy.SetPreferredSize( Vector2(100.0f, 100.0f ) );
 
     dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT);
     Stage::GetCurrent().Add(dummy);
@@ -277,7 +279,8 @@ int UtcDaliControlImplOnGestureMethods(void)
   // Ensure full code coverage
   {
     DummyControl dummy = DummyControl::New();
-    dummy.SetSize( Vector3(100.0f, 100.0f, 100.0f) );
+    dummy.SetRelayoutEnabled( true );
+    dummy.SetPreferredSize( Vector2( 100.0f, 100.0f ) );
 
     dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT);
     Stage::GetCurrent().Add(dummy);
@@ -442,22 +445,23 @@ int UtcDaliControlImplSizeSet(void)
 
   {
     DummyControl dummy = DummyControl::New( true );
+    dummy.SetRelayoutEnabled( true );
     DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
 
     Stage::GetCurrent().Add(dummy);
     application.Render();
     application.SendNotification();
 
-    DALI_TEST_EQUALS( dummyImpl.sizeSetCalled, false, TEST_LOCATION );
-    Vector3 size(100.0f, 200.0f, 0.0f);
-    dummy.SetSize(size);
+    DALI_TEST_EQUALS( dummyImpl.sizeSetCalled, true, TEST_LOCATION ); // Called from size negotiation
+    Vector2 size(100.0f, 200.0f);
+    dummy.SetPreferredSize(size);
 
     application.Render();
     application.SendNotification();
     application.Render();
     application.SendNotification();
 
-    DALI_TEST_EQUALS(size, dummy.GetCurrentSize(), TEST_LOCATION);
+    DALI_TEST_EQUALS(size, dummy.GetCurrentSize().GetVectorXY(), TEST_LOCATION);
     DALI_TEST_EQUALS( dummyImpl.sizeSetCalled, true, TEST_LOCATION );
 
     Stage::GetCurrent().Remove(dummy);
@@ -466,22 +470,23 @@ int UtcDaliControlImplSizeSet(void)
   // Ensure full code coverage
   {
     DummyControl dummy = DummyControl::New();
+    dummy.SetRelayoutEnabled( true );
     Stage::GetCurrent().Add(dummy);
 
-    Vector3 size(100.0f, 200.0f, 0.0f);
-    DALI_TEST_CHECK( size != dummy.GetCurrentSize() );
+    Vector2 size(100.0f, 200.0f);
+    DALI_TEST_CHECK( size != dummy.GetCurrentSize().GetVectorXY() );
 
     application.Render();
     application.SendNotification();
 
-    dummy.SetSize(size);
+    dummy.SetPreferredSize(size);
 
     application.Render();
     application.SendNotification();
     application.Render();
     application.SendNotification();
 
-    DALI_TEST_EQUALS(size, dummy.GetCurrentSize(), TEST_LOCATION);
+    DALI_TEST_EQUALS(size, dummy.GetCurrentSize().GetVectorXY(), TEST_LOCATION);
 
     Stage::GetCurrent().Remove(dummy);
   }
@@ -500,7 +505,7 @@ int UtcDaliControlImplSizeAnimation(void)
 
     DALI_TEST_EQUALS( dummyImpl.sizeAnimationCalled, false, TEST_LOCATION );
     Animation animation = Animation::New(1.0f);
-    animation.Resize(dummy, Vector3(100.0f, 150.0f, 200.0f));
+    animation.AnimateTo( Property( dummy, Actor::Property::SIZE ), Vector3( 100.0f, 150.0f, 200.0f ) );
     animation.Play();
 
     application.Render();
@@ -520,7 +525,7 @@ int UtcDaliControlImplSizeAnimation(void)
     Stage::GetCurrent().Add(dummy);
 
     Animation animation = Animation::New(1.0f);
-    animation.Resize(dummy, Vector3(100.0f, 150.0f, 200.0f));
+    animation.AnimateTo( Property( dummy, Actor::Property::SIZE ), Vector3( 100.0f, 150.0f, 200.0f ) );
     animation.Play();
 
     application.Render();
@@ -541,9 +546,10 @@ int UtcDaliControlImplTouchEvent(void)
 
   {
     DummyControl dummy = DummyControl::New( true );
+    dummy.SetRelayoutEnabled( true );
     DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
 
-    dummy.SetSize(100.0f, 100.0f);
+    dummy.SetPreferredSize( Vector2( 100.0f, 100.0f ) );
     dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT);
     Stage::GetCurrent().Add(dummy);
 
@@ -565,8 +571,9 @@ int UtcDaliControlImplTouchEvent(void)
   // Ensure full code coverage
   {
     DummyControl dummy = DummyControl::New();
+    dummy.SetRelayoutEnabled( true );
 
-    dummy.SetSize(100.0f, 100.0f);
+    dummy.SetPreferredSize( Vector2( 100.0f, 100.0f ) );
     dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT);
     Stage::GetCurrent().Add(dummy);
 
@@ -656,7 +663,7 @@ int UtcDaliControlImplStyleChange(void)
   DALI_TEST_EQUALS( dummyImpl.fontChangeCalled, false, TEST_LOCATION );
   StyleChange styleChange;
   styleChange.defaultFontChange = true;
-  Dali::StyleMonitor styleMonitor = application.GetAdaptor().GetToolkitStyleMonitor();
+  Dali::StyleMonitor styleMonitor = StyleMonitor::Get();
   styleMonitor.EmitStyleChangeSignal(styleChange);
 
   DALI_TEST_EQUALS( dummyImpl.fontChangeCalled, true, TEST_LOCATION );
@@ -733,3 +740,86 @@ int UtcDaliControlImplKeyInputFocusLost(void)
   }
   END_TEST;
 }
+
+int UtcDaliControlImplTypeRegistry(void)
+{
+  ToolkitTestApplication application;
+
+  // Register Type
+  TypeInfo type;
+  type = TypeRegistry::Get().GetTypeInfo( "Control" );
+  DALI_TEST_CHECK( type );
+  BaseHandle handle = type.CreateInstance();
+  DALI_TEST_CHECK( handle );
+
+  // Check if it's a control
+  DALI_TEST_CHECK( Control::DownCast(handle) );
+  END_TEST;
+}
+
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+namespace
+{
+static bool MouseWheelEventCallback(Actor actor, const MouseWheelEvent& event)
+{
+  return false;
+}
+}
+
+int UtcDaliControlImplMouseWheelEvent(void)
+{
+  ToolkitTestApplication application;
+
+  {
+    DummyControl dummy = DummyControl::New( true );
+    dummy.SetRelayoutEnabled( true );
+    DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
+
+    dummy.SetPreferredSize( Vector2( 100.0f, 100.0f ) );
+    dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT);
+    Stage::GetCurrent().Add(dummy);
+
+    dummy.MouseWheelEventSignal().Connect(&MouseWheelEventCallback);
+
+    application.Render();
+    application.SendNotification();
+    application.Render();
+    application.SendNotification();
+
+    DALI_TEST_EQUALS( dummyImpl.mouseWheelEventCalled, false, TEST_LOCATION );
+
+    // simulate a mouse wheel event
+    Vector2 screenCoordinates( 10.0f, 10.0f );
+    Integration::MouseWheelEvent event(0, 0u, screenCoordinates, 1, 1000u);
+    application.ProcessEvent(event);
+    DALI_TEST_EQUALS( dummyImpl.mouseWheelEventCalled, true, TEST_LOCATION );
+
+    Stage::GetCurrent().Remove(dummy);
+  }
+
+  // Ensure full code coverage
+  {
+    DummyControl dummy = DummyControl::New();
+    dummy.SetRelayoutEnabled( true );
+
+    dummy.SetPreferredSize( Vector2( 100.0f, 100.0f ) );
+    dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT);
+    Stage::GetCurrent().Add(dummy);
+
+    dummy.MouseWheelEventSignal().Connect(&MouseWheelEventCallback);
+
+    application.Render();
+    application.SendNotification();
+    application.Render();
+    application.SendNotification();
+
+    // simulate a mouse wheel event
+    Vector2 screenCoordinates( 20.0f, 20.0f );
+    Integration::MouseWheelEvent event(0, 0u, screenCoordinates, 1, 1000u);
+    application.ProcessEvent(event);
+
+    Stage::GetCurrent().Remove(dummy);
+  }
+  END_TEST;
+}