-int UtcDaliBuiltinConstraintShrinkInsideKeepAspectRatioConstraint(void)
-{
- TestApplication application;
-
- Actor parent = Actor::New();
- Vector3 parentSize1( 10, 10, 10 );
- parent.SetSize( parentSize1 );
- Stage::GetCurrent().Add( parent );
-
- Actor actor = Actor::New();
- Vector3 childSize( 4, 5, 5 );
- actor.SetSize( childSize );
- parent.Add( actor );
-
- application.SendNotification();
- application.Render(0);
- Vector3 childScale1( 1.0f, 1.0f, 1.0f );
- DALI_TEST_EQUALS( actor.GetCurrentScale(), childScale1, TEST_LOCATION );
-
- // Apply constraint
-
- Constraint constraint = Constraint::New<Vector3>( Actor::SCALE,
- LocalSource( Actor::SIZE ),
- ParentSource( Actor::SIZE ),
- ShrinkInsideKeepAspectRatioConstraint() );
- actor.ApplyConstraint( constraint );
-
- application.SendNotification();
- application.Render(0);
-
- // Constraint should be fully applied, but parent size is larger than child
- Vector3 childScale2( 1.0f, 1.0f, 1.0f );
- DALI_TEST_EQUALS( actor.GetCurrentScale(), childScale2, TEST_LOCATION );
-
- // change parent size
- Vector3 parentSize2( 40, 50, 50 );
- parent.SetSize( parentSize2 );
-
- application.SendNotification();
- application.Render(0);
-
- // Constraint should be fully applied, but parent size is larger than child
- Vector3 childScale3( 1.0f, 1.0f, 1.0f );
- DALI_TEST_EQUALS( actor.GetCurrentScale(), childScale3, TEST_LOCATION );
- END_TEST;
-}
-
-int UtcDaliBuiltinConstraintMultiplyConstraint(void)
-{
- TestApplication application;
-
- Actor actor1 = Actor::New();
- Vector3 startPosition( 10, 10, 10 );
- actor1.SetPosition( startPosition );
- Stage::GetCurrent().Add( actor1 );
-
- Actor actor2 = Actor::New();
- Vector3 startSize( 100, 100, 100 );
- actor2.SetSize( startSize );
- Stage::GetCurrent().Add( actor2 );
-
- application.SendNotification();
- application.Render(0);
- DALI_TEST_CHECK( actor1.GetCurrentPosition() == startPosition );
- DALI_TEST_CHECK( actor2.GetCurrentSize() == startSize );
-
- // Apply constraint - multiply actor1 size by actor2 position
-
- Constraint constraint = Constraint::New<Vector3>( Actor::SIZE,
- Source( actor1, Actor::POSITION ),
- MultiplyConstraint() );
- constraint.SetRemoveAction( Constraint::Discard );
- actor2.ApplyConstraint( constraint );
-
- application.SendNotification();
- application.Render(0);
-
- // Constraint should be fully applied
- Vector3 size( startSize * startPosition );
- DALI_TEST_EQUALS( actor2.GetCurrentSize(), size, TEST_LOCATION );
-
- // Change the multiply input
- Vector3 endPosition( 2, 2, 2 );
- actor1.SetPosition( endPosition );
-
- application.SendNotification();
- application.Render(0);
-
- // Constraint should be fully applied
- size = Vector3( startSize * endPosition );
- DALI_TEST_EQUALS( actor2.GetCurrentSize(), size, TEST_LOCATION );
- application.Render(0);
- DALI_TEST_EQUALS( actor2.GetCurrentSize(), size, TEST_LOCATION );
- END_TEST;
-}
-
-int UtcDaliBuiltinConstraintDivideConstraint(void)
-{
- TestApplication application;
-
- Actor actor1 = Actor::New();
- Vector3 startPosition( 10, 10, 10 );
- actor1.SetPosition( startPosition );
- Stage::GetCurrent().Add( actor1 );
-
- Actor actor2 = Actor::New();
- Vector3 startSize( 100, 100, 100 );
- actor2.SetSize( startSize );
- Stage::GetCurrent().Add( actor2 );
-
- application.SendNotification();
- application.Render(0);
- DALI_TEST_CHECK( actor1.GetCurrentPosition() == startPosition );
- DALI_TEST_CHECK( actor2.GetCurrentSize() == startSize );
-
- // Apply constraint - divide actor1 size by actor2 position
-
- Constraint constraint = Constraint::New<Vector3>( Actor::SIZE,
- Source( actor1, Actor::POSITION ),
- DivideConstraint() );
- constraint.SetRemoveAction( Constraint::Discard );
- actor2.ApplyConstraint( constraint );
-
- application.SendNotification();
- application.Render(0);
-
- // Constraint should be fully applied
- Vector3 size( 10, 10, 10 ); // startSize / startPosition
- DALI_TEST_EQUALS( actor2.GetCurrentSize(), size, TEST_LOCATION );
-
- // Change the divide input
- Vector3 endPosition( 2, 2, 2 );
- actor1.SetPosition( endPosition );
-
- application.SendNotification();
- application.Render(0);
-
- // Constraint should be fully applied
- size = Vector3( 50, 50, 50 ); // startSize / endPosition
- DALI_TEST_EQUALS( actor2.GetCurrentSize(), size, TEST_LOCATION );
- application.Render(0);
- DALI_TEST_EQUALS( actor2.GetCurrentSize(), size, TEST_LOCATION );
- END_TEST;
-}
-