/*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 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.
END_TEST;
}
+int UtcDaliAnimationStopEmitFinishedSignalImmediateP(void)
+{
+ TestApplication application;
+
+ Actor actor = Actor::New();
+ application.GetScene().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);
+
+ bool signalReceived(false);
+ AnimationFinishCheck finishCheck(signalReceived);
+ animation.FinishedSignal().Connect(&application, finishCheck);
+
+ // Play
+ {
+ tet_printf("Play and Stop immediately\n");
+ // Start the animation, and stop immediately.
+ animation.Play();
+ animation.Stop();
+
+ finishCheck.CheckSignalNotReceived();
+
+ application.SendNotification();
+ application.Render(0);
+
+ // expect finished signal recieved due to Stop API.
+ application.SendNotification();
+ finishCheck.CheckSignalReceived();
+ finishCheck.Reset();
+
+ application.SendNotification();
+ application.Render(0);
+ }
+ // Play multiple times
+ {
+ tet_printf("Play and Stop immediately 2\n");
+ // Start the animation, and stop immediately.
+ animation.Play();
+ animation.Stop();
+ animation.Play();
+ animation.Stop();
+ animation.Play();
+ animation.Play();
+ animation.Stop();
+
+ finishCheck.CheckSignalNotReceived();
+
+ application.SendNotification();
+ application.Render(0);
+
+ // expect finished signal recieved due to Stop API.
+ application.SendNotification();
+ finishCheck.CheckSignalReceived();
+ finishCheck.Reset();
+
+ application.SendNotification();
+ application.Render(0);
+ }
+ // PlayAfter
+ {
+ tet_printf("PlayAfter and Stop immediately\n");
+ // Start the animation, and stop immediately.
+ animation.PlayAfter(1.0f);
+ animation.Stop();
+
+ finishCheck.CheckSignalNotReceived();
+
+ application.SendNotification();
+ application.Render(0);
+
+ // expect finished signal recieved due to Stop API.
+ application.SendNotification();
+ finishCheck.CheckSignalReceived();
+ finishCheck.Reset();
+
+ application.SendNotification();
+ application.Render(0);
+ }
+ // PlayFrom
+ {
+ tet_printf("PlayFrom and Stop immediately\n");
+ // Start the animation, and stop immediately.
+ animation.PlayFrom(0.5f);
+ animation.Stop();
+
+ finishCheck.CheckSignalNotReceived();
+
+ application.SendNotification();
+ application.Render(0);
+
+ // expect finished signal recieved due to Stop API.
+ application.SendNotification();
+ finishCheck.CheckSignalReceived();
+ finishCheck.Reset();
+
+ application.SendNotification();
+ application.Render(0);
+ }
+ // Play and Pause
+ {
+ tet_printf("Play and Pause and Stop immediately\n");
+ // Pause the animation, and stop immediately.
+ animation.Play();
+ animation.Pause();
+ animation.Stop();
+
+ finishCheck.CheckSignalNotReceived();
+
+ application.SendNotification();
+ application.Render(0);
+
+ // expect finished signal recieved due to Stop API.
+ application.SendNotification();
+ finishCheck.CheckSignalReceived();
+ finishCheck.Reset();
+
+ application.SendNotification();
+ application.Render(0);
+ }
+
+ // Check finished signal not emmited if animation was not play state.
+ {
+ tet_printf("Check whether stop-only case didnt send finished signal\n");
+ // Stop only.
+ animation.Stop();
+ animation.Stop();
+ animation.Stop();
+
+ finishCheck.CheckSignalNotReceived();
+
+ application.SendNotification();
+ application.Render(0);
+
+ // expect finished signal not recieved.
+ application.SendNotification();
+ finishCheck.CheckSignalNotReceived();
+ finishCheck.Reset();
+
+ application.SendNotification();
+ application.Render(0);
+ }
+ {
+ tet_printf("Check whether pause-stop case didnt send finished signal\n");
+ // Pause and Stop.
+ animation.Pause();
+ animation.Stop();
+
+ finishCheck.CheckSignalNotReceived();
+
+ application.SendNotification();
+ application.Render(0);
+
+ // expect finished signal not recieved.
+ application.SendNotification();
+ finishCheck.CheckSignalNotReceived();
+ finishCheck.Reset();
+
+ application.SendNotification();
+ application.Render(0);
+ }
+
+ END_TEST;
+}
+
int UtcDaliAnimationClearP(void)
{
TestApplication application;
END_TEST;
}
-int UtcDaliAnimationFinishedSignalP(void)
-{
- TestApplication application;
-
- // Start the empty animation
- float durationSeconds(1.0f);
- Animation animation = Animation::New(durationSeconds);
- animation.Play();
-
- bool signalReceived(false);
- AnimationFinishCheck finishCheck(signalReceived);
- animation.FinishedSignal().Connect(&application, finishCheck);
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds * 1000.0f) + 1u /*beyond the animation duration*/);
-
- // We did expect the animation to finish
- application.SendNotification();
- finishCheck.CheckSignalReceived();
- END_TEST;
-}
-
-int UtcDaliAnimationAnimateByBooleanP(void)
+int UtcDaliAnimationClearIgnoreFinishedSignal(void)
{
TestApplication application;
Actor actor = Actor::New();
-
- // Register a boolean property
- bool startValue(false);
- Property::Index index = actor.RegisterProperty("testProperty", startValue);
application.GetScene().Add(actor);
- DALI_TEST_CHECK(actor.GetProperty<bool>(index) == startValue);
- DALI_TEST_CHECK(actor.GetCurrentProperty<bool>(index) == startValue);
// Build the animation
- float durationSeconds(2.0f);
- Animation animation = Animation::New(durationSeconds);
- const bool relativeValue(true);
- const bool finalValue(false || relativeValue);
- animation.AnimateBy(Property(actor, index), relativeValue);
+ 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();
- // Target value should be retrievable straight away
- DALI_TEST_EQUALS(actor.GetProperty<bool>(index), finalValue, TEST_LOCATION);
-
bool signalReceived(false);
AnimationFinishCheck finishCheck(signalReceived);
animation.FinishedSignal().Connect(&application, finishCheck);
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds * 950.0f) /* 95% progress */);
+ // Check finished signal not emmited if animation was cleared.
+ {
+ tet_printf("Check whether stop and clear case didnt send finished signal\n");
+ // Play the animation, and stop after animation finished naturally, and clear.
+ animation.Play();
- // We didn't expect the animation to finish yet
- application.SendNotification();
- finishCheck.CheckSignalNotReceived();
- DALI_TEST_CHECK(actor.GetCurrentProperty<bool>(index) == startValue);
+ application.SendNotification();
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds * 50.0f) + 1u /*just beyond the animation duration*/);
+ animation.Stop();
+ animation.Clear();
- // We did expect the animation to finish
- application.SendNotification();
- finishCheck.CheckSignalReceived();
- DALI_TEST_CHECK(actor.GetCurrentProperty<bool>(index) == finalValue);
+ application.SendNotification();
+ finishCheck.CheckSignalNotReceived();
+ finishCheck.Reset();
- // Check that nothing has changed after a couple of buffer swaps
- application.Render(0);
- DALI_TEST_CHECK(actor.GetCurrentProperty<bool>(index) == finalValue);
- application.Render(0);
- DALI_TEST_CHECK(actor.GetCurrentProperty<bool>(index) == finalValue);
+ // Finish animation naturally. (Note that dali don't call finished callback even if one render frame spend more than duration.)
+ application.Render(static_cast<uint32_t>(durationSeconds * 500.0f));
+ application.Render(static_cast<uint32_t>(durationSeconds * 500.0f) + 10u);
+ application.SendNotification();
- // Repeat with relative value "false" - this should be an NOOP
- animation = Animation::New(durationSeconds);
- bool noOpValue(false);
- animation.AnimateBy(Property(actor, index), noOpValue);
+ // expect finished signal not recieved.
+ finishCheck.CheckSignalNotReceived();
+ finishCheck.Reset();
- // Start the animation
- animation.Play();
+ application.SendNotification();
+ application.Render(0);
+ }
+ {
+ tet_printf("Check whether stop and clear and render-well case send finished signal\n");
+ // Play the animation, and stop after animation finished naturally, and clear, and play again.
+ animation.PlayAfter(durationSeconds);
- finishCheck.Reset();
- animation.FinishedSignal().Connect(&application, finishCheck);
+ application.SendNotification();
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds * 950.0f) /* 95% progress */);
+ // delay 50%.
+ application.Render(static_cast<uint32_t>(durationSeconds * 500.0f));
- // We didn't expect the animation to finish yet
- application.SendNotification();
- finishCheck.CheckSignalNotReceived();
- DALI_TEST_CHECK(actor.GetCurrentProperty<bool>(index) == finalValue);
+ animation.Stop();
+ animation.Clear();
+ animation.Play();
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds * 50.0f) + 1u /*just beyond the animation duration*/);
+ application.SendNotification();
+ finishCheck.CheckSignalNotReceived();
+ finishCheck.Reset();
- // We did expect the animation to finish
- application.SendNotification();
- finishCheck.CheckSignalReceived();
- DALI_TEST_CHECK(actor.GetCurrentProperty<bool>(index) == finalValue);
+ // Finish animation naturally. (Note that dali don't call finished callback even if one render frame spend more than duration.)
+ application.Render(static_cast<uint32_t>(durationSeconds * 500.0f));
+ application.Render(static_cast<uint32_t>(durationSeconds * 500.0f) + 10u);
+ application.SendNotification();
+
+ // expect finished signal recieved due to Animation finished.
+ application.SendNotification();
+ finishCheck.CheckSignalReceived();
+ finishCheck.Reset();
+
+ application.SendNotification();
+ application.Render(0);
+ }
- // Check that nothing has changed after a couple of buffer swaps
- application.Render(0);
- DALI_TEST_CHECK(actor.GetCurrentProperty<bool>(index) == finalValue);
- application.Render(0);
- DALI_TEST_CHECK(actor.GetCurrentProperty<bool>(index) == finalValue);
END_TEST;
}
-int UtcDaliAnimationAnimateByBooleanAlphaFunctionP(void)
+int UtcDaliAnimationEmptyAnimatorAndLoopCount(void)
{
+ // Clear and play the empty animation, and get the state values.
TestApplication application;
- Actor actor = Actor::New();
-
- // Register a boolean property
- bool startValue(false);
- Property::Index index = actor.RegisterProperty("testProperty", startValue);
- application.GetScene().Add(actor);
- DALI_TEST_CHECK(actor.GetProperty<bool>(index) == startValue);
- DALI_TEST_CHECK(actor.GetCurrentProperty<bool>(index) == startValue);
-
- // Build the animation
- float durationSeconds(2.0f);
+ float durationSeconds(1.0f);
Animation animation = Animation::New(durationSeconds);
- bool relativeValue(true);
- bool finalValue(false || relativeValue);
- animation.AnimateBy(Property(actor, index), relativeValue, AlphaFunction::EASE_IN);
+ animation.SetLoopCount(3);
+
+ bool signalReceived(false);
+ AnimationFinishCheck finishCheck(signalReceived);
+ animation.FinishedSignal().Connect(&application, finishCheck);
+
+ try
+ {
+ DALI_TEST_EQUALS(animation.GetState(), Dali::Animation::STOPPED, TEST_LOCATION);
+ DALI_TEST_EQUALS(animation.GetCurrentLoop(), 0, TEST_LOCATION);
+ application.SendNotification();
+ application.Render();
+
+ animation.Play();
+
+ DALI_TEST_EQUALS(animation.GetState(), Dali::Animation::PLAYING, TEST_LOCATION);
+ DALI_TEST_EQUALS(animation.GetCurrentLoop(), 0, TEST_LOCATION);
+ application.SendNotification();
+ application.Render(1500 /* 150% of loop. */);
+
+ DALI_TEST_EQUALS(animation.GetState(), Dali::Animation::PLAYING, TEST_LOCATION);
+ DALI_TEST_EQUALS(animation.GetCurrentLoop(), 1, TEST_LOCATION);
+
+ application.SendNotification();
+ application.Render(1400 /* 290% of loop. */);
+
+ DALI_TEST_EQUALS(animation.GetState(), Dali::Animation::PLAYING, TEST_LOCATION);
+ DALI_TEST_EQUALS(animation.GetCurrentLoop(), 2, TEST_LOCATION);
+
+ application.SendNotification();
+ application.Render(100 + 1100 /* 300% of loop. and extra 110%. */);
+ application.SendNotification(); // Notification trigger.
+
+ DALI_TEST_EQUALS(animation.GetState(), Dali::Animation::STOPPED, TEST_LOCATION);
+ DALI_TEST_EQUALS(animation.GetCurrentLoop(), 3, TEST_LOCATION);
+
+ tet_printf("Check wether empty animation also call finished signal.\n");
+ finishCheck.CheckSignalReceived();
+ finishCheck.Reset();
+
+ animation.Play();
+
+ DALI_TEST_EQUALS(animation.GetState(), Dali::Animation::PLAYING, TEST_LOCATION);
+ application.SendNotification();
+ application.Render(0 /* 0% of loop. */);
+
+ // LoopCount beome 0 again.
+ DALI_TEST_EQUALS(animation.GetCurrentLoop(), 0, TEST_LOCATION);
+
+ application.Render(1500 /* 150% of loop. */);
+
+ DALI_TEST_EQUALS(animation.GetState(), Dali::Animation::PLAYING, TEST_LOCATION);
+ DALI_TEST_EQUALS(animation.GetCurrentLoop(), 1, TEST_LOCATION);
+
+ animation.Pause();
+
+ application.SendNotification();
+ application.Render(2500 /* 150% of loop. (Since it is paused) */);
+
+ DALI_TEST_EQUALS(animation.GetState(), Dali::Animation::PAUSED, TEST_LOCATION);
+ DALI_TEST_EQUALS(animation.GetCurrentLoop(), 1, TEST_LOCATION);
+
+ animation.Play();
+
+ application.SendNotification();
+ application.Render(1000 /* 250% of loop. */);
+
+ DALI_TEST_EQUALS(animation.GetState(), Dali::Animation::PLAYING, TEST_LOCATION);
+ DALI_TEST_EQUALS(animation.GetCurrentLoop(), 2, TEST_LOCATION);
+
+ animation.Clear();
+
+ DALI_TEST_EQUALS(animation.GetState(), Dali::Animation::STOPPED, TEST_LOCATION);
+
+ application.SendNotification();
+ application.Render(500 + 100 /* 300% of loop + 10% over the loop. */);
+ application.SendNotification(); // Notification trigger.
+
+ DALI_TEST_EQUALS(animation.GetCurrentLoop(), 0, TEST_LOCATION);
+
+ tet_printf("Check animation completed signal not recieved even if animation finished normally at this loop.\n");
+ finishCheck.CheckSignalNotReceived();
+
+ application.SendNotification();
+ application.Render(1100);
+ application.Render(1100);
+ application.Render(1100 /* Over the loop count */);
+ application.SendNotification(); // Notification trigger.
+
+ tet_printf("Check animation completed signal not recieved even if animation finished normally.\n");
+ finishCheck.CheckSignalNotReceived();
+
+ animation.Play();
+
+ application.SendNotification();
+ application.Render(1500 /* 150% of loop. */);
+
+ DALI_TEST_EQUALS(animation.GetState(), Dali::Animation::PLAYING, TEST_LOCATION);
+ DALI_TEST_EQUALS(animation.GetCurrentLoop(), 1, TEST_LOCATION);
+
+ animation.Stop();
+ animation.Clear();
+
+ DALI_TEST_EQUALS(animation.GetState(), Dali::Animation::STOPPED, TEST_LOCATION);
+
+ application.SendNotification();
+ application.Render();
+ application.SendNotification(); // Notification trigger.
+
+ DALI_TEST_EQUALS(animation.GetCurrentLoop(), 0, TEST_LOCATION);
+
+ tet_printf("Check animation completed signal not recieved even if we call Stop forcibly.\n");
+ finishCheck.CheckSignalNotReceived();
+
+ animation.Clear();
+
+ DALI_TEST_EQUALS(animation.GetState(), Dali::Animation::STOPPED, TEST_LOCATION);
+
+ animation.Play();
+
+ DALI_TEST_EQUALS(animation.GetState(), Dali::Animation::PLAYING, TEST_LOCATION);
+ DALI_TEST_EQUALS(animation.GetCurrentLoop(), 0, TEST_LOCATION);
+
+ application.SendNotification();
+ application.Render(1100);
+ application.Render(1100);
+ application.Render(1100 /* Over the loop count */);
+ application.SendNotification(); // Notification trigger.
+
+ DALI_TEST_EQUALS(animation.GetState(), Dali::Animation::STOPPED, TEST_LOCATION);
+ DALI_TEST_EQUALS(animation.GetCurrentLoop(), 3, TEST_LOCATION);
+
+ tet_printf("Check animation completed signal recieved. (Since clear didn't disconnect complete signal)\n");
+ finishCheck.CheckSignalReceived();
+ finishCheck.Reset();
+ }
+ catch(...)
+ {
+ DALI_TEST_CHECK(false); // Should not get here
+ }
+
+ END_TEST;
+}
+
+int UtcDaliAnimationFinishedSignalP(void)
+{
+ TestApplication application;
+
+ // Start the empty animation
+ float durationSeconds(1.0f);
+ Animation animation = Animation::New(durationSeconds);
+ animation.Play();
+
+ bool signalReceived(false);
+ AnimationFinishCheck finishCheck(signalReceived);
+ animation.FinishedSignal().Connect(&application, finishCheck);
+
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(durationSeconds * 1000.0f) + 1u /*beyond the animation duration*/);
+
+ // We did expect the animation to finish
+ application.SendNotification();
+ finishCheck.CheckSignalReceived();
+ END_TEST;
+}
+
+int UtcDaliAnimationAnimateByBooleanP(void)
+{
+ TestApplication application;
+
+ Actor actor = Actor::New();
+
+ // Register a boolean property
+ bool startValue(false);
+ Property::Index index = actor.RegisterProperty("testProperty", startValue);
+ application.GetScene().Add(actor);
+ DALI_TEST_CHECK(actor.GetProperty<bool>(index) == startValue);
+ DALI_TEST_CHECK(actor.GetCurrentProperty<bool>(index) == startValue);
+
+ // Build the animation
+ float durationSeconds(2.0f);
+ Animation animation = Animation::New(durationSeconds);
+ const bool relativeValue(true);
+ const bool finalValue(false || relativeValue);
+ animation.AnimateBy(Property(actor, index), relativeValue);
+
+ // Start the animation
+ animation.Play();
+
+ // Target value should be retrievable straight away
+ DALI_TEST_EQUALS(actor.GetProperty<bool>(index), finalValue, TEST_LOCATION);
+
+ bool signalReceived(false);
+ AnimationFinishCheck finishCheck(signalReceived);
+ animation.FinishedSignal().Connect(&application, finishCheck);
+
+ 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.GetCurrentProperty<bool>(index) == startValue);
+
+ 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.GetCurrentProperty<bool>(index) == finalValue);
+
+ // Check that nothing has changed after a couple of buffer swaps
+ application.Render(0);
+ DALI_TEST_CHECK(actor.GetCurrentProperty<bool>(index) == finalValue);
+ application.Render(0);
+ DALI_TEST_CHECK(actor.GetCurrentProperty<bool>(index) == finalValue);
+
+ // Repeat with relative value "false" - this should be an NOOP
+ animation = Animation::New(durationSeconds);
+ bool noOpValue(false);
+ animation.AnimateBy(Property(actor, index), noOpValue);
+
+ // Start the animation
+ animation.Play();
+
+ 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.GetCurrentProperty<bool>(index) == finalValue);
+
+ 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.GetCurrentProperty<bool>(index) == finalValue);
+
+ // Check that nothing has changed after a couple of buffer swaps
+ application.Render(0);
+ DALI_TEST_CHECK(actor.GetCurrentProperty<bool>(index) == finalValue);
+ application.Render(0);
+ DALI_TEST_CHECK(actor.GetCurrentProperty<bool>(index) == finalValue);
+ END_TEST;
+}
+
+int UtcDaliAnimationAnimateByBooleanAlphaFunctionP(void)
+{
+ TestApplication application;
+
+ Actor actor = Actor::New();
+
+ // Register a boolean property
+ bool startValue(false);
+ Property::Index index = actor.RegisterProperty("testProperty", startValue);
+ application.GetScene().Add(actor);
+ DALI_TEST_CHECK(actor.GetProperty<bool>(index) == startValue);
+ DALI_TEST_CHECK(actor.GetCurrentProperty<bool>(index) == startValue);
+
+ // Build the animation
+ float durationSeconds(2.0f);
+ Animation animation = Animation::New(durationSeconds);
+ bool relativeValue(true);
+ bool finalValue(false || relativeValue);
+ animation.AnimateBy(Property(actor, index), relativeValue, AlphaFunction::EASE_IN);
// Start the animation
animation.Play();
TestApplication application;
KeyFrames keyFrames = KeyFrames::New();
+
+ DALI_TEST_EQUALS(DevelKeyFrames::GetKeyFrameCount(keyFrames), 0, TEST_LOCATION);
+
keyFrames.Add(0.0f, Vector4(0.0f, 0.0f, 0.0f, 0.6f));
keyFrames.Add(0.6f, Vector4(0.0f, 0.0f, 0.0f, 0.3f));
keyFrames.Add(1.0f, Vector4(0.0f, 0.0f, 0.0f, 0.8f));
float inputTime = 0.6f;
Vector4 inputValue = Vector4(0.0f, 0.0f, 0.0f, 0.3f);
- KeyFrames keyFrames = KeyFrames::New();
+ float outputTime;
+ Property::Value outputValue;
+ KeyFrames keyFrames = KeyFrames::New();
+
+ DevelKeyFrames::GetKeyFrame(keyFrames, 0, outputTime, outputValue);
+
+ DALI_TEST_EQUALS(outputValue.GetType(), Property::Type::NONE, TEST_LOCATION);
+
keyFrames.Add(0.0f, Vector4(0.0f, 0.0f, 0.0f, 0.6f));
keyFrames.Add(inputTime, inputValue);
keyFrames.Add(1.0f, Vector4(0.0f, 0.0f, 0.0f, 0.8f));
- float outputTime;
- Property::Value outputValue;
-
DevelKeyFrames::GetKeyFrame(keyFrames, 3, outputTime, outputValue);
DALI_TEST_EQUALS(outputValue.GetType(), Property::Type::NONE, TEST_LOCATION);
END_TEST;
}
-int UtcDaliAnimationAnimateBetweenActorColorAlphaP(void)
+int UtcDaliAnimationKeyFramesSetKeyFrameP(void)
{
TestApplication application;
- float startValue(1.0f);
- Actor actor = Actor::New();
- actor.SetProperty(Actor::Property::COLOR, Vector4(startValue, startValue, startValue, startValue));
- application.GetScene().Add(actor);
-
- DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR).a, startValue, TEST_LOCATION);
- DALI_TEST_EQUALS(actor.GetProperty<float>(Actor::Property::COLOR_RED), startValue, TEST_LOCATION);
- DALI_TEST_EQUALS(actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION);
- DALI_TEST_EQUALS(actor.GetProperty<float>(Actor::Property::COLOR_BLUE), startValue, TEST_LOCATION);
- DALI_TEST_EQUALS(actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION);
- DALI_TEST_EQUALS(actor.GetCurrentProperty<float>(Actor::Property::COLOR_RED), startValue, TEST_LOCATION);
- DALI_TEST_EQUALS(actor.GetCurrentProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION);
- DALI_TEST_EQUALS(actor.GetCurrentProperty<float>(Actor::Property::COLOR_BLUE), startValue, TEST_LOCATION);
- DALI_TEST_EQUALS(actor.GetCurrentProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION);
-
- // Build the animation
- float durationSeconds(1.0f);
- Animation animation = Animation::New(durationSeconds);
+ float inputTime = 0.6f;
+ Vector4 inputValue = Vector4(0.0f, 0.0f, 0.0f, 0.3f);
KeyFrames keyFrames = KeyFrames::New();
- keyFrames.Add(0.0f, 0.1f);
- keyFrames.Add(0.2f, 0.5f);
- keyFrames.Add(0.4f, 0.0f);
- keyFrames.Add(0.6f, 1.0f);
- keyFrames.Add(0.8f, 0.7f);
- keyFrames.Add(1.0f, 0.9f);
-
- animation.AnimateBetween(Property(actor, Actor::Property::COLOR_ALPHA), keyFrames);
+ keyFrames.Add(0.0f, Vector4(0.0f, 0.0f, 0.0f, 0.6f));
+ keyFrames.Add(inputTime, inputValue);
+ keyFrames.Add(1.0f, Vector4(0.0f, 0.0f, 0.0f, 0.8f));
+
+ float outputTime;
+ Property::Value outputValue;
+
+ DevelKeyFrames::GetKeyFrame(keyFrames, 3, outputTime, outputValue);
+
+ DALI_TEST_EQUALS(outputValue.GetType(), Property::Type::NONE, TEST_LOCATION);
+
+ DevelKeyFrames::GetKeyFrame(keyFrames, 1, outputTime, outputValue);
+
+ DALI_TEST_EQUALS(outputTime, inputTime, TEST_LOCATION);
+ DALI_TEST_EQUALS(outputValue.GetType(), Property::Type::VECTOR4, TEST_LOCATION);
+ DALI_TEST_EQUALS(outputValue.Get<Vector4>(), inputValue, TEST_LOCATION);
+
+ Vector4 newValue = Vector4(1.0f, 0.2f, 0.6f, 0.9f);
+
+ DevelKeyFrames::SetKeyFrameValue(keyFrames, 1, newValue);
+
+ DevelKeyFrames::GetKeyFrame(keyFrames, 1, outputTime, outputValue);
+
+ DALI_TEST_EQUALS(outputTime, inputTime, TEST_LOCATION);
+ DALI_TEST_EQUALS(outputValue.GetType(), Property::Type::VECTOR4, TEST_LOCATION);
+ DALI_TEST_EQUALS(outputValue.Get<Vector4>(), newValue, TEST_LOCATION);
+
+ Vector3 newUnmatchedValue = Vector3(0.0f, 1.0f, 0.2f);
+
+ // Check nothing happened if we set unmatched value type.
+ DevelKeyFrames::SetKeyFrameValue(keyFrames, 1, newUnmatchedValue);
+
+ DevelKeyFrames::GetKeyFrame(keyFrames, 1, outputTime, outputValue);
+
+ DALI_TEST_EQUALS(outputTime, inputTime, TEST_LOCATION);
+ DALI_TEST_EQUALS(outputValue.GetType(), Property::Type::VECTOR4, TEST_LOCATION);
+ DALI_TEST_EQUALS(outputValue.Get<Vector4>(), newValue, TEST_LOCATION);
+
+ END_TEST;
+}
+
+int UtcDaliAnimationKeyFramesOptimizeKeyFramesLinearP(void)
+{
+ TestApplication application;
+
+ KeyFrames keyFrames = KeyFrames::New();
+
+ float firstExpectTime = 0.0f;
+ float firstExpectValue = 0.0f;
+ float secondExpectTime = 0.4f;
+ float secondExpectValue = 1.2f;
+ float thirdExpectTime = 0.8f;
+ float thirdExpectValue = 0.4f;
+ float fourthExpectTime = 1.0f;
+ float fourthExpectValue = 0.7f;
+
+ float interpolateLate = 0.5f;
+
+ tet_printf("first - second phase test\n");
+
+ DALI_TEST_EQUALS(false, DevelKeyFrames::OptimizeKeyFramesLinear(keyFrames), TEST_LOCATION);
+ DALI_TEST_EQUALS(DevelKeyFrames::GetKeyFrameCount(keyFrames), 0, TEST_LOCATION);
+
+ keyFrames.Add(firstExpectTime, firstExpectValue);
+ DALI_TEST_EQUALS(false, DevelKeyFrames::OptimizeKeyFramesLinear(keyFrames), TEST_LOCATION);
+ DALI_TEST_EQUALS(DevelKeyFrames::GetKeyFrameCount(keyFrames), 1, TEST_LOCATION);
+
+ keyFrames.Add(firstExpectTime * (1.0f - interpolateLate) + secondExpectTime * interpolateLate, firstExpectValue * (1.0f - interpolateLate) + secondExpectValue * interpolateLate);
+ DALI_TEST_EQUALS(false, DevelKeyFrames::OptimizeKeyFramesLinear(keyFrames), TEST_LOCATION);
+ DALI_TEST_EQUALS(DevelKeyFrames::GetKeyFrameCount(keyFrames), 2, TEST_LOCATION);
+
+ keyFrames.Add(secondExpectTime, secondExpectValue);
+
+ DALI_TEST_EQUALS(DevelKeyFrames::GetKeyFrameCount(keyFrames), 3, TEST_LOCATION);
+ DALI_TEST_EQUALS(true, DevelKeyFrames::OptimizeKeyFramesLinear(keyFrames), TEST_LOCATION);
+ DALI_TEST_EQUALS(DevelKeyFrames::GetKeyFrameCount(keyFrames), 2, TEST_LOCATION);
+
+ float outputTime;
+ Property::Value outputValue;
+
+ DevelKeyFrames::GetKeyFrame(keyFrames, 0, outputTime, outputValue);
+
+ DALI_TEST_EQUALS(outputTime, firstExpectTime, TEST_LOCATION);
+ DALI_TEST_EQUALS(outputValue.GetType(), Property::Type::FLOAT, TEST_LOCATION);
+ DALI_TEST_EQUALS(outputValue.Get<float>(), firstExpectValue, TEST_LOCATION);
+
+ DevelKeyFrames::GetKeyFrame(keyFrames, 1, outputTime, outputValue);
+
+ DALI_TEST_EQUALS(outputTime, secondExpectTime, TEST_LOCATION);
+ DALI_TEST_EQUALS(outputValue.GetType(), Property::Type::FLOAT, TEST_LOCATION);
+ DALI_TEST_EQUALS(outputValue.Get<float>(), secondExpectValue, TEST_LOCATION);
+
+ tet_printf("second - third phase test\n");
+
+ interpolateLate = 0.3f;
+ keyFrames.Add(secondExpectTime * (1.0f - interpolateLate) + thirdExpectTime * interpolateLate, secondExpectValue * (1.0f - interpolateLate) + thirdExpectValue * interpolateLate);
+ DALI_TEST_EQUALS(DevelKeyFrames::GetKeyFrameCount(keyFrames), 3, TEST_LOCATION);
+
+ interpolateLate = 0.4f;
+ keyFrames.Add(secondExpectTime * (1.0f - interpolateLate) + thirdExpectTime * interpolateLate, secondExpectValue * (1.0f - interpolateLate) + thirdExpectValue * interpolateLate);
+ DALI_TEST_EQUALS(DevelKeyFrames::GetKeyFrameCount(keyFrames), 4, TEST_LOCATION);
+
+ interpolateLate = 0.5f;
+ keyFrames.Add(secondExpectTime * (1.0f - interpolateLate) + thirdExpectTime * interpolateLate, secondExpectValue * (1.0f - interpolateLate) + thirdExpectValue * interpolateLate);
+ DALI_TEST_EQUALS(DevelKeyFrames::GetKeyFrameCount(keyFrames), 5, TEST_LOCATION);
+
+ interpolateLate = 0.8f;
+ keyFrames.Add(secondExpectTime * (1.0f - interpolateLate) + thirdExpectTime * interpolateLate, secondExpectValue * (1.0f - interpolateLate) + thirdExpectValue * interpolateLate);
+ DALI_TEST_EQUALS(DevelKeyFrames::GetKeyFrameCount(keyFrames), 6, TEST_LOCATION);
+
+ keyFrames.Add(thirdExpectTime, thirdExpectValue);
+ DALI_TEST_EQUALS(DevelKeyFrames::GetKeyFrameCount(keyFrames), 7, TEST_LOCATION);
+
+ DALI_TEST_EQUALS(true, DevelKeyFrames::OptimizeKeyFramesLinear(keyFrames), TEST_LOCATION);
+ DALI_TEST_EQUALS(DevelKeyFrames::GetKeyFrameCount(keyFrames), 3, TEST_LOCATION);
+
+ DevelKeyFrames::GetKeyFrame(keyFrames, 0, outputTime, outputValue);
+
+ DALI_TEST_EQUALS(outputTime, firstExpectTime, TEST_LOCATION);
+ DALI_TEST_EQUALS(outputValue.GetType(), Property::Type::FLOAT, TEST_LOCATION);
+ DALI_TEST_EQUALS(outputValue.Get<float>(), firstExpectValue, TEST_LOCATION);
+
+ DevelKeyFrames::GetKeyFrame(keyFrames, 1, outputTime, outputValue);
+
+ DALI_TEST_EQUALS(outputTime, secondExpectTime, TEST_LOCATION);
+ DALI_TEST_EQUALS(outputValue.GetType(), Property::Type::FLOAT, TEST_LOCATION);
+ DALI_TEST_EQUALS(outputValue.Get<float>(), secondExpectValue, TEST_LOCATION);
+
+ DevelKeyFrames::GetKeyFrame(keyFrames, 2, outputTime, outputValue);
+
+ DALI_TEST_EQUALS(outputTime, thirdExpectTime, TEST_LOCATION);
+ DALI_TEST_EQUALS(outputValue.GetType(), Property::Type::FLOAT, TEST_LOCATION);
+ DALI_TEST_EQUALS(outputValue.Get<float>(), thirdExpectValue, TEST_LOCATION);
+
+ tet_printf("third - fourth phase test. Test what we skip same progress.\n");
+
+ interpolateLate = 0.3f;
+ keyFrames.Add(thirdExpectTime * (1.0f - interpolateLate) + fourthExpectTime * interpolateLate, thirdExpectValue * (1.0f - interpolateLate) + fourthExpectValue * interpolateLate);
+ DALI_TEST_EQUALS(DevelKeyFrames::GetKeyFrameCount(keyFrames), 4, TEST_LOCATION);
+
+ interpolateLate = 0.5f;
+ keyFrames.Add(thirdExpectTime * (1.0f - interpolateLate) + fourthExpectTime * interpolateLate, thirdExpectValue * (1.0f - interpolateLate) + fourthExpectValue * interpolateLate);
+ DALI_TEST_EQUALS(DevelKeyFrames::GetKeyFrameCount(keyFrames), 5, TEST_LOCATION);
+
+ interpolateLate = 0.8f;
+ keyFrames.Add(thirdExpectTime * (1.0f - interpolateLate) + fourthExpectTime * interpolateLate, thirdExpectValue * (1.0f - interpolateLate) + fourthExpectValue * interpolateLate);
+ DALI_TEST_EQUALS(DevelKeyFrames::GetKeyFrameCount(keyFrames), 6, TEST_LOCATION);
+
+ keyFrames.Add(fourthExpectTime, fourthExpectValue);
+ DALI_TEST_EQUALS(DevelKeyFrames::GetKeyFrameCount(keyFrames), 7, TEST_LOCATION);
+
+ DALI_TEST_EQUALS(true, DevelKeyFrames::OptimizeKeyFramesLinear(keyFrames), TEST_LOCATION);
+ DALI_TEST_EQUALS(DevelKeyFrames::GetKeyFrameCount(keyFrames), 4, TEST_LOCATION);
+
+ DevelKeyFrames::GetKeyFrame(keyFrames, 0, outputTime, outputValue);
+
+ DALI_TEST_EQUALS(outputTime, firstExpectTime, TEST_LOCATION);
+ DALI_TEST_EQUALS(outputValue.GetType(), Property::Type::FLOAT, TEST_LOCATION);
+ DALI_TEST_EQUALS(outputValue.Get<float>(), firstExpectValue, TEST_LOCATION);
+
+ DevelKeyFrames::GetKeyFrame(keyFrames, 1, outputTime, outputValue);
+
+ DALI_TEST_EQUALS(outputTime, secondExpectTime, TEST_LOCATION);
+ DALI_TEST_EQUALS(outputValue.GetType(), Property::Type::FLOAT, TEST_LOCATION);
+ DALI_TEST_EQUALS(outputValue.Get<float>(), secondExpectValue, TEST_LOCATION);
+
+ DevelKeyFrames::GetKeyFrame(keyFrames, 2, outputTime, outputValue);
+
+ DALI_TEST_EQUALS(outputTime, thirdExpectTime, TEST_LOCATION);
+ DALI_TEST_EQUALS(outputValue.GetType(), Property::Type::FLOAT, TEST_LOCATION);
+ DALI_TEST_EQUALS(outputValue.Get<float>(), thirdExpectValue, TEST_LOCATION);
+
+ DevelKeyFrames::GetKeyFrame(keyFrames, 3, outputTime, outputValue);
+
+ DALI_TEST_EQUALS(outputTime, fourthExpectTime, TEST_LOCATION);
+ DALI_TEST_EQUALS(outputValue.GetType(), Property::Type::FLOAT, TEST_LOCATION);
+ DALI_TEST_EQUALS(outputValue.Get<float>(), fourthExpectValue, TEST_LOCATION);
+
+ END_TEST;
+}
+
+int UtcDaliAnimationAnimateBetweenActorColorAlphaP(void)
+{
+ TestApplication application;
+
+ float startValue(1.0f);
+ Actor actor = Actor::New();
+ actor.SetProperty(Actor::Property::COLOR, Vector4(startValue, startValue, startValue, startValue));
+ application.GetScene().Add(actor);
+
+ DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR).a, startValue, TEST_LOCATION);
+ DALI_TEST_EQUALS(actor.GetProperty<float>(Actor::Property::COLOR_RED), startValue, TEST_LOCATION);
+ DALI_TEST_EQUALS(actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION);
+ DALI_TEST_EQUALS(actor.GetProperty<float>(Actor::Property::COLOR_BLUE), startValue, TEST_LOCATION);
+ DALI_TEST_EQUALS(actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION);
+ DALI_TEST_EQUALS(actor.GetCurrentProperty<float>(Actor::Property::COLOR_RED), startValue, TEST_LOCATION);
+ DALI_TEST_EQUALS(actor.GetCurrentProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION);
+ DALI_TEST_EQUALS(actor.GetCurrentProperty<float>(Actor::Property::COLOR_BLUE), startValue, TEST_LOCATION);
+ DALI_TEST_EQUALS(actor.GetCurrentProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION);
+
+ // Build the animation
+ float durationSeconds(1.0f);
+ Animation animation = Animation::New(durationSeconds);
+
+ KeyFrames keyFrames = KeyFrames::New();
+ keyFrames.Add(0.0f, 0.1f);
+ keyFrames.Add(0.2f, 0.5f);
+ keyFrames.Add(0.4f, 0.0f);
+ keyFrames.Add(0.6f, 1.0f);
+ keyFrames.Add(0.8f, 0.7f);
+ keyFrames.Add(1.0f, 0.9f);
+
+ animation.AnimateBetween(Property(actor, Actor::Property::COLOR_ALPHA), keyFrames);
// Start the animation
animation.Play();
application.SendNotification();
tet_infoline("Ensure after animation has started playing that ProgressReachedSignal not emitted");
+ finishCheck.CheckSignalNotReceived();
progressCheck.CheckSignalNotReceived();
application.Render(static_cast<unsigned int>(durationSeconds * 900.0f) + 1u /*just beyond the animation duration*/);
for(int count = 0; count < loopCount; count++)
{
application.SendNotification();
- application.Render(0); // start animation
+ application.Render(0); // start animation
+ finishCheck.CheckSignalNotReceived();
+
application.Render(durationSeconds * 0.25 * 1000.0f); // 25% progress
DALI_TEST_EQUALS(0.25f, animation.GetCurrentProgress(), TEST_LOCATION);
animation.SetLooping(false);
animation.SetLoopCount(4);
animation.Play();
- application.Render(0u);
- application.SendNotification();
+ application.SendNotification(); // Send Stop event into update thread
+ application.Render(0u); // Send Notification into event thread
+ application.SendNotification(); // Execute finished signal.
+
+ finishCheck.CheckSignalReceived(); // Due to stop called.
+ finishCheck.Reset();
for(int count = 0; count < 4; count++)
{
application.SendNotification();
application.Render(0); // start animation
progressCheck.CheckSignalNotReceived();
+ finishCheck.CheckSignalNotReceived();
application.SendNotification();
application.Render(durationSeconds * 0.25 * 1000.0f); // 25% progress
DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::POSITION).Get<Vector3>(), expectedValueTable[i].expectedGetPropertyValue, VECTOR3_EPSILON, TEST_LOCATION);
DALI_TEST_EQUALS(actor.GetCurrentProperty(Actor::Property::POSITION).Get<Vector3>(), expectedValueTable[i].expectedGetPropertyValue, VECTOR3_EPSILON, TEST_LOCATION);
+
+ // If we call Clear before, The animation didn't give any effort to actor now. Let we check it
+ if(functionToTest == TestFunction::CLEAR)
+ {
+ actor.SetProperty(Actor::Property::POSITION, originalPosition);
+
+ DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::POSITION).Get<Vector3>(), originalPosition, VECTOR3_EPSILON, TEST_LOCATION);
+ DALI_TEST_EQUALS(actor.GetCurrentProperty(Actor::Property::POSITION).Get<Vector3>(), expectedValueTable[i].expectedGetPropertyValue, VECTOR3_EPSILON, TEST_LOCATION);
+
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::POSITION).Get<Vector3>(), originalPosition, VECTOR3_EPSILON, TEST_LOCATION);
+ DALI_TEST_EQUALS(actor.GetCurrentProperty(Actor::Property::POSITION).Get<Vector3>(), originalPosition, VECTOR3_EPSILON, TEST_LOCATION);
+
+ // Start the animation, which we already clear.
+ animation.Play();
+
+ DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::POSITION).Get<Vector3>(), originalPosition, VECTOR3_EPSILON, TEST_LOCATION);
+ DALI_TEST_EQUALS(actor.GetCurrentProperty(Actor::Property::POSITION).Get<Vector3>(), originalPosition, VECTOR3_EPSILON, TEST_LOCATION);
+
+ application.SendNotification();
+ application.Render(halfAnimationDuration);
+
+ DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::POSITION).Get<Vector3>(), originalPosition, VECTOR3_EPSILON, TEST_LOCATION);
+ DALI_TEST_EQUALS(actor.GetCurrentProperty(Actor::Property::POSITION).Get<Vector3>(), originalPosition, VECTOR3_EPSILON, TEST_LOCATION);
+ }
}
}
} // unnamed namespace
}
END_TEST;
}
+
+int UtcDaliAnimationSetGetBlendPoint(void)
+{
+ TestApplication application;
+
+ Animation animation = Animation::New(1.0f);
+ DALI_TEST_EQUALS(animation.GetBlendPoint(), 0.0f, 0.01f, TEST_LOCATION);
+
+ animation.SetBlendPoint(0.5f);
+
+ DALI_TEST_EQUALS(animation.GetBlendPoint(), 0.5f, 0.01f, TEST_LOCATION);
+
+ animation.SetBlendPoint(-0.5f);
+
+ DALI_TEST_EQUALS(animation.GetBlendPoint(), 0.5f, 0.01f, TEST_LOCATION);
+
+ animation.SetBlendPoint(1.5f);
+
+ DALI_TEST_EQUALS(animation.GetBlendPoint(), 0.5f, 0.01f, TEST_LOCATION);
+
+ animation.SetBlendPoint(0.7f);
+
+ DALI_TEST_EQUALS(animation.GetBlendPoint(), 0.7f, 0.01f, TEST_LOCATION);
+
+ END_TEST;
+}
+
+int UtcDaliAnimationPlayBlendFloatCubic(void)
+{
+ TestApplication application;
+
+ Actor actor = Actor::New();
+ application.GetScene().Add(actor);
+ Property::Index index = actor.RegisterProperty("property", 0.0f);
+
+ Animation animation = Animation::New(1.0f);
+ KeyFrames keyframes = KeyFrames::New();
+ keyframes.Add(0.0f, 3.0f);
+ keyframes.Add(0.4f, 1.0f);
+ keyframes.Add(0.6f, 1.0f);
+ keyframes.Add(1.0f, 3.0f);
+ animation.AnimateBetween(Property(actor, index), keyframes, AlphaFunction::LINEAR, Animation::Interpolation::CUBIC);
+
+ application.SendNotification();
+ application.Render(20);
+
+ animation.SetBlendPoint(0.5f);
+ animation.Play();
+
+ application.SendNotification();
+ application.Render(250);
+
+ float value = actor.GetCurrentProperty<float>(index);
+ DALI_TEST_EQUALS(value, 0.989258f, 0.05f, TEST_LOCATION); // original value : 1.603516 (Same value as when progress is 0.75.)
+ // current value : 0.0f
+ // value when progress is 0.5 : 0.75
+
+ application.SendNotification();
+ application.Render(250);
+
+ value = actor.GetCurrentProperty<float>(index);
+ DALI_TEST_EQUALS(value, 0.750000f, 0.05f, TEST_LOCATION); // value is less than 1.0f
+
+ application.SendNotification();
+ application.Render(250);
+
+ value = actor.GetCurrentProperty<float>(index);
+ DALI_TEST_EQUALS(value, 1.603516f, 0.05f, TEST_LOCATION);
+
+ application.SendNotification();
+ application.Render(250);
+
+ value = actor.GetCurrentProperty<float>(index);
+ DALI_TEST_EQUALS(value, 3.0f, 0.05f, TEST_LOCATION);
+
+ END_TEST;
+}
+
+int UtcDaliAnimationPlayBlendFloat1(void)
+{
+ TestApplication application;
+
+ Actor actor = Actor::New();
+ application.GetScene().Add(actor);
+ Property::Index index = actor.RegisterProperty("property", 0.0f);
+
+ Animation animation = Animation::New(1.0f);
+ KeyFrames keyframes = KeyFrames::New();
+ keyframes.Add(0.0f, 1.0f);
+ keyframes.Add(0.2f, 2.0f);
+ keyframes.Add(0.4f, 3.0f);
+ keyframes.Add(0.6f, 4.0f);
+ keyframes.Add(0.8f, 5.0f);
+ keyframes.Add(1.0f, 6.0f);
+ animation.AnimateBetween(Property(actor, index), keyframes, AlphaFunction::LINEAR);
+
+ application.SendNotification();
+ application.Render(20);
+
+ animation.SetBlendPoint(0.9f);
+ animation.Play();
+
+ application.SendNotification();
+ application.Render(250);
+
+ float value = actor.GetCurrentProperty<float>(index);
+ DALI_TEST_EQUALS(value, 1.728395f, 0.05f, TEST_LOCATION);
+
+ application.SendNotification();
+ application.Render(250);
+
+ value = actor.GetCurrentProperty<float>(index);
+ DALI_TEST_EQUALS(value, 3.302469f, 0.05f, TEST_LOCATION);
+
+ application.SendNotification();
+ application.Render(250);
+
+ value = actor.GetCurrentProperty<float>(index);
+ DALI_TEST_EQUALS(value, 4.722222f, 0.05f, TEST_LOCATION);
+
+ application.SendNotification();
+ application.Render(250);
+
+ value = actor.GetCurrentProperty<float>(index);
+ DALI_TEST_EQUALS(value, 6.0f, 0.05f, TEST_LOCATION);
+
+ END_TEST;
+}
+
+int UtcDaliAnimationPlayBlendFloat2(void)
+{
+ TestApplication application;
+
+ Actor actor = Actor::New();
+ application.GetScene().Add(actor);
+ Property::Index index = actor.RegisterProperty("property", 0.0f);
+
+ Animation animation = Animation::New(1.0f);
+ KeyFrames keyframes = KeyFrames::New();
+ keyframes.Add(0.0f, 0.0f);
+ keyframes.Add(1.0f, 1.0f);
+ animation.AnimateBetween(Property(actor, index), keyframes, AlphaFunction::LINEAR);
+
+ application.SendNotification();
+ application.Render(20);
+
+ animation.SetBlendPoint(0.5f);
+ animation.Play();
+
+ application.SendNotification();
+ application.Render(250);
+
+ float value = actor.GetCurrentProperty<float>(index);
+ DALI_TEST_EQUALS(value, 0.25f, 0.05f, TEST_LOCATION);
+
+ application.SendNotification();
+ application.Render(250);
+
+ value = actor.GetCurrentProperty<float>(index);
+ DALI_TEST_EQUALS(value, 0.5f, 0.05f, TEST_LOCATION);
+
+ END_TEST;
+}
+
+int UtcDaliAnimationPlayBlendFloat3(void)
+{
+ TestApplication application;
+
+ Actor actor = Actor::New();
+ application.GetScene().Add(actor);
+ Property::Index index = actor.RegisterProperty("property", 0.0f);
+
+ Animation animation = Animation::New(1.0f);
+ KeyFrames keyframes = KeyFrames::New();
+ keyframes.Add(0.0f, 1.0f);
+ keyframes.Add(1.0f, 2.0f);
+ animation.AnimateBetween(Property(actor, index), keyframes, AlphaFunction::LINEAR);
+
+ application.SendNotification();
+ application.Render(20);
+
+ animation.SetBlendPoint(0.5f);
+ animation.Play();
+
+ application.SendNotification();
+ application.Render(250);
+
+ float value = actor.GetCurrentProperty<float>(index);
+ DALI_TEST_EQUALS(value, 1.0f, 0.05f, TEST_LOCATION);
+
+ application.SendNotification();
+ application.Render(250);
+
+ value = actor.GetCurrentProperty<float>(index);
+ DALI_TEST_EQUALS(value, 1.5f, 0.05f, TEST_LOCATION);
+
+ END_TEST;
+}
+
+int UtcDaliAnimationPlayBlendFloat4(void)
+{
+ TestApplication application;
+
+ Actor actor = Actor::New();
+ application.GetScene().Add(actor);
+ Property::Index index = actor.RegisterProperty("property", 0.0f);
+
+ Animation animation = Animation::New(1.0f);
+ KeyFrames keyframes = KeyFrames::New();
+ keyframes.Add(0.0f, 1.0f);
+ keyframes.Add(1.0f, 2.0f);
+ animation.AnimateBetween(Property(actor, index), keyframes, AlphaFunction::LINEAR);
+
+ application.SendNotification();
+ application.Render(20);
+
+ animation.SetBlendPoint(0.5f);
+ animation.Play();
+
+ application.SendNotification();
+ application.Render(250);
+
+ float value = actor.GetCurrentProperty<float>(index);
+ DALI_TEST_EQUALS(value, 1.0f, 0.05f, TEST_LOCATION);
+
+ application.SendNotification();
+ application.Render(250);
+
+ value = actor.GetCurrentProperty<float>(index);
+ DALI_TEST_EQUALS(value, 1.5f, 0.05f, TEST_LOCATION);
+
+ application.SendNotification();
+ application.Render(550);
+
+ actor.SetProperty(index, 0.0f);
+ animation.Play();
+
+ application.SendNotification();
+ application.Render(250);
+
+ value = actor.GetCurrentProperty<float>(index);
+ DALI_TEST_EQUALS(value, 1.0f, 0.05f, TEST_LOCATION);
+
+ application.SendNotification();
+ application.Render(250);
+
+ value = actor.GetCurrentProperty<float>(index);
+ DALI_TEST_EQUALS(value, 1.5f, 0.05f, TEST_LOCATION);
+
+ END_TEST;
+}
+
+int UtcDaliAnimationPlayBlendInt(void)
+{
+ TestApplication application;
+
+ Actor actor = Actor::New();
+ application.GetScene().Add(actor);
+ Property::Index index = actor.RegisterProperty("property", 0);
+
+ Animation animation = Animation::New(1.0f);
+ KeyFrames keyframes = KeyFrames::New();
+ keyframes.Add(0.0f, 100);
+ keyframes.Add(1.0f, 200);
+ animation.AnimateBetween(Property(actor, index), keyframes, AlphaFunction::LINEAR);
+
+ application.SendNotification();
+ application.Render(20);
+
+ animation.SetBlendPoint(0.5f);
+ animation.Play();
+
+ application.SendNotification();
+ application.Render(250);
+
+ int32_t value = actor.GetCurrentProperty<int32_t>(index);
+ DALI_TEST_EQUALS(value, 100, TEST_LOCATION);
+
+ application.SendNotification();
+ application.Render(250);
+
+ value = actor.GetCurrentProperty<int32_t>(index);
+ DALI_TEST_EQUALS(value, 150, TEST_LOCATION);
+
+ END_TEST;
+}
+
+int UtcDaliAnimationPlayBlendVector2(void)
+{
+ TestApplication application;
+
+ Actor actor = Actor::New();
+ application.GetScene().Add(actor);
+ Property::Index index = actor.RegisterProperty("property", Vector2::ZERO);
+
+ Animation animation = Animation::New(1.0f);
+ KeyFrames keyframes = KeyFrames::New();
+ keyframes.Add(0.0f, Vector2::ONE);
+ keyframes.Add(1.0f, Vector2::ONE * 2.0f);
+ animation.AnimateBetween(Property(actor, index), keyframes, AlphaFunction::LINEAR);
+
+ application.SendNotification();
+ application.Render(20);
+
+ animation.SetBlendPoint(0.5f);
+ animation.Play();
+
+ application.SendNotification();
+ application.Render(250);
+
+ Vector2 value = actor.GetCurrentProperty<Vector2>(index);
+ DALI_TEST_EQUALS(value, Vector2::ONE, 0.05f, TEST_LOCATION);
+
+ application.SendNotification();
+ application.Render(250);
+
+ value = actor.GetCurrentProperty<Vector2>(index);
+ DALI_TEST_EQUALS(value, Vector2::ONE * 1.5f, 0.05f, TEST_LOCATION);
+
+ END_TEST;
+}
+
+int UtcDaliAnimationPlayBlendVector3(void)
+{
+ TestApplication application;
+
+ Actor actor = Actor::New();
+ application.GetScene().Add(actor);
+ Property::Index index = actor.RegisterProperty("property", Vector3::ZERO);
+
+ Animation animation = Animation::New(1.0f);
+ KeyFrames keyframes = KeyFrames::New();
+ keyframes.Add(0.0f, Vector3::ONE);
+ keyframes.Add(1.0f, Vector3::ONE * 2.0f);
+ animation.AnimateBetween(Property(actor, index), keyframes, AlphaFunction::LINEAR);
+
+ application.SendNotification();
+ application.Render(20);
+
+ animation.SetBlendPoint(0.5f);
+ animation.Play();
+
+ application.SendNotification();
+ application.Render(250);
+
+ Vector3 value = actor.GetCurrentProperty<Vector3>(index);
+ DALI_TEST_EQUALS(value, Vector3::ONE, 0.05f, TEST_LOCATION);
+
+ application.SendNotification();
+ application.Render(250);
+
+ value = actor.GetCurrentProperty<Vector3>(index);
+ DALI_TEST_EQUALS(value, Vector3::ONE * 1.5f, 0.05f, TEST_LOCATION);
+
+ END_TEST;
+}
+
+int UtcDaliAnimationPlayBlendVector4(void)
+{
+ TestApplication application;
+
+ Actor actor = Actor::New();
+ application.GetScene().Add(actor);
+ Property::Index index = actor.RegisterProperty("property", Vector4::ZERO);
+
+ Animation animation = Animation::New(1.0f);
+ KeyFrames keyframes = KeyFrames::New();
+ keyframes.Add(0.0f, Vector4::ONE);
+ keyframes.Add(1.0f, Vector4::ONE * 2.0f);
+ animation.AnimateBetween(Property(actor, index), keyframes, AlphaFunction::LINEAR);
+
+ application.SendNotification();
+ application.Render(20);
+
+ animation.SetBlendPoint(0.5f);
+ animation.Play();
+
+ application.SendNotification();
+ application.Render(250);
+
+ Vector4 value = actor.GetCurrentProperty<Vector4>(index);
+ DALI_TEST_EQUALS(value, Vector4::ONE, 0.05f, TEST_LOCATION);
+
+ application.SendNotification();
+ application.Render(250);
+
+ value = actor.GetCurrentProperty<Vector4>(index);
+ DALI_TEST_EQUALS(value, Vector4::ONE * 1.5f, 0.05f, TEST_LOCATION);
+
+ END_TEST;
+}
+
+int UtcDaliAnimationPlayBlendQuaternion(void)
+{
+ TestApplication application;
+
+ Actor actor = Actor::New();
+ application.GetScene().Add(actor);
+ Property::Index index = actor.RegisterProperty("property", Quaternion(Dali::Radian(0.0f), Vector3::ZAXIS));
+
+ Animation animation = Animation::New(1.0f);
+ KeyFrames keyframes = KeyFrames::New();
+ keyframes.Add(0.0f, Quaternion(Dali::Radian(1.0f), Vector3::ZAXIS));
+ keyframes.Add(1.0f, Quaternion(Dali::Radian(2.0f), Vector3::ZAXIS));
+ animation.AnimateBetween(Property(actor, index), keyframes, AlphaFunction::LINEAR);
+
+ application.SendNotification();
+ application.Render(20);
+
+ animation.SetBlendPoint(0.5f);
+ animation.Play();
+
+ application.SendNotification();
+ application.Render(250);
+
+ Quaternion value = actor.GetCurrentProperty<Quaternion>(index);
+ Vector3 axis;
+ Dali::Radian angle;
+ DALI_TEST_EQUALS(value.ToAxisAngle(axis, angle), true, TEST_LOCATION);
+ DALI_TEST_EQUALS(angle.radian, 1.0f, 0.05f, TEST_LOCATION);
+
+ application.SendNotification();
+ application.Render(250);
+
+ value = actor.GetCurrentProperty<Quaternion>(index);
+ DALI_TEST_EQUALS(value.ToAxisAngle(axis, angle), true, TEST_LOCATION);
+ DALI_TEST_EQUALS(angle.radian, 1.5f, 0.05f, TEST_LOCATION);
+
+ END_TEST;
+}