Merge "Updated test harness behaviour" into tizen
[platform/core/uifw/dali-core.git] / automated-tests / src / dali / utc-Dali-CustomActor.cpp
index 1f961a2..aa10dd3 100644 (file)
 
 #include <iostream>
 #include <stdlib.h>
-#include <dali/dali.h>
+#include <dali/public-api/dali-core.h>
 
 #include <dali/integration-api/events/touch-event-integ.h>
+#include <dali/integration-api/events/hover-event-integ.h>
 #include <dali/integration-api/events/mouse-wheel-event-integ.h>
 #include <dali/integration-api/events/key-event-integ.h>
 
@@ -61,6 +62,7 @@ struct TestCustomActor : public CustomActorImpl
     mTargetSize( Vector3::ZERO )
   {
     SetRequiresMouseWheelEvents(true);
+    SetRequiresHoverEvents(true);
   }
 
   /**
@@ -144,6 +146,11 @@ struct TestCustomActor : public CustomActorImpl
     AddToCallStacks("OnTouchEvent");
     return true;
   }
+  virtual bool OnHoverEvent(const HoverEvent& event)
+  {
+    AddToCallStacks("OnHoverEvent");
+    return true;
+  }
   virtual bool OnMouseWheelEvent(const MouseWheelEvent& event)
   {
     AddToCallStacks("OnMouseWheelEvent");
@@ -176,6 +183,11 @@ struct TestCustomActor : public CustomActorImpl
     }
   }
 
+  virtual Vector3 GetNaturalSize()
+  {
+    return Vector3( 0.0f, 0.0f, 0.0f );
+  }
+
   void SetDaliProperty(std::string s)
   {
     Self().SetProperty(mDaliProperty, s) ;
@@ -451,6 +463,10 @@ public:
   {
     return true;
   }
+  virtual bool OnHoverEvent(const HoverEvent& event)
+  {
+    return true;
+  }
   virtual bool OnMouseWheelEvent(const MouseWheelEvent& event)
   {
     return true;
@@ -470,6 +486,11 @@ public:
   {
     return Actor();
   }
+
+  virtual Vector3 GetNaturalSize()
+  {
+    return Vector3( 0.0f, 0.0f, 0.0f );
+  }
 };
 
 } ; // namespace Impl
@@ -609,6 +630,11 @@ public:
     return GetImpl().mTargetSize;
   }
 
+  virtual Vector3 GetNaturalSize()
+  {
+    return Vector3( 0.0f, 0.0f, 0.0f );
+  }
+
 private:
 
   TestCustomActor( Impl::TestCustomActor& impl ) : CustomActor( impl )
@@ -1497,6 +1523,37 @@ int UtcDaliCustomActorOnTouchEvent(void)
   END_TEST;
 }
 
+int UtcDaliCustomActorOnHoverEvent(void)
+{
+  TestApplication application;
+  tet_infoline("Testing Dali::CustomActor::OnHoverEvent()");
+
+  TestCustomActor custom = TestCustomActor::New();
+  DALI_TEST_EQUALS( 0, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
+
+  // set size for custom actor
+  custom.SetSize( 100, 100 );
+  // add the custom actor to stage
+  Stage::GetCurrent().Add( custom );
+  custom.ResetCallStack();
+
+  // Render and notify a couple of times
+  application.SendNotification();
+  application.Render();
+  application.SendNotification();
+  application.Render();
+
+  // simulate a hover event
+  Dali::TouchPoint point( 0, TouchPoint::Motion, 1, 1 );
+  Dali::Integration::HoverEvent event;
+  event.AddPoint( point );
+  application.ProcessEvent( event );
+
+  DALI_TEST_EQUALS( 1, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
+  DALI_TEST_EQUALS( "OnHoverEvent", custom.GetMethodsCalled()[ 0 ], TEST_LOCATION );
+  END_TEST;
+}
+
 int UtcDaliCustomActorOnMouseWheelEvent(void)
 {
   TestApplication application;