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 UtcDaliAnimationGetDestroyAction(void)
535 TestApplication application;
536 Animation animation = Animation::New(1.0f);
537 DALI_TEST_CHECK(animation.GetDestroyAction() == Animation::Bake); // default!
539 animation.SetDestroyAction(Animation::Discard);
540 DALI_TEST_CHECK(animation.GetDestroyAction() == Animation::Discard);
542 animation.SetDestroyAction(Animation::BakeFinal);
543 DALI_TEST_CHECK(animation.GetDestroyAction() == Animation::BakeFinal);
548 int UtcDaliAnimationSetDefaultAlphaFunction(void)
550 TestApplication application;
552 Animation animation = Animation::New(1.0f);
553 AlphaFunction func = animation.GetDefaultAlphaFunction();
554 DALI_TEST_EQUALS(func(0.1f), AlphaFunctions::Linear(0.1f), TEST_LOCATION);
556 animation.SetDefaultAlphaFunction(AlphaFunctions::EaseIn);
557 AlphaFunction func2 = animation.GetDefaultAlphaFunction();
558 DALI_TEST_CHECK(func2(0.1f) < AlphaFunctions::Linear(0.1f)); // less progress when easing-in
562 int UtcDaliAnimationGetDefaultAlphaFunction(void)
564 TestApplication application;
566 Animation animation = Animation::New(1.0f);
567 AlphaFunction func = animation.GetDefaultAlphaFunction();
569 // Test that the default is linear
570 DALI_TEST_EQUALS(func(0.1f), AlphaFunctions::Linear(0.1f), TEST_LOCATION);
574 int UtcDaliAnimationPlay(void)
576 TestApplication application;
578 Actor actor = Actor::New();
579 Stage::GetCurrent().Add(actor);
581 // Build the animation
582 float durationSeconds(1.0f);
583 Animation animation = Animation::New(durationSeconds);
584 Vector3 targetPosition(100.0f, 100.0f, 100.0f);
585 animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear);
587 // Start the animation
590 bool signalReceived(false);
591 AnimationFinishCheck finishCheck(signalReceived);
592 animation.FinishedSignal().Connect(&application, finishCheck);
594 application.SendNotification();
595 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 20% progress */);
597 // We didn't expect the animation to finish yet
598 application.SendNotification();
599 finishCheck.CheckSignalNotReceived();
600 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION );
602 animation.Play(); // Test that calling play has no effect, when animation is already playing
603 application.SendNotification();
604 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 40% progress */);
606 // We didn't expect the animation to finish yet
607 application.SendNotification();
608 finishCheck.CheckSignalNotReceived();
609 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.4f), TEST_LOCATION );
611 animation.Play(); // Test that calling play has no effect, when animation is already playing
612 application.SendNotification();
613 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 60% progress */);
615 // We didn't expect the animation to finish yet
616 application.SendNotification();
617 finishCheck.CheckSignalNotReceived();
618 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.6f), TEST_LOCATION );
620 animation.Play(); // Test that calling play has no effect, when animation is already playing
621 application.SendNotification();
622 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 80% progress */);
624 // We didn't expect the animation to finish yet
625 application.SendNotification();
626 finishCheck.CheckSignalNotReceived();
627 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.8f), TEST_LOCATION );
629 animation.Play(); // Test that calling play has no effect, when animation is already playing
630 application.SendNotification();
631 application.Render(static_cast<unsigned int>(durationSeconds*200.0f) + 1u/*just beyond the animation duration*/);
633 // We did expect the animation to finish
634 application.SendNotification();
635 finishCheck.CheckSignalReceived();
636 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
638 // Check that nothing has changed after a couple of buffer swaps
639 application.Render(0);
640 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
641 application.Render(0);
642 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
646 int UtcDaliAnimationSetSpeedFactor(void)
648 TestApplication application;
650 Actor actor = Actor::New();
651 Stage::GetCurrent().Add(actor);
653 // Build the animation
654 float durationSeconds(1.0f);
655 Animation animation = Animation::New(durationSeconds);
657 const Vector3 initialPosition(0.0f, 0.0f, 0.0f);
658 const Vector3 targetPosition(100.0f, 100.0f, 100.0f);
660 KeyFrames keyframes = KeyFrames::New();
661 keyframes.Add( 0.0f, initialPosition);
662 keyframes.Add( 1.0f, targetPosition );
663 animation.AnimateBetween( Property(actor, Actor::POSITION), keyframes, AlphaFunctions::Linear);
666 animation.SetSpeedFactor(2.0f);
668 // Start the animation
671 bool signalReceived(false);
672 AnimationFinishCheck finishCheck(signalReceived);
673 animation.FinishedSignal().Connect(&application, finishCheck);
675 application.SendNotification();
676 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 40% progress */);
678 // We didn't expect the animation to finish yet
679 application.SendNotification();
680 finishCheck.CheckSignalNotReceived();
681 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.4f), TEST_LOCATION );
683 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 80% progress */);
685 // We didn't expect the animation to finish yet
686 application.SendNotification();
687 finishCheck.CheckSignalNotReceived();
688 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.8f), TEST_LOCATION );
690 application.Render(static_cast<unsigned int>(durationSeconds*100.0f) + 1u/*just beyond half the duration*/);
692 // We did expect the animation to finish
693 application.SendNotification();
694 finishCheck.CheckSignalReceived();
695 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
697 // Check that nothing has changed after a couple of buffer swaps
698 application.Render(0);
699 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
700 application.Render(0);
701 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
705 //Test -1 speed factor. Animation will play in reverse at normal speed
706 animation.SetSpeedFactor( -1.0f );
708 // Start the animation
711 application.SendNotification();
712 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 80% progress */);
714 // We didn't expect the animation to finish yet
715 application.SendNotification();
716 finishCheck.CheckSignalNotReceived();
717 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.8f), TEST_LOCATION );
719 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 60% progress */);
721 // We didn't expect the animation to finish yet
722 application.SendNotification();
723 finishCheck.CheckSignalNotReceived();
724 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.6f), TEST_LOCATION );
726 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 40% progress */);
728 // We didn't expect the animation to finish yet
729 application.SendNotification();
730 finishCheck.CheckSignalNotReceived();
731 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.4f), TEST_LOCATION );
733 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 20% progress */);
735 // We didn't expect the animation to finish yet
736 application.SendNotification();
737 finishCheck.CheckSignalNotReceived();
738 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION );
740 application.Render(static_cast<unsigned int>(durationSeconds*200.0f) + 1u/*just beyond the animation duration*/);
742 // We did expect the animation to finish
743 application.SendNotification();
744 finishCheck.CheckSignalReceived();
745 DALI_TEST_EQUALS( actor.GetCurrentPosition(), initialPosition, TEST_LOCATION );
747 // Check that nothing has changed after a couple of buffer swaps
748 application.Render(0);
749 DALI_TEST_EQUALS( initialPosition, actor.GetCurrentPosition(), TEST_LOCATION );
750 application.Render(0);
751 DALI_TEST_EQUALS( initialPosition, actor.GetCurrentPosition(), TEST_LOCATION );
754 //Test change speed factor on the fly
757 //Set speed to be half of normal speed
758 animation.SetSpeedFactor( 0.5f );
760 // Start the animation
763 application.SendNotification();
764 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 10% progress */);
766 // We didn't expect the animation to finish yet
767 application.SendNotification();
768 finishCheck.CheckSignalNotReceived();
769 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.1f), TEST_LOCATION );
771 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 20% progress */);
773 // We didn't expect the animation to finish yet
774 application.SendNotification();
775 finishCheck.CheckSignalNotReceived();
776 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION );
778 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 30% progress */);
780 // We didn't expect the animation to finish yet
781 application.SendNotification();
782 finishCheck.CheckSignalNotReceived();
783 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.3f), TEST_LOCATION );
785 //Change speed factor while animation still playing.
786 animation.SetSpeedFactor(-1.0f);
787 application.SendNotification();
788 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 10% 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.1f), TEST_LOCATION );
795 application.Render(static_cast<unsigned int>(durationSeconds*100.0f) + 1u/*just beyond the animation duration*/);
797 // We did expect the animation to finish
798 application.SendNotification();
799 finishCheck.CheckSignalReceived();
800 DALI_TEST_EQUALS( actor.GetCurrentPosition(), initialPosition, TEST_LOCATION );
802 // Check that nothing has changed after a couple of buffer swaps
803 application.Render(0);
804 DALI_TEST_EQUALS( initialPosition, actor.GetCurrentPosition(), TEST_LOCATION );
805 application.Render(0);
806 DALI_TEST_EQUALS( initialPosition, actor.GetCurrentPosition(), TEST_LOCATION );
810 int UtcDaliAnimationGetSpeedFactor(void)
812 TestApplication application;
814 Animation animation = Animation::New(1.0f);
815 animation.SetSpeedFactor(0.5f);
816 DALI_TEST_EQUALS(animation.GetSpeedFactor(), 0.5f, TEST_LOCATION);
818 animation.SetSpeedFactor(-2.5f);
819 DALI_TEST_EQUALS(animation.GetSpeedFactor(), -2.5f, TEST_LOCATION);
823 int UtcDaliAnimationPlayOffStage(void)
825 // Test that an animation can be played, when the actor is off-stage.
826 // When the actor is added to the stage, it should appear at the current position
827 // i.e. where it would have been anyway, if on-stage from the beginning.
829 TestApplication application;
831 Actor actor = Actor::New();
832 Vector3 basePosition(Vector3::ZERO);
833 DALI_TEST_EQUALS( actor.GetCurrentPosition(), basePosition, TEST_LOCATION );
834 // Not added to the stage!
836 // Build the animation
837 float durationSeconds(1.0f);
838 Animation animation = Animation::New(durationSeconds);
839 Vector3 targetPosition(100.0f, 100.0f, 100.0f);
840 animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear);
842 // Start the animation
845 bool signalReceived(false);
846 AnimationFinishCheck finishCheck(signalReceived);
847 animation.FinishedSignal().Connect(&application, finishCheck);
849 application.SendNotification();
850 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 20% progress */);
852 // We didn't expect the animation to finish yet
853 application.SendNotification();
854 finishCheck.CheckSignalNotReceived();
855 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO/*off-stage*/, TEST_LOCATION );
858 Stage::GetCurrent().Add(actor);
860 application.SendNotification();
861 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 40% progress */);
863 // We didn't expect the animation to finish yet
864 application.SendNotification();
865 finishCheck.CheckSignalNotReceived();
866 Vector3 expectedPosition(basePosition + (targetPosition - basePosition)*0.4f);
867 DALI_TEST_EQUALS( actor.GetCurrentPosition(), expectedPosition/*on-stage*/, TEST_LOCATION );
869 // Remove from the stage
870 Stage::GetCurrent().Remove(actor);
872 application.SendNotification();
873 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 60% progress */);
875 // We didn't expect the animation to finish yet
876 application.SendNotification();
877 finishCheck.CheckSignalNotReceived();
878 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO/*back to start position*/, TEST_LOCATION );
881 Stage::GetCurrent().Add(actor);
883 application.SendNotification();
884 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 80% progress */);
886 // We didn't expect the animation to finish yet
887 application.SendNotification();
888 finishCheck.CheckSignalNotReceived();
889 expectedPosition = Vector3(basePosition + (targetPosition - basePosition)*0.8f);
890 DALI_TEST_EQUALS( actor.GetCurrentPosition(), expectedPosition, TEST_LOCATION );
892 application.SendNotification();
893 application.Render(static_cast<unsigned int>(durationSeconds*200.0f) + 1u/*just beyond the animation duration*/);
895 // We did expect the animation to finish
896 application.SendNotification();
897 finishCheck.CheckSignalReceived();
898 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
900 // Check that nothing has changed after a couple of buffer swaps
901 application.Render(0);
902 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
903 application.Render(0);
904 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
908 int UtcDaliAnimationPlayDiscardHandle(void)
910 TestApplication application;
912 Actor actor = Actor::New();
913 Stage::GetCurrent().Add(actor);
915 // Build the animation
916 float durationSeconds(1.0f);
917 Animation animation = Animation::New(durationSeconds);
918 Vector3 targetPosition(100.0f, 100.0f, 100.0f);
919 animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear);
921 bool signalReceived(false);
922 AnimationFinishCheck finishCheck(signalReceived);
923 animation.FinishedSignal().Connect(&application, finishCheck);
925 // Start the animation
928 // This is a test of the "Fire and Forget" behaviour
929 // Discard the animation handle!
931 DALI_TEST_CHECK( !animation );
933 application.SendNotification();
934 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 20% progress */);
936 // We didn't expect the animation to finish yet
937 application.SendNotification();
938 finishCheck.CheckSignalNotReceived();
939 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION );
941 application.SendNotification();
942 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 40% progress */);
944 // We didn't expect the animation to finish yet
945 application.SendNotification();
946 finishCheck.CheckSignalNotReceived();
947 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.4f), TEST_LOCATION );
949 application.SendNotification();
950 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 60% progress */);
952 // We didn't expect the animation to finish yet
953 application.SendNotification();
954 finishCheck.CheckSignalNotReceived();
955 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.6f), TEST_LOCATION );
957 application.SendNotification();
958 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 80% progress */);
960 // We didn't expect the animation to finish yet
961 application.SendNotification();
962 finishCheck.CheckSignalNotReceived();
963 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.8f), TEST_LOCATION );
965 application.SendNotification();
966 application.Render(static_cast<unsigned int>(durationSeconds*200.0f) + 1u/*just beyond the animation duration*/);
968 // We did expect the animation to finish
969 application.SendNotification();
970 finishCheck.CheckSignalReceived();
971 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
973 // Check that nothing has changed after a couple of buffer swaps
974 application.Render(0);
975 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
976 application.Render(0);
977 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
981 int UtcDaliAnimationPlayStopDiscardHandle(void)
983 TestApplication application;
985 Actor actor = Actor::New();
986 Stage::GetCurrent().Add(actor);
988 // Build the animation
989 float durationSeconds(1.0f);
990 Animation animation = Animation::New(durationSeconds);
991 Vector3 targetPosition(100.0f, 100.0f, 100.0f);
992 animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear);
994 // Start the animation
997 bool signalReceived(false);
998 AnimationFinishCheck finishCheck(signalReceived);
999 animation.FinishedSignal().Connect(&application, finishCheck);
1001 application.SendNotification();
1002 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 20% progress */);
1004 // We didn't expect the animation to finish yet
1005 application.SendNotification();
1006 finishCheck.CheckSignalNotReceived();
1007 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION );
1009 // This is a test of the "Fire and Forget" behaviour
1010 // Stop the animation, and Discard the animation handle!
1013 DALI_TEST_CHECK( !animation );
1015 application.SendNotification();
1016 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 40% progress */);
1018 // We expect the animation to finish at 20% progress
1019 application.SendNotification();
1020 finishCheck.CheckSignalReceived();
1021 finishCheck.Reset();
1022 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION );
1024 application.SendNotification();
1025 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 60% progress */);
1027 // Check that nothing has changed
1028 application.SendNotification();
1029 finishCheck.CheckSignalNotReceived();
1030 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION );
1032 application.SendNotification();
1033 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 80% progress */);
1035 // Check that nothing has changed
1036 application.SendNotification();
1037 finishCheck.CheckSignalNotReceived();
1038 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION );
1040 application.SendNotification();
1041 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 100% progress */);
1043 // Check that nothing has changed
1044 application.SendNotification();
1045 finishCheck.CheckSignalNotReceived();
1046 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION );
1050 int UtcDaliAnimationPlayFrom(void)
1052 TestApplication application;
1054 Actor actor = Actor::New();
1055 Stage::GetCurrent().Add(actor);
1057 // Build the animation
1058 float durationSeconds(1.0f);
1059 Animation animation = Animation::New(durationSeconds);
1060 Vector3 targetPosition(100.0f, 100.0f, 100.0f);
1061 animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear);
1063 //PlayFrom with an argument outside the range [0..1] will be ignored
1064 animation.PlayFrom(-1.0f);
1065 application.SendNotification();
1066 DALI_TEST_EQUALS(0.0f, animation.GetCurrentProgress(), TEST_LOCATION );
1068 animation.PlayFrom(100.0f);
1069 application.SendNotification();
1070 DALI_TEST_EQUALS(0.0f, animation.GetCurrentProgress(), TEST_LOCATION );
1072 // Start the animation from 40% progress
1073 animation.PlayFrom( 0.4f );
1075 bool signalReceived(false);
1076 AnimationFinishCheck finishCheck(signalReceived);
1077 animation.FinishedSignal().Connect(&application, finishCheck);
1079 application.SendNotification();
1080 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 60% progress */);
1082 // We didn't expect the animation to finish yet
1083 application.SendNotification();
1084 finishCheck.CheckSignalNotReceived();
1085 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.6f), TEST_LOCATION );
1087 animation.Play(); // Test that calling play has no effect, when animation is already playing
1088 application.SendNotification();
1089 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 80% progress */);
1091 // We didn't expect the animation to finish yet
1092 application.SendNotification();
1093 finishCheck.CheckSignalNotReceived();
1094 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.8f), TEST_LOCATION );
1096 application.Render(static_cast<unsigned int>(durationSeconds*200.0f) + 1u/*just beyond the animation duration*/);
1097 // We did expect the animation to finish
1098 application.SendNotification();
1099 finishCheck.CheckSignalReceived();
1100 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
1102 // Check that nothing has changed after a couple of buffer swaps
1103 application.Render(0);
1104 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
1105 application.Render(0);
1106 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
1110 int UtcDaliAnimationSetCurrentProgress(void)
1112 TestApplication application;
1114 Actor actor = Actor::New();
1115 Stage::GetCurrent().Add(actor);
1117 // Build the animation
1118 Animation animation = Animation::New(0.0f);
1121 //Test GetCurrentProgress return 0.0 as the duration is 0.0
1122 DALI_TEST_EQUALS( 0.0f, animation.GetCurrentProgress(), TEST_LOCATION );
1124 animation.SetCurrentProgress( 0.5f );
1125 application.SendNotification();
1126 application.Render(static_cast<unsigned int>(100.0f));
1128 //Progress should still be 0.0
1129 DALI_TEST_EQUALS( 0.0f, animation.GetCurrentProgress(), TEST_LOCATION );
1132 float durationSeconds(1.0f);
1133 animation.SetDuration(durationSeconds);
1134 application.SendNotification();
1136 bool signalReceived(false);
1137 AnimationFinishCheck finishCheck(signalReceived);
1138 animation.FinishedSignal().Connect(&application, finishCheck);
1139 application.SendNotification();
1141 Vector3 targetPosition(100.0f, 100.0f, 100.0f);
1142 animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear);
1144 //Trying to set the current cursor outside the range [0..1] is ignored
1145 animation.SetCurrentProgress( -1.0f);
1146 application.SendNotification();
1147 DALI_TEST_EQUALS( 0.0f, animation.GetCurrentProgress(), TEST_LOCATION );
1149 animation.SetCurrentProgress( 100.0f);
1150 application.SendNotification();
1151 DALI_TEST_EQUALS( 0.0f, animation.GetCurrentProgress(), TEST_LOCATION );
1153 // Start the animation from 40% progress
1154 animation.SetCurrentProgress( 0.4f );
1157 application.SendNotification();
1158 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 60% progress */);
1160 // We didn't expect the animation to finish yet
1161 application.SendNotification();
1162 finishCheck.CheckSignalNotReceived();
1163 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.6f), TEST_LOCATION );
1164 DALI_TEST_EQUALS( 0.6f, animation.GetCurrentProgress(), TEST_LOCATION );
1166 animation.Play(); // Test that calling play has no effect, when animation is already playing
1167 application.SendNotification();
1169 //Set the progress to 70%
1170 animation.SetCurrentProgress( 0.7f );
1171 application.SendNotification();
1172 application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 80% progress */);
1173 DALI_TEST_EQUALS( 0.8f, animation.GetCurrentProgress(), TEST_LOCATION );
1176 application.SendNotification();
1177 finishCheck.CheckSignalNotReceived();
1178 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.8f), TEST_LOCATION );
1179 DALI_TEST_EQUALS( 0.8f, animation.GetCurrentProgress(), TEST_LOCATION );
1183 application.Render(static_cast<unsigned int>(durationSeconds*200.0f) + 1u/*just beyond the animation duration*/);
1184 // We did expect the animation to finish
1185 application.SendNotification();
1186 finishCheck.CheckSignalReceived();
1187 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
1189 // Check that nothing has changed after a couple of buffer swaps
1190 application.Render(0);
1191 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
1192 application.Render(0);
1193 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
1198 int UtcDaliAnimationPause(void)
1200 TestApplication application;
1202 Actor actor = Actor::New();
1203 Stage::GetCurrent().Add(actor);
1205 // Build the animation
1206 float durationSeconds(1.0f);
1207 Animation animation = Animation::New(durationSeconds);
1208 Vector3 targetPosition(100.0f, 100.0f, 100.0f);
1209 animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear);
1211 Vector3 fiftyPercentProgress(targetPosition * 0.5f);
1213 // Start the animation
1216 bool signalReceived(false);
1217 AnimationFinishCheck finishCheck(signalReceived);
1218 animation.FinishedSignal().Connect(&application, finishCheck);
1220 application.SendNotification();
1221 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
1223 // We didn't expect the animation to finish yet
1224 application.SendNotification();
1225 finishCheck.CheckSignalNotReceived();
1226 DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress, TEST_LOCATION );
1228 // Pause the animation
1230 application.SendNotification();
1233 for (int i=0; i<5; ++i)
1235 application.Render(static_cast<unsigned int>(durationSeconds*500.0f));
1237 // We didn't expect the animation to finish yet
1238 application.SendNotification();
1239 finishCheck.CheckSignalNotReceived();
1240 DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress/* Still 50% progress when paused */, TEST_LOCATION );
1245 application.SendNotification();
1246 application.Render(static_cast<unsigned int>(durationSeconds*490.0f)/*slightly less than the animation duration*/);
1248 // We didn't expect the animation to finish yet
1249 application.SendNotification();
1250 finishCheck.CheckSignalNotReceived();
1252 application.SendNotification();
1253 application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
1255 // We did expect the animation to finish
1256 application.SendNotification();
1257 finishCheck.CheckSignalReceived();
1258 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
1260 // Check that nothing has changed after a couple of buffer swaps
1261 application.Render(0);
1262 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
1263 application.Render(0);
1264 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
1268 int UtcDaliAnimationStop(void)
1270 TestApplication application;
1272 Actor actor = Actor::New();
1273 Stage::GetCurrent().Add(actor);
1275 // Build the animation
1276 float durationSeconds(1.0f);
1277 Animation animation = Animation::New(durationSeconds);
1278 Vector3 targetPosition(100.0f, 100.0f, 100.0f);
1279 animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear);
1281 Vector3 fiftyPercentProgress(targetPosition * 0.5f);
1283 // Start the animation
1286 bool signalReceived(false);
1287 AnimationFinishCheck finishCheck(signalReceived);
1288 animation.FinishedSignal().Connect(&application, finishCheck);
1290 application.SendNotification();
1291 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
1293 // We didn't expect the animation to finish yet
1294 application.SendNotification();
1295 finishCheck.CheckSignalNotReceived();
1296 DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress, TEST_LOCATION );
1298 // Stop the animation
1300 application.SendNotification();
1303 for (int i=0; i<5; ++i)
1305 application.Render(static_cast<unsigned int>(durationSeconds*500.0f));
1307 // We did expect the animation to finish
1308 application.SendNotification();
1309 finishCheck.CheckSignalReceived();
1310 DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress/* Still 50% progress when stopped */, TEST_LOCATION );
1315 int UtcDaliAnimationStopSetPosition(void)
1317 // Test that Animation::Stop & Actor::SetPosition can be used in conjunction
1318 // i.e. to check that the animation does not interfere with the position set.
1320 TestApplication application;
1322 Actor actor = Actor::New();
1323 Stage::GetCurrent().Add(actor);
1325 // Build the animation
1326 float durationSeconds(1.0f);
1327 Animation animation = Animation::New(durationSeconds);
1328 Vector3 targetPosition(100.0f, 100.0f, 100.0f);
1329 animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear);
1331 Vector3 fiftyPercentProgress(targetPosition * 0.5f);
1333 // Start the animation
1336 bool signalReceived(false);
1337 AnimationFinishCheck finishCheck(signalReceived);
1338 animation.FinishedSignal().Connect(&application, finishCheck);
1340 application.SendNotification();
1341 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
1343 // We didn't expect the animation to finish yet
1344 application.SendNotification();
1345 finishCheck.CheckSignalNotReceived();
1346 DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress, TEST_LOCATION );
1348 // Stop the animation
1350 Vector3 positionSet(2.0f, 3.0f, 4.0f);
1351 actor.SetPosition(positionSet);
1352 application.SendNotification();
1355 for (int i=0; i<5; ++i)
1357 application.Render(static_cast<unsigned int>(durationSeconds*500.0f));
1359 // We did expect the animation to finish
1360 application.SendNotification();
1361 finishCheck.CheckSignalReceived();
1362 DALI_TEST_EQUALS( actor.GetCurrentPosition(), positionSet/*Animation should not interfere with this*/, TEST_LOCATION );
1367 int UtcDaliAnimationClear(void)
1369 TestApplication application;
1371 Actor actor = Actor::New();
1372 Stage::GetCurrent().Add(actor);
1374 // Build the animation
1375 float durationSeconds(1.0f);
1376 Animation animation = Animation::New(durationSeconds);
1377 Vector3 targetPosition(100.0f, 100.0f, 100.0f);
1378 animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear);
1380 Vector3 fiftyPercentProgress(targetPosition * 0.5f);
1382 // Start the animation
1385 bool signalReceived(false);
1386 AnimationFinishCheck finishCheck(signalReceived);
1387 animation.FinishedSignal().Connect(&application, finishCheck);
1389 application.SendNotification();
1390 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
1392 // We didn't expect the animation to finish yet
1393 application.SendNotification();
1394 finishCheck.CheckSignalNotReceived();
1395 DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress, TEST_LOCATION );
1397 // Clear the animation
1399 application.SendNotification();
1401 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
1403 // We don't expect the animation to finish now
1404 application.SendNotification();
1405 finishCheck.CheckSignalNotReceived();
1406 DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress/* Still 50% progress since the animator was destroyed */, TEST_LOCATION );
1408 // Restart as a scale animation; this should not move the actor's position
1409 finishCheck.Reset();
1410 actor.SetPosition(Vector3::ZERO);
1411 Vector3 targetScale(3.0f, 3.0f, 3.0f);
1412 animation.ScaleTo(actor, targetScale, AlphaFunctions::Linear);
1415 application.SendNotification();
1416 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
1418 // We didn't expect the animation to finish yet
1419 application.SendNotification();
1420 finishCheck.CheckSignalNotReceived();
1421 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO/*Check move-animator was destroyed*/, TEST_LOCATION );
1422 DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3(2.0f, 2.0f, 2.0f), TEST_LOCATION );
1424 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
1426 // We did expect the animation to finish
1427 application.SendNotification();
1428 finishCheck.CheckSignalReceived();
1429 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO/*Check move-animator was destroyed*/, TEST_LOCATION );
1430 DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
1434 int UtcDaliAnimationSignalFinish(void)
1436 TestApplication application;
1438 // Start the empty animation
1439 float durationSeconds(1.0f);
1440 Animation animation = Animation::New(durationSeconds);
1443 bool signalReceived(false);
1444 AnimationFinishCheck finishCheck(signalReceived);
1445 animation.FinishedSignal().Connect(&application, finishCheck);
1447 application.SendNotification();
1448 application.Render(static_cast<unsigned int>(durationSeconds*1000.0f) + 1u/*beyond the animation duration*/);
1450 // We did expect the animation to finish
1451 application.SendNotification();
1452 finishCheck.CheckSignalReceived();
1456 int UtcDaliAnimationAnimateByBoolean(void)
1458 TestApplication application;
1460 Actor actor = Actor::New();
1462 // Register a boolean property
1463 bool startValue(false);
1464 Property::Index index = actor.RegisterProperty( "test-property", startValue );
1465 Stage::GetCurrent().Add(actor);
1466 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
1468 // Build the animation
1469 float durationSeconds(2.0f);
1470 Animation animation = Animation::New(durationSeconds);
1471 const bool relativeValue(true);
1472 const bool finalValue( false || relativeValue );
1473 animation.AnimateBy(Property(actor, index), relativeValue);
1475 // Start the animation
1478 bool signalReceived(false);
1479 AnimationFinishCheck finishCheck(signalReceived);
1480 animation.FinishedSignal().Connect(&application, finishCheck);
1482 application.SendNotification();
1483 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
1485 // We didn't expect the animation to finish yet
1486 application.SendNotification();
1487 finishCheck.CheckSignalNotReceived();
1488 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
1490 application.SendNotification();
1491 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
1493 // We did expect the animation to finish
1494 application.SendNotification();
1495 finishCheck.CheckSignalReceived();
1496 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1498 // Check that nothing has changed after a couple of buffer swaps
1499 application.Render(0);
1500 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1501 application.Render(0);
1502 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1504 // Repeat with relative value "false" - this should be an NOOP
1505 animation = Animation::New(durationSeconds);
1506 bool noOpValue(false);
1507 animation.AnimateBy(Property(actor, index), noOpValue);
1509 // Start the animation
1512 finishCheck.Reset();
1513 animation.FinishedSignal().Connect(&application, finishCheck);
1515 application.SendNotification();
1516 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
1518 // We didn't expect the animation to finish yet
1519 application.SendNotification();
1520 finishCheck.CheckSignalNotReceived();
1521 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1523 application.SendNotification();
1524 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
1526 // We did expect the animation to finish
1527 application.SendNotification();
1528 finishCheck.CheckSignalReceived();
1529 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1531 // Check that nothing has changed after a couple of buffer swaps
1532 application.Render(0);
1533 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1534 application.Render(0);
1535 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1539 int UtcDaliAnimationAnimateByBooleanAlphaFunction(void)
1541 TestApplication application;
1543 Actor actor = Actor::New();
1545 // Register a boolean property
1546 bool startValue(false);
1547 Property::Index index = actor.RegisterProperty( "test-property", startValue );
1548 Stage::GetCurrent().Add(actor);
1549 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
1551 // Build the animation
1552 float durationSeconds(2.0f);
1553 Animation animation = Animation::New(durationSeconds);
1554 bool relativeValue(true);
1555 bool finalValue( false || relativeValue );
1556 animation.AnimateBy(Property(actor, index), relativeValue, AlphaFunctions::EaseIn);
1558 // Start the animation
1561 bool signalReceived(false);
1562 AnimationFinishCheck finishCheck(signalReceived);
1563 animation.FinishedSignal().Connect(&application, finishCheck);
1565 application.SendNotification();
1566 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
1568 // We didn't expect the animation to finish yet
1569 application.SendNotification();
1570 finishCheck.CheckSignalNotReceived();
1571 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
1573 application.SendNotification();
1574 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
1576 // We did expect the animation to finish
1577 application.SendNotification();
1578 finishCheck.CheckSignalReceived();
1579 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1581 // Check that nothing has changed after a couple of buffer swaps
1582 application.Render(0);
1583 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1584 application.Render(0);
1585 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1587 // Repeat with relative value "false" - this should be an NOOP
1588 animation = Animation::New(durationSeconds);
1589 bool noOpValue(false);
1590 animation.AnimateBy(Property(actor, index), noOpValue, AlphaFunctions::EaseIn);
1592 // Start the animation
1595 finishCheck.Reset();
1596 animation.FinishedSignal().Connect(&application, finishCheck);
1598 application.SendNotification();
1599 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
1601 // We didn't expect the animation to finish yet
1602 application.SendNotification();
1603 finishCheck.CheckSignalNotReceived();
1604 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1606 application.SendNotification();
1607 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
1609 // We did expect the animation to finish
1610 application.SendNotification();
1611 finishCheck.CheckSignalReceived();
1612 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1616 int UtcDaliAnimationAnimateByBooleanTimePeriod(void)
1618 TestApplication application;
1620 Actor actor = Actor::New();
1622 // Register a boolean property
1623 bool startValue(false);
1624 Property::Index index = actor.RegisterProperty( "test-property", startValue );
1625 Stage::GetCurrent().Add(actor);
1626 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
1628 // Build the animation
1629 float durationSeconds(2.0f);
1630 Animation animation = Animation::New(durationSeconds);
1631 bool relativeValue(true);
1632 bool finalValue( false || relativeValue );
1633 float animatorDurationSeconds(durationSeconds * 0.5f);
1634 animation.AnimateBy( Property(actor, index),
1636 TimePeriod( animatorDurationSeconds ) );
1638 // Start the animation
1641 bool signalReceived(false);
1642 AnimationFinishCheck finishCheck(signalReceived);
1643 animation.FinishedSignal().Connect(&application, finishCheck);
1645 application.SendNotification();
1646 application.Render(static_cast<unsigned int>(animatorDurationSeconds*950.0f)/* 95% animator progress */);
1648 // We didn't expect the animation to finish yet
1649 application.SendNotification();
1650 finishCheck.CheckSignalNotReceived();
1651 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
1653 application.SendNotification();
1654 application.Render(static_cast<unsigned int>(animatorDurationSeconds*50.0f) + 1u/*just beyond the animator duration*/);
1656 // We didn't expect the animation to finish yet...
1657 application.SendNotification();
1658 finishCheck.CheckSignalNotReceived();
1660 // ...however we should have reached the final value
1661 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1663 application.SendNotification();
1664 application.Render(static_cast<unsigned int>(animatorDurationSeconds*1000.0f)/*just beyond the animation duration*/);
1666 // We did expect the animation to finish
1667 application.SendNotification();
1668 finishCheck.CheckSignalReceived();
1669 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1671 // Check that nothing has changed after a couple of buffer swaps
1672 application.Render(0);
1673 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1674 application.Render(0);
1675 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1679 int UtcDaliAnimationAnimateByBooleanAlphaFunctionTimePeriod(void)
1681 TestApplication application;
1683 Actor actor = Actor::New();
1685 // Register a boolean property
1686 bool startValue(false);
1687 Property::Index index = actor.RegisterProperty( "test-property", startValue );
1688 Stage::GetCurrent().Add(actor);
1689 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
1691 // Build the animation
1692 float durationSeconds(2.0f);
1693 Animation animation = Animation::New(durationSeconds);
1694 bool relativeValue(true);
1695 bool finalValue( false || relativeValue );
1696 float animatorDurationSeconds(durationSeconds * 0.5f);
1697 animation.AnimateBy( Property(actor, index),
1699 AlphaFunctions::EaseInOut,
1700 TimePeriod( animatorDurationSeconds ) );
1702 // Start the animation
1705 bool signalReceived(false);
1706 AnimationFinishCheck finishCheck(signalReceived);
1707 animation.FinishedSignal().Connect(&application, finishCheck);
1709 application.SendNotification();
1710 application.Render(static_cast<unsigned int>(animatorDurationSeconds*950.0f)/* 95% animator progress */);
1712 // We didn't expect the animation to finish yet
1713 application.SendNotification();
1714 finishCheck.CheckSignalNotReceived();
1715 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
1717 application.SendNotification();
1718 application.Render(static_cast<unsigned int>(animatorDurationSeconds*50.0f) + 1u/*just beyond the animator duration*/);
1720 // We didn't expect the animation to finish yet...
1721 application.SendNotification();
1722 finishCheck.CheckSignalNotReceived();
1724 // ...however we should have reached the final value
1725 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1727 application.SendNotification();
1728 application.Render(static_cast<unsigned int>(animatorDurationSeconds*1000.0f)/*just beyond the animation duration*/);
1730 // We did expect the animation to finish
1731 application.SendNotification();
1732 finishCheck.CheckSignalReceived();
1733 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1735 // Check that nothing has changed after a couple of buffer swaps
1736 application.Render(0);
1737 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1738 application.Render(0);
1739 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1743 int UtcDaliAnimationAnimateByFloat(void)
1745 TestApplication application;
1747 Actor actor = Actor::New();
1749 // Register a float property
1750 float startValue(10.0f);
1751 Property::Index index = actor.RegisterProperty( "test-property", startValue );
1752 Stage::GetCurrent().Add(actor);
1753 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
1755 // Build the animation
1756 float durationSeconds(2.0f);
1757 Animation animation = Animation::New(durationSeconds);
1758 float targetValue(50.0f);
1759 float relativeValue(targetValue - startValue);
1760 animation.AnimateBy(Property(actor, index), relativeValue);
1762 float ninetyFivePercentProgress(startValue + relativeValue*0.95f);
1764 // Start the animation
1767 bool signalReceived(false);
1768 AnimationFinishCheck finishCheck(signalReceived);
1769 animation.FinishedSignal().Connect(&application, finishCheck);
1771 application.SendNotification();
1772 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
1774 // We didn't expect the animation to finish yet
1775 application.SendNotification();
1776 finishCheck.CheckSignalNotReceived();
1777 DALI_TEST_EQUALS( actor.GetProperty<float>(index), ninetyFivePercentProgress, TEST_LOCATION );
1779 application.SendNotification();
1780 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
1782 // We did expect the animation to finish
1783 application.SendNotification();
1784 finishCheck.CheckSignalReceived();
1785 DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
1787 // Check that nothing has changed after a couple of buffer swaps
1788 application.Render(0);
1789 DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
1790 application.Render(0);
1791 DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
1795 int UtcDaliAnimationAnimateByFloatAlphaFunction(void)
1797 TestApplication application;
1799 Actor actor = Actor::New();
1801 // Register a float property
1802 float startValue(10.0f);
1803 Property::Index index = actor.RegisterProperty( "test-property", startValue );
1804 Stage::GetCurrent().Add(actor);
1805 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
1807 // Build the animation
1808 float durationSeconds(1.0f);
1809 Animation animation = Animation::New(durationSeconds);
1810 float targetValue(90.0f);
1811 float relativeValue(targetValue - startValue);
1812 animation.AnimateBy(Property(actor, index), relativeValue, AlphaFunctions::EaseOut);
1814 float ninetyFivePercentProgress(startValue + relativeValue*0.95f);
1816 // Start the animation
1819 bool signalReceived(false);
1820 AnimationFinishCheck finishCheck(signalReceived);
1821 animation.FinishedSignal().Connect(&application, finishCheck);
1823 application.SendNotification();
1824 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
1826 // We didn't expect the animation to finish yet
1827 application.SendNotification();
1828 finishCheck.CheckSignalNotReceived();
1830 // The position should have moved more, than with a linear alpha function
1831 float current(actor.GetProperty<float>(index));
1832 DALI_TEST_CHECK( current > ninetyFivePercentProgress );
1834 application.SendNotification();
1835 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
1837 // We did expect the animation to finish
1838 application.SendNotification();
1839 finishCheck.CheckSignalReceived();
1840 DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
1842 // Check that nothing has changed after a couple of buffer swaps
1843 application.Render(0);
1844 DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
1845 application.Render(0);
1846 DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
1850 int UtcDaliAnimationAnimateByFloatTimePeriod(void)
1852 TestApplication application;
1854 Actor actor = Actor::New();
1856 // Register a float property
1857 float startValue(10.0f);
1858 Property::Index index = actor.RegisterProperty( "test-property", startValue );
1859 Stage::GetCurrent().Add(actor);
1860 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
1862 // Build the animation
1863 float durationSeconds(1.0f);
1864 Animation animation = Animation::New(durationSeconds);
1865 float targetValue(30.0f);
1866 float relativeValue(targetValue - startValue);
1868 animation.AnimateBy(Property(actor, index),
1870 TimePeriod(delay, durationSeconds - delay));
1872 // Start the animation
1875 bool signalReceived(false);
1876 AnimationFinishCheck finishCheck(signalReceived);
1877 animation.FinishedSignal().Connect(&application, finishCheck);
1879 application.SendNotification();
1880 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
1882 // We didn't expect the animation to finish yet
1883 application.SendNotification();
1884 finishCheck.CheckSignalNotReceived();
1885 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
1887 application.SendNotification();
1888 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
1890 // We didn't expect the animation to finish yet
1891 application.SendNotification();
1892 finishCheck.CheckSignalNotReceived();
1893 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
1895 application.SendNotification();
1896 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
1898 // We did expect the animation to finish
1899 application.SendNotification();
1900 finishCheck.CheckSignalReceived();
1901 DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
1903 // Check that nothing has changed after a couple of buffer swaps
1904 application.Render(0);
1905 DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
1906 application.Render(0);
1907 DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
1911 int UtcDaliAnimationAnimateByFloatAlphaFunctionTimePeriod(void)
1913 TestApplication application;
1915 Actor actor = Actor::New();
1917 // Register a float property
1918 float startValue(10.0f);
1919 Property::Index index = actor.RegisterProperty( "test-property", startValue );
1920 Stage::GetCurrent().Add(actor);
1921 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
1923 // Build the animation
1924 float durationSeconds(1.0f);
1925 Animation animation = Animation::New(durationSeconds);
1926 float targetValue(30.0f);
1927 float relativeValue(targetValue - startValue);
1929 animation.AnimateBy(Property(actor, index),
1931 AlphaFunctions::Linear,
1932 TimePeriod(delay, durationSeconds - delay));
1934 // Start the animation
1937 bool signalReceived(false);
1938 AnimationFinishCheck finishCheck(signalReceived);
1939 animation.FinishedSignal().Connect(&application, finishCheck);
1941 application.SendNotification();
1942 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
1944 // We didn't expect the animation to finish yet
1945 application.SendNotification();
1946 finishCheck.CheckSignalNotReceived();
1947 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
1949 application.SendNotification();
1950 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
1952 // We didn't expect the animation to finish yet
1953 application.SendNotification();
1954 finishCheck.CheckSignalNotReceived();
1955 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
1957 application.SendNotification();
1958 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
1960 // We did expect the animation to finish
1961 application.SendNotification();
1962 finishCheck.CheckSignalReceived();
1963 DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
1965 // Check that nothing has changed after a couple of buffer swaps
1966 application.Render(0);
1967 DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
1968 application.Render(0);
1969 DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
1973 int UtcDaliAnimationAnimateByInteger(void)
1975 TestApplication application;
1977 Actor actor = Actor::New();
1979 // Register an integer property
1981 Property::Index index = actor.RegisterProperty( "test-property", startValue );
1982 Stage::GetCurrent().Add(actor);
1983 DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
1985 // Build the animation
1986 float durationSeconds(2.0f);
1987 Animation animation = Animation::New(durationSeconds);
1988 int targetValue(50);
1989 int relativeValue(targetValue - startValue);
1990 animation.AnimateBy(Property(actor, index), relativeValue);
1992 int ninetyFivePercentProgress(static_cast<int>(startValue + relativeValue*0.95f + 0.5f));
1994 // Start the animation
1997 bool signalReceived(false);
1998 AnimationFinishCheck finishCheck(signalReceived);
1999 animation.FinishedSignal().Connect(&application, finishCheck);
2001 application.SendNotification();
2002 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
2004 // We didn't expect the animation to finish yet
2005 application.SendNotification();
2006 finishCheck.CheckSignalNotReceived();
2007 DALI_TEST_EQUALS( actor.GetProperty<int>(index), ninetyFivePercentProgress, TEST_LOCATION );
2009 application.SendNotification();
2010 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
2012 // We did expect the animation to finish
2013 application.SendNotification();
2014 finishCheck.CheckSignalReceived();
2015 DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
2017 // Check that nothing has changed after a couple of buffer swaps
2018 application.Render(0);
2019 DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
2020 application.Render(0);
2021 DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
2025 int UtcDaliAnimationAnimateByIntegerAlphaFunction(void)
2027 TestApplication application;
2029 Actor actor = Actor::New();
2031 // Register an integer property
2033 Property::Index index = actor.RegisterProperty( "test-property", startValue );
2034 Stage::GetCurrent().Add(actor);
2035 DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
2037 // Build the animation
2038 float durationSeconds(1.0f);
2039 Animation animation = Animation::New(durationSeconds);
2040 int targetValue(90);
2041 int relativeValue(targetValue - startValue);
2042 animation.AnimateBy(Property(actor, index), relativeValue, AlphaFunctions::EaseOut);
2044 int ninetyFivePercentProgress(static_cast<int>(startValue + relativeValue*0.95f + 0.5f));
2046 // Start the animation
2049 bool signalReceived(false);
2050 AnimationFinishCheck finishCheck(signalReceived);
2051 animation.FinishedSignal().Connect(&application, finishCheck);
2053 application.SendNotification();
2054 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
2056 // We didn't expect the animation to finish yet
2057 application.SendNotification();
2058 finishCheck.CheckSignalNotReceived();
2060 // The position should have moved more, than with a linear alpha function
2061 int current(actor.GetProperty<int>(index));
2062 DALI_TEST_CHECK( current > ninetyFivePercentProgress );
2064 application.SendNotification();
2065 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
2067 // We did expect the animation to finish
2068 application.SendNotification();
2069 finishCheck.CheckSignalReceived();
2070 DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
2072 // Check that nothing has changed after a couple of buffer swaps
2073 application.Render(0);
2074 DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
2075 application.Render(0);
2076 DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
2080 int UtcDaliAnimationAnimateByIntegerTimePeriod(void)
2082 TestApplication application;
2084 Actor actor = Actor::New();
2086 // Register an integer property
2088 Property::Index index = actor.RegisterProperty( "test-property", startValue );
2089 Stage::GetCurrent().Add(actor);
2090 DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
2092 // Build the animation
2093 float durationSeconds(1.0f);
2094 Animation animation = Animation::New(durationSeconds);
2095 int targetValue(30);
2096 int relativeValue(targetValue - startValue);
2098 animation.AnimateBy(Property(actor, index),
2100 TimePeriod(delay, durationSeconds - delay));
2102 // Start the animation
2105 bool signalReceived(false);
2106 AnimationFinishCheck finishCheck(signalReceived);
2107 animation.FinishedSignal().Connect(&application, finishCheck);
2109 application.SendNotification();
2110 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
2112 // We didn't expect the animation to finish yet
2113 application.SendNotification();
2114 finishCheck.CheckSignalNotReceived();
2115 DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
2117 application.SendNotification();
2118 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
2120 // We didn't expect the animation to finish yet
2121 application.SendNotification();
2122 finishCheck.CheckSignalNotReceived();
2123 DALI_TEST_EQUALS( actor.GetProperty<int>(index), static_cast<int>(startValue+(relativeValue*0.5f)+0.5f), TEST_LOCATION );
2125 application.SendNotification();
2126 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
2128 // We did expect the animation to finish
2129 application.SendNotification();
2130 finishCheck.CheckSignalReceived();
2131 DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
2133 // Check that nothing has changed after a couple of buffer swaps
2134 application.Render(0);
2135 DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
2136 application.Render(0);
2137 DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
2141 int UtcDaliAnimationAnimateByIntegerAlphaFunctionTimePeriod(void)
2143 TestApplication application;
2145 Actor actor = Actor::New();
2147 // Register an integer property
2149 Property::Index index = actor.RegisterProperty( "test-property", startValue );
2150 Stage::GetCurrent().Add(actor);
2151 DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
2153 // Build the animation
2154 float durationSeconds(1.0f);
2155 Animation animation = Animation::New(durationSeconds);
2156 int targetValue(30);
2157 int relativeValue(targetValue - startValue);
2159 animation.AnimateBy(Property(actor, index),
2161 AlphaFunctions::Linear,
2162 TimePeriod(delay, durationSeconds - delay));
2164 // Start the animation
2167 bool signalReceived(false);
2168 AnimationFinishCheck finishCheck(signalReceived);
2169 animation.FinishedSignal().Connect(&application, finishCheck);
2171 application.SendNotification();
2172 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
2174 // We didn't expect the animation to finish yet
2175 application.SendNotification();
2176 finishCheck.CheckSignalNotReceived();
2177 DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
2179 application.SendNotification();
2180 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
2182 // We didn't expect the animation to finish yet
2183 application.SendNotification();
2184 finishCheck.CheckSignalNotReceived();
2185 DALI_TEST_EQUALS( actor.GetProperty<int>(index), static_cast<int>(startValue+(relativeValue*0.5f)+0.5f), TEST_LOCATION );
2187 application.SendNotification();
2188 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
2190 // We did expect the animation to finish
2191 application.SendNotification();
2192 finishCheck.CheckSignalReceived();
2193 DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
2195 // Check that nothing has changed after a couple of buffer swaps
2196 application.Render(0);
2197 DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
2198 application.Render(0);
2199 DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
2203 int UtcDaliAnimationAnimateByVector2(void)
2205 TestApplication application;
2207 Actor actor = Actor::New();
2209 // Register a Vector2 property
2210 Vector2 startValue(10.0f, 10.0f);
2211 Property::Index index = actor.RegisterProperty( "test-property", startValue );
2212 Stage::GetCurrent().Add(actor);
2213 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
2215 // Build the animation
2216 float durationSeconds(2.0f);
2217 Animation animation = Animation::New(durationSeconds);
2218 Vector2 targetValue(60.0f, 60.0f);
2219 Vector2 relativeValue(targetValue - startValue);
2220 animation.AnimateBy(Property(actor, index), relativeValue);
2222 Vector2 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
2224 // Start the animation
2227 bool signalReceived(false);
2228 AnimationFinishCheck finishCheck(signalReceived);
2229 animation.FinishedSignal().Connect(&application, finishCheck);
2231 application.SendNotification();
2232 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
2234 // We didn't expect the animation to finish yet
2235 application.SendNotification();
2236 finishCheck.CheckSignalNotReceived();
2237 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), ninetyFivePercentProgress, TEST_LOCATION );
2239 application.SendNotification();
2240 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
2242 // We did expect the animation to finish
2243 application.SendNotification();
2244 finishCheck.CheckSignalReceived();
2245 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
2247 // Check that nothing has changed after a couple of buffer swaps
2248 application.Render(0);
2249 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
2250 application.Render(0);
2251 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
2255 int UtcDaliAnimationAnimateByVector2AlphaFunction(void)
2257 TestApplication application;
2259 Actor actor = Actor::New();
2261 // Register a Vector2 property
2262 Vector2 startValue(100.0f, 100.0f);
2263 Property::Index index = actor.RegisterProperty( "test-property", startValue );
2264 Stage::GetCurrent().Add(actor);
2265 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
2267 // Build the animation
2268 float durationSeconds(1.0f);
2269 Animation animation = Animation::New(durationSeconds);
2270 Vector2 targetValue(20.0f, 20.0f);
2271 Vector2 relativeValue(targetValue - startValue);
2272 animation.AnimateBy(Property(actor, index), relativeValue, AlphaFunctions::EaseOut);
2274 Vector2 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
2276 // Start the animation
2279 bool signalReceived(false);
2280 AnimationFinishCheck finishCheck(signalReceived);
2281 animation.FinishedSignal().Connect(&application, finishCheck);
2283 application.SendNotification();
2284 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
2286 // We didn't expect the animation to finish yet
2287 application.SendNotification();
2288 finishCheck.CheckSignalNotReceived();
2290 // The position should have moved more, than with a linear alpha function
2291 Vector2 current(actor.GetProperty<Vector2>(index));
2292 DALI_TEST_CHECK( current.x < ninetyFivePercentProgress.x );
2293 DALI_TEST_CHECK( current.y < ninetyFivePercentProgress.y );
2295 application.SendNotification();
2296 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
2298 // We did expect the animation to finish
2299 application.SendNotification();
2300 finishCheck.CheckSignalReceived();
2301 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
2303 // Check that nothing has changed after a couple of buffer swaps
2304 application.Render(0);
2305 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
2306 application.Render(0);
2307 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
2311 int UtcDaliAnimationAnimateByVector2TimePeriod(void)
2313 TestApplication application;
2315 Actor actor = Actor::New();
2317 // Register a Vector2 property
2318 Vector2 startValue(10.0f, 10.0f);
2319 Property::Index index = actor.RegisterProperty( "test-property", startValue );
2320 Stage::GetCurrent().Add(actor);
2321 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
2323 // Build the animation
2324 float durationSeconds(1.0f);
2325 Animation animation = Animation::New(durationSeconds);
2326 Vector2 targetValue(30.0f, 30.0f);
2327 Vector2 relativeValue(targetValue - startValue);
2329 animation.AnimateBy(Property(actor, index),
2331 TimePeriod(delay, durationSeconds - delay));
2333 // Start the animation
2336 bool signalReceived(false);
2337 AnimationFinishCheck finishCheck(signalReceived);
2338 animation.FinishedSignal().Connect(&application, finishCheck);
2340 application.SendNotification();
2341 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
2343 // We didn't expect the animation to finish yet
2344 application.SendNotification();
2345 finishCheck.CheckSignalNotReceived();
2346 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
2348 application.SendNotification();
2349 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
2351 // We didn't expect the animation to finish yet
2352 application.SendNotification();
2353 finishCheck.CheckSignalNotReceived();
2354 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
2356 application.SendNotification();
2357 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
2359 // We did expect the animation to finish
2360 application.SendNotification();
2361 finishCheck.CheckSignalReceived();
2362 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
2364 // Check that nothing has changed after a couple of buffer swaps
2365 application.Render(0);
2366 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
2367 application.Render(0);
2368 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
2372 int UtcDaliAnimationAnimateByVector2AlphaFunctionTimePeriod(void)
2374 TestApplication application;
2376 Actor actor = Actor::New();
2378 // Register a Vector2 property
2379 Vector2 startValue(5.0f, 5.0f);
2380 Property::Index index = actor.RegisterProperty( "test-property", startValue );
2381 Stage::GetCurrent().Add(actor);
2382 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
2384 // Build the animation
2385 float durationSeconds(1.0f);
2386 Animation animation = Animation::New(durationSeconds);
2387 Vector2 targetValue(10.0f, 10.0f);
2388 Vector2 relativeValue(targetValue - startValue);
2390 animation.AnimateBy(Property(actor, index),
2392 AlphaFunctions::Linear,
2393 TimePeriod(delay, durationSeconds - delay));
2395 // Start the animation
2398 bool signalReceived(false);
2399 AnimationFinishCheck finishCheck(signalReceived);
2400 animation.FinishedSignal().Connect(&application, finishCheck);
2402 application.SendNotification();
2403 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
2405 // We didn't expect the animation to finish yet
2406 application.SendNotification();
2407 finishCheck.CheckSignalNotReceived();
2408 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
2410 application.SendNotification();
2411 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
2413 // We didn't expect the animation to finish yet
2414 application.SendNotification();
2415 finishCheck.CheckSignalNotReceived();
2416 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
2418 application.SendNotification();
2419 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
2421 // We did expect the animation to finish
2422 application.SendNotification();
2423 finishCheck.CheckSignalReceived();
2424 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
2426 // Check that nothing has changed after a couple of buffer swaps
2427 application.Render(0);
2428 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
2429 application.Render(0);
2430 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
2434 int UtcDaliAnimationAnimateByVector3(void)
2436 TestApplication application;
2438 Actor actor = Actor::New();
2440 // Register a Vector3 property
2441 Vector3 startValue(10.0f, 10.0f, 10.0f);
2442 Property::Index index = actor.RegisterProperty( "test-property", startValue );
2443 Stage::GetCurrent().Add(actor);
2444 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
2446 // Build the animation
2447 float durationSeconds(2.0f);
2448 Animation animation = Animation::New(durationSeconds);
2449 Vector3 targetValue(60.0f, 60.0f, 60.0f);
2450 Vector3 relativeValue(targetValue - startValue);
2451 animation.AnimateBy(Property(actor, index), relativeValue);
2453 Vector3 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
2455 // Start the animation
2458 bool signalReceived(false);
2459 AnimationFinishCheck finishCheck(signalReceived);
2460 animation.FinishedSignal().Connect(&application, finishCheck);
2462 application.SendNotification();
2463 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
2465 // We didn't expect the animation to finish yet
2466 application.SendNotification();
2467 finishCheck.CheckSignalNotReceived();
2468 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), ninetyFivePercentProgress, TEST_LOCATION );
2470 application.SendNotification();
2471 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
2473 // We did expect the animation to finish
2474 application.SendNotification();
2475 finishCheck.CheckSignalReceived();
2476 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
2478 // Check that nothing has changed after a couple of buffer swaps
2479 application.Render(0);
2480 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
2481 application.Render(0);
2482 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
2486 int UtcDaliAnimationAnimateByVector3AlphaFunction(void)
2488 TestApplication application;
2490 Actor actor = Actor::New();
2492 // Register a Vector3 property
2493 Vector3 startValue(100.0f, 100.0f, 100.0f);
2494 Property::Index index = actor.RegisterProperty( "test-property", startValue );
2495 Stage::GetCurrent().Add(actor);
2496 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
2498 // Build the animation
2499 float durationSeconds(1.0f);
2500 Animation animation = Animation::New(durationSeconds);
2501 Vector3 targetValue(20.0f, 20.0f, 20.0f);
2502 Vector3 relativeValue(targetValue - startValue);
2503 animation.AnimateBy(Property(actor, index), relativeValue, AlphaFunctions::EaseOut);
2505 Vector3 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
2507 // Start the animation
2510 bool signalReceived(false);
2511 AnimationFinishCheck finishCheck(signalReceived);
2512 animation.FinishedSignal().Connect(&application, finishCheck);
2514 application.SendNotification();
2515 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
2517 // We didn't expect the animation to finish yet
2518 application.SendNotification();
2519 finishCheck.CheckSignalNotReceived();
2521 // The position should have moved more, than with a linear alpha function
2522 Vector3 current(actor.GetProperty<Vector3>(index));
2523 DALI_TEST_CHECK( current.x < ninetyFivePercentProgress.x );
2524 DALI_TEST_CHECK( current.y < ninetyFivePercentProgress.y );
2525 DALI_TEST_CHECK( current.z < ninetyFivePercentProgress.z );
2527 application.SendNotification();
2528 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
2530 // We did expect the animation to finish
2531 application.SendNotification();
2532 finishCheck.CheckSignalReceived();
2533 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
2535 // Check that nothing has changed after a couple of buffer swaps
2536 application.Render(0);
2537 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
2538 application.Render(0);
2539 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
2543 int UtcDaliAnimationAnimateByVector3TimePeriod(void)
2545 TestApplication application;
2547 Actor actor = Actor::New();
2549 // Register a Vector3 property
2550 Vector3 startValue(10.0f, 10.0f, 10.0f);
2551 Property::Index index = actor.RegisterProperty( "test-property", startValue );
2552 Stage::GetCurrent().Add(actor);
2553 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
2555 // Build the animation
2556 float durationSeconds(1.0f);
2557 Animation animation = Animation::New(durationSeconds);
2558 Vector3 targetValue(30.0f, 30.0f, 30.0f);
2559 Vector3 relativeValue(targetValue - startValue);
2561 animation.AnimateBy(Property(actor, index),
2563 TimePeriod(delay, durationSeconds - delay));
2565 // Start the animation
2568 bool signalReceived(false);
2569 AnimationFinishCheck finishCheck(signalReceived);
2570 animation.FinishedSignal().Connect(&application, finishCheck);
2572 application.SendNotification();
2573 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
2575 // We didn't expect the animation to finish yet
2576 application.SendNotification();
2577 finishCheck.CheckSignalNotReceived();
2578 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
2580 application.SendNotification();
2581 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
2583 // We didn't expect the animation to finish yet
2584 application.SendNotification();
2585 finishCheck.CheckSignalNotReceived();
2586 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
2588 application.SendNotification();
2589 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
2591 // We did expect the animation to finish
2592 application.SendNotification();
2593 finishCheck.CheckSignalReceived();
2594 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
2596 // Check that nothing has changed after a couple of buffer swaps
2597 application.Render(0);
2598 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
2599 application.Render(0);
2600 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
2604 int UtcDaliAnimationAnimateByVector3AlphaFunctionTimePeriod(void)
2606 TestApplication application;
2608 Actor actor = Actor::New();
2610 // Register a Vector3 property
2611 Vector3 startValue(5.0f, 5.0f, 5.0f);
2612 Property::Index index = actor.RegisterProperty( "test-property", startValue );
2613 Stage::GetCurrent().Add(actor);
2614 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
2616 // Build the animation
2617 float durationSeconds(1.0f);
2618 Animation animation = Animation::New(durationSeconds);
2619 Vector3 targetValue(10.0f, 10.0f, 10.0f);
2620 Vector3 relativeValue(targetValue - startValue);
2622 animation.AnimateBy(Property(actor, index),
2624 AlphaFunctions::Linear,
2625 TimePeriod(delay, durationSeconds - delay));
2627 // Start the animation
2630 bool signalReceived(false);
2631 AnimationFinishCheck finishCheck(signalReceived);
2632 animation.FinishedSignal().Connect(&application, finishCheck);
2634 application.SendNotification();
2635 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
2637 // We didn't expect the animation to finish yet
2638 application.SendNotification();
2639 finishCheck.CheckSignalNotReceived();
2640 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
2642 application.SendNotification();
2643 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
2645 // We didn't expect the animation to finish yet
2646 application.SendNotification();
2647 finishCheck.CheckSignalNotReceived();
2648 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
2650 application.SendNotification();
2651 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
2653 // We did expect the animation to finish
2654 application.SendNotification();
2655 finishCheck.CheckSignalReceived();
2656 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
2658 // Check that nothing has changed after a couple of buffer swaps
2659 application.Render(0);
2660 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
2661 application.Render(0);
2662 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
2666 int UtcDaliAnimationAnimateByVector4(void)
2668 TestApplication application;
2670 Actor actor = Actor::New();
2672 // Register a Vector4 property
2673 Vector4 startValue(10.0f, 10.0f, 10.0f, 10.0f);
2674 Property::Index index = actor.RegisterProperty( "test-property", startValue );
2675 Stage::GetCurrent().Add(actor);
2676 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
2678 // Build the animation
2679 float durationSeconds(2.0f);
2680 Animation animation = Animation::New(durationSeconds);
2681 Vector4 targetValue(60.0f, 60.0f, 60.0f, 60.0f);
2682 Vector4 relativeValue(targetValue - startValue);
2683 animation.AnimateBy(Property(actor, index), relativeValue);
2685 Vector4 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
2687 // Start the animation
2690 bool signalReceived(false);
2691 AnimationFinishCheck finishCheck(signalReceived);
2692 animation.FinishedSignal().Connect(&application, finishCheck);
2694 application.SendNotification();
2695 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
2697 // We didn't expect the animation to finish yet
2698 application.SendNotification();
2699 finishCheck.CheckSignalNotReceived();
2700 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), ninetyFivePercentProgress, TEST_LOCATION );
2702 application.SendNotification();
2703 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
2705 // We did expect the animation to finish
2706 application.SendNotification();
2707 finishCheck.CheckSignalReceived();
2708 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
2710 // Check that nothing has changed after a couple of buffer swaps
2711 application.Render(0);
2712 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
2713 application.Render(0);
2714 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
2718 int UtcDaliAnimationAnimateByVector4AlphaFunction(void)
2720 TestApplication application;
2722 Actor actor = Actor::New();
2724 // Register a Vector4 property
2725 Vector4 startValue(100.0f, 100.0f, 100.0f, 100.0f);
2726 Property::Index index = actor.RegisterProperty( "test-property", startValue );
2727 Stage::GetCurrent().Add(actor);
2728 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
2730 // Build the animation
2731 float durationSeconds(1.0f);
2732 Animation animation = Animation::New(durationSeconds);
2733 Vector4 targetValue(20.0f, 20.0f, 20.0f, 20.0f);
2734 Vector4 relativeValue(targetValue - startValue);
2735 animation.AnimateBy(Property(actor, index), relativeValue, AlphaFunctions::EaseOut);
2737 Vector4 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
2739 // Start the animation
2742 bool signalReceived(false);
2743 AnimationFinishCheck finishCheck(signalReceived);
2744 animation.FinishedSignal().Connect(&application, finishCheck);
2746 application.SendNotification();
2747 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
2749 // We didn't expect the animation to finish yet
2750 application.SendNotification();
2751 finishCheck.CheckSignalNotReceived();
2753 // The position should have moved more, than with a linear alpha function
2754 Vector4 current(actor.GetProperty<Vector4>(index));
2755 DALI_TEST_CHECK( current.x < ninetyFivePercentProgress.x );
2756 DALI_TEST_CHECK( current.y < ninetyFivePercentProgress.y );
2757 DALI_TEST_CHECK( current.z < ninetyFivePercentProgress.z );
2758 DALI_TEST_CHECK( current.w < ninetyFivePercentProgress.w );
2760 application.SendNotification();
2761 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
2763 // We did expect the animation to finish
2764 application.SendNotification();
2765 finishCheck.CheckSignalReceived();
2766 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
2768 // Check that nothing has changed after a couple of buffer swaps
2769 application.Render(0);
2770 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
2771 application.Render(0);
2772 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
2776 int UtcDaliAnimationAnimateByVector4TimePeriod(void)
2778 TestApplication application;
2780 Actor actor = Actor::New();
2782 // Register a Vector4 property
2783 Vector4 startValue(10.0f, 10.0f, 10.0f, 10.0f);
2784 Property::Index index = actor.RegisterProperty( "test-property", startValue );
2785 Stage::GetCurrent().Add(actor);
2786 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
2788 // Build the animation
2789 float durationSeconds(1.0f);
2790 Animation animation = Animation::New(durationSeconds);
2791 Vector4 targetValue(30.0f, 30.0f, 30.0f, 30.0f);
2792 Vector4 relativeValue(targetValue - startValue);
2794 animation.AnimateBy(Property(actor, index),
2796 TimePeriod(delay, durationSeconds - delay));
2798 // Start the animation
2801 bool signalReceived(false);
2802 AnimationFinishCheck finishCheck(signalReceived);
2803 animation.FinishedSignal().Connect(&application, finishCheck);
2805 application.SendNotification();
2806 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
2808 // We didn't expect the animation to finish yet
2809 application.SendNotification();
2810 finishCheck.CheckSignalNotReceived();
2811 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
2813 application.SendNotification();
2814 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
2816 // We didn't expect the animation to finish yet
2817 application.SendNotification();
2818 finishCheck.CheckSignalNotReceived();
2819 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
2821 application.SendNotification();
2822 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
2824 // We did expect the animation to finish
2825 application.SendNotification();
2826 finishCheck.CheckSignalReceived();
2827 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
2829 // Check that nothing has changed after a couple of buffer swaps
2830 application.Render(0);
2831 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
2832 application.Render(0);
2833 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
2837 int UtcDaliAnimationAnimateByVector4AlphaFunctionTimePeriod(void)
2839 TestApplication application;
2841 Actor actor = Actor::New();
2843 // Register a Vector4 property
2844 Vector4 startValue(5.0f, 5.0f, 5.0f, 5.0f);
2845 Property::Index index = actor.RegisterProperty( "test-property", startValue );
2846 Stage::GetCurrent().Add(actor);
2847 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
2849 // Build the animation
2850 float durationSeconds(1.0f);
2851 Animation animation = Animation::New(durationSeconds);
2852 Vector4 targetValue(10.0f, 10.0f, 10.0f, 10.0f);
2853 Vector4 relativeValue(targetValue - startValue);
2855 animation.AnimateBy(Property(actor, index),
2857 AlphaFunctions::Linear,
2858 TimePeriod(delay, durationSeconds - delay));
2860 // Start the animation
2863 bool signalReceived(false);
2864 AnimationFinishCheck finishCheck(signalReceived);
2865 animation.FinishedSignal().Connect(&application, finishCheck);
2867 application.SendNotification();
2868 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
2870 // We didn't expect the animation to finish yet
2871 application.SendNotification();
2872 finishCheck.CheckSignalNotReceived();
2873 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
2875 application.SendNotification();
2876 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
2878 // We didn't expect the animation to finish yet
2879 application.SendNotification();
2880 finishCheck.CheckSignalNotReceived();
2881 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
2883 application.SendNotification();
2884 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
2886 // We did expect the animation to finish
2887 application.SendNotification();
2888 finishCheck.CheckSignalReceived();
2889 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
2891 // Check that nothing has changed after a couple of buffer swaps
2892 application.Render(0);
2893 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
2894 application.Render(0);
2895 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
2899 int UtcDaliAnimationAnimateByActorPosition(void)
2901 TestApplication application;
2903 Actor actor = Actor::New();
2904 Vector3 startPosition(10.0f, 10.0f, 10.0f);
2905 actor.SetPosition(startPosition);
2906 Stage::GetCurrent().Add(actor);
2907 application.SendNotification();
2908 application.Render(0);
2909 DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION );
2911 // Build the animation
2912 float durationSeconds(1.0f);
2913 Animation animation = Animation::New(durationSeconds);
2914 Vector3 targetPosition(20.0f, 20.0f, 20.0f);
2915 Vector3 relativePosition(targetPosition - startPosition);
2916 animation.AnimateBy(Property(actor, Actor::POSITION), relativePosition);
2918 Vector3 ninetyFivePercentProgress(startPosition + relativePosition*0.95f);
2920 // Start the animation
2923 bool signalReceived(false);
2924 AnimationFinishCheck finishCheck(signalReceived);
2925 animation.FinishedSignal().Connect(&application, finishCheck);
2927 application.SendNotification();
2928 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
2930 // We didn't expect the animation to finish yet
2931 application.SendNotification();
2932 finishCheck.CheckSignalNotReceived();
2933 DALI_TEST_EQUALS( actor.GetCurrentPosition(), ninetyFivePercentProgress, TEST_LOCATION );
2935 application.SendNotification();
2936 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
2938 // We did expect the animation to finish
2939 application.SendNotification();
2940 finishCheck.CheckSignalReceived();
2941 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
2943 // Check that nothing has changed after a couple of buffer swaps
2944 application.Render(0);
2945 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
2946 application.Render(0);
2947 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
2951 int UtcDaliAnimationAnimateByActorPositionAlphaFunction(void)
2953 TestApplication application;
2955 Actor actor = Actor::New();
2956 Vector3 startPosition(10.0f, 10.0f, 10.0f);
2957 actor.SetPosition(startPosition);
2958 Stage::GetCurrent().Add(actor);
2959 application.SendNotification();
2960 application.Render(0);
2961 DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION );
2963 // Build the animation
2964 float durationSeconds(1.0f);
2965 Animation animation = Animation::New(durationSeconds);
2966 Vector3 targetPosition(20.0f, 20.0f, 20.0f);
2967 Vector3 relativePosition(targetPosition - startPosition);
2968 animation.AnimateBy(Property(actor, Actor::POSITION), relativePosition, AlphaFunctions::EaseOut);
2970 Vector3 ninetyFivePercentProgress(startPosition + relativePosition*0.95f);
2972 // Start the animation
2975 bool signalReceived(false);
2976 AnimationFinishCheck finishCheck(signalReceived);
2977 animation.FinishedSignal().Connect(&application, finishCheck);
2979 application.SendNotification();
2980 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
2982 // We didn't expect the animation to finish yet
2983 application.SendNotification();
2984 finishCheck.CheckSignalNotReceived();
2986 // The position should have moved more, than with a linear alpha function
2987 Vector3 current(actor.GetCurrentPosition());
2988 DALI_TEST_CHECK( current.x > ninetyFivePercentProgress.x );
2989 DALI_TEST_CHECK( current.y > ninetyFivePercentProgress.y );
2990 DALI_TEST_CHECK( current.z > ninetyFivePercentProgress.z );
2992 application.SendNotification();
2993 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
2995 // We did expect the animation to finish
2996 application.SendNotification();
2997 finishCheck.CheckSignalReceived();
2998 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
3000 // Check that nothing has changed after a couple of buffer swaps
3001 application.Render(0);
3002 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
3003 application.Render(0);
3004 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
3008 int UtcDaliAnimationAnimateByActorPositionTimePeriod(void)
3010 TestApplication application;
3012 Actor actor = Actor::New();
3013 Vector3 startPosition(10.0f, 10.0f, 10.0f);
3014 actor.SetPosition(startPosition);
3015 Stage::GetCurrent().Add(actor);
3016 application.SendNotification();
3017 application.Render(0);
3018 DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION );
3020 // Build the animation
3021 float durationSeconds(1.0f);
3022 Animation animation = Animation::New(durationSeconds);
3023 Vector3 targetPosition(20.0f, 20.0f, 20.0f);
3024 Vector3 relativePosition(targetPosition - startPosition);
3026 animation.AnimateBy(Property(actor, Actor::POSITION),
3028 TimePeriod(delay, durationSeconds - delay));
3030 Vector3 ninetyFivePercentProgress(startPosition + relativePosition*0.95f);
3032 // Start the animation
3035 bool signalReceived(false);
3036 AnimationFinishCheck finishCheck(signalReceived);
3037 animation.FinishedSignal().Connect(&application, finishCheck);
3039 application.SendNotification();
3040 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
3042 // We didn't expect the animation to finish yet
3043 application.SendNotification();
3044 finishCheck.CheckSignalNotReceived();
3045 DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION );
3047 application.SendNotification();
3048 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
3050 // We did expect the animation to finish
3051 application.SendNotification();
3052 finishCheck.CheckSignalReceived();
3053 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
3055 // Check that nothing has changed after a couple of buffer swaps
3056 application.Render(0);
3057 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
3058 application.Render(0);
3059 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
3063 int UtcDaliAnimationAnimateByActorPositionAlphaFunctionTimePeriod(void)
3065 TestApplication application;
3067 Actor actor = Actor::New();
3068 Vector3 startPosition(10.0f, 10.0f, 10.0f);
3069 actor.SetPosition(startPosition);
3070 Stage::GetCurrent().Add(actor);
3071 application.SendNotification();
3072 application.Render(0);
3073 DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION );
3075 // Build the animation
3076 float durationSeconds(1.0f);
3077 Animation animation = Animation::New(durationSeconds);
3078 Vector3 targetPosition(20.0f, 20.0f, 20.0f);
3079 Vector3 relativePosition(targetPosition - startPosition);
3081 animation.AnimateBy(Property(actor, Actor::POSITION),
3083 AlphaFunctions::Linear,
3084 TimePeriod(delay, durationSeconds - delay));
3086 Vector3 ninetyFivePercentProgress(startPosition + relativePosition*0.95f);
3088 // Start the animation
3091 bool signalReceived(false);
3092 AnimationFinishCheck finishCheck(signalReceived);
3093 animation.FinishedSignal().Connect(&application, finishCheck);
3095 application.SendNotification();
3096 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
3098 // We didn't expect the animation to finish yet
3099 application.SendNotification();
3100 finishCheck.CheckSignalNotReceived();
3101 DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION );
3103 application.SendNotification();
3104 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
3106 // We did expect the animation to finish
3107 application.SendNotification();
3108 finishCheck.CheckSignalReceived();
3109 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
3111 // Check that nothing has changed after a couple of buffer swaps
3112 application.Render(0);
3113 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
3114 application.Render(0);
3115 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
3119 int UtcDaliAnimationAnimateToBoolean(void)
3121 TestApplication application;
3123 Actor actor = Actor::New();
3125 // Register a boolean property
3126 const bool startValue(false);
3127 Property::Index index = actor.RegisterProperty( "test-property", startValue );
3128 Stage::GetCurrent().Add(actor);
3129 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
3131 // Build the animation
3132 float durationSeconds(2.0f);
3133 Animation animation = Animation::New(durationSeconds);
3134 const bool targetValue( !startValue );
3135 animation.AnimateTo(Property(actor, index), targetValue);
3137 // Start the animation
3140 bool signalReceived(false);
3141 AnimationFinishCheck finishCheck(signalReceived);
3142 animation.FinishedSignal().Connect(&application, finishCheck);
3144 application.SendNotification();
3145 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3147 // We didn't expect the animation to finish yet
3148 application.SendNotification();
3149 finishCheck.CheckSignalNotReceived();
3150 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
3152 application.SendNotification();
3153 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3155 // We did expect the animation to finish
3156 application.SendNotification();
3157 finishCheck.CheckSignalReceived();
3158 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == targetValue );
3160 // Check that nothing has changed after a couple of buffer swaps
3161 application.Render(0);
3162 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == targetValue );
3163 application.Render(0);
3164 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == targetValue );
3166 // Repeat with target value "false"
3167 animation = Animation::New(durationSeconds);
3168 const bool finalValue( !targetValue );
3169 animation.AnimateTo(Property(actor, index), finalValue);
3171 // Start the animation
3174 finishCheck.Reset();
3175 animation.FinishedSignal().Connect(&application, finishCheck);
3177 application.SendNotification();
3178 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3180 // We didn't expect the animation to finish yet
3181 application.SendNotification();
3182 finishCheck.CheckSignalNotReceived();
3183 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == targetValue );
3185 application.SendNotification();
3186 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3188 // We did expect the animation to finish
3189 application.SendNotification();
3190 finishCheck.CheckSignalReceived();
3191 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
3193 // Check that nothing has changed after a couple of buffer swaps
3194 application.Render(0);
3195 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
3196 application.Render(0);
3197 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
3201 int UtcDaliAnimationAnimateToBooleanAlphaFunction(void)
3203 TestApplication application;
3205 Actor actor = Actor::New();
3207 // Register a boolean property
3208 const bool startValue(false);
3209 Property::Index index = actor.RegisterProperty( "test-property", startValue );
3210 Stage::GetCurrent().Add(actor);
3211 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
3213 // Build the animation
3214 float durationSeconds(2.0f);
3215 Animation animation = Animation::New(durationSeconds);
3216 const bool targetValue( !startValue );
3217 animation.AnimateTo(Property(actor, "test-property"), targetValue, AlphaFunctions::EaseOut);
3219 // Start the animation
3222 bool signalReceived(false);
3223 AnimationFinishCheck finishCheck(signalReceived);
3224 animation.FinishedSignal().Connect(&application, finishCheck);
3226 application.SendNotification();
3227 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3229 // We didn't expect the animation to finish yet
3230 application.SendNotification();
3231 finishCheck.CheckSignalNotReceived();
3232 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
3234 application.SendNotification();
3235 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3237 // We did expect the animation to finish
3238 application.SendNotification();
3239 finishCheck.CheckSignalReceived();
3240 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == targetValue );
3242 // Check that nothing has changed after a couple of buffer swaps
3243 application.Render(0);
3244 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == targetValue );
3245 application.Render(0);
3246 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == targetValue );
3248 // Repeat with target value "false"
3249 animation = Animation::New(durationSeconds);
3250 const bool finalValue( !targetValue );
3251 animation.AnimateTo(Property(actor, index), finalValue, AlphaFunctions::EaseOut);
3253 // Start the animation
3256 finishCheck.Reset();
3257 animation.FinishedSignal().Connect(&application, finishCheck);
3259 application.SendNotification();
3260 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3262 // We didn't expect the animation to finish yet
3263 application.SendNotification();
3264 finishCheck.CheckSignalNotReceived();
3265 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == targetValue );
3267 application.SendNotification();
3268 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3270 // We did expect the animation to finish
3271 application.SendNotification();
3272 finishCheck.CheckSignalReceived();
3273 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
3275 // Check that nothing has changed after a couple of buffer swaps
3276 application.Render(0);
3277 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
3278 application.Render(0);
3279 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
3283 int UtcDaliAnimationAnimateToBooleanTimePeriod(void)
3285 TestApplication application;
3287 Actor actor = Actor::New();
3289 // Register a boolean property
3290 bool startValue(false);
3291 Property::Index index = actor.RegisterProperty( "test-property", startValue );
3292 Stage::GetCurrent().Add(actor);
3293 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
3295 // Build the animation
3296 float durationSeconds(2.0f);
3297 Animation animation = Animation::New(durationSeconds);
3298 bool finalValue( !startValue );
3299 float animatorDurationSeconds(durationSeconds * 0.5f);
3300 animation.AnimateTo( Property(actor, index),
3302 TimePeriod( animatorDurationSeconds ) );
3304 // Start the animation
3307 bool signalReceived(false);
3308 AnimationFinishCheck finishCheck(signalReceived);
3309 animation.FinishedSignal().Connect(&application, finishCheck);
3311 application.SendNotification();
3312 application.Render(static_cast<unsigned int>(animatorDurationSeconds*950.0f)/* 95% animator progress */);
3314 // We didn't expect the animation to finish yet
3315 application.SendNotification();
3316 finishCheck.CheckSignalNotReceived();
3317 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
3319 application.SendNotification();
3320 application.Render(static_cast<unsigned int>(animatorDurationSeconds*50.0f) + 1u/*just beyond the animator duration*/);
3322 // We didn't expect the animation to finish yet...
3323 application.SendNotification();
3324 finishCheck.CheckSignalNotReceived();
3326 // ...however we should have reached the final value
3327 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
3329 application.SendNotification();
3330 application.Render(static_cast<unsigned int>(animatorDurationSeconds*1000.0f)/*just beyond the animation duration*/);
3332 // We did expect the animation to finish
3333 application.SendNotification();
3334 finishCheck.CheckSignalReceived();
3335 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
3337 // Check that nothing has changed after a couple of buffer swaps
3338 application.Render(0);
3339 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
3340 application.Render(0);
3341 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
3345 int UtcDaliAnimationAnimateToBooleanAlphaFunctionTimePeriod(void)
3347 TestApplication application;
3349 Actor actor = Actor::New();
3351 // Register a boolean property
3352 bool startValue(false);
3353 Property::Index index = actor.RegisterProperty( "test-property", startValue );
3354 Stage::GetCurrent().Add(actor);
3355 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
3357 // Build the animation
3358 float durationSeconds(2.0f);
3359 Animation animation = Animation::New(durationSeconds);
3360 bool finalValue( !startValue );
3361 float animatorDurationSeconds(durationSeconds * 0.5f);
3362 animation.AnimateTo( Property(actor, index),
3364 AlphaFunctions::Linear,
3365 TimePeriod( animatorDurationSeconds ) );
3367 // Start the animation
3370 bool signalReceived(false);
3371 AnimationFinishCheck finishCheck(signalReceived);
3372 animation.FinishedSignal().Connect(&application, finishCheck);
3374 application.SendNotification();
3375 application.Render(static_cast<unsigned int>(animatorDurationSeconds*950.0f)/* 95% animator progress */);
3377 // We didn't expect the animation to finish yet
3378 application.SendNotification();
3379 finishCheck.CheckSignalNotReceived();
3380 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
3382 application.SendNotification();
3383 application.Render(static_cast<unsigned int>(animatorDurationSeconds*50.0f) + 1u/*just beyond the animator duration*/);
3385 // We didn't expect the animation to finish yet...
3386 application.SendNotification();
3387 finishCheck.CheckSignalNotReceived();
3389 // ...however we should have reached the final value
3390 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
3392 application.SendNotification();
3393 application.Render(static_cast<unsigned int>(animatorDurationSeconds*1000.0f)/*just beyond the animation duration*/);
3395 // We did expect the animation to finish
3396 application.SendNotification();
3397 finishCheck.CheckSignalReceived();
3398 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
3400 // Check that nothing has changed after a couple of buffer swaps
3401 application.Render(0);
3402 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
3403 application.Render(0);
3404 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
3408 int UtcDaliAnimationAnimateToFloat(void)
3410 TestApplication application;
3412 Actor actor = Actor::New();
3414 // Register a float property
3415 float startValue(10.0f);
3416 Property::Index index = actor.RegisterProperty( "test-property", startValue );
3417 Stage::GetCurrent().Add(actor);
3418 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
3420 // Build the animation
3421 float durationSeconds(2.0f);
3422 Animation animation = Animation::New(durationSeconds);
3423 float targetValue(50.0f);
3424 float relativeValue(targetValue - startValue);
3425 animation.AnimateTo(Property(actor, "test-property"), targetValue);
3427 float ninetyFivePercentProgress(startValue + relativeValue*0.95f);
3429 // Start the animation
3432 bool signalReceived(false);
3433 AnimationFinishCheck finishCheck(signalReceived);
3434 animation.FinishedSignal().Connect(&application, finishCheck);
3436 application.SendNotification();
3437 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3439 // We didn't expect the animation to finish yet
3440 application.SendNotification();
3441 finishCheck.CheckSignalNotReceived();
3442 DALI_TEST_EQUALS( actor.GetProperty<float>(index), ninetyFivePercentProgress, TEST_LOCATION );
3444 application.SendNotification();
3445 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3447 // We did expect the animation to finish
3448 application.SendNotification();
3449 finishCheck.CheckSignalReceived();
3450 DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
3454 int UtcDaliAnimationAnimateToFloatAlphaFunction(void)
3456 TestApplication application;
3458 Actor actor = Actor::New();
3460 // Register a float property
3461 float startValue(10.0f);
3462 Property::Index index = actor.RegisterProperty( "test-property", startValue );
3463 Stage::GetCurrent().Add(actor);
3464 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
3466 // Build the animation
3467 float durationSeconds(1.0f);
3468 Animation animation = Animation::New(durationSeconds);
3469 float targetValue(90.0f);
3470 float relativeValue(targetValue - startValue);
3471 animation.AnimateTo(Property(actor, index), targetValue, AlphaFunctions::EaseOut);
3473 float ninetyFivePercentProgress(startValue + relativeValue*0.95f);
3475 // Start the animation
3478 bool signalReceived(false);
3479 AnimationFinishCheck finishCheck(signalReceived);
3480 animation.FinishedSignal().Connect(&application, finishCheck);
3482 application.SendNotification();
3483 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3485 // We didn't expect the animation to finish yet
3486 application.SendNotification();
3487 finishCheck.CheckSignalNotReceived();
3489 // The position should have moved more, than with a linear alpha function
3490 float current(actor.GetProperty<float>(index));
3491 DALI_TEST_CHECK( current > ninetyFivePercentProgress );
3493 application.SendNotification();
3494 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3496 // We did expect the animation to finish
3497 application.SendNotification();
3498 finishCheck.CheckSignalReceived();
3499 DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
3503 int UtcDaliAnimationAnimateToFloatTimePeriod(void)
3505 TestApplication application;
3507 Actor actor = Actor::New();
3509 // Register a float property
3510 float startValue(10.0f);
3511 Property::Index index = actor.RegisterProperty( "test-property", startValue );
3512 Stage::GetCurrent().Add(actor);
3513 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
3515 // Build the animation
3516 float durationSeconds(1.0f);
3517 Animation animation = Animation::New(durationSeconds);
3518 float targetValue(30.0f);
3519 float relativeValue(targetValue - startValue);
3521 animation.AnimateTo(Property(actor, index),
3523 TimePeriod(delay, durationSeconds - delay));
3525 // Start the animation
3528 bool signalReceived(false);
3529 AnimationFinishCheck finishCheck(signalReceived);
3530 animation.FinishedSignal().Connect(&application, finishCheck);
3532 application.SendNotification();
3533 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
3535 // We didn't expect the animation to finish yet
3536 application.SendNotification();
3537 finishCheck.CheckSignalNotReceived();
3538 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
3540 application.SendNotification();
3541 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
3543 // We didn't expect the animation to finish yet
3544 application.SendNotification();
3545 finishCheck.CheckSignalNotReceived();
3546 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
3548 application.SendNotification();
3549 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
3551 // We did expect the animation to finish
3552 application.SendNotification();
3553 finishCheck.CheckSignalReceived();
3554 DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
3558 int UtcDaliAnimationAnimateToFloatAlphaFunctionTimePeriod(void)
3560 TestApplication application;
3562 Actor actor = Actor::New();
3564 // Register a float property
3565 float startValue(10.0f);
3566 Property::Index index = actor.RegisterProperty( "test-property", startValue );
3567 Stage::GetCurrent().Add(actor);
3568 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
3570 // Build the animation
3571 float durationSeconds(1.0f);
3572 Animation animation = Animation::New(durationSeconds);
3573 float targetValue(30.0f);
3574 float relativeValue(targetValue - startValue);
3576 animation.AnimateTo(Property(actor, index),
3578 AlphaFunctions::Linear,
3579 TimePeriod(delay, durationSeconds - delay));
3581 // Start the animation
3584 bool signalReceived(false);
3585 AnimationFinishCheck finishCheck(signalReceived);
3586 animation.FinishedSignal().Connect(&application, finishCheck);
3588 application.SendNotification();
3589 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
3591 // We didn't expect the animation to finish yet
3592 application.SendNotification();
3593 finishCheck.CheckSignalNotReceived();
3594 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
3596 application.SendNotification();
3597 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
3599 // We didn't expect the animation to finish yet
3600 application.SendNotification();
3601 finishCheck.CheckSignalNotReceived();
3602 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
3604 application.SendNotification();
3605 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
3607 // We did expect the animation to finish
3608 application.SendNotification();
3609 finishCheck.CheckSignalReceived();
3610 DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
3614 int UtcDaliAnimationAnimateToInteger(void)
3616 TestApplication application;
3618 Actor actor = Actor::New();
3620 // Register an integer property
3622 Property::Index index = actor.RegisterProperty( "test-property", startValue );
3623 Stage::GetCurrent().Add(actor);
3624 DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
3626 // Build the animation
3627 float durationSeconds(2.0f);
3628 Animation animation = Animation::New(durationSeconds);
3629 int targetValue(50);
3630 int relativeValue(targetValue - startValue);
3631 animation.AnimateTo(Property(actor, "test-property"), targetValue);
3633 int ninetyFivePercentProgress(static_cast<int>(startValue + relativeValue*0.95f + 0.5f));
3635 // Start the animation
3638 bool signalReceived(false);
3639 AnimationFinishCheck finishCheck(signalReceived);
3640 animation.FinishedSignal().Connect(&application, finishCheck);
3642 application.SendNotification();
3643 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3645 // We didn't expect the animation to finish yet
3646 application.SendNotification();
3647 finishCheck.CheckSignalNotReceived();
3648 DALI_TEST_EQUALS( actor.GetProperty<int>(index), ninetyFivePercentProgress, TEST_LOCATION );
3650 application.SendNotification();
3651 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3653 // We did expect the animation to finish
3654 application.SendNotification();
3655 finishCheck.CheckSignalReceived();
3656 DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
3660 int UtcDaliAnimationAnimateToIntegerAlphaFunction(void)
3662 TestApplication application;
3664 Actor actor = Actor::New();
3666 // Register an integer property
3668 Property::Index index = actor.RegisterProperty( "test-property", startValue );
3669 Stage::GetCurrent().Add(actor);
3670 DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
3672 // Build the animation
3673 float durationSeconds(1.0f);
3674 Animation animation = Animation::New(durationSeconds);
3675 int targetValue(90);
3676 int relativeValue(targetValue - startValue);
3677 animation.AnimateTo(Property(actor, index), targetValue, AlphaFunctions::EaseOut);
3679 int ninetyFivePercentProgress(static_cast<int>(startValue + relativeValue*0.95f + 0.5f));
3681 // Start the animation
3684 bool signalReceived(false);
3685 AnimationFinishCheck finishCheck(signalReceived);
3686 animation.FinishedSignal().Connect(&application, finishCheck);
3688 application.SendNotification();
3689 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3691 // We didn't expect the animation to finish yet
3692 application.SendNotification();
3693 finishCheck.CheckSignalNotReceived();
3695 // The position should have moved more, than with a linear alpha function
3696 int current(actor.GetProperty<int>(index));
3697 DALI_TEST_CHECK( current > ninetyFivePercentProgress );
3699 application.SendNotification();
3700 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3702 // We did expect the animation to finish
3703 application.SendNotification();
3704 finishCheck.CheckSignalReceived();
3705 DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
3709 int UtcDaliAnimationAnimateToIntegerTimePeriod(void)
3711 TestApplication application;
3713 Actor actor = Actor::New();
3715 // Register an integer property
3717 Property::Index index = actor.RegisterProperty( "test-property", startValue );
3718 Stage::GetCurrent().Add(actor);
3719 DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
3721 // Build the animation
3722 float durationSeconds(1.0f);
3723 Animation animation = Animation::New(durationSeconds);
3724 int targetValue(30);
3725 int relativeValue(targetValue - startValue);
3727 animation.AnimateTo(Property(actor, index),
3729 TimePeriod(delay, durationSeconds - delay));
3731 // Start the animation
3734 bool signalReceived(false);
3735 AnimationFinishCheck finishCheck(signalReceived);
3736 animation.FinishedSignal().Connect(&application, finishCheck);
3738 application.SendNotification();
3739 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
3741 // We didn't expect the animation to finish yet
3742 application.SendNotification();
3743 finishCheck.CheckSignalNotReceived();
3744 DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
3746 application.SendNotification();
3747 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
3749 // We didn't expect the animation to finish yet
3750 application.SendNotification();
3751 finishCheck.CheckSignalNotReceived();
3752 DALI_TEST_EQUALS( actor.GetProperty<int>(index), static_cast<int>(startValue+(relativeValue*0.5f)+0.5f), TEST_LOCATION );
3754 application.SendNotification();
3755 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
3757 // We did expect the animation to finish
3758 application.SendNotification();
3759 finishCheck.CheckSignalReceived();
3760 DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
3764 int UtcDaliAnimationAnimateToIntegerAlphaFunctionTimePeriod(void)
3766 TestApplication application;
3768 Actor actor = Actor::New();
3770 // Register an integer property
3772 Property::Index index = actor.RegisterProperty( "test-property", startValue );
3773 Stage::GetCurrent().Add(actor);
3774 DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
3776 // Build the animation
3777 float durationSeconds(1.0f);
3778 Animation animation = Animation::New(durationSeconds);
3779 int targetValue(30);
3780 int relativeValue(targetValue - startValue);
3782 animation.AnimateTo(Property(actor, index),
3784 AlphaFunctions::Linear,
3785 TimePeriod(delay, durationSeconds - delay));
3787 // Start the animation
3790 bool signalReceived(false);
3791 AnimationFinishCheck finishCheck(signalReceived);
3792 animation.FinishedSignal().Connect(&application, finishCheck);
3794 application.SendNotification();
3795 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
3797 // We didn't expect the animation to finish yet
3798 application.SendNotification();
3799 finishCheck.CheckSignalNotReceived();
3800 DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
3802 application.SendNotification();
3803 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
3805 // We didn't expect the animation to finish yet
3806 application.SendNotification();
3807 finishCheck.CheckSignalNotReceived();
3808 DALI_TEST_EQUALS( actor.GetProperty<int>(index), static_cast<int>(startValue+(relativeValue*0.5f)+0.5f), TEST_LOCATION );
3810 application.SendNotification();
3811 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
3813 // We did expect the animation to finish
3814 application.SendNotification();
3815 finishCheck.CheckSignalReceived();
3816 DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
3820 int UtcDaliAnimationAnimateToVector2(void)
3822 TestApplication application;
3824 Actor actor = Actor::New();
3826 // Register a Vector2 property
3827 Vector2 startValue(-50.0f, -50.0f);
3828 Property::Index index = actor.RegisterProperty( "test-property", startValue );
3829 Stage::GetCurrent().Add(actor);
3830 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
3832 // Build the animation
3833 float durationSeconds(2.0f);
3834 Animation animation = Animation::New(durationSeconds);
3835 Vector2 targetValue(50.0f, 50.0f);
3836 Vector2 relativeValue(targetValue - startValue);
3837 animation.AnimateTo(Property(actor, index), targetValue);
3839 Vector2 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
3841 // Start the animation
3844 bool signalReceived(false);
3845 AnimationFinishCheck finishCheck(signalReceived);
3846 animation.FinishedSignal().Connect(&application, finishCheck);
3848 application.SendNotification();
3849 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3851 // We didn't expect the animation to finish yet
3852 application.SendNotification();
3853 finishCheck.CheckSignalNotReceived();
3854 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), ninetyFivePercentProgress, TEST_LOCATION );
3856 application.SendNotification();
3857 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3859 // We did expect the animation to finish
3860 application.SendNotification();
3861 finishCheck.CheckSignalReceived();
3862 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
3866 int UtcDaliAnimationAnimateToVector2AlphaFunction(void)
3868 TestApplication application;
3870 Actor actor = Actor::New();
3872 // Register a Vector2 property
3873 Vector2 startValue(1000.0f, 1000.0f);
3874 Property::Index index = actor.RegisterProperty( "test-property", startValue );
3875 Stage::GetCurrent().Add(actor);
3876 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
3878 // Build the animation
3879 float durationSeconds(1.0f);
3880 Animation animation = Animation::New(durationSeconds);
3881 Vector2 targetValue(9000.0f, 9000.0f);
3882 Vector2 relativeValue(targetValue - startValue);
3883 animation.AnimateTo(Property(actor, "test-property"), targetValue, AlphaFunctions::EaseOut);
3885 Vector2 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
3887 // Start the animation
3890 bool signalReceived(false);
3891 AnimationFinishCheck finishCheck(signalReceived);
3892 animation.FinishedSignal().Connect(&application, finishCheck);
3894 application.SendNotification();
3895 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3897 // We didn't expect the animation to finish yet
3898 application.SendNotification();
3899 finishCheck.CheckSignalNotReceived();
3901 // The position should have moved more, than with a linear alpha function
3902 Vector2 current(actor.GetProperty<Vector2>(index));
3903 DALI_TEST_CHECK( current.x > ninetyFivePercentProgress.x );
3904 DALI_TEST_CHECK( current.y > ninetyFivePercentProgress.y );
3906 application.SendNotification();
3907 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3909 // We did expect the animation to finish
3910 application.SendNotification();
3911 finishCheck.CheckSignalReceived();
3912 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
3916 int UtcDaliAnimationAnimateToVector2TimePeriod(void)
3918 TestApplication application;
3920 Actor actor = Actor::New();
3922 // Register a Vector2 property
3923 Vector2 startValue(10.0f, 10.0f);
3924 Property::Index index = actor.RegisterProperty( "test-property", startValue );
3925 Stage::GetCurrent().Add(actor);
3926 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
3928 // Build the animation
3929 float durationSeconds(1.0f);
3930 Animation animation = Animation::New(durationSeconds);
3931 Vector2 targetValue(-10.0f, 20.0f);
3932 Vector2 relativeValue(targetValue - startValue);
3934 animation.AnimateTo(Property(actor, index),
3936 TimePeriod(delay, durationSeconds - delay));
3938 // Start the animation
3941 bool signalReceived(false);
3942 AnimationFinishCheck finishCheck(signalReceived);
3943 animation.FinishedSignal().Connect(&application, finishCheck);
3945 application.SendNotification();
3946 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
3948 // We didn't expect the animation to finish yet
3949 application.SendNotification();
3950 finishCheck.CheckSignalNotReceived();
3951 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
3953 application.SendNotification();
3954 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
3956 // We didn't expect the animation to finish yet
3957 application.SendNotification();
3958 finishCheck.CheckSignalNotReceived();
3959 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
3961 application.SendNotification();
3962 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
3964 // We did expect the animation to finish
3965 application.SendNotification();
3966 finishCheck.CheckSignalReceived();
3967 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
3971 int UtcDaliAnimationAnimateToVector2AlphaFunctionTimePeriod(void)
3973 TestApplication application;
3975 Actor actor = Actor::New();
3977 // Register a Vector2 property
3978 Vector2 startValue(10.0f, 10.0f);
3979 Property::Index index = actor.RegisterProperty( "test-property", startValue );
3980 Stage::GetCurrent().Add(actor);
3981 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
3983 // Build the animation
3984 float durationSeconds(1.0f);
3985 Animation animation = Animation::New(durationSeconds);
3986 Vector2 targetValue(30.0f, 30.0f);
3987 Vector2 relativeValue(targetValue - startValue);
3989 animation.AnimateTo(Property(actor, index),
3991 AlphaFunctions::Linear,
3992 TimePeriod(delay, durationSeconds - delay));
3994 // Start the animation
3997 bool signalReceived(false);
3998 AnimationFinishCheck finishCheck(signalReceived);
3999 animation.FinishedSignal().Connect(&application, finishCheck);
4001 application.SendNotification();
4002 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
4004 // We didn't expect the animation to finish yet
4005 application.SendNotification();
4006 finishCheck.CheckSignalNotReceived();
4007 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
4009 application.SendNotification();
4010 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
4012 // We didn't expect the animation to finish yet
4013 application.SendNotification();
4014 finishCheck.CheckSignalNotReceived();
4015 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
4017 application.SendNotification();
4018 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
4020 // We did expect the animation to finish
4021 application.SendNotification();
4022 finishCheck.CheckSignalReceived();
4023 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
4027 int UtcDaliAnimationAnimateToVector3(void)
4029 TestApplication application;
4031 Actor actor = Actor::New();
4033 // Register a Vector3 property
4034 Vector3 startValue(-50.0f, -50.0f, -50.0f);
4035 Property::Index index = actor.RegisterProperty( "test-property", startValue );
4036 Stage::GetCurrent().Add(actor);
4037 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
4039 // Build the animation
4040 float durationSeconds(2.0f);
4041 Animation animation = Animation::New(durationSeconds);
4042 Vector3 targetValue(50.0f, 50.0f, 50.0f);
4043 Vector3 relativeValue(targetValue - startValue);
4044 animation.AnimateTo(Property(actor, index), targetValue);
4046 Vector3 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
4048 // Start the animation
4051 bool signalReceived(false);
4052 AnimationFinishCheck finishCheck(signalReceived);
4053 animation.FinishedSignal().Connect(&application, finishCheck);
4055 application.SendNotification();
4056 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
4058 // We didn't expect the animation to finish yet
4059 application.SendNotification();
4060 finishCheck.CheckSignalNotReceived();
4061 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), ninetyFivePercentProgress, TEST_LOCATION );
4063 application.SendNotification();
4064 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
4066 // We did expect the animation to finish
4067 application.SendNotification();
4068 finishCheck.CheckSignalReceived();
4069 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
4073 int UtcDaliAnimationAnimateToVector3AlphaFunction(void)
4075 TestApplication application;
4077 Actor actor = Actor::New();
4079 // Register a Vector3 property
4080 Vector3 startValue(1000.0f, 1000.0f, 1000.0f);
4081 Property::Index index = actor.RegisterProperty( "test-property", startValue );
4082 Stage::GetCurrent().Add(actor);
4083 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
4085 // Build the animation
4086 float durationSeconds(1.0f);
4087 Animation animation = Animation::New(durationSeconds);
4088 Vector3 targetValue(9000.0f, 9000.0f, 9000.0f);
4089 Vector3 relativeValue(targetValue - startValue);
4090 animation.AnimateTo(Property(actor, index), targetValue, AlphaFunctions::EaseOut);
4092 Vector3 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
4094 // Start the animation
4097 bool signalReceived(false);
4098 AnimationFinishCheck finishCheck(signalReceived);
4099 animation.FinishedSignal().Connect(&application, finishCheck);
4101 application.SendNotification();
4102 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
4104 // We didn't expect the animation to finish yet
4105 application.SendNotification();
4106 finishCheck.CheckSignalNotReceived();
4108 // The position should have moved more, than with a linear alpha function
4109 Vector3 current(actor.GetProperty<Vector3>(index));
4110 DALI_TEST_CHECK( current.x > ninetyFivePercentProgress.x );
4111 DALI_TEST_CHECK( current.y > ninetyFivePercentProgress.y );
4112 DALI_TEST_CHECK( current.z > ninetyFivePercentProgress.z );
4114 application.SendNotification();
4115 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
4117 // We did expect the animation to finish
4118 application.SendNotification();
4119 finishCheck.CheckSignalReceived();
4120 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
4124 int UtcDaliAnimationAnimateToVector3TimePeriod(void)
4126 TestApplication application;
4128 Actor actor = Actor::New();
4130 // Register a Vector3 property
4131 Vector3 startValue(10.0f, 10.0f, 10.0f);
4132 Property::Index index = actor.RegisterProperty( "test-property", startValue );
4133 Stage::GetCurrent().Add(actor);
4134 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
4136 // Build the animation
4137 float durationSeconds(1.0f);
4138 Animation animation = Animation::New(durationSeconds);
4139 Vector3 targetValue(-10.0f, 20.0f, 100.0f);
4140 Vector3 relativeValue(targetValue - startValue);
4142 animation.AnimateTo(Property(actor, index),
4144 TimePeriod(delay, durationSeconds - delay));
4146 // Start the animation
4149 bool signalReceived(false);
4150 AnimationFinishCheck finishCheck(signalReceived);
4151 animation.FinishedSignal().Connect(&application, finishCheck);
4153 application.SendNotification();
4154 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
4156 // We didn't expect the animation to finish yet
4157 application.SendNotification();
4158 finishCheck.CheckSignalNotReceived();
4159 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
4161 application.SendNotification();
4162 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
4164 // We didn't expect the animation to finish yet
4165 application.SendNotification();
4166 finishCheck.CheckSignalNotReceived();
4167 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
4169 application.SendNotification();
4170 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
4172 // We did expect the animation to finish
4173 application.SendNotification();
4174 finishCheck.CheckSignalReceived();
4175 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
4179 int UtcDaliAnimationAnimateToVector3AlphaFunctionTimePeriod(void)
4181 TestApplication application;
4183 Actor actor = Actor::New();
4185 // Register a Vector3 property
4186 Vector3 startValue(10.0f, 10.0f, 10.0f);
4187 Property::Index index = actor.RegisterProperty( "test-property", startValue );
4188 Stage::GetCurrent().Add(actor);
4189 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
4191 // Build the animation
4192 float durationSeconds(1.0f);
4193 Animation animation = Animation::New(durationSeconds);
4194 Vector3 targetValue(30.0f, 30.0f, 30.0f);
4195 Vector3 relativeValue(targetValue - startValue);
4197 animation.AnimateTo(Property(actor, "test-property"),
4199 AlphaFunctions::Linear,
4200 TimePeriod(delay, durationSeconds - delay));
4202 // Start the animation
4205 bool signalReceived(false);
4206 AnimationFinishCheck finishCheck(signalReceived);
4207 animation.FinishedSignal().Connect(&application, finishCheck);
4209 application.SendNotification();
4210 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
4212 // We didn't expect the animation to finish yet
4213 application.SendNotification();
4214 finishCheck.CheckSignalNotReceived();
4215 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
4217 application.SendNotification();
4218 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
4220 // We didn't expect the animation to finish yet
4221 application.SendNotification();
4222 finishCheck.CheckSignalNotReceived();
4223 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
4225 application.SendNotification();
4226 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
4228 // We did expect the animation to finish
4229 application.SendNotification();
4230 finishCheck.CheckSignalReceived();
4231 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
4235 int UtcDaliAnimationAnimateToVector3Component(void)
4237 TestApplication application;
4239 Actor actor = Actor::New();
4241 // Register a Vector3 property
4242 Vector3 startValue(10.0f, 10.0f, 10.0f);
4243 Property::Index index = actor.RegisterProperty( "test-property", startValue );
4244 Stage::GetCurrent().Add(actor);
4245 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
4247 // Build the animation
4248 float durationSeconds(1.0f);
4249 Animation animation = Animation::New(durationSeconds);
4250 Vector3 targetValue(30.0f, 30.0f, 10.0f);
4251 Vector3 relativeValue(targetValue - startValue);
4253 animation.AnimateTo(Property(actor, "test-property", 0),
4255 AlphaFunctions::Linear,
4256 TimePeriod(delay, durationSeconds - delay));
4257 animation.AnimateTo(Property(actor, index, 1),
4259 AlphaFunctions::Linear,
4260 TimePeriod(delay, durationSeconds - delay));
4262 // Start the animation
4265 bool signalReceived(false);
4266 AnimationFinishCheck finishCheck(signalReceived);
4267 animation.FinishedSignal().Connect(&application, finishCheck);
4269 application.SendNotification();
4270 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
4272 // We didn't expect the animation to finish yet
4273 application.SendNotification();
4274 finishCheck.CheckSignalNotReceived();
4275 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
4277 application.SendNotification();
4278 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
4280 // We didn't expect the animation to finish yet
4281 application.SendNotification();
4282 finishCheck.CheckSignalNotReceived();
4283 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
4285 application.SendNotification();
4286 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
4288 // We did expect the animation to finish
4289 application.SendNotification();
4290 finishCheck.CheckSignalReceived();
4291 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
4295 int UtcDaliAnimationAnimateToVector4(void)
4297 TestApplication application;
4299 Actor actor = Actor::New();
4301 // Register a Vector4 property
4302 Vector4 startValue(-50.0f, -40.0f, -30.0f, -20.0f);
4303 Property::Index index = actor.RegisterProperty( "test-property", startValue );
4304 Stage::GetCurrent().Add(actor);
4305 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
4307 // Build the animation
4308 float durationSeconds(2.0f);
4309 Animation animation = Animation::New(durationSeconds);
4310 Vector4 targetValue(50.0f, 50.0f, 50.0f, 50.0f);
4311 Vector4 relativeValue(targetValue - startValue);
4312 animation.AnimateTo(Property(actor, index), targetValue);
4314 Vector4 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
4316 // Start the animation
4319 bool signalReceived(false);
4320 AnimationFinishCheck finishCheck(signalReceived);
4321 animation.FinishedSignal().Connect(&application, finishCheck);
4323 application.SendNotification();
4324 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
4326 // We didn't expect the animation to finish yet
4327 application.SendNotification();
4328 finishCheck.CheckSignalNotReceived();
4329 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), ninetyFivePercentProgress, TEST_LOCATION );
4331 application.SendNotification();
4332 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
4334 // We did expect the animation to finish
4335 application.SendNotification();
4336 finishCheck.CheckSignalReceived();
4337 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
4341 int UtcDaliAnimationAnimateToVector4AlphaFunction(void)
4343 TestApplication application;
4345 Actor actor = Actor::New();
4347 // Register a Vector4 property
4348 Vector4 startValue(1000.0f, 1000.0f, 1000.0f, 1000.0f);
4349 Property::Index index = actor.RegisterProperty( "test-property", startValue );
4350 Stage::GetCurrent().Add(actor);
4351 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
4353 // Build the animation
4354 float durationSeconds(1.0f);
4355 Animation animation = Animation::New(durationSeconds);
4356 Vector4 targetValue(9000.0f, 9000.0f, 9000.0f, 9000.0f);
4357 Vector4 relativeValue(targetValue - startValue);
4358 animation.AnimateTo(Property(actor, index), targetValue, AlphaFunctions::EaseOut);
4360 Vector4 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
4362 // Start the animation
4365 bool signalReceived(false);
4366 AnimationFinishCheck finishCheck(signalReceived);
4367 animation.FinishedSignal().Connect(&application, finishCheck);
4369 application.SendNotification();
4370 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
4372 // We didn't expect the animation to finish yet
4373 application.SendNotification();
4374 finishCheck.CheckSignalNotReceived();
4376 // The position should have moved more, than with a linear alpha function
4377 Vector4 current(actor.GetProperty<Vector4>(index));
4378 DALI_TEST_CHECK( current.x > ninetyFivePercentProgress.x );
4379 DALI_TEST_CHECK( current.y > ninetyFivePercentProgress.y );
4380 DALI_TEST_CHECK( current.z > ninetyFivePercentProgress.z );
4381 DALI_TEST_CHECK( current.w > ninetyFivePercentProgress.w );
4383 application.SendNotification();
4384 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
4386 // We did expect the animation to finish
4387 application.SendNotification();
4388 finishCheck.CheckSignalReceived();
4389 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
4393 int UtcDaliAnimationAnimateToVector4TimePeriod(void)
4395 TestApplication application;
4397 Actor actor = Actor::New();
4399 // Register a Vector4 property
4400 Vector4 startValue(10.0f, 10.0f, 10.0f, 10.0f);
4401 Property::Index index = actor.RegisterProperty( "test-property", startValue );
4402 Stage::GetCurrent().Add(actor);
4403 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, VECTOR4_EPSILON, TEST_LOCATION );
4405 // Build the animation
4406 float durationSeconds(1.0f);
4407 Animation animation = Animation::New(durationSeconds);
4408 Vector4 targetValue(-10.0f, 20.0f, 100.0f, 100.0f);
4409 Vector4 relativeValue(targetValue - startValue);
4411 animation.AnimateTo(Property(actor, index),
4413 TimePeriod(delay, durationSeconds - delay));
4415 // Start the animation
4418 bool signalReceived(false);
4419 AnimationFinishCheck finishCheck(signalReceived);
4420 animation.FinishedSignal().Connect(&application, finishCheck);
4422 application.SendNotification();
4423 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
4425 // We didn't expect the animation to finish yet
4426 application.SendNotification();
4427 finishCheck.CheckSignalNotReceived();
4428 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, VECTOR4_EPSILON, TEST_LOCATION );
4430 application.SendNotification();
4431 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
4433 // We didn't expect the animation to finish yet
4434 application.SendNotification();
4435 finishCheck.CheckSignalNotReceived();
4436 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue+(relativeValue*0.5f), VECTOR4_EPSILON, TEST_LOCATION );
4438 application.SendNotification();
4439 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
4441 // We did expect the animation to finish
4442 application.SendNotification();
4443 finishCheck.CheckSignalReceived();
4444 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, VECTOR4_EPSILON, TEST_LOCATION );
4448 int UtcDaliAnimationAnimateToVector4AlphaFunctionTimePeriod(void)
4450 TestApplication application;
4452 Actor actor = Actor::New();
4454 // Register a Vector4 property
4455 Vector4 startValue(10.0f, 10.0f, 10.0f, 10.0f);
4456 Property::Index index = actor.RegisterProperty( "test-property", startValue );
4457 Stage::GetCurrent().Add(actor);
4458 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
4460 // Build the animation
4461 float durationSeconds(1.0f);
4462 Animation animation = Animation::New(durationSeconds);
4463 Vector4 targetValue(30.0f, 30.0f, 30.0f, 30.0f);
4464 Vector4 relativeValue(targetValue - startValue);
4466 animation.AnimateTo(Property(actor, index),
4468 AlphaFunctions::Linear,
4469 TimePeriod(delay, durationSeconds - delay));
4471 // Start the animation
4474 bool signalReceived(false);
4475 AnimationFinishCheck finishCheck(signalReceived);
4476 animation.FinishedSignal().Connect(&application, finishCheck);
4478 application.SendNotification();
4479 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
4481 // We didn't expect the animation to finish yet
4482 application.SendNotification();
4483 finishCheck.CheckSignalNotReceived();
4484 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
4486 application.SendNotification();
4487 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
4489 // We didn't expect the animation to finish yet
4490 application.SendNotification();
4491 finishCheck.CheckSignalNotReceived();
4492 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
4494 application.SendNotification();
4495 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
4497 // We did expect the animation to finish
4498 application.SendNotification();
4499 finishCheck.CheckSignalReceived();
4500 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
4504 int UtcDaliAnimationAnimateToActorParentOrigin(void)
4506 TestApplication application;
4508 Actor actor = Actor::New();
4509 Stage::GetCurrent().Add(actor);
4510 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::TOP_LEFT, TEST_LOCATION );
4512 // Build the animation
4513 float durationSeconds(1.0f);
4514 Animation animation = Animation::New(durationSeconds);
4515 Vector3 targetParentOrigin(ParentOrigin::BOTTOM_RIGHT);
4519 animation.AnimateTo( Property(actor, Actor::PARENT_ORIGIN), targetParentOrigin );
4521 catch (Dali::DaliException& e)
4523 tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
4524 DALI_TEST_ASSERT(e, "IsPropertyAnimatable(index)", TEST_LOCATION);
4529 int UtcDaliAnimationAnimateToActorParentOriginX(void)
4531 TestApplication application;
4533 Actor actor = Actor::New();
4534 Stage::GetCurrent().Add(actor);
4535 float startValue(0.0f);
4536 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin().x, startValue, TEST_LOCATION );
4537 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::PARENT_ORIGIN_X), startValue, TEST_LOCATION );
4539 // Build the animation
4540 float durationSeconds(1.0f);
4541 Animation animation = Animation::New(durationSeconds);
4542 float targetX(1.0f);
4546 animation.AnimateTo( Property(actor, Actor::PARENT_ORIGIN_X), targetX );
4548 catch (Dali::DaliException& e)
4550 tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
4551 DALI_TEST_ASSERT(e, "IsPropertyAnimatable(index)", TEST_LOCATION);
4556 int UtcDaliAnimationAnimateToActorParentOriginY(void)
4558 TestApplication application;
4560 Actor actor = Actor::New();
4561 Stage::GetCurrent().Add(actor);
4562 float startValue(0.0f);
4563 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin().y, startValue, TEST_LOCATION );
4564 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::PARENT_ORIGIN_Y), startValue, TEST_LOCATION );
4566 // Build the animation
4567 float durationSeconds(1.0f);
4568 Animation animation = Animation::New(durationSeconds);
4569 float targetY(1.0f);
4573 animation.AnimateTo( Property(actor, Actor::PARENT_ORIGIN_Y), targetY );
4575 catch (Dali::DaliException& e)
4577 tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
4578 DALI_TEST_ASSERT(e, "IsPropertyAnimatable(index)", TEST_LOCATION);
4583 int UtcDaliAnimationAnimateToActorParentOriginZ(void)
4585 TestApplication application;
4587 Actor actor = Actor::New();
4588 Stage::GetCurrent().Add(actor);
4589 float startValue(0.5f);
4590 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin().z, startValue, TEST_LOCATION );
4591 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::PARENT_ORIGIN_Z), startValue, TEST_LOCATION );
4593 // Build the animation
4594 float durationSeconds(1.0f);
4595 Animation animation = Animation::New(durationSeconds);
4596 float targetZ(1.0f);
4600 animation.AnimateTo( Property(actor, Actor::PARENT_ORIGIN_Z), targetZ );
4602 catch (Dali::DaliException& e)
4604 tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
4605 DALI_TEST_ASSERT(e, "IsPropertyAnimatable(index)", TEST_LOCATION);
4610 int UtcDaliAnimationAnimateToActorAnchorPoint(void)
4612 TestApplication application;
4614 Actor actor = Actor::New();
4615 Stage::GetCurrent().Add(actor);
4616 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), AnchorPoint::CENTER, TEST_LOCATION );
4618 // Build the animation
4619 float durationSeconds(1.0f);
4620 Animation animation = Animation::New(durationSeconds);
4621 Vector3 targetAnchorPoint(AnchorPoint::TOP_LEFT);
4625 animation.AnimateTo( Property(actor, Actor::ANCHOR_POINT), targetAnchorPoint);
4627 catch (Dali::DaliException& e)
4629 tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
4630 DALI_TEST_ASSERT(e, "IsPropertyAnimatable(index)", TEST_LOCATION);
4635 int UtcDaliAnimationAnimateToActorAnchorPointX(void)
4637 TestApplication application;
4639 Actor actor = Actor::New();
4640 Stage::GetCurrent().Add(actor);
4641 float startValue(0.5f);
4642 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint().x, startValue, TEST_LOCATION );
4643 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::ANCHOR_POINT_X), startValue, TEST_LOCATION );
4645 // Build the animation
4646 float durationSeconds(1.0f);
4647 Animation animation = Animation::New(durationSeconds);
4648 float targetX(1.0f);
4652 animation.AnimateTo( Property(actor, Actor::ANCHOR_POINT_X), targetX );
4654 catch (Dali::DaliException& e)
4656 tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
4657 DALI_TEST_ASSERT(e, "IsPropertyAnimatable(index)", TEST_LOCATION);
4662 int UtcDaliAnimationAnimateToActorAnchorPointY(void)
4664 TestApplication application;
4666 Actor actor = Actor::New();
4667 Stage::GetCurrent().Add(actor);
4668 float startValue(0.5f);
4669 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint().y, startValue, TEST_LOCATION );
4670 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::ANCHOR_POINT_Y), startValue, TEST_LOCATION );
4672 // Build the animation
4673 float durationSeconds(1.0f);
4674 Animation animation = Animation::New(durationSeconds);
4675 float targetY(0.0f);
4679 animation.AnimateTo( Property(actor, Actor::ANCHOR_POINT_Y), targetY );
4681 catch (Dali::DaliException& e)
4683 tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
4684 DALI_TEST_ASSERT(e, "IsPropertyAnimatable(index)", TEST_LOCATION);
4689 int UtcDaliAnimationAnimateToActorAnchorPointZ(void)
4691 TestApplication application;
4693 Actor actor = Actor::New();
4694 Stage::GetCurrent().Add(actor);
4695 float startValue(0.5f);
4696 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint().z, startValue, TEST_LOCATION );
4697 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::ANCHOR_POINT_Z), startValue, TEST_LOCATION );
4699 // Build the animation
4700 float durationSeconds(1.0f);
4701 Animation animation = Animation::New(durationSeconds);
4702 float targetZ(100.0f);
4706 animation.AnimateTo( Property(actor, Actor::ANCHOR_POINT_Z), targetZ );
4708 catch (Dali::DaliException& e)
4710 tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
4711 DALI_TEST_ASSERT(e, "IsPropertyAnimatable(index)", TEST_LOCATION);
4716 int UtcDaliAnimationAnimateToActorSize(void)
4718 TestApplication application;
4720 Actor actor = Actor::New();
4721 Stage::GetCurrent().Add(actor);
4722 DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
4724 // Build the animation
4725 float durationSeconds(1.0f);
4726 Animation animation = Animation::New(durationSeconds);
4727 Vector3 targetSize(100.0f, 100.0f, 100.0f);
4728 animation.AnimateTo( Property(actor, Actor::SIZE), targetSize );
4730 Vector3 ninetyNinePercentProgress(targetSize * 0.99f);
4732 // Start the animation
4735 bool signalReceived(false);
4736 AnimationFinishCheck finishCheck(signalReceived);
4737 animation.FinishedSignal().Connect(&application, finishCheck);
4739 application.SendNotification();
4740 application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
4742 // We didn't expect the animation to finish yet
4743 application.SendNotification();
4744 finishCheck.CheckSignalNotReceived();
4745 DALI_TEST_EQUALS( actor.GetCurrentSize(), ninetyNinePercentProgress, TEST_LOCATION );
4747 application.SendNotification();
4748 application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
4750 // We did expect the animation to finish
4751 application.SendNotification();
4752 finishCheck.CheckSignalReceived();
4753 DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION );
4756 finishCheck.Reset();
4757 actor.SetSize(Vector3::ZERO);
4758 application.SendNotification();
4759 application.Render(0);
4760 DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
4762 // Repeat with a different (ease-in) alpha function
4763 animation = Animation::New(durationSeconds);
4764 animation.AnimateTo( Property(actor, Actor::SIZE), targetSize, AlphaFunctions::EaseIn);
4765 animation.FinishedSignal().Connect(&application, finishCheck);
4768 application.SendNotification();
4769 application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
4771 // We didn't expect the animation to finish yet
4772 application.SendNotification();
4773 finishCheck.CheckSignalNotReceived();
4775 // The size should have travelled less, than with a linear alpha function
4776 Vector3 current(actor.GetCurrentSize());
4777 DALI_TEST_CHECK( current.x > 0.0f );
4778 DALI_TEST_CHECK( current.y > 0.0f );
4779 DALI_TEST_CHECK( current.z > 0.0f );
4780 DALI_TEST_CHECK( current.x < ninetyNinePercentProgress.x );
4781 DALI_TEST_CHECK( current.y < ninetyNinePercentProgress.y );
4782 DALI_TEST_CHECK( current.z < ninetyNinePercentProgress.z );
4784 application.SendNotification();
4785 application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
4787 // We did expect the animation to finish
4788 application.SendNotification();
4789 finishCheck.CheckSignalReceived();
4790 DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION );
4793 finishCheck.Reset();
4794 actor.SetSize(Vector3::ZERO);
4795 application.SendNotification();
4796 application.Render(0);
4797 DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
4799 // Repeat with a delay
4801 animation = Animation::New(durationSeconds);
4802 animation.AnimateTo( Property(actor, Actor::SIZE), targetSize, AlphaFunctions::Linear, TimePeriod(delay, durationSeconds - delay));
4803 animation.FinishedSignal().Connect(&application, finishCheck);
4806 application.SendNotification();
4807 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
4809 // We didn't expect the animation to finish yet
4810 application.SendNotification();
4811 finishCheck.CheckSignalNotReceived();
4812 DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
4814 application.SendNotification();
4815 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
4817 // We did expect the animation to finish
4818 application.SendNotification();
4819 finishCheck.CheckSignalReceived();
4820 DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION );
4824 int UtcDaliAnimationAnimateToActorSizeWidth(void)
4826 TestApplication application;
4828 Actor actor = Actor::New();
4829 Stage::GetCurrent().Add(actor);
4830 float startValue(0.0f);
4831 DALI_TEST_EQUALS( actor.GetCurrentSize().width, startValue, TEST_LOCATION );
4832 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SIZE_WIDTH), startValue, TEST_LOCATION );
4834 // Build the animation
4835 float durationSeconds(1.0f);
4836 Animation animation = Animation::New(durationSeconds);
4837 float targetWidth(10.0f);
4838 animation.AnimateTo( Property(actor, Actor::SIZE_WIDTH), targetWidth );
4840 float fiftyPercentProgress(startValue + (targetWidth - startValue)*0.5f);
4842 // Start the animation
4845 bool signalReceived(false);
4846 AnimationFinishCheck finishCheck(signalReceived);
4847 animation.FinishedSignal().Connect(&application, finishCheck);
4849 application.SendNotification();
4850 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
4852 // We didn't expect the animation to finish yet
4853 application.SendNotification();
4854 finishCheck.CheckSignalNotReceived();
4855 DALI_TEST_EQUALS( actor.GetCurrentSize().width, fiftyPercentProgress, TEST_LOCATION );
4856 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SIZE_WIDTH), fiftyPercentProgress, TEST_LOCATION );
4858 application.SendNotification();
4859 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
4861 // We did expect the animation to finish
4862 application.SendNotification();
4863 finishCheck.CheckSignalReceived();
4864 DALI_TEST_EQUALS( actor.GetCurrentSize().width, targetWidth, TEST_LOCATION );
4865 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SIZE_WIDTH), targetWidth, TEST_LOCATION );
4869 int UtcDaliAnimationAnimateToActorSizeHeight(void)
4871 TestApplication application;
4873 Actor actor = Actor::New();
4874 Stage::GetCurrent().Add(actor);
4875 float startValue(0.0f);
4876 DALI_TEST_EQUALS( actor.GetCurrentSize().height, startValue, TEST_LOCATION );
4877 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SIZE_HEIGHT), startValue, TEST_LOCATION );
4879 // Build the animation
4880 float durationSeconds(1.0f);
4881 Animation animation = Animation::New(durationSeconds);
4882 float targetHeight(-10.0f);
4883 animation.AnimateTo( Property(actor, Actor::SIZE_HEIGHT), targetHeight );
4885 float fiftyPercentProgress(startValue + (targetHeight - startValue)*0.5f);
4887 // Start the animation
4890 bool signalReceived(false);
4891 AnimationFinishCheck finishCheck(signalReceived);
4892 animation.FinishedSignal().Connect(&application, finishCheck);
4894 application.SendNotification();
4895 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
4897 // We didn't expect the animation to finish yet
4898 application.SendNotification();
4899 finishCheck.CheckSignalNotReceived();
4900 DALI_TEST_EQUALS( actor.GetCurrentSize().height, fiftyPercentProgress, TEST_LOCATION );
4901 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SIZE_HEIGHT), fiftyPercentProgress, TEST_LOCATION );
4903 application.SendNotification();
4904 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
4906 // We did expect the animation to finish
4907 application.SendNotification();
4908 finishCheck.CheckSignalReceived();
4909 DALI_TEST_EQUALS( actor.GetCurrentSize().height, targetHeight, TEST_LOCATION );
4910 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SIZE_HEIGHT), targetHeight, TEST_LOCATION );
4914 int UtcDaliAnimationAnimateToActorSizeDepth(void)
4916 TestApplication application;
4918 Actor actor = Actor::New();
4919 Stage::GetCurrent().Add(actor);
4920 float startValue(0.0f);
4921 DALI_TEST_EQUALS( actor.GetCurrentSize().depth, startValue, TEST_LOCATION );
4922 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SIZE_DEPTH), startValue, TEST_LOCATION );
4924 // Build the animation
4925 float durationSeconds(1.0f);
4926 Animation animation = Animation::New(durationSeconds);
4927 float targetDepth(-10.0f);
4928 animation.AnimateTo( Property(actor, Actor::SIZE_DEPTH), targetDepth );
4930 float fiftyPercentProgress(startValue + (targetDepth - startValue)*0.5f);
4932 // Start the animation
4935 bool signalReceived(false);
4936 AnimationFinishCheck finishCheck(signalReceived);
4937 animation.FinishedSignal().Connect(&application, finishCheck);
4939 application.SendNotification();
4940 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
4942 // We didn't expect the animation to finish yet
4943 application.SendNotification();
4944 finishCheck.CheckSignalNotReceived();
4945 DALI_TEST_EQUALS( actor.GetCurrentSize().depth, fiftyPercentProgress, TEST_LOCATION );
4946 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SIZE_DEPTH), fiftyPercentProgress, TEST_LOCATION );
4948 application.SendNotification();
4949 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
4951 // We did expect the animation to finish
4952 application.SendNotification();
4953 finishCheck.CheckSignalReceived();
4954 DALI_TEST_EQUALS( actor.GetCurrentSize().depth, targetDepth, TEST_LOCATION );
4955 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SIZE_DEPTH), targetDepth, TEST_LOCATION );
4959 int UtcDaliAnimationAnimateToActorPosition(void)
4961 TestApplication application;
4963 Actor actor = Actor::New();
4964 Stage::GetCurrent().Add(actor);
4965 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
4967 // Build the animation
4968 float durationSeconds(1.0f);
4969 Animation animation = Animation::New(durationSeconds);
4970 Vector3 targetPosition(200.0f, 200.0f, 200.0f);
4971 animation.AnimateTo(Property(actor, Actor::POSITION), targetPosition);
4973 Vector3 seventyFivePercentProgress(targetPosition * 0.75f);
4975 // Start the animation
4978 bool signalReceived(false);
4979 AnimationFinishCheck finishCheck(signalReceived);
4980 animation.FinishedSignal().Connect(&application, finishCheck);
4982 application.SendNotification();
4983 application.Render(static_cast<unsigned int>(durationSeconds*750.0f)/* 75% progress */);
4985 // We didn't expect the animation to finish yet
4986 application.SendNotification();
4987 finishCheck.CheckSignalNotReceived();
4988 DALI_TEST_EQUALS( actor.GetCurrentPosition(), seventyFivePercentProgress, TEST_LOCATION );
4990 application.SendNotification();
4991 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
4993 // We did expect the animation to finish
4994 application.SendNotification();
4995 finishCheck.CheckSignalReceived();
4996 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
5000 int UtcDaliAnimationAnimateToActorPositionX(void)
5002 TestApplication application;
5004 Actor actor = Actor::New();
5005 Stage::GetCurrent().Add(actor);
5006 float startValue(0.0f);
5007 DALI_TEST_EQUALS( actor.GetCurrentPosition().x, startValue, TEST_LOCATION );
5008 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_X), startValue, TEST_LOCATION );
5009 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_Y), startValue, TEST_LOCATION );
5010 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_Z), startValue, TEST_LOCATION );
5012 // Build the animation
5013 float durationSeconds(1.0f);
5014 Animation animation = Animation::New(durationSeconds);
5015 float targetX(1.0f);
5016 animation.AnimateTo( Property(actor, Actor::POSITION_X), targetX );
5018 float fiftyPercentProgress(startValue + (targetX - startValue)*0.5f);
5020 // Start the animation
5023 bool signalReceived(false);
5024 AnimationFinishCheck finishCheck(signalReceived);
5025 animation.FinishedSignal().Connect(&application, finishCheck);
5027 application.SendNotification();
5028 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
5030 // We didn't expect the animation to finish yet
5031 application.SendNotification();
5032 finishCheck.CheckSignalNotReceived();
5033 DALI_TEST_EQUALS( actor.GetCurrentPosition().x, fiftyPercentProgress, TEST_LOCATION );
5034 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_X), fiftyPercentProgress, TEST_LOCATION );
5035 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_Y), startValue, TEST_LOCATION );
5036 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_Z), startValue, TEST_LOCATION );
5038 application.SendNotification();
5039 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
5041 // We did expect the animation to finish
5042 application.SendNotification();
5043 finishCheck.CheckSignalReceived();
5044 DALI_TEST_EQUALS( actor.GetCurrentPosition().x, targetX, TEST_LOCATION );
5045 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_X), targetX, TEST_LOCATION );
5046 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_Y), startValue, TEST_LOCATION );
5047 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_Z), startValue, TEST_LOCATION );
5051 int UtcDaliAnimationAnimateToActorPositionY(void)
5053 TestApplication application;
5055 Actor actor = Actor::New();
5056 Stage::GetCurrent().Add(actor);
5057 float startValue(0.0f);
5058 DALI_TEST_EQUALS( actor.GetCurrentPosition().y, startValue, TEST_LOCATION );
5059 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_X), startValue, TEST_LOCATION );
5060 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_Y), startValue, TEST_LOCATION );
5061 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_Z), startValue, TEST_LOCATION );
5063 // Build the animation
5064 float durationSeconds(1.0f);
5065 Animation animation = Animation::New(durationSeconds);
5066 float targetY(10.0f);
5067 animation.AnimateTo( Property(actor, Actor::POSITION_Y), targetY );
5069 float fiftyPercentProgress(startValue + (targetY - startValue)*0.5f);
5071 // Start the animation
5074 bool signalReceived(false);
5075 AnimationFinishCheck finishCheck(signalReceived);
5076 animation.FinishedSignal().Connect(&application, finishCheck);
5078 application.SendNotification();
5079 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
5081 // We didn't expect the animation to finish yet
5082 application.SendNotification();
5083 finishCheck.CheckSignalNotReceived();
5084 DALI_TEST_EQUALS( actor.GetCurrentPosition().y, fiftyPercentProgress, TEST_LOCATION );
5085 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_X), startValue, TEST_LOCATION );
5086 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_Y), fiftyPercentProgress, TEST_LOCATION );
5087 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_Z), startValue, TEST_LOCATION );
5089 application.SendNotification();
5090 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
5092 // We did expect the animation to finish
5093 application.SendNotification();
5094 finishCheck.CheckSignalReceived();
5095 DALI_TEST_EQUALS( actor.GetCurrentPosition().y, targetY, TEST_LOCATION );
5096 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_X), startValue, TEST_LOCATION );
5097 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_Y), targetY, TEST_LOCATION );
5098 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_Z), startValue, TEST_LOCATION );
5102 int UtcDaliAnimationAnimateToActorPositionZ(void)
5104 TestApplication application;
5106 Actor actor = Actor::New();
5107 Stage::GetCurrent().Add(actor);
5108 float startValue(0.0f);
5109 DALI_TEST_EQUALS( actor.GetCurrentPosition().z, startValue, TEST_LOCATION );
5110 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_X), startValue, TEST_LOCATION );
5111 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_Y), startValue, TEST_LOCATION );
5112 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_Z), startValue, TEST_LOCATION );
5114 // Build the animation
5115 float durationSeconds(1.0f);
5116 Animation animation = Animation::New(durationSeconds);
5117 float targetZ(-5.0f);
5118 animation.AnimateTo( Property(actor, Actor::POSITION_Z), targetZ );
5120 float fiftyPercentProgress(startValue + (targetZ - startValue)*0.5f);
5122 // Start the animation
5125 bool signalReceived(false);
5126 AnimationFinishCheck finishCheck(signalReceived);
5127 animation.FinishedSignal().Connect(&application, finishCheck);
5129 application.SendNotification();
5130 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
5132 // We didn't expect the animation to finish yet
5133 application.SendNotification();
5134 finishCheck.CheckSignalNotReceived();
5135 DALI_TEST_EQUALS( actor.GetCurrentPosition().z, fiftyPercentProgress, TEST_LOCATION );
5136 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_X), startValue, TEST_LOCATION );
5137 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_Y), startValue, TEST_LOCATION );
5138 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_Z), fiftyPercentProgress, TEST_LOCATION );
5140 application.SendNotification();
5141 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
5143 // We did expect the animation to finish
5144 application.SendNotification();
5145 finishCheck.CheckSignalReceived();
5146 DALI_TEST_EQUALS( actor.GetCurrentPosition().z, targetZ, TEST_LOCATION );
5147 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_X), startValue, TEST_LOCATION );
5148 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_Y), startValue, TEST_LOCATION );
5149 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_Z), targetZ, TEST_LOCATION );
5153 int UtcDaliAnimationAnimateToActorPositionAlphaFunction(void)
5155 TestApplication application;
5157 Actor actor = Actor::New();
5158 Stage::GetCurrent().Add(actor);
5159 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
5161 // Build the animation
5162 float durationSeconds(1.0f);
5163 Animation animation = Animation::New(durationSeconds);
5164 Vector3 targetPosition(200.0f, 200.0f, 200.0f);
5165 animation.AnimateTo(Property(actor, Actor::POSITION), targetPosition, AlphaFunctions::EaseIn);
5167 Vector3 seventyFivePercentProgress(targetPosition * 0.75f);
5169 // Start the animation
5172 bool signalReceived(false);
5173 AnimationFinishCheck finishCheck(signalReceived);
5174 animation.FinishedSignal().Connect(&application, finishCheck);
5176 application.SendNotification();
5177 application.Render(static_cast<unsigned int>(durationSeconds*750.0f)/* 75% progress */);
5179 // We didn't expect the animation to finish yet
5180 application.SendNotification();
5181 finishCheck.CheckSignalNotReceived();
5183 // The position should have moved less, than with a linear alpha function
5184 Vector3 current(actor.GetCurrentPosition());
5185 DALI_TEST_CHECK( current.x > Vector3::ZERO.x );
5186 DALI_TEST_CHECK( current.y > Vector3::ZERO.y );
5187 DALI_TEST_CHECK( current.z > Vector3::ZERO.z );
5188 DALI_TEST_CHECK( current.x < seventyFivePercentProgress.x );
5189 DALI_TEST_CHECK( current.y < seventyFivePercentProgress.y );
5190 DALI_TEST_CHECK( current.z < seventyFivePercentProgress.z );
5192 application.SendNotification();
5193 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
5195 // We did expect the animation to finish
5196 application.SendNotification();
5197 finishCheck.CheckSignalReceived();
5198 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
5202 int UtcDaliAnimationAnimateToActorPositionTimePeriod(void)
5204 TestApplication application;
5206 Actor actor = Actor::New();
5207 Stage::GetCurrent().Add(actor);
5208 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
5210 // Build the animation
5211 float durationSeconds(1.0f);
5212 Animation animation = Animation::New(durationSeconds);
5213 Vector3 targetPosition(200.0f, 200.0f, 200.0f);
5215 animation.AnimateTo( Property(actor, Actor::POSITION),
5217 TimePeriod( delay, durationSeconds - delay ) );
5219 Vector3 seventyFivePercentProgress(targetPosition * 0.75f);
5221 // Start the animation
5224 bool signalReceived(false);
5225 AnimationFinishCheck finishCheck(signalReceived);
5226 animation.FinishedSignal().Connect(&application, finishCheck);
5228 application.SendNotification();
5229 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
5231 // We didn't expect the animation to finish yet
5232 application.SendNotification();
5233 finishCheck.CheckSignalNotReceived();
5234 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
5236 application.SendNotification();
5237 application.Render(static_cast<unsigned int>(durationSeconds*500.0f*0.75)/* 7/8 animation progress, 3/4 animator progress */);
5239 // We didn't expect the animation to finish yet
5240 application.SendNotification();
5241 finishCheck.CheckSignalNotReceived();
5242 DALI_TEST_EQUALS( actor.GetCurrentPosition(), seventyFivePercentProgress, TEST_LOCATION );
5244 application.SendNotification();
5245 application.Render(static_cast<unsigned int>(durationSeconds*500.0f*0.25) + 1u/*just beyond the animation duration*/);
5247 // We did expect the animation to finish
5248 application.SendNotification();
5249 finishCheck.CheckSignalReceived();
5250 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
5254 int UtcDaliAnimationAnimateToActorPositionAlphaFunctionTimePeriod(void)
5256 TestApplication application;
5258 Actor actor = Actor::New();
5259 Stage::GetCurrent().Add(actor);
5260 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
5262 // Build the animation
5263 float durationSeconds(1.0f);
5264 Animation animation = Animation::New(durationSeconds);
5265 Vector3 targetPosition(200.0f, 200.0f, 200.0f);
5267 animation.AnimateTo( Property(actor, Actor::POSITION),
5269 AlphaFunctions::Linear,
5270 TimePeriod( delay, durationSeconds - delay ) );
5272 Vector3 seventyFivePercentProgress(targetPosition * 0.75f);
5274 // Start the animation
5277 bool signalReceived(false);
5278 AnimationFinishCheck finishCheck(signalReceived);
5279 animation.FinishedSignal().Connect(&application, finishCheck);
5281 application.SendNotification();
5282 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
5284 // We didn't expect the animation to finish yet
5285 application.SendNotification();
5286 finishCheck.CheckSignalNotReceived();
5287 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
5289 application.SendNotification();
5290 application.Render(static_cast<unsigned int>(durationSeconds*500.0f*0.75)/* 7/8 animation progress, 3/4 animator progress */);
5292 // We didn't expect the animation to finish yet
5293 application.SendNotification();
5294 finishCheck.CheckSignalNotReceived();
5295 DALI_TEST_EQUALS( actor.GetCurrentPosition(), seventyFivePercentProgress, TEST_LOCATION );
5297 application.SendNotification();
5298 application.Render(static_cast<unsigned int>(durationSeconds*500.0f*0.25) + 1u/*just beyond the animation duration*/);
5300 // We did expect the animation to finish
5301 application.SendNotification();
5302 finishCheck.CheckSignalReceived();
5303 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
5307 int UtcDaliAnimationAnimateToActorRotationAngleAxis(void)
5309 TestApplication application;
5311 Actor actor = Actor::New();
5312 actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
5313 Stage::GetCurrent().Add(actor);
5314 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5316 // Build the animation
5317 float durationSeconds(1.0f);
5318 Animation animation = Animation::New(durationSeconds);
5319 Degree targetRotationDegrees(90.0f);
5320 Radian targetRotationRadians(targetRotationDegrees);
5321 animation.AnimateTo( Property(actor, Actor::ROTATION), AngleAxis(targetRotationRadians, Vector3::YAXIS) );
5323 // Start the animation
5326 bool signalReceived(false);
5327 AnimationFinishCheck finishCheck(signalReceived);
5328 animation.FinishedSignal().Connect(&application, finishCheck);
5330 application.SendNotification();
5331 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
5333 // We didn't expect the animation to finish yet
5334 application.SendNotification();
5335 finishCheck.CheckSignalNotReceived();
5336 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.25f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5338 application.SendNotification();
5339 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
5341 // We didn't expect the animation to finish yet
5342 application.SendNotification();
5343 finishCheck.CheckSignalNotReceived();
5344 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.5f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5346 application.SendNotification();
5347 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
5349 // We didn't expect the animation to finish yet
5350 application.SendNotification();
5351 finishCheck.CheckSignalNotReceived();
5352 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.75f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5354 application.SendNotification();
5355 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
5357 // We did expect the animation to finish
5358 application.SendNotification();
5359 finishCheck.CheckSignalReceived();
5360 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5364 int UtcDaliAnimationAnimateToActorRotationQuaternion(void)
5366 TestApplication application;
5368 Actor actor = Actor::New();
5369 actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
5370 Stage::GetCurrent().Add(actor);
5371 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5373 // Build the animation
5374 float durationSeconds(1.0f);
5375 Animation animation = Animation::New(durationSeconds);
5376 Degree targetRotationDegrees(90.0f);
5377 Radian targetRotationRadians(targetRotationDegrees);
5378 Quaternion targetRotation(targetRotationRadians, Vector3::YAXIS);
5379 animation.AnimateTo( Property(actor, Actor::ROTATION), targetRotation );
5381 // Start the animation
5384 bool signalReceived(false);
5385 AnimationFinishCheck finishCheck(signalReceived);
5386 animation.FinishedSignal().Connect(&application, finishCheck);
5388 application.SendNotification();
5389 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
5391 // We didn't expect the animation to finish yet
5392 application.SendNotification();
5393 finishCheck.CheckSignalNotReceived();
5394 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.25f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5396 application.SendNotification();
5397 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
5399 // We didn't expect the animation to finish yet
5400 application.SendNotification();
5401 finishCheck.CheckSignalNotReceived();
5402 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.5f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5404 application.SendNotification();
5405 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
5407 // We didn't expect the animation to finish yet
5408 application.SendNotification();
5409 finishCheck.CheckSignalNotReceived();
5410 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.75f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5412 application.SendNotification();
5413 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
5415 // We did expect the animation to finish
5416 application.SendNotification();
5417 finishCheck.CheckSignalReceived();
5418 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5422 int UtcDaliAnimationAnimateToActorRotationAlphaFunction(void)
5424 TestApplication application;
5426 Actor actor = Actor::New();
5427 actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
5428 Stage::GetCurrent().Add(actor);
5429 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5431 // Build the animation
5432 float durationSeconds(1.0f);
5433 Animation animation = Animation::New(durationSeconds);
5434 Degree targetRotationDegrees(90.0f);
5435 Radian targetRotationRadians(targetRotationDegrees);
5436 animation.AnimateTo( Property(actor, Actor::ROTATION), AngleAxis(targetRotationDegrees, Vector3::YAXIS), AlphaFunctions::EaseIn);
5438 // Start the animation
5441 bool signalReceived(false);
5442 AnimationFinishCheck finishCheck(signalReceived);
5443 animation.FinishedSignal().Connect(&application, finishCheck);
5445 application.SendNotification();
5446 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
5448 // We didn't expect the animation to finish yet
5449 application.SendNotification();
5450 finishCheck.CheckSignalNotReceived();
5451 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(0.25f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5453 application.SendNotification();
5454 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
5456 // We didn't expect the animation to finish yet
5457 application.SendNotification();
5458 finishCheck.CheckSignalNotReceived();
5459 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(0.5f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5461 application.SendNotification();
5462 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
5464 // We didn't expect the animation to finish yet
5465 application.SendNotification();
5466 finishCheck.CheckSignalNotReceived();
5467 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(0.75f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5469 application.SendNotification();
5470 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
5472 // We did expect the animation to finish
5473 application.SendNotification();
5474 finishCheck.CheckSignalReceived();
5475 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5479 int UtcDaliAnimationAnimateToActorRotationTimePeriod(void)
5481 TestApplication application;
5483 Actor actor = Actor::New();
5484 actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
5485 Stage::GetCurrent().Add(actor);
5486 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5488 // Build the animation
5489 float durationSeconds(1.0f);
5490 Animation animation = Animation::New(durationSeconds);
5491 Degree targetRotationDegrees(90.0f);
5492 Radian targetRotationRadians(targetRotationDegrees);
5494 animation.AnimateTo( Property(actor, Actor::ROTATION), AngleAxis(targetRotationDegrees, Vector3::YAXIS), TimePeriod(delay, durationSeconds - delay));
5496 // Start the animation
5499 bool signalReceived(false);
5500 AnimationFinishCheck finishCheck(signalReceived);
5501 animation.FinishedSignal().Connect(&application, finishCheck);
5503 application.SendNotification();
5504 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
5506 // We didn't expect the animation to finish yet
5507 application.SendNotification();
5508 finishCheck.CheckSignalNotReceived();
5509 float progress = max(0.0f, 0.25f - delay) / (1.0f - delay);
5510 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * progress, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5512 application.SendNotification();
5513 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
5515 // We didn't expect the animation to finish yet
5516 application.SendNotification();
5517 finishCheck.CheckSignalNotReceived();
5518 progress = max(0.0f, 0.5f - delay) / (1.0f - delay);
5519 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * progress, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5521 application.SendNotification();
5522 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
5524 // We didn't expect the animation to finish yet
5525 application.SendNotification();
5526 finishCheck.CheckSignalNotReceived();
5527 progress = max(0.0f, 0.75f - delay) / (1.0f - delay);
5528 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * progress, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5530 application.SendNotification();
5531 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
5533 // We did expect the animation to finish
5534 application.SendNotification();
5535 finishCheck.CheckSignalReceived();
5536 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5540 int UtcDaliAnimationAnimateToActorRotationAlphaFunctionTimePeriod(void)
5542 TestApplication application;
5544 Actor actor = Actor::New();
5545 actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
5546 Stage::GetCurrent().Add(actor);
5547 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5549 // Build the animation
5550 float durationSeconds(1.0f);
5551 Animation animation = Animation::New(durationSeconds);
5552 Degree targetRotationDegrees(90.0f);
5553 Radian targetRotationRadians(targetRotationDegrees);
5555 animation.AnimateTo( Property(actor, Actor::ROTATION), AngleAxis(targetRotationDegrees, Vector3::YAXIS), AlphaFunctions::EaseIn, TimePeriod(delay, durationSeconds - delay));
5557 // Start the animation
5560 bool signalReceived(false);
5561 AnimationFinishCheck finishCheck(signalReceived);
5562 animation.FinishedSignal().Connect(&application, finishCheck);
5564 application.SendNotification();
5565 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
5567 // We didn't expect the animation to finish yet
5568 application.SendNotification();
5569 finishCheck.CheckSignalNotReceived();
5570 float progress = max(0.0f, 0.25f - delay) / (1.0f - delay);
5571 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5573 application.SendNotification();
5574 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
5576 // We didn't expect the animation to finish yet
5577 application.SendNotification();
5578 finishCheck.CheckSignalNotReceived();
5579 progress = max(0.0f, 0.5f - delay) / (1.0f - delay);
5580 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5582 application.SendNotification();
5583 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
5585 // We didn't expect the animation to finish yet
5586 application.SendNotification();
5587 finishCheck.CheckSignalNotReceived();
5588 progress = max(0.0f, 0.75f - delay) / (1.0f - delay);
5589 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5591 application.SendNotification();
5592 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
5594 // We did expect the animation to finish
5595 application.SendNotification();
5596 finishCheck.CheckSignalReceived();
5597 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5601 int UtcDaliAnimationAnimateToActorScale(void)
5603 TestApplication application;
5605 Actor actor = Actor::New();
5606 Stage::GetCurrent().Add(actor);
5607 DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
5609 // Build the animation
5610 float durationSeconds(1.0f);
5611 Animation animation = Animation::New(durationSeconds);
5612 Vector3 targetScale(2.0f, 2.0f, 2.0f);
5613 animation.AnimateTo( Property(actor, Actor::SCALE), targetScale );
5615 Vector3 ninetyNinePercentProgress(Vector3::ONE + (targetScale - Vector3::ONE)*0.99f);
5617 // Start the animation
5620 bool signalReceived(false);
5621 AnimationFinishCheck finishCheck(signalReceived);
5622 animation.FinishedSignal().Connect(&application, finishCheck);
5624 application.SendNotification();
5625 application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
5627 // We didn't expect the animation to finish yet
5628 application.SendNotification();
5629 finishCheck.CheckSignalNotReceived();
5630 DALI_TEST_EQUALS( actor.GetCurrentScale(), ninetyNinePercentProgress, TEST_LOCATION );
5632 application.SendNotification();
5633 application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
5635 // We did expect the animation to finish
5636 application.SendNotification();
5637 finishCheck.CheckSignalReceived();
5638 DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
5641 finishCheck.Reset();
5642 actor.SetScale(Vector3::ONE);
5643 application.SendNotification();
5644 application.Render(0);
5645 DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
5647 // Repeat with a different (ease-in) alpha function
5648 animation = Animation::New(durationSeconds);
5649 animation.AnimateTo( Property(actor, Actor::SCALE), targetScale, AlphaFunctions::EaseIn);
5650 animation.FinishedSignal().Connect(&application, finishCheck);
5653 application.SendNotification();
5654 application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
5656 // We didn't expect the animation to finish yet
5657 application.SendNotification();
5658 finishCheck.CheckSignalNotReceived();
5660 // The scale should have grown less, than with a linear alpha function
5661 Vector3 current(actor.GetCurrentScale());
5662 DALI_TEST_CHECK( current.x > 1.0f );
5663 DALI_TEST_CHECK( current.y > 1.0f );
5664 DALI_TEST_CHECK( current.z > 1.0f );
5665 DALI_TEST_CHECK( current.x < ninetyNinePercentProgress.x );
5666 DALI_TEST_CHECK( current.y < ninetyNinePercentProgress.y );
5667 DALI_TEST_CHECK( current.z < ninetyNinePercentProgress.z );
5669 application.SendNotification();
5670 application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
5672 // We did expect the animation to finish
5673 application.SendNotification();
5674 finishCheck.CheckSignalReceived();
5675 DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
5678 finishCheck.Reset();
5679 actor.SetScale(Vector3::ONE);
5680 application.SendNotification();
5681 application.Render(0);
5682 DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
5684 // Repeat with a delay
5686 animation = Animation::New(durationSeconds);
5687 animation.AnimateTo( Property(actor, Actor::SCALE), targetScale, AlphaFunctions::Linear, TimePeriod(delay, durationSeconds - delay));
5688 animation.FinishedSignal().Connect(&application, finishCheck);
5691 application.SendNotification();
5692 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
5694 // We didn't expect the animation to finish yet
5695 application.SendNotification();
5696 finishCheck.CheckSignalNotReceived();
5697 DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
5699 application.SendNotification();
5700 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
5702 // We did expect the animation to finish
5703 application.SendNotification();
5704 finishCheck.CheckSignalReceived();
5705 DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
5709 int UtcDaliAnimationAnimateToActorScaleX(void)
5711 TestApplication application;
5713 Actor actor = Actor::New();
5714 Stage::GetCurrent().Add(actor);
5715 float startValue(1.0f);
5716 DALI_TEST_EQUALS( actor.GetCurrentScale().x, startValue, TEST_LOCATION );
5717 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_X), startValue, TEST_LOCATION );
5718 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_Y), startValue, TEST_LOCATION );
5719 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_Z), startValue, TEST_LOCATION );
5721 // Build the animation
5722 float durationSeconds(1.0f);
5723 Animation animation = Animation::New(durationSeconds);
5724 float targetX(10.0f);
5725 animation.AnimateTo( Property(actor, Actor::SCALE_X), targetX );
5727 float fiftyPercentProgress(startValue + (targetX - startValue)*0.5f);
5729 // Start the animation
5732 bool signalReceived(false);
5733 AnimationFinishCheck finishCheck(signalReceived);
5734 animation.FinishedSignal().Connect(&application, finishCheck);
5736 application.SendNotification();
5737 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
5739 // We didn't expect the animation to finish yet
5740 application.SendNotification();
5741 finishCheck.CheckSignalNotReceived();
5742 DALI_TEST_EQUALS( actor.GetCurrentScale().x, fiftyPercentProgress, TEST_LOCATION );
5743 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_X), fiftyPercentProgress, TEST_LOCATION );
5744 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_Y), startValue, TEST_LOCATION );
5745 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_Z), startValue, TEST_LOCATION );
5747 application.SendNotification();
5748 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
5750 // We did expect the animation to finish
5751 application.SendNotification();
5752 finishCheck.CheckSignalReceived();
5753 DALI_TEST_EQUALS( actor.GetCurrentScale().x, targetX, TEST_LOCATION );
5754 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_X), targetX, TEST_LOCATION );
5755 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_Y), startValue, TEST_LOCATION );
5756 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_Z), startValue, TEST_LOCATION );
5760 int UtcDaliAnimationAnimateToActorScaleY(void)
5762 TestApplication application;
5764 Actor actor = Actor::New();
5765 Stage::GetCurrent().Add(actor);
5766 float startValue(1.0f);
5767 DALI_TEST_EQUALS( actor.GetCurrentScale().y, startValue, TEST_LOCATION );
5768 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_X), startValue, TEST_LOCATION );
5769 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_Y), startValue, TEST_LOCATION );
5770 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_Z), startValue, TEST_LOCATION );
5772 // Build the animation
5773 float durationSeconds(1.0f);
5774 Animation animation = Animation::New(durationSeconds);
5775 float targetY(1000.0f);
5776 animation.AnimateTo( Property(actor, Actor::SCALE_Y), targetY );
5778 float fiftyPercentProgress(startValue + (targetY - startValue)*0.5f);
5780 // Start the animation
5783 bool signalReceived(false);
5784 AnimationFinishCheck finishCheck(signalReceived);
5785 animation.FinishedSignal().Connect(&application, finishCheck);
5787 application.SendNotification();
5788 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
5790 // We didn't expect the animation to finish yet
5791 application.SendNotification();
5792 finishCheck.CheckSignalNotReceived();
5793 DALI_TEST_EQUALS( actor.GetCurrentScale().y, fiftyPercentProgress, TEST_LOCATION );
5794 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_X), startValue, TEST_LOCATION );
5795 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_Y), fiftyPercentProgress, TEST_LOCATION );
5796 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_Z), startValue, TEST_LOCATION );
5798 application.SendNotification();
5799 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
5801 // We did expect the animation to finish
5802 application.SendNotification();
5803 finishCheck.CheckSignalReceived();
5804 DALI_TEST_EQUALS( actor.GetCurrentScale().y, targetY, TEST_LOCATION );
5805 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_X), startValue, TEST_LOCATION );
5806 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_Y), targetY, TEST_LOCATION );
5807 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_Z), startValue, TEST_LOCATION );
5811 int UtcDaliAnimationAnimateToActorScaleZ(void)
5813 TestApplication application;
5815 Actor actor = Actor::New();
5816 Stage::GetCurrent().Add(actor);
5817 float startValue(1.0f);
5818 DALI_TEST_EQUALS( actor.GetCurrentScale().z, startValue, TEST_LOCATION );
5819 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_X), startValue, TEST_LOCATION );
5820 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_Y), startValue, TEST_LOCATION );
5821 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_Z), startValue, TEST_LOCATION );
5823 // Build the animation
5824 float durationSeconds(1.0f);
5825 Animation animation = Animation::New(durationSeconds);
5826 float targetZ(-1000.0f);
5827 animation.AnimateTo( Property(actor, Actor::SCALE_Z), targetZ );
5829 float fiftyPercentProgress(startValue + (targetZ - startValue)*0.5f);
5831 // Start the animation
5834 bool signalReceived(false);
5835 AnimationFinishCheck finishCheck(signalReceived);
5836 animation.FinishedSignal().Connect(&application, finishCheck);
5838 application.SendNotification();
5839 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
5841 // We didn't expect the animation to finish yet
5842 application.SendNotification();
5843 finishCheck.CheckSignalNotReceived();
5844 DALI_TEST_EQUALS( actor.GetCurrentScale().z, fiftyPercentProgress, TEST_LOCATION );
5845 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_X), startValue, TEST_LOCATION );
5846 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_Y), startValue, TEST_LOCATION );
5847 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_Z), fiftyPercentProgress, TEST_LOCATION );
5849 application.SendNotification();
5850 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
5852 // We did expect the animation to finish
5853 application.SendNotification();
5854 finishCheck.CheckSignalReceived();
5855 DALI_TEST_EQUALS( actor.GetCurrentScale().z, targetZ, TEST_LOCATION );
5856 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_X), startValue, TEST_LOCATION );
5857 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_Y), startValue, TEST_LOCATION );
5858 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_Z), targetZ, TEST_LOCATION );
5862 int UtcDaliAnimationAnimateToActorColor(void)
5864 TestApplication application;
5866 Actor actor = Actor::New();
5867 Stage::GetCurrent().Add(actor);
5868 DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
5870 // Build the animation
5871 float durationSeconds(1.0f);
5872 Animation animation = Animation::New(durationSeconds);
5873 Vector4 targetColor(Color::RED);
5874 animation.AnimateTo( Property(actor, Actor::COLOR), targetColor );
5876 Vector4 tenPercentProgress(Vector4(1.0f, 0.9f, 0.9f, 1.0f));
5877 Vector4 twentyPercentProgress(Vector4(1.0f, 0.8f, 0.8f, 1.0f));
5879 // Start the animation
5882 bool signalReceived(false);
5883 AnimationFinishCheck finishCheck(signalReceived);
5884 animation.FinishedSignal().Connect(&application, finishCheck);
5886 application.SendNotification();
5887 application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% progress */);
5889 // We didn't expect the animation to finish yet
5890 application.SendNotification();
5891 finishCheck.CheckSignalNotReceived();
5892 DALI_TEST_EQUALS( actor.GetCurrentColor(), tenPercentProgress, TEST_LOCATION );
5894 application.SendNotification();
5895 application.Render(static_cast<unsigned int>(durationSeconds*900.0f) + 1u/*just beyond the animation duration*/);
5897 // We did expect the animation to finish
5898 application.SendNotification();
5899 finishCheck.CheckSignalReceived();
5900 DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION );
5903 finishCheck.Reset();
5904 actor.SetColor(Color::WHITE);
5905 application.SendNotification();
5906 application.Render(0);
5907 DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
5909 // Repeat with a different (ease-in) alpha function
5910 animation = Animation::New(durationSeconds);
5911 animation.AnimateTo( Property(actor, Actor::COLOR), targetColor, AlphaFunctions::EaseIn);
5912 animation.FinishedSignal().Connect(&application, finishCheck);
5915 application.SendNotification();
5916 application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% progress */);
5918 // We didn't expect the animation to finish yet
5919 application.SendNotification();
5920 finishCheck.CheckSignalNotReceived();
5922 // The color should have changed less, than with a linear alpha function
5923 Vector4 current(actor.GetCurrentColor());
5924 DALI_TEST_CHECK( current.x == 1.0f ); // doesn't change
5925 DALI_TEST_CHECK( current.y < 1.0f );
5926 DALI_TEST_CHECK( current.y > tenPercentProgress.y );
5927 DALI_TEST_CHECK( current.z < 1.0f );
5928 DALI_TEST_CHECK( current.z > tenPercentProgress.z );
5929 DALI_TEST_CHECK( current.w == 1.0f ); // doesn't change
5931 application.SendNotification();
5932 application.Render(static_cast<unsigned int>(durationSeconds*900.0f) + 1u/*just beyond the animation duration*/);
5934 // We did expect the animation to finish
5935 application.SendNotification();
5936 finishCheck.CheckSignalReceived();
5937 DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION );
5940 finishCheck.Reset();
5941 actor.SetColor(Color::WHITE);
5942 application.SendNotification();
5943 application.Render(0);
5944 DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
5946 // Repeat with a shorter animator duration
5947 float animatorDuration = 0.5f;
5948 animation = Animation::New(durationSeconds);
5949 animation.AnimateTo( Property(actor, Actor::COLOR), targetColor, AlphaFunctions::Linear, TimePeriod(animatorDuration));
5950 animation.FinishedSignal().Connect(&application, finishCheck);
5953 application.SendNotification();
5954 application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% animation progress, 20% animator progress */);
5956 // We didn't expect the animation to finish yet
5957 application.SendNotification();
5958 finishCheck.CheckSignalNotReceived();
5959 DALI_TEST_EQUALS( actor.GetCurrentColor(), twentyPercentProgress, TEST_LOCATION );
5961 application.SendNotification();
5962 application.Render(static_cast<unsigned int>(durationSeconds*400.0f)/* 50% animation progress, 100% animator progress */);
5964 // We didn't expect the animation to finish yet
5965 application.SendNotification();
5966 finishCheck.CheckSignalNotReceived();
5967 DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION );
5969 application.SendNotification();
5970 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
5972 // We did expect the animation to finish
5973 application.SendNotification();
5974 finishCheck.CheckSignalReceived();
5975 DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION );
5979 int UtcDaliAnimationAnimateToActorColorRed(void)
5981 TestApplication application;
5983 Actor actor = Actor::New();
5984 Stage::GetCurrent().Add(actor);
5985 float startValue(1.0f);
5986 DALI_TEST_EQUALS( actor.GetCurrentColor().r, startValue, TEST_LOCATION );
5987 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
5988 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
5989 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
5990 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), startValue, TEST_LOCATION );
5992 // Build the animation
5993 float durationSeconds(1.0f);
5994 Animation animation = Animation::New(durationSeconds);
5995 float targetRed(0.5f);
5996 animation.AnimateTo( Property(actor, Actor::COLOR_RED), targetRed );
5998 float fiftyPercentProgress(startValue + (targetRed - startValue)*0.5f);
6000 // Start the animation
6003 bool signalReceived(false);
6004 AnimationFinishCheck finishCheck(signalReceived);
6005 animation.FinishedSignal().Connect(&application, finishCheck);
6007 application.SendNotification();
6008 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
6010 // We didn't expect the animation to finish yet
6011 application.SendNotification();
6012 finishCheck.CheckSignalNotReceived();
6013 DALI_TEST_EQUALS( actor.GetCurrentColor().r, fiftyPercentProgress, TEST_LOCATION );
6014 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), fiftyPercentProgress, TEST_LOCATION );
6015 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
6016 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
6017 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), startValue, TEST_LOCATION );
6019 application.SendNotification();
6020 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
6022 // We did expect the animation to finish
6023 application.SendNotification();
6024 finishCheck.CheckSignalReceived();
6025 DALI_TEST_EQUALS( actor.GetCurrentColor().r, targetRed, TEST_LOCATION );
6026 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), targetRed, TEST_LOCATION );
6027 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
6028 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
6029 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), startValue, TEST_LOCATION );
6033 int UtcDaliAnimationAnimateToActorColorGreen(void)
6035 TestApplication application;
6037 Actor actor = Actor::New();
6038 Stage::GetCurrent().Add(actor);
6039 float startValue(1.0f);
6040 DALI_TEST_EQUALS( actor.GetCurrentColor().g, startValue, TEST_LOCATION );
6041 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
6042 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
6043 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
6044 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), startValue, TEST_LOCATION );
6046 // Build the animation
6047 float durationSeconds(1.0f);
6048 Animation animation = Animation::New(durationSeconds);
6049 float targetGreen(0.5f);
6050 animation.AnimateTo( Property(actor, Actor::COLOR_GREEN), targetGreen );
6052 float fiftyPercentProgress(startValue + (targetGreen - startValue)*0.5f);
6054 // Start the animation
6057 bool signalReceived(false);
6058 AnimationFinishCheck finishCheck(signalReceived);
6059 animation.FinishedSignal().Connect(&application, finishCheck);
6061 application.SendNotification();
6062 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
6064 // We didn't expect the animation to finish yet
6065 application.SendNotification();
6066 finishCheck.CheckSignalNotReceived();
6067 DALI_TEST_EQUALS( actor.GetCurrentColor().g, fiftyPercentProgress, TEST_LOCATION );
6068 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
6069 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), fiftyPercentProgress, TEST_LOCATION );
6070 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
6071 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), startValue, TEST_LOCATION );
6073 application.SendNotification();
6074 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
6076 // We did expect the animation to finish
6077 application.SendNotification();
6078 finishCheck.CheckSignalReceived();
6079 DALI_TEST_EQUALS( actor.GetCurrentColor().g, targetGreen, TEST_LOCATION );
6080 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
6081 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), targetGreen, TEST_LOCATION );
6082 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
6083 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), startValue, TEST_LOCATION );
6087 int UtcDaliAnimationAnimateToActorColorBlue(void)
6089 TestApplication application;
6091 Actor actor = Actor::New();
6092 Stage::GetCurrent().Add(actor);
6093 float startValue(1.0f);
6094 DALI_TEST_EQUALS( actor.GetCurrentColor().b, startValue, TEST_LOCATION );
6095 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
6096 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
6097 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
6098 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), startValue, TEST_LOCATION );
6100 // Build the animation
6101 float durationSeconds(1.0f);
6102 Animation animation = Animation::New(durationSeconds);
6103 float targetBlue(0.5f);
6104 animation.AnimateTo( Property(actor, Actor::COLOR_BLUE), targetBlue );
6106 float fiftyPercentProgress(startValue + (targetBlue - startValue)*0.5f);
6108 // Start the animation
6111 bool signalReceived(false);
6112 AnimationFinishCheck finishCheck(signalReceived);
6113 animation.FinishedSignal().Connect(&application, finishCheck);
6115 application.SendNotification();
6116 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
6118 // We didn't expect the animation to finish yet
6119 application.SendNotification();
6120 finishCheck.CheckSignalNotReceived();
6121 DALI_TEST_EQUALS( actor.GetCurrentColor().b, fiftyPercentProgress, TEST_LOCATION );
6122 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
6123 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
6124 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), fiftyPercentProgress, TEST_LOCATION );
6125 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), startValue, TEST_LOCATION );
6127 application.SendNotification();
6128 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
6130 // We did expect the animation to finish
6131 application.SendNotification();
6132 finishCheck.CheckSignalReceived();
6133 DALI_TEST_EQUALS( actor.GetCurrentColor().b, targetBlue, TEST_LOCATION );
6134 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
6135 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
6136 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), targetBlue, TEST_LOCATION );
6137 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), startValue, TEST_LOCATION );
6141 int UtcDaliAnimationAnimateToActorColorAlpha(void)
6143 TestApplication application;
6145 Actor actor = Actor::New();
6146 Stage::GetCurrent().Add(actor);
6147 float startValue(1.0f);
6148 DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
6149 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
6150 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
6151 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
6152 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), startValue, TEST_LOCATION );
6154 // Build the animation
6155 float durationSeconds(1.0f);
6156 Animation animation = Animation::New(durationSeconds);
6157 float targetAlpha(0.5f);
6158 animation.AnimateTo( Property(actor, Actor::COLOR_ALPHA), targetAlpha );
6160 float fiftyPercentProgress(startValue + (targetAlpha - startValue)*0.5f);
6162 // Start the animation
6165 bool signalReceived(false);
6166 AnimationFinishCheck finishCheck(signalReceived);
6167 animation.FinishedSignal().Connect(&application, finishCheck);
6169 application.SendNotification();
6170 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
6172 // We didn't expect the animation to finish yet
6173 application.SendNotification();
6174 finishCheck.CheckSignalNotReceived();
6175 DALI_TEST_EQUALS( actor.GetCurrentColor().a, fiftyPercentProgress, TEST_LOCATION );
6176 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
6177 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
6178 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
6179 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), fiftyPercentProgress, TEST_LOCATION );
6181 application.SendNotification();
6182 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
6184 // We did expect the animation to finish
6185 application.SendNotification();
6186 finishCheck.CheckSignalReceived();
6187 DALI_TEST_EQUALS( actor.GetCurrentColor().a, targetAlpha, TEST_LOCATION );
6188 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
6189 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
6190 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
6191 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), targetAlpha, TEST_LOCATION );
6197 int UtcDaliAnimationKeyFrames01(void)
6199 TestApplication application;
6201 KeyFrames keyFrames = KeyFrames::New();
6202 DALI_TEST_EQUALS(keyFrames.GetType(), Property::NONE, TEST_LOCATION);
6204 keyFrames.Add(0.0f, 0.1f);
6205 keyFrames.Add(0.2f, 0.5f);
6206 keyFrames.Add(0.4f, 0.0f);
6207 keyFrames.Add(0.6f, 1.0f);
6208 keyFrames.Add(0.8f, 0.7f);
6209 keyFrames.Add(1.0f, 0.9f);
6211 DALI_TEST_EQUALS(keyFrames.GetType(), Property::FLOAT, TEST_LOCATION);
6215 keyFrames.Add(1.9f, false);
6217 catch (Dali::DaliException& e)
6219 tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
6220 DALI_TEST_ASSERT(e, "mType == value.GetType()", TEST_LOCATION);
6225 int UtcDaliAnimationKeyFrames02(void)
6227 TestApplication application;
6229 KeyFrames keyFrames = KeyFrames::New();
6230 DALI_TEST_EQUALS(keyFrames.GetType(), Property::NONE, TEST_LOCATION);
6232 keyFrames.Add(0.0f, true);
6233 keyFrames.Add(0.2f, false);
6234 keyFrames.Add(0.4f, false);
6235 keyFrames.Add(0.6f, true);
6236 keyFrames.Add(0.8f, true);
6237 keyFrames.Add(1.0f, false);
6239 DALI_TEST_EQUALS(keyFrames.GetType(), Property::BOOLEAN, TEST_LOCATION);
6243 keyFrames.Add(0.7f, Vector3(1.0f, 1.0f, 1.0f));
6245 catch (Dali::DaliException& e)
6247 tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
6248 DALI_TEST_ASSERT(e, "mType == value.GetType()", TEST_LOCATION);
6254 int UtcDaliAnimationKeyFrames03(void)
6256 TestApplication application;
6258 KeyFrames keyFrames = KeyFrames::New();
6259 DALI_TEST_EQUALS(keyFrames.GetType(), Property::NONE, TEST_LOCATION);
6261 keyFrames.Add(0.0f, Vector2(0.0f, 0.0f));
6262 keyFrames.Add(0.2f, Vector2(1.0f, 1.0f));
6263 keyFrames.Add(0.4f, Vector2(2.0f, 2.0f));
6264 keyFrames.Add(0.6f, Vector2(3.0f, 5.0f));
6265 keyFrames.Add(0.8f, Vector2(4.0f, 3.0f));
6266 keyFrames.Add(1.0f, Vector2(6.0f, 2.0f));
6268 DALI_TEST_EQUALS(keyFrames.GetType(), Property::VECTOR2, TEST_LOCATION);
6272 keyFrames.Add(0.7f, Vector3(1.0f, 1.0f, 1.0f));
6274 catch (Dali::DaliException& e)
6276 tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
6277 DALI_TEST_ASSERT(e, "mType == value.GetType()", TEST_LOCATION);
6283 int UtcDaliAnimationKeyFrames04(void)
6285 TestApplication application;
6287 KeyFrames keyFrames = KeyFrames::New();
6288 DALI_TEST_EQUALS(keyFrames.GetType(), Property::NONE, TEST_LOCATION);
6290 keyFrames.Add(0.0f, Vector3(0.0f, 4.0f, 0.0f));
6291 keyFrames.Add(0.2f, Vector3(1.0f, 3.0f, 1.0f));
6292 keyFrames.Add(0.4f, Vector3(2.0f, 2.0f, 2.0f));
6293 keyFrames.Add(0.6f, Vector3(3.0f, 2.0f, 5.0f));
6294 keyFrames.Add(0.8f, Vector3(4.0f, 4.0f, 3.0f));
6295 keyFrames.Add(1.0f, Vector3(6.0f, 8.0f, 2.0f));
6297 DALI_TEST_EQUALS(keyFrames.GetType(), Property::VECTOR3, TEST_LOCATION);
6301 keyFrames.Add(0.7f, 1.0f);
6303 catch (Dali::DaliException& e)
6305 tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
6306 DALI_TEST_ASSERT(e, "mType == value.GetType()", TEST_LOCATION);
6311 int UtcDaliAnimationKeyFrames05(void)
6313 TestApplication application;
6315 KeyFrames keyFrames = KeyFrames::New();
6316 DALI_TEST_EQUALS(keyFrames.GetType(), Property::NONE, TEST_LOCATION);
6318 keyFrames.Add(0.0f, Vector4(0.0f, 0.0f, 0.0f, 0.0f));
6319 keyFrames.Add(0.2f, Vector4(1.0f, 1.0f, 1.0f, 1.0f));
6320 keyFrames.Add(0.4f, Vector4(2.0f, 2.0f, 2.0f, 2.0f));
6321 keyFrames.Add(0.6f, Vector4(3.0f, 5.0f, 3.0f, 5.0f));
6322 keyFrames.Add(0.8f, Vector4(4.0f, 3.0f, 4.0f, 3.0f));
6323 keyFrames.Add(1.0f, Vector4(6.0f, 2.0f, 6.0f, 2.0f));
6325 DALI_TEST_EQUALS(keyFrames.GetType(), Property::VECTOR4, TEST_LOCATION);
6329 keyFrames.Add(0.7f, Quaternion(1.717f, Vector3::XAXIS));
6331 catch (Dali::DaliException& e)
6333 tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
6334 DALI_TEST_ASSERT(e, "mType == value.GetType()", TEST_LOCATION);
6340 int UtcDaliAnimationKeyFrames06(void)
6342 TestApplication application;
6344 KeyFrames keyFrames = KeyFrames::New();
6345 DALI_TEST_EQUALS(keyFrames.GetType(), Property::NONE, TEST_LOCATION);
6347 keyFrames.Add(0.0f, Quaternion(1.717f, Vector3::XAXIS));
6348 keyFrames.Add(0.2f, Quaternion(2.0f, Vector3::XAXIS));
6349 keyFrames.Add(0.4f, Quaternion(3.0f, Vector3::ZAXIS));
6350 keyFrames.Add(0.6f, Quaternion(4.0f, Vector3(1.0f, 1.0f, 1.0f)));
6351 keyFrames.Add(0.8f, AngleAxis(Degree(90), Vector3::XAXIS));
6352 keyFrames.Add(1.0f, Quaternion(3.0f, Vector3::YAXIS));
6354 DALI_TEST_EQUALS(keyFrames.GetType(), Property::ROTATION, TEST_LOCATION);
6358 keyFrames.Add(0.7f, 1.1f);
6360 catch (Dali::DaliException& e)
6362 tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
6363 DALI_TEST_ASSERT(e, "mType == value.GetType()", TEST_LOCATION);
6372 int UtcDaliAnimationAnimateBetweenActorColorAlpha(void)
6374 TestApplication application;
6376 float startValue(1.0f);
6377 Actor actor = Actor::New();
6378 actor.SetColor(Vector4(startValue, startValue, startValue, startValue));
6379 Stage::GetCurrent().Add(actor);
6381 DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
6382 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
6383 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
6384 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
6385 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), startValue, TEST_LOCATION );
6387 // Build the animation
6388 float durationSeconds(1.0f);
6389 Animation animation = Animation::New(durationSeconds);
6391 KeyFrames keyFrames = KeyFrames::New();
6392 keyFrames.Add(0.0f, 0.1f);
6393 keyFrames.Add(0.2f, 0.5f);
6394 keyFrames.Add(0.4f, 0.0f);
6395 keyFrames.Add(0.6f, 1.0f);
6396 keyFrames.Add(0.8f, 0.7f);
6397 keyFrames.Add(1.0f, 0.9f);
6399 animation.AnimateBetween( Property(actor, Actor::COLOR_ALPHA), keyFrames );
6401 // Start the animation
6404 bool signalReceived(false);
6405 AnimationFinishCheck finishCheck(signalReceived);
6406 animation.FinishedSignal().Connect(&application, finishCheck);
6407 application.SendNotification();
6408 application.Render(0);
6409 application.SendNotification();
6410 finishCheck.CheckSignalNotReceived();
6411 DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.1f, TEST_LOCATION );
6413 application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% progress */);
6414 application.SendNotification();
6415 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
6416 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
6417 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
6418 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.3f, 0.01f, TEST_LOCATION );
6419 DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.3f, 0.01f, TEST_LOCATION );
6421 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 30% progress */);
6422 application.SendNotification();
6423 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
6424 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
6425 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
6426 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.25f, 0.01f, TEST_LOCATION );
6427 DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.25f, 0.01f, TEST_LOCATION );
6429 application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 40% progress */);
6430 application.SendNotification();
6431 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
6432 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
6433 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
6434 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.0f, 0.01f, TEST_LOCATION );
6435 DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.0f, 0.01f, TEST_LOCATION );
6437 application.Render(static_cast<unsigned int>(durationSeconds*400.0f)/* 80% progress */);
6438 application.SendNotification();
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), 0.7f, 0.01f, TEST_LOCATION );
6443 DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.7f, 0.01f, TEST_LOCATION );
6445 application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 90% progress */);
6446 application.SendNotification();
6447 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
6448 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
6449 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
6450 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.8f, 0.01f, TEST_LOCATION );
6451 DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.8f, 0.01f, TEST_LOCATION );
6453 application.Render(static_cast<unsigned int>(durationSeconds*100.0f)+1/* 100% progress */);
6454 application.SendNotification();
6455 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
6456 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
6457 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
6458 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.9f, 0.01f, TEST_LOCATION );
6459 DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.9f, 0.01f, TEST_LOCATION );
6461 // We did expect the animation to finish
6463 finishCheck.CheckSignalReceived();
6468 int UtcDaliAnimationAnimateBetweenActorColor(void)
6470 TestApplication application;
6472 float startValue(1.0f);
6473 Actor actor = Actor::New();
6474 actor.SetColor(Vector4(startValue, startValue, startValue, startValue));
6475 Stage::GetCurrent().Add(actor);
6477 DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
6478 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
6479 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
6480 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
6481 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), startValue, TEST_LOCATION );
6483 // Build the animation
6484 float durationSeconds(1.0f);
6485 Animation animation = Animation::New(durationSeconds);
6487 KeyFrames keyFrames = KeyFrames::New();
6488 keyFrames.Add(0.0f, Vector4(0.1f, 0.2f, 0.3f, 0.4f));
6489 keyFrames.Add(0.5f, Vector4(0.9f, 0.8f, 0.7f, 0.6f));
6490 keyFrames.Add(1.0f, Vector4(1.0f, 1.0f, 1.0f, 1.0f));
6492 animation.AnimateBetween( Property(actor, Actor::COLOR), keyFrames );
6494 // Start the animation
6497 bool signalReceived(false);
6498 AnimationFinishCheck finishCheck(signalReceived);
6499 animation.FinishedSignal().Connect(&application, finishCheck);
6500 application.SendNotification();
6501 application.Render(0);
6502 application.SendNotification();
6503 finishCheck.CheckSignalNotReceived();
6504 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), 0.1f, 0.01f, TEST_LOCATION );
6505 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 0.2f, 0.01f, TEST_LOCATION );
6506 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), 0.3f, 0.01f, TEST_LOCATION );
6507 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.4f, 0.01f, TEST_LOCATION );
6509 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
6510 application.SendNotification();
6511 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), 0.5f, 0.01f, TEST_LOCATION );
6512 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 0.5f, 0.01f, TEST_LOCATION );
6513 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), 0.5f, 0.01f, TEST_LOCATION );
6514 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.5f, 0.01f, TEST_LOCATION );
6516 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
6517 application.SendNotification();
6518 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), 0.9f, 0.01f, TEST_LOCATION );
6519 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 0.8f, 0.01f, TEST_LOCATION );
6520 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), 0.7f, 0.01f, TEST_LOCATION );
6521 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.6f, 0.01f, TEST_LOCATION );
6523 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
6524 application.SendNotification();
6525 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), 0.95f, 0.01f, TEST_LOCATION );
6526 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 0.90f, 0.01f, TEST_LOCATION );
6527 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), 0.85f, 0.01f, TEST_LOCATION );
6528 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.80f, 0.01f, TEST_LOCATION );
6530 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
6531 application.SendNotification();
6532 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), 1.0f, 0.01f, TEST_LOCATION );
6533 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 1.0f, 0.01f, TEST_LOCATION );
6534 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), 1.0f, 0.01f, TEST_LOCATION );
6535 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 1.0f, 0.01f, TEST_LOCATION );
6537 // We did expect the animation to finish
6539 finishCheck.CheckSignalReceived();
6543 int UtcDaliAnimationAnimateBetweenActorVisible01(void)
6545 TestApplication application;
6547 Actor actor = Actor::New();
6548 AngleAxis aa(Degree(90), Vector3::XAXIS);
6549 actor.SetRotation(aa.angle, aa.axis);
6550 Stage::GetCurrent().Add(actor);
6552 application.SendNotification();
6553 application.Render(0);
6555 DALI_TEST_EQUALS( actor.IsVisible(), true, TEST_LOCATION );
6557 // Build the animation
6558 float durationSeconds(1.0f);
6559 Animation animation = Animation::New(durationSeconds);
6561 KeyFrames keyFrames = KeyFrames::New();
6562 keyFrames.Add(0.0f, false);
6563 keyFrames.Add(0.2f, true);
6564 keyFrames.Add(0.4f, true);
6565 keyFrames.Add(0.8f, false);
6566 keyFrames.Add(1.0f, true);
6568 animation.AnimateBetween( Property(actor, Actor::VISIBLE), keyFrames );
6570 // Start the animation
6573 bool signalReceived(false);
6574 AnimationFinishCheck finishCheck(signalReceived);
6575 animation.FinishedSignal().Connect(&application, finishCheck);
6576 application.SendNotification();
6577 application.SendNotification();
6578 application.Render(static_cast<unsigned int>(durationSeconds*500.0f));
6579 application.SendNotification();
6580 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)+1);
6581 application.SendNotification();
6583 DALI_TEST_EQUALS( actor.IsVisible(), true, TEST_LOCATION);
6584 finishCheck.CheckSignalReceived();
6588 int UtcDaliAnimationAnimateBetweenActorRotation01(void)
6590 TestApplication application;
6592 Actor actor = Actor::New();
6593 AngleAxis aa(Degree(90), Vector3::XAXIS);
6594 actor.SetRotation(aa.angle, aa.axis);
6595 Stage::GetCurrent().Add(actor);
6597 application.SendNotification();
6598 application.Render(0);
6599 Quaternion start(Radian(aa.angle), aa.axis);
6600 DALI_TEST_EQUALS( actor.GetCurrentRotation(), start, 0.001f, TEST_LOCATION );
6602 // Build the animation
6603 float durationSeconds(1.0f);
6604 Animation animation = Animation::New(durationSeconds);
6606 KeyFrames keyFrames = KeyFrames::New();
6607 keyFrames.Add(0.0f, AngleAxis(Degree(60), Vector3::ZAXIS));
6609 animation.AnimateBetween( Property(actor, Actor::ROTATION), keyFrames );
6611 // Start the animation
6614 bool signalReceived(false);
6615 AnimationFinishCheck finishCheck(signalReceived);
6616 animation.FinishedSignal().Connect(&application, finishCheck);
6617 application.SendNotification();
6618 application.SendNotification();
6619 application.Render(static_cast<unsigned int>(durationSeconds*500.0f));
6620 application.SendNotification();
6621 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)+1);
6622 application.SendNotification();
6624 Quaternion check = Quaternion::FromAxisAngle(Vector4::ZAXIS, Radian(Degree(60)));
6626 DALI_TEST_EQUALS( actor.GetCurrentRotation(), check, 0.001f, TEST_LOCATION );
6627 finishCheck.CheckSignalReceived();
6631 int UtcDaliAnimationAnimateBetweenActorRotation02(void)
6633 TestApplication application;
6635 Actor actor = Actor::New();
6636 AngleAxis aa(Degree(90), Vector3::XAXIS);
6637 actor.SetRotation(aa.angle, aa.axis);
6638 application.SendNotification();
6639 application.Render(0);
6640 Stage::GetCurrent().Add(actor);
6642 Quaternion start(Radian(aa.angle), aa.axis);
6643 DALI_TEST_EQUALS( actor.GetCurrentRotation(), start, 0.001f, TEST_LOCATION );
6645 // Build the animation
6646 float durationSeconds(1.0f);
6647 Animation animation = Animation::New(durationSeconds);
6649 KeyFrames keyFrames = KeyFrames::New();
6650 keyFrames.Add(0.0f, AngleAxis(Degree(60), Vector3::XAXIS));
6651 keyFrames.Add(0.5f, AngleAxis(Degree(120), Vector3::XAXIS));
6652 keyFrames.Add(1.0f, AngleAxis(Degree(120), Vector3::YAXIS));
6654 animation.AnimateBetween( Property(actor, Actor::ROTATION), keyFrames );
6656 // Start the animation
6659 bool signalReceived(false);
6660 AnimationFinishCheck finishCheck(signalReceived);
6661 animation.FinishedSignal().Connect(&application, finishCheck);
6662 application.SendNotification();
6663 application.Render(0);
6664 application.SendNotification();
6665 finishCheck.CheckSignalNotReceived();
6667 Quaternion check(Radian(Degree(60)), Vector3::XAXIS);
6668 DALI_TEST_EQUALS( actor.GetCurrentRotation(), check, 0.001f, TEST_LOCATION );
6670 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
6671 application.SendNotification();
6672 check = Quaternion::FromAxisAngle(Vector4::XAXIS, Radian(Degree(90)));
6673 DALI_TEST_EQUALS( actor.GetCurrentRotation(), check, 0.001f, TEST_LOCATION );
6675 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
6676 application.SendNotification();
6677 check = Quaternion::FromAxisAngle(Vector4::XAXIS, Radian(Degree(120)));
6678 DALI_TEST_EQUALS( actor.GetCurrentRotation(), check, 0.001f, TEST_LOCATION );
6680 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
6681 application.SendNotification();
6682 check = Quaternion::FromAxisAngle(Vector4(0.5f, 0.5f, 0.0f, 0.0f), Radian(Degree(101.5)));
6683 DALI_TEST_EQUALS( actor.GetCurrentRotation(), check, 0.001f, TEST_LOCATION );
6685 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
6686 application.SendNotification();
6687 check = Quaternion::FromAxisAngle(Vector4::YAXIS, Radian(Degree(120)));
6688 DALI_TEST_EQUALS( actor.GetCurrentRotation(), check, 0.001f, TEST_LOCATION );
6690 // We did expect the animation to finish
6692 finishCheck.CheckSignalReceived();
6696 int UtcDaliAnimationMoveByFloat3(void)
6698 TestApplication application;
6700 Actor actor = Actor::New();
6701 Vector3 startPosition(10.0f, 10.0f, 10.0f);
6702 actor.SetPosition(startPosition);
6703 Stage::GetCurrent().Add(actor);
6704 application.SendNotification();
6705 application.Render(0);
6706 DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION );
6708 // Build the animation
6709 float durationSeconds(1.0f);
6710 Animation animation = Animation::New(durationSeconds);
6711 Vector3 targetPosition(20.0f, 20.0f, 20.0f);
6712 Vector3 relativePosition(targetPosition - startPosition);
6713 animation.MoveBy(actor, relativePosition.x, relativePosition.y, relativePosition.z);
6715 Vector3 ninetyFivePercentProgress(startPosition + relativePosition*0.95f);
6717 // Start the animation
6720 bool signalReceived(false);
6721 AnimationFinishCheck finishCheck(signalReceived);
6722 animation.FinishedSignal().Connect(&application, finishCheck);
6724 application.SendNotification();
6725 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
6727 // We didn't expect the animation to finish yet
6728 application.SendNotification();
6729 finishCheck.CheckSignalNotReceived();
6730 DALI_TEST_EQUALS( actor.GetCurrentPosition(), ninetyFivePercentProgress, TEST_LOCATION );
6732 application.SendNotification();
6733 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
6735 // We did expect the animation to finish
6736 application.SendNotification();
6737 finishCheck.CheckSignalReceived();
6738 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
6742 int UtcDaliAnimationMoveByVector3Alpha(void)
6744 TestApplication application;
6746 Actor actor = Actor::New();
6747 Vector3 startPosition(10.0f, 10.0f, 10.0f);
6748 actor.SetPosition(startPosition);
6749 Stage::GetCurrent().Add(actor);
6750 application.SendNotification();
6751 application.Render(0);
6752 DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION );
6754 // Build the animation
6755 float durationSeconds(1.0f);
6756 Animation animation = Animation::New(durationSeconds);
6757 Vector3 targetPosition(20.0f, 20.0f, 20.0f);
6758 Vector3 relativePosition(targetPosition - startPosition);
6759 animation.MoveBy(actor, relativePosition, AlphaFunctions::EaseOut);
6761 Vector3 ninetyFivePercentProgress(startPosition + relativePosition*0.95f);
6763 // Start the animation
6766 bool signalReceived(false);
6767 AnimationFinishCheck finishCheck(signalReceived);
6768 animation.FinishedSignal().Connect(&application, finishCheck);
6770 application.SendNotification();
6771 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
6773 // We didn't expect the animation to finish yet
6774 application.SendNotification();
6775 finishCheck.CheckSignalNotReceived();
6777 // The position should have moved more, than with a linear alpha function
6778 Vector3 current(actor.GetCurrentPosition());
6779 DALI_TEST_CHECK( current.x > ninetyFivePercentProgress.x );
6780 DALI_TEST_CHECK( current.y > ninetyFivePercentProgress.y );
6781 DALI_TEST_CHECK( current.z > ninetyFivePercentProgress.z );
6783 application.SendNotification();
6784 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
6786 // We did expect the animation to finish
6787 application.SendNotification();
6788 finishCheck.CheckSignalReceived();
6789 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
6793 int UtcDaliAnimationMoveByVector3AlphaFloat2(void)
6795 TestApplication application;
6797 Actor actor = Actor::New();
6798 Vector3 startPosition(10.0f, 10.0f, 10.0f);
6799 actor.SetPosition(startPosition);
6800 Stage::GetCurrent().Add(actor);
6801 application.SendNotification();
6802 application.Render(0);
6803 DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION );
6805 // Build the animation
6806 float durationSeconds(1.0f);
6807 Animation animation = Animation::New(durationSeconds);
6808 Vector3 targetPosition(20.0f, 20.0f, 20.0f);
6809 Vector3 relativePosition(targetPosition - startPosition);
6811 animation.MoveBy(actor, relativePosition, AlphaFunctions::Linear, delay, durationSeconds - delay);
6813 Vector3 ninetyFivePercentProgress(startPosition + relativePosition*0.95f);
6815 // Start the animation
6818 bool signalReceived(false);
6819 AnimationFinishCheck finishCheck(signalReceived);
6820 animation.FinishedSignal().Connect(&application, finishCheck);
6822 application.SendNotification();
6823 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
6825 // We didn't expect the animation to finish yet
6826 application.SendNotification();
6827 finishCheck.CheckSignalNotReceived();
6828 DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION );
6830 application.SendNotification();
6831 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
6833 // We did expect the animation to finish
6834 application.SendNotification();
6835 finishCheck.CheckSignalReceived();
6836 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
6840 int UtcDaliAnimationMoveToFloat3(void)
6842 TestApplication application;
6844 Actor actor = Actor::New();
6845 Stage::GetCurrent().Add(actor);
6846 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
6848 // Build the animation
6849 float durationSeconds(1.0f);
6850 Animation animation = Animation::New(durationSeconds);
6851 Vector3 targetPosition(200.0f, 200.0f, 200.0f);
6852 animation.MoveTo(actor, targetPosition.x, targetPosition.y, targetPosition.z);
6854 Vector3 seventyFivePercentProgress(targetPosition * 0.75f);
6856 // Start the animation
6859 bool signalReceived(false);
6860 AnimationFinishCheck finishCheck(signalReceived);
6861 animation.FinishedSignal().Connect(&application, finishCheck);
6863 application.SendNotification();
6864 application.Render(static_cast<unsigned int>(durationSeconds*750.0f)/* 75% progress */);
6866 // We didn't expect the animation to finish yet
6867 application.SendNotification();
6868 finishCheck.CheckSignalNotReceived();
6869 DALI_TEST_EQUALS( actor.GetCurrentPosition(), seventyFivePercentProgress, TEST_LOCATION );
6871 application.SendNotification();
6872 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
6874 // We did expect the animation to finish
6875 application.SendNotification();
6876 finishCheck.CheckSignalReceived();
6877 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
6881 int UtcDaliAnimationMoveToVector3Alpha(void)
6883 TestApplication application;
6885 Actor actor = Actor::New();
6886 Stage::GetCurrent().Add(actor);
6887 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
6889 // Build the animation
6890 float durationSeconds(1.0f);
6891 Animation animation = Animation::New(durationSeconds);
6892 Vector3 targetPosition(200.0f, 200.0f, 200.0f);
6893 animation.MoveTo(actor, targetPosition, AlphaFunctions::EaseIn);
6895 Vector3 seventyFivePercentProgress(targetPosition * 0.75f);
6897 // Start the animation
6900 bool signalReceived(false);
6901 AnimationFinishCheck finishCheck(signalReceived);
6902 animation.FinishedSignal().Connect(&application, finishCheck);
6904 application.SendNotification();
6905 application.Render(static_cast<unsigned int>(durationSeconds*750.0f)/* 75% progress */);
6907 // We didn't expect the animation to finish yet
6908 application.SendNotification();
6909 finishCheck.CheckSignalNotReceived();
6911 // The position should have moved less, than with a linear alpha function
6912 Vector3 current(actor.GetCurrentPosition());
6913 DALI_TEST_CHECK( current.x > Vector3::ZERO.x );
6914 DALI_TEST_CHECK( current.y > Vector3::ZERO.y );
6915 DALI_TEST_CHECK( current.z > Vector3::ZERO.z );
6916 DALI_TEST_CHECK( current.x < seventyFivePercentProgress.x );
6917 DALI_TEST_CHECK( current.y < seventyFivePercentProgress.y );
6918 DALI_TEST_CHECK( current.z < seventyFivePercentProgress.z );
6920 application.SendNotification();
6921 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
6923 // We did expect the animation to finish
6924 application.SendNotification();
6925 finishCheck.CheckSignalReceived();
6926 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
6930 int UtcDaliAnimationMoveToVector3AlphaFloat2(void)
6932 TestApplication application;
6934 Actor actor = Actor::New();
6935 Stage::GetCurrent().Add(actor);
6936 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
6938 // Build the animation
6939 float durationSeconds(1.0f);
6940 Animation animation = Animation::New(durationSeconds);
6941 Vector3 targetPosition(200.0f, 200.0f, 200.0f);
6943 animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear, delay, durationSeconds - delay);
6945 Vector3 seventyFivePercentProgress(targetPosition * 0.75f);
6947 // Start the animation
6950 bool signalReceived(false);
6951 AnimationFinishCheck finishCheck(signalReceived);
6952 animation.FinishedSignal().Connect(&application, finishCheck);
6954 application.SendNotification();
6955 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
6957 // We didn't expect the animation to finish yet
6958 application.SendNotification();
6959 finishCheck.CheckSignalNotReceived();
6960 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
6962 application.SendNotification();
6963 application.Render(static_cast<unsigned int>(durationSeconds*500.0f*0.75)/* 7/8 animation progress, 3/4 animator progress */);
6965 // We didn't expect the animation to finish yet
6966 application.SendNotification();
6967 finishCheck.CheckSignalNotReceived();
6968 DALI_TEST_EQUALS( actor.GetCurrentPosition(), seventyFivePercentProgress, TEST_LOCATION );
6970 application.SendNotification();
6971 application.Render(static_cast<unsigned int>(durationSeconds*500.0f*0.25) + 1u/*just beyond the animation duration*/);
6973 // We did expect the animation to finish
6974 application.SendNotification();
6975 finishCheck.CheckSignalReceived();
6976 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
6980 int UtcDaliAnimationMove(void)
6982 TestApplication application;
6984 Actor actor = Actor::New();
6985 Vector3 initialPosition(Vector3::ZERO);
6986 DALI_TEST_EQUALS( actor.GetCurrentPosition(), initialPosition, TEST_LOCATION );
6987 Stage::GetCurrent().Add(actor);
6989 // Build the animation
6990 float durationSeconds(10.0f);
6991 Animation animation = Animation::New(durationSeconds);
6992 Vector3 targetPosition(200.0f, 200.0f, 200.0f);
6993 BounceFunc func(0.0f, 0.0f, -100.0f);
6994 animation.Move(actor, func, AlphaFunctions::Linear, 0.0f, durationSeconds);
6996 // Start the animation
6999 bool signalReceived(false);
7000 AnimationFinishCheck finishCheck(signalReceived);
7001 animation.FinishedSignal().Connect(&application, finishCheck);
7003 application.SendNotification();
7004 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7006 // We didn't expect the animation to finish yet
7007 application.SendNotification();
7008 finishCheck.CheckSignalNotReceived();
7009 DALI_TEST_EQUALS( actor.GetCurrentPosition(), func(0.25f, initialPosition), TEST_LOCATION );
7011 application.SendNotification();
7012 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7014 // We didn't expect the animation to finish yet
7015 application.SendNotification();
7016 finishCheck.CheckSignalNotReceived();
7017 DALI_TEST_EQUALS( actor.GetCurrentPosition(), func(0.5f, initialPosition), TEST_LOCATION );
7019 application.SendNotification();
7020 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7022 // We didn't expect the animation to finish yet
7023 application.SendNotification();
7024 finishCheck.CheckSignalNotReceived();
7025 DALI_TEST_EQUALS( actor.GetCurrentPosition(), func(0.75f, initialPosition), TEST_LOCATION );
7027 application.SendNotification();
7028 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7030 // We did expect the animation to finish
7031 application.SendNotification();
7032 finishCheck.CheckSignalReceived();
7033 DALI_TEST_EQUALS( actor.GetCurrentPosition(), initialPosition, TEST_LOCATION );
7037 int UtcDaliAnimationRotateByDegreeVector3(void)
7039 TestApplication application;
7041 Actor actor = Actor::New();
7042 actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
7043 Stage::GetCurrent().Add(actor);
7044 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7046 // Build the animation
7047 float durationSeconds(1.0f);
7048 Animation animation = Animation::New(durationSeconds);
7049 Degree relativeRotationDegrees(360.0f);
7050 Radian relativeRotationRadians(relativeRotationDegrees);
7051 animation.RotateBy(actor, relativeRotationDegrees/*Degree version*/, Vector3::YAXIS);
7053 // Start the animation
7056 bool signalReceived(false);
7057 AnimationFinishCheck finishCheck(signalReceived);
7058 animation.FinishedSignal().Connect(&application, finishCheck);
7060 application.SendNotification();
7061 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7063 // We didn't expect the animation to finish yet
7064 application.SendNotification();
7065 finishCheck.CheckSignalNotReceived();
7066 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * 0.25f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7068 application.SendNotification();
7069 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7071 // We didn't expect the animation to finish yet
7072 application.SendNotification();
7073 finishCheck.CheckSignalNotReceived();
7074 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * 0.5f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7076 application.SendNotification();
7077 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7079 // We didn't expect the animation to finish yet
7080 application.SendNotification();
7081 finishCheck.CheckSignalNotReceived();
7082 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * 0.75f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7084 application.SendNotification();
7085 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7087 // We did expect the animation to finish
7088 application.SendNotification();
7089 finishCheck.CheckSignalReceived();
7090 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7094 int UtcDaliAnimationRotateByRadianVector3(void)
7096 TestApplication application;
7098 Actor actor = Actor::New();
7099 actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
7100 Stage::GetCurrent().Add(actor);
7101 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7103 // Build the animation
7104 float durationSeconds(1.0f);
7105 Animation animation = Animation::New(durationSeconds);
7106 Degree relativeRotationDegrees(360.0f);
7107 Radian relativeRotationRadians(relativeRotationDegrees);
7108 animation.RotateBy(actor, relativeRotationRadians/*Radian version*/, Vector3::YAXIS);
7110 // Start the animation
7113 bool signalReceived(false);
7114 AnimationFinishCheck finishCheck(signalReceived);
7115 animation.FinishedSignal().Connect(&application, finishCheck);
7117 application.SendNotification();
7118 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7120 // We didn't expect the animation to finish yet
7121 application.SendNotification();
7122 finishCheck.CheckSignalNotReceived();
7123 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * 0.25f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7125 application.SendNotification();
7126 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7128 // We didn't expect the animation to finish yet
7129 application.SendNotification();
7130 finishCheck.CheckSignalNotReceived();
7131 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * 0.5f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7133 application.SendNotification();
7134 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7136 // We didn't expect the animation to finish yet
7137 application.SendNotification();
7138 finishCheck.CheckSignalNotReceived();
7139 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * 0.75f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7141 application.SendNotification();
7142 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7144 // We did expect the animation to finish
7145 application.SendNotification();
7146 finishCheck.CheckSignalReceived();
7147 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7151 int UtcDaliAnimationRotateByDegreeVector3Alpha(void)
7153 TestApplication application;
7155 Actor actor = Actor::New();
7156 actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
7157 Stage::GetCurrent().Add(actor);
7158 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7160 // Build the animation
7161 float durationSeconds(1.0f);
7162 Animation animation = Animation::New(durationSeconds);
7163 Degree relativeRotationDegrees(360.0f);
7164 Radian relativeRotationRadians(relativeRotationDegrees);
7165 animation.RotateBy(actor, relativeRotationDegrees/*Degree version*/, Vector3::YAXIS, AlphaFunctions::EaseIn);
7167 // Start the animation
7170 bool signalReceived(false);
7171 AnimationFinishCheck finishCheck(signalReceived);
7172 animation.FinishedSignal().Connect(&application, finishCheck);
7174 application.SendNotification();
7175 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7177 // We didn't expect the animation to finish yet
7178 application.SendNotification();
7179 finishCheck.CheckSignalNotReceived();
7180 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * AlphaFunctions::EaseIn(0.25f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7182 application.SendNotification();
7183 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7185 // We didn't expect the animation to finish yet
7186 application.SendNotification();
7187 finishCheck.CheckSignalNotReceived();
7188 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * AlphaFunctions::EaseIn(0.5f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7190 application.SendNotification();
7191 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7193 // We didn't expect the animation to finish yet
7194 application.SendNotification();
7195 finishCheck.CheckSignalNotReceived();
7196 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * AlphaFunctions::EaseIn(0.75f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7198 application.SendNotification();
7199 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7201 // We did expect the animation to finish
7202 application.SendNotification();
7203 finishCheck.CheckSignalReceived();
7204 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7208 int UtcDaliAnimationRotateByRadianVector3Alpha(void)
7210 TestApplication application;
7212 Actor actor = Actor::New();
7213 actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
7214 Stage::GetCurrent().Add(actor);
7215 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7217 // Build the animation
7218 float durationSeconds(1.0f);
7219 Animation animation = Animation::New(durationSeconds);
7220 Degree relativeRotationDegrees(360.0f);
7221 Radian relativeRotationRadians(relativeRotationDegrees);
7222 animation.RotateBy(actor, relativeRotationRadians/*Radian version*/, Vector3::YAXIS, AlphaFunctions::EaseIn);
7224 // Start the animation
7227 bool signalReceived(false);
7228 AnimationFinishCheck finishCheck(signalReceived);
7229 animation.FinishedSignal().Connect(&application, finishCheck);
7231 application.SendNotification();
7232 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7234 // We didn't expect the animation to finish yet
7235 application.SendNotification();
7236 finishCheck.CheckSignalNotReceived();
7237 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * AlphaFunctions::EaseIn(0.25f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7239 application.SendNotification();
7240 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7242 // We didn't expect the animation to finish yet
7243 application.SendNotification();
7244 finishCheck.CheckSignalNotReceived();
7245 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * AlphaFunctions::EaseIn(0.5f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7247 application.SendNotification();
7248 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7250 // We didn't expect the animation to finish yet
7251 application.SendNotification();
7252 finishCheck.CheckSignalNotReceived();
7253 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * AlphaFunctions::EaseIn(0.75f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7255 application.SendNotification();
7256 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7258 // We did expect the animation to finish
7259 application.SendNotification();
7260 finishCheck.CheckSignalReceived();
7261 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7265 int UtcDaliAnimationRotateByDegreeVector3AlphaFloat2(void)
7267 TestApplication application;
7269 Actor actor = Actor::New();
7270 actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
7271 Stage::GetCurrent().Add(actor);
7272 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7274 // Build the animation
7275 float durationSeconds(1.0f);
7276 Animation animation = Animation::New(durationSeconds);
7277 Degree relativeRotationDegrees(360.0f);
7278 Radian relativeRotationRadians(relativeRotationDegrees);
7280 animation.RotateBy(actor, relativeRotationDegrees/*Degree version*/, Vector3::YAXIS, AlphaFunctions::EaseIn, delay, durationSeconds - delay);
7282 // Start the animation
7285 bool signalReceived(false);
7286 AnimationFinishCheck finishCheck(signalReceived);
7287 animation.FinishedSignal().Connect(&application, finishCheck);
7289 application.SendNotification();
7290 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7292 // We didn't expect the animation to finish yet
7293 application.SendNotification();
7294 finishCheck.CheckSignalNotReceived();
7295 float progress = max(0.0f, 0.25f - delay) / (1.0f - delay);
7296 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7298 application.SendNotification();
7299 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7301 // We didn't expect the animation to finish yet
7302 application.SendNotification();
7303 finishCheck.CheckSignalNotReceived();
7304 progress = max(0.0f, 0.5f - delay) / (1.0f - delay);
7305 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7307 application.SendNotification();
7308 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7310 // We didn't expect the animation to finish yet
7311 application.SendNotification();
7312 finishCheck.CheckSignalNotReceived();
7313 progress = max(0.0f, 0.75f - delay) / (1.0f - delay);
7314 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7316 application.SendNotification();
7317 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7319 // We did expect the animation to finish
7320 application.SendNotification();
7321 finishCheck.CheckSignalReceived();
7322 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7327 int UtcDaliAnimationRotateByRadianVector3AlphaFloat2(void)
7329 TestApplication application;
7331 Actor actor = Actor::New();
7332 actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
7333 Stage::GetCurrent().Add(actor);
7334 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7336 // Build the animation
7337 float durationSeconds(1.0f);
7338 Animation animation = Animation::New(durationSeconds);
7339 Degree relativeRotationDegrees(360.0f);
7340 Radian relativeRotationRadians(relativeRotationDegrees);
7342 animation.RotateBy(actor, relativeRotationRadians/*Radian version*/, Vector3::YAXIS, AlphaFunctions::EaseIn, delay, durationSeconds - delay);
7344 // Start the animation
7347 bool signalReceived(false);
7348 AnimationFinishCheck finishCheck(signalReceived);
7349 animation.FinishedSignal().Connect(&application, finishCheck);
7351 application.SendNotification();
7352 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7354 // We didn't expect the animation to finish yet
7355 application.SendNotification();
7356 finishCheck.CheckSignalNotReceived();
7357 float progress = max(0.0f, 0.25f - delay) / (1.0f - delay);
7358 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7360 application.SendNotification();
7361 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7363 // We didn't expect the animation to finish yet
7364 application.SendNotification();
7365 finishCheck.CheckSignalNotReceived();
7366 progress = max(0.0f, 0.5f - delay) / (1.0f - delay);
7367 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7369 application.SendNotification();
7370 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7372 // We didn't expect the animation to finish yet
7373 application.SendNotification();
7374 finishCheck.CheckSignalNotReceived();
7375 progress = max(0.0f, 0.75f - delay) / (1.0f - delay);
7376 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7378 application.SendNotification();
7379 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7381 // We did expect the animation to finish
7382 application.SendNotification();
7383 finishCheck.CheckSignalReceived();
7384 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7388 int UtcDaliAnimationRotateToDegreeVector3(void)
7390 TestApplication application;
7392 Actor actor = Actor::New();
7393 actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
7394 Stage::GetCurrent().Add(actor);
7395 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7397 // Build the animation
7398 float durationSeconds(1.0f);
7399 Animation animation = Animation::New(durationSeconds);
7400 Degree targetRotationDegrees(90.0f);
7401 Radian targetRotationRadians(targetRotationDegrees);
7402 animation.RotateTo(actor, targetRotationDegrees/*Degree version*/, Vector3::YAXIS);
7404 // Start the animation
7407 bool signalReceived(false);
7408 AnimationFinishCheck finishCheck(signalReceived);
7409 animation.FinishedSignal().Connect(&application, finishCheck);
7411 application.SendNotification();
7412 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7414 // We didn't expect the animation to finish yet
7415 application.SendNotification();
7416 finishCheck.CheckSignalNotReceived();
7417 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.25f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7419 application.SendNotification();
7420 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7422 // We didn't expect the animation to finish yet
7423 application.SendNotification();
7424 finishCheck.CheckSignalNotReceived();
7425 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.5f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7427 application.SendNotification();
7428 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7430 // We didn't expect the animation to finish yet
7431 application.SendNotification();
7432 finishCheck.CheckSignalNotReceived();
7433 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.75f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7435 application.SendNotification();
7436 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7438 // We did expect the animation to finish
7439 application.SendNotification();
7440 finishCheck.CheckSignalReceived();
7441 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7445 int UtcDaliAnimationRotateToRadianVector3(void)
7447 TestApplication application;
7449 Actor actor = Actor::New();
7450 actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
7451 Stage::GetCurrent().Add(actor);
7452 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7454 // Build the animation
7455 float durationSeconds(1.0f);
7456 Animation animation = Animation::New(durationSeconds);
7457 Degree targetRotationDegrees(90.0f);
7458 Radian targetRotationRadians(targetRotationDegrees);
7459 animation.RotateTo(actor, targetRotationRadians/*Radian version*/, Vector3::YAXIS);
7461 // Start the animation
7464 bool signalReceived(false);
7465 AnimationFinishCheck finishCheck(signalReceived);
7466 animation.FinishedSignal().Connect(&application, finishCheck);
7468 application.SendNotification();
7469 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7471 // We didn't expect the animation to finish yet
7472 application.SendNotification();
7473 finishCheck.CheckSignalNotReceived();
7474 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.25f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7476 application.SendNotification();
7477 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7479 // We didn't expect the animation to finish yet
7480 application.SendNotification();
7481 finishCheck.CheckSignalNotReceived();
7482 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.5f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7484 application.SendNotification();
7485 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7487 // We didn't expect the animation to finish yet
7488 application.SendNotification();
7489 finishCheck.CheckSignalNotReceived();
7490 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.75f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7492 application.SendNotification();
7493 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7495 // We did expect the animation to finish
7496 application.SendNotification();
7497 finishCheck.CheckSignalReceived();
7498 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7502 int UtcDaliAnimationRotateToQuaternion(void)
7504 TestApplication application;
7506 Actor actor = Actor::New();
7507 actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
7508 Stage::GetCurrent().Add(actor);
7509 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7511 // Build the animation
7512 float durationSeconds(1.0f);
7513 Animation animation = Animation::New(durationSeconds);
7514 Degree targetRotationDegrees(90.0f);
7515 Radian targetRotationRadians(targetRotationDegrees);
7516 Quaternion targetRotation(targetRotationRadians, Vector3::YAXIS);
7517 animation.RotateTo(actor, targetRotation/*Quaternion version*/);
7519 // Start the animation
7522 bool signalReceived(false);
7523 AnimationFinishCheck finishCheck(signalReceived);
7524 animation.FinishedSignal().Connect(&application, finishCheck);
7526 application.SendNotification();
7527 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7529 // We didn't expect the animation to finish yet
7530 application.SendNotification();
7531 finishCheck.CheckSignalNotReceived();
7532 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.25f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7534 application.SendNotification();
7535 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7537 // We didn't expect the animation to finish yet
7538 application.SendNotification();
7539 finishCheck.CheckSignalNotReceived();
7540 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.5f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7542 application.SendNotification();
7543 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7545 // We didn't expect the animation to finish yet
7546 application.SendNotification();
7547 finishCheck.CheckSignalNotReceived();
7548 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.75f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7550 application.SendNotification();
7551 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7553 // We did expect the animation to finish
7554 application.SendNotification();
7555 finishCheck.CheckSignalReceived();
7556 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7560 int UtcDaliAnimationRotateToDegreeVector3Alpha(void)
7562 TestApplication application;
7564 Actor actor = Actor::New();
7565 actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
7566 Stage::GetCurrent().Add(actor);
7567 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7569 // Build the animation
7570 float durationSeconds(1.0f);
7571 Animation animation = Animation::New(durationSeconds);
7572 Degree targetRotationDegrees(90.0f);
7573 Radian targetRotationRadians(targetRotationDegrees);
7574 animation.RotateTo(actor, targetRotationDegrees/*Degree version*/, Vector3::YAXIS, AlphaFunctions::EaseIn);
7576 // Start the animation
7579 bool signalReceived(false);
7580 AnimationFinishCheck finishCheck(signalReceived);
7581 animation.FinishedSignal().Connect(&application, finishCheck);
7583 application.SendNotification();
7584 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7586 // We didn't expect the animation to finish yet
7587 application.SendNotification();
7588 finishCheck.CheckSignalNotReceived();
7589 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(0.25f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7591 application.SendNotification();
7592 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7594 // We didn't expect the animation to finish yet
7595 application.SendNotification();
7596 finishCheck.CheckSignalNotReceived();
7597 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(0.5f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7599 application.SendNotification();
7600 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7602 // We didn't expect the animation to finish yet
7603 application.SendNotification();
7604 finishCheck.CheckSignalNotReceived();
7605 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(0.75f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7607 application.SendNotification();
7608 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7610 // We did expect the animation to finish
7611 application.SendNotification();
7612 finishCheck.CheckSignalReceived();
7613 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7617 int UtcDaliAnimationRotateToRadianVector3Alpha(void)
7619 TestApplication application;
7621 Actor actor = Actor::New();
7622 actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
7623 Stage::GetCurrent().Add(actor);
7624 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7626 // Build the animation
7627 float durationSeconds(1.0f);
7628 Animation animation = Animation::New(durationSeconds);
7629 Degree targetRotationDegrees(90.0f);
7630 Radian targetRotationRadians(targetRotationDegrees);
7631 animation.RotateTo(actor, targetRotationRadians/*Radian version*/, Vector3::YAXIS, AlphaFunctions::EaseIn);
7633 // Start the animation
7636 bool signalReceived(false);
7637 AnimationFinishCheck finishCheck(signalReceived);
7638 animation.FinishedSignal().Connect(&application, finishCheck);
7640 application.SendNotification();
7641 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7643 // We didn't expect the animation to finish yet
7644 application.SendNotification();
7645 finishCheck.CheckSignalNotReceived();
7646 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(0.25f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7648 application.SendNotification();
7649 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7651 // We didn't expect the animation to finish yet
7652 application.SendNotification();
7653 finishCheck.CheckSignalNotReceived();
7654 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(0.5f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7656 application.SendNotification();
7657 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7659 // We didn't expect the animation to finish yet
7660 application.SendNotification();
7661 finishCheck.CheckSignalNotReceived();
7662 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(0.75f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7664 application.SendNotification();
7665 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7667 // We did expect the animation to finish
7668 application.SendNotification();
7669 finishCheck.CheckSignalReceived();
7670 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7674 int UtcDaliAnimationRotateToQuaternionAlpha(void)
7676 TestApplication application;
7678 Actor actor = Actor::New();
7679 actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
7680 Stage::GetCurrent().Add(actor);
7681 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7683 // Build the animation
7684 float durationSeconds(1.0f);
7685 Animation animation = Animation::New(durationSeconds);
7686 Degree targetRotationDegrees(90.0f);
7687 Radian targetRotationRadians(targetRotationDegrees);
7688 Quaternion targetRotation(targetRotationRadians, Vector3::YAXIS);
7689 animation.RotateTo(actor, targetRotation/*Quaternion version*/, AlphaFunctions::EaseIn);
7691 // Start the animation
7694 bool signalReceived(false);
7695 AnimationFinishCheck finishCheck(signalReceived);
7696 animation.FinishedSignal().Connect(&application, finishCheck);
7698 application.SendNotification();
7699 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7701 // We didn't expect the animation to finish yet
7702 application.SendNotification();
7703 finishCheck.CheckSignalNotReceived();
7704 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(0.25f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7706 application.SendNotification();
7707 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7709 // We didn't expect the animation to finish yet
7710 application.SendNotification();
7711 finishCheck.CheckSignalNotReceived();
7712 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(0.5f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7714 application.SendNotification();
7715 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7717 // We didn't expect the animation to finish yet
7718 application.SendNotification();
7719 finishCheck.CheckSignalNotReceived();
7720 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(0.75f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7722 application.SendNotification();
7723 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7725 // We did expect the animation to finish
7726 application.SendNotification();
7727 finishCheck.CheckSignalReceived();
7728 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7732 int UtcDaliAnimationRotateToDegreeVector3AlphaFloat2(void)
7734 TestApplication application;
7736 Actor actor = Actor::New();
7737 actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
7738 Stage::GetCurrent().Add(actor);
7739 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7741 // Build the animation
7742 float durationSeconds(1.0f);
7743 Animation animation = Animation::New(durationSeconds);
7744 Degree targetRotationDegrees(90.0f);
7745 Radian targetRotationRadians(targetRotationDegrees);
7747 animation.RotateTo(actor, targetRotationDegrees/*Degree version*/, Vector3::YAXIS, AlphaFunctions::EaseIn, delay, durationSeconds - delay);
7749 // Start the animation
7752 bool signalReceived(false);
7753 AnimationFinishCheck finishCheck(signalReceived);
7754 animation.FinishedSignal().Connect(&application, finishCheck);
7756 application.SendNotification();
7757 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7759 // We didn't expect the animation to finish yet
7760 application.SendNotification();
7761 finishCheck.CheckSignalNotReceived();
7762 float progress = max(0.0f, 0.25f - delay) / (1.0f - delay);
7763 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7765 application.SendNotification();
7766 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7768 // We didn't expect the animation to finish yet
7769 application.SendNotification();
7770 finishCheck.CheckSignalNotReceived();
7771 progress = max(0.0f, 0.5f - delay) / (1.0f - delay);
7772 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7774 application.SendNotification();
7775 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7777 // We didn't expect the animation to finish yet
7778 application.SendNotification();
7779 finishCheck.CheckSignalNotReceived();
7780 progress = max(0.0f, 0.75f - delay) / (1.0f - delay);
7781 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7783 application.SendNotification();
7784 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7786 // We did expect the animation to finish
7787 application.SendNotification();
7788 finishCheck.CheckSignalReceived();
7789 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7793 int UtcDaliAnimationRotateToRadianVector3AlphaFloat2(void)
7795 TestApplication application;
7797 Actor actor = Actor::New();
7798 actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
7799 Stage::GetCurrent().Add(actor);
7800 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7802 // Build the animation
7803 float durationSeconds(1.0f);
7804 Animation animation = Animation::New(durationSeconds);
7805 Degree targetRotationDegrees(90.0f);
7806 Radian targetRotationRadians(targetRotationDegrees);
7808 animation.RotateTo(actor, targetRotationRadians/*Radian version*/, Vector3::YAXIS, AlphaFunctions::EaseIn, delay, durationSeconds - delay);
7810 // Start the animation
7813 bool signalReceived(false);
7814 AnimationFinishCheck finishCheck(signalReceived);
7815 animation.FinishedSignal().Connect(&application, finishCheck);
7817 application.SendNotification();
7818 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7820 // We didn't expect the animation to finish yet
7821 application.SendNotification();
7822 finishCheck.CheckSignalNotReceived();
7823 float progress = max(0.0f, 0.25f - delay) / (1.0f - delay);
7824 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7826 application.SendNotification();
7827 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7829 // We didn't expect the animation to finish yet
7830 application.SendNotification();
7831 finishCheck.CheckSignalNotReceived();
7832 progress = max(0.0f, 0.5f - delay) / (1.0f - delay);
7833 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7835 application.SendNotification();
7836 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7838 // We didn't expect the animation to finish yet
7839 application.SendNotification();
7840 finishCheck.CheckSignalNotReceived();
7841 progress = max(0.0f, 0.75f - delay) / (1.0f - delay);
7842 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7844 application.SendNotification();
7845 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7847 // We did expect the animation to finish
7848 application.SendNotification();
7849 finishCheck.CheckSignalReceived();
7850 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7854 int UtcDaliAnimationRotateToQuaternionAlphaFloat2(void)
7856 TestApplication application;
7858 Actor actor = Actor::New();
7859 actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
7860 Stage::GetCurrent().Add(actor);
7861 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7863 // Build the animation
7864 float durationSeconds(1.0f);
7865 Animation animation = Animation::New(durationSeconds);
7866 Degree targetRotationDegrees(90.0f);
7867 Radian targetRotationRadians(targetRotationDegrees);
7869 Quaternion targetRotation(targetRotationRadians, Vector3::YAXIS);
7870 animation.RotateTo(actor, targetRotation/*Quaternion version*/, AlphaFunctions::EaseIn, delay, durationSeconds - delay);
7872 // Start the animation
7875 bool signalReceived(false);
7876 AnimationFinishCheck finishCheck(signalReceived);
7877 animation.FinishedSignal().Connect(&application, finishCheck);
7879 application.SendNotification();
7880 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7882 // We didn't expect the animation to finish yet
7883 application.SendNotification();
7884 finishCheck.CheckSignalNotReceived();
7885 float progress = max(0.0f, 0.25f - delay) / (1.0f - delay);
7886 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7888 application.SendNotification();
7889 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7891 // We didn't expect the animation to finish yet
7892 application.SendNotification();
7893 finishCheck.CheckSignalNotReceived();
7894 progress = max(0.0f, 0.5f - delay) / (1.0f - delay);
7895 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7897 application.SendNotification();
7898 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7900 // We didn't expect the animation to finish yet
7901 application.SendNotification();
7902 finishCheck.CheckSignalNotReceived();
7903 progress = max(0.0f, 0.75f - delay) / (1.0f - delay);
7904 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7906 application.SendNotification();
7907 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7909 // We did expect the animation to finish
7910 application.SendNotification();
7911 finishCheck.CheckSignalReceived();
7912 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7916 int UtcDaliAnimationRotate(void)
7918 TestApplication application;
7920 Actor actor = Actor::New();
7921 Quaternion initialRotation(0.0f, Vector3::YAXIS);
7922 actor.SetRotation(initialRotation);
7923 Stage::GetCurrent().Add(actor);
7924 DALI_TEST_EQUALS( actor.GetCurrentRotation(), initialRotation, ROTATION_EPSILON, TEST_LOCATION );
7926 // Build the animation
7927 float durationSeconds(1.0f);
7928 Animation animation = Animation::New(durationSeconds);
7929 TumbleFunc func(Vector3::YAXIS);
7930 animation.Rotate(actor, func, AlphaFunctions::Linear, 0.0f, durationSeconds);
7932 // Start the animation
7935 bool signalReceived(false);
7936 AnimationFinishCheck finishCheck(signalReceived);
7937 animation.FinishedSignal().Connect(&application, finishCheck);
7939 application.SendNotification();
7940 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7942 // We didn't expect the animation to finish yet
7943 application.SendNotification();
7944 finishCheck.CheckSignalNotReceived();
7945 DALI_TEST_EQUALS( actor.GetCurrentRotation(), func(0.25f, initialRotation), ROTATION_EPSILON, TEST_LOCATION );
7947 application.SendNotification();
7948 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7950 // We didn't expect the animation to finish yet
7951 application.SendNotification();
7952 finishCheck.CheckSignalNotReceived();
7953 DALI_TEST_EQUALS( actor.GetCurrentRotation(), func(0.5f, initialRotation), ROTATION_EPSILON, TEST_LOCATION );
7955 application.SendNotification();
7956 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7958 // We didn't expect the animation to finish yet
7959 application.SendNotification();
7960 finishCheck.CheckSignalNotReceived();
7961 DALI_TEST_EQUALS( actor.GetCurrentRotation(), func(0.75f, initialRotation), ROTATION_EPSILON, TEST_LOCATION );
7963 application.SendNotification();
7964 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7966 // We did expect the animation to finish
7967 application.SendNotification();
7968 finishCheck.CheckSignalReceived();
7969 DALI_TEST_EQUALS( actor.GetCurrentRotation(), func(1.0f, initialRotation), ROTATION_EPSILON, TEST_LOCATION );
7973 int UtcDaliAnimationScaleBy(void)
7975 TestApplication application;
7977 Actor actor = Actor::New();
7978 Stage::GetCurrent().Add(actor);
7979 DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
7981 // Build the animation
7982 float durationSeconds(1.0f);
7983 Animation animation = Animation::New(durationSeconds);
7984 Vector3 targetScale(2.0f, 2.0f, 2.0f);
7985 Vector3 relativeScale(targetScale - Vector3::ONE);
7986 animation.ScaleBy(actor, relativeScale.x, relativeScale.y, relativeScale.z);
7988 Vector3 ninetyNinePercentProgress(Vector3::ONE + relativeScale*0.99f);
7990 // Start the animation
7993 bool signalReceived(false);
7994 AnimationFinishCheck finishCheck(signalReceived);
7995 animation.FinishedSignal().Connect(&application, finishCheck);
7997 application.SendNotification();
7998 application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
8000 // We didn't expect the animation to finish yet
8001 application.SendNotification();
8002 finishCheck.CheckSignalNotReceived();
8003 DALI_TEST_EQUALS( actor.GetCurrentScale(), ninetyNinePercentProgress, TEST_LOCATION );
8005 application.SendNotification();
8006 application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
8008 // We did expect the animation to finish
8009 application.SendNotification();
8010 finishCheck.CheckSignalReceived();
8011 DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
8014 finishCheck.Reset();
8015 actor.SetScale(Vector3::ONE);
8016 application.SendNotification();
8017 application.Render(0);
8018 DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
8020 // Repeat with a different (ease-in) alpha function
8021 animation = Animation::New(durationSeconds);
8022 animation.ScaleBy(actor, relativeScale, AlphaFunctions::EaseIn);
8023 animation.FinishedSignal().Connect(&application, finishCheck);
8026 application.SendNotification();
8027 application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
8029 // We didn't expect the animation to finish yet
8030 application.SendNotification();
8031 finishCheck.CheckSignalNotReceived();
8033 // The scale should have grown less, than with a linear alpha function
8034 Vector3 current(actor.GetCurrentScale());
8035 DALI_TEST_CHECK( current.x > 1.0f );
8036 DALI_TEST_CHECK( current.y > 1.0f );
8037 DALI_TEST_CHECK( current.z > 1.0f );
8038 DALI_TEST_CHECK( current.x < ninetyNinePercentProgress.x );
8039 DALI_TEST_CHECK( current.y < ninetyNinePercentProgress.y );
8040 DALI_TEST_CHECK( current.z < ninetyNinePercentProgress.z );
8042 application.SendNotification();
8043 application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
8045 // We did expect the animation to finish
8046 application.SendNotification();
8047 finishCheck.CheckSignalReceived();
8048 DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
8051 finishCheck.Reset();
8052 actor.SetScale(Vector3::ONE);
8053 application.SendNotification();
8054 application.Render(0);
8055 DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
8057 // Repeat with a delay
8059 animation = Animation::New(durationSeconds);
8060 animation.ScaleBy(actor, relativeScale, AlphaFunctions::Linear, delay, durationSeconds - delay);
8061 animation.FinishedSignal().Connect(&application, finishCheck);
8064 application.SendNotification();
8065 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
8067 // We didn't expect the animation to finish yet
8068 application.SendNotification();
8069 finishCheck.CheckSignalNotReceived();
8070 DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
8072 application.SendNotification();
8073 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
8075 // We did expect the animation to finish
8076 application.SendNotification();
8077 finishCheck.CheckSignalReceived();
8078 DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
8082 int UtcDaliAnimationScaleTo(void)
8084 TestApplication application;
8086 Actor actor = Actor::New();
8087 Stage::GetCurrent().Add(actor);
8088 DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
8090 // Build the animation
8091 float durationSeconds(1.0f);
8092 Animation animation = Animation::New(durationSeconds);
8093 Vector3 targetScale(2.0f, 2.0f, 2.0f);
8094 animation.ScaleTo(actor, targetScale.x, targetScale.y, targetScale.z);
8096 Vector3 ninetyNinePercentProgress(Vector3::ONE + (targetScale - Vector3::ONE)*0.99f);
8098 // Start the animation
8101 bool signalReceived(false);
8102 AnimationFinishCheck finishCheck(signalReceived);
8103 animation.FinishedSignal().Connect(&application, finishCheck);
8105 application.SendNotification();
8106 application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
8108 // We didn't expect the animation to finish yet
8109 application.SendNotification();
8110 finishCheck.CheckSignalNotReceived();
8111 DALI_TEST_EQUALS( actor.GetCurrentScale(), ninetyNinePercentProgress, TEST_LOCATION );
8113 application.SendNotification();
8114 application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
8116 // We did expect the animation to finish
8117 application.SendNotification();
8118 finishCheck.CheckSignalReceived();
8119 DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
8122 finishCheck.Reset();
8123 actor.SetScale(Vector3::ONE);
8124 application.SendNotification();
8125 application.Render(0);
8126 DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
8128 // Repeat with a different (ease-in) alpha function
8129 animation = Animation::New(durationSeconds);
8130 animation.ScaleTo(actor, targetScale, AlphaFunctions::EaseIn);
8131 animation.FinishedSignal().Connect(&application, finishCheck);
8134 application.SendNotification();
8135 application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
8137 // We didn't expect the animation to finish yet
8138 application.SendNotification();
8139 finishCheck.CheckSignalNotReceived();
8141 // The scale should have grown less, than with a linear alpha function
8142 Vector3 current(actor.GetCurrentScale());
8143 DALI_TEST_CHECK( current.x > 1.0f );
8144 DALI_TEST_CHECK( current.y > 1.0f );
8145 DALI_TEST_CHECK( current.z > 1.0f );
8146 DALI_TEST_CHECK( current.x < ninetyNinePercentProgress.x );
8147 DALI_TEST_CHECK( current.y < ninetyNinePercentProgress.y );
8148 DALI_TEST_CHECK( current.z < ninetyNinePercentProgress.z );
8150 application.SendNotification();
8151 application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
8153 // We did expect the animation to finish
8154 application.SendNotification();
8155 finishCheck.CheckSignalReceived();
8156 DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
8159 finishCheck.Reset();
8160 actor.SetScale(Vector3::ONE);
8161 application.SendNotification();
8162 application.Render(0);
8163 DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
8165 // Repeat with a delay
8167 animation = Animation::New(durationSeconds);
8168 animation.ScaleTo(actor, targetScale, AlphaFunctions::Linear, delay, durationSeconds - delay);
8169 animation.FinishedSignal().Connect(&application, finishCheck);
8172 application.SendNotification();
8173 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
8175 // We didn't expect the animation to finish yet
8176 application.SendNotification();
8177 finishCheck.CheckSignalNotReceived();
8178 DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
8180 application.SendNotification();
8181 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
8183 // We did expect the animation to finish
8184 application.SendNotification();
8185 finishCheck.CheckSignalReceived();
8186 DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
8190 int UtcDaliAnimationShow(void)
8192 TestApplication application;
8194 Actor actor = Actor::New();
8195 actor.SetVisible(false);
8196 application.SendNotification();
8197 application.Render(0);
8198 DALI_TEST_CHECK( !actor.IsVisible() );
8199 Stage::GetCurrent().Add(actor);
8201 // Start the animation
8202 float durationSeconds(10.0f);
8203 Animation animation = Animation::New(durationSeconds);
8204 animation.Show(actor, durationSeconds*0.5f);
8207 bool signalReceived(false);
8208 AnimationFinishCheck finishCheck(signalReceived);
8209 animation.FinishedSignal().Connect(&application, finishCheck);
8211 application.SendNotification();
8212 application.Render(static_cast<unsigned int>(durationSeconds*490.0f));
8214 // We didn't expect the animation to finish yet
8215 application.SendNotification();
8216 finishCheck.CheckSignalNotReceived();
8217 DALI_TEST_CHECK( !actor.IsVisible() );
8219 application.SendNotification();
8220 application.Render(static_cast<unsigned int>(durationSeconds*10.0f)/*Should be shown now*/);
8222 // We didn't expect the animation to finish yet
8223 application.SendNotification();
8224 finishCheck.CheckSignalNotReceived();
8225 DALI_TEST_CHECK( actor.IsVisible() );
8227 application.SendNotification();
8228 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
8230 // We did expect the animation to finish
8231 application.SendNotification();
8232 finishCheck.CheckSignalReceived();
8233 DALI_TEST_CHECK( actor.IsVisible() );
8237 int UtcDaliAnimationHide(void)
8239 TestApplication application;
8241 Actor actor = Actor::New();
8242 DALI_TEST_CHECK( actor.IsVisible() );
8243 Stage::GetCurrent().Add(actor);
8245 // Start the animation
8246 float durationSeconds(10.0f);
8247 Animation animation = Animation::New(durationSeconds);
8248 animation.Hide(actor, durationSeconds*0.5f);
8251 bool signalReceived(false);
8252 AnimationFinishCheck finishCheck(signalReceived);
8253 animation.FinishedSignal().Connect(&application, finishCheck);
8255 application.SendNotification();
8256 application.Render(static_cast<unsigned int>(durationSeconds*490.0f));
8258 // We didn't expect the animation to finish yet
8259 application.SendNotification();
8260 finishCheck.CheckSignalNotReceived();
8261 DALI_TEST_CHECK( actor.IsVisible() );
8263 application.SendNotification();
8264 application.Render(static_cast<unsigned int>(durationSeconds*10.0f)/*Should be hidden now*/);
8266 // We didn't expect the animation to finish yet
8267 application.SendNotification();
8268 finishCheck.CheckSignalNotReceived();
8269 DALI_TEST_CHECK( !actor.IsVisible() );
8271 application.SendNotification();
8272 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
8274 // We did expect the animation to finish
8275 application.SendNotification();
8276 finishCheck.CheckSignalReceived();
8277 DALI_TEST_CHECK( !actor.IsVisible() );
8281 int UtcDaliAnimationShowHideAtEnd(void)
8283 // Test that show/hide delay can be the same as animation duration
8284 // i.e. to show/hide at the end of the animation
8286 TestApplication application;
8288 Actor actor = Actor::New();
8289 DALI_TEST_CHECK( actor.IsVisible() );
8290 Stage::GetCurrent().Add(actor);
8292 // Start Hide animation
8293 float durationSeconds(10.0f);
8294 Animation animation = Animation::New(durationSeconds);
8295 animation.Hide(actor, durationSeconds/*Hide at end*/);
8298 bool signalReceived(false);
8299 AnimationFinishCheck finishCheck(signalReceived);
8300 animation.FinishedSignal().Connect(&application, finishCheck);
8302 application.SendNotification();
8303 application.Render(static_cast<unsigned int>(durationSeconds*1000.0f) + 1u/*just beyond the animation duration*/);
8305 // We did expect the animation to finish
8306 application.SendNotification();
8307 finishCheck.CheckSignalReceived();
8308 DALI_TEST_CHECK( !actor.IsVisible() );
8310 // Start Show animation
8311 animation = Animation::New(durationSeconds);
8312 animation.Show(actor, durationSeconds/*Show at end*/);
8313 animation.FinishedSignal().Connect(&application, finishCheck);
8316 application.SendNotification();
8317 application.Render(static_cast<unsigned int>(durationSeconds*1000.0f) + 1u/*just beyond the animation duration*/);
8319 // We did expect the animation to finish
8320 application.SendNotification();
8321 finishCheck.CheckSignalReceived();
8322 DALI_TEST_CHECK( actor.IsVisible() );
8326 int UtcDaliAnimationOpacityBy(void)
8328 TestApplication application;
8329 Actor actor = Actor::New();
8330 float startingOpacity(0.5f);
8331 actor.SetOpacity(startingOpacity);
8332 application.SendNotification();
8333 application.Render(0);
8334 DALI_TEST_EQUALS( actor.GetCurrentOpacity(), startingOpacity, TEST_LOCATION );
8335 Stage::GetCurrent().Add(actor);
8337 // Build the animation
8338 float durationSeconds(1.0f);
8339 Animation animation = Animation::New(durationSeconds);
8340 float relativeOpacity(-0.5f); // target of zero
8341 animation.OpacityBy(actor, relativeOpacity);
8343 float seventyFivePercentProgress((1.0f - 0.75f) * startingOpacity);
8345 // Start the animation
8348 bool signalReceived(false);
8349 AnimationFinishCheck finishCheck(signalReceived);
8350 animation.FinishedSignal().Connect(&application, finishCheck);
8352 application.SendNotification();
8353 application.Render(static_cast<unsigned int>(durationSeconds*750.0f)/* 75% progress */);
8355 // We didn't expect the animation to finish yet
8356 application.SendNotification();
8357 finishCheck.CheckSignalNotReceived();
8358 DALI_TEST_EQUALS( actor.GetCurrentOpacity(), seventyFivePercentProgress, TEST_LOCATION );
8360 application.SendNotification();
8361 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
8363 // We did expect the animation to finish
8364 application.SendNotification();
8365 finishCheck.CheckSignalReceived();
8366 DALI_TEST_EQUALS( actor.GetCurrentOpacity(), startingOpacity+relativeOpacity, TEST_LOCATION );
8369 finishCheck.Reset();
8370 actor.SetOpacity(startingOpacity);
8371 application.SendNotification();
8372 application.Render(0);
8373 DALI_TEST_EQUALS( actor.GetCurrentOpacity(), startingOpacity, TEST_LOCATION );
8375 // Repeat with a different (ease-in) alpha function
8376 animation = Animation::New(durationSeconds);
8377 animation.OpacityBy(actor, relativeOpacity, AlphaFunctions::EaseIn);
8378 animation.FinishedSignal().Connect(&application, finishCheck);
8381 application.SendNotification();
8382 application.Render(static_cast<unsigned int>(durationSeconds*750.0f)/* 75% progress */);
8384 // We didn't expect the animation to finish yet
8385 application.SendNotification();
8386 finishCheck.CheckSignalNotReceived();
8388 // The opacity should reduce less, than with a linear alpha function
8389 float current(actor.GetCurrentOpacity());
8390 DALI_TEST_CHECK( current < 1.0f );
8391 DALI_TEST_CHECK( current > seventyFivePercentProgress );
8393 application.SendNotification();
8394 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
8396 // We did expect the animation to finish
8397 application.SendNotification();
8398 finishCheck.CheckSignalReceived();
8399 DALI_TEST_EQUALS( actor.GetCurrentOpacity(), startingOpacity+relativeOpacity, TEST_LOCATION );
8402 finishCheck.Reset();
8403 actor.SetOpacity(startingOpacity);
8404 application.SendNotification();
8405 application.Render(0);
8406 DALI_TEST_EQUALS( actor.GetCurrentOpacity(), startingOpacity, TEST_LOCATION );
8408 // Repeat with a delay
8410 animation = Animation::New(durationSeconds);
8411 animation.OpacityBy(actor, relativeOpacity, AlphaFunctions::Linear, delay, durationSeconds - delay);
8412 animation.FinishedSignal().Connect(&application, finishCheck);
8415 application.SendNotification();
8416 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
8418 // We didn't expect the animation to finish yet
8419 application.SendNotification();
8420 finishCheck.CheckSignalNotReceived();
8421 DALI_TEST_EQUALS( actor.GetCurrentOpacity(), startingOpacity, TEST_LOCATION );
8423 application.SendNotification();
8424 application.Render(static_cast<unsigned int>(durationSeconds*500.0f*0.75)/* 7/8 animation progress, 3/4 animator progress */);
8426 // We didn't expect the animation to finish yet
8427 application.SendNotification();
8428 finishCheck.CheckSignalNotReceived();
8429 DALI_TEST_EQUALS( actor.GetCurrentOpacity(), seventyFivePercentProgress, TEST_LOCATION );
8431 application.SendNotification();
8432 application.Render(static_cast<unsigned int>(durationSeconds*500.0f*0.25) + 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.GetCurrentOpacity(), startingOpacity+relativeOpacity, TEST_LOCATION );
8441 int UtcDaliAnimationOpacityTo(void)
8443 TestApplication application;
8445 Actor actor = Actor::New();
8446 Stage::GetCurrent().Add(actor);
8447 DALI_TEST_EQUALS( actor.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
8449 // Build the animation
8450 float durationSeconds(1.0f);
8451 Animation animation = Animation::New(durationSeconds);
8452 float targetOpacity(0.0f);
8453 animation.OpacityTo(actor, targetOpacity);
8455 float ninetyNinePercentProgress(0.01f);
8457 // Start the animation
8460 bool signalReceived(false);
8461 AnimationFinishCheck finishCheck(signalReceived);
8462 animation.FinishedSignal().Connect(&application, finishCheck);
8464 application.SendNotification();
8465 application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
8467 // We didn't expect the animation to finish yet
8468 application.SendNotification();
8469 finishCheck.CheckSignalNotReceived();
8470 DALI_TEST_EQUALS( actor.GetCurrentOpacity(), ninetyNinePercentProgress, 0.001f, TEST_LOCATION );
8472 application.SendNotification();
8473 application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
8475 // We did expect the animation to finish
8476 application.SendNotification();
8477 finishCheck.CheckSignalReceived();
8478 DALI_TEST_EQUALS( actor.GetCurrentOpacity(), targetOpacity, TEST_LOCATION );
8481 finishCheck.Reset();
8482 actor.SetOpacity(1.0f);
8483 application.SendNotification();
8484 application.Render(0);
8485 DALI_TEST_EQUALS( actor.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
8487 // Repeat with a different (ease-in) alpha function
8488 animation = Animation::New(durationSeconds);
8489 animation.OpacityTo(actor, targetOpacity, AlphaFunctions::EaseIn);
8490 animation.FinishedSignal().Connect(&application, finishCheck);
8493 application.SendNotification();
8494 application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
8496 // We didn't expect the animation to finish yet
8497 application.SendNotification();
8498 finishCheck.CheckSignalNotReceived();
8500 // The opacity should reduce less, than with a linear alpha function
8501 float current(actor.GetCurrentOpacity());
8502 DALI_TEST_CHECK( current < 1.0f );
8503 DALI_TEST_CHECK( current > ninetyNinePercentProgress );
8505 application.SendNotification();
8506 application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
8508 // We did expect the animation to finish
8509 application.SendNotification();
8510 finishCheck.CheckSignalReceived();
8511 DALI_TEST_EQUALS( actor.GetCurrentOpacity(), targetOpacity, TEST_LOCATION );
8514 finishCheck.Reset();
8515 actor.SetOpacity(1.0f);
8516 application.SendNotification();
8517 application.Render(0);
8518 DALI_TEST_EQUALS( actor.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
8520 // Repeat with a delay
8522 animation = Animation::New(durationSeconds);
8523 animation.OpacityTo(actor, targetOpacity, AlphaFunctions::Linear, delay, durationSeconds - delay);
8524 animation.FinishedSignal().Connect(&application, finishCheck);
8527 application.SendNotification();
8528 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
8530 // We didn't expect the animation to finish yet
8531 application.SendNotification();
8532 finishCheck.CheckSignalNotReceived();
8533 DALI_TEST_EQUALS( actor.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
8535 application.SendNotification();
8536 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
8538 // We did expect the animation to finish
8539 application.SendNotification();
8540 finishCheck.CheckSignalReceived();
8541 DALI_TEST_EQUALS( actor.GetCurrentOpacity(), targetOpacity, TEST_LOCATION );
8545 int UtcDaliAnimationColorBy(void)
8547 TestApplication application;
8549 Actor actor = Actor::New();
8550 actor.SetColor(Color::BLACK);
8551 application.SendNotification();
8552 application.Render(0);
8553 DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::BLACK, TEST_LOCATION );
8554 Stage::GetCurrent().Add(actor);
8556 // Build the animation
8557 float durationSeconds(1.0f);
8558 Animation animation = Animation::New(durationSeconds);
8559 Vector4 targetColor(Color::GREEN);
8560 Vector4 relativeColor(Color::GREEN); // Note the alpha is automatically clamped <= 1.0f in world color
8561 animation.ColorBy(actor, relativeColor);
8563 Vector4 tenPercentProgress(Vector4(0.0f, 0.1f, 0.0f, 1.0f));
8564 Vector4 twentyPercentProgress(Vector4(0.0f, 0.2f, 0.0f, 1.0f));
8566 // Start the animation
8569 bool signalReceived(false);
8570 AnimationFinishCheck finishCheck(signalReceived);
8571 animation.FinishedSignal().Connect(&application, finishCheck);
8573 application.SendNotification();
8574 application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% progress */);
8576 // We didn't expect the animation to finish yet
8577 application.SendNotification();
8578 finishCheck.CheckSignalNotReceived();
8579 DALI_TEST_EQUALS( actor.GetCurrentWorldColor(), tenPercentProgress, TEST_LOCATION );
8581 application.SendNotification();
8582 application.Render(static_cast<unsigned int>(durationSeconds*900.0f) + 1u/*just beyond the animation duration*/);
8584 // We did expect the animation to finish
8585 application.SendNotification();
8586 finishCheck.CheckSignalReceived();
8587 DALI_TEST_EQUALS( actor.GetCurrentWorldColor(), targetColor, TEST_LOCATION );
8590 finishCheck.Reset();
8591 actor.SetColor(Color::BLACK);
8592 application.SendNotification();
8593 application.Render(0);
8594 DALI_TEST_EQUALS( actor.GetCurrentWorldColor(), Color::BLACK, TEST_LOCATION );
8596 // Repeat with a different (ease-in) alpha function
8597 animation = Animation::New(durationSeconds);
8598 animation.ColorBy(actor, relativeColor, AlphaFunctions::EaseIn);
8599 animation.FinishedSignal().Connect(&application, finishCheck);
8602 application.SendNotification();
8603 application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% progress */);
8605 // We didn't expect the animation to finish yet
8606 application.SendNotification();
8607 finishCheck.CheckSignalNotReceived();
8609 // The color should have changed less, than with a linear alpha function
8610 Vector4 current(actor.GetCurrentWorldColor());
8611 DALI_TEST_CHECK( current.x == 0.0f ); // doesn't change
8612 DALI_TEST_CHECK( current.y > 0.0f );
8613 DALI_TEST_CHECK( current.y < tenPercentProgress.y );
8614 DALI_TEST_CHECK( current.z == 0.0f ); // doesn't change
8615 DALI_TEST_CHECK( current.w == 1.0f ); // doesn't change
8617 application.SendNotification();
8618 application.Render(static_cast<unsigned int>(durationSeconds*900.0f) + 1u/*just beyond the animation duration*/);
8620 // We did expect the animation to finish
8621 application.SendNotification();
8622 finishCheck.CheckSignalReceived();
8623 DALI_TEST_EQUALS( actor.GetCurrentWorldColor(), targetColor, TEST_LOCATION );
8626 finishCheck.Reset();
8627 actor.SetColor(Color::BLACK);
8628 application.SendNotification();
8629 application.Render(0);
8630 DALI_TEST_EQUALS( actor.GetCurrentWorldColor(), Color::BLACK, TEST_LOCATION );
8632 // Repeat with a shorter animator duration
8633 float animatorDuration = 0.5f;
8634 animation = Animation::New(durationSeconds);
8635 animation.ColorBy(actor, relativeColor, AlphaFunctions::Linear, 0, animatorDuration);
8636 animation.FinishedSignal().Connect(&application, finishCheck);
8639 application.SendNotification();
8640 application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% animation progress, 20% animator progress */);
8642 // We didn't expect the animation to finish yet
8643 application.SendNotification();
8644 finishCheck.CheckSignalNotReceived();
8645 DALI_TEST_EQUALS( actor.GetCurrentWorldColor(), twentyPercentProgress, TEST_LOCATION );
8647 application.SendNotification();
8648 application.Render(static_cast<unsigned int>(durationSeconds*400.0f)/* 50% animation progress, 100% animator progress */);
8650 // We didn't expect the animation to finish yet
8651 application.SendNotification();
8652 finishCheck.CheckSignalNotReceived();
8653 DALI_TEST_EQUALS( actor.GetCurrentWorldColor(), targetColor, TEST_LOCATION );
8655 application.SendNotification();
8656 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
8658 // We did expect the animation to finish
8659 application.SendNotification();
8660 finishCheck.CheckSignalReceived();
8661 DALI_TEST_EQUALS( actor.GetCurrentWorldColor(), targetColor, TEST_LOCATION );
8665 int UtcDaliAnimationColorTo(void)
8667 TestApplication application;
8669 Actor actor = Actor::New();
8670 Stage::GetCurrent().Add(actor);
8671 DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
8673 // Build the animation
8674 float durationSeconds(1.0f);
8675 Animation animation = Animation::New(durationSeconds);
8676 Vector4 targetColor(Color::RED);
8677 animation.ColorTo(actor, targetColor);
8679 Vector4 tenPercentProgress(Vector4(1.0f, 0.9f, 0.9f, 1.0f));
8680 Vector4 twentyPercentProgress(Vector4(1.0f, 0.8f, 0.8f, 1.0f));
8682 // Start the animation
8685 bool signalReceived(false);
8686 AnimationFinishCheck finishCheck(signalReceived);
8687 animation.FinishedSignal().Connect(&application, finishCheck);
8689 application.SendNotification();
8690 application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% progress */);
8692 // We didn't expect the animation to finish yet
8693 application.SendNotification();
8694 finishCheck.CheckSignalNotReceived();
8695 DALI_TEST_EQUALS( actor.GetCurrentColor(), tenPercentProgress, TEST_LOCATION );
8697 application.SendNotification();
8698 application.Render(static_cast<unsigned int>(durationSeconds*900.0f) + 1u/*just beyond the animation duration*/);
8700 // We did expect the animation to finish
8701 application.SendNotification();
8702 finishCheck.CheckSignalReceived();
8703 DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION );
8706 finishCheck.Reset();
8707 actor.SetColor(Color::WHITE);
8708 application.SendNotification();
8709 application.Render(0);
8710 DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
8712 // Repeat with a different (ease-in) alpha function
8713 animation = Animation::New(durationSeconds);
8714 animation.ColorTo(actor, targetColor, AlphaFunctions::EaseIn);
8715 animation.FinishedSignal().Connect(&application, finishCheck);
8718 application.SendNotification();
8719 application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% progress */);
8721 // We didn't expect the animation to finish yet
8722 application.SendNotification();
8723 finishCheck.CheckSignalNotReceived();
8725 // The color should have changed less, than with a linear alpha function
8726 Vector4 current(actor.GetCurrentColor());
8727 DALI_TEST_CHECK( current.x == 1.0f ); // doesn't change
8728 DALI_TEST_CHECK( current.y < 1.0f );
8729 DALI_TEST_CHECK( current.y > tenPercentProgress.y );
8730 DALI_TEST_CHECK( current.z < 1.0f );
8731 DALI_TEST_CHECK( current.z > tenPercentProgress.z );
8732 DALI_TEST_CHECK( current.w == 1.0f ); // doesn't change
8734 application.SendNotification();
8735 application.Render(static_cast<unsigned int>(durationSeconds*900.0f) + 1u/*just beyond the animation duration*/);
8737 // We did expect the animation to finish
8738 application.SendNotification();
8739 finishCheck.CheckSignalReceived();
8740 DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION );
8743 finishCheck.Reset();
8744 actor.SetColor(Color::WHITE);
8745 application.SendNotification();
8746 application.Render(0);
8747 DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
8749 // Repeat with a shorter animator duration
8750 float animatorDuration = 0.5f;
8751 animation = Animation::New(durationSeconds);
8752 animation.ColorTo(actor, targetColor, AlphaFunctions::Linear, 0, animatorDuration);
8753 animation.FinishedSignal().Connect(&application, finishCheck);
8756 application.SendNotification();
8757 application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% animation progress, 20% animator progress */);
8759 // We didn't expect the animation to finish yet
8760 application.SendNotification();
8761 finishCheck.CheckSignalNotReceived();
8762 DALI_TEST_EQUALS( actor.GetCurrentColor(), twentyPercentProgress, TEST_LOCATION );
8764 application.SendNotification();
8765 application.Render(static_cast<unsigned int>(durationSeconds*400.0f)/* 50% animation progress, 100% animator progress */);
8767 // We didn't expect the animation to finish yet
8768 application.SendNotification();
8769 finishCheck.CheckSignalNotReceived();
8770 DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION );
8772 application.SendNotification();
8773 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
8775 // We did expect the animation to finish
8776 application.SendNotification();
8777 finishCheck.CheckSignalReceived();
8778 DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION );
8782 int UtcDaliAnimationResize(void)
8784 TestApplication application;
8786 Actor actor = Actor::New();
8787 Stage::GetCurrent().Add(actor);
8788 DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
8790 // Build the animation
8791 float durationSeconds(1.0f);
8792 Animation animation = Animation::New(durationSeconds);
8793 Vector3 targetSize(100.0f, 100.0f, 100.0f);
8794 animation.Resize(actor, targetSize);
8796 Vector3 ninetyNinePercentProgress(targetSize * 0.99f);
8798 // Start the animation
8801 bool signalReceived(false);
8802 AnimationFinishCheck finishCheck(signalReceived);
8803 animation.FinishedSignal().Connect(&application, finishCheck);
8805 application.SendNotification();
8806 application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
8808 // We didn't expect the animation to finish yet
8809 application.SendNotification();
8810 finishCheck.CheckSignalNotReceived();
8811 DALI_TEST_EQUALS( actor.GetCurrentSize(), ninetyNinePercentProgress, TEST_LOCATION );
8813 application.SendNotification();
8814 application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
8816 // We did expect the animation to finish
8817 application.SendNotification();
8818 finishCheck.CheckSignalReceived();
8819 DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION );
8822 finishCheck.Reset();
8823 actor.SetSize(Vector3::ZERO);
8824 application.SendNotification();
8825 application.Render(0);
8826 DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
8828 // Repeat with a different (ease-in) alpha function
8829 animation = Animation::New(durationSeconds);
8830 animation.Resize(actor, targetSize, AlphaFunctions::EaseIn);
8831 animation.FinishedSignal().Connect(&application, finishCheck);
8834 application.SendNotification();
8835 application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
8837 // We didn't expect the animation to finish yet
8838 application.SendNotification();
8839 finishCheck.CheckSignalNotReceived();
8841 // The size should have travelled less, than with a linear alpha function
8842 Vector3 current(actor.GetCurrentSize());
8843 DALI_TEST_CHECK( current.x > 0.0f );
8844 DALI_TEST_CHECK( current.y > 0.0f );
8845 DALI_TEST_CHECK( current.z > 0.0f );
8846 DALI_TEST_CHECK( current.x < ninetyNinePercentProgress.x );
8847 DALI_TEST_CHECK( current.y < ninetyNinePercentProgress.y );
8848 DALI_TEST_CHECK( current.z < ninetyNinePercentProgress.z );
8850 application.SendNotification();
8851 application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
8853 // We did expect the animation to finish
8854 application.SendNotification();
8855 finishCheck.CheckSignalReceived();
8856 DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION );
8859 finishCheck.Reset();
8860 actor.SetSize(Vector3::ZERO);
8861 application.SendNotification();
8862 application.Render(0);
8863 DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
8865 // Repeat with a delay
8867 animation = Animation::New(durationSeconds);
8868 animation.Resize(actor, targetSize, AlphaFunctions::Linear, delay, durationSeconds - delay);
8869 animation.FinishedSignal().Connect(&application, finishCheck);
8872 application.SendNotification();
8873 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
8875 // We didn't expect the animation to finish yet
8876 application.SendNotification();
8877 finishCheck.CheckSignalNotReceived();
8878 DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
8880 application.SendNotification();
8881 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
8883 // We did expect the animation to finish
8884 application.SendNotification();
8885 finishCheck.CheckSignalReceived();
8886 DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION );
8890 int UtcDaliAnimationAnimateBool(void)
8892 TestApplication application;
8894 Actor actor = Actor::New();
8895 DALI_TEST_EQUALS( actor.IsVisible(), true, TEST_LOCATION );
8896 Stage::GetCurrent().Add(actor);
8898 // Build the animation
8899 float durationSeconds(10.0f);
8900 Animation animation = Animation::New(durationSeconds);
8901 animation.Animate<bool>( Property(actor, Actor::VISIBLE), ReturnFalseAfterProgressOne, TimePeriod(durationSeconds*0.25f/*delay*/, durationSeconds*0.1f) );
8903 // Start the animation
8906 bool signalReceived(false);
8907 AnimationFinishCheck finishCheck(signalReceived);
8908 animation.FinishedSignal().Connect(&application, finishCheck);
8910 application.SendNotification();
8911 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
8913 // We didn't expect the animation to finish yet
8914 application.SendNotification();
8915 finishCheck.CheckSignalNotReceived();
8917 // Should still be visible
8918 DALI_TEST_EQUALS( actor.IsVisible(), true, TEST_LOCATION );
8920 application.SendNotification();
8921 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
8923 // We didn't expect the animation to finish yet
8924 application.SendNotification();
8925 finishCheck.CheckSignalNotReceived();
8927 // Now animate functor should have hidden the actor
8928 DALI_TEST_EQUALS( actor.IsVisible(), false, TEST_LOCATION );
8930 application.SendNotification();
8931 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
8933 // We did expect the animation to finish
8934 application.SendNotification();
8935 finishCheck.CheckSignalReceived();
8936 DALI_TEST_EQUALS( actor.IsVisible(), false, TEST_LOCATION );
8940 int UtcDaliAnimationAnimateFloat(void)
8942 TestApplication application;
8944 Actor actor = Actor::New();
8945 Stage::GetCurrent().Add(actor);
8947 // Register a float property
8948 float startValue(10.0f);
8949 Property::Index index = actor.RegisterProperty( "test-property", startValue );
8950 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
8952 // Build the animation
8953 float durationSeconds(10.0f);
8954 Animation animation = Animation::New(durationSeconds);
8955 float targetPosition(0.0f);
8956 AnimateFloatTestFunctor func( 100, targetPosition );
8957 animation.Animate<float>( Property(actor, index), func );
8959 // Start the animation
8962 bool signalReceived(false);
8963 AnimationFinishCheck finishCheck(signalReceived);
8964 animation.FinishedSignal().Connect(&application, finishCheck);
8966 application.SendNotification();
8967 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
8969 // We didn't expect the animation to finish yet
8970 application.SendNotification();
8971 finishCheck.CheckSignalNotReceived();
8972 DALI_TEST_EQUALS( actor.GetProperty<float>(index), 75.0f, TEST_LOCATION );
8974 application.SendNotification();
8975 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
8977 // We didn't expect the animation to finish yet
8978 application.SendNotification();
8979 finishCheck.CheckSignalNotReceived();
8980 DALI_TEST_EQUALS( actor.GetProperty<float>(index), 50.0f, TEST_LOCATION );
8982 application.SendNotification();
8983 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
8985 // We didn't expect the animation to finish yet
8986 application.SendNotification();
8987 finishCheck.CheckSignalNotReceived();
8988 DALI_TEST_EQUALS( actor.GetProperty<float>(index), 25.0f, TEST_LOCATION );
8990 application.SendNotification();
8991 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
8993 // We did expect the animation to finish
8994 application.SendNotification();
8995 finishCheck.CheckSignalReceived();
8996 DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetPosition, TEST_LOCATION );
9000 int UtcDaliAnimationAnimateInteger(void)
9002 TestApplication application;
9004 Actor actor = Actor::New();
9005 Stage::GetCurrent().Add(actor);
9007 // Register an integer property
9009 Property::Index index = actor.RegisterProperty( "test-property", startValue );
9010 DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
9012 // Build the animation
9013 float durationSeconds(10.0f);
9014 Animation animation = Animation::New(durationSeconds);
9015 int targetPosition(0);
9016 AnimateIntegerTestFunctor func( 100, targetPosition );
9017 animation.Animate<int>( Property(actor, index), func );
9019 // Start the animation
9022 bool signalReceived(false);
9023 AnimationFinishCheck finishCheck(signalReceived);
9024 animation.FinishedSignal().Connect(&application, finishCheck);
9026 application.SendNotification();
9027 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
9029 // We didn't expect the animation to finish yet
9030 application.SendNotification();
9031 finishCheck.CheckSignalNotReceived();
9032 DALI_TEST_EQUALS( actor.GetProperty<int>(index), 75, TEST_LOCATION );
9034 application.SendNotification();
9035 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
9037 // We didn't expect the animation to finish yet
9038 application.SendNotification();
9039 finishCheck.CheckSignalNotReceived();
9040 DALI_TEST_EQUALS( actor.GetProperty<int>(index), 50, TEST_LOCATION );
9042 application.SendNotification();
9043 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
9045 // We didn't expect the animation to finish yet
9046 application.SendNotification();
9047 finishCheck.CheckSignalNotReceived();
9048 DALI_TEST_EQUALS( actor.GetProperty<int>(index), 25, TEST_LOCATION );
9050 application.SendNotification();
9051 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
9053 // We did expect the animation to finish
9054 application.SendNotification();
9055 finishCheck.CheckSignalReceived();
9056 DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetPosition, TEST_LOCATION );
9060 int UtcDaliAnimationAnimateVector2(void)
9062 TestApplication application;
9064 Actor actor = Actor::New();
9065 Stage::GetCurrent().Add(actor);
9067 // Register a Vector2 property
9068 Vector2 startValue(10.0f, 10.0f);
9069 Property::Index index = actor.RegisterProperty( "test-property", startValue );
9070 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
9072 // Build the animation
9073 float durationSeconds(10.0f);
9074 Animation animation = Animation::New(durationSeconds);
9075 Vector2 targetPosition(0.0f, 0.0f);
9076 AnimateVector2TestFunctor func( Vector2(100,100), targetPosition );
9077 animation.Animate<Vector2>( Property(actor, index), func );
9079 // Start the animation
9082 bool signalReceived(false);
9083 AnimationFinishCheck finishCheck(signalReceived);
9084 animation.FinishedSignal().Connect(&application, finishCheck);
9086 application.SendNotification();
9087 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
9089 // We didn't expect the animation to finish yet
9090 application.SendNotification();
9091 finishCheck.CheckSignalNotReceived();
9092 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), Vector2(75,75), TEST_LOCATION );
9094 application.SendNotification();
9095 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
9097 // We didn't expect the animation to finish yet
9098 application.SendNotification();
9099 finishCheck.CheckSignalNotReceived();
9100 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), Vector2(50,50), TEST_LOCATION );
9102 application.SendNotification();
9103 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
9105 // We didn't expect the animation to finish yet
9106 application.SendNotification();
9107 finishCheck.CheckSignalNotReceived();
9108 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), Vector2(25,25), TEST_LOCATION );
9110 application.SendNotification();
9111 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
9113 // We did expect the animation to finish
9114 application.SendNotification();
9115 finishCheck.CheckSignalReceived();
9116 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetPosition, TEST_LOCATION );
9120 int UtcDaliAnimationAnimateVector3(void)
9122 TestApplication application;
9124 Actor actor = Actor::New();
9125 Vector3 initialPosition(Vector3::ZERO);
9126 DALI_TEST_EQUALS( actor.GetCurrentPosition(), initialPosition, TEST_LOCATION );
9127 Stage::GetCurrent().Add(actor);
9129 // Build the animation
9130 float durationSeconds(10.0f);
9131 Animation animation = Animation::New(durationSeconds);
9132 Vector3 targetPosition(200.0f, 200.0f, 200.0f);
9133 BounceFunc func(0.0f, 0.0f, -100.0f);
9134 animation.Animate<Vector3>( Property(actor, Actor::POSITION), func, AlphaFunctions::Linear, durationSeconds );
9136 // Start the animation
9139 bool signalReceived(false);
9140 AnimationFinishCheck finishCheck(signalReceived);
9141 animation.FinishedSignal().Connect(&application, finishCheck);
9143 application.SendNotification();
9144 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
9146 // We didn't expect the animation to finish yet
9147 application.SendNotification();
9148 finishCheck.CheckSignalNotReceived();
9149 DALI_TEST_EQUALS( actor.GetCurrentPosition(), func(0.25f, initialPosition), TEST_LOCATION );
9151 application.SendNotification();
9152 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
9154 // We didn't expect the animation to finish yet
9155 application.SendNotification();
9156 finishCheck.CheckSignalNotReceived();
9157 DALI_TEST_EQUALS( actor.GetCurrentPosition(), func(0.5f, initialPosition), TEST_LOCATION );
9159 application.SendNotification();
9160 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
9162 // We didn't expect the animation to finish yet
9163 application.SendNotification();
9164 finishCheck.CheckSignalNotReceived();
9165 DALI_TEST_EQUALS( actor.GetCurrentPosition(), func(0.75f, initialPosition), TEST_LOCATION );
9167 application.SendNotification();
9168 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
9170 // We did expect the animation to finish
9171 application.SendNotification();
9172 finishCheck.CheckSignalReceived();
9173 DALI_TEST_EQUALS( actor.GetCurrentPosition(), initialPosition, TEST_LOCATION );
9177 int UtcDaliAnimationAnimateVector4(void)
9179 TestApplication application;
9181 Actor actor = Actor::New();
9182 Stage::GetCurrent().Add(actor);
9184 // Register a Vector4 property
9185 Vector4 startValue(10.0f, 10.0f, 10.0f, 10.0f);
9186 Property::Index index = actor.RegisterProperty( "test-property", startValue );
9187 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
9189 // Build the animation
9190 float durationSeconds(10.0f);
9191 Animation animation = Animation::New(durationSeconds);
9192 Vector4 targetPosition(200,400,0,-1000);
9193 AnimateVector4TestFunctor func( Vector4(1000,1000,1000,1000), targetPosition );
9194 animation.Animate<Vector4>( Property(actor, index), func );
9196 // Start the animation
9199 bool signalReceived(false);
9200 AnimationFinishCheck finishCheck(signalReceived);
9201 animation.FinishedSignal().Connect(&application, finishCheck);
9203 application.SendNotification();
9204 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
9206 // We didn't expect the animation to finish yet
9207 application.SendNotification();
9208 finishCheck.CheckSignalNotReceived();
9209 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), Vector4(800,850,750,500), TEST_LOCATION );
9211 application.SendNotification();
9212 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
9214 // We didn't expect the animation to finish yet
9215 application.SendNotification();
9216 finishCheck.CheckSignalNotReceived();
9217 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), Vector4(600,700,500,0), TEST_LOCATION );
9219 application.SendNotification();
9220 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
9222 // We didn't expect the animation to finish yet
9223 application.SendNotification();
9224 finishCheck.CheckSignalNotReceived();
9225 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), Vector4(400,550,250,-500), TEST_LOCATION );
9227 application.SendNotification();
9228 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
9230 // We did expect the animation to finish
9231 application.SendNotification();
9232 finishCheck.CheckSignalReceived();
9233 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetPosition, TEST_LOCATION );
9237 int UtcDaliAnimationAnimateQuaternion(void)
9239 TestApplication application;
9241 Actor actor = Actor::New();
9242 actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
9243 Stage::GetCurrent().Add(actor);
9244 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
9246 // Build the animation
9247 float durationSeconds(1.0f);
9248 Animation animation = Animation::New(durationSeconds);
9250 Degree sourceRotationDegrees(90.0f);
9251 Radian sourceRotationRadians(sourceRotationDegrees);
9252 Quaternion sourceRotation(sourceRotationRadians, Vector3::YAXIS);
9254 Degree targetRotationDegrees(150.0f);
9255 Radian targetRotationRadians(targetRotationDegrees);
9256 Quaternion targetRotation(targetRotationRadians, Vector3::YAXIS);
9258 AnimateQuaternionTestFunctor func( sourceRotation, targetRotation );
9259 animation.Animate<Quaternion>( Property(actor, Actor::ROTATION), func );
9261 // Start the animation
9264 bool signalReceived(false);
9265 AnimationFinishCheck finishCheck(signalReceived);
9266 animation.FinishedSignal().Connect(&application, finishCheck);
9268 application.SendNotification();
9269 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
9271 // We didn't expect the animation to finish yet
9272 application.SendNotification();
9273 finishCheck.CheckSignalNotReceived();
9274 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(Radian(Degree(105)), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
9276 application.SendNotification();
9277 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
9279 // We didn't expect the animation to finish yet
9280 application.SendNotification();
9281 finishCheck.CheckSignalNotReceived();
9282 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(Radian(Degree(120)), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
9284 application.SendNotification();
9285 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
9287 // We didn't expect the animation to finish yet
9288 application.SendNotification();
9289 finishCheck.CheckSignalNotReceived();
9290 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(Radian(Degree(135)), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
9292 application.SendNotification();
9293 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
9295 // We did expect the animation to finish
9296 application.SendNotification();
9297 finishCheck.CheckSignalReceived();
9298 DALI_TEST_EQUALS( actor.GetCurrentRotation(), targetRotation, ROTATION_EPSILON, TEST_LOCATION );
9302 int UtcDaliKeyFramesCreateDestroy(void)
9304 tet_infoline("Testing Dali::Animation::UtcDaliKeyFramesCreateDestroy()");
9306 KeyFrames* keyFrames = new KeyFrames;
9308 DALI_TEST_CHECK( true );
9312 int UtcDaliKeyFramesDownCast(void)
9314 TestApplication application;
9315 tet_infoline("Testing Dali::Animation::KeyFramesDownCast()");
9317 KeyFrames keyFrames = KeyFrames::New();
9318 BaseHandle object(keyFrames);
9320 KeyFrames keyFrames2 = KeyFrames::DownCast(object);
9321 DALI_TEST_CHECK(keyFrames2);
9323 KeyFrames keyFrames3 = DownCast< KeyFrames >(object);
9324 DALI_TEST_CHECK(keyFrames3);
9326 BaseHandle unInitializedObject;
9327 KeyFrames keyFrames4 = KeyFrames::DownCast(unInitializedObject);
9328 DALI_TEST_CHECK(!keyFrames4);
9330 KeyFrames keyFrames5 = DownCast< KeyFrames >(unInitializedObject);
9331 DALI_TEST_CHECK(!keyFrames5);
9335 int UtcDaliAnimationResizeByXY(void)
9337 TestApplication application;
9339 Actor actor = Actor::New();
9340 Stage::GetCurrent().Add(actor);
9341 DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
9343 // Build the animation
9344 float durationSeconds(1.0f);
9345 Animation animation = Animation::New(durationSeconds);
9346 Vector3 targetSize(100.0f, 100.0f, 100.0f);
9347 animation.Resize(actor, targetSize);
9349 Vector3 ninetyNinePercentProgress(targetSize * 0.99f);
9351 // Start the animation
9354 bool signalReceived(false);
9355 AnimationFinishCheck finishCheck(signalReceived);
9356 animation.FinishedSignal().Connect(&application, finishCheck);
9358 application.SendNotification();
9359 application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
9361 // We didn't expect the animation to finish yet
9362 application.SendNotification();
9363 finishCheck.CheckSignalNotReceived();
9364 DALI_TEST_EQUALS( actor.GetCurrentSize(), ninetyNinePercentProgress, TEST_LOCATION );
9366 application.SendNotification();
9367 application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
9369 // We did expect the animation to finish
9370 application.SendNotification();
9371 finishCheck.CheckSignalReceived();
9372 DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION );
9375 finishCheck.Reset();
9376 actor.SetSize(Vector3::ZERO);
9377 application.SendNotification();
9378 application.Render(0);
9379 DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
9381 // Repeat with a different (ease-in) alpha function
9382 animation = Animation::New(durationSeconds);
9383 animation.Resize(actor, targetSize.x, targetSize.y, AlphaFunctions::EaseIn);
9384 animation.FinishedSignal().Connect(&application, finishCheck);
9387 application.SendNotification();
9388 application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
9390 // We didn't expect the animation to finish yet
9391 application.SendNotification();
9392 finishCheck.CheckSignalNotReceived();
9394 // The size should have travelled less, than with a linear alpha function
9395 Vector3 current(actor.GetCurrentSize());
9396 DALI_TEST_CHECK( current.x > 0.0f );
9397 DALI_TEST_CHECK( current.y > 0.0f );
9398 DALI_TEST_CHECK( current.z > 0.0f );
9399 DALI_TEST_CHECK( current.x < ninetyNinePercentProgress.x );
9400 DALI_TEST_CHECK( current.y < ninetyNinePercentProgress.y );
9401 DALI_TEST_CHECK( current.z < ninetyNinePercentProgress.z );
9403 application.SendNotification();
9404 application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
9406 // We did expect the animation to finish
9407 application.SendNotification();
9408 finishCheck.CheckSignalReceived();
9409 DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION );
9412 finishCheck.Reset();
9413 actor.SetSize(Vector3::ZERO);
9414 application.SendNotification();
9415 application.Render(0);
9416 DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
9418 // Repeat with a delay
9420 animation = Animation::New(durationSeconds);
9421 animation.Resize(actor, targetSize.x, targetSize.y, AlphaFunctions::Linear, delay, durationSeconds - delay);
9422 animation.FinishedSignal().Connect(&application, finishCheck);
9425 application.SendNotification();
9426 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
9428 // We didn't expect the animation to finish yet
9429 application.SendNotification();
9430 finishCheck.CheckSignalNotReceived();
9431 DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
9433 application.SendNotification();
9434 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
9436 // We did expect the animation to finish
9437 application.SendNotification();
9438 finishCheck.CheckSignalReceived();
9439 DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION );
9444 int UtcDaliAnimationAnimateBetweenActorColorTimePeriod(void)
9446 TestApplication application;
9448 float startValue(1.0f);
9449 Actor actor = Actor::New();
9450 actor.SetColor(Vector4(startValue, startValue, startValue, startValue));
9451 Stage::GetCurrent().Add(actor);
9453 DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
9454 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
9455 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
9456 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
9457 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), startValue, TEST_LOCATION );
9459 // Build the animation
9460 float durationSeconds(1.0f);
9461 Animation animation = Animation::New(durationSeconds);
9463 KeyFrames keyFrames = KeyFrames::New();
9464 keyFrames.Add(0.0f, Vector4(0.1f, 0.2f, 0.3f, 0.4f));
9465 keyFrames.Add(0.5f, Vector4(0.9f, 0.8f, 0.7f, 0.6f));
9466 keyFrames.Add(1.0f, Vector4(1.0f, 1.0f, 1.0f, 1.0f));
9468 animation.AnimateBetween( Property(actor, Actor::COLOR), keyFrames, TimePeriod( 1.0f) );
9470 // Start the animation
9473 bool signalReceived(false);
9474 AnimationFinishCheck finishCheck(signalReceived);
9475 animation.FinishedSignal().Connect(&application, finishCheck);
9476 application.SendNotification();
9477 application.Render(0);
9478 application.SendNotification();
9479 finishCheck.CheckSignalNotReceived();
9480 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), 0.1f, 0.01f, TEST_LOCATION );
9481 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 0.2f, 0.01f, TEST_LOCATION );
9482 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), 0.3f, 0.01f, TEST_LOCATION );
9483 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.4f, 0.01f, TEST_LOCATION );
9485 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
9486 application.SendNotification();
9487 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), 0.5f, 0.01f, TEST_LOCATION );
9488 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 0.5f, 0.01f, TEST_LOCATION );
9489 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), 0.5f, 0.01f, TEST_LOCATION );
9490 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.5f, 0.01f, TEST_LOCATION );
9492 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
9493 application.SendNotification();
9494 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), 0.9f, 0.01f, TEST_LOCATION );
9495 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 0.8f, 0.01f, TEST_LOCATION );
9496 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), 0.7f, 0.01f, TEST_LOCATION );
9497 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.6f, 0.01f, TEST_LOCATION );
9499 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
9500 application.SendNotification();
9501 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), 0.95f, 0.01f, TEST_LOCATION );
9502 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 0.90f, 0.01f, TEST_LOCATION );
9503 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), 0.85f, 0.01f, TEST_LOCATION );
9504 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.80f, 0.01f, TEST_LOCATION );
9506 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
9507 application.SendNotification();
9508 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), 1.0f, 0.01f, TEST_LOCATION );
9509 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 1.0f, 0.01f, TEST_LOCATION );
9510 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), 1.0f, 0.01f, TEST_LOCATION );
9511 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 1.0f, 0.01f, TEST_LOCATION );
9513 // We did expect the animation to finish
9515 finishCheck.CheckSignalReceived();
9519 int UtcDaliAnimationAnimateBetweenActorColorFunction(void)
9521 TestApplication application;
9523 float startValue(1.0f);
9524 Actor actor = Actor::New();
9525 actor.SetColor(Vector4(startValue, startValue, startValue, startValue));
9526 Stage::GetCurrent().Add(actor);
9528 DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
9529 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
9530 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
9531 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
9532 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), startValue, TEST_LOCATION );
9534 // Build the animation
9535 float durationSeconds(1.0f);
9536 Animation animation = Animation::New(durationSeconds);
9538 KeyFrames keyFrames = KeyFrames::New();
9539 keyFrames.Add(0.0f, Vector4(0.1f, 0.2f, 0.3f, 0.4f));
9540 keyFrames.Add(0.5f, Vector4(0.9f, 0.8f, 0.7f, 0.6f));
9541 keyFrames.Add(1.0f, Vector4(1.0f, 1.0f, 1.0f, 1.0f));
9543 animation.AnimateBetween( Property(actor, Actor::COLOR), keyFrames, AlphaFunctions::Linear );
9545 // Start the animation
9548 bool signalReceived(false);
9549 AnimationFinishCheck finishCheck(signalReceived);
9550 animation.FinishedSignal().Connect(&application, finishCheck);
9551 application.SendNotification();
9552 application.Render(0);
9553 application.SendNotification();
9554 finishCheck.CheckSignalNotReceived();
9555 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), 0.1f, 0.01f, TEST_LOCATION );
9556 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 0.2f, 0.01f, TEST_LOCATION );
9557 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), 0.3f, 0.01f, TEST_LOCATION );
9558 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.4f, 0.01f, TEST_LOCATION );
9560 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
9561 application.SendNotification();
9562 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), 0.5f, 0.01f, TEST_LOCATION );
9563 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 0.5f, 0.01f, TEST_LOCATION );
9564 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), 0.5f, 0.01f, TEST_LOCATION );
9565 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.5f, 0.01f, TEST_LOCATION );
9567 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
9568 application.SendNotification();
9569 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), 0.9f, 0.01f, TEST_LOCATION );
9570 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 0.8f, 0.01f, TEST_LOCATION );
9571 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), 0.7f, 0.01f, TEST_LOCATION );
9572 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.6f, 0.01f, TEST_LOCATION );
9574 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
9575 application.SendNotification();
9576 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), 0.95f, 0.01f, TEST_LOCATION );
9577 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 0.90f, 0.01f, TEST_LOCATION );
9578 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), 0.85f, 0.01f, TEST_LOCATION );
9579 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.80f, 0.01f, TEST_LOCATION );
9581 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
9582 application.SendNotification();
9583 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), 1.0f, 0.01f, TEST_LOCATION );
9584 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 1.0f, 0.01f, TEST_LOCATION );
9585 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), 1.0f, 0.01f, TEST_LOCATION );
9586 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 1.0f, 0.01f, TEST_LOCATION );
9588 // We did expect the animation to finish
9590 finishCheck.CheckSignalReceived();
9594 int UtcDaliAnimationAnimateBetweenActorColorFunctionTimePeriod(void)
9596 TestApplication application;
9598 float startValue(1.0f);
9599 Actor actor = Actor::New();
9600 actor.SetColor(Vector4(startValue, startValue, startValue, startValue));
9601 Stage::GetCurrent().Add(actor);
9603 DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
9604 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
9605 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
9606 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
9607 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), startValue, TEST_LOCATION );
9609 // Build the animation
9610 float durationSeconds(1.0f);
9611 Animation animation = Animation::New(durationSeconds);
9613 KeyFrames keyFrames = KeyFrames::New();
9614 keyFrames.Add(0.0f, Vector4(0.1f, 0.2f, 0.3f, 0.4f));
9615 keyFrames.Add(0.5f, Vector4(0.9f, 0.8f, 0.7f, 0.6f));
9616 keyFrames.Add(1.0f, Vector4(1.0f, 1.0f, 1.0f, 1.0f));
9618 animation.AnimateBetween( Property(actor, Actor::COLOR), keyFrames, AlphaFunctions::Linear, TimePeriod( 1.0f) );
9620 // Start the animation
9623 bool signalReceived(false);
9624 AnimationFinishCheck finishCheck(signalReceived);
9625 animation.FinishedSignal().Connect(&application, finishCheck);
9626 application.SendNotification();
9627 application.Render(0);
9628 application.SendNotification();
9629 finishCheck.CheckSignalNotReceived();
9630 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), 0.1f, 0.01f, TEST_LOCATION );
9631 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 0.2f, 0.01f, TEST_LOCATION );
9632 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), 0.3f, 0.01f, TEST_LOCATION );
9633 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.4f, 0.01f, TEST_LOCATION );
9635 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
9636 application.SendNotification();
9637 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), 0.5f, 0.01f, TEST_LOCATION );
9638 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 0.5f, 0.01f, TEST_LOCATION );
9639 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), 0.5f, 0.01f, TEST_LOCATION );
9640 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.5f, 0.01f, TEST_LOCATION );
9642 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
9643 application.SendNotification();
9644 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), 0.9f, 0.01f, TEST_LOCATION );
9645 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 0.8f, 0.01f, TEST_LOCATION );
9646 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), 0.7f, 0.01f, TEST_LOCATION );
9647 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.6f, 0.01f, TEST_LOCATION );
9649 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
9650 application.SendNotification();
9651 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), 0.95f, 0.01f, TEST_LOCATION );
9652 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 0.90f, 0.01f, TEST_LOCATION );
9653 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), 0.85f, 0.01f, TEST_LOCATION );
9654 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.80f, 0.01f, TEST_LOCATION );
9656 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
9657 application.SendNotification();
9658 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), 1.0f, 0.01f, TEST_LOCATION );
9659 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 1.0f, 0.01f, TEST_LOCATION );
9660 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), 1.0f, 0.01f, TEST_LOCATION );
9661 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 1.0f, 0.01f, TEST_LOCATION );
9663 // We did expect the animation to finish
9665 finishCheck.CheckSignalReceived();
9669 int UtcDaliAnimationAnimateVector3Func(void)
9671 TestApplication application;
9673 Actor actor = Actor::New();
9674 Vector3 initialPosition(Vector3::ZERO);
9675 DALI_TEST_EQUALS( actor.GetCurrentPosition(), initialPosition, TEST_LOCATION );
9676 Stage::GetCurrent().Add(actor);
9678 // Build the animation
9679 float durationSeconds(10.0f);
9680 Animation animation = Animation::New(durationSeconds);
9681 Vector3 targetPosition(200.0f, 200.0f, 200.0f);
9682 BounceFunc func(0.0f, 0.0f, -100.0f);
9683 animation.Animate<Vector3>( Property(actor, Actor::POSITION), func, AlphaFunctions::Linear );
9685 // Start the animation
9688 bool signalReceived(false);
9689 AnimationFinishCheck finishCheck(signalReceived);
9690 animation.FinishedSignal().Connect(&application, finishCheck);
9692 application.SendNotification();
9693 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
9695 // We didn't expect the animation to finish yet
9696 application.SendNotification();
9697 finishCheck.CheckSignalNotReceived();
9698 DALI_TEST_EQUALS( actor.GetCurrentPosition(), func(0.25f, initialPosition), TEST_LOCATION );
9700 application.SendNotification();
9701 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
9703 // We didn't expect the animation to finish yet
9704 application.SendNotification();
9705 finishCheck.CheckSignalNotReceived();
9706 DALI_TEST_EQUALS( actor.GetCurrentPosition(), func(0.5f, initialPosition), TEST_LOCATION );
9708 application.SendNotification();
9709 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
9711 // We didn't expect the animation to finish yet
9712 application.SendNotification();
9713 finishCheck.CheckSignalNotReceived();
9714 DALI_TEST_EQUALS( actor.GetCurrentPosition(), func(0.75f, initialPosition), TEST_LOCATION );
9716 application.SendNotification();
9717 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
9719 // We did expect the animation to finish
9720 application.SendNotification();
9721 finishCheck.CheckSignalReceived();
9722 DALI_TEST_EQUALS( actor.GetCurrentPosition(), initialPosition, TEST_LOCATION );
9726 int UtcDaliAnimationCreateDestroy(void)
9728 TestApplication application;
9729 Animation* animation = new Animation;
9730 DALI_TEST_CHECK( animation );
9735 struct UpdateManagerTestConstraint
9737 UpdateManagerTestConstraint(TestApplication& application)
9738 : mApplication(application)
9742 Vector3 operator()(const Vector3& current)
9744 mApplication.SendNotification(); // Process events
9748 TestApplication& mApplication;
9751 int UtcDaliAnimationUpdateManager(void)
9753 TestApplication application;
9755 Actor actor = Actor::New();
9756 Stage::GetCurrent().Add( actor );
9758 // Build the animation
9759 Animation animation = Animation::New( 0.0f );
9761 bool signalReceived = false;
9762 AnimationFinishCheck finishCheck( signalReceived );
9763 animation.FinishedSignal().Connect( &application, finishCheck );
9765 Vector3 startValue(1.0f, 1.0f, 1.0f);
9766 Property::Index index = actor.RegisterProperty( "test-property", startValue );
9767 Constraint constraint = Constraint::New<Vector3>( index, UpdateManagerTestConstraint( application ) );
9768 actor.ApplyConstraint( constraint );
9770 // Apply animation to actor
9771 BounceFunc func(0.0f, 0.0f, -100.0f);
9772 animation.Animate<Vector3>( Property(actor, Actor::POSITION), func, AlphaFunctions::Linear );
9776 application.SendNotification();
9777 application.UpdateOnly( 16 );
9779 finishCheck.CheckSignalNotReceived();
9781 application.SendNotification(); // Process events
9783 finishCheck.CheckSignalReceived();
9788 int UtcDaliAnimationSignalOrder(void)
9790 TestApplication application;
9792 Actor actor = Actor::New();
9793 Stage::GetCurrent().Add( actor );
9795 // Build the animations
9796 Animation animation1 = Animation::New( 0.0f ); // finishes first frame
9797 Animation animation2 = Animation::New( 0.02f ); // finishes in 20 ms
9799 bool signal1Received = false;
9800 animation1.FinishedSignal().Connect( &application, AnimationFinishCheck( signal1Received ) );
9802 bool signal2Received = false;
9803 animation2.FinishedSignal().Connect( &application, AnimationFinishCheck( signal2Received ) );
9805 // Apply animations to actor
9806 animation1.AnimateTo( Property(actor, Actor::POSITION), Vector3( 3.0f, 2.0f, 1.0f ), AlphaFunctions::Linear );
9808 animation2.AnimateTo( Property(actor, Actor::SIZE ), Vector3( 10.0f, 20.0f, 30.0f ), AlphaFunctions::Linear );
9811 DALI_TEST_EQUALS( signal1Received, false, TEST_LOCATION );
9812 DALI_TEST_EQUALS( signal2Received, false, TEST_LOCATION );
9814 application.SendNotification();
9815 application.UpdateOnly( 10 ); // 10ms progress
9817 // no notifications yet
9818 DALI_TEST_EQUALS( signal1Received, false, TEST_LOCATION );
9819 DALI_TEST_EQUALS( signal2Received, false, TEST_LOCATION );
9821 application.SendNotification();
9824 DALI_TEST_EQUALS( signal1Received, true, TEST_LOCATION );
9825 DALI_TEST_EQUALS( signal2Received, false, TEST_LOCATION );
9826 signal1Received = false;
9828 // 1st animation is complete now, do another update with no ProcessEvents in between
9829 application.UpdateOnly( 20 ); // 20ms progress
9832 application.SendNotification();
9834 // 2nd should complete now
9835 DALI_TEST_EQUALS( signal1Received, false, TEST_LOCATION );
9836 DALI_TEST_EQUALS( signal2Received, true, TEST_LOCATION );
9841 int UtcDaliAnimationExtendDuration(void)
9843 TestApplication application;
9845 Actor actor = Actor::New();
9847 // Register a float property
9848 float startValue(10.0f);
9849 Property::Index index = actor.RegisterProperty( "test-property", startValue );
9850 Stage::GetCurrent().Add(actor);
9851 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
9853 // Build the animation
9854 float initialDurationSeconds(1.0f);
9855 float animatorDelay = 5.0f;
9856 float animatorDurationSeconds(5.0f);
9857 float extendedDurationSeconds(animatorDelay+animatorDurationSeconds);
9858 Animation animation = Animation::New(initialDurationSeconds);
9859 float targetValue(30.0f);
9860 float relativeValue(targetValue - startValue);
9862 animation.AnimateTo(Property(actor, index),
9864 TimePeriod(animatorDelay, animatorDurationSeconds));
9866 // The duration should have been extended
9867 DALI_TEST_EQUALS( animation.GetDuration(), extendedDurationSeconds, TEST_LOCATION );
9869 // Start the animation
9872 bool signalReceived(false);
9873 AnimationFinishCheck finishCheck(signalReceived);
9874 animation.FinishedSignal().Connect(&application, finishCheck);
9876 application.SendNotification();
9877 application.Render(static_cast<unsigned int>(extendedDurationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
9879 // We didn't expect the animation to finish yet
9880 application.SendNotification();
9881 finishCheck.CheckSignalNotReceived();
9882 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
9884 application.SendNotification();
9885 application.Render(static_cast<unsigned int>(extendedDurationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
9887 // We didn't expect the animation to finish yet
9888 application.SendNotification();
9889 finishCheck.CheckSignalNotReceived();
9890 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
9892 application.SendNotification();
9893 application.Render(static_cast<unsigned int>(extendedDurationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
9895 // We did expect the animation to finish
9896 application.SendNotification();
9897 finishCheck.CheckSignalReceived();
9898 DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );