#include <algorithm>
#include <stdlib.h>
-#include <dali/dali.h>
+#include <dali/public-api/dali-core.h>
#include <dali-test-suite-utils.h>
using std::max;
float mEnd;
};
+struct AnimateIntegerTestFunctor
+{
+ AnimateIntegerTestFunctor( int start, int end )
+ : mStart( start ),
+ mEnd( end )
+ {
+ }
+
+ int operator()( float alpha, const int& current )
+ {
+ return static_cast<int>( mStart + ((mEnd - mStart) * alpha ) + 0.5f );
+ }
+
+ int mStart;
+ int mEnd;
+};
+
struct AnimateVector2TestFunctor
{
AnimateVector2TestFunctor( Vector2 start, Vector2 end )
END_TEST;
}
+int UtcDaliAnimationSetSpeedFactor(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::POSITION), keyframes, AlphaFunctions::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<unsigned int>(durationSeconds*200.0f)/* 40% progress */);
+
+ // We didn't expect the animation to finish yet
+ application.SendNotification();
+ finishCheck.CheckSignalNotReceived();
+ DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.4f), TEST_LOCATION );
+
+ application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 80% progress */);
+
+ // We didn't expect the animation to finish yet
+ application.SendNotification();
+ finishCheck.CheckSignalNotReceived();
+ DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.8f), TEST_LOCATION );
+
+ application.Render(static_cast<unsigned int>(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 );
+
+ finishCheck.Reset();
+
+ //Test -1 speed factor. Animation will play in reverse at normal speed
+ animation.SetSpeedFactor( -1.0f );
+
+ // Start the animation
+ animation.Play();
+
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 80% progress */);
+
+ // We didn't expect the animation to finish yet
+ application.SendNotification();
+ finishCheck.CheckSignalNotReceived();
+ DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.8f), TEST_LOCATION );
+
+ application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 60% progress */);
+
+ // We didn't expect the animation to finish yet
+ application.SendNotification();
+ finishCheck.CheckSignalNotReceived();
+ DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.6f), TEST_LOCATION );
+
+ application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 40% progress */);
+
+ // We didn't expect the animation to finish yet
+ application.SendNotification();
+ finishCheck.CheckSignalNotReceived();
+ DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.4f), TEST_LOCATION );
+
+ application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 20% progress */);
+
+ // We didn't expect the animation to finish yet
+ application.SendNotification();
+ finishCheck.CheckSignalNotReceived();
+ DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION );
+
+ application.Render(static_cast<unsigned int>(durationSeconds*200.0f) + 1u/*just beyond the animation duration*/);
+
+ // We did expect the animation to finish
+ application.SendNotification();
+ finishCheck.CheckSignalReceived();
+ DALI_TEST_EQUALS( actor.GetCurrentPosition(), 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 );
+
+
+ //Test change speed factor on the fly
+ finishCheck.Reset();
+
+ //Set speed to be half of normal speed
+ animation.SetSpeedFactor( 0.5f );
+
+ // Start the animation
+ animation.Play();
+
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 10% progress */);
+
+ // We didn't expect the animation to finish yet
+ application.SendNotification();
+ finishCheck.CheckSignalNotReceived();
+ DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.1f), TEST_LOCATION );
+
+ application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 20% progress */);
+
+ // We didn't expect the animation to finish yet
+ application.SendNotification();
+ finishCheck.CheckSignalNotReceived();
+ DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION );
+
+ application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 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 );
+
+ //Change speed factor while animation still playing.
+ animation.SetSpeedFactor(-1.0f);
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 10% progress */);
+
+ // We didn't expect the animation to finish yet
+ application.SendNotification();
+ finishCheck.CheckSignalNotReceived();
+ DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.1f), TEST_LOCATION );
+
+ 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(), 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 UtcDaliAnimationGetSpeedFactor(void)
+{
+ TestApplication application;
+
+ Animation animation = Animation::New(1.0f);
+ animation.SetSpeedFactor(0.5f);
+ DALI_TEST_EQUALS(animation.GetSpeedFactor(), 0.5f, TEST_LOCATION);
+
+ animation.SetSpeedFactor(-2.5f);
+ DALI_TEST_EQUALS(animation.GetSpeedFactor(), -2.5f, TEST_LOCATION);
+ END_TEST;
+}
+
int UtcDaliAnimationPlayOffStage(void)
{
// Test that an animation can be played, when the actor is off-stage.
END_TEST;
}
+int UtcDaliAnimationPlayRange(void)
+{
+ TestApplication application;
+
+ Actor actor = Actor::New();
+ Stage::GetCurrent().Add(actor);
+
+ // Build the animation
+ float durationSeconds(1.0f);
+ Animation animation = Animation::New(durationSeconds);
+ Vector3 targetPosition(100.0f, 100.0f, 100.0f);
+ KeyFrames keyframes = KeyFrames::New();
+ keyframes.Add( 0.0f , Vector3(0.0f,0.0f,0.0f ) );
+ keyframes.Add( 1.0f , Vector3(100.0f,100.0f,100.0f ) );
+
+ animation.AnimateBetween( Property( actor, Actor::POSITION), keyframes );
+
+ // Set range between 0.4 and 0.8
+ animation.SetPlayRange( Vector2(0.4f,0.8f) );
+ animation.Play();
+
+ bool signalReceived(false);
+ AnimationFinishCheck finishCheck(signalReceived);
+ animation.FinishedSignal().Connect(&application, finishCheck);
+
+ //Test that setting progress outside the range doesn't work
+ animation.SetCurrentProgress( 0.9f );
+ application.SendNotification();
+ application.Render(0);
+ DALI_TEST_EQUALS( animation.GetCurrentProgress(), 0.4f, TEST_LOCATION );
+ animation.SetCurrentProgress( 0.2f );
+ application.SendNotification();
+ application.Render(0);
+ DALI_TEST_EQUALS( animation.GetCurrentProgress(), 0.4f, TEST_LOCATION );
+
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 60% progress */);
+
+ // We didn't expect the animation to finish yet
+ application.SendNotification();
+ finishCheck.CheckSignalNotReceived();
+ DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.6f), TEST_LOCATION );
+
+ animation.Play(); // Test that calling play has no effect, when animation is already playing
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(durationSeconds*200.0f) + 1u/* 80% progress */);
+
+ // We did expect the animation to finish
+ application.SendNotification();
+ finishCheck.CheckSignalReceived();
+ DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.8f), TEST_LOCATION );
+
+ // Check that nothing has changed after a couple of buffer swaps
+ application.Render(0);
+ DALI_TEST_EQUALS( targetPosition * 0.8f, actor.GetCurrentPosition(), TEST_LOCATION );
+ application.Render(0);
+ DALI_TEST_EQUALS( targetPosition * 0.8f, actor.GetCurrentPosition(), TEST_LOCATION );
+
+
+ //Loop inside the range
+ finishCheck.Reset();
+ animation.SetLooping( true );
+ animation.Play();
+ application.SendNotification();
+ float intervalSeconds = 0.1f;
+ float progress = 0.4f;
+ for (int iterations = 0; iterations < 10; ++iterations )
+ {
+ application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
+
+ progress += intervalSeconds;
+ if (progress > 0.8f)
+ {
+ progress = progress - 0.4f;
+ }
+
+ DALI_TEST_EQUALS( targetPosition*progress, actor.GetCurrentPosition(), 0.001f, TEST_LOCATION );
+ }
+
+ // We didn't expect the animation to finish yet
+ application.SendNotification();
+ finishCheck.CheckSignalNotReceived();
+
+
+ //Test change range on the fly
+ animation.SetPlayRange( Vector2( 0.2f, 0.9f ) );
+ application.SendNotification();
+
+ for (int iterations = 0; iterations < 10; ++iterations )
+ {
+ application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
+
+ progress += intervalSeconds;
+ if (progress > 0.9f)
+ {
+ progress = progress - 0.7f;
+ }
+
+ DALI_TEST_EQUALS( targetPosition*progress, actor.GetCurrentPosition(), 0.001f, TEST_LOCATION );
+ }
+
+ END_TEST;
+}
+
+int UtcDaliAnimationSetPlayRange(void)
+{
+ TestApplication application;
+
+ Actor actor = Actor::New();
+ Stage::GetCurrent().Add(actor);
+
+ // Build the animation
+ Animation animation = Animation::New(0);
+ application.SendNotification();
+
+ //If PlayRange not specified it should be 0.0-1.0 by default
+ DALI_TEST_EQUALS( Vector2(0.0,1.0), animation.GetPlayRange(), TEST_LOCATION );
+
+ //PlayRange out of bounds
+ animation.SetPlayRange( Vector2(-1.0f,1.0f) );
+ application.SendNotification();
+ DALI_TEST_EQUALS( Vector2(0.0f,1.0f), animation.GetPlayRange(), TEST_LOCATION );
+ animation.SetPlayRange( Vector2(0.0f,2.0f) );
+ application.SendNotification();
+ DALI_TEST_EQUALS( Vector2(0.0f,1.0f), animation.GetPlayRange(), TEST_LOCATION );
+
+ //If playRange is not in the correct order it has to be ordered
+ animation.SetPlayRange( Vector2(0.8f,0.2f) );
+ application.SendNotification();
+ DALI_TEST_EQUALS( Vector2(0.2f,0.8f), animation.GetPlayRange(), TEST_LOCATION );
+
+ // Set range between 0.4 and 0.8
+ animation.SetPlayRange( Vector2(0.4f,0.8f) );
+ application.SendNotification();
+ DALI_TEST_EQUALS( Vector2(0.4f,0.8f), animation.GetPlayRange(), TEST_LOCATION );
+
+ END_TEST;
+}
int UtcDaliAnimationPause(void)
{
END_TEST;
}
-int UtcDaliAnimationAnimateByVector2(void)
+int UtcDaliAnimationAnimateByInteger(void)
{
TestApplication application;
Actor actor = Actor::New();
- // Register a Vector2 property
- Vector2 startValue(10.0f, 10.0f);
+ // Register an integer property
+ int startValue(1);
Property::Index index = actor.RegisterProperty( "test-property", startValue );
Stage::GetCurrent().Add(actor);
- DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
+
+ // Build the animation
+ float durationSeconds(2.0f);
+ Animation animation = Animation::New(durationSeconds);
+ int targetValue(50);
+ int relativeValue(targetValue - startValue);
+ animation.AnimateBy(Property(actor, index), relativeValue);
+
+ int ninetyFivePercentProgress(static_cast<int>(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<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
+
+ // We didn't expect the animation to finish yet
+ application.SendNotification();
+ finishCheck.CheckSignalNotReceived();
+ DALI_TEST_EQUALS( actor.GetProperty<int>(index), ninetyFivePercentProgress, TEST_LOCATION );
+
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
+
+ // We did expect the animation to finish
+ application.SendNotification();
+ finishCheck.CheckSignalReceived();
+ DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
+
+ // Check that nothing has changed after a couple of buffer swaps
+ application.Render(0);
+ DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
+ application.Render(0);
+ DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
+ END_TEST;
+}
+
+int UtcDaliAnimationAnimateByIntegerAlphaFunction(void)
+{
+ TestApplication application;
+
+ Actor actor = Actor::New();
+
+ // Register an integer property
+ int startValue(1);
+ Property::Index index = actor.RegisterProperty( "test-property", startValue );
+ Stage::GetCurrent().Add(actor);
+ DALI_TEST_EQUALS( actor.GetProperty<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);
+
+ int ninetyFivePercentProgress(static_cast<int>(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<unsigned int>(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.GetProperty<int>(index));
+ DALI_TEST_CHECK( current > ninetyFivePercentProgress );
+
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
+
+ // We did expect the animation to finish
+ application.SendNotification();
+ finishCheck.CheckSignalReceived();
+ DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
+
+ // Check that nothing has changed after a couple of buffer swaps
+ application.Render(0);
+ DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
+ application.Render(0);
+ DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
+ END_TEST;
+}
+
+int UtcDaliAnimationAnimateByIntegerTimePeriod(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<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.AnimateBy(Property(actor, index),
+ relativeValue,
+ 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<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
+
+ // We didn't expect the animation to finish yet
+ application.SendNotification();
+ finishCheck.CheckSignalNotReceived();
+ DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
+
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(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<int>(index), static_cast<int>(startValue+(relativeValue*0.5f)+0.5f), TEST_LOCATION );
+
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
+
+ // We did expect the animation to finish
+ application.SendNotification();
+ finishCheck.CheckSignalReceived();
+ DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
+
+ // Check that nothing has changed after a couple of buffer swaps
+ application.Render(0);
+ DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
+ application.Render(0);
+ DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
+ END_TEST;
+}
+
+int UtcDaliAnimationAnimateByIntegerAlphaFunctionTimePeriod(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<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.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<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
+
+ // We didn't expect the animation to finish yet
+ application.SendNotification();
+ finishCheck.CheckSignalNotReceived();
+ DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
+
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(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<int>(index), static_cast<int>(startValue+(relativeValue*0.5f)+0.5f), TEST_LOCATION );
+
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
+
+ // We did expect the animation to finish
+ application.SendNotification();
+ finishCheck.CheckSignalReceived();
+ DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
+
+ // Check that nothing has changed after a couple of buffer swaps
+ application.Render(0);
+ DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
+ application.Render(0);
+ DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
+ END_TEST;
+}
+
+int UtcDaliAnimationAnimateByVector2(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<Vector2>(index), startValue, TEST_LOCATION );
// Build the animation
float durationSeconds(2.0f);
finishCheck.CheckSignalReceived();
DALI_TEST_CHECK( actor.GetProperty<bool>(index) == targetValue );
- // Check that nothing has changed after a couple of buffer swaps
- application.Render(0);
- DALI_TEST_CHECK( actor.GetProperty<bool>(index) == targetValue );
- application.Render(0);
- DALI_TEST_CHECK( actor.GetProperty<bool>(index) == targetValue );
+ // Check that nothing has changed after a couple of buffer swaps
+ application.Render(0);
+ DALI_TEST_CHECK( actor.GetProperty<bool>(index) == targetValue );
+ application.Render(0);
+ DALI_TEST_CHECK( actor.GetProperty<bool>(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<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
+
+ // We didn't expect the animation to finish yet
+ application.SendNotification();
+ finishCheck.CheckSignalNotReceived();
+ DALI_TEST_CHECK( actor.GetProperty<bool>(index) == targetValue );
+
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
+
+ // We did expect the animation to finish
+ application.SendNotification();
+ finishCheck.CheckSignalReceived();
+ DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
+
+ // Check that nothing has changed after a couple of buffer swaps
+ application.Render(0);
+ DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
+ application.Render(0);
+ DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
+ END_TEST;
+}
+
+int UtcDaliAnimationAnimateToBooleanTimePeriod(void)
+{
+ TestApplication application;
+
+ Actor actor = Actor::New();
+
+ // Register a boolean property
+ bool startValue(false);
+ Property::Index index = actor.RegisterProperty( "test-property", startValue );
+ Stage::GetCurrent().Add(actor);
+ DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
+
+ // Build the animation
+ float durationSeconds(2.0f);
+ Animation animation = Animation::New(durationSeconds);
+ bool finalValue( !startValue );
+ float animatorDurationSeconds(durationSeconds * 0.5f);
+ animation.AnimateTo( Property(actor, index),
+ finalValue,
+ TimePeriod( animatorDurationSeconds ) );
+
+ // Start the animation
+ animation.Play();
+
+ bool signalReceived(false);
+ AnimationFinishCheck finishCheck(signalReceived);
+ animation.FinishedSignal().Connect(&application, finishCheck);
+
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(animatorDurationSeconds*950.0f)/* 95% animator progress */);
+
+ // We didn't expect the animation to finish yet
+ application.SendNotification();
+ finishCheck.CheckSignalNotReceived();
+ DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
+
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(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<bool>(index) == finalValue );
+
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(animatorDurationSeconds*1000.0f)/*just beyond the animation duration*/);
+
+ // We did expect the animation to finish
+ application.SendNotification();
+ finishCheck.CheckSignalReceived();
+ DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
+
+ // Check that nothing has changed after a couple of buffer swaps
+ application.Render(0);
+ DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
+ application.Render(0);
+ DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
+ END_TEST;
+}
+
+int UtcDaliAnimationAnimateToBooleanAlphaFunctionTimePeriod(void)
+{
+ TestApplication application;
+
+ Actor actor = Actor::New();
+
+ // Register a boolean property
+ bool startValue(false);
+ Property::Index index = actor.RegisterProperty( "test-property", startValue );
+ Stage::GetCurrent().Add(actor);
+ DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
+
+ // Build the animation
+ float durationSeconds(2.0f);
+ Animation animation = Animation::New(durationSeconds);
+ bool finalValue( !startValue );
+ float animatorDurationSeconds(durationSeconds * 0.5f);
+ animation.AnimateTo( Property(actor, index),
+ finalValue,
+ AlphaFunctions::Linear,
+ TimePeriod( animatorDurationSeconds ) );
+
+ // Start the animation
+ animation.Play();
+
+ bool signalReceived(false);
+ AnimationFinishCheck finishCheck(signalReceived);
+ animation.FinishedSignal().Connect(&application, finishCheck);
+
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(animatorDurationSeconds*950.0f)/* 95% animator progress */);
+
+ // We didn't expect the animation to finish yet
+ application.SendNotification();
+ finishCheck.CheckSignalNotReceived();
+ DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
+
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(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<bool>(index) == finalValue );
+
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(animatorDurationSeconds*1000.0f)/*just beyond the animation duration*/);
+
+ // We did expect the animation to finish
+ application.SendNotification();
+ finishCheck.CheckSignalReceived();
+ DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
+
+ // Check that nothing has changed after a couple of buffer swaps
+ application.Render(0);
+ DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
+ application.Render(0);
+ DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
+ END_TEST;
+}
+
+int UtcDaliAnimationAnimateToFloat(void)
+{
+ TestApplication application;
+
+ Actor actor = Actor::New();
+
+ // Register a float property
+ float startValue(10.0f);
+ Property::Index index = actor.RegisterProperty( "test-property", startValue );
+ Stage::GetCurrent().Add(actor);
+ DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
+
+ // Build the animation
+ float durationSeconds(2.0f);
+ Animation animation = Animation::New(durationSeconds);
+ float targetValue(50.0f);
+ float relativeValue(targetValue - startValue);
+ animation.AnimateTo(Property(actor, "test-property"), targetValue);
+
+ float ninetyFivePercentProgress(startValue + relativeValue*0.95f);
+
+ // Start the animation
+ animation.Play();
+
+ bool signalReceived(false);
+ AnimationFinishCheck finishCheck(signalReceived);
+ animation.FinishedSignal().Connect(&application, finishCheck);
+
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
+
+ // We didn't expect the animation to finish yet
+ application.SendNotification();
+ finishCheck.CheckSignalNotReceived();
+ DALI_TEST_EQUALS( actor.GetProperty<float>(index), ninetyFivePercentProgress, TEST_LOCATION );
+
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
+
+ // We did expect the animation to finish
+ application.SendNotification();
+ finishCheck.CheckSignalReceived();
+ DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
+ END_TEST;
+}
+
+int UtcDaliAnimationAnimateToFloatAlphaFunction(void)
+{
+ TestApplication application;
+
+ Actor actor = Actor::New();
+
+ // Register a float property
+ float startValue(10.0f);
+ Property::Index index = actor.RegisterProperty( "test-property", startValue );
+ Stage::GetCurrent().Add(actor);
+ DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
+
+ // Build the animation
+ float durationSeconds(1.0f);
+ Animation animation = Animation::New(durationSeconds);
+ float targetValue(90.0f);
+ float relativeValue(targetValue - startValue);
+ animation.AnimateTo(Property(actor, index), targetValue, AlphaFunctions::EaseOut);
- // Repeat with target value "false"
- animation = Animation::New(durationSeconds);
- const bool finalValue( !targetValue );
- animation.AnimateTo(Property(actor, index), finalValue, AlphaFunctions::EaseOut);
+ float ninetyFivePercentProgress(startValue + relativeValue*0.95f);
// Start the animation
animation.Play();
- finishCheck.Reset();
+ bool signalReceived(false);
+ AnimationFinishCheck finishCheck(signalReceived);
animation.FinishedSignal().Connect(&application, finishCheck);
application.SendNotification();
// We didn't expect the animation to finish yet
application.SendNotification();
finishCheck.CheckSignalNotReceived();
- DALI_TEST_CHECK( actor.GetProperty<bool>(index) == targetValue );
+
+ // The position should have moved more, than with a linear alpha function
+ float current(actor.GetProperty<float>(index));
+ DALI_TEST_CHECK( current > ninetyFivePercentProgress );
application.SendNotification();
application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
// We did expect the animation to finish
application.SendNotification();
finishCheck.CheckSignalReceived();
- DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
-
- // Check that nothing has changed after a couple of buffer swaps
- application.Render(0);
- DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
- application.Render(0);
- DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
+ DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
END_TEST;
}
-int UtcDaliAnimationAnimateToBooleanTimePeriod(void)
+int UtcDaliAnimationAnimateToFloatTimePeriod(void)
{
TestApplication application;
Actor actor = Actor::New();
- // Register a boolean property
- bool startValue(false);
+ // Register a float property
+ float startValue(10.0f);
Property::Index index = actor.RegisterProperty( "test-property", startValue );
Stage::GetCurrent().Add(actor);
- DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
+ DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
// Build the animation
- float durationSeconds(2.0f);
+ float durationSeconds(1.0f);
Animation animation = Animation::New(durationSeconds);
- bool finalValue( !startValue );
- float animatorDurationSeconds(durationSeconds * 0.5f);
- animation.AnimateTo( Property(actor, index),
- finalValue,
- TimePeriod( animatorDurationSeconds ) );
+ float targetValue(30.0f);
+ float relativeValue(targetValue - startValue);
+ float delay = 0.5f;
+ animation.AnimateTo(Property(actor, index),
+ targetValue,
+ TimePeriod(delay, durationSeconds - delay));
// Start the animation
animation.Play();
animation.FinishedSignal().Connect(&application, finishCheck);
application.SendNotification();
- application.Render(static_cast<unsigned int>(animatorDurationSeconds*950.0f)/* 95% animator progress */);
+ application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
// We didn't expect the animation to finish yet
application.SendNotification();
finishCheck.CheckSignalNotReceived();
- DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
+ DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
application.SendNotification();
- application.Render(static_cast<unsigned int>(animatorDurationSeconds*50.0f) + 1u/*just beyond the animator duration*/);
+ application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
- // We didn't expect the animation to finish yet...
+ // We didn't expect the animation to finish yet
application.SendNotification();
finishCheck.CheckSignalNotReceived();
-
- // ...however we should have reached the final value
- DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
+ DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
application.SendNotification();
- application.Render(static_cast<unsigned int>(animatorDurationSeconds*1000.0f)/*just beyond the animation duration*/);
+ application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
// We did expect the animation to finish
application.SendNotification();
finishCheck.CheckSignalReceived();
- DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
-
- // Check that nothing has changed after a couple of buffer swaps
- application.Render(0);
- DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
- application.Render(0);
- DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
+ DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
END_TEST;
}
-int UtcDaliAnimationAnimateToBooleanAlphaFunctionTimePeriod(void)
+int UtcDaliAnimationAnimateToFloatAlphaFunctionTimePeriod(void)
{
TestApplication application;
Actor actor = Actor::New();
- // Register a boolean property
- bool startValue(false);
+ // Register a float property
+ float startValue(10.0f);
Property::Index index = actor.RegisterProperty( "test-property", startValue );
Stage::GetCurrent().Add(actor);
- DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
+ DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
// Build the animation
- float durationSeconds(2.0f);
+ float durationSeconds(1.0f);
Animation animation = Animation::New(durationSeconds);
- bool finalValue( !startValue );
- float animatorDurationSeconds(durationSeconds * 0.5f);
- animation.AnimateTo( Property(actor, index),
- finalValue,
- AlphaFunctions::Linear,
- TimePeriod( animatorDurationSeconds ) );
+ 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
animation.Play();
animation.FinishedSignal().Connect(&application, finishCheck);
application.SendNotification();
- application.Render(static_cast<unsigned int>(animatorDurationSeconds*950.0f)/* 95% animator progress */);
+ application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
// We didn't expect the animation to finish yet
application.SendNotification();
finishCheck.CheckSignalNotReceived();
- DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
+ DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
application.SendNotification();
- application.Render(static_cast<unsigned int>(animatorDurationSeconds*50.0f) + 1u/*just beyond the animator duration*/);
+ application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
- // We didn't expect the animation to finish yet...
+ // We didn't expect the animation to finish yet
application.SendNotification();
finishCheck.CheckSignalNotReceived();
-
- // ...however we should have reached the final value
- DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
+ DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
application.SendNotification();
- application.Render(static_cast<unsigned int>(animatorDurationSeconds*1000.0f)/*just beyond the animation duration*/);
+ application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
// We did expect the animation to finish
application.SendNotification();
finishCheck.CheckSignalReceived();
- DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
-
- // Check that nothing has changed after a couple of buffer swaps
- application.Render(0);
- DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
- application.Render(0);
- DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
+ DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
END_TEST;
}
-int UtcDaliAnimationAnimateToFloat(void)
+int UtcDaliAnimationAnimateToInteger(void)
{
TestApplication application;
Actor actor = Actor::New();
- // Register a float property
- float startValue(10.0f);
+ // Register an integer property
+ int startValue(10);
Property::Index index = actor.RegisterProperty( "test-property", startValue );
Stage::GetCurrent().Add(actor);
- DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
// Build the animation
float durationSeconds(2.0f);
Animation animation = Animation::New(durationSeconds);
- float targetValue(50.0f);
- float relativeValue(targetValue - startValue);
+ int targetValue(50);
+ int relativeValue(targetValue - startValue);
animation.AnimateTo(Property(actor, "test-property"), targetValue);
- float ninetyFivePercentProgress(startValue + relativeValue*0.95f);
+ int ninetyFivePercentProgress(static_cast<int>(startValue + relativeValue*0.95f + 0.5f));
// Start the animation
animation.Play();
// We didn't expect the animation to finish yet
application.SendNotification();
finishCheck.CheckSignalNotReceived();
- DALI_TEST_EQUALS( actor.GetProperty<float>(index), ninetyFivePercentProgress, TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetProperty<int>(index), ninetyFivePercentProgress, TEST_LOCATION );
application.SendNotification();
application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
// We did expect the animation to finish
application.SendNotification();
finishCheck.CheckSignalReceived();
- DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
END_TEST;
}
-int UtcDaliAnimationAnimateToFloatAlphaFunction(void)
+int UtcDaliAnimationAnimateToIntegerAlphaFunction(void)
{
TestApplication application;
Actor actor = Actor::New();
- // Register a float property
- float startValue(10.0f);
+ // Register an integer property
+ int startValue(10);
Property::Index index = actor.RegisterProperty( "test-property", startValue );
Stage::GetCurrent().Add(actor);
- DALI_TEST_EQUALS( actor.GetProperty<float>(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);
- float targetValue(90.0f);
- float relativeValue(targetValue - startValue);
+ int targetValue(90);
+ int relativeValue(targetValue - startValue);
animation.AnimateTo(Property(actor, index), targetValue, AlphaFunctions::EaseOut);
- float ninetyFivePercentProgress(startValue + relativeValue*0.95f);
+ int ninetyFivePercentProgress(static_cast<int>(startValue + relativeValue*0.95f + 0.5f));
// Start the animation
animation.Play();
finishCheck.CheckSignalNotReceived();
// The position should have moved more, than with a linear alpha function
- float current(actor.GetProperty<float>(index));
+ int current(actor.GetProperty<int>(index));
DALI_TEST_CHECK( current > ninetyFivePercentProgress );
application.SendNotification();
// We did expect the animation to finish
application.SendNotification();
finishCheck.CheckSignalReceived();
- DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
END_TEST;
}
-int UtcDaliAnimationAnimateToFloatTimePeriod(void)
+int UtcDaliAnimationAnimateToIntegerTimePeriod(void)
{
TestApplication application;
Actor actor = Actor::New();
- // Register a float property
- float startValue(10.0f);
+ // Register an integer property
+ int startValue(10);
Property::Index index = actor.RegisterProperty( "test-property", startValue );
Stage::GetCurrent().Add(actor);
- DALI_TEST_EQUALS( actor.GetProperty<float>(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);
- float targetValue(30.0f);
- float relativeValue(targetValue - startValue);
+ int targetValue(30);
+ int relativeValue(targetValue - startValue);
float delay = 0.5f;
animation.AnimateTo(Property(actor, index),
targetValue,
// We didn't expect the animation to finish yet
application.SendNotification();
finishCheck.CheckSignalNotReceived();
- DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
application.SendNotification();
application.Render(static_cast<unsigned int>(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<float>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetProperty<int>(index), static_cast<int>(startValue+(relativeValue*0.5f)+0.5f), TEST_LOCATION );
application.SendNotification();
application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
// We did expect the animation to finish
application.SendNotification();
finishCheck.CheckSignalReceived();
- DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
END_TEST;
}
-int UtcDaliAnimationAnimateToFloatAlphaFunctionTimePeriod(void)
+int UtcDaliAnimationAnimateToIntegerAlphaFunctionTimePeriod(void)
{
TestApplication application;
Actor actor = Actor::New();
- // Register a float property
- float startValue(10.0f);
+ // Register an integer property
+ int startValue(10);
Property::Index index = actor.RegisterProperty( "test-property", startValue );
Stage::GetCurrent().Add(actor);
- DALI_TEST_EQUALS( actor.GetProperty<float>(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);
- float targetValue(30.0f);
- float relativeValue(targetValue - startValue);
+ int targetValue(30);
+ int relativeValue(targetValue - startValue);
float delay = 0.5f;
animation.AnimateTo(Property(actor, index),
targetValue,
// We didn't expect the animation to finish yet
application.SendNotification();
finishCheck.CheckSignalNotReceived();
- DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
application.SendNotification();
application.Render(static_cast<unsigned int>(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<float>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetProperty<int>(index), static_cast<int>(startValue+(relativeValue*0.5f)+0.5f), TEST_LOCATION );
application.SendNotification();
application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
// We did expect the animation to finish
application.SendNotification();
finishCheck.CheckSignalReceived();
- DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
END_TEST;
}
END_TEST;
}
+int UtcDaliAnimationAnimateInteger(void)
+{
+ TestApplication application;
+
+ Actor actor = Actor::New();
+ Stage::GetCurrent().Add(actor);
+
+ // Register an integer property
+ int startValue(10);
+ Property::Index index = actor.RegisterProperty( "test-property", startValue );
+ DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
+
+ // Build the animation
+ float durationSeconds(10.0f);
+ Animation animation = Animation::New(durationSeconds);
+ int targetPosition(0);
+ AnimateIntegerTestFunctor func( 100, targetPosition );
+ animation.Animate<int>( Property(actor, index), func );
+
+ // Start the animation
+ animation.Play();
+
+ bool signalReceived(false);
+ AnimationFinishCheck finishCheck(signalReceived);
+ animation.FinishedSignal().Connect(&application, finishCheck);
+
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
+
+ // We didn't expect the animation to finish yet
+ application.SendNotification();
+ finishCheck.CheckSignalNotReceived();
+ DALI_TEST_EQUALS( actor.GetProperty<int>(index), 75, TEST_LOCATION );
+
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
+
+ // We didn't expect the animation to finish yet
+ application.SendNotification();
+ finishCheck.CheckSignalNotReceived();
+ DALI_TEST_EQUALS( actor.GetProperty<int>(index), 50, TEST_LOCATION );
+
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
+
+ // We didn't expect the animation to finish yet
+ application.SendNotification();
+ finishCheck.CheckSignalNotReceived();
+ DALI_TEST_EQUALS( actor.GetProperty<int>(index), 25, TEST_LOCATION );
+
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
+
+ // We did expect the animation to finish
+ application.SendNotification();
+ finishCheck.CheckSignalReceived();
+ DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetPosition, TEST_LOCATION );
+ END_TEST;
+}
+
int UtcDaliAnimationAnimateVector2(void)
{
TestApplication application;
END_TEST;
}
+int UtcDaliAnimationExtendDuration(void)
+{
+ TestApplication application;
+
+ Actor actor = Actor::New();
+
+ // Register a float property
+ float startValue(10.0f);
+ Property::Index index = actor.RegisterProperty( "test-property", startValue );
+ Stage::GetCurrent().Add(actor);
+ DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
+
+ // Build the animation
+ float initialDurationSeconds(1.0f);
+ float animatorDelay = 5.0f;
+ float animatorDurationSeconds(5.0f);
+ float extendedDurationSeconds(animatorDelay+animatorDurationSeconds);
+ Animation animation = Animation::New(initialDurationSeconds);
+ float targetValue(30.0f);
+ float relativeValue(targetValue - startValue);
+
+ animation.AnimateTo(Property(actor, index),
+ targetValue,
+ TimePeriod(animatorDelay, animatorDurationSeconds));
+
+ // The duration should have been extended
+ DALI_TEST_EQUALS( animation.GetDuration(), extendedDurationSeconds, TEST_LOCATION );
+
+ // Start the animation
+ animation.Play();
+
+ bool signalReceived(false);
+ AnimationFinishCheck finishCheck(signalReceived);
+ animation.FinishedSignal().Connect(&application, finishCheck);
+
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(extendedDurationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
+
+ // We didn't expect the animation to finish yet
+ application.SendNotification();
+ finishCheck.CheckSignalNotReceived();
+ DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
+
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(extendedDurationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
+
+ // We didn't expect the animation to finish yet
+ application.SendNotification();
+ finishCheck.CheckSignalNotReceived();
+ DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
+
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(extendedDurationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
+
+ // We did expect the animation to finish
+ application.SendNotification();
+ finishCheck.CheckSignalReceived();
+ DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
+ END_TEST;
+}
+