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 );
619 // Don't play the animation: disconnect action should not be applied
621 Actor actor = Actor::New();
624 // Build the animation
625 float durationSeconds(1.0f);
626 Animation animation = Animation::New(durationSeconds);
628 Vector3 targetPosition(10.0f, 10.0f, 10.0f);
629 animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear);
631 application.SendNotification();
632 application.Render(static_cast<unsigned int>(durationSeconds*0.5f*1000.0f)/*Only half the animation*/);
636 application.SendNotification();
637 application.Render();
639 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
645 int UtcDaliAnimationGetDisconnectAction(void)
647 TestApplication application;
648 Animation animation = Animation::New(1.0f);
649 DALI_TEST_CHECK(animation.GetDisconnectAction() == Animation::BakeFinal); // default!
651 animation.SetDisconnectAction(Animation::Discard);
652 DALI_TEST_CHECK(animation.GetDisconnectAction() == Animation::Discard);
654 animation.SetDisconnectAction(Animation::Bake);
655 DALI_TEST_CHECK(animation.GetDisconnectAction() == Animation::Bake);
660 int UtcDaliAnimationSetDefaultAlphaFunction(void)
662 TestApplication application;
664 Animation animation = Animation::New(1.0f);
665 AlphaFunction func = animation.GetDefaultAlphaFunction();
666 DALI_TEST_EQUALS(func(0.1f), AlphaFunctions::Linear(0.1f), TEST_LOCATION);
668 animation.SetDefaultAlphaFunction(AlphaFunctions::EaseIn);
669 AlphaFunction func2 = animation.GetDefaultAlphaFunction();
670 DALI_TEST_CHECK(func2(0.1f) < AlphaFunctions::Linear(0.1f)); // less progress when easing-in
674 int UtcDaliAnimationGetDefaultAlphaFunction(void)
676 TestApplication application;
678 Animation animation = Animation::New(1.0f);
679 AlphaFunction func = animation.GetDefaultAlphaFunction();
681 // Test that the default is linear
682 DALI_TEST_EQUALS(func(0.1f), AlphaFunctions::Linear(0.1f), TEST_LOCATION);
686 int UtcDaliAnimationPlay(void)
688 TestApplication application;
690 Actor actor = Actor::New();
691 Stage::GetCurrent().Add(actor);
693 // Build the animation
694 float durationSeconds(1.0f);
695 Animation animation = Animation::New(durationSeconds);
696 Vector3 targetPosition(100.0f, 100.0f, 100.0f);
697 animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear);
699 // Start the animation
702 bool signalReceived(false);
703 AnimationFinishCheck finishCheck(signalReceived);
704 animation.FinishedSignal().Connect(&application, finishCheck);
706 application.SendNotification();
707 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 20% progress */);
709 // We didn't expect the animation to finish yet
710 application.SendNotification();
711 finishCheck.CheckSignalNotReceived();
712 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION );
714 animation.Play(); // Test that calling play has no effect, when animation is already playing
715 application.SendNotification();
716 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 40% progress */);
718 // We didn't expect the animation to finish yet
719 application.SendNotification();
720 finishCheck.CheckSignalNotReceived();
721 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.4f), TEST_LOCATION );
723 animation.Play(); // Test that calling play has no effect, when animation is already playing
724 application.SendNotification();
725 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 60% progress */);
727 // We didn't expect the animation to finish yet
728 application.SendNotification();
729 finishCheck.CheckSignalNotReceived();
730 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.6f), TEST_LOCATION );
732 animation.Play(); // Test that calling play has no effect, when animation is already playing
733 application.SendNotification();
734 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 80% progress */);
736 // We didn't expect the animation to finish yet
737 application.SendNotification();
738 finishCheck.CheckSignalNotReceived();
739 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.8f), TEST_LOCATION );
741 animation.Play(); // Test that calling play has no effect, when animation is already playing
742 application.SendNotification();
743 application.Render(static_cast<unsigned int>(durationSeconds*200.0f) + 1u/*just beyond the animation duration*/);
745 // We did expect the animation to finish
746 application.SendNotification();
747 finishCheck.CheckSignalReceived();
748 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
750 // Check that nothing has changed after a couple of buffer swaps
751 application.Render(0);
752 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
753 application.Render(0);
754 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
758 int UtcDaliAnimationSetSpeedFactor(void)
760 TestApplication application;
762 Actor actor = Actor::New();
763 Stage::GetCurrent().Add(actor);
765 // Build the animation
766 float durationSeconds(1.0f);
767 Animation animation = Animation::New(durationSeconds);
769 const Vector3 initialPosition(0.0f, 0.0f, 0.0f);
770 const Vector3 targetPosition(100.0f, 100.0f, 100.0f);
772 KeyFrames keyframes = KeyFrames::New();
773 keyframes.Add( 0.0f, initialPosition);
774 keyframes.Add( 1.0f, targetPosition );
775 animation.AnimateBetween( Property(actor, Actor::POSITION), keyframes, AlphaFunctions::Linear);
778 animation.SetSpeedFactor(2.0f);
780 // Start the animation
783 bool signalReceived(false);
784 AnimationFinishCheck finishCheck(signalReceived);
785 animation.FinishedSignal().Connect(&application, finishCheck);
787 application.SendNotification();
788 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 40% progress */);
790 // We didn't expect the animation to finish yet
791 application.SendNotification();
792 finishCheck.CheckSignalNotReceived();
793 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.4f), TEST_LOCATION );
795 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 80% progress */);
797 // We didn't expect the animation to finish yet
798 application.SendNotification();
799 finishCheck.CheckSignalNotReceived();
800 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.8f), TEST_LOCATION );
802 application.Render(static_cast<unsigned int>(durationSeconds*100.0f) + 1u/*just beyond half the duration*/);
804 // We did expect the animation to finish
805 application.SendNotification();
806 finishCheck.CheckSignalReceived();
807 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
809 // Check that nothing has changed after a couple of buffer swaps
810 application.Render(0);
811 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
812 application.Render(0);
813 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
817 //Test -1 speed factor. Animation will play in reverse at normal speed
818 animation.SetSpeedFactor( -1.0f );
820 // Start the animation
823 application.SendNotification();
824 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 80% progress */);
826 // We didn't expect the animation to finish yet
827 application.SendNotification();
828 finishCheck.CheckSignalNotReceived();
829 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.8f), TEST_LOCATION );
831 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 60% progress */);
833 // We didn't expect the animation to finish yet
834 application.SendNotification();
835 finishCheck.CheckSignalNotReceived();
836 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.6f), TEST_LOCATION );
838 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 40% progress */);
840 // We didn't expect the animation to finish yet
841 application.SendNotification();
842 finishCheck.CheckSignalNotReceived();
843 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.4f), TEST_LOCATION );
845 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 20% progress */);
847 // We didn't expect the animation to finish yet
848 application.SendNotification();
849 finishCheck.CheckSignalNotReceived();
850 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION );
852 application.Render(static_cast<unsigned int>(durationSeconds*200.0f) + 1u/*just beyond the animation duration*/);
854 // We did expect the animation to finish
855 application.SendNotification();
856 finishCheck.CheckSignalReceived();
857 DALI_TEST_EQUALS( actor.GetCurrentPosition(), initialPosition, TEST_LOCATION );
859 // Check that nothing has changed after a couple of buffer swaps
860 application.Render(0);
861 DALI_TEST_EQUALS( initialPosition, actor.GetCurrentPosition(), TEST_LOCATION );
862 application.Render(0);
863 DALI_TEST_EQUALS( initialPosition, actor.GetCurrentPosition(), TEST_LOCATION );
866 //Test change speed factor on the fly
869 //Set speed to be half of normal speed
870 animation.SetSpeedFactor( 0.5f );
872 // Start the animation
875 application.SendNotification();
876 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 10% progress */);
878 // We didn't expect the animation to finish yet
879 application.SendNotification();
880 finishCheck.CheckSignalNotReceived();
881 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.1f), TEST_LOCATION );
883 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 20% progress */);
885 // We didn't expect the animation to finish yet
886 application.SendNotification();
887 finishCheck.CheckSignalNotReceived();
888 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION );
890 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 30% progress */);
892 // We didn't expect the animation to finish yet
893 application.SendNotification();
894 finishCheck.CheckSignalNotReceived();
895 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.3f), TEST_LOCATION );
897 //Change speed factor while animation still playing.
898 animation.SetSpeedFactor(-1.0f);
899 application.SendNotification();
900 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 10% progress */);
902 // We didn't expect the animation to finish yet
903 application.SendNotification();
904 finishCheck.CheckSignalNotReceived();
905 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.1f), TEST_LOCATION );
907 application.Render(static_cast<unsigned int>(durationSeconds*100.0f) + 1u/*just beyond the animation duration*/);
909 // We did expect the animation to finish
910 application.SendNotification();
911 finishCheck.CheckSignalReceived();
912 DALI_TEST_EQUALS( actor.GetCurrentPosition(), initialPosition, TEST_LOCATION );
914 // Check that nothing has changed after a couple of buffer swaps
915 application.Render(0);
916 DALI_TEST_EQUALS( initialPosition, actor.GetCurrentPosition(), TEST_LOCATION );
917 application.Render(0);
918 DALI_TEST_EQUALS( initialPosition, actor.GetCurrentPosition(), TEST_LOCATION );
922 int UtcDaliAnimationGetSpeedFactor(void)
924 TestApplication application;
926 Animation animation = Animation::New(1.0f);
927 animation.SetSpeedFactor(0.5f);
928 DALI_TEST_EQUALS(animation.GetSpeedFactor(), 0.5f, TEST_LOCATION);
930 animation.SetSpeedFactor(-2.5f);
931 DALI_TEST_EQUALS(animation.GetSpeedFactor(), -2.5f, TEST_LOCATION);
935 int UtcDaliAnimationPlayOffStage(void)
937 // Test that an animation can be played, when the actor is off-stage.
938 // When the actor is added to the stage, it should appear at the current position
939 // i.e. where it would have been anyway, if on-stage from the beginning.
941 TestApplication application;
943 Actor actor = Actor::New();
944 Vector3 basePosition(Vector3::ZERO);
945 DALI_TEST_EQUALS( actor.GetCurrentPosition(), basePosition, TEST_LOCATION );
946 // Not added to the stage!
948 // Build the animation
949 float durationSeconds(1.0f);
950 Animation animation = Animation::New(durationSeconds);
951 animation.SetDisconnectAction( Animation::Discard );
952 Vector3 targetPosition(100.0f, 100.0f, 100.0f);
953 animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear);
955 // Start the animation
958 bool signalReceived(false);
959 AnimationFinishCheck finishCheck(signalReceived);
960 animation.FinishedSignal().Connect(&application, finishCheck);
962 application.SendNotification();
963 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 20% 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/*off-stage*/, TEST_LOCATION );
971 Stage::GetCurrent().Add(actor);
973 application.SendNotification();
974 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 40% progress */);
976 // We didn't expect the animation to finish yet
977 application.SendNotification();
978 finishCheck.CheckSignalNotReceived();
979 Vector3 expectedPosition(basePosition + (targetPosition - basePosition)*0.4f);
980 DALI_TEST_EQUALS( actor.GetCurrentPosition(), expectedPosition/*on-stage*/, TEST_LOCATION );
982 // Remove from the stage
983 Stage::GetCurrent().Remove(actor);
985 application.SendNotification();
986 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 60% progress */);
988 // We didn't expect the animation to finish yet
989 application.SendNotification();
990 finishCheck.CheckSignalNotReceived();
991 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO/*back to start position*/, TEST_LOCATION );
994 Stage::GetCurrent().Add(actor);
996 application.SendNotification();
997 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 80% progress */);
999 // We didn't expect the animation to finish yet
1000 application.SendNotification();
1001 finishCheck.CheckSignalNotReceived();
1002 expectedPosition = Vector3(basePosition + (targetPosition - basePosition)*0.8f);
1003 DALI_TEST_EQUALS( actor.GetCurrentPosition(), expectedPosition, TEST_LOCATION );
1005 application.SendNotification();
1006 application.Render(static_cast<unsigned int>(durationSeconds*200.0f) + 1u/*just beyond the animation duration*/);
1008 // We did expect the animation to finish
1009 application.SendNotification();
1010 finishCheck.CheckSignalReceived();
1011 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
1013 // Check that nothing has changed after a couple of buffer swaps
1014 application.Render(0);
1015 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
1016 application.Render(0);
1017 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
1021 int UtcDaliAnimationPlayDiscardHandle(void)
1023 TestApplication application;
1025 Actor actor = Actor::New();
1026 Stage::GetCurrent().Add(actor);
1028 // Build the animation
1029 float durationSeconds(1.0f);
1030 Animation animation = Animation::New(durationSeconds);
1031 Vector3 targetPosition(100.0f, 100.0f, 100.0f);
1032 animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear);
1034 bool signalReceived(false);
1035 AnimationFinishCheck finishCheck(signalReceived);
1036 animation.FinishedSignal().Connect(&application, finishCheck);
1038 // Start the animation
1041 // This is a test of the "Fire and Forget" behaviour
1042 // Discard the animation handle!
1044 DALI_TEST_CHECK( !animation );
1046 application.SendNotification();
1047 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 20% progress */);
1049 // We didn't expect the animation to finish yet
1050 application.SendNotification();
1051 finishCheck.CheckSignalNotReceived();
1052 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION );
1054 application.SendNotification();
1055 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 40% progress */);
1057 // We didn't expect the animation to finish yet
1058 application.SendNotification();
1059 finishCheck.CheckSignalNotReceived();
1060 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.4f), TEST_LOCATION );
1062 application.SendNotification();
1063 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 60% progress */);
1065 // We didn't expect the animation to finish yet
1066 application.SendNotification();
1067 finishCheck.CheckSignalNotReceived();
1068 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.6f), TEST_LOCATION );
1070 application.SendNotification();
1071 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 80% progress */);
1073 // We didn't expect the animation to finish yet
1074 application.SendNotification();
1075 finishCheck.CheckSignalNotReceived();
1076 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.8f), TEST_LOCATION );
1078 application.SendNotification();
1079 application.Render(static_cast<unsigned int>(durationSeconds*200.0f) + 1u/*just beyond the animation duration*/);
1081 // We did expect the animation to finish
1082 application.SendNotification();
1083 finishCheck.CheckSignalReceived();
1084 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
1086 // Check that nothing has changed after a couple of buffer swaps
1087 application.Render(0);
1088 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
1089 application.Render(0);
1090 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
1094 int UtcDaliAnimationPlayStopDiscardHandle(void)
1096 TestApplication application;
1098 Actor actor = Actor::New();
1099 Stage::GetCurrent().Add(actor);
1101 // Build the animation
1102 float durationSeconds(1.0f);
1103 Animation animation = Animation::New(durationSeconds);
1104 Vector3 targetPosition(100.0f, 100.0f, 100.0f);
1105 animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear);
1107 // Start the animation
1110 bool signalReceived(false);
1111 AnimationFinishCheck finishCheck(signalReceived);
1112 animation.FinishedSignal().Connect(&application, finishCheck);
1114 application.SendNotification();
1115 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 20% progress */);
1117 // We didn't expect the animation to finish yet
1118 application.SendNotification();
1119 finishCheck.CheckSignalNotReceived();
1120 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION );
1122 // This is a test of the "Fire and Forget" behaviour
1123 // Stop the animation, and Discard the animation handle!
1126 DALI_TEST_CHECK( !animation );
1128 application.SendNotification();
1129 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 40% progress */);
1131 // We expect the animation to finish at 20% progress
1132 application.SendNotification();
1133 finishCheck.CheckSignalReceived();
1134 finishCheck.Reset();
1135 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION );
1137 application.SendNotification();
1138 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 60% progress */);
1140 // Check that nothing has changed
1141 application.SendNotification();
1142 finishCheck.CheckSignalNotReceived();
1143 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION );
1145 application.SendNotification();
1146 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 80% progress */);
1148 // Check that nothing has changed
1149 application.SendNotification();
1150 finishCheck.CheckSignalNotReceived();
1151 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION );
1153 application.SendNotification();
1154 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 100% progress */);
1156 // Check that nothing has changed
1157 application.SendNotification();
1158 finishCheck.CheckSignalNotReceived();
1159 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION );
1163 int UtcDaliAnimationPlayFrom(void)
1165 TestApplication application;
1167 Actor actor = Actor::New();
1168 Stage::GetCurrent().Add(actor);
1170 // Build the animation
1171 float durationSeconds(1.0f);
1172 Animation animation = Animation::New(durationSeconds);
1173 Vector3 targetPosition(100.0f, 100.0f, 100.0f);
1174 animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear);
1176 //PlayFrom with an argument outside the range [0..1] will be ignored
1177 animation.PlayFrom(-1.0f);
1178 application.SendNotification();
1179 DALI_TEST_EQUALS(0.0f, animation.GetCurrentProgress(), TEST_LOCATION );
1181 animation.PlayFrom(100.0f);
1182 application.SendNotification();
1183 DALI_TEST_EQUALS(0.0f, animation.GetCurrentProgress(), TEST_LOCATION );
1185 // Start the animation from 40% progress
1186 animation.PlayFrom( 0.4f );
1188 bool signalReceived(false);
1189 AnimationFinishCheck finishCheck(signalReceived);
1190 animation.FinishedSignal().Connect(&application, finishCheck);
1192 application.SendNotification();
1193 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 60% progress */);
1195 // We didn't expect the animation to finish yet
1196 application.SendNotification();
1197 finishCheck.CheckSignalNotReceived();
1198 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.6f), TEST_LOCATION );
1200 animation.Play(); // Test that calling play has no effect, when animation is already playing
1201 application.SendNotification();
1202 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 80% progress */);
1204 // We didn't expect the animation to finish yet
1205 application.SendNotification();
1206 finishCheck.CheckSignalNotReceived();
1207 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.8f), TEST_LOCATION );
1209 application.Render(static_cast<unsigned int>(durationSeconds*200.0f) + 1u/*just beyond the animation duration*/);
1210 // We did expect the animation to finish
1211 application.SendNotification();
1212 finishCheck.CheckSignalReceived();
1213 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
1215 // Check that nothing has changed after a couple of buffer swaps
1216 application.Render(0);
1217 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
1218 application.Render(0);
1219 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
1223 int UtcDaliAnimationSetCurrentProgress(void)
1225 TestApplication application;
1227 Actor actor = Actor::New();
1228 Stage::GetCurrent().Add(actor);
1230 // Build the animation
1231 Animation animation = Animation::New(0.0f);
1234 //Test GetCurrentProgress return 0.0 as the duration is 0.0
1235 DALI_TEST_EQUALS( 0.0f, animation.GetCurrentProgress(), TEST_LOCATION );
1237 animation.SetCurrentProgress( 0.5f );
1238 application.SendNotification();
1239 application.Render(static_cast<unsigned int>(100.0f));
1241 //Progress should still be 0.0
1242 DALI_TEST_EQUALS( 0.0f, animation.GetCurrentProgress(), TEST_LOCATION );
1245 float durationSeconds(1.0f);
1246 animation.SetDuration(durationSeconds);
1247 application.SendNotification();
1249 bool signalReceived(false);
1250 AnimationFinishCheck finishCheck(signalReceived);
1251 animation.FinishedSignal().Connect(&application, finishCheck);
1252 application.SendNotification();
1254 Vector3 targetPosition(100.0f, 100.0f, 100.0f);
1255 animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear);
1257 //Trying to set the current cursor outside the range [0..1] is ignored
1258 animation.SetCurrentProgress( -1.0f);
1259 application.SendNotification();
1260 DALI_TEST_EQUALS( 0.0f, animation.GetCurrentProgress(), TEST_LOCATION );
1262 animation.SetCurrentProgress( 100.0f);
1263 application.SendNotification();
1264 DALI_TEST_EQUALS( 0.0f, animation.GetCurrentProgress(), TEST_LOCATION );
1266 // Start the animation from 40% progress
1267 animation.SetCurrentProgress( 0.4f );
1270 application.SendNotification();
1271 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 60% progress */);
1273 // We didn't expect the animation to finish yet
1274 application.SendNotification();
1275 finishCheck.CheckSignalNotReceived();
1276 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.6f), TEST_LOCATION );
1277 DALI_TEST_EQUALS( 0.6f, animation.GetCurrentProgress(), TEST_LOCATION );
1279 animation.Play(); // Test that calling play has no effect, when animation is already playing
1280 application.SendNotification();
1282 //Set the progress to 70%
1283 animation.SetCurrentProgress( 0.7f );
1284 application.SendNotification();
1285 application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 80% progress */);
1286 DALI_TEST_EQUALS( 0.8f, animation.GetCurrentProgress(), TEST_LOCATION );
1289 application.SendNotification();
1290 finishCheck.CheckSignalNotReceived();
1291 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.8f), TEST_LOCATION );
1292 DALI_TEST_EQUALS( 0.8f, animation.GetCurrentProgress(), TEST_LOCATION );
1296 application.Render(static_cast<unsigned int>(durationSeconds*200.0f) + 1u/*just beyond the animation duration*/);
1297 // We did expect the animation to finish
1298 application.SendNotification();
1299 finishCheck.CheckSignalReceived();
1300 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
1302 // Check that nothing has changed after a couple of buffer swaps
1303 application.Render(0);
1304 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
1305 application.Render(0);
1306 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
1310 int UtcDaliAnimationPlayRange(void)
1312 TestApplication application;
1314 Actor actor = Actor::New();
1315 Stage::GetCurrent().Add(actor);
1317 // Build the animation
1318 float durationSeconds(1.0f);
1319 Animation animation = Animation::New(durationSeconds);
1320 Vector3 targetPosition(100.0f, 100.0f, 100.0f);
1321 KeyFrames keyframes = KeyFrames::New();
1322 keyframes.Add( 0.0f , Vector3(0.0f,0.0f,0.0f ) );
1323 keyframes.Add( 1.0f , Vector3(100.0f,100.0f,100.0f ) );
1325 animation.AnimateBetween( Property( actor, Actor::POSITION), keyframes );
1327 // Set range between 0.4 and 0.8
1328 animation.SetPlayRange( Vector2(0.4f,0.8f) );
1331 bool signalReceived(false);
1332 AnimationFinishCheck finishCheck(signalReceived);
1333 animation.FinishedSignal().Connect(&application, finishCheck);
1335 //Test that setting progress outside the range doesn't work
1336 animation.SetCurrentProgress( 0.9f );
1337 application.SendNotification();
1338 application.Render(0);
1339 DALI_TEST_EQUALS( animation.GetCurrentProgress(), 0.4f, TEST_LOCATION );
1340 animation.SetCurrentProgress( 0.2f );
1341 application.SendNotification();
1342 application.Render(0);
1343 DALI_TEST_EQUALS( animation.GetCurrentProgress(), 0.4f, TEST_LOCATION );
1345 application.SendNotification();
1346 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 60% progress */);
1348 // We didn't expect the animation to finish yet
1349 application.SendNotification();
1350 finishCheck.CheckSignalNotReceived();
1351 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.6f), TEST_LOCATION );
1353 animation.Play(); // Test that calling play has no effect, when animation is already playing
1354 application.SendNotification();
1355 application.Render(static_cast<unsigned int>(durationSeconds*200.0f) + 1u/* 80% progress */);
1357 // We did expect the animation to finish
1358 application.SendNotification();
1359 finishCheck.CheckSignalReceived();
1360 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.8f), TEST_LOCATION );
1362 // Check that nothing has changed after a couple of buffer swaps
1363 application.Render(0);
1364 DALI_TEST_EQUALS( targetPosition * 0.8f, actor.GetCurrentPosition(), TEST_LOCATION );
1365 application.Render(0);
1366 DALI_TEST_EQUALS( targetPosition * 0.8f, actor.GetCurrentPosition(), TEST_LOCATION );
1369 //Loop inside the range
1370 finishCheck.Reset();
1371 animation.SetLooping( true );
1373 application.SendNotification();
1374 float intervalSeconds = 0.1f;
1375 float progress = 0.4f;
1376 for (int iterations = 0; iterations < 10; ++iterations )
1378 application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
1380 progress += intervalSeconds;
1381 if (progress > 0.8f)
1383 progress = progress - 0.4f;
1386 DALI_TEST_EQUALS( targetPosition*progress, actor.GetCurrentPosition(), 0.001f, TEST_LOCATION );
1389 // We didn't expect the animation to finish yet
1390 application.SendNotification();
1391 finishCheck.CheckSignalNotReceived();
1394 //Test change range on the fly
1395 animation.SetPlayRange( Vector2( 0.2f, 0.9f ) );
1396 application.SendNotification();
1398 for (int iterations = 0; iterations < 10; ++iterations )
1400 application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
1402 progress += intervalSeconds;
1403 if (progress > 0.9f)
1405 progress = progress - 0.7f;
1408 DALI_TEST_EQUALS( targetPosition*progress, actor.GetCurrentPosition(), 0.001f, TEST_LOCATION );
1414 int UtcDaliAnimationSetPlayRange(void)
1416 TestApplication application;
1418 Actor actor = Actor::New();
1419 Stage::GetCurrent().Add(actor);
1421 // Build the animation
1422 Animation animation = Animation::New(0);
1423 application.SendNotification();
1425 //If PlayRange not specified it should be 0.0-1.0 by default
1426 DALI_TEST_EQUALS( Vector2(0.0,1.0), animation.GetPlayRange(), TEST_LOCATION );
1428 //PlayRange out of bounds
1429 animation.SetPlayRange( Vector2(-1.0f,1.0f) );
1430 application.SendNotification();
1431 DALI_TEST_EQUALS( Vector2(0.0f,1.0f), animation.GetPlayRange(), TEST_LOCATION );
1432 animation.SetPlayRange( Vector2(0.0f,2.0f) );
1433 application.SendNotification();
1434 DALI_TEST_EQUALS( Vector2(0.0f,1.0f), animation.GetPlayRange(), TEST_LOCATION );
1436 //If playRange is not in the correct order it has to be ordered
1437 animation.SetPlayRange( Vector2(0.8f,0.2f) );
1438 application.SendNotification();
1439 DALI_TEST_EQUALS( Vector2(0.2f,0.8f), animation.GetPlayRange(), TEST_LOCATION );
1441 // Set range between 0.4 and 0.8
1442 animation.SetPlayRange( Vector2(0.4f,0.8f) );
1443 application.SendNotification();
1444 DALI_TEST_EQUALS( Vector2(0.4f,0.8f), animation.GetPlayRange(), TEST_LOCATION );
1449 int UtcDaliAnimationPause(void)
1451 TestApplication application;
1453 Actor actor = Actor::New();
1454 Stage::GetCurrent().Add(actor);
1456 // Build the animation
1457 float durationSeconds(1.0f);
1458 Animation animation = Animation::New(durationSeconds);
1459 Vector3 targetPosition(100.0f, 100.0f, 100.0f);
1460 animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear);
1462 Vector3 fiftyPercentProgress(targetPosition * 0.5f);
1464 // Start the animation
1467 bool signalReceived(false);
1468 AnimationFinishCheck finishCheck(signalReceived);
1469 animation.FinishedSignal().Connect(&application, finishCheck);
1471 application.SendNotification();
1472 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
1474 // We didn't expect the animation to finish yet
1475 application.SendNotification();
1476 finishCheck.CheckSignalNotReceived();
1477 DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress, TEST_LOCATION );
1479 // Pause the animation
1481 application.SendNotification();
1484 for (int i=0; i<5; ++i)
1486 application.Render(static_cast<unsigned int>(durationSeconds*500.0f));
1488 // We didn't expect the animation to finish yet
1489 application.SendNotification();
1490 finishCheck.CheckSignalNotReceived();
1491 DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress/* Still 50% progress when paused */, TEST_LOCATION );
1496 application.SendNotification();
1497 application.Render(static_cast<unsigned int>(durationSeconds*490.0f)/*slightly less than the animation duration*/);
1499 // We didn't expect the animation to finish yet
1500 application.SendNotification();
1501 finishCheck.CheckSignalNotReceived();
1503 application.SendNotification();
1504 application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
1506 // We did expect the animation to finish
1507 application.SendNotification();
1508 finishCheck.CheckSignalReceived();
1509 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
1511 // Check that nothing has changed after a couple of buffer swaps
1512 application.Render(0);
1513 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
1514 application.Render(0);
1515 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
1519 int UtcDaliAnimationStop(void)
1521 TestApplication application;
1523 Actor actor = Actor::New();
1524 Stage::GetCurrent().Add(actor);
1526 // Build the animation
1527 float durationSeconds(1.0f);
1528 Animation animation = Animation::New(durationSeconds);
1529 Vector3 targetPosition(100.0f, 100.0f, 100.0f);
1530 animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear);
1532 Vector3 fiftyPercentProgress(targetPosition * 0.5f);
1534 // Start the animation
1537 bool signalReceived(false);
1538 AnimationFinishCheck finishCheck(signalReceived);
1539 animation.FinishedSignal().Connect(&application, finishCheck);
1541 application.SendNotification();
1542 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
1544 // We didn't expect the animation to finish yet
1545 application.SendNotification();
1546 finishCheck.CheckSignalNotReceived();
1547 DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress, TEST_LOCATION );
1549 // Stop the animation
1551 application.SendNotification();
1554 for (int i=0; i<5; ++i)
1556 application.Render(static_cast<unsigned int>(durationSeconds*500.0f));
1558 // We did expect the animation to finish
1559 application.SendNotification();
1560 finishCheck.CheckSignalReceived();
1561 DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress/* Still 50% progress when stopped */, TEST_LOCATION );
1566 int UtcDaliAnimationStopSetPosition(void)
1568 // Test that Animation::Stop & Actor::SetPosition can be used in conjunction
1569 // i.e. to check that the animation does not interfere with the position set.
1571 TestApplication application;
1573 Actor actor = Actor::New();
1574 Stage::GetCurrent().Add(actor);
1576 // Build the animation
1577 float durationSeconds(1.0f);
1578 Animation animation = Animation::New(durationSeconds);
1579 Vector3 targetPosition(100.0f, 100.0f, 100.0f);
1580 animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear);
1582 Vector3 fiftyPercentProgress(targetPosition * 0.5f);
1584 // Start the animation
1587 bool signalReceived(false);
1588 AnimationFinishCheck finishCheck(signalReceived);
1589 animation.FinishedSignal().Connect(&application, finishCheck);
1591 application.SendNotification();
1592 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
1594 // We didn't expect the animation to finish yet
1595 application.SendNotification();
1596 finishCheck.CheckSignalNotReceived();
1597 DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress, TEST_LOCATION );
1599 // Stop the animation
1601 Vector3 positionSet(2.0f, 3.0f, 4.0f);
1602 actor.SetPosition(positionSet);
1603 application.SendNotification();
1606 for (int i=0; i<5; ++i)
1608 application.Render(static_cast<unsigned int>(durationSeconds*500.0f));
1610 // We did expect the animation to finish
1611 application.SendNotification();
1612 finishCheck.CheckSignalReceived();
1613 DALI_TEST_EQUALS( actor.GetCurrentPosition(), positionSet/*Animation should not interfere with this*/, TEST_LOCATION );
1618 int UtcDaliAnimationClear(void)
1620 TestApplication application;
1622 Actor actor = Actor::New();
1623 Stage::GetCurrent().Add(actor);
1625 // Build the animation
1626 float durationSeconds(1.0f);
1627 Animation animation = Animation::New(durationSeconds);
1628 Vector3 targetPosition(100.0f, 100.0f, 100.0f);
1629 animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear);
1631 Vector3 fiftyPercentProgress(targetPosition * 0.5f);
1633 // Start the animation
1636 bool signalReceived(false);
1637 AnimationFinishCheck finishCheck(signalReceived);
1638 animation.FinishedSignal().Connect(&application, finishCheck);
1640 application.SendNotification();
1641 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
1643 // We didn't expect the animation to finish yet
1644 application.SendNotification();
1645 finishCheck.CheckSignalNotReceived();
1646 DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress, TEST_LOCATION );
1648 // Clear the animation
1650 application.SendNotification();
1652 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
1654 // We don't expect the animation to finish now
1655 application.SendNotification();
1656 finishCheck.CheckSignalNotReceived();
1657 DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress/* Still 50% progress since the animator was destroyed */, TEST_LOCATION );
1659 // Restart as a scale animation; this should not move the actor's position
1660 finishCheck.Reset();
1661 actor.SetPosition(Vector3::ZERO);
1662 Vector3 targetScale(3.0f, 3.0f, 3.0f);
1663 animation.ScaleTo(actor, targetScale, AlphaFunctions::Linear);
1666 application.SendNotification();
1667 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
1669 // We didn't expect the animation to finish yet
1670 application.SendNotification();
1671 finishCheck.CheckSignalNotReceived();
1672 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO/*Check move-animator was destroyed*/, TEST_LOCATION );
1673 DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3(2.0f, 2.0f, 2.0f), TEST_LOCATION );
1675 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
1677 // We did expect the animation to finish
1678 application.SendNotification();
1679 finishCheck.CheckSignalReceived();
1680 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO/*Check move-animator was destroyed*/, TEST_LOCATION );
1681 DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
1685 int UtcDaliAnimationSignalFinish(void)
1687 TestApplication application;
1689 // Start the empty animation
1690 float durationSeconds(1.0f);
1691 Animation animation = Animation::New(durationSeconds);
1694 bool signalReceived(false);
1695 AnimationFinishCheck finishCheck(signalReceived);
1696 animation.FinishedSignal().Connect(&application, finishCheck);
1698 application.SendNotification();
1699 application.Render(static_cast<unsigned int>(durationSeconds*1000.0f) + 1u/*beyond the animation duration*/);
1701 // We did expect the animation to finish
1702 application.SendNotification();
1703 finishCheck.CheckSignalReceived();
1707 int UtcDaliAnimationAnimateByBoolean(void)
1709 TestApplication application;
1711 Actor actor = Actor::New();
1713 // Register a boolean property
1714 bool startValue(false);
1715 Property::Index index = actor.RegisterProperty( "test-property", startValue );
1716 Stage::GetCurrent().Add(actor);
1717 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
1719 // Build the animation
1720 float durationSeconds(2.0f);
1721 Animation animation = Animation::New(durationSeconds);
1722 const bool relativeValue(true);
1723 const bool finalValue( false || relativeValue );
1724 animation.AnimateBy(Property(actor, index), relativeValue);
1726 // Start the animation
1729 bool signalReceived(false);
1730 AnimationFinishCheck finishCheck(signalReceived);
1731 animation.FinishedSignal().Connect(&application, finishCheck);
1733 application.SendNotification();
1734 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
1736 // We didn't expect the animation to finish yet
1737 application.SendNotification();
1738 finishCheck.CheckSignalNotReceived();
1739 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
1741 application.SendNotification();
1742 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
1744 // We did expect the animation to finish
1745 application.SendNotification();
1746 finishCheck.CheckSignalReceived();
1747 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1749 // Check that nothing has changed after a couple of buffer swaps
1750 application.Render(0);
1751 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1752 application.Render(0);
1753 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1755 // Repeat with relative value "false" - this should be an NOOP
1756 animation = Animation::New(durationSeconds);
1757 bool noOpValue(false);
1758 animation.AnimateBy(Property(actor, index), noOpValue);
1760 // Start the animation
1763 finishCheck.Reset();
1764 animation.FinishedSignal().Connect(&application, finishCheck);
1766 application.SendNotification();
1767 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
1769 // We didn't expect the animation to finish yet
1770 application.SendNotification();
1771 finishCheck.CheckSignalNotReceived();
1772 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1774 application.SendNotification();
1775 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
1777 // We did expect the animation to finish
1778 application.SendNotification();
1779 finishCheck.CheckSignalReceived();
1780 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1782 // Check that nothing has changed after a couple of buffer swaps
1783 application.Render(0);
1784 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1785 application.Render(0);
1786 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1790 int UtcDaliAnimationAnimateByBooleanAlphaFunction(void)
1792 TestApplication application;
1794 Actor actor = Actor::New();
1796 // Register a boolean property
1797 bool startValue(false);
1798 Property::Index index = actor.RegisterProperty( "test-property", startValue );
1799 Stage::GetCurrent().Add(actor);
1800 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
1802 // Build the animation
1803 float durationSeconds(2.0f);
1804 Animation animation = Animation::New(durationSeconds);
1805 bool relativeValue(true);
1806 bool finalValue( false || relativeValue );
1807 animation.AnimateBy(Property(actor, index), relativeValue, AlphaFunctions::EaseIn);
1809 // Start the animation
1812 bool signalReceived(false);
1813 AnimationFinishCheck finishCheck(signalReceived);
1814 animation.FinishedSignal().Connect(&application, finishCheck);
1816 application.SendNotification();
1817 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
1819 // We didn't expect the animation to finish yet
1820 application.SendNotification();
1821 finishCheck.CheckSignalNotReceived();
1822 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
1824 application.SendNotification();
1825 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
1827 // We did expect the animation to finish
1828 application.SendNotification();
1829 finishCheck.CheckSignalReceived();
1830 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1832 // Check that nothing has changed after a couple of buffer swaps
1833 application.Render(0);
1834 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1835 application.Render(0);
1836 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1838 // Repeat with relative value "false" - this should be an NOOP
1839 animation = Animation::New(durationSeconds);
1840 bool noOpValue(false);
1841 animation.AnimateBy(Property(actor, index), noOpValue, AlphaFunctions::EaseIn);
1843 // Start the animation
1846 finishCheck.Reset();
1847 animation.FinishedSignal().Connect(&application, finishCheck);
1849 application.SendNotification();
1850 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
1852 // We didn't expect the animation to finish yet
1853 application.SendNotification();
1854 finishCheck.CheckSignalNotReceived();
1855 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1857 application.SendNotification();
1858 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
1860 // We did expect the animation to finish
1861 application.SendNotification();
1862 finishCheck.CheckSignalReceived();
1863 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1867 int UtcDaliAnimationAnimateByBooleanTimePeriod(void)
1869 TestApplication application;
1871 Actor actor = Actor::New();
1873 // Register a boolean property
1874 bool startValue(false);
1875 Property::Index index = actor.RegisterProperty( "test-property", startValue );
1876 Stage::GetCurrent().Add(actor);
1877 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
1879 // Build the animation
1880 float durationSeconds(2.0f);
1881 Animation animation = Animation::New(durationSeconds);
1882 bool relativeValue(true);
1883 bool finalValue( false || relativeValue );
1884 float animatorDurationSeconds(durationSeconds * 0.5f);
1885 animation.AnimateBy( Property(actor, index),
1887 TimePeriod( animatorDurationSeconds ) );
1889 // Start the animation
1892 bool signalReceived(false);
1893 AnimationFinishCheck finishCheck(signalReceived);
1894 animation.FinishedSignal().Connect(&application, finishCheck);
1896 application.SendNotification();
1897 application.Render(static_cast<unsigned int>(animatorDurationSeconds*950.0f)/* 95% animator progress */);
1899 // We didn't expect the animation to finish yet
1900 application.SendNotification();
1901 finishCheck.CheckSignalNotReceived();
1902 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
1904 application.SendNotification();
1905 application.Render(static_cast<unsigned int>(animatorDurationSeconds*50.0f) + 1u/*just beyond the animator duration*/);
1907 // We didn't expect the animation to finish yet...
1908 application.SendNotification();
1909 finishCheck.CheckSignalNotReceived();
1911 // ...however we should have reached the final value
1912 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1914 application.SendNotification();
1915 application.Render(static_cast<unsigned int>(animatorDurationSeconds*1000.0f)/*just beyond the animation duration*/);
1917 // We did expect the animation to finish
1918 application.SendNotification();
1919 finishCheck.CheckSignalReceived();
1920 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1922 // Check that nothing has changed after a couple of buffer swaps
1923 application.Render(0);
1924 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1925 application.Render(0);
1926 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1930 int UtcDaliAnimationAnimateByBooleanAlphaFunctionTimePeriod(void)
1932 TestApplication application;
1934 Actor actor = Actor::New();
1936 // Register a boolean property
1937 bool startValue(false);
1938 Property::Index index = actor.RegisterProperty( "test-property", startValue );
1939 Stage::GetCurrent().Add(actor);
1940 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
1942 // Build the animation
1943 float durationSeconds(2.0f);
1944 Animation animation = Animation::New(durationSeconds);
1945 bool relativeValue(true);
1946 bool finalValue( false || relativeValue );
1947 float animatorDurationSeconds(durationSeconds * 0.5f);
1948 animation.AnimateBy( Property(actor, index),
1950 AlphaFunctions::EaseInOut,
1951 TimePeriod( animatorDurationSeconds ) );
1953 // Start the animation
1956 bool signalReceived(false);
1957 AnimationFinishCheck finishCheck(signalReceived);
1958 animation.FinishedSignal().Connect(&application, finishCheck);
1960 application.SendNotification();
1961 application.Render(static_cast<unsigned int>(animatorDurationSeconds*950.0f)/* 95% animator progress */);
1963 // We didn't expect the animation to finish yet
1964 application.SendNotification();
1965 finishCheck.CheckSignalNotReceived();
1966 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
1968 application.SendNotification();
1969 application.Render(static_cast<unsigned int>(animatorDurationSeconds*50.0f) + 1u/*just beyond the animator duration*/);
1971 // We didn't expect the animation to finish yet...
1972 application.SendNotification();
1973 finishCheck.CheckSignalNotReceived();
1975 // ...however we should have reached the final value
1976 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1978 application.SendNotification();
1979 application.Render(static_cast<unsigned int>(animatorDurationSeconds*1000.0f)/*just beyond the animation duration*/);
1981 // We did expect the animation to finish
1982 application.SendNotification();
1983 finishCheck.CheckSignalReceived();
1984 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1986 // Check that nothing has changed after a couple of buffer swaps
1987 application.Render(0);
1988 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1989 application.Render(0);
1990 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1994 int UtcDaliAnimationAnimateByFloat(void)
1996 TestApplication application;
1998 Actor actor = Actor::New();
2000 // Register a float property
2001 float startValue(10.0f);
2002 Property::Index index = actor.RegisterProperty( "test-property", startValue );
2003 Stage::GetCurrent().Add(actor);
2004 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
2006 // Build the animation
2007 float durationSeconds(2.0f);
2008 Animation animation = Animation::New(durationSeconds);
2009 float targetValue(50.0f);
2010 float relativeValue(targetValue - startValue);
2011 animation.AnimateBy(Property(actor, index), relativeValue);
2013 float ninetyFivePercentProgress(startValue + relativeValue*0.95f);
2015 // Start the animation
2018 bool signalReceived(false);
2019 AnimationFinishCheck finishCheck(signalReceived);
2020 animation.FinishedSignal().Connect(&application, finishCheck);
2022 application.SendNotification();
2023 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
2025 // We didn't expect the animation to finish yet
2026 application.SendNotification();
2027 finishCheck.CheckSignalNotReceived();
2028 DALI_TEST_EQUALS( actor.GetProperty<float>(index), ninetyFivePercentProgress, TEST_LOCATION );
2030 application.SendNotification();
2031 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
2033 // We did expect the animation to finish
2034 application.SendNotification();
2035 finishCheck.CheckSignalReceived();
2036 DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
2038 // Check that nothing has changed after a couple of buffer swaps
2039 application.Render(0);
2040 DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
2041 application.Render(0);
2042 DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
2046 int UtcDaliAnimationAnimateByFloatAlphaFunction(void)
2048 TestApplication application;
2050 Actor actor = Actor::New();
2052 // Register a float property
2053 float startValue(10.0f);
2054 Property::Index index = actor.RegisterProperty( "test-property", startValue );
2055 Stage::GetCurrent().Add(actor);
2056 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
2058 // Build the animation
2059 float durationSeconds(1.0f);
2060 Animation animation = Animation::New(durationSeconds);
2061 float targetValue(90.0f);
2062 float relativeValue(targetValue - startValue);
2063 animation.AnimateBy(Property(actor, index), relativeValue, AlphaFunctions::EaseOut);
2065 float ninetyFivePercentProgress(startValue + relativeValue*0.95f);
2067 // Start the animation
2070 bool signalReceived(false);
2071 AnimationFinishCheck finishCheck(signalReceived);
2072 animation.FinishedSignal().Connect(&application, finishCheck);
2074 application.SendNotification();
2075 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
2077 // We didn't expect the animation to finish yet
2078 application.SendNotification();
2079 finishCheck.CheckSignalNotReceived();
2081 // The position should have moved more, than with a linear alpha function
2082 float current(actor.GetProperty<float>(index));
2083 DALI_TEST_CHECK( current > ninetyFivePercentProgress );
2085 application.SendNotification();
2086 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
2088 // We did expect the animation to finish
2089 application.SendNotification();
2090 finishCheck.CheckSignalReceived();
2091 DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
2093 // Check that nothing has changed after a couple of buffer swaps
2094 application.Render(0);
2095 DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
2096 application.Render(0);
2097 DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
2101 int UtcDaliAnimationAnimateByFloatTimePeriod(void)
2103 TestApplication application;
2105 Actor actor = Actor::New();
2107 // Register a float property
2108 float startValue(10.0f);
2109 Property::Index index = actor.RegisterProperty( "test-property", startValue );
2110 Stage::GetCurrent().Add(actor);
2111 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
2113 // Build the animation
2114 float durationSeconds(1.0f);
2115 Animation animation = Animation::New(durationSeconds);
2116 float targetValue(30.0f);
2117 float relativeValue(targetValue - startValue);
2119 animation.AnimateBy(Property(actor, index),
2121 TimePeriod(delay, durationSeconds - delay));
2123 // Start the animation
2126 bool signalReceived(false);
2127 AnimationFinishCheck finishCheck(signalReceived);
2128 animation.FinishedSignal().Connect(&application, finishCheck);
2130 application.SendNotification();
2131 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
2133 // We didn't expect the animation to finish yet
2134 application.SendNotification();
2135 finishCheck.CheckSignalNotReceived();
2136 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
2138 application.SendNotification();
2139 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
2141 // We didn't expect the animation to finish yet
2142 application.SendNotification();
2143 finishCheck.CheckSignalNotReceived();
2144 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
2146 application.SendNotification();
2147 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
2149 // We did expect the animation to finish
2150 application.SendNotification();
2151 finishCheck.CheckSignalReceived();
2152 DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
2154 // Check that nothing has changed after a couple of buffer swaps
2155 application.Render(0);
2156 DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
2157 application.Render(0);
2158 DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
2162 int UtcDaliAnimationAnimateByFloatAlphaFunctionTimePeriod(void)
2164 TestApplication application;
2166 Actor actor = Actor::New();
2168 // Register a float property
2169 float startValue(10.0f);
2170 Property::Index index = actor.RegisterProperty( "test-property", startValue );
2171 Stage::GetCurrent().Add(actor);
2172 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
2174 // Build the animation
2175 float durationSeconds(1.0f);
2176 Animation animation = Animation::New(durationSeconds);
2177 float targetValue(30.0f);
2178 float relativeValue(targetValue - startValue);
2180 animation.AnimateBy(Property(actor, index),
2182 AlphaFunctions::Linear,
2183 TimePeriod(delay, durationSeconds - delay));
2185 // Start the animation
2188 bool signalReceived(false);
2189 AnimationFinishCheck finishCheck(signalReceived);
2190 animation.FinishedSignal().Connect(&application, finishCheck);
2192 application.SendNotification();
2193 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
2195 // We didn't expect the animation to finish yet
2196 application.SendNotification();
2197 finishCheck.CheckSignalNotReceived();
2198 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
2200 application.SendNotification();
2201 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
2203 // We didn't expect the animation to finish yet
2204 application.SendNotification();
2205 finishCheck.CheckSignalNotReceived();
2206 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
2208 application.SendNotification();
2209 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
2211 // We did expect the animation to finish
2212 application.SendNotification();
2213 finishCheck.CheckSignalReceived();
2214 DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
2216 // Check that nothing has changed after a couple of buffer swaps
2217 application.Render(0);
2218 DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
2219 application.Render(0);
2220 DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
2224 int UtcDaliAnimationAnimateByInteger(void)
2226 TestApplication application;
2228 Actor actor = Actor::New();
2230 // Register an integer property
2232 Property::Index index = actor.RegisterProperty( "test-property", startValue );
2233 Stage::GetCurrent().Add(actor);
2234 DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
2236 // Build the animation
2237 float durationSeconds(2.0f);
2238 Animation animation = Animation::New(durationSeconds);
2239 int targetValue(50);
2240 int relativeValue(targetValue - startValue);
2241 animation.AnimateBy(Property(actor, index), relativeValue);
2243 int ninetyFivePercentProgress(static_cast<int>(startValue + relativeValue*0.95f + 0.5f));
2245 // Start the animation
2248 bool signalReceived(false);
2249 AnimationFinishCheck finishCheck(signalReceived);
2250 animation.FinishedSignal().Connect(&application, finishCheck);
2252 application.SendNotification();
2253 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
2255 // We didn't expect the animation to finish yet
2256 application.SendNotification();
2257 finishCheck.CheckSignalNotReceived();
2258 DALI_TEST_EQUALS( actor.GetProperty<int>(index), ninetyFivePercentProgress, TEST_LOCATION );
2260 application.SendNotification();
2261 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
2263 // We did expect the animation to finish
2264 application.SendNotification();
2265 finishCheck.CheckSignalReceived();
2266 DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
2268 // Check that nothing has changed after a couple of buffer swaps
2269 application.Render(0);
2270 DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
2271 application.Render(0);
2272 DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
2276 int UtcDaliAnimationAnimateByIntegerAlphaFunction(void)
2278 TestApplication application;
2280 Actor actor = Actor::New();
2282 // Register an integer property
2284 Property::Index index = actor.RegisterProperty( "test-property", startValue );
2285 Stage::GetCurrent().Add(actor);
2286 DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
2288 // Build the animation
2289 float durationSeconds(1.0f);
2290 Animation animation = Animation::New(durationSeconds);
2291 int targetValue(90);
2292 int relativeValue(targetValue - startValue);
2293 animation.AnimateBy(Property(actor, index), relativeValue, AlphaFunctions::EaseOut);
2295 int ninetyFivePercentProgress(static_cast<int>(startValue + relativeValue*0.95f + 0.5f));
2297 // Start the animation
2300 bool signalReceived(false);
2301 AnimationFinishCheck finishCheck(signalReceived);
2302 animation.FinishedSignal().Connect(&application, finishCheck);
2304 application.SendNotification();
2305 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
2307 // We didn't expect the animation to finish yet
2308 application.SendNotification();
2309 finishCheck.CheckSignalNotReceived();
2311 // The position should have moved more, than with a linear alpha function
2312 int current(actor.GetProperty<int>(index));
2313 DALI_TEST_CHECK( current > ninetyFivePercentProgress );
2315 application.SendNotification();
2316 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
2318 // We did expect the animation to finish
2319 application.SendNotification();
2320 finishCheck.CheckSignalReceived();
2321 DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
2323 // Check that nothing has changed after a couple of buffer swaps
2324 application.Render(0);
2325 DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
2326 application.Render(0);
2327 DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
2331 int UtcDaliAnimationAnimateByIntegerTimePeriod(void)
2333 TestApplication application;
2335 Actor actor = Actor::New();
2337 // Register an integer property
2339 Property::Index index = actor.RegisterProperty( "test-property", startValue );
2340 Stage::GetCurrent().Add(actor);
2341 DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
2343 // Build the animation
2344 float durationSeconds(1.0f);
2345 Animation animation = Animation::New(durationSeconds);
2346 int targetValue(30);
2347 int relativeValue(targetValue - startValue);
2349 animation.AnimateBy(Property(actor, index),
2351 TimePeriod(delay, durationSeconds - delay));
2353 // Start the animation
2356 bool signalReceived(false);
2357 AnimationFinishCheck finishCheck(signalReceived);
2358 animation.FinishedSignal().Connect(&application, finishCheck);
2360 application.SendNotification();
2361 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
2363 // We didn't expect the animation to finish yet
2364 application.SendNotification();
2365 finishCheck.CheckSignalNotReceived();
2366 DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
2368 application.SendNotification();
2369 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
2371 // We didn't expect the animation to finish yet
2372 application.SendNotification();
2373 finishCheck.CheckSignalNotReceived();
2374 DALI_TEST_EQUALS( actor.GetProperty<int>(index), static_cast<int>(startValue+(relativeValue*0.5f)+0.5f), TEST_LOCATION );
2376 application.SendNotification();
2377 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
2379 // We did expect the animation to finish
2380 application.SendNotification();
2381 finishCheck.CheckSignalReceived();
2382 DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
2384 // Check that nothing has changed after a couple of buffer swaps
2385 application.Render(0);
2386 DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
2387 application.Render(0);
2388 DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
2392 int UtcDaliAnimationAnimateByIntegerAlphaFunctionTimePeriod(void)
2394 TestApplication application;
2396 Actor actor = Actor::New();
2398 // Register an integer property
2400 Property::Index index = actor.RegisterProperty( "test-property", startValue );
2401 Stage::GetCurrent().Add(actor);
2402 DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
2404 // Build the animation
2405 float durationSeconds(1.0f);
2406 Animation animation = Animation::New(durationSeconds);
2407 int targetValue(30);
2408 int relativeValue(targetValue - startValue);
2410 animation.AnimateBy(Property(actor, index),
2412 AlphaFunctions::Linear,
2413 TimePeriod(delay, durationSeconds - delay));
2415 // Start the animation
2418 bool signalReceived(false);
2419 AnimationFinishCheck finishCheck(signalReceived);
2420 animation.FinishedSignal().Connect(&application, finishCheck);
2422 application.SendNotification();
2423 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
2425 // We didn't expect the animation to finish yet
2426 application.SendNotification();
2427 finishCheck.CheckSignalNotReceived();
2428 DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
2430 application.SendNotification();
2431 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
2433 // We didn't expect the animation to finish yet
2434 application.SendNotification();
2435 finishCheck.CheckSignalNotReceived();
2436 DALI_TEST_EQUALS( actor.GetProperty<int>(index), static_cast<int>(startValue+(relativeValue*0.5f)+0.5f), TEST_LOCATION );
2438 application.SendNotification();
2439 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
2441 // We did expect the animation to finish
2442 application.SendNotification();
2443 finishCheck.CheckSignalReceived();
2444 DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
2446 // Check that nothing has changed after a couple of buffer swaps
2447 application.Render(0);
2448 DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
2449 application.Render(0);
2450 DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
2454 int UtcDaliAnimationAnimateByVector2(void)
2456 TestApplication application;
2458 Actor actor = Actor::New();
2460 // Register a Vector2 property
2461 Vector2 startValue(10.0f, 10.0f);
2462 Property::Index index = actor.RegisterProperty( "test-property", startValue );
2463 Stage::GetCurrent().Add(actor);
2464 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
2466 // Build the animation
2467 float durationSeconds(2.0f);
2468 Animation animation = Animation::New(durationSeconds);
2469 Vector2 targetValue(60.0f, 60.0f);
2470 Vector2 relativeValue(targetValue - startValue);
2471 animation.AnimateBy(Property(actor, index), relativeValue);
2473 Vector2 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
2475 // Start the animation
2478 bool signalReceived(false);
2479 AnimationFinishCheck finishCheck(signalReceived);
2480 animation.FinishedSignal().Connect(&application, finishCheck);
2482 application.SendNotification();
2483 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
2485 // We didn't expect the animation to finish yet
2486 application.SendNotification();
2487 finishCheck.CheckSignalNotReceived();
2488 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), ninetyFivePercentProgress, TEST_LOCATION );
2490 application.SendNotification();
2491 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
2493 // We did expect the animation to finish
2494 application.SendNotification();
2495 finishCheck.CheckSignalReceived();
2496 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
2498 // Check that nothing has changed after a couple of buffer swaps
2499 application.Render(0);
2500 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
2501 application.Render(0);
2502 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
2506 int UtcDaliAnimationAnimateByVector2AlphaFunction(void)
2508 TestApplication application;
2510 Actor actor = Actor::New();
2512 // Register a Vector2 property
2513 Vector2 startValue(100.0f, 100.0f);
2514 Property::Index index = actor.RegisterProperty( "test-property", startValue );
2515 Stage::GetCurrent().Add(actor);
2516 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
2518 // Build the animation
2519 float durationSeconds(1.0f);
2520 Animation animation = Animation::New(durationSeconds);
2521 Vector2 targetValue(20.0f, 20.0f);
2522 Vector2 relativeValue(targetValue - startValue);
2523 animation.AnimateBy(Property(actor, index), relativeValue, AlphaFunctions::EaseOut);
2525 Vector2 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
2527 // Start the animation
2530 bool signalReceived(false);
2531 AnimationFinishCheck finishCheck(signalReceived);
2532 animation.FinishedSignal().Connect(&application, finishCheck);
2534 application.SendNotification();
2535 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
2537 // We didn't expect the animation to finish yet
2538 application.SendNotification();
2539 finishCheck.CheckSignalNotReceived();
2541 // The position should have moved more, than with a linear alpha function
2542 Vector2 current(actor.GetProperty<Vector2>(index));
2543 DALI_TEST_CHECK( current.x < ninetyFivePercentProgress.x );
2544 DALI_TEST_CHECK( current.y < ninetyFivePercentProgress.y );
2546 application.SendNotification();
2547 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
2549 // We did expect the animation to finish
2550 application.SendNotification();
2551 finishCheck.CheckSignalReceived();
2552 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
2554 // Check that nothing has changed after a couple of buffer swaps
2555 application.Render(0);
2556 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
2557 application.Render(0);
2558 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
2562 int UtcDaliAnimationAnimateByVector2TimePeriod(void)
2564 TestApplication application;
2566 Actor actor = Actor::New();
2568 // Register a Vector2 property
2569 Vector2 startValue(10.0f, 10.0f);
2570 Property::Index index = actor.RegisterProperty( "test-property", startValue );
2571 Stage::GetCurrent().Add(actor);
2572 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
2574 // Build the animation
2575 float durationSeconds(1.0f);
2576 Animation animation = Animation::New(durationSeconds);
2577 Vector2 targetValue(30.0f, 30.0f);
2578 Vector2 relativeValue(targetValue - startValue);
2580 animation.AnimateBy(Property(actor, index),
2582 TimePeriod(delay, durationSeconds - delay));
2584 // Start the animation
2587 bool signalReceived(false);
2588 AnimationFinishCheck finishCheck(signalReceived);
2589 animation.FinishedSignal().Connect(&application, finishCheck);
2591 application.SendNotification();
2592 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
2594 // We didn't expect the animation to finish yet
2595 application.SendNotification();
2596 finishCheck.CheckSignalNotReceived();
2597 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
2599 application.SendNotification();
2600 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
2602 // We didn't expect the animation to finish yet
2603 application.SendNotification();
2604 finishCheck.CheckSignalNotReceived();
2605 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
2607 application.SendNotification();
2608 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
2610 // We did expect the animation to finish
2611 application.SendNotification();
2612 finishCheck.CheckSignalReceived();
2613 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
2615 // Check that nothing has changed after a couple of buffer swaps
2616 application.Render(0);
2617 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
2618 application.Render(0);
2619 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
2623 int UtcDaliAnimationAnimateByVector2AlphaFunctionTimePeriod(void)
2625 TestApplication application;
2627 Actor actor = Actor::New();
2629 // Register a Vector2 property
2630 Vector2 startValue(5.0f, 5.0f);
2631 Property::Index index = actor.RegisterProperty( "test-property", startValue );
2632 Stage::GetCurrent().Add(actor);
2633 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
2635 // Build the animation
2636 float durationSeconds(1.0f);
2637 Animation animation = Animation::New(durationSeconds);
2638 Vector2 targetValue(10.0f, 10.0f);
2639 Vector2 relativeValue(targetValue - startValue);
2641 animation.AnimateBy(Property(actor, index),
2643 AlphaFunctions::Linear,
2644 TimePeriod(delay, durationSeconds - delay));
2646 // Start the animation
2649 bool signalReceived(false);
2650 AnimationFinishCheck finishCheck(signalReceived);
2651 animation.FinishedSignal().Connect(&application, finishCheck);
2653 application.SendNotification();
2654 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
2656 // We didn't expect the animation to finish yet
2657 application.SendNotification();
2658 finishCheck.CheckSignalNotReceived();
2659 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
2661 application.SendNotification();
2662 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
2664 // We didn't expect the animation to finish yet
2665 application.SendNotification();
2666 finishCheck.CheckSignalNotReceived();
2667 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
2669 application.SendNotification();
2670 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
2672 // We did expect the animation to finish
2673 application.SendNotification();
2674 finishCheck.CheckSignalReceived();
2675 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
2677 // Check that nothing has changed after a couple of buffer swaps
2678 application.Render(0);
2679 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
2680 application.Render(0);
2681 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
2685 int UtcDaliAnimationAnimateByVector3(void)
2687 TestApplication application;
2689 Actor actor = Actor::New();
2691 // Register a Vector3 property
2692 Vector3 startValue(10.0f, 10.0f, 10.0f);
2693 Property::Index index = actor.RegisterProperty( "test-property", startValue );
2694 Stage::GetCurrent().Add(actor);
2695 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
2697 // Build the animation
2698 float durationSeconds(2.0f);
2699 Animation animation = Animation::New(durationSeconds);
2700 Vector3 targetValue(60.0f, 60.0f, 60.0f);
2701 Vector3 relativeValue(targetValue - startValue);
2702 animation.AnimateBy(Property(actor, index), relativeValue);
2704 Vector3 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
2706 // Start the animation
2709 bool signalReceived(false);
2710 AnimationFinishCheck finishCheck(signalReceived);
2711 animation.FinishedSignal().Connect(&application, finishCheck);
2713 application.SendNotification();
2714 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
2716 // We didn't expect the animation to finish yet
2717 application.SendNotification();
2718 finishCheck.CheckSignalNotReceived();
2719 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), ninetyFivePercentProgress, TEST_LOCATION );
2721 application.SendNotification();
2722 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
2724 // We did expect the animation to finish
2725 application.SendNotification();
2726 finishCheck.CheckSignalReceived();
2727 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
2729 // Check that nothing has changed after a couple of buffer swaps
2730 application.Render(0);
2731 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
2732 application.Render(0);
2733 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
2737 int UtcDaliAnimationAnimateByVector3AlphaFunction(void)
2739 TestApplication application;
2741 Actor actor = Actor::New();
2743 // Register a Vector3 property
2744 Vector3 startValue(100.0f, 100.0f, 100.0f);
2745 Property::Index index = actor.RegisterProperty( "test-property", startValue );
2746 Stage::GetCurrent().Add(actor);
2747 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
2749 // Build the animation
2750 float durationSeconds(1.0f);
2751 Animation animation = Animation::New(durationSeconds);
2752 Vector3 targetValue(20.0f, 20.0f, 20.0f);
2753 Vector3 relativeValue(targetValue - startValue);
2754 animation.AnimateBy(Property(actor, index), relativeValue, AlphaFunctions::EaseOut);
2756 Vector3 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
2758 // Start the animation
2761 bool signalReceived(false);
2762 AnimationFinishCheck finishCheck(signalReceived);
2763 animation.FinishedSignal().Connect(&application, finishCheck);
2765 application.SendNotification();
2766 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
2768 // We didn't expect the animation to finish yet
2769 application.SendNotification();
2770 finishCheck.CheckSignalNotReceived();
2772 // The position should have moved more, than with a linear alpha function
2773 Vector3 current(actor.GetProperty<Vector3>(index));
2774 DALI_TEST_CHECK( current.x < ninetyFivePercentProgress.x );
2775 DALI_TEST_CHECK( current.y < ninetyFivePercentProgress.y );
2776 DALI_TEST_CHECK( current.z < ninetyFivePercentProgress.z );
2778 application.SendNotification();
2779 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
2781 // We did expect the animation to finish
2782 application.SendNotification();
2783 finishCheck.CheckSignalReceived();
2784 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
2786 // Check that nothing has changed after a couple of buffer swaps
2787 application.Render(0);
2788 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
2789 application.Render(0);
2790 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
2794 int UtcDaliAnimationAnimateByVector3TimePeriod(void)
2796 TestApplication application;
2798 Actor actor = Actor::New();
2800 // Register a Vector3 property
2801 Vector3 startValue(10.0f, 10.0f, 10.0f);
2802 Property::Index index = actor.RegisterProperty( "test-property", startValue );
2803 Stage::GetCurrent().Add(actor);
2804 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
2806 // Build the animation
2807 float durationSeconds(1.0f);
2808 Animation animation = Animation::New(durationSeconds);
2809 Vector3 targetValue(30.0f, 30.0f, 30.0f);
2810 Vector3 relativeValue(targetValue - startValue);
2812 animation.AnimateBy(Property(actor, index),
2814 TimePeriod(delay, durationSeconds - delay));
2816 // Start the animation
2819 bool signalReceived(false);
2820 AnimationFinishCheck finishCheck(signalReceived);
2821 animation.FinishedSignal().Connect(&application, finishCheck);
2823 application.SendNotification();
2824 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
2826 // We didn't expect the animation to finish yet
2827 application.SendNotification();
2828 finishCheck.CheckSignalNotReceived();
2829 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
2831 application.SendNotification();
2832 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
2834 // We didn't expect the animation to finish yet
2835 application.SendNotification();
2836 finishCheck.CheckSignalNotReceived();
2837 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
2839 application.SendNotification();
2840 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
2842 // We did expect the animation to finish
2843 application.SendNotification();
2844 finishCheck.CheckSignalReceived();
2845 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
2847 // Check that nothing has changed after a couple of buffer swaps
2848 application.Render(0);
2849 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
2850 application.Render(0);
2851 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
2855 int UtcDaliAnimationAnimateByVector3AlphaFunctionTimePeriod(void)
2857 TestApplication application;
2859 Actor actor = Actor::New();
2861 // Register a Vector3 property
2862 Vector3 startValue(5.0f, 5.0f, 5.0f);
2863 Property::Index index = actor.RegisterProperty( "test-property", startValue );
2864 Stage::GetCurrent().Add(actor);
2865 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
2867 // Build the animation
2868 float durationSeconds(1.0f);
2869 Animation animation = Animation::New(durationSeconds);
2870 Vector3 targetValue(10.0f, 10.0f, 10.0f);
2871 Vector3 relativeValue(targetValue - startValue);
2873 animation.AnimateBy(Property(actor, index),
2875 AlphaFunctions::Linear,
2876 TimePeriod(delay, durationSeconds - delay));
2878 // Start the animation
2881 bool signalReceived(false);
2882 AnimationFinishCheck finishCheck(signalReceived);
2883 animation.FinishedSignal().Connect(&application, finishCheck);
2885 application.SendNotification();
2886 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
2888 // We didn't expect the animation to finish yet
2889 application.SendNotification();
2890 finishCheck.CheckSignalNotReceived();
2891 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
2893 application.SendNotification();
2894 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
2896 // We didn't expect the animation to finish yet
2897 application.SendNotification();
2898 finishCheck.CheckSignalNotReceived();
2899 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
2901 application.SendNotification();
2902 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
2904 // We did expect the animation to finish
2905 application.SendNotification();
2906 finishCheck.CheckSignalReceived();
2907 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
2909 // Check that nothing has changed after a couple of buffer swaps
2910 application.Render(0);
2911 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
2912 application.Render(0);
2913 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
2917 int UtcDaliAnimationAnimateByVector4(void)
2919 TestApplication application;
2921 Actor actor = Actor::New();
2923 // Register a Vector4 property
2924 Vector4 startValue(10.0f, 10.0f, 10.0f, 10.0f);
2925 Property::Index index = actor.RegisterProperty( "test-property", startValue );
2926 Stage::GetCurrent().Add(actor);
2927 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
2929 // Build the animation
2930 float durationSeconds(2.0f);
2931 Animation animation = Animation::New(durationSeconds);
2932 Vector4 targetValue(60.0f, 60.0f, 60.0f, 60.0f);
2933 Vector4 relativeValue(targetValue - startValue);
2934 animation.AnimateBy(Property(actor, index), relativeValue);
2936 Vector4 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
2938 // Start the animation
2941 bool signalReceived(false);
2942 AnimationFinishCheck finishCheck(signalReceived);
2943 animation.FinishedSignal().Connect(&application, finishCheck);
2945 application.SendNotification();
2946 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
2948 // We didn't expect the animation to finish yet
2949 application.SendNotification();
2950 finishCheck.CheckSignalNotReceived();
2951 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), ninetyFivePercentProgress, TEST_LOCATION );
2953 application.SendNotification();
2954 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
2956 // We did expect the animation to finish
2957 application.SendNotification();
2958 finishCheck.CheckSignalReceived();
2959 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
2961 // Check that nothing has changed after a couple of buffer swaps
2962 application.Render(0);
2963 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
2964 application.Render(0);
2965 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
2969 int UtcDaliAnimationAnimateByVector4AlphaFunction(void)
2971 TestApplication application;
2973 Actor actor = Actor::New();
2975 // Register a Vector4 property
2976 Vector4 startValue(100.0f, 100.0f, 100.0f, 100.0f);
2977 Property::Index index = actor.RegisterProperty( "test-property", startValue );
2978 Stage::GetCurrent().Add(actor);
2979 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
2981 // Build the animation
2982 float durationSeconds(1.0f);
2983 Animation animation = Animation::New(durationSeconds);
2984 Vector4 targetValue(20.0f, 20.0f, 20.0f, 20.0f);
2985 Vector4 relativeValue(targetValue - startValue);
2986 animation.AnimateBy(Property(actor, index), relativeValue, AlphaFunctions::EaseOut);
2988 Vector4 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
2990 // Start the animation
2993 bool signalReceived(false);
2994 AnimationFinishCheck finishCheck(signalReceived);
2995 animation.FinishedSignal().Connect(&application, finishCheck);
2997 application.SendNotification();
2998 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3000 // We didn't expect the animation to finish yet
3001 application.SendNotification();
3002 finishCheck.CheckSignalNotReceived();
3004 // The position should have moved more, than with a linear alpha function
3005 Vector4 current(actor.GetProperty<Vector4>(index));
3006 DALI_TEST_CHECK( current.x < ninetyFivePercentProgress.x );
3007 DALI_TEST_CHECK( current.y < ninetyFivePercentProgress.y );
3008 DALI_TEST_CHECK( current.z < ninetyFivePercentProgress.z );
3009 DALI_TEST_CHECK( current.w < ninetyFivePercentProgress.w );
3011 application.SendNotification();
3012 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3014 // We did expect the animation to finish
3015 application.SendNotification();
3016 finishCheck.CheckSignalReceived();
3017 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
3019 // Check that nothing has changed after a couple of buffer swaps
3020 application.Render(0);
3021 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
3022 application.Render(0);
3023 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
3027 int UtcDaliAnimationAnimateByVector4TimePeriod(void)
3029 TestApplication application;
3031 Actor actor = Actor::New();
3033 // Register a Vector4 property
3034 Vector4 startValue(10.0f, 10.0f, 10.0f, 10.0f);
3035 Property::Index index = actor.RegisterProperty( "test-property", startValue );
3036 Stage::GetCurrent().Add(actor);
3037 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
3039 // Build the animation
3040 float durationSeconds(1.0f);
3041 Animation animation = Animation::New(durationSeconds);
3042 Vector4 targetValue(30.0f, 30.0f, 30.0f, 30.0f);
3043 Vector4 relativeValue(targetValue - startValue);
3045 animation.AnimateBy(Property(actor, index),
3047 TimePeriod(delay, durationSeconds - delay));
3049 // Start the animation
3052 bool signalReceived(false);
3053 AnimationFinishCheck finishCheck(signalReceived);
3054 animation.FinishedSignal().Connect(&application, finishCheck);
3056 application.SendNotification();
3057 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
3059 // We didn't expect the animation to finish yet
3060 application.SendNotification();
3061 finishCheck.CheckSignalNotReceived();
3062 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
3064 application.SendNotification();
3065 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
3067 // We didn't expect the animation to finish yet
3068 application.SendNotification();
3069 finishCheck.CheckSignalNotReceived();
3070 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
3072 application.SendNotification();
3073 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
3075 // We did expect the animation to finish
3076 application.SendNotification();
3077 finishCheck.CheckSignalReceived();
3078 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
3080 // Check that nothing has changed after a couple of buffer swaps
3081 application.Render(0);
3082 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
3083 application.Render(0);
3084 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
3088 int UtcDaliAnimationAnimateByVector4AlphaFunctionTimePeriod(void)
3090 TestApplication application;
3092 Actor actor = Actor::New();
3094 // Register a Vector4 property
3095 Vector4 startValue(5.0f, 5.0f, 5.0f, 5.0f);
3096 Property::Index index = actor.RegisterProperty( "test-property", startValue );
3097 Stage::GetCurrent().Add(actor);
3098 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
3100 // Build the animation
3101 float durationSeconds(1.0f);
3102 Animation animation = Animation::New(durationSeconds);
3103 Vector4 targetValue(10.0f, 10.0f, 10.0f, 10.0f);
3104 Vector4 relativeValue(targetValue - startValue);
3106 animation.AnimateBy(Property(actor, index),
3108 AlphaFunctions::Linear,
3109 TimePeriod(delay, durationSeconds - delay));
3111 // Start the animation
3114 bool signalReceived(false);
3115 AnimationFinishCheck finishCheck(signalReceived);
3116 animation.FinishedSignal().Connect(&application, finishCheck);
3118 application.SendNotification();
3119 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
3121 // We didn't expect the animation to finish yet
3122 application.SendNotification();
3123 finishCheck.CheckSignalNotReceived();
3124 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
3126 application.SendNotification();
3127 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
3129 // We didn't expect the animation to finish yet
3130 application.SendNotification();
3131 finishCheck.CheckSignalNotReceived();
3132 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
3134 application.SendNotification();
3135 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
3137 // We did expect the animation to finish
3138 application.SendNotification();
3139 finishCheck.CheckSignalReceived();
3140 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
3142 // Check that nothing has changed after a couple of buffer swaps
3143 application.Render(0);
3144 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
3145 application.Render(0);
3146 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
3150 int UtcDaliAnimationAnimateByActorPosition(void)
3152 TestApplication application;
3154 Actor actor = Actor::New();
3155 Vector3 startPosition(10.0f, 10.0f, 10.0f);
3156 actor.SetPosition(startPosition);
3157 Stage::GetCurrent().Add(actor);
3158 application.SendNotification();
3159 application.Render(0);
3160 DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION );
3162 // Build the animation
3163 float durationSeconds(1.0f);
3164 Animation animation = Animation::New(durationSeconds);
3165 Vector3 targetPosition(20.0f, 20.0f, 20.0f);
3166 Vector3 relativePosition(targetPosition - startPosition);
3167 animation.AnimateBy(Property(actor, Actor::POSITION), relativePosition);
3169 Vector3 ninetyFivePercentProgress(startPosition + relativePosition*0.95f);
3171 // Start the animation
3174 bool signalReceived(false);
3175 AnimationFinishCheck finishCheck(signalReceived);
3176 animation.FinishedSignal().Connect(&application, finishCheck);
3178 application.SendNotification();
3179 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3181 // We didn't expect the animation to finish yet
3182 application.SendNotification();
3183 finishCheck.CheckSignalNotReceived();
3184 DALI_TEST_EQUALS( actor.GetCurrentPosition(), ninetyFivePercentProgress, TEST_LOCATION );
3186 application.SendNotification();
3187 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3189 // We did expect the animation to finish
3190 application.SendNotification();
3191 finishCheck.CheckSignalReceived();
3192 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
3194 // Check that nothing has changed after a couple of buffer swaps
3195 application.Render(0);
3196 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
3197 application.Render(0);
3198 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
3202 int UtcDaliAnimationAnimateByActorPositionAlphaFunction(void)
3204 TestApplication application;
3206 Actor actor = Actor::New();
3207 Vector3 startPosition(10.0f, 10.0f, 10.0f);
3208 actor.SetPosition(startPosition);
3209 Stage::GetCurrent().Add(actor);
3210 application.SendNotification();
3211 application.Render(0);
3212 DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION );
3214 // Build the animation
3215 float durationSeconds(1.0f);
3216 Animation animation = Animation::New(durationSeconds);
3217 Vector3 targetPosition(20.0f, 20.0f, 20.0f);
3218 Vector3 relativePosition(targetPosition - startPosition);
3219 animation.AnimateBy(Property(actor, Actor::POSITION), relativePosition, AlphaFunctions::EaseOut);
3221 Vector3 ninetyFivePercentProgress(startPosition + relativePosition*0.95f);
3223 // Start the animation
3226 bool signalReceived(false);
3227 AnimationFinishCheck finishCheck(signalReceived);
3228 animation.FinishedSignal().Connect(&application, finishCheck);
3230 application.SendNotification();
3231 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3233 // We didn't expect the animation to finish yet
3234 application.SendNotification();
3235 finishCheck.CheckSignalNotReceived();
3237 // The position should have moved more, than with a linear alpha function
3238 Vector3 current(actor.GetCurrentPosition());
3239 DALI_TEST_CHECK( current.x > ninetyFivePercentProgress.x );
3240 DALI_TEST_CHECK( current.y > ninetyFivePercentProgress.y );
3241 DALI_TEST_CHECK( current.z > ninetyFivePercentProgress.z );
3243 application.SendNotification();
3244 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3246 // We did expect the animation to finish
3247 application.SendNotification();
3248 finishCheck.CheckSignalReceived();
3249 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
3251 // Check that nothing has changed after a couple of buffer swaps
3252 application.Render(0);
3253 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
3254 application.Render(0);
3255 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
3259 int UtcDaliAnimationAnimateByActorPositionTimePeriod(void)
3261 TestApplication application;
3263 Actor actor = Actor::New();
3264 Vector3 startPosition(10.0f, 10.0f, 10.0f);
3265 actor.SetPosition(startPosition);
3266 Stage::GetCurrent().Add(actor);
3267 application.SendNotification();
3268 application.Render(0);
3269 DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION );
3271 // Build the animation
3272 float durationSeconds(1.0f);
3273 Animation animation = Animation::New(durationSeconds);
3274 Vector3 targetPosition(20.0f, 20.0f, 20.0f);
3275 Vector3 relativePosition(targetPosition - startPosition);
3277 animation.AnimateBy(Property(actor, Actor::POSITION),
3279 TimePeriod(delay, durationSeconds - delay));
3281 Vector3 ninetyFivePercentProgress(startPosition + relativePosition*0.95f);
3283 // Start the animation
3286 bool signalReceived(false);
3287 AnimationFinishCheck finishCheck(signalReceived);
3288 animation.FinishedSignal().Connect(&application, finishCheck);
3290 application.SendNotification();
3291 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
3293 // We didn't expect the animation to finish yet
3294 application.SendNotification();
3295 finishCheck.CheckSignalNotReceived();
3296 DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION );
3298 application.SendNotification();
3299 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
3301 // We did expect the animation to finish
3302 application.SendNotification();
3303 finishCheck.CheckSignalReceived();
3304 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
3306 // Check that nothing has changed after a couple of buffer swaps
3307 application.Render(0);
3308 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
3309 application.Render(0);
3310 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
3314 int UtcDaliAnimationAnimateByActorPositionAlphaFunctionTimePeriod(void)
3316 TestApplication application;
3318 Actor actor = Actor::New();
3319 Vector3 startPosition(10.0f, 10.0f, 10.0f);
3320 actor.SetPosition(startPosition);
3321 Stage::GetCurrent().Add(actor);
3322 application.SendNotification();
3323 application.Render(0);
3324 DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION );
3326 // Build the animation
3327 float durationSeconds(1.0f);
3328 Animation animation = Animation::New(durationSeconds);
3329 Vector3 targetPosition(20.0f, 20.0f, 20.0f);
3330 Vector3 relativePosition(targetPosition - startPosition);
3332 animation.AnimateBy(Property(actor, Actor::POSITION),
3334 AlphaFunctions::Linear,
3335 TimePeriod(delay, durationSeconds - delay));
3337 Vector3 ninetyFivePercentProgress(startPosition + relativePosition*0.95f);
3339 // Start the animation
3342 bool signalReceived(false);
3343 AnimationFinishCheck finishCheck(signalReceived);
3344 animation.FinishedSignal().Connect(&application, finishCheck);
3346 application.SendNotification();
3347 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
3349 // We didn't expect the animation to finish yet
3350 application.SendNotification();
3351 finishCheck.CheckSignalNotReceived();
3352 DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION );
3354 application.SendNotification();
3355 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
3357 // We did expect the animation to finish
3358 application.SendNotification();
3359 finishCheck.CheckSignalReceived();
3360 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
3362 // Check that nothing has changed after a couple of buffer swaps
3363 application.Render(0);
3364 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
3365 application.Render(0);
3366 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
3370 int UtcDaliAnimationAnimateToBoolean(void)
3372 TestApplication application;
3374 Actor actor = Actor::New();
3376 // Register a boolean property
3377 const bool startValue(false);
3378 Property::Index index = actor.RegisterProperty( "test-property", startValue );
3379 Stage::GetCurrent().Add(actor);
3380 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
3382 // Build the animation
3383 float durationSeconds(2.0f);
3384 Animation animation = Animation::New(durationSeconds);
3385 const bool targetValue( !startValue );
3386 animation.AnimateTo(Property(actor, index), targetValue);
3388 // Start the animation
3391 bool signalReceived(false);
3392 AnimationFinishCheck finishCheck(signalReceived);
3393 animation.FinishedSignal().Connect(&application, finishCheck);
3395 application.SendNotification();
3396 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3398 // We didn't expect the animation to finish yet
3399 application.SendNotification();
3400 finishCheck.CheckSignalNotReceived();
3401 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
3403 application.SendNotification();
3404 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3406 // We did expect the animation to finish
3407 application.SendNotification();
3408 finishCheck.CheckSignalReceived();
3409 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == targetValue );
3411 // Check that nothing has changed after a couple of buffer swaps
3412 application.Render(0);
3413 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == targetValue );
3414 application.Render(0);
3415 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == targetValue );
3417 // Repeat with target value "false"
3418 animation = Animation::New(durationSeconds);
3419 const bool finalValue( !targetValue );
3420 animation.AnimateTo(Property(actor, index), finalValue);
3422 // Start the animation
3425 finishCheck.Reset();
3426 animation.FinishedSignal().Connect(&application, finishCheck);
3428 application.SendNotification();
3429 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3431 // We didn't expect the animation to finish yet
3432 application.SendNotification();
3433 finishCheck.CheckSignalNotReceived();
3434 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == targetValue );
3436 application.SendNotification();
3437 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3439 // We did expect the animation to finish
3440 application.SendNotification();
3441 finishCheck.CheckSignalReceived();
3442 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
3444 // Check that nothing has changed after a couple of buffer swaps
3445 application.Render(0);
3446 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
3447 application.Render(0);
3448 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
3452 int UtcDaliAnimationAnimateToBooleanAlphaFunction(void)
3454 TestApplication application;
3456 Actor actor = Actor::New();
3458 // Register a boolean property
3459 const bool startValue(false);
3460 Property::Index index = actor.RegisterProperty( "test-property", startValue );
3461 Stage::GetCurrent().Add(actor);
3462 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
3464 // Build the animation
3465 float durationSeconds(2.0f);
3466 Animation animation = Animation::New(durationSeconds);
3467 const bool targetValue( !startValue );
3468 animation.AnimateTo(Property(actor, "test-property"), targetValue, AlphaFunctions::EaseOut);
3470 // Start the animation
3473 bool signalReceived(false);
3474 AnimationFinishCheck finishCheck(signalReceived);
3475 animation.FinishedSignal().Connect(&application, finishCheck);
3477 application.SendNotification();
3478 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3480 // We didn't expect the animation to finish yet
3481 application.SendNotification();
3482 finishCheck.CheckSignalNotReceived();
3483 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
3485 application.SendNotification();
3486 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3488 // We did expect the animation to finish
3489 application.SendNotification();
3490 finishCheck.CheckSignalReceived();
3491 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == targetValue );
3493 // Check that nothing has changed after a couple of buffer swaps
3494 application.Render(0);
3495 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == targetValue );
3496 application.Render(0);
3497 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == targetValue );
3499 // Repeat with target value "false"
3500 animation = Animation::New(durationSeconds);
3501 const bool finalValue( !targetValue );
3502 animation.AnimateTo(Property(actor, index), finalValue, AlphaFunctions::EaseOut);
3504 // Start the animation
3507 finishCheck.Reset();
3508 animation.FinishedSignal().Connect(&application, finishCheck);
3510 application.SendNotification();
3511 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3513 // We didn't expect the animation to finish yet
3514 application.SendNotification();
3515 finishCheck.CheckSignalNotReceived();
3516 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == targetValue );
3518 application.SendNotification();
3519 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3521 // We did expect the animation to finish
3522 application.SendNotification();
3523 finishCheck.CheckSignalReceived();
3524 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
3526 // Check that nothing has changed after a couple of buffer swaps
3527 application.Render(0);
3528 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
3529 application.Render(0);
3530 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
3534 int UtcDaliAnimationAnimateToBooleanTimePeriod(void)
3536 TestApplication application;
3538 Actor actor = Actor::New();
3540 // Register a boolean property
3541 bool startValue(false);
3542 Property::Index index = actor.RegisterProperty( "test-property", startValue );
3543 Stage::GetCurrent().Add(actor);
3544 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
3546 // Build the animation
3547 float durationSeconds(2.0f);
3548 Animation animation = Animation::New(durationSeconds);
3549 bool finalValue( !startValue );
3550 float animatorDurationSeconds(durationSeconds * 0.5f);
3551 animation.AnimateTo( Property(actor, index),
3553 TimePeriod( animatorDurationSeconds ) );
3555 // Start the animation
3558 bool signalReceived(false);
3559 AnimationFinishCheck finishCheck(signalReceived);
3560 animation.FinishedSignal().Connect(&application, finishCheck);
3562 application.SendNotification();
3563 application.Render(static_cast<unsigned int>(animatorDurationSeconds*950.0f)/* 95% animator progress */);
3565 // We didn't expect the animation to finish yet
3566 application.SendNotification();
3567 finishCheck.CheckSignalNotReceived();
3568 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
3570 application.SendNotification();
3571 application.Render(static_cast<unsigned int>(animatorDurationSeconds*50.0f) + 1u/*just beyond the animator duration*/);
3573 // We didn't expect the animation to finish yet...
3574 application.SendNotification();
3575 finishCheck.CheckSignalNotReceived();
3577 // ...however we should have reached the final value
3578 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
3580 application.SendNotification();
3581 application.Render(static_cast<unsigned int>(animatorDurationSeconds*1000.0f)/*just beyond the animation duration*/);
3583 // We did expect the animation to finish
3584 application.SendNotification();
3585 finishCheck.CheckSignalReceived();
3586 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
3588 // Check that nothing has changed after a couple of buffer swaps
3589 application.Render(0);
3590 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
3591 application.Render(0);
3592 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
3596 int UtcDaliAnimationAnimateToBooleanAlphaFunctionTimePeriod(void)
3598 TestApplication application;
3600 Actor actor = Actor::New();
3602 // Register a boolean property
3603 bool startValue(false);
3604 Property::Index index = actor.RegisterProperty( "test-property", startValue );
3605 Stage::GetCurrent().Add(actor);
3606 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
3608 // Build the animation
3609 float durationSeconds(2.0f);
3610 Animation animation = Animation::New(durationSeconds);
3611 bool finalValue( !startValue );
3612 float animatorDurationSeconds(durationSeconds * 0.5f);
3613 animation.AnimateTo( Property(actor, index),
3615 AlphaFunctions::Linear,
3616 TimePeriod( animatorDurationSeconds ) );
3618 // Start the animation
3621 bool signalReceived(false);
3622 AnimationFinishCheck finishCheck(signalReceived);
3623 animation.FinishedSignal().Connect(&application, finishCheck);
3625 application.SendNotification();
3626 application.Render(static_cast<unsigned int>(animatorDurationSeconds*950.0f)/* 95% animator progress */);
3628 // We didn't expect the animation to finish yet
3629 application.SendNotification();
3630 finishCheck.CheckSignalNotReceived();
3631 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
3633 application.SendNotification();
3634 application.Render(static_cast<unsigned int>(animatorDurationSeconds*50.0f) + 1u/*just beyond the animator duration*/);
3636 // We didn't expect the animation to finish yet...
3637 application.SendNotification();
3638 finishCheck.CheckSignalNotReceived();
3640 // ...however we should have reached the final value
3641 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
3643 application.SendNotification();
3644 application.Render(static_cast<unsigned int>(animatorDurationSeconds*1000.0f)/*just beyond the animation duration*/);
3646 // We did expect the animation to finish
3647 application.SendNotification();
3648 finishCheck.CheckSignalReceived();
3649 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
3651 // Check that nothing has changed after a couple of buffer swaps
3652 application.Render(0);
3653 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
3654 application.Render(0);
3655 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
3659 int UtcDaliAnimationAnimateToFloat(void)
3661 TestApplication application;
3663 Actor actor = Actor::New();
3665 // Register a float property
3666 float startValue(10.0f);
3667 Property::Index index = actor.RegisterProperty( "test-property", startValue );
3668 Stage::GetCurrent().Add(actor);
3669 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
3671 // Build the animation
3672 float durationSeconds(2.0f);
3673 Animation animation = Animation::New(durationSeconds);
3674 float targetValue(50.0f);
3675 float relativeValue(targetValue - startValue);
3676 animation.AnimateTo(Property(actor, "test-property"), targetValue);
3678 float ninetyFivePercentProgress(startValue + relativeValue*0.95f);
3680 // Start the animation
3683 bool signalReceived(false);
3684 AnimationFinishCheck finishCheck(signalReceived);
3685 animation.FinishedSignal().Connect(&application, finishCheck);
3687 application.SendNotification();
3688 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3690 // We didn't expect the animation to finish yet
3691 application.SendNotification();
3692 finishCheck.CheckSignalNotReceived();
3693 DALI_TEST_EQUALS( actor.GetProperty<float>(index), ninetyFivePercentProgress, TEST_LOCATION );
3695 application.SendNotification();
3696 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3698 // We did expect the animation to finish
3699 application.SendNotification();
3700 finishCheck.CheckSignalReceived();
3701 DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
3705 int UtcDaliAnimationAnimateToFloatAlphaFunction(void)
3707 TestApplication application;
3709 Actor actor = Actor::New();
3711 // Register a float property
3712 float startValue(10.0f);
3713 Property::Index index = actor.RegisterProperty( "test-property", startValue );
3714 Stage::GetCurrent().Add(actor);
3715 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
3717 // Build the animation
3718 float durationSeconds(1.0f);
3719 Animation animation = Animation::New(durationSeconds);
3720 float targetValue(90.0f);
3721 float relativeValue(targetValue - startValue);
3722 animation.AnimateTo(Property(actor, index), targetValue, AlphaFunctions::EaseOut);
3724 float ninetyFivePercentProgress(startValue + relativeValue*0.95f);
3726 // Start the animation
3729 bool signalReceived(false);
3730 AnimationFinishCheck finishCheck(signalReceived);
3731 animation.FinishedSignal().Connect(&application, finishCheck);
3733 application.SendNotification();
3734 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3736 // We didn't expect the animation to finish yet
3737 application.SendNotification();
3738 finishCheck.CheckSignalNotReceived();
3740 // The position should have moved more, than with a linear alpha function
3741 float current(actor.GetProperty<float>(index));
3742 DALI_TEST_CHECK( current > ninetyFivePercentProgress );
3744 application.SendNotification();
3745 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3747 // We did expect the animation to finish
3748 application.SendNotification();
3749 finishCheck.CheckSignalReceived();
3750 DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
3754 int UtcDaliAnimationAnimateToFloatTimePeriod(void)
3756 TestApplication application;
3758 Actor actor = Actor::New();
3760 // Register a float property
3761 float startValue(10.0f);
3762 Property::Index index = actor.RegisterProperty( "test-property", startValue );
3763 Stage::GetCurrent().Add(actor);
3764 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
3766 // Build the animation
3767 float durationSeconds(1.0f);
3768 Animation animation = Animation::New(durationSeconds);
3769 float targetValue(30.0f);
3770 float relativeValue(targetValue - startValue);
3772 animation.AnimateTo(Property(actor, index),
3774 TimePeriod(delay, durationSeconds - delay));
3776 // Start the animation
3779 bool signalReceived(false);
3780 AnimationFinishCheck finishCheck(signalReceived);
3781 animation.FinishedSignal().Connect(&application, finishCheck);
3783 application.SendNotification();
3784 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
3786 // We didn't expect the animation to finish yet
3787 application.SendNotification();
3788 finishCheck.CheckSignalNotReceived();
3789 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
3791 application.SendNotification();
3792 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
3794 // We didn't expect the animation to finish yet
3795 application.SendNotification();
3796 finishCheck.CheckSignalNotReceived();
3797 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
3799 application.SendNotification();
3800 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
3802 // We did expect the animation to finish
3803 application.SendNotification();
3804 finishCheck.CheckSignalReceived();
3805 DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
3809 int UtcDaliAnimationAnimateToFloatAlphaFunctionTimePeriod(void)
3811 TestApplication application;
3813 Actor actor = Actor::New();
3815 // Register a float property
3816 float startValue(10.0f);
3817 Property::Index index = actor.RegisterProperty( "test-property", startValue );
3818 Stage::GetCurrent().Add(actor);
3819 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
3821 // Build the animation
3822 float durationSeconds(1.0f);
3823 Animation animation = Animation::New(durationSeconds);
3824 float targetValue(30.0f);
3825 float relativeValue(targetValue - startValue);
3827 animation.AnimateTo(Property(actor, index),
3829 AlphaFunctions::Linear,
3830 TimePeriod(delay, durationSeconds - delay));
3832 // Start the animation
3835 bool signalReceived(false);
3836 AnimationFinishCheck finishCheck(signalReceived);
3837 animation.FinishedSignal().Connect(&application, finishCheck);
3839 application.SendNotification();
3840 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
3842 // We didn't expect the animation to finish yet
3843 application.SendNotification();
3844 finishCheck.CheckSignalNotReceived();
3845 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
3847 application.SendNotification();
3848 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
3850 // We didn't expect the animation to finish yet
3851 application.SendNotification();
3852 finishCheck.CheckSignalNotReceived();
3853 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
3855 application.SendNotification();
3856 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
3858 // We did expect the animation to finish
3859 application.SendNotification();
3860 finishCheck.CheckSignalReceived();
3861 DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
3865 int UtcDaliAnimationAnimateToInteger(void)
3867 TestApplication application;
3869 Actor actor = Actor::New();
3871 // Register an integer property
3873 Property::Index index = actor.RegisterProperty( "test-property", startValue );
3874 Stage::GetCurrent().Add(actor);
3875 DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
3877 // Build the animation
3878 float durationSeconds(2.0f);
3879 Animation animation = Animation::New(durationSeconds);
3880 int targetValue(50);
3881 int relativeValue(targetValue - startValue);
3882 animation.AnimateTo(Property(actor, "test-property"), targetValue);
3884 int ninetyFivePercentProgress(static_cast<int>(startValue + relativeValue*0.95f + 0.5f));
3886 // Start the animation
3889 bool signalReceived(false);
3890 AnimationFinishCheck finishCheck(signalReceived);
3891 animation.FinishedSignal().Connect(&application, finishCheck);
3893 application.SendNotification();
3894 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3896 // We didn't expect the animation to finish yet
3897 application.SendNotification();
3898 finishCheck.CheckSignalNotReceived();
3899 DALI_TEST_EQUALS( actor.GetProperty<int>(index), ninetyFivePercentProgress, TEST_LOCATION );
3901 application.SendNotification();
3902 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3904 // We did expect the animation to finish
3905 application.SendNotification();
3906 finishCheck.CheckSignalReceived();
3907 DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
3911 int UtcDaliAnimationAnimateToIntegerAlphaFunction(void)
3913 TestApplication application;
3915 Actor actor = Actor::New();
3917 // Register an integer property
3919 Property::Index index = actor.RegisterProperty( "test-property", startValue );
3920 Stage::GetCurrent().Add(actor);
3921 DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
3923 // Build the animation
3924 float durationSeconds(1.0f);
3925 Animation animation = Animation::New(durationSeconds);
3926 int targetValue(90);
3927 int relativeValue(targetValue - startValue);
3928 animation.AnimateTo(Property(actor, index), targetValue, AlphaFunctions::EaseOut);
3930 int ninetyFivePercentProgress(static_cast<int>(startValue + relativeValue*0.95f + 0.5f));
3932 // Start the animation
3935 bool signalReceived(false);
3936 AnimationFinishCheck finishCheck(signalReceived);
3937 animation.FinishedSignal().Connect(&application, finishCheck);
3939 application.SendNotification();
3940 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3942 // We didn't expect the animation to finish yet
3943 application.SendNotification();
3944 finishCheck.CheckSignalNotReceived();
3946 // The position should have moved more, than with a linear alpha function
3947 int current(actor.GetProperty<int>(index));
3948 DALI_TEST_CHECK( current > ninetyFivePercentProgress );
3950 application.SendNotification();
3951 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3953 // We did expect the animation to finish
3954 application.SendNotification();
3955 finishCheck.CheckSignalReceived();
3956 DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
3960 int UtcDaliAnimationAnimateToIntegerTimePeriod(void)
3962 TestApplication application;
3964 Actor actor = Actor::New();
3966 // Register an integer property
3968 Property::Index index = actor.RegisterProperty( "test-property", startValue );
3969 Stage::GetCurrent().Add(actor);
3970 DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
3972 // Build the animation
3973 float durationSeconds(1.0f);
3974 Animation animation = Animation::New(durationSeconds);
3975 int targetValue(30);
3976 int relativeValue(targetValue - startValue);
3978 animation.AnimateTo(Property(actor, index),
3980 TimePeriod(delay, durationSeconds - delay));
3982 // Start the animation
3985 bool signalReceived(false);
3986 AnimationFinishCheck finishCheck(signalReceived);
3987 animation.FinishedSignal().Connect(&application, finishCheck);
3989 application.SendNotification();
3990 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
3992 // We didn't expect the animation to finish yet
3993 application.SendNotification();
3994 finishCheck.CheckSignalNotReceived();
3995 DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
3997 application.SendNotification();
3998 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
4000 // We didn't expect the animation to finish yet
4001 application.SendNotification();
4002 finishCheck.CheckSignalNotReceived();
4003 DALI_TEST_EQUALS( actor.GetProperty<int>(index), static_cast<int>(startValue+(relativeValue*0.5f)+0.5f), TEST_LOCATION );
4005 application.SendNotification();
4006 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
4008 // We did expect the animation to finish
4009 application.SendNotification();
4010 finishCheck.CheckSignalReceived();
4011 DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
4015 int UtcDaliAnimationAnimateToIntegerAlphaFunctionTimePeriod(void)
4017 TestApplication application;
4019 Actor actor = Actor::New();
4021 // Register an integer property
4023 Property::Index index = actor.RegisterProperty( "test-property", startValue );
4024 Stage::GetCurrent().Add(actor);
4025 DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
4027 // Build the animation
4028 float durationSeconds(1.0f);
4029 Animation animation = Animation::New(durationSeconds);
4030 int targetValue(30);
4031 int relativeValue(targetValue - startValue);
4033 animation.AnimateTo(Property(actor, index),
4035 AlphaFunctions::Linear,
4036 TimePeriod(delay, durationSeconds - delay));
4038 // Start the animation
4041 bool signalReceived(false);
4042 AnimationFinishCheck finishCheck(signalReceived);
4043 animation.FinishedSignal().Connect(&application, finishCheck);
4045 application.SendNotification();
4046 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
4048 // We didn't expect the animation to finish yet
4049 application.SendNotification();
4050 finishCheck.CheckSignalNotReceived();
4051 DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
4053 application.SendNotification();
4054 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
4056 // We didn't expect the animation to finish yet
4057 application.SendNotification();
4058 finishCheck.CheckSignalNotReceived();
4059 DALI_TEST_EQUALS( actor.GetProperty<int>(index), static_cast<int>(startValue+(relativeValue*0.5f)+0.5f), TEST_LOCATION );
4061 application.SendNotification();
4062 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
4064 // We did expect the animation to finish
4065 application.SendNotification();
4066 finishCheck.CheckSignalReceived();
4067 DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
4071 int UtcDaliAnimationAnimateToVector2(void)
4073 TestApplication application;
4075 Actor actor = Actor::New();
4077 // Register a Vector2 property
4078 Vector2 startValue(-50.0f, -50.0f);
4079 Property::Index index = actor.RegisterProperty( "test-property", startValue );
4080 Stage::GetCurrent().Add(actor);
4081 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
4083 // Build the animation
4084 float durationSeconds(2.0f);
4085 Animation animation = Animation::New(durationSeconds);
4086 Vector2 targetValue(50.0f, 50.0f);
4087 Vector2 relativeValue(targetValue - startValue);
4088 animation.AnimateTo(Property(actor, index), targetValue);
4090 Vector2 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
4092 // Start the animation
4095 bool signalReceived(false);
4096 AnimationFinishCheck finishCheck(signalReceived);
4097 animation.FinishedSignal().Connect(&application, finishCheck);
4099 application.SendNotification();
4100 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
4102 // We didn't expect the animation to finish yet
4103 application.SendNotification();
4104 finishCheck.CheckSignalNotReceived();
4105 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), ninetyFivePercentProgress, TEST_LOCATION );
4107 application.SendNotification();
4108 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
4110 // We did expect the animation to finish
4111 application.SendNotification();
4112 finishCheck.CheckSignalReceived();
4113 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
4117 int UtcDaliAnimationAnimateToVector2AlphaFunction(void)
4119 TestApplication application;
4121 Actor actor = Actor::New();
4123 // Register a Vector2 property
4124 Vector2 startValue(1000.0f, 1000.0f);
4125 Property::Index index = actor.RegisterProperty( "test-property", startValue );
4126 Stage::GetCurrent().Add(actor);
4127 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
4129 // Build the animation
4130 float durationSeconds(1.0f);
4131 Animation animation = Animation::New(durationSeconds);
4132 Vector2 targetValue(9000.0f, 9000.0f);
4133 Vector2 relativeValue(targetValue - startValue);
4134 animation.AnimateTo(Property(actor, "test-property"), targetValue, AlphaFunctions::EaseOut);
4136 Vector2 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
4138 // Start the animation
4141 bool signalReceived(false);
4142 AnimationFinishCheck finishCheck(signalReceived);
4143 animation.FinishedSignal().Connect(&application, finishCheck);
4145 application.SendNotification();
4146 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
4148 // We didn't expect the animation to finish yet
4149 application.SendNotification();
4150 finishCheck.CheckSignalNotReceived();
4152 // The position should have moved more, than with a linear alpha function
4153 Vector2 current(actor.GetProperty<Vector2>(index));
4154 DALI_TEST_CHECK( current.x > ninetyFivePercentProgress.x );
4155 DALI_TEST_CHECK( current.y > ninetyFivePercentProgress.y );
4157 application.SendNotification();
4158 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
4160 // We did expect the animation to finish
4161 application.SendNotification();
4162 finishCheck.CheckSignalReceived();
4163 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
4167 int UtcDaliAnimationAnimateToVector2TimePeriod(void)
4169 TestApplication application;
4171 Actor actor = Actor::New();
4173 // Register a Vector2 property
4174 Vector2 startValue(10.0f, 10.0f);
4175 Property::Index index = actor.RegisterProperty( "test-property", startValue );
4176 Stage::GetCurrent().Add(actor);
4177 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
4179 // Build the animation
4180 float durationSeconds(1.0f);
4181 Animation animation = Animation::New(durationSeconds);
4182 Vector2 targetValue(-10.0f, 20.0f);
4183 Vector2 relativeValue(targetValue - startValue);
4185 animation.AnimateTo(Property(actor, index),
4187 TimePeriod(delay, durationSeconds - delay));
4189 // Start the animation
4192 bool signalReceived(false);
4193 AnimationFinishCheck finishCheck(signalReceived);
4194 animation.FinishedSignal().Connect(&application, finishCheck);
4196 application.SendNotification();
4197 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
4199 // We didn't expect the animation to finish yet
4200 application.SendNotification();
4201 finishCheck.CheckSignalNotReceived();
4202 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
4204 application.SendNotification();
4205 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
4207 // We didn't expect the animation to finish yet
4208 application.SendNotification();
4209 finishCheck.CheckSignalNotReceived();
4210 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
4212 application.SendNotification();
4213 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
4215 // We did expect the animation to finish
4216 application.SendNotification();
4217 finishCheck.CheckSignalReceived();
4218 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
4222 int UtcDaliAnimationAnimateToVector2AlphaFunctionTimePeriod(void)
4224 TestApplication application;
4226 Actor actor = Actor::New();
4228 // Register a Vector2 property
4229 Vector2 startValue(10.0f, 10.0f);
4230 Property::Index index = actor.RegisterProperty( "test-property", startValue );
4231 Stage::GetCurrent().Add(actor);
4232 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
4234 // Build the animation
4235 float durationSeconds(1.0f);
4236 Animation animation = Animation::New(durationSeconds);
4237 Vector2 targetValue(30.0f, 30.0f);
4238 Vector2 relativeValue(targetValue - startValue);
4240 animation.AnimateTo(Property(actor, index),
4242 AlphaFunctions::Linear,
4243 TimePeriod(delay, durationSeconds - delay));
4245 // Start the animation
4248 bool signalReceived(false);
4249 AnimationFinishCheck finishCheck(signalReceived);
4250 animation.FinishedSignal().Connect(&application, finishCheck);
4252 application.SendNotification();
4253 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
4255 // We didn't expect the animation to finish yet
4256 application.SendNotification();
4257 finishCheck.CheckSignalNotReceived();
4258 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
4260 application.SendNotification();
4261 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
4263 // We didn't expect the animation to finish yet
4264 application.SendNotification();
4265 finishCheck.CheckSignalNotReceived();
4266 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
4268 application.SendNotification();
4269 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
4271 // We did expect the animation to finish
4272 application.SendNotification();
4273 finishCheck.CheckSignalReceived();
4274 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
4278 int UtcDaliAnimationAnimateToVector3(void)
4280 TestApplication application;
4282 Actor actor = Actor::New();
4284 // Register a Vector3 property
4285 Vector3 startValue(-50.0f, -50.0f, -50.0f);
4286 Property::Index index = actor.RegisterProperty( "test-property", startValue );
4287 Stage::GetCurrent().Add(actor);
4288 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
4290 // Build the animation
4291 float durationSeconds(2.0f);
4292 Animation animation = Animation::New(durationSeconds);
4293 Vector3 targetValue(50.0f, 50.0f, 50.0f);
4294 Vector3 relativeValue(targetValue - startValue);
4295 animation.AnimateTo(Property(actor, index), targetValue);
4297 Vector3 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
4299 // Start the animation
4302 bool signalReceived(false);
4303 AnimationFinishCheck finishCheck(signalReceived);
4304 animation.FinishedSignal().Connect(&application, finishCheck);
4306 application.SendNotification();
4307 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
4309 // We didn't expect the animation to finish yet
4310 application.SendNotification();
4311 finishCheck.CheckSignalNotReceived();
4312 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), ninetyFivePercentProgress, TEST_LOCATION );
4314 application.SendNotification();
4315 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
4317 // We did expect the animation to finish
4318 application.SendNotification();
4319 finishCheck.CheckSignalReceived();
4320 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
4324 int UtcDaliAnimationAnimateToVector3AlphaFunction(void)
4326 TestApplication application;
4328 Actor actor = Actor::New();
4330 // Register a Vector3 property
4331 Vector3 startValue(1000.0f, 1000.0f, 1000.0f);
4332 Property::Index index = actor.RegisterProperty( "test-property", startValue );
4333 Stage::GetCurrent().Add(actor);
4334 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
4336 // Build the animation
4337 float durationSeconds(1.0f);
4338 Animation animation = Animation::New(durationSeconds);
4339 Vector3 targetValue(9000.0f, 9000.0f, 9000.0f);
4340 Vector3 relativeValue(targetValue - startValue);
4341 animation.AnimateTo(Property(actor, index), targetValue, AlphaFunctions::EaseOut);
4343 Vector3 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
4345 // Start the animation
4348 bool signalReceived(false);
4349 AnimationFinishCheck finishCheck(signalReceived);
4350 animation.FinishedSignal().Connect(&application, finishCheck);
4352 application.SendNotification();
4353 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
4355 // We didn't expect the animation to finish yet
4356 application.SendNotification();
4357 finishCheck.CheckSignalNotReceived();
4359 // The position should have moved more, than with a linear alpha function
4360 Vector3 current(actor.GetProperty<Vector3>(index));
4361 DALI_TEST_CHECK( current.x > ninetyFivePercentProgress.x );
4362 DALI_TEST_CHECK( current.y > ninetyFivePercentProgress.y );
4363 DALI_TEST_CHECK( current.z > ninetyFivePercentProgress.z );
4365 application.SendNotification();
4366 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
4368 // We did expect the animation to finish
4369 application.SendNotification();
4370 finishCheck.CheckSignalReceived();
4371 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
4375 int UtcDaliAnimationAnimateToVector3TimePeriod(void)
4377 TestApplication application;
4379 Actor actor = Actor::New();
4381 // Register a Vector3 property
4382 Vector3 startValue(10.0f, 10.0f, 10.0f);
4383 Property::Index index = actor.RegisterProperty( "test-property", startValue );
4384 Stage::GetCurrent().Add(actor);
4385 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
4387 // Build the animation
4388 float durationSeconds(1.0f);
4389 Animation animation = Animation::New(durationSeconds);
4390 Vector3 targetValue(-10.0f, 20.0f, 100.0f);
4391 Vector3 relativeValue(targetValue - startValue);
4393 animation.AnimateTo(Property(actor, index),
4395 TimePeriod(delay, durationSeconds - delay));
4397 // Start the animation
4400 bool signalReceived(false);
4401 AnimationFinishCheck finishCheck(signalReceived);
4402 animation.FinishedSignal().Connect(&application, finishCheck);
4404 application.SendNotification();
4405 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
4407 // We didn't expect the animation to finish yet
4408 application.SendNotification();
4409 finishCheck.CheckSignalNotReceived();
4410 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
4412 application.SendNotification();
4413 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
4415 // We didn't expect the animation to finish yet
4416 application.SendNotification();
4417 finishCheck.CheckSignalNotReceived();
4418 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
4420 application.SendNotification();
4421 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
4423 // We did expect the animation to finish
4424 application.SendNotification();
4425 finishCheck.CheckSignalReceived();
4426 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
4430 int UtcDaliAnimationAnimateToVector3AlphaFunctionTimePeriod(void)
4432 TestApplication application;
4434 Actor actor = Actor::New();
4436 // Register a Vector3 property
4437 Vector3 startValue(10.0f, 10.0f, 10.0f);
4438 Property::Index index = actor.RegisterProperty( "test-property", startValue );
4439 Stage::GetCurrent().Add(actor);
4440 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
4442 // Build the animation
4443 float durationSeconds(1.0f);
4444 Animation animation = Animation::New(durationSeconds);
4445 Vector3 targetValue(30.0f, 30.0f, 30.0f);
4446 Vector3 relativeValue(targetValue - startValue);
4448 animation.AnimateTo(Property(actor, "test-property"),
4450 AlphaFunctions::Linear,
4451 TimePeriod(delay, durationSeconds - delay));
4453 // Start the animation
4456 bool signalReceived(false);
4457 AnimationFinishCheck finishCheck(signalReceived);
4458 animation.FinishedSignal().Connect(&application, finishCheck);
4460 application.SendNotification();
4461 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
4463 // We didn't expect the animation to finish yet
4464 application.SendNotification();
4465 finishCheck.CheckSignalNotReceived();
4466 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
4468 application.SendNotification();
4469 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
4471 // We didn't expect the animation to finish yet
4472 application.SendNotification();
4473 finishCheck.CheckSignalNotReceived();
4474 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
4476 application.SendNotification();
4477 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
4479 // We did expect the animation to finish
4480 application.SendNotification();
4481 finishCheck.CheckSignalReceived();
4482 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
4486 int UtcDaliAnimationAnimateToVector3Component(void)
4488 TestApplication application;
4490 Actor actor = Actor::New();
4492 // Register a Vector3 property
4493 Vector3 startValue(10.0f, 10.0f, 10.0f);
4494 Property::Index index = actor.RegisterProperty( "test-property", startValue );
4495 Stage::GetCurrent().Add(actor);
4496 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
4498 // Build the animation
4499 float durationSeconds(1.0f);
4500 Animation animation = Animation::New(durationSeconds);
4501 Vector3 targetValue(30.0f, 30.0f, 10.0f);
4502 Vector3 relativeValue(targetValue - startValue);
4504 animation.AnimateTo(Property(actor, "test-property", 0),
4506 AlphaFunctions::Linear,
4507 TimePeriod(delay, durationSeconds - delay));
4508 animation.AnimateTo(Property(actor, index, 1),
4510 AlphaFunctions::Linear,
4511 TimePeriod(delay, durationSeconds - delay));
4513 // Start the animation
4516 bool signalReceived(false);
4517 AnimationFinishCheck finishCheck(signalReceived);
4518 animation.FinishedSignal().Connect(&application, finishCheck);
4520 application.SendNotification();
4521 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
4523 // We didn't expect the animation to finish yet
4524 application.SendNotification();
4525 finishCheck.CheckSignalNotReceived();
4526 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
4528 application.SendNotification();
4529 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
4531 // We didn't expect the animation to finish yet
4532 application.SendNotification();
4533 finishCheck.CheckSignalNotReceived();
4534 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
4536 application.SendNotification();
4537 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
4539 // We did expect the animation to finish
4540 application.SendNotification();
4541 finishCheck.CheckSignalReceived();
4542 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
4546 int UtcDaliAnimationAnimateToVector4(void)
4548 TestApplication application;
4550 Actor actor = Actor::New();
4552 // Register a Vector4 property
4553 Vector4 startValue(-50.0f, -40.0f, -30.0f, -20.0f);
4554 Property::Index index = actor.RegisterProperty( "test-property", startValue );
4555 Stage::GetCurrent().Add(actor);
4556 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
4558 // Build the animation
4559 float durationSeconds(2.0f);
4560 Animation animation = Animation::New(durationSeconds);
4561 Vector4 targetValue(50.0f, 50.0f, 50.0f, 50.0f);
4562 Vector4 relativeValue(targetValue - startValue);
4563 animation.AnimateTo(Property(actor, index), targetValue);
4565 Vector4 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
4567 // Start the animation
4570 bool signalReceived(false);
4571 AnimationFinishCheck finishCheck(signalReceived);
4572 animation.FinishedSignal().Connect(&application, finishCheck);
4574 application.SendNotification();
4575 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
4577 // We didn't expect the animation to finish yet
4578 application.SendNotification();
4579 finishCheck.CheckSignalNotReceived();
4580 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), ninetyFivePercentProgress, TEST_LOCATION );
4582 application.SendNotification();
4583 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
4585 // We did expect the animation to finish
4586 application.SendNotification();
4587 finishCheck.CheckSignalReceived();
4588 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
4592 int UtcDaliAnimationAnimateToVector4AlphaFunction(void)
4594 TestApplication application;
4596 Actor actor = Actor::New();
4598 // Register a Vector4 property
4599 Vector4 startValue(1000.0f, 1000.0f, 1000.0f, 1000.0f);
4600 Property::Index index = actor.RegisterProperty( "test-property", startValue );
4601 Stage::GetCurrent().Add(actor);
4602 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
4604 // Build the animation
4605 float durationSeconds(1.0f);
4606 Animation animation = Animation::New(durationSeconds);
4607 Vector4 targetValue(9000.0f, 9000.0f, 9000.0f, 9000.0f);
4608 Vector4 relativeValue(targetValue - startValue);
4609 animation.AnimateTo(Property(actor, index), targetValue, AlphaFunctions::EaseOut);
4611 Vector4 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
4613 // Start the animation
4616 bool signalReceived(false);
4617 AnimationFinishCheck finishCheck(signalReceived);
4618 animation.FinishedSignal().Connect(&application, finishCheck);
4620 application.SendNotification();
4621 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
4623 // We didn't expect the animation to finish yet
4624 application.SendNotification();
4625 finishCheck.CheckSignalNotReceived();
4627 // The position should have moved more, than with a linear alpha function
4628 Vector4 current(actor.GetProperty<Vector4>(index));
4629 DALI_TEST_CHECK( current.x > ninetyFivePercentProgress.x );
4630 DALI_TEST_CHECK( current.y > ninetyFivePercentProgress.y );
4631 DALI_TEST_CHECK( current.z > ninetyFivePercentProgress.z );
4632 DALI_TEST_CHECK( current.w > ninetyFivePercentProgress.w );
4634 application.SendNotification();
4635 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
4637 // We did expect the animation to finish
4638 application.SendNotification();
4639 finishCheck.CheckSignalReceived();
4640 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
4644 int UtcDaliAnimationAnimateToVector4TimePeriod(void)
4646 TestApplication application;
4648 Actor actor = Actor::New();
4650 // Register a Vector4 property
4651 Vector4 startValue(10.0f, 10.0f, 10.0f, 10.0f);
4652 Property::Index index = actor.RegisterProperty( "test-property", startValue );
4653 Stage::GetCurrent().Add(actor);
4654 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, VECTOR4_EPSILON, TEST_LOCATION );
4656 // Build the animation
4657 float durationSeconds(1.0f);
4658 Animation animation = Animation::New(durationSeconds);
4659 Vector4 targetValue(-10.0f, 20.0f, 100.0f, 100.0f);
4660 Vector4 relativeValue(targetValue - startValue);
4662 animation.AnimateTo(Property(actor, index),
4664 TimePeriod(delay, durationSeconds - delay));
4666 // Start the animation
4669 bool signalReceived(false);
4670 AnimationFinishCheck finishCheck(signalReceived);
4671 animation.FinishedSignal().Connect(&application, finishCheck);
4673 application.SendNotification();
4674 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
4676 // We didn't expect the animation to finish yet
4677 application.SendNotification();
4678 finishCheck.CheckSignalNotReceived();
4679 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, VECTOR4_EPSILON, TEST_LOCATION );
4681 application.SendNotification();
4682 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
4684 // We didn't expect the animation to finish yet
4685 application.SendNotification();
4686 finishCheck.CheckSignalNotReceived();
4687 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue+(relativeValue*0.5f), VECTOR4_EPSILON, TEST_LOCATION );
4689 application.SendNotification();
4690 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
4692 // We did expect the animation to finish
4693 application.SendNotification();
4694 finishCheck.CheckSignalReceived();
4695 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, VECTOR4_EPSILON, TEST_LOCATION );
4699 int UtcDaliAnimationAnimateToVector4AlphaFunctionTimePeriod(void)
4701 TestApplication application;
4703 Actor actor = Actor::New();
4705 // Register a Vector4 property
4706 Vector4 startValue(10.0f, 10.0f, 10.0f, 10.0f);
4707 Property::Index index = actor.RegisterProperty( "test-property", startValue );
4708 Stage::GetCurrent().Add(actor);
4709 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
4711 // Build the animation
4712 float durationSeconds(1.0f);
4713 Animation animation = Animation::New(durationSeconds);
4714 Vector4 targetValue(30.0f, 30.0f, 30.0f, 30.0f);
4715 Vector4 relativeValue(targetValue - startValue);
4717 animation.AnimateTo(Property(actor, index),
4719 AlphaFunctions::Linear,
4720 TimePeriod(delay, durationSeconds - delay));
4722 // Start the animation
4725 bool signalReceived(false);
4726 AnimationFinishCheck finishCheck(signalReceived);
4727 animation.FinishedSignal().Connect(&application, finishCheck);
4729 application.SendNotification();
4730 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
4732 // We didn't expect the animation to finish yet
4733 application.SendNotification();
4734 finishCheck.CheckSignalNotReceived();
4735 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
4737 application.SendNotification();
4738 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
4740 // We didn't expect the animation to finish yet
4741 application.SendNotification();
4742 finishCheck.CheckSignalNotReceived();
4743 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
4745 application.SendNotification();
4746 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
4748 // We did expect the animation to finish
4749 application.SendNotification();
4750 finishCheck.CheckSignalReceived();
4751 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
4755 int UtcDaliAnimationAnimateToActorParentOrigin(void)
4757 TestApplication application;
4759 Actor actor = Actor::New();
4760 Stage::GetCurrent().Add(actor);
4761 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::TOP_LEFT, TEST_LOCATION );
4763 // Build the animation
4764 float durationSeconds(1.0f);
4765 Animation animation = Animation::New(durationSeconds);
4766 Vector3 targetParentOrigin(ParentOrigin::BOTTOM_RIGHT);
4770 animation.AnimateTo( Property(actor, Actor::PARENT_ORIGIN), targetParentOrigin );
4772 catch (Dali::DaliException& e)
4774 tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
4775 DALI_TEST_ASSERT(e, "IsPropertyAnimatable(index)", TEST_LOCATION);
4780 int UtcDaliAnimationAnimateToActorParentOriginX(void)
4782 TestApplication application;
4784 Actor actor = Actor::New();
4785 Stage::GetCurrent().Add(actor);
4786 float startValue(0.0f);
4787 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin().x, startValue, TEST_LOCATION );
4788 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::PARENT_ORIGIN_X), startValue, TEST_LOCATION );
4790 // Build the animation
4791 float durationSeconds(1.0f);
4792 Animation animation = Animation::New(durationSeconds);
4793 float targetX(1.0f);
4797 animation.AnimateTo( Property(actor, Actor::PARENT_ORIGIN_X), targetX );
4799 catch (Dali::DaliException& e)
4801 tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
4802 DALI_TEST_ASSERT(e, "IsPropertyAnimatable(index)", TEST_LOCATION);
4807 int UtcDaliAnimationAnimateToActorParentOriginY(void)
4809 TestApplication application;
4811 Actor actor = Actor::New();
4812 Stage::GetCurrent().Add(actor);
4813 float startValue(0.0f);
4814 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin().y, startValue, TEST_LOCATION );
4815 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::PARENT_ORIGIN_Y), startValue, TEST_LOCATION );
4817 // Build the animation
4818 float durationSeconds(1.0f);
4819 Animation animation = Animation::New(durationSeconds);
4820 float targetY(1.0f);
4824 animation.AnimateTo( Property(actor, Actor::PARENT_ORIGIN_Y), targetY );
4826 catch (Dali::DaliException& e)
4828 tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
4829 DALI_TEST_ASSERT(e, "IsPropertyAnimatable(index)", TEST_LOCATION);
4834 int UtcDaliAnimationAnimateToActorParentOriginZ(void)
4836 TestApplication application;
4838 Actor actor = Actor::New();
4839 Stage::GetCurrent().Add(actor);
4840 float startValue(0.5f);
4841 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin().z, startValue, TEST_LOCATION );
4842 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::PARENT_ORIGIN_Z), startValue, TEST_LOCATION );
4844 // Build the animation
4845 float durationSeconds(1.0f);
4846 Animation animation = Animation::New(durationSeconds);
4847 float targetZ(1.0f);
4851 animation.AnimateTo( Property(actor, Actor::PARENT_ORIGIN_Z), targetZ );
4853 catch (Dali::DaliException& e)
4855 tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
4856 DALI_TEST_ASSERT(e, "IsPropertyAnimatable(index)", TEST_LOCATION);
4861 int UtcDaliAnimationAnimateToActorAnchorPoint(void)
4863 TestApplication application;
4865 Actor actor = Actor::New();
4866 Stage::GetCurrent().Add(actor);
4867 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), AnchorPoint::CENTER, TEST_LOCATION );
4869 // Build the animation
4870 float durationSeconds(1.0f);
4871 Animation animation = Animation::New(durationSeconds);
4872 Vector3 targetAnchorPoint(AnchorPoint::TOP_LEFT);
4876 animation.AnimateTo( Property(actor, Actor::ANCHOR_POINT), targetAnchorPoint);
4878 catch (Dali::DaliException& e)
4880 tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
4881 DALI_TEST_ASSERT(e, "IsPropertyAnimatable(index)", TEST_LOCATION);
4886 int UtcDaliAnimationAnimateToActorAnchorPointX(void)
4888 TestApplication application;
4890 Actor actor = Actor::New();
4891 Stage::GetCurrent().Add(actor);
4892 float startValue(0.5f);
4893 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint().x, startValue, TEST_LOCATION );
4894 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::ANCHOR_POINT_X), startValue, TEST_LOCATION );
4896 // Build the animation
4897 float durationSeconds(1.0f);
4898 Animation animation = Animation::New(durationSeconds);
4899 float targetX(1.0f);
4903 animation.AnimateTo( Property(actor, Actor::ANCHOR_POINT_X), targetX );
4905 catch (Dali::DaliException& e)
4907 tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
4908 DALI_TEST_ASSERT(e, "IsPropertyAnimatable(index)", TEST_LOCATION);
4913 int UtcDaliAnimationAnimateToActorAnchorPointY(void)
4915 TestApplication application;
4917 Actor actor = Actor::New();
4918 Stage::GetCurrent().Add(actor);
4919 float startValue(0.5f);
4920 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint().y, startValue, TEST_LOCATION );
4921 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::ANCHOR_POINT_Y), startValue, TEST_LOCATION );
4923 // Build the animation
4924 float durationSeconds(1.0f);
4925 Animation animation = Animation::New(durationSeconds);
4926 float targetY(0.0f);
4930 animation.AnimateTo( Property(actor, Actor::ANCHOR_POINT_Y), targetY );
4932 catch (Dali::DaliException& e)
4934 tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
4935 DALI_TEST_ASSERT(e, "IsPropertyAnimatable(index)", TEST_LOCATION);
4940 int UtcDaliAnimationAnimateToActorAnchorPointZ(void)
4942 TestApplication application;
4944 Actor actor = Actor::New();
4945 Stage::GetCurrent().Add(actor);
4946 float startValue(0.5f);
4947 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint().z, startValue, TEST_LOCATION );
4948 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::ANCHOR_POINT_Z), startValue, TEST_LOCATION );
4950 // Build the animation
4951 float durationSeconds(1.0f);
4952 Animation animation = Animation::New(durationSeconds);
4953 float targetZ(100.0f);
4957 animation.AnimateTo( Property(actor, Actor::ANCHOR_POINT_Z), targetZ );
4959 catch (Dali::DaliException& e)
4961 tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
4962 DALI_TEST_ASSERT(e, "IsPropertyAnimatable(index)", TEST_LOCATION);
4967 int UtcDaliAnimationAnimateToActorSize(void)
4969 TestApplication application;
4971 Actor actor = Actor::New();
4972 Stage::GetCurrent().Add(actor);
4973 DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
4975 // Build the animation
4976 float durationSeconds(1.0f);
4977 Animation animation = Animation::New(durationSeconds);
4978 Vector3 targetSize(100.0f, 100.0f, 100.0f);
4979 animation.AnimateTo( Property(actor, Actor::SIZE), targetSize );
4981 Vector3 ninetyNinePercentProgress(targetSize * 0.99f);
4983 // Start the animation
4986 bool signalReceived(false);
4987 AnimationFinishCheck finishCheck(signalReceived);
4988 animation.FinishedSignal().Connect(&application, finishCheck);
4990 application.SendNotification();
4991 application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
4993 // We didn't expect the animation to finish yet
4994 application.SendNotification();
4995 finishCheck.CheckSignalNotReceived();
4996 DALI_TEST_EQUALS( actor.GetCurrentSize(), ninetyNinePercentProgress, TEST_LOCATION );
4998 application.SendNotification();
4999 application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
5001 // We did expect the animation to finish
5002 application.SendNotification();
5003 finishCheck.CheckSignalReceived();
5004 DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION );
5007 finishCheck.Reset();
5008 actor.SetSize(Vector3::ZERO);
5009 application.SendNotification();
5010 application.Render(0);
5011 DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
5013 // Repeat with a different (ease-in) alpha function
5014 animation = Animation::New(durationSeconds);
5015 animation.AnimateTo( Property(actor, Actor::SIZE), targetSize, AlphaFunctions::EaseIn);
5016 animation.FinishedSignal().Connect(&application, finishCheck);
5019 application.SendNotification();
5020 application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
5022 // We didn't expect the animation to finish yet
5023 application.SendNotification();
5024 finishCheck.CheckSignalNotReceived();
5026 // The size should have travelled less, than with a linear alpha function
5027 Vector3 current(actor.GetCurrentSize());
5028 DALI_TEST_CHECK( current.x > 0.0f );
5029 DALI_TEST_CHECK( current.y > 0.0f );
5030 DALI_TEST_CHECK( current.z > 0.0f );
5031 DALI_TEST_CHECK( current.x < ninetyNinePercentProgress.x );
5032 DALI_TEST_CHECK( current.y < ninetyNinePercentProgress.y );
5033 DALI_TEST_CHECK( current.z < ninetyNinePercentProgress.z );
5035 application.SendNotification();
5036 application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
5038 // We did expect the animation to finish
5039 application.SendNotification();
5040 finishCheck.CheckSignalReceived();
5041 DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION );
5044 finishCheck.Reset();
5045 actor.SetSize(Vector3::ZERO);
5046 application.SendNotification();
5047 application.Render(0);
5048 DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
5050 // Repeat with a delay
5052 animation = Animation::New(durationSeconds);
5053 animation.AnimateTo( Property(actor, Actor::SIZE), targetSize, AlphaFunctions::Linear, TimePeriod(delay, durationSeconds - delay));
5054 animation.FinishedSignal().Connect(&application, finishCheck);
5057 application.SendNotification();
5058 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
5060 // We didn't expect the animation to finish yet
5061 application.SendNotification();
5062 finishCheck.CheckSignalNotReceived();
5063 DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
5065 application.SendNotification();
5066 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
5068 // We did expect the animation to finish
5069 application.SendNotification();
5070 finishCheck.CheckSignalReceived();
5071 DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION );
5075 int UtcDaliAnimationAnimateToActorSizeWidth(void)
5077 TestApplication application;
5079 Actor actor = Actor::New();
5080 Stage::GetCurrent().Add(actor);
5081 float startValue(0.0f);
5082 DALI_TEST_EQUALS( actor.GetCurrentSize().width, startValue, TEST_LOCATION );
5083 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SIZE_WIDTH), startValue, TEST_LOCATION );
5085 // Build the animation
5086 float durationSeconds(1.0f);
5087 Animation animation = Animation::New(durationSeconds);
5088 float targetWidth(10.0f);
5089 animation.AnimateTo( Property(actor, Actor::SIZE_WIDTH), targetWidth );
5091 float fiftyPercentProgress(startValue + (targetWidth - startValue)*0.5f);
5093 // Start the animation
5096 bool signalReceived(false);
5097 AnimationFinishCheck finishCheck(signalReceived);
5098 animation.FinishedSignal().Connect(&application, finishCheck);
5100 application.SendNotification();
5101 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
5103 // We didn't expect the animation to finish yet
5104 application.SendNotification();
5105 finishCheck.CheckSignalNotReceived();
5106 DALI_TEST_EQUALS( actor.GetCurrentSize().width, fiftyPercentProgress, TEST_LOCATION );
5107 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SIZE_WIDTH), fiftyPercentProgress, TEST_LOCATION );
5109 application.SendNotification();
5110 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
5112 // We did expect the animation to finish
5113 application.SendNotification();
5114 finishCheck.CheckSignalReceived();
5115 DALI_TEST_EQUALS( actor.GetCurrentSize().width, targetWidth, TEST_LOCATION );
5116 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SIZE_WIDTH), targetWidth, TEST_LOCATION );
5120 int UtcDaliAnimationAnimateToActorSizeHeight(void)
5122 TestApplication application;
5124 Actor actor = Actor::New();
5125 Stage::GetCurrent().Add(actor);
5126 float startValue(0.0f);
5127 DALI_TEST_EQUALS( actor.GetCurrentSize().height, startValue, TEST_LOCATION );
5128 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SIZE_HEIGHT), startValue, TEST_LOCATION );
5130 // Build the animation
5131 float durationSeconds(1.0f);
5132 Animation animation = Animation::New(durationSeconds);
5133 float targetHeight(-10.0f);
5134 animation.AnimateTo( Property(actor, Actor::SIZE_HEIGHT), targetHeight );
5136 float fiftyPercentProgress(startValue + (targetHeight - startValue)*0.5f);
5138 // Start the animation
5141 bool signalReceived(false);
5142 AnimationFinishCheck finishCheck(signalReceived);
5143 animation.FinishedSignal().Connect(&application, finishCheck);
5145 application.SendNotification();
5146 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
5148 // We didn't expect the animation to finish yet
5149 application.SendNotification();
5150 finishCheck.CheckSignalNotReceived();
5151 DALI_TEST_EQUALS( actor.GetCurrentSize().height, fiftyPercentProgress, TEST_LOCATION );
5152 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SIZE_HEIGHT), fiftyPercentProgress, TEST_LOCATION );
5154 application.SendNotification();
5155 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
5157 // We did expect the animation to finish
5158 application.SendNotification();
5159 finishCheck.CheckSignalReceived();
5160 DALI_TEST_EQUALS( actor.GetCurrentSize().height, targetHeight, TEST_LOCATION );
5161 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SIZE_HEIGHT), targetHeight, TEST_LOCATION );
5165 int UtcDaliAnimationAnimateToActorSizeDepth(void)
5167 TestApplication application;
5169 Actor actor = Actor::New();
5170 Stage::GetCurrent().Add(actor);
5171 float startValue(0.0f);
5172 DALI_TEST_EQUALS( actor.GetCurrentSize().depth, startValue, TEST_LOCATION );
5173 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SIZE_DEPTH), startValue, TEST_LOCATION );
5175 // Build the animation
5176 float durationSeconds(1.0f);
5177 Animation animation = Animation::New(durationSeconds);
5178 float targetDepth(-10.0f);
5179 animation.AnimateTo( Property(actor, Actor::SIZE_DEPTH), targetDepth );
5181 float fiftyPercentProgress(startValue + (targetDepth - startValue)*0.5f);
5183 // Start the animation
5186 bool signalReceived(false);
5187 AnimationFinishCheck finishCheck(signalReceived);
5188 animation.FinishedSignal().Connect(&application, finishCheck);
5190 application.SendNotification();
5191 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
5193 // We didn't expect the animation to finish yet
5194 application.SendNotification();
5195 finishCheck.CheckSignalNotReceived();
5196 DALI_TEST_EQUALS( actor.GetCurrentSize().depth, fiftyPercentProgress, TEST_LOCATION );
5197 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SIZE_DEPTH), fiftyPercentProgress, TEST_LOCATION );
5199 application.SendNotification();
5200 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
5202 // We did expect the animation to finish
5203 application.SendNotification();
5204 finishCheck.CheckSignalReceived();
5205 DALI_TEST_EQUALS( actor.GetCurrentSize().depth, targetDepth, TEST_LOCATION );
5206 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SIZE_DEPTH), targetDepth, TEST_LOCATION );
5210 int UtcDaliAnimationAnimateToActorPosition(void)
5212 TestApplication application;
5214 Actor actor = Actor::New();
5215 Stage::GetCurrent().Add(actor);
5216 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
5218 // Build the animation
5219 float durationSeconds(1.0f);
5220 Animation animation = Animation::New(durationSeconds);
5221 Vector3 targetPosition(200.0f, 200.0f, 200.0f);
5222 animation.AnimateTo(Property(actor, Actor::POSITION), targetPosition);
5224 Vector3 seventyFivePercentProgress(targetPosition * 0.75f);
5226 // Start the animation
5229 bool signalReceived(false);
5230 AnimationFinishCheck finishCheck(signalReceived);
5231 animation.FinishedSignal().Connect(&application, finishCheck);
5233 application.SendNotification();
5234 application.Render(static_cast<unsigned int>(durationSeconds*750.0f)/* 75% progress */);
5236 // We didn't expect the animation to finish yet
5237 application.SendNotification();
5238 finishCheck.CheckSignalNotReceived();
5239 DALI_TEST_EQUALS( actor.GetCurrentPosition(), seventyFivePercentProgress, TEST_LOCATION );
5241 application.SendNotification();
5242 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
5244 // We did expect the animation to finish
5245 application.SendNotification();
5246 finishCheck.CheckSignalReceived();
5247 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
5251 int UtcDaliAnimationAnimateToActorPositionX(void)
5253 TestApplication application;
5255 Actor actor = Actor::New();
5256 Stage::GetCurrent().Add(actor);
5257 float startValue(0.0f);
5258 DALI_TEST_EQUALS( actor.GetCurrentPosition().x, startValue, TEST_LOCATION );
5259 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_X), startValue, TEST_LOCATION );
5260 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_Y), startValue, TEST_LOCATION );
5261 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_Z), startValue, TEST_LOCATION );
5263 // Build the animation
5264 float durationSeconds(1.0f);
5265 Animation animation = Animation::New(durationSeconds);
5266 float targetX(1.0f);
5267 animation.AnimateTo( Property(actor, Actor::POSITION_X), targetX );
5269 float fiftyPercentProgress(startValue + (targetX - startValue)*0.5f);
5271 // Start the animation
5274 bool signalReceived(false);
5275 AnimationFinishCheck finishCheck(signalReceived);
5276 animation.FinishedSignal().Connect(&application, finishCheck);
5278 application.SendNotification();
5279 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
5281 // We didn't expect the animation to finish yet
5282 application.SendNotification();
5283 finishCheck.CheckSignalNotReceived();
5284 DALI_TEST_EQUALS( actor.GetCurrentPosition().x, fiftyPercentProgress, TEST_LOCATION );
5285 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_X), fiftyPercentProgress, TEST_LOCATION );
5286 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_Y), startValue, TEST_LOCATION );
5287 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_Z), startValue, TEST_LOCATION );
5289 application.SendNotification();
5290 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
5292 // We did expect the animation to finish
5293 application.SendNotification();
5294 finishCheck.CheckSignalReceived();
5295 DALI_TEST_EQUALS( actor.GetCurrentPosition().x, targetX, TEST_LOCATION );
5296 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_X), targetX, TEST_LOCATION );
5297 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_Y), startValue, TEST_LOCATION );
5298 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_Z), startValue, TEST_LOCATION );
5302 int UtcDaliAnimationAnimateToActorPositionY(void)
5304 TestApplication application;
5306 Actor actor = Actor::New();
5307 Stage::GetCurrent().Add(actor);
5308 float startValue(0.0f);
5309 DALI_TEST_EQUALS( actor.GetCurrentPosition().y, startValue, TEST_LOCATION );
5310 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_X), startValue, TEST_LOCATION );
5311 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_Y), startValue, TEST_LOCATION );
5312 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_Z), startValue, TEST_LOCATION );
5314 // Build the animation
5315 float durationSeconds(1.0f);
5316 Animation animation = Animation::New(durationSeconds);
5317 float targetY(10.0f);
5318 animation.AnimateTo( Property(actor, Actor::POSITION_Y), targetY );
5320 float fiftyPercentProgress(startValue + (targetY - startValue)*0.5f);
5322 // Start the animation
5325 bool signalReceived(false);
5326 AnimationFinishCheck finishCheck(signalReceived);
5327 animation.FinishedSignal().Connect(&application, finishCheck);
5329 application.SendNotification();
5330 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
5332 // We didn't expect the animation to finish yet
5333 application.SendNotification();
5334 finishCheck.CheckSignalNotReceived();
5335 DALI_TEST_EQUALS( actor.GetCurrentPosition().y, fiftyPercentProgress, TEST_LOCATION );
5336 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_X), startValue, TEST_LOCATION );
5337 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_Y), fiftyPercentProgress, TEST_LOCATION );
5338 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_Z), startValue, TEST_LOCATION );
5340 application.SendNotification();
5341 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
5343 // We did expect the animation to finish
5344 application.SendNotification();
5345 finishCheck.CheckSignalReceived();
5346 DALI_TEST_EQUALS( actor.GetCurrentPosition().y, targetY, TEST_LOCATION );
5347 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_X), startValue, TEST_LOCATION );
5348 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_Y), targetY, TEST_LOCATION );
5349 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_Z), startValue, TEST_LOCATION );
5353 int UtcDaliAnimationAnimateToActorPositionZ(void)
5355 TestApplication application;
5357 Actor actor = Actor::New();
5358 Stage::GetCurrent().Add(actor);
5359 float startValue(0.0f);
5360 DALI_TEST_EQUALS( actor.GetCurrentPosition().z, startValue, TEST_LOCATION );
5361 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_X), startValue, TEST_LOCATION );
5362 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_Y), startValue, TEST_LOCATION );
5363 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_Z), startValue, TEST_LOCATION );
5365 // Build the animation
5366 float durationSeconds(1.0f);
5367 Animation animation = Animation::New(durationSeconds);
5368 float targetZ(-5.0f);
5369 animation.AnimateTo( Property(actor, Actor::POSITION_Z), targetZ );
5371 float fiftyPercentProgress(startValue + (targetZ - startValue)*0.5f);
5373 // Start the animation
5376 bool signalReceived(false);
5377 AnimationFinishCheck finishCheck(signalReceived);
5378 animation.FinishedSignal().Connect(&application, finishCheck);
5380 application.SendNotification();
5381 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
5383 // We didn't expect the animation to finish yet
5384 application.SendNotification();
5385 finishCheck.CheckSignalNotReceived();
5386 DALI_TEST_EQUALS( actor.GetCurrentPosition().z, fiftyPercentProgress, TEST_LOCATION );
5387 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_X), startValue, TEST_LOCATION );
5388 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_Y), startValue, TEST_LOCATION );
5389 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_Z), fiftyPercentProgress, TEST_LOCATION );
5391 application.SendNotification();
5392 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
5394 // We did expect the animation to finish
5395 application.SendNotification();
5396 finishCheck.CheckSignalReceived();
5397 DALI_TEST_EQUALS( actor.GetCurrentPosition().z, targetZ, TEST_LOCATION );
5398 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_X), startValue, TEST_LOCATION );
5399 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_Y), startValue, TEST_LOCATION );
5400 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_Z), targetZ, TEST_LOCATION );
5404 int UtcDaliAnimationAnimateToActorPositionAlphaFunction(void)
5406 TestApplication application;
5408 Actor actor = Actor::New();
5409 Stage::GetCurrent().Add(actor);
5410 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
5412 // Build the animation
5413 float durationSeconds(1.0f);
5414 Animation animation = Animation::New(durationSeconds);
5415 Vector3 targetPosition(200.0f, 200.0f, 200.0f);
5416 animation.AnimateTo(Property(actor, Actor::POSITION), targetPosition, AlphaFunctions::EaseIn);
5418 Vector3 seventyFivePercentProgress(targetPosition * 0.75f);
5420 // Start the animation
5423 bool signalReceived(false);
5424 AnimationFinishCheck finishCheck(signalReceived);
5425 animation.FinishedSignal().Connect(&application, finishCheck);
5427 application.SendNotification();
5428 application.Render(static_cast<unsigned int>(durationSeconds*750.0f)/* 75% progress */);
5430 // We didn't expect the animation to finish yet
5431 application.SendNotification();
5432 finishCheck.CheckSignalNotReceived();
5434 // The position should have moved less, than with a linear alpha function
5435 Vector3 current(actor.GetCurrentPosition());
5436 DALI_TEST_CHECK( current.x > Vector3::ZERO.x );
5437 DALI_TEST_CHECK( current.y > Vector3::ZERO.y );
5438 DALI_TEST_CHECK( current.z > Vector3::ZERO.z );
5439 DALI_TEST_CHECK( current.x < seventyFivePercentProgress.x );
5440 DALI_TEST_CHECK( current.y < seventyFivePercentProgress.y );
5441 DALI_TEST_CHECK( current.z < seventyFivePercentProgress.z );
5443 application.SendNotification();
5444 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
5446 // We did expect the animation to finish
5447 application.SendNotification();
5448 finishCheck.CheckSignalReceived();
5449 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
5453 int UtcDaliAnimationAnimateToActorPositionTimePeriod(void)
5455 TestApplication application;
5457 Actor actor = Actor::New();
5458 Stage::GetCurrent().Add(actor);
5459 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
5461 // Build the animation
5462 float durationSeconds(1.0f);
5463 Animation animation = Animation::New(durationSeconds);
5464 Vector3 targetPosition(200.0f, 200.0f, 200.0f);
5466 animation.AnimateTo( Property(actor, Actor::POSITION),
5468 TimePeriod( delay, durationSeconds - delay ) );
5470 Vector3 seventyFivePercentProgress(targetPosition * 0.75f);
5472 // Start the animation
5475 bool signalReceived(false);
5476 AnimationFinishCheck finishCheck(signalReceived);
5477 animation.FinishedSignal().Connect(&application, finishCheck);
5479 application.SendNotification();
5480 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
5482 // We didn't expect the animation to finish yet
5483 application.SendNotification();
5484 finishCheck.CheckSignalNotReceived();
5485 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
5487 application.SendNotification();
5488 application.Render(static_cast<unsigned int>(durationSeconds*500.0f*0.75)/* 7/8 animation progress, 3/4 animator progress */);
5490 // We didn't expect the animation to finish yet
5491 application.SendNotification();
5492 finishCheck.CheckSignalNotReceived();
5493 DALI_TEST_EQUALS( actor.GetCurrentPosition(), seventyFivePercentProgress, TEST_LOCATION );
5495 application.SendNotification();
5496 application.Render(static_cast<unsigned int>(durationSeconds*500.0f*0.25) + 1u/*just beyond the animation duration*/);
5498 // We did expect the animation to finish
5499 application.SendNotification();
5500 finishCheck.CheckSignalReceived();
5501 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
5505 int UtcDaliAnimationAnimateToActorPositionAlphaFunctionTimePeriod(void)
5507 TestApplication application;
5509 Actor actor = Actor::New();
5510 Stage::GetCurrent().Add(actor);
5511 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
5513 // Build the animation
5514 float durationSeconds(1.0f);
5515 Animation animation = Animation::New(durationSeconds);
5516 Vector3 targetPosition(200.0f, 200.0f, 200.0f);
5518 animation.AnimateTo( Property(actor, Actor::POSITION),
5520 AlphaFunctions::Linear,
5521 TimePeriod( delay, durationSeconds - delay ) );
5523 Vector3 seventyFivePercentProgress(targetPosition * 0.75f);
5525 // Start the animation
5528 bool signalReceived(false);
5529 AnimationFinishCheck finishCheck(signalReceived);
5530 animation.FinishedSignal().Connect(&application, finishCheck);
5532 application.SendNotification();
5533 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
5535 // We didn't expect the animation to finish yet
5536 application.SendNotification();
5537 finishCheck.CheckSignalNotReceived();
5538 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
5540 application.SendNotification();
5541 application.Render(static_cast<unsigned int>(durationSeconds*500.0f*0.75)/* 7/8 animation progress, 3/4 animator progress */);
5543 // We didn't expect the animation to finish yet
5544 application.SendNotification();
5545 finishCheck.CheckSignalNotReceived();
5546 DALI_TEST_EQUALS( actor.GetCurrentPosition(), seventyFivePercentProgress, TEST_LOCATION );
5548 application.SendNotification();
5549 application.Render(static_cast<unsigned int>(durationSeconds*500.0f*0.25) + 1u/*just beyond the animation duration*/);
5551 // We did expect the animation to finish
5552 application.SendNotification();
5553 finishCheck.CheckSignalReceived();
5554 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
5558 int UtcDaliAnimationAnimateToActorRotationAngleAxis(void)
5560 TestApplication application;
5562 Actor actor = Actor::New();
5563 actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
5564 Stage::GetCurrent().Add(actor);
5565 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5567 // Build the animation
5568 float durationSeconds(1.0f);
5569 Animation animation = Animation::New(durationSeconds);
5570 Degree targetRotationDegrees(90.0f);
5571 Radian targetRotationRadians(targetRotationDegrees);
5572 animation.AnimateTo( Property(actor, Actor::ROTATION), AngleAxis(targetRotationRadians, Vector3::YAXIS) );
5574 // Start the animation
5577 bool signalReceived(false);
5578 AnimationFinishCheck finishCheck(signalReceived);
5579 animation.FinishedSignal().Connect(&application, finishCheck);
5581 application.SendNotification();
5582 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
5584 // We didn't expect the animation to finish yet
5585 application.SendNotification();
5586 finishCheck.CheckSignalNotReceived();
5587 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.25f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5589 application.SendNotification();
5590 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
5592 // We didn't expect the animation to finish yet
5593 application.SendNotification();
5594 finishCheck.CheckSignalNotReceived();
5595 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.5f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5597 application.SendNotification();
5598 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
5600 // We didn't expect the animation to finish yet
5601 application.SendNotification();
5602 finishCheck.CheckSignalNotReceived();
5603 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.75f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5605 application.SendNotification();
5606 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
5608 // We did expect the animation to finish
5609 application.SendNotification();
5610 finishCheck.CheckSignalReceived();
5611 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5615 int UtcDaliAnimationAnimateToActorRotationQuaternion(void)
5617 TestApplication application;
5619 Actor actor = Actor::New();
5620 actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
5621 Stage::GetCurrent().Add(actor);
5622 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5624 // Build the animation
5625 float durationSeconds(1.0f);
5626 Animation animation = Animation::New(durationSeconds);
5627 Degree targetRotationDegrees(90.0f);
5628 Radian targetRotationRadians(targetRotationDegrees);
5629 Quaternion targetRotation(targetRotationRadians, Vector3::YAXIS);
5630 animation.AnimateTo( Property(actor, Actor::ROTATION), targetRotation );
5632 // Start the animation
5635 bool signalReceived(false);
5636 AnimationFinishCheck finishCheck(signalReceived);
5637 animation.FinishedSignal().Connect(&application, finishCheck);
5639 application.SendNotification();
5640 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
5642 // We didn't expect the animation to finish yet
5643 application.SendNotification();
5644 finishCheck.CheckSignalNotReceived();
5645 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.25f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5647 application.SendNotification();
5648 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
5650 // We didn't expect the animation to finish yet
5651 application.SendNotification();
5652 finishCheck.CheckSignalNotReceived();
5653 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.5f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5655 application.SendNotification();
5656 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
5658 // We didn't expect the animation to finish yet
5659 application.SendNotification();
5660 finishCheck.CheckSignalNotReceived();
5661 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.75f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5663 application.SendNotification();
5664 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
5666 // We did expect the animation to finish
5667 application.SendNotification();
5668 finishCheck.CheckSignalReceived();
5669 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5673 int UtcDaliAnimationAnimateToActorRotationAlphaFunction(void)
5675 TestApplication application;
5677 Actor actor = Actor::New();
5678 actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
5679 Stage::GetCurrent().Add(actor);
5680 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5682 // Build the animation
5683 float durationSeconds(1.0f);
5684 Animation animation = Animation::New(durationSeconds);
5685 Degree targetRotationDegrees(90.0f);
5686 Radian targetRotationRadians(targetRotationDegrees);
5687 animation.AnimateTo( Property(actor, Actor::ROTATION), AngleAxis(targetRotationDegrees, Vector3::YAXIS), AlphaFunctions::EaseIn);
5689 // Start the animation
5692 bool signalReceived(false);
5693 AnimationFinishCheck finishCheck(signalReceived);
5694 animation.FinishedSignal().Connect(&application, finishCheck);
5696 application.SendNotification();
5697 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
5699 // We didn't expect the animation to finish yet
5700 application.SendNotification();
5701 finishCheck.CheckSignalNotReceived();
5702 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(0.25f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5704 application.SendNotification();
5705 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
5707 // We didn't expect the animation to finish yet
5708 application.SendNotification();
5709 finishCheck.CheckSignalNotReceived();
5710 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(0.5f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5712 application.SendNotification();
5713 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
5715 // We didn't expect the animation to finish yet
5716 application.SendNotification();
5717 finishCheck.CheckSignalNotReceived();
5718 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(0.75f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5720 application.SendNotification();
5721 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
5723 // We did expect the animation to finish
5724 application.SendNotification();
5725 finishCheck.CheckSignalReceived();
5726 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5730 int UtcDaliAnimationAnimateToActorRotationTimePeriod(void)
5732 TestApplication application;
5734 Actor actor = Actor::New();
5735 actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
5736 Stage::GetCurrent().Add(actor);
5737 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5739 // Build the animation
5740 float durationSeconds(1.0f);
5741 Animation animation = Animation::New(durationSeconds);
5742 Degree targetRotationDegrees(90.0f);
5743 Radian targetRotationRadians(targetRotationDegrees);
5745 animation.AnimateTo( Property(actor, Actor::ROTATION), AngleAxis(targetRotationDegrees, Vector3::YAXIS), TimePeriod(delay, durationSeconds - delay));
5747 // Start the animation
5750 bool signalReceived(false);
5751 AnimationFinishCheck finishCheck(signalReceived);
5752 animation.FinishedSignal().Connect(&application, finishCheck);
5754 application.SendNotification();
5755 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
5757 // We didn't expect the animation to finish yet
5758 application.SendNotification();
5759 finishCheck.CheckSignalNotReceived();
5760 float progress = max(0.0f, 0.25f - delay) / (1.0f - delay);
5761 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * progress, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5763 application.SendNotification();
5764 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
5766 // We didn't expect the animation to finish yet
5767 application.SendNotification();
5768 finishCheck.CheckSignalNotReceived();
5769 progress = max(0.0f, 0.5f - delay) / (1.0f - delay);
5770 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * progress, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5772 application.SendNotification();
5773 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
5775 // We didn't expect the animation to finish yet
5776 application.SendNotification();
5777 finishCheck.CheckSignalNotReceived();
5778 progress = max(0.0f, 0.75f - delay) / (1.0f - delay);
5779 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * progress, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5781 application.SendNotification();
5782 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
5784 // We did expect the animation to finish
5785 application.SendNotification();
5786 finishCheck.CheckSignalReceived();
5787 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5791 int UtcDaliAnimationAnimateToActorRotationAlphaFunctionTimePeriod(void)
5793 TestApplication application;
5795 Actor actor = Actor::New();
5796 actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
5797 Stage::GetCurrent().Add(actor);
5798 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5800 // Build the animation
5801 float durationSeconds(1.0f);
5802 Animation animation = Animation::New(durationSeconds);
5803 Degree targetRotationDegrees(90.0f);
5804 Radian targetRotationRadians(targetRotationDegrees);
5806 animation.AnimateTo( Property(actor, Actor::ROTATION), AngleAxis(targetRotationDegrees, Vector3::YAXIS), AlphaFunctions::EaseIn, TimePeriod(delay, durationSeconds - delay));
5808 // Start the animation
5811 bool signalReceived(false);
5812 AnimationFinishCheck finishCheck(signalReceived);
5813 animation.FinishedSignal().Connect(&application, finishCheck);
5815 application.SendNotification();
5816 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
5818 // We didn't expect the animation to finish yet
5819 application.SendNotification();
5820 finishCheck.CheckSignalNotReceived();
5821 float progress = max(0.0f, 0.25f - delay) / (1.0f - delay);
5822 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5824 application.SendNotification();
5825 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
5827 // We didn't expect the animation to finish yet
5828 application.SendNotification();
5829 finishCheck.CheckSignalNotReceived();
5830 progress = max(0.0f, 0.5f - delay) / (1.0f - delay);
5831 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5833 application.SendNotification();
5834 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
5836 // We didn't expect the animation to finish yet
5837 application.SendNotification();
5838 finishCheck.CheckSignalNotReceived();
5839 progress = max(0.0f, 0.75f - delay) / (1.0f - delay);
5840 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5842 application.SendNotification();
5843 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
5845 // We did expect the animation to finish
5846 application.SendNotification();
5847 finishCheck.CheckSignalReceived();
5848 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5852 int UtcDaliAnimationAnimateToActorScale(void)
5854 TestApplication application;
5856 Actor actor = Actor::New();
5857 Stage::GetCurrent().Add(actor);
5858 DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
5860 // Build the animation
5861 float durationSeconds(1.0f);
5862 Animation animation = Animation::New(durationSeconds);
5863 Vector3 targetScale(2.0f, 2.0f, 2.0f);
5864 animation.AnimateTo( Property(actor, Actor::SCALE), targetScale );
5866 Vector3 ninetyNinePercentProgress(Vector3::ONE + (targetScale - Vector3::ONE)*0.99f);
5868 // Start the animation
5871 bool signalReceived(false);
5872 AnimationFinishCheck finishCheck(signalReceived);
5873 animation.FinishedSignal().Connect(&application, finishCheck);
5875 application.SendNotification();
5876 application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
5878 // We didn't expect the animation to finish yet
5879 application.SendNotification();
5880 finishCheck.CheckSignalNotReceived();
5881 DALI_TEST_EQUALS( actor.GetCurrentScale(), ninetyNinePercentProgress, TEST_LOCATION );
5883 application.SendNotification();
5884 application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
5886 // We did expect the animation to finish
5887 application.SendNotification();
5888 finishCheck.CheckSignalReceived();
5889 DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
5892 finishCheck.Reset();
5893 actor.SetScale(Vector3::ONE);
5894 application.SendNotification();
5895 application.Render(0);
5896 DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
5898 // Repeat with a different (ease-in) alpha function
5899 animation = Animation::New(durationSeconds);
5900 animation.AnimateTo( Property(actor, Actor::SCALE), targetScale, AlphaFunctions::EaseIn);
5901 animation.FinishedSignal().Connect(&application, finishCheck);
5904 application.SendNotification();
5905 application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
5907 // We didn't expect the animation to finish yet
5908 application.SendNotification();
5909 finishCheck.CheckSignalNotReceived();
5911 // The scale should have grown less, than with a linear alpha function
5912 Vector3 current(actor.GetCurrentScale());
5913 DALI_TEST_CHECK( current.x > 1.0f );
5914 DALI_TEST_CHECK( current.y > 1.0f );
5915 DALI_TEST_CHECK( current.z > 1.0f );
5916 DALI_TEST_CHECK( current.x < ninetyNinePercentProgress.x );
5917 DALI_TEST_CHECK( current.y < ninetyNinePercentProgress.y );
5918 DALI_TEST_CHECK( current.z < ninetyNinePercentProgress.z );
5920 application.SendNotification();
5921 application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
5923 // We did expect the animation to finish
5924 application.SendNotification();
5925 finishCheck.CheckSignalReceived();
5926 DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
5929 finishCheck.Reset();
5930 actor.SetScale(Vector3::ONE);
5931 application.SendNotification();
5932 application.Render(0);
5933 DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
5935 // Repeat with a delay
5937 animation = Animation::New(durationSeconds);
5938 animation.AnimateTo( Property(actor, Actor::SCALE), targetScale, AlphaFunctions::Linear, TimePeriod(delay, durationSeconds - delay));
5939 animation.FinishedSignal().Connect(&application, finishCheck);
5942 application.SendNotification();
5943 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
5945 // We didn't expect the animation to finish yet
5946 application.SendNotification();
5947 finishCheck.CheckSignalNotReceived();
5948 DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
5950 application.SendNotification();
5951 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
5953 // We did expect the animation to finish
5954 application.SendNotification();
5955 finishCheck.CheckSignalReceived();
5956 DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
5960 int UtcDaliAnimationAnimateToActorScaleX(void)
5962 TestApplication application;
5964 Actor actor = Actor::New();
5965 Stage::GetCurrent().Add(actor);
5966 float startValue(1.0f);
5967 DALI_TEST_EQUALS( actor.GetCurrentScale().x, startValue, TEST_LOCATION );
5968 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_X), startValue, TEST_LOCATION );
5969 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_Y), startValue, TEST_LOCATION );
5970 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_Z), startValue, TEST_LOCATION );
5972 // Build the animation
5973 float durationSeconds(1.0f);
5974 Animation animation = Animation::New(durationSeconds);
5975 float targetX(10.0f);
5976 animation.AnimateTo( Property(actor, Actor::SCALE_X), targetX );
5978 float fiftyPercentProgress(startValue + (targetX - startValue)*0.5f);
5980 // Start the animation
5983 bool signalReceived(false);
5984 AnimationFinishCheck finishCheck(signalReceived);
5985 animation.FinishedSignal().Connect(&application, finishCheck);
5987 application.SendNotification();
5988 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
5990 // We didn't expect the animation to finish yet
5991 application.SendNotification();
5992 finishCheck.CheckSignalNotReceived();
5993 DALI_TEST_EQUALS( actor.GetCurrentScale().x, fiftyPercentProgress, TEST_LOCATION );
5994 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_X), fiftyPercentProgress, TEST_LOCATION );
5995 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_Y), startValue, TEST_LOCATION );
5996 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_Z), startValue, TEST_LOCATION );
5998 application.SendNotification();
5999 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
6001 // We did expect the animation to finish
6002 application.SendNotification();
6003 finishCheck.CheckSignalReceived();
6004 DALI_TEST_EQUALS( actor.GetCurrentScale().x, targetX, TEST_LOCATION );
6005 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_X), targetX, TEST_LOCATION );
6006 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_Y), startValue, TEST_LOCATION );
6007 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_Z), startValue, TEST_LOCATION );
6011 int UtcDaliAnimationAnimateToActorScaleY(void)
6013 TestApplication application;
6015 Actor actor = Actor::New();
6016 Stage::GetCurrent().Add(actor);
6017 float startValue(1.0f);
6018 DALI_TEST_EQUALS( actor.GetCurrentScale().y, startValue, TEST_LOCATION );
6019 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_X), startValue, TEST_LOCATION );
6020 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_Y), startValue, TEST_LOCATION );
6021 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_Z), startValue, TEST_LOCATION );
6023 // Build the animation
6024 float durationSeconds(1.0f);
6025 Animation animation = Animation::New(durationSeconds);
6026 float targetY(1000.0f);
6027 animation.AnimateTo( Property(actor, Actor::SCALE_Y), targetY );
6029 float fiftyPercentProgress(startValue + (targetY - startValue)*0.5f);
6031 // Start the animation
6034 bool signalReceived(false);
6035 AnimationFinishCheck finishCheck(signalReceived);
6036 animation.FinishedSignal().Connect(&application, finishCheck);
6038 application.SendNotification();
6039 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
6041 // We didn't expect the animation to finish yet
6042 application.SendNotification();
6043 finishCheck.CheckSignalNotReceived();
6044 DALI_TEST_EQUALS( actor.GetCurrentScale().y, fiftyPercentProgress, TEST_LOCATION );
6045 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_X), startValue, TEST_LOCATION );
6046 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_Y), fiftyPercentProgress, TEST_LOCATION );
6047 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_Z), startValue, TEST_LOCATION );
6049 application.SendNotification();
6050 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
6052 // We did expect the animation to finish
6053 application.SendNotification();
6054 finishCheck.CheckSignalReceived();
6055 DALI_TEST_EQUALS( actor.GetCurrentScale().y, targetY, TEST_LOCATION );
6056 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_X), startValue, TEST_LOCATION );
6057 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_Y), targetY, TEST_LOCATION );
6058 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_Z), startValue, TEST_LOCATION );
6062 int UtcDaliAnimationAnimateToActorScaleZ(void)
6064 TestApplication application;
6066 Actor actor = Actor::New();
6067 Stage::GetCurrent().Add(actor);
6068 float startValue(1.0f);
6069 DALI_TEST_EQUALS( actor.GetCurrentScale().z, startValue, TEST_LOCATION );
6070 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_X), startValue, TEST_LOCATION );
6071 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_Y), startValue, TEST_LOCATION );
6072 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_Z), startValue, TEST_LOCATION );
6074 // Build the animation
6075 float durationSeconds(1.0f);
6076 Animation animation = Animation::New(durationSeconds);
6077 float targetZ(-1000.0f);
6078 animation.AnimateTo( Property(actor, Actor::SCALE_Z), targetZ );
6080 float fiftyPercentProgress(startValue + (targetZ - startValue)*0.5f);
6082 // Start the animation
6085 bool signalReceived(false);
6086 AnimationFinishCheck finishCheck(signalReceived);
6087 animation.FinishedSignal().Connect(&application, finishCheck);
6089 application.SendNotification();
6090 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
6092 // We didn't expect the animation to finish yet
6093 application.SendNotification();
6094 finishCheck.CheckSignalNotReceived();
6095 DALI_TEST_EQUALS( actor.GetCurrentScale().z, fiftyPercentProgress, TEST_LOCATION );
6096 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_X), startValue, TEST_LOCATION );
6097 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_Y), startValue, TEST_LOCATION );
6098 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_Z), fiftyPercentProgress, TEST_LOCATION );
6100 application.SendNotification();
6101 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
6103 // We did expect the animation to finish
6104 application.SendNotification();
6105 finishCheck.CheckSignalReceived();
6106 DALI_TEST_EQUALS( actor.GetCurrentScale().z, targetZ, TEST_LOCATION );
6107 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_X), startValue, TEST_LOCATION );
6108 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_Y), startValue, TEST_LOCATION );
6109 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_Z), targetZ, TEST_LOCATION );
6113 int UtcDaliAnimationAnimateToActorColor(void)
6115 TestApplication application;
6117 Actor actor = Actor::New();
6118 Stage::GetCurrent().Add(actor);
6119 DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
6121 // Build the animation
6122 float durationSeconds(1.0f);
6123 Animation animation = Animation::New(durationSeconds);
6124 Vector4 targetColor(Color::RED);
6125 animation.AnimateTo( Property(actor, Actor::COLOR), targetColor );
6127 Vector4 tenPercentProgress(Vector4(1.0f, 0.9f, 0.9f, 1.0f));
6128 Vector4 twentyPercentProgress(Vector4(1.0f, 0.8f, 0.8f, 1.0f));
6130 // Start the animation
6133 bool signalReceived(false);
6134 AnimationFinishCheck finishCheck(signalReceived);
6135 animation.FinishedSignal().Connect(&application, finishCheck);
6137 application.SendNotification();
6138 application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% progress */);
6140 // We didn't expect the animation to finish yet
6141 application.SendNotification();
6142 finishCheck.CheckSignalNotReceived();
6143 DALI_TEST_EQUALS( actor.GetCurrentColor(), tenPercentProgress, TEST_LOCATION );
6145 application.SendNotification();
6146 application.Render(static_cast<unsigned int>(durationSeconds*900.0f) + 1u/*just beyond the animation duration*/);
6148 // We did expect the animation to finish
6149 application.SendNotification();
6150 finishCheck.CheckSignalReceived();
6151 DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION );
6154 finishCheck.Reset();
6155 actor.SetColor(Color::WHITE);
6156 application.SendNotification();
6157 application.Render(0);
6158 DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
6160 // Repeat with a different (ease-in) alpha function
6161 animation = Animation::New(durationSeconds);
6162 animation.AnimateTo( Property(actor, Actor::COLOR), targetColor, AlphaFunctions::EaseIn);
6163 animation.FinishedSignal().Connect(&application, finishCheck);
6166 application.SendNotification();
6167 application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% progress */);
6169 // We didn't expect the animation to finish yet
6170 application.SendNotification();
6171 finishCheck.CheckSignalNotReceived();
6173 // The color should have changed less, than with a linear alpha function
6174 Vector4 current(actor.GetCurrentColor());
6175 DALI_TEST_CHECK( current.x == 1.0f ); // doesn't change
6176 DALI_TEST_CHECK( current.y < 1.0f );
6177 DALI_TEST_CHECK( current.y > tenPercentProgress.y );
6178 DALI_TEST_CHECK( current.z < 1.0f );
6179 DALI_TEST_CHECK( current.z > tenPercentProgress.z );
6180 DALI_TEST_CHECK( current.w == 1.0f ); // doesn't change
6182 application.SendNotification();
6183 application.Render(static_cast<unsigned int>(durationSeconds*900.0f) + 1u/*just beyond the animation duration*/);
6185 // We did expect the animation to finish
6186 application.SendNotification();
6187 finishCheck.CheckSignalReceived();
6188 DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION );
6191 finishCheck.Reset();
6192 actor.SetColor(Color::WHITE);
6193 application.SendNotification();
6194 application.Render(0);
6195 DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
6197 // Repeat with a shorter animator duration
6198 float animatorDuration = 0.5f;
6199 animation = Animation::New(durationSeconds);
6200 animation.AnimateTo( Property(actor, Actor::COLOR), targetColor, AlphaFunctions::Linear, TimePeriod(animatorDuration));
6201 animation.FinishedSignal().Connect(&application, finishCheck);
6204 application.SendNotification();
6205 application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% animation progress, 20% animator progress */);
6207 // We didn't expect the animation to finish yet
6208 application.SendNotification();
6209 finishCheck.CheckSignalNotReceived();
6210 DALI_TEST_EQUALS( actor.GetCurrentColor(), twentyPercentProgress, TEST_LOCATION );
6212 application.SendNotification();
6213 application.Render(static_cast<unsigned int>(durationSeconds*400.0f)/* 50% animation progress, 100% animator progress */);
6215 // We didn't expect the animation to finish yet
6216 application.SendNotification();
6217 finishCheck.CheckSignalNotReceived();
6218 DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION );
6220 application.SendNotification();
6221 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
6223 // We did expect the animation to finish
6224 application.SendNotification();
6225 finishCheck.CheckSignalReceived();
6226 DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION );
6230 int UtcDaliAnimationAnimateToActorColorRed(void)
6232 TestApplication application;
6234 Actor actor = Actor::New();
6235 Stage::GetCurrent().Add(actor);
6236 float startValue(1.0f);
6237 DALI_TEST_EQUALS( actor.GetCurrentColor().r, startValue, TEST_LOCATION );
6238 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
6239 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
6240 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
6241 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), startValue, TEST_LOCATION );
6243 // Build the animation
6244 float durationSeconds(1.0f);
6245 Animation animation = Animation::New(durationSeconds);
6246 float targetRed(0.5f);
6247 animation.AnimateTo( Property(actor, Actor::COLOR_RED), targetRed );
6249 float fiftyPercentProgress(startValue + (targetRed - startValue)*0.5f);
6251 // Start the animation
6254 bool signalReceived(false);
6255 AnimationFinishCheck finishCheck(signalReceived);
6256 animation.FinishedSignal().Connect(&application, finishCheck);
6258 application.SendNotification();
6259 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
6261 // We didn't expect the animation to finish yet
6262 application.SendNotification();
6263 finishCheck.CheckSignalNotReceived();
6264 DALI_TEST_EQUALS( actor.GetCurrentColor().r, fiftyPercentProgress, TEST_LOCATION );
6265 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), fiftyPercentProgress, TEST_LOCATION );
6266 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
6267 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
6268 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), startValue, TEST_LOCATION );
6270 application.SendNotification();
6271 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
6273 // We did expect the animation to finish
6274 application.SendNotification();
6275 finishCheck.CheckSignalReceived();
6276 DALI_TEST_EQUALS( actor.GetCurrentColor().r, targetRed, TEST_LOCATION );
6277 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), targetRed, TEST_LOCATION );
6278 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
6279 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
6280 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), startValue, TEST_LOCATION );
6284 int UtcDaliAnimationAnimateToActorColorGreen(void)
6286 TestApplication application;
6288 Actor actor = Actor::New();
6289 Stage::GetCurrent().Add(actor);
6290 float startValue(1.0f);
6291 DALI_TEST_EQUALS( actor.GetCurrentColor().g, startValue, TEST_LOCATION );
6292 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
6293 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
6294 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
6295 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), startValue, TEST_LOCATION );
6297 // Build the animation
6298 float durationSeconds(1.0f);
6299 Animation animation = Animation::New(durationSeconds);
6300 float targetGreen(0.5f);
6301 animation.AnimateTo( Property(actor, Actor::COLOR_GREEN), targetGreen );
6303 float fiftyPercentProgress(startValue + (targetGreen - startValue)*0.5f);
6305 // Start the animation
6308 bool signalReceived(false);
6309 AnimationFinishCheck finishCheck(signalReceived);
6310 animation.FinishedSignal().Connect(&application, finishCheck);
6312 application.SendNotification();
6313 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
6315 // We didn't expect the animation to finish yet
6316 application.SendNotification();
6317 finishCheck.CheckSignalNotReceived();
6318 DALI_TEST_EQUALS( actor.GetCurrentColor().g, fiftyPercentProgress, TEST_LOCATION );
6319 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
6320 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), fiftyPercentProgress, TEST_LOCATION );
6321 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
6322 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), startValue, TEST_LOCATION );
6324 application.SendNotification();
6325 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
6327 // We did expect the animation to finish
6328 application.SendNotification();
6329 finishCheck.CheckSignalReceived();
6330 DALI_TEST_EQUALS( actor.GetCurrentColor().g, targetGreen, TEST_LOCATION );
6331 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
6332 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), targetGreen, TEST_LOCATION );
6333 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
6334 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), startValue, TEST_LOCATION );
6338 int UtcDaliAnimationAnimateToActorColorBlue(void)
6340 TestApplication application;
6342 Actor actor = Actor::New();
6343 Stage::GetCurrent().Add(actor);
6344 float startValue(1.0f);
6345 DALI_TEST_EQUALS( actor.GetCurrentColor().b, startValue, TEST_LOCATION );
6346 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
6347 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
6348 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
6349 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), startValue, TEST_LOCATION );
6351 // Build the animation
6352 float durationSeconds(1.0f);
6353 Animation animation = Animation::New(durationSeconds);
6354 float targetBlue(0.5f);
6355 animation.AnimateTo( Property(actor, Actor::COLOR_BLUE), targetBlue );
6357 float fiftyPercentProgress(startValue + (targetBlue - startValue)*0.5f);
6359 // Start the animation
6362 bool signalReceived(false);
6363 AnimationFinishCheck finishCheck(signalReceived);
6364 animation.FinishedSignal().Connect(&application, finishCheck);
6366 application.SendNotification();
6367 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
6369 // We didn't expect the animation to finish yet
6370 application.SendNotification();
6371 finishCheck.CheckSignalNotReceived();
6372 DALI_TEST_EQUALS( actor.GetCurrentColor().b, fiftyPercentProgress, TEST_LOCATION );
6373 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
6374 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
6375 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), fiftyPercentProgress, TEST_LOCATION );
6376 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), startValue, TEST_LOCATION );
6378 application.SendNotification();
6379 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
6381 // We did expect the animation to finish
6382 application.SendNotification();
6383 finishCheck.CheckSignalReceived();
6384 DALI_TEST_EQUALS( actor.GetCurrentColor().b, targetBlue, TEST_LOCATION );
6385 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
6386 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
6387 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), targetBlue, TEST_LOCATION );
6388 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), startValue, TEST_LOCATION );
6392 int UtcDaliAnimationAnimateToActorColorAlpha(void)
6394 TestApplication application;
6396 Actor actor = Actor::New();
6397 Stage::GetCurrent().Add(actor);
6398 float startValue(1.0f);
6399 DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
6400 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
6401 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
6402 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
6403 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), startValue, TEST_LOCATION );
6405 // Build the animation
6406 float durationSeconds(1.0f);
6407 Animation animation = Animation::New(durationSeconds);
6408 float targetAlpha(0.5f);
6409 animation.AnimateTo( Property(actor, Actor::COLOR_ALPHA), targetAlpha );
6411 float fiftyPercentProgress(startValue + (targetAlpha - startValue)*0.5f);
6413 // Start the animation
6416 bool signalReceived(false);
6417 AnimationFinishCheck finishCheck(signalReceived);
6418 animation.FinishedSignal().Connect(&application, finishCheck);
6420 application.SendNotification();
6421 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
6423 // We didn't expect the animation to finish yet
6424 application.SendNotification();
6425 finishCheck.CheckSignalNotReceived();
6426 DALI_TEST_EQUALS( actor.GetCurrentColor().a, fiftyPercentProgress, TEST_LOCATION );
6427 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
6428 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
6429 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
6430 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), fiftyPercentProgress, TEST_LOCATION );
6432 application.SendNotification();
6433 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
6435 // We did expect the animation to finish
6436 application.SendNotification();
6437 finishCheck.CheckSignalReceived();
6438 DALI_TEST_EQUALS( actor.GetCurrentColor().a, targetAlpha, TEST_LOCATION );
6439 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
6440 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
6441 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
6442 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), targetAlpha, TEST_LOCATION );
6448 int UtcDaliAnimationKeyFrames01(void)
6450 TestApplication application;
6452 KeyFrames keyFrames = KeyFrames::New();
6453 DALI_TEST_EQUALS(keyFrames.GetType(), Property::NONE, TEST_LOCATION);
6455 keyFrames.Add(0.0f, 0.1f);
6456 keyFrames.Add(0.2f, 0.5f);
6457 keyFrames.Add(0.4f, 0.0f);
6458 keyFrames.Add(0.6f, 1.0f);
6459 keyFrames.Add(0.8f, 0.7f);
6460 keyFrames.Add(1.0f, 0.9f);
6462 DALI_TEST_EQUALS(keyFrames.GetType(), Property::FLOAT, TEST_LOCATION);
6466 keyFrames.Add(1.9f, false);
6468 catch (Dali::DaliException& e)
6470 tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
6471 DALI_TEST_ASSERT(e, "mType == value.GetType()", TEST_LOCATION);
6476 int UtcDaliAnimationKeyFrames02(void)
6478 TestApplication application;
6480 KeyFrames keyFrames = KeyFrames::New();
6481 DALI_TEST_EQUALS(keyFrames.GetType(), Property::NONE, TEST_LOCATION);
6483 keyFrames.Add(0.0f, true);
6484 keyFrames.Add(0.2f, false);
6485 keyFrames.Add(0.4f, false);
6486 keyFrames.Add(0.6f, true);
6487 keyFrames.Add(0.8f, true);
6488 keyFrames.Add(1.0f, false);
6490 DALI_TEST_EQUALS(keyFrames.GetType(), Property::BOOLEAN, TEST_LOCATION);
6494 keyFrames.Add(0.7f, Vector3(1.0f, 1.0f, 1.0f));
6496 catch (Dali::DaliException& e)
6498 tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
6499 DALI_TEST_ASSERT(e, "mType == value.GetType()", TEST_LOCATION);
6505 int UtcDaliAnimationKeyFrames03(void)
6507 TestApplication application;
6509 KeyFrames keyFrames = KeyFrames::New();
6510 DALI_TEST_EQUALS(keyFrames.GetType(), Property::NONE, TEST_LOCATION);
6512 keyFrames.Add(0.0f, Vector2(0.0f, 0.0f));
6513 keyFrames.Add(0.2f, Vector2(1.0f, 1.0f));
6514 keyFrames.Add(0.4f, Vector2(2.0f, 2.0f));
6515 keyFrames.Add(0.6f, Vector2(3.0f, 5.0f));
6516 keyFrames.Add(0.8f, Vector2(4.0f, 3.0f));
6517 keyFrames.Add(1.0f, Vector2(6.0f, 2.0f));
6519 DALI_TEST_EQUALS(keyFrames.GetType(), Property::VECTOR2, TEST_LOCATION);
6523 keyFrames.Add(0.7f, Vector3(1.0f, 1.0f, 1.0f));
6525 catch (Dali::DaliException& e)
6527 tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
6528 DALI_TEST_ASSERT(e, "mType == value.GetType()", TEST_LOCATION);
6534 int UtcDaliAnimationKeyFrames04(void)
6536 TestApplication application;
6538 KeyFrames keyFrames = KeyFrames::New();
6539 DALI_TEST_EQUALS(keyFrames.GetType(), Property::NONE, TEST_LOCATION);
6541 keyFrames.Add(0.0f, Vector3(0.0f, 4.0f, 0.0f));
6542 keyFrames.Add(0.2f, Vector3(1.0f, 3.0f, 1.0f));
6543 keyFrames.Add(0.4f, Vector3(2.0f, 2.0f, 2.0f));
6544 keyFrames.Add(0.6f, Vector3(3.0f, 2.0f, 5.0f));
6545 keyFrames.Add(0.8f, Vector3(4.0f, 4.0f, 3.0f));
6546 keyFrames.Add(1.0f, Vector3(6.0f, 8.0f, 2.0f));
6548 DALI_TEST_EQUALS(keyFrames.GetType(), Property::VECTOR3, TEST_LOCATION);
6552 keyFrames.Add(0.7f, 1.0f);
6554 catch (Dali::DaliException& e)
6556 tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
6557 DALI_TEST_ASSERT(e, "mType == value.GetType()", TEST_LOCATION);
6562 int UtcDaliAnimationKeyFrames05(void)
6564 TestApplication application;
6566 KeyFrames keyFrames = KeyFrames::New();
6567 DALI_TEST_EQUALS(keyFrames.GetType(), Property::NONE, TEST_LOCATION);
6569 keyFrames.Add(0.0f, Vector4(0.0f, 0.0f, 0.0f, 0.0f));
6570 keyFrames.Add(0.2f, Vector4(1.0f, 1.0f, 1.0f, 1.0f));
6571 keyFrames.Add(0.4f, Vector4(2.0f, 2.0f, 2.0f, 2.0f));
6572 keyFrames.Add(0.6f, Vector4(3.0f, 5.0f, 3.0f, 5.0f));
6573 keyFrames.Add(0.8f, Vector4(4.0f, 3.0f, 4.0f, 3.0f));
6574 keyFrames.Add(1.0f, Vector4(6.0f, 2.0f, 6.0f, 2.0f));
6576 DALI_TEST_EQUALS(keyFrames.GetType(), Property::VECTOR4, TEST_LOCATION);
6580 keyFrames.Add(0.7f, Quaternion(1.717f, Vector3::XAXIS));
6582 catch (Dali::DaliException& e)
6584 tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
6585 DALI_TEST_ASSERT(e, "mType == value.GetType()", TEST_LOCATION);
6591 int UtcDaliAnimationKeyFrames06(void)
6593 TestApplication application;
6595 KeyFrames keyFrames = KeyFrames::New();
6596 DALI_TEST_EQUALS(keyFrames.GetType(), Property::NONE, TEST_LOCATION);
6598 keyFrames.Add(0.0f, Quaternion(1.717f, Vector3::XAXIS));
6599 keyFrames.Add(0.2f, Quaternion(2.0f, Vector3::XAXIS));
6600 keyFrames.Add(0.4f, Quaternion(3.0f, Vector3::ZAXIS));
6601 keyFrames.Add(0.6f, Quaternion(4.0f, Vector3(1.0f, 1.0f, 1.0f)));
6602 keyFrames.Add(0.8f, AngleAxis(Degree(90), Vector3::XAXIS));
6603 keyFrames.Add(1.0f, Quaternion(3.0f, Vector3::YAXIS));
6605 DALI_TEST_EQUALS(keyFrames.GetType(), Property::ROTATION, TEST_LOCATION);
6609 keyFrames.Add(0.7f, 1.1f);
6611 catch (Dali::DaliException& e)
6613 tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
6614 DALI_TEST_ASSERT(e, "mType == value.GetType()", TEST_LOCATION);
6623 int UtcDaliAnimationAnimateBetweenActorColorAlpha(void)
6625 TestApplication application;
6627 float startValue(1.0f);
6628 Actor actor = Actor::New();
6629 actor.SetColor(Vector4(startValue, startValue, startValue, startValue));
6630 Stage::GetCurrent().Add(actor);
6632 DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
6633 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
6634 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
6635 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
6636 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), startValue, TEST_LOCATION );
6638 // Build the animation
6639 float durationSeconds(1.0f);
6640 Animation animation = Animation::New(durationSeconds);
6642 KeyFrames keyFrames = KeyFrames::New();
6643 keyFrames.Add(0.0f, 0.1f);
6644 keyFrames.Add(0.2f, 0.5f);
6645 keyFrames.Add(0.4f, 0.0f);
6646 keyFrames.Add(0.6f, 1.0f);
6647 keyFrames.Add(0.8f, 0.7f);
6648 keyFrames.Add(1.0f, 0.9f);
6650 animation.AnimateBetween( Property(actor, Actor::COLOR_ALPHA), keyFrames );
6652 // Start the animation
6655 bool signalReceived(false);
6656 AnimationFinishCheck finishCheck(signalReceived);
6657 animation.FinishedSignal().Connect(&application, finishCheck);
6658 application.SendNotification();
6659 application.Render(0);
6660 application.SendNotification();
6661 finishCheck.CheckSignalNotReceived();
6662 DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.1f, TEST_LOCATION );
6664 application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% progress */);
6665 application.SendNotification();
6666 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
6667 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
6668 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
6669 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.3f, 0.01f, TEST_LOCATION );
6670 DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.3f, 0.01f, TEST_LOCATION );
6672 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 30% progress */);
6673 application.SendNotification();
6674 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
6675 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
6676 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
6677 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.25f, 0.01f, TEST_LOCATION );
6678 DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.25f, 0.01f, TEST_LOCATION );
6680 application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 40% progress */);
6681 application.SendNotification();
6682 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
6683 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
6684 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
6685 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.0f, 0.01f, TEST_LOCATION );
6686 DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.0f, 0.01f, TEST_LOCATION );
6688 application.Render(static_cast<unsigned int>(durationSeconds*400.0f)/* 80% progress */);
6689 application.SendNotification();
6690 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
6691 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
6692 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
6693 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.7f, 0.01f, TEST_LOCATION );
6694 DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.7f, 0.01f, TEST_LOCATION );
6696 application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 90% progress */);
6697 application.SendNotification();
6698 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
6699 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
6700 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
6701 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.8f, 0.01f, TEST_LOCATION );
6702 DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.8f, 0.01f, TEST_LOCATION );
6704 application.Render(static_cast<unsigned int>(durationSeconds*100.0f)+1/* 100% progress */);
6705 application.SendNotification();
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), 0.9f, 0.01f, TEST_LOCATION );
6710 DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.9f, 0.01f, TEST_LOCATION );
6712 // We did expect the animation to finish
6714 finishCheck.CheckSignalReceived();
6719 int UtcDaliAnimationAnimateBetweenActorColor(void)
6721 TestApplication application;
6723 float startValue(1.0f);
6724 Actor actor = Actor::New();
6725 actor.SetColor(Vector4(startValue, startValue, startValue, startValue));
6726 Stage::GetCurrent().Add(actor);
6728 DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
6729 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
6730 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
6731 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
6732 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), startValue, TEST_LOCATION );
6734 // Build the animation
6735 float durationSeconds(1.0f);
6736 Animation animation = Animation::New(durationSeconds);
6738 KeyFrames keyFrames = KeyFrames::New();
6739 keyFrames.Add(0.0f, Vector4(0.1f, 0.2f, 0.3f, 0.4f));
6740 keyFrames.Add(0.5f, Vector4(0.9f, 0.8f, 0.7f, 0.6f));
6741 keyFrames.Add(1.0f, Vector4(1.0f, 1.0f, 1.0f, 1.0f));
6743 animation.AnimateBetween( Property(actor, Actor::COLOR), keyFrames );
6745 // Start the animation
6748 bool signalReceived(false);
6749 AnimationFinishCheck finishCheck(signalReceived);
6750 animation.FinishedSignal().Connect(&application, finishCheck);
6751 application.SendNotification();
6752 application.Render(0);
6753 application.SendNotification();
6754 finishCheck.CheckSignalNotReceived();
6755 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), 0.1f, 0.01f, TEST_LOCATION );
6756 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 0.2f, 0.01f, TEST_LOCATION );
6757 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), 0.3f, 0.01f, TEST_LOCATION );
6758 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.4f, 0.01f, TEST_LOCATION );
6760 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
6761 application.SendNotification();
6762 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), 0.5f, 0.01f, TEST_LOCATION );
6763 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 0.5f, 0.01f, TEST_LOCATION );
6764 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), 0.5f, 0.01f, TEST_LOCATION );
6765 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.5f, 0.01f, TEST_LOCATION );
6767 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
6768 application.SendNotification();
6769 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), 0.9f, 0.01f, TEST_LOCATION );
6770 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 0.8f, 0.01f, TEST_LOCATION );
6771 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), 0.7f, 0.01f, TEST_LOCATION );
6772 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.6f, 0.01f, TEST_LOCATION );
6774 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
6775 application.SendNotification();
6776 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), 0.95f, 0.01f, TEST_LOCATION );
6777 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 0.90f, 0.01f, TEST_LOCATION );
6778 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), 0.85f, 0.01f, TEST_LOCATION );
6779 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.80f, 0.01f, TEST_LOCATION );
6781 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
6782 application.SendNotification();
6783 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), 1.0f, 0.01f, TEST_LOCATION );
6784 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 1.0f, 0.01f, TEST_LOCATION );
6785 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), 1.0f, 0.01f, TEST_LOCATION );
6786 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 1.0f, 0.01f, TEST_LOCATION );
6788 // We did expect the animation to finish
6790 finishCheck.CheckSignalReceived();
6794 int UtcDaliAnimationAnimateBetweenActorVisible01(void)
6796 TestApplication application;
6798 Actor actor = Actor::New();
6799 AngleAxis aa(Degree(90), Vector3::XAXIS);
6800 actor.SetRotation(aa.angle, aa.axis);
6801 Stage::GetCurrent().Add(actor);
6803 application.SendNotification();
6804 application.Render(0);
6806 DALI_TEST_EQUALS( actor.IsVisible(), true, TEST_LOCATION );
6808 // Build the animation
6809 float durationSeconds(1.0f);
6810 Animation animation = Animation::New(durationSeconds);
6812 KeyFrames keyFrames = KeyFrames::New();
6813 keyFrames.Add(0.0f, false);
6814 keyFrames.Add(0.2f, true);
6815 keyFrames.Add(0.4f, true);
6816 keyFrames.Add(0.8f, false);
6817 keyFrames.Add(1.0f, true);
6819 animation.AnimateBetween( Property(actor, Actor::VISIBLE), keyFrames );
6821 // Start the animation
6824 bool signalReceived(false);
6825 AnimationFinishCheck finishCheck(signalReceived);
6826 animation.FinishedSignal().Connect(&application, finishCheck);
6827 application.SendNotification();
6828 application.SendNotification();
6829 application.Render(static_cast<unsigned int>(durationSeconds*500.0f));
6830 application.SendNotification();
6831 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)+1);
6832 application.SendNotification();
6834 DALI_TEST_EQUALS( actor.IsVisible(), true, TEST_LOCATION);
6835 finishCheck.CheckSignalReceived();
6839 int UtcDaliAnimationAnimateBetweenActorRotation01(void)
6841 TestApplication application;
6843 Actor actor = Actor::New();
6844 AngleAxis aa(Degree(90), Vector3::XAXIS);
6845 actor.SetRotation(aa.angle, aa.axis);
6846 Stage::GetCurrent().Add(actor);
6848 application.SendNotification();
6849 application.Render(0);
6850 Quaternion start(Radian(aa.angle), aa.axis);
6851 DALI_TEST_EQUALS( actor.GetCurrentRotation(), start, 0.001f, TEST_LOCATION );
6853 // Build the animation
6854 float durationSeconds(1.0f);
6855 Animation animation = Animation::New(durationSeconds);
6857 KeyFrames keyFrames = KeyFrames::New();
6858 keyFrames.Add(0.0f, AngleAxis(Degree(60), Vector3::ZAXIS));
6860 animation.AnimateBetween( Property(actor, Actor::ROTATION), keyFrames );
6862 // Start the animation
6865 bool signalReceived(false);
6866 AnimationFinishCheck finishCheck(signalReceived);
6867 animation.FinishedSignal().Connect(&application, finishCheck);
6868 application.SendNotification();
6869 application.SendNotification();
6870 application.Render(static_cast<unsigned int>(durationSeconds*500.0f));
6871 application.SendNotification();
6872 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)+1);
6873 application.SendNotification();
6875 Quaternion check = Quaternion::FromAxisAngle(Vector4::ZAXIS, Radian(Degree(60)));
6877 DALI_TEST_EQUALS( actor.GetCurrentRotation(), check, 0.001f, TEST_LOCATION );
6878 finishCheck.CheckSignalReceived();
6882 int UtcDaliAnimationAnimateBetweenActorRotation02(void)
6884 TestApplication application;
6886 Actor actor = Actor::New();
6887 AngleAxis aa(Degree(90), Vector3::XAXIS);
6888 actor.SetRotation(aa.angle, aa.axis);
6889 application.SendNotification();
6890 application.Render(0);
6891 Stage::GetCurrent().Add(actor);
6893 Quaternion start(Radian(aa.angle), aa.axis);
6894 DALI_TEST_EQUALS( actor.GetCurrentRotation(), start, 0.001f, TEST_LOCATION );
6896 // Build the animation
6897 float durationSeconds(1.0f);
6898 Animation animation = Animation::New(durationSeconds);
6900 KeyFrames keyFrames = KeyFrames::New();
6901 keyFrames.Add(0.0f, AngleAxis(Degree(60), Vector3::XAXIS));
6902 keyFrames.Add(0.5f, AngleAxis(Degree(120), Vector3::XAXIS));
6903 keyFrames.Add(1.0f, AngleAxis(Degree(120), Vector3::YAXIS));
6905 animation.AnimateBetween( Property(actor, Actor::ROTATION), keyFrames );
6907 // Start the animation
6910 bool signalReceived(false);
6911 AnimationFinishCheck finishCheck(signalReceived);
6912 animation.FinishedSignal().Connect(&application, finishCheck);
6913 application.SendNotification();
6914 application.Render(0);
6915 application.SendNotification();
6916 finishCheck.CheckSignalNotReceived();
6918 Quaternion check(Radian(Degree(60)), Vector3::XAXIS);
6919 DALI_TEST_EQUALS( actor.GetCurrentRotation(), check, 0.001f, TEST_LOCATION );
6921 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
6922 application.SendNotification();
6923 check = Quaternion::FromAxisAngle(Vector4::XAXIS, Radian(Degree(90)));
6924 DALI_TEST_EQUALS( actor.GetCurrentRotation(), check, 0.001f, TEST_LOCATION );
6926 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
6927 application.SendNotification();
6928 check = Quaternion::FromAxisAngle(Vector4::XAXIS, Radian(Degree(120)));
6929 DALI_TEST_EQUALS( actor.GetCurrentRotation(), check, 0.001f, TEST_LOCATION );
6931 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
6932 application.SendNotification();
6933 check = Quaternion::FromAxisAngle(Vector4(0.5f, 0.5f, 0.0f, 0.0f), Radian(Degree(101.5)));
6934 DALI_TEST_EQUALS( actor.GetCurrentRotation(), check, 0.001f, TEST_LOCATION );
6936 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
6937 application.SendNotification();
6938 check = Quaternion::FromAxisAngle(Vector4::YAXIS, Radian(Degree(120)));
6939 DALI_TEST_EQUALS( actor.GetCurrentRotation(), check, 0.001f, TEST_LOCATION );
6941 // We did expect the animation to finish
6943 finishCheck.CheckSignalReceived();
6947 int UtcDaliAnimationMoveByFloat3(void)
6949 TestApplication application;
6951 Actor actor = Actor::New();
6952 Vector3 startPosition(10.0f, 10.0f, 10.0f);
6953 actor.SetPosition(startPosition);
6954 Stage::GetCurrent().Add(actor);
6955 application.SendNotification();
6956 application.Render(0);
6957 DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION );
6959 // Build the animation
6960 float durationSeconds(1.0f);
6961 Animation animation = Animation::New(durationSeconds);
6962 Vector3 targetPosition(20.0f, 20.0f, 20.0f);
6963 Vector3 relativePosition(targetPosition - startPosition);
6964 animation.MoveBy(actor, relativePosition.x, relativePosition.y, relativePosition.z);
6966 Vector3 ninetyFivePercentProgress(startPosition + relativePosition*0.95f);
6968 // Start the animation
6971 bool signalReceived(false);
6972 AnimationFinishCheck finishCheck(signalReceived);
6973 animation.FinishedSignal().Connect(&application, finishCheck);
6975 application.SendNotification();
6976 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
6978 // We didn't expect the animation to finish yet
6979 application.SendNotification();
6980 finishCheck.CheckSignalNotReceived();
6981 DALI_TEST_EQUALS( actor.GetCurrentPosition(), ninetyFivePercentProgress, TEST_LOCATION );
6983 application.SendNotification();
6984 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
6986 // We did expect the animation to finish
6987 application.SendNotification();
6988 finishCheck.CheckSignalReceived();
6989 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
6993 int UtcDaliAnimationMoveByVector3Alpha(void)
6995 TestApplication application;
6997 Actor actor = Actor::New();
6998 Vector3 startPosition(10.0f, 10.0f, 10.0f);
6999 actor.SetPosition(startPosition);
7000 Stage::GetCurrent().Add(actor);
7001 application.SendNotification();
7002 application.Render(0);
7003 DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION );
7005 // Build the animation
7006 float durationSeconds(1.0f);
7007 Animation animation = Animation::New(durationSeconds);
7008 Vector3 targetPosition(20.0f, 20.0f, 20.0f);
7009 Vector3 relativePosition(targetPosition - startPosition);
7010 animation.MoveBy(actor, relativePosition, AlphaFunctions::EaseOut);
7012 Vector3 ninetyFivePercentProgress(startPosition + relativePosition*0.95f);
7014 // Start the animation
7017 bool signalReceived(false);
7018 AnimationFinishCheck finishCheck(signalReceived);
7019 animation.FinishedSignal().Connect(&application, finishCheck);
7021 application.SendNotification();
7022 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
7024 // We didn't expect the animation to finish yet
7025 application.SendNotification();
7026 finishCheck.CheckSignalNotReceived();
7028 // The position should have moved more, than with a linear alpha function
7029 Vector3 current(actor.GetCurrentPosition());
7030 DALI_TEST_CHECK( current.x > ninetyFivePercentProgress.x );
7031 DALI_TEST_CHECK( current.y > ninetyFivePercentProgress.y );
7032 DALI_TEST_CHECK( current.z > ninetyFivePercentProgress.z );
7034 application.SendNotification();
7035 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
7037 // We did expect the animation to finish
7038 application.SendNotification();
7039 finishCheck.CheckSignalReceived();
7040 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
7044 int UtcDaliAnimationMoveByVector3AlphaFloat2(void)
7046 TestApplication application;
7048 Actor actor = Actor::New();
7049 Vector3 startPosition(10.0f, 10.0f, 10.0f);
7050 actor.SetPosition(startPosition);
7051 Stage::GetCurrent().Add(actor);
7052 application.SendNotification();
7053 application.Render(0);
7054 DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION );
7056 // Build the animation
7057 float durationSeconds(1.0f);
7058 Animation animation = Animation::New(durationSeconds);
7059 Vector3 targetPosition(20.0f, 20.0f, 20.0f);
7060 Vector3 relativePosition(targetPosition - startPosition);
7062 animation.MoveBy(actor, relativePosition, AlphaFunctions::Linear, delay, durationSeconds - delay);
7064 Vector3 ninetyFivePercentProgress(startPosition + relativePosition*0.95f);
7066 // Start the animation
7069 bool signalReceived(false);
7070 AnimationFinishCheck finishCheck(signalReceived);
7071 animation.FinishedSignal().Connect(&application, finishCheck);
7073 application.SendNotification();
7074 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
7076 // We didn't expect the animation to finish yet
7077 application.SendNotification();
7078 finishCheck.CheckSignalNotReceived();
7079 DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION );
7081 application.SendNotification();
7082 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
7084 // We did expect the animation to finish
7085 application.SendNotification();
7086 finishCheck.CheckSignalReceived();
7087 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
7091 int UtcDaliAnimationMoveToFloat3(void)
7093 TestApplication application;
7095 Actor actor = Actor::New();
7096 Stage::GetCurrent().Add(actor);
7097 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
7099 // Build the animation
7100 float durationSeconds(1.0f);
7101 Animation animation = Animation::New(durationSeconds);
7102 Vector3 targetPosition(200.0f, 200.0f, 200.0f);
7103 animation.MoveTo(actor, targetPosition.x, targetPosition.y, targetPosition.z);
7105 Vector3 seventyFivePercentProgress(targetPosition * 0.75f);
7107 // Start the animation
7110 bool signalReceived(false);
7111 AnimationFinishCheck finishCheck(signalReceived);
7112 animation.FinishedSignal().Connect(&application, finishCheck);
7114 application.SendNotification();
7115 application.Render(static_cast<unsigned int>(durationSeconds*750.0f)/* 75% progress */);
7117 // We didn't expect the animation to finish yet
7118 application.SendNotification();
7119 finishCheck.CheckSignalNotReceived();
7120 DALI_TEST_EQUALS( actor.GetCurrentPosition(), seventyFivePercentProgress, TEST_LOCATION );
7122 application.SendNotification();
7123 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7125 // We did expect the animation to finish
7126 application.SendNotification();
7127 finishCheck.CheckSignalReceived();
7128 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
7132 int UtcDaliAnimationMoveToVector3Alpha(void)
7134 TestApplication application;
7136 Actor actor = Actor::New();
7137 Stage::GetCurrent().Add(actor);
7138 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
7140 // Build the animation
7141 float durationSeconds(1.0f);
7142 Animation animation = Animation::New(durationSeconds);
7143 Vector3 targetPosition(200.0f, 200.0f, 200.0f);
7144 animation.MoveTo(actor, targetPosition, AlphaFunctions::EaseIn);
7146 Vector3 seventyFivePercentProgress(targetPosition * 0.75f);
7148 // Start the animation
7151 bool signalReceived(false);
7152 AnimationFinishCheck finishCheck(signalReceived);
7153 animation.FinishedSignal().Connect(&application, finishCheck);
7155 application.SendNotification();
7156 application.Render(static_cast<unsigned int>(durationSeconds*750.0f)/* 75% progress */);
7158 // We didn't expect the animation to finish yet
7159 application.SendNotification();
7160 finishCheck.CheckSignalNotReceived();
7162 // The position should have moved less, than with a linear alpha function
7163 Vector3 current(actor.GetCurrentPosition());
7164 DALI_TEST_CHECK( current.x > Vector3::ZERO.x );
7165 DALI_TEST_CHECK( current.y > Vector3::ZERO.y );
7166 DALI_TEST_CHECK( current.z > Vector3::ZERO.z );
7167 DALI_TEST_CHECK( current.x < seventyFivePercentProgress.x );
7168 DALI_TEST_CHECK( current.y < seventyFivePercentProgress.y );
7169 DALI_TEST_CHECK( current.z < seventyFivePercentProgress.z );
7171 application.SendNotification();
7172 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7174 // We did expect the animation to finish
7175 application.SendNotification();
7176 finishCheck.CheckSignalReceived();
7177 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
7181 int UtcDaliAnimationMoveToVector3AlphaFloat2(void)
7183 TestApplication application;
7185 Actor actor = Actor::New();
7186 Stage::GetCurrent().Add(actor);
7187 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
7189 // Build the animation
7190 float durationSeconds(1.0f);
7191 Animation animation = Animation::New(durationSeconds);
7192 Vector3 targetPosition(200.0f, 200.0f, 200.0f);
7194 animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear, delay, durationSeconds - delay);
7196 Vector3 seventyFivePercentProgress(targetPosition * 0.75f);
7198 // Start the animation
7201 bool signalReceived(false);
7202 AnimationFinishCheck finishCheck(signalReceived);
7203 animation.FinishedSignal().Connect(&application, finishCheck);
7205 application.SendNotification();
7206 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
7208 // We didn't expect the animation to finish yet
7209 application.SendNotification();
7210 finishCheck.CheckSignalNotReceived();
7211 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
7213 application.SendNotification();
7214 application.Render(static_cast<unsigned int>(durationSeconds*500.0f*0.75)/* 7/8 animation progress, 3/4 animator progress */);
7216 // We didn't expect the animation to finish yet
7217 application.SendNotification();
7218 finishCheck.CheckSignalNotReceived();
7219 DALI_TEST_EQUALS( actor.GetCurrentPosition(), seventyFivePercentProgress, TEST_LOCATION );
7221 application.SendNotification();
7222 application.Render(static_cast<unsigned int>(durationSeconds*500.0f*0.25) + 1u/*just beyond the animation duration*/);
7224 // We did expect the animation to finish
7225 application.SendNotification();
7226 finishCheck.CheckSignalReceived();
7227 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
7231 int UtcDaliAnimationMove(void)
7233 TestApplication application;
7235 Actor actor = Actor::New();
7236 Vector3 initialPosition(Vector3::ZERO);
7237 DALI_TEST_EQUALS( actor.GetCurrentPosition(), initialPosition, TEST_LOCATION );
7238 Stage::GetCurrent().Add(actor);
7240 // Build the animation
7241 float durationSeconds(10.0f);
7242 Animation animation = Animation::New(durationSeconds);
7243 Vector3 targetPosition(200.0f, 200.0f, 200.0f);
7244 BounceFunc func(0.0f, 0.0f, -100.0f);
7245 animation.Move(actor, func, AlphaFunctions::Linear, 0.0f, durationSeconds);
7247 // Start the animation
7250 bool signalReceived(false);
7251 AnimationFinishCheck finishCheck(signalReceived);
7252 animation.FinishedSignal().Connect(&application, finishCheck);
7254 application.SendNotification();
7255 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7257 // We didn't expect the animation to finish yet
7258 application.SendNotification();
7259 finishCheck.CheckSignalNotReceived();
7260 DALI_TEST_EQUALS( actor.GetCurrentPosition(), func(0.25f, initialPosition), TEST_LOCATION );
7262 application.SendNotification();
7263 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7265 // We didn't expect the animation to finish yet
7266 application.SendNotification();
7267 finishCheck.CheckSignalNotReceived();
7268 DALI_TEST_EQUALS( actor.GetCurrentPosition(), func(0.5f, initialPosition), TEST_LOCATION );
7270 application.SendNotification();
7271 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7273 // We didn't expect the animation to finish yet
7274 application.SendNotification();
7275 finishCheck.CheckSignalNotReceived();
7276 DALI_TEST_EQUALS( actor.GetCurrentPosition(), func(0.75f, initialPosition), TEST_LOCATION );
7278 application.SendNotification();
7279 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7281 // We did expect the animation to finish
7282 application.SendNotification();
7283 finishCheck.CheckSignalReceived();
7284 DALI_TEST_EQUALS( actor.GetCurrentPosition(), initialPosition, TEST_LOCATION );
7288 int UtcDaliAnimationRotateByDegreeVector3(void)
7290 TestApplication application;
7292 Actor actor = Actor::New();
7293 actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
7294 Stage::GetCurrent().Add(actor);
7295 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7297 // Build the animation
7298 float durationSeconds(1.0f);
7299 Animation animation = Animation::New(durationSeconds);
7300 Degree relativeRotationDegrees(360.0f);
7301 Radian relativeRotationRadians(relativeRotationDegrees);
7302 animation.RotateBy(actor, relativeRotationDegrees/*Degree version*/, Vector3::YAXIS);
7304 // Start the animation
7307 bool signalReceived(false);
7308 AnimationFinishCheck finishCheck(signalReceived);
7309 animation.FinishedSignal().Connect(&application, finishCheck);
7311 application.SendNotification();
7312 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7314 // We didn't expect the animation to finish yet
7315 application.SendNotification();
7316 finishCheck.CheckSignalNotReceived();
7317 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * 0.25f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7319 application.SendNotification();
7320 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7322 // We didn't expect the animation to finish yet
7323 application.SendNotification();
7324 finishCheck.CheckSignalNotReceived();
7325 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * 0.5f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7327 application.SendNotification();
7328 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7330 // We didn't expect the animation to finish yet
7331 application.SendNotification();
7332 finishCheck.CheckSignalNotReceived();
7333 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * 0.75f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7335 application.SendNotification();
7336 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7338 // We did expect the animation to finish
7339 application.SendNotification();
7340 finishCheck.CheckSignalReceived();
7341 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7345 int UtcDaliAnimationRotateByRadianVector3(void)
7347 TestApplication application;
7349 Actor actor = Actor::New();
7350 actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
7351 Stage::GetCurrent().Add(actor);
7352 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7354 // Build the animation
7355 float durationSeconds(1.0f);
7356 Animation animation = Animation::New(durationSeconds);
7357 Degree relativeRotationDegrees(360.0f);
7358 Radian relativeRotationRadians(relativeRotationDegrees);
7359 animation.RotateBy(actor, relativeRotationRadians/*Radian version*/, Vector3::YAXIS);
7361 // Start the animation
7364 bool signalReceived(false);
7365 AnimationFinishCheck finishCheck(signalReceived);
7366 animation.FinishedSignal().Connect(&application, finishCheck);
7368 application.SendNotification();
7369 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7371 // We didn't expect the animation to finish yet
7372 application.SendNotification();
7373 finishCheck.CheckSignalNotReceived();
7374 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * 0.25f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7376 application.SendNotification();
7377 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7379 // We didn't expect the animation to finish yet
7380 application.SendNotification();
7381 finishCheck.CheckSignalNotReceived();
7382 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * 0.5f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7384 application.SendNotification();
7385 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7387 // We didn't expect the animation to finish yet
7388 application.SendNotification();
7389 finishCheck.CheckSignalNotReceived();
7390 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * 0.75f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7392 application.SendNotification();
7393 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7395 // We did expect the animation to finish
7396 application.SendNotification();
7397 finishCheck.CheckSignalReceived();
7398 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7402 int UtcDaliAnimationRotateByDegreeVector3Alpha(void)
7404 TestApplication application;
7406 Actor actor = Actor::New();
7407 actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
7408 Stage::GetCurrent().Add(actor);
7409 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7411 // Build the animation
7412 float durationSeconds(1.0f);
7413 Animation animation = Animation::New(durationSeconds);
7414 Degree relativeRotationDegrees(360.0f);
7415 Radian relativeRotationRadians(relativeRotationDegrees);
7416 animation.RotateBy(actor, relativeRotationDegrees/*Degree version*/, Vector3::YAXIS, AlphaFunctions::EaseIn);
7418 // Start the animation
7421 bool signalReceived(false);
7422 AnimationFinishCheck finishCheck(signalReceived);
7423 animation.FinishedSignal().Connect(&application, finishCheck);
7425 application.SendNotification();
7426 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7428 // We didn't expect the animation to finish yet
7429 application.SendNotification();
7430 finishCheck.CheckSignalNotReceived();
7431 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * AlphaFunctions::EaseIn(0.25f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7433 application.SendNotification();
7434 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7436 // We didn't expect the animation to finish yet
7437 application.SendNotification();
7438 finishCheck.CheckSignalNotReceived();
7439 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * AlphaFunctions::EaseIn(0.5f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7441 application.SendNotification();
7442 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7444 // We didn't expect the animation to finish yet
7445 application.SendNotification();
7446 finishCheck.CheckSignalNotReceived();
7447 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * AlphaFunctions::EaseIn(0.75f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7449 application.SendNotification();
7450 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7452 // We did expect the animation to finish
7453 application.SendNotification();
7454 finishCheck.CheckSignalReceived();
7455 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7459 int UtcDaliAnimationRotateByRadianVector3Alpha(void)
7461 TestApplication application;
7463 Actor actor = Actor::New();
7464 actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
7465 Stage::GetCurrent().Add(actor);
7466 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7468 // Build the animation
7469 float durationSeconds(1.0f);
7470 Animation animation = Animation::New(durationSeconds);
7471 Degree relativeRotationDegrees(360.0f);
7472 Radian relativeRotationRadians(relativeRotationDegrees);
7473 animation.RotateBy(actor, relativeRotationRadians/*Radian version*/, Vector3::YAXIS, AlphaFunctions::EaseIn);
7475 // Start the animation
7478 bool signalReceived(false);
7479 AnimationFinishCheck finishCheck(signalReceived);
7480 animation.FinishedSignal().Connect(&application, finishCheck);
7482 application.SendNotification();
7483 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7485 // We didn't expect the animation to finish yet
7486 application.SendNotification();
7487 finishCheck.CheckSignalNotReceived();
7488 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * AlphaFunctions::EaseIn(0.25f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7490 application.SendNotification();
7491 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7493 // We didn't expect the animation to finish yet
7494 application.SendNotification();
7495 finishCheck.CheckSignalNotReceived();
7496 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * AlphaFunctions::EaseIn(0.5f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7498 application.SendNotification();
7499 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7501 // We didn't expect the animation to finish yet
7502 application.SendNotification();
7503 finishCheck.CheckSignalNotReceived();
7504 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * AlphaFunctions::EaseIn(0.75f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7506 application.SendNotification();
7507 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7509 // We did expect the animation to finish
7510 application.SendNotification();
7511 finishCheck.CheckSignalReceived();
7512 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7516 int UtcDaliAnimationRotateByDegreeVector3AlphaFloat2(void)
7518 TestApplication application;
7520 Actor actor = Actor::New();
7521 actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
7522 Stage::GetCurrent().Add(actor);
7523 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7525 // Build the animation
7526 float durationSeconds(1.0f);
7527 Animation animation = Animation::New(durationSeconds);
7528 Degree relativeRotationDegrees(360.0f);
7529 Radian relativeRotationRadians(relativeRotationDegrees);
7531 animation.RotateBy(actor, relativeRotationDegrees/*Degree version*/, Vector3::YAXIS, AlphaFunctions::EaseIn, delay, durationSeconds - delay);
7533 // Start the animation
7536 bool signalReceived(false);
7537 AnimationFinishCheck finishCheck(signalReceived);
7538 animation.FinishedSignal().Connect(&application, finishCheck);
7540 application.SendNotification();
7541 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7543 // We didn't expect the animation to finish yet
7544 application.SendNotification();
7545 finishCheck.CheckSignalNotReceived();
7546 float progress = max(0.0f, 0.25f - delay) / (1.0f - delay);
7547 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7549 application.SendNotification();
7550 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7552 // We didn't expect the animation to finish yet
7553 application.SendNotification();
7554 finishCheck.CheckSignalNotReceived();
7555 progress = max(0.0f, 0.5f - delay) / (1.0f - delay);
7556 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7558 application.SendNotification();
7559 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7561 // We didn't expect the animation to finish yet
7562 application.SendNotification();
7563 finishCheck.CheckSignalNotReceived();
7564 progress = max(0.0f, 0.75f - delay) / (1.0f - delay);
7565 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7567 application.SendNotification();
7568 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7570 // We did expect the animation to finish
7571 application.SendNotification();
7572 finishCheck.CheckSignalReceived();
7573 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7578 int UtcDaliAnimationRotateByRadianVector3AlphaFloat2(void)
7580 TestApplication application;
7582 Actor actor = Actor::New();
7583 actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
7584 Stage::GetCurrent().Add(actor);
7585 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7587 // Build the animation
7588 float durationSeconds(1.0f);
7589 Animation animation = Animation::New(durationSeconds);
7590 Degree relativeRotationDegrees(360.0f);
7591 Radian relativeRotationRadians(relativeRotationDegrees);
7593 animation.RotateBy(actor, relativeRotationRadians/*Radian version*/, Vector3::YAXIS, AlphaFunctions::EaseIn, delay, durationSeconds - delay);
7595 // Start the animation
7598 bool signalReceived(false);
7599 AnimationFinishCheck finishCheck(signalReceived);
7600 animation.FinishedSignal().Connect(&application, finishCheck);
7602 application.SendNotification();
7603 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7605 // We didn't expect the animation to finish yet
7606 application.SendNotification();
7607 finishCheck.CheckSignalNotReceived();
7608 float progress = max(0.0f, 0.25f - delay) / (1.0f - delay);
7609 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7611 application.SendNotification();
7612 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7614 // We didn't expect the animation to finish yet
7615 application.SendNotification();
7616 finishCheck.CheckSignalNotReceived();
7617 progress = max(0.0f, 0.5f - delay) / (1.0f - delay);
7618 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7620 application.SendNotification();
7621 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7623 // We didn't expect the animation to finish yet
7624 application.SendNotification();
7625 finishCheck.CheckSignalNotReceived();
7626 progress = max(0.0f, 0.75f - delay) / (1.0f - delay);
7627 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7629 application.SendNotification();
7630 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7632 // We did expect the animation to finish
7633 application.SendNotification();
7634 finishCheck.CheckSignalReceived();
7635 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7639 int UtcDaliAnimationRotateToDegreeVector3(void)
7641 TestApplication application;
7643 Actor actor = Actor::New();
7644 actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
7645 Stage::GetCurrent().Add(actor);
7646 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7648 // Build the animation
7649 float durationSeconds(1.0f);
7650 Animation animation = Animation::New(durationSeconds);
7651 Degree targetRotationDegrees(90.0f);
7652 Radian targetRotationRadians(targetRotationDegrees);
7653 animation.RotateTo(actor, targetRotationDegrees/*Degree version*/, Vector3::YAXIS);
7655 // Start the animation
7658 bool signalReceived(false);
7659 AnimationFinishCheck finishCheck(signalReceived);
7660 animation.FinishedSignal().Connect(&application, finishCheck);
7662 application.SendNotification();
7663 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7665 // We didn't expect the animation to finish yet
7666 application.SendNotification();
7667 finishCheck.CheckSignalNotReceived();
7668 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.25f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7670 application.SendNotification();
7671 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7673 // We didn't expect the animation to finish yet
7674 application.SendNotification();
7675 finishCheck.CheckSignalNotReceived();
7676 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.5f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7678 application.SendNotification();
7679 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7681 // We didn't expect the animation to finish yet
7682 application.SendNotification();
7683 finishCheck.CheckSignalNotReceived();
7684 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.75f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7686 application.SendNotification();
7687 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7689 // We did expect the animation to finish
7690 application.SendNotification();
7691 finishCheck.CheckSignalReceived();
7692 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7696 int UtcDaliAnimationRotateToRadianVector3(void)
7698 TestApplication application;
7700 Actor actor = Actor::New();
7701 actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
7702 Stage::GetCurrent().Add(actor);
7703 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7705 // Build the animation
7706 float durationSeconds(1.0f);
7707 Animation animation = Animation::New(durationSeconds);
7708 Degree targetRotationDegrees(90.0f);
7709 Radian targetRotationRadians(targetRotationDegrees);
7710 animation.RotateTo(actor, targetRotationRadians/*Radian version*/, Vector3::YAXIS);
7712 // Start the animation
7715 bool signalReceived(false);
7716 AnimationFinishCheck finishCheck(signalReceived);
7717 animation.FinishedSignal().Connect(&application, finishCheck);
7719 application.SendNotification();
7720 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7722 // We didn't expect the animation to finish yet
7723 application.SendNotification();
7724 finishCheck.CheckSignalNotReceived();
7725 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.25f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7727 application.SendNotification();
7728 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7730 // We didn't expect the animation to finish yet
7731 application.SendNotification();
7732 finishCheck.CheckSignalNotReceived();
7733 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.5f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7735 application.SendNotification();
7736 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7738 // We didn't expect the animation to finish yet
7739 application.SendNotification();
7740 finishCheck.CheckSignalNotReceived();
7741 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.75f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7743 application.SendNotification();
7744 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7746 // We did expect the animation to finish
7747 application.SendNotification();
7748 finishCheck.CheckSignalReceived();
7749 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7753 int UtcDaliAnimationRotateToQuaternion(void)
7755 TestApplication application;
7757 Actor actor = Actor::New();
7758 actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
7759 Stage::GetCurrent().Add(actor);
7760 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7762 // Build the animation
7763 float durationSeconds(1.0f);
7764 Animation animation = Animation::New(durationSeconds);
7765 Degree targetRotationDegrees(90.0f);
7766 Radian targetRotationRadians(targetRotationDegrees);
7767 Quaternion targetRotation(targetRotationRadians, Vector3::YAXIS);
7768 animation.RotateTo(actor, targetRotation/*Quaternion version*/);
7770 // Start the animation
7773 bool signalReceived(false);
7774 AnimationFinishCheck finishCheck(signalReceived);
7775 animation.FinishedSignal().Connect(&application, finishCheck);
7777 application.SendNotification();
7778 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7780 // We didn't expect the animation to finish yet
7781 application.SendNotification();
7782 finishCheck.CheckSignalNotReceived();
7783 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.25f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7785 application.SendNotification();
7786 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7788 // We didn't expect the animation to finish yet
7789 application.SendNotification();
7790 finishCheck.CheckSignalNotReceived();
7791 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.5f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7793 application.SendNotification();
7794 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7796 // We didn't expect the animation to finish yet
7797 application.SendNotification();
7798 finishCheck.CheckSignalNotReceived();
7799 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.75f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7801 application.SendNotification();
7802 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7804 // We did expect the animation to finish
7805 application.SendNotification();
7806 finishCheck.CheckSignalReceived();
7807 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7811 int UtcDaliAnimationRotateToDegreeVector3Alpha(void)
7813 TestApplication application;
7815 Actor actor = Actor::New();
7816 actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
7817 Stage::GetCurrent().Add(actor);
7818 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7820 // Build the animation
7821 float durationSeconds(1.0f);
7822 Animation animation = Animation::New(durationSeconds);
7823 Degree targetRotationDegrees(90.0f);
7824 Radian targetRotationRadians(targetRotationDegrees);
7825 animation.RotateTo(actor, targetRotationDegrees/*Degree version*/, Vector3::YAXIS, AlphaFunctions::EaseIn);
7827 // Start the animation
7830 bool signalReceived(false);
7831 AnimationFinishCheck finishCheck(signalReceived);
7832 animation.FinishedSignal().Connect(&application, finishCheck);
7834 application.SendNotification();
7835 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7837 // We didn't expect the animation to finish yet
7838 application.SendNotification();
7839 finishCheck.CheckSignalNotReceived();
7840 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(0.25f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7842 application.SendNotification();
7843 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7845 // We didn't expect the animation to finish yet
7846 application.SendNotification();
7847 finishCheck.CheckSignalNotReceived();
7848 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(0.5f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7850 application.SendNotification();
7851 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7853 // We didn't expect the animation to finish yet
7854 application.SendNotification();
7855 finishCheck.CheckSignalNotReceived();
7856 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(0.75f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7858 application.SendNotification();
7859 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7861 // We did expect the animation to finish
7862 application.SendNotification();
7863 finishCheck.CheckSignalReceived();
7864 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7868 int UtcDaliAnimationRotateToRadianVector3Alpha(void)
7870 TestApplication application;
7872 Actor actor = Actor::New();
7873 actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
7874 Stage::GetCurrent().Add(actor);
7875 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7877 // Build the animation
7878 float durationSeconds(1.0f);
7879 Animation animation = Animation::New(durationSeconds);
7880 Degree targetRotationDegrees(90.0f);
7881 Radian targetRotationRadians(targetRotationDegrees);
7882 animation.RotateTo(actor, targetRotationRadians/*Radian version*/, Vector3::YAXIS, AlphaFunctions::EaseIn);
7884 // Start the animation
7887 bool signalReceived(false);
7888 AnimationFinishCheck finishCheck(signalReceived);
7889 animation.FinishedSignal().Connect(&application, finishCheck);
7891 application.SendNotification();
7892 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7894 // We didn't expect the animation to finish yet
7895 application.SendNotification();
7896 finishCheck.CheckSignalNotReceived();
7897 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(0.25f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7899 application.SendNotification();
7900 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7902 // We didn't expect the animation to finish yet
7903 application.SendNotification();
7904 finishCheck.CheckSignalNotReceived();
7905 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(0.5f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7907 application.SendNotification();
7908 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7910 // We didn't expect the animation to finish yet
7911 application.SendNotification();
7912 finishCheck.CheckSignalNotReceived();
7913 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(0.75f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7915 application.SendNotification();
7916 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7918 // We did expect the animation to finish
7919 application.SendNotification();
7920 finishCheck.CheckSignalReceived();
7921 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7925 int UtcDaliAnimationRotateToQuaternionAlpha(void)
7927 TestApplication application;
7929 Actor actor = Actor::New();
7930 actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
7931 Stage::GetCurrent().Add(actor);
7932 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7934 // Build the animation
7935 float durationSeconds(1.0f);
7936 Animation animation = Animation::New(durationSeconds);
7937 Degree targetRotationDegrees(90.0f);
7938 Radian targetRotationRadians(targetRotationDegrees);
7939 Quaternion targetRotation(targetRotationRadians, Vector3::YAXIS);
7940 animation.RotateTo(actor, targetRotation/*Quaternion version*/, AlphaFunctions::EaseIn);
7942 // Start the animation
7945 bool signalReceived(false);
7946 AnimationFinishCheck finishCheck(signalReceived);
7947 animation.FinishedSignal().Connect(&application, finishCheck);
7949 application.SendNotification();
7950 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7952 // We didn't expect the animation to finish yet
7953 application.SendNotification();
7954 finishCheck.CheckSignalNotReceived();
7955 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(0.25f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7957 application.SendNotification();
7958 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7960 // We didn't expect the animation to finish yet
7961 application.SendNotification();
7962 finishCheck.CheckSignalNotReceived();
7963 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(0.5f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7965 application.SendNotification();
7966 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7968 // We didn't expect the animation to finish yet
7969 application.SendNotification();
7970 finishCheck.CheckSignalNotReceived();
7971 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(0.75f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7973 application.SendNotification();
7974 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7976 // We did expect the animation to finish
7977 application.SendNotification();
7978 finishCheck.CheckSignalReceived();
7979 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7983 int UtcDaliAnimationRotateToDegreeVector3AlphaFloat2(void)
7985 TestApplication application;
7987 Actor actor = Actor::New();
7988 actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
7989 Stage::GetCurrent().Add(actor);
7990 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7992 // Build the animation
7993 float durationSeconds(1.0f);
7994 Animation animation = Animation::New(durationSeconds);
7995 Degree targetRotationDegrees(90.0f);
7996 Radian targetRotationRadians(targetRotationDegrees);
7998 animation.RotateTo(actor, targetRotationDegrees/*Degree version*/, Vector3::YAXIS, AlphaFunctions::EaseIn, delay, durationSeconds - delay);
8000 // Start the animation
8003 bool signalReceived(false);
8004 AnimationFinishCheck finishCheck(signalReceived);
8005 animation.FinishedSignal().Connect(&application, finishCheck);
8007 application.SendNotification();
8008 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
8010 // We didn't expect the animation to finish yet
8011 application.SendNotification();
8012 finishCheck.CheckSignalNotReceived();
8013 float progress = max(0.0f, 0.25f - delay) / (1.0f - delay);
8014 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
8016 application.SendNotification();
8017 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
8019 // We didn't expect the animation to finish yet
8020 application.SendNotification();
8021 finishCheck.CheckSignalNotReceived();
8022 progress = max(0.0f, 0.5f - delay) / (1.0f - delay);
8023 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
8025 application.SendNotification();
8026 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
8028 // We didn't expect the animation to finish yet
8029 application.SendNotification();
8030 finishCheck.CheckSignalNotReceived();
8031 progress = max(0.0f, 0.75f - delay) / (1.0f - delay);
8032 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
8034 application.SendNotification();
8035 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
8037 // We did expect the animation to finish
8038 application.SendNotification();
8039 finishCheck.CheckSignalReceived();
8040 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
8044 int UtcDaliAnimationRotateToRadianVector3AlphaFloat2(void)
8046 TestApplication application;
8048 Actor actor = Actor::New();
8049 actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
8050 Stage::GetCurrent().Add(actor);
8051 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
8053 // Build the animation
8054 float durationSeconds(1.0f);
8055 Animation animation = Animation::New(durationSeconds);
8056 Degree targetRotationDegrees(90.0f);
8057 Radian targetRotationRadians(targetRotationDegrees);
8059 animation.RotateTo(actor, targetRotationRadians/*Radian version*/, Vector3::YAXIS, AlphaFunctions::EaseIn, delay, durationSeconds - delay);
8061 // Start the animation
8064 bool signalReceived(false);
8065 AnimationFinishCheck finishCheck(signalReceived);
8066 animation.FinishedSignal().Connect(&application, finishCheck);
8068 application.SendNotification();
8069 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
8071 // We didn't expect the animation to finish yet
8072 application.SendNotification();
8073 finishCheck.CheckSignalNotReceived();
8074 float progress = max(0.0f, 0.25f - delay) / (1.0f - delay);
8075 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
8077 application.SendNotification();
8078 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
8080 // We didn't expect the animation to finish yet
8081 application.SendNotification();
8082 finishCheck.CheckSignalNotReceived();
8083 progress = max(0.0f, 0.5f - delay) / (1.0f - delay);
8084 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
8086 application.SendNotification();
8087 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
8089 // We didn't expect the animation to finish yet
8090 application.SendNotification();
8091 finishCheck.CheckSignalNotReceived();
8092 progress = max(0.0f, 0.75f - delay) / (1.0f - delay);
8093 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
8095 application.SendNotification();
8096 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
8098 // We did expect the animation to finish
8099 application.SendNotification();
8100 finishCheck.CheckSignalReceived();
8101 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
8105 int UtcDaliAnimationRotateToQuaternionAlphaFloat2(void)
8107 TestApplication application;
8109 Actor actor = Actor::New();
8110 actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
8111 Stage::GetCurrent().Add(actor);
8112 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
8114 // Build the animation
8115 float durationSeconds(1.0f);
8116 Animation animation = Animation::New(durationSeconds);
8117 Degree targetRotationDegrees(90.0f);
8118 Radian targetRotationRadians(targetRotationDegrees);
8120 Quaternion targetRotation(targetRotationRadians, Vector3::YAXIS);
8121 animation.RotateTo(actor, targetRotation/*Quaternion version*/, AlphaFunctions::EaseIn, delay, durationSeconds - delay);
8123 // Start the animation
8126 bool signalReceived(false);
8127 AnimationFinishCheck finishCheck(signalReceived);
8128 animation.FinishedSignal().Connect(&application, finishCheck);
8130 application.SendNotification();
8131 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
8133 // We didn't expect the animation to finish yet
8134 application.SendNotification();
8135 finishCheck.CheckSignalNotReceived();
8136 float progress = max(0.0f, 0.25f - delay) / (1.0f - delay);
8137 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
8139 application.SendNotification();
8140 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
8142 // We didn't expect the animation to finish yet
8143 application.SendNotification();
8144 finishCheck.CheckSignalNotReceived();
8145 progress = max(0.0f, 0.5f - delay) / (1.0f - delay);
8146 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
8148 application.SendNotification();
8149 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
8151 // We didn't expect the animation to finish yet
8152 application.SendNotification();
8153 finishCheck.CheckSignalNotReceived();
8154 progress = max(0.0f, 0.75f - delay) / (1.0f - delay);
8155 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
8157 application.SendNotification();
8158 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
8160 // We did expect the animation to finish
8161 application.SendNotification();
8162 finishCheck.CheckSignalReceived();
8163 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
8167 int UtcDaliAnimationRotate(void)
8169 TestApplication application;
8171 Actor actor = Actor::New();
8172 Quaternion initialRotation(0.0f, Vector3::YAXIS);
8173 actor.SetRotation(initialRotation);
8174 Stage::GetCurrent().Add(actor);
8175 DALI_TEST_EQUALS( actor.GetCurrentRotation(), initialRotation, ROTATION_EPSILON, TEST_LOCATION );
8177 // Build the animation
8178 float durationSeconds(1.0f);
8179 Animation animation = Animation::New(durationSeconds);
8180 TumbleFunc func(Vector3::YAXIS);
8181 animation.Rotate(actor, func, AlphaFunctions::Linear, 0.0f, durationSeconds);
8183 // Start the animation
8186 bool signalReceived(false);
8187 AnimationFinishCheck finishCheck(signalReceived);
8188 animation.FinishedSignal().Connect(&application, finishCheck);
8190 application.SendNotification();
8191 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
8193 // We didn't expect the animation to finish yet
8194 application.SendNotification();
8195 finishCheck.CheckSignalNotReceived();
8196 DALI_TEST_EQUALS( actor.GetCurrentRotation(), func(0.25f, initialRotation), ROTATION_EPSILON, TEST_LOCATION );
8198 application.SendNotification();
8199 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
8201 // We didn't expect the animation to finish yet
8202 application.SendNotification();
8203 finishCheck.CheckSignalNotReceived();
8204 DALI_TEST_EQUALS( actor.GetCurrentRotation(), func(0.5f, initialRotation), ROTATION_EPSILON, TEST_LOCATION );
8206 application.SendNotification();
8207 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
8209 // We didn't expect the animation to finish yet
8210 application.SendNotification();
8211 finishCheck.CheckSignalNotReceived();
8212 DALI_TEST_EQUALS( actor.GetCurrentRotation(), func(0.75f, initialRotation), ROTATION_EPSILON, TEST_LOCATION );
8214 application.SendNotification();
8215 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
8217 // We did expect the animation to finish
8218 application.SendNotification();
8219 finishCheck.CheckSignalReceived();
8220 DALI_TEST_EQUALS( actor.GetCurrentRotation(), func(1.0f, initialRotation), ROTATION_EPSILON, TEST_LOCATION );
8224 int UtcDaliAnimationScaleBy(void)
8226 TestApplication application;
8228 Actor actor = Actor::New();
8229 Stage::GetCurrent().Add(actor);
8230 DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
8232 // Build the animation
8233 float durationSeconds(1.0f);
8234 Animation animation = Animation::New(durationSeconds);
8235 Vector3 targetScale(2.0f, 2.0f, 2.0f);
8236 Vector3 relativeScale(targetScale - Vector3::ONE);
8237 animation.ScaleBy(actor, relativeScale.x, relativeScale.y, relativeScale.z);
8239 Vector3 ninetyNinePercentProgress(Vector3::ONE + relativeScale*0.99f);
8241 // Start the animation
8244 bool signalReceived(false);
8245 AnimationFinishCheck finishCheck(signalReceived);
8246 animation.FinishedSignal().Connect(&application, finishCheck);
8248 application.SendNotification();
8249 application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
8251 // We didn't expect the animation to finish yet
8252 application.SendNotification();
8253 finishCheck.CheckSignalNotReceived();
8254 DALI_TEST_EQUALS( actor.GetCurrentScale(), ninetyNinePercentProgress, TEST_LOCATION );
8256 application.SendNotification();
8257 application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
8259 // We did expect the animation to finish
8260 application.SendNotification();
8261 finishCheck.CheckSignalReceived();
8262 DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
8265 finishCheck.Reset();
8266 actor.SetScale(Vector3::ONE);
8267 application.SendNotification();
8268 application.Render(0);
8269 DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
8271 // Repeat with a different (ease-in) alpha function
8272 animation = Animation::New(durationSeconds);
8273 animation.ScaleBy(actor, relativeScale, AlphaFunctions::EaseIn);
8274 animation.FinishedSignal().Connect(&application, finishCheck);
8277 application.SendNotification();
8278 application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
8280 // We didn't expect the animation to finish yet
8281 application.SendNotification();
8282 finishCheck.CheckSignalNotReceived();
8284 // The scale should have grown less, than with a linear alpha function
8285 Vector3 current(actor.GetCurrentScale());
8286 DALI_TEST_CHECK( current.x > 1.0f );
8287 DALI_TEST_CHECK( current.y > 1.0f );
8288 DALI_TEST_CHECK( current.z > 1.0f );
8289 DALI_TEST_CHECK( current.x < ninetyNinePercentProgress.x );
8290 DALI_TEST_CHECK( current.y < ninetyNinePercentProgress.y );
8291 DALI_TEST_CHECK( current.z < ninetyNinePercentProgress.z );
8293 application.SendNotification();
8294 application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
8296 // We did expect the animation to finish
8297 application.SendNotification();
8298 finishCheck.CheckSignalReceived();
8299 DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
8302 finishCheck.Reset();
8303 actor.SetScale(Vector3::ONE);
8304 application.SendNotification();
8305 application.Render(0);
8306 DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
8308 // Repeat with a delay
8310 animation = Animation::New(durationSeconds);
8311 animation.ScaleBy(actor, relativeScale, AlphaFunctions::Linear, delay, durationSeconds - delay);
8312 animation.FinishedSignal().Connect(&application, finishCheck);
8315 application.SendNotification();
8316 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
8318 // We didn't expect the animation to finish yet
8319 application.SendNotification();
8320 finishCheck.CheckSignalNotReceived();
8321 DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
8323 application.SendNotification();
8324 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
8326 // We did expect the animation to finish
8327 application.SendNotification();
8328 finishCheck.CheckSignalReceived();
8329 DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
8333 int UtcDaliAnimationScaleTo(void)
8335 TestApplication application;
8337 Actor actor = Actor::New();
8338 Stage::GetCurrent().Add(actor);
8339 DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
8341 // Build the animation
8342 float durationSeconds(1.0f);
8343 Animation animation = Animation::New(durationSeconds);
8344 Vector3 targetScale(2.0f, 2.0f, 2.0f);
8345 animation.ScaleTo(actor, targetScale.x, targetScale.y, targetScale.z);
8347 Vector3 ninetyNinePercentProgress(Vector3::ONE + (targetScale - Vector3::ONE)*0.99f);
8349 // Start the animation
8352 bool signalReceived(false);
8353 AnimationFinishCheck finishCheck(signalReceived);
8354 animation.FinishedSignal().Connect(&application, finishCheck);
8356 application.SendNotification();
8357 application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
8359 // We didn't expect the animation to finish yet
8360 application.SendNotification();
8361 finishCheck.CheckSignalNotReceived();
8362 DALI_TEST_EQUALS( actor.GetCurrentScale(), ninetyNinePercentProgress, TEST_LOCATION );
8364 application.SendNotification();
8365 application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
8367 // We did expect the animation to finish
8368 application.SendNotification();
8369 finishCheck.CheckSignalReceived();
8370 DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
8373 finishCheck.Reset();
8374 actor.SetScale(Vector3::ONE);
8375 application.SendNotification();
8376 application.Render(0);
8377 DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
8379 // Repeat with a different (ease-in) alpha function
8380 animation = Animation::New(durationSeconds);
8381 animation.ScaleTo(actor, targetScale, AlphaFunctions::EaseIn);
8382 animation.FinishedSignal().Connect(&application, finishCheck);
8385 application.SendNotification();
8386 application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
8388 // We didn't expect the animation to finish yet
8389 application.SendNotification();
8390 finishCheck.CheckSignalNotReceived();
8392 // The scale should have grown less, than with a linear alpha function
8393 Vector3 current(actor.GetCurrentScale());
8394 DALI_TEST_CHECK( current.x > 1.0f );
8395 DALI_TEST_CHECK( current.y > 1.0f );
8396 DALI_TEST_CHECK( current.z > 1.0f );
8397 DALI_TEST_CHECK( current.x < ninetyNinePercentProgress.x );
8398 DALI_TEST_CHECK( current.y < ninetyNinePercentProgress.y );
8399 DALI_TEST_CHECK( current.z < ninetyNinePercentProgress.z );
8401 application.SendNotification();
8402 application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
8404 // We did expect the animation to finish
8405 application.SendNotification();
8406 finishCheck.CheckSignalReceived();
8407 DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
8410 finishCheck.Reset();
8411 actor.SetScale(Vector3::ONE);
8412 application.SendNotification();
8413 application.Render(0);
8414 DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
8416 // Repeat with a delay
8418 animation = Animation::New(durationSeconds);
8419 animation.ScaleTo(actor, targetScale, AlphaFunctions::Linear, delay, durationSeconds - delay);
8420 animation.FinishedSignal().Connect(&application, finishCheck);
8423 application.SendNotification();
8424 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
8426 // We didn't expect the animation to finish yet
8427 application.SendNotification();
8428 finishCheck.CheckSignalNotReceived();
8429 DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
8431 application.SendNotification();
8432 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
8434 // We did expect the animation to finish
8435 application.SendNotification();
8436 finishCheck.CheckSignalReceived();
8437 DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
8441 int UtcDaliAnimationShow(void)
8443 TestApplication application;
8445 Actor actor = Actor::New();
8446 actor.SetVisible(false);
8447 application.SendNotification();
8448 application.Render(0);
8449 DALI_TEST_CHECK( !actor.IsVisible() );
8450 Stage::GetCurrent().Add(actor);
8452 // Start the animation
8453 float durationSeconds(10.0f);
8454 Animation animation = Animation::New(durationSeconds);
8455 animation.Show(actor, durationSeconds*0.5f);
8458 bool signalReceived(false);
8459 AnimationFinishCheck finishCheck(signalReceived);
8460 animation.FinishedSignal().Connect(&application, finishCheck);
8462 application.SendNotification();
8463 application.Render(static_cast<unsigned int>(durationSeconds*490.0f));
8465 // We didn't expect the animation to finish yet
8466 application.SendNotification();
8467 finishCheck.CheckSignalNotReceived();
8468 DALI_TEST_CHECK( !actor.IsVisible() );
8470 application.SendNotification();
8471 application.Render(static_cast<unsigned int>(durationSeconds*10.0f)/*Should be shown now*/);
8473 // We didn't expect the animation to finish yet
8474 application.SendNotification();
8475 finishCheck.CheckSignalNotReceived();
8476 DALI_TEST_CHECK( actor.IsVisible() );
8478 application.SendNotification();
8479 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
8481 // We did expect the animation to finish
8482 application.SendNotification();
8483 finishCheck.CheckSignalReceived();
8484 DALI_TEST_CHECK( actor.IsVisible() );
8488 int UtcDaliAnimationHide(void)
8490 TestApplication application;
8492 Actor actor = Actor::New();
8493 DALI_TEST_CHECK( actor.IsVisible() );
8494 Stage::GetCurrent().Add(actor);
8496 // Start the animation
8497 float durationSeconds(10.0f);
8498 Animation animation = Animation::New(durationSeconds);
8499 animation.Hide(actor, durationSeconds*0.5f);
8502 bool signalReceived(false);
8503 AnimationFinishCheck finishCheck(signalReceived);
8504 animation.FinishedSignal().Connect(&application, finishCheck);
8506 application.SendNotification();
8507 application.Render(static_cast<unsigned int>(durationSeconds*490.0f));
8509 // We didn't expect the animation to finish yet
8510 application.SendNotification();
8511 finishCheck.CheckSignalNotReceived();
8512 DALI_TEST_CHECK( actor.IsVisible() );
8514 application.SendNotification();
8515 application.Render(static_cast<unsigned int>(durationSeconds*10.0f)/*Should be hidden now*/);
8517 // We didn't expect the animation to finish yet
8518 application.SendNotification();
8519 finishCheck.CheckSignalNotReceived();
8520 DALI_TEST_CHECK( !actor.IsVisible() );
8522 application.SendNotification();
8523 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
8525 // We did expect the animation to finish
8526 application.SendNotification();
8527 finishCheck.CheckSignalReceived();
8528 DALI_TEST_CHECK( !actor.IsVisible() );
8532 int UtcDaliAnimationShowHideAtEnd(void)
8534 // Test that show/hide delay can be the same as animation duration
8535 // i.e. to show/hide at the end of the animation
8537 TestApplication application;
8539 Actor actor = Actor::New();
8540 DALI_TEST_CHECK( actor.IsVisible() );
8541 Stage::GetCurrent().Add(actor);
8543 // Start Hide animation
8544 float durationSeconds(10.0f);
8545 Animation animation = Animation::New(durationSeconds);
8546 animation.Hide(actor, durationSeconds/*Hide at end*/);
8549 bool signalReceived(false);
8550 AnimationFinishCheck finishCheck(signalReceived);
8551 animation.FinishedSignal().Connect(&application, finishCheck);
8553 application.SendNotification();
8554 application.Render(static_cast<unsigned int>(durationSeconds*1000.0f) + 1u/*just beyond the animation duration*/);
8556 // We did expect the animation to finish
8557 application.SendNotification();
8558 finishCheck.CheckSignalReceived();
8559 DALI_TEST_CHECK( !actor.IsVisible() );
8561 // Start Show animation
8562 animation = Animation::New(durationSeconds);
8563 animation.Show(actor, durationSeconds/*Show at end*/);
8564 animation.FinishedSignal().Connect(&application, finishCheck);
8567 application.SendNotification();
8568 application.Render(static_cast<unsigned int>(durationSeconds*1000.0f) + 1u/*just beyond the animation duration*/);
8570 // We did expect the animation to finish
8571 application.SendNotification();
8572 finishCheck.CheckSignalReceived();
8573 DALI_TEST_CHECK( actor.IsVisible() );
8577 int UtcDaliAnimationOpacityBy(void)
8579 TestApplication application;
8580 Actor actor = Actor::New();
8581 float startingOpacity(0.5f);
8582 actor.SetOpacity(startingOpacity);
8583 application.SendNotification();
8584 application.Render(0);
8585 DALI_TEST_EQUALS( actor.GetCurrentOpacity(), startingOpacity, TEST_LOCATION );
8586 Stage::GetCurrent().Add(actor);
8588 // Build the animation
8589 float durationSeconds(1.0f);
8590 Animation animation = Animation::New(durationSeconds);
8591 float relativeOpacity(-0.5f); // target of zero
8592 animation.OpacityBy(actor, relativeOpacity);
8594 float seventyFivePercentProgress((1.0f - 0.75f) * startingOpacity);
8596 // Start the animation
8599 bool signalReceived(false);
8600 AnimationFinishCheck finishCheck(signalReceived);
8601 animation.FinishedSignal().Connect(&application, finishCheck);
8603 application.SendNotification();
8604 application.Render(static_cast<unsigned int>(durationSeconds*750.0f)/* 75% progress */);
8606 // We didn't expect the animation to finish yet
8607 application.SendNotification();
8608 finishCheck.CheckSignalNotReceived();
8609 DALI_TEST_EQUALS( actor.GetCurrentOpacity(), seventyFivePercentProgress, TEST_LOCATION );
8611 application.SendNotification();
8612 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
8614 // We did expect the animation to finish
8615 application.SendNotification();
8616 finishCheck.CheckSignalReceived();
8617 DALI_TEST_EQUALS( actor.GetCurrentOpacity(), startingOpacity+relativeOpacity, TEST_LOCATION );
8620 finishCheck.Reset();
8621 actor.SetOpacity(startingOpacity);
8622 application.SendNotification();
8623 application.Render(0);
8624 DALI_TEST_EQUALS( actor.GetCurrentOpacity(), startingOpacity, TEST_LOCATION );
8626 // Repeat with a different (ease-in) alpha function
8627 animation = Animation::New(durationSeconds);
8628 animation.OpacityBy(actor, relativeOpacity, AlphaFunctions::EaseIn);
8629 animation.FinishedSignal().Connect(&application, finishCheck);
8632 application.SendNotification();
8633 application.Render(static_cast<unsigned int>(durationSeconds*750.0f)/* 75% progress */);
8635 // We didn't expect the animation to finish yet
8636 application.SendNotification();
8637 finishCheck.CheckSignalNotReceived();
8639 // The opacity should reduce less, than with a linear alpha function
8640 float current(actor.GetCurrentOpacity());
8641 DALI_TEST_CHECK( current < 1.0f );
8642 DALI_TEST_CHECK( current > seventyFivePercentProgress );
8644 application.SendNotification();
8645 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
8647 // We did expect the animation to finish
8648 application.SendNotification();
8649 finishCheck.CheckSignalReceived();
8650 DALI_TEST_EQUALS( actor.GetCurrentOpacity(), startingOpacity+relativeOpacity, TEST_LOCATION );
8653 finishCheck.Reset();
8654 actor.SetOpacity(startingOpacity);
8655 application.SendNotification();
8656 application.Render(0);
8657 DALI_TEST_EQUALS( actor.GetCurrentOpacity(), startingOpacity, TEST_LOCATION );
8659 // Repeat with a delay
8661 animation = Animation::New(durationSeconds);
8662 animation.OpacityBy(actor, relativeOpacity, AlphaFunctions::Linear, delay, durationSeconds - delay);
8663 animation.FinishedSignal().Connect(&application, finishCheck);
8666 application.SendNotification();
8667 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
8669 // We didn't expect the animation to finish yet
8670 application.SendNotification();
8671 finishCheck.CheckSignalNotReceived();
8672 DALI_TEST_EQUALS( actor.GetCurrentOpacity(), startingOpacity, TEST_LOCATION );
8674 application.SendNotification();
8675 application.Render(static_cast<unsigned int>(durationSeconds*500.0f*0.75)/* 7/8 animation progress, 3/4 animator progress */);
8677 // We didn't expect the animation to finish yet
8678 application.SendNotification();
8679 finishCheck.CheckSignalNotReceived();
8680 DALI_TEST_EQUALS( actor.GetCurrentOpacity(), seventyFivePercentProgress, TEST_LOCATION );
8682 application.SendNotification();
8683 application.Render(static_cast<unsigned int>(durationSeconds*500.0f*0.25) + 1u/*just beyond the animation duration*/);
8685 // We did expect the animation to finish
8686 application.SendNotification();
8687 finishCheck.CheckSignalReceived();
8688 DALI_TEST_EQUALS( actor.GetCurrentOpacity(), startingOpacity+relativeOpacity, TEST_LOCATION );
8692 int UtcDaliAnimationOpacityTo(void)
8694 TestApplication application;
8696 Actor actor = Actor::New();
8697 Stage::GetCurrent().Add(actor);
8698 DALI_TEST_EQUALS( actor.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
8700 // Build the animation
8701 float durationSeconds(1.0f);
8702 Animation animation = Animation::New(durationSeconds);
8703 float targetOpacity(0.0f);
8704 animation.OpacityTo(actor, targetOpacity);
8706 float ninetyNinePercentProgress(0.01f);
8708 // Start the animation
8711 bool signalReceived(false);
8712 AnimationFinishCheck finishCheck(signalReceived);
8713 animation.FinishedSignal().Connect(&application, finishCheck);
8715 application.SendNotification();
8716 application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
8718 // We didn't expect the animation to finish yet
8719 application.SendNotification();
8720 finishCheck.CheckSignalNotReceived();
8721 DALI_TEST_EQUALS( actor.GetCurrentOpacity(), ninetyNinePercentProgress, 0.001f, TEST_LOCATION );
8723 application.SendNotification();
8724 application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
8726 // We did expect the animation to finish
8727 application.SendNotification();
8728 finishCheck.CheckSignalReceived();
8729 DALI_TEST_EQUALS( actor.GetCurrentOpacity(), targetOpacity, TEST_LOCATION );
8732 finishCheck.Reset();
8733 actor.SetOpacity(1.0f);
8734 application.SendNotification();
8735 application.Render(0);
8736 DALI_TEST_EQUALS( actor.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
8738 // Repeat with a different (ease-in) alpha function
8739 animation = Animation::New(durationSeconds);
8740 animation.OpacityTo(actor, targetOpacity, AlphaFunctions::EaseIn);
8741 animation.FinishedSignal().Connect(&application, finishCheck);
8744 application.SendNotification();
8745 application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
8747 // We didn't expect the animation to finish yet
8748 application.SendNotification();
8749 finishCheck.CheckSignalNotReceived();
8751 // The opacity should reduce less, than with a linear alpha function
8752 float current(actor.GetCurrentOpacity());
8753 DALI_TEST_CHECK( current < 1.0f );
8754 DALI_TEST_CHECK( current > ninetyNinePercentProgress );
8756 application.SendNotification();
8757 application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
8759 // We did expect the animation to finish
8760 application.SendNotification();
8761 finishCheck.CheckSignalReceived();
8762 DALI_TEST_EQUALS( actor.GetCurrentOpacity(), targetOpacity, TEST_LOCATION );
8765 finishCheck.Reset();
8766 actor.SetOpacity(1.0f);
8767 application.SendNotification();
8768 application.Render(0);
8769 DALI_TEST_EQUALS( actor.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
8771 // Repeat with a delay
8773 animation = Animation::New(durationSeconds);
8774 animation.OpacityTo(actor, targetOpacity, AlphaFunctions::Linear, delay, durationSeconds - delay);
8775 animation.FinishedSignal().Connect(&application, finishCheck);
8778 application.SendNotification();
8779 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
8781 // We didn't expect the animation to finish yet
8782 application.SendNotification();
8783 finishCheck.CheckSignalNotReceived();
8784 DALI_TEST_EQUALS( actor.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
8786 application.SendNotification();
8787 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
8789 // We did expect the animation to finish
8790 application.SendNotification();
8791 finishCheck.CheckSignalReceived();
8792 DALI_TEST_EQUALS( actor.GetCurrentOpacity(), targetOpacity, TEST_LOCATION );
8796 int UtcDaliAnimationColorBy(void)
8798 TestApplication application;
8800 Actor actor = Actor::New();
8801 actor.SetColor(Color::BLACK);
8802 application.SendNotification();
8803 application.Render(0);
8804 DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::BLACK, TEST_LOCATION );
8805 Stage::GetCurrent().Add(actor);
8807 // Build the animation
8808 float durationSeconds(1.0f);
8809 Animation animation = Animation::New(durationSeconds);
8810 Vector4 targetColor(Color::GREEN);
8811 Vector4 relativeColor(Color::GREEN); // Note the alpha is automatically clamped <= 1.0f in world color
8812 animation.ColorBy(actor, relativeColor);
8814 Vector4 tenPercentProgress(Vector4(0.0f, 0.1f, 0.0f, 1.0f));
8815 Vector4 twentyPercentProgress(Vector4(0.0f, 0.2f, 0.0f, 1.0f));
8817 // Start the animation
8820 bool signalReceived(false);
8821 AnimationFinishCheck finishCheck(signalReceived);
8822 animation.FinishedSignal().Connect(&application, finishCheck);
8824 application.SendNotification();
8825 application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% progress */);
8827 // We didn't expect the animation to finish yet
8828 application.SendNotification();
8829 finishCheck.CheckSignalNotReceived();
8830 DALI_TEST_EQUALS( actor.GetCurrentWorldColor(), tenPercentProgress, TEST_LOCATION );
8832 application.SendNotification();
8833 application.Render(static_cast<unsigned int>(durationSeconds*900.0f) + 1u/*just beyond the animation duration*/);
8835 // We did expect the animation to finish
8836 application.SendNotification();
8837 finishCheck.CheckSignalReceived();
8838 DALI_TEST_EQUALS( actor.GetCurrentWorldColor(), targetColor, TEST_LOCATION );
8841 finishCheck.Reset();
8842 actor.SetColor(Color::BLACK);
8843 application.SendNotification();
8844 application.Render(0);
8845 DALI_TEST_EQUALS( actor.GetCurrentWorldColor(), Color::BLACK, TEST_LOCATION );
8847 // Repeat with a different (ease-in) alpha function
8848 animation = Animation::New(durationSeconds);
8849 animation.ColorBy(actor, relativeColor, AlphaFunctions::EaseIn);
8850 animation.FinishedSignal().Connect(&application, finishCheck);
8853 application.SendNotification();
8854 application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% progress */);
8856 // We didn't expect the animation to finish yet
8857 application.SendNotification();
8858 finishCheck.CheckSignalNotReceived();
8860 // The color should have changed less, than with a linear alpha function
8861 Vector4 current(actor.GetCurrentWorldColor());
8862 DALI_TEST_CHECK( current.x == 0.0f ); // doesn't change
8863 DALI_TEST_CHECK( current.y > 0.0f );
8864 DALI_TEST_CHECK( current.y < tenPercentProgress.y );
8865 DALI_TEST_CHECK( current.z == 0.0f ); // doesn't change
8866 DALI_TEST_CHECK( current.w == 1.0f ); // doesn't change
8868 application.SendNotification();
8869 application.Render(static_cast<unsigned int>(durationSeconds*900.0f) + 1u/*just beyond the animation duration*/);
8871 // We did expect the animation to finish
8872 application.SendNotification();
8873 finishCheck.CheckSignalReceived();
8874 DALI_TEST_EQUALS( actor.GetCurrentWorldColor(), targetColor, TEST_LOCATION );
8877 finishCheck.Reset();
8878 actor.SetColor(Color::BLACK);
8879 application.SendNotification();
8880 application.Render(0);
8881 DALI_TEST_EQUALS( actor.GetCurrentWorldColor(), Color::BLACK, TEST_LOCATION );
8883 // Repeat with a shorter animator duration
8884 float animatorDuration = 0.5f;
8885 animation = Animation::New(durationSeconds);
8886 animation.ColorBy(actor, relativeColor, AlphaFunctions::Linear, 0, animatorDuration);
8887 animation.FinishedSignal().Connect(&application, finishCheck);
8890 application.SendNotification();
8891 application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% animation progress, 20% animator progress */);
8893 // We didn't expect the animation to finish yet
8894 application.SendNotification();
8895 finishCheck.CheckSignalNotReceived();
8896 DALI_TEST_EQUALS( actor.GetCurrentWorldColor(), twentyPercentProgress, TEST_LOCATION );
8898 application.SendNotification();
8899 application.Render(static_cast<unsigned int>(durationSeconds*400.0f)/* 50% animation progress, 100% animator progress */);
8901 // We didn't expect the animation to finish yet
8902 application.SendNotification();
8903 finishCheck.CheckSignalNotReceived();
8904 DALI_TEST_EQUALS( actor.GetCurrentWorldColor(), targetColor, TEST_LOCATION );
8906 application.SendNotification();
8907 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
8909 // We did expect the animation to finish
8910 application.SendNotification();
8911 finishCheck.CheckSignalReceived();
8912 DALI_TEST_EQUALS( actor.GetCurrentWorldColor(), targetColor, TEST_LOCATION );
8916 int UtcDaliAnimationColorTo(void)
8918 TestApplication application;
8920 Actor actor = Actor::New();
8921 Stage::GetCurrent().Add(actor);
8922 DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
8924 // Build the animation
8925 float durationSeconds(1.0f);
8926 Animation animation = Animation::New(durationSeconds);
8927 Vector4 targetColor(Color::RED);
8928 animation.ColorTo(actor, targetColor);
8930 Vector4 tenPercentProgress(Vector4(1.0f, 0.9f, 0.9f, 1.0f));
8931 Vector4 twentyPercentProgress(Vector4(1.0f, 0.8f, 0.8f, 1.0f));
8933 // Start the animation
8936 bool signalReceived(false);
8937 AnimationFinishCheck finishCheck(signalReceived);
8938 animation.FinishedSignal().Connect(&application, finishCheck);
8940 application.SendNotification();
8941 application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% progress */);
8943 // We didn't expect the animation to finish yet
8944 application.SendNotification();
8945 finishCheck.CheckSignalNotReceived();
8946 DALI_TEST_EQUALS( actor.GetCurrentColor(), tenPercentProgress, TEST_LOCATION );
8948 application.SendNotification();
8949 application.Render(static_cast<unsigned int>(durationSeconds*900.0f) + 1u/*just beyond the animation duration*/);
8951 // We did expect the animation to finish
8952 application.SendNotification();
8953 finishCheck.CheckSignalReceived();
8954 DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION );
8957 finishCheck.Reset();
8958 actor.SetColor(Color::WHITE);
8959 application.SendNotification();
8960 application.Render(0);
8961 DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
8963 // Repeat with a different (ease-in) alpha function
8964 animation = Animation::New(durationSeconds);
8965 animation.ColorTo(actor, targetColor, AlphaFunctions::EaseIn);
8966 animation.FinishedSignal().Connect(&application, finishCheck);
8969 application.SendNotification();
8970 application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% progress */);
8972 // We didn't expect the animation to finish yet
8973 application.SendNotification();
8974 finishCheck.CheckSignalNotReceived();
8976 // The color should have changed less, than with a linear alpha function
8977 Vector4 current(actor.GetCurrentColor());
8978 DALI_TEST_CHECK( current.x == 1.0f ); // doesn't change
8979 DALI_TEST_CHECK( current.y < 1.0f );
8980 DALI_TEST_CHECK( current.y > tenPercentProgress.y );
8981 DALI_TEST_CHECK( current.z < 1.0f );
8982 DALI_TEST_CHECK( current.z > tenPercentProgress.z );
8983 DALI_TEST_CHECK( current.w == 1.0f ); // doesn't change
8985 application.SendNotification();
8986 application.Render(static_cast<unsigned int>(durationSeconds*900.0f) + 1u/*just beyond the animation duration*/);
8988 // We did expect the animation to finish
8989 application.SendNotification();
8990 finishCheck.CheckSignalReceived();
8991 DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION );
8994 finishCheck.Reset();
8995 actor.SetColor(Color::WHITE);
8996 application.SendNotification();
8997 application.Render(0);
8998 DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
9000 // Repeat with a shorter animator duration
9001 float animatorDuration = 0.5f;
9002 animation = Animation::New(durationSeconds);
9003 animation.ColorTo(actor, targetColor, AlphaFunctions::Linear, 0, animatorDuration);
9004 animation.FinishedSignal().Connect(&application, finishCheck);
9007 application.SendNotification();
9008 application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% animation progress, 20% animator progress */);
9010 // We didn't expect the animation to finish yet
9011 application.SendNotification();
9012 finishCheck.CheckSignalNotReceived();
9013 DALI_TEST_EQUALS( actor.GetCurrentColor(), twentyPercentProgress, TEST_LOCATION );
9015 application.SendNotification();
9016 application.Render(static_cast<unsigned int>(durationSeconds*400.0f)/* 50% animation progress, 100% animator progress */);
9018 // We didn't expect the animation to finish yet
9019 application.SendNotification();
9020 finishCheck.CheckSignalNotReceived();
9021 DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION );
9023 application.SendNotification();
9024 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
9026 // We did expect the animation to finish
9027 application.SendNotification();
9028 finishCheck.CheckSignalReceived();
9029 DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION );
9033 int UtcDaliAnimationResize(void)
9035 TestApplication application;
9037 Actor actor = Actor::New();
9038 Stage::GetCurrent().Add(actor);
9039 DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
9041 // Build the animation
9042 float durationSeconds(1.0f);
9043 Animation animation = Animation::New(durationSeconds);
9044 Vector3 targetSize(100.0f, 100.0f, 100.0f);
9045 animation.Resize(actor, targetSize);
9047 Vector3 ninetyNinePercentProgress(targetSize * 0.99f);
9049 // Start the animation
9052 bool signalReceived(false);
9053 AnimationFinishCheck finishCheck(signalReceived);
9054 animation.FinishedSignal().Connect(&application, finishCheck);
9056 application.SendNotification();
9057 application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
9059 // We didn't expect the animation to finish yet
9060 application.SendNotification();
9061 finishCheck.CheckSignalNotReceived();
9062 DALI_TEST_EQUALS( actor.GetCurrentSize(), ninetyNinePercentProgress, TEST_LOCATION );
9064 application.SendNotification();
9065 application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
9067 // We did expect the animation to finish
9068 application.SendNotification();
9069 finishCheck.CheckSignalReceived();
9070 DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION );
9073 finishCheck.Reset();
9074 actor.SetSize(Vector3::ZERO);
9075 application.SendNotification();
9076 application.Render(0);
9077 DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
9079 // Repeat with a different (ease-in) alpha function
9080 animation = Animation::New(durationSeconds);
9081 animation.Resize(actor, targetSize, AlphaFunctions::EaseIn);
9082 animation.FinishedSignal().Connect(&application, finishCheck);
9085 application.SendNotification();
9086 application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
9088 // We didn't expect the animation to finish yet
9089 application.SendNotification();
9090 finishCheck.CheckSignalNotReceived();
9092 // The size should have travelled less, than with a linear alpha function
9093 Vector3 current(actor.GetCurrentSize());
9094 DALI_TEST_CHECK( current.x > 0.0f );
9095 DALI_TEST_CHECK( current.y > 0.0f );
9096 DALI_TEST_CHECK( current.z > 0.0f );
9097 DALI_TEST_CHECK( current.x < ninetyNinePercentProgress.x );
9098 DALI_TEST_CHECK( current.y < ninetyNinePercentProgress.y );
9099 DALI_TEST_CHECK( current.z < ninetyNinePercentProgress.z );
9101 application.SendNotification();
9102 application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
9104 // We did expect the animation to finish
9105 application.SendNotification();
9106 finishCheck.CheckSignalReceived();
9107 DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION );
9110 finishCheck.Reset();
9111 actor.SetSize(Vector3::ZERO);
9112 application.SendNotification();
9113 application.Render(0);
9114 DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
9116 // Repeat with a delay
9118 animation = Animation::New(durationSeconds);
9119 animation.Resize(actor, targetSize, AlphaFunctions::Linear, delay, durationSeconds - delay);
9120 animation.FinishedSignal().Connect(&application, finishCheck);
9123 application.SendNotification();
9124 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
9126 // We didn't expect the animation to finish yet
9127 application.SendNotification();
9128 finishCheck.CheckSignalNotReceived();
9129 DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
9131 application.SendNotification();
9132 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
9134 // We did expect the animation to finish
9135 application.SendNotification();
9136 finishCheck.CheckSignalReceived();
9137 DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION );
9141 int UtcDaliAnimationAnimateBool(void)
9143 TestApplication application;
9145 Actor actor = Actor::New();
9146 DALI_TEST_EQUALS( actor.IsVisible(), true, TEST_LOCATION );
9147 Stage::GetCurrent().Add(actor);
9149 // Build the animation
9150 float durationSeconds(10.0f);
9151 Animation animation = Animation::New(durationSeconds);
9152 animation.Animate<bool>( Property(actor, Actor::VISIBLE), ReturnFalseAfterProgressOne, TimePeriod(durationSeconds*0.25f/*delay*/, durationSeconds*0.1f) );
9154 // Start the animation
9157 bool signalReceived(false);
9158 AnimationFinishCheck finishCheck(signalReceived);
9159 animation.FinishedSignal().Connect(&application, finishCheck);
9161 application.SendNotification();
9162 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
9164 // We didn't expect the animation to finish yet
9165 application.SendNotification();
9166 finishCheck.CheckSignalNotReceived();
9168 // Should still be visible
9169 DALI_TEST_EQUALS( actor.IsVisible(), true, TEST_LOCATION );
9171 application.SendNotification();
9172 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
9174 // We didn't expect the animation to finish yet
9175 application.SendNotification();
9176 finishCheck.CheckSignalNotReceived();
9178 // Now animate functor should have hidden the actor
9179 DALI_TEST_EQUALS( actor.IsVisible(), false, TEST_LOCATION );
9181 application.SendNotification();
9182 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
9184 // We did expect the animation to finish
9185 application.SendNotification();
9186 finishCheck.CheckSignalReceived();
9187 DALI_TEST_EQUALS( actor.IsVisible(), false, TEST_LOCATION );
9191 int UtcDaliAnimationAnimateFloat(void)
9193 TestApplication application;
9195 Actor actor = Actor::New();
9196 Stage::GetCurrent().Add(actor);
9198 // Register a float property
9199 float startValue(10.0f);
9200 Property::Index index = actor.RegisterProperty( "test-property", startValue );
9201 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
9203 // Build the animation
9204 float durationSeconds(10.0f);
9205 Animation animation = Animation::New(durationSeconds);
9206 float targetPosition(0.0f);
9207 AnimateFloatTestFunctor func( 100, targetPosition );
9208 animation.Animate<float>( Property(actor, index), func );
9210 // Start the animation
9213 bool signalReceived(false);
9214 AnimationFinishCheck finishCheck(signalReceived);
9215 animation.FinishedSignal().Connect(&application, finishCheck);
9217 application.SendNotification();
9218 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
9220 // We didn't expect the animation to finish yet
9221 application.SendNotification();
9222 finishCheck.CheckSignalNotReceived();
9223 DALI_TEST_EQUALS( actor.GetProperty<float>(index), 75.0f, TEST_LOCATION );
9225 application.SendNotification();
9226 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
9228 // We didn't expect the animation to finish yet
9229 application.SendNotification();
9230 finishCheck.CheckSignalNotReceived();
9231 DALI_TEST_EQUALS( actor.GetProperty<float>(index), 50.0f, TEST_LOCATION );
9233 application.SendNotification();
9234 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
9236 // We didn't expect the animation to finish yet
9237 application.SendNotification();
9238 finishCheck.CheckSignalNotReceived();
9239 DALI_TEST_EQUALS( actor.GetProperty<float>(index), 25.0f, TEST_LOCATION );
9241 application.SendNotification();
9242 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
9244 // We did expect the animation to finish
9245 application.SendNotification();
9246 finishCheck.CheckSignalReceived();
9247 DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetPosition, TEST_LOCATION );
9251 int UtcDaliAnimationAnimateInteger(void)
9253 TestApplication application;
9255 Actor actor = Actor::New();
9256 Stage::GetCurrent().Add(actor);
9258 // Register an integer property
9260 Property::Index index = actor.RegisterProperty( "test-property", startValue );
9261 DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
9263 // Build the animation
9264 float durationSeconds(10.0f);
9265 Animation animation = Animation::New(durationSeconds);
9266 int targetPosition(0);
9267 AnimateIntegerTestFunctor func( 100, targetPosition );
9268 animation.Animate<int>( Property(actor, index), func );
9270 // Start the animation
9273 bool signalReceived(false);
9274 AnimationFinishCheck finishCheck(signalReceived);
9275 animation.FinishedSignal().Connect(&application, finishCheck);
9277 application.SendNotification();
9278 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
9280 // We didn't expect the animation to finish yet
9281 application.SendNotification();
9282 finishCheck.CheckSignalNotReceived();
9283 DALI_TEST_EQUALS( actor.GetProperty<int>(index), 75, TEST_LOCATION );
9285 application.SendNotification();
9286 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
9288 // We didn't expect the animation to finish yet
9289 application.SendNotification();
9290 finishCheck.CheckSignalNotReceived();
9291 DALI_TEST_EQUALS( actor.GetProperty<int>(index), 50, TEST_LOCATION );
9293 application.SendNotification();
9294 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
9296 // We didn't expect the animation to finish yet
9297 application.SendNotification();
9298 finishCheck.CheckSignalNotReceived();
9299 DALI_TEST_EQUALS( actor.GetProperty<int>(index), 25, TEST_LOCATION );
9301 application.SendNotification();
9302 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
9304 // We did expect the animation to finish
9305 application.SendNotification();
9306 finishCheck.CheckSignalReceived();
9307 DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetPosition, TEST_LOCATION );
9311 int UtcDaliAnimationAnimateVector2(void)
9313 TestApplication application;
9315 Actor actor = Actor::New();
9316 Stage::GetCurrent().Add(actor);
9318 // Register a Vector2 property
9319 Vector2 startValue(10.0f, 10.0f);
9320 Property::Index index = actor.RegisterProperty( "test-property", startValue );
9321 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
9323 // Build the animation
9324 float durationSeconds(10.0f);
9325 Animation animation = Animation::New(durationSeconds);
9326 Vector2 targetPosition(0.0f, 0.0f);
9327 AnimateVector2TestFunctor func( Vector2(100,100), targetPosition );
9328 animation.Animate<Vector2>( Property(actor, index), func );
9330 // Start the animation
9333 bool signalReceived(false);
9334 AnimationFinishCheck finishCheck(signalReceived);
9335 animation.FinishedSignal().Connect(&application, finishCheck);
9337 application.SendNotification();
9338 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
9340 // We didn't expect the animation to finish yet
9341 application.SendNotification();
9342 finishCheck.CheckSignalNotReceived();
9343 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), Vector2(75,75), TEST_LOCATION );
9345 application.SendNotification();
9346 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
9348 // We didn't expect the animation to finish yet
9349 application.SendNotification();
9350 finishCheck.CheckSignalNotReceived();
9351 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), Vector2(50,50), TEST_LOCATION );
9353 application.SendNotification();
9354 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
9356 // We didn't expect the animation to finish yet
9357 application.SendNotification();
9358 finishCheck.CheckSignalNotReceived();
9359 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), Vector2(25,25), TEST_LOCATION );
9361 application.SendNotification();
9362 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
9364 // We did expect the animation to finish
9365 application.SendNotification();
9366 finishCheck.CheckSignalReceived();
9367 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetPosition, TEST_LOCATION );
9371 int UtcDaliAnimationAnimateVector3(void)
9373 TestApplication application;
9375 Actor actor = Actor::New();
9376 Vector3 initialPosition(Vector3::ZERO);
9377 DALI_TEST_EQUALS( actor.GetCurrentPosition(), initialPosition, TEST_LOCATION );
9378 Stage::GetCurrent().Add(actor);
9380 // Build the animation
9381 float durationSeconds(10.0f);
9382 Animation animation = Animation::New(durationSeconds);
9383 Vector3 targetPosition(200.0f, 200.0f, 200.0f);
9384 BounceFunc func(0.0f, 0.0f, -100.0f);
9385 animation.Animate<Vector3>( Property(actor, Actor::POSITION), func, AlphaFunctions::Linear, durationSeconds );
9387 // Start the animation
9390 bool signalReceived(false);
9391 AnimationFinishCheck finishCheck(signalReceived);
9392 animation.FinishedSignal().Connect(&application, finishCheck);
9394 application.SendNotification();
9395 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
9397 // We didn't expect the animation to finish yet
9398 application.SendNotification();
9399 finishCheck.CheckSignalNotReceived();
9400 DALI_TEST_EQUALS( actor.GetCurrentPosition(), func(0.25f, initialPosition), TEST_LOCATION );
9402 application.SendNotification();
9403 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
9405 // We didn't expect the animation to finish yet
9406 application.SendNotification();
9407 finishCheck.CheckSignalNotReceived();
9408 DALI_TEST_EQUALS( actor.GetCurrentPosition(), func(0.5f, initialPosition), TEST_LOCATION );
9410 application.SendNotification();
9411 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
9413 // We didn't expect the animation to finish yet
9414 application.SendNotification();
9415 finishCheck.CheckSignalNotReceived();
9416 DALI_TEST_EQUALS( actor.GetCurrentPosition(), func(0.75f, initialPosition), TEST_LOCATION );
9418 application.SendNotification();
9419 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
9421 // We did expect the animation to finish
9422 application.SendNotification();
9423 finishCheck.CheckSignalReceived();
9424 DALI_TEST_EQUALS( actor.GetCurrentPosition(), initialPosition, TEST_LOCATION );
9428 int UtcDaliAnimationAnimateVector4(void)
9430 TestApplication application;
9432 Actor actor = Actor::New();
9433 Stage::GetCurrent().Add(actor);
9435 // Register a Vector4 property
9436 Vector4 startValue(10.0f, 10.0f, 10.0f, 10.0f);
9437 Property::Index index = actor.RegisterProperty( "test-property", startValue );
9438 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
9440 // Build the animation
9441 float durationSeconds(10.0f);
9442 Animation animation = Animation::New(durationSeconds);
9443 Vector4 targetPosition(200,400,0,-1000);
9444 AnimateVector4TestFunctor func( Vector4(1000,1000,1000,1000), targetPosition );
9445 animation.Animate<Vector4>( Property(actor, index), func );
9447 // Start the animation
9450 bool signalReceived(false);
9451 AnimationFinishCheck finishCheck(signalReceived);
9452 animation.FinishedSignal().Connect(&application, finishCheck);
9454 application.SendNotification();
9455 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
9457 // We didn't expect the animation to finish yet
9458 application.SendNotification();
9459 finishCheck.CheckSignalNotReceived();
9460 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), Vector4(800,850,750,500), TEST_LOCATION );
9462 application.SendNotification();
9463 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
9465 // We didn't expect the animation to finish yet
9466 application.SendNotification();
9467 finishCheck.CheckSignalNotReceived();
9468 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), Vector4(600,700,500,0), TEST_LOCATION );
9470 application.SendNotification();
9471 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
9473 // We didn't expect the animation to finish yet
9474 application.SendNotification();
9475 finishCheck.CheckSignalNotReceived();
9476 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), Vector4(400,550,250,-500), TEST_LOCATION );
9478 application.SendNotification();
9479 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
9481 // We did expect the animation to finish
9482 application.SendNotification();
9483 finishCheck.CheckSignalReceived();
9484 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetPosition, TEST_LOCATION );
9488 int UtcDaliAnimationAnimateQuaternion(void)
9490 TestApplication application;
9492 Actor actor = Actor::New();
9493 actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
9494 Stage::GetCurrent().Add(actor);
9495 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
9497 // Build the animation
9498 float durationSeconds(1.0f);
9499 Animation animation = Animation::New(durationSeconds);
9501 Degree sourceRotationDegrees(90.0f);
9502 Radian sourceRotationRadians(sourceRotationDegrees);
9503 Quaternion sourceRotation(sourceRotationRadians, Vector3::YAXIS);
9505 Degree targetRotationDegrees(150.0f);
9506 Radian targetRotationRadians(targetRotationDegrees);
9507 Quaternion targetRotation(targetRotationRadians, Vector3::YAXIS);
9509 AnimateQuaternionTestFunctor func( sourceRotation, targetRotation );
9510 animation.Animate<Quaternion>( Property(actor, Actor::ROTATION), func );
9512 // Start the animation
9515 bool signalReceived(false);
9516 AnimationFinishCheck finishCheck(signalReceived);
9517 animation.FinishedSignal().Connect(&application, finishCheck);
9519 application.SendNotification();
9520 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
9522 // We didn't expect the animation to finish yet
9523 application.SendNotification();
9524 finishCheck.CheckSignalNotReceived();
9525 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(Radian(Degree(105)), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
9527 application.SendNotification();
9528 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
9530 // We didn't expect the animation to finish yet
9531 application.SendNotification();
9532 finishCheck.CheckSignalNotReceived();
9533 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(Radian(Degree(120)), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
9535 application.SendNotification();
9536 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
9538 // We didn't expect the animation to finish yet
9539 application.SendNotification();
9540 finishCheck.CheckSignalNotReceived();
9541 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(Radian(Degree(135)), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
9543 application.SendNotification();
9544 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
9546 // We did expect the animation to finish
9547 application.SendNotification();
9548 finishCheck.CheckSignalReceived();
9549 DALI_TEST_EQUALS( actor.GetCurrentRotation(), targetRotation, ROTATION_EPSILON, TEST_LOCATION );
9553 int UtcDaliKeyFramesCreateDestroy(void)
9555 tet_infoline("Testing Dali::Animation::UtcDaliKeyFramesCreateDestroy()");
9557 KeyFrames* keyFrames = new KeyFrames;
9559 DALI_TEST_CHECK( true );
9563 int UtcDaliKeyFramesDownCast(void)
9565 TestApplication application;
9566 tet_infoline("Testing Dali::Animation::KeyFramesDownCast()");
9568 KeyFrames keyFrames = KeyFrames::New();
9569 BaseHandle object(keyFrames);
9571 KeyFrames keyFrames2 = KeyFrames::DownCast(object);
9572 DALI_TEST_CHECK(keyFrames2);
9574 KeyFrames keyFrames3 = DownCast< KeyFrames >(object);
9575 DALI_TEST_CHECK(keyFrames3);
9577 BaseHandle unInitializedObject;
9578 KeyFrames keyFrames4 = KeyFrames::DownCast(unInitializedObject);
9579 DALI_TEST_CHECK(!keyFrames4);
9581 KeyFrames keyFrames5 = DownCast< KeyFrames >(unInitializedObject);
9582 DALI_TEST_CHECK(!keyFrames5);
9586 int UtcDaliAnimationResizeByXY(void)
9588 TestApplication application;
9590 Actor actor = Actor::New();
9591 Stage::GetCurrent().Add(actor);
9592 DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
9594 // Build the animation
9595 float durationSeconds(1.0f);
9596 Animation animation = Animation::New(durationSeconds);
9597 Vector3 targetSize(100.0f, 100.0f, 100.0f);
9598 animation.Resize(actor, targetSize);
9600 Vector3 ninetyNinePercentProgress(targetSize * 0.99f);
9602 // Start the animation
9605 bool signalReceived(false);
9606 AnimationFinishCheck finishCheck(signalReceived);
9607 animation.FinishedSignal().Connect(&application, finishCheck);
9609 application.SendNotification();
9610 application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
9612 // We didn't expect the animation to finish yet
9613 application.SendNotification();
9614 finishCheck.CheckSignalNotReceived();
9615 DALI_TEST_EQUALS( actor.GetCurrentSize(), ninetyNinePercentProgress, TEST_LOCATION );
9617 application.SendNotification();
9618 application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
9620 // We did expect the animation to finish
9621 application.SendNotification();
9622 finishCheck.CheckSignalReceived();
9623 DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION );
9626 finishCheck.Reset();
9627 actor.SetSize(Vector3::ZERO);
9628 application.SendNotification();
9629 application.Render(0);
9630 DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
9632 // Repeat with a different (ease-in) alpha function
9633 animation = Animation::New(durationSeconds);
9634 animation.Resize(actor, targetSize.x, targetSize.y, AlphaFunctions::EaseIn);
9635 animation.FinishedSignal().Connect(&application, finishCheck);
9638 application.SendNotification();
9639 application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
9641 // We didn't expect the animation to finish yet
9642 application.SendNotification();
9643 finishCheck.CheckSignalNotReceived();
9645 // The size should have travelled less, than with a linear alpha function
9646 Vector3 current(actor.GetCurrentSize());
9647 DALI_TEST_CHECK( current.x > 0.0f );
9648 DALI_TEST_CHECK( current.y > 0.0f );
9649 DALI_TEST_CHECK( current.z > 0.0f );
9650 DALI_TEST_CHECK( current.x < ninetyNinePercentProgress.x );
9651 DALI_TEST_CHECK( current.y < ninetyNinePercentProgress.y );
9652 DALI_TEST_CHECK( current.z < ninetyNinePercentProgress.z );
9654 application.SendNotification();
9655 application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
9657 // We did expect the animation to finish
9658 application.SendNotification();
9659 finishCheck.CheckSignalReceived();
9660 DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION );
9663 finishCheck.Reset();
9664 actor.SetSize(Vector3::ZERO);
9665 application.SendNotification();
9666 application.Render(0);
9667 DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
9669 // Repeat with a delay
9671 animation = Animation::New(durationSeconds);
9672 animation.Resize(actor, targetSize.x, targetSize.y, AlphaFunctions::Linear, delay, durationSeconds - delay);
9673 animation.FinishedSignal().Connect(&application, finishCheck);
9676 application.SendNotification();
9677 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
9679 // We didn't expect the animation to finish yet
9680 application.SendNotification();
9681 finishCheck.CheckSignalNotReceived();
9682 DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
9684 application.SendNotification();
9685 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
9687 // We did expect the animation to finish
9688 application.SendNotification();
9689 finishCheck.CheckSignalReceived();
9690 DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION );
9695 int UtcDaliAnimationAnimateBetweenActorColorTimePeriod(void)
9697 TestApplication application;
9699 float startValue(1.0f);
9700 Actor actor = Actor::New();
9701 actor.SetColor(Vector4(startValue, startValue, startValue, startValue));
9702 Stage::GetCurrent().Add(actor);
9704 DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
9705 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
9706 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
9707 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
9708 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), startValue, TEST_LOCATION );
9710 // Build the animation
9711 float durationSeconds(1.0f);
9712 Animation animation = Animation::New(durationSeconds);
9714 KeyFrames keyFrames = KeyFrames::New();
9715 keyFrames.Add(0.0f, Vector4(0.1f, 0.2f, 0.3f, 0.4f));
9716 keyFrames.Add(0.5f, Vector4(0.9f, 0.8f, 0.7f, 0.6f));
9717 keyFrames.Add(1.0f, Vector4(1.0f, 1.0f, 1.0f, 1.0f));
9719 animation.AnimateBetween( Property(actor, Actor::COLOR), keyFrames, TimePeriod( 1.0f) );
9721 // Start the animation
9724 bool signalReceived(false);
9725 AnimationFinishCheck finishCheck(signalReceived);
9726 animation.FinishedSignal().Connect(&application, finishCheck);
9727 application.SendNotification();
9728 application.Render(0);
9729 application.SendNotification();
9730 finishCheck.CheckSignalNotReceived();
9731 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), 0.1f, 0.01f, TEST_LOCATION );
9732 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 0.2f, 0.01f, TEST_LOCATION );
9733 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), 0.3f, 0.01f, TEST_LOCATION );
9734 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.4f, 0.01f, TEST_LOCATION );
9736 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
9737 application.SendNotification();
9738 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), 0.5f, 0.01f, TEST_LOCATION );
9739 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 0.5f, 0.01f, TEST_LOCATION );
9740 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), 0.5f, 0.01f, TEST_LOCATION );
9741 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.5f, 0.01f, TEST_LOCATION );
9743 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
9744 application.SendNotification();
9745 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), 0.9f, 0.01f, TEST_LOCATION );
9746 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 0.8f, 0.01f, TEST_LOCATION );
9747 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), 0.7f, 0.01f, TEST_LOCATION );
9748 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.6f, 0.01f, TEST_LOCATION );
9750 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
9751 application.SendNotification();
9752 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), 0.95f, 0.01f, TEST_LOCATION );
9753 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 0.90f, 0.01f, TEST_LOCATION );
9754 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), 0.85f, 0.01f, TEST_LOCATION );
9755 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.80f, 0.01f, TEST_LOCATION );
9757 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
9758 application.SendNotification();
9759 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), 1.0f, 0.01f, TEST_LOCATION );
9760 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 1.0f, 0.01f, TEST_LOCATION );
9761 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), 1.0f, 0.01f, TEST_LOCATION );
9762 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 1.0f, 0.01f, TEST_LOCATION );
9764 // We did expect the animation to finish
9766 finishCheck.CheckSignalReceived();
9770 int UtcDaliAnimationAnimateBetweenActorColorFunction(void)
9772 TestApplication application;
9774 float startValue(1.0f);
9775 Actor actor = Actor::New();
9776 actor.SetColor(Vector4(startValue, startValue, startValue, startValue));
9777 Stage::GetCurrent().Add(actor);
9779 DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
9780 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
9781 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
9782 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
9783 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), startValue, TEST_LOCATION );
9785 // Build the animation
9786 float durationSeconds(1.0f);
9787 Animation animation = Animation::New(durationSeconds);
9789 KeyFrames keyFrames = KeyFrames::New();
9790 keyFrames.Add(0.0f, Vector4(0.1f, 0.2f, 0.3f, 0.4f));
9791 keyFrames.Add(0.5f, Vector4(0.9f, 0.8f, 0.7f, 0.6f));
9792 keyFrames.Add(1.0f, Vector4(1.0f, 1.0f, 1.0f, 1.0f));
9794 animation.AnimateBetween( Property(actor, Actor::COLOR), keyFrames, AlphaFunctions::Linear );
9796 // Start the animation
9799 bool signalReceived(false);
9800 AnimationFinishCheck finishCheck(signalReceived);
9801 animation.FinishedSignal().Connect(&application, finishCheck);
9802 application.SendNotification();
9803 application.Render(0);
9804 application.SendNotification();
9805 finishCheck.CheckSignalNotReceived();
9806 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), 0.1f, 0.01f, TEST_LOCATION );
9807 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 0.2f, 0.01f, TEST_LOCATION );
9808 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), 0.3f, 0.01f, TEST_LOCATION );
9809 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.4f, 0.01f, TEST_LOCATION );
9811 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
9812 application.SendNotification();
9813 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), 0.5f, 0.01f, TEST_LOCATION );
9814 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 0.5f, 0.01f, TEST_LOCATION );
9815 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), 0.5f, 0.01f, TEST_LOCATION );
9816 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.5f, 0.01f, TEST_LOCATION );
9818 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
9819 application.SendNotification();
9820 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), 0.9f, 0.01f, TEST_LOCATION );
9821 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 0.8f, 0.01f, TEST_LOCATION );
9822 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), 0.7f, 0.01f, TEST_LOCATION );
9823 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.6f, 0.01f, TEST_LOCATION );
9825 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
9826 application.SendNotification();
9827 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), 0.95f, 0.01f, TEST_LOCATION );
9828 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 0.90f, 0.01f, TEST_LOCATION );
9829 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), 0.85f, 0.01f, TEST_LOCATION );
9830 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.80f, 0.01f, TEST_LOCATION );
9832 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
9833 application.SendNotification();
9834 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), 1.0f, 0.01f, TEST_LOCATION );
9835 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 1.0f, 0.01f, TEST_LOCATION );
9836 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), 1.0f, 0.01f, TEST_LOCATION );
9837 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 1.0f, 0.01f, TEST_LOCATION );
9839 // We did expect the animation to finish
9841 finishCheck.CheckSignalReceived();
9845 int UtcDaliAnimationAnimateBetweenActorColorFunctionTimePeriod(void)
9847 TestApplication application;
9849 float startValue(1.0f);
9850 Actor actor = Actor::New();
9851 actor.SetColor(Vector4(startValue, startValue, startValue, startValue));
9852 Stage::GetCurrent().Add(actor);
9854 DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
9855 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
9856 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
9857 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
9858 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), startValue, TEST_LOCATION );
9860 // Build the animation
9861 float durationSeconds(1.0f);
9862 Animation animation = Animation::New(durationSeconds);
9864 KeyFrames keyFrames = KeyFrames::New();
9865 keyFrames.Add(0.0f, Vector4(0.1f, 0.2f, 0.3f, 0.4f));
9866 keyFrames.Add(0.5f, Vector4(0.9f, 0.8f, 0.7f, 0.6f));
9867 keyFrames.Add(1.0f, Vector4(1.0f, 1.0f, 1.0f, 1.0f));
9869 animation.AnimateBetween( Property(actor, Actor::COLOR), keyFrames, AlphaFunctions::Linear, TimePeriod( 1.0f) );
9871 // Start the animation
9874 bool signalReceived(false);
9875 AnimationFinishCheck finishCheck(signalReceived);
9876 animation.FinishedSignal().Connect(&application, finishCheck);
9877 application.SendNotification();
9878 application.Render(0);
9879 application.SendNotification();
9880 finishCheck.CheckSignalNotReceived();
9881 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), 0.1f, 0.01f, TEST_LOCATION );
9882 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 0.2f, 0.01f, TEST_LOCATION );
9883 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), 0.3f, 0.01f, TEST_LOCATION );
9884 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.4f, 0.01f, TEST_LOCATION );
9886 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
9887 application.SendNotification();
9888 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), 0.5f, 0.01f, TEST_LOCATION );
9889 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 0.5f, 0.01f, TEST_LOCATION );
9890 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), 0.5f, 0.01f, TEST_LOCATION );
9891 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.5f, 0.01f, TEST_LOCATION );
9893 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
9894 application.SendNotification();
9895 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), 0.9f, 0.01f, TEST_LOCATION );
9896 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 0.8f, 0.01f, TEST_LOCATION );
9897 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), 0.7f, 0.01f, TEST_LOCATION );
9898 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.6f, 0.01f, TEST_LOCATION );
9900 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
9901 application.SendNotification();
9902 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), 0.95f, 0.01f, TEST_LOCATION );
9903 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 0.90f, 0.01f, TEST_LOCATION );
9904 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), 0.85f, 0.01f, TEST_LOCATION );
9905 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.80f, 0.01f, TEST_LOCATION );
9907 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
9908 application.SendNotification();
9909 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), 1.0f, 0.01f, TEST_LOCATION );
9910 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 1.0f, 0.01f, TEST_LOCATION );
9911 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), 1.0f, 0.01f, TEST_LOCATION );
9912 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 1.0f, 0.01f, TEST_LOCATION );
9914 // We did expect the animation to finish
9916 finishCheck.CheckSignalReceived();
9920 int UtcDaliAnimationAnimateVector3Func(void)
9922 TestApplication application;
9924 Actor actor = Actor::New();
9925 Vector3 initialPosition(Vector3::ZERO);
9926 DALI_TEST_EQUALS( actor.GetCurrentPosition(), initialPosition, TEST_LOCATION );
9927 Stage::GetCurrent().Add(actor);
9929 // Build the animation
9930 float durationSeconds(10.0f);
9931 Animation animation = Animation::New(durationSeconds);
9932 Vector3 targetPosition(200.0f, 200.0f, 200.0f);
9933 BounceFunc func(0.0f, 0.0f, -100.0f);
9934 animation.Animate<Vector3>( Property(actor, Actor::POSITION), func, AlphaFunctions::Linear );
9936 // Start the animation
9939 bool signalReceived(false);
9940 AnimationFinishCheck finishCheck(signalReceived);
9941 animation.FinishedSignal().Connect(&application, finishCheck);
9943 application.SendNotification();
9944 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
9946 // We didn't expect the animation to finish yet
9947 application.SendNotification();
9948 finishCheck.CheckSignalNotReceived();
9949 DALI_TEST_EQUALS( actor.GetCurrentPosition(), func(0.25f, initialPosition), TEST_LOCATION );
9951 application.SendNotification();
9952 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
9954 // We didn't expect the animation to finish yet
9955 application.SendNotification();
9956 finishCheck.CheckSignalNotReceived();
9957 DALI_TEST_EQUALS( actor.GetCurrentPosition(), func(0.5f, initialPosition), TEST_LOCATION );
9959 application.SendNotification();
9960 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
9962 // We didn't expect the animation to finish yet
9963 application.SendNotification();
9964 finishCheck.CheckSignalNotReceived();
9965 DALI_TEST_EQUALS( actor.GetCurrentPosition(), func(0.75f, initialPosition), TEST_LOCATION );
9967 application.SendNotification();
9968 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
9970 // We did expect the animation to finish
9971 application.SendNotification();
9972 finishCheck.CheckSignalReceived();
9973 DALI_TEST_EQUALS( actor.GetCurrentPosition(), initialPosition, TEST_LOCATION );
9977 int UtcDaliAnimationCreateDestroy(void)
9979 TestApplication application;
9980 Animation* animation = new Animation;
9981 DALI_TEST_CHECK( animation );
9986 struct UpdateManagerTestConstraint
9988 UpdateManagerTestConstraint(TestApplication& application)
9989 : mApplication(application)
9993 Vector3 operator()(const Vector3& current)
9995 mApplication.SendNotification(); // Process events
9999 TestApplication& mApplication;
10002 int UtcDaliAnimationUpdateManager(void)
10004 TestApplication application;
10006 Actor actor = Actor::New();
10007 Stage::GetCurrent().Add( actor );
10009 // Build the animation
10010 Animation animation = Animation::New( 0.0f );
10012 bool signalReceived = false;
10013 AnimationFinishCheck finishCheck( signalReceived );
10014 animation.FinishedSignal().Connect( &application, finishCheck );
10016 Vector3 startValue(1.0f, 1.0f, 1.0f);
10017 Property::Index index = actor.RegisterProperty( "test-property", startValue );
10018 Constraint constraint = Constraint::New<Vector3>( index, UpdateManagerTestConstraint( application ) );
10019 actor.ApplyConstraint( constraint );
10021 // Apply animation to actor
10022 BounceFunc func(0.0f, 0.0f, -100.0f);
10023 animation.Animate<Vector3>( Property(actor, Actor::POSITION), func, AlphaFunctions::Linear );
10027 application.SendNotification();
10028 application.UpdateOnly( 16 );
10030 finishCheck.CheckSignalNotReceived();
10032 application.SendNotification(); // Process events
10034 finishCheck.CheckSignalReceived();
10039 int UtcDaliAnimationSignalOrder(void)
10041 TestApplication application;
10043 Actor actor = Actor::New();
10044 Stage::GetCurrent().Add( actor );
10046 // Build the animations
10047 Animation animation1 = Animation::New( 0.0f ); // finishes first frame
10048 Animation animation2 = Animation::New( 0.02f ); // finishes in 20 ms
10050 bool signal1Received = false;
10051 animation1.FinishedSignal().Connect( &application, AnimationFinishCheck( signal1Received ) );
10053 bool signal2Received = false;
10054 animation2.FinishedSignal().Connect( &application, AnimationFinishCheck( signal2Received ) );
10056 // Apply animations to actor
10057 animation1.AnimateTo( Property(actor, Actor::POSITION), Vector3( 3.0f, 2.0f, 1.0f ), AlphaFunctions::Linear );
10059 animation2.AnimateTo( Property(actor, Actor::SIZE ), Vector3( 10.0f, 20.0f, 30.0f ), AlphaFunctions::Linear );
10062 DALI_TEST_EQUALS( signal1Received, false, TEST_LOCATION );
10063 DALI_TEST_EQUALS( signal2Received, false, TEST_LOCATION );
10065 application.SendNotification();
10066 application.UpdateOnly( 10 ); // 10ms progress
10068 // no notifications yet
10069 DALI_TEST_EQUALS( signal1Received, false, TEST_LOCATION );
10070 DALI_TEST_EQUALS( signal2Received, false, TEST_LOCATION );
10072 application.SendNotification();
10075 DALI_TEST_EQUALS( signal1Received, true, TEST_LOCATION );
10076 DALI_TEST_EQUALS( signal2Received, false, TEST_LOCATION );
10077 signal1Received = false;
10079 // 1st animation is complete now, do another update with no ProcessEvents in between
10080 application.UpdateOnly( 20 ); // 20ms progress
10083 application.SendNotification();
10085 // 2nd should complete now
10086 DALI_TEST_EQUALS( signal1Received, false, TEST_LOCATION );
10087 DALI_TEST_EQUALS( signal2Received, true, TEST_LOCATION );
10092 int UtcDaliAnimationExtendDuration(void)
10094 TestApplication application;
10096 Actor actor = Actor::New();
10098 // Register a float property
10099 float startValue(10.0f);
10100 Property::Index index = actor.RegisterProperty( "test-property", startValue );
10101 Stage::GetCurrent().Add(actor);
10102 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
10104 // Build the animation
10105 float initialDurationSeconds(1.0f);
10106 float animatorDelay = 5.0f;
10107 float animatorDurationSeconds(5.0f);
10108 float extendedDurationSeconds(animatorDelay+animatorDurationSeconds);
10109 Animation animation = Animation::New(initialDurationSeconds);
10110 float targetValue(30.0f);
10111 float relativeValue(targetValue - startValue);
10113 animation.AnimateTo(Property(actor, index),
10115 TimePeriod(animatorDelay, animatorDurationSeconds));
10117 // The duration should have been extended
10118 DALI_TEST_EQUALS( animation.GetDuration(), extendedDurationSeconds, TEST_LOCATION );
10120 // Start the animation
10123 bool signalReceived(false);
10124 AnimationFinishCheck finishCheck(signalReceived);
10125 animation.FinishedSignal().Connect(&application, finishCheck);
10127 application.SendNotification();
10128 application.Render(static_cast<unsigned int>(extendedDurationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
10130 // We didn't expect the animation to finish yet
10131 application.SendNotification();
10132 finishCheck.CheckSignalNotReceived();
10133 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
10135 application.SendNotification();
10136 application.Render(static_cast<unsigned int>(extendedDurationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
10138 // We didn't expect the animation to finish yet
10139 application.SendNotification();
10140 finishCheck.CheckSignalNotReceived();
10141 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
10143 application.SendNotification();
10144 application.Render(static_cast<unsigned int>(extendedDurationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
10146 // We did expect the animation to finish
10147 application.SendNotification();
10148 finishCheck.CheckSignalReceived();
10149 DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );