+int utcDaliActorVisibilityChangeSignalSelf(void)
+{
+ TestApplication application;
+ tet_infoline( "Check that the visibility change signal is called when the visibility changes for the actor itself" );
+
+ Actor actor = Actor::New();
+
+ VisibilityChangedFunctorData data;
+ DevelActor::VisibilityChangedSignal( actor ).Connect( &application, VisibilityChangedFunctor( data ) );
+
+ actor.SetVisible( false );
+
+ data.Check( true /* called */, actor, false /* not visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION );
+
+ tet_infoline( "Ensure functor is not called if we attempt to change the visibility to what it already is at" );
+ data.Reset();
+
+ actor.SetVisible( false );
+ data.Check( false /* not called */, TEST_LOCATION );
+
+ tet_infoline( "Change the visibility using properties, ensure called" );
+ data.Reset();
+
+ actor.SetProperty( Actor::Property::VISIBLE, true );
+ data.Check( true /* called */, actor, true /* visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION );
+
+ tet_infoline( "Set the visibility to current using properties, ensure not called" );
+ data.Reset();
+
+ actor.SetProperty( Actor::Property::VISIBLE, true );
+ data.Check( false /* not called */, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int utcDaliActorVisibilityChangeSignalChildren(void)
+{
+ TestApplication application;
+ tet_infoline( "Check that the visibility change signal is called for the children when the visibility changes for the parent" );
+
+ Actor parent = Actor::New();
+ Actor child = Actor::New();
+ parent.Add( child );
+
+ Actor grandChild = Actor::New();
+ child.Add( grandChild );
+
+ VisibilityChangedFunctorData parentData;
+ VisibilityChangedFunctorData childData;
+ VisibilityChangedFunctorData grandChildData;
+
+ tet_infoline( "Only connect the child and grandchild, ensure they are called and not the parent" );
+ DevelActor::VisibilityChangedSignal( child ).Connect( &application, VisibilityChangedFunctor( childData ) );
+ DevelActor::VisibilityChangedSignal( grandChild ).Connect( &application, VisibilityChangedFunctor( grandChildData ) );
+
+ parent.SetVisible( false );
+ parentData.Check( false /* not called */, TEST_LOCATION );
+ childData.Check( true /* called */, child, false /* not visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION );
+ grandChildData.Check( true /* called */, grandChild, false /* not visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION );
+
+ tet_infoline( "Connect to the parent's signal as well and ensure all three are called" );
+ parentData.Reset();
+ childData.Reset();
+ grandChildData.Reset();
+
+ DevelActor::VisibilityChangedSignal( parent ).Connect( &application, VisibilityChangedFunctor( parentData ) );
+
+ parent.SetVisible( true );
+ parentData.Check( true /* called */, parent, true /* visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION );
+ childData.Check( true /* called */, child, true /* visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION );
+ grandChildData.Check( true /* called */, grandChild, true /* visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION );
+
+ tet_infoline( "Ensure none of the functors are called if we attempt to change the visibility to what it already is at" );
+ parentData.Reset();
+ childData.Reset();
+ grandChildData.Reset();
+
+ parent.SetVisible( true );
+ parentData.Check( false /* not called */, TEST_LOCATION );
+ childData.Check( false /* not called */, TEST_LOCATION );
+ grandChildData.Check( false /* not called */, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int utcDaliActorVisibilityChangeSignalAfterAnimation(void)
+{
+ TestApplication application;
+ tet_infoline( "Check that the visibility change signal is emitted when the visibility changes when an animation starts" );
+
+ Actor actor = Actor::New();
+ Stage::GetCurrent().Add( actor );
+
+ application.SendNotification();
+ application.Render();
+
+ VisibilityChangedFunctorData data;
+ DevelActor::VisibilityChangedSignal( actor ).Connect( &application, VisibilityChangedFunctor( data ) );
+
+ Animation animation = Animation::New( 1.0f );
+ animation.AnimateTo( Property( actor, Actor::Property::VISIBLE ), false );
+
+ data.Check( false, TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetProperty< bool >( Actor::Property::VISIBLE ), true, TEST_LOCATION );
+ DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty< bool >( actor, Actor::Property::VISIBLE ), true, TEST_LOCATION );
+
+ tet_infoline( "Play the animation and check the property value" );
+ animation.Play();
+
+ data.Check( true /* called */, actor, false /* not visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetProperty< bool >( Actor::Property::VISIBLE ), false, TEST_LOCATION );
+
+ tet_infoline( "Animation not currently finished, so the current visibility should still be true" );
+ DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty< bool >( actor, Actor::Property::VISIBLE ), true, TEST_LOCATION );
+
+ application.SendNotification();
+ application.Render( 1100 ); // After the animation
+
+ DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty< bool >( actor, Actor::Property::VISIBLE ), false, TEST_LOCATION );
+
+ END_TEST;
+}