-
-int UtcDaliActorApplyConstraint(void)
-{
- TestApplication application;
-
- gTestConstraintCalled = false;
-
- Actor actor = Actor::New();
-
- Constraint constraint = Constraint::New<Vector4>( Actor::Property::COLOR, TestConstraint() );
- actor.ApplyConstraint(constraint);
-
- DALI_TEST_CHECK( gTestConstraintCalled == false );
- // add to stage
- Stage::GetCurrent().Add( actor );
-
- // flush the queue and render once
- application.SendNotification();
- application.Render();
-
- DALI_TEST_CHECK( gTestConstraintCalled == true );
- END_TEST;
-}
-
-
-int UtcDaliActorApplyConstraintAppliedCallback(void)
-{
- TestApplication application;
-
- // Build a reusable constraint
-
- Actor parent = Actor::New();
- Vector3 parentSize( 100.0f, 100.0f, 100.0f );
- parent.SetSize( parentSize );
- Stage::GetCurrent().Add( parent );
-
- Constraint constraint = Constraint::New<Vector3>( Actor::Property::SIZE,
- Source( parent, Actor::Property::SIZE ),
- EqualToConstraint() );
-
- // Create some child actors
-
- Actor child1 = Actor::New();
- parent.Add( child1 );
-
- Actor child2 = Actor::New();
- parent.Add( child2 );
-
- Actor child3 = Actor::New();
- parent.Add( child3 );
-
- // Apply constraint with different timings - everything should be finished after 10 seconds
-
- wasConstraintCallbackCalled1 = false;
- wasConstraintCallbackCalled2 = false;
- wasConstraintCallbackCalled3 = false;
-
- constraint.SetApplyTime( 5.0f );
- ActiveConstraint activeConstraint1 = child1.ApplyConstraint( constraint );
- activeConstraint1.AppliedSignal().Connect( TestConstraintCallback1 );
-
- constraint.SetApplyTime( 10.0f );
- ActiveConstraint activeConstraint2 = child2.ApplyConstraint( constraint );
- activeConstraint2.AppliedSignal().Connect( TestConstraintCallback2 );
-
- constraint.SetApplyTime( TimePeriod( 2.0f/*delay*/, 5.0f/*duration*/ ) );
- ActiveConstraint activeConstraint3 = child3.ApplyConstraint( constraint );
- activeConstraint3.AppliedSignal().Connect( TestConstraintCallback3 );
-
- // Check event-side size
- DALI_TEST_EQUALS( child1.GetSize(), Vector3::ZERO, TEST_LOCATION );
- DALI_TEST_EQUALS( child2.GetSize(), Vector3::ZERO, TEST_LOCATION );
- DALI_TEST_EQUALS( child3.GetSize(), Vector3::ZERO, TEST_LOCATION );
-
- DALI_TEST_EQUALS( child1.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
- DALI_TEST_EQUALS( child2.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
- DALI_TEST_EQUALS( child3.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
-
- application.SendNotification();
-
- application.Render(static_cast<unsigned int>(1000.0f)); // 1 elapsed second
-
- DALI_TEST_EQUALS( child1.GetCurrentSize(), parentSize*0.20f, TEST_LOCATION ); // 1 / 5 * 100 = 20%
- DALI_TEST_EQUALS( child2.GetCurrentSize(), parentSize*0.10f, TEST_LOCATION ); // 1 / 10 * 100 = 10%
- DALI_TEST_EQUALS( child3.GetCurrentSize(), parentSize*0.00f, TEST_LOCATION ); // 0%
-
- // Check signals have not fired
- application.SendNotification();
- DALI_TEST_EQUALS( wasConstraintCallbackCalled1, false, TEST_LOCATION );
- DALI_TEST_EQUALS( wasConstraintCallbackCalled2, false, TEST_LOCATION );
- DALI_TEST_EQUALS( wasConstraintCallbackCalled3, false, TEST_LOCATION );
-
- application.Render(static_cast<unsigned int>(1000.0f)); // 2 elapsed seconds
- DALI_TEST_EQUALS( child1.GetCurrentSize(), parentSize*0.40f, TEST_LOCATION ); // 2 / 5 * 100 = 40%
- DALI_TEST_EQUALS( child2.GetCurrentSize(), parentSize*0.20f, TEST_LOCATION ); // 2 / 10 * 100 = 20%
- DALI_TEST_EQUALS( child3.GetCurrentSize(), parentSize*0.00f, TEST_LOCATION ); // 0%
-
- // Check signals have not fired
- application.SendNotification();
- DALI_TEST_EQUALS( wasConstraintCallbackCalled1, false, TEST_LOCATION );
- DALI_TEST_EQUALS( wasConstraintCallbackCalled2, false, TEST_LOCATION );
- DALI_TEST_EQUALS( wasConstraintCallbackCalled3, false, TEST_LOCATION );
-
- application.Render(static_cast<unsigned int>(1000.0f)); // 3 elapsed seconds
- DALI_TEST_EQUALS( child1.GetCurrentSize(), parentSize*0.60f, TEST_LOCATION ); // 3 / 5 * 100 = 60%
- DALI_TEST_EQUALS( child2.GetCurrentSize(), parentSize*0.30f, TEST_LOCATION ); // 3 / 10 * 100 = 30%
- DALI_TEST_EQUALS( child3.GetCurrentSize(), parentSize*0.20f, TEST_LOCATION ); // (3 - 2) / 5 * 100 = 20%
-
- // Check signals have not fired
- application.SendNotification();
- DALI_TEST_EQUALS( wasConstraintCallbackCalled1, false, TEST_LOCATION );
- DALI_TEST_EQUALS( wasConstraintCallbackCalled2, false, TEST_LOCATION );
- DALI_TEST_EQUALS( wasConstraintCallbackCalled3, false, TEST_LOCATION );
-
- application.Render(static_cast<unsigned int>(1000.0f)); // 4 elapsed seconds
- DALI_TEST_EQUALS( child1.GetCurrentSize(), parentSize*0.80f, TEST_LOCATION ); // 4 / 5 * 100 = 80%
- DALI_TEST_EQUALS( child2.GetCurrentSize(), parentSize*0.40f, TEST_LOCATION ); // 4 / 10 * 100 = 40%
- DALI_TEST_EQUALS( child3.GetCurrentSize(), parentSize*0.40f, TEST_LOCATION ); // (4 - 2) / 5 * 100 = 40%
-
- // Check signals have not fired
- application.SendNotification();
- DALI_TEST_EQUALS( wasConstraintCallbackCalled1, false, TEST_LOCATION );
- DALI_TEST_EQUALS( wasConstraintCallbackCalled2, false, TEST_LOCATION );
- DALI_TEST_EQUALS( wasConstraintCallbackCalled3, false, TEST_LOCATION );
-
- application.Render(static_cast<unsigned int>(1000.0f)); // 5 elapsed seconds
- DALI_TEST_EQUALS( child1.GetCurrentSize(), parentSize, TEST_LOCATION ); // 5 / 5 * 100 = 100%
- DALI_TEST_EQUALS( child2.GetCurrentSize(), parentSize*0.50f, TEST_LOCATION ); // 5 / 10 * 100 = 50%
- DALI_TEST_EQUALS( child3.GetCurrentSize(), parentSize*0.60f, TEST_LOCATION ); // (5 - 2) / 5 * 100 = 60%
-
- // Check signals have not fired
- application.SendNotification();
- DALI_TEST_EQUALS( wasConstraintCallbackCalled1, false, TEST_LOCATION );
- DALI_TEST_EQUALS( wasConstraintCallbackCalled2, false, TEST_LOCATION );
- DALI_TEST_EQUALS( wasConstraintCallbackCalled3, false, TEST_LOCATION );
-
- application.Render(static_cast<unsigned int>(1000.0f)); // 6 elapsed seconds
- DALI_TEST_EQUALS( child1.GetCurrentSize(), parentSize, TEST_LOCATION ); // Past 100% (signal 1 should fire)
- DALI_TEST_EQUALS( child2.GetCurrentSize(), parentSize*0.60f, TEST_LOCATION ); // 6 / 10 * 100 = 60%
- DALI_TEST_EQUALS( child3.GetCurrentSize(), parentSize*0.80f, TEST_LOCATION ); // (6 - 2) / 5 * 100 = 80%
-
- // 1st signal should have fired
- application.SendNotification();
- DALI_TEST_EQUALS( wasConstraintCallbackCalled1, true, TEST_LOCATION );
- wasConstraintCallbackCalled1 = false;
- DALI_TEST_EQUALS( wasConstraintCallbackCalled2, false, TEST_LOCATION );
- DALI_TEST_EQUALS( wasConstraintCallbackCalled3, false, TEST_LOCATION );
-
- application.Render(static_cast<unsigned int>(1000.0f)); // 7 elapsed seconds
- DALI_TEST_EQUALS( child1.GetCurrentSize(), parentSize, TEST_LOCATION ); // Past 100%
- DALI_TEST_EQUALS( child2.GetCurrentSize(), parentSize*0.70f, TEST_LOCATION ); // 7 / 10 * 100 = 70%
- DALI_TEST_EQUALS( child3.GetCurrentSize(), parentSize, TEST_LOCATION ); // (7 - 2) / 5 * 100 = 100%
-
- // Check signals have not fired
- application.SendNotification();
- DALI_TEST_EQUALS( wasConstraintCallbackCalled1, false, TEST_LOCATION );
- DALI_TEST_EQUALS( wasConstraintCallbackCalled2, false, TEST_LOCATION );
- DALI_TEST_EQUALS( wasConstraintCallbackCalled3, false, TEST_LOCATION );
-
- application.Render(static_cast<unsigned int>(1000.0f)); // 8 elapsed seconds
- DALI_TEST_EQUALS( child1.GetCurrentSize(), parentSize, TEST_LOCATION ); // Past 100%
- DALI_TEST_EQUALS( child2.GetCurrentSize(), parentSize*0.80f, TEST_LOCATION ); // 8 / 10 * 100 = 80%
- DALI_TEST_EQUALS( child3.GetCurrentSize(), parentSize, TEST_LOCATION ); // Past 100% (signal 3 should fire)
-
- // 3rd signal should have fired
- application.SendNotification();
-
- DALI_TEST_EQUALS( wasConstraintCallbackCalled1, false, TEST_LOCATION );
- DALI_TEST_EQUALS( wasConstraintCallbackCalled2, false, TEST_LOCATION );
- DALI_TEST_EQUALS( wasConstraintCallbackCalled3, true, TEST_LOCATION );
- wasConstraintCallbackCalled3 = false;
-
- application.Render(static_cast<unsigned int>(1000.0f)); // 9 elapsed seconds
- DALI_TEST_EQUALS( child1.GetCurrentSize(), parentSize, TEST_LOCATION ); // Past 100%
- DALI_TEST_EQUALS( child2.GetCurrentSize(), parentSize*0.90f, TEST_LOCATION ); // 9 / 10 * 100 = 90%
- DALI_TEST_EQUALS( child3.GetCurrentSize(), parentSize, TEST_LOCATION ); // Past 100%
-
- // Check signals have not fired
- application.SendNotification();
- DALI_TEST_EQUALS( wasConstraintCallbackCalled1, false, TEST_LOCATION );
- DALI_TEST_EQUALS( wasConstraintCallbackCalled2, false, TEST_LOCATION );
- DALI_TEST_EQUALS( wasConstraintCallbackCalled3, false, TEST_LOCATION );
-
- application.Render(static_cast<unsigned int>(1000.0f + 1.0f)); // over 10 elapsed seconds
- DALI_TEST_EQUALS( child1.GetCurrentSize(), parentSize, TEST_LOCATION ); // Past 100%
- DALI_TEST_EQUALS( child2.GetCurrentSize(), parentSize, TEST_LOCATION ); // Past 100% (signal 2 should fire)
- DALI_TEST_EQUALS( child3.GetCurrentSize(), parentSize, TEST_LOCATION ); // Past 100%
-
- // 2nd signal should have fired
- application.SendNotification();
- DALI_TEST_EQUALS( wasConstraintCallbackCalled1, false, TEST_LOCATION );
- DALI_TEST_EQUALS( wasConstraintCallbackCalled2, true, TEST_LOCATION );
- wasConstraintCallbackCalled2 = false;
- DALI_TEST_EQUALS( wasConstraintCallbackCalled3, false, TEST_LOCATION );
-
- // Check that nothing has changed after a couple of buffer swaps
-
- application.Render(0);
- DALI_TEST_EQUALS( child1.GetCurrentSize(), parentSize, TEST_LOCATION );
- DALI_TEST_EQUALS( child2.GetCurrentSize(), parentSize, TEST_LOCATION );
- DALI_TEST_EQUALS( child3.GetCurrentSize(), parentSize, TEST_LOCATION );
-
- application.SendNotification();
- DALI_TEST_EQUALS( wasConstraintCallbackCalled1, false, TEST_LOCATION );
- DALI_TEST_EQUALS( wasConstraintCallbackCalled2, false, TEST_LOCATION );
- DALI_TEST_EQUALS( wasConstraintCallbackCalled3, false, TEST_LOCATION );
-
- application.Render(0);
- DALI_TEST_EQUALS( child1.GetCurrentSize(), parentSize, TEST_LOCATION );
- DALI_TEST_EQUALS( child2.GetCurrentSize(), parentSize, TEST_LOCATION );
- DALI_TEST_EQUALS( child3.GetCurrentSize(), parentSize, TEST_LOCATION );
-
- application.SendNotification();
- DALI_TEST_EQUALS( wasConstraintCallbackCalled1, false, TEST_LOCATION );
- DALI_TEST_EQUALS( wasConstraintCallbackCalled2, false, TEST_LOCATION );
- DALI_TEST_EQUALS( wasConstraintCallbackCalled3, false, TEST_LOCATION );
- END_TEST;
-}
-