2 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
22 #include <dali/public-api/dali-core.h>
23 #include <dali-test-suite-utils.h>
28 void utc_dali_animation_startup(void)
30 test_return_value = TET_UNDEF;
33 void utc_dali_animation_cleanup(void)
35 test_return_value = TET_PASS;
41 static const float ROTATION_EPSILON = 0.0001f;
42 static const float VECTOR4_EPSILON = 0.0001f;
44 // Functor to test whether a Finish signal is emitted
45 struct AnimationFinishCheck
47 AnimationFinishCheck(bool& signalReceived)
48 : mSignalReceived(signalReceived)
52 void operator()(Animation& animation)
54 mSignalReceived = true;
59 mSignalReceived = false;
62 void CheckSignalReceived()
66 tet_printf("Expected Finish signal was not received\n");
75 void CheckSignalNotReceived()
79 tet_printf("Unexpected Finish signal was received\n");
88 bool& mSignalReceived; // owned by individual tests
91 static bool ReturnFalseAfterProgressOne( float alpha, const bool& current )
96 struct AnimateFloatTestFunctor
98 AnimateFloatTestFunctor( float start, float end )
104 float operator()( float alpha, const float& current )
106 return mStart + ((mEnd - mStart) * alpha );
113 struct AnimateVector2TestFunctor
115 AnimateVector2TestFunctor( Vector2 start, Vector2 end )
121 Vector2 operator()( float alpha, const Vector2& current )
123 return mStart + ((mEnd - mStart) * alpha );
130 struct AnimateVector4TestFunctor
132 AnimateVector4TestFunctor( Vector4 start, Vector4 end )
138 Vector4 operator()( float alpha, const Vector4& current )
140 return mStart + ((mEnd - mStart) * alpha );
147 struct AnimateQuaternionTestFunctor
149 AnimateQuaternionTestFunctor( Quaternion start, Quaternion end )
155 Quaternion operator()( float alpha, const Quaternion& current )
157 return Quaternion::Slerp(mStart, mEnd, alpha);
166 BounceFunc(float x, float y, float z)
167 : mDistance(Vector3(x, y, z))
170 Vector3 operator()(float alpha, const Vector3& current)
172 if (alpha>0.001f && alpha<1.0f)
174 const float flip = 0.5f - cosf(alpha * Math::PI * 2.0f) * 0.5f;
175 Vector3 newTranslation(current);
176 newTranslation += mDistance * flip;
177 return newTranslation;
187 TumbleFunc(Vector3 axis) : tumbleAxis(axis){}
188 Quaternion operator()(float alpha, const Quaternion& current)
190 if (alpha>0.001f && alpha<1.0f)
192 Quaternion tumbleRotation(alpha * Math::PI * 2.0f, tumbleAxis);
193 return tumbleRotation * current;
202 int UtcDaliAnimationNew01(void)
204 TestApplication application;
207 DALI_TEST_CHECK(!animation);
209 animation = Animation::New(1.0f);
211 DALI_TEST_CHECK(animation);
215 int UtcDaliAnimationNew02(void)
217 TestApplication application;
220 DALI_TEST_CHECK(!animation);
223 animation = Animation::New(0.0f);
225 catch (Dali::DaliException& e)
227 // TODO: Determine why catch doesn't.
230 // Tests that a negative test of an assertion succeeds
231 tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
232 DALI_TEST_EQUALS(e.mCondition, "durationSeconds > 0.0f", TEST_LOCATION);
237 int UtcDaliAnimationDownCast(void)
239 TestApplication application;
240 tet_infoline("Testing Dali::Animation::DownCast()");
242 float durationSeconds(1.0f);
243 Animation animation = Animation::New(durationSeconds);
245 BaseHandle object(animation);
247 Animation animation2 = Animation::DownCast(object);
248 DALI_TEST_CHECK(animation2);
250 Animation animation3 = DownCast< Animation >(object);
251 DALI_TEST_CHECK(animation3);
253 BaseHandle unInitializedObject;
254 Animation animation4 = Animation::DownCast(unInitializedObject);
255 DALI_TEST_CHECK(!animation4);
257 Animation animation5 = DownCast< Animation >(unInitializedObject);
258 DALI_TEST_CHECK(!animation5);
262 int UtcDaliAnimationSetDuration(void)
264 TestApplication application;
266 Actor actor = Actor::New();
267 Stage::GetCurrent().Add(actor);
269 // Build the animation
270 float durationSeconds(1.0f);
271 Animation animation = Animation::New(durationSeconds);
272 DALI_TEST_EQUALS(animation.GetDuration(), durationSeconds, TEST_LOCATION);
274 // Start the animation
275 Vector3 targetPosition(10.0f, 10.0f, 10.0f);
276 animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear);
279 bool signalReceived(false);
280 AnimationFinishCheck finishCheck(signalReceived);
281 animation.FinishedSignal().Connect(&application, finishCheck);
283 application.SendNotification();
284 application.Render(static_cast<unsigned int>(durationSeconds*1000.0f) - 1u/*just less than the animation duration*/);
286 // We didn't expect the animation to finish yet
287 application.SendNotification();
288 finishCheck.CheckSignalNotReceived();
290 application.Render(2u/*just beyond the animation duration*/);
292 // We did expect the animation to finish
293 application.SendNotification();
294 finishCheck.CheckSignalReceived();
295 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
297 // Restart the animation, with a different duration
299 actor.SetPosition(Vector3::ZERO);
300 durationSeconds = 3.5f;
301 animation.SetDuration(durationSeconds);
302 DALI_TEST_EQUALS(animation.GetDuration(), durationSeconds, TEST_LOCATION);
305 application.SendNotification();
306 application.Render(static_cast<unsigned int>(durationSeconds*1000.0f) - 1u/*just less than the animation duration*/);
308 // We didn't expect the animation to finish yet
309 application.SendNotification();
310 finishCheck.CheckSignalNotReceived();
312 application.Render(2u/*just beyond the animation duration*/);
314 // We did expect the animation to finish
315 application.SendNotification();
316 finishCheck.CheckSignalReceived();
317 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
319 // Check that nothing has changed after a couple of buffer swaps
320 application.Render(0);
321 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
322 application.Render(0);
323 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
327 int UtcDaliAnimationGetDuration(void)
329 TestApplication application;
331 Animation animation = Animation::New(1.0f);
332 DALI_TEST_EQUALS(animation.GetDuration(), 1.0f, TEST_LOCATION);
334 animation.SetDuration(2.0f);
335 DALI_TEST_EQUALS(animation.GetDuration(), 2.0f, TEST_LOCATION);
339 int UtcDaliAnimationSetLooping(void)
341 TestApplication application;
343 Actor actor = Actor::New();
344 Stage::GetCurrent().Add(actor);
346 // Build the animation
347 float durationSeconds(1.0f);
348 Animation animation = Animation::New(durationSeconds);
349 Vector3 targetPosition(10.0f, 10.0f, 10.0f);
350 animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear);
352 // Start the animation
353 animation.SetLooping(true);
354 DALI_TEST_CHECK(animation.IsLooping());
357 bool signalReceived(false);
358 AnimationFinishCheck finishCheck(signalReceived);
359 animation.FinishedSignal().Connect(&application, finishCheck);
361 application.SendNotification();
364 float intervalSeconds = 0.25f;
365 float progress = 0.0f;
366 for (int iterations = 0; iterations < 5;)
368 application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
370 progress += intervalSeconds;
371 DALI_TEST_EQUALS( targetPosition*progress, actor.GetCurrentPosition(), 0.001f, TEST_LOCATION );
373 if (progress >= 1.0f)
375 progress = progress - 1.0f;
380 // We didn't expect the animation to finish yet
381 application.SendNotification();
382 finishCheck.CheckSignalNotReceived();
384 animation.SetLooping(false);
385 DALI_TEST_CHECK(!animation.IsLooping());
387 application.SendNotification();
388 application.Render(static_cast<unsigned int>(durationSeconds*1000.0f) + 1u/*just beyond the animation duration*/);
390 // We did expect the animation to finish
391 application.SendNotification();
392 finishCheck.CheckSignalReceived();
393 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
395 // Check that nothing has changed after a couple of buffer swaps
396 application.Render(0);
397 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
398 application.Render(0);
399 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
403 int UtcDaliAnimationIsLooping(void)
405 TestApplication application;
407 Animation animation = Animation::New(1.0f);
408 DALI_TEST_CHECK(!animation.IsLooping());
410 animation.SetLooping(true);
411 DALI_TEST_CHECK(animation.IsLooping());
415 int UtcDaliAnimationSetEndAction(void)
417 TestApplication application;
419 Actor actor = Actor::New();
420 Stage::GetCurrent().Add(actor);
422 // Build the animation
423 float durationSeconds(1.0f);
424 Animation animation = Animation::New(durationSeconds);
425 DALI_TEST_CHECK(animation.GetEndAction() == Animation::Bake);
427 Vector3 targetPosition(10.0f, 10.0f, 10.0f);
428 animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear);
430 // Start the animation
433 bool signalReceived(false);
434 AnimationFinishCheck finishCheck(signalReceived);
435 animation.FinishedSignal().Connect(&application, finishCheck);
437 application.SendNotification();
438 application.Render(static_cast<unsigned int>(durationSeconds*1000.0f) + 1u/*just beyond the animation duration*/);
440 // We did expect the animation to finish
441 application.SendNotification();
442 finishCheck.CheckSignalReceived();
443 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
445 // Go back to the start
446 actor.SetPosition(Vector3::ZERO);
447 application.SendNotification();
448 application.Render(0);
449 DALI_TEST_EQUALS( Vector3::ZERO, actor.GetCurrentPosition(), TEST_LOCATION );
451 // Test BakeFinal, animate again, for half the duration
453 animation.SetEndAction(Animation::BakeFinal);
454 DALI_TEST_CHECK(animation.GetEndAction() == Animation::BakeFinal);
457 application.SendNotification();
458 application.Render(static_cast<unsigned int>(durationSeconds*1000.0f*0.5f) /*half of the animation duration*/);
460 // Stop the animation early
463 // We did NOT expect the animation to finish
464 application.SendNotification();
465 finishCheck.CheckSignalNotReceived();
466 DALI_TEST_EQUALS( targetPosition * 0.5f, actor.GetCurrentPosition(), VECTOR4_EPSILON, TEST_LOCATION );
468 // Go back to the start
469 actor.SetPosition(Vector3::ZERO);
470 application.SendNotification();
471 application.Render(0);
472 DALI_TEST_EQUALS( Vector3::ZERO, actor.GetCurrentPosition(), TEST_LOCATION );
474 // Test EndAction::Discard, animate again, but don't bake this time
476 animation.SetEndAction(Animation::Discard);
477 DALI_TEST_CHECK(animation.GetEndAction() == Animation::Discard);
480 application.SendNotification();
481 application.Render(static_cast<unsigned int>(durationSeconds*1000.0f) + 1u/*just beyond the animation duration*/);
483 // We did expect the animation to finish
484 application.SendNotification();
485 finishCheck.CheckSignalReceived();
486 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
488 // The position should be discarded in the next frame
489 application.Render(0);
490 DALI_TEST_EQUALS( Vector3::ZERO/*discarded*/, actor.GetCurrentPosition(), TEST_LOCATION );
492 // Check that nothing has changed after a couple of buffer swaps
493 application.Render(0);
494 DALI_TEST_EQUALS( Vector3::ZERO, actor.GetCurrentPosition(), TEST_LOCATION );
495 application.Render(0);
496 DALI_TEST_EQUALS( Vector3::ZERO, actor.GetCurrentPosition(), TEST_LOCATION );
500 int UtcDaliAnimationGetEndAction(void)
502 TestApplication application;
504 Animation animation = Animation::New(1.0f);
505 DALI_TEST_CHECK(animation.GetEndAction() == Animation::Bake);
507 animation.SetEndAction(Animation::Discard);
508 DALI_TEST_CHECK(animation.GetEndAction() == Animation::Discard);
510 animation.SetEndAction(Animation::BakeFinal);
511 DALI_TEST_CHECK(animation.GetEndAction() == Animation::BakeFinal);
516 int UtcDaliAnimationGetDestroyAction(void)
518 TestApplication application;
519 Animation animation = Animation::New(1.0f);
520 DALI_TEST_CHECK(animation.GetDestroyAction() == Animation::Bake); // default!
522 animation.SetDestroyAction(Animation::Discard);
523 DALI_TEST_CHECK(animation.GetDestroyAction() == Animation::Discard);
525 animation.SetDestroyAction(Animation::BakeFinal);
526 DALI_TEST_CHECK(animation.GetDestroyAction() == Animation::BakeFinal);
531 int UtcDaliAnimationSetDefaultAlphaFunction(void)
533 TestApplication application;
535 Animation animation = Animation::New(1.0f);
536 AlphaFunction func = animation.GetDefaultAlphaFunction();
537 DALI_TEST_EQUALS(func(0.1f), AlphaFunctions::Linear(0.1f), TEST_LOCATION);
539 animation.SetDefaultAlphaFunction(AlphaFunctions::EaseIn);
540 AlphaFunction func2 = animation.GetDefaultAlphaFunction();
541 DALI_TEST_CHECK(func2(0.1f) < AlphaFunctions::Linear(0.1f)); // less progress when easing-in
545 int UtcDaliAnimationGetDefaultAlphaFunction(void)
547 TestApplication application;
549 Animation animation = Animation::New(1.0f);
550 AlphaFunction func = animation.GetDefaultAlphaFunction();
552 // Test that the default is linear
553 DALI_TEST_EQUALS(func(0.1f), AlphaFunctions::Linear(0.1f), TEST_LOCATION);
557 int UtcDaliAnimationPlay(void)
559 TestApplication application;
561 Actor actor = Actor::New();
562 Stage::GetCurrent().Add(actor);
564 // Build the animation
565 float durationSeconds(1.0f);
566 Animation animation = Animation::New(durationSeconds);
567 Vector3 targetPosition(100.0f, 100.0f, 100.0f);
568 animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear);
570 // Start the animation
573 bool signalReceived(false);
574 AnimationFinishCheck finishCheck(signalReceived);
575 animation.FinishedSignal().Connect(&application, finishCheck);
577 application.SendNotification();
578 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 20% progress */);
580 // We didn't expect the animation to finish yet
581 application.SendNotification();
582 finishCheck.CheckSignalNotReceived();
583 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION );
585 animation.Play(); // Test that calling play has no effect, when animation is already playing
586 application.SendNotification();
587 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 40% progress */);
589 // We didn't expect the animation to finish yet
590 application.SendNotification();
591 finishCheck.CheckSignalNotReceived();
592 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.4f), TEST_LOCATION );
594 animation.Play(); // Test that calling play has no effect, when animation is already playing
595 application.SendNotification();
596 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 60% progress */);
598 // We didn't expect the animation to finish yet
599 application.SendNotification();
600 finishCheck.CheckSignalNotReceived();
601 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.6f), TEST_LOCATION );
603 animation.Play(); // Test that calling play has no effect, when animation is already playing
604 application.SendNotification();
605 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 80% progress */);
607 // We didn't expect the animation to finish yet
608 application.SendNotification();
609 finishCheck.CheckSignalNotReceived();
610 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.8f), TEST_LOCATION );
612 animation.Play(); // Test that calling play has no effect, when animation is already playing
613 application.SendNotification();
614 application.Render(static_cast<unsigned int>(durationSeconds*200.0f) + 1u/*just beyond the animation duration*/);
616 // We did expect the animation to finish
617 application.SendNotification();
618 finishCheck.CheckSignalReceived();
619 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
621 // Check that nothing has changed after a couple of buffer swaps
622 application.Render(0);
623 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
624 application.Render(0);
625 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
629 int UtcDaliAnimationPlayOffStage(void)
631 // Test that an animation can be played, when the actor is off-stage.
632 // When the actor is added to the stage, it should appear at the current position
633 // i.e. where it would have been anyway, if on-stage from the beginning.
635 TestApplication application;
637 Actor actor = Actor::New();
638 Vector3 basePosition(Vector3::ZERO);
639 DALI_TEST_EQUALS( actor.GetCurrentPosition(), basePosition, TEST_LOCATION );
640 // Not added to the stage!
642 // Build the animation
643 float durationSeconds(1.0f);
644 Animation animation = Animation::New(durationSeconds);
645 Vector3 targetPosition(100.0f, 100.0f, 100.0f);
646 animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear);
648 // Start the animation
651 bool signalReceived(false);
652 AnimationFinishCheck finishCheck(signalReceived);
653 animation.FinishedSignal().Connect(&application, finishCheck);
655 application.SendNotification();
656 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 20% progress */);
658 // We didn't expect the animation to finish yet
659 application.SendNotification();
660 finishCheck.CheckSignalNotReceived();
661 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO/*off-stage*/, TEST_LOCATION );
664 Stage::GetCurrent().Add(actor);
666 application.SendNotification();
667 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 40% progress */);
669 // We didn't expect the animation to finish yet
670 application.SendNotification();
671 finishCheck.CheckSignalNotReceived();
672 Vector3 expectedPosition(basePosition + (targetPosition - basePosition)*0.4f);
673 DALI_TEST_EQUALS( actor.GetCurrentPosition(), expectedPosition/*on-stage*/, TEST_LOCATION );
675 // Remove from the stage
676 Stage::GetCurrent().Remove(actor);
678 application.SendNotification();
679 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 60% progress */);
681 // We didn't expect the animation to finish yet
682 application.SendNotification();
683 finishCheck.CheckSignalNotReceived();
684 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO/*back to start position*/, TEST_LOCATION );
687 Stage::GetCurrent().Add(actor);
689 application.SendNotification();
690 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 80% progress */);
692 // We didn't expect the animation to finish yet
693 application.SendNotification();
694 finishCheck.CheckSignalNotReceived();
695 expectedPosition = Vector3(basePosition + (targetPosition - basePosition)*0.8f);
696 DALI_TEST_EQUALS( actor.GetCurrentPosition(), expectedPosition, TEST_LOCATION );
698 application.SendNotification();
699 application.Render(static_cast<unsigned int>(durationSeconds*200.0f) + 1u/*just beyond the animation duration*/);
701 // We did expect the animation to finish
702 application.SendNotification();
703 finishCheck.CheckSignalReceived();
704 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
706 // Check that nothing has changed after a couple of buffer swaps
707 application.Render(0);
708 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
709 application.Render(0);
710 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
714 int UtcDaliAnimationPlayDiscardHandle(void)
716 TestApplication application;
718 Actor actor = Actor::New();
719 Stage::GetCurrent().Add(actor);
721 // Build the animation
722 float durationSeconds(1.0f);
723 Animation animation = Animation::New(durationSeconds);
724 Vector3 targetPosition(100.0f, 100.0f, 100.0f);
725 animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear);
727 bool signalReceived(false);
728 AnimationFinishCheck finishCheck(signalReceived);
729 animation.FinishedSignal().Connect(&application, finishCheck);
731 // Start the animation
734 // This is a test of the "Fire and Forget" behaviour
735 // Discard the animation handle!
737 DALI_TEST_CHECK( !animation );
739 application.SendNotification();
740 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 20% progress */);
742 // We didn't expect the animation to finish yet
743 application.SendNotification();
744 finishCheck.CheckSignalNotReceived();
745 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION );
747 application.SendNotification();
748 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 40% progress */);
750 // We didn't expect the animation to finish yet
751 application.SendNotification();
752 finishCheck.CheckSignalNotReceived();
753 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.4f), TEST_LOCATION );
755 application.SendNotification();
756 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 60% progress */);
758 // We didn't expect the animation to finish yet
759 application.SendNotification();
760 finishCheck.CheckSignalNotReceived();
761 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.6f), TEST_LOCATION );
763 application.SendNotification();
764 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 80% progress */);
766 // We didn't expect the animation to finish yet
767 application.SendNotification();
768 finishCheck.CheckSignalNotReceived();
769 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.8f), TEST_LOCATION );
771 application.SendNotification();
772 application.Render(static_cast<unsigned int>(durationSeconds*200.0f) + 1u/*just beyond the animation duration*/);
774 // We did expect the animation to finish
775 application.SendNotification();
776 finishCheck.CheckSignalReceived();
777 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
779 // Check that nothing has changed after a couple of buffer swaps
780 application.Render(0);
781 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
782 application.Render(0);
783 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
787 int UtcDaliAnimationPlayStopDiscardHandle(void)
789 TestApplication application;
791 Actor actor = Actor::New();
792 Stage::GetCurrent().Add(actor);
794 // Build the animation
795 float durationSeconds(1.0f);
796 Animation animation = Animation::New(durationSeconds);
797 Vector3 targetPosition(100.0f, 100.0f, 100.0f);
798 animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear);
800 // Start the animation
803 bool signalReceived(false);
804 AnimationFinishCheck finishCheck(signalReceived);
805 animation.FinishedSignal().Connect(&application, finishCheck);
807 application.SendNotification();
808 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 20% progress */);
810 // We didn't expect the animation to finish yet
811 application.SendNotification();
812 finishCheck.CheckSignalNotReceived();
813 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION );
815 // This is a test of the "Fire and Forget" behaviour
816 // Stop the animation, and Discard the animation handle!
819 DALI_TEST_CHECK( !animation );
821 application.SendNotification();
822 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 40% progress */);
824 // We expect the animation to finish at 20% progress
825 application.SendNotification();
826 finishCheck.CheckSignalReceived();
828 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION );
830 application.SendNotification();
831 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 60% progress */);
833 // Check that nothing has changed
834 application.SendNotification();
835 finishCheck.CheckSignalNotReceived();
836 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION );
838 application.SendNotification();
839 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 80% progress */);
841 // Check that nothing has changed
842 application.SendNotification();
843 finishCheck.CheckSignalNotReceived();
844 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION );
846 application.SendNotification();
847 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 100% progress */);
849 // Check that nothing has changed
850 application.SendNotification();
851 finishCheck.CheckSignalNotReceived();
852 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION );
856 int UtcDaliAnimationPlayFrom(void)
858 TestApplication application;
860 Actor actor = Actor::New();
861 Stage::GetCurrent().Add(actor);
863 // Build the animation
864 float durationSeconds(1.0f);
865 Animation animation = Animation::New(durationSeconds);
866 Vector3 targetPosition(100.0f, 100.0f, 100.0f);
867 animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear);
869 //PlayFrom with an argument outside the range [0..1] will be ignored
870 animation.PlayFrom(-1.0f);
871 application.SendNotification();
872 DALI_TEST_EQUALS(0.0f, animation.GetCurrentProgress(), TEST_LOCATION );
874 animation.PlayFrom(100.0f);
875 application.SendNotification();
876 DALI_TEST_EQUALS(0.0f, animation.GetCurrentProgress(), TEST_LOCATION );
878 // Start the animation from 40% progress
879 animation.PlayFrom( 0.4f );
881 bool signalReceived(false);
882 AnimationFinishCheck finishCheck(signalReceived);
883 animation.FinishedSignal().Connect(&application, finishCheck);
885 application.SendNotification();
886 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 60% progress */);
888 // We didn't expect the animation to finish yet
889 application.SendNotification();
890 finishCheck.CheckSignalNotReceived();
891 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.6f), TEST_LOCATION );
893 animation.Play(); // Test that calling play has no effect, when animation is already playing
894 application.SendNotification();
895 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 80% progress */);
897 // We didn't expect the animation to finish yet
898 application.SendNotification();
899 finishCheck.CheckSignalNotReceived();
900 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.8f), TEST_LOCATION );
902 application.Render(static_cast<unsigned int>(durationSeconds*200.0f) + 1u/*just beyond the animation duration*/);
903 // We did expect the animation to finish
904 application.SendNotification();
905 finishCheck.CheckSignalReceived();
906 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
908 // Check that nothing has changed after a couple of buffer swaps
909 application.Render(0);
910 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
911 application.Render(0);
912 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
916 int UtcDaliAnimationSetCurrentProgress(void)
918 TestApplication application;
920 Actor actor = Actor::New();
921 Stage::GetCurrent().Add(actor);
923 // Build the animation
924 Animation animation = Animation::New(0.0f);
927 //Test GetCurrentProgress return 0.0 as the duration is 0.0
928 DALI_TEST_EQUALS( 0.0f, animation.GetCurrentProgress(), TEST_LOCATION );
930 animation.SetCurrentProgress( 0.5f );
931 application.SendNotification();
932 application.Render(static_cast<unsigned int>(100.0f));
934 //Progress should still be 0.0
935 DALI_TEST_EQUALS( 0.0f, animation.GetCurrentProgress(), TEST_LOCATION );
938 float durationSeconds(1.0f);
939 animation.SetDuration(durationSeconds);
940 application.SendNotification();
942 bool signalReceived(false);
943 AnimationFinishCheck finishCheck(signalReceived);
944 animation.FinishedSignal().Connect(&application, finishCheck);
945 application.SendNotification();
947 Vector3 targetPosition(100.0f, 100.0f, 100.0f);
948 animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear);
950 //Trying to set the current cursor outside the range [0..1] is ignored
951 animation.SetCurrentProgress( -1.0f);
952 application.SendNotification();
953 DALI_TEST_EQUALS( 0.0f, animation.GetCurrentProgress(), TEST_LOCATION );
955 animation.SetCurrentProgress( 100.0f);
956 application.SendNotification();
957 DALI_TEST_EQUALS( 0.0f, animation.GetCurrentProgress(), TEST_LOCATION );
959 // Start the animation from 40% progress
960 animation.SetCurrentProgress( 0.4f );
963 application.SendNotification();
964 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 60% progress */);
966 // We didn't expect the animation to finish yet
967 application.SendNotification();
968 finishCheck.CheckSignalNotReceived();
969 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.6f), TEST_LOCATION );
970 DALI_TEST_EQUALS( 0.6f, animation.GetCurrentProgress(), TEST_LOCATION );
972 animation.Play(); // Test that calling play has no effect, when animation is already playing
973 application.SendNotification();
975 //Set the progress to 70%
976 animation.SetCurrentProgress( 0.7f );
977 application.SendNotification();
978 application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 80% progress */);
979 DALI_TEST_EQUALS( 0.8f, animation.GetCurrentProgress(), TEST_LOCATION );
982 application.SendNotification();
983 finishCheck.CheckSignalNotReceived();
984 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.8f), TEST_LOCATION );
985 DALI_TEST_EQUALS( 0.8f, animation.GetCurrentProgress(), TEST_LOCATION );
989 application.Render(static_cast<unsigned int>(durationSeconds*200.0f) + 1u/*just beyond the animation duration*/);
990 // We did expect the animation to finish
991 application.SendNotification();
992 finishCheck.CheckSignalReceived();
993 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
995 // Check that nothing has changed after a couple of buffer swaps
996 application.Render(0);
997 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
998 application.Render(0);
999 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
1004 int UtcDaliAnimationPause(void)
1006 TestApplication application;
1008 Actor actor = Actor::New();
1009 Stage::GetCurrent().Add(actor);
1011 // Build the animation
1012 float durationSeconds(1.0f);
1013 Animation animation = Animation::New(durationSeconds);
1014 Vector3 targetPosition(100.0f, 100.0f, 100.0f);
1015 animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear);
1017 Vector3 fiftyPercentProgress(targetPosition * 0.5f);
1019 // Start the animation
1022 bool signalReceived(false);
1023 AnimationFinishCheck finishCheck(signalReceived);
1024 animation.FinishedSignal().Connect(&application, finishCheck);
1026 application.SendNotification();
1027 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
1029 // We didn't expect the animation to finish yet
1030 application.SendNotification();
1031 finishCheck.CheckSignalNotReceived();
1032 DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress, TEST_LOCATION );
1034 // Pause the animation
1036 application.SendNotification();
1039 for (int i=0; i<5; ++i)
1041 application.Render(static_cast<unsigned int>(durationSeconds*500.0f));
1043 // We didn't expect the animation to finish yet
1044 application.SendNotification();
1045 finishCheck.CheckSignalNotReceived();
1046 DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress/* Still 50% progress when paused */, TEST_LOCATION );
1051 application.SendNotification();
1052 application.Render(static_cast<unsigned int>(durationSeconds*490.0f)/*slightly less than the animation duration*/);
1054 // We didn't expect the animation to finish yet
1055 application.SendNotification();
1056 finishCheck.CheckSignalNotReceived();
1058 application.SendNotification();
1059 application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
1061 // We did expect the animation to finish
1062 application.SendNotification();
1063 finishCheck.CheckSignalReceived();
1064 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
1066 // Check that nothing has changed after a couple of buffer swaps
1067 application.Render(0);
1068 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
1069 application.Render(0);
1070 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
1074 int UtcDaliAnimationStop(void)
1076 TestApplication application;
1078 Actor actor = Actor::New();
1079 Stage::GetCurrent().Add(actor);
1081 // Build the animation
1082 float durationSeconds(1.0f);
1083 Animation animation = Animation::New(durationSeconds);
1084 Vector3 targetPosition(100.0f, 100.0f, 100.0f);
1085 animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear);
1087 Vector3 fiftyPercentProgress(targetPosition * 0.5f);
1089 // Start the animation
1092 bool signalReceived(false);
1093 AnimationFinishCheck finishCheck(signalReceived);
1094 animation.FinishedSignal().Connect(&application, finishCheck);
1096 application.SendNotification();
1097 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
1099 // We didn't expect the animation to finish yet
1100 application.SendNotification();
1101 finishCheck.CheckSignalNotReceived();
1102 DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress, TEST_LOCATION );
1104 // Stop the animation
1106 application.SendNotification();
1109 for (int i=0; i<5; ++i)
1111 application.Render(static_cast<unsigned int>(durationSeconds*500.0f));
1113 // We did expect the animation to finish
1114 application.SendNotification();
1115 finishCheck.CheckSignalReceived();
1116 DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress/* Still 50% progress when stopped */, TEST_LOCATION );
1121 int UtcDaliAnimationStopSetPosition(void)
1123 // Test that Animation::Stop & Actor::SetPosition can be used in conjunction
1124 // i.e. to check that the animation does not interfere with the position set.
1126 TestApplication application;
1128 Actor actor = Actor::New();
1129 Stage::GetCurrent().Add(actor);
1131 // Build the animation
1132 float durationSeconds(1.0f);
1133 Animation animation = Animation::New(durationSeconds);
1134 Vector3 targetPosition(100.0f, 100.0f, 100.0f);
1135 animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear);
1137 Vector3 fiftyPercentProgress(targetPosition * 0.5f);
1139 // Start the animation
1142 bool signalReceived(false);
1143 AnimationFinishCheck finishCheck(signalReceived);
1144 animation.FinishedSignal().Connect(&application, finishCheck);
1146 application.SendNotification();
1147 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
1149 // We didn't expect the animation to finish yet
1150 application.SendNotification();
1151 finishCheck.CheckSignalNotReceived();
1152 DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress, TEST_LOCATION );
1154 // Stop the animation
1156 Vector3 positionSet(2.0f, 3.0f, 4.0f);
1157 actor.SetPosition(positionSet);
1158 application.SendNotification();
1161 for (int i=0; i<5; ++i)
1163 application.Render(static_cast<unsigned int>(durationSeconds*500.0f));
1165 // We did expect the animation to finish
1166 application.SendNotification();
1167 finishCheck.CheckSignalReceived();
1168 DALI_TEST_EQUALS( actor.GetCurrentPosition(), positionSet/*Animation should not interfere with this*/, TEST_LOCATION );
1173 int UtcDaliAnimationClear(void)
1175 TestApplication application;
1177 Actor actor = Actor::New();
1178 Stage::GetCurrent().Add(actor);
1180 // Build the animation
1181 float durationSeconds(1.0f);
1182 Animation animation = Animation::New(durationSeconds);
1183 Vector3 targetPosition(100.0f, 100.0f, 100.0f);
1184 animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear);
1186 Vector3 fiftyPercentProgress(targetPosition * 0.5f);
1188 // Start the animation
1191 bool signalReceived(false);
1192 AnimationFinishCheck finishCheck(signalReceived);
1193 animation.FinishedSignal().Connect(&application, finishCheck);
1195 application.SendNotification();
1196 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
1198 // We didn't expect the animation to finish yet
1199 application.SendNotification();
1200 finishCheck.CheckSignalNotReceived();
1201 DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress, TEST_LOCATION );
1203 // Clear the animation
1205 application.SendNotification();
1207 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
1209 // We don't expect the animation to finish now
1210 application.SendNotification();
1211 finishCheck.CheckSignalNotReceived();
1212 DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress/* Still 50% progress since the animator was destroyed */, TEST_LOCATION );
1214 // Restart as a scale animation; this should not move the actor's position
1215 finishCheck.Reset();
1216 actor.SetPosition(Vector3::ZERO);
1217 Vector3 targetScale(3.0f, 3.0f, 3.0f);
1218 animation.ScaleTo(actor, targetScale, AlphaFunctions::Linear);
1221 application.SendNotification();
1222 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
1224 // We didn't expect the animation to finish yet
1225 application.SendNotification();
1226 finishCheck.CheckSignalNotReceived();
1227 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO/*Check move-animator was destroyed*/, TEST_LOCATION );
1228 DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3(2.0f, 2.0f, 2.0f), TEST_LOCATION );
1230 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
1232 // We did expect the animation to finish
1233 application.SendNotification();
1234 finishCheck.CheckSignalReceived();
1235 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO/*Check move-animator was destroyed*/, TEST_LOCATION );
1236 DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
1240 int UtcDaliAnimationSignalFinish(void)
1242 TestApplication application;
1244 // Start the empty animation
1245 float durationSeconds(1.0f);
1246 Animation animation = Animation::New(durationSeconds);
1249 bool signalReceived(false);
1250 AnimationFinishCheck finishCheck(signalReceived);
1251 animation.FinishedSignal().Connect(&application, finishCheck);
1253 application.SendNotification();
1254 application.Render(static_cast<unsigned int>(durationSeconds*1000.0f) + 1u/*beyond the animation duration*/);
1256 // We did expect the animation to finish
1257 application.SendNotification();
1258 finishCheck.CheckSignalReceived();
1262 int UtcDaliAnimationAnimateByBoolean(void)
1264 TestApplication application;
1266 Actor actor = Actor::New();
1268 // Register a boolean property
1269 bool startValue(false);
1270 Property::Index index = actor.RegisterProperty( "test-property", startValue );
1271 Stage::GetCurrent().Add(actor);
1272 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
1274 // Build the animation
1275 float durationSeconds(2.0f);
1276 Animation animation = Animation::New(durationSeconds);
1277 const bool relativeValue(true);
1278 const bool finalValue( false || relativeValue );
1279 animation.AnimateBy(Property(actor, index), relativeValue);
1281 // Start the animation
1284 bool signalReceived(false);
1285 AnimationFinishCheck finishCheck(signalReceived);
1286 animation.FinishedSignal().Connect(&application, finishCheck);
1288 application.SendNotification();
1289 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
1291 // We didn't expect the animation to finish yet
1292 application.SendNotification();
1293 finishCheck.CheckSignalNotReceived();
1294 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
1296 application.SendNotification();
1297 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
1299 // We did expect the animation to finish
1300 application.SendNotification();
1301 finishCheck.CheckSignalReceived();
1302 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1304 // Check that nothing has changed after a couple of buffer swaps
1305 application.Render(0);
1306 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1307 application.Render(0);
1308 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1310 // Repeat with relative value "false" - this should be an NOOP
1311 animation = Animation::New(durationSeconds);
1312 bool noOpValue(false);
1313 animation.AnimateBy(Property(actor, index), noOpValue);
1315 // Start the animation
1318 finishCheck.Reset();
1319 animation.FinishedSignal().Connect(&application, finishCheck);
1321 application.SendNotification();
1322 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
1324 // We didn't expect the animation to finish yet
1325 application.SendNotification();
1326 finishCheck.CheckSignalNotReceived();
1327 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1329 application.SendNotification();
1330 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
1332 // We did expect the animation to finish
1333 application.SendNotification();
1334 finishCheck.CheckSignalReceived();
1335 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1337 // Check that nothing has changed after a couple of buffer swaps
1338 application.Render(0);
1339 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1340 application.Render(0);
1341 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1345 int UtcDaliAnimationAnimateByBooleanAlphaFunction(void)
1347 TestApplication application;
1349 Actor actor = Actor::New();
1351 // Register a boolean property
1352 bool startValue(false);
1353 Property::Index index = actor.RegisterProperty( "test-property", startValue );
1354 Stage::GetCurrent().Add(actor);
1355 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
1357 // Build the animation
1358 float durationSeconds(2.0f);
1359 Animation animation = Animation::New(durationSeconds);
1360 bool relativeValue(true);
1361 bool finalValue( false || relativeValue );
1362 animation.AnimateBy(Property(actor, index), relativeValue, AlphaFunctions::EaseIn);
1364 // Start the animation
1367 bool signalReceived(false);
1368 AnimationFinishCheck finishCheck(signalReceived);
1369 animation.FinishedSignal().Connect(&application, finishCheck);
1371 application.SendNotification();
1372 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
1374 // We didn't expect the animation to finish yet
1375 application.SendNotification();
1376 finishCheck.CheckSignalNotReceived();
1377 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
1379 application.SendNotification();
1380 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
1382 // We did expect the animation to finish
1383 application.SendNotification();
1384 finishCheck.CheckSignalReceived();
1385 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1387 // Check that nothing has changed after a couple of buffer swaps
1388 application.Render(0);
1389 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1390 application.Render(0);
1391 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1393 // Repeat with relative value "false" - this should be an NOOP
1394 animation = Animation::New(durationSeconds);
1395 bool noOpValue(false);
1396 animation.AnimateBy(Property(actor, index), noOpValue, AlphaFunctions::EaseIn);
1398 // Start the animation
1401 finishCheck.Reset();
1402 animation.FinishedSignal().Connect(&application, finishCheck);
1404 application.SendNotification();
1405 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
1407 // We didn't expect the animation to finish yet
1408 application.SendNotification();
1409 finishCheck.CheckSignalNotReceived();
1410 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1412 application.SendNotification();
1413 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
1415 // We did expect the animation to finish
1416 application.SendNotification();
1417 finishCheck.CheckSignalReceived();
1418 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1422 int UtcDaliAnimationAnimateByBooleanTimePeriod(void)
1424 TestApplication application;
1426 Actor actor = Actor::New();
1428 // Register a boolean property
1429 bool startValue(false);
1430 Property::Index index = actor.RegisterProperty( "test-property", startValue );
1431 Stage::GetCurrent().Add(actor);
1432 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
1434 // Build the animation
1435 float durationSeconds(2.0f);
1436 Animation animation = Animation::New(durationSeconds);
1437 bool relativeValue(true);
1438 bool finalValue( false || relativeValue );
1439 float animatorDurationSeconds(durationSeconds * 0.5f);
1440 animation.AnimateBy( Property(actor, index),
1442 TimePeriod( animatorDurationSeconds ) );
1444 // Start the animation
1447 bool signalReceived(false);
1448 AnimationFinishCheck finishCheck(signalReceived);
1449 animation.FinishedSignal().Connect(&application, finishCheck);
1451 application.SendNotification();
1452 application.Render(static_cast<unsigned int>(animatorDurationSeconds*950.0f)/* 95% animator progress */);
1454 // We didn't expect the animation to finish yet
1455 application.SendNotification();
1456 finishCheck.CheckSignalNotReceived();
1457 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
1459 application.SendNotification();
1460 application.Render(static_cast<unsigned int>(animatorDurationSeconds*50.0f) + 1u/*just beyond the animator duration*/);
1462 // We didn't expect the animation to finish yet...
1463 application.SendNotification();
1464 finishCheck.CheckSignalNotReceived();
1466 // ...however we should have reached the final value
1467 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1469 application.SendNotification();
1470 application.Render(static_cast<unsigned int>(animatorDurationSeconds*1000.0f)/*just beyond the animation duration*/);
1472 // We did expect the animation to finish
1473 application.SendNotification();
1474 finishCheck.CheckSignalReceived();
1475 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1477 // Check that nothing has changed after a couple of buffer swaps
1478 application.Render(0);
1479 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1480 application.Render(0);
1481 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1485 int UtcDaliAnimationAnimateByBooleanAlphaFunctionTimePeriod(void)
1487 TestApplication application;
1489 Actor actor = Actor::New();
1491 // Register a boolean property
1492 bool startValue(false);
1493 Property::Index index = actor.RegisterProperty( "test-property", startValue );
1494 Stage::GetCurrent().Add(actor);
1495 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
1497 // Build the animation
1498 float durationSeconds(2.0f);
1499 Animation animation = Animation::New(durationSeconds);
1500 bool relativeValue(true);
1501 bool finalValue( false || relativeValue );
1502 float animatorDurationSeconds(durationSeconds * 0.5f);
1503 animation.AnimateBy( Property(actor, index),
1505 AlphaFunctions::EaseInOut,
1506 TimePeriod( animatorDurationSeconds ) );
1508 // Start the animation
1511 bool signalReceived(false);
1512 AnimationFinishCheck finishCheck(signalReceived);
1513 animation.FinishedSignal().Connect(&application, finishCheck);
1515 application.SendNotification();
1516 application.Render(static_cast<unsigned int>(animatorDurationSeconds*950.0f)/* 95% animator progress */);
1518 // We didn't expect the animation to finish yet
1519 application.SendNotification();
1520 finishCheck.CheckSignalNotReceived();
1521 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
1523 application.SendNotification();
1524 application.Render(static_cast<unsigned int>(animatorDurationSeconds*50.0f) + 1u/*just beyond the animator duration*/);
1526 // We didn't expect the animation to finish yet...
1527 application.SendNotification();
1528 finishCheck.CheckSignalNotReceived();
1530 // ...however we should have reached the final value
1531 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1533 application.SendNotification();
1534 application.Render(static_cast<unsigned int>(animatorDurationSeconds*1000.0f)/*just beyond the animation duration*/);
1536 // We did expect the animation to finish
1537 application.SendNotification();
1538 finishCheck.CheckSignalReceived();
1539 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1541 // Check that nothing has changed after a couple of buffer swaps
1542 application.Render(0);
1543 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1544 application.Render(0);
1545 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1549 int UtcDaliAnimationAnimateByFloat(void)
1551 TestApplication application;
1553 Actor actor = Actor::New();
1555 // Register a float property
1556 float startValue(10.0f);
1557 Property::Index index = actor.RegisterProperty( "test-property", startValue );
1558 Stage::GetCurrent().Add(actor);
1559 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
1561 // Build the animation
1562 float durationSeconds(2.0f);
1563 Animation animation = Animation::New(durationSeconds);
1564 float targetValue(50.0f);
1565 float relativeValue(targetValue - startValue);
1566 animation.AnimateBy(Property(actor, index), relativeValue);
1568 float ninetyFivePercentProgress(startValue + relativeValue*0.95f);
1570 // Start the animation
1573 bool signalReceived(false);
1574 AnimationFinishCheck finishCheck(signalReceived);
1575 animation.FinishedSignal().Connect(&application, finishCheck);
1577 application.SendNotification();
1578 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
1580 // We didn't expect the animation to finish yet
1581 application.SendNotification();
1582 finishCheck.CheckSignalNotReceived();
1583 DALI_TEST_EQUALS( actor.GetProperty<float>(index), ninetyFivePercentProgress, TEST_LOCATION );
1585 application.SendNotification();
1586 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
1588 // We did expect the animation to finish
1589 application.SendNotification();
1590 finishCheck.CheckSignalReceived();
1591 DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
1593 // Check that nothing has changed after a couple of buffer swaps
1594 application.Render(0);
1595 DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
1596 application.Render(0);
1597 DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
1601 int UtcDaliAnimationAnimateByFloatAlphaFunction(void)
1603 TestApplication application;
1605 Actor actor = Actor::New();
1607 // Register a float property
1608 float startValue(10.0f);
1609 Property::Index index = actor.RegisterProperty( "test-property", startValue );
1610 Stage::GetCurrent().Add(actor);
1611 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
1613 // Build the animation
1614 float durationSeconds(1.0f);
1615 Animation animation = Animation::New(durationSeconds);
1616 float targetValue(90.0f);
1617 float relativeValue(targetValue - startValue);
1618 animation.AnimateBy(Property(actor, index), relativeValue, AlphaFunctions::EaseOut);
1620 float ninetyFivePercentProgress(startValue + relativeValue*0.95f);
1622 // Start the animation
1625 bool signalReceived(false);
1626 AnimationFinishCheck finishCheck(signalReceived);
1627 animation.FinishedSignal().Connect(&application, finishCheck);
1629 application.SendNotification();
1630 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
1632 // We didn't expect the animation to finish yet
1633 application.SendNotification();
1634 finishCheck.CheckSignalNotReceived();
1636 // The position should have moved more, than with a linear alpha function
1637 float current(actor.GetProperty<float>(index));
1638 DALI_TEST_CHECK( current > ninetyFivePercentProgress );
1640 application.SendNotification();
1641 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
1643 // We did expect the animation to finish
1644 application.SendNotification();
1645 finishCheck.CheckSignalReceived();
1646 DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
1648 // Check that nothing has changed after a couple of buffer swaps
1649 application.Render(0);
1650 DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
1651 application.Render(0);
1652 DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
1656 int UtcDaliAnimationAnimateByFloatTimePeriod(void)
1658 TestApplication application;
1660 Actor actor = Actor::New();
1662 // Register a float property
1663 float startValue(10.0f);
1664 Property::Index index = actor.RegisterProperty( "test-property", startValue );
1665 Stage::GetCurrent().Add(actor);
1666 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
1668 // Build the animation
1669 float durationSeconds(1.0f);
1670 Animation animation = Animation::New(durationSeconds);
1671 float targetValue(30.0f);
1672 float relativeValue(targetValue - startValue);
1674 animation.AnimateBy(Property(actor, index),
1676 TimePeriod(delay, durationSeconds - delay));
1678 // Start the animation
1681 bool signalReceived(false);
1682 AnimationFinishCheck finishCheck(signalReceived);
1683 animation.FinishedSignal().Connect(&application, finishCheck);
1685 application.SendNotification();
1686 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
1688 // We didn't expect the animation to finish yet
1689 application.SendNotification();
1690 finishCheck.CheckSignalNotReceived();
1691 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
1693 application.SendNotification();
1694 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
1696 // We didn't expect the animation to finish yet
1697 application.SendNotification();
1698 finishCheck.CheckSignalNotReceived();
1699 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
1701 application.SendNotification();
1702 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
1704 // We did expect the animation to finish
1705 application.SendNotification();
1706 finishCheck.CheckSignalReceived();
1707 DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
1709 // Check that nothing has changed after a couple of buffer swaps
1710 application.Render(0);
1711 DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
1712 application.Render(0);
1713 DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
1717 int UtcDaliAnimationAnimateByFloatAlphaFunctionTimePeriod(void)
1719 TestApplication application;
1721 Actor actor = Actor::New();
1723 // Register a float property
1724 float startValue(10.0f);
1725 Property::Index index = actor.RegisterProperty( "test-property", startValue );
1726 Stage::GetCurrent().Add(actor);
1727 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
1729 // Build the animation
1730 float durationSeconds(1.0f);
1731 Animation animation = Animation::New(durationSeconds);
1732 float targetValue(30.0f);
1733 float relativeValue(targetValue - startValue);
1735 animation.AnimateBy(Property(actor, index),
1737 AlphaFunctions::Linear,
1738 TimePeriod(delay, durationSeconds - delay));
1740 // Start the animation
1743 bool signalReceived(false);
1744 AnimationFinishCheck finishCheck(signalReceived);
1745 animation.FinishedSignal().Connect(&application, finishCheck);
1747 application.SendNotification();
1748 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
1750 // We didn't expect the animation to finish yet
1751 application.SendNotification();
1752 finishCheck.CheckSignalNotReceived();
1753 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
1755 application.SendNotification();
1756 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
1758 // We didn't expect the animation to finish yet
1759 application.SendNotification();
1760 finishCheck.CheckSignalNotReceived();
1761 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
1763 application.SendNotification();
1764 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
1766 // We did expect the animation to finish
1767 application.SendNotification();
1768 finishCheck.CheckSignalReceived();
1769 DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
1771 // Check that nothing has changed after a couple of buffer swaps
1772 application.Render(0);
1773 DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
1774 application.Render(0);
1775 DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
1779 int UtcDaliAnimationAnimateByVector2(void)
1781 TestApplication application;
1783 Actor actor = Actor::New();
1785 // Register a Vector2 property
1786 Vector2 startValue(10.0f, 10.0f);
1787 Property::Index index = actor.RegisterProperty( "test-property", startValue );
1788 Stage::GetCurrent().Add(actor);
1789 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
1791 // Build the animation
1792 float durationSeconds(2.0f);
1793 Animation animation = Animation::New(durationSeconds);
1794 Vector2 targetValue(60.0f, 60.0f);
1795 Vector2 relativeValue(targetValue - startValue);
1796 animation.AnimateBy(Property(actor, index), relativeValue);
1798 Vector2 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
1800 // Start the animation
1803 bool signalReceived(false);
1804 AnimationFinishCheck finishCheck(signalReceived);
1805 animation.FinishedSignal().Connect(&application, finishCheck);
1807 application.SendNotification();
1808 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
1810 // We didn't expect the animation to finish yet
1811 application.SendNotification();
1812 finishCheck.CheckSignalNotReceived();
1813 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), ninetyFivePercentProgress, TEST_LOCATION );
1815 application.SendNotification();
1816 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
1818 // We did expect the animation to finish
1819 application.SendNotification();
1820 finishCheck.CheckSignalReceived();
1821 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
1823 // Check that nothing has changed after a couple of buffer swaps
1824 application.Render(0);
1825 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
1826 application.Render(0);
1827 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
1831 int UtcDaliAnimationAnimateByVector2AlphaFunction(void)
1833 TestApplication application;
1835 Actor actor = Actor::New();
1837 // Register a Vector2 property
1838 Vector2 startValue(100.0f, 100.0f);
1839 Property::Index index = actor.RegisterProperty( "test-property", startValue );
1840 Stage::GetCurrent().Add(actor);
1841 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
1843 // Build the animation
1844 float durationSeconds(1.0f);
1845 Animation animation = Animation::New(durationSeconds);
1846 Vector2 targetValue(20.0f, 20.0f);
1847 Vector2 relativeValue(targetValue - startValue);
1848 animation.AnimateBy(Property(actor, index), relativeValue, AlphaFunctions::EaseOut);
1850 Vector2 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
1852 // Start the animation
1855 bool signalReceived(false);
1856 AnimationFinishCheck finishCheck(signalReceived);
1857 animation.FinishedSignal().Connect(&application, finishCheck);
1859 application.SendNotification();
1860 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
1862 // We didn't expect the animation to finish yet
1863 application.SendNotification();
1864 finishCheck.CheckSignalNotReceived();
1866 // The position should have moved more, than with a linear alpha function
1867 Vector2 current(actor.GetProperty<Vector2>(index));
1868 DALI_TEST_CHECK( current.x < ninetyFivePercentProgress.x );
1869 DALI_TEST_CHECK( current.y < ninetyFivePercentProgress.y );
1871 application.SendNotification();
1872 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
1874 // We did expect the animation to finish
1875 application.SendNotification();
1876 finishCheck.CheckSignalReceived();
1877 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
1879 // Check that nothing has changed after a couple of buffer swaps
1880 application.Render(0);
1881 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
1882 application.Render(0);
1883 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
1887 int UtcDaliAnimationAnimateByVector2TimePeriod(void)
1889 TestApplication application;
1891 Actor actor = Actor::New();
1893 // Register a Vector2 property
1894 Vector2 startValue(10.0f, 10.0f);
1895 Property::Index index = actor.RegisterProperty( "test-property", startValue );
1896 Stage::GetCurrent().Add(actor);
1897 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
1899 // Build the animation
1900 float durationSeconds(1.0f);
1901 Animation animation = Animation::New(durationSeconds);
1902 Vector2 targetValue(30.0f, 30.0f);
1903 Vector2 relativeValue(targetValue - startValue);
1905 animation.AnimateBy(Property(actor, index),
1907 TimePeriod(delay, durationSeconds - delay));
1909 // Start the animation
1912 bool signalReceived(false);
1913 AnimationFinishCheck finishCheck(signalReceived);
1914 animation.FinishedSignal().Connect(&application, finishCheck);
1916 application.SendNotification();
1917 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
1919 // We didn't expect the animation to finish yet
1920 application.SendNotification();
1921 finishCheck.CheckSignalNotReceived();
1922 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
1924 application.SendNotification();
1925 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
1927 // We didn't expect the animation to finish yet
1928 application.SendNotification();
1929 finishCheck.CheckSignalNotReceived();
1930 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
1932 application.SendNotification();
1933 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
1935 // We did expect the animation to finish
1936 application.SendNotification();
1937 finishCheck.CheckSignalReceived();
1938 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
1940 // Check that nothing has changed after a couple of buffer swaps
1941 application.Render(0);
1942 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
1943 application.Render(0);
1944 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
1948 int UtcDaliAnimationAnimateByVector2AlphaFunctionTimePeriod(void)
1950 TestApplication application;
1952 Actor actor = Actor::New();
1954 // Register a Vector2 property
1955 Vector2 startValue(5.0f, 5.0f);
1956 Property::Index index = actor.RegisterProperty( "test-property", startValue );
1957 Stage::GetCurrent().Add(actor);
1958 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
1960 // Build the animation
1961 float durationSeconds(1.0f);
1962 Animation animation = Animation::New(durationSeconds);
1963 Vector2 targetValue(10.0f, 10.0f);
1964 Vector2 relativeValue(targetValue - startValue);
1966 animation.AnimateBy(Property(actor, index),
1968 AlphaFunctions::Linear,
1969 TimePeriod(delay, durationSeconds - delay));
1971 // Start the animation
1974 bool signalReceived(false);
1975 AnimationFinishCheck finishCheck(signalReceived);
1976 animation.FinishedSignal().Connect(&application, finishCheck);
1978 application.SendNotification();
1979 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
1981 // We didn't expect the animation to finish yet
1982 application.SendNotification();
1983 finishCheck.CheckSignalNotReceived();
1984 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
1986 application.SendNotification();
1987 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
1989 // We didn't expect the animation to finish yet
1990 application.SendNotification();
1991 finishCheck.CheckSignalNotReceived();
1992 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
1994 application.SendNotification();
1995 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
1997 // We did expect the animation to finish
1998 application.SendNotification();
1999 finishCheck.CheckSignalReceived();
2000 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
2002 // Check that nothing has changed after a couple of buffer swaps
2003 application.Render(0);
2004 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
2005 application.Render(0);
2006 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
2010 int UtcDaliAnimationAnimateByVector3(void)
2012 TestApplication application;
2014 Actor actor = Actor::New();
2016 // Register a Vector3 property
2017 Vector3 startValue(10.0f, 10.0f, 10.0f);
2018 Property::Index index = actor.RegisterProperty( "test-property", startValue );
2019 Stage::GetCurrent().Add(actor);
2020 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
2022 // Build the animation
2023 float durationSeconds(2.0f);
2024 Animation animation = Animation::New(durationSeconds);
2025 Vector3 targetValue(60.0f, 60.0f, 60.0f);
2026 Vector3 relativeValue(targetValue - startValue);
2027 animation.AnimateBy(Property(actor, index), relativeValue);
2029 Vector3 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
2031 // Start the animation
2034 bool signalReceived(false);
2035 AnimationFinishCheck finishCheck(signalReceived);
2036 animation.FinishedSignal().Connect(&application, finishCheck);
2038 application.SendNotification();
2039 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
2041 // We didn't expect the animation to finish yet
2042 application.SendNotification();
2043 finishCheck.CheckSignalNotReceived();
2044 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), ninetyFivePercentProgress, TEST_LOCATION );
2046 application.SendNotification();
2047 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
2049 // We did expect the animation to finish
2050 application.SendNotification();
2051 finishCheck.CheckSignalReceived();
2052 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
2054 // Check that nothing has changed after a couple of buffer swaps
2055 application.Render(0);
2056 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
2057 application.Render(0);
2058 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
2062 int UtcDaliAnimationAnimateByVector3AlphaFunction(void)
2064 TestApplication application;
2066 Actor actor = Actor::New();
2068 // Register a Vector3 property
2069 Vector3 startValue(100.0f, 100.0f, 100.0f);
2070 Property::Index index = actor.RegisterProperty( "test-property", startValue );
2071 Stage::GetCurrent().Add(actor);
2072 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
2074 // Build the animation
2075 float durationSeconds(1.0f);
2076 Animation animation = Animation::New(durationSeconds);
2077 Vector3 targetValue(20.0f, 20.0f, 20.0f);
2078 Vector3 relativeValue(targetValue - startValue);
2079 animation.AnimateBy(Property(actor, index), relativeValue, AlphaFunctions::EaseOut);
2081 Vector3 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
2083 // Start the animation
2086 bool signalReceived(false);
2087 AnimationFinishCheck finishCheck(signalReceived);
2088 animation.FinishedSignal().Connect(&application, finishCheck);
2090 application.SendNotification();
2091 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
2093 // We didn't expect the animation to finish yet
2094 application.SendNotification();
2095 finishCheck.CheckSignalNotReceived();
2097 // The position should have moved more, than with a linear alpha function
2098 Vector3 current(actor.GetProperty<Vector3>(index));
2099 DALI_TEST_CHECK( current.x < ninetyFivePercentProgress.x );
2100 DALI_TEST_CHECK( current.y < ninetyFivePercentProgress.y );
2101 DALI_TEST_CHECK( current.z < ninetyFivePercentProgress.z );
2103 application.SendNotification();
2104 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
2106 // We did expect the animation to finish
2107 application.SendNotification();
2108 finishCheck.CheckSignalReceived();
2109 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
2111 // Check that nothing has changed after a couple of buffer swaps
2112 application.Render(0);
2113 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
2114 application.Render(0);
2115 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
2119 int UtcDaliAnimationAnimateByVector3TimePeriod(void)
2121 TestApplication application;
2123 Actor actor = Actor::New();
2125 // Register a Vector3 property
2126 Vector3 startValue(10.0f, 10.0f, 10.0f);
2127 Property::Index index = actor.RegisterProperty( "test-property", startValue );
2128 Stage::GetCurrent().Add(actor);
2129 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
2131 // Build the animation
2132 float durationSeconds(1.0f);
2133 Animation animation = Animation::New(durationSeconds);
2134 Vector3 targetValue(30.0f, 30.0f, 30.0f);
2135 Vector3 relativeValue(targetValue - startValue);
2137 animation.AnimateBy(Property(actor, index),
2139 TimePeriod(delay, durationSeconds - delay));
2141 // Start the animation
2144 bool signalReceived(false);
2145 AnimationFinishCheck finishCheck(signalReceived);
2146 animation.FinishedSignal().Connect(&application, finishCheck);
2148 application.SendNotification();
2149 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
2151 // We didn't expect the animation to finish yet
2152 application.SendNotification();
2153 finishCheck.CheckSignalNotReceived();
2154 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
2156 application.SendNotification();
2157 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
2159 // We didn't expect the animation to finish yet
2160 application.SendNotification();
2161 finishCheck.CheckSignalNotReceived();
2162 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
2164 application.SendNotification();
2165 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
2167 // We did expect the animation to finish
2168 application.SendNotification();
2169 finishCheck.CheckSignalReceived();
2170 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
2172 // Check that nothing has changed after a couple of buffer swaps
2173 application.Render(0);
2174 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
2175 application.Render(0);
2176 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
2180 int UtcDaliAnimationAnimateByVector3AlphaFunctionTimePeriod(void)
2182 TestApplication application;
2184 Actor actor = Actor::New();
2186 // Register a Vector3 property
2187 Vector3 startValue(5.0f, 5.0f, 5.0f);
2188 Property::Index index = actor.RegisterProperty( "test-property", startValue );
2189 Stage::GetCurrent().Add(actor);
2190 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
2192 // Build the animation
2193 float durationSeconds(1.0f);
2194 Animation animation = Animation::New(durationSeconds);
2195 Vector3 targetValue(10.0f, 10.0f, 10.0f);
2196 Vector3 relativeValue(targetValue - startValue);
2198 animation.AnimateBy(Property(actor, index),
2200 AlphaFunctions::Linear,
2201 TimePeriod(delay, durationSeconds - delay));
2203 // Start the animation
2206 bool signalReceived(false);
2207 AnimationFinishCheck finishCheck(signalReceived);
2208 animation.FinishedSignal().Connect(&application, finishCheck);
2210 application.SendNotification();
2211 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
2213 // We didn't expect the animation to finish yet
2214 application.SendNotification();
2215 finishCheck.CheckSignalNotReceived();
2216 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
2218 application.SendNotification();
2219 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
2221 // We didn't expect the animation to finish yet
2222 application.SendNotification();
2223 finishCheck.CheckSignalNotReceived();
2224 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
2226 application.SendNotification();
2227 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
2229 // We did expect the animation to finish
2230 application.SendNotification();
2231 finishCheck.CheckSignalReceived();
2232 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
2234 // Check that nothing has changed after a couple of buffer swaps
2235 application.Render(0);
2236 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
2237 application.Render(0);
2238 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
2242 int UtcDaliAnimationAnimateByVector4(void)
2244 TestApplication application;
2246 Actor actor = Actor::New();
2248 // Register a Vector4 property
2249 Vector4 startValue(10.0f, 10.0f, 10.0f, 10.0f);
2250 Property::Index index = actor.RegisterProperty( "test-property", startValue );
2251 Stage::GetCurrent().Add(actor);
2252 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
2254 // Build the animation
2255 float durationSeconds(2.0f);
2256 Animation animation = Animation::New(durationSeconds);
2257 Vector4 targetValue(60.0f, 60.0f, 60.0f, 60.0f);
2258 Vector4 relativeValue(targetValue - startValue);
2259 animation.AnimateBy(Property(actor, index), relativeValue);
2261 Vector4 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
2263 // Start the animation
2266 bool signalReceived(false);
2267 AnimationFinishCheck finishCheck(signalReceived);
2268 animation.FinishedSignal().Connect(&application, finishCheck);
2270 application.SendNotification();
2271 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
2273 // We didn't expect the animation to finish yet
2274 application.SendNotification();
2275 finishCheck.CheckSignalNotReceived();
2276 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), ninetyFivePercentProgress, TEST_LOCATION );
2278 application.SendNotification();
2279 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
2281 // We did expect the animation to finish
2282 application.SendNotification();
2283 finishCheck.CheckSignalReceived();
2284 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
2286 // Check that nothing has changed after a couple of buffer swaps
2287 application.Render(0);
2288 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
2289 application.Render(0);
2290 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
2294 int UtcDaliAnimationAnimateByVector4AlphaFunction(void)
2296 TestApplication application;
2298 Actor actor = Actor::New();
2300 // Register a Vector4 property
2301 Vector4 startValue(100.0f, 100.0f, 100.0f, 100.0f);
2302 Property::Index index = actor.RegisterProperty( "test-property", startValue );
2303 Stage::GetCurrent().Add(actor);
2304 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
2306 // Build the animation
2307 float durationSeconds(1.0f);
2308 Animation animation = Animation::New(durationSeconds);
2309 Vector4 targetValue(20.0f, 20.0f, 20.0f, 20.0f);
2310 Vector4 relativeValue(targetValue - startValue);
2311 animation.AnimateBy(Property(actor, index), relativeValue, AlphaFunctions::EaseOut);
2313 Vector4 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
2315 // Start the animation
2318 bool signalReceived(false);
2319 AnimationFinishCheck finishCheck(signalReceived);
2320 animation.FinishedSignal().Connect(&application, finishCheck);
2322 application.SendNotification();
2323 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
2325 // We didn't expect the animation to finish yet
2326 application.SendNotification();
2327 finishCheck.CheckSignalNotReceived();
2329 // The position should have moved more, than with a linear alpha function
2330 Vector4 current(actor.GetProperty<Vector4>(index));
2331 DALI_TEST_CHECK( current.x < ninetyFivePercentProgress.x );
2332 DALI_TEST_CHECK( current.y < ninetyFivePercentProgress.y );
2333 DALI_TEST_CHECK( current.z < ninetyFivePercentProgress.z );
2334 DALI_TEST_CHECK( current.w < ninetyFivePercentProgress.w );
2336 application.SendNotification();
2337 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
2339 // We did expect the animation to finish
2340 application.SendNotification();
2341 finishCheck.CheckSignalReceived();
2342 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
2344 // Check that nothing has changed after a couple of buffer swaps
2345 application.Render(0);
2346 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
2347 application.Render(0);
2348 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
2352 int UtcDaliAnimationAnimateByVector4TimePeriod(void)
2354 TestApplication application;
2356 Actor actor = Actor::New();
2358 // Register a Vector4 property
2359 Vector4 startValue(10.0f, 10.0f, 10.0f, 10.0f);
2360 Property::Index index = actor.RegisterProperty( "test-property", startValue );
2361 Stage::GetCurrent().Add(actor);
2362 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
2364 // Build the animation
2365 float durationSeconds(1.0f);
2366 Animation animation = Animation::New(durationSeconds);
2367 Vector4 targetValue(30.0f, 30.0f, 30.0f, 30.0f);
2368 Vector4 relativeValue(targetValue - startValue);
2370 animation.AnimateBy(Property(actor, index),
2372 TimePeriod(delay, durationSeconds - delay));
2374 // Start the animation
2377 bool signalReceived(false);
2378 AnimationFinishCheck finishCheck(signalReceived);
2379 animation.FinishedSignal().Connect(&application, finishCheck);
2381 application.SendNotification();
2382 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
2384 // We didn't expect the animation to finish yet
2385 application.SendNotification();
2386 finishCheck.CheckSignalNotReceived();
2387 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
2389 application.SendNotification();
2390 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
2392 // We didn't expect the animation to finish yet
2393 application.SendNotification();
2394 finishCheck.CheckSignalNotReceived();
2395 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
2397 application.SendNotification();
2398 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
2400 // We did expect the animation to finish
2401 application.SendNotification();
2402 finishCheck.CheckSignalReceived();
2403 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
2405 // Check that nothing has changed after a couple of buffer swaps
2406 application.Render(0);
2407 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
2408 application.Render(0);
2409 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
2413 int UtcDaliAnimationAnimateByVector4AlphaFunctionTimePeriod(void)
2415 TestApplication application;
2417 Actor actor = Actor::New();
2419 // Register a Vector4 property
2420 Vector4 startValue(5.0f, 5.0f, 5.0f, 5.0f);
2421 Property::Index index = actor.RegisterProperty( "test-property", startValue );
2422 Stage::GetCurrent().Add(actor);
2423 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
2425 // Build the animation
2426 float durationSeconds(1.0f);
2427 Animation animation = Animation::New(durationSeconds);
2428 Vector4 targetValue(10.0f, 10.0f, 10.0f, 10.0f);
2429 Vector4 relativeValue(targetValue - startValue);
2431 animation.AnimateBy(Property(actor, index),
2433 AlphaFunctions::Linear,
2434 TimePeriod(delay, durationSeconds - delay));
2436 // Start the animation
2439 bool signalReceived(false);
2440 AnimationFinishCheck finishCheck(signalReceived);
2441 animation.FinishedSignal().Connect(&application, finishCheck);
2443 application.SendNotification();
2444 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
2446 // We didn't expect the animation to finish yet
2447 application.SendNotification();
2448 finishCheck.CheckSignalNotReceived();
2449 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
2451 application.SendNotification();
2452 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
2454 // We didn't expect the animation to finish yet
2455 application.SendNotification();
2456 finishCheck.CheckSignalNotReceived();
2457 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
2459 application.SendNotification();
2460 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
2462 // We did expect the animation to finish
2463 application.SendNotification();
2464 finishCheck.CheckSignalReceived();
2465 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
2467 // Check that nothing has changed after a couple of buffer swaps
2468 application.Render(0);
2469 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
2470 application.Render(0);
2471 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
2475 int UtcDaliAnimationAnimateByActorPosition(void)
2477 TestApplication application;
2479 Actor actor = Actor::New();
2480 Vector3 startPosition(10.0f, 10.0f, 10.0f);
2481 actor.SetPosition(startPosition);
2482 Stage::GetCurrent().Add(actor);
2483 application.SendNotification();
2484 application.Render(0);
2485 DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION );
2487 // Build the animation
2488 float durationSeconds(1.0f);
2489 Animation animation = Animation::New(durationSeconds);
2490 Vector3 targetPosition(20.0f, 20.0f, 20.0f);
2491 Vector3 relativePosition(targetPosition - startPosition);
2492 animation.AnimateBy(Property(actor, Actor::POSITION), relativePosition);
2494 Vector3 ninetyFivePercentProgress(startPosition + relativePosition*0.95f);
2496 // Start the animation
2499 bool signalReceived(false);
2500 AnimationFinishCheck finishCheck(signalReceived);
2501 animation.FinishedSignal().Connect(&application, finishCheck);
2503 application.SendNotification();
2504 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
2506 // We didn't expect the animation to finish yet
2507 application.SendNotification();
2508 finishCheck.CheckSignalNotReceived();
2509 DALI_TEST_EQUALS( actor.GetCurrentPosition(), ninetyFivePercentProgress, TEST_LOCATION );
2511 application.SendNotification();
2512 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
2514 // We did expect the animation to finish
2515 application.SendNotification();
2516 finishCheck.CheckSignalReceived();
2517 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
2519 // Check that nothing has changed after a couple of buffer swaps
2520 application.Render(0);
2521 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
2522 application.Render(0);
2523 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
2527 int UtcDaliAnimationAnimateByActorPositionAlphaFunction(void)
2529 TestApplication application;
2531 Actor actor = Actor::New();
2532 Vector3 startPosition(10.0f, 10.0f, 10.0f);
2533 actor.SetPosition(startPosition);
2534 Stage::GetCurrent().Add(actor);
2535 application.SendNotification();
2536 application.Render(0);
2537 DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION );
2539 // Build the animation
2540 float durationSeconds(1.0f);
2541 Animation animation = Animation::New(durationSeconds);
2542 Vector3 targetPosition(20.0f, 20.0f, 20.0f);
2543 Vector3 relativePosition(targetPosition - startPosition);
2544 animation.AnimateBy(Property(actor, Actor::POSITION), relativePosition, AlphaFunctions::EaseOut);
2546 Vector3 ninetyFivePercentProgress(startPosition + relativePosition*0.95f);
2548 // Start the animation
2551 bool signalReceived(false);
2552 AnimationFinishCheck finishCheck(signalReceived);
2553 animation.FinishedSignal().Connect(&application, finishCheck);
2555 application.SendNotification();
2556 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
2558 // We didn't expect the animation to finish yet
2559 application.SendNotification();
2560 finishCheck.CheckSignalNotReceived();
2562 // The position should have moved more, than with a linear alpha function
2563 Vector3 current(actor.GetCurrentPosition());
2564 DALI_TEST_CHECK( current.x > ninetyFivePercentProgress.x );
2565 DALI_TEST_CHECK( current.y > ninetyFivePercentProgress.y );
2566 DALI_TEST_CHECK( current.z > ninetyFivePercentProgress.z );
2568 application.SendNotification();
2569 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
2571 // We did expect the animation to finish
2572 application.SendNotification();
2573 finishCheck.CheckSignalReceived();
2574 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
2576 // Check that nothing has changed after a couple of buffer swaps
2577 application.Render(0);
2578 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
2579 application.Render(0);
2580 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
2584 int UtcDaliAnimationAnimateByActorPositionTimePeriod(void)
2586 TestApplication application;
2588 Actor actor = Actor::New();
2589 Vector3 startPosition(10.0f, 10.0f, 10.0f);
2590 actor.SetPosition(startPosition);
2591 Stage::GetCurrent().Add(actor);
2592 application.SendNotification();
2593 application.Render(0);
2594 DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION );
2596 // Build the animation
2597 float durationSeconds(1.0f);
2598 Animation animation = Animation::New(durationSeconds);
2599 Vector3 targetPosition(20.0f, 20.0f, 20.0f);
2600 Vector3 relativePosition(targetPosition - startPosition);
2602 animation.AnimateBy(Property(actor, Actor::POSITION),
2604 TimePeriod(delay, durationSeconds - delay));
2606 Vector3 ninetyFivePercentProgress(startPosition + relativePosition*0.95f);
2608 // Start the animation
2611 bool signalReceived(false);
2612 AnimationFinishCheck finishCheck(signalReceived);
2613 animation.FinishedSignal().Connect(&application, finishCheck);
2615 application.SendNotification();
2616 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
2618 // We didn't expect the animation to finish yet
2619 application.SendNotification();
2620 finishCheck.CheckSignalNotReceived();
2621 DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION );
2623 application.SendNotification();
2624 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
2626 // We did expect the animation to finish
2627 application.SendNotification();
2628 finishCheck.CheckSignalReceived();
2629 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
2631 // Check that nothing has changed after a couple of buffer swaps
2632 application.Render(0);
2633 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
2634 application.Render(0);
2635 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
2639 int UtcDaliAnimationAnimateByActorPositionAlphaFunctionTimePeriod(void)
2641 TestApplication application;
2643 Actor actor = Actor::New();
2644 Vector3 startPosition(10.0f, 10.0f, 10.0f);
2645 actor.SetPosition(startPosition);
2646 Stage::GetCurrent().Add(actor);
2647 application.SendNotification();
2648 application.Render(0);
2649 DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION );
2651 // Build the animation
2652 float durationSeconds(1.0f);
2653 Animation animation = Animation::New(durationSeconds);
2654 Vector3 targetPosition(20.0f, 20.0f, 20.0f);
2655 Vector3 relativePosition(targetPosition - startPosition);
2657 animation.AnimateBy(Property(actor, Actor::POSITION),
2659 AlphaFunctions::Linear,
2660 TimePeriod(delay, durationSeconds - delay));
2662 Vector3 ninetyFivePercentProgress(startPosition + relativePosition*0.95f);
2664 // Start the animation
2667 bool signalReceived(false);
2668 AnimationFinishCheck finishCheck(signalReceived);
2669 animation.FinishedSignal().Connect(&application, finishCheck);
2671 application.SendNotification();
2672 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
2674 // We didn't expect the animation to finish yet
2675 application.SendNotification();
2676 finishCheck.CheckSignalNotReceived();
2677 DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION );
2679 application.SendNotification();
2680 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
2682 // We did expect the animation to finish
2683 application.SendNotification();
2684 finishCheck.CheckSignalReceived();
2685 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
2687 // Check that nothing has changed after a couple of buffer swaps
2688 application.Render(0);
2689 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
2690 application.Render(0);
2691 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
2695 int UtcDaliAnimationAnimateToBoolean(void)
2697 TestApplication application;
2699 Actor actor = Actor::New();
2701 // Register a boolean property
2702 const bool startValue(false);
2703 Property::Index index = actor.RegisterProperty( "test-property", startValue );
2704 Stage::GetCurrent().Add(actor);
2705 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
2707 // Build the animation
2708 float durationSeconds(2.0f);
2709 Animation animation = Animation::New(durationSeconds);
2710 const bool targetValue( !startValue );
2711 animation.AnimateTo(Property(actor, index), targetValue);
2713 // Start the animation
2716 bool signalReceived(false);
2717 AnimationFinishCheck finishCheck(signalReceived);
2718 animation.FinishedSignal().Connect(&application, finishCheck);
2720 application.SendNotification();
2721 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
2723 // We didn't expect the animation to finish yet
2724 application.SendNotification();
2725 finishCheck.CheckSignalNotReceived();
2726 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
2728 application.SendNotification();
2729 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
2731 // We did expect the animation to finish
2732 application.SendNotification();
2733 finishCheck.CheckSignalReceived();
2734 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == targetValue );
2736 // Check that nothing has changed after a couple of buffer swaps
2737 application.Render(0);
2738 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == targetValue );
2739 application.Render(0);
2740 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == targetValue );
2742 // Repeat with target value "false"
2743 animation = Animation::New(durationSeconds);
2744 const bool finalValue( !targetValue );
2745 animation.AnimateTo(Property(actor, index), finalValue);
2747 // Start the animation
2750 finishCheck.Reset();
2751 animation.FinishedSignal().Connect(&application, finishCheck);
2753 application.SendNotification();
2754 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
2756 // We didn't expect the animation to finish yet
2757 application.SendNotification();
2758 finishCheck.CheckSignalNotReceived();
2759 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == targetValue );
2761 application.SendNotification();
2762 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
2764 // We did expect the animation to finish
2765 application.SendNotification();
2766 finishCheck.CheckSignalReceived();
2767 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
2769 // Check that nothing has changed after a couple of buffer swaps
2770 application.Render(0);
2771 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
2772 application.Render(0);
2773 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
2777 int UtcDaliAnimationAnimateToBooleanAlphaFunction(void)
2779 TestApplication application;
2781 Actor actor = Actor::New();
2783 // Register a boolean property
2784 const bool startValue(false);
2785 Property::Index index = actor.RegisterProperty( "test-property", startValue );
2786 Stage::GetCurrent().Add(actor);
2787 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
2789 // Build the animation
2790 float durationSeconds(2.0f);
2791 Animation animation = Animation::New(durationSeconds);
2792 const bool targetValue( !startValue );
2793 animation.AnimateTo(Property(actor, "test-property"), targetValue, AlphaFunctions::EaseOut);
2795 // Start the animation
2798 bool signalReceived(false);
2799 AnimationFinishCheck finishCheck(signalReceived);
2800 animation.FinishedSignal().Connect(&application, finishCheck);
2802 application.SendNotification();
2803 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
2805 // We didn't expect the animation to finish yet
2806 application.SendNotification();
2807 finishCheck.CheckSignalNotReceived();
2808 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
2810 application.SendNotification();
2811 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
2813 // We did expect the animation to finish
2814 application.SendNotification();
2815 finishCheck.CheckSignalReceived();
2816 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == targetValue );
2818 // Check that nothing has changed after a couple of buffer swaps
2819 application.Render(0);
2820 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == targetValue );
2821 application.Render(0);
2822 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == targetValue );
2824 // Repeat with target value "false"
2825 animation = Animation::New(durationSeconds);
2826 const bool finalValue( !targetValue );
2827 animation.AnimateTo(Property(actor, index), finalValue, AlphaFunctions::EaseOut);
2829 // Start the animation
2832 finishCheck.Reset();
2833 animation.FinishedSignal().Connect(&application, finishCheck);
2835 application.SendNotification();
2836 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
2838 // We didn't expect the animation to finish yet
2839 application.SendNotification();
2840 finishCheck.CheckSignalNotReceived();
2841 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == targetValue );
2843 application.SendNotification();
2844 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
2846 // We did expect the animation to finish
2847 application.SendNotification();
2848 finishCheck.CheckSignalReceived();
2849 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
2851 // Check that nothing has changed after a couple of buffer swaps
2852 application.Render(0);
2853 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
2854 application.Render(0);
2855 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
2859 int UtcDaliAnimationAnimateToBooleanTimePeriod(void)
2861 TestApplication application;
2863 Actor actor = Actor::New();
2865 // Register a boolean property
2866 bool startValue(false);
2867 Property::Index index = actor.RegisterProperty( "test-property", startValue );
2868 Stage::GetCurrent().Add(actor);
2869 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
2871 // Build the animation
2872 float durationSeconds(2.0f);
2873 Animation animation = Animation::New(durationSeconds);
2874 bool finalValue( !startValue );
2875 float animatorDurationSeconds(durationSeconds * 0.5f);
2876 animation.AnimateTo( Property(actor, index),
2878 TimePeriod( animatorDurationSeconds ) );
2880 // Start the animation
2883 bool signalReceived(false);
2884 AnimationFinishCheck finishCheck(signalReceived);
2885 animation.FinishedSignal().Connect(&application, finishCheck);
2887 application.SendNotification();
2888 application.Render(static_cast<unsigned int>(animatorDurationSeconds*950.0f)/* 95% animator progress */);
2890 // We didn't expect the animation to finish yet
2891 application.SendNotification();
2892 finishCheck.CheckSignalNotReceived();
2893 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
2895 application.SendNotification();
2896 application.Render(static_cast<unsigned int>(animatorDurationSeconds*50.0f) + 1u/*just beyond the animator duration*/);
2898 // We didn't expect the animation to finish yet...
2899 application.SendNotification();
2900 finishCheck.CheckSignalNotReceived();
2902 // ...however we should have reached the final value
2903 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
2905 application.SendNotification();
2906 application.Render(static_cast<unsigned int>(animatorDurationSeconds*1000.0f)/*just beyond the animation duration*/);
2908 // We did expect the animation to finish
2909 application.SendNotification();
2910 finishCheck.CheckSignalReceived();
2911 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
2913 // Check that nothing has changed after a couple of buffer swaps
2914 application.Render(0);
2915 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
2916 application.Render(0);
2917 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
2921 int UtcDaliAnimationAnimateToBooleanAlphaFunctionTimePeriod(void)
2923 TestApplication application;
2925 Actor actor = Actor::New();
2927 // Register a boolean property
2928 bool startValue(false);
2929 Property::Index index = actor.RegisterProperty( "test-property", startValue );
2930 Stage::GetCurrent().Add(actor);
2931 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
2933 // Build the animation
2934 float durationSeconds(2.0f);
2935 Animation animation = Animation::New(durationSeconds);
2936 bool finalValue( !startValue );
2937 float animatorDurationSeconds(durationSeconds * 0.5f);
2938 animation.AnimateTo( Property(actor, index),
2940 AlphaFunctions::Linear,
2941 TimePeriod( animatorDurationSeconds ) );
2943 // Start the animation
2946 bool signalReceived(false);
2947 AnimationFinishCheck finishCheck(signalReceived);
2948 animation.FinishedSignal().Connect(&application, finishCheck);
2950 application.SendNotification();
2951 application.Render(static_cast<unsigned int>(animatorDurationSeconds*950.0f)/* 95% animator progress */);
2953 // We didn't expect the animation to finish yet
2954 application.SendNotification();
2955 finishCheck.CheckSignalNotReceived();
2956 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
2958 application.SendNotification();
2959 application.Render(static_cast<unsigned int>(animatorDurationSeconds*50.0f) + 1u/*just beyond the animator duration*/);
2961 // We didn't expect the animation to finish yet...
2962 application.SendNotification();
2963 finishCheck.CheckSignalNotReceived();
2965 // ...however we should have reached the final value
2966 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
2968 application.SendNotification();
2969 application.Render(static_cast<unsigned int>(animatorDurationSeconds*1000.0f)/*just beyond the animation duration*/);
2971 // We did expect the animation to finish
2972 application.SendNotification();
2973 finishCheck.CheckSignalReceived();
2974 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
2976 // Check that nothing has changed after a couple of buffer swaps
2977 application.Render(0);
2978 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
2979 application.Render(0);
2980 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
2984 int UtcDaliAnimationAnimateToFloat(void)
2986 TestApplication application;
2988 Actor actor = Actor::New();
2990 // Register a float property
2991 float startValue(10.0f);
2992 Property::Index index = actor.RegisterProperty( "test-property", startValue );
2993 Stage::GetCurrent().Add(actor);
2994 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
2996 // Build the animation
2997 float durationSeconds(2.0f);
2998 Animation animation = Animation::New(durationSeconds);
2999 float targetValue(50.0f);
3000 float relativeValue(targetValue - startValue);
3001 animation.AnimateTo(Property(actor, "test-property"), targetValue);
3003 float ninetyFivePercentProgress(startValue + relativeValue*0.95f);
3005 // Start the animation
3008 bool signalReceived(false);
3009 AnimationFinishCheck finishCheck(signalReceived);
3010 animation.FinishedSignal().Connect(&application, finishCheck);
3012 application.SendNotification();
3013 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3015 // We didn't expect the animation to finish yet
3016 application.SendNotification();
3017 finishCheck.CheckSignalNotReceived();
3018 DALI_TEST_EQUALS( actor.GetProperty<float>(index), ninetyFivePercentProgress, TEST_LOCATION );
3020 application.SendNotification();
3021 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3023 // We did expect the animation to finish
3024 application.SendNotification();
3025 finishCheck.CheckSignalReceived();
3026 DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
3030 int UtcDaliAnimationAnimateToFloatAlphaFunction(void)
3032 TestApplication application;
3034 Actor actor = Actor::New();
3036 // Register a float property
3037 float startValue(10.0f);
3038 Property::Index index = actor.RegisterProperty( "test-property", startValue );
3039 Stage::GetCurrent().Add(actor);
3040 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
3042 // Build the animation
3043 float durationSeconds(1.0f);
3044 Animation animation = Animation::New(durationSeconds);
3045 float targetValue(90.0f);
3046 float relativeValue(targetValue - startValue);
3047 animation.AnimateTo(Property(actor, index), targetValue, AlphaFunctions::EaseOut);
3049 float ninetyFivePercentProgress(startValue + relativeValue*0.95f);
3051 // Start the animation
3054 bool signalReceived(false);
3055 AnimationFinishCheck finishCheck(signalReceived);
3056 animation.FinishedSignal().Connect(&application, finishCheck);
3058 application.SendNotification();
3059 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3061 // We didn't expect the animation to finish yet
3062 application.SendNotification();
3063 finishCheck.CheckSignalNotReceived();
3065 // The position should have moved more, than with a linear alpha function
3066 float current(actor.GetProperty<float>(index));
3067 DALI_TEST_CHECK( current > ninetyFivePercentProgress );
3069 application.SendNotification();
3070 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3072 // We did expect the animation to finish
3073 application.SendNotification();
3074 finishCheck.CheckSignalReceived();
3075 DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
3079 int UtcDaliAnimationAnimateToFloatTimePeriod(void)
3081 TestApplication application;
3083 Actor actor = Actor::New();
3085 // Register a float property
3086 float startValue(10.0f);
3087 Property::Index index = actor.RegisterProperty( "test-property", startValue );
3088 Stage::GetCurrent().Add(actor);
3089 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
3091 // Build the animation
3092 float durationSeconds(1.0f);
3093 Animation animation = Animation::New(durationSeconds);
3094 float targetValue(30.0f);
3095 float relativeValue(targetValue - startValue);
3097 animation.AnimateTo(Property(actor, index),
3099 TimePeriod(delay, durationSeconds - delay));
3101 // Start the animation
3104 bool signalReceived(false);
3105 AnimationFinishCheck finishCheck(signalReceived);
3106 animation.FinishedSignal().Connect(&application, finishCheck);
3108 application.SendNotification();
3109 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
3111 // We didn't expect the animation to finish yet
3112 application.SendNotification();
3113 finishCheck.CheckSignalNotReceived();
3114 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
3116 application.SendNotification();
3117 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
3119 // We didn't expect the animation to finish yet
3120 application.SendNotification();
3121 finishCheck.CheckSignalNotReceived();
3122 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
3124 application.SendNotification();
3125 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
3127 // We did expect the animation to finish
3128 application.SendNotification();
3129 finishCheck.CheckSignalReceived();
3130 DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
3134 int UtcDaliAnimationAnimateToFloatAlphaFunctionTimePeriod(void)
3136 TestApplication application;
3138 Actor actor = Actor::New();
3140 // Register a float property
3141 float startValue(10.0f);
3142 Property::Index index = actor.RegisterProperty( "test-property", startValue );
3143 Stage::GetCurrent().Add(actor);
3144 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
3146 // Build the animation
3147 float durationSeconds(1.0f);
3148 Animation animation = Animation::New(durationSeconds);
3149 float targetValue(30.0f);
3150 float relativeValue(targetValue - startValue);
3152 animation.AnimateTo(Property(actor, index),
3154 AlphaFunctions::Linear,
3155 TimePeriod(delay, durationSeconds - delay));
3157 // Start the animation
3160 bool signalReceived(false);
3161 AnimationFinishCheck finishCheck(signalReceived);
3162 animation.FinishedSignal().Connect(&application, finishCheck);
3164 application.SendNotification();
3165 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
3167 // We didn't expect the animation to finish yet
3168 application.SendNotification();
3169 finishCheck.CheckSignalNotReceived();
3170 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
3172 application.SendNotification();
3173 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
3175 // We didn't expect the animation to finish yet
3176 application.SendNotification();
3177 finishCheck.CheckSignalNotReceived();
3178 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
3180 application.SendNotification();
3181 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
3183 // We did expect the animation to finish
3184 application.SendNotification();
3185 finishCheck.CheckSignalReceived();
3186 DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
3190 int UtcDaliAnimationAnimateToVector2(void)
3192 TestApplication application;
3194 Actor actor = Actor::New();
3196 // Register a Vector2 property
3197 Vector2 startValue(-50.0f, -50.0f);
3198 Property::Index index = actor.RegisterProperty( "test-property", startValue );
3199 Stage::GetCurrent().Add(actor);
3200 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
3202 // Build the animation
3203 float durationSeconds(2.0f);
3204 Animation animation = Animation::New(durationSeconds);
3205 Vector2 targetValue(50.0f, 50.0f);
3206 Vector2 relativeValue(targetValue - startValue);
3207 animation.AnimateTo(Property(actor, index), targetValue);
3209 Vector2 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
3211 // Start the animation
3214 bool signalReceived(false);
3215 AnimationFinishCheck finishCheck(signalReceived);
3216 animation.FinishedSignal().Connect(&application, finishCheck);
3218 application.SendNotification();
3219 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3221 // We didn't expect the animation to finish yet
3222 application.SendNotification();
3223 finishCheck.CheckSignalNotReceived();
3224 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), ninetyFivePercentProgress, TEST_LOCATION );
3226 application.SendNotification();
3227 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3229 // We did expect the animation to finish
3230 application.SendNotification();
3231 finishCheck.CheckSignalReceived();
3232 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
3236 int UtcDaliAnimationAnimateToVector2AlphaFunction(void)
3238 TestApplication application;
3240 Actor actor = Actor::New();
3242 // Register a Vector2 property
3243 Vector2 startValue(1000.0f, 1000.0f);
3244 Property::Index index = actor.RegisterProperty( "test-property", startValue );
3245 Stage::GetCurrent().Add(actor);
3246 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
3248 // Build the animation
3249 float durationSeconds(1.0f);
3250 Animation animation = Animation::New(durationSeconds);
3251 Vector2 targetValue(9000.0f, 9000.0f);
3252 Vector2 relativeValue(targetValue - startValue);
3253 animation.AnimateTo(Property(actor, "test-property"), targetValue, AlphaFunctions::EaseOut);
3255 Vector2 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
3257 // Start the animation
3260 bool signalReceived(false);
3261 AnimationFinishCheck finishCheck(signalReceived);
3262 animation.FinishedSignal().Connect(&application, finishCheck);
3264 application.SendNotification();
3265 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3267 // We didn't expect the animation to finish yet
3268 application.SendNotification();
3269 finishCheck.CheckSignalNotReceived();
3271 // The position should have moved more, than with a linear alpha function
3272 Vector2 current(actor.GetProperty<Vector2>(index));
3273 DALI_TEST_CHECK( current.x > ninetyFivePercentProgress.x );
3274 DALI_TEST_CHECK( current.y > ninetyFivePercentProgress.y );
3276 application.SendNotification();
3277 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3279 // We did expect the animation to finish
3280 application.SendNotification();
3281 finishCheck.CheckSignalReceived();
3282 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
3286 int UtcDaliAnimationAnimateToVector2TimePeriod(void)
3288 TestApplication application;
3290 Actor actor = Actor::New();
3292 // Register a Vector2 property
3293 Vector2 startValue(10.0f, 10.0f);
3294 Property::Index index = actor.RegisterProperty( "test-property", startValue );
3295 Stage::GetCurrent().Add(actor);
3296 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
3298 // Build the animation
3299 float durationSeconds(1.0f);
3300 Animation animation = Animation::New(durationSeconds);
3301 Vector2 targetValue(-10.0f, 20.0f);
3302 Vector2 relativeValue(targetValue - startValue);
3304 animation.AnimateTo(Property(actor, index),
3306 TimePeriod(delay, durationSeconds - delay));
3308 // Start the animation
3311 bool signalReceived(false);
3312 AnimationFinishCheck finishCheck(signalReceived);
3313 animation.FinishedSignal().Connect(&application, finishCheck);
3315 application.SendNotification();
3316 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
3318 // We didn't expect the animation to finish yet
3319 application.SendNotification();
3320 finishCheck.CheckSignalNotReceived();
3321 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
3323 application.SendNotification();
3324 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
3326 // We didn't expect the animation to finish yet
3327 application.SendNotification();
3328 finishCheck.CheckSignalNotReceived();
3329 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
3331 application.SendNotification();
3332 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
3334 // We did expect the animation to finish
3335 application.SendNotification();
3336 finishCheck.CheckSignalReceived();
3337 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
3341 int UtcDaliAnimationAnimateToVector2AlphaFunctionTimePeriod(void)
3343 TestApplication application;
3345 Actor actor = Actor::New();
3347 // Register a Vector2 property
3348 Vector2 startValue(10.0f, 10.0f);
3349 Property::Index index = actor.RegisterProperty( "test-property", startValue );
3350 Stage::GetCurrent().Add(actor);
3351 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
3353 // Build the animation
3354 float durationSeconds(1.0f);
3355 Animation animation = Animation::New(durationSeconds);
3356 Vector2 targetValue(30.0f, 30.0f);
3357 Vector2 relativeValue(targetValue - startValue);
3359 animation.AnimateTo(Property(actor, index),
3361 AlphaFunctions::Linear,
3362 TimePeriod(delay, durationSeconds - delay));
3364 // Start the animation
3367 bool signalReceived(false);
3368 AnimationFinishCheck finishCheck(signalReceived);
3369 animation.FinishedSignal().Connect(&application, finishCheck);
3371 application.SendNotification();
3372 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
3374 // We didn't expect the animation to finish yet
3375 application.SendNotification();
3376 finishCheck.CheckSignalNotReceived();
3377 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
3379 application.SendNotification();
3380 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
3382 // We didn't expect the animation to finish yet
3383 application.SendNotification();
3384 finishCheck.CheckSignalNotReceived();
3385 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
3387 application.SendNotification();
3388 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
3390 // We did expect the animation to finish
3391 application.SendNotification();
3392 finishCheck.CheckSignalReceived();
3393 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
3397 int UtcDaliAnimationAnimateToVector3(void)
3399 TestApplication application;
3401 Actor actor = Actor::New();
3403 // Register a Vector3 property
3404 Vector3 startValue(-50.0f, -50.0f, -50.0f);
3405 Property::Index index = actor.RegisterProperty( "test-property", startValue );
3406 Stage::GetCurrent().Add(actor);
3407 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
3409 // Build the animation
3410 float durationSeconds(2.0f);
3411 Animation animation = Animation::New(durationSeconds);
3412 Vector3 targetValue(50.0f, 50.0f, 50.0f);
3413 Vector3 relativeValue(targetValue - startValue);
3414 animation.AnimateTo(Property(actor, index), targetValue);
3416 Vector3 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
3418 // Start the animation
3421 bool signalReceived(false);
3422 AnimationFinishCheck finishCheck(signalReceived);
3423 animation.FinishedSignal().Connect(&application, finishCheck);
3425 application.SendNotification();
3426 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3428 // We didn't expect the animation to finish yet
3429 application.SendNotification();
3430 finishCheck.CheckSignalNotReceived();
3431 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), ninetyFivePercentProgress, TEST_LOCATION );
3433 application.SendNotification();
3434 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3436 // We did expect the animation to finish
3437 application.SendNotification();
3438 finishCheck.CheckSignalReceived();
3439 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
3443 int UtcDaliAnimationAnimateToVector3AlphaFunction(void)
3445 TestApplication application;
3447 Actor actor = Actor::New();
3449 // Register a Vector3 property
3450 Vector3 startValue(1000.0f, 1000.0f, 1000.0f);
3451 Property::Index index = actor.RegisterProperty( "test-property", startValue );
3452 Stage::GetCurrent().Add(actor);
3453 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
3455 // Build the animation
3456 float durationSeconds(1.0f);
3457 Animation animation = Animation::New(durationSeconds);
3458 Vector3 targetValue(9000.0f, 9000.0f, 9000.0f);
3459 Vector3 relativeValue(targetValue - startValue);
3460 animation.AnimateTo(Property(actor, index), targetValue, AlphaFunctions::EaseOut);
3462 Vector3 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
3464 // Start the animation
3467 bool signalReceived(false);
3468 AnimationFinishCheck finishCheck(signalReceived);
3469 animation.FinishedSignal().Connect(&application, finishCheck);
3471 application.SendNotification();
3472 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3474 // We didn't expect the animation to finish yet
3475 application.SendNotification();
3476 finishCheck.CheckSignalNotReceived();
3478 // The position should have moved more, than with a linear alpha function
3479 Vector3 current(actor.GetProperty<Vector3>(index));
3480 DALI_TEST_CHECK( current.x > ninetyFivePercentProgress.x );
3481 DALI_TEST_CHECK( current.y > ninetyFivePercentProgress.y );
3482 DALI_TEST_CHECK( current.z > ninetyFivePercentProgress.z );
3484 application.SendNotification();
3485 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3487 // We did expect the animation to finish
3488 application.SendNotification();
3489 finishCheck.CheckSignalReceived();
3490 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
3494 int UtcDaliAnimationAnimateToVector3TimePeriod(void)
3496 TestApplication application;
3498 Actor actor = Actor::New();
3500 // Register a Vector3 property
3501 Vector3 startValue(10.0f, 10.0f, 10.0f);
3502 Property::Index index = actor.RegisterProperty( "test-property", startValue );
3503 Stage::GetCurrent().Add(actor);
3504 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
3506 // Build the animation
3507 float durationSeconds(1.0f);
3508 Animation animation = Animation::New(durationSeconds);
3509 Vector3 targetValue(-10.0f, 20.0f, 100.0f);
3510 Vector3 relativeValue(targetValue - startValue);
3512 animation.AnimateTo(Property(actor, index),
3514 TimePeriod(delay, durationSeconds - delay));
3516 // Start the animation
3519 bool signalReceived(false);
3520 AnimationFinishCheck finishCheck(signalReceived);
3521 animation.FinishedSignal().Connect(&application, finishCheck);
3523 application.SendNotification();
3524 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
3526 // We didn't expect the animation to finish yet
3527 application.SendNotification();
3528 finishCheck.CheckSignalNotReceived();
3529 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
3531 application.SendNotification();
3532 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
3534 // We didn't expect the animation to finish yet
3535 application.SendNotification();
3536 finishCheck.CheckSignalNotReceived();
3537 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
3539 application.SendNotification();
3540 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
3542 // We did expect the animation to finish
3543 application.SendNotification();
3544 finishCheck.CheckSignalReceived();
3545 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
3549 int UtcDaliAnimationAnimateToVector3AlphaFunctionTimePeriod(void)
3551 TestApplication application;
3553 Actor actor = Actor::New();
3555 // Register a Vector3 property
3556 Vector3 startValue(10.0f, 10.0f, 10.0f);
3557 Property::Index index = actor.RegisterProperty( "test-property", startValue );
3558 Stage::GetCurrent().Add(actor);
3559 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
3561 // Build the animation
3562 float durationSeconds(1.0f);
3563 Animation animation = Animation::New(durationSeconds);
3564 Vector3 targetValue(30.0f, 30.0f, 30.0f);
3565 Vector3 relativeValue(targetValue - startValue);
3567 animation.AnimateTo(Property(actor, "test-property"),
3569 AlphaFunctions::Linear,
3570 TimePeriod(delay, durationSeconds - delay));
3572 // Start the animation
3575 bool signalReceived(false);
3576 AnimationFinishCheck finishCheck(signalReceived);
3577 animation.FinishedSignal().Connect(&application, finishCheck);
3579 application.SendNotification();
3580 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
3582 // We didn't expect the animation to finish yet
3583 application.SendNotification();
3584 finishCheck.CheckSignalNotReceived();
3585 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
3587 application.SendNotification();
3588 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
3590 // We didn't expect the animation to finish yet
3591 application.SendNotification();
3592 finishCheck.CheckSignalNotReceived();
3593 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
3595 application.SendNotification();
3596 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
3598 // We did expect the animation to finish
3599 application.SendNotification();
3600 finishCheck.CheckSignalReceived();
3601 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
3605 int UtcDaliAnimationAnimateToVector3Component(void)
3607 TestApplication application;
3609 Actor actor = Actor::New();
3611 // Register a Vector3 property
3612 Vector3 startValue(10.0f, 10.0f, 10.0f);
3613 Property::Index index = actor.RegisterProperty( "test-property", startValue );
3614 Stage::GetCurrent().Add(actor);
3615 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
3617 // Build the animation
3618 float durationSeconds(1.0f);
3619 Animation animation = Animation::New(durationSeconds);
3620 Vector3 targetValue(30.0f, 30.0f, 10.0f);
3621 Vector3 relativeValue(targetValue - startValue);
3623 animation.AnimateTo(Property(actor, "test-property", 0),
3625 AlphaFunctions::Linear,
3626 TimePeriod(delay, durationSeconds - delay));
3627 animation.AnimateTo(Property(actor, index, 1),
3629 AlphaFunctions::Linear,
3630 TimePeriod(delay, durationSeconds - delay));
3632 // Start the animation
3635 bool signalReceived(false);
3636 AnimationFinishCheck finishCheck(signalReceived);
3637 animation.FinishedSignal().Connect(&application, finishCheck);
3639 application.SendNotification();
3640 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
3642 // We didn't expect the animation to finish yet
3643 application.SendNotification();
3644 finishCheck.CheckSignalNotReceived();
3645 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
3647 application.SendNotification();
3648 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
3650 // We didn't expect the animation to finish yet
3651 application.SendNotification();
3652 finishCheck.CheckSignalNotReceived();
3653 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
3655 application.SendNotification();
3656 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
3658 // We did expect the animation to finish
3659 application.SendNotification();
3660 finishCheck.CheckSignalReceived();
3661 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
3665 int UtcDaliAnimationAnimateToVector4(void)
3667 TestApplication application;
3669 Actor actor = Actor::New();
3671 // Register a Vector4 property
3672 Vector4 startValue(-50.0f, -40.0f, -30.0f, -20.0f);
3673 Property::Index index = actor.RegisterProperty( "test-property", startValue );
3674 Stage::GetCurrent().Add(actor);
3675 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
3677 // Build the animation
3678 float durationSeconds(2.0f);
3679 Animation animation = Animation::New(durationSeconds);
3680 Vector4 targetValue(50.0f, 50.0f, 50.0f, 50.0f);
3681 Vector4 relativeValue(targetValue - startValue);
3682 animation.AnimateTo(Property(actor, index), targetValue);
3684 Vector4 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
3686 // Start the animation
3689 bool signalReceived(false);
3690 AnimationFinishCheck finishCheck(signalReceived);
3691 animation.FinishedSignal().Connect(&application, finishCheck);
3693 application.SendNotification();
3694 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3696 // We didn't expect the animation to finish yet
3697 application.SendNotification();
3698 finishCheck.CheckSignalNotReceived();
3699 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), ninetyFivePercentProgress, TEST_LOCATION );
3701 application.SendNotification();
3702 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3704 // We did expect the animation to finish
3705 application.SendNotification();
3706 finishCheck.CheckSignalReceived();
3707 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
3711 int UtcDaliAnimationAnimateToVector4AlphaFunction(void)
3713 TestApplication application;
3715 Actor actor = Actor::New();
3717 // Register a Vector4 property
3718 Vector4 startValue(1000.0f, 1000.0f, 1000.0f, 1000.0f);
3719 Property::Index index = actor.RegisterProperty( "test-property", startValue );
3720 Stage::GetCurrent().Add(actor);
3721 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
3723 // Build the animation
3724 float durationSeconds(1.0f);
3725 Animation animation = Animation::New(durationSeconds);
3726 Vector4 targetValue(9000.0f, 9000.0f, 9000.0f, 9000.0f);
3727 Vector4 relativeValue(targetValue - startValue);
3728 animation.AnimateTo(Property(actor, index), targetValue, AlphaFunctions::EaseOut);
3730 Vector4 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
3732 // Start the animation
3735 bool signalReceived(false);
3736 AnimationFinishCheck finishCheck(signalReceived);
3737 animation.FinishedSignal().Connect(&application, finishCheck);
3739 application.SendNotification();
3740 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3742 // We didn't expect the animation to finish yet
3743 application.SendNotification();
3744 finishCheck.CheckSignalNotReceived();
3746 // The position should have moved more, than with a linear alpha function
3747 Vector4 current(actor.GetProperty<Vector4>(index));
3748 DALI_TEST_CHECK( current.x > ninetyFivePercentProgress.x );
3749 DALI_TEST_CHECK( current.y > ninetyFivePercentProgress.y );
3750 DALI_TEST_CHECK( current.z > ninetyFivePercentProgress.z );
3751 DALI_TEST_CHECK( current.w > ninetyFivePercentProgress.w );
3753 application.SendNotification();
3754 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3756 // We did expect the animation to finish
3757 application.SendNotification();
3758 finishCheck.CheckSignalReceived();
3759 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
3763 int UtcDaliAnimationAnimateToVector4TimePeriod(void)
3765 TestApplication application;
3767 Actor actor = Actor::New();
3769 // Register a Vector4 property
3770 Vector4 startValue(10.0f, 10.0f, 10.0f, 10.0f);
3771 Property::Index index = actor.RegisterProperty( "test-property", startValue );
3772 Stage::GetCurrent().Add(actor);
3773 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, VECTOR4_EPSILON, TEST_LOCATION );
3775 // Build the animation
3776 float durationSeconds(1.0f);
3777 Animation animation = Animation::New(durationSeconds);
3778 Vector4 targetValue(-10.0f, 20.0f, 100.0f, 100.0f);
3779 Vector4 relativeValue(targetValue - startValue);
3781 animation.AnimateTo(Property(actor, index),
3783 TimePeriod(delay, durationSeconds - delay));
3785 // Start the animation
3788 bool signalReceived(false);
3789 AnimationFinishCheck finishCheck(signalReceived);
3790 animation.FinishedSignal().Connect(&application, finishCheck);
3792 application.SendNotification();
3793 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
3795 // We didn't expect the animation to finish yet
3796 application.SendNotification();
3797 finishCheck.CheckSignalNotReceived();
3798 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, VECTOR4_EPSILON, TEST_LOCATION );
3800 application.SendNotification();
3801 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
3803 // We didn't expect the animation to finish yet
3804 application.SendNotification();
3805 finishCheck.CheckSignalNotReceived();
3806 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue+(relativeValue*0.5f), VECTOR4_EPSILON, TEST_LOCATION );
3808 application.SendNotification();
3809 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
3811 // We did expect the animation to finish
3812 application.SendNotification();
3813 finishCheck.CheckSignalReceived();
3814 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, VECTOR4_EPSILON, TEST_LOCATION );
3818 int UtcDaliAnimationAnimateToVector4AlphaFunctionTimePeriod(void)
3820 TestApplication application;
3822 Actor actor = Actor::New();
3824 // Register a Vector4 property
3825 Vector4 startValue(10.0f, 10.0f, 10.0f, 10.0f);
3826 Property::Index index = actor.RegisterProperty( "test-property", startValue );
3827 Stage::GetCurrent().Add(actor);
3828 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
3830 // Build the animation
3831 float durationSeconds(1.0f);
3832 Animation animation = Animation::New(durationSeconds);
3833 Vector4 targetValue(30.0f, 30.0f, 30.0f, 30.0f);
3834 Vector4 relativeValue(targetValue - startValue);
3836 animation.AnimateTo(Property(actor, index),
3838 AlphaFunctions::Linear,
3839 TimePeriod(delay, durationSeconds - delay));
3841 // Start the animation
3844 bool signalReceived(false);
3845 AnimationFinishCheck finishCheck(signalReceived);
3846 animation.FinishedSignal().Connect(&application, finishCheck);
3848 application.SendNotification();
3849 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
3851 // We didn't expect the animation to finish yet
3852 application.SendNotification();
3853 finishCheck.CheckSignalNotReceived();
3854 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
3856 application.SendNotification();
3857 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
3859 // We didn't expect the animation to finish yet
3860 application.SendNotification();
3861 finishCheck.CheckSignalNotReceived();
3862 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
3864 application.SendNotification();
3865 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
3867 // We did expect the animation to finish
3868 application.SendNotification();
3869 finishCheck.CheckSignalReceived();
3870 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
3874 int UtcDaliAnimationAnimateToActorParentOrigin(void)
3876 TestApplication application;
3878 Actor actor = Actor::New();
3879 Stage::GetCurrent().Add(actor);
3880 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::TOP_LEFT, TEST_LOCATION );
3882 // Build the animation
3883 float durationSeconds(1.0f);
3884 Animation animation = Animation::New(durationSeconds);
3885 Vector3 targetParentOrigin(ParentOrigin::BOTTOM_RIGHT);
3889 animation.AnimateTo( Property(actor, Actor::PARENT_ORIGIN), targetParentOrigin );
3891 catch (Dali::DaliException& e)
3893 tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
3894 DALI_TEST_ASSERT(e, "IsPropertyAnimatable(index)", TEST_LOCATION);
3899 int UtcDaliAnimationAnimateToActorParentOriginX(void)
3901 TestApplication application;
3903 Actor actor = Actor::New();
3904 Stage::GetCurrent().Add(actor);
3905 float startValue(0.0f);
3906 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin().x, startValue, TEST_LOCATION );
3907 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::PARENT_ORIGIN_X), startValue, TEST_LOCATION );
3909 // Build the animation
3910 float durationSeconds(1.0f);
3911 Animation animation = Animation::New(durationSeconds);
3912 float targetX(1.0f);
3916 animation.AnimateTo( Property(actor, Actor::PARENT_ORIGIN_X), targetX );
3918 catch (Dali::DaliException& e)
3920 tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
3921 DALI_TEST_ASSERT(e, "IsPropertyAnimatable(index)", TEST_LOCATION);
3926 int UtcDaliAnimationAnimateToActorParentOriginY(void)
3928 TestApplication application;
3930 Actor actor = Actor::New();
3931 Stage::GetCurrent().Add(actor);
3932 float startValue(0.0f);
3933 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin().y, startValue, TEST_LOCATION );
3934 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::PARENT_ORIGIN_Y), startValue, TEST_LOCATION );
3936 // Build the animation
3937 float durationSeconds(1.0f);
3938 Animation animation = Animation::New(durationSeconds);
3939 float targetY(1.0f);
3943 animation.AnimateTo( Property(actor, Actor::PARENT_ORIGIN_Y), targetY );
3945 catch (Dali::DaliException& e)
3947 tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
3948 DALI_TEST_ASSERT(e, "IsPropertyAnimatable(index)", TEST_LOCATION);
3953 int UtcDaliAnimationAnimateToActorParentOriginZ(void)
3955 TestApplication application;
3957 Actor actor = Actor::New();
3958 Stage::GetCurrent().Add(actor);
3959 float startValue(0.5f);
3960 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin().z, startValue, TEST_LOCATION );
3961 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::PARENT_ORIGIN_Z), startValue, TEST_LOCATION );
3963 // Build the animation
3964 float durationSeconds(1.0f);
3965 Animation animation = Animation::New(durationSeconds);
3966 float targetZ(1.0f);
3970 animation.AnimateTo( Property(actor, Actor::PARENT_ORIGIN_Z), targetZ );
3972 catch (Dali::DaliException& e)
3974 tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
3975 DALI_TEST_ASSERT(e, "IsPropertyAnimatable(index)", TEST_LOCATION);
3980 int UtcDaliAnimationAnimateToActorAnchorPoint(void)
3982 TestApplication application;
3984 Actor actor = Actor::New();
3985 Stage::GetCurrent().Add(actor);
3986 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), AnchorPoint::CENTER, TEST_LOCATION );
3988 // Build the animation
3989 float durationSeconds(1.0f);
3990 Animation animation = Animation::New(durationSeconds);
3991 Vector3 targetAnchorPoint(AnchorPoint::TOP_LEFT);
3995 animation.AnimateTo( Property(actor, Actor::ANCHOR_POINT), targetAnchorPoint);
3997 catch (Dali::DaliException& e)
3999 tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
4000 DALI_TEST_ASSERT(e, "IsPropertyAnimatable(index)", TEST_LOCATION);
4005 int UtcDaliAnimationAnimateToActorAnchorPointX(void)
4007 TestApplication application;
4009 Actor actor = Actor::New();
4010 Stage::GetCurrent().Add(actor);
4011 float startValue(0.5f);
4012 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint().x, startValue, TEST_LOCATION );
4013 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::ANCHOR_POINT_X), startValue, TEST_LOCATION );
4015 // Build the animation
4016 float durationSeconds(1.0f);
4017 Animation animation = Animation::New(durationSeconds);
4018 float targetX(1.0f);
4022 animation.AnimateTo( Property(actor, Actor::ANCHOR_POINT_X), targetX );
4024 catch (Dali::DaliException& e)
4026 tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
4027 DALI_TEST_ASSERT(e, "IsPropertyAnimatable(index)", TEST_LOCATION);
4032 int UtcDaliAnimationAnimateToActorAnchorPointY(void)
4034 TestApplication application;
4036 Actor actor = Actor::New();
4037 Stage::GetCurrent().Add(actor);
4038 float startValue(0.5f);
4039 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint().y, startValue, TEST_LOCATION );
4040 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::ANCHOR_POINT_Y), startValue, TEST_LOCATION );
4042 // Build the animation
4043 float durationSeconds(1.0f);
4044 Animation animation = Animation::New(durationSeconds);
4045 float targetY(0.0f);
4049 animation.AnimateTo( Property(actor, Actor::ANCHOR_POINT_Y), targetY );
4051 catch (Dali::DaliException& e)
4053 tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
4054 DALI_TEST_ASSERT(e, "IsPropertyAnimatable(index)", TEST_LOCATION);
4059 int UtcDaliAnimationAnimateToActorAnchorPointZ(void)
4061 TestApplication application;
4063 Actor actor = Actor::New();
4064 Stage::GetCurrent().Add(actor);
4065 float startValue(0.5f);
4066 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint().z, startValue, TEST_LOCATION );
4067 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::ANCHOR_POINT_Z), startValue, TEST_LOCATION );
4069 // Build the animation
4070 float durationSeconds(1.0f);
4071 Animation animation = Animation::New(durationSeconds);
4072 float targetZ(100.0f);
4076 animation.AnimateTo( Property(actor, Actor::ANCHOR_POINT_Z), targetZ );
4078 catch (Dali::DaliException& e)
4080 tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
4081 DALI_TEST_ASSERT(e, "IsPropertyAnimatable(index)", TEST_LOCATION);
4086 int UtcDaliAnimationAnimateToActorSize(void)
4088 TestApplication application;
4090 Actor actor = Actor::New();
4091 Stage::GetCurrent().Add(actor);
4092 DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
4094 // Build the animation
4095 float durationSeconds(1.0f);
4096 Animation animation = Animation::New(durationSeconds);
4097 Vector3 targetSize(100.0f, 100.0f, 100.0f);
4098 animation.AnimateTo( Property(actor, Actor::SIZE), targetSize );
4100 Vector3 ninetyNinePercentProgress(targetSize * 0.99f);
4102 // Start the animation
4105 bool signalReceived(false);
4106 AnimationFinishCheck finishCheck(signalReceived);
4107 animation.FinishedSignal().Connect(&application, finishCheck);
4109 application.SendNotification();
4110 application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
4112 // We didn't expect the animation to finish yet
4113 application.SendNotification();
4114 finishCheck.CheckSignalNotReceived();
4115 DALI_TEST_EQUALS( actor.GetCurrentSize(), ninetyNinePercentProgress, TEST_LOCATION );
4117 application.SendNotification();
4118 application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
4120 // We did expect the animation to finish
4121 application.SendNotification();
4122 finishCheck.CheckSignalReceived();
4123 DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION );
4126 finishCheck.Reset();
4127 actor.SetSize(Vector3::ZERO);
4128 application.SendNotification();
4129 application.Render(0);
4130 DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
4132 // Repeat with a different (ease-in) alpha function
4133 animation = Animation::New(durationSeconds);
4134 animation.AnimateTo( Property(actor, Actor::SIZE), targetSize, AlphaFunctions::EaseIn);
4135 animation.FinishedSignal().Connect(&application, finishCheck);
4138 application.SendNotification();
4139 application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
4141 // We didn't expect the animation to finish yet
4142 application.SendNotification();
4143 finishCheck.CheckSignalNotReceived();
4145 // The size should have travelled less, than with a linear alpha function
4146 Vector3 current(actor.GetCurrentSize());
4147 DALI_TEST_CHECK( current.x > 0.0f );
4148 DALI_TEST_CHECK( current.y > 0.0f );
4149 DALI_TEST_CHECK( current.z > 0.0f );
4150 DALI_TEST_CHECK( current.x < ninetyNinePercentProgress.x );
4151 DALI_TEST_CHECK( current.y < ninetyNinePercentProgress.y );
4152 DALI_TEST_CHECK( current.z < ninetyNinePercentProgress.z );
4154 application.SendNotification();
4155 application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
4157 // We did expect the animation to finish
4158 application.SendNotification();
4159 finishCheck.CheckSignalReceived();
4160 DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION );
4163 finishCheck.Reset();
4164 actor.SetSize(Vector3::ZERO);
4165 application.SendNotification();
4166 application.Render(0);
4167 DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
4169 // Repeat with a delay
4171 animation = Animation::New(durationSeconds);
4172 animation.AnimateTo( Property(actor, Actor::SIZE), targetSize, AlphaFunctions::Linear, TimePeriod(delay, durationSeconds - delay));
4173 animation.FinishedSignal().Connect(&application, finishCheck);
4176 application.SendNotification();
4177 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
4179 // We didn't expect the animation to finish yet
4180 application.SendNotification();
4181 finishCheck.CheckSignalNotReceived();
4182 DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
4184 application.SendNotification();
4185 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
4187 // We did expect the animation to finish
4188 application.SendNotification();
4189 finishCheck.CheckSignalReceived();
4190 DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION );
4194 int UtcDaliAnimationAnimateToActorSizeWidth(void)
4196 TestApplication application;
4198 Actor actor = Actor::New();
4199 Stage::GetCurrent().Add(actor);
4200 float startValue(0.0f);
4201 DALI_TEST_EQUALS( actor.GetCurrentSize().width, startValue, TEST_LOCATION );
4202 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SIZE_WIDTH), startValue, TEST_LOCATION );
4204 // Build the animation
4205 float durationSeconds(1.0f);
4206 Animation animation = Animation::New(durationSeconds);
4207 float targetWidth(10.0f);
4208 animation.AnimateTo( Property(actor, Actor::SIZE_WIDTH), targetWidth );
4210 float fiftyPercentProgress(startValue + (targetWidth - startValue)*0.5f);
4212 // Start the animation
4215 bool signalReceived(false);
4216 AnimationFinishCheck finishCheck(signalReceived);
4217 animation.FinishedSignal().Connect(&application, finishCheck);
4219 application.SendNotification();
4220 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
4222 // We didn't expect the animation to finish yet
4223 application.SendNotification();
4224 finishCheck.CheckSignalNotReceived();
4225 DALI_TEST_EQUALS( actor.GetCurrentSize().width, fiftyPercentProgress, TEST_LOCATION );
4226 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SIZE_WIDTH), fiftyPercentProgress, TEST_LOCATION );
4228 application.SendNotification();
4229 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
4231 // We did expect the animation to finish
4232 application.SendNotification();
4233 finishCheck.CheckSignalReceived();
4234 DALI_TEST_EQUALS( actor.GetCurrentSize().width, targetWidth, TEST_LOCATION );
4235 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SIZE_WIDTH), targetWidth, TEST_LOCATION );
4239 int UtcDaliAnimationAnimateToActorSizeHeight(void)
4241 TestApplication application;
4243 Actor actor = Actor::New();
4244 Stage::GetCurrent().Add(actor);
4245 float startValue(0.0f);
4246 DALI_TEST_EQUALS( actor.GetCurrentSize().height, startValue, TEST_LOCATION );
4247 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SIZE_HEIGHT), startValue, TEST_LOCATION );
4249 // Build the animation
4250 float durationSeconds(1.0f);
4251 Animation animation = Animation::New(durationSeconds);
4252 float targetHeight(-10.0f);
4253 animation.AnimateTo( Property(actor, Actor::SIZE_HEIGHT), targetHeight );
4255 float fiftyPercentProgress(startValue + (targetHeight - startValue)*0.5f);
4257 // Start the animation
4260 bool signalReceived(false);
4261 AnimationFinishCheck finishCheck(signalReceived);
4262 animation.FinishedSignal().Connect(&application, finishCheck);
4264 application.SendNotification();
4265 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
4267 // We didn't expect the animation to finish yet
4268 application.SendNotification();
4269 finishCheck.CheckSignalNotReceived();
4270 DALI_TEST_EQUALS( actor.GetCurrentSize().height, fiftyPercentProgress, TEST_LOCATION );
4271 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SIZE_HEIGHT), fiftyPercentProgress, TEST_LOCATION );
4273 application.SendNotification();
4274 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
4276 // We did expect the animation to finish
4277 application.SendNotification();
4278 finishCheck.CheckSignalReceived();
4279 DALI_TEST_EQUALS( actor.GetCurrentSize().height, targetHeight, TEST_LOCATION );
4280 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SIZE_HEIGHT), targetHeight, TEST_LOCATION );
4284 int UtcDaliAnimationAnimateToActorSizeDepth(void)
4286 TestApplication application;
4288 Actor actor = Actor::New();
4289 Stage::GetCurrent().Add(actor);
4290 float startValue(0.0f);
4291 DALI_TEST_EQUALS( actor.GetCurrentSize().depth, startValue, TEST_LOCATION );
4292 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SIZE_DEPTH), startValue, TEST_LOCATION );
4294 // Build the animation
4295 float durationSeconds(1.0f);
4296 Animation animation = Animation::New(durationSeconds);
4297 float targetDepth(-10.0f);
4298 animation.AnimateTo( Property(actor, Actor::SIZE_DEPTH), targetDepth );
4300 float fiftyPercentProgress(startValue + (targetDepth - startValue)*0.5f);
4302 // Start the animation
4305 bool signalReceived(false);
4306 AnimationFinishCheck finishCheck(signalReceived);
4307 animation.FinishedSignal().Connect(&application, finishCheck);
4309 application.SendNotification();
4310 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
4312 // We didn't expect the animation to finish yet
4313 application.SendNotification();
4314 finishCheck.CheckSignalNotReceived();
4315 DALI_TEST_EQUALS( actor.GetCurrentSize().depth, fiftyPercentProgress, TEST_LOCATION );
4316 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SIZE_DEPTH), fiftyPercentProgress, TEST_LOCATION );
4318 application.SendNotification();
4319 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
4321 // We did expect the animation to finish
4322 application.SendNotification();
4323 finishCheck.CheckSignalReceived();
4324 DALI_TEST_EQUALS( actor.GetCurrentSize().depth, targetDepth, TEST_LOCATION );
4325 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SIZE_DEPTH), targetDepth, TEST_LOCATION );
4329 int UtcDaliAnimationAnimateToActorPosition(void)
4331 TestApplication application;
4333 Actor actor = Actor::New();
4334 Stage::GetCurrent().Add(actor);
4335 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
4337 // Build the animation
4338 float durationSeconds(1.0f);
4339 Animation animation = Animation::New(durationSeconds);
4340 Vector3 targetPosition(200.0f, 200.0f, 200.0f);
4341 animation.AnimateTo(Property(actor, Actor::POSITION), targetPosition);
4343 Vector3 seventyFivePercentProgress(targetPosition * 0.75f);
4345 // Start the animation
4348 bool signalReceived(false);
4349 AnimationFinishCheck finishCheck(signalReceived);
4350 animation.FinishedSignal().Connect(&application, finishCheck);
4352 application.SendNotification();
4353 application.Render(static_cast<unsigned int>(durationSeconds*750.0f)/* 75% progress */);
4355 // We didn't expect the animation to finish yet
4356 application.SendNotification();
4357 finishCheck.CheckSignalNotReceived();
4358 DALI_TEST_EQUALS( actor.GetCurrentPosition(), seventyFivePercentProgress, TEST_LOCATION );
4360 application.SendNotification();
4361 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
4363 // We did expect the animation to finish
4364 application.SendNotification();
4365 finishCheck.CheckSignalReceived();
4366 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
4370 int UtcDaliAnimationAnimateToActorPositionX(void)
4372 TestApplication application;
4374 Actor actor = Actor::New();
4375 Stage::GetCurrent().Add(actor);
4376 float startValue(0.0f);
4377 DALI_TEST_EQUALS( actor.GetCurrentPosition().x, startValue, TEST_LOCATION );
4378 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_X), startValue, TEST_LOCATION );
4379 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_Y), startValue, TEST_LOCATION );
4380 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_Z), startValue, TEST_LOCATION );
4382 // Build the animation
4383 float durationSeconds(1.0f);
4384 Animation animation = Animation::New(durationSeconds);
4385 float targetX(1.0f);
4386 animation.AnimateTo( Property(actor, Actor::POSITION_X), targetX );
4388 float fiftyPercentProgress(startValue + (targetX - startValue)*0.5f);
4390 // Start the animation
4393 bool signalReceived(false);
4394 AnimationFinishCheck finishCheck(signalReceived);
4395 animation.FinishedSignal().Connect(&application, finishCheck);
4397 application.SendNotification();
4398 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
4400 // We didn't expect the animation to finish yet
4401 application.SendNotification();
4402 finishCheck.CheckSignalNotReceived();
4403 DALI_TEST_EQUALS( actor.GetCurrentPosition().x, fiftyPercentProgress, TEST_LOCATION );
4404 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_X), fiftyPercentProgress, TEST_LOCATION );
4405 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_Y), startValue, TEST_LOCATION );
4406 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_Z), startValue, TEST_LOCATION );
4408 application.SendNotification();
4409 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
4411 // We did expect the animation to finish
4412 application.SendNotification();
4413 finishCheck.CheckSignalReceived();
4414 DALI_TEST_EQUALS( actor.GetCurrentPosition().x, targetX, TEST_LOCATION );
4415 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_X), targetX, TEST_LOCATION );
4416 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_Y), startValue, TEST_LOCATION );
4417 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_Z), startValue, TEST_LOCATION );
4421 int UtcDaliAnimationAnimateToActorPositionY(void)
4423 TestApplication application;
4425 Actor actor = Actor::New();
4426 Stage::GetCurrent().Add(actor);
4427 float startValue(0.0f);
4428 DALI_TEST_EQUALS( actor.GetCurrentPosition().y, startValue, TEST_LOCATION );
4429 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_X), startValue, TEST_LOCATION );
4430 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_Y), startValue, TEST_LOCATION );
4431 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_Z), startValue, TEST_LOCATION );
4433 // Build the animation
4434 float durationSeconds(1.0f);
4435 Animation animation = Animation::New(durationSeconds);
4436 float targetY(10.0f);
4437 animation.AnimateTo( Property(actor, Actor::POSITION_Y), targetY );
4439 float fiftyPercentProgress(startValue + (targetY - startValue)*0.5f);
4441 // Start the animation
4444 bool signalReceived(false);
4445 AnimationFinishCheck finishCheck(signalReceived);
4446 animation.FinishedSignal().Connect(&application, finishCheck);
4448 application.SendNotification();
4449 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
4451 // We didn't expect the animation to finish yet
4452 application.SendNotification();
4453 finishCheck.CheckSignalNotReceived();
4454 DALI_TEST_EQUALS( actor.GetCurrentPosition().y, fiftyPercentProgress, TEST_LOCATION );
4455 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_X), startValue, TEST_LOCATION );
4456 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_Y), fiftyPercentProgress, TEST_LOCATION );
4457 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_Z), startValue, TEST_LOCATION );
4459 application.SendNotification();
4460 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
4462 // We did expect the animation to finish
4463 application.SendNotification();
4464 finishCheck.CheckSignalReceived();
4465 DALI_TEST_EQUALS( actor.GetCurrentPosition().y, targetY, TEST_LOCATION );
4466 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_X), startValue, TEST_LOCATION );
4467 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_Y), targetY, TEST_LOCATION );
4468 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_Z), startValue, TEST_LOCATION );
4472 int UtcDaliAnimationAnimateToActorPositionZ(void)
4474 TestApplication application;
4476 Actor actor = Actor::New();
4477 Stage::GetCurrent().Add(actor);
4478 float startValue(0.0f);
4479 DALI_TEST_EQUALS( actor.GetCurrentPosition().z, startValue, TEST_LOCATION );
4480 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_X), startValue, TEST_LOCATION );
4481 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_Y), startValue, TEST_LOCATION );
4482 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_Z), startValue, TEST_LOCATION );
4484 // Build the animation
4485 float durationSeconds(1.0f);
4486 Animation animation = Animation::New(durationSeconds);
4487 float targetZ(-5.0f);
4488 animation.AnimateTo( Property(actor, Actor::POSITION_Z), targetZ );
4490 float fiftyPercentProgress(startValue + (targetZ - startValue)*0.5f);
4492 // Start the animation
4495 bool signalReceived(false);
4496 AnimationFinishCheck finishCheck(signalReceived);
4497 animation.FinishedSignal().Connect(&application, finishCheck);
4499 application.SendNotification();
4500 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
4502 // We didn't expect the animation to finish yet
4503 application.SendNotification();
4504 finishCheck.CheckSignalNotReceived();
4505 DALI_TEST_EQUALS( actor.GetCurrentPosition().z, fiftyPercentProgress, TEST_LOCATION );
4506 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_X), startValue, TEST_LOCATION );
4507 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_Y), startValue, TEST_LOCATION );
4508 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_Z), fiftyPercentProgress, TEST_LOCATION );
4510 application.SendNotification();
4511 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
4513 // We did expect the animation to finish
4514 application.SendNotification();
4515 finishCheck.CheckSignalReceived();
4516 DALI_TEST_EQUALS( actor.GetCurrentPosition().z, targetZ, TEST_LOCATION );
4517 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_X), startValue, TEST_LOCATION );
4518 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_Y), startValue, TEST_LOCATION );
4519 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_Z), targetZ, TEST_LOCATION );
4523 int UtcDaliAnimationAnimateToActorPositionAlphaFunction(void)
4525 TestApplication application;
4527 Actor actor = Actor::New();
4528 Stage::GetCurrent().Add(actor);
4529 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
4531 // Build the animation
4532 float durationSeconds(1.0f);
4533 Animation animation = Animation::New(durationSeconds);
4534 Vector3 targetPosition(200.0f, 200.0f, 200.0f);
4535 animation.AnimateTo(Property(actor, Actor::POSITION), targetPosition, AlphaFunctions::EaseIn);
4537 Vector3 seventyFivePercentProgress(targetPosition * 0.75f);
4539 // Start the animation
4542 bool signalReceived(false);
4543 AnimationFinishCheck finishCheck(signalReceived);
4544 animation.FinishedSignal().Connect(&application, finishCheck);
4546 application.SendNotification();
4547 application.Render(static_cast<unsigned int>(durationSeconds*750.0f)/* 75% progress */);
4549 // We didn't expect the animation to finish yet
4550 application.SendNotification();
4551 finishCheck.CheckSignalNotReceived();
4553 // The position should have moved less, than with a linear alpha function
4554 Vector3 current(actor.GetCurrentPosition());
4555 DALI_TEST_CHECK( current.x > Vector3::ZERO.x );
4556 DALI_TEST_CHECK( current.y > Vector3::ZERO.y );
4557 DALI_TEST_CHECK( current.z > Vector3::ZERO.z );
4558 DALI_TEST_CHECK( current.x < seventyFivePercentProgress.x );
4559 DALI_TEST_CHECK( current.y < seventyFivePercentProgress.y );
4560 DALI_TEST_CHECK( current.z < seventyFivePercentProgress.z );
4562 application.SendNotification();
4563 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
4565 // We did expect the animation to finish
4566 application.SendNotification();
4567 finishCheck.CheckSignalReceived();
4568 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
4572 int UtcDaliAnimationAnimateToActorPositionTimePeriod(void)
4574 TestApplication application;
4576 Actor actor = Actor::New();
4577 Stage::GetCurrent().Add(actor);
4578 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
4580 // Build the animation
4581 float durationSeconds(1.0f);
4582 Animation animation = Animation::New(durationSeconds);
4583 Vector3 targetPosition(200.0f, 200.0f, 200.0f);
4585 animation.AnimateTo( Property(actor, Actor::POSITION),
4587 TimePeriod( delay, durationSeconds - delay ) );
4589 Vector3 seventyFivePercentProgress(targetPosition * 0.75f);
4591 // Start the animation
4594 bool signalReceived(false);
4595 AnimationFinishCheck finishCheck(signalReceived);
4596 animation.FinishedSignal().Connect(&application, finishCheck);
4598 application.SendNotification();
4599 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
4601 // We didn't expect the animation to finish yet
4602 application.SendNotification();
4603 finishCheck.CheckSignalNotReceived();
4604 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
4606 application.SendNotification();
4607 application.Render(static_cast<unsigned int>(durationSeconds*500.0f*0.75)/* 7/8 animation progress, 3/4 animator progress */);
4609 // We didn't expect the animation to finish yet
4610 application.SendNotification();
4611 finishCheck.CheckSignalNotReceived();
4612 DALI_TEST_EQUALS( actor.GetCurrentPosition(), seventyFivePercentProgress, TEST_LOCATION );
4614 application.SendNotification();
4615 application.Render(static_cast<unsigned int>(durationSeconds*500.0f*0.25) + 1u/*just beyond the animation duration*/);
4617 // We did expect the animation to finish
4618 application.SendNotification();
4619 finishCheck.CheckSignalReceived();
4620 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
4624 int UtcDaliAnimationAnimateToActorPositionAlphaFunctionTimePeriod(void)
4626 TestApplication application;
4628 Actor actor = Actor::New();
4629 Stage::GetCurrent().Add(actor);
4630 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
4632 // Build the animation
4633 float durationSeconds(1.0f);
4634 Animation animation = Animation::New(durationSeconds);
4635 Vector3 targetPosition(200.0f, 200.0f, 200.0f);
4637 animation.AnimateTo( Property(actor, Actor::POSITION),
4639 AlphaFunctions::Linear,
4640 TimePeriod( delay, durationSeconds - delay ) );
4642 Vector3 seventyFivePercentProgress(targetPosition * 0.75f);
4644 // Start the animation
4647 bool signalReceived(false);
4648 AnimationFinishCheck finishCheck(signalReceived);
4649 animation.FinishedSignal().Connect(&application, finishCheck);
4651 application.SendNotification();
4652 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
4654 // We didn't expect the animation to finish yet
4655 application.SendNotification();
4656 finishCheck.CheckSignalNotReceived();
4657 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
4659 application.SendNotification();
4660 application.Render(static_cast<unsigned int>(durationSeconds*500.0f*0.75)/* 7/8 animation progress, 3/4 animator progress */);
4662 // We didn't expect the animation to finish yet
4663 application.SendNotification();
4664 finishCheck.CheckSignalNotReceived();
4665 DALI_TEST_EQUALS( actor.GetCurrentPosition(), seventyFivePercentProgress, TEST_LOCATION );
4667 application.SendNotification();
4668 application.Render(static_cast<unsigned int>(durationSeconds*500.0f*0.25) + 1u/*just beyond the animation duration*/);
4670 // We did expect the animation to finish
4671 application.SendNotification();
4672 finishCheck.CheckSignalReceived();
4673 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
4677 int UtcDaliAnimationAnimateToActorRotationAngleAxis(void)
4679 TestApplication application;
4681 Actor actor = Actor::New();
4682 actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
4683 Stage::GetCurrent().Add(actor);
4684 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
4686 // Build the animation
4687 float durationSeconds(1.0f);
4688 Animation animation = Animation::New(durationSeconds);
4689 Degree targetRotationDegrees(90.0f);
4690 Radian targetRotationRadians(targetRotationDegrees);
4691 animation.AnimateTo( Property(actor, Actor::ROTATION), AngleAxis(targetRotationRadians, Vector3::YAXIS) );
4693 // Start the animation
4696 bool signalReceived(false);
4697 AnimationFinishCheck finishCheck(signalReceived);
4698 animation.FinishedSignal().Connect(&application, finishCheck);
4700 application.SendNotification();
4701 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
4703 // We didn't expect the animation to finish yet
4704 application.SendNotification();
4705 finishCheck.CheckSignalNotReceived();
4706 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.25f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
4708 application.SendNotification();
4709 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
4711 // We didn't expect the animation to finish yet
4712 application.SendNotification();
4713 finishCheck.CheckSignalNotReceived();
4714 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.5f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
4716 application.SendNotification();
4717 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
4719 // We didn't expect the animation to finish yet
4720 application.SendNotification();
4721 finishCheck.CheckSignalNotReceived();
4722 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.75f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
4724 application.SendNotification();
4725 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
4727 // We did expect the animation to finish
4728 application.SendNotification();
4729 finishCheck.CheckSignalReceived();
4730 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
4734 int UtcDaliAnimationAnimateToActorRotationQuaternion(void)
4736 TestApplication application;
4738 Actor actor = Actor::New();
4739 actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
4740 Stage::GetCurrent().Add(actor);
4741 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
4743 // Build the animation
4744 float durationSeconds(1.0f);
4745 Animation animation = Animation::New(durationSeconds);
4746 Degree targetRotationDegrees(90.0f);
4747 Radian targetRotationRadians(targetRotationDegrees);
4748 Quaternion targetRotation(targetRotationRadians, Vector3::YAXIS);
4749 animation.AnimateTo( Property(actor, Actor::ROTATION), targetRotation );
4751 // Start the animation
4754 bool signalReceived(false);
4755 AnimationFinishCheck finishCheck(signalReceived);
4756 animation.FinishedSignal().Connect(&application, finishCheck);
4758 application.SendNotification();
4759 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
4761 // We didn't expect the animation to finish yet
4762 application.SendNotification();
4763 finishCheck.CheckSignalNotReceived();
4764 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.25f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
4766 application.SendNotification();
4767 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
4769 // We didn't expect the animation to finish yet
4770 application.SendNotification();
4771 finishCheck.CheckSignalNotReceived();
4772 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.5f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
4774 application.SendNotification();
4775 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
4777 // We didn't expect the animation to finish yet
4778 application.SendNotification();
4779 finishCheck.CheckSignalNotReceived();
4780 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.75f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
4782 application.SendNotification();
4783 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
4785 // We did expect the animation to finish
4786 application.SendNotification();
4787 finishCheck.CheckSignalReceived();
4788 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
4792 int UtcDaliAnimationAnimateToActorRotationAlphaFunction(void)
4794 TestApplication application;
4796 Actor actor = Actor::New();
4797 actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
4798 Stage::GetCurrent().Add(actor);
4799 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
4801 // Build the animation
4802 float durationSeconds(1.0f);
4803 Animation animation = Animation::New(durationSeconds);
4804 Degree targetRotationDegrees(90.0f);
4805 Radian targetRotationRadians(targetRotationDegrees);
4806 animation.AnimateTo( Property(actor, Actor::ROTATION), AngleAxis(targetRotationDegrees, Vector3::YAXIS), AlphaFunctions::EaseIn);
4808 // Start the animation
4811 bool signalReceived(false);
4812 AnimationFinishCheck finishCheck(signalReceived);
4813 animation.FinishedSignal().Connect(&application, finishCheck);
4815 application.SendNotification();
4816 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
4818 // We didn't expect the animation to finish yet
4819 application.SendNotification();
4820 finishCheck.CheckSignalNotReceived();
4821 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(0.25f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
4823 application.SendNotification();
4824 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
4826 // We didn't expect the animation to finish yet
4827 application.SendNotification();
4828 finishCheck.CheckSignalNotReceived();
4829 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(0.5f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
4831 application.SendNotification();
4832 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
4834 // We didn't expect the animation to finish yet
4835 application.SendNotification();
4836 finishCheck.CheckSignalNotReceived();
4837 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(0.75f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
4839 application.SendNotification();
4840 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
4842 // We did expect the animation to finish
4843 application.SendNotification();
4844 finishCheck.CheckSignalReceived();
4845 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
4849 int UtcDaliAnimationAnimateToActorRotationTimePeriod(void)
4851 TestApplication application;
4853 Actor actor = Actor::New();
4854 actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
4855 Stage::GetCurrent().Add(actor);
4856 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
4858 // Build the animation
4859 float durationSeconds(1.0f);
4860 Animation animation = Animation::New(durationSeconds);
4861 Degree targetRotationDegrees(90.0f);
4862 Radian targetRotationRadians(targetRotationDegrees);
4864 animation.AnimateTo( Property(actor, Actor::ROTATION), AngleAxis(targetRotationDegrees, Vector3::YAXIS), TimePeriod(delay, durationSeconds - delay));
4866 // Start the animation
4869 bool signalReceived(false);
4870 AnimationFinishCheck finishCheck(signalReceived);
4871 animation.FinishedSignal().Connect(&application, finishCheck);
4873 application.SendNotification();
4874 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
4876 // We didn't expect the animation to finish yet
4877 application.SendNotification();
4878 finishCheck.CheckSignalNotReceived();
4879 float progress = max(0.0f, 0.25f - delay) / (1.0f - delay);
4880 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * progress, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
4882 application.SendNotification();
4883 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
4885 // We didn't expect the animation to finish yet
4886 application.SendNotification();
4887 finishCheck.CheckSignalNotReceived();
4888 progress = max(0.0f, 0.5f - delay) / (1.0f - delay);
4889 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * progress, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
4891 application.SendNotification();
4892 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
4894 // We didn't expect the animation to finish yet
4895 application.SendNotification();
4896 finishCheck.CheckSignalNotReceived();
4897 progress = max(0.0f, 0.75f - delay) / (1.0f - delay);
4898 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * progress, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
4900 application.SendNotification();
4901 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
4903 // We did expect the animation to finish
4904 application.SendNotification();
4905 finishCheck.CheckSignalReceived();
4906 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
4910 int UtcDaliAnimationAnimateToActorRotationAlphaFunctionTimePeriod(void)
4912 TestApplication application;
4914 Actor actor = Actor::New();
4915 actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
4916 Stage::GetCurrent().Add(actor);
4917 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
4919 // Build the animation
4920 float durationSeconds(1.0f);
4921 Animation animation = Animation::New(durationSeconds);
4922 Degree targetRotationDegrees(90.0f);
4923 Radian targetRotationRadians(targetRotationDegrees);
4925 animation.AnimateTo( Property(actor, Actor::ROTATION), AngleAxis(targetRotationDegrees, Vector3::YAXIS), AlphaFunctions::EaseIn, TimePeriod(delay, durationSeconds - delay));
4927 // Start the animation
4930 bool signalReceived(false);
4931 AnimationFinishCheck finishCheck(signalReceived);
4932 animation.FinishedSignal().Connect(&application, finishCheck);
4934 application.SendNotification();
4935 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
4937 // We didn't expect the animation to finish yet
4938 application.SendNotification();
4939 finishCheck.CheckSignalNotReceived();
4940 float progress = max(0.0f, 0.25f - delay) / (1.0f - delay);
4941 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
4943 application.SendNotification();
4944 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
4946 // We didn't expect the animation to finish yet
4947 application.SendNotification();
4948 finishCheck.CheckSignalNotReceived();
4949 progress = max(0.0f, 0.5f - delay) / (1.0f - delay);
4950 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
4952 application.SendNotification();
4953 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
4955 // We didn't expect the animation to finish yet
4956 application.SendNotification();
4957 finishCheck.CheckSignalNotReceived();
4958 progress = max(0.0f, 0.75f - delay) / (1.0f - delay);
4959 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
4961 application.SendNotification();
4962 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
4964 // We did expect the animation to finish
4965 application.SendNotification();
4966 finishCheck.CheckSignalReceived();
4967 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
4971 int UtcDaliAnimationAnimateToActorScale(void)
4973 TestApplication application;
4975 Actor actor = Actor::New();
4976 Stage::GetCurrent().Add(actor);
4977 DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
4979 // Build the animation
4980 float durationSeconds(1.0f);
4981 Animation animation = Animation::New(durationSeconds);
4982 Vector3 targetScale(2.0f, 2.0f, 2.0f);
4983 animation.AnimateTo( Property(actor, Actor::SCALE), targetScale );
4985 Vector3 ninetyNinePercentProgress(Vector3::ONE + (targetScale - Vector3::ONE)*0.99f);
4987 // Start the animation
4990 bool signalReceived(false);
4991 AnimationFinishCheck finishCheck(signalReceived);
4992 animation.FinishedSignal().Connect(&application, finishCheck);
4994 application.SendNotification();
4995 application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
4997 // We didn't expect the animation to finish yet
4998 application.SendNotification();
4999 finishCheck.CheckSignalNotReceived();
5000 DALI_TEST_EQUALS( actor.GetCurrentScale(), ninetyNinePercentProgress, TEST_LOCATION );
5002 application.SendNotification();
5003 application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
5005 // We did expect the animation to finish
5006 application.SendNotification();
5007 finishCheck.CheckSignalReceived();
5008 DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
5011 finishCheck.Reset();
5012 actor.SetScale(Vector3::ONE);
5013 application.SendNotification();
5014 application.Render(0);
5015 DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
5017 // Repeat with a different (ease-in) alpha function
5018 animation = Animation::New(durationSeconds);
5019 animation.AnimateTo( Property(actor, Actor::SCALE), targetScale, AlphaFunctions::EaseIn);
5020 animation.FinishedSignal().Connect(&application, finishCheck);
5023 application.SendNotification();
5024 application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
5026 // We didn't expect the animation to finish yet
5027 application.SendNotification();
5028 finishCheck.CheckSignalNotReceived();
5030 // The scale should have grown less, than with a linear alpha function
5031 Vector3 current(actor.GetCurrentScale());
5032 DALI_TEST_CHECK( current.x > 1.0f );
5033 DALI_TEST_CHECK( current.y > 1.0f );
5034 DALI_TEST_CHECK( current.z > 1.0f );
5035 DALI_TEST_CHECK( current.x < ninetyNinePercentProgress.x );
5036 DALI_TEST_CHECK( current.y < ninetyNinePercentProgress.y );
5037 DALI_TEST_CHECK( current.z < ninetyNinePercentProgress.z );
5039 application.SendNotification();
5040 application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
5042 // We did expect the animation to finish
5043 application.SendNotification();
5044 finishCheck.CheckSignalReceived();
5045 DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
5048 finishCheck.Reset();
5049 actor.SetScale(Vector3::ONE);
5050 application.SendNotification();
5051 application.Render(0);
5052 DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
5054 // Repeat with a delay
5056 animation = Animation::New(durationSeconds);
5057 animation.AnimateTo( Property(actor, Actor::SCALE), targetScale, AlphaFunctions::Linear, TimePeriod(delay, durationSeconds - delay));
5058 animation.FinishedSignal().Connect(&application, finishCheck);
5061 application.SendNotification();
5062 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
5064 // We didn't expect the animation to finish yet
5065 application.SendNotification();
5066 finishCheck.CheckSignalNotReceived();
5067 DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
5069 application.SendNotification();
5070 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
5072 // We did expect the animation to finish
5073 application.SendNotification();
5074 finishCheck.CheckSignalReceived();
5075 DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
5079 int UtcDaliAnimationAnimateToActorScaleX(void)
5081 TestApplication application;
5083 Actor actor = Actor::New();
5084 Stage::GetCurrent().Add(actor);
5085 float startValue(1.0f);
5086 DALI_TEST_EQUALS( actor.GetCurrentScale().x, startValue, TEST_LOCATION );
5087 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_X), startValue, TEST_LOCATION );
5088 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_Y), startValue, TEST_LOCATION );
5089 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_Z), startValue, TEST_LOCATION );
5091 // Build the animation
5092 float durationSeconds(1.0f);
5093 Animation animation = Animation::New(durationSeconds);
5094 float targetX(10.0f);
5095 animation.AnimateTo( Property(actor, Actor::SCALE_X), targetX );
5097 float fiftyPercentProgress(startValue + (targetX - startValue)*0.5f);
5099 // Start the animation
5102 bool signalReceived(false);
5103 AnimationFinishCheck finishCheck(signalReceived);
5104 animation.FinishedSignal().Connect(&application, finishCheck);
5106 application.SendNotification();
5107 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
5109 // We didn't expect the animation to finish yet
5110 application.SendNotification();
5111 finishCheck.CheckSignalNotReceived();
5112 DALI_TEST_EQUALS( actor.GetCurrentScale().x, fiftyPercentProgress, TEST_LOCATION );
5113 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_X), fiftyPercentProgress, TEST_LOCATION );
5114 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_Y), startValue, TEST_LOCATION );
5115 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_Z), startValue, TEST_LOCATION );
5117 application.SendNotification();
5118 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
5120 // We did expect the animation to finish
5121 application.SendNotification();
5122 finishCheck.CheckSignalReceived();
5123 DALI_TEST_EQUALS( actor.GetCurrentScale().x, targetX, TEST_LOCATION );
5124 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_X), targetX, TEST_LOCATION );
5125 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_Y), startValue, TEST_LOCATION );
5126 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_Z), startValue, TEST_LOCATION );
5130 int UtcDaliAnimationAnimateToActorScaleY(void)
5132 TestApplication application;
5134 Actor actor = Actor::New();
5135 Stage::GetCurrent().Add(actor);
5136 float startValue(1.0f);
5137 DALI_TEST_EQUALS( actor.GetCurrentScale().y, startValue, TEST_LOCATION );
5138 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_X), startValue, TEST_LOCATION );
5139 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_Y), startValue, TEST_LOCATION );
5140 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_Z), startValue, TEST_LOCATION );
5142 // Build the animation
5143 float durationSeconds(1.0f);
5144 Animation animation = Animation::New(durationSeconds);
5145 float targetY(1000.0f);
5146 animation.AnimateTo( Property(actor, Actor::SCALE_Y), targetY );
5148 float fiftyPercentProgress(startValue + (targetY - startValue)*0.5f);
5150 // Start the animation
5153 bool signalReceived(false);
5154 AnimationFinishCheck finishCheck(signalReceived);
5155 animation.FinishedSignal().Connect(&application, finishCheck);
5157 application.SendNotification();
5158 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
5160 // We didn't expect the animation to finish yet
5161 application.SendNotification();
5162 finishCheck.CheckSignalNotReceived();
5163 DALI_TEST_EQUALS( actor.GetCurrentScale().y, fiftyPercentProgress, TEST_LOCATION );
5164 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_X), startValue, TEST_LOCATION );
5165 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_Y), fiftyPercentProgress, TEST_LOCATION );
5166 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_Z), startValue, TEST_LOCATION );
5168 application.SendNotification();
5169 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
5171 // We did expect the animation to finish
5172 application.SendNotification();
5173 finishCheck.CheckSignalReceived();
5174 DALI_TEST_EQUALS( actor.GetCurrentScale().y, targetY, TEST_LOCATION );
5175 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_X), startValue, TEST_LOCATION );
5176 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_Y), targetY, TEST_LOCATION );
5177 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_Z), startValue, TEST_LOCATION );
5181 int UtcDaliAnimationAnimateToActorScaleZ(void)
5183 TestApplication application;
5185 Actor actor = Actor::New();
5186 Stage::GetCurrent().Add(actor);
5187 float startValue(1.0f);
5188 DALI_TEST_EQUALS( actor.GetCurrentScale().z, startValue, TEST_LOCATION );
5189 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_X), startValue, TEST_LOCATION );
5190 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_Y), startValue, TEST_LOCATION );
5191 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_Z), startValue, TEST_LOCATION );
5193 // Build the animation
5194 float durationSeconds(1.0f);
5195 Animation animation = Animation::New(durationSeconds);
5196 float targetZ(-1000.0f);
5197 animation.AnimateTo( Property(actor, Actor::SCALE_Z), targetZ );
5199 float fiftyPercentProgress(startValue + (targetZ - startValue)*0.5f);
5201 // Start the animation
5204 bool signalReceived(false);
5205 AnimationFinishCheck finishCheck(signalReceived);
5206 animation.FinishedSignal().Connect(&application, finishCheck);
5208 application.SendNotification();
5209 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
5211 // We didn't expect the animation to finish yet
5212 application.SendNotification();
5213 finishCheck.CheckSignalNotReceived();
5214 DALI_TEST_EQUALS( actor.GetCurrentScale().z, fiftyPercentProgress, TEST_LOCATION );
5215 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_X), startValue, TEST_LOCATION );
5216 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_Y), startValue, TEST_LOCATION );
5217 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_Z), fiftyPercentProgress, TEST_LOCATION );
5219 application.SendNotification();
5220 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
5222 // We did expect the animation to finish
5223 application.SendNotification();
5224 finishCheck.CheckSignalReceived();
5225 DALI_TEST_EQUALS( actor.GetCurrentScale().z, targetZ, TEST_LOCATION );
5226 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_X), startValue, TEST_LOCATION );
5227 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_Y), startValue, TEST_LOCATION );
5228 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_Z), targetZ, TEST_LOCATION );
5232 int UtcDaliAnimationAnimateToActorColor(void)
5234 TestApplication application;
5236 Actor actor = Actor::New();
5237 Stage::GetCurrent().Add(actor);
5238 DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
5240 // Build the animation
5241 float durationSeconds(1.0f);
5242 Animation animation = Animation::New(durationSeconds);
5243 Vector4 targetColor(Color::RED);
5244 animation.AnimateTo( Property(actor, Actor::COLOR), targetColor );
5246 Vector4 tenPercentProgress(Vector4(1.0f, 0.9f, 0.9f, 1.0f));
5247 Vector4 twentyPercentProgress(Vector4(1.0f, 0.8f, 0.8f, 1.0f));
5249 // Start the animation
5252 bool signalReceived(false);
5253 AnimationFinishCheck finishCheck(signalReceived);
5254 animation.FinishedSignal().Connect(&application, finishCheck);
5256 application.SendNotification();
5257 application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% progress */);
5259 // We didn't expect the animation to finish yet
5260 application.SendNotification();
5261 finishCheck.CheckSignalNotReceived();
5262 DALI_TEST_EQUALS( actor.GetCurrentColor(), tenPercentProgress, TEST_LOCATION );
5264 application.SendNotification();
5265 application.Render(static_cast<unsigned int>(durationSeconds*900.0f) + 1u/*just beyond the animation duration*/);
5267 // We did expect the animation to finish
5268 application.SendNotification();
5269 finishCheck.CheckSignalReceived();
5270 DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION );
5273 finishCheck.Reset();
5274 actor.SetColor(Color::WHITE);
5275 application.SendNotification();
5276 application.Render(0);
5277 DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
5279 // Repeat with a different (ease-in) alpha function
5280 animation = Animation::New(durationSeconds);
5281 animation.AnimateTo( Property(actor, Actor::COLOR), targetColor, AlphaFunctions::EaseIn);
5282 animation.FinishedSignal().Connect(&application, finishCheck);
5285 application.SendNotification();
5286 application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% progress */);
5288 // We didn't expect the animation to finish yet
5289 application.SendNotification();
5290 finishCheck.CheckSignalNotReceived();
5292 // The color should have changed less, than with a linear alpha function
5293 Vector4 current(actor.GetCurrentColor());
5294 DALI_TEST_CHECK( current.x == 1.0f ); // doesn't change
5295 DALI_TEST_CHECK( current.y < 1.0f );
5296 DALI_TEST_CHECK( current.y > tenPercentProgress.y );
5297 DALI_TEST_CHECK( current.z < 1.0f );
5298 DALI_TEST_CHECK( current.z > tenPercentProgress.z );
5299 DALI_TEST_CHECK( current.w == 1.0f ); // doesn't change
5301 application.SendNotification();
5302 application.Render(static_cast<unsigned int>(durationSeconds*900.0f) + 1u/*just beyond the animation duration*/);
5304 // We did expect the animation to finish
5305 application.SendNotification();
5306 finishCheck.CheckSignalReceived();
5307 DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION );
5310 finishCheck.Reset();
5311 actor.SetColor(Color::WHITE);
5312 application.SendNotification();
5313 application.Render(0);
5314 DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
5316 // Repeat with a shorter animator duration
5317 float animatorDuration = 0.5f;
5318 animation = Animation::New(durationSeconds);
5319 animation.AnimateTo( Property(actor, Actor::COLOR), targetColor, AlphaFunctions::Linear, TimePeriod(animatorDuration));
5320 animation.FinishedSignal().Connect(&application, finishCheck);
5323 application.SendNotification();
5324 application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% animation progress, 20% animator progress */);
5326 // We didn't expect the animation to finish yet
5327 application.SendNotification();
5328 finishCheck.CheckSignalNotReceived();
5329 DALI_TEST_EQUALS( actor.GetCurrentColor(), twentyPercentProgress, TEST_LOCATION );
5331 application.SendNotification();
5332 application.Render(static_cast<unsigned int>(durationSeconds*400.0f)/* 50% animation progress, 100% animator progress */);
5334 // We didn't expect the animation to finish yet
5335 application.SendNotification();
5336 finishCheck.CheckSignalNotReceived();
5337 DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION );
5339 application.SendNotification();
5340 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
5342 // We did expect the animation to finish
5343 application.SendNotification();
5344 finishCheck.CheckSignalReceived();
5345 DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION );
5349 int UtcDaliAnimationAnimateToActorColorRed(void)
5351 TestApplication application;
5353 Actor actor = Actor::New();
5354 Stage::GetCurrent().Add(actor);
5355 float startValue(1.0f);
5356 DALI_TEST_EQUALS( actor.GetCurrentColor().r, startValue, TEST_LOCATION );
5357 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
5358 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
5359 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
5360 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), startValue, TEST_LOCATION );
5362 // Build the animation
5363 float durationSeconds(1.0f);
5364 Animation animation = Animation::New(durationSeconds);
5365 float targetRed(0.5f);
5366 animation.AnimateTo( Property(actor, Actor::COLOR_RED), targetRed );
5368 float fiftyPercentProgress(startValue + (targetRed - startValue)*0.5f);
5370 // Start the animation
5373 bool signalReceived(false);
5374 AnimationFinishCheck finishCheck(signalReceived);
5375 animation.FinishedSignal().Connect(&application, finishCheck);
5377 application.SendNotification();
5378 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
5380 // We didn't expect the animation to finish yet
5381 application.SendNotification();
5382 finishCheck.CheckSignalNotReceived();
5383 DALI_TEST_EQUALS( actor.GetCurrentColor().r, fiftyPercentProgress, TEST_LOCATION );
5384 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), fiftyPercentProgress, TEST_LOCATION );
5385 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
5386 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
5387 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), startValue, TEST_LOCATION );
5389 application.SendNotification();
5390 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
5392 // We did expect the animation to finish
5393 application.SendNotification();
5394 finishCheck.CheckSignalReceived();
5395 DALI_TEST_EQUALS( actor.GetCurrentColor().r, targetRed, TEST_LOCATION );
5396 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), targetRed, TEST_LOCATION );
5397 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
5398 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
5399 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), startValue, TEST_LOCATION );
5403 int UtcDaliAnimationAnimateToActorColorGreen(void)
5405 TestApplication application;
5407 Actor actor = Actor::New();
5408 Stage::GetCurrent().Add(actor);
5409 float startValue(1.0f);
5410 DALI_TEST_EQUALS( actor.GetCurrentColor().g, startValue, TEST_LOCATION );
5411 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
5412 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
5413 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
5414 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), startValue, TEST_LOCATION );
5416 // Build the animation
5417 float durationSeconds(1.0f);
5418 Animation animation = Animation::New(durationSeconds);
5419 float targetGreen(0.5f);
5420 animation.AnimateTo( Property(actor, Actor::COLOR_GREEN), targetGreen );
5422 float fiftyPercentProgress(startValue + (targetGreen - startValue)*0.5f);
5424 // Start the animation
5427 bool signalReceived(false);
5428 AnimationFinishCheck finishCheck(signalReceived);
5429 animation.FinishedSignal().Connect(&application, finishCheck);
5431 application.SendNotification();
5432 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
5434 // We didn't expect the animation to finish yet
5435 application.SendNotification();
5436 finishCheck.CheckSignalNotReceived();
5437 DALI_TEST_EQUALS( actor.GetCurrentColor().g, fiftyPercentProgress, TEST_LOCATION );
5438 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
5439 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), fiftyPercentProgress, TEST_LOCATION );
5440 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
5441 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), startValue, TEST_LOCATION );
5443 application.SendNotification();
5444 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
5446 // We did expect the animation to finish
5447 application.SendNotification();
5448 finishCheck.CheckSignalReceived();
5449 DALI_TEST_EQUALS( actor.GetCurrentColor().g, targetGreen, TEST_LOCATION );
5450 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
5451 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), targetGreen, TEST_LOCATION );
5452 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
5453 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), startValue, TEST_LOCATION );
5457 int UtcDaliAnimationAnimateToActorColorBlue(void)
5459 TestApplication application;
5461 Actor actor = Actor::New();
5462 Stage::GetCurrent().Add(actor);
5463 float startValue(1.0f);
5464 DALI_TEST_EQUALS( actor.GetCurrentColor().b, startValue, TEST_LOCATION );
5465 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
5466 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
5467 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
5468 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), startValue, TEST_LOCATION );
5470 // Build the animation
5471 float durationSeconds(1.0f);
5472 Animation animation = Animation::New(durationSeconds);
5473 float targetBlue(0.5f);
5474 animation.AnimateTo( Property(actor, Actor::COLOR_BLUE), targetBlue );
5476 float fiftyPercentProgress(startValue + (targetBlue - startValue)*0.5f);
5478 // Start the animation
5481 bool signalReceived(false);
5482 AnimationFinishCheck finishCheck(signalReceived);
5483 animation.FinishedSignal().Connect(&application, finishCheck);
5485 application.SendNotification();
5486 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
5488 // We didn't expect the animation to finish yet
5489 application.SendNotification();
5490 finishCheck.CheckSignalNotReceived();
5491 DALI_TEST_EQUALS( actor.GetCurrentColor().b, fiftyPercentProgress, TEST_LOCATION );
5492 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
5493 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
5494 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), fiftyPercentProgress, TEST_LOCATION );
5495 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), startValue, TEST_LOCATION );
5497 application.SendNotification();
5498 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
5500 // We did expect the animation to finish
5501 application.SendNotification();
5502 finishCheck.CheckSignalReceived();
5503 DALI_TEST_EQUALS( actor.GetCurrentColor().b, targetBlue, TEST_LOCATION );
5504 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
5505 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
5506 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), targetBlue, TEST_LOCATION );
5507 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), startValue, TEST_LOCATION );
5511 int UtcDaliAnimationAnimateToActorColorAlpha(void)
5513 TestApplication application;
5515 Actor actor = Actor::New();
5516 Stage::GetCurrent().Add(actor);
5517 float startValue(1.0f);
5518 DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
5519 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
5520 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
5521 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
5522 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), startValue, TEST_LOCATION );
5524 // Build the animation
5525 float durationSeconds(1.0f);
5526 Animation animation = Animation::New(durationSeconds);
5527 float targetAlpha(0.5f);
5528 animation.AnimateTo( Property(actor, Actor::COLOR_ALPHA), targetAlpha );
5530 float fiftyPercentProgress(startValue + (targetAlpha - startValue)*0.5f);
5532 // Start the animation
5535 bool signalReceived(false);
5536 AnimationFinishCheck finishCheck(signalReceived);
5537 animation.FinishedSignal().Connect(&application, finishCheck);
5539 application.SendNotification();
5540 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
5542 // We didn't expect the animation to finish yet
5543 application.SendNotification();
5544 finishCheck.CheckSignalNotReceived();
5545 DALI_TEST_EQUALS( actor.GetCurrentColor().a, fiftyPercentProgress, TEST_LOCATION );
5546 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
5547 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
5548 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
5549 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), fiftyPercentProgress, TEST_LOCATION );
5551 application.SendNotification();
5552 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
5554 // We did expect the animation to finish
5555 application.SendNotification();
5556 finishCheck.CheckSignalReceived();
5557 DALI_TEST_EQUALS( actor.GetCurrentColor().a, targetAlpha, TEST_LOCATION );
5558 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
5559 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
5560 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
5561 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), targetAlpha, TEST_LOCATION );
5567 int UtcDaliAnimationKeyFrames01(void)
5569 TestApplication application;
5571 KeyFrames keyFrames = KeyFrames::New();
5572 DALI_TEST_EQUALS(keyFrames.GetType(), Property::NONE, TEST_LOCATION);
5574 keyFrames.Add(0.0f, 0.1f);
5575 keyFrames.Add(0.2f, 0.5f);
5576 keyFrames.Add(0.4f, 0.0f);
5577 keyFrames.Add(0.6f, 1.0f);
5578 keyFrames.Add(0.8f, 0.7f);
5579 keyFrames.Add(1.0f, 0.9f);
5581 DALI_TEST_EQUALS(keyFrames.GetType(), Property::FLOAT, TEST_LOCATION);
5585 keyFrames.Add(1.9f, false);
5587 catch (Dali::DaliException& e)
5589 tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
5590 DALI_TEST_ASSERT(e, "mType == value.GetType()", TEST_LOCATION);
5595 int UtcDaliAnimationKeyFrames02(void)
5597 TestApplication application;
5599 KeyFrames keyFrames = KeyFrames::New();
5600 DALI_TEST_EQUALS(keyFrames.GetType(), Property::NONE, TEST_LOCATION);
5602 keyFrames.Add(0.0f, true);
5603 keyFrames.Add(0.2f, false);
5604 keyFrames.Add(0.4f, false);
5605 keyFrames.Add(0.6f, true);
5606 keyFrames.Add(0.8f, true);
5607 keyFrames.Add(1.0f, false);
5609 DALI_TEST_EQUALS(keyFrames.GetType(), Property::BOOLEAN, TEST_LOCATION);
5613 keyFrames.Add(0.7f, Vector3(1.0f, 1.0f, 1.0f));
5615 catch (Dali::DaliException& e)
5617 tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
5618 DALI_TEST_ASSERT(e, "mType == value.GetType()", TEST_LOCATION);
5624 int UtcDaliAnimationKeyFrames03(void)
5626 TestApplication application;
5628 KeyFrames keyFrames = KeyFrames::New();
5629 DALI_TEST_EQUALS(keyFrames.GetType(), Property::NONE, TEST_LOCATION);
5631 keyFrames.Add(0.0f, Vector2(0.0f, 0.0f));
5632 keyFrames.Add(0.2f, Vector2(1.0f, 1.0f));
5633 keyFrames.Add(0.4f, Vector2(2.0f, 2.0f));
5634 keyFrames.Add(0.6f, Vector2(3.0f, 5.0f));
5635 keyFrames.Add(0.8f, Vector2(4.0f, 3.0f));
5636 keyFrames.Add(1.0f, Vector2(6.0f, 2.0f));
5638 DALI_TEST_EQUALS(keyFrames.GetType(), Property::VECTOR2, TEST_LOCATION);
5642 keyFrames.Add(0.7f, Vector3(1.0f, 1.0f, 1.0f));
5644 catch (Dali::DaliException& e)
5646 tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
5647 DALI_TEST_ASSERT(e, "mType == value.GetType()", TEST_LOCATION);
5653 int UtcDaliAnimationKeyFrames04(void)
5655 TestApplication application;
5657 KeyFrames keyFrames = KeyFrames::New();
5658 DALI_TEST_EQUALS(keyFrames.GetType(), Property::NONE, TEST_LOCATION);
5660 keyFrames.Add(0.0f, Vector3(0.0f, 4.0f, 0.0f));
5661 keyFrames.Add(0.2f, Vector3(1.0f, 3.0f, 1.0f));
5662 keyFrames.Add(0.4f, Vector3(2.0f, 2.0f, 2.0f));
5663 keyFrames.Add(0.6f, Vector3(3.0f, 2.0f, 5.0f));
5664 keyFrames.Add(0.8f, Vector3(4.0f, 4.0f, 3.0f));
5665 keyFrames.Add(1.0f, Vector3(6.0f, 8.0f, 2.0f));
5667 DALI_TEST_EQUALS(keyFrames.GetType(), Property::VECTOR3, TEST_LOCATION);
5671 keyFrames.Add(0.7f, 1.0f);
5673 catch (Dali::DaliException& e)
5675 tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
5676 DALI_TEST_ASSERT(e, "mType == value.GetType()", TEST_LOCATION);
5681 int UtcDaliAnimationKeyFrames05(void)
5683 TestApplication application;
5685 KeyFrames keyFrames = KeyFrames::New();
5686 DALI_TEST_EQUALS(keyFrames.GetType(), Property::NONE, TEST_LOCATION);
5688 keyFrames.Add(0.0f, Vector4(0.0f, 0.0f, 0.0f, 0.0f));
5689 keyFrames.Add(0.2f, Vector4(1.0f, 1.0f, 1.0f, 1.0f));
5690 keyFrames.Add(0.4f, Vector4(2.0f, 2.0f, 2.0f, 2.0f));
5691 keyFrames.Add(0.6f, Vector4(3.0f, 5.0f, 3.0f, 5.0f));
5692 keyFrames.Add(0.8f, Vector4(4.0f, 3.0f, 4.0f, 3.0f));
5693 keyFrames.Add(1.0f, Vector4(6.0f, 2.0f, 6.0f, 2.0f));
5695 DALI_TEST_EQUALS(keyFrames.GetType(), Property::VECTOR4, TEST_LOCATION);
5699 keyFrames.Add(0.7f, Quaternion(1.717f, Vector3::XAXIS));
5701 catch (Dali::DaliException& e)
5703 tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
5704 DALI_TEST_ASSERT(e, "mType == value.GetType()", TEST_LOCATION);
5710 int UtcDaliAnimationKeyFrames06(void)
5712 TestApplication application;
5714 KeyFrames keyFrames = KeyFrames::New();
5715 DALI_TEST_EQUALS(keyFrames.GetType(), Property::NONE, TEST_LOCATION);
5717 keyFrames.Add(0.0f, Quaternion(1.717f, Vector3::XAXIS));
5718 keyFrames.Add(0.2f, Quaternion(2.0f, Vector3::XAXIS));
5719 keyFrames.Add(0.4f, Quaternion(3.0f, Vector3::ZAXIS));
5720 keyFrames.Add(0.6f, Quaternion(4.0f, Vector3(1.0f, 1.0f, 1.0f)));
5721 keyFrames.Add(0.8f, AngleAxis(Degree(90), Vector3::XAXIS));
5722 keyFrames.Add(1.0f, Quaternion(3.0f, Vector3::YAXIS));
5724 DALI_TEST_EQUALS(keyFrames.GetType(), Property::ROTATION, TEST_LOCATION);
5728 keyFrames.Add(0.7f, 1.1f);
5730 catch (Dali::DaliException& e)
5732 tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
5733 DALI_TEST_ASSERT(e, "mType == value.GetType()", TEST_LOCATION);
5742 int UtcDaliAnimationAnimateBetweenActorColorAlpha(void)
5744 TestApplication application;
5746 float startValue(1.0f);
5747 Actor actor = Actor::New();
5748 actor.SetColor(Vector4(startValue, startValue, startValue, startValue));
5749 Stage::GetCurrent().Add(actor);
5751 DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
5752 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
5753 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
5754 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
5755 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), startValue, TEST_LOCATION );
5757 // Build the animation
5758 float durationSeconds(1.0f);
5759 Animation animation = Animation::New(durationSeconds);
5761 KeyFrames keyFrames = KeyFrames::New();
5762 keyFrames.Add(0.0f, 0.1f);
5763 keyFrames.Add(0.2f, 0.5f);
5764 keyFrames.Add(0.4f, 0.0f);
5765 keyFrames.Add(0.6f, 1.0f);
5766 keyFrames.Add(0.8f, 0.7f);
5767 keyFrames.Add(1.0f, 0.9f);
5769 animation.AnimateBetween( Property(actor, Actor::COLOR_ALPHA), keyFrames );
5771 // Start the animation
5774 bool signalReceived(false);
5775 AnimationFinishCheck finishCheck(signalReceived);
5776 animation.FinishedSignal().Connect(&application, finishCheck);
5777 application.SendNotification();
5778 application.Render(0);
5779 application.SendNotification();
5780 finishCheck.CheckSignalNotReceived();
5781 DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.1f, TEST_LOCATION );
5783 application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% progress */);
5784 application.SendNotification();
5785 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
5786 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
5787 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
5788 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.3f, 0.01f, TEST_LOCATION );
5789 DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.3f, 0.01f, TEST_LOCATION );
5791 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 30% progress */);
5792 application.SendNotification();
5793 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
5794 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
5795 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
5796 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.25f, 0.01f, TEST_LOCATION );
5797 DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.25f, 0.01f, TEST_LOCATION );
5799 application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 40% progress */);
5800 application.SendNotification();
5801 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
5802 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
5803 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
5804 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.0f, 0.01f, TEST_LOCATION );
5805 DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.0f, 0.01f, TEST_LOCATION );
5807 application.Render(static_cast<unsigned int>(durationSeconds*400.0f)/* 80% progress */);
5808 application.SendNotification();
5809 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
5810 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
5811 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
5812 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.7f, 0.01f, TEST_LOCATION );
5813 DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.7f, 0.01f, TEST_LOCATION );
5815 application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 90% progress */);
5816 application.SendNotification();
5817 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
5818 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
5819 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
5820 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.8f, 0.01f, TEST_LOCATION );
5821 DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.8f, 0.01f, TEST_LOCATION );
5823 application.Render(static_cast<unsigned int>(durationSeconds*100.0f)+1/* 100% progress */);
5824 application.SendNotification();
5825 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
5826 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
5827 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
5828 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.9f, 0.01f, TEST_LOCATION );
5829 DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.9f, 0.01f, TEST_LOCATION );
5831 // We did expect the animation to finish
5833 finishCheck.CheckSignalReceived();
5838 int UtcDaliAnimationAnimateBetweenActorColor(void)
5840 TestApplication application;
5842 float startValue(1.0f);
5843 Actor actor = Actor::New();
5844 actor.SetColor(Vector4(startValue, startValue, startValue, startValue));
5845 Stage::GetCurrent().Add(actor);
5847 DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
5848 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
5849 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
5850 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
5851 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), startValue, TEST_LOCATION );
5853 // Build the animation
5854 float durationSeconds(1.0f);
5855 Animation animation = Animation::New(durationSeconds);
5857 KeyFrames keyFrames = KeyFrames::New();
5858 keyFrames.Add(0.0f, Vector4(0.1f, 0.2f, 0.3f, 0.4f));
5859 keyFrames.Add(0.5f, Vector4(0.9f, 0.8f, 0.7f, 0.6f));
5860 keyFrames.Add(1.0f, Vector4(1.0f, 1.0f, 1.0f, 1.0f));
5862 animation.AnimateBetween( Property(actor, Actor::COLOR), keyFrames );
5864 // Start the animation
5867 bool signalReceived(false);
5868 AnimationFinishCheck finishCheck(signalReceived);
5869 animation.FinishedSignal().Connect(&application, finishCheck);
5870 application.SendNotification();
5871 application.Render(0);
5872 application.SendNotification();
5873 finishCheck.CheckSignalNotReceived();
5874 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), 0.1f, 0.01f, TEST_LOCATION );
5875 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 0.2f, 0.01f, TEST_LOCATION );
5876 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), 0.3f, 0.01f, TEST_LOCATION );
5877 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.4f, 0.01f, TEST_LOCATION );
5879 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
5880 application.SendNotification();
5881 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), 0.5f, 0.01f, TEST_LOCATION );
5882 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 0.5f, 0.01f, TEST_LOCATION );
5883 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), 0.5f, 0.01f, TEST_LOCATION );
5884 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.5f, 0.01f, TEST_LOCATION );
5886 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
5887 application.SendNotification();
5888 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), 0.9f, 0.01f, TEST_LOCATION );
5889 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 0.8f, 0.01f, TEST_LOCATION );
5890 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), 0.7f, 0.01f, TEST_LOCATION );
5891 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.6f, 0.01f, TEST_LOCATION );
5893 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
5894 application.SendNotification();
5895 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), 0.95f, 0.01f, TEST_LOCATION );
5896 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 0.90f, 0.01f, TEST_LOCATION );
5897 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), 0.85f, 0.01f, TEST_LOCATION );
5898 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.80f, 0.01f, TEST_LOCATION );
5900 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
5901 application.SendNotification();
5902 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), 1.0f, 0.01f, TEST_LOCATION );
5903 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 1.0f, 0.01f, TEST_LOCATION );
5904 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), 1.0f, 0.01f, TEST_LOCATION );
5905 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 1.0f, 0.01f, TEST_LOCATION );
5907 // We did expect the animation to finish
5909 finishCheck.CheckSignalReceived();
5913 int UtcDaliAnimationAnimateBetweenActorVisible01(void)
5915 TestApplication application;
5917 Actor actor = Actor::New();
5918 AngleAxis aa(Degree(90), Vector3::XAXIS);
5919 actor.SetRotation(aa.angle, aa.axis);
5920 Stage::GetCurrent().Add(actor);
5922 application.SendNotification();
5923 application.Render(0);
5925 DALI_TEST_EQUALS( actor.IsVisible(), true, TEST_LOCATION );
5927 // Build the animation
5928 float durationSeconds(1.0f);
5929 Animation animation = Animation::New(durationSeconds);
5931 KeyFrames keyFrames = KeyFrames::New();
5932 keyFrames.Add(0.0f, false);
5933 keyFrames.Add(0.2f, true);
5934 keyFrames.Add(0.4f, true);
5935 keyFrames.Add(0.8f, false);
5936 keyFrames.Add(1.0f, true);
5938 animation.AnimateBetween( Property(actor, Actor::VISIBLE), keyFrames );
5940 // Start the animation
5943 bool signalReceived(false);
5944 AnimationFinishCheck finishCheck(signalReceived);
5945 animation.FinishedSignal().Connect(&application, finishCheck);
5946 application.SendNotification();
5947 application.SendNotification();
5948 application.Render(static_cast<unsigned int>(durationSeconds*500.0f));
5949 application.SendNotification();
5950 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)+1);
5951 application.SendNotification();
5953 DALI_TEST_EQUALS( actor.IsVisible(), true, TEST_LOCATION);
5954 finishCheck.CheckSignalReceived();
5958 int UtcDaliAnimationAnimateBetweenActorRotation01(void)
5960 TestApplication application;
5962 Actor actor = Actor::New();
5963 AngleAxis aa(Degree(90), Vector3::XAXIS);
5964 actor.SetRotation(aa.angle, aa.axis);
5965 Stage::GetCurrent().Add(actor);
5967 application.SendNotification();
5968 application.Render(0);
5969 Quaternion start(Radian(aa.angle), aa.axis);
5970 DALI_TEST_EQUALS( actor.GetCurrentRotation(), start, 0.001f, TEST_LOCATION );
5972 // Build the animation
5973 float durationSeconds(1.0f);
5974 Animation animation = Animation::New(durationSeconds);
5976 KeyFrames keyFrames = KeyFrames::New();
5977 keyFrames.Add(0.0f, AngleAxis(Degree(60), Vector3::ZAXIS));
5979 animation.AnimateBetween( Property(actor, Actor::ROTATION), keyFrames );
5981 // Start the animation
5984 bool signalReceived(false);
5985 AnimationFinishCheck finishCheck(signalReceived);
5986 animation.FinishedSignal().Connect(&application, finishCheck);
5987 application.SendNotification();
5988 application.SendNotification();
5989 application.Render(static_cast<unsigned int>(durationSeconds*500.0f));
5990 application.SendNotification();
5991 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)+1);
5992 application.SendNotification();
5994 Quaternion check = Quaternion::FromAxisAngle(Vector4::ZAXIS, Radian(Degree(60)));
5996 DALI_TEST_EQUALS( actor.GetCurrentRotation(), check, 0.001f, TEST_LOCATION );
5997 finishCheck.CheckSignalReceived();
6001 int UtcDaliAnimationAnimateBetweenActorRotation02(void)
6003 TestApplication application;
6005 Actor actor = Actor::New();
6006 AngleAxis aa(Degree(90), Vector3::XAXIS);
6007 actor.SetRotation(aa.angle, aa.axis);
6008 application.SendNotification();
6009 application.Render(0);
6010 Stage::GetCurrent().Add(actor);
6012 Quaternion start(Radian(aa.angle), aa.axis);
6013 DALI_TEST_EQUALS( actor.GetCurrentRotation(), start, 0.001f, TEST_LOCATION );
6015 // Build the animation
6016 float durationSeconds(1.0f);
6017 Animation animation = Animation::New(durationSeconds);
6019 KeyFrames keyFrames = KeyFrames::New();
6020 keyFrames.Add(0.0f, AngleAxis(Degree(60), Vector3::XAXIS));
6021 keyFrames.Add(0.5f, AngleAxis(Degree(120), Vector3::XAXIS));
6022 keyFrames.Add(1.0f, AngleAxis(Degree(120), Vector3::YAXIS));
6024 animation.AnimateBetween( Property(actor, Actor::ROTATION), keyFrames );
6026 // Start the animation
6029 bool signalReceived(false);
6030 AnimationFinishCheck finishCheck(signalReceived);
6031 animation.FinishedSignal().Connect(&application, finishCheck);
6032 application.SendNotification();
6033 application.Render(0);
6034 application.SendNotification();
6035 finishCheck.CheckSignalNotReceived();
6037 Quaternion check(Radian(Degree(60)), Vector3::XAXIS);
6038 DALI_TEST_EQUALS( actor.GetCurrentRotation(), check, 0.001f, TEST_LOCATION );
6040 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
6041 application.SendNotification();
6042 check = Quaternion::FromAxisAngle(Vector4::XAXIS, Radian(Degree(90)));
6043 DALI_TEST_EQUALS( actor.GetCurrentRotation(), check, 0.001f, TEST_LOCATION );
6045 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
6046 application.SendNotification();
6047 check = Quaternion::FromAxisAngle(Vector4::XAXIS, Radian(Degree(120)));
6048 DALI_TEST_EQUALS( actor.GetCurrentRotation(), check, 0.001f, TEST_LOCATION );
6050 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
6051 application.SendNotification();
6052 check = Quaternion::FromAxisAngle(Vector4(0.5f, 0.5f, 0.0f, 0.0f), Radian(Degree(101.5)));
6053 DALI_TEST_EQUALS( actor.GetCurrentRotation(), check, 0.001f, TEST_LOCATION );
6055 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
6056 application.SendNotification();
6057 check = Quaternion::FromAxisAngle(Vector4::YAXIS, Radian(Degree(120)));
6058 DALI_TEST_EQUALS( actor.GetCurrentRotation(), check, 0.001f, TEST_LOCATION );
6060 // We did expect the animation to finish
6062 finishCheck.CheckSignalReceived();
6066 int UtcDaliAnimationMoveByFloat3(void)
6068 TestApplication application;
6070 Actor actor = Actor::New();
6071 Vector3 startPosition(10.0f, 10.0f, 10.0f);
6072 actor.SetPosition(startPosition);
6073 Stage::GetCurrent().Add(actor);
6074 application.SendNotification();
6075 application.Render(0);
6076 DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION );
6078 // Build the animation
6079 float durationSeconds(1.0f);
6080 Animation animation = Animation::New(durationSeconds);
6081 Vector3 targetPosition(20.0f, 20.0f, 20.0f);
6082 Vector3 relativePosition(targetPosition - startPosition);
6083 animation.MoveBy(actor, relativePosition.x, relativePosition.y, relativePosition.z);
6085 Vector3 ninetyFivePercentProgress(startPosition + relativePosition*0.95f);
6087 // Start the animation
6090 bool signalReceived(false);
6091 AnimationFinishCheck finishCheck(signalReceived);
6092 animation.FinishedSignal().Connect(&application, finishCheck);
6094 application.SendNotification();
6095 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
6097 // We didn't expect the animation to finish yet
6098 application.SendNotification();
6099 finishCheck.CheckSignalNotReceived();
6100 DALI_TEST_EQUALS( actor.GetCurrentPosition(), ninetyFivePercentProgress, TEST_LOCATION );
6102 application.SendNotification();
6103 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
6105 // We did expect the animation to finish
6106 application.SendNotification();
6107 finishCheck.CheckSignalReceived();
6108 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
6112 int UtcDaliAnimationMoveByVector3Alpha(void)
6114 TestApplication application;
6116 Actor actor = Actor::New();
6117 Vector3 startPosition(10.0f, 10.0f, 10.0f);
6118 actor.SetPosition(startPosition);
6119 Stage::GetCurrent().Add(actor);
6120 application.SendNotification();
6121 application.Render(0);
6122 DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION );
6124 // Build the animation
6125 float durationSeconds(1.0f);
6126 Animation animation = Animation::New(durationSeconds);
6127 Vector3 targetPosition(20.0f, 20.0f, 20.0f);
6128 Vector3 relativePosition(targetPosition - startPosition);
6129 animation.MoveBy(actor, relativePosition, AlphaFunctions::EaseOut);
6131 Vector3 ninetyFivePercentProgress(startPosition + relativePosition*0.95f);
6133 // Start the animation
6136 bool signalReceived(false);
6137 AnimationFinishCheck finishCheck(signalReceived);
6138 animation.FinishedSignal().Connect(&application, finishCheck);
6140 application.SendNotification();
6141 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
6143 // We didn't expect the animation to finish yet
6144 application.SendNotification();
6145 finishCheck.CheckSignalNotReceived();
6147 // The position should have moved more, than with a linear alpha function
6148 Vector3 current(actor.GetCurrentPosition());
6149 DALI_TEST_CHECK( current.x > ninetyFivePercentProgress.x );
6150 DALI_TEST_CHECK( current.y > ninetyFivePercentProgress.y );
6151 DALI_TEST_CHECK( current.z > ninetyFivePercentProgress.z );
6153 application.SendNotification();
6154 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
6156 // We did expect the animation to finish
6157 application.SendNotification();
6158 finishCheck.CheckSignalReceived();
6159 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
6163 int UtcDaliAnimationMoveByVector3AlphaFloat2(void)
6165 TestApplication application;
6167 Actor actor = Actor::New();
6168 Vector3 startPosition(10.0f, 10.0f, 10.0f);
6169 actor.SetPosition(startPosition);
6170 Stage::GetCurrent().Add(actor);
6171 application.SendNotification();
6172 application.Render(0);
6173 DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION );
6175 // Build the animation
6176 float durationSeconds(1.0f);
6177 Animation animation = Animation::New(durationSeconds);
6178 Vector3 targetPosition(20.0f, 20.0f, 20.0f);
6179 Vector3 relativePosition(targetPosition - startPosition);
6181 animation.MoveBy(actor, relativePosition, AlphaFunctions::Linear, delay, durationSeconds - delay);
6183 Vector3 ninetyFivePercentProgress(startPosition + relativePosition*0.95f);
6185 // Start the animation
6188 bool signalReceived(false);
6189 AnimationFinishCheck finishCheck(signalReceived);
6190 animation.FinishedSignal().Connect(&application, finishCheck);
6192 application.SendNotification();
6193 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
6195 // We didn't expect the animation to finish yet
6196 application.SendNotification();
6197 finishCheck.CheckSignalNotReceived();
6198 DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION );
6200 application.SendNotification();
6201 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
6203 // We did expect the animation to finish
6204 application.SendNotification();
6205 finishCheck.CheckSignalReceived();
6206 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
6210 int UtcDaliAnimationMoveToFloat3(void)
6212 TestApplication application;
6214 Actor actor = Actor::New();
6215 Stage::GetCurrent().Add(actor);
6216 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
6218 // Build the animation
6219 float durationSeconds(1.0f);
6220 Animation animation = Animation::New(durationSeconds);
6221 Vector3 targetPosition(200.0f, 200.0f, 200.0f);
6222 animation.MoveTo(actor, targetPosition.x, targetPosition.y, targetPosition.z);
6224 Vector3 seventyFivePercentProgress(targetPosition * 0.75f);
6226 // Start the animation
6229 bool signalReceived(false);
6230 AnimationFinishCheck finishCheck(signalReceived);
6231 animation.FinishedSignal().Connect(&application, finishCheck);
6233 application.SendNotification();
6234 application.Render(static_cast<unsigned int>(durationSeconds*750.0f)/* 75% progress */);
6236 // We didn't expect the animation to finish yet
6237 application.SendNotification();
6238 finishCheck.CheckSignalNotReceived();
6239 DALI_TEST_EQUALS( actor.GetCurrentPosition(), seventyFivePercentProgress, TEST_LOCATION );
6241 application.SendNotification();
6242 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
6244 // We did expect the animation to finish
6245 application.SendNotification();
6246 finishCheck.CheckSignalReceived();
6247 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
6251 int UtcDaliAnimationMoveToVector3Alpha(void)
6253 TestApplication application;
6255 Actor actor = Actor::New();
6256 Stage::GetCurrent().Add(actor);
6257 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
6259 // Build the animation
6260 float durationSeconds(1.0f);
6261 Animation animation = Animation::New(durationSeconds);
6262 Vector3 targetPosition(200.0f, 200.0f, 200.0f);
6263 animation.MoveTo(actor, targetPosition, AlphaFunctions::EaseIn);
6265 Vector3 seventyFivePercentProgress(targetPosition * 0.75f);
6267 // Start the animation
6270 bool signalReceived(false);
6271 AnimationFinishCheck finishCheck(signalReceived);
6272 animation.FinishedSignal().Connect(&application, finishCheck);
6274 application.SendNotification();
6275 application.Render(static_cast<unsigned int>(durationSeconds*750.0f)/* 75% progress */);
6277 // We didn't expect the animation to finish yet
6278 application.SendNotification();
6279 finishCheck.CheckSignalNotReceived();
6281 // The position should have moved less, than with a linear alpha function
6282 Vector3 current(actor.GetCurrentPosition());
6283 DALI_TEST_CHECK( current.x > Vector3::ZERO.x );
6284 DALI_TEST_CHECK( current.y > Vector3::ZERO.y );
6285 DALI_TEST_CHECK( current.z > Vector3::ZERO.z );
6286 DALI_TEST_CHECK( current.x < seventyFivePercentProgress.x );
6287 DALI_TEST_CHECK( current.y < seventyFivePercentProgress.y );
6288 DALI_TEST_CHECK( current.z < seventyFivePercentProgress.z );
6290 application.SendNotification();
6291 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
6293 // We did expect the animation to finish
6294 application.SendNotification();
6295 finishCheck.CheckSignalReceived();
6296 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
6300 int UtcDaliAnimationMoveToVector3AlphaFloat2(void)
6302 TestApplication application;
6304 Actor actor = Actor::New();
6305 Stage::GetCurrent().Add(actor);
6306 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
6308 // Build the animation
6309 float durationSeconds(1.0f);
6310 Animation animation = Animation::New(durationSeconds);
6311 Vector3 targetPosition(200.0f, 200.0f, 200.0f);
6313 animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear, delay, durationSeconds - delay);
6315 Vector3 seventyFivePercentProgress(targetPosition * 0.75f);
6317 // Start the animation
6320 bool signalReceived(false);
6321 AnimationFinishCheck finishCheck(signalReceived);
6322 animation.FinishedSignal().Connect(&application, finishCheck);
6324 application.SendNotification();
6325 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
6327 // We didn't expect the animation to finish yet
6328 application.SendNotification();
6329 finishCheck.CheckSignalNotReceived();
6330 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
6332 application.SendNotification();
6333 application.Render(static_cast<unsigned int>(durationSeconds*500.0f*0.75)/* 7/8 animation progress, 3/4 animator progress */);
6335 // We didn't expect the animation to finish yet
6336 application.SendNotification();
6337 finishCheck.CheckSignalNotReceived();
6338 DALI_TEST_EQUALS( actor.GetCurrentPosition(), seventyFivePercentProgress, TEST_LOCATION );
6340 application.SendNotification();
6341 application.Render(static_cast<unsigned int>(durationSeconds*500.0f*0.25) + 1u/*just beyond the animation duration*/);
6343 // We did expect the animation to finish
6344 application.SendNotification();
6345 finishCheck.CheckSignalReceived();
6346 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
6350 int UtcDaliAnimationMove(void)
6352 TestApplication application;
6354 Actor actor = Actor::New();
6355 Vector3 initialPosition(Vector3::ZERO);
6356 DALI_TEST_EQUALS( actor.GetCurrentPosition(), initialPosition, TEST_LOCATION );
6357 Stage::GetCurrent().Add(actor);
6359 // Build the animation
6360 float durationSeconds(10.0f);
6361 Animation animation = Animation::New(durationSeconds);
6362 Vector3 targetPosition(200.0f, 200.0f, 200.0f);
6363 BounceFunc func(0.0f, 0.0f, -100.0f);
6364 animation.Move(actor, func, AlphaFunctions::Linear, 0.0f, durationSeconds);
6366 // Start the animation
6369 bool signalReceived(false);
6370 AnimationFinishCheck finishCheck(signalReceived);
6371 animation.FinishedSignal().Connect(&application, finishCheck);
6373 application.SendNotification();
6374 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
6376 // We didn't expect the animation to finish yet
6377 application.SendNotification();
6378 finishCheck.CheckSignalNotReceived();
6379 DALI_TEST_EQUALS( actor.GetCurrentPosition(), func(0.25f, initialPosition), TEST_LOCATION );
6381 application.SendNotification();
6382 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
6384 // We didn't expect the animation to finish yet
6385 application.SendNotification();
6386 finishCheck.CheckSignalNotReceived();
6387 DALI_TEST_EQUALS( actor.GetCurrentPosition(), func(0.5f, initialPosition), TEST_LOCATION );
6389 application.SendNotification();
6390 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
6392 // We didn't expect the animation to finish yet
6393 application.SendNotification();
6394 finishCheck.CheckSignalNotReceived();
6395 DALI_TEST_EQUALS( actor.GetCurrentPosition(), func(0.75f, initialPosition), TEST_LOCATION );
6397 application.SendNotification();
6398 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
6400 // We did expect the animation to finish
6401 application.SendNotification();
6402 finishCheck.CheckSignalReceived();
6403 DALI_TEST_EQUALS( actor.GetCurrentPosition(), initialPosition, TEST_LOCATION );
6407 int UtcDaliAnimationRotateByDegreeVector3(void)
6409 TestApplication application;
6411 Actor actor = Actor::New();
6412 actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
6413 Stage::GetCurrent().Add(actor);
6414 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6416 // Build the animation
6417 float durationSeconds(1.0f);
6418 Animation animation = Animation::New(durationSeconds);
6419 Degree relativeRotationDegrees(360.0f);
6420 Radian relativeRotationRadians(relativeRotationDegrees);
6421 animation.RotateBy(actor, relativeRotationDegrees/*Degree version*/, Vector3::YAXIS);
6423 // Start the animation
6426 bool signalReceived(false);
6427 AnimationFinishCheck finishCheck(signalReceived);
6428 animation.FinishedSignal().Connect(&application, finishCheck);
6430 application.SendNotification();
6431 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
6433 // We didn't expect the animation to finish yet
6434 application.SendNotification();
6435 finishCheck.CheckSignalNotReceived();
6436 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * 0.25f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6438 application.SendNotification();
6439 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
6441 // We didn't expect the animation to finish yet
6442 application.SendNotification();
6443 finishCheck.CheckSignalNotReceived();
6444 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * 0.5f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6446 application.SendNotification();
6447 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
6449 // We didn't expect the animation to finish yet
6450 application.SendNotification();
6451 finishCheck.CheckSignalNotReceived();
6452 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * 0.75f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6454 application.SendNotification();
6455 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
6457 // We did expect the animation to finish
6458 application.SendNotification();
6459 finishCheck.CheckSignalReceived();
6460 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6464 int UtcDaliAnimationRotateByRadianVector3(void)
6466 TestApplication application;
6468 Actor actor = Actor::New();
6469 actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
6470 Stage::GetCurrent().Add(actor);
6471 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6473 // Build the animation
6474 float durationSeconds(1.0f);
6475 Animation animation = Animation::New(durationSeconds);
6476 Degree relativeRotationDegrees(360.0f);
6477 Radian relativeRotationRadians(relativeRotationDegrees);
6478 animation.RotateBy(actor, relativeRotationRadians/*Radian version*/, Vector3::YAXIS);
6480 // Start the animation
6483 bool signalReceived(false);
6484 AnimationFinishCheck finishCheck(signalReceived);
6485 animation.FinishedSignal().Connect(&application, finishCheck);
6487 application.SendNotification();
6488 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
6490 // We didn't expect the animation to finish yet
6491 application.SendNotification();
6492 finishCheck.CheckSignalNotReceived();
6493 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * 0.25f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6495 application.SendNotification();
6496 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
6498 // We didn't expect the animation to finish yet
6499 application.SendNotification();
6500 finishCheck.CheckSignalNotReceived();
6501 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * 0.5f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6503 application.SendNotification();
6504 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
6506 // We didn't expect the animation to finish yet
6507 application.SendNotification();
6508 finishCheck.CheckSignalNotReceived();
6509 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * 0.75f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6511 application.SendNotification();
6512 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
6514 // We did expect the animation to finish
6515 application.SendNotification();
6516 finishCheck.CheckSignalReceived();
6517 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6521 int UtcDaliAnimationRotateByDegreeVector3Alpha(void)
6523 TestApplication application;
6525 Actor actor = Actor::New();
6526 actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
6527 Stage::GetCurrent().Add(actor);
6528 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6530 // Build the animation
6531 float durationSeconds(1.0f);
6532 Animation animation = Animation::New(durationSeconds);
6533 Degree relativeRotationDegrees(360.0f);
6534 Radian relativeRotationRadians(relativeRotationDegrees);
6535 animation.RotateBy(actor, relativeRotationDegrees/*Degree version*/, Vector3::YAXIS, AlphaFunctions::EaseIn);
6537 // Start the animation
6540 bool signalReceived(false);
6541 AnimationFinishCheck finishCheck(signalReceived);
6542 animation.FinishedSignal().Connect(&application, finishCheck);
6544 application.SendNotification();
6545 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
6547 // We didn't expect the animation to finish yet
6548 application.SendNotification();
6549 finishCheck.CheckSignalNotReceived();
6550 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * AlphaFunctions::EaseIn(0.25f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6552 application.SendNotification();
6553 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
6555 // We didn't expect the animation to finish yet
6556 application.SendNotification();
6557 finishCheck.CheckSignalNotReceived();
6558 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * AlphaFunctions::EaseIn(0.5f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6560 application.SendNotification();
6561 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
6563 // We didn't expect the animation to finish yet
6564 application.SendNotification();
6565 finishCheck.CheckSignalNotReceived();
6566 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * AlphaFunctions::EaseIn(0.75f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6568 application.SendNotification();
6569 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
6571 // We did expect the animation to finish
6572 application.SendNotification();
6573 finishCheck.CheckSignalReceived();
6574 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6578 int UtcDaliAnimationRotateByRadianVector3Alpha(void)
6580 TestApplication application;
6582 Actor actor = Actor::New();
6583 actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
6584 Stage::GetCurrent().Add(actor);
6585 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6587 // Build the animation
6588 float durationSeconds(1.0f);
6589 Animation animation = Animation::New(durationSeconds);
6590 Degree relativeRotationDegrees(360.0f);
6591 Radian relativeRotationRadians(relativeRotationDegrees);
6592 animation.RotateBy(actor, relativeRotationRadians/*Radian version*/, Vector3::YAXIS, AlphaFunctions::EaseIn);
6594 // Start the animation
6597 bool signalReceived(false);
6598 AnimationFinishCheck finishCheck(signalReceived);
6599 animation.FinishedSignal().Connect(&application, finishCheck);
6601 application.SendNotification();
6602 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
6604 // We didn't expect the animation to finish yet
6605 application.SendNotification();
6606 finishCheck.CheckSignalNotReceived();
6607 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * AlphaFunctions::EaseIn(0.25f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6609 application.SendNotification();
6610 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
6612 // We didn't expect the animation to finish yet
6613 application.SendNotification();
6614 finishCheck.CheckSignalNotReceived();
6615 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * AlphaFunctions::EaseIn(0.5f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6617 application.SendNotification();
6618 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
6620 // We didn't expect the animation to finish yet
6621 application.SendNotification();
6622 finishCheck.CheckSignalNotReceived();
6623 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * AlphaFunctions::EaseIn(0.75f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6625 application.SendNotification();
6626 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
6628 // We did expect the animation to finish
6629 application.SendNotification();
6630 finishCheck.CheckSignalReceived();
6631 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6635 int UtcDaliAnimationRotateByDegreeVector3AlphaFloat2(void)
6637 TestApplication application;
6639 Actor actor = Actor::New();
6640 actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
6641 Stage::GetCurrent().Add(actor);
6642 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6644 // Build the animation
6645 float durationSeconds(1.0f);
6646 Animation animation = Animation::New(durationSeconds);
6647 Degree relativeRotationDegrees(360.0f);
6648 Radian relativeRotationRadians(relativeRotationDegrees);
6650 animation.RotateBy(actor, relativeRotationDegrees/*Degree version*/, Vector3::YAXIS, AlphaFunctions::EaseIn, delay, durationSeconds - delay);
6652 // Start the animation
6655 bool signalReceived(false);
6656 AnimationFinishCheck finishCheck(signalReceived);
6657 animation.FinishedSignal().Connect(&application, finishCheck);
6659 application.SendNotification();
6660 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
6662 // We didn't expect the animation to finish yet
6663 application.SendNotification();
6664 finishCheck.CheckSignalNotReceived();
6665 float progress = max(0.0f, 0.25f - delay) / (1.0f - delay);
6666 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6668 application.SendNotification();
6669 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
6671 // We didn't expect the animation to finish yet
6672 application.SendNotification();
6673 finishCheck.CheckSignalNotReceived();
6674 progress = max(0.0f, 0.5f - delay) / (1.0f - delay);
6675 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6677 application.SendNotification();
6678 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
6680 // We didn't expect the animation to finish yet
6681 application.SendNotification();
6682 finishCheck.CheckSignalNotReceived();
6683 progress = max(0.0f, 0.75f - delay) / (1.0f - delay);
6684 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6686 application.SendNotification();
6687 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
6689 // We did expect the animation to finish
6690 application.SendNotification();
6691 finishCheck.CheckSignalReceived();
6692 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6697 int UtcDaliAnimationRotateByRadianVector3AlphaFloat2(void)
6699 TestApplication application;
6701 Actor actor = Actor::New();
6702 actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
6703 Stage::GetCurrent().Add(actor);
6704 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6706 // Build the animation
6707 float durationSeconds(1.0f);
6708 Animation animation = Animation::New(durationSeconds);
6709 Degree relativeRotationDegrees(360.0f);
6710 Radian relativeRotationRadians(relativeRotationDegrees);
6712 animation.RotateBy(actor, relativeRotationRadians/*Radian version*/, Vector3::YAXIS, AlphaFunctions::EaseIn, delay, durationSeconds - delay);
6714 // Start the animation
6717 bool signalReceived(false);
6718 AnimationFinishCheck finishCheck(signalReceived);
6719 animation.FinishedSignal().Connect(&application, finishCheck);
6721 application.SendNotification();
6722 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
6724 // We didn't expect the animation to finish yet
6725 application.SendNotification();
6726 finishCheck.CheckSignalNotReceived();
6727 float progress = max(0.0f, 0.25f - delay) / (1.0f - delay);
6728 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6730 application.SendNotification();
6731 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
6733 // We didn't expect the animation to finish yet
6734 application.SendNotification();
6735 finishCheck.CheckSignalNotReceived();
6736 progress = max(0.0f, 0.5f - delay) / (1.0f - delay);
6737 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6739 application.SendNotification();
6740 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
6742 // We didn't expect the animation to finish yet
6743 application.SendNotification();
6744 finishCheck.CheckSignalNotReceived();
6745 progress = max(0.0f, 0.75f - delay) / (1.0f - delay);
6746 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6748 application.SendNotification();
6749 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
6751 // We did expect the animation to finish
6752 application.SendNotification();
6753 finishCheck.CheckSignalReceived();
6754 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6758 int UtcDaliAnimationRotateToDegreeVector3(void)
6760 TestApplication application;
6762 Actor actor = Actor::New();
6763 actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
6764 Stage::GetCurrent().Add(actor);
6765 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6767 // Build the animation
6768 float durationSeconds(1.0f);
6769 Animation animation = Animation::New(durationSeconds);
6770 Degree targetRotationDegrees(90.0f);
6771 Radian targetRotationRadians(targetRotationDegrees);
6772 animation.RotateTo(actor, targetRotationDegrees/*Degree version*/, Vector3::YAXIS);
6774 // Start the animation
6777 bool signalReceived(false);
6778 AnimationFinishCheck finishCheck(signalReceived);
6779 animation.FinishedSignal().Connect(&application, finishCheck);
6781 application.SendNotification();
6782 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
6784 // We didn't expect the animation to finish yet
6785 application.SendNotification();
6786 finishCheck.CheckSignalNotReceived();
6787 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.25f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6789 application.SendNotification();
6790 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
6792 // We didn't expect the animation to finish yet
6793 application.SendNotification();
6794 finishCheck.CheckSignalNotReceived();
6795 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.5f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6797 application.SendNotification();
6798 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
6800 // We didn't expect the animation to finish yet
6801 application.SendNotification();
6802 finishCheck.CheckSignalNotReceived();
6803 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.75f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6805 application.SendNotification();
6806 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
6808 // We did expect the animation to finish
6809 application.SendNotification();
6810 finishCheck.CheckSignalReceived();
6811 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6815 int UtcDaliAnimationRotateToRadianVector3(void)
6817 TestApplication application;
6819 Actor actor = Actor::New();
6820 actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
6821 Stage::GetCurrent().Add(actor);
6822 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6824 // Build the animation
6825 float durationSeconds(1.0f);
6826 Animation animation = Animation::New(durationSeconds);
6827 Degree targetRotationDegrees(90.0f);
6828 Radian targetRotationRadians(targetRotationDegrees);
6829 animation.RotateTo(actor, targetRotationRadians/*Radian version*/, Vector3::YAXIS);
6831 // Start the animation
6834 bool signalReceived(false);
6835 AnimationFinishCheck finishCheck(signalReceived);
6836 animation.FinishedSignal().Connect(&application, finishCheck);
6838 application.SendNotification();
6839 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
6841 // We didn't expect the animation to finish yet
6842 application.SendNotification();
6843 finishCheck.CheckSignalNotReceived();
6844 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.25f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6846 application.SendNotification();
6847 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
6849 // We didn't expect the animation to finish yet
6850 application.SendNotification();
6851 finishCheck.CheckSignalNotReceived();
6852 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.5f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6854 application.SendNotification();
6855 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
6857 // We didn't expect the animation to finish yet
6858 application.SendNotification();
6859 finishCheck.CheckSignalNotReceived();
6860 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.75f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6862 application.SendNotification();
6863 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
6865 // We did expect the animation to finish
6866 application.SendNotification();
6867 finishCheck.CheckSignalReceived();
6868 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6872 int UtcDaliAnimationRotateToQuaternion(void)
6874 TestApplication application;
6876 Actor actor = Actor::New();
6877 actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
6878 Stage::GetCurrent().Add(actor);
6879 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6881 // Build the animation
6882 float durationSeconds(1.0f);
6883 Animation animation = Animation::New(durationSeconds);
6884 Degree targetRotationDegrees(90.0f);
6885 Radian targetRotationRadians(targetRotationDegrees);
6886 Quaternion targetRotation(targetRotationRadians, Vector3::YAXIS);
6887 animation.RotateTo(actor, targetRotation/*Quaternion version*/);
6889 // Start the animation
6892 bool signalReceived(false);
6893 AnimationFinishCheck finishCheck(signalReceived);
6894 animation.FinishedSignal().Connect(&application, finishCheck);
6896 application.SendNotification();
6897 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
6899 // We didn't expect the animation to finish yet
6900 application.SendNotification();
6901 finishCheck.CheckSignalNotReceived();
6902 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.25f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6904 application.SendNotification();
6905 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
6907 // We didn't expect the animation to finish yet
6908 application.SendNotification();
6909 finishCheck.CheckSignalNotReceived();
6910 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.5f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6912 application.SendNotification();
6913 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
6915 // We didn't expect the animation to finish yet
6916 application.SendNotification();
6917 finishCheck.CheckSignalNotReceived();
6918 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.75f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6920 application.SendNotification();
6921 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
6923 // We did expect the animation to finish
6924 application.SendNotification();
6925 finishCheck.CheckSignalReceived();
6926 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6930 int UtcDaliAnimationRotateToDegreeVector3Alpha(void)
6932 TestApplication application;
6934 Actor actor = Actor::New();
6935 actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
6936 Stage::GetCurrent().Add(actor);
6937 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6939 // Build the animation
6940 float durationSeconds(1.0f);
6941 Animation animation = Animation::New(durationSeconds);
6942 Degree targetRotationDegrees(90.0f);
6943 Radian targetRotationRadians(targetRotationDegrees);
6944 animation.RotateTo(actor, targetRotationDegrees/*Degree version*/, Vector3::YAXIS, AlphaFunctions::EaseIn);
6946 // Start the animation
6949 bool signalReceived(false);
6950 AnimationFinishCheck finishCheck(signalReceived);
6951 animation.FinishedSignal().Connect(&application, finishCheck);
6953 application.SendNotification();
6954 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
6956 // We didn't expect the animation to finish yet
6957 application.SendNotification();
6958 finishCheck.CheckSignalNotReceived();
6959 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(0.25f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6961 application.SendNotification();
6962 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
6964 // We didn't expect the animation to finish yet
6965 application.SendNotification();
6966 finishCheck.CheckSignalNotReceived();
6967 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(0.5f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6969 application.SendNotification();
6970 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
6972 // We didn't expect the animation to finish yet
6973 application.SendNotification();
6974 finishCheck.CheckSignalNotReceived();
6975 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(0.75f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6977 application.SendNotification();
6978 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
6980 // We did expect the animation to finish
6981 application.SendNotification();
6982 finishCheck.CheckSignalReceived();
6983 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6987 int UtcDaliAnimationRotateToRadianVector3Alpha(void)
6989 TestApplication application;
6991 Actor actor = Actor::New();
6992 actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
6993 Stage::GetCurrent().Add(actor);
6994 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6996 // Build the animation
6997 float durationSeconds(1.0f);
6998 Animation animation = Animation::New(durationSeconds);
6999 Degree targetRotationDegrees(90.0f);
7000 Radian targetRotationRadians(targetRotationDegrees);
7001 animation.RotateTo(actor, targetRotationRadians/*Radian version*/, Vector3::YAXIS, AlphaFunctions::EaseIn);
7003 // Start the animation
7006 bool signalReceived(false);
7007 AnimationFinishCheck finishCheck(signalReceived);
7008 animation.FinishedSignal().Connect(&application, finishCheck);
7010 application.SendNotification();
7011 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7013 // We didn't expect the animation to finish yet
7014 application.SendNotification();
7015 finishCheck.CheckSignalNotReceived();
7016 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(0.25f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7018 application.SendNotification();
7019 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7021 // We didn't expect the animation to finish yet
7022 application.SendNotification();
7023 finishCheck.CheckSignalNotReceived();
7024 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(0.5f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7026 application.SendNotification();
7027 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7029 // We didn't expect the animation to finish yet
7030 application.SendNotification();
7031 finishCheck.CheckSignalNotReceived();
7032 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(0.75f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7034 application.SendNotification();
7035 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7037 // We did expect the animation to finish
7038 application.SendNotification();
7039 finishCheck.CheckSignalReceived();
7040 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7044 int UtcDaliAnimationRotateToQuaternionAlpha(void)
7046 TestApplication application;
7048 Actor actor = Actor::New();
7049 actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
7050 Stage::GetCurrent().Add(actor);
7051 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7053 // Build the animation
7054 float durationSeconds(1.0f);
7055 Animation animation = Animation::New(durationSeconds);
7056 Degree targetRotationDegrees(90.0f);
7057 Radian targetRotationRadians(targetRotationDegrees);
7058 Quaternion targetRotation(targetRotationRadians, Vector3::YAXIS);
7059 animation.RotateTo(actor, targetRotation/*Quaternion version*/, AlphaFunctions::EaseIn);
7061 // Start the animation
7064 bool signalReceived(false);
7065 AnimationFinishCheck finishCheck(signalReceived);
7066 animation.FinishedSignal().Connect(&application, finishCheck);
7068 application.SendNotification();
7069 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7071 // We didn't expect the animation to finish yet
7072 application.SendNotification();
7073 finishCheck.CheckSignalNotReceived();
7074 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(0.25f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7076 application.SendNotification();
7077 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7079 // We didn't expect the animation to finish yet
7080 application.SendNotification();
7081 finishCheck.CheckSignalNotReceived();
7082 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(0.5f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7084 application.SendNotification();
7085 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7087 // We didn't expect the animation to finish yet
7088 application.SendNotification();
7089 finishCheck.CheckSignalNotReceived();
7090 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(0.75f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7092 application.SendNotification();
7093 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7095 // We did expect the animation to finish
7096 application.SendNotification();
7097 finishCheck.CheckSignalReceived();
7098 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7102 int UtcDaliAnimationRotateToDegreeVector3AlphaFloat2(void)
7104 TestApplication application;
7106 Actor actor = Actor::New();
7107 actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
7108 Stage::GetCurrent().Add(actor);
7109 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7111 // Build the animation
7112 float durationSeconds(1.0f);
7113 Animation animation = Animation::New(durationSeconds);
7114 Degree targetRotationDegrees(90.0f);
7115 Radian targetRotationRadians(targetRotationDegrees);
7117 animation.RotateTo(actor, targetRotationDegrees/*Degree version*/, Vector3::YAXIS, AlphaFunctions::EaseIn, delay, durationSeconds - delay);
7119 // Start the animation
7122 bool signalReceived(false);
7123 AnimationFinishCheck finishCheck(signalReceived);
7124 animation.FinishedSignal().Connect(&application, finishCheck);
7126 application.SendNotification();
7127 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7129 // We didn't expect the animation to finish yet
7130 application.SendNotification();
7131 finishCheck.CheckSignalNotReceived();
7132 float progress = max(0.0f, 0.25f - delay) / (1.0f - delay);
7133 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7135 application.SendNotification();
7136 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7138 // We didn't expect the animation to finish yet
7139 application.SendNotification();
7140 finishCheck.CheckSignalNotReceived();
7141 progress = max(0.0f, 0.5f - delay) / (1.0f - delay);
7142 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7144 application.SendNotification();
7145 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7147 // We didn't expect the animation to finish yet
7148 application.SendNotification();
7149 finishCheck.CheckSignalNotReceived();
7150 progress = max(0.0f, 0.75f - delay) / (1.0f - delay);
7151 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7153 application.SendNotification();
7154 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7156 // We did expect the animation to finish
7157 application.SendNotification();
7158 finishCheck.CheckSignalReceived();
7159 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7163 int UtcDaliAnimationRotateToRadianVector3AlphaFloat2(void)
7165 TestApplication application;
7167 Actor actor = Actor::New();
7168 actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
7169 Stage::GetCurrent().Add(actor);
7170 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7172 // Build the animation
7173 float durationSeconds(1.0f);
7174 Animation animation = Animation::New(durationSeconds);
7175 Degree targetRotationDegrees(90.0f);
7176 Radian targetRotationRadians(targetRotationDegrees);
7178 animation.RotateTo(actor, targetRotationRadians/*Radian version*/, Vector3::YAXIS, AlphaFunctions::EaseIn, delay, durationSeconds - delay);
7180 // Start the animation
7183 bool signalReceived(false);
7184 AnimationFinishCheck finishCheck(signalReceived);
7185 animation.FinishedSignal().Connect(&application, finishCheck);
7187 application.SendNotification();
7188 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7190 // We didn't expect the animation to finish yet
7191 application.SendNotification();
7192 finishCheck.CheckSignalNotReceived();
7193 float progress = max(0.0f, 0.25f - delay) / (1.0f - delay);
7194 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7196 application.SendNotification();
7197 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7199 // We didn't expect the animation to finish yet
7200 application.SendNotification();
7201 finishCheck.CheckSignalNotReceived();
7202 progress = max(0.0f, 0.5f - delay) / (1.0f - delay);
7203 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7205 application.SendNotification();
7206 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7208 // We didn't expect the animation to finish yet
7209 application.SendNotification();
7210 finishCheck.CheckSignalNotReceived();
7211 progress = max(0.0f, 0.75f - delay) / (1.0f - delay);
7212 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7214 application.SendNotification();
7215 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7217 // We did expect the animation to finish
7218 application.SendNotification();
7219 finishCheck.CheckSignalReceived();
7220 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7224 int UtcDaliAnimationRotateToQuaternionAlphaFloat2(void)
7226 TestApplication application;
7228 Actor actor = Actor::New();
7229 actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
7230 Stage::GetCurrent().Add(actor);
7231 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7233 // Build the animation
7234 float durationSeconds(1.0f);
7235 Animation animation = Animation::New(durationSeconds);
7236 Degree targetRotationDegrees(90.0f);
7237 Radian targetRotationRadians(targetRotationDegrees);
7239 Quaternion targetRotation(targetRotationRadians, Vector3::YAXIS);
7240 animation.RotateTo(actor, targetRotation/*Quaternion version*/, AlphaFunctions::EaseIn, delay, durationSeconds - delay);
7242 // Start the animation
7245 bool signalReceived(false);
7246 AnimationFinishCheck finishCheck(signalReceived);
7247 animation.FinishedSignal().Connect(&application, finishCheck);
7249 application.SendNotification();
7250 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7252 // We didn't expect the animation to finish yet
7253 application.SendNotification();
7254 finishCheck.CheckSignalNotReceived();
7255 float progress = max(0.0f, 0.25f - delay) / (1.0f - delay);
7256 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7258 application.SendNotification();
7259 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7261 // We didn't expect the animation to finish yet
7262 application.SendNotification();
7263 finishCheck.CheckSignalNotReceived();
7264 progress = max(0.0f, 0.5f - delay) / (1.0f - delay);
7265 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7267 application.SendNotification();
7268 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7270 // We didn't expect the animation to finish yet
7271 application.SendNotification();
7272 finishCheck.CheckSignalNotReceived();
7273 progress = max(0.0f, 0.75f - delay) / (1.0f - delay);
7274 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7276 application.SendNotification();
7277 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7279 // We did expect the animation to finish
7280 application.SendNotification();
7281 finishCheck.CheckSignalReceived();
7282 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7286 int UtcDaliAnimationRotate(void)
7288 TestApplication application;
7290 Actor actor = Actor::New();
7291 Quaternion initialRotation(0.0f, Vector3::YAXIS);
7292 actor.SetRotation(initialRotation);
7293 Stage::GetCurrent().Add(actor);
7294 DALI_TEST_EQUALS( actor.GetCurrentRotation(), initialRotation, ROTATION_EPSILON, TEST_LOCATION );
7296 // Build the animation
7297 float durationSeconds(1.0f);
7298 Animation animation = Animation::New(durationSeconds);
7299 TumbleFunc func(Vector3::YAXIS);
7300 animation.Rotate(actor, func, AlphaFunctions::Linear, 0.0f, durationSeconds);
7302 // Start the animation
7305 bool signalReceived(false);
7306 AnimationFinishCheck finishCheck(signalReceived);
7307 animation.FinishedSignal().Connect(&application, finishCheck);
7309 application.SendNotification();
7310 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7312 // We didn't expect the animation to finish yet
7313 application.SendNotification();
7314 finishCheck.CheckSignalNotReceived();
7315 DALI_TEST_EQUALS( actor.GetCurrentRotation(), func(0.25f, initialRotation), ROTATION_EPSILON, TEST_LOCATION );
7317 application.SendNotification();
7318 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7320 // We didn't expect the animation to finish yet
7321 application.SendNotification();
7322 finishCheck.CheckSignalNotReceived();
7323 DALI_TEST_EQUALS( actor.GetCurrentRotation(), func(0.5f, initialRotation), ROTATION_EPSILON, TEST_LOCATION );
7325 application.SendNotification();
7326 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7328 // We didn't expect the animation to finish yet
7329 application.SendNotification();
7330 finishCheck.CheckSignalNotReceived();
7331 DALI_TEST_EQUALS( actor.GetCurrentRotation(), func(0.75f, initialRotation), ROTATION_EPSILON, TEST_LOCATION );
7333 application.SendNotification();
7334 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7336 // We did expect the animation to finish
7337 application.SendNotification();
7338 finishCheck.CheckSignalReceived();
7339 DALI_TEST_EQUALS( actor.GetCurrentRotation(), func(1.0f, initialRotation), ROTATION_EPSILON, TEST_LOCATION );
7343 int UtcDaliAnimationScaleBy(void)
7345 TestApplication application;
7347 Actor actor = Actor::New();
7348 Stage::GetCurrent().Add(actor);
7349 DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
7351 // Build the animation
7352 float durationSeconds(1.0f);
7353 Animation animation = Animation::New(durationSeconds);
7354 Vector3 targetScale(2.0f, 2.0f, 2.0f);
7355 Vector3 relativeScale(targetScale - Vector3::ONE);
7356 animation.ScaleBy(actor, relativeScale.x, relativeScale.y, relativeScale.z);
7358 Vector3 ninetyNinePercentProgress(Vector3::ONE + relativeScale*0.99f);
7360 // Start the animation
7363 bool signalReceived(false);
7364 AnimationFinishCheck finishCheck(signalReceived);
7365 animation.FinishedSignal().Connect(&application, finishCheck);
7367 application.SendNotification();
7368 application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
7370 // We didn't expect the animation to finish yet
7371 application.SendNotification();
7372 finishCheck.CheckSignalNotReceived();
7373 DALI_TEST_EQUALS( actor.GetCurrentScale(), ninetyNinePercentProgress, TEST_LOCATION );
7375 application.SendNotification();
7376 application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
7378 // We did expect the animation to finish
7379 application.SendNotification();
7380 finishCheck.CheckSignalReceived();
7381 DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
7384 finishCheck.Reset();
7385 actor.SetScale(Vector3::ONE);
7386 application.SendNotification();
7387 application.Render(0);
7388 DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
7390 // Repeat with a different (ease-in) alpha function
7391 animation = Animation::New(durationSeconds);
7392 animation.ScaleBy(actor, relativeScale, AlphaFunctions::EaseIn);
7393 animation.FinishedSignal().Connect(&application, finishCheck);
7396 application.SendNotification();
7397 application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
7399 // We didn't expect the animation to finish yet
7400 application.SendNotification();
7401 finishCheck.CheckSignalNotReceived();
7403 // The scale should have grown less, than with a linear alpha function
7404 Vector3 current(actor.GetCurrentScale());
7405 DALI_TEST_CHECK( current.x > 1.0f );
7406 DALI_TEST_CHECK( current.y > 1.0f );
7407 DALI_TEST_CHECK( current.z > 1.0f );
7408 DALI_TEST_CHECK( current.x < ninetyNinePercentProgress.x );
7409 DALI_TEST_CHECK( current.y < ninetyNinePercentProgress.y );
7410 DALI_TEST_CHECK( current.z < ninetyNinePercentProgress.z );
7412 application.SendNotification();
7413 application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
7415 // We did expect the animation to finish
7416 application.SendNotification();
7417 finishCheck.CheckSignalReceived();
7418 DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
7421 finishCheck.Reset();
7422 actor.SetScale(Vector3::ONE);
7423 application.SendNotification();
7424 application.Render(0);
7425 DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
7427 // Repeat with a delay
7429 animation = Animation::New(durationSeconds);
7430 animation.ScaleBy(actor, relativeScale, AlphaFunctions::Linear, delay, durationSeconds - delay);
7431 animation.FinishedSignal().Connect(&application, finishCheck);
7434 application.SendNotification();
7435 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
7437 // We didn't expect the animation to finish yet
7438 application.SendNotification();
7439 finishCheck.CheckSignalNotReceived();
7440 DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
7442 application.SendNotification();
7443 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
7445 // We did expect the animation to finish
7446 application.SendNotification();
7447 finishCheck.CheckSignalReceived();
7448 DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
7452 int UtcDaliAnimationScaleTo(void)
7454 TestApplication application;
7456 Actor actor = Actor::New();
7457 Stage::GetCurrent().Add(actor);
7458 DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
7460 // Build the animation
7461 float durationSeconds(1.0f);
7462 Animation animation = Animation::New(durationSeconds);
7463 Vector3 targetScale(2.0f, 2.0f, 2.0f);
7464 animation.ScaleTo(actor, targetScale.x, targetScale.y, targetScale.z);
7466 Vector3 ninetyNinePercentProgress(Vector3::ONE + (targetScale - Vector3::ONE)*0.99f);
7468 // Start the animation
7471 bool signalReceived(false);
7472 AnimationFinishCheck finishCheck(signalReceived);
7473 animation.FinishedSignal().Connect(&application, finishCheck);
7475 application.SendNotification();
7476 application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
7478 // We didn't expect the animation to finish yet
7479 application.SendNotification();
7480 finishCheck.CheckSignalNotReceived();
7481 DALI_TEST_EQUALS( actor.GetCurrentScale(), ninetyNinePercentProgress, TEST_LOCATION );
7483 application.SendNotification();
7484 application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
7486 // We did expect the animation to finish
7487 application.SendNotification();
7488 finishCheck.CheckSignalReceived();
7489 DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
7492 finishCheck.Reset();
7493 actor.SetScale(Vector3::ONE);
7494 application.SendNotification();
7495 application.Render(0);
7496 DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
7498 // Repeat with a different (ease-in) alpha function
7499 animation = Animation::New(durationSeconds);
7500 animation.ScaleTo(actor, targetScale, AlphaFunctions::EaseIn);
7501 animation.FinishedSignal().Connect(&application, finishCheck);
7504 application.SendNotification();
7505 application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
7507 // We didn't expect the animation to finish yet
7508 application.SendNotification();
7509 finishCheck.CheckSignalNotReceived();
7511 // The scale should have grown less, than with a linear alpha function
7512 Vector3 current(actor.GetCurrentScale());
7513 DALI_TEST_CHECK( current.x > 1.0f );
7514 DALI_TEST_CHECK( current.y > 1.0f );
7515 DALI_TEST_CHECK( current.z > 1.0f );
7516 DALI_TEST_CHECK( current.x < ninetyNinePercentProgress.x );
7517 DALI_TEST_CHECK( current.y < ninetyNinePercentProgress.y );
7518 DALI_TEST_CHECK( current.z < ninetyNinePercentProgress.z );
7520 application.SendNotification();
7521 application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
7523 // We did expect the animation to finish
7524 application.SendNotification();
7525 finishCheck.CheckSignalReceived();
7526 DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
7529 finishCheck.Reset();
7530 actor.SetScale(Vector3::ONE);
7531 application.SendNotification();
7532 application.Render(0);
7533 DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
7535 // Repeat with a delay
7537 animation = Animation::New(durationSeconds);
7538 animation.ScaleTo(actor, targetScale, AlphaFunctions::Linear, delay, durationSeconds - delay);
7539 animation.FinishedSignal().Connect(&application, finishCheck);
7542 application.SendNotification();
7543 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
7545 // We didn't expect the animation to finish yet
7546 application.SendNotification();
7547 finishCheck.CheckSignalNotReceived();
7548 DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
7550 application.SendNotification();
7551 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
7553 // We did expect the animation to finish
7554 application.SendNotification();
7555 finishCheck.CheckSignalReceived();
7556 DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
7560 int UtcDaliAnimationShow(void)
7562 TestApplication application;
7564 Actor actor = Actor::New();
7565 actor.SetVisible(false);
7566 application.SendNotification();
7567 application.Render(0);
7568 DALI_TEST_CHECK( !actor.IsVisible() );
7569 Stage::GetCurrent().Add(actor);
7571 // Start the animation
7572 float durationSeconds(10.0f);
7573 Animation animation = Animation::New(durationSeconds);
7574 animation.Show(actor, durationSeconds*0.5f);
7577 bool signalReceived(false);
7578 AnimationFinishCheck finishCheck(signalReceived);
7579 animation.FinishedSignal().Connect(&application, finishCheck);
7581 application.SendNotification();
7582 application.Render(static_cast<unsigned int>(durationSeconds*490.0f));
7584 // We didn't expect the animation to finish yet
7585 application.SendNotification();
7586 finishCheck.CheckSignalNotReceived();
7587 DALI_TEST_CHECK( !actor.IsVisible() );
7589 application.SendNotification();
7590 application.Render(static_cast<unsigned int>(durationSeconds*10.0f)/*Should be shown now*/);
7592 // We didn't expect the animation to finish yet
7593 application.SendNotification();
7594 finishCheck.CheckSignalNotReceived();
7595 DALI_TEST_CHECK( actor.IsVisible() );
7597 application.SendNotification();
7598 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
7600 // We did expect the animation to finish
7601 application.SendNotification();
7602 finishCheck.CheckSignalReceived();
7603 DALI_TEST_CHECK( actor.IsVisible() );
7607 int UtcDaliAnimationHide(void)
7609 TestApplication application;
7611 Actor actor = Actor::New();
7612 DALI_TEST_CHECK( actor.IsVisible() );
7613 Stage::GetCurrent().Add(actor);
7615 // Start the animation
7616 float durationSeconds(10.0f);
7617 Animation animation = Animation::New(durationSeconds);
7618 animation.Hide(actor, durationSeconds*0.5f);
7621 bool signalReceived(false);
7622 AnimationFinishCheck finishCheck(signalReceived);
7623 animation.FinishedSignal().Connect(&application, finishCheck);
7625 application.SendNotification();
7626 application.Render(static_cast<unsigned int>(durationSeconds*490.0f));
7628 // We didn't expect the animation to finish yet
7629 application.SendNotification();
7630 finishCheck.CheckSignalNotReceived();
7631 DALI_TEST_CHECK( actor.IsVisible() );
7633 application.SendNotification();
7634 application.Render(static_cast<unsigned int>(durationSeconds*10.0f)/*Should be hidden now*/);
7636 // We didn't expect the animation to finish yet
7637 application.SendNotification();
7638 finishCheck.CheckSignalNotReceived();
7639 DALI_TEST_CHECK( !actor.IsVisible() );
7641 application.SendNotification();
7642 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
7644 // We did expect the animation to finish
7645 application.SendNotification();
7646 finishCheck.CheckSignalReceived();
7647 DALI_TEST_CHECK( !actor.IsVisible() );
7651 int UtcDaliAnimationShowHideAtEnd(void)
7653 // Test that show/hide delay can be the same as animation duration
7654 // i.e. to show/hide at the end of the animation
7656 TestApplication application;
7658 Actor actor = Actor::New();
7659 DALI_TEST_CHECK( actor.IsVisible() );
7660 Stage::GetCurrent().Add(actor);
7662 // Start Hide animation
7663 float durationSeconds(10.0f);
7664 Animation animation = Animation::New(durationSeconds);
7665 animation.Hide(actor, durationSeconds/*Hide at end*/);
7668 bool signalReceived(false);
7669 AnimationFinishCheck finishCheck(signalReceived);
7670 animation.FinishedSignal().Connect(&application, finishCheck);
7672 application.SendNotification();
7673 application.Render(static_cast<unsigned int>(durationSeconds*1000.0f) + 1u/*just beyond the animation duration*/);
7675 // We did expect the animation to finish
7676 application.SendNotification();
7677 finishCheck.CheckSignalReceived();
7678 DALI_TEST_CHECK( !actor.IsVisible() );
7680 // Start Show animation
7681 animation = Animation::New(durationSeconds);
7682 animation.Show(actor, durationSeconds/*Show at end*/);
7683 animation.FinishedSignal().Connect(&application, finishCheck);
7686 application.SendNotification();
7687 application.Render(static_cast<unsigned int>(durationSeconds*1000.0f) + 1u/*just beyond the animation duration*/);
7689 // We did expect the animation to finish
7690 application.SendNotification();
7691 finishCheck.CheckSignalReceived();
7692 DALI_TEST_CHECK( actor.IsVisible() );
7696 int UtcDaliAnimationOpacityBy(void)
7698 TestApplication application;
7699 Actor actor = Actor::New();
7700 float startingOpacity(0.5f);
7701 actor.SetOpacity(startingOpacity);
7702 application.SendNotification();
7703 application.Render(0);
7704 DALI_TEST_EQUALS( actor.GetCurrentOpacity(), startingOpacity, TEST_LOCATION );
7705 Stage::GetCurrent().Add(actor);
7707 // Build the animation
7708 float durationSeconds(1.0f);
7709 Animation animation = Animation::New(durationSeconds);
7710 float relativeOpacity(-0.5f); // target of zero
7711 animation.OpacityBy(actor, relativeOpacity);
7713 float seventyFivePercentProgress((1.0f - 0.75f) * startingOpacity);
7715 // Start the animation
7718 bool signalReceived(false);
7719 AnimationFinishCheck finishCheck(signalReceived);
7720 animation.FinishedSignal().Connect(&application, finishCheck);
7722 application.SendNotification();
7723 application.Render(static_cast<unsigned int>(durationSeconds*750.0f)/* 75% progress */);
7725 // We didn't expect the animation to finish yet
7726 application.SendNotification();
7727 finishCheck.CheckSignalNotReceived();
7728 DALI_TEST_EQUALS( actor.GetCurrentOpacity(), seventyFivePercentProgress, TEST_LOCATION );
7730 application.SendNotification();
7731 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7733 // We did expect the animation to finish
7734 application.SendNotification();
7735 finishCheck.CheckSignalReceived();
7736 DALI_TEST_EQUALS( actor.GetCurrentOpacity(), startingOpacity+relativeOpacity, TEST_LOCATION );
7739 finishCheck.Reset();
7740 actor.SetOpacity(startingOpacity);
7741 application.SendNotification();
7742 application.Render(0);
7743 DALI_TEST_EQUALS( actor.GetCurrentOpacity(), startingOpacity, TEST_LOCATION );
7745 // Repeat with a different (ease-in) alpha function
7746 animation = Animation::New(durationSeconds);
7747 animation.OpacityBy(actor, relativeOpacity, AlphaFunctions::EaseIn);
7748 animation.FinishedSignal().Connect(&application, finishCheck);
7751 application.SendNotification();
7752 application.Render(static_cast<unsigned int>(durationSeconds*750.0f)/* 75% progress */);
7754 // We didn't expect the animation to finish yet
7755 application.SendNotification();
7756 finishCheck.CheckSignalNotReceived();
7758 // The opacity should reduce less, than with a linear alpha function
7759 float current(actor.GetCurrentOpacity());
7760 DALI_TEST_CHECK( current < 1.0f );
7761 DALI_TEST_CHECK( current > seventyFivePercentProgress );
7763 application.SendNotification();
7764 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7766 // We did expect the animation to finish
7767 application.SendNotification();
7768 finishCheck.CheckSignalReceived();
7769 DALI_TEST_EQUALS( actor.GetCurrentOpacity(), startingOpacity+relativeOpacity, TEST_LOCATION );
7772 finishCheck.Reset();
7773 actor.SetOpacity(startingOpacity);
7774 application.SendNotification();
7775 application.Render(0);
7776 DALI_TEST_EQUALS( actor.GetCurrentOpacity(), startingOpacity, TEST_LOCATION );
7778 // Repeat with a delay
7780 animation = Animation::New(durationSeconds);
7781 animation.OpacityBy(actor, relativeOpacity, AlphaFunctions::Linear, delay, durationSeconds - delay);
7782 animation.FinishedSignal().Connect(&application, finishCheck);
7785 application.SendNotification();
7786 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
7788 // We didn't expect the animation to finish yet
7789 application.SendNotification();
7790 finishCheck.CheckSignalNotReceived();
7791 DALI_TEST_EQUALS( actor.GetCurrentOpacity(), startingOpacity, TEST_LOCATION );
7793 application.SendNotification();
7794 application.Render(static_cast<unsigned int>(durationSeconds*500.0f*0.75)/* 7/8 animation progress, 3/4 animator progress */);
7796 // We didn't expect the animation to finish yet
7797 application.SendNotification();
7798 finishCheck.CheckSignalNotReceived();
7799 DALI_TEST_EQUALS( actor.GetCurrentOpacity(), seventyFivePercentProgress, TEST_LOCATION );
7801 application.SendNotification();
7802 application.Render(static_cast<unsigned int>(durationSeconds*500.0f*0.25) + 1u/*just beyond the animation duration*/);
7804 // We did expect the animation to finish
7805 application.SendNotification();
7806 finishCheck.CheckSignalReceived();
7807 DALI_TEST_EQUALS( actor.GetCurrentOpacity(), startingOpacity+relativeOpacity, TEST_LOCATION );
7811 int UtcDaliAnimationOpacityTo(void)
7813 TestApplication application;
7815 Actor actor = Actor::New();
7816 Stage::GetCurrent().Add(actor);
7817 DALI_TEST_EQUALS( actor.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
7819 // Build the animation
7820 float durationSeconds(1.0f);
7821 Animation animation = Animation::New(durationSeconds);
7822 float targetOpacity(0.0f);
7823 animation.OpacityTo(actor, targetOpacity);
7825 float ninetyNinePercentProgress(0.01f);
7827 // Start the animation
7830 bool signalReceived(false);
7831 AnimationFinishCheck finishCheck(signalReceived);
7832 animation.FinishedSignal().Connect(&application, finishCheck);
7834 application.SendNotification();
7835 application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
7837 // We didn't expect the animation to finish yet
7838 application.SendNotification();
7839 finishCheck.CheckSignalNotReceived();
7840 DALI_TEST_EQUALS( actor.GetCurrentOpacity(), ninetyNinePercentProgress, 0.001f, TEST_LOCATION );
7842 application.SendNotification();
7843 application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
7845 // We did expect the animation to finish
7846 application.SendNotification();
7847 finishCheck.CheckSignalReceived();
7848 DALI_TEST_EQUALS( actor.GetCurrentOpacity(), targetOpacity, TEST_LOCATION );
7851 finishCheck.Reset();
7852 actor.SetOpacity(1.0f);
7853 application.SendNotification();
7854 application.Render(0);
7855 DALI_TEST_EQUALS( actor.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
7857 // Repeat with a different (ease-in) alpha function
7858 animation = Animation::New(durationSeconds);
7859 animation.OpacityTo(actor, targetOpacity, AlphaFunctions::EaseIn);
7860 animation.FinishedSignal().Connect(&application, finishCheck);
7863 application.SendNotification();
7864 application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
7866 // We didn't expect the animation to finish yet
7867 application.SendNotification();
7868 finishCheck.CheckSignalNotReceived();
7870 // The opacity should reduce less, than with a linear alpha function
7871 float current(actor.GetCurrentOpacity());
7872 DALI_TEST_CHECK( current < 1.0f );
7873 DALI_TEST_CHECK( current > ninetyNinePercentProgress );
7875 application.SendNotification();
7876 application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
7878 // We did expect the animation to finish
7879 application.SendNotification();
7880 finishCheck.CheckSignalReceived();
7881 DALI_TEST_EQUALS( actor.GetCurrentOpacity(), targetOpacity, TEST_LOCATION );
7884 finishCheck.Reset();
7885 actor.SetOpacity(1.0f);
7886 application.SendNotification();
7887 application.Render(0);
7888 DALI_TEST_EQUALS( actor.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
7890 // Repeat with a delay
7892 animation = Animation::New(durationSeconds);
7893 animation.OpacityTo(actor, targetOpacity, AlphaFunctions::Linear, delay, durationSeconds - delay);
7894 animation.FinishedSignal().Connect(&application, finishCheck);
7897 application.SendNotification();
7898 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
7900 // We didn't expect the animation to finish yet
7901 application.SendNotification();
7902 finishCheck.CheckSignalNotReceived();
7903 DALI_TEST_EQUALS( actor.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
7905 application.SendNotification();
7906 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
7908 // We did expect the animation to finish
7909 application.SendNotification();
7910 finishCheck.CheckSignalReceived();
7911 DALI_TEST_EQUALS( actor.GetCurrentOpacity(), targetOpacity, TEST_LOCATION );
7915 int UtcDaliAnimationColorBy(void)
7917 TestApplication application;
7919 Actor actor = Actor::New();
7920 actor.SetColor(Color::BLACK);
7921 application.SendNotification();
7922 application.Render(0);
7923 DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::BLACK, TEST_LOCATION );
7924 Stage::GetCurrent().Add(actor);
7926 // Build the animation
7927 float durationSeconds(1.0f);
7928 Animation animation = Animation::New(durationSeconds);
7929 Vector4 targetColor(Color::GREEN);
7930 Vector4 relativeColor(Color::GREEN); // Note the alpha is automatically clamped <= 1.0f in world color
7931 animation.ColorBy(actor, relativeColor);
7933 Vector4 tenPercentProgress(Vector4(0.0f, 0.1f, 0.0f, 1.0f));
7934 Vector4 twentyPercentProgress(Vector4(0.0f, 0.2f, 0.0f, 1.0f));
7936 // Start the animation
7939 bool signalReceived(false);
7940 AnimationFinishCheck finishCheck(signalReceived);
7941 animation.FinishedSignal().Connect(&application, finishCheck);
7943 application.SendNotification();
7944 application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% progress */);
7946 // We didn't expect the animation to finish yet
7947 application.SendNotification();
7948 finishCheck.CheckSignalNotReceived();
7949 DALI_TEST_EQUALS( actor.GetCurrentWorldColor(), tenPercentProgress, TEST_LOCATION );
7951 application.SendNotification();
7952 application.Render(static_cast<unsigned int>(durationSeconds*900.0f) + 1u/*just beyond the animation duration*/);
7954 // We did expect the animation to finish
7955 application.SendNotification();
7956 finishCheck.CheckSignalReceived();
7957 DALI_TEST_EQUALS( actor.GetCurrentWorldColor(), targetColor, TEST_LOCATION );
7960 finishCheck.Reset();
7961 actor.SetColor(Color::BLACK);
7962 application.SendNotification();
7963 application.Render(0);
7964 DALI_TEST_EQUALS( actor.GetCurrentWorldColor(), Color::BLACK, TEST_LOCATION );
7966 // Repeat with a different (ease-in) alpha function
7967 animation = Animation::New(durationSeconds);
7968 animation.ColorBy(actor, relativeColor, AlphaFunctions::EaseIn);
7969 animation.FinishedSignal().Connect(&application, finishCheck);
7972 application.SendNotification();
7973 application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% progress */);
7975 // We didn't expect the animation to finish yet
7976 application.SendNotification();
7977 finishCheck.CheckSignalNotReceived();
7979 // The color should have changed less, than with a linear alpha function
7980 Vector4 current(actor.GetCurrentWorldColor());
7981 DALI_TEST_CHECK( current.x == 0.0f ); // doesn't change
7982 DALI_TEST_CHECK( current.y > 0.0f );
7983 DALI_TEST_CHECK( current.y < tenPercentProgress.y );
7984 DALI_TEST_CHECK( current.z == 0.0f ); // doesn't change
7985 DALI_TEST_CHECK( current.w == 1.0f ); // doesn't change
7987 application.SendNotification();
7988 application.Render(static_cast<unsigned int>(durationSeconds*900.0f) + 1u/*just beyond the animation duration*/);
7990 // We did expect the animation to finish
7991 application.SendNotification();
7992 finishCheck.CheckSignalReceived();
7993 DALI_TEST_EQUALS( actor.GetCurrentWorldColor(), targetColor, TEST_LOCATION );
7996 finishCheck.Reset();
7997 actor.SetColor(Color::BLACK);
7998 application.SendNotification();
7999 application.Render(0);
8000 DALI_TEST_EQUALS( actor.GetCurrentWorldColor(), Color::BLACK, TEST_LOCATION );
8002 // Repeat with a shorter animator duration
8003 float animatorDuration = 0.5f;
8004 animation = Animation::New(durationSeconds);
8005 animation.ColorBy(actor, relativeColor, AlphaFunctions::Linear, 0, animatorDuration);
8006 animation.FinishedSignal().Connect(&application, finishCheck);
8009 application.SendNotification();
8010 application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% animation progress, 20% animator progress */);
8012 // We didn't expect the animation to finish yet
8013 application.SendNotification();
8014 finishCheck.CheckSignalNotReceived();
8015 DALI_TEST_EQUALS( actor.GetCurrentWorldColor(), twentyPercentProgress, TEST_LOCATION );
8017 application.SendNotification();
8018 application.Render(static_cast<unsigned int>(durationSeconds*400.0f)/* 50% animation progress, 100% animator progress */);
8020 // We didn't expect the animation to finish yet
8021 application.SendNotification();
8022 finishCheck.CheckSignalNotReceived();
8023 DALI_TEST_EQUALS( actor.GetCurrentWorldColor(), targetColor, TEST_LOCATION );
8025 application.SendNotification();
8026 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
8028 // We did expect the animation to finish
8029 application.SendNotification();
8030 finishCheck.CheckSignalReceived();
8031 DALI_TEST_EQUALS( actor.GetCurrentWorldColor(), targetColor, TEST_LOCATION );
8035 int UtcDaliAnimationColorTo(void)
8037 TestApplication application;
8039 Actor actor = Actor::New();
8040 Stage::GetCurrent().Add(actor);
8041 DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
8043 // Build the animation
8044 float durationSeconds(1.0f);
8045 Animation animation = Animation::New(durationSeconds);
8046 Vector4 targetColor(Color::RED);
8047 animation.ColorTo(actor, targetColor);
8049 Vector4 tenPercentProgress(Vector4(1.0f, 0.9f, 0.9f, 1.0f));
8050 Vector4 twentyPercentProgress(Vector4(1.0f, 0.8f, 0.8f, 1.0f));
8052 // Start the animation
8055 bool signalReceived(false);
8056 AnimationFinishCheck finishCheck(signalReceived);
8057 animation.FinishedSignal().Connect(&application, finishCheck);
8059 application.SendNotification();
8060 application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% progress */);
8062 // We didn't expect the animation to finish yet
8063 application.SendNotification();
8064 finishCheck.CheckSignalNotReceived();
8065 DALI_TEST_EQUALS( actor.GetCurrentColor(), tenPercentProgress, TEST_LOCATION );
8067 application.SendNotification();
8068 application.Render(static_cast<unsigned int>(durationSeconds*900.0f) + 1u/*just beyond the animation duration*/);
8070 // We did expect the animation to finish
8071 application.SendNotification();
8072 finishCheck.CheckSignalReceived();
8073 DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION );
8076 finishCheck.Reset();
8077 actor.SetColor(Color::WHITE);
8078 application.SendNotification();
8079 application.Render(0);
8080 DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
8082 // Repeat with a different (ease-in) alpha function
8083 animation = Animation::New(durationSeconds);
8084 animation.ColorTo(actor, targetColor, AlphaFunctions::EaseIn);
8085 animation.FinishedSignal().Connect(&application, finishCheck);
8088 application.SendNotification();
8089 application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% progress */);
8091 // We didn't expect the animation to finish yet
8092 application.SendNotification();
8093 finishCheck.CheckSignalNotReceived();
8095 // The color should have changed less, than with a linear alpha function
8096 Vector4 current(actor.GetCurrentColor());
8097 DALI_TEST_CHECK( current.x == 1.0f ); // doesn't change
8098 DALI_TEST_CHECK( current.y < 1.0f );
8099 DALI_TEST_CHECK( current.y > tenPercentProgress.y );
8100 DALI_TEST_CHECK( current.z < 1.0f );
8101 DALI_TEST_CHECK( current.z > tenPercentProgress.z );
8102 DALI_TEST_CHECK( current.w == 1.0f ); // doesn't change
8104 application.SendNotification();
8105 application.Render(static_cast<unsigned int>(durationSeconds*900.0f) + 1u/*just beyond the animation duration*/);
8107 // We did expect the animation to finish
8108 application.SendNotification();
8109 finishCheck.CheckSignalReceived();
8110 DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION );
8113 finishCheck.Reset();
8114 actor.SetColor(Color::WHITE);
8115 application.SendNotification();
8116 application.Render(0);
8117 DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
8119 // Repeat with a shorter animator duration
8120 float animatorDuration = 0.5f;
8121 animation = Animation::New(durationSeconds);
8122 animation.ColorTo(actor, targetColor, AlphaFunctions::Linear, 0, animatorDuration);
8123 animation.FinishedSignal().Connect(&application, finishCheck);
8126 application.SendNotification();
8127 application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% animation progress, 20% animator progress */);
8129 // We didn't expect the animation to finish yet
8130 application.SendNotification();
8131 finishCheck.CheckSignalNotReceived();
8132 DALI_TEST_EQUALS( actor.GetCurrentColor(), twentyPercentProgress, TEST_LOCATION );
8134 application.SendNotification();
8135 application.Render(static_cast<unsigned int>(durationSeconds*400.0f)/* 50% animation progress, 100% animator progress */);
8137 // We didn't expect the animation to finish yet
8138 application.SendNotification();
8139 finishCheck.CheckSignalNotReceived();
8140 DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION );
8142 application.SendNotification();
8143 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
8145 // We did expect the animation to finish
8146 application.SendNotification();
8147 finishCheck.CheckSignalReceived();
8148 DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION );
8152 int UtcDaliAnimationResize(void)
8154 TestApplication application;
8156 Actor actor = Actor::New();
8157 Stage::GetCurrent().Add(actor);
8158 DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
8160 // Build the animation
8161 float durationSeconds(1.0f);
8162 Animation animation = Animation::New(durationSeconds);
8163 Vector3 targetSize(100.0f, 100.0f, 100.0f);
8164 animation.Resize(actor, targetSize);
8166 Vector3 ninetyNinePercentProgress(targetSize * 0.99f);
8168 // Start the animation
8171 bool signalReceived(false);
8172 AnimationFinishCheck finishCheck(signalReceived);
8173 animation.FinishedSignal().Connect(&application, finishCheck);
8175 application.SendNotification();
8176 application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
8178 // We didn't expect the animation to finish yet
8179 application.SendNotification();
8180 finishCheck.CheckSignalNotReceived();
8181 DALI_TEST_EQUALS( actor.GetCurrentSize(), ninetyNinePercentProgress, TEST_LOCATION );
8183 application.SendNotification();
8184 application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
8186 // We did expect the animation to finish
8187 application.SendNotification();
8188 finishCheck.CheckSignalReceived();
8189 DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION );
8192 finishCheck.Reset();
8193 actor.SetSize(Vector3::ZERO);
8194 application.SendNotification();
8195 application.Render(0);
8196 DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
8198 // Repeat with a different (ease-in) alpha function
8199 animation = Animation::New(durationSeconds);
8200 animation.Resize(actor, targetSize, AlphaFunctions::EaseIn);
8201 animation.FinishedSignal().Connect(&application, finishCheck);
8204 application.SendNotification();
8205 application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
8207 // We didn't expect the animation to finish yet
8208 application.SendNotification();
8209 finishCheck.CheckSignalNotReceived();
8211 // The size should have travelled less, than with a linear alpha function
8212 Vector3 current(actor.GetCurrentSize());
8213 DALI_TEST_CHECK( current.x > 0.0f );
8214 DALI_TEST_CHECK( current.y > 0.0f );
8215 DALI_TEST_CHECK( current.z > 0.0f );
8216 DALI_TEST_CHECK( current.x < ninetyNinePercentProgress.x );
8217 DALI_TEST_CHECK( current.y < ninetyNinePercentProgress.y );
8218 DALI_TEST_CHECK( current.z < ninetyNinePercentProgress.z );
8220 application.SendNotification();
8221 application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
8223 // We did expect the animation to finish
8224 application.SendNotification();
8225 finishCheck.CheckSignalReceived();
8226 DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION );
8229 finishCheck.Reset();
8230 actor.SetSize(Vector3::ZERO);
8231 application.SendNotification();
8232 application.Render(0);
8233 DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
8235 // Repeat with a delay
8237 animation = Animation::New(durationSeconds);
8238 animation.Resize(actor, targetSize, AlphaFunctions::Linear, delay, durationSeconds - delay);
8239 animation.FinishedSignal().Connect(&application, finishCheck);
8242 application.SendNotification();
8243 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
8245 // We didn't expect the animation to finish yet
8246 application.SendNotification();
8247 finishCheck.CheckSignalNotReceived();
8248 DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
8250 application.SendNotification();
8251 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
8253 // We did expect the animation to finish
8254 application.SendNotification();
8255 finishCheck.CheckSignalReceived();
8256 DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION );
8260 int UtcDaliAnimationAnimateBool(void)
8262 TestApplication application;
8264 Actor actor = Actor::New();
8265 DALI_TEST_EQUALS( actor.IsVisible(), true, TEST_LOCATION );
8266 Stage::GetCurrent().Add(actor);
8268 // Build the animation
8269 float durationSeconds(10.0f);
8270 Animation animation = Animation::New(durationSeconds);
8271 animation.Animate<bool>( Property(actor, Actor::VISIBLE), ReturnFalseAfterProgressOne, TimePeriod(durationSeconds*0.25f/*delay*/, durationSeconds*0.1f) );
8273 // Start the animation
8276 bool signalReceived(false);
8277 AnimationFinishCheck finishCheck(signalReceived);
8278 animation.FinishedSignal().Connect(&application, finishCheck);
8280 application.SendNotification();
8281 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
8283 // We didn't expect the animation to finish yet
8284 application.SendNotification();
8285 finishCheck.CheckSignalNotReceived();
8287 // Should still be visible
8288 DALI_TEST_EQUALS( actor.IsVisible(), true, TEST_LOCATION );
8290 application.SendNotification();
8291 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
8293 // We didn't expect the animation to finish yet
8294 application.SendNotification();
8295 finishCheck.CheckSignalNotReceived();
8297 // Now animate functor should have hidden the actor
8298 DALI_TEST_EQUALS( actor.IsVisible(), false, TEST_LOCATION );
8300 application.SendNotification();
8301 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
8303 // We did expect the animation to finish
8304 application.SendNotification();
8305 finishCheck.CheckSignalReceived();
8306 DALI_TEST_EQUALS( actor.IsVisible(), false, TEST_LOCATION );
8310 int UtcDaliAnimationAnimateFloat(void)
8312 TestApplication application;
8314 Actor actor = Actor::New();
8315 Stage::GetCurrent().Add(actor);
8317 // Register a float property
8318 float startValue(10.0f);
8319 Property::Index index = actor.RegisterProperty( "test-property", startValue );
8320 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
8322 // Build the animation
8323 float durationSeconds(10.0f);
8324 Animation animation = Animation::New(durationSeconds);
8325 float targetPosition(0.0f);
8326 AnimateFloatTestFunctor func( 100, targetPosition );
8327 animation.Animate<float>( Property(actor, index), func );
8329 // Start the animation
8332 bool signalReceived(false);
8333 AnimationFinishCheck finishCheck(signalReceived);
8334 animation.FinishedSignal().Connect(&application, finishCheck);
8336 application.SendNotification();
8337 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
8339 // We didn't expect the animation to finish yet
8340 application.SendNotification();
8341 finishCheck.CheckSignalNotReceived();
8342 DALI_TEST_EQUALS( actor.GetProperty<float>(index), 75.0f, TEST_LOCATION );
8344 application.SendNotification();
8345 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
8347 // We didn't expect the animation to finish yet
8348 application.SendNotification();
8349 finishCheck.CheckSignalNotReceived();
8350 DALI_TEST_EQUALS( actor.GetProperty<float>(index), 50.0f, TEST_LOCATION );
8352 application.SendNotification();
8353 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
8355 // We didn't expect the animation to finish yet
8356 application.SendNotification();
8357 finishCheck.CheckSignalNotReceived();
8358 DALI_TEST_EQUALS( actor.GetProperty<float>(index), 25.0f, TEST_LOCATION );
8360 application.SendNotification();
8361 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
8363 // We did expect the animation to finish
8364 application.SendNotification();
8365 finishCheck.CheckSignalReceived();
8366 DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetPosition, TEST_LOCATION );
8370 int UtcDaliAnimationAnimateVector2(void)
8372 TestApplication application;
8374 Actor actor = Actor::New();
8375 Stage::GetCurrent().Add(actor);
8377 // Register a Vector2 property
8378 Vector2 startValue(10.0f, 10.0f);
8379 Property::Index index = actor.RegisterProperty( "test-property", startValue );
8380 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
8382 // Build the animation
8383 float durationSeconds(10.0f);
8384 Animation animation = Animation::New(durationSeconds);
8385 Vector2 targetPosition(0.0f, 0.0f);
8386 AnimateVector2TestFunctor func( Vector2(100,100), targetPosition );
8387 animation.Animate<Vector2>( Property(actor, index), func );
8389 // Start the animation
8392 bool signalReceived(false);
8393 AnimationFinishCheck finishCheck(signalReceived);
8394 animation.FinishedSignal().Connect(&application, finishCheck);
8396 application.SendNotification();
8397 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
8399 // We didn't expect the animation to finish yet
8400 application.SendNotification();
8401 finishCheck.CheckSignalNotReceived();
8402 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), Vector2(75,75), TEST_LOCATION );
8404 application.SendNotification();
8405 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
8407 // We didn't expect the animation to finish yet
8408 application.SendNotification();
8409 finishCheck.CheckSignalNotReceived();
8410 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), Vector2(50,50), TEST_LOCATION );
8412 application.SendNotification();
8413 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
8415 // We didn't expect the animation to finish yet
8416 application.SendNotification();
8417 finishCheck.CheckSignalNotReceived();
8418 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), Vector2(25,25), TEST_LOCATION );
8420 application.SendNotification();
8421 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
8423 // We did expect the animation to finish
8424 application.SendNotification();
8425 finishCheck.CheckSignalReceived();
8426 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetPosition, TEST_LOCATION );
8430 int UtcDaliAnimationAnimateVector3(void)
8432 TestApplication application;
8434 Actor actor = Actor::New();
8435 Vector3 initialPosition(Vector3::ZERO);
8436 DALI_TEST_EQUALS( actor.GetCurrentPosition(), initialPosition, TEST_LOCATION );
8437 Stage::GetCurrent().Add(actor);
8439 // Build the animation
8440 float durationSeconds(10.0f);
8441 Animation animation = Animation::New(durationSeconds);
8442 Vector3 targetPosition(200.0f, 200.0f, 200.0f);
8443 BounceFunc func(0.0f, 0.0f, -100.0f);
8444 animation.Animate<Vector3>( Property(actor, Actor::POSITION), func, AlphaFunctions::Linear, durationSeconds );
8446 // Start the animation
8449 bool signalReceived(false);
8450 AnimationFinishCheck finishCheck(signalReceived);
8451 animation.FinishedSignal().Connect(&application, finishCheck);
8453 application.SendNotification();
8454 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
8456 // We didn't expect the animation to finish yet
8457 application.SendNotification();
8458 finishCheck.CheckSignalNotReceived();
8459 DALI_TEST_EQUALS( actor.GetCurrentPosition(), func(0.25f, initialPosition), TEST_LOCATION );
8461 application.SendNotification();
8462 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
8464 // We didn't expect the animation to finish yet
8465 application.SendNotification();
8466 finishCheck.CheckSignalNotReceived();
8467 DALI_TEST_EQUALS( actor.GetCurrentPosition(), func(0.5f, initialPosition), TEST_LOCATION );
8469 application.SendNotification();
8470 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
8472 // We didn't expect the animation to finish yet
8473 application.SendNotification();
8474 finishCheck.CheckSignalNotReceived();
8475 DALI_TEST_EQUALS( actor.GetCurrentPosition(), func(0.75f, initialPosition), TEST_LOCATION );
8477 application.SendNotification();
8478 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
8480 // We did expect the animation to finish
8481 application.SendNotification();
8482 finishCheck.CheckSignalReceived();
8483 DALI_TEST_EQUALS( actor.GetCurrentPosition(), initialPosition, TEST_LOCATION );
8487 int UtcDaliAnimationAnimateVector4(void)
8489 TestApplication application;
8491 Actor actor = Actor::New();
8492 Stage::GetCurrent().Add(actor);
8494 // Register a Vector4 property
8495 Vector4 startValue(10.0f, 10.0f, 10.0f, 10.0f);
8496 Property::Index index = actor.RegisterProperty( "test-property", startValue );
8497 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
8499 // Build the animation
8500 float durationSeconds(10.0f);
8501 Animation animation = Animation::New(durationSeconds);
8502 Vector4 targetPosition(200,400,0,-1000);
8503 AnimateVector4TestFunctor func( Vector4(1000,1000,1000,1000), targetPosition );
8504 animation.Animate<Vector4>( Property(actor, index), func );
8506 // Start the animation
8509 bool signalReceived(false);
8510 AnimationFinishCheck finishCheck(signalReceived);
8511 animation.FinishedSignal().Connect(&application, finishCheck);
8513 application.SendNotification();
8514 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
8516 // We didn't expect the animation to finish yet
8517 application.SendNotification();
8518 finishCheck.CheckSignalNotReceived();
8519 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), Vector4(800,850,750,500), TEST_LOCATION );
8521 application.SendNotification();
8522 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
8524 // We didn't expect the animation to finish yet
8525 application.SendNotification();
8526 finishCheck.CheckSignalNotReceived();
8527 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), Vector4(600,700,500,0), TEST_LOCATION );
8529 application.SendNotification();
8530 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
8532 // We didn't expect the animation to finish yet
8533 application.SendNotification();
8534 finishCheck.CheckSignalNotReceived();
8535 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), Vector4(400,550,250,-500), TEST_LOCATION );
8537 application.SendNotification();
8538 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
8540 // We did expect the animation to finish
8541 application.SendNotification();
8542 finishCheck.CheckSignalReceived();
8543 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetPosition, TEST_LOCATION );
8547 int UtcDaliAnimationAnimateQuaternion(void)
8549 TestApplication application;
8551 Actor actor = Actor::New();
8552 actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
8553 Stage::GetCurrent().Add(actor);
8554 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
8556 // Build the animation
8557 float durationSeconds(1.0f);
8558 Animation animation = Animation::New(durationSeconds);
8560 Degree sourceRotationDegrees(90.0f);
8561 Radian sourceRotationRadians(sourceRotationDegrees);
8562 Quaternion sourceRotation(sourceRotationRadians, Vector3::YAXIS);
8564 Degree targetRotationDegrees(150.0f);
8565 Radian targetRotationRadians(targetRotationDegrees);
8566 Quaternion targetRotation(targetRotationRadians, Vector3::YAXIS);
8568 AnimateQuaternionTestFunctor func( sourceRotation, targetRotation );
8569 animation.Animate<Quaternion>( Property(actor, Actor::ROTATION), func );
8571 // Start the animation
8574 bool signalReceived(false);
8575 AnimationFinishCheck finishCheck(signalReceived);
8576 animation.FinishedSignal().Connect(&application, finishCheck);
8578 application.SendNotification();
8579 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
8581 // We didn't expect the animation to finish yet
8582 application.SendNotification();
8583 finishCheck.CheckSignalNotReceived();
8584 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(Radian(Degree(105)), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
8586 application.SendNotification();
8587 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
8589 // We didn't expect the animation to finish yet
8590 application.SendNotification();
8591 finishCheck.CheckSignalNotReceived();
8592 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(Radian(Degree(120)), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
8594 application.SendNotification();
8595 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
8597 // We didn't expect the animation to finish yet
8598 application.SendNotification();
8599 finishCheck.CheckSignalNotReceived();
8600 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(Radian(Degree(135)), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
8602 application.SendNotification();
8603 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
8605 // We did expect the animation to finish
8606 application.SendNotification();
8607 finishCheck.CheckSignalReceived();
8608 DALI_TEST_EQUALS( actor.GetCurrentRotation(), targetRotation, ROTATION_EPSILON, TEST_LOCATION );
8612 int UtcDaliKeyFramesCreateDestroy(void)
8614 tet_infoline("Testing Dali::Animation::UtcDaliKeyFramesCreateDestroy()");
8616 KeyFrames* keyFrames = new KeyFrames;
8618 DALI_TEST_CHECK( true );
8622 int UtcDaliKeyFramesDownCast(void)
8624 TestApplication application;
8625 tet_infoline("Testing Dali::Animation::KeyFramesDownCast()");
8627 KeyFrames keyFrames = KeyFrames::New();
8628 BaseHandle object(keyFrames);
8630 KeyFrames keyFrames2 = KeyFrames::DownCast(object);
8631 DALI_TEST_CHECK(keyFrames2);
8633 KeyFrames keyFrames3 = DownCast< KeyFrames >(object);
8634 DALI_TEST_CHECK(keyFrames3);
8636 BaseHandle unInitializedObject;
8637 KeyFrames keyFrames4 = KeyFrames::DownCast(unInitializedObject);
8638 DALI_TEST_CHECK(!keyFrames4);
8640 KeyFrames keyFrames5 = DownCast< KeyFrames >(unInitializedObject);
8641 DALI_TEST_CHECK(!keyFrames5);
8645 int UtcDaliAnimationResizeByXY(void)
8647 TestApplication application;
8649 Actor actor = Actor::New();
8650 Stage::GetCurrent().Add(actor);
8651 DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
8653 // Build the animation
8654 float durationSeconds(1.0f);
8655 Animation animation = Animation::New(durationSeconds);
8656 Vector3 targetSize(100.0f, 100.0f, 100.0f);
8657 animation.Resize(actor, targetSize);
8659 Vector3 ninetyNinePercentProgress(targetSize * 0.99f);
8661 // Start the animation
8664 bool signalReceived(false);
8665 AnimationFinishCheck finishCheck(signalReceived);
8666 animation.FinishedSignal().Connect(&application, finishCheck);
8668 application.SendNotification();
8669 application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
8671 // We didn't expect the animation to finish yet
8672 application.SendNotification();
8673 finishCheck.CheckSignalNotReceived();
8674 DALI_TEST_EQUALS( actor.GetCurrentSize(), ninetyNinePercentProgress, TEST_LOCATION );
8676 application.SendNotification();
8677 application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
8679 // We did expect the animation to finish
8680 application.SendNotification();
8681 finishCheck.CheckSignalReceived();
8682 DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION );
8685 finishCheck.Reset();
8686 actor.SetSize(Vector3::ZERO);
8687 application.SendNotification();
8688 application.Render(0);
8689 DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
8691 // Repeat with a different (ease-in) alpha function
8692 animation = Animation::New(durationSeconds);
8693 animation.Resize(actor, targetSize.x, targetSize.y, AlphaFunctions::EaseIn);
8694 animation.FinishedSignal().Connect(&application, finishCheck);
8697 application.SendNotification();
8698 application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
8700 // We didn't expect the animation to finish yet
8701 application.SendNotification();
8702 finishCheck.CheckSignalNotReceived();
8704 // The size should have travelled less, than with a linear alpha function
8705 Vector3 current(actor.GetCurrentSize());
8706 DALI_TEST_CHECK( current.x > 0.0f );
8707 DALI_TEST_CHECK( current.y > 0.0f );
8708 DALI_TEST_CHECK( current.z > 0.0f );
8709 DALI_TEST_CHECK( current.x < ninetyNinePercentProgress.x );
8710 DALI_TEST_CHECK( current.y < ninetyNinePercentProgress.y );
8711 DALI_TEST_CHECK( current.z < ninetyNinePercentProgress.z );
8713 application.SendNotification();
8714 application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
8716 // We did expect the animation to finish
8717 application.SendNotification();
8718 finishCheck.CheckSignalReceived();
8719 DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION );
8722 finishCheck.Reset();
8723 actor.SetSize(Vector3::ZERO);
8724 application.SendNotification();
8725 application.Render(0);
8726 DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
8728 // Repeat with a delay
8730 animation = Animation::New(durationSeconds);
8731 animation.Resize(actor, targetSize.x, targetSize.y, AlphaFunctions::Linear, delay, durationSeconds - delay);
8732 animation.FinishedSignal().Connect(&application, finishCheck);
8735 application.SendNotification();
8736 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
8738 // We didn't expect the animation to finish yet
8739 application.SendNotification();
8740 finishCheck.CheckSignalNotReceived();
8741 DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
8743 application.SendNotification();
8744 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
8746 // We did expect the animation to finish
8747 application.SendNotification();
8748 finishCheck.CheckSignalReceived();
8749 DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION );
8754 int UtcDaliAnimationAnimateBetweenActorColorTimePeriod(void)
8756 TestApplication application;
8758 float startValue(1.0f);
8759 Actor actor = Actor::New();
8760 actor.SetColor(Vector4(startValue, startValue, startValue, startValue));
8761 Stage::GetCurrent().Add(actor);
8763 DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
8764 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
8765 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
8766 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
8767 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), startValue, TEST_LOCATION );
8769 // Build the animation
8770 float durationSeconds(1.0f);
8771 Animation animation = Animation::New(durationSeconds);
8773 KeyFrames keyFrames = KeyFrames::New();
8774 keyFrames.Add(0.0f, Vector4(0.1f, 0.2f, 0.3f, 0.4f));
8775 keyFrames.Add(0.5f, Vector4(0.9f, 0.8f, 0.7f, 0.6f));
8776 keyFrames.Add(1.0f, Vector4(1.0f, 1.0f, 1.0f, 1.0f));
8778 animation.AnimateBetween( Property(actor, Actor::COLOR), keyFrames, TimePeriod( 1.0f) );
8780 // Start the animation
8783 bool signalReceived(false);
8784 AnimationFinishCheck finishCheck(signalReceived);
8785 animation.FinishedSignal().Connect(&application, finishCheck);
8786 application.SendNotification();
8787 application.Render(0);
8788 application.SendNotification();
8789 finishCheck.CheckSignalNotReceived();
8790 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), 0.1f, 0.01f, TEST_LOCATION );
8791 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 0.2f, 0.01f, TEST_LOCATION );
8792 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), 0.3f, 0.01f, TEST_LOCATION );
8793 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.4f, 0.01f, TEST_LOCATION );
8795 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
8796 application.SendNotification();
8797 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), 0.5f, 0.01f, TEST_LOCATION );
8798 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 0.5f, 0.01f, TEST_LOCATION );
8799 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), 0.5f, 0.01f, TEST_LOCATION );
8800 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.5f, 0.01f, TEST_LOCATION );
8802 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
8803 application.SendNotification();
8804 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), 0.9f, 0.01f, TEST_LOCATION );
8805 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 0.8f, 0.01f, TEST_LOCATION );
8806 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), 0.7f, 0.01f, TEST_LOCATION );
8807 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.6f, 0.01f, TEST_LOCATION );
8809 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
8810 application.SendNotification();
8811 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), 0.95f, 0.01f, TEST_LOCATION );
8812 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 0.90f, 0.01f, TEST_LOCATION );
8813 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), 0.85f, 0.01f, TEST_LOCATION );
8814 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.80f, 0.01f, TEST_LOCATION );
8816 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
8817 application.SendNotification();
8818 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), 1.0f, 0.01f, TEST_LOCATION );
8819 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 1.0f, 0.01f, TEST_LOCATION );
8820 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), 1.0f, 0.01f, TEST_LOCATION );
8821 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 1.0f, 0.01f, TEST_LOCATION );
8823 // We did expect the animation to finish
8825 finishCheck.CheckSignalReceived();
8829 int UtcDaliAnimationAnimateBetweenActorColorFunction(void)
8831 TestApplication application;
8833 float startValue(1.0f);
8834 Actor actor = Actor::New();
8835 actor.SetColor(Vector4(startValue, startValue, startValue, startValue));
8836 Stage::GetCurrent().Add(actor);
8838 DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
8839 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
8840 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
8841 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
8842 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), startValue, TEST_LOCATION );
8844 // Build the animation
8845 float durationSeconds(1.0f);
8846 Animation animation = Animation::New(durationSeconds);
8848 KeyFrames keyFrames = KeyFrames::New();
8849 keyFrames.Add(0.0f, Vector4(0.1f, 0.2f, 0.3f, 0.4f));
8850 keyFrames.Add(0.5f, Vector4(0.9f, 0.8f, 0.7f, 0.6f));
8851 keyFrames.Add(1.0f, Vector4(1.0f, 1.0f, 1.0f, 1.0f));
8853 animation.AnimateBetween( Property(actor, Actor::COLOR), keyFrames, AlphaFunctions::Linear );
8855 // Start the animation
8858 bool signalReceived(false);
8859 AnimationFinishCheck finishCheck(signalReceived);
8860 animation.FinishedSignal().Connect(&application, finishCheck);
8861 application.SendNotification();
8862 application.Render(0);
8863 application.SendNotification();
8864 finishCheck.CheckSignalNotReceived();
8865 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), 0.1f, 0.01f, TEST_LOCATION );
8866 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 0.2f, 0.01f, TEST_LOCATION );
8867 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), 0.3f, 0.01f, TEST_LOCATION );
8868 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.4f, 0.01f, TEST_LOCATION );
8870 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
8871 application.SendNotification();
8872 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), 0.5f, 0.01f, TEST_LOCATION );
8873 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 0.5f, 0.01f, TEST_LOCATION );
8874 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), 0.5f, 0.01f, TEST_LOCATION );
8875 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.5f, 0.01f, TEST_LOCATION );
8877 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
8878 application.SendNotification();
8879 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), 0.9f, 0.01f, TEST_LOCATION );
8880 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 0.8f, 0.01f, TEST_LOCATION );
8881 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), 0.7f, 0.01f, TEST_LOCATION );
8882 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.6f, 0.01f, TEST_LOCATION );
8884 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
8885 application.SendNotification();
8886 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), 0.95f, 0.01f, TEST_LOCATION );
8887 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 0.90f, 0.01f, TEST_LOCATION );
8888 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), 0.85f, 0.01f, TEST_LOCATION );
8889 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.80f, 0.01f, TEST_LOCATION );
8891 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
8892 application.SendNotification();
8893 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), 1.0f, 0.01f, TEST_LOCATION );
8894 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 1.0f, 0.01f, TEST_LOCATION );
8895 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), 1.0f, 0.01f, TEST_LOCATION );
8896 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 1.0f, 0.01f, TEST_LOCATION );
8898 // We did expect the animation to finish
8900 finishCheck.CheckSignalReceived();
8904 int UtcDaliAnimationAnimateBetweenActorColorFunctionTimePeriod(void)
8906 TestApplication application;
8908 float startValue(1.0f);
8909 Actor actor = Actor::New();
8910 actor.SetColor(Vector4(startValue, startValue, startValue, startValue));
8911 Stage::GetCurrent().Add(actor);
8913 DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
8914 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
8915 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
8916 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
8917 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), startValue, TEST_LOCATION );
8919 // Build the animation
8920 float durationSeconds(1.0f);
8921 Animation animation = Animation::New(durationSeconds);
8923 KeyFrames keyFrames = KeyFrames::New();
8924 keyFrames.Add(0.0f, Vector4(0.1f, 0.2f, 0.3f, 0.4f));
8925 keyFrames.Add(0.5f, Vector4(0.9f, 0.8f, 0.7f, 0.6f));
8926 keyFrames.Add(1.0f, Vector4(1.0f, 1.0f, 1.0f, 1.0f));
8928 animation.AnimateBetween( Property(actor, Actor::COLOR), keyFrames, AlphaFunctions::Linear, TimePeriod( 1.0f) );
8930 // Start the animation
8933 bool signalReceived(false);
8934 AnimationFinishCheck finishCheck(signalReceived);
8935 animation.FinishedSignal().Connect(&application, finishCheck);
8936 application.SendNotification();
8937 application.Render(0);
8938 application.SendNotification();
8939 finishCheck.CheckSignalNotReceived();
8940 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), 0.1f, 0.01f, TEST_LOCATION );
8941 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 0.2f, 0.01f, TEST_LOCATION );
8942 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), 0.3f, 0.01f, TEST_LOCATION );
8943 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.4f, 0.01f, TEST_LOCATION );
8945 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
8946 application.SendNotification();
8947 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), 0.5f, 0.01f, TEST_LOCATION );
8948 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 0.5f, 0.01f, TEST_LOCATION );
8949 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), 0.5f, 0.01f, TEST_LOCATION );
8950 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.5f, 0.01f, TEST_LOCATION );
8952 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
8953 application.SendNotification();
8954 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), 0.9f, 0.01f, TEST_LOCATION );
8955 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 0.8f, 0.01f, TEST_LOCATION );
8956 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), 0.7f, 0.01f, TEST_LOCATION );
8957 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.6f, 0.01f, TEST_LOCATION );
8959 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
8960 application.SendNotification();
8961 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), 0.95f, 0.01f, TEST_LOCATION );
8962 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 0.90f, 0.01f, TEST_LOCATION );
8963 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), 0.85f, 0.01f, TEST_LOCATION );
8964 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.80f, 0.01f, TEST_LOCATION );
8966 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
8967 application.SendNotification();
8968 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), 1.0f, 0.01f, TEST_LOCATION );
8969 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 1.0f, 0.01f, TEST_LOCATION );
8970 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), 1.0f, 0.01f, TEST_LOCATION );
8971 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 1.0f, 0.01f, TEST_LOCATION );
8973 // We did expect the animation to finish
8975 finishCheck.CheckSignalReceived();
8979 int UtcDaliAnimationAnimateVector3Func(void)
8981 TestApplication application;
8983 Actor actor = Actor::New();
8984 Vector3 initialPosition(Vector3::ZERO);
8985 DALI_TEST_EQUALS( actor.GetCurrentPosition(), initialPosition, TEST_LOCATION );
8986 Stage::GetCurrent().Add(actor);
8988 // Build the animation
8989 float durationSeconds(10.0f);
8990 Animation animation = Animation::New(durationSeconds);
8991 Vector3 targetPosition(200.0f, 200.0f, 200.0f);
8992 BounceFunc func(0.0f, 0.0f, -100.0f);
8993 animation.Animate<Vector3>( Property(actor, Actor::POSITION), func, AlphaFunctions::Linear );
8995 // Start the animation
8998 bool signalReceived(false);
8999 AnimationFinishCheck finishCheck(signalReceived);
9000 animation.FinishedSignal().Connect(&application, finishCheck);
9002 application.SendNotification();
9003 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
9005 // We didn't expect the animation to finish yet
9006 application.SendNotification();
9007 finishCheck.CheckSignalNotReceived();
9008 DALI_TEST_EQUALS( actor.GetCurrentPosition(), func(0.25f, initialPosition), TEST_LOCATION );
9010 application.SendNotification();
9011 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
9013 // We didn't expect the animation to finish yet
9014 application.SendNotification();
9015 finishCheck.CheckSignalNotReceived();
9016 DALI_TEST_EQUALS( actor.GetCurrentPosition(), func(0.5f, initialPosition), TEST_LOCATION );
9018 application.SendNotification();
9019 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
9021 // We didn't expect the animation to finish yet
9022 application.SendNotification();
9023 finishCheck.CheckSignalNotReceived();
9024 DALI_TEST_EQUALS( actor.GetCurrentPosition(), func(0.75f, initialPosition), TEST_LOCATION );
9026 application.SendNotification();
9027 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
9029 // We did expect the animation to finish
9030 application.SendNotification();
9031 finishCheck.CheckSignalReceived();
9032 DALI_TEST_EQUALS( actor.GetCurrentPosition(), initialPosition, TEST_LOCATION );
9036 int UtcDaliAnimationCreateDestroy(void)
9038 TestApplication application;
9039 Animation* animation = new Animation;
9040 DALI_TEST_CHECK( animation );
9045 struct UpdateManagerTestConstraint
9047 UpdateManagerTestConstraint(TestApplication& application)
9048 : mApplication(application)
9052 Vector3 operator()(const Vector3& current)
9054 mApplication.SendNotification(); // Process events
9058 TestApplication& mApplication;
9061 int UtcDaliAnimationUpdateManager(void)
9063 TestApplication application;
9065 Actor actor = Actor::New();
9066 Stage::GetCurrent().Add( actor );
9068 // Build the animation
9069 Animation animation = Animation::New( 0.0f );
9071 bool signalReceived = false;
9072 AnimationFinishCheck finishCheck( signalReceived );
9073 animation.FinishedSignal().Connect( &application, finishCheck );
9075 Vector3 startValue(1.0f, 1.0f, 1.0f);
9076 Property::Index index = actor.RegisterProperty( "test-property", startValue );
9077 Constraint constraint = Constraint::New<Vector3>( index, UpdateManagerTestConstraint( application ) );
9078 actor.ApplyConstraint( constraint );
9080 // Apply animation to actor
9081 BounceFunc func(0.0f, 0.0f, -100.0f);
9082 animation.Animate<Vector3>( Property(actor, Actor::POSITION), func, AlphaFunctions::Linear );
9086 application.SendNotification();
9087 application.UpdateOnly( 16 );
9089 finishCheck.CheckSignalNotReceived();
9091 application.SendNotification(); // Process events
9093 finishCheck.CheckSignalReceived();
9098 int UtcDaliAnimationSignalOrder(void)
9100 TestApplication application;
9102 Actor actor = Actor::New();
9103 Stage::GetCurrent().Add( actor );
9105 // Build the animations
9106 Animation animation1 = Animation::New( 0.0f ); // finishes first frame
9107 Animation animation2 = Animation::New( 0.02f ); // finishes in 20 ms
9109 bool signal1Received = false;
9110 animation1.FinishedSignal().Connect( &application, AnimationFinishCheck( signal1Received ) );
9112 bool signal2Received = false;
9113 animation2.FinishedSignal().Connect( &application, AnimationFinishCheck( signal2Received ) );
9115 // Apply animations to actor
9116 animation1.AnimateTo( Property(actor, Actor::POSITION), Vector3( 3.0f, 2.0f, 1.0f ), AlphaFunctions::Linear );
9118 animation2.AnimateTo( Property(actor, Actor::SIZE ), Vector3( 10.0f, 20.0f, 30.0f ), AlphaFunctions::Linear );
9121 DALI_TEST_EQUALS( signal1Received, false, TEST_LOCATION );
9122 DALI_TEST_EQUALS( signal2Received, false, TEST_LOCATION );
9124 application.SendNotification();
9125 application.UpdateOnly( 10 ); // 10ms progress
9127 // no notifications yet
9128 DALI_TEST_EQUALS( signal1Received, false, TEST_LOCATION );
9129 DALI_TEST_EQUALS( signal2Received, false, TEST_LOCATION );
9131 application.SendNotification();
9134 DALI_TEST_EQUALS( signal1Received, true, TEST_LOCATION );
9135 DALI_TEST_EQUALS( signal2Received, false, TEST_LOCATION );
9136 signal1Received = false;
9138 // 1st animation is complete now, do another update with no ProcessEvents in between
9139 application.UpdateOnly( 20 ); // 20ms progress
9142 application.SendNotification();
9144 // 2nd should complete now
9145 DALI_TEST_EQUALS( signal1Received, false, TEST_LOCATION );
9146 DALI_TEST_EQUALS( signal2Received, true, TEST_LOCATION );