- // Check that nothing has changed after a couple of buffer swaps
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), minValue, TEST_LOCATION );
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), minValue, TEST_LOCATION );
-
- // Set to greater than 2.0f, the constraint will allow this
- Vector3 greaterValue( 3.0f, 3.0f, 3.0f );
- actor.SetProperty( index, greaterValue );
-
- application.SendNotification();
- application.Render(0);
-
- DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), greaterValue, TEST_LOCATION );
-
- // Check that nothing has changed after a couple of buffer swaps
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), greaterValue, TEST_LOCATION );
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), greaterValue, TEST_LOCATION );
-
- // Set to less than 2.0f, the constraint will NOT allow this
- Vector3 lesserValue( 1.0f, 1.0f, 1.0f );
- actor.SetProperty( index, lesserValue );
-
- application.SendNotification();
- application.Render(0);
-
- DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), minValue/*not lesserValue*/, TEST_LOCATION );
-
- // Check that nothing has changed after a couple of buffer swaps
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), minValue, TEST_LOCATION );
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), minValue, TEST_LOCATION );
-
- // Remove the constraint, then set new value
- actor.RemoveConstraints();
- actor.SetProperty( index, lesserValue );
-
- // Constraint should have been removed
- application.SendNotification();
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), lesserValue, TEST_LOCATION );
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), lesserValue, TEST_LOCATION );
- END_TEST;
-}
-
-int UtcDaliConstraintNewVector4(void)
-{
- TestApplication application;
-
- Actor actor = Actor::New();
-
- // Register a Vector4 property
- Vector4 startValue( 1.0f, 1.0f, 1.0f, 1.0f );
- Property::Index index = actor.RegisterProperty( "test-property", startValue );
- Stage::GetCurrent().Add(actor);
- DALI_TEST_CHECK( actor.GetProperty<Vector4>(index) == startValue );
-
- /**
- * Test that the Constraint is correctly applied on a clean Node
- */
- application.SendNotification();
- application.Render(0);
- DALI_TEST_CHECK( actor.GetProperty<Vector4>(index) == startValue );
- application.Render(0);
- DALI_TEST_CHECK( actor.GetProperty<Vector4>(index) == startValue );
- application.Render(0);
- DALI_TEST_CHECK( actor.GetProperty<Vector4>(index) == startValue );
-
- // Apply constraint
-
- Vector4 minValue( 2.0f, 2.0f, 2.0f, 2.0f );
- Constraint constraint = Constraint::New<Vector4>( index, TestAlwaysEqualOrGreaterThanConstraintVector4( minValue ) );
-
- actor.ApplyConstraint( constraint );
- DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
-
- application.SendNotification();
- application.Render(0);
-
- // Constraint should be fully applied
- DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), minValue, TEST_LOCATION );
-
- // Check that nothing has changed after a couple of buffer swaps
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), minValue, TEST_LOCATION );
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), minValue, TEST_LOCATION );
-
- // Set to greater than 2.0f, the constraint will allow this
- Vector4 greaterValue( 3.0f, 3.0f, 3.0f, 3.0f );
- actor.SetProperty( index, greaterValue );
-
- application.SendNotification();
- application.Render(0);
-
- DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), greaterValue, TEST_LOCATION );
-
- // Check that nothing has changed after a couple of buffer swaps
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), greaterValue, TEST_LOCATION );
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), greaterValue, TEST_LOCATION );
-
- // Set to less than 2.0f, the constraint will NOT allow this
- Vector4 lesserValue( 1.0f, 1.0f, 1.0f, 1.0f );
- actor.SetProperty( index, lesserValue );
-
- application.SendNotification();
- application.Render(0);
-
- DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), minValue/*not lesserValue*/, TEST_LOCATION );
-
- // Check that nothing has changed after a couple of buffer swaps
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), minValue, TEST_LOCATION );
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), minValue, TEST_LOCATION );
-
- // Remove the constraint, then set new value
- actor.RemoveConstraints();
- actor.SetProperty( index, lesserValue );
-
- // Constraint should have been removed
- application.SendNotification();
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), lesserValue, TEST_LOCATION );
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), lesserValue, TEST_LOCATION );
- END_TEST;
-}
-
-int UtcDaliConstraintNewMatrix(void)
-{
- try
- {
- TestApplication application;
-
- Actor actor = Actor::New();
-
- // Register a Matrix property
- Matrix startValue = Matrix::IDENTITY;
- Property::Index index = actor.RegisterProperty( "test-property", startValue );
- DALI_TEST_CHECK( index != Property::INVALID_INDEX );
- if (index != Property::INVALID_INDEX)
- {
- Stage::GetCurrent().Add(actor);
- DALI_TEST_CHECK( actor.GetProperty<Matrix>(index) == startValue );
-
- // Apply constraint
- Matrix constraintLimit;
- constraintLimit.SetTransformComponents(Vector3::ONE, Quaternion(Radian(Degree(30.0f)), Vector3::YAXIS), Vector3::ZAXIS );
- Constraint constraint = Constraint::New<Matrix>( index, TestConstraintMatrix(constraintLimit));
- actor.ApplyConstraint( constraint );
- DALI_TEST_EQUALS( actor.GetProperty<Matrix>(index), startValue, TEST_LOCATION );
-
- application.SendNotification();
- application.Render(0);
-
- DALI_TEST_EQUALS( actor.GetProperty<Matrix>(index), constraintLimit, TEST_LOCATION );
- }
- }
- catch (Dali::DaliException& e)
- {
- tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
- DALI_TEST_CHECK(0);
- }
- END_TEST;
-}
-
-int UtcDaliConstraintNewMatrix3(void)
-{
- try
- {
- TestApplication application;
-
- Actor actor = Actor::New();
-
- // Register a Matrix3 property
- Matrix3 startValue(1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f);
- Property::Index index = actor.RegisterProperty( "test-property", startValue );
- DALI_TEST_CHECK( index != Property::INVALID_INDEX );
- if (index != Property::INVALID_INDEX)
- {
- Stage::GetCurrent().Add(actor);
- DALI_TEST_CHECK( actor.GetProperty<Matrix3>(index) == startValue );
-
- // Apply constraint
- Matrix3 constraintLimit(42.0f, 0.0f, 0.0f, 0.0f, 42.0f, 0.0f, 0.0f, 0.0f, 1.0f);
- Constraint constraint = Constraint::New<Matrix3>( index, TestConstraintMatrix3(constraintLimit));
- actor.ApplyConstraint( constraint );
- DALI_TEST_EQUALS( actor.GetProperty<Matrix3>(index), startValue, 0.001f, TEST_LOCATION );
-
- application.SendNotification();
- application.Render(0);
-
- DALI_TEST_EQUALS( actor.GetProperty<Matrix3>(index), constraintLimit, 0.001f, TEST_LOCATION );
- }
- }
- catch (Dali::DaliException& e)
- {
- tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str() );
- DALI_TEST_CHECK(0);
- }
- END_TEST;
-}
-
-int UtcDaliConstraintNewQuaternion(void)
-{
- TestApplication application;
-
- Actor actor = Actor::New();
-
- // Register a Quaternion property
- Quaternion startValue( 0.0f, Vector3::YAXIS );
- Property::Index index = actor.RegisterProperty( "test-property", startValue );
- Stage::GetCurrent().Add(actor);
- DALI_TEST_EQUALS( actor.GetProperty<Quaternion>(index), startValue, ROTATION_EPSILON, TEST_LOCATION );
-
- /**
- * Test that the Constraint is correctly applied on a clean Node
- */
- application.SendNotification();
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetProperty<Quaternion>(index), startValue, ROTATION_EPSILON, TEST_LOCATION );
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetProperty<Quaternion>(index), startValue, ROTATION_EPSILON, TEST_LOCATION );
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetProperty<Quaternion>(index), startValue, ROTATION_EPSILON, TEST_LOCATION );
-
- // Apply constraint
-
- Quaternion constrainedRotation( M_PI*0.25f, Vector3::YAXIS );
- Constraint constraint = Constraint::New<Quaternion>( index, TestConstraintRotation( constrainedRotation ) );
-
- actor.ApplyConstraint( constraint );
- DALI_TEST_EQUALS( actor.GetProperty<Quaternion>(index), startValue, ROTATION_EPSILON, TEST_LOCATION );
-
- application.SendNotification();
- application.Render(0);
-
- // Constraint should be fully applied
- DALI_TEST_EQUALS( actor.GetProperty<Quaternion>(index), constrainedRotation, ROTATION_EPSILON, TEST_LOCATION );
-
- // Check that nothing has changed after a couple of buffer swaps
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetProperty<Quaternion>(index), constrainedRotation, ROTATION_EPSILON, TEST_LOCATION );
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetProperty<Quaternion>(index), constrainedRotation, ROTATION_EPSILON, TEST_LOCATION );
-
- // Set to a different rotation, the constraint will NOT allow this
- Quaternion differentRotation( M_PI*0.5f, Vector3::YAXIS );
- actor.SetProperty( index, differentRotation );
-
- application.SendNotification();
- application.Render(0);
-
- DALI_TEST_EQUALS( actor.GetProperty<Quaternion>(index), constrainedRotation/*not differentRotation*/, ROTATION_EPSILON, TEST_LOCATION );
-
- // Check that nothing has changed after a couple of buffer swaps
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetProperty<Quaternion>(index), constrainedRotation, ROTATION_EPSILON, TEST_LOCATION );
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetProperty<Quaternion>(index), constrainedRotation, ROTATION_EPSILON, TEST_LOCATION );
-
- // Remove the constraint, then set new value
- actor.RemoveConstraints();
- actor.SetProperty( index, differentRotation );
-
- // Constraint should have been removed
- application.SendNotification();
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetProperty<Quaternion>(index), differentRotation, ROTATION_EPSILON, TEST_LOCATION );
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetProperty<Quaternion>(index), differentRotation, ROTATION_EPSILON, TEST_LOCATION );
- END_TEST;
-}
-
-int UtcDaliConstraintNewOffStageBoolean(void)
-{
- TestApplication application;
-
- Actor actor = Actor::New();
-
- // Register a boolean property
- bool startValue(false);
- Property::Index index = actor.RegisterProperty( "test-property", startValue );
- DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
-
- // Apply constraint to off-stage Actor
- Constraint constraint = Constraint::New<bool>( index, TestAlwaysTrueConstraint() );
- actor.ApplyConstraint( constraint );
-
- application.SendNotification();
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetProperty<bool>(index), false, TEST_LOCATION );
-
- // Add actor to stage
- Stage::GetCurrent().Add(actor);
- application.SendNotification();
- application.Render(0);
-
- // Constraint should be fully applied
- DALI_TEST_EQUALS( actor.GetProperty<bool>(index), true, TEST_LOCATION );
-
- // Check that nothing has changed after a couple of buffer swaps
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetProperty<bool>(index), true, TEST_LOCATION );
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetProperty<bool>(index), true, TEST_LOCATION );
-
- // Take the actor off-stage
- Stage::GetCurrent().Remove(actor);
- application.SendNotification();
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetProperty<bool>(index), true, TEST_LOCATION );
-
- // Set a new value; the constraint will not prevent this
- actor.SetProperty( index, false );
- application.SendNotification();
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetProperty<bool>(index), false, TEST_LOCATION );
-
- // Add actor to stage (2nd time)
- Stage::GetCurrent().Add(actor);
- application.SendNotification();
- application.Render(0);
-
- // Constraint should be fully applied (2nd time)
- DALI_TEST_EQUALS( actor.GetProperty<bool>(index), true, TEST_LOCATION );
-
- // Check that nothing has changed after a couple of buffer swaps
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetProperty<bool>(index), true, TEST_LOCATION );
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetProperty<bool>(index), true, TEST_LOCATION );
-
- // Take the actor off-stage (2nd-time)
- Stage::GetCurrent().Remove(actor);
- application.SendNotification();
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetProperty<bool>(index), true, TEST_LOCATION );
-
- // Remove the constraint, and set a new value
- actor.RemoveConstraints();
- actor.SetProperty( index, false );
- application.SendNotification();
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetProperty<bool>(index), false, TEST_LOCATION );
-
- // Add actor to stage (3rd time)
- Stage::GetCurrent().Add(actor);
- application.SendNotification();
- application.Render(0);
-
- // Constraint should be gone
- DALI_TEST_EQUALS( actor.GetProperty<bool>(index), false, TEST_LOCATION );
-
- // Check that nothing has changed after a couple of buffer swaps
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetProperty<bool>(index), false, TEST_LOCATION );
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetProperty<bool>(index), false, TEST_LOCATION );
- END_TEST;
-}
-
-int UtcDaliConstraintNewOffStageFloat(void)
-{
- TestApplication application;
-
- Actor actor = Actor::New();
-
- // Register a float property
- float startValue(1.0f);
- Property::Index index = actor.RegisterProperty( "test-property", startValue );
- DALI_TEST_CHECK( actor.GetProperty<float>(index) == startValue );
-
- // Apply constraint to off-stage Actor
- float constrainedValue( 2.0f );
- Constraint constraint = Constraint::New<float>( index, TestConstraintFloat( constrainedValue ) );
- actor.ApplyConstraint( constraint );
-
- application.SendNotification();
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
-
- // Add actor to stage
- Stage::GetCurrent().Add(actor);
- application.SendNotification();
- application.Render(0);
-
- // Constraint should be fully applied
- DALI_TEST_EQUALS( actor.GetProperty<float>(index), constrainedValue, TEST_LOCATION );
-
- // Check that nothing has changed after a couple of buffer swaps
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetProperty<float>(index), constrainedValue, TEST_LOCATION );
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetProperty<float>(index), constrainedValue, TEST_LOCATION );
-
- // Take the actor off-stage
- Stage::GetCurrent().Remove(actor);
- application.SendNotification();
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetProperty<float>(index), constrainedValue, TEST_LOCATION );
-
- // Set back to startValue; the constraint will not prevent this
- actor.SetProperty( index, startValue );
- application.SendNotification();
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
-
- // Add actor to stage (2nd time)
- Stage::GetCurrent().Add(actor);
- application.SendNotification();
- application.Render(0);
-
- // Constraint should be fully applied (2nd time)
- DALI_TEST_EQUALS( actor.GetProperty<float>(index), constrainedValue, TEST_LOCATION );
-
- // Check that nothing has changed after a couple of buffer swaps
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetProperty<float>(index), constrainedValue, TEST_LOCATION );
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetProperty<float>(index), constrainedValue, TEST_LOCATION );
-
- // Take the actor off-stage (2nd-time)
- Stage::GetCurrent().Remove(actor);
- application.SendNotification();
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetProperty<float>(index), constrainedValue, TEST_LOCATION );
-
- // Remove the constraint, and set back to startValue
- actor.RemoveConstraints();
- actor.SetProperty( index, startValue );
- application.SendNotification();
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
-
- // Add actor to stage (3rd time)
- Stage::GetCurrent().Add(actor);
- application.SendNotification();
- application.Render(0);
-
- // Constraint should be gone
- DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
-
- // Check that nothing has changed after a couple of buffer swaps
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
- END_TEST;
-}
-
-int UtcDaliConstraintNewOffStageVector2(void)
-{
- TestApplication application;
-
- Actor actor = Actor::New();
-
- // Register a Vector2 property
- Vector2 startValue(1.0f, 1.0f);
- Property::Index index = actor.RegisterProperty( "test-property", startValue );
- DALI_TEST_CHECK( actor.GetProperty<Vector2>(index) == startValue );
-
- // Apply constraint to off-stage Actor
- Vector2 constrainedValue( 2.0f, 2.0f );
- Constraint constraint = Constraint::New<Vector2>( index, TestConstraintVector2( constrainedValue ) );
- actor.ApplyConstraint( constraint );
-
- application.SendNotification();
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
-
- // Add actor to stage
- Stage::GetCurrent().Add(actor);
- application.SendNotification();
- application.Render(0);
-
- // Constraint should be fully applied
- DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), constrainedValue, TEST_LOCATION );
-
- // Check that nothing has changed after a couple of buffer swaps
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), constrainedValue, TEST_LOCATION );
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), constrainedValue, TEST_LOCATION );
-
- // Take the actor off-stage
- Stage::GetCurrent().Remove(actor);
- application.SendNotification();
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), constrainedValue, TEST_LOCATION );
-
- // Set back to startValue; the constraint will not prevent this
- actor.SetProperty( index, startValue );
- application.SendNotification();
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
-
- // Add actor to stage (2nd time)
- Stage::GetCurrent().Add(actor);
- application.SendNotification();
- application.Render(0);
-
- // Constraint should be fully applied (2nd time)
- DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), constrainedValue, TEST_LOCATION );
-
- // Check that nothing has changed after a couple of buffer swaps
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), constrainedValue, TEST_LOCATION );
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), constrainedValue, TEST_LOCATION );
-
- // Take the actor off-stage (2nd-time)
- Stage::GetCurrent().Remove(actor);
- application.SendNotification();
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), constrainedValue, TEST_LOCATION );
-
- // Remove the constraint, and set back to startValue
- actor.RemoveConstraints();
- actor.SetProperty( index, startValue );
- application.SendNotification();
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
-
- // Add actor to stage (3rd time)
- Stage::GetCurrent().Add(actor);
- application.SendNotification();
- application.Render(0);
-
- // Constraint should be gone
- DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
-
- // Check that nothing has changed after a couple of buffer swaps
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
- END_TEST;
-}
-
-int UtcDaliConstraintNewOffStageVector3(void)
-{
- TestApplication application;
- Vector3 startValue(1.0f, 1.0f, 1.0f);
- Vector3 constrainedValue = Vector3( 2.0f, 3.0f, 4.0f );
-
- Actor actor = Actor::New();
- // Register a Vector3 property
-
- Property::Index index = actor.RegisterProperty( "test-property", startValue );
- DALI_TEST_CHECK( actor.GetProperty<Vector3>(index) == startValue );
-
- // Apply constraint to off-stage Actor
- Constraint constraint = Constraint::New<Vector3>( index, TestConstraintVector3( constrainedValue ) );
- actor.ApplyConstraint( constraint );
-
- application.SendNotification();
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
-
- // Add actor to stage
- Stage::GetCurrent().Add(actor);
- application.SendNotification();
- application.Render();
-
- // Constraint should be fully applied
- DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), constrainedValue, TEST_LOCATION );
-
- // Check that nothing has changed after a couple of buffer swaps
- application.Render();
- DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), constrainedValue, TEST_LOCATION );
- application.Render();
- DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), constrainedValue, TEST_LOCATION );
-
- // Take the actor off-stage
- Stage::GetCurrent().Remove(actor);
- application.SendNotification();
- application.Render();
- DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), constrainedValue, TEST_LOCATION );
-
- // Set back to startValue; the constraint will not prevent this
- Vector3 intermediateValue(5.0f, 6.0f, 7.0f);
- actor.SetProperty( index, intermediateValue );
- application.SendNotification();
- application.Render();
- application.Render(); // ensure both buffers are set to intermediateValue
- DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), intermediateValue, TEST_LOCATION );
-
- // Add actor to stage (2nd time)
- Stage::GetCurrent().Add(actor);
- application.SendNotification();
- application.Render();
-
- // Constraint should be fully applied (2nd time)
- DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), constrainedValue, TEST_LOCATION );
-
- // Check that nothing has changed after a couple of buffer swaps
- application.Render();
- DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), constrainedValue, TEST_LOCATION );
- application.Render();
- DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), constrainedValue, TEST_LOCATION );
-
- // Take the actor off-stage (2nd-time)
- Stage::GetCurrent().Remove(actor);
- application.SendNotification();
- application.Render();
- DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), constrainedValue, TEST_LOCATION );
-
- // Remove the constraint, and set back to startValue
- actor.RemoveConstraints();
- actor.SetProperty( index, startValue );
- application.SendNotification();
- application.Render();
- DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
-
- // Add actor to stage (3rd time)
- Stage::GetCurrent().Add(actor);
- application.SendNotification();
- application.Render();
-
- // Constraint should be gone
- DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
-
- // Check that nothing has changed after a couple of buffer swaps
- application.Render();
- DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
- application.Render();
- DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
- END_TEST;
-}
-
-int UtcDaliConstraintNewOffStageVector4(void)
-{
- TestApplication application;
-
- Actor actor = Actor::New();
-
- // Register a Vector4 property
- Vector4 startValue(1.0f, 1.0f, 1.0f, 1.0f);
- Property::Index index = actor.RegisterProperty( "test-property", startValue );
- DALI_TEST_CHECK( actor.GetProperty<Vector4>(index) == startValue );
-
- // Apply constraint to off-stage Actor
- Vector4 constrainedValue( 2.0f, 2.0f, 2.0f, 2.0f );
- Constraint constraint = Constraint::New<Vector4>( index, TestConstraintVector4( constrainedValue ) );
- actor.ApplyConstraint( constraint );
-
- application.SendNotification();
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
-
- // Add actor to stage
- Stage::GetCurrent().Add(actor);
- application.SendNotification();
- application.Render(0);
-
- // Constraint should be fully applied
- DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), constrainedValue, TEST_LOCATION );
-
- // Check that nothing has changed after a couple of buffer swaps
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), constrainedValue, TEST_LOCATION );
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), constrainedValue, TEST_LOCATION );
-
- // Take the actor off-stage
- Stage::GetCurrent().Remove(actor);
- application.SendNotification();
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), constrainedValue, TEST_LOCATION );
-
- // Set back to startValue; the constraint will not prevent this
- actor.SetProperty( index, startValue );
- application.SendNotification();
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
-
- // Add actor to stage (2nd time)
- Stage::GetCurrent().Add(actor);
- application.SendNotification();
- application.Render(0);
-
- // Constraint should be fully applied (2nd time)
- DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), constrainedValue, TEST_LOCATION );
-
- // Check that nothing has changed after a couple of buffer swaps
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), constrainedValue, TEST_LOCATION );
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), constrainedValue, TEST_LOCATION );
-
- // Take the actor off-stage (2nd-time)
- Stage::GetCurrent().Remove(actor);
- application.SendNotification();
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), constrainedValue, TEST_LOCATION );
-
- // Remove the constraint, and set back to startValue
- actor.RemoveConstraints();
- actor.SetProperty( index, startValue );
- application.SendNotification();
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
-
- // Add actor to stage (3rd time)
- Stage::GetCurrent().Add(actor);
- application.SendNotification();
- application.Render(0);
-
- // Constraint should be gone
- DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
-
- // Check that nothing has changed after a couple of buffer swaps
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
- END_TEST;
-}
-
-int UtcDaliConstraintNewOffStageQuaternion(void)
-{
- TestApplication application;
-
- Actor actor = Actor::New();
-
- // Register a Quaternion property
- Quaternion startValue( 0.0f, Vector3::YAXIS );
- Property::Index index = actor.RegisterProperty( "test-property", startValue );
- DALI_TEST_EQUALS( actor.GetProperty<Quaternion>(index), startValue, ROTATION_EPSILON, TEST_LOCATION );
-
- // Apply constraint to off-stage Actor
- Quaternion constrainedRotation( M_PI*0.25f, Vector3::YAXIS );
- Constraint constraint = Constraint::New<Quaternion>( index, TestConstraintRotation( constrainedRotation ) );
- actor.ApplyConstraint( constraint );
-
- application.SendNotification();
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetProperty<Quaternion>(index), startValue, ROTATION_EPSILON, TEST_LOCATION );
-
- // Add actor to stage
- Stage::GetCurrent().Add(actor);
- application.SendNotification();
- application.Render(0);
-
- // Constraint should be fully applied
- DALI_TEST_EQUALS( actor.GetProperty<Quaternion>(index), constrainedRotation, ROTATION_EPSILON, TEST_LOCATION );
-
- // Check that nothing has changed after a couple of buffer swaps
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetProperty<Quaternion>(index), constrainedRotation, ROTATION_EPSILON, TEST_LOCATION );
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetProperty<Quaternion>(index), constrainedRotation, ROTATION_EPSILON, TEST_LOCATION );
-
- // Take the actor off-stage
- Stage::GetCurrent().Remove(actor);
- application.SendNotification();
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetProperty<Quaternion>(index), constrainedRotation, ROTATION_EPSILON, TEST_LOCATION );
-
- // Set back to startValue; the constraint will not prevent this
- actor.SetProperty( index, startValue );
- application.SendNotification();
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetProperty<Quaternion>(index), startValue, ROTATION_EPSILON, TEST_LOCATION );
-
- // Add actor to stage (2nd time)
- Stage::GetCurrent().Add(actor);
- application.SendNotification();
- application.Render(0);
-
- // Constraint should be fully applied (2nd time)
- DALI_TEST_EQUALS( actor.GetProperty<Quaternion>(index), constrainedRotation, ROTATION_EPSILON, TEST_LOCATION );
-
- // Check that nothing has changed after a couple of buffer swaps
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetProperty<Quaternion>(index), constrainedRotation, ROTATION_EPSILON, TEST_LOCATION );
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetProperty<Quaternion>(index), constrainedRotation, ROTATION_EPSILON, TEST_LOCATION );
-
- // Take the actor off-stage (2nd-time)
- Stage::GetCurrent().Remove(actor);
- application.SendNotification();
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetProperty<Quaternion>(index), constrainedRotation, ROTATION_EPSILON, TEST_LOCATION );
-
- // Remove the constraint, and set back to startValue
- actor.RemoveConstraints();
- actor.SetProperty( index, startValue );
- application.SendNotification();
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetProperty<Quaternion>(index), startValue, ROTATION_EPSILON, TEST_LOCATION );
-
- // Add actor to stage (3rd time)
- Stage::GetCurrent().Add(actor);
- application.SendNotification();
- application.Render(0);
-
- // Constraint should be gone
- DALI_TEST_EQUALS( actor.GetProperty<Quaternion>(index), startValue, ROTATION_EPSILON, TEST_LOCATION );
-
- // Check that nothing has changed after a couple of buffer swaps
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetProperty<Quaternion>(index), startValue, ROTATION_EPSILON, TEST_LOCATION );
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetProperty<Quaternion>(index), startValue, ROTATION_EPSILON, TEST_LOCATION );
- END_TEST;
-}
-
-int UtcDaliConstraintNewLocalInput(void)
-{
- TestApplication application;
-
- Actor actor = Actor::New();
- Stage::GetCurrent().Add(actor);
-
- Vector3 startValue( 0.0f, 0.0f, 0.0f );
- float distanceWhenFullyTransparent( 100.0f );
-
- /**
- * Test that the Constraint is correctly applied on a clean Node
- */
- application.SendNotification();
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::POSITION ), startValue, TEST_LOCATION );
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::POSITION ), startValue, TEST_LOCATION );
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::POSITION ), startValue, TEST_LOCATION );
-
- // Apply constraint with a local input property
-
- Constraint constraint = Constraint::New<Vector3>( Actor::POSITION,
- LocalSource( Actor::COLOR ),
- MoveAwayWithFadeConstraint(distanceWhenFullyTransparent) );
-
- actor.ApplyConstraint( constraint );
- DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::POSITION ), startValue, TEST_LOCATION );
-
- application.SendNotification();
- application.Render(0);
-
- // Gradually set the color to fully-transparent; the actor should move back
-
- for ( float progress = 0.0f; progress < 1.1f; progress += 0.1f )
- {
- actor.SetOpacity( 1.0f - progress );
-
- application.SendNotification();
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::POSITION ), ( startValue - Vector3(0.0f, 0.0f, progress*distanceWhenFullyTransparent) ), POSITION_EPSILON, TEST_LOCATION );
- }
- DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::POSITION ), ( startValue - Vector3(0.0f, 0.0f, distanceWhenFullyTransparent) ), POSITION_EPSILON, TEST_LOCATION );
- END_TEST;
-}
-
-int UtcDaliConstraintNewParentInput(void)
-{
- TestApplication application;
-
- Actor parent = Actor::New();
- Vector3 parentStartSize( 100.0f, 100.0f, 0.0f );
- parent.SetSize( parentStartSize );
- Stage::GetCurrent().Add( parent );
-
- Actor actor = Actor::New();
- parent.Add( actor );
-
- Vector3 startValue( 0.0f, 0.0f, 0.0f );
-
- /**
- * Test that the Constraint is correctly applied on a clean Node
- */
- application.SendNotification();
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::POSITION ), startValue, TEST_LOCATION );
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::POSITION ), startValue, TEST_LOCATION );
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::POSITION ), startValue, TEST_LOCATION );
-
- // Apply constraint with a parent input property
-
- Constraint constraint = Constraint::New<Vector3>( Actor::POSITION,
- ParentSource( Actor::SIZE ),
- TestBottomRightAlignConstraint() );
-
- actor.ApplyConstraint( constraint );
- DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::POSITION ), startValue, TEST_LOCATION );
-
- application.SendNotification();
- application.Render(0);
-
- DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::POSITION ), parentStartSize, TEST_LOCATION );
- DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::POSITION ), parent.GetCurrentSize(), TEST_LOCATION );
-
- // Gradually shrink the parent; the actor should move inwards
-
- for ( float progress = 0.0f; progress < 1.1f; progress += 0.1f )
- {
- Vector3 size( parentStartSize * std::max(0.0f, 1.0f - progress) );
- parent.SetSize( size );
-
- application.SendNotification();
- application.Render(0);
-
- DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::POSITION ), size, POSITION_EPSILON, TEST_LOCATION );
- DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::POSITION ), parent.GetCurrentSize(), POSITION_EPSILON, TEST_LOCATION );
- }
- DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::POSITION ), Vector3::ZERO, POSITION_EPSILON, TEST_LOCATION );
- END_TEST;
-}
-
-int UtcDaliConstraintNewInput1(void)
-{
- TestApplication application;
-
- Actor parent = Actor::New();
- Vector3 parentStartSize( 100.0f, 100.0f, 0.0f );
- parent.SetSize( parentStartSize );
- Stage::GetCurrent().Add( parent );
-
- Actor actor = Actor::New();
- parent.Add( actor );
-
- Actor sibling1 = Actor::New();
- sibling1.SetPosition( Vector3(1.0f, 2.0f, 3.0f) );
- parent.Add( sibling1 );
-
- Vector3 startValue( 0.0f, 0.0f, 0.0f );
-
- /**
- * Test that the Constraint is correctly applied on a clean Node
- */
- application.SendNotification();
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::POSITION ), startValue, TEST_LOCATION );
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::POSITION ), startValue, TEST_LOCATION );
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::POSITION ), startValue, TEST_LOCATION );
-
- // Apply constraint with a parent input property
-
- Constraint constraint = Constraint::New<Vector3>( Actor::POSITION,
- Source( sibling1, Actor::POSITION ),
- MeanPositionConstraint1() );
-
- actor.ApplyConstraint( constraint );
- DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::POSITION ), startValue, TEST_LOCATION );
-
- application.SendNotification();
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::POSITION ), sibling1.GetCurrentPosition(), TEST_LOCATION );
-
- // Check that nothing has changed after a couple of buffer swaps
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::POSITION ), sibling1.GetCurrentPosition(), TEST_LOCATION );
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::POSITION ), sibling1.GetCurrentPosition(), TEST_LOCATION );
- END_TEST;
-}
-
-int UtcDaliConstraintNewInput2(void)
-{
- TestApplication application;
-
- Actor parent = Actor::New();
- Vector3 parentStartSize( 100.0f, 100.0f, 0.0f );
- parent.SetSize( parentStartSize );
- Stage::GetCurrent().Add( parent );
-
- Actor actor = Actor::New();
- parent.Add( actor );
-
- Actor sibling1 = Actor::New();
- sibling1.SetPosition( Vector3(1.0f, 2.0f, 3.0f) );
- parent.Add( sibling1 );
-
- Actor sibling2 = Actor::New();
- sibling2.SetPosition( Vector3(300.0f, 300.0f, 300.0f) );
- parent.Add( sibling2 );
-
- application.SendNotification();
- application.Render(0);
-
- Vector3 startValue( 0.0f, 0.0f, 0.0f );
- Vector3 meanValue = sibling1.GetCurrentPosition() +
- sibling2.GetCurrentPosition();
- meanValue *= (1.0f / 2.0f); // divide by number of siblings
-
- /**
- * Test that the Constraint is correctly applied on a clean Node
- */
- application.SendNotification();
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::POSITION ), startValue, TEST_LOCATION );
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::POSITION ), startValue, TEST_LOCATION );
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::POSITION ), startValue, TEST_LOCATION );
-
- // Apply constraint with a parent input property
-
- Constraint constraint = Constraint::New<Vector3>( Actor::POSITION,
- Source( sibling1, Actor::POSITION ),
- Source( sibling2, Actor::POSITION ),
- MeanPositionConstraint2() );
-
- actor.ApplyConstraint( constraint );
- DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::POSITION ), startValue, TEST_LOCATION );
-
- application.SendNotification();
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::POSITION ), meanValue, POSITION_EPSILON, TEST_LOCATION );
-
- // Check that nothing has changed after a couple of buffer swaps
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::POSITION ), meanValue, POSITION_EPSILON, TEST_LOCATION );
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::POSITION ), meanValue, POSITION_EPSILON, TEST_LOCATION );
- END_TEST;
-}
-
-int UtcDaliConstraintNewInput3(void)
-{
- TestApplication application;
-
- Actor parent = Actor::New();
- Vector3 parentStartSize( 100.0f, 100.0f, 0.0f );
- parent.SetSize( parentStartSize );
- Stage::GetCurrent().Add( parent );
-
- Actor actor = Actor::New();
- parent.Add( actor );
-
- Actor sibling1 = Actor::New();
- sibling1.SetPosition( Vector3(1.0f, 2.0f, 3.0f) );
- parent.Add( sibling1 );
-
- Actor sibling2 = Actor::New();
- sibling2.SetPosition( Vector3(300.0f, 300.0f, 300.0f) );
- parent.Add( sibling2 );
-
- Actor sibling3 = Actor::New();
- sibling3.SetPosition( Vector3(-100.0f, -10.0f, -1.0f) );
- parent.Add( sibling3 );
-
- application.SendNotification();
- application.Render(0);
-
- Vector3 startValue( 0.0f, 0.0f, 0.0f );
- Vector3 meanValue = sibling1.GetCurrentPosition() +
- sibling2.GetCurrentPosition() +
- sibling3.GetCurrentPosition();
- meanValue *= (1.0f / 3.0f); // divide by number of siblings
-
- /**
- * Test that the Constraint is correctly applied on a clean Node
- */
- application.SendNotification();
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::POSITION ), startValue, TEST_LOCATION );
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::POSITION ), startValue, TEST_LOCATION );
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::POSITION ), startValue, TEST_LOCATION );
-
- // Apply constraint with a parent input property
-
- Constraint constraint = Constraint::New<Vector3>( Actor::POSITION,
- Source( sibling1, Actor::POSITION ),
- Source( sibling2, Actor::POSITION ),
- Source( sibling3, Actor::POSITION ),
- MeanPositionConstraint3() );
-
- actor.ApplyConstraint( constraint );
- DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::POSITION ), startValue, TEST_LOCATION );
-
- application.SendNotification();
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::POSITION ), meanValue, POSITION_EPSILON, TEST_LOCATION );
-
- // Check that nothing has changed after a couple of buffer swaps
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::POSITION ), meanValue, POSITION_EPSILON, TEST_LOCATION );
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::POSITION ), meanValue, POSITION_EPSILON, TEST_LOCATION );
- END_TEST;
-}
-
-int UtcDaliConstraintNewInput4(void)
-{
- TestApplication application;
-
- Actor parent = Actor::New();
- Vector3 parentStartSize( 100.0f, 100.0f, 0.0f );
- parent.SetSize( parentStartSize );
- parent.SetPosition( 10.0f, 10.0f, 10.0f );
- Stage::GetCurrent().Add( parent );
-
- Actor actor = Actor::New();
- parent.Add( actor );
-
- Actor sibling1 = Actor::New();
- sibling1.SetPosition( Vector3(1.0f, 2.0f, 3.0f) );
- parent.Add( sibling1 );
-
- Actor sibling2 = Actor::New();
- sibling2.SetPosition( Vector3(300.0f, 300.0f, 300.0f) );
- parent.Add( sibling2 );
-
- Actor sibling3 = Actor::New();
- sibling3.SetPosition( Vector3(-100.0f, -10.0f, -1.0f) );
- parent.Add( sibling3 );
-
- application.SendNotification();
- application.Render(0);
-
- Vector3 startValue( 0.0f, 0.0f, 0.0f );
- Vector3 meanValue = parent.GetCurrentPosition() +
- sibling1.GetCurrentPosition() +
- sibling2.GetCurrentPosition() +
- sibling3.GetCurrentPosition();
- meanValue *= (1.0f / 4.0f); // divide by number of positions
-
- /**
- * Test that the Constraint is correctly applied on a clean Node
- */
- application.SendNotification();
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::POSITION ), startValue, TEST_LOCATION );
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::POSITION ), startValue, TEST_LOCATION );
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::POSITION ), startValue, TEST_LOCATION );
-
- // Apply constraint with a parent input property
-
- Constraint constraint = Constraint::New<Vector3>( Actor::POSITION,
- Source( sibling1, Actor::POSITION ),
- Source( sibling2, Actor::POSITION ),
- ParentSource( Actor::POSITION ),
- Source( sibling3, Actor::POSITION ),
- MeanPositionConstraint4() );
-
- actor.ApplyConstraint( constraint );
- DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::POSITION ), startValue, TEST_LOCATION );
-
- application.SendNotification();
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::POSITION ), meanValue, POSITION_EPSILON, TEST_LOCATION );
-
- // Check that nothing has changed after a couple of buffer swaps
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::POSITION ), meanValue, POSITION_EPSILON, TEST_LOCATION );
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::POSITION ), meanValue, POSITION_EPSILON, TEST_LOCATION );
- END_TEST;
-}
-
-int UtcDaliConstraintNewInput5(void)
-{
- TestApplication application;
-
- Actor parent = Actor::New();
- Vector3 parentStartSize( 100.0f, 100.0f, 0.0f );
- parent.SetSize( parentStartSize );
- parent.SetPosition( 10.0f, 10.0f, 10.0f );
- Stage::GetCurrent().Add( parent );
-
- Actor actor = Actor::New();
- parent.Add( actor );
-
- Actor sibling1 = Actor::New();
- sibling1.SetPosition( Vector3(1.0f, 2.0f, 3.0f) );
- parent.Add( sibling1 );
-
- Actor sibling2 = Actor::New();
- sibling2.SetPosition( Vector3(300.0f, 300.0f, 300.0f) );
- parent.Add( sibling2 );
-
- Actor sibling3 = Actor::New();
- sibling3.SetPosition( Vector3(-100.0f, -10.0f, -1.0f) );
- parent.Add( sibling3 );
-
- Actor sibling4 = Actor::New();
- sibling4.SetPosition( Vector3(-1.0f, 1.0f, 2.0f) );
- parent.Add( sibling4 );
-
- application.SendNotification();
- application.Render(0);
-
- Vector3 startValue( 0.0f, 0.0f, 0.0f );
- Vector3 meanValue = parent.GetCurrentPosition() +
- sibling1.GetCurrentPosition() +
- sibling2.GetCurrentPosition() +
- sibling3.GetCurrentPosition() +
- sibling4.GetCurrentPosition();
- meanValue *= (1.0f / 5.0f); // divide by number of positions
-
- /**
- * Test that the Constraint is correctly applied on a clean Node
- */
- application.SendNotification();
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::POSITION ), startValue, TEST_LOCATION );
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::POSITION ), startValue, TEST_LOCATION );
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::POSITION ), startValue, TEST_LOCATION );
-
- // Apply constraint with a parent input property
-
- Constraint constraint = Constraint::New<Vector3>( Actor::POSITION,
- Source( sibling1, Actor::POSITION ),
- Source( sibling2, Actor::POSITION ),
- ParentSource( Actor::POSITION ),
- Source( sibling3, Actor::POSITION ),
- Source( sibling4, Actor::POSITION ),
- MeanPositionConstraint5() );
-
- actor.ApplyConstraint( constraint );
- DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::POSITION ), startValue, TEST_LOCATION );
-
- application.SendNotification();
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::POSITION ), meanValue, POSITION_EPSILON, TEST_LOCATION );
-
- // Check that nothing has changed after a couple of buffer swaps
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::POSITION ), meanValue, POSITION_EPSILON, TEST_LOCATION );
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::POSITION ), meanValue, POSITION_EPSILON, TEST_LOCATION );
- END_TEST;
-}
-
-int UtcDaliConstraintNewInput6(void)
-{
- TestApplication application;
-
- Actor parent = Actor::New();
- Vector3 parentStartSize( 100.0f, 100.0f, 0.0f );
- parent.SetSize( parentStartSize );
- parent.SetPosition( 10.0f, 10.0f, 10.0f );
- Stage::GetCurrent().Add( parent );
-
- Actor actor = Actor::New();
- parent.Add( actor );
-
- Actor child = Actor::New();
- child.SetPosition( Vector3(7.0f, 7.0f, 7.0f) );
- actor.Add( child );
-
- Actor sibling1 = Actor::New();
- sibling1.SetPosition( Vector3(1.0f, 2.0f, 3.0f) );
- parent.Add( sibling1 );
-
- Actor sibling2 = Actor::New();
- sibling2.SetPosition( Vector3(300.0f, 300.0f, 300.0f) );
- parent.Add( sibling2 );
-
- Actor sibling3 = Actor::New();
- sibling3.SetPosition( Vector3(-100.0f, -10.0f, -1.0f) );
- parent.Add( sibling3 );
-
- Actor sibling4 = Actor::New();
- sibling4.SetPosition( Vector3(-1.0f, 1.0f, 2.0f) );
- parent.Add( sibling4 );
-
- application.SendNotification();
- application.Render(0);
-
- Vector3 startValue( 0.0f, 0.0f, 0.0f );
- Vector3 meanValue = parent.GetCurrentPosition() +
- child.GetCurrentPosition() +
- sibling1.GetCurrentPosition() +
- sibling2.GetCurrentPosition() +
- sibling3.GetCurrentPosition() +
- sibling4.GetCurrentPosition();
- meanValue *= (1.0f / 6.0f); // divide by number of positions
-
- /**
- * Test that the Constraint is correctly applied on a clean Node
- */
- application.SendNotification();
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::POSITION ), startValue, TEST_LOCATION );
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::POSITION ), startValue, TEST_LOCATION );
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::POSITION ), startValue, TEST_LOCATION );
-
- // Apply constraint with a parent input property
-
- Constraint constraint = Constraint::New<Vector3>( Actor::POSITION,
- Source( child, Actor::POSITION ),
- Source( sibling1, Actor::POSITION ),
- Source( sibling2, Actor::POSITION ),
- ParentSource( Actor::POSITION ),
- Source( sibling3, Actor::POSITION ),
- Source( sibling4, Actor::POSITION ),
- MeanPositionConstraint6() );
-
- actor.ApplyConstraint( constraint );
- DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::POSITION ), startValue, TEST_LOCATION );
-
- application.SendNotification();
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::POSITION ), meanValue, POSITION_EPSILON, TEST_LOCATION );
-
- // Check that nothing has changed after a couple of buffer swaps
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::POSITION ), meanValue, POSITION_EPSILON, TEST_LOCATION );
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::POSITION ), meanValue, POSITION_EPSILON, TEST_LOCATION );
- END_TEST;
-}
-
-int UtcDaliConstraintDownCast(void)
-{
- TestApplication application;
- tet_infoline("Testing Dali::Constraint::DownCast()");
-
- Actor actor = Actor::New();
-
- // Register a boolean property
- bool startValue(false);
- Property::Index index = actor.RegisterProperty( "test-property", startValue );
- Constraint constraint = Constraint::New<bool>( index, TestAlwaysTrueConstraint() );
-
- BaseHandle object(constraint);
-
- Constraint constraint2 = Constraint::DownCast(object);
- DALI_TEST_CHECK(constraint2);
-
- Constraint constraint3 = DownCast< Constraint >(object);
- DALI_TEST_CHECK(constraint3);
-
- BaseHandle unInitializedObject;
- Constraint constraint4 = Constraint::DownCast(unInitializedObject);
- DALI_TEST_CHECK(!constraint4);
-
- Constraint constraint5 = DownCast< Constraint >(unInitializedObject);
- DALI_TEST_CHECK(!constraint5);
- END_TEST;
-}
-
-int UtcDaliConstraintSetApplyTime(void)
-{
- TestApplication application;
-
- // Build constraint
-
- Vector4 targetColor(Color::BLACK);
- Constraint constraint = Constraint::New<Vector4>( Actor::COLOR, TestColorConstraint(targetColor) );
- DALI_TEST_EQUALS(constraint.GetApplyTime(), TimePeriod(0.0f), TEST_LOCATION);
-
- float applySeconds(7.0f);
- constraint.SetApplyTime(applySeconds);
- DALI_TEST_EQUALS(constraint.GetApplyTime(), TimePeriod(applySeconds), TEST_LOCATION);
-
- // Apply to an actor
-
- Actor actor = Actor::New();
- Stage::GetCurrent().Add(actor);
-
- actor.ApplyConstraint( constraint );
- DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(applySeconds*200.0f)/* 20% progress */);
-
- // Constraint shouldn't be fully applied yet
- Vector4 twentyPercentColor( Color::WHITE.x*0.8f, Color::WHITE.y*0.8f, Color::WHITE.z*0.8f, Color::WHITE.a );
- DALI_TEST_EQUALS( actor.GetCurrentColor(), twentyPercentColor, TEST_LOCATION );
-
- // Constraint shouldn't be fully applied yet
- application.Render(static_cast<unsigned int>(applySeconds*200.0f)/* 40% progress */);
- Vector4 fourtyPercentColor( Color::WHITE.x*0.6f, Color::WHITE.y*0.6f, Color::WHITE.z*0.6f, Color::WHITE.a );
- DALI_TEST_EQUALS( actor.GetCurrentColor(), fourtyPercentColor, TEST_LOCATION );
-
- // Constraint shouldn't be fully applied yet
- application.Render(static_cast<unsigned int>(applySeconds*200.0f)/* 60% progress */);
- Vector4 sixtyPercentColor( Color::WHITE.x*0.4f, Color::WHITE.y*0.4f, Color::WHITE.z*0.4f, Color::WHITE.a );
- DALI_TEST_EQUALS( actor.GetCurrentColor(), sixtyPercentColor, TEST_LOCATION );
-
- // Constraint shouldn't be fully applied yet
- application.Render(static_cast<unsigned int>(applySeconds*200.0f)/* 80% progress */);
- Vector4 eightyPercentColor( Color::WHITE.x*0.2f, Color::WHITE.y*0.2f, Color::WHITE.z*0.2f, Color::WHITE.a );
- DALI_TEST_EQUALS( actor.GetCurrentColor(), eightyPercentColor, TEST_LOCATION );
-
- // Constraint should be fully applied
- application.Render(static_cast<unsigned int>(applySeconds*200.0f)/* 100% progress */);
- DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION );
-
- // Constraint should still be fully applied
- application.Render(static_cast<unsigned int>(applySeconds*200.0f)/* Still 100% progress */);
- DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION );
-
- // Check that nothing has changed after a couple of buffer swaps
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION );
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION );
- END_TEST;
-}
-
-int UtcDaliConstraintGetApplyTime(void)
-{
- TestApplication application;
-
- Constraint constraint = Constraint::New<Vector4>( Actor::COLOR, TestConstraint() );
- DALI_TEST_EQUALS(constraint.GetApplyTime(), TimePeriod(0.0f), TEST_LOCATION);
-
- float applySeconds(7.0f);
- constraint.SetApplyTime(applySeconds);
- DALI_TEST_EQUALS(constraint.GetApplyTime(), TimePeriod(applySeconds), TEST_LOCATION);
-
- constraint.SetApplyTime(applySeconds - 3.0f);
- DALI_TEST_EQUALS(constraint.GetApplyTime(), TimePeriod(applySeconds - 3.0f), TEST_LOCATION);
- END_TEST;
-}
-
-int UtcDaliConstraintSetRemoveTime(void)
-{
- TestApplication application;
-
- Vector3 sourcePosition(0.0f, 0.0f, 0.0f);
- Vector3 targetPosition(100.0f, 100.0f, 100.0f);
-
- // Build constraint
-
- Constraint constraint = Constraint::New<Vector3>( Actor::POSITION, TestPositionConstraint(targetPosition) );
- DALI_TEST_EQUALS(constraint.GetRemoveTime(), TimePeriod(0.0f), TEST_LOCATION);
-
- float removeSeconds(8.0f);
- constraint.SetRemoveTime(removeSeconds);
- DALI_TEST_EQUALS(constraint.GetRemoveTime(), TimePeriod(removeSeconds), TEST_LOCATION);
-
- // Apply to an actor
-
- Actor actor = Actor::New();
- Stage::GetCurrent().Add(actor);
-
- actor.ApplyConstraint( constraint );
- DALI_TEST_EQUALS( actor.GetCurrentPosition(), sourcePosition, TEST_LOCATION );
-
- application.SendNotification();
- application.Render(100u/*0.1 seconds*/);
-
- // Constraint should be fully applied
- DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
-
- // Check that nothing has changed after a couple of buffer swaps
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
-
- // Remove from the actor, and set to alternative position
-
- actor.RemoveConstraints();
-
- Vector3 thirdPosition(200.0f, 200.0f, 200.0f);
- actor.SetPosition(thirdPosition); // Go back to 3rd position
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(removeSeconds*200.0f)/* 20% removal progress */);
-
- // Constraint shouldn't be fully removed yet
- Vector3 twentyPercentBack( targetPosition + (thirdPosition - targetPosition)*0.2f );
- DALI_TEST_EQUALS( actor.GetCurrentPosition(), twentyPercentBack, TEST_LOCATION );
-
- application.Render(static_cast<unsigned int>(removeSeconds*200.0f)/* 40% removal progress */);
-
- // Constraint shouldn't be fully removed yet
- Vector3 fourtyPercentBack( targetPosition + (thirdPosition - targetPosition)*0.4f );
- DALI_TEST_EQUALS( actor.GetCurrentPosition(), fourtyPercentBack, TEST_LOCATION );
-
- application.Render(static_cast<unsigned int>(removeSeconds*200.0f)/* 60% removal progress */);
-
- // Constraint shouldn't be fully removed yet
- Vector3 sixtyPercentBack( targetPosition + (thirdPosition - targetPosition)*0.6f );
- DALI_TEST_EQUALS( actor.GetCurrentPosition(), sixtyPercentBack, TEST_LOCATION );
-
- application.Render(static_cast<unsigned int>(removeSeconds*200.0f)/* 80% removal progress */);
-
- // Constraint shouldn't be fully removed yet
- Vector3 eightyPercentBack( targetPosition + (thirdPosition - targetPosition)*0.8f );
- DALI_TEST_EQUALS( actor.GetCurrentPosition(), eightyPercentBack, TEST_LOCATION );
-
- // Constraint should be fully removed
- application.Render(static_cast<unsigned int>(removeSeconds*200.0f)/* 100% removal progress */);
- DALI_TEST_EQUALS( actor.GetCurrentPosition(), thirdPosition, TEST_LOCATION );
-
- // Constraint should still be fully applied
- application.Render(static_cast<unsigned int>(removeSeconds*200.0f)/* Still 100% removal progress */);
- DALI_TEST_EQUALS( actor.GetCurrentPosition(), thirdPosition, TEST_LOCATION );
-
- // Check that nothing has changed after a couple of buffer swaps
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetCurrentPosition(), thirdPosition, TEST_LOCATION );
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetCurrentPosition(), thirdPosition, TEST_LOCATION );
- END_TEST;
-}
-
-int UtcDaliConstraintGetRemoveTime(void)
-{
- TestApplication application;
-
- Constraint constraint = Constraint::New<Vector4>( Actor::COLOR, TestConstraint() );
- DALI_TEST_EQUALS(constraint.GetRemoveTime(), TimePeriod(0.0f), TEST_LOCATION);
- END_TEST;
-}
-
-int UtcDaliConstraintSetAlphaFunction(void)
-{
- TestApplication application;
-
- Vector3 startValue( Vector3::ZERO );
- Vector3 targetValue(100.0f, 100.0f, 100.0f);
-
- Constraint constraint = Constraint::New<Vector3>( Actor::POSITION,
- TestConstraintVector3( targetValue ) );
-
- // Test the alpha-function itself
-
- AlphaFunction func = constraint.GetAlphaFunction();
- DALI_TEST_EQUALS(func(0.1f), 0.1f, TEST_LOCATION); // Default is Linear
-
- // Test that the alpha-function is used correctly
-
- Actor actor = Actor::New();
- Stage::GetCurrent().Add(actor);
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(1000.0f/*1 second*/));
- DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::POSITION ), startValue, TEST_LOCATION );
- application.Render(static_cast<unsigned int>(1000.0f/*1 second*/));
- DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::POSITION ), startValue, TEST_LOCATION );
- application.Render(static_cast<unsigned int>(1000.0f/*1 second*/));
- DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::POSITION ), startValue, TEST_LOCATION );
-
- constraint.SetApplyTime( 10.0f );
- actor.ApplyConstraint( constraint );
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(1000.0f/*1 second*/));
- DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::POSITION ), (targetValue - startValue) * 0.1f, TEST_LOCATION );
- application.Render(static_cast<unsigned int>(1000.0f/*1 second*/));
- DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::POSITION ), (targetValue - startValue) * 0.2f, TEST_LOCATION );
- application.Render(static_cast<unsigned int>(1000.0f/*1 second*/));
- DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::POSITION ), (targetValue - startValue) * 0.3f, TEST_LOCATION );
- application.Render(static_cast<unsigned int>(1000.0f/*1 second*/));
- DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::POSITION ), (targetValue - startValue) * 0.4f, TEST_LOCATION );
- application.Render(static_cast<unsigned int>(1000.0f/*1 second*/));
- DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::POSITION ), (targetValue - startValue) * 0.5f, TEST_LOCATION );
- application.Render(static_cast<unsigned int>(1000.0f/*1 second*/));
- DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::POSITION ), (targetValue - startValue) * 0.6f, TEST_LOCATION );
- application.Render(static_cast<unsigned int>(1000.0f/*1 second*/));
- DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::POSITION ), (targetValue - startValue) * 0.7f, TEST_LOCATION );
- application.Render(static_cast<unsigned int>(1000.0f/*1 second*/));
- DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::POSITION ), (targetValue - startValue) * 0.8f, TEST_LOCATION );
- application.Render(static_cast<unsigned int>(1000.0f/*1 second*/));
- DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::POSITION ), (targetValue - startValue) * 0.9f, TEST_LOCATION );
- application.Render(static_cast<unsigned int>(1000.0f/*1 second*/));
- DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::POSITION ), (targetValue - startValue), TEST_LOCATION );
-
- // Check that the constrained value is stable
- application.Render(static_cast<unsigned int>(1000.0f/*1 second*/));
- DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::POSITION ), (targetValue - startValue), TEST_LOCATION );
- application.Render(static_cast<unsigned int>(1000.0f/*1 second*/));
- DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::POSITION ), (targetValue - startValue), TEST_LOCATION );
-
- // Remove the constraint
-
- actor.RemoveConstraints();
- actor.SetPosition( startValue );
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(1000.0f/*1 second*/));
- DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::POSITION ), startValue, TEST_LOCATION );
- application.Render(static_cast<unsigned int>(1000.0f/*1 second*/));
- DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::POSITION ), startValue, TEST_LOCATION );
- application.Render(static_cast<unsigned int>(1000.0f/*1 second*/));
- DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::POSITION ), startValue, TEST_LOCATION );
-
- // Change to non-linear alpha and retest
-
- constraint.SetAlphaFunction(AlphaFunctions::EaseIn);
- func = constraint.GetAlphaFunction();
- DALI_TEST_CHECK(func(0.1f) < 0.09f);
-
- actor.ApplyConstraint( constraint );
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(1000.0f/*1 second*/));
-
- DALI_TEST_CHECK( actor.GetProperty<Vector3>( Actor::POSITION ).x > startValue.x );
- DALI_TEST_CHECK( actor.GetProperty<Vector3>( Actor::POSITION ).y > startValue.y );
- DALI_TEST_CHECK( actor.GetProperty<Vector3>( Actor::POSITION ).z > startValue.z );
-
- Vector3 lessThanTenPercentProgress( (targetValue - startValue) * 0.09f );
- DALI_TEST_CHECK( actor.GetProperty<Vector3>( Actor::POSITION ).x < lessThanTenPercentProgress.x );
- DALI_TEST_CHECK( actor.GetProperty<Vector3>( Actor::POSITION ).y < lessThanTenPercentProgress.y );
- DALI_TEST_CHECK( actor.GetProperty<Vector3>( Actor::POSITION ).z < lessThanTenPercentProgress.z );
-
- application.Render(static_cast<unsigned int>(9000.0f/*9 seconds*/));
- DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::POSITION ), (targetValue - startValue), TEST_LOCATION );
-
- // Check that the constrained value is stable
- application.Render(static_cast<unsigned int>(1000.0f/*1 second*/));
- DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::POSITION ), (targetValue - startValue), TEST_LOCATION );
- application.Render(static_cast<unsigned int>(1000.0f/*1 second*/));
- DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::POSITION ), (targetValue - startValue), TEST_LOCATION );
- END_TEST;
-}
-
-int UtcDaliConstraintGetAlphaFunction(void)
-{
- TestApplication application;
-
- Constraint constraint = Constraint::New<Vector4>( Actor::COLOR, TestConstraint() );
-
- AlphaFunction func = constraint.GetAlphaFunction();
- DALI_TEST_EQUALS(func(0.5f), 0.5f, TEST_LOCATION); // Default is Linear
- END_TEST;
-}
-
-int UtcDaliConstraintSetRemoveAction(void)
-{
- TestApplication application;
-
- Vector3 sourcePosition(0.0f, 0.0f, 0.0f);
- Vector3 targetPosition(100.0f, 100.0f, 100.0f);
-
- // Build constraint, with "Discard" remove action
-
- Constraint constraint = Constraint::New<Vector3>( Actor::POSITION, TestPositionConstraint(targetPosition) );
- DALI_TEST_EQUALS((unsigned int)constraint.GetRemoveAction(), (unsigned int)Constraint::Bake, TEST_LOCATION);
-
- constraint.SetRemoveAction(Constraint::Discard);
- DALI_TEST_EQUALS((unsigned int)constraint.GetRemoveAction(), (unsigned int)Constraint::Discard, TEST_LOCATION);
-
- float removeSeconds(8.0f);
- constraint.SetRemoveTime(removeSeconds);
- DALI_TEST_EQUALS(constraint.GetRemoveTime(), TimePeriod(removeSeconds), TEST_LOCATION);
-
- // Apply to an actor
-
- Actor actor = Actor::New();
- Stage::GetCurrent().Add(actor);
-
- actor.ApplyConstraint( constraint );
- DALI_TEST_EQUALS( actor.GetCurrentPosition(), sourcePosition, TEST_LOCATION );
-
- application.SendNotification();
- application.Render(100u/*0.1 seconds*/);
-
- // Constraint should be fully applied
- DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
-
- // Check that nothing has changed after a couple of buffer swaps
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
-
- // Remove from the actor
-
- actor.RemoveConstraints(); // should go back to source position
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(removeSeconds*200.0f)/* 20% removal progress */);
-
- // Constraint shouldn't be fully removed yet
- Vector3 twentyPercentBack( targetPosition * 0.8f );
- DALI_TEST_EQUALS( actor.GetCurrentPosition(), twentyPercentBack, TEST_LOCATION );
-
- application.Render(static_cast<unsigned int>(removeSeconds*200.0f)/* 40% removal progress */);
-
- // Constraint shouldn't be fully removed yet
- Vector3 fourtyPercentBack( targetPosition * 0.6f );
- DALI_TEST_EQUALS( actor.GetCurrentPosition(), fourtyPercentBack, TEST_LOCATION );
-
- application.Render(static_cast<unsigned int>(removeSeconds*200.0f)/* 60% removal progress */);
-
- // Constraint shouldn't be fully removed yet
- Vector3 sixtyPercentBack( targetPosition * 0.4f );
- DALI_TEST_EQUALS( actor.GetCurrentPosition(), sixtyPercentBack, TEST_LOCATION );
-
- application.Render(static_cast<unsigned int>(removeSeconds*200.0f)/* 80% removal progress */);
-
- // Constraint shouldn't be fully removed yet
- Vector3 eightyPercentBack( targetPosition * 0.2f );
- DALI_TEST_EQUALS( actor.GetCurrentPosition(), eightyPercentBack, TEST_LOCATION );
-
- // Constraint should be fully removed
- application.Render(static_cast<unsigned int>(removeSeconds*200.0f)/* 100% removal progress */);
- DALI_TEST_EQUALS( actor.GetCurrentPosition(), sourcePosition, TEST_LOCATION );
-
- // Constraint should still be fully applied
- application.Render(static_cast<unsigned int>(removeSeconds*200.0f)/* Still 100% removal progress */);
- DALI_TEST_EQUALS( actor.GetCurrentPosition(), sourcePosition, TEST_LOCATION );
-
- // Check that nothing has changed after a couple of buffer swaps
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetCurrentPosition(), sourcePosition, TEST_LOCATION );
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetCurrentPosition(), sourcePosition, TEST_LOCATION );
- END_TEST;
-}
-
-int UtcDaliConstraintGetRemoveAction(void)
-{
- TestApplication application;
-
- Constraint constraint = Constraint::New<Vector4>( Actor::COLOR, TestConstraint() );
- DALI_TEST_EQUALS((unsigned int)constraint.GetRemoveAction(), (unsigned int)Constraint::Bake, TEST_LOCATION);
-
- constraint.SetRemoveAction(Constraint::Discard);
- DALI_TEST_EQUALS((unsigned int)constraint.GetRemoveAction(), (unsigned int)Constraint::Discard, TEST_LOCATION);
-
- constraint.SetRemoveAction(Constraint::Bake);
- DALI_TEST_EQUALS((unsigned int)constraint.GetRemoveAction(), (unsigned int)Constraint::Bake, TEST_LOCATION);
- END_TEST;
-}
-
-/**
- * Test a constraint with non-zero apply-time and remove-time, where the constraint is removed during the apply-time
- */
-int UtcDaliConstraintRemoveDuringApply(void)
-{
- TestApplication application;
-
- Vector3 sourcePosition(0.0f, 0.0f, 0.0f);
- Vector3 targetPosition(100.0f, 100.0f, 100.0f);
- Vector3 halfwayPosition(targetPosition * 0.5f);
-
- // Build constraint
-
- Constraint constraint = Constraint::New<Vector3>( Actor::POSITION, TestPositionConstraint(targetPosition) );
- DALI_TEST_EQUALS((unsigned int)constraint.GetRemoveAction(), (unsigned int)Constraint::Bake, TEST_LOCATION);
-
- float applySeconds(4.0f);
- constraint.SetApplyTime(applySeconds);
- DALI_TEST_EQUALS(constraint.GetApplyTime(), TimePeriod(applySeconds), TEST_LOCATION);
-
- float removeSeconds(8.0f);
- constraint.SetRemoveTime(removeSeconds);
- DALI_TEST_EQUALS(constraint.GetRemoveTime(), TimePeriod(removeSeconds), TEST_LOCATION);
-
- // Apply to an actor
-
- Actor actor = Actor::New();
- Stage::GetCurrent().Add(actor);
-
- actor.ApplyConstraint( constraint );
- DALI_TEST_EQUALS( actor.GetCurrentPosition(), sourcePosition, TEST_LOCATION );
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(applySeconds*250.0f)/* 25% progress */);
-
- // Constraint shouldn't be fully applied yet
- Vector3 twentyFivePercent( targetPosition * 0.25f );
- DALI_TEST_EQUALS( actor.GetCurrentPosition(), twentyFivePercent, TEST_LOCATION );
-
- application.Render(static_cast<unsigned int>(applySeconds*250.0f)/* 50% progress */);
-
- // Constraint shouldn't be fully applied yet
- Vector3 fiftyPercent( targetPosition * 0.5f );
- DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercent, TEST_LOCATION );
-
- // Remove from the actor
-
- actor.RemoveConstraints(); // should go back to source position
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(removeSeconds*100.0f)/* 50% - 5% = 45% progress */);
-
- // Constraint shouldn't be fully removed yet
- Vector3 fourtyFivePercent( targetPosition * 0.45f );
- DALI_TEST_EQUALS( actor.GetCurrentPosition(), fourtyFivePercent, TEST_LOCATION );
-
- application.Render(static_cast<unsigned int>(removeSeconds*400.0f)/* 50% - 25% = 25% progress */);
-
- // Constraint shouldn't be fully removed yet
- DALI_TEST_EQUALS( actor.GetCurrentPosition(), twentyFivePercent, TEST_LOCATION );
-
- // Constraint should be fully removed
- application.Render(static_cast<unsigned int>(removeSeconds*500.0f)/* 0% progress */);
- DALI_TEST_EQUALS( actor.GetCurrentPosition(), sourcePosition, TEST_LOCATION );
-
- // Constraint should still be fully applied
- application.Render(static_cast<unsigned int>(removeSeconds*200.0f)/* Still 0% progress */);
- DALI_TEST_EQUALS( actor.GetCurrentPosition(), sourcePosition, TEST_LOCATION );
-
- // Check that nothing has changed after a couple of buffer swaps
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetCurrentPosition(), sourcePosition, TEST_LOCATION );
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetCurrentPosition(), sourcePosition, TEST_LOCATION );
- END_TEST;
-}
-
-/**
- * Test a constraint with non-zero apply-time & zero (immediate) remove-time, where the constraint is removed during the apply-time
- */
-int UtcDaliConstraintImmediateRemoveDuringApply(void)
-{
- TestApplication application;
-
- Vector3 sourcePosition(0.0f, 0.0f, 0.0f);
- Vector3 targetPosition(100.0f, 100.0f, 100.0f);
-
- // Build constraint
-
- Constraint constraint = Constraint::New<Vector3>( Actor::POSITION, TestPositionConstraint(targetPosition) );
- DALI_TEST_EQUALS((unsigned int)constraint.GetRemoveAction(), (unsigned int)Constraint::Bake, TEST_LOCATION);
-
- float applySeconds(4.0f);
- constraint.SetApplyTime(applySeconds);
- DALI_TEST_EQUALS(constraint.GetApplyTime(), TimePeriod(applySeconds), TEST_LOCATION);
- DALI_TEST_EQUALS(constraint.GetRemoveTime(), TimePeriod(0.0f), TEST_LOCATION);
-
- // Apply to an actor
-
- Actor actor = Actor::New();
- Stage::GetCurrent().Add(actor);
-
- actor.ApplyConstraint( constraint );
- DALI_TEST_EQUALS( actor.GetCurrentPosition(), sourcePosition, TEST_LOCATION );
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(applySeconds*250.0f)/* 25% progress */);
-
- // Constraint shouldn't be fully applied yet
- Vector3 twentyFivePercent( targetPosition * 0.25f );
- DALI_TEST_EQUALS( actor.GetCurrentPosition(), twentyFivePercent, TEST_LOCATION );
-
- application.Render(static_cast<unsigned int>(applySeconds*250.0f)/* 50% progress */);
-
- // Constraint shouldn't be fully applied yet
- Vector3 fiftyPercent( targetPosition * 0.5f );
- DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercent, TEST_LOCATION );
-
- // Remove from the actor
-
- actor.RemoveConstraints(); // should go back to source position
- application.SendNotification();
-
- // Constraint should be fully removed
- application.Render(static_cast<unsigned int>(200.0f /*0.2 seconds*/));
- DALI_TEST_EQUALS( actor.GetCurrentPosition(), sourcePosition, TEST_LOCATION );
-
- // Constraint should still be fully applied
- application.Render(static_cast<unsigned int>(200.0f /*0.2 seconds*/));
- DALI_TEST_EQUALS( actor.GetCurrentPosition(), sourcePosition, TEST_LOCATION );
-
- // Check that nothing has changed after a couple of buffer swaps
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetCurrentPosition(), sourcePosition, TEST_LOCATION );
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetCurrentPosition(), sourcePosition, TEST_LOCATION );
- END_TEST;
-}
-
-int UtcDaliConstraintActorSize(void)
-{
- TestApplication application;
-
- // Build constraint, to make child 20% of parent size
-
- Constraint constraint = Constraint::New<Vector3>( Actor::SIZE,
- ParentSource( Actor::SIZE ),
- TestRelativeConstraintVector3(0.2f) );
- // Apply to a child actor
-
- Actor parent = Actor::New();
- Stage::GetCurrent().Add(parent);
-
- Actor child = Actor::New();
- parent.Add(child);
-
- child.ApplyConstraint( constraint );
- DALI_TEST_EQUALS( child.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
-
- // Animate the parent between two sizes
-
- Vector3 targetParentSize(100.0f, 100.0f, 100.0f);
-
- float durationSeconds(10.0f);
- Animation animation = Animation::New(durationSeconds);
- animation.AnimateTo( Property(parent, Actor::SIZE), targetParentSize );
- animation.Play();
-
- application.SendNotification();
-
- application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
- DALI_TEST_EQUALS( parent.GetCurrentSize(), targetParentSize*0.25f, TEST_LOCATION );
- DALI_TEST_EQUALS( child.GetCurrentSize(), targetParentSize*0.25f * 0.2f, TEST_LOCATION );
-
- application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
- DALI_TEST_EQUALS( parent.GetCurrentSize(), targetParentSize*0.5f, TEST_LOCATION );
- DALI_TEST_EQUALS( child.GetCurrentSize(), targetParentSize*0.5f * 0.2f, TEST_LOCATION );
-
- application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
- DALI_TEST_EQUALS( parent.GetCurrentSize(), targetParentSize*0.75f, TEST_LOCATION );
- DALI_TEST_EQUALS( child.GetCurrentSize(), targetParentSize*0.75f * 0.2f, TEST_LOCATION );
-
- application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 100% progress */);
- DALI_TEST_EQUALS( parent.GetCurrentSize(), targetParentSize, TEST_LOCATION );
- DALI_TEST_EQUALS( child.GetCurrentSize(), targetParentSize * 0.2f, TEST_LOCATION );
-
- // Check that nothing has changed after a couple of buffer swaps
- application.Render(0);
- DALI_TEST_EQUALS( parent.GetCurrentSize(), targetParentSize, TEST_LOCATION );
- DALI_TEST_EQUALS( child.GetCurrentSize(), targetParentSize * 0.2f, TEST_LOCATION );
- application.Render(0);
- DALI_TEST_EQUALS( parent.GetCurrentSize(), targetParentSize, TEST_LOCATION );
- DALI_TEST_EQUALS( child.GetCurrentSize(), targetParentSize * 0.2f, TEST_LOCATION );
- END_TEST;
-}
-
-int UtcDaliConstraintActorSizeWidth(void)
-{
- TestApplication application;
-
- // Build constraint, to make child 20% of parent width
-
- Constraint constraint = Constraint::New<float>( Actor::SIZE_WIDTH,
- ParentSource( Actor::SIZE_WIDTH ),
- TestRelativeConstraintFloat(0.2f) );
- // Apply to a child actor
-
- Actor parent = Actor::New();
- Stage::GetCurrent().Add(parent);
-
- Actor child = Actor::New();
- parent.Add(child);
-
- child.ApplyConstraint( constraint );
- DALI_TEST_EQUALS( child.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
-
- // Animate the parent between two sizes
-
- Vector3 targetParentSize(80.0f, 90.0f, 100.0f);
-
- float durationSeconds(10.0f);
- Animation animation = Animation::New(durationSeconds);
- animation.AnimateTo( Property(parent, Actor::SIZE), targetParentSize );
- animation.Play();
-
- application.SendNotification();
-
- application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
- DALI_TEST_EQUALS( parent.GetCurrentSize(), targetParentSize*0.25f, TEST_LOCATION );
- DALI_TEST_EQUALS( child.GetCurrentSize().width, targetParentSize.width*0.25f * 0.2f, TEST_LOCATION );
- DALI_TEST_EQUALS( child.GetCurrentSize().height, 0.0f, TEST_LOCATION );
- DALI_TEST_EQUALS( child.GetCurrentSize().depth, 0.0f, TEST_LOCATION );
-
- application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
- DALI_TEST_EQUALS( parent.GetCurrentSize(), targetParentSize*0.5f, TEST_LOCATION );
- DALI_TEST_EQUALS( child.GetCurrentSize().width, targetParentSize.width*0.5f * 0.2f, TEST_LOCATION );
- DALI_TEST_EQUALS( child.GetCurrentSize().height, 0.0f, TEST_LOCATION );
- DALI_TEST_EQUALS( child.GetCurrentSize().depth, 0.0f, TEST_LOCATION );
-
- application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
- DALI_TEST_EQUALS( parent.GetCurrentSize(), targetParentSize*0.75f, TEST_LOCATION );
- DALI_TEST_EQUALS( child.GetCurrentSize().width, targetParentSize.width*0.75f * 0.2f, TEST_LOCATION );
- DALI_TEST_EQUALS( child.GetCurrentSize().height, 0.0f, TEST_LOCATION );
- DALI_TEST_EQUALS( child.GetCurrentSize().depth, 0.0f, TEST_LOCATION );
-
- application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 100% progress */);
- DALI_TEST_EQUALS( parent.GetCurrentSize(), targetParentSize, TEST_LOCATION );
- DALI_TEST_EQUALS( child.GetCurrentSize().width, targetParentSize.width * 0.2f, TEST_LOCATION );
- DALI_TEST_EQUALS( child.GetCurrentSize().height, 0.0f, TEST_LOCATION );
- DALI_TEST_EQUALS( child.GetCurrentSize().depth, 0.0f, TEST_LOCATION );
-
- // Check that nothing has changed after a couple of buffer swaps
- application.Render(0);
- DALI_TEST_EQUALS( parent.GetCurrentSize(), targetParentSize, TEST_LOCATION );
- DALI_TEST_EQUALS( child.GetCurrentSize().width, targetParentSize.width * 0.2f, TEST_LOCATION );
- DALI_TEST_EQUALS( child.GetCurrentSize().height, 0.0f, TEST_LOCATION );
- DALI_TEST_EQUALS( child.GetCurrentSize().depth, 0.0f, TEST_LOCATION );
-
- application.Render(0);
- DALI_TEST_EQUALS( parent.GetCurrentSize(), targetParentSize, TEST_LOCATION );
- DALI_TEST_EQUALS( child.GetCurrentSize().width, targetParentSize.width * 0.2f, TEST_LOCATION );
- DALI_TEST_EQUALS( child.GetCurrentSize().height, 0.0f, TEST_LOCATION );
- DALI_TEST_EQUALS( child.GetCurrentSize().depth, 0.0f, TEST_LOCATION );
- END_TEST;
-}
-
-int UtcDaliConstraintActorSizeHeight(void)
-{
- TestApplication application;
-
- // Build constraint, to make child 20% of parent height
-
- Constraint constraint = Constraint::New<float>( Actor::SIZE_HEIGHT,
- ParentSource( Actor::SIZE_HEIGHT ),
- TestRelativeConstraintFloat(0.2f) );
- // Apply to a child actor
-
- Actor parent = Actor::New();
- Stage::GetCurrent().Add(parent);
-
- Actor child = Actor::New();
- parent.Add(child);
-
- child.ApplyConstraint( constraint );
- DALI_TEST_EQUALS( child.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
-
- // Animate the parent between two sizes
-
- Vector3 targetParentSize(80.0f, 90.0f, 100.0f);
-
- float durationSeconds(10.0f);
- Animation animation = Animation::New(durationSeconds);
- animation.AnimateTo( Property(parent, Actor::SIZE), targetParentSize );
- animation.Play();
-
- application.SendNotification();
-
- application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
- DALI_TEST_EQUALS( parent.GetCurrentSize(), targetParentSize*0.25f, TEST_LOCATION );
- DALI_TEST_EQUALS( child.GetCurrentSize().width, 0.0f, TEST_LOCATION );
- DALI_TEST_EQUALS( child.GetCurrentSize().height, targetParentSize.height*0.25f * 0.2f, TEST_LOCATION );
- DALI_TEST_EQUALS( child.GetCurrentSize().depth, 0.0f, TEST_LOCATION );
-
- application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
- DALI_TEST_EQUALS( parent.GetCurrentSize(), targetParentSize*0.5f, TEST_LOCATION );
- DALI_TEST_EQUALS( child.GetCurrentSize().width, 0.0f, TEST_LOCATION );
- DALI_TEST_EQUALS( child.GetCurrentSize().height, targetParentSize.height*0.5f * 0.2f, TEST_LOCATION );
- DALI_TEST_EQUALS( child.GetCurrentSize().depth, 0.0f, TEST_LOCATION );
-
- application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
- DALI_TEST_EQUALS( parent.GetCurrentSize(), targetParentSize*0.75f, TEST_LOCATION );
- DALI_TEST_EQUALS( child.GetCurrentSize().width, 0.0f, TEST_LOCATION );
- DALI_TEST_EQUALS( child.GetCurrentSize().height, targetParentSize.height*0.75f * 0.2f, TEST_LOCATION );
- DALI_TEST_EQUALS( child.GetCurrentSize().depth, 0.0f, TEST_LOCATION );
-
- application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 100% progress */);
- DALI_TEST_EQUALS( parent.GetCurrentSize(), targetParentSize, TEST_LOCATION );
- DALI_TEST_EQUALS( child.GetCurrentSize().width, 0.0f, TEST_LOCATION );
- DALI_TEST_EQUALS( child.GetCurrentSize().height, targetParentSize.height * 0.2f, TEST_LOCATION );
- DALI_TEST_EQUALS( child.GetCurrentSize().depth, 0.0f, TEST_LOCATION );
-
- // Check that nothing has changed after a couple of buffer swaps
- application.Render(0);
- DALI_TEST_EQUALS( parent.GetCurrentSize(), targetParentSize, TEST_LOCATION );
- DALI_TEST_EQUALS( child.GetCurrentSize().width, 0.0f, TEST_LOCATION );
- DALI_TEST_EQUALS( child.GetCurrentSize().height, targetParentSize.height * 0.2f, TEST_LOCATION );
- DALI_TEST_EQUALS( child.GetCurrentSize().depth, 0.0f, TEST_LOCATION );
-
- application.Render(0);
- DALI_TEST_EQUALS( parent.GetCurrentSize(), targetParentSize, TEST_LOCATION );
- DALI_TEST_EQUALS( child.GetCurrentSize().width, 0.0f, TEST_LOCATION );
- DALI_TEST_EQUALS( child.GetCurrentSize().height, targetParentSize.height * 0.2f, TEST_LOCATION );
- DALI_TEST_EQUALS( child.GetCurrentSize().depth, 0.0f, TEST_LOCATION );
- END_TEST;
-}
-
-int UtcDaliConstraintActorSizeDepth(void)
-{
- TestApplication application;
-
- // Build constraint, to make child 20% of parent height
-
- Constraint constraint = Constraint::New<float>( Actor::SIZE_DEPTH,
- ParentSource( Actor::SIZE_DEPTH ),
- TestRelativeConstraintFloat(0.2f) );
- // Apply to a child actor
-
- Actor parent = Actor::New();
- Stage::GetCurrent().Add(parent);
-
- Actor child = Actor::New();
- parent.Add(child);
-
- child.ApplyConstraint( constraint );
- DALI_TEST_EQUALS( child.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
-
- // Animate the parent between two sizes
-
- Vector3 targetParentSize(80.0f, 90.0f, 100.0f);
-
- float durationSeconds(10.0f);
- Animation animation = Animation::New(durationSeconds);
- animation.AnimateTo( Property(parent, Actor::SIZE), targetParentSize );
- animation.Play();
-
- application.SendNotification();
-
- application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
- DALI_TEST_EQUALS( parent.GetCurrentSize(), targetParentSize*0.25f, TEST_LOCATION );
- DALI_TEST_EQUALS( child.GetCurrentSize().width, 0.0f, TEST_LOCATION );
- DALI_TEST_EQUALS( child.GetCurrentSize().height, 0.0f, TEST_LOCATION );
- DALI_TEST_EQUALS( child.GetCurrentSize().depth, targetParentSize.depth*0.25f * 0.2f, TEST_LOCATION );
-
- application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
- DALI_TEST_EQUALS( parent.GetCurrentSize(), targetParentSize*0.5f, TEST_LOCATION );
- DALI_TEST_EQUALS( child.GetCurrentSize().width, 0.0f, TEST_LOCATION );
- DALI_TEST_EQUALS( child.GetCurrentSize().height, 0.0f, TEST_LOCATION );
- DALI_TEST_EQUALS( child.GetCurrentSize().depth, targetParentSize.depth*0.5f * 0.2f, TEST_LOCATION );
-
- application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
- DALI_TEST_EQUALS( parent.GetCurrentSize(), targetParentSize*0.75f, TEST_LOCATION );
- DALI_TEST_EQUALS( child.GetCurrentSize().width, 0.0f, TEST_LOCATION );
- DALI_TEST_EQUALS( child.GetCurrentSize().height, 0.0f, TEST_LOCATION );
- DALI_TEST_EQUALS( child.GetCurrentSize().depth, targetParentSize.depth*0.75f * 0.2f, TEST_LOCATION );
-
- application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 100% progress */);
- DALI_TEST_EQUALS( parent.GetCurrentSize(), targetParentSize, TEST_LOCATION );
- DALI_TEST_EQUALS( child.GetCurrentSize().width, 0.0f, TEST_LOCATION );
- DALI_TEST_EQUALS( child.GetCurrentSize().height, 0.0f, TEST_LOCATION );
- DALI_TEST_EQUALS( child.GetCurrentSize().depth, targetParentSize.depth * 0.2f, TEST_LOCATION );
-
- // Check that nothing has changed after a couple of buffer swaps
- application.Render(0);
- DALI_TEST_EQUALS( parent.GetCurrentSize(), targetParentSize, TEST_LOCATION );
- DALI_TEST_EQUALS( child.GetCurrentSize().width, 0.0f, TEST_LOCATION );
- DALI_TEST_EQUALS( child.GetCurrentSize().height, 0.0f, TEST_LOCATION );
- DALI_TEST_EQUALS( child.GetCurrentSize().depth, targetParentSize.depth * 0.2f, TEST_LOCATION );
-
- application.Render(0);
- DALI_TEST_EQUALS( parent.GetCurrentSize(), targetParentSize, TEST_LOCATION );
- DALI_TEST_EQUALS( child.GetCurrentSize().width, 0.0f, TEST_LOCATION );
- DALI_TEST_EQUALS( child.GetCurrentSize().height, 0.0f, TEST_LOCATION );
- DALI_TEST_EQUALS( child.GetCurrentSize().depth, targetParentSize.depth * 0.2f, TEST_LOCATION );
- END_TEST;
-}
-
-int UtcDaliConstraintInputWorldPosition(void)
-{
- TestApplication application;
-
- Actor parent = Actor::New();
- Vector3 parentPosition( 10.0f, 10.0f, 10.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, 10.0f, 10.0f );
- child.SetPosition( childPosition );
- parent.Add( child );
-
- Actor trackingActor = Actor::New();
- trackingActor.SetParentOrigin( ParentOrigin::CENTER );
- trackingActor.SetAnchorPoint( AnchorPoint::CENTER );
- Stage::GetCurrent().Add( trackingActor );
-
- // 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 );
- DALI_TEST_EQUALS( trackingActor.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
-
- application.SendNotification();
- application.Render(0);
-
- DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
- DALI_TEST_EQUALS( child.GetCurrentPosition(), childPosition, TEST_LOCATION );
- DALI_TEST_EQUALS( trackingActor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
-
- DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
- Vector3 previousPosition( parentPosition + childPosition );
- DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), previousPosition, TEST_LOCATION );
- DALI_TEST_EQUALS( trackingActor.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
-
- // Build constraint, to make actor track the world-position of another actor
- // Note that the world-position is always from the previous frame, so the tracking actor will lag behind
-
- Constraint constraint = Constraint::New<Vector3>( Actor::POSITION,
- Source( child, Actor::WORLD_POSITION ),
- EqualToConstraint() );
-
- trackingActor.ApplyConstraint( constraint );
-
- application.SendNotification();
- application.Render(0);
-
- DALI_TEST_EQUALS( trackingActor.GetCurrentPosition(), previousPosition, TEST_LOCATION );
-
- // Move the actors and try again
- Vector3 relativePosition( 5, 5, 5 );
- parent.MoveBy( relativePosition );
-
- application.SendNotification();
- application.Render(0);
-
- DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition + relativePosition, TEST_LOCATION );
- DALI_TEST_EQUALS( child.GetCurrentPosition(), childPosition, TEST_LOCATION );
-
- // The tracking actor lags behind
- DALI_TEST_EQUALS( trackingActor.GetCurrentPosition(), previousPosition, TEST_LOCATION );
-
- DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition + relativePosition, TEST_LOCATION );
- previousPosition = Vector3( parentPosition + childPosition + relativePosition );
- DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), previousPosition, TEST_LOCATION );
-
- // Allow the tracking actor to catch up
- application.SendNotification();
- application.Render(0);
-
- DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition + relativePosition, TEST_LOCATION );
- DALI_TEST_EQUALS( child.GetCurrentPosition(), childPosition, TEST_LOCATION );
-
- // The tracking actor catches up!
- DALI_TEST_EQUALS( trackingActor.GetCurrentPosition(), previousPosition, TEST_LOCATION );
- DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition + relativePosition, TEST_LOCATION );
- DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), previousPosition, TEST_LOCATION );