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 AnimateIntegerTestFunctor
115 AnimateIntegerTestFunctor( int start, int end )
121 int operator()( float alpha, const int& current )
123 return static_cast<int>( mStart + ((mEnd - mStart) * alpha ) + 0.5f );
130 struct AnimateVector2TestFunctor
132 AnimateVector2TestFunctor( Vector2 start, Vector2 end )
138 Vector2 operator()( float alpha, const Vector2& current )
140 return mStart + ((mEnd - mStart) * alpha );
147 struct AnimateVector4TestFunctor
149 AnimateVector4TestFunctor( Vector4 start, Vector4 end )
155 Vector4 operator()( float alpha, const Vector4& current )
157 return mStart + ((mEnd - mStart) * alpha );
164 struct AnimateQuaternionTestFunctor
166 AnimateQuaternionTestFunctor( Quaternion start, Quaternion end )
172 Quaternion operator()( float alpha, const Quaternion& current )
174 return Quaternion::Slerp(mStart, mEnd, alpha);
183 BounceFunc(float x, float y, float z)
184 : mDistance(Vector3(x, y, z))
187 Vector3 operator()(float alpha, const Vector3& current)
189 if (alpha>0.001f && alpha<1.0f)
191 const float flip = 0.5f - cosf(alpha * Math::PI * 2.0f) * 0.5f;
192 Vector3 newTranslation(current);
193 newTranslation += mDistance * flip;
194 return newTranslation;
204 TumbleFunc(Vector3 axis) : tumbleAxis(axis){}
205 Quaternion operator()(float alpha, const Quaternion& current)
207 if (alpha>0.001f && alpha<1.0f)
209 Quaternion tumbleRotation(alpha * Math::PI * 2.0f, tumbleAxis);
210 return tumbleRotation * current;
219 int UtcDaliAnimationNew01(void)
221 TestApplication application;
224 DALI_TEST_CHECK(!animation);
226 animation = Animation::New(1.0f);
228 DALI_TEST_CHECK(animation);
232 int UtcDaliAnimationNew02(void)
234 TestApplication application;
237 DALI_TEST_CHECK(!animation);
240 animation = Animation::New(0.0f);
242 catch (Dali::DaliException& e)
244 // TODO: Determine why catch doesn't.
247 // Tests that a negative test of an assertion succeeds
248 tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
249 DALI_TEST_EQUALS(e.mCondition, "durationSeconds > 0.0f", TEST_LOCATION);
254 int UtcDaliAnimationDownCast(void)
256 TestApplication application;
257 tet_infoline("Testing Dali::Animation::DownCast()");
259 float durationSeconds(1.0f);
260 Animation animation = Animation::New(durationSeconds);
262 BaseHandle object(animation);
264 Animation animation2 = Animation::DownCast(object);
265 DALI_TEST_CHECK(animation2);
267 Animation animation3 = DownCast< Animation >(object);
268 DALI_TEST_CHECK(animation3);
270 BaseHandle unInitializedObject;
271 Animation animation4 = Animation::DownCast(unInitializedObject);
272 DALI_TEST_CHECK(!animation4);
274 Animation animation5 = DownCast< Animation >(unInitializedObject);
275 DALI_TEST_CHECK(!animation5);
279 int UtcDaliAnimationSetDuration(void)
281 TestApplication application;
283 Actor actor = Actor::New();
284 Stage::GetCurrent().Add(actor);
286 // Build the animation
287 float durationSeconds(1.0f);
288 Animation animation = Animation::New(durationSeconds);
289 DALI_TEST_EQUALS(animation.GetDuration(), durationSeconds, TEST_LOCATION);
291 // Start the animation
292 Vector3 targetPosition(10.0f, 10.0f, 10.0f);
293 animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear);
296 bool signalReceived(false);
297 AnimationFinishCheck finishCheck(signalReceived);
298 animation.FinishedSignal().Connect(&application, finishCheck);
300 application.SendNotification();
301 application.Render(static_cast<unsigned int>(durationSeconds*1000.0f) - 1u/*just less than the animation duration*/);
303 // We didn't expect the animation to finish yet
304 application.SendNotification();
305 finishCheck.CheckSignalNotReceived();
307 application.Render(2u/*just beyond the animation duration*/);
309 // We did expect the animation to finish
310 application.SendNotification();
311 finishCheck.CheckSignalReceived();
312 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
314 // Restart the animation, with a different duration
316 actor.SetPosition(Vector3::ZERO);
317 durationSeconds = 3.5f;
318 animation.SetDuration(durationSeconds);
319 DALI_TEST_EQUALS(animation.GetDuration(), durationSeconds, TEST_LOCATION);
322 application.SendNotification();
323 application.Render(static_cast<unsigned int>(durationSeconds*1000.0f) - 1u/*just less than the animation duration*/);
325 // We didn't expect the animation to finish yet
326 application.SendNotification();
327 finishCheck.CheckSignalNotReceived();
329 application.Render(2u/*just beyond the animation duration*/);
331 // We did expect the animation to finish
332 application.SendNotification();
333 finishCheck.CheckSignalReceived();
334 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
336 // Check that nothing has changed after a couple of buffer swaps
337 application.Render(0);
338 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
339 application.Render(0);
340 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
344 int UtcDaliAnimationGetDuration(void)
346 TestApplication application;
348 Animation animation = Animation::New(1.0f);
349 DALI_TEST_EQUALS(animation.GetDuration(), 1.0f, TEST_LOCATION);
351 animation.SetDuration(2.0f);
352 DALI_TEST_EQUALS(animation.GetDuration(), 2.0f, TEST_LOCATION);
356 int UtcDaliAnimationSetLooping(void)
358 TestApplication application;
360 Actor actor = Actor::New();
361 Stage::GetCurrent().Add(actor);
363 // Build the animation
364 float durationSeconds(1.0f);
365 Animation animation = Animation::New(durationSeconds);
366 Vector3 targetPosition(10.0f, 10.0f, 10.0f);
367 animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear);
369 // Start the animation
370 animation.SetLooping(true);
371 DALI_TEST_CHECK(animation.IsLooping());
374 bool signalReceived(false);
375 AnimationFinishCheck finishCheck(signalReceived);
376 animation.FinishedSignal().Connect(&application, finishCheck);
378 application.SendNotification();
381 float intervalSeconds = 0.25f;
382 float progress = 0.0f;
383 for (int iterations = 0; iterations < 5;)
385 application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
387 progress += intervalSeconds;
388 DALI_TEST_EQUALS( targetPosition*progress, actor.GetCurrentPosition(), 0.001f, TEST_LOCATION );
390 if (progress >= 1.0f)
392 progress = progress - 1.0f;
397 // We didn't expect the animation to finish yet
398 application.SendNotification();
399 finishCheck.CheckSignalNotReceived();
401 animation.SetLooping(false);
402 DALI_TEST_CHECK(!animation.IsLooping());
404 application.SendNotification();
405 application.Render(static_cast<unsigned int>(durationSeconds*1000.0f) + 1u/*just beyond the animation duration*/);
407 // We did expect the animation to finish
408 application.SendNotification();
409 finishCheck.CheckSignalReceived();
410 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
412 // Check that nothing has changed after a couple of buffer swaps
413 application.Render(0);
414 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
415 application.Render(0);
416 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
420 int UtcDaliAnimationIsLooping(void)
422 TestApplication application;
424 Animation animation = Animation::New(1.0f);
425 DALI_TEST_CHECK(!animation.IsLooping());
427 animation.SetLooping(true);
428 DALI_TEST_CHECK(animation.IsLooping());
432 int UtcDaliAnimationSetEndAction(void)
434 TestApplication application;
436 Actor actor = Actor::New();
437 Stage::GetCurrent().Add(actor);
439 // Build the animation
440 float durationSeconds(1.0f);
441 Animation animation = Animation::New(durationSeconds);
442 DALI_TEST_CHECK(animation.GetEndAction() == Animation::Bake);
444 Vector3 targetPosition(10.0f, 10.0f, 10.0f);
445 animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear);
447 // Start the animation
450 bool signalReceived(false);
451 AnimationFinishCheck finishCheck(signalReceived);
452 animation.FinishedSignal().Connect(&application, finishCheck);
454 application.SendNotification();
455 application.Render(static_cast<unsigned int>(durationSeconds*1000.0f) + 1u/*just beyond the animation duration*/);
457 // We did expect the animation to finish
458 application.SendNotification();
459 finishCheck.CheckSignalReceived();
460 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
462 // Go back to the start
463 actor.SetPosition(Vector3::ZERO);
464 application.SendNotification();
465 application.Render(0);
466 DALI_TEST_EQUALS( Vector3::ZERO, actor.GetCurrentPosition(), TEST_LOCATION );
468 // Test BakeFinal, animate again, for half the duration
470 animation.SetEndAction(Animation::BakeFinal);
471 DALI_TEST_CHECK(animation.GetEndAction() == Animation::BakeFinal);
474 application.SendNotification();
475 application.Render(static_cast<unsigned int>(durationSeconds*1000.0f*0.5f) /*half of the animation duration*/);
477 // Stop the animation early
480 // We did NOT expect the animation to finish
481 application.SendNotification();
482 finishCheck.CheckSignalNotReceived();
483 DALI_TEST_EQUALS( targetPosition * 0.5f, actor.GetCurrentPosition(), VECTOR4_EPSILON, TEST_LOCATION );
485 // Go back to the start
486 actor.SetPosition(Vector3::ZERO);
487 application.SendNotification();
488 application.Render(0);
489 DALI_TEST_EQUALS( Vector3::ZERO, actor.GetCurrentPosition(), TEST_LOCATION );
491 // Test EndAction::Discard, animate again, but don't bake this time
493 animation.SetEndAction(Animation::Discard);
494 DALI_TEST_CHECK(animation.GetEndAction() == Animation::Discard);
497 application.SendNotification();
498 application.Render(static_cast<unsigned int>(durationSeconds*1000.0f) + 1u/*just beyond the animation duration*/);
500 // We did expect the animation to finish
501 application.SendNotification();
502 finishCheck.CheckSignalReceived();
503 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
505 // The position should be discarded in the next frame
506 application.Render(0);
507 DALI_TEST_EQUALS( Vector3::ZERO/*discarded*/, actor.GetCurrentPosition(), TEST_LOCATION );
509 // Check that nothing has changed after a couple of buffer swaps
510 application.Render(0);
511 DALI_TEST_EQUALS( Vector3::ZERO, actor.GetCurrentPosition(), TEST_LOCATION );
512 application.Render(0);
513 DALI_TEST_EQUALS( Vector3::ZERO, actor.GetCurrentPosition(), TEST_LOCATION );
517 int UtcDaliAnimationGetEndAction(void)
519 TestApplication application;
521 Animation animation = Animation::New(1.0f);
522 DALI_TEST_CHECK(animation.GetEndAction() == Animation::Bake);
524 animation.SetEndAction(Animation::Discard);
525 DALI_TEST_CHECK(animation.GetEndAction() == Animation::Discard);
527 animation.SetEndAction(Animation::BakeFinal);
528 DALI_TEST_CHECK(animation.GetEndAction() == Animation::BakeFinal);
533 int UtcDaliAnimationSetDisconnectAction(void)
535 TestApplication application;
536 Stage stage( Stage::GetCurrent() );
538 // Default: BakeFinal
540 Actor actor = Actor::New();
543 // Build the animation
544 float durationSeconds(1.0f);
545 Animation animation = Animation::New(durationSeconds);
546 DALI_TEST_CHECK(animation.GetDisconnectAction() == Animation::BakeFinal);
548 Vector3 targetPosition(10.0f, 10.0f, 10.0f);
549 animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear);
551 // Start the animation
554 application.SendNotification();
555 application.Render(static_cast<unsigned int>(durationSeconds*0.5f*1000.0f)/*Only half the animation*/);
559 application.SendNotification();
560 application.Render();
562 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
567 Actor actor = Actor::New();
570 // Build the animation
571 float durationSeconds(1.0f);
572 Animation animation = Animation::New(durationSeconds);
573 animation.SetDisconnectAction( Animation::Bake );
575 Vector3 targetPosition(10.0f, 10.0f, 10.0f);
576 animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear);
578 // Start the animation
581 application.SendNotification();
582 application.Render(static_cast<unsigned int>(durationSeconds*0.5f*1000.0f)/*Only half the animation*/);
586 application.SendNotification();
587 application.Render();
589 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition*0.5f, TEST_LOCATION );
594 Actor actor = Actor::New();
597 // Build the animation
598 float durationSeconds(1.0f);
599 Animation animation = Animation::New(durationSeconds);
600 animation.SetDisconnectAction( Animation::Discard );
602 Vector3 targetPosition(10.0f, 10.0f, 10.0f);
603 animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear);
605 // Start the animation
608 application.SendNotification();
609 application.Render(static_cast<unsigned int>(durationSeconds*0.5f*1000.0f)/*Only half the animation*/);
613 application.SendNotification();
614 application.Render();
616 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
622 int UtcDaliAnimationGetDisconnectAction(void)
624 TestApplication application;
625 Animation animation = Animation::New(1.0f);
626 DALI_TEST_CHECK(animation.GetDisconnectAction() == Animation::BakeFinal); // default!
628 animation.SetDisconnectAction(Animation::Discard);
629 DALI_TEST_CHECK(animation.GetDisconnectAction() == Animation::Discard);
631 animation.SetDisconnectAction(Animation::Bake);
632 DALI_TEST_CHECK(animation.GetDisconnectAction() == Animation::Bake);
637 int UtcDaliAnimationSetDefaultAlphaFunction(void)
639 TestApplication application;
641 Animation animation = Animation::New(1.0f);
642 AlphaFunction func = animation.GetDefaultAlphaFunction();
643 DALI_TEST_EQUALS(func(0.1f), AlphaFunctions::Linear(0.1f), TEST_LOCATION);
645 animation.SetDefaultAlphaFunction(AlphaFunctions::EaseIn);
646 AlphaFunction func2 = animation.GetDefaultAlphaFunction();
647 DALI_TEST_CHECK(func2(0.1f) < AlphaFunctions::Linear(0.1f)); // less progress when easing-in
651 int UtcDaliAnimationGetDefaultAlphaFunction(void)
653 TestApplication application;
655 Animation animation = Animation::New(1.0f);
656 AlphaFunction func = animation.GetDefaultAlphaFunction();
658 // Test that the default is linear
659 DALI_TEST_EQUALS(func(0.1f), AlphaFunctions::Linear(0.1f), TEST_LOCATION);
663 int UtcDaliAnimationPlay(void)
665 TestApplication application;
667 Actor actor = Actor::New();
668 Stage::GetCurrent().Add(actor);
670 // Build the animation
671 float durationSeconds(1.0f);
672 Animation animation = Animation::New(durationSeconds);
673 Vector3 targetPosition(100.0f, 100.0f, 100.0f);
674 animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear);
676 // Start the animation
679 bool signalReceived(false);
680 AnimationFinishCheck finishCheck(signalReceived);
681 animation.FinishedSignal().Connect(&application, finishCheck);
683 application.SendNotification();
684 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 20% progress */);
686 // We didn't expect the animation to finish yet
687 application.SendNotification();
688 finishCheck.CheckSignalNotReceived();
689 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION );
691 animation.Play(); // Test that calling play has no effect, when animation is already playing
692 application.SendNotification();
693 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 40% progress */);
695 // We didn't expect the animation to finish yet
696 application.SendNotification();
697 finishCheck.CheckSignalNotReceived();
698 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.4f), TEST_LOCATION );
700 animation.Play(); // Test that calling play has no effect, when animation is already playing
701 application.SendNotification();
702 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 60% progress */);
704 // We didn't expect the animation to finish yet
705 application.SendNotification();
706 finishCheck.CheckSignalNotReceived();
707 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.6f), TEST_LOCATION );
709 animation.Play(); // Test that calling play has no effect, when animation is already playing
710 application.SendNotification();
711 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 80% progress */);
713 // We didn't expect the animation to finish yet
714 application.SendNotification();
715 finishCheck.CheckSignalNotReceived();
716 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.8f), TEST_LOCATION );
718 animation.Play(); // Test that calling play has no effect, when animation is already playing
719 application.SendNotification();
720 application.Render(static_cast<unsigned int>(durationSeconds*200.0f) + 1u/*just beyond the animation duration*/);
722 // We did expect the animation to finish
723 application.SendNotification();
724 finishCheck.CheckSignalReceived();
725 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
727 // Check that nothing has changed after a couple of buffer swaps
728 application.Render(0);
729 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
730 application.Render(0);
731 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
735 int UtcDaliAnimationSetSpeedFactor(void)
737 TestApplication application;
739 Actor actor = Actor::New();
740 Stage::GetCurrent().Add(actor);
742 // Build the animation
743 float durationSeconds(1.0f);
744 Animation animation = Animation::New(durationSeconds);
746 const Vector3 initialPosition(0.0f, 0.0f, 0.0f);
747 const Vector3 targetPosition(100.0f, 100.0f, 100.0f);
749 KeyFrames keyframes = KeyFrames::New();
750 keyframes.Add( 0.0f, initialPosition);
751 keyframes.Add( 1.0f, targetPosition );
752 animation.AnimateBetween( Property(actor, Actor::POSITION), keyframes, AlphaFunctions::Linear);
755 animation.SetSpeedFactor(2.0f);
757 // Start the animation
760 bool signalReceived(false);
761 AnimationFinishCheck finishCheck(signalReceived);
762 animation.FinishedSignal().Connect(&application, finishCheck);
764 application.SendNotification();
765 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 40% progress */);
767 // We didn't expect the animation to finish yet
768 application.SendNotification();
769 finishCheck.CheckSignalNotReceived();
770 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.4f), TEST_LOCATION );
772 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 80% progress */);
774 // We didn't expect the animation to finish yet
775 application.SendNotification();
776 finishCheck.CheckSignalNotReceived();
777 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.8f), TEST_LOCATION );
779 application.Render(static_cast<unsigned int>(durationSeconds*100.0f) + 1u/*just beyond half the duration*/);
781 // We did expect the animation to finish
782 application.SendNotification();
783 finishCheck.CheckSignalReceived();
784 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
786 // Check that nothing has changed after a couple of buffer swaps
787 application.Render(0);
788 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
789 application.Render(0);
790 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
794 //Test -1 speed factor. Animation will play in reverse at normal speed
795 animation.SetSpeedFactor( -1.0f );
797 // Start the animation
800 application.SendNotification();
801 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 80% progress */);
803 // We didn't expect the animation to finish yet
804 application.SendNotification();
805 finishCheck.CheckSignalNotReceived();
806 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.8f), TEST_LOCATION );
808 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 60% 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.6f), TEST_LOCATION );
815 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 40% progress */);
817 // We didn't expect the animation to finish yet
818 application.SendNotification();
819 finishCheck.CheckSignalNotReceived();
820 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.4f), TEST_LOCATION );
822 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 20% progress */);
824 // We didn't expect the animation to finish yet
825 application.SendNotification();
826 finishCheck.CheckSignalNotReceived();
827 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION );
829 application.Render(static_cast<unsigned int>(durationSeconds*200.0f) + 1u/*just beyond the animation duration*/);
831 // We did expect the animation to finish
832 application.SendNotification();
833 finishCheck.CheckSignalReceived();
834 DALI_TEST_EQUALS( actor.GetCurrentPosition(), initialPosition, TEST_LOCATION );
836 // Check that nothing has changed after a couple of buffer swaps
837 application.Render(0);
838 DALI_TEST_EQUALS( initialPosition, actor.GetCurrentPosition(), TEST_LOCATION );
839 application.Render(0);
840 DALI_TEST_EQUALS( initialPosition, actor.GetCurrentPosition(), TEST_LOCATION );
843 //Test change speed factor on the fly
846 //Set speed to be half of normal speed
847 animation.SetSpeedFactor( 0.5f );
849 // Start the animation
852 application.SendNotification();
853 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 10% progress */);
855 // We didn't expect the animation to finish yet
856 application.SendNotification();
857 finishCheck.CheckSignalNotReceived();
858 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.1f), TEST_LOCATION );
860 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 20% progress */);
862 // We didn't expect the animation to finish yet
863 application.SendNotification();
864 finishCheck.CheckSignalNotReceived();
865 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION );
867 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 30% progress */);
869 // We didn't expect the animation to finish yet
870 application.SendNotification();
871 finishCheck.CheckSignalNotReceived();
872 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.3f), TEST_LOCATION );
874 //Change speed factor while animation still playing.
875 animation.SetSpeedFactor(-1.0f);
876 application.SendNotification();
877 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 10% progress */);
879 // We didn't expect the animation to finish yet
880 application.SendNotification();
881 finishCheck.CheckSignalNotReceived();
882 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.1f), TEST_LOCATION );
884 application.Render(static_cast<unsigned int>(durationSeconds*100.0f) + 1u/*just beyond the animation duration*/);
886 // We did expect the animation to finish
887 application.SendNotification();
888 finishCheck.CheckSignalReceived();
889 DALI_TEST_EQUALS( actor.GetCurrentPosition(), initialPosition, TEST_LOCATION );
891 // Check that nothing has changed after a couple of buffer swaps
892 application.Render(0);
893 DALI_TEST_EQUALS( initialPosition, actor.GetCurrentPosition(), TEST_LOCATION );
894 application.Render(0);
895 DALI_TEST_EQUALS( initialPosition, actor.GetCurrentPosition(), TEST_LOCATION );
899 int UtcDaliAnimationGetSpeedFactor(void)
901 TestApplication application;
903 Animation animation = Animation::New(1.0f);
904 animation.SetSpeedFactor(0.5f);
905 DALI_TEST_EQUALS(animation.GetSpeedFactor(), 0.5f, TEST_LOCATION);
907 animation.SetSpeedFactor(-2.5f);
908 DALI_TEST_EQUALS(animation.GetSpeedFactor(), -2.5f, TEST_LOCATION);
912 int UtcDaliAnimationPlayOffStage(void)
914 // Test that an animation can be played, when the actor is off-stage.
915 // When the actor is added to the stage, it should appear at the current position
916 // i.e. where it would have been anyway, if on-stage from the beginning.
918 TestApplication application;
920 Actor actor = Actor::New();
921 Vector3 basePosition(Vector3::ZERO);
922 DALI_TEST_EQUALS( actor.GetCurrentPosition(), basePosition, TEST_LOCATION );
923 // Not added to the stage!
925 // Build the animation
926 float durationSeconds(1.0f);
927 Animation animation = Animation::New(durationSeconds);
928 animation.SetDisconnectAction( Animation::Discard );
929 Vector3 targetPosition(100.0f, 100.0f, 100.0f);
930 animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear);
932 // Start the animation
935 bool signalReceived(false);
936 AnimationFinishCheck finishCheck(signalReceived);
937 animation.FinishedSignal().Connect(&application, finishCheck);
939 application.SendNotification();
940 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 20% progress */);
942 // We didn't expect the animation to finish yet
943 application.SendNotification();
944 finishCheck.CheckSignalNotReceived();
945 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO/*off-stage*/, TEST_LOCATION );
948 Stage::GetCurrent().Add(actor);
950 application.SendNotification();
951 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 40% progress */);
953 // We didn't expect the animation to finish yet
954 application.SendNotification();
955 finishCheck.CheckSignalNotReceived();
956 Vector3 expectedPosition(basePosition + (targetPosition - basePosition)*0.4f);
957 DALI_TEST_EQUALS( actor.GetCurrentPosition(), expectedPosition/*on-stage*/, TEST_LOCATION );
959 // Remove from the stage
960 Stage::GetCurrent().Remove(actor);
962 application.SendNotification();
963 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 60% progress */);
965 // We didn't expect the animation to finish yet
966 application.SendNotification();
967 finishCheck.CheckSignalNotReceived();
968 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO/*back to start position*/, TEST_LOCATION );
971 Stage::GetCurrent().Add(actor);
973 application.SendNotification();
974 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 80% progress */);
976 // We didn't expect the animation to finish yet
977 application.SendNotification();
978 finishCheck.CheckSignalNotReceived();
979 expectedPosition = Vector3(basePosition + (targetPosition - basePosition)*0.8f);
980 DALI_TEST_EQUALS( actor.GetCurrentPosition(), expectedPosition, TEST_LOCATION );
982 application.SendNotification();
983 application.Render(static_cast<unsigned int>(durationSeconds*200.0f) + 1u/*just beyond the animation duration*/);
985 // We did expect the animation to finish
986 application.SendNotification();
987 finishCheck.CheckSignalReceived();
988 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
990 // Check that nothing has changed after a couple of buffer swaps
991 application.Render(0);
992 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
993 application.Render(0);
994 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
998 int UtcDaliAnimationPlayDiscardHandle(void)
1000 TestApplication application;
1002 Actor actor = Actor::New();
1003 Stage::GetCurrent().Add(actor);
1005 // Build the animation
1006 float durationSeconds(1.0f);
1007 Animation animation = Animation::New(durationSeconds);
1008 Vector3 targetPosition(100.0f, 100.0f, 100.0f);
1009 animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear);
1011 bool signalReceived(false);
1012 AnimationFinishCheck finishCheck(signalReceived);
1013 animation.FinishedSignal().Connect(&application, finishCheck);
1015 // Start the animation
1018 // This is a test of the "Fire and Forget" behaviour
1019 // Discard the animation handle!
1021 DALI_TEST_CHECK( !animation );
1023 application.SendNotification();
1024 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 20% progress */);
1026 // We didn't expect the animation to finish yet
1027 application.SendNotification();
1028 finishCheck.CheckSignalNotReceived();
1029 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION );
1031 application.SendNotification();
1032 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 40% progress */);
1034 // We didn't expect the animation to finish yet
1035 application.SendNotification();
1036 finishCheck.CheckSignalNotReceived();
1037 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.4f), TEST_LOCATION );
1039 application.SendNotification();
1040 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 60% progress */);
1042 // We didn't expect the animation to finish yet
1043 application.SendNotification();
1044 finishCheck.CheckSignalNotReceived();
1045 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.6f), TEST_LOCATION );
1047 application.SendNotification();
1048 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 80% progress */);
1050 // We didn't expect the animation to finish yet
1051 application.SendNotification();
1052 finishCheck.CheckSignalNotReceived();
1053 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.8f), TEST_LOCATION );
1055 application.SendNotification();
1056 application.Render(static_cast<unsigned int>(durationSeconds*200.0f) + 1u/*just beyond the animation duration*/);
1058 // We did expect the animation to finish
1059 application.SendNotification();
1060 finishCheck.CheckSignalReceived();
1061 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
1063 // Check that nothing has changed after a couple of buffer swaps
1064 application.Render(0);
1065 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
1066 application.Render(0);
1067 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
1071 int UtcDaliAnimationPlayStopDiscardHandle(void)
1073 TestApplication application;
1075 Actor actor = Actor::New();
1076 Stage::GetCurrent().Add(actor);
1078 // Build the animation
1079 float durationSeconds(1.0f);
1080 Animation animation = Animation::New(durationSeconds);
1081 Vector3 targetPosition(100.0f, 100.0f, 100.0f);
1082 animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear);
1084 // Start the animation
1087 bool signalReceived(false);
1088 AnimationFinishCheck finishCheck(signalReceived);
1089 animation.FinishedSignal().Connect(&application, finishCheck);
1091 application.SendNotification();
1092 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 20% progress */);
1094 // We didn't expect the animation to finish yet
1095 application.SendNotification();
1096 finishCheck.CheckSignalNotReceived();
1097 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION );
1099 // This is a test of the "Fire and Forget" behaviour
1100 // Stop the animation, and Discard the animation handle!
1103 DALI_TEST_CHECK( !animation );
1105 application.SendNotification();
1106 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 40% progress */);
1108 // We expect the animation to finish at 20% progress
1109 application.SendNotification();
1110 finishCheck.CheckSignalReceived();
1111 finishCheck.Reset();
1112 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION );
1114 application.SendNotification();
1115 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 60% progress */);
1117 // Check that nothing has changed
1118 application.SendNotification();
1119 finishCheck.CheckSignalNotReceived();
1120 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION );
1122 application.SendNotification();
1123 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 80% progress */);
1125 // Check that nothing has changed
1126 application.SendNotification();
1127 finishCheck.CheckSignalNotReceived();
1128 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION );
1130 application.SendNotification();
1131 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 100% progress */);
1133 // Check that nothing has changed
1134 application.SendNotification();
1135 finishCheck.CheckSignalNotReceived();
1136 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION );
1140 int UtcDaliAnimationPlayFrom(void)
1142 TestApplication application;
1144 Actor actor = Actor::New();
1145 Stage::GetCurrent().Add(actor);
1147 // Build the animation
1148 float durationSeconds(1.0f);
1149 Animation animation = Animation::New(durationSeconds);
1150 Vector3 targetPosition(100.0f, 100.0f, 100.0f);
1151 animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear);
1153 //PlayFrom with an argument outside the range [0..1] will be ignored
1154 animation.PlayFrom(-1.0f);
1155 application.SendNotification();
1156 DALI_TEST_EQUALS(0.0f, animation.GetCurrentProgress(), TEST_LOCATION );
1158 animation.PlayFrom(100.0f);
1159 application.SendNotification();
1160 DALI_TEST_EQUALS(0.0f, animation.GetCurrentProgress(), TEST_LOCATION );
1162 // Start the animation from 40% progress
1163 animation.PlayFrom( 0.4f );
1165 bool signalReceived(false);
1166 AnimationFinishCheck finishCheck(signalReceived);
1167 animation.FinishedSignal().Connect(&application, finishCheck);
1169 application.SendNotification();
1170 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 60% progress */);
1172 // We didn't expect the animation to finish yet
1173 application.SendNotification();
1174 finishCheck.CheckSignalNotReceived();
1175 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.6f), TEST_LOCATION );
1177 animation.Play(); // Test that calling play has no effect, when animation is already playing
1178 application.SendNotification();
1179 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 80% progress */);
1181 // We didn't expect the animation to finish yet
1182 application.SendNotification();
1183 finishCheck.CheckSignalNotReceived();
1184 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.8f), TEST_LOCATION );
1186 application.Render(static_cast<unsigned int>(durationSeconds*200.0f) + 1u/*just beyond the animation duration*/);
1187 // We did expect the animation to finish
1188 application.SendNotification();
1189 finishCheck.CheckSignalReceived();
1190 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
1192 // Check that nothing has changed after a couple of buffer swaps
1193 application.Render(0);
1194 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
1195 application.Render(0);
1196 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
1200 int UtcDaliAnimationSetCurrentProgress(void)
1202 TestApplication application;
1204 Actor actor = Actor::New();
1205 Stage::GetCurrent().Add(actor);
1207 // Build the animation
1208 Animation animation = Animation::New(0.0f);
1211 //Test GetCurrentProgress return 0.0 as the duration is 0.0
1212 DALI_TEST_EQUALS( 0.0f, animation.GetCurrentProgress(), TEST_LOCATION );
1214 animation.SetCurrentProgress( 0.5f );
1215 application.SendNotification();
1216 application.Render(static_cast<unsigned int>(100.0f));
1218 //Progress should still be 0.0
1219 DALI_TEST_EQUALS( 0.0f, animation.GetCurrentProgress(), TEST_LOCATION );
1222 float durationSeconds(1.0f);
1223 animation.SetDuration(durationSeconds);
1224 application.SendNotification();
1226 bool signalReceived(false);
1227 AnimationFinishCheck finishCheck(signalReceived);
1228 animation.FinishedSignal().Connect(&application, finishCheck);
1229 application.SendNotification();
1231 Vector3 targetPosition(100.0f, 100.0f, 100.0f);
1232 animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear);
1234 //Trying to set the current cursor outside the range [0..1] is ignored
1235 animation.SetCurrentProgress( -1.0f);
1236 application.SendNotification();
1237 DALI_TEST_EQUALS( 0.0f, animation.GetCurrentProgress(), TEST_LOCATION );
1239 animation.SetCurrentProgress( 100.0f);
1240 application.SendNotification();
1241 DALI_TEST_EQUALS( 0.0f, animation.GetCurrentProgress(), TEST_LOCATION );
1243 // Start the animation from 40% progress
1244 animation.SetCurrentProgress( 0.4f );
1247 application.SendNotification();
1248 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 60% progress */);
1250 // We didn't expect the animation to finish yet
1251 application.SendNotification();
1252 finishCheck.CheckSignalNotReceived();
1253 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.6f), TEST_LOCATION );
1254 DALI_TEST_EQUALS( 0.6f, animation.GetCurrentProgress(), TEST_LOCATION );
1256 animation.Play(); // Test that calling play has no effect, when animation is already playing
1257 application.SendNotification();
1259 //Set the progress to 70%
1260 animation.SetCurrentProgress( 0.7f );
1261 application.SendNotification();
1262 application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 80% progress */);
1263 DALI_TEST_EQUALS( 0.8f, animation.GetCurrentProgress(), TEST_LOCATION );
1266 application.SendNotification();
1267 finishCheck.CheckSignalNotReceived();
1268 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.8f), TEST_LOCATION );
1269 DALI_TEST_EQUALS( 0.8f, animation.GetCurrentProgress(), TEST_LOCATION );
1273 application.Render(static_cast<unsigned int>(durationSeconds*200.0f) + 1u/*just beyond the animation duration*/);
1274 // We did expect the animation to finish
1275 application.SendNotification();
1276 finishCheck.CheckSignalReceived();
1277 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
1279 // Check that nothing has changed after a couple of buffer swaps
1280 application.Render(0);
1281 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
1282 application.Render(0);
1283 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
1287 int UtcDaliAnimationPlayRange(void)
1289 TestApplication application;
1291 Actor actor = Actor::New();
1292 Stage::GetCurrent().Add(actor);
1294 // Build the animation
1295 float durationSeconds(1.0f);
1296 Animation animation = Animation::New(durationSeconds);
1297 Vector3 targetPosition(100.0f, 100.0f, 100.0f);
1298 KeyFrames keyframes = KeyFrames::New();
1299 keyframes.Add( 0.0f , Vector3(0.0f,0.0f,0.0f ) );
1300 keyframes.Add( 1.0f , Vector3(100.0f,100.0f,100.0f ) );
1302 animation.AnimateBetween( Property( actor, Actor::POSITION), keyframes );
1304 // Set range between 0.4 and 0.8
1305 animation.SetPlayRange( Vector2(0.4f,0.8f) );
1308 bool signalReceived(false);
1309 AnimationFinishCheck finishCheck(signalReceived);
1310 animation.FinishedSignal().Connect(&application, finishCheck);
1312 //Test that setting progress outside the range doesn't work
1313 animation.SetCurrentProgress( 0.9f );
1314 application.SendNotification();
1315 application.Render(0);
1316 DALI_TEST_EQUALS( animation.GetCurrentProgress(), 0.4f, TEST_LOCATION );
1317 animation.SetCurrentProgress( 0.2f );
1318 application.SendNotification();
1319 application.Render(0);
1320 DALI_TEST_EQUALS( animation.GetCurrentProgress(), 0.4f, TEST_LOCATION );
1322 application.SendNotification();
1323 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 60% progress */);
1325 // We didn't expect the animation to finish yet
1326 application.SendNotification();
1327 finishCheck.CheckSignalNotReceived();
1328 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.6f), TEST_LOCATION );
1330 animation.Play(); // Test that calling play has no effect, when animation is already playing
1331 application.SendNotification();
1332 application.Render(static_cast<unsigned int>(durationSeconds*200.0f) + 1u/* 80% progress */);
1334 // We did expect the animation to finish
1335 application.SendNotification();
1336 finishCheck.CheckSignalReceived();
1337 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.8f), TEST_LOCATION );
1339 // Check that nothing has changed after a couple of buffer swaps
1340 application.Render(0);
1341 DALI_TEST_EQUALS( targetPosition * 0.8f, actor.GetCurrentPosition(), TEST_LOCATION );
1342 application.Render(0);
1343 DALI_TEST_EQUALS( targetPosition * 0.8f, actor.GetCurrentPosition(), TEST_LOCATION );
1346 //Loop inside the range
1347 finishCheck.Reset();
1348 animation.SetLooping( true );
1350 application.SendNotification();
1351 float intervalSeconds = 0.1f;
1352 float progress = 0.4f;
1353 for (int iterations = 0; iterations < 10; ++iterations )
1355 application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
1357 progress += intervalSeconds;
1358 if (progress > 0.8f)
1360 progress = progress - 0.4f;
1363 DALI_TEST_EQUALS( targetPosition*progress, actor.GetCurrentPosition(), 0.001f, TEST_LOCATION );
1366 // We didn't expect the animation to finish yet
1367 application.SendNotification();
1368 finishCheck.CheckSignalNotReceived();
1371 //Test change range on the fly
1372 animation.SetPlayRange( Vector2( 0.2f, 0.9f ) );
1373 application.SendNotification();
1375 for (int iterations = 0; iterations < 10; ++iterations )
1377 application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
1379 progress += intervalSeconds;
1380 if (progress > 0.9f)
1382 progress = progress - 0.7f;
1385 DALI_TEST_EQUALS( targetPosition*progress, actor.GetCurrentPosition(), 0.001f, TEST_LOCATION );
1391 int UtcDaliAnimationSetPlayRange(void)
1393 TestApplication application;
1395 Actor actor = Actor::New();
1396 Stage::GetCurrent().Add(actor);
1398 // Build the animation
1399 Animation animation = Animation::New(0);
1400 application.SendNotification();
1402 //If PlayRange not specified it should be 0.0-1.0 by default
1403 DALI_TEST_EQUALS( Vector2(0.0,1.0), animation.GetPlayRange(), TEST_LOCATION );
1405 //PlayRange out of bounds
1406 animation.SetPlayRange( Vector2(-1.0f,1.0f) );
1407 application.SendNotification();
1408 DALI_TEST_EQUALS( Vector2(0.0f,1.0f), animation.GetPlayRange(), TEST_LOCATION );
1409 animation.SetPlayRange( Vector2(0.0f,2.0f) );
1410 application.SendNotification();
1411 DALI_TEST_EQUALS( Vector2(0.0f,1.0f), animation.GetPlayRange(), TEST_LOCATION );
1413 //If playRange is not in the correct order it has to be ordered
1414 animation.SetPlayRange( Vector2(0.8f,0.2f) );
1415 application.SendNotification();
1416 DALI_TEST_EQUALS( Vector2(0.2f,0.8f), animation.GetPlayRange(), TEST_LOCATION );
1418 // Set range between 0.4 and 0.8
1419 animation.SetPlayRange( Vector2(0.4f,0.8f) );
1420 application.SendNotification();
1421 DALI_TEST_EQUALS( Vector2(0.4f,0.8f), animation.GetPlayRange(), TEST_LOCATION );
1426 int UtcDaliAnimationPause(void)
1428 TestApplication application;
1430 Actor actor = Actor::New();
1431 Stage::GetCurrent().Add(actor);
1433 // Build the animation
1434 float durationSeconds(1.0f);
1435 Animation animation = Animation::New(durationSeconds);
1436 Vector3 targetPosition(100.0f, 100.0f, 100.0f);
1437 animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear);
1439 Vector3 fiftyPercentProgress(targetPosition * 0.5f);
1441 // Start the animation
1444 bool signalReceived(false);
1445 AnimationFinishCheck finishCheck(signalReceived);
1446 animation.FinishedSignal().Connect(&application, finishCheck);
1448 application.SendNotification();
1449 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
1451 // We didn't expect the animation to finish yet
1452 application.SendNotification();
1453 finishCheck.CheckSignalNotReceived();
1454 DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress, TEST_LOCATION );
1456 // Pause the animation
1458 application.SendNotification();
1461 for (int i=0; i<5; ++i)
1463 application.Render(static_cast<unsigned int>(durationSeconds*500.0f));
1465 // We didn't expect the animation to finish yet
1466 application.SendNotification();
1467 finishCheck.CheckSignalNotReceived();
1468 DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress/* Still 50% progress when paused */, TEST_LOCATION );
1473 application.SendNotification();
1474 application.Render(static_cast<unsigned int>(durationSeconds*490.0f)/*slightly less than the animation duration*/);
1476 // We didn't expect the animation to finish yet
1477 application.SendNotification();
1478 finishCheck.CheckSignalNotReceived();
1480 application.SendNotification();
1481 application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
1483 // We did expect the animation to finish
1484 application.SendNotification();
1485 finishCheck.CheckSignalReceived();
1486 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
1488 // Check that nothing has changed after a couple of buffer swaps
1489 application.Render(0);
1490 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
1491 application.Render(0);
1492 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
1496 int UtcDaliAnimationStop(void)
1498 TestApplication application;
1500 Actor actor = Actor::New();
1501 Stage::GetCurrent().Add(actor);
1503 // Build the animation
1504 float durationSeconds(1.0f);
1505 Animation animation = Animation::New(durationSeconds);
1506 Vector3 targetPosition(100.0f, 100.0f, 100.0f);
1507 animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear);
1509 Vector3 fiftyPercentProgress(targetPosition * 0.5f);
1511 // Start the animation
1514 bool signalReceived(false);
1515 AnimationFinishCheck finishCheck(signalReceived);
1516 animation.FinishedSignal().Connect(&application, finishCheck);
1518 application.SendNotification();
1519 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
1521 // We didn't expect the animation to finish yet
1522 application.SendNotification();
1523 finishCheck.CheckSignalNotReceived();
1524 DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress, TEST_LOCATION );
1526 // Stop the animation
1528 application.SendNotification();
1531 for (int i=0; i<5; ++i)
1533 application.Render(static_cast<unsigned int>(durationSeconds*500.0f));
1535 // We did expect the animation to finish
1536 application.SendNotification();
1537 finishCheck.CheckSignalReceived();
1538 DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress/* Still 50% progress when stopped */, TEST_LOCATION );
1543 int UtcDaliAnimationStopSetPosition(void)
1545 // Test that Animation::Stop & Actor::SetPosition can be used in conjunction
1546 // i.e. to check that the animation does not interfere with the position set.
1548 TestApplication application;
1550 Actor actor = Actor::New();
1551 Stage::GetCurrent().Add(actor);
1553 // Build the animation
1554 float durationSeconds(1.0f);
1555 Animation animation = Animation::New(durationSeconds);
1556 Vector3 targetPosition(100.0f, 100.0f, 100.0f);
1557 animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear);
1559 Vector3 fiftyPercentProgress(targetPosition * 0.5f);
1561 // Start the animation
1564 bool signalReceived(false);
1565 AnimationFinishCheck finishCheck(signalReceived);
1566 animation.FinishedSignal().Connect(&application, finishCheck);
1568 application.SendNotification();
1569 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
1571 // We didn't expect the animation to finish yet
1572 application.SendNotification();
1573 finishCheck.CheckSignalNotReceived();
1574 DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress, TEST_LOCATION );
1576 // Stop the animation
1578 Vector3 positionSet(2.0f, 3.0f, 4.0f);
1579 actor.SetPosition(positionSet);
1580 application.SendNotification();
1583 for (int i=0; i<5; ++i)
1585 application.Render(static_cast<unsigned int>(durationSeconds*500.0f));
1587 // We did expect the animation to finish
1588 application.SendNotification();
1589 finishCheck.CheckSignalReceived();
1590 DALI_TEST_EQUALS( actor.GetCurrentPosition(), positionSet/*Animation should not interfere with this*/, TEST_LOCATION );
1595 int UtcDaliAnimationClear(void)
1597 TestApplication application;
1599 Actor actor = Actor::New();
1600 Stage::GetCurrent().Add(actor);
1602 // Build the animation
1603 float durationSeconds(1.0f);
1604 Animation animation = Animation::New(durationSeconds);
1605 Vector3 targetPosition(100.0f, 100.0f, 100.0f);
1606 animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear);
1608 Vector3 fiftyPercentProgress(targetPosition * 0.5f);
1610 // Start the animation
1613 bool signalReceived(false);
1614 AnimationFinishCheck finishCheck(signalReceived);
1615 animation.FinishedSignal().Connect(&application, finishCheck);
1617 application.SendNotification();
1618 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
1620 // We didn't expect the animation to finish yet
1621 application.SendNotification();
1622 finishCheck.CheckSignalNotReceived();
1623 DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress, TEST_LOCATION );
1625 // Clear the animation
1627 application.SendNotification();
1629 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
1631 // We don't expect the animation to finish now
1632 application.SendNotification();
1633 finishCheck.CheckSignalNotReceived();
1634 DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress/* Still 50% progress since the animator was destroyed */, TEST_LOCATION );
1636 // Restart as a scale animation; this should not move the actor's position
1637 finishCheck.Reset();
1638 actor.SetPosition(Vector3::ZERO);
1639 Vector3 targetScale(3.0f, 3.0f, 3.0f);
1640 animation.ScaleTo(actor, targetScale, AlphaFunctions::Linear);
1643 application.SendNotification();
1644 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
1646 // We didn't expect the animation to finish yet
1647 application.SendNotification();
1648 finishCheck.CheckSignalNotReceived();
1649 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO/*Check move-animator was destroyed*/, TEST_LOCATION );
1650 DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3(2.0f, 2.0f, 2.0f), TEST_LOCATION );
1652 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
1654 // We did expect the animation to finish
1655 application.SendNotification();
1656 finishCheck.CheckSignalReceived();
1657 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO/*Check move-animator was destroyed*/, TEST_LOCATION );
1658 DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
1662 int UtcDaliAnimationSignalFinish(void)
1664 TestApplication application;
1666 // Start the empty animation
1667 float durationSeconds(1.0f);
1668 Animation animation = Animation::New(durationSeconds);
1671 bool signalReceived(false);
1672 AnimationFinishCheck finishCheck(signalReceived);
1673 animation.FinishedSignal().Connect(&application, finishCheck);
1675 application.SendNotification();
1676 application.Render(static_cast<unsigned int>(durationSeconds*1000.0f) + 1u/*beyond the animation duration*/);
1678 // We did expect the animation to finish
1679 application.SendNotification();
1680 finishCheck.CheckSignalReceived();
1684 int UtcDaliAnimationAnimateByBoolean(void)
1686 TestApplication application;
1688 Actor actor = Actor::New();
1690 // Register a boolean property
1691 bool startValue(false);
1692 Property::Index index = actor.RegisterProperty( "test-property", startValue );
1693 Stage::GetCurrent().Add(actor);
1694 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
1696 // Build the animation
1697 float durationSeconds(2.0f);
1698 Animation animation = Animation::New(durationSeconds);
1699 const bool relativeValue(true);
1700 const bool finalValue( false || relativeValue );
1701 animation.AnimateBy(Property(actor, index), relativeValue);
1703 // Start the animation
1706 bool signalReceived(false);
1707 AnimationFinishCheck finishCheck(signalReceived);
1708 animation.FinishedSignal().Connect(&application, finishCheck);
1710 application.SendNotification();
1711 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
1713 // We didn't expect the animation to finish yet
1714 application.SendNotification();
1715 finishCheck.CheckSignalNotReceived();
1716 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
1718 application.SendNotification();
1719 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
1721 // We did expect the animation to finish
1722 application.SendNotification();
1723 finishCheck.CheckSignalReceived();
1724 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1726 // Check that nothing has changed after a couple of buffer swaps
1727 application.Render(0);
1728 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1729 application.Render(0);
1730 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1732 // Repeat with relative value "false" - this should be an NOOP
1733 animation = Animation::New(durationSeconds);
1734 bool noOpValue(false);
1735 animation.AnimateBy(Property(actor, index), noOpValue);
1737 // Start the animation
1740 finishCheck.Reset();
1741 animation.FinishedSignal().Connect(&application, finishCheck);
1743 application.SendNotification();
1744 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
1746 // We didn't expect the animation to finish yet
1747 application.SendNotification();
1748 finishCheck.CheckSignalNotReceived();
1749 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1751 application.SendNotification();
1752 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
1754 // We did expect the animation to finish
1755 application.SendNotification();
1756 finishCheck.CheckSignalReceived();
1757 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1759 // Check that nothing has changed after a couple of buffer swaps
1760 application.Render(0);
1761 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1762 application.Render(0);
1763 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1767 int UtcDaliAnimationAnimateByBooleanAlphaFunction(void)
1769 TestApplication application;
1771 Actor actor = Actor::New();
1773 // Register a boolean property
1774 bool startValue(false);
1775 Property::Index index = actor.RegisterProperty( "test-property", startValue );
1776 Stage::GetCurrent().Add(actor);
1777 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
1779 // Build the animation
1780 float durationSeconds(2.0f);
1781 Animation animation = Animation::New(durationSeconds);
1782 bool relativeValue(true);
1783 bool finalValue( false || relativeValue );
1784 animation.AnimateBy(Property(actor, index), relativeValue, AlphaFunctions::EaseIn);
1786 // Start the animation
1789 bool signalReceived(false);
1790 AnimationFinishCheck finishCheck(signalReceived);
1791 animation.FinishedSignal().Connect(&application, finishCheck);
1793 application.SendNotification();
1794 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
1796 // We didn't expect the animation to finish yet
1797 application.SendNotification();
1798 finishCheck.CheckSignalNotReceived();
1799 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
1801 application.SendNotification();
1802 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
1804 // We did expect the animation to finish
1805 application.SendNotification();
1806 finishCheck.CheckSignalReceived();
1807 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1809 // Check that nothing has changed after a couple of buffer swaps
1810 application.Render(0);
1811 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1812 application.Render(0);
1813 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1815 // Repeat with relative value "false" - this should be an NOOP
1816 animation = Animation::New(durationSeconds);
1817 bool noOpValue(false);
1818 animation.AnimateBy(Property(actor, index), noOpValue, AlphaFunctions::EaseIn);
1820 // Start the animation
1823 finishCheck.Reset();
1824 animation.FinishedSignal().Connect(&application, finishCheck);
1826 application.SendNotification();
1827 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
1829 // We didn't expect the animation to finish yet
1830 application.SendNotification();
1831 finishCheck.CheckSignalNotReceived();
1832 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1834 application.SendNotification();
1835 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
1837 // We did expect the animation to finish
1838 application.SendNotification();
1839 finishCheck.CheckSignalReceived();
1840 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1844 int UtcDaliAnimationAnimateByBooleanTimePeriod(void)
1846 TestApplication application;
1848 Actor actor = Actor::New();
1850 // Register a boolean property
1851 bool startValue(false);
1852 Property::Index index = actor.RegisterProperty( "test-property", startValue );
1853 Stage::GetCurrent().Add(actor);
1854 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
1856 // Build the animation
1857 float durationSeconds(2.0f);
1858 Animation animation = Animation::New(durationSeconds);
1859 bool relativeValue(true);
1860 bool finalValue( false || relativeValue );
1861 float animatorDurationSeconds(durationSeconds * 0.5f);
1862 animation.AnimateBy( Property(actor, index),
1864 TimePeriod( animatorDurationSeconds ) );
1866 // Start the animation
1869 bool signalReceived(false);
1870 AnimationFinishCheck finishCheck(signalReceived);
1871 animation.FinishedSignal().Connect(&application, finishCheck);
1873 application.SendNotification();
1874 application.Render(static_cast<unsigned int>(animatorDurationSeconds*950.0f)/* 95% animator progress */);
1876 // We didn't expect the animation to finish yet
1877 application.SendNotification();
1878 finishCheck.CheckSignalNotReceived();
1879 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
1881 application.SendNotification();
1882 application.Render(static_cast<unsigned int>(animatorDurationSeconds*50.0f) + 1u/*just beyond the animator duration*/);
1884 // We didn't expect the animation to finish yet...
1885 application.SendNotification();
1886 finishCheck.CheckSignalNotReceived();
1888 // ...however we should have reached the final value
1889 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1891 application.SendNotification();
1892 application.Render(static_cast<unsigned int>(animatorDurationSeconds*1000.0f)/*just beyond the animation duration*/);
1894 // We did expect the animation to finish
1895 application.SendNotification();
1896 finishCheck.CheckSignalReceived();
1897 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1899 // Check that nothing has changed after a couple of buffer swaps
1900 application.Render(0);
1901 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1902 application.Render(0);
1903 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1907 int UtcDaliAnimationAnimateByBooleanAlphaFunctionTimePeriod(void)
1909 TestApplication application;
1911 Actor actor = Actor::New();
1913 // Register a boolean property
1914 bool startValue(false);
1915 Property::Index index = actor.RegisterProperty( "test-property", startValue );
1916 Stage::GetCurrent().Add(actor);
1917 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
1919 // Build the animation
1920 float durationSeconds(2.0f);
1921 Animation animation = Animation::New(durationSeconds);
1922 bool relativeValue(true);
1923 bool finalValue( false || relativeValue );
1924 float animatorDurationSeconds(durationSeconds * 0.5f);
1925 animation.AnimateBy( Property(actor, index),
1927 AlphaFunctions::EaseInOut,
1928 TimePeriod( animatorDurationSeconds ) );
1930 // Start the animation
1933 bool signalReceived(false);
1934 AnimationFinishCheck finishCheck(signalReceived);
1935 animation.FinishedSignal().Connect(&application, finishCheck);
1937 application.SendNotification();
1938 application.Render(static_cast<unsigned int>(animatorDurationSeconds*950.0f)/* 95% animator progress */);
1940 // We didn't expect the animation to finish yet
1941 application.SendNotification();
1942 finishCheck.CheckSignalNotReceived();
1943 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
1945 application.SendNotification();
1946 application.Render(static_cast<unsigned int>(animatorDurationSeconds*50.0f) + 1u/*just beyond the animator duration*/);
1948 // We didn't expect the animation to finish yet...
1949 application.SendNotification();
1950 finishCheck.CheckSignalNotReceived();
1952 // ...however we should have reached the final value
1953 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1955 application.SendNotification();
1956 application.Render(static_cast<unsigned int>(animatorDurationSeconds*1000.0f)/*just beyond the animation duration*/);
1958 // We did expect the animation to finish
1959 application.SendNotification();
1960 finishCheck.CheckSignalReceived();
1961 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1963 // Check that nothing has changed after a couple of buffer swaps
1964 application.Render(0);
1965 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1966 application.Render(0);
1967 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1971 int UtcDaliAnimationAnimateByFloat(void)
1973 TestApplication application;
1975 Actor actor = Actor::New();
1977 // Register a float property
1978 float startValue(10.0f);
1979 Property::Index index = actor.RegisterProperty( "test-property", startValue );
1980 Stage::GetCurrent().Add(actor);
1981 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
1983 // Build the animation
1984 float durationSeconds(2.0f);
1985 Animation animation = Animation::New(durationSeconds);
1986 float targetValue(50.0f);
1987 float relativeValue(targetValue - startValue);
1988 animation.AnimateBy(Property(actor, index), relativeValue);
1990 float ninetyFivePercentProgress(startValue + relativeValue*0.95f);
1992 // Start the animation
1995 bool signalReceived(false);
1996 AnimationFinishCheck finishCheck(signalReceived);
1997 animation.FinishedSignal().Connect(&application, finishCheck);
1999 application.SendNotification();
2000 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
2002 // We didn't expect the animation to finish yet
2003 application.SendNotification();
2004 finishCheck.CheckSignalNotReceived();
2005 DALI_TEST_EQUALS( actor.GetProperty<float>(index), ninetyFivePercentProgress, TEST_LOCATION );
2007 application.SendNotification();
2008 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
2010 // We did expect the animation to finish
2011 application.SendNotification();
2012 finishCheck.CheckSignalReceived();
2013 DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
2015 // Check that nothing has changed after a couple of buffer swaps
2016 application.Render(0);
2017 DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
2018 application.Render(0);
2019 DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
2023 int UtcDaliAnimationAnimateByFloatAlphaFunction(void)
2025 TestApplication application;
2027 Actor actor = Actor::New();
2029 // Register a float property
2030 float startValue(10.0f);
2031 Property::Index index = actor.RegisterProperty( "test-property", startValue );
2032 Stage::GetCurrent().Add(actor);
2033 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
2035 // Build the animation
2036 float durationSeconds(1.0f);
2037 Animation animation = Animation::New(durationSeconds);
2038 float targetValue(90.0f);
2039 float relativeValue(targetValue - startValue);
2040 animation.AnimateBy(Property(actor, index), relativeValue, AlphaFunctions::EaseOut);
2042 float ninetyFivePercentProgress(startValue + relativeValue*0.95f);
2044 // Start the animation
2047 bool signalReceived(false);
2048 AnimationFinishCheck finishCheck(signalReceived);
2049 animation.FinishedSignal().Connect(&application, finishCheck);
2051 application.SendNotification();
2052 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
2054 // We didn't expect the animation to finish yet
2055 application.SendNotification();
2056 finishCheck.CheckSignalNotReceived();
2058 // The position should have moved more, than with a linear alpha function
2059 float current(actor.GetProperty<float>(index));
2060 DALI_TEST_CHECK( current > ninetyFivePercentProgress );
2062 application.SendNotification();
2063 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
2065 // We did expect the animation to finish
2066 application.SendNotification();
2067 finishCheck.CheckSignalReceived();
2068 DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
2070 // Check that nothing has changed after a couple of buffer swaps
2071 application.Render(0);
2072 DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
2073 application.Render(0);
2074 DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
2078 int UtcDaliAnimationAnimateByFloatTimePeriod(void)
2080 TestApplication application;
2082 Actor actor = Actor::New();
2084 // Register a float property
2085 float startValue(10.0f);
2086 Property::Index index = actor.RegisterProperty( "test-property", startValue );
2087 Stage::GetCurrent().Add(actor);
2088 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
2090 // Build the animation
2091 float durationSeconds(1.0f);
2092 Animation animation = Animation::New(durationSeconds);
2093 float targetValue(30.0f);
2094 float relativeValue(targetValue - startValue);
2096 animation.AnimateBy(Property(actor, index),
2098 TimePeriod(delay, durationSeconds - delay));
2100 // Start the animation
2103 bool signalReceived(false);
2104 AnimationFinishCheck finishCheck(signalReceived);
2105 animation.FinishedSignal().Connect(&application, finishCheck);
2107 application.SendNotification();
2108 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
2110 // We didn't expect the animation to finish yet
2111 application.SendNotification();
2112 finishCheck.CheckSignalNotReceived();
2113 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
2115 application.SendNotification();
2116 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
2118 // We didn't expect the animation to finish yet
2119 application.SendNotification();
2120 finishCheck.CheckSignalNotReceived();
2121 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
2123 application.SendNotification();
2124 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
2126 // We did expect the animation to finish
2127 application.SendNotification();
2128 finishCheck.CheckSignalReceived();
2129 DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
2131 // Check that nothing has changed after a couple of buffer swaps
2132 application.Render(0);
2133 DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
2134 application.Render(0);
2135 DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
2139 int UtcDaliAnimationAnimateByFloatAlphaFunctionTimePeriod(void)
2141 TestApplication application;
2143 Actor actor = Actor::New();
2145 // Register a float property
2146 float startValue(10.0f);
2147 Property::Index index = actor.RegisterProperty( "test-property", startValue );
2148 Stage::GetCurrent().Add(actor);
2149 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
2151 // Build the animation
2152 float durationSeconds(1.0f);
2153 Animation animation = Animation::New(durationSeconds);
2154 float targetValue(30.0f);
2155 float relativeValue(targetValue - startValue);
2157 animation.AnimateBy(Property(actor, index),
2159 AlphaFunctions::Linear,
2160 TimePeriod(delay, durationSeconds - delay));
2162 // Start the animation
2165 bool signalReceived(false);
2166 AnimationFinishCheck finishCheck(signalReceived);
2167 animation.FinishedSignal().Connect(&application, finishCheck);
2169 application.SendNotification();
2170 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
2172 // We didn't expect the animation to finish yet
2173 application.SendNotification();
2174 finishCheck.CheckSignalNotReceived();
2175 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
2177 application.SendNotification();
2178 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
2180 // We didn't expect the animation to finish yet
2181 application.SendNotification();
2182 finishCheck.CheckSignalNotReceived();
2183 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
2185 application.SendNotification();
2186 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
2188 // We did expect the animation to finish
2189 application.SendNotification();
2190 finishCheck.CheckSignalReceived();
2191 DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
2193 // Check that nothing has changed after a couple of buffer swaps
2194 application.Render(0);
2195 DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
2196 application.Render(0);
2197 DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
2201 int UtcDaliAnimationAnimateByInteger(void)
2203 TestApplication application;
2205 Actor actor = Actor::New();
2207 // Register an integer property
2209 Property::Index index = actor.RegisterProperty( "test-property", startValue );
2210 Stage::GetCurrent().Add(actor);
2211 DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
2213 // Build the animation
2214 float durationSeconds(2.0f);
2215 Animation animation = Animation::New(durationSeconds);
2216 int targetValue(50);
2217 int relativeValue(targetValue - startValue);
2218 animation.AnimateBy(Property(actor, index), relativeValue);
2220 int ninetyFivePercentProgress(static_cast<int>(startValue + relativeValue*0.95f + 0.5f));
2222 // Start the animation
2225 bool signalReceived(false);
2226 AnimationFinishCheck finishCheck(signalReceived);
2227 animation.FinishedSignal().Connect(&application, finishCheck);
2229 application.SendNotification();
2230 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
2232 // We didn't expect the animation to finish yet
2233 application.SendNotification();
2234 finishCheck.CheckSignalNotReceived();
2235 DALI_TEST_EQUALS( actor.GetProperty<int>(index), ninetyFivePercentProgress, TEST_LOCATION );
2237 application.SendNotification();
2238 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
2240 // We did expect the animation to finish
2241 application.SendNotification();
2242 finishCheck.CheckSignalReceived();
2243 DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
2245 // Check that nothing has changed after a couple of buffer swaps
2246 application.Render(0);
2247 DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
2248 application.Render(0);
2249 DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
2253 int UtcDaliAnimationAnimateByIntegerAlphaFunction(void)
2255 TestApplication application;
2257 Actor actor = Actor::New();
2259 // Register an integer property
2261 Property::Index index = actor.RegisterProperty( "test-property", startValue );
2262 Stage::GetCurrent().Add(actor);
2263 DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
2265 // Build the animation
2266 float durationSeconds(1.0f);
2267 Animation animation = Animation::New(durationSeconds);
2268 int targetValue(90);
2269 int relativeValue(targetValue - startValue);
2270 animation.AnimateBy(Property(actor, index), relativeValue, AlphaFunctions::EaseOut);
2272 int ninetyFivePercentProgress(static_cast<int>(startValue + relativeValue*0.95f + 0.5f));
2274 // Start the animation
2277 bool signalReceived(false);
2278 AnimationFinishCheck finishCheck(signalReceived);
2279 animation.FinishedSignal().Connect(&application, finishCheck);
2281 application.SendNotification();
2282 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
2284 // We didn't expect the animation to finish yet
2285 application.SendNotification();
2286 finishCheck.CheckSignalNotReceived();
2288 // The position should have moved more, than with a linear alpha function
2289 int current(actor.GetProperty<int>(index));
2290 DALI_TEST_CHECK( current > ninetyFivePercentProgress );
2292 application.SendNotification();
2293 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
2295 // We did expect the animation to finish
2296 application.SendNotification();
2297 finishCheck.CheckSignalReceived();
2298 DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
2300 // Check that nothing has changed after a couple of buffer swaps
2301 application.Render(0);
2302 DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
2303 application.Render(0);
2304 DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
2308 int UtcDaliAnimationAnimateByIntegerTimePeriod(void)
2310 TestApplication application;
2312 Actor actor = Actor::New();
2314 // Register an integer property
2316 Property::Index index = actor.RegisterProperty( "test-property", startValue );
2317 Stage::GetCurrent().Add(actor);
2318 DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
2320 // Build the animation
2321 float durationSeconds(1.0f);
2322 Animation animation = Animation::New(durationSeconds);
2323 int targetValue(30);
2324 int relativeValue(targetValue - startValue);
2326 animation.AnimateBy(Property(actor, index),
2328 TimePeriod(delay, durationSeconds - delay));
2330 // Start the animation
2333 bool signalReceived(false);
2334 AnimationFinishCheck finishCheck(signalReceived);
2335 animation.FinishedSignal().Connect(&application, finishCheck);
2337 application.SendNotification();
2338 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
2340 // We didn't expect the animation to finish yet
2341 application.SendNotification();
2342 finishCheck.CheckSignalNotReceived();
2343 DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
2345 application.SendNotification();
2346 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
2348 // We didn't expect the animation to finish yet
2349 application.SendNotification();
2350 finishCheck.CheckSignalNotReceived();
2351 DALI_TEST_EQUALS( actor.GetProperty<int>(index), static_cast<int>(startValue+(relativeValue*0.5f)+0.5f), TEST_LOCATION );
2353 application.SendNotification();
2354 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
2356 // We did expect the animation to finish
2357 application.SendNotification();
2358 finishCheck.CheckSignalReceived();
2359 DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
2361 // Check that nothing has changed after a couple of buffer swaps
2362 application.Render(0);
2363 DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
2364 application.Render(0);
2365 DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
2369 int UtcDaliAnimationAnimateByIntegerAlphaFunctionTimePeriod(void)
2371 TestApplication application;
2373 Actor actor = Actor::New();
2375 // Register an integer property
2377 Property::Index index = actor.RegisterProperty( "test-property", startValue );
2378 Stage::GetCurrent().Add(actor);
2379 DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
2381 // Build the animation
2382 float durationSeconds(1.0f);
2383 Animation animation = Animation::New(durationSeconds);
2384 int targetValue(30);
2385 int relativeValue(targetValue - startValue);
2387 animation.AnimateBy(Property(actor, index),
2389 AlphaFunctions::Linear,
2390 TimePeriod(delay, durationSeconds - delay));
2392 // Start the animation
2395 bool signalReceived(false);
2396 AnimationFinishCheck finishCheck(signalReceived);
2397 animation.FinishedSignal().Connect(&application, finishCheck);
2399 application.SendNotification();
2400 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
2402 // We didn't expect the animation to finish yet
2403 application.SendNotification();
2404 finishCheck.CheckSignalNotReceived();
2405 DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
2407 application.SendNotification();
2408 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
2410 // We didn't expect the animation to finish yet
2411 application.SendNotification();
2412 finishCheck.CheckSignalNotReceived();
2413 DALI_TEST_EQUALS( actor.GetProperty<int>(index), static_cast<int>(startValue+(relativeValue*0.5f)+0.5f), TEST_LOCATION );
2415 application.SendNotification();
2416 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
2418 // We did expect the animation to finish
2419 application.SendNotification();
2420 finishCheck.CheckSignalReceived();
2421 DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
2423 // Check that nothing has changed after a couple of buffer swaps
2424 application.Render(0);
2425 DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
2426 application.Render(0);
2427 DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
2431 int UtcDaliAnimationAnimateByVector2(void)
2433 TestApplication application;
2435 Actor actor = Actor::New();
2437 // Register a Vector2 property
2438 Vector2 startValue(10.0f, 10.0f);
2439 Property::Index index = actor.RegisterProperty( "test-property", startValue );
2440 Stage::GetCurrent().Add(actor);
2441 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
2443 // Build the animation
2444 float durationSeconds(2.0f);
2445 Animation animation = Animation::New(durationSeconds);
2446 Vector2 targetValue(60.0f, 60.0f);
2447 Vector2 relativeValue(targetValue - startValue);
2448 animation.AnimateBy(Property(actor, index), relativeValue);
2450 Vector2 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
2452 // Start the animation
2455 bool signalReceived(false);
2456 AnimationFinishCheck finishCheck(signalReceived);
2457 animation.FinishedSignal().Connect(&application, finishCheck);
2459 application.SendNotification();
2460 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
2462 // We didn't expect the animation to finish yet
2463 application.SendNotification();
2464 finishCheck.CheckSignalNotReceived();
2465 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), ninetyFivePercentProgress, TEST_LOCATION );
2467 application.SendNotification();
2468 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
2470 // We did expect the animation to finish
2471 application.SendNotification();
2472 finishCheck.CheckSignalReceived();
2473 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
2475 // Check that nothing has changed after a couple of buffer swaps
2476 application.Render(0);
2477 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
2478 application.Render(0);
2479 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
2483 int UtcDaliAnimationAnimateByVector2AlphaFunction(void)
2485 TestApplication application;
2487 Actor actor = Actor::New();
2489 // Register a Vector2 property
2490 Vector2 startValue(100.0f, 100.0f);
2491 Property::Index index = actor.RegisterProperty( "test-property", startValue );
2492 Stage::GetCurrent().Add(actor);
2493 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
2495 // Build the animation
2496 float durationSeconds(1.0f);
2497 Animation animation = Animation::New(durationSeconds);
2498 Vector2 targetValue(20.0f, 20.0f);
2499 Vector2 relativeValue(targetValue - startValue);
2500 animation.AnimateBy(Property(actor, index), relativeValue, AlphaFunctions::EaseOut);
2502 Vector2 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
2504 // Start the animation
2507 bool signalReceived(false);
2508 AnimationFinishCheck finishCheck(signalReceived);
2509 animation.FinishedSignal().Connect(&application, finishCheck);
2511 application.SendNotification();
2512 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
2514 // We didn't expect the animation to finish yet
2515 application.SendNotification();
2516 finishCheck.CheckSignalNotReceived();
2518 // The position should have moved more, than with a linear alpha function
2519 Vector2 current(actor.GetProperty<Vector2>(index));
2520 DALI_TEST_CHECK( current.x < ninetyFivePercentProgress.x );
2521 DALI_TEST_CHECK( current.y < ninetyFivePercentProgress.y );
2523 application.SendNotification();
2524 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
2526 // We did expect the animation to finish
2527 application.SendNotification();
2528 finishCheck.CheckSignalReceived();
2529 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
2531 // Check that nothing has changed after a couple of buffer swaps
2532 application.Render(0);
2533 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
2534 application.Render(0);
2535 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
2539 int UtcDaliAnimationAnimateByVector2TimePeriod(void)
2541 TestApplication application;
2543 Actor actor = Actor::New();
2545 // Register a Vector2 property
2546 Vector2 startValue(10.0f, 10.0f);
2547 Property::Index index = actor.RegisterProperty( "test-property", startValue );
2548 Stage::GetCurrent().Add(actor);
2549 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
2551 // Build the animation
2552 float durationSeconds(1.0f);
2553 Animation animation = Animation::New(durationSeconds);
2554 Vector2 targetValue(30.0f, 30.0f);
2555 Vector2 relativeValue(targetValue - startValue);
2557 animation.AnimateBy(Property(actor, index),
2559 TimePeriod(delay, durationSeconds - delay));
2561 // Start the animation
2564 bool signalReceived(false);
2565 AnimationFinishCheck finishCheck(signalReceived);
2566 animation.FinishedSignal().Connect(&application, finishCheck);
2568 application.SendNotification();
2569 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
2571 // We didn't expect the animation to finish yet
2572 application.SendNotification();
2573 finishCheck.CheckSignalNotReceived();
2574 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
2576 application.SendNotification();
2577 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
2579 // We didn't expect the animation to finish yet
2580 application.SendNotification();
2581 finishCheck.CheckSignalNotReceived();
2582 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
2584 application.SendNotification();
2585 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
2587 // We did expect the animation to finish
2588 application.SendNotification();
2589 finishCheck.CheckSignalReceived();
2590 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
2592 // Check that nothing has changed after a couple of buffer swaps
2593 application.Render(0);
2594 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
2595 application.Render(0);
2596 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
2600 int UtcDaliAnimationAnimateByVector2AlphaFunctionTimePeriod(void)
2602 TestApplication application;
2604 Actor actor = Actor::New();
2606 // Register a Vector2 property
2607 Vector2 startValue(5.0f, 5.0f);
2608 Property::Index index = actor.RegisterProperty( "test-property", startValue );
2609 Stage::GetCurrent().Add(actor);
2610 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
2612 // Build the animation
2613 float durationSeconds(1.0f);
2614 Animation animation = Animation::New(durationSeconds);
2615 Vector2 targetValue(10.0f, 10.0f);
2616 Vector2 relativeValue(targetValue - startValue);
2618 animation.AnimateBy(Property(actor, index),
2620 AlphaFunctions::Linear,
2621 TimePeriod(delay, durationSeconds - delay));
2623 // Start the animation
2626 bool signalReceived(false);
2627 AnimationFinishCheck finishCheck(signalReceived);
2628 animation.FinishedSignal().Connect(&application, finishCheck);
2630 application.SendNotification();
2631 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
2633 // We didn't expect the animation to finish yet
2634 application.SendNotification();
2635 finishCheck.CheckSignalNotReceived();
2636 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
2638 application.SendNotification();
2639 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
2641 // We didn't expect the animation to finish yet
2642 application.SendNotification();
2643 finishCheck.CheckSignalNotReceived();
2644 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
2646 application.SendNotification();
2647 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
2649 // We did expect the animation to finish
2650 application.SendNotification();
2651 finishCheck.CheckSignalReceived();
2652 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
2654 // Check that nothing has changed after a couple of buffer swaps
2655 application.Render(0);
2656 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
2657 application.Render(0);
2658 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
2662 int UtcDaliAnimationAnimateByVector3(void)
2664 TestApplication application;
2666 Actor actor = Actor::New();
2668 // Register a Vector3 property
2669 Vector3 startValue(10.0f, 10.0f, 10.0f);
2670 Property::Index index = actor.RegisterProperty( "test-property", startValue );
2671 Stage::GetCurrent().Add(actor);
2672 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
2674 // Build the animation
2675 float durationSeconds(2.0f);
2676 Animation animation = Animation::New(durationSeconds);
2677 Vector3 targetValue(60.0f, 60.0f, 60.0f);
2678 Vector3 relativeValue(targetValue - startValue);
2679 animation.AnimateBy(Property(actor, index), relativeValue);
2681 Vector3 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
2683 // Start the animation
2686 bool signalReceived(false);
2687 AnimationFinishCheck finishCheck(signalReceived);
2688 animation.FinishedSignal().Connect(&application, finishCheck);
2690 application.SendNotification();
2691 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
2693 // We didn't expect the animation to finish yet
2694 application.SendNotification();
2695 finishCheck.CheckSignalNotReceived();
2696 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), ninetyFivePercentProgress, TEST_LOCATION );
2698 application.SendNotification();
2699 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
2701 // We did expect the animation to finish
2702 application.SendNotification();
2703 finishCheck.CheckSignalReceived();
2704 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
2706 // Check that nothing has changed after a couple of buffer swaps
2707 application.Render(0);
2708 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
2709 application.Render(0);
2710 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
2714 int UtcDaliAnimationAnimateByVector3AlphaFunction(void)
2716 TestApplication application;
2718 Actor actor = Actor::New();
2720 // Register a Vector3 property
2721 Vector3 startValue(100.0f, 100.0f, 100.0f);
2722 Property::Index index = actor.RegisterProperty( "test-property", startValue );
2723 Stage::GetCurrent().Add(actor);
2724 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
2726 // Build the animation
2727 float durationSeconds(1.0f);
2728 Animation animation = Animation::New(durationSeconds);
2729 Vector3 targetValue(20.0f, 20.0f, 20.0f);
2730 Vector3 relativeValue(targetValue - startValue);
2731 animation.AnimateBy(Property(actor, index), relativeValue, AlphaFunctions::EaseOut);
2733 Vector3 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
2735 // Start the animation
2738 bool signalReceived(false);
2739 AnimationFinishCheck finishCheck(signalReceived);
2740 animation.FinishedSignal().Connect(&application, finishCheck);
2742 application.SendNotification();
2743 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
2745 // We didn't expect the animation to finish yet
2746 application.SendNotification();
2747 finishCheck.CheckSignalNotReceived();
2749 // The position should have moved more, than with a linear alpha function
2750 Vector3 current(actor.GetProperty<Vector3>(index));
2751 DALI_TEST_CHECK( current.x < ninetyFivePercentProgress.x );
2752 DALI_TEST_CHECK( current.y < ninetyFivePercentProgress.y );
2753 DALI_TEST_CHECK( current.z < ninetyFivePercentProgress.z );
2755 application.SendNotification();
2756 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
2758 // We did expect the animation to finish
2759 application.SendNotification();
2760 finishCheck.CheckSignalReceived();
2761 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
2763 // Check that nothing has changed after a couple of buffer swaps
2764 application.Render(0);
2765 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
2766 application.Render(0);
2767 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
2771 int UtcDaliAnimationAnimateByVector3TimePeriod(void)
2773 TestApplication application;
2775 Actor actor = Actor::New();
2777 // Register a Vector3 property
2778 Vector3 startValue(10.0f, 10.0f, 10.0f);
2779 Property::Index index = actor.RegisterProperty( "test-property", startValue );
2780 Stage::GetCurrent().Add(actor);
2781 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
2783 // Build the animation
2784 float durationSeconds(1.0f);
2785 Animation animation = Animation::New(durationSeconds);
2786 Vector3 targetValue(30.0f, 30.0f, 30.0f);
2787 Vector3 relativeValue(targetValue - startValue);
2789 animation.AnimateBy(Property(actor, index),
2791 TimePeriod(delay, durationSeconds - delay));
2793 // Start the animation
2796 bool signalReceived(false);
2797 AnimationFinishCheck finishCheck(signalReceived);
2798 animation.FinishedSignal().Connect(&application, finishCheck);
2800 application.SendNotification();
2801 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
2803 // We didn't expect the animation to finish yet
2804 application.SendNotification();
2805 finishCheck.CheckSignalNotReceived();
2806 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
2808 application.SendNotification();
2809 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
2811 // We didn't expect the animation to finish yet
2812 application.SendNotification();
2813 finishCheck.CheckSignalNotReceived();
2814 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
2816 application.SendNotification();
2817 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
2819 // We did expect the animation to finish
2820 application.SendNotification();
2821 finishCheck.CheckSignalReceived();
2822 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
2824 // Check that nothing has changed after a couple of buffer swaps
2825 application.Render(0);
2826 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
2827 application.Render(0);
2828 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
2832 int UtcDaliAnimationAnimateByVector3AlphaFunctionTimePeriod(void)
2834 TestApplication application;
2836 Actor actor = Actor::New();
2838 // Register a Vector3 property
2839 Vector3 startValue(5.0f, 5.0f, 5.0f);
2840 Property::Index index = actor.RegisterProperty( "test-property", startValue );
2841 Stage::GetCurrent().Add(actor);
2842 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
2844 // Build the animation
2845 float durationSeconds(1.0f);
2846 Animation animation = Animation::New(durationSeconds);
2847 Vector3 targetValue(10.0f, 10.0f, 10.0f);
2848 Vector3 relativeValue(targetValue - startValue);
2850 animation.AnimateBy(Property(actor, index),
2852 AlphaFunctions::Linear,
2853 TimePeriod(delay, durationSeconds - delay));
2855 // Start the animation
2858 bool signalReceived(false);
2859 AnimationFinishCheck finishCheck(signalReceived);
2860 animation.FinishedSignal().Connect(&application, finishCheck);
2862 application.SendNotification();
2863 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
2865 // We didn't expect the animation to finish yet
2866 application.SendNotification();
2867 finishCheck.CheckSignalNotReceived();
2868 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
2870 application.SendNotification();
2871 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
2873 // We didn't expect the animation to finish yet
2874 application.SendNotification();
2875 finishCheck.CheckSignalNotReceived();
2876 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
2878 application.SendNotification();
2879 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
2881 // We did expect the animation to finish
2882 application.SendNotification();
2883 finishCheck.CheckSignalReceived();
2884 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
2886 // Check that nothing has changed after a couple of buffer swaps
2887 application.Render(0);
2888 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
2889 application.Render(0);
2890 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
2894 int UtcDaliAnimationAnimateByVector4(void)
2896 TestApplication application;
2898 Actor actor = Actor::New();
2900 // Register a Vector4 property
2901 Vector4 startValue(10.0f, 10.0f, 10.0f, 10.0f);
2902 Property::Index index = actor.RegisterProperty( "test-property", startValue );
2903 Stage::GetCurrent().Add(actor);
2904 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
2906 // Build the animation
2907 float durationSeconds(2.0f);
2908 Animation animation = Animation::New(durationSeconds);
2909 Vector4 targetValue(60.0f, 60.0f, 60.0f, 60.0f);
2910 Vector4 relativeValue(targetValue - startValue);
2911 animation.AnimateBy(Property(actor, index), relativeValue);
2913 Vector4 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
2915 // Start the animation
2918 bool signalReceived(false);
2919 AnimationFinishCheck finishCheck(signalReceived);
2920 animation.FinishedSignal().Connect(&application, finishCheck);
2922 application.SendNotification();
2923 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
2925 // We didn't expect the animation to finish yet
2926 application.SendNotification();
2927 finishCheck.CheckSignalNotReceived();
2928 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), ninetyFivePercentProgress, TEST_LOCATION );
2930 application.SendNotification();
2931 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
2933 // We did expect the animation to finish
2934 application.SendNotification();
2935 finishCheck.CheckSignalReceived();
2936 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
2938 // Check that nothing has changed after a couple of buffer swaps
2939 application.Render(0);
2940 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
2941 application.Render(0);
2942 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
2946 int UtcDaliAnimationAnimateByVector4AlphaFunction(void)
2948 TestApplication application;
2950 Actor actor = Actor::New();
2952 // Register a Vector4 property
2953 Vector4 startValue(100.0f, 100.0f, 100.0f, 100.0f);
2954 Property::Index index = actor.RegisterProperty( "test-property", startValue );
2955 Stage::GetCurrent().Add(actor);
2956 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
2958 // Build the animation
2959 float durationSeconds(1.0f);
2960 Animation animation = Animation::New(durationSeconds);
2961 Vector4 targetValue(20.0f, 20.0f, 20.0f, 20.0f);
2962 Vector4 relativeValue(targetValue - startValue);
2963 animation.AnimateBy(Property(actor, index), relativeValue, AlphaFunctions::EaseOut);
2965 Vector4 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
2967 // Start the animation
2970 bool signalReceived(false);
2971 AnimationFinishCheck finishCheck(signalReceived);
2972 animation.FinishedSignal().Connect(&application, finishCheck);
2974 application.SendNotification();
2975 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
2977 // We didn't expect the animation to finish yet
2978 application.SendNotification();
2979 finishCheck.CheckSignalNotReceived();
2981 // The position should have moved more, than with a linear alpha function
2982 Vector4 current(actor.GetProperty<Vector4>(index));
2983 DALI_TEST_CHECK( current.x < ninetyFivePercentProgress.x );
2984 DALI_TEST_CHECK( current.y < ninetyFivePercentProgress.y );
2985 DALI_TEST_CHECK( current.z < ninetyFivePercentProgress.z );
2986 DALI_TEST_CHECK( current.w < ninetyFivePercentProgress.w );
2988 application.SendNotification();
2989 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
2991 // We did expect the animation to finish
2992 application.SendNotification();
2993 finishCheck.CheckSignalReceived();
2994 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
2996 // Check that nothing has changed after a couple of buffer swaps
2997 application.Render(0);
2998 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
2999 application.Render(0);
3000 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
3004 int UtcDaliAnimationAnimateByVector4TimePeriod(void)
3006 TestApplication application;
3008 Actor actor = Actor::New();
3010 // Register a Vector4 property
3011 Vector4 startValue(10.0f, 10.0f, 10.0f, 10.0f);
3012 Property::Index index = actor.RegisterProperty( "test-property", startValue );
3013 Stage::GetCurrent().Add(actor);
3014 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
3016 // Build the animation
3017 float durationSeconds(1.0f);
3018 Animation animation = Animation::New(durationSeconds);
3019 Vector4 targetValue(30.0f, 30.0f, 30.0f, 30.0f);
3020 Vector4 relativeValue(targetValue - startValue);
3022 animation.AnimateBy(Property(actor, index),
3024 TimePeriod(delay, durationSeconds - delay));
3026 // Start the animation
3029 bool signalReceived(false);
3030 AnimationFinishCheck finishCheck(signalReceived);
3031 animation.FinishedSignal().Connect(&application, finishCheck);
3033 application.SendNotification();
3034 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
3036 // We didn't expect the animation to finish yet
3037 application.SendNotification();
3038 finishCheck.CheckSignalNotReceived();
3039 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
3041 application.SendNotification();
3042 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
3044 // We didn't expect the animation to finish yet
3045 application.SendNotification();
3046 finishCheck.CheckSignalNotReceived();
3047 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
3049 application.SendNotification();
3050 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
3052 // We did expect the animation to finish
3053 application.SendNotification();
3054 finishCheck.CheckSignalReceived();
3055 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
3057 // Check that nothing has changed after a couple of buffer swaps
3058 application.Render(0);
3059 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
3060 application.Render(0);
3061 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
3065 int UtcDaliAnimationAnimateByVector4AlphaFunctionTimePeriod(void)
3067 TestApplication application;
3069 Actor actor = Actor::New();
3071 // Register a Vector4 property
3072 Vector4 startValue(5.0f, 5.0f, 5.0f, 5.0f);
3073 Property::Index index = actor.RegisterProperty( "test-property", startValue );
3074 Stage::GetCurrent().Add(actor);
3075 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
3077 // Build the animation
3078 float durationSeconds(1.0f);
3079 Animation animation = Animation::New(durationSeconds);
3080 Vector4 targetValue(10.0f, 10.0f, 10.0f, 10.0f);
3081 Vector4 relativeValue(targetValue - startValue);
3083 animation.AnimateBy(Property(actor, index),
3085 AlphaFunctions::Linear,
3086 TimePeriod(delay, durationSeconds - delay));
3088 // Start the animation
3091 bool signalReceived(false);
3092 AnimationFinishCheck finishCheck(signalReceived);
3093 animation.FinishedSignal().Connect(&application, finishCheck);
3095 application.SendNotification();
3096 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
3098 // We didn't expect the animation to finish yet
3099 application.SendNotification();
3100 finishCheck.CheckSignalNotReceived();
3101 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
3103 application.SendNotification();
3104 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
3106 // We didn't expect the animation to finish yet
3107 application.SendNotification();
3108 finishCheck.CheckSignalNotReceived();
3109 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
3111 application.SendNotification();
3112 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
3114 // We did expect the animation to finish
3115 application.SendNotification();
3116 finishCheck.CheckSignalReceived();
3117 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
3119 // Check that nothing has changed after a couple of buffer swaps
3120 application.Render(0);
3121 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
3122 application.Render(0);
3123 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
3127 int UtcDaliAnimationAnimateByActorPosition(void)
3129 TestApplication application;
3131 Actor actor = Actor::New();
3132 Vector3 startPosition(10.0f, 10.0f, 10.0f);
3133 actor.SetPosition(startPosition);
3134 Stage::GetCurrent().Add(actor);
3135 application.SendNotification();
3136 application.Render(0);
3137 DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION );
3139 // Build the animation
3140 float durationSeconds(1.0f);
3141 Animation animation = Animation::New(durationSeconds);
3142 Vector3 targetPosition(20.0f, 20.0f, 20.0f);
3143 Vector3 relativePosition(targetPosition - startPosition);
3144 animation.AnimateBy(Property(actor, Actor::POSITION), relativePosition);
3146 Vector3 ninetyFivePercentProgress(startPosition + relativePosition*0.95f);
3148 // Start the animation
3151 bool signalReceived(false);
3152 AnimationFinishCheck finishCheck(signalReceived);
3153 animation.FinishedSignal().Connect(&application, finishCheck);
3155 application.SendNotification();
3156 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3158 // We didn't expect the animation to finish yet
3159 application.SendNotification();
3160 finishCheck.CheckSignalNotReceived();
3161 DALI_TEST_EQUALS( actor.GetCurrentPosition(), ninetyFivePercentProgress, TEST_LOCATION );
3163 application.SendNotification();
3164 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3166 // We did expect the animation to finish
3167 application.SendNotification();
3168 finishCheck.CheckSignalReceived();
3169 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
3171 // Check that nothing has changed after a couple of buffer swaps
3172 application.Render(0);
3173 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
3174 application.Render(0);
3175 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
3179 int UtcDaliAnimationAnimateByActorPositionAlphaFunction(void)
3181 TestApplication application;
3183 Actor actor = Actor::New();
3184 Vector3 startPosition(10.0f, 10.0f, 10.0f);
3185 actor.SetPosition(startPosition);
3186 Stage::GetCurrent().Add(actor);
3187 application.SendNotification();
3188 application.Render(0);
3189 DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION );
3191 // Build the animation
3192 float durationSeconds(1.0f);
3193 Animation animation = Animation::New(durationSeconds);
3194 Vector3 targetPosition(20.0f, 20.0f, 20.0f);
3195 Vector3 relativePosition(targetPosition - startPosition);
3196 animation.AnimateBy(Property(actor, Actor::POSITION), relativePosition, AlphaFunctions::EaseOut);
3198 Vector3 ninetyFivePercentProgress(startPosition + relativePosition*0.95f);
3200 // Start the animation
3203 bool signalReceived(false);
3204 AnimationFinishCheck finishCheck(signalReceived);
3205 animation.FinishedSignal().Connect(&application, finishCheck);
3207 application.SendNotification();
3208 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3210 // We didn't expect the animation to finish yet
3211 application.SendNotification();
3212 finishCheck.CheckSignalNotReceived();
3214 // The position should have moved more, than with a linear alpha function
3215 Vector3 current(actor.GetCurrentPosition());
3216 DALI_TEST_CHECK( current.x > ninetyFivePercentProgress.x );
3217 DALI_TEST_CHECK( current.y > ninetyFivePercentProgress.y );
3218 DALI_TEST_CHECK( current.z > ninetyFivePercentProgress.z );
3220 application.SendNotification();
3221 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3223 // We did expect the animation to finish
3224 application.SendNotification();
3225 finishCheck.CheckSignalReceived();
3226 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
3228 // Check that nothing has changed after a couple of buffer swaps
3229 application.Render(0);
3230 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
3231 application.Render(0);
3232 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
3236 int UtcDaliAnimationAnimateByActorPositionTimePeriod(void)
3238 TestApplication application;
3240 Actor actor = Actor::New();
3241 Vector3 startPosition(10.0f, 10.0f, 10.0f);
3242 actor.SetPosition(startPosition);
3243 Stage::GetCurrent().Add(actor);
3244 application.SendNotification();
3245 application.Render(0);
3246 DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION );
3248 // Build the animation
3249 float durationSeconds(1.0f);
3250 Animation animation = Animation::New(durationSeconds);
3251 Vector3 targetPosition(20.0f, 20.0f, 20.0f);
3252 Vector3 relativePosition(targetPosition - startPosition);
3254 animation.AnimateBy(Property(actor, Actor::POSITION),
3256 TimePeriod(delay, durationSeconds - delay));
3258 Vector3 ninetyFivePercentProgress(startPosition + relativePosition*0.95f);
3260 // Start the animation
3263 bool signalReceived(false);
3264 AnimationFinishCheck finishCheck(signalReceived);
3265 animation.FinishedSignal().Connect(&application, finishCheck);
3267 application.SendNotification();
3268 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
3270 // We didn't expect the animation to finish yet
3271 application.SendNotification();
3272 finishCheck.CheckSignalNotReceived();
3273 DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION );
3275 application.SendNotification();
3276 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
3278 // We did expect the animation to finish
3279 application.SendNotification();
3280 finishCheck.CheckSignalReceived();
3281 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
3283 // Check that nothing has changed after a couple of buffer swaps
3284 application.Render(0);
3285 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
3286 application.Render(0);
3287 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
3291 int UtcDaliAnimationAnimateByActorPositionAlphaFunctionTimePeriod(void)
3293 TestApplication application;
3295 Actor actor = Actor::New();
3296 Vector3 startPosition(10.0f, 10.0f, 10.0f);
3297 actor.SetPosition(startPosition);
3298 Stage::GetCurrent().Add(actor);
3299 application.SendNotification();
3300 application.Render(0);
3301 DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION );
3303 // Build the animation
3304 float durationSeconds(1.0f);
3305 Animation animation = Animation::New(durationSeconds);
3306 Vector3 targetPosition(20.0f, 20.0f, 20.0f);
3307 Vector3 relativePosition(targetPosition - startPosition);
3309 animation.AnimateBy(Property(actor, Actor::POSITION),
3311 AlphaFunctions::Linear,
3312 TimePeriod(delay, durationSeconds - delay));
3314 Vector3 ninetyFivePercentProgress(startPosition + relativePosition*0.95f);
3316 // Start the animation
3319 bool signalReceived(false);
3320 AnimationFinishCheck finishCheck(signalReceived);
3321 animation.FinishedSignal().Connect(&application, finishCheck);
3323 application.SendNotification();
3324 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
3326 // We didn't expect the animation to finish yet
3327 application.SendNotification();
3328 finishCheck.CheckSignalNotReceived();
3329 DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION );
3331 application.SendNotification();
3332 application.Render(static_cast<unsigned int>(durationSeconds*500.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.GetCurrentPosition(), targetPosition, TEST_LOCATION );
3339 // Check that nothing has changed after a couple of buffer swaps
3340 application.Render(0);
3341 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
3342 application.Render(0);
3343 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
3347 int UtcDaliAnimationAnimateToBoolean(void)
3349 TestApplication application;
3351 Actor actor = Actor::New();
3353 // Register a boolean property
3354 const bool startValue(false);
3355 Property::Index index = actor.RegisterProperty( "test-property", startValue );
3356 Stage::GetCurrent().Add(actor);
3357 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
3359 // Build the animation
3360 float durationSeconds(2.0f);
3361 Animation animation = Animation::New(durationSeconds);
3362 const bool targetValue( !startValue );
3363 animation.AnimateTo(Property(actor, index), targetValue);
3365 // Start the animation
3368 bool signalReceived(false);
3369 AnimationFinishCheck finishCheck(signalReceived);
3370 animation.FinishedSignal().Connect(&application, finishCheck);
3372 application.SendNotification();
3373 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3375 // We didn't expect the animation to finish yet
3376 application.SendNotification();
3377 finishCheck.CheckSignalNotReceived();
3378 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
3380 application.SendNotification();
3381 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3383 // We did expect the animation to finish
3384 application.SendNotification();
3385 finishCheck.CheckSignalReceived();
3386 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == targetValue );
3388 // Check that nothing has changed after a couple of buffer swaps
3389 application.Render(0);
3390 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == targetValue );
3391 application.Render(0);
3392 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == targetValue );
3394 // Repeat with target value "false"
3395 animation = Animation::New(durationSeconds);
3396 const bool finalValue( !targetValue );
3397 animation.AnimateTo(Property(actor, index), finalValue);
3399 // Start the animation
3402 finishCheck.Reset();
3403 animation.FinishedSignal().Connect(&application, finishCheck);
3405 application.SendNotification();
3406 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3408 // We didn't expect the animation to finish yet
3409 application.SendNotification();
3410 finishCheck.CheckSignalNotReceived();
3411 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == targetValue );
3413 application.SendNotification();
3414 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3416 // We did expect the animation to finish
3417 application.SendNotification();
3418 finishCheck.CheckSignalReceived();
3419 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
3421 // Check that nothing has changed after a couple of buffer swaps
3422 application.Render(0);
3423 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
3424 application.Render(0);
3425 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
3429 int UtcDaliAnimationAnimateToBooleanAlphaFunction(void)
3431 TestApplication application;
3433 Actor actor = Actor::New();
3435 // Register a boolean property
3436 const bool startValue(false);
3437 Property::Index index = actor.RegisterProperty( "test-property", startValue );
3438 Stage::GetCurrent().Add(actor);
3439 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
3441 // Build the animation
3442 float durationSeconds(2.0f);
3443 Animation animation = Animation::New(durationSeconds);
3444 const bool targetValue( !startValue );
3445 animation.AnimateTo(Property(actor, "test-property"), targetValue, AlphaFunctions::EaseOut);
3447 // Start the animation
3450 bool signalReceived(false);
3451 AnimationFinishCheck finishCheck(signalReceived);
3452 animation.FinishedSignal().Connect(&application, finishCheck);
3454 application.SendNotification();
3455 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3457 // We didn't expect the animation to finish yet
3458 application.SendNotification();
3459 finishCheck.CheckSignalNotReceived();
3460 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
3462 application.SendNotification();
3463 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3465 // We did expect the animation to finish
3466 application.SendNotification();
3467 finishCheck.CheckSignalReceived();
3468 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == targetValue );
3470 // Check that nothing has changed after a couple of buffer swaps
3471 application.Render(0);
3472 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == targetValue );
3473 application.Render(0);
3474 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == targetValue );
3476 // Repeat with target value "false"
3477 animation = Animation::New(durationSeconds);
3478 const bool finalValue( !targetValue );
3479 animation.AnimateTo(Property(actor, index), finalValue, AlphaFunctions::EaseOut);
3481 // Start the animation
3484 finishCheck.Reset();
3485 animation.FinishedSignal().Connect(&application, finishCheck);
3487 application.SendNotification();
3488 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3490 // We didn't expect the animation to finish yet
3491 application.SendNotification();
3492 finishCheck.CheckSignalNotReceived();
3493 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == targetValue );
3495 application.SendNotification();
3496 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3498 // We did expect the animation to finish
3499 application.SendNotification();
3500 finishCheck.CheckSignalReceived();
3501 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
3503 // Check that nothing has changed after a couple of buffer swaps
3504 application.Render(0);
3505 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
3506 application.Render(0);
3507 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
3511 int UtcDaliAnimationAnimateToBooleanTimePeriod(void)
3513 TestApplication application;
3515 Actor actor = Actor::New();
3517 // Register a boolean property
3518 bool startValue(false);
3519 Property::Index index = actor.RegisterProperty( "test-property", startValue );
3520 Stage::GetCurrent().Add(actor);
3521 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
3523 // Build the animation
3524 float durationSeconds(2.0f);
3525 Animation animation = Animation::New(durationSeconds);
3526 bool finalValue( !startValue );
3527 float animatorDurationSeconds(durationSeconds * 0.5f);
3528 animation.AnimateTo( Property(actor, index),
3530 TimePeriod( animatorDurationSeconds ) );
3532 // Start the animation
3535 bool signalReceived(false);
3536 AnimationFinishCheck finishCheck(signalReceived);
3537 animation.FinishedSignal().Connect(&application, finishCheck);
3539 application.SendNotification();
3540 application.Render(static_cast<unsigned int>(animatorDurationSeconds*950.0f)/* 95% animator progress */);
3542 // We didn't expect the animation to finish yet
3543 application.SendNotification();
3544 finishCheck.CheckSignalNotReceived();
3545 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
3547 application.SendNotification();
3548 application.Render(static_cast<unsigned int>(animatorDurationSeconds*50.0f) + 1u/*just beyond the animator duration*/);
3550 // We didn't expect the animation to finish yet...
3551 application.SendNotification();
3552 finishCheck.CheckSignalNotReceived();
3554 // ...however we should have reached the final value
3555 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
3557 application.SendNotification();
3558 application.Render(static_cast<unsigned int>(animatorDurationSeconds*1000.0f)/*just beyond the animation duration*/);
3560 // We did expect the animation to finish
3561 application.SendNotification();
3562 finishCheck.CheckSignalReceived();
3563 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
3565 // Check that nothing has changed after a couple of buffer swaps
3566 application.Render(0);
3567 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
3568 application.Render(0);
3569 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
3573 int UtcDaliAnimationAnimateToBooleanAlphaFunctionTimePeriod(void)
3575 TestApplication application;
3577 Actor actor = Actor::New();
3579 // Register a boolean property
3580 bool startValue(false);
3581 Property::Index index = actor.RegisterProperty( "test-property", startValue );
3582 Stage::GetCurrent().Add(actor);
3583 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
3585 // Build the animation
3586 float durationSeconds(2.0f);
3587 Animation animation = Animation::New(durationSeconds);
3588 bool finalValue( !startValue );
3589 float animatorDurationSeconds(durationSeconds * 0.5f);
3590 animation.AnimateTo( Property(actor, index),
3592 AlphaFunctions::Linear,
3593 TimePeriod( animatorDurationSeconds ) );
3595 // Start the animation
3598 bool signalReceived(false);
3599 AnimationFinishCheck finishCheck(signalReceived);
3600 animation.FinishedSignal().Connect(&application, finishCheck);
3602 application.SendNotification();
3603 application.Render(static_cast<unsigned int>(animatorDurationSeconds*950.0f)/* 95% animator progress */);
3605 // We didn't expect the animation to finish yet
3606 application.SendNotification();
3607 finishCheck.CheckSignalNotReceived();
3608 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
3610 application.SendNotification();
3611 application.Render(static_cast<unsigned int>(animatorDurationSeconds*50.0f) + 1u/*just beyond the animator duration*/);
3613 // We didn't expect the animation to finish yet...
3614 application.SendNotification();
3615 finishCheck.CheckSignalNotReceived();
3617 // ...however we should have reached the final value
3618 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
3620 application.SendNotification();
3621 application.Render(static_cast<unsigned int>(animatorDurationSeconds*1000.0f)/*just beyond the animation duration*/);
3623 // We did expect the animation to finish
3624 application.SendNotification();
3625 finishCheck.CheckSignalReceived();
3626 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
3628 // Check that nothing has changed after a couple of buffer swaps
3629 application.Render(0);
3630 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
3631 application.Render(0);
3632 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
3636 int UtcDaliAnimationAnimateToFloat(void)
3638 TestApplication application;
3640 Actor actor = Actor::New();
3642 // Register a float property
3643 float startValue(10.0f);
3644 Property::Index index = actor.RegisterProperty( "test-property", startValue );
3645 Stage::GetCurrent().Add(actor);
3646 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
3648 // Build the animation
3649 float durationSeconds(2.0f);
3650 Animation animation = Animation::New(durationSeconds);
3651 float targetValue(50.0f);
3652 float relativeValue(targetValue - startValue);
3653 animation.AnimateTo(Property(actor, "test-property"), targetValue);
3655 float ninetyFivePercentProgress(startValue + relativeValue*0.95f);
3657 // Start the animation
3660 bool signalReceived(false);
3661 AnimationFinishCheck finishCheck(signalReceived);
3662 animation.FinishedSignal().Connect(&application, finishCheck);
3664 application.SendNotification();
3665 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3667 // We didn't expect the animation to finish yet
3668 application.SendNotification();
3669 finishCheck.CheckSignalNotReceived();
3670 DALI_TEST_EQUALS( actor.GetProperty<float>(index), ninetyFivePercentProgress, TEST_LOCATION );
3672 application.SendNotification();
3673 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3675 // We did expect the animation to finish
3676 application.SendNotification();
3677 finishCheck.CheckSignalReceived();
3678 DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
3682 int UtcDaliAnimationAnimateToFloatAlphaFunction(void)
3684 TestApplication application;
3686 Actor actor = Actor::New();
3688 // Register a float property
3689 float startValue(10.0f);
3690 Property::Index index = actor.RegisterProperty( "test-property", startValue );
3691 Stage::GetCurrent().Add(actor);
3692 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
3694 // Build the animation
3695 float durationSeconds(1.0f);
3696 Animation animation = Animation::New(durationSeconds);
3697 float targetValue(90.0f);
3698 float relativeValue(targetValue - startValue);
3699 animation.AnimateTo(Property(actor, index), targetValue, AlphaFunctions::EaseOut);
3701 float ninetyFivePercentProgress(startValue + relativeValue*0.95f);
3703 // Start the animation
3706 bool signalReceived(false);
3707 AnimationFinishCheck finishCheck(signalReceived);
3708 animation.FinishedSignal().Connect(&application, finishCheck);
3710 application.SendNotification();
3711 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3713 // We didn't expect the animation to finish yet
3714 application.SendNotification();
3715 finishCheck.CheckSignalNotReceived();
3717 // The position should have moved more, than with a linear alpha function
3718 float current(actor.GetProperty<float>(index));
3719 DALI_TEST_CHECK( current > ninetyFivePercentProgress );
3721 application.SendNotification();
3722 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3724 // We did expect the animation to finish
3725 application.SendNotification();
3726 finishCheck.CheckSignalReceived();
3727 DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
3731 int UtcDaliAnimationAnimateToFloatTimePeriod(void)
3733 TestApplication application;
3735 Actor actor = Actor::New();
3737 // Register a float property
3738 float startValue(10.0f);
3739 Property::Index index = actor.RegisterProperty( "test-property", startValue );
3740 Stage::GetCurrent().Add(actor);
3741 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
3743 // Build the animation
3744 float durationSeconds(1.0f);
3745 Animation animation = Animation::New(durationSeconds);
3746 float targetValue(30.0f);
3747 float relativeValue(targetValue - startValue);
3749 animation.AnimateTo(Property(actor, index),
3751 TimePeriod(delay, durationSeconds - delay));
3753 // Start the animation
3756 bool signalReceived(false);
3757 AnimationFinishCheck finishCheck(signalReceived);
3758 animation.FinishedSignal().Connect(&application, finishCheck);
3760 application.SendNotification();
3761 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
3763 // We didn't expect the animation to finish yet
3764 application.SendNotification();
3765 finishCheck.CheckSignalNotReceived();
3766 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
3768 application.SendNotification();
3769 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
3771 // We didn't expect the animation to finish yet
3772 application.SendNotification();
3773 finishCheck.CheckSignalNotReceived();
3774 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
3776 application.SendNotification();
3777 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
3779 // We did expect the animation to finish
3780 application.SendNotification();
3781 finishCheck.CheckSignalReceived();
3782 DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
3786 int UtcDaliAnimationAnimateToFloatAlphaFunctionTimePeriod(void)
3788 TestApplication application;
3790 Actor actor = Actor::New();
3792 // Register a float property
3793 float startValue(10.0f);
3794 Property::Index index = actor.RegisterProperty( "test-property", startValue );
3795 Stage::GetCurrent().Add(actor);
3796 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
3798 // Build the animation
3799 float durationSeconds(1.0f);
3800 Animation animation = Animation::New(durationSeconds);
3801 float targetValue(30.0f);
3802 float relativeValue(targetValue - startValue);
3804 animation.AnimateTo(Property(actor, index),
3806 AlphaFunctions::Linear,
3807 TimePeriod(delay, durationSeconds - delay));
3809 // Start the animation
3812 bool signalReceived(false);
3813 AnimationFinishCheck finishCheck(signalReceived);
3814 animation.FinishedSignal().Connect(&application, finishCheck);
3816 application.SendNotification();
3817 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
3819 // We didn't expect the animation to finish yet
3820 application.SendNotification();
3821 finishCheck.CheckSignalNotReceived();
3822 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
3824 application.SendNotification();
3825 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
3827 // We didn't expect the animation to finish yet
3828 application.SendNotification();
3829 finishCheck.CheckSignalNotReceived();
3830 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
3832 application.SendNotification();
3833 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
3835 // We did expect the animation to finish
3836 application.SendNotification();
3837 finishCheck.CheckSignalReceived();
3838 DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
3842 int UtcDaliAnimationAnimateToInteger(void)
3844 TestApplication application;
3846 Actor actor = Actor::New();
3848 // Register an integer property
3850 Property::Index index = actor.RegisterProperty( "test-property", startValue );
3851 Stage::GetCurrent().Add(actor);
3852 DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
3854 // Build the animation
3855 float durationSeconds(2.0f);
3856 Animation animation = Animation::New(durationSeconds);
3857 int targetValue(50);
3858 int relativeValue(targetValue - startValue);
3859 animation.AnimateTo(Property(actor, "test-property"), targetValue);
3861 int ninetyFivePercentProgress(static_cast<int>(startValue + relativeValue*0.95f + 0.5f));
3863 // Start the animation
3866 bool signalReceived(false);
3867 AnimationFinishCheck finishCheck(signalReceived);
3868 animation.FinishedSignal().Connect(&application, finishCheck);
3870 application.SendNotification();
3871 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3873 // We didn't expect the animation to finish yet
3874 application.SendNotification();
3875 finishCheck.CheckSignalNotReceived();
3876 DALI_TEST_EQUALS( actor.GetProperty<int>(index), ninetyFivePercentProgress, TEST_LOCATION );
3878 application.SendNotification();
3879 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3881 // We did expect the animation to finish
3882 application.SendNotification();
3883 finishCheck.CheckSignalReceived();
3884 DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
3888 int UtcDaliAnimationAnimateToIntegerAlphaFunction(void)
3890 TestApplication application;
3892 Actor actor = Actor::New();
3894 // Register an integer property
3896 Property::Index index = actor.RegisterProperty( "test-property", startValue );
3897 Stage::GetCurrent().Add(actor);
3898 DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
3900 // Build the animation
3901 float durationSeconds(1.0f);
3902 Animation animation = Animation::New(durationSeconds);
3903 int targetValue(90);
3904 int relativeValue(targetValue - startValue);
3905 animation.AnimateTo(Property(actor, index), targetValue, AlphaFunctions::EaseOut);
3907 int ninetyFivePercentProgress(static_cast<int>(startValue + relativeValue*0.95f + 0.5f));
3909 // Start the animation
3912 bool signalReceived(false);
3913 AnimationFinishCheck finishCheck(signalReceived);
3914 animation.FinishedSignal().Connect(&application, finishCheck);
3916 application.SendNotification();
3917 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3919 // We didn't expect the animation to finish yet
3920 application.SendNotification();
3921 finishCheck.CheckSignalNotReceived();
3923 // The position should have moved more, than with a linear alpha function
3924 int current(actor.GetProperty<int>(index));
3925 DALI_TEST_CHECK( current > ninetyFivePercentProgress );
3927 application.SendNotification();
3928 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3930 // We did expect the animation to finish
3931 application.SendNotification();
3932 finishCheck.CheckSignalReceived();
3933 DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
3937 int UtcDaliAnimationAnimateToIntegerTimePeriod(void)
3939 TestApplication application;
3941 Actor actor = Actor::New();
3943 // Register an integer property
3945 Property::Index index = actor.RegisterProperty( "test-property", startValue );
3946 Stage::GetCurrent().Add(actor);
3947 DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
3949 // Build the animation
3950 float durationSeconds(1.0f);
3951 Animation animation = Animation::New(durationSeconds);
3952 int targetValue(30);
3953 int relativeValue(targetValue - startValue);
3955 animation.AnimateTo(Property(actor, index),
3957 TimePeriod(delay, durationSeconds - delay));
3959 // Start the animation
3962 bool signalReceived(false);
3963 AnimationFinishCheck finishCheck(signalReceived);
3964 animation.FinishedSignal().Connect(&application, finishCheck);
3966 application.SendNotification();
3967 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
3969 // We didn't expect the animation to finish yet
3970 application.SendNotification();
3971 finishCheck.CheckSignalNotReceived();
3972 DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
3974 application.SendNotification();
3975 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
3977 // We didn't expect the animation to finish yet
3978 application.SendNotification();
3979 finishCheck.CheckSignalNotReceived();
3980 DALI_TEST_EQUALS( actor.GetProperty<int>(index), static_cast<int>(startValue+(relativeValue*0.5f)+0.5f), TEST_LOCATION );
3982 application.SendNotification();
3983 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
3985 // We did expect the animation to finish
3986 application.SendNotification();
3987 finishCheck.CheckSignalReceived();
3988 DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
3992 int UtcDaliAnimationAnimateToIntegerAlphaFunctionTimePeriod(void)
3994 TestApplication application;
3996 Actor actor = Actor::New();
3998 // Register an integer property
4000 Property::Index index = actor.RegisterProperty( "test-property", startValue );
4001 Stage::GetCurrent().Add(actor);
4002 DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
4004 // Build the animation
4005 float durationSeconds(1.0f);
4006 Animation animation = Animation::New(durationSeconds);
4007 int targetValue(30);
4008 int relativeValue(targetValue - startValue);
4010 animation.AnimateTo(Property(actor, index),
4012 AlphaFunctions::Linear,
4013 TimePeriod(delay, durationSeconds - delay));
4015 // Start the animation
4018 bool signalReceived(false);
4019 AnimationFinishCheck finishCheck(signalReceived);
4020 animation.FinishedSignal().Connect(&application, finishCheck);
4022 application.SendNotification();
4023 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
4025 // We didn't expect the animation to finish yet
4026 application.SendNotification();
4027 finishCheck.CheckSignalNotReceived();
4028 DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
4030 application.SendNotification();
4031 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
4033 // We didn't expect the animation to finish yet
4034 application.SendNotification();
4035 finishCheck.CheckSignalNotReceived();
4036 DALI_TEST_EQUALS( actor.GetProperty<int>(index), static_cast<int>(startValue+(relativeValue*0.5f)+0.5f), TEST_LOCATION );
4038 application.SendNotification();
4039 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
4041 // We did expect the animation to finish
4042 application.SendNotification();
4043 finishCheck.CheckSignalReceived();
4044 DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
4048 int UtcDaliAnimationAnimateToVector2(void)
4050 TestApplication application;
4052 Actor actor = Actor::New();
4054 // Register a Vector2 property
4055 Vector2 startValue(-50.0f, -50.0f);
4056 Property::Index index = actor.RegisterProperty( "test-property", startValue );
4057 Stage::GetCurrent().Add(actor);
4058 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
4060 // Build the animation
4061 float durationSeconds(2.0f);
4062 Animation animation = Animation::New(durationSeconds);
4063 Vector2 targetValue(50.0f, 50.0f);
4064 Vector2 relativeValue(targetValue - startValue);
4065 animation.AnimateTo(Property(actor, index), targetValue);
4067 Vector2 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
4069 // Start the animation
4072 bool signalReceived(false);
4073 AnimationFinishCheck finishCheck(signalReceived);
4074 animation.FinishedSignal().Connect(&application, finishCheck);
4076 application.SendNotification();
4077 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
4079 // We didn't expect the animation to finish yet
4080 application.SendNotification();
4081 finishCheck.CheckSignalNotReceived();
4082 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), ninetyFivePercentProgress, TEST_LOCATION );
4084 application.SendNotification();
4085 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
4087 // We did expect the animation to finish
4088 application.SendNotification();
4089 finishCheck.CheckSignalReceived();
4090 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
4094 int UtcDaliAnimationAnimateToVector2AlphaFunction(void)
4096 TestApplication application;
4098 Actor actor = Actor::New();
4100 // Register a Vector2 property
4101 Vector2 startValue(1000.0f, 1000.0f);
4102 Property::Index index = actor.RegisterProperty( "test-property", startValue );
4103 Stage::GetCurrent().Add(actor);
4104 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
4106 // Build the animation
4107 float durationSeconds(1.0f);
4108 Animation animation = Animation::New(durationSeconds);
4109 Vector2 targetValue(9000.0f, 9000.0f);
4110 Vector2 relativeValue(targetValue - startValue);
4111 animation.AnimateTo(Property(actor, "test-property"), targetValue, AlphaFunctions::EaseOut);
4113 Vector2 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
4115 // Start the animation
4118 bool signalReceived(false);
4119 AnimationFinishCheck finishCheck(signalReceived);
4120 animation.FinishedSignal().Connect(&application, finishCheck);
4122 application.SendNotification();
4123 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
4125 // We didn't expect the animation to finish yet
4126 application.SendNotification();
4127 finishCheck.CheckSignalNotReceived();
4129 // The position should have moved more, than with a linear alpha function
4130 Vector2 current(actor.GetProperty<Vector2>(index));
4131 DALI_TEST_CHECK( current.x > ninetyFivePercentProgress.x );
4132 DALI_TEST_CHECK( current.y > ninetyFivePercentProgress.y );
4134 application.SendNotification();
4135 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
4137 // We did expect the animation to finish
4138 application.SendNotification();
4139 finishCheck.CheckSignalReceived();
4140 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
4144 int UtcDaliAnimationAnimateToVector2TimePeriod(void)
4146 TestApplication application;
4148 Actor actor = Actor::New();
4150 // Register a Vector2 property
4151 Vector2 startValue(10.0f, 10.0f);
4152 Property::Index index = actor.RegisterProperty( "test-property", startValue );
4153 Stage::GetCurrent().Add(actor);
4154 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
4156 // Build the animation
4157 float durationSeconds(1.0f);
4158 Animation animation = Animation::New(durationSeconds);
4159 Vector2 targetValue(-10.0f, 20.0f);
4160 Vector2 relativeValue(targetValue - startValue);
4162 animation.AnimateTo(Property(actor, index),
4164 TimePeriod(delay, durationSeconds - delay));
4166 // Start the animation
4169 bool signalReceived(false);
4170 AnimationFinishCheck finishCheck(signalReceived);
4171 animation.FinishedSignal().Connect(&application, finishCheck);
4173 application.SendNotification();
4174 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
4176 // We didn't expect the animation to finish yet
4177 application.SendNotification();
4178 finishCheck.CheckSignalNotReceived();
4179 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
4181 application.SendNotification();
4182 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
4184 // We didn't expect the animation to finish yet
4185 application.SendNotification();
4186 finishCheck.CheckSignalNotReceived();
4187 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
4189 application.SendNotification();
4190 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
4192 // We did expect the animation to finish
4193 application.SendNotification();
4194 finishCheck.CheckSignalReceived();
4195 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
4199 int UtcDaliAnimationAnimateToVector2AlphaFunctionTimePeriod(void)
4201 TestApplication application;
4203 Actor actor = Actor::New();
4205 // Register a Vector2 property
4206 Vector2 startValue(10.0f, 10.0f);
4207 Property::Index index = actor.RegisterProperty( "test-property", startValue );
4208 Stage::GetCurrent().Add(actor);
4209 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
4211 // Build the animation
4212 float durationSeconds(1.0f);
4213 Animation animation = Animation::New(durationSeconds);
4214 Vector2 targetValue(30.0f, 30.0f);
4215 Vector2 relativeValue(targetValue - startValue);
4217 animation.AnimateTo(Property(actor, index),
4219 AlphaFunctions::Linear,
4220 TimePeriod(delay, durationSeconds - delay));
4222 // Start the animation
4225 bool signalReceived(false);
4226 AnimationFinishCheck finishCheck(signalReceived);
4227 animation.FinishedSignal().Connect(&application, finishCheck);
4229 application.SendNotification();
4230 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
4232 // We didn't expect the animation to finish yet
4233 application.SendNotification();
4234 finishCheck.CheckSignalNotReceived();
4235 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
4237 application.SendNotification();
4238 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
4240 // We didn't expect the animation to finish yet
4241 application.SendNotification();
4242 finishCheck.CheckSignalNotReceived();
4243 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
4245 application.SendNotification();
4246 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
4248 // We did expect the animation to finish
4249 application.SendNotification();
4250 finishCheck.CheckSignalReceived();
4251 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
4255 int UtcDaliAnimationAnimateToVector3(void)
4257 TestApplication application;
4259 Actor actor = Actor::New();
4261 // Register a Vector3 property
4262 Vector3 startValue(-50.0f, -50.0f, -50.0f);
4263 Property::Index index = actor.RegisterProperty( "test-property", startValue );
4264 Stage::GetCurrent().Add(actor);
4265 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
4267 // Build the animation
4268 float durationSeconds(2.0f);
4269 Animation animation = Animation::New(durationSeconds);
4270 Vector3 targetValue(50.0f, 50.0f, 50.0f);
4271 Vector3 relativeValue(targetValue - startValue);
4272 animation.AnimateTo(Property(actor, index), targetValue);
4274 Vector3 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
4276 // Start the animation
4279 bool signalReceived(false);
4280 AnimationFinishCheck finishCheck(signalReceived);
4281 animation.FinishedSignal().Connect(&application, finishCheck);
4283 application.SendNotification();
4284 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
4286 // We didn't expect the animation to finish yet
4287 application.SendNotification();
4288 finishCheck.CheckSignalNotReceived();
4289 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), ninetyFivePercentProgress, TEST_LOCATION );
4291 application.SendNotification();
4292 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
4294 // We did expect the animation to finish
4295 application.SendNotification();
4296 finishCheck.CheckSignalReceived();
4297 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
4301 int UtcDaliAnimationAnimateToVector3AlphaFunction(void)
4303 TestApplication application;
4305 Actor actor = Actor::New();
4307 // Register a Vector3 property
4308 Vector3 startValue(1000.0f, 1000.0f, 1000.0f);
4309 Property::Index index = actor.RegisterProperty( "test-property", startValue );
4310 Stage::GetCurrent().Add(actor);
4311 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
4313 // Build the animation
4314 float durationSeconds(1.0f);
4315 Animation animation = Animation::New(durationSeconds);
4316 Vector3 targetValue(9000.0f, 9000.0f, 9000.0f);
4317 Vector3 relativeValue(targetValue - startValue);
4318 animation.AnimateTo(Property(actor, index), targetValue, AlphaFunctions::EaseOut);
4320 Vector3 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
4322 // Start the animation
4325 bool signalReceived(false);
4326 AnimationFinishCheck finishCheck(signalReceived);
4327 animation.FinishedSignal().Connect(&application, finishCheck);
4329 application.SendNotification();
4330 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
4332 // We didn't expect the animation to finish yet
4333 application.SendNotification();
4334 finishCheck.CheckSignalNotReceived();
4336 // The position should have moved more, than with a linear alpha function
4337 Vector3 current(actor.GetProperty<Vector3>(index));
4338 DALI_TEST_CHECK( current.x > ninetyFivePercentProgress.x );
4339 DALI_TEST_CHECK( current.y > ninetyFivePercentProgress.y );
4340 DALI_TEST_CHECK( current.z > ninetyFivePercentProgress.z );
4342 application.SendNotification();
4343 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
4345 // We did expect the animation to finish
4346 application.SendNotification();
4347 finishCheck.CheckSignalReceived();
4348 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
4352 int UtcDaliAnimationAnimateToVector3TimePeriod(void)
4354 TestApplication application;
4356 Actor actor = Actor::New();
4358 // Register a Vector3 property
4359 Vector3 startValue(10.0f, 10.0f, 10.0f);
4360 Property::Index index = actor.RegisterProperty( "test-property", startValue );
4361 Stage::GetCurrent().Add(actor);
4362 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
4364 // Build the animation
4365 float durationSeconds(1.0f);
4366 Animation animation = Animation::New(durationSeconds);
4367 Vector3 targetValue(-10.0f, 20.0f, 100.0f);
4368 Vector3 relativeValue(targetValue - startValue);
4370 animation.AnimateTo(Property(actor, index),
4372 TimePeriod(delay, durationSeconds - delay));
4374 // Start the animation
4377 bool signalReceived(false);
4378 AnimationFinishCheck finishCheck(signalReceived);
4379 animation.FinishedSignal().Connect(&application, finishCheck);
4381 application.SendNotification();
4382 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
4384 // We didn't expect the animation to finish yet
4385 application.SendNotification();
4386 finishCheck.CheckSignalNotReceived();
4387 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
4389 application.SendNotification();
4390 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
4392 // We didn't expect the animation to finish yet
4393 application.SendNotification();
4394 finishCheck.CheckSignalNotReceived();
4395 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
4397 application.SendNotification();
4398 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
4400 // We did expect the animation to finish
4401 application.SendNotification();
4402 finishCheck.CheckSignalReceived();
4403 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
4407 int UtcDaliAnimationAnimateToVector3AlphaFunctionTimePeriod(void)
4409 TestApplication application;
4411 Actor actor = Actor::New();
4413 // Register a Vector3 property
4414 Vector3 startValue(10.0f, 10.0f, 10.0f);
4415 Property::Index index = actor.RegisterProperty( "test-property", startValue );
4416 Stage::GetCurrent().Add(actor);
4417 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
4419 // Build the animation
4420 float durationSeconds(1.0f);
4421 Animation animation = Animation::New(durationSeconds);
4422 Vector3 targetValue(30.0f, 30.0f, 30.0f);
4423 Vector3 relativeValue(targetValue - startValue);
4425 animation.AnimateTo(Property(actor, "test-property"),
4427 AlphaFunctions::Linear,
4428 TimePeriod(delay, durationSeconds - delay));
4430 // Start the animation
4433 bool signalReceived(false);
4434 AnimationFinishCheck finishCheck(signalReceived);
4435 animation.FinishedSignal().Connect(&application, finishCheck);
4437 application.SendNotification();
4438 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
4440 // We didn't expect the animation to finish yet
4441 application.SendNotification();
4442 finishCheck.CheckSignalNotReceived();
4443 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
4445 application.SendNotification();
4446 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
4448 // We didn't expect the animation to finish yet
4449 application.SendNotification();
4450 finishCheck.CheckSignalNotReceived();
4451 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
4453 application.SendNotification();
4454 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
4456 // We did expect the animation to finish
4457 application.SendNotification();
4458 finishCheck.CheckSignalReceived();
4459 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
4463 int UtcDaliAnimationAnimateToVector3Component(void)
4465 TestApplication application;
4467 Actor actor = Actor::New();
4469 // Register a Vector3 property
4470 Vector3 startValue(10.0f, 10.0f, 10.0f);
4471 Property::Index index = actor.RegisterProperty( "test-property", startValue );
4472 Stage::GetCurrent().Add(actor);
4473 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
4475 // Build the animation
4476 float durationSeconds(1.0f);
4477 Animation animation = Animation::New(durationSeconds);
4478 Vector3 targetValue(30.0f, 30.0f, 10.0f);
4479 Vector3 relativeValue(targetValue - startValue);
4481 animation.AnimateTo(Property(actor, "test-property", 0),
4483 AlphaFunctions::Linear,
4484 TimePeriod(delay, durationSeconds - delay));
4485 animation.AnimateTo(Property(actor, index, 1),
4487 AlphaFunctions::Linear,
4488 TimePeriod(delay, durationSeconds - delay));
4490 // Start the animation
4493 bool signalReceived(false);
4494 AnimationFinishCheck finishCheck(signalReceived);
4495 animation.FinishedSignal().Connect(&application, finishCheck);
4497 application.SendNotification();
4498 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
4500 // We didn't expect the animation to finish yet
4501 application.SendNotification();
4502 finishCheck.CheckSignalNotReceived();
4503 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
4505 application.SendNotification();
4506 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
4508 // We didn't expect the animation to finish yet
4509 application.SendNotification();
4510 finishCheck.CheckSignalNotReceived();
4511 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
4513 application.SendNotification();
4514 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
4516 // We did expect the animation to finish
4517 application.SendNotification();
4518 finishCheck.CheckSignalReceived();
4519 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
4523 int UtcDaliAnimationAnimateToVector4(void)
4525 TestApplication application;
4527 Actor actor = Actor::New();
4529 // Register a Vector4 property
4530 Vector4 startValue(-50.0f, -40.0f, -30.0f, -20.0f);
4531 Property::Index index = actor.RegisterProperty( "test-property", startValue );
4532 Stage::GetCurrent().Add(actor);
4533 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
4535 // Build the animation
4536 float durationSeconds(2.0f);
4537 Animation animation = Animation::New(durationSeconds);
4538 Vector4 targetValue(50.0f, 50.0f, 50.0f, 50.0f);
4539 Vector4 relativeValue(targetValue - startValue);
4540 animation.AnimateTo(Property(actor, index), targetValue);
4542 Vector4 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
4544 // Start the animation
4547 bool signalReceived(false);
4548 AnimationFinishCheck finishCheck(signalReceived);
4549 animation.FinishedSignal().Connect(&application, finishCheck);
4551 application.SendNotification();
4552 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
4554 // We didn't expect the animation to finish yet
4555 application.SendNotification();
4556 finishCheck.CheckSignalNotReceived();
4557 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), ninetyFivePercentProgress, TEST_LOCATION );
4559 application.SendNotification();
4560 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
4562 // We did expect the animation to finish
4563 application.SendNotification();
4564 finishCheck.CheckSignalReceived();
4565 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
4569 int UtcDaliAnimationAnimateToVector4AlphaFunction(void)
4571 TestApplication application;
4573 Actor actor = Actor::New();
4575 // Register a Vector4 property
4576 Vector4 startValue(1000.0f, 1000.0f, 1000.0f, 1000.0f);
4577 Property::Index index = actor.RegisterProperty( "test-property", startValue );
4578 Stage::GetCurrent().Add(actor);
4579 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
4581 // Build the animation
4582 float durationSeconds(1.0f);
4583 Animation animation = Animation::New(durationSeconds);
4584 Vector4 targetValue(9000.0f, 9000.0f, 9000.0f, 9000.0f);
4585 Vector4 relativeValue(targetValue - startValue);
4586 animation.AnimateTo(Property(actor, index), targetValue, AlphaFunctions::EaseOut);
4588 Vector4 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
4590 // Start the animation
4593 bool signalReceived(false);
4594 AnimationFinishCheck finishCheck(signalReceived);
4595 animation.FinishedSignal().Connect(&application, finishCheck);
4597 application.SendNotification();
4598 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
4600 // We didn't expect the animation to finish yet
4601 application.SendNotification();
4602 finishCheck.CheckSignalNotReceived();
4604 // The position should have moved more, than with a linear alpha function
4605 Vector4 current(actor.GetProperty<Vector4>(index));
4606 DALI_TEST_CHECK( current.x > ninetyFivePercentProgress.x );
4607 DALI_TEST_CHECK( current.y > ninetyFivePercentProgress.y );
4608 DALI_TEST_CHECK( current.z > ninetyFivePercentProgress.z );
4609 DALI_TEST_CHECK( current.w > ninetyFivePercentProgress.w );
4611 application.SendNotification();
4612 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
4614 // We did expect the animation to finish
4615 application.SendNotification();
4616 finishCheck.CheckSignalReceived();
4617 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
4621 int UtcDaliAnimationAnimateToVector4TimePeriod(void)
4623 TestApplication application;
4625 Actor actor = Actor::New();
4627 // Register a Vector4 property
4628 Vector4 startValue(10.0f, 10.0f, 10.0f, 10.0f);
4629 Property::Index index = actor.RegisterProperty( "test-property", startValue );
4630 Stage::GetCurrent().Add(actor);
4631 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, VECTOR4_EPSILON, TEST_LOCATION );
4633 // Build the animation
4634 float durationSeconds(1.0f);
4635 Animation animation = Animation::New(durationSeconds);
4636 Vector4 targetValue(-10.0f, 20.0f, 100.0f, 100.0f);
4637 Vector4 relativeValue(targetValue - startValue);
4639 animation.AnimateTo(Property(actor, index),
4641 TimePeriod(delay, durationSeconds - delay));
4643 // Start the animation
4646 bool signalReceived(false);
4647 AnimationFinishCheck finishCheck(signalReceived);
4648 animation.FinishedSignal().Connect(&application, finishCheck);
4650 application.SendNotification();
4651 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
4653 // We didn't expect the animation to finish yet
4654 application.SendNotification();
4655 finishCheck.CheckSignalNotReceived();
4656 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, VECTOR4_EPSILON, TEST_LOCATION );
4658 application.SendNotification();
4659 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
4661 // We didn't expect the animation to finish yet
4662 application.SendNotification();
4663 finishCheck.CheckSignalNotReceived();
4664 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue+(relativeValue*0.5f), VECTOR4_EPSILON, TEST_LOCATION );
4666 application.SendNotification();
4667 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
4669 // We did expect the animation to finish
4670 application.SendNotification();
4671 finishCheck.CheckSignalReceived();
4672 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, VECTOR4_EPSILON, TEST_LOCATION );
4676 int UtcDaliAnimationAnimateToVector4AlphaFunctionTimePeriod(void)
4678 TestApplication application;
4680 Actor actor = Actor::New();
4682 // Register a Vector4 property
4683 Vector4 startValue(10.0f, 10.0f, 10.0f, 10.0f);
4684 Property::Index index = actor.RegisterProperty( "test-property", startValue );
4685 Stage::GetCurrent().Add(actor);
4686 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
4688 // Build the animation
4689 float durationSeconds(1.0f);
4690 Animation animation = Animation::New(durationSeconds);
4691 Vector4 targetValue(30.0f, 30.0f, 30.0f, 30.0f);
4692 Vector4 relativeValue(targetValue - startValue);
4694 animation.AnimateTo(Property(actor, index),
4696 AlphaFunctions::Linear,
4697 TimePeriod(delay, durationSeconds - delay));
4699 // Start the animation
4702 bool signalReceived(false);
4703 AnimationFinishCheck finishCheck(signalReceived);
4704 animation.FinishedSignal().Connect(&application, finishCheck);
4706 application.SendNotification();
4707 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
4709 // We didn't expect the animation to finish yet
4710 application.SendNotification();
4711 finishCheck.CheckSignalNotReceived();
4712 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
4714 application.SendNotification();
4715 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
4717 // We didn't expect the animation to finish yet
4718 application.SendNotification();
4719 finishCheck.CheckSignalNotReceived();
4720 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
4722 application.SendNotification();
4723 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
4725 // We did expect the animation to finish
4726 application.SendNotification();
4727 finishCheck.CheckSignalReceived();
4728 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
4732 int UtcDaliAnimationAnimateToActorParentOrigin(void)
4734 TestApplication application;
4736 Actor actor = Actor::New();
4737 Stage::GetCurrent().Add(actor);
4738 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::TOP_LEFT, TEST_LOCATION );
4740 // Build the animation
4741 float durationSeconds(1.0f);
4742 Animation animation = Animation::New(durationSeconds);
4743 Vector3 targetParentOrigin(ParentOrigin::BOTTOM_RIGHT);
4747 animation.AnimateTo( Property(actor, Actor::PARENT_ORIGIN), targetParentOrigin );
4749 catch (Dali::DaliException& e)
4751 tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
4752 DALI_TEST_ASSERT(e, "IsPropertyAnimatable(index)", TEST_LOCATION);
4757 int UtcDaliAnimationAnimateToActorParentOriginX(void)
4759 TestApplication application;
4761 Actor actor = Actor::New();
4762 Stage::GetCurrent().Add(actor);
4763 float startValue(0.0f);
4764 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin().x, startValue, TEST_LOCATION );
4765 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::PARENT_ORIGIN_X), startValue, TEST_LOCATION );
4767 // Build the animation
4768 float durationSeconds(1.0f);
4769 Animation animation = Animation::New(durationSeconds);
4770 float targetX(1.0f);
4774 animation.AnimateTo( Property(actor, Actor::PARENT_ORIGIN_X), targetX );
4776 catch (Dali::DaliException& e)
4778 tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
4779 DALI_TEST_ASSERT(e, "IsPropertyAnimatable(index)", TEST_LOCATION);
4784 int UtcDaliAnimationAnimateToActorParentOriginY(void)
4786 TestApplication application;
4788 Actor actor = Actor::New();
4789 Stage::GetCurrent().Add(actor);
4790 float startValue(0.0f);
4791 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin().y, startValue, TEST_LOCATION );
4792 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::PARENT_ORIGIN_Y), startValue, TEST_LOCATION );
4794 // Build the animation
4795 float durationSeconds(1.0f);
4796 Animation animation = Animation::New(durationSeconds);
4797 float targetY(1.0f);
4801 animation.AnimateTo( Property(actor, Actor::PARENT_ORIGIN_Y), targetY );
4803 catch (Dali::DaliException& e)
4805 tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
4806 DALI_TEST_ASSERT(e, "IsPropertyAnimatable(index)", TEST_LOCATION);
4811 int UtcDaliAnimationAnimateToActorParentOriginZ(void)
4813 TestApplication application;
4815 Actor actor = Actor::New();
4816 Stage::GetCurrent().Add(actor);
4817 float startValue(0.5f);
4818 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin().z, startValue, TEST_LOCATION );
4819 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::PARENT_ORIGIN_Z), startValue, TEST_LOCATION );
4821 // Build the animation
4822 float durationSeconds(1.0f);
4823 Animation animation = Animation::New(durationSeconds);
4824 float targetZ(1.0f);
4828 animation.AnimateTo( Property(actor, Actor::PARENT_ORIGIN_Z), targetZ );
4830 catch (Dali::DaliException& e)
4832 tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
4833 DALI_TEST_ASSERT(e, "IsPropertyAnimatable(index)", TEST_LOCATION);
4838 int UtcDaliAnimationAnimateToActorAnchorPoint(void)
4840 TestApplication application;
4842 Actor actor = Actor::New();
4843 Stage::GetCurrent().Add(actor);
4844 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), AnchorPoint::CENTER, TEST_LOCATION );
4846 // Build the animation
4847 float durationSeconds(1.0f);
4848 Animation animation = Animation::New(durationSeconds);
4849 Vector3 targetAnchorPoint(AnchorPoint::TOP_LEFT);
4853 animation.AnimateTo( Property(actor, Actor::ANCHOR_POINT), targetAnchorPoint);
4855 catch (Dali::DaliException& e)
4857 tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
4858 DALI_TEST_ASSERT(e, "IsPropertyAnimatable(index)", TEST_LOCATION);
4863 int UtcDaliAnimationAnimateToActorAnchorPointX(void)
4865 TestApplication application;
4867 Actor actor = Actor::New();
4868 Stage::GetCurrent().Add(actor);
4869 float startValue(0.5f);
4870 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint().x, startValue, TEST_LOCATION );
4871 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::ANCHOR_POINT_X), startValue, TEST_LOCATION );
4873 // Build the animation
4874 float durationSeconds(1.0f);
4875 Animation animation = Animation::New(durationSeconds);
4876 float targetX(1.0f);
4880 animation.AnimateTo( Property(actor, Actor::ANCHOR_POINT_X), targetX );
4882 catch (Dali::DaliException& e)
4884 tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
4885 DALI_TEST_ASSERT(e, "IsPropertyAnimatable(index)", TEST_LOCATION);
4890 int UtcDaliAnimationAnimateToActorAnchorPointY(void)
4892 TestApplication application;
4894 Actor actor = Actor::New();
4895 Stage::GetCurrent().Add(actor);
4896 float startValue(0.5f);
4897 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint().y, startValue, TEST_LOCATION );
4898 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::ANCHOR_POINT_Y), startValue, TEST_LOCATION );
4900 // Build the animation
4901 float durationSeconds(1.0f);
4902 Animation animation = Animation::New(durationSeconds);
4903 float targetY(0.0f);
4907 animation.AnimateTo( Property(actor, Actor::ANCHOR_POINT_Y), targetY );
4909 catch (Dali::DaliException& e)
4911 tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
4912 DALI_TEST_ASSERT(e, "IsPropertyAnimatable(index)", TEST_LOCATION);
4917 int UtcDaliAnimationAnimateToActorAnchorPointZ(void)
4919 TestApplication application;
4921 Actor actor = Actor::New();
4922 Stage::GetCurrent().Add(actor);
4923 float startValue(0.5f);
4924 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint().z, startValue, TEST_LOCATION );
4925 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::ANCHOR_POINT_Z), startValue, TEST_LOCATION );
4927 // Build the animation
4928 float durationSeconds(1.0f);
4929 Animation animation = Animation::New(durationSeconds);
4930 float targetZ(100.0f);
4934 animation.AnimateTo( Property(actor, Actor::ANCHOR_POINT_Z), targetZ );
4936 catch (Dali::DaliException& e)
4938 tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
4939 DALI_TEST_ASSERT(e, "IsPropertyAnimatable(index)", TEST_LOCATION);
4944 int UtcDaliAnimationAnimateToActorSize(void)
4946 TestApplication application;
4948 Actor actor = Actor::New();
4949 Stage::GetCurrent().Add(actor);
4950 DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
4952 // Build the animation
4953 float durationSeconds(1.0f);
4954 Animation animation = Animation::New(durationSeconds);
4955 Vector3 targetSize(100.0f, 100.0f, 100.0f);
4956 animation.AnimateTo( Property(actor, Actor::SIZE), targetSize );
4958 Vector3 ninetyNinePercentProgress(targetSize * 0.99f);
4960 // Start the animation
4963 bool signalReceived(false);
4964 AnimationFinishCheck finishCheck(signalReceived);
4965 animation.FinishedSignal().Connect(&application, finishCheck);
4967 application.SendNotification();
4968 application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
4970 // We didn't expect the animation to finish yet
4971 application.SendNotification();
4972 finishCheck.CheckSignalNotReceived();
4973 DALI_TEST_EQUALS( actor.GetCurrentSize(), ninetyNinePercentProgress, TEST_LOCATION );
4975 application.SendNotification();
4976 application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
4978 // We did expect the animation to finish
4979 application.SendNotification();
4980 finishCheck.CheckSignalReceived();
4981 DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION );
4984 finishCheck.Reset();
4985 actor.SetSize(Vector3::ZERO);
4986 application.SendNotification();
4987 application.Render(0);
4988 DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
4990 // Repeat with a different (ease-in) alpha function
4991 animation = Animation::New(durationSeconds);
4992 animation.AnimateTo( Property(actor, Actor::SIZE), targetSize, AlphaFunctions::EaseIn);
4993 animation.FinishedSignal().Connect(&application, finishCheck);
4996 application.SendNotification();
4997 application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
4999 // We didn't expect the animation to finish yet
5000 application.SendNotification();
5001 finishCheck.CheckSignalNotReceived();
5003 // The size should have travelled less, than with a linear alpha function
5004 Vector3 current(actor.GetCurrentSize());
5005 DALI_TEST_CHECK( current.x > 0.0f );
5006 DALI_TEST_CHECK( current.y > 0.0f );
5007 DALI_TEST_CHECK( current.z > 0.0f );
5008 DALI_TEST_CHECK( current.x < ninetyNinePercentProgress.x );
5009 DALI_TEST_CHECK( current.y < ninetyNinePercentProgress.y );
5010 DALI_TEST_CHECK( current.z < ninetyNinePercentProgress.z );
5012 application.SendNotification();
5013 application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
5015 // We did expect the animation to finish
5016 application.SendNotification();
5017 finishCheck.CheckSignalReceived();
5018 DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION );
5021 finishCheck.Reset();
5022 actor.SetSize(Vector3::ZERO);
5023 application.SendNotification();
5024 application.Render(0);
5025 DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
5027 // Repeat with a delay
5029 animation = Animation::New(durationSeconds);
5030 animation.AnimateTo( Property(actor, Actor::SIZE), targetSize, AlphaFunctions::Linear, TimePeriod(delay, durationSeconds - delay));
5031 animation.FinishedSignal().Connect(&application, finishCheck);
5034 application.SendNotification();
5035 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
5037 // We didn't expect the animation to finish yet
5038 application.SendNotification();
5039 finishCheck.CheckSignalNotReceived();
5040 DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
5042 application.SendNotification();
5043 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
5045 // We did expect the animation to finish
5046 application.SendNotification();
5047 finishCheck.CheckSignalReceived();
5048 DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION );
5052 int UtcDaliAnimationAnimateToActorSizeWidth(void)
5054 TestApplication application;
5056 Actor actor = Actor::New();
5057 Stage::GetCurrent().Add(actor);
5058 float startValue(0.0f);
5059 DALI_TEST_EQUALS( actor.GetCurrentSize().width, startValue, TEST_LOCATION );
5060 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SIZE_WIDTH), startValue, TEST_LOCATION );
5062 // Build the animation
5063 float durationSeconds(1.0f);
5064 Animation animation = Animation::New(durationSeconds);
5065 float targetWidth(10.0f);
5066 animation.AnimateTo( Property(actor, Actor::SIZE_WIDTH), targetWidth );
5068 float fiftyPercentProgress(startValue + (targetWidth - startValue)*0.5f);
5070 // Start the animation
5073 bool signalReceived(false);
5074 AnimationFinishCheck finishCheck(signalReceived);
5075 animation.FinishedSignal().Connect(&application, finishCheck);
5077 application.SendNotification();
5078 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
5080 // We didn't expect the animation to finish yet
5081 application.SendNotification();
5082 finishCheck.CheckSignalNotReceived();
5083 DALI_TEST_EQUALS( actor.GetCurrentSize().width, fiftyPercentProgress, TEST_LOCATION );
5084 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SIZE_WIDTH), fiftyPercentProgress, TEST_LOCATION );
5086 application.SendNotification();
5087 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
5089 // We did expect the animation to finish
5090 application.SendNotification();
5091 finishCheck.CheckSignalReceived();
5092 DALI_TEST_EQUALS( actor.GetCurrentSize().width, targetWidth, TEST_LOCATION );
5093 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SIZE_WIDTH), targetWidth, TEST_LOCATION );
5097 int UtcDaliAnimationAnimateToActorSizeHeight(void)
5099 TestApplication application;
5101 Actor actor = Actor::New();
5102 Stage::GetCurrent().Add(actor);
5103 float startValue(0.0f);
5104 DALI_TEST_EQUALS( actor.GetCurrentSize().height, startValue, TEST_LOCATION );
5105 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SIZE_HEIGHT), startValue, TEST_LOCATION );
5107 // Build the animation
5108 float durationSeconds(1.0f);
5109 Animation animation = Animation::New(durationSeconds);
5110 float targetHeight(-10.0f);
5111 animation.AnimateTo( Property(actor, Actor::SIZE_HEIGHT), targetHeight );
5113 float fiftyPercentProgress(startValue + (targetHeight - startValue)*0.5f);
5115 // Start the animation
5118 bool signalReceived(false);
5119 AnimationFinishCheck finishCheck(signalReceived);
5120 animation.FinishedSignal().Connect(&application, finishCheck);
5122 application.SendNotification();
5123 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
5125 // We didn't expect the animation to finish yet
5126 application.SendNotification();
5127 finishCheck.CheckSignalNotReceived();
5128 DALI_TEST_EQUALS( actor.GetCurrentSize().height, fiftyPercentProgress, TEST_LOCATION );
5129 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SIZE_HEIGHT), fiftyPercentProgress, TEST_LOCATION );
5131 application.SendNotification();
5132 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
5134 // We did expect the animation to finish
5135 application.SendNotification();
5136 finishCheck.CheckSignalReceived();
5137 DALI_TEST_EQUALS( actor.GetCurrentSize().height, targetHeight, TEST_LOCATION );
5138 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SIZE_HEIGHT), targetHeight, TEST_LOCATION );
5142 int UtcDaliAnimationAnimateToActorSizeDepth(void)
5144 TestApplication application;
5146 Actor actor = Actor::New();
5147 Stage::GetCurrent().Add(actor);
5148 float startValue(0.0f);
5149 DALI_TEST_EQUALS( actor.GetCurrentSize().depth, startValue, TEST_LOCATION );
5150 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SIZE_DEPTH), startValue, TEST_LOCATION );
5152 // Build the animation
5153 float durationSeconds(1.0f);
5154 Animation animation = Animation::New(durationSeconds);
5155 float targetDepth(-10.0f);
5156 animation.AnimateTo( Property(actor, Actor::SIZE_DEPTH), targetDepth );
5158 float fiftyPercentProgress(startValue + (targetDepth - startValue)*0.5f);
5160 // Start the animation
5163 bool signalReceived(false);
5164 AnimationFinishCheck finishCheck(signalReceived);
5165 animation.FinishedSignal().Connect(&application, finishCheck);
5167 application.SendNotification();
5168 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
5170 // We didn't expect the animation to finish yet
5171 application.SendNotification();
5172 finishCheck.CheckSignalNotReceived();
5173 DALI_TEST_EQUALS( actor.GetCurrentSize().depth, fiftyPercentProgress, TEST_LOCATION );
5174 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SIZE_DEPTH), fiftyPercentProgress, TEST_LOCATION );
5176 application.SendNotification();
5177 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
5179 // We did expect the animation to finish
5180 application.SendNotification();
5181 finishCheck.CheckSignalReceived();
5182 DALI_TEST_EQUALS( actor.GetCurrentSize().depth, targetDepth, TEST_LOCATION );
5183 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SIZE_DEPTH), targetDepth, TEST_LOCATION );
5187 int UtcDaliAnimationAnimateToActorPosition(void)
5189 TestApplication application;
5191 Actor actor = Actor::New();
5192 Stage::GetCurrent().Add(actor);
5193 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
5195 // Build the animation
5196 float durationSeconds(1.0f);
5197 Animation animation = Animation::New(durationSeconds);
5198 Vector3 targetPosition(200.0f, 200.0f, 200.0f);
5199 animation.AnimateTo(Property(actor, Actor::POSITION), targetPosition);
5201 Vector3 seventyFivePercentProgress(targetPosition * 0.75f);
5203 // Start the animation
5206 bool signalReceived(false);
5207 AnimationFinishCheck finishCheck(signalReceived);
5208 animation.FinishedSignal().Connect(&application, finishCheck);
5210 application.SendNotification();
5211 application.Render(static_cast<unsigned int>(durationSeconds*750.0f)/* 75% progress */);
5213 // We didn't expect the animation to finish yet
5214 application.SendNotification();
5215 finishCheck.CheckSignalNotReceived();
5216 DALI_TEST_EQUALS( actor.GetCurrentPosition(), seventyFivePercentProgress, TEST_LOCATION );
5218 application.SendNotification();
5219 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
5221 // We did expect the animation to finish
5222 application.SendNotification();
5223 finishCheck.CheckSignalReceived();
5224 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
5228 int UtcDaliAnimationAnimateToActorPositionX(void)
5230 TestApplication application;
5232 Actor actor = Actor::New();
5233 Stage::GetCurrent().Add(actor);
5234 float startValue(0.0f);
5235 DALI_TEST_EQUALS( actor.GetCurrentPosition().x, startValue, TEST_LOCATION );
5236 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_X), startValue, TEST_LOCATION );
5237 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_Y), startValue, TEST_LOCATION );
5238 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_Z), startValue, TEST_LOCATION );
5240 // Build the animation
5241 float durationSeconds(1.0f);
5242 Animation animation = Animation::New(durationSeconds);
5243 float targetX(1.0f);
5244 animation.AnimateTo( Property(actor, Actor::POSITION_X), targetX );
5246 float fiftyPercentProgress(startValue + (targetX - startValue)*0.5f);
5248 // Start the animation
5251 bool signalReceived(false);
5252 AnimationFinishCheck finishCheck(signalReceived);
5253 animation.FinishedSignal().Connect(&application, finishCheck);
5255 application.SendNotification();
5256 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
5258 // We didn't expect the animation to finish yet
5259 application.SendNotification();
5260 finishCheck.CheckSignalNotReceived();
5261 DALI_TEST_EQUALS( actor.GetCurrentPosition().x, fiftyPercentProgress, TEST_LOCATION );
5262 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_X), fiftyPercentProgress, TEST_LOCATION );
5263 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_Y), startValue, TEST_LOCATION );
5264 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_Z), startValue, TEST_LOCATION );
5266 application.SendNotification();
5267 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
5269 // We did expect the animation to finish
5270 application.SendNotification();
5271 finishCheck.CheckSignalReceived();
5272 DALI_TEST_EQUALS( actor.GetCurrentPosition().x, targetX, TEST_LOCATION );
5273 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_X), targetX, TEST_LOCATION );
5274 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_Y), startValue, TEST_LOCATION );
5275 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_Z), startValue, TEST_LOCATION );
5279 int UtcDaliAnimationAnimateToActorPositionY(void)
5281 TestApplication application;
5283 Actor actor = Actor::New();
5284 Stage::GetCurrent().Add(actor);
5285 float startValue(0.0f);
5286 DALI_TEST_EQUALS( actor.GetCurrentPosition().y, startValue, TEST_LOCATION );
5287 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_X), startValue, TEST_LOCATION );
5288 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_Y), startValue, TEST_LOCATION );
5289 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_Z), startValue, TEST_LOCATION );
5291 // Build the animation
5292 float durationSeconds(1.0f);
5293 Animation animation = Animation::New(durationSeconds);
5294 float targetY(10.0f);
5295 animation.AnimateTo( Property(actor, Actor::POSITION_Y), targetY );
5297 float fiftyPercentProgress(startValue + (targetY - startValue)*0.5f);
5299 // Start the animation
5302 bool signalReceived(false);
5303 AnimationFinishCheck finishCheck(signalReceived);
5304 animation.FinishedSignal().Connect(&application, finishCheck);
5306 application.SendNotification();
5307 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
5309 // We didn't expect the animation to finish yet
5310 application.SendNotification();
5311 finishCheck.CheckSignalNotReceived();
5312 DALI_TEST_EQUALS( actor.GetCurrentPosition().y, fiftyPercentProgress, TEST_LOCATION );
5313 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_X), startValue, TEST_LOCATION );
5314 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_Y), fiftyPercentProgress, TEST_LOCATION );
5315 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_Z), startValue, TEST_LOCATION );
5317 application.SendNotification();
5318 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
5320 // We did expect the animation to finish
5321 application.SendNotification();
5322 finishCheck.CheckSignalReceived();
5323 DALI_TEST_EQUALS( actor.GetCurrentPosition().y, targetY, TEST_LOCATION );
5324 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_X), startValue, TEST_LOCATION );
5325 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_Y), targetY, TEST_LOCATION );
5326 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_Z), startValue, TEST_LOCATION );
5330 int UtcDaliAnimationAnimateToActorPositionZ(void)
5332 TestApplication application;
5334 Actor actor = Actor::New();
5335 Stage::GetCurrent().Add(actor);
5336 float startValue(0.0f);
5337 DALI_TEST_EQUALS( actor.GetCurrentPosition().z, startValue, TEST_LOCATION );
5338 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_X), startValue, TEST_LOCATION );
5339 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_Y), startValue, TEST_LOCATION );
5340 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_Z), startValue, TEST_LOCATION );
5342 // Build the animation
5343 float durationSeconds(1.0f);
5344 Animation animation = Animation::New(durationSeconds);
5345 float targetZ(-5.0f);
5346 animation.AnimateTo( Property(actor, Actor::POSITION_Z), targetZ );
5348 float fiftyPercentProgress(startValue + (targetZ - startValue)*0.5f);
5350 // Start the animation
5353 bool signalReceived(false);
5354 AnimationFinishCheck finishCheck(signalReceived);
5355 animation.FinishedSignal().Connect(&application, finishCheck);
5357 application.SendNotification();
5358 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
5360 // We didn't expect the animation to finish yet
5361 application.SendNotification();
5362 finishCheck.CheckSignalNotReceived();
5363 DALI_TEST_EQUALS( actor.GetCurrentPosition().z, fiftyPercentProgress, TEST_LOCATION );
5364 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_X), startValue, TEST_LOCATION );
5365 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_Y), startValue, TEST_LOCATION );
5366 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_Z), fiftyPercentProgress, TEST_LOCATION );
5368 application.SendNotification();
5369 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
5371 // We did expect the animation to finish
5372 application.SendNotification();
5373 finishCheck.CheckSignalReceived();
5374 DALI_TEST_EQUALS( actor.GetCurrentPosition().z, targetZ, TEST_LOCATION );
5375 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_X), startValue, TEST_LOCATION );
5376 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_Y), startValue, TEST_LOCATION );
5377 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_Z), targetZ, TEST_LOCATION );
5381 int UtcDaliAnimationAnimateToActorPositionAlphaFunction(void)
5383 TestApplication application;
5385 Actor actor = Actor::New();
5386 Stage::GetCurrent().Add(actor);
5387 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
5389 // Build the animation
5390 float durationSeconds(1.0f);
5391 Animation animation = Animation::New(durationSeconds);
5392 Vector3 targetPosition(200.0f, 200.0f, 200.0f);
5393 animation.AnimateTo(Property(actor, Actor::POSITION), targetPosition, AlphaFunctions::EaseIn);
5395 Vector3 seventyFivePercentProgress(targetPosition * 0.75f);
5397 // Start the animation
5400 bool signalReceived(false);
5401 AnimationFinishCheck finishCheck(signalReceived);
5402 animation.FinishedSignal().Connect(&application, finishCheck);
5404 application.SendNotification();
5405 application.Render(static_cast<unsigned int>(durationSeconds*750.0f)/* 75% progress */);
5407 // We didn't expect the animation to finish yet
5408 application.SendNotification();
5409 finishCheck.CheckSignalNotReceived();
5411 // The position should have moved less, than with a linear alpha function
5412 Vector3 current(actor.GetCurrentPosition());
5413 DALI_TEST_CHECK( current.x > Vector3::ZERO.x );
5414 DALI_TEST_CHECK( current.y > Vector3::ZERO.y );
5415 DALI_TEST_CHECK( current.z > Vector3::ZERO.z );
5416 DALI_TEST_CHECK( current.x < seventyFivePercentProgress.x );
5417 DALI_TEST_CHECK( current.y < seventyFivePercentProgress.y );
5418 DALI_TEST_CHECK( current.z < seventyFivePercentProgress.z );
5420 application.SendNotification();
5421 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
5423 // We did expect the animation to finish
5424 application.SendNotification();
5425 finishCheck.CheckSignalReceived();
5426 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
5430 int UtcDaliAnimationAnimateToActorPositionTimePeriod(void)
5432 TestApplication application;
5434 Actor actor = Actor::New();
5435 Stage::GetCurrent().Add(actor);
5436 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
5438 // Build the animation
5439 float durationSeconds(1.0f);
5440 Animation animation = Animation::New(durationSeconds);
5441 Vector3 targetPosition(200.0f, 200.0f, 200.0f);
5443 animation.AnimateTo( Property(actor, Actor::POSITION),
5445 TimePeriod( delay, durationSeconds - delay ) );
5447 Vector3 seventyFivePercentProgress(targetPosition * 0.75f);
5449 // Start the animation
5452 bool signalReceived(false);
5453 AnimationFinishCheck finishCheck(signalReceived);
5454 animation.FinishedSignal().Connect(&application, finishCheck);
5456 application.SendNotification();
5457 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
5459 // We didn't expect the animation to finish yet
5460 application.SendNotification();
5461 finishCheck.CheckSignalNotReceived();
5462 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
5464 application.SendNotification();
5465 application.Render(static_cast<unsigned int>(durationSeconds*500.0f*0.75)/* 7/8 animation progress, 3/4 animator progress */);
5467 // We didn't expect the animation to finish yet
5468 application.SendNotification();
5469 finishCheck.CheckSignalNotReceived();
5470 DALI_TEST_EQUALS( actor.GetCurrentPosition(), seventyFivePercentProgress, TEST_LOCATION );
5472 application.SendNotification();
5473 application.Render(static_cast<unsigned int>(durationSeconds*500.0f*0.25) + 1u/*just beyond the animation duration*/);
5475 // We did expect the animation to finish
5476 application.SendNotification();
5477 finishCheck.CheckSignalReceived();
5478 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
5482 int UtcDaliAnimationAnimateToActorPositionAlphaFunctionTimePeriod(void)
5484 TestApplication application;
5486 Actor actor = Actor::New();
5487 Stage::GetCurrent().Add(actor);
5488 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
5490 // Build the animation
5491 float durationSeconds(1.0f);
5492 Animation animation = Animation::New(durationSeconds);
5493 Vector3 targetPosition(200.0f, 200.0f, 200.0f);
5495 animation.AnimateTo( Property(actor, Actor::POSITION),
5497 AlphaFunctions::Linear,
5498 TimePeriod( delay, durationSeconds - delay ) );
5500 Vector3 seventyFivePercentProgress(targetPosition * 0.75f);
5502 // Start the animation
5505 bool signalReceived(false);
5506 AnimationFinishCheck finishCheck(signalReceived);
5507 animation.FinishedSignal().Connect(&application, finishCheck);
5509 application.SendNotification();
5510 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
5512 // We didn't expect the animation to finish yet
5513 application.SendNotification();
5514 finishCheck.CheckSignalNotReceived();
5515 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
5517 application.SendNotification();
5518 application.Render(static_cast<unsigned int>(durationSeconds*500.0f*0.75)/* 7/8 animation progress, 3/4 animator progress */);
5520 // We didn't expect the animation to finish yet
5521 application.SendNotification();
5522 finishCheck.CheckSignalNotReceived();
5523 DALI_TEST_EQUALS( actor.GetCurrentPosition(), seventyFivePercentProgress, TEST_LOCATION );
5525 application.SendNotification();
5526 application.Render(static_cast<unsigned int>(durationSeconds*500.0f*0.25) + 1u/*just beyond the animation duration*/);
5528 // We did expect the animation to finish
5529 application.SendNotification();
5530 finishCheck.CheckSignalReceived();
5531 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
5535 int UtcDaliAnimationAnimateToActorRotationAngleAxis(void)
5537 TestApplication application;
5539 Actor actor = Actor::New();
5540 actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
5541 Stage::GetCurrent().Add(actor);
5542 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5544 // Build the animation
5545 float durationSeconds(1.0f);
5546 Animation animation = Animation::New(durationSeconds);
5547 Degree targetRotationDegrees(90.0f);
5548 Radian targetRotationRadians(targetRotationDegrees);
5549 animation.AnimateTo( Property(actor, Actor::ROTATION), AngleAxis(targetRotationRadians, Vector3::YAXIS) );
5551 // Start the animation
5554 bool signalReceived(false);
5555 AnimationFinishCheck finishCheck(signalReceived);
5556 animation.FinishedSignal().Connect(&application, finishCheck);
5558 application.SendNotification();
5559 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
5561 // We didn't expect the animation to finish yet
5562 application.SendNotification();
5563 finishCheck.CheckSignalNotReceived();
5564 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.25f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5566 application.SendNotification();
5567 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
5569 // We didn't expect the animation to finish yet
5570 application.SendNotification();
5571 finishCheck.CheckSignalNotReceived();
5572 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.5f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5574 application.SendNotification();
5575 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
5577 // We didn't expect the animation to finish yet
5578 application.SendNotification();
5579 finishCheck.CheckSignalNotReceived();
5580 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.75f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5582 application.SendNotification();
5583 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
5585 // We did expect the animation to finish
5586 application.SendNotification();
5587 finishCheck.CheckSignalReceived();
5588 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5592 int UtcDaliAnimationAnimateToActorRotationQuaternion(void)
5594 TestApplication application;
5596 Actor actor = Actor::New();
5597 actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
5598 Stage::GetCurrent().Add(actor);
5599 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5601 // Build the animation
5602 float durationSeconds(1.0f);
5603 Animation animation = Animation::New(durationSeconds);
5604 Degree targetRotationDegrees(90.0f);
5605 Radian targetRotationRadians(targetRotationDegrees);
5606 Quaternion targetRotation(targetRotationRadians, Vector3::YAXIS);
5607 animation.AnimateTo( Property(actor, Actor::ROTATION), targetRotation );
5609 // Start the animation
5612 bool signalReceived(false);
5613 AnimationFinishCheck finishCheck(signalReceived);
5614 animation.FinishedSignal().Connect(&application, finishCheck);
5616 application.SendNotification();
5617 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
5619 // We didn't expect the animation to finish yet
5620 application.SendNotification();
5621 finishCheck.CheckSignalNotReceived();
5622 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.25f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5624 application.SendNotification();
5625 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
5627 // We didn't expect the animation to finish yet
5628 application.SendNotification();
5629 finishCheck.CheckSignalNotReceived();
5630 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.5f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5632 application.SendNotification();
5633 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
5635 // We didn't expect the animation to finish yet
5636 application.SendNotification();
5637 finishCheck.CheckSignalNotReceived();
5638 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.75f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5640 application.SendNotification();
5641 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
5643 // We did expect the animation to finish
5644 application.SendNotification();
5645 finishCheck.CheckSignalReceived();
5646 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5650 int UtcDaliAnimationAnimateToActorRotationAlphaFunction(void)
5652 TestApplication application;
5654 Actor actor = Actor::New();
5655 actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
5656 Stage::GetCurrent().Add(actor);
5657 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5659 // Build the animation
5660 float durationSeconds(1.0f);
5661 Animation animation = Animation::New(durationSeconds);
5662 Degree targetRotationDegrees(90.0f);
5663 Radian targetRotationRadians(targetRotationDegrees);
5664 animation.AnimateTo( Property(actor, Actor::ROTATION), AngleAxis(targetRotationDegrees, Vector3::YAXIS), AlphaFunctions::EaseIn);
5666 // Start the animation
5669 bool signalReceived(false);
5670 AnimationFinishCheck finishCheck(signalReceived);
5671 animation.FinishedSignal().Connect(&application, finishCheck);
5673 application.SendNotification();
5674 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
5676 // We didn't expect the animation to finish yet
5677 application.SendNotification();
5678 finishCheck.CheckSignalNotReceived();
5679 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(0.25f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5681 application.SendNotification();
5682 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
5684 // We didn't expect the animation to finish yet
5685 application.SendNotification();
5686 finishCheck.CheckSignalNotReceived();
5687 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(0.5f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5689 application.SendNotification();
5690 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
5692 // We didn't expect the animation to finish yet
5693 application.SendNotification();
5694 finishCheck.CheckSignalNotReceived();
5695 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(0.75f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5697 application.SendNotification();
5698 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
5700 // We did expect the animation to finish
5701 application.SendNotification();
5702 finishCheck.CheckSignalReceived();
5703 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5707 int UtcDaliAnimationAnimateToActorRotationTimePeriod(void)
5709 TestApplication application;
5711 Actor actor = Actor::New();
5712 actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
5713 Stage::GetCurrent().Add(actor);
5714 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5716 // Build the animation
5717 float durationSeconds(1.0f);
5718 Animation animation = Animation::New(durationSeconds);
5719 Degree targetRotationDegrees(90.0f);
5720 Radian targetRotationRadians(targetRotationDegrees);
5722 animation.AnimateTo( Property(actor, Actor::ROTATION), AngleAxis(targetRotationDegrees, Vector3::YAXIS), TimePeriod(delay, durationSeconds - delay));
5724 // Start the animation
5727 bool signalReceived(false);
5728 AnimationFinishCheck finishCheck(signalReceived);
5729 animation.FinishedSignal().Connect(&application, finishCheck);
5731 application.SendNotification();
5732 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
5734 // We didn't expect the animation to finish yet
5735 application.SendNotification();
5736 finishCheck.CheckSignalNotReceived();
5737 float progress = max(0.0f, 0.25f - delay) / (1.0f - delay);
5738 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * progress, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5740 application.SendNotification();
5741 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
5743 // We didn't expect the animation to finish yet
5744 application.SendNotification();
5745 finishCheck.CheckSignalNotReceived();
5746 progress = max(0.0f, 0.5f - delay) / (1.0f - delay);
5747 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * progress, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5749 application.SendNotification();
5750 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
5752 // We didn't expect the animation to finish yet
5753 application.SendNotification();
5754 finishCheck.CheckSignalNotReceived();
5755 progress = max(0.0f, 0.75f - delay) / (1.0f - delay);
5756 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * progress, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5758 application.SendNotification();
5759 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
5761 // We did expect the animation to finish
5762 application.SendNotification();
5763 finishCheck.CheckSignalReceived();
5764 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5768 int UtcDaliAnimationAnimateToActorRotationAlphaFunctionTimePeriod(void)
5770 TestApplication application;
5772 Actor actor = Actor::New();
5773 actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
5774 Stage::GetCurrent().Add(actor);
5775 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5777 // Build the animation
5778 float durationSeconds(1.0f);
5779 Animation animation = Animation::New(durationSeconds);
5780 Degree targetRotationDegrees(90.0f);
5781 Radian targetRotationRadians(targetRotationDegrees);
5783 animation.AnimateTo( Property(actor, Actor::ROTATION), AngleAxis(targetRotationDegrees, Vector3::YAXIS), AlphaFunctions::EaseIn, TimePeriod(delay, durationSeconds - delay));
5785 // Start the animation
5788 bool signalReceived(false);
5789 AnimationFinishCheck finishCheck(signalReceived);
5790 animation.FinishedSignal().Connect(&application, finishCheck);
5792 application.SendNotification();
5793 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
5795 // We didn't expect the animation to finish yet
5796 application.SendNotification();
5797 finishCheck.CheckSignalNotReceived();
5798 float progress = max(0.0f, 0.25f - delay) / (1.0f - delay);
5799 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5801 application.SendNotification();
5802 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
5804 // We didn't expect the animation to finish yet
5805 application.SendNotification();
5806 finishCheck.CheckSignalNotReceived();
5807 progress = max(0.0f, 0.5f - delay) / (1.0f - delay);
5808 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5810 application.SendNotification();
5811 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
5813 // We didn't expect the animation to finish yet
5814 application.SendNotification();
5815 finishCheck.CheckSignalNotReceived();
5816 progress = max(0.0f, 0.75f - delay) / (1.0f - delay);
5817 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5819 application.SendNotification();
5820 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
5822 // We did expect the animation to finish
5823 application.SendNotification();
5824 finishCheck.CheckSignalReceived();
5825 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5829 int UtcDaliAnimationAnimateToActorScale(void)
5831 TestApplication application;
5833 Actor actor = Actor::New();
5834 Stage::GetCurrent().Add(actor);
5835 DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
5837 // Build the animation
5838 float durationSeconds(1.0f);
5839 Animation animation = Animation::New(durationSeconds);
5840 Vector3 targetScale(2.0f, 2.0f, 2.0f);
5841 animation.AnimateTo( Property(actor, Actor::SCALE), targetScale );
5843 Vector3 ninetyNinePercentProgress(Vector3::ONE + (targetScale - Vector3::ONE)*0.99f);
5845 // Start the animation
5848 bool signalReceived(false);
5849 AnimationFinishCheck finishCheck(signalReceived);
5850 animation.FinishedSignal().Connect(&application, finishCheck);
5852 application.SendNotification();
5853 application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
5855 // We didn't expect the animation to finish yet
5856 application.SendNotification();
5857 finishCheck.CheckSignalNotReceived();
5858 DALI_TEST_EQUALS( actor.GetCurrentScale(), ninetyNinePercentProgress, TEST_LOCATION );
5860 application.SendNotification();
5861 application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
5863 // We did expect the animation to finish
5864 application.SendNotification();
5865 finishCheck.CheckSignalReceived();
5866 DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
5869 finishCheck.Reset();
5870 actor.SetScale(Vector3::ONE);
5871 application.SendNotification();
5872 application.Render(0);
5873 DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
5875 // Repeat with a different (ease-in) alpha function
5876 animation = Animation::New(durationSeconds);
5877 animation.AnimateTo( Property(actor, Actor::SCALE), targetScale, AlphaFunctions::EaseIn);
5878 animation.FinishedSignal().Connect(&application, finishCheck);
5881 application.SendNotification();
5882 application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
5884 // We didn't expect the animation to finish yet
5885 application.SendNotification();
5886 finishCheck.CheckSignalNotReceived();
5888 // The scale should have grown less, than with a linear alpha function
5889 Vector3 current(actor.GetCurrentScale());
5890 DALI_TEST_CHECK( current.x > 1.0f );
5891 DALI_TEST_CHECK( current.y > 1.0f );
5892 DALI_TEST_CHECK( current.z > 1.0f );
5893 DALI_TEST_CHECK( current.x < ninetyNinePercentProgress.x );
5894 DALI_TEST_CHECK( current.y < ninetyNinePercentProgress.y );
5895 DALI_TEST_CHECK( current.z < ninetyNinePercentProgress.z );
5897 application.SendNotification();
5898 application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
5900 // We did expect the animation to finish
5901 application.SendNotification();
5902 finishCheck.CheckSignalReceived();
5903 DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
5906 finishCheck.Reset();
5907 actor.SetScale(Vector3::ONE);
5908 application.SendNotification();
5909 application.Render(0);
5910 DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
5912 // Repeat with a delay
5914 animation = Animation::New(durationSeconds);
5915 animation.AnimateTo( Property(actor, Actor::SCALE), targetScale, AlphaFunctions::Linear, TimePeriod(delay, durationSeconds - delay));
5916 animation.FinishedSignal().Connect(&application, finishCheck);
5919 application.SendNotification();
5920 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
5922 // We didn't expect the animation to finish yet
5923 application.SendNotification();
5924 finishCheck.CheckSignalNotReceived();
5925 DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
5927 application.SendNotification();
5928 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
5930 // We did expect the animation to finish
5931 application.SendNotification();
5932 finishCheck.CheckSignalReceived();
5933 DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
5937 int UtcDaliAnimationAnimateToActorScaleX(void)
5939 TestApplication application;
5941 Actor actor = Actor::New();
5942 Stage::GetCurrent().Add(actor);
5943 float startValue(1.0f);
5944 DALI_TEST_EQUALS( actor.GetCurrentScale().x, startValue, TEST_LOCATION );
5945 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_X), startValue, TEST_LOCATION );
5946 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_Y), startValue, TEST_LOCATION );
5947 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_Z), startValue, TEST_LOCATION );
5949 // Build the animation
5950 float durationSeconds(1.0f);
5951 Animation animation = Animation::New(durationSeconds);
5952 float targetX(10.0f);
5953 animation.AnimateTo( Property(actor, Actor::SCALE_X), targetX );
5955 float fiftyPercentProgress(startValue + (targetX - startValue)*0.5f);
5957 // Start the animation
5960 bool signalReceived(false);
5961 AnimationFinishCheck finishCheck(signalReceived);
5962 animation.FinishedSignal().Connect(&application, finishCheck);
5964 application.SendNotification();
5965 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
5967 // We didn't expect the animation to finish yet
5968 application.SendNotification();
5969 finishCheck.CheckSignalNotReceived();
5970 DALI_TEST_EQUALS( actor.GetCurrentScale().x, fiftyPercentProgress, TEST_LOCATION );
5971 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_X), fiftyPercentProgress, TEST_LOCATION );
5972 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_Y), startValue, TEST_LOCATION );
5973 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_Z), startValue, TEST_LOCATION );
5975 application.SendNotification();
5976 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
5978 // We did expect the animation to finish
5979 application.SendNotification();
5980 finishCheck.CheckSignalReceived();
5981 DALI_TEST_EQUALS( actor.GetCurrentScale().x, targetX, TEST_LOCATION );
5982 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_X), targetX, TEST_LOCATION );
5983 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_Y), startValue, TEST_LOCATION );
5984 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_Z), startValue, TEST_LOCATION );
5988 int UtcDaliAnimationAnimateToActorScaleY(void)
5990 TestApplication application;
5992 Actor actor = Actor::New();
5993 Stage::GetCurrent().Add(actor);
5994 float startValue(1.0f);
5995 DALI_TEST_EQUALS( actor.GetCurrentScale().y, startValue, TEST_LOCATION );
5996 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_X), startValue, TEST_LOCATION );
5997 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_Y), startValue, TEST_LOCATION );
5998 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_Z), startValue, TEST_LOCATION );
6000 // Build the animation
6001 float durationSeconds(1.0f);
6002 Animation animation = Animation::New(durationSeconds);
6003 float targetY(1000.0f);
6004 animation.AnimateTo( Property(actor, Actor::SCALE_Y), targetY );
6006 float fiftyPercentProgress(startValue + (targetY - startValue)*0.5f);
6008 // Start the animation
6011 bool signalReceived(false);
6012 AnimationFinishCheck finishCheck(signalReceived);
6013 animation.FinishedSignal().Connect(&application, finishCheck);
6015 application.SendNotification();
6016 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
6018 // We didn't expect the animation to finish yet
6019 application.SendNotification();
6020 finishCheck.CheckSignalNotReceived();
6021 DALI_TEST_EQUALS( actor.GetCurrentScale().y, fiftyPercentProgress, TEST_LOCATION );
6022 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_X), startValue, TEST_LOCATION );
6023 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_Y), fiftyPercentProgress, TEST_LOCATION );
6024 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_Z), startValue, TEST_LOCATION );
6026 application.SendNotification();
6027 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
6029 // We did expect the animation to finish
6030 application.SendNotification();
6031 finishCheck.CheckSignalReceived();
6032 DALI_TEST_EQUALS( actor.GetCurrentScale().y, targetY, TEST_LOCATION );
6033 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_X), startValue, TEST_LOCATION );
6034 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_Y), targetY, TEST_LOCATION );
6035 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_Z), startValue, TEST_LOCATION );
6039 int UtcDaliAnimationAnimateToActorScaleZ(void)
6041 TestApplication application;
6043 Actor actor = Actor::New();
6044 Stage::GetCurrent().Add(actor);
6045 float startValue(1.0f);
6046 DALI_TEST_EQUALS( actor.GetCurrentScale().z, startValue, TEST_LOCATION );
6047 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_X), startValue, TEST_LOCATION );
6048 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_Y), startValue, TEST_LOCATION );
6049 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_Z), startValue, TEST_LOCATION );
6051 // Build the animation
6052 float durationSeconds(1.0f);
6053 Animation animation = Animation::New(durationSeconds);
6054 float targetZ(-1000.0f);
6055 animation.AnimateTo( Property(actor, Actor::SCALE_Z), targetZ );
6057 float fiftyPercentProgress(startValue + (targetZ - startValue)*0.5f);
6059 // Start the animation
6062 bool signalReceived(false);
6063 AnimationFinishCheck finishCheck(signalReceived);
6064 animation.FinishedSignal().Connect(&application, finishCheck);
6066 application.SendNotification();
6067 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
6069 // We didn't expect the animation to finish yet
6070 application.SendNotification();
6071 finishCheck.CheckSignalNotReceived();
6072 DALI_TEST_EQUALS( actor.GetCurrentScale().z, fiftyPercentProgress, TEST_LOCATION );
6073 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_X), startValue, TEST_LOCATION );
6074 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_Y), startValue, TEST_LOCATION );
6075 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_Z), fiftyPercentProgress, TEST_LOCATION );
6077 application.SendNotification();
6078 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
6080 // We did expect the animation to finish
6081 application.SendNotification();
6082 finishCheck.CheckSignalReceived();
6083 DALI_TEST_EQUALS( actor.GetCurrentScale().z, targetZ, TEST_LOCATION );
6084 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_X), startValue, TEST_LOCATION );
6085 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_Y), startValue, TEST_LOCATION );
6086 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_Z), targetZ, TEST_LOCATION );
6090 int UtcDaliAnimationAnimateToActorColor(void)
6092 TestApplication application;
6094 Actor actor = Actor::New();
6095 Stage::GetCurrent().Add(actor);
6096 DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
6098 // Build the animation
6099 float durationSeconds(1.0f);
6100 Animation animation = Animation::New(durationSeconds);
6101 Vector4 targetColor(Color::RED);
6102 animation.AnimateTo( Property(actor, Actor::COLOR), targetColor );
6104 Vector4 tenPercentProgress(Vector4(1.0f, 0.9f, 0.9f, 1.0f));
6105 Vector4 twentyPercentProgress(Vector4(1.0f, 0.8f, 0.8f, 1.0f));
6107 // Start the animation
6110 bool signalReceived(false);
6111 AnimationFinishCheck finishCheck(signalReceived);
6112 animation.FinishedSignal().Connect(&application, finishCheck);
6114 application.SendNotification();
6115 application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% progress */);
6117 // We didn't expect the animation to finish yet
6118 application.SendNotification();
6119 finishCheck.CheckSignalNotReceived();
6120 DALI_TEST_EQUALS( actor.GetCurrentColor(), tenPercentProgress, TEST_LOCATION );
6122 application.SendNotification();
6123 application.Render(static_cast<unsigned int>(durationSeconds*900.0f) + 1u/*just beyond the animation duration*/);
6125 // We did expect the animation to finish
6126 application.SendNotification();
6127 finishCheck.CheckSignalReceived();
6128 DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION );
6131 finishCheck.Reset();
6132 actor.SetColor(Color::WHITE);
6133 application.SendNotification();
6134 application.Render(0);
6135 DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
6137 // Repeat with a different (ease-in) alpha function
6138 animation = Animation::New(durationSeconds);
6139 animation.AnimateTo( Property(actor, Actor::COLOR), targetColor, AlphaFunctions::EaseIn);
6140 animation.FinishedSignal().Connect(&application, finishCheck);
6143 application.SendNotification();
6144 application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% progress */);
6146 // We didn't expect the animation to finish yet
6147 application.SendNotification();
6148 finishCheck.CheckSignalNotReceived();
6150 // The color should have changed less, than with a linear alpha function
6151 Vector4 current(actor.GetCurrentColor());
6152 DALI_TEST_CHECK( current.x == 1.0f ); // doesn't change
6153 DALI_TEST_CHECK( current.y < 1.0f );
6154 DALI_TEST_CHECK( current.y > tenPercentProgress.y );
6155 DALI_TEST_CHECK( current.z < 1.0f );
6156 DALI_TEST_CHECK( current.z > tenPercentProgress.z );
6157 DALI_TEST_CHECK( current.w == 1.0f ); // doesn't change
6159 application.SendNotification();
6160 application.Render(static_cast<unsigned int>(durationSeconds*900.0f) + 1u/*just beyond the animation duration*/);
6162 // We did expect the animation to finish
6163 application.SendNotification();
6164 finishCheck.CheckSignalReceived();
6165 DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION );
6168 finishCheck.Reset();
6169 actor.SetColor(Color::WHITE);
6170 application.SendNotification();
6171 application.Render(0);
6172 DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
6174 // Repeat with a shorter animator duration
6175 float animatorDuration = 0.5f;
6176 animation = Animation::New(durationSeconds);
6177 animation.AnimateTo( Property(actor, Actor::COLOR), targetColor, AlphaFunctions::Linear, TimePeriod(animatorDuration));
6178 animation.FinishedSignal().Connect(&application, finishCheck);
6181 application.SendNotification();
6182 application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% animation progress, 20% animator progress */);
6184 // We didn't expect the animation to finish yet
6185 application.SendNotification();
6186 finishCheck.CheckSignalNotReceived();
6187 DALI_TEST_EQUALS( actor.GetCurrentColor(), twentyPercentProgress, TEST_LOCATION );
6189 application.SendNotification();
6190 application.Render(static_cast<unsigned int>(durationSeconds*400.0f)/* 50% animation progress, 100% animator progress */);
6192 // We didn't expect the animation to finish yet
6193 application.SendNotification();
6194 finishCheck.CheckSignalNotReceived();
6195 DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION );
6197 application.SendNotification();
6198 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
6200 // We did expect the animation to finish
6201 application.SendNotification();
6202 finishCheck.CheckSignalReceived();
6203 DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION );
6207 int UtcDaliAnimationAnimateToActorColorRed(void)
6209 TestApplication application;
6211 Actor actor = Actor::New();
6212 Stage::GetCurrent().Add(actor);
6213 float startValue(1.0f);
6214 DALI_TEST_EQUALS( actor.GetCurrentColor().r, startValue, TEST_LOCATION );
6215 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
6216 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
6217 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
6218 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), startValue, TEST_LOCATION );
6220 // Build the animation
6221 float durationSeconds(1.0f);
6222 Animation animation = Animation::New(durationSeconds);
6223 float targetRed(0.5f);
6224 animation.AnimateTo( Property(actor, Actor::COLOR_RED), targetRed );
6226 float fiftyPercentProgress(startValue + (targetRed - startValue)*0.5f);
6228 // Start the animation
6231 bool signalReceived(false);
6232 AnimationFinishCheck finishCheck(signalReceived);
6233 animation.FinishedSignal().Connect(&application, finishCheck);
6235 application.SendNotification();
6236 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
6238 // We didn't expect the animation to finish yet
6239 application.SendNotification();
6240 finishCheck.CheckSignalNotReceived();
6241 DALI_TEST_EQUALS( actor.GetCurrentColor().r, fiftyPercentProgress, TEST_LOCATION );
6242 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), fiftyPercentProgress, TEST_LOCATION );
6243 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
6244 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
6245 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), startValue, TEST_LOCATION );
6247 application.SendNotification();
6248 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
6250 // We did expect the animation to finish
6251 application.SendNotification();
6252 finishCheck.CheckSignalReceived();
6253 DALI_TEST_EQUALS( actor.GetCurrentColor().r, targetRed, TEST_LOCATION );
6254 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), targetRed, TEST_LOCATION );
6255 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
6256 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
6257 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), startValue, TEST_LOCATION );
6261 int UtcDaliAnimationAnimateToActorColorGreen(void)
6263 TestApplication application;
6265 Actor actor = Actor::New();
6266 Stage::GetCurrent().Add(actor);
6267 float startValue(1.0f);
6268 DALI_TEST_EQUALS( actor.GetCurrentColor().g, startValue, TEST_LOCATION );
6269 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
6270 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
6271 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
6272 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), startValue, TEST_LOCATION );
6274 // Build the animation
6275 float durationSeconds(1.0f);
6276 Animation animation = Animation::New(durationSeconds);
6277 float targetGreen(0.5f);
6278 animation.AnimateTo( Property(actor, Actor::COLOR_GREEN), targetGreen );
6280 float fiftyPercentProgress(startValue + (targetGreen - startValue)*0.5f);
6282 // Start the animation
6285 bool signalReceived(false);
6286 AnimationFinishCheck finishCheck(signalReceived);
6287 animation.FinishedSignal().Connect(&application, finishCheck);
6289 application.SendNotification();
6290 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
6292 // We didn't expect the animation to finish yet
6293 application.SendNotification();
6294 finishCheck.CheckSignalNotReceived();
6295 DALI_TEST_EQUALS( actor.GetCurrentColor().g, fiftyPercentProgress, TEST_LOCATION );
6296 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
6297 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), fiftyPercentProgress, TEST_LOCATION );
6298 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
6299 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), startValue, TEST_LOCATION );
6301 application.SendNotification();
6302 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
6304 // We did expect the animation to finish
6305 application.SendNotification();
6306 finishCheck.CheckSignalReceived();
6307 DALI_TEST_EQUALS( actor.GetCurrentColor().g, targetGreen, TEST_LOCATION );
6308 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
6309 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), targetGreen, TEST_LOCATION );
6310 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
6311 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), startValue, TEST_LOCATION );
6315 int UtcDaliAnimationAnimateToActorColorBlue(void)
6317 TestApplication application;
6319 Actor actor = Actor::New();
6320 Stage::GetCurrent().Add(actor);
6321 float startValue(1.0f);
6322 DALI_TEST_EQUALS( actor.GetCurrentColor().b, startValue, TEST_LOCATION );
6323 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
6324 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
6325 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
6326 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), startValue, TEST_LOCATION );
6328 // Build the animation
6329 float durationSeconds(1.0f);
6330 Animation animation = Animation::New(durationSeconds);
6331 float targetBlue(0.5f);
6332 animation.AnimateTo( Property(actor, Actor::COLOR_BLUE), targetBlue );
6334 float fiftyPercentProgress(startValue + (targetBlue - startValue)*0.5f);
6336 // Start the animation
6339 bool signalReceived(false);
6340 AnimationFinishCheck finishCheck(signalReceived);
6341 animation.FinishedSignal().Connect(&application, finishCheck);
6343 application.SendNotification();
6344 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
6346 // We didn't expect the animation to finish yet
6347 application.SendNotification();
6348 finishCheck.CheckSignalNotReceived();
6349 DALI_TEST_EQUALS( actor.GetCurrentColor().b, fiftyPercentProgress, TEST_LOCATION );
6350 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
6351 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
6352 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), fiftyPercentProgress, TEST_LOCATION );
6353 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), startValue, TEST_LOCATION );
6355 application.SendNotification();
6356 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
6358 // We did expect the animation to finish
6359 application.SendNotification();
6360 finishCheck.CheckSignalReceived();
6361 DALI_TEST_EQUALS( actor.GetCurrentColor().b, targetBlue, TEST_LOCATION );
6362 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
6363 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
6364 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), targetBlue, TEST_LOCATION );
6365 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), startValue, TEST_LOCATION );
6369 int UtcDaliAnimationAnimateToActorColorAlpha(void)
6371 TestApplication application;
6373 Actor actor = Actor::New();
6374 Stage::GetCurrent().Add(actor);
6375 float startValue(1.0f);
6376 DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
6377 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
6378 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
6379 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
6380 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), startValue, TEST_LOCATION );
6382 // Build the animation
6383 float durationSeconds(1.0f);
6384 Animation animation = Animation::New(durationSeconds);
6385 float targetAlpha(0.5f);
6386 animation.AnimateTo( Property(actor, Actor::COLOR_ALPHA), targetAlpha );
6388 float fiftyPercentProgress(startValue + (targetAlpha - startValue)*0.5f);
6390 // Start the animation
6393 bool signalReceived(false);
6394 AnimationFinishCheck finishCheck(signalReceived);
6395 animation.FinishedSignal().Connect(&application, finishCheck);
6397 application.SendNotification();
6398 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
6400 // We didn't expect the animation to finish yet
6401 application.SendNotification();
6402 finishCheck.CheckSignalNotReceived();
6403 DALI_TEST_EQUALS( actor.GetCurrentColor().a, fiftyPercentProgress, TEST_LOCATION );
6404 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
6405 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
6406 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
6407 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), fiftyPercentProgress, TEST_LOCATION );
6409 application.SendNotification();
6410 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
6412 // We did expect the animation to finish
6413 application.SendNotification();
6414 finishCheck.CheckSignalReceived();
6415 DALI_TEST_EQUALS( actor.GetCurrentColor().a, targetAlpha, TEST_LOCATION );
6416 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
6417 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
6418 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
6419 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), targetAlpha, TEST_LOCATION );
6425 int UtcDaliAnimationKeyFrames01(void)
6427 TestApplication application;
6429 KeyFrames keyFrames = KeyFrames::New();
6430 DALI_TEST_EQUALS(keyFrames.GetType(), Property::NONE, TEST_LOCATION);
6432 keyFrames.Add(0.0f, 0.1f);
6433 keyFrames.Add(0.2f, 0.5f);
6434 keyFrames.Add(0.4f, 0.0f);
6435 keyFrames.Add(0.6f, 1.0f);
6436 keyFrames.Add(0.8f, 0.7f);
6437 keyFrames.Add(1.0f, 0.9f);
6439 DALI_TEST_EQUALS(keyFrames.GetType(), Property::FLOAT, TEST_LOCATION);
6443 keyFrames.Add(1.9f, false);
6445 catch (Dali::DaliException& e)
6447 tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
6448 DALI_TEST_ASSERT(e, "mType == value.GetType()", TEST_LOCATION);
6453 int UtcDaliAnimationKeyFrames02(void)
6455 TestApplication application;
6457 KeyFrames keyFrames = KeyFrames::New();
6458 DALI_TEST_EQUALS(keyFrames.GetType(), Property::NONE, TEST_LOCATION);
6460 keyFrames.Add(0.0f, true);
6461 keyFrames.Add(0.2f, false);
6462 keyFrames.Add(0.4f, false);
6463 keyFrames.Add(0.6f, true);
6464 keyFrames.Add(0.8f, true);
6465 keyFrames.Add(1.0f, false);
6467 DALI_TEST_EQUALS(keyFrames.GetType(), Property::BOOLEAN, TEST_LOCATION);
6471 keyFrames.Add(0.7f, Vector3(1.0f, 1.0f, 1.0f));
6473 catch (Dali::DaliException& e)
6475 tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
6476 DALI_TEST_ASSERT(e, "mType == value.GetType()", TEST_LOCATION);
6482 int UtcDaliAnimationKeyFrames03(void)
6484 TestApplication application;
6486 KeyFrames keyFrames = KeyFrames::New();
6487 DALI_TEST_EQUALS(keyFrames.GetType(), Property::NONE, TEST_LOCATION);
6489 keyFrames.Add(0.0f, Vector2(0.0f, 0.0f));
6490 keyFrames.Add(0.2f, Vector2(1.0f, 1.0f));
6491 keyFrames.Add(0.4f, Vector2(2.0f, 2.0f));
6492 keyFrames.Add(0.6f, Vector2(3.0f, 5.0f));
6493 keyFrames.Add(0.8f, Vector2(4.0f, 3.0f));
6494 keyFrames.Add(1.0f, Vector2(6.0f, 2.0f));
6496 DALI_TEST_EQUALS(keyFrames.GetType(), Property::VECTOR2, TEST_LOCATION);
6500 keyFrames.Add(0.7f, Vector3(1.0f, 1.0f, 1.0f));
6502 catch (Dali::DaliException& e)
6504 tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
6505 DALI_TEST_ASSERT(e, "mType == value.GetType()", TEST_LOCATION);
6511 int UtcDaliAnimationKeyFrames04(void)
6513 TestApplication application;
6515 KeyFrames keyFrames = KeyFrames::New();
6516 DALI_TEST_EQUALS(keyFrames.GetType(), Property::NONE, TEST_LOCATION);
6518 keyFrames.Add(0.0f, Vector3(0.0f, 4.0f, 0.0f));
6519 keyFrames.Add(0.2f, Vector3(1.0f, 3.0f, 1.0f));
6520 keyFrames.Add(0.4f, Vector3(2.0f, 2.0f, 2.0f));
6521 keyFrames.Add(0.6f, Vector3(3.0f, 2.0f, 5.0f));
6522 keyFrames.Add(0.8f, Vector3(4.0f, 4.0f, 3.0f));
6523 keyFrames.Add(1.0f, Vector3(6.0f, 8.0f, 2.0f));
6525 DALI_TEST_EQUALS(keyFrames.GetType(), Property::VECTOR3, TEST_LOCATION);
6529 keyFrames.Add(0.7f, 1.0f);
6531 catch (Dali::DaliException& e)
6533 tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
6534 DALI_TEST_ASSERT(e, "mType == value.GetType()", TEST_LOCATION);
6539 int UtcDaliAnimationKeyFrames05(void)
6541 TestApplication application;
6543 KeyFrames keyFrames = KeyFrames::New();
6544 DALI_TEST_EQUALS(keyFrames.GetType(), Property::NONE, TEST_LOCATION);
6546 keyFrames.Add(0.0f, Vector4(0.0f, 0.0f, 0.0f, 0.0f));
6547 keyFrames.Add(0.2f, Vector4(1.0f, 1.0f, 1.0f, 1.0f));
6548 keyFrames.Add(0.4f, Vector4(2.0f, 2.0f, 2.0f, 2.0f));
6549 keyFrames.Add(0.6f, Vector4(3.0f, 5.0f, 3.0f, 5.0f));
6550 keyFrames.Add(0.8f, Vector4(4.0f, 3.0f, 4.0f, 3.0f));
6551 keyFrames.Add(1.0f, Vector4(6.0f, 2.0f, 6.0f, 2.0f));
6553 DALI_TEST_EQUALS(keyFrames.GetType(), Property::VECTOR4, TEST_LOCATION);
6557 keyFrames.Add(0.7f, Quaternion(1.717f, Vector3::XAXIS));
6559 catch (Dali::DaliException& e)
6561 tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
6562 DALI_TEST_ASSERT(e, "mType == value.GetType()", TEST_LOCATION);
6568 int UtcDaliAnimationKeyFrames06(void)
6570 TestApplication application;
6572 KeyFrames keyFrames = KeyFrames::New();
6573 DALI_TEST_EQUALS(keyFrames.GetType(), Property::NONE, TEST_LOCATION);
6575 keyFrames.Add(0.0f, Quaternion(1.717f, Vector3::XAXIS));
6576 keyFrames.Add(0.2f, Quaternion(2.0f, Vector3::XAXIS));
6577 keyFrames.Add(0.4f, Quaternion(3.0f, Vector3::ZAXIS));
6578 keyFrames.Add(0.6f, Quaternion(4.0f, Vector3(1.0f, 1.0f, 1.0f)));
6579 keyFrames.Add(0.8f, AngleAxis(Degree(90), Vector3::XAXIS));
6580 keyFrames.Add(1.0f, Quaternion(3.0f, Vector3::YAXIS));
6582 DALI_TEST_EQUALS(keyFrames.GetType(), Property::ROTATION, TEST_LOCATION);
6586 keyFrames.Add(0.7f, 1.1f);
6588 catch (Dali::DaliException& e)
6590 tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
6591 DALI_TEST_ASSERT(e, "mType == value.GetType()", TEST_LOCATION);
6600 int UtcDaliAnimationAnimateBetweenActorColorAlpha(void)
6602 TestApplication application;
6604 float startValue(1.0f);
6605 Actor actor = Actor::New();
6606 actor.SetColor(Vector4(startValue, startValue, startValue, startValue));
6607 Stage::GetCurrent().Add(actor);
6609 DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
6610 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
6611 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
6612 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
6613 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), startValue, TEST_LOCATION );
6615 // Build the animation
6616 float durationSeconds(1.0f);
6617 Animation animation = Animation::New(durationSeconds);
6619 KeyFrames keyFrames = KeyFrames::New();
6620 keyFrames.Add(0.0f, 0.1f);
6621 keyFrames.Add(0.2f, 0.5f);
6622 keyFrames.Add(0.4f, 0.0f);
6623 keyFrames.Add(0.6f, 1.0f);
6624 keyFrames.Add(0.8f, 0.7f);
6625 keyFrames.Add(1.0f, 0.9f);
6627 animation.AnimateBetween( Property(actor, Actor::COLOR_ALPHA), keyFrames );
6629 // Start the animation
6632 bool signalReceived(false);
6633 AnimationFinishCheck finishCheck(signalReceived);
6634 animation.FinishedSignal().Connect(&application, finishCheck);
6635 application.SendNotification();
6636 application.Render(0);
6637 application.SendNotification();
6638 finishCheck.CheckSignalNotReceived();
6639 DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.1f, TEST_LOCATION );
6641 application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% progress */);
6642 application.SendNotification();
6643 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
6644 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
6645 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
6646 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.3f, 0.01f, TEST_LOCATION );
6647 DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.3f, 0.01f, TEST_LOCATION );
6649 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 30% progress */);
6650 application.SendNotification();
6651 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
6652 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
6653 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
6654 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.25f, 0.01f, TEST_LOCATION );
6655 DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.25f, 0.01f, TEST_LOCATION );
6657 application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 40% progress */);
6658 application.SendNotification();
6659 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
6660 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
6661 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
6662 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.0f, 0.01f, TEST_LOCATION );
6663 DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.0f, 0.01f, TEST_LOCATION );
6665 application.Render(static_cast<unsigned int>(durationSeconds*400.0f)/* 80% progress */);
6666 application.SendNotification();
6667 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
6668 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
6669 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
6670 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.7f, 0.01f, TEST_LOCATION );
6671 DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.7f, 0.01f, TEST_LOCATION );
6673 application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 90% progress */);
6674 application.SendNotification();
6675 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
6676 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
6677 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
6678 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.8f, 0.01f, TEST_LOCATION );
6679 DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.8f, 0.01f, TEST_LOCATION );
6681 application.Render(static_cast<unsigned int>(durationSeconds*100.0f)+1/* 100% progress */);
6682 application.SendNotification();
6683 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
6684 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
6685 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
6686 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.9f, 0.01f, TEST_LOCATION );
6687 DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.9f, 0.01f, TEST_LOCATION );
6689 // We did expect the animation to finish
6691 finishCheck.CheckSignalReceived();
6696 int UtcDaliAnimationAnimateBetweenActorColor(void)
6698 TestApplication application;
6700 float startValue(1.0f);
6701 Actor actor = Actor::New();
6702 actor.SetColor(Vector4(startValue, startValue, startValue, startValue));
6703 Stage::GetCurrent().Add(actor);
6705 DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
6706 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
6707 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
6708 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
6709 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), startValue, TEST_LOCATION );
6711 // Build the animation
6712 float durationSeconds(1.0f);
6713 Animation animation = Animation::New(durationSeconds);
6715 KeyFrames keyFrames = KeyFrames::New();
6716 keyFrames.Add(0.0f, Vector4(0.1f, 0.2f, 0.3f, 0.4f));
6717 keyFrames.Add(0.5f, Vector4(0.9f, 0.8f, 0.7f, 0.6f));
6718 keyFrames.Add(1.0f, Vector4(1.0f, 1.0f, 1.0f, 1.0f));
6720 animation.AnimateBetween( Property(actor, Actor::COLOR), keyFrames );
6722 // Start the animation
6725 bool signalReceived(false);
6726 AnimationFinishCheck finishCheck(signalReceived);
6727 animation.FinishedSignal().Connect(&application, finishCheck);
6728 application.SendNotification();
6729 application.Render(0);
6730 application.SendNotification();
6731 finishCheck.CheckSignalNotReceived();
6732 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), 0.1f, 0.01f, TEST_LOCATION );
6733 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 0.2f, 0.01f, TEST_LOCATION );
6734 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), 0.3f, 0.01f, TEST_LOCATION );
6735 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.4f, 0.01f, TEST_LOCATION );
6737 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
6738 application.SendNotification();
6739 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), 0.5f, 0.01f, TEST_LOCATION );
6740 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 0.5f, 0.01f, TEST_LOCATION );
6741 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), 0.5f, 0.01f, TEST_LOCATION );
6742 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.5f, 0.01f, TEST_LOCATION );
6744 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
6745 application.SendNotification();
6746 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), 0.9f, 0.01f, TEST_LOCATION );
6747 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 0.8f, 0.01f, TEST_LOCATION );
6748 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), 0.7f, 0.01f, TEST_LOCATION );
6749 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.6f, 0.01f, TEST_LOCATION );
6751 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
6752 application.SendNotification();
6753 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), 0.95f, 0.01f, TEST_LOCATION );
6754 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 0.90f, 0.01f, TEST_LOCATION );
6755 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), 0.85f, 0.01f, TEST_LOCATION );
6756 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.80f, 0.01f, TEST_LOCATION );
6758 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
6759 application.SendNotification();
6760 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), 1.0f, 0.01f, TEST_LOCATION );
6761 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 1.0f, 0.01f, TEST_LOCATION );
6762 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), 1.0f, 0.01f, TEST_LOCATION );
6763 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 1.0f, 0.01f, TEST_LOCATION );
6765 // We did expect the animation to finish
6767 finishCheck.CheckSignalReceived();
6771 int UtcDaliAnimationAnimateBetweenActorVisible01(void)
6773 TestApplication application;
6775 Actor actor = Actor::New();
6776 AngleAxis aa(Degree(90), Vector3::XAXIS);
6777 actor.SetRotation(aa.angle, aa.axis);
6778 Stage::GetCurrent().Add(actor);
6780 application.SendNotification();
6781 application.Render(0);
6783 DALI_TEST_EQUALS( actor.IsVisible(), true, TEST_LOCATION );
6785 // Build the animation
6786 float durationSeconds(1.0f);
6787 Animation animation = Animation::New(durationSeconds);
6789 KeyFrames keyFrames = KeyFrames::New();
6790 keyFrames.Add(0.0f, false);
6791 keyFrames.Add(0.2f, true);
6792 keyFrames.Add(0.4f, true);
6793 keyFrames.Add(0.8f, false);
6794 keyFrames.Add(1.0f, true);
6796 animation.AnimateBetween( Property(actor, Actor::VISIBLE), keyFrames );
6798 // Start the animation
6801 bool signalReceived(false);
6802 AnimationFinishCheck finishCheck(signalReceived);
6803 animation.FinishedSignal().Connect(&application, finishCheck);
6804 application.SendNotification();
6805 application.SendNotification();
6806 application.Render(static_cast<unsigned int>(durationSeconds*500.0f));
6807 application.SendNotification();
6808 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)+1);
6809 application.SendNotification();
6811 DALI_TEST_EQUALS( actor.IsVisible(), true, TEST_LOCATION);
6812 finishCheck.CheckSignalReceived();
6816 int UtcDaliAnimationAnimateBetweenActorRotation01(void)
6818 TestApplication application;
6820 Actor actor = Actor::New();
6821 AngleAxis aa(Degree(90), Vector3::XAXIS);
6822 actor.SetRotation(aa.angle, aa.axis);
6823 Stage::GetCurrent().Add(actor);
6825 application.SendNotification();
6826 application.Render(0);
6827 Quaternion start(Radian(aa.angle), aa.axis);
6828 DALI_TEST_EQUALS( actor.GetCurrentRotation(), start, 0.001f, TEST_LOCATION );
6830 // Build the animation
6831 float durationSeconds(1.0f);
6832 Animation animation = Animation::New(durationSeconds);
6834 KeyFrames keyFrames = KeyFrames::New();
6835 keyFrames.Add(0.0f, AngleAxis(Degree(60), Vector3::ZAXIS));
6837 animation.AnimateBetween( Property(actor, Actor::ROTATION), keyFrames );
6839 // Start the animation
6842 bool signalReceived(false);
6843 AnimationFinishCheck finishCheck(signalReceived);
6844 animation.FinishedSignal().Connect(&application, finishCheck);
6845 application.SendNotification();
6846 application.SendNotification();
6847 application.Render(static_cast<unsigned int>(durationSeconds*500.0f));
6848 application.SendNotification();
6849 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)+1);
6850 application.SendNotification();
6852 Quaternion check = Quaternion::FromAxisAngle(Vector4::ZAXIS, Radian(Degree(60)));
6854 DALI_TEST_EQUALS( actor.GetCurrentRotation(), check, 0.001f, TEST_LOCATION );
6855 finishCheck.CheckSignalReceived();
6859 int UtcDaliAnimationAnimateBetweenActorRotation02(void)
6861 TestApplication application;
6863 Actor actor = Actor::New();
6864 AngleAxis aa(Degree(90), Vector3::XAXIS);
6865 actor.SetRotation(aa.angle, aa.axis);
6866 application.SendNotification();
6867 application.Render(0);
6868 Stage::GetCurrent().Add(actor);
6870 Quaternion start(Radian(aa.angle), aa.axis);
6871 DALI_TEST_EQUALS( actor.GetCurrentRotation(), start, 0.001f, TEST_LOCATION );
6873 // Build the animation
6874 float durationSeconds(1.0f);
6875 Animation animation = Animation::New(durationSeconds);
6877 KeyFrames keyFrames = KeyFrames::New();
6878 keyFrames.Add(0.0f, AngleAxis(Degree(60), Vector3::XAXIS));
6879 keyFrames.Add(0.5f, AngleAxis(Degree(120), Vector3::XAXIS));
6880 keyFrames.Add(1.0f, AngleAxis(Degree(120), Vector3::YAXIS));
6882 animation.AnimateBetween( Property(actor, Actor::ROTATION), keyFrames );
6884 // Start the animation
6887 bool signalReceived(false);
6888 AnimationFinishCheck finishCheck(signalReceived);
6889 animation.FinishedSignal().Connect(&application, finishCheck);
6890 application.SendNotification();
6891 application.Render(0);
6892 application.SendNotification();
6893 finishCheck.CheckSignalNotReceived();
6895 Quaternion check(Radian(Degree(60)), Vector3::XAXIS);
6896 DALI_TEST_EQUALS( actor.GetCurrentRotation(), check, 0.001f, TEST_LOCATION );
6898 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
6899 application.SendNotification();
6900 check = Quaternion::FromAxisAngle(Vector4::XAXIS, Radian(Degree(90)));
6901 DALI_TEST_EQUALS( actor.GetCurrentRotation(), check, 0.001f, TEST_LOCATION );
6903 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
6904 application.SendNotification();
6905 check = Quaternion::FromAxisAngle(Vector4::XAXIS, Radian(Degree(120)));
6906 DALI_TEST_EQUALS( actor.GetCurrentRotation(), check, 0.001f, TEST_LOCATION );
6908 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
6909 application.SendNotification();
6910 check = Quaternion::FromAxisAngle(Vector4(0.5f, 0.5f, 0.0f, 0.0f), Radian(Degree(101.5)));
6911 DALI_TEST_EQUALS( actor.GetCurrentRotation(), check, 0.001f, TEST_LOCATION );
6913 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
6914 application.SendNotification();
6915 check = Quaternion::FromAxisAngle(Vector4::YAXIS, Radian(Degree(120)));
6916 DALI_TEST_EQUALS( actor.GetCurrentRotation(), check, 0.001f, TEST_LOCATION );
6918 // We did expect the animation to finish
6920 finishCheck.CheckSignalReceived();
6924 int UtcDaliAnimationMoveByFloat3(void)
6926 TestApplication application;
6928 Actor actor = Actor::New();
6929 Vector3 startPosition(10.0f, 10.0f, 10.0f);
6930 actor.SetPosition(startPosition);
6931 Stage::GetCurrent().Add(actor);
6932 application.SendNotification();
6933 application.Render(0);
6934 DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION );
6936 // Build the animation
6937 float durationSeconds(1.0f);
6938 Animation animation = Animation::New(durationSeconds);
6939 Vector3 targetPosition(20.0f, 20.0f, 20.0f);
6940 Vector3 relativePosition(targetPosition - startPosition);
6941 animation.MoveBy(actor, relativePosition.x, relativePosition.y, relativePosition.z);
6943 Vector3 ninetyFivePercentProgress(startPosition + relativePosition*0.95f);
6945 // Start the animation
6948 bool signalReceived(false);
6949 AnimationFinishCheck finishCheck(signalReceived);
6950 animation.FinishedSignal().Connect(&application, finishCheck);
6952 application.SendNotification();
6953 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
6955 // We didn't expect the animation to finish yet
6956 application.SendNotification();
6957 finishCheck.CheckSignalNotReceived();
6958 DALI_TEST_EQUALS( actor.GetCurrentPosition(), ninetyFivePercentProgress, TEST_LOCATION );
6960 application.SendNotification();
6961 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
6963 // We did expect the animation to finish
6964 application.SendNotification();
6965 finishCheck.CheckSignalReceived();
6966 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
6970 int UtcDaliAnimationMoveByVector3Alpha(void)
6972 TestApplication application;
6974 Actor actor = Actor::New();
6975 Vector3 startPosition(10.0f, 10.0f, 10.0f);
6976 actor.SetPosition(startPosition);
6977 Stage::GetCurrent().Add(actor);
6978 application.SendNotification();
6979 application.Render(0);
6980 DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION );
6982 // Build the animation
6983 float durationSeconds(1.0f);
6984 Animation animation = Animation::New(durationSeconds);
6985 Vector3 targetPosition(20.0f, 20.0f, 20.0f);
6986 Vector3 relativePosition(targetPosition - startPosition);
6987 animation.MoveBy(actor, relativePosition, AlphaFunctions::EaseOut);
6989 Vector3 ninetyFivePercentProgress(startPosition + relativePosition*0.95f);
6991 // Start the animation
6994 bool signalReceived(false);
6995 AnimationFinishCheck finishCheck(signalReceived);
6996 animation.FinishedSignal().Connect(&application, finishCheck);
6998 application.SendNotification();
6999 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
7001 // We didn't expect the animation to finish yet
7002 application.SendNotification();
7003 finishCheck.CheckSignalNotReceived();
7005 // The position should have moved more, than with a linear alpha function
7006 Vector3 current(actor.GetCurrentPosition());
7007 DALI_TEST_CHECK( current.x > ninetyFivePercentProgress.x );
7008 DALI_TEST_CHECK( current.y > ninetyFivePercentProgress.y );
7009 DALI_TEST_CHECK( current.z > ninetyFivePercentProgress.z );
7011 application.SendNotification();
7012 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
7014 // We did expect the animation to finish
7015 application.SendNotification();
7016 finishCheck.CheckSignalReceived();
7017 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
7021 int UtcDaliAnimationMoveByVector3AlphaFloat2(void)
7023 TestApplication application;
7025 Actor actor = Actor::New();
7026 Vector3 startPosition(10.0f, 10.0f, 10.0f);
7027 actor.SetPosition(startPosition);
7028 Stage::GetCurrent().Add(actor);
7029 application.SendNotification();
7030 application.Render(0);
7031 DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION );
7033 // Build the animation
7034 float durationSeconds(1.0f);
7035 Animation animation = Animation::New(durationSeconds);
7036 Vector3 targetPosition(20.0f, 20.0f, 20.0f);
7037 Vector3 relativePosition(targetPosition - startPosition);
7039 animation.MoveBy(actor, relativePosition, AlphaFunctions::Linear, delay, durationSeconds - delay);
7041 Vector3 ninetyFivePercentProgress(startPosition + relativePosition*0.95f);
7043 // Start the animation
7046 bool signalReceived(false);
7047 AnimationFinishCheck finishCheck(signalReceived);
7048 animation.FinishedSignal().Connect(&application, finishCheck);
7050 application.SendNotification();
7051 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
7053 // We didn't expect the animation to finish yet
7054 application.SendNotification();
7055 finishCheck.CheckSignalNotReceived();
7056 DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION );
7058 application.SendNotification();
7059 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
7061 // We did expect the animation to finish
7062 application.SendNotification();
7063 finishCheck.CheckSignalReceived();
7064 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
7068 int UtcDaliAnimationMoveToFloat3(void)
7070 TestApplication application;
7072 Actor actor = Actor::New();
7073 Stage::GetCurrent().Add(actor);
7074 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
7076 // Build the animation
7077 float durationSeconds(1.0f);
7078 Animation animation = Animation::New(durationSeconds);
7079 Vector3 targetPosition(200.0f, 200.0f, 200.0f);
7080 animation.MoveTo(actor, targetPosition.x, targetPosition.y, targetPosition.z);
7082 Vector3 seventyFivePercentProgress(targetPosition * 0.75f);
7084 // Start the animation
7087 bool signalReceived(false);
7088 AnimationFinishCheck finishCheck(signalReceived);
7089 animation.FinishedSignal().Connect(&application, finishCheck);
7091 application.SendNotification();
7092 application.Render(static_cast<unsigned int>(durationSeconds*750.0f)/* 75% progress */);
7094 // We didn't expect the animation to finish yet
7095 application.SendNotification();
7096 finishCheck.CheckSignalNotReceived();
7097 DALI_TEST_EQUALS( actor.GetCurrentPosition(), seventyFivePercentProgress, TEST_LOCATION );
7099 application.SendNotification();
7100 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7102 // We did expect the animation to finish
7103 application.SendNotification();
7104 finishCheck.CheckSignalReceived();
7105 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
7109 int UtcDaliAnimationMoveToVector3Alpha(void)
7111 TestApplication application;
7113 Actor actor = Actor::New();
7114 Stage::GetCurrent().Add(actor);
7115 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
7117 // Build the animation
7118 float durationSeconds(1.0f);
7119 Animation animation = Animation::New(durationSeconds);
7120 Vector3 targetPosition(200.0f, 200.0f, 200.0f);
7121 animation.MoveTo(actor, targetPosition, AlphaFunctions::EaseIn);
7123 Vector3 seventyFivePercentProgress(targetPosition * 0.75f);
7125 // Start the animation
7128 bool signalReceived(false);
7129 AnimationFinishCheck finishCheck(signalReceived);
7130 animation.FinishedSignal().Connect(&application, finishCheck);
7132 application.SendNotification();
7133 application.Render(static_cast<unsigned int>(durationSeconds*750.0f)/* 75% progress */);
7135 // We didn't expect the animation to finish yet
7136 application.SendNotification();
7137 finishCheck.CheckSignalNotReceived();
7139 // The position should have moved less, than with a linear alpha function
7140 Vector3 current(actor.GetCurrentPosition());
7141 DALI_TEST_CHECK( current.x > Vector3::ZERO.x );
7142 DALI_TEST_CHECK( current.y > Vector3::ZERO.y );
7143 DALI_TEST_CHECK( current.z > Vector3::ZERO.z );
7144 DALI_TEST_CHECK( current.x < seventyFivePercentProgress.x );
7145 DALI_TEST_CHECK( current.y < seventyFivePercentProgress.y );
7146 DALI_TEST_CHECK( current.z < seventyFivePercentProgress.z );
7148 application.SendNotification();
7149 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7151 // We did expect the animation to finish
7152 application.SendNotification();
7153 finishCheck.CheckSignalReceived();
7154 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
7158 int UtcDaliAnimationMoveToVector3AlphaFloat2(void)
7160 TestApplication application;
7162 Actor actor = Actor::New();
7163 Stage::GetCurrent().Add(actor);
7164 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
7166 // Build the animation
7167 float durationSeconds(1.0f);
7168 Animation animation = Animation::New(durationSeconds);
7169 Vector3 targetPosition(200.0f, 200.0f, 200.0f);
7171 animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear, delay, durationSeconds - delay);
7173 Vector3 seventyFivePercentProgress(targetPosition * 0.75f);
7175 // Start the animation
7178 bool signalReceived(false);
7179 AnimationFinishCheck finishCheck(signalReceived);
7180 animation.FinishedSignal().Connect(&application, finishCheck);
7182 application.SendNotification();
7183 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
7185 // We didn't expect the animation to finish yet
7186 application.SendNotification();
7187 finishCheck.CheckSignalNotReceived();
7188 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
7190 application.SendNotification();
7191 application.Render(static_cast<unsigned int>(durationSeconds*500.0f*0.75)/* 7/8 animation progress, 3/4 animator progress */);
7193 // We didn't expect the animation to finish yet
7194 application.SendNotification();
7195 finishCheck.CheckSignalNotReceived();
7196 DALI_TEST_EQUALS( actor.GetCurrentPosition(), seventyFivePercentProgress, TEST_LOCATION );
7198 application.SendNotification();
7199 application.Render(static_cast<unsigned int>(durationSeconds*500.0f*0.25) + 1u/*just beyond the animation duration*/);
7201 // We did expect the animation to finish
7202 application.SendNotification();
7203 finishCheck.CheckSignalReceived();
7204 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
7208 int UtcDaliAnimationMove(void)
7210 TestApplication application;
7212 Actor actor = Actor::New();
7213 Vector3 initialPosition(Vector3::ZERO);
7214 DALI_TEST_EQUALS( actor.GetCurrentPosition(), initialPosition, TEST_LOCATION );
7215 Stage::GetCurrent().Add(actor);
7217 // Build the animation
7218 float durationSeconds(10.0f);
7219 Animation animation = Animation::New(durationSeconds);
7220 Vector3 targetPosition(200.0f, 200.0f, 200.0f);
7221 BounceFunc func(0.0f, 0.0f, -100.0f);
7222 animation.Move(actor, func, AlphaFunctions::Linear, 0.0f, durationSeconds);
7224 // Start the animation
7227 bool signalReceived(false);
7228 AnimationFinishCheck finishCheck(signalReceived);
7229 animation.FinishedSignal().Connect(&application, finishCheck);
7231 application.SendNotification();
7232 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7234 // We didn't expect the animation to finish yet
7235 application.SendNotification();
7236 finishCheck.CheckSignalNotReceived();
7237 DALI_TEST_EQUALS( actor.GetCurrentPosition(), func(0.25f, initialPosition), TEST_LOCATION );
7239 application.SendNotification();
7240 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7242 // We didn't expect the animation to finish yet
7243 application.SendNotification();
7244 finishCheck.CheckSignalNotReceived();
7245 DALI_TEST_EQUALS( actor.GetCurrentPosition(), func(0.5f, initialPosition), TEST_LOCATION );
7247 application.SendNotification();
7248 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7250 // We didn't expect the animation to finish yet
7251 application.SendNotification();
7252 finishCheck.CheckSignalNotReceived();
7253 DALI_TEST_EQUALS( actor.GetCurrentPosition(), func(0.75f, initialPosition), TEST_LOCATION );
7255 application.SendNotification();
7256 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7258 // We did expect the animation to finish
7259 application.SendNotification();
7260 finishCheck.CheckSignalReceived();
7261 DALI_TEST_EQUALS( actor.GetCurrentPosition(), initialPosition, TEST_LOCATION );
7265 int UtcDaliAnimationRotateByDegreeVector3(void)
7267 TestApplication application;
7269 Actor actor = Actor::New();
7270 actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
7271 Stage::GetCurrent().Add(actor);
7272 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7274 // Build the animation
7275 float durationSeconds(1.0f);
7276 Animation animation = Animation::New(durationSeconds);
7277 Degree relativeRotationDegrees(360.0f);
7278 Radian relativeRotationRadians(relativeRotationDegrees);
7279 animation.RotateBy(actor, relativeRotationDegrees/*Degree version*/, Vector3::YAXIS);
7281 // Start the animation
7284 bool signalReceived(false);
7285 AnimationFinishCheck finishCheck(signalReceived);
7286 animation.FinishedSignal().Connect(&application, finishCheck);
7288 application.SendNotification();
7289 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7291 // We didn't expect the animation to finish yet
7292 application.SendNotification();
7293 finishCheck.CheckSignalNotReceived();
7294 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * 0.25f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7296 application.SendNotification();
7297 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7299 // We didn't expect the animation to finish yet
7300 application.SendNotification();
7301 finishCheck.CheckSignalNotReceived();
7302 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * 0.5f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7304 application.SendNotification();
7305 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7307 // We didn't expect the animation to finish yet
7308 application.SendNotification();
7309 finishCheck.CheckSignalNotReceived();
7310 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * 0.75f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7312 application.SendNotification();
7313 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7315 // We did expect the animation to finish
7316 application.SendNotification();
7317 finishCheck.CheckSignalReceived();
7318 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7322 int UtcDaliAnimationRotateByRadianVector3(void)
7324 TestApplication application;
7326 Actor actor = Actor::New();
7327 actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
7328 Stage::GetCurrent().Add(actor);
7329 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7331 // Build the animation
7332 float durationSeconds(1.0f);
7333 Animation animation = Animation::New(durationSeconds);
7334 Degree relativeRotationDegrees(360.0f);
7335 Radian relativeRotationRadians(relativeRotationDegrees);
7336 animation.RotateBy(actor, relativeRotationRadians/*Radian version*/, Vector3::YAXIS);
7338 // Start the animation
7341 bool signalReceived(false);
7342 AnimationFinishCheck finishCheck(signalReceived);
7343 animation.FinishedSignal().Connect(&application, finishCheck);
7345 application.SendNotification();
7346 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7348 // We didn't expect the animation to finish yet
7349 application.SendNotification();
7350 finishCheck.CheckSignalNotReceived();
7351 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * 0.25f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7353 application.SendNotification();
7354 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7356 // We didn't expect the animation to finish yet
7357 application.SendNotification();
7358 finishCheck.CheckSignalNotReceived();
7359 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * 0.5f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7361 application.SendNotification();
7362 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7364 // We didn't expect the animation to finish yet
7365 application.SendNotification();
7366 finishCheck.CheckSignalNotReceived();
7367 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * 0.75f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7369 application.SendNotification();
7370 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7372 // We did expect the animation to finish
7373 application.SendNotification();
7374 finishCheck.CheckSignalReceived();
7375 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7379 int UtcDaliAnimationRotateByDegreeVector3Alpha(void)
7381 TestApplication application;
7383 Actor actor = Actor::New();
7384 actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
7385 Stage::GetCurrent().Add(actor);
7386 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7388 // Build the animation
7389 float durationSeconds(1.0f);
7390 Animation animation = Animation::New(durationSeconds);
7391 Degree relativeRotationDegrees(360.0f);
7392 Radian relativeRotationRadians(relativeRotationDegrees);
7393 animation.RotateBy(actor, relativeRotationDegrees/*Degree version*/, Vector3::YAXIS, AlphaFunctions::EaseIn);
7395 // Start the animation
7398 bool signalReceived(false);
7399 AnimationFinishCheck finishCheck(signalReceived);
7400 animation.FinishedSignal().Connect(&application, finishCheck);
7402 application.SendNotification();
7403 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7405 // We didn't expect the animation to finish yet
7406 application.SendNotification();
7407 finishCheck.CheckSignalNotReceived();
7408 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * AlphaFunctions::EaseIn(0.25f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7410 application.SendNotification();
7411 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7413 // We didn't expect the animation to finish yet
7414 application.SendNotification();
7415 finishCheck.CheckSignalNotReceived();
7416 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * AlphaFunctions::EaseIn(0.5f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7418 application.SendNotification();
7419 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7421 // We didn't expect the animation to finish yet
7422 application.SendNotification();
7423 finishCheck.CheckSignalNotReceived();
7424 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * AlphaFunctions::EaseIn(0.75f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7426 application.SendNotification();
7427 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7429 // We did expect the animation to finish
7430 application.SendNotification();
7431 finishCheck.CheckSignalReceived();
7432 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7436 int UtcDaliAnimationRotateByRadianVector3Alpha(void)
7438 TestApplication application;
7440 Actor actor = Actor::New();
7441 actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
7442 Stage::GetCurrent().Add(actor);
7443 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7445 // Build the animation
7446 float durationSeconds(1.0f);
7447 Animation animation = Animation::New(durationSeconds);
7448 Degree relativeRotationDegrees(360.0f);
7449 Radian relativeRotationRadians(relativeRotationDegrees);
7450 animation.RotateBy(actor, relativeRotationRadians/*Radian version*/, Vector3::YAXIS, AlphaFunctions::EaseIn);
7452 // Start the animation
7455 bool signalReceived(false);
7456 AnimationFinishCheck finishCheck(signalReceived);
7457 animation.FinishedSignal().Connect(&application, finishCheck);
7459 application.SendNotification();
7460 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7462 // We didn't expect the animation to finish yet
7463 application.SendNotification();
7464 finishCheck.CheckSignalNotReceived();
7465 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * AlphaFunctions::EaseIn(0.25f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7467 application.SendNotification();
7468 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7470 // We didn't expect the animation to finish yet
7471 application.SendNotification();
7472 finishCheck.CheckSignalNotReceived();
7473 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * AlphaFunctions::EaseIn(0.5f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7475 application.SendNotification();
7476 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7478 // We didn't expect the animation to finish yet
7479 application.SendNotification();
7480 finishCheck.CheckSignalNotReceived();
7481 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * AlphaFunctions::EaseIn(0.75f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7483 application.SendNotification();
7484 application.Render(static_cast<unsigned int>(durationSeconds*250.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.GetCurrentRotation(), Quaternion(relativeRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7493 int UtcDaliAnimationRotateByDegreeVector3AlphaFloat2(void)
7495 TestApplication application;
7497 Actor actor = Actor::New();
7498 actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
7499 Stage::GetCurrent().Add(actor);
7500 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7502 // Build the animation
7503 float durationSeconds(1.0f);
7504 Animation animation = Animation::New(durationSeconds);
7505 Degree relativeRotationDegrees(360.0f);
7506 Radian relativeRotationRadians(relativeRotationDegrees);
7508 animation.RotateBy(actor, relativeRotationDegrees/*Degree version*/, Vector3::YAXIS, AlphaFunctions::EaseIn, delay, durationSeconds - delay);
7510 // Start the animation
7513 bool signalReceived(false);
7514 AnimationFinishCheck finishCheck(signalReceived);
7515 animation.FinishedSignal().Connect(&application, finishCheck);
7517 application.SendNotification();
7518 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7520 // We didn't expect the animation to finish yet
7521 application.SendNotification();
7522 finishCheck.CheckSignalNotReceived();
7523 float progress = max(0.0f, 0.25f - delay) / (1.0f - delay);
7524 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7526 application.SendNotification();
7527 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7529 // We didn't expect the animation to finish yet
7530 application.SendNotification();
7531 finishCheck.CheckSignalNotReceived();
7532 progress = max(0.0f, 0.5f - delay) / (1.0f - delay);
7533 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7535 application.SendNotification();
7536 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7538 // We didn't expect the animation to finish yet
7539 application.SendNotification();
7540 finishCheck.CheckSignalNotReceived();
7541 progress = max(0.0f, 0.75f - delay) / (1.0f - delay);
7542 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7544 application.SendNotification();
7545 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7547 // We did expect the animation to finish
7548 application.SendNotification();
7549 finishCheck.CheckSignalReceived();
7550 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7555 int UtcDaliAnimationRotateByRadianVector3AlphaFloat2(void)
7557 TestApplication application;
7559 Actor actor = Actor::New();
7560 actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
7561 Stage::GetCurrent().Add(actor);
7562 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7564 // Build the animation
7565 float durationSeconds(1.0f);
7566 Animation animation = Animation::New(durationSeconds);
7567 Degree relativeRotationDegrees(360.0f);
7568 Radian relativeRotationRadians(relativeRotationDegrees);
7570 animation.RotateBy(actor, relativeRotationRadians/*Radian version*/, Vector3::YAXIS, AlphaFunctions::EaseIn, delay, durationSeconds - delay);
7572 // Start the animation
7575 bool signalReceived(false);
7576 AnimationFinishCheck finishCheck(signalReceived);
7577 animation.FinishedSignal().Connect(&application, finishCheck);
7579 application.SendNotification();
7580 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7582 // We didn't expect the animation to finish yet
7583 application.SendNotification();
7584 finishCheck.CheckSignalNotReceived();
7585 float progress = max(0.0f, 0.25f - delay) / (1.0f - delay);
7586 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7588 application.SendNotification();
7589 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7591 // We didn't expect the animation to finish yet
7592 application.SendNotification();
7593 finishCheck.CheckSignalNotReceived();
7594 progress = max(0.0f, 0.5f - delay) / (1.0f - delay);
7595 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7597 application.SendNotification();
7598 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7600 // We didn't expect the animation to finish yet
7601 application.SendNotification();
7602 finishCheck.CheckSignalNotReceived();
7603 progress = max(0.0f, 0.75f - delay) / (1.0f - delay);
7604 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7606 application.SendNotification();
7607 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7609 // We did expect the animation to finish
7610 application.SendNotification();
7611 finishCheck.CheckSignalReceived();
7612 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7616 int UtcDaliAnimationRotateToDegreeVector3(void)
7618 TestApplication application;
7620 Actor actor = Actor::New();
7621 actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
7622 Stage::GetCurrent().Add(actor);
7623 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7625 // Build the animation
7626 float durationSeconds(1.0f);
7627 Animation animation = Animation::New(durationSeconds);
7628 Degree targetRotationDegrees(90.0f);
7629 Radian targetRotationRadians(targetRotationDegrees);
7630 animation.RotateTo(actor, targetRotationDegrees/*Degree version*/, Vector3::YAXIS);
7632 // Start the animation
7635 bool signalReceived(false);
7636 AnimationFinishCheck finishCheck(signalReceived);
7637 animation.FinishedSignal().Connect(&application, finishCheck);
7639 application.SendNotification();
7640 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7642 // We didn't expect the animation to finish yet
7643 application.SendNotification();
7644 finishCheck.CheckSignalNotReceived();
7645 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.25f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7647 application.SendNotification();
7648 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7650 // We didn't expect the animation to finish yet
7651 application.SendNotification();
7652 finishCheck.CheckSignalNotReceived();
7653 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.5f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7655 application.SendNotification();
7656 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7658 // We didn't expect the animation to finish yet
7659 application.SendNotification();
7660 finishCheck.CheckSignalNotReceived();
7661 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.75f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7663 application.SendNotification();
7664 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7666 // We did expect the animation to finish
7667 application.SendNotification();
7668 finishCheck.CheckSignalReceived();
7669 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7673 int UtcDaliAnimationRotateToRadianVector3(void)
7675 TestApplication application;
7677 Actor actor = Actor::New();
7678 actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
7679 Stage::GetCurrent().Add(actor);
7680 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7682 // Build the animation
7683 float durationSeconds(1.0f);
7684 Animation animation = Animation::New(durationSeconds);
7685 Degree targetRotationDegrees(90.0f);
7686 Radian targetRotationRadians(targetRotationDegrees);
7687 animation.RotateTo(actor, targetRotationRadians/*Radian version*/, Vector3::YAXIS);
7689 // Start the animation
7692 bool signalReceived(false);
7693 AnimationFinishCheck finishCheck(signalReceived);
7694 animation.FinishedSignal().Connect(&application, finishCheck);
7696 application.SendNotification();
7697 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7699 // We didn't expect the animation to finish yet
7700 application.SendNotification();
7701 finishCheck.CheckSignalNotReceived();
7702 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.25f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7704 application.SendNotification();
7705 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7707 // We didn't expect the animation to finish yet
7708 application.SendNotification();
7709 finishCheck.CheckSignalNotReceived();
7710 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.5f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7712 application.SendNotification();
7713 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7715 // We didn't expect the animation to finish yet
7716 application.SendNotification();
7717 finishCheck.CheckSignalNotReceived();
7718 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.75f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7720 application.SendNotification();
7721 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7723 // We did expect the animation to finish
7724 application.SendNotification();
7725 finishCheck.CheckSignalReceived();
7726 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7730 int UtcDaliAnimationRotateToQuaternion(void)
7732 TestApplication application;
7734 Actor actor = Actor::New();
7735 actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
7736 Stage::GetCurrent().Add(actor);
7737 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7739 // Build the animation
7740 float durationSeconds(1.0f);
7741 Animation animation = Animation::New(durationSeconds);
7742 Degree targetRotationDegrees(90.0f);
7743 Radian targetRotationRadians(targetRotationDegrees);
7744 Quaternion targetRotation(targetRotationRadians, Vector3::YAXIS);
7745 animation.RotateTo(actor, targetRotation/*Quaternion version*/);
7747 // Start the animation
7750 bool signalReceived(false);
7751 AnimationFinishCheck finishCheck(signalReceived);
7752 animation.FinishedSignal().Connect(&application, finishCheck);
7754 application.SendNotification();
7755 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7757 // We didn't expect the animation to finish yet
7758 application.SendNotification();
7759 finishCheck.CheckSignalNotReceived();
7760 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.25f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7762 application.SendNotification();
7763 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7765 // We didn't expect the animation to finish yet
7766 application.SendNotification();
7767 finishCheck.CheckSignalNotReceived();
7768 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.5f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7770 application.SendNotification();
7771 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7773 // We didn't expect the animation to finish yet
7774 application.SendNotification();
7775 finishCheck.CheckSignalNotReceived();
7776 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.75f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7778 application.SendNotification();
7779 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7781 // We did expect the animation to finish
7782 application.SendNotification();
7783 finishCheck.CheckSignalReceived();
7784 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7788 int UtcDaliAnimationRotateToDegreeVector3Alpha(void)
7790 TestApplication application;
7792 Actor actor = Actor::New();
7793 actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
7794 Stage::GetCurrent().Add(actor);
7795 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7797 // Build the animation
7798 float durationSeconds(1.0f);
7799 Animation animation = Animation::New(durationSeconds);
7800 Degree targetRotationDegrees(90.0f);
7801 Radian targetRotationRadians(targetRotationDegrees);
7802 animation.RotateTo(actor, targetRotationDegrees/*Degree version*/, Vector3::YAXIS, AlphaFunctions::EaseIn);
7804 // Start the animation
7807 bool signalReceived(false);
7808 AnimationFinishCheck finishCheck(signalReceived);
7809 animation.FinishedSignal().Connect(&application, finishCheck);
7811 application.SendNotification();
7812 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7814 // We didn't expect the animation to finish yet
7815 application.SendNotification();
7816 finishCheck.CheckSignalNotReceived();
7817 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(0.25f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7819 application.SendNotification();
7820 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7822 // We didn't expect the animation to finish yet
7823 application.SendNotification();
7824 finishCheck.CheckSignalNotReceived();
7825 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(0.5f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7827 application.SendNotification();
7828 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7830 // We didn't expect the animation to finish yet
7831 application.SendNotification();
7832 finishCheck.CheckSignalNotReceived();
7833 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(0.75f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7835 application.SendNotification();
7836 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7838 // We did expect the animation to finish
7839 application.SendNotification();
7840 finishCheck.CheckSignalReceived();
7841 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7845 int UtcDaliAnimationRotateToRadianVector3Alpha(void)
7847 TestApplication application;
7849 Actor actor = Actor::New();
7850 actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
7851 Stage::GetCurrent().Add(actor);
7852 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7854 // Build the animation
7855 float durationSeconds(1.0f);
7856 Animation animation = Animation::New(durationSeconds);
7857 Degree targetRotationDegrees(90.0f);
7858 Radian targetRotationRadians(targetRotationDegrees);
7859 animation.RotateTo(actor, targetRotationRadians/*Radian version*/, Vector3::YAXIS, AlphaFunctions::EaseIn);
7861 // Start the animation
7864 bool signalReceived(false);
7865 AnimationFinishCheck finishCheck(signalReceived);
7866 animation.FinishedSignal().Connect(&application, finishCheck);
7868 application.SendNotification();
7869 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7871 // We didn't expect the animation to finish yet
7872 application.SendNotification();
7873 finishCheck.CheckSignalNotReceived();
7874 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(0.25f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7876 application.SendNotification();
7877 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7879 // We didn't expect the animation to finish yet
7880 application.SendNotification();
7881 finishCheck.CheckSignalNotReceived();
7882 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(0.5f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7884 application.SendNotification();
7885 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7887 // We didn't expect the animation to finish yet
7888 application.SendNotification();
7889 finishCheck.CheckSignalNotReceived();
7890 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(0.75f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7892 application.SendNotification();
7893 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7895 // We did expect the animation to finish
7896 application.SendNotification();
7897 finishCheck.CheckSignalReceived();
7898 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7902 int UtcDaliAnimationRotateToQuaternionAlpha(void)
7904 TestApplication application;
7906 Actor actor = Actor::New();
7907 actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
7908 Stage::GetCurrent().Add(actor);
7909 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7911 // Build the animation
7912 float durationSeconds(1.0f);
7913 Animation animation = Animation::New(durationSeconds);
7914 Degree targetRotationDegrees(90.0f);
7915 Radian targetRotationRadians(targetRotationDegrees);
7916 Quaternion targetRotation(targetRotationRadians, Vector3::YAXIS);
7917 animation.RotateTo(actor, targetRotation/*Quaternion version*/, AlphaFunctions::EaseIn);
7919 // Start the animation
7922 bool signalReceived(false);
7923 AnimationFinishCheck finishCheck(signalReceived);
7924 animation.FinishedSignal().Connect(&application, finishCheck);
7926 application.SendNotification();
7927 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7929 // We didn't expect the animation to finish yet
7930 application.SendNotification();
7931 finishCheck.CheckSignalNotReceived();
7932 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(0.25f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7934 application.SendNotification();
7935 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7937 // We didn't expect the animation to finish yet
7938 application.SendNotification();
7939 finishCheck.CheckSignalNotReceived();
7940 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(0.5f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7942 application.SendNotification();
7943 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7945 // We didn't expect the animation to finish yet
7946 application.SendNotification();
7947 finishCheck.CheckSignalNotReceived();
7948 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(0.75f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7950 application.SendNotification();
7951 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7953 // We did expect the animation to finish
7954 application.SendNotification();
7955 finishCheck.CheckSignalReceived();
7956 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7960 int UtcDaliAnimationRotateToDegreeVector3AlphaFloat2(void)
7962 TestApplication application;
7964 Actor actor = Actor::New();
7965 actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
7966 Stage::GetCurrent().Add(actor);
7967 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7969 // Build the animation
7970 float durationSeconds(1.0f);
7971 Animation animation = Animation::New(durationSeconds);
7972 Degree targetRotationDegrees(90.0f);
7973 Radian targetRotationRadians(targetRotationDegrees);
7975 animation.RotateTo(actor, targetRotationDegrees/*Degree version*/, Vector3::YAXIS, AlphaFunctions::EaseIn, delay, durationSeconds - delay);
7977 // Start the animation
7980 bool signalReceived(false);
7981 AnimationFinishCheck finishCheck(signalReceived);
7982 animation.FinishedSignal().Connect(&application, finishCheck);
7984 application.SendNotification();
7985 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7987 // We didn't expect the animation to finish yet
7988 application.SendNotification();
7989 finishCheck.CheckSignalNotReceived();
7990 float progress = max(0.0f, 0.25f - delay) / (1.0f - delay);
7991 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7993 application.SendNotification();
7994 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7996 // We didn't expect the animation to finish yet
7997 application.SendNotification();
7998 finishCheck.CheckSignalNotReceived();
7999 progress = max(0.0f, 0.5f - delay) / (1.0f - delay);
8000 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
8002 application.SendNotification();
8003 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
8005 // We didn't expect the animation to finish yet
8006 application.SendNotification();
8007 finishCheck.CheckSignalNotReceived();
8008 progress = max(0.0f, 0.75f - delay) / (1.0f - delay);
8009 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
8011 application.SendNotification();
8012 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
8014 // We did expect the animation to finish
8015 application.SendNotification();
8016 finishCheck.CheckSignalReceived();
8017 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
8021 int UtcDaliAnimationRotateToRadianVector3AlphaFloat2(void)
8023 TestApplication application;
8025 Actor actor = Actor::New();
8026 actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
8027 Stage::GetCurrent().Add(actor);
8028 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
8030 // Build the animation
8031 float durationSeconds(1.0f);
8032 Animation animation = Animation::New(durationSeconds);
8033 Degree targetRotationDegrees(90.0f);
8034 Radian targetRotationRadians(targetRotationDegrees);
8036 animation.RotateTo(actor, targetRotationRadians/*Radian version*/, Vector3::YAXIS, AlphaFunctions::EaseIn, delay, durationSeconds - delay);
8038 // Start the animation
8041 bool signalReceived(false);
8042 AnimationFinishCheck finishCheck(signalReceived);
8043 animation.FinishedSignal().Connect(&application, finishCheck);
8045 application.SendNotification();
8046 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
8048 // We didn't expect the animation to finish yet
8049 application.SendNotification();
8050 finishCheck.CheckSignalNotReceived();
8051 float progress = max(0.0f, 0.25f - delay) / (1.0f - delay);
8052 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
8054 application.SendNotification();
8055 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
8057 // We didn't expect the animation to finish yet
8058 application.SendNotification();
8059 finishCheck.CheckSignalNotReceived();
8060 progress = max(0.0f, 0.5f - delay) / (1.0f - delay);
8061 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
8063 application.SendNotification();
8064 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
8066 // We didn't expect the animation to finish yet
8067 application.SendNotification();
8068 finishCheck.CheckSignalNotReceived();
8069 progress = max(0.0f, 0.75f - delay) / (1.0f - delay);
8070 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
8072 application.SendNotification();
8073 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
8075 // We did expect the animation to finish
8076 application.SendNotification();
8077 finishCheck.CheckSignalReceived();
8078 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
8082 int UtcDaliAnimationRotateToQuaternionAlphaFloat2(void)
8084 TestApplication application;
8086 Actor actor = Actor::New();
8087 actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
8088 Stage::GetCurrent().Add(actor);
8089 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
8091 // Build the animation
8092 float durationSeconds(1.0f);
8093 Animation animation = Animation::New(durationSeconds);
8094 Degree targetRotationDegrees(90.0f);
8095 Radian targetRotationRadians(targetRotationDegrees);
8097 Quaternion targetRotation(targetRotationRadians, Vector3::YAXIS);
8098 animation.RotateTo(actor, targetRotation/*Quaternion version*/, AlphaFunctions::EaseIn, delay, durationSeconds - delay);
8100 // Start the animation
8103 bool signalReceived(false);
8104 AnimationFinishCheck finishCheck(signalReceived);
8105 animation.FinishedSignal().Connect(&application, finishCheck);
8107 application.SendNotification();
8108 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
8110 // We didn't expect the animation to finish yet
8111 application.SendNotification();
8112 finishCheck.CheckSignalNotReceived();
8113 float progress = max(0.0f, 0.25f - delay) / (1.0f - delay);
8114 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
8116 application.SendNotification();
8117 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
8119 // We didn't expect the animation to finish yet
8120 application.SendNotification();
8121 finishCheck.CheckSignalNotReceived();
8122 progress = max(0.0f, 0.5f - delay) / (1.0f - delay);
8123 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
8125 application.SendNotification();
8126 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
8128 // We didn't expect the animation to finish yet
8129 application.SendNotification();
8130 finishCheck.CheckSignalNotReceived();
8131 progress = max(0.0f, 0.75f - delay) / (1.0f - delay);
8132 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
8134 application.SendNotification();
8135 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
8137 // We did expect the animation to finish
8138 application.SendNotification();
8139 finishCheck.CheckSignalReceived();
8140 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
8144 int UtcDaliAnimationRotate(void)
8146 TestApplication application;
8148 Actor actor = Actor::New();
8149 Quaternion initialRotation(0.0f, Vector3::YAXIS);
8150 actor.SetRotation(initialRotation);
8151 Stage::GetCurrent().Add(actor);
8152 DALI_TEST_EQUALS( actor.GetCurrentRotation(), initialRotation, ROTATION_EPSILON, TEST_LOCATION );
8154 // Build the animation
8155 float durationSeconds(1.0f);
8156 Animation animation = Animation::New(durationSeconds);
8157 TumbleFunc func(Vector3::YAXIS);
8158 animation.Rotate(actor, func, AlphaFunctions::Linear, 0.0f, durationSeconds);
8160 // Start the animation
8163 bool signalReceived(false);
8164 AnimationFinishCheck finishCheck(signalReceived);
8165 animation.FinishedSignal().Connect(&application, finishCheck);
8167 application.SendNotification();
8168 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
8170 // We didn't expect the animation to finish yet
8171 application.SendNotification();
8172 finishCheck.CheckSignalNotReceived();
8173 DALI_TEST_EQUALS( actor.GetCurrentRotation(), func(0.25f, initialRotation), ROTATION_EPSILON, TEST_LOCATION );
8175 application.SendNotification();
8176 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
8178 // We didn't expect the animation to finish yet
8179 application.SendNotification();
8180 finishCheck.CheckSignalNotReceived();
8181 DALI_TEST_EQUALS( actor.GetCurrentRotation(), func(0.5f, initialRotation), ROTATION_EPSILON, TEST_LOCATION );
8183 application.SendNotification();
8184 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
8186 // We didn't expect the animation to finish yet
8187 application.SendNotification();
8188 finishCheck.CheckSignalNotReceived();
8189 DALI_TEST_EQUALS( actor.GetCurrentRotation(), func(0.75f, initialRotation), ROTATION_EPSILON, TEST_LOCATION );
8191 application.SendNotification();
8192 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
8194 // We did expect the animation to finish
8195 application.SendNotification();
8196 finishCheck.CheckSignalReceived();
8197 DALI_TEST_EQUALS( actor.GetCurrentRotation(), func(1.0f, initialRotation), ROTATION_EPSILON, TEST_LOCATION );
8201 int UtcDaliAnimationScaleBy(void)
8203 TestApplication application;
8205 Actor actor = Actor::New();
8206 Stage::GetCurrent().Add(actor);
8207 DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
8209 // Build the animation
8210 float durationSeconds(1.0f);
8211 Animation animation = Animation::New(durationSeconds);
8212 Vector3 targetScale(2.0f, 2.0f, 2.0f);
8213 Vector3 relativeScale(targetScale - Vector3::ONE);
8214 animation.ScaleBy(actor, relativeScale.x, relativeScale.y, relativeScale.z);
8216 Vector3 ninetyNinePercentProgress(Vector3::ONE + relativeScale*0.99f);
8218 // Start the animation
8221 bool signalReceived(false);
8222 AnimationFinishCheck finishCheck(signalReceived);
8223 animation.FinishedSignal().Connect(&application, finishCheck);
8225 application.SendNotification();
8226 application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
8228 // We didn't expect the animation to finish yet
8229 application.SendNotification();
8230 finishCheck.CheckSignalNotReceived();
8231 DALI_TEST_EQUALS( actor.GetCurrentScale(), ninetyNinePercentProgress, TEST_LOCATION );
8233 application.SendNotification();
8234 application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
8236 // We did expect the animation to finish
8237 application.SendNotification();
8238 finishCheck.CheckSignalReceived();
8239 DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
8242 finishCheck.Reset();
8243 actor.SetScale(Vector3::ONE);
8244 application.SendNotification();
8245 application.Render(0);
8246 DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
8248 // Repeat with a different (ease-in) alpha function
8249 animation = Animation::New(durationSeconds);
8250 animation.ScaleBy(actor, relativeScale, AlphaFunctions::EaseIn);
8251 animation.FinishedSignal().Connect(&application, finishCheck);
8254 application.SendNotification();
8255 application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
8257 // We didn't expect the animation to finish yet
8258 application.SendNotification();
8259 finishCheck.CheckSignalNotReceived();
8261 // The scale should have grown less, than with a linear alpha function
8262 Vector3 current(actor.GetCurrentScale());
8263 DALI_TEST_CHECK( current.x > 1.0f );
8264 DALI_TEST_CHECK( current.y > 1.0f );
8265 DALI_TEST_CHECK( current.z > 1.0f );
8266 DALI_TEST_CHECK( current.x < ninetyNinePercentProgress.x );
8267 DALI_TEST_CHECK( current.y < ninetyNinePercentProgress.y );
8268 DALI_TEST_CHECK( current.z < ninetyNinePercentProgress.z );
8270 application.SendNotification();
8271 application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
8273 // We did expect the animation to finish
8274 application.SendNotification();
8275 finishCheck.CheckSignalReceived();
8276 DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
8279 finishCheck.Reset();
8280 actor.SetScale(Vector3::ONE);
8281 application.SendNotification();
8282 application.Render(0);
8283 DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
8285 // Repeat with a delay
8287 animation = Animation::New(durationSeconds);
8288 animation.ScaleBy(actor, relativeScale, AlphaFunctions::Linear, delay, durationSeconds - delay);
8289 animation.FinishedSignal().Connect(&application, finishCheck);
8292 application.SendNotification();
8293 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
8295 // We didn't expect the animation to finish yet
8296 application.SendNotification();
8297 finishCheck.CheckSignalNotReceived();
8298 DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, 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.GetCurrentScale(), targetScale, TEST_LOCATION );
8310 int UtcDaliAnimationScaleTo(void)
8312 TestApplication application;
8314 Actor actor = Actor::New();
8315 Stage::GetCurrent().Add(actor);
8316 DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
8318 // Build the animation
8319 float durationSeconds(1.0f);
8320 Animation animation = Animation::New(durationSeconds);
8321 Vector3 targetScale(2.0f, 2.0f, 2.0f);
8322 animation.ScaleTo(actor, targetScale.x, targetScale.y, targetScale.z);
8324 Vector3 ninetyNinePercentProgress(Vector3::ONE + (targetScale - Vector3::ONE)*0.99f);
8326 // Start the animation
8329 bool signalReceived(false);
8330 AnimationFinishCheck finishCheck(signalReceived);
8331 animation.FinishedSignal().Connect(&application, finishCheck);
8333 application.SendNotification();
8334 application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
8336 // We didn't expect the animation to finish yet
8337 application.SendNotification();
8338 finishCheck.CheckSignalNotReceived();
8339 DALI_TEST_EQUALS( actor.GetCurrentScale(), ninetyNinePercentProgress, TEST_LOCATION );
8341 application.SendNotification();
8342 application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
8344 // We did expect the animation to finish
8345 application.SendNotification();
8346 finishCheck.CheckSignalReceived();
8347 DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
8350 finishCheck.Reset();
8351 actor.SetScale(Vector3::ONE);
8352 application.SendNotification();
8353 application.Render(0);
8354 DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
8356 // Repeat with a different (ease-in) alpha function
8357 animation = Animation::New(durationSeconds);
8358 animation.ScaleTo(actor, targetScale, AlphaFunctions::EaseIn);
8359 animation.FinishedSignal().Connect(&application, finishCheck);
8362 application.SendNotification();
8363 application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
8365 // We didn't expect the animation to finish yet
8366 application.SendNotification();
8367 finishCheck.CheckSignalNotReceived();
8369 // The scale should have grown less, than with a linear alpha function
8370 Vector3 current(actor.GetCurrentScale());
8371 DALI_TEST_CHECK( current.x > 1.0f );
8372 DALI_TEST_CHECK( current.y > 1.0f );
8373 DALI_TEST_CHECK( current.z > 1.0f );
8374 DALI_TEST_CHECK( current.x < ninetyNinePercentProgress.x );
8375 DALI_TEST_CHECK( current.y < ninetyNinePercentProgress.y );
8376 DALI_TEST_CHECK( current.z < ninetyNinePercentProgress.z );
8378 application.SendNotification();
8379 application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
8381 // We did expect the animation to finish
8382 application.SendNotification();
8383 finishCheck.CheckSignalReceived();
8384 DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
8387 finishCheck.Reset();
8388 actor.SetScale(Vector3::ONE);
8389 application.SendNotification();
8390 application.Render(0);
8391 DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
8393 // Repeat with a delay
8395 animation = Animation::New(durationSeconds);
8396 animation.ScaleTo(actor, targetScale, AlphaFunctions::Linear, delay, durationSeconds - delay);
8397 animation.FinishedSignal().Connect(&application, finishCheck);
8400 application.SendNotification();
8401 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
8403 // We didn't expect the animation to finish yet
8404 application.SendNotification();
8405 finishCheck.CheckSignalNotReceived();
8406 DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
8408 application.SendNotification();
8409 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
8411 // We did expect the animation to finish
8412 application.SendNotification();
8413 finishCheck.CheckSignalReceived();
8414 DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
8418 int UtcDaliAnimationShow(void)
8420 TestApplication application;
8422 Actor actor = Actor::New();
8423 actor.SetVisible(false);
8424 application.SendNotification();
8425 application.Render(0);
8426 DALI_TEST_CHECK( !actor.IsVisible() );
8427 Stage::GetCurrent().Add(actor);
8429 // Start the animation
8430 float durationSeconds(10.0f);
8431 Animation animation = Animation::New(durationSeconds);
8432 animation.Show(actor, durationSeconds*0.5f);
8435 bool signalReceived(false);
8436 AnimationFinishCheck finishCheck(signalReceived);
8437 animation.FinishedSignal().Connect(&application, finishCheck);
8439 application.SendNotification();
8440 application.Render(static_cast<unsigned int>(durationSeconds*490.0f));
8442 // We didn't expect the animation to finish yet
8443 application.SendNotification();
8444 finishCheck.CheckSignalNotReceived();
8445 DALI_TEST_CHECK( !actor.IsVisible() );
8447 application.SendNotification();
8448 application.Render(static_cast<unsigned int>(durationSeconds*10.0f)/*Should be shown now*/);
8450 // We didn't expect the animation to finish yet
8451 application.SendNotification();
8452 finishCheck.CheckSignalNotReceived();
8453 DALI_TEST_CHECK( actor.IsVisible() );
8455 application.SendNotification();
8456 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
8458 // We did expect the animation to finish
8459 application.SendNotification();
8460 finishCheck.CheckSignalReceived();
8461 DALI_TEST_CHECK( actor.IsVisible() );
8465 int UtcDaliAnimationHide(void)
8467 TestApplication application;
8469 Actor actor = Actor::New();
8470 DALI_TEST_CHECK( actor.IsVisible() );
8471 Stage::GetCurrent().Add(actor);
8473 // Start the animation
8474 float durationSeconds(10.0f);
8475 Animation animation = Animation::New(durationSeconds);
8476 animation.Hide(actor, durationSeconds*0.5f);
8479 bool signalReceived(false);
8480 AnimationFinishCheck finishCheck(signalReceived);
8481 animation.FinishedSignal().Connect(&application, finishCheck);
8483 application.SendNotification();
8484 application.Render(static_cast<unsigned int>(durationSeconds*490.0f));
8486 // We didn't expect the animation to finish yet
8487 application.SendNotification();
8488 finishCheck.CheckSignalNotReceived();
8489 DALI_TEST_CHECK( actor.IsVisible() );
8491 application.SendNotification();
8492 application.Render(static_cast<unsigned int>(durationSeconds*10.0f)/*Should be hidden now*/);
8494 // We didn't expect the animation to finish yet
8495 application.SendNotification();
8496 finishCheck.CheckSignalNotReceived();
8497 DALI_TEST_CHECK( !actor.IsVisible() );
8499 application.SendNotification();
8500 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
8502 // We did expect the animation to finish
8503 application.SendNotification();
8504 finishCheck.CheckSignalReceived();
8505 DALI_TEST_CHECK( !actor.IsVisible() );
8509 int UtcDaliAnimationShowHideAtEnd(void)
8511 // Test that show/hide delay can be the same as animation duration
8512 // i.e. to show/hide at the end of the animation
8514 TestApplication application;
8516 Actor actor = Actor::New();
8517 DALI_TEST_CHECK( actor.IsVisible() );
8518 Stage::GetCurrent().Add(actor);
8520 // Start Hide animation
8521 float durationSeconds(10.0f);
8522 Animation animation = Animation::New(durationSeconds);
8523 animation.Hide(actor, durationSeconds/*Hide at end*/);
8526 bool signalReceived(false);
8527 AnimationFinishCheck finishCheck(signalReceived);
8528 animation.FinishedSignal().Connect(&application, finishCheck);
8530 application.SendNotification();
8531 application.Render(static_cast<unsigned int>(durationSeconds*1000.0f) + 1u/*just beyond the animation duration*/);
8533 // We did expect the animation to finish
8534 application.SendNotification();
8535 finishCheck.CheckSignalReceived();
8536 DALI_TEST_CHECK( !actor.IsVisible() );
8538 // Start Show animation
8539 animation = Animation::New(durationSeconds);
8540 animation.Show(actor, durationSeconds/*Show at end*/);
8541 animation.FinishedSignal().Connect(&application, finishCheck);
8544 application.SendNotification();
8545 application.Render(static_cast<unsigned int>(durationSeconds*1000.0f) + 1u/*just beyond the animation duration*/);
8547 // We did expect the animation to finish
8548 application.SendNotification();
8549 finishCheck.CheckSignalReceived();
8550 DALI_TEST_CHECK( actor.IsVisible() );
8554 int UtcDaliAnimationOpacityBy(void)
8556 TestApplication application;
8557 Actor actor = Actor::New();
8558 float startingOpacity(0.5f);
8559 actor.SetOpacity(startingOpacity);
8560 application.SendNotification();
8561 application.Render(0);
8562 DALI_TEST_EQUALS( actor.GetCurrentOpacity(), startingOpacity, TEST_LOCATION );
8563 Stage::GetCurrent().Add(actor);
8565 // Build the animation
8566 float durationSeconds(1.0f);
8567 Animation animation = Animation::New(durationSeconds);
8568 float relativeOpacity(-0.5f); // target of zero
8569 animation.OpacityBy(actor, relativeOpacity);
8571 float seventyFivePercentProgress((1.0f - 0.75f) * startingOpacity);
8573 // Start the animation
8576 bool signalReceived(false);
8577 AnimationFinishCheck finishCheck(signalReceived);
8578 animation.FinishedSignal().Connect(&application, finishCheck);
8580 application.SendNotification();
8581 application.Render(static_cast<unsigned int>(durationSeconds*750.0f)/* 75% progress */);
8583 // We didn't expect the animation to finish yet
8584 application.SendNotification();
8585 finishCheck.CheckSignalNotReceived();
8586 DALI_TEST_EQUALS( actor.GetCurrentOpacity(), seventyFivePercentProgress, TEST_LOCATION );
8588 application.SendNotification();
8589 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
8591 // We did expect the animation to finish
8592 application.SendNotification();
8593 finishCheck.CheckSignalReceived();
8594 DALI_TEST_EQUALS( actor.GetCurrentOpacity(), startingOpacity+relativeOpacity, TEST_LOCATION );
8597 finishCheck.Reset();
8598 actor.SetOpacity(startingOpacity);
8599 application.SendNotification();
8600 application.Render(0);
8601 DALI_TEST_EQUALS( actor.GetCurrentOpacity(), startingOpacity, TEST_LOCATION );
8603 // Repeat with a different (ease-in) alpha function
8604 animation = Animation::New(durationSeconds);
8605 animation.OpacityBy(actor, relativeOpacity, AlphaFunctions::EaseIn);
8606 animation.FinishedSignal().Connect(&application, finishCheck);
8609 application.SendNotification();
8610 application.Render(static_cast<unsigned int>(durationSeconds*750.0f)/* 75% progress */);
8612 // We didn't expect the animation to finish yet
8613 application.SendNotification();
8614 finishCheck.CheckSignalNotReceived();
8616 // The opacity should reduce less, than with a linear alpha function
8617 float current(actor.GetCurrentOpacity());
8618 DALI_TEST_CHECK( current < 1.0f );
8619 DALI_TEST_CHECK( current > seventyFivePercentProgress );
8621 application.SendNotification();
8622 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
8624 // We did expect the animation to finish
8625 application.SendNotification();
8626 finishCheck.CheckSignalReceived();
8627 DALI_TEST_EQUALS( actor.GetCurrentOpacity(), startingOpacity+relativeOpacity, TEST_LOCATION );
8630 finishCheck.Reset();
8631 actor.SetOpacity(startingOpacity);
8632 application.SendNotification();
8633 application.Render(0);
8634 DALI_TEST_EQUALS( actor.GetCurrentOpacity(), startingOpacity, TEST_LOCATION );
8636 // Repeat with a delay
8638 animation = Animation::New(durationSeconds);
8639 animation.OpacityBy(actor, relativeOpacity, AlphaFunctions::Linear, delay, durationSeconds - delay);
8640 animation.FinishedSignal().Connect(&application, finishCheck);
8643 application.SendNotification();
8644 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
8646 // We didn't expect the animation to finish yet
8647 application.SendNotification();
8648 finishCheck.CheckSignalNotReceived();
8649 DALI_TEST_EQUALS( actor.GetCurrentOpacity(), startingOpacity, TEST_LOCATION );
8651 application.SendNotification();
8652 application.Render(static_cast<unsigned int>(durationSeconds*500.0f*0.75)/* 7/8 animation progress, 3/4 animator progress */);
8654 // We didn't expect the animation to finish yet
8655 application.SendNotification();
8656 finishCheck.CheckSignalNotReceived();
8657 DALI_TEST_EQUALS( actor.GetCurrentOpacity(), seventyFivePercentProgress, TEST_LOCATION );
8659 application.SendNotification();
8660 application.Render(static_cast<unsigned int>(durationSeconds*500.0f*0.25) + 1u/*just beyond the animation duration*/);
8662 // We did expect the animation to finish
8663 application.SendNotification();
8664 finishCheck.CheckSignalReceived();
8665 DALI_TEST_EQUALS( actor.GetCurrentOpacity(), startingOpacity+relativeOpacity, TEST_LOCATION );
8669 int UtcDaliAnimationOpacityTo(void)
8671 TestApplication application;
8673 Actor actor = Actor::New();
8674 Stage::GetCurrent().Add(actor);
8675 DALI_TEST_EQUALS( actor.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
8677 // Build the animation
8678 float durationSeconds(1.0f);
8679 Animation animation = Animation::New(durationSeconds);
8680 float targetOpacity(0.0f);
8681 animation.OpacityTo(actor, targetOpacity);
8683 float ninetyNinePercentProgress(0.01f);
8685 // Start the animation
8688 bool signalReceived(false);
8689 AnimationFinishCheck finishCheck(signalReceived);
8690 animation.FinishedSignal().Connect(&application, finishCheck);
8692 application.SendNotification();
8693 application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
8695 // We didn't expect the animation to finish yet
8696 application.SendNotification();
8697 finishCheck.CheckSignalNotReceived();
8698 DALI_TEST_EQUALS( actor.GetCurrentOpacity(), ninetyNinePercentProgress, 0.001f, TEST_LOCATION );
8700 application.SendNotification();
8701 application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
8703 // We did expect the animation to finish
8704 application.SendNotification();
8705 finishCheck.CheckSignalReceived();
8706 DALI_TEST_EQUALS( actor.GetCurrentOpacity(), targetOpacity, TEST_LOCATION );
8709 finishCheck.Reset();
8710 actor.SetOpacity(1.0f);
8711 application.SendNotification();
8712 application.Render(0);
8713 DALI_TEST_EQUALS( actor.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
8715 // Repeat with a different (ease-in) alpha function
8716 animation = Animation::New(durationSeconds);
8717 animation.OpacityTo(actor, targetOpacity, AlphaFunctions::EaseIn);
8718 animation.FinishedSignal().Connect(&application, finishCheck);
8721 application.SendNotification();
8722 application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
8724 // We didn't expect the animation to finish yet
8725 application.SendNotification();
8726 finishCheck.CheckSignalNotReceived();
8728 // The opacity should reduce less, than with a linear alpha function
8729 float current(actor.GetCurrentOpacity());
8730 DALI_TEST_CHECK( current < 1.0f );
8731 DALI_TEST_CHECK( current > ninetyNinePercentProgress );
8733 application.SendNotification();
8734 application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
8736 // We did expect the animation to finish
8737 application.SendNotification();
8738 finishCheck.CheckSignalReceived();
8739 DALI_TEST_EQUALS( actor.GetCurrentOpacity(), targetOpacity, TEST_LOCATION );
8742 finishCheck.Reset();
8743 actor.SetOpacity(1.0f);
8744 application.SendNotification();
8745 application.Render(0);
8746 DALI_TEST_EQUALS( actor.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
8748 // Repeat with a delay
8750 animation = Animation::New(durationSeconds);
8751 animation.OpacityTo(actor, targetOpacity, AlphaFunctions::Linear, delay, durationSeconds - delay);
8752 animation.FinishedSignal().Connect(&application, finishCheck);
8755 application.SendNotification();
8756 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
8758 // We didn't expect the animation to finish yet
8759 application.SendNotification();
8760 finishCheck.CheckSignalNotReceived();
8761 DALI_TEST_EQUALS( actor.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
8763 application.SendNotification();
8764 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
8766 // We did expect the animation to finish
8767 application.SendNotification();
8768 finishCheck.CheckSignalReceived();
8769 DALI_TEST_EQUALS( actor.GetCurrentOpacity(), targetOpacity, TEST_LOCATION );
8773 int UtcDaliAnimationColorBy(void)
8775 TestApplication application;
8777 Actor actor = Actor::New();
8778 actor.SetColor(Color::BLACK);
8779 application.SendNotification();
8780 application.Render(0);
8781 DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::BLACK, TEST_LOCATION );
8782 Stage::GetCurrent().Add(actor);
8784 // Build the animation
8785 float durationSeconds(1.0f);
8786 Animation animation = Animation::New(durationSeconds);
8787 Vector4 targetColor(Color::GREEN);
8788 Vector4 relativeColor(Color::GREEN); // Note the alpha is automatically clamped <= 1.0f in world color
8789 animation.ColorBy(actor, relativeColor);
8791 Vector4 tenPercentProgress(Vector4(0.0f, 0.1f, 0.0f, 1.0f));
8792 Vector4 twentyPercentProgress(Vector4(0.0f, 0.2f, 0.0f, 1.0f));
8794 // Start the animation
8797 bool signalReceived(false);
8798 AnimationFinishCheck finishCheck(signalReceived);
8799 animation.FinishedSignal().Connect(&application, finishCheck);
8801 application.SendNotification();
8802 application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% progress */);
8804 // We didn't expect the animation to finish yet
8805 application.SendNotification();
8806 finishCheck.CheckSignalNotReceived();
8807 DALI_TEST_EQUALS( actor.GetCurrentWorldColor(), tenPercentProgress, TEST_LOCATION );
8809 application.SendNotification();
8810 application.Render(static_cast<unsigned int>(durationSeconds*900.0f) + 1u/*just beyond the animation duration*/);
8812 // We did expect the animation to finish
8813 application.SendNotification();
8814 finishCheck.CheckSignalReceived();
8815 DALI_TEST_EQUALS( actor.GetCurrentWorldColor(), targetColor, TEST_LOCATION );
8818 finishCheck.Reset();
8819 actor.SetColor(Color::BLACK);
8820 application.SendNotification();
8821 application.Render(0);
8822 DALI_TEST_EQUALS( actor.GetCurrentWorldColor(), Color::BLACK, TEST_LOCATION );
8824 // Repeat with a different (ease-in) alpha function
8825 animation = Animation::New(durationSeconds);
8826 animation.ColorBy(actor, relativeColor, AlphaFunctions::EaseIn);
8827 animation.FinishedSignal().Connect(&application, finishCheck);
8830 application.SendNotification();
8831 application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% progress */);
8833 // We didn't expect the animation to finish yet
8834 application.SendNotification();
8835 finishCheck.CheckSignalNotReceived();
8837 // The color should have changed less, than with a linear alpha function
8838 Vector4 current(actor.GetCurrentWorldColor());
8839 DALI_TEST_CHECK( current.x == 0.0f ); // doesn't change
8840 DALI_TEST_CHECK( current.y > 0.0f );
8841 DALI_TEST_CHECK( current.y < tenPercentProgress.y );
8842 DALI_TEST_CHECK( current.z == 0.0f ); // doesn't change
8843 DALI_TEST_CHECK( current.w == 1.0f ); // doesn't change
8845 application.SendNotification();
8846 application.Render(static_cast<unsigned int>(durationSeconds*900.0f) + 1u/*just beyond the animation duration*/);
8848 // We did expect the animation to finish
8849 application.SendNotification();
8850 finishCheck.CheckSignalReceived();
8851 DALI_TEST_EQUALS( actor.GetCurrentWorldColor(), targetColor, TEST_LOCATION );
8854 finishCheck.Reset();
8855 actor.SetColor(Color::BLACK);
8856 application.SendNotification();
8857 application.Render(0);
8858 DALI_TEST_EQUALS( actor.GetCurrentWorldColor(), Color::BLACK, TEST_LOCATION );
8860 // Repeat with a shorter animator duration
8861 float animatorDuration = 0.5f;
8862 animation = Animation::New(durationSeconds);
8863 animation.ColorBy(actor, relativeColor, AlphaFunctions::Linear, 0, animatorDuration);
8864 animation.FinishedSignal().Connect(&application, finishCheck);
8867 application.SendNotification();
8868 application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% animation progress, 20% animator progress */);
8870 // We didn't expect the animation to finish yet
8871 application.SendNotification();
8872 finishCheck.CheckSignalNotReceived();
8873 DALI_TEST_EQUALS( actor.GetCurrentWorldColor(), twentyPercentProgress, TEST_LOCATION );
8875 application.SendNotification();
8876 application.Render(static_cast<unsigned int>(durationSeconds*400.0f)/* 50% animation progress, 100% animator progress */);
8878 // We didn't expect the animation to finish yet
8879 application.SendNotification();
8880 finishCheck.CheckSignalNotReceived();
8881 DALI_TEST_EQUALS( actor.GetCurrentWorldColor(), targetColor, TEST_LOCATION );
8883 application.SendNotification();
8884 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
8886 // We did expect the animation to finish
8887 application.SendNotification();
8888 finishCheck.CheckSignalReceived();
8889 DALI_TEST_EQUALS( actor.GetCurrentWorldColor(), targetColor, TEST_LOCATION );
8893 int UtcDaliAnimationColorTo(void)
8895 TestApplication application;
8897 Actor actor = Actor::New();
8898 Stage::GetCurrent().Add(actor);
8899 DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
8901 // Build the animation
8902 float durationSeconds(1.0f);
8903 Animation animation = Animation::New(durationSeconds);
8904 Vector4 targetColor(Color::RED);
8905 animation.ColorTo(actor, targetColor);
8907 Vector4 tenPercentProgress(Vector4(1.0f, 0.9f, 0.9f, 1.0f));
8908 Vector4 twentyPercentProgress(Vector4(1.0f, 0.8f, 0.8f, 1.0f));
8910 // Start the animation
8913 bool signalReceived(false);
8914 AnimationFinishCheck finishCheck(signalReceived);
8915 animation.FinishedSignal().Connect(&application, finishCheck);
8917 application.SendNotification();
8918 application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% progress */);
8920 // We didn't expect the animation to finish yet
8921 application.SendNotification();
8922 finishCheck.CheckSignalNotReceived();
8923 DALI_TEST_EQUALS( actor.GetCurrentColor(), tenPercentProgress, TEST_LOCATION );
8925 application.SendNotification();
8926 application.Render(static_cast<unsigned int>(durationSeconds*900.0f) + 1u/*just beyond the animation duration*/);
8928 // We did expect the animation to finish
8929 application.SendNotification();
8930 finishCheck.CheckSignalReceived();
8931 DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION );
8934 finishCheck.Reset();
8935 actor.SetColor(Color::WHITE);
8936 application.SendNotification();
8937 application.Render(0);
8938 DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
8940 // Repeat with a different (ease-in) alpha function
8941 animation = Animation::New(durationSeconds);
8942 animation.ColorTo(actor, targetColor, AlphaFunctions::EaseIn);
8943 animation.FinishedSignal().Connect(&application, finishCheck);
8946 application.SendNotification();
8947 application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% progress */);
8949 // We didn't expect the animation to finish yet
8950 application.SendNotification();
8951 finishCheck.CheckSignalNotReceived();
8953 // The color should have changed less, than with a linear alpha function
8954 Vector4 current(actor.GetCurrentColor());
8955 DALI_TEST_CHECK( current.x == 1.0f ); // doesn't change
8956 DALI_TEST_CHECK( current.y < 1.0f );
8957 DALI_TEST_CHECK( current.y > tenPercentProgress.y );
8958 DALI_TEST_CHECK( current.z < 1.0f );
8959 DALI_TEST_CHECK( current.z > tenPercentProgress.z );
8960 DALI_TEST_CHECK( current.w == 1.0f ); // doesn't change
8962 application.SendNotification();
8963 application.Render(static_cast<unsigned int>(durationSeconds*900.0f) + 1u/*just beyond the animation duration*/);
8965 // We did expect the animation to finish
8966 application.SendNotification();
8967 finishCheck.CheckSignalReceived();
8968 DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION );
8971 finishCheck.Reset();
8972 actor.SetColor(Color::WHITE);
8973 application.SendNotification();
8974 application.Render(0);
8975 DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
8977 // Repeat with a shorter animator duration
8978 float animatorDuration = 0.5f;
8979 animation = Animation::New(durationSeconds);
8980 animation.ColorTo(actor, targetColor, AlphaFunctions::Linear, 0, animatorDuration);
8981 animation.FinishedSignal().Connect(&application, finishCheck);
8984 application.SendNotification();
8985 application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% animation progress, 20% animator progress */);
8987 // We didn't expect the animation to finish yet
8988 application.SendNotification();
8989 finishCheck.CheckSignalNotReceived();
8990 DALI_TEST_EQUALS( actor.GetCurrentColor(), twentyPercentProgress, TEST_LOCATION );
8992 application.SendNotification();
8993 application.Render(static_cast<unsigned int>(durationSeconds*400.0f)/* 50% animation progress, 100% animator progress */);
8995 // We didn't expect the animation to finish yet
8996 application.SendNotification();
8997 finishCheck.CheckSignalNotReceived();
8998 DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION );
9000 application.SendNotification();
9001 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
9003 // We did expect the animation to finish
9004 application.SendNotification();
9005 finishCheck.CheckSignalReceived();
9006 DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION );
9010 int UtcDaliAnimationResize(void)
9012 TestApplication application;
9014 Actor actor = Actor::New();
9015 Stage::GetCurrent().Add(actor);
9016 DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
9018 // Build the animation
9019 float durationSeconds(1.0f);
9020 Animation animation = Animation::New(durationSeconds);
9021 Vector3 targetSize(100.0f, 100.0f, 100.0f);
9022 animation.Resize(actor, targetSize);
9024 Vector3 ninetyNinePercentProgress(targetSize * 0.99f);
9026 // Start the animation
9029 bool signalReceived(false);
9030 AnimationFinishCheck finishCheck(signalReceived);
9031 animation.FinishedSignal().Connect(&application, finishCheck);
9033 application.SendNotification();
9034 application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
9036 // We didn't expect the animation to finish yet
9037 application.SendNotification();
9038 finishCheck.CheckSignalNotReceived();
9039 DALI_TEST_EQUALS( actor.GetCurrentSize(), ninetyNinePercentProgress, TEST_LOCATION );
9041 application.SendNotification();
9042 application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
9044 // We did expect the animation to finish
9045 application.SendNotification();
9046 finishCheck.CheckSignalReceived();
9047 DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION );
9050 finishCheck.Reset();
9051 actor.SetSize(Vector3::ZERO);
9052 application.SendNotification();
9053 application.Render(0);
9054 DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
9056 // Repeat with a different (ease-in) alpha function
9057 animation = Animation::New(durationSeconds);
9058 animation.Resize(actor, targetSize, AlphaFunctions::EaseIn);
9059 animation.FinishedSignal().Connect(&application, finishCheck);
9062 application.SendNotification();
9063 application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
9065 // We didn't expect the animation to finish yet
9066 application.SendNotification();
9067 finishCheck.CheckSignalNotReceived();
9069 // The size should have travelled less, than with a linear alpha function
9070 Vector3 current(actor.GetCurrentSize());
9071 DALI_TEST_CHECK( current.x > 0.0f );
9072 DALI_TEST_CHECK( current.y > 0.0f );
9073 DALI_TEST_CHECK( current.z > 0.0f );
9074 DALI_TEST_CHECK( current.x < ninetyNinePercentProgress.x );
9075 DALI_TEST_CHECK( current.y < ninetyNinePercentProgress.y );
9076 DALI_TEST_CHECK( current.z < ninetyNinePercentProgress.z );
9078 application.SendNotification();
9079 application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
9081 // We did expect the animation to finish
9082 application.SendNotification();
9083 finishCheck.CheckSignalReceived();
9084 DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION );
9087 finishCheck.Reset();
9088 actor.SetSize(Vector3::ZERO);
9089 application.SendNotification();
9090 application.Render(0);
9091 DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
9093 // Repeat with a delay
9095 animation = Animation::New(durationSeconds);
9096 animation.Resize(actor, targetSize, AlphaFunctions::Linear, delay, durationSeconds - delay);
9097 animation.FinishedSignal().Connect(&application, finishCheck);
9100 application.SendNotification();
9101 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
9103 // We didn't expect the animation to finish yet
9104 application.SendNotification();
9105 finishCheck.CheckSignalNotReceived();
9106 DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
9108 application.SendNotification();
9109 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
9111 // We did expect the animation to finish
9112 application.SendNotification();
9113 finishCheck.CheckSignalReceived();
9114 DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION );
9118 int UtcDaliAnimationAnimateBool(void)
9120 TestApplication application;
9122 Actor actor = Actor::New();
9123 DALI_TEST_EQUALS( actor.IsVisible(), true, TEST_LOCATION );
9124 Stage::GetCurrent().Add(actor);
9126 // Build the animation
9127 float durationSeconds(10.0f);
9128 Animation animation = Animation::New(durationSeconds);
9129 animation.Animate<bool>( Property(actor, Actor::VISIBLE), ReturnFalseAfterProgressOne, TimePeriod(durationSeconds*0.25f/*delay*/, durationSeconds*0.1f) );
9131 // Start the animation
9134 bool signalReceived(false);
9135 AnimationFinishCheck finishCheck(signalReceived);
9136 animation.FinishedSignal().Connect(&application, finishCheck);
9138 application.SendNotification();
9139 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
9141 // We didn't expect the animation to finish yet
9142 application.SendNotification();
9143 finishCheck.CheckSignalNotReceived();
9145 // Should still be visible
9146 DALI_TEST_EQUALS( actor.IsVisible(), true, TEST_LOCATION );
9148 application.SendNotification();
9149 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
9151 // We didn't expect the animation to finish yet
9152 application.SendNotification();
9153 finishCheck.CheckSignalNotReceived();
9155 // Now animate functor should have hidden the actor
9156 DALI_TEST_EQUALS( actor.IsVisible(), false, TEST_LOCATION );
9158 application.SendNotification();
9159 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
9161 // We did expect the animation to finish
9162 application.SendNotification();
9163 finishCheck.CheckSignalReceived();
9164 DALI_TEST_EQUALS( actor.IsVisible(), false, TEST_LOCATION );
9168 int UtcDaliAnimationAnimateFloat(void)
9170 TestApplication application;
9172 Actor actor = Actor::New();
9173 Stage::GetCurrent().Add(actor);
9175 // Register a float property
9176 float startValue(10.0f);
9177 Property::Index index = actor.RegisterProperty( "test-property", startValue );
9178 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
9180 // Build the animation
9181 float durationSeconds(10.0f);
9182 Animation animation = Animation::New(durationSeconds);
9183 float targetPosition(0.0f);
9184 AnimateFloatTestFunctor func( 100, targetPosition );
9185 animation.Animate<float>( Property(actor, index), func );
9187 // Start the animation
9190 bool signalReceived(false);
9191 AnimationFinishCheck finishCheck(signalReceived);
9192 animation.FinishedSignal().Connect(&application, finishCheck);
9194 application.SendNotification();
9195 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
9197 // We didn't expect the animation to finish yet
9198 application.SendNotification();
9199 finishCheck.CheckSignalNotReceived();
9200 DALI_TEST_EQUALS( actor.GetProperty<float>(index), 75.0f, TEST_LOCATION );
9202 application.SendNotification();
9203 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
9205 // We didn't expect the animation to finish yet
9206 application.SendNotification();
9207 finishCheck.CheckSignalNotReceived();
9208 DALI_TEST_EQUALS( actor.GetProperty<float>(index), 50.0f, TEST_LOCATION );
9210 application.SendNotification();
9211 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
9213 // We didn't expect the animation to finish yet
9214 application.SendNotification();
9215 finishCheck.CheckSignalNotReceived();
9216 DALI_TEST_EQUALS( actor.GetProperty<float>(index), 25.0f, TEST_LOCATION );
9218 application.SendNotification();
9219 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
9221 // We did expect the animation to finish
9222 application.SendNotification();
9223 finishCheck.CheckSignalReceived();
9224 DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetPosition, TEST_LOCATION );
9228 int UtcDaliAnimationAnimateInteger(void)
9230 TestApplication application;
9232 Actor actor = Actor::New();
9233 Stage::GetCurrent().Add(actor);
9235 // Register an integer property
9237 Property::Index index = actor.RegisterProperty( "test-property", startValue );
9238 DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
9240 // Build the animation
9241 float durationSeconds(10.0f);
9242 Animation animation = Animation::New(durationSeconds);
9243 int targetPosition(0);
9244 AnimateIntegerTestFunctor func( 100, targetPosition );
9245 animation.Animate<int>( Property(actor, index), func );
9247 // Start the animation
9250 bool signalReceived(false);
9251 AnimationFinishCheck finishCheck(signalReceived);
9252 animation.FinishedSignal().Connect(&application, finishCheck);
9254 application.SendNotification();
9255 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
9257 // We didn't expect the animation to finish yet
9258 application.SendNotification();
9259 finishCheck.CheckSignalNotReceived();
9260 DALI_TEST_EQUALS( actor.GetProperty<int>(index), 75, TEST_LOCATION );
9262 application.SendNotification();
9263 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
9265 // We didn't expect the animation to finish yet
9266 application.SendNotification();
9267 finishCheck.CheckSignalNotReceived();
9268 DALI_TEST_EQUALS( actor.GetProperty<int>(index), 50, TEST_LOCATION );
9270 application.SendNotification();
9271 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
9273 // We didn't expect the animation to finish yet
9274 application.SendNotification();
9275 finishCheck.CheckSignalNotReceived();
9276 DALI_TEST_EQUALS( actor.GetProperty<int>(index), 25, TEST_LOCATION );
9278 application.SendNotification();
9279 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
9281 // We did expect the animation to finish
9282 application.SendNotification();
9283 finishCheck.CheckSignalReceived();
9284 DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetPosition, TEST_LOCATION );
9288 int UtcDaliAnimationAnimateVector2(void)
9290 TestApplication application;
9292 Actor actor = Actor::New();
9293 Stage::GetCurrent().Add(actor);
9295 // Register a Vector2 property
9296 Vector2 startValue(10.0f, 10.0f);
9297 Property::Index index = actor.RegisterProperty( "test-property", startValue );
9298 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
9300 // Build the animation
9301 float durationSeconds(10.0f);
9302 Animation animation = Animation::New(durationSeconds);
9303 Vector2 targetPosition(0.0f, 0.0f);
9304 AnimateVector2TestFunctor func( Vector2(100,100), targetPosition );
9305 animation.Animate<Vector2>( Property(actor, index), func );
9307 // Start the animation
9310 bool signalReceived(false);
9311 AnimationFinishCheck finishCheck(signalReceived);
9312 animation.FinishedSignal().Connect(&application, finishCheck);
9314 application.SendNotification();
9315 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
9317 // We didn't expect the animation to finish yet
9318 application.SendNotification();
9319 finishCheck.CheckSignalNotReceived();
9320 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), Vector2(75,75), TEST_LOCATION );
9322 application.SendNotification();
9323 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
9325 // We didn't expect the animation to finish yet
9326 application.SendNotification();
9327 finishCheck.CheckSignalNotReceived();
9328 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), Vector2(50,50), TEST_LOCATION );
9330 application.SendNotification();
9331 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
9333 // We didn't expect the animation to finish yet
9334 application.SendNotification();
9335 finishCheck.CheckSignalNotReceived();
9336 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), Vector2(25,25), TEST_LOCATION );
9338 application.SendNotification();
9339 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
9341 // We did expect the animation to finish
9342 application.SendNotification();
9343 finishCheck.CheckSignalReceived();
9344 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetPosition, TEST_LOCATION );
9348 int UtcDaliAnimationAnimateVector3(void)
9350 TestApplication application;
9352 Actor actor = Actor::New();
9353 Vector3 initialPosition(Vector3::ZERO);
9354 DALI_TEST_EQUALS( actor.GetCurrentPosition(), initialPosition, TEST_LOCATION );
9355 Stage::GetCurrent().Add(actor);
9357 // Build the animation
9358 float durationSeconds(10.0f);
9359 Animation animation = Animation::New(durationSeconds);
9360 Vector3 targetPosition(200.0f, 200.0f, 200.0f);
9361 BounceFunc func(0.0f, 0.0f, -100.0f);
9362 animation.Animate<Vector3>( Property(actor, Actor::POSITION), func, AlphaFunctions::Linear, durationSeconds );
9364 // Start the animation
9367 bool signalReceived(false);
9368 AnimationFinishCheck finishCheck(signalReceived);
9369 animation.FinishedSignal().Connect(&application, finishCheck);
9371 application.SendNotification();
9372 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
9374 // We didn't expect the animation to finish yet
9375 application.SendNotification();
9376 finishCheck.CheckSignalNotReceived();
9377 DALI_TEST_EQUALS( actor.GetCurrentPosition(), func(0.25f, initialPosition), TEST_LOCATION );
9379 application.SendNotification();
9380 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
9382 // We didn't expect the animation to finish yet
9383 application.SendNotification();
9384 finishCheck.CheckSignalNotReceived();
9385 DALI_TEST_EQUALS( actor.GetCurrentPosition(), func(0.5f, initialPosition), TEST_LOCATION );
9387 application.SendNotification();
9388 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
9390 // We didn't expect the animation to finish yet
9391 application.SendNotification();
9392 finishCheck.CheckSignalNotReceived();
9393 DALI_TEST_EQUALS( actor.GetCurrentPosition(), func(0.75f, initialPosition), TEST_LOCATION );
9395 application.SendNotification();
9396 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
9398 // We did expect the animation to finish
9399 application.SendNotification();
9400 finishCheck.CheckSignalReceived();
9401 DALI_TEST_EQUALS( actor.GetCurrentPosition(), initialPosition, TEST_LOCATION );
9405 int UtcDaliAnimationAnimateVector4(void)
9407 TestApplication application;
9409 Actor actor = Actor::New();
9410 Stage::GetCurrent().Add(actor);
9412 // Register a Vector4 property
9413 Vector4 startValue(10.0f, 10.0f, 10.0f, 10.0f);
9414 Property::Index index = actor.RegisterProperty( "test-property", startValue );
9415 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
9417 // Build the animation
9418 float durationSeconds(10.0f);
9419 Animation animation = Animation::New(durationSeconds);
9420 Vector4 targetPosition(200,400,0,-1000);
9421 AnimateVector4TestFunctor func( Vector4(1000,1000,1000,1000), targetPosition );
9422 animation.Animate<Vector4>( Property(actor, index), func );
9424 // Start the animation
9427 bool signalReceived(false);
9428 AnimationFinishCheck finishCheck(signalReceived);
9429 animation.FinishedSignal().Connect(&application, finishCheck);
9431 application.SendNotification();
9432 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
9434 // We didn't expect the animation to finish yet
9435 application.SendNotification();
9436 finishCheck.CheckSignalNotReceived();
9437 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), Vector4(800,850,750,500), TEST_LOCATION );
9439 application.SendNotification();
9440 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
9442 // We didn't expect the animation to finish yet
9443 application.SendNotification();
9444 finishCheck.CheckSignalNotReceived();
9445 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), Vector4(600,700,500,0), TEST_LOCATION );
9447 application.SendNotification();
9448 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
9450 // We didn't expect the animation to finish yet
9451 application.SendNotification();
9452 finishCheck.CheckSignalNotReceived();
9453 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), Vector4(400,550,250,-500), TEST_LOCATION );
9455 application.SendNotification();
9456 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
9458 // We did expect the animation to finish
9459 application.SendNotification();
9460 finishCheck.CheckSignalReceived();
9461 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetPosition, TEST_LOCATION );
9465 int UtcDaliAnimationAnimateQuaternion(void)
9467 TestApplication application;
9469 Actor actor = Actor::New();
9470 actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
9471 Stage::GetCurrent().Add(actor);
9472 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
9474 // Build the animation
9475 float durationSeconds(1.0f);
9476 Animation animation = Animation::New(durationSeconds);
9478 Degree sourceRotationDegrees(90.0f);
9479 Radian sourceRotationRadians(sourceRotationDegrees);
9480 Quaternion sourceRotation(sourceRotationRadians, Vector3::YAXIS);
9482 Degree targetRotationDegrees(150.0f);
9483 Radian targetRotationRadians(targetRotationDegrees);
9484 Quaternion targetRotation(targetRotationRadians, Vector3::YAXIS);
9486 AnimateQuaternionTestFunctor func( sourceRotation, targetRotation );
9487 animation.Animate<Quaternion>( Property(actor, Actor::ROTATION), func );
9489 // Start the animation
9492 bool signalReceived(false);
9493 AnimationFinishCheck finishCheck(signalReceived);
9494 animation.FinishedSignal().Connect(&application, finishCheck);
9496 application.SendNotification();
9497 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
9499 // We didn't expect the animation to finish yet
9500 application.SendNotification();
9501 finishCheck.CheckSignalNotReceived();
9502 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(Radian(Degree(105)), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
9504 application.SendNotification();
9505 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
9507 // We didn't expect the animation to finish yet
9508 application.SendNotification();
9509 finishCheck.CheckSignalNotReceived();
9510 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(Radian(Degree(120)), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
9512 application.SendNotification();
9513 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
9515 // We didn't expect the animation to finish yet
9516 application.SendNotification();
9517 finishCheck.CheckSignalNotReceived();
9518 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(Radian(Degree(135)), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
9520 application.SendNotification();
9521 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
9523 // We did expect the animation to finish
9524 application.SendNotification();
9525 finishCheck.CheckSignalReceived();
9526 DALI_TEST_EQUALS( actor.GetCurrentRotation(), targetRotation, ROTATION_EPSILON, TEST_LOCATION );
9530 int UtcDaliKeyFramesCreateDestroy(void)
9532 tet_infoline("Testing Dali::Animation::UtcDaliKeyFramesCreateDestroy()");
9534 KeyFrames* keyFrames = new KeyFrames;
9536 DALI_TEST_CHECK( true );
9540 int UtcDaliKeyFramesDownCast(void)
9542 TestApplication application;
9543 tet_infoline("Testing Dali::Animation::KeyFramesDownCast()");
9545 KeyFrames keyFrames = KeyFrames::New();
9546 BaseHandle object(keyFrames);
9548 KeyFrames keyFrames2 = KeyFrames::DownCast(object);
9549 DALI_TEST_CHECK(keyFrames2);
9551 KeyFrames keyFrames3 = DownCast< KeyFrames >(object);
9552 DALI_TEST_CHECK(keyFrames3);
9554 BaseHandle unInitializedObject;
9555 KeyFrames keyFrames4 = KeyFrames::DownCast(unInitializedObject);
9556 DALI_TEST_CHECK(!keyFrames4);
9558 KeyFrames keyFrames5 = DownCast< KeyFrames >(unInitializedObject);
9559 DALI_TEST_CHECK(!keyFrames5);
9563 int UtcDaliAnimationResizeByXY(void)
9565 TestApplication application;
9567 Actor actor = Actor::New();
9568 Stage::GetCurrent().Add(actor);
9569 DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
9571 // Build the animation
9572 float durationSeconds(1.0f);
9573 Animation animation = Animation::New(durationSeconds);
9574 Vector3 targetSize(100.0f, 100.0f, 100.0f);
9575 animation.Resize(actor, targetSize);
9577 Vector3 ninetyNinePercentProgress(targetSize * 0.99f);
9579 // Start the animation
9582 bool signalReceived(false);
9583 AnimationFinishCheck finishCheck(signalReceived);
9584 animation.FinishedSignal().Connect(&application, finishCheck);
9586 application.SendNotification();
9587 application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
9589 // We didn't expect the animation to finish yet
9590 application.SendNotification();
9591 finishCheck.CheckSignalNotReceived();
9592 DALI_TEST_EQUALS( actor.GetCurrentSize(), ninetyNinePercentProgress, TEST_LOCATION );
9594 application.SendNotification();
9595 application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
9597 // We did expect the animation to finish
9598 application.SendNotification();
9599 finishCheck.CheckSignalReceived();
9600 DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION );
9603 finishCheck.Reset();
9604 actor.SetSize(Vector3::ZERO);
9605 application.SendNotification();
9606 application.Render(0);
9607 DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
9609 // Repeat with a different (ease-in) alpha function
9610 animation = Animation::New(durationSeconds);
9611 animation.Resize(actor, targetSize.x, targetSize.y, AlphaFunctions::EaseIn);
9612 animation.FinishedSignal().Connect(&application, finishCheck);
9615 application.SendNotification();
9616 application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
9618 // We didn't expect the animation to finish yet
9619 application.SendNotification();
9620 finishCheck.CheckSignalNotReceived();
9622 // The size should have travelled less, than with a linear alpha function
9623 Vector3 current(actor.GetCurrentSize());
9624 DALI_TEST_CHECK( current.x > 0.0f );
9625 DALI_TEST_CHECK( current.y > 0.0f );
9626 DALI_TEST_CHECK( current.z > 0.0f );
9627 DALI_TEST_CHECK( current.x < ninetyNinePercentProgress.x );
9628 DALI_TEST_CHECK( current.y < ninetyNinePercentProgress.y );
9629 DALI_TEST_CHECK( current.z < ninetyNinePercentProgress.z );
9631 application.SendNotification();
9632 application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
9634 // We did expect the animation to finish
9635 application.SendNotification();
9636 finishCheck.CheckSignalReceived();
9637 DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION );
9640 finishCheck.Reset();
9641 actor.SetSize(Vector3::ZERO);
9642 application.SendNotification();
9643 application.Render(0);
9644 DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
9646 // Repeat with a delay
9648 animation = Animation::New(durationSeconds);
9649 animation.Resize(actor, targetSize.x, targetSize.y, AlphaFunctions::Linear, delay, durationSeconds - delay);
9650 animation.FinishedSignal().Connect(&application, finishCheck);
9653 application.SendNotification();
9654 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
9656 // We didn't expect the animation to finish yet
9657 application.SendNotification();
9658 finishCheck.CheckSignalNotReceived();
9659 DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
9661 application.SendNotification();
9662 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
9664 // We did expect the animation to finish
9665 application.SendNotification();
9666 finishCheck.CheckSignalReceived();
9667 DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION );
9672 int UtcDaliAnimationAnimateBetweenActorColorTimePeriod(void)
9674 TestApplication application;
9676 float startValue(1.0f);
9677 Actor actor = Actor::New();
9678 actor.SetColor(Vector4(startValue, startValue, startValue, startValue));
9679 Stage::GetCurrent().Add(actor);
9681 DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
9682 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
9683 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
9684 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
9685 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), startValue, TEST_LOCATION );
9687 // Build the animation
9688 float durationSeconds(1.0f);
9689 Animation animation = Animation::New(durationSeconds);
9691 KeyFrames keyFrames = KeyFrames::New();
9692 keyFrames.Add(0.0f, Vector4(0.1f, 0.2f, 0.3f, 0.4f));
9693 keyFrames.Add(0.5f, Vector4(0.9f, 0.8f, 0.7f, 0.6f));
9694 keyFrames.Add(1.0f, Vector4(1.0f, 1.0f, 1.0f, 1.0f));
9696 animation.AnimateBetween( Property(actor, Actor::COLOR), keyFrames, TimePeriod( 1.0f) );
9698 // Start the animation
9701 bool signalReceived(false);
9702 AnimationFinishCheck finishCheck(signalReceived);
9703 animation.FinishedSignal().Connect(&application, finishCheck);
9704 application.SendNotification();
9705 application.Render(0);
9706 application.SendNotification();
9707 finishCheck.CheckSignalNotReceived();
9708 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), 0.1f, 0.01f, TEST_LOCATION );
9709 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 0.2f, 0.01f, TEST_LOCATION );
9710 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), 0.3f, 0.01f, TEST_LOCATION );
9711 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.4f, 0.01f, TEST_LOCATION );
9713 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
9714 application.SendNotification();
9715 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), 0.5f, 0.01f, TEST_LOCATION );
9716 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 0.5f, 0.01f, TEST_LOCATION );
9717 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), 0.5f, 0.01f, TEST_LOCATION );
9718 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.5f, 0.01f, TEST_LOCATION );
9720 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
9721 application.SendNotification();
9722 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), 0.9f, 0.01f, TEST_LOCATION );
9723 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 0.8f, 0.01f, TEST_LOCATION );
9724 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), 0.7f, 0.01f, TEST_LOCATION );
9725 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.6f, 0.01f, TEST_LOCATION );
9727 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
9728 application.SendNotification();
9729 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), 0.95f, 0.01f, TEST_LOCATION );
9730 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 0.90f, 0.01f, TEST_LOCATION );
9731 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), 0.85f, 0.01f, TEST_LOCATION );
9732 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.80f, 0.01f, TEST_LOCATION );
9734 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
9735 application.SendNotification();
9736 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), 1.0f, 0.01f, TEST_LOCATION );
9737 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 1.0f, 0.01f, TEST_LOCATION );
9738 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), 1.0f, 0.01f, TEST_LOCATION );
9739 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 1.0f, 0.01f, TEST_LOCATION );
9741 // We did expect the animation to finish
9743 finishCheck.CheckSignalReceived();
9747 int UtcDaliAnimationAnimateBetweenActorColorFunction(void)
9749 TestApplication application;
9751 float startValue(1.0f);
9752 Actor actor = Actor::New();
9753 actor.SetColor(Vector4(startValue, startValue, startValue, startValue));
9754 Stage::GetCurrent().Add(actor);
9756 DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
9757 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
9758 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
9759 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
9760 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), startValue, TEST_LOCATION );
9762 // Build the animation
9763 float durationSeconds(1.0f);
9764 Animation animation = Animation::New(durationSeconds);
9766 KeyFrames keyFrames = KeyFrames::New();
9767 keyFrames.Add(0.0f, Vector4(0.1f, 0.2f, 0.3f, 0.4f));
9768 keyFrames.Add(0.5f, Vector4(0.9f, 0.8f, 0.7f, 0.6f));
9769 keyFrames.Add(1.0f, Vector4(1.0f, 1.0f, 1.0f, 1.0f));
9771 animation.AnimateBetween( Property(actor, Actor::COLOR), keyFrames, AlphaFunctions::Linear );
9773 // Start the animation
9776 bool signalReceived(false);
9777 AnimationFinishCheck finishCheck(signalReceived);
9778 animation.FinishedSignal().Connect(&application, finishCheck);
9779 application.SendNotification();
9780 application.Render(0);
9781 application.SendNotification();
9782 finishCheck.CheckSignalNotReceived();
9783 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), 0.1f, 0.01f, TEST_LOCATION );
9784 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 0.2f, 0.01f, TEST_LOCATION );
9785 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), 0.3f, 0.01f, TEST_LOCATION );
9786 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.4f, 0.01f, TEST_LOCATION );
9788 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
9789 application.SendNotification();
9790 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), 0.5f, 0.01f, TEST_LOCATION );
9791 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 0.5f, 0.01f, TEST_LOCATION );
9792 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), 0.5f, 0.01f, TEST_LOCATION );
9793 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.5f, 0.01f, TEST_LOCATION );
9795 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
9796 application.SendNotification();
9797 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), 0.9f, 0.01f, TEST_LOCATION );
9798 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 0.8f, 0.01f, TEST_LOCATION );
9799 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), 0.7f, 0.01f, TEST_LOCATION );
9800 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.6f, 0.01f, TEST_LOCATION );
9802 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
9803 application.SendNotification();
9804 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), 0.95f, 0.01f, TEST_LOCATION );
9805 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 0.90f, 0.01f, TEST_LOCATION );
9806 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), 0.85f, 0.01f, TEST_LOCATION );
9807 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.80f, 0.01f, TEST_LOCATION );
9809 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
9810 application.SendNotification();
9811 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), 1.0f, 0.01f, TEST_LOCATION );
9812 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 1.0f, 0.01f, TEST_LOCATION );
9813 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), 1.0f, 0.01f, TEST_LOCATION );
9814 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 1.0f, 0.01f, TEST_LOCATION );
9816 // We did expect the animation to finish
9818 finishCheck.CheckSignalReceived();
9822 int UtcDaliAnimationAnimateBetweenActorColorFunctionTimePeriod(void)
9824 TestApplication application;
9826 float startValue(1.0f);
9827 Actor actor = Actor::New();
9828 actor.SetColor(Vector4(startValue, startValue, startValue, startValue));
9829 Stage::GetCurrent().Add(actor);
9831 DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
9832 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
9833 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
9834 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
9835 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), startValue, TEST_LOCATION );
9837 // Build the animation
9838 float durationSeconds(1.0f);
9839 Animation animation = Animation::New(durationSeconds);
9841 KeyFrames keyFrames = KeyFrames::New();
9842 keyFrames.Add(0.0f, Vector4(0.1f, 0.2f, 0.3f, 0.4f));
9843 keyFrames.Add(0.5f, Vector4(0.9f, 0.8f, 0.7f, 0.6f));
9844 keyFrames.Add(1.0f, Vector4(1.0f, 1.0f, 1.0f, 1.0f));
9846 animation.AnimateBetween( Property(actor, Actor::COLOR), keyFrames, AlphaFunctions::Linear, TimePeriod( 1.0f) );
9848 // Start the animation
9851 bool signalReceived(false);
9852 AnimationFinishCheck finishCheck(signalReceived);
9853 animation.FinishedSignal().Connect(&application, finishCheck);
9854 application.SendNotification();
9855 application.Render(0);
9856 application.SendNotification();
9857 finishCheck.CheckSignalNotReceived();
9858 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), 0.1f, 0.01f, TEST_LOCATION );
9859 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 0.2f, 0.01f, TEST_LOCATION );
9860 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), 0.3f, 0.01f, TEST_LOCATION );
9861 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.4f, 0.01f, TEST_LOCATION );
9863 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
9864 application.SendNotification();
9865 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), 0.5f, 0.01f, TEST_LOCATION );
9866 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 0.5f, 0.01f, TEST_LOCATION );
9867 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), 0.5f, 0.01f, TEST_LOCATION );
9868 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.5f, 0.01f, TEST_LOCATION );
9870 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
9871 application.SendNotification();
9872 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), 0.9f, 0.01f, TEST_LOCATION );
9873 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 0.8f, 0.01f, TEST_LOCATION );
9874 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), 0.7f, 0.01f, TEST_LOCATION );
9875 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.6f, 0.01f, TEST_LOCATION );
9877 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
9878 application.SendNotification();
9879 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), 0.95f, 0.01f, TEST_LOCATION );
9880 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 0.90f, 0.01f, TEST_LOCATION );
9881 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), 0.85f, 0.01f, TEST_LOCATION );
9882 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.80f, 0.01f, TEST_LOCATION );
9884 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
9885 application.SendNotification();
9886 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), 1.0f, 0.01f, TEST_LOCATION );
9887 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 1.0f, 0.01f, TEST_LOCATION );
9888 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), 1.0f, 0.01f, TEST_LOCATION );
9889 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 1.0f, 0.01f, TEST_LOCATION );
9891 // We did expect the animation to finish
9893 finishCheck.CheckSignalReceived();
9897 int UtcDaliAnimationAnimateVector3Func(void)
9899 TestApplication application;
9901 Actor actor = Actor::New();
9902 Vector3 initialPosition(Vector3::ZERO);
9903 DALI_TEST_EQUALS( actor.GetCurrentPosition(), initialPosition, TEST_LOCATION );
9904 Stage::GetCurrent().Add(actor);
9906 // Build the animation
9907 float durationSeconds(10.0f);
9908 Animation animation = Animation::New(durationSeconds);
9909 Vector3 targetPosition(200.0f, 200.0f, 200.0f);
9910 BounceFunc func(0.0f, 0.0f, -100.0f);
9911 animation.Animate<Vector3>( Property(actor, Actor::POSITION), func, AlphaFunctions::Linear );
9913 // Start the animation
9916 bool signalReceived(false);
9917 AnimationFinishCheck finishCheck(signalReceived);
9918 animation.FinishedSignal().Connect(&application, finishCheck);
9920 application.SendNotification();
9921 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
9923 // We didn't expect the animation to finish yet
9924 application.SendNotification();
9925 finishCheck.CheckSignalNotReceived();
9926 DALI_TEST_EQUALS( actor.GetCurrentPosition(), func(0.25f, initialPosition), TEST_LOCATION );
9928 application.SendNotification();
9929 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
9931 // We didn't expect the animation to finish yet
9932 application.SendNotification();
9933 finishCheck.CheckSignalNotReceived();
9934 DALI_TEST_EQUALS( actor.GetCurrentPosition(), func(0.5f, initialPosition), TEST_LOCATION );
9936 application.SendNotification();
9937 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
9939 // We didn't expect the animation to finish yet
9940 application.SendNotification();
9941 finishCheck.CheckSignalNotReceived();
9942 DALI_TEST_EQUALS( actor.GetCurrentPosition(), func(0.75f, initialPosition), TEST_LOCATION );
9944 application.SendNotification();
9945 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
9947 // We did expect the animation to finish
9948 application.SendNotification();
9949 finishCheck.CheckSignalReceived();
9950 DALI_TEST_EQUALS( actor.GetCurrentPosition(), initialPosition, TEST_LOCATION );
9954 int UtcDaliAnimationCreateDestroy(void)
9956 TestApplication application;
9957 Animation* animation = new Animation;
9958 DALI_TEST_CHECK( animation );
9963 struct UpdateManagerTestConstraint
9965 UpdateManagerTestConstraint(TestApplication& application)
9966 : mApplication(application)
9970 Vector3 operator()(const Vector3& current)
9972 mApplication.SendNotification(); // Process events
9976 TestApplication& mApplication;
9979 int UtcDaliAnimationUpdateManager(void)
9981 TestApplication application;
9983 Actor actor = Actor::New();
9984 Stage::GetCurrent().Add( actor );
9986 // Build the animation
9987 Animation animation = Animation::New( 0.0f );
9989 bool signalReceived = false;
9990 AnimationFinishCheck finishCheck( signalReceived );
9991 animation.FinishedSignal().Connect( &application, finishCheck );
9993 Vector3 startValue(1.0f, 1.0f, 1.0f);
9994 Property::Index index = actor.RegisterProperty( "test-property", startValue );
9995 Constraint constraint = Constraint::New<Vector3>( index, UpdateManagerTestConstraint( application ) );
9996 actor.ApplyConstraint( constraint );
9998 // Apply animation to actor
9999 BounceFunc func(0.0f, 0.0f, -100.0f);
10000 animation.Animate<Vector3>( Property(actor, Actor::POSITION), func, AlphaFunctions::Linear );
10004 application.SendNotification();
10005 application.UpdateOnly( 16 );
10007 finishCheck.CheckSignalNotReceived();
10009 application.SendNotification(); // Process events
10011 finishCheck.CheckSignalReceived();
10016 int UtcDaliAnimationSignalOrder(void)
10018 TestApplication application;
10020 Actor actor = Actor::New();
10021 Stage::GetCurrent().Add( actor );
10023 // Build the animations
10024 Animation animation1 = Animation::New( 0.0f ); // finishes first frame
10025 Animation animation2 = Animation::New( 0.02f ); // finishes in 20 ms
10027 bool signal1Received = false;
10028 animation1.FinishedSignal().Connect( &application, AnimationFinishCheck( signal1Received ) );
10030 bool signal2Received = false;
10031 animation2.FinishedSignal().Connect( &application, AnimationFinishCheck( signal2Received ) );
10033 // Apply animations to actor
10034 animation1.AnimateTo( Property(actor, Actor::POSITION), Vector3( 3.0f, 2.0f, 1.0f ), AlphaFunctions::Linear );
10036 animation2.AnimateTo( Property(actor, Actor::SIZE ), Vector3( 10.0f, 20.0f, 30.0f ), AlphaFunctions::Linear );
10039 DALI_TEST_EQUALS( signal1Received, false, TEST_LOCATION );
10040 DALI_TEST_EQUALS( signal2Received, false, TEST_LOCATION );
10042 application.SendNotification();
10043 application.UpdateOnly( 10 ); // 10ms progress
10045 // no notifications yet
10046 DALI_TEST_EQUALS( signal1Received, false, TEST_LOCATION );
10047 DALI_TEST_EQUALS( signal2Received, false, TEST_LOCATION );
10049 application.SendNotification();
10052 DALI_TEST_EQUALS( signal1Received, true, TEST_LOCATION );
10053 DALI_TEST_EQUALS( signal2Received, false, TEST_LOCATION );
10054 signal1Received = false;
10056 // 1st animation is complete now, do another update with no ProcessEvents in between
10057 application.UpdateOnly( 20 ); // 20ms progress
10060 application.SendNotification();
10062 // 2nd should complete now
10063 DALI_TEST_EQUALS( signal1Received, false, TEST_LOCATION );
10064 DALI_TEST_EQUALS( signal2Received, true, TEST_LOCATION );
10069 int UtcDaliAnimationExtendDuration(void)
10071 TestApplication application;
10073 Actor actor = Actor::New();
10075 // Register a float property
10076 float startValue(10.0f);
10077 Property::Index index = actor.RegisterProperty( "test-property", startValue );
10078 Stage::GetCurrent().Add(actor);
10079 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
10081 // Build the animation
10082 float initialDurationSeconds(1.0f);
10083 float animatorDelay = 5.0f;
10084 float animatorDurationSeconds(5.0f);
10085 float extendedDurationSeconds(animatorDelay+animatorDurationSeconds);
10086 Animation animation = Animation::New(initialDurationSeconds);
10087 float targetValue(30.0f);
10088 float relativeValue(targetValue - startValue);
10090 animation.AnimateTo(Property(actor, index),
10092 TimePeriod(animatorDelay, animatorDurationSeconds));
10094 // The duration should have been extended
10095 DALI_TEST_EQUALS( animation.GetDuration(), extendedDurationSeconds, TEST_LOCATION );
10097 // Start the animation
10100 bool signalReceived(false);
10101 AnimationFinishCheck finishCheck(signalReceived);
10102 animation.FinishedSignal().Connect(&application, finishCheck);
10104 application.SendNotification();
10105 application.Render(static_cast<unsigned int>(extendedDurationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
10107 // We didn't expect the animation to finish yet
10108 application.SendNotification();
10109 finishCheck.CheckSignalNotReceived();
10110 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
10112 application.SendNotification();
10113 application.Render(static_cast<unsigned int>(extendedDurationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
10115 // We didn't expect the animation to finish yet
10116 application.SendNotification();
10117 finishCheck.CheckSignalNotReceived();
10118 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
10120 application.SendNotification();
10121 application.Render(static_cast<unsigned int>(extendedDurationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
10123 // We did expect the animation to finish
10124 application.SendNotification();
10125 finishCheck.CheckSignalReceived();
10126 DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );