#include <dali-test-suite-utils.h>
#include <dali/devel-api/actors/actor-devel.h>
#include <dali/devel-api/animation/animation-devel.h>
+#include <dali/devel-api/animation/key-frames-devel.h>
#include <dali/public-api/dali-core.h>
#include <stdlib.h>
END_TEST;
}
+int UtcDaliAnimationPlayOffSceneP(void)
+{
+ // Test that an animation cannot be played, when the actor is off-stage.
+ // And the property value and the current property value should not be changed in the case.
+
+ TestApplication application;
+
+ Actor actor = Actor::New();
+ Vector3 basePosition(Vector3::ZERO);
+ DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION), basePosition, TEST_LOCATION);
+ // Not added to the stage yet!
+
+ // Build the animation
+ float durationSeconds(1.0f);
+ Animation animation = Animation::New(durationSeconds);
+ Vector3 targetPosition(100.0f, 100.0f, 100.0f);
+ animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
+
+ // Start the animation
+ animation.Play();
+
+ bool signalReceived(false);
+ AnimationFinishCheck finishCheck(signalReceived);
+ animation.FinishedSignal().Connect(&application, finishCheck);
+
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(durationSeconds * 1000.0f) + 1u /*just beyond the animation duration*/);
+
+ application.SendNotification();
+ finishCheck.CheckSignalReceived();
+
+ // An animation can't be played. The position shouldn't be changed.
+ DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION), basePosition, TEST_LOCATION);
+ DALI_TEST_EQUALS(actor.GetProperty<Vector3>(Actor::Property::POSITION), basePosition, TEST_LOCATION);
+
+ // Add to the stage
+ application.GetScene().Add(actor);
+
+ // Start the animation again
+ animation.Play();
+
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(durationSeconds * 1000.0f) + 1u /*just beyond the animation duration*/);
+
+ // We did expect the animation to finish
+ application.SendNotification();
+ finishCheck.CheckSignalReceived();
+
+ DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION), targetPosition, TEST_LOCATION);
+ DALI_TEST_EQUALS(actor.GetProperty<Vector3>(Actor::Property::POSITION), targetPosition, TEST_LOCATION);
+
+ // Reset the position
+ actor[Actor::Property::POSITION] = basePosition;
+
+ application.SendNotification();
+ application.Render();
+
+ // Create an animator again
+ animation.Clear();
+ animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
+
+ // Remove from the stage
+ application.GetScene().Remove(actor);
+
+ signalReceived = false;
+
+ // Start the animation again
+ animation.Play();
+
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(durationSeconds * 1000.0f) + 1u /*just beyond the animation duration*/);
+
+ application.SendNotification();
+ finishCheck.CheckSignalReceived();
+
+ // An animation can't be played. The position shouldn't be changed.
+ DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION), basePosition, TEST_LOCATION);
+ DALI_TEST_EQUALS(actor.GetProperty<Vector3>(Actor::Property::POSITION), basePosition, TEST_LOCATION);
+
+ END_TEST;
+}
+
int UtcDaliAnimationPlayOffSceneDiscardP(void)
{
- // Test that an animation can be played, when the actor is off-stage.
+ // Test that an animation cannot be played, when the actor is off-stage.
// When the actor is added to the stage, it should appear at the current position
// i.e. where it would have been anyway, if on-stage from the beginning.
// We didn't expect the animation to finish yet
application.SendNotification();
finishCheck.CheckSignalNotReceived();
- DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION), Vector3(20, 20, 20), TEST_LOCATION);
+
+ // An animation can't be played. The position shouldn't be changed.
+ DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION), basePosition, TEST_LOCATION);
// Add to the stage
application.GetScene().Add(actor);
int UtcDaliAnimationPlayOffSceneBakeFinalP(void)
{
- // Test that an animation can be played, when the actor is off-stage.
+ // Test that an animation cannot be played, when the actor is off-stage.
// When the actor is added to the stage, it should appear at the current position
// i.e. where it would have been anyway, if on-stage from the beginning.
// We didn't expect the animation to finish yet
application.SendNotification();
finishCheck.CheckSignalNotReceived();
- DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION), Vector3(20, 20, 20), TEST_LOCATION);
+
+ // An animation can't be played. The position shouldn't be changed.
+ DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION), basePosition, TEST_LOCATION);
// Add to the stage
application.GetScene().Add(actor);
int UtcDaliAnimationPlayOffSceneBakeP(void)
{
- // Test that an animation can be played, when the actor is off-stage.
+ // Test that an animation cannot be played, when the actor is off-stage.
// When the actor is added to the stage, it should appear at the current position
// i.e. where it would have been anyway, if on-stage from the beginning.
// We didn't expect the animation to finish yet
application.SendNotification();
finishCheck.CheckSignalNotReceived();
- DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION), Vector3(20, 20, 20), TEST_LOCATION);
+
+ // An animation can't be played. The position shouldn't be changed.
+ DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION), basePosition, TEST_LOCATION);
// Add to the stage
application.GetScene().Add(actor);
END_TEST;
}
+int UtcDaliAnimationKeyFramesGetKeyFrameCountP(void)
+{
+ TestApplication application;
+
+ KeyFrames keyFrames = KeyFrames::New();
+ 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));
+
+ DALI_TEST_EQUALS(DevelKeyFrames::GetKeyFrameCount(keyFrames), 3, TEST_LOCATION);
+
+ END_TEST;
+}
+
+int UtcDaliAnimationKeyFramesGetKeyFrameP(void)
+{
+ TestApplication application;
+
+ float inputTime = 0.6f;
+ Vector4 inputValue = Vector4(0.0f, 0.0f, 0.0f, 0.3f);
+
+ KeyFrames keyFrames = KeyFrames::New();
+ 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);
+
+ END_TEST;
+}
+
int UtcDaliAnimationAnimateBetweenActorColorAlphaP(void)
{
TestApplication application;
END_TEST;
}
-int UtcDaliAnimationClearPropertyValue(void)
+int UtcDaliAnimationClearPropertyValue01(void)
{
CheckPropertyValuesWhenCallingAnimationMethod(TestFunction::CLEAR, "UtcDaliAnimationStopPropertyValue");
END_TEST;
}
+int UtcDaliAnimationClearPropertyValue02(void)
+{
+ TestApplication application;
+
+ Actor actor = Actor::New();
+ application.GetScene().Add(actor);
+
+ const float durationSeconds(1.0f);
+ const Vector3 targetPosition1(10.0f, 10.0f, 10.0f);
+ const Vector3 targetPosition2(20.0f, 20.0f, 20.0f);
+
+ // Build the animation
+ Animation animation1 = Animation::New(durationSeconds);
+ animation1.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition1, AlphaFunction::LINEAR);
+ animation1.Play();
+
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(durationSeconds * 1000.0f) - 1u /*just less than the animation duration*/);
+
+ // The event side property should be set the current value immediately
+ DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::POSITION).Get<Vector3>(), targetPosition1, VECTOR3_EPSILON, TEST_LOCATION);
+
+ application.SendNotification();
+ application.Render(2u /*just beyond the animation duration*/);
+
+ // Build a new animation
+ Animation animation2 = Animation::New(durationSeconds);
+ animation2.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition2, AlphaFunction::LINEAR);
+ animation2.Play();
+
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(durationSeconds * 1000.0f) - 1u /*just less than the animation duration*/);
+
+ // The event side property should be set the current value immediately
+ DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::POSITION).Get<Vector3>(), targetPosition2, VECTOR3_EPSILON, TEST_LOCATION);
+
+ // Clear the first animation after finished
+ animation1.Clear();
+
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(durationSeconds * 1000.0f) - 1u /*just less than the animation duration*/);
+
+ // The property should not be changed.
+ DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::POSITION).Get<Vector3>(), targetPosition2, VECTOR3_EPSILON, TEST_LOCATION);
+
+ END_TEST;
+}
+
int UtcDaliAnimationPausePropertyValue(void)
{
const float durationSeconds(1.0f);
unsigned int halfAnimationDuration(static_cast<unsigned int>(durationSeconds * 1000.0f * 0.5f));
- const Vector3 originalPosition(Vector3::ZERO);
const Vector3 targetPosition(10.0f, 10.0f, 10.0f);
const Vector3 halfWayToTarget(targetPosition * 0.5f);