X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=automated-tests%2Fsrc%2Fdali%2Futc-Dali-Actor.cpp;h=fad466a56da642f68f5193e51414ef9fb86b6278;hb=e08e2992259823c5f9832ad959ffa510b0445a6c;hp=ebdf66e2aa64d3fe2f86605e57ce554a4aafee0c;hpb=aff80077ec8fcc8ea763a327518e1612f1e957dc;p=platform%2Fcore%2Fuifw%2Fdali-core.git diff --git a/automated-tests/src/dali/utc-Dali-Actor.cpp b/automated-tests/src/dali/utc-Dali-Actor.cpp index ebdf66e..fad466a 100644 --- a/automated-tests/src/dali/utc-Dali-Actor.cpp +++ b/automated-tests/src/dali/utc-Dali-Actor.cpp @@ -246,6 +246,40 @@ struct VisibilityChangedVoidFunctor bool& mSignalCalled; }; +struct ChildOrderChangedFunctor +{ + ChildOrderChangedFunctor(bool& signalCalled, Actor& actor) + : mSignalCalled( signalCalled ), + mActor( actor ) + { } + + void operator()( Actor actor ) + { + mSignalCalled = true; + mActor = actor; + } + + bool& mSignalCalled; + Actor& mActor; +}; + +struct CulledPropertyNotificationFunctor +{ + CulledPropertyNotificationFunctor( bool& signalCalled, PropertyNotification& propertyNotification ) + : mSignalCalled( signalCalled ), + mPropertyNotification( propertyNotification ) + { } + + void operator()( PropertyNotification& source ) + { + mSignalCalled = true; + mPropertyNotification = source; + } + + bool& mSignalCalled; + PropertyNotification& mPropertyNotification; +}; + } // anonymous namespace @@ -638,6 +672,75 @@ int UtcDaliActorGetParent02(void) END_TEST; } +int UtcDaliActorCustomProperty(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + Stage::GetCurrent().Add( actor ); + + float startValue(1.0f); + Property::Index index = actor.RegisterProperty( "testProperty", startValue ); + DALI_TEST_CHECK( actor.GetProperty(index) == startValue ); + + application.SendNotification(); + application.Render(0); + DALI_TEST_CHECK( actor.GetProperty(index) == startValue ); + + actor.SetProperty( index, 5.0f ); + + application.SendNotification(); + application.Render(0); + DALI_TEST_CHECK( actor.GetProperty(index) == 5.0f ); + END_TEST; +} + +int UtcDaliActorCustomPropertyIntToFloat(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + Stage::GetCurrent().Add( actor ); + + float startValue(5.0f); + Property::Index index = actor.RegisterProperty( "testProperty", startValue ); + DALI_TEST_CHECK( actor.GetProperty(index) == startValue ); + + application.SendNotification(); + application.Render(0); + DALI_TEST_CHECK( actor.GetProperty(index) == startValue ); + + actor.SetProperty( index, int(1) ); + + application.SendNotification(); + application.Render(0); + DALI_TEST_CHECK( actor.GetProperty(index) == 1.0f ); + END_TEST; +} + +int UtcDaliActorCustomPropertyFloatToInt(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + Stage::GetCurrent().Add( actor ); + + int startValue(5); + Property::Index index = actor.RegisterProperty( "testProperty", startValue ); + DALI_TEST_CHECK( actor.GetProperty(index) == startValue ); + + application.SendNotification(); + application.Render(0); + DALI_TEST_CHECK( actor.GetProperty(index) == startValue ); + + actor.SetProperty( index, float(1.5) ); + + application.SendNotification(); + application.Render(0); + DALI_TEST_CHECK( actor.GetProperty(index) == 1 ); + END_TEST; +} + int UtcDaliActorSetParentOrigin(void) { TestApplication application; @@ -1450,55 +1553,6 @@ int UtcDaliActorGetCurrentWorldPosition(void) END_TEST; } -int UtcDaliActorInheritPosition(void) -{ - tet_infoline("Testing Actor::SetPositionInheritanceMode"); - TestApplication application; - - Actor parent = Actor::New(); - Vector3 parentPosition( 1.0f, 2.0f, 3.0f ); - parent.SetPosition( parentPosition ); - parent.SetParentOrigin( ParentOrigin::CENTER ); - parent.SetAnchorPoint( AnchorPoint::CENTER ); - Stage::GetCurrent().Add( parent ); - - Actor child = Actor::New(); - child.SetParentOrigin( ParentOrigin::CENTER ); - child.SetAnchorPoint( AnchorPoint::CENTER ); - Vector3 childPosition( 10.0f, 11.0f, 12.0f ); - child.SetPosition( childPosition ); - parent.Add( child ); - - // The actors should not have a world position yet - DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION ); - DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION ); - - // first test default, which is to inherit position - DALI_TEST_EQUALS( child.GetPositionInheritanceMode(), Dali::INHERIT_PARENT_POSITION, TEST_LOCATION ); - application.SendNotification(); - application.Render(0); // should only really call Update as Render is not required to update scene - DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION ); - DALI_TEST_EQUALS( child.GetCurrentPosition(), childPosition, TEST_LOCATION ); - DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION ); - DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childPosition, TEST_LOCATION ); - - - //Change child position - Vector3 childOffset( -1.0f, 1.0f, 0.0f ); - child.SetPosition( childOffset ); - - // Change inheritance mode to not inherit - child.SetPositionInheritanceMode( Dali::DONT_INHERIT_POSITION ); - DALI_TEST_EQUALS( child.GetPositionInheritanceMode(), Dali::DONT_INHERIT_POSITION, TEST_LOCATION ); - application.SendNotification(); - application.Render(0); // should only really call Update as Render is not required to update scene - DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION ); - DALI_TEST_EQUALS( child.GetCurrentPosition(), childOffset, TEST_LOCATION ); - DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION ); - DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), childOffset, TEST_LOCATION ); - END_TEST; -} - int UtcDaliActorSetInheritPosition(void) { tet_infoline("Testing Actor::SetInheritPosition"); @@ -1557,6 +1611,41 @@ int UtcDaliActorSetInheritPosition(void) END_TEST; } +int UtcDaliActorInheritOpacity(void) +{ + tet_infoline("Testing Actor::Inherit Opacity"); + TestApplication application; + + Actor parent = Actor::New(); + Actor child = Actor::New(); + parent.Add( child ); + Stage::GetCurrent().Add( parent ); + + DALI_TEST_EQUALS( parent.GetProperty( Actor::Property::COLOR_ALPHA ).Get(), 1.0f, 0.0001f, TEST_LOCATION ); + DALI_TEST_EQUALS( child.GetProperty( Actor::Property::COLOR_ALPHA ).Get(), 1.0f, 0.0001f, TEST_LOCATION ); + + // flush the queue and render once + application.SendNotification(); + application.Render(); + + parent.SetOpacity( 0.1f ); + + DALI_TEST_EQUALS( parent.GetProperty( Actor::Property::COLOR_ALPHA ).Get(), 0.1f, 0.0001f, TEST_LOCATION ); + DALI_TEST_EQUALS( child.GetProperty( Actor::Property::COLOR_ALPHA ).Get(), 1.0f, 0.0001f, TEST_LOCATION ); + + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS( parent.GetProperty( Actor::Property::WORLD_COLOR ).Get(), Vector4(1.f, 1.f, 1.f, 0.1f), 0.0001f, TEST_LOCATION ); + DALI_TEST_EQUALS( parent.GetCurrentProperty( Actor::Property::COLOR_ALPHA ).Get(), 0.1f, 0.0001f, TEST_LOCATION ); + DALI_TEST_EQUALS( parent.GetCurrentProperty( Actor::Property::WORLD_COLOR ).Get(), Vector4(1.f, 1.f, 1.f, 0.1f), 0.0001f, TEST_LOCATION ); + DALI_TEST_EQUALS( child.GetProperty( Actor::Property::WORLD_COLOR ).Get(), Vector4(1.f, 1.f, 1.f, 0.1f), 0.0001f, TEST_LOCATION ); + DALI_TEST_EQUALS( child.GetCurrentProperty( Actor::Property::WORLD_COLOR ).Get(), Vector4(1.f, 1.f, 1.f, 0.1f), 0.0001f, TEST_LOCATION ); + DALI_TEST_EQUALS( child.GetCurrentProperty( Actor::Property::COLOR_ALPHA ).Get(), 1.f, 0.0001f, TEST_LOCATION ); + + END_TEST; +} + // SetOrientation(float angleRadians, Vector3 axis) int UtcDaliActorSetOrientation01(void) { @@ -3159,7 +3248,6 @@ const PropertyStringIndex PROPERTY_TABLE[] = { "inheritOrientation", Actor::Property::INHERIT_ORIENTATION, Property::BOOLEAN }, { "inheritScale", Actor::Property::INHERIT_SCALE, Property::BOOLEAN }, { "colorMode", Actor::Property::COLOR_MODE, Property::STRING }, - { "positionInheritance", Actor::Property::POSITION_INHERITANCE, Property::STRING }, { "drawMode", Actor::Property::DRAW_MODE, Property::STRING }, { "sizeModeFactor", Actor::Property::SIZE_MODE_FACTOR, Property::VECTOR3 }, { "widthResizePolicy", Actor::Property::WIDTH_RESIZE_POLICY, Property::STRING }, @@ -3678,31 +3766,6 @@ int UtcDaliActorColorModePropertyAsString(void) END_TEST; } -int UtcDaliActorPositionInheritancePropertyAsString(void) -{ - TestApplication application; - - Actor actor = Actor::New(); - - actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "INHERIT_PARENT_POSITION" ); - DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), INHERIT_PARENT_POSITION, TEST_LOCATION ); - - actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "USE_PARENT_POSITION" ); - DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), USE_PARENT_POSITION, TEST_LOCATION ); - - actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "USE_PARENT_POSITION_PLUS_LOCAL_POSITION" ); - DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), USE_PARENT_POSITION_PLUS_LOCAL_POSITION, TEST_LOCATION ); - - actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "DONT_INHERIT_POSITION" ); - DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), DONT_INHERIT_POSITION, TEST_LOCATION ); - - // Invalid should not change anything - actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "INVALID_ARG" ); - DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), DONT_INHERIT_POSITION, TEST_LOCATION ); - - END_TEST; -} - int UtcDaliActorDrawModePropertyAsString(void) { TestApplication application; @@ -3715,12 +3778,9 @@ int UtcDaliActorDrawModePropertyAsString(void) actor.SetProperty( Actor::Property::DRAW_MODE, "OVERLAY_2D" ); DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::OVERLAY_2D, TEST_LOCATION ); - actor.SetProperty( Actor::Property::DRAW_MODE, "STENCIL" ); - DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::STENCIL, TEST_LOCATION ); - // Invalid should not change anything actor.SetProperty( Actor::Property::DRAW_MODE, "INVALID_ARG" ); - DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::STENCIL, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::OVERLAY_2D, TEST_LOCATION ); END_TEST; } @@ -3746,27 +3806,6 @@ int UtcDaliActorColorModePropertyAsEnum(void) END_TEST; } -int UtcDaliActorPositionInheritancePropertyAsEnum(void) -{ - TestApplication application; - - Actor actor = Actor::New(); - - actor.SetProperty( Actor::Property::POSITION_INHERITANCE, INHERIT_PARENT_POSITION ); - DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), INHERIT_PARENT_POSITION, TEST_LOCATION ); - - actor.SetProperty( Actor::Property::POSITION_INHERITANCE, USE_PARENT_POSITION ); - DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), USE_PARENT_POSITION, TEST_LOCATION ); - - actor.SetProperty( Actor::Property::POSITION_INHERITANCE, USE_PARENT_POSITION_PLUS_LOCAL_POSITION ); - DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), USE_PARENT_POSITION_PLUS_LOCAL_POSITION, TEST_LOCATION ); - - actor.SetProperty( Actor::Property::POSITION_INHERITANCE, DONT_INHERIT_POSITION ); - DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), DONT_INHERIT_POSITION, TEST_LOCATION ); - - END_TEST; -} - int UtcDaliActorDrawModePropertyAsEnum(void) { TestApplication application; @@ -3779,9 +3818,6 @@ int UtcDaliActorDrawModePropertyAsEnum(void) actor.SetProperty( Actor::Property::DRAW_MODE, DrawMode::OVERLAY_2D ); DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::OVERLAY_2D, TEST_LOCATION ); - actor.SetProperty( Actor::Property::DRAW_MODE, DrawMode::STENCIL ); - DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::STENCIL, TEST_LOCATION ); - END_TEST; } @@ -4723,6 +4759,12 @@ int UtcDaliActorRaiseLower(void) actorB.TouchSignal().Connect( TestTouchCallback2 ); actorC.TouchSignal().Connect( TestTouchCallback3 ); + // Connect ChildOrderChangedSignal + bool orderChangedSignal( false ); + Actor orderChangedActor; + ChildOrderChangedFunctor f( orderChangedSignal, orderChangedActor ); + DevelActor::ChildOrderChangedSignal( stage.GetRootLayer() ).Connect( &application, f ) ; + Dali::Integration::Point point; point.SetDeviceId( 1 ); point.SetState( PointState::DOWN ); @@ -4746,7 +4788,11 @@ int UtcDaliActorRaiseLower(void) Property::Value value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER ); value.Get( preActorOrder ); + DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION ); actorB.Raise(); + DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION ); + DALI_TEST_EQUALS( orderChangedActor, actorB, TEST_LOCATION ); + // Ensure sort order is calculated before next touch event application.SendNotification(); @@ -4768,7 +4814,13 @@ int UtcDaliActorRaiseLower(void) value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER ); value.Get( preActorOrder ); + orderChangedSignal = false; + + DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION ); actorB.Lower(); + DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION ); + DALI_TEST_EQUALS( orderChangedActor, actorB, TEST_LOCATION ); + application.SendNotification(); // ensure sort order calculated before next touch event value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER ); @@ -4846,6 +4898,12 @@ int UtcDaliActorRaiseToTopLowerToBottom(void) ResetTouchCallbacks(); + // Connect ChildOrderChangedSignal + bool orderChangedSignal( false ); + Actor orderChangedActor; + ChildOrderChangedFunctor f( orderChangedSignal, orderChangedActor ); + DevelActor::ChildOrderChangedSignal( stage.GetRootLayer() ).Connect( &application, f ) ; + // Set up gl abstraction trace so can query the set uniform order TestGlAbstraction& glAbstraction = application.GetGlAbstraction(); glAbstraction.EnableSetUniformCallTrace(true); @@ -4895,7 +4953,11 @@ int UtcDaliActorRaiseToTopLowerToBottom(void) tet_printf( "RaiseToTop ActorA\n" ); + DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION ); actorA.RaiseToTop(); + DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION ); + DALI_TEST_EQUALS( orderChangedActor, actorA, TEST_LOCATION ); + application.SendNotification(); // ensure sorting order is calculated before next touch event application.ProcessEvent( touchEvent ); @@ -4926,7 +4988,13 @@ int UtcDaliActorRaiseToTopLowerToBottom(void) tet_printf( "RaiseToTop ActorB\n" ); + orderChangedSignal = false; + + DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION ); actorB.RaiseToTop(); + DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION ); + DALI_TEST_EQUALS( orderChangedActor, actorB, TEST_LOCATION ); + application.SendNotification(); // Ensure sort order is calculated before next touch event application.ProcessEvent( touchEvent ); @@ -4957,11 +5025,23 @@ int UtcDaliActorRaiseToTopLowerToBottom(void) tet_printf( "LowerToBottom ActorA then ActorB leaving Actor C at Top\n" ); + orderChangedSignal = false; + + DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION ); actorA.LowerToBottom(); + DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION ); + DALI_TEST_EQUALS( orderChangedActor, actorA, TEST_LOCATION ); + application.SendNotification(); application.Render(); + orderChangedSignal = false; + + DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION ); actorB.LowerToBottom(); + DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION ); + DALI_TEST_EQUALS( orderChangedActor, actorB, TEST_LOCATION ); + application.SendNotification(); application.Render(); @@ -5043,6 +5123,11 @@ int UtcDaliActorRaiseAbove(void) actorB.TouchSignal().Connect( TestTouchCallback2 ); actorC.TouchSignal().Connect( TestTouchCallback3 ); + bool orderChangedSignal( false ); + Actor orderChangedActor; + ChildOrderChangedFunctor f( orderChangedSignal, orderChangedActor ); + DevelActor::ChildOrderChangedSignal( stage.GetRootLayer() ).Connect( &application, f ) ; + Dali::Integration::Point point; point.SetDeviceId( 1 ); point.SetState( PointState::DOWN ); @@ -5060,10 +5145,13 @@ int UtcDaliActorRaiseAbove(void) tet_printf( "Raise actor B Above Actor C\n" ); + DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION ); actorB.RaiseAbove( actorC ); + DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION ); + DALI_TEST_EQUALS( orderChangedActor, actorB, TEST_LOCATION ); + // Ensure sorting happens at end of Core::ProcessEvents() before next touch application.SendNotification(); - application.ProcessEvent( touchEvent ); DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION ); @@ -5074,7 +5162,12 @@ int UtcDaliActorRaiseAbove(void) tet_printf( "Raise actor A Above Actor B\n" ); + orderChangedSignal = false; + + DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION ); actorA.RaiseAbove( actorB ); + DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION ); + DALI_TEST_EQUALS( orderChangedActor, actorA, TEST_LOCATION ); // Ensure sorting happens at end of Core::ProcessEvents() before next touch application.SendNotification(); @@ -5154,6 +5247,12 @@ int UtcDaliActorLowerBelow(void) ResetTouchCallbacks(); + // Connect ChildOrderChangedSignal + bool orderChangedSignal( false ); + Actor orderChangedActor; + ChildOrderChangedFunctor f( orderChangedSignal, orderChangedActor ); + DevelActor::ChildOrderChangedSignal( container ).Connect( &application, f ) ; + // Set up gl abstraction trace so can query the set uniform order TestGlAbstraction& glAbstraction = application.GetGlAbstraction(); glAbstraction.EnableSetUniformCallTrace(true); @@ -5208,7 +5307,11 @@ int UtcDaliActorLowerBelow(void) tet_printf( "Lower actor C below Actor B ( actor B and A on same level due to insertion order) so C is below both \n" ); + DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION ); actorC.LowerBelow( actorB ); + DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION ); + DALI_TEST_EQUALS( orderChangedActor, actorC, TEST_LOCATION ); + // Ensure sorting happens at end of Core::ProcessEvents() before next touch application.SendNotification(); application.Render(); @@ -5240,7 +5343,13 @@ int UtcDaliActorLowerBelow(void) tet_printf( "Lower actor C below Actor A leaving B on top\n" ); + orderChangedSignal = false; + + DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION ); actorC.LowerBelow( actorA ); + DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION ); + DALI_TEST_EQUALS( orderChangedActor, actorC, TEST_LOCATION ); + // Ensure sorting happens at end of Core::ProcessEvents() before next touch application.SendNotification(); application.Render(); @@ -5269,7 +5378,13 @@ int UtcDaliActorLowerBelow(void) tet_printf( "Lower actor B below Actor C leaving A on top\n" ); + orderChangedSignal = false; + + DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION ); actorB.LowerBelow( actorC ); + DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION ); + DALI_TEST_EQUALS( orderChangedActor, actorB, TEST_LOCATION ); + // Ensure sorting happens at end of Core::ProcessEvents() before next touch application.SendNotification(); application.Render(); @@ -5348,6 +5463,12 @@ int UtcDaliActorRaiseAboveDifferentParentsN(void) ResetTouchCallbacks(); + // Connect ChildOrderChangedSignal + bool orderChangedSignal( false ); + Actor orderChangedActor; + ChildOrderChangedFunctor f( orderChangedSignal, orderChangedActor ); + DevelActor::ChildOrderChangedSignal( stage.GetRootLayer() ).Connect( &application, f ) ; + application.SendNotification(); application.Render(); @@ -5378,7 +5499,10 @@ int UtcDaliActorRaiseAboveDifferentParentsN(void) tet_printf( "Raise actor A Above Actor C which have different parents\n" ); + DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION ); actorA.RaiseAbove( actorC ); + DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION ); + // Ensure sorting happens at end of Core::ProcessEvents() before next touch application.SendNotification(); @@ -5425,6 +5549,12 @@ int UtcDaliActorRaiseLowerWhenUnparentedTargetN(void) ResetTouchCallbacks(); + // Connect ChildOrderChangedSignal + bool orderChangedSignal( false ); + Actor orderChangedActor; + ChildOrderChangedFunctor f( orderChangedSignal, orderChangedActor ); + DevelActor::ChildOrderChangedSignal( stage.GetRootLayer() ).Connect( &application, f ) ; + application.SendNotification(); application.Render(); @@ -5447,7 +5577,10 @@ int UtcDaliActorRaiseLowerWhenUnparentedTargetN(void) tet_printf( "Raise actor A Above Actor C which have no parents\n" ); + DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION ); actorA.RaiseAbove( actorC ); + DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION ); + // Ensure sorting happens at end of Core::ProcessEvents() before next touch application.SendNotification(); @@ -5461,9 +5594,14 @@ int UtcDaliActorRaiseLowerWhenUnparentedTargetN(void) ResetTouchCallbacks(); + orderChangedSignal = false; + stage.Add ( actorB ); tet_printf( "Lower actor A below Actor C when only A is not on stage \n" ); + + DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION ); actorA.LowerBelow( actorC ); + DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION ); // Ensure sorting happens at end of Core::ProcessEvents() before next touch application.SendNotification(); @@ -5478,6 +5616,8 @@ int UtcDaliActorRaiseLowerWhenUnparentedTargetN(void) ResetTouchCallbacks(); + orderChangedSignal = false; + tet_printf( "Adding Actor A to stage, will be on top\n" ); stage.Add ( actorA ); @@ -5485,7 +5625,11 @@ int UtcDaliActorRaiseLowerWhenUnparentedTargetN(void) application.Render(); tet_printf( "Raise actor B Above Actor C when only B has a parent\n" ); + + DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION ); actorB.RaiseAbove( actorC ); + DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION ); + // Ensure sorting happens at end of Core::ProcessEvents() before next touch application.SendNotification(); @@ -5498,8 +5642,14 @@ int UtcDaliActorRaiseLowerWhenUnparentedTargetN(void) ResetTouchCallbacks(); + orderChangedSignal = false; + tet_printf( "Lower actor A below Actor C when only A has a parent\n" ); + + DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION ); actorA.LowerBelow( actorC ); + DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION ); + // Ensure sorting happens at end of Core::ProcessEvents() before next touch application.SendNotification(); @@ -5512,8 +5662,15 @@ int UtcDaliActorRaiseLowerWhenUnparentedTargetN(void) ResetTouchCallbacks(); + orderChangedSignal = false; + stage.Add ( actorC ); + + DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION ); actorA.RaiseAbove( actorC ); + DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION ); + DALI_TEST_EQUALS( orderChangedActor, actorA, TEST_LOCATION ); + // Ensure sorting happens at end of Core::ProcessEvents() before next touch application.SendNotification(); application.Render(); @@ -5560,6 +5717,12 @@ int UtcDaliActorTestAllAPIwhenActorNotParented(void) ResetTouchCallbacks(); + // Connect ChildOrderChangedSignal + bool orderChangedSignal( false ); + Actor orderChangedActor; + ChildOrderChangedFunctor f( orderChangedSignal, orderChangedActor ); + DevelActor::ChildOrderChangedSignal( stage.GetRootLayer() ).Connect( &application, f ) ; + // connect to actor touch signals, will use touch callbacks to determine which actor is on top. // Only top actor will get touched. actorA.TouchSignal().Connect( TestTouchCallback ); @@ -5575,7 +5738,10 @@ int UtcDaliActorTestAllAPIwhenActorNotParented(void) stage.Add ( actorA ); tet_printf( "Raise actor B Above Actor C but B not parented\n" ); + + DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION ); actorB.Raise(); + DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION ); application.SendNotification(); application.Render(); @@ -5591,7 +5757,12 @@ int UtcDaliActorTestAllAPIwhenActorNotParented(void) tet_printf( "Raise actor B Above Actor C but B not parented\n" ); ResetTouchCallbacks(); + orderChangedSignal = false; + + DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION ); actorC.Lower(); + DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION ); + // Sort actor tree before next touch event application.SendNotification(); application.Render(); @@ -5605,9 +5776,14 @@ int UtcDaliActorTestAllAPIwhenActorNotParented(void) DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION ); ResetTouchCallbacks(); + orderChangedSignal = false; + tet_printf( "Lower actor C below B but C not parented\n" ); + DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION ); actorB.Lower(); + DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION ); + // Sort actor tree before next touch event application.SendNotification(); application.Render(); @@ -5621,9 +5797,14 @@ int UtcDaliActorTestAllAPIwhenActorNotParented(void) DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION ); ResetTouchCallbacks(); + orderChangedSignal = false; + tet_printf( "Raise actor B to top\n" ); + DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION ); actorB.RaiseToTop(); + DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION ); + // Sort actor tree before next touch event application.SendNotification(); application.Render(); @@ -5637,13 +5818,18 @@ int UtcDaliActorTestAllAPIwhenActorNotParented(void) DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION ); ResetTouchCallbacks(); + orderChangedSignal = false; + tet_printf( "Add ActorB to stage so only Actor C not parented\n" ); stage.Add ( actorB ); tet_printf( "Lower actor C to Bottom, B stays at top\n" ); + DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION ); actorC.LowerToBottom(); + DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION ); + application.SendNotification(); application.Render(); @@ -5702,6 +5888,12 @@ int UtcDaliActorRaiseAboveActorAndTargetTheSameN(void) ResetTouchCallbacks(); + // Connect ChildOrderChangedSignal + bool orderChangedSignal( false ); + Actor orderChangedActor; + ChildOrderChangedFunctor f( orderChangedSignal, orderChangedActor ); + DevelActor::ChildOrderChangedSignal( stage.GetRootLayer() ).Connect( &application, f ) ; + application.SendNotification(); application.Render(); @@ -5722,7 +5914,11 @@ int UtcDaliActorRaiseAboveActorAndTargetTheSameN(void) tet_infoline( "Raise actor A Above Actor A which is the same actor!!\n" ); + DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION ); actorA.RaiseAbove( actorA ); + DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION ); + DALI_TEST_EQUALS( orderChangedActor, actorA, TEST_LOCATION ); + application.SendNotification(); application.Render(); @@ -5736,7 +5932,13 @@ int UtcDaliActorRaiseAboveActorAndTargetTheSameN(void) ResetTouchCallbacks(); + orderChangedSignal = false; + + DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION ); actorA.RaiseAbove( actorC ); + DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION ); + DALI_TEST_EQUALS( orderChangedActor, actorA, TEST_LOCATION ); + application.SendNotification(); application.Render(); @@ -6923,3 +7125,50 @@ int UtcDaliChildMovedSignalP(void) 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; +}