X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=automated-tests%2Fsrc%2Fdali%2Futc-Dali-Animation.cpp;h=8e617ded82eb0ab04907a440ddba316cd7410ee6;hb=181787be13303d7a17ace569c4eba09d6aec1de3;hp=9bf8296953d6b82cff4dac7ed6cdfc830536e955;hpb=37263dd1185ea7ec62a15e5fcbbb1b8f2d69d784;p=platform%2Fcore%2Fuifw%2Fdali-core.git diff --git a/automated-tests/src/dali/utc-Dali-Animation.cpp b/automated-tests/src/dali/utc-Dali-Animation.cpp index 9bf8296..8e617de 100644 --- a/automated-tests/src/dali/utc-Dali-Animation.cpp +++ b/automated-tests/src/dali/utc-Dali-Animation.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * Copyright (c) 2016 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,17 +20,18 @@ #include #include +#include #include using std::max; using namespace Dali; -void utc_dali_animation_startup(void) +void utc_dali_animation_startuP(void) { test_return_value = TET_UNDEF; } -void utc_dali_animation_cleanup(void) +void utc_dali_animation_cleanuP(void) { test_return_value = TET_PASS; } @@ -88,195 +89,102 @@ struct AnimationFinishCheck 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; -}; +} // anon namespace -struct AnimateIntegerTestFunctor +int UtcDaliAnimationConstructorP(void) { - AnimateIntegerTestFunctor( int start, int end ) - : mStart( start ), - mEnd( end ) - { - } + TestApplication application; - int operator()( float alpha, const int& current ) - { - return static_cast( mStart + ((mEnd - mStart) * alpha ) + 0.5f ); - } + Animation animation; - int mStart; - int mEnd; -}; + DALI_TEST_CHECK( !animation ); + END_TEST; +} -struct AnimateVector2TestFunctor +int UtcDaliAnimationNewP(void) { - AnimateVector2TestFunctor( Vector2 start, Vector2 end ) - : mStart( start ), - mEnd( end ) - { - } + TestApplication application; - Vector2 operator()( float alpha, const Vector2& current ) - { - return mStart + ((mEnd - mStart) * alpha ); - } + Animation animation = Animation::New( 1.0f ); - Vector2 mStart; - Vector2 mEnd; -}; + DALI_TEST_CHECK(animation); + END_TEST; +} -struct AnimateVector4TestFunctor +int UtcDaliAnimationNewN(void) { - AnimateVector4TestFunctor( Vector4 start, Vector4 end ) - : mStart( start ), - mEnd( end ) - { - } + TestApplication application; - Vector4 operator()( float alpha, const Vector4& current ) - { - return mStart + ((mEnd - mStart) * alpha ); - } + Animation animation = Animation::New( -1.0f ); - Vector4 mStart; - Vector4 mEnd; -}; + DALI_TEST_CHECK(animation); + DALI_TEST_EQUALS(animation.GetDuration(), 0.0f, TEST_LOCATION); + END_TEST; +} -struct AnimateQuaternionTestFunctor +int UtcDaliAnimationDownCastP(void) { - AnimateQuaternionTestFunctor( Quaternion start, Quaternion end ) - : mStart( start ), - mEnd( end ) - { - } - - Quaternion operator()( float alpha, const Quaternion& current ) - { - return Quaternion::Slerp(mStart, mEnd, alpha); - } + TestApplication application; - Quaternion mStart; - Quaternion mEnd; -}; + tet_infoline("Testing Dali::Animation::DownCast()"); -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; -}; + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + BaseHandle object(animation); -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; -}; + Animation animation2 = Animation::DownCast(object); + DALI_TEST_CHECK(animation2); -} // anon namespace + Animation animation3 = DownCast< Animation >(object); + DALI_TEST_CHECK(animation3); + END_TEST; +} -int UtcDaliAnimationNew01(void) +int UtcDaliAnimationDownCastN(void) { TestApplication application; - Animation animation; - DALI_TEST_CHECK(!animation); + BaseHandle unInitializedObject; - animation = Animation::New(1.0f); + Animation animation1 = Animation::DownCast( unInitializedObject ); + DALI_TEST_CHECK( !animation1 ); - DALI_TEST_CHECK(animation); + Animation animation2 = DownCast< Animation >( unInitializedObject ); + DALI_TEST_CHECK( !animation2 ); END_TEST; } -int UtcDaliAnimationNew02(void) +int UtcDaliAnimationCopyConstructorP(void) { TestApplication application; - Animation animation; - DALI_TEST_CHECK(!animation); - try - { - animation = Animation::New(0.0f); - } - catch (Dali::DaliException& e) - { - // TODO: Determine why catch doesn't. - // + // Initialize an object, ref count == 1 + Animation animation = Animation::New( 1.0f ); - // 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); - } + Animation copy( animation ); + DALI_TEST_CHECK( copy ); + + DALI_TEST_CHECK( copy.GetDuration() == animation.GetDuration() ); END_TEST; } -int UtcDaliAnimationDownCast(void) +int UtcDaliAnimationAssignmentOperatorP(void) { TestApplication application; - tet_infoline("Testing Dali::Animation::DownCast()"); - - float durationSeconds(1.0f); - Animation animation = Animation::New(durationSeconds); - - BaseHandle object(animation); - Animation animation2 = Animation::DownCast(object); - DALI_TEST_CHECK(animation2); + Animation animation = Animation::New( 1.0f ); - Animation animation3 = DownCast< Animation >(object); - DALI_TEST_CHECK(animation3); + Animation copy = animation; + DALI_TEST_CHECK( copy ); - BaseHandle unInitializedObject; - Animation animation4 = Animation::DownCast(unInitializedObject); - DALI_TEST_CHECK(!animation4); + DALI_TEST_CHECK( animation == copy ); - Animation animation5 = DownCast< Animation >(unInitializedObject); - DALI_TEST_CHECK(!animation5); + DALI_TEST_CHECK( copy.GetDuration() == animation.GetDuration() ); END_TEST; } -int UtcDaliAnimationSetDuration(void) +int UtcDaliAnimationSetDurationP(void) { TestApplication application; @@ -290,7 +198,7 @@ int UtcDaliAnimationSetDuration(void) // Start the animation Vector3 targetPosition(10.0f, 10.0f, 10.0f); - animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear); + animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR); animation.Play(); bool signalReceived(false); @@ -341,7 +249,19 @@ int UtcDaliAnimationSetDuration(void) END_TEST; } -int UtcDaliAnimationGetDuration(void) +int UtcDaliAnimationSetDurationN(void) +{ + TestApplication application; + + Animation animation = Animation::New( 1.0f ); + DALI_TEST_EQUALS( animation.GetDuration(), 1.0f, TEST_LOCATION ); + + animation.SetDuration( -1.0f ); + DALI_TEST_EQUALS( animation.GetDuration(), 0.0f, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliAnimationGetDurationP(void) { TestApplication application; @@ -353,7 +273,7 @@ int UtcDaliAnimationGetDuration(void) END_TEST; } -int UtcDaliAnimationSetLooping(void) +int UtcDaliAnimationSetLoopingP(void) { TestApplication application; @@ -364,7 +284,7 @@ int UtcDaliAnimationSetLooping(void) float durationSeconds(1.0f); Animation animation = Animation::New(durationSeconds); Vector3 targetPosition(10.0f, 10.0f, 10.0f); - animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear); + animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR); // Start the animation animation.SetLooping(true); @@ -417,19 +337,7 @@ int UtcDaliAnimationSetLooping(void) END_TEST; } -int UtcDaliAnimationIsLooping(void) -{ - TestApplication application; - - Animation animation = Animation::New(1.0f); - DALI_TEST_CHECK(!animation.IsLooping()); - - animation.SetLooping(true); - DALI_TEST_CHECK(animation.IsLooping()); - END_TEST; -} - -int UtcDaliAnimationSetEndAction(void) +int UtcDaliAnimationSetLoopCountP(void) { TestApplication application; @@ -439,141 +347,72 @@ int UtcDaliAnimationSetEndAction(void) // Build the animation float durationSeconds(1.0f); Animation animation = Animation::New(durationSeconds); - DALI_TEST_CHECK(animation.GetEndAction() == Animation::Bake); - Vector3 targetPosition(10.0f, 10.0f, 10.0f); - animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear); + animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR); // Start the animation + animation.SetLoopCount(3); + DALI_TEST_CHECK(animation.IsLooping()); animation.Play(); bool signalReceived(false); AnimationFinishCheck finishCheck(signalReceived); animation.FinishedSignal().Connect(&application, finishCheck); + application.Render(0); application.SendNotification(); - application.Render(static_cast(durationSeconds*1000.0f) + 1u/*just beyond the animation duration*/); - - // We did expect the animation to finish + application.Render(0); application.SendNotification(); - finishCheck.CheckSignalReceived(); - DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION ); - - // Go back to the start - actor.SetPosition(Vector3::ZERO); + application.Render(0); application.SendNotification(); application.Render(0); - DALI_TEST_EQUALS( Vector3::ZERO, actor.GetCurrentPosition(), TEST_LOCATION ); - - // Test BakeFinal, animate again, for half the duration - finishCheck.Reset(); - animation.SetEndAction(Animation::BakeFinal); - DALI_TEST_CHECK(animation.GetEndAction() == Animation::BakeFinal); - animation.Play(); - application.SendNotification(); - application.Render(static_cast(durationSeconds*1000.0f*0.5f) /*half of the animation duration*/); - // Stop the animation early - animation.Stop(); + // Loop + float intervalSeconds = 3.0f; - // We did NOT expect the animation to finish - application.SendNotification(); - finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( targetPosition * 0.5f, actor.GetCurrentPosition(), VECTOR4_EPSILON, TEST_LOCATION ); + application.Render(static_cast(durationSeconds*intervalSeconds*1000.0f)); + application.Render(static_cast(durationSeconds*intervalSeconds*1000.0f)); - // Go back to the start - actor.SetPosition(Vector3::ZERO); - application.SendNotification(); application.Render(0); - DALI_TEST_EQUALS( Vector3::ZERO, actor.GetCurrentPosition(), TEST_LOCATION ); - - // Test EndAction::Discard, animate again, but don't bake this time - finishCheck.Reset(); - animation.SetEndAction(Animation::Discard); - DALI_TEST_CHECK(animation.GetEndAction() == Animation::Discard); - animation.Play(); - application.SendNotification(); - application.Render(static_cast(durationSeconds*1000.0f) + 1u/*just beyond the animation duration*/); - - // We did expect the animation to finish - application.SendNotification(); - finishCheck.CheckSignalReceived(); - DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION ); - - // The position should be discarded in the next frame application.Render(0); - DALI_TEST_EQUALS( Vector3::ZERO/*discarded*/, actor.GetCurrentPosition(), TEST_LOCATION ); - - // Check that nothing has changed after a couple of buffer swaps + application.SendNotification(); application.Render(0); - DALI_TEST_EQUALS( Vector3::ZERO, actor.GetCurrentPosition(), TEST_LOCATION ); + application.SendNotification(); application.Render(0); - DALI_TEST_EQUALS( Vector3::ZERO, actor.GetCurrentPosition(), TEST_LOCATION ); - END_TEST; -} - -int UtcDaliAnimationGetEndAction(void) -{ - TestApplication application; - - Animation animation = Animation::New(1.0f); - DALI_TEST_CHECK(animation.GetEndAction() == Animation::Bake); - - animation.SetEndAction(Animation::Discard); - DALI_TEST_CHECK(animation.GetEndAction() == Animation::Discard); - - animation.SetEndAction(Animation::BakeFinal); - DALI_TEST_CHECK(animation.GetEndAction() == Animation::BakeFinal); - - END_TEST; -} - -int UtcDaliAnimationGetDestroyAction(void) -{ - TestApplication application; - Animation animation = Animation::New(1.0f); - DALI_TEST_CHECK(animation.GetDestroyAction() == Animation::Bake); // default! + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); - animation.SetDestroyAction(Animation::Discard); - DALI_TEST_CHECK(animation.GetDestroyAction() == Animation::Discard); + application.Render(static_cast(durationSeconds*intervalSeconds*1000.0f)); - animation.SetDestroyAction(Animation::BakeFinal); - DALI_TEST_CHECK(animation.GetDestroyAction() == Animation::BakeFinal); + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION ); - END_TEST; -} + finishCheck.Reset(); -int UtcDaliAnimationSetDefaultAlphaFunction(void) -{ - TestApplication application; + application.Render(static_cast(durationSeconds*intervalSeconds*1000.0f)); + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); - Animation animation = Animation::New(1.0f); - AlphaFunction func = animation.GetDefaultAlphaFunction(); - DALI_TEST_EQUALS(func(0.1f), AlphaFunctions::Linear(0.1f), TEST_LOCATION); + application.Render(static_cast(durationSeconds*intervalSeconds*1000.0f)); + application.Render(static_cast(durationSeconds*intervalSeconds*1000.0f)); + application.Render(static_cast(durationSeconds*intervalSeconds*1000.0f)); + application.Render(static_cast(durationSeconds*intervalSeconds*1000.0f)); + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); - animation.SetDefaultAlphaFunction(AlphaFunctions::EaseIn); - AlphaFunction func2 = animation.GetDefaultAlphaFunction(); - DALI_TEST_CHECK(func2(0.1f) < AlphaFunctions::Linear(0.1f)); // less progress when easing-in END_TEST; } -int UtcDaliAnimationGetDefaultAlphaFunction(void) +int UtcDaliAnimationSetLoopCountP2(void) { TestApplication application; - Animation animation = Animation::New(1.0f); - AlphaFunction func = animation.GetDefaultAlphaFunction(); - - // Test that the default is linear - DALI_TEST_EQUALS(func(0.1f), AlphaFunctions::Linear(0.1f), TEST_LOCATION); - END_TEST; -} - -int UtcDaliAnimationPlay(void) -{ - TestApplication application; + // + // switching between forever and loop count + // Actor actor = Actor::New(); Stage::GetCurrent().Add(actor); @@ -581,263 +420,365 @@ int UtcDaliAnimationPlay(void) // 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); + Vector3 targetPosition(10.0f, 10.0f, 10.0f); + animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR); + animation.SetEndAction(Animation::Discard); // Start the animation + animation.SetLoopCount(3); + DALI_TEST_CHECK(animation.IsLooping()); animation.Play(); bool signalReceived(false); AnimationFinishCheck finishCheck(signalReceived); animation.FinishedSignal().Connect(&application, finishCheck); - application.SendNotification(); - application.Render(static_cast(durationSeconds*200.0f)/* 20% progress */); + float intervalSeconds = 3.0f; - // We didn't expect the animation to finish yet application.SendNotification(); - finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION ); - - animation.Play(); // Test that calling play has no effect, when animation is already playing + application.Render(static_cast(durationSeconds*intervalSeconds*1000.0f)); application.SendNotification(); - application.Render(static_cast(durationSeconds*200.0f)/* 40% progress */); - - // We didn't expect the animation to finish yet + application.Render(static_cast(durationSeconds*intervalSeconds*1000.0f)); + application.SendNotification(); + application.Render(static_cast(durationSeconds*intervalSeconds*1000.0f)); application.SendNotification(); - finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.4f), TEST_LOCATION ); - animation.Play(); // Test that calling play has no effect, when animation is already playing application.SendNotification(); - application.Render(static_cast(durationSeconds*200.0f)/* 60% progress */); + finishCheck.CheckSignalReceived(); - // We didn't expect the animation to finish yet + finishCheck.Reset(); + + // Loop forever + animation.SetLooping(true); + DALI_TEST_CHECK(animation.IsLooping()); + + application.Render(static_cast(durationSeconds*intervalSeconds*1000.0f)); 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.Render(static_cast(durationSeconds*intervalSeconds*1000.0f)); + application.SendNotification(); + application.Render(static_cast(durationSeconds*intervalSeconds*1000.0f)); + application.SendNotification(); + application.Render(static_cast(durationSeconds*intervalSeconds*1000.0f)); + application.SendNotification(); + application.Render(static_cast(durationSeconds*intervalSeconds*1000.0f)); application.SendNotification(); - application.Render(static_cast(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 ); - animation.Play(); // Test that calling play has no effect, when animation is already playing - application.SendNotification(); - application.Render(static_cast(durationSeconds*200.0f) + 1u/*just beyond the animation duration*/); + finishCheck.Reset(); - // We did expect the animation to finish + // Loop N again + animation.SetLoopCount(3); + DALI_TEST_CHECK(animation.IsLooping()); + animation.Play(); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*intervalSeconds*1000.0f)); + application.SendNotification(); + application.Render(static_cast(durationSeconds*intervalSeconds*1000.0f)); + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + + application.Render(static_cast(durationSeconds*intervalSeconds*1000.0f)); 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 ); + finishCheck.Reset(); + + // loop forever + animation.SetLooping(true); + DALI_TEST_CHECK(animation.IsLooping()); + + application.Render(static_cast(durationSeconds*intervalSeconds*1000.0f)); + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + + application.Render(static_cast(durationSeconds*intervalSeconds*1000.0f)); + application.SendNotification(); + application.Render(static_cast(durationSeconds*intervalSeconds*1000.0f)); + application.SendNotification(); + application.Render(static_cast(durationSeconds*intervalSeconds*1000.0f)); + application.SendNotification(); + application.Render(static_cast(durationSeconds*intervalSeconds*1000.0f)); + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + + finishCheck.Reset(); + + // Loop N again + animation.SetLoopCount(3); + DALI_TEST_CHECK(animation.IsLooping()); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*intervalSeconds*1000.0f)); + application.SendNotification(); + application.Render(static_cast(durationSeconds*intervalSeconds*1000.0f)); + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + + application.Render(static_cast(durationSeconds*intervalSeconds*1000.0f)); + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); // we never hit play + + finishCheck.Reset(); + + END_TEST; } -int UtcDaliAnimationSetSpeedFactor(void) +int UtcDaliAnimationSetLoopCountP3(void) { TestApplication application; + // + // switching between forever and loop count + // Actor actor = Actor::New(); Stage::GetCurrent().Add(actor); // Build the animation float durationSeconds(1.0f); Animation animation = Animation::New(durationSeconds); + Vector3 targetPosition(10.0f, 10.0f, 10.0f); + animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR); + animation.SetEndAction(Animation::Discard); - 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(); + float intervalSeconds = 3.0f; bool signalReceived(false); AnimationFinishCheck finishCheck(signalReceived); animation.FinishedSignal().Connect(&application, finishCheck); - application.SendNotification(); - application.Render(static_cast(durationSeconds*200.0f)/* 40% progress */); + // loop forever + animation.SetLooping(true); + DALI_TEST_CHECK(animation.IsLooping()); - // We didn't expect the animation to finish yet + application.Render(static_cast(durationSeconds*intervalSeconds*1000.0f)); application.SendNotification(); finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.4f), TEST_LOCATION ); - application.Render(static_cast(durationSeconds*200.0f)/* 80% progress */); - - // We didn't expect the animation to finish yet + application.Render(static_cast(durationSeconds*intervalSeconds*1000.0f)); + application.SendNotification(); + application.Render(static_cast(durationSeconds*intervalSeconds*1000.0f)); + application.SendNotification(); + application.Render(static_cast(durationSeconds*intervalSeconds*1000.0f)); + application.SendNotification(); + application.Render(static_cast(durationSeconds*intervalSeconds*1000.0f)); application.SendNotification(); finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.8f), TEST_LOCATION ); - application.Render(static_cast(durationSeconds*100.0f) + 1u/*just beyond half the duration*/); + finishCheck.Reset(); + + // Loop N again + animation.SetLoopCount(3); + DALI_TEST_CHECK(animation.IsLooping()); - // We did expect the animation to finish application.SendNotification(); - finishCheck.CheckSignalReceived(); - DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION ); + application.Render(static_cast(durationSeconds*intervalSeconds*1000.0f)); + application.SendNotification(); + application.Render(static_cast(durationSeconds*intervalSeconds*1000.0f)); + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); - // 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 ); + application.Render(static_cast(durationSeconds*intervalSeconds*1000.0f)); + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); // we never hit play finishCheck.Reset(); - //Test -1 speed factor. Animation will play in reverse at normal speed - animation.SetSpeedFactor( -1.0f ); - // Start the animation - animation.Play(); + END_TEST; +} - application.SendNotification(); - application.Render(static_cast(durationSeconds*200.0f)/* 80% progress */); +int UtcDaliAnimationSetLoopCountP4(void) +{ + TestApplication application; - // We didn't expect the animation to finish yet - application.SendNotification(); - finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.8f), TEST_LOCATION ); + // + // ..and play again + // + Actor actor = Actor::New(); + Stage::GetCurrent().Add(actor); - application.Render(static_cast(durationSeconds*200.0f)/* 60% progress */); + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + Vector3 targetPosition(10.0f, 10.0f, 10.0f); + animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR); + animation.SetEndAction(Animation::Bake); - // We didn't expect the animation to finish yet - application.SendNotification(); - finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.6f), TEST_LOCATION ); + float intervalSeconds = 3.0f; - application.Render(static_cast(durationSeconds*200.0f)/* 40% progress */); + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + + animation.SetLoopCount(1); + animation.Play(); + DALI_TEST_CHECK(!animation.IsLooping()); - // We didn't expect the animation to finish yet application.SendNotification(); finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.4f), TEST_LOCATION ); + application.Render(static_cast(durationSeconds*intervalSeconds*1000.0f)); + application.SendNotification(); + finishCheck.CheckSignalReceived(); - application.Render(static_cast(durationSeconds*200.0f)/* 20% progress */); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION ); + actor.SetProperty( Actor::Property::POSITION, Vector3(0.0f, 0.0f, 0.0f) ); - // We didn't expect the animation to finish yet - application.SendNotification(); - finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION ); + finishCheck.Reset(); - application.Render(static_cast(durationSeconds*200.0f) + 1u/*just beyond the animation duration*/); + animation.Play(); // again + DALI_TEST_CHECK(!animation.IsLooping()); - // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + application.Render(static_cast(durationSeconds*intervalSeconds*1000.0f)); application.SendNotification(); finishCheck.CheckSignalReceived(); - 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( initialPosition, actor.GetCurrentPosition(), TEST_LOCATION ); - application.Render(0); - DALI_TEST_EQUALS( initialPosition, actor.GetCurrentPosition(), TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION ); + + END_TEST; +} +int UtcDaliAnimationGetLoopCountP(void) +{ + TestApplication application; - //Test change speed factor on the fly - finishCheck.Reset(); + Actor actor = Actor::New(); + Stage::GetCurrent().Add(actor); - //Set speed to be half of normal speed - animation.SetSpeedFactor( 0.5f ); + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + Vector3 targetPosition(10.0f, 10.0f, 10.0f); + animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR); + + DALI_TEST_CHECK(1 == animation.GetLoopCount()); // Start the animation + animation.SetLoopCount(3); + DALI_TEST_CHECK(animation.IsLooping()); + DALI_TEST_CHECK(3 == animation.GetLoopCount()); + animation.Play(); + application.Render(0); application.SendNotification(); - application.Render(static_cast(durationSeconds*200.0f)/* 10% progress */); - // We didn't expect the animation to finish yet + // Loop + float intervalSeconds = 3.0f; + + application.Render(static_cast(durationSeconds*intervalSeconds*1000.0f)); + application.Render(static_cast(durationSeconds*intervalSeconds*1000.0f)); + + application.Render(0); application.SendNotification(); - finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.1f), TEST_LOCATION ); - application.Render(static_cast(durationSeconds*200.0f)/* 20% progress */); + application.Render(static_cast(durationSeconds*intervalSeconds*1000.0f)); + application.SendNotification(); + + animation.SetLoopCount(0); + DALI_TEST_CHECK(animation.IsLooping()); + DALI_TEST_CHECK(0 == animation.GetLoopCount()); + + animation.SetLoopCount(1); + DALI_TEST_CHECK(!animation.IsLooping()); + DALI_TEST_CHECK(1 == animation.GetLoopCount()); + + END_TEST; +} + + +int UtcDaliAnimationGetCurrentLoopP(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(10.0f, 10.0f, 10.0f); + animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR); + + // Start the animation + animation.SetLoopCount(3); + DALI_TEST_CHECK(animation.IsLooping()); + DALI_TEST_CHECK(0 == animation.GetCurrentLoop()); + animation.Play(); + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); - // 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(durationSeconds*200.0f)/* 30% progress */); + // Loop + float intervalSeconds = 3.0f; + + application.Render(static_cast(durationSeconds*intervalSeconds*1000.0f)); + application.Render(static_cast(durationSeconds*intervalSeconds*1000.0f)); - // We didn't expect the animation to finish yet application.SendNotification(); finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.3f), TEST_LOCATION ); + DALI_TEST_CHECK(2 == animation.GetCurrentLoop()); + + application.Render(static_cast(durationSeconds*intervalSeconds*1000.0f)); - //Change speed factor while animation still playing. - animation.SetSpeedFactor(-1.0f); application.SendNotification(); - application.Render(static_cast(durationSeconds*200.0f)/* 10% progress */); + finishCheck.CheckSignalReceived(); + DALI_TEST_CHECK(3 == animation.GetCurrentLoop()); + DALI_TEST_CHECK(animation.GetLoopCount() == animation.GetCurrentLoop()); - // We didn't expect the animation to finish yet + finishCheck.Reset(); + + application.Render(static_cast(durationSeconds*intervalSeconds*1000.0f)); application.SendNotification(); finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.1f), TEST_LOCATION ); - - application.Render(static_cast(durationSeconds*100.0f) + 1u/*just beyond the animation duration*/); + DALI_TEST_CHECK(3 == animation.GetCurrentLoop()); - // We did expect the animation to finish + application.Render(static_cast(durationSeconds*intervalSeconds*1000.0f)); + application.Render(static_cast(durationSeconds*intervalSeconds*1000.0f)); + application.Render(static_cast(durationSeconds*intervalSeconds*1000.0f)); + application.Render(static_cast(durationSeconds*intervalSeconds*1000.0f)); application.SendNotification(); - finishCheck.CheckSignalReceived(); - DALI_TEST_EQUALS( actor.GetCurrentPosition(), initialPosition, TEST_LOCATION ); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_CHECK(3 == animation.GetCurrentLoop()); - // Check that nothing has changed after a couple of buffer swaps - application.Render(0); - DALI_TEST_EQUALS( initialPosition, actor.GetCurrentPosition(), TEST_LOCATION ); - application.Render(0); - DALI_TEST_EQUALS( initialPosition, actor.GetCurrentPosition(), TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationGetSpeedFactor(void) +int UtcDaliAnimationIsLoopingP(void) { TestApplication application; Animation animation = Animation::New(1.0f); - animation.SetSpeedFactor(0.5f); - DALI_TEST_EQUALS(animation.GetSpeedFactor(), 0.5f, TEST_LOCATION); + DALI_TEST_CHECK(!animation.IsLooping()); - animation.SetSpeedFactor(-2.5f); - DALI_TEST_EQUALS(animation.GetSpeedFactor(), -2.5f, TEST_LOCATION); + animation.SetLooping(true); + DALI_TEST_CHECK(animation.IsLooping()); END_TEST; } -int UtcDaliAnimationPlayOffStage(void) +int UtcDaliAnimationSetEndActioN(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); + DALI_TEST_CHECK(animation.GetEndAction() == Animation::Bake); + + Vector3 targetPosition(10.0f, 10.0f, 10.0f); + animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR); // Start the animation animation.Play(); @@ -847,207 +788,247 @@ int UtcDaliAnimationPlayOffStage(void) animation.FinishedSignal().Connect(&application, finishCheck); application.SendNotification(); - application.Render(static_cast(durationSeconds*200.0f)/* 20% progress */); + application.Render(static_cast(durationSeconds*1000.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.GetCurrentPosition(), Vector3::ZERO/*off-stage*/, TEST_LOCATION ); - - // Add to the stage - Stage::GetCurrent().Add(actor); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION ); + // Go back to the start + actor.SetPosition(Vector3::ZERO); application.SendNotification(); - application.Render(static_cast(durationSeconds*200.0f)/* 40% progress */); + application.Render(0); + DALI_TEST_EQUALS( Vector3::ZERO, actor.GetCurrentPosition(), TEST_LOCATION ); - // 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); + // Test BakeFinal, animate again, for half the duration + finishCheck.Reset(); + animation.SetEndAction(Animation::BakeFinal); + DALI_TEST_CHECK(animation.GetEndAction() == Animation::BakeFinal); + animation.Play(); application.SendNotification(); - application.Render(static_cast(durationSeconds*200.0f)/* 60% progress */); + application.Render(static_cast(durationSeconds*1000.0f*0.5f) /*half of the animation duration*/); - // We didn't expect the animation to finish yet + // Stop the animation early + animation.Stop(); + + // We did NOT expect the animation to finish application.SendNotification(); finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO/*back to start position*/, TEST_LOCATION ); + DALI_TEST_EQUALS( targetPosition * 0.5f, actor.GetCurrentPosition(), VECTOR4_EPSILON, TEST_LOCATION ); - // Add to the stage - Stage::GetCurrent().Add(actor); + // The position should be same with target position in the next frame + application.Render(0); + DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION ); + // Go back to the start + actor.SetPosition(Vector3::ZERO); application.SendNotification(); - application.Render(static_cast(durationSeconds*200.0f)/* 80% progress */); + application.Render(0); + DALI_TEST_EQUALS( Vector3::ZERO, actor.GetCurrentPosition(), TEST_LOCATION ); - // 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 ); + // Test EndAction::Discard, animate again, but don't bake this time + finishCheck.Reset(); + animation.SetEndAction(Animation::Discard); + DALI_TEST_CHECK(animation.GetEndAction() == Animation::Discard); + animation.Play(); application.SendNotification(); - application.Render(static_cast(durationSeconds*200.0f) + 1u/*just beyond the animation duration*/); + application.Render(static_cast(durationSeconds*1000.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( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION ); + + // The position should be discarded in the next frame + application.Render(0); + DALI_TEST_EQUALS( Vector3::ZERO/*discarded*/, actor.GetCurrentPosition(), 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( Vector3::ZERO, actor.GetCurrentPosition(), TEST_LOCATION ); application.Render(0); - DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION ); + DALI_TEST_EQUALS( Vector3::ZERO, actor.GetCurrentPosition(), TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationPlayDiscardHandle(void) +int UtcDaliAnimationGetEndActionP(void) { TestApplication application; - Actor actor = Actor::New(); - Stage::GetCurrent().Add(actor); + Animation animation = Animation::New(1.0f); + DALI_TEST_CHECK(animation.GetEndAction() == Animation::Bake); - // 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); + animation.SetEndAction(Animation::Discard); + DALI_TEST_CHECK(animation.GetEndAction() == Animation::Discard); - bool signalReceived(false); - AnimationFinishCheck finishCheck(signalReceived); - animation.FinishedSignal().Connect(&application, finishCheck); + animation.SetEndAction(Animation::BakeFinal); + DALI_TEST_CHECK(animation.GetEndAction() == Animation::BakeFinal); - // Start the animation - animation.Play(); + END_TEST; +} - // This is a test of the "Fire and Forget" behaviour - // Discard the animation handle! - animation.Reset(); - DALI_TEST_CHECK( !animation ); +int UtcDaliAnimationSetDisconnectActionP(void) +{ + TestApplication application; + Stage stage( Stage::GetCurrent() ); - application.SendNotification(); - application.Render(static_cast(durationSeconds*200.0f)/* 20% progress */); + // Default: BakeFinal + { + Actor actor = Actor::New(); + stage.Add(actor); - // We didn't expect the animation to finish yet - application.SendNotification(); - finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION ); + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + DALI_TEST_CHECK(animation.GetDisconnectAction() == Animation::BakeFinal); - application.SendNotification(); - application.Render(static_cast(durationSeconds*200.0f)/* 40% progress */); + Vector3 targetPosition(10.0f, 10.0f, 10.0f); + animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR); - // We didn't expect the animation to finish yet - application.SendNotification(); - finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.4f), TEST_LOCATION ); + // Start the animation + animation.Play(); - application.SendNotification(); - application.Render(static_cast(durationSeconds*200.0f)/* 60% progress */); + application.SendNotification(); + application.Render(static_cast(durationSeconds*0.5f*1000.0f)/*Only half the animation*/); - // We didn't expect the animation to finish yet - application.SendNotification(); - finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.6f), TEST_LOCATION ); + actor.Unparent(); - application.SendNotification(); - application.Render(static_cast(durationSeconds*200.0f)/* 80% progress */); + application.SendNotification(); + application.Render(); - // 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, TEST_LOCATION ); + } - application.SendNotification(); - application.Render(static_cast(durationSeconds*200.0f) + 1u/*just beyond the animation duration*/); + // Bake + { + Actor actor = Actor::New(); + stage.Add(actor); - // We did expect the animation to finish - application.SendNotification(); - finishCheck.CheckSignalReceived(); - DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION ); + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + animation.SetDisconnectAction( Animation::Bake ); - // 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; -} + Vector3 targetPosition(10.0f, 10.0f, 10.0f); + animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR); -int UtcDaliAnimationPlayStopDiscardHandle(void) -{ - TestApplication application; + // Start the animation + animation.Play(); - Actor actor = Actor::New(); - Stage::GetCurrent().Add(actor); + application.SendNotification(); + application.Render(static_cast(durationSeconds*0.5f*1000.0f)/*Only half the animation*/); - // 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); + actor.Unparent(); - // Start the animation - animation.Play(); + application.SendNotification(); + application.Render(); - bool signalReceived(false); - AnimationFinishCheck finishCheck(signalReceived); - animation.FinishedSignal().Connect(&application, finishCheck); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition*0.5f, TEST_LOCATION ); + } - application.SendNotification(); - application.Render(static_cast(durationSeconds*200.0f)/* 20% progress */); + // Discard + { + Actor actor = Actor::New(); + stage.Add(actor); - // We didn't expect the animation to finish yet - application.SendNotification(); - finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION ); + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + animation.SetDisconnectAction( Animation::Discard ); - // 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 ); + Vector3 targetPosition(10.0f, 10.0f, 10.0f); + animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR); - application.SendNotification(); - application.Render(static_cast(durationSeconds*200.0f)/* 40% progress */); + // Start the animation + animation.Play(); - // We expect the animation to finish at 20% progress - application.SendNotification(); - finishCheck.CheckSignalReceived(); - finishCheck.Reset(); - DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION ); + application.SendNotification(); + application.Render(static_cast(durationSeconds*0.5f*1000.0f)/*Only half the animation*/); - application.SendNotification(); - application.Render(static_cast(durationSeconds*200.0f)/* 60% progress */); + actor.Unparent(); - // Check that nothing has changed - application.SendNotification(); - finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION ); + application.SendNotification(); + application.Render(); - application.SendNotification(); - application.Render(static_cast(durationSeconds*200.0f)/* 80% progress */); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION ); + } - // Check that nothing has changed - application.SendNotification(); - finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION ); + // Don't play the animation: disconnect action should not be applied + { + Actor actor = Actor::New(); + stage.Add(actor); - application.SendNotification(); - application.Render(static_cast(durationSeconds*200.0f)/* 100% progress */); + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + + Vector3 targetPosition(10.0f, 10.0f, 10.0f); + animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR); + + application.SendNotification(); + application.Render(static_cast(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 UtcDaliAnimationGetDisconnectActionP(void) +{ + TestApplication application; + Animation animation = Animation::New(1.0f); + DALI_TEST_CHECK(animation.GetDisconnectAction() == Animation::BakeFinal); // default! + + animation.SetDisconnectAction(Animation::Discard); + DALI_TEST_CHECK(animation.GetDisconnectAction() == Animation::Discard); + + animation.SetDisconnectAction(Animation::Bake); + DALI_TEST_CHECK(animation.GetDisconnectAction() == Animation::Bake); + + END_TEST; +} + +int UtcDaliAnimationSetDefaultAlphaFunctionP(void) +{ + TestApplication application; + + Animation animation = Animation::New(1.0f); + AlphaFunction func = animation.GetDefaultAlphaFunction(); + DALI_TEST_EQUALS(func.GetBuiltinFunction(), AlphaFunction::DEFAULT, TEST_LOCATION); + + animation.SetDefaultAlphaFunction(AlphaFunction::EASE_IN); + AlphaFunction func2 = animation.GetDefaultAlphaFunction(); + DALI_TEST_EQUALS(func2.GetBuiltinFunction(), AlphaFunction::EASE_IN, TEST_LOCATION); + END_TEST; +} + +int UtcDaliAnimationGetDefaultAlphaFunctionP(void) +{ + TestApplication application; + + Animation animation = Animation::New(1.0f); + AlphaFunction func = animation.GetDefaultAlphaFunction(); + + // Test that the default is linear + DALI_TEST_EQUALS(func.GetBuiltinFunction(), AlphaFunction::DEFAULT, TEST_LOCATION); + + animation.SetDefaultAlphaFunction(AlphaFunction::EASE_IN); + AlphaFunction func2 = animation.GetDefaultAlphaFunction(); + DALI_TEST_EQUALS(func2.GetBuiltinFunction(), AlphaFunction::EASE_IN, TEST_LOCATION); - // Check that nothing has changed - application.SendNotification(); - finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationPlayFrom(void) +int UtcDaliAnimationSetCurrentProgressP(void) { TestApplication application; @@ -1055,26 +1036,23 @@ int UtcDaliAnimationPlayFrom(void) Stage::GetCurrent().Add(actor); // Build the animation + Animation animation = Animation::New(0.0f); + + //Set duration float durationSeconds(1.0f); - Animation animation = Animation::New(durationSeconds); - Vector3 targetPosition(100.0f, 100.0f, 100.0f); - animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear); + animation.SetDuration(durationSeconds); - //PlayFrom with an argument outside the range [0..1] will be ignored - animation.PlayFrom(-1.0f); + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); application.SendNotification(); - DALI_TEST_EQUALS(0.0f, animation.GetCurrentProgress(), TEST_LOCATION ); - animation.PlayFrom(100.0f); - application.SendNotification(); - DALI_TEST_EQUALS(0.0f, animation.GetCurrentProgress(), TEST_LOCATION ); + Vector3 targetPosition(100.0f, 100.0f, 100.0f); + animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR); // Start the animation from 40% progress - animation.PlayFrom( 0.4f ); - - bool signalReceived(false); - AnimationFinishCheck finishCheck(signalReceived); - animation.FinishedSignal().Connect(&application, finishCheck); + animation.SetCurrentProgress( 0.4f ); + animation.Play(); application.SendNotification(); application.Render(static_cast(durationSeconds*200.0f)/* 60% progress */); @@ -1083,15 +1061,21 @@ int UtcDaliAnimationPlayFrom(void) application.SendNotification(); finishCheck.CheckSignalNotReceived(); DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.6f), TEST_LOCATION ); + DALI_TEST_EQUALS( 0.6f, animation.GetCurrentProgress(), TEST_LOCATION ); animation.Play(); // Test that calling play has no effect, when animation is already playing application.SendNotification(); - application.Render(static_cast(durationSeconds*200.0f)/* 80% progress */); - // We didn't expect the animation to finish yet + //Set the progress to 70% + animation.SetCurrentProgress( 0.7f ); + application.SendNotification(); + application.Render(static_cast(durationSeconds*100.0f)/* 80% progress */); + DALI_TEST_EQUALS( 0.8f, animation.GetCurrentProgress(), TEST_LOCATION ); + application.SendNotification(); finishCheck.CheckSignalNotReceived(); DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.8f), TEST_LOCATION ); + DALI_TEST_EQUALS( 0.8f, animation.GetCurrentProgress(), TEST_LOCATION ); application.Render(static_cast(durationSeconds*200.0f) + 1u/*just beyond the animation duration*/); // We did expect the animation to finish @@ -1107,7 +1091,7 @@ int UtcDaliAnimationPlayFrom(void) END_TEST; } -int UtcDaliAnimationSetCurrentProgress(void) +int UtcDaliAnimationSetCurrentProgressN(void) { TestApplication application; @@ -1116,10 +1100,43 @@ int UtcDaliAnimationSetCurrentProgress(void) // Build the animation Animation animation = Animation::New(0.0f); - animation.Play(); - //Test GetCurrentProgress return 0.0 as the duration is 0.0 - DALI_TEST_EQUALS( 0.0f, animation.GetCurrentProgress(), TEST_LOCATION ); + //Set duration + float durationSeconds(1.0f); + animation.SetDuration(durationSeconds); + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + application.SendNotification(); + + Vector3 targetPosition(100.0f, 100.0f, 100.0f); + animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR); + + //Trying to set the current cursor outside the range [0..1] is ignored + animation.SetCurrentProgress( -1.0f); + application.SendNotification(); + DALI_TEST_EQUALS( 0.0f, animation.GetCurrentProgress(), TEST_LOCATION ); + + animation.SetCurrentProgress( 100.0f); + application.SendNotification(); + DALI_TEST_EQUALS( 0.0f, animation.GetCurrentProgress(), TEST_LOCATION ); + END_TEST; +} + +int UtcDaliAnimationGetCurrentProgressP(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + Stage::GetCurrent().Add(actor); + + // Build the animation + Animation animation = Animation::New(0.0f); + animation.Play(); + + //Test GetCurrentProgress return 0.0 as the duration is 0.0 + DALI_TEST_EQUALS( 0.0f, animation.GetCurrentProgress(), TEST_LOCATION ); animation.SetCurrentProgress( 0.5f ); application.SendNotification(); @@ -1139,16 +1156,7 @@ int UtcDaliAnimationSetCurrentProgress(void) application.SendNotification(); Vector3 targetPosition(100.0f, 100.0f, 100.0f); - animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear); - - //Trying to set the current cursor outside the range [0..1] is ignored - animation.SetCurrentProgress( -1.0f); - application.SendNotification(); - DALI_TEST_EQUALS( 0.0f, animation.GetCurrentProgress(), TEST_LOCATION ); - - animation.SetCurrentProgress( 100.0f); - application.SendNotification(); - DALI_TEST_EQUALS( 0.0f, animation.GetCurrentProgress(), TEST_LOCATION ); + animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR); // Start the animation from 40% progress animation.SetCurrentProgress( 0.4f ); @@ -1160,7 +1168,6 @@ int UtcDaliAnimationSetCurrentProgress(void) // 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( 0.6f, animation.GetCurrentProgress(), TEST_LOCATION ); animation.Play(); // Test that calling play has no effect, when animation is already playing @@ -1172,43 +1179,40 @@ int UtcDaliAnimationSetCurrentProgress(void) application.Render(static_cast(durationSeconds*100.0f)/* 80% progress */); DALI_TEST_EQUALS( 0.8f, animation.GetCurrentProgress(), TEST_LOCATION ); - application.SendNotification(); finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.8f), TEST_LOCATION ); DALI_TEST_EQUALS( 0.8f, animation.GetCurrentProgress(), TEST_LOCATION ); - // - application.Render(static_cast(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 UtcDaliAnimationPause(void) +int UtcDaliAnimationSetSpeedFactorP1(void) { TestApplication application; + tet_printf("Testing that setting a speed factor of 2 takes half the time\n"); + 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); - Vector3 fiftyPercentProgress(targetPosition * 0.5f); + 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::Property::POSITION), keyframes, AlphaFunction::LINEAR); + + //Set speed to be x2 + animation.SetSpeedFactor(2.0f); // Start the animation animation.Play(); @@ -1218,39 +1222,21 @@ int UtcDaliAnimationPause(void) animation.FinishedSignal().Connect(&application, finishCheck); application.SendNotification(); - application.Render(static_cast(durationSeconds*500.0f)/* 50% progress */); + application.Render(static_cast(durationSeconds*200.0f)/* 40% progress */); // We didn't expect the animation to finish yet application.SendNotification(); finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress, TEST_LOCATION ); - - // Pause the animation - animation.Pause(); - application.SendNotification(); - - // Loop 5 times - for (int i=0; i<5; ++i) - { - application.Render(static_cast(durationSeconds*500.0f)); - - // We didn't expect the animation to finish yet - application.SendNotification(); - finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress/* Still 50% progress when paused */, TEST_LOCATION ); - } + DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.4f), TEST_LOCATION ); - // Keep going - animation.Play(); - application.SendNotification(); - application.Render(static_cast(durationSeconds*490.0f)/*slightly less than the animation duration*/); + application.Render(static_cast(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(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/); + application.Render(static_cast(durationSeconds*100.0f) + 1u/*just beyond half the duration*/); // We did expect the animation to finish application.SendNotification(); @@ -1262,10 +1248,11 @@ int UtcDaliAnimationPause(void) DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION ); application.Render(0); DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION ); + END_TEST; } -int UtcDaliAnimationStop(void) +int UtcDaliAnimationSetSpeedFactorP2(void) { TestApplication application; @@ -1275,10 +1262,17 @@ int UtcDaliAnimationStop(void) // 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); - Vector3 fiftyPercentProgress(targetPosition * 0.5f); + 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::Property::POSITION), keyframes, AlphaFunction::LINEAR); + + tet_printf("Test -1 speed factor. Animation will play in reverse at normal speed\n"); + animation.SetSpeedFactor( -1.0f ); // Start the animation animation.Play(); @@ -1288,35 +1282,52 @@ int UtcDaliAnimationStop(void) animation.FinishedSignal().Connect(&application, finishCheck); application.SendNotification(); - application.Render(static_cast(durationSeconds*500.0f)/* 50% progress */); + application.Render(static_cast(durationSeconds*200.0f)/* 80% progress */); // We didn't expect the animation to finish yet application.SendNotification(); finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.8f), TEST_LOCATION ); - // Stop the animation - animation.Stop(); + application.Render(static_cast(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 ); - // Loop 5 times - for (int i=0; i<5; ++i) - { - application.Render(static_cast(durationSeconds*500.0f)); + application.Render(static_cast(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.Render(static_cast(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(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(), initialPosition, TEST_LOCATION ); + + // Check that nothing has changed after a couple of buffer swaps + application.Render(0); + DALI_TEST_EQUALS( initialPosition, actor.GetCurrentPosition(), TEST_LOCATION ); + application.Render(0); + DALI_TEST_EQUALS( initialPosition, actor.GetCurrentPosition(), TEST_LOCATION ); - // We did expect the animation to finish - application.SendNotification(); - finishCheck.CheckSignalReceived(); - DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress/* Still 50% progress when stopped */, TEST_LOCATION ); - } END_TEST; } -int UtcDaliAnimationStopSetPosition(void) +int UtcDaliAnimationSetSpeedFactorP3(void) { - // Test that Animation::Stop & Actor::SetPosition can be used in conjunction - // i.e. to check that the animation does not interfere with the position set. - TestApplication application; Actor actor = Actor::New(); @@ -1325,46 +1336,74 @@ int UtcDaliAnimationStopSetPosition(void) // 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); - Vector3 fiftyPercentProgress(targetPosition * 0.5f); + const Vector3 initialPosition(0.0f, 0.0f, 0.0f); + const Vector3 targetPosition(100.0f, 100.0f, 100.0f); - // Start the animation - animation.Play(); + KeyFrames keyframes = KeyFrames::New(); + keyframes.Add( 0.0f, initialPosition); + keyframes.Add( 1.0f, targetPosition ); + animation.AnimateBetween( Property(actor, Actor::Property::POSITION), keyframes, AlphaFunction::LINEAR); bool signalReceived(false); AnimationFinishCheck finishCheck(signalReceived); animation.FinishedSignal().Connect(&application, finishCheck); + tet_printf("Test half speed factor. Animation will take twice the duration\n"); + + //Set speed to be half of normal speed + animation.SetSpeedFactor( 0.5f ); + + // Start the animation + animation.Play(); + application.SendNotification(); - application.Render(static_cast(durationSeconds*500.0f)/* 50% progress */); + application.Render(static_cast(durationSeconds*200.0f)/* 10% progress */); // We didn't expect the animation to finish yet application.SendNotification(); finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.1f), TEST_LOCATION ); - // Stop the animation - animation.Stop(); - Vector3 positionSet(2.0f, 3.0f, 4.0f); - actor.SetPosition(positionSet); + application.Render(static_cast(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 ); - // Loop 5 times - for (int i=0; i<5; ++i) - { - application.Render(static_cast(durationSeconds*500.0f)); + application.Render(static_cast(durationSeconds*200.0f)/* 30% progress */); - // We did expect the animation to finish - application.SendNotification(); - finishCheck.CheckSignalReceived(); - DALI_TEST_EQUALS( actor.GetCurrentPosition(), positionSet/*Animation should not interfere with this*/, TEST_LOCATION ); - } + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.3f), TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(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.Render(static_cast(durationSeconds*1200.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 UtcDaliAnimationClear(void) + +int UtcDaliAnimationSetSpeedFactorP4(void) { TestApplication application; @@ -1374,266 +1413,556 @@ int UtcDaliAnimationClear(void) // 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); - Vector3 fiftyPercentProgress(targetPosition * 0.5f); + const Vector3 initialPosition(0.0f, 0.0f, 0.0f); + const Vector3 targetPosition(100.0f, 100.0f, 100.0f); - // Start the animation - animation.Play(); + KeyFrames keyframes = KeyFrames::New(); + keyframes.Add( 0.0f, initialPosition); + keyframes.Add( 1.0f, targetPosition ); + animation.AnimateBetween( Property(actor, Actor::Property::POSITION), keyframes, AlphaFunction::LINEAR); bool signalReceived(false); AnimationFinishCheck finishCheck(signalReceived); animation.FinishedSignal().Connect(&application, finishCheck); + tet_printf("Test half speed factor. Animation will take twice the duration\n"); + + tet_printf("Set speed to be half of normal speed\n"); + tet_printf("SetSpeedFactor(0.5f)\n"); + animation.SetSpeedFactor( 0.5f ); + + // Start the animation + animation.Play(); + application.SendNotification(); - application.Render(static_cast(durationSeconds*500.0f)/* 50% progress */); + application.Render(static_cast(durationSeconds*200.0f)/* 10% progress */); // We didn't expect the animation to finish yet application.SendNotification(); finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.1f), TEST_LOCATION ); - // Clear the animation - animation.Clear(); + application.Render(static_cast(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(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/); + application.Render(static_cast(durationSeconds*200.0f)/* 30% progress */); - // We don't expect the animation to finish now + // We didn't expect the animation to finish yet application.SendNotification(); finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress/* Still 50% progress since the animator was destroyed */, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.3f), TEST_LOCATION ); - // Restart as a scale animation; this should not move the actor's position - finishCheck.Reset(); - actor.SetPosition(Vector3::ZERO); - Vector3 targetScale(3.0f, 3.0f, 3.0f); - animation.ScaleTo(actor, targetScale, AlphaFunctions::Linear); - animation.Play(); + tet_printf("Reverse direction of animation whilst playing\n"); + tet_printf("SetSpeedFactor(-0.5f)\n"); + animation.SetSpeedFactor(-0.5f); application.SendNotification(); - application.Render(static_cast(durationSeconds*500.0f)/* 50% progress */); + application.Render(static_cast(durationSeconds*200.0f)/* 20% progress */); // We didn't expect the animation to finish yet application.SendNotification(); finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO/*Check move-animator was destroyed*/, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3(2.0f, 2.0f, 2.0f), TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION ); - application.Render(static_cast(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/); + application.Render(static_cast(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.1f), 0.0001, TEST_LOCATION ); + + application.Render(static_cast(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(), Vector3::ZERO/*Check move-animator was destroyed*/, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, 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( initialPosition, actor.GetCurrentPosition(), TEST_LOCATION ); + application.Render(0); + DALI_TEST_EQUALS( initialPosition, actor.GetCurrentPosition(), TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationSignalFinish(void) +int UtcDaliAnimationSetSpeedFactorAndRange(void) { TestApplication application; - // Start the empty animation + const unsigned int NUM_FRAMES(15); + + struct TestData + { + float startTime; + float endTime; + float startX; + float endX; + float expected[NUM_FRAMES]; + }; + + TestData testData[] = { + // ACTOR 0 + /*0.0f, 0.1f 0.2f 0.3f 0.4f 0.5f 0.6f 0.7f 0.8f 0.9f 1.0f */ + /* |----------PlayRange---------------| */ + /* | reverse */ + { 0.0f, 1.0f, // TimePeriod + 0.0f, 100.0f, // POS + {/**/ 30.0f, 40.0f, 50.0f, 60.0f, 70.0f, /* Loop */ + /**/ 30.0f, 40.0f, 50.0f, 60.0f, /* Reverse direction */ + /**/ 50.0f, + /**/ 40.0f, + /**/ 30.0f, + /**/ 70.0f, + /**/ 60.0f, + /**/ 50.0f, + /**/ + } + }, + + // ACTOR 1 - Across start of range + /*0.0f, 0.1f 0.2f 0.3f 0.4f 0.5f 0.6f 0.7f 0.8f 0.9f 1.0f */ + /* |----------PlayRange---------------| */ + /* | reverse */ + { 0.2f, 0.5f, // TimePeriod + 20.0f, 50.0f, // POS + {/**/ 30.0f, 40.0f, 50.0f, 50.0f, 50.0f, /* Loop */ + /**/ 30.0f, 40.0f, 50.0f, 50.0f, /* Reverse direction @ frame #9 */ + /**/ 50.0f, + /**/ 40.0f, + /**/ 30.0f, + /**/ 50.0f, + /**/ 50.0f, + /**/ 50.0f + } + }, + + // ACTOR 2 - Across end of range + /*0.0f, 0.1f 0.2f 0.3f 0.4f 0.5f 0.6f 0.7f 0.8f 0.9f 1.0f */ + /* |----------PlayRange---------------| */ + /* | reverse */ + {/**/ 0.5f, 0.9f, // TimePeriod + /**/ 50.0f, 90.0f, // POS + { /**/ 50.0f, 50.0f, 50.0f, 60.0f, 70.0f, /* Loop */ + /**/ 50.0f, 50.0f, 50.0f, 60.0f,/* Reverse direction @ frame #9 */ + /**/ 50.0f, + /**/ 50.0f, + /**/ 50.0f, 70.0f, + /**/ 60.0f, + /**/ 50.0f, + } + }, + + // ACTOR 3 - Before beginning of range + /*0.0f, 0.1f 0.2f 0.3f 0.4f 0.5f 0.6f 0.7f 0.8f 0.9f 1.0f */ + /* |----------PlayRange---------------| */ + /* | reverse */ + {/**/ 0.1f, 0.25f, // TimePeriod + /**/ 10.0f, 25.0f, // POS + { /**/ + /**/ 25.0f, 25.0f, 25.0f, 25.0f, 25.0f, 25.0f, 25.0f, 25.0f, 25.0f, 25.0f, 25.0f, 25.0f, 25.0f, 25.0f, 25.0f + /**/ + } + }, + + // ACTOR 4 - After end of range + /*0.0f, 0.1f 0.2f 0.3f 0.4f 0.5f 0.6f 0.7f 0.8f 0.9f 1.0f */ + /* |----------PlayRange---------------| */ + /* | reverse */ + {/**/ 0.85f, 1.0f, // TimePeriod + /**/ 85.0f, 100.0f, // POS + { /**/ + /**/ 85.0f, 85.0f, 85.0f, 85.0f, 85.0f, 85.0f, 85.0f, 85.0f, 85.0f, 85.0f, 85.0f, 85.0f, 85.0f, 85.0f, 85.0f + /**/ + } + }, + // Actor 5 - Middle of range + /*0.0f, 0.1f 0.2f 0.3f 0.4f 0.5f 0.6f 0.7f 0.8f 0.9f 1.0f */ + /* |----------PlayRange---------------| */ + /* | reverse */ + {/**/ 0.4f, 0.65f, // Time Period + /**/ 40.0f, 65.0f, // Position + { /**/ 40.0f, 40.0f, 50.0f, 60.0f, 65.0f, + /**/ 40.0f, 40.0f, 50.0f, 60.0f, // Reverse + /**/ 50.0f, + /**/ 40.0f, + /**/ 40.0f, + /**/ 65.0f, + /**/ 60.0f, + /**/ 50.0f, + } + } + }; + + const size_t NUM_ENTRIES(sizeof(testData)/sizeof(TestData)); + + // Build the animation float durationSeconds(1.0f); Animation animation = Animation::New(durationSeconds); - animation.Play(); - bool signalReceived(false); AnimationFinishCheck finishCheck(signalReceived); animation.FinishedSignal().Connect(&application, finishCheck); - application.SendNotification(); - application.Render(static_cast(durationSeconds*1000.0f) + 1u/*beyond the animation duration*/); + std::vector actors; - // We did expect the animation to finish + for( unsigned int actorIndex = 0; actorIndex < NUM_ENTRIES; ++actorIndex ) + { + Actor actor = Actor::New(); + actor.SetPosition( Vector3( testData[actorIndex].startX, 0, 0 ) ); + actors.push_back(actor); + Stage::GetCurrent().Add(actor); + + if( actorIndex == 0 || actorIndex == NUM_ENTRIES-1 ) + { + KeyFrames keyframes = KeyFrames::New(); + keyframes.Add( testData[actorIndex].startTime, Vector3(testData[actorIndex].startX, 0, 0)); + keyframes.Add( testData[actorIndex].endTime, Vector3(testData[actorIndex].endX, 0, 0)); + animation.AnimateBetween( Property(actor, Actor::Property::POSITION), keyframes, AlphaFunction::LINEAR); + } + else + { + animation.AnimateTo( Property(actor, Actor::Property::POSITION), Vector3( testData[actorIndex].endX, 0, 0 ), TimePeriod( testData[actorIndex].startTime, testData[actorIndex].endTime - testData[actorIndex].startTime) ); + } + } + + tet_printf("Test half speed factor. Animation will take twice the duration\n"); + tet_printf("Set play range to be 0.3 - 0.8 of the duration\n"); + tet_printf("SetSpeedFactor(0.5f)\n"); + animation.SetSpeedFactor( 0.5f ); + animation.SetPlayRange( Vector2(0.3f, 0.8f) ); + animation.SetLooping(true); + + // Start the animation + animation.Play(); application.SendNotification(); - finishCheck.CheckSignalReceived(); + application.Render(0); // Frame 0 tests initial values + + for( unsigned int frame = 0; frame < NUM_FRAMES; ++frame ) + { + unsigned int actorIndex = 0u; + for( actorIndex = 0u; actorIndex < NUM_ENTRIES; ++actorIndex ) + { + DALI_TEST_EQUALS( actors[actorIndex].GetCurrentPosition().x, testData[actorIndex].expected[frame], 0.001, TEST_LOCATION ); + if( ! Equals(actors[actorIndex].GetCurrentPosition().x, testData[actorIndex].expected[frame]) ) + { + tet_printf("Failed at frame %u, actorIndex %u\n", frame, actorIndex ); + } + } + + if( frame == 8 ) + { + tet_printf("Reverse direction of animation whilst playing after frame 8\n"); + tet_printf("SetSpeedFactor(-0.5f)\n"); + animation.SetSpeedFactor(-0.5f); + application.SendNotification(); + } + application.Render(200); // 200 ms at half speed corresponds to 0.1 s + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + } + END_TEST; } -int UtcDaliAnimationAnimateByBoolean(void) +int UtcDaliAnimationSetSpeedFactorRangeAndLoopCount01(void) { TestApplication application; - Actor actor = Actor::New(); + const unsigned int NUM_FRAMES(15); + + struct TestData + { + float startTime; + float endTime; + float startX; + float endX; + float expected[NUM_FRAMES]; + }; + + TestData testData = + // ACTOR 0 + /*0.0f, 0.1f 0.2f 0.3f 0.4f 0.5f 0.6f 0.7f 0.8f 0.9f 1.0f */ + /* |----------PlayRange---------------| */ + { 0.0f, 1.0f, // TimePeriod + 0.0f, 100.0f, // POS + {/**/ 30.0f, 40.0f, 50.0f, 60.0f, 70.0f, /* Loop */ + /**/ 30.0f, 40.0f, 50.0f, 60.0f, 70.0f, + /**/ 30.0f, 40.0f, 50.0f, 60.0f, 70.0f, + /**/ + } + }; - // Register a boolean property - bool startValue(false); - Property::Index index = actor.RegisterProperty( "test-property", startValue ); - Stage::GetCurrent().Add(actor); - DALI_TEST_CHECK( actor.GetProperty(index) == startValue ); // Build the animation - float durationSeconds(2.0f); + float durationSeconds(1.0f); Animation animation = Animation::New(durationSeconds); - const bool relativeValue(true); - const bool finalValue( false || relativeValue ); - animation.AnimateBy(Property(actor, index), relativeValue); - - // Start the animation - animation.Play(); - bool signalReceived(false); AnimationFinishCheck finishCheck(signalReceived); animation.FinishedSignal().Connect(&application, finishCheck); - application.SendNotification(); - application.Render(static_cast(durationSeconds*950.0f)/* 95% progress */); + std::vector actors; - // We didn't expect the animation to finish yet - application.SendNotification(); - finishCheck.CheckSignalNotReceived(); - DALI_TEST_CHECK( actor.GetProperty(index) == startValue ); + Actor actor = Actor::New(); + actor.SetPosition( Vector3( testData.startX, 0, 0 ) ); + actors.push_back(actor); + Stage::GetCurrent().Add(actor); + KeyFrames keyframes = KeyFrames::New(); + keyframes.Add( testData.startTime, Vector3(testData.startX, 0, 0)); + keyframes.Add( testData.endTime, Vector3(testData.endX, 0, 0)); + animation.AnimateBetween( Property(actor, Actor::Property::POSITION), keyframes, AlphaFunction::LINEAR); + + tet_printf("Test half speed factor. Animation will take twice the duration\n"); + tet_printf("Set play range to be 0.3 - 0.8 of the duration\n"); + tet_printf("SetSpeedFactor(0.5f)\n"); + tet_printf("SetLoopCount(3)\n"); + animation.SetSpeedFactor( 0.5f ); + animation.SetPlayRange( Vector2(0.3f, 0.8f) ); + animation.SetLoopCount(3); + + // Start the animation + animation.Play(); application.SendNotification(); - application.Render(static_cast(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/); + application.Render(0); // Frame 0 tests initial values + + for( unsigned int frame = 0; frame < NUM_FRAMES; ++frame ) + { + DALI_TEST_EQUALS( actor.GetCurrentPosition().x, testData.expected[frame], 0.001, TEST_LOCATION ); + + application.Render(200); // 200 ms at half speed corresponds to 0.1 s + + if( frame < NUM_FRAMES-1 ) + { + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + } + } // We did expect the animation to finish application.SendNotification(); finishCheck.CheckSignalReceived(); - DALI_TEST_CHECK( actor.GetProperty(index) == finalValue ); + DALI_TEST_EQUALS( actor.GetCurrentPosition().x, 80.0f, 0.001, TEST_LOCATION ); - // Check that nothing has changed after a couple of buffer swaps - application.Render(0); - DALI_TEST_CHECK( actor.GetProperty(index) == finalValue ); - application.Render(0); - DALI_TEST_CHECK( actor.GetProperty(index) == finalValue ); + END_TEST; +} - // Repeat with relative value "false" - this should be an NOOP - animation = Animation::New(durationSeconds); - bool noOpValue(false); - animation.AnimateBy(Property(actor, index), noOpValue); +int UtcDaliAnimationSetSpeedFactorRangeAndLoopCount02(void) +{ + TestApplication application; - // Start the animation - animation.Play(); + const unsigned int NUM_FRAMES(15); - finishCheck.Reset(); + struct TestData + { + float startTime; + float endTime; + float startX; + float endX; + float expected[NUM_FRAMES]; + }; + + TestData testData = + // ACTOR 0 + /*0.0f, 0.1f 0.2f 0.3f 0.4f 0.5f 0.6f 0.7f 0.8f 0.9f 1.0f */ + /* |----------PlayRange---------------| */ + { 0.0f, 1.0f, // TimePeriod + 0.0f, 100.0f, // POS + {/**/ 80.0f, 70.0f, 60.0f, 50.0f, 40.0f, + /**/ 80.0f, 70.0f, 60.0f, 50.0f, 40.0f, + /**/ 80.0f, 70.0f, 60.0f, 50.0f, 40.0f, + } + }; + + + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); animation.FinishedSignal().Connect(&application, finishCheck); - application.SendNotification(); - application.Render(static_cast(durationSeconds*950.0f)/* 95% progress */); + std::vector actors; - // We didn't expect the animation to finish yet - application.SendNotification(); - finishCheck.CheckSignalNotReceived(); - DALI_TEST_CHECK( actor.GetProperty(index) == finalValue ); + Actor actor = Actor::New(); + actor.SetPosition( Vector3( testData.startX, 0, 0 ) ); + actors.push_back(actor); + Stage::GetCurrent().Add(actor); + + KeyFrames keyframes = KeyFrames::New(); + keyframes.Add( testData.startTime, Vector3(testData.startX, 0, 0)); + keyframes.Add( testData.endTime, Vector3(testData.endX, 0, 0)); + animation.AnimateBetween( Property(actor, Actor::Property::POSITION), keyframes, AlphaFunction::LINEAR); + tet_printf("Test reverse half speed factor. Animation will take twice the duration\n"); + tet_printf("Set play range to be 0.3 - 0.8 of the duration\n"); + tet_printf("SetSpeedFactor(-0.5f)\n"); + tet_printf("SetLoopCount(3)\n"); + animation.SetSpeedFactor( -0.5f ); + animation.SetPlayRange( Vector2(0.3f, 0.8f) ); + animation.SetLoopCount(3); + + // Start the animation + animation.Play(); application.SendNotification(); - application.Render(static_cast(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/); + application.Render(0); // Frame 0 tests initial values + + for( unsigned int frame = 0; frame < NUM_FRAMES; ++frame ) + { + DALI_TEST_EQUALS( actor.GetCurrentPosition().x, testData.expected[frame], 0.001, TEST_LOCATION ); + + application.Render(200); // 200 ms at half speed corresponds to 0.1 s + + if( frame < NUM_FRAMES-1 ) + { + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + } + } // We did expect the animation to finish application.SendNotification(); finishCheck.CheckSignalReceived(); - DALI_TEST_CHECK( actor.GetProperty(index) == finalValue ); + DALI_TEST_EQUALS( actor.GetCurrentPosition().x, 30.0f, 0.001, TEST_LOCATION ); - // Check that nothing has changed after a couple of buffer swaps - application.Render(0); - DALI_TEST_CHECK( actor.GetProperty(index) == finalValue ); - application.Render(0); - DALI_TEST_CHECK( actor.GetProperty(index) == finalValue ); END_TEST; } -int UtcDaliAnimationAnimateByBooleanAlphaFunction(void) + +int UtcDaliAnimationGetSpeedFactorP(void) { TestApplication application; - Actor actor = Actor::New(); + Animation animation = Animation::New(1.0f); + animation.SetSpeedFactor(0.5f); + DALI_TEST_EQUALS(animation.GetSpeedFactor(), 0.5f, TEST_LOCATION); - // Register a boolean property - bool startValue(false); - Property::Index index = actor.RegisterProperty( "test-property", startValue ); - Stage::GetCurrent().Add(actor); - DALI_TEST_CHECK( actor.GetProperty(index) == startValue ); + animation.SetSpeedFactor(-2.5f); + DALI_TEST_EQUALS(animation.GetSpeedFactor(), -2.5f, TEST_LOCATION); + END_TEST; +} + +int UtcDaliAnimationSetPlayRangeP(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + Stage::GetCurrent().Add( actor ); // Build the animation - float durationSeconds(2.0f); - Animation animation = Animation::New(durationSeconds); - bool relativeValue(true); - bool finalValue( false || relativeValue ); - animation.AnimateBy(Property(actor, index), relativeValue, AlphaFunctions::EaseIn); + float durationSeconds( 1.0f ); + Animation animation = Animation::New( durationSeconds ); - // Start the animation - animation.Play(); + bool signalReceived( false ); + AnimationFinishCheck finishCheck( signalReceived ); + animation.FinishedSignal().Connect( &application, finishCheck ); + application.SendNotification(); - bool signalReceived(false); - AnimationFinishCheck finishCheck(signalReceived); - animation.FinishedSignal().Connect(&application, finishCheck); + // Set range between 0.4 and 0.8 + animation.SetPlayRange( Vector2( 0.4f, 0.9f ) ); + application.SendNotification(); + DALI_TEST_EQUALS( Vector2( 0.4f, 0.9f ), animation.GetPlayRange(), TEST_LOCATION ); + + Vector3 targetPosition( 100.0f, 100.0f, 100.0f ); + animation.AnimateTo( Property( actor, Actor::Property::POSITION ), targetPosition, AlphaFunction::LINEAR ); + + // Start the animation from 40% progress + animation.Play(); application.SendNotification(); - application.Render(static_cast(durationSeconds*950.0f)/* 95% progress */); + 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_CHECK( actor.GetProperty(index) == startValue ); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), ( targetPosition * 0.6f ), TEST_LOCATION ); application.SendNotification(); - application.Render(static_cast(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/); + application.Render( static_cast< unsigned int >( durationSeconds * 200.0f )/* 80% progress */ ); + + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), ( targetPosition * 0.8f ), TEST_LOCATION ); + + application.SendNotification(); + 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_CHECK( actor.GetProperty(index) == finalValue ); - - // Check that nothing has changed after a couple of buffer swaps - application.Render(0); - DALI_TEST_CHECK( actor.GetProperty(index) == finalValue ); - application.Render(0); - DALI_TEST_CHECK( actor.GetProperty(index) == finalValue ); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), ( targetPosition * 0.9f ), TEST_LOCATION ); + END_TEST; +} - // Repeat with relative value "false" - this should be an NOOP - animation = Animation::New(durationSeconds); - bool noOpValue(false); - animation.AnimateBy(Property(actor, index), noOpValue, AlphaFunctions::EaseIn); +int UtcDaliAnimationSetPlayRangeN(void) +{ + TestApplication application; - // Start the animation - animation.Play(); + Actor actor = Actor::New(); + Stage::GetCurrent().Add(actor); - finishCheck.Reset(); - animation.FinishedSignal().Connect(&application, finishCheck); + // Build the animation + Animation animation = Animation::New(0); + application.SendNotification(); + //PlayRange out of bounds + animation.SetPlayRange( Vector2(-1.0f,1.0f) ); application.SendNotification(); - application.Render(static_cast(durationSeconds*950.0f)/* 95% progress */); + 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 ); - // We didn't expect the animation to finish yet + //If playRange is not in the correct order it has to be ordered + animation.SetPlayRange( Vector2(0.8f,0.2f) ); application.SendNotification(); - finishCheck.CheckSignalNotReceived(); - DALI_TEST_CHECK( actor.GetProperty(index) == finalValue ); + DALI_TEST_EQUALS( Vector2(0.2f,0.8f), animation.GetPlayRange(), TEST_LOCATION ); + + END_TEST; +} + +int UtcDaliAnimationGetPlayRangeP(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + Stage::GetCurrent().Add( actor ); + // Build the animation + Animation animation = Animation::New( 1.0f ); application.SendNotification(); - application.Render(static_cast(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/); - // We did expect the animation to finish + //If PlayRange not specified it should be 0.0-1.0 by default + DALI_TEST_EQUALS( Vector2( 0.0f,1.0f ), animation.GetPlayRange(), TEST_LOCATION ); + + // Set range between 0.4 and 0.8 + animation.SetPlayRange( Vector2( 0.4f, 0.8f ) ); application.SendNotification(); - finishCheck.CheckSignalReceived(); - DALI_TEST_CHECK( actor.GetProperty(index) == finalValue ); + DALI_TEST_EQUALS( Vector2( 0.4f, 0.8f ), animation.GetPlayRange(), TEST_LOCATION ); + END_TEST; } -int UtcDaliAnimationAnimateByBooleanTimePeriod(void) +int UtcDaliAnimationPlayP(void) { TestApplication application; Actor actor = Actor::New(); - - // Register a boolean property - bool startValue(false); - Property::Index index = actor.RegisterProperty( "test-property", startValue ); Stage::GetCurrent().Add(actor); - DALI_TEST_CHECK( actor.GetProperty(index) == startValue ); // Build the animation - float durationSeconds(2.0f); + float durationSeconds(1.0f); Animation animation = Animation::New(durationSeconds); - bool relativeValue(true); - bool finalValue( false || relativeValue ); - float animatorDurationSeconds(durationSeconds * 0.5f); - animation.AnimateBy( Property(actor, index), - relativeValue, - TimePeriod( animatorDurationSeconds ) ); + Vector3 targetPosition(100.0f, 100.0f, 100.0f); + animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR); // Start the animation animation.Play(); @@ -1643,61 +1972,76 @@ int UtcDaliAnimationAnimateByBooleanTimePeriod(void) animation.FinishedSignal().Connect(&application, finishCheck); application.SendNotification(); - application.Render(static_cast(animatorDurationSeconds*950.0f)/* 95% animator progress */); + application.Render(static_cast(durationSeconds*200.0f)/* 20% progress */); // We didn't expect the animation to finish yet application.SendNotification(); finishCheck.CheckSignalNotReceived(); - DALI_TEST_CHECK( actor.GetProperty(index) == startValue ); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION ); + animation.Play(); // Test that calling play has no effect, when animation is already playing application.SendNotification(); - application.Render(static_cast(animatorDurationSeconds*50.0f) + 1u/*just beyond the animator duration*/); + application.Render(static_cast(durationSeconds*200.0f)/* 40% progress */); - // We didn't expect the animation to finish yet... + // We didn't expect the animation to finish yet application.SendNotification(); finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.4f), TEST_LOCATION ); - // ...however we should have reached the final value - DALI_TEST_CHECK( actor.GetProperty(index) == finalValue ); + animation.Play(); // Test that calling play has no effect, when animation is already playing + application.SendNotification(); + application.Render(static_cast(durationSeconds*200.0f)/* 60% progress */); + // We didn't expect the animation to finish yet application.SendNotification(); - application.Render(static_cast(animatorDurationSeconds*1000.0f)/*just beyond the animation duration*/); + 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(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 ); + + animation.Play(); // Test that calling play has no effect, when animation is already playing + application.SendNotification(); + application.Render(static_cast(durationSeconds*200.0f) + 1u/*just beyond the animation duration*/); // We did expect the animation to finish application.SendNotification(); finishCheck.CheckSignalReceived(); - DALI_TEST_CHECK( actor.GetProperty(index) == finalValue ); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION ); // Check that nothing has changed after a couple of buffer swaps application.Render(0); - DALI_TEST_CHECK( actor.GetProperty(index) == finalValue ); + DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION ); application.Render(0); - DALI_TEST_CHECK( actor.GetProperty(index) == finalValue ); + DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationAnimateByBooleanAlphaFunctionTimePeriod(void) +int UtcDaliAnimationPlayOffStageP(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(); - - // Register a boolean property - bool startValue(false); - Property::Index index = actor.RegisterProperty( "test-property", startValue ); - Stage::GetCurrent().Add(actor); - DALI_TEST_CHECK( actor.GetProperty(index) == startValue ); + Vector3 basePosition(Vector3::ZERO); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), basePosition, TEST_LOCATION ); + // Not added to the stage! // Build the animation - float durationSeconds(2.0f); + float durationSeconds(1.0f); Animation animation = Animation::New(durationSeconds); - bool relativeValue(true); - bool finalValue( false || relativeValue ); - float animatorDurationSeconds(durationSeconds * 0.5f); - animation.AnimateBy( Property(actor, index), - relativeValue, - AlphaFunctions::EaseInOut, - TimePeriod( animatorDurationSeconds ) ); + animation.SetDisconnectAction( Animation::Discard ); + Vector3 targetPosition(100.0f, 100.0f, 100.0f); + animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR); // Start the animation animation.Play(); @@ -1707,167 +2051,149 @@ int UtcDaliAnimationAnimateByBooleanAlphaFunctionTimePeriod(void) animation.FinishedSignal().Connect(&application, finishCheck); application.SendNotification(); - application.Render(static_cast(animatorDurationSeconds*950.0f)/* 95% animator progress */); + application.Render(static_cast(durationSeconds*200.0f)/* 20% progress */); // We didn't expect the animation to finish yet application.SendNotification(); finishCheck.CheckSignalNotReceived(); - DALI_TEST_CHECK( actor.GetProperty(index) == startValue ); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO/*off-stage*/, TEST_LOCATION ); + + // Add to the stage + Stage::GetCurrent().Add(actor); application.SendNotification(); - application.Render(static_cast(animatorDurationSeconds*50.0f) + 1u/*just beyond the animator duration*/); + application.Render(static_cast(durationSeconds*200.0f)/* 40% progress */); - // We didn't expect the animation to finish yet... + // 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 ); - // ...however we should have reached the final value - DALI_TEST_CHECK( actor.GetProperty(index) == finalValue ); + // Remove from the stage + Stage::GetCurrent().Remove(actor); application.SendNotification(); - application.Render(static_cast(animatorDurationSeconds*1000.0f)/*just beyond the animation duration*/); + application.Render(static_cast(durationSeconds*200.0f)/* 60% progress */); - // We did expect the animation to finish + // We didn't expect the animation to finish yet application.SendNotification(); - finishCheck.CheckSignalReceived(); - DALI_TEST_CHECK( actor.GetProperty(index) == finalValue ); - - // Check that nothing has changed after a couple of buffer swaps - application.Render(0); - DALI_TEST_CHECK( actor.GetProperty(index) == finalValue ); - application.Render(0); - DALI_TEST_CHECK( actor.GetProperty(index) == finalValue ); - END_TEST; -} - -int UtcDaliAnimationAnimateByFloat(void) -{ - TestApplication application; - - Actor actor = Actor::New(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO/*back to start position*/, TEST_LOCATION ); - // Register a float property - float startValue(10.0f); - Property::Index index = actor.RegisterProperty( "test-property", startValue ); + // Add to the stage Stage::GetCurrent().Add(actor); - DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); - - // Build the animation - float durationSeconds(2.0f); - Animation animation = Animation::New(durationSeconds); - float targetValue(50.0f); - float relativeValue(targetValue - startValue); - animation.AnimateBy(Property(actor, index), relativeValue); - - float ninetyFivePercentProgress(startValue + relativeValue*0.95f); - - // Start the animation - animation.Play(); - - bool signalReceived(false); - AnimationFinishCheck finishCheck(signalReceived); - animation.FinishedSignal().Connect(&application, finishCheck); application.SendNotification(); - application.Render(static_cast(durationSeconds*950.0f)/* 95% progress */); + application.Render(static_cast(durationSeconds*200.0f)/* 80% progress */); // We didn't expect the animation to finish yet application.SendNotification(); finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetProperty(index), ninetyFivePercentProgress, TEST_LOCATION ); + expectedPosition = Vector3(basePosition + (targetPosition - basePosition)*0.8f); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), expectedPosition, TEST_LOCATION ); application.SendNotification(); - application.Render(static_cast(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/); + application.Render(static_cast(durationSeconds*200.0f) + 1u/*just beyond the animation duration*/); // We did expect the animation to finish application.SendNotification(); finishCheck.CheckSignalReceived(); - DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION ); // Check that nothing has changed after a couple of buffer swaps application.Render(0); - DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION ); application.Render(0); - DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationAnimateByFloatAlphaFunction(void) +int UtcDaliAnimationPlayDiscardHandleP(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(index), startValue, TEST_LOCATION ); // Build the animation float durationSeconds(1.0f); Animation animation = Animation::New(durationSeconds); - float targetValue(90.0f); - float relativeValue(targetValue - startValue); - animation.AnimateBy(Property(actor, index), relativeValue, AlphaFunctions::EaseOut); + Vector3 targetPosition(100.0f, 100.0f, 100.0f); + animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR); - float ninetyFivePercentProgress(startValue + relativeValue*0.95f); + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); // Start the animation animation.Play(); - bool signalReceived(false); - AnimationFinishCheck finishCheck(signalReceived); - animation.FinishedSignal().Connect(&application, finishCheck); + // 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(durationSeconds*950.0f)/* 95% progress */); + application.Render(static_cast(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(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 ); - // The position should have moved more, than with a linear alpha function - float current(actor.GetProperty(index)); - DALI_TEST_CHECK( current > ninetyFivePercentProgress ); + application.SendNotification(); + application.Render(static_cast(durationSeconds*200.0f)/* 60% progress */); + // We didn't expect the animation to finish yet application.SendNotification(); - application.Render(static_cast(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.6f), TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(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(durationSeconds*200.0f) + 1u/*just beyond the animation duration*/); // We did expect the animation to finish application.SendNotification(); finishCheck.CheckSignalReceived(); - DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION ); // Check that nothing has changed after a couple of buffer swaps application.Render(0); - DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION ); application.Render(0); - DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationAnimateByFloatTimePeriod(void) +int UtcDaliAnimationPlayStopDiscardHandleP(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(index), startValue, TEST_LOCATION ); // Build the animation float durationSeconds(1.0f); Animation animation = Animation::New(durationSeconds); - float targetValue(30.0f); - float relativeValue(targetValue - startValue); - float delay = 0.5f; - animation.AnimateBy(Property(actor, index), - relativeValue, - TimePeriod(delay, durationSeconds - delay)); + Vector3 targetPosition(100.0f, 100.0f, 100.0f); + animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR); // Start the animation animation.Play(); @@ -1877,227 +2203,247 @@ int UtcDaliAnimationAnimateByFloatTimePeriod(void) animation.FinishedSignal().Connect(&application, finishCheck); application.SendNotification(); - application.Render(static_cast(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */); + application.Render(static_cast(durationSeconds*200.0f)/* 20% progress */); // We didn't expect the animation to finish yet application.SendNotification(); finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + 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 ); application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */); + application.Render(static_cast(durationSeconds*200.0f)/* 40% progress */); + + // We expect the animation to finish at 20% progress + application.SendNotification(); + finishCheck.CheckSignalReceived(); + finishCheck.Reset(); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION ); - // We didn't expect the animation to finish yet + application.SendNotification(); + application.Render(static_cast(durationSeconds*200.0f)/* 60% progress */); + + // Check that nothing has changed application.SendNotification(); finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetProperty(index), startValue+(relativeValue*0.5f), TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION ); application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/); + application.Render(static_cast(durationSeconds*200.0f)/* 80% progress */); - // We did expect the animation to finish + // Check that nothing has changed application.SendNotification(); - finishCheck.CheckSignalReceived(); - DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION ); - // Check that nothing has changed after a couple of buffer swaps - application.Render(0); - DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); - application.Render(0); - DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + application.SendNotification(); + application.Render(static_cast(durationSeconds*200.0f)/* 100% progress */); + + // Check that nothing has changed + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationAnimateByFloatAlphaFunctionTimePeriod(void) +int UtcDaliAnimationPlayRangeP(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(index), startValue, TEST_LOCATION ); // Build the animation float durationSeconds(1.0f); Animation animation = Animation::New(durationSeconds); - float targetValue(30.0f); - float relativeValue(targetValue - startValue); - float delay = 0.5f; - animation.AnimateBy(Property(actor, index), - relativeValue, - AlphaFunctions::Linear, - TimePeriod(delay, durationSeconds - delay)); + 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 ) ); - // Start the animation + animation.AnimateBetween( Property( actor, Actor::Property::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(static_cast(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */); + 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(durationSeconds*200.0f)/* 60% progress */); // We didn't expect the animation to finish yet application.SendNotification(); finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); - - application.SendNotification(); - application.Render(static_cast(durationSeconds*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(index), startValue+(relativeValue*0.5f), TEST_LOCATION ); + 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(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/); + application.Render(static_cast(durationSeconds*200.0f) + 1u/* 80% progress */); // We did expect the animation to finish application.SendNotification(); finishCheck.CheckSignalReceived(); - DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + 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( actor.GetProperty(index), targetValue, TEST_LOCATION ); + DALI_TEST_EQUALS( targetPosition * 0.8f, actor.GetCurrentPosition(), TEST_LOCATION ); application.Render(0); - DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); - END_TEST; -} - -int UtcDaliAnimationAnimateByInteger(void) -{ - TestApplication application; - - Actor actor = Actor::New(); - - // Register an integer property - int startValue(1); - Property::Index index = actor.RegisterProperty( "test-property", startValue ); - Stage::GetCurrent().Add(actor); - DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); - - // Build the animation - float durationSeconds(2.0f); - Animation animation = Animation::New(durationSeconds); - int targetValue(50); - int relativeValue(targetValue - startValue); - animation.AnimateBy(Property(actor, index), relativeValue); + DALI_TEST_EQUALS( targetPosition * 0.8f, actor.GetCurrentPosition(), TEST_LOCATION ); - int ninetyFivePercentProgress(static_cast(startValue + relativeValue*0.95f + 0.5f)); - // Start the animation + //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(durationSeconds*intervalSeconds*1000.0f)); - bool signalReceived(false); - AnimationFinishCheck finishCheck(signalReceived); - animation.FinishedSignal().Connect(&application, finishCheck); + progress += intervalSeconds; + if (progress > 0.8f) + { + progress = progress - 0.4f; + } - application.SendNotification(); - application.Render(static_cast(durationSeconds*950.0f)/* 95% progress */); + DALI_TEST_EQUALS( targetPosition*progress, actor.GetCurrentPosition(), 0.001f, TEST_LOCATION ); + } // We didn't expect the animation to finish yet application.SendNotification(); finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetProperty(index), ninetyFivePercentProgress, TEST_LOCATION ); - application.SendNotification(); - application.Render(static_cast(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/); - // We did expect the animation to finish + //Test change range on the fly + animation.SetPlayRange( Vector2( 0.2f, 0.9f ) ); application.SendNotification(); - finishCheck.CheckSignalReceived(); - DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); - // Check that nothing has changed after a couple of buffer swaps - application.Render(0); - DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); - application.Render(0); - DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + for (int iterations = 0; iterations < 10; ++iterations ) + { + application.Render(static_cast(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 UtcDaliAnimationAnimateByIntegerAlphaFunction(void) +int UtcDaliAnimationPlayFromP(void) { TestApplication application; Actor actor = Actor::New(); - - // Register an integer property - int startValue(1); - Property::Index index = actor.RegisterProperty( "test-property", startValue ); Stage::GetCurrent().Add(actor); - DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); // Build the animation float durationSeconds(1.0f); Animation animation = Animation::New(durationSeconds); - int targetValue(90); - int relativeValue(targetValue - startValue); - animation.AnimateBy(Property(actor, index), relativeValue, AlphaFunctions::EaseOut); - - int ninetyFivePercentProgress(static_cast(startValue + relativeValue*0.95f + 0.5f)); + Vector3 targetPosition(100.0f, 100.0f, 100.0f); + animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR); - // Start the animation - animation.Play(); + // Start the animation from 40% progress + animation.PlayFrom( 0.4f ); bool signalReceived(false); AnimationFinishCheck finishCheck(signalReceived); animation.FinishedSignal().Connect(&application, finishCheck); application.SendNotification(); - application.Render(static_cast(durationSeconds*950.0f)/* 95% progress */); + application.Render(static_cast(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 ); - // The position should have moved more, than with a linear alpha function - int current(actor.GetProperty(index)); - DALI_TEST_CHECK( current > ninetyFivePercentProgress ); + animation.Play(); // Test that calling play has no effect, when animation is already playing + application.SendNotification(); + application.Render(static_cast(durationSeconds*200.0f)/* 80% progress */); + // We didn't expect the animation to finish yet application.SendNotification(); - application.Render(static_cast(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.8f), TEST_LOCATION ); + application.Render(static_cast(durationSeconds*200.0f) + 1u/*just beyond the animation duration*/); // We did expect the animation to finish application.SendNotification(); finishCheck.CheckSignalReceived(); - DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION ); // Check that nothing has changed after a couple of buffer swaps application.Render(0); - DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION ); application.Render(0); - DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationAnimateByIntegerTimePeriod(void) +int UtcDaliAnimationPlayFromN(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 ); + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + Vector3 targetPosition(100.0f, 100.0f, 100.0f); + animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR); + + //PlayFrom with an argument outside the range [0..1] will be ignored + animation.PlayFrom(-1.0f); + application.SendNotification(); + DALI_TEST_EQUALS(0.0f, animation.GetCurrentProgress(), TEST_LOCATION ); + + animation.PlayFrom(100.0f); + application.SendNotification(); + DALI_TEST_EQUALS(0.0f, animation.GetCurrentProgress(), TEST_LOCATION ); + END_TEST; +} + +int UtcDaliAnimationPauseP(void) +{ + TestApplication application; + + Actor actor = Actor::New(); Stage::GetCurrent().Add(actor); - DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); // Build the animation float durationSeconds(1.0f); Animation animation = Animation::New(durationSeconds); - int targetValue(30); - int relativeValue(targetValue - startValue); - float delay = 0.5f; - animation.AnimateBy(Property(actor, index), - relativeValue, - TimePeriod(delay, durationSeconds - delay)); + Vector3 targetPosition(100.0f, 100.0f, 100.0f); + animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR); + + Vector3 fiftyPercentProgress(targetPosition * 0.5f); // Start the animation animation.Play(); @@ -2107,119 +2453,161 @@ int UtcDaliAnimationAnimateByIntegerTimePeriod(void) animation.FinishedSignal().Connect(&application, finishCheck); application.SendNotification(); - application.Render(static_cast(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */); + application.Render(static_cast(durationSeconds*500.0f)/* 50% progress */); // We didn't expect the animation to finish yet application.SendNotification(); finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress, TEST_LOCATION ); + // Pause the animation + animation.Pause(); application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */); + + // Loop 5 times + for (int i=0; i<5; ++i) + { + application.Render(static_cast(durationSeconds*500.0f)); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress/* Still 50% progress when paused */, TEST_LOCATION ); + } + + // Keep going + animation.Play(); + application.SendNotification(); + application.Render(static_cast(durationSeconds*490.0f)/*slightly less than the animation duration*/); // We didn't expect the animation to finish yet application.SendNotification(); finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetProperty(index), static_cast(startValue+(relativeValue*0.5f)+0.5f), TEST_LOCATION ); application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/); + application.Render(static_cast(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(index), targetValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION ); // Check that nothing has changed after a couple of buffer swaps application.Render(0); - DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION ); application.Render(0); - DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationAnimateByIntegerAlphaFunctionTimePeriod(void) + +int UtcDaliAnimationGetStateP(void) { TestApplication application; Actor actor = Actor::New(); - - // Register an integer property - int startValue(10); - Property::Index index = actor.RegisterProperty( "test-property", startValue ); Stage::GetCurrent().Add(actor); - DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); // Build the animation float durationSeconds(1.0f); Animation animation = Animation::New(durationSeconds); - int targetValue(30); - int relativeValue(targetValue - startValue); - float delay = 0.5f; - animation.AnimateBy(Property(actor, index), - relativeValue, - AlphaFunctions::Linear, - TimePeriod(delay, durationSeconds - delay)); + Vector3 targetPosition(100.0f, 100.0f, 100.0f); + animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR); + DALI_TEST_EQUALS( animation.GetState(), Animation::STOPPED, TEST_LOCATION ); + + Vector3 fiftyPercentProgress(targetPosition * 0.5f); // Start the animation animation.Play(); + DALI_TEST_EQUALS( animation.GetState(), Animation::PLAYING, TEST_LOCATION ); + bool signalReceived(false); AnimationFinishCheck finishCheck(signalReceived); animation.FinishedSignal().Connect(&application, finishCheck); application.SendNotification(); - application.Render(static_cast(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */); + application.Render(static_cast(durationSeconds*500.0f)/* 50% progress */); // We didn't expect the animation to finish yet application.SendNotification(); finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( animation.GetState(), Animation::PLAYING, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress, TEST_LOCATION ); + // Pause the animation + animation.Pause(); + DALI_TEST_EQUALS( animation.GetState(), Animation::PAUSED, TEST_LOCATION ); application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */); + application.Render(0.f); + + // Loop 5 times + for (int i=0; i<5; ++i) + { + application.Render(static_cast(durationSeconds*500.0f)); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress/* Still 50% progress when paused */, TEST_LOCATION ); + DALI_TEST_EQUALS( animation.GetState(), Animation::PAUSED, TEST_LOCATION ); + } + // Keep going + finishCheck.Reset(); + animation.Play(); + DALI_TEST_EQUALS( animation.GetState(), Animation::PLAYING, TEST_LOCATION ); + application.SendNotification(); + application.Render(static_cast(durationSeconds*490.0f)/*slightly less than the animation duration*/); // We didn't expect the animation to finish yet application.SendNotification(); finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetProperty(index), static_cast(startValue+(relativeValue*0.5f)+0.5f), TEST_LOCATION ); + DALI_TEST_EQUALS( animation.GetState(), Animation::PLAYING, TEST_LOCATION ); application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/); + application.Render(static_cast(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(index), targetValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION ); + DALI_TEST_EQUALS( animation.GetState(), Animation::STOPPED, TEST_LOCATION ); // Check that nothing has changed after a couple of buffer swaps application.Render(0); - DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION ); application.Render(0); - DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION ); + DALI_TEST_EQUALS( animation.GetState(), Animation::STOPPED, TEST_LOCATION ); + + // re-play + finishCheck.Reset(); + animation.Play(); + DALI_TEST_EQUALS( animation.GetState(), Animation::PLAYING, TEST_LOCATION ); + application.SendNotification(); + application.Render(static_cast(durationSeconds*490.0f)/*slightly less than the animation duration*/); + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( animation.GetState(), Animation::PLAYING, TEST_LOCATION ); + + END_TEST; } -int UtcDaliAnimationAnimateByVector2(void) +int UtcDaliAnimationStopP(void) { TestApplication application; Actor actor = Actor::New(); - - // Register a Vector2 property - Vector2 startValue(10.0f, 10.0f); - Property::Index index = actor.RegisterProperty( "test-property", startValue ); Stage::GetCurrent().Add(actor); - DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); // Build the animation - float durationSeconds(2.0f); + float durationSeconds(1.0f); Animation animation = Animation::New(durationSeconds); - Vector2 targetValue(60.0f, 60.0f); - Vector2 relativeValue(targetValue - startValue); - animation.AnimateBy(Property(actor, index), relativeValue); + Vector3 targetPosition(100.0f, 100.0f, 100.0f); + animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR); - Vector2 ninetyFivePercentProgress(startValue + relativeValue*0.95f); + Vector3 fiftyPercentProgress(targetPosition * 0.5f); // Start the animation animation.Play(); @@ -2229,49 +2617,47 @@ int UtcDaliAnimationAnimateByVector2(void) animation.FinishedSignal().Connect(&application, finishCheck); application.SendNotification(); - application.Render(static_cast(durationSeconds*950.0f)/* 95% progress */); + application.Render(static_cast(durationSeconds*500.0f)/* 50% progress */); // We didn't expect the animation to finish yet application.SendNotification(); finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetProperty(index), ninetyFivePercentProgress, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress, TEST_LOCATION ); + // Stop the animation + animation.Stop(); application.SendNotification(); - application.Render(static_cast(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/); - // We did expect the animation to finish - application.SendNotification(); - finishCheck.CheckSignalReceived(); - DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + // Loop 5 times + for (int i=0; i<5; ++i) + { + application.Render(static_cast(durationSeconds*500.0f)); - // Check that nothing has changed after a couple of buffer swaps - application.Render(0); - DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); - application.Render(0); - DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress/* Still 50% progress when stopped */, TEST_LOCATION ); + } END_TEST; } -int UtcDaliAnimationAnimateByVector2AlphaFunction(void) +int UtcDaliAnimationStopSetPositionP(void) { + // Test that Animation::Stop & Actor::SetPosition can be used in conjunction + // i.e. to check that the animation does not interfere with the position set. + TestApplication application; Actor actor = Actor::New(); - - // Register a Vector2 property - Vector2 startValue(100.0f, 100.0f); - Property::Index index = actor.RegisterProperty( "test-property", startValue ); Stage::GetCurrent().Add(actor); - DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); // Build the animation float durationSeconds(1.0f); Animation animation = Animation::New(durationSeconds); - Vector2 targetValue(20.0f, 20.0f); - Vector2 relativeValue(targetValue - startValue); - animation.AnimateBy(Property(actor, index), relativeValue, AlphaFunctions::EaseOut); + Vector3 targetPosition(100.0f, 100.0f, 100.0f); + animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR); - Vector2 ninetyFivePercentProgress(startValue + relativeValue*0.95f); + Vector3 fiftyPercentProgress(targetPosition * 0.5f); // Start the animation animation.Play(); @@ -2281,54 +2667,46 @@ int UtcDaliAnimationAnimateByVector2AlphaFunction(void) animation.FinishedSignal().Connect(&application, finishCheck); application.SendNotification(); - application.Render(static_cast(durationSeconds*950.0f)/* 95% progress */); + application.Render(static_cast(durationSeconds*500.0f)/* 50% progress */); // We didn't expect the animation to finish yet application.SendNotification(); finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress, TEST_LOCATION ); - // The position should have moved more, than with a linear alpha function - Vector2 current(actor.GetProperty(index)); - DALI_TEST_CHECK( current.x < ninetyFivePercentProgress.x ); - DALI_TEST_CHECK( current.y < ninetyFivePercentProgress.y ); - + // Stop the animation + animation.Stop(); + Vector3 positionSet(2.0f, 3.0f, 4.0f); + actor.SetPosition(positionSet); application.SendNotification(); - application.Render(static_cast(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/); - // We did expect the animation to finish - application.SendNotification(); - finishCheck.CheckSignalReceived(); - DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + // Loop 5 times + for (int i=0; i<5; ++i) + { + application.Render(static_cast(durationSeconds*500.0f)); - // Check that nothing has changed after a couple of buffer swaps - application.Render(0); - DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); - application.Render(0); - DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), positionSet/*Animation should not interfere with this*/, TEST_LOCATION ); + } END_TEST; } -int UtcDaliAnimationAnimateByVector2TimePeriod(void) +int UtcDaliAnimationClearP(void) { TestApplication application; Actor actor = Actor::New(); - - // Register a Vector2 property - Vector2 startValue(10.0f, 10.0f); - Property::Index index = actor.RegisterProperty( "test-property", startValue ); Stage::GetCurrent().Add(actor); - DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); // Build the animation float durationSeconds(1.0f); Animation animation = Animation::New(durationSeconds); - Vector2 targetValue(30.0f, 30.0f); - Vector2 relativeValue(targetValue - startValue); - float delay = 0.5f; - animation.AnimateBy(Property(actor, index), - relativeValue, - TimePeriod(delay, durationSeconds - delay)); + Vector3 targetPosition(100.0f, 100.0f, 100.0f); + animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR); + + Vector3 fiftyPercentProgress(targetPosition * 0.5f); // Start the animation animation.Play(); @@ -2338,61 +2716,57 @@ int UtcDaliAnimationAnimateByVector2TimePeriod(void) animation.FinishedSignal().Connect(&application, finishCheck); application.SendNotification(); - application.Render(static_cast(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */); + application.Render(static_cast(durationSeconds*500.0f)/* 50% progress */); // We didn't expect the animation to finish yet application.SendNotification(); finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress, TEST_LOCATION ); + // Clear the animation + animation.Clear(); application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */); - // We didn't expect the animation to finish yet + application.Render(static_cast(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/); + + // We don't expect the animation to finish now application.SendNotification(); finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetProperty(index), startValue+(relativeValue*0.5f), TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress/* Still 50% progress since the animator was destroyed */, TEST_LOCATION ); + + // Restart as a scale animation; this should not move the actor's position + finishCheck.Reset(); + actor.SetPosition(Vector3::ZERO); + Vector3 targetScale(3.0f, 3.0f, 3.0f); + animation.AnimateTo( Property( actor, Actor::Property::SCALE ), targetScale, AlphaFunction::LINEAR ); + animation.Play(); application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/); + application.Render(static_cast(durationSeconds*500.0f)/* 50% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO/*Check move-animator was destroyed*/, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3(2.0f, 2.0f, 2.0f), TEST_LOCATION ); + + application.Render(static_cast(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/); // We did expect the animation to finish application.SendNotification(); finishCheck.CheckSignalReceived(); - DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); - - // Check that nothing has changed after a couple of buffer swaps - application.Render(0); - DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); - application.Render(0); - DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO/*Check move-animator was destroyed*/, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationAnimateByVector2AlphaFunctionTimePeriod(void) +int UtcDaliAnimationFinishedSignalP(void) { TestApplication application; - Actor actor = Actor::New(); - - // Register a Vector2 property - Vector2 startValue(5.0f, 5.0f); - Property::Index index = actor.RegisterProperty( "test-property", startValue ); - Stage::GetCurrent().Add(actor); - DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); - - // Build the animation + // Start the empty animation float durationSeconds(1.0f); Animation animation = Animation::New(durationSeconds); - Vector2 targetValue(10.0f, 10.0f); - Vector2 relativeValue(targetValue - startValue); - float delay = 0.5f; - animation.AnimateBy(Property(actor, index), - relativeValue, - AlphaFunctions::Linear, - TimePeriod(delay, durationSeconds - delay)); - - // Start the animation animation.Play(); bool signalReceived(false); @@ -2400,58 +2774,33 @@ int UtcDaliAnimationAnimateByVector2AlphaFunctionTimePeriod(void) animation.FinishedSignal().Connect(&application, finishCheck); application.SendNotification(); - application.Render(static_cast(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.GetProperty(index), startValue, TEST_LOCATION ); - - application.SendNotification(); - application.Render(static_cast(durationSeconds*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(index), startValue+(relativeValue*0.5f), TEST_LOCATION ); - - application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/); + application.Render(static_cast(durationSeconds*1000.0f) + 1u/*beyond the animation duration*/); // We did expect the animation to finish application.SendNotification(); finishCheck.CheckSignalReceived(); - DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); - - // Check that nothing has changed after a couple of buffer swaps - application.Render(0); - DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); - application.Render(0); - DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationAnimateByVector3(void) +int UtcDaliAnimationAnimateByBooleanP(void) { TestApplication application; Actor actor = Actor::New(); - // Register a Vector3 property - Vector3 startValue(10.0f, 10.0f, 10.0f); - Property::Index index = actor.RegisterProperty( "test-property", startValue ); + // Register a boolean property + bool startValue(false); + Property::Index index = actor.RegisterProperty( "testProperty", startValue ); Stage::GetCurrent().Add(actor); - DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + DALI_TEST_CHECK( actor.GetProperty(index) == startValue ); // Build the animation float durationSeconds(2.0f); Animation animation = Animation::New(durationSeconds); - Vector3 targetValue(60.0f, 60.0f, 60.0f); - Vector3 relativeValue(targetValue - startValue); + const bool relativeValue(true); + const bool finalValue( false || relativeValue ); animation.AnimateBy(Property(actor, index), relativeValue); - Vector3 ninetyFivePercentProgress(startValue + relativeValue*0.95f); - // Start the animation animation.Play(); @@ -2465,7 +2814,7 @@ int UtcDaliAnimationAnimateByVector3(void) // We didn't expect the animation to finish yet application.SendNotification(); finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetProperty(index), ninetyFivePercentProgress, TEST_LOCATION ); + DALI_TEST_CHECK( actor.GetProperty(index) == startValue ); application.SendNotification(); application.Render(static_cast(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/); @@ -2473,42 +2822,23 @@ int UtcDaliAnimationAnimateByVector3(void) // We did expect the animation to finish application.SendNotification(); finishCheck.CheckSignalReceived(); - DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + DALI_TEST_CHECK( actor.GetProperty(index) == finalValue ); // Check that nothing has changed after a couple of buffer swaps application.Render(0); - DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + DALI_TEST_CHECK( actor.GetProperty(index) == finalValue ); application.Render(0); - DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); - END_TEST; -} - -int UtcDaliAnimationAnimateByVector3AlphaFunction(void) -{ - TestApplication application; - - Actor actor = Actor::New(); - - // Register a Vector3 property - Vector3 startValue(100.0f, 100.0f, 100.0f); - Property::Index index = actor.RegisterProperty( "test-property", startValue ); - Stage::GetCurrent().Add(actor); - DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); - - // Build the animation - float durationSeconds(1.0f); - Animation animation = Animation::New(durationSeconds); - Vector3 targetValue(20.0f, 20.0f, 20.0f); - Vector3 relativeValue(targetValue - startValue); - animation.AnimateBy(Property(actor, index), relativeValue, AlphaFunctions::EaseOut); + DALI_TEST_CHECK( actor.GetProperty(index) == finalValue ); - Vector3 ninetyFivePercentProgress(startValue + relativeValue*0.95f); + // Repeat with relative value "false" - this should be an NOOP + animation = Animation::New(durationSeconds); + bool noOpValue(false); + animation.AnimateBy(Property(actor, index), noOpValue); // Start the animation animation.Play(); - bool signalReceived(false); - AnimationFinishCheck finishCheck(signalReceived); + finishCheck.Reset(); animation.FinishedSignal().Connect(&application, finishCheck); application.SendNotification(); @@ -2517,12 +2847,7 @@ int UtcDaliAnimationAnimateByVector3AlphaFunction(void) // We didn't expect the animation to finish yet application.SendNotification(); finishCheck.CheckSignalNotReceived(); - - // The position should have moved more, than with a linear alpha function - Vector3 current(actor.GetProperty(index)); - DALI_TEST_CHECK( current.x < ninetyFivePercentProgress.x ); - DALI_TEST_CHECK( current.y < ninetyFivePercentProgress.y ); - DALI_TEST_CHECK( current.z < ninetyFivePercentProgress.z ); + DALI_TEST_CHECK( actor.GetProperty(index) == finalValue ); application.SendNotification(); application.Render(static_cast(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/); @@ -2530,37 +2855,34 @@ int UtcDaliAnimationAnimateByVector3AlphaFunction(void) // We did expect the animation to finish application.SendNotification(); finishCheck.CheckSignalReceived(); - DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + DALI_TEST_CHECK( actor.GetProperty(index) == finalValue ); // Check that nothing has changed after a couple of buffer swaps application.Render(0); - DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + DALI_TEST_CHECK( actor.GetProperty(index) == finalValue ); application.Render(0); - DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + DALI_TEST_CHECK( actor.GetProperty(index) == finalValue ); END_TEST; } -int UtcDaliAnimationAnimateByVector3TimePeriod(void) +int UtcDaliAnimationAnimateByBooleanAlphaFunctionP(void) { TestApplication application; Actor actor = Actor::New(); - // Register a Vector3 property - Vector3 startValue(10.0f, 10.0f, 10.0f); - Property::Index index = actor.RegisterProperty( "test-property", startValue ); + // Register a boolean property + bool startValue(false); + Property::Index index = actor.RegisterProperty( "testProperty", startValue ); Stage::GetCurrent().Add(actor); - DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + DALI_TEST_CHECK( actor.GetProperty(index) == startValue ); // Build the animation - float durationSeconds(1.0f); + float durationSeconds(2.0f); Animation animation = Animation::New(durationSeconds); - Vector3 targetValue(30.0f, 30.0f, 30.0f); - Vector3 relativeValue(targetValue - startValue); - float delay = 0.5f; - animation.AnimateBy(Property(actor, index), - relativeValue, - TimePeriod(delay, durationSeconds - delay)); + bool relativeValue(true); + bool finalValue( false || relativeValue ); + animation.AnimateBy(Property(actor, index), relativeValue, AlphaFunction::EASE_IN); // Start the animation animation.Play(); @@ -2570,59 +2892,77 @@ int UtcDaliAnimationAnimateByVector3TimePeriod(void) animation.FinishedSignal().Connect(&application, finishCheck); application.SendNotification(); - application.Render(static_cast(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.GetProperty(index), startValue, TEST_LOCATION ); - - application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */); + application.Render(static_cast(durationSeconds*950.0f)/* 95% progress */); // We didn't expect the animation to finish yet application.SendNotification(); finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetProperty(index), startValue+(relativeValue*0.5f), TEST_LOCATION ); + DALI_TEST_CHECK( actor.GetProperty(index) == startValue ); application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/); + application.Render(static_cast(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/); // We did expect the animation to finish application.SendNotification(); finishCheck.CheckSignalReceived(); - DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + DALI_TEST_CHECK( actor.GetProperty(index) == finalValue ); // Check that nothing has changed after a couple of buffer swaps application.Render(0); - DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + DALI_TEST_CHECK( actor.GetProperty(index) == finalValue ); application.Render(0); - DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); - END_TEST; -} + DALI_TEST_CHECK( actor.GetProperty(index) == finalValue ); -int UtcDaliAnimationAnimateByVector3AlphaFunctionTimePeriod(void) -{ - TestApplication application; + // Repeat with relative value "false" - this should be an NOOP + animation = Animation::New(durationSeconds); + bool noOpValue(false); + animation.AnimateBy(Property(actor, index), noOpValue, AlphaFunction::EASE_IN); - Actor actor = Actor::New(); + // Start the animation + animation.Play(); - // Register a Vector3 property - Vector3 startValue(5.0f, 5.0f, 5.0f); - Property::Index index = actor.RegisterProperty( "test-property", startValue ); - Stage::GetCurrent().Add(actor); - DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + finishCheck.Reset(); + animation.FinishedSignal().Connect(&application, finishCheck); - // Build the animation - float durationSeconds(1.0f); - Animation animation = Animation::New(durationSeconds); - Vector3 targetValue(10.0f, 10.0f, 10.0f); - Vector3 relativeValue(targetValue - startValue); - float delay = 0.5f; - animation.AnimateBy(Property(actor, index), - relativeValue, - AlphaFunctions::Linear, - TimePeriod(delay, durationSeconds - delay)); + application.SendNotification(); + application.Render(static_cast(durationSeconds*950.0f)/* 95% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_CHECK( actor.GetProperty(index) == finalValue ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_CHECK( actor.GetProperty(index) == finalValue ); + END_TEST; +} + +int UtcDaliAnimationAnimateByBooleanTimePeriodP(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + + // Register a boolean property + bool startValue(false); + Property::Index index = actor.RegisterProperty( "testProperty", startValue ); + Stage::GetCurrent().Add(actor); + DALI_TEST_CHECK( actor.GetProperty(index) == startValue ); + + // Build the animation + float durationSeconds(2.0f); + Animation animation = Animation::New(durationSeconds); + bool relativeValue(true); + bool finalValue( false || relativeValue ); + float animatorDurationSeconds(durationSeconds * 0.5f); + animation.AnimateBy( Property(actor, index), + relativeValue, + TimePeriod( animatorDurationSeconds ) ); // Start the animation animation.Play(); @@ -2632,57 +2972,123 @@ int UtcDaliAnimationAnimateByVector3AlphaFunctionTimePeriod(void) animation.FinishedSignal().Connect(&application, finishCheck); application.SendNotification(); - application.Render(static_cast(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */); + application.Render(static_cast(animatorDurationSeconds*950.0f)/* 95% animator progress */); // We didn't expect the animation to finish yet application.SendNotification(); finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + DALI_TEST_CHECK( actor.GetProperty(index) == startValue ); application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */); + application.Render(static_cast(animatorDurationSeconds*50.0f) + 1u/*just beyond the animator duration*/); + + // We didn't expect the animation to finish yet... + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + + // ...however we should have reached the final value + DALI_TEST_CHECK( actor.GetProperty(index) == finalValue ); + + application.SendNotification(); + application.Render(static_cast(animatorDurationSeconds*1000.0f)/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_CHECK( actor.GetProperty(index) == finalValue ); + + // Check that nothing has changed after a couple of buffer swaps + application.Render(0); + DALI_TEST_CHECK( actor.GetProperty(index) == finalValue ); + application.Render(0); + DALI_TEST_CHECK( actor.GetProperty(index) == finalValue ); + END_TEST; +} + +int UtcDaliAnimationAnimateByBooleanAlphaFunctionTimePeriodP(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + + // Register a boolean property + bool startValue(false); + Property::Index index = actor.RegisterProperty( "testProperty", startValue ); + Stage::GetCurrent().Add(actor); + DALI_TEST_CHECK( actor.GetProperty(index) == startValue ); + + // Build the animation + float durationSeconds(2.0f); + Animation animation = Animation::New(durationSeconds); + bool relativeValue(true); + bool finalValue( false || relativeValue ); + float animatorDurationSeconds(durationSeconds * 0.5f); + animation.AnimateBy( Property(actor, index), + relativeValue, + AlphaFunction::EASE_IN_OUT, + TimePeriod( animatorDurationSeconds ) ); + + // Start the animation + animation.Play(); + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + + application.SendNotification(); + application.Render(static_cast(animatorDurationSeconds*950.0f)/* 95% animator progress */); // We didn't expect the animation to finish yet application.SendNotification(); finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetProperty(index), startValue+(relativeValue*0.5f), TEST_LOCATION ); + DALI_TEST_CHECK( actor.GetProperty(index) == startValue ); application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/); + application.Render(static_cast(animatorDurationSeconds*50.0f) + 1u/*just beyond the animator duration*/); + + // We didn't expect the animation to finish yet... + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + + // ...however we should have reached the final value + DALI_TEST_CHECK( actor.GetProperty(index) == finalValue ); + + application.SendNotification(); + application.Render(static_cast(animatorDurationSeconds*1000.0f)/*just beyond the animation duration*/); // We did expect the animation to finish application.SendNotification(); finishCheck.CheckSignalReceived(); - DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + DALI_TEST_CHECK( actor.GetProperty(index) == finalValue ); // Check that nothing has changed after a couple of buffer swaps application.Render(0); - DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + DALI_TEST_CHECK( actor.GetProperty(index) == finalValue ); application.Render(0); - DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + DALI_TEST_CHECK( actor.GetProperty(index) == finalValue ); END_TEST; } -int UtcDaliAnimationAnimateByVector4(void) +int UtcDaliAnimationAnimateByFloatP(void) { TestApplication application; Actor actor = Actor::New(); - // Register a Vector4 property - Vector4 startValue(10.0f, 10.0f, 10.0f, 10.0f); - Property::Index index = actor.RegisterProperty( "test-property", startValue ); + // Register a float property + float startValue(10.0f); + Property::Index index = actor.RegisterProperty( "testProperty", startValue ); Stage::GetCurrent().Add(actor); - DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); // Build the animation float durationSeconds(2.0f); Animation animation = Animation::New(durationSeconds); - Vector4 targetValue(60.0f, 60.0f, 60.0f, 60.0f); - Vector4 relativeValue(targetValue - startValue); + float targetValue(50.0f); + float relativeValue(targetValue - startValue); animation.AnimateBy(Property(actor, index), relativeValue); - Vector4 ninetyFivePercentProgress(startValue + relativeValue*0.95f); + float ninetyFivePercentProgress(startValue + relativeValue*0.95f); // Start the animation animation.Play(); @@ -2697,7 +3103,7 @@ int UtcDaliAnimationAnimateByVector4(void) // We didn't expect the animation to finish yet application.SendNotification(); finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetProperty(index), ninetyFivePercentProgress, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(index), ninetyFivePercentProgress, TEST_LOCATION ); application.SendNotification(); application.Render(static_cast(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/); @@ -2705,36 +3111,36 @@ int UtcDaliAnimationAnimateByVector4(void) // We did expect the animation to finish application.SendNotification(); finishCheck.CheckSignalReceived(); - DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); // Check that nothing has changed after a couple of buffer swaps application.Render(0); - DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); application.Render(0); - DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationAnimateByVector4AlphaFunction(void) +int UtcDaliAnimationAnimateByFloatAlphaFunctionP(void) { TestApplication application; Actor actor = Actor::New(); - // Register a Vector4 property - Vector4 startValue(100.0f, 100.0f, 100.0f, 100.0f); - Property::Index index = actor.RegisterProperty( "test-property", startValue ); + // Register a float property + float startValue(10.0f); + Property::Index index = actor.RegisterProperty( "testProperty", startValue ); Stage::GetCurrent().Add(actor); - DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); // Build the animation float durationSeconds(1.0f); Animation animation = Animation::New(durationSeconds); - Vector4 targetValue(20.0f, 20.0f, 20.0f, 20.0f); - Vector4 relativeValue(targetValue - startValue); - animation.AnimateBy(Property(actor, index), relativeValue, AlphaFunctions::EaseOut); + float targetValue(90.0f); + float relativeValue(targetValue - startValue); + animation.AnimateBy(Property(actor, index), relativeValue, AlphaFunction::EASE_OUT); - Vector4 ninetyFivePercentProgress(startValue + relativeValue*0.95f); + float ninetyFivePercentProgress(startValue + relativeValue*0.95f); // Start the animation animation.Play(); @@ -2751,11 +3157,8 @@ int UtcDaliAnimationAnimateByVector4AlphaFunction(void) finishCheck.CheckSignalNotReceived(); // The position should have moved more, than with a linear alpha function - Vector4 current(actor.GetProperty(index)); - DALI_TEST_CHECK( current.x < ninetyFivePercentProgress.x ); - DALI_TEST_CHECK( current.y < ninetyFivePercentProgress.y ); - DALI_TEST_CHECK( current.z < ninetyFivePercentProgress.z ); - DALI_TEST_CHECK( current.w < ninetyFivePercentProgress.w ); + float current(actor.GetProperty(index)); + DALI_TEST_CHECK( current > ninetyFivePercentProgress ); application.SendNotification(); application.Render(static_cast(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/); @@ -2763,33 +3166,33 @@ int UtcDaliAnimationAnimateByVector4AlphaFunction(void) // We did expect the animation to finish application.SendNotification(); finishCheck.CheckSignalReceived(); - DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); // Check that nothing has changed after a couple of buffer swaps application.Render(0); - DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); application.Render(0); - DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationAnimateByVector4TimePeriod(void) +int UtcDaliAnimationAnimateByFloatTimePeriodP(void) { TestApplication application; Actor actor = Actor::New(); - // Register a Vector4 property - Vector4 startValue(10.0f, 10.0f, 10.0f, 10.0f); - Property::Index index = actor.RegisterProperty( "test-property", startValue ); + // Register a float property + float startValue(10.0f); + Property::Index index = actor.RegisterProperty( "testProperty", startValue ); Stage::GetCurrent().Add(actor); - DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); // Build the animation float durationSeconds(1.0f); Animation animation = Animation::New(durationSeconds); - Vector4 targetValue(30.0f, 30.0f, 30.0f, 30.0f); - Vector4 relativeValue(targetValue - startValue); + float targetValue(30.0f); + float relativeValue(targetValue - startValue); float delay = 0.5f; animation.AnimateBy(Property(actor, index), relativeValue, @@ -2808,7 +3211,7 @@ int UtcDaliAnimationAnimateByVector4TimePeriod(void) // We didn't expect the animation to finish yet application.SendNotification(); finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); application.SendNotification(); application.Render(static_cast(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */); @@ -2816,7 +3219,7 @@ int UtcDaliAnimationAnimateByVector4TimePeriod(void) // We didn't expect the animation to finish yet application.SendNotification(); finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetProperty(index), startValue+(relativeValue*0.5f), TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue+(relativeValue*0.5f), TEST_LOCATION ); application.SendNotification(); application.Render(static_cast(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/); @@ -2824,37 +3227,37 @@ int UtcDaliAnimationAnimateByVector4TimePeriod(void) // We did expect the animation to finish application.SendNotification(); finishCheck.CheckSignalReceived(); - DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); // Check that nothing has changed after a couple of buffer swaps application.Render(0); - DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); application.Render(0); - DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationAnimateByVector4AlphaFunctionTimePeriod(void) +int UtcDaliAnimationAnimateByFloatAlphaFunctionTimePeriodP(void) { TestApplication application; Actor actor = Actor::New(); - // Register a Vector4 property - Vector4 startValue(5.0f, 5.0f, 5.0f, 5.0f); - Property::Index index = actor.RegisterProperty( "test-property", startValue ); + // Register a float property + float startValue(10.0f); + Property::Index index = actor.RegisterProperty( "testProperty", startValue ); Stage::GetCurrent().Add(actor); - DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); // Build the animation float durationSeconds(1.0f); Animation animation = Animation::New(durationSeconds); - Vector4 targetValue(10.0f, 10.0f, 10.0f, 10.0f); - Vector4 relativeValue(targetValue - startValue); + float targetValue(30.0f); + float relativeValue(targetValue - startValue); float delay = 0.5f; animation.AnimateBy(Property(actor, index), relativeValue, - AlphaFunctions::Linear, + AlphaFunction::LINEAR, TimePeriod(delay, durationSeconds - delay)); // Start the animation @@ -2870,7 +3273,7 @@ int UtcDaliAnimationAnimateByVector4AlphaFunctionTimePeriod(void) // We didn't expect the animation to finish yet application.SendNotification(); finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); application.SendNotification(); application.Render(static_cast(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */); @@ -2878,7 +3281,7 @@ int UtcDaliAnimationAnimateByVector4AlphaFunctionTimePeriod(void) // We didn't expect the animation to finish yet application.SendNotification(); finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetProperty(index), startValue+(relativeValue*0.5f), TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue+(relativeValue*0.5f), TEST_LOCATION ); application.SendNotification(); application.Render(static_cast(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/); @@ -2886,36 +3289,36 @@ int UtcDaliAnimationAnimateByVector4AlphaFunctionTimePeriod(void) // We did expect the animation to finish application.SendNotification(); finishCheck.CheckSignalReceived(); - DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); // Check that nothing has changed after a couple of buffer swaps application.Render(0); - DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); application.Render(0); - DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationAnimateByActorPosition(void) +int UtcDaliAnimationAnimateByIntegerP(void) { TestApplication application; Actor actor = Actor::New(); - Vector3 startPosition(10.0f, 10.0f, 10.0f); - actor.SetPosition(startPosition); + + // Register an integer property + int startValue(1); + Property::Index index = actor.RegisterProperty( "testProperty", startValue ); Stage::GetCurrent().Add(actor); - application.SendNotification(); - application.Render(0); - DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); // Build the animation - float durationSeconds(1.0f); + float durationSeconds(2.0f); Animation animation = Animation::New(durationSeconds); - Vector3 targetPosition(20.0f, 20.0f, 20.0f); - Vector3 relativePosition(targetPosition - startPosition); - animation.AnimateBy(Property(actor, Actor::POSITION), relativePosition); + int targetValue(50); + int relativeValue(targetValue - startValue); + animation.AnimateBy(Property(actor, index), relativeValue); - Vector3 ninetyFivePercentProgress(startPosition + relativePosition*0.95f); + int ninetyFivePercentProgress(static_cast(startValue + relativeValue*0.95f + 0.5f)); // Start the animation animation.Play(); @@ -2930,7 +3333,7 @@ int UtcDaliAnimationAnimateByActorPosition(void) // We didn't expect the animation to finish yet application.SendNotification(); finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetCurrentPosition(), ninetyFivePercentProgress, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(index), ninetyFivePercentProgress, TEST_LOCATION ); application.SendNotification(); application.Render(static_cast(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/); @@ -2938,36 +3341,36 @@ int UtcDaliAnimationAnimateByActorPosition(void) // We did expect the animation to finish application.SendNotification(); finishCheck.CheckSignalReceived(); - DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); // Check that nothing has changed after a couple of buffer swaps application.Render(0); - DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); application.Render(0); - DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationAnimateByActorPositionAlphaFunction(void) +int UtcDaliAnimationAnimateByIntegerAlphaFunctionP(void) { TestApplication application; Actor actor = Actor::New(); - Vector3 startPosition(10.0f, 10.0f, 10.0f); - actor.SetPosition(startPosition); + + // Register an integer property + int startValue(1); + Property::Index index = actor.RegisterProperty( "testProperty", startValue ); Stage::GetCurrent().Add(actor); - application.SendNotification(); - application.Render(0); - DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, 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.AnimateBy(Property(actor, Actor::POSITION), relativePosition, AlphaFunctions::EaseOut); + int targetValue(90); + int relativeValue(targetValue - startValue); + animation.AnimateBy(Property(actor, index), relativeValue, AlphaFunction::EASE_OUT); - Vector3 ninetyFivePercentProgress(startPosition + relativePosition*0.95f); + int ninetyFivePercentProgress(static_cast(startValue + relativeValue*0.95f + 0.5f)); // Start the animation animation.Play(); @@ -2984,10 +3387,8 @@ int UtcDaliAnimationAnimateByActorPositionAlphaFunction(void) finishCheck.CheckSignalNotReceived(); // The position should have moved more, than with a linear alpha function - Vector3 current(actor.GetCurrentPosition()); - DALI_TEST_CHECK( current.x > ninetyFivePercentProgress.x ); - DALI_TEST_CHECK( current.y > ninetyFivePercentProgress.y ); - DALI_TEST_CHECK( current.z > ninetyFivePercentProgress.z ); + int current(actor.GetProperty(index)); + DALI_TEST_CHECK( current > ninetyFivePercentProgress ); application.SendNotification(); application.Render(static_cast(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/); @@ -2995,40 +3396,38 @@ int UtcDaliAnimationAnimateByActorPositionAlphaFunction(void) // We did expect the animation to finish application.SendNotification(); finishCheck.CheckSignalReceived(); - DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); // Check that nothing has changed after a couple of buffer swaps application.Render(0); - DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); application.Render(0); - DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationAnimateByActorPositionTimePeriod(void) +int UtcDaliAnimationAnimateByIntegerTimePeriodP(void) { TestApplication application; Actor actor = Actor::New(); - Vector3 startPosition(10.0f, 10.0f, 10.0f); - actor.SetPosition(startPosition); + + // Register an integer property + int startValue(10); + Property::Index index = actor.RegisterProperty( "testProperty", startValue ); Stage::GetCurrent().Add(actor); - application.SendNotification(); - application.Render(0); - DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, 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); + int targetValue(30); + int relativeValue(targetValue - startValue); float delay = 0.5f; - animation.AnimateBy(Property(actor, Actor::POSITION), - relativePosition, + animation.AnimateBy(Property(actor, index), + relativeValue, TimePeriod(delay, durationSeconds - delay)); - Vector3 ninetyFivePercentProgress(startPosition + relativePosition*0.95f); - // Start the animation animation.Play(); @@ -3042,49 +3441,55 @@ int UtcDaliAnimationAnimateByActorPositionTimePeriod(void) // We didn't expect the animation to finish yet application.SendNotification(); finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); application.SendNotification(); - application.Render(static_cast(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/); + application.Render(static_cast(durationSeconds*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(index), static_cast(startValue+(relativeValue*0.5f)+0.5f), TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(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(), targetPosition, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); // Check that nothing has changed after a couple of buffer swaps application.Render(0); - DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); application.Render(0); - DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationAnimateByActorPositionAlphaFunctionTimePeriod(void) +int UtcDaliAnimationAnimateByIntegerAlphaFunctionTimePeriodP(void) { TestApplication application; Actor actor = Actor::New(); - Vector3 startPosition(10.0f, 10.0f, 10.0f); - actor.SetPosition(startPosition); + + // Register an integer property + int startValue(10); + Property::Index index = actor.RegisterProperty( "testProperty", startValue ); Stage::GetCurrent().Add(actor); - application.SendNotification(); - application.Render(0); - DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, 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); + int targetValue(30); + int relativeValue(targetValue - startValue); float delay = 0.5f; - animation.AnimateBy(Property(actor, Actor::POSITION), - relativePosition, - AlphaFunctions::Linear, + animation.AnimateBy(Property(actor, index), + relativeValue, + AlphaFunction::LINEAR, TimePeriod(delay, durationSeconds - delay)); - Vector3 ninetyFivePercentProgress(startPosition + relativePosition*0.95f); - // Start the animation animation.Play(); @@ -3098,41 +3503,52 @@ int UtcDaliAnimationAnimateByActorPositionAlphaFunctionTimePeriod(void) // We didn't expect the animation to finish yet application.SendNotification(); finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); application.SendNotification(); - application.Render(static_cast(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/); + application.Render(static_cast(durationSeconds*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(index), static_cast(startValue+(relativeValue*0.5f)+0.5f), TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(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(), targetPosition, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); // Check that nothing has changed after a couple of buffer swaps application.Render(0); - DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); application.Render(0); - DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationAnimateToBoolean(void) +int UtcDaliAnimationAnimateByVector2P(void) { TestApplication application; Actor actor = Actor::New(); - // Register a boolean property - const bool startValue(false); - Property::Index index = actor.RegisterProperty( "test-property", startValue ); + // Register a Vector2 property + Vector2 startValue(10.0f, 10.0f); + Property::Index index = actor.RegisterProperty( "testProperty", startValue ); Stage::GetCurrent().Add(actor); - DALI_TEST_CHECK( actor.GetProperty(index) == startValue ); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); // Build the animation float durationSeconds(2.0f); Animation animation = Animation::New(durationSeconds); - const bool targetValue( !startValue ); - animation.AnimateTo(Property(actor, index), targetValue); + Vector2 targetValue(60.0f, 60.0f); + Vector2 relativeValue(targetValue - startValue); + animation.AnimateBy(Property(actor, index), relativeValue); + + Vector2 ninetyFivePercentProgress(startValue + relativeValue*0.95f); // Start the animation animation.Play(); @@ -3147,7 +3563,7 @@ int UtcDaliAnimationAnimateToBoolean(void) // We didn't expect the animation to finish yet application.SendNotification(); finishCheck.CheckSignalNotReceived(); - DALI_TEST_CHECK( actor.GetProperty(index) == startValue ); + DALI_TEST_EQUALS( actor.GetProperty(index), ninetyFivePercentProgress, TEST_LOCATION ); application.SendNotification(); application.Render(static_cast(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/); @@ -3155,23 +3571,42 @@ int UtcDaliAnimationAnimateToBoolean(void) // We did expect the animation to finish application.SendNotification(); finishCheck.CheckSignalReceived(); - DALI_TEST_CHECK( actor.GetProperty(index) == targetValue ); + DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); // Check that nothing has changed after a couple of buffer swaps application.Render(0); - DALI_TEST_CHECK( actor.GetProperty(index) == targetValue ); + DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); application.Render(0); - DALI_TEST_CHECK( actor.GetProperty(index) == targetValue ); + DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + END_TEST; +} - // Repeat with target value "false" - animation = Animation::New(durationSeconds); - const bool finalValue( !targetValue ); - animation.AnimateTo(Property(actor, index), finalValue); +int UtcDaliAnimationAnimateByVector2AlphaFunctionP(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + + // Register a Vector2 property + Vector2 startValue(100.0f, 100.0f); + Property::Index index = actor.RegisterProperty( "testProperty", startValue ); + Stage::GetCurrent().Add(actor); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + Vector2 targetValue(20.0f, 20.0f); + Vector2 relativeValue(targetValue - startValue); + animation.AnimateBy(Property(actor, index), relativeValue, AlphaFunction::EASE_OUT); + + Vector2 ninetyFivePercentProgress(startValue + relativeValue*0.95f); // Start the animation animation.Play(); - finishCheck.Reset(); + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); animation.FinishedSignal().Connect(&application, finishCheck); application.SendNotification(); @@ -3180,7 +3615,11 @@ int UtcDaliAnimationAnimateToBoolean(void) // We didn't expect the animation to finish yet application.SendNotification(); finishCheck.CheckSignalNotReceived(); - DALI_TEST_CHECK( actor.GetProperty(index) == targetValue ); + + // The position should have moved more, than with a linear alpha function + Vector2 current(actor.GetProperty(index)); + DALI_TEST_CHECK( current.x < ninetyFivePercentProgress.x ); + DALI_TEST_CHECK( current.y < ninetyFivePercentProgress.y ); application.SendNotification(); application.Render(static_cast(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/); @@ -3188,33 +3627,37 @@ int UtcDaliAnimationAnimateToBoolean(void) // We did expect the animation to finish application.SendNotification(); finishCheck.CheckSignalReceived(); - DALI_TEST_CHECK( actor.GetProperty(index) == finalValue ); + DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); // Check that nothing has changed after a couple of buffer swaps application.Render(0); - DALI_TEST_CHECK( actor.GetProperty(index) == finalValue ); + DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); application.Render(0); - DALI_TEST_CHECK( actor.GetProperty(index) == finalValue ); + DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationAnimateToBooleanAlphaFunction(void) +int UtcDaliAnimationAnimateByVector2TimePeriodP(void) { TestApplication application; Actor actor = Actor::New(); - // Register a boolean property - const bool startValue(false); - Property::Index index = actor.RegisterProperty( "test-property", startValue ); + // Register a Vector2 property + Vector2 startValue(10.0f, 10.0f); + Property::Index index = actor.RegisterProperty( "testProperty", startValue ); Stage::GetCurrent().Add(actor); - DALI_TEST_CHECK( actor.GetProperty(index) == startValue ); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); // Build the animation - float durationSeconds(2.0f); + float durationSeconds(1.0f); Animation animation = Animation::New(durationSeconds); - const bool targetValue( !startValue ); - animation.AnimateTo(Property(actor, "test-property"), targetValue, AlphaFunctions::EaseOut); + Vector2 targetValue(30.0f, 30.0f); + Vector2 relativeValue(targetValue - startValue); + float delay = 0.5f; + animation.AnimateBy(Property(actor, index), + relativeValue, + TimePeriod(delay, durationSeconds - delay)); // Start the animation animation.Play(); @@ -3224,82 +3667,59 @@ int UtcDaliAnimationAnimateToBooleanAlphaFunction(void) animation.FinishedSignal().Connect(&application, finishCheck); application.SendNotification(); - application.Render(static_cast(durationSeconds*950.0f)/* 95% progress */); + application.Render(static_cast(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */); // We didn't expect the animation to finish yet application.SendNotification(); finishCheck.CheckSignalNotReceived(); - DALI_TEST_CHECK( actor.GetProperty(index) == startValue ); - - application.SendNotification(); - application.Render(static_cast(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/); - - // We did expect the animation to finish - application.SendNotification(); - finishCheck.CheckSignalReceived(); - DALI_TEST_CHECK( actor.GetProperty(index) == targetValue ); - - // Check that nothing has changed after a couple of buffer swaps - application.Render(0); - DALI_TEST_CHECK( actor.GetProperty(index) == targetValue ); - application.Render(0); - DALI_TEST_CHECK( actor.GetProperty(index) == targetValue ); - - // Repeat with target value "false" - animation = Animation::New(durationSeconds); - const bool finalValue( !targetValue ); - animation.AnimateTo(Property(actor, index), finalValue, AlphaFunctions::EaseOut); - - // Start the animation - animation.Play(); - - finishCheck.Reset(); - animation.FinishedSignal().Connect(&application, finishCheck); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); application.SendNotification(); - application.Render(static_cast(durationSeconds*950.0f)/* 95% progress */); + application.Render(static_cast(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */); // We didn't expect the animation to finish yet application.SendNotification(); finishCheck.CheckSignalNotReceived(); - DALI_TEST_CHECK( actor.GetProperty(index) == targetValue ); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue+(relativeValue*0.5f), TEST_LOCATION ); application.SendNotification(); - application.Render(static_cast(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/); + application.Render(static_cast(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/); // We did expect the animation to finish application.SendNotification(); finishCheck.CheckSignalReceived(); - DALI_TEST_CHECK( actor.GetProperty(index) == finalValue ); + DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); // Check that nothing has changed after a couple of buffer swaps application.Render(0); - DALI_TEST_CHECK( actor.GetProperty(index) == finalValue ); + DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); application.Render(0); - DALI_TEST_CHECK( actor.GetProperty(index) == finalValue ); + DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationAnimateToBooleanTimePeriod(void) +int UtcDaliAnimationAnimateByVector2AlphaFunctionTimePeriodP(void) { TestApplication application; Actor actor = Actor::New(); - // Register a boolean property - bool startValue(false); - Property::Index index = actor.RegisterProperty( "test-property", startValue ); + // Register a Vector2 property + Vector2 startValue(5.0f, 5.0f); + Property::Index index = actor.RegisterProperty( "testProperty", startValue ); Stage::GetCurrent().Add(actor); - DALI_TEST_CHECK( actor.GetProperty(index) == startValue ); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); // Build the animation - float durationSeconds(2.0f); + float durationSeconds(1.0f); Animation animation = Animation::New(durationSeconds); - bool finalValue( !startValue ); - float animatorDurationSeconds(durationSeconds * 0.5f); - animation.AnimateTo( Property(actor, index), - finalValue, - TimePeriod( animatorDurationSeconds ) ); + Vector2 targetValue(10.0f, 10.0f); + Vector2 relativeValue(targetValue - startValue); + float delay = 0.5f; + animation.AnimateBy(Property(actor, index), + relativeValue, + AlphaFunction::LINEAR, + TimePeriod(delay, durationSeconds - delay)); // Start the animation animation.Play(); @@ -3309,60 +3729,57 @@ int UtcDaliAnimationAnimateToBooleanTimePeriod(void) animation.FinishedSignal().Connect(&application, finishCheck); application.SendNotification(); - application.Render(static_cast(animatorDurationSeconds*950.0f)/* 95% animator progress */); + application.Render(static_cast(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */); // We didn't expect the animation to finish yet application.SendNotification(); finishCheck.CheckSignalNotReceived(); - DALI_TEST_CHECK( actor.GetProperty(index) == startValue ); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); application.SendNotification(); - application.Render(static_cast(animatorDurationSeconds*50.0f) + 1u/*just beyond the animator duration*/); + application.Render(static_cast(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */); - // We didn't expect the animation to finish yet... + // We didn't expect the animation to finish yet application.SendNotification(); finishCheck.CheckSignalNotReceived(); - - // ...however we should have reached the final value - DALI_TEST_CHECK( actor.GetProperty(index) == finalValue ); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue+(relativeValue*0.5f), TEST_LOCATION ); application.SendNotification(); - application.Render(static_cast(animatorDurationSeconds*1000.0f)/*just beyond the animation duration*/); + application.Render(static_cast(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/); // We did expect the animation to finish application.SendNotification(); finishCheck.CheckSignalReceived(); - DALI_TEST_CHECK( actor.GetProperty(index) == finalValue ); + DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); // Check that nothing has changed after a couple of buffer swaps application.Render(0); - DALI_TEST_CHECK( actor.GetProperty(index) == finalValue ); + DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); application.Render(0); - DALI_TEST_CHECK( actor.GetProperty(index) == finalValue ); + DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationAnimateToBooleanAlphaFunctionTimePeriod(void) +int UtcDaliAnimationAnimateByVector3P(void) { TestApplication application; Actor actor = Actor::New(); - // Register a boolean property - bool startValue(false); - Property::Index index = actor.RegisterProperty( "test-property", startValue ); + // Register a Vector3 property + Vector3 startValue(10.0f, 10.0f, 10.0f); + Property::Index index = actor.RegisterProperty( "testProperty", startValue ); Stage::GetCurrent().Add(actor); - DALI_TEST_CHECK( actor.GetProperty(index) == startValue ); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); // Build the animation float durationSeconds(2.0f); Animation animation = Animation::New(durationSeconds); - bool finalValue( !startValue ); - float animatorDurationSeconds(durationSeconds * 0.5f); - animation.AnimateTo( Property(actor, index), - finalValue, - AlphaFunctions::Linear, - TimePeriod( animatorDurationSeconds ) ); + Vector3 targetValue(60.0f, 60.0f, 60.0f); + Vector3 relativeValue(targetValue - startValue); + animation.AnimateBy(Property(actor, index), relativeValue); + + Vector3 ninetyFivePercentProgress(startValue + relativeValue*0.95f); // Start the animation animation.Play(); @@ -3372,105 +3789,49 @@ int UtcDaliAnimationAnimateToBooleanAlphaFunctionTimePeriod(void) animation.FinishedSignal().Connect(&application, finishCheck); application.SendNotification(); - application.Render(static_cast(animatorDurationSeconds*950.0f)/* 95% animator progress */); + application.Render(static_cast(durationSeconds*950.0f)/* 95% progress */); // We didn't expect the animation to finish yet application.SendNotification(); finishCheck.CheckSignalNotReceived(); - DALI_TEST_CHECK( actor.GetProperty(index) == startValue ); + DALI_TEST_EQUALS( actor.GetProperty(index), ninetyFivePercentProgress, TEST_LOCATION ); application.SendNotification(); - application.Render(static_cast(animatorDurationSeconds*50.0f) + 1u/*just beyond the animator duration*/); + application.Render(static_cast(durationSeconds*50.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(); - - // ...however we should have reached the final value - DALI_TEST_CHECK( actor.GetProperty(index) == finalValue ); - - application.SendNotification(); - application.Render(static_cast(animatorDurationSeconds*1000.0f)/*just beyond the animation duration*/); - - // We did expect the animation to finish - application.SendNotification(); - finishCheck.CheckSignalReceived(); - DALI_TEST_CHECK( actor.GetProperty(index) == finalValue ); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); // Check that nothing has changed after a couple of buffer swaps application.Render(0); - DALI_TEST_CHECK( actor.GetProperty(index) == finalValue ); + DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); application.Render(0); - DALI_TEST_CHECK( actor.GetProperty(index) == finalValue ); - END_TEST; -} - -int UtcDaliAnimationAnimateToFloat(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(index), startValue, TEST_LOCATION ); - - // Build the animation - float durationSeconds(2.0f); - Animation animation = Animation::New(durationSeconds); - float targetValue(50.0f); - float relativeValue(targetValue - startValue); - animation.AnimateTo(Property(actor, "test-property"), targetValue); - - float ninetyFivePercentProgress(startValue + relativeValue*0.95f); - - // Start the animation - animation.Play(); - - bool signalReceived(false); - AnimationFinishCheck finishCheck(signalReceived); - animation.FinishedSignal().Connect(&application, finishCheck); - - application.SendNotification(); - application.Render(static_cast(durationSeconds*950.0f)/* 95% progress */); - - // We didn't expect the animation to finish yet - application.SendNotification(); - finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetProperty(index), ninetyFivePercentProgress, TEST_LOCATION ); - - application.SendNotification(); - application.Render(static_cast(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/); - - // We did expect the animation to finish - application.SendNotification(); - finishCheck.CheckSignalReceived(); - DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationAnimateToFloatAlphaFunction(void) +int UtcDaliAnimationAnimateByVector3AlphaFunctionP(void) { TestApplication application; Actor actor = Actor::New(); - // Register a float property - float startValue(10.0f); - Property::Index index = actor.RegisterProperty( "test-property", startValue ); + // Register a Vector3 property + Vector3 startValue(100.0f, 100.0f, 100.0f); + Property::Index index = actor.RegisterProperty( "testProperty", startValue ); Stage::GetCurrent().Add(actor); - DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); // Build the animation float durationSeconds(1.0f); Animation animation = Animation::New(durationSeconds); - float targetValue(90.0f); - float relativeValue(targetValue - startValue); - animation.AnimateTo(Property(actor, index), targetValue, AlphaFunctions::EaseOut); + Vector3 targetValue(20.0f, 20.0f, 20.0f); + Vector3 relativeValue(targetValue - startValue); + animation.AnimateBy(Property(actor, index), relativeValue, AlphaFunction::EASE_OUT); - float ninetyFivePercentProgress(startValue + relativeValue*0.95f); + Vector3 ninetyFivePercentProgress(startValue + relativeValue*0.95f); // Start the animation animation.Play(); @@ -3487,8 +3848,10 @@ int UtcDaliAnimationAnimateToFloatAlphaFunction(void) finishCheck.CheckSignalNotReceived(); // The position should have moved more, than with a linear alpha function - float current(actor.GetProperty(index)); - DALI_TEST_CHECK( current > ninetyFivePercentProgress ); + Vector3 current(actor.GetProperty(index)); + DALI_TEST_CHECK( current.x < ninetyFivePercentProgress.x ); + DALI_TEST_CHECK( current.y < ninetyFivePercentProgress.y ); + DALI_TEST_CHECK( current.z < ninetyFivePercentProgress.z ); application.SendNotification(); application.Render(static_cast(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/); @@ -3496,30 +3859,36 @@ int UtcDaliAnimationAnimateToFloatAlphaFunction(void) // We did expect the animation to finish application.SendNotification(); finishCheck.CheckSignalReceived(); - DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + + // Check that nothing has changed after a couple of buffer swaps + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationAnimateToFloatTimePeriod(void) +int UtcDaliAnimationAnimateByVector3TimePeriodP(void) { TestApplication application; Actor actor = Actor::New(); - // Register a float property - float startValue(10.0f); - Property::Index index = actor.RegisterProperty( "test-property", startValue ); + // Register a Vector3 property + Vector3 startValue(10.0f, 10.0f, 10.0f); + Property::Index index = actor.RegisterProperty( "testProperty", startValue ); Stage::GetCurrent().Add(actor); - DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); // Build the animation float durationSeconds(1.0f); Animation animation = Animation::New(durationSeconds); - float targetValue(30.0f); - float relativeValue(targetValue - startValue); + Vector3 targetValue(30.0f, 30.0f, 30.0f); + Vector3 relativeValue(targetValue - startValue); float delay = 0.5f; - animation.AnimateTo(Property(actor, index), - targetValue, + animation.AnimateBy(Property(actor, index), + relativeValue, TimePeriod(delay, durationSeconds - delay)); // Start the animation @@ -3535,7 +3904,7 @@ int UtcDaliAnimationAnimateToFloatTimePeriod(void) // We didn't expect the animation to finish yet application.SendNotification(); finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); application.SendNotification(); application.Render(static_cast(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */); @@ -3543,7 +3912,7 @@ int UtcDaliAnimationAnimateToFloatTimePeriod(void) // We didn't expect the animation to finish yet application.SendNotification(); finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetProperty(index), startValue+(relativeValue*0.5f), TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue+(relativeValue*0.5f), TEST_LOCATION ); application.SendNotification(); application.Render(static_cast(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/); @@ -3551,31 +3920,37 @@ int UtcDaliAnimationAnimateToFloatTimePeriod(void) // We did expect the animation to finish application.SendNotification(); finishCheck.CheckSignalReceived(); - DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + + // Check that nothing has changed after a couple of buffer swaps + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationAnimateToFloatAlphaFunctionTimePeriod(void) +int UtcDaliAnimationAnimateByVector3AlphaFunctionTimePeriodP(void) { TestApplication application; Actor actor = Actor::New(); - // Register a float property - float startValue(10.0f); - Property::Index index = actor.RegisterProperty( "test-property", startValue ); + // Register a Vector3 property + Vector3 startValue(5.0f, 5.0f, 5.0f); + Property::Index index = actor.RegisterProperty( "testProperty", startValue ); Stage::GetCurrent().Add(actor); - DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); // Build the animation float durationSeconds(1.0f); Animation animation = Animation::New(durationSeconds); - float targetValue(30.0f); - float relativeValue(targetValue - startValue); + Vector3 targetValue(10.0f, 10.0f, 10.0f); + Vector3 relativeValue(targetValue - startValue); float delay = 0.5f; - animation.AnimateTo(Property(actor, index), - targetValue, - AlphaFunctions::Linear, + animation.AnimateBy(Property(actor, index), + relativeValue, + AlphaFunction::LINEAR, TimePeriod(delay, durationSeconds - delay)); // Start the animation @@ -3591,7 +3966,7 @@ int UtcDaliAnimationAnimateToFloatAlphaFunctionTimePeriod(void) // We didn't expect the animation to finish yet application.SendNotification(); finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); application.SendNotification(); application.Render(static_cast(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */); @@ -3599,7 +3974,7 @@ int UtcDaliAnimationAnimateToFloatAlphaFunctionTimePeriod(void) // We didn't expect the animation to finish yet application.SendNotification(); finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetProperty(index), startValue+(relativeValue*0.5f), TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue+(relativeValue*0.5f), TEST_LOCATION ); application.SendNotification(); application.Render(static_cast(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/); @@ -3607,30 +3982,36 @@ int UtcDaliAnimationAnimateToFloatAlphaFunctionTimePeriod(void) // We did expect the animation to finish application.SendNotification(); finishCheck.CheckSignalReceived(); - DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + + // Check that nothing has changed after a couple of buffer swaps + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationAnimateToInteger(void) +int UtcDaliAnimationAnimateByVector4P(void) { TestApplication application; Actor actor = Actor::New(); - // Register an integer property - int startValue(10); - Property::Index index = actor.RegisterProperty( "test-property", startValue ); + // Register a Vector4 property + Vector4 startValue(10.0f, 10.0f, 10.0f, 10.0f); + Property::Index index = actor.RegisterProperty( "testProperty", startValue ); Stage::GetCurrent().Add(actor); - DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); // Build the animation float durationSeconds(2.0f); Animation animation = Animation::New(durationSeconds); - int targetValue(50); - int relativeValue(targetValue - startValue); - animation.AnimateTo(Property(actor, "test-property"), targetValue); + Vector4 targetValue(60.0f, 60.0f, 60.0f, 60.0f); + Vector4 relativeValue(targetValue - startValue); + animation.AnimateBy(Property(actor, index), relativeValue); - int ninetyFivePercentProgress(static_cast(startValue + relativeValue*0.95f + 0.5f)); + Vector4 ninetyFivePercentProgress(startValue + relativeValue*0.95f); // Start the animation animation.Play(); @@ -3645,7 +4026,7 @@ int UtcDaliAnimationAnimateToInteger(void) // We didn't expect the animation to finish yet application.SendNotification(); finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetProperty(index), ninetyFivePercentProgress, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(index), ninetyFivePercentProgress, TEST_LOCATION ); application.SendNotification(); application.Render(static_cast(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/); @@ -3653,30 +4034,36 @@ int UtcDaliAnimationAnimateToInteger(void) // We did expect the animation to finish application.SendNotification(); finishCheck.CheckSignalReceived(); - DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + + // Check that nothing has changed after a couple of buffer swaps + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationAnimateToIntegerAlphaFunction(void) +int UtcDaliAnimationAnimateByVector4AlphaFunctionP(void) { TestApplication application; Actor actor = Actor::New(); - // Register an integer property - int startValue(10); - Property::Index index = actor.RegisterProperty( "test-property", startValue ); + // Register a Vector4 property + Vector4 startValue(100.0f, 100.0f, 100.0f, 100.0f); + Property::Index index = actor.RegisterProperty( "testProperty", startValue ); Stage::GetCurrent().Add(actor); - DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); // Build the animation float durationSeconds(1.0f); Animation animation = Animation::New(durationSeconds); - int targetValue(90); - int relativeValue(targetValue - startValue); - animation.AnimateTo(Property(actor, index), targetValue, AlphaFunctions::EaseOut); + Vector4 targetValue(20.0f, 20.0f, 20.0f, 20.0f); + Vector4 relativeValue(targetValue - startValue); + animation.AnimateBy(Property(actor, index), relativeValue, AlphaFunction::EASE_OUT); - int ninetyFivePercentProgress(static_cast(startValue + relativeValue*0.95f + 0.5f)); + Vector4 ninetyFivePercentProgress(startValue + relativeValue*0.95f); // Start the animation animation.Play(); @@ -3693,8 +4080,11 @@ int UtcDaliAnimationAnimateToIntegerAlphaFunction(void) finishCheck.CheckSignalNotReceived(); // The position should have moved more, than with a linear alpha function - int current(actor.GetProperty(index)); - DALI_TEST_CHECK( current > ninetyFivePercentProgress ); + Vector4 current(actor.GetProperty(index)); + DALI_TEST_CHECK( current.x < ninetyFivePercentProgress.x ); + DALI_TEST_CHECK( current.y < ninetyFivePercentProgress.y ); + DALI_TEST_CHECK( current.z < ninetyFivePercentProgress.z ); + DALI_TEST_CHECK( current.w < ninetyFivePercentProgress.w ); application.SendNotification(); application.Render(static_cast(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/); @@ -3702,30 +4092,36 @@ int UtcDaliAnimationAnimateToIntegerAlphaFunction(void) // We did expect the animation to finish application.SendNotification(); finishCheck.CheckSignalReceived(); - DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + + // Check that nothing has changed after a couple of buffer swaps + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationAnimateToIntegerTimePeriod(void) +int UtcDaliAnimationAnimateByVector4TimePeriodP(void) { TestApplication application; Actor actor = Actor::New(); - // Register an integer property - int startValue(10); - Property::Index index = actor.RegisterProperty( "test-property", startValue ); + // Register a Vector4 property + Vector4 startValue(10.0f, 10.0f, 10.0f, 10.0f); + Property::Index index = actor.RegisterProperty( "testProperty", startValue ); Stage::GetCurrent().Add(actor); - DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); // Build the animation float durationSeconds(1.0f); Animation animation = Animation::New(durationSeconds); - int targetValue(30); - int relativeValue(targetValue - startValue); + Vector4 targetValue(30.0f, 30.0f, 30.0f, 30.0f); + Vector4 relativeValue(targetValue - startValue); float delay = 0.5f; - animation.AnimateTo(Property(actor, index), - targetValue, + animation.AnimateBy(Property(actor, index), + relativeValue, TimePeriod(delay, durationSeconds - delay)); // Start the animation @@ -3741,7 +4137,7 @@ int UtcDaliAnimationAnimateToIntegerTimePeriod(void) // We didn't expect the animation to finish yet application.SendNotification(); finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); application.SendNotification(); application.Render(static_cast(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */); @@ -3749,7 +4145,7 @@ int UtcDaliAnimationAnimateToIntegerTimePeriod(void) // We didn't expect the animation to finish yet application.SendNotification(); finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetProperty(index), static_cast(startValue+(relativeValue*0.5f)+0.5f), TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue+(relativeValue*0.5f), TEST_LOCATION ); application.SendNotification(); application.Render(static_cast(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/); @@ -3757,31 +4153,37 @@ int UtcDaliAnimationAnimateToIntegerTimePeriod(void) // We did expect the animation to finish application.SendNotification(); finishCheck.CheckSignalReceived(); - DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + + // Check that nothing has changed after a couple of buffer swaps + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationAnimateToIntegerAlphaFunctionTimePeriod(void) +int UtcDaliAnimationAnimateByVector4AlphaFunctionTimePeriodP(void) { TestApplication application; Actor actor = Actor::New(); - // Register an integer property - int startValue(10); - Property::Index index = actor.RegisterProperty( "test-property", startValue ); + // Register a Vector4 property + Vector4 startValue(5.0f, 5.0f, 5.0f, 5.0f); + Property::Index index = actor.RegisterProperty( "testProperty", startValue ); Stage::GetCurrent().Add(actor); - DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); // Build the animation float durationSeconds(1.0f); Animation animation = Animation::New(durationSeconds); - int targetValue(30); - int relativeValue(targetValue - startValue); + Vector4 targetValue(10.0f, 10.0f, 10.0f, 10.0f); + Vector4 relativeValue(targetValue - startValue); float delay = 0.5f; - animation.AnimateTo(Property(actor, index), - targetValue, - AlphaFunctions::Linear, + animation.AnimateBy(Property(actor, index), + relativeValue, + AlphaFunction::LINEAR, TimePeriod(delay, durationSeconds - delay)); // Start the animation @@ -3797,7 +4199,7 @@ int UtcDaliAnimationAnimateToIntegerAlphaFunctionTimePeriod(void) // We didn't expect the animation to finish yet application.SendNotification(); finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); application.SendNotification(); application.Render(static_cast(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */); @@ -3805,7 +4207,7 @@ int UtcDaliAnimationAnimateToIntegerAlphaFunctionTimePeriod(void) // We didn't expect the animation to finish yet application.SendNotification(); finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetProperty(index), static_cast(startValue+(relativeValue*0.5f)+0.5f), TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue+(relativeValue*0.5f), TEST_LOCATION ); application.SendNotification(); application.Render(static_cast(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/); @@ -3813,30 +4215,36 @@ int UtcDaliAnimationAnimateToIntegerAlphaFunctionTimePeriod(void) // We did expect the animation to finish application.SendNotification(); finishCheck.CheckSignalReceived(); - DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + + // Check that nothing has changed after a couple of buffer swaps + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationAnimateToVector2(void) +int UtcDaliAnimationAnimateByActorPositionP(void) { TestApplication application; Actor actor = Actor::New(); - - // Register a Vector2 property - Vector2 startValue(-50.0f, -50.0f); - Property::Index index = actor.RegisterProperty( "test-property", startValue ); + Vector3 startPosition(10.0f, 10.0f, 10.0f); + actor.SetPosition(startPosition); Stage::GetCurrent().Add(actor); - DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + application.SendNotification(); + application.Render(0); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION ); // Build the animation - float durationSeconds(2.0f); + float durationSeconds(1.0f); Animation animation = Animation::New(durationSeconds); - Vector2 targetValue(50.0f, 50.0f); - Vector2 relativeValue(targetValue - startValue); - animation.AnimateTo(Property(actor, index), targetValue); + Vector3 targetPosition(20.0f, 20.0f, 20.0f); + Vector3 relativePosition(targetPosition - startPosition); + animation.AnimateBy(Property(actor, Actor::Property::POSITION), relativePosition); - Vector2 ninetyFivePercentProgress(startValue + relativeValue*0.95f); + Vector3 ninetyFivePercentProgress(startPosition + relativePosition*0.95f); // Start the animation animation.Play(); @@ -3851,7 +4259,7 @@ int UtcDaliAnimationAnimateToVector2(void) // We didn't expect the animation to finish yet application.SendNotification(); finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetProperty(index), ninetyFivePercentProgress, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), ninetyFivePercentProgress, TEST_LOCATION ); application.SendNotification(); application.Render(static_cast(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/); @@ -3859,30 +4267,36 @@ int UtcDaliAnimationAnimateToVector2(void) // We did expect the animation to finish application.SendNotification(); finishCheck.CheckSignalReceived(); - DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION ); + + // Check that nothing has changed after a couple of buffer swaps + application.Render(0); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION ); + application.Render(0); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationAnimateToVector2AlphaFunction(void) +int UtcDaliAnimationAnimateByActorPositionAlphaFunctionP(void) { TestApplication application; Actor actor = Actor::New(); - - // Register a Vector2 property - Vector2 startValue(1000.0f, 1000.0f); - Property::Index index = actor.RegisterProperty( "test-property", startValue ); + Vector3 startPosition(10.0f, 10.0f, 10.0f); + actor.SetPosition(startPosition); Stage::GetCurrent().Add(actor); - DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + 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); - Vector2 targetValue(9000.0f, 9000.0f); - Vector2 relativeValue(targetValue - startValue); - animation.AnimateTo(Property(actor, "test-property"), targetValue, AlphaFunctions::EaseOut); + Vector3 targetPosition(20.0f, 20.0f, 20.0f); + Vector3 relativePosition(targetPosition - startPosition); + animation.AnimateBy(Property(actor, Actor::Property::POSITION), relativePosition, AlphaFunction::EASE_OUT); - Vector2 ninetyFivePercentProgress(startValue + relativeValue*0.95f); + Vector3 ninetyFivePercentProgress(startPosition + relativePosition*0.95f); // Start the animation animation.Play(); @@ -3899,9 +4313,10 @@ int UtcDaliAnimationAnimateToVector2AlphaFunction(void) finishCheck.CheckSignalNotReceived(); // The position should have moved more, than with a linear alpha function - Vector2 current(actor.GetProperty(index)); + Vector3 current(actor.GetCurrentPosition()); DALI_TEST_CHECK( current.x > ninetyFivePercentProgress.x ); DALI_TEST_CHECK( current.y > ninetyFivePercentProgress.y ); + DALI_TEST_CHECK( current.z > ninetyFivePercentProgress.z ); application.SendNotification(); application.Render(static_cast(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/); @@ -3909,32 +4324,40 @@ int UtcDaliAnimationAnimateToVector2AlphaFunction(void) // We did expect the animation to finish application.SendNotification(); finishCheck.CheckSignalReceived(); - DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION ); + + // Check that nothing has changed after a couple of buffer swaps + application.Render(0); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION ); + application.Render(0); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationAnimateToVector2TimePeriod(void) +int UtcDaliAnimationAnimateByActorPositionTimePeriodP(void) { TestApplication application; Actor actor = Actor::New(); - - // Register a Vector2 property - Vector2 startValue(10.0f, 10.0f); - Property::Index index = actor.RegisterProperty( "test-property", startValue ); + Vector3 startPosition(10.0f, 10.0f, 10.0f); + actor.SetPosition(startPosition); Stage::GetCurrent().Add(actor); - DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + 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); - Vector2 targetValue(-10.0f, 20.0f); - Vector2 relativeValue(targetValue - startValue); + Vector3 targetPosition(20.0f, 20.0f, 20.0f); + Vector3 relativePosition(targetPosition - startPosition); float delay = 0.5f; - animation.AnimateTo(Property(actor, index), - targetValue, + animation.AnimateBy(Property(actor, Actor::Property::POSITION), + relativePosition, TimePeriod(delay, durationSeconds - delay)); + Vector3 ninetyFivePercentProgress(startPosition + relativePosition*0.95f); + // Start the animation animation.Play(); @@ -3948,49 +4371,49 @@ int UtcDaliAnimationAnimateToVector2TimePeriod(void) // We didn't expect the animation to finish yet application.SendNotification(); finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); - - application.SendNotification(); - application.Render(static_cast(durationSeconds*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(index), startValue+(relativeValue*0.5f), TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION ); application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/); + application.Render(static_cast(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/); // We did expect the animation to finish application.SendNotification(); finishCheck.CheckSignalReceived(); - DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION ); + + // Check that nothing has changed after a couple of buffer swaps + application.Render(0); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION ); + application.Render(0); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationAnimateToVector2AlphaFunctionTimePeriod(void) +int UtcDaliAnimationAnimateByActorPositionAlphaFunctionTimePeriodP(void) { TestApplication application; Actor actor = Actor::New(); - - // Register a Vector2 property - Vector2 startValue(10.0f, 10.0f); - Property::Index index = actor.RegisterProperty( "test-property", startValue ); + Vector3 startPosition(10.0f, 10.0f, 10.0f); + actor.SetPosition(startPosition); Stage::GetCurrent().Add(actor); - DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + 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); - Vector2 targetValue(30.0f, 30.0f); - Vector2 relativeValue(targetValue - startValue); + Vector3 targetPosition(20.0f, 20.0f, 20.0f); + Vector3 relativePosition(targetPosition - startPosition); float delay = 0.5f; - animation.AnimateTo(Property(actor, index), - targetValue, - AlphaFunctions::Linear, + animation.AnimateBy(Property(actor, Actor::Property::POSITION), + relativePosition, + AlphaFunction::LINEAR, TimePeriod(delay, durationSeconds - delay)); + Vector3 ninetyFivePercentProgress(startPosition + relativePosition*0.95f); + // Start the animation animation.Play(); @@ -4004,46 +4427,39 @@ int UtcDaliAnimationAnimateToVector2AlphaFunctionTimePeriod(void) // We didn't expect the animation to finish yet application.SendNotification(); finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); - - application.SendNotification(); - application.Render(static_cast(durationSeconds*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(index), startValue+(relativeValue*0.5f), TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION ); application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/); + application.Render(static_cast(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/); // We did expect the animation to finish application.SendNotification(); finishCheck.CheckSignalReceived(); - DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION ); + + // Check that nothing has changed after a couple of buffer swaps + application.Render(0); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION ); + application.Render(0); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationAnimateToVector3(void) +int UtcDaliAnimationAnimateByActorOrientationP1(void) { TestApplication application; Actor actor = Actor::New(); - - // Register a Vector3 property - Vector3 startValue(-50.0f, -50.0f, -50.0f); - Property::Index index = actor.RegisterProperty( "test-property", startValue ); + actor.SetOrientation( Quaternion( Dali::ANGLE_0, Vector3::YAXIS ) ); Stage::GetCurrent().Add(actor); - DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion( Dali::ANGLE_0, Vector3::YAXIS ), ROTATION_EPSILON, TEST_LOCATION ); // Build the animation - float durationSeconds(2.0f); + float durationSeconds(1.0f); Animation animation = Animation::New(durationSeconds); - Vector3 targetValue(50.0f, 50.0f, 50.0f); - Vector3 relativeValue(targetValue - startValue); - animation.AnimateTo(Property(actor, index), targetValue); - - Vector3 ninetyFivePercentProgress(startValue + relativeValue*0.95f); + Degree relativeRotationDegrees(360.0f); + Radian relativeRotationRadians(relativeRotationDegrees); + animation.AnimateBy( Property( actor, Actor::Property::ORIENTATION ), Quaternion( relativeRotationRadians, Vector3::YAXIS ) ); // Start the animation animation.Play(); @@ -4053,43 +4469,57 @@ int UtcDaliAnimationAnimateToVector3(void) animation.FinishedSignal().Connect(&application, finishCheck); application.SendNotification(); - application.Render(static_cast(durationSeconds*950.0f)/* 95% progress */); + application.Render(static_cast(durationSeconds*250.0f)/* 25% progress */); // We didn't expect the animation to finish yet application.SendNotification(); finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetProperty(index), ninetyFivePercentProgress, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians * 0.25f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); application.SendNotification(); - application.Render(static_cast(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/); + application.Render(static_cast(durationSeconds*250.0f)/* 50% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians * 0.5f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f)/* 75% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians * 0.75f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(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(index), targetValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationAnimateToVector3AlphaFunction(void) +int UtcDaliAnimationAnimateByActorOrientationP2(void) { TestApplication application; - Actor actor = Actor::New(); + tet_printf("Testing that rotation angle > 360 performs full rotations\n"); - // Register a Vector3 property - Vector3 startValue(1000.0f, 1000.0f, 1000.0f); - Property::Index index = actor.RegisterProperty( "test-property", startValue ); + Actor actor = Actor::New(); + actor.SetOrientation( Quaternion( Dali::ANGLE_0, Vector3::ZAXIS ) ); Stage::GetCurrent().Add(actor); - DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion( Dali::ANGLE_0, Vector3::ZAXIS ), ROTATION_EPSILON, TEST_LOCATION ); // Build the animation float durationSeconds(1.0f); Animation animation = Animation::New(durationSeconds); - Vector3 targetValue(9000.0f, 9000.0f, 9000.0f); - Vector3 relativeValue(targetValue - startValue); - animation.AnimateTo(Property(actor, index), targetValue, AlphaFunctions::EaseOut); + Degree relativeRotationDegrees(710.0f); + Radian relativeRotationRadians(relativeRotationDegrees); - Vector3 ninetyFivePercentProgress(startValue + relativeValue*0.95f); + animation.AnimateBy( Property( actor, Actor::Property::ORIENTATION ), AngleAxis( relativeRotationRadians, Vector3::ZAXIS ) ); // Start the animation animation.Play(); @@ -4099,49 +4529,60 @@ int UtcDaliAnimationAnimateToVector3AlphaFunction(void) animation.FinishedSignal().Connect(&application, finishCheck); application.SendNotification(); - application.Render(static_cast(durationSeconds*950.0f)/* 95% progress */); + application.Render(static_cast(durationSeconds*250.0f)/* 25% progress */); // We didn't expect the animation to finish yet application.SendNotification(); finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians * 0.25f, Vector3::ZAXIS), ROTATION_EPSILON, TEST_LOCATION ); - // The position should have moved more, than with a linear alpha function - Vector3 current(actor.GetProperty(index)); - DALI_TEST_CHECK( current.x > ninetyFivePercentProgress.x ); - DALI_TEST_CHECK( current.y > ninetyFivePercentProgress.y ); - DALI_TEST_CHECK( current.z > ninetyFivePercentProgress.z ); + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f)/* 50% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians * 0.5f, Vector3::ZAXIS), ROTATION_EPSILON, TEST_LOCATION ); application.SendNotification(); - application.Render(static_cast(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/); + application.Render(static_cast(durationSeconds*250.0f)/* 75% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians * 0.75f, Vector3::ZAXIS), ROTATION_EPSILON, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(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(index), targetValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians, Vector3::ZAXIS), ROTATION_EPSILON, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationAnimateToVector3TimePeriod(void) + +int UtcDaliAnimationAnimateByActorOrientationP3(void) { TestApplication application; - Actor actor = Actor::New(); + tet_printf("Testing that rotation angle > 360 performs partial rotations when cast to Quaternion\n"); - // Register a Vector3 property - Vector3 startValue(10.0f, 10.0f, 10.0f); - Property::Index index = actor.RegisterProperty( "test-property", startValue ); + Actor actor = Actor::New(); + actor.SetOrientation( Quaternion( Dali::ANGLE_0, Vector3::ZAXIS ) ); Stage::GetCurrent().Add(actor); - DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion( Dali::ANGLE_0, Vector3::ZAXIS ), ROTATION_EPSILON, TEST_LOCATION ); // Build the animation float durationSeconds(1.0f); Animation animation = Animation::New(durationSeconds); - Vector3 targetValue(-10.0f, 20.0f, 100.0f); - Vector3 relativeValue(targetValue - startValue); - float delay = 0.5f; - animation.AnimateTo(Property(actor, index), - targetValue, - TimePeriod(delay, durationSeconds - delay)); + Degree relativeRotationDegrees(730.0f); + Radian relativeRotationRadians(relativeRotationDegrees); + + Radian actualRotationRadians( Degree(10.0f) ); + + animation.AnimateBy( Property( actor, Actor::Property::ORIENTATION ), Quaternion( relativeRotationRadians, Vector3::ZAXIS ) ); // Start the animation animation.Play(); @@ -4151,20 +4592,28 @@ int UtcDaliAnimationAnimateToVector3TimePeriod(void) animation.FinishedSignal().Connect(&application, finishCheck); application.SendNotification(); - application.Render(static_cast(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */); + application.Render(static_cast(durationSeconds*250.0f)/* 25% progress */); // We didn't expect the animation to finish yet application.SendNotification(); finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(actualRotationRadians * 0.25f, Vector3::ZAXIS), ROTATION_EPSILON, TEST_LOCATION ); application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */); + application.Render(static_cast(durationSeconds*250.0f)/* 50% progress */); // We didn't expect the animation to finish yet application.SendNotification(); finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetProperty(index), startValue+(relativeValue*0.5f), TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(actualRotationRadians * 0.5f, Vector3::ZAXIS), ROTATION_EPSILON, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f)/* 75% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(actualRotationRadians * 0.75f, Vector3::ZAXIS), ROTATION_EPSILON, TEST_LOCATION ); application.SendNotification(); application.Render(static_cast(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/); @@ -4172,32 +4621,27 @@ int UtcDaliAnimationAnimateToVector3TimePeriod(void) // We did expect the animation to finish application.SendNotification(); finishCheck.CheckSignalReceived(); - DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(actualRotationRadians, Vector3::ZAXIS), ROTATION_EPSILON, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians, Vector3::ZAXIS), ROTATION_EPSILON, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationAnimateToVector3AlphaFunctionTimePeriod(void) + +int UtcDaliAnimationAnimateByActorOrientationAlphaFunctionP(void) { TestApplication application; Actor actor = Actor::New(); - - // Register a Vector3 property - Vector3 startValue(10.0f, 10.0f, 10.0f); - Property::Index index = actor.RegisterProperty( "test-property", startValue ); + actor.SetOrientation( Quaternion( Dali::ANGLE_0, Vector3::YAXIS ) ); Stage::GetCurrent().Add(actor); - DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion( Dali::ANGLE_0, Vector3::YAXIS ), ROTATION_EPSILON, TEST_LOCATION ); // Build the animation float durationSeconds(1.0f); Animation animation = Animation::New(durationSeconds); - Vector3 targetValue(30.0f, 30.0f, 30.0f); - Vector3 relativeValue(targetValue - startValue); - float delay = 0.5f; - animation.AnimateTo(Property(actor, "test-property"), - targetValue, - AlphaFunctions::Linear, - TimePeriod(delay, durationSeconds - delay)); + Degree relativeRotationDegrees(360.0f); + Radian relativeRotationRadians(relativeRotationDegrees); + animation.AnimateBy( Property( actor, Actor::Property::ORIENTATION ), Quaternion( relativeRotationRadians, Vector3::YAXIS ), AlphaFunction::EASE_IN ); // Start the animation animation.Play(); @@ -4207,20 +4651,28 @@ int UtcDaliAnimationAnimateToVector3AlphaFunctionTimePeriod(void) animation.FinishedSignal().Connect(&application, finishCheck); application.SendNotification(); - application.Render(static_cast(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */); + application.Render(static_cast(durationSeconds*250.0f)/* 25% progress */); // We didn't expect the animation to finish yet application.SendNotification(); finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians * 0.25f*0.25f*0.25f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */); + application.Render(static_cast(durationSeconds*250.0f)/* 50% progress */); // We didn't expect the animation to finish yet application.SendNotification(); finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetProperty(index), startValue+(relativeValue*0.5f), TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians * 0.5f*0.5f*0.5f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f)/* 75% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians * 0.75f*0.75f*0.75f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); application.SendNotification(); application.Render(static_cast(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/); @@ -4228,36 +4680,27 @@ int UtcDaliAnimationAnimateToVector3AlphaFunctionTimePeriod(void) // We did expect the animation to finish application.SendNotification(); finishCheck.CheckSignalReceived(); - DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationAnimateToVector3Component(void) +int UtcDaliAnimationAnimateByActorOrientationAlphaFunctionTimePeriodP(void) { TestApplication application; Actor actor = Actor::New(); - - // Register a Vector3 property - Vector3 startValue(10.0f, 10.0f, 10.0f); - Property::Index index = actor.RegisterProperty( "test-property", startValue ); + actor.SetOrientation( Quaternion( Dali::ANGLE_0, Vector3::YAXIS ) ); Stage::GetCurrent().Add(actor); - DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion( Dali::ANGLE_0, Vector3::YAXIS ), ROTATION_EPSILON, TEST_LOCATION ); // Build the animation float durationSeconds(1.0f); Animation animation = Animation::New(durationSeconds); - Vector3 targetValue(30.0f, 30.0f, 10.0f); - Vector3 relativeValue(targetValue - startValue); - float delay = 0.5f; - animation.AnimateTo(Property(actor, "test-property", 0), - 30.0f, - AlphaFunctions::Linear, - TimePeriod(delay, durationSeconds - delay)); - animation.AnimateTo(Property(actor, index, 1), - 30.0f, - AlphaFunctions::Linear, - TimePeriod(delay, durationSeconds - delay)); + Degree relativeRotationDegrees(360.0f); + Radian relativeRotationRadians(relativeRotationDegrees); + float delay = 0.3f; + animation.AnimateBy( Property( actor, Actor::Property::ORIENTATION ), Quaternion( relativeRotationRadians, Vector3::YAXIS ), + AlphaFunction::EASE_IN, TimePeriod( delay, durationSeconds - delay ) ); // Start the animation animation.Play(); @@ -4267,51 +4710,58 @@ int UtcDaliAnimationAnimateToVector3Component(void) animation.FinishedSignal().Connect(&application, finishCheck); application.SendNotification(); - application.Render(static_cast(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */); + application.Render(static_cast(durationSeconds*250.0f)/* 25% progress */); // We didn't expect the animation to finish yet application.SendNotification(); finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + float progress = max(0.0f, 0.25f - delay) / (1.0f - delay); + DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians * progress*progress*progress, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */); + application.Render(static_cast(durationSeconds*250.0f)/* 50% progress */); // We didn't expect the animation to finish yet application.SendNotification(); finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetProperty(index), startValue+(relativeValue*0.5f), TEST_LOCATION ); + progress = max(0.0f, 0.5f - delay) / (1.0f - delay); + DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians * progress*progress*progress, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/); + application.Render(static_cast(durationSeconds*250.0f)/* 75% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + progress = max(0.0f, 0.75f - delay) / (1.0f - delay); + DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians * progress*progress*progress, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(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(index), targetValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationAnimateToVector4(void) +int UtcDaliAnimationAnimateByActorScaleP(void) { TestApplication application; Actor actor = Actor::New(); - - // Register a Vector4 property - Vector4 startValue(-50.0f, -40.0f, -30.0f, -20.0f); - Property::Index index = actor.RegisterProperty( "test-property", startValue ); Stage::GetCurrent().Add(actor); - DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION ); // Build the animation - float durationSeconds(2.0f); + float durationSeconds(1.0f); Animation animation = Animation::New(durationSeconds); - Vector4 targetValue(50.0f, 50.0f, 50.0f, 50.0f); - Vector4 relativeValue(targetValue - startValue); - animation.AnimateTo(Property(actor, index), targetValue); + Vector3 targetScale(2.0f, 2.0f, 2.0f); + Vector3 relativeScale(targetScale - Vector3::ONE); + animation.AnimateBy( Property( actor, Actor::Property::SCALE ), Vector3( relativeScale.x, relativeScale.y, relativeScale.z ) ); - Vector4 ninetyFivePercentProgress(startValue + relativeValue*0.95f); + Vector3 ninetyNinePercentProgress(Vector3::ONE + relativeScale*0.99f); // Start the animation animation.Play(); @@ -4321,43 +4771,107 @@ int UtcDaliAnimationAnimateToVector4(void) animation.FinishedSignal().Connect(&application, finishCheck); application.SendNotification(); - application.Render(static_cast(durationSeconds*950.0f)/* 95% progress */); + application.Render(static_cast(durationSeconds*990.0f)/* 99% progress */); // We didn't expect the animation to finish yet application.SendNotification(); finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetProperty(index), ninetyFivePercentProgress, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentScale(), ninetyNinePercentProgress, TEST_LOCATION ); application.SendNotification(); - application.Render(static_cast(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/); + application.Render(static_cast(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(index), targetValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION ); + + // Reset everything + finishCheck.Reset(); + actor.SetScale(Vector3::ONE); + application.SendNotification(); + application.Render(0); + DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION ); + + // Repeat with a different (ease-in) alpha function + animation = Animation::New(durationSeconds); + animation.AnimateBy( Property( actor, Actor::Property::SCALE ), relativeScale, AlphaFunction::EASE_IN ); + animation.FinishedSignal().Connect(&application, finishCheck); + animation.Play(); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*990.0f)/* 99% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + + // The scale should have grown less, than with a linear alpha function + Vector3 current(actor.GetCurrentScale()); + DALI_TEST_CHECK( current.x > 1.0f ); + DALI_TEST_CHECK( current.y > 1.0f ); + DALI_TEST_CHECK( current.z > 1.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(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION ); + + // Reset everything + finishCheck.Reset(); + actor.SetScale(Vector3::ONE); + application.SendNotification(); + application.Render(0); + DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION ); + + // Repeat with a delay + float delay = 0.5f; + animation = Animation::New(durationSeconds); + animation.AnimateBy( Property( actor, Actor::Property::SCALE ), relativeScale, AlphaFunction::LINEAR, TimePeriod( delay, durationSeconds - delay ) ); + animation.FinishedSignal().Connect(&application, finishCheck); + animation.Play(); + + application.SendNotification(); + application.Render(static_cast(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.GetCurrentScale(), Vector3::ONE, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationAnimateToVector4AlphaFunction(void) +int UtcDaliAnimationAnimateToBooleanP(void) { TestApplication application; Actor actor = Actor::New(); - // Register a Vector4 property - Vector4 startValue(1000.0f, 1000.0f, 1000.0f, 1000.0f); - Property::Index index = actor.RegisterProperty( "test-property", startValue ); + // Register a boolean property + const bool startValue(false); + Property::Index index = actor.RegisterProperty( "testProperty", startValue ); Stage::GetCurrent().Add(actor); - DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + DALI_TEST_CHECK( actor.GetProperty(index) == startValue ); // Build the animation - float durationSeconds(1.0f); + float durationSeconds(2.0f); Animation animation = Animation::New(durationSeconds); - Vector4 targetValue(9000.0f, 9000.0f, 9000.0f, 9000.0f); - Vector4 relativeValue(targetValue - startValue); - animation.AnimateTo(Property(actor, index), targetValue, AlphaFunctions::EaseOut); - - Vector4 ninetyFivePercentProgress(startValue + relativeValue*0.95f); + const bool targetValue( !startValue ); + animation.AnimateTo(Property(actor, index), targetValue); // Start the animation animation.Play(); @@ -4372,13 +4886,40 @@ int UtcDaliAnimationAnimateToVector4AlphaFunction(void) // We didn't expect the animation to finish yet application.SendNotification(); finishCheck.CheckSignalNotReceived(); + DALI_TEST_CHECK( actor.GetProperty(index) == startValue ); - // The position should have moved more, than with a linear alpha function - Vector4 current(actor.GetProperty(index)); - DALI_TEST_CHECK( current.x > ninetyFivePercentProgress.x ); - DALI_TEST_CHECK( current.y > ninetyFivePercentProgress.y ); - DALI_TEST_CHECK( current.z > ninetyFivePercentProgress.z ); - DALI_TEST_CHECK( current.w > ninetyFivePercentProgress.w ); + application.SendNotification(); + application.Render(static_cast(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_CHECK( actor.GetProperty(index) == targetValue ); + + // Check that nothing has changed after a couple of buffer swaps + application.Render(0); + DALI_TEST_CHECK( actor.GetProperty(index) == targetValue ); + application.Render(0); + DALI_TEST_CHECK( actor.GetProperty(index) == targetValue ); + + // Repeat with target value "false" + animation = Animation::New(durationSeconds); + const bool finalValue( !targetValue ); + animation.AnimateTo(Property(actor, index), finalValue); + + // Start the animation + animation.Play(); + + finishCheck.Reset(); + animation.FinishedSignal().Connect(&application, finishCheck); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*950.0f)/* 95% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_CHECK( actor.GetProperty(index) == targetValue ); application.SendNotification(); application.Render(static_cast(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/); @@ -4386,31 +4927,33 @@ int UtcDaliAnimationAnimateToVector4AlphaFunction(void) // We did expect the animation to finish application.SendNotification(); finishCheck.CheckSignalReceived(); - DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + DALI_TEST_CHECK( actor.GetProperty(index) == finalValue ); + + // Check that nothing has changed after a couple of buffer swaps + application.Render(0); + DALI_TEST_CHECK( actor.GetProperty(index) == finalValue ); + application.Render(0); + DALI_TEST_CHECK( actor.GetProperty(index) == finalValue ); END_TEST; } -int UtcDaliAnimationAnimateToVector4TimePeriod(void) +int UtcDaliAnimationAnimateToBooleanAlphaFunctionP(void) { TestApplication application; Actor actor = Actor::New(); - // Register a Vector4 property - Vector4 startValue(10.0f, 10.0f, 10.0f, 10.0f); - Property::Index index = actor.RegisterProperty( "test-property", startValue ); + // Register a boolean property + const bool startValue(false); + Property::Index index = actor.RegisterProperty( "testProperty", startValue ); Stage::GetCurrent().Add(actor); - DALI_TEST_EQUALS( actor.GetProperty(index), startValue, VECTOR4_EPSILON, TEST_LOCATION ); + DALI_TEST_CHECK( actor.GetProperty(index) == startValue ); // Build the animation - float durationSeconds(1.0f); + float durationSeconds(2.0f); Animation animation = Animation::New(durationSeconds); - Vector4 targetValue(-10.0f, 20.0f, 100.0f, 100.0f); - Vector4 relativeValue(targetValue - startValue); - float delay = 0.5f; - animation.AnimateTo(Property(actor, index), - targetValue, - TimePeriod(delay, durationSeconds - delay)); + const bool targetValue( !startValue ); + animation.AnimateTo(Property(actor, "testProperty"), targetValue, AlphaFunction::EASE_OUT); // Start the animation animation.Play(); @@ -4420,53 +4963,82 @@ int UtcDaliAnimationAnimateToVector4TimePeriod(void) animation.FinishedSignal().Connect(&application, finishCheck); application.SendNotification(); - application.Render(static_cast(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */); + application.Render(static_cast(durationSeconds*950.0f)/* 95% progress */); // We didn't expect the animation to finish yet application.SendNotification(); finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetProperty(index), startValue, VECTOR4_EPSILON, TEST_LOCATION ); + DALI_TEST_CHECK( actor.GetProperty(index) == startValue ); application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */); + application.Render(static_cast(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_CHECK( actor.GetProperty(index) == targetValue ); + + // Check that nothing has changed after a couple of buffer swaps + application.Render(0); + DALI_TEST_CHECK( actor.GetProperty(index) == targetValue ); + application.Render(0); + DALI_TEST_CHECK( actor.GetProperty(index) == targetValue ); + + // Repeat with target value "false" + animation = Animation::New(durationSeconds); + const bool finalValue( !targetValue ); + animation.AnimateTo(Property(actor, index), finalValue, AlphaFunction::EASE_OUT); + + // Start the animation + animation.Play(); + + finishCheck.Reset(); + animation.FinishedSignal().Connect(&application, finishCheck); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*950.0f)/* 95% progress */); // We didn't expect the animation to finish yet application.SendNotification(); finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetProperty(index), startValue+(relativeValue*0.5f), VECTOR4_EPSILON, TEST_LOCATION ); + DALI_TEST_CHECK( actor.GetProperty(index) == targetValue ); application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/); + application.Render(static_cast(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/); // We did expect the animation to finish application.SendNotification(); finishCheck.CheckSignalReceived(); - DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, VECTOR4_EPSILON, TEST_LOCATION ); + DALI_TEST_CHECK( actor.GetProperty(index) == finalValue ); + + // Check that nothing has changed after a couple of buffer swaps + application.Render(0); + DALI_TEST_CHECK( actor.GetProperty(index) == finalValue ); + application.Render(0); + DALI_TEST_CHECK( actor.GetProperty(index) == finalValue ); END_TEST; } -int UtcDaliAnimationAnimateToVector4AlphaFunctionTimePeriod(void) +int UtcDaliAnimationAnimateToBooleanTimePeriodP(void) { TestApplication application; Actor actor = Actor::New(); - // Register a Vector4 property - Vector4 startValue(10.0f, 10.0f, 10.0f, 10.0f); - Property::Index index = actor.RegisterProperty( "test-property", startValue ); + // Register a boolean property + bool startValue(false); + Property::Index index = actor.RegisterProperty( "testProperty", startValue ); Stage::GetCurrent().Add(actor); - DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + DALI_TEST_CHECK( actor.GetProperty(index) == startValue ); // Build the animation - float durationSeconds(1.0f); + float durationSeconds(2.0f); Animation animation = Animation::New(durationSeconds); - Vector4 targetValue(30.0f, 30.0f, 30.0f, 30.0f); - Vector4 relativeValue(targetValue - startValue); - float delay = 0.5f; - animation.AnimateTo(Property(actor, index), - targetValue, - AlphaFunctions::Linear, - TimePeriod(delay, durationSeconds - delay)); + bool finalValue( !startValue ); + float animatorDurationSeconds(durationSeconds * 0.5f); + animation.AnimateTo( Property(actor, index), + finalValue, + TimePeriod( animatorDurationSeconds ) ); // Start the animation animation.Play(); @@ -4476,258 +5048,218 @@ int UtcDaliAnimationAnimateToVector4AlphaFunctionTimePeriod(void) animation.FinishedSignal().Connect(&application, finishCheck); application.SendNotification(); - application.Render(static_cast(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */); + application.Render(static_cast(animatorDurationSeconds*950.0f)/* 95% animator progress */); // We didn't expect the animation to finish yet application.SendNotification(); finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + DALI_TEST_CHECK( actor.GetProperty(index) == startValue ); application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */); + application.Render(static_cast(animatorDurationSeconds*50.0f) + 1u/*just beyond the animator duration*/); - // We didn't expect the animation to finish yet + // We didn't expect the animation to finish yet... application.SendNotification(); finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetProperty(index), startValue+(relativeValue*0.5f), TEST_LOCATION ); + + // ...however we should have reached the final value + DALI_TEST_CHECK( actor.GetProperty(index) == finalValue ); application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/); + application.Render(static_cast(animatorDurationSeconds*1000.0f)/*just beyond the animation duration*/); // We did expect the animation to finish application.SendNotification(); finishCheck.CheckSignalReceived(); - DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + DALI_TEST_CHECK( actor.GetProperty(index) == finalValue ); + + // Check that nothing has changed after a couple of buffer swaps + application.Render(0); + DALI_TEST_CHECK( actor.GetProperty(index) == finalValue ); + application.Render(0); + DALI_TEST_CHECK( actor.GetProperty(index) == finalValue ); END_TEST; } -int UtcDaliAnimationAnimateToActorParentOrigin(void) +int UtcDaliAnimationAnimateToBooleanAlphaFunctionTimePeriodP(void) { TestApplication application; Actor actor = Actor::New(); + + // Register a boolean property + bool startValue(false); + Property::Index index = actor.RegisterProperty( "testProperty", startValue ); Stage::GetCurrent().Add(actor); - DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::TOP_LEFT, TEST_LOCATION ); + DALI_TEST_CHECK( actor.GetProperty(index) == startValue ); // Build the animation - float durationSeconds(1.0f); + float durationSeconds(2.0f); Animation animation = Animation::New(durationSeconds); - Vector3 targetParentOrigin(ParentOrigin::BOTTOM_RIGHT); + bool finalValue( !startValue ); + float animatorDurationSeconds(durationSeconds * 0.5f); + animation.AnimateTo( Property(actor, index), + finalValue, + AlphaFunction::LINEAR, + TimePeriod( animatorDurationSeconds ) ); - try - { - animation.AnimateTo( Property(actor, Actor::PARENT_ORIGIN), targetParentOrigin ); - } - catch (Dali::DaliException& e) - { - tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str()); - DALI_TEST_ASSERT(e, "IsPropertyAnimatable(index)", TEST_LOCATION); - } - END_TEST; -} + // Start the animation + animation.Play(); -int UtcDaliAnimationAnimateToActorParentOriginX(void) -{ - TestApplication application; + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); - Actor actor = Actor::New(); - Stage::GetCurrent().Add(actor); - float startValue(0.0f); - DALI_TEST_EQUALS( actor.GetCurrentParentOrigin().x, startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::PARENT_ORIGIN_X), startValue, TEST_LOCATION ); + application.SendNotification(); + application.Render(static_cast(animatorDurationSeconds*950.0f)/* 95% animator progress */); - // Build the animation - float durationSeconds(1.0f); - Animation animation = Animation::New(durationSeconds); - float targetX(1.0f); + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_CHECK( actor.GetProperty(index) == startValue ); - try - { - animation.AnimateTo( Property(actor, Actor::PARENT_ORIGIN_X), targetX ); - } - catch (Dali::DaliException& e) - { - tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str()); - DALI_TEST_ASSERT(e, "IsPropertyAnimatable(index)", TEST_LOCATION); - } - END_TEST; -} + application.SendNotification(); + application.Render(static_cast(animatorDurationSeconds*50.0f) + 1u/*just beyond the animator duration*/); -int UtcDaliAnimationAnimateToActorParentOriginY(void) -{ - TestApplication application; + // We didn't expect the animation to finish yet... + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); - Actor actor = Actor::New(); - Stage::GetCurrent().Add(actor); - float startValue(0.0f); - DALI_TEST_EQUALS( actor.GetCurrentParentOrigin().y, startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::PARENT_ORIGIN_Y), startValue, TEST_LOCATION ); + // ...however we should have reached the final value + DALI_TEST_CHECK( actor.GetProperty(index) == finalValue ); - // Build the animation - float durationSeconds(1.0f); - Animation animation = Animation::New(durationSeconds); - float targetY(1.0f); + application.SendNotification(); + application.Render(static_cast(animatorDurationSeconds*1000.0f)/*just beyond the animation duration*/); - try - { - animation.AnimateTo( Property(actor, Actor::PARENT_ORIGIN_Y), targetY ); - } - catch (Dali::DaliException& e) - { - tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str()); - DALI_TEST_ASSERT(e, "IsPropertyAnimatable(index)", TEST_LOCATION); - } + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_CHECK( actor.GetProperty(index) == finalValue ); + + // Check that nothing has changed after a couple of buffer swaps + application.Render(0); + DALI_TEST_CHECK( actor.GetProperty(index) == finalValue ); + application.Render(0); + DALI_TEST_CHECK( actor.GetProperty(index) == finalValue ); END_TEST; } -int UtcDaliAnimationAnimateToActorParentOriginZ(void) +int UtcDaliAnimationAnimateToFloatP(void) { TestApplication application; Actor actor = Actor::New(); + + // Register a float property + float startValue(10.0f); + Property::Index index = actor.RegisterProperty( "testProperty", startValue ); Stage::GetCurrent().Add(actor); - float startValue(0.5f); - DALI_TEST_EQUALS( actor.GetCurrentParentOrigin().z, startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::PARENT_ORIGIN_Z), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); // Build the animation - float durationSeconds(1.0f); + float durationSeconds(2.0f); Animation animation = Animation::New(durationSeconds); - float targetZ(1.0f); + float targetValue(50.0f); + float relativeValue(targetValue - startValue); + animation.AnimateTo(Property(actor, "testProperty"), targetValue); - try - { - animation.AnimateTo( Property(actor, Actor::PARENT_ORIGIN_Z), targetZ ); - } - catch (Dali::DaliException& e) - { - tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str()); - DALI_TEST_ASSERT(e, "IsPropertyAnimatable(index)", TEST_LOCATION); - } - END_TEST; -} + float ninetyFivePercentProgress(startValue + relativeValue*0.95f); -int UtcDaliAnimationAnimateToActorAnchorPoint(void) -{ - TestApplication application; + // Start the animation + animation.Play(); - Actor actor = Actor::New(); - Stage::GetCurrent().Add(actor); - DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), AnchorPoint::CENTER, TEST_LOCATION ); + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); - // Build the animation - float durationSeconds(1.0f); - Animation animation = Animation::New(durationSeconds); - Vector3 targetAnchorPoint(AnchorPoint::TOP_LEFT); + application.SendNotification(); + application.Render(static_cast(durationSeconds*950.0f)/* 95% progress */); - try - { - animation.AnimateTo( Property(actor, Actor::ANCHOR_POINT), targetAnchorPoint); - } - catch (Dali::DaliException& e) - { - tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str()); - DALI_TEST_ASSERT(e, "IsPropertyAnimatable(index)", TEST_LOCATION); - } + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetProperty(index), ninetyFivePercentProgress, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationAnimateToActorAnchorPointX(void) +int UtcDaliAnimationAnimateToFloatAlphaFunctionP(void) { TestApplication application; Actor actor = Actor::New(); + + // Register a float property + float startValue(10.0f); + Property::Index index = actor.RegisterProperty( "testProperty", startValue ); Stage::GetCurrent().Add(actor); - float startValue(0.5f); - DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint().x, startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::ANCHOR_POINT_X), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); // Build the animation float durationSeconds(1.0f); Animation animation = Animation::New(durationSeconds); - float targetX(1.0f); - - try - { - animation.AnimateTo( Property(actor, Actor::ANCHOR_POINT_X), targetX ); - } - catch (Dali::DaliException& e) - { - tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str()); - DALI_TEST_ASSERT(e, "IsPropertyAnimatable(index)", TEST_LOCATION); - } - END_TEST; -} + float targetValue(90.0f); + float relativeValue(targetValue - startValue); + animation.AnimateTo(Property(actor, index), targetValue, AlphaFunction::EASE_OUT); -int UtcDaliAnimationAnimateToActorAnchorPointY(void) -{ - TestApplication application; + float ninetyFivePercentProgress(startValue + relativeValue*0.95f); - Actor actor = Actor::New(); - Stage::GetCurrent().Add(actor); - float startValue(0.5f); - DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint().y, startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::ANCHOR_POINT_Y), startValue, TEST_LOCATION ); + // Start the animation + animation.Play(); - // Build the animation - float durationSeconds(1.0f); - Animation animation = Animation::New(durationSeconds); - float targetY(0.0f); + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); - try - { - animation.AnimateTo( Property(actor, Actor::ANCHOR_POINT_Y), targetY ); - } - catch (Dali::DaliException& e) - { - tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str()); - DALI_TEST_ASSERT(e, "IsPropertyAnimatable(index)", TEST_LOCATION); - } - END_TEST; -} + application.SendNotification(); + application.Render(static_cast(durationSeconds*950.0f)/* 95% progress */); -int UtcDaliAnimationAnimateToActorAnchorPointZ(void) -{ - TestApplication application; + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); - Actor actor = Actor::New(); - Stage::GetCurrent().Add(actor); - float startValue(0.5f); - DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint().z, startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::ANCHOR_POINT_Z), startValue, TEST_LOCATION ); + // The position should have moved more, than with a linear alpha function + float current(actor.GetProperty(index)); + DALI_TEST_CHECK( current > ninetyFivePercentProgress ); - // Build the animation - float durationSeconds(1.0f); - Animation animation = Animation::New(durationSeconds); - float targetZ(100.0f); + application.SendNotification(); + application.Render(static_cast(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/); - try - { - animation.AnimateTo( Property(actor, Actor::ANCHOR_POINT_Z), targetZ ); - } - catch (Dali::DaliException& e) - { - tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str()); - DALI_TEST_ASSERT(e, "IsPropertyAnimatable(index)", TEST_LOCATION); - } + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationAnimateToActorSize(void) +int UtcDaliAnimationAnimateToFloatTimePeriodP(void) { TestApplication application; Actor actor = Actor::New(); + + // Register a float property + float startValue(10.0f); + Property::Index index = actor.RegisterProperty( "testProperty", startValue ); Stage::GetCurrent().Add(actor); - DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); // Build the animation float durationSeconds(1.0f); Animation animation = Animation::New(durationSeconds); - Vector3 targetSize(100.0f, 100.0f, 100.0f); - animation.AnimateTo( Property(actor, Actor::SIZE), targetSize ); - - Vector3 ninetyNinePercentProgress(targetSize * 0.99f); + float targetValue(30.0f); + float relativeValue(targetValue - startValue); + float delay = 0.5f; + animation.AnimateTo(Property(actor, index), + targetValue, + TimePeriod(delay, durationSeconds - delay)); // Start the animation animation.Play(); @@ -4737,71 +5269,60 @@ int UtcDaliAnimationAnimateToActorSize(void) animation.FinishedSignal().Connect(&application, finishCheck); application.SendNotification(); - application.Render(static_cast(durationSeconds*990.0f)/* 99% progress */); + application.Render(static_cast(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(), ninetyNinePercentProgress, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); application.SendNotification(); - application.Render(static_cast(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/); + application.Render(static_cast(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */); - // We did expect the animation to finish + // We didn't expect the animation to finish yet application.SendNotification(); - finishCheck.CheckSignalReceived(); - DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION ); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue+(relativeValue*0.5f), 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.AnimateTo( Property(actor, Actor::SIZE), targetSize, AlphaFunctions::EaseIn); - animation.FinishedSignal().Connect(&application, finishCheck); - animation.Play(); + application.Render(static_cast(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/); + // We did expect the animation to finish application.SendNotification(); - application.Render(static_cast(durationSeconds*990.0f)/* 99% progress */); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + END_TEST; +} - // We didn't expect the animation to finish yet - application.SendNotification(); - finishCheck.CheckSignalNotReceived(); +int UtcDaliAnimationAnimateToFloatAlphaFunctionTimePeriodP(void) +{ + TestApplication application; - // 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 ); + Actor actor = Actor::New(); - application.SendNotification(); - application.Render(static_cast(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/); + // Register a float property + float startValue(10.0f); + Property::Index index = actor.RegisterProperty( "testProperty", startValue ); + Stage::GetCurrent().Add(actor); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); - // We did expect the animation to finish - application.SendNotification(); - finishCheck.CheckSignalReceived(); - DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION ); + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + float targetValue(30.0f); + float relativeValue(targetValue - startValue); + float delay = 0.5f; + animation.AnimateTo(Property(actor, index), + targetValue, + AlphaFunction::LINEAR, + TimePeriod(delay, durationSeconds - delay)); - // Reset everything - finishCheck.Reset(); - actor.SetSize(Vector3::ZERO); - application.SendNotification(); - application.Render(0); - DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION ); + // Start the animation + animation.Play(); - // Repeat with a delay - float delay = 0.5f; - animation = Animation::New(durationSeconds); - animation.AnimateTo( Property(actor, Actor::SIZE), targetSize, AlphaFunctions::Linear, TimePeriod(delay, durationSeconds - delay)); + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); animation.FinishedSignal().Connect(&application, finishCheck); - animation.Play(); application.SendNotification(); application.Render(static_cast(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */); @@ -4809,35 +5330,46 @@ int UtcDaliAnimationAnimateToActorSize(void) // We didn't expect the animation to finish yet application.SendNotification(); finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); application.SendNotification(); - application.Render(static_cast(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/); + application.Render(static_cast(durationSeconds*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(index), startValue+(relativeValue*0.5f), TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.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 ); + DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationAnimateToActorSizeWidth(void) +int UtcDaliAnimationAnimateToIntegerP(void) { TestApplication application; Actor actor = Actor::New(); + + // Register an integer property + int startValue(10); + Property::Index index = actor.RegisterProperty( "testProperty", startValue ); Stage::GetCurrent().Add(actor); - float startValue(0.0f); - DALI_TEST_EQUALS( actor.GetCurrentSize().width, startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::SIZE_WIDTH), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); // Build the animation - float durationSeconds(1.0f); + float durationSeconds(2.0f); Animation animation = Animation::New(durationSeconds); - float targetWidth(10.0f); - animation.AnimateTo( Property(actor, Actor::SIZE_WIDTH), targetWidth ); + int targetValue(50); + int relativeValue(targetValue - startValue); + animation.AnimateTo(Property(actor, "testProperty"), targetValue); - float fiftyPercentProgress(startValue + (targetWidth - startValue)*0.5f); + int ninetyFivePercentProgress(static_cast(startValue + relativeValue*0.95f + 0.5f)); // Start the animation animation.Play(); @@ -4847,42 +5379,43 @@ int UtcDaliAnimationAnimateToActorSizeWidth(void) animation.FinishedSignal().Connect(&application, finishCheck); application.SendNotification(); - application.Render(static_cast(durationSeconds*500.0f)/* 50% progress */); + application.Render(static_cast(durationSeconds*950.0f)/* 95% progress */); // We didn't expect the animation to finish yet application.SendNotification(); finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetCurrentSize().width, fiftyPercentProgress, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::SIZE_WIDTH), fiftyPercentProgress, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(index), ninetyFivePercentProgress, TEST_LOCATION ); application.SendNotification(); - application.Render(static_cast(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/); + application.Render(static_cast(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/); // We did expect the animation to finish application.SendNotification(); finishCheck.CheckSignalReceived(); - DALI_TEST_EQUALS( actor.GetCurrentSize().width, targetWidth, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::SIZE_WIDTH), targetWidth, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationAnimateToActorSizeHeight(void) +int UtcDaliAnimationAnimateToIntegerAlphaFunctionP(void) { TestApplication application; Actor actor = Actor::New(); + + // Register an integer property + int startValue(10); + Property::Index index = actor.RegisterProperty( "testProperty", startValue ); Stage::GetCurrent().Add(actor); - float startValue(0.0f); - DALI_TEST_EQUALS( actor.GetCurrentSize().height, startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::SIZE_HEIGHT), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); // Build the animation float durationSeconds(1.0f); Animation animation = Animation::New(durationSeconds); - float targetHeight(-10.0f); - animation.AnimateTo( Property(actor, Actor::SIZE_HEIGHT), targetHeight ); + int targetValue(90); + int relativeValue(targetValue - startValue); + animation.AnimateTo(Property(actor, index), targetValue, AlphaFunction::EASE_OUT); - float fiftyPercentProgress(startValue + (targetHeight - startValue)*0.5f); + int ninetyFivePercentProgress(static_cast(startValue + relativeValue*0.95f + 0.5f)); // Start the animation animation.Play(); @@ -4892,42 +5425,47 @@ int UtcDaliAnimationAnimateToActorSizeHeight(void) animation.FinishedSignal().Connect(&application, finishCheck); application.SendNotification(); - application.Render(static_cast(durationSeconds*500.0f)/* 50% progress */); + application.Render(static_cast(durationSeconds*950.0f)/* 95% progress */); // We didn't expect the animation to finish yet application.SendNotification(); finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetCurrentSize().height, fiftyPercentProgress, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::SIZE_HEIGHT), fiftyPercentProgress, TEST_LOCATION ); + + // The position should have moved more, than with a linear alpha function + int current(actor.GetProperty(index)); + DALI_TEST_CHECK( current > ninetyFivePercentProgress ); application.SendNotification(); - application.Render(static_cast(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/); + application.Render(static_cast(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/); // We did expect the animation to finish application.SendNotification(); finishCheck.CheckSignalReceived(); - DALI_TEST_EQUALS( actor.GetCurrentSize().height, targetHeight, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::SIZE_HEIGHT), targetHeight, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationAnimateToActorSizeDepth(void) +int UtcDaliAnimationAnimateToIntegerTimePeriodP(void) { TestApplication application; Actor actor = Actor::New(); + + // Register an integer property + int startValue(10); + Property::Index index = actor.RegisterProperty( "testProperty", startValue ); Stage::GetCurrent().Add(actor); - float startValue(0.0f); - DALI_TEST_EQUALS( actor.GetCurrentSize().depth, startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::SIZE_DEPTH), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); // Build the animation float durationSeconds(1.0f); Animation animation = Animation::New(durationSeconds); - float targetDepth(-10.0f); - animation.AnimateTo( Property(actor, Actor::SIZE_DEPTH), targetDepth ); - - float fiftyPercentProgress(startValue + (targetDepth - startValue)*0.5f); + int targetValue(30); + int relativeValue(targetValue - startValue); + float delay = 0.5f; + animation.AnimateTo(Property(actor, index), + targetValue, + TimePeriod(delay, durationSeconds - delay)); // Start the animation animation.Play(); @@ -4937,40 +5475,53 @@ int UtcDaliAnimationAnimateToActorSizeDepth(void) animation.FinishedSignal().Connect(&application, finishCheck); application.SendNotification(); - application.Render(static_cast(durationSeconds*500.0f)/* 50% progress */); + application.Render(static_cast(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().depth, fiftyPercentProgress, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::SIZE_DEPTH), fiftyPercentProgress, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); application.SendNotification(); - application.Render(static_cast(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/); + application.Render(static_cast(durationSeconds*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(index), static_cast(startValue+(relativeValue*0.5f)+0.5f), TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/); // We did expect the animation to finish application.SendNotification(); finishCheck.CheckSignalReceived(); - DALI_TEST_EQUALS( actor.GetCurrentSize().depth, targetDepth, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::SIZE_DEPTH), targetDepth, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationAnimateToActorPosition(void) +int UtcDaliAnimationAnimateToIntegerAlphaFunctionTimePeriodP(void) { TestApplication application; Actor actor = Actor::New(); + + // Register an integer property + int startValue(10); + Property::Index index = actor.RegisterProperty( "testProperty", startValue ); Stage::GetCurrent().Add(actor); - DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); // Build the animation float durationSeconds(1.0f); Animation animation = Animation::New(durationSeconds); - Vector3 targetPosition(200.0f, 200.0f, 200.0f); - animation.AnimateTo(Property(actor, Actor::POSITION), targetPosition); - - Vector3 seventyFivePercentProgress(targetPosition * 0.75f); + int targetValue(30); + int relativeValue(targetValue - startValue); + float delay = 0.5f; + animation.AnimateTo(Property(actor, index), + targetValue, + AlphaFunction::LINEAR, + TimePeriod(delay, durationSeconds - delay)); // Start the animation animation.Play(); @@ -4980,12 +5531,20 @@ int UtcDaliAnimationAnimateToActorPosition(void) animation.FinishedSignal().Connect(&application, finishCheck); application.SendNotification(); - application.Render(static_cast(durationSeconds*750.0f)/* 75% progress */); + application.Render(static_cast(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.GetCurrentPosition(), seventyFivePercentProgress, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*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(index), static_cast(startValue+(relativeValue*0.5f)+0.5f), TEST_LOCATION ); application.SendNotification(); application.Render(static_cast(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/); @@ -4993,29 +5552,30 @@ int UtcDaliAnimationAnimateToActorPosition(void) // We did expect the animation to finish application.SendNotification(); finishCheck.CheckSignalReceived(); - DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationAnimateToActorPositionX(void) +int UtcDaliAnimationAnimateToVector2P(void) { TestApplication application; Actor actor = Actor::New(); + + // Register a Vector2 property + Vector2 startValue(-50.0f, -50.0f); + Property::Index index = actor.RegisterProperty( "testProperty", startValue ); Stage::GetCurrent().Add(actor); - float startValue(0.0f); - DALI_TEST_EQUALS( actor.GetCurrentPosition().x, startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::POSITION_X), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::POSITION_Y), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::POSITION_Z), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); // Build the animation - float durationSeconds(1.0f); + float durationSeconds(2.0f); Animation animation = Animation::New(durationSeconds); - float targetX(1.0f); - animation.AnimateTo( Property(actor, Actor::POSITION_X), targetX ); + Vector2 targetValue(50.0f, 50.0f); + Vector2 relativeValue(targetValue - startValue); + animation.AnimateTo(Property(actor, index), targetValue); - float fiftyPercentProgress(startValue + (targetX - startValue)*0.5f); + Vector2 ninetyFivePercentProgress(startValue + relativeValue*0.95f); // Start the animation animation.Play(); @@ -5025,48 +5585,43 @@ int UtcDaliAnimationAnimateToActorPositionX(void) animation.FinishedSignal().Connect(&application, finishCheck); application.SendNotification(); - application.Render(static_cast(durationSeconds*500.0f)/* 50% progress */); + application.Render(static_cast(durationSeconds*950.0f)/* 95% progress */); // We didn't expect the animation to finish yet application.SendNotification(); finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetCurrentPosition().x, fiftyPercentProgress, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::POSITION_X), fiftyPercentProgress, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::POSITION_Y), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::POSITION_Z), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(index), ninetyFivePercentProgress, TEST_LOCATION ); application.SendNotification(); - application.Render(static_cast(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/); + application.Render(static_cast(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().x, targetX, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::POSITION_X), targetX, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::POSITION_Y), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::POSITION_Z), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationAnimateToActorPositionY(void) +int UtcDaliAnimationAnimateToVector2AlphaFunctionP(void) { TestApplication application; Actor actor = Actor::New(); + + // Register a Vector2 property + Vector2 startValue(1000.0f, 1000.0f); + Property::Index index = actor.RegisterProperty( "testProperty", startValue ); Stage::GetCurrent().Add(actor); - float startValue(0.0f); - DALI_TEST_EQUALS( actor.GetCurrentPosition().y, startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::POSITION_X), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::POSITION_Y), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::POSITION_Z), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); // Build the animation float durationSeconds(1.0f); Animation animation = Animation::New(durationSeconds); - float targetY(10.0f); - animation.AnimateTo( Property(actor, Actor::POSITION_Y), targetY ); + Vector2 targetValue(9000.0f, 9000.0f); + Vector2 relativeValue(targetValue - startValue); + animation.AnimateTo(Property(actor, "testProperty"), targetValue, AlphaFunction::EASE_OUT); - float fiftyPercentProgress(startValue + (targetY - startValue)*0.5f); + Vector2 ninetyFivePercentProgress(startValue + relativeValue*0.95f); // Start the animation animation.Play(); @@ -5076,48 +5631,48 @@ int UtcDaliAnimationAnimateToActorPositionY(void) animation.FinishedSignal().Connect(&application, finishCheck); application.SendNotification(); - application.Render(static_cast(durationSeconds*500.0f)/* 50% progress */); + application.Render(static_cast(durationSeconds*950.0f)/* 95% progress */); // We didn't expect the animation to finish yet application.SendNotification(); finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetCurrentPosition().y, fiftyPercentProgress, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::POSITION_X), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::POSITION_Y), fiftyPercentProgress, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::POSITION_Z), startValue, TEST_LOCATION ); + + // The position should have moved more, than with a linear alpha function + Vector2 current(actor.GetProperty(index)); + DALI_TEST_CHECK( current.x > ninetyFivePercentProgress.x ); + DALI_TEST_CHECK( current.y > ninetyFivePercentProgress.y ); application.SendNotification(); - application.Render(static_cast(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/); + application.Render(static_cast(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().y, targetY, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::POSITION_X), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::POSITION_Y), targetY, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::POSITION_Z), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationAnimateToActorPositionZ(void) +int UtcDaliAnimationAnimateToVector2TimePeriodP(void) { TestApplication application; Actor actor = Actor::New(); + + // Register a Vector2 property + Vector2 startValue(10.0f, 10.0f); + Property::Index index = actor.RegisterProperty( "testProperty", startValue ); Stage::GetCurrent().Add(actor); - float startValue(0.0f); - DALI_TEST_EQUALS( actor.GetCurrentPosition().z, startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::POSITION_X), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::POSITION_Y), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::POSITION_Z), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); // Build the animation float durationSeconds(1.0f); Animation animation = Animation::New(durationSeconds); - float targetZ(-5.0f); - animation.AnimateTo( Property(actor, Actor::POSITION_Z), targetZ ); - - float fiftyPercentProgress(startValue + (targetZ - startValue)*0.5f); + Vector2 targetValue(-10.0f, 20.0f); + Vector2 relativeValue(targetValue - startValue); + float delay = 0.5f; + animation.AnimateTo(Property(actor, index), + targetValue, + TimePeriod(delay, durationSeconds - delay)); // Start the animation animation.Play(); @@ -5127,44 +5682,53 @@ int UtcDaliAnimationAnimateToActorPositionZ(void) animation.FinishedSignal().Connect(&application, finishCheck); application.SendNotification(); - application.Render(static_cast(durationSeconds*500.0f)/* 50% progress */); + application.Render(static_cast(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.GetCurrentPosition().z, fiftyPercentProgress, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::POSITION_X), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::POSITION_Y), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::POSITION_Z), fiftyPercentProgress, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); application.SendNotification(); - application.Render(static_cast(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/); + application.Render(static_cast(durationSeconds*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(index), startValue+(relativeValue*0.5f), TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(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().z, targetZ, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::POSITION_X), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::POSITION_Y), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::POSITION_Z), targetZ, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationAnimateToActorPositionAlphaFunction(void) +int UtcDaliAnimationAnimateToVector2AlphaFunctionTimePeriodP(void) { TestApplication application; Actor actor = Actor::New(); + + // Register a Vector2 property + Vector2 startValue(10.0f, 10.0f); + Property::Index index = actor.RegisterProperty( "testProperty", startValue ); Stage::GetCurrent().Add(actor); - DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); // Build the animation float durationSeconds(1.0f); Animation animation = Animation::New(durationSeconds); - Vector3 targetPosition(200.0f, 200.0f, 200.0f); - animation.AnimateTo(Property(actor, Actor::POSITION), targetPosition, AlphaFunctions::EaseIn); - - Vector3 seventyFivePercentProgress(targetPosition * 0.75f); + Vector2 targetValue(30.0f, 30.0f); + Vector2 relativeValue(targetValue - startValue); + float delay = 0.5f; + animation.AnimateTo(Property(actor, index), + targetValue, + AlphaFunction::LINEAR, + TimePeriod(delay, durationSeconds - delay)); // Start the animation animation.Play(); @@ -5174,20 +5738,20 @@ int UtcDaliAnimationAnimateToActorPositionAlphaFunction(void) animation.FinishedSignal().Connect(&application, finishCheck); application.SendNotification(); - application.Render(static_cast(durationSeconds*750.0f)/* 75% progress */); + application.Render(static_cast(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.GetProperty(index), startValue, TEST_LOCATION ); - // The position should have moved less, than with a linear alpha function - Vector3 current(actor.GetCurrentPosition()); - DALI_TEST_CHECK( current.x > Vector3::ZERO.x ); - DALI_TEST_CHECK( current.y > Vector3::ZERO.y ); - DALI_TEST_CHECK( current.z > Vector3::ZERO.z ); - DALI_TEST_CHECK( current.x < seventyFivePercentProgress.x ); - DALI_TEST_CHECK( current.y < seventyFivePercentProgress.y ); - DALI_TEST_CHECK( current.z < seventyFivePercentProgress.z ); + application.SendNotification(); + application.Render(static_cast(durationSeconds*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(index), startValue+(relativeValue*0.5f), TEST_LOCATION ); application.SendNotification(); application.Render(static_cast(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/); @@ -5195,28 +5759,30 @@ int UtcDaliAnimationAnimateToActorPositionAlphaFunction(void) // We did expect the animation to finish application.SendNotification(); finishCheck.CheckSignalReceived(); - DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationAnimateToActorPositionTimePeriod(void) +int UtcDaliAnimationAnimateToVector3P(void) { TestApplication application; Actor actor = Actor::New(); + + // Register a Vector3 property + Vector3 startValue(-50.0f, -50.0f, -50.0f); + Property::Index index = actor.RegisterProperty( "testProperty", startValue ); Stage::GetCurrent().Add(actor); - DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); // Build the animation - float durationSeconds(1.0f); + float durationSeconds(2.0f); Animation animation = Animation::New(durationSeconds); - Vector3 targetPosition(200.0f, 200.0f, 200.0f); - float delay = 0.5f; - animation.AnimateTo( Property(actor, Actor::POSITION), - targetPosition, - TimePeriod( delay, durationSeconds - delay ) ); + Vector3 targetValue(50.0f, 50.0f, 50.0f); + Vector3 relativeValue(targetValue - startValue); + animation.AnimateTo(Property(actor, index), targetValue); - Vector3 seventyFivePercentProgress(targetPosition * 0.75f); + Vector3 ninetyFivePercentProgress(startValue + relativeValue*0.95f); // Start the animation animation.Play(); @@ -5226,50 +5792,43 @@ int UtcDaliAnimationAnimateToActorPositionTimePeriod(void) animation.FinishedSignal().Connect(&application, finishCheck); application.SendNotification(); - application.Render(static_cast(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.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION ); - - application.SendNotification(); - application.Render(static_cast(durationSeconds*500.0f*0.75)/* 7/8 animation progress, 3/4 animator progress */); + application.Render(static_cast(durationSeconds*950.0f)/* 95% progress */); // We didn't expect the animation to finish yet application.SendNotification(); finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetCurrentPosition(), seventyFivePercentProgress, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(index), ninetyFivePercentProgress, TEST_LOCATION ); application.SendNotification(); - application.Render(static_cast(durationSeconds*500.0f*0.25) + 1u/*just beyond the animation duration*/); + application.Render(static_cast(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 ); + DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationAnimateToActorPositionAlphaFunctionTimePeriod(void) +int UtcDaliAnimationAnimateToVector3AlphaFunctionP(void) { TestApplication application; Actor actor = Actor::New(); + + // Register a Vector3 property + Vector3 startValue(1000.0f, 1000.0f, 1000.0f); + Property::Index index = actor.RegisterProperty( "testProperty", startValue ); Stage::GetCurrent().Add(actor); - DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); // Build the animation float durationSeconds(1.0f); Animation animation = Animation::New(durationSeconds); - Vector3 targetPosition(200.0f, 200.0f, 200.0f); - float delay = 0.5f; - animation.AnimateTo( Property(actor, Actor::POSITION), - targetPosition, - AlphaFunctions::Linear, - TimePeriod( delay, durationSeconds - delay ) ); + Vector3 targetValue(9000.0f, 9000.0f, 9000.0f); + Vector3 relativeValue(targetValue - startValue); + animation.AnimateTo(Property(actor, index), targetValue, AlphaFunction::EASE_OUT); - Vector3 seventyFivePercentProgress(targetPosition * 0.75f); + Vector3 ninetyFivePercentProgress(startValue + relativeValue*0.95f); // Start the animation animation.Play(); @@ -5279,46 +5838,49 @@ int UtcDaliAnimationAnimateToActorPositionAlphaFunctionTimePeriod(void) animation.FinishedSignal().Connect(&application, finishCheck); application.SendNotification(); - application.Render(static_cast(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */); + application.Render(static_cast(durationSeconds*950.0f)/* 95% progress */); // We didn't expect the animation to finish yet application.SendNotification(); finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION ); - - application.SendNotification(); - application.Render(static_cast(durationSeconds*500.0f*0.75)/* 7/8 animation progress, 3/4 animator progress */); - // We didn't expect the animation to finish yet - application.SendNotification(); - finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetCurrentPosition(), seventyFivePercentProgress, TEST_LOCATION ); + // The position should have moved more, than with a linear alpha function + Vector3 current(actor.GetProperty(index)); + DALI_TEST_CHECK( current.x > ninetyFivePercentProgress.x ); + DALI_TEST_CHECK( current.y > ninetyFivePercentProgress.y ); + DALI_TEST_CHECK( current.z > ninetyFivePercentProgress.z ); application.SendNotification(); - application.Render(static_cast(durationSeconds*500.0f*0.25) + 1u/*just beyond the animation duration*/); + application.Render(static_cast(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 ); + DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationAnimateToActorRotationAngleAxis(void) +int UtcDaliAnimationAnimateToVector3TimePeriodP(void) { TestApplication application; Actor actor = Actor::New(); - actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS)); + + // Register a Vector3 property + Vector3 startValue(10.0f, 10.0f, 10.0f); + Property::Index index = actor.RegisterProperty( "testProperty", startValue ); Stage::GetCurrent().Add(actor); - DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); // Build the animation float durationSeconds(1.0f); Animation animation = Animation::New(durationSeconds); - Degree targetRotationDegrees(90.0f); - Radian targetRotationRadians(targetRotationDegrees); - animation.AnimateTo( Property(actor, Actor::ROTATION), AngleAxis(targetRotationRadians, Vector3::YAXIS) ); + Vector3 targetValue(-10.0f, 20.0f, 100.0f); + Vector3 relativeValue(targetValue - startValue); + float delay = 0.5f; + animation.AnimateTo(Property(actor, index), + targetValue, + TimePeriod(delay, durationSeconds - delay)); // Start the animation animation.Play(); @@ -5328,28 +5890,20 @@ int UtcDaliAnimationAnimateToActorRotationAngleAxis(void) animation.FinishedSignal().Connect(&application, finishCheck); application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f)/* 25% progress */); - - // We didn't expect the animation to finish yet - application.SendNotification(); - finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.25f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); - - application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f)/* 50% progress */); + application.Render(static_cast(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(targetRotationRadians * 0.5f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f)/* 75% progress */); + application.Render(static_cast(durationSeconds*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.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.75f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue+(relativeValue*0.5f), TEST_LOCATION ); application.SendNotification(); application.Render(static_cast(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/); @@ -5357,26 +5911,32 @@ int UtcDaliAnimationAnimateToActorRotationAngleAxis(void) // We did expect the animation to finish application.SendNotification(); finishCheck.CheckSignalReceived(); - DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationAnimateToActorRotationQuaternion(void) +int UtcDaliAnimationAnimateToVector3AlphaFunctionTimePeriodP(void) { TestApplication application; Actor actor = Actor::New(); - actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS)); + + // Register a Vector3 property + Vector3 startValue(10.0f, 10.0f, 10.0f); + Property::Index index = actor.RegisterProperty( "testProperty", startValue ); Stage::GetCurrent().Add(actor); - DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); // Build the animation float durationSeconds(1.0f); Animation animation = Animation::New(durationSeconds); - Degree targetRotationDegrees(90.0f); - Radian targetRotationRadians(targetRotationDegrees); - Quaternion targetRotation(targetRotationRadians, Vector3::YAXIS); - animation.AnimateTo( Property(actor, Actor::ROTATION), targetRotation ); + Vector3 targetValue(30.0f, 30.0f, 30.0f); + Vector3 relativeValue(targetValue - startValue); + float delay = 0.5f; + animation.AnimateTo(Property(actor, "testProperty"), + targetValue, + AlphaFunction::LINEAR, + TimePeriod(delay, durationSeconds - delay)); // Start the animation animation.Play(); @@ -5386,28 +5946,20 @@ int UtcDaliAnimationAnimateToActorRotationQuaternion(void) animation.FinishedSignal().Connect(&application, finishCheck); application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f)/* 25% progress */); - - // We didn't expect the animation to finish yet - application.SendNotification(); - finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.25f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); - - application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f)/* 50% progress */); + application.Render(static_cast(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(targetRotationRadians * 0.5f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f)/* 75% progress */); + application.Render(static_cast(durationSeconds*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.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.75f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue+(relativeValue*0.5f), TEST_LOCATION ); application.SendNotification(); application.Render(static_cast(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/); @@ -5415,25 +5967,36 @@ int UtcDaliAnimationAnimateToActorRotationQuaternion(void) // We did expect the animation to finish application.SendNotification(); finishCheck.CheckSignalReceived(); - DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationAnimateToActorRotationAlphaFunction(void) +int UtcDaliAnimationAnimateToVector3ComponentP(void) { TestApplication application; Actor actor = Actor::New(); - actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS)); + + // Register a Vector3 property + Vector3 startValue(10.0f, 10.0f, 10.0f); + Property::Index index = actor.RegisterProperty( "testProperty", startValue ); Stage::GetCurrent().Add(actor); - DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); // Build the animation float durationSeconds(1.0f); Animation animation = Animation::New(durationSeconds); - Degree targetRotationDegrees(90.0f); - Radian targetRotationRadians(targetRotationDegrees); - animation.AnimateTo( Property(actor, Actor::ROTATION), AngleAxis(targetRotationDegrees, Vector3::YAXIS), AlphaFunctions::EaseIn); + Vector3 targetValue(30.0f, 30.0f, 10.0f); + Vector3 relativeValue(targetValue - startValue); + float delay = 0.5f; + animation.AnimateTo(Property(actor, "testProperty", 0), + 30.0f, + AlphaFunction::LINEAR, + TimePeriod(delay, durationSeconds - delay)); + animation.AnimateTo(Property(actor, index, 1), + 30.0f, + AlphaFunction::LINEAR, + TimePeriod(delay, durationSeconds - delay)); // Start the animation animation.Play(); @@ -5443,28 +6006,20 @@ int UtcDaliAnimationAnimateToActorRotationAlphaFunction(void) animation.FinishedSignal().Connect(&application, finishCheck); application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f)/* 25% progress */); - - // We didn't expect the animation to finish yet - application.SendNotification(); - finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(0.25f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); - - application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f)/* 50% progress */); + application.Render(static_cast(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(targetRotationRadians * AlphaFunctions::EaseIn(0.5f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f)/* 75% progress */); + application.Render(static_cast(durationSeconds*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.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(0.75f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue+(relativeValue*0.5f), TEST_LOCATION ); application.SendNotification(); application.Render(static_cast(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/); @@ -5472,26 +6027,30 @@ int UtcDaliAnimationAnimateToActorRotationAlphaFunction(void) // We did expect the animation to finish application.SendNotification(); finishCheck.CheckSignalReceived(); - DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationAnimateToActorRotationTimePeriod(void) +int UtcDaliAnimationAnimateToVector4P(void) { TestApplication application; Actor actor = Actor::New(); - actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS)); + + // Register a Vector4 property + Vector4 startValue(-50.0f, -40.0f, -30.0f, -20.0f); + Property::Index index = actor.RegisterProperty( "testProperty", startValue ); Stage::GetCurrent().Add(actor); - DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); // Build the animation - float durationSeconds(1.0f); + float durationSeconds(2.0f); Animation animation = Animation::New(durationSeconds); - Degree targetRotationDegrees(90.0f); - Radian targetRotationRadians(targetRotationDegrees); - float delay(0.1f); - animation.AnimateTo( Property(actor, Actor::ROTATION), AngleAxis(targetRotationDegrees, Vector3::YAXIS), TimePeriod(delay, durationSeconds - delay)); + Vector4 targetValue(50.0f, 50.0f, 50.0f, 50.0f); + Vector4 relativeValue(targetValue - startValue); + animation.AnimateTo(Property(actor, index), targetValue); + + Vector4 ninetyFivePercentProgress(startValue + relativeValue*0.95f); // Start the animation animation.Play(); @@ -5501,58 +6060,43 @@ int UtcDaliAnimationAnimateToActorRotationTimePeriod(void) animation.FinishedSignal().Connect(&application, finishCheck); application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f)/* 25% progress */); - - // We didn't expect the animation to finish yet - application.SendNotification(); - finishCheck.CheckSignalNotReceived(); - float progress = max(0.0f, 0.25f - delay) / (1.0f - delay); - DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * progress, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); - - application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f)/* 50% progress */); - - // We didn't expect the animation to finish yet - application.SendNotification(); - finishCheck.CheckSignalNotReceived(); - progress = max(0.0f, 0.5f - delay) / (1.0f - delay); - DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * progress, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); - - application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f)/* 75% progress */); + application.Render(static_cast(durationSeconds*950.0f)/* 95% progress */); // We didn't expect the animation to finish yet application.SendNotification(); finishCheck.CheckSignalNotReceived(); - progress = max(0.0f, 0.75f - delay) / (1.0f - delay); - DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * progress, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(index), ninetyFivePercentProgress, TEST_LOCATION ); application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/); + application.Render(static_cast(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/); // We did expect the animation to finish application.SendNotification(); finishCheck.CheckSignalReceived(); - DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationAnimateToActorRotationAlphaFunctionTimePeriod(void) +int UtcDaliAnimationAnimateToVector4AlphaFunctionP(void) { TestApplication application; Actor actor = Actor::New(); - actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS)); + + // Register a Vector4 property + Vector4 startValue(1000.0f, 1000.0f, 1000.0f, 1000.0f); + Property::Index index = actor.RegisterProperty( "testProperty", startValue ); Stage::GetCurrent().Add(actor); - DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); // Build the animation float durationSeconds(1.0f); Animation animation = Animation::New(durationSeconds); - Degree targetRotationDegrees(90.0f); - Radian targetRotationRadians(targetRotationDegrees); - float delay(0.1f); - animation.AnimateTo( Property(actor, Actor::ROTATION), AngleAxis(targetRotationDegrees, Vector3::YAXIS), AlphaFunctions::EaseIn, TimePeriod(delay, durationSeconds - delay)); + Vector4 targetValue(9000.0f, 9000.0f, 9000.0f, 9000.0f); + Vector4 relativeValue(targetValue - startValue); + animation.AnimateTo(Property(actor, index), targetValue, AlphaFunction::EASE_OUT); + + Vector4 ninetyFivePercentProgress(startValue + relativeValue*0.95f); // Start the animation animation.Play(); @@ -5562,57 +6106,50 @@ int UtcDaliAnimationAnimateToActorRotationAlphaFunctionTimePeriod(void) animation.FinishedSignal().Connect(&application, finishCheck); application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f)/* 25% progress */); - - // We didn't expect the animation to finish yet - application.SendNotification(); - finishCheck.CheckSignalNotReceived(); - float progress = max(0.0f, 0.25f - delay) / (1.0f - delay); - DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); - - application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f)/* 50% progress */); + application.Render(static_cast(durationSeconds*950.0f)/* 95% progress */); // We didn't expect the animation to finish yet application.SendNotification(); finishCheck.CheckSignalNotReceived(); - progress = max(0.0f, 0.5f - delay) / (1.0f - delay); - DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); - - application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f)/* 75% progress */); - // We didn't expect the animation to finish yet - application.SendNotification(); - finishCheck.CheckSignalNotReceived(); - progress = max(0.0f, 0.75f - delay) / (1.0f - delay); - DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + // The position should have moved more, than with a linear alpha function + Vector4 current(actor.GetProperty(index)); + DALI_TEST_CHECK( current.x > ninetyFivePercentProgress.x ); + DALI_TEST_CHECK( current.y > ninetyFivePercentProgress.y ); + DALI_TEST_CHECK( current.z > ninetyFivePercentProgress.z ); + DALI_TEST_CHECK( current.w > ninetyFivePercentProgress.w ); application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/); + application.Render(static_cast(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/); // We did expect the animation to finish application.SendNotification(); finishCheck.CheckSignalReceived(); - DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationAnimateToActorScale(void) +int UtcDaliAnimationAnimateToVector4TimePeriodP(void) { TestApplication application; Actor actor = Actor::New(); + + // Register a Vector4 property + Vector4 startValue(10.0f, 10.0f, 10.0f, 10.0f); + Property::Index index = actor.RegisterProperty( "testProperty", startValue ); Stage::GetCurrent().Add(actor); - DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, VECTOR4_EPSILON, TEST_LOCATION ); // Build the animation float durationSeconds(1.0f); Animation animation = Animation::New(durationSeconds); - Vector3 targetScale(2.0f, 2.0f, 2.0f); - animation.AnimateTo( Property(actor, Actor::SCALE), targetScale ); - - Vector3 ninetyNinePercentProgress(Vector3::ONE + (targetScale - Vector3::ONE)*0.99f); + Vector4 targetValue(-10.0f, 20.0f, 100.0f, 100.0f); + Vector4 relativeValue(targetValue - startValue); + float delay = 0.5f; + animation.AnimateTo(Property(actor, index), + targetValue, + TimePeriod(delay, durationSeconds - delay)); // Start the animation animation.Play(); @@ -5622,109 +6159,53 @@ int UtcDaliAnimationAnimateToActorScale(void) animation.FinishedSignal().Connect(&application, finishCheck); application.SendNotification(); - application.Render(static_cast(durationSeconds*990.0f)/* 99% progress */); + application.Render(static_cast(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.GetCurrentScale(), ninetyNinePercentProgress, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, VECTOR4_EPSILON, TEST_LOCATION ); application.SendNotification(); - application.Render(static_cast(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/); + application.Render(static_cast(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */); - // We did expect the animation to finish - application.SendNotification(); - finishCheck.CheckSignalReceived(); - DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION ); - - // Reset everything - finishCheck.Reset(); - actor.SetScale(Vector3::ONE); - application.SendNotification(); - application.Render(0); - DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION ); - - // Repeat with a different (ease-in) alpha function - animation = Animation::New(durationSeconds); - animation.AnimateTo( Property(actor, Actor::SCALE), targetScale, AlphaFunctions::EaseIn); - animation.FinishedSignal().Connect(&application, finishCheck); - animation.Play(); - - application.SendNotification(); - application.Render(static_cast(durationSeconds*990.0f)/* 99% progress */); - - // We didn't expect the animation to finish yet - application.SendNotification(); - finishCheck.CheckSignalNotReceived(); - - // The scale should have grown less, than with a linear alpha function - Vector3 current(actor.GetCurrentScale()); - DALI_TEST_CHECK( current.x > 1.0f ); - DALI_TEST_CHECK( current.y > 1.0f ); - DALI_TEST_CHECK( current.z > 1.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(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/); - - // We did expect the animation to finish - application.SendNotification(); - finishCheck.CheckSignalReceived(); - DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION ); - - // Reset everything - finishCheck.Reset(); - actor.SetScale(Vector3::ONE); - application.SendNotification(); - application.Render(0); - DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION ); - - // Repeat with a delay - float delay = 0.5f; - animation = Animation::New(durationSeconds); - animation.AnimateTo( Property(actor, Actor::SCALE), targetScale, AlphaFunctions::Linear, TimePeriod(delay, durationSeconds - delay)); - animation.FinishedSignal().Connect(&application, finishCheck); - animation.Play(); - - application.SendNotification(); - application.Render(static_cast(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */); - - // We didn't expect the animation to finish yet + // We didn't expect the animation to finish yet application.SendNotification(); finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue+(relativeValue*0.5f), VECTOR4_EPSILON, TEST_LOCATION ); application.SendNotification(); - application.Render(static_cast(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/); + application.Render(static_cast(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/); // We did expect the animation to finish application.SendNotification(); finishCheck.CheckSignalReceived(); - DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, VECTOR4_EPSILON, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationAnimateToActorScaleX(void) +int UtcDaliAnimationAnimateToVector4AlphaFunctionTimePeriodP(void) { TestApplication application; Actor actor = Actor::New(); + + // Register a Vector4 property + Vector4 startValue(10.0f, 10.0f, 10.0f, 10.0f); + Property::Index index = actor.RegisterProperty( "testProperty", startValue ); Stage::GetCurrent().Add(actor); - float startValue(1.0f); - DALI_TEST_EQUALS( actor.GetCurrentScale().x, startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::SCALE_X), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::SCALE_Y), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::SCALE_Z), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); // Build the animation float durationSeconds(1.0f); Animation animation = Animation::New(durationSeconds); - float targetX(10.0f); - animation.AnimateTo( Property(actor, Actor::SCALE_X), targetX ); - - float fiftyPercentProgress(startValue + (targetX - startValue)*0.5f); + Vector4 targetValue(30.0f, 30.0f, 30.0f, 30.0f); + Vector4 relativeValue(targetValue - startValue); + float delay = 0.5f; + animation.AnimateTo(Property(actor, index), + targetValue, + AlphaFunction::LINEAR, + TimePeriod(delay, durationSeconds - delay)); // Start the animation animation.Play(); @@ -5734,237 +6215,340 @@ int UtcDaliAnimationAnimateToActorScaleX(void) animation.FinishedSignal().Connect(&application, finishCheck); application.SendNotification(); - application.Render(static_cast(durationSeconds*500.0f)/* 50% progress */); + application.Render(static_cast(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.GetCurrentScale().x, fiftyPercentProgress, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::SCALE_X), fiftyPercentProgress, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::SCALE_Y), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::SCALE_Z), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); application.SendNotification(); - application.Render(static_cast(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/); + application.Render(static_cast(durationSeconds*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(index), startValue+(relativeValue*0.5f), TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/); // We did expect the animation to finish application.SendNotification(); finishCheck.CheckSignalReceived(); - DALI_TEST_EQUALS( actor.GetCurrentScale().x, targetX, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::SCALE_X), targetX, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::SCALE_Y), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::SCALE_Z), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationAnimateToActorScaleY(void) +int UtcDaliAnimationAnimateToActorParentOriginP(void) { TestApplication application; Actor actor = Actor::New(); Stage::GetCurrent().Add(actor); - float startValue(1.0f); - DALI_TEST_EQUALS( actor.GetCurrentScale().y, startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::SCALE_X), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::SCALE_Y), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::SCALE_Z), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::TOP_LEFT, TEST_LOCATION ); // Build the animation float durationSeconds(1.0f); Animation animation = Animation::New(durationSeconds); - float targetY(1000.0f); - animation.AnimateTo( Property(actor, Actor::SCALE_Y), targetY ); - - float fiftyPercentProgress(startValue + (targetY - startValue)*0.5f); - - // Start the animation - animation.Play(); + Vector3 targetParentOrigin(ParentOrigin::BOTTOM_RIGHT); - bool signalReceived(false); - AnimationFinishCheck finishCheck(signalReceived); - animation.FinishedSignal().Connect(&application, finishCheck); + try + { + animation.AnimateTo( Property(actor, Actor::Property::PARENT_ORIGIN), targetParentOrigin ); + } + catch (Dali::DaliException& e) + { + DALI_TEST_PRINT_ASSERT( e ); + DALI_TEST_ASSERT(e, "IsPropertyAnimatable( index )", TEST_LOCATION); + } + END_TEST; +} - application.SendNotification(); - application.Render(static_cast(durationSeconds*500.0f)/* 50% progress */); +int UtcDaliAnimationAnimateToActorParentOriginXP(void) +{ + TestApplication application; - // We didn't expect the animation to finish yet - application.SendNotification(); - finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetCurrentScale().y, fiftyPercentProgress, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::SCALE_X), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::SCALE_Y), fiftyPercentProgress, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::SCALE_Z), startValue, TEST_LOCATION ); + Actor actor = Actor::New(); + Stage::GetCurrent().Add(actor); + float startValue(0.0f); + DALI_TEST_EQUALS( actor.GetCurrentParentOrigin().x, startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::PARENT_ORIGIN_X), startValue, TEST_LOCATION ); - application.SendNotification(); - application.Render(static_cast(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/); + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + float targetX(1.0f); - // We did expect the animation to finish - application.SendNotification(); - finishCheck.CheckSignalReceived(); - DALI_TEST_EQUALS( actor.GetCurrentScale().y, targetY, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::SCALE_X), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::SCALE_Y), targetY, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::SCALE_Z), startValue, TEST_LOCATION ); + try + { + animation.AnimateTo( Property(actor, Actor::Property::PARENT_ORIGIN_X), targetX ); + } + catch (Dali::DaliException& e) + { + DALI_TEST_PRINT_ASSERT( e ); + DALI_TEST_ASSERT(e, "IsPropertyAnimatable( index )", TEST_LOCATION); + } END_TEST; } -int UtcDaliAnimationAnimateToActorScaleZ(void) +int UtcDaliAnimationAnimateToActorParentOriginYP(void) { TestApplication application; Actor actor = Actor::New(); Stage::GetCurrent().Add(actor); - float startValue(1.0f); - DALI_TEST_EQUALS( actor.GetCurrentScale().z, startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::SCALE_X), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::SCALE_Y), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::SCALE_Z), startValue, TEST_LOCATION ); + float startValue(0.0f); + DALI_TEST_EQUALS( actor.GetCurrentParentOrigin().y, startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::PARENT_ORIGIN_Y), startValue, TEST_LOCATION ); // Build the animation float durationSeconds(1.0f); Animation animation = Animation::New(durationSeconds); - float targetZ(-1000.0f); - animation.AnimateTo( Property(actor, Actor::SCALE_Z), targetZ ); - - float fiftyPercentProgress(startValue + (targetZ - startValue)*0.5f); - - // Start the animation - animation.Play(); + float targetY(1.0f); - bool signalReceived(false); - AnimationFinishCheck finishCheck(signalReceived); - animation.FinishedSignal().Connect(&application, finishCheck); + try + { + animation.AnimateTo( Property(actor, Actor::Property::PARENT_ORIGIN_Y), targetY ); + } + catch (Dali::DaliException& e) + { + DALI_TEST_PRINT_ASSERT( e ); + DALI_TEST_ASSERT(e, "IsPropertyAnimatable( index )", TEST_LOCATION); + } + END_TEST; +} - application.SendNotification(); - application.Render(static_cast(durationSeconds*500.0f)/* 50% progress */); +int UtcDaliAnimationAnimateToActorParentOriginZP(void) +{ + TestApplication application; - // We didn't expect the animation to finish yet - application.SendNotification(); - finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetCurrentScale().z, fiftyPercentProgress, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::SCALE_X), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::SCALE_Y), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::SCALE_Z), fiftyPercentProgress, TEST_LOCATION ); + Actor actor = Actor::New(); + Stage::GetCurrent().Add(actor); + float startValue(0.5f); + DALI_TEST_EQUALS( actor.GetCurrentParentOrigin().z, startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::PARENT_ORIGIN_Z), startValue, TEST_LOCATION ); - application.SendNotification(); - application.Render(static_cast(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/); + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + float targetZ(1.0f); - // We did expect the animation to finish - application.SendNotification(); - finishCheck.CheckSignalReceived(); - DALI_TEST_EQUALS( actor.GetCurrentScale().z, targetZ, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::SCALE_X), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::SCALE_Y), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::SCALE_Z), targetZ, TEST_LOCATION ); + try + { + animation.AnimateTo( Property(actor, Actor::Property::PARENT_ORIGIN_Z), targetZ ); + } + catch (Dali::DaliException& e) + { + DALI_TEST_PRINT_ASSERT( e ); + DALI_TEST_ASSERT(e, "IsPropertyAnimatable( index )", TEST_LOCATION); + } END_TEST; } -int UtcDaliAnimationAnimateToActorColor(void) +int UtcDaliAnimationAnimateToActorAnchorPointP(void) { TestApplication application; Actor actor = Actor::New(); Stage::GetCurrent().Add(actor); - DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), AnchorPoint::CENTER, TEST_LOCATION ); // Build the animation float durationSeconds(1.0f); Animation animation = Animation::New(durationSeconds); - Vector4 targetColor(Color::RED); - animation.AnimateTo( Property(actor, Actor::COLOR), targetColor ); - - Vector4 tenPercentProgress(Vector4(1.0f, 0.9f, 0.9f, 1.0f)); - Vector4 twentyPercentProgress(Vector4(1.0f, 0.8f, 0.8f, 1.0f)); + Vector3 targetAnchorPoint(AnchorPoint::TOP_LEFT); - // Start the animation - animation.Play(); + try + { + animation.AnimateTo( Property(actor, Actor::Property::ANCHOR_POINT), targetAnchorPoint); + } + catch (Dali::DaliException& e) + { + DALI_TEST_PRINT_ASSERT( e ); + DALI_TEST_ASSERT(e, "IsPropertyAnimatable( index )", TEST_LOCATION); + } + END_TEST; +} - bool signalReceived(false); - AnimationFinishCheck finishCheck(signalReceived); - animation.FinishedSignal().Connect(&application, finishCheck); +int UtcDaliAnimationAnimateToActorAnchorPointXP(void) +{ + TestApplication application; - application.SendNotification(); - application.Render(static_cast(durationSeconds*100.0f)/* 10% progress */); + Actor actor = Actor::New(); + Stage::GetCurrent().Add(actor); + float startValue(0.5f); + DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint().x, startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ANCHOR_POINT_X), startValue, TEST_LOCATION ); - // We didn't expect the animation to finish yet - application.SendNotification(); - finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetCurrentColor(), tenPercentProgress, TEST_LOCATION ); + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + float targetX(1.0f); - application.SendNotification(); - application.Render(static_cast(durationSeconds*900.0f) + 1u/*just beyond the animation duration*/); + try + { + animation.AnimateTo( Property(actor, Actor::Property::ANCHOR_POINT_X), targetX ); + } + catch (Dali::DaliException& e) + { + DALI_TEST_PRINT_ASSERT( e ); + DALI_TEST_ASSERT(e, "IsPropertyAnimatable( index )", TEST_LOCATION); + } + END_TEST; +} - // We did expect the animation to finish - application.SendNotification(); - finishCheck.CheckSignalReceived(); - DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION ); +int UtcDaliAnimationAnimateToActorAnchorPointYP(void) +{ + TestApplication application; - // Reset everything - finishCheck.Reset(); - actor.SetColor(Color::WHITE); - application.SendNotification(); - application.Render(0); - DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION ); + Actor actor = Actor::New(); + Stage::GetCurrent().Add(actor); + float startValue(0.5f); + DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint().y, startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ANCHOR_POINT_Y), startValue, TEST_LOCATION ); - // Repeat with a different (ease-in) alpha function - animation = Animation::New(durationSeconds); - animation.AnimateTo( Property(actor, Actor::COLOR), targetColor, AlphaFunctions::EaseIn); - animation.FinishedSignal().Connect(&application, finishCheck); + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + float targetY(0.0f); + + try + { + animation.AnimateTo( Property(actor, Actor::Property::ANCHOR_POINT_Y), targetY ); + } + catch (Dali::DaliException& e) + { + DALI_TEST_PRINT_ASSERT( e ); + DALI_TEST_ASSERT(e, "IsPropertyAnimatable( index )", TEST_LOCATION); + } + END_TEST; +} + +int UtcDaliAnimationAnimateToActorAnchorPointZP(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + Stage::GetCurrent().Add(actor); + float startValue(0.5f); + DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint().z, startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ANCHOR_POINT_Z), startValue, TEST_LOCATION ); + + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + float targetZ(100.0f); + + try + { + animation.AnimateTo( Property(actor, Actor::Property::ANCHOR_POINT_Z), targetZ ); + } + catch (Dali::DaliException& e) + { + DALI_TEST_PRINT_ASSERT( e ); + DALI_TEST_ASSERT(e, "IsPropertyAnimatable( index )", TEST_LOCATION); + } + END_TEST; +} + +int UtcDaliAnimationAnimateToActorSizeP(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.AnimateTo( Property(actor, Actor::Property::SIZE), 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(durationSeconds*100.0f)/* 10% progress */); + application.Render(static_cast(durationSeconds*990.0f)/* 99% progress */); // We didn't expect the animation to finish yet application.SendNotification(); finishCheck.CheckSignalNotReceived(); - - // The color should have changed less, than with a linear alpha function - Vector4 current(actor.GetCurrentColor()); - DALI_TEST_CHECK( current.x == 1.0f ); // doesn't change - DALI_TEST_CHECK( current.y < 1.0f ); - DALI_TEST_CHECK( current.y > tenPercentProgress.y ); - DALI_TEST_CHECK( current.z < 1.0f ); - DALI_TEST_CHECK( current.z > tenPercentProgress.z ); - DALI_TEST_CHECK( current.w == 1.0f ); // doesn't change + DALI_TEST_EQUALS( actor.GetCurrentSize(), ninetyNinePercentProgress, TEST_LOCATION ); application.SendNotification(); - application.Render(static_cast(durationSeconds*900.0f) + 1u/*just beyond the animation duration*/); + application.Render(static_cast(durationSeconds*10.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 ); + DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION ); // Reset everything finishCheck.Reset(); - actor.SetColor(Color::WHITE); + actor.SetSize(Vector3::ZERO); application.SendNotification(); application.Render(0); - DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION ); - // Repeat with a shorter animator duration - float animatorDuration = 0.5f; + // Repeat with a different (ease-in) alpha function animation = Animation::New(durationSeconds); - animation.AnimateTo( Property(actor, Actor::COLOR), targetColor, AlphaFunctions::Linear, TimePeriod(animatorDuration)); + animation.AnimateTo( Property(actor, Actor::Property::SIZE), targetSize, AlphaFunction::EASE_IN); animation.FinishedSignal().Connect(&application, finishCheck); animation.Play(); application.SendNotification(); - application.Render(static_cast(durationSeconds*100.0f)/* 10% animation progress, 20% animator progress */); + application.Render(static_cast(durationSeconds*990.0f)/* 99% progress */); // We didn't expect the animation to finish yet application.SendNotification(); finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetCurrentColor(), twentyPercentProgress, 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(durationSeconds*400.0f)/* 50% animation progress, 100% animator progress */); + application.Render(static_cast(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.AnimateTo( Property(actor, Actor::Property::SIZE), targetSize, AlphaFunction::LINEAR, TimePeriod(delay, durationSeconds - delay)); + animation.FinishedSignal().Connect(&application, finishCheck); + animation.Play(); + + application.SendNotification(); + application.Render(static_cast(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.GetCurrentColor(), targetColor, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION ); application.SendNotification(); application.Render(static_cast(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/); @@ -5972,30 +6556,27 @@ int UtcDaliAnimationAnimateToActorColor(void) // We did expect the animation to finish application.SendNotification(); finishCheck.CheckSignalReceived(); - DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationAnimateToActorColorRed(void) +int UtcDaliAnimationAnimateToActorSizeWidthP(void) { TestApplication application; Actor actor = Actor::New(); Stage::GetCurrent().Add(actor); - float startValue(1.0f); - DALI_TEST_EQUALS( actor.GetCurrentColor().r, startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_RED), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_GREEN), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_BLUE), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_ALPHA), startValue, TEST_LOCATION ); + float startValue(0.0f); + DALI_TEST_EQUALS( actor.GetCurrentSize().width, startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::SIZE_WIDTH), startValue, TEST_LOCATION ); // Build the animation float durationSeconds(1.0f); Animation animation = Animation::New(durationSeconds); - float targetRed(0.5f); - animation.AnimateTo( Property(actor, Actor::COLOR_RED), targetRed ); + float targetWidth(10.0f); + animation.AnimateTo( Property(actor, Actor::Property::SIZE_WIDTH), targetWidth ); - float fiftyPercentProgress(startValue + (targetRed - startValue)*0.5f); + float fiftyPercentProgress(startValue + (targetWidth - startValue)*0.5f); // Start the animation animation.Play(); @@ -6010,11 +6591,7 @@ int UtcDaliAnimationAnimateToActorColorRed(void) // We didn't expect the animation to finish yet application.SendNotification(); finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetCurrentColor().r, fiftyPercentProgress, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_RED), fiftyPercentProgress, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_GREEN), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_BLUE), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_ALPHA), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentSize().width, fiftyPercentProgress, TEST_LOCATION ); application.SendNotification(); application.Render(static_cast(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/); @@ -6022,34 +6599,28 @@ int UtcDaliAnimationAnimateToActorColorRed(void) // We did expect the animation to finish application.SendNotification(); finishCheck.CheckSignalReceived(); - DALI_TEST_EQUALS( actor.GetCurrentColor().r, targetRed, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_RED), targetRed, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_GREEN), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_BLUE), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_ALPHA), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentSize().width, targetWidth, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::SIZE_WIDTH), targetWidth, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationAnimateToActorColorGreen(void) +int UtcDaliAnimationAnimateToActorSizeHeightP(void) { TestApplication application; Actor actor = Actor::New(); Stage::GetCurrent().Add(actor); - float startValue(1.0f); - DALI_TEST_EQUALS( actor.GetCurrentColor().g, startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_RED), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_GREEN), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_BLUE), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_ALPHA), startValue, TEST_LOCATION ); + float startValue(0.0f); + DALI_TEST_EQUALS( actor.GetCurrentSize().height, startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::SIZE_HEIGHT), startValue, TEST_LOCATION ); // Build the animation float durationSeconds(1.0f); Animation animation = Animation::New(durationSeconds); - float targetGreen(0.5f); - animation.AnimateTo( Property(actor, Actor::COLOR_GREEN), targetGreen ); + float targetHeight(-10.0f); + animation.AnimateTo( Property(actor, Actor::Property::SIZE_HEIGHT), targetHeight ); - float fiftyPercentProgress(startValue + (targetGreen - startValue)*0.5f); + float fiftyPercentProgress(startValue + (targetHeight - startValue)*0.5f); // Start the animation animation.Play(); @@ -6064,11 +6635,7 @@ int UtcDaliAnimationAnimateToActorColorGreen(void) // We didn't expect the animation to finish yet application.SendNotification(); finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetCurrentColor().g, fiftyPercentProgress, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_RED), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_GREEN), fiftyPercentProgress, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_BLUE), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_ALPHA), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentSize().height, fiftyPercentProgress, TEST_LOCATION ); application.SendNotification(); application.Render(static_cast(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/); @@ -6076,34 +6643,28 @@ int UtcDaliAnimationAnimateToActorColorGreen(void) // We did expect the animation to finish application.SendNotification(); finishCheck.CheckSignalReceived(); - DALI_TEST_EQUALS( actor.GetCurrentColor().g, targetGreen, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_RED), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_GREEN), targetGreen, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_BLUE), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_ALPHA), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentSize().height, targetHeight, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::SIZE_HEIGHT), targetHeight, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationAnimateToActorColorBlue(void) +int UtcDaliAnimationAnimateToActorSizeDepthP(void) { TestApplication application; Actor actor = Actor::New(); Stage::GetCurrent().Add(actor); - float startValue(1.0f); - DALI_TEST_EQUALS( actor.GetCurrentColor().b, startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_RED), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_GREEN), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_BLUE), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_ALPHA), startValue, TEST_LOCATION ); + float startValue(0.0f); + DALI_TEST_EQUALS( actor.GetCurrentSize().depth, startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::SIZE_DEPTH), startValue, TEST_LOCATION ); // Build the animation float durationSeconds(1.0f); Animation animation = Animation::New(durationSeconds); - float targetBlue(0.5f); - animation.AnimateTo( Property(actor, Actor::COLOR_BLUE), targetBlue ); + float targetDepth(-10.0f); + animation.AnimateTo( Property(actor, Actor::Property::SIZE_DEPTH), targetDepth ); - float fiftyPercentProgress(startValue + (targetBlue - startValue)*0.5f); + float fiftyPercentProgress(startValue + (targetDepth - startValue)*0.5f); // Start the animation animation.Play(); @@ -6118,11 +6679,7 @@ int UtcDaliAnimationAnimateToActorColorBlue(void) // We didn't expect the animation to finish yet application.SendNotification(); finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetCurrentColor().b, fiftyPercentProgress, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_RED), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_GREEN), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_BLUE), fiftyPercentProgress, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_ALPHA), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentSize().depth, fiftyPercentProgress, TEST_LOCATION ); application.SendNotification(); application.Render(static_cast(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/); @@ -6130,34 +6687,26 @@ int UtcDaliAnimationAnimateToActorColorBlue(void) // We did expect the animation to finish application.SendNotification(); finishCheck.CheckSignalReceived(); - DALI_TEST_EQUALS( actor.GetCurrentColor().b, targetBlue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_RED), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_GREEN), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_BLUE), targetBlue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_ALPHA), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentSize().depth, targetDepth, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::SIZE_DEPTH), targetDepth, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationAnimateToActorColorAlpha(void) +int UtcDaliAnimationAnimateToActorSizeWidthHeightP(void) { TestApplication application; Actor actor = Actor::New(); Stage::GetCurrent().Add(actor); - float startValue(1.0f); - DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_RED), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_GREEN), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_BLUE), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_ALPHA), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION ); // Build the animation float durationSeconds(1.0f); Animation animation = Animation::New(durationSeconds); - float targetAlpha(0.5f); - animation.AnimateTo( Property(actor, Actor::COLOR_ALPHA), targetAlpha ); + Vector3 targetSize(100.0f, 100.0f, 100.0f); + animation.AnimateTo( Property( actor, Actor::Property::SIZE ), targetSize ); - float fiftyPercentProgress(startValue + (targetAlpha - startValue)*0.5f); + Vector3 ninetyNinePercentProgress(targetSize * 0.99f); // Start the animation animation.Play(); @@ -6167,236 +6716,152 @@ int UtcDaliAnimationAnimateToActorColorAlpha(void) animation.FinishedSignal().Connect(&application, finishCheck); application.SendNotification(); - application.Render(static_cast(durationSeconds*500.0f)/* 50% progress */); + application.Render(static_cast(durationSeconds*990.0f)/* 99% progress */); // We didn't expect the animation to finish yet application.SendNotification(); finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetCurrentColor().a, fiftyPercentProgress, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_RED), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_GREEN), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_BLUE), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_ALPHA), fiftyPercentProgress, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentSize(), ninetyNinePercentProgress, TEST_LOCATION ); application.SendNotification(); - application.Render(static_cast(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/); + application.Render(static_cast(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/); // We did expect the animation to finish application.SendNotification(); finishCheck.CheckSignalReceived(); - DALI_TEST_EQUALS( actor.GetCurrentColor().a, targetAlpha, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_RED), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_GREEN), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_BLUE), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_ALPHA), targetAlpha, TEST_LOCATION ); - END_TEST; -} + 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.AnimateTo( Property( actor, Actor::Property::SIZE_WIDTH ), targetSize.x, AlphaFunction::EASE_IN ); + animation.AnimateTo( Property( actor, Actor::Property::SIZE_HEIGHT ), targetSize.y, AlphaFunction::EASE_IN ); + animation.FinishedSignal().Connect(&application, finishCheck); + animation.Play(); -int UtcDaliAnimationKeyFrames01(void) -{ - TestApplication application; + application.SendNotification(); + application.Render(static_cast(durationSeconds*990.0f)/* 99% progress */); - KeyFrames keyFrames = KeyFrames::New(); - DALI_TEST_EQUALS(keyFrames.GetType(), Property::NONE, TEST_LOCATION); + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); - 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); + // 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.x < ninetyNinePercentProgress.x ); + DALI_TEST_CHECK( current.y < ninetyNinePercentProgress.y ); - DALI_TEST_EQUALS(keyFrames.GetType(), Property::FLOAT, TEST_LOCATION); + application.SendNotification(); + application.Render(static_cast(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/); - try - { - keyFrames.Add(1.9f, false); - } - catch (Dali::DaliException& e) - { - tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str()); - DALI_TEST_ASSERT(e, "mType == value.GetType()", TEST_LOCATION); - } + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetCurrentSize().x, targetSize.x, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentSize().y, targetSize.y, 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.AnimateTo( Property( actor, Actor::Property::SIZE_WIDTH ), targetSize.x, AlphaFunction::LINEAR, TimePeriod( delay, durationSeconds - delay ) ); + animation.AnimateTo( Property( actor, Actor::Property::SIZE_HEIGHT ), targetSize.y, AlphaFunction::LINEAR, TimePeriod( delay, durationSeconds - delay ) ); + animation.FinishedSignal().Connect(&application, finishCheck); + animation.Play(); + + application.SendNotification(); + application.Render(static_cast(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(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().x, targetSize.x, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentSize().y, targetSize.y, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationKeyFrames02(void) +int UtcDaliAnimationAnimateToActorPositionP(void) { TestApplication application; - KeyFrames keyFrames = KeyFrames::New(); - DALI_TEST_EQUALS(keyFrames.GetType(), Property::NONE, TEST_LOCATION); + Actor actor = Actor::New(); + Stage::GetCurrent().Add(actor); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION ); - keyFrames.Add(0.0f, true); - keyFrames.Add(0.2f, false); - keyFrames.Add(0.4f, false); - keyFrames.Add(0.6f, true); - keyFrames.Add(0.8f, true); - keyFrames.Add(1.0f, false); - - DALI_TEST_EQUALS(keyFrames.GetType(), Property::BOOLEAN, TEST_LOCATION); - - try - { - keyFrames.Add(0.7f, Vector3(1.0f, 1.0f, 1.0f)); - } - catch (Dali::DaliException& e) - { - tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str()); - DALI_TEST_ASSERT(e, "mType == value.GetType()", TEST_LOCATION); - } - END_TEST; -} - - -int UtcDaliAnimationKeyFrames03(void) -{ - TestApplication application; - - KeyFrames keyFrames = KeyFrames::New(); - DALI_TEST_EQUALS(keyFrames.GetType(), Property::NONE, TEST_LOCATION); - - keyFrames.Add(0.0f, Vector2(0.0f, 0.0f)); - keyFrames.Add(0.2f, Vector2(1.0f, 1.0f)); - keyFrames.Add(0.4f, Vector2(2.0f, 2.0f)); - keyFrames.Add(0.6f, Vector2(3.0f, 5.0f)); - keyFrames.Add(0.8f, Vector2(4.0f, 3.0f)); - keyFrames.Add(1.0f, Vector2(6.0f, 2.0f)); - - DALI_TEST_EQUALS(keyFrames.GetType(), Property::VECTOR2, TEST_LOCATION); - - try - { - keyFrames.Add(0.7f, Vector3(1.0f, 1.0f, 1.0f)); - } - catch (Dali::DaliException& e) - { - tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str()); - DALI_TEST_ASSERT(e, "mType == value.GetType()", TEST_LOCATION); - } - END_TEST; -} - - -int UtcDaliAnimationKeyFrames04(void) -{ - TestApplication application; - - KeyFrames keyFrames = KeyFrames::New(); - DALI_TEST_EQUALS(keyFrames.GetType(), Property::NONE, TEST_LOCATION); - - keyFrames.Add(0.0f, Vector3(0.0f, 4.0f, 0.0f)); - keyFrames.Add(0.2f, Vector3(1.0f, 3.0f, 1.0f)); - keyFrames.Add(0.4f, Vector3(2.0f, 2.0f, 2.0f)); - keyFrames.Add(0.6f, Vector3(3.0f, 2.0f, 5.0f)); - keyFrames.Add(0.8f, Vector3(4.0f, 4.0f, 3.0f)); - keyFrames.Add(1.0f, Vector3(6.0f, 8.0f, 2.0f)); - - DALI_TEST_EQUALS(keyFrames.GetType(), Property::VECTOR3, TEST_LOCATION); - - try - { - keyFrames.Add(0.7f, 1.0f); - } - catch (Dali::DaliException& e) - { - tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str()); - DALI_TEST_ASSERT(e, "mType == value.GetType()", TEST_LOCATION); - } - END_TEST; -} - -int UtcDaliAnimationKeyFrames05(void) -{ - TestApplication application; - - KeyFrames keyFrames = KeyFrames::New(); - DALI_TEST_EQUALS(keyFrames.GetType(), Property::NONE, TEST_LOCATION); - - keyFrames.Add(0.0f, Vector4(0.0f, 0.0f, 0.0f, 0.0f)); - keyFrames.Add(0.2f, Vector4(1.0f, 1.0f, 1.0f, 1.0f)); - keyFrames.Add(0.4f, Vector4(2.0f, 2.0f, 2.0f, 2.0f)); - keyFrames.Add(0.6f, Vector4(3.0f, 5.0f, 3.0f, 5.0f)); - keyFrames.Add(0.8f, Vector4(4.0f, 3.0f, 4.0f, 3.0f)); - keyFrames.Add(1.0f, Vector4(6.0f, 2.0f, 6.0f, 2.0f)); - - DALI_TEST_EQUALS(keyFrames.GetType(), Property::VECTOR4, TEST_LOCATION); + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + Vector3 targetPosition(200.0f, 200.0f, 200.0f); + animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition); - try - { - keyFrames.Add(0.7f, Quaternion(1.717f, Vector3::XAXIS)); - } - catch (Dali::DaliException& e) - { - tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str()); - DALI_TEST_ASSERT(e, "mType == value.GetType()", TEST_LOCATION); - } - END_TEST; -} + Vector3 seventyFivePercentProgress(targetPosition * 0.75f); + // Start the animation + animation.Play(); -int UtcDaliAnimationKeyFrames06(void) -{ - TestApplication application; + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); - KeyFrames keyFrames = KeyFrames::New(); - DALI_TEST_EQUALS(keyFrames.GetType(), Property::NONE, TEST_LOCATION); + application.SendNotification(); + application.Render(static_cast(durationSeconds*750.0f)/* 75% progress */); - keyFrames.Add(0.0f, Quaternion(1.717f, Vector3::XAXIS)); - keyFrames.Add(0.2f, Quaternion(2.0f, Vector3::XAXIS)); - keyFrames.Add(0.4f, Quaternion(3.0f, Vector3::ZAXIS)); - keyFrames.Add(0.6f, Quaternion(4.0f, Vector3(1.0f, 1.0f, 1.0f))); - keyFrames.Add(0.8f, AngleAxis(Degree(90), Vector3::XAXIS)); - keyFrames.Add(1.0f, Quaternion(3.0f, Vector3::YAXIS)); + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), seventyFivePercentProgress, TEST_LOCATION ); - DALI_TEST_EQUALS(keyFrames.GetType(), Property::ROTATION, TEST_LOCATION); + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/); - try - { - keyFrames.Add(0.7f, 1.1f); - } - catch (Dali::DaliException& e) - { - tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str()); - DALI_TEST_ASSERT(e, "mType == value.GetType()", TEST_LOCATION); - } + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION ); END_TEST; } - - - - -int UtcDaliAnimationAnimateBetweenActorColorAlpha(void) +int UtcDaliAnimationAnimateToActorPositionXP(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(Actor::COLOR_RED), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_GREEN), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_BLUE), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_ALPHA), startValue, TEST_LOCATION ); + float startValue(0.0f); + DALI_TEST_EQUALS( actor.GetCurrentPosition().x, startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::POSITION_X), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::POSITION_Y), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::POSITION_Z), startValue, TEST_LOCATION ); // Build the animation float durationSeconds(1.0f); Animation animation = Animation::New(durationSeconds); + float targetX(1.0f); + animation.AnimateTo( Property(actor, Actor::Property::POSITION_X), targetX ); - KeyFrames keyFrames = KeyFrames::New(); - 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 ); + float fiftyPercentProgress(startValue + (targetX - startValue)*0.5f); // Start the animation animation.Play(); @@ -6404,92 +6869,47 @@ int UtcDaliAnimationAnimateBetweenActorColorAlpha(void) 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(durationSeconds*100.0f)/* 10% progress */); - application.SendNotification(); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_RED), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_GREEN), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_BLUE), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_ALPHA), 0.3f, 0.01f, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.3f, 0.01f, TEST_LOCATION ); - - application.Render(static_cast(durationSeconds*200.0f)/* 30% progress */); - application.SendNotification(); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_RED), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_GREEN), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_BLUE), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_ALPHA), 0.25f, 0.01f, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.25f, 0.01f, TEST_LOCATION ); - application.Render(static_cast(durationSeconds*100.0f)/* 40% progress */); - application.SendNotification(); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_RED), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_GREEN), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_BLUE), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(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(durationSeconds*400.0f)/* 80% progress */); application.SendNotification(); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_RED), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_GREEN), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_BLUE), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(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(durationSeconds*500.0f)/* 50% progress */); - application.Render(static_cast(durationSeconds*100.0f)/* 90% progress */); + // We didn't expect the animation to finish yet application.SendNotification(); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_RED), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_GREEN), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_BLUE), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_ALPHA), 0.8f, 0.01f, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.8f, 0.01f, TEST_LOCATION ); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentPosition().x, fiftyPercentProgress, TEST_LOCATION ); - application.Render(static_cast(durationSeconds*100.0f)+1/* 100% progress */); application.SendNotification(); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_RED), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_GREEN), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_BLUE), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_ALPHA), 0.9f, 0.01f, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.9f, 0.01f, TEST_LOCATION ); + application.Render(static_cast(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().x, targetX, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::POSITION_X), targetX, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::POSITION_Y), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::POSITION_Z), startValue, TEST_LOCATION ); END_TEST; } - -int UtcDaliAnimationAnimateBetweenActorColor(void) +int UtcDaliAnimationAnimateToActorPositionYP(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(Actor::COLOR_RED), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_GREEN), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_BLUE), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_ALPHA), startValue, TEST_LOCATION ); + float startValue(0.0f); + DALI_TEST_EQUALS( actor.GetCurrentPosition().y, startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::POSITION_X), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::POSITION_Y), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::POSITION_Z), startValue, TEST_LOCATION ); // Build the animation float durationSeconds(1.0f); Animation animation = Animation::New(durationSeconds); + float targetY(10.0f); + animation.AnimateTo( Property(actor, Actor::Property::POSITION_Y), targetY ); - 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 ); + float fiftyPercentProgress(startValue + (targetY - startValue)*0.5f); // Start the animation animation.Play(); @@ -6497,75 +6917,47 @@ int UtcDaliAnimationAnimateBetweenActorColor(void) 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(Actor::COLOR_RED), 0.1f, 0.01f, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_GREEN), 0.2f, 0.01f, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_BLUE), 0.3f, 0.01f, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_ALPHA), 0.4f, 0.01f, TEST_LOCATION ); - application.Render(static_cast(durationSeconds*250.0f)/* 25% progress */); - application.SendNotification(); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_RED), 0.5f, 0.01f, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_GREEN), 0.5f, 0.01f, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_BLUE), 0.5f, 0.01f, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_ALPHA), 0.5f, 0.01f, TEST_LOCATION ); - - application.Render(static_cast(durationSeconds*250.0f)/* 50% progress */); application.SendNotification(); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_RED), 0.9f, 0.01f, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_GREEN), 0.8f, 0.01f, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_BLUE), 0.7f, 0.01f, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_ALPHA), 0.6f, 0.01f, TEST_LOCATION ); + application.Render(static_cast(durationSeconds*500.0f)/* 50% progress */); - application.Render(static_cast(durationSeconds*250.0f)/* 75% progress */); + // We didn't expect the animation to finish yet application.SendNotification(); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_RED), 0.95f, 0.01f, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_GREEN), 0.90f, 0.01f, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_BLUE), 0.85f, 0.01f, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_ALPHA), 0.80f, 0.01f, TEST_LOCATION ); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentPosition().y, fiftyPercentProgress, TEST_LOCATION ); - application.Render(static_cast(durationSeconds*250.0f)+1/* 100% progress */); application.SendNotification(); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_RED), 1.0f, 0.01f, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_GREEN), 1.0f, 0.01f, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_BLUE), 1.0f, 0.01f, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_ALPHA), 1.0f, 0.01f, TEST_LOCATION ); + application.Render(static_cast(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().y, targetY, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::POSITION_X), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::POSITION_Y), targetY, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::POSITION_Z), startValue, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationAnimateBetweenActorVisible01(void) +int UtcDaliAnimationAnimateToActorPositionZP(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 ); + float startValue(0.0f); + DALI_TEST_EQUALS( actor.GetCurrentPosition().z, startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::POSITION_X), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::POSITION_Y), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::POSITION_Z), startValue, TEST_LOCATION ); // Build the animation float durationSeconds(1.0f); Animation animation = Animation::New(durationSeconds); + float targetZ(-5.0f); + animation.AnimateTo( Property(actor, Actor::Property::POSITION_Z), targetZ ); - 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); - - animation.AnimateBetween( Property(actor, Actor::VISIBLE), keyFrames ); + float fiftyPercentProgress(startValue + (targetZ - startValue)*0.5f); // Start the animation animation.Play(); @@ -6573,40 +6965,43 @@ int UtcDaliAnimationAnimateBetweenActorVisible01(void) bool signalReceived(false); AnimationFinishCheck finishCheck(signalReceived); animation.FinishedSignal().Connect(&application, finishCheck); + application.SendNotification(); + application.Render(static_cast(durationSeconds*500.0f)/* 50% progress */); + + // We didn't expect the animation to finish yet application.SendNotification(); - application.Render(static_cast(durationSeconds*500.0f)); - application.SendNotification(); - application.Render(static_cast(durationSeconds*500.0f)+1); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentPosition().z, fiftyPercentProgress, TEST_LOCATION ); + application.SendNotification(); + application.Render(static_cast(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/); - DALI_TEST_EQUALS( actor.IsVisible(), true, TEST_LOCATION); + // We did expect the animation to finish + application.SendNotification(); finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetCurrentPosition().z, targetZ, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::POSITION_X), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::POSITION_Y), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::POSITION_Z), targetZ, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationAnimateBetweenActorRotation01(void) +int UtcDaliAnimationAnimateToActorPositionAlphaFunctionP(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); - Quaternion start(Radian(aa.angle), aa.axis); - DALI_TEST_EQUALS( actor.GetCurrentRotation(), start, 0.001f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION ); // Build the animation float durationSeconds(1.0f); Animation animation = Animation::New(durationSeconds); + Vector3 targetPosition(200.0f, 200.0f, 200.0f); + animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::EASE_IN); - KeyFrames keyFrames = KeyFrames::New(); - keyFrames.Add(0.0f, AngleAxis(Degree(60), Vector3::ZAXIS)); - - animation.AnimateBetween( Property(actor, Actor::ROTATION), keyFrames ); + Vector3 seventyFivePercentProgress(targetPosition * 0.75f); // Start the animation animation.Play(); @@ -6614,105 +7009,51 @@ int UtcDaliAnimationAnimateBetweenActorRotation01(void) bool signalReceived(false); AnimationFinishCheck finishCheck(signalReceived); animation.FinishedSignal().Connect(&application, finishCheck); + application.SendNotification(); - application.SendNotification(); - application.Render(static_cast(durationSeconds*500.0f)); - application.SendNotification(); - application.Render(static_cast(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(); - END_TEST; -} - -int UtcDaliAnimationAnimateBetweenActorRotation02(void) -{ - TestApplication application; - - Actor actor = Actor::New(); - AngleAxis aa(Degree(90), Vector3::XAXIS); - actor.SetRotation(aa.angle, aa.axis); - application.SendNotification(); - application.Render(0); - 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); - - 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)); - - animation.AnimateBetween( Property(actor, Actor::ROTATION), keyFrames ); - - // Start the animation - animation.Play(); + application.Render(static_cast(durationSeconds*750.0f)/* 75% progress */); - bool signalReceived(false); - AnimationFinishCheck finishCheck(signalReceived); - animation.FinishedSignal().Connect(&application, finishCheck); - application.SendNotification(); - application.Render(0); + // We didn't expect the animation to finish yet 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(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(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(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 ); + // The position should have moved less, than with a linear alpha function + Vector3 current(actor.GetCurrentPosition()); + DALI_TEST_CHECK( current.x > Vector3::ZERO.x ); + DALI_TEST_CHECK( current.y > Vector3::ZERO.y ); + DALI_TEST_CHECK( current.z > Vector3::ZERO.z ); + DALI_TEST_CHECK( current.x < seventyFivePercentProgress.x ); + DALI_TEST_CHECK( current.y < seventyFivePercentProgress.y ); + DALI_TEST_CHECK( current.z < seventyFivePercentProgress.z ); - application.Render(static_cast(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 ); + application.Render(static_cast(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(), targetPosition, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationMoveByFloat3(void) +int UtcDaliAnimationAnimateToActorPositionTimePeriodP(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 ); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, 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 targetPosition(200.0f, 200.0f, 200.0f); + float delay = 0.5f; + animation.AnimateTo( Property(actor, Actor::Property::POSITION), + targetPosition, + TimePeriod( delay, durationSeconds - delay ) ); - Vector3 ninetyFivePercentProgress(startPosition + relativePosition*0.95f); + Vector3 seventyFivePercentProgress(targetPosition * 0.75f); // Start the animation animation.Play(); @@ -6722,66 +7063,23 @@ int UtcDaliAnimationMoveByFloat3(void) animation.FinishedSignal().Connect(&application, finishCheck); application.SendNotification(); - application.Render(static_cast(durationSeconds*950.0f)/* 95% progress */); + application.Render(static_cast(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.GetCurrentPosition(), ninetyFivePercentProgress, TEST_LOCATION ); - - application.SendNotification(); - application.Render(static_cast(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); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION ); application.SendNotification(); - application.Render(static_cast(durationSeconds*950.0f)/* 95% progress */); + application.Render(static_cast(durationSeconds*500.0f*0.75)/* 7/8 animation progress, 3/4 animator progress */); // We didn't expect the animation to finish yet application.SendNotification(); finishCheck.CheckSignalNotReceived(); - - // The position should have moved more, than with a linear alpha function - Vector3 current(actor.GetCurrentPosition()); - DALI_TEST_CHECK( current.x > ninetyFivePercentProgress.x ); - DALI_TEST_CHECK( current.y > ninetyFivePercentProgress.y ); - DALI_TEST_CHECK( current.z > ninetyFivePercentProgress.z ); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), seventyFivePercentProgress, TEST_LOCATION ); application.SendNotification(); - application.Render(static_cast(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/); + application.Render(static_cast(durationSeconds*500.0f*0.25) + 1u/*just beyond the animation duration*/); // We did expect the animation to finish application.SendNotification(); @@ -6790,27 +7088,25 @@ int UtcDaliAnimationMoveByVector3Alpha(void) END_TEST; } -int UtcDaliAnimationMoveByVector3AlphaFloat2(void) +int UtcDaliAnimationAnimateToActorPositionAlphaFunctionTimePeriodP(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 ); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, 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); + Vector3 targetPosition(200.0f, 200.0f, 200.0f); float delay = 0.5f; - animation.MoveBy(actor, relativePosition, AlphaFunctions::Linear, delay, durationSeconds - delay); + animation.AnimateTo( Property(actor, Actor::Property::POSITION), + targetPosition, + AlphaFunction::LINEAR, + TimePeriod( delay, durationSeconds - delay ) ); - Vector3 ninetyFivePercentProgress(startPosition + relativePosition*0.95f); + Vector3 seventyFivePercentProgress(targetPosition * 0.75f); // Start the animation animation.Play(); @@ -6825,10 +7121,18 @@ int UtcDaliAnimationMoveByVector3AlphaFloat2(void) // We didn't expect the animation to finish yet application.SendNotification(); finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION ); application.SendNotification(); - application.Render(static_cast(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/); + application.Render(static_cast(durationSeconds*500.0f*0.75)/* 7/8 animation progress, 3/4 animator progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), seventyFivePercentProgress, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*500.0f*0.25) + 1u/*just beyond the animation duration*/); // We did expect the animation to finish application.SendNotification(); @@ -6837,21 +7141,21 @@ int UtcDaliAnimationMoveByVector3AlphaFloat2(void) END_TEST; } -int UtcDaliAnimationMoveToFloat3(void) +int UtcDaliAnimationAnimateToActorOrientationAngleAxisP(void) { TestApplication application; Actor actor = Actor::New(); + actor.SetOrientation(Quaternion( Dali::ANGLE_0, Vector3::YAXIS ) ); Stage::GetCurrent().Add(actor); - DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion( Dali::ANGLE_0, Vector3::YAXIS ), ROTATION_EPSILON, TEST_LOCATION ); // Build the animation float durationSeconds(1.0f); Animation animation = Animation::New(durationSeconds); - Vector3 targetPosition(200.0f, 200.0f, 200.0f); - animation.MoveTo(actor, targetPosition.x, targetPosition.y, targetPosition.z); - - Vector3 seventyFivePercentProgress(targetPosition * 0.75f); + Degree targetRotationDegrees(90.0f); + Radian targetRotationRadians(targetRotationDegrees); + animation.AnimateTo( Property(actor, Actor::Property::ORIENTATION), AngleAxis(targetRotationRadians, Vector3::YAXIS) ); // Start the animation animation.Play(); @@ -6861,61 +7165,28 @@ int UtcDaliAnimationMoveToFloat3(void) animation.FinishedSignal().Connect(&application, finishCheck); application.SendNotification(); - application.Render(static_cast(durationSeconds*750.0f)/* 75% progress */); + application.Render(static_cast(durationSeconds*250.0f)/* 25% progress */); // We didn't expect the animation to finish yet application.SendNotification(); finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetCurrentPosition(), seventyFivePercentProgress, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * 0.25f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/); + application.Render(static_cast(durationSeconds*250.0f)/* 50% progress */); - // We did expect the animation to finish + // We didn't expect the animation to finish yet application.SendNotification(); - finishCheck.CheckSignalReceived(); - DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION ); - END_TEST; -} - -int UtcDaliAnimationMoveToVector3Alpha(void) -{ - TestApplication application; - - Actor actor = Actor::New(); - Stage::GetCurrent().Add(actor); - DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION ); - - // Build the animation - float durationSeconds(1.0f); - Animation animation = Animation::New(durationSeconds); - Vector3 targetPosition(200.0f, 200.0f, 200.0f); - animation.MoveTo(actor, targetPosition, AlphaFunctions::EaseIn); - - Vector3 seventyFivePercentProgress(targetPosition * 0.75f); - - // Start the animation - animation.Play(); - - bool signalReceived(false); - AnimationFinishCheck finishCheck(signalReceived); - animation.FinishedSignal().Connect(&application, finishCheck); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * 0.5f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); application.SendNotification(); - application.Render(static_cast(durationSeconds*750.0f)/* 75% progress */); + application.Render(static_cast(durationSeconds*250.0f)/* 75% progress */); // We didn't expect the animation to finish yet application.SendNotification(); finishCheck.CheckSignalNotReceived(); - - // The position should have moved less, than with a linear alpha function - Vector3 current(actor.GetCurrentPosition()); - DALI_TEST_CHECK( current.x > Vector3::ZERO.x ); - DALI_TEST_CHECK( current.y > Vector3::ZERO.y ); - DALI_TEST_CHECK( current.z > Vector3::ZERO.z ); - DALI_TEST_CHECK( current.x < seventyFivePercentProgress.x ); - DALI_TEST_CHECK( current.y < seventyFivePercentProgress.y ); - DALI_TEST_CHECK( current.z < seventyFivePercentProgress.z ); + DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * 0.75f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); application.SendNotification(); application.Render(static_cast(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/); @@ -6923,26 +7194,26 @@ int UtcDaliAnimationMoveToVector3Alpha(void) // We did expect the animation to finish application.SendNotification(); finishCheck.CheckSignalReceived(); - DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationMoveToVector3AlphaFloat2(void) +int UtcDaliAnimationAnimateToActorOrientationQuaternionP(void) { TestApplication application; Actor actor = Actor::New(); + actor.SetOrientation(Quaternion( Dali::ANGLE_0, Vector3::YAXIS ) ); Stage::GetCurrent().Add(actor); - DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion( Dali::ANGLE_0, Vector3::YAXIS ), ROTATION_EPSILON, TEST_LOCATION ); // Build the animation float durationSeconds(1.0f); Animation animation = Animation::New(durationSeconds); - Vector3 targetPosition(200.0f, 200.0f, 200.0f); - float delay = 0.5f; - animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear, delay, durationSeconds - delay); - - Vector3 seventyFivePercentProgress(targetPosition * 0.75f); + Degree targetRotationDegrees(90.0f); + Radian targetRotationRadians(targetRotationDegrees); + Quaternion targetRotation(targetRotationRadians, Vector3::YAXIS); + animation.AnimateTo( Property(actor, Actor::Property::ORIENTATION), targetRotation ); // Start the animation animation.Play(); @@ -6952,46 +7223,54 @@ int UtcDaliAnimationMoveToVector3AlphaFloat2(void) animation.FinishedSignal().Connect(&application, finishCheck); application.SendNotification(); - application.Render(static_cast(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */); + application.Render(static_cast(durationSeconds*250.0f)/* 25% progress */); // We didn't expect the animation to finish yet application.SendNotification(); finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * 0.25f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); application.SendNotification(); - application.Render(static_cast(durationSeconds*500.0f*0.75)/* 7/8 animation progress, 3/4 animator progress */); + application.Render(static_cast(durationSeconds*250.0f)/* 50% progress */); // We didn't expect the animation to finish yet application.SendNotification(); finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetCurrentPosition(), seventyFivePercentProgress, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * 0.5f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); application.SendNotification(); - application.Render(static_cast(durationSeconds*500.0f*0.25) + 1u/*just beyond the animation duration*/); + application.Render(static_cast(durationSeconds*250.0f)/* 75% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * 0.75f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(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(), targetPosition, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationMove(void) +int UtcDaliAnimationAnimateToActorOrientationAlphaFunctionP(void) { TestApplication application; Actor actor = Actor::New(); - Vector3 initialPosition(Vector3::ZERO); - DALI_TEST_EQUALS( actor.GetCurrentPosition(), initialPosition, TEST_LOCATION ); + actor.SetOrientation(Quaternion( Dali::ANGLE_0, Vector3::YAXIS ) ); Stage::GetCurrent().Add(actor); + DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(Radian(0.0f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); // Build the animation - float durationSeconds(10.0f); + float durationSeconds(1.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); + Degree targetRotationDegrees(90.0f); + Radian targetRotationRadians(targetRotationDegrees); + animation.AnimateTo( Property(actor, Actor::Property::ORIENTATION), AngleAxis(targetRotationDegrees, Vector3::YAXIS), AlphaFunction::EASE_IN); // Start the animation animation.Play(); @@ -7006,7 +7285,7 @@ int UtcDaliAnimationMove(void) // We didn't expect the animation to finish yet application.SendNotification(); finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetCurrentPosition(), func(0.25f, initialPosition), TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * 0.25f*0.25f*0.25f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); application.SendNotification(); application.Render(static_cast(durationSeconds*250.0f)/* 50% progress */); @@ -7014,7 +7293,7 @@ int UtcDaliAnimationMove(void) // 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.GetCurrentOrientation(), Quaternion(targetRotationRadians * 0.5f*0.5f*0.5f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); application.SendNotification(); application.Render(static_cast(durationSeconds*250.0f)/* 75% progress */); @@ -7022,7 +7301,7 @@ int UtcDaliAnimationMove(void) // 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.GetCurrentOrientation(), Quaternion(targetRotationRadians * 0.75f*0.75f*0.75f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); application.SendNotification(); application.Render(static_cast(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/); @@ -7030,25 +7309,26 @@ int UtcDaliAnimationMove(void) // We did expect the animation to finish application.SendNotification(); finishCheck.CheckSignalReceived(); - DALI_TEST_EQUALS( actor.GetCurrentPosition(), initialPosition, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationRotateByDegreeVector3(void) +int UtcDaliAnimationAnimateToActorOrientationTimePeriodP(void) { TestApplication application; Actor actor = Actor::New(); - actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS)); + actor.SetOrientation(Quaternion( Dali::ANGLE_0, Vector3::YAXIS ) ); Stage::GetCurrent().Add(actor); - DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion( Dali::ANGLE_0, Vector3::YAXIS ), ROTATION_EPSILON, TEST_LOCATION ); // Build the animation float durationSeconds(1.0f); Animation animation = Animation::New(durationSeconds); - Degree relativeRotationDegrees(360.0f); - Radian relativeRotationRadians(relativeRotationDegrees); - animation.RotateBy(actor, relativeRotationDegrees/*Degree version*/, Vector3::YAXIS); + Degree targetRotationDegrees(90.0f); + Radian targetRotationRadians(targetRotationDegrees); + float delay(0.1f); + animation.AnimateTo( Property(actor, Actor::Property::ORIENTATION), AngleAxis(targetRotationDegrees, Vector3::YAXIS), TimePeriod(delay, durationSeconds - delay)); // Start the animation animation.Play(); @@ -7063,7 +7343,8 @@ int UtcDaliAnimationRotateByDegreeVector3(void) // We didn't expect the animation to finish yet application.SendNotification(); finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * 0.25f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + float progress = max(0.0f, 0.25f - delay) / (1.0f - delay); + DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * progress, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); application.SendNotification(); application.Render(static_cast(durationSeconds*250.0f)/* 50% progress */); @@ -7071,7 +7352,8 @@ int UtcDaliAnimationRotateByDegreeVector3(void) // We didn't expect the animation to finish yet application.SendNotification(); finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * 0.5f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + progress = max(0.0f, 0.5f - delay) / (1.0f - delay); + DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * progress, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); application.SendNotification(); application.Render(static_cast(durationSeconds*250.0f)/* 75% progress */); @@ -7079,7 +7361,8 @@ int UtcDaliAnimationRotateByDegreeVector3(void) // We didn't expect the animation to finish yet application.SendNotification(); finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * 0.75f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + progress = max(0.0f, 0.75f - delay) / (1.0f - delay); + DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * progress, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); application.SendNotification(); application.Render(static_cast(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/); @@ -7087,25 +7370,26 @@ int UtcDaliAnimationRotateByDegreeVector3(void) // We did expect the animation to finish application.SendNotification(); finishCheck.CheckSignalReceived(); - DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationRotateByRadianVector3(void) +int UtcDaliAnimationAnimateToActorOrientationAlphaFunctionTimePeriodP(void) { TestApplication application; Actor actor = Actor::New(); - actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS)); + actor.SetOrientation(Quaternion( Dali::ANGLE_0, Vector3::YAXIS ) ); Stage::GetCurrent().Add(actor); - DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion( Dali::ANGLE_0, Vector3::YAXIS ), ROTATION_EPSILON, TEST_LOCATION ); // Build the animation float durationSeconds(1.0f); Animation animation = Animation::New(durationSeconds); - Degree relativeRotationDegrees(360.0f); - Radian relativeRotationRadians(relativeRotationDegrees); - animation.RotateBy(actor, relativeRotationRadians/*Radian version*/, Vector3::YAXIS); + Degree targetRotationDegrees(90.0f); + Radian targetRotationRadians(targetRotationDegrees); + float delay(0.1f); + animation.AnimateTo( Property(actor, Actor::Property::ORIENTATION), AngleAxis(targetRotationDegrees, Vector3::YAXIS), AlphaFunction::EASE_IN, TimePeriod(delay, durationSeconds - delay)); // Start the animation animation.Play(); @@ -7120,7 +7404,8 @@ int UtcDaliAnimationRotateByRadianVector3(void) // We didn't expect the animation to finish yet application.SendNotification(); finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * 0.25f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + float progress = max(0.0f, 0.25f - delay) / (1.0f - delay); + DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * progress*progress*progress, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); application.SendNotification(); application.Render(static_cast(durationSeconds*250.0f)/* 50% progress */); @@ -7128,7 +7413,8 @@ int UtcDaliAnimationRotateByRadianVector3(void) // We didn't expect the animation to finish yet application.SendNotification(); finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * 0.5f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + progress = max(0.0f, 0.5f - delay) / (1.0f - delay); + DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * progress*progress*progress, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); application.SendNotification(); application.Render(static_cast(durationSeconds*250.0f)/* 75% progress */); @@ -7136,7 +7422,8 @@ int UtcDaliAnimationRotateByRadianVector3(void) // We didn't expect the animation to finish yet application.SendNotification(); finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * 0.75f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + progress = max(0.0f, 0.75f - delay) / (1.0f - delay); + DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * progress*progress*progress, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); application.SendNotification(); application.Render(static_cast(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/); @@ -7144,25 +7431,25 @@ int UtcDaliAnimationRotateByRadianVector3(void) // We did expect the animation to finish application.SendNotification(); finishCheck.CheckSignalReceived(); - DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationRotateByDegreeVector3Alpha(void) +int UtcDaliAnimationAnimateToActorScaleP(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 ); + DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION ); // Build the animation float durationSeconds(1.0f); Animation animation = Animation::New(durationSeconds); - Degree relativeRotationDegrees(360.0f); - Radian relativeRotationRadians(relativeRotationDegrees); - animation.RotateBy(actor, relativeRotationDegrees/*Degree version*/, Vector3::YAXIS, AlphaFunctions::EaseIn); + Vector3 targetScale(2.0f, 2.0f, 2.0f); + animation.AnimateTo( Property(actor, Actor::Property::SCALE), targetScale ); + + Vector3 ninetyNinePercentProgress(Vector3::ONE + (targetScale - Vector3::ONE)*0.99f); // Start the animation animation.Play(); @@ -7172,54 +7459,109 @@ int UtcDaliAnimationRotateByDegreeVector3Alpha(void) animation.FinishedSignal().Connect(&application, finishCheck); application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f)/* 25% progress */); + application.Render(static_cast(durationSeconds*990.0f)/* 99% progress */); // We didn't expect the animation to finish yet application.SendNotification(); finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * AlphaFunctions::EaseIn(0.25f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentScale(), ninetyNinePercentProgress, TEST_LOCATION ); application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f)/* 50% progress */); + application.Render(static_cast(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION ); + + // Reset everything + finishCheck.Reset(); + actor.SetScale(Vector3::ONE); + application.SendNotification(); + application.Render(0); + DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION ); + + // Repeat with a different (ease-in) alpha function + animation = Animation::New(durationSeconds); + animation.AnimateTo( Property(actor, Actor::Property::SCALE), targetScale, AlphaFunction::EASE_IN); + animation.FinishedSignal().Connect(&application, finishCheck); + animation.Play(); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*990.0f)/* 99% progress */); // We didn't expect the animation to finish yet application.SendNotification(); finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * AlphaFunctions::EaseIn(0.5f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + + // The scale should have grown less, than with a linear alpha function + Vector3 current(actor.GetCurrentScale()); + DALI_TEST_CHECK( current.x > 1.0f ); + DALI_TEST_CHECK( current.y > 1.0f ); + DALI_TEST_CHECK( current.z > 1.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(durationSeconds*250.0f)/* 75% progress */); + application.Render(static_cast(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION ); + + // Reset everything + finishCheck.Reset(); + actor.SetScale(Vector3::ONE); + application.SendNotification(); + application.Render(0); + DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION ); + + // Repeat with a delay + float delay = 0.5f; + animation = Animation::New(durationSeconds); + animation.AnimateTo( Property(actor, Actor::Property::SCALE), targetScale, AlphaFunction::LINEAR, TimePeriod(delay, durationSeconds - delay)); + animation.FinishedSignal().Connect(&application, finishCheck); + animation.Play(); + + application.SendNotification(); + application.Render(static_cast(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(relativeRotationRadians * AlphaFunctions::EaseIn(0.75f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION ); application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/); + application.Render(static_cast(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(), Quaternion(relativeRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationRotateByRadianVector3Alpha(void) +int UtcDaliAnimationAnimateToActorScaleXP(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 ); + float startValue(1.0f); + DALI_TEST_EQUALS( actor.GetCurrentScale().x, startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::SCALE_X), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::SCALE_Y), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::SCALE_Z), startValue, TEST_LOCATION ); // Build the animation float durationSeconds(1.0f); Animation animation = Animation::New(durationSeconds); - Degree relativeRotationDegrees(360.0f); - Radian relativeRotationRadians(relativeRotationDegrees); - animation.RotateBy(actor, relativeRotationRadians/*Radian version*/, Vector3::YAXIS, AlphaFunctions::EaseIn); + float targetX(10.0f); + animation.AnimateTo( Property(actor, Actor::Property::SCALE_X), targetX ); + + float fiftyPercentProgress(startValue + (targetX - startValue)*0.5f); // Start the animation animation.Play(); @@ -7229,55 +7571,48 @@ int UtcDaliAnimationRotateByRadianVector3Alpha(void) animation.FinishedSignal().Connect(&application, finishCheck); application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f)/* 25% progress */); - - // We didn't expect the animation to finish yet - application.SendNotification(); - finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * AlphaFunctions::EaseIn(0.25f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); - - application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f)/* 50% progress */); - - // We didn't expect the animation to finish yet - application.SendNotification(); - finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * AlphaFunctions::EaseIn(0.5f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); - - application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f)/* 75% progress */); + application.Render(static_cast(durationSeconds*500.0f)/* 50% progress */); // We didn't expect the animation to finish yet application.SendNotification(); finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * AlphaFunctions::EaseIn(0.75f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentScale().x, fiftyPercentProgress, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::SCALE_X), fiftyPercentProgress, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::SCALE_Y), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::SCALE_Z), startValue, TEST_LOCATION ); application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/); + application.Render(static_cast(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(), Quaternion(relativeRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentScale().x, targetX, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::SCALE_X), targetX, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::SCALE_Y), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::SCALE_Z), startValue, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationRotateByDegreeVector3AlphaFloat2(void) +int UtcDaliAnimationAnimateToActorScaleYP(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 ); + float startValue(1.0f); + DALI_TEST_EQUALS( actor.GetCurrentScale().y, startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::SCALE_X), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::SCALE_Y), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::SCALE_Z), startValue, TEST_LOCATION ); // Build the animation float durationSeconds(1.0f); Animation animation = Animation::New(durationSeconds); - Degree relativeRotationDegrees(360.0f); - Radian relativeRotationRadians(relativeRotationDegrees); - float delay = 0.3f; - animation.RotateBy(actor, relativeRotationDegrees/*Degree version*/, Vector3::YAXIS, AlphaFunctions::EaseIn, delay, durationSeconds - delay); + float targetY(1000.0f); + animation.AnimateTo( Property(actor, Actor::Property::SCALE_Y), targetY ); + + float fiftyPercentProgress(startValue + (targetY - startValue)*0.5f); // Start the animation animation.Play(); @@ -7287,59 +7622,48 @@ int UtcDaliAnimationRotateByDegreeVector3AlphaFloat2(void) animation.FinishedSignal().Connect(&application, finishCheck); application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f)/* 25% progress */); - - // We didn't expect the animation to finish yet - application.SendNotification(); - finishCheck.CheckSignalNotReceived(); - float progress = max(0.0f, 0.25f - delay) / (1.0f - delay); - DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); - - application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f)/* 50% progress */); - - // We didn't expect the animation to finish yet - application.SendNotification(); - finishCheck.CheckSignalNotReceived(); - progress = max(0.0f, 0.5f - delay) / (1.0f - delay); - DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); - - application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f)/* 75% progress */); + application.Render(static_cast(durationSeconds*500.0f)/* 50% progress */); // We didn't expect the animation to finish yet application.SendNotification(); finishCheck.CheckSignalNotReceived(); - progress = max(0.0f, 0.75f - delay) / (1.0f - delay); - DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentScale().y, fiftyPercentProgress, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::SCALE_X), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::SCALE_Y), fiftyPercentProgress, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::SCALE_Z), startValue, TEST_LOCATION ); application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/); + application.Render(static_cast(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(), Quaternion(relativeRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentScale().y, targetY, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::SCALE_X), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::SCALE_Y), targetY, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::SCALE_Z), startValue, TEST_LOCATION ); END_TEST; } - -int UtcDaliAnimationRotateByRadianVector3AlphaFloat2(void) +int UtcDaliAnimationAnimateToActorScaleZP(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 ); + float startValue(1.0f); + DALI_TEST_EQUALS( actor.GetCurrentScale().z, startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::SCALE_X), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::SCALE_Y), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::SCALE_Z), startValue, TEST_LOCATION ); // Build the animation float durationSeconds(1.0f); Animation animation = Animation::New(durationSeconds); - Degree relativeRotationDegrees(360.0f); - Radian relativeRotationRadians(relativeRotationDegrees); - float delay = 0.3f; - animation.RotateBy(actor, relativeRotationRadians/*Radian version*/, Vector3::YAXIS, AlphaFunctions::EaseIn, delay, durationSeconds - delay); + float targetZ(-1000.0f); + animation.AnimateTo( Property(actor, Actor::Property::SCALE_Z), targetZ ); + + float fiftyPercentProgress(startValue + (targetZ - startValue)*0.5f); // Start the animation animation.Play(); @@ -7349,57 +7673,45 @@ int UtcDaliAnimationRotateByRadianVector3AlphaFloat2(void) animation.FinishedSignal().Connect(&application, finishCheck); application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f)/* 25% progress */); - - // We didn't expect the animation to finish yet - application.SendNotification(); - finishCheck.CheckSignalNotReceived(); - float progress = max(0.0f, 0.25f - delay) / (1.0f - delay); - DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); - - application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f)/* 50% progress */); - - // We didn't expect the animation to finish yet - application.SendNotification(); - finishCheck.CheckSignalNotReceived(); - progress = max(0.0f, 0.5f - delay) / (1.0f - delay); - DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); - - application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f)/* 75% progress */); + application.Render(static_cast(durationSeconds*500.0f)/* 50% progress */); // We didn't expect the animation to finish yet application.SendNotification(); finishCheck.CheckSignalNotReceived(); - progress = max(0.0f, 0.75f - delay) / (1.0f - delay); - DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentScale().z, fiftyPercentProgress, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::SCALE_X), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::SCALE_Y), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::SCALE_Z), fiftyPercentProgress, TEST_LOCATION ); application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/); + application.Render(static_cast(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(), Quaternion(relativeRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentScale().z, targetZ, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::SCALE_X), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::SCALE_Y), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::SCALE_Z), targetZ, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationRotateToDegreeVector3(void) +int UtcDaliAnimationAnimateToActorColorP(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 ); + DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION ); // Build the animation float durationSeconds(1.0f); Animation animation = Animation::New(durationSeconds); - Degree targetRotationDegrees(90.0f); - Radian targetRotationRadians(targetRotationDegrees); - animation.RotateTo(actor, targetRotationDegrees/*Degree version*/, Vector3::YAXIS); + Vector4 targetColor(Color::RED); + animation.AnimateTo( Property(actor, Actor::Property::COLOR), targetColor ); + + Vector4 tenPercentProgress(Vector4(1.0f, 0.9f, 0.9f, 1.0f)); + Vector4 twentyPercentProgress(Vector4(1.0f, 0.8f, 0.8f, 1.0f)); // Start the animation animation.Play(); @@ -7409,112 +7721,118 @@ int UtcDaliAnimationRotateToDegreeVector3(void) animation.FinishedSignal().Connect(&application, finishCheck); application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f)/* 25% progress */); + application.Render(static_cast(durationSeconds*100.0f)/* 10% progress */); // We didn't expect the animation to finish yet application.SendNotification(); finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.25f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentColor(), tenPercentProgress, TEST_LOCATION ); application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f)/* 50% progress */); + application.Render(static_cast(durationSeconds*900.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(targetRotationRadians * 0.5f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION ); + // Reset everything + finishCheck.Reset(); + actor.SetColor(Color::WHITE); application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f)/* 75% progress */); + application.Render(0); + DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION ); + + // Repeat with a different (ease-in) alpha function + animation = Animation::New(durationSeconds); + animation.AnimateTo( Property(actor, Actor::Property::COLOR), targetColor, AlphaFunction::EASE_IN); + animation.FinishedSignal().Connect(&application, finishCheck); + animation.Play(); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*100.0f)/* 10% progress */); // We didn't expect the animation to finish yet application.SendNotification(); finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.75f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + + // The color should have changed less, than with a linear alpha function + Vector4 current(actor.GetCurrentColor()); + DALI_TEST_CHECK( current.x == 1.0f ); // doesn't change + DALI_TEST_CHECK( current.y < 1.0f ); + DALI_TEST_CHECK( current.y > tenPercentProgress.y ); + DALI_TEST_CHECK( current.z < 1.0f ); + DALI_TEST_CHECK( current.z > tenPercentProgress.z ); + DALI_TEST_CHECK( current.w == 1.0f ); // doesn't change application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/); + application.Render(static_cast(durationSeconds*900.0f) + 1u/*just beyond the animation duration*/); // We did expect the animation to finish application.SendNotification(); finishCheck.CheckSignalReceived(); - DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); - END_TEST; -} - -int UtcDaliAnimationRotateToRadianVector3(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 targetRotationDegrees(90.0f); - Radian targetRotationRadians(targetRotationDegrees); - animation.RotateTo(actor, targetRotationRadians/*Radian version*/, Vector3::YAXIS); - - // Start the animation - animation.Play(); - - bool signalReceived(false); - AnimationFinishCheck finishCheck(signalReceived); - animation.FinishedSignal().Connect(&application, finishCheck); + DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION ); + // Reset everything + finishCheck.Reset(); + actor.SetColor(Color::WHITE); application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f)/* 25% progress */); + application.Render(0); + DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION ); - // We didn't expect the animation to finish yet - application.SendNotification(); - finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.25f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + // Repeat with a shorter animator duration + float animatorDuration = 0.5f; + animation = Animation::New(durationSeconds); + animation.AnimateTo( Property(actor, Actor::Property::COLOR), targetColor, AlphaFunction::LINEAR, TimePeriod(animatorDuration)); + animation.FinishedSignal().Connect(&application, finishCheck); + animation.Play(); application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f)/* 50% progress */); + application.Render(static_cast(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.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.5f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentColor(), twentyPercentProgress, TEST_LOCATION ); application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f)/* 75% progress */); + application.Render(static_cast(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.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.75f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION ); application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/); + application.Render(static_cast(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(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationRotateToQuaternion(void) +int UtcDaliAnimationAnimateToActorColorRedP(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 ); + float startValue(1.0f); + DALI_TEST_EQUALS( actor.GetCurrentColor().r, startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_RED), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_BLUE), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION ); // Build the animation float durationSeconds(1.0f); Animation animation = Animation::New(durationSeconds); - Degree targetRotationDegrees(90.0f); - Radian targetRotationRadians(targetRotationDegrees); - Quaternion targetRotation(targetRotationRadians, Vector3::YAXIS); - animation.RotateTo(actor, targetRotation/*Quaternion version*/); + float targetRed(0.5f); + animation.AnimateTo( Property(actor, Actor::Property::COLOR_RED), targetRed ); + + float fiftyPercentProgress(startValue + (targetRed - startValue)*0.5f); // Start the animation animation.Play(); @@ -7524,54 +7842,51 @@ int UtcDaliAnimationRotateToQuaternion(void) animation.FinishedSignal().Connect(&application, finishCheck); application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f)/* 25% progress */); + application.Render(static_cast(durationSeconds*500.0f)/* 50% progress */); // We didn't expect the animation to finish yet application.SendNotification(); finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.25f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); - - application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f)/* 50% progress */); + DALI_TEST_EQUALS( actor.GetCurrentColor().r, fiftyPercentProgress, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_RED), fiftyPercentProgress, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_BLUE), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION ); - // We didn't expect the animation to finish yet application.SendNotification(); - finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.5f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + application.Render(static_cast(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/); - application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f)/* 75% progress */); - - // We didn't expect the animation to finish yet - application.SendNotification(); - finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.75f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); - - application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/); - - // We did expect the animation to finish + // We did expect the animation to finish application.SendNotification(); finishCheck.CheckSignalReceived(); - DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentColor().r, targetRed, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_RED), targetRed, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_BLUE), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationRotateToDegreeVector3Alpha(void) +int UtcDaliAnimationAnimateToActorColorGreenP(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 ); + float startValue(1.0f); + DALI_TEST_EQUALS( actor.GetCurrentColor().g, startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_RED), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_BLUE), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION ); // Build the animation float durationSeconds(1.0f); Animation animation = Animation::New(durationSeconds); - Degree targetRotationDegrees(90.0f); - Radian targetRotationRadians(targetRotationDegrees); - animation.RotateTo(actor, targetRotationDegrees/*Degree version*/, Vector3::YAXIS, AlphaFunctions::EaseIn); + float targetGreen(0.5f); + animation.AnimateTo( Property(actor, Actor::Property::COLOR_GREEN), targetGreen ); + + float fiftyPercentProgress(startValue + (targetGreen - startValue)*0.5f); // Start the animation animation.Play(); @@ -7581,54 +7896,51 @@ int UtcDaliAnimationRotateToDegreeVector3Alpha(void) animation.FinishedSignal().Connect(&application, finishCheck); application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f)/* 25% progress */); - - // We didn't expect the animation to finish yet - application.SendNotification(); - finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(0.25f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); - - application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f)/* 50% progress */); - - // We didn't expect the animation to finish yet - application.SendNotification(); - finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(0.5f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); - - application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f)/* 75% progress */); + application.Render(static_cast(durationSeconds*500.0f)/* 50% progress */); // We didn't expect the animation to finish yet application.SendNotification(); finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(0.75f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentColor().g, fiftyPercentProgress, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_RED), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_GREEN), fiftyPercentProgress, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_BLUE), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION ); application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/); + application.Render(static_cast(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(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentColor().g, targetGreen, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_RED), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_GREEN), targetGreen, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_BLUE), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationRotateToRadianVector3Alpha(void) +int UtcDaliAnimationAnimateToActorColorBlueP(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 ); + float startValue(1.0f); + DALI_TEST_EQUALS( actor.GetCurrentColor().b, startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_RED), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_BLUE), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION ); // Build the animation float durationSeconds(1.0f); Animation animation = Animation::New(durationSeconds); - Degree targetRotationDegrees(90.0f); - Radian targetRotationRadians(targetRotationDegrees); - animation.RotateTo(actor, targetRotationRadians/*Radian version*/, Vector3::YAXIS, AlphaFunctions::EaseIn); + float targetBlue(0.5f); + animation.AnimateTo( Property(actor, Actor::Property::COLOR_BLUE), targetBlue ); + + float fiftyPercentProgress(startValue + (targetBlue - startValue)*0.5f); // Start the animation animation.Play(); @@ -7638,55 +7950,51 @@ int UtcDaliAnimationRotateToRadianVector3Alpha(void) animation.FinishedSignal().Connect(&application, finishCheck); application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f)/* 25% progress */); - - // We didn't expect the animation to finish yet - application.SendNotification(); - finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(0.25f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); - - application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f)/* 50% progress */); - - // We didn't expect the animation to finish yet - application.SendNotification(); - finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(0.5f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); - - application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f)/* 75% progress */); + application.Render(static_cast(durationSeconds*500.0f)/* 50% progress */); // We didn't expect the animation to finish yet application.SendNotification(); finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(0.75f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentColor().b, fiftyPercentProgress, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_RED), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_BLUE), fiftyPercentProgress, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION ); application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/); + application.Render(static_cast(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(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentColor().b, targetBlue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_RED), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_BLUE), targetBlue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationRotateToQuaternionAlpha(void) +int UtcDaliAnimationAnimateToActorColorAlphaP(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 ); + float startValue(1.0f); + DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_RED), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_BLUE), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION ); // Build the animation float durationSeconds(1.0f); Animation animation = Animation::New(durationSeconds); - Degree targetRotationDegrees(90.0f); - Radian targetRotationRadians(targetRotationDegrees); - Quaternion targetRotation(targetRotationRadians, Vector3::YAXIS); - animation.RotateTo(actor, targetRotation/*Quaternion version*/, AlphaFunctions::EaseIn); + float targetAlpha(0.5f); + animation.AnimateTo( Property(actor, Actor::Property::COLOR_ALPHA), targetAlpha ); + + float fiftyPercentProgress(startValue + (targetAlpha - startValue)*0.5f); // Start the animation animation.Play(); @@ -7696,651 +8004,254 @@ int UtcDaliAnimationRotateToQuaternionAlpha(void) animation.FinishedSignal().Connect(&application, finishCheck); application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f)/* 25% progress */); - - // We didn't expect the animation to finish yet - application.SendNotification(); - finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(0.25f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); - - application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f)/* 50% progress */); - - // We didn't expect the animation to finish yet - application.SendNotification(); - finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(0.5f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); - - application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f)/* 75% progress */); + application.Render(static_cast(durationSeconds*500.0f)/* 50% progress */); // We didn't expect the animation to finish yet application.SendNotification(); finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(0.75f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentColor().a, fiftyPercentProgress, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_RED), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_BLUE), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_ALPHA), fiftyPercentProgress, TEST_LOCATION ); application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/); + application.Render(static_cast(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(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentColor().a, targetAlpha, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_RED), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_BLUE), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_ALPHA), targetAlpha, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationRotateToDegreeVector3AlphaFloat2(void) +int UtcDaliAnimationKeyFrames01P(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 ); + KeyFrames keyFrames = KeyFrames::New(); + DALI_TEST_EQUALS(keyFrames.GetType(), Property::NONE, TEST_LOCATION); - // Build the animation - float durationSeconds(1.0f); - Animation animation = Animation::New(durationSeconds); - Degree targetRotationDegrees(90.0f); - Radian targetRotationRadians(targetRotationDegrees); - float delay(0.1f); - animation.RotateTo(actor, targetRotationDegrees/*Degree version*/, Vector3::YAXIS, AlphaFunctions::EaseIn, delay, durationSeconds - delay); + keyFrames.Add(0.0f, 0.1f); - // Start the animation - animation.Play(); + DALI_TEST_EQUALS(keyFrames.GetType(), Property::FLOAT, TEST_LOCATION); - bool signalReceived(false); - AnimationFinishCheck finishCheck(signalReceived); - animation.FinishedSignal().Connect(&application, finishCheck); + KeyFrames keyFrames2( keyFrames); + DALI_TEST_CHECK( keyFrames2 ); + DALI_TEST_EQUALS(keyFrames2.GetType(), Property::FLOAT, TEST_LOCATION); - application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f)/* 25% progress */); + KeyFrames keyFrames3 = KeyFrames::New(); + keyFrames3.Add(0.6f, true); + DALI_TEST_CHECK( keyFrames3 ); + DALI_TEST_EQUALS(keyFrames3.GetType(), Property::BOOLEAN, TEST_LOCATION); - // We didn't expect the animation to finish yet - application.SendNotification(); - finishCheck.CheckSignalNotReceived(); - float progress = max(0.0f, 0.25f - delay) / (1.0f - delay); - DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + keyFrames3 = keyFrames; + DALI_TEST_CHECK( keyFrames3 ); + DALI_TEST_EQUALS(keyFrames3.GetType(), Property::FLOAT, TEST_LOCATION); - application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f)/* 50% progress */); + END_TEST; +} - // We didn't expect the animation to finish yet - application.SendNotification(); - finishCheck.CheckSignalNotReceived(); - progress = max(0.0f, 0.5f - delay) / (1.0f - delay); - DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); +int UtcDaliAnimationKeyFrames02P(void) +{ + TestApplication application; - application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f)/* 75% progress */); + KeyFrames keyFrames = KeyFrames::New(); + DALI_TEST_EQUALS(keyFrames.GetType(), Property::NONE, TEST_LOCATION); - // We didn't expect the animation to finish yet - application.SendNotification(); - finishCheck.CheckSignalNotReceived(); - progress = max(0.0f, 0.75f - delay) / (1.0f - delay); - DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + 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); - application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/); + DALI_TEST_EQUALS(keyFrames.GetType(), Property::FLOAT, TEST_LOCATION); - // We did expect the animation to finish - application.SendNotification(); - finishCheck.CheckSignalReceived(); - DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + try + { + keyFrames.Add(1.9f, false); + } + catch (Dali::DaliException& e) + { + DALI_TEST_PRINT_ASSERT( e ); + DALI_TEST_ASSERT(e, "mType == value.GetType()", TEST_LOCATION); + } END_TEST; } -int UtcDaliAnimationRotateToRadianVector3AlphaFloat2(void) +int UtcDaliAnimationKeyFrames03P(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 ); + KeyFrames keyFrames = KeyFrames::New(); + DALI_TEST_EQUALS(keyFrames.GetType(), Property::NONE, TEST_LOCATION); - // Build the animation - float durationSeconds(1.0f); - Animation animation = Animation::New(durationSeconds); - Degree targetRotationDegrees(90.0f); - Radian targetRotationRadians(targetRotationDegrees); - float delay(0.1f); - animation.RotateTo(actor, targetRotationRadians/*Radian version*/, Vector3::YAXIS, AlphaFunctions::EaseIn, delay, durationSeconds - delay); + keyFrames.Add(0.0f, true); + keyFrames.Add(0.2f, false); + keyFrames.Add(0.4f, false); + keyFrames.Add(0.6f, true); + keyFrames.Add(0.8f, true); + keyFrames.Add(1.0f, false); - // Start the animation - animation.Play(); + DALI_TEST_EQUALS(keyFrames.GetType(), Property::BOOLEAN, TEST_LOCATION); - bool signalReceived(false); - AnimationFinishCheck finishCheck(signalReceived); - animation.FinishedSignal().Connect(&application, finishCheck); + try + { + keyFrames.Add(0.7f, Vector3(1.0f, 1.0f, 1.0f)); + } + catch (Dali::DaliException& e) + { + DALI_TEST_PRINT_ASSERT( e ); + DALI_TEST_ASSERT(e, "mType == value.GetType()", TEST_LOCATION); + } + END_TEST; +} - application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f)/* 25% progress */); +int UtcDaliAnimationKeyFrames04P(void) +{ + TestApplication application; - // We didn't expect the animation to finish yet - application.SendNotification(); - finishCheck.CheckSignalNotReceived(); - float progress = max(0.0f, 0.25f - delay) / (1.0f - delay); - DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + KeyFrames keyFrames = KeyFrames::New(); + DALI_TEST_EQUALS(keyFrames.GetType(), Property::NONE, TEST_LOCATION); - application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f)/* 50% progress */); + keyFrames.Add(0.0f, Vector2(0.0f, 0.0f)); + keyFrames.Add(0.2f, Vector2(1.0f, 1.0f)); + keyFrames.Add(0.4f, Vector2(2.0f, 2.0f)); + keyFrames.Add(0.6f, Vector2(3.0f, 5.0f)); + keyFrames.Add(0.8f, Vector2(4.0f, 3.0f)); + keyFrames.Add(1.0f, Vector2(6.0f, 2.0f)); - // We didn't expect the animation to finish yet - application.SendNotification(); - finishCheck.CheckSignalNotReceived(); - progress = max(0.0f, 0.5f - delay) / (1.0f - delay); - DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + DALI_TEST_EQUALS(keyFrames.GetType(), Property::VECTOR2, TEST_LOCATION); - application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f)/* 75% progress */); + try + { + keyFrames.Add(0.7f, Vector3(1.0f, 1.0f, 1.0f)); + } + catch (Dali::DaliException& e) + { + DALI_TEST_PRINT_ASSERT( e ); + DALI_TEST_ASSERT(e, "mType == value.GetType()", TEST_LOCATION); + } + END_TEST; +} - // We didn't expect the animation to finish yet - application.SendNotification(); - finishCheck.CheckSignalNotReceived(); - progress = max(0.0f, 0.75f - delay) / (1.0f - delay); - DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); +int UtcDaliAnimationKeyFrames05P(void) +{ + TestApplication application; - application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/); + KeyFrames keyFrames = KeyFrames::New(); + DALI_TEST_EQUALS(keyFrames.GetType(), Property::NONE, TEST_LOCATION); - // We did expect the animation to finish - application.SendNotification(); - finishCheck.CheckSignalReceived(); - DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + keyFrames.Add(0.0f, Vector3(0.0f, 4.0f, 0.0f)); + keyFrames.Add(0.2f, Vector3(1.0f, 3.0f, 1.0f)); + keyFrames.Add(0.4f, Vector3(2.0f, 2.0f, 2.0f)); + keyFrames.Add(0.6f, Vector3(3.0f, 2.0f, 5.0f)); + keyFrames.Add(0.8f, Vector3(4.0f, 4.0f, 3.0f)); + keyFrames.Add(1.0f, Vector3(6.0f, 8.0f, 2.0f)); + + DALI_TEST_EQUALS(keyFrames.GetType(), Property::VECTOR3, TEST_LOCATION); + + try + { + keyFrames.Add(0.7f, 1.0f); + } + catch (Dali::DaliException& e) + { + DALI_TEST_PRINT_ASSERT( e ); + DALI_TEST_ASSERT(e, "mType == value.GetType()", TEST_LOCATION); + } END_TEST; } -int UtcDaliAnimationRotateToQuaternionAlphaFloat2(void) +int UtcDaliAnimationKeyFrames06P(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 ); + KeyFrames keyFrames = KeyFrames::New(); + DALI_TEST_EQUALS(keyFrames.GetType(), Property::NONE, TEST_LOCATION); - // Build the animation - float durationSeconds(1.0f); - Animation animation = Animation::New(durationSeconds); - Degree targetRotationDegrees(90.0f); - Radian targetRotationRadians(targetRotationDegrees); - float delay(0.1f); - Quaternion targetRotation(targetRotationRadians, Vector3::YAXIS); - animation.RotateTo(actor, targetRotation/*Quaternion version*/, AlphaFunctions::EaseIn, delay, durationSeconds - delay); - - // Start the animation - animation.Play(); - - bool signalReceived(false); - AnimationFinishCheck finishCheck(signalReceived); - animation.FinishedSignal().Connect(&application, finishCheck); - - application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f)/* 25% progress */); - - // We didn't expect the animation to finish yet - application.SendNotification(); - finishCheck.CheckSignalNotReceived(); - float progress = max(0.0f, 0.25f - delay) / (1.0f - delay); - DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); - - application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f)/* 50% progress */); - - // We didn't expect the animation to finish yet - application.SendNotification(); - finishCheck.CheckSignalNotReceived(); - progress = max(0.0f, 0.5f - delay) / (1.0f - delay); - DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); - - application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f)/* 75% progress */); - - // We didn't expect the animation to finish yet - application.SendNotification(); - finishCheck.CheckSignalNotReceived(); - progress = max(0.0f, 0.75f - delay) / (1.0f - delay); - DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + keyFrames.Add(0.0f, Vector4(0.0f, 0.0f, 0.0f, 0.0f)); + keyFrames.Add(0.2f, Vector4(1.0f, 1.0f, 1.0f, 1.0f)); + keyFrames.Add(0.4f, Vector4(2.0f, 2.0f, 2.0f, 2.0f)); + keyFrames.Add(0.6f, Vector4(3.0f, 5.0f, 3.0f, 5.0f)); + keyFrames.Add(0.8f, Vector4(4.0f, 3.0f, 4.0f, 3.0f)); + keyFrames.Add(1.0f, Vector4(6.0f, 2.0f, 6.0f, 2.0f)); - application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/); + DALI_TEST_EQUALS(keyFrames.GetType(), Property::VECTOR4, TEST_LOCATION); - // We did expect the animation to finish - application.SendNotification(); - finishCheck.CheckSignalReceived(); - DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + try + { + keyFrames.Add(0.7f, Quaternion(Radian(1.717f), Vector3::XAXIS)); + } + catch (Dali::DaliException& e) + { + DALI_TEST_PRINT_ASSERT( e ); + DALI_TEST_ASSERT(e, "mType == value.GetType()", TEST_LOCATION); + } END_TEST; } -int UtcDaliAnimationRotate(void) +int UtcDaliAnimationKeyFrames07P(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(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(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(durationSeconds*250.0f)/* 75% progress */); + KeyFrames keyFrames = KeyFrames::New(); + DALI_TEST_EQUALS(keyFrames.GetType(), Property::NONE, TEST_LOCATION); - // 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 ); + keyFrames.Add(0.0f, Quaternion(Radian(1.717f), Vector3::XAXIS)); + keyFrames.Add(0.2f, Quaternion(Radian(2.0f), Vector3::XAXIS)); + keyFrames.Add(0.4f, Quaternion(Radian(3.0f), Vector3::ZAXIS)); + keyFrames.Add(0.6f, Quaternion(Radian(4.0f), Vector3(1.0f, 1.0f, 1.0f))); + keyFrames.Add(0.8f, AngleAxis(Degree(90), Vector3::XAXIS)); + keyFrames.Add(1.0f, Quaternion(Radian(3.0f), Vector3::YAXIS)); - application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/); + DALI_TEST_EQUALS(keyFrames.GetType(), Property::ROTATION, TEST_LOCATION); - // We did expect the animation to finish - application.SendNotification(); - finishCheck.CheckSignalReceived(); - DALI_TEST_EQUALS( actor.GetCurrentRotation(), func(1.0f, initialRotation), ROTATION_EPSILON, TEST_LOCATION ); + try + { + keyFrames.Add(0.7f, 1.1f); + } + catch (Dali::DaliException& e) + { + DALI_TEST_PRINT_ASSERT( e ); + DALI_TEST_ASSERT(e, "mType == value.GetType()", TEST_LOCATION); + } END_TEST; } -int UtcDaliAnimationScaleBy(void) +int UtcDaliAnimationAnimateBetweenActorColorAlphaP(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.GetCurrentScale(), Vector3::ONE, TEST_LOCATION ); - // Build the animation - float durationSeconds(1.0f); - Animation animation = Animation::New(durationSeconds); - Vector3 targetScale(2.0f, 2.0f, 2.0f); - Vector3 relativeScale(targetScale - Vector3::ONE); - animation.ScaleBy(actor, relativeScale.x, relativeScale.y, relativeScale.z); - - Vector3 ninetyNinePercentProgress(Vector3::ONE + relativeScale*0.99f); - - // Start the animation - animation.Play(); - - bool signalReceived(false); - AnimationFinishCheck finishCheck(signalReceived); - animation.FinishedSignal().Connect(&application, finishCheck); - - application.SendNotification(); - application.Render(static_cast(durationSeconds*990.0f)/* 99% progress */); - - // We didn't expect the animation to finish yet - application.SendNotification(); - finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetCurrentScale(), ninetyNinePercentProgress, TEST_LOCATION ); - - application.SendNotification(); - application.Render(static_cast(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/); - - // We did expect the animation to finish - application.SendNotification(); - finishCheck.CheckSignalReceived(); - DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION ); - - // Reset everything - finishCheck.Reset(); - actor.SetScale(Vector3::ONE); - application.SendNotification(); - application.Render(0); - DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION ); - - // Repeat with a different (ease-in) alpha function - animation = Animation::New(durationSeconds); - animation.ScaleBy(actor, relativeScale, AlphaFunctions::EaseIn); - animation.FinishedSignal().Connect(&application, finishCheck); - animation.Play(); - - application.SendNotification(); - application.Render(static_cast(durationSeconds*990.0f)/* 99% progress */); - - // We didn't expect the animation to finish yet - application.SendNotification(); - finishCheck.CheckSignalNotReceived(); - - // The scale should have grown less, than with a linear alpha function - Vector3 current(actor.GetCurrentScale()); - DALI_TEST_CHECK( current.x > 1.0f ); - DALI_TEST_CHECK( current.y > 1.0f ); - DALI_TEST_CHECK( current.z > 1.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(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/); - - // We did expect the animation to finish - application.SendNotification(); - finishCheck.CheckSignalReceived(); - DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION ); - - // Reset everything - finishCheck.Reset(); - actor.SetScale(Vector3::ONE); - application.SendNotification(); - application.Render(0); - DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION ); - - // Repeat with a delay - float delay = 0.5f; - animation = Animation::New(durationSeconds); - animation.ScaleBy(actor, relativeScale, AlphaFunctions::Linear, delay, durationSeconds - delay); - animation.FinishedSignal().Connect(&application, finishCheck); - animation.Play(); - - application.SendNotification(); - application.Render(static_cast(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.GetCurrentScale(), Vector3::ONE, TEST_LOCATION ); - - application.SendNotification(); - application.Render(static_cast(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/); - - // We did expect the animation to finish - application.SendNotification(); - finishCheck.CheckSignalReceived(); - DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION ); - END_TEST; -} - -int UtcDaliAnimationScaleTo(void) -{ - TestApplication application; - - Actor actor = Actor::New(); - Stage::GetCurrent().Add(actor); - DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_RED), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_BLUE), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION ); // Build the animation float durationSeconds(1.0f); Animation animation = Animation::New(durationSeconds); - Vector3 targetScale(2.0f, 2.0f, 2.0f); - animation.ScaleTo(actor, targetScale.x, targetScale.y, targetScale.z); - - Vector3 ninetyNinePercentProgress(Vector3::ONE + (targetScale - Vector3::ONE)*0.99f); - - // Start the animation - animation.Play(); - - bool signalReceived(false); - AnimationFinishCheck finishCheck(signalReceived); - animation.FinishedSignal().Connect(&application, finishCheck); - - application.SendNotification(); - application.Render(static_cast(durationSeconds*990.0f)/* 99% progress */); - - // We didn't expect the animation to finish yet - application.SendNotification(); - finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetCurrentScale(), ninetyNinePercentProgress, TEST_LOCATION ); - - application.SendNotification(); - application.Render(static_cast(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/); - - // We did expect the animation to finish - application.SendNotification(); - finishCheck.CheckSignalReceived(); - DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION ); - - // Reset everything - finishCheck.Reset(); - actor.SetScale(Vector3::ONE); - application.SendNotification(); - application.Render(0); - DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION ); - - // Repeat with a different (ease-in) alpha function - animation = Animation::New(durationSeconds); - animation.ScaleTo(actor, targetScale, AlphaFunctions::EaseIn); - animation.FinishedSignal().Connect(&application, finishCheck); - animation.Play(); - application.SendNotification(); - application.Render(static_cast(durationSeconds*990.0f)/* 99% progress */); - - // We didn't expect the animation to finish yet - application.SendNotification(); - finishCheck.CheckSignalNotReceived(); - - // The scale should have grown less, than with a linear alpha function - Vector3 current(actor.GetCurrentScale()); - DALI_TEST_CHECK( current.x > 1.0f ); - DALI_TEST_CHECK( current.y > 1.0f ); - DALI_TEST_CHECK( current.z > 1.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(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/); - - // We did expect the animation to finish - application.SendNotification(); - finishCheck.CheckSignalReceived(); - DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION ); - - // Reset everything - finishCheck.Reset(); - actor.SetScale(Vector3::ONE); - application.SendNotification(); - application.Render(0); - DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION ); - - // Repeat with a delay - float delay = 0.5f; - animation = Animation::New(durationSeconds); - animation.ScaleTo(actor, targetScale, AlphaFunctions::Linear, delay, durationSeconds - delay); - animation.FinishedSignal().Connect(&application, finishCheck); - animation.Play(); - - application.SendNotification(); - application.Render(static_cast(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.GetCurrentScale(), Vector3::ONE, TEST_LOCATION ); - - application.SendNotification(); - application.Render(static_cast(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/); - - // We did expect the animation to finish - application.SendNotification(); - finishCheck.CheckSignalReceived(); - DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION ); - END_TEST; -} - -int UtcDaliAnimationShow(void) -{ - TestApplication application; - - Actor actor = Actor::New(); - actor.SetVisible(false); - application.SendNotification(); - application.Render(0); - DALI_TEST_CHECK( !actor.IsVisible() ); - Stage::GetCurrent().Add(actor); - - // Start the animation - float durationSeconds(10.0f); - Animation animation = Animation::New(durationSeconds); - animation.Show(actor, durationSeconds*0.5f); - animation.Play(); - - bool signalReceived(false); - AnimationFinishCheck finishCheck(signalReceived); - animation.FinishedSignal().Connect(&application, finishCheck); - - application.SendNotification(); - application.Render(static_cast(durationSeconds*490.0f)); - - // We didn't expect the animation to finish yet - application.SendNotification(); - finishCheck.CheckSignalNotReceived(); - DALI_TEST_CHECK( !actor.IsVisible() ); - - application.SendNotification(); - application.Render(static_cast(durationSeconds*10.0f)/*Should be shown now*/); - - // We didn't expect the animation to finish yet - application.SendNotification(); - finishCheck.CheckSignalNotReceived(); - DALI_TEST_CHECK( actor.IsVisible() ); - - application.SendNotification(); - application.Render(static_cast(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/); - - // We did expect the animation to finish - application.SendNotification(); - finishCheck.CheckSignalReceived(); - DALI_TEST_CHECK( actor.IsVisible() ); - END_TEST; -} - -int UtcDaliAnimationHide(void) -{ - TestApplication application; - - Actor actor = Actor::New(); - DALI_TEST_CHECK( actor.IsVisible() ); - Stage::GetCurrent().Add(actor); - - // Start the animation - float durationSeconds(10.0f); - Animation animation = Animation::New(durationSeconds); - animation.Hide(actor, durationSeconds*0.5f); - animation.Play(); - - bool signalReceived(false); - AnimationFinishCheck finishCheck(signalReceived); - animation.FinishedSignal().Connect(&application, finishCheck); - - application.SendNotification(); - application.Render(static_cast(durationSeconds*490.0f)); - - // We didn't expect the animation to finish yet - application.SendNotification(); - finishCheck.CheckSignalNotReceived(); - DALI_TEST_CHECK( actor.IsVisible() ); - - application.SendNotification(); - application.Render(static_cast(durationSeconds*10.0f)/*Should be hidden now*/); - - // We didn't expect the animation to finish yet - application.SendNotification(); - finishCheck.CheckSignalNotReceived(); - DALI_TEST_CHECK( !actor.IsVisible() ); - - application.SendNotification(); - application.Render(static_cast(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/); - - // We did expect the animation to finish - application.SendNotification(); - finishCheck.CheckSignalReceived(); - DALI_TEST_CHECK( !actor.IsVisible() ); - END_TEST; -} - -int UtcDaliAnimationShowHideAtEnd(void) -{ - // Test that show/hide delay can be the same as animation duration - // i.e. to show/hide at the end of the animation - - TestApplication application; - - Actor actor = Actor::New(); - DALI_TEST_CHECK( actor.IsVisible() ); - Stage::GetCurrent().Add(actor); - - // Start Hide animation - float durationSeconds(10.0f); - Animation animation = Animation::New(durationSeconds); - animation.Hide(actor, durationSeconds/*Hide at end*/); - animation.Play(); - - bool signalReceived(false); - AnimationFinishCheck finishCheck(signalReceived); - animation.FinishedSignal().Connect(&application, finishCheck); - - application.SendNotification(); - application.Render(static_cast(durationSeconds*1000.0f) + 1u/*just beyond the animation duration*/); - - // We did expect the animation to finish - application.SendNotification(); - finishCheck.CheckSignalReceived(); - DALI_TEST_CHECK( !actor.IsVisible() ); - - // Start Show animation - animation = Animation::New(durationSeconds); - animation.Show(actor, durationSeconds/*Show at end*/); - animation.FinishedSignal().Connect(&application, finishCheck); - animation.Play(); - - application.SendNotification(); - application.Render(static_cast(durationSeconds*1000.0f) + 1u/*just beyond the animation duration*/); - - // We did expect the animation to finish - application.SendNotification(); - finishCheck.CheckSignalReceived(); - DALI_TEST_CHECK( actor.IsVisible() ); - END_TEST; -} - -int UtcDaliAnimationOpacityBy(void) -{ - TestApplication application; - Actor actor = Actor::New(); - float startingOpacity(0.5f); - actor.SetOpacity(startingOpacity); - application.SendNotification(); - application.Render(0); - DALI_TEST_EQUALS( actor.GetCurrentOpacity(), startingOpacity, TEST_LOCATION ); - Stage::GetCurrent().Add(actor); - - // Build the animation - float durationSeconds(1.0f); - Animation animation = Animation::New(durationSeconds); - float relativeOpacity(-0.5f); // target of zero - animation.OpacityBy(actor, relativeOpacity); + KeyFrames keyFrames = KeyFrames::New(); + 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); - float seventyFivePercentProgress((1.0f - 0.75f) * startingOpacity); + animation.AnimateBetween( Property(actor, Actor::Property::COLOR_ALPHA), keyFrames ); // Start the animation animation.Play(); @@ -8348,111 +8259,94 @@ int UtcDaliAnimationOpacityBy(void) bool signalReceived(false); AnimationFinishCheck finishCheck(signalReceived); animation.FinishedSignal().Connect(&application, finishCheck); - - application.SendNotification(); - application.Render(static_cast(durationSeconds*750.0f)/* 75% progress */); - - // We didn't expect the animation to finish yet - application.SendNotification(); - finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetCurrentOpacity(), seventyFivePercentProgress, TEST_LOCATION ); - - application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/); - - // We did expect the animation to finish - application.SendNotification(); - finishCheck.CheckSignalReceived(); - DALI_TEST_EQUALS( actor.GetCurrentOpacity(), startingOpacity+relativeOpacity, TEST_LOCATION ); - - // Reset everything - finishCheck.Reset(); - actor.SetOpacity(startingOpacity); application.SendNotification(); application.Render(0); - DALI_TEST_EQUALS( actor.GetCurrentOpacity(), startingOpacity, TEST_LOCATION ); - - // Repeat with a different (ease-in) alpha function - animation = Animation::New(durationSeconds); - animation.OpacityBy(actor, relativeOpacity, AlphaFunctions::EaseIn); - animation.FinishedSignal().Connect(&application, finishCheck); - animation.Play(); - - application.SendNotification(); - application.Render(static_cast(durationSeconds*750.0f)/* 75% progress */); - - // We didn't expect the animation to finish yet application.SendNotification(); finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.1f, TEST_LOCATION ); - // The opacity should reduce less, than with a linear alpha function - float current(actor.GetCurrentOpacity()); - DALI_TEST_CHECK( current < 1.0f ); - DALI_TEST_CHECK( current > seventyFivePercentProgress ); - - application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/); - - // We did expect the animation to finish - application.SendNotification(); - finishCheck.CheckSignalReceived(); - DALI_TEST_EQUALS( actor.GetCurrentOpacity(), startingOpacity+relativeOpacity, TEST_LOCATION ); - - // Reset everything - finishCheck.Reset(); - actor.SetOpacity(startingOpacity); - application.SendNotification(); - application.Render(0); - DALI_TEST_EQUALS( actor.GetCurrentOpacity(), startingOpacity, TEST_LOCATION ); - - // Repeat with a delay - float delay = 0.5f; - animation = Animation::New(durationSeconds); - animation.OpacityBy(actor, relativeOpacity, AlphaFunctions::Linear, delay, durationSeconds - delay); - animation.FinishedSignal().Connect(&application, finishCheck); - animation.Play(); - + application.Render(static_cast(durationSeconds*100.0f)/* 10% progress */); application.SendNotification(); - application.Render(static_cast(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_RED), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_BLUE), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_ALPHA), 0.3f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.3f, 0.01f, TEST_LOCATION ); - // We didn't expect the animation to finish yet + application.Render(static_cast(durationSeconds*200.0f)/* 30% progress */); application.SendNotification(); - finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetCurrentOpacity(), startingOpacity, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_RED), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_BLUE), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_ALPHA), 0.25f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.25f, 0.01f, TEST_LOCATION ); + application.Render(static_cast(durationSeconds*100.0f)/* 40% progress */); application.SendNotification(); - application.Render(static_cast(durationSeconds*500.0f*0.75)/* 7/8 animation progress, 3/4 animator progress */); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_RED), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_BLUE), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_ALPHA), 0.0f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.0f, 0.01f, TEST_LOCATION ); - // We didn't expect the animation to finish yet + application.Render(static_cast(durationSeconds*400.0f)/* 80% progress */); application.SendNotification(); - finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetCurrentOpacity(), seventyFivePercentProgress, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_RED), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_BLUE), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_ALPHA), 0.7f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.7f, 0.01f, TEST_LOCATION ); + application.Render(static_cast(durationSeconds*100.0f)/* 90% progress */); application.SendNotification(); - application.Render(static_cast(durationSeconds*500.0f*0.25) + 1u/*just beyond the animation duration*/); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_RED), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_BLUE), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_ALPHA), 0.8f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.8f, 0.01f, TEST_LOCATION ); - // We did expect the animation to finish + application.Render(static_cast(durationSeconds*100.0f)+1/* 100% progress */); application.SendNotification(); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_RED), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_BLUE), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::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(); - DALI_TEST_EQUALS( actor.GetCurrentOpacity(), startingOpacity+relativeOpacity, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationOpacityTo(void) +int UtcDaliAnimationAnimateBetweenActorColorAlphaCubicP(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.GetCurrentOpacity(), 1.0f, TEST_LOCATION ); + + DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_RED), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_BLUE), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION ); // Build the animation float durationSeconds(1.0f); Animation animation = Animation::New(durationSeconds); - float targetOpacity(0.0f); - animation.OpacityTo(actor, targetOpacity); - float ninetyNinePercentProgress(0.01f); + KeyFrames keyFrames = KeyFrames::New(); + 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::Property::COLOR_ALPHA), keyFrames, Animation::Cubic ); // Start the animation animation.Play(); @@ -8460,108 +8354,91 @@ int UtcDaliAnimationOpacityTo(void) bool signalReceived(false); AnimationFinishCheck finishCheck(signalReceived); animation.FinishedSignal().Connect(&application, finishCheck); - - application.SendNotification(); - application.Render(static_cast(durationSeconds*990.0f)/* 99% progress */); - - // We didn't expect the animation to finish yet - application.SendNotification(); - finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetCurrentOpacity(), ninetyNinePercentProgress, 0.001f, TEST_LOCATION ); - - application.SendNotification(); - application.Render(static_cast(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/); - - // We did expect the animation to finish - application.SendNotification(); - finishCheck.CheckSignalReceived(); - DALI_TEST_EQUALS( actor.GetCurrentOpacity(), targetOpacity, TEST_LOCATION ); - - // Reset everything - finishCheck.Reset(); - actor.SetOpacity(1.0f); application.SendNotification(); application.Render(0); - DALI_TEST_EQUALS( actor.GetCurrentOpacity(), 1.0f, TEST_LOCATION ); - - // Repeat with a different (ease-in) alpha function - animation = Animation::New(durationSeconds); - animation.OpacityTo(actor, targetOpacity, AlphaFunctions::EaseIn); - animation.FinishedSignal().Connect(&application, finishCheck); - animation.Play(); - - application.SendNotification(); - application.Render(static_cast(durationSeconds*990.0f)/* 99% progress */); - - // We didn't expect the animation to finish yet application.SendNotification(); finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.1f, TEST_LOCATION ); - // The opacity should reduce less, than with a linear alpha function - float current(actor.GetCurrentOpacity()); - DALI_TEST_CHECK( current < 1.0f ); - DALI_TEST_CHECK( current > ninetyNinePercentProgress ); - + application.Render(static_cast(durationSeconds*100.0f)/* 10% progress */); application.SendNotification(); - application.Render(static_cast(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_RED), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_BLUE), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_ALPHA), 0.36f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.36f, 0.01f, TEST_LOCATION ); - // We did expect the animation to finish + application.Render(static_cast(durationSeconds*200.0f)/* 30% progress */); application.SendNotification(); - finishCheck.CheckSignalReceived(); - DALI_TEST_EQUALS( actor.GetCurrentOpacity(), targetOpacity, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_RED), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_BLUE), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_ALPHA), 0.21f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.21f, 0.01f, TEST_LOCATION ); - // Reset everything - finishCheck.Reset(); - actor.SetOpacity(1.0f); + application.Render(static_cast(durationSeconds*100.0f)/* 40% progress */); application.SendNotification(); - application.Render(0); - DALI_TEST_EQUALS( actor.GetCurrentOpacity(), 1.0f, TEST_LOCATION ); - - // Repeat with a delay - float delay = 0.5f; - animation = Animation::New(durationSeconds); - animation.OpacityTo(actor, targetOpacity, AlphaFunctions::Linear, delay, durationSeconds - delay); - animation.FinishedSignal().Connect(&application, finishCheck); - animation.Play(); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_RED), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_BLUE), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_ALPHA), 0.0f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.0f, 0.01f, TEST_LOCATION ); + application.Render(static_cast(durationSeconds*400.0f)/* 80% progress */); application.SendNotification(); - application.Render(static_cast(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_RED), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_BLUE), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_ALPHA), 0.7f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.7f, 0.01f, TEST_LOCATION ); - // We didn't expect the animation to finish yet + application.Render(static_cast(durationSeconds*100.0f)/* 90% progress */); application.SendNotification(); - finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetCurrentOpacity(), 1.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_RED), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_BLUE), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_ALPHA), 0.76f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.76f, 0.01f, TEST_LOCATION ); + application.Render(static_cast(durationSeconds*100.0f)+1/* 100% progress */); application.SendNotification(); - application.Render(static_cast(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_RED), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_BLUE), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::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 - application.SendNotification(); + finishCheck.CheckSignalReceived(); - DALI_TEST_EQUALS( actor.GetCurrentOpacity(), targetOpacity, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationColorBy(void) +int UtcDaliAnimationAnimateBetweenActorColorP(void) { TestApplication application; + float startValue(1.0f); Actor actor = Actor::New(); - actor.SetColor(Color::BLACK); - application.SendNotification(); - application.Render(0); - DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::BLACK, TEST_LOCATION ); + 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(Actor::Property::COLOR_RED), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_BLUE), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION ); + // Build the animation float durationSeconds(1.0f); Animation animation = Animation::New(durationSeconds); - Vector4 targetColor(Color::GREEN); - Vector4 relativeColor(Color::GREEN); // Note the alpha is automatically clamped <= 1.0f in world color - animation.ColorBy(actor, relativeColor); - Vector4 tenPercentProgress(Vector4(0.0f, 0.1f, 0.0f, 1.0f)); - Vector4 twentyPercentProgress(Vector4(0.0f, 0.2f, 0.0f, 1.0f)); + 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::Property::COLOR), keyFrames ); // Start the animation animation.Play(); @@ -8569,115 +8446,150 @@ int UtcDaliAnimationColorBy(void) bool signalReceived(false); AnimationFinishCheck finishCheck(signalReceived); animation.FinishedSignal().Connect(&application, finishCheck); - application.SendNotification(); - application.Render(static_cast(durationSeconds*100.0f)/* 10% progress */); - - // We didn't expect the animation to finish yet + application.Render(0); application.SendNotification(); finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetCurrentWorldColor(), tenPercentProgress, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_RED), 0.1f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_GREEN), 0.2f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_BLUE), 0.3f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_ALPHA), 0.4f, 0.01f, TEST_LOCATION ); + application.Render(static_cast(durationSeconds*250.0f)/* 25% progress */); application.SendNotification(); - application.Render(static_cast(durationSeconds*900.0f) + 1u/*just beyond the animation duration*/); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_RED), 0.5f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_GREEN), 0.5f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_BLUE), 0.5f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_ALPHA), 0.5f, 0.01f, TEST_LOCATION ); - // We did expect the animation to finish + application.Render(static_cast(durationSeconds*250.0f)/* 50% progress */); application.SendNotification(); - finishCheck.CheckSignalReceived(); - DALI_TEST_EQUALS( actor.GetCurrentWorldColor(), targetColor, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_RED), 0.9f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_GREEN), 0.8f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_BLUE), 0.7f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_ALPHA), 0.6f, 0.01f, TEST_LOCATION ); - // Reset everything - finishCheck.Reset(); - actor.SetColor(Color::BLACK); + application.Render(static_cast(durationSeconds*250.0f)/* 75% progress */); application.SendNotification(); - application.Render(0); - DALI_TEST_EQUALS( actor.GetCurrentWorldColor(), Color::BLACK, TEST_LOCATION ); - - // Repeat with a different (ease-in) alpha function - animation = Animation::New(durationSeconds); - animation.ColorBy(actor, relativeColor, AlphaFunctions::EaseIn); - animation.FinishedSignal().Connect(&application, finishCheck); - animation.Play(); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_RED), 0.95f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_GREEN), 0.90f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_BLUE), 0.85f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_ALPHA), 0.80f, 0.01f, TEST_LOCATION ); + application.Render(static_cast(durationSeconds*250.0f)+1/* 100% progress */); application.SendNotification(); - application.Render(static_cast(durationSeconds*100.0f)/* 10% progress */); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_RED), 1.0f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_GREEN), 1.0f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_BLUE), 1.0f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_ALPHA), 1.0f, 0.01f, TEST_LOCATION ); - // We didn't expect the animation to finish yet - application.SendNotification(); - finishCheck.CheckSignalNotReceived(); + // We did expect the animation to finish - // The color should have changed less, than with a linear alpha function - Vector4 current(actor.GetCurrentWorldColor()); - DALI_TEST_CHECK( current.x == 0.0f ); // doesn't change - DALI_TEST_CHECK( current.y > 0.0f ); - DALI_TEST_CHECK( current.y < tenPercentProgress.y ); - DALI_TEST_CHECK( current.z == 0.0f ); // doesn't change - DALI_TEST_CHECK( current.w == 1.0f ); // doesn't change + finishCheck.CheckSignalReceived(); + END_TEST; +} - application.SendNotification(); - application.Render(static_cast(durationSeconds*900.0f) + 1u/*just beyond the animation duration*/); +int UtcDaliAnimationAnimateBetweenActorColorCubicP(void) +{ + TestApplication application; - // We did expect the animation to finish - application.SendNotification(); - finishCheck.CheckSignalReceived(); - DALI_TEST_EQUALS( actor.GetCurrentWorldColor(), targetColor, TEST_LOCATION ); + float startValue(1.0f); + Actor actor = Actor::New(); + actor.SetColor(Vector4(startValue, startValue, startValue, startValue)); + Stage::GetCurrent().Add(actor); - // Reset everything - finishCheck.Reset(); - actor.SetColor(Color::BLACK); - application.SendNotification(); - application.Render(0); - DALI_TEST_EQUALS( actor.GetCurrentWorldColor(), Color::BLACK, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_RED), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_BLUE), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION ); - // Repeat with a shorter animator duration - float animatorDuration = 0.5f; - animation = Animation::New(durationSeconds); - animation.ColorBy(actor, relativeColor, AlphaFunctions::Linear, 0, animatorDuration); - animation.FinishedSignal().Connect(&application, finishCheck); + // 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::Property::COLOR), 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(durationSeconds*100.0f)/* 10% animation progress, 20% animator progress */); - - // We didn't expect the animation to finish yet + application.Render(0); application.SendNotification(); finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetCurrentWorldColor(), twentyPercentProgress, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_RED), 0.1f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_GREEN), 0.2f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_BLUE), 0.3f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_ALPHA), 0.4f, 0.01f, TEST_LOCATION ); + application.Render(static_cast(durationSeconds*250.0f)/* 25% progress */); application.SendNotification(); - application.Render(static_cast(durationSeconds*400.0f)/* 50% animation progress, 100% animator progress */); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_RED), 0.55f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_GREEN), 0.525f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_BLUE), 0.506f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_ALPHA), 0.4875f, 0.01f, TEST_LOCATION ); - // We didn't expect the animation to finish yet + application.Render(static_cast(durationSeconds*250.0f)/* 50% progress */); application.SendNotification(); - finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetCurrentWorldColor(), targetColor, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_RED), 0.9f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_GREEN), 0.8f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_BLUE), 0.7f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_ALPHA), 0.6f, 0.01f, TEST_LOCATION ); + application.Render(static_cast(durationSeconds*250.0f)/* 75% progress */); application.SendNotification(); - application.Render(static_cast(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_RED), 0.99375f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_GREEN), 0.925f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_BLUE), 0.85625f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_ALPHA), 0.7875f, 0.01f, TEST_LOCATION ); - // We did expect the animation to finish + application.Render(static_cast(durationSeconds*250.0f)+1/* 100% progress */); application.SendNotification(); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_RED), 1.0f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_GREEN), 1.0f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_BLUE), 1.0f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_ALPHA), 1.0f, 0.01f, TEST_LOCATION ); + + // We did expect the animation to finish + finishCheck.CheckSignalReceived(); - DALI_TEST_EQUALS( actor.GetCurrentWorldColor(), targetColor, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationColorTo(void) +int UtcDaliAnimationAnimateBetweenActorVisibleP(void) { TestApplication application; Actor actor = Actor::New(); + AngleAxis aa(Degree(90), Vector3::XAXIS); + actor.SetOrientation(aa.angle, aa.axis); Stage::GetCurrent().Add(actor); - DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION ); + + 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); - Vector4 targetColor(Color::RED); - animation.ColorTo(actor, targetColor); - Vector4 tenPercentProgress(Vector4(1.0f, 0.9f, 0.9f, 1.0f)); - Vector4 twentyPercentProgress(Vector4(1.0f, 0.8f, 0.8f, 1.0f)); + 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); + + animation.AnimateBetween( Property(actor, Actor::Property::VISIBLE), keyFrames ); // Start the animation animation.Play(); @@ -8685,115 +8597,131 @@ int UtcDaliAnimationColorTo(void) bool signalReceived(false); AnimationFinishCheck finishCheck(signalReceived); animation.FinishedSignal().Connect(&application, finishCheck); - application.SendNotification(); - application.Render(static_cast(durationSeconds*100.0f)/* 10% progress */); - - // We didn't expect the animation to finish yet application.SendNotification(); - finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetCurrentColor(), tenPercentProgress, TEST_LOCATION ); - + application.Render(static_cast(durationSeconds*500.0f)); application.SendNotification(); - application.Render(static_cast(durationSeconds*900.0f) + 1u/*just beyond the animation duration*/); - - // We did expect the animation to finish + application.Render(static_cast(durationSeconds*500.0f)+1); application.SendNotification(); + + DALI_TEST_EQUALS( actor.IsVisible(), true, TEST_LOCATION); finishCheck.CheckSignalReceived(); - DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliAnimationAnimateBetweenActorVisibleCubicP(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + AngleAxis aa(Degree(90), Vector3::XAXIS); + actor.SetOrientation(aa.angle, aa.axis); + Stage::GetCurrent().Add(actor); - // Reset everything - finishCheck.Reset(); - actor.SetColor(Color::WHITE); application.SendNotification(); application.Render(0); - DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION ); - // Repeat with a different (ease-in) alpha function - animation = Animation::New(durationSeconds); - animation.ColorTo(actor, targetColor, AlphaFunctions::EaseIn); - animation.FinishedSignal().Connect(&application, finishCheck); - animation.Play(); + DALI_TEST_EQUALS( actor.IsVisible(), true, TEST_LOCATION ); - application.SendNotification(); - application.Render(static_cast(durationSeconds*100.0f)/* 10% progress */); + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); - // We didn't expect the animation to finish yet - application.SendNotification(); - finishCheck.CheckSignalNotReceived(); + 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); - // The color should have changed less, than with a linear alpha function - Vector4 current(actor.GetCurrentColor()); - DALI_TEST_CHECK( current.x == 1.0f ); // doesn't change - DALI_TEST_CHECK( current.y < 1.0f ); - DALI_TEST_CHECK( current.y > tenPercentProgress.y ); - DALI_TEST_CHECK( current.z < 1.0f ); - DALI_TEST_CHECK( current.z > tenPercentProgress.z ); - DALI_TEST_CHECK( current.w == 1.0f ); // doesn't change + //Cubic interpolation for boolean values should be ignored + animation.AnimateBetween( Property(actor, Actor::Property::VISIBLE), 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(durationSeconds*900.0f) + 1u/*just beyond the animation duration*/); - - // We did expect the animation to finish application.SendNotification(); + application.Render(static_cast(durationSeconds*500.0f)); + application.SendNotification(); + application.Render(static_cast(durationSeconds*500.0f)+1); + application.SendNotification(); + + DALI_TEST_EQUALS( actor.IsVisible(), true, TEST_LOCATION); finishCheck.CheckSignalReceived(); - DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliAnimationAnimateBetweenActorOrientation01P(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + AngleAxis aa(Degree(90), Vector3::XAXIS); + actor.SetOrientation(aa.angle, aa.axis); + Stage::GetCurrent().Add(actor); - // Reset everything - finishCheck.Reset(); - actor.SetColor(Color::WHITE); application.SendNotification(); application.Render(0); - DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION ); + Quaternion start(Radian(aa.angle), aa.axis); + DALI_TEST_EQUALS( actor.GetCurrentOrientation(), start, 0.001f, TEST_LOCATION ); - // 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); + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + + KeyFrames keyFrames = KeyFrames::New(); + keyFrames.Add(0.0f, AngleAxis(Degree(60), Vector3::ZAXIS)); + + animation.AnimateBetween( Property(actor, Actor::Property::ORIENTATION), keyFrames ); + + // Start the animation animation.Play(); + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); application.SendNotification(); - application.Render(static_cast(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.Render(static_cast(durationSeconds*500.0f)); application.SendNotification(); - application.Render(static_cast(durationSeconds*400.0f)/* 50% animation progress, 100% animator progress */); - - // We didn't expect the animation to finish yet + application.Render(static_cast(durationSeconds*500.0f)+1); application.SendNotification(); - finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION ); - application.SendNotification(); - application.Render(static_cast(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/); + Quaternion check( Radian(Degree(60)), Vector3::ZAXIS ); - // We did expect the animation to finish - application.SendNotification(); + DALI_TEST_EQUALS( actor.GetCurrentOrientation(), check, 0.001f, TEST_LOCATION ); finishCheck.CheckSignalReceived(); - DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationResize(void) +int UtcDaliAnimationAnimateBetweenActorOrientation02P(void) { TestApplication application; Actor actor = Actor::New(); + AngleAxis aa(Degree(90), Vector3::XAXIS); + actor.SetOrientation(aa.angle, aa.axis); + application.SendNotification(); + application.Render(0); Stage::GetCurrent().Add(actor); - DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION ); + + Quaternion start(Radian(aa.angle), aa.axis); + DALI_TEST_EQUALS( actor.GetCurrentOrientation(), start, 0.001f, 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); + 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)); + + animation.AnimateBetween( Property(actor, Actor::Property::ORIENTATION), keyFrames ); // Start the animation animation.Play(); @@ -8801,104 +8729,109 @@ int UtcDaliAnimationResize(void) bool signalReceived(false); AnimationFinishCheck finishCheck(signalReceived); animation.FinishedSignal().Connect(&application, finishCheck); - application.SendNotification(); - application.Render(static_cast(durationSeconds*990.0f)/* 99% progress */); - - // We didn't expect the animation to finish yet + application.Render(0); application.SendNotification(); finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetCurrentSize(), ninetyNinePercentProgress, TEST_LOCATION ); - - application.SendNotification(); - application.Render(static_cast(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 ); + Quaternion check(Radian(Degree(60)), Vector3::XAXIS); + DALI_TEST_EQUALS( actor.GetCurrentOrientation(), check, 0.001f, TEST_LOCATION ); - // Reset everything - finishCheck.Reset(); - actor.SetSize(Vector3::ZERO); + application.Render(static_cast(durationSeconds*250.0f)/* 25% progress */); 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(); + check = Quaternion( Radian(Degree(90)), Vector3::XAXIS ); + DALI_TEST_EQUALS( actor.GetCurrentOrientation(), check, 0.001f, TEST_LOCATION ); + application.Render(static_cast(durationSeconds*250.0f)/* 50% progress */); application.SendNotification(); - application.Render(static_cast(durationSeconds*990.0f)/* 99% progress */); + check = Quaternion( Radian(Degree(120)), Vector3::XAXIS ); + DALI_TEST_EQUALS( actor.GetCurrentOrientation(), check, 0.001f, TEST_LOCATION ); - // We didn't expect the animation to finish yet + application.Render(static_cast(durationSeconds*250.0f)/* 75% progress */); 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 ); + check = Quaternion( Radian(Degree(101.5)), Vector3(0.5f, 0.5f, 0.0f) ); + DALI_TEST_EQUALS( actor.GetCurrentOrientation(), check, 0.001f, TEST_LOCATION ); + application.Render(static_cast(durationSeconds*250.0f)+1/* 100% progress */); application.SendNotification(); - application.Render(static_cast(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/); + check = Quaternion( Radian(Degree(120)), Vector3::YAXIS ); + DALI_TEST_EQUALS( actor.GetCurrentOrientation(), check, 0.001f, TEST_LOCATION ); // We did expect the animation to finish - application.SendNotification(); + finishCheck.CheckSignalReceived(); - DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliAnimationAnimateBetweenActorOrientation01CubicP(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + AngleAxis aa(Degree(90), Vector3::XAXIS); + actor.SetOrientation(aa.angle, aa.axis); + Stage::GetCurrent().Add(actor); - // Reset everything - finishCheck.Reset(); - actor.SetSize(Vector3::ZERO); application.SendNotification(); application.Render(0); - DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION ); + Quaternion start(Radian(aa.angle), aa.axis); + DALI_TEST_EQUALS( actor.GetCurrentOrientation(), start, 0.001f, 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); + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + + 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::Property::ORIENTATION), 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(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.Render(static_cast(durationSeconds*500.0f)); application.SendNotification(); - application.Render(static_cast(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/); - - // We did expect the animation to finish + application.Render(static_cast(durationSeconds*500.0f)+1); application.SendNotification(); + + Quaternion check( Radian(Degree(60)), Vector3::ZAXIS ); + + DALI_TEST_EQUALS( actor.GetCurrentOrientation(), check, 0.001f, TEST_LOCATION ); finishCheck.CheckSignalReceived(); - DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationAnimateBool(void) +int UtcDaliAnimationAnimateBetweenActorOrientation02CubicP(void) { TestApplication application; Actor actor = Actor::New(); - DALI_TEST_EQUALS( actor.IsVisible(), true, TEST_LOCATION ); + AngleAxis aa(Degree(90), Vector3::XAXIS); + actor.SetOrientation(aa.angle, aa.axis); + application.SendNotification(); + application.Render(0); Stage::GetCurrent().Add(actor); + Quaternion start(Radian(aa.angle), aa.axis); + DALI_TEST_EQUALS( actor.GetCurrentOrientation(), start, 0.001f, TEST_LOCATION ); + // Build the animation - float durationSeconds(10.0f); + float durationSeconds(1.0f); Animation animation = Animation::New(durationSeconds); - animation.Animate( Property(actor, Actor::VISIBLE), ReturnFalseAfterProgressOne, TimePeriod(durationSeconds*0.25f/*delay*/, durationSeconds*0.1f) ); + + 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::Property::ORIENTATION), keyFrames, Animation::Cubic ); // Start the animation animation.Play(); @@ -8906,55 +8839,65 @@ int UtcDaliAnimationAnimateBool(void) bool signalReceived(false); AnimationFinishCheck finishCheck(signalReceived); animation.FinishedSignal().Connect(&application, finishCheck); - application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f)/* 25% progress */); - - // We didn't expect the animation to finish yet + application.Render(0); application.SendNotification(); finishCheck.CheckSignalNotReceived(); - // Should still be visible - DALI_TEST_EQUALS( actor.IsVisible(), true, TEST_LOCATION ); + Quaternion check(Radian(Degree(60)), Vector3::XAXIS); + DALI_TEST_EQUALS( actor.GetCurrentOrientation(), check, 0.001f, TEST_LOCATION ); + application.Render(static_cast(durationSeconds*250.0f)/* 25% progress */); application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f)/* 50% progress */); + check = Quaternion( Radian(Degree(90)), Vector3::XAXIS ); + DALI_TEST_EQUALS( actor.GetCurrentOrientation(), check, 0.001f, TEST_LOCATION ); - // We didn't expect the animation to finish yet + application.Render(static_cast(durationSeconds*250.0f)/* 50% progress */); application.SendNotification(); - finishCheck.CheckSignalNotReceived(); + check = Quaternion( Radian(Degree(120)), Vector3::XAXIS ); + DALI_TEST_EQUALS( actor.GetCurrentOrientation(), check, 0.001f, TEST_LOCATION ); - // Now animate functor should have hidden the actor - DALI_TEST_EQUALS( actor.IsVisible(), false, TEST_LOCATION ); + application.Render(static_cast(durationSeconds*250.0f)/* 75% progress */); + application.SendNotification(); + check = Quaternion( Radian(Degree(101.5)), Vector3(0.5f, 0.5f, 0.0f ) ); + DALI_TEST_EQUALS( actor.GetCurrentOrientation(), check, 0.001f, TEST_LOCATION ); + application.Render(static_cast(durationSeconds*250.0f)+1/* 100% progress */); application.SendNotification(); - application.Render(static_cast(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/); + check = Quaternion( Radian(Degree(120)), Vector3::YAXIS ); + DALI_TEST_EQUALS( actor.GetCurrentOrientation(), check, 0.001f, TEST_LOCATION ); // We did expect the animation to finish - application.SendNotification(); + finishCheck.CheckSignalReceived(); - DALI_TEST_EQUALS( actor.IsVisible(), false, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationAnimateFloat(void) +int UtcDaliAnimationAnimateBetweenActorColorAlphaFunctionP(void) { TestApplication application; + float startValue(1.0f); Actor actor = Actor::New(); + actor.SetColor(Vector4(startValue, startValue, startValue, startValue)); 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(index), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_RED), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_BLUE), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_ALPHA), startValue, 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( Property(actor, index), func ); + + 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::Property::COLOR), keyFrames, AlphaFunction::LINEAR ); // Start the animation animation.Play(); @@ -8962,59 +8905,74 @@ int UtcDaliAnimationAnimateFloat(void) bool signalReceived(false); AnimationFinishCheck finishCheck(signalReceived); animation.FinishedSignal().Connect(&application, finishCheck); - application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f)/* 25% progress */); - - // We didn't expect the animation to finish yet + application.Render(0); application.SendNotification(); finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetProperty(index), 75.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_RED), 0.1f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_GREEN), 0.2f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_BLUE), 0.3f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_ALPHA), 0.4f, 0.01f, TEST_LOCATION ); + application.Render(static_cast(durationSeconds*250.0f)/* 25% progress */); application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f)/* 50% progress */); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_RED), 0.5f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_GREEN), 0.5f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_BLUE), 0.5f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_ALPHA), 0.5f, 0.01f, TEST_LOCATION ); - // We didn't expect the animation to finish yet + application.Render(static_cast(durationSeconds*250.0f)/* 50% progress */); application.SendNotification(); - finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetProperty(index), 50.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_RED), 0.9f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_GREEN), 0.8f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_BLUE), 0.7f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_ALPHA), 0.6f, 0.01f, TEST_LOCATION ); - application.SendNotification(); application.Render(static_cast(durationSeconds*250.0f)/* 75% progress */); - - // We didn't expect the animation to finish yet application.SendNotification(); - finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetProperty(index), 25.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_RED), 0.95f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_GREEN), 0.90f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_BLUE), 0.85f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_ALPHA), 0.80f, 0.01f, TEST_LOCATION ); + application.Render(static_cast(durationSeconds*250.0f)+1/* 100% progress */); application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_RED), 1.0f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_GREEN), 1.0f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_BLUE), 1.0f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_ALPHA), 1.0f, 0.01f, TEST_LOCATION ); // We did expect the animation to finish - application.SendNotification(); + finishCheck.CheckSignalReceived(); - DALI_TEST_EQUALS( actor.GetProperty(index), targetPosition, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationAnimateInteger(void) +int UtcDaliAnimationAnimateBetweenActorColorAlphaFunctionCubicP(void) { TestApplication application; + float startValue(1.0f); Actor actor = Actor::New(); + actor.SetColor(Vector4(startValue, startValue, startValue, startValue)); Stage::GetCurrent().Add(actor); - // Register an integer property - int startValue(10); - Property::Index index = actor.RegisterProperty( "test-property", startValue ); - DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_RED), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_BLUE), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION ); // Build the animation - float durationSeconds(10.0f); + float durationSeconds(1.0f); Animation animation = Animation::New(durationSeconds); - int targetPosition(0); - AnimateIntegerTestFunctor func( 100, targetPosition ); - animation.Animate( Property(actor, index), func ); + + 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::Property::COLOR), keyFrames, AlphaFunction::LINEAR, Animation::Cubic ); // Start the animation animation.Play(); @@ -9022,59 +8980,75 @@ int UtcDaliAnimationAnimateInteger(void) bool signalReceived(false); AnimationFinishCheck finishCheck(signalReceived); animation.FinishedSignal().Connect(&application, finishCheck); - application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f)/* 25% progress */); - - // We didn't expect the animation to finish yet + application.Render(0); application.SendNotification(); finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetProperty(index), 75, TEST_LOCATION ); - - application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f)/* 50% progress */); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_RED), 0.1f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_GREEN), 0.2f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_BLUE), 0.3f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_ALPHA), 0.4f, 0.01f, TEST_LOCATION ); - // We didn't expect the animation to finish yet + application.Render(static_cast(durationSeconds*250.0f)/* 25% progress */); application.SendNotification(); - finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetProperty(index), 50, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_RED), 0.55f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_GREEN), 0.525f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_BLUE), 0.506f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_ALPHA), 0.4875f, 0.01f, TEST_LOCATION ); + application.Render(static_cast(durationSeconds*250.0f)/* 50% progress */); application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f)/* 75% progress */); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_RED), 0.9f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_GREEN), 0.8f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_BLUE), 0.7f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_ALPHA), 0.6f, 0.01f, TEST_LOCATION ); - // We didn't expect the animation to finish yet + application.Render(static_cast(durationSeconds*250.0f)/* 75% progress */); application.SendNotification(); - finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetProperty(index), 25, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_RED), 0.99375f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_GREEN), 0.925f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_BLUE), 0.85625f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_ALPHA), 0.7875f, 0.01f, TEST_LOCATION ); + application.Render(static_cast(durationSeconds*250.0f)+1/* 100% progress */); application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_RED), 1.0f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_GREEN), 1.0f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_BLUE), 1.0f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_ALPHA), 1.0f, 0.01f, TEST_LOCATION ); // We did expect the animation to finish - application.SendNotification(); + finishCheck.CheckSignalReceived(); - DALI_TEST_EQUALS( actor.GetProperty(index), targetPosition, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationAnimateVector2(void) +int UtcDaliAnimationAnimateBetweenActorColorTimePeriodP(void) { TestApplication application; + float startValue(1.0f); Actor actor = Actor::New(); + actor.SetColor(Vector4(startValue, startValue, startValue, startValue)); 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(index), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_RED), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_BLUE), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION ); // Build the animation - float durationSeconds(10.0f); + float durationSeconds(1.0f); + float delay = 0.5f; Animation animation = Animation::New(durationSeconds); - Vector2 targetPosition(0.0f, 0.0f); - AnimateVector2TestFunctor func( Vector2(100,100), targetPosition ); - animation.Animate( Property(actor, index), func ); + + 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::Property::COLOR), keyFrames, TimePeriod( delay, durationSeconds - delay ) ); // Start the animation animation.Play(); @@ -9082,56 +9056,76 @@ int UtcDaliAnimationAnimateVector2(void) bool signalReceived(false); AnimationFinishCheck finishCheck(signalReceived); animation.FinishedSignal().Connect(&application, finishCheck); - application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f)/* 25% progress */); - // We didn't expect the animation to finish yet + application.Render(static_cast(delay*1000.0f)/* 0% progress */); application.SendNotification(); finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetProperty(index), Vector2(75,75), TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_RED), 0.1f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_GREEN), 0.2f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_BLUE), 0.3f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_ALPHA), 0.4f, 0.01f, TEST_LOCATION ); + application.Render(static_cast((durationSeconds - delay)*250.0f)/* 25% progress */); application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f)/* 50% progress */); - - // We didn't expect the animation to finish yet - application.SendNotification(); - finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetProperty(index), Vector2(50,50), TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_RED), 0.5f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_GREEN), 0.5f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_BLUE), 0.5f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_ALPHA), 0.5f, 0.01f, TEST_LOCATION ); + application.Render(static_cast((durationSeconds - delay)*250.0f)/* 50% progress */); application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f)/* 75% progress */); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_RED), 0.9f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_GREEN), 0.8f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_BLUE), 0.7f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_ALPHA), 0.6f, 0.01f, TEST_LOCATION ); - // We didn't expect the animation to finish yet + application.Render(static_cast((durationSeconds - delay)*250.0f)/* 75% progress */); application.SendNotification(); - finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetProperty(index), Vector2(25,25), TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_RED), 0.95f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_GREEN), 0.90f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_BLUE), 0.85f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_ALPHA), 0.80f, 0.01f, TEST_LOCATION ); + application.Render(static_cast((durationSeconds - delay)*250.0f)+1/* 100% progress */); application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_RED), 1.0f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_GREEN), 1.0f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_BLUE), 1.0f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_ALPHA), 1.0f, 0.01f, TEST_LOCATION ); // We did expect the animation to finish - application.SendNotification(); + finishCheck.CheckSignalReceived(); - DALI_TEST_EQUALS( actor.GetProperty(index), targetPosition, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationAnimateVector3(void) +int UtcDaliAnimationAnimateBetweenActorColorTimePeriodCubicP(void) { TestApplication application; + float startValue(1.0f); Actor actor = Actor::New(); - Vector3 initialPosition(Vector3::ZERO); - DALI_TEST_EQUALS( actor.GetCurrentPosition(), initialPosition, TEST_LOCATION ); + 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(Actor::Property::COLOR_RED), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_BLUE), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION ); + // Build the animation - float durationSeconds(10.0f); + float durationSeconds(1.0f); + float delay = 0.5f; Animation animation = Animation::New(durationSeconds); - Vector3 targetPosition(200.0f, 200.0f, 200.0f); - BounceFunc func(0.0f, 0.0f, -100.0f); - animation.Animate( Property(actor, Actor::POSITION), func, AlphaFunctions::Linear, 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::Property::COLOR), keyFrames, TimePeriod( delay, durationSeconds - delay ), Animation::Cubic ); // Start the animation animation.Play(); @@ -9139,59 +9133,76 @@ int UtcDaliAnimationAnimateVector3(void) bool signalReceived(false); AnimationFinishCheck finishCheck(signalReceived); animation.FinishedSignal().Connect(&application, finishCheck); - application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f)/* 25% progress */); - // We didn't expect the animation to finish yet + application.Render(static_cast(delay*1000.0f)/* 0% progress */); application.SendNotification(); finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetCurrentPosition(), func(0.25f, initialPosition), TEST_LOCATION ); - - application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f)/* 50% progress */); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_RED), 0.1f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_GREEN), 0.2f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_BLUE), 0.3f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_ALPHA), 0.4f, 0.01f, TEST_LOCATION ); - // We didn't expect the animation to finish yet + application.Render(static_cast((durationSeconds - delay)*250.0f)/* 25% progress */); application.SendNotification(); - finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetCurrentPosition(), func(0.5f, initialPosition), TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_RED), 0.55f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_GREEN), 0.525f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_BLUE), 0.506f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_ALPHA), 0.4875f, 0.01f, TEST_LOCATION ); + application.Render(static_cast((durationSeconds - delay)*250.0f)/* 50% progress */); application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f)/* 75% progress */); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_RED), 0.9f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_GREEN), 0.8f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_BLUE), 0.7f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_ALPHA), 0.6f, 0.01f, TEST_LOCATION ); - // We didn't expect the animation to finish yet + application.Render(static_cast((durationSeconds - delay)*250.0f)/* 75% progress */); application.SendNotification(); - finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetCurrentPosition(), func(0.75f, initialPosition), TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_RED), 0.99375f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_GREEN), 0.925f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_BLUE), 0.85625f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_ALPHA), 0.7875f, 0.01f, TEST_LOCATION ); + application.Render(static_cast((durationSeconds - delay)*250.0f)+1/* 100% progress */); application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_RED), 1.0f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_GREEN), 1.0f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_BLUE), 1.0f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_ALPHA), 1.0f, 0.01f, TEST_LOCATION ); // We did expect the animation to finish - application.SendNotification(); + finishCheck.CheckSignalReceived(); - DALI_TEST_EQUALS( actor.GetCurrentPosition(), initialPosition, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationAnimateVector4(void) +int UtcDaliAnimationAnimateBetweenActorColorAlphaFunctionTimePeriodP(void) { TestApplication application; + float startValue(1.0f); + float delay = 0.5f; Actor actor = Actor::New(); + actor.SetColor(Vector4(startValue, startValue, startValue, startValue)); 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(index), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_RED), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_BLUE), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_ALPHA), startValue, 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( Property(actor, index), func ); + + 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::Property::COLOR), keyFrames, AlphaFunction::LINEAR, TimePeriod( delay, durationSeconds - delay ) ); // Start the animation animation.Play(); @@ -9199,64 +9210,76 @@ int UtcDaliAnimationAnimateVector4(void) bool signalReceived(false); AnimationFinishCheck finishCheck(signalReceived); animation.FinishedSignal().Connect(&application, finishCheck); - application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f)/* 25% progress */); - // We didn't expect the animation to finish yet + application.Render(static_cast(delay*1000.0f)/* 0% progress */); application.SendNotification(); finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetProperty(index), Vector4(800,850,750,500), TEST_LOCATION ); - - application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f)/* 50% progress */); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_RED), 0.1f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_GREEN), 0.2f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_BLUE), 0.3f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_ALPHA), 0.4f, 0.01f, TEST_LOCATION ); - // We didn't expect the animation to finish yet + application.Render(static_cast((durationSeconds - delay)*250.0f)/* 25% progress */); application.SendNotification(); - finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetProperty(index), Vector4(600,700,500,0), TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_RED), 0.5f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_GREEN), 0.5f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_BLUE), 0.5f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_ALPHA), 0.5f, 0.01f, TEST_LOCATION ); + application.Render(static_cast((durationSeconds - delay)*250.0f)/* 50% progress */); application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f)/* 75% progress */); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_RED), 0.9f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_GREEN), 0.8f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_BLUE), 0.7f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_ALPHA), 0.6f, 0.01f, TEST_LOCATION ); - // We didn't expect the animation to finish yet + application.Render(static_cast((durationSeconds - delay)*250.0f)/* 75% progress */); application.SendNotification(); - finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetProperty(index), Vector4(400,550,250,-500), TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_RED), 0.95f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_GREEN), 0.90f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_BLUE), 0.85f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_ALPHA), 0.80f, 0.01f, TEST_LOCATION ); + application.Render(static_cast((durationSeconds - delay)*250.0f)+1/* 100% progress */); application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_RED), 1.0f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_GREEN), 1.0f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_BLUE), 1.0f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_ALPHA), 1.0f, 0.01f, TEST_LOCATION ); // We did expect the animation to finish - application.SendNotification(); + finishCheck.CheckSignalReceived(); - DALI_TEST_EQUALS( actor.GetProperty(index), targetPosition, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationAnimateQuaternion(void) +int UtcDaliAnimationAnimateBetweenActorColorCubicWithDelayP(void) { TestApplication application; + float startValue(1.0f); Actor actor = Actor::New(); - actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS)); + actor.SetColor(Vector4(startValue, startValue, startValue, startValue)); Stage::GetCurrent().Add(actor); - DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + + DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_RED), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_BLUE), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION ); // Build the animation float durationSeconds(1.0f); + float delay = 0.5f; 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); + 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)); - AnimateQuaternionTestFunctor func( sourceRotation, targetRotation ); - animation.Animate( Property(actor, Actor::ROTATION), func ); + animation.AnimateBetween( Property(actor, Actor::Property::COLOR), keyFrames, AlphaFunction::LINEAR, TimePeriod( delay, durationSeconds - delay ), Animation::Cubic ); // Start the animation animation.Play(); @@ -9264,89 +9287,79 @@ int UtcDaliAnimationAnimateQuaternion(void) bool signalReceived(false); AnimationFinishCheck finishCheck(signalReceived); animation.FinishedSignal().Connect(&application, finishCheck); - application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f)/* 25% progress */); - // We didn't expect the animation to finish yet + application.Render(static_cast(delay*1000.0f)/* 0% progress */); 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(durationSeconds*250.0f)/* 50% progress */); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_RED), 0.1f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_GREEN), 0.2f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_BLUE), 0.3f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_ALPHA), 0.4f, 0.01f, TEST_LOCATION ); - // We didn't expect the animation to finish yet + application.Render(static_cast((durationSeconds - delay)*250.0f)/* 25% progress */); application.SendNotification(); - finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(Radian(Degree(120)), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_RED), 0.55f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_GREEN), 0.525f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_BLUE), 0.506f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_ALPHA), 0.4875f, 0.01f, TEST_LOCATION ); + application.Render(static_cast((durationSeconds - delay)*250.0f)/* 50% progress */); application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f)/* 75% progress */); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_RED), 0.9f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_GREEN), 0.8f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_BLUE), 0.7f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_ALPHA), 0.6f, 0.01f, TEST_LOCATION ); - // We didn't expect the animation to finish yet + application.Render(static_cast((durationSeconds - delay)*250.0f)/* 75% progress */); application.SendNotification(); - finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(Radian(Degree(135)), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_RED), 0.99375f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_GREEN), 0.925f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_BLUE), 0.85625f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_ALPHA), 0.7875f, 0.01f, TEST_LOCATION ); + application.Render(static_cast((durationSeconds - delay)*250.0f)+1/* 100% progress */); application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_RED), 1.0f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_GREEN), 1.0f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_BLUE), 1.0f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_ALPHA), 1.0f, 0.01f, TEST_LOCATION ); // 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 ); + finishCheck.CheckSignalReceived(); END_TEST; } -int UtcDaliKeyFramesDownCast(void) +int UtcDaliAnimationAnimateP(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); + Actor actor = Actor::New(); + Stage::GetCurrent().Add(actor); - BaseHandle unInitializedObject; - KeyFrames keyFrames4 = KeyFrames::DownCast(unInitializedObject); - DALI_TEST_CHECK(!keyFrames4); + //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); - KeyFrames keyFrames5 = DownCast< KeyFrames >(unInitializedObject); - DALI_TEST_CHECK(!keyFrames5); - END_TEST; -} + Dali::Path path = Dali::Path::New(); + path.AddPoint(position0); + path.AddPoint(position1); + path.AddPoint(position2); -int UtcDaliAnimationResizeByXY(void) -{ - TestApplication application; + //Control points for first segment + path.AddControlPoint( Vector3( 39.0, 90.0, 0.0) ); + path.AddControlPoint(Vector3( 56.0, 119.0, 0.0) ); - Actor actor = Actor::New(); - Stage::GetCurrent().Add(actor); - DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION ); + //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); + 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); + animation.Animate(actor, path, Vector3::XAXIS); // Start the animation animation.Play(); @@ -9354,118 +9367,157 @@ int UtcDaliAnimationResizeByXY(void) 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.GetCurrentOrientation(), rotation, TEST_LOCATION ); + application.Render(static_cast(durationSeconds*250.0f)/* 25% progress */); application.SendNotification(); - application.Render(static_cast(durationSeconds*990.0f)/* 99% progress */); + path.Sample( 0.25f, position, tangent ); + rotation = Quaternion( Vector3::XAXIS, tangent ); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION ); - // We didn't expect the animation to finish yet + application.Render(static_cast(durationSeconds*250.0f)/* 50% progress */); application.SendNotification(); - finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetCurrentSize(), ninetyNinePercentProgress, TEST_LOCATION ); + path.Sample( 0.5f, position, tangent ); + rotation = Quaternion( Vector3::XAXIS, tangent ); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION ); + application.Render(static_cast(durationSeconds*250.0f)/* 75% progress */); application.SendNotification(); - application.Render(static_cast(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/); + path.Sample( 0.75f, position, tangent ); + rotation = Quaternion( Vector3::XAXIS, tangent ); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION ); - // We did expect the animation to finish + application.Render(static_cast(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.GetCurrentOrientation(), rotation, TEST_LOCATION ); + finishCheck.CheckSignalReceived(); - DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION ); + END_TEST; +} - // Reset everything - finishCheck.Reset(); - actor.SetSize(Vector3::ZERO); - application.SendNotification(); - application.Render(0); - DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION ); +int UtcDaliAnimationAnimateAlphaFunctionP(void) +{ + TestApplication application; - // 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(); + Actor actor = Actor::New(); + Stage::GetCurrent().Add(actor); - application.SendNotification(); - application.Render(static_cast(durationSeconds*990.0f)/* 99% progress */); + //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); - // We didn't expect the animation to finish yet - application.SendNotification(); - finishCheck.CheckSignalNotReceived(); + Dali::Path path = Dali::Path::New(); + path.AddPoint(position0); + path.AddPoint(position1); + path.AddPoint(position2); - // 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 ); + //Control points for first segment + path.AddControlPoint( Vector3( 39.0, 90.0, 0.0) ); + path.AddControlPoint(Vector3( 56.0, 119.0, 0.0) ); - application.SendNotification(); - application.Render(static_cast(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/); + //Control points for second segment + path.AddControlPoint(Vector3( 78.0, 120.0, 0.0)); + path.AddControlPoint(Vector3( 93.0, 104.0, 0.0)); - // We did expect the animation to finish - application.SendNotification(); - finishCheck.CheckSignalReceived(); - DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION ); + // Build the animation + float durationSeconds( 1.0f ); + Animation animation = Animation::New(durationSeconds); + animation.Animate(actor, path, Vector3::XAXIS, AlphaFunction::LINEAR); - // Reset everything - finishCheck.Reset(); - actor.SetSize(Vector3::ZERO); - application.SendNotification(); - application.Render(0); - DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION ); + // Start the animation + animation.Play(); - // Repeat with a delay - float delay = 0.5f; - animation = Animation::New(durationSeconds); - animation.Resize(actor, targetSize.x, targetSize.y, AlphaFunctions::Linear, delay, durationSeconds - delay); + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); animation.FinishedSignal().Connect(&application, finishCheck); - animation.Play(); + 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.GetCurrentOrientation(), rotation, TEST_LOCATION ); + application.Render(static_cast(durationSeconds*250.0f)/* 25% progress */); application.SendNotification(); - application.Render(static_cast(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */); + path.Sample( 0.25f, position, tangent ); + rotation = Quaternion( Vector3::XAXIS, tangent ); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION ); - // We didn't expect the animation to finish yet + application.Render(static_cast(durationSeconds*250.0f)/* 50% progress */); application.SendNotification(); - finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION ); + path.Sample( 0.5f, position, tangent ); + rotation = Quaternion( Vector3::XAXIS, tangent ); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION ); + application.Render(static_cast(durationSeconds*250.0f)/* 75% progress */); application.SendNotification(); - application.Render(static_cast(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/); + path.Sample( 0.75f, position, tangent ); + rotation = Quaternion( Vector3::XAXIS, tangent ); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION ); - // We did expect the animation to finish + application.Render(static_cast(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.GetCurrentOrientation(), rotation, TEST_LOCATION ); + finishCheck.CheckSignalReceived(); - DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION ); END_TEST; } - -int UtcDaliAnimationAnimateBetweenActorColorTimePeriod(void) +int UtcDaliAnimationAnimateTimePeriodP(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(Actor::COLOR_RED), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_GREEN), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_BLUE), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_ALPHA), startValue, TEST_LOCATION ); + //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); - // Build the animation - float durationSeconds(1.0f); - Animation animation = Animation::New(durationSeconds); + Dali::Path path = Dali::Path::New(); + path.AddPoint(position0); + path.AddPoint(position1); + path.AddPoint(position2); - 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)); + //Control points for first segment + path.AddControlPoint( Vector3( 39.0, 90.0, 0.0) ); + path.AddControlPoint(Vector3( 56.0, 119.0, 0.0) ); - animation.AnimateBetween( Property(actor, Actor::COLOR), keyFrames, TimePeriod( 1.0f) ); + //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, TimePeriod(0.0f, 1.0f)); // Start the animation animation.Play(); @@ -9477,70 +9529,74 @@ int UtcDaliAnimationAnimateBetweenActorColorTimePeriod(void) application.Render(0); application.SendNotification(); finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_RED), 0.1f, 0.01f, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_GREEN), 0.2f, 0.01f, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_BLUE), 0.3f, 0.01f, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_ALPHA), 0.4f, 0.01f, TEST_LOCATION ); + 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.GetCurrentOrientation(), rotation, TEST_LOCATION ); application.Render(static_cast(durationSeconds*250.0f)/* 25% progress */); application.SendNotification(); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_RED), 0.5f, 0.01f, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_GREEN), 0.5f, 0.01f, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_BLUE), 0.5f, 0.01f, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_ALPHA), 0.5f, 0.01f, TEST_LOCATION ); + path.Sample( 0.25f, position, tangent ); + rotation = Quaternion( Vector3::XAXIS, tangent ); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION ); application.Render(static_cast(durationSeconds*250.0f)/* 50% progress */); application.SendNotification(); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_RED), 0.9f, 0.01f, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_GREEN), 0.8f, 0.01f, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_BLUE), 0.7f, 0.01f, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_ALPHA), 0.6f, 0.01f, TEST_LOCATION ); + path.Sample( 0.5f, position, tangent ); + rotation = Quaternion( Vector3::XAXIS, tangent ); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION ); application.Render(static_cast(durationSeconds*250.0f)/* 75% progress */); application.SendNotification(); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_RED), 0.95f, 0.01f, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_GREEN), 0.90f, 0.01f, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_BLUE), 0.85f, 0.01f, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_ALPHA), 0.80f, 0.01f, TEST_LOCATION ); + path.Sample( 0.75f, position, tangent ); + rotation = Quaternion( Vector3::XAXIS, tangent ); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION ); application.Render(static_cast(durationSeconds*250.0f)+1/* 100% progress */); application.SendNotification(); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_RED), 1.0f, 0.01f, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_GREEN), 1.0f, 0.01f, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_BLUE), 1.0f, 0.01f, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_ALPHA), 1.0f, 0.01f, TEST_LOCATION ); - - // We did expect the animation to finish + path.Sample( 1.0f, position, tangent ); + rotation = Quaternion( Vector3::XAXIS, tangent ); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION ); finishCheck.CheckSignalReceived(); END_TEST; } -int UtcDaliAnimationAnimateBetweenActorColorFunction(void) +int UtcDaliAnimationAnimateAlphaFunctionTimePeriodP(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(Actor::COLOR_RED), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_GREEN), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_BLUE), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_ALPHA), startValue, TEST_LOCATION ); + //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); - // Build the animation - float durationSeconds(1.0f); - Animation animation = Animation::New(durationSeconds); + Dali::Path path = Dali::Path::New(); + path.AddPoint(position0); + path.AddPoint(position1); + path.AddPoint(position2); - 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)); + //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)); - animation.AnimateBetween( Property(actor, Actor::COLOR), keyFrames, AlphaFunctions::Linear ); + // Build the animation + float durationSeconds( 1.0f ); + Animation animation = Animation::New(durationSeconds); + animation.Animate(actor, path, Vector3::XAXIS, AlphaFunction::LINEAR, TimePeriod(0.0f, 1.0f)); // Start the animation animation.Play(); @@ -9552,137 +9608,104 @@ int UtcDaliAnimationAnimateBetweenActorColorFunction(void) application.Render(0); application.SendNotification(); finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_RED), 0.1f, 0.01f, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_GREEN), 0.2f, 0.01f, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_BLUE), 0.3f, 0.01f, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_ALPHA), 0.4f, 0.01f, TEST_LOCATION ); + 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.GetCurrentOrientation(), rotation, TEST_LOCATION ); application.Render(static_cast(durationSeconds*250.0f)/* 25% progress */); application.SendNotification(); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_RED), 0.5f, 0.01f, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_GREEN), 0.5f, 0.01f, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_BLUE), 0.5f, 0.01f, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_ALPHA), 0.5f, 0.01f, TEST_LOCATION ); + path.Sample( 0.25f, position, tangent ); + rotation = Quaternion( Vector3::XAXIS, tangent ); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION ); application.Render(static_cast(durationSeconds*250.0f)/* 50% progress */); application.SendNotification(); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_RED), 0.9f, 0.01f, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_GREEN), 0.8f, 0.01f, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_BLUE), 0.7f, 0.01f, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_ALPHA), 0.6f, 0.01f, TEST_LOCATION ); + path.Sample( 0.5f, position, tangent ); + rotation = Quaternion( Vector3::XAXIS, tangent ); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION ); application.Render(static_cast(durationSeconds*250.0f)/* 75% progress */); application.SendNotification(); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_RED), 0.95f, 0.01f, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_GREEN), 0.90f, 0.01f, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_BLUE), 0.85f, 0.01f, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_ALPHA), 0.80f, 0.01f, TEST_LOCATION ); + path.Sample( 0.75f, position, tangent ); + rotation = Quaternion( Vector3::XAXIS, tangent ); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION ); application.Render(static_cast(durationSeconds*250.0f)+1/* 100% progress */); application.SendNotification(); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_RED), 1.0f, 0.01f, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_GREEN), 1.0f, 0.01f, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_BLUE), 1.0f, 0.01f, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_ALPHA), 1.0f, 0.01f, TEST_LOCATION ); - - // We did expect the animation to finish + path.Sample( 1.0f, position, tangent ); + rotation = Quaternion( Vector3::XAXIS, tangent ); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION ); finishCheck.CheckSignalReceived(); END_TEST; } -int UtcDaliAnimationAnimateBetweenActorColorFunctionTimePeriod(void) +int UtcDaliAnimationShowP(void) { TestApplication application; - float startValue(1.0f); Actor actor = Actor::New(); - actor.SetColor(Vector4(startValue, startValue, startValue, startValue)); + actor.SetVisible(false); + application.SendNotification(); + application.Render(0); + DALI_TEST_CHECK( !actor.IsVisible() ); Stage::GetCurrent().Add(actor); - DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_RED), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_GREEN), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_BLUE), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(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, AlphaFunctions::Linear, TimePeriod( 1.0f) ); - // Start the animation + float durationSeconds(10.0f); + Animation animation = Animation::New(durationSeconds); + animation.Show(actor, durationSeconds*0.5f); 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(Actor::COLOR_RED), 0.1f, 0.01f, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_GREEN), 0.2f, 0.01f, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_BLUE), 0.3f, 0.01f, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_ALPHA), 0.4f, 0.01f, TEST_LOCATION ); + application.Render(static_cast(durationSeconds*490.0f)); - application.Render(static_cast(durationSeconds*250.0f)/* 25% progress */); + // We didn't expect the animation to finish yet application.SendNotification(); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_RED), 0.5f, 0.01f, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_GREEN), 0.5f, 0.01f, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_BLUE), 0.5f, 0.01f, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_ALPHA), 0.5f, 0.01f, TEST_LOCATION ); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_CHECK( !actor.IsVisible() ); - application.Render(static_cast(durationSeconds*250.0f)/* 50% progress */); application.SendNotification(); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_RED), 0.9f, 0.01f, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_GREEN), 0.8f, 0.01f, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_BLUE), 0.7f, 0.01f, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_ALPHA), 0.6f, 0.01f, TEST_LOCATION ); + application.Render(static_cast(durationSeconds*10.0f)/*Should be shown now*/); - application.Render(static_cast(durationSeconds*250.0f)/* 75% progress */); + // We didn't expect the animation to finish yet application.SendNotification(); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_RED), 0.95f, 0.01f, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_GREEN), 0.90f, 0.01f, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_BLUE), 0.85f, 0.01f, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_ALPHA), 0.80f, 0.01f, TEST_LOCATION ); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_CHECK( actor.IsVisible() ); - application.Render(static_cast(durationSeconds*250.0f)+1/* 100% progress */); application.SendNotification(); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_RED), 1.0f, 0.01f, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_GREEN), 1.0f, 0.01f, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_BLUE), 1.0f, 0.01f, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_ALPHA), 1.0f, 0.01f, TEST_LOCATION ); + application.Render(static_cast(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/); // We did expect the animation to finish - + application.SendNotification(); finishCheck.CheckSignalReceived(); + DALI_TEST_CHECK( actor.IsVisible() ); END_TEST; } -int UtcDaliAnimationAnimateVector3Func(void) +int UtcDaliAnimationHideP(void) { TestApplication application; Actor actor = Actor::New(); - Vector3 initialPosition(Vector3::ZERO); - DALI_TEST_EQUALS( actor.GetCurrentPosition(), initialPosition, TEST_LOCATION ); + DALI_TEST_CHECK( actor.IsVisible() ); Stage::GetCurrent().Add(actor); - // Build the animation + // Start 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( Property(actor, Actor::POSITION), func, AlphaFunctions::Linear ); - - // Start the animation + animation.Hide(actor, durationSeconds*0.5f); animation.Play(); bool signalReceived(false); @@ -9690,40 +9713,110 @@ int UtcDaliAnimationAnimateVector3Func(void) animation.FinishedSignal().Connect(&application, finishCheck); application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f)/* 25% progress */); + application.Render(static_cast(durationSeconds*490.0f)); // We didn't expect the animation to finish yet application.SendNotification(); finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetCurrentPosition(), func(0.25f, initialPosition), TEST_LOCATION ); + DALI_TEST_CHECK( actor.IsVisible() ); application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f)/* 50% progress */); + application.Render(static_cast(durationSeconds*10.0f)/*Should be hidden now*/); // 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_CHECK( !actor.IsVisible() ); application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f)/* 75% progress */); + application.Render(static_cast(durationSeconds*500.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.GetCurrentPosition(), func(0.75f, initialPosition), TEST_LOCATION ); + finishCheck.CheckSignalReceived(); + DALI_TEST_CHECK( !actor.IsVisible() ); + END_TEST; +} + +int UtcDaliAnimationShowHideAtEndP(void) +{ + // Test that show/hide delay can be the same as animation duration + // i.e. to show/hide at the end of the animation + + TestApplication application; + + Actor actor = Actor::New(); + DALI_TEST_CHECK( actor.IsVisible() ); + Stage::GetCurrent().Add(actor); + + // Start Hide animation + float durationSeconds(10.0f); + Animation animation = Animation::New(durationSeconds); + animation.Hide(actor, durationSeconds/*Hide at end*/); + animation.Play(); + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/); + application.Render(static_cast(durationSeconds*1000.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_CHECK( !actor.IsVisible() ); + + // Start Show animation + animation = Animation::New(durationSeconds); + animation.Show(actor, durationSeconds/*Show at end*/); + animation.FinishedSignal().Connect(&application, finishCheck); + animation.Play(); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*1000.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_CHECK( actor.IsVisible() ); + END_TEST; +} + +int UtcDaliKeyFramesCreateDestroyP(void) +{ + tet_infoline("Testing Dali::Animation::UtcDaliKeyFramesCreateDestroy()"); + + KeyFrames* keyFrames = new KeyFrames; + delete keyFrames; + DALI_TEST_CHECK( true ); + END_TEST; +} + +int UtcDaliKeyFramesDownCastP(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 UtcDaliAnimationCreateDestroy(void) +int UtcDaliAnimationCreateDestroyP(void) { TestApplication application; Animation* animation = new Animation; @@ -9739,16 +9832,15 @@ struct UpdateManagerTestConstraint { } - Vector3 operator()(const Vector3& current) + void operator()( Vector3& current, const PropertyInputContainer& /* inputs */) { mApplication.SendNotification(); // Process events - return current; } TestApplication& mApplication; }; -int UtcDaliAnimationUpdateManager(void) +int UtcDaliAnimationUpdateManagerP(void) { TestApplication application; @@ -9763,13 +9855,13 @@ int UtcDaliAnimationUpdateManager(void) animation.FinishedSignal().Connect( &application, finishCheck ); Vector3 startValue(1.0f, 1.0f, 1.0f); - Property::Index index = actor.RegisterProperty( "test-property", startValue ); - Constraint constraint = Constraint::New( index, UpdateManagerTestConstraint( application ) ); - actor.ApplyConstraint( constraint ); + Property::Index index = actor.RegisterProperty( "testProperty", startValue ); + Constraint constraint = Constraint::New( actor, index, UpdateManagerTestConstraint( application ) ); + constraint.Apply(); // Apply animation to actor - BounceFunc func(0.0f, 0.0f, -100.0f); - animation.Animate( Property(actor, Actor::POSITION), func, AlphaFunctions::Linear ); + animation.AnimateTo( Property(actor, Actor::Property::POSITION), Vector3( 100.f, 90.f, 80.f ), AlphaFunction::LINEAR ); + animation.AnimateTo( Property(actor, DevelActor::Property::OPACITY), 0.3f, AlphaFunction::LINEAR ); animation.Play(); @@ -9785,7 +9877,7 @@ int UtcDaliAnimationUpdateManager(void) END_TEST; } -int UtcDaliAnimationSignalOrder(void) +int UtcDaliAnimationSignalOrderP(void) { TestApplication application; @@ -9803,9 +9895,9 @@ int UtcDaliAnimationSignalOrder(void) animation2.FinishedSignal().Connect( &application, AnimationFinishCheck( signal2Received ) ); // Apply animations to actor - animation1.AnimateTo( Property(actor, Actor::POSITION), Vector3( 3.0f, 2.0f, 1.0f ), AlphaFunctions::Linear ); + animation1.AnimateTo( Property(actor, Actor::Property::POSITION), Vector3( 3.0f, 2.0f, 1.0f ), AlphaFunction::LINEAR ); animation1.Play(); - animation2.AnimateTo( Property(actor, Actor::SIZE ), Vector3( 10.0f, 20.0f, 30.0f ), AlphaFunctions::Linear ); + animation2.AnimateTo( Property(actor, Actor::Property::SIZE ), Vector3( 10.0f, 20.0f, 30.0f ), AlphaFunction::LINEAR ); animation2.Play(); DALI_TEST_EQUALS( signal1Received, false, TEST_LOCATION ); @@ -9838,7 +9930,7 @@ int UtcDaliAnimationSignalOrder(void) END_TEST; } -int UtcDaliAnimationExtendDuration(void) +int UtcDaliAnimationExtendDurationP(void) { TestApplication application; @@ -9846,7 +9938,7 @@ int UtcDaliAnimationExtendDuration(void) // Register a float property float startValue(10.0f); - Property::Index index = actor.RegisterProperty( "test-property", startValue ); + Property::Index index = actor.RegisterProperty( "testProperty", startValue ); Stage::GetCurrent().Add(actor); DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); @@ -9899,3 +9991,153 @@ int UtcDaliAnimationExtendDuration(void) END_TEST; } +int UtcDaliAnimationCustomIntProperty(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + Stage::GetCurrent().Add(actor); + int startValue(0u); + + Property::Index index = actor.RegisterProperty("anIndex", startValue); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + animation.AnimateTo( Property(actor, index), 20 ); + + // Start the animation + animation.Play(); + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*500.0f)/* 50% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetProperty(index), 10, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetProperty(index), 20, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliAnimationDuration(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + Stage::GetCurrent().Add(actor); + + Animation animation = Animation::New( 0.0f ); + DALI_TEST_EQUALS( 0.0f, animation.GetDuration(), TEST_LOCATION ); + + // The animation duration should automatically increase depending on the animator time period + + animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 100.0f, TimePeriod( 0.0f, 1.0f ) ); + DALI_TEST_EQUALS( 1.0f, animation.GetDuration(), TEST_LOCATION ); + + animation.AnimateTo( Property( actor, Actor::Property::POSITION_Y ), 200.0f, TimePeriod( 10.0f, 1.0f ) ); + DALI_TEST_EQUALS( 11.0f, animation.GetDuration(), TEST_LOCATION ); + + END_TEST; +} + +int UtcDaliAnimationAnimateByNonAnimateableTypeN(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + + // Register an integer property + int startValue(1); + Property::Index index = actor.RegisterProperty( "testProperty", startValue ); + Stage::GetCurrent().Add(actor); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + + try + { + // Build the animation + Animation animation = Animation::New( 2.0f ); + std::string relativeValue = "relative string"; + animation.AnimateBy( Property(actor, index), relativeValue ); + tet_result(TET_FAIL); + } + catch ( Dali::DaliException& e ) + { + DALI_TEST_ASSERT( e, "Animated value and Property type don't match", TEST_LOCATION ); + } + + + END_TEST; +} + + +int UtcDaliAnimationAnimateToNonAnimateableTypeN(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + + // Register an integer property + int startValue(1); + Property::Index index = actor.RegisterProperty( "testProperty", startValue ); + Stage::GetCurrent().Add(actor); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + + try + { + // Build the animation + Animation animation = Animation::New( 2.0f ); + std::string relativeValue = "relative string"; + animation.AnimateTo( Property(actor, index), relativeValue ); + + tet_result(TET_FAIL); + } + catch ( Dali::DaliException& e ) + { + DALI_TEST_ASSERT( e, "Animated value and Property type don't match", TEST_LOCATION ); + } + + END_TEST; +} + +int UtcDaliAnimationAnimateBetweenNonAnimateableTypeN(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + + // Register an integer property + int startValue(1); + Property::Index index = actor.RegisterProperty( "testProperty", startValue ); + Stage::GetCurrent().Add(actor); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + + try + { + // Build the animation + KeyFrames keyFrames = KeyFrames::New(); + keyFrames.Add( 0.0f, std::string("relative string1") ); + keyFrames.Add( 1.0f, std::string("relative string2") ); + // no need to really create the animation as keyframes do the check + + tet_result(TET_FAIL); + } + catch ( Dali::DaliException& e ) + { + DALI_TEST_ASSERT( e, "Type not animateable", TEST_LOCATION ); + } + + END_TEST; +}