+ actor3.SetProperty( Actor::Property::LAYOUT_DIRECTION, "RIGHT_TO_LEFT" );
+ actor5.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT );
+
+ DALI_TEST_EQUALS( actor8.GetProperty< bool >( Actor::Property::INHERIT_LAYOUT_DIRECTION ), true, TEST_LOCATION );
+ actor8.SetProperty( Actor::Property::INHERIT_LAYOUT_DIRECTION, false );
+ DALI_TEST_EQUALS( actor8.GetProperty< bool >( Actor::Property::INHERIT_LAYOUT_DIRECTION ), false, TEST_LOCATION );
+
+ actor7.SetProperty( Actor::Property::LAYOUT_DIRECTION, "RIGHT_TO_LEFT" );
+
+ DALI_TEST_EQUALS( actor3.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
+ DALI_TEST_EQUALS( actor4.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
+ DALI_TEST_EQUALS( actor5.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
+ DALI_TEST_EQUALS( actor6.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
+ DALI_TEST_EQUALS( actor7.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
+ DALI_TEST_EQUALS( actor8.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
+ DALI_TEST_EQUALS( actor9.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
+
+ actor8.SetProperty( Actor::Property::LAYOUT_DIRECTION, "RIGHT_TO_LEFT" );
+ DALI_TEST_EQUALS( actor8.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
+ DALI_TEST_EQUALS( actor9.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
+
+ actor7.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT );
+ DALI_TEST_EQUALS( actor7.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
+ DALI_TEST_EQUALS( actor8.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
+ DALI_TEST_EQUALS( actor9.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
+
+ actor8.SetProperty( Actor::Property::INHERIT_LAYOUT_DIRECTION, true );
+ DALI_TEST_EQUALS( actor8.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
+ DALI_TEST_EQUALS( actor9.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
+
+ END_TEST;
+}
+
+
+struct LayoutDirectionFunctor
+{
+ LayoutDirectionFunctor(bool& signalCalled)
+ : mSignalCalled( signalCalled )
+ {
+ }
+
+ LayoutDirectionFunctor(const LayoutDirectionFunctor& rhs)
+ : mSignalCalled( rhs.mSignalCalled )
+ {
+ }
+
+ void operator()()
+ {
+ mSignalCalled = true;
+ }
+
+ bool& mSignalCalled;
+};
+
+int UtcDaliActorLayoutDirectionSignal(void)
+{
+ TestApplication application;
+ tet_infoline( "Check changing layout direction property sends a signal" );
+
+ Actor actor = Actor::New();
+ DALI_TEST_EQUALS( actor.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
+ Stage::GetCurrent().Add( actor );
+ bool signalCalled = false;
+ LayoutDirectionFunctor layoutDirectionFunctor(signalCalled);
+
+ actor.ConnectSignal( &application, "layoutDirectionChanged", layoutDirectionFunctor );
+ DALI_TEST_EQUALS( signalCalled, false, TEST_LOCATION );
+
+ // Test that writing the same value doesn't send a signal
+ actor.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT );
+ DALI_TEST_EQUALS( signalCalled, false, TEST_LOCATION );
+
+ // Test that writing a different value sends the signal
+ signalCalled = false;
+ actor.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
+ DALI_TEST_EQUALS( signalCalled, true, TEST_LOCATION );
+
+ signalCalled = false;
+ actor.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
+ DALI_TEST_EQUALS( signalCalled, false, TEST_LOCATION );
+
+ END_TEST;
+}
+
+struct ChildAddedSignalCheck
+{
+ ChildAddedSignalCheck( bool& signalReceived, Actor& childHandle )
+ : mSignalReceived( signalReceived ),
+ mChildHandle( childHandle )
+ {
+ }
+
+ void operator() ( Actor childHandle )
+ {
+ mSignalReceived = true;
+ mChildHandle = childHandle;
+ }
+ void operator() ()
+ {
+ mSignalReceived = true;
+ mChildHandle = Actor();
+ }
+
+ bool& mSignalReceived;
+ Actor& mChildHandle;
+};
+
+int UtcDaliChildAddedSignalP1(void)
+{
+ TestApplication application;
+ auto stage = Stage::GetCurrent();
+
+ bool signalReceived=false;
+ Actor childActor;
+
+ ChildAddedSignalCheck signal( signalReceived, childActor );
+ DevelActor::ChildAddedSignal( stage.GetRootLayer() ).Connect( &application, signal );
+ DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
+
+ auto actorA = Actor::New();
+ stage.Add( actorA );
+ DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
+ DALI_TEST_EQUALS( childActor, actorA, TEST_LOCATION );
+ signalReceived = false;
+
+ auto actorB = Actor::New();
+ stage.Add( actorB );
+ DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
+ DALI_TEST_EQUALS( childActor, actorB, TEST_LOCATION );
+
+ END_TEST;
+}
+
+
+int UtcDaliChildAddedSignalP2(void)
+{
+ TestApplication application;
+ auto stage = Stage::GetCurrent();
+
+ bool signalReceived=false;
+ Actor childActor;
+
+ ChildAddedSignalCheck signal( signalReceived, childActor );
+ tet_infoline( "Connect to childAdded signal by name" );
+
+ stage.GetRootLayer().ConnectSignal( &application, "childAdded", signal );
+ DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
+
+ auto actorA = Actor::New();
+ stage.Add( actorA );
+ DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
+
+ // Can't test which actor was added; signal signature is void() when connecting via name.
+ signalReceived = false;
+
+ auto actorB = Actor::New();
+ stage.Add( actorB );
+ DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliChildAddedSignalN(void)
+{
+ TestApplication application;
+ auto stage = Stage::GetCurrent();
+
+ bool signalReceived=false;
+ Actor childActor;
+
+ ChildAddedSignalCheck signal( signalReceived, childActor );
+ DevelActor::ChildAddedSignal( stage.GetRootLayer() ).Connect( &application, signal );
+ DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
+
+ auto actorA = Actor::New();
+ stage.Add( actorA );
+ DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
+ DALI_TEST_EQUALS( childActor, actorA, TEST_LOCATION );
+ signalReceived = false;
+
+ auto actorB = Actor::New();
+ actorA.Add( actorB );
+ DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
+ END_TEST;
+}
+
+
+struct ChildRemovedSignalCheck
+{
+ ChildRemovedSignalCheck( bool& signalReceived, Actor& childHandle )
+ : mSignalReceived( signalReceived ),
+ mChildHandle( childHandle )
+ {
+ }
+
+ void operator() ( Actor childHandle )
+ {
+ mSignalReceived = true;
+ mChildHandle = childHandle;
+ }
+
+ void operator() ()
+ {
+ mSignalReceived = true;
+ }
+
+ bool& mSignalReceived;
+ Actor& mChildHandle;
+};
+
+int UtcDaliChildRemovedSignalP1(void)
+{
+ TestApplication application;
+ auto stage = Stage::GetCurrent();
+
+ bool signalReceived=false;
+ Actor childActor;
+
+ ChildRemovedSignalCheck signal( signalReceived, childActor );
+ DevelActor::ChildRemovedSignal( stage.GetRootLayer() ).Connect( &application, signal );
+ DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
+
+ auto actorA = Actor::New();
+ stage.Add( actorA );
+ DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
+ DALI_TEST_CHECK( !childActor );
+
+ stage.Remove( actorA );
+ DALI_TEST_EQUALS( childActor, actorA, TEST_LOCATION );
+ DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
+
+ signalReceived = false;
+ auto actorB = Actor::New();
+ stage.Add( actorB );
+ DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
+
+ stage.Remove( actorB );
+ DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
+ DALI_TEST_EQUALS( childActor, actorB, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliChildRemovedSignalP2(void)
+{
+ TestApplication application;
+ auto stage = Stage::GetCurrent();
+
+ bool signalReceived=false;
+ Actor childActor;
+
+ ChildAddedSignalCheck signal( signalReceived, childActor );
+ tet_infoline( "Connect to childRemoved signal by name" );
+
+ stage.GetRootLayer().ConnectSignal( &application, "childRemoved", signal );
+ DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
+
+ auto actorA = Actor::New();
+ stage.Add( actorA );
+ DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
+
+ stage.Remove( actorA );
+ DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
+
+ signalReceived = false;
+ auto actorB = Actor::New();
+ stage.Add( actorB );
+ DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
+
+ stage.Remove( actorB );
+ DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
+
+ END_TEST;
+}
+
+
+int UtcDaliChildRemovedSignalN(void)
+{
+ TestApplication application;
+ auto stage = Stage::GetCurrent();
+
+ bool signalReceived=false;
+ Actor childActor;
+
+ ChildRemovedSignalCheck signal( signalReceived, childActor );
+ DevelActor::ChildRemovedSignal( stage.GetRootLayer() ).Connect( &application, signal );
+ DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
+
+ auto actorA = Actor::New();
+ stage.Add( actorA );
+
+ auto actorB = Actor::New();
+ actorA.Add( actorB );
+
+ DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
+ DALI_TEST_CHECK( ! childActor );
+
+ actorA.Remove( actorB );
+ DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
+ END_TEST;
+}
+
+
+int UtcDaliChildMovedSignalP(void)
+{
+ TestApplication application;
+ auto stage = Stage::GetCurrent();
+
+ bool addedASignalReceived = false;
+ bool removedASignalReceived = false;
+ bool addedBSignalReceived = false;
+ bool removedBSignalReceived = false;
+ Actor childActor;
+
+ auto actorA = Actor::New();
+ auto actorB = Actor::New();
+ stage.Add( actorA );
+ stage.Add( actorB );
+
+ ChildAddedSignalCheck addedSignalA( addedASignalReceived, childActor );
+ ChildRemovedSignalCheck removedSignalA( removedASignalReceived, childActor );
+ ChildAddedSignalCheck addedSignalB( addedBSignalReceived, childActor );
+ ChildRemovedSignalCheck removedSignalB( removedBSignalReceived, childActor );
+
+ DevelActor::ChildAddedSignal( actorA ).Connect( &application, addedSignalA );
+ DevelActor::ChildRemovedSignal( actorA ).Connect( &application, removedSignalA );
+ DevelActor::ChildAddedSignal( actorB ).Connect( &application, addedSignalB );
+ DevelActor::ChildRemovedSignal( actorB ).Connect( &application, removedSignalB );
+
+ DALI_TEST_EQUALS( addedASignalReceived, false, TEST_LOCATION );
+ DALI_TEST_EQUALS( removedASignalReceived, false, TEST_LOCATION );
+ DALI_TEST_EQUALS( addedBSignalReceived, false, TEST_LOCATION );
+ DALI_TEST_EQUALS( removedBSignalReceived, false, TEST_LOCATION );
+
+ // Create a child of A
+
+ auto child = Actor::New();
+ actorA.Add( child );
+
+ DALI_TEST_EQUALS( addedASignalReceived, true, TEST_LOCATION );
+ DALI_TEST_EQUALS( removedASignalReceived, false, TEST_LOCATION );
+ DALI_TEST_EQUALS( addedBSignalReceived, false, TEST_LOCATION );
+ DALI_TEST_EQUALS( removedBSignalReceived, false, TEST_LOCATION );
+ DALI_TEST_EQUALS( childActor, child, TEST_LOCATION );
+
+ // Move child to B:
+ addedASignalReceived = false;
+ addedBSignalReceived = false;
+ removedASignalReceived = false;
+ removedBSignalReceived = false;
+
+ actorB.Add( child ); // Expect this child to be re-parented
+ DALI_TEST_EQUALS( addedASignalReceived, false, TEST_LOCATION );
+ DALI_TEST_EQUALS( removedASignalReceived, true, TEST_LOCATION );
+ DALI_TEST_EQUALS( addedBSignalReceived, true, TEST_LOCATION );
+ DALI_TEST_EQUALS( removedBSignalReceived, false, TEST_LOCATION );
+
+ // Move child back to A:
+ addedASignalReceived = false;
+ addedBSignalReceived = false;
+ removedASignalReceived = false;
+ removedBSignalReceived = false;
+
+ actorA.Add( child ); // Expect this child to be re-parented
+ DALI_TEST_EQUALS( addedASignalReceived, true, TEST_LOCATION );
+ DALI_TEST_EQUALS( removedASignalReceived, false, TEST_LOCATION );
+ DALI_TEST_EQUALS( addedBSignalReceived, false, TEST_LOCATION );
+ DALI_TEST_EQUALS( removedBSignalReceived, true, TEST_LOCATION );
+
+
+ END_TEST;
+}
+
+int utcDaliActorCulled(void)
+{
+ TestApplication application;
+ auto stage = Stage::GetCurrent();
+
+ tet_infoline( "Check that the actor is culled if the actor is out of the screen" );
+
+ Actor actor = Actor::New();
+ actor.SetSize( 10.0f, 10.0f );
+
+ Geometry geometry = CreateQuadGeometry();
+ Shader shader = CreateShader();
+ Renderer renderer = Renderer::New(geometry, shader);
+ actor.AddRenderer( renderer );
+
+ stage.Add( actor );
+
+ application.SendNotification();
+ application.Render( 0 );
+
+ DALI_TEST_EQUALS( actor.GetProperty< bool >( DevelActor::Property::CULLED ), false, TEST_LOCATION );
+
+ PropertyNotification notification = actor.AddPropertyNotification( DevelActor::Property::CULLED, LessThanCondition( 0.5f ) );
+ notification.SetNotifyMode( PropertyNotification::NotifyOnChanged );
+
+ // Connect NotifySignal
+ bool propertyNotificationSignal( false );
+ PropertyNotification source;
+ CulledPropertyNotificationFunctor f( propertyNotificationSignal, source );
+ notification.NotifySignal().Connect( &application, f ) ;
+
+ actor.SetPosition( 1000.0f, 1000.0f );
+
+ application.SendNotification();
+ application.Render();
+
+ application.SendNotification();
+
+ DALI_TEST_EQUALS( actor.GetProperty< bool >( DevelActor::Property::CULLED ), true, TEST_LOCATION );
+
+ DALI_TEST_EQUALS( propertyNotificationSignal, true, TEST_LOCATION );
+ DALI_TEST_EQUALS( source.GetTargetProperty(), static_cast< int >( DevelActor::Property::CULLED ), TEST_LOCATION );
+ DALI_TEST_EQUALS( source.GetTarget().GetProperty< bool >( source.GetTargetProperty() ), true, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliActorUpdateSizeHint(void)
+{
+ TestApplication application;
+
+ Actor actor = Actor::New();
+ Vector3 vector(100.0f, 100.0f, 0.0f);
+
+ DALI_TEST_CHECK(vector != actor.GetCurrentSize());
+
+ actor.SetSize(vector.x, vector.y);
+
+
+ Vector2 updateSizeHint = Vector2(150.f, 150.f);
+ actor.SetProperty(Dali::DevelActor::Property::UPDATE_SIZE_HINT, updateSizeHint);
+
+ // Flush the queue and render once
+ application.SendNotification();
+ application.Render();
+
+
+ Vector2 currentSizeHint = actor.GetProperty( Dali::DevelActor::Property::UPDATE_SIZE_HINT ).Get< Vector2 >();
+ DALI_TEST_EQUALS( currentSizeHint, updateSizeHint, Math::MACHINE_EPSILON_0, TEST_LOCATION );
+
+ // Flush the queue and render once
+ application.SendNotification();
+ application.Render();
+
+ END_TEST;
+}
+
+int utcDaliEnsureRenderWhenRemovingLastRenderableActor(void)
+{
+ TestApplication application;
+ auto stage = Stage::GetCurrent();
+
+ tet_infoline( "Ensure we clear the screen when the last actor is removed" );
+
+ Actor actor = CreateRenderableActor();
+ actor.SetSize( 100.0f, 100.0f );
+ stage.Add( actor );
+
+ application.SendNotification();
+ application.Render();
+
+ auto& glAbstraction = application.GetGlAbstraction();
+ const auto clearCountBefore = glAbstraction.GetClearCountCalled();
+
+ actor.Unparent();
+
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS( glAbstraction.GetClearCountCalled(), clearCountBefore + 1, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int utcDaliEnsureRenderWhenMakingLastActorInvisible(void)
+{
+ TestApplication application;
+ auto stage = Stage::GetCurrent();
+
+ tet_infoline( "Ensure we clear the screen when the last actor is made invisible" );
+
+ Actor actor = CreateRenderableActor();
+ actor.SetSize( 100.0f, 100.0f );
+ stage.Add( actor );
+
+ application.SendNotification();
+ application.Render();
+
+ auto& glAbstraction = application.GetGlAbstraction();
+ const auto clearCountBefore = glAbstraction.GetClearCountCalled();
+
+ actor.SetVisible( false );
+
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS( glAbstraction.GetClearCountCalled(), clearCountBefore + 1, TEST_LOCATION );