[3.0] Change CustomActorImpl destructor to protected
[platform/core/uifw/dali-core.git] / automated-tests / src / dali / utc-Dali-CustomActor.cpp
index afc9fcd..c32c8e7 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2016 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.
@@ -120,7 +120,7 @@ struct TestCustomActor : public CustomActorImpl
   }
 
   // From CustomActorImpl
-  virtual void OnStageConnection( unsigned int depth )
+  virtual void OnStageConnection( int depth )
   {
     AddToCallStacks("OnStageConnection");
     mDepth = depth;
@@ -272,7 +272,7 @@ struct TestCustomActorVariant1 : public TestCustomActor
   }
 
   // From CustomActorImpl
-  virtual void OnStageConnection( unsigned int depth )
+  virtual void OnStageConnection( int depth )
   {
     // Chain up first
     TestCustomActor::OnStageConnection( depth );
@@ -297,7 +297,7 @@ struct TestCustomActorVariant2 : public TestCustomActor
   }
 
   // From CustomActorImpl
-  virtual void OnStageConnection( unsigned int depth )
+  virtual void OnStageConnection( int depth )
   {
     // Chain up first
     TestCustomActor::OnStageConnection( depth );
@@ -375,7 +375,7 @@ struct TestCustomActorVariant5 : public TestCustomActor
   }
 
   // From CustomActorImpl
-  virtual void OnStageConnection( unsigned int depth )
+  virtual void OnStageConnection( int depth )
   {
     // Chain up first
     TestCustomActor::OnStageConnection( depth );
@@ -500,7 +500,7 @@ public:
   }
 
   // From CustomActorImpl
-  virtual void OnStageConnection( unsigned int depth )
+  virtual void OnStageConnection( int depth )
   {
   }
   virtual void OnStageDisconnection()
@@ -823,7 +823,7 @@ int UtcDaliCustomActorImplDestructor(void)
 {
   TestApplication application;
   CustomActorImpl* actor = new Impl::TestCustomActor();
-  delete actor;
+  CustomActor customActor( *actor ); // Will automatically unref at the end of this function
 
   DALI_TEST_CHECK( true );
   END_TEST;
@@ -1567,17 +1567,21 @@ int UtcDaliCustomActorRemoveDuringOnChildRemove(void)
   DALI_TEST_EQUALS( "OnChildRemove",        actorA.GetMethodsCalled()[ 2 ], TEST_LOCATION ); // The actorB added to actorA
   // mContainer will then receive OnChildAdd
 
-  DALI_TEST_EQUALS( 2, (int)(actorB.GetMethodsCalled().size()), TEST_LOCATION );
+  DALI_TEST_EQUALS( 3, (int)(actorB.GetMethodsCalled().size()), TEST_LOCATION );
   DALI_TEST_EQUALS( "OnStageConnection",    actorB.GetMethodsCalled()[ 0 ], TEST_LOCATION );
-  DALI_TEST_EQUALS( "OnChildAdd",           actorB.GetMethodsCalled()[ 1 ], TEST_LOCATION );
+  // The derived class are always notified, no matter the child is successfully removed or not
+  DALI_TEST_EQUALS( "OnChildRemove",        actorB.GetMethodsCalled()[ 1 ], TEST_LOCATION );
+  DALI_TEST_EQUALS( "OnChildAdd",           actorB.GetMethodsCalled()[ 2 ], TEST_LOCATION );
 
-  DALI_TEST_EQUALS( 5, (int)(MasterCallStack.size()), TEST_LOCATION );
+  DALI_TEST_EQUALS( 6, (int)(MasterCallStack.size()), TEST_LOCATION );
 
   DALI_TEST_EQUALS( "ActorB: OnStageConnection",    MasterCallStack[ 0 ], TEST_LOCATION );
   DALI_TEST_EQUALS( "ActorA: OnStageConnection",    MasterCallStack[ 1 ], TEST_LOCATION );
   DALI_TEST_EQUALS( "ActorA: OnChildAdd",           MasterCallStack[ 2 ], TEST_LOCATION );
   DALI_TEST_EQUALS( "ActorA: OnChildRemove",        MasterCallStack[ 3 ], TEST_LOCATION );
-  DALI_TEST_EQUALS( "ActorB: OnChildAdd",           MasterCallStack[ 4 ], TEST_LOCATION );
+  // The derived class are always notified, no matter the child is successfully removed or not
+  DALI_TEST_EQUALS( "ActorB: OnChildRemove",        MasterCallStack[ 4 ], TEST_LOCATION );
+  DALI_TEST_EQUALS( "ActorB: OnChildAdd",           MasterCallStack[ 5 ], TEST_LOCATION );
 
   // Excercise the message passing to Update thread
 
@@ -1664,7 +1668,9 @@ int UtcDaliCustomActorOnTouchEvent(void)
   application.Render();
 
   // simulate a touch event
-  Dali::TouchPoint point( 0, TouchPoint::Down, 1, 1 );
+  Dali::Integration::Point point;
+  point.SetState( PointState::DOWN );
+  point.SetScreenPosition( Vector2( 1, 1 ) );
   Dali::Integration::TouchEvent event;
   event.AddPoint( point );
   application.ProcessEvent( event );
@@ -1695,7 +1701,9 @@ int UtcDaliCustomActorOnHoverEvent(void)
   application.Render();
 
   // simulate a hover event
-  Dali::TouchPoint point( 0, TouchPoint::Motion, 1, 1 );
+  Dali::Integration::Point point;
+  point.SetState( PointState::MOTION );
+  point.SetScreenPosition( Vector2( 1, 1 ) );
   Dali::Integration::HoverEvent event;
   event.AddPoint( point );
   application.ProcessEvent( event );
@@ -1739,12 +1747,12 @@ int UtcDaliCustomActorImplOnPropertySet(void)
 {
   TestApplication application;
   CustomActorImpl* impl = new Impl::SimpleTestCustomActor();
+  CustomActor customActor( *impl ); // Will automatically unref at the end of this function
 
   impl->OnPropertySet( 0, 0 );
 
   DALI_TEST_CHECK( true );
 
-  delete impl;
   END_TEST;
 }