/*
- * 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.
mDaliProperty( Property::INVALID_INDEX ),
mSizeSet( Vector3::ZERO ),
mTargetSize( Vector3::ZERO ),
- mNego( false )
+ mNego( false ),
+ mDepth(0u)
{
}
}
// From CustomActorImpl
- virtual void OnStageConnection()
+ virtual void OnStageConnection( int depth )
{
AddToCallStacks("OnStageConnection");
+ mDepth = depth;
}
virtual void OnStageDisconnection()
{
Vector3 mSizeSet;
Vector3 mTargetSize;
bool mNego;
+ unsigned int mDepth;
};
/**
}
// From CustomActorImpl
- virtual void OnStageConnection()
+ virtual void OnStageConnection( int depth )
{
// Chain up first
- TestCustomActor::OnStageConnection();
+ TestCustomActor::OnStageConnection( depth );
// Add the child
Self().Add( mChildToAdd );
}
// From CustomActorImpl
- virtual void OnStageConnection()
+ virtual void OnStageConnection( int depth )
{
// Chain up first
- TestCustomActor::OnStageConnection();
+ TestCustomActor::OnStageConnection( depth );
// Remove all the children
for( unsigned int i=0, num=Self().GetChildCount(); i<num; ++i )
}
// From CustomActorImpl
- virtual void OnStageConnection()
+ virtual void OnStageConnection( int depth )
{
// Chain up first
- TestCustomActor::OnStageConnection();
+ TestCustomActor::OnStageConnection( depth );
// Take parent off-stage
Actor parent = Self().GetParent();
}
// From CustomActorImpl
- virtual void OnStageConnection()
+ virtual void OnStageConnection( int depth )
{
}
virtual void OnStageDisconnection()
return GetImpl().TestRelayoutDependentOnChildrenBase( dimension );
}
+ unsigned int GetDepth()
+ {
+ return GetImpl().mDepth;
+ }
private:
TestCustomActor( Impl::TestCustomActor& impl ) : CustomActor( impl )
{
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;
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
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 );
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 );
{
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;
}
END_TEST;
}
+
+int UtcDaliCustomActorOnConnectionDepth(void)
+{
+ TestApplication application;
+ tet_infoline("Testing Dali::CustomActor::OnStageConnection() hierarchy depth");
+
+ Stage stage = Stage::GetCurrent();
+
+ /* Build tree of actors:
+ *
+ * Depth
+ *
+ * A (parent) 1
+ * / \
+ * B C 2
+ * / \ \
+ * D E F 3
+ *
+ * OnStageConnection should return 1 for A, 2 for B and C, and 3 for D, E and F.
+ */
+
+ TestCustomActor actorA = TestCustomActor::New();
+ stage.Add( actorA );
+
+ TestCustomActor actorB = TestCustomActor::New();
+ actorA.Add( actorB );
+
+ TestCustomActor actorC = TestCustomActor::New();
+ actorA.Add( actorC );
+
+ TestCustomActor actorD = TestCustomActor::New();
+ actorB.Add( actorD );
+
+ TestCustomActor actorE = TestCustomActor::New();
+ actorB.Add( actorE );
+
+ TestCustomActor actorF = TestCustomActor::New();
+ actorC.Add( actorF );
+
+ // Excercise the message passing to Update thread
+ application.SendNotification();
+ application.Render();
+ application.Render();
+
+ DALI_TEST_EQUALS( 1u, actorA.GetDepth(), TEST_LOCATION );
+ DALI_TEST_EQUALS( 2u, actorB.GetDepth(), TEST_LOCATION );
+ DALI_TEST_EQUALS( 2u, actorC.GetDepth(), TEST_LOCATION );
+ DALI_TEST_EQUALS( 3u, actorD.GetDepth(), TEST_LOCATION );
+ DALI_TEST_EQUALS( 3u, actorE.GetDepth(), TEST_LOCATION );
+ DALI_TEST_EQUALS( 3u, actorF.GetDepth(), TEST_LOCATION );
+
+ END_TEST;
+}