X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=automated-tests%2Fsrc%2Fdali%2Futc-Dali-Animation.cpp;h=8e617ded82eb0ab04907a440ddba316cd7410ee6;hb=181787be13303d7a17ace569c4eba09d6aec1de3;hp=7397d92fb65a46dbfad52193cd9a02e38a1725df;hpb=61932641177011d1fd40daa90113711aebcafa3f;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 7397d92..8e617de 100644 --- a/automated-tests/src/dali/utc-Dali-Animation.cpp +++ b/automated-tests/src/dali/utc-Dali-Animation.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * Copyright (c) 2016 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,6 +20,7 @@ #include #include +#include #include using std::max; @@ -336,6 +337,422 @@ int UtcDaliAnimationSetLoopingP(void) END_TEST; } +int UtcDaliAnimationSetLoopCountP(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + Stage::GetCurrent().Add(actor); + + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + Vector3 targetPosition(10.0f, 10.0f, 10.0f); + animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR); + + // Start the animation + animation.SetLoopCount(3); + DALI_TEST_CHECK(animation.IsLooping()); + 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 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); + Vector3 targetPosition(10.0f, 10.0f, 10.0f); + animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR); + animation.SetEndAction(Animation::Discard); + + // Start the animation + animation.SetLoopCount(3); + DALI_TEST_CHECK(animation.IsLooping()); + animation.Play(); + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + + 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.SendNotification(); + finishCheck.CheckSignalReceived(); + + finishCheck.Reset(); + + // Loop forever + animation.SetLooping(true); + DALI_TEST_CHECK(animation.IsLooping()); + + application.Render(static_cast(durationSeconds*intervalSeconds*1000.0f)); + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + + application.Render(static_cast(durationSeconds*intervalSeconds*1000.0f)); + application.SendNotification(); + application.Render(static_cast(durationSeconds*intervalSeconds*1000.0f)); + application.SendNotification(); + application.Render(static_cast(durationSeconds*intervalSeconds*1000.0f)); + application.SendNotification(); + application.Render(static_cast(durationSeconds*intervalSeconds*1000.0f)); + application.SendNotification(); + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + + finishCheck.Reset(); + + // Loop N again + animation.SetLoopCount(3); + DALI_TEST_CHECK(animation.IsLooping()); + animation.Play(); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*intervalSeconds*1000.0f)); + application.SendNotification(); + application.Render(static_cast(durationSeconds*intervalSeconds*1000.0f)); + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + + application.Render(static_cast(durationSeconds*intervalSeconds*1000.0f)); + application.SendNotification(); + finishCheck.CheckSignalReceived(); + + finishCheck.Reset(); + + // loop forever + animation.SetLooping(true); + DALI_TEST_CHECK(animation.IsLooping()); + + application.Render(static_cast(durationSeconds*intervalSeconds*1000.0f)); + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + + application.Render(static_cast(durationSeconds*intervalSeconds*1000.0f)); + application.SendNotification(); + application.Render(static_cast(durationSeconds*intervalSeconds*1000.0f)); + application.SendNotification(); + application.Render(static_cast(durationSeconds*intervalSeconds*1000.0f)); + application.SendNotification(); + application.Render(static_cast(durationSeconds*intervalSeconds*1000.0f)); + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + + finishCheck.Reset(); + + // Loop N again + animation.SetLoopCount(3); + DALI_TEST_CHECK(animation.IsLooping()); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*intervalSeconds*1000.0f)); + application.SendNotification(); + application.Render(static_cast(durationSeconds*intervalSeconds*1000.0f)); + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + + application.Render(static_cast(durationSeconds*intervalSeconds*1000.0f)); + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); // we never hit play + + finishCheck.Reset(); + + + END_TEST; +} + +int UtcDaliAnimationSetLoopCountP3(void) +{ + TestApplication application; + + // + // switching between forever and loop count + // + Actor actor = Actor::New(); + Stage::GetCurrent().Add(actor); + + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + Vector3 targetPosition(10.0f, 10.0f, 10.0f); + animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR); + animation.SetEndAction(Animation::Discard); + + float intervalSeconds = 3.0f; + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + + // loop forever + animation.SetLooping(true); + DALI_TEST_CHECK(animation.IsLooping()); + + application.Render(static_cast(durationSeconds*intervalSeconds*1000.0f)); + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + + application.Render(static_cast(durationSeconds*intervalSeconds*1000.0f)); + application.SendNotification(); + application.Render(static_cast(durationSeconds*intervalSeconds*1000.0f)); + application.SendNotification(); + application.Render(static_cast(durationSeconds*intervalSeconds*1000.0f)); + application.SendNotification(); + application.Render(static_cast(durationSeconds*intervalSeconds*1000.0f)); + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + + finishCheck.Reset(); + + // Loop N again + animation.SetLoopCount(3); + DALI_TEST_CHECK(animation.IsLooping()); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*intervalSeconds*1000.0f)); + application.SendNotification(); + application.Render(static_cast(durationSeconds*intervalSeconds*1000.0f)); + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + + application.Render(static_cast(durationSeconds*intervalSeconds*1000.0f)); + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); // we never hit play + + finishCheck.Reset(); + + + END_TEST; +} + +int UtcDaliAnimationSetLoopCountP4(void) +{ + TestApplication application; + + // + // ..and play again + // + Actor actor = Actor::New(); + Stage::GetCurrent().Add(actor); + + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + Vector3 targetPosition(10.0f, 10.0f, 10.0f); + animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR); + animation.SetEndAction(Animation::Bake); + + float intervalSeconds = 3.0f; + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + + animation.SetLoopCount(1); + animation.Play(); + DALI_TEST_CHECK(!animation.IsLooping()); + + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + application.Render(static_cast(durationSeconds*intervalSeconds*1000.0f)); + application.SendNotification(); + finishCheck.CheckSignalReceived(); + + DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION ); + actor.SetProperty( Actor::Property::POSITION, Vector3(0.0f, 0.0f, 0.0f) ); + + finishCheck.Reset(); + + animation.Play(); // again + DALI_TEST_CHECK(!animation.IsLooping()); + + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + application.Render(static_cast(durationSeconds*intervalSeconds*1000.0f)); + application.SendNotification(); + finishCheck.CheckSignalReceived(); + + DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION ); + + END_TEST; +} + +int UtcDaliAnimationGetLoopCountP(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + Stage::GetCurrent().Add(actor); + + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + Vector3 targetPosition(10.0f, 10.0f, 10.0f); + animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR); + + DALI_TEST_CHECK(1 == animation.GetLoopCount()); + + // Start the animation + animation.SetLoopCount(3); + DALI_TEST_CHECK(animation.IsLooping()); + DALI_TEST_CHECK(3 == animation.GetLoopCount()); + + animation.Play(); + + application.Render(0); + application.SendNotification(); + + // 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(static_cast(durationSeconds*intervalSeconds*1000.0f)); + application.SendNotification(); + + animation.SetLoopCount(0); + DALI_TEST_CHECK(animation.IsLooping()); + DALI_TEST_CHECK(0 == animation.GetLoopCount()); + + animation.SetLoopCount(1); + DALI_TEST_CHECK(!animation.IsLooping()); + DALI_TEST_CHECK(1 == animation.GetLoopCount()); + + END_TEST; +} + + +int UtcDaliAnimationGetCurrentLoopP(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + Stage::GetCurrent().Add(actor); + + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + Vector3 targetPosition(10.0f, 10.0f, 10.0f); + animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR); + + // Start the animation + animation.SetLoopCount(3); + DALI_TEST_CHECK(animation.IsLooping()); + DALI_TEST_CHECK(0 == animation.GetCurrentLoop()); + animation.Play(); + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + + application.SendNotification(); + + // Loop + float intervalSeconds = 3.0f; + + application.Render(static_cast(durationSeconds*intervalSeconds*1000.0f)); + application.Render(static_cast(durationSeconds*intervalSeconds*1000.0f)); + + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_CHECK(2 == animation.GetCurrentLoop()); + + application.Render(static_cast(durationSeconds*intervalSeconds*1000.0f)); + + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_CHECK(3 == animation.GetCurrentLoop()); + DALI_TEST_CHECK(animation.GetLoopCount() == animation.GetCurrentLoop()); + + finishCheck.Reset(); + + application.Render(static_cast(durationSeconds*intervalSeconds*1000.0f)); + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_CHECK(3 == animation.GetCurrentLoop()); + + 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(); + DALI_TEST_CHECK(3 == animation.GetCurrentLoop()); + + END_TEST; +} + int UtcDaliAnimationIsLoopingP(void) { TestApplication application; @@ -773,10 +1190,12 @@ int UtcDaliAnimationGetCurrentProgressP(void) END_TEST; } -int UtcDaliAnimationSetSpeedFactorP(void) +int UtcDaliAnimationSetSpeedFactorP1(void) { TestApplication application; + tet_printf("Testing that setting a speed factor of 2 takes half the time\n"); + Actor actor = Actor::New(); Stage::GetCurrent().Add(actor); @@ -817,49 +1236,232 @@ int UtcDaliAnimationSetSpeedFactorP(void) 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*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); - // We did expect the animation to finish - application.SendNotification(); - finishCheck.CheckSignalReceived(); - DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION ); + KeyFrames keyframes = KeyFrames::New(); + keyframes.Add( 0.0f, initialPosition); + keyframes.Add( 1.0f, targetPosition ); + animation.AnimateBetween( Property(actor, Actor::Property::POSITION), keyframes, AlphaFunction::LINEAR); - // 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 ); + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); - finishCheck.Reset(); + tet_printf("Test half speed factor. Animation will take twice the duration\n"); - //Test -1 speed factor. Animation will play in reverse at normal speed - animation.SetSpeedFactor( -1.0f ); + 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)/* 80% progress */); + application.Render(static_cast(durationSeconds*200.0f)/* 10% progress */); // We didn't expect the animation to finish yet application.SendNotification(); finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.8f), TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.1f), TEST_LOCATION ); - application.Render(static_cast(durationSeconds*200.0f)/* 60% progress */); + application.Render(static_cast(durationSeconds*200.0f)/* 20% progress */); // We didn't expect the animation to finish yet application.SendNotification(); finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.6f), TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION ); - application.Render(static_cast(durationSeconds*200.0f)/* 40% progress */); + 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.4f), TEST_LOCATION ); + 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 @@ -867,6 +1469,13 @@ int UtcDaliAnimationSetSpeedFactorP(void) 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 @@ -879,63 +1488,355 @@ int UtcDaliAnimationSetSpeedFactorP(void) DALI_TEST_EQUALS( initialPosition, actor.GetCurrentPosition(), TEST_LOCATION ); application.Render(0); DALI_TEST_EQUALS( initialPosition, actor.GetCurrentPosition(), TEST_LOCATION ); + END_TEST; +} - //Test change speed factor on the fly - finishCheck.Reset(); +int UtcDaliAnimationSetSpeedFactorAndRange(void) +{ + TestApplication application; - //Set speed to be half of normal speed + 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(static_cast(durationSeconds*200.0f)/* 10% progress */); + application.Render(0); // Frame 0 tests initial values - // We didn't expect the animation to finish yet - application.SendNotification(); - finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.1f), TEST_LOCATION ); + 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 ); + } + } - application.Render(static_cast(durationSeconds*200.0f)/* 20% progress */); + 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(); - DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION ); + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + } - application.Render(static_cast(durationSeconds*200.0f)/* 30% progress */); + END_TEST; +} - // We didn't expect the animation to finish yet +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(); - finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.3f), TEST_LOCATION ); + 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 ); - //Change speed factor while animation still playing. - animation.SetSpeedFactor(-1.0f); + 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 ); - // We didn't expect the animation to finish yet + 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(); - finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.1f), TEST_LOCATION ); + 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(static_cast(durationSeconds*100.0f) + 1u/*just beyond the animation duration*/); + 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(), initialPosition, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentPosition().x, 30.0f, 0.001, TEST_LOCATION ); - // Check that nothing has changed after a couple of buffer swaps - application.Render(0); - DALI_TEST_EQUALS( initialPosition, actor.GetCurrentPosition(), TEST_LOCATION ); - application.Render(0); - DALI_TEST_EQUALS( initialPosition, actor.GetCurrentPosition(), TEST_LOCATION ); END_TEST; } + int UtcDaliAnimationGetSpeedFactorP(void) { TestApplication application; @@ -1467,31 +2368,125 @@ int UtcDaliAnimationPlayFromP(void) 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 ); + // 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 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); + + // 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*200.0f)/* 60% 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(), (targetPosition * 0.6f), TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress, TEST_LOCATION ); - animation.Play(); // Test that calling play has no effect, when animation is already playing + // Pause the animation + animation.Pause(); application.SendNotification(); - application.Render(static_cast(durationSeconds*200.0f)/* 80% progress */); + + // Loop 5 times + for (int i=0; i<5; ++i) + { + application.Render(static_cast(durationSeconds*500.0f)); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress/* Still 50% progress when paused */, TEST_LOCATION ); + } + + // Keep going + animation.Play(); + application.SendNotification(); + application.Render(static_cast(durationSeconds*490.0f)/*slightly less than the animation duration*/); // We didn't expect the animation to finish yet application.SendNotification(); finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.8f), TEST_LOCATION ); - application.Render(static_cast(durationSeconds*200.0f) + 1u/*just beyond the animation duration*/); + 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(); @@ -1505,31 +2500,8 @@ int UtcDaliAnimationPlayFromP(void) 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) +int UtcDaliAnimationGetStateP(void) { TestApplication application; @@ -1541,12 +2513,15 @@ int UtcDaliAnimationPauseP(void) Animation animation = Animation::New(durationSeconds); Vector3 targetPosition(100.0f, 100.0f, 100.0f); animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR); + DALI_TEST_EQUALS( animation.GetState(), Animation::STOPPED, TEST_LOCATION ); Vector3 fiftyPercentProgress(targetPosition * 0.5f); // Start the animation animation.Play(); + DALI_TEST_EQUALS( animation.GetState(), Animation::PLAYING, TEST_LOCATION ); + bool signalReceived(false); AnimationFinishCheck finishCheck(signalReceived); animation.FinishedSignal().Connect(&application, finishCheck); @@ -1557,11 +2532,14 @@ int UtcDaliAnimationPauseP(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) @@ -1572,16 +2550,19 @@ int UtcDaliAnimationPauseP(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*/); @@ -1590,16 +2571,30 @@ int UtcDaliAnimationPauseP(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; @@ -1795,7 +2790,7 @@ int UtcDaliAnimationAnimateByBooleanP(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 ); @@ -1878,7 +2873,7 @@ int UtcDaliAnimationAnimateByBooleanAlphaFunctionP(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 ); @@ -1955,7 +2950,7 @@ int UtcDaliAnimationAnimateByBooleanTimePeriodP(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 ); @@ -2018,7 +3013,7 @@ int UtcDaliAnimationAnimateByBooleanAlphaFunctionTimePeriodP(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 ); @@ -2082,7 +3077,7 @@ int UtcDaliAnimationAnimateByFloatP(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 ); @@ -2134,7 +3129,7 @@ int UtcDaliAnimationAnimateByFloatAlphaFunctionP(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 ); @@ -2189,7 +3184,7 @@ int UtcDaliAnimationAnimateByFloatTimePeriodP(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 ); @@ -2250,7 +3245,7 @@ int UtcDaliAnimationAnimateByFloatAlphaFunctionTimePeriodP(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 ); @@ -2312,7 +3307,7 @@ int UtcDaliAnimationAnimateByIntegerP(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 ); @@ -2364,7 +3359,7 @@ int UtcDaliAnimationAnimateByIntegerAlphaFunctionP(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 ); @@ -2419,7 +3414,7 @@ int UtcDaliAnimationAnimateByIntegerTimePeriodP(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 ); @@ -2480,7 +3475,7 @@ int UtcDaliAnimationAnimateByIntegerAlphaFunctionTimePeriodP(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 ); @@ -2542,7 +3537,7 @@ int UtcDaliAnimationAnimateByVector2P(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 ); @@ -2594,7 +3589,7 @@ int UtcDaliAnimationAnimateByVector2AlphaFunctionP(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 ); @@ -2650,7 +3645,7 @@ int UtcDaliAnimationAnimateByVector2TimePeriodP(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 ); @@ -2711,7 +3706,7 @@ int UtcDaliAnimationAnimateByVector2AlphaFunctionTimePeriodP(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 ); @@ -2773,7 +3768,7 @@ int UtcDaliAnimationAnimateByVector3P(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 ); @@ -2825,7 +3820,7 @@ int UtcDaliAnimationAnimateByVector3AlphaFunctionP(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 ); @@ -2882,7 +3877,7 @@ int UtcDaliAnimationAnimateByVector3TimePeriodP(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 ); @@ -2943,7 +3938,7 @@ int UtcDaliAnimationAnimateByVector3AlphaFunctionTimePeriodP(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 ); @@ -3005,7 +4000,7 @@ int UtcDaliAnimationAnimateByVector4P(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 ); @@ -3057,7 +4052,7 @@ int UtcDaliAnimationAnimateByVector4AlphaFunctionP(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 ); @@ -3115,7 +4110,7 @@ int UtcDaliAnimationAnimateByVector4TimePeriodP(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 ); @@ -3176,7 +4171,7 @@ int UtcDaliAnimationAnimateByVector4AlphaFunctionTimePeriodP(void) // Register a Vector4 property Vector4 startValue(5.0f, 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 ); @@ -3450,7 +4445,7 @@ int UtcDaliAnimationAnimateByActorPositionAlphaFunctionTimePeriodP(void) END_TEST; } -int UtcDaliAnimationAnimateByActorOrientationP(void) +int UtcDaliAnimationAnimateByActorOrientationP1(void) { TestApplication application; @@ -3507,6 +4502,131 @@ int UtcDaliAnimationAnimateByActorOrientationP(void) END_TEST; } +int UtcDaliAnimationAnimateByActorOrientationP2(void) +{ + TestApplication application; + + tet_printf("Testing that rotation angle > 360 performs full rotations\n"); + + Actor actor = Actor::New(); + actor.SetOrientation( Quaternion( Dali::ANGLE_0, Vector3::ZAXIS ) ); + Stage::GetCurrent().Add(actor); + 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); + Degree relativeRotationDegrees(710.0f); + Radian relativeRotationRadians(relativeRotationDegrees); + + animation.AnimateBy( Property( actor, Actor::Property::ORIENTATION ), AngleAxis( relativeRotationRadians, Vector3::ZAXIS ) ); + + // 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.GetCurrentOrientation(), Quaternion(relativeRotationRadians * 0.25f, Vector3::ZAXIS), 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.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.GetCurrentOrientation(), Quaternion(relativeRotationRadians, Vector3::ZAXIS), ROTATION_EPSILON, TEST_LOCATION ); + END_TEST; +} + + +int UtcDaliAnimationAnimateByActorOrientationP3(void) +{ + TestApplication application; + + tet_printf("Testing that rotation angle > 360 performs partial rotations when cast to Quaternion\n"); + + Actor actor = Actor::New(); + actor.SetOrientation( Quaternion( Dali::ANGLE_0, Vector3::ZAXIS ) ); + Stage::GetCurrent().Add(actor); + 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); + 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(); + + 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.GetCurrentOrientation(), Quaternion(actualRotationRadians * 0.25f, Vector3::ZAXIS), 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.GetCurrentOrientation(), Quaternion(actualRotationRadians * 0.5f, Vector3::ZAXIS), ROTATION_EPSILON, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f)/* 75% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(actualRotationRadians * 0.75f, Vector3::ZAXIS), ROTATION_EPSILON, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + 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 UtcDaliAnimationAnimateByActorOrientationAlphaFunctionP(void) { TestApplication application; @@ -3743,7 +4863,7 @@ int UtcDaliAnimationAnimateToBooleanP(void) // Register a boolean property const 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 ); @@ -3825,7 +4945,7 @@ int UtcDaliAnimationAnimateToBooleanAlphaFunctionP(void) // Register a boolean property const 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 ); @@ -3833,7 +4953,7 @@ int UtcDaliAnimationAnimateToBooleanAlphaFunctionP(void) float durationSeconds(2.0f); Animation animation = Animation::New(durationSeconds); const bool targetValue( !startValue ); - animation.AnimateTo(Property(actor, "test-property"), targetValue, AlphaFunction::EASE_OUT); + animation.AnimateTo(Property(actor, "testProperty"), targetValue, AlphaFunction::EASE_OUT); // Start the animation animation.Play(); @@ -3907,7 +5027,7 @@ int UtcDaliAnimationAnimateToBooleanTimePeriodP(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 ); @@ -3969,7 +5089,7 @@ int UtcDaliAnimationAnimateToBooleanAlphaFunctionTimePeriodP(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 ); @@ -4032,7 +5152,7 @@ int UtcDaliAnimationAnimateToFloatP(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 ); @@ -4041,7 +5161,7 @@ int UtcDaliAnimationAnimateToFloatP(void) Animation animation = Animation::New(durationSeconds); float targetValue(50.0f); float relativeValue(targetValue - startValue); - animation.AnimateTo(Property(actor, "test-property"), targetValue); + animation.AnimateTo(Property(actor, "testProperty"), targetValue); float ninetyFivePercentProgress(startValue + relativeValue*0.95f); @@ -4078,7 +5198,7 @@ int UtcDaliAnimationAnimateToFloatAlphaFunctionP(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 ); @@ -4127,7 +5247,7 @@ int UtcDaliAnimationAnimateToFloatTimePeriodP(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 ); @@ -4182,7 +5302,7 @@ int UtcDaliAnimationAnimateToFloatAlphaFunctionTimePeriodP(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 ); @@ -4238,7 +5358,7 @@ int UtcDaliAnimationAnimateToIntegerP(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 ); @@ -4247,7 +5367,7 @@ int UtcDaliAnimationAnimateToIntegerP(void) Animation animation = Animation::New(durationSeconds); int targetValue(50); int relativeValue(targetValue - startValue); - animation.AnimateTo(Property(actor, "test-property"), targetValue); + animation.AnimateTo(Property(actor, "testProperty"), targetValue); int ninetyFivePercentProgress(static_cast(startValue + relativeValue*0.95f + 0.5f)); @@ -4284,7 +5404,7 @@ int UtcDaliAnimationAnimateToIntegerAlphaFunctionP(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 ); @@ -4333,7 +5453,7 @@ int UtcDaliAnimationAnimateToIntegerTimePeriodP(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 ); @@ -4388,7 +5508,7 @@ int UtcDaliAnimationAnimateToIntegerAlphaFunctionTimePeriodP(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 ); @@ -4444,7 +5564,7 @@ int UtcDaliAnimationAnimateToVector2P(void) // Register a Vector2 property Vector2 startValue(-50.0f, -50.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 ); @@ -4490,7 +5610,7 @@ int UtcDaliAnimationAnimateToVector2AlphaFunctionP(void) // Register a Vector2 property Vector2 startValue(1000.0f, 1000.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 ); @@ -4499,7 +5619,7 @@ int UtcDaliAnimationAnimateToVector2AlphaFunctionP(void) Animation animation = Animation::New(durationSeconds); Vector2 targetValue(9000.0f, 9000.0f); Vector2 relativeValue(targetValue - startValue); - animation.AnimateTo(Property(actor, "test-property"), targetValue, AlphaFunction::EASE_OUT); + animation.AnimateTo(Property(actor, "testProperty"), targetValue, AlphaFunction::EASE_OUT); Vector2 ninetyFivePercentProgress(startValue + relativeValue*0.95f); @@ -4540,7 +5660,7 @@ int UtcDaliAnimationAnimateToVector2TimePeriodP(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 ); @@ -4595,7 +5715,7 @@ int UtcDaliAnimationAnimateToVector2AlphaFunctionTimePeriodP(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 ); @@ -4651,7 +5771,7 @@ int UtcDaliAnimationAnimateToVector3P(void) // Register a Vector3 property Vector3 startValue(-50.0f, -50.0f, -50.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 ); @@ -4697,7 +5817,7 @@ int UtcDaliAnimationAnimateToVector3AlphaFunctionP(void) // Register a Vector3 property Vector3 startValue(1000.0f, 1000.0f, 1000.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 ); @@ -4748,7 +5868,7 @@ int UtcDaliAnimationAnimateToVector3TimePeriodP(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 ); @@ -4803,7 +5923,7 @@ int UtcDaliAnimationAnimateToVector3AlphaFunctionTimePeriodP(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 ); @@ -4813,7 +5933,7 @@ int UtcDaliAnimationAnimateToVector3AlphaFunctionTimePeriodP(void) Vector3 targetValue(30.0f, 30.0f, 30.0f); Vector3 relativeValue(targetValue - startValue); float delay = 0.5f; - animation.AnimateTo(Property(actor, "test-property"), + animation.AnimateTo(Property(actor, "testProperty"), targetValue, AlphaFunction::LINEAR, TimePeriod(delay, durationSeconds - delay)); @@ -4859,7 +5979,7 @@ int UtcDaliAnimationAnimateToVector3ComponentP(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 ); @@ -4869,7 +5989,7 @@ int UtcDaliAnimationAnimateToVector3ComponentP(void) Vector3 targetValue(30.0f, 30.0f, 10.0f); Vector3 relativeValue(targetValue - startValue); float delay = 0.5f; - animation.AnimateTo(Property(actor, "test-property", 0), + animation.AnimateTo(Property(actor, "testProperty", 0), 30.0f, AlphaFunction::LINEAR, TimePeriod(delay, durationSeconds - delay)); @@ -4919,7 +6039,7 @@ int UtcDaliAnimationAnimateToVector4P(void) // Register a Vector4 property Vector4 startValue(-50.0f, -40.0f, -30.0f, -20.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 ); @@ -4965,7 +6085,7 @@ int UtcDaliAnimationAnimateToVector4AlphaFunctionP(void) // Register a Vector4 property Vector4 startValue(1000.0f, 1000.0f, 1000.0f, 1000.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 ); @@ -5017,7 +6137,7 @@ int UtcDaliAnimationAnimateToVector4TimePeriodP(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, VECTOR4_EPSILON, TEST_LOCATION ); @@ -5072,7 +6192,7 @@ int UtcDaliAnimationAnimateToVector4AlphaFunctionTimePeriodP(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 ); @@ -5472,7 +6592,6 @@ int UtcDaliAnimationAnimateToActorSizeWidthP(void) application.SendNotification(); finishCheck.CheckSignalNotReceived(); DALI_TEST_EQUALS( actor.GetCurrentSize().width, fiftyPercentProgress, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::SIZE_WIDTH), fiftyPercentProgress, TEST_LOCATION ); application.SendNotification(); application.Render(static_cast(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/); @@ -5517,7 +6636,6 @@ int UtcDaliAnimationAnimateToActorSizeHeightP(void) application.SendNotification(); finishCheck.CheckSignalNotReceived(); DALI_TEST_EQUALS( actor.GetCurrentSize().height, fiftyPercentProgress, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::SIZE_HEIGHT), fiftyPercentProgress, TEST_LOCATION ); application.SendNotification(); application.Render(static_cast(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/); @@ -5562,7 +6680,6 @@ int UtcDaliAnimationAnimateToActorSizeDepthP(void) application.SendNotification(); finishCheck.CheckSignalNotReceived(); DALI_TEST_EQUALS( actor.GetCurrentSize().depth, fiftyPercentProgress, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::SIZE_DEPTH), fiftyPercentProgress, TEST_LOCATION ); application.SendNotification(); application.Render(static_cast(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/); @@ -5760,9 +6877,6 @@ int UtcDaliAnimationAnimateToActorPositionXP(void) application.SendNotification(); finishCheck.CheckSignalNotReceived(); DALI_TEST_EQUALS( actor.GetCurrentPosition().x, fiftyPercentProgress, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::POSITION_X), fiftyPercentProgress, 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 ); application.SendNotification(); application.Render(static_cast(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/); @@ -5811,9 +6925,6 @@ int UtcDaliAnimationAnimateToActorPositionYP(void) application.SendNotification(); finishCheck.CheckSignalNotReceived(); DALI_TEST_EQUALS( actor.GetCurrentPosition().y, fiftyPercentProgress, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::POSITION_X), startValue, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::POSITION_Y), fiftyPercentProgress, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::POSITION_Z), startValue, TEST_LOCATION ); application.SendNotification(); application.Render(static_cast(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/); @@ -5862,9 +6973,6 @@ int UtcDaliAnimationAnimateToActorPositionZP(void) application.SendNotification(); finishCheck.CheckSignalNotReceived(); DALI_TEST_EQUALS( actor.GetCurrentPosition().z, fiftyPercentProgress, 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), fiftyPercentProgress, TEST_LOCATION ); application.SendNotification(); application.Render(static_cast(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/); @@ -8146,7 +9254,7 @@ int UtcDaliAnimationAnimateBetweenActorColorAlphaFunctionTimePeriodP(void) END_TEST; } -int P(void) +int UtcDaliAnimationAnimateBetweenActorColorCubicWithDelayP(void) { TestApplication application; @@ -8747,12 +9855,13 @@ int UtcDaliAnimationUpdateManagerP(void) animation.FinishedSignal().Connect( &application, finishCheck ); Vector3 startValue(1.0f, 1.0f, 1.0f); - Property::Index index = actor.RegisterProperty( "test-property", startValue ); + 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(); @@ -8829,7 +9938,7 @@ int UtcDaliAnimationExtendDurationP(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 ); @@ -8882,21 +9991,21 @@ int UtcDaliAnimationExtendDurationP(void) END_TEST; } -int UtcDaliAnimationCustomUnsignedIntProperty(void) +int UtcDaliAnimationCustomIntProperty(void) { TestApplication application; Actor actor = Actor::New(); Stage::GetCurrent().Add(actor); - unsigned int startValue(0u); + int startValue(0u); - Property::Index index = actor.RegisterProperty("an-index", startValue); - DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + Property::Index index = actor.RegisterProperty("anIndex", startValue); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); // Build the animation float durationSeconds(1.0f); Animation animation = Animation::New(durationSeconds); - animation.AnimateTo( Property(actor, index), 20u ); + animation.AnimateTo( Property(actor, index), 20 ); // Start the animation animation.Play(); @@ -8911,7 +10020,7 @@ int UtcDaliAnimationCustomUnsignedIntProperty(void) // We didn't expect the animation to finish yet application.SendNotification(); finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetProperty(index), 10u, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(index), 10, TEST_LOCATION ); application.SendNotification(); application.Render(static_cast(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/); @@ -8919,7 +10028,116 @@ int UtcDaliAnimationCustomUnsignedIntProperty(void) // We did expect the animation to finish application.SendNotification(); finishCheck.CheckSignalReceived(); - DALI_TEST_EQUALS( actor.GetProperty(index), 20u, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(index), 20, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliAnimationDuration(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + Stage::GetCurrent().Add(actor); + + Animation animation = Animation::New( 0.0f ); + DALI_TEST_EQUALS( 0.0f, animation.GetDuration(), TEST_LOCATION ); + + // The animation duration should automatically increase depending on the animator time period + + animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 100.0f, TimePeriod( 0.0f, 1.0f ) ); + DALI_TEST_EQUALS( 1.0f, animation.GetDuration(), TEST_LOCATION ); + + animation.AnimateTo( Property( actor, Actor::Property::POSITION_Y ), 200.0f, TimePeriod( 10.0f, 1.0f ) ); + DALI_TEST_EQUALS( 11.0f, animation.GetDuration(), TEST_LOCATION ); + + END_TEST; +} + +int UtcDaliAnimationAnimateByNonAnimateableTypeN(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + + // Register an integer property + int startValue(1); + Property::Index index = actor.RegisterProperty( "testProperty", startValue ); + Stage::GetCurrent().Add(actor); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + + try + { + // Build the animation + Animation animation = Animation::New( 2.0f ); + std::string relativeValue = "relative string"; + animation.AnimateBy( Property(actor, index), relativeValue ); + tet_result(TET_FAIL); + } + catch ( Dali::DaliException& e ) + { + DALI_TEST_ASSERT( e, "Animated value and Property type don't match", TEST_LOCATION ); + } + + + END_TEST; +} + + +int UtcDaliAnimationAnimateToNonAnimateableTypeN(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + + // Register an integer property + int startValue(1); + Property::Index index = actor.RegisterProperty( "testProperty", startValue ); + Stage::GetCurrent().Add(actor); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + + try + { + // Build the animation + Animation animation = Animation::New( 2.0f ); + std::string relativeValue = "relative string"; + animation.AnimateTo( Property(actor, index), relativeValue ); + + tet_result(TET_FAIL); + } + catch ( Dali::DaliException& e ) + { + DALI_TEST_ASSERT( e, "Animated value and Property type don't match", TEST_LOCATION ); + } + END_TEST; } +int UtcDaliAnimationAnimateBetweenNonAnimateableTypeN(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + + // Register an integer property + int startValue(1); + Property::Index index = actor.RegisterProperty( "testProperty", startValue ); + Stage::GetCurrent().Add(actor); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + + try + { + // Build the animation + KeyFrames keyFrames = KeyFrames::New(); + keyFrames.Add( 0.0f, std::string("relative string1") ); + keyFrames.Add( 1.0f, std::string("relative string2") ); + // no need to really create the animation as keyframes do the check + + tet_result(TET_FAIL); + } + catch ( Dali::DaliException& e ) + { + DALI_TEST_ASSERT( e, "Type not animateable", TEST_LOCATION ); + } + + END_TEST; +}