bool& mSignalReceived; // owned by individual tests
};
-static bool ReturnFalseAfterProgressOne( float alpha, const bool& current )
-{
- return alpha < 1.0f;
-}
-
-struct AnimateFloatTestFunctor
-{
- AnimateFloatTestFunctor( float start, float end )
- : mStart( start ),
- mEnd( end )
- {
- }
-
- float operator()( float alpha, const float& current )
- {
- return mStart + ((mEnd - mStart) * alpha );
- }
-
- float mStart;
- float mEnd;
-};
-
-struct AnimateIntegerTestFunctor
-{
- AnimateIntegerTestFunctor( int start, int end )
- : mStart( start ),
- mEnd( end )
- {
- }
-
- int operator()( float alpha, const int& current )
- {
- return static_cast<int>( mStart + ((mEnd - mStart) * alpha ) + 0.5f );
- }
-
- int mStart;
- int mEnd;
-};
-
-struct AnimateVector2TestFunctor
-{
- AnimateVector2TestFunctor( Vector2 start, Vector2 end )
- : mStart( start ),
- mEnd( end )
- {
- }
-
- Vector2 operator()( float alpha, const Vector2& current )
- {
- return mStart + ((mEnd - mStart) * alpha );
- }
-
- Vector2 mStart;
- Vector2 mEnd;
-};
-
-struct AnimateVector4TestFunctor
-{
- AnimateVector4TestFunctor( Vector4 start, Vector4 end )
- : mStart( start ),
- mEnd( end )
- {
- }
-
- Vector4 operator()( float alpha, const Vector4& current )
- {
- return mStart + ((mEnd - mStart) * alpha );
- }
-
- Vector4 mStart;
- Vector4 mEnd;
-};
-
-struct AnimateQuaternionTestFunctor
-{
- AnimateQuaternionTestFunctor( Quaternion start, Quaternion end )
- : mStart( start ),
- mEnd( end )
- {
- }
-
- Quaternion operator()( float alpha, const Quaternion& current )
- {
- return Quaternion::Slerp(mStart, mEnd, alpha);
- }
-
- Quaternion mStart;
- Quaternion mEnd;
-};
-
-struct BounceFunc
-{
- BounceFunc(float x, float y, float z)
- : mDistance(Vector3(x, y, z))
- {
- }
- Vector3 operator()(float alpha, const Vector3& current)
- {
- if (alpha>0.001f && alpha<1.0f)
- {
- const float flip = 0.5f - cosf(alpha * Math::PI * 2.0f) * 0.5f;
- Vector3 newTranslation(current);
- newTranslation += mDistance * flip;
- return newTranslation;
- }
- return current;
- }
- Vector3 mDistance;
-};
-
-
-struct TumbleFunc
-{
- TumbleFunc(Vector3 axis) : tumbleAxis(axis){}
- Quaternion operator()(float alpha, const Quaternion& current)
- {
- if (alpha>0.001f && alpha<1.0f)
- {
- Quaternion tumbleRotation(alpha * Math::PI * 2.0f, tumbleAxis);
- return tumbleRotation * current;
- }
- return current;
- }
- Vector3 tumbleAxis;
-};
-
} // anon namespace
int UtcDaliAnimationNew01(void)
}
catch (Dali::DaliException& e)
{
- // TODO: Determine why catch doesn't.
- //
-
// Tests that a negative test of an assertion succeeds
- tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
- DALI_TEST_EQUALS(e.mCondition, "durationSeconds > 0.0f", TEST_LOCATION);
+ DALI_TEST_PRINT_ASSERT( e );
+ DALI_TEST_EQUALS(e.condition, "durationSeconds > 0.0f", TEST_LOCATION);
}
END_TEST;
}
END_TEST;
}
-int UtcDaliAnimationGetDestroyAction(void)
+int UtcDaliAnimationSetDisconnectAction(void)
+{
+ TestApplication application;
+ Stage stage( Stage::GetCurrent() );
+
+ // Default: BakeFinal
+ {
+ Actor actor = Actor::New();
+ stage.Add(actor);
+
+ // Build the animation
+ float durationSeconds(1.0f);
+ Animation animation = Animation::New(durationSeconds);
+ DALI_TEST_CHECK(animation.GetDisconnectAction() == Animation::BakeFinal);
+
+ Vector3 targetPosition(10.0f, 10.0f, 10.0f);
+ animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear);
+
+ // Start the animation
+ animation.Play();
+
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(durationSeconds*0.5f*1000.0f)/*Only half the animation*/);
+
+ actor.Unparent();
+
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
+ }
+
+ // Bake
+ {
+ Actor actor = Actor::New();
+ stage.Add(actor);
+
+ // Build the animation
+ float durationSeconds(1.0f);
+ Animation animation = Animation::New(durationSeconds);
+ animation.SetDisconnectAction( Animation::Bake );
+
+ Vector3 targetPosition(10.0f, 10.0f, 10.0f);
+ animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear);
+
+ // Start the animation
+ animation.Play();
+
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(durationSeconds*0.5f*1000.0f)/*Only half the animation*/);
+
+ actor.Unparent();
+
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition*0.5f, TEST_LOCATION );
+ }
+
+ // Discard
+ {
+ Actor actor = Actor::New();
+ stage.Add(actor);
+
+ // Build the animation
+ float durationSeconds(1.0f);
+ Animation animation = Animation::New(durationSeconds);
+ animation.SetDisconnectAction( Animation::Discard );
+
+ Vector3 targetPosition(10.0f, 10.0f, 10.0f);
+ animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear);
+
+ // Start the animation
+ animation.Play();
+
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(durationSeconds*0.5f*1000.0f)/*Only half the animation*/);
+
+ actor.Unparent();
+
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
+ }
+
+ // Don't play the animation: disconnect action should not be applied
+ {
+ Actor actor = Actor::New();
+ stage.Add(actor);
+
+ // Build the animation
+ float durationSeconds(1.0f);
+ Animation animation = Animation::New(durationSeconds);
+
+ Vector3 targetPosition(10.0f, 10.0f, 10.0f);
+ animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear);
+
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(durationSeconds*0.5f*1000.0f)/*Only half the animation*/);
+
+ actor.Unparent();
+
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
+ }
+
+ END_TEST;
+}
+
+int UtcDaliAnimationGetDisconnectAction(void)
{
TestApplication application;
Animation animation = Animation::New(1.0f);
- DALI_TEST_CHECK(animation.GetDestroyAction() == Animation::Bake); // default!
+ DALI_TEST_CHECK(animation.GetDisconnectAction() == Animation::BakeFinal); // default!
- animation.SetDestroyAction(Animation::Discard);
- DALI_TEST_CHECK(animation.GetDestroyAction() == Animation::Discard);
+ animation.SetDisconnectAction(Animation::Discard);
+ DALI_TEST_CHECK(animation.GetDisconnectAction() == Animation::Discard);
- animation.SetDestroyAction(Animation::BakeFinal);
- DALI_TEST_CHECK(animation.GetDestroyAction() == Animation::BakeFinal);
+ animation.SetDisconnectAction(Animation::Bake);
+ DALI_TEST_CHECK(animation.GetDisconnectAction() == Animation::Bake);
END_TEST;
}
END_TEST;
}
-int UtcDaliAnimationPlayOffStage(void)
+int UtcDaliAnimationSetSpeedFactor(void)
{
- // Test that an animation can be played, when the actor is off-stage.
- // When the actor is added to the stage, it should appear at the current position
- // i.e. where it would have been anyway, if on-stage from the beginning.
-
TestApplication application;
Actor actor = Actor::New();
- Vector3 basePosition(Vector3::ZERO);
- DALI_TEST_EQUALS( actor.GetCurrentPosition(), basePosition, TEST_LOCATION );
- // Not added to the stage!
+ Stage::GetCurrent().Add(actor);
// Build the animation
float durationSeconds(1.0f);
Animation animation = Animation::New(durationSeconds);
- Vector3 targetPosition(100.0f, 100.0f, 100.0f);
- animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear);
+
+ const Vector3 initialPosition(0.0f, 0.0f, 0.0f);
+ const Vector3 targetPosition(100.0f, 100.0f, 100.0f);
+
+ KeyFrames keyframes = KeyFrames::New();
+ keyframes.Add( 0.0f, initialPosition);
+ keyframes.Add( 1.0f, targetPosition );
+ animation.AnimateBetween( Property(actor, Actor::POSITION), keyframes, AlphaFunctions::Linear);
+
+ //Set speed to be x2
+ animation.SetSpeedFactor(2.0f);
// Start the animation
animation.Play();
animation.FinishedSignal().Connect(&application, finishCheck);
application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 20% progress */);
+ application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 40% progress */);
// We didn't expect the animation to finish yet
application.SendNotification();
finishCheck.CheckSignalNotReceived();
- DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO/*off-stage*/, TEST_LOCATION );
-
- // Add to the stage
- Stage::GetCurrent().Add(actor);
+ DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.4f), TEST_LOCATION );
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 40% progress */);
+ application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 80% progress */);
// We didn't expect the animation to finish yet
application.SendNotification();
finishCheck.CheckSignalNotReceived();
- Vector3 expectedPosition(basePosition + (targetPosition - basePosition)*0.4f);
- DALI_TEST_EQUALS( actor.GetCurrentPosition(), expectedPosition/*on-stage*/, TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.8f), TEST_LOCATION );
- // Remove from the stage
- Stage::GetCurrent().Remove(actor);
+ application.Render(static_cast<unsigned int>(durationSeconds*100.0f) + 1u/*just beyond half the duration*/);
+ // We did expect the animation to finish
application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 60% progress */);
+ finishCheck.CheckSignalReceived();
+ 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( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
+ application.Render(0);
+ DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
+
+ finishCheck.Reset();
+
+ //Test -1 speed factor. Animation will play in reverse at normal speed
+ animation.SetSpeedFactor( -1.0f );
+
+ // Start the animation
+ animation.Play();
+
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 80% progress */);
// We didn't expect the animation to finish yet
application.SendNotification();
finishCheck.CheckSignalNotReceived();
- DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO/*back to start position*/, TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.8f), TEST_LOCATION );
- // Add to the stage
- Stage::GetCurrent().Add(actor);
+ application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 60% progress */);
+ // We didn't expect the animation to finish yet
application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 80% progress */);
+ finishCheck.CheckSignalNotReceived();
+ DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.6f), TEST_LOCATION );
+
+ application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 40% progress */);
// We didn't expect the animation to finish yet
application.SendNotification();
finishCheck.CheckSignalNotReceived();
- expectedPosition = Vector3(basePosition + (targetPosition - basePosition)*0.8f);
- DALI_TEST_EQUALS( actor.GetCurrentPosition(), expectedPosition, TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.4f), TEST_LOCATION );
+
+ application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 20% progress */);
+ // We didn't expect the animation to finish yet
application.SendNotification();
+ finishCheck.CheckSignalNotReceived();
+ DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION );
+
application.Render(static_cast<unsigned int>(durationSeconds*200.0f) + 1u/*just beyond the animation duration*/);
// We did expect the animation to finish
application.SendNotification();
finishCheck.CheckSignalReceived();
- DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetCurrentPosition(), initialPosition, TEST_LOCATION );
// Check that nothing has changed after a couple of buffer swaps
application.Render(0);
- DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
+ DALI_TEST_EQUALS( initialPosition, actor.GetCurrentPosition(), TEST_LOCATION );
application.Render(0);
- DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
- END_TEST;
-}
-
-int UtcDaliAnimationPlayDiscardHandle(void)
-{
- TestApplication application;
+ DALI_TEST_EQUALS( initialPosition, actor.GetCurrentPosition(), TEST_LOCATION );
- Actor actor = Actor::New();
- Stage::GetCurrent().Add(actor);
- // Build the animation
- float durationSeconds(1.0f);
- Animation animation = Animation::New(durationSeconds);
- Vector3 targetPosition(100.0f, 100.0f, 100.0f);
- animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear);
+ //Test change speed factor on the fly
+ finishCheck.Reset();
- bool signalReceived(false);
- AnimationFinishCheck finishCheck(signalReceived);
- animation.FinishedSignal().Connect(&application, finishCheck);
+ //Set speed to be half of normal speed
+ animation.SetSpeedFactor( 0.5f );
// Start the animation
animation.Play();
- // This is a test of the "Fire and Forget" behaviour
- // Discard the animation handle!
- animation.Reset();
- DALI_TEST_CHECK( !animation );
-
application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 20% progress */);
+ application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 10% progress */);
// We didn't expect the animation to finish yet
application.SendNotification();
finishCheck.CheckSignalNotReceived();
- DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.1f), TEST_LOCATION );
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 40% progress */);
+ application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 20% progress */);
// We didn't expect the animation to finish yet
application.SendNotification();
finishCheck.CheckSignalNotReceived();
- DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.4f), TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION );
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 60% progress */);
+ application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 30% progress */);
// We didn't expect the animation to finish yet
application.SendNotification();
finishCheck.CheckSignalNotReceived();
- DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.6f), TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.3f), TEST_LOCATION );
+ //Change speed factor while animation still playing.
+ animation.SetSpeedFactor(-1.0f);
application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 80% progress */);
+ application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 10% progress */);
// We didn't expect the animation to finish yet
application.SendNotification();
finishCheck.CheckSignalNotReceived();
- DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.8f), TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.1f), TEST_LOCATION );
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*200.0f) + 1u/*just beyond the animation duration*/);
+ application.Render(static_cast<unsigned int>(durationSeconds*100.0f) + 1u/*just beyond the animation duration*/);
// We did expect the animation to finish
application.SendNotification();
finishCheck.CheckSignalReceived();
- DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetCurrentPosition(), initialPosition, TEST_LOCATION );
// Check that nothing has changed after a couple of buffer swaps
application.Render(0);
- DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
+ DALI_TEST_EQUALS( initialPosition, actor.GetCurrentPosition(), TEST_LOCATION );
application.Render(0);
- DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
+ DALI_TEST_EQUALS( initialPosition, actor.GetCurrentPosition(), TEST_LOCATION );
END_TEST;
}
-int UtcDaliAnimationPlayStopDiscardHandle(void)
+int UtcDaliAnimationGetSpeedFactor(void)
+{
+ TestApplication application;
+
+ Animation animation = Animation::New(1.0f);
+ animation.SetSpeedFactor(0.5f);
+ DALI_TEST_EQUALS(animation.GetSpeedFactor(), 0.5f, TEST_LOCATION);
+
+ animation.SetSpeedFactor(-2.5f);
+ DALI_TEST_EQUALS(animation.GetSpeedFactor(), -2.5f, TEST_LOCATION);
+ END_TEST;
+}
+
+int UtcDaliAnimationPlayOffStage(void)
{
+ // Test that an animation can be played, when the actor is off-stage.
+ // When the actor is added to the stage, it should appear at the current position
+ // i.e. where it would have been anyway, if on-stage from the beginning.
+
TestApplication application;
Actor actor = Actor::New();
- Stage::GetCurrent().Add(actor);
+ Vector3 basePosition(Vector3::ZERO);
+ DALI_TEST_EQUALS( actor.GetCurrentPosition(), basePosition, TEST_LOCATION );
+ // Not added to the stage!
// Build the animation
float durationSeconds(1.0f);
Animation animation = Animation::New(durationSeconds);
+ animation.SetDisconnectAction( Animation::Discard );
Vector3 targetPosition(100.0f, 100.0f, 100.0f);
animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear);
// We didn't expect the animation to finish yet
application.SendNotification();
finishCheck.CheckSignalNotReceived();
- DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO/*off-stage*/, TEST_LOCATION );
- // This is a test of the "Fire and Forget" behaviour
- // Stop the animation, and Discard the animation handle!
+ // Add to the stage
+ Stage::GetCurrent().Add(actor);
+
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 40% progress */);
+
+ // We didn't expect the animation to finish yet
+ application.SendNotification();
+ finishCheck.CheckSignalNotReceived();
+ Vector3 expectedPosition(basePosition + (targetPosition - basePosition)*0.4f);
+ DALI_TEST_EQUALS( actor.GetCurrentPosition(), expectedPosition/*on-stage*/, TEST_LOCATION );
+
+ // Remove from the stage
+ Stage::GetCurrent().Remove(actor);
+
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 60% progress */);
+
+ // We didn't expect the animation to finish yet
+ application.SendNotification();
+ finishCheck.CheckSignalNotReceived();
+ DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO/*back to start position*/, TEST_LOCATION );
+
+ // Add to the stage
+ Stage::GetCurrent().Add(actor);
+
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 80% progress */);
+
+ // We didn't expect the animation to finish yet
+ application.SendNotification();
+ finishCheck.CheckSignalNotReceived();
+ expectedPosition = Vector3(basePosition + (targetPosition - basePosition)*0.8f);
+ DALI_TEST_EQUALS( actor.GetCurrentPosition(), expectedPosition, TEST_LOCATION );
+
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(durationSeconds*200.0f) + 1u/*just beyond the animation duration*/);
+
+ // We did expect the animation to finish
+ application.SendNotification();
+ finishCheck.CheckSignalReceived();
+ 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( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
+ application.Render(0);
+ DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
+ END_TEST;
+}
+
+int UtcDaliAnimationPlayDiscardHandle(void)
+{
+ TestApplication application;
+
+ Actor actor = Actor::New();
+ Stage::GetCurrent().Add(actor);
+
+ // Build the animation
+ float durationSeconds(1.0f);
+ Animation animation = Animation::New(durationSeconds);
+ Vector3 targetPosition(100.0f, 100.0f, 100.0f);
+ animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear);
+
+ bool signalReceived(false);
+ AnimationFinishCheck finishCheck(signalReceived);
+ animation.FinishedSignal().Connect(&application, finishCheck);
+
+ // Start the animation
+ animation.Play();
+
+ // This is a test of the "Fire and Forget" behaviour
+ // Discard the animation handle!
+ animation.Reset();
+ DALI_TEST_CHECK( !animation );
+
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 20% progress */);
+
+ // We didn't expect the animation to finish yet
+ application.SendNotification();
+ finishCheck.CheckSignalNotReceived();
+ DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION );
+
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 40% progress */);
+
+ // We didn't expect the animation to finish yet
+ application.SendNotification();
+ finishCheck.CheckSignalNotReceived();
+ DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.4f), TEST_LOCATION );
+
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 60% progress */);
+
+ // We didn't expect the animation to finish yet
+ application.SendNotification();
+ finishCheck.CheckSignalNotReceived();
+ DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.6f), TEST_LOCATION );
+
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 80% progress */);
+
+ // We didn't expect the animation to finish yet
+ application.SendNotification();
+ finishCheck.CheckSignalNotReceived();
+ DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.8f), TEST_LOCATION );
+
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(durationSeconds*200.0f) + 1u/*just beyond the animation duration*/);
+
+ // We did expect the animation to finish
+ application.SendNotification();
+ finishCheck.CheckSignalReceived();
+ 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( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
+ application.Render(0);
+ DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
+ END_TEST;
+}
+
+int UtcDaliAnimationPlayStopDiscardHandle(void)
+{
+ TestApplication application;
+
+ Actor actor = Actor::New();
+ Stage::GetCurrent().Add(actor);
+
+ // Build the animation
+ float durationSeconds(1.0f);
+ Animation animation = Animation::New(durationSeconds);
+ Vector3 targetPosition(100.0f, 100.0f, 100.0f);
+ animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear);
+
+ // Start the animation
+ animation.Play();
+
+ bool signalReceived(false);
+ AnimationFinishCheck finishCheck(signalReceived);
+ animation.FinishedSignal().Connect(&application, finishCheck);
+
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 20% progress */);
+
+ // We didn't expect the animation to finish yet
+ application.SendNotification();
+ finishCheck.CheckSignalNotReceived();
+ DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION );
+
+ // This is a test of the "Fire and Forget" behaviour
+ // Stop the animation, and Discard the animation handle!
animation.Stop();
animation.Reset();
DALI_TEST_CHECK( !animation );
END_TEST;
}
+int UtcDaliAnimationPlayRange(void)
+{
+ TestApplication application;
+
+ Actor actor = Actor::New();
+ Stage::GetCurrent().Add(actor);
+
+ // Build the animation
+ float durationSeconds(1.0f);
+ Animation animation = Animation::New(durationSeconds);
+ Vector3 targetPosition(100.0f, 100.0f, 100.0f);
+ KeyFrames keyframes = KeyFrames::New();
+ keyframes.Add( 0.0f , Vector3(0.0f,0.0f,0.0f ) );
+ keyframes.Add( 1.0f , Vector3(100.0f,100.0f,100.0f ) );
+
+ animation.AnimateBetween( Property( actor, Actor::POSITION), keyframes );
+
+ // Set range between 0.4 and 0.8
+ animation.SetPlayRange( Vector2(0.4f,0.8f) );
+ animation.Play();
+
+ bool signalReceived(false);
+ AnimationFinishCheck finishCheck(signalReceived);
+ animation.FinishedSignal().Connect(&application, finishCheck);
+
+ //Test that setting progress outside the range doesn't work
+ animation.SetCurrentProgress( 0.9f );
+ application.SendNotification();
+ application.Render(0);
+ DALI_TEST_EQUALS( animation.GetCurrentProgress(), 0.4f, TEST_LOCATION );
+ animation.SetCurrentProgress( 0.2f );
+ application.SendNotification();
+ application.Render(0);
+ DALI_TEST_EQUALS( animation.GetCurrentProgress(), 0.4f, TEST_LOCATION );
+
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 60% progress */);
+
+ // We didn't expect the animation to finish yet
+ application.SendNotification();
+ finishCheck.CheckSignalNotReceived();
+ DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.6f), TEST_LOCATION );
+
+ animation.Play(); // Test that calling play has no effect, when animation is already playing
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(durationSeconds*200.0f) + 1u/* 80% progress */);
+
+ // We did expect the animation to finish
+ application.SendNotification();
+ finishCheck.CheckSignalReceived();
+ DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.8f), TEST_LOCATION );
+
+ // Check that nothing has changed after a couple of buffer swaps
+ application.Render(0);
+ DALI_TEST_EQUALS( targetPosition * 0.8f, actor.GetCurrentPosition(), TEST_LOCATION );
+ application.Render(0);
+ DALI_TEST_EQUALS( targetPosition * 0.8f, actor.GetCurrentPosition(), TEST_LOCATION );
+
+
+ //Loop inside the range
+ finishCheck.Reset();
+ animation.SetLooping( true );
+ animation.Play();
+ application.SendNotification();
+ float intervalSeconds = 0.1f;
+ float progress = 0.4f;
+ for (int iterations = 0; iterations < 10; ++iterations )
+ {
+ application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
+
+ progress += intervalSeconds;
+ if (progress > 0.8f)
+ {
+ progress = progress - 0.4f;
+ }
+
+ DALI_TEST_EQUALS( targetPosition*progress, actor.GetCurrentPosition(), 0.001f, TEST_LOCATION );
+ }
+
+ // We didn't expect the animation to finish yet
+ application.SendNotification();
+ finishCheck.CheckSignalNotReceived();
+
+
+ //Test change range on the fly
+ animation.SetPlayRange( Vector2( 0.2f, 0.9f ) );
+ application.SendNotification();
+
+ for (int iterations = 0; iterations < 10; ++iterations )
+ {
+ application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
+
+ progress += intervalSeconds;
+ if (progress > 0.9f)
+ {
+ progress = progress - 0.7f;
+ }
+
+ DALI_TEST_EQUALS( targetPosition*progress, actor.GetCurrentPosition(), 0.001f, TEST_LOCATION );
+ }
+
+ END_TEST;
+}
+
+int UtcDaliAnimationSetPlayRange(void)
+{
+ TestApplication application;
+
+ Actor actor = Actor::New();
+ Stage::GetCurrent().Add(actor);
+
+ // Build the animation
+ Animation animation = Animation::New(0);
+ application.SendNotification();
+
+ //If PlayRange not specified it should be 0.0-1.0 by default
+ DALI_TEST_EQUALS( Vector2(0.0,1.0), animation.GetPlayRange(), TEST_LOCATION );
+
+ //PlayRange out of bounds
+ animation.SetPlayRange( Vector2(-1.0f,1.0f) );
+ application.SendNotification();
+ DALI_TEST_EQUALS( Vector2(0.0f,1.0f), animation.GetPlayRange(), TEST_LOCATION );
+ animation.SetPlayRange( Vector2(0.0f,2.0f) );
+ application.SendNotification();
+ DALI_TEST_EQUALS( Vector2(0.0f,1.0f), animation.GetPlayRange(), TEST_LOCATION );
+
+ //If playRange is not in the correct order it has to be ordered
+ animation.SetPlayRange( Vector2(0.8f,0.2f) );
+ application.SendNotification();
+ DALI_TEST_EQUALS( Vector2(0.2f,0.8f), animation.GetPlayRange(), TEST_LOCATION );
+
+ // Set range between 0.4 and 0.8
+ animation.SetPlayRange( Vector2(0.4f,0.8f) );
+ application.SendNotification();
+ DALI_TEST_EQUALS( Vector2(0.4f,0.8f), animation.GetPlayRange(), TEST_LOCATION );
+
+ END_TEST;
+}
int UtcDaliAnimationPause(void)
{
}
catch (Dali::DaliException& e)
{
- tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
+ DALI_TEST_PRINT_ASSERT( e );
DALI_TEST_ASSERT(e, "IsPropertyAnimatable(index)", TEST_LOCATION);
}
END_TEST;
}
catch (Dali::DaliException& e)
{
- tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
+ DALI_TEST_PRINT_ASSERT( e );
DALI_TEST_ASSERT(e, "IsPropertyAnimatable(index)", TEST_LOCATION);
}
END_TEST;
}
catch (Dali::DaliException& e)
{
- tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
+ DALI_TEST_PRINT_ASSERT( e );
DALI_TEST_ASSERT(e, "IsPropertyAnimatable(index)", TEST_LOCATION);
}
END_TEST;
}
catch (Dali::DaliException& e)
{
- tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
+ DALI_TEST_PRINT_ASSERT( e );
DALI_TEST_ASSERT(e, "IsPropertyAnimatable(index)", TEST_LOCATION);
}
END_TEST;
}
catch (Dali::DaliException& e)
{
- tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
+ DALI_TEST_PRINT_ASSERT( e );
DALI_TEST_ASSERT(e, "IsPropertyAnimatable(index)", TEST_LOCATION);
}
END_TEST;
}
catch (Dali::DaliException& e)
{
- tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
+ DALI_TEST_PRINT_ASSERT( e );
DALI_TEST_ASSERT(e, "IsPropertyAnimatable(index)", TEST_LOCATION);
}
END_TEST;
}
catch (Dali::DaliException& e)
{
- tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
+ DALI_TEST_PRINT_ASSERT( e );
DALI_TEST_ASSERT(e, "IsPropertyAnimatable(index)", TEST_LOCATION);
}
END_TEST;
}
catch (Dali::DaliException& e)
{
- tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
+ DALI_TEST_PRINT_ASSERT( e );
DALI_TEST_ASSERT(e, "IsPropertyAnimatable(index)", TEST_LOCATION);
}
END_TEST;
}
catch (Dali::DaliException& e)
{
- tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
+ DALI_TEST_PRINT_ASSERT( e );
DALI_TEST_ASSERT(e, "mType == value.GetType()", TEST_LOCATION);
}
END_TEST;
}
catch (Dali::DaliException& e)
{
- tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
+ DALI_TEST_PRINT_ASSERT( e );
DALI_TEST_ASSERT(e, "mType == value.GetType()", TEST_LOCATION);
}
END_TEST;
}
catch (Dali::DaliException& e)
{
- tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
+ DALI_TEST_PRINT_ASSERT( e );
DALI_TEST_ASSERT(e, "mType == value.GetType()", TEST_LOCATION);
}
END_TEST;
}
catch (Dali::DaliException& e)
{
- tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
+ DALI_TEST_PRINT_ASSERT( e );
DALI_TEST_ASSERT(e, "mType == value.GetType()", TEST_LOCATION);
}
END_TEST;
}
catch (Dali::DaliException& e)
{
- tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
+ DALI_TEST_PRINT_ASSERT( e );
DALI_TEST_ASSERT(e, "mType == value.GetType()", TEST_LOCATION);
}
END_TEST;
}
catch (Dali::DaliException& e)
{
- tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
+ DALI_TEST_PRINT_ASSERT( e );
DALI_TEST_ASSERT(e, "mType == value.GetType()", TEST_LOCATION);
}
END_TEST;
END_TEST;
}
-
-int UtcDaliAnimationAnimateBetweenActorColor(void)
+int UtcDaliAnimationAnimateBetweenActorColorAlphaCubic(void)
{
TestApplication application;
Animation animation = Animation::New(durationSeconds);
KeyFrames keyFrames = KeyFrames::New();
- keyFrames.Add(0.0f, Vector4(0.1f, 0.2f, 0.3f, 0.4f));
- keyFrames.Add(0.5f, Vector4(0.9f, 0.8f, 0.7f, 0.6f));
- keyFrames.Add(1.0f, Vector4(1.0f, 1.0f, 1.0f, 1.0f));
-
+ keyFrames.Add(0.0f, 0.1f);
+ keyFrames.Add(0.2f, 0.5f);
+ keyFrames.Add(0.4f, 0.0f);
+ keyFrames.Add(0.6f, 1.0f);
+ keyFrames.Add(0.8f, 0.7f);
+ keyFrames.Add(1.0f, 0.9f);
+
+ animation.AnimateBetween( Property(actor, Actor::COLOR_ALPHA), keyFrames, Animation::Cubic );
+
+ // Start the animation
+ animation.Play();
+
+ bool signalReceived(false);
+ AnimationFinishCheck finishCheck(signalReceived);
+ animation.FinishedSignal().Connect(&application, finishCheck);
+ application.SendNotification();
+ application.Render(0);
+ application.SendNotification();
+ finishCheck.CheckSignalNotReceived();
+ DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.1f, TEST_LOCATION );
+
+ application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% progress */);
+ application.SendNotification();
+ DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.36f, 0.01f, TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.36f, 0.01f, TEST_LOCATION );
+
+ application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 30% progress */);
+ application.SendNotification();
+ DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.21f, 0.01f, TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.21f, 0.01f, TEST_LOCATION );
+
+ application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 40% progress */);
+ application.SendNotification();
+ DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.0f, 0.01f, TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.0f, 0.01f, TEST_LOCATION );
+
+ application.Render(static_cast<unsigned int>(durationSeconds*400.0f)/* 80% progress */);
+ application.SendNotification();
+ DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.7f, 0.01f, TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.7f, 0.01f, TEST_LOCATION );
+
+ application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 90% progress */);
+ application.SendNotification();
+ DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.76f, 0.01f, TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.76f, 0.01f, TEST_LOCATION );
+
+ application.Render(static_cast<unsigned int>(durationSeconds*100.0f)+1/* 100% progress */);
+ application.SendNotification();
+ DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.9f, 0.01f, TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.9f, 0.01f, TEST_LOCATION );
+
+ // We did expect the animation to finish
+
+ finishCheck.CheckSignalReceived();
+ END_TEST;
+}
+
+int UtcDaliAnimationAnimateBetweenActorColor(void)
+{
+ TestApplication application;
+
+ float startValue(1.0f);
+ Actor actor = Actor::New();
+ actor.SetColor(Vector4(startValue, startValue, startValue, startValue));
+ Stage::GetCurrent().Add(actor);
+
+ DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), startValue, TEST_LOCATION );
+
+ // Build the animation
+ float durationSeconds(1.0f);
+ Animation animation = Animation::New(durationSeconds);
+
+ KeyFrames keyFrames = KeyFrames::New();
+ keyFrames.Add(0.0f, Vector4(0.1f, 0.2f, 0.3f, 0.4f));
+ keyFrames.Add(0.5f, Vector4(0.9f, 0.8f, 0.7f, 0.6f));
+ keyFrames.Add(1.0f, Vector4(1.0f, 1.0f, 1.0f, 1.0f));
+
animation.AnimateBetween( Property(actor, Actor::COLOR), keyFrames );
// Start the animation
END_TEST;
}
-int UtcDaliAnimationAnimateBetweenActorVisible01(void)
+int UtcDaliAnimationAnimateBetweenActorColorCubic(void)
+{
+ TestApplication application;
+
+ float startValue(1.0f);
+ Actor actor = Actor::New();
+ actor.SetColor(Vector4(startValue, startValue, startValue, startValue));
+ Stage::GetCurrent().Add(actor);
+
+ DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), startValue, TEST_LOCATION );
+
+ // Build the animation
+ float durationSeconds(1.0f);
+ Animation animation = Animation::New(durationSeconds);
+
+ KeyFrames keyFrames = KeyFrames::New();
+ keyFrames.Add(0.0f, Vector4(0.1f, 0.2f, 0.3f, 0.4f));
+ keyFrames.Add(0.5f, Vector4(0.9f, 0.8f, 0.7f, 0.6f));
+ keyFrames.Add(1.0f, Vector4(1.0f, 1.0f, 1.0f, 1.0f));
+
+ animation.AnimateBetween( Property(actor, Actor::COLOR), keyFrames, Animation::Cubic );
+
+ // Start the animation
+ animation.Play();
+
+ bool signalReceived(false);
+ AnimationFinishCheck finishCheck(signalReceived);
+ animation.FinishedSignal().Connect(&application, finishCheck);
+ application.SendNotification();
+ application.Render(0);
+ application.SendNotification();
+ finishCheck.CheckSignalNotReceived();
+ DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), 0.1f, 0.01f, TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 0.2f, 0.01f, TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), 0.3f, 0.01f, TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.4f, 0.01f, TEST_LOCATION );
+
+ application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
+ application.SendNotification();
+ DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), 0.55f, 0.01f, TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 0.525f, 0.01f, TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), 0.506f, 0.01f, TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.4875f, 0.01f, TEST_LOCATION );
+
+ application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
+ application.SendNotification();
+ DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), 0.9f, 0.01f, TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 0.8f, 0.01f, TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), 0.7f, 0.01f, TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.6f, 0.01f, TEST_LOCATION );
+
+ application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
+ application.SendNotification();
+ DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), 0.99375f, 0.01f, TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 0.925f, 0.01f, TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), 0.85625f, 0.01f, TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.7875f, 0.01f, TEST_LOCATION );
+
+ application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
+ application.SendNotification();
+ DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), 1.0f, 0.01f, TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 1.0f, 0.01f, TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), 1.0f, 0.01f, TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 1.0f, 0.01f, TEST_LOCATION );
+
+ // We did expect the animation to finish
+
+ finishCheck.CheckSignalReceived();
+ END_TEST;
+}
+
+int UtcDaliAnimationAnimateBetweenActorVisible(void)
{
TestApplication application;
END_TEST;
}
+int UtcDaliAnimationAnimateBetweenActorVisibleCubic(void)
+{
+ TestApplication application;
+
+ Actor actor = Actor::New();
+ AngleAxis aa(Degree(90), Vector3::XAXIS);
+ actor.SetRotation(aa.angle, aa.axis);
+ Stage::GetCurrent().Add(actor);
+
+ application.SendNotification();
+ application.Render(0);
+
+ DALI_TEST_EQUALS( actor.IsVisible(), true, TEST_LOCATION );
+
+ // Build the animation
+ float durationSeconds(1.0f);
+ Animation animation = Animation::New(durationSeconds);
+
+ KeyFrames keyFrames = KeyFrames::New();
+ keyFrames.Add(0.0f, false);
+ keyFrames.Add(0.2f, true);
+ keyFrames.Add(0.4f, true);
+ keyFrames.Add(0.8f, false);
+ keyFrames.Add(1.0f, true);
+
+ //Cubic interpolation for boolean values should be ignored
+ animation.AnimateBetween( Property(actor, Actor::VISIBLE), keyFrames, Animation::Cubic );
+
+ // Start the animation
+ animation.Play();
+
+ bool signalReceived(false);
+ AnimationFinishCheck finishCheck(signalReceived);
+ animation.FinishedSignal().Connect(&application, finishCheck);
+ application.SendNotification();
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(durationSeconds*500.0f));
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(durationSeconds*500.0f)+1);
+ application.SendNotification();
+
+ DALI_TEST_EQUALS( actor.IsVisible(), true, TEST_LOCATION);
+ finishCheck.CheckSignalReceived();
+ END_TEST;
+}
+
int UtcDaliAnimationAnimateBetweenActorRotation01(void)
{
TestApplication application;
END_TEST;
}
-int UtcDaliAnimationMoveByFloat3(void)
+int UtcDaliAnimationAnimateBetweenActorRotation01Cubic(void)
{
TestApplication application;
Actor actor = Actor::New();
- Vector3 startPosition(10.0f, 10.0f, 10.0f);
- actor.SetPosition(startPosition);
+ AngleAxis aa(Degree(90), Vector3::XAXIS);
+ actor.SetRotation(aa.angle, aa.axis);
Stage::GetCurrent().Add(actor);
+
application.SendNotification();
application.Render(0);
- DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION );
+ Quaternion start(Radian(aa.angle), aa.axis);
+ DALI_TEST_EQUALS( actor.GetCurrentRotation(), start, 0.001f, TEST_LOCATION );
// Build the animation
float durationSeconds(1.0f);
Animation animation = Animation::New(durationSeconds);
- Vector3 targetPosition(20.0f, 20.0f, 20.0f);
- Vector3 relativePosition(targetPosition - startPosition);
- animation.MoveBy(actor, relativePosition.x, relativePosition.y, relativePosition.z);
- Vector3 ninetyFivePercentProgress(startPosition + relativePosition*0.95f);
+ KeyFrames keyFrames = KeyFrames::New();
+ keyFrames.Add(0.0f, AngleAxis(Degree(60), Vector3::ZAXIS));
+
+ //Cubic interpolation should be ignored for quaternions
+ animation.AnimateBetween( Property(actor, Actor::ROTATION), keyFrames, Animation::Cubic );
// Start the animation
animation.Play();
bool signalReceived(false);
AnimationFinishCheck finishCheck(signalReceived);
animation.FinishedSignal().Connect(&application, finishCheck);
-
application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
-
- // We didn't expect the animation to finish yet
application.SendNotification();
- finishCheck.CheckSignalNotReceived();
- DALI_TEST_EQUALS( actor.GetCurrentPosition(), ninetyFivePercentProgress, TEST_LOCATION );
-
+ application.Render(static_cast<unsigned int>(durationSeconds*500.0f));
application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
-
- // We did expect the animation to finish
+ application.Render(static_cast<unsigned int>(durationSeconds*500.0f)+1);
application.SendNotification();
+
+ Quaternion check = Quaternion::FromAxisAngle(Vector4::ZAXIS, Radian(Degree(60)));
+
+ DALI_TEST_EQUALS( actor.GetCurrentRotation(), check, 0.001f, TEST_LOCATION );
finishCheck.CheckSignalReceived();
- DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
END_TEST;
}
-int UtcDaliAnimationMoveByVector3Alpha(void)
+int UtcDaliAnimationAnimateBetweenActorRotation02Cubic(void)
{
TestApplication application;
Actor actor = Actor::New();
- Vector3 startPosition(10.0f, 10.0f, 10.0f);
- actor.SetPosition(startPosition);
- Stage::GetCurrent().Add(actor);
+ AngleAxis aa(Degree(90), Vector3::XAXIS);
+ actor.SetRotation(aa.angle, aa.axis);
application.SendNotification();
application.Render(0);
- DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION );
+ Stage::GetCurrent().Add(actor);
+
+ Quaternion start(Radian(aa.angle), aa.axis);
+ DALI_TEST_EQUALS( actor.GetCurrentRotation(), start, 0.001f, TEST_LOCATION );
// Build the animation
float durationSeconds(1.0f);
Animation animation = Animation::New(durationSeconds);
- Vector3 targetPosition(20.0f, 20.0f, 20.0f);
- Vector3 relativePosition(targetPosition - startPosition);
- animation.MoveBy(actor, relativePosition, AlphaFunctions::EaseOut);
- Vector3 ninetyFivePercentProgress(startPosition + relativePosition*0.95f);
+ KeyFrames keyFrames = KeyFrames::New();
+ keyFrames.Add(0.0f, AngleAxis(Degree(60), Vector3::XAXIS));
+ keyFrames.Add(0.5f, AngleAxis(Degree(120), Vector3::XAXIS));
+ keyFrames.Add(1.0f, AngleAxis(Degree(120), Vector3::YAXIS));
+
+ //Cubic interpolation should be ignored for quaternions
+ animation.AnimateBetween( Property(actor, Actor::ROTATION), keyFrames, Animation::Cubic );
// Start the animation
animation.Play();
bool signalReceived(false);
AnimationFinishCheck finishCheck(signalReceived);
animation.FinishedSignal().Connect(&application, finishCheck);
-
application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
-
+ application.Render(0);
+ application.SendNotification();
+ finishCheck.CheckSignalNotReceived();
+
+ Quaternion check(Radian(Degree(60)), Vector3::XAXIS);
+ DALI_TEST_EQUALS( actor.GetCurrentRotation(), check, 0.001f, TEST_LOCATION );
+
+ application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
+ application.SendNotification();
+ check = Quaternion::FromAxisAngle(Vector4::XAXIS, Radian(Degree(90)));
+ DALI_TEST_EQUALS( actor.GetCurrentRotation(), check, 0.001f, TEST_LOCATION );
+
+ application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
+ application.SendNotification();
+ check = Quaternion::FromAxisAngle(Vector4::XAXIS, Radian(Degree(120)));
+ DALI_TEST_EQUALS( actor.GetCurrentRotation(), check, 0.001f, TEST_LOCATION );
+
+ application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
+ application.SendNotification();
+ check = Quaternion::FromAxisAngle(Vector4(0.5f, 0.5f, 0.0f, 0.0f), Radian(Degree(101.5)));
+ DALI_TEST_EQUALS( actor.GetCurrentRotation(), check, 0.001f, TEST_LOCATION );
+
+ application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
+ application.SendNotification();
+ check = Quaternion::FromAxisAngle(Vector4::YAXIS, Radian(Degree(120)));
+ DALI_TEST_EQUALS( actor.GetCurrentRotation(), check, 0.001f, TEST_LOCATION );
+
+ // We did expect the animation to finish
+
+ finishCheck.CheckSignalReceived();
+ END_TEST;
+}
+
+
+int UtcDaliAnimationMoveByFloat3(void)
+{
+ TestApplication application;
+
+ Actor actor = Actor::New();
+ Vector3 startPosition(10.0f, 10.0f, 10.0f);
+ actor.SetPosition(startPosition);
+ Stage::GetCurrent().Add(actor);
+ application.SendNotification();
+ application.Render(0);
+ DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION );
+
+ // Build the animation
+ float durationSeconds(1.0f);
+ Animation animation = Animation::New(durationSeconds);
+ Vector3 targetPosition(20.0f, 20.0f, 20.0f);
+ Vector3 relativePosition(targetPosition - startPosition);
+ animation.MoveBy(actor, relativePosition.x, relativePosition.y, relativePosition.z);
+
+ Vector3 ninetyFivePercentProgress(startPosition + relativePosition*0.95f);
+
+ // Start the animation
+ animation.Play();
+
+ bool signalReceived(false);
+ AnimationFinishCheck finishCheck(signalReceived);
+ animation.FinishedSignal().Connect(&application, finishCheck);
+
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
+
+ // We didn't expect the animation to finish yet
+ application.SendNotification();
+ finishCheck.CheckSignalNotReceived();
+ DALI_TEST_EQUALS( actor.GetCurrentPosition(), ninetyFivePercentProgress, TEST_LOCATION );
+
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
+
+ // We did expect the animation to finish
+ application.SendNotification();
+ finishCheck.CheckSignalReceived();
+ DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
+ END_TEST;
+}
+
+int UtcDaliAnimationMoveByVector3Alpha(void)
+{
+ TestApplication application;
+
+ Actor actor = Actor::New();
+ Vector3 startPosition(10.0f, 10.0f, 10.0f);
+ actor.SetPosition(startPosition);
+ Stage::GetCurrent().Add(actor);
+ application.SendNotification();
+ application.Render(0);
+ DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION );
+
+ // Build the animation
+ float durationSeconds(1.0f);
+ Animation animation = Animation::New(durationSeconds);
+ Vector3 targetPosition(20.0f, 20.0f, 20.0f);
+ Vector3 relativePosition(targetPosition - startPosition);
+ animation.MoveBy(actor, relativePosition, AlphaFunctions::EaseOut);
+
+ Vector3 ninetyFivePercentProgress(startPosition + relativePosition*0.95f);
+
+ // Start the animation
+ animation.Play();
+
+ bool signalReceived(false);
+ AnimationFinishCheck finishCheck(signalReceived);
+ animation.FinishedSignal().Connect(&application, finishCheck);
+
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
+
// We didn't expect the animation to finish yet
application.SendNotification();
finishCheck.CheckSignalNotReceived();
END_TEST;
}
-int UtcDaliAnimationMove(void)
-{
- TestApplication application;
-
- Actor actor = Actor::New();
- Vector3 initialPosition(Vector3::ZERO);
- DALI_TEST_EQUALS( actor.GetCurrentPosition(), initialPosition, TEST_LOCATION );
- Stage::GetCurrent().Add(actor);
-
- // Build the animation
- float durationSeconds(10.0f);
- Animation animation = Animation::New(durationSeconds);
- Vector3 targetPosition(200.0f, 200.0f, 200.0f);
- BounceFunc func(0.0f, 0.0f, -100.0f);
- animation.Move(actor, func, AlphaFunctions::Linear, 0.0f, durationSeconds);
-
- // Start the animation
- animation.Play();
-
- bool signalReceived(false);
- AnimationFinishCheck finishCheck(signalReceived);
- animation.FinishedSignal().Connect(&application, finishCheck);
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
-
- // We didn't expect the animation to finish yet
- application.SendNotification();
- finishCheck.CheckSignalNotReceived();
- DALI_TEST_EQUALS( actor.GetCurrentPosition(), func(0.25f, initialPosition), TEST_LOCATION );
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
-
- // We didn't expect the animation to finish yet
- application.SendNotification();
- finishCheck.CheckSignalNotReceived();
- DALI_TEST_EQUALS( actor.GetCurrentPosition(), func(0.5f, initialPosition), TEST_LOCATION );
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
-
- // We didn't expect the animation to finish yet
- application.SendNotification();
- finishCheck.CheckSignalNotReceived();
- DALI_TEST_EQUALS( actor.GetCurrentPosition(), func(0.75f, initialPosition), TEST_LOCATION );
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
-
- // We did expect the animation to finish
- application.SendNotification();
- finishCheck.CheckSignalReceived();
- DALI_TEST_EQUALS( actor.GetCurrentPosition(), initialPosition, TEST_LOCATION );
- END_TEST;
-}
-
int UtcDaliAnimationRotateByDegreeVector3(void)
{
TestApplication application;
END_TEST;
}
-int UtcDaliAnimationRotate(void)
-{
- TestApplication application;
-
- Actor actor = Actor::New();
- Quaternion initialRotation(0.0f, Vector3::YAXIS);
- actor.SetRotation(initialRotation);
- Stage::GetCurrent().Add(actor);
- DALI_TEST_EQUALS( actor.GetCurrentRotation(), initialRotation, ROTATION_EPSILON, TEST_LOCATION );
-
- // Build the animation
- float durationSeconds(1.0f);
- Animation animation = Animation::New(durationSeconds);
- TumbleFunc func(Vector3::YAXIS);
- animation.Rotate(actor, func, AlphaFunctions::Linear, 0.0f, durationSeconds);
-
- // Start the animation
- animation.Play();
-
- bool signalReceived(false);
- AnimationFinishCheck finishCheck(signalReceived);
- animation.FinishedSignal().Connect(&application, finishCheck);
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
-
- // We didn't expect the animation to finish yet
- application.SendNotification();
- finishCheck.CheckSignalNotReceived();
- DALI_TEST_EQUALS( actor.GetCurrentRotation(), func(0.25f, initialRotation), ROTATION_EPSILON, TEST_LOCATION );
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
-
- // We didn't expect the animation to finish yet
- application.SendNotification();
- finishCheck.CheckSignalNotReceived();
- DALI_TEST_EQUALS( actor.GetCurrentRotation(), func(0.5f, initialRotation), ROTATION_EPSILON, TEST_LOCATION );
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
-
- // We didn't expect the animation to finish yet
- application.SendNotification();
- finishCheck.CheckSignalNotReceived();
- DALI_TEST_EQUALS( actor.GetCurrentRotation(), func(0.75f, initialRotation), ROTATION_EPSILON, TEST_LOCATION );
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
-
- // We did expect the animation to finish
- application.SendNotification();
- finishCheck.CheckSignalReceived();
- DALI_TEST_EQUALS( actor.GetCurrentRotation(), func(1.0f, initialRotation), ROTATION_EPSILON, TEST_LOCATION );
- END_TEST;
-}
-
int UtcDaliAnimationScaleBy(void)
{
TestApplication application;
// Repeat with a shorter animator duration
float animatorDuration = 0.5f;
animation = Animation::New(durationSeconds);
- animation.ColorTo(actor, targetColor, AlphaFunctions::Linear, 0, animatorDuration);
- animation.FinishedSignal().Connect(&application, finishCheck);
- animation.Play();
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% animation progress, 20% animator progress */);
-
- // We didn't expect the animation to finish yet
- application.SendNotification();
- finishCheck.CheckSignalNotReceived();
- DALI_TEST_EQUALS( actor.GetCurrentColor(), twentyPercentProgress, TEST_LOCATION );
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*400.0f)/* 50% animation progress, 100% animator progress */);
-
- // We didn't expect the animation to finish yet
- application.SendNotification();
- finishCheck.CheckSignalNotReceived();
- DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION );
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
-
- // We did expect the animation to finish
- application.SendNotification();
- finishCheck.CheckSignalReceived();
- DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION );
- END_TEST;
-}
-
-int UtcDaliAnimationResize(void)
-{
- TestApplication application;
-
- Actor actor = Actor::New();
- Stage::GetCurrent().Add(actor);
- DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
-
- // Build the animation
- float durationSeconds(1.0f);
- Animation animation = Animation::New(durationSeconds);
- Vector3 targetSize(100.0f, 100.0f, 100.0f);
- animation.Resize(actor, targetSize);
-
- Vector3 ninetyNinePercentProgress(targetSize * 0.99f);
-
- // Start the animation
- animation.Play();
-
- bool signalReceived(false);
- AnimationFinishCheck finishCheck(signalReceived);
- animation.FinishedSignal().Connect(&application, finishCheck);
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
-
- // We didn't expect the animation to finish yet
- application.SendNotification();
- finishCheck.CheckSignalNotReceived();
- DALI_TEST_EQUALS( actor.GetCurrentSize(), ninetyNinePercentProgress, TEST_LOCATION );
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
-
- // We did expect the animation to finish
- application.SendNotification();
- finishCheck.CheckSignalReceived();
- DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION );
-
- // Reset everything
- finishCheck.Reset();
- actor.SetSize(Vector3::ZERO);
- application.SendNotification();
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
-
- // Repeat with a different (ease-in) alpha function
- animation = Animation::New(durationSeconds);
- animation.Resize(actor, targetSize, AlphaFunctions::EaseIn);
- animation.FinishedSignal().Connect(&application, finishCheck);
- animation.Play();
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
-
- // We didn't expect the animation to finish yet
- application.SendNotification();
- finishCheck.CheckSignalNotReceived();
-
- // The size should have travelled less, than with a linear alpha function
- Vector3 current(actor.GetCurrentSize());
- DALI_TEST_CHECK( current.x > 0.0f );
- DALI_TEST_CHECK( current.y > 0.0f );
- DALI_TEST_CHECK( current.z > 0.0f );
- DALI_TEST_CHECK( current.x < ninetyNinePercentProgress.x );
- DALI_TEST_CHECK( current.y < ninetyNinePercentProgress.y );
- DALI_TEST_CHECK( current.z < ninetyNinePercentProgress.z );
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
-
- // We did expect the animation to finish
- application.SendNotification();
- finishCheck.CheckSignalReceived();
- DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION );
-
- // Reset everything
- finishCheck.Reset();
- actor.SetSize(Vector3::ZERO);
- application.SendNotification();
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
-
- // Repeat with a delay
- float delay = 0.5f;
- animation = Animation::New(durationSeconds);
- animation.Resize(actor, targetSize, AlphaFunctions::Linear, delay, durationSeconds - delay);
- animation.FinishedSignal().Connect(&application, finishCheck);
- animation.Play();
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
-
- // We didn't expect the animation to finish yet
- application.SendNotification();
- finishCheck.CheckSignalNotReceived();
- DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
-
- // We did expect the animation to finish
- application.SendNotification();
- finishCheck.CheckSignalReceived();
- DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION );
- END_TEST;
-}
-
-int UtcDaliAnimationAnimateBool(void)
-{
- TestApplication application;
-
- Actor actor = Actor::New();
- DALI_TEST_EQUALS( actor.IsVisible(), true, TEST_LOCATION );
- Stage::GetCurrent().Add(actor);
-
- // Build the animation
- float durationSeconds(10.0f);
- Animation animation = Animation::New(durationSeconds);
- animation.Animate<bool>( Property(actor, Actor::VISIBLE), ReturnFalseAfterProgressOne, TimePeriod(durationSeconds*0.25f/*delay*/, durationSeconds*0.1f) );
-
- // Start the animation
- animation.Play();
-
- bool signalReceived(false);
- AnimationFinishCheck finishCheck(signalReceived);
- animation.FinishedSignal().Connect(&application, finishCheck);
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
-
- // We didn't expect the animation to finish yet
- application.SendNotification();
- finishCheck.CheckSignalNotReceived();
-
- // Should still be visible
- DALI_TEST_EQUALS( actor.IsVisible(), true, TEST_LOCATION );
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
-
- // We didn't expect the animation to finish yet
- application.SendNotification();
- finishCheck.CheckSignalNotReceived();
-
- // Now animate functor should have hidden the actor
- DALI_TEST_EQUALS( actor.IsVisible(), false, TEST_LOCATION );
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
-
- // We did expect the animation to finish
- application.SendNotification();
- finishCheck.CheckSignalReceived();
- DALI_TEST_EQUALS( actor.IsVisible(), false, TEST_LOCATION );
- END_TEST;
-}
-
-int UtcDaliAnimationAnimateFloat(void)
-{
- TestApplication application;
-
- Actor actor = Actor::New();
- Stage::GetCurrent().Add(actor);
-
- // Register a float property
- float startValue(10.0f);
- Property::Index index = actor.RegisterProperty( "test-property", startValue );
- DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
-
- // Build the animation
- float durationSeconds(10.0f);
- Animation animation = Animation::New(durationSeconds);
- float targetPosition(0.0f);
- AnimateFloatTestFunctor func( 100, targetPosition );
- animation.Animate<float>( Property(actor, index), func );
-
- // Start the animation
- animation.Play();
-
- bool signalReceived(false);
- AnimationFinishCheck finishCheck(signalReceived);
- animation.FinishedSignal().Connect(&application, finishCheck);
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
-
- // We didn't expect the animation to finish yet
- application.SendNotification();
- finishCheck.CheckSignalNotReceived();
- DALI_TEST_EQUALS( actor.GetProperty<float>(index), 75.0f, TEST_LOCATION );
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
-
- // We didn't expect the animation to finish yet
- application.SendNotification();
- finishCheck.CheckSignalNotReceived();
- DALI_TEST_EQUALS( actor.GetProperty<float>(index), 50.0f, TEST_LOCATION );
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
-
- // We didn't expect the animation to finish yet
- application.SendNotification();
- finishCheck.CheckSignalNotReceived();
- DALI_TEST_EQUALS( actor.GetProperty<float>(index), 25.0f, TEST_LOCATION );
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
-
- // We did expect the animation to finish
- application.SendNotification();
- finishCheck.CheckSignalReceived();
- DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetPosition, TEST_LOCATION );
- END_TEST;
-}
-
-int UtcDaliAnimationAnimateInteger(void)
-{
- TestApplication application;
-
- Actor actor = Actor::New();
- Stage::GetCurrent().Add(actor);
-
- // Register an integer property
- int startValue(10);
- Property::Index index = actor.RegisterProperty( "test-property", startValue );
- DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
-
- // Build the animation
- float durationSeconds(10.0f);
- Animation animation = Animation::New(durationSeconds);
- int targetPosition(0);
- AnimateIntegerTestFunctor func( 100, targetPosition );
- animation.Animate<int>( Property(actor, index), func );
-
- // Start the animation
- animation.Play();
-
- bool signalReceived(false);
- AnimationFinishCheck finishCheck(signalReceived);
- animation.FinishedSignal().Connect(&application, finishCheck);
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
-
- // We didn't expect the animation to finish yet
- application.SendNotification();
- finishCheck.CheckSignalNotReceived();
- DALI_TEST_EQUALS( actor.GetProperty<int>(index), 75, TEST_LOCATION );
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
-
- // We didn't expect the animation to finish yet
- application.SendNotification();
- finishCheck.CheckSignalNotReceived();
- DALI_TEST_EQUALS( actor.GetProperty<int>(index), 50, TEST_LOCATION );
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
-
- // We didn't expect the animation to finish yet
- application.SendNotification();
- finishCheck.CheckSignalNotReceived();
- DALI_TEST_EQUALS( actor.GetProperty<int>(index), 25, TEST_LOCATION );
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
-
- // We did expect the animation to finish
- application.SendNotification();
- finishCheck.CheckSignalReceived();
- DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetPosition, TEST_LOCATION );
- END_TEST;
-}
-
-int UtcDaliAnimationAnimateVector2(void)
-{
- TestApplication application;
-
- Actor actor = Actor::New();
- Stage::GetCurrent().Add(actor);
-
- // Register a Vector2 property
- Vector2 startValue(10.0f, 10.0f);
- Property::Index index = actor.RegisterProperty( "test-property", startValue );
- DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
-
- // Build the animation
- float durationSeconds(10.0f);
- Animation animation = Animation::New(durationSeconds);
- Vector2 targetPosition(0.0f, 0.0f);
- AnimateVector2TestFunctor func( Vector2(100,100), targetPosition );
- animation.Animate<Vector2>( Property(actor, index), func );
-
- // Start the animation
- animation.Play();
-
- bool signalReceived(false);
- AnimationFinishCheck finishCheck(signalReceived);
- animation.FinishedSignal().Connect(&application, finishCheck);
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
-
- // We didn't expect the animation to finish yet
- application.SendNotification();
- finishCheck.CheckSignalNotReceived();
- DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), Vector2(75,75), TEST_LOCATION );
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
-
- // We didn't expect the animation to finish yet
- application.SendNotification();
- finishCheck.CheckSignalNotReceived();
- DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), Vector2(50,50), TEST_LOCATION );
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
-
- // We didn't expect the animation to finish yet
- application.SendNotification();
- finishCheck.CheckSignalNotReceived();
- DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), Vector2(25,25), TEST_LOCATION );
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
-
- // We did expect the animation to finish
- application.SendNotification();
- finishCheck.CheckSignalReceived();
- DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetPosition, TEST_LOCATION );
- END_TEST;
-}
-
-int UtcDaliAnimationAnimateVector3(void)
-{
- TestApplication application;
-
- Actor actor = Actor::New();
- Vector3 initialPosition(Vector3::ZERO);
- DALI_TEST_EQUALS( actor.GetCurrentPosition(), initialPosition, TEST_LOCATION );
- Stage::GetCurrent().Add(actor);
-
- // Build the animation
- float durationSeconds(10.0f);
- Animation animation = Animation::New(durationSeconds);
- Vector3 targetPosition(200.0f, 200.0f, 200.0f);
- BounceFunc func(0.0f, 0.0f, -100.0f);
- animation.Animate<Vector3>( Property(actor, Actor::POSITION), func, AlphaFunctions::Linear, durationSeconds );
-
- // Start the animation
- animation.Play();
-
- bool signalReceived(false);
- AnimationFinishCheck finishCheck(signalReceived);
- animation.FinishedSignal().Connect(&application, finishCheck);
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
-
- // We didn't expect the animation to finish yet
- application.SendNotification();
- finishCheck.CheckSignalNotReceived();
- DALI_TEST_EQUALS( actor.GetCurrentPosition(), func(0.25f, initialPosition), TEST_LOCATION );
+ animation.ColorTo(actor, targetColor, AlphaFunctions::Linear, 0, animatorDuration);
+ animation.FinishedSignal().Connect(&application, finishCheck);
+ animation.Play();
application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
+ application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% animation progress, 20% animator progress */);
// We didn't expect the animation to finish yet
application.SendNotification();
finishCheck.CheckSignalNotReceived();
- DALI_TEST_EQUALS( actor.GetCurrentPosition(), func(0.5f, initialPosition), TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetCurrentColor(), twentyPercentProgress, TEST_LOCATION );
application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
+ application.Render(static_cast<unsigned int>(durationSeconds*400.0f)/* 50% animation progress, 100% animator progress */);
// We didn't expect the animation to finish yet
application.SendNotification();
finishCheck.CheckSignalNotReceived();
- DALI_TEST_EQUALS( actor.GetCurrentPosition(), func(0.75f, initialPosition), TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION );
application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
+ application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
// We did expect the animation to finish
application.SendNotification();
finishCheck.CheckSignalReceived();
- DALI_TEST_EQUALS( actor.GetCurrentPosition(), initialPosition, TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION );
END_TEST;
}
-int UtcDaliAnimationAnimateVector4(void)
+int UtcDaliAnimationResize(void)
{
TestApplication application;
Actor actor = Actor::New();
Stage::GetCurrent().Add(actor);
-
- // Register a Vector4 property
- Vector4 startValue(10.0f, 10.0f, 10.0f, 10.0f);
- Property::Index index = actor.RegisterProperty( "test-property", startValue );
- DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
// Build the animation
- float durationSeconds(10.0f);
+ float durationSeconds(1.0f);
Animation animation = Animation::New(durationSeconds);
- Vector4 targetPosition(200,400,0,-1000);
- AnimateVector4TestFunctor func( Vector4(1000,1000,1000,1000), targetPosition );
- animation.Animate<Vector4>( Property(actor, index), func );
+ Vector3 targetSize(100.0f, 100.0f, 100.0f);
+ animation.Resize(actor, targetSize);
+
+ Vector3 ninetyNinePercentProgress(targetSize * 0.99f);
// Start the animation
animation.Play();
animation.FinishedSignal().Connect(&application, finishCheck);
application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
-
- // We didn't expect the animation to finish yet
- application.SendNotification();
- finishCheck.CheckSignalNotReceived();
- DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), Vector4(800,850,750,500), TEST_LOCATION );
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
-
- // We didn't expect the animation to finish yet
- application.SendNotification();
- finishCheck.CheckSignalNotReceived();
- DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), Vector4(600,700,500,0), TEST_LOCATION );
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
+ application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
// We didn't expect the animation to finish yet
application.SendNotification();
finishCheck.CheckSignalNotReceived();
- DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), Vector4(400,550,250,-500), TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetCurrentSize(), ninetyNinePercentProgress, TEST_LOCATION );
application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
+ application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
// We did expect the animation to finish
application.SendNotification();
finishCheck.CheckSignalReceived();
- DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetPosition, TEST_LOCATION );
- END_TEST;
-}
-
-int UtcDaliAnimationAnimateQuaternion(void)
-{
- TestApplication application;
-
- Actor actor = Actor::New();
- actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
- Stage::GetCurrent().Add(actor);
- DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
-
- // Build the animation
- float durationSeconds(1.0f);
- Animation animation = Animation::New(durationSeconds);
-
- Degree sourceRotationDegrees(90.0f);
- Radian sourceRotationRadians(sourceRotationDegrees);
- Quaternion sourceRotation(sourceRotationRadians, Vector3::YAXIS);
-
- Degree targetRotationDegrees(150.0f);
- Radian targetRotationRadians(targetRotationDegrees);
- Quaternion targetRotation(targetRotationRadians, Vector3::YAXIS);
-
- AnimateQuaternionTestFunctor func( sourceRotation, targetRotation );
- animation.Animate<Quaternion>( Property(actor, Actor::ROTATION), func );
+ DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION );
- // Start the animation
- animation.Play();
+ // Reset everything
+ finishCheck.Reset();
+ actor.SetSize(Vector3::ZERO);
+ application.SendNotification();
+ application.Render(0);
+ DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
- bool signalReceived(false);
- AnimationFinishCheck finishCheck(signalReceived);
+ // Repeat with a different (ease-in) alpha function
+ animation = Animation::New(durationSeconds);
+ animation.Resize(actor, targetSize, AlphaFunctions::EaseIn);
animation.FinishedSignal().Connect(&application, finishCheck);
+ animation.Play();
application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
+ application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
// We didn't expect the animation to finish yet
application.SendNotification();
finishCheck.CheckSignalNotReceived();
- DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(Radian(Degree(105)), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
+
+ // The size should have travelled less, than with a linear alpha function
+ Vector3 current(actor.GetCurrentSize());
+ DALI_TEST_CHECK( current.x > 0.0f );
+ DALI_TEST_CHECK( current.y > 0.0f );
+ DALI_TEST_CHECK( current.z > 0.0f );
+ DALI_TEST_CHECK( current.x < ninetyNinePercentProgress.x );
+ DALI_TEST_CHECK( current.y < ninetyNinePercentProgress.y );
+ DALI_TEST_CHECK( current.z < ninetyNinePercentProgress.z );
application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
+ application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
- // We didn't expect the animation to finish yet
+ // We did expect the animation to finish
application.SendNotification();
- finishCheck.CheckSignalNotReceived();
- DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(Radian(Degree(120)), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
+ finishCheck.CheckSignalReceived();
+ DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION );
+ // Reset everything
+ finishCheck.Reset();
+ actor.SetSize(Vector3::ZERO);
application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
+ application.Render(0);
+ DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
+
+ // Repeat with a delay
+ float delay = 0.5f;
+ animation = Animation::New(durationSeconds);
+ animation.Resize(actor, targetSize, AlphaFunctions::Linear, delay, durationSeconds - delay);
+ animation.FinishedSignal().Connect(&application, finishCheck);
+ animation.Play();
+
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
// We didn't expect the animation to finish yet
application.SendNotification();
finishCheck.CheckSignalNotReceived();
- DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(Radian(Degree(135)), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
+ application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
// We did expect the animation to finish
application.SendNotification();
finishCheck.CheckSignalReceived();
- DALI_TEST_EQUALS( actor.GetCurrentRotation(), targetRotation, ROTATION_EPSILON, TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION );
END_TEST;
}
END_TEST;
}
-int UtcDaliAnimationAnimateVector3Func(void)
-{
- TestApplication application;
-
- Actor actor = Actor::New();
- Vector3 initialPosition(Vector3::ZERO);
- DALI_TEST_EQUALS( actor.GetCurrentPosition(), initialPosition, TEST_LOCATION );
- Stage::GetCurrent().Add(actor);
-
- // Build the animation
- float durationSeconds(10.0f);
- Animation animation = Animation::New(durationSeconds);
- Vector3 targetPosition(200.0f, 200.0f, 200.0f);
- BounceFunc func(0.0f, 0.0f, -100.0f);
- animation.Animate<Vector3>( Property(actor, Actor::POSITION), func, AlphaFunctions::Linear );
-
- // Start the animation
- animation.Play();
-
- bool signalReceived(false);
- AnimationFinishCheck finishCheck(signalReceived);
- animation.FinishedSignal().Connect(&application, finishCheck);
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
-
- // We didn't expect the animation to finish yet
- application.SendNotification();
- finishCheck.CheckSignalNotReceived();
- DALI_TEST_EQUALS( actor.GetCurrentPosition(), func(0.25f, initialPosition), TEST_LOCATION );
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
-
- // We didn't expect the animation to finish yet
- application.SendNotification();
- finishCheck.CheckSignalNotReceived();
- DALI_TEST_EQUALS( actor.GetCurrentPosition(), func(0.5f, initialPosition), TEST_LOCATION );
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
-
- // We didn't expect the animation to finish yet
- application.SendNotification();
- finishCheck.CheckSignalNotReceived();
- DALI_TEST_EQUALS( actor.GetCurrentPosition(), func(0.75f, initialPosition), TEST_LOCATION );
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
-
- // We did expect the animation to finish
- application.SendNotification();
- finishCheck.CheckSignalReceived();
- DALI_TEST_EQUALS( actor.GetCurrentPosition(), initialPosition, TEST_LOCATION );
- END_TEST;
-}
-
int UtcDaliAnimationCreateDestroy(void)
{
TestApplication application;
actor.ApplyConstraint( constraint );
// Apply animation to actor
- BounceFunc func(0.0f, 0.0f, -100.0f);
- animation.Animate<Vector3>( Property(actor, Actor::POSITION), func, AlphaFunctions::Linear );
+ animation.AnimateTo( Property(actor, Actor::POSITION), Vector3( 100.f, 90.f, 80.f ), AlphaFunctions::Linear );
animation.Play();
END_TEST;
}
+
+int UtcDaliAnimationExtendDuration(void)
+{
+ TestApplication application;
+
+ Actor actor = Actor::New();
+
+ // Register a float property
+ float startValue(10.0f);
+ Property::Index index = actor.RegisterProperty( "test-property", startValue );
+ Stage::GetCurrent().Add(actor);
+ DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
+
+ // Build the animation
+ float initialDurationSeconds(1.0f);
+ float animatorDelay = 5.0f;
+ float animatorDurationSeconds(5.0f);
+ float extendedDurationSeconds(animatorDelay+animatorDurationSeconds);
+ Animation animation = Animation::New(initialDurationSeconds);
+ float targetValue(30.0f);
+ float relativeValue(targetValue - startValue);
+
+ animation.AnimateTo(Property(actor, index),
+ targetValue,
+ TimePeriod(animatorDelay, animatorDurationSeconds));
+
+ // The duration should have been extended
+ DALI_TEST_EQUALS( animation.GetDuration(), extendedDurationSeconds, TEST_LOCATION );
+
+ // Start the animation
+ animation.Play();
+
+ bool signalReceived(false);
+ AnimationFinishCheck finishCheck(signalReceived);
+ animation.FinishedSignal().Connect(&application, finishCheck);
+
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(extendedDurationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
+
+ // We didn't expect the animation to finish yet
+ application.SendNotification();
+ finishCheck.CheckSignalNotReceived();
+ DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
+
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(extendedDurationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
+
+ // We didn't expect the animation to finish yet
+ application.SendNotification();
+ finishCheck.CheckSignalNotReceived();
+ DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
+
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(extendedDurationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
+
+ // We did expect the animation to finish
+ application.SendNotification();
+ finishCheck.CheckSignalReceived();
+ DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
+ END_TEST;
+}
+
+int UtcDaliAnimationPath(void)
+{
+ TestApplication application;
+
+ Actor actor = Actor::New();
+ Stage::GetCurrent().Add(actor);
+
+ //Build the path
+ Vector3 position0( 30.0, 80.0, 0.0);
+ Vector3 position1( 70.0, 120.0, 0.0);
+ Vector3 position2( 100.0, 100.0, 0.0);
+
+ Dali::Path path = Dali::Path::New();
+ path.AddPoint(position0);
+ path.AddPoint(position1);
+ path.AddPoint(position2);
+
+ //Control points for first segment
+ path.AddControlPoint( Vector3( 39.0, 90.0, 0.0) );
+ path.AddControlPoint(Vector3( 56.0, 119.0, 0.0) );
+
+ //Control points for second segment
+ path.AddControlPoint(Vector3( 78.0, 120.0, 0.0));
+ path.AddControlPoint(Vector3( 93.0, 104.0, 0.0));
+
+ // Build the animation
+ float durationSeconds( 1.0f );
+ Animation animation = Animation::New(durationSeconds);
+ animation.Animate(actor, path, Vector3::XAXIS, AlphaFunctions::Linear, TimePeriod(0.0f, 1.0f ));
+
+ // Start the animation
+ animation.Play();
+
+ bool signalReceived(false);
+ AnimationFinishCheck finishCheck(signalReceived);
+ animation.FinishedSignal().Connect(&application, finishCheck);
+ application.SendNotification();
+ application.Render(0);
+ application.SendNotification();
+ finishCheck.CheckSignalNotReceived();
+ Vector3 position, tangent;
+ Quaternion rotation;
+ path.Sample( 0.0f, position, tangent );
+ rotation = Quaternion( Vector3::XAXIS, tangent );
+ DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetCurrentRotation(), rotation, TEST_LOCATION );
+
+ application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
+ application.SendNotification();
+ path.Sample( 0.25f, position, tangent );
+ rotation = Quaternion( Vector3::XAXIS, tangent );
+ DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetCurrentRotation(), rotation, TEST_LOCATION );
+
+ application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
+ application.SendNotification();
+ path.Sample( 0.5f, position, tangent );
+ rotation = Quaternion( Vector3::XAXIS, tangent );
+ DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetCurrentRotation(), rotation, TEST_LOCATION );
+
+ application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
+ application.SendNotification();
+ path.Sample( 0.75f, position, tangent );
+ rotation = Quaternion( Vector3::XAXIS, tangent );
+ DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetCurrentRotation(), rotation, TEST_LOCATION );
+
+ application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
+ application.SendNotification();
+ path.Sample( 1.0f, position, tangent );
+ rotation = Quaternion( Vector3::XAXIS, tangent );
+ DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetCurrentRotation(), rotation, TEST_LOCATION );
+
+ finishCheck.CheckSignalReceived();
+ END_TEST;
+}