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 );
1197 int UtcDaliAnimationPlayRange(void)
1199 TestApplication application;
1201 Actor actor = Actor::New();
1202 Stage::GetCurrent().Add(actor);
1204 // Build the animation
1205 float durationSeconds(1.0f);
1206 Animation animation = Animation::New(durationSeconds);
1207 Vector3 targetPosition(100.0f, 100.0f, 100.0f);
1208 KeyFrames keyframes = KeyFrames::New();
1209 keyframes.Add( 0.0f , Vector3(0.0f,0.0f,0.0f ) );
1210 keyframes.Add( 1.0f , Vector3(100.0f,100.0f,100.0f ) );
1212 animation.AnimateBetween( Property( actor, Actor::POSITION), keyframes );
1214 // Set range between 0.4 and 0.8
1215 animation.SetPlayRange( Vector2(0.4f,0.8f) );
1218 bool signalReceived(false);
1219 AnimationFinishCheck finishCheck(signalReceived);
1220 animation.FinishedSignal().Connect(&application, finishCheck);
1222 //Test that setting progress outside the range doesn't work
1223 animation.SetCurrentProgress( 0.9f );
1224 application.SendNotification();
1225 application.Render(0);
1226 DALI_TEST_EQUALS( animation.GetCurrentProgress(), 0.4f, TEST_LOCATION );
1227 animation.SetCurrentProgress( 0.2f );
1228 application.SendNotification();
1229 application.Render(0);
1230 DALI_TEST_EQUALS( animation.GetCurrentProgress(), 0.4f, TEST_LOCATION );
1232 application.SendNotification();
1233 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 60% progress */);
1235 // We didn't expect the animation to finish yet
1236 application.SendNotification();
1237 finishCheck.CheckSignalNotReceived();
1238 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.6f), TEST_LOCATION );
1240 animation.Play(); // Test that calling play has no effect, when animation is already playing
1241 application.SendNotification();
1242 application.Render(static_cast<unsigned int>(durationSeconds*200.0f) + 1u/* 80% progress */);
1244 // We did expect the animation to finish
1245 application.SendNotification();
1246 finishCheck.CheckSignalReceived();
1247 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.8f), TEST_LOCATION );
1249 // Check that nothing has changed after a couple of buffer swaps
1250 application.Render(0);
1251 DALI_TEST_EQUALS( targetPosition * 0.8f, actor.GetCurrentPosition(), TEST_LOCATION );
1252 application.Render(0);
1253 DALI_TEST_EQUALS( targetPosition * 0.8f, actor.GetCurrentPosition(), TEST_LOCATION );
1256 //Loop inside the range
1257 finishCheck.Reset();
1258 animation.SetLooping( true );
1260 application.SendNotification();
1261 float intervalSeconds = 0.1f;
1262 float progress = 0.4f;
1263 for (int iterations = 0; iterations < 10; ++iterations )
1265 application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
1267 progress += intervalSeconds;
1268 if (progress > 0.8f)
1270 progress = progress - 0.4f;
1273 DALI_TEST_EQUALS( targetPosition*progress, actor.GetCurrentPosition(), 0.001f, TEST_LOCATION );
1276 // We didn't expect the animation to finish yet
1277 application.SendNotification();
1278 finishCheck.CheckSignalNotReceived();
1281 //Test change range on the fly
1282 animation.SetPlayRange( Vector2( 0.2f, 0.9f ) );
1283 application.SendNotification();
1285 for (int iterations = 0; iterations < 10; ++iterations )
1287 application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
1289 progress += intervalSeconds;
1290 if (progress > 0.9f)
1292 progress = progress - 0.7f;
1295 DALI_TEST_EQUALS( targetPosition*progress, actor.GetCurrentPosition(), 0.001f, TEST_LOCATION );
1301 int UtcDaliAnimationSetPlayRange(void)
1303 TestApplication application;
1305 Actor actor = Actor::New();
1306 Stage::GetCurrent().Add(actor);
1308 // Build the animation
1309 Animation animation = Animation::New(0);
1310 application.SendNotification();
1312 //If PlayRange not specified it should be 0.0-1.0 by default
1313 DALI_TEST_EQUALS( Vector2(0.0,1.0), animation.GetPlayRange(), TEST_LOCATION );
1315 //PlayRange out of bounds
1316 animation.SetPlayRange( Vector2(-1.0f,1.0f) );
1317 application.SendNotification();
1318 DALI_TEST_EQUALS( Vector2(0.0f,1.0f), animation.GetPlayRange(), TEST_LOCATION );
1319 animation.SetPlayRange( Vector2(0.0f,2.0f) );
1320 application.SendNotification();
1321 DALI_TEST_EQUALS( Vector2(0.0f,1.0f), animation.GetPlayRange(), TEST_LOCATION );
1323 //If playRange is not in the correct order it has to be ordered
1324 animation.SetPlayRange( Vector2(0.8f,0.2f) );
1325 application.SendNotification();
1326 DALI_TEST_EQUALS( Vector2(0.2f,0.8f), animation.GetPlayRange(), TEST_LOCATION );
1328 // Set range between 0.4 and 0.8
1329 animation.SetPlayRange( Vector2(0.4f,0.8f) );
1330 application.SendNotification();
1331 DALI_TEST_EQUALS( Vector2(0.4f,0.8f), animation.GetPlayRange(), TEST_LOCATION );
1336 int UtcDaliAnimationPause(void)
1338 TestApplication application;
1340 Actor actor = Actor::New();
1341 Stage::GetCurrent().Add(actor);
1343 // Build the animation
1344 float durationSeconds(1.0f);
1345 Animation animation = Animation::New(durationSeconds);
1346 Vector3 targetPosition(100.0f, 100.0f, 100.0f);
1347 animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear);
1349 Vector3 fiftyPercentProgress(targetPosition * 0.5f);
1351 // Start the animation
1354 bool signalReceived(false);
1355 AnimationFinishCheck finishCheck(signalReceived);
1356 animation.FinishedSignal().Connect(&application, finishCheck);
1358 application.SendNotification();
1359 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
1361 // We didn't expect the animation to finish yet
1362 application.SendNotification();
1363 finishCheck.CheckSignalNotReceived();
1364 DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress, TEST_LOCATION );
1366 // Pause the animation
1368 application.SendNotification();
1371 for (int i=0; i<5; ++i)
1373 application.Render(static_cast<unsigned int>(durationSeconds*500.0f));
1375 // We didn't expect the animation to finish yet
1376 application.SendNotification();
1377 finishCheck.CheckSignalNotReceived();
1378 DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress/* Still 50% progress when paused */, TEST_LOCATION );
1383 application.SendNotification();
1384 application.Render(static_cast<unsigned int>(durationSeconds*490.0f)/*slightly less than the animation duration*/);
1386 // We didn't expect the animation to finish yet
1387 application.SendNotification();
1388 finishCheck.CheckSignalNotReceived();
1390 application.SendNotification();
1391 application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
1393 // We did expect the animation to finish
1394 application.SendNotification();
1395 finishCheck.CheckSignalReceived();
1396 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
1398 // Check that nothing has changed after a couple of buffer swaps
1399 application.Render(0);
1400 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
1401 application.Render(0);
1402 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
1406 int UtcDaliAnimationStop(void)
1408 TestApplication application;
1410 Actor actor = Actor::New();
1411 Stage::GetCurrent().Add(actor);
1413 // Build the animation
1414 float durationSeconds(1.0f);
1415 Animation animation = Animation::New(durationSeconds);
1416 Vector3 targetPosition(100.0f, 100.0f, 100.0f);
1417 animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear);
1419 Vector3 fiftyPercentProgress(targetPosition * 0.5f);
1421 // Start the animation
1424 bool signalReceived(false);
1425 AnimationFinishCheck finishCheck(signalReceived);
1426 animation.FinishedSignal().Connect(&application, finishCheck);
1428 application.SendNotification();
1429 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
1431 // We didn't expect the animation to finish yet
1432 application.SendNotification();
1433 finishCheck.CheckSignalNotReceived();
1434 DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress, TEST_LOCATION );
1436 // Stop the animation
1438 application.SendNotification();
1441 for (int i=0; i<5; ++i)
1443 application.Render(static_cast<unsigned int>(durationSeconds*500.0f));
1445 // We did expect the animation to finish
1446 application.SendNotification();
1447 finishCheck.CheckSignalReceived();
1448 DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress/* Still 50% progress when stopped */, TEST_LOCATION );
1453 int UtcDaliAnimationStopSetPosition(void)
1455 // Test that Animation::Stop & Actor::SetPosition can be used in conjunction
1456 // i.e. to check that the animation does not interfere with the position set.
1458 TestApplication application;
1460 Actor actor = Actor::New();
1461 Stage::GetCurrent().Add(actor);
1463 // Build the animation
1464 float durationSeconds(1.0f);
1465 Animation animation = Animation::New(durationSeconds);
1466 Vector3 targetPosition(100.0f, 100.0f, 100.0f);
1467 animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear);
1469 Vector3 fiftyPercentProgress(targetPosition * 0.5f);
1471 // Start the animation
1474 bool signalReceived(false);
1475 AnimationFinishCheck finishCheck(signalReceived);
1476 animation.FinishedSignal().Connect(&application, finishCheck);
1478 application.SendNotification();
1479 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
1481 // We didn't expect the animation to finish yet
1482 application.SendNotification();
1483 finishCheck.CheckSignalNotReceived();
1484 DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress, TEST_LOCATION );
1486 // Stop the animation
1488 Vector3 positionSet(2.0f, 3.0f, 4.0f);
1489 actor.SetPosition(positionSet);
1490 application.SendNotification();
1493 for (int i=0; i<5; ++i)
1495 application.Render(static_cast<unsigned int>(durationSeconds*500.0f));
1497 // We did expect the animation to finish
1498 application.SendNotification();
1499 finishCheck.CheckSignalReceived();
1500 DALI_TEST_EQUALS( actor.GetCurrentPosition(), positionSet/*Animation should not interfere with this*/, TEST_LOCATION );
1505 int UtcDaliAnimationClear(void)
1507 TestApplication application;
1509 Actor actor = Actor::New();
1510 Stage::GetCurrent().Add(actor);
1512 // Build the animation
1513 float durationSeconds(1.0f);
1514 Animation animation = Animation::New(durationSeconds);
1515 Vector3 targetPosition(100.0f, 100.0f, 100.0f);
1516 animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear);
1518 Vector3 fiftyPercentProgress(targetPosition * 0.5f);
1520 // Start the animation
1523 bool signalReceived(false);
1524 AnimationFinishCheck finishCheck(signalReceived);
1525 animation.FinishedSignal().Connect(&application, finishCheck);
1527 application.SendNotification();
1528 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
1530 // We didn't expect the animation to finish yet
1531 application.SendNotification();
1532 finishCheck.CheckSignalNotReceived();
1533 DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress, TEST_LOCATION );
1535 // Clear the animation
1537 application.SendNotification();
1539 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
1541 // We don't expect the animation to finish now
1542 application.SendNotification();
1543 finishCheck.CheckSignalNotReceived();
1544 DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress/* Still 50% progress since the animator was destroyed */, TEST_LOCATION );
1546 // Restart as a scale animation; this should not move the actor's position
1547 finishCheck.Reset();
1548 actor.SetPosition(Vector3::ZERO);
1549 Vector3 targetScale(3.0f, 3.0f, 3.0f);
1550 animation.ScaleTo(actor, targetScale, AlphaFunctions::Linear);
1553 application.SendNotification();
1554 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
1556 // We didn't expect the animation to finish yet
1557 application.SendNotification();
1558 finishCheck.CheckSignalNotReceived();
1559 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO/*Check move-animator was destroyed*/, TEST_LOCATION );
1560 DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3(2.0f, 2.0f, 2.0f), TEST_LOCATION );
1562 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
1564 // We did expect the animation to finish
1565 application.SendNotification();
1566 finishCheck.CheckSignalReceived();
1567 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO/*Check move-animator was destroyed*/, TEST_LOCATION );
1568 DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
1572 int UtcDaliAnimationSignalFinish(void)
1574 TestApplication application;
1576 // Start the empty animation
1577 float durationSeconds(1.0f);
1578 Animation animation = Animation::New(durationSeconds);
1581 bool signalReceived(false);
1582 AnimationFinishCheck finishCheck(signalReceived);
1583 animation.FinishedSignal().Connect(&application, finishCheck);
1585 application.SendNotification();
1586 application.Render(static_cast<unsigned int>(durationSeconds*1000.0f) + 1u/*beyond the animation duration*/);
1588 // We did expect the animation to finish
1589 application.SendNotification();
1590 finishCheck.CheckSignalReceived();
1594 int UtcDaliAnimationAnimateByBoolean(void)
1596 TestApplication application;
1598 Actor actor = Actor::New();
1600 // Register a boolean property
1601 bool startValue(false);
1602 Property::Index index = actor.RegisterProperty( "test-property", startValue );
1603 Stage::GetCurrent().Add(actor);
1604 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
1606 // Build the animation
1607 float durationSeconds(2.0f);
1608 Animation animation = Animation::New(durationSeconds);
1609 const bool relativeValue(true);
1610 const bool finalValue( false || relativeValue );
1611 animation.AnimateBy(Property(actor, index), relativeValue);
1613 // Start the animation
1616 bool signalReceived(false);
1617 AnimationFinishCheck finishCheck(signalReceived);
1618 animation.FinishedSignal().Connect(&application, finishCheck);
1620 application.SendNotification();
1621 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
1623 // We didn't expect the animation to finish yet
1624 application.SendNotification();
1625 finishCheck.CheckSignalNotReceived();
1626 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
1628 application.SendNotification();
1629 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
1631 // We did expect the animation to finish
1632 application.SendNotification();
1633 finishCheck.CheckSignalReceived();
1634 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1636 // Check that nothing has changed after a couple of buffer swaps
1637 application.Render(0);
1638 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1639 application.Render(0);
1640 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1642 // Repeat with relative value "false" - this should be an NOOP
1643 animation = Animation::New(durationSeconds);
1644 bool noOpValue(false);
1645 animation.AnimateBy(Property(actor, index), noOpValue);
1647 // Start the animation
1650 finishCheck.Reset();
1651 animation.FinishedSignal().Connect(&application, finishCheck);
1653 application.SendNotification();
1654 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
1656 // We didn't expect the animation to finish yet
1657 application.SendNotification();
1658 finishCheck.CheckSignalNotReceived();
1659 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1661 application.SendNotification();
1662 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
1664 // We did expect the animation to finish
1665 application.SendNotification();
1666 finishCheck.CheckSignalReceived();
1667 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1669 // Check that nothing has changed after a couple of buffer swaps
1670 application.Render(0);
1671 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1672 application.Render(0);
1673 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1677 int UtcDaliAnimationAnimateByBooleanAlphaFunction(void)
1679 TestApplication application;
1681 Actor actor = Actor::New();
1683 // Register a boolean property
1684 bool startValue(false);
1685 Property::Index index = actor.RegisterProperty( "test-property", startValue );
1686 Stage::GetCurrent().Add(actor);
1687 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
1689 // Build the animation
1690 float durationSeconds(2.0f);
1691 Animation animation = Animation::New(durationSeconds);
1692 bool relativeValue(true);
1693 bool finalValue( false || relativeValue );
1694 animation.AnimateBy(Property(actor, index), relativeValue, AlphaFunctions::EaseIn);
1696 // Start the animation
1699 bool signalReceived(false);
1700 AnimationFinishCheck finishCheck(signalReceived);
1701 animation.FinishedSignal().Connect(&application, finishCheck);
1703 application.SendNotification();
1704 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
1706 // We didn't expect the animation to finish yet
1707 application.SendNotification();
1708 finishCheck.CheckSignalNotReceived();
1709 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
1711 application.SendNotification();
1712 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
1714 // We did expect the animation to finish
1715 application.SendNotification();
1716 finishCheck.CheckSignalReceived();
1717 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1719 // Check that nothing has changed after a couple of buffer swaps
1720 application.Render(0);
1721 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1722 application.Render(0);
1723 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1725 // Repeat with relative value "false" - this should be an NOOP
1726 animation = Animation::New(durationSeconds);
1727 bool noOpValue(false);
1728 animation.AnimateBy(Property(actor, index), noOpValue, AlphaFunctions::EaseIn);
1730 // Start the animation
1733 finishCheck.Reset();
1734 animation.FinishedSignal().Connect(&application, finishCheck);
1736 application.SendNotification();
1737 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
1739 // We didn't expect the animation to finish yet
1740 application.SendNotification();
1741 finishCheck.CheckSignalNotReceived();
1742 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1744 application.SendNotification();
1745 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
1747 // We did expect the animation to finish
1748 application.SendNotification();
1749 finishCheck.CheckSignalReceived();
1750 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1754 int UtcDaliAnimationAnimateByBooleanTimePeriod(void)
1756 TestApplication application;
1758 Actor actor = Actor::New();
1760 // Register a boolean property
1761 bool startValue(false);
1762 Property::Index index = actor.RegisterProperty( "test-property", startValue );
1763 Stage::GetCurrent().Add(actor);
1764 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
1766 // Build the animation
1767 float durationSeconds(2.0f);
1768 Animation animation = Animation::New(durationSeconds);
1769 bool relativeValue(true);
1770 bool finalValue( false || relativeValue );
1771 float animatorDurationSeconds(durationSeconds * 0.5f);
1772 animation.AnimateBy( Property(actor, index),
1774 TimePeriod( animatorDurationSeconds ) );
1776 // Start the animation
1779 bool signalReceived(false);
1780 AnimationFinishCheck finishCheck(signalReceived);
1781 animation.FinishedSignal().Connect(&application, finishCheck);
1783 application.SendNotification();
1784 application.Render(static_cast<unsigned int>(animatorDurationSeconds*950.0f)/* 95% animator progress */);
1786 // We didn't expect the animation to finish yet
1787 application.SendNotification();
1788 finishCheck.CheckSignalNotReceived();
1789 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
1791 application.SendNotification();
1792 application.Render(static_cast<unsigned int>(animatorDurationSeconds*50.0f) + 1u/*just beyond the animator duration*/);
1794 // We didn't expect the animation to finish yet...
1795 application.SendNotification();
1796 finishCheck.CheckSignalNotReceived();
1798 // ...however we should have reached the final value
1799 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1801 application.SendNotification();
1802 application.Render(static_cast<unsigned int>(animatorDurationSeconds*1000.0f)/*just beyond the animation duration*/);
1804 // We did expect the animation to finish
1805 application.SendNotification();
1806 finishCheck.CheckSignalReceived();
1807 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1809 // Check that nothing has changed after a couple of buffer swaps
1810 application.Render(0);
1811 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1812 application.Render(0);
1813 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1817 int UtcDaliAnimationAnimateByBooleanAlphaFunctionTimePeriod(void)
1819 TestApplication application;
1821 Actor actor = Actor::New();
1823 // Register a boolean property
1824 bool startValue(false);
1825 Property::Index index = actor.RegisterProperty( "test-property", startValue );
1826 Stage::GetCurrent().Add(actor);
1827 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
1829 // Build the animation
1830 float durationSeconds(2.0f);
1831 Animation animation = Animation::New(durationSeconds);
1832 bool relativeValue(true);
1833 bool finalValue( false || relativeValue );
1834 float animatorDurationSeconds(durationSeconds * 0.5f);
1835 animation.AnimateBy( Property(actor, index),
1837 AlphaFunctions::EaseInOut,
1838 TimePeriod( animatorDurationSeconds ) );
1840 // Start the animation
1843 bool signalReceived(false);
1844 AnimationFinishCheck finishCheck(signalReceived);
1845 animation.FinishedSignal().Connect(&application, finishCheck);
1847 application.SendNotification();
1848 application.Render(static_cast<unsigned int>(animatorDurationSeconds*950.0f)/* 95% animator progress */);
1850 // We didn't expect the animation to finish yet
1851 application.SendNotification();
1852 finishCheck.CheckSignalNotReceived();
1853 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
1855 application.SendNotification();
1856 application.Render(static_cast<unsigned int>(animatorDurationSeconds*50.0f) + 1u/*just beyond the animator duration*/);
1858 // We didn't expect the animation to finish yet...
1859 application.SendNotification();
1860 finishCheck.CheckSignalNotReceived();
1862 // ...however we should have reached the final value
1863 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1865 application.SendNotification();
1866 application.Render(static_cast<unsigned int>(animatorDurationSeconds*1000.0f)/*just beyond the animation duration*/);
1868 // We did expect the animation to finish
1869 application.SendNotification();
1870 finishCheck.CheckSignalReceived();
1871 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1873 // Check that nothing has changed after a couple of buffer swaps
1874 application.Render(0);
1875 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1876 application.Render(0);
1877 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1881 int UtcDaliAnimationAnimateByFloat(void)
1883 TestApplication application;
1885 Actor actor = Actor::New();
1887 // Register a float property
1888 float startValue(10.0f);
1889 Property::Index index = actor.RegisterProperty( "test-property", startValue );
1890 Stage::GetCurrent().Add(actor);
1891 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
1893 // Build the animation
1894 float durationSeconds(2.0f);
1895 Animation animation = Animation::New(durationSeconds);
1896 float targetValue(50.0f);
1897 float relativeValue(targetValue - startValue);
1898 animation.AnimateBy(Property(actor, index), relativeValue);
1900 float ninetyFivePercentProgress(startValue + relativeValue*0.95f);
1902 // Start the animation
1905 bool signalReceived(false);
1906 AnimationFinishCheck finishCheck(signalReceived);
1907 animation.FinishedSignal().Connect(&application, finishCheck);
1909 application.SendNotification();
1910 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
1912 // We didn't expect the animation to finish yet
1913 application.SendNotification();
1914 finishCheck.CheckSignalNotReceived();
1915 DALI_TEST_EQUALS( actor.GetProperty<float>(index), ninetyFivePercentProgress, TEST_LOCATION );
1917 application.SendNotification();
1918 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
1920 // We did expect the animation to finish
1921 application.SendNotification();
1922 finishCheck.CheckSignalReceived();
1923 DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
1925 // Check that nothing has changed after a couple of buffer swaps
1926 application.Render(0);
1927 DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
1928 application.Render(0);
1929 DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
1933 int UtcDaliAnimationAnimateByFloatAlphaFunction(void)
1935 TestApplication application;
1937 Actor actor = Actor::New();
1939 // Register a float property
1940 float startValue(10.0f);
1941 Property::Index index = actor.RegisterProperty( "test-property", startValue );
1942 Stage::GetCurrent().Add(actor);
1943 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
1945 // Build the animation
1946 float durationSeconds(1.0f);
1947 Animation animation = Animation::New(durationSeconds);
1948 float targetValue(90.0f);
1949 float relativeValue(targetValue - startValue);
1950 animation.AnimateBy(Property(actor, index), relativeValue, AlphaFunctions::EaseOut);
1952 float ninetyFivePercentProgress(startValue + relativeValue*0.95f);
1954 // Start the animation
1957 bool signalReceived(false);
1958 AnimationFinishCheck finishCheck(signalReceived);
1959 animation.FinishedSignal().Connect(&application, finishCheck);
1961 application.SendNotification();
1962 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
1964 // We didn't expect the animation to finish yet
1965 application.SendNotification();
1966 finishCheck.CheckSignalNotReceived();
1968 // The position should have moved more, than with a linear alpha function
1969 float current(actor.GetProperty<float>(index));
1970 DALI_TEST_CHECK( current > ninetyFivePercentProgress );
1972 application.SendNotification();
1973 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
1975 // We did expect the animation to finish
1976 application.SendNotification();
1977 finishCheck.CheckSignalReceived();
1978 DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
1980 // Check that nothing has changed after a couple of buffer swaps
1981 application.Render(0);
1982 DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
1983 application.Render(0);
1984 DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
1988 int UtcDaliAnimationAnimateByFloatTimePeriod(void)
1990 TestApplication application;
1992 Actor actor = Actor::New();
1994 // Register a float property
1995 float startValue(10.0f);
1996 Property::Index index = actor.RegisterProperty( "test-property", startValue );
1997 Stage::GetCurrent().Add(actor);
1998 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
2000 // Build the animation
2001 float durationSeconds(1.0f);
2002 Animation animation = Animation::New(durationSeconds);
2003 float targetValue(30.0f);
2004 float relativeValue(targetValue - startValue);
2006 animation.AnimateBy(Property(actor, index),
2008 TimePeriod(delay, durationSeconds - delay));
2010 // Start the animation
2013 bool signalReceived(false);
2014 AnimationFinishCheck finishCheck(signalReceived);
2015 animation.FinishedSignal().Connect(&application, finishCheck);
2017 application.SendNotification();
2018 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
2020 // We didn't expect the animation to finish yet
2021 application.SendNotification();
2022 finishCheck.CheckSignalNotReceived();
2023 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
2025 application.SendNotification();
2026 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
2028 // We didn't expect the animation to finish yet
2029 application.SendNotification();
2030 finishCheck.CheckSignalNotReceived();
2031 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
2033 application.SendNotification();
2034 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
2036 // We did expect the animation to finish
2037 application.SendNotification();
2038 finishCheck.CheckSignalReceived();
2039 DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
2041 // Check that nothing has changed after a couple of buffer swaps
2042 application.Render(0);
2043 DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
2044 application.Render(0);
2045 DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
2049 int UtcDaliAnimationAnimateByFloatAlphaFunctionTimePeriod(void)
2051 TestApplication application;
2053 Actor actor = Actor::New();
2055 // Register a float property
2056 float startValue(10.0f);
2057 Property::Index index = actor.RegisterProperty( "test-property", startValue );
2058 Stage::GetCurrent().Add(actor);
2059 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
2061 // Build the animation
2062 float durationSeconds(1.0f);
2063 Animation animation = Animation::New(durationSeconds);
2064 float targetValue(30.0f);
2065 float relativeValue(targetValue - startValue);
2067 animation.AnimateBy(Property(actor, index),
2069 AlphaFunctions::Linear,
2070 TimePeriod(delay, durationSeconds - delay));
2072 // Start the animation
2075 bool signalReceived(false);
2076 AnimationFinishCheck finishCheck(signalReceived);
2077 animation.FinishedSignal().Connect(&application, finishCheck);
2079 application.SendNotification();
2080 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
2082 // We didn't expect the animation to finish yet
2083 application.SendNotification();
2084 finishCheck.CheckSignalNotReceived();
2085 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
2087 application.SendNotification();
2088 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
2090 // We didn't expect the animation to finish yet
2091 application.SendNotification();
2092 finishCheck.CheckSignalNotReceived();
2093 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
2095 application.SendNotification();
2096 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
2098 // We did expect the animation to finish
2099 application.SendNotification();
2100 finishCheck.CheckSignalReceived();
2101 DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
2103 // Check that nothing has changed after a couple of buffer swaps
2104 application.Render(0);
2105 DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
2106 application.Render(0);
2107 DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
2111 int UtcDaliAnimationAnimateByInteger(void)
2113 TestApplication application;
2115 Actor actor = Actor::New();
2117 // Register an integer property
2119 Property::Index index = actor.RegisterProperty( "test-property", startValue );
2120 Stage::GetCurrent().Add(actor);
2121 DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
2123 // Build the animation
2124 float durationSeconds(2.0f);
2125 Animation animation = Animation::New(durationSeconds);
2126 int targetValue(50);
2127 int relativeValue(targetValue - startValue);
2128 animation.AnimateBy(Property(actor, index), relativeValue);
2130 int ninetyFivePercentProgress(static_cast<int>(startValue + relativeValue*0.95f + 0.5f));
2132 // Start the animation
2135 bool signalReceived(false);
2136 AnimationFinishCheck finishCheck(signalReceived);
2137 animation.FinishedSignal().Connect(&application, finishCheck);
2139 application.SendNotification();
2140 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
2142 // We didn't expect the animation to finish yet
2143 application.SendNotification();
2144 finishCheck.CheckSignalNotReceived();
2145 DALI_TEST_EQUALS( actor.GetProperty<int>(index), ninetyFivePercentProgress, TEST_LOCATION );
2147 application.SendNotification();
2148 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
2150 // We did expect the animation to finish
2151 application.SendNotification();
2152 finishCheck.CheckSignalReceived();
2153 DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
2155 // Check that nothing has changed after a couple of buffer swaps
2156 application.Render(0);
2157 DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
2158 application.Render(0);
2159 DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
2163 int UtcDaliAnimationAnimateByIntegerAlphaFunction(void)
2165 TestApplication application;
2167 Actor actor = Actor::New();
2169 // Register an integer property
2171 Property::Index index = actor.RegisterProperty( "test-property", startValue );
2172 Stage::GetCurrent().Add(actor);
2173 DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
2175 // Build the animation
2176 float durationSeconds(1.0f);
2177 Animation animation = Animation::New(durationSeconds);
2178 int targetValue(90);
2179 int relativeValue(targetValue - startValue);
2180 animation.AnimateBy(Property(actor, index), relativeValue, AlphaFunctions::EaseOut);
2182 int ninetyFivePercentProgress(static_cast<int>(startValue + relativeValue*0.95f + 0.5f));
2184 // Start the animation
2187 bool signalReceived(false);
2188 AnimationFinishCheck finishCheck(signalReceived);
2189 animation.FinishedSignal().Connect(&application, finishCheck);
2191 application.SendNotification();
2192 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
2194 // We didn't expect the animation to finish yet
2195 application.SendNotification();
2196 finishCheck.CheckSignalNotReceived();
2198 // The position should have moved more, than with a linear alpha function
2199 int current(actor.GetProperty<int>(index));
2200 DALI_TEST_CHECK( current > ninetyFivePercentProgress );
2202 application.SendNotification();
2203 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
2205 // We did expect the animation to finish
2206 application.SendNotification();
2207 finishCheck.CheckSignalReceived();
2208 DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
2210 // Check that nothing has changed after a couple of buffer swaps
2211 application.Render(0);
2212 DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
2213 application.Render(0);
2214 DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
2218 int UtcDaliAnimationAnimateByIntegerTimePeriod(void)
2220 TestApplication application;
2222 Actor actor = Actor::New();
2224 // Register an integer property
2226 Property::Index index = actor.RegisterProperty( "test-property", startValue );
2227 Stage::GetCurrent().Add(actor);
2228 DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
2230 // Build the animation
2231 float durationSeconds(1.0f);
2232 Animation animation = Animation::New(durationSeconds);
2233 int targetValue(30);
2234 int relativeValue(targetValue - startValue);
2236 animation.AnimateBy(Property(actor, index),
2238 TimePeriod(delay, durationSeconds - delay));
2240 // Start the animation
2243 bool signalReceived(false);
2244 AnimationFinishCheck finishCheck(signalReceived);
2245 animation.FinishedSignal().Connect(&application, finishCheck);
2247 application.SendNotification();
2248 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
2250 // We didn't expect the animation to finish yet
2251 application.SendNotification();
2252 finishCheck.CheckSignalNotReceived();
2253 DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
2255 application.SendNotification();
2256 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
2258 // We didn't expect the animation to finish yet
2259 application.SendNotification();
2260 finishCheck.CheckSignalNotReceived();
2261 DALI_TEST_EQUALS( actor.GetProperty<int>(index), static_cast<int>(startValue+(relativeValue*0.5f)+0.5f), TEST_LOCATION );
2263 application.SendNotification();
2264 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
2266 // We did expect the animation to finish
2267 application.SendNotification();
2268 finishCheck.CheckSignalReceived();
2269 DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
2271 // Check that nothing has changed after a couple of buffer swaps
2272 application.Render(0);
2273 DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
2274 application.Render(0);
2275 DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
2279 int UtcDaliAnimationAnimateByIntegerAlphaFunctionTimePeriod(void)
2281 TestApplication application;
2283 Actor actor = Actor::New();
2285 // Register an integer property
2287 Property::Index index = actor.RegisterProperty( "test-property", startValue );
2288 Stage::GetCurrent().Add(actor);
2289 DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
2291 // Build the animation
2292 float durationSeconds(1.0f);
2293 Animation animation = Animation::New(durationSeconds);
2294 int targetValue(30);
2295 int relativeValue(targetValue - startValue);
2297 animation.AnimateBy(Property(actor, index),
2299 AlphaFunctions::Linear,
2300 TimePeriod(delay, durationSeconds - delay));
2302 // Start the animation
2305 bool signalReceived(false);
2306 AnimationFinishCheck finishCheck(signalReceived);
2307 animation.FinishedSignal().Connect(&application, finishCheck);
2309 application.SendNotification();
2310 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
2312 // We didn't expect the animation to finish yet
2313 application.SendNotification();
2314 finishCheck.CheckSignalNotReceived();
2315 DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
2317 application.SendNotification();
2318 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
2320 // We didn't expect the animation to finish yet
2321 application.SendNotification();
2322 finishCheck.CheckSignalNotReceived();
2323 DALI_TEST_EQUALS( actor.GetProperty<int>(index), static_cast<int>(startValue+(relativeValue*0.5f)+0.5f), TEST_LOCATION );
2325 application.SendNotification();
2326 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
2328 // We did expect the animation to finish
2329 application.SendNotification();
2330 finishCheck.CheckSignalReceived();
2331 DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
2333 // Check that nothing has changed after a couple of buffer swaps
2334 application.Render(0);
2335 DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
2336 application.Render(0);
2337 DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
2341 int UtcDaliAnimationAnimateByVector2(void)
2343 TestApplication application;
2345 Actor actor = Actor::New();
2347 // Register a Vector2 property
2348 Vector2 startValue(10.0f, 10.0f);
2349 Property::Index index = actor.RegisterProperty( "test-property", startValue );
2350 Stage::GetCurrent().Add(actor);
2351 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
2353 // Build the animation
2354 float durationSeconds(2.0f);
2355 Animation animation = Animation::New(durationSeconds);
2356 Vector2 targetValue(60.0f, 60.0f);
2357 Vector2 relativeValue(targetValue - startValue);
2358 animation.AnimateBy(Property(actor, index), relativeValue);
2360 Vector2 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
2362 // Start the animation
2365 bool signalReceived(false);
2366 AnimationFinishCheck finishCheck(signalReceived);
2367 animation.FinishedSignal().Connect(&application, finishCheck);
2369 application.SendNotification();
2370 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
2372 // We didn't expect the animation to finish yet
2373 application.SendNotification();
2374 finishCheck.CheckSignalNotReceived();
2375 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), ninetyFivePercentProgress, TEST_LOCATION );
2377 application.SendNotification();
2378 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
2380 // We did expect the animation to finish
2381 application.SendNotification();
2382 finishCheck.CheckSignalReceived();
2383 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
2385 // Check that nothing has changed after a couple of buffer swaps
2386 application.Render(0);
2387 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
2388 application.Render(0);
2389 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
2393 int UtcDaliAnimationAnimateByVector2AlphaFunction(void)
2395 TestApplication application;
2397 Actor actor = Actor::New();
2399 // Register a Vector2 property
2400 Vector2 startValue(100.0f, 100.0f);
2401 Property::Index index = actor.RegisterProperty( "test-property", startValue );
2402 Stage::GetCurrent().Add(actor);
2403 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
2405 // Build the animation
2406 float durationSeconds(1.0f);
2407 Animation animation = Animation::New(durationSeconds);
2408 Vector2 targetValue(20.0f, 20.0f);
2409 Vector2 relativeValue(targetValue - startValue);
2410 animation.AnimateBy(Property(actor, index), relativeValue, AlphaFunctions::EaseOut);
2412 Vector2 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
2414 // Start the animation
2417 bool signalReceived(false);
2418 AnimationFinishCheck finishCheck(signalReceived);
2419 animation.FinishedSignal().Connect(&application, finishCheck);
2421 application.SendNotification();
2422 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
2424 // We didn't expect the animation to finish yet
2425 application.SendNotification();
2426 finishCheck.CheckSignalNotReceived();
2428 // The position should have moved more, than with a linear alpha function
2429 Vector2 current(actor.GetProperty<Vector2>(index));
2430 DALI_TEST_CHECK( current.x < ninetyFivePercentProgress.x );
2431 DALI_TEST_CHECK( current.y < ninetyFivePercentProgress.y );
2433 application.SendNotification();
2434 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
2436 // We did expect the animation to finish
2437 application.SendNotification();
2438 finishCheck.CheckSignalReceived();
2439 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
2441 // Check that nothing has changed after a couple of buffer swaps
2442 application.Render(0);
2443 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
2444 application.Render(0);
2445 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
2449 int UtcDaliAnimationAnimateByVector2TimePeriod(void)
2451 TestApplication application;
2453 Actor actor = Actor::New();
2455 // Register a Vector2 property
2456 Vector2 startValue(10.0f, 10.0f);
2457 Property::Index index = actor.RegisterProperty( "test-property", startValue );
2458 Stage::GetCurrent().Add(actor);
2459 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
2461 // Build the animation
2462 float durationSeconds(1.0f);
2463 Animation animation = Animation::New(durationSeconds);
2464 Vector2 targetValue(30.0f, 30.0f);
2465 Vector2 relativeValue(targetValue - startValue);
2467 animation.AnimateBy(Property(actor, index),
2469 TimePeriod(delay, durationSeconds - delay));
2471 // Start the animation
2474 bool signalReceived(false);
2475 AnimationFinishCheck finishCheck(signalReceived);
2476 animation.FinishedSignal().Connect(&application, finishCheck);
2478 application.SendNotification();
2479 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
2481 // We didn't expect the animation to finish yet
2482 application.SendNotification();
2483 finishCheck.CheckSignalNotReceived();
2484 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
2486 application.SendNotification();
2487 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
2489 // We didn't expect the animation to finish yet
2490 application.SendNotification();
2491 finishCheck.CheckSignalNotReceived();
2492 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
2494 application.SendNotification();
2495 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
2497 // We did expect the animation to finish
2498 application.SendNotification();
2499 finishCheck.CheckSignalReceived();
2500 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
2502 // Check that nothing has changed after a couple of buffer swaps
2503 application.Render(0);
2504 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
2505 application.Render(0);
2506 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
2510 int UtcDaliAnimationAnimateByVector2AlphaFunctionTimePeriod(void)
2512 TestApplication application;
2514 Actor actor = Actor::New();
2516 // Register a Vector2 property
2517 Vector2 startValue(5.0f, 5.0f);
2518 Property::Index index = actor.RegisterProperty( "test-property", startValue );
2519 Stage::GetCurrent().Add(actor);
2520 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
2522 // Build the animation
2523 float durationSeconds(1.0f);
2524 Animation animation = Animation::New(durationSeconds);
2525 Vector2 targetValue(10.0f, 10.0f);
2526 Vector2 relativeValue(targetValue - startValue);
2528 animation.AnimateBy(Property(actor, index),
2530 AlphaFunctions::Linear,
2531 TimePeriod(delay, durationSeconds - delay));
2533 // Start the animation
2536 bool signalReceived(false);
2537 AnimationFinishCheck finishCheck(signalReceived);
2538 animation.FinishedSignal().Connect(&application, finishCheck);
2540 application.SendNotification();
2541 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
2543 // We didn't expect the animation to finish yet
2544 application.SendNotification();
2545 finishCheck.CheckSignalNotReceived();
2546 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
2548 application.SendNotification();
2549 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
2551 // We didn't expect the animation to finish yet
2552 application.SendNotification();
2553 finishCheck.CheckSignalNotReceived();
2554 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
2556 application.SendNotification();
2557 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
2559 // We did expect the animation to finish
2560 application.SendNotification();
2561 finishCheck.CheckSignalReceived();
2562 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
2564 // Check that nothing has changed after a couple of buffer swaps
2565 application.Render(0);
2566 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
2567 application.Render(0);
2568 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
2572 int UtcDaliAnimationAnimateByVector3(void)
2574 TestApplication application;
2576 Actor actor = Actor::New();
2578 // Register a Vector3 property
2579 Vector3 startValue(10.0f, 10.0f, 10.0f);
2580 Property::Index index = actor.RegisterProperty( "test-property", startValue );
2581 Stage::GetCurrent().Add(actor);
2582 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
2584 // Build the animation
2585 float durationSeconds(2.0f);
2586 Animation animation = Animation::New(durationSeconds);
2587 Vector3 targetValue(60.0f, 60.0f, 60.0f);
2588 Vector3 relativeValue(targetValue - startValue);
2589 animation.AnimateBy(Property(actor, index), relativeValue);
2591 Vector3 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
2593 // Start the animation
2596 bool signalReceived(false);
2597 AnimationFinishCheck finishCheck(signalReceived);
2598 animation.FinishedSignal().Connect(&application, finishCheck);
2600 application.SendNotification();
2601 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
2603 // We didn't expect the animation to finish yet
2604 application.SendNotification();
2605 finishCheck.CheckSignalNotReceived();
2606 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), ninetyFivePercentProgress, TEST_LOCATION );
2608 application.SendNotification();
2609 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
2611 // We did expect the animation to finish
2612 application.SendNotification();
2613 finishCheck.CheckSignalReceived();
2614 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
2616 // Check that nothing has changed after a couple of buffer swaps
2617 application.Render(0);
2618 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
2619 application.Render(0);
2620 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
2624 int UtcDaliAnimationAnimateByVector3AlphaFunction(void)
2626 TestApplication application;
2628 Actor actor = Actor::New();
2630 // Register a Vector3 property
2631 Vector3 startValue(100.0f, 100.0f, 100.0f);
2632 Property::Index index = actor.RegisterProperty( "test-property", startValue );
2633 Stage::GetCurrent().Add(actor);
2634 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
2636 // Build the animation
2637 float durationSeconds(1.0f);
2638 Animation animation = Animation::New(durationSeconds);
2639 Vector3 targetValue(20.0f, 20.0f, 20.0f);
2640 Vector3 relativeValue(targetValue - startValue);
2641 animation.AnimateBy(Property(actor, index), relativeValue, AlphaFunctions::EaseOut);
2643 Vector3 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
2645 // Start the animation
2648 bool signalReceived(false);
2649 AnimationFinishCheck finishCheck(signalReceived);
2650 animation.FinishedSignal().Connect(&application, finishCheck);
2652 application.SendNotification();
2653 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
2655 // We didn't expect the animation to finish yet
2656 application.SendNotification();
2657 finishCheck.CheckSignalNotReceived();
2659 // The position should have moved more, than with a linear alpha function
2660 Vector3 current(actor.GetProperty<Vector3>(index));
2661 DALI_TEST_CHECK( current.x < ninetyFivePercentProgress.x );
2662 DALI_TEST_CHECK( current.y < ninetyFivePercentProgress.y );
2663 DALI_TEST_CHECK( current.z < ninetyFivePercentProgress.z );
2665 application.SendNotification();
2666 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
2668 // We did expect the animation to finish
2669 application.SendNotification();
2670 finishCheck.CheckSignalReceived();
2671 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
2673 // Check that nothing has changed after a couple of buffer swaps
2674 application.Render(0);
2675 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
2676 application.Render(0);
2677 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
2681 int UtcDaliAnimationAnimateByVector3TimePeriod(void)
2683 TestApplication application;
2685 Actor actor = Actor::New();
2687 // Register a Vector3 property
2688 Vector3 startValue(10.0f, 10.0f, 10.0f);
2689 Property::Index index = actor.RegisterProperty( "test-property", startValue );
2690 Stage::GetCurrent().Add(actor);
2691 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
2693 // Build the animation
2694 float durationSeconds(1.0f);
2695 Animation animation = Animation::New(durationSeconds);
2696 Vector3 targetValue(30.0f, 30.0f, 30.0f);
2697 Vector3 relativeValue(targetValue - startValue);
2699 animation.AnimateBy(Property(actor, index),
2701 TimePeriod(delay, durationSeconds - delay));
2703 // Start the animation
2706 bool signalReceived(false);
2707 AnimationFinishCheck finishCheck(signalReceived);
2708 animation.FinishedSignal().Connect(&application, finishCheck);
2710 application.SendNotification();
2711 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
2713 // We didn't expect the animation to finish yet
2714 application.SendNotification();
2715 finishCheck.CheckSignalNotReceived();
2716 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
2718 application.SendNotification();
2719 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
2721 // We didn't expect the animation to finish yet
2722 application.SendNotification();
2723 finishCheck.CheckSignalNotReceived();
2724 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
2726 application.SendNotification();
2727 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
2729 // We did expect the animation to finish
2730 application.SendNotification();
2731 finishCheck.CheckSignalReceived();
2732 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
2734 // Check that nothing has changed after a couple of buffer swaps
2735 application.Render(0);
2736 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
2737 application.Render(0);
2738 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
2742 int UtcDaliAnimationAnimateByVector3AlphaFunctionTimePeriod(void)
2744 TestApplication application;
2746 Actor actor = Actor::New();
2748 // Register a Vector3 property
2749 Vector3 startValue(5.0f, 5.0f, 5.0f);
2750 Property::Index index = actor.RegisterProperty( "test-property", startValue );
2751 Stage::GetCurrent().Add(actor);
2752 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
2754 // Build the animation
2755 float durationSeconds(1.0f);
2756 Animation animation = Animation::New(durationSeconds);
2757 Vector3 targetValue(10.0f, 10.0f, 10.0f);
2758 Vector3 relativeValue(targetValue - startValue);
2760 animation.AnimateBy(Property(actor, index),
2762 AlphaFunctions::Linear,
2763 TimePeriod(delay, durationSeconds - delay));
2765 // Start the animation
2768 bool signalReceived(false);
2769 AnimationFinishCheck finishCheck(signalReceived);
2770 animation.FinishedSignal().Connect(&application, finishCheck);
2772 application.SendNotification();
2773 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
2775 // We didn't expect the animation to finish yet
2776 application.SendNotification();
2777 finishCheck.CheckSignalNotReceived();
2778 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
2780 application.SendNotification();
2781 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
2783 // We didn't expect the animation to finish yet
2784 application.SendNotification();
2785 finishCheck.CheckSignalNotReceived();
2786 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
2788 application.SendNotification();
2789 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
2791 // We did expect the animation to finish
2792 application.SendNotification();
2793 finishCheck.CheckSignalReceived();
2794 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
2796 // Check that nothing has changed after a couple of buffer swaps
2797 application.Render(0);
2798 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
2799 application.Render(0);
2800 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
2804 int UtcDaliAnimationAnimateByVector4(void)
2806 TestApplication application;
2808 Actor actor = Actor::New();
2810 // Register a Vector4 property
2811 Vector4 startValue(10.0f, 10.0f, 10.0f, 10.0f);
2812 Property::Index index = actor.RegisterProperty( "test-property", startValue );
2813 Stage::GetCurrent().Add(actor);
2814 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
2816 // Build the animation
2817 float durationSeconds(2.0f);
2818 Animation animation = Animation::New(durationSeconds);
2819 Vector4 targetValue(60.0f, 60.0f, 60.0f, 60.0f);
2820 Vector4 relativeValue(targetValue - startValue);
2821 animation.AnimateBy(Property(actor, index), relativeValue);
2823 Vector4 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
2825 // Start the animation
2828 bool signalReceived(false);
2829 AnimationFinishCheck finishCheck(signalReceived);
2830 animation.FinishedSignal().Connect(&application, finishCheck);
2832 application.SendNotification();
2833 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
2835 // We didn't expect the animation to finish yet
2836 application.SendNotification();
2837 finishCheck.CheckSignalNotReceived();
2838 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), ninetyFivePercentProgress, TEST_LOCATION );
2840 application.SendNotification();
2841 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
2843 // We did expect the animation to finish
2844 application.SendNotification();
2845 finishCheck.CheckSignalReceived();
2846 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
2848 // Check that nothing has changed after a couple of buffer swaps
2849 application.Render(0);
2850 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
2851 application.Render(0);
2852 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
2856 int UtcDaliAnimationAnimateByVector4AlphaFunction(void)
2858 TestApplication application;
2860 Actor actor = Actor::New();
2862 // Register a Vector4 property
2863 Vector4 startValue(100.0f, 100.0f, 100.0f, 100.0f);
2864 Property::Index index = actor.RegisterProperty( "test-property", startValue );
2865 Stage::GetCurrent().Add(actor);
2866 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
2868 // Build the animation
2869 float durationSeconds(1.0f);
2870 Animation animation = Animation::New(durationSeconds);
2871 Vector4 targetValue(20.0f, 20.0f, 20.0f, 20.0f);
2872 Vector4 relativeValue(targetValue - startValue);
2873 animation.AnimateBy(Property(actor, index), relativeValue, AlphaFunctions::EaseOut);
2875 Vector4 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
2877 // Start the animation
2880 bool signalReceived(false);
2881 AnimationFinishCheck finishCheck(signalReceived);
2882 animation.FinishedSignal().Connect(&application, finishCheck);
2884 application.SendNotification();
2885 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
2887 // We didn't expect the animation to finish yet
2888 application.SendNotification();
2889 finishCheck.CheckSignalNotReceived();
2891 // The position should have moved more, than with a linear alpha function
2892 Vector4 current(actor.GetProperty<Vector4>(index));
2893 DALI_TEST_CHECK( current.x < ninetyFivePercentProgress.x );
2894 DALI_TEST_CHECK( current.y < ninetyFivePercentProgress.y );
2895 DALI_TEST_CHECK( current.z < ninetyFivePercentProgress.z );
2896 DALI_TEST_CHECK( current.w < ninetyFivePercentProgress.w );
2898 application.SendNotification();
2899 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
2901 // We did expect the animation to finish
2902 application.SendNotification();
2903 finishCheck.CheckSignalReceived();
2904 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
2906 // Check that nothing has changed after a couple of buffer swaps
2907 application.Render(0);
2908 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
2909 application.Render(0);
2910 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
2914 int UtcDaliAnimationAnimateByVector4TimePeriod(void)
2916 TestApplication application;
2918 Actor actor = Actor::New();
2920 // Register a Vector4 property
2921 Vector4 startValue(10.0f, 10.0f, 10.0f, 10.0f);
2922 Property::Index index = actor.RegisterProperty( "test-property", startValue );
2923 Stage::GetCurrent().Add(actor);
2924 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
2926 // Build the animation
2927 float durationSeconds(1.0f);
2928 Animation animation = Animation::New(durationSeconds);
2929 Vector4 targetValue(30.0f, 30.0f, 30.0f, 30.0f);
2930 Vector4 relativeValue(targetValue - startValue);
2932 animation.AnimateBy(Property(actor, index),
2934 TimePeriod(delay, durationSeconds - delay));
2936 // Start the animation
2939 bool signalReceived(false);
2940 AnimationFinishCheck finishCheck(signalReceived);
2941 animation.FinishedSignal().Connect(&application, finishCheck);
2943 application.SendNotification();
2944 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
2946 // We didn't expect the animation to finish yet
2947 application.SendNotification();
2948 finishCheck.CheckSignalNotReceived();
2949 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
2951 application.SendNotification();
2952 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
2954 // We didn't expect the animation to finish yet
2955 application.SendNotification();
2956 finishCheck.CheckSignalNotReceived();
2957 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
2959 application.SendNotification();
2960 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
2962 // We did expect the animation to finish
2963 application.SendNotification();
2964 finishCheck.CheckSignalReceived();
2965 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
2967 // Check that nothing has changed after a couple of buffer swaps
2968 application.Render(0);
2969 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
2970 application.Render(0);
2971 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
2975 int UtcDaliAnimationAnimateByVector4AlphaFunctionTimePeriod(void)
2977 TestApplication application;
2979 Actor actor = Actor::New();
2981 // Register a Vector4 property
2982 Vector4 startValue(5.0f, 5.0f, 5.0f, 5.0f);
2983 Property::Index index = actor.RegisterProperty( "test-property", startValue );
2984 Stage::GetCurrent().Add(actor);
2985 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
2987 // Build the animation
2988 float durationSeconds(1.0f);
2989 Animation animation = Animation::New(durationSeconds);
2990 Vector4 targetValue(10.0f, 10.0f, 10.0f, 10.0f);
2991 Vector4 relativeValue(targetValue - startValue);
2993 animation.AnimateBy(Property(actor, index),
2995 AlphaFunctions::Linear,
2996 TimePeriod(delay, durationSeconds - delay));
2998 // Start the animation
3001 bool signalReceived(false);
3002 AnimationFinishCheck finishCheck(signalReceived);
3003 animation.FinishedSignal().Connect(&application, finishCheck);
3005 application.SendNotification();
3006 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
3008 // We didn't expect the animation to finish yet
3009 application.SendNotification();
3010 finishCheck.CheckSignalNotReceived();
3011 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
3013 application.SendNotification();
3014 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
3016 // We didn't expect the animation to finish yet
3017 application.SendNotification();
3018 finishCheck.CheckSignalNotReceived();
3019 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
3021 application.SendNotification();
3022 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
3024 // We did expect the animation to finish
3025 application.SendNotification();
3026 finishCheck.CheckSignalReceived();
3027 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
3029 // Check that nothing has changed after a couple of buffer swaps
3030 application.Render(0);
3031 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
3032 application.Render(0);
3033 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
3037 int UtcDaliAnimationAnimateByActorPosition(void)
3039 TestApplication application;
3041 Actor actor = Actor::New();
3042 Vector3 startPosition(10.0f, 10.0f, 10.0f);
3043 actor.SetPosition(startPosition);
3044 Stage::GetCurrent().Add(actor);
3045 application.SendNotification();
3046 application.Render(0);
3047 DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION );
3049 // Build the animation
3050 float durationSeconds(1.0f);
3051 Animation animation = Animation::New(durationSeconds);
3052 Vector3 targetPosition(20.0f, 20.0f, 20.0f);
3053 Vector3 relativePosition(targetPosition - startPosition);
3054 animation.AnimateBy(Property(actor, Actor::POSITION), relativePosition);
3056 Vector3 ninetyFivePercentProgress(startPosition + relativePosition*0.95f);
3058 // Start the animation
3061 bool signalReceived(false);
3062 AnimationFinishCheck finishCheck(signalReceived);
3063 animation.FinishedSignal().Connect(&application, finishCheck);
3065 application.SendNotification();
3066 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3068 // We didn't expect the animation to finish yet
3069 application.SendNotification();
3070 finishCheck.CheckSignalNotReceived();
3071 DALI_TEST_EQUALS( actor.GetCurrentPosition(), ninetyFivePercentProgress, TEST_LOCATION );
3073 application.SendNotification();
3074 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3076 // We did expect the animation to finish
3077 application.SendNotification();
3078 finishCheck.CheckSignalReceived();
3079 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
3081 // Check that nothing has changed after a couple of buffer swaps
3082 application.Render(0);
3083 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
3084 application.Render(0);
3085 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
3089 int UtcDaliAnimationAnimateByActorPositionAlphaFunction(void)
3091 TestApplication application;
3093 Actor actor = Actor::New();
3094 Vector3 startPosition(10.0f, 10.0f, 10.0f);
3095 actor.SetPosition(startPosition);
3096 Stage::GetCurrent().Add(actor);
3097 application.SendNotification();
3098 application.Render(0);
3099 DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION );
3101 // Build the animation
3102 float durationSeconds(1.0f);
3103 Animation animation = Animation::New(durationSeconds);
3104 Vector3 targetPosition(20.0f, 20.0f, 20.0f);
3105 Vector3 relativePosition(targetPosition - startPosition);
3106 animation.AnimateBy(Property(actor, Actor::POSITION), relativePosition, AlphaFunctions::EaseOut);
3108 Vector3 ninetyFivePercentProgress(startPosition + relativePosition*0.95f);
3110 // Start the animation
3113 bool signalReceived(false);
3114 AnimationFinishCheck finishCheck(signalReceived);
3115 animation.FinishedSignal().Connect(&application, finishCheck);
3117 application.SendNotification();
3118 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3120 // We didn't expect the animation to finish yet
3121 application.SendNotification();
3122 finishCheck.CheckSignalNotReceived();
3124 // The position should have moved more, than with a linear alpha function
3125 Vector3 current(actor.GetCurrentPosition());
3126 DALI_TEST_CHECK( current.x > ninetyFivePercentProgress.x );
3127 DALI_TEST_CHECK( current.y > ninetyFivePercentProgress.y );
3128 DALI_TEST_CHECK( current.z > ninetyFivePercentProgress.z );
3130 application.SendNotification();
3131 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3133 // We did expect the animation to finish
3134 application.SendNotification();
3135 finishCheck.CheckSignalReceived();
3136 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
3138 // Check that nothing has changed after a couple of buffer swaps
3139 application.Render(0);
3140 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
3141 application.Render(0);
3142 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
3146 int UtcDaliAnimationAnimateByActorPositionTimePeriod(void)
3148 TestApplication application;
3150 Actor actor = Actor::New();
3151 Vector3 startPosition(10.0f, 10.0f, 10.0f);
3152 actor.SetPosition(startPosition);
3153 Stage::GetCurrent().Add(actor);
3154 application.SendNotification();
3155 application.Render(0);
3156 DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION );
3158 // Build the animation
3159 float durationSeconds(1.0f);
3160 Animation animation = Animation::New(durationSeconds);
3161 Vector3 targetPosition(20.0f, 20.0f, 20.0f);
3162 Vector3 relativePosition(targetPosition - startPosition);
3164 animation.AnimateBy(Property(actor, Actor::POSITION),
3166 TimePeriod(delay, durationSeconds - delay));
3168 Vector3 ninetyFivePercentProgress(startPosition + relativePosition*0.95f);
3170 // Start the animation
3173 bool signalReceived(false);
3174 AnimationFinishCheck finishCheck(signalReceived);
3175 animation.FinishedSignal().Connect(&application, finishCheck);
3177 application.SendNotification();
3178 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
3180 // We didn't expect the animation to finish yet
3181 application.SendNotification();
3182 finishCheck.CheckSignalNotReceived();
3183 DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION );
3185 application.SendNotification();
3186 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
3188 // We did expect the animation to finish
3189 application.SendNotification();
3190 finishCheck.CheckSignalReceived();
3191 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
3193 // Check that nothing has changed after a couple of buffer swaps
3194 application.Render(0);
3195 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
3196 application.Render(0);
3197 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
3201 int UtcDaliAnimationAnimateByActorPositionAlphaFunctionTimePeriod(void)
3203 TestApplication application;
3205 Actor actor = Actor::New();
3206 Vector3 startPosition(10.0f, 10.0f, 10.0f);
3207 actor.SetPosition(startPosition);
3208 Stage::GetCurrent().Add(actor);
3209 application.SendNotification();
3210 application.Render(0);
3211 DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION );
3213 // Build the animation
3214 float durationSeconds(1.0f);
3215 Animation animation = Animation::New(durationSeconds);
3216 Vector3 targetPosition(20.0f, 20.0f, 20.0f);
3217 Vector3 relativePosition(targetPosition - startPosition);
3219 animation.AnimateBy(Property(actor, Actor::POSITION),
3221 AlphaFunctions::Linear,
3222 TimePeriod(delay, durationSeconds - delay));
3224 Vector3 ninetyFivePercentProgress(startPosition + relativePosition*0.95f);
3226 // Start the animation
3229 bool signalReceived(false);
3230 AnimationFinishCheck finishCheck(signalReceived);
3231 animation.FinishedSignal().Connect(&application, finishCheck);
3233 application.SendNotification();
3234 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
3236 // We didn't expect the animation to finish yet
3237 application.SendNotification();
3238 finishCheck.CheckSignalNotReceived();
3239 DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION );
3241 application.SendNotification();
3242 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
3244 // We did expect the animation to finish
3245 application.SendNotification();
3246 finishCheck.CheckSignalReceived();
3247 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
3249 // Check that nothing has changed after a couple of buffer swaps
3250 application.Render(0);
3251 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
3252 application.Render(0);
3253 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
3257 int UtcDaliAnimationAnimateToBoolean(void)
3259 TestApplication application;
3261 Actor actor = Actor::New();
3263 // Register a boolean property
3264 const bool startValue(false);
3265 Property::Index index = actor.RegisterProperty( "test-property", startValue );
3266 Stage::GetCurrent().Add(actor);
3267 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
3269 // Build the animation
3270 float durationSeconds(2.0f);
3271 Animation animation = Animation::New(durationSeconds);
3272 const bool targetValue( !startValue );
3273 animation.AnimateTo(Property(actor, index), targetValue);
3275 // Start the animation
3278 bool signalReceived(false);
3279 AnimationFinishCheck finishCheck(signalReceived);
3280 animation.FinishedSignal().Connect(&application, finishCheck);
3282 application.SendNotification();
3283 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3285 // We didn't expect the animation to finish yet
3286 application.SendNotification();
3287 finishCheck.CheckSignalNotReceived();
3288 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
3290 application.SendNotification();
3291 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3293 // We did expect the animation to finish
3294 application.SendNotification();
3295 finishCheck.CheckSignalReceived();
3296 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == targetValue );
3298 // Check that nothing has changed after a couple of buffer swaps
3299 application.Render(0);
3300 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == targetValue );
3301 application.Render(0);
3302 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == targetValue );
3304 // Repeat with target value "false"
3305 animation = Animation::New(durationSeconds);
3306 const bool finalValue( !targetValue );
3307 animation.AnimateTo(Property(actor, index), finalValue);
3309 // Start the animation
3312 finishCheck.Reset();
3313 animation.FinishedSignal().Connect(&application, finishCheck);
3315 application.SendNotification();
3316 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3318 // We didn't expect the animation to finish yet
3319 application.SendNotification();
3320 finishCheck.CheckSignalNotReceived();
3321 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == targetValue );
3323 application.SendNotification();
3324 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3326 // We did expect the animation to finish
3327 application.SendNotification();
3328 finishCheck.CheckSignalReceived();
3329 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
3331 // Check that nothing has changed after a couple of buffer swaps
3332 application.Render(0);
3333 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
3334 application.Render(0);
3335 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
3339 int UtcDaliAnimationAnimateToBooleanAlphaFunction(void)
3341 TestApplication application;
3343 Actor actor = Actor::New();
3345 // Register a boolean property
3346 const bool startValue(false);
3347 Property::Index index = actor.RegisterProperty( "test-property", startValue );
3348 Stage::GetCurrent().Add(actor);
3349 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
3351 // Build the animation
3352 float durationSeconds(2.0f);
3353 Animation animation = Animation::New(durationSeconds);
3354 const bool targetValue( !startValue );
3355 animation.AnimateTo(Property(actor, "test-property"), targetValue, AlphaFunctions::EaseOut);
3357 // Start the animation
3360 bool signalReceived(false);
3361 AnimationFinishCheck finishCheck(signalReceived);
3362 animation.FinishedSignal().Connect(&application, finishCheck);
3364 application.SendNotification();
3365 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3367 // We didn't expect the animation to finish yet
3368 application.SendNotification();
3369 finishCheck.CheckSignalNotReceived();
3370 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
3372 application.SendNotification();
3373 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3375 // We did expect the animation to finish
3376 application.SendNotification();
3377 finishCheck.CheckSignalReceived();
3378 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == targetValue );
3380 // Check that nothing has changed after a couple of buffer swaps
3381 application.Render(0);
3382 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == targetValue );
3383 application.Render(0);
3384 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == targetValue );
3386 // Repeat with target value "false"
3387 animation = Animation::New(durationSeconds);
3388 const bool finalValue( !targetValue );
3389 animation.AnimateTo(Property(actor, index), finalValue, AlphaFunctions::EaseOut);
3391 // Start the animation
3394 finishCheck.Reset();
3395 animation.FinishedSignal().Connect(&application, finishCheck);
3397 application.SendNotification();
3398 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3400 // We didn't expect the animation to finish yet
3401 application.SendNotification();
3402 finishCheck.CheckSignalNotReceived();
3403 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == targetValue );
3405 application.SendNotification();
3406 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3408 // We did expect the animation to finish
3409 application.SendNotification();
3410 finishCheck.CheckSignalReceived();
3411 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
3413 // Check that nothing has changed after a couple of buffer swaps
3414 application.Render(0);
3415 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
3416 application.Render(0);
3417 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
3421 int UtcDaliAnimationAnimateToBooleanTimePeriod(void)
3423 TestApplication application;
3425 Actor actor = Actor::New();
3427 // Register a boolean property
3428 bool startValue(false);
3429 Property::Index index = actor.RegisterProperty( "test-property", startValue );
3430 Stage::GetCurrent().Add(actor);
3431 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
3433 // Build the animation
3434 float durationSeconds(2.0f);
3435 Animation animation = Animation::New(durationSeconds);
3436 bool finalValue( !startValue );
3437 float animatorDurationSeconds(durationSeconds * 0.5f);
3438 animation.AnimateTo( Property(actor, index),
3440 TimePeriod( animatorDurationSeconds ) );
3442 // Start the animation
3445 bool signalReceived(false);
3446 AnimationFinishCheck finishCheck(signalReceived);
3447 animation.FinishedSignal().Connect(&application, finishCheck);
3449 application.SendNotification();
3450 application.Render(static_cast<unsigned int>(animatorDurationSeconds*950.0f)/* 95% animator progress */);
3452 // We didn't expect the animation to finish yet
3453 application.SendNotification();
3454 finishCheck.CheckSignalNotReceived();
3455 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
3457 application.SendNotification();
3458 application.Render(static_cast<unsigned int>(animatorDurationSeconds*50.0f) + 1u/*just beyond the animator duration*/);
3460 // We didn't expect the animation to finish yet...
3461 application.SendNotification();
3462 finishCheck.CheckSignalNotReceived();
3464 // ...however we should have reached the final value
3465 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
3467 application.SendNotification();
3468 application.Render(static_cast<unsigned int>(animatorDurationSeconds*1000.0f)/*just beyond the animation duration*/);
3470 // We did expect the animation to finish
3471 application.SendNotification();
3472 finishCheck.CheckSignalReceived();
3473 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
3475 // Check that nothing has changed after a couple of buffer swaps
3476 application.Render(0);
3477 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
3478 application.Render(0);
3479 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
3483 int UtcDaliAnimationAnimateToBooleanAlphaFunctionTimePeriod(void)
3485 TestApplication application;
3487 Actor actor = Actor::New();
3489 // Register a boolean property
3490 bool startValue(false);
3491 Property::Index index = actor.RegisterProperty( "test-property", startValue );
3492 Stage::GetCurrent().Add(actor);
3493 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
3495 // Build the animation
3496 float durationSeconds(2.0f);
3497 Animation animation = Animation::New(durationSeconds);
3498 bool finalValue( !startValue );
3499 float animatorDurationSeconds(durationSeconds * 0.5f);
3500 animation.AnimateTo( Property(actor, index),
3502 AlphaFunctions::Linear,
3503 TimePeriod( animatorDurationSeconds ) );
3505 // Start the animation
3508 bool signalReceived(false);
3509 AnimationFinishCheck finishCheck(signalReceived);
3510 animation.FinishedSignal().Connect(&application, finishCheck);
3512 application.SendNotification();
3513 application.Render(static_cast<unsigned int>(animatorDurationSeconds*950.0f)/* 95% animator progress */);
3515 // We didn't expect the animation to finish yet
3516 application.SendNotification();
3517 finishCheck.CheckSignalNotReceived();
3518 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
3520 application.SendNotification();
3521 application.Render(static_cast<unsigned int>(animatorDurationSeconds*50.0f) + 1u/*just beyond the animator duration*/);
3523 // We didn't expect the animation to finish yet...
3524 application.SendNotification();
3525 finishCheck.CheckSignalNotReceived();
3527 // ...however we should have reached the final value
3528 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
3530 application.SendNotification();
3531 application.Render(static_cast<unsigned int>(animatorDurationSeconds*1000.0f)/*just beyond the animation duration*/);
3533 // We did expect the animation to finish
3534 application.SendNotification();
3535 finishCheck.CheckSignalReceived();
3536 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
3538 // Check that nothing has changed after a couple of buffer swaps
3539 application.Render(0);
3540 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
3541 application.Render(0);
3542 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
3546 int UtcDaliAnimationAnimateToFloat(void)
3548 TestApplication application;
3550 Actor actor = Actor::New();
3552 // Register a float property
3553 float startValue(10.0f);
3554 Property::Index index = actor.RegisterProperty( "test-property", startValue );
3555 Stage::GetCurrent().Add(actor);
3556 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
3558 // Build the animation
3559 float durationSeconds(2.0f);
3560 Animation animation = Animation::New(durationSeconds);
3561 float targetValue(50.0f);
3562 float relativeValue(targetValue - startValue);
3563 animation.AnimateTo(Property(actor, "test-property"), targetValue);
3565 float ninetyFivePercentProgress(startValue + relativeValue*0.95f);
3567 // Start the animation
3570 bool signalReceived(false);
3571 AnimationFinishCheck finishCheck(signalReceived);
3572 animation.FinishedSignal().Connect(&application, finishCheck);
3574 application.SendNotification();
3575 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3577 // We didn't expect the animation to finish yet
3578 application.SendNotification();
3579 finishCheck.CheckSignalNotReceived();
3580 DALI_TEST_EQUALS( actor.GetProperty<float>(index), ninetyFivePercentProgress, TEST_LOCATION );
3582 application.SendNotification();
3583 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3585 // We did expect the animation to finish
3586 application.SendNotification();
3587 finishCheck.CheckSignalReceived();
3588 DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
3592 int UtcDaliAnimationAnimateToFloatAlphaFunction(void)
3594 TestApplication application;
3596 Actor actor = Actor::New();
3598 // Register a float property
3599 float startValue(10.0f);
3600 Property::Index index = actor.RegisterProperty( "test-property", startValue );
3601 Stage::GetCurrent().Add(actor);
3602 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
3604 // Build the animation
3605 float durationSeconds(1.0f);
3606 Animation animation = Animation::New(durationSeconds);
3607 float targetValue(90.0f);
3608 float relativeValue(targetValue - startValue);
3609 animation.AnimateTo(Property(actor, index), targetValue, AlphaFunctions::EaseOut);
3611 float ninetyFivePercentProgress(startValue + relativeValue*0.95f);
3613 // Start the animation
3616 bool signalReceived(false);
3617 AnimationFinishCheck finishCheck(signalReceived);
3618 animation.FinishedSignal().Connect(&application, finishCheck);
3620 application.SendNotification();
3621 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3623 // We didn't expect the animation to finish yet
3624 application.SendNotification();
3625 finishCheck.CheckSignalNotReceived();
3627 // The position should have moved more, than with a linear alpha function
3628 float current(actor.GetProperty<float>(index));
3629 DALI_TEST_CHECK( current > ninetyFivePercentProgress );
3631 application.SendNotification();
3632 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3634 // We did expect the animation to finish
3635 application.SendNotification();
3636 finishCheck.CheckSignalReceived();
3637 DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
3641 int UtcDaliAnimationAnimateToFloatTimePeriod(void)
3643 TestApplication application;
3645 Actor actor = Actor::New();
3647 // Register a float property
3648 float startValue(10.0f);
3649 Property::Index index = actor.RegisterProperty( "test-property", startValue );
3650 Stage::GetCurrent().Add(actor);
3651 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
3653 // Build the animation
3654 float durationSeconds(1.0f);
3655 Animation animation = Animation::New(durationSeconds);
3656 float targetValue(30.0f);
3657 float relativeValue(targetValue - startValue);
3659 animation.AnimateTo(Property(actor, index),
3661 TimePeriod(delay, durationSeconds - delay));
3663 // Start the animation
3666 bool signalReceived(false);
3667 AnimationFinishCheck finishCheck(signalReceived);
3668 animation.FinishedSignal().Connect(&application, finishCheck);
3670 application.SendNotification();
3671 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
3673 // We didn't expect the animation to finish yet
3674 application.SendNotification();
3675 finishCheck.CheckSignalNotReceived();
3676 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
3678 application.SendNotification();
3679 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
3681 // We didn't expect the animation to finish yet
3682 application.SendNotification();
3683 finishCheck.CheckSignalNotReceived();
3684 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
3686 application.SendNotification();
3687 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
3689 // We did expect the animation to finish
3690 application.SendNotification();
3691 finishCheck.CheckSignalReceived();
3692 DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
3696 int UtcDaliAnimationAnimateToFloatAlphaFunctionTimePeriod(void)
3698 TestApplication application;
3700 Actor actor = Actor::New();
3702 // Register a float property
3703 float startValue(10.0f);
3704 Property::Index index = actor.RegisterProperty( "test-property", startValue );
3705 Stage::GetCurrent().Add(actor);
3706 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
3708 // Build the animation
3709 float durationSeconds(1.0f);
3710 Animation animation = Animation::New(durationSeconds);
3711 float targetValue(30.0f);
3712 float relativeValue(targetValue - startValue);
3714 animation.AnimateTo(Property(actor, index),
3716 AlphaFunctions::Linear,
3717 TimePeriod(delay, durationSeconds - delay));
3719 // Start the animation
3722 bool signalReceived(false);
3723 AnimationFinishCheck finishCheck(signalReceived);
3724 animation.FinishedSignal().Connect(&application, finishCheck);
3726 application.SendNotification();
3727 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
3729 // We didn't expect the animation to finish yet
3730 application.SendNotification();
3731 finishCheck.CheckSignalNotReceived();
3732 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
3734 application.SendNotification();
3735 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
3737 // We didn't expect the animation to finish yet
3738 application.SendNotification();
3739 finishCheck.CheckSignalNotReceived();
3740 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
3742 application.SendNotification();
3743 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
3745 // We did expect the animation to finish
3746 application.SendNotification();
3747 finishCheck.CheckSignalReceived();
3748 DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
3752 int UtcDaliAnimationAnimateToInteger(void)
3754 TestApplication application;
3756 Actor actor = Actor::New();
3758 // Register an integer property
3760 Property::Index index = actor.RegisterProperty( "test-property", startValue );
3761 Stage::GetCurrent().Add(actor);
3762 DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
3764 // Build the animation
3765 float durationSeconds(2.0f);
3766 Animation animation = Animation::New(durationSeconds);
3767 int targetValue(50);
3768 int relativeValue(targetValue - startValue);
3769 animation.AnimateTo(Property(actor, "test-property"), targetValue);
3771 int ninetyFivePercentProgress(static_cast<int>(startValue + relativeValue*0.95f + 0.5f));
3773 // Start the animation
3776 bool signalReceived(false);
3777 AnimationFinishCheck finishCheck(signalReceived);
3778 animation.FinishedSignal().Connect(&application, finishCheck);
3780 application.SendNotification();
3781 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3783 // We didn't expect the animation to finish yet
3784 application.SendNotification();
3785 finishCheck.CheckSignalNotReceived();
3786 DALI_TEST_EQUALS( actor.GetProperty<int>(index), ninetyFivePercentProgress, TEST_LOCATION );
3788 application.SendNotification();
3789 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3791 // We did expect the animation to finish
3792 application.SendNotification();
3793 finishCheck.CheckSignalReceived();
3794 DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
3798 int UtcDaliAnimationAnimateToIntegerAlphaFunction(void)
3800 TestApplication application;
3802 Actor actor = Actor::New();
3804 // Register an integer property
3806 Property::Index index = actor.RegisterProperty( "test-property", startValue );
3807 Stage::GetCurrent().Add(actor);
3808 DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
3810 // Build the animation
3811 float durationSeconds(1.0f);
3812 Animation animation = Animation::New(durationSeconds);
3813 int targetValue(90);
3814 int relativeValue(targetValue - startValue);
3815 animation.AnimateTo(Property(actor, index), targetValue, AlphaFunctions::EaseOut);
3817 int ninetyFivePercentProgress(static_cast<int>(startValue + relativeValue*0.95f + 0.5f));
3819 // Start the animation
3822 bool signalReceived(false);
3823 AnimationFinishCheck finishCheck(signalReceived);
3824 animation.FinishedSignal().Connect(&application, finishCheck);
3826 application.SendNotification();
3827 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3829 // We didn't expect the animation to finish yet
3830 application.SendNotification();
3831 finishCheck.CheckSignalNotReceived();
3833 // The position should have moved more, than with a linear alpha function
3834 int current(actor.GetProperty<int>(index));
3835 DALI_TEST_CHECK( current > ninetyFivePercentProgress );
3837 application.SendNotification();
3838 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3840 // We did expect the animation to finish
3841 application.SendNotification();
3842 finishCheck.CheckSignalReceived();
3843 DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
3847 int UtcDaliAnimationAnimateToIntegerTimePeriod(void)
3849 TestApplication application;
3851 Actor actor = Actor::New();
3853 // Register an integer property
3855 Property::Index index = actor.RegisterProperty( "test-property", startValue );
3856 Stage::GetCurrent().Add(actor);
3857 DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
3859 // Build the animation
3860 float durationSeconds(1.0f);
3861 Animation animation = Animation::New(durationSeconds);
3862 int targetValue(30);
3863 int relativeValue(targetValue - startValue);
3865 animation.AnimateTo(Property(actor, index),
3867 TimePeriod(delay, durationSeconds - delay));
3869 // Start the animation
3872 bool signalReceived(false);
3873 AnimationFinishCheck finishCheck(signalReceived);
3874 animation.FinishedSignal().Connect(&application, finishCheck);
3876 application.SendNotification();
3877 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
3879 // We didn't expect the animation to finish yet
3880 application.SendNotification();
3881 finishCheck.CheckSignalNotReceived();
3882 DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
3884 application.SendNotification();
3885 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
3887 // We didn't expect the animation to finish yet
3888 application.SendNotification();
3889 finishCheck.CheckSignalNotReceived();
3890 DALI_TEST_EQUALS( actor.GetProperty<int>(index), static_cast<int>(startValue+(relativeValue*0.5f)+0.5f), TEST_LOCATION );
3892 application.SendNotification();
3893 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
3895 // We did expect the animation to finish
3896 application.SendNotification();
3897 finishCheck.CheckSignalReceived();
3898 DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
3902 int UtcDaliAnimationAnimateToIntegerAlphaFunctionTimePeriod(void)
3904 TestApplication application;
3906 Actor actor = Actor::New();
3908 // Register an integer property
3910 Property::Index index = actor.RegisterProperty( "test-property", startValue );
3911 Stage::GetCurrent().Add(actor);
3912 DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
3914 // Build the animation
3915 float durationSeconds(1.0f);
3916 Animation animation = Animation::New(durationSeconds);
3917 int targetValue(30);
3918 int relativeValue(targetValue - startValue);
3920 animation.AnimateTo(Property(actor, index),
3922 AlphaFunctions::Linear,
3923 TimePeriod(delay, durationSeconds - delay));
3925 // Start the animation
3928 bool signalReceived(false);
3929 AnimationFinishCheck finishCheck(signalReceived);
3930 animation.FinishedSignal().Connect(&application, finishCheck);
3932 application.SendNotification();
3933 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
3935 // We didn't expect the animation to finish yet
3936 application.SendNotification();
3937 finishCheck.CheckSignalNotReceived();
3938 DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
3940 application.SendNotification();
3941 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
3943 // We didn't expect the animation to finish yet
3944 application.SendNotification();
3945 finishCheck.CheckSignalNotReceived();
3946 DALI_TEST_EQUALS( actor.GetProperty<int>(index), static_cast<int>(startValue+(relativeValue*0.5f)+0.5f), TEST_LOCATION );
3948 application.SendNotification();
3949 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
3951 // We did expect the animation to finish
3952 application.SendNotification();
3953 finishCheck.CheckSignalReceived();
3954 DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
3958 int UtcDaliAnimationAnimateToVector2(void)
3960 TestApplication application;
3962 Actor actor = Actor::New();
3964 // Register a Vector2 property
3965 Vector2 startValue(-50.0f, -50.0f);
3966 Property::Index index = actor.RegisterProperty( "test-property", startValue );
3967 Stage::GetCurrent().Add(actor);
3968 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
3970 // Build the animation
3971 float durationSeconds(2.0f);
3972 Animation animation = Animation::New(durationSeconds);
3973 Vector2 targetValue(50.0f, 50.0f);
3974 Vector2 relativeValue(targetValue - startValue);
3975 animation.AnimateTo(Property(actor, index), targetValue);
3977 Vector2 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
3979 // Start the animation
3982 bool signalReceived(false);
3983 AnimationFinishCheck finishCheck(signalReceived);
3984 animation.FinishedSignal().Connect(&application, finishCheck);
3986 application.SendNotification();
3987 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3989 // We didn't expect the animation to finish yet
3990 application.SendNotification();
3991 finishCheck.CheckSignalNotReceived();
3992 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), ninetyFivePercentProgress, TEST_LOCATION );
3994 application.SendNotification();
3995 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3997 // We did expect the animation to finish
3998 application.SendNotification();
3999 finishCheck.CheckSignalReceived();
4000 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
4004 int UtcDaliAnimationAnimateToVector2AlphaFunction(void)
4006 TestApplication application;
4008 Actor actor = Actor::New();
4010 // Register a Vector2 property
4011 Vector2 startValue(1000.0f, 1000.0f);
4012 Property::Index index = actor.RegisterProperty( "test-property", startValue );
4013 Stage::GetCurrent().Add(actor);
4014 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
4016 // Build the animation
4017 float durationSeconds(1.0f);
4018 Animation animation = Animation::New(durationSeconds);
4019 Vector2 targetValue(9000.0f, 9000.0f);
4020 Vector2 relativeValue(targetValue - startValue);
4021 animation.AnimateTo(Property(actor, "test-property"), targetValue, AlphaFunctions::EaseOut);
4023 Vector2 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
4025 // Start the animation
4028 bool signalReceived(false);
4029 AnimationFinishCheck finishCheck(signalReceived);
4030 animation.FinishedSignal().Connect(&application, finishCheck);
4032 application.SendNotification();
4033 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
4035 // We didn't expect the animation to finish yet
4036 application.SendNotification();
4037 finishCheck.CheckSignalNotReceived();
4039 // The position should have moved more, than with a linear alpha function
4040 Vector2 current(actor.GetProperty<Vector2>(index));
4041 DALI_TEST_CHECK( current.x > ninetyFivePercentProgress.x );
4042 DALI_TEST_CHECK( current.y > ninetyFivePercentProgress.y );
4044 application.SendNotification();
4045 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
4047 // We did expect the animation to finish
4048 application.SendNotification();
4049 finishCheck.CheckSignalReceived();
4050 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
4054 int UtcDaliAnimationAnimateToVector2TimePeriod(void)
4056 TestApplication application;
4058 Actor actor = Actor::New();
4060 // Register a Vector2 property
4061 Vector2 startValue(10.0f, 10.0f);
4062 Property::Index index = actor.RegisterProperty( "test-property", startValue );
4063 Stage::GetCurrent().Add(actor);
4064 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
4066 // Build the animation
4067 float durationSeconds(1.0f);
4068 Animation animation = Animation::New(durationSeconds);
4069 Vector2 targetValue(-10.0f, 20.0f);
4070 Vector2 relativeValue(targetValue - startValue);
4072 animation.AnimateTo(Property(actor, index),
4074 TimePeriod(delay, durationSeconds - delay));
4076 // Start the animation
4079 bool signalReceived(false);
4080 AnimationFinishCheck finishCheck(signalReceived);
4081 animation.FinishedSignal().Connect(&application, finishCheck);
4083 application.SendNotification();
4084 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
4086 // We didn't expect the animation to finish yet
4087 application.SendNotification();
4088 finishCheck.CheckSignalNotReceived();
4089 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
4091 application.SendNotification();
4092 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
4094 // We didn't expect the animation to finish yet
4095 application.SendNotification();
4096 finishCheck.CheckSignalNotReceived();
4097 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
4099 application.SendNotification();
4100 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
4102 // We did expect the animation to finish
4103 application.SendNotification();
4104 finishCheck.CheckSignalReceived();
4105 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
4109 int UtcDaliAnimationAnimateToVector2AlphaFunctionTimePeriod(void)
4111 TestApplication application;
4113 Actor actor = Actor::New();
4115 // Register a Vector2 property
4116 Vector2 startValue(10.0f, 10.0f);
4117 Property::Index index = actor.RegisterProperty( "test-property", startValue );
4118 Stage::GetCurrent().Add(actor);
4119 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
4121 // Build the animation
4122 float durationSeconds(1.0f);
4123 Animation animation = Animation::New(durationSeconds);
4124 Vector2 targetValue(30.0f, 30.0f);
4125 Vector2 relativeValue(targetValue - startValue);
4127 animation.AnimateTo(Property(actor, index),
4129 AlphaFunctions::Linear,
4130 TimePeriod(delay, durationSeconds - delay));
4132 // Start the animation
4135 bool signalReceived(false);
4136 AnimationFinishCheck finishCheck(signalReceived);
4137 animation.FinishedSignal().Connect(&application, finishCheck);
4139 application.SendNotification();
4140 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
4142 // We didn't expect the animation to finish yet
4143 application.SendNotification();
4144 finishCheck.CheckSignalNotReceived();
4145 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
4147 application.SendNotification();
4148 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
4150 // We didn't expect the animation to finish yet
4151 application.SendNotification();
4152 finishCheck.CheckSignalNotReceived();
4153 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
4155 application.SendNotification();
4156 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
4158 // We did expect the animation to finish
4159 application.SendNotification();
4160 finishCheck.CheckSignalReceived();
4161 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
4165 int UtcDaliAnimationAnimateToVector3(void)
4167 TestApplication application;
4169 Actor actor = Actor::New();
4171 // Register a Vector3 property
4172 Vector3 startValue(-50.0f, -50.0f, -50.0f);
4173 Property::Index index = actor.RegisterProperty( "test-property", startValue );
4174 Stage::GetCurrent().Add(actor);
4175 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
4177 // Build the animation
4178 float durationSeconds(2.0f);
4179 Animation animation = Animation::New(durationSeconds);
4180 Vector3 targetValue(50.0f, 50.0f, 50.0f);
4181 Vector3 relativeValue(targetValue - startValue);
4182 animation.AnimateTo(Property(actor, index), targetValue);
4184 Vector3 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
4186 // Start the animation
4189 bool signalReceived(false);
4190 AnimationFinishCheck finishCheck(signalReceived);
4191 animation.FinishedSignal().Connect(&application, finishCheck);
4193 application.SendNotification();
4194 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
4196 // We didn't expect the animation to finish yet
4197 application.SendNotification();
4198 finishCheck.CheckSignalNotReceived();
4199 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), ninetyFivePercentProgress, TEST_LOCATION );
4201 application.SendNotification();
4202 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
4204 // We did expect the animation to finish
4205 application.SendNotification();
4206 finishCheck.CheckSignalReceived();
4207 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
4211 int UtcDaliAnimationAnimateToVector3AlphaFunction(void)
4213 TestApplication application;
4215 Actor actor = Actor::New();
4217 // Register a Vector3 property
4218 Vector3 startValue(1000.0f, 1000.0f, 1000.0f);
4219 Property::Index index = actor.RegisterProperty( "test-property", startValue );
4220 Stage::GetCurrent().Add(actor);
4221 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
4223 // Build the animation
4224 float durationSeconds(1.0f);
4225 Animation animation = Animation::New(durationSeconds);
4226 Vector3 targetValue(9000.0f, 9000.0f, 9000.0f);
4227 Vector3 relativeValue(targetValue - startValue);
4228 animation.AnimateTo(Property(actor, index), targetValue, AlphaFunctions::EaseOut);
4230 Vector3 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
4232 // Start the animation
4235 bool signalReceived(false);
4236 AnimationFinishCheck finishCheck(signalReceived);
4237 animation.FinishedSignal().Connect(&application, finishCheck);
4239 application.SendNotification();
4240 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
4242 // We didn't expect the animation to finish yet
4243 application.SendNotification();
4244 finishCheck.CheckSignalNotReceived();
4246 // The position should have moved more, than with a linear alpha function
4247 Vector3 current(actor.GetProperty<Vector3>(index));
4248 DALI_TEST_CHECK( current.x > ninetyFivePercentProgress.x );
4249 DALI_TEST_CHECK( current.y > ninetyFivePercentProgress.y );
4250 DALI_TEST_CHECK( current.z > ninetyFivePercentProgress.z );
4252 application.SendNotification();
4253 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
4255 // We did expect the animation to finish
4256 application.SendNotification();
4257 finishCheck.CheckSignalReceived();
4258 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
4262 int UtcDaliAnimationAnimateToVector3TimePeriod(void)
4264 TestApplication application;
4266 Actor actor = Actor::New();
4268 // Register a Vector3 property
4269 Vector3 startValue(10.0f, 10.0f, 10.0f);
4270 Property::Index index = actor.RegisterProperty( "test-property", startValue );
4271 Stage::GetCurrent().Add(actor);
4272 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
4274 // Build the animation
4275 float durationSeconds(1.0f);
4276 Animation animation = Animation::New(durationSeconds);
4277 Vector3 targetValue(-10.0f, 20.0f, 100.0f);
4278 Vector3 relativeValue(targetValue - startValue);
4280 animation.AnimateTo(Property(actor, index),
4282 TimePeriod(delay, durationSeconds - delay));
4284 // Start the animation
4287 bool signalReceived(false);
4288 AnimationFinishCheck finishCheck(signalReceived);
4289 animation.FinishedSignal().Connect(&application, finishCheck);
4291 application.SendNotification();
4292 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
4294 // We didn't expect the animation to finish yet
4295 application.SendNotification();
4296 finishCheck.CheckSignalNotReceived();
4297 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
4299 application.SendNotification();
4300 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
4302 // We didn't expect the animation to finish yet
4303 application.SendNotification();
4304 finishCheck.CheckSignalNotReceived();
4305 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
4307 application.SendNotification();
4308 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
4310 // We did expect the animation to finish
4311 application.SendNotification();
4312 finishCheck.CheckSignalReceived();
4313 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
4317 int UtcDaliAnimationAnimateToVector3AlphaFunctionTimePeriod(void)
4319 TestApplication application;
4321 Actor actor = Actor::New();
4323 // Register a Vector3 property
4324 Vector3 startValue(10.0f, 10.0f, 10.0f);
4325 Property::Index index = actor.RegisterProperty( "test-property", startValue );
4326 Stage::GetCurrent().Add(actor);
4327 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
4329 // Build the animation
4330 float durationSeconds(1.0f);
4331 Animation animation = Animation::New(durationSeconds);
4332 Vector3 targetValue(30.0f, 30.0f, 30.0f);
4333 Vector3 relativeValue(targetValue - startValue);
4335 animation.AnimateTo(Property(actor, "test-property"),
4337 AlphaFunctions::Linear,
4338 TimePeriod(delay, durationSeconds - delay));
4340 // Start the animation
4343 bool signalReceived(false);
4344 AnimationFinishCheck finishCheck(signalReceived);
4345 animation.FinishedSignal().Connect(&application, finishCheck);
4347 application.SendNotification();
4348 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
4350 // We didn't expect the animation to finish yet
4351 application.SendNotification();
4352 finishCheck.CheckSignalNotReceived();
4353 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
4355 application.SendNotification();
4356 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
4358 // We didn't expect the animation to finish yet
4359 application.SendNotification();
4360 finishCheck.CheckSignalNotReceived();
4361 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
4363 application.SendNotification();
4364 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
4366 // We did expect the animation to finish
4367 application.SendNotification();
4368 finishCheck.CheckSignalReceived();
4369 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
4373 int UtcDaliAnimationAnimateToVector3Component(void)
4375 TestApplication application;
4377 Actor actor = Actor::New();
4379 // Register a Vector3 property
4380 Vector3 startValue(10.0f, 10.0f, 10.0f);
4381 Property::Index index = actor.RegisterProperty( "test-property", startValue );
4382 Stage::GetCurrent().Add(actor);
4383 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
4385 // Build the animation
4386 float durationSeconds(1.0f);
4387 Animation animation = Animation::New(durationSeconds);
4388 Vector3 targetValue(30.0f, 30.0f, 10.0f);
4389 Vector3 relativeValue(targetValue - startValue);
4391 animation.AnimateTo(Property(actor, "test-property", 0),
4393 AlphaFunctions::Linear,
4394 TimePeriod(delay, durationSeconds - delay));
4395 animation.AnimateTo(Property(actor, index, 1),
4397 AlphaFunctions::Linear,
4398 TimePeriod(delay, durationSeconds - delay));
4400 // Start the animation
4403 bool signalReceived(false);
4404 AnimationFinishCheck finishCheck(signalReceived);
4405 animation.FinishedSignal().Connect(&application, finishCheck);
4407 application.SendNotification();
4408 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
4410 // We didn't expect the animation to finish yet
4411 application.SendNotification();
4412 finishCheck.CheckSignalNotReceived();
4413 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
4415 application.SendNotification();
4416 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
4418 // We didn't expect the animation to finish yet
4419 application.SendNotification();
4420 finishCheck.CheckSignalNotReceived();
4421 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
4423 application.SendNotification();
4424 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
4426 // We did expect the animation to finish
4427 application.SendNotification();
4428 finishCheck.CheckSignalReceived();
4429 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
4433 int UtcDaliAnimationAnimateToVector4(void)
4435 TestApplication application;
4437 Actor actor = Actor::New();
4439 // Register a Vector4 property
4440 Vector4 startValue(-50.0f, -40.0f, -30.0f, -20.0f);
4441 Property::Index index = actor.RegisterProperty( "test-property", startValue );
4442 Stage::GetCurrent().Add(actor);
4443 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
4445 // Build the animation
4446 float durationSeconds(2.0f);
4447 Animation animation = Animation::New(durationSeconds);
4448 Vector4 targetValue(50.0f, 50.0f, 50.0f, 50.0f);
4449 Vector4 relativeValue(targetValue - startValue);
4450 animation.AnimateTo(Property(actor, index), targetValue);
4452 Vector4 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
4454 // Start the animation
4457 bool signalReceived(false);
4458 AnimationFinishCheck finishCheck(signalReceived);
4459 animation.FinishedSignal().Connect(&application, finishCheck);
4461 application.SendNotification();
4462 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
4464 // We didn't expect the animation to finish yet
4465 application.SendNotification();
4466 finishCheck.CheckSignalNotReceived();
4467 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), ninetyFivePercentProgress, TEST_LOCATION );
4469 application.SendNotification();
4470 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
4472 // We did expect the animation to finish
4473 application.SendNotification();
4474 finishCheck.CheckSignalReceived();
4475 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
4479 int UtcDaliAnimationAnimateToVector4AlphaFunction(void)
4481 TestApplication application;
4483 Actor actor = Actor::New();
4485 // Register a Vector4 property
4486 Vector4 startValue(1000.0f, 1000.0f, 1000.0f, 1000.0f);
4487 Property::Index index = actor.RegisterProperty( "test-property", startValue );
4488 Stage::GetCurrent().Add(actor);
4489 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
4491 // Build the animation
4492 float durationSeconds(1.0f);
4493 Animation animation = Animation::New(durationSeconds);
4494 Vector4 targetValue(9000.0f, 9000.0f, 9000.0f, 9000.0f);
4495 Vector4 relativeValue(targetValue - startValue);
4496 animation.AnimateTo(Property(actor, index), targetValue, AlphaFunctions::EaseOut);
4498 Vector4 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
4500 // Start the animation
4503 bool signalReceived(false);
4504 AnimationFinishCheck finishCheck(signalReceived);
4505 animation.FinishedSignal().Connect(&application, finishCheck);
4507 application.SendNotification();
4508 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
4510 // We didn't expect the animation to finish yet
4511 application.SendNotification();
4512 finishCheck.CheckSignalNotReceived();
4514 // The position should have moved more, than with a linear alpha function
4515 Vector4 current(actor.GetProperty<Vector4>(index));
4516 DALI_TEST_CHECK( current.x > ninetyFivePercentProgress.x );
4517 DALI_TEST_CHECK( current.y > ninetyFivePercentProgress.y );
4518 DALI_TEST_CHECK( current.z > ninetyFivePercentProgress.z );
4519 DALI_TEST_CHECK( current.w > ninetyFivePercentProgress.w );
4521 application.SendNotification();
4522 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
4524 // We did expect the animation to finish
4525 application.SendNotification();
4526 finishCheck.CheckSignalReceived();
4527 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
4531 int UtcDaliAnimationAnimateToVector4TimePeriod(void)
4533 TestApplication application;
4535 Actor actor = Actor::New();
4537 // Register a Vector4 property
4538 Vector4 startValue(10.0f, 10.0f, 10.0f, 10.0f);
4539 Property::Index index = actor.RegisterProperty( "test-property", startValue );
4540 Stage::GetCurrent().Add(actor);
4541 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, VECTOR4_EPSILON, TEST_LOCATION );
4543 // Build the animation
4544 float durationSeconds(1.0f);
4545 Animation animation = Animation::New(durationSeconds);
4546 Vector4 targetValue(-10.0f, 20.0f, 100.0f, 100.0f);
4547 Vector4 relativeValue(targetValue - startValue);
4549 animation.AnimateTo(Property(actor, index),
4551 TimePeriod(delay, durationSeconds - delay));
4553 // Start the animation
4556 bool signalReceived(false);
4557 AnimationFinishCheck finishCheck(signalReceived);
4558 animation.FinishedSignal().Connect(&application, finishCheck);
4560 application.SendNotification();
4561 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
4563 // We didn't expect the animation to finish yet
4564 application.SendNotification();
4565 finishCheck.CheckSignalNotReceived();
4566 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, VECTOR4_EPSILON, TEST_LOCATION );
4568 application.SendNotification();
4569 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
4571 // We didn't expect the animation to finish yet
4572 application.SendNotification();
4573 finishCheck.CheckSignalNotReceived();
4574 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue+(relativeValue*0.5f), VECTOR4_EPSILON, TEST_LOCATION );
4576 application.SendNotification();
4577 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
4579 // We did expect the animation to finish
4580 application.SendNotification();
4581 finishCheck.CheckSignalReceived();
4582 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, VECTOR4_EPSILON, TEST_LOCATION );
4586 int UtcDaliAnimationAnimateToVector4AlphaFunctionTimePeriod(void)
4588 TestApplication application;
4590 Actor actor = Actor::New();
4592 // Register a Vector4 property
4593 Vector4 startValue(10.0f, 10.0f, 10.0f, 10.0f);
4594 Property::Index index = actor.RegisterProperty( "test-property", startValue );
4595 Stage::GetCurrent().Add(actor);
4596 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
4598 // Build the animation
4599 float durationSeconds(1.0f);
4600 Animation animation = Animation::New(durationSeconds);
4601 Vector4 targetValue(30.0f, 30.0f, 30.0f, 30.0f);
4602 Vector4 relativeValue(targetValue - startValue);
4604 animation.AnimateTo(Property(actor, index),
4606 AlphaFunctions::Linear,
4607 TimePeriod(delay, durationSeconds - delay));
4609 // Start the animation
4612 bool signalReceived(false);
4613 AnimationFinishCheck finishCheck(signalReceived);
4614 animation.FinishedSignal().Connect(&application, finishCheck);
4616 application.SendNotification();
4617 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
4619 // We didn't expect the animation to finish yet
4620 application.SendNotification();
4621 finishCheck.CheckSignalNotReceived();
4622 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
4624 application.SendNotification();
4625 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
4627 // We didn't expect the animation to finish yet
4628 application.SendNotification();
4629 finishCheck.CheckSignalNotReceived();
4630 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
4632 application.SendNotification();
4633 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
4635 // We did expect the animation to finish
4636 application.SendNotification();
4637 finishCheck.CheckSignalReceived();
4638 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
4642 int UtcDaliAnimationAnimateToActorParentOrigin(void)
4644 TestApplication application;
4646 Actor actor = Actor::New();
4647 Stage::GetCurrent().Add(actor);
4648 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::TOP_LEFT, TEST_LOCATION );
4650 // Build the animation
4651 float durationSeconds(1.0f);
4652 Animation animation = Animation::New(durationSeconds);
4653 Vector3 targetParentOrigin(ParentOrigin::BOTTOM_RIGHT);
4657 animation.AnimateTo( Property(actor, Actor::PARENT_ORIGIN), targetParentOrigin );
4659 catch (Dali::DaliException& e)
4661 tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
4662 DALI_TEST_ASSERT(e, "IsPropertyAnimatable(index)", TEST_LOCATION);
4667 int UtcDaliAnimationAnimateToActorParentOriginX(void)
4669 TestApplication application;
4671 Actor actor = Actor::New();
4672 Stage::GetCurrent().Add(actor);
4673 float startValue(0.0f);
4674 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin().x, startValue, TEST_LOCATION );
4675 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::PARENT_ORIGIN_X), startValue, TEST_LOCATION );
4677 // Build the animation
4678 float durationSeconds(1.0f);
4679 Animation animation = Animation::New(durationSeconds);
4680 float targetX(1.0f);
4684 animation.AnimateTo( Property(actor, Actor::PARENT_ORIGIN_X), targetX );
4686 catch (Dali::DaliException& e)
4688 tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
4689 DALI_TEST_ASSERT(e, "IsPropertyAnimatable(index)", TEST_LOCATION);
4694 int UtcDaliAnimationAnimateToActorParentOriginY(void)
4696 TestApplication application;
4698 Actor actor = Actor::New();
4699 Stage::GetCurrent().Add(actor);
4700 float startValue(0.0f);
4701 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin().y, startValue, TEST_LOCATION );
4702 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::PARENT_ORIGIN_Y), startValue, TEST_LOCATION );
4704 // Build the animation
4705 float durationSeconds(1.0f);
4706 Animation animation = Animation::New(durationSeconds);
4707 float targetY(1.0f);
4711 animation.AnimateTo( Property(actor, Actor::PARENT_ORIGIN_Y), targetY );
4713 catch (Dali::DaliException& e)
4715 tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
4716 DALI_TEST_ASSERT(e, "IsPropertyAnimatable(index)", TEST_LOCATION);
4721 int UtcDaliAnimationAnimateToActorParentOriginZ(void)
4723 TestApplication application;
4725 Actor actor = Actor::New();
4726 Stage::GetCurrent().Add(actor);
4727 float startValue(0.5f);
4728 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin().z, startValue, TEST_LOCATION );
4729 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::PARENT_ORIGIN_Z), startValue, TEST_LOCATION );
4731 // Build the animation
4732 float durationSeconds(1.0f);
4733 Animation animation = Animation::New(durationSeconds);
4734 float targetZ(1.0f);
4738 animation.AnimateTo( Property(actor, Actor::PARENT_ORIGIN_Z), targetZ );
4740 catch (Dali::DaliException& e)
4742 tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
4743 DALI_TEST_ASSERT(e, "IsPropertyAnimatable(index)", TEST_LOCATION);
4748 int UtcDaliAnimationAnimateToActorAnchorPoint(void)
4750 TestApplication application;
4752 Actor actor = Actor::New();
4753 Stage::GetCurrent().Add(actor);
4754 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), AnchorPoint::CENTER, TEST_LOCATION );
4756 // Build the animation
4757 float durationSeconds(1.0f);
4758 Animation animation = Animation::New(durationSeconds);
4759 Vector3 targetAnchorPoint(AnchorPoint::TOP_LEFT);
4763 animation.AnimateTo( Property(actor, Actor::ANCHOR_POINT), targetAnchorPoint);
4765 catch (Dali::DaliException& e)
4767 tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
4768 DALI_TEST_ASSERT(e, "IsPropertyAnimatable(index)", TEST_LOCATION);
4773 int UtcDaliAnimationAnimateToActorAnchorPointX(void)
4775 TestApplication application;
4777 Actor actor = Actor::New();
4778 Stage::GetCurrent().Add(actor);
4779 float startValue(0.5f);
4780 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint().x, startValue, TEST_LOCATION );
4781 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::ANCHOR_POINT_X), startValue, TEST_LOCATION );
4783 // Build the animation
4784 float durationSeconds(1.0f);
4785 Animation animation = Animation::New(durationSeconds);
4786 float targetX(1.0f);
4790 animation.AnimateTo( Property(actor, Actor::ANCHOR_POINT_X), targetX );
4792 catch (Dali::DaliException& e)
4794 tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
4795 DALI_TEST_ASSERT(e, "IsPropertyAnimatable(index)", TEST_LOCATION);
4800 int UtcDaliAnimationAnimateToActorAnchorPointY(void)
4802 TestApplication application;
4804 Actor actor = Actor::New();
4805 Stage::GetCurrent().Add(actor);
4806 float startValue(0.5f);
4807 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint().y, startValue, TEST_LOCATION );
4808 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::ANCHOR_POINT_Y), startValue, TEST_LOCATION );
4810 // Build the animation
4811 float durationSeconds(1.0f);
4812 Animation animation = Animation::New(durationSeconds);
4813 float targetY(0.0f);
4817 animation.AnimateTo( Property(actor, Actor::ANCHOR_POINT_Y), targetY );
4819 catch (Dali::DaliException& e)
4821 tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
4822 DALI_TEST_ASSERT(e, "IsPropertyAnimatable(index)", TEST_LOCATION);
4827 int UtcDaliAnimationAnimateToActorAnchorPointZ(void)
4829 TestApplication application;
4831 Actor actor = Actor::New();
4832 Stage::GetCurrent().Add(actor);
4833 float startValue(0.5f);
4834 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint().z, startValue, TEST_LOCATION );
4835 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::ANCHOR_POINT_Z), startValue, TEST_LOCATION );
4837 // Build the animation
4838 float durationSeconds(1.0f);
4839 Animation animation = Animation::New(durationSeconds);
4840 float targetZ(100.0f);
4844 animation.AnimateTo( Property(actor, Actor::ANCHOR_POINT_Z), targetZ );
4846 catch (Dali::DaliException& e)
4848 tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
4849 DALI_TEST_ASSERT(e, "IsPropertyAnimatable(index)", TEST_LOCATION);
4854 int UtcDaliAnimationAnimateToActorSize(void)
4856 TestApplication application;
4858 Actor actor = Actor::New();
4859 Stage::GetCurrent().Add(actor);
4860 DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
4862 // Build the animation
4863 float durationSeconds(1.0f);
4864 Animation animation = Animation::New(durationSeconds);
4865 Vector3 targetSize(100.0f, 100.0f, 100.0f);
4866 animation.AnimateTo( Property(actor, Actor::SIZE), targetSize );
4868 Vector3 ninetyNinePercentProgress(targetSize * 0.99f);
4870 // Start the animation
4873 bool signalReceived(false);
4874 AnimationFinishCheck finishCheck(signalReceived);
4875 animation.FinishedSignal().Connect(&application, finishCheck);
4877 application.SendNotification();
4878 application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
4880 // We didn't expect the animation to finish yet
4881 application.SendNotification();
4882 finishCheck.CheckSignalNotReceived();
4883 DALI_TEST_EQUALS( actor.GetCurrentSize(), ninetyNinePercentProgress, TEST_LOCATION );
4885 application.SendNotification();
4886 application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
4888 // We did expect the animation to finish
4889 application.SendNotification();
4890 finishCheck.CheckSignalReceived();
4891 DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION );
4894 finishCheck.Reset();
4895 actor.SetSize(Vector3::ZERO);
4896 application.SendNotification();
4897 application.Render(0);
4898 DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
4900 // Repeat with a different (ease-in) alpha function
4901 animation = Animation::New(durationSeconds);
4902 animation.AnimateTo( Property(actor, Actor::SIZE), targetSize, AlphaFunctions::EaseIn);
4903 animation.FinishedSignal().Connect(&application, finishCheck);
4906 application.SendNotification();
4907 application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
4909 // We didn't expect the animation to finish yet
4910 application.SendNotification();
4911 finishCheck.CheckSignalNotReceived();
4913 // The size should have travelled less, than with a linear alpha function
4914 Vector3 current(actor.GetCurrentSize());
4915 DALI_TEST_CHECK( current.x > 0.0f );
4916 DALI_TEST_CHECK( current.y > 0.0f );
4917 DALI_TEST_CHECK( current.z > 0.0f );
4918 DALI_TEST_CHECK( current.x < ninetyNinePercentProgress.x );
4919 DALI_TEST_CHECK( current.y < ninetyNinePercentProgress.y );
4920 DALI_TEST_CHECK( current.z < ninetyNinePercentProgress.z );
4922 application.SendNotification();
4923 application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
4925 // We did expect the animation to finish
4926 application.SendNotification();
4927 finishCheck.CheckSignalReceived();
4928 DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION );
4931 finishCheck.Reset();
4932 actor.SetSize(Vector3::ZERO);
4933 application.SendNotification();
4934 application.Render(0);
4935 DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
4937 // Repeat with a delay
4939 animation = Animation::New(durationSeconds);
4940 animation.AnimateTo( Property(actor, Actor::SIZE), targetSize, AlphaFunctions::Linear, TimePeriod(delay, durationSeconds - delay));
4941 animation.FinishedSignal().Connect(&application, finishCheck);
4944 application.SendNotification();
4945 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
4947 // We didn't expect the animation to finish yet
4948 application.SendNotification();
4949 finishCheck.CheckSignalNotReceived();
4950 DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
4952 application.SendNotification();
4953 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
4955 // We did expect the animation to finish
4956 application.SendNotification();
4957 finishCheck.CheckSignalReceived();
4958 DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION );
4962 int UtcDaliAnimationAnimateToActorSizeWidth(void)
4964 TestApplication application;
4966 Actor actor = Actor::New();
4967 Stage::GetCurrent().Add(actor);
4968 float startValue(0.0f);
4969 DALI_TEST_EQUALS( actor.GetCurrentSize().width, startValue, TEST_LOCATION );
4970 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SIZE_WIDTH), startValue, TEST_LOCATION );
4972 // Build the animation
4973 float durationSeconds(1.0f);
4974 Animation animation = Animation::New(durationSeconds);
4975 float targetWidth(10.0f);
4976 animation.AnimateTo( Property(actor, Actor::SIZE_WIDTH), targetWidth );
4978 float fiftyPercentProgress(startValue + (targetWidth - startValue)*0.5f);
4980 // Start the animation
4983 bool signalReceived(false);
4984 AnimationFinishCheck finishCheck(signalReceived);
4985 animation.FinishedSignal().Connect(&application, finishCheck);
4987 application.SendNotification();
4988 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
4990 // We didn't expect the animation to finish yet
4991 application.SendNotification();
4992 finishCheck.CheckSignalNotReceived();
4993 DALI_TEST_EQUALS( actor.GetCurrentSize().width, fiftyPercentProgress, TEST_LOCATION );
4994 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SIZE_WIDTH), fiftyPercentProgress, TEST_LOCATION );
4996 application.SendNotification();
4997 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
4999 // We did expect the animation to finish
5000 application.SendNotification();
5001 finishCheck.CheckSignalReceived();
5002 DALI_TEST_EQUALS( actor.GetCurrentSize().width, targetWidth, TEST_LOCATION );
5003 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SIZE_WIDTH), targetWidth, TEST_LOCATION );
5007 int UtcDaliAnimationAnimateToActorSizeHeight(void)
5009 TestApplication application;
5011 Actor actor = Actor::New();
5012 Stage::GetCurrent().Add(actor);
5013 float startValue(0.0f);
5014 DALI_TEST_EQUALS( actor.GetCurrentSize().height, startValue, TEST_LOCATION );
5015 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SIZE_HEIGHT), startValue, TEST_LOCATION );
5017 // Build the animation
5018 float durationSeconds(1.0f);
5019 Animation animation = Animation::New(durationSeconds);
5020 float targetHeight(-10.0f);
5021 animation.AnimateTo( Property(actor, Actor::SIZE_HEIGHT), targetHeight );
5023 float fiftyPercentProgress(startValue + (targetHeight - startValue)*0.5f);
5025 // Start the animation
5028 bool signalReceived(false);
5029 AnimationFinishCheck finishCheck(signalReceived);
5030 animation.FinishedSignal().Connect(&application, finishCheck);
5032 application.SendNotification();
5033 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
5035 // We didn't expect the animation to finish yet
5036 application.SendNotification();
5037 finishCheck.CheckSignalNotReceived();
5038 DALI_TEST_EQUALS( actor.GetCurrentSize().height, fiftyPercentProgress, TEST_LOCATION );
5039 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SIZE_HEIGHT), fiftyPercentProgress, TEST_LOCATION );
5041 application.SendNotification();
5042 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
5044 // We did expect the animation to finish
5045 application.SendNotification();
5046 finishCheck.CheckSignalReceived();
5047 DALI_TEST_EQUALS( actor.GetCurrentSize().height, targetHeight, TEST_LOCATION );
5048 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SIZE_HEIGHT), targetHeight, TEST_LOCATION );
5052 int UtcDaliAnimationAnimateToActorSizeDepth(void)
5054 TestApplication application;
5056 Actor actor = Actor::New();
5057 Stage::GetCurrent().Add(actor);
5058 float startValue(0.0f);
5059 DALI_TEST_EQUALS( actor.GetCurrentSize().depth, startValue, TEST_LOCATION );
5060 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SIZE_DEPTH), startValue, TEST_LOCATION );
5062 // Build the animation
5063 float durationSeconds(1.0f);
5064 Animation animation = Animation::New(durationSeconds);
5065 float targetDepth(-10.0f);
5066 animation.AnimateTo( Property(actor, Actor::SIZE_DEPTH), targetDepth );
5068 float fiftyPercentProgress(startValue + (targetDepth - startValue)*0.5f);
5070 // Start the animation
5073 bool signalReceived(false);
5074 AnimationFinishCheck finishCheck(signalReceived);
5075 animation.FinishedSignal().Connect(&application, finishCheck);
5077 application.SendNotification();
5078 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
5080 // We didn't expect the animation to finish yet
5081 application.SendNotification();
5082 finishCheck.CheckSignalNotReceived();
5083 DALI_TEST_EQUALS( actor.GetCurrentSize().depth, fiftyPercentProgress, TEST_LOCATION );
5084 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SIZE_DEPTH), fiftyPercentProgress, TEST_LOCATION );
5086 application.SendNotification();
5087 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
5089 // We did expect the animation to finish
5090 application.SendNotification();
5091 finishCheck.CheckSignalReceived();
5092 DALI_TEST_EQUALS( actor.GetCurrentSize().depth, targetDepth, TEST_LOCATION );
5093 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SIZE_DEPTH), targetDepth, TEST_LOCATION );
5097 int UtcDaliAnimationAnimateToActorPosition(void)
5099 TestApplication application;
5101 Actor actor = Actor::New();
5102 Stage::GetCurrent().Add(actor);
5103 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
5105 // Build the animation
5106 float durationSeconds(1.0f);
5107 Animation animation = Animation::New(durationSeconds);
5108 Vector3 targetPosition(200.0f, 200.0f, 200.0f);
5109 animation.AnimateTo(Property(actor, Actor::POSITION), targetPosition);
5111 Vector3 seventyFivePercentProgress(targetPosition * 0.75f);
5113 // Start the animation
5116 bool signalReceived(false);
5117 AnimationFinishCheck finishCheck(signalReceived);
5118 animation.FinishedSignal().Connect(&application, finishCheck);
5120 application.SendNotification();
5121 application.Render(static_cast<unsigned int>(durationSeconds*750.0f)/* 75% progress */);
5123 // We didn't expect the animation to finish yet
5124 application.SendNotification();
5125 finishCheck.CheckSignalNotReceived();
5126 DALI_TEST_EQUALS( actor.GetCurrentPosition(), seventyFivePercentProgress, TEST_LOCATION );
5128 application.SendNotification();
5129 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
5131 // We did expect the animation to finish
5132 application.SendNotification();
5133 finishCheck.CheckSignalReceived();
5134 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
5138 int UtcDaliAnimationAnimateToActorPositionX(void)
5140 TestApplication application;
5142 Actor actor = Actor::New();
5143 Stage::GetCurrent().Add(actor);
5144 float startValue(0.0f);
5145 DALI_TEST_EQUALS( actor.GetCurrentPosition().x, startValue, TEST_LOCATION );
5146 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_X), startValue, TEST_LOCATION );
5147 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_Y), startValue, TEST_LOCATION );
5148 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_Z), startValue, TEST_LOCATION );
5150 // Build the animation
5151 float durationSeconds(1.0f);
5152 Animation animation = Animation::New(durationSeconds);
5153 float targetX(1.0f);
5154 animation.AnimateTo( Property(actor, Actor::POSITION_X), targetX );
5156 float fiftyPercentProgress(startValue + (targetX - startValue)*0.5f);
5158 // Start the animation
5161 bool signalReceived(false);
5162 AnimationFinishCheck finishCheck(signalReceived);
5163 animation.FinishedSignal().Connect(&application, finishCheck);
5165 application.SendNotification();
5166 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
5168 // We didn't expect the animation to finish yet
5169 application.SendNotification();
5170 finishCheck.CheckSignalNotReceived();
5171 DALI_TEST_EQUALS( actor.GetCurrentPosition().x, fiftyPercentProgress, TEST_LOCATION );
5172 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_X), fiftyPercentProgress, TEST_LOCATION );
5173 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_Y), startValue, TEST_LOCATION );
5174 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_Z), startValue, TEST_LOCATION );
5176 application.SendNotification();
5177 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
5179 // We did expect the animation to finish
5180 application.SendNotification();
5181 finishCheck.CheckSignalReceived();
5182 DALI_TEST_EQUALS( actor.GetCurrentPosition().x, targetX, TEST_LOCATION );
5183 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_X), targetX, TEST_LOCATION );
5184 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_Y), startValue, TEST_LOCATION );
5185 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_Z), startValue, TEST_LOCATION );
5189 int UtcDaliAnimationAnimateToActorPositionY(void)
5191 TestApplication application;
5193 Actor actor = Actor::New();
5194 Stage::GetCurrent().Add(actor);
5195 float startValue(0.0f);
5196 DALI_TEST_EQUALS( actor.GetCurrentPosition().y, startValue, TEST_LOCATION );
5197 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_X), startValue, TEST_LOCATION );
5198 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_Y), startValue, TEST_LOCATION );
5199 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_Z), startValue, TEST_LOCATION );
5201 // Build the animation
5202 float durationSeconds(1.0f);
5203 Animation animation = Animation::New(durationSeconds);
5204 float targetY(10.0f);
5205 animation.AnimateTo( Property(actor, Actor::POSITION_Y), targetY );
5207 float fiftyPercentProgress(startValue + (targetY - startValue)*0.5f);
5209 // Start the animation
5212 bool signalReceived(false);
5213 AnimationFinishCheck finishCheck(signalReceived);
5214 animation.FinishedSignal().Connect(&application, finishCheck);
5216 application.SendNotification();
5217 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
5219 // We didn't expect the animation to finish yet
5220 application.SendNotification();
5221 finishCheck.CheckSignalNotReceived();
5222 DALI_TEST_EQUALS( actor.GetCurrentPosition().y, fiftyPercentProgress, TEST_LOCATION );
5223 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_X), startValue, TEST_LOCATION );
5224 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_Y), fiftyPercentProgress, TEST_LOCATION );
5225 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_Z), startValue, TEST_LOCATION );
5227 application.SendNotification();
5228 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
5230 // We did expect the animation to finish
5231 application.SendNotification();
5232 finishCheck.CheckSignalReceived();
5233 DALI_TEST_EQUALS( actor.GetCurrentPosition().y, targetY, TEST_LOCATION );
5234 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_X), startValue, TEST_LOCATION );
5235 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_Y), targetY, TEST_LOCATION );
5236 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_Z), startValue, TEST_LOCATION );
5240 int UtcDaliAnimationAnimateToActorPositionZ(void)
5242 TestApplication application;
5244 Actor actor = Actor::New();
5245 Stage::GetCurrent().Add(actor);
5246 float startValue(0.0f);
5247 DALI_TEST_EQUALS( actor.GetCurrentPosition().z, startValue, TEST_LOCATION );
5248 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_X), startValue, TEST_LOCATION );
5249 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_Y), startValue, TEST_LOCATION );
5250 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_Z), startValue, TEST_LOCATION );
5252 // Build the animation
5253 float durationSeconds(1.0f);
5254 Animation animation = Animation::New(durationSeconds);
5255 float targetZ(-5.0f);
5256 animation.AnimateTo( Property(actor, Actor::POSITION_Z), targetZ );
5258 float fiftyPercentProgress(startValue + (targetZ - startValue)*0.5f);
5260 // Start the animation
5263 bool signalReceived(false);
5264 AnimationFinishCheck finishCheck(signalReceived);
5265 animation.FinishedSignal().Connect(&application, finishCheck);
5267 application.SendNotification();
5268 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
5270 // We didn't expect the animation to finish yet
5271 application.SendNotification();
5272 finishCheck.CheckSignalNotReceived();
5273 DALI_TEST_EQUALS( actor.GetCurrentPosition().z, fiftyPercentProgress, TEST_LOCATION );
5274 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_X), startValue, TEST_LOCATION );
5275 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_Y), startValue, TEST_LOCATION );
5276 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_Z), fiftyPercentProgress, TEST_LOCATION );
5278 application.SendNotification();
5279 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
5281 // We did expect the animation to finish
5282 application.SendNotification();
5283 finishCheck.CheckSignalReceived();
5284 DALI_TEST_EQUALS( actor.GetCurrentPosition().z, targetZ, TEST_LOCATION );
5285 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_X), startValue, TEST_LOCATION );
5286 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_Y), startValue, TEST_LOCATION );
5287 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_Z), targetZ, TEST_LOCATION );
5291 int UtcDaliAnimationAnimateToActorPositionAlphaFunction(void)
5293 TestApplication application;
5295 Actor actor = Actor::New();
5296 Stage::GetCurrent().Add(actor);
5297 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
5299 // Build the animation
5300 float durationSeconds(1.0f);
5301 Animation animation = Animation::New(durationSeconds);
5302 Vector3 targetPosition(200.0f, 200.0f, 200.0f);
5303 animation.AnimateTo(Property(actor, Actor::POSITION), targetPosition, AlphaFunctions::EaseIn);
5305 Vector3 seventyFivePercentProgress(targetPosition * 0.75f);
5307 // Start the animation
5310 bool signalReceived(false);
5311 AnimationFinishCheck finishCheck(signalReceived);
5312 animation.FinishedSignal().Connect(&application, finishCheck);
5314 application.SendNotification();
5315 application.Render(static_cast<unsigned int>(durationSeconds*750.0f)/* 75% progress */);
5317 // We didn't expect the animation to finish yet
5318 application.SendNotification();
5319 finishCheck.CheckSignalNotReceived();
5321 // The position should have moved less, than with a linear alpha function
5322 Vector3 current(actor.GetCurrentPosition());
5323 DALI_TEST_CHECK( current.x > Vector3::ZERO.x );
5324 DALI_TEST_CHECK( current.y > Vector3::ZERO.y );
5325 DALI_TEST_CHECK( current.z > Vector3::ZERO.z );
5326 DALI_TEST_CHECK( current.x < seventyFivePercentProgress.x );
5327 DALI_TEST_CHECK( current.y < seventyFivePercentProgress.y );
5328 DALI_TEST_CHECK( current.z < seventyFivePercentProgress.z );
5330 application.SendNotification();
5331 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
5333 // We did expect the animation to finish
5334 application.SendNotification();
5335 finishCheck.CheckSignalReceived();
5336 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
5340 int UtcDaliAnimationAnimateToActorPositionTimePeriod(void)
5342 TestApplication application;
5344 Actor actor = Actor::New();
5345 Stage::GetCurrent().Add(actor);
5346 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
5348 // Build the animation
5349 float durationSeconds(1.0f);
5350 Animation animation = Animation::New(durationSeconds);
5351 Vector3 targetPosition(200.0f, 200.0f, 200.0f);
5353 animation.AnimateTo( Property(actor, Actor::POSITION),
5355 TimePeriod( delay, durationSeconds - delay ) );
5357 Vector3 seventyFivePercentProgress(targetPosition * 0.75f);
5359 // Start the animation
5362 bool signalReceived(false);
5363 AnimationFinishCheck finishCheck(signalReceived);
5364 animation.FinishedSignal().Connect(&application, finishCheck);
5366 application.SendNotification();
5367 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
5369 // We didn't expect the animation to finish yet
5370 application.SendNotification();
5371 finishCheck.CheckSignalNotReceived();
5372 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
5374 application.SendNotification();
5375 application.Render(static_cast<unsigned int>(durationSeconds*500.0f*0.75)/* 7/8 animation progress, 3/4 animator progress */);
5377 // We didn't expect the animation to finish yet
5378 application.SendNotification();
5379 finishCheck.CheckSignalNotReceived();
5380 DALI_TEST_EQUALS( actor.GetCurrentPosition(), seventyFivePercentProgress, TEST_LOCATION );
5382 application.SendNotification();
5383 application.Render(static_cast<unsigned int>(durationSeconds*500.0f*0.25) + 1u/*just beyond the animation duration*/);
5385 // We did expect the animation to finish
5386 application.SendNotification();
5387 finishCheck.CheckSignalReceived();
5388 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
5392 int UtcDaliAnimationAnimateToActorPositionAlphaFunctionTimePeriod(void)
5394 TestApplication application;
5396 Actor actor = Actor::New();
5397 Stage::GetCurrent().Add(actor);
5398 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
5400 // Build the animation
5401 float durationSeconds(1.0f);
5402 Animation animation = Animation::New(durationSeconds);
5403 Vector3 targetPosition(200.0f, 200.0f, 200.0f);
5405 animation.AnimateTo( Property(actor, Actor::POSITION),
5407 AlphaFunctions::Linear,
5408 TimePeriod( delay, durationSeconds - delay ) );
5410 Vector3 seventyFivePercentProgress(targetPosition * 0.75f);
5412 // Start the animation
5415 bool signalReceived(false);
5416 AnimationFinishCheck finishCheck(signalReceived);
5417 animation.FinishedSignal().Connect(&application, finishCheck);
5419 application.SendNotification();
5420 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
5422 // We didn't expect the animation to finish yet
5423 application.SendNotification();
5424 finishCheck.CheckSignalNotReceived();
5425 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
5427 application.SendNotification();
5428 application.Render(static_cast<unsigned int>(durationSeconds*500.0f*0.75)/* 7/8 animation progress, 3/4 animator progress */);
5430 // We didn't expect the animation to finish yet
5431 application.SendNotification();
5432 finishCheck.CheckSignalNotReceived();
5433 DALI_TEST_EQUALS( actor.GetCurrentPosition(), seventyFivePercentProgress, TEST_LOCATION );
5435 application.SendNotification();
5436 application.Render(static_cast<unsigned int>(durationSeconds*500.0f*0.25) + 1u/*just beyond the animation duration*/);
5438 // We did expect the animation to finish
5439 application.SendNotification();
5440 finishCheck.CheckSignalReceived();
5441 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
5445 int UtcDaliAnimationAnimateToActorRotationAngleAxis(void)
5447 TestApplication application;
5449 Actor actor = Actor::New();
5450 actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
5451 Stage::GetCurrent().Add(actor);
5452 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5454 // Build the animation
5455 float durationSeconds(1.0f);
5456 Animation animation = Animation::New(durationSeconds);
5457 Degree targetRotationDegrees(90.0f);
5458 Radian targetRotationRadians(targetRotationDegrees);
5459 animation.AnimateTo( Property(actor, Actor::ROTATION), AngleAxis(targetRotationRadians, Vector3::YAXIS) );
5461 // Start the animation
5464 bool signalReceived(false);
5465 AnimationFinishCheck finishCheck(signalReceived);
5466 animation.FinishedSignal().Connect(&application, finishCheck);
5468 application.SendNotification();
5469 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
5471 // We didn't expect the animation to finish yet
5472 application.SendNotification();
5473 finishCheck.CheckSignalNotReceived();
5474 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.25f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5476 application.SendNotification();
5477 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
5479 // We didn't expect the animation to finish yet
5480 application.SendNotification();
5481 finishCheck.CheckSignalNotReceived();
5482 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.5f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5484 application.SendNotification();
5485 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
5487 // We didn't expect the animation to finish yet
5488 application.SendNotification();
5489 finishCheck.CheckSignalNotReceived();
5490 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.75f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5492 application.SendNotification();
5493 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
5495 // We did expect the animation to finish
5496 application.SendNotification();
5497 finishCheck.CheckSignalReceived();
5498 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5502 int UtcDaliAnimationAnimateToActorRotationQuaternion(void)
5504 TestApplication application;
5506 Actor actor = Actor::New();
5507 actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
5508 Stage::GetCurrent().Add(actor);
5509 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5511 // Build the animation
5512 float durationSeconds(1.0f);
5513 Animation animation = Animation::New(durationSeconds);
5514 Degree targetRotationDegrees(90.0f);
5515 Radian targetRotationRadians(targetRotationDegrees);
5516 Quaternion targetRotation(targetRotationRadians, Vector3::YAXIS);
5517 animation.AnimateTo( Property(actor, Actor::ROTATION), targetRotation );
5519 // Start the animation
5522 bool signalReceived(false);
5523 AnimationFinishCheck finishCheck(signalReceived);
5524 animation.FinishedSignal().Connect(&application, finishCheck);
5526 application.SendNotification();
5527 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
5529 // We didn't expect the animation to finish yet
5530 application.SendNotification();
5531 finishCheck.CheckSignalNotReceived();
5532 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.25f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5534 application.SendNotification();
5535 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
5537 // We didn't expect the animation to finish yet
5538 application.SendNotification();
5539 finishCheck.CheckSignalNotReceived();
5540 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.5f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5542 application.SendNotification();
5543 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
5545 // We didn't expect the animation to finish yet
5546 application.SendNotification();
5547 finishCheck.CheckSignalNotReceived();
5548 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.75f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5550 application.SendNotification();
5551 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
5553 // We did expect the animation to finish
5554 application.SendNotification();
5555 finishCheck.CheckSignalReceived();
5556 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5560 int UtcDaliAnimationAnimateToActorRotationAlphaFunction(void)
5562 TestApplication application;
5564 Actor actor = Actor::New();
5565 actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
5566 Stage::GetCurrent().Add(actor);
5567 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5569 // Build the animation
5570 float durationSeconds(1.0f);
5571 Animation animation = Animation::New(durationSeconds);
5572 Degree targetRotationDegrees(90.0f);
5573 Radian targetRotationRadians(targetRotationDegrees);
5574 animation.AnimateTo( Property(actor, Actor::ROTATION), AngleAxis(targetRotationDegrees, Vector3::YAXIS), AlphaFunctions::EaseIn);
5576 // Start the animation
5579 bool signalReceived(false);
5580 AnimationFinishCheck finishCheck(signalReceived);
5581 animation.FinishedSignal().Connect(&application, finishCheck);
5583 application.SendNotification();
5584 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
5586 // We didn't expect the animation to finish yet
5587 application.SendNotification();
5588 finishCheck.CheckSignalNotReceived();
5589 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(0.25f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5591 application.SendNotification();
5592 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
5594 // We didn't expect the animation to finish yet
5595 application.SendNotification();
5596 finishCheck.CheckSignalNotReceived();
5597 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(0.5f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5599 application.SendNotification();
5600 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
5602 // We didn't expect the animation to finish yet
5603 application.SendNotification();
5604 finishCheck.CheckSignalNotReceived();
5605 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(0.75f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5607 application.SendNotification();
5608 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
5610 // We did expect the animation to finish
5611 application.SendNotification();
5612 finishCheck.CheckSignalReceived();
5613 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5617 int UtcDaliAnimationAnimateToActorRotationTimePeriod(void)
5619 TestApplication application;
5621 Actor actor = Actor::New();
5622 actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
5623 Stage::GetCurrent().Add(actor);
5624 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5626 // Build the animation
5627 float durationSeconds(1.0f);
5628 Animation animation = Animation::New(durationSeconds);
5629 Degree targetRotationDegrees(90.0f);
5630 Radian targetRotationRadians(targetRotationDegrees);
5632 animation.AnimateTo( Property(actor, Actor::ROTATION), AngleAxis(targetRotationDegrees, Vector3::YAXIS), TimePeriod(delay, durationSeconds - delay));
5634 // Start the animation
5637 bool signalReceived(false);
5638 AnimationFinishCheck finishCheck(signalReceived);
5639 animation.FinishedSignal().Connect(&application, finishCheck);
5641 application.SendNotification();
5642 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
5644 // We didn't expect the animation to finish yet
5645 application.SendNotification();
5646 finishCheck.CheckSignalNotReceived();
5647 float progress = max(0.0f, 0.25f - delay) / (1.0f - delay);
5648 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * progress, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5650 application.SendNotification();
5651 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
5653 // We didn't expect the animation to finish yet
5654 application.SendNotification();
5655 finishCheck.CheckSignalNotReceived();
5656 progress = max(0.0f, 0.5f - delay) / (1.0f - delay);
5657 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * progress, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5659 application.SendNotification();
5660 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
5662 // We didn't expect the animation to finish yet
5663 application.SendNotification();
5664 finishCheck.CheckSignalNotReceived();
5665 progress = max(0.0f, 0.75f - delay) / (1.0f - delay);
5666 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * progress, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5668 application.SendNotification();
5669 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
5671 // We did expect the animation to finish
5672 application.SendNotification();
5673 finishCheck.CheckSignalReceived();
5674 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5678 int UtcDaliAnimationAnimateToActorRotationAlphaFunctionTimePeriod(void)
5680 TestApplication application;
5682 Actor actor = Actor::New();
5683 actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
5684 Stage::GetCurrent().Add(actor);
5685 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5687 // Build the animation
5688 float durationSeconds(1.0f);
5689 Animation animation = Animation::New(durationSeconds);
5690 Degree targetRotationDegrees(90.0f);
5691 Radian targetRotationRadians(targetRotationDegrees);
5693 animation.AnimateTo( Property(actor, Actor::ROTATION), AngleAxis(targetRotationDegrees, Vector3::YAXIS), AlphaFunctions::EaseIn, TimePeriod(delay, durationSeconds - delay));
5695 // Start the animation
5698 bool signalReceived(false);
5699 AnimationFinishCheck finishCheck(signalReceived);
5700 animation.FinishedSignal().Connect(&application, finishCheck);
5702 application.SendNotification();
5703 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
5705 // We didn't expect the animation to finish yet
5706 application.SendNotification();
5707 finishCheck.CheckSignalNotReceived();
5708 float progress = max(0.0f, 0.25f - delay) / (1.0f - delay);
5709 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5711 application.SendNotification();
5712 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
5714 // We didn't expect the animation to finish yet
5715 application.SendNotification();
5716 finishCheck.CheckSignalNotReceived();
5717 progress = max(0.0f, 0.5f - delay) / (1.0f - delay);
5718 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5720 application.SendNotification();
5721 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
5723 // We didn't expect the animation to finish yet
5724 application.SendNotification();
5725 finishCheck.CheckSignalNotReceived();
5726 progress = max(0.0f, 0.75f - delay) / (1.0f - delay);
5727 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5729 application.SendNotification();
5730 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
5732 // We did expect the animation to finish
5733 application.SendNotification();
5734 finishCheck.CheckSignalReceived();
5735 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5739 int UtcDaliAnimationAnimateToActorScale(void)
5741 TestApplication application;
5743 Actor actor = Actor::New();
5744 Stage::GetCurrent().Add(actor);
5745 DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
5747 // Build the animation
5748 float durationSeconds(1.0f);
5749 Animation animation = Animation::New(durationSeconds);
5750 Vector3 targetScale(2.0f, 2.0f, 2.0f);
5751 animation.AnimateTo( Property(actor, Actor::SCALE), targetScale );
5753 Vector3 ninetyNinePercentProgress(Vector3::ONE + (targetScale - Vector3::ONE)*0.99f);
5755 // Start the animation
5758 bool signalReceived(false);
5759 AnimationFinishCheck finishCheck(signalReceived);
5760 animation.FinishedSignal().Connect(&application, finishCheck);
5762 application.SendNotification();
5763 application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
5765 // We didn't expect the animation to finish yet
5766 application.SendNotification();
5767 finishCheck.CheckSignalNotReceived();
5768 DALI_TEST_EQUALS( actor.GetCurrentScale(), ninetyNinePercentProgress, TEST_LOCATION );
5770 application.SendNotification();
5771 application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
5773 // We did expect the animation to finish
5774 application.SendNotification();
5775 finishCheck.CheckSignalReceived();
5776 DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
5779 finishCheck.Reset();
5780 actor.SetScale(Vector3::ONE);
5781 application.SendNotification();
5782 application.Render(0);
5783 DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
5785 // Repeat with a different (ease-in) alpha function
5786 animation = Animation::New(durationSeconds);
5787 animation.AnimateTo( Property(actor, Actor::SCALE), targetScale, AlphaFunctions::EaseIn);
5788 animation.FinishedSignal().Connect(&application, finishCheck);
5791 application.SendNotification();
5792 application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
5794 // We didn't expect the animation to finish yet
5795 application.SendNotification();
5796 finishCheck.CheckSignalNotReceived();
5798 // The scale should have grown less, than with a linear alpha function
5799 Vector3 current(actor.GetCurrentScale());
5800 DALI_TEST_CHECK( current.x > 1.0f );
5801 DALI_TEST_CHECK( current.y > 1.0f );
5802 DALI_TEST_CHECK( current.z > 1.0f );
5803 DALI_TEST_CHECK( current.x < ninetyNinePercentProgress.x );
5804 DALI_TEST_CHECK( current.y < ninetyNinePercentProgress.y );
5805 DALI_TEST_CHECK( current.z < ninetyNinePercentProgress.z );
5807 application.SendNotification();
5808 application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
5810 // We did expect the animation to finish
5811 application.SendNotification();
5812 finishCheck.CheckSignalReceived();
5813 DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
5816 finishCheck.Reset();
5817 actor.SetScale(Vector3::ONE);
5818 application.SendNotification();
5819 application.Render(0);
5820 DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
5822 // Repeat with a delay
5824 animation = Animation::New(durationSeconds);
5825 animation.AnimateTo( Property(actor, Actor::SCALE), targetScale, AlphaFunctions::Linear, TimePeriod(delay, durationSeconds - delay));
5826 animation.FinishedSignal().Connect(&application, finishCheck);
5829 application.SendNotification();
5830 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
5832 // We didn't expect the animation to finish yet
5833 application.SendNotification();
5834 finishCheck.CheckSignalNotReceived();
5835 DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
5837 application.SendNotification();
5838 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
5840 // We did expect the animation to finish
5841 application.SendNotification();
5842 finishCheck.CheckSignalReceived();
5843 DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
5847 int UtcDaliAnimationAnimateToActorScaleX(void)
5849 TestApplication application;
5851 Actor actor = Actor::New();
5852 Stage::GetCurrent().Add(actor);
5853 float startValue(1.0f);
5854 DALI_TEST_EQUALS( actor.GetCurrentScale().x, startValue, TEST_LOCATION );
5855 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_X), startValue, TEST_LOCATION );
5856 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_Y), startValue, TEST_LOCATION );
5857 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_Z), startValue, TEST_LOCATION );
5859 // Build the animation
5860 float durationSeconds(1.0f);
5861 Animation animation = Animation::New(durationSeconds);
5862 float targetX(10.0f);
5863 animation.AnimateTo( Property(actor, Actor::SCALE_X), targetX );
5865 float fiftyPercentProgress(startValue + (targetX - startValue)*0.5f);
5867 // Start the animation
5870 bool signalReceived(false);
5871 AnimationFinishCheck finishCheck(signalReceived);
5872 animation.FinishedSignal().Connect(&application, finishCheck);
5874 application.SendNotification();
5875 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
5877 // We didn't expect the animation to finish yet
5878 application.SendNotification();
5879 finishCheck.CheckSignalNotReceived();
5880 DALI_TEST_EQUALS( actor.GetCurrentScale().x, fiftyPercentProgress, TEST_LOCATION );
5881 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_X), fiftyPercentProgress, TEST_LOCATION );
5882 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_Y), startValue, TEST_LOCATION );
5883 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_Z), startValue, TEST_LOCATION );
5885 application.SendNotification();
5886 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
5888 // We did expect the animation to finish
5889 application.SendNotification();
5890 finishCheck.CheckSignalReceived();
5891 DALI_TEST_EQUALS( actor.GetCurrentScale().x, targetX, TEST_LOCATION );
5892 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_X), targetX, TEST_LOCATION );
5893 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_Y), startValue, TEST_LOCATION );
5894 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_Z), startValue, TEST_LOCATION );
5898 int UtcDaliAnimationAnimateToActorScaleY(void)
5900 TestApplication application;
5902 Actor actor = Actor::New();
5903 Stage::GetCurrent().Add(actor);
5904 float startValue(1.0f);
5905 DALI_TEST_EQUALS( actor.GetCurrentScale().y, startValue, TEST_LOCATION );
5906 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_X), startValue, TEST_LOCATION );
5907 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_Y), startValue, TEST_LOCATION );
5908 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_Z), startValue, TEST_LOCATION );
5910 // Build the animation
5911 float durationSeconds(1.0f);
5912 Animation animation = Animation::New(durationSeconds);
5913 float targetY(1000.0f);
5914 animation.AnimateTo( Property(actor, Actor::SCALE_Y), targetY );
5916 float fiftyPercentProgress(startValue + (targetY - startValue)*0.5f);
5918 // Start the animation
5921 bool signalReceived(false);
5922 AnimationFinishCheck finishCheck(signalReceived);
5923 animation.FinishedSignal().Connect(&application, finishCheck);
5925 application.SendNotification();
5926 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
5928 // We didn't expect the animation to finish yet
5929 application.SendNotification();
5930 finishCheck.CheckSignalNotReceived();
5931 DALI_TEST_EQUALS( actor.GetCurrentScale().y, fiftyPercentProgress, TEST_LOCATION );
5932 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_X), startValue, TEST_LOCATION );
5933 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_Y), fiftyPercentProgress, TEST_LOCATION );
5934 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_Z), startValue, TEST_LOCATION );
5936 application.SendNotification();
5937 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
5939 // We did expect the animation to finish
5940 application.SendNotification();
5941 finishCheck.CheckSignalReceived();
5942 DALI_TEST_EQUALS( actor.GetCurrentScale().y, targetY, TEST_LOCATION );
5943 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_X), startValue, TEST_LOCATION );
5944 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_Y), targetY, TEST_LOCATION );
5945 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_Z), startValue, TEST_LOCATION );
5949 int UtcDaliAnimationAnimateToActorScaleZ(void)
5951 TestApplication application;
5953 Actor actor = Actor::New();
5954 Stage::GetCurrent().Add(actor);
5955 float startValue(1.0f);
5956 DALI_TEST_EQUALS( actor.GetCurrentScale().z, startValue, TEST_LOCATION );
5957 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_X), startValue, TEST_LOCATION );
5958 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_Y), startValue, TEST_LOCATION );
5959 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_Z), startValue, TEST_LOCATION );
5961 // Build the animation
5962 float durationSeconds(1.0f);
5963 Animation animation = Animation::New(durationSeconds);
5964 float targetZ(-1000.0f);
5965 animation.AnimateTo( Property(actor, Actor::SCALE_Z), targetZ );
5967 float fiftyPercentProgress(startValue + (targetZ - startValue)*0.5f);
5969 // Start the animation
5972 bool signalReceived(false);
5973 AnimationFinishCheck finishCheck(signalReceived);
5974 animation.FinishedSignal().Connect(&application, finishCheck);
5976 application.SendNotification();
5977 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
5979 // We didn't expect the animation to finish yet
5980 application.SendNotification();
5981 finishCheck.CheckSignalNotReceived();
5982 DALI_TEST_EQUALS( actor.GetCurrentScale().z, fiftyPercentProgress, TEST_LOCATION );
5983 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_X), startValue, TEST_LOCATION );
5984 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_Y), startValue, TEST_LOCATION );
5985 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_Z), fiftyPercentProgress, TEST_LOCATION );
5987 application.SendNotification();
5988 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
5990 // We did expect the animation to finish
5991 application.SendNotification();
5992 finishCheck.CheckSignalReceived();
5993 DALI_TEST_EQUALS( actor.GetCurrentScale().z, targetZ, TEST_LOCATION );
5994 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_X), startValue, TEST_LOCATION );
5995 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_Y), startValue, TEST_LOCATION );
5996 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_Z), targetZ, TEST_LOCATION );
6000 int UtcDaliAnimationAnimateToActorColor(void)
6002 TestApplication application;
6004 Actor actor = Actor::New();
6005 Stage::GetCurrent().Add(actor);
6006 DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
6008 // Build the animation
6009 float durationSeconds(1.0f);
6010 Animation animation = Animation::New(durationSeconds);
6011 Vector4 targetColor(Color::RED);
6012 animation.AnimateTo( Property(actor, Actor::COLOR), targetColor );
6014 Vector4 tenPercentProgress(Vector4(1.0f, 0.9f, 0.9f, 1.0f));
6015 Vector4 twentyPercentProgress(Vector4(1.0f, 0.8f, 0.8f, 1.0f));
6017 // Start the animation
6020 bool signalReceived(false);
6021 AnimationFinishCheck finishCheck(signalReceived);
6022 animation.FinishedSignal().Connect(&application, finishCheck);
6024 application.SendNotification();
6025 application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% progress */);
6027 // We didn't expect the animation to finish yet
6028 application.SendNotification();
6029 finishCheck.CheckSignalNotReceived();
6030 DALI_TEST_EQUALS( actor.GetCurrentColor(), tenPercentProgress, TEST_LOCATION );
6032 application.SendNotification();
6033 application.Render(static_cast<unsigned int>(durationSeconds*900.0f) + 1u/*just beyond the animation duration*/);
6035 // We did expect the animation to finish
6036 application.SendNotification();
6037 finishCheck.CheckSignalReceived();
6038 DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION );
6041 finishCheck.Reset();
6042 actor.SetColor(Color::WHITE);
6043 application.SendNotification();
6044 application.Render(0);
6045 DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
6047 // Repeat with a different (ease-in) alpha function
6048 animation = Animation::New(durationSeconds);
6049 animation.AnimateTo( Property(actor, Actor::COLOR), targetColor, AlphaFunctions::EaseIn);
6050 animation.FinishedSignal().Connect(&application, finishCheck);
6053 application.SendNotification();
6054 application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% progress */);
6056 // We didn't expect the animation to finish yet
6057 application.SendNotification();
6058 finishCheck.CheckSignalNotReceived();
6060 // The color should have changed less, than with a linear alpha function
6061 Vector4 current(actor.GetCurrentColor());
6062 DALI_TEST_CHECK( current.x == 1.0f ); // doesn't change
6063 DALI_TEST_CHECK( current.y < 1.0f );
6064 DALI_TEST_CHECK( current.y > tenPercentProgress.y );
6065 DALI_TEST_CHECK( current.z < 1.0f );
6066 DALI_TEST_CHECK( current.z > tenPercentProgress.z );
6067 DALI_TEST_CHECK( current.w == 1.0f ); // doesn't change
6069 application.SendNotification();
6070 application.Render(static_cast<unsigned int>(durationSeconds*900.0f) + 1u/*just beyond the animation duration*/);
6072 // We did expect the animation to finish
6073 application.SendNotification();
6074 finishCheck.CheckSignalReceived();
6075 DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION );
6078 finishCheck.Reset();
6079 actor.SetColor(Color::WHITE);
6080 application.SendNotification();
6081 application.Render(0);
6082 DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
6084 // Repeat with a shorter animator duration
6085 float animatorDuration = 0.5f;
6086 animation = Animation::New(durationSeconds);
6087 animation.AnimateTo( Property(actor, Actor::COLOR), targetColor, AlphaFunctions::Linear, TimePeriod(animatorDuration));
6088 animation.FinishedSignal().Connect(&application, finishCheck);
6091 application.SendNotification();
6092 application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% animation progress, 20% animator progress */);
6094 // We didn't expect the animation to finish yet
6095 application.SendNotification();
6096 finishCheck.CheckSignalNotReceived();
6097 DALI_TEST_EQUALS( actor.GetCurrentColor(), twentyPercentProgress, TEST_LOCATION );
6099 application.SendNotification();
6100 application.Render(static_cast<unsigned int>(durationSeconds*400.0f)/* 50% animation progress, 100% animator progress */);
6102 // We didn't expect the animation to finish yet
6103 application.SendNotification();
6104 finishCheck.CheckSignalNotReceived();
6105 DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION );
6107 application.SendNotification();
6108 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
6110 // We did expect the animation to finish
6111 application.SendNotification();
6112 finishCheck.CheckSignalReceived();
6113 DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION );
6117 int UtcDaliAnimationAnimateToActorColorRed(void)
6119 TestApplication application;
6121 Actor actor = Actor::New();
6122 Stage::GetCurrent().Add(actor);
6123 float startValue(1.0f);
6124 DALI_TEST_EQUALS( actor.GetCurrentColor().r, startValue, TEST_LOCATION );
6125 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
6126 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
6127 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
6128 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), startValue, TEST_LOCATION );
6130 // Build the animation
6131 float durationSeconds(1.0f);
6132 Animation animation = Animation::New(durationSeconds);
6133 float targetRed(0.5f);
6134 animation.AnimateTo( Property(actor, Actor::COLOR_RED), targetRed );
6136 float fiftyPercentProgress(startValue + (targetRed - startValue)*0.5f);
6138 // Start the animation
6141 bool signalReceived(false);
6142 AnimationFinishCheck finishCheck(signalReceived);
6143 animation.FinishedSignal().Connect(&application, finishCheck);
6145 application.SendNotification();
6146 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
6148 // We didn't expect the animation to finish yet
6149 application.SendNotification();
6150 finishCheck.CheckSignalNotReceived();
6151 DALI_TEST_EQUALS( actor.GetCurrentColor().r, fiftyPercentProgress, TEST_LOCATION );
6152 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), fiftyPercentProgress, TEST_LOCATION );
6153 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
6154 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
6155 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), startValue, TEST_LOCATION );
6157 application.SendNotification();
6158 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
6160 // We did expect the animation to finish
6161 application.SendNotification();
6162 finishCheck.CheckSignalReceived();
6163 DALI_TEST_EQUALS( actor.GetCurrentColor().r, targetRed, TEST_LOCATION );
6164 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), targetRed, TEST_LOCATION );
6165 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
6166 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
6167 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), startValue, TEST_LOCATION );
6171 int UtcDaliAnimationAnimateToActorColorGreen(void)
6173 TestApplication application;
6175 Actor actor = Actor::New();
6176 Stage::GetCurrent().Add(actor);
6177 float startValue(1.0f);
6178 DALI_TEST_EQUALS( actor.GetCurrentColor().g, startValue, TEST_LOCATION );
6179 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
6180 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
6181 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
6182 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), startValue, TEST_LOCATION );
6184 // Build the animation
6185 float durationSeconds(1.0f);
6186 Animation animation = Animation::New(durationSeconds);
6187 float targetGreen(0.5f);
6188 animation.AnimateTo( Property(actor, Actor::COLOR_GREEN), targetGreen );
6190 float fiftyPercentProgress(startValue + (targetGreen - startValue)*0.5f);
6192 // Start the animation
6195 bool signalReceived(false);
6196 AnimationFinishCheck finishCheck(signalReceived);
6197 animation.FinishedSignal().Connect(&application, finishCheck);
6199 application.SendNotification();
6200 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
6202 // We didn't expect the animation to finish yet
6203 application.SendNotification();
6204 finishCheck.CheckSignalNotReceived();
6205 DALI_TEST_EQUALS( actor.GetCurrentColor().g, fiftyPercentProgress, TEST_LOCATION );
6206 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
6207 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), fiftyPercentProgress, TEST_LOCATION );
6208 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
6209 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), startValue, TEST_LOCATION );
6211 application.SendNotification();
6212 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
6214 // We did expect the animation to finish
6215 application.SendNotification();
6216 finishCheck.CheckSignalReceived();
6217 DALI_TEST_EQUALS( actor.GetCurrentColor().g, targetGreen, TEST_LOCATION );
6218 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
6219 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), targetGreen, TEST_LOCATION );
6220 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
6221 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), startValue, TEST_LOCATION );
6225 int UtcDaliAnimationAnimateToActorColorBlue(void)
6227 TestApplication application;
6229 Actor actor = Actor::New();
6230 Stage::GetCurrent().Add(actor);
6231 float startValue(1.0f);
6232 DALI_TEST_EQUALS( actor.GetCurrentColor().b, startValue, TEST_LOCATION );
6233 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
6234 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
6235 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
6236 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), startValue, TEST_LOCATION );
6238 // Build the animation
6239 float durationSeconds(1.0f);
6240 Animation animation = Animation::New(durationSeconds);
6241 float targetBlue(0.5f);
6242 animation.AnimateTo( Property(actor, Actor::COLOR_BLUE), targetBlue );
6244 float fiftyPercentProgress(startValue + (targetBlue - startValue)*0.5f);
6246 // Start the animation
6249 bool signalReceived(false);
6250 AnimationFinishCheck finishCheck(signalReceived);
6251 animation.FinishedSignal().Connect(&application, finishCheck);
6253 application.SendNotification();
6254 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
6256 // We didn't expect the animation to finish yet
6257 application.SendNotification();
6258 finishCheck.CheckSignalNotReceived();
6259 DALI_TEST_EQUALS( actor.GetCurrentColor().b, fiftyPercentProgress, TEST_LOCATION );
6260 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
6261 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
6262 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), fiftyPercentProgress, TEST_LOCATION );
6263 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), startValue, TEST_LOCATION );
6265 application.SendNotification();
6266 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
6268 // We did expect the animation to finish
6269 application.SendNotification();
6270 finishCheck.CheckSignalReceived();
6271 DALI_TEST_EQUALS( actor.GetCurrentColor().b, targetBlue, TEST_LOCATION );
6272 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
6273 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
6274 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), targetBlue, TEST_LOCATION );
6275 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), startValue, TEST_LOCATION );
6279 int UtcDaliAnimationAnimateToActorColorAlpha(void)
6281 TestApplication application;
6283 Actor actor = Actor::New();
6284 Stage::GetCurrent().Add(actor);
6285 float startValue(1.0f);
6286 DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
6287 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
6288 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
6289 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
6290 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), startValue, TEST_LOCATION );
6292 // Build the animation
6293 float durationSeconds(1.0f);
6294 Animation animation = Animation::New(durationSeconds);
6295 float targetAlpha(0.5f);
6296 animation.AnimateTo( Property(actor, Actor::COLOR_ALPHA), targetAlpha );
6298 float fiftyPercentProgress(startValue + (targetAlpha - startValue)*0.5f);
6300 // Start the animation
6303 bool signalReceived(false);
6304 AnimationFinishCheck finishCheck(signalReceived);
6305 animation.FinishedSignal().Connect(&application, finishCheck);
6307 application.SendNotification();
6308 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
6310 // We didn't expect the animation to finish yet
6311 application.SendNotification();
6312 finishCheck.CheckSignalNotReceived();
6313 DALI_TEST_EQUALS( actor.GetCurrentColor().a, fiftyPercentProgress, TEST_LOCATION );
6314 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
6315 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
6316 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
6317 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), fiftyPercentProgress, TEST_LOCATION );
6319 application.SendNotification();
6320 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
6322 // We did expect the animation to finish
6323 application.SendNotification();
6324 finishCheck.CheckSignalReceived();
6325 DALI_TEST_EQUALS( actor.GetCurrentColor().a, targetAlpha, TEST_LOCATION );
6326 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
6327 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
6328 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
6329 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), targetAlpha, TEST_LOCATION );
6335 int UtcDaliAnimationKeyFrames01(void)
6337 TestApplication application;
6339 KeyFrames keyFrames = KeyFrames::New();
6340 DALI_TEST_EQUALS(keyFrames.GetType(), Property::NONE, TEST_LOCATION);
6342 keyFrames.Add(0.0f, 0.1f);
6343 keyFrames.Add(0.2f, 0.5f);
6344 keyFrames.Add(0.4f, 0.0f);
6345 keyFrames.Add(0.6f, 1.0f);
6346 keyFrames.Add(0.8f, 0.7f);
6347 keyFrames.Add(1.0f, 0.9f);
6349 DALI_TEST_EQUALS(keyFrames.GetType(), Property::FLOAT, TEST_LOCATION);
6353 keyFrames.Add(1.9f, false);
6355 catch (Dali::DaliException& e)
6357 tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
6358 DALI_TEST_ASSERT(e, "mType == value.GetType()", TEST_LOCATION);
6363 int UtcDaliAnimationKeyFrames02(void)
6365 TestApplication application;
6367 KeyFrames keyFrames = KeyFrames::New();
6368 DALI_TEST_EQUALS(keyFrames.GetType(), Property::NONE, TEST_LOCATION);
6370 keyFrames.Add(0.0f, true);
6371 keyFrames.Add(0.2f, false);
6372 keyFrames.Add(0.4f, false);
6373 keyFrames.Add(0.6f, true);
6374 keyFrames.Add(0.8f, true);
6375 keyFrames.Add(1.0f, false);
6377 DALI_TEST_EQUALS(keyFrames.GetType(), Property::BOOLEAN, TEST_LOCATION);
6381 keyFrames.Add(0.7f, Vector3(1.0f, 1.0f, 1.0f));
6383 catch (Dali::DaliException& e)
6385 tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
6386 DALI_TEST_ASSERT(e, "mType == value.GetType()", TEST_LOCATION);
6392 int UtcDaliAnimationKeyFrames03(void)
6394 TestApplication application;
6396 KeyFrames keyFrames = KeyFrames::New();
6397 DALI_TEST_EQUALS(keyFrames.GetType(), Property::NONE, TEST_LOCATION);
6399 keyFrames.Add(0.0f, Vector2(0.0f, 0.0f));
6400 keyFrames.Add(0.2f, Vector2(1.0f, 1.0f));
6401 keyFrames.Add(0.4f, Vector2(2.0f, 2.0f));
6402 keyFrames.Add(0.6f, Vector2(3.0f, 5.0f));
6403 keyFrames.Add(0.8f, Vector2(4.0f, 3.0f));
6404 keyFrames.Add(1.0f, Vector2(6.0f, 2.0f));
6406 DALI_TEST_EQUALS(keyFrames.GetType(), Property::VECTOR2, TEST_LOCATION);
6410 keyFrames.Add(0.7f, Vector3(1.0f, 1.0f, 1.0f));
6412 catch (Dali::DaliException& e)
6414 tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
6415 DALI_TEST_ASSERT(e, "mType == value.GetType()", TEST_LOCATION);
6421 int UtcDaliAnimationKeyFrames04(void)
6423 TestApplication application;
6425 KeyFrames keyFrames = KeyFrames::New();
6426 DALI_TEST_EQUALS(keyFrames.GetType(), Property::NONE, TEST_LOCATION);
6428 keyFrames.Add(0.0f, Vector3(0.0f, 4.0f, 0.0f));
6429 keyFrames.Add(0.2f, Vector3(1.0f, 3.0f, 1.0f));
6430 keyFrames.Add(0.4f, Vector3(2.0f, 2.0f, 2.0f));
6431 keyFrames.Add(0.6f, Vector3(3.0f, 2.0f, 5.0f));
6432 keyFrames.Add(0.8f, Vector3(4.0f, 4.0f, 3.0f));
6433 keyFrames.Add(1.0f, Vector3(6.0f, 8.0f, 2.0f));
6435 DALI_TEST_EQUALS(keyFrames.GetType(), Property::VECTOR3, TEST_LOCATION);
6439 keyFrames.Add(0.7f, 1.0f);
6441 catch (Dali::DaliException& e)
6443 tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
6444 DALI_TEST_ASSERT(e, "mType == value.GetType()", TEST_LOCATION);
6449 int UtcDaliAnimationKeyFrames05(void)
6451 TestApplication application;
6453 KeyFrames keyFrames = KeyFrames::New();
6454 DALI_TEST_EQUALS(keyFrames.GetType(), Property::NONE, TEST_LOCATION);
6456 keyFrames.Add(0.0f, Vector4(0.0f, 0.0f, 0.0f, 0.0f));
6457 keyFrames.Add(0.2f, Vector4(1.0f, 1.0f, 1.0f, 1.0f));
6458 keyFrames.Add(0.4f, Vector4(2.0f, 2.0f, 2.0f, 2.0f));
6459 keyFrames.Add(0.6f, Vector4(3.0f, 5.0f, 3.0f, 5.0f));
6460 keyFrames.Add(0.8f, Vector4(4.0f, 3.0f, 4.0f, 3.0f));
6461 keyFrames.Add(1.0f, Vector4(6.0f, 2.0f, 6.0f, 2.0f));
6463 DALI_TEST_EQUALS(keyFrames.GetType(), Property::VECTOR4, TEST_LOCATION);
6467 keyFrames.Add(0.7f, Quaternion(1.717f, Vector3::XAXIS));
6469 catch (Dali::DaliException& e)
6471 tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
6472 DALI_TEST_ASSERT(e, "mType == value.GetType()", TEST_LOCATION);
6478 int UtcDaliAnimationKeyFrames06(void)
6480 TestApplication application;
6482 KeyFrames keyFrames = KeyFrames::New();
6483 DALI_TEST_EQUALS(keyFrames.GetType(), Property::NONE, TEST_LOCATION);
6485 keyFrames.Add(0.0f, Quaternion(1.717f, Vector3::XAXIS));
6486 keyFrames.Add(0.2f, Quaternion(2.0f, Vector3::XAXIS));
6487 keyFrames.Add(0.4f, Quaternion(3.0f, Vector3::ZAXIS));
6488 keyFrames.Add(0.6f, Quaternion(4.0f, Vector3(1.0f, 1.0f, 1.0f)));
6489 keyFrames.Add(0.8f, AngleAxis(Degree(90), Vector3::XAXIS));
6490 keyFrames.Add(1.0f, Quaternion(3.0f, Vector3::YAXIS));
6492 DALI_TEST_EQUALS(keyFrames.GetType(), Property::ROTATION, TEST_LOCATION);
6496 keyFrames.Add(0.7f, 1.1f);
6498 catch (Dali::DaliException& e)
6500 tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
6501 DALI_TEST_ASSERT(e, "mType == value.GetType()", TEST_LOCATION);
6510 int UtcDaliAnimationAnimateBetweenActorColorAlpha(void)
6512 TestApplication application;
6514 float startValue(1.0f);
6515 Actor actor = Actor::New();
6516 actor.SetColor(Vector4(startValue, startValue, startValue, startValue));
6517 Stage::GetCurrent().Add(actor);
6519 DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
6520 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
6521 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
6522 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
6523 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), startValue, TEST_LOCATION );
6525 // Build the animation
6526 float durationSeconds(1.0f);
6527 Animation animation = Animation::New(durationSeconds);
6529 KeyFrames keyFrames = KeyFrames::New();
6530 keyFrames.Add(0.0f, 0.1f);
6531 keyFrames.Add(0.2f, 0.5f);
6532 keyFrames.Add(0.4f, 0.0f);
6533 keyFrames.Add(0.6f, 1.0f);
6534 keyFrames.Add(0.8f, 0.7f);
6535 keyFrames.Add(1.0f, 0.9f);
6537 animation.AnimateBetween( Property(actor, Actor::COLOR_ALPHA), keyFrames );
6539 // Start the animation
6542 bool signalReceived(false);
6543 AnimationFinishCheck finishCheck(signalReceived);
6544 animation.FinishedSignal().Connect(&application, finishCheck);
6545 application.SendNotification();
6546 application.Render(0);
6547 application.SendNotification();
6548 finishCheck.CheckSignalNotReceived();
6549 DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.1f, TEST_LOCATION );
6551 application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% progress */);
6552 application.SendNotification();
6553 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
6554 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
6555 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
6556 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.3f, 0.01f, TEST_LOCATION );
6557 DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.3f, 0.01f, TEST_LOCATION );
6559 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 30% progress */);
6560 application.SendNotification();
6561 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
6562 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
6563 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
6564 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.25f, 0.01f, TEST_LOCATION );
6565 DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.25f, 0.01f, TEST_LOCATION );
6567 application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 40% progress */);
6568 application.SendNotification();
6569 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
6570 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
6571 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
6572 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.0f, 0.01f, TEST_LOCATION );
6573 DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.0f, 0.01f, TEST_LOCATION );
6575 application.Render(static_cast<unsigned int>(durationSeconds*400.0f)/* 80% progress */);
6576 application.SendNotification();
6577 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
6578 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
6579 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
6580 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.7f, 0.01f, TEST_LOCATION );
6581 DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.7f, 0.01f, TEST_LOCATION );
6583 application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 90% progress */);
6584 application.SendNotification();
6585 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
6586 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
6587 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
6588 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.8f, 0.01f, TEST_LOCATION );
6589 DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.8f, 0.01f, TEST_LOCATION );
6591 application.Render(static_cast<unsigned int>(durationSeconds*100.0f)+1/* 100% progress */);
6592 application.SendNotification();
6593 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
6594 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
6595 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
6596 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.9f, 0.01f, TEST_LOCATION );
6597 DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.9f, 0.01f, TEST_LOCATION );
6599 // We did expect the animation to finish
6601 finishCheck.CheckSignalReceived();
6606 int UtcDaliAnimationAnimateBetweenActorColor(void)
6608 TestApplication application;
6610 float startValue(1.0f);
6611 Actor actor = Actor::New();
6612 actor.SetColor(Vector4(startValue, startValue, startValue, startValue));
6613 Stage::GetCurrent().Add(actor);
6615 DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
6616 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
6617 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
6618 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
6619 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), startValue, TEST_LOCATION );
6621 // Build the animation
6622 float durationSeconds(1.0f);
6623 Animation animation = Animation::New(durationSeconds);
6625 KeyFrames keyFrames = KeyFrames::New();
6626 keyFrames.Add(0.0f, Vector4(0.1f, 0.2f, 0.3f, 0.4f));
6627 keyFrames.Add(0.5f, Vector4(0.9f, 0.8f, 0.7f, 0.6f));
6628 keyFrames.Add(1.0f, Vector4(1.0f, 1.0f, 1.0f, 1.0f));
6630 animation.AnimateBetween( Property(actor, Actor::COLOR), keyFrames );
6632 // Start the animation
6635 bool signalReceived(false);
6636 AnimationFinishCheck finishCheck(signalReceived);
6637 animation.FinishedSignal().Connect(&application, finishCheck);
6638 application.SendNotification();
6639 application.Render(0);
6640 application.SendNotification();
6641 finishCheck.CheckSignalNotReceived();
6642 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), 0.1f, 0.01f, TEST_LOCATION );
6643 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 0.2f, 0.01f, TEST_LOCATION );
6644 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), 0.3f, 0.01f, TEST_LOCATION );
6645 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.4f, 0.01f, TEST_LOCATION );
6647 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
6648 application.SendNotification();
6649 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), 0.5f, 0.01f, TEST_LOCATION );
6650 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 0.5f, 0.01f, TEST_LOCATION );
6651 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), 0.5f, 0.01f, TEST_LOCATION );
6652 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.5f, 0.01f, TEST_LOCATION );
6654 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
6655 application.SendNotification();
6656 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), 0.9f, 0.01f, TEST_LOCATION );
6657 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 0.8f, 0.01f, TEST_LOCATION );
6658 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), 0.7f, 0.01f, TEST_LOCATION );
6659 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.6f, 0.01f, TEST_LOCATION );
6661 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
6662 application.SendNotification();
6663 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), 0.95f, 0.01f, TEST_LOCATION );
6664 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 0.90f, 0.01f, TEST_LOCATION );
6665 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), 0.85f, 0.01f, TEST_LOCATION );
6666 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.80f, 0.01f, TEST_LOCATION );
6668 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
6669 application.SendNotification();
6670 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), 1.0f, 0.01f, TEST_LOCATION );
6671 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 1.0f, 0.01f, TEST_LOCATION );
6672 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), 1.0f, 0.01f, TEST_LOCATION );
6673 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 1.0f, 0.01f, TEST_LOCATION );
6675 // We did expect the animation to finish
6677 finishCheck.CheckSignalReceived();
6681 int UtcDaliAnimationAnimateBetweenActorVisible01(void)
6683 TestApplication application;
6685 Actor actor = Actor::New();
6686 AngleAxis aa(Degree(90), Vector3::XAXIS);
6687 actor.SetRotation(aa.angle, aa.axis);
6688 Stage::GetCurrent().Add(actor);
6690 application.SendNotification();
6691 application.Render(0);
6693 DALI_TEST_EQUALS( actor.IsVisible(), true, TEST_LOCATION );
6695 // Build the animation
6696 float durationSeconds(1.0f);
6697 Animation animation = Animation::New(durationSeconds);
6699 KeyFrames keyFrames = KeyFrames::New();
6700 keyFrames.Add(0.0f, false);
6701 keyFrames.Add(0.2f, true);
6702 keyFrames.Add(0.4f, true);
6703 keyFrames.Add(0.8f, false);
6704 keyFrames.Add(1.0f, true);
6706 animation.AnimateBetween( Property(actor, Actor::VISIBLE), keyFrames );
6708 // Start the animation
6711 bool signalReceived(false);
6712 AnimationFinishCheck finishCheck(signalReceived);
6713 animation.FinishedSignal().Connect(&application, finishCheck);
6714 application.SendNotification();
6715 application.SendNotification();
6716 application.Render(static_cast<unsigned int>(durationSeconds*500.0f));
6717 application.SendNotification();
6718 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)+1);
6719 application.SendNotification();
6721 DALI_TEST_EQUALS( actor.IsVisible(), true, TEST_LOCATION);
6722 finishCheck.CheckSignalReceived();
6726 int UtcDaliAnimationAnimateBetweenActorRotation01(void)
6728 TestApplication application;
6730 Actor actor = Actor::New();
6731 AngleAxis aa(Degree(90), Vector3::XAXIS);
6732 actor.SetRotation(aa.angle, aa.axis);
6733 Stage::GetCurrent().Add(actor);
6735 application.SendNotification();
6736 application.Render(0);
6737 Quaternion start(Radian(aa.angle), aa.axis);
6738 DALI_TEST_EQUALS( actor.GetCurrentRotation(), start, 0.001f, TEST_LOCATION );
6740 // Build the animation
6741 float durationSeconds(1.0f);
6742 Animation animation = Animation::New(durationSeconds);
6744 KeyFrames keyFrames = KeyFrames::New();
6745 keyFrames.Add(0.0f, AngleAxis(Degree(60), Vector3::ZAXIS));
6747 animation.AnimateBetween( Property(actor, Actor::ROTATION), keyFrames );
6749 // Start the animation
6752 bool signalReceived(false);
6753 AnimationFinishCheck finishCheck(signalReceived);
6754 animation.FinishedSignal().Connect(&application, finishCheck);
6755 application.SendNotification();
6756 application.SendNotification();
6757 application.Render(static_cast<unsigned int>(durationSeconds*500.0f));
6758 application.SendNotification();
6759 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)+1);
6760 application.SendNotification();
6762 Quaternion check = Quaternion::FromAxisAngle(Vector4::ZAXIS, Radian(Degree(60)));
6764 DALI_TEST_EQUALS( actor.GetCurrentRotation(), check, 0.001f, TEST_LOCATION );
6765 finishCheck.CheckSignalReceived();
6769 int UtcDaliAnimationAnimateBetweenActorRotation02(void)
6771 TestApplication application;
6773 Actor actor = Actor::New();
6774 AngleAxis aa(Degree(90), Vector3::XAXIS);
6775 actor.SetRotation(aa.angle, aa.axis);
6776 application.SendNotification();
6777 application.Render(0);
6778 Stage::GetCurrent().Add(actor);
6780 Quaternion start(Radian(aa.angle), aa.axis);
6781 DALI_TEST_EQUALS( actor.GetCurrentRotation(), start, 0.001f, TEST_LOCATION );
6783 // Build the animation
6784 float durationSeconds(1.0f);
6785 Animation animation = Animation::New(durationSeconds);
6787 KeyFrames keyFrames = KeyFrames::New();
6788 keyFrames.Add(0.0f, AngleAxis(Degree(60), Vector3::XAXIS));
6789 keyFrames.Add(0.5f, AngleAxis(Degree(120), Vector3::XAXIS));
6790 keyFrames.Add(1.0f, AngleAxis(Degree(120), Vector3::YAXIS));
6792 animation.AnimateBetween( Property(actor, Actor::ROTATION), keyFrames );
6794 // Start the animation
6797 bool signalReceived(false);
6798 AnimationFinishCheck finishCheck(signalReceived);
6799 animation.FinishedSignal().Connect(&application, finishCheck);
6800 application.SendNotification();
6801 application.Render(0);
6802 application.SendNotification();
6803 finishCheck.CheckSignalNotReceived();
6805 Quaternion check(Radian(Degree(60)), Vector3::XAXIS);
6806 DALI_TEST_EQUALS( actor.GetCurrentRotation(), check, 0.001f, TEST_LOCATION );
6808 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
6809 application.SendNotification();
6810 check = Quaternion::FromAxisAngle(Vector4::XAXIS, Radian(Degree(90)));
6811 DALI_TEST_EQUALS( actor.GetCurrentRotation(), check, 0.001f, TEST_LOCATION );
6813 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
6814 application.SendNotification();
6815 check = Quaternion::FromAxisAngle(Vector4::XAXIS, Radian(Degree(120)));
6816 DALI_TEST_EQUALS( actor.GetCurrentRotation(), check, 0.001f, TEST_LOCATION );
6818 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
6819 application.SendNotification();
6820 check = Quaternion::FromAxisAngle(Vector4(0.5f, 0.5f, 0.0f, 0.0f), Radian(Degree(101.5)));
6821 DALI_TEST_EQUALS( actor.GetCurrentRotation(), check, 0.001f, TEST_LOCATION );
6823 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
6824 application.SendNotification();
6825 check = Quaternion::FromAxisAngle(Vector4::YAXIS, Radian(Degree(120)));
6826 DALI_TEST_EQUALS( actor.GetCurrentRotation(), check, 0.001f, TEST_LOCATION );
6828 // We did expect the animation to finish
6830 finishCheck.CheckSignalReceived();
6834 int UtcDaliAnimationMoveByFloat3(void)
6836 TestApplication application;
6838 Actor actor = Actor::New();
6839 Vector3 startPosition(10.0f, 10.0f, 10.0f);
6840 actor.SetPosition(startPosition);
6841 Stage::GetCurrent().Add(actor);
6842 application.SendNotification();
6843 application.Render(0);
6844 DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION );
6846 // Build the animation
6847 float durationSeconds(1.0f);
6848 Animation animation = Animation::New(durationSeconds);
6849 Vector3 targetPosition(20.0f, 20.0f, 20.0f);
6850 Vector3 relativePosition(targetPosition - startPosition);
6851 animation.MoveBy(actor, relativePosition.x, relativePosition.y, relativePosition.z);
6853 Vector3 ninetyFivePercentProgress(startPosition + relativePosition*0.95f);
6855 // Start the animation
6858 bool signalReceived(false);
6859 AnimationFinishCheck finishCheck(signalReceived);
6860 animation.FinishedSignal().Connect(&application, finishCheck);
6862 application.SendNotification();
6863 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
6865 // We didn't expect the animation to finish yet
6866 application.SendNotification();
6867 finishCheck.CheckSignalNotReceived();
6868 DALI_TEST_EQUALS( actor.GetCurrentPosition(), ninetyFivePercentProgress, TEST_LOCATION );
6870 application.SendNotification();
6871 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
6873 // We did expect the animation to finish
6874 application.SendNotification();
6875 finishCheck.CheckSignalReceived();
6876 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
6880 int UtcDaliAnimationMoveByVector3Alpha(void)
6882 TestApplication application;
6884 Actor actor = Actor::New();
6885 Vector3 startPosition(10.0f, 10.0f, 10.0f);
6886 actor.SetPosition(startPosition);
6887 Stage::GetCurrent().Add(actor);
6888 application.SendNotification();
6889 application.Render(0);
6890 DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION );
6892 // Build the animation
6893 float durationSeconds(1.0f);
6894 Animation animation = Animation::New(durationSeconds);
6895 Vector3 targetPosition(20.0f, 20.0f, 20.0f);
6896 Vector3 relativePosition(targetPosition - startPosition);
6897 animation.MoveBy(actor, relativePosition, AlphaFunctions::EaseOut);
6899 Vector3 ninetyFivePercentProgress(startPosition + relativePosition*0.95f);
6901 // Start the animation
6904 bool signalReceived(false);
6905 AnimationFinishCheck finishCheck(signalReceived);
6906 animation.FinishedSignal().Connect(&application, finishCheck);
6908 application.SendNotification();
6909 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
6911 // We didn't expect the animation to finish yet
6912 application.SendNotification();
6913 finishCheck.CheckSignalNotReceived();
6915 // The position should have moved more, than with a linear alpha function
6916 Vector3 current(actor.GetCurrentPosition());
6917 DALI_TEST_CHECK( current.x > ninetyFivePercentProgress.x );
6918 DALI_TEST_CHECK( current.y > ninetyFivePercentProgress.y );
6919 DALI_TEST_CHECK( current.z > ninetyFivePercentProgress.z );
6921 application.SendNotification();
6922 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
6924 // We did expect the animation to finish
6925 application.SendNotification();
6926 finishCheck.CheckSignalReceived();
6927 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
6931 int UtcDaliAnimationMoveByVector3AlphaFloat2(void)
6933 TestApplication application;
6935 Actor actor = Actor::New();
6936 Vector3 startPosition(10.0f, 10.0f, 10.0f);
6937 actor.SetPosition(startPosition);
6938 Stage::GetCurrent().Add(actor);
6939 application.SendNotification();
6940 application.Render(0);
6941 DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION );
6943 // Build the animation
6944 float durationSeconds(1.0f);
6945 Animation animation = Animation::New(durationSeconds);
6946 Vector3 targetPosition(20.0f, 20.0f, 20.0f);
6947 Vector3 relativePosition(targetPosition - startPosition);
6949 animation.MoveBy(actor, relativePosition, AlphaFunctions::Linear, delay, durationSeconds - delay);
6951 Vector3 ninetyFivePercentProgress(startPosition + relativePosition*0.95f);
6953 // Start the animation
6956 bool signalReceived(false);
6957 AnimationFinishCheck finishCheck(signalReceived);
6958 animation.FinishedSignal().Connect(&application, finishCheck);
6960 application.SendNotification();
6961 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
6963 // We didn't expect the animation to finish yet
6964 application.SendNotification();
6965 finishCheck.CheckSignalNotReceived();
6966 DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION );
6968 application.SendNotification();
6969 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
6971 // We did expect the animation to finish
6972 application.SendNotification();
6973 finishCheck.CheckSignalReceived();
6974 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
6978 int UtcDaliAnimationMoveToFloat3(void)
6980 TestApplication application;
6982 Actor actor = Actor::New();
6983 Stage::GetCurrent().Add(actor);
6984 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
6986 // Build the animation
6987 float durationSeconds(1.0f);
6988 Animation animation = Animation::New(durationSeconds);
6989 Vector3 targetPosition(200.0f, 200.0f, 200.0f);
6990 animation.MoveTo(actor, targetPosition.x, targetPosition.y, targetPosition.z);
6992 Vector3 seventyFivePercentProgress(targetPosition * 0.75f);
6994 // Start the animation
6997 bool signalReceived(false);
6998 AnimationFinishCheck finishCheck(signalReceived);
6999 animation.FinishedSignal().Connect(&application, finishCheck);
7001 application.SendNotification();
7002 application.Render(static_cast<unsigned int>(durationSeconds*750.0f)/* 75% progress */);
7004 // We didn't expect the animation to finish yet
7005 application.SendNotification();
7006 finishCheck.CheckSignalNotReceived();
7007 DALI_TEST_EQUALS( actor.GetCurrentPosition(), seventyFivePercentProgress, TEST_LOCATION );
7009 application.SendNotification();
7010 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7012 // We did expect the animation to finish
7013 application.SendNotification();
7014 finishCheck.CheckSignalReceived();
7015 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
7019 int UtcDaliAnimationMoveToVector3Alpha(void)
7021 TestApplication application;
7023 Actor actor = Actor::New();
7024 Stage::GetCurrent().Add(actor);
7025 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
7027 // Build the animation
7028 float durationSeconds(1.0f);
7029 Animation animation = Animation::New(durationSeconds);
7030 Vector3 targetPosition(200.0f, 200.0f, 200.0f);
7031 animation.MoveTo(actor, targetPosition, AlphaFunctions::EaseIn);
7033 Vector3 seventyFivePercentProgress(targetPosition * 0.75f);
7035 // Start the animation
7038 bool signalReceived(false);
7039 AnimationFinishCheck finishCheck(signalReceived);
7040 animation.FinishedSignal().Connect(&application, finishCheck);
7042 application.SendNotification();
7043 application.Render(static_cast<unsigned int>(durationSeconds*750.0f)/* 75% progress */);
7045 // We didn't expect the animation to finish yet
7046 application.SendNotification();
7047 finishCheck.CheckSignalNotReceived();
7049 // The position should have moved less, than with a linear alpha function
7050 Vector3 current(actor.GetCurrentPosition());
7051 DALI_TEST_CHECK( current.x > Vector3::ZERO.x );
7052 DALI_TEST_CHECK( current.y > Vector3::ZERO.y );
7053 DALI_TEST_CHECK( current.z > Vector3::ZERO.z );
7054 DALI_TEST_CHECK( current.x < seventyFivePercentProgress.x );
7055 DALI_TEST_CHECK( current.y < seventyFivePercentProgress.y );
7056 DALI_TEST_CHECK( current.z < seventyFivePercentProgress.z );
7058 application.SendNotification();
7059 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7061 // We did expect the animation to finish
7062 application.SendNotification();
7063 finishCheck.CheckSignalReceived();
7064 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
7068 int UtcDaliAnimationMoveToVector3AlphaFloat2(void)
7070 TestApplication application;
7072 Actor actor = Actor::New();
7073 Stage::GetCurrent().Add(actor);
7074 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
7076 // Build the animation
7077 float durationSeconds(1.0f);
7078 Animation animation = Animation::New(durationSeconds);
7079 Vector3 targetPosition(200.0f, 200.0f, 200.0f);
7081 animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear, delay, durationSeconds - delay);
7083 Vector3 seventyFivePercentProgress(targetPosition * 0.75f);
7085 // Start the animation
7088 bool signalReceived(false);
7089 AnimationFinishCheck finishCheck(signalReceived);
7090 animation.FinishedSignal().Connect(&application, finishCheck);
7092 application.SendNotification();
7093 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
7095 // We didn't expect the animation to finish yet
7096 application.SendNotification();
7097 finishCheck.CheckSignalNotReceived();
7098 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
7100 application.SendNotification();
7101 application.Render(static_cast<unsigned int>(durationSeconds*500.0f*0.75)/* 7/8 animation progress, 3/4 animator progress */);
7103 // We didn't expect the animation to finish yet
7104 application.SendNotification();
7105 finishCheck.CheckSignalNotReceived();
7106 DALI_TEST_EQUALS( actor.GetCurrentPosition(), seventyFivePercentProgress, TEST_LOCATION );
7108 application.SendNotification();
7109 application.Render(static_cast<unsigned int>(durationSeconds*500.0f*0.25) + 1u/*just beyond the animation duration*/);
7111 // We did expect the animation to finish
7112 application.SendNotification();
7113 finishCheck.CheckSignalReceived();
7114 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
7118 int UtcDaliAnimationMove(void)
7120 TestApplication application;
7122 Actor actor = Actor::New();
7123 Vector3 initialPosition(Vector3::ZERO);
7124 DALI_TEST_EQUALS( actor.GetCurrentPosition(), initialPosition, TEST_LOCATION );
7125 Stage::GetCurrent().Add(actor);
7127 // Build the animation
7128 float durationSeconds(10.0f);
7129 Animation animation = Animation::New(durationSeconds);
7130 Vector3 targetPosition(200.0f, 200.0f, 200.0f);
7131 BounceFunc func(0.0f, 0.0f, -100.0f);
7132 animation.Move(actor, func, AlphaFunctions::Linear, 0.0f, durationSeconds);
7134 // Start the animation
7137 bool signalReceived(false);
7138 AnimationFinishCheck finishCheck(signalReceived);
7139 animation.FinishedSignal().Connect(&application, finishCheck);
7141 application.SendNotification();
7142 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7144 // We didn't expect the animation to finish yet
7145 application.SendNotification();
7146 finishCheck.CheckSignalNotReceived();
7147 DALI_TEST_EQUALS( actor.GetCurrentPosition(), func(0.25f, initialPosition), TEST_LOCATION );
7149 application.SendNotification();
7150 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7152 // We didn't expect the animation to finish yet
7153 application.SendNotification();
7154 finishCheck.CheckSignalNotReceived();
7155 DALI_TEST_EQUALS( actor.GetCurrentPosition(), func(0.5f, initialPosition), TEST_LOCATION );
7157 application.SendNotification();
7158 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7160 // We didn't expect the animation to finish yet
7161 application.SendNotification();
7162 finishCheck.CheckSignalNotReceived();
7163 DALI_TEST_EQUALS( actor.GetCurrentPosition(), func(0.75f, initialPosition), TEST_LOCATION );
7165 application.SendNotification();
7166 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7168 // We did expect the animation to finish
7169 application.SendNotification();
7170 finishCheck.CheckSignalReceived();
7171 DALI_TEST_EQUALS( actor.GetCurrentPosition(), initialPosition, TEST_LOCATION );
7175 int UtcDaliAnimationRotateByDegreeVector3(void)
7177 TestApplication application;
7179 Actor actor = Actor::New();
7180 actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
7181 Stage::GetCurrent().Add(actor);
7182 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7184 // Build the animation
7185 float durationSeconds(1.0f);
7186 Animation animation = Animation::New(durationSeconds);
7187 Degree relativeRotationDegrees(360.0f);
7188 Radian relativeRotationRadians(relativeRotationDegrees);
7189 animation.RotateBy(actor, relativeRotationDegrees/*Degree version*/, Vector3::YAXIS);
7191 // Start the animation
7194 bool signalReceived(false);
7195 AnimationFinishCheck finishCheck(signalReceived);
7196 animation.FinishedSignal().Connect(&application, finishCheck);
7198 application.SendNotification();
7199 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7201 // We didn't expect the animation to finish yet
7202 application.SendNotification();
7203 finishCheck.CheckSignalNotReceived();
7204 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * 0.25f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7206 application.SendNotification();
7207 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7209 // We didn't expect the animation to finish yet
7210 application.SendNotification();
7211 finishCheck.CheckSignalNotReceived();
7212 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * 0.5f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7214 application.SendNotification();
7215 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7217 // We didn't expect the animation to finish yet
7218 application.SendNotification();
7219 finishCheck.CheckSignalNotReceived();
7220 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * 0.75f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7222 application.SendNotification();
7223 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7225 // We did expect the animation to finish
7226 application.SendNotification();
7227 finishCheck.CheckSignalReceived();
7228 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7232 int UtcDaliAnimationRotateByRadianVector3(void)
7234 TestApplication application;
7236 Actor actor = Actor::New();
7237 actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
7238 Stage::GetCurrent().Add(actor);
7239 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7241 // Build the animation
7242 float durationSeconds(1.0f);
7243 Animation animation = Animation::New(durationSeconds);
7244 Degree relativeRotationDegrees(360.0f);
7245 Radian relativeRotationRadians(relativeRotationDegrees);
7246 animation.RotateBy(actor, relativeRotationRadians/*Radian version*/, Vector3::YAXIS);
7248 // Start the animation
7251 bool signalReceived(false);
7252 AnimationFinishCheck finishCheck(signalReceived);
7253 animation.FinishedSignal().Connect(&application, finishCheck);
7255 application.SendNotification();
7256 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7258 // We didn't expect the animation to finish yet
7259 application.SendNotification();
7260 finishCheck.CheckSignalNotReceived();
7261 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * 0.25f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7263 application.SendNotification();
7264 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7266 // We didn't expect the animation to finish yet
7267 application.SendNotification();
7268 finishCheck.CheckSignalNotReceived();
7269 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * 0.5f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7271 application.SendNotification();
7272 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7274 // We didn't expect the animation to finish yet
7275 application.SendNotification();
7276 finishCheck.CheckSignalNotReceived();
7277 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * 0.75f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7279 application.SendNotification();
7280 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7282 // We did expect the animation to finish
7283 application.SendNotification();
7284 finishCheck.CheckSignalReceived();
7285 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7289 int UtcDaliAnimationRotateByDegreeVector3Alpha(void)
7291 TestApplication application;
7293 Actor actor = Actor::New();
7294 actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
7295 Stage::GetCurrent().Add(actor);
7296 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7298 // Build the animation
7299 float durationSeconds(1.0f);
7300 Animation animation = Animation::New(durationSeconds);
7301 Degree relativeRotationDegrees(360.0f);
7302 Radian relativeRotationRadians(relativeRotationDegrees);
7303 animation.RotateBy(actor, relativeRotationDegrees/*Degree version*/, Vector3::YAXIS, AlphaFunctions::EaseIn);
7305 // Start the animation
7308 bool signalReceived(false);
7309 AnimationFinishCheck finishCheck(signalReceived);
7310 animation.FinishedSignal().Connect(&application, finishCheck);
7312 application.SendNotification();
7313 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7315 // We didn't expect the animation to finish yet
7316 application.SendNotification();
7317 finishCheck.CheckSignalNotReceived();
7318 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * AlphaFunctions::EaseIn(0.25f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7320 application.SendNotification();
7321 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7323 // We didn't expect the animation to finish yet
7324 application.SendNotification();
7325 finishCheck.CheckSignalNotReceived();
7326 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * AlphaFunctions::EaseIn(0.5f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7328 application.SendNotification();
7329 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7331 // We didn't expect the animation to finish yet
7332 application.SendNotification();
7333 finishCheck.CheckSignalNotReceived();
7334 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * AlphaFunctions::EaseIn(0.75f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7336 application.SendNotification();
7337 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7339 // We did expect the animation to finish
7340 application.SendNotification();
7341 finishCheck.CheckSignalReceived();
7342 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7346 int UtcDaliAnimationRotateByRadianVector3Alpha(void)
7348 TestApplication application;
7350 Actor actor = Actor::New();
7351 actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
7352 Stage::GetCurrent().Add(actor);
7353 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7355 // Build the animation
7356 float durationSeconds(1.0f);
7357 Animation animation = Animation::New(durationSeconds);
7358 Degree relativeRotationDegrees(360.0f);
7359 Radian relativeRotationRadians(relativeRotationDegrees);
7360 animation.RotateBy(actor, relativeRotationRadians/*Radian version*/, Vector3::YAXIS, AlphaFunctions::EaseIn);
7362 // Start the animation
7365 bool signalReceived(false);
7366 AnimationFinishCheck finishCheck(signalReceived);
7367 animation.FinishedSignal().Connect(&application, finishCheck);
7369 application.SendNotification();
7370 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7372 // We didn't expect the animation to finish yet
7373 application.SendNotification();
7374 finishCheck.CheckSignalNotReceived();
7375 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * AlphaFunctions::EaseIn(0.25f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7377 application.SendNotification();
7378 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7380 // We didn't expect the animation to finish yet
7381 application.SendNotification();
7382 finishCheck.CheckSignalNotReceived();
7383 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * AlphaFunctions::EaseIn(0.5f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7385 application.SendNotification();
7386 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7388 // We didn't expect the animation to finish yet
7389 application.SendNotification();
7390 finishCheck.CheckSignalNotReceived();
7391 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * AlphaFunctions::EaseIn(0.75f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7393 application.SendNotification();
7394 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7396 // We did expect the animation to finish
7397 application.SendNotification();
7398 finishCheck.CheckSignalReceived();
7399 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7403 int UtcDaliAnimationRotateByDegreeVector3AlphaFloat2(void)
7405 TestApplication application;
7407 Actor actor = Actor::New();
7408 actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
7409 Stage::GetCurrent().Add(actor);
7410 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7412 // Build the animation
7413 float durationSeconds(1.0f);
7414 Animation animation = Animation::New(durationSeconds);
7415 Degree relativeRotationDegrees(360.0f);
7416 Radian relativeRotationRadians(relativeRotationDegrees);
7418 animation.RotateBy(actor, relativeRotationDegrees/*Degree version*/, Vector3::YAXIS, AlphaFunctions::EaseIn, delay, durationSeconds - delay);
7420 // Start the animation
7423 bool signalReceived(false);
7424 AnimationFinishCheck finishCheck(signalReceived);
7425 animation.FinishedSignal().Connect(&application, finishCheck);
7427 application.SendNotification();
7428 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7430 // We didn't expect the animation to finish yet
7431 application.SendNotification();
7432 finishCheck.CheckSignalNotReceived();
7433 float progress = max(0.0f, 0.25f - delay) / (1.0f - delay);
7434 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7436 application.SendNotification();
7437 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7439 // We didn't expect the animation to finish yet
7440 application.SendNotification();
7441 finishCheck.CheckSignalNotReceived();
7442 progress = max(0.0f, 0.5f - delay) / (1.0f - delay);
7443 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7445 application.SendNotification();
7446 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7448 // We didn't expect the animation to finish yet
7449 application.SendNotification();
7450 finishCheck.CheckSignalNotReceived();
7451 progress = max(0.0f, 0.75f - delay) / (1.0f - delay);
7452 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7454 application.SendNotification();
7455 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7457 // We did expect the animation to finish
7458 application.SendNotification();
7459 finishCheck.CheckSignalReceived();
7460 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7465 int UtcDaliAnimationRotateByRadianVector3AlphaFloat2(void)
7467 TestApplication application;
7469 Actor actor = Actor::New();
7470 actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
7471 Stage::GetCurrent().Add(actor);
7472 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7474 // Build the animation
7475 float durationSeconds(1.0f);
7476 Animation animation = Animation::New(durationSeconds);
7477 Degree relativeRotationDegrees(360.0f);
7478 Radian relativeRotationRadians(relativeRotationDegrees);
7480 animation.RotateBy(actor, relativeRotationRadians/*Radian version*/, Vector3::YAXIS, AlphaFunctions::EaseIn, delay, durationSeconds - delay);
7482 // Start the animation
7485 bool signalReceived(false);
7486 AnimationFinishCheck finishCheck(signalReceived);
7487 animation.FinishedSignal().Connect(&application, finishCheck);
7489 application.SendNotification();
7490 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7492 // We didn't expect the animation to finish yet
7493 application.SendNotification();
7494 finishCheck.CheckSignalNotReceived();
7495 float progress = max(0.0f, 0.25f - delay) / (1.0f - delay);
7496 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7498 application.SendNotification();
7499 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7501 // We didn't expect the animation to finish yet
7502 application.SendNotification();
7503 finishCheck.CheckSignalNotReceived();
7504 progress = max(0.0f, 0.5f - delay) / (1.0f - delay);
7505 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7507 application.SendNotification();
7508 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7510 // We didn't expect the animation to finish yet
7511 application.SendNotification();
7512 finishCheck.CheckSignalNotReceived();
7513 progress = max(0.0f, 0.75f - delay) / (1.0f - delay);
7514 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7516 application.SendNotification();
7517 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7519 // We did expect the animation to finish
7520 application.SendNotification();
7521 finishCheck.CheckSignalReceived();
7522 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7526 int UtcDaliAnimationRotateToDegreeVector3(void)
7528 TestApplication application;
7530 Actor actor = Actor::New();
7531 actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
7532 Stage::GetCurrent().Add(actor);
7533 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7535 // Build the animation
7536 float durationSeconds(1.0f);
7537 Animation animation = Animation::New(durationSeconds);
7538 Degree targetRotationDegrees(90.0f);
7539 Radian targetRotationRadians(targetRotationDegrees);
7540 animation.RotateTo(actor, targetRotationDegrees/*Degree version*/, Vector3::YAXIS);
7542 // Start the animation
7545 bool signalReceived(false);
7546 AnimationFinishCheck finishCheck(signalReceived);
7547 animation.FinishedSignal().Connect(&application, finishCheck);
7549 application.SendNotification();
7550 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7552 // We didn't expect the animation to finish yet
7553 application.SendNotification();
7554 finishCheck.CheckSignalNotReceived();
7555 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.25f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7557 application.SendNotification();
7558 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7560 // We didn't expect the animation to finish yet
7561 application.SendNotification();
7562 finishCheck.CheckSignalNotReceived();
7563 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.5f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7565 application.SendNotification();
7566 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7568 // We didn't expect the animation to finish yet
7569 application.SendNotification();
7570 finishCheck.CheckSignalNotReceived();
7571 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.75f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7573 application.SendNotification();
7574 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7576 // We did expect the animation to finish
7577 application.SendNotification();
7578 finishCheck.CheckSignalReceived();
7579 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7583 int UtcDaliAnimationRotateToRadianVector3(void)
7585 TestApplication application;
7587 Actor actor = Actor::New();
7588 actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
7589 Stage::GetCurrent().Add(actor);
7590 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7592 // Build the animation
7593 float durationSeconds(1.0f);
7594 Animation animation = Animation::New(durationSeconds);
7595 Degree targetRotationDegrees(90.0f);
7596 Radian targetRotationRadians(targetRotationDegrees);
7597 animation.RotateTo(actor, targetRotationRadians/*Radian version*/, Vector3::YAXIS);
7599 // Start the animation
7602 bool signalReceived(false);
7603 AnimationFinishCheck finishCheck(signalReceived);
7604 animation.FinishedSignal().Connect(&application, finishCheck);
7606 application.SendNotification();
7607 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7609 // We didn't expect the animation to finish yet
7610 application.SendNotification();
7611 finishCheck.CheckSignalNotReceived();
7612 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.25f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7614 application.SendNotification();
7615 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7617 // We didn't expect the animation to finish yet
7618 application.SendNotification();
7619 finishCheck.CheckSignalNotReceived();
7620 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.5f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7622 application.SendNotification();
7623 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7625 // We didn't expect the animation to finish yet
7626 application.SendNotification();
7627 finishCheck.CheckSignalNotReceived();
7628 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.75f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7630 application.SendNotification();
7631 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7633 // We did expect the animation to finish
7634 application.SendNotification();
7635 finishCheck.CheckSignalReceived();
7636 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7640 int UtcDaliAnimationRotateToQuaternion(void)
7642 TestApplication application;
7644 Actor actor = Actor::New();
7645 actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
7646 Stage::GetCurrent().Add(actor);
7647 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7649 // Build the animation
7650 float durationSeconds(1.0f);
7651 Animation animation = Animation::New(durationSeconds);
7652 Degree targetRotationDegrees(90.0f);
7653 Radian targetRotationRadians(targetRotationDegrees);
7654 Quaternion targetRotation(targetRotationRadians, Vector3::YAXIS);
7655 animation.RotateTo(actor, targetRotation/*Quaternion version*/);
7657 // Start the animation
7660 bool signalReceived(false);
7661 AnimationFinishCheck finishCheck(signalReceived);
7662 animation.FinishedSignal().Connect(&application, finishCheck);
7664 application.SendNotification();
7665 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7667 // We didn't expect the animation to finish yet
7668 application.SendNotification();
7669 finishCheck.CheckSignalNotReceived();
7670 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.25f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7672 application.SendNotification();
7673 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7675 // We didn't expect the animation to finish yet
7676 application.SendNotification();
7677 finishCheck.CheckSignalNotReceived();
7678 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.5f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7680 application.SendNotification();
7681 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7683 // We didn't expect the animation to finish yet
7684 application.SendNotification();
7685 finishCheck.CheckSignalNotReceived();
7686 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.75f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7688 application.SendNotification();
7689 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7691 // We did expect the animation to finish
7692 application.SendNotification();
7693 finishCheck.CheckSignalReceived();
7694 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7698 int UtcDaliAnimationRotateToDegreeVector3Alpha(void)
7700 TestApplication application;
7702 Actor actor = Actor::New();
7703 actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
7704 Stage::GetCurrent().Add(actor);
7705 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7707 // Build the animation
7708 float durationSeconds(1.0f);
7709 Animation animation = Animation::New(durationSeconds);
7710 Degree targetRotationDegrees(90.0f);
7711 Radian targetRotationRadians(targetRotationDegrees);
7712 animation.RotateTo(actor, targetRotationDegrees/*Degree version*/, Vector3::YAXIS, AlphaFunctions::EaseIn);
7714 // Start the animation
7717 bool signalReceived(false);
7718 AnimationFinishCheck finishCheck(signalReceived);
7719 animation.FinishedSignal().Connect(&application, finishCheck);
7721 application.SendNotification();
7722 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7724 // We didn't expect the animation to finish yet
7725 application.SendNotification();
7726 finishCheck.CheckSignalNotReceived();
7727 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(0.25f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7729 application.SendNotification();
7730 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7732 // We didn't expect the animation to finish yet
7733 application.SendNotification();
7734 finishCheck.CheckSignalNotReceived();
7735 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(0.5f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7737 application.SendNotification();
7738 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7740 // We didn't expect the animation to finish yet
7741 application.SendNotification();
7742 finishCheck.CheckSignalNotReceived();
7743 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(0.75f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7745 application.SendNotification();
7746 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7748 // We did expect the animation to finish
7749 application.SendNotification();
7750 finishCheck.CheckSignalReceived();
7751 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7755 int UtcDaliAnimationRotateToRadianVector3Alpha(void)
7757 TestApplication application;
7759 Actor actor = Actor::New();
7760 actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
7761 Stage::GetCurrent().Add(actor);
7762 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7764 // Build the animation
7765 float durationSeconds(1.0f);
7766 Animation animation = Animation::New(durationSeconds);
7767 Degree targetRotationDegrees(90.0f);
7768 Radian targetRotationRadians(targetRotationDegrees);
7769 animation.RotateTo(actor, targetRotationRadians/*Radian version*/, Vector3::YAXIS, AlphaFunctions::EaseIn);
7771 // Start the animation
7774 bool signalReceived(false);
7775 AnimationFinishCheck finishCheck(signalReceived);
7776 animation.FinishedSignal().Connect(&application, finishCheck);
7778 application.SendNotification();
7779 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7781 // We didn't expect the animation to finish yet
7782 application.SendNotification();
7783 finishCheck.CheckSignalNotReceived();
7784 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(0.25f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7786 application.SendNotification();
7787 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7789 // We didn't expect the animation to finish yet
7790 application.SendNotification();
7791 finishCheck.CheckSignalNotReceived();
7792 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(0.5f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7794 application.SendNotification();
7795 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7797 // We didn't expect the animation to finish yet
7798 application.SendNotification();
7799 finishCheck.CheckSignalNotReceived();
7800 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(0.75f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7802 application.SendNotification();
7803 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7805 // We did expect the animation to finish
7806 application.SendNotification();
7807 finishCheck.CheckSignalReceived();
7808 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7812 int UtcDaliAnimationRotateToQuaternionAlpha(void)
7814 TestApplication application;
7816 Actor actor = Actor::New();
7817 actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
7818 Stage::GetCurrent().Add(actor);
7819 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7821 // Build the animation
7822 float durationSeconds(1.0f);
7823 Animation animation = Animation::New(durationSeconds);
7824 Degree targetRotationDegrees(90.0f);
7825 Radian targetRotationRadians(targetRotationDegrees);
7826 Quaternion targetRotation(targetRotationRadians, Vector3::YAXIS);
7827 animation.RotateTo(actor, targetRotation/*Quaternion version*/, AlphaFunctions::EaseIn);
7829 // Start the animation
7832 bool signalReceived(false);
7833 AnimationFinishCheck finishCheck(signalReceived);
7834 animation.FinishedSignal().Connect(&application, finishCheck);
7836 application.SendNotification();
7837 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7839 // We didn't expect the animation to finish yet
7840 application.SendNotification();
7841 finishCheck.CheckSignalNotReceived();
7842 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(0.25f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7844 application.SendNotification();
7845 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7847 // We didn't expect the animation to finish yet
7848 application.SendNotification();
7849 finishCheck.CheckSignalNotReceived();
7850 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(0.5f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7852 application.SendNotification();
7853 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7855 // We didn't expect the animation to finish yet
7856 application.SendNotification();
7857 finishCheck.CheckSignalNotReceived();
7858 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(0.75f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7860 application.SendNotification();
7861 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7863 // We did expect the animation to finish
7864 application.SendNotification();
7865 finishCheck.CheckSignalReceived();
7866 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7870 int UtcDaliAnimationRotateToDegreeVector3AlphaFloat2(void)
7872 TestApplication application;
7874 Actor actor = Actor::New();
7875 actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
7876 Stage::GetCurrent().Add(actor);
7877 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7879 // Build the animation
7880 float durationSeconds(1.0f);
7881 Animation animation = Animation::New(durationSeconds);
7882 Degree targetRotationDegrees(90.0f);
7883 Radian targetRotationRadians(targetRotationDegrees);
7885 animation.RotateTo(actor, targetRotationDegrees/*Degree version*/, Vector3::YAXIS, AlphaFunctions::EaseIn, delay, durationSeconds - delay);
7887 // Start the animation
7890 bool signalReceived(false);
7891 AnimationFinishCheck finishCheck(signalReceived);
7892 animation.FinishedSignal().Connect(&application, finishCheck);
7894 application.SendNotification();
7895 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7897 // We didn't expect the animation to finish yet
7898 application.SendNotification();
7899 finishCheck.CheckSignalNotReceived();
7900 float progress = max(0.0f, 0.25f - delay) / (1.0f - delay);
7901 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7903 application.SendNotification();
7904 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7906 // We didn't expect the animation to finish yet
7907 application.SendNotification();
7908 finishCheck.CheckSignalNotReceived();
7909 progress = max(0.0f, 0.5f - delay) / (1.0f - delay);
7910 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7912 application.SendNotification();
7913 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7915 // We didn't expect the animation to finish yet
7916 application.SendNotification();
7917 finishCheck.CheckSignalNotReceived();
7918 progress = max(0.0f, 0.75f - delay) / (1.0f - delay);
7919 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7921 application.SendNotification();
7922 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7924 // We did expect the animation to finish
7925 application.SendNotification();
7926 finishCheck.CheckSignalReceived();
7927 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7931 int UtcDaliAnimationRotateToRadianVector3AlphaFloat2(void)
7933 TestApplication application;
7935 Actor actor = Actor::New();
7936 actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
7937 Stage::GetCurrent().Add(actor);
7938 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7940 // Build the animation
7941 float durationSeconds(1.0f);
7942 Animation animation = Animation::New(durationSeconds);
7943 Degree targetRotationDegrees(90.0f);
7944 Radian targetRotationRadians(targetRotationDegrees);
7946 animation.RotateTo(actor, targetRotationRadians/*Radian version*/, Vector3::YAXIS, AlphaFunctions::EaseIn, delay, durationSeconds - delay);
7948 // Start the animation
7951 bool signalReceived(false);
7952 AnimationFinishCheck finishCheck(signalReceived);
7953 animation.FinishedSignal().Connect(&application, finishCheck);
7955 application.SendNotification();
7956 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7958 // We didn't expect the animation to finish yet
7959 application.SendNotification();
7960 finishCheck.CheckSignalNotReceived();
7961 float progress = max(0.0f, 0.25f - delay) / (1.0f - delay);
7962 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7964 application.SendNotification();
7965 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7967 // We didn't expect the animation to finish yet
7968 application.SendNotification();
7969 finishCheck.CheckSignalNotReceived();
7970 progress = max(0.0f, 0.5f - delay) / (1.0f - delay);
7971 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7973 application.SendNotification();
7974 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7976 // We didn't expect the animation to finish yet
7977 application.SendNotification();
7978 finishCheck.CheckSignalNotReceived();
7979 progress = max(0.0f, 0.75f - delay) / (1.0f - delay);
7980 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7982 application.SendNotification();
7983 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7985 // We did expect the animation to finish
7986 application.SendNotification();
7987 finishCheck.CheckSignalReceived();
7988 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7992 int UtcDaliAnimationRotateToQuaternionAlphaFloat2(void)
7994 TestApplication application;
7996 Actor actor = Actor::New();
7997 actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
7998 Stage::GetCurrent().Add(actor);
7999 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
8001 // Build the animation
8002 float durationSeconds(1.0f);
8003 Animation animation = Animation::New(durationSeconds);
8004 Degree targetRotationDegrees(90.0f);
8005 Radian targetRotationRadians(targetRotationDegrees);
8007 Quaternion targetRotation(targetRotationRadians, Vector3::YAXIS);
8008 animation.RotateTo(actor, targetRotation/*Quaternion version*/, AlphaFunctions::EaseIn, delay, durationSeconds - delay);
8010 // Start the animation
8013 bool signalReceived(false);
8014 AnimationFinishCheck finishCheck(signalReceived);
8015 animation.FinishedSignal().Connect(&application, finishCheck);
8017 application.SendNotification();
8018 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
8020 // We didn't expect the animation to finish yet
8021 application.SendNotification();
8022 finishCheck.CheckSignalNotReceived();
8023 float progress = max(0.0f, 0.25f - delay) / (1.0f - delay);
8024 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
8026 application.SendNotification();
8027 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
8029 // We didn't expect the animation to finish yet
8030 application.SendNotification();
8031 finishCheck.CheckSignalNotReceived();
8032 progress = max(0.0f, 0.5f - delay) / (1.0f - delay);
8033 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
8035 application.SendNotification();
8036 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
8038 // We didn't expect the animation to finish yet
8039 application.SendNotification();
8040 finishCheck.CheckSignalNotReceived();
8041 progress = max(0.0f, 0.75f - delay) / (1.0f - delay);
8042 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
8044 application.SendNotification();
8045 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
8047 // We did expect the animation to finish
8048 application.SendNotification();
8049 finishCheck.CheckSignalReceived();
8050 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
8054 int UtcDaliAnimationRotate(void)
8056 TestApplication application;
8058 Actor actor = Actor::New();
8059 Quaternion initialRotation(0.0f, Vector3::YAXIS);
8060 actor.SetRotation(initialRotation);
8061 Stage::GetCurrent().Add(actor);
8062 DALI_TEST_EQUALS( actor.GetCurrentRotation(), initialRotation, ROTATION_EPSILON, TEST_LOCATION );
8064 // Build the animation
8065 float durationSeconds(1.0f);
8066 Animation animation = Animation::New(durationSeconds);
8067 TumbleFunc func(Vector3::YAXIS);
8068 animation.Rotate(actor, func, AlphaFunctions::Linear, 0.0f, durationSeconds);
8070 // Start the animation
8073 bool signalReceived(false);
8074 AnimationFinishCheck finishCheck(signalReceived);
8075 animation.FinishedSignal().Connect(&application, finishCheck);
8077 application.SendNotification();
8078 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
8080 // We didn't expect the animation to finish yet
8081 application.SendNotification();
8082 finishCheck.CheckSignalNotReceived();
8083 DALI_TEST_EQUALS( actor.GetCurrentRotation(), func(0.25f, initialRotation), ROTATION_EPSILON, TEST_LOCATION );
8085 application.SendNotification();
8086 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
8088 // We didn't expect the animation to finish yet
8089 application.SendNotification();
8090 finishCheck.CheckSignalNotReceived();
8091 DALI_TEST_EQUALS( actor.GetCurrentRotation(), func(0.5f, initialRotation), ROTATION_EPSILON, TEST_LOCATION );
8093 application.SendNotification();
8094 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
8096 // We didn't expect the animation to finish yet
8097 application.SendNotification();
8098 finishCheck.CheckSignalNotReceived();
8099 DALI_TEST_EQUALS( actor.GetCurrentRotation(), func(0.75f, initialRotation), ROTATION_EPSILON, TEST_LOCATION );
8101 application.SendNotification();
8102 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
8104 // We did expect the animation to finish
8105 application.SendNotification();
8106 finishCheck.CheckSignalReceived();
8107 DALI_TEST_EQUALS( actor.GetCurrentRotation(), func(1.0f, initialRotation), ROTATION_EPSILON, TEST_LOCATION );
8111 int UtcDaliAnimationScaleBy(void)
8113 TestApplication application;
8115 Actor actor = Actor::New();
8116 Stage::GetCurrent().Add(actor);
8117 DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
8119 // Build the animation
8120 float durationSeconds(1.0f);
8121 Animation animation = Animation::New(durationSeconds);
8122 Vector3 targetScale(2.0f, 2.0f, 2.0f);
8123 Vector3 relativeScale(targetScale - Vector3::ONE);
8124 animation.ScaleBy(actor, relativeScale.x, relativeScale.y, relativeScale.z);
8126 Vector3 ninetyNinePercentProgress(Vector3::ONE + relativeScale*0.99f);
8128 // Start the animation
8131 bool signalReceived(false);
8132 AnimationFinishCheck finishCheck(signalReceived);
8133 animation.FinishedSignal().Connect(&application, finishCheck);
8135 application.SendNotification();
8136 application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
8138 // We didn't expect the animation to finish yet
8139 application.SendNotification();
8140 finishCheck.CheckSignalNotReceived();
8141 DALI_TEST_EQUALS( actor.GetCurrentScale(), ninetyNinePercentProgress, TEST_LOCATION );
8143 application.SendNotification();
8144 application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
8146 // We did expect the animation to finish
8147 application.SendNotification();
8148 finishCheck.CheckSignalReceived();
8149 DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
8152 finishCheck.Reset();
8153 actor.SetScale(Vector3::ONE);
8154 application.SendNotification();
8155 application.Render(0);
8156 DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
8158 // Repeat with a different (ease-in) alpha function
8159 animation = Animation::New(durationSeconds);
8160 animation.ScaleBy(actor, relativeScale, AlphaFunctions::EaseIn);
8161 animation.FinishedSignal().Connect(&application, finishCheck);
8164 application.SendNotification();
8165 application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
8167 // We didn't expect the animation to finish yet
8168 application.SendNotification();
8169 finishCheck.CheckSignalNotReceived();
8171 // The scale should have grown less, than with a linear alpha function
8172 Vector3 current(actor.GetCurrentScale());
8173 DALI_TEST_CHECK( current.x > 1.0f );
8174 DALI_TEST_CHECK( current.y > 1.0f );
8175 DALI_TEST_CHECK( current.z > 1.0f );
8176 DALI_TEST_CHECK( current.x < ninetyNinePercentProgress.x );
8177 DALI_TEST_CHECK( current.y < ninetyNinePercentProgress.y );
8178 DALI_TEST_CHECK( current.z < ninetyNinePercentProgress.z );
8180 application.SendNotification();
8181 application.Render(static_cast<unsigned int>(durationSeconds*10.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 );
8189 finishCheck.Reset();
8190 actor.SetScale(Vector3::ONE);
8191 application.SendNotification();
8192 application.Render(0);
8193 DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
8195 // Repeat with a delay
8197 animation = Animation::New(durationSeconds);
8198 animation.ScaleBy(actor, relativeScale, AlphaFunctions::Linear, delay, durationSeconds - delay);
8199 animation.FinishedSignal().Connect(&application, finishCheck);
8202 application.SendNotification();
8203 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
8205 // We didn't expect the animation to finish yet
8206 application.SendNotification();
8207 finishCheck.CheckSignalNotReceived();
8208 DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
8210 application.SendNotification();
8211 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
8213 // We did expect the animation to finish
8214 application.SendNotification();
8215 finishCheck.CheckSignalReceived();
8216 DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
8220 int UtcDaliAnimationScaleTo(void)
8222 TestApplication application;
8224 Actor actor = Actor::New();
8225 Stage::GetCurrent().Add(actor);
8226 DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
8228 // Build the animation
8229 float durationSeconds(1.0f);
8230 Animation animation = Animation::New(durationSeconds);
8231 Vector3 targetScale(2.0f, 2.0f, 2.0f);
8232 animation.ScaleTo(actor, targetScale.x, targetScale.y, targetScale.z);
8234 Vector3 ninetyNinePercentProgress(Vector3::ONE + (targetScale - Vector3::ONE)*0.99f);
8236 // Start the animation
8239 bool signalReceived(false);
8240 AnimationFinishCheck finishCheck(signalReceived);
8241 animation.FinishedSignal().Connect(&application, finishCheck);
8243 application.SendNotification();
8244 application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
8246 // We didn't expect the animation to finish yet
8247 application.SendNotification();
8248 finishCheck.CheckSignalNotReceived();
8249 DALI_TEST_EQUALS( actor.GetCurrentScale(), ninetyNinePercentProgress, TEST_LOCATION );
8251 application.SendNotification();
8252 application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
8254 // We did expect the animation to finish
8255 application.SendNotification();
8256 finishCheck.CheckSignalReceived();
8257 DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
8260 finishCheck.Reset();
8261 actor.SetScale(Vector3::ONE);
8262 application.SendNotification();
8263 application.Render(0);
8264 DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
8266 // Repeat with a different (ease-in) alpha function
8267 animation = Animation::New(durationSeconds);
8268 animation.ScaleTo(actor, targetScale, AlphaFunctions::EaseIn);
8269 animation.FinishedSignal().Connect(&application, finishCheck);
8272 application.SendNotification();
8273 application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
8275 // We didn't expect the animation to finish yet
8276 application.SendNotification();
8277 finishCheck.CheckSignalNotReceived();
8279 // The scale should have grown less, than with a linear alpha function
8280 Vector3 current(actor.GetCurrentScale());
8281 DALI_TEST_CHECK( current.x > 1.0f );
8282 DALI_TEST_CHECK( current.y > 1.0f );
8283 DALI_TEST_CHECK( current.z > 1.0f );
8284 DALI_TEST_CHECK( current.x < ninetyNinePercentProgress.x );
8285 DALI_TEST_CHECK( current.y < ninetyNinePercentProgress.y );
8286 DALI_TEST_CHECK( current.z < ninetyNinePercentProgress.z );
8288 application.SendNotification();
8289 application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
8291 // We did expect the animation to finish
8292 application.SendNotification();
8293 finishCheck.CheckSignalReceived();
8294 DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
8297 finishCheck.Reset();
8298 actor.SetScale(Vector3::ONE);
8299 application.SendNotification();
8300 application.Render(0);
8301 DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
8303 // Repeat with a delay
8305 animation = Animation::New(durationSeconds);
8306 animation.ScaleTo(actor, targetScale, AlphaFunctions::Linear, delay, durationSeconds - delay);
8307 animation.FinishedSignal().Connect(&application, finishCheck);
8310 application.SendNotification();
8311 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
8313 // We didn't expect the animation to finish yet
8314 application.SendNotification();
8315 finishCheck.CheckSignalNotReceived();
8316 DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
8318 application.SendNotification();
8319 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
8321 // We did expect the animation to finish
8322 application.SendNotification();
8323 finishCheck.CheckSignalReceived();
8324 DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
8328 int UtcDaliAnimationShow(void)
8330 TestApplication application;
8332 Actor actor = Actor::New();
8333 actor.SetVisible(false);
8334 application.SendNotification();
8335 application.Render(0);
8336 DALI_TEST_CHECK( !actor.IsVisible() );
8337 Stage::GetCurrent().Add(actor);
8339 // Start the animation
8340 float durationSeconds(10.0f);
8341 Animation animation = Animation::New(durationSeconds);
8342 animation.Show(actor, durationSeconds*0.5f);
8345 bool signalReceived(false);
8346 AnimationFinishCheck finishCheck(signalReceived);
8347 animation.FinishedSignal().Connect(&application, finishCheck);
8349 application.SendNotification();
8350 application.Render(static_cast<unsigned int>(durationSeconds*490.0f));
8352 // We didn't expect the animation to finish yet
8353 application.SendNotification();
8354 finishCheck.CheckSignalNotReceived();
8355 DALI_TEST_CHECK( !actor.IsVisible() );
8357 application.SendNotification();
8358 application.Render(static_cast<unsigned int>(durationSeconds*10.0f)/*Should be shown now*/);
8360 // We didn't expect the animation to finish yet
8361 application.SendNotification();
8362 finishCheck.CheckSignalNotReceived();
8363 DALI_TEST_CHECK( actor.IsVisible() );
8365 application.SendNotification();
8366 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
8368 // We did expect the animation to finish
8369 application.SendNotification();
8370 finishCheck.CheckSignalReceived();
8371 DALI_TEST_CHECK( actor.IsVisible() );
8375 int UtcDaliAnimationHide(void)
8377 TestApplication application;
8379 Actor actor = Actor::New();
8380 DALI_TEST_CHECK( actor.IsVisible() );
8381 Stage::GetCurrent().Add(actor);
8383 // Start the animation
8384 float durationSeconds(10.0f);
8385 Animation animation = Animation::New(durationSeconds);
8386 animation.Hide(actor, durationSeconds*0.5f);
8389 bool signalReceived(false);
8390 AnimationFinishCheck finishCheck(signalReceived);
8391 animation.FinishedSignal().Connect(&application, finishCheck);
8393 application.SendNotification();
8394 application.Render(static_cast<unsigned int>(durationSeconds*490.0f));
8396 // We didn't expect the animation to finish yet
8397 application.SendNotification();
8398 finishCheck.CheckSignalNotReceived();
8399 DALI_TEST_CHECK( actor.IsVisible() );
8401 application.SendNotification();
8402 application.Render(static_cast<unsigned int>(durationSeconds*10.0f)/*Should be hidden now*/);
8404 // We didn't expect the animation to finish yet
8405 application.SendNotification();
8406 finishCheck.CheckSignalNotReceived();
8407 DALI_TEST_CHECK( !actor.IsVisible() );
8409 application.SendNotification();
8410 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
8412 // We did expect the animation to finish
8413 application.SendNotification();
8414 finishCheck.CheckSignalReceived();
8415 DALI_TEST_CHECK( !actor.IsVisible() );
8419 int UtcDaliAnimationShowHideAtEnd(void)
8421 // Test that show/hide delay can be the same as animation duration
8422 // i.e. to show/hide at the end of the animation
8424 TestApplication application;
8426 Actor actor = Actor::New();
8427 DALI_TEST_CHECK( actor.IsVisible() );
8428 Stage::GetCurrent().Add(actor);
8430 // Start Hide animation
8431 float durationSeconds(10.0f);
8432 Animation animation = Animation::New(durationSeconds);
8433 animation.Hide(actor, durationSeconds/*Hide at end*/);
8436 bool signalReceived(false);
8437 AnimationFinishCheck finishCheck(signalReceived);
8438 animation.FinishedSignal().Connect(&application, finishCheck);
8440 application.SendNotification();
8441 application.Render(static_cast<unsigned int>(durationSeconds*1000.0f) + 1u/*just beyond the animation duration*/);
8443 // We did expect the animation to finish
8444 application.SendNotification();
8445 finishCheck.CheckSignalReceived();
8446 DALI_TEST_CHECK( !actor.IsVisible() );
8448 // Start Show animation
8449 animation = Animation::New(durationSeconds);
8450 animation.Show(actor, durationSeconds/*Show at end*/);
8451 animation.FinishedSignal().Connect(&application, finishCheck);
8454 application.SendNotification();
8455 application.Render(static_cast<unsigned int>(durationSeconds*1000.0f) + 1u/*just beyond the animation duration*/);
8457 // We did expect the animation to finish
8458 application.SendNotification();
8459 finishCheck.CheckSignalReceived();
8460 DALI_TEST_CHECK( actor.IsVisible() );
8464 int UtcDaliAnimationOpacityBy(void)
8466 TestApplication application;
8467 Actor actor = Actor::New();
8468 float startingOpacity(0.5f);
8469 actor.SetOpacity(startingOpacity);
8470 application.SendNotification();
8471 application.Render(0);
8472 DALI_TEST_EQUALS( actor.GetCurrentOpacity(), startingOpacity, TEST_LOCATION );
8473 Stage::GetCurrent().Add(actor);
8475 // Build the animation
8476 float durationSeconds(1.0f);
8477 Animation animation = Animation::New(durationSeconds);
8478 float relativeOpacity(-0.5f); // target of zero
8479 animation.OpacityBy(actor, relativeOpacity);
8481 float seventyFivePercentProgress((1.0f - 0.75f) * startingOpacity);
8483 // Start the animation
8486 bool signalReceived(false);
8487 AnimationFinishCheck finishCheck(signalReceived);
8488 animation.FinishedSignal().Connect(&application, finishCheck);
8490 application.SendNotification();
8491 application.Render(static_cast<unsigned int>(durationSeconds*750.0f)/* 75% progress */);
8493 // We didn't expect the animation to finish yet
8494 application.SendNotification();
8495 finishCheck.CheckSignalNotReceived();
8496 DALI_TEST_EQUALS( actor.GetCurrentOpacity(), seventyFivePercentProgress, TEST_LOCATION );
8498 application.SendNotification();
8499 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
8501 // We did expect the animation to finish
8502 application.SendNotification();
8503 finishCheck.CheckSignalReceived();
8504 DALI_TEST_EQUALS( actor.GetCurrentOpacity(), startingOpacity+relativeOpacity, TEST_LOCATION );
8507 finishCheck.Reset();
8508 actor.SetOpacity(startingOpacity);
8509 application.SendNotification();
8510 application.Render(0);
8511 DALI_TEST_EQUALS( actor.GetCurrentOpacity(), startingOpacity, TEST_LOCATION );
8513 // Repeat with a different (ease-in) alpha function
8514 animation = Animation::New(durationSeconds);
8515 animation.OpacityBy(actor, relativeOpacity, AlphaFunctions::EaseIn);
8516 animation.FinishedSignal().Connect(&application, finishCheck);
8519 application.SendNotification();
8520 application.Render(static_cast<unsigned int>(durationSeconds*750.0f)/* 75% progress */);
8522 // We didn't expect the animation to finish yet
8523 application.SendNotification();
8524 finishCheck.CheckSignalNotReceived();
8526 // The opacity should reduce less, than with a linear alpha function
8527 float current(actor.GetCurrentOpacity());
8528 DALI_TEST_CHECK( current < 1.0f );
8529 DALI_TEST_CHECK( current > seventyFivePercentProgress );
8531 application.SendNotification();
8532 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
8534 // We did expect the animation to finish
8535 application.SendNotification();
8536 finishCheck.CheckSignalReceived();
8537 DALI_TEST_EQUALS( actor.GetCurrentOpacity(), startingOpacity+relativeOpacity, TEST_LOCATION );
8540 finishCheck.Reset();
8541 actor.SetOpacity(startingOpacity);
8542 application.SendNotification();
8543 application.Render(0);
8544 DALI_TEST_EQUALS( actor.GetCurrentOpacity(), startingOpacity, TEST_LOCATION );
8546 // Repeat with a delay
8548 animation = Animation::New(durationSeconds);
8549 animation.OpacityBy(actor, relativeOpacity, AlphaFunctions::Linear, delay, durationSeconds - delay);
8550 animation.FinishedSignal().Connect(&application, finishCheck);
8553 application.SendNotification();
8554 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
8556 // We didn't expect the animation to finish yet
8557 application.SendNotification();
8558 finishCheck.CheckSignalNotReceived();
8559 DALI_TEST_EQUALS( actor.GetCurrentOpacity(), startingOpacity, TEST_LOCATION );
8561 application.SendNotification();
8562 application.Render(static_cast<unsigned int>(durationSeconds*500.0f*0.75)/* 7/8 animation progress, 3/4 animator progress */);
8564 // We didn't expect the animation to finish yet
8565 application.SendNotification();
8566 finishCheck.CheckSignalNotReceived();
8567 DALI_TEST_EQUALS( actor.GetCurrentOpacity(), seventyFivePercentProgress, TEST_LOCATION );
8569 application.SendNotification();
8570 application.Render(static_cast<unsigned int>(durationSeconds*500.0f*0.25) + 1u/*just beyond the animation duration*/);
8572 // We did expect the animation to finish
8573 application.SendNotification();
8574 finishCheck.CheckSignalReceived();
8575 DALI_TEST_EQUALS( actor.GetCurrentOpacity(), startingOpacity+relativeOpacity, TEST_LOCATION );
8579 int UtcDaliAnimationOpacityTo(void)
8581 TestApplication application;
8583 Actor actor = Actor::New();
8584 Stage::GetCurrent().Add(actor);
8585 DALI_TEST_EQUALS( actor.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
8587 // Build the animation
8588 float durationSeconds(1.0f);
8589 Animation animation = Animation::New(durationSeconds);
8590 float targetOpacity(0.0f);
8591 animation.OpacityTo(actor, targetOpacity);
8593 float ninetyNinePercentProgress(0.01f);
8595 // Start the animation
8598 bool signalReceived(false);
8599 AnimationFinishCheck finishCheck(signalReceived);
8600 animation.FinishedSignal().Connect(&application, finishCheck);
8602 application.SendNotification();
8603 application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
8605 // We didn't expect the animation to finish yet
8606 application.SendNotification();
8607 finishCheck.CheckSignalNotReceived();
8608 DALI_TEST_EQUALS( actor.GetCurrentOpacity(), ninetyNinePercentProgress, 0.001f, TEST_LOCATION );
8610 application.SendNotification();
8611 application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
8613 // We did expect the animation to finish
8614 application.SendNotification();
8615 finishCheck.CheckSignalReceived();
8616 DALI_TEST_EQUALS( actor.GetCurrentOpacity(), targetOpacity, TEST_LOCATION );
8619 finishCheck.Reset();
8620 actor.SetOpacity(1.0f);
8621 application.SendNotification();
8622 application.Render(0);
8623 DALI_TEST_EQUALS( actor.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
8625 // Repeat with a different (ease-in) alpha function
8626 animation = Animation::New(durationSeconds);
8627 animation.OpacityTo(actor, targetOpacity, AlphaFunctions::EaseIn);
8628 animation.FinishedSignal().Connect(&application, finishCheck);
8631 application.SendNotification();
8632 application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
8634 // We didn't expect the animation to finish yet
8635 application.SendNotification();
8636 finishCheck.CheckSignalNotReceived();
8638 // The opacity should reduce less, than with a linear alpha function
8639 float current(actor.GetCurrentOpacity());
8640 DALI_TEST_CHECK( current < 1.0f );
8641 DALI_TEST_CHECK( current > ninetyNinePercentProgress );
8643 application.SendNotification();
8644 application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
8646 // We did expect the animation to finish
8647 application.SendNotification();
8648 finishCheck.CheckSignalReceived();
8649 DALI_TEST_EQUALS( actor.GetCurrentOpacity(), targetOpacity, TEST_LOCATION );
8652 finishCheck.Reset();
8653 actor.SetOpacity(1.0f);
8654 application.SendNotification();
8655 application.Render(0);
8656 DALI_TEST_EQUALS( actor.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
8658 // Repeat with a delay
8660 animation = Animation::New(durationSeconds);
8661 animation.OpacityTo(actor, targetOpacity, AlphaFunctions::Linear, delay, durationSeconds - delay);
8662 animation.FinishedSignal().Connect(&application, finishCheck);
8665 application.SendNotification();
8666 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
8668 // We didn't expect the animation to finish yet
8669 application.SendNotification();
8670 finishCheck.CheckSignalNotReceived();
8671 DALI_TEST_EQUALS( actor.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
8673 application.SendNotification();
8674 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
8676 // We did expect the animation to finish
8677 application.SendNotification();
8678 finishCheck.CheckSignalReceived();
8679 DALI_TEST_EQUALS( actor.GetCurrentOpacity(), targetOpacity, TEST_LOCATION );
8683 int UtcDaliAnimationColorBy(void)
8685 TestApplication application;
8687 Actor actor = Actor::New();
8688 actor.SetColor(Color::BLACK);
8689 application.SendNotification();
8690 application.Render(0);
8691 DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::BLACK, TEST_LOCATION );
8692 Stage::GetCurrent().Add(actor);
8694 // Build the animation
8695 float durationSeconds(1.0f);
8696 Animation animation = Animation::New(durationSeconds);
8697 Vector4 targetColor(Color::GREEN);
8698 Vector4 relativeColor(Color::GREEN); // Note the alpha is automatically clamped <= 1.0f in world color
8699 animation.ColorBy(actor, relativeColor);
8701 Vector4 tenPercentProgress(Vector4(0.0f, 0.1f, 0.0f, 1.0f));
8702 Vector4 twentyPercentProgress(Vector4(0.0f, 0.2f, 0.0f, 1.0f));
8704 // Start the animation
8707 bool signalReceived(false);
8708 AnimationFinishCheck finishCheck(signalReceived);
8709 animation.FinishedSignal().Connect(&application, finishCheck);
8711 application.SendNotification();
8712 application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% progress */);
8714 // We didn't expect the animation to finish yet
8715 application.SendNotification();
8716 finishCheck.CheckSignalNotReceived();
8717 DALI_TEST_EQUALS( actor.GetCurrentWorldColor(), tenPercentProgress, TEST_LOCATION );
8719 application.SendNotification();
8720 application.Render(static_cast<unsigned int>(durationSeconds*900.0f) + 1u/*just beyond the animation duration*/);
8722 // We did expect the animation to finish
8723 application.SendNotification();
8724 finishCheck.CheckSignalReceived();
8725 DALI_TEST_EQUALS( actor.GetCurrentWorldColor(), targetColor, TEST_LOCATION );
8728 finishCheck.Reset();
8729 actor.SetColor(Color::BLACK);
8730 application.SendNotification();
8731 application.Render(0);
8732 DALI_TEST_EQUALS( actor.GetCurrentWorldColor(), Color::BLACK, TEST_LOCATION );
8734 // Repeat with a different (ease-in) alpha function
8735 animation = Animation::New(durationSeconds);
8736 animation.ColorBy(actor, relativeColor, AlphaFunctions::EaseIn);
8737 animation.FinishedSignal().Connect(&application, finishCheck);
8740 application.SendNotification();
8741 application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% progress */);
8743 // We didn't expect the animation to finish yet
8744 application.SendNotification();
8745 finishCheck.CheckSignalNotReceived();
8747 // The color should have changed less, than with a linear alpha function
8748 Vector4 current(actor.GetCurrentWorldColor());
8749 DALI_TEST_CHECK( current.x == 0.0f ); // doesn't change
8750 DALI_TEST_CHECK( current.y > 0.0f );
8751 DALI_TEST_CHECK( current.y < tenPercentProgress.y );
8752 DALI_TEST_CHECK( current.z == 0.0f ); // doesn't change
8753 DALI_TEST_CHECK( current.w == 1.0f ); // doesn't change
8755 application.SendNotification();
8756 application.Render(static_cast<unsigned int>(durationSeconds*900.0f) + 1u/*just beyond the animation duration*/);
8758 // We did expect the animation to finish
8759 application.SendNotification();
8760 finishCheck.CheckSignalReceived();
8761 DALI_TEST_EQUALS( actor.GetCurrentWorldColor(), targetColor, TEST_LOCATION );
8764 finishCheck.Reset();
8765 actor.SetColor(Color::BLACK);
8766 application.SendNotification();
8767 application.Render(0);
8768 DALI_TEST_EQUALS( actor.GetCurrentWorldColor(), Color::BLACK, TEST_LOCATION );
8770 // Repeat with a shorter animator duration
8771 float animatorDuration = 0.5f;
8772 animation = Animation::New(durationSeconds);
8773 animation.ColorBy(actor, relativeColor, AlphaFunctions::Linear, 0, animatorDuration);
8774 animation.FinishedSignal().Connect(&application, finishCheck);
8777 application.SendNotification();
8778 application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% animation progress, 20% animator progress */);
8780 // We didn't expect the animation to finish yet
8781 application.SendNotification();
8782 finishCheck.CheckSignalNotReceived();
8783 DALI_TEST_EQUALS( actor.GetCurrentWorldColor(), twentyPercentProgress, TEST_LOCATION );
8785 application.SendNotification();
8786 application.Render(static_cast<unsigned int>(durationSeconds*400.0f)/* 50% animation progress, 100% animator progress */);
8788 // We didn't expect the animation to finish yet
8789 application.SendNotification();
8790 finishCheck.CheckSignalNotReceived();
8791 DALI_TEST_EQUALS( actor.GetCurrentWorldColor(), targetColor, TEST_LOCATION );
8793 application.SendNotification();
8794 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
8796 // We did expect the animation to finish
8797 application.SendNotification();
8798 finishCheck.CheckSignalReceived();
8799 DALI_TEST_EQUALS( actor.GetCurrentWorldColor(), targetColor, TEST_LOCATION );
8803 int UtcDaliAnimationColorTo(void)
8805 TestApplication application;
8807 Actor actor = Actor::New();
8808 Stage::GetCurrent().Add(actor);
8809 DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
8811 // Build the animation
8812 float durationSeconds(1.0f);
8813 Animation animation = Animation::New(durationSeconds);
8814 Vector4 targetColor(Color::RED);
8815 animation.ColorTo(actor, targetColor);
8817 Vector4 tenPercentProgress(Vector4(1.0f, 0.9f, 0.9f, 1.0f));
8818 Vector4 twentyPercentProgress(Vector4(1.0f, 0.8f, 0.8f, 1.0f));
8820 // Start the animation
8823 bool signalReceived(false);
8824 AnimationFinishCheck finishCheck(signalReceived);
8825 animation.FinishedSignal().Connect(&application, finishCheck);
8827 application.SendNotification();
8828 application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% progress */);
8830 // We didn't expect the animation to finish yet
8831 application.SendNotification();
8832 finishCheck.CheckSignalNotReceived();
8833 DALI_TEST_EQUALS( actor.GetCurrentColor(), tenPercentProgress, TEST_LOCATION );
8835 application.SendNotification();
8836 application.Render(static_cast<unsigned int>(durationSeconds*900.0f) + 1u/*just beyond the animation duration*/);
8838 // We did expect the animation to finish
8839 application.SendNotification();
8840 finishCheck.CheckSignalReceived();
8841 DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION );
8844 finishCheck.Reset();
8845 actor.SetColor(Color::WHITE);
8846 application.SendNotification();
8847 application.Render(0);
8848 DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
8850 // Repeat with a different (ease-in) alpha function
8851 animation = Animation::New(durationSeconds);
8852 animation.ColorTo(actor, targetColor, AlphaFunctions::EaseIn);
8853 animation.FinishedSignal().Connect(&application, finishCheck);
8856 application.SendNotification();
8857 application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% progress */);
8859 // We didn't expect the animation to finish yet
8860 application.SendNotification();
8861 finishCheck.CheckSignalNotReceived();
8863 // The color should have changed less, than with a linear alpha function
8864 Vector4 current(actor.GetCurrentColor());
8865 DALI_TEST_CHECK( current.x == 1.0f ); // doesn't change
8866 DALI_TEST_CHECK( current.y < 1.0f );
8867 DALI_TEST_CHECK( current.y > tenPercentProgress.y );
8868 DALI_TEST_CHECK( current.z < 1.0f );
8869 DALI_TEST_CHECK( current.z > tenPercentProgress.z );
8870 DALI_TEST_CHECK( current.w == 1.0f ); // doesn't change
8872 application.SendNotification();
8873 application.Render(static_cast<unsigned int>(durationSeconds*900.0f) + 1u/*just beyond the animation duration*/);
8875 // We did expect the animation to finish
8876 application.SendNotification();
8877 finishCheck.CheckSignalReceived();
8878 DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION );
8881 finishCheck.Reset();
8882 actor.SetColor(Color::WHITE);
8883 application.SendNotification();
8884 application.Render(0);
8885 DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
8887 // Repeat with a shorter animator duration
8888 float animatorDuration = 0.5f;
8889 animation = Animation::New(durationSeconds);
8890 animation.ColorTo(actor, targetColor, AlphaFunctions::Linear, 0, animatorDuration);
8891 animation.FinishedSignal().Connect(&application, finishCheck);
8894 application.SendNotification();
8895 application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% animation progress, 20% animator progress */);
8897 // We didn't expect the animation to finish yet
8898 application.SendNotification();
8899 finishCheck.CheckSignalNotReceived();
8900 DALI_TEST_EQUALS( actor.GetCurrentColor(), twentyPercentProgress, TEST_LOCATION );
8902 application.SendNotification();
8903 application.Render(static_cast<unsigned int>(durationSeconds*400.0f)/* 50% animation progress, 100% animator progress */);
8905 // We didn't expect the animation to finish yet
8906 application.SendNotification();
8907 finishCheck.CheckSignalNotReceived();
8908 DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION );
8910 application.SendNotification();
8911 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
8913 // We did expect the animation to finish
8914 application.SendNotification();
8915 finishCheck.CheckSignalReceived();
8916 DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION );
8920 int UtcDaliAnimationResize(void)
8922 TestApplication application;
8924 Actor actor = Actor::New();
8925 Stage::GetCurrent().Add(actor);
8926 DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
8928 // Build the animation
8929 float durationSeconds(1.0f);
8930 Animation animation = Animation::New(durationSeconds);
8931 Vector3 targetSize(100.0f, 100.0f, 100.0f);
8932 animation.Resize(actor, targetSize);
8934 Vector3 ninetyNinePercentProgress(targetSize * 0.99f);
8936 // Start the animation
8939 bool signalReceived(false);
8940 AnimationFinishCheck finishCheck(signalReceived);
8941 animation.FinishedSignal().Connect(&application, finishCheck);
8943 application.SendNotification();
8944 application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
8946 // We didn't expect the animation to finish yet
8947 application.SendNotification();
8948 finishCheck.CheckSignalNotReceived();
8949 DALI_TEST_EQUALS( actor.GetCurrentSize(), ninetyNinePercentProgress, TEST_LOCATION );
8951 application.SendNotification();
8952 application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
8954 // We did expect the animation to finish
8955 application.SendNotification();
8956 finishCheck.CheckSignalReceived();
8957 DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION );
8960 finishCheck.Reset();
8961 actor.SetSize(Vector3::ZERO);
8962 application.SendNotification();
8963 application.Render(0);
8964 DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
8966 // Repeat with a different (ease-in) alpha function
8967 animation = Animation::New(durationSeconds);
8968 animation.Resize(actor, targetSize, AlphaFunctions::EaseIn);
8969 animation.FinishedSignal().Connect(&application, finishCheck);
8972 application.SendNotification();
8973 application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
8975 // We didn't expect the animation to finish yet
8976 application.SendNotification();
8977 finishCheck.CheckSignalNotReceived();
8979 // The size should have travelled less, than with a linear alpha function
8980 Vector3 current(actor.GetCurrentSize());
8981 DALI_TEST_CHECK( current.x > 0.0f );
8982 DALI_TEST_CHECK( current.y > 0.0f );
8983 DALI_TEST_CHECK( current.z > 0.0f );
8984 DALI_TEST_CHECK( current.x < ninetyNinePercentProgress.x );
8985 DALI_TEST_CHECK( current.y < ninetyNinePercentProgress.y );
8986 DALI_TEST_CHECK( current.z < ninetyNinePercentProgress.z );
8988 application.SendNotification();
8989 application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
8991 // We did expect the animation to finish
8992 application.SendNotification();
8993 finishCheck.CheckSignalReceived();
8994 DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION );
8997 finishCheck.Reset();
8998 actor.SetSize(Vector3::ZERO);
8999 application.SendNotification();
9000 application.Render(0);
9001 DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
9003 // Repeat with a delay
9005 animation = Animation::New(durationSeconds);
9006 animation.Resize(actor, targetSize, AlphaFunctions::Linear, delay, durationSeconds - delay);
9007 animation.FinishedSignal().Connect(&application, finishCheck);
9010 application.SendNotification();
9011 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
9013 // We didn't expect the animation to finish yet
9014 application.SendNotification();
9015 finishCheck.CheckSignalNotReceived();
9016 DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
9018 application.SendNotification();
9019 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
9021 // We did expect the animation to finish
9022 application.SendNotification();
9023 finishCheck.CheckSignalReceived();
9024 DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION );
9028 int UtcDaliAnimationAnimateBool(void)
9030 TestApplication application;
9032 Actor actor = Actor::New();
9033 DALI_TEST_EQUALS( actor.IsVisible(), true, TEST_LOCATION );
9034 Stage::GetCurrent().Add(actor);
9036 // Build the animation
9037 float durationSeconds(10.0f);
9038 Animation animation = Animation::New(durationSeconds);
9039 animation.Animate<bool>( Property(actor, Actor::VISIBLE), ReturnFalseAfterProgressOne, TimePeriod(durationSeconds*0.25f/*delay*/, durationSeconds*0.1f) );
9041 // Start the animation
9044 bool signalReceived(false);
9045 AnimationFinishCheck finishCheck(signalReceived);
9046 animation.FinishedSignal().Connect(&application, finishCheck);
9048 application.SendNotification();
9049 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
9051 // We didn't expect the animation to finish yet
9052 application.SendNotification();
9053 finishCheck.CheckSignalNotReceived();
9055 // Should still be visible
9056 DALI_TEST_EQUALS( actor.IsVisible(), true, TEST_LOCATION );
9058 application.SendNotification();
9059 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
9061 // We didn't expect the animation to finish yet
9062 application.SendNotification();
9063 finishCheck.CheckSignalNotReceived();
9065 // Now animate functor should have hidden the actor
9066 DALI_TEST_EQUALS( actor.IsVisible(), false, TEST_LOCATION );
9068 application.SendNotification();
9069 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
9071 // We did expect the animation to finish
9072 application.SendNotification();
9073 finishCheck.CheckSignalReceived();
9074 DALI_TEST_EQUALS( actor.IsVisible(), false, TEST_LOCATION );
9078 int UtcDaliAnimationAnimateFloat(void)
9080 TestApplication application;
9082 Actor actor = Actor::New();
9083 Stage::GetCurrent().Add(actor);
9085 // Register a float property
9086 float startValue(10.0f);
9087 Property::Index index = actor.RegisterProperty( "test-property", startValue );
9088 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
9090 // Build the animation
9091 float durationSeconds(10.0f);
9092 Animation animation = Animation::New(durationSeconds);
9093 float targetPosition(0.0f);
9094 AnimateFloatTestFunctor func( 100, targetPosition );
9095 animation.Animate<float>( Property(actor, index), func );
9097 // Start the animation
9100 bool signalReceived(false);
9101 AnimationFinishCheck finishCheck(signalReceived);
9102 animation.FinishedSignal().Connect(&application, finishCheck);
9104 application.SendNotification();
9105 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
9107 // We didn't expect the animation to finish yet
9108 application.SendNotification();
9109 finishCheck.CheckSignalNotReceived();
9110 DALI_TEST_EQUALS( actor.GetProperty<float>(index), 75.0f, TEST_LOCATION );
9112 application.SendNotification();
9113 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
9115 // We didn't expect the animation to finish yet
9116 application.SendNotification();
9117 finishCheck.CheckSignalNotReceived();
9118 DALI_TEST_EQUALS( actor.GetProperty<float>(index), 50.0f, TEST_LOCATION );
9120 application.SendNotification();
9121 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
9123 // We didn't expect the animation to finish yet
9124 application.SendNotification();
9125 finishCheck.CheckSignalNotReceived();
9126 DALI_TEST_EQUALS( actor.GetProperty<float>(index), 25.0f, TEST_LOCATION );
9128 application.SendNotification();
9129 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
9131 // We did expect the animation to finish
9132 application.SendNotification();
9133 finishCheck.CheckSignalReceived();
9134 DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetPosition, TEST_LOCATION );
9138 int UtcDaliAnimationAnimateInteger(void)
9140 TestApplication application;
9142 Actor actor = Actor::New();
9143 Stage::GetCurrent().Add(actor);
9145 // Register an integer property
9147 Property::Index index = actor.RegisterProperty( "test-property", startValue );
9148 DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
9150 // Build the animation
9151 float durationSeconds(10.0f);
9152 Animation animation = Animation::New(durationSeconds);
9153 int targetPosition(0);
9154 AnimateIntegerTestFunctor func( 100, targetPosition );
9155 animation.Animate<int>( Property(actor, index), func );
9157 // Start the animation
9160 bool signalReceived(false);
9161 AnimationFinishCheck finishCheck(signalReceived);
9162 animation.FinishedSignal().Connect(&application, finishCheck);
9164 application.SendNotification();
9165 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
9167 // We didn't expect the animation to finish yet
9168 application.SendNotification();
9169 finishCheck.CheckSignalNotReceived();
9170 DALI_TEST_EQUALS( actor.GetProperty<int>(index), 75, TEST_LOCATION );
9172 application.SendNotification();
9173 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
9175 // We didn't expect the animation to finish yet
9176 application.SendNotification();
9177 finishCheck.CheckSignalNotReceived();
9178 DALI_TEST_EQUALS( actor.GetProperty<int>(index), 50, TEST_LOCATION );
9180 application.SendNotification();
9181 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
9183 // We didn't expect the animation to finish yet
9184 application.SendNotification();
9185 finishCheck.CheckSignalNotReceived();
9186 DALI_TEST_EQUALS( actor.GetProperty<int>(index), 25, TEST_LOCATION );
9188 application.SendNotification();
9189 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
9191 // We did expect the animation to finish
9192 application.SendNotification();
9193 finishCheck.CheckSignalReceived();
9194 DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetPosition, TEST_LOCATION );
9198 int UtcDaliAnimationAnimateVector2(void)
9200 TestApplication application;
9202 Actor actor = Actor::New();
9203 Stage::GetCurrent().Add(actor);
9205 // Register a Vector2 property
9206 Vector2 startValue(10.0f, 10.0f);
9207 Property::Index index = actor.RegisterProperty( "test-property", startValue );
9208 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
9210 // Build the animation
9211 float durationSeconds(10.0f);
9212 Animation animation = Animation::New(durationSeconds);
9213 Vector2 targetPosition(0.0f, 0.0f);
9214 AnimateVector2TestFunctor func( Vector2(100,100), targetPosition );
9215 animation.Animate<Vector2>( Property(actor, index), func );
9217 // Start the animation
9220 bool signalReceived(false);
9221 AnimationFinishCheck finishCheck(signalReceived);
9222 animation.FinishedSignal().Connect(&application, finishCheck);
9224 application.SendNotification();
9225 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
9227 // We didn't expect the animation to finish yet
9228 application.SendNotification();
9229 finishCheck.CheckSignalNotReceived();
9230 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), Vector2(75,75), TEST_LOCATION );
9232 application.SendNotification();
9233 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
9235 // We didn't expect the animation to finish yet
9236 application.SendNotification();
9237 finishCheck.CheckSignalNotReceived();
9238 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), Vector2(50,50), TEST_LOCATION );
9240 application.SendNotification();
9241 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
9243 // We didn't expect the animation to finish yet
9244 application.SendNotification();
9245 finishCheck.CheckSignalNotReceived();
9246 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), Vector2(25,25), TEST_LOCATION );
9248 application.SendNotification();
9249 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
9251 // We did expect the animation to finish
9252 application.SendNotification();
9253 finishCheck.CheckSignalReceived();
9254 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetPosition, TEST_LOCATION );
9258 int UtcDaliAnimationAnimateVector3(void)
9260 TestApplication application;
9262 Actor actor = Actor::New();
9263 Vector3 initialPosition(Vector3::ZERO);
9264 DALI_TEST_EQUALS( actor.GetCurrentPosition(), initialPosition, TEST_LOCATION );
9265 Stage::GetCurrent().Add(actor);
9267 // Build the animation
9268 float durationSeconds(10.0f);
9269 Animation animation = Animation::New(durationSeconds);
9270 Vector3 targetPosition(200.0f, 200.0f, 200.0f);
9271 BounceFunc func(0.0f, 0.0f, -100.0f);
9272 animation.Animate<Vector3>( Property(actor, Actor::POSITION), func, AlphaFunctions::Linear, durationSeconds );
9274 // Start the animation
9277 bool signalReceived(false);
9278 AnimationFinishCheck finishCheck(signalReceived);
9279 animation.FinishedSignal().Connect(&application, finishCheck);
9281 application.SendNotification();
9282 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
9284 // We didn't expect the animation to finish yet
9285 application.SendNotification();
9286 finishCheck.CheckSignalNotReceived();
9287 DALI_TEST_EQUALS( actor.GetCurrentPosition(), func(0.25f, initialPosition), TEST_LOCATION );
9289 application.SendNotification();
9290 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
9292 // We didn't expect the animation to finish yet
9293 application.SendNotification();
9294 finishCheck.CheckSignalNotReceived();
9295 DALI_TEST_EQUALS( actor.GetCurrentPosition(), func(0.5f, initialPosition), TEST_LOCATION );
9297 application.SendNotification();
9298 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
9300 // We didn't expect the animation to finish yet
9301 application.SendNotification();
9302 finishCheck.CheckSignalNotReceived();
9303 DALI_TEST_EQUALS( actor.GetCurrentPosition(), func(0.75f, initialPosition), TEST_LOCATION );
9305 application.SendNotification();
9306 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
9308 // We did expect the animation to finish
9309 application.SendNotification();
9310 finishCheck.CheckSignalReceived();
9311 DALI_TEST_EQUALS( actor.GetCurrentPosition(), initialPosition, TEST_LOCATION );
9315 int UtcDaliAnimationAnimateVector4(void)
9317 TestApplication application;
9319 Actor actor = Actor::New();
9320 Stage::GetCurrent().Add(actor);
9322 // Register a Vector4 property
9323 Vector4 startValue(10.0f, 10.0f, 10.0f, 10.0f);
9324 Property::Index index = actor.RegisterProperty( "test-property", startValue );
9325 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
9327 // Build the animation
9328 float durationSeconds(10.0f);
9329 Animation animation = Animation::New(durationSeconds);
9330 Vector4 targetPosition(200,400,0,-1000);
9331 AnimateVector4TestFunctor func( Vector4(1000,1000,1000,1000), targetPosition );
9332 animation.Animate<Vector4>( Property(actor, index), func );
9334 // Start the animation
9337 bool signalReceived(false);
9338 AnimationFinishCheck finishCheck(signalReceived);
9339 animation.FinishedSignal().Connect(&application, finishCheck);
9341 application.SendNotification();
9342 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
9344 // We didn't expect the animation to finish yet
9345 application.SendNotification();
9346 finishCheck.CheckSignalNotReceived();
9347 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), Vector4(800,850,750,500), TEST_LOCATION );
9349 application.SendNotification();
9350 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
9352 // We didn't expect the animation to finish yet
9353 application.SendNotification();
9354 finishCheck.CheckSignalNotReceived();
9355 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), Vector4(600,700,500,0), TEST_LOCATION );
9357 application.SendNotification();
9358 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
9360 // We didn't expect the animation to finish yet
9361 application.SendNotification();
9362 finishCheck.CheckSignalNotReceived();
9363 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), Vector4(400,550,250,-500), TEST_LOCATION );
9365 application.SendNotification();
9366 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
9368 // We did expect the animation to finish
9369 application.SendNotification();
9370 finishCheck.CheckSignalReceived();
9371 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetPosition, TEST_LOCATION );
9375 int UtcDaliAnimationAnimateQuaternion(void)
9377 TestApplication application;
9379 Actor actor = Actor::New();
9380 actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
9381 Stage::GetCurrent().Add(actor);
9382 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
9384 // Build the animation
9385 float durationSeconds(1.0f);
9386 Animation animation = Animation::New(durationSeconds);
9388 Degree sourceRotationDegrees(90.0f);
9389 Radian sourceRotationRadians(sourceRotationDegrees);
9390 Quaternion sourceRotation(sourceRotationRadians, Vector3::YAXIS);
9392 Degree targetRotationDegrees(150.0f);
9393 Radian targetRotationRadians(targetRotationDegrees);
9394 Quaternion targetRotation(targetRotationRadians, Vector3::YAXIS);
9396 AnimateQuaternionTestFunctor func( sourceRotation, targetRotation );
9397 animation.Animate<Quaternion>( Property(actor, Actor::ROTATION), func );
9399 // Start the animation
9402 bool signalReceived(false);
9403 AnimationFinishCheck finishCheck(signalReceived);
9404 animation.FinishedSignal().Connect(&application, finishCheck);
9406 application.SendNotification();
9407 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
9409 // We didn't expect the animation to finish yet
9410 application.SendNotification();
9411 finishCheck.CheckSignalNotReceived();
9412 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(Radian(Degree(105)), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
9414 application.SendNotification();
9415 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
9417 // We didn't expect the animation to finish yet
9418 application.SendNotification();
9419 finishCheck.CheckSignalNotReceived();
9420 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(Radian(Degree(120)), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
9422 application.SendNotification();
9423 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
9425 // We didn't expect the animation to finish yet
9426 application.SendNotification();
9427 finishCheck.CheckSignalNotReceived();
9428 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(Radian(Degree(135)), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
9430 application.SendNotification();
9431 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
9433 // We did expect the animation to finish
9434 application.SendNotification();
9435 finishCheck.CheckSignalReceived();
9436 DALI_TEST_EQUALS( actor.GetCurrentRotation(), targetRotation, ROTATION_EPSILON, TEST_LOCATION );
9440 int UtcDaliKeyFramesCreateDestroy(void)
9442 tet_infoline("Testing Dali::Animation::UtcDaliKeyFramesCreateDestroy()");
9444 KeyFrames* keyFrames = new KeyFrames;
9446 DALI_TEST_CHECK( true );
9450 int UtcDaliKeyFramesDownCast(void)
9452 TestApplication application;
9453 tet_infoline("Testing Dali::Animation::KeyFramesDownCast()");
9455 KeyFrames keyFrames = KeyFrames::New();
9456 BaseHandle object(keyFrames);
9458 KeyFrames keyFrames2 = KeyFrames::DownCast(object);
9459 DALI_TEST_CHECK(keyFrames2);
9461 KeyFrames keyFrames3 = DownCast< KeyFrames >(object);
9462 DALI_TEST_CHECK(keyFrames3);
9464 BaseHandle unInitializedObject;
9465 KeyFrames keyFrames4 = KeyFrames::DownCast(unInitializedObject);
9466 DALI_TEST_CHECK(!keyFrames4);
9468 KeyFrames keyFrames5 = DownCast< KeyFrames >(unInitializedObject);
9469 DALI_TEST_CHECK(!keyFrames5);
9473 int UtcDaliAnimationResizeByXY(void)
9475 TestApplication application;
9477 Actor actor = Actor::New();
9478 Stage::GetCurrent().Add(actor);
9479 DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
9481 // Build the animation
9482 float durationSeconds(1.0f);
9483 Animation animation = Animation::New(durationSeconds);
9484 Vector3 targetSize(100.0f, 100.0f, 100.0f);
9485 animation.Resize(actor, targetSize);
9487 Vector3 ninetyNinePercentProgress(targetSize * 0.99f);
9489 // Start the animation
9492 bool signalReceived(false);
9493 AnimationFinishCheck finishCheck(signalReceived);
9494 animation.FinishedSignal().Connect(&application, finishCheck);
9496 application.SendNotification();
9497 application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
9499 // We didn't expect the animation to finish yet
9500 application.SendNotification();
9501 finishCheck.CheckSignalNotReceived();
9502 DALI_TEST_EQUALS( actor.GetCurrentSize(), ninetyNinePercentProgress, TEST_LOCATION );
9504 application.SendNotification();
9505 application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
9507 // We did expect the animation to finish
9508 application.SendNotification();
9509 finishCheck.CheckSignalReceived();
9510 DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION );
9513 finishCheck.Reset();
9514 actor.SetSize(Vector3::ZERO);
9515 application.SendNotification();
9516 application.Render(0);
9517 DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
9519 // Repeat with a different (ease-in) alpha function
9520 animation = Animation::New(durationSeconds);
9521 animation.Resize(actor, targetSize.x, targetSize.y, AlphaFunctions::EaseIn);
9522 animation.FinishedSignal().Connect(&application, finishCheck);
9525 application.SendNotification();
9526 application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
9528 // We didn't expect the animation to finish yet
9529 application.SendNotification();
9530 finishCheck.CheckSignalNotReceived();
9532 // The size should have travelled less, than with a linear alpha function
9533 Vector3 current(actor.GetCurrentSize());
9534 DALI_TEST_CHECK( current.x > 0.0f );
9535 DALI_TEST_CHECK( current.y > 0.0f );
9536 DALI_TEST_CHECK( current.z > 0.0f );
9537 DALI_TEST_CHECK( current.x < ninetyNinePercentProgress.x );
9538 DALI_TEST_CHECK( current.y < ninetyNinePercentProgress.y );
9539 DALI_TEST_CHECK( current.z < ninetyNinePercentProgress.z );
9541 application.SendNotification();
9542 application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
9544 // We did expect the animation to finish
9545 application.SendNotification();
9546 finishCheck.CheckSignalReceived();
9547 DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION );
9550 finishCheck.Reset();
9551 actor.SetSize(Vector3::ZERO);
9552 application.SendNotification();
9553 application.Render(0);
9554 DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
9556 // Repeat with a delay
9558 animation = Animation::New(durationSeconds);
9559 animation.Resize(actor, targetSize.x, targetSize.y, AlphaFunctions::Linear, delay, durationSeconds - delay);
9560 animation.FinishedSignal().Connect(&application, finishCheck);
9563 application.SendNotification();
9564 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
9566 // We didn't expect the animation to finish yet
9567 application.SendNotification();
9568 finishCheck.CheckSignalNotReceived();
9569 DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
9571 application.SendNotification();
9572 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
9574 // We did expect the animation to finish
9575 application.SendNotification();
9576 finishCheck.CheckSignalReceived();
9577 DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION );
9582 int UtcDaliAnimationAnimateBetweenActorColorTimePeriod(void)
9584 TestApplication application;
9586 float startValue(1.0f);
9587 Actor actor = Actor::New();
9588 actor.SetColor(Vector4(startValue, startValue, startValue, startValue));
9589 Stage::GetCurrent().Add(actor);
9591 DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
9592 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
9593 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
9594 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
9595 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), startValue, TEST_LOCATION );
9597 // Build the animation
9598 float durationSeconds(1.0f);
9599 Animation animation = Animation::New(durationSeconds);
9601 KeyFrames keyFrames = KeyFrames::New();
9602 keyFrames.Add(0.0f, Vector4(0.1f, 0.2f, 0.3f, 0.4f));
9603 keyFrames.Add(0.5f, Vector4(0.9f, 0.8f, 0.7f, 0.6f));
9604 keyFrames.Add(1.0f, Vector4(1.0f, 1.0f, 1.0f, 1.0f));
9606 animation.AnimateBetween( Property(actor, Actor::COLOR), keyFrames, TimePeriod( 1.0f) );
9608 // Start the animation
9611 bool signalReceived(false);
9612 AnimationFinishCheck finishCheck(signalReceived);
9613 animation.FinishedSignal().Connect(&application, finishCheck);
9614 application.SendNotification();
9615 application.Render(0);
9616 application.SendNotification();
9617 finishCheck.CheckSignalNotReceived();
9618 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), 0.1f, 0.01f, TEST_LOCATION );
9619 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 0.2f, 0.01f, TEST_LOCATION );
9620 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), 0.3f, 0.01f, TEST_LOCATION );
9621 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.4f, 0.01f, TEST_LOCATION );
9623 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
9624 application.SendNotification();
9625 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), 0.5f, 0.01f, TEST_LOCATION );
9626 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 0.5f, 0.01f, TEST_LOCATION );
9627 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), 0.5f, 0.01f, TEST_LOCATION );
9628 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.5f, 0.01f, TEST_LOCATION );
9630 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
9631 application.SendNotification();
9632 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), 0.9f, 0.01f, TEST_LOCATION );
9633 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 0.8f, 0.01f, TEST_LOCATION );
9634 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), 0.7f, 0.01f, TEST_LOCATION );
9635 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.6f, 0.01f, TEST_LOCATION );
9637 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
9638 application.SendNotification();
9639 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), 0.95f, 0.01f, TEST_LOCATION );
9640 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 0.90f, 0.01f, TEST_LOCATION );
9641 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), 0.85f, 0.01f, TEST_LOCATION );
9642 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.80f, 0.01f, TEST_LOCATION );
9644 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
9645 application.SendNotification();
9646 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), 1.0f, 0.01f, TEST_LOCATION );
9647 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 1.0f, 0.01f, TEST_LOCATION );
9648 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), 1.0f, 0.01f, TEST_LOCATION );
9649 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 1.0f, 0.01f, TEST_LOCATION );
9651 // We did expect the animation to finish
9653 finishCheck.CheckSignalReceived();
9657 int UtcDaliAnimationAnimateBetweenActorColorFunction(void)
9659 TestApplication application;
9661 float startValue(1.0f);
9662 Actor actor = Actor::New();
9663 actor.SetColor(Vector4(startValue, startValue, startValue, startValue));
9664 Stage::GetCurrent().Add(actor);
9666 DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
9667 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
9668 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
9669 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
9670 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), startValue, TEST_LOCATION );
9672 // Build the animation
9673 float durationSeconds(1.0f);
9674 Animation animation = Animation::New(durationSeconds);
9676 KeyFrames keyFrames = KeyFrames::New();
9677 keyFrames.Add(0.0f, Vector4(0.1f, 0.2f, 0.3f, 0.4f));
9678 keyFrames.Add(0.5f, Vector4(0.9f, 0.8f, 0.7f, 0.6f));
9679 keyFrames.Add(1.0f, Vector4(1.0f, 1.0f, 1.0f, 1.0f));
9681 animation.AnimateBetween( Property(actor, Actor::COLOR), keyFrames, AlphaFunctions::Linear );
9683 // Start the animation
9686 bool signalReceived(false);
9687 AnimationFinishCheck finishCheck(signalReceived);
9688 animation.FinishedSignal().Connect(&application, finishCheck);
9689 application.SendNotification();
9690 application.Render(0);
9691 application.SendNotification();
9692 finishCheck.CheckSignalNotReceived();
9693 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), 0.1f, 0.01f, TEST_LOCATION );
9694 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 0.2f, 0.01f, TEST_LOCATION );
9695 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), 0.3f, 0.01f, TEST_LOCATION );
9696 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.4f, 0.01f, TEST_LOCATION );
9698 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
9699 application.SendNotification();
9700 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), 0.5f, 0.01f, TEST_LOCATION );
9701 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 0.5f, 0.01f, TEST_LOCATION );
9702 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), 0.5f, 0.01f, TEST_LOCATION );
9703 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.5f, 0.01f, TEST_LOCATION );
9705 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
9706 application.SendNotification();
9707 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), 0.9f, 0.01f, TEST_LOCATION );
9708 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 0.8f, 0.01f, TEST_LOCATION );
9709 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), 0.7f, 0.01f, TEST_LOCATION );
9710 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.6f, 0.01f, TEST_LOCATION );
9712 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
9713 application.SendNotification();
9714 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), 0.95f, 0.01f, TEST_LOCATION );
9715 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 0.90f, 0.01f, TEST_LOCATION );
9716 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), 0.85f, 0.01f, TEST_LOCATION );
9717 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.80f, 0.01f, TEST_LOCATION );
9719 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
9720 application.SendNotification();
9721 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), 1.0f, 0.01f, TEST_LOCATION );
9722 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 1.0f, 0.01f, TEST_LOCATION );
9723 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), 1.0f, 0.01f, TEST_LOCATION );
9724 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 1.0f, 0.01f, TEST_LOCATION );
9726 // We did expect the animation to finish
9728 finishCheck.CheckSignalReceived();
9732 int UtcDaliAnimationAnimateBetweenActorColorFunctionTimePeriod(void)
9734 TestApplication application;
9736 float startValue(1.0f);
9737 Actor actor = Actor::New();
9738 actor.SetColor(Vector4(startValue, startValue, startValue, startValue));
9739 Stage::GetCurrent().Add(actor);
9741 DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
9742 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
9743 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
9744 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
9745 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), startValue, TEST_LOCATION );
9747 // Build the animation
9748 float durationSeconds(1.0f);
9749 Animation animation = Animation::New(durationSeconds);
9751 KeyFrames keyFrames = KeyFrames::New();
9752 keyFrames.Add(0.0f, Vector4(0.1f, 0.2f, 0.3f, 0.4f));
9753 keyFrames.Add(0.5f, Vector4(0.9f, 0.8f, 0.7f, 0.6f));
9754 keyFrames.Add(1.0f, Vector4(1.0f, 1.0f, 1.0f, 1.0f));
9756 animation.AnimateBetween( Property(actor, Actor::COLOR), keyFrames, AlphaFunctions::Linear, TimePeriod( 1.0f) );
9758 // Start the animation
9761 bool signalReceived(false);
9762 AnimationFinishCheck finishCheck(signalReceived);
9763 animation.FinishedSignal().Connect(&application, finishCheck);
9764 application.SendNotification();
9765 application.Render(0);
9766 application.SendNotification();
9767 finishCheck.CheckSignalNotReceived();
9768 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), 0.1f, 0.01f, TEST_LOCATION );
9769 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 0.2f, 0.01f, TEST_LOCATION );
9770 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), 0.3f, 0.01f, TEST_LOCATION );
9771 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.4f, 0.01f, TEST_LOCATION );
9773 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
9774 application.SendNotification();
9775 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), 0.5f, 0.01f, TEST_LOCATION );
9776 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 0.5f, 0.01f, TEST_LOCATION );
9777 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), 0.5f, 0.01f, TEST_LOCATION );
9778 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.5f, 0.01f, TEST_LOCATION );
9780 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
9781 application.SendNotification();
9782 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), 0.9f, 0.01f, TEST_LOCATION );
9783 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 0.8f, 0.01f, TEST_LOCATION );
9784 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), 0.7f, 0.01f, TEST_LOCATION );
9785 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.6f, 0.01f, TEST_LOCATION );
9787 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
9788 application.SendNotification();
9789 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), 0.95f, 0.01f, TEST_LOCATION );
9790 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 0.90f, 0.01f, TEST_LOCATION );
9791 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), 0.85f, 0.01f, TEST_LOCATION );
9792 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.80f, 0.01f, TEST_LOCATION );
9794 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
9795 application.SendNotification();
9796 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), 1.0f, 0.01f, TEST_LOCATION );
9797 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 1.0f, 0.01f, TEST_LOCATION );
9798 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), 1.0f, 0.01f, TEST_LOCATION );
9799 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 1.0f, 0.01f, TEST_LOCATION );
9801 // We did expect the animation to finish
9803 finishCheck.CheckSignalReceived();
9807 int UtcDaliAnimationAnimateVector3Func(void)
9809 TestApplication application;
9811 Actor actor = Actor::New();
9812 Vector3 initialPosition(Vector3::ZERO);
9813 DALI_TEST_EQUALS( actor.GetCurrentPosition(), initialPosition, TEST_LOCATION );
9814 Stage::GetCurrent().Add(actor);
9816 // Build the animation
9817 float durationSeconds(10.0f);
9818 Animation animation = Animation::New(durationSeconds);
9819 Vector3 targetPosition(200.0f, 200.0f, 200.0f);
9820 BounceFunc func(0.0f, 0.0f, -100.0f);
9821 animation.Animate<Vector3>( Property(actor, Actor::POSITION), func, AlphaFunctions::Linear );
9823 // Start the animation
9826 bool signalReceived(false);
9827 AnimationFinishCheck finishCheck(signalReceived);
9828 animation.FinishedSignal().Connect(&application, finishCheck);
9830 application.SendNotification();
9831 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
9833 // We didn't expect the animation to finish yet
9834 application.SendNotification();
9835 finishCheck.CheckSignalNotReceived();
9836 DALI_TEST_EQUALS( actor.GetCurrentPosition(), func(0.25f, initialPosition), TEST_LOCATION );
9838 application.SendNotification();
9839 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
9841 // We didn't expect the animation to finish yet
9842 application.SendNotification();
9843 finishCheck.CheckSignalNotReceived();
9844 DALI_TEST_EQUALS( actor.GetCurrentPosition(), func(0.5f, initialPosition), TEST_LOCATION );
9846 application.SendNotification();
9847 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
9849 // We didn't expect the animation to finish yet
9850 application.SendNotification();
9851 finishCheck.CheckSignalNotReceived();
9852 DALI_TEST_EQUALS( actor.GetCurrentPosition(), func(0.75f, initialPosition), TEST_LOCATION );
9854 application.SendNotification();
9855 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
9857 // We did expect the animation to finish
9858 application.SendNotification();
9859 finishCheck.CheckSignalReceived();
9860 DALI_TEST_EQUALS( actor.GetCurrentPosition(), initialPosition, TEST_LOCATION );
9864 int UtcDaliAnimationCreateDestroy(void)
9866 TestApplication application;
9867 Animation* animation = new Animation;
9868 DALI_TEST_CHECK( animation );
9873 struct UpdateManagerTestConstraint
9875 UpdateManagerTestConstraint(TestApplication& application)
9876 : mApplication(application)
9880 Vector3 operator()(const Vector3& current)
9882 mApplication.SendNotification(); // Process events
9886 TestApplication& mApplication;
9889 int UtcDaliAnimationUpdateManager(void)
9891 TestApplication application;
9893 Actor actor = Actor::New();
9894 Stage::GetCurrent().Add( actor );
9896 // Build the animation
9897 Animation animation = Animation::New( 0.0f );
9899 bool signalReceived = false;
9900 AnimationFinishCheck finishCheck( signalReceived );
9901 animation.FinishedSignal().Connect( &application, finishCheck );
9903 Vector3 startValue(1.0f, 1.0f, 1.0f);
9904 Property::Index index = actor.RegisterProperty( "test-property", startValue );
9905 Constraint constraint = Constraint::New<Vector3>( index, UpdateManagerTestConstraint( application ) );
9906 actor.ApplyConstraint( constraint );
9908 // Apply animation to actor
9909 BounceFunc func(0.0f, 0.0f, -100.0f);
9910 animation.Animate<Vector3>( Property(actor, Actor::POSITION), func, AlphaFunctions::Linear );
9914 application.SendNotification();
9915 application.UpdateOnly( 16 );
9917 finishCheck.CheckSignalNotReceived();
9919 application.SendNotification(); // Process events
9921 finishCheck.CheckSignalReceived();
9926 int UtcDaliAnimationSignalOrder(void)
9928 TestApplication application;
9930 Actor actor = Actor::New();
9931 Stage::GetCurrent().Add( actor );
9933 // Build the animations
9934 Animation animation1 = Animation::New( 0.0f ); // finishes first frame
9935 Animation animation2 = Animation::New( 0.02f ); // finishes in 20 ms
9937 bool signal1Received = false;
9938 animation1.FinishedSignal().Connect( &application, AnimationFinishCheck( signal1Received ) );
9940 bool signal2Received = false;
9941 animation2.FinishedSignal().Connect( &application, AnimationFinishCheck( signal2Received ) );
9943 // Apply animations to actor
9944 animation1.AnimateTo( Property(actor, Actor::POSITION), Vector3( 3.0f, 2.0f, 1.0f ), AlphaFunctions::Linear );
9946 animation2.AnimateTo( Property(actor, Actor::SIZE ), Vector3( 10.0f, 20.0f, 30.0f ), AlphaFunctions::Linear );
9949 DALI_TEST_EQUALS( signal1Received, false, TEST_LOCATION );
9950 DALI_TEST_EQUALS( signal2Received, false, TEST_LOCATION );
9952 application.SendNotification();
9953 application.UpdateOnly( 10 ); // 10ms progress
9955 // no notifications yet
9956 DALI_TEST_EQUALS( signal1Received, false, TEST_LOCATION );
9957 DALI_TEST_EQUALS( signal2Received, false, TEST_LOCATION );
9959 application.SendNotification();
9962 DALI_TEST_EQUALS( signal1Received, true, TEST_LOCATION );
9963 DALI_TEST_EQUALS( signal2Received, false, TEST_LOCATION );
9964 signal1Received = false;
9966 // 1st animation is complete now, do another update with no ProcessEvents in between
9967 application.UpdateOnly( 20 ); // 20ms progress
9970 application.SendNotification();
9972 // 2nd should complete now
9973 DALI_TEST_EQUALS( signal1Received, false, TEST_LOCATION );
9974 DALI_TEST_EQUALS( signal2Received, true, TEST_LOCATION );
9979 int UtcDaliAnimationExtendDuration(void)
9981 TestApplication application;
9983 Actor actor = Actor::New();
9985 // Register a float property
9986 float startValue(10.0f);
9987 Property::Index index = actor.RegisterProperty( "test-property", startValue );
9988 Stage::GetCurrent().Add(actor);
9989 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
9991 // Build the animation
9992 float initialDurationSeconds(1.0f);
9993 float animatorDelay = 5.0f;
9994 float animatorDurationSeconds(5.0f);
9995 float extendedDurationSeconds(animatorDelay+animatorDurationSeconds);
9996 Animation animation = Animation::New(initialDurationSeconds);
9997 float targetValue(30.0f);
9998 float relativeValue(targetValue - startValue);
10000 animation.AnimateTo(Property(actor, index),
10002 TimePeriod(animatorDelay, animatorDurationSeconds));
10004 // The duration should have been extended
10005 DALI_TEST_EQUALS( animation.GetDuration(), extendedDurationSeconds, TEST_LOCATION );
10007 // Start the animation
10010 bool signalReceived(false);
10011 AnimationFinishCheck finishCheck(signalReceived);
10012 animation.FinishedSignal().Connect(&application, finishCheck);
10014 application.SendNotification();
10015 application.Render(static_cast<unsigned int>(extendedDurationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
10017 // We didn't expect the animation to finish yet
10018 application.SendNotification();
10019 finishCheck.CheckSignalNotReceived();
10020 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
10022 application.SendNotification();
10023 application.Render(static_cast<unsigned int>(extendedDurationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
10025 // We didn't expect the animation to finish yet
10026 application.SendNotification();
10027 finishCheck.CheckSignalNotReceived();
10028 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
10030 application.SendNotification();
10031 application.Render(static_cast<unsigned int>(extendedDurationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
10033 // We did expect the animation to finish
10034 application.SendNotification();
10035 finishCheck.CheckSignalReceived();
10036 DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );