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)
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;
END_TEST;
}
-int UtcDaliAnimationAnimateBool(void)
+int UtcDaliKeyFramesCreateDestroy(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 */);
+ tet_infoline("Testing Dali::Animation::UtcDaliKeyFramesCreateDestroy()");
- // We didn't expect the animation to finish yet
- application.SendNotification();
- finishCheck.CheckSignalNotReceived();
+ KeyFrames* keyFrames = new KeyFrames;
+ delete keyFrames;
+ DALI_TEST_CHECK( true );
+ END_TEST;
+}
- // Should still be visible
- DALI_TEST_EQUALS( actor.IsVisible(), true, TEST_LOCATION );
+int UtcDaliKeyFramesDownCast(void)
+{
+ TestApplication application;
+ tet_infoline("Testing Dali::Animation::KeyFramesDownCast()");
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
+ KeyFrames keyFrames = KeyFrames::New();
+ BaseHandle object(keyFrames);
- // We didn't expect the animation to finish yet
- application.SendNotification();
- finishCheck.CheckSignalNotReceived();
+ KeyFrames keyFrames2 = KeyFrames::DownCast(object);
+ DALI_TEST_CHECK(keyFrames2);
- // Now animate functor should have hidden the actor
- DALI_TEST_EQUALS( actor.IsVisible(), false, TEST_LOCATION );
+ KeyFrames keyFrames3 = DownCast< KeyFrames >(object);
+ DALI_TEST_CHECK(keyFrames3);
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
+ BaseHandle unInitializedObject;
+ KeyFrames keyFrames4 = KeyFrames::DownCast(unInitializedObject);
+ DALI_TEST_CHECK(!keyFrames4);
- // We did expect the animation to finish
- application.SendNotification();
- finishCheck.CheckSignalReceived();
- DALI_TEST_EQUALS( actor.IsVisible(), false, TEST_LOCATION );
+ KeyFrames keyFrames5 = DownCast< KeyFrames >(unInitializedObject);
+ DALI_TEST_CHECK(!keyFrames5);
END_TEST;
}
-int UtcDaliAnimationAnimateFloat(void)
+int UtcDaliAnimationResizeByXY(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 );
+ 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);
- float targetPosition(0.0f);
- AnimateFloatTestFunctor func( 100, targetPosition );
- animation.Animate<float>( 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 */);
+ 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<float>(index), 75.0f, TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetCurrentSize(), ninetyNinePercentProgress, TEST_LOCATION );
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.GetProperty<float>(index), 50.0f, 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 );
- // 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 );
-
- 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 UtcDaliAnimationAnimateVector4(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 );
-
- // Build the animation
- float durationSeconds(10.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 );
-
- // 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<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 */);
-
- // 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 );
-
- 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<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 );
-
- // 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(), Quaternion(Radian(Degree(105)), Vector3::YAXIS), 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(), Quaternion(Radian(Degree(120)), Vector3::YAXIS), 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(), Quaternion(Radian(Degree(135)), Vector3::YAXIS), 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(), targetRotation, ROTATION_EPSILON, TEST_LOCATION );
- END_TEST;
-}
-
-int UtcDaliKeyFramesCreateDestroy(void)
-{
- tet_infoline("Testing Dali::Animation::UtcDaliKeyFramesCreateDestroy()");
-
- KeyFrames* keyFrames = new KeyFrames;
- delete keyFrames;
- DALI_TEST_CHECK( true );
- END_TEST;
-}
-
-int UtcDaliKeyFramesDownCast(void)
-{
- TestApplication application;
- tet_infoline("Testing Dali::Animation::KeyFramesDownCast()");
-
- KeyFrames keyFrames = KeyFrames::New();
- BaseHandle object(keyFrames);
-
- KeyFrames keyFrames2 = KeyFrames::DownCast(object);
- DALI_TEST_CHECK(keyFrames2);
-
- KeyFrames keyFrames3 = DownCast< KeyFrames >(object);
- DALI_TEST_CHECK(keyFrames3);
-
- BaseHandle unInitializedObject;
- KeyFrames keyFrames4 = KeyFrames::DownCast(unInitializedObject);
- DALI_TEST_CHECK(!keyFrames4);
-
- KeyFrames keyFrames5 = DownCast< KeyFrames >(unInitializedObject);
- DALI_TEST_CHECK(!keyFrames5);
- END_TEST;
-}
-
-int UtcDaliAnimationResizeByXY(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.x, targetSize.y, AlphaFunctions::EaseIn);
- animation.FinishedSignal().Connect(&application, finishCheck);
- animation.Play();
+ // Repeat with a different (ease-in) alpha function
+ animation = Animation::New(durationSeconds);
+ animation.Resize(actor, targetSize.x, targetSize.y, AlphaFunctions::EaseIn);
+ animation.FinishedSignal().Connect(&application, finishCheck);
+ animation.Play();
application.SendNotification();
application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
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();
*
*/
-// EXTERNAL INCLUDES
-#include <boost/function.hpp>
-
// INTERNAL INCLUDES
#include <dali/public-api/animation/alpha-functions.h>
#include <dali/public-api/animation/key-frames.h>
struct Vector3;
struct Vector4;
-typedef boost::function<bool (float alpha, const bool& current)> AnimatorFunctionBool; ///< Animator function signature for boolean properties.
-typedef boost::function<float (float alpha, const float& current)> AnimatorFunctionFloat; ///< Animator function signature for float properties.
-typedef boost::function<int (float alpha, const int& current)> AnimatorFunctionInteger; ///< Animator function signature for integer properties.
-typedef boost::function<Vector2 (float alpha, const Vector2& current)> AnimatorFunctionVector2; ///< Animator function signature for Vector2 properties.
-typedef boost::function<Vector3 (float alpha, const Vector3& current)> AnimatorFunctionVector3; ///< Animator function signature for Vector3 properties.
-typedef boost::function<Vector4 (float alpha, const Vector4& current)> AnimatorFunctionVector4; ///< Animator function signature for Vector4 properties.
-typedef boost::function<Quaternion (float alpha, const Quaternion& current)> AnimatorFunctionQuaternion;///< Animator function signature for Quaternion properties.
-
namespace Internal DALI_INTERNAL
{
class Animation;
typedef SignalV2< void (Animation&) > AnimationSignalV2; ///< Animation finished signal type
typedef Any AnyFunction; ///< Interpolation function
- typedef boost::function<Vector3 (float alpha, const Vector3& current)> Vector3AnimatorFunc; ///< Interpolation function
- typedef boost::function<Quaternion (float alpha, const Quaternion& current)> QuaternionAnimatorFunc; ///< Interpolation function
/**
* @brief What to do when the animation ends, is stopped or is destroyed
*/
void AnimateBetween(Property target, KeyFrames& keyFrames, AlphaFunction alpha, TimePeriod period);
- /**
- * @brief Animate a property using a custom function.
- *
- * The function will be called from a separate animation-thread; it should return quickly, to avoid performance degredation.
- * @pre The property type is equal PropertyTypes::Get<P>().
- * @param [in] target The target object/property to animate.
- * @param [in] animatorFunc The function to call during the animation.
- */
- template <class P>
- void Animate( Property target, boost::function<P (float alpha, const P& current)> animatorFunc )
- {
- Animate( target, PropertyTypes::Get<P>(), animatorFunc );
- }
-
- /**
- * @brief Animate a property using a custom function.
- *
- * The function will be called from a separate animation-thread; it should return quickly, to avoid performance degredation.
- * @pre The property type is equal PropertyTypes::Get<P>().
- * @param [in] target The target object/property to animate.
- * @param [in] animatorFunc The function to call during the animation.
- * @param [in] alpha The alpha function to apply.
- */
- template <class P>
- void Animate( Property target, boost::function<P (float alpha, const P& current)> animatorFunc, AlphaFunction alpha )
- {
- Animate( target, PropertyTypes::Get<P>(), animatorFunc, alpha );
- }
-
- /**
- * @brief Animate a property using a custom function.
- *
- * The function will be called from a separate animation-thread; it should return quickly, to avoid performance degredation.
- * @pre The property type is equal PropertyTypes::Get<P>().
- * @param [in] target The target object/property to animate.
- * @param [in] animatorFunc The function to call during the animation.
- * @param [in] period The effect will occur during this time period.
- */
- template <class P>
- void Animate( Property target, boost::function<P (float alpha, const P& current)> animatorFunc, TimePeriod period )
- {
- Animate( target, PropertyTypes::Get<P>(), animatorFunc, period );
- }
-
- /**
- * @brief Animate a property using a custom function.
- *
- * The function will be called from a separate animation-thread; it should return quickly, to avoid performance degredation.
- * @pre The property type is equal PropertyTypes::Get<P>().
- * @param [in] target The target object/property to animate.
- * @param [in] animatorFunc The function to call during the animation.
- * @param [in] alpha The alpha function to apply.
- * @param [in] period The effect will occur during this time period.
- */
- template <class P>
- void Animate( Property target, boost::function<P (float alpha, const P& current)> animatorFunc, AlphaFunction alpha, TimePeriod period )
- {
- Animate( target, PropertyTypes::Get<P>(), animatorFunc, alpha, period );
- }
-
// Actor-specific convenience methods
/**
void MoveTo(Actor actor, Vector3 position, AlphaFunction alpha, float delaySeconds, float durationSeconds);
/**
- * @brief Move an actor using a custom function.
- *
- * The animatorFunc will be called from a separate animation-thread; it should return quickly, to avoid performance degredation.
- * @pre delaySeconds must be zero or greater.
- * @pre durationSeconds must be zero or greater; zero is useful when animating boolean values.
- * @param [in] actor The actor to animate.
- * @param [in] animatorFunc The function to call during the animation.
- * @param [in] alpha The alpha function to apply.
- * @param [in] delaySeconds The initial delay from the start of the animation.
- * @param [in] durationSeconds The duration of the translation.
- */
- void Move(Actor actor, AnimatorFunctionVector3 animatorFunc, AlphaFunction alpha, float delaySeconds, float durationSeconds);
-
- /**
* @brief Rotate an actor around an arbitrary axis.
*
* The default alpha function will be used.
void RotateTo(Actor actor, Quaternion orientation, AlphaFunction alpha, float delaySeconds, float durationSeconds);
/**
- * @brief Rotate an actor using a custom function.
- *
- * The animatorFunc will be called from a separate animation-thread; it should return quickly, to avoid performance degredation.
- * @pre delaySeconds must be zero or greater.
- * @pre durationSeconds must be zero or greater; zero is useful when animating boolean values.
- * @param [in] actor The actor to animate.
- * @param [in] animatorFunc The function to call during the animation.
- * @param [in] alpha The alpha function to apply.
- * @param [in] delaySeconds The initial delay from the start of the animation.
- * @param [in] durationSeconds The duration of the rotation.
- */
- void Rotate(Actor actor, AnimatorFunctionQuaternion animatorFunc, AlphaFunction alpha, float delaySeconds, float durationSeconds);
-
- /**
* @brief Scale an actor.
*
* The default alpha function will be used.
*/
explicit DALI_INTERNAL Animation(Internal::Animation* animation);
-private:
-
- /**
- * @brief Animate a property using a custom function.
- *
- * @pre The property type is equal expectedType.
- * @param [in] target The target object/property to animate.
- * @param [in] targetType The expected type of the property.
- * @param [in] func The function to call during the animation.
- */
- void Animate( Property target,
- Property::Type targetType,
- AnyFunction func );
-
- /**
- * @brief Animate a property using a custom function.
- *
- * @pre The property type is equal expectedType.
- * @param [in] target The target object/property to animate.
- * @param [in] targetType The expected type of the property.
- * @param [in] func The function to call during the animation.
- * @param [in] alpha The alpha function to apply.
- */
- void Animate( Property target,
- Property::Type targetType,
- AnyFunction func,
- AlphaFunction alpha );
-
- /**
- * @brief Animate a property using a custom function.
- *
- * @pre The property type is equal expectedType.
- * @param [in] target The target object/property to animate.
- * @param [in] targetType The expected type of the property.
- * @param [in] func The function to call during the animation.
- * @param [in] period The effect will occur during this time period.
- */
- void Animate( Property target,
- Property::Type targetType,
- AnyFunction func,
- TimePeriod period );
-
- /**
- * @brief Animate a property using a custom function.
- *
- * @pre The property type is equal expectedType.
- * @param [in] target The target object/property to animate.
- * @param [in] targetType The expected type of the property.
- * @param [in] func The function to call during the animation.
- * @param [in] alpha The alpha function to apply.
- * @param [in] period The effect will occur during this time period.
- */
- void Animate( Property target,
- Property::Type targetType,
- AnyFunction func,
- AlphaFunction alpha,
- TimePeriod period );
};
} // namespace Dali