X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=automated-tests%2Fsrc%2Fdali%2Futc-Dali-Animation.cpp;h=01180b8ad27dc004e29c7eb65a3c0d44b37e17e8;hb=5d77add47f208b222c21995fe64869f763725919;hp=b44c95e4cad7d4da6e375313aadb92f205b13433;hpb=f62577b50f22eb3f399eafff3349f91baf8bbce6;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 b44c95e..01180b8 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) 2017 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; } @@ -90,41 +91,41 @@ struct AnimationFinishCheck } // anon namespace -int UtcDaliAnimationNew01(void) +int UtcDaliAnimationConstructorP(void) { TestApplication application; Animation animation; - DALI_TEST_CHECK(!animation); - animation = Animation::New(1.0f); + DALI_TEST_CHECK( !animation ); + END_TEST; +} + +int UtcDaliAnimationNewP(void) +{ + TestApplication application; + + Animation animation = Animation::New( 1.0f ); DALI_TEST_CHECK(animation); END_TEST; } -int UtcDaliAnimationNew02(void) +int UtcDaliAnimationNewN(void) { TestApplication application; - Animation animation; - DALI_TEST_CHECK(!animation); - try - { - animation = Animation::New(0.0f); - } - catch (Dali::DaliException& e) - { - // Tests that a negative test of an assertion succeeds - DALI_TEST_PRINT_ASSERT( e ); - DALI_TEST_EQUALS(e.condition, "durationSeconds > 0.0f", TEST_LOCATION); - } + Animation animation = Animation::New( -1.0f ); + + DALI_TEST_CHECK(animation); + DALI_TEST_EQUALS(animation.GetDuration(), 0.0f, TEST_LOCATION); END_TEST; } -int UtcDaliAnimationDownCast(void) +int UtcDaliAnimationDownCastP(void) { TestApplication application; + tet_infoline("Testing Dali::Animation::DownCast()"); float durationSeconds(1.0f); @@ -137,17 +138,53 @@ int UtcDaliAnimationDownCast(void) Animation animation3 = DownCast< Animation >(object); DALI_TEST_CHECK(animation3); + END_TEST; +} + +int UtcDaliAnimationDownCastN(void) +{ + TestApplication application; BaseHandle unInitializedObject; - Animation animation4 = Animation::DownCast(unInitializedObject); - DALI_TEST_CHECK(!animation4); - Animation animation5 = DownCast< Animation >(unInitializedObject); - DALI_TEST_CHECK(!animation5); + Animation animation1 = Animation::DownCast( unInitializedObject ); + DALI_TEST_CHECK( !animation1 ); + + Animation animation2 = DownCast< Animation >( unInitializedObject ); + DALI_TEST_CHECK( !animation2 ); + END_TEST; +} + +int UtcDaliAnimationCopyConstructorP(void) +{ + TestApplication application; + + // Initialize an object, ref count == 1 + Animation animation = Animation::New( 1.0f ); + + Animation copy( animation ); + DALI_TEST_CHECK( copy ); + + DALI_TEST_CHECK( copy.GetDuration() == animation.GetDuration() ); END_TEST; } -int UtcDaliAnimationSetDuration(void) +int UtcDaliAnimationAssignmentOperatorP(void) +{ + TestApplication application; + + Animation animation = Animation::New( 1.0f ); + + Animation copy = animation; + DALI_TEST_CHECK( copy ); + + DALI_TEST_CHECK( animation == copy ); + + DALI_TEST_CHECK( copy.GetDuration() == animation.GetDuration() ); + END_TEST; +} + +int UtcDaliAnimationSetDurationP(void) { TestApplication application; @@ -161,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); @@ -212,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; @@ -224,7 +273,7 @@ int UtcDaliAnimationGetDuration(void) END_TEST; } -int UtcDaliAnimationSetLooping(void) +int UtcDaliAnimationSetLoopingP(void) { TestApplication application; @@ -235,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); @@ -288,273 +337,363 @@ int UtcDaliAnimationSetLooping(void) END_TEST; } -int UtcDaliAnimationIsLooping(void) +int UtcDaliAnimationSetLoopCountP(void) { TestApplication application; - Animation animation = Animation::New(1.0f); - DALI_TEST_CHECK(!animation.IsLooping()); + Actor actor = Actor::New(); + Stage::GetCurrent().Add(actor); - animation.SetLooping(true); + // 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()); + animation.Play(); + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + + application.Render(0); + application.SendNotification(); + application.Render(0); + application.SendNotification(); + application.Render(0); + application.SendNotification(); + application.Render(0); + application.SendNotification(); + + // 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(); + application.Render(0); + application.SendNotification(); + application.Render(0); + application.SendNotification(); + application.Render(0); + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + + application.Render(static_cast(durationSeconds*intervalSeconds*1000.0f)); + + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION ); + + finishCheck.Reset(); + + application.Render(static_cast(durationSeconds*intervalSeconds*1000.0f)); + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + + 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(); + END_TEST; } -int UtcDaliAnimationSetEndAction(void) +int UtcDaliAnimationSetLoopCountP2(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); - 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); + 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); + float intervalSeconds = 3.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*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 ); - // Go back to the start - actor.SetPosition(Vector3::ZERO); + finishCheck.Reset(); + + // Loop forever + animation.SetLooping(true); + DALI_TEST_CHECK(animation.IsLooping()); + + application.Render(static_cast(durationSeconds*intervalSeconds*1000.0f)); application.SendNotification(); - application.Render(0); - DALI_TEST_EQUALS( Vector3::ZERO, actor.GetCurrentPosition(), TEST_LOCATION ); + 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(); + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); - // Test BakeFinal, animate again, for half the duration finishCheck.Reset(); - animation.SetEndAction(Animation::BakeFinal); - DALI_TEST_CHECK(animation.GetEndAction() == Animation::BakeFinal); + + // Loop N again + animation.SetLoopCount(3); + DALI_TEST_CHECK(animation.IsLooping()); animation.Play(); application.SendNotification(); - application.Render(static_cast(durationSeconds*1000.0f*0.5f) /*half of the animation duration*/); - - // Stop the animation early - animation.Stop(); - - // We did NOT expect the animation to finish + 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( targetPosition * 0.5f, actor.GetCurrentPosition(), VECTOR4_EPSILON, TEST_LOCATION ); - // Go back to the start - actor.SetPosition(Vector3::ZERO); + application.Render(static_cast(durationSeconds*intervalSeconds*1000.0f)); application.SendNotification(); - application.Render(0); - DALI_TEST_EQUALS( Vector3::ZERO, actor.GetCurrentPosition(), TEST_LOCATION ); + finishCheck.CheckSignalReceived(); - // 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(); + // loop forever + animation.SetLooping(true); + DALI_TEST_CHECK(animation.IsLooping()); + + application.Render(static_cast(durationSeconds*intervalSeconds*1000.0f)); application.SendNotification(); - application.Render(static_cast(durationSeconds*1000.0f) + 1u/*just beyond the animation duration*/); + finishCheck.CheckSignalNotReceived(); - // We did expect the animation to finish + application.Render(static_cast(durationSeconds*intervalSeconds*1000.0f)); application.SendNotification(); - finishCheck.CheckSignalReceived(); - DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION ); + 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(); - // The position should be discarded in the next frame - application.Render(0); - DALI_TEST_EQUALS( Vector3::ZERO/*discarded*/, actor.GetCurrentPosition(), TEST_LOCATION ); + finishCheck.Reset(); - // Check that nothing has changed after a couple of buffer swaps - application.Render(0); - DALI_TEST_EQUALS( Vector3::ZERO, actor.GetCurrentPosition(), TEST_LOCATION ); - application.Render(0); - DALI_TEST_EQUALS( Vector3::ZERO, actor.GetCurrentPosition(), TEST_LOCATION ); - END_TEST; -} + // Loop N again + animation.SetLoopCount(3); + DALI_TEST_CHECK(animation.IsLooping()); -int UtcDaliAnimationGetEndAction(void) -{ - TestApplication application; + application.SendNotification(); + application.Render(static_cast(durationSeconds*intervalSeconds*1000.0f)); + application.SendNotification(); + application.Render(static_cast(durationSeconds*intervalSeconds*1000.0f)); + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); - Animation animation = Animation::New(1.0f); - DALI_TEST_CHECK(animation.GetEndAction() == Animation::Bake); + application.Render(static_cast(durationSeconds*intervalSeconds*1000.0f)); + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); // we never hit play - animation.SetEndAction(Animation::Discard); - DALI_TEST_CHECK(animation.GetEndAction() == Animation::Discard); + finishCheck.Reset(); - animation.SetEndAction(Animation::BakeFinal); - DALI_TEST_CHECK(animation.GetEndAction() == Animation::BakeFinal); END_TEST; } -int UtcDaliAnimationSetDisconnectAction(void) +int UtcDaliAnimationSetLoopCountP3(void) { TestApplication application; - Stage stage( Stage::GetCurrent() ); - // Default: BakeFinal - { - Actor actor = Actor::New(); - stage.Add(actor); + // + // 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); - DALI_TEST_CHECK(animation.GetDisconnectAction() == Animation::BakeFinal); + // 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); - Vector3 targetPosition(10.0f, 10.0f, 10.0f); - animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear); + float intervalSeconds = 3.0f; - // Start the animation - animation.Play(); + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); - application.SendNotification(); - application.Render(static_cast(durationSeconds*0.5f*1000.0f)/*Only half the animation*/); + // loop forever + animation.SetLooping(true); + DALI_TEST_CHECK(animation.IsLooping()); - actor.Unparent(); + application.Render(static_cast(durationSeconds*intervalSeconds*1000.0f)); + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); - application.SendNotification(); - application.Render(); + 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, TEST_LOCATION ); - } + finishCheck.Reset(); - // Bake - { - Actor actor = Actor::New(); - stage.Add(actor); + // Loop N again + animation.SetLoopCount(3); + DALI_TEST_CHECK(animation.IsLooping()); - // Build the animation - float durationSeconds(1.0f); - Animation animation = Animation::New(durationSeconds); - animation.SetDisconnectAction( Animation::Bake ); + application.SendNotification(); + application.Render(static_cast(durationSeconds*intervalSeconds*1000.0f)); + application.SendNotification(); + application.Render(static_cast(durationSeconds*intervalSeconds*1000.0f)); + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); - Vector3 targetPosition(10.0f, 10.0f, 10.0f); - animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear); + application.Render(static_cast(durationSeconds*intervalSeconds*1000.0f)); + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); // we never hit play - // Start the animation - animation.Play(); + finishCheck.Reset(); - application.SendNotification(); - application.Render(static_cast(durationSeconds*0.5f*1000.0f)/*Only half the animation*/); - actor.Unparent(); + END_TEST; +} - application.SendNotification(); - application.Render(); - - DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition*0.5f, TEST_LOCATION ); - } - - // Discard - { - Actor actor = Actor::New(); - stage.Add(actor); - - // Build the animation - float durationSeconds(1.0f); - Animation animation = Animation::New(durationSeconds); - animation.SetDisconnectAction( Animation::Discard ); - - Vector3 targetPosition(10.0f, 10.0f, 10.0f); - animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear); - - // Start the animation - animation.Play(); +int UtcDaliAnimationSetLoopCountP4(void) +{ + TestApplication application; - application.SendNotification(); - application.Render(static_cast(durationSeconds*0.5f*1000.0f)/*Only half the animation*/); + // + // ..and play again + // + Actor actor = Actor::New(); + Stage::GetCurrent().Add(actor); - actor.Unparent(); + // 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); - application.SendNotification(); - application.Render(); + float intervalSeconds = 3.0f; - DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION ); - } + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); - // Don't play the animation: disconnect action should not be applied - { - Actor actor = Actor::New(); - stage.Add(actor); + animation.SetLoopCount(1); + animation.Play(); + DALI_TEST_CHECK(!animation.IsLooping()); - // Build the animation - float durationSeconds(1.0f); - Animation animation = Animation::New(durationSeconds); + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + application.Render(static_cast(durationSeconds*intervalSeconds*1000.0f)); + application.SendNotification(); + finishCheck.CheckSignalReceived(); - Vector3 targetPosition(10.0f, 10.0f, 10.0f); - animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION ); + actor.SetProperty( Actor::Property::POSITION, Vector3(0.0f, 0.0f, 0.0f) ); - application.SendNotification(); - application.Render(static_cast(durationSeconds*0.5f*1000.0f)/*Only half the animation*/); + finishCheck.Reset(); - actor.Unparent(); + animation.Play(); // again + DALI_TEST_CHECK(!animation.IsLooping()); - application.SendNotification(); - application.Render(); + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + application.Render(static_cast(durationSeconds*intervalSeconds*1000.0f)); + application.SendNotification(); + finishCheck.CheckSignalReceived(); - DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION ); - } + DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationGetDisconnectAction(void) +int UtcDaliAnimationGetLoopCountP(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); + Actor actor = Actor::New(); + Stage::GetCurrent().Add(actor); - animation.SetDisconnectAction(Animation::Bake); - DALI_TEST_CHECK(animation.GetDisconnectAction() == Animation::Bake); + // 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); - END_TEST; -} + DALI_TEST_CHECK(1 == animation.GetLoopCount()); -int UtcDaliAnimationSetDefaultAlphaFunction(void) -{ - TestApplication application; + // Start the animation + animation.SetLoopCount(3); + DALI_TEST_CHECK(animation.IsLooping()); + DALI_TEST_CHECK(3 == animation.GetLoopCount()); - Animation animation = Animation::New(1.0f); - AlphaFunction func = animation.GetDefaultAlphaFunction(); - DALI_TEST_EQUALS(func(0.1f), AlphaFunctions::Linear(0.1f), TEST_LOCATION); + animation.Play(); - 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; -} + application.Render(0); + application.SendNotification(); -int UtcDaliAnimationGetDefaultAlphaFunction(void) -{ - TestApplication application; + // Loop + float intervalSeconds = 3.0f; - Animation animation = Animation::New(1.0f); - AlphaFunction func = animation.GetDefaultAlphaFunction(); + application.Render(static_cast(durationSeconds*intervalSeconds*1000.0f)); + application.Render(static_cast(durationSeconds*intervalSeconds*1000.0f)); + + application.Render(0); + application.SendNotification(); + + 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()); - // Test that the default is linear - DALI_TEST_EQUALS(func(0.1f), AlphaFunctions::Linear(0.1f), TEST_LOCATION); END_TEST; } -int UtcDaliAnimationPlay(void) + +int UtcDaliAnimationGetCurrentLoopP(void) { TestApplication application; @@ -564,10 +703,13 @@ 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); // Start the animation + animation.SetLoopCount(3); + DALI_TEST_CHECK(animation.IsLooping()); + DALI_TEST_CHECK(0 == animation.GetCurrentLoop()); animation.Play(); bool signalReceived(false); @@ -575,58 +717,55 @@ int UtcDaliAnimationPlay(void) animation.FinishedSignal().Connect(&application, finishCheck); application.SendNotification(); - 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 + float intervalSeconds = 3.0f; - animation.Play(); // Test that calling play has no effect, when animation is already playing - application.SendNotification(); - application.Render(static_cast(durationSeconds*200.0f)/* 40% progress */); + 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.4f), TEST_LOCATION ); + DALI_TEST_CHECK(2 == animation.GetCurrentLoop()); - 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 */); + 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.6f), TEST_LOCATION ); + finishCheck.CheckSignalReceived(); + DALI_TEST_CHECK(3 == animation.GetCurrentLoop()); + DALI_TEST_CHECK(animation.GetLoopCount() == animation.GetCurrentLoop()); - 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 */); + finishCheck.Reset(); - // 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.8f), TEST_LOCATION ); + DALI_TEST_CHECK(3 == animation.GetCurrentLoop()); - animation.Play(); // Test that calling play has no effect, when animation is already playing + 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(); - application.Render(static_cast(durationSeconds*200.0f) + 1u/*just beyond the animation duration*/); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_CHECK(3 == animation.GetCurrentLoop()); - // We did expect the animation to finish - application.SendNotification(); - finishCheck.CheckSignalReceived(); - DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION ); + END_TEST; +} - // 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 ); +int UtcDaliAnimationIsLoopingP(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 UtcDaliAnimationSetSpeedFactor(void) +int UtcDaliAnimationSetEndActioN(void) { TestApplication application; @@ -636,17 +775,10 @@ int UtcDaliAnimationSetSpeedFactor(void) // Build the animation float durationSeconds(1.0f); Animation animation = Animation::New(durationSeconds); + DALI_TEST_CHECK(animation.GetEndAction() == Animation::Bake); - 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, AlphaFunctions::Linear); - - //Set speed to be x2 - animation.SetSpeedFactor(2.0f); + Vector3 targetPosition(10.0f, 10.0f, 10.0f); + animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR); // Start the animation animation.Play(); @@ -656,101 +788,1190 @@ int UtcDaliAnimationSetSpeedFactor(void) animation.FinishedSignal().Connect(&application, finishCheck); 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*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.Render(static_cast(durationSeconds*100.0f) + 1u/*just beyond half the 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 ); - - // Check that nothing has changed after a couple of buffer swaps - application.Render(0); DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION ); + + // Go back to the start + actor.SetPosition(Vector3::ZERO); + application.SendNotification(); application.Render(0); - DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION ); + DALI_TEST_EQUALS( Vector3::ZERO, actor.GetCurrentPosition(), TEST_LOCATION ); + // Test BakeFinal, animate again, for half the duration finishCheck.Reset(); - - //Test -1 speed factor. Animation will play in reverse at normal speed - animation.SetSpeedFactor( -1.0f ); - - // Start the animation + animation.SetEndAction(Animation::BakeFinal); + DALI_TEST_CHECK(animation.GetEndAction() == Animation::BakeFinal); animation.Play(); 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.Render(static_cast(durationSeconds*1000.0f*0.5f) /*half of the animation duration*/); - application.Render(static_cast(durationSeconds*200.0f)/* 60% progress */); + // Stop the animation early + animation.Stop(); - // We didn't expect the animation to finish yet + // We did NOT expect the animation to finish application.SendNotification(); finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.6f), TEST_LOCATION ); + DALI_TEST_EQUALS( targetPosition * 0.5f, actor.GetCurrentPosition(), VECTOR4_EPSILON, TEST_LOCATION ); - application.Render(static_cast(durationSeconds*200.0f)/* 40% progress */); + // The position should be same with target position in the next frame + application.Render(0); + DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION ); - // We didn't expect the animation to finish yet + // Go back to the start + actor.SetPosition(Vector3::ZERO); application.SendNotification(); - finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.4f), TEST_LOCATION ); + application.Render(0); + DALI_TEST_EQUALS( Vector3::ZERO, actor.GetCurrentPosition(), TEST_LOCATION ); - application.Render(static_cast(durationSeconds*200.0f)/* 20% progress */); + // 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(); - // 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*/); + 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_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( initialPosition, actor.GetCurrentPosition(), TEST_LOCATION ); + DALI_TEST_EQUALS( Vector3::ZERO, actor.GetCurrentPosition(), TEST_LOCATION ); application.Render(0); - DALI_TEST_EQUALS( initialPosition, actor.GetCurrentPosition(), TEST_LOCATION ); - + DALI_TEST_EQUALS( Vector3::ZERO, actor.GetCurrentPosition(), TEST_LOCATION ); + END_TEST; +} - //Test change speed factor on the fly - finishCheck.Reset(); +int UtcDaliAnimationGetEndActionP(void) +{ + TestApplication application; - //Set speed to be half of normal speed - animation.SetSpeedFactor( 0.5f ); + 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 UtcDaliAnimationSetDisconnectActionP(void) +{ + TestApplication application; + Stage stage( Stage::GetCurrent() ); + + // Default: BakeFinal + { + Actor actor = Actor::New(); + stage.Add(actor); + + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + DALI_TEST_CHECK(animation.GetDisconnectAction() == Animation::BakeFinal); + + Vector3 targetPosition(10.0f, 10.0f, 10.0f); + animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR); + + // Start the animation + animation.Play(); + + 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(), targetPosition, TEST_LOCATION ); + } + + // Bake + { + Actor actor = Actor::New(); + stage.Add(actor); + + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + animation.SetDisconnectAction( Animation::Bake ); + + Vector3 targetPosition(10.0f, 10.0f, 10.0f); + animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR); + + // Start the animation + animation.Play(); + + 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(), targetPosition*0.5f, TEST_LOCATION ); + } + + // Discard + { + Actor actor = Actor::New(); + stage.Add(actor); + + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + animation.SetDisconnectAction( Animation::Discard ); + + Vector3 targetPosition(10.0f, 10.0f, 10.0f); + animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR); + + // Start the animation + animation.Play(); + + 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 ); + } + + // Don't play the animation: disconnect action should not be applied + { + Actor actor = Actor::New(); + stage.Add(actor); + + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + + Vector3 targetPosition(10.0f, 10.0f, 10.0f); + animation.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); + + END_TEST; +} + +int UtcDaliAnimationSetCurrentProgressP(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + Stage::GetCurrent().Add(actor); + + // Build the animation + Animation animation = Animation::New(0.0f); + + //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); + + // Start the animation from 40% progress + animation.SetCurrentProgress( 0.4f ); + animation.Play(); + + 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.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(); + + //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 + 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 UtcDaliAnimationSetCurrentProgressN(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + Stage::GetCurrent().Add(actor); + + // Build the animation + Animation animation = Animation::New(0.0f); + + //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(); + application.Render(static_cast(100.0f)); + + //Progress should still be 0.0 + DALI_TEST_EQUALS( 0.0f, animation.GetCurrentProgress(), TEST_LOCATION ); + + //Set duration + float durationSeconds(1.0f); + animation.SetDuration(durationSeconds); + application.SendNotification(); + + 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); + + // Start the animation from 40% progress + animation.SetCurrentProgress( 0.4f ); + animation.Play(); + + 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( 0.6f, animation.GetCurrentProgress(), TEST_LOCATION ); + + animation.Play(); // Test that calling play has no effect, when animation is already playing + application.SendNotification(); + + //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( 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(); + END_TEST; +} + +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); + + 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(); + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + + 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*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.Render(static_cast(durationSeconds*100.0f) + 1u/*just beyond half the 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 UtcDaliAnimationSetSpeedFactorP2(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + Stage::GetCurrent().Add(actor); + + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + + 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(); + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + + 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.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 ); + + 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 ); + + END_TEST; +} + +int UtcDaliAnimationSetSpeedFactorP3(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + Stage::GetCurrent().Add(actor); + + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + + 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); + + 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*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), 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)/* 30% progress */); + + // 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 UtcDaliAnimationSetSpeedFactorP4(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + Stage::GetCurrent().Add(actor); + + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + + 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); + + 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*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), 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)/* 30% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.3f), TEST_LOCATION ); + + 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*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)/* 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(), 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 UtcDaliAnimationSetSpeedFactorAndRange(void) +{ + TestApplication application; + + 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); + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + + std::vector actors; + + 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(); + 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 UtcDaliAnimationSetSpeedFactorRangeAndLoopCount01(void) +{ + TestApplication application; + + 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, + /**/ + } + }; + + + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + + std::vector actors; + + 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(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(); - application.Render(static_cast(durationSeconds*200.0f)/* 10% progress */); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetCurrentPosition().x, 80.0f, 0.001, TEST_LOCATION ); + + END_TEST; +} + +int UtcDaliAnimationSetSpeedFactorRangeAndLoopCount02(void) +{ + TestApplication application; + + 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 + {/**/ 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); + + std::vector actors; + + 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(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_EQUALS( actor.GetCurrentPosition().x, 30.0f, 0.001, TEST_LOCATION ); + + END_TEST; +} + + +int UtcDaliAnimationGetSpeedFactorP(void) +{ + TestApplication application; + + Animation animation = Animation::New(1.0f); + animation.SetSpeedFactor(0.5f); + DALI_TEST_EQUALS(animation.GetSpeedFactor(), 0.5f, TEST_LOCATION); + + animation.SetSpeedFactor(-2.5f); + DALI_TEST_EQUALS(animation.GetSpeedFactor(), -2.5f, TEST_LOCATION); + END_TEST; +} + +int UtcDaliAnimationSetPlayRangeP(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + Stage::GetCurrent().Add( actor ); + + // 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(); + + // 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< unsigned int >( durationSeconds * 200.0f )/* 60% progress */ ); // We didn't expect the animation to finish yet application.SendNotification(); finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.1f), TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), ( targetPosition * 0.6f ), TEST_LOCATION ); + + application.SendNotification(); + 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_EQUALS( actor.GetCurrentPosition(), ( targetPosition * 0.9f ), TEST_LOCATION ); + END_TEST; +} + +int UtcDaliAnimationSetPlayRangeN(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + Stage::GetCurrent().Add(actor); + + // Build the animation + Animation animation = Animation::New(0); + application.SendNotification(); + + //PlayRange out of bounds + animation.SetPlayRange( Vector2(-1.0f,1.0f) ); + application.SendNotification(); + DALI_TEST_EQUALS( Vector2(0.0f,1.0f), animation.GetPlayRange(), TEST_LOCATION ); + animation.SetPlayRange( Vector2(0.0f,2.0f) ); + application.SendNotification(); + DALI_TEST_EQUALS( Vector2(0.0f,1.0f), animation.GetPlayRange(), TEST_LOCATION ); + + //If playRange is not in the correct order it has to be ordered + animation.SetPlayRange( Vector2(0.8f,0.2f) ); + application.SendNotification(); + DALI_TEST_EQUALS( Vector2(0.2f,0.8f), animation.GetPlayRange(), TEST_LOCATION ); + + 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(); + + //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(); + DALI_TEST_EQUALS( Vector2( 0.4f, 0.8f ), animation.GetPlayRange(), TEST_LOCATION ); + + END_TEST; +} + +int UtcDaliAnimationPlayP(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + Stage::GetCurrent().Add(actor); + + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + Vector3 targetPosition(100.0f, 100.0f, 100.0f); + animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR); + + // Start the animation + animation.Play(); + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + application.SendNotification(); application.Render(static_cast(durationSeconds*200.0f)/* 20% progress */); // We didn't expect the animation to finish yet @@ -758,52 +1979,51 @@ int UtcDaliAnimationSetSpeedFactor(void) finishCheck.CheckSignalNotReceived(); DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION ); - application.Render(static_cast(durationSeconds*200.0f)/* 30% progress */); + animation.Play(); // Test that calling play has no effect, when animation is already playing + 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.3f), TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.4f), TEST_LOCATION ); - //Change speed factor while animation still playing. - animation.SetSpeedFactor(-1.0f); + animation.Play(); // Test that calling play has no effect, when animation is already playing application.SendNotification(); - application.Render(static_cast(durationSeconds*200.0f)/* 10% 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 ); + + 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.1f), TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.8f), TEST_LOCATION ); - application.Render(static_cast(durationSeconds*100.0f) + 1u/*just beyond the animation duration*/); + 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_EQUALS( actor.GetCurrentPosition(), initialPosition, 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( initialPosition, actor.GetCurrentPosition(), TEST_LOCATION ); + DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION ); application.Render(0); - DALI_TEST_EQUALS( initialPosition, actor.GetCurrentPosition(), TEST_LOCATION ); - END_TEST; -} - -int UtcDaliAnimationGetSpeedFactor(void) -{ - TestApplication application; - - Animation animation = Animation::New(1.0f); - animation.SetSpeedFactor(0.5f); - DALI_TEST_EQUALS(animation.GetSpeedFactor(), 0.5f, TEST_LOCATION); - - animation.SetSpeedFactor(-2.5f); - DALI_TEST_EQUALS(animation.GetSpeedFactor(), -2.5f, TEST_LOCATION); + DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationPlayOffStage(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 @@ -821,7 +2041,7 @@ int UtcDaliAnimationPlayOffStage(void) Animation animation = Animation::New(durationSeconds); animation.SetDisconnectAction( Animation::Discard ); Vector3 targetPosition(100.0f, 100.0f, 100.0f); - animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear); + animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR); // Start the animation animation.Play(); @@ -889,7 +2109,7 @@ int UtcDaliAnimationPlayOffStage(void) END_TEST; } -int UtcDaliAnimationPlayDiscardHandle(void) +int UtcDaliAnimationPlayDiscardHandleP(void) { TestApplication application; @@ -900,7 +2120,7 @@ int UtcDaliAnimationPlayDiscardHandle(void) float durationSeconds(1.0f); Animation animation = Animation::New(durationSeconds); Vector3 targetPosition(100.0f, 100.0f, 100.0f); - animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear); + animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR); bool signalReceived(false); AnimationFinishCheck finishCheck(signalReceived); @@ -962,7 +2182,7 @@ int UtcDaliAnimationPlayDiscardHandle(void) END_TEST; } -int UtcDaliAnimationPlayStopDiscardHandle(void) +int UtcDaliAnimationPlayStopDiscardHandleP(void) { TestApplication application; @@ -973,7 +2193,7 @@ int UtcDaliAnimationPlayStopDiscardHandle(void) float durationSeconds(1.0f); Animation animation = Animation::New(durationSeconds); Vector3 targetPosition(100.0f, 100.0f, 100.0f); - animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear); + animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR); // Start the animation animation.Play(); @@ -1031,154 +2251,7 @@ int UtcDaliAnimationPlayStopDiscardHandle(void) END_TEST; } -int UtcDaliAnimationPlayFrom(void) -{ - TestApplication application; - - Actor actor = Actor::New(); - Stage::GetCurrent().Add(actor); - - // Build the animation - float durationSeconds(1.0f); - Animation animation = Animation::New(durationSeconds); - Vector3 targetPosition(100.0f, 100.0f, 100.0f); - animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear); - - //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 ); - - // 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*200.0f)/* 60% progress */); - - // We didn't expect the animation to finish yet - application.SendNotification(); - finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.6f), TEST_LOCATION ); - - animation.Play(); // Test that calling play has no effect, when animation is already playing - application.SendNotification(); - application.Render(static_cast(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.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 UtcDaliAnimationSetCurrentProgress(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(); - application.Render(static_cast(100.0f)); - - //Progress should still be 0.0 - DALI_TEST_EQUALS( 0.0f, animation.GetCurrentProgress(), TEST_LOCATION ); - - //Set duration - float durationSeconds(1.0f); - animation.SetDuration(durationSeconds); - application.SendNotification(); - - bool signalReceived(false); - AnimationFinishCheck finishCheck(signalReceived); - animation.FinishedSignal().Connect(&application, finishCheck); - 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 ); - - // Start the animation from 40% progress - animation.SetCurrentProgress( 0.4f ); - animation.Play(); - - 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.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(); - - //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 - 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 UtcDaliAnimationPlayRange(void) +int UtcDaliAnimationPlayRangeP(void) { TestApplication application; @@ -1193,7 +2266,7 @@ int UtcDaliAnimationPlayRange(void) keyframes.Add( 0.0f , Vector3(0.0f,0.0f,0.0f ) ); keyframes.Add( 1.0f , Vector3(100.0f,100.0f,100.0f ) ); - animation.AnimateBetween( Property( actor, Actor::Property::Position), keyframes ); + animation.AnimateBetween( Property( actor, Actor::Property::POSITION), keyframes ); // Set range between 0.4 and 0.8 animation.SetPlayRange( Vector2(0.4f,0.8f) ); @@ -1282,42 +2355,158 @@ int UtcDaliAnimationPlayRange(void) END_TEST; } -int UtcDaliAnimationSetPlayRange(void) +int UtcDaliAnimationPlayFromP(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + Stage::GetCurrent().Add(actor); + + DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), Vector3::ZERO, TEST_LOCATION ); + + // 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); + + // Start the animation from 40% progress + animation.PlayFrom( 0.4f ); + + // Target value should be updated straight away + DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), targetPosition, TEST_LOCATION ); + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + + 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.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 ); + + 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 UtcDaliAnimationPlayFromN(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + Stage::GetCurrent().Add(actor); + + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + Vector3 targetPosition(100.0f, 100.0f, 100.0f); + animation.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); + 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.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR); + + Vector3 fiftyPercentProgress(targetPosition * 0.5f); + + // 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 */); - // Build the animation - Animation animation = Animation::New(0); + // We didn't expect the animation to finish yet application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress, TEST_LOCATION ); - //If PlayRange not specified it should be 0.0-1.0 by default - DALI_TEST_EQUALS( Vector2(0.0,1.0), animation.GetPlayRange(), TEST_LOCATION ); + // Pause the animation + animation.Pause(); + application.SendNotification(); - //PlayRange out of bounds - animation.SetPlayRange( Vector2(-1.0f,1.0f) ); + // 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(); - DALI_TEST_EQUALS( Vector2(0.0f,1.0f), animation.GetPlayRange(), TEST_LOCATION ); - animation.SetPlayRange( Vector2(0.0f,2.0f) ); + application.Render(static_cast(durationSeconds*490.0f)/*slightly less than the animation duration*/); + + // We didn't expect the animation to finish yet application.SendNotification(); - DALI_TEST_EQUALS( Vector2(0.0f,1.0f), animation.GetPlayRange(), TEST_LOCATION ); + finishCheck.CheckSignalNotReceived(); - //If playRange is not in the correct order it has to be ordered - animation.SetPlayRange( Vector2(0.8f,0.2f) ); application.SendNotification(); - DALI_TEST_EQUALS( Vector2(0.2f,0.8f), animation.GetPlayRange(), TEST_LOCATION ); + application.Render(static_cast(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/); - // Set range between 0.4 and 0.8 - animation.SetPlayRange( Vector2(0.4f,0.8f) ); + // We did expect the animation to finish application.SendNotification(); - DALI_TEST_EQUALS( Vector2(0.4f,0.8f), animation.GetPlayRange(), TEST_LOCATION ); + 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 UtcDaliAnimationGetStateP(void) { TestApplication application; @@ -1328,13 +2517,16 @@ int UtcDaliAnimationPause(void) float durationSeconds(1.0f); Animation animation = Animation::New(durationSeconds); Vector3 targetPosition(100.0f, 100.0f, 100.0f); - animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear); + 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); @@ -1345,11 +2537,14 @@ int UtcDaliAnimationPause(void) // We didn't expect the animation to finish yet application.SendNotification(); finishCheck.CheckSignalNotReceived(); + 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(0.f); // Loop 5 times for (int i=0; i<5; ++i) @@ -1360,16 +2555,19 @@ int UtcDaliAnimationPause(void) 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( animation.GetState(), Animation::PLAYING, TEST_LOCATION ); application.SendNotification(); application.Render(static_cast(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/); @@ -1378,16 +2576,30 @@ int UtcDaliAnimationPause(void) application.SendNotification(); finishCheck.CheckSignalReceived(); 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( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION ); application.Render(0); 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 UtcDaliAnimationStop(void) +int UtcDaliAnimationStopP(void) { TestApplication application; @@ -1398,7 +2610,7 @@ int UtcDaliAnimationStop(void) float durationSeconds(1.0f); Animation animation = Animation::New(durationSeconds); Vector3 targetPosition(100.0f, 100.0f, 100.0f); - animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear); + animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR); Vector3 fiftyPercentProgress(targetPosition * 0.5f); @@ -1434,7 +2646,7 @@ int UtcDaliAnimationStop(void) END_TEST; } -int UtcDaliAnimationStopSetPosition(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. @@ -1448,7 +2660,7 @@ int UtcDaliAnimationStopSetPosition(void) float durationSeconds(1.0f); Animation animation = Animation::New(durationSeconds); Vector3 targetPosition(100.0f, 100.0f, 100.0f); - animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear); + animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR); Vector3 fiftyPercentProgress(targetPosition * 0.5f); @@ -1486,7 +2698,7 @@ int UtcDaliAnimationStopSetPosition(void) END_TEST; } -int UtcDaliAnimationClear(void) +int UtcDaliAnimationClearP(void) { TestApplication application; @@ -1497,7 +2709,7 @@ int UtcDaliAnimationClear(void) float durationSeconds(1.0f); Animation animation = Animation::New(durationSeconds); Vector3 targetPosition(100.0f, 100.0f, 100.0f); - animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear); + animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR); Vector3 fiftyPercentProgress(targetPosition * 0.5f); @@ -1531,7 +2743,7 @@ int UtcDaliAnimationClear(void) finishCheck.Reset(); actor.SetPosition(Vector3::ZERO); Vector3 targetScale(3.0f, 3.0f, 3.0f); - animation.ScaleTo(actor, targetScale, AlphaFunctions::Linear); + animation.AnimateTo( Property( actor, Actor::Property::SCALE ), targetScale, AlphaFunction::LINEAR ); animation.Play(); application.SendNotification(); @@ -1553,7 +2765,7 @@ int UtcDaliAnimationClear(void) END_TEST; } -int UtcDaliAnimationSignalFinish(void) +int UtcDaliAnimationFinishedSignalP(void) { TestApplication application; @@ -1575,7 +2787,7 @@ int UtcDaliAnimationSignalFinish(void) END_TEST; } -int UtcDaliAnimationAnimateByBoolean(void) +int UtcDaliAnimationAnimateByBooleanP(void) { TestApplication application; @@ -1583,9 +2795,10 @@ int UtcDaliAnimationAnimateByBoolean(void) // Register a boolean property bool startValue(false); - Property::Index index = actor.RegisterProperty( "test-property", startValue ); + Property::Index index = actor.RegisterProperty( "testProperty", startValue ); Stage::GetCurrent().Add(actor); DALI_TEST_CHECK( actor.GetProperty(index) == startValue ); + DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == startValue ); // Build the animation float durationSeconds(2.0f); @@ -1597,6 +2810,9 @@ int UtcDaliAnimationAnimateByBoolean(void) // Start the animation animation.Play(); + // Target value should be retrievable straight away + DALI_TEST_EQUALS( actor.GetProperty< bool >( index ), finalValue, TEST_LOCATION ); + bool signalReceived(false); AnimationFinishCheck finishCheck(signalReceived); animation.FinishedSignal().Connect(&application, finishCheck); @@ -1607,7 +2823,7 @@ int UtcDaliAnimationAnimateByBoolean(void) // We didn't expect the animation to finish yet application.SendNotification(); finishCheck.CheckSignalNotReceived(); - DALI_TEST_CHECK( actor.GetProperty(index) == startValue ); + DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == startValue ); application.SendNotification(); application.Render(static_cast(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/); @@ -1615,13 +2831,13 @@ int UtcDaliAnimationAnimateByBoolean(void) // We did expect the animation to finish application.SendNotification(); finishCheck.CheckSignalReceived(); - DALI_TEST_CHECK( actor.GetProperty(index) == finalValue ); + DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue ); // Check that nothing has changed after a couple of buffer swaps application.Render(0); - DALI_TEST_CHECK( actor.GetProperty(index) == finalValue ); + DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue ); application.Render(0); - DALI_TEST_CHECK( actor.GetProperty(index) == finalValue ); + DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue ); // Repeat with relative value "false" - this should be an NOOP animation = Animation::New(durationSeconds); @@ -1640,7 +2856,7 @@ int UtcDaliAnimationAnimateByBoolean(void) // We didn't expect the animation to finish yet application.SendNotification(); finishCheck.CheckSignalNotReceived(); - DALI_TEST_CHECK( actor.GetProperty(index) == finalValue ); + DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue ); application.SendNotification(); application.Render(static_cast(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/); @@ -1648,17 +2864,17 @@ int UtcDaliAnimationAnimateByBoolean(void) // We did expect the animation to finish application.SendNotification(); finishCheck.CheckSignalReceived(); - DALI_TEST_CHECK( actor.GetProperty(index) == finalValue ); + DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue ); // Check that nothing has changed after a couple of buffer swaps application.Render(0); - DALI_TEST_CHECK( actor.GetProperty(index) == finalValue ); + DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue ); application.Render(0); - DALI_TEST_CHECK( actor.GetProperty(index) == finalValue ); + DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue ); END_TEST; } -int UtcDaliAnimationAnimateByBooleanAlphaFunction(void) +int UtcDaliAnimationAnimateByBooleanAlphaFunctionP(void) { TestApplication application; @@ -1666,16 +2882,17 @@ int UtcDaliAnimationAnimateByBooleanAlphaFunction(void) // Register a boolean property bool startValue(false); - Property::Index index = actor.RegisterProperty( "test-property", startValue ); + Property::Index index = actor.RegisterProperty( "testProperty", startValue ); Stage::GetCurrent().Add(actor); DALI_TEST_CHECK( actor.GetProperty(index) == startValue ); + DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == startValue ); // 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); + animation.AnimateBy(Property(actor, index), relativeValue, AlphaFunction::EASE_IN); // Start the animation animation.Play(); @@ -1690,7 +2907,7 @@ int UtcDaliAnimationAnimateByBooleanAlphaFunction(void) // We didn't expect the animation to finish yet application.SendNotification(); finishCheck.CheckSignalNotReceived(); - DALI_TEST_CHECK( actor.GetProperty(index) == startValue ); + DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == startValue ); application.SendNotification(); application.Render(static_cast(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/); @@ -1698,18 +2915,18 @@ int UtcDaliAnimationAnimateByBooleanAlphaFunction(void) // We did expect the animation to finish application.SendNotification(); finishCheck.CheckSignalReceived(); - DALI_TEST_CHECK( actor.GetProperty(index) == finalValue ); + DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue ); // Check that nothing has changed after a couple of buffer swaps application.Render(0); - DALI_TEST_CHECK( actor.GetProperty(index) == finalValue ); + DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue ); application.Render(0); - DALI_TEST_CHECK( actor.GetProperty(index) == finalValue ); + DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue ); // 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); + animation.AnimateBy(Property(actor, index), noOpValue, AlphaFunction::EASE_IN); // Start the animation animation.Play(); @@ -1723,7 +2940,7 @@ int UtcDaliAnimationAnimateByBooleanAlphaFunction(void) // We didn't expect the animation to finish yet application.SendNotification(); finishCheck.CheckSignalNotReceived(); - DALI_TEST_CHECK( actor.GetProperty(index) == finalValue ); + DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue ); application.SendNotification(); application.Render(static_cast(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/); @@ -1731,11 +2948,11 @@ int UtcDaliAnimationAnimateByBooleanAlphaFunction(void) // We did expect the animation to finish application.SendNotification(); finishCheck.CheckSignalReceived(); - DALI_TEST_CHECK( actor.GetProperty(index) == finalValue ); + DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue ); END_TEST; } -int UtcDaliAnimationAnimateByBooleanTimePeriod(void) +int UtcDaliAnimationAnimateByBooleanTimePeriodP(void) { TestApplication application; @@ -1743,9 +2960,10 @@ int UtcDaliAnimationAnimateByBooleanTimePeriod(void) // Register a boolean property bool startValue(false); - Property::Index index = actor.RegisterProperty( "test-property", startValue ); + Property::Index index = actor.RegisterProperty( "testProperty", startValue ); Stage::GetCurrent().Add(actor); DALI_TEST_CHECK( actor.GetProperty(index) == startValue ); + DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == startValue ); // Build the animation float durationSeconds(2.0f); @@ -1770,7 +2988,7 @@ int UtcDaliAnimationAnimateByBooleanTimePeriod(void) // We didn't expect the animation to finish yet application.SendNotification(); finishCheck.CheckSignalNotReceived(); - DALI_TEST_CHECK( actor.GetProperty(index) == startValue ); + DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == startValue ); application.SendNotification(); application.Render(static_cast(animatorDurationSeconds*50.0f) + 1u/*just beyond the animator duration*/); @@ -1780,7 +2998,7 @@ int UtcDaliAnimationAnimateByBooleanTimePeriod(void) finishCheck.CheckSignalNotReceived(); // ...however we should have reached the final value - DALI_TEST_CHECK( actor.GetProperty(index) == finalValue ); + DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue ); application.SendNotification(); application.Render(static_cast(animatorDurationSeconds*1000.0f)/*just beyond the animation duration*/); @@ -1788,17 +3006,17 @@ int UtcDaliAnimationAnimateByBooleanTimePeriod(void) // We did expect the animation to finish application.SendNotification(); finishCheck.CheckSignalReceived(); - DALI_TEST_CHECK( actor.GetProperty(index) == finalValue ); + DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue ); // Check that nothing has changed after a couple of buffer swaps application.Render(0); - DALI_TEST_CHECK( actor.GetProperty(index) == finalValue ); + DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue ); application.Render(0); - DALI_TEST_CHECK( actor.GetProperty(index) == finalValue ); + DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue ); END_TEST; } -int UtcDaliAnimationAnimateByBooleanAlphaFunctionTimePeriod(void) +int UtcDaliAnimationAnimateByBooleanAlphaFunctionTimePeriodP(void) { TestApplication application; @@ -1806,9 +3024,10 @@ int UtcDaliAnimationAnimateByBooleanAlphaFunctionTimePeriod(void) // Register a boolean property bool startValue(false); - Property::Index index = actor.RegisterProperty( "test-property", startValue ); + Property::Index index = actor.RegisterProperty( "testProperty", startValue ); Stage::GetCurrent().Add(actor); DALI_TEST_CHECK( actor.GetProperty(index) == startValue ); + DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == startValue ); // Build the animation float durationSeconds(2.0f); @@ -1818,7 +3037,7 @@ int UtcDaliAnimationAnimateByBooleanAlphaFunctionTimePeriod(void) float animatorDurationSeconds(durationSeconds * 0.5f); animation.AnimateBy( Property(actor, index), relativeValue, - AlphaFunctions::EaseInOut, + AlphaFunction::EASE_IN_OUT, TimePeriod( animatorDurationSeconds ) ); // Start the animation @@ -1834,7 +3053,7 @@ int UtcDaliAnimationAnimateByBooleanAlphaFunctionTimePeriod(void) // We didn't expect the animation to finish yet application.SendNotification(); finishCheck.CheckSignalNotReceived(); - DALI_TEST_CHECK( actor.GetProperty(index) == startValue ); + DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == startValue ); application.SendNotification(); application.Render(static_cast(animatorDurationSeconds*50.0f) + 1u/*just beyond the animator duration*/); @@ -1844,7 +3063,7 @@ int UtcDaliAnimationAnimateByBooleanAlphaFunctionTimePeriod(void) finishCheck.CheckSignalNotReceived(); // ...however we should have reached the final value - DALI_TEST_CHECK( actor.GetProperty(index) == finalValue ); + DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue ); application.SendNotification(); application.Render(static_cast(animatorDurationSeconds*1000.0f)/*just beyond the animation duration*/); @@ -1852,17 +3071,17 @@ int UtcDaliAnimationAnimateByBooleanAlphaFunctionTimePeriod(void) // We did expect the animation to finish application.SendNotification(); finishCheck.CheckSignalReceived(); - DALI_TEST_CHECK( actor.GetProperty(index) == finalValue ); + DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue ); // Check that nothing has changed after a couple of buffer swaps application.Render(0); - DALI_TEST_CHECK( actor.GetProperty(index) == finalValue ); + DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue ); application.Render(0); - DALI_TEST_CHECK( actor.GetProperty(index) == finalValue ); + DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue ); END_TEST; } -int UtcDaliAnimationAnimateByFloat(void) +int UtcDaliAnimationAnimateByFloatP(void) { TestApplication application; @@ -1870,9 +3089,10 @@ int UtcDaliAnimationAnimateByFloat(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 ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), startValue, TEST_LOCATION ); // Build the animation float durationSeconds(2.0f); @@ -1886,6 +3106,9 @@ int UtcDaliAnimationAnimateByFloat(void) // Start the animation animation.Play(); + // Target value should be retrievable straight away + DALI_TEST_EQUALS( actor.GetProperty< float >( index ), targetValue, TEST_LOCATION ); + bool signalReceived(false); AnimationFinishCheck finishCheck(signalReceived); animation.FinishedSignal().Connect(&application, finishCheck); @@ -1896,7 +3119,7 @@ int UtcDaliAnimationAnimateByFloat(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.GetCurrentProperty< float >( index ), ninetyFivePercentProgress, TEST_LOCATION ); application.SendNotification(); application.Render(static_cast(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/); @@ -1904,17 +3127,17 @@ int UtcDaliAnimationAnimateByFloat(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.GetCurrentProperty< float >( 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.GetCurrentProperty< float >( index ), targetValue, TEST_LOCATION ); application.Render(0); - DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), targetValue, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationAnimateByFloatAlphaFunction(void) +int UtcDaliAnimationAnimateByFloatAlphaFunctionP(void) { TestApplication application; @@ -1922,16 +3145,17 @@ int UtcDaliAnimationAnimateByFloatAlphaFunction(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 ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( 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); + animation.AnimateBy(Property(actor, index), relativeValue, AlphaFunction::EASE_OUT); float ninetyFivePercentProgress(startValue + relativeValue*0.95f); @@ -1950,7 +3174,7 @@ int UtcDaliAnimationAnimateByFloatAlphaFunction(void) finishCheck.CheckSignalNotReceived(); // The position should have moved more, than with a linear alpha function - float current(actor.GetProperty(index)); + float current( actor.GetCurrentProperty< float >( index ) ); DALI_TEST_CHECK( current > ninetyFivePercentProgress ); application.SendNotification(); @@ -1959,17 +3183,17 @@ int UtcDaliAnimationAnimateByFloatAlphaFunction(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.GetCurrentProperty< float >( 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.GetCurrentProperty< float >( index ), targetValue, TEST_LOCATION ); application.Render(0); - DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), targetValue, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationAnimateByFloatTimePeriod(void) +int UtcDaliAnimationAnimateByFloatTimePeriodP(void) { TestApplication application; @@ -1977,9 +3201,10 @@ int UtcDaliAnimationAnimateByFloatTimePeriod(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 ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), startValue, TEST_LOCATION ); // Build the animation float durationSeconds(1.0f); @@ -2004,7 +3229,7 @@ int UtcDaliAnimationAnimateByFloatTimePeriod(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.GetCurrentProperty< float >( index ), startValue, TEST_LOCATION ); application.SendNotification(); application.Render(static_cast(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */); @@ -2012,7 +3237,7 @@ int UtcDaliAnimationAnimateByFloatTimePeriod(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.GetCurrentProperty< float >( index ), startValue+(relativeValue*0.5f), TEST_LOCATION ); application.SendNotification(); application.Render(static_cast(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/); @@ -2020,17 +3245,17 @@ int UtcDaliAnimationAnimateByFloatTimePeriod(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.GetCurrentProperty< float >( 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.GetCurrentProperty< float >( index ), targetValue, TEST_LOCATION ); application.Render(0); - DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), targetValue, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationAnimateByFloatAlphaFunctionTimePeriod(void) +int UtcDaliAnimationAnimateByFloatAlphaFunctionTimePeriodP(void) { TestApplication application; @@ -2038,9 +3263,10 @@ int UtcDaliAnimationAnimateByFloatAlphaFunctionTimePeriod(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 ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), startValue, TEST_LOCATION ); // Build the animation float durationSeconds(1.0f); @@ -2050,7 +3276,7 @@ int UtcDaliAnimationAnimateByFloatAlphaFunctionTimePeriod(void) float delay = 0.5f; animation.AnimateBy(Property(actor, index), relativeValue, - AlphaFunctions::Linear, + AlphaFunction::LINEAR, TimePeriod(delay, durationSeconds - delay)); // Start the animation @@ -2066,7 +3292,7 @@ int UtcDaliAnimationAnimateByFloatAlphaFunctionTimePeriod(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.GetCurrentProperty< float >( index ), startValue, TEST_LOCATION ); application.SendNotification(); application.Render(static_cast(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */); @@ -2074,7 +3300,7 @@ int UtcDaliAnimationAnimateByFloatAlphaFunctionTimePeriod(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.GetCurrentProperty< float >( index ), startValue+(relativeValue*0.5f), TEST_LOCATION ); application.SendNotification(); application.Render(static_cast(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/); @@ -2082,17 +3308,17 @@ int UtcDaliAnimationAnimateByFloatAlphaFunctionTimePeriod(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.GetCurrentProperty< float >( 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.GetCurrentProperty< float >( index ), targetValue, TEST_LOCATION ); application.Render(0); - DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), targetValue, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationAnimateByInteger(void) +int UtcDaliAnimationAnimateByIntegerP(void) { TestApplication application; @@ -2100,9 +3326,10 @@ int UtcDaliAnimationAnimateByInteger(void) // Register an integer property int startValue(1); - 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 ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), startValue, TEST_LOCATION ); // Build the animation float durationSeconds(2.0f); @@ -2116,6 +3343,9 @@ int UtcDaliAnimationAnimateByInteger(void) // Start the animation animation.Play(); + // Target value should be retrievable straight away + DALI_TEST_EQUALS( actor.GetProperty< int >( index ), targetValue, TEST_LOCATION ); + bool signalReceived(false); AnimationFinishCheck finishCheck(signalReceived); animation.FinishedSignal().Connect(&application, finishCheck); @@ -2126,7 +3356,7 @@ int UtcDaliAnimationAnimateByInteger(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.GetCurrentProperty< int >( index ), ninetyFivePercentProgress, TEST_LOCATION ); application.SendNotification(); application.Render(static_cast(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/); @@ -2134,17 +3364,17 @@ int UtcDaliAnimationAnimateByInteger(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.GetCurrentProperty< int >( 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.GetCurrentProperty< int >( index ), targetValue, TEST_LOCATION ); application.Render(0); - DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), targetValue, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationAnimateByIntegerAlphaFunction(void) +int UtcDaliAnimationAnimateByIntegerAlphaFunctionP(void) { TestApplication application; @@ -2152,16 +3382,17 @@ int UtcDaliAnimationAnimateByIntegerAlphaFunction(void) // Register an integer property int startValue(1); - 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 ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( 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); + animation.AnimateBy(Property(actor, index), relativeValue, AlphaFunction::EASE_OUT); int ninetyFivePercentProgress(static_cast(startValue + relativeValue*0.95f + 0.5f)); @@ -2180,7 +3411,7 @@ int UtcDaliAnimationAnimateByIntegerAlphaFunction(void) finishCheck.CheckSignalNotReceived(); // The position should have moved more, than with a linear alpha function - int current(actor.GetProperty(index)); + int current( actor.GetCurrentProperty< int >( index ) ); DALI_TEST_CHECK( current > ninetyFivePercentProgress ); application.SendNotification(); @@ -2189,17 +3420,17 @@ int UtcDaliAnimationAnimateByIntegerAlphaFunction(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.GetCurrentProperty< int >( 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.GetCurrentProperty< int >( index ), targetValue, TEST_LOCATION ); application.Render(0); - DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), targetValue, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationAnimateByIntegerTimePeriod(void) +int UtcDaliAnimationAnimateByIntegerTimePeriodP(void) { TestApplication application; @@ -2207,9 +3438,10 @@ int UtcDaliAnimationAnimateByIntegerTimePeriod(void) // Register an integer property int startValue(10); - 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 ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), startValue, TEST_LOCATION ); // Build the animation float durationSeconds(1.0f); @@ -2234,7 +3466,7 @@ int UtcDaliAnimationAnimateByIntegerTimePeriod(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.GetCurrentProperty< int >( index ), startValue, TEST_LOCATION ); application.SendNotification(); application.Render(static_cast(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */); @@ -2242,7 +3474,7 @@ int UtcDaliAnimationAnimateByIntegerTimePeriod(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.GetCurrentProperty< int >( 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*/); @@ -2250,17 +3482,17 @@ int UtcDaliAnimationAnimateByIntegerTimePeriod(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.GetCurrentProperty< int >( 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.GetCurrentProperty< int >( index ), targetValue, TEST_LOCATION ); application.Render(0); - DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), targetValue, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationAnimateByIntegerAlphaFunctionTimePeriod(void) +int UtcDaliAnimationAnimateByIntegerAlphaFunctionTimePeriodP(void) { TestApplication application; @@ -2268,9 +3500,10 @@ int UtcDaliAnimationAnimateByIntegerAlphaFunctionTimePeriod(void) // Register an integer property int startValue(10); - 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 ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), startValue, TEST_LOCATION ); // Build the animation float durationSeconds(1.0f); @@ -2280,7 +3513,7 @@ int UtcDaliAnimationAnimateByIntegerAlphaFunctionTimePeriod(void) float delay = 0.5f; animation.AnimateBy(Property(actor, index), relativeValue, - AlphaFunctions::Linear, + AlphaFunction::LINEAR, TimePeriod(delay, durationSeconds - delay)); // Start the animation @@ -2296,7 +3529,7 @@ int UtcDaliAnimationAnimateByIntegerAlphaFunctionTimePeriod(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.GetCurrentProperty< int >( index ), startValue, TEST_LOCATION ); application.SendNotification(); application.Render(static_cast(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */); @@ -2304,7 +3537,7 @@ int UtcDaliAnimationAnimateByIntegerAlphaFunctionTimePeriod(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.GetCurrentProperty< int >( 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*/); @@ -2312,17 +3545,55 @@ int UtcDaliAnimationAnimateByIntegerAlphaFunctionTimePeriod(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.GetCurrentProperty< int >( 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.GetCurrentProperty< int >( index ), targetValue, TEST_LOCATION ); application.Render(0); - DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), targetValue, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliAnimationAnimateByQuaternionP(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + + // Register a quaternion property + const Quaternion startValue( Degree( 90 ), Vector3::XAXIS ); + Property::Index index = actor.RegisterProperty( "testProperty", startValue ); + Stage::GetCurrent().Add(actor); + DALI_TEST_CHECK( actor.GetProperty< Quaternion >(index) == startValue ); + DALI_TEST_CHECK( actor.GetCurrentProperty< Quaternion >( index ) == startValue ); + + // Build the animation + float durationSeconds(2.0f); + Animation animation = Animation::New(durationSeconds); + const Quaternion relativeValue( Degree( 90 ), Vector3::ZAXIS ); + const Quaternion finalValue( startValue * relativeValue ); + animation.AnimateBy(Property(actor, index), relativeValue); + + DALI_TEST_CHECK( actor.GetProperty< Quaternion >(index) == startValue ); + DALI_TEST_CHECK( actor.GetCurrentProperty< Quaternion >( index ) == startValue ); + + // Start the animation + animation.Play(); + + // Target value should be retrievable straight away + DALI_TEST_CHECK( actor.GetProperty< Quaternion >(index) == finalValue ); + + application.SendNotification(); + application.Render( 2000 ); // animation complete + + DALI_TEST_CHECK( actor.GetProperty< Quaternion >(index) == finalValue ); + DALI_TEST_CHECK( actor.GetCurrentProperty< Quaternion >( index ) == finalValue ); + END_TEST; } -int UtcDaliAnimationAnimateByVector2(void) +int UtcDaliAnimationAnimateByVector2P(void) { TestApplication application; @@ -2330,9 +3601,10 @@ int UtcDaliAnimationAnimateByVector2(void) // Register a Vector2 property Vector2 startValue(10.0f, 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 ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), startValue, TEST_LOCATION ); // Build the animation float durationSeconds(2.0f); @@ -2346,6 +3618,9 @@ int UtcDaliAnimationAnimateByVector2(void) // Start the animation animation.Play(); + // Target value should be retrievable straight away + DALI_TEST_EQUALS( actor.GetProperty< Vector2 >( index ), targetValue, TEST_LOCATION ); + bool signalReceived(false); AnimationFinishCheck finishCheck(signalReceived); animation.FinishedSignal().Connect(&application, finishCheck); @@ -2356,7 +3631,7 @@ int UtcDaliAnimationAnimateByVector2(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.GetCurrentProperty< Vector2 >( index ), ninetyFivePercentProgress, TEST_LOCATION ); application.SendNotification(); application.Render(static_cast(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/); @@ -2364,17 +3639,17 @@ int UtcDaliAnimationAnimateByVector2(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.GetCurrentProperty< Vector2 >( 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.GetCurrentProperty< Vector2 >( index ), targetValue, TEST_LOCATION ); application.Render(0); - DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), targetValue, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationAnimateByVector2AlphaFunction(void) +int UtcDaliAnimationAnimateByVector2AlphaFunctionP(void) { TestApplication application; @@ -2382,16 +3657,17 @@ int UtcDaliAnimationAnimateByVector2AlphaFunction(void) // Register a Vector2 property Vector2 startValue(100.0f, 100.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 ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( 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); + animation.AnimateBy(Property(actor, index), relativeValue, AlphaFunction::EASE_OUT); Vector2 ninetyFivePercentProgress(startValue + relativeValue*0.95f); @@ -2410,7 +3686,7 @@ int UtcDaliAnimationAnimateByVector2AlphaFunction(void) finishCheck.CheckSignalNotReceived(); // The position should have moved more, than with a linear alpha function - Vector2 current(actor.GetProperty(index)); + Vector2 current( actor.GetCurrentProperty< Vector2 >( index ) ); DALI_TEST_CHECK( current.x < ninetyFivePercentProgress.x ); DALI_TEST_CHECK( current.y < ninetyFivePercentProgress.y ); @@ -2420,17 +3696,17 @@ int UtcDaliAnimationAnimateByVector2AlphaFunction(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.GetCurrentProperty< Vector2 >( 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.GetCurrentProperty< Vector2 >( index ), targetValue, TEST_LOCATION ); application.Render(0); - DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), targetValue, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationAnimateByVector2TimePeriod(void) +int UtcDaliAnimationAnimateByVector2TimePeriodP(void) { TestApplication application; @@ -2438,9 +3714,10 @@ int UtcDaliAnimationAnimateByVector2TimePeriod(void) // Register a Vector2 property Vector2 startValue(10.0f, 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 ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), startValue, TEST_LOCATION ); // Build the animation float durationSeconds(1.0f); @@ -2465,7 +3742,7 @@ int UtcDaliAnimationAnimateByVector2TimePeriod(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.GetCurrentProperty< Vector2 >( index ), startValue, TEST_LOCATION ); application.SendNotification(); application.Render(static_cast(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */); @@ -2473,7 +3750,7 @@ int UtcDaliAnimationAnimateByVector2TimePeriod(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.GetCurrentProperty< Vector2 >( index ), startValue+(relativeValue*0.5f), TEST_LOCATION ); application.SendNotification(); application.Render(static_cast(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/); @@ -2481,17 +3758,17 @@ int UtcDaliAnimationAnimateByVector2TimePeriod(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.GetCurrentProperty< Vector2 >( 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.GetCurrentProperty< Vector2 >( index ), targetValue, TEST_LOCATION ); application.Render(0); - DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), targetValue, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationAnimateByVector2AlphaFunctionTimePeriod(void) +int UtcDaliAnimationAnimateByVector2AlphaFunctionTimePeriodP(void) { TestApplication application; @@ -2499,9 +3776,10 @@ int UtcDaliAnimationAnimateByVector2AlphaFunctionTimePeriod(void) // Register a Vector2 property Vector2 startValue(5.0f, 5.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 ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), startValue, TEST_LOCATION ); // Build the animation float durationSeconds(1.0f); @@ -2511,7 +3789,7 @@ int UtcDaliAnimationAnimateByVector2AlphaFunctionTimePeriod(void) float delay = 0.5f; animation.AnimateBy(Property(actor, index), relativeValue, - AlphaFunctions::Linear, + AlphaFunction::LINEAR, TimePeriod(delay, durationSeconds - delay)); // Start the animation @@ -2527,7 +3805,7 @@ int UtcDaliAnimationAnimateByVector2AlphaFunctionTimePeriod(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.GetCurrentProperty< Vector2 >( index ), startValue, TEST_LOCATION ); application.SendNotification(); application.Render(static_cast(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */); @@ -2535,7 +3813,7 @@ int UtcDaliAnimationAnimateByVector2AlphaFunctionTimePeriod(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.GetCurrentProperty< Vector2 >( index ), startValue+(relativeValue*0.5f), TEST_LOCATION ); application.SendNotification(); application.Render(static_cast(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/); @@ -2543,17 +3821,17 @@ int UtcDaliAnimationAnimateByVector2AlphaFunctionTimePeriod(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.GetCurrentProperty< Vector2 >( 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.GetCurrentProperty< Vector2 >( index ), targetValue, TEST_LOCATION ); application.Render(0); - DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), targetValue, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationAnimateByVector3(void) +int UtcDaliAnimationAnimateByVector3P(void) { TestApplication application; @@ -2561,9 +3839,10 @@ int UtcDaliAnimationAnimateByVector3(void) // Register a Vector3 property Vector3 startValue(10.0f, 10.0f, 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 ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), startValue, TEST_LOCATION ); // Build the animation float durationSeconds(2.0f); @@ -2577,6 +3856,9 @@ int UtcDaliAnimationAnimateByVector3(void) // Start the animation animation.Play(); + // Target value should be retrievable straight away + DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( index ), targetValue, TEST_LOCATION ); + bool signalReceived(false); AnimationFinishCheck finishCheck(signalReceived); animation.FinishedSignal().Connect(&application, finishCheck); @@ -2587,7 +3869,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_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), ninetyFivePercentProgress, TEST_LOCATION ); application.SendNotification(); application.Render(static_cast(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/); @@ -2595,17 +3877,17 @@ 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_EQUALS( actor.GetCurrentProperty< Vector3 >( 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.GetCurrentProperty< Vector3 >( index ), targetValue, TEST_LOCATION ); application.Render(0); - DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), targetValue, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationAnimateByVector3AlphaFunction(void) +int UtcDaliAnimationAnimateByVector3AlphaFunctionP(void) { TestApplication application; @@ -2613,16 +3895,17 @@ int UtcDaliAnimationAnimateByVector3AlphaFunction(void) // Register a Vector3 property Vector3 startValue(100.0f, 100.0f, 100.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 ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( 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); + animation.AnimateBy(Property(actor, index), relativeValue, AlphaFunction::EASE_OUT); Vector3 ninetyFivePercentProgress(startValue + relativeValue*0.95f); @@ -2641,7 +3924,7 @@ int UtcDaliAnimationAnimateByVector3AlphaFunction(void) finishCheck.CheckSignalNotReceived(); // The position should have moved more, than with a linear alpha function - Vector3 current(actor.GetProperty(index)); + Vector3 current(actor.GetCurrentProperty< Vector3 >( index )); DALI_TEST_CHECK( current.x < ninetyFivePercentProgress.x ); DALI_TEST_CHECK( current.y < ninetyFivePercentProgress.y ); DALI_TEST_CHECK( current.z < ninetyFivePercentProgress.z ); @@ -2652,17 +3935,17 @@ 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_EQUALS( actor.GetCurrentProperty< Vector3 >( 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.GetCurrentProperty< Vector3 >( index ), targetValue, TEST_LOCATION ); application.Render(0); - DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), targetValue, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationAnimateByVector3TimePeriod(void) +int UtcDaliAnimationAnimateByVector3TimePeriodP(void) { TestApplication application; @@ -2670,9 +3953,10 @@ int UtcDaliAnimationAnimateByVector3TimePeriod(void) // Register a Vector3 property Vector3 startValue(10.0f, 10.0f, 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 ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), startValue, TEST_LOCATION ); // Build the animation float durationSeconds(1.0f); @@ -2697,7 +3981,7 @@ int UtcDaliAnimationAnimateByVector3TimePeriod(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.GetCurrentProperty< Vector3 >( index ), startValue, TEST_LOCATION ); application.SendNotification(); application.Render(static_cast(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */); @@ -2705,7 +3989,7 @@ int UtcDaliAnimationAnimateByVector3TimePeriod(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.GetCurrentProperty< Vector3 >( index ), startValue+(relativeValue*0.5f), TEST_LOCATION ); application.SendNotification(); application.Render(static_cast(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/); @@ -2713,17 +3997,17 @@ int UtcDaliAnimationAnimateByVector3TimePeriod(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.GetCurrentProperty< Vector3 >( 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.GetCurrentProperty< Vector3 >( index ), targetValue, TEST_LOCATION ); application.Render(0); - DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), targetValue, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationAnimateByVector3AlphaFunctionTimePeriod(void) +int UtcDaliAnimationAnimateByVector3AlphaFunctionTimePeriodP(void) { TestApplication application; @@ -2731,9 +4015,10 @@ int UtcDaliAnimationAnimateByVector3AlphaFunctionTimePeriod(void) // Register a Vector3 property Vector3 startValue(5.0f, 5.0f, 5.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 ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), startValue, TEST_LOCATION ); // Build the animation float durationSeconds(1.0f); @@ -2743,7 +4028,7 @@ int UtcDaliAnimationAnimateByVector3AlphaFunctionTimePeriod(void) float delay = 0.5f; animation.AnimateBy(Property(actor, index), relativeValue, - AlphaFunctions::Linear, + AlphaFunction::LINEAR, TimePeriod(delay, durationSeconds - delay)); // Start the animation @@ -2759,7 +4044,7 @@ int UtcDaliAnimationAnimateByVector3AlphaFunctionTimePeriod(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.GetCurrentProperty< Vector3 >( index ), startValue, TEST_LOCATION ); application.SendNotification(); application.Render(static_cast(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */); @@ -2767,7 +4052,7 @@ int UtcDaliAnimationAnimateByVector3AlphaFunctionTimePeriod(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.GetCurrentProperty< Vector3 >( index ), startValue+(relativeValue*0.5f), TEST_LOCATION ); application.SendNotification(); application.Render(static_cast(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/); @@ -2775,17 +4060,17 @@ int UtcDaliAnimationAnimateByVector3AlphaFunctionTimePeriod(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.GetCurrentProperty< Vector3 >( 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.GetCurrentProperty< Vector3 >( index ), targetValue, TEST_LOCATION ); application.Render(0); - DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), targetValue, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationAnimateByVector4(void) +int UtcDaliAnimationAnimateByVector4P(void) { TestApplication application; @@ -2793,9 +4078,10 @@ int UtcDaliAnimationAnimateByVector4(void) // Register a Vector4 property Vector4 startValue(10.0f, 10.0f, 10.0f, 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 ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), startValue, TEST_LOCATION ); // Build the animation float durationSeconds(2.0f); @@ -2809,6 +4095,9 @@ int UtcDaliAnimationAnimateByVector4(void) // Start the animation animation.Play(); + // Target value should be retrievable straight away + DALI_TEST_EQUALS( actor.GetProperty< Vector4 >( index ), targetValue, TEST_LOCATION ); + bool signalReceived(false); AnimationFinishCheck finishCheck(signalReceived); animation.FinishedSignal().Connect(&application, finishCheck); @@ -2819,7 +4108,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.GetCurrentProperty< Vector4 >( index ), ninetyFivePercentProgress, TEST_LOCATION ); application.SendNotification(); application.Render(static_cast(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/); @@ -2827,17 +4116,17 @@ 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.GetCurrentProperty< Vector4 >( 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.GetCurrentProperty< Vector4 >( index ), targetValue, TEST_LOCATION ); application.Render(0); - DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), targetValue, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationAnimateByVector4AlphaFunction(void) +int UtcDaliAnimationAnimateByVector4AlphaFunctionP(void) { TestApplication application; @@ -2845,16 +4134,17 @@ int UtcDaliAnimationAnimateByVector4AlphaFunction(void) // Register a Vector4 property Vector4 startValue(100.0f, 100.0f, 100.0f, 100.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 ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( 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); + animation.AnimateBy(Property(actor, index), relativeValue, AlphaFunction::EASE_OUT); Vector4 ninetyFivePercentProgress(startValue + relativeValue*0.95f); @@ -2873,7 +4163,7 @@ int UtcDaliAnimationAnimateByVector4AlphaFunction(void) finishCheck.CheckSignalNotReceived(); // The position should have moved more, than with a linear alpha function - Vector4 current(actor.GetProperty(index)); + Vector4 current( actor.GetCurrentProperty< Vector4 >( index ) ); DALI_TEST_CHECK( current.x < ninetyFivePercentProgress.x ); DALI_TEST_CHECK( current.y < ninetyFivePercentProgress.y ); DALI_TEST_CHECK( current.z < ninetyFivePercentProgress.z ); @@ -2885,17 +4175,17 @@ 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.GetCurrentProperty< Vector4 >( 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.GetCurrentProperty< Vector4 >( index ), targetValue, TEST_LOCATION ); application.Render(0); - DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), targetValue, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationAnimateByVector4TimePeriod(void) +int UtcDaliAnimationAnimateByVector4TimePeriodP(void) { TestApplication application; @@ -2903,9 +4193,10 @@ int UtcDaliAnimationAnimateByVector4TimePeriod(void) // Register a Vector4 property Vector4 startValue(10.0f, 10.0f, 10.0f, 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 ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), startValue, TEST_LOCATION ); // Build the animation float durationSeconds(1.0f); @@ -2929,228 +4220,57 @@ 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 ); - - 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*/); - - // 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 UtcDaliAnimationAnimateByVector4AlphaFunctionTimePeriod(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 ); - 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); - Vector4 targetValue(10.0f, 10.0f, 10.0f, 10.0f); - Vector4 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); - 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.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*/); - - // 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 UtcDaliAnimationAnimateByActorPosition(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.AnimateBy(Property(actor, Actor::Property::Position), relativePosition); - - Vector3 ninetyFivePercentProgress(startPosition + relativePosition*0.95f); - - // Start the animation - animation.Play(); - - bool signalReceived(false); - AnimationFinishCheck finishCheck(signalReceived); - animation.FinishedSignal().Connect(&application, finishCheck); - - application.SendNotification(); - application.Render(static_cast(durationSeconds*950.0f)/* 95% progress */); - - // We didn't expect the animation to finish yet - application.SendNotification(); - finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetCurrentPosition(), ninetyFivePercentProgress, TEST_LOCATION ); - - application.SendNotification(); - application.Render(static_cast(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 ); - - // 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 UtcDaliAnimationAnimateByActorPositionAlphaFunction(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.AnimateBy(Property(actor, Actor::Property::Position), 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); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( 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(); - - // 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.GetCurrentProperty< Vector4 >( 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_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( 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.GetCurrentProperty< Vector4 >( index ), targetValue, TEST_LOCATION ); application.Render(0); - DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), targetValue, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationAnimateByActorPositionTimePeriod(void) +int UtcDaliAnimationAnimateByVector4AlphaFunctionTimePeriodP(void) { TestApplication application; Actor actor = Actor::New(); - Vector3 startPosition(10.0f, 10.0f, 10.0f); - actor.SetPosition(startPosition); + + // 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); - application.SendNotification(); - application.Render(0); - DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( 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); + Vector4 targetValue(10.0f, 10.0f, 10.0f, 10.0f); + Vector4 relativeValue(targetValue - startValue); float delay = 0.5f; - animation.AnimateBy(Property(actor, Actor::Property::Position), - relativePosition, + animation.AnimateBy(Property(actor, index), + relativeValue, + AlphaFunction::LINEAR, TimePeriod(delay, durationSeconds - delay)); - Vector3 ninetyFivePercentProgress(startPosition + relativePosition*0.95f); - // Start the animation animation.Play(); @@ -3164,25 +4284,33 @@ 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.GetCurrentProperty< Vector4 >( 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.GetCurrentProperty< Vector4 >( 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(), targetPosition, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( 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.GetCurrentProperty< Vector4 >( index ), targetValue, TEST_LOCATION ); application.Render(0); - DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), targetValue, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationAnimateByActorPositionAlphaFunctionTimePeriod(void) +int UtcDaliAnimationAnimateByActorPositionP(void) { TestApplication application; @@ -3199,31 +4327,30 @@ int UtcDaliAnimationAnimateByActorPositionAlphaFunctionTimePeriod(void) Animation animation = Animation::New(durationSeconds); Vector3 targetPosition(20.0f, 20.0f, 20.0f); Vector3 relativePosition(targetPosition - startPosition); - float delay = 0.5f; - animation.AnimateBy(Property(actor, Actor::Property::Position), - relativePosition, - AlphaFunctions::Linear, - TimePeriod(delay, durationSeconds - delay)); + animation.AnimateBy(Property(actor, Actor::Property::POSITION), relativePosition); Vector3 ninetyFivePercentProgress(startPosition + relativePosition*0.95f); // Start the animation animation.Play(); + // Target value should be retrievable straight away + DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), targetPosition, 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*950.0f)/* 95% progress */); // 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(), 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(); @@ -3238,105 +4365,65 @@ int UtcDaliAnimationAnimateByActorPositionAlphaFunctionTimePeriod(void) END_TEST; } -int UtcDaliAnimationAnimateToBoolean(void) +int UtcDaliAnimationAnimateByActorPositionComponentsP(void) { TestApplication application; Actor actor = Actor::New(); - - // Register a boolean property - const bool startValue(false); - Property::Index index = actor.RegisterProperty( "test-property", startValue ); Stage::GetCurrent().Add(actor); - DALI_TEST_CHECK( actor.GetProperty(index) == startValue ); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, 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, index), targetValue); + Vector3 targetPosition(200.0f, 300.0f, 400.0f); + Vector3 relativePosition(targetPosition - Vector3::ZERO); + animation.AnimateBy( Property( actor, Actor::Property::POSITION_X ), relativePosition.x ); + animation.AnimateBy( Property( actor, Actor::Property::POSITION_Y ), relativePosition.y ); + animation.AnimateBy( Property( actor, Actor::Property::POSITION_Z ), relativePosition.z ); - // 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_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); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), Vector3::ZERO, TEST_LOCATION ); // Start the animation animation.Play(); - finishCheck.Reset(); - animation.FinishedSignal().Connect(&application, finishCheck); - - application.SendNotification(); - application.Render(static_cast(durationSeconds*950.0f)/* 95% progress */); + // Target value should be retrievable straight away + DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), targetPosition, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_X ), targetPosition.x, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_Y ), targetPosition.y, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_Z ), targetPosition.z, TEST_LOCATION ); - // We didn't expect the animation to finish yet - application.SendNotification(); - finishCheck.CheckSignalNotReceived(); - DALI_TEST_CHECK( actor.GetProperty(index) == targetValue ); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION ); // Not changed yet application.SendNotification(); - application.Render(static_cast(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/); + application.Render( 1000 ); // 1 second progress - // 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 ); - application.Render(0); - DALI_TEST_CHECK( actor.GetProperty(index) == finalValue ); END_TEST; } -int UtcDaliAnimationAnimateToBooleanAlphaFunction(void) +int UtcDaliAnimationAnimateByActorPositionAlphaFunctionP(void) { TestApplication application; Actor actor = Actor::New(); - - // Register a boolean property - const bool startValue(false); - 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_CHECK( actor.GetProperty(index) == startValue ); + 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); - const bool 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); + + Vector3 ninetyFivePercentProgress(startPosition + relativePosition*0.95f); // Start the animation animation.Play(); @@ -3351,40 +4438,12 @@ int UtcDaliAnimationAnimateToBooleanAlphaFunction(void) // 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); - - 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 ); + // 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 ); application.SendNotification(); application.Render(static_cast(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/); @@ -3392,36 +4451,39 @@ int UtcDaliAnimationAnimateToBooleanAlphaFunction(void) // 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( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION ); application.Render(0); - DALI_TEST_CHECK( actor.GetProperty(index) == finalValue ); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationAnimateToBooleanTimePeriod(void) +int UtcDaliAnimationAnimateByActorPositionTimePeriodP(void) { TestApplication application; Actor actor = Actor::New(); - - // Register a boolean property - bool startValue(false); - 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_CHECK( actor.GetProperty(index) == startValue ); + 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); - bool finalValue( !startValue ); - float animatorDurationSeconds(durationSeconds * 0.5f); - animation.AnimateTo( Property(actor, index), - finalValue, - TimePeriod( animatorDurationSeconds ) ); + Vector3 targetPosition(20.0f, 20.0f, 20.0f); + Vector3 relativePosition(targetPosition - startPosition); + float delay = 0.5f; + animation.AnimateBy(Property(actor, Actor::Property::POSITION), + relativePosition, + TimePeriod(delay, durationSeconds - delay)); + + Vector3 ninetyFivePercentProgress(startPosition + relativePosition*0.95f); // Start the animation animation.Play(); @@ -3431,60 +4493,53 @@ 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 ); - - application.SendNotification(); - 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 ); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION ); application.SendNotification(); - application.Render(static_cast(animatorDurationSeconds*1000.0f)/*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_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( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION ); application.Render(0); - DALI_TEST_CHECK( actor.GetProperty(index) == finalValue ); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationAnimateToBooleanAlphaFunctionTimePeriod(void) +int UtcDaliAnimationAnimateByActorPositionAlphaFunctionTimePeriodP(void) { TestApplication application; Actor actor = Actor::New(); - - // Register a boolean property - bool startValue(false); - 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_CHECK( actor.GetProperty(index) == startValue ); + 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); - bool finalValue( !startValue ); - float animatorDurationSeconds(durationSeconds * 0.5f); - animation.AnimateTo( Property(actor, index), - finalValue, - AlphaFunctions::Linear, - TimePeriod( animatorDurationSeconds ) ); + Vector3 targetPosition(20.0f, 20.0f, 20.0f); + Vector3 relativePosition(targetPosition - startPosition); + float delay = 0.5f; + 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(); @@ -3494,105 +4549,107 @@ 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*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(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 ); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION ); application.SendNotification(); - application.Render(static_cast(animatorDurationSeconds*1000.0f)/*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_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( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION ); application.Render(0); - DALI_TEST_CHECK( actor.GetProperty(index) == finalValue ); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationAnimateToFloat(void) +int UtcDaliAnimationAnimateByActorOrientationP1(void) { TestApplication application; Actor actor = Actor::New(); - - // Register a float property - float startValue(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(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); + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + Degree relativeRotationDegrees(360.0f); + Radian relativeRotationRadians(relativeRotationDegrees); + animation.AnimateBy( Property( actor, Actor::Property::ORIENTATION ), Quaternion( relativeRotationRadians, Vector3::YAXIS ) ); // Start the animation animation.Play(); + // Target value should be retrievable straight away + DALI_TEST_EQUALS( actor.GetProperty< Quaternion >( Actor::Property::ORIENTATION ), Quaternion(relativeRotationRadians, Vector3::YAXIS), TEST_LOCATION ); + 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*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 UtcDaliAnimationAnimateToFloatAlphaFunction(void) +int UtcDaliAnimationAnimateByActorOrientationP2(void) { TestApplication application; - Actor actor = Actor::New(); + tet_printf("Testing that rotation angle > 360 performs full rotations\n"); - // Register a float property - float startValue(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); - float targetValue(90.0f); - float relativeValue(targetValue - startValue); - animation.AnimateTo(Property(actor, index), targetValue, AlphaFunctions::EaseOut); + Degree relativeRotationDegrees(710.0f); + Radian relativeRotationRadians(relativeRotationDegrees); - float ninetyFivePercentProgress(startValue + relativeValue*0.95f); + animation.AnimateBy( Property( actor, Actor::Property::ORIENTATION ), AngleAxis( relativeRotationRadians, Vector3::ZAXIS ) ); // Start the animation animation.Play(); @@ -3602,47 +4659,60 @@ int UtcDaliAnimationAnimateToFloatAlphaFunction(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 - float current(actor.GetProperty(index)); - DALI_TEST_CHECK( current > ninetyFivePercentProgress ); + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f)/* 50% 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.GetCurrentOrientation(), Quaternion(relativeRotationRadians * 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(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 UtcDaliAnimationAnimateToFloatTimePeriod(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 float property - float startValue(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); - float targetValue(30.0f); - float 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(); @@ -3652,20 +4722,28 @@ int UtcDaliAnimationAnimateToFloatTimePeriod(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.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.GetProperty(index), startValue+(relativeValue*0.5f), TEST_LOCATION ); + 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*/); @@ -3673,32 +4751,27 @@ 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.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 UtcDaliAnimationAnimateToFloatAlphaFunctionTimePeriod(void) + +int UtcDaliAnimationAnimateByActorOrientationAlphaFunctionP(void) { TestApplication application; Actor actor = Actor::New(); - - // Register a float property - float startValue(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); - float targetValue(30.0f); - float relativeValue(targetValue - startValue); - float delay = 0.5f; - animation.AnimateTo(Property(actor, index), - 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(); @@ -3708,20 +4781,28 @@ int UtcDaliAnimationAnimateToFloatAlphaFunctionTimePeriod(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.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.GetProperty(index), startValue+(relativeValue*0.5f), TEST_LOCATION ); + 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*/); @@ -3729,30 +4810,27 @@ 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.GetCurrentOrientation(), Quaternion(relativeRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationAnimateToInteger(void) +int UtcDaliAnimationAnimateByActorOrientationAlphaFunctionTimePeriodP(void) { TestApplication application; Actor actor = Actor::New(); - - // Register an integer property - int startValue(10); - 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); - int targetValue(50); - int relativeValue(targetValue - startValue); - animation.AnimateTo(Property(actor, "test-property"), targetValue); - - int ninetyFivePercentProgress(static_cast(startValue + relativeValue*0.95f + 0.5f)); + 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(); @@ -3762,456 +4840,405 @@ int UtcDaliAnimationAnimateToInteger(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 ); + 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*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(); + 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)/* 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 UtcDaliAnimationAnimateToIntegerAlphaFunction(void) +int UtcDaliAnimationAnimateByActorScaleP(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 ); + DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, 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); + 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 ) ); - int ninetyFivePercentProgress(static_cast(startValue + relativeValue*0.95f + 0.5f)); + Vector3 ninetyNinePercentProgress(Vector3::ONE + relativeScale*0.99f); // Start the animation animation.Play(); + // Target value should be retrievable straight away + DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SCALE ), targetScale, TEST_LOCATION ); + 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*990.0f)/* 99% 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 - int current(actor.GetProperty(index)); - DALI_TEST_CHECK( current > ninetyFivePercentProgress ); + 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 ); - END_TEST; -} + DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION ); -int UtcDaliAnimationAnimateToIntegerTimePeriod(void) -{ - TestApplication application; + // Reset everything + finishCheck.Reset(); + actor.SetScale(Vector3::ONE); + application.SendNotification(); + application.Render(0); + DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION ); - Actor actor = Actor::New(); + // 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(); - // 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 ); + application.SendNotification(); + application.Render(static_cast(durationSeconds*990.0f)/* 99% progress */); - // Build the animation - float durationSeconds(1.0f); - Animation animation = Animation::New(durationSeconds); - int targetValue(30); - int relativeValue(targetValue - startValue); - float delay = 0.5f; - animation.AnimateTo(Property(actor, index), - targetValue, - TimePeriod(delay, durationSeconds - delay)); + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); - // Start the animation - animation.Play(); + // 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 ); - bool signalReceived(false); - AnimationFinishCheck finishCheck(signalReceived); - animation.FinishedSignal().Connect(&application, finishCheck); + application.SendNotification(); + application.Render(static_cast(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/); + // We did expect the animation to finish application.SendNotification(); - application.Render(static_cast(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION ); - // We didn't expect the animation to finish yet + // Reset everything + finishCheck.Reset(); + actor.SetScale(Vector3::ONE); application.SendNotification(); - finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + 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*250.0f)/* 75% animation progress, 50% 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_EQUALS( actor.GetProperty(index), static_cast(startValue+(relativeValue*0.5f)+0.5f), 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.GetProperty(index), targetValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationAnimateToIntegerAlphaFunctionTimePeriod(void) +int UtcDaliAnimationAnimateByActorScaleComponentsP(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 ); + DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, 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.AnimateTo(Property(actor, index), - targetValue, - AlphaFunctions::Linear, - TimePeriod(delay, durationSeconds - delay)); + Vector3 targetScale(2.0f, 3.0f, 4.0f); + Vector3 relativeScale(targetScale - Vector3::ONE); + animation.AnimateBy( Property( actor, Actor::Property::SCALE_X ), relativeScale.x ); + animation.AnimateBy( Property( actor, Actor::Property::SCALE_Y ), relativeScale.y ); + animation.AnimateBy( Property( actor, Actor::Property::SCALE_Z ), relativeScale.z ); + + DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SCALE ), Vector3::ONE, TEST_LOCATION ); // 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.GetProperty(index), startValue, TEST_LOCATION ); + // Target value should be retrievable straight away + DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SCALE ), targetScale, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SCALE_X ), targetScale.x, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SCALE_Y ), targetScale.y, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SCALE_Z ), targetScale.z, TEST_LOCATION ); - application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */); + DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION ); // Not changed yet - // 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.Render( 1000 ); // 1 second progress - application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/); + DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, 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 UtcDaliAnimationAnimateToVector2(void) +int UtcDaliAnimationAnimateByActorColorP(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 ); Stage::GetCurrent().Add(actor); - DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, 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); + Vector4 targetColor( 0.5f, 0.75f, 0.8f, 0.1f ); + Vector4 relativeColor( targetColor - Color::WHITE ); + animation.AnimateBy( Property( actor, Actor::Property::COLOR ), relativeColor ); - Vector2 ninetyFivePercentProgress(startValue + relativeValue*0.95f); + DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty< Vector4 >( Actor::Property::COLOR ), Color::WHITE, TEST_LOCATION ); // Start the animation animation.Play(); - bool signalReceived(false); - AnimationFinishCheck finishCheck(signalReceived); - animation.FinishedSignal().Connect(&application, finishCheck); + // Target value should be retrievable straight away + DALI_TEST_EQUALS( actor.GetProperty< Vector4 >( Actor::Property::COLOR ), targetColor, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::COLOR_RED ), targetColor.r, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::COLOR_GREEN ), targetColor.g, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::COLOR_BLUE ), targetColor.b, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::COLOR_ALPHA ), targetColor.a, TEST_LOCATION ); - application.SendNotification(); - application.Render(static_cast(durationSeconds*950.0f)/* 95% progress */); + DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION ); // Not changed yet - // We didn't expect the animation to finish yet application.SendNotification(); - finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetProperty(index), ninetyFivePercentProgress, TEST_LOCATION ); + application.Render( 1000 ); // 1 second progress - application.SendNotification(); - application.Render(static_cast(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/); + DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, 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 UtcDaliAnimationAnimateToVector2AlphaFunction(void) +int UtcDaliAnimationAnimateByActorColorComponentsP(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 ); Stage::GetCurrent().Add(actor); - DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, 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); + Vector4 targetColor( 0.5f, 0.75f, 0.8f, 0.1f ); + Vector4 relativeColor( targetColor - Color::WHITE ); + animation.AnimateBy( Property( actor, Actor::Property::COLOR_RED ), relativeColor.r ); + animation.AnimateBy( Property( actor, Actor::Property::COLOR_GREEN ), relativeColor.g ); + animation.AnimateBy( Property( actor, Actor::Property::COLOR_BLUE ), relativeColor.b ); + animation.AnimateBy( Property( actor, Actor::Property::COLOR_ALPHA ), relativeColor.a ); - Vector2 ninetyFivePercentProgress(startValue + relativeValue*0.95f); + DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty< Vector4 >( Actor::Property::COLOR ), Color::WHITE, TEST_LOCATION ); // Start the animation animation.Play(); - bool signalReceived(false); - AnimationFinishCheck finishCheck(signalReceived); - animation.FinishedSignal().Connect(&application, finishCheck); + // Target value should be retrievable straight away + DALI_TEST_EQUALS( actor.GetProperty< Vector4 >( Actor::Property::COLOR ), targetColor, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::COLOR_RED ), targetColor.r, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::COLOR_GREEN ), targetColor.g, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::COLOR_BLUE ), targetColor.b, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::COLOR_ALPHA ), targetColor.a, TEST_LOCATION ); - application.SendNotification(); - application.Render(static_cast(durationSeconds*950.0f)/* 95% progress */); + DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION ); // Not changed yet - // 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 - Vector2 current(actor.GetProperty(index)); - DALI_TEST_CHECK( current.x > ninetyFivePercentProgress.x ); - DALI_TEST_CHECK( current.y > ninetyFivePercentProgress.y ); + application.Render( 1000 ); // 1 second progress - application.SendNotification(); - application.Render(static_cast(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/); + DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, 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 UtcDaliAnimationAnimateToVector2TimePeriod(void) +int UtcDaliAnimationAnimateByActorSizeP(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 ); + DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION ); // Build the animation float durationSeconds(1.0f); Animation animation = Animation::New(durationSeconds); - Vector2 targetValue(-10.0f, 20.0f); - Vector2 relativeValue(targetValue - startValue); - float delay = 0.5f; - animation.AnimateTo(Property(actor, index), - targetValue, - TimePeriod(delay, durationSeconds - delay)); + Vector3 targetSize( 100.0f, 200.0f, 300.0f ); + Vector3 relativeSize( targetSize - Vector3::ZERO ); + animation.AnimateBy( Property( actor, Actor::Property::SIZE ), relativeSize ); + + DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SIZE ), Vector3::ZERO, TEST_LOCATION ); // 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.GetProperty(index), startValue, TEST_LOCATION ); + // Target value should be retrievable straight away + DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SIZE ), targetSize, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SIZE_WIDTH ), targetSize.width, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SIZE_HEIGHT ), targetSize.height, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SIZE_DEPTH ), targetSize.depth, TEST_LOCATION ); - application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */); + DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION ); // Not changed 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 ); + application.Render( 1000 ); // 1 second progress - application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/); + DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, 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 UtcDaliAnimationAnimateToVector2AlphaFunctionTimePeriod(void) +int UtcDaliAnimationAnimateByActorSizeComponentsP(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 ); + DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, 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.AnimateTo(Property(actor, index), - targetValue, - AlphaFunctions::Linear, - TimePeriod(delay, durationSeconds - delay)); + Vector3 targetSize( 100.0f, 200.0f, 300.0f ); + Vector3 relativeSize( targetSize - Vector3::ZERO ); + animation.AnimateBy( Property( actor, Actor::Property::SIZE_WIDTH ), relativeSize.width ); + animation.AnimateBy( Property( actor, Actor::Property::SIZE_HEIGHT ), relativeSize.height ); + animation.AnimateBy( Property( actor, Actor::Property::SIZE_DEPTH ), relativeSize.depth ); + + DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SIZE ), Vector3::ZERO, TEST_LOCATION ); // 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.GetProperty(index), startValue, TEST_LOCATION ); + // Target value should be retrievable straight away + DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SIZE ), targetSize, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SIZE_WIDTH ), targetSize.width, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SIZE_HEIGHT ), targetSize.height, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SIZE_DEPTH ), targetSize.depth, TEST_LOCATION ); - application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */); + DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION ); // Not changed 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 ); + application.Render( 1000 ); // 1 second progress - application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/); + DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, 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 UtcDaliAnimationAnimateToVector3(void) +int UtcDaliAnimationAnimateByActorVisibilityP(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 ); Stage::GetCurrent().Add(actor); - DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.IsVisible(), true, TEST_LOCATION ); + + actor.SetVisible( false ); + + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS( actor.IsVisible(), false, 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); + bool targetVisibility( true ); + bool relativeVisibility( targetVisibility ); + animation.AnimateBy( Property( actor, Actor::Property::VISIBLE ), relativeVisibility ); - Vector3 ninetyFivePercentProgress(startValue + relativeValue*0.95f); + DALI_TEST_EQUALS( actor.GetProperty< bool >( Actor::Property::VISIBLE ), false, TEST_LOCATION ); // 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 */); + // Target value should be retrievable straight away + DALI_TEST_EQUALS( actor.GetProperty< bool >( Actor::Property::VISIBLE ), targetVisibility, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.IsVisible(), false, TEST_LOCATION ); // Not changed yet - // We didn't expect the animation to finish yet application.SendNotification(); - finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetProperty(index), ninetyFivePercentProgress, TEST_LOCATION ); + application.Render( 1000 ); // 1 second progress - application.SendNotification(); - application.Render(static_cast(durationSeconds*50.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.GetProperty(index), targetValue, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationAnimateToVector3AlphaFunction(void) +int UtcDaliAnimationAnimateToBooleanP(void) { TestApplication application; Actor actor = Actor::New(); - // Register a Vector3 property - Vector3 startValue(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 ); + DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == startValue ); // Build the animation - float durationSeconds(1.0f); + float durationSeconds(2.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); - - Vector3 ninetyFivePercentProgress(startValue + relativeValue*0.95f); + const bool targetValue( !startValue ); + animation.AnimateTo(Property(actor, index), targetValue); // Start the animation animation.Play(); @@ -4226,12 +5253,7 @@ int UtcDaliAnimationAnimateToVector3AlphaFunction(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.GetCurrentProperty< bool >( index ) == startValue ); application.SendNotification(); application.Render(static_cast(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/); @@ -4239,87 +5261,67 @@ int UtcDaliAnimationAnimateToVector3AlphaFunction(void) // We did expect the animation to finish application.SendNotification(); finishCheck.CheckSignalReceived(); - DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); - END_TEST; -} - -int UtcDaliAnimationAnimateToVector3TimePeriod(void) -{ - TestApplication application; + DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == targetValue ); - Actor actor = Actor::New(); - - // Register a Vector3 property - Vector3 startValue(10.0f, 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 ); + // Check that nothing has changed after a couple of buffer swaps + application.Render(0); + DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == targetValue ); + application.Render(0); + DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == targetValue ); - // 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)); + // Repeat with target value "false" + animation = Animation::New(durationSeconds); + const bool finalValue( !targetValue ); + animation.AnimateTo(Property(actor, index), finalValue); // Start the animation animation.Play(); - bool signalReceived(false); - AnimationFinishCheck finishCheck(signalReceived); + finishCheck.Reset(); 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.GetCurrentProperty< bool >( 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, TEST_LOCATION ); + DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue ); + + // Check that nothing has changed after a couple of buffer swaps + application.Render(0); + DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue ); + application.Render(0); + DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue ); END_TEST; } -int UtcDaliAnimationAnimateToVector3AlphaFunctionTimePeriod(void) +int UtcDaliAnimationAnimateToBooleanAlphaFunctionP(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 + 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 ); + DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( 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.AnimateTo(Property(actor, "test-property"), - targetValue, - AlphaFunctions::Linear, - TimePeriod(delay, durationSeconds - delay)); + const bool targetValue( !startValue ); + animation.AnimateTo(Property(actor, "testProperty"), targetValue, AlphaFunction::EASE_OUT); // Start the animation animation.Play(); @@ -4329,57 +5331,83 @@ 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*950.0f)/* 95% 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.GetCurrentProperty< bool >( 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.GetCurrentProperty< bool >( index ) == targetValue ); + + // Check that nothing has changed after a couple of buffer swaps + application.Render(0); + DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == targetValue ); + application.Render(0); + DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( 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*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.GetCurrentProperty< bool >( 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, TEST_LOCATION ); + DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue ); + + // Check that nothing has changed after a couple of buffer swaps + application.Render(0); + DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue ); + application.Render(0); + DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue ); END_TEST; } -int UtcDaliAnimationAnimateToVector3Component(void) +int UtcDaliAnimationAnimateToBooleanTimePeriodP(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 ); + DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == startValue ); // Build the animation - float durationSeconds(1.0f); + float durationSeconds(2.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)); + bool finalValue( !startValue ); + float animatorDurationSeconds(durationSeconds * 0.5f); + animation.AnimateTo( Property(actor, index), + finalValue, + TimePeriod( animatorDurationSeconds ) ); // Start the animation animation.Play(); @@ -4389,51 +5417,61 @@ 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(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.GetCurrentProperty< bool >( 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.GetCurrentProperty< bool >( 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.GetCurrentProperty< bool >( index ) == finalValue ); + + // Check that nothing has changed after a couple of buffer swaps + application.Render(0); + DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue ); + application.Render(0); + DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue ); END_TEST; } -int UtcDaliAnimationAnimateToVector4(void) +int UtcDaliAnimationAnimateToBooleanAlphaFunctionTimePeriodP(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 ); + // 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 ); + DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == startValue ); // Build the animation float durationSeconds(2.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); - - Vector4 ninetyFivePercentProgress(startValue + relativeValue*0.95f); + bool finalValue( !startValue ); + float animatorDurationSeconds(durationSeconds * 0.5f); + animation.AnimateTo( Property(actor, index), + finalValue, + AlphaFunction::LINEAR, + TimePeriod( animatorDurationSeconds ) ); // Start the animation animation.Play(); @@ -4443,43 +5481,60 @@ int UtcDaliAnimationAnimateToVector4(void) animation.FinishedSignal().Connect(&application, finishCheck); application.SendNotification(); - application.Render(static_cast(durationSeconds*950.0f)/* 95% 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), ninetyFivePercentProgress, TEST_LOCATION ); + DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == startValue ); application.SendNotification(); - application.Render(static_cast(durationSeconds*50.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.GetCurrentProperty< bool >( 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.GetCurrentProperty< bool >( index ) == finalValue ); + + // Check that nothing has changed after a couple of buffer swaps + application.Render(0); + DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue ); + application.Render(0); + DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue ); END_TEST; } -int UtcDaliAnimationAnimateToVector4AlphaFunction(void) +int UtcDaliAnimationAnimateToFloatP(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 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 ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), startValue, TEST_LOCATION ); // 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); + float targetValue(50.0f); + float relativeValue(targetValue - startValue); + animation.AnimateTo(Property(actor, "testProperty"), targetValue); - Vector4 ninetyFivePercentProgress(startValue + relativeValue*0.95f); + float ninetyFivePercentProgress(startValue + relativeValue*0.95f); // Start the animation animation.Play(); @@ -4494,13 +5549,7 @@ int UtcDaliAnimationAnimateToVector4AlphaFunction(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 - 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 ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), ninetyFivePercentProgress, TEST_LOCATION ); application.SendNotification(); application.Render(static_cast(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/); @@ -4508,31 +5557,31 @@ 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_EQUALS( actor.GetCurrentProperty< float >( index ), targetValue, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationAnimateToVector4TimePeriod(void) +int UtcDaliAnimationAnimateToFloatAlphaFunctionP(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, VECTOR4_EPSILON, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), startValue, TEST_LOCATION ); // Build the animation float durationSeconds(1.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)); + float targetValue(90.0f); + float relativeValue(targetValue - startValue); + animation.AnimateTo(Property(actor, index), targetValue, AlphaFunction::EASE_OUT); + + float ninetyFivePercentProgress(startValue + relativeValue*0.95f); // Start the animation animation.Play(); @@ -4542,52 +5591,47 @@ 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 ); - - 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), VECTOR4_EPSILON, TEST_LOCATION ); + // The position should have moved more, than with a linear alpha function + float current( actor.GetCurrentProperty< float >( index ) ); + DALI_TEST_CHECK( current > ninetyFivePercentProgress ); 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_EQUALS( actor.GetCurrentProperty< float >( index ), targetValue, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationAnimateToVector4AlphaFunctionTimePeriod(void) +int UtcDaliAnimationAnimateToFloatTimePeriodP(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 ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( 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.AnimateTo(Property(actor, index), targetValue, - AlphaFunctions::Linear, TimePeriod(delay, durationSeconds - delay)); // Start the animation @@ -4603,7 +5647,7 @@ int UtcDaliAnimationAnimateToVector4AlphaFunctionTimePeriod(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.GetCurrentProperty< float >( index ), startValue, TEST_LOCATION ); application.SendNotification(); application.Render(static_cast(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */); @@ -4611,245 +5655,194 @@ int UtcDaliAnimationAnimateToVector4AlphaFunctionTimePeriod(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 ); - - application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), startValue+(relativeValue*0.5f), 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 UtcDaliAnimationAnimateToActorParentOrigin(void) -{ - TestApplication application; - - Actor actor = Actor::New(); - Stage::GetCurrent().Add(actor); - DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::TOP_LEFT, TEST_LOCATION ); - - // Build the animation - float durationSeconds(1.0f); - Animation animation = Animation::New(durationSeconds); - Vector3 targetParentOrigin(ParentOrigin::BOTTOM_RIGHT); - - try - { - animation.AnimateTo( Property(actor, Actor::Property::ParentOrigin), targetParentOrigin ); - } - catch (Dali::DaliException& e) - { - DALI_TEST_PRINT_ASSERT( e ); - DALI_TEST_ASSERT(e, "IsPropertyAnimatable(index)", TEST_LOCATION); - } - END_TEST; -} - -int UtcDaliAnimationAnimateToActorParentOriginX(void) -{ - TestApplication application; - - 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::ParentOriginX), 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::Property::ParentOriginX), targetX ); - } - catch (Dali::DaliException& e) - { - DALI_TEST_PRINT_ASSERT( e ); - DALI_TEST_ASSERT(e, "IsPropertyAnimatable(index)", TEST_LOCATION); - } - END_TEST; -} - -int UtcDaliAnimationAnimateToActorParentOriginY(void) -{ - TestApplication application; - - 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::Property::ParentOriginY), startValue, TEST_LOCATION ); - - // Build the animation - float durationSeconds(1.0f); - Animation animation = Animation::New(durationSeconds); - float targetY(1.0f); - - try - { - animation.AnimateTo( Property(actor, Actor::Property::ParentOriginY), targetY ); - } - catch (Dali::DaliException& e) - { - DALI_TEST_PRINT_ASSERT( e ); - DALI_TEST_ASSERT(e, "IsPropertyAnimatable(index)", TEST_LOCATION); - } - END_TEST; -} - -int UtcDaliAnimationAnimateToActorParentOriginZ(void) -{ - TestApplication application; - - 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::ParentOriginZ), startValue, TEST_LOCATION ); - - // Build the animation - float durationSeconds(1.0f); - Animation animation = Animation::New(durationSeconds); - float targetZ(1.0f); - - try - { - animation.AnimateTo( Property(actor, Actor::Property::ParentOriginZ), targetZ ); - } - catch (Dali::DaliException& e) - { - DALI_TEST_PRINT_ASSERT( e ); - DALI_TEST_ASSERT(e, "IsPropertyAnimatable(index)", TEST_LOCATION); - } - END_TEST; -} - -int UtcDaliAnimationAnimateToActorAnchorPoint(void) -{ - TestApplication application; - - Actor actor = Actor::New(); - Stage::GetCurrent().Add(actor); - DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), AnchorPoint::CENTER, TEST_LOCATION ); - - // Build the animation - float durationSeconds(1.0f); - Animation animation = Animation::New(durationSeconds); - Vector3 targetAnchorPoint(AnchorPoint::TOP_LEFT); - - try - { - animation.AnimateTo( Property(actor, Actor::Property::AnchorPoint), targetAnchorPoint); - } - catch (Dali::DaliException& e) - { - DALI_TEST_PRINT_ASSERT( e ); - DALI_TEST_ASSERT(e, "IsPropertyAnimatable(index)", 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.GetCurrentProperty< float >( index ), targetValue, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationAnimateToActorAnchorPointX(void) +int UtcDaliAnimationAnimateToFloatAlphaFunctionTimePeriodP(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::Property::AnchorPointX), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), startValue, TEST_LOCATION ); // Build the animation float durationSeconds(1.0f); Animation animation = Animation::New(durationSeconds); - float targetX(1.0f); + float targetValue(30.0f); + float relativeValue(targetValue - startValue); + float delay = 0.5f; + animation.AnimateTo(Property(actor, index), + targetValue, + AlphaFunction::LINEAR, + TimePeriod(delay, durationSeconds - delay)); - try - { - animation.AnimateTo( Property(actor, Actor::Property::AnchorPointX), targetX ); - } - catch (Dali::DaliException& e) - { - DALI_TEST_PRINT_ASSERT( e ); - DALI_TEST_ASSERT(e, "IsPropertyAnimatable(index)", TEST_LOCATION); - } + // 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.GetCurrentProperty< float >( 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.GetCurrentProperty< float >( 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.GetCurrentProperty< float >( index ), targetValue, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationAnimateToActorAnchorPointY(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.5f); - DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint().y, startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::AnchorPointY), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), startValue, TEST_LOCATION ); // Build the animation - float durationSeconds(1.0f); + float durationSeconds(2.0f); Animation animation = Animation::New(durationSeconds); - float targetY(0.0f); + int targetValue(50); + int relativeValue(targetValue - startValue); + animation.AnimateTo(Property(actor, "testProperty"), targetValue); - try - { - animation.AnimateTo( Property(actor, Actor::Property::AnchorPointY), targetY ); - } - catch (Dali::DaliException& e) - { - DALI_TEST_PRINT_ASSERT( e ); - DALI_TEST_ASSERT(e, "IsPropertyAnimatable(index)", TEST_LOCATION); - } + int ninetyFivePercentProgress(static_cast(startValue + relativeValue*0.95f + 0.5f)); + + // 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.GetCurrentProperty< int >( 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.GetCurrentProperty< int >( index ), targetValue, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationAnimateToActorAnchorPointZ(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.5f); - DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint().z, startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::AnchorPointZ), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), startValue, TEST_LOCATION ); // Build the animation float durationSeconds(1.0f); Animation animation = Animation::New(durationSeconds); - float targetZ(100.0f); + int targetValue(90); + int relativeValue(targetValue - startValue); + animation.AnimateTo(Property(actor, index), targetValue, AlphaFunction::EASE_OUT); - try - { - animation.AnimateTo( Property(actor, Actor::Property::AnchorPointZ), targetZ ); - } - catch (Dali::DaliException& e) - { - DALI_TEST_PRINT_ASSERT( e ); - DALI_TEST_ASSERT(e, "IsPropertyAnimatable(index)", TEST_LOCATION); - } + int ninetyFivePercentProgress(static_cast(startValue + relativeValue*0.95f + 0.5f)); + + // 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(); + + // The position should have moved more, than with a linear alpha function + int current( actor.GetCurrentProperty< int >( index ) ); + DALI_TEST_CHECK( current > ninetyFivePercentProgress ); + + 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.GetCurrentProperty< int >( index ), targetValue, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationAnimateToActorSize(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); - DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( 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::Property::Size), targetSize ); - - Vector3 ninetyNinePercentProgress(targetSize * 0.99f); + 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(); @@ -4859,107 +5852,156 @@ 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.GetCurrentProperty< int >( 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 didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( 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(), targetSize, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), targetValue, 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 UtcDaliAnimationAnimateToIntegerAlphaFunctionTimePeriodP(void) +{ + TestApplication application; - // Repeat with a different (ease-in) alpha function - animation = Animation::New(durationSeconds); - animation.AnimateTo( Property(actor, Actor::Property::Size), targetSize, AlphaFunctions::EaseIn); - animation.FinishedSignal().Connect(&application, finishCheck); + 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.GetProperty(index), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( 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.AnimateTo(Property(actor, index), + targetValue, + AlphaFunction::LINEAR, + TimePeriod(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*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.GetCurrentProperty< int >( index ), startValue, 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*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.GetCurrentProperty< int >( index ), static_cast(startValue+(relativeValue*0.5f)+0.5f), TEST_LOCATION ); application.SendNotification(); - application.Render(static_cast(durationSeconds*10.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.GetCurrentSize(), targetSize, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), targetValue, 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 UtcDaliAnimationAnimateToVector2P(void) +{ + TestApplication application; - // Repeat with a delay - float delay = 0.5f; - animation = Animation::New(durationSeconds); - animation.AnimateTo( Property(actor, Actor::Property::Size), targetSize, AlphaFunctions::Linear, TimePeriod(delay, durationSeconds - delay)); - animation.FinishedSignal().Connect(&application, finishCheck); + 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); + DALI_TEST_EQUALS( actor.GetProperty< Vector2 >( index ), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), startValue, TEST_LOCATION ); + + // Build the animation + float durationSeconds(2.0f); + Animation animation = Animation::New(durationSeconds); + Vector2 targetValue(50.0f, 50.0f); + Vector2 relativeValue(targetValue - startValue); + animation.AnimateTo(Property(actor, index), targetValue); + + Vector2 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*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.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( 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(), targetSize, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), targetValue, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationAnimateToActorSizeWidth(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.GetCurrentSize().width, startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::SizeWidth), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty< Vector2 >( index ), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), startValue, TEST_LOCATION ); // Build the animation float durationSeconds(1.0f); Animation animation = Animation::New(durationSeconds); - float targetWidth(10.0f); - animation.AnimateTo( Property(actor, Actor::Property::SizeWidth), targetWidth ); + Vector2 targetValue(9000.0f, 9000.0f); + Vector2 relativeValue(targetValue - startValue); + animation.AnimateTo(Property(actor, "testProperty"), targetValue, AlphaFunction::EASE_OUT); - float fiftyPercentProgress(startValue + (targetWidth - startValue)*0.5f); + Vector2 ninetyFivePercentProgress(startValue + relativeValue*0.95f); // Start the animation animation.Play(); @@ -4969,42 +6011,49 @@ 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::Property::SizeWidth), fiftyPercentProgress, TEST_LOCATION ); + + // The position should have moved more, than with a linear alpha function + Vector2 current( actor.GetCurrentProperty< Vector2 >( 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.GetCurrentSize().width, targetWidth, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::SizeWidth), targetWidth, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), targetValue, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationAnimateToActorSizeHeight(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.GetCurrentSize().height, startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::SizeHeight), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty< Vector2 >( index ), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( 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::Property::SizeHeight), targetHeight ); - - float fiftyPercentProgress(startValue + (targetHeight - 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(); @@ -5014,42 +6063,54 @@ int UtcDaliAnimationAnimateToActorSizeHeight(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().height, fiftyPercentProgress, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::SizeHeight), fiftyPercentProgress, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( 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.GetCurrentProperty< Vector2 >( 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().height, targetHeight, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::SizeHeight), targetHeight, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), targetValue, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationAnimateToActorSizeDepth(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); - float startValue(0.0f); - DALI_TEST_EQUALS( actor.GetCurrentSize().depth, startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::SizeDepth), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty< Vector2 >( index ), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( 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::Property::SizeDepth), targetDepth ); - - float fiftyPercentProgress(startValue + (targetDepth - startValue)*0.5f); + 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(); @@ -5059,40 +6120,54 @@ 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, but cached value should be the final one + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetProperty< Vector2 >( index ), targetValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty( 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.GetCurrentSize().depth, fiftyPercentProgress, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::SizeDepth), fiftyPercentProgress, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), startValue+(relativeValue*0.5f), 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.GetCurrentSize().depth, targetDepth, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::SizeDepth), targetDepth, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), targetValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty< Vector2 >( index ), targetValue, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationAnimateToActorPosition(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 ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( 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); - animation.AnimateTo(Property(actor, Actor::Property::Position), targetPosition); + 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(); @@ -5102,42 +6177,44 @@ int UtcDaliAnimationAnimateToActorPosition(void) animation.FinishedSignal().Connect(&application, finishCheck); application.SendNotification(); - application.Render(static_cast(durationSeconds*750.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(); - DALI_TEST_EQUALS( actor.GetCurrentPosition(), seventyFivePercentProgress, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( 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.GetCurrentPosition(), targetPosition, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), targetValue, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationAnimateToActorPositionX(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); - float startValue(0.0f); - DALI_TEST_EQUALS( actor.GetCurrentPosition().x, startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::PositionX), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::PositionY), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::PositionZ), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), 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::PositionX), targetX ); + Vector3 targetValue(9000.0f, 9000.0f, 9000.0f); + Vector3 relativeValue(targetValue - startValue); + animation.AnimateTo(Property(actor, index), targetValue, AlphaFunction::EASE_OUT); - float fiftyPercentProgress(startValue + (targetX - startValue)*0.5f); + Vector3 ninetyFivePercentProgress(startValue + relativeValue*0.95f); // Start the animation animation.Play(); @@ -5147,48 +6224,50 @@ 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::Property::PositionX), fiftyPercentProgress, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::PositionY), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::PositionZ), startValue, TEST_LOCATION ); + + // The position should have moved more, than with a linear alpha function + Vector3 current( actor.GetCurrentProperty< Vector3 >( 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) + 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::Property::PositionX), targetX, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::PositionY), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::PositionZ), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), targetValue, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationAnimateToActorPositionY(void) +int UtcDaliAnimationAnimateToVector3TimePeriodP(void) { TestApplication application; Actor actor = Actor::New(); + + // Register a Vector3 property + Vector3 startValue(10.0f, 10.0f, 10.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::Property::PositionX), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::PositionY), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::PositionZ), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( 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::Property::PositionY), targetY ); - - float fiftyPercentProgress(startValue + (targetY - startValue)*0.5f); + 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(); @@ -5198,48 +6277,54 @@ int UtcDaliAnimationAnimateToActorPositionY(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().y, fiftyPercentProgress, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::PositionX), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::PositionY), fiftyPercentProgress, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::PositionZ), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( 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.GetCurrentProperty< Vector3 >( 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().y, targetY, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::PositionX), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::PositionY), targetY, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::PositionZ), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), targetValue, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationAnimateToActorPositionZ(void) +int UtcDaliAnimationAnimateToVector3AlphaFunctionTimePeriodP(void) { TestApplication application; Actor actor = Actor::New(); + + // Register a Vector3 property + Vector3 startValue(10.0f, 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::Property::PositionX), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::PositionY), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::PositionZ), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( 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::Property::PositionZ), targetZ ); - - float fiftyPercentProgress(startValue + (targetZ - startValue)*0.5f); + 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(); @@ -5249,44 +6334,58 @@ 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::Property::PositionX), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::PositionY), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::PositionZ), fiftyPercentProgress, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( 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.GetCurrentProperty< Vector3 >( 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::Property::PositionX), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::PositionY), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::PositionZ), targetZ, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), targetValue, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationAnimateToActorPositionAlphaFunction(void) +int UtcDaliAnimationAnimateToVector3ComponentP(void) { TestApplication application; Actor actor = Actor::New(); + + // 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.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( 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::Property::Position), targetPosition, AlphaFunctions::EaseIn); - - Vector3 seventyFivePercentProgress(targetPosition * 0.75f); + 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(); @@ -5296,20 +6395,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.GetCurrentProperty< Vector3 >( 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.GetCurrentProperty< Vector3 >( index ), startValue+(relativeValue*0.5f), TEST_LOCATION ); application.SendNotification(); application.Render(static_cast(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/); @@ -5317,28 +6416,31 @@ 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.GetCurrentProperty< Vector3 >( index ), targetValue, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationAnimateToActorPositionTimePeriod(void) +int UtcDaliAnimationAnimateToVector4P(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( "testProperty", startValue ); Stage::GetCurrent().Add(actor); - DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( 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::Property::Position), - targetPosition, - TimePeriod( delay, durationSeconds - delay ) ); + Vector4 targetValue(50.0f, 50.0f, 50.0f, 50.0f); + Vector4 relativeValue(targetValue - startValue); + animation.AnimateTo(Property(actor, index), targetValue); - Vector3 seventyFivePercentProgress(targetPosition * 0.75f); + Vector4 ninetyFivePercentProgress(startValue + relativeValue*0.95f); // Start the animation animation.Play(); @@ -5348,50 +6450,44 @@ 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.GetCurrentProperty< Vector4 >( 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.GetCurrentProperty< Vector4 >( index ), targetValue, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationAnimateToActorPositionAlphaFunctionTimePeriod(void) +int UtcDaliAnimationAnimateToVector4AlphaFunctionP(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( "testProperty", startValue ); Stage::GetCurrent().Add(actor); - DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( 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::Property::Position), - targetPosition, - AlphaFunctions::Linear, - 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); - Vector3 seventyFivePercentProgress(targetPosition * 0.75f); + Vector4 ninetyFivePercentProgress(startValue + relativeValue*0.95f); // Start the animation animation.Play(); @@ -5401,46 +6497,51 @@ 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 + Vector4 current( actor.GetCurrentProperty< Vector4 >( 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*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.GetCurrentProperty< Vector4 >( index ), targetValue, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationAnimateToActorRotationAngleAxis(void) +int UtcDaliAnimationAnimateToVector4TimePeriodP(void) { TestApplication application; Actor actor = Actor::New(); - actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS)); + + // 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.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), startValue, VECTOR4_EPSILON, 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::Property::Rotation), AngleAxis(targetRotationRadians, Vector3::YAXIS) ); + 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(); @@ -5450,28 +6551,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.GetCurrentProperty< Vector4 >( index ), startValue, VECTOR4_EPSILON, 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.GetCurrentProperty< Vector4 >( index ), startValue+(relativeValue*0.5f), VECTOR4_EPSILON, TEST_LOCATION ); application.SendNotification(); application.Render(static_cast(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/); @@ -5479,26 +6572,33 @@ 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.GetCurrentProperty< Vector4 >( index ), targetValue, VECTOR4_EPSILON, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationAnimateToActorRotationQuaternion(void) +int UtcDaliAnimationAnimateToVector4AlphaFunctionTimePeriodP(void) { TestApplication application; Actor actor = Actor::New(); - actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS)); + + // 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.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( 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::Property::Rotation), targetRotation ); + 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(); @@ -5508,28 +6608,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.GetCurrentProperty< Vector4 >( 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.GetCurrentProperty< Vector4 >( index ), startValue+(relativeValue*0.5f), TEST_LOCATION ); application.SendNotification(); application.Render(static_cast(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/); @@ -5537,208 +6629,253 @@ 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.GetCurrentProperty< Vector4 >( index ), targetValue, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationAnimateToActorRotationAlphaFunction(void) +int UtcDaliAnimationAnimateToActorParentOriginP(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.GetCurrentParentOrigin(), ParentOrigin::TOP_LEFT, 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::Property::Rotation), AngleAxis(targetRotationDegrees, Vector3::YAXIS), AlphaFunctions::EaseIn); - - // 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(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(0.25f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); - - application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f)/* 50% progress */); + Vector3 targetParentOrigin(ParentOrigin::BOTTOM_RIGHT); - // 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 ); + 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*250.0f)/* 75% progress */); +int UtcDaliAnimationAnimateToActorParentOriginXP(void) +{ + TestApplication application; - // 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 ); + 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*250.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.GetCurrentRotation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, 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 UtcDaliAnimationAnimateToActorRotationTimePeriod(void) +int UtcDaliAnimationAnimateToActorParentOriginYP(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(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); - Degree targetRotationDegrees(90.0f); - Radian targetRotationRadians(targetRotationDegrees); - float delay(0.1f); - animation.AnimateTo( Property(actor, Actor::Property::Rotation), AngleAxis(targetRotationDegrees, Vector3::YAXIS), TimePeriod(delay, durationSeconds - delay)); - - // 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*250.0f)/* 25% progress */); +int UtcDaliAnimationAnimateToActorParentOriginZP(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 * progress, Vector3::YAXIS), ROTATION_EPSILON, 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*250.0f)/* 50% progress */); + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + float targetZ(1.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 * progress, Vector3::YAXIS), ROTATION_EPSILON, 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; +} - application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f)/* 75% progress */); +int UtcDaliAnimationAnimateToActorAnchorPointP(void) +{ + TestApplication application; - // 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 ); + Actor actor = Actor::New(); + Stage::GetCurrent().Add(actor); + DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), AnchorPoint::CENTER, TEST_LOCATION ); - application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/); + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + Vector3 targetAnchorPoint(AnchorPoint::TOP_LEFT); - // 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 + { + 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; } -int UtcDaliAnimationAnimateToActorRotationAlphaFunctionTimePeriod(void) +int UtcDaliAnimationAnimateToActorAnchorPointXP(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(0.5f); + DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint().x, startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ANCHOR_POINT_X), 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::Property::Rotation), AngleAxis(targetRotationDegrees, Vector3::YAXIS), AlphaFunctions::EaseIn, TimePeriod(delay, durationSeconds - delay)); - - // Start the animation - animation.Play(); + float targetX(1.0f); - bool signalReceived(false); - AnimationFinishCheck finishCheck(signalReceived); - animation.FinishedSignal().Connect(&application, finishCheck); + 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; +} - application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f)/* 25% progress */); +int UtcDaliAnimationAnimateToActorAnchorPointYP(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 ); + 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 ); - application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f)/* 50% progress */); + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + float targetY(0.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 ); + 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; +} - application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f)/* 75% progress */); +int UtcDaliAnimationAnimateToActorAnchorPointZP(void) +{ + TestApplication application; - // 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 ); + 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 ); - application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/); + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + float targetZ(100.0f); - // 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 + { + 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 UtcDaliAnimationAnimateToActorScale(void) +int UtcDaliAnimationAnimateToActorSizeP(void) { TestApplication application; Actor actor = Actor::New(); Stage::GetCurrent().Add(actor); - DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, 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::Property::Scale), targetScale ); + Vector3 targetSize(100.0f, 100.0f, 100.0f); + animation.AnimateTo( Property(actor, Actor::Property::SIZE), targetSize ); - Vector3 ninetyNinePercentProgress(Vector3::ONE + (targetScale - Vector3::ONE)*0.99f); + Vector3 ninetyNinePercentProgress(targetSize * 0.99f); + + // Should return the initial properties before play + DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SIZE ), Vector3::ZERO, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SIZE_WIDTH ), 0.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SIZE_HEIGHT ), 0.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SIZE_DEPTH ), 0.0f, TEST_LOCATION ); // Start the animation animation.Play(); + // Should return the target property after play + DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SIZE ), targetSize, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SIZE_WIDTH ), targetSize.width, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SIZE_HEIGHT ), targetSize.height, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SIZE_DEPTH ), targetSize.depth, TEST_LOCATION ); + bool signalReceived(false); AnimationFinishCheck finishCheck(signalReceived); animation.FinishedSignal().Connect(&application, finishCheck); @@ -5749,7 +6886,7 @@ int UtcDaliAnimationAnimateToActorScale(void) // 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.GetCurrentSize(), ninetyNinePercentProgress, TEST_LOCATION ); application.SendNotification(); application.Render(static_cast(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/); @@ -5757,18 +6894,18 @@ int UtcDaliAnimationAnimateToActorScale(void) // We did expect the animation to finish application.SendNotification(); finishCheck.CheckSignalReceived(); - DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION ); // Reset everything finishCheck.Reset(); - actor.SetScale(Vector3::ONE); + actor.SetSize(Vector3::ZERO); application.SendNotification(); application.Render(0); - DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION ); + 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::Scale), targetScale, AlphaFunctions::EaseIn); + animation.AnimateTo( Property(actor, Actor::Property::SIZE), targetSize, AlphaFunction::EASE_IN); animation.FinishedSignal().Connect(&application, finishCheck); animation.Play(); @@ -5779,11 +6916,11 @@ int UtcDaliAnimationAnimateToActorScale(void) 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 ); + // 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 ); @@ -5794,19 +6931,19 @@ int UtcDaliAnimationAnimateToActorScale(void) // We did expect the animation to finish application.SendNotification(); finishCheck.CheckSignalReceived(); - DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION ); // Reset everything finishCheck.Reset(); - actor.SetScale(Vector3::ONE); + actor.SetSize(Vector3::ZERO); application.SendNotification(); application.Render(0); - DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION ); + 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::Scale), targetScale, AlphaFunctions::Linear, TimePeriod(delay, durationSeconds - delay)); + animation.AnimateTo( Property(actor, Actor::Property::SIZE), targetSize, AlphaFunction::LINEAR, TimePeriod(delay, durationSeconds - delay)); animation.FinishedSignal().Connect(&application, finishCheck); animation.Play(); @@ -5816,7 +6953,7 @@ int UtcDaliAnimationAnimateToActorScale(void) // 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.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION ); application.SendNotification(); application.Render(static_cast(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/); @@ -5824,33 +6961,39 @@ int UtcDaliAnimationAnimateToActorScale(void) // We did expect the animation to finish application.SendNotification(); finishCheck.CheckSignalReceived(); - DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationAnimateToActorScaleX(void) +int UtcDaliAnimationAnimateToActorSizeWidthP(void) { TestApplication application; Actor actor = Actor::New(); Stage::GetCurrent().Add(actor); - float startValue(1.0f); - DALI_TEST_EQUALS( actor.GetCurrentScale().x, startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ScaleX), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ScaleY), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ScaleZ), 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 targetX(10.0f); - animation.AnimateTo( Property(actor, Actor::Property::ScaleX), targetX ); + float targetWidth(10.0f); + animation.AnimateTo( Property(actor, Actor::Property::SIZE_WIDTH), targetWidth ); - float fiftyPercentProgress(startValue + (targetX - startValue)*0.5f); + float fiftyPercentProgress(startValue + (targetWidth - startValue)*0.5f); + + // Should return the initial properties before play + DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SIZE ), Vector3::ZERO, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SIZE_WIDTH ), startValue, TEST_LOCATION ); // Start the animation animation.Play(); + // Should return the target property after play + DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SIZE ), Vector3( targetWidth, 0.0f, 0.0f ), TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SIZE_WIDTH ), targetWidth, TEST_LOCATION ); + bool signalReceived(false); AnimationFinishCheck finishCheck(signalReceived); animation.FinishedSignal().Connect(&application, finishCheck); @@ -5861,10 +7004,7 @@ int UtcDaliAnimationAnimateToActorScaleX(void) // 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::Property::ScaleX), fiftyPercentProgress, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ScaleY), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ScaleZ), 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*/); @@ -5872,36 +7012,40 @@ int UtcDaliAnimationAnimateToActorScaleX(void) // 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::Property::ScaleX), targetX, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ScaleY), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ScaleZ), 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 UtcDaliAnimationAnimateToActorScaleY(void) +int UtcDaliAnimationAnimateToActorSizeHeightP(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::Property::ScaleX), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ScaleY), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ScaleZ), 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 targetY(1000.0f); - animation.AnimateTo( Property(actor, Actor::Property::ScaleY), targetY ); + float targetHeight(-10.0f); + animation.AnimateTo( Property(actor, Actor::Property::SIZE_HEIGHT), targetHeight ); - float fiftyPercentProgress(startValue + (targetY - startValue)*0.5f); + float fiftyPercentProgress(startValue + (targetHeight - startValue)*0.5f); + + // Should return the initial properties before play + DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SIZE ), Vector3::ZERO, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SIZE_HEIGHT ), startValue, TEST_LOCATION ); // Start the animation animation.Play(); + // Should return the target property after play + DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SIZE ), Vector3( 0.0f, targetHeight, 0.0f ), TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SIZE_HEIGHT ), targetHeight, TEST_LOCATION ); + bool signalReceived(false); AnimationFinishCheck finishCheck(signalReceived); animation.FinishedSignal().Connect(&application, finishCheck); @@ -5912,10 +7056,7 @@ int UtcDaliAnimationAnimateToActorScaleY(void) // 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::Property::ScaleX), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ScaleY), fiftyPercentProgress, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ScaleZ), 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*/); @@ -5923,36 +7064,40 @@ int UtcDaliAnimationAnimateToActorScaleY(void) // 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::Property::ScaleX), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ScaleY), targetY, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ScaleZ), 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 UtcDaliAnimationAnimateToActorScaleZ(void) +int UtcDaliAnimationAnimateToActorSizeDepthP(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::Property::ScaleX), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ScaleY), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ScaleZ), 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 targetZ(-1000.0f); - animation.AnimateTo( Property(actor, Actor::Property::ScaleZ), targetZ ); + float targetDepth(-10.0f); + animation.AnimateTo( Property(actor, Actor::Property::SIZE_DEPTH), targetDepth ); - float fiftyPercentProgress(startValue + (targetZ - startValue)*0.5f); + float fiftyPercentProgress(startValue + (targetDepth - startValue)*0.5f); + + // Should return the initial properties before play + DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SIZE ), Vector3::ZERO, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SIZE_DEPTH ), startValue, TEST_LOCATION ); // Start the animation animation.Play(); + // Should return the target property after play + DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SIZE ), Vector3( 0.0f, 0.0f, targetDepth ), TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SIZE_DEPTH ), targetDepth, TEST_LOCATION ); + bool signalReceived(false); AnimationFinishCheck finishCheck(signalReceived); animation.FinishedSignal().Connect(&application, finishCheck); @@ -5963,10 +7108,7 @@ int UtcDaliAnimationAnimateToActorScaleZ(void) // 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::Property::ScaleX), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ScaleY), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ScaleZ), fiftyPercentProgress, 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*/); @@ -5974,29 +7116,26 @@ int UtcDaliAnimationAnimateToActorScaleZ(void) // 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::Property::ScaleX), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ScaleY), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ScaleZ), targetZ, 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 UtcDaliAnimationAnimateToActorColor(void) +int UtcDaliAnimationAnimateToActorSizeWidthHeightP(void) { TestApplication application; Actor actor = Actor::New(); Stage::GetCurrent().Add(actor); - DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION ); // Build the animation float durationSeconds(1.0f); Animation animation = Animation::New(durationSeconds); - Vector4 targetColor(Color::RED); - animation.AnimateTo( Property(actor, Actor::Property::Color), targetColor ); + Vector3 targetSize(100.0f, 100.0f, 100.0f); + animation.AnimateTo( Property( actor, Actor::Property::SIZE ), targetSize ); - Vector4 tenPercentProgress(Vector4(1.0f, 0.9f, 0.9f, 1.0f)); - Vector4 twentyPercentProgress(Vector4(1.0f, 0.8f, 0.8f, 1.0f)); + Vector3 ninetyNinePercentProgress(targetSize * 0.99f); // Start the animation animation.Play(); @@ -6006,87 +7145,80 @@ int UtcDaliAnimationAnimateToActorColor(void) 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(); - DALI_TEST_EQUALS( actor.GetCurrentColor(), tenPercentProgress, TEST_LOCATION ); + 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 different (ease-in) alpha function animation = Animation::New(durationSeconds); - animation.AnimateTo( Property(actor, Actor::Property::Color), targetColor, AlphaFunctions::EaseIn); + 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(); 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 + // 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 ); 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().x, targetSize.x, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentSize().y, targetSize.y, 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 delay + float delay = 0.5f; animation = Animation::New(durationSeconds); - animation.AnimateTo( Property(actor, Actor::Property::Color), targetColor, AlphaFunctions::Linear, TimePeriod(animatorDuration)); + 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*100.0f)/* 10% animation progress, 20% animator progress */); - - // We didn't expect the animation to finish yet - application.SendNotification(); - finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetCurrentColor(), twentyPercentProgress, TEST_LOCATION ); - - application.SendNotification(); - application.Render(static_cast(durationSeconds*400.0f)/* 50% animation progress, 100% 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_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*/); @@ -6094,88 +7226,95 @@ 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().x, targetSize.x, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentSize().y, targetSize.y, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationAnimateToActorColorRed(void) +int UtcDaliAnimationAnimateToActorPositionP(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::Property::ColorRed), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorGreen), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorBlue), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorAlpha), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION ); // Build the animation float durationSeconds(1.0f); Animation animation = Animation::New(durationSeconds); - float targetRed(0.5f); - animation.AnimateTo( Property(actor, Actor::Property::ColorRed), targetRed ); + Vector3 targetPosition(200.0f, 200.0f, 200.0f); + animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition); - float fiftyPercentProgress(startValue + (targetRed - startValue)*0.5f); + Vector3 seventyFivePercentProgress(targetPosition * 0.75f); + + // Should return the initial properties before play + DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), Vector3::ZERO, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_X ), 0.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_Y ), 0.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_Z ), 0.0f, TEST_LOCATION ); // Start the animation animation.Play(); + // Should return the target property after play + DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), targetPosition, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_X ), targetPosition.x, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_Y ), targetPosition.y, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_Z ), targetPosition.z, TEST_LOCATION ); + bool signalReceived(false); AnimationFinishCheck finishCheck(signalReceived); animation.FinishedSignal().Connect(&application, finishCheck); application.SendNotification(); - application.Render(static_cast(durationSeconds*500.0f)/* 50% progress */); + 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().r, fiftyPercentProgress, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorRed), fiftyPercentProgress, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorGreen), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorBlue), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorAlpha), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), seventyFivePercentProgress, 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.GetCurrentColor().r, targetRed, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorRed), targetRed, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorGreen), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorBlue), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorAlpha), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationAnimateToActorColorGreen(void) +int UtcDaliAnimationAnimateToActorPositionXP(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::Property::ColorRed), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorGreen), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorBlue), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorAlpha), 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 targetGreen(0.5f); - animation.AnimateTo( Property(actor, Actor::Property::ColorGreen), targetGreen ); + float targetX(1.0f); + animation.AnimateTo( Property(actor, Actor::Property::POSITION_X), targetX ); - float fiftyPercentProgress(startValue + (targetGreen - startValue)*0.5f); + float fiftyPercentProgress(startValue + (targetX - startValue)*0.5f); + + // Should return the initial properties before play + DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), Vector3::ZERO, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_X ), startValue, TEST_LOCATION ); // Start the animation animation.Play(); + // Should return the target property after play + DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), Vector3( targetX, 0.0f, 0.0f ), TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_X ), targetX, TEST_LOCATION ); + bool signalReceived(false); AnimationFinishCheck finishCheck(signalReceived); animation.FinishedSignal().Connect(&application, finishCheck); @@ -6186,11 +7325,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::Property::ColorRed), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorGreen), fiftyPercentProgress, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorBlue), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorAlpha), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentPosition().x, fiftyPercentProgress, TEST_LOCATION ); application.SendNotification(); application.Render(static_cast(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/); @@ -6198,38 +7333,44 @@ 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::Property::ColorRed), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorGreen), targetGreen, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorBlue), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorAlpha), startValue, TEST_LOCATION ); + 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 UtcDaliAnimationAnimateToActorColorBlue(void) +int UtcDaliAnimationAnimateToActorPositionYP(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::Property::ColorRed), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorGreen), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorBlue), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorAlpha), 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 targetBlue(0.5f); - animation.AnimateTo( Property(actor, Actor::Property::ColorBlue), targetBlue ); + float targetY(10.0f); + animation.AnimateTo( Property(actor, Actor::Property::POSITION_Y), targetY ); - float fiftyPercentProgress(startValue + (targetBlue - startValue)*0.5f); + float fiftyPercentProgress(startValue + (targetY - startValue)*0.5f); + + // Should return the initial properties before play + DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), Vector3::ZERO, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_Y ), startValue, TEST_LOCATION ); // Start the animation animation.Play(); + // Should return the target property after play + DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), Vector3( 0.0f, targetY, 0.0f ), TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_Y ), targetY, TEST_LOCATION ); + bool signalReceived(false); AnimationFinishCheck finishCheck(signalReceived); animation.FinishedSignal().Connect(&application, finishCheck); @@ -6240,11 +7381,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::Property::ColorRed), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorGreen), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorBlue), fiftyPercentProgress, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorAlpha), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentPosition().y, fiftyPercentProgress, TEST_LOCATION ); application.SendNotification(); application.Render(static_cast(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/); @@ -6252,38 +7389,44 @@ 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::Property::ColorRed), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorGreen), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorBlue), targetBlue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorAlpha), startValue, TEST_LOCATION ); + 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 UtcDaliAnimationAnimateToActorColorAlpha(void) +int UtcDaliAnimationAnimateToActorPositionZP(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::Property::ColorRed), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorGreen), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorBlue), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorAlpha), startValue, 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 targetAlpha(0.5f); - animation.AnimateTo( Property(actor, Actor::Property::ColorAlpha), targetAlpha ); + float targetZ(-5.0f); + animation.AnimateTo( Property(actor, Actor::Property::POSITION_Z), targetZ ); - float fiftyPercentProgress(startValue + (targetAlpha - startValue)*0.5f); + float fiftyPercentProgress(startValue + (targetZ - startValue)*0.5f); + + // Should return the initial properties before play + DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), Vector3::ZERO, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_Z ), startValue, TEST_LOCATION ); // Start the animation animation.Play(); + // Should return the target property after play + DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, targetZ ), TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_Z ), targetZ, TEST_LOCATION ); + bool signalReceived(false); AnimationFinishCheck finishCheck(signalReceived); animation.FinishedSignal().Connect(&application, finishCheck); @@ -6291,234 +7434,144 @@ int UtcDaliAnimationAnimateToActorColorAlpha(void) 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.GetCurrentColor().a, fiftyPercentProgress, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorRed), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorGreen), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorBlue), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorAlpha), fiftyPercentProgress, 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.GetCurrentColor().a, targetAlpha, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorRed), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorGreen), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorBlue), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorAlpha), targetAlpha, TEST_LOCATION ); - END_TEST; -} - - - -int UtcDaliAnimationKeyFrames01(void) -{ - TestApplication application; - - KeyFrames keyFrames = KeyFrames::New(); - DALI_TEST_EQUALS(keyFrames.GetType(), Property::NONE, 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); - - DALI_TEST_EQUALS(keyFrames.GetType(), Property::FLOAT, 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 UtcDaliAnimationKeyFrames02(void) -{ - TestApplication application; - - KeyFrames keyFrames = KeyFrames::New(); - DALI_TEST_EQUALS(keyFrames.GetType(), Property::NONE, 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); + // 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(keyFrames.GetType(), Property::BOOLEAN, TEST_LOCATION); + application.SendNotification(); + application.Render(static_cast(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/); - 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); - } + // 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 UtcDaliAnimationKeyFrames03(void) +int UtcDaliAnimationAnimateToActorPositionAlphaFunctionP(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, 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)); + // 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); - DALI_TEST_EQUALS(keyFrames.GetType(), Property::VECTOR2, TEST_LOCATION); + Vector3 seventyFivePercentProgress(targetPosition * 0.75f); - 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; -} + // Start the animation + animation.Play(); + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); -int UtcDaliAnimationKeyFrames04(void) -{ - TestApplication application; + application.SendNotification(); + application.Render(static_cast(durationSeconds*750.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(); - 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)); + // 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(keyFrames.GetType(), Property::VECTOR3, TEST_LOCATION); + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/); - 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); - } + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationKeyFrames05(void) +int UtcDaliAnimationAnimateToActorPositionTimePeriodP(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, 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)); + // 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::Property::POSITION), + targetPosition, + TimePeriod( delay, durationSeconds - delay ) ); - DALI_TEST_EQUALS(keyFrames.GetType(), Property::VECTOR4, TEST_LOCATION); + Vector3 seventyFivePercentProgress(targetPosition * 0.75f); - try - { - keyFrames.Add(0.7f, Quaternion(1.717f, Vector3::XAXIS)); - } - catch (Dali::DaliException& e) - { - DALI_TEST_PRINT_ASSERT( e ); - DALI_TEST_ASSERT(e, "mType == value.GetType()", TEST_LOCATION); - } - END_TEST; -} + // Start the animation + animation.Play(); + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); -int UtcDaliAnimationKeyFrames06(void) -{ - TestApplication application; + application.SendNotification(); + application.Render(static_cast(durationSeconds*500.0f)/* 50% animation progress, 0% animator 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.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION ); - 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)); + application.SendNotification(); + application.Render(static_cast(durationSeconds*500.0f*0.75)/* 7/8 animation progress, 3/4 animator progress */); - DALI_TEST_EQUALS(keyFrames.GetType(), Property::ROTATION, TEST_LOCATION); + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), seventyFivePercentProgress, 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); - } + 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(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION ); END_TEST; } - - - - -int UtcDaliAnimationAnimateBetweenActorColorAlpha(void) +int UtcDaliAnimationAnimateToActorPositionAlphaFunctionTimePeriodP(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::Property::ColorRed), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorGreen), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorBlue), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorAlpha), startValue, 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); + float delay = 0.5f; + animation.AnimateTo( Property(actor, Actor::Property::POSITION), + targetPosition, + AlphaFunction::LINEAR, + TimePeriod( delay, durationSeconds - delay ) ); - 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::ColorAlpha), keyFrames ); + Vector3 seventyFivePercentProgress(targetPosition * 0.75f); // Start the animation animation.Play(); @@ -6526,186 +7579,109 @@ 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::Property::ColorRed), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorGreen), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorBlue), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorAlpha), 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::Property::ColorRed), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorGreen), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorBlue), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorAlpha), 0.25f, 0.01f, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.25f, 0.01f, TEST_LOCATION ); + application.Render(static_cast(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */); - application.Render(static_cast(durationSeconds*100.0f)/* 40% progress */); + // We didn't expect the animation to finish yet application.SendNotification(); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorRed), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorGreen), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorBlue), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorAlpha), 0.0f, 0.01f, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.0f, 0.01f, TEST_LOCATION ); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION ); - application.Render(static_cast(durationSeconds*400.0f)/* 80% progress */); application.SendNotification(); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorRed), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorGreen), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorBlue), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorAlpha), 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*0.75)/* 7/8 animation progress, 3/4 animator 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::Property::ColorRed), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorGreen), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorBlue), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorAlpha), 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(), seventyFivePercentProgress, TEST_LOCATION ); - application.Render(static_cast(durationSeconds*100.0f)+1/* 100% progress */); application.SendNotification(); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorRed), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorGreen), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorBlue), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorAlpha), 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*0.25) + 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 UtcDaliAnimationAnimateBetweenActorColorAlphaCubic(void) +int UtcDaliAnimationAnimateToActorOrientationAngleAxisP(void) { TestApplication application; - float startValue(1.0f); Actor actor = Actor::New(); - actor.SetColor(Vector4(startValue, startValue, startValue, startValue)); + actor.SetOrientation(Quaternion( Dali::ANGLE_0, Vector3::YAXIS ) ); Stage::GetCurrent().Add(actor); - - DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorRed), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorGreen), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorBlue), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorAlpha), 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); - - 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::ColorAlpha), keyFrames, Animation::Cubic ); + Degree targetRotationDegrees(90.0f); + Radian targetRotationRadians(targetRotationDegrees); + animation.AnimateTo( Property(actor, Actor::Property::ORIENTATION), AngleAxis(targetRotationRadians, Vector3::YAXIS) ); // Start the animation animation.Play(); + // Target value should be retrievable straight away + DALI_TEST_EQUALS( actor.GetProperty< Quaternion >( Actor::Property::ORIENTATION ), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + 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*250.0f)/* 25% progress */); - application.Render(static_cast(durationSeconds*100.0f)/* 10% progress */); + // We didn't expect the animation to finish yet application.SendNotification(); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorRed), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorGreen), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorBlue), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorAlpha), 0.36f, 0.01f, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.36f, 0.01f, TEST_LOCATION ); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * 0.25f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); - application.Render(static_cast(durationSeconds*200.0f)/* 30% progress */); application.SendNotification(); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorRed), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorGreen), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorBlue), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorAlpha), 0.21f, 0.01f, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.21f, 0.01f, TEST_LOCATION ); + application.Render(static_cast(durationSeconds*250.0f)/* 50% progress */); - application.Render(static_cast(durationSeconds*100.0f)/* 40% progress */); + // We didn't expect the animation to finish yet application.SendNotification(); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorRed), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorGreen), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorBlue), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorAlpha), 0.0f, 0.01f, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.0f, 0.01f, TEST_LOCATION ); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * 0.5f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); - application.Render(static_cast(durationSeconds*400.0f)/* 80% progress */); application.SendNotification(); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorRed), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorGreen), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorBlue), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorAlpha), 0.7f, 0.01f, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.7f, 0.01f, TEST_LOCATION ); + application.Render(static_cast(durationSeconds*250.0f)/* 75% 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::Property::ColorRed), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorGreen), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorBlue), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorAlpha), 0.76f, 0.01f, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.76f, 0.01f, TEST_LOCATION ); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * 0.75f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); - application.Render(static_cast(durationSeconds*100.0f)+1/* 100% progress */); application.SendNotification(); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorRed), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorGreen), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorBlue), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorAlpha), 0.9f, 0.01f, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.9f, 0.01f, 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.GetCurrentOrientation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationAnimateBetweenActorColor(void) +int UtcDaliAnimationAnimateToActorOrientationQuaternionP(void) { TestApplication application; - float startValue(1.0f); Actor actor = Actor::New(); - actor.SetColor(Vector4(startValue, startValue, startValue, startValue)); + actor.SetOrientation(Quaternion( Dali::ANGLE_0, Vector3::YAXIS ) ); Stage::GetCurrent().Add(actor); - - DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorRed), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorGreen), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorBlue), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorAlpha), 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); - - 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 ); + 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(); @@ -6713,74 +7689,56 @@ int UtcDaliAnimationAnimateBetweenActorColor(void) bool signalReceived(false); AnimationFinishCheck finishCheck(signalReceived); animation.FinishedSignal().Connect(&application, finishCheck); + application.SendNotification(); - application.Render(0); + 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(Actor::Property::ColorRed), 0.1f, 0.01f, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorGreen), 0.2f, 0.01f, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorBlue), 0.3f, 0.01f, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorAlpha), 0.4f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * 0.25f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); - application.Render(static_cast(durationSeconds*250.0f)/* 25% progress */); application.SendNotification(); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorRed), 0.5f, 0.01f, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorGreen), 0.5f, 0.01f, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorBlue), 0.5f, 0.01f, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorAlpha), 0.5f, 0.01f, TEST_LOCATION ); - application.Render(static_cast(durationSeconds*250.0f)/* 50% progress */); + + // We didn't expect the animation to finish yet application.SendNotification(); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorRed), 0.9f, 0.01f, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorGreen), 0.8f, 0.01f, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorBlue), 0.7f, 0.01f, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorAlpha), 0.6f, 0.01f, TEST_LOCATION ); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * 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(); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorRed), 0.95f, 0.01f, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorGreen), 0.90f, 0.01f, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorBlue), 0.85f, 0.01f, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorAlpha), 0.80f, 0.01f, TEST_LOCATION ); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * 0.75f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); - application.Render(static_cast(durationSeconds*250.0f)+1/* 100% progress */); application.SendNotification(); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorRed), 1.0f, 0.01f, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorGreen), 1.0f, 0.01f, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorBlue), 1.0f, 0.01f, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorAlpha), 1.0f, 0.01f, 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.GetCurrentOrientation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationAnimateBetweenActorColorCubic(void) +int UtcDaliAnimationAnimateToActorOrientationAlphaFunctionP(void) { TestApplication application; - float startValue(1.0f); Actor actor = Actor::New(); - actor.SetColor(Vector4(startValue, startValue, startValue, startValue)); + actor.SetOrientation(Quaternion( Dali::ANGLE_0, Vector3::YAXIS ) ); Stage::GetCurrent().Add(actor); - - DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorRed), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorGreen), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorBlue), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorAlpha), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(Radian(0.0f), Vector3::YAXIS), ROTATION_EPSILON, 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::Property::Color), keyFrames, Animation::Cubic ); + 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(); @@ -6788,75 +7746,57 @@ int UtcDaliAnimationAnimateBetweenActorColorCubic(void) bool signalReceived(false); AnimationFinishCheck finishCheck(signalReceived); animation.FinishedSignal().Connect(&application, finishCheck); + application.SendNotification(); - application.Render(0); + 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(Actor::Property::ColorRed), 0.1f, 0.01f, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorGreen), 0.2f, 0.01f, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorBlue), 0.3f, 0.01f, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorAlpha), 0.4f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * 0.25f*0.25f*0.25f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); - application.Render(static_cast(durationSeconds*250.0f)/* 25% progress */); application.SendNotification(); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorRed), 0.55f, 0.01f, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorGreen), 0.525f, 0.01f, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorBlue), 0.506f, 0.01f, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorAlpha), 0.4875f, 0.01f, TEST_LOCATION ); - application.Render(static_cast(durationSeconds*250.0f)/* 50% progress */); + + // We didn't expect the animation to finish yet application.SendNotification(); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorRed), 0.9f, 0.01f, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorGreen), 0.8f, 0.01f, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorBlue), 0.7f, 0.01f, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorAlpha), 0.6f, 0.01f, TEST_LOCATION ); + finishCheck.CheckSignalNotReceived(); + 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 */); + + // We didn't expect the animation to finish yet application.SendNotification(); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorRed), 0.99375f, 0.01f, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorGreen), 0.925f, 0.01f, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorBlue), 0.85625f, 0.01f, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorAlpha), 0.7875f, 0.01f, TEST_LOCATION ); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * 0.75f*0.75f*0.75f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); - application.Render(static_cast(durationSeconds*250.0f)+1/* 100% progress */); application.SendNotification(); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorRed), 1.0f, 0.01f, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorGreen), 1.0f, 0.01f, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorBlue), 1.0f, 0.01f, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorAlpha), 1.0f, 0.01f, 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.GetCurrentOrientation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationAnimateBetweenActorVisible(void) +int UtcDaliAnimationAnimateToActorOrientationTimePeriodP(void) { TestApplication application; Actor actor = Actor::New(); - AngleAxis aa(Degree(90), Vector3::XAXIS); - actor.SetRotation(aa.angle, aa.axis); + actor.SetOrientation(Quaternion( Dali::ANGLE_0, Vector3::YAXIS ) ); Stage::GetCurrent().Add(actor); - - application.SendNotification(); - application.Render(0); - - DALI_TEST_EQUALS( actor.IsVisible(), true, 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); - - 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 ); + 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(); @@ -6864,45 +7804,60 @@ int UtcDaliAnimationAnimateBetweenActorVisible(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.SendNotification(); - application.Render(static_cast(durationSeconds*500.0f)); + finishCheck.CheckSignalNotReceived(); + 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*500.0f)+1); + 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.GetCurrentOrientation(), Quaternion(targetRotationRadians * progress, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.IsVisible(), true, 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.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*/); + + // We did expect the animation to finish + application.SendNotification(); finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationAnimateBetweenActorVisibleCubic(void) +int UtcDaliAnimationAnimateToActorOrientationAlphaFunctionTimePeriodP(void) { TestApplication application; Actor actor = Actor::New(); - AngleAxis aa(Degree(90), Vector3::XAXIS); - actor.SetRotation(aa.angle, aa.axis); + actor.SetOrientation(Quaternion( Dali::ANGLE_0, Vector3::YAXIS ) ); Stage::GetCurrent().Add(actor); - - application.SendNotification(); - application.Render(0); - - DALI_TEST_EQUALS( actor.IsVisible(), true, 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); - - KeyFrames keyFrames = KeyFrames::New(); - keyFrames.Add(0.0f, false); - keyFrames.Add(0.2f, true); - keyFrames.Add(0.4f, true); - keyFrames.Add(0.8f, false); - keyFrames.Add(1.0f, true); - - //Cubic interpolation for boolean values should be ignored - animation.AnimateBetween( Property(actor, Actor::Property::Visible), keyFrames, Animation::Cubic ); + 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(); @@ -6910,370 +7865,446 @@ int UtcDaliAnimationAnimateBetweenActorVisibleCubic(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.SendNotification(); - application.Render(static_cast(durationSeconds*500.0f)); + finishCheck.CheckSignalNotReceived(); + 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*500.0f)+1); + 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.GetCurrentOrientation(), Quaternion(targetRotationRadians * progress*progress*progress, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f)/* 75% progress */); - DALI_TEST_EQUALS( actor.IsVisible(), true, 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.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*/); + + // We did expect the animation to finish + application.SendNotification(); finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationAnimateBetweenActorRotation01(void) +int UtcDaliAnimationAnimateToActorScaleP(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.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); + animation.AnimateTo( Property(actor, Actor::Property::SCALE), targetScale ); - KeyFrames keyFrames = KeyFrames::New(); - keyFrames.Add(0.0f, AngleAxis(Degree(60), Vector3::ZAXIS)); - - animation.AnimateBetween( Property(actor, Actor::Property::Rotation), keyFrames ); + Vector3 ninetyNinePercentProgress(Vector3::ONE + (targetScale - Vector3::ONE)*0.99f); // Start the animation animation.Play(); + // Target value should be retrievable straight away + DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SCALE ), targetScale, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SCALE_X ), targetScale.x, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SCALE_Y ), targetScale.y, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SCALE_Z ), targetScale.z, TEST_LOCATION ); + 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(); - application.Render(static_cast(durationSeconds*500.0f)); - application.SendNotification(); - application.Render(static_cast(durationSeconds*500.0f)+1); - application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentScale(), ninetyNinePercentProgress, TEST_LOCATION ); - Quaternion check = Quaternion::FromAxisAngle(Vector4::ZAXIS, Radian(Degree(60))); + application.SendNotification(); + application.Render(static_cast(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/); - DALI_TEST_EQUALS( actor.GetCurrentRotation(), check, 0.001f, TEST_LOCATION ); + // We did expect the animation to finish + application.SendNotification(); finishCheck.CheckSignalReceived(); - END_TEST; -} - -int UtcDaliAnimationAnimateBetweenActorRotation02(void) -{ - TestApplication application; + DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION ); - Actor actor = Actor::New(); - AngleAxis aa(Degree(90), Vector3::XAXIS); - actor.SetRotation(aa.angle, aa.axis); + // Reset everything + finishCheck.Reset(); + actor.SetScale(Vector3::ONE); 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::Property::Rotation), keyFrames ); + DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION ); - // Start the animation + // 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(); - bool signalReceived(false); - AnimationFinishCheck finishCheck(signalReceived); - animation.FinishedSignal().Connect(&application, finishCheck); application.SendNotification(); - application.Render(0); + application.Render(static_cast(durationSeconds*990.0f)/* 99% progress */); + + // 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 ); + // 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.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*10.0f) + 1u/*just beyond the animation duration*/); - application.Render(static_cast(durationSeconds*250.0f)/* 50% progress */); + // We did expect the animation to finish application.SendNotification(); - check = Quaternion::FromAxisAngle(Vector4::XAXIS, Radian(Degree(120))); - DALI_TEST_EQUALS( actor.GetCurrentRotation(), check, 0.001f, TEST_LOCATION ); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION ); - application.Render(static_cast(durationSeconds*250.0f)/* 75% progress */); + // 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(); - 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 ); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION ); - 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*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 UtcDaliAnimationAnimateBetweenActorRotation01Cubic(void) +int UtcDaliAnimationAnimateToActorScaleXP(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 ); + 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 ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_X ), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_Y ), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_Z ), startValue, TEST_LOCATION ); // Build the animation float durationSeconds(1.0f); Animation animation = Animation::New(durationSeconds); + float targetX(10.0f); + animation.AnimateTo( Property(actor, Actor::Property::SCALE_X), targetX ); - 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::Rotation), keyFrames, Animation::Cubic ); + float fiftyPercentProgress(startValue + (targetX - startValue)*0.5f); // Start the animation animation.Play(); + // Target value should be retrievable straight away + DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SCALE ), Vector3( targetX, startValue, startValue ), TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SCALE_X ), targetX, TEST_LOCATION ); + 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); - application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentScale().x, fiftyPercentProgress, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_X ), fiftyPercentProgress, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_Y ), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_Z ), startValue, TEST_LOCATION ); - Quaternion check = Quaternion::FromAxisAngle(Vector4::ZAXIS, Radian(Degree(60))); + application.SendNotification(); + application.Render(static_cast(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/); - DALI_TEST_EQUALS( actor.GetCurrentRotation(), check, 0.001f, TEST_LOCATION ); + // We did expect the animation to finish + application.SendNotification(); finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetCurrentScale().x, targetX, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_X ), targetX, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_Y ), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_Z ), startValue, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationAnimateBetweenActorRotation02Cubic(void) +int UtcDaliAnimationAnimateToActorScaleYP(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 ); + 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 ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_X ), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_Y ), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_Z ), startValue, TEST_LOCATION ); // Build the animation float durationSeconds(1.0f); Animation animation = Animation::New(durationSeconds); + float targetY(1000.0f); + animation.AnimateTo( Property(actor, Actor::Property::SCALE_Y), targetY ); - 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::Rotation), keyFrames, Animation::Cubic ); + float fiftyPercentProgress(startValue + (targetY - startValue)*0.5f); // Start the animation animation.Play(); + // Target value should be retrievable straight away + DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SCALE ), Vector3( startValue, targetY, startValue ), TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SCALE_Y ), targetY, TEST_LOCATION ); + bool signalReceived(false); AnimationFinishCheck finishCheck(signalReceived); animation.FinishedSignal().Connect(&application, finishCheck); - application.SendNotification(); - application.Render(0); - application.SendNotification(); - finishCheck.CheckSignalNotReceived(); - - Quaternion check(Radian(Degree(60)), Vector3::XAXIS); - DALI_TEST_EQUALS( actor.GetCurrentRotation(), check, 0.001f, TEST_LOCATION ); - - application.Render(static_cast(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*500.0f)/* 50% progress */); - application.Render(static_cast(durationSeconds*250.0f)/* 75% progress */); + // We didn't expect the animation to finish yet 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 ); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentScale().y, fiftyPercentProgress, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_X ), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_Y ), fiftyPercentProgress, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_Z ), startValue, TEST_LOCATION ); - 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*500.0f) + 1u/*just beyond the animation duration*/); // We did expect the animation to finish - + application.SendNotification(); finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetCurrentScale().y, targetY, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_X ), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_Y ), targetY, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_Z ), startValue, TEST_LOCATION ); END_TEST; } - -int UtcDaliAnimationMoveByFloat3(void) +int UtcDaliAnimationAnimateToActorScaleZP(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 ); + 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 ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_X ), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_Y ), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_Z ), 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.MoveBy(actor, relativePosition.x, relativePosition.y, relativePosition.z); + float targetZ(-1000.0f); + animation.AnimateTo( Property(actor, Actor::Property::SCALE_Z), targetZ ); - Vector3 ninetyFivePercentProgress(startPosition + relativePosition*0.95f); + float fiftyPercentProgress(startValue + (targetZ - startValue)*0.5f); // Start the animation animation.Play(); + // Target value should be retrievable straight away + DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SCALE ), Vector3( startValue, startValue, targetZ ), TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SCALE_Z ), targetZ, TEST_LOCATION ); + 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*500.0f)/* 50% progress */); // 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.GetCurrentScale().z, fiftyPercentProgress, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_X ), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_Y ), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_Z ), fiftyPercentProgress, TEST_LOCATION ); application.SendNotification(); - application.Render(static_cast(durationSeconds*50.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.GetCurrentPosition(), targetPosition, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentScale().z, targetZ, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_X ), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_Y ), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_Z ), targetZ, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationMoveByVector3Alpha(void) +int UtcDaliAnimationAnimateToActorColorP(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.GetCurrentColor(), Color::WHITE, 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); + Vector4 targetColor(Color::RED); + animation.AnimateTo( Property(actor, Actor::Property::COLOR), targetColor ); - Vector3 ninetyFivePercentProgress(startPosition + relativePosition*0.95f); + 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(); + // Target value should be retrievable straight away + DALI_TEST_EQUALS( actor.GetProperty< Vector4 >( Actor::Property::COLOR ), targetColor, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::COLOR_RED ), targetColor.r, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::COLOR_GREEN ), targetColor.g, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::COLOR_BLUE ), targetColor.b, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::COLOR_ALPHA ), targetColor.a, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty< float >( DevelActor::Property::OPACITY ), targetColor.a, TEST_LOCATION ); + 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*100.0f)/* 10% 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.GetCurrentColor(), tenPercentProgress, TEST_LOCATION ); application.SendNotification(); - application.Render(static_cast(durationSeconds*50.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.GetCurrentPosition(), targetPosition, TEST_LOCATION ); - END_TEST; -} - -int UtcDaliAnimationMoveByVector3AlphaFloat2(void) -{ - TestApplication application; + DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION ); - Actor actor = Actor::New(); - Vector3 startPosition(10.0f, 10.0f, 10.0f); - actor.SetPosition(startPosition); - Stage::GetCurrent().Add(actor); + // Reset everything + finishCheck.Reset(); + actor.SetColor(Color::WHITE); application.SendNotification(); application.Render(0); - DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, 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); - float delay = 0.5f; - animation.MoveBy(actor, relativePosition, AlphaFunctions::Linear, delay, durationSeconds - delay); + // 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(); - Vector3 ninetyFivePercentProgress(startPosition + relativePosition*0.95f); + application.SendNotification(); + application.Render(static_cast(durationSeconds*100.0f)/* 10% progress */); - // Start the animation - animation.Play(); + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); - bool signalReceived(false); - AnimationFinishCheck finishCheck(signalReceived); + // 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*900.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 ); + + // 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 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*500.0f)/* 50% animation progress, 0% animator 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.GetCurrentPosition(), startPosition, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentColor(), twentyPercentProgress, TEST_LOCATION ); + + 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.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*/); @@ -7281,394 +8312,588 @@ int UtcDaliAnimationMoveByVector3AlphaFloat2(void) // We did expect the animation to finish application.SendNotification(); finishCheck.CheckSignalReceived(); - DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationMoveToFloat3(void) +int UtcDaliAnimationAnimateToActorColorRedP(void) { TestApplication application; Actor actor = Actor::New(); Stage::GetCurrent().Add(actor); - DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, 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 ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), startValue, 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); + float targetRed(0.5f); + animation.AnimateTo( Property(actor, Actor::Property::COLOR_RED), targetRed ); - Vector3 seventyFivePercentProgress(targetPosition * 0.75f); + float fiftyPercentProgress(startValue + (targetRed - startValue)*0.5f); // Start the animation animation.Play(); + // Target value should be retrievable straight away + DALI_TEST_EQUALS( actor.GetProperty< Vector4 >( Actor::Property::COLOR ), Vector4( targetRed, startValue, startValue, startValue ), TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::COLOR_RED ), targetRed, TEST_LOCATION ); + bool signalReceived(false); AnimationFinishCheck finishCheck(signalReceived); animation.FinishedSignal().Connect(&application, finishCheck); application.SendNotification(); - application.Render(static_cast(durationSeconds*750.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.GetCurrentPosition(), seventyFivePercentProgress, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentColor().r, fiftyPercentProgress, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED), fiftyPercentProgress, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( 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.GetCurrentPosition(), targetPosition, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentColor().r, targetRed, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED), targetRed, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationMoveToVector3Alpha(void) +int UtcDaliAnimationAnimateToActorColorGreenP(void) { TestApplication application; Actor actor = Actor::New(); Stage::GetCurrent().Add(actor); - DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, 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 ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), startValue, 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); + float targetGreen(0.5f); + animation.AnimateTo( Property(actor, Actor::Property::COLOR_GREEN), targetGreen ); - Vector3 seventyFivePercentProgress(targetPosition * 0.75f); + float fiftyPercentProgress(startValue + (targetGreen - startValue)*0.5f); // Start the animation animation.Play(); + // Target value should be retrievable straight away + DALI_TEST_EQUALS( actor.GetProperty< Vector4 >( Actor::Property::COLOR ), Vector4( startValue, targetGreen, startValue, startValue ), TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::COLOR_GREEN ), targetGreen, TEST_LOCATION ); + bool signalReceived(false); AnimationFinishCheck finishCheck(signalReceived); animation.FinishedSignal().Connect(&application, finishCheck); application.SendNotification(); - application.Render(static_cast(durationSeconds*750.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(); - - // 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.GetCurrentColor().g, fiftyPercentProgress, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN), fiftyPercentProgress, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( 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.GetCurrentPosition(), targetPosition, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentColor().g, targetGreen, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN), targetGreen, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationMoveToVector3AlphaFloat2(void) +int UtcDaliAnimationAnimateToActorColorBlueP(void) { TestApplication application; Actor actor = Actor::New(); Stage::GetCurrent().Add(actor); - DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, 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 ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 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.MoveTo(actor, targetPosition, AlphaFunctions::Linear, delay, durationSeconds - delay); + float targetBlue(0.5f); + animation.AnimateTo( Property(actor, Actor::Property::COLOR_BLUE), targetBlue ); - Vector3 seventyFivePercentProgress(targetPosition * 0.75f); + float fiftyPercentProgress(startValue + (targetBlue - startValue)*0.5f); // Start the animation animation.Play(); + // Target value should be retrievable straight away + DALI_TEST_EQUALS( actor.GetProperty< Vector4 >( Actor::Property::COLOR ), Vector4( startValue, startValue, targetBlue, startValue ), TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::COLOR_BLUE ), targetBlue, 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 */); - - // 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*500.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.GetCurrentColor().b, fiftyPercentProgress, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ), fiftyPercentProgress, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), startValue, TEST_LOCATION ); application.SendNotification(); - application.Render(static_cast(durationSeconds*500.0f*0.25) + 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.GetCurrentPosition(), targetPosition, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentColor().b, targetBlue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ), targetBlue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), startValue, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationRotateByDegreeVector3(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 ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 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, relativeRotationDegrees/*Degree version*/, Vector3::YAXIS); + 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(); + // Target value should be retrievable straight away + DALI_TEST_EQUALS( actor.GetProperty< Vector4 >( Actor::Property::COLOR ), Vector4( startValue, startValue, startValue, targetAlpha ), TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::COLOR_ALPHA ), targetAlpha, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty< float >( DevelActor::Property::OPACITY ), targetAlpha, TEST_LOCATION ); + bool signalReceived(false); AnimationFinishCheck finishCheck(signalReceived); 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(relativeRotationRadians * 0.25f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentColor().a, fiftyPercentProgress, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), fiftyPercentProgress, TEST_LOCATION ); application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f)/* 50% 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.GetCurrentRotation(), Quaternion(relativeRotationRadians * 0.5f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetCurrentColor().a, targetAlpha, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), targetAlpha, TEST_LOCATION ); + END_TEST; +} - application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f)/* 75% progress */); +int UtcDaliAnimationKeyFrames01P(void) +{ + TestApplication application; - // 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 ); + KeyFrames keyFrames = KeyFrames::New(); + DALI_TEST_EQUALS(keyFrames.GetType(), Property::NONE, TEST_LOCATION); - application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/); + keyFrames.Add(0.0f, 0.1f); + + DALI_TEST_EQUALS(keyFrames.GetType(), Property::FLOAT, TEST_LOCATION); + + KeyFrames keyFrames2( keyFrames); + DALI_TEST_CHECK( keyFrames2 ); + DALI_TEST_EQUALS(keyFrames2.GetType(), Property::FLOAT, TEST_LOCATION); + + KeyFrames keyFrames3 = KeyFrames::New(); + keyFrames3.Add(0.6f, true); + DALI_TEST_CHECK( keyFrames3 ); + DALI_TEST_EQUALS(keyFrames3.GetType(), Property::BOOLEAN, TEST_LOCATION); + + keyFrames3 = keyFrames; + DALI_TEST_CHECK( keyFrames3 ); + DALI_TEST_EQUALS(keyFrames3.GetType(), Property::FLOAT, TEST_LOCATION); - // We did expect the animation to finish - application.SendNotification(); - finishCheck.CheckSignalReceived(); - DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationRotateByRadianVector3(void) +int UtcDaliAnimationKeyFrames02P(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 relativeRotationDegrees(360.0f); - Radian relativeRotationRadians(relativeRotationDegrees); - animation.RotateBy(actor, relativeRotationRadians/*Radian version*/, Vector3::YAXIS); + 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); - // 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); + 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; +} - application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f)/* 25% progress */); +int UtcDaliAnimationKeyFrames03P(void) +{ + TestApplication application; - // 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 ); + 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, 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); - // 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 ); + DALI_TEST_EQUALS(keyFrames.GetType(), Property::BOOLEAN, 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(); - DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * 0.75f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); +int UtcDaliAnimationKeyFrames04P(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(relativeRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, 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) + { + DALI_TEST_PRINT_ASSERT( e ); + DALI_TEST_ASSERT(e, "mType == value.GetType()", TEST_LOCATION); + } END_TEST; } -int UtcDaliAnimationRotateByDegreeVector3Alpha(void) +int UtcDaliAnimationKeyFrames05P(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 relativeRotationDegrees(360.0f); - Radian relativeRotationRadians(relativeRotationDegrees); - animation.RotateBy(actor, relativeRotationDegrees/*Degree version*/, Vector3::YAXIS, AlphaFunctions::EaseIn); + 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)); - // Start the animation - animation.Play(); + DALI_TEST_EQUALS(keyFrames.GetType(), Property::VECTOR3, TEST_LOCATION); - bool signalReceived(false); - AnimationFinishCheck finishCheck(signalReceived); - animation.FinishedSignal().Connect(&application, finishCheck); + 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; +} - application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f)/* 25% progress */); +int UtcDaliAnimationKeyFrames06P(void) +{ + TestApplication application; - // 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 ); + 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, 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)); - // 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 ); + DALI_TEST_EQUALS(keyFrames.GetType(), Property::VECTOR4, TEST_LOCATION); - application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f)/* 75% progress */); + 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; +} - // 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 ); +int UtcDaliAnimationKeyFrames07P(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(relativeRotationRadians, Vector3::YAXIS), 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)); + + DALI_TEST_EQUALS(keyFrames.GetType(), Property::ROTATION, 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 UtcDaliAnimationRotateByRadianVector3Alpha(void) +int UtcDaliAnimationAnimateBetweenActorColorAlphaP(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 ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 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); + + 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 ); // Start the animation animation.Play(); + // Final key frame value should be retrievable straight away + DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::COLOR_ALPHA ), 0.9f, TEST_LOCATION ); + bool signalReceived(false); AnimationFinishCheck finishCheck(signalReceived); animation.FinishedSignal().Connect(&application, finishCheck); - application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f)/* 25% progress */); + application.Render(0); + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.1f, TEST_LOCATION ); - // We didn't expect the animation to finish yet + application.Render(static_cast(durationSeconds*100.0f)/* 10% progress */); 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.GetCurrentProperty< float >( Actor::Property::COLOR_RED), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::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(); - application.Render(static_cast(durationSeconds*250.0f)/* 50% progress */); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA), 0.25f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.25f, 0.01f, TEST_LOCATION ); - // We didn't expect the animation to finish yet + application.Render(static_cast(durationSeconds*100.0f)/* 40% progress */); application.SendNotification(); - finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * AlphaFunctions::EaseIn(0.5f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( 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*250.0f)/* 75% progress */); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( 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.GetCurrentRotation(), Quaternion(relativeRotationRadians * AlphaFunctions::EaseIn(0.75f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA), 0.8f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.8f, 0.01f, TEST_LOCATION ); + application.Render(static_cast(durationSeconds*100.0f)+1/* 100% progress */); application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( 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.GetCurrentRotation(), Quaternion(relativeRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationRotateByDegreeVector3AlphaFloat2(void) +int UtcDaliAnimationAnimateBetweenActorColorAlphaCubicP(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 ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 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); + + 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(); @@ -7676,61 +8901,95 @@ int UtcDaliAnimationRotateByDegreeVector3AlphaFloat2(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(); - 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 ); + DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.1f, TEST_LOCATION ); + application.Render(static_cast(durationSeconds*100.0f)/* 10% progress */); application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f)/* 50% progress */); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.36f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.36f, 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(); - 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 ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.21f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.21f, 0.01f, TEST_LOCATION ); + application.Render(static_cast(durationSeconds*100.0f)/* 40% progress */); application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f)/* 75% progress */); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( 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(); - 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.GetCurrentProperty< float >( Actor::Property::COLOR_RED ), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( 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*250.0f) + 1u/*just beyond the animation duration*/); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.76f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.76f, 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.GetCurrentProperty< float >( Actor::Property::COLOR_RED ), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( 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.GetCurrentRotation(), Quaternion(relativeRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); END_TEST; } - -int UtcDaliAnimationRotateByRadianVector3AlphaFloat2(void) +int UtcDaliAnimationAnimateBetweenActorColorP(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 ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 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); + + 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(); @@ -7738,59 +8997,78 @@ int UtcDaliAnimationRotateByRadianVector3AlphaFloat2(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(); - 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 ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ), 0.1f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.2f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ), 0.3f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( 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.GetCurrentProperty< float >( Actor::Property::COLOR_RED ), 0.5f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.5f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ), 0.5f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( 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(); - 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 ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ), 0.9f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.8f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ), 0.7f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( 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(); - 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.GetCurrentProperty< float >( Actor::Property::COLOR_RED ), 0.95f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.90f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ), 0.85f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( 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.GetCurrentProperty< float >( Actor::Property::COLOR_RED ), 1.0f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 1.0f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ), 1.0f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( 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(), Quaternion(relativeRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationRotateToDegreeVector3(void) +int UtcDaliAnimationAnimateBetweenActorColorCubicP(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 ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( 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); + + 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(); @@ -7798,114 +9076,124 @@ int UtcDaliAnimationRotateToDegreeVector3(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.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.25f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ), 0.1f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.2f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ), 0.3f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( 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.GetCurrentProperty< float >( Actor::Property::COLOR_RED ), 0.55f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.525f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ), 0.506f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( 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.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.5f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ), 0.9f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.8f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ), 0.7f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( 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.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.75f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ), 0.99375f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.925f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ), 0.85625f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( 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.GetCurrentProperty< float >( Actor::Property::COLOR_RED ), 1.0f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 1.0f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ), 1.0f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( 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(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationRotateToRadianVector3(void) +int UtcDaliAnimationAnimateBetweenActorVisibleP(void) { TestApplication application; Actor actor = Actor::New(); - actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS)); + AngleAxis aa(Degree(90), Vector3::XAXIS); + actor.SetOrientation(aa.angle, aa.axis); Stage::GetCurrent().Add(actor); - DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, 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); - Degree targetRotationDegrees(90.0f); - Radian targetRotationRadians(targetRotationDegrees); - animation.RotateTo(actor, targetRotationRadians/*Radian version*/, Vector3::YAXIS); + + 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(); + // Final key frame value should be retrievable straight away + DALI_TEST_EQUALS( actor.GetProperty< bool >( Actor::Property::VISIBLE ), true, TEST_LOCATION ); + 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(), Quaternion(targetRotationRadians * 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 * 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.Render(static_cast(durationSeconds*500.0f)); application.SendNotification(); - finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.75f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); - + application.Render(static_cast(durationSeconds*500.0f)+1); application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/); - // We did expect the animation to finish - application.SendNotification(); + DALI_TEST_EQUALS( actor.IsVisible(), true, TEST_LOCATION); finishCheck.CheckSignalReceived(); - DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationRotateToQuaternion(void) +int UtcDaliAnimationAnimateBetweenActorVisibleCubicP(void) { TestApplication application; Actor actor = Actor::New(); - actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS)); + AngleAxis aa(Degree(90), Vector3::XAXIS); + actor.SetOrientation(aa.angle, aa.axis); Stage::GetCurrent().Add(actor); - DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, 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); - Degree targetRotationDegrees(90.0f); - Radian targetRotationRadians(targetRotationDegrees); - Quaternion targetRotation(targetRotationRadians, Vector3::YAXIS); - animation.RotateTo(actor, targetRotation/*Quaternion version*/); + + KeyFrames keyFrames = KeyFrames::New(); + keyFrames.Add(0.0f, false); + keyFrames.Add(0.2f, true); + keyFrames.Add(0.4f, true); + keyFrames.Add(0.8f, false); + keyFrames.Add(1.0f, true); + + //Cubic interpolation for boolean values should be ignored + animation.AnimateBetween( Property(actor, Actor::Property::VISIBLE), keyFrames, Animation::Cubic ); // Start the animation animation.Play(); @@ -7913,113 +9201,88 @@ int UtcDaliAnimationRotateToQuaternion(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.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 */); - - // 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.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f)/* 75% progress */); - - // We didn't expect the animation to finish yet + application.Render(static_cast(durationSeconds*500.0f)); application.SendNotification(); - finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.75f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); - + application.Render(static_cast(durationSeconds*500.0f)+1); application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/); - // We did expect the animation to finish - application.SendNotification(); + DALI_TEST_EQUALS( actor.IsVisible(), true, TEST_LOCATION); finishCheck.CheckSignalReceived(); - DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationRotateToDegreeVector3Alpha(void) +int UtcDaliAnimationAnimateBetweenActorOrientation01P(void) { TestApplication application; Actor actor = Actor::New(); - actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS)); + AngleAxis aa(Degree(90), Vector3::XAXIS); + actor.SetOrientation(aa.angle, aa.axis); Stage::GetCurrent().Add(actor); - DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + + application.SendNotification(); + application.Render(0); + 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); - Degree targetRotationDegrees(90.0f); - Radian targetRotationRadians(targetRotationDegrees); - animation.RotateTo(actor, targetRotationDegrees/*Degree version*/, Vector3::YAXIS, AlphaFunctions::EaseIn); + + 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(); + // Final key frame value should be retrievable straight away + DALI_TEST_EQUALS( actor.GetProperty< Quaternion >( Actor::Property::ORIENTATION ), Quaternion( Degree( 60 ), Vector3::ZAXIS ), TEST_LOCATION ); + 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(), 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 */); - - // 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 ); - + application.Render(static_cast(durationSeconds*500.0f)); application.SendNotification(); - application.Render(static_cast(durationSeconds*250.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.GetCurrentRotation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationRotateToRadianVector3Alpha(void) +int UtcDaliAnimationAnimateBetweenActorOrientation02P(void) { TestApplication application; Actor actor = Actor::New(); - actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS)); + 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.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, 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); - Degree targetRotationDegrees(90.0f); - Radian targetRotationRadians(targetRotationDegrees); - animation.RotateTo(actor, targetRotationRadians/*Radian version*/, Vector3::YAXIS, AlphaFunctions::EaseIn); + + 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(); @@ -8027,57 +9290,63 @@ int UtcDaliAnimationRotateToRadianVector3Alpha(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.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(0.25f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); - application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f)/* 50% progress */); + Quaternion check(Radian(Degree(60)), 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)/* 25% progress */); application.SendNotification(); - finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(0.5f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + 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*250.0f)/* 75% 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(); - DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(0.75f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + 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*250.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.GetCurrentRotation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationRotateToQuaternionAlpha(void) +int UtcDaliAnimationAnimateBetweenActorOrientation01CubicP(void) { TestApplication application; Actor actor = Actor::New(); - actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS)); + AngleAxis aa(Degree(90), Vector3::XAXIS); + actor.SetOrientation(aa.angle, aa.axis); Stage::GetCurrent().Add(actor); - DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + + application.SendNotification(); + application.Render(0); + 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); - Degree targetRotationDegrees(90.0f); - Radian targetRotationRadians(targetRotationDegrees); - Quaternion targetRotation(targetRotationRadians, Vector3::YAXIS); - animation.RotateTo(actor, targetRotation/*Quaternion version*/, AlphaFunctions::EaseIn); + + 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(); @@ -8085,57 +9354,45 @@ int UtcDaliAnimationRotateToQuaternionAlpha(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.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.Render(static_cast(durationSeconds*500.0f)); application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f)/* 75% 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.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(0.75f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); - application.SendNotification(); - application.Render(static_cast(durationSeconds*250.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.GetCurrentRotation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationRotateToDegreeVector3AlphaFloat2(void) +int UtcDaliAnimationAnimateBetweenActorOrientation02CubicP(void) { TestApplication application; Actor actor = Actor::New(); - actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS)); + 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.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, 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); - 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 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(); @@ -8143,60 +9400,69 @@ int UtcDaliAnimationRotateToDegreeVector3AlphaFloat2(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(); - 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 */); + Quaternion check(Radian(Degree(60)), 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)/* 25% progress */); 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 ); + 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*250.0f)/* 75% 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(); - 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 ); + 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*250.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.GetCurrentRotation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationRotateToRadianVector3AlphaFloat2(void) +int UtcDaliAnimationAnimateBetweenActorColorAlphaFunctionP(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 ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( 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); - float delay(0.1f); - animation.RotateTo(actor, targetRotationRadians/*Radian version*/, Vector3::YAXIS, AlphaFunctions::EaseIn, delay, durationSeconds - delay); + + 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(); @@ -8204,61 +9470,78 @@ int UtcDaliAnimationRotateToRadianVector3AlphaFloat2(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(); - 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 ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ), 0.1f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.2f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ), 0.3f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( 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.GetCurrentProperty< float >( Actor::Property::COLOR_RED ), 0.5f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.5f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ), 0.5f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( 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(); - 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( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ), 0.9f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.8f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ), 0.7f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( 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(); - 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 ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ), 0.95f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.90f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ), 0.85f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( 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.GetCurrentProperty< float >( Actor::Property::COLOR_RED ), 1.0f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 1.0f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ), 1.0f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( 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(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationRotateToQuaternionAlphaFloat2(void) +int UtcDaliAnimationAnimateBetweenActorColorAlphaFunctionCubicP(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 ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( 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); - float delay(0.1f); - Quaternion targetRotation(targetRotationRadians, Vector3::YAXIS); - animation.RotateTo(actor, targetRotation/*Quaternion version*/, AlphaFunctions::EaseIn, delay, durationSeconds - delay); + + 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(); @@ -8266,60 +9549,79 @@ int UtcDaliAnimationRotateToQuaternionAlphaFloat2(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(); - 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 ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ), 0.1f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.2f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ), 0.3f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( 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.GetCurrentProperty< float >( Actor::Property::COLOR_RED ), 0.55f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.525f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ), 0.506f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( 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(); - 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( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ), 0.9f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.8f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ), 0.7f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( 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(); - 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 ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ), 0.99375f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.925f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ), 0.85625f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( 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.GetCurrentProperty< float >( Actor::Property::COLOR_RED ), 1.0f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 1.0f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ), 1.0f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( 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(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationScaleBy(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); - 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 ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), startValue, TEST_LOCATION ); // Build the animation float durationSeconds(1.0f); + float delay = 0.5f; 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); + 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(); @@ -8327,107 +9629,161 @@ int UtcDaliAnimationScaleBy(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(static_cast(delay*1000.0f)/* 0% progress */); application.SendNotification(); finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetCurrentScale(), ninetyNinePercentProgress, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ), 0.1f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.2f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ), 0.3f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( 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*10.0f) + 1u/*just beyond the animation duration*/); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ), 0.5f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.5f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ), 0.5f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.5f, 0.01f, TEST_LOCATION ); - // We did expect the animation to finish + application.Render(static_cast((durationSeconds - delay)*250.0f)/* 50% progress */); application.SendNotification(); - finishCheck.CheckSignalReceived(); - DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ), 0.9f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.8f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ), 0.7f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.6f, 0.01f, TEST_LOCATION ); - // Reset everything - finishCheck.Reset(); - actor.SetScale(Vector3::ONE); + application.Render(static_cast((durationSeconds - delay)*250.0f)/* 75% progress */); 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(); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ), 0.95f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.90f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ), 0.85f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( 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*990.0f)/* 99% progress */); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ), 1.0f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 1.0f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ), 1.0f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( 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 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 ); + finishCheck.CheckSignalReceived(); + END_TEST; +} - application.SendNotification(); - application.Render(static_cast(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/); +int UtcDaliAnimationAnimateBetweenActorColorTimePeriodCubicP(void) +{ + TestApplication application; - // We did expect the animation to finish - application.SendNotification(); - finishCheck.CheckSignalReceived(); - DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, 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.SetScale(Vector3::ONE); - application.SendNotification(); - application.Render(0); - 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 ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), startValue, TEST_LOCATION ); - // Repeat with a delay + // Build the animation + float durationSeconds(1.0f); float delay = 0.5f; - animation = Animation::New(durationSeconds); - animation.ScaleBy(actor, relativeScale, AlphaFunctions::Linear, delay, durationSeconds - delay); - animation.FinishedSignal().Connect(&application, finishCheck); + 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, TimePeriod( delay, durationSeconds - delay ), 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.Render(static_cast(delay*1000.0f)/* 0% progress */); application.SendNotification(); finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ), 0.1f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.2f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ), 0.3f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( 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*500.0f) + 1u/*just beyond the animation duration*/); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ), 0.55f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.525f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ), 0.506f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.4875f, 0.01f, TEST_LOCATION ); - // We did expect the animation to finish + application.Render(static_cast((durationSeconds - delay)*250.0f)/* 50% progress */); + application.SendNotification(); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ), 0.9f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN), 0.8f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ), 0.7f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.6f, 0.01f, TEST_LOCATION ); + + application.Render(static_cast((durationSeconds - delay)*250.0f)/* 75% progress */); + application.SendNotification(); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ), 0.99375f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.925f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ), 0.85625f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.7875f, 0.01f, TEST_LOCATION ); + + application.Render(static_cast((durationSeconds - delay)*250.0f)+1/* 100% progress */); application.SendNotification(); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ), 1.0f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 1.0f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ), 1.0f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 1.0f, 0.01f, TEST_LOCATION ); + + // We did expect the animation to finish + finishCheck.CheckSignalReceived(); - DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationScaleTo(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); - 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 ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( 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); + 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(); @@ -8435,246 +9791,319 @@ int UtcDaliAnimationScaleTo(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(static_cast(delay*1000.0f)/* 0% progress */); 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 ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ), 0.1f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.2f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ), 0.3f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.4f, 0.01f, TEST_LOCATION ); - // Reset everything - finishCheck.Reset(); - actor.SetScale(Vector3::ONE); + application.Render(static_cast((durationSeconds - delay)*250.0f)/* 25% progress */); 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(); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ), 0.5f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.5f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ), 0.5f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( 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*990.0f)/* 99% progress */); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ), 0.9f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.8f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ), 0.7f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( 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(); - - // 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 ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ), 0.95f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.90f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ), 0.85f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( 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*10.0f) + 1u/*just beyond the animation duration*/); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ), 1.0f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 1.0f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ), 1.0f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( 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.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) +int UtcDaliAnimationAnimateBetweenActorColorCubicWithDelayP(void) { TestApplication application; + float startValue(1.0f); Actor actor = Actor::New(); - actor.SetVisible(false); - application.SendNotification(); - application.Render(0); - DALI_TEST_CHECK( !actor.IsVisible() ); + actor.SetColor(Vector4(startValue, startValue, startValue, startValue)); Stage::GetCurrent().Add(actor); - // Start the animation - float durationSeconds(10.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 ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), startValue, TEST_LOCATION ); + + + // Build the animation + float durationSeconds(1.0f); + float delay = 0.5f; Animation animation = Animation::New(durationSeconds); - animation.Show(actor, durationSeconds*0.5f); + + 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 ), 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*490.0f)); - // We didn't expect the animation to finish yet + application.Render(static_cast(delay*1000.0f)/* 0% progress */); application.SendNotification(); finishCheck.CheckSignalNotReceived(); - DALI_TEST_CHECK( !actor.IsVisible() ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ), 0.1f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.2f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ), 0.3f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( 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*10.0f)/*Should be shown now*/); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ), 0.55f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.525f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ), 0.506f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.4875f, 0.01f, TEST_LOCATION ); - // We didn't expect the animation to finish yet + application.Render(static_cast((durationSeconds - delay)*250.0f)/* 50% progress */); application.SendNotification(); - finishCheck.CheckSignalNotReceived(); - DALI_TEST_CHECK( actor.IsVisible() ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ), 0.9f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.8f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ), 0.7f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.6f, 0.01f, TEST_LOCATION ); + application.Render(static_cast((durationSeconds - delay)*250.0f)/* 75% progress */); application.SendNotification(); - application.Render(static_cast(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ), 0.99375f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.925f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ), 0.85625f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.7875f, 0.01f, TEST_LOCATION ); - // We did expect the animation to finish + application.Render(static_cast((durationSeconds - delay)*250.0f)+1/* 100% progress */); application.SendNotification(); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ), 1.0f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 1.0f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ), 1.0f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 1.0f, 0.01f, TEST_LOCATION ); + + // We did expect the animation to finish + finishCheck.CheckSignalReceived(); - DALI_TEST_CHECK( actor.IsVisible() ); END_TEST; } -int UtcDaliAnimationHide(void) +int UtcDaliAnimationAnimateP(void) { TestApplication application; Actor actor = Actor::New(); - DALI_TEST_CHECK( actor.IsVisible() ); Stage::GetCurrent().Add(actor); - // Start the animation - float durationSeconds(10.0f); + //Build the path + Vector3 position0( 30.0, 80.0, 0.0); + Vector3 position1( 70.0, 120.0, 0.0); + Vector3 position2( 100.0, 100.0, 0.0); + + Dali::Path path = Dali::Path::New(); + path.AddPoint(position0); + path.AddPoint(position1); + path.AddPoint(position2); + + //Control points for first segment + path.AddControlPoint( Vector3( 39.0, 90.0, 0.0) ); + path.AddControlPoint(Vector3( 56.0, 119.0, 0.0) ); + + //Control points for second segment + path.AddControlPoint(Vector3( 78.0, 120.0, 0.0)); + path.AddControlPoint(Vector3( 93.0, 104.0, 0.0)); + + // Build the animation + float durationSeconds( 1.0f ); Animation animation = Animation::New(durationSeconds); - animation.Hide(actor, durationSeconds*0.5f); + animation.Animate(actor, path, Vector3::XAXIS); + + // Start the animation 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.Render(0); application.SendNotification(); finishCheck.CheckSignalNotReceived(); - DALI_TEST_CHECK( actor.IsVisible() ); + 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*10.0f)/*Should be hidden now*/); + 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_CHECK( !actor.IsVisible() ); + 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_CHECK( !actor.IsVisible() ); END_TEST; } -int UtcDaliAnimationShowHideAtEnd(void) +int UtcDaliAnimationAnimateAlphaFunctionP(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); + //Build the path + Vector3 position0( 30.0, 80.0, 0.0); + Vector3 position1( 70.0, 120.0, 0.0); + Vector3 position2( 100.0, 100.0, 0.0); + + Dali::Path path = Dali::Path::New(); + path.AddPoint(position0); + path.AddPoint(position1); + path.AddPoint(position2); + + //Control points for first segment + path.AddControlPoint( Vector3( 39.0, 90.0, 0.0) ); + path.AddControlPoint(Vector3( 56.0, 119.0, 0.0) ); + + //Control points for second segment + path.AddControlPoint(Vector3( 78.0, 120.0, 0.0)); + path.AddControlPoint(Vector3( 93.0, 104.0, 0.0)); + + // Build the animation + float durationSeconds( 1.0f ); Animation animation = Animation::New(durationSeconds); - animation.Hide(actor, durationSeconds/*Hide at end*/); + animation.Animate(actor, path, Vector3::XAXIS, AlphaFunction::LINEAR); + + // Start the animation 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*/); + 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 ); - // We did expect the animation to finish + application.Render(static_cast(durationSeconds*250.0f)/* 25% progress */); application.SendNotification(); - finishCheck.CheckSignalReceived(); - DALI_TEST_CHECK( !actor.IsVisible() ); + 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 ); - // Start Show animation - animation = Animation::New(durationSeconds); - animation.Show(actor, durationSeconds/*Show at end*/); - animation.FinishedSignal().Connect(&application, finishCheck); - animation.Play(); + application.Render(static_cast(durationSeconds*250.0f)/* 50% progress */); + application.SendNotification(); + path.Sample( 0.5f, position, tangent ); + rotation = Quaternion( Vector3::XAXIS, tangent ); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION ); + application.Render(static_cast(durationSeconds*250.0f)/* 75% progress */); application.SendNotification(); - application.Render(static_cast(durationSeconds*1000.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_CHECK( actor.IsVisible() ); END_TEST; } -int UtcDaliAnimationOpacityBy(void) +int UtcDaliAnimationAnimateTimePeriodP(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 path + Vector3 position0( 30.0, 80.0, 0.0); + Vector3 position1( 70.0, 120.0, 0.0); + Vector3 position2( 100.0, 100.0, 0.0); + + Dali::Path path = Dali::Path::New(); + path.AddPoint(position0); + path.AddPoint(position1); + path.AddPoint(position2); + + //Control points for first segment + path.AddControlPoint( Vector3( 39.0, 90.0, 0.0) ); + path.AddControlPoint(Vector3( 56.0, 119.0, 0.0) ); + + //Control points for second segment + path.AddControlPoint(Vector3( 78.0, 120.0, 0.0)); + path.AddControlPoint(Vector3( 93.0, 104.0, 0.0)); + // Build the animation - float durationSeconds(1.0f); + float durationSeconds( 1.0f ); Animation animation = Animation::New(durationSeconds); - float relativeOpacity(-0.5f); // target of zero - animation.OpacityBy(actor, relativeOpacity); - - float seventyFivePercentProgress((1.0f - 0.75f) * startingOpacity); + animation.Animate(actor, path, Vector3::XAXIS, TimePeriod(0.0f, 1.0f)); // Start the animation animation.Play(); @@ -8682,111 +10111,78 @@ 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(); + 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 ); - // 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.SendNotification(); - application.Render(static_cast(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */); - - // 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.GetCurrentOpacity(), startingOpacity, 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(); - application.Render(static_cast(durationSeconds*500.0f*0.75)/* 7/8 animation progress, 3/4 animator progress */); + 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 ); - // 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.GetCurrentOpacity(), seventyFivePercentProgress, 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(); - application.Render(static_cast(durationSeconds*500.0f*0.25) + 1u/*just beyond the animation duration*/); + 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 ); - // We did expect the animation to finish - application.SendNotification(); finishCheck.CheckSignalReceived(); - DALI_TEST_EQUALS( actor.GetCurrentOpacity(), startingOpacity+relativeOpacity, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationOpacityTo(void) +int UtcDaliAnimationAnimateAlphaFunctionTimePeriodP(void) { TestApplication application; Actor actor = Actor::New(); Stage::GetCurrent().Add(actor); - DALI_TEST_EQUALS( actor.GetCurrentOpacity(), 1.0f, 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); + + Dali::Path path = Dali::Path::New(); + path.AddPoint(position0); + path.AddPoint(position1); + path.AddPoint(position2); + + //Control points for first segment + path.AddControlPoint( Vector3( 39.0, 90.0, 0.0) ); + path.AddControlPoint(Vector3( 56.0, 119.0, 0.0) ); + + //Control points for second segment + path.AddControlPoint(Vector3( 78.0, 120.0, 0.0)); + path.AddControlPoint(Vector3( 93.0, 104.0, 0.0)); // Build the animation - float durationSeconds(1.0f); + float durationSeconds( 1.0f ); Animation animation = Animation::New(durationSeconds); - float targetOpacity(0.0f); - animation.OpacityTo(actor, targetOpacity); - - float ninetyNinePercentProgress(0.01f); + animation.Animate(actor, path, Vector3::XAXIS, AlphaFunction::LINEAR, TimePeriod(0.0f, 1.0f)); // Start the animation animation.Play(); @@ -8794,110 +10190,64 @@ 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(); + 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 ); - // 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.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.Render(static_cast(durationSeconds*250.0f)/* 25% 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(); + 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(); - application.Render(static_cast(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */); + 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 ); - // 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.GetCurrentOpacity(), 1.0f, 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(); - application.Render(static_cast(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/); + 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 ); - // 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 UtcDaliAnimationShowP(void) { TestApplication application; Actor actor = Actor::New(); - actor.SetColor(Color::BLACK); + actor.SetVisible(false); application.SendNotification(); application.Render(0); - DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::BLACK, TEST_LOCATION ); + DALI_TEST_CHECK( !actor.IsVisible() ); Stage::GetCurrent().Add(actor); - // 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)); - // Start the animation + float durationSeconds(10.0f); + Animation animation = Animation::New(durationSeconds); + animation.Show(actor, durationSeconds*0.5f); animation.Play(); bool signalReceived(false); @@ -8905,86 +10255,64 @@ int UtcDaliAnimationColorBy(void) animation.FinishedSignal().Connect(&application, finishCheck); application.SendNotification(); - application.Render(static_cast(durationSeconds*100.0f)/* 10% 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.GetCurrentWorldColor(), tenPercentProgress, TEST_LOCATION ); - - application.SendNotification(); - 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.GetCurrentWorldColor(), targetColor, TEST_LOCATION ); - - // Reset everything - finishCheck.Reset(); - actor.SetColor(Color::BLACK); - 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_CHECK( !actor.IsVisible() ); application.SendNotification(); - application.Render(static_cast(durationSeconds*100.0f)/* 10% progress */); + application.Render(static_cast(durationSeconds*10.0f)/*Should be shown now*/); // 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.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 + DALI_TEST_CHECK( actor.IsVisible() ); application.SendNotification(); - application.Render(static_cast(durationSeconds*900.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.GetCurrentWorldColor(), targetColor, TEST_LOCATION ); + DALI_TEST_CHECK( actor.IsVisible() ); + END_TEST; +} - // Reset everything - finishCheck.Reset(); - actor.SetColor(Color::BLACK); - application.SendNotification(); - application.Render(0); - DALI_TEST_EQUALS( actor.GetCurrentWorldColor(), Color::BLACK, TEST_LOCATION ); +int UtcDaliAnimationHideP(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(); - // Repeat with a shorter animator duration - float animatorDuration = 0.5f; - animation = Animation::New(durationSeconds); - animation.ColorBy(actor, relativeColor, AlphaFunctions::Linear, 0, animatorDuration); + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); 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*490.0f)); // We didn't expect the animation to finish yet application.SendNotification(); finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetCurrentWorldColor(), twentyPercentProgress, TEST_LOCATION ); + DALI_TEST_CHECK( actor.IsVisible() ); application.SendNotification(); - application.Render(static_cast(durationSeconds*400.0f)/* 50% animation progress, 100% animator 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.GetCurrentWorldColor(), targetColor, TEST_LOCATION ); + DALI_TEST_CHECK( !actor.IsVisible() ); application.SendNotification(); application.Render(static_cast(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/); @@ -8992,28 +10320,25 @@ int UtcDaliAnimationColorBy(void) // We did expect the animation to finish application.SendNotification(); finishCheck.CheckSignalReceived(); - DALI_TEST_EQUALS( actor.GetCurrentWorldColor(), targetColor, TEST_LOCATION ); + DALI_TEST_CHECK( !actor.IsVisible() ); END_TEST; } -int UtcDaliAnimationColorTo(void) +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); - DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION ); - // Build the animation - float durationSeconds(1.0f); + // Start Hide animation + float durationSeconds(10.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)); - - // Start the animation + animation.Hide(actor, durationSeconds/*Hide at end*/); animation.Play(); bool signalReceived(false); @@ -9021,823 +10346,867 @@ int UtcDaliAnimationColorTo(void) 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.SendNotification(); - application.Render(static_cast(durationSeconds*900.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.GetCurrentColor(), targetColor, TEST_LOCATION ); - - // Reset everything - finishCheck.Reset(); - actor.SetColor(Color::WHITE); - application.SendNotification(); - application.Render(0); - DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION ); + DALI_TEST_CHECK( !actor.IsVisible() ); - // Repeat with a different (ease-in) alpha function + // Start Show animation animation = Animation::New(durationSeconds); - animation.ColorTo(actor, targetColor, AlphaFunctions::EaseIn); + animation.Show(actor, durationSeconds/*Show at end*/); animation.FinishedSignal().Connect(&application, finishCheck); animation.Play(); application.SendNotification(); - application.Render(static_cast(durationSeconds*100.0f)/* 10% 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(); + finishCheck.CheckSignalReceived(); + DALI_TEST_CHECK( actor.IsVisible() ); + END_TEST; +} - // 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 +int UtcDaliKeyFramesCreateDestroyP(void) +{ + tet_infoline("Testing Dali::Animation::UtcDaliKeyFramesCreateDestroy()"); - application.SendNotification(); - application.Render(static_cast(durationSeconds*900.0f) + 1u/*just beyond the animation duration*/); + KeyFrames* keyFrames = new KeyFrames; + delete keyFrames; + DALI_TEST_CHECK( true ); + END_TEST; +} - // We did expect the animation to finish - application.SendNotification(); - finishCheck.CheckSignalReceived(); - DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION ); +int UtcDaliKeyFramesDownCastP(void) +{ + TestApplication application; + tet_infoline("Testing Dali::Animation::KeyFramesDownCast()"); - // Reset everything - finishCheck.Reset(); - actor.SetColor(Color::WHITE); - application.SendNotification(); - application.Render(0); - DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION ); + KeyFrames keyFrames = KeyFrames::New(); + BaseHandle object(keyFrames); - // Repeat with a shorter animator duration - float animatorDuration = 0.5f; - animation = Animation::New(durationSeconds); - animation.ColorTo(actor, targetColor, AlphaFunctions::Linear, 0, animatorDuration); - animation.FinishedSignal().Connect(&application, finishCheck); - animation.Play(); + KeyFrames keyFrames2 = KeyFrames::DownCast(object); + DALI_TEST_CHECK(keyFrames2); - application.SendNotification(); - application.Render(static_cast(durationSeconds*100.0f)/* 10% animation progress, 20% animator progress */); + KeyFrames keyFrames3 = DownCast< KeyFrames >(object); + DALI_TEST_CHECK(keyFrames3); - // We didn't expect the animation to finish yet - application.SendNotification(); - finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetCurrentColor(), twentyPercentProgress, TEST_LOCATION ); + BaseHandle unInitializedObject; + KeyFrames keyFrames4 = KeyFrames::DownCast(unInitializedObject); + DALI_TEST_CHECK(!keyFrames4); - application.SendNotification(); - application.Render(static_cast(durationSeconds*400.0f)/* 50% animation progress, 100% animator progress */); + KeyFrames keyFrames5 = DownCast< KeyFrames >(unInitializedObject); + DALI_TEST_CHECK(!keyFrames5); + END_TEST; +} + +int UtcDaliAnimationCreateDestroyP(void) +{ + TestApplication application; + Animation* animation = new Animation; + DALI_TEST_CHECK( animation ); + delete animation; + END_TEST; +} + +struct UpdateManagerTestConstraint +{ + UpdateManagerTestConstraint(TestApplication& application) + : mApplication(application) + { + } + + void operator()( Vector3& current, const PropertyInputContainer& /* inputs */) + { + mApplication.SendNotification(); // Process events + } + + TestApplication& mApplication; +}; + +int UtcDaliAnimationUpdateManagerP(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + Stage::GetCurrent().Add( actor ); + + // Build the animation + Animation animation = Animation::New( 0.0f ); + + bool signalReceived = false; + AnimationFinishCheck finishCheck( signalReceived ); + animation.FinishedSignal().Connect( &application, finishCheck ); + + Vector3 startValue(1.0f, 1.0f, 1.0f); + Property::Index index = actor.RegisterProperty( "testProperty", startValue ); + Constraint constraint = Constraint::New( actor, index, UpdateManagerTestConstraint( application ) ); + constraint.Apply(); + + // Apply animation to actor + 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(); - // We didn't expect the animation to finish yet application.SendNotification(); + application.UpdateOnly( 16 ); + 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*/); + application.SendNotification(); // Process events - // We did expect the animation to finish - application.SendNotification(); finishCheck.CheckSignalReceived(); - DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION ); + END_TEST; } -int UtcDaliAnimationResize(void) +int UtcDaliAnimationSignalOrderP(void) { TestApplication application; Actor actor = Actor::New(); - Stage::GetCurrent().Add(actor); - DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION ); + Stage::GetCurrent().Add( actor ); - // Build the animation - float durationSeconds(1.0f); - Animation animation = Animation::New(durationSeconds); - Vector3 targetSize(100.0f, 100.0f, 100.0f); - animation.Resize(actor, targetSize); + // Build the animations + Animation animation1 = Animation::New( 0.0f ); // finishes first frame + Animation animation2 = Animation::New( 0.02f ); // finishes in 20 ms - Vector3 ninetyNinePercentProgress(targetSize * 0.99f); + bool signal1Received = false; + animation1.FinishedSignal().Connect( &application, AnimationFinishCheck( signal1Received ) ); - // Start the animation - animation.Play(); + bool signal2Received = false; + animation2.FinishedSignal().Connect( &application, AnimationFinishCheck( signal2Received ) ); - bool signalReceived(false); - AnimationFinishCheck finishCheck(signalReceived); - animation.FinishedSignal().Connect(&application, finishCheck); + // Apply animations to actor + animation1.AnimateTo( Property(actor, Actor::Property::POSITION), Vector3( 3.0f, 2.0f, 1.0f ), AlphaFunction::LINEAR ); + animation1.Play(); + animation2.AnimateTo( Property(actor, Actor::Property::SIZE ), Vector3( 10.0f, 20.0f, 30.0f ), AlphaFunction::LINEAR ); + animation2.Play(); - application.SendNotification(); - application.Render(static_cast(durationSeconds*990.0f)/* 99% progress */); + DALI_TEST_EQUALS( signal1Received, false, TEST_LOCATION ); + DALI_TEST_EQUALS( signal2Received, false, TEST_LOCATION ); - // We didn't expect the animation to finish yet application.SendNotification(); - finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetCurrentSize(), ninetyNinePercentProgress, TEST_LOCATION ); + application.UpdateOnly( 10 ); // 10ms progress - application.SendNotification(); - application.Render(static_cast(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/); + // no notifications yet + DALI_TEST_EQUALS( signal1Received, false, TEST_LOCATION ); + DALI_TEST_EQUALS( signal2Received, false, TEST_LOCATION ); - // 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 ); + // first completed + DALI_TEST_EQUALS( signal1Received, true, TEST_LOCATION ); + DALI_TEST_EQUALS( signal2Received, false, TEST_LOCATION ); + signal1Received = false; - // 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(); + // 1st animation is complete now, do another update with no ProcessEvents in between + application.UpdateOnly( 20 ); // 20ms progress + // ProcessEvents application.SendNotification(); - application.Render(static_cast(durationSeconds*990.0f)/* 99% progress */); - // We didn't expect the animation to finish yet - application.SendNotification(); - finishCheck.CheckSignalNotReceived(); + // 2nd should complete now + DALI_TEST_EQUALS( signal1Received, false, TEST_LOCATION ); + DALI_TEST_EQUALS( signal2Received, true, TEST_LOCATION ); + + END_TEST; +} + +int UtcDaliAnimationExtendDurationP(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.GetProperty(index), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), startValue, TEST_LOCATION ); + + // Build the animation + float initialDurationSeconds(1.0f); + float animatorDelay = 5.0f; + float animatorDurationSeconds(5.0f); + float extendedDurationSeconds(animatorDelay+animatorDurationSeconds); + Animation animation = Animation::New(initialDurationSeconds); + float targetValue(30.0f); + float relativeValue(targetValue - startValue); + + animation.AnimateTo(Property(actor, index), + targetValue, + TimePeriod(animatorDelay, animatorDurationSeconds)); + + // The duration should have been extended + DALI_TEST_EQUALS( animation.GetDuration(), extendedDurationSeconds, TEST_LOCATION ); - // 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 ); + // Start the animation + animation.Play(); - application.SendNotification(); - application.Render(static_cast(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/); + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); - // We did expect the animation to finish application.SendNotification(); - finishCheck.CheckSignalReceived(); - DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION ); + application.Render(static_cast(extendedDurationSeconds*500.0f)/* 50% animation progress, 0% animator progress */); - // Reset everything - finishCheck.Reset(); - actor.SetSize(Vector3::ZERO); + // We didn't expect the animation to finish yet, but cached value should be the final one application.SendNotification(); - application.Render(0); - DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION ); - - // Repeat with a delay - float delay = 0.5f; - animation = Animation::New(durationSeconds); - animation.Resize(actor, targetSize, AlphaFunctions::Linear, delay, durationSeconds - delay); - animation.FinishedSignal().Connect(&application, finishCheck); - animation.Play(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetProperty< float >( index ), targetValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), startValue, TEST_LOCATION ); application.SendNotification(); - application.Render(static_cast(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */); + application.Render(static_cast(extendedDurationSeconds*250.0f)/* 75% animation progress, 50% animator progress */); // We didn't expect the animation to finish yet application.SendNotification(); finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), startValue+(relativeValue*0.5f), TEST_LOCATION ); application.SendNotification(); - application.Render(static_cast(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/); + application.Render(static_cast(extendedDurationSeconds*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 ); - END_TEST; -} - -int UtcDaliKeyFramesCreateDestroy(void) -{ - tet_infoline("Testing Dali::Animation::UtcDaliKeyFramesCreateDestroy()"); - - KeyFrames* keyFrames = new KeyFrames; - delete keyFrames; - DALI_TEST_CHECK( true ); - END_TEST; -} - -int UtcDaliKeyFramesDownCast(void) -{ - TestApplication application; - tet_infoline("Testing Dali::Animation::KeyFramesDownCast()"); - - KeyFrames keyFrames = KeyFrames::New(); - BaseHandle object(keyFrames); - - KeyFrames keyFrames2 = KeyFrames::DownCast(object); - DALI_TEST_CHECK(keyFrames2); - - KeyFrames keyFrames3 = DownCast< KeyFrames >(object); - DALI_TEST_CHECK(keyFrames3); - - BaseHandle unInitializedObject; - KeyFrames keyFrames4 = KeyFrames::DownCast(unInitializedObject); - DALI_TEST_CHECK(!keyFrames4); - - KeyFrames keyFrames5 = DownCast< KeyFrames >(unInitializedObject); - DALI_TEST_CHECK(!keyFrames5); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), targetValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty< float >( index ), targetValue, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationResizeByXY(void) +int UtcDaliAnimationCustomIntProperty(void) { TestApplication application; Actor actor = Actor::New(); Stage::GetCurrent().Add(actor); - DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION ); + int startValue(0u); + + Property::Index index = actor.RegisterProperty("anIndex", startValue); + DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty< int >( 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.Resize(actor, targetSize); - - Vector3 ninetyNinePercentProgress(targetSize * 0.99f); + animation.AnimateTo( Property(actor, index), 20 ); // Start the animation animation.Play(); + // Target value should be retrievable straight away + DALI_TEST_EQUALS( actor.GetProperty< int >( index ), 20, TEST_LOCATION ); + bool signalReceived(false); AnimationFinishCheck finishCheck(signalReceived); animation.FinishedSignal().Connect(&application, finishCheck); application.SendNotification(); - application.Render(static_cast(durationSeconds*990.0f)/* 99% 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.GetCurrentSize(), ninetyNinePercentProgress, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), 10, TEST_LOCATION ); application.SendNotification(); - application.Render(static_cast(durationSeconds*10.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.GetCurrentSize(), targetSize, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), 20, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty< int >( index ), 20, 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 UtcDaliAnimationDuration(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 */); + Animation animation = Animation::New( 0.0f ); + DALI_TEST_EQUALS( 0.0f, animation.GetDuration(), TEST_LOCATION ); - // We didn't expect the animation to finish yet - application.SendNotification(); - finishCheck.CheckSignalNotReceived(); + // The animation duration should automatically increase depending on the animator time period - // 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 ); + animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 100.0f, TimePeriod( 0.0f, 1.0f ) ); + DALI_TEST_EQUALS( 1.0f, animation.GetDuration(), TEST_LOCATION ); - application.SendNotification(); - application.Render(static_cast(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/); + animation.AnimateTo( Property( actor, Actor::Property::POSITION_Y ), 200.0f, TimePeriod( 10.0f, 1.0f ) ); + DALI_TEST_EQUALS( 11.0f, animation.GetDuration(), TEST_LOCATION ); - // We did expect the animation to finish - application.SendNotification(); - 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 UtcDaliAnimationAnimateByNonAnimateableTypeN(void) +{ + TestApplication application; - // Repeat with a delay - float delay = 0.5f; - animation = Animation::New(durationSeconds); - animation.Resize(actor, targetSize.x, targetSize.y, AlphaFunctions::Linear, delay, durationSeconds - delay); - animation.FinishedSignal().Connect(&application, finishCheck); - animation.Play(); + Actor actor = Actor::New(); - application.SendNotification(); - application.Render(static_cast(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */); + // 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 ); - // We didn't expect the animation to finish yet - application.SendNotification(); - finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, 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 ); + } - 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(), targetSize, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationAnimateBetweenActorColorTimePeriod(void) +int UtcDaliAnimationAnimateToNonAnimateableTypeN(void) { TestApplication application; - float startValue(1.0f); Actor actor = Actor::New(); - actor.SetColor(Vector4(startValue, startValue, startValue, startValue)); + + // 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 ); - DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorRed), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorGreen), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorBlue), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorAlpha), 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; +} + +int UtcDaliAnimationSetAndGetTargetBeforePlayP(void) +{ + tet_infoline("Setting up an animation should not effect it's position property until the animation plays"); + + TestApplication application; + + tet_infoline("Set initial position and set up animation to re-position actor"); + + Actor actor = Actor::New(); + Stage::GetCurrent().Add(actor); + Vector3 initialPosition(0.0f, 0.0f, 0.0f); + actor.SetProperty( Actor::Property::POSITION, initialPosition ); // Build the animation - float durationSeconds(1.0f); - Animation animation = Animation::New(durationSeconds); + Animation animation = Animation::New(2.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)); + //Test GetCurrentProgress return 0.0 as the duration is 0.0 + DALI_TEST_EQUALS( 0.0f, animation.GetCurrentProgress(), TEST_LOCATION ); + DALI_TEST_EQUALS( Vector3( 0.0f, 0.0f, 0.0f ), actor.GetCurrentPosition(), TEST_LOCATION ); - animation.AnimateBetween( Property(actor, Actor::Property::Color), keyFrames, TimePeriod( 1.0f) ); + tet_infoline("Set target position in animation without intiating play"); - // Start the animation - animation.Play(); + Vector3 targetPosition(100.0f, 100.0f, 100.0f); + animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR); - 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::Property::ColorRed), 0.1f, 0.01f, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorGreen), 0.2f, 0.01f, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorBlue), 0.3f, 0.01f, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorAlpha), 0.4f, 0.01f, TEST_LOCATION ); + application.Render(); - application.Render(static_cast(durationSeconds*250.0f)/* 25% progress */); - application.SendNotification(); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorRed), 0.5f, 0.01f, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorGreen), 0.5f, 0.01f, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorBlue), 0.5f, 0.01f, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorAlpha), 0.5f, 0.01f, TEST_LOCATION ); + tet_infoline("Ensure position of actor is still at intial value"); - application.Render(static_cast(durationSeconds*250.0f)/* 50% progress */); - application.SendNotification(); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorRed), 0.9f, 0.01f, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorGreen), 0.8f, 0.01f, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorBlue), 0.7f, 0.01f, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorAlpha), 0.6f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::POSITION_X), initialPosition.x, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::POSITION_Y), initialPosition.y, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::POSITION_Z), initialPosition.z, TEST_LOCATION ); - application.Render(static_cast(durationSeconds*250.0f)/* 75% progress */); - application.SendNotification(); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorRed), 0.95f, 0.01f, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorGreen), 0.90f, 0.01f, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorBlue), 0.85f, 0.01f, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorAlpha), 0.80f, 0.01f, TEST_LOCATION ); + tet_infoline("Play animation and ensure actor position is now target"); - application.Render(static_cast(durationSeconds*250.0f)+1/* 100% progress */); + animation.Play(); application.SendNotification(); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorRed), 1.0f, 0.01f, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorGreen), 1.0f, 0.01f, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorBlue), 1.0f, 0.01f, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorAlpha), 1.0f, 0.01f, TEST_LOCATION ); + application.Render(1000u); - // We did expect the animation to finish + tet_infoline("Ensure position of actor is at target value when aninmation half way"); + + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::POSITION_X), targetPosition.x, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::POSITION_Y), targetPosition.y, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::POSITION_Z), targetPosition.z, TEST_LOCATION ); + + tet_printf( "x position at half way point(%f)\n", actor.GetCurrentPosition().x ); + + application.Render(2000u); + + tet_infoline("Ensure position of actor is still at target value when aninmation complete"); + + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::POSITION_X), targetPosition.x, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::POSITION_Y), targetPosition.y, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::POSITION_Z), targetPosition.z, TEST_LOCATION ); - finishCheck.CheckSignalReceived(); END_TEST; } -int UtcDaliAnimationAnimateBetweenActorColorFunction(void) +int UtcDaliAnimationSetAndGetTargetBeforePlayMulitpleAnimatorsPositionP(void) { + tet_infoline("Setting up an animation should not effect it's position property until the animation plays even with mulitple animators"); + TestApplication application; - float startValue(1.0f); + std::vector targetPositions; + + targetPositions.push_back( Vector3( 100.0f, 100.0f, 100.0f ) ); + targetPositions.push_back( Vector3( 200.0f, 1.0f, 100.0f ) ); + targetPositions.push_back( Vector3( 50.0f, 10.0f, 100.0f ) ); + + tet_infoline("Set initial position and set up animation to re-position actor"); + Actor actor = Actor::New(); - actor.SetColor(Vector4(startValue, startValue, startValue, startValue)); Stage::GetCurrent().Add(actor); + Vector3 initialPosition(0.0f, 0.0f, 0.0f); + actor.SetProperty( Actor::Property::POSITION, initialPosition ); - DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorRed), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorGreen), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorBlue), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorAlpha), startValue, TEST_LOCATION ); + // Build the animation + Animation animation = Animation::New(2.0f); + + //Test GetCurrentProgress return 0.0 as the duration is 0.0 + DALI_TEST_EQUALS( 0.0f, animation.GetCurrentProgress(), TEST_LOCATION ); + DALI_TEST_EQUALS( Vector3( 0.0f, 0.0f, 0.0f ), actor.GetCurrentPosition(), TEST_LOCATION ); + + tet_infoline("Set target position in animation without intiating play"); + + for ( unsigned int i = 0; i < targetPositions.size(); i++ ) + { + animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPositions[i], AlphaFunction::LINEAR); + } + + application.SendNotification(); + application.Render(); - // Build the animation - float durationSeconds(1.0f); - Animation animation = Animation::New(durationSeconds); + tet_infoline("Ensure position of actor is still at intial value"); - 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)); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::POSITION_X), initialPosition.x, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::POSITION_Y), initialPosition.y, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::POSITION_Z), initialPosition.z, TEST_LOCATION ); - animation.AnimateBetween( Property(actor, Actor::Property::Color), keyFrames, AlphaFunctions::Linear ); + tet_infoline("Play animation and ensure actor position is now target"); - // Start the animation animation.Play(); - - bool signalReceived(false); - AnimationFinishCheck finishCheck(signalReceived); - animation.FinishedSignal().Connect(&application, finishCheck); application.SendNotification(); - application.Render(0); - application.SendNotification(); - finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorRed), 0.1f, 0.01f, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorGreen), 0.2f, 0.01f, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorBlue), 0.3f, 0.01f, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorAlpha), 0.4f, 0.01f, TEST_LOCATION ); + application.Render(1000u); - application.Render(static_cast(durationSeconds*250.0f)/* 25% progress */); - application.SendNotification(); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorRed), 0.5f, 0.01f, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorGreen), 0.5f, 0.01f, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorBlue), 0.5f, 0.01f, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorAlpha), 0.5f, 0.01f, TEST_LOCATION ); + tet_infoline("Ensure position of actor is at target value when aninmation half way"); - application.Render(static_cast(durationSeconds*250.0f)/* 50% progress */); - application.SendNotification(); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorRed), 0.9f, 0.01f, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorGreen), 0.8f, 0.01f, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorBlue), 0.7f, 0.01f, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorAlpha), 0.6f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::POSITION_X), targetPositions[2].x, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::POSITION_Y), targetPositions[2].y, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::POSITION_Z), targetPositions[2].z, TEST_LOCATION ); - application.Render(static_cast(durationSeconds*250.0f)/* 75% progress */); - application.SendNotification(); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorRed), 0.95f, 0.01f, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorGreen), 0.90f, 0.01f, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorBlue), 0.85f, 0.01f, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorAlpha), 0.80f, 0.01f, TEST_LOCATION ); + tet_printf( "x position at half way point(%f)\n", actor.GetCurrentPosition().x ); - application.Render(static_cast(durationSeconds*250.0f)+1/* 100% progress */); - application.SendNotification(); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorRed), 1.0f, 0.01f, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorGreen), 1.0f, 0.01f, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorBlue), 1.0f, 0.01f, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorAlpha), 1.0f, 0.01f, TEST_LOCATION ); + application.Render(2000u); - // We did expect the animation to finish + tet_infoline("Ensure position of actor is still at target value when aninmation complete"); + + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::POSITION_X), targetPositions[2].x, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::POSITION_Y), targetPositions[2].y, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::POSITION_Z), targetPositions[2].z, TEST_LOCATION ); - finishCheck.CheckSignalReceived(); END_TEST; } -int UtcDaliAnimationAnimateBetweenActorColorFunctionTimePeriod(void) +int UtcDaliAnimationSetAndGetTargetBeforePlayMulitpleAnimatorsSizeAndPositionP(void) { + tet_infoline("Setting up an animation should not effect it's size property until the animation plays even with mulitple animators of different Property Indexes"); + TestApplication application; - float startValue(1.0f); + std::vector targetSizes; + std::vector targetPositions; + + targetSizes.push_back( Vector3( 100.0f, 100.0f, 100.0f ) ); + targetSizes.push_back( Vector3( 50.0f, 10.0f, 100.0f ) ); + + targetPositions.push_back( Vector3( 200.0f, 1.0f, 100.0f ) ); + + tet_infoline("Set initial position and set up animation to re-position actor"); + Actor actor = Actor::New(); - actor.SetColor(Vector4(startValue, startValue, startValue, startValue)); Stage::GetCurrent().Add(actor); + Vector3 initialSize( 10.0f, 10.0f, 10.0f); + Vector3 initialPosition(10.0f, 10.0f, 10.0f); - DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorRed), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorGreen), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorBlue), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorAlpha), startValue, TEST_LOCATION ); + actor.SetProperty( Actor::Property::SIZE, initialSize ); + actor.SetProperty( Actor::Property::POSITION, initialPosition ); // Build the animation - float durationSeconds(1.0f); - Animation animation = Animation::New(durationSeconds); + Animation animation = Animation::New(2.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)); + tet_infoline("Set target size in animation without intiating play"); + animation.AnimateTo(Property(actor, Actor::Property::SIZE), targetSizes[0], AlphaFunction::LINEAR); + tet_infoline("Set target position in animation without intiating play"); + animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPositions[0], AlphaFunction::LINEAR); + animation.AnimateTo(Property(actor, Actor::Property::SIZE), targetSizes[1], AlphaFunction::LINEAR); - animation.AnimateBetween( Property(actor, Actor::Property::Color), keyFrames, AlphaFunctions::Linear, TimePeriod( 1.0f) ); + application.SendNotification(); + application.Render(); - // Start the animation - animation.Play(); + tet_infoline("Ensure position of actor is still at intial size and position"); - 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::Property::ColorRed), 0.1f, 0.01f, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorGreen), 0.2f, 0.01f, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorBlue), 0.3f, 0.01f, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorAlpha), 0.4f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::SIZE_WIDTH), initialSize.x, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::SIZE_HEIGHT), initialSize.y, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::SIZE_DEPTH), initialSize.z, TEST_LOCATION ); - application.Render(static_cast(durationSeconds*250.0f)/* 25% progress */); - application.SendNotification(); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorRed), 0.5f, 0.01f, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorGreen), 0.5f, 0.01f, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorBlue), 0.5f, 0.01f, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorAlpha), 0.5f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::SIZE_WIDTH), initialPosition.x, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::SIZE_HEIGHT), initialPosition.y, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::SIZE_DEPTH), initialPosition.z, TEST_LOCATION ); - application.Render(static_cast(durationSeconds*250.0f)/* 50% progress */); - application.SendNotification(); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorRed), 0.9f, 0.01f, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorGreen), 0.8f, 0.01f, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorBlue), 0.7f, 0.01f, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorAlpha), 0.6f, 0.01f, TEST_LOCATION ); + tet_infoline("Play animation and ensure actor position and size is now matches targets"); - application.Render(static_cast(durationSeconds*250.0f)/* 75% progress */); + animation.Play(); application.SendNotification(); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorRed), 0.95f, 0.01f, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorGreen), 0.90f, 0.01f, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorBlue), 0.85f, 0.01f, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorAlpha), 0.80f, 0.01f, TEST_LOCATION ); + application.Render(2000u); - application.Render(static_cast(durationSeconds*250.0f)+1/* 100% progress */); - application.SendNotification(); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorRed), 1.0f, 0.01f, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorGreen), 1.0f, 0.01f, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorBlue), 1.0f, 0.01f, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::ColorAlpha), 1.0f, 0.01f, TEST_LOCATION ); + tet_infoline("Ensure position and size of actor is at target value when aninmation playing"); - // We did expect the animation to finish + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::SIZE_WIDTH), targetSizes[1].x, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::SIZE_HEIGHT), targetSizes[1].y, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::SIZE_DEPTH), targetSizes[1].z, TEST_LOCATION ); + + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::POSITION_X), targetPositions[0].x, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::POSITION_Y), targetPositions[0].y, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::POSITION_Z), targetPositions[0].z, TEST_LOCATION ); - finishCheck.CheckSignalReceived(); END_TEST; } -int UtcDaliAnimationCreateDestroy(void) +int UtcDaliAnimationSetAndGetTargetBeforePlayMulitpleAnimatorsSizeAndPositionColourP(void) { + tet_infoline("Setting up an animation should not effect it's size property until the animation plays even if other Properties animated"); + TestApplication application; - Animation* animation = new Animation; - DALI_TEST_CHECK( animation ); - delete animation; - END_TEST; -} -struct UpdateManagerTestConstraint -{ - UpdateManagerTestConstraint(TestApplication& application) - : mApplication(application) - { - } + std::vector targetSizes; + std::vector targetColors; - Vector3 operator()(const Vector3& current) - { - mApplication.SendNotification(); // Process events - return current; - } + targetSizes.push_back( Vector3( 100.0f, 100.0f, 100.0f ) ); + targetSizes.push_back( Vector3( 50.0f, 10.0f, 150.0f ) ); - TestApplication& mApplication; -}; + targetColors.push_back( 1.0f ); -int UtcDaliAnimationUpdateManager(void) -{ - TestApplication application; + tet_infoline("Set initial position and set up animation to re-position actor"); Actor actor = Actor::New(); - Stage::GetCurrent().Add( actor ); + Stage::GetCurrent().Add(actor); + Vector3 initialSize( 10.0f, 5.0f, 10.0f); + + actor.SetProperty( Actor::Property::SIZE, initialSize ); // Build the animation - Animation animation = Animation::New( 0.0f ); + Animation animation = Animation::New(2.0f); - bool signalReceived = false; - AnimationFinishCheck finishCheck( signalReceived ); - animation.FinishedSignal().Connect( &application, finishCheck ); + tet_infoline("Set target size in animation without initiating play"); + animation.AnimateTo(Property(actor, Actor::Property::SIZE), targetSizes[0], AlphaFunction::LINEAR); + tet_infoline("Set target position in animation without intiating play"); + animation.AnimateTo(Property(actor, Actor::Property::COLOR_RED), targetColors[0], AlphaFunction::LINEAR); + animation.AnimateTo(Property(actor, Actor::Property::SIZE), targetSizes[1], AlphaFunction::LINEAR); - 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 ); + application.SendNotification(); + application.Render(); - // Apply animation to actor - animation.AnimateTo( Property(actor, Actor::Property::Position), Vector3( 100.f, 90.f, 80.f ), AlphaFunctions::Linear ); + tet_infoline("Ensure position of actor is still at initial size and position"); - animation.Play(); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::SIZE_WIDTH), initialSize.x, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::SIZE_HEIGHT), initialSize.y, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::SIZE_DEPTH), initialSize.z, TEST_LOCATION ); + + tet_infoline("Play animation and ensure actor position and size is now matches targets"); + animation.Play(); application.SendNotification(); - application.UpdateOnly( 16 ); + application.Render(2000u); - finishCheck.CheckSignalNotReceived(); + tet_infoline("Ensure position and size of actor is at target value when animation playing"); - application.SendNotification(); // Process events + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::SIZE_WIDTH), targetSizes[1].x, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::SIZE_HEIGHT), targetSizes[1].y, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::SIZE_DEPTH), targetSizes[1].z, TEST_LOCATION ); - finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::COLOR_RED), targetColors[0], TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationSignalOrder(void) +int UtcDaliAnimationTimePeriodOrder(void) { + tet_infoline("Animate the same property with different time periods and ensure it runs correctly and ends up in the right place" ); + TestApplication application; Actor actor = Actor::New(); Stage::GetCurrent().Add( actor ); - // Build the animations - Animation animation1 = Animation::New( 0.0f ); // finishes first frame - Animation animation2 = Animation::New( 0.02f ); // finishes in 20 ms + application.SendNotification(); + application.Render(); - bool signal1Received = false; - animation1.FinishedSignal().Connect( &application, AnimationFinishCheck( signal1Received ) ); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), Vector3::ZERO, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_X ), 0.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), Vector3::ZERO, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::POSITION_X ), 0.0f, TEST_LOCATION ); - bool signal2Received = false; - animation2.FinishedSignal().Connect( &application, AnimationFinishCheck( signal2Received ) ); + ////////////////////////////////////////////////////////////////////////////////// - // Apply animations to actor - animation1.AnimateTo( Property(actor, Actor::Property::Position), Vector3( 3.0f, 2.0f, 1.0f ), AlphaFunctions::Linear ); - animation1.Play(); - animation2.AnimateTo( Property(actor, Actor::Property::Size ), Vector3( 10.0f, 20.0f, 30.0f ), AlphaFunctions::Linear ); - animation2.Play(); + tet_infoline( "With two AnimateTo calls" ); - DALI_TEST_EQUALS( signal1Received, false, TEST_LOCATION ); - DALI_TEST_EQUALS( signal2Received, false, TEST_LOCATION ); + Animation animation = Animation::New( 0.0f ); + animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 100.0f, TimePeriod( 3.0f, 1.0f ) ); + animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 10.0f, TimePeriod( 1.0f, 1.0f ) ); + animation.Play(); + + tet_infoline( "The target position should change instantly" ); + DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), Vector3( 100.0f, 0.0f, 0.0f ), TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_X ), 100.0f, TEST_LOCATION ); application.SendNotification(); - application.UpdateOnly( 10 ); // 10ms progress + application.Render(5000); // After the animation is complete - // no notifications yet - DALI_TEST_EQUALS( signal1Received, false, TEST_LOCATION ); - DALI_TEST_EQUALS( signal2Received, false, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3( 100.0f, 0.0f, 0.0f ), TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), Vector3( 100.0f, 0.0f, 0.0f ), TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::POSITION_X ), 100.0f, TEST_LOCATION ); + + ////////////////////////////////////////////////////////////////////////////////// + + tet_infoline( "Same animation again but in a different order - should yield the same result" ); + + actor.SetX( 0.0f ); + DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), Vector3::ZERO, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_X ), 0.0f, TEST_LOCATION ); application.SendNotification(); + application.Render(); - // first completed - DALI_TEST_EQUALS( signal1Received, true, TEST_LOCATION ); - DALI_TEST_EQUALS( signal2Received, false, TEST_LOCATION ); - signal1Received = false; + DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), Vector3::ZERO, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::POSITION_X ), 0.0f, TEST_LOCATION ); - // 1st animation is complete now, do another update with no ProcessEvents in between - application.UpdateOnly( 20 ); // 20ms progress + animation = Animation::New( 0.0f ); + animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 10.0f, TimePeriod( 1.0f, 1.0f ) ); + animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 100.0f, TimePeriod( 3.0f, 1.0f ) ); + animation.Play(); + + tet_infoline( "The target position should change instantly" ); + DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), Vector3( 100.0f, 0.0f, 0.0f ), TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_X ), 100.0f, TEST_LOCATION ); - // ProcessEvents application.SendNotification(); + application.Render(5000); // After the animation is complete - // 2nd should complete now - DALI_TEST_EQUALS( signal1Received, false, TEST_LOCATION ); - DALI_TEST_EQUALS( signal2Received, true, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3( 100.0f, 0.0f, 0.0f ), TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), Vector3( 100.0f, 0.0f, 0.0f ), TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::POSITION_X ), 100.0f, TEST_LOCATION ); END_TEST; } -int UtcDaliAnimationExtendDuration(void) +int UtcDaliAnimationTimePeriodOrderSeveralAnimateToCalls(void) { + tet_infoline("Animate the same property with different time periods and ensure it runs correctly and ends up in the right place with several AnimateTo calls" ); + TestApplication application; Actor actor = Actor::New(); + Stage::GetCurrent().Add( actor ); - // Register a float property - float startValue(10.0f); - Property::Index index = actor.RegisterProperty( "test-property", startValue ); - Stage::GetCurrent().Add(actor); - DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + application.SendNotification(); + application.Render(); - // Build the animation - float initialDurationSeconds(1.0f); - float animatorDelay = 5.0f; - float animatorDurationSeconds(5.0f); - float extendedDurationSeconds(animatorDelay+animatorDurationSeconds); - Animation animation = Animation::New(initialDurationSeconds); - float targetValue(30.0f); - float relativeValue(targetValue - startValue); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), Vector3::ZERO, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_X ), 0.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), Vector3::ZERO, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::POSITION_X ), 0.0f, TEST_LOCATION ); - animation.AnimateTo(Property(actor, index), - targetValue, - TimePeriod(animatorDelay, animatorDurationSeconds)); + ////////////////////////////////////////////////////////////////////////////////// - // The duration should have been extended - DALI_TEST_EQUALS( animation.GetDuration(), extendedDurationSeconds, TEST_LOCATION ); + tet_infoline( "" ); - // Start the animation + Animation animation = Animation::New( 0.0f ); + animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 1000.0f, TimePeriod( 4.0f, 2.0f ) ); + animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 145.0f, TimePeriod( 3.0f, 10.0f ) ); + animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 109.0f, TimePeriod( 1.0f, 1.0f ) ); + animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 1.0f, TimePeriod( 3.0f, 4.0f ) ); + animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 200.0f, TimePeriod( 2.0f, 5.0f ) ); + animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 10.0f, TimePeriod( 10.0f, 2.0f ) ); animation.Play(); - bool signalReceived(false); - AnimationFinishCheck finishCheck(signalReceived); - animation.FinishedSignal().Connect(&application, finishCheck); + tet_infoline( "The target position should change instantly" ); + DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), Vector3( 145.0f, 0.0f, 0.0f ), TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_X ), 145.0f, TEST_LOCATION ); application.SendNotification(); - application.Render(static_cast(extendedDurationSeconds*500.0f)/* 50% animation progress, 0% animator progress */); + application.Render(14000); // After the animation is complete - // 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(), Vector3( 145.0f, 0.0f, 0.0f ), TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), Vector3( 145.0f, 0.0f, 0.0f ), TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::POSITION_X ), 145.0f, TEST_LOCATION ); - application.SendNotification(); - application.Render(static_cast(extendedDurationSeconds*250.0f)/* 75% animation progress, 50% animator progress */); + ////////////////////////////////////////////////////////////////////////////////// - // We didn't expect the animation to finish yet - application.SendNotification(); - finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetProperty(index), startValue+(relativeValue*0.5f), TEST_LOCATION ); + tet_infoline( "Same animation again but in a different order - should end up at the same point" ); + + actor.SetX( 0.0f ); + + DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), Vector3::ZERO, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_X ), 0.0f, TEST_LOCATION ); application.SendNotification(); - application.Render(static_cast(extendedDurationSeconds*250.0f) + 1u/*just beyond the animation duration*/); + application.Render(); + + DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), Vector3::ZERO, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::POSITION_X ), 0.0f, TEST_LOCATION ); + + animation = Animation::New( 0.0f ); + animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 200.0f, TimePeriod( 2.0f, 5.0f ) ); + animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 10.0f, TimePeriod( 10.0f, 2.0f ) ); + animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 145.0f, TimePeriod( 3.0f, 10.0f ) ); + animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 1000.0f, TimePeriod( 4.0f, 2.0f ) ); + animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 1.0f, TimePeriod( 3.0f, 4.0f ) ); + animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 109.0f, TimePeriod( 1.0f, 1.0f ) ); + animation.Play(); + + tet_infoline( "The target position should change instantly" ); + DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), Vector3( 145.0f, 0.0f, 0.0f ), TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_X ), 145.0f, TEST_LOCATION ); - // We did expect the animation to finish application.SendNotification(); - finishCheck.CheckSignalReceived(); - DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + application.Render(14000); // After the animation is complete + + DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3( 145.0f, 0.0f, 0.0f ), TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), Vector3( 145.0f, 0.0f, 0.0f ), TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::POSITION_X ), 145.0f, TEST_LOCATION ); + END_TEST; } -int UtcDaliAnimationPath(void) +int UtcDaliAnimationAnimateBetweenIntegerP(void) { TestApplication application; + int startValue(1); Actor actor = Actor::New(); + const Property::Index index = actor.RegisterProperty("customProperty", startValue ); Stage::GetCurrent().Add(actor); - //Build the path - Vector3 position0( 30.0, 80.0, 0.0); - Vector3 position1( 70.0, 120.0, 0.0); - Vector3 position2( 100.0, 100.0, 0.0); - - Dali::Path path = Dali::Path::New(); - path.AddPoint(position0); - path.AddPoint(position1); - path.AddPoint(position2); - - //Control points for first segment - path.AddControlPoint( Vector3( 39.0, 90.0, 0.0) ); - path.AddControlPoint(Vector3( 56.0, 119.0, 0.0) ); + application.Render(); + application.SendNotification(); - //Control points for second segment - path.AddControlPoint(Vector3( 78.0, 120.0, 0.0)); - path.AddControlPoint(Vector3( 93.0, 104.0, 0.0)); + DALI_TEST_EQUALS( actor.GetProperty< int >( index ), startValue, TEST_LOCATION ); // Build the animation - float durationSeconds( 1.0f ); + float durationSeconds(1.0f); Animation animation = Animation::New(durationSeconds); - animation.Animate(actor, path, Vector3::XAXIS, AlphaFunctions::Linear, TimePeriod(0.0f, 1.0f )); + + KeyFrames keyFrames = KeyFrames::New(); + keyFrames.Add(0.0f, 10); + keyFrames.Add(0.2f, 20); + keyFrames.Add(0.4f, 30); + keyFrames.Add(0.6f, 40); + keyFrames.Add(0.8f, 50); + keyFrames.Add(1.0f, 60); + + animation.AnimateBetween( Property(actor, index ), keyFrames ); // Start the animation animation.Play(); - bool signalReceived(false); - AnimationFinishCheck finishCheck(signalReceived); - animation.FinishedSignal().Connect(&application, finishCheck); - application.SendNotification(); - application.Render(0); - application.SendNotification(); - finishCheck.CheckSignalNotReceived(); - Vector3 position, tangent; - Quaternion rotation; - path.Sample( 0.0f, position, tangent ); - rotation = Quaternion( Vector3::XAXIS, tangent ); - DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetCurrentRotation(), rotation, TEST_LOCATION ); + // Target value should change to the last key-frame's value straight away + DALI_TEST_EQUALS( actor.GetProperty< int >( index ), 60, TEST_LOCATION ); - application.Render(static_cast(durationSeconds*250.0f)/* 25% progress */); - application.SendNotification(); - path.Sample( 0.25f, position, tangent ); - rotation = Quaternion( Vector3::XAXIS, tangent ); - DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetCurrentRotation(), rotation, TEST_LOCATION ); + END_TEST; +} - application.Render(static_cast(durationSeconds*250.0f)/* 50% progress */); - application.SendNotification(); - path.Sample( 0.5f, position, tangent ); - rotation = Quaternion( Vector3::XAXIS, tangent ); - DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetCurrentRotation(), rotation, TEST_LOCATION ); +int UtcDaliAnimationAnimateBetweenVector2P(void) +{ + TestApplication application; - application.Render(static_cast(durationSeconds*250.0f)/* 75% progress */); - application.SendNotification(); - path.Sample( 0.75f, position, tangent ); - rotation = Quaternion( Vector3::XAXIS, tangent ); - DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetCurrentRotation(), rotation, TEST_LOCATION ); + Vector2 startValue( 10.0f, 20.0f ); + Actor actor = Actor::New(); + const Property::Index index = actor.RegisterProperty("customProperty", startValue ); + Stage::GetCurrent().Add(actor); - application.Render(static_cast(durationSeconds*250.0f)+1/* 100% progress */); + application.Render(); application.SendNotification(); - path.Sample( 1.0f, position, tangent ); - rotation = Quaternion( Vector3::XAXIS, tangent ); - DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetCurrentRotation(), rotation, TEST_LOCATION ); - finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetProperty< Vector2 >( index ), startValue, TEST_LOCATION ); + + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + + KeyFrames keyFrames = KeyFrames::New(); + keyFrames.Add( 0.0f, Vector2( 0.0f, 5.0f ) ); + keyFrames.Add( 0.2f, Vector2( 30.0f, 25.0f ) ); + keyFrames.Add( 0.4f, Vector2( 40.0f, 35.0f ) ); + keyFrames.Add( 0.6f, Vector2( 50.0f, 45.0f ) ); + keyFrames.Add( 0.8f, Vector2( 60.0f, 55.0f ) ); + keyFrames.Add( 1.0f, Vector2( 70.0f, 65.0f ) ); + + animation.AnimateBetween( Property(actor, index ), keyFrames ); + + // Start the animation + animation.Play(); + + // Target value should change to the last key-frame's value straight away + DALI_TEST_EQUALS( actor.GetProperty< Vector2 >( index ), Vector2( 70.0f, 65.0f ), TEST_LOCATION ); + END_TEST; }