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 UtcDaliAnimationPlayOffStage(void)
648 // Test that an animation can be played, when the actor is off-stage.
649 // When the actor is added to the stage, it should appear at the current position
650 // i.e. where it would have been anyway, if on-stage from the beginning.
652 TestApplication application;
654 Actor actor = Actor::New();
655 Vector3 basePosition(Vector3::ZERO);
656 DALI_TEST_EQUALS( actor.GetCurrentPosition(), basePosition, TEST_LOCATION );
657 // Not added to the stage!
659 // Build the animation
660 float durationSeconds(1.0f);
661 Animation animation = Animation::New(durationSeconds);
662 Vector3 targetPosition(100.0f, 100.0f, 100.0f);
663 animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear);
665 // Start the animation
668 bool signalReceived(false);
669 AnimationFinishCheck finishCheck(signalReceived);
670 animation.FinishedSignal().Connect(&application, finishCheck);
672 application.SendNotification();
673 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 20% progress */);
675 // We didn't expect the animation to finish yet
676 application.SendNotification();
677 finishCheck.CheckSignalNotReceived();
678 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO/*off-stage*/, TEST_LOCATION );
681 Stage::GetCurrent().Add(actor);
683 application.SendNotification();
684 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 40% progress */);
686 // We didn't expect the animation to finish yet
687 application.SendNotification();
688 finishCheck.CheckSignalNotReceived();
689 Vector3 expectedPosition(basePosition + (targetPosition - basePosition)*0.4f);
690 DALI_TEST_EQUALS( actor.GetCurrentPosition(), expectedPosition/*on-stage*/, TEST_LOCATION );
692 // Remove from the stage
693 Stage::GetCurrent().Remove(actor);
695 application.SendNotification();
696 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 60% progress */);
698 // We didn't expect the animation to finish yet
699 application.SendNotification();
700 finishCheck.CheckSignalNotReceived();
701 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO/*back to start position*/, TEST_LOCATION );
704 Stage::GetCurrent().Add(actor);
706 application.SendNotification();
707 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 80% progress */);
709 // We didn't expect the animation to finish yet
710 application.SendNotification();
711 finishCheck.CheckSignalNotReceived();
712 expectedPosition = Vector3(basePosition + (targetPosition - basePosition)*0.8f);
713 DALI_TEST_EQUALS( actor.GetCurrentPosition(), expectedPosition, TEST_LOCATION );
715 application.SendNotification();
716 application.Render(static_cast<unsigned int>(durationSeconds*200.0f) + 1u/*just beyond the animation duration*/);
718 // We did expect the animation to finish
719 application.SendNotification();
720 finishCheck.CheckSignalReceived();
721 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
723 // Check that nothing has changed after a couple of buffer swaps
724 application.Render(0);
725 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
726 application.Render(0);
727 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
731 int UtcDaliAnimationPlayDiscardHandle(void)
733 TestApplication application;
735 Actor actor = Actor::New();
736 Stage::GetCurrent().Add(actor);
738 // Build the animation
739 float durationSeconds(1.0f);
740 Animation animation = Animation::New(durationSeconds);
741 Vector3 targetPosition(100.0f, 100.0f, 100.0f);
742 animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear);
744 bool signalReceived(false);
745 AnimationFinishCheck finishCheck(signalReceived);
746 animation.FinishedSignal().Connect(&application, finishCheck);
748 // Start the animation
751 // This is a test of the "Fire and Forget" behaviour
752 // Discard the animation handle!
754 DALI_TEST_CHECK( !animation );
756 application.SendNotification();
757 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 20% progress */);
759 // We didn't expect the animation to finish yet
760 application.SendNotification();
761 finishCheck.CheckSignalNotReceived();
762 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION );
764 application.SendNotification();
765 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 40% progress */);
767 // We didn't expect the animation to finish yet
768 application.SendNotification();
769 finishCheck.CheckSignalNotReceived();
770 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.4f), TEST_LOCATION );
772 application.SendNotification();
773 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 60% progress */);
775 // We didn't expect the animation to finish yet
776 application.SendNotification();
777 finishCheck.CheckSignalNotReceived();
778 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.6f), TEST_LOCATION );
780 application.SendNotification();
781 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 80% progress */);
783 // We didn't expect the animation to finish yet
784 application.SendNotification();
785 finishCheck.CheckSignalNotReceived();
786 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.8f), TEST_LOCATION );
788 application.SendNotification();
789 application.Render(static_cast<unsigned int>(durationSeconds*200.0f) + 1u/*just beyond the animation duration*/);
791 // We did expect the animation to finish
792 application.SendNotification();
793 finishCheck.CheckSignalReceived();
794 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
796 // Check that nothing has changed after a couple of buffer swaps
797 application.Render(0);
798 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
799 application.Render(0);
800 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
804 int UtcDaliAnimationPlayStopDiscardHandle(void)
806 TestApplication application;
808 Actor actor = Actor::New();
809 Stage::GetCurrent().Add(actor);
811 // Build the animation
812 float durationSeconds(1.0f);
813 Animation animation = Animation::New(durationSeconds);
814 Vector3 targetPosition(100.0f, 100.0f, 100.0f);
815 animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear);
817 // Start the animation
820 bool signalReceived(false);
821 AnimationFinishCheck finishCheck(signalReceived);
822 animation.FinishedSignal().Connect(&application, finishCheck);
824 application.SendNotification();
825 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 20% progress */);
827 // We didn't expect the animation to finish yet
828 application.SendNotification();
829 finishCheck.CheckSignalNotReceived();
830 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION );
832 // This is a test of the "Fire and Forget" behaviour
833 // Stop the animation, and Discard the animation handle!
836 DALI_TEST_CHECK( !animation );
838 application.SendNotification();
839 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 40% progress */);
841 // We expect the animation to finish at 20% progress
842 application.SendNotification();
843 finishCheck.CheckSignalReceived();
845 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION );
847 application.SendNotification();
848 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 60% progress */);
850 // Check that nothing has changed
851 application.SendNotification();
852 finishCheck.CheckSignalNotReceived();
853 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION );
855 application.SendNotification();
856 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 80% progress */);
858 // Check that nothing has changed
859 application.SendNotification();
860 finishCheck.CheckSignalNotReceived();
861 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION );
863 application.SendNotification();
864 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 100% progress */);
866 // Check that nothing has changed
867 application.SendNotification();
868 finishCheck.CheckSignalNotReceived();
869 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION );
873 int UtcDaliAnimationPlayFrom(void)
875 TestApplication application;
877 Actor actor = Actor::New();
878 Stage::GetCurrent().Add(actor);
880 // Build the animation
881 float durationSeconds(1.0f);
882 Animation animation = Animation::New(durationSeconds);
883 Vector3 targetPosition(100.0f, 100.0f, 100.0f);
884 animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear);
886 //PlayFrom with an argument outside the range [0..1] will be ignored
887 animation.PlayFrom(-1.0f);
888 application.SendNotification();
889 DALI_TEST_EQUALS(0.0f, animation.GetCurrentProgress(), TEST_LOCATION );
891 animation.PlayFrom(100.0f);
892 application.SendNotification();
893 DALI_TEST_EQUALS(0.0f, animation.GetCurrentProgress(), TEST_LOCATION );
895 // Start the animation from 40% progress
896 animation.PlayFrom( 0.4f );
898 bool signalReceived(false);
899 AnimationFinishCheck finishCheck(signalReceived);
900 animation.FinishedSignal().Connect(&application, finishCheck);
902 application.SendNotification();
903 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 60% progress */);
905 // We didn't expect the animation to finish yet
906 application.SendNotification();
907 finishCheck.CheckSignalNotReceived();
908 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.6f), TEST_LOCATION );
910 animation.Play(); // Test that calling play has no effect, when animation is already playing
911 application.SendNotification();
912 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 80% progress */);
914 // We didn't expect the animation to finish yet
915 application.SendNotification();
916 finishCheck.CheckSignalNotReceived();
917 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.8f), TEST_LOCATION );
919 application.Render(static_cast<unsigned int>(durationSeconds*200.0f) + 1u/*just beyond the animation duration*/);
920 // We did expect the animation to finish
921 application.SendNotification();
922 finishCheck.CheckSignalReceived();
923 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
925 // Check that nothing has changed after a couple of buffer swaps
926 application.Render(0);
927 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
928 application.Render(0);
929 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
933 int UtcDaliAnimationSetCurrentProgress(void)
935 TestApplication application;
937 Actor actor = Actor::New();
938 Stage::GetCurrent().Add(actor);
940 // Build the animation
941 Animation animation = Animation::New(0.0f);
944 //Test GetCurrentProgress return 0.0 as the duration is 0.0
945 DALI_TEST_EQUALS( 0.0f, animation.GetCurrentProgress(), TEST_LOCATION );
947 animation.SetCurrentProgress( 0.5f );
948 application.SendNotification();
949 application.Render(static_cast<unsigned int>(100.0f));
951 //Progress should still be 0.0
952 DALI_TEST_EQUALS( 0.0f, animation.GetCurrentProgress(), TEST_LOCATION );
955 float durationSeconds(1.0f);
956 animation.SetDuration(durationSeconds);
957 application.SendNotification();
959 bool signalReceived(false);
960 AnimationFinishCheck finishCheck(signalReceived);
961 animation.FinishedSignal().Connect(&application, finishCheck);
962 application.SendNotification();
964 Vector3 targetPosition(100.0f, 100.0f, 100.0f);
965 animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear);
967 //Trying to set the current cursor outside the range [0..1] is ignored
968 animation.SetCurrentProgress( -1.0f);
969 application.SendNotification();
970 DALI_TEST_EQUALS( 0.0f, animation.GetCurrentProgress(), TEST_LOCATION );
972 animation.SetCurrentProgress( 100.0f);
973 application.SendNotification();
974 DALI_TEST_EQUALS( 0.0f, animation.GetCurrentProgress(), TEST_LOCATION );
976 // Start the animation from 40% progress
977 animation.SetCurrentProgress( 0.4f );
980 application.SendNotification();
981 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 60% progress */);
983 // We didn't expect the animation to finish yet
984 application.SendNotification();
985 finishCheck.CheckSignalNotReceived();
986 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.6f), TEST_LOCATION );
987 DALI_TEST_EQUALS( 0.6f, animation.GetCurrentProgress(), TEST_LOCATION );
989 animation.Play(); // Test that calling play has no effect, when animation is already playing
990 application.SendNotification();
992 //Set the progress to 70%
993 animation.SetCurrentProgress( 0.7f );
994 application.SendNotification();
995 application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 80% progress */);
996 DALI_TEST_EQUALS( 0.8f, animation.GetCurrentProgress(), TEST_LOCATION );
999 application.SendNotification();
1000 finishCheck.CheckSignalNotReceived();
1001 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.8f), TEST_LOCATION );
1002 DALI_TEST_EQUALS( 0.8f, animation.GetCurrentProgress(), TEST_LOCATION );
1006 application.Render(static_cast<unsigned int>(durationSeconds*200.0f) + 1u/*just beyond the animation duration*/);
1007 // We did expect the animation to finish
1008 application.SendNotification();
1009 finishCheck.CheckSignalReceived();
1010 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
1012 // Check that nothing has changed after a couple of buffer swaps
1013 application.Render(0);
1014 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
1015 application.Render(0);
1016 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
1021 int UtcDaliAnimationPause(void)
1023 TestApplication application;
1025 Actor actor = Actor::New();
1026 Stage::GetCurrent().Add(actor);
1028 // Build the animation
1029 float durationSeconds(1.0f);
1030 Animation animation = Animation::New(durationSeconds);
1031 Vector3 targetPosition(100.0f, 100.0f, 100.0f);
1032 animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear);
1034 Vector3 fiftyPercentProgress(targetPosition * 0.5f);
1036 // Start the animation
1039 bool signalReceived(false);
1040 AnimationFinishCheck finishCheck(signalReceived);
1041 animation.FinishedSignal().Connect(&application, finishCheck);
1043 application.SendNotification();
1044 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
1046 // We didn't expect the animation to finish yet
1047 application.SendNotification();
1048 finishCheck.CheckSignalNotReceived();
1049 DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress, TEST_LOCATION );
1051 // Pause the animation
1053 application.SendNotification();
1056 for (int i=0; i<5; ++i)
1058 application.Render(static_cast<unsigned int>(durationSeconds*500.0f));
1060 // We didn't expect the animation to finish yet
1061 application.SendNotification();
1062 finishCheck.CheckSignalNotReceived();
1063 DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress/* Still 50% progress when paused */, TEST_LOCATION );
1068 application.SendNotification();
1069 application.Render(static_cast<unsigned int>(durationSeconds*490.0f)/*slightly less than the animation duration*/);
1071 // We didn't expect the animation to finish yet
1072 application.SendNotification();
1073 finishCheck.CheckSignalNotReceived();
1075 application.SendNotification();
1076 application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
1078 // We did expect the animation to finish
1079 application.SendNotification();
1080 finishCheck.CheckSignalReceived();
1081 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
1083 // Check that nothing has changed after a couple of buffer swaps
1084 application.Render(0);
1085 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
1086 application.Render(0);
1087 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
1091 int UtcDaliAnimationStop(void)
1093 TestApplication application;
1095 Actor actor = Actor::New();
1096 Stage::GetCurrent().Add(actor);
1098 // Build the animation
1099 float durationSeconds(1.0f);
1100 Animation animation = Animation::New(durationSeconds);
1101 Vector3 targetPosition(100.0f, 100.0f, 100.0f);
1102 animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear);
1104 Vector3 fiftyPercentProgress(targetPosition * 0.5f);
1106 // Start the animation
1109 bool signalReceived(false);
1110 AnimationFinishCheck finishCheck(signalReceived);
1111 animation.FinishedSignal().Connect(&application, finishCheck);
1113 application.SendNotification();
1114 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
1116 // We didn't expect the animation to finish yet
1117 application.SendNotification();
1118 finishCheck.CheckSignalNotReceived();
1119 DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress, TEST_LOCATION );
1121 // Stop the animation
1123 application.SendNotification();
1126 for (int i=0; i<5; ++i)
1128 application.Render(static_cast<unsigned int>(durationSeconds*500.0f));
1130 // We did expect the animation to finish
1131 application.SendNotification();
1132 finishCheck.CheckSignalReceived();
1133 DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress/* Still 50% progress when stopped */, TEST_LOCATION );
1138 int UtcDaliAnimationStopSetPosition(void)
1140 // Test that Animation::Stop & Actor::SetPosition can be used in conjunction
1141 // i.e. to check that the animation does not interfere with the position set.
1143 TestApplication application;
1145 Actor actor = Actor::New();
1146 Stage::GetCurrent().Add(actor);
1148 // Build the animation
1149 float durationSeconds(1.0f);
1150 Animation animation = Animation::New(durationSeconds);
1151 Vector3 targetPosition(100.0f, 100.0f, 100.0f);
1152 animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear);
1154 Vector3 fiftyPercentProgress(targetPosition * 0.5f);
1156 // Start the animation
1159 bool signalReceived(false);
1160 AnimationFinishCheck finishCheck(signalReceived);
1161 animation.FinishedSignal().Connect(&application, finishCheck);
1163 application.SendNotification();
1164 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
1166 // We didn't expect the animation to finish yet
1167 application.SendNotification();
1168 finishCheck.CheckSignalNotReceived();
1169 DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress, TEST_LOCATION );
1171 // Stop the animation
1173 Vector3 positionSet(2.0f, 3.0f, 4.0f);
1174 actor.SetPosition(positionSet);
1175 application.SendNotification();
1178 for (int i=0; i<5; ++i)
1180 application.Render(static_cast<unsigned int>(durationSeconds*500.0f));
1182 // We did expect the animation to finish
1183 application.SendNotification();
1184 finishCheck.CheckSignalReceived();
1185 DALI_TEST_EQUALS( actor.GetCurrentPosition(), positionSet/*Animation should not interfere with this*/, TEST_LOCATION );
1190 int UtcDaliAnimationClear(void)
1192 TestApplication application;
1194 Actor actor = Actor::New();
1195 Stage::GetCurrent().Add(actor);
1197 // Build the animation
1198 float durationSeconds(1.0f);
1199 Animation animation = Animation::New(durationSeconds);
1200 Vector3 targetPosition(100.0f, 100.0f, 100.0f);
1201 animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear);
1203 Vector3 fiftyPercentProgress(targetPosition * 0.5f);
1205 // Start the animation
1208 bool signalReceived(false);
1209 AnimationFinishCheck finishCheck(signalReceived);
1210 animation.FinishedSignal().Connect(&application, finishCheck);
1212 application.SendNotification();
1213 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
1215 // We didn't expect the animation to finish yet
1216 application.SendNotification();
1217 finishCheck.CheckSignalNotReceived();
1218 DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress, TEST_LOCATION );
1220 // Clear the animation
1222 application.SendNotification();
1224 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
1226 // We don't expect the animation to finish now
1227 application.SendNotification();
1228 finishCheck.CheckSignalNotReceived();
1229 DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress/* Still 50% progress since the animator was destroyed */, TEST_LOCATION );
1231 // Restart as a scale animation; this should not move the actor's position
1232 finishCheck.Reset();
1233 actor.SetPosition(Vector3::ZERO);
1234 Vector3 targetScale(3.0f, 3.0f, 3.0f);
1235 animation.ScaleTo(actor, targetScale, AlphaFunctions::Linear);
1238 application.SendNotification();
1239 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
1241 // We didn't expect the animation to finish yet
1242 application.SendNotification();
1243 finishCheck.CheckSignalNotReceived();
1244 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO/*Check move-animator was destroyed*/, TEST_LOCATION );
1245 DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3(2.0f, 2.0f, 2.0f), TEST_LOCATION );
1247 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
1249 // We did expect the animation to finish
1250 application.SendNotification();
1251 finishCheck.CheckSignalReceived();
1252 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO/*Check move-animator was destroyed*/, TEST_LOCATION );
1253 DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
1257 int UtcDaliAnimationSignalFinish(void)
1259 TestApplication application;
1261 // Start the empty animation
1262 float durationSeconds(1.0f);
1263 Animation animation = Animation::New(durationSeconds);
1266 bool signalReceived(false);
1267 AnimationFinishCheck finishCheck(signalReceived);
1268 animation.FinishedSignal().Connect(&application, finishCheck);
1270 application.SendNotification();
1271 application.Render(static_cast<unsigned int>(durationSeconds*1000.0f) + 1u/*beyond the animation duration*/);
1273 // We did expect the animation to finish
1274 application.SendNotification();
1275 finishCheck.CheckSignalReceived();
1279 int UtcDaliAnimationAnimateByBoolean(void)
1281 TestApplication application;
1283 Actor actor = Actor::New();
1285 // Register a boolean property
1286 bool startValue(false);
1287 Property::Index index = actor.RegisterProperty( "test-property", startValue );
1288 Stage::GetCurrent().Add(actor);
1289 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
1291 // Build the animation
1292 float durationSeconds(2.0f);
1293 Animation animation = Animation::New(durationSeconds);
1294 const bool relativeValue(true);
1295 const bool finalValue( false || relativeValue );
1296 animation.AnimateBy(Property(actor, index), relativeValue);
1298 // Start the animation
1301 bool signalReceived(false);
1302 AnimationFinishCheck finishCheck(signalReceived);
1303 animation.FinishedSignal().Connect(&application, finishCheck);
1305 application.SendNotification();
1306 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
1308 // We didn't expect the animation to finish yet
1309 application.SendNotification();
1310 finishCheck.CheckSignalNotReceived();
1311 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
1313 application.SendNotification();
1314 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
1316 // We did expect the animation to finish
1317 application.SendNotification();
1318 finishCheck.CheckSignalReceived();
1319 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1321 // Check that nothing has changed after a couple of buffer swaps
1322 application.Render(0);
1323 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1324 application.Render(0);
1325 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1327 // Repeat with relative value "false" - this should be an NOOP
1328 animation = Animation::New(durationSeconds);
1329 bool noOpValue(false);
1330 animation.AnimateBy(Property(actor, index), noOpValue);
1332 // Start the animation
1335 finishCheck.Reset();
1336 animation.FinishedSignal().Connect(&application, finishCheck);
1338 application.SendNotification();
1339 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
1341 // We didn't expect the animation to finish yet
1342 application.SendNotification();
1343 finishCheck.CheckSignalNotReceived();
1344 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1346 application.SendNotification();
1347 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
1349 // We did expect the animation to finish
1350 application.SendNotification();
1351 finishCheck.CheckSignalReceived();
1352 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1354 // Check that nothing has changed after a couple of buffer swaps
1355 application.Render(0);
1356 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1357 application.Render(0);
1358 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1362 int UtcDaliAnimationAnimateByBooleanAlphaFunction(void)
1364 TestApplication application;
1366 Actor actor = Actor::New();
1368 // Register a boolean property
1369 bool startValue(false);
1370 Property::Index index = actor.RegisterProperty( "test-property", startValue );
1371 Stage::GetCurrent().Add(actor);
1372 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
1374 // Build the animation
1375 float durationSeconds(2.0f);
1376 Animation animation = Animation::New(durationSeconds);
1377 bool relativeValue(true);
1378 bool finalValue( false || relativeValue );
1379 animation.AnimateBy(Property(actor, index), relativeValue, AlphaFunctions::EaseIn);
1381 // Start the animation
1384 bool signalReceived(false);
1385 AnimationFinishCheck finishCheck(signalReceived);
1386 animation.FinishedSignal().Connect(&application, finishCheck);
1388 application.SendNotification();
1389 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
1391 // We didn't expect the animation to finish yet
1392 application.SendNotification();
1393 finishCheck.CheckSignalNotReceived();
1394 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
1396 application.SendNotification();
1397 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
1399 // We did expect the animation to finish
1400 application.SendNotification();
1401 finishCheck.CheckSignalReceived();
1402 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1404 // Check that nothing has changed after a couple of buffer swaps
1405 application.Render(0);
1406 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1407 application.Render(0);
1408 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1410 // Repeat with relative value "false" - this should be an NOOP
1411 animation = Animation::New(durationSeconds);
1412 bool noOpValue(false);
1413 animation.AnimateBy(Property(actor, index), noOpValue, AlphaFunctions::EaseIn);
1415 // Start the animation
1418 finishCheck.Reset();
1419 animation.FinishedSignal().Connect(&application, finishCheck);
1421 application.SendNotification();
1422 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
1424 // We didn't expect the animation to finish yet
1425 application.SendNotification();
1426 finishCheck.CheckSignalNotReceived();
1427 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1429 application.SendNotification();
1430 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
1432 // We did expect the animation to finish
1433 application.SendNotification();
1434 finishCheck.CheckSignalReceived();
1435 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1439 int UtcDaliAnimationAnimateByBooleanTimePeriod(void)
1441 TestApplication application;
1443 Actor actor = Actor::New();
1445 // Register a boolean property
1446 bool startValue(false);
1447 Property::Index index = actor.RegisterProperty( "test-property", startValue );
1448 Stage::GetCurrent().Add(actor);
1449 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
1451 // Build the animation
1452 float durationSeconds(2.0f);
1453 Animation animation = Animation::New(durationSeconds);
1454 bool relativeValue(true);
1455 bool finalValue( false || relativeValue );
1456 float animatorDurationSeconds(durationSeconds * 0.5f);
1457 animation.AnimateBy( Property(actor, index),
1459 TimePeriod( animatorDurationSeconds ) );
1461 // Start the animation
1464 bool signalReceived(false);
1465 AnimationFinishCheck finishCheck(signalReceived);
1466 animation.FinishedSignal().Connect(&application, finishCheck);
1468 application.SendNotification();
1469 application.Render(static_cast<unsigned int>(animatorDurationSeconds*950.0f)/* 95% animator progress */);
1471 // We didn't expect the animation to finish yet
1472 application.SendNotification();
1473 finishCheck.CheckSignalNotReceived();
1474 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
1476 application.SendNotification();
1477 application.Render(static_cast<unsigned int>(animatorDurationSeconds*50.0f) + 1u/*just beyond the animator duration*/);
1479 // We didn't expect the animation to finish yet...
1480 application.SendNotification();
1481 finishCheck.CheckSignalNotReceived();
1483 // ...however we should have reached the final value
1484 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1486 application.SendNotification();
1487 application.Render(static_cast<unsigned int>(animatorDurationSeconds*1000.0f)/*just beyond the animation duration*/);
1489 // We did expect the animation to finish
1490 application.SendNotification();
1491 finishCheck.CheckSignalReceived();
1492 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1494 // Check that nothing has changed after a couple of buffer swaps
1495 application.Render(0);
1496 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1497 application.Render(0);
1498 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1502 int UtcDaliAnimationAnimateByBooleanAlphaFunctionTimePeriod(void)
1504 TestApplication application;
1506 Actor actor = Actor::New();
1508 // Register a boolean property
1509 bool startValue(false);
1510 Property::Index index = actor.RegisterProperty( "test-property", startValue );
1511 Stage::GetCurrent().Add(actor);
1512 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
1514 // Build the animation
1515 float durationSeconds(2.0f);
1516 Animation animation = Animation::New(durationSeconds);
1517 bool relativeValue(true);
1518 bool finalValue( false || relativeValue );
1519 float animatorDurationSeconds(durationSeconds * 0.5f);
1520 animation.AnimateBy( Property(actor, index),
1522 AlphaFunctions::EaseInOut,
1523 TimePeriod( animatorDurationSeconds ) );
1525 // Start the animation
1528 bool signalReceived(false);
1529 AnimationFinishCheck finishCheck(signalReceived);
1530 animation.FinishedSignal().Connect(&application, finishCheck);
1532 application.SendNotification();
1533 application.Render(static_cast<unsigned int>(animatorDurationSeconds*950.0f)/* 95% animator progress */);
1535 // We didn't expect the animation to finish yet
1536 application.SendNotification();
1537 finishCheck.CheckSignalNotReceived();
1538 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
1540 application.SendNotification();
1541 application.Render(static_cast<unsigned int>(animatorDurationSeconds*50.0f) + 1u/*just beyond the animator duration*/);
1543 // We didn't expect the animation to finish yet...
1544 application.SendNotification();
1545 finishCheck.CheckSignalNotReceived();
1547 // ...however we should have reached the final value
1548 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1550 application.SendNotification();
1551 application.Render(static_cast<unsigned int>(animatorDurationSeconds*1000.0f)/*just beyond the animation duration*/);
1553 // We did expect the animation to finish
1554 application.SendNotification();
1555 finishCheck.CheckSignalReceived();
1556 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1558 // Check that nothing has changed after a couple of buffer swaps
1559 application.Render(0);
1560 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1561 application.Render(0);
1562 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1566 int UtcDaliAnimationAnimateByFloat(void)
1568 TestApplication application;
1570 Actor actor = Actor::New();
1572 // Register a float property
1573 float startValue(10.0f);
1574 Property::Index index = actor.RegisterProperty( "test-property", startValue );
1575 Stage::GetCurrent().Add(actor);
1576 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
1578 // Build the animation
1579 float durationSeconds(2.0f);
1580 Animation animation = Animation::New(durationSeconds);
1581 float targetValue(50.0f);
1582 float relativeValue(targetValue - startValue);
1583 animation.AnimateBy(Property(actor, index), relativeValue);
1585 float ninetyFivePercentProgress(startValue + relativeValue*0.95f);
1587 // Start the animation
1590 bool signalReceived(false);
1591 AnimationFinishCheck finishCheck(signalReceived);
1592 animation.FinishedSignal().Connect(&application, finishCheck);
1594 application.SendNotification();
1595 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
1597 // We didn't expect the animation to finish yet
1598 application.SendNotification();
1599 finishCheck.CheckSignalNotReceived();
1600 DALI_TEST_EQUALS( actor.GetProperty<float>(index), ninetyFivePercentProgress, TEST_LOCATION );
1602 application.SendNotification();
1603 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
1605 // We did expect the animation to finish
1606 application.SendNotification();
1607 finishCheck.CheckSignalReceived();
1608 DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
1610 // Check that nothing has changed after a couple of buffer swaps
1611 application.Render(0);
1612 DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
1613 application.Render(0);
1614 DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
1618 int UtcDaliAnimationAnimateByFloatAlphaFunction(void)
1620 TestApplication application;
1622 Actor actor = Actor::New();
1624 // Register a float property
1625 float startValue(10.0f);
1626 Property::Index index = actor.RegisterProperty( "test-property", startValue );
1627 Stage::GetCurrent().Add(actor);
1628 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
1630 // Build the animation
1631 float durationSeconds(1.0f);
1632 Animation animation = Animation::New(durationSeconds);
1633 float targetValue(90.0f);
1634 float relativeValue(targetValue - startValue);
1635 animation.AnimateBy(Property(actor, index), relativeValue, AlphaFunctions::EaseOut);
1637 float ninetyFivePercentProgress(startValue + relativeValue*0.95f);
1639 // Start the animation
1642 bool signalReceived(false);
1643 AnimationFinishCheck finishCheck(signalReceived);
1644 animation.FinishedSignal().Connect(&application, finishCheck);
1646 application.SendNotification();
1647 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
1649 // We didn't expect the animation to finish yet
1650 application.SendNotification();
1651 finishCheck.CheckSignalNotReceived();
1653 // The position should have moved more, than with a linear alpha function
1654 float current(actor.GetProperty<float>(index));
1655 DALI_TEST_CHECK( current > ninetyFivePercentProgress );
1657 application.SendNotification();
1658 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
1660 // We did expect the animation to finish
1661 application.SendNotification();
1662 finishCheck.CheckSignalReceived();
1663 DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
1665 // Check that nothing has changed after a couple of buffer swaps
1666 application.Render(0);
1667 DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
1668 application.Render(0);
1669 DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
1673 int UtcDaliAnimationAnimateByFloatTimePeriod(void)
1675 TestApplication application;
1677 Actor actor = Actor::New();
1679 // Register a float property
1680 float startValue(10.0f);
1681 Property::Index index = actor.RegisterProperty( "test-property", startValue );
1682 Stage::GetCurrent().Add(actor);
1683 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
1685 // Build the animation
1686 float durationSeconds(1.0f);
1687 Animation animation = Animation::New(durationSeconds);
1688 float targetValue(30.0f);
1689 float relativeValue(targetValue - startValue);
1691 animation.AnimateBy(Property(actor, index),
1693 TimePeriod(delay, durationSeconds - delay));
1695 // Start the animation
1698 bool signalReceived(false);
1699 AnimationFinishCheck finishCheck(signalReceived);
1700 animation.FinishedSignal().Connect(&application, finishCheck);
1702 application.SendNotification();
1703 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
1705 // We didn't expect the animation to finish yet
1706 application.SendNotification();
1707 finishCheck.CheckSignalNotReceived();
1708 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
1710 application.SendNotification();
1711 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
1713 // We didn't expect the animation to finish yet
1714 application.SendNotification();
1715 finishCheck.CheckSignalNotReceived();
1716 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
1718 application.SendNotification();
1719 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
1721 // We did expect the animation to finish
1722 application.SendNotification();
1723 finishCheck.CheckSignalReceived();
1724 DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
1726 // Check that nothing has changed after a couple of buffer swaps
1727 application.Render(0);
1728 DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
1729 application.Render(0);
1730 DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
1734 int UtcDaliAnimationAnimateByFloatAlphaFunctionTimePeriod(void)
1736 TestApplication application;
1738 Actor actor = Actor::New();
1740 // Register a float property
1741 float startValue(10.0f);
1742 Property::Index index = actor.RegisterProperty( "test-property", startValue );
1743 Stage::GetCurrent().Add(actor);
1744 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
1746 // Build the animation
1747 float durationSeconds(1.0f);
1748 Animation animation = Animation::New(durationSeconds);
1749 float targetValue(30.0f);
1750 float relativeValue(targetValue - startValue);
1752 animation.AnimateBy(Property(actor, index),
1754 AlphaFunctions::Linear,
1755 TimePeriod(delay, durationSeconds - delay));
1757 // Start the animation
1760 bool signalReceived(false);
1761 AnimationFinishCheck finishCheck(signalReceived);
1762 animation.FinishedSignal().Connect(&application, finishCheck);
1764 application.SendNotification();
1765 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
1767 // We didn't expect the animation to finish yet
1768 application.SendNotification();
1769 finishCheck.CheckSignalNotReceived();
1770 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
1772 application.SendNotification();
1773 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
1775 // We didn't expect the animation to finish yet
1776 application.SendNotification();
1777 finishCheck.CheckSignalNotReceived();
1778 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
1780 application.SendNotification();
1781 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
1783 // We did expect the animation to finish
1784 application.SendNotification();
1785 finishCheck.CheckSignalReceived();
1786 DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
1788 // Check that nothing has changed after a couple of buffer swaps
1789 application.Render(0);
1790 DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
1791 application.Render(0);
1792 DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
1796 int UtcDaliAnimationAnimateByInteger(void)
1798 TestApplication application;
1800 Actor actor = Actor::New();
1802 // Register an integer property
1804 Property::Index index = actor.RegisterProperty( "test-property", startValue );
1805 Stage::GetCurrent().Add(actor);
1806 DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
1808 // Build the animation
1809 float durationSeconds(2.0f);
1810 Animation animation = Animation::New(durationSeconds);
1811 int targetValue(50);
1812 int relativeValue(targetValue - startValue);
1813 animation.AnimateBy(Property(actor, index), relativeValue);
1815 int ninetyFivePercentProgress(static_cast<int>(startValue + relativeValue*0.95f + 0.5f));
1817 // Start the animation
1820 bool signalReceived(false);
1821 AnimationFinishCheck finishCheck(signalReceived);
1822 animation.FinishedSignal().Connect(&application, finishCheck);
1824 application.SendNotification();
1825 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
1827 // We didn't expect the animation to finish yet
1828 application.SendNotification();
1829 finishCheck.CheckSignalNotReceived();
1830 DALI_TEST_EQUALS( actor.GetProperty<int>(index), ninetyFivePercentProgress, TEST_LOCATION );
1832 application.SendNotification();
1833 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
1835 // We did expect the animation to finish
1836 application.SendNotification();
1837 finishCheck.CheckSignalReceived();
1838 DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
1840 // Check that nothing has changed after a couple of buffer swaps
1841 application.Render(0);
1842 DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
1843 application.Render(0);
1844 DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
1848 int UtcDaliAnimationAnimateByIntegerAlphaFunction(void)
1850 TestApplication application;
1852 Actor actor = Actor::New();
1854 // Register an integer property
1856 Property::Index index = actor.RegisterProperty( "test-property", startValue );
1857 Stage::GetCurrent().Add(actor);
1858 DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
1860 // Build the animation
1861 float durationSeconds(1.0f);
1862 Animation animation = Animation::New(durationSeconds);
1863 int targetValue(90);
1864 int relativeValue(targetValue - startValue);
1865 animation.AnimateBy(Property(actor, index), relativeValue, AlphaFunctions::EaseOut);
1867 int ninetyFivePercentProgress(static_cast<int>(startValue + relativeValue*0.95f + 0.5f));
1869 // Start the animation
1872 bool signalReceived(false);
1873 AnimationFinishCheck finishCheck(signalReceived);
1874 animation.FinishedSignal().Connect(&application, finishCheck);
1876 application.SendNotification();
1877 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
1879 // We didn't expect the animation to finish yet
1880 application.SendNotification();
1881 finishCheck.CheckSignalNotReceived();
1883 // The position should have moved more, than with a linear alpha function
1884 int current(actor.GetProperty<int>(index));
1885 DALI_TEST_CHECK( current > ninetyFivePercentProgress );
1887 application.SendNotification();
1888 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
1890 // We did expect the animation to finish
1891 application.SendNotification();
1892 finishCheck.CheckSignalReceived();
1893 DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
1895 // Check that nothing has changed after a couple of buffer swaps
1896 application.Render(0);
1897 DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
1898 application.Render(0);
1899 DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
1903 int UtcDaliAnimationAnimateByIntegerTimePeriod(void)
1905 TestApplication application;
1907 Actor actor = Actor::New();
1909 // Register an integer property
1911 Property::Index index = actor.RegisterProperty( "test-property", startValue );
1912 Stage::GetCurrent().Add(actor);
1913 DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
1915 // Build the animation
1916 float durationSeconds(1.0f);
1917 Animation animation = Animation::New(durationSeconds);
1918 int targetValue(30);
1919 int relativeValue(targetValue - startValue);
1921 animation.AnimateBy(Property(actor, index),
1923 TimePeriod(delay, durationSeconds - delay));
1925 // Start the animation
1928 bool signalReceived(false);
1929 AnimationFinishCheck finishCheck(signalReceived);
1930 animation.FinishedSignal().Connect(&application, finishCheck);
1932 application.SendNotification();
1933 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
1935 // We didn't expect the animation to finish yet
1936 application.SendNotification();
1937 finishCheck.CheckSignalNotReceived();
1938 DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
1940 application.SendNotification();
1941 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
1943 // We didn't expect the animation to finish yet
1944 application.SendNotification();
1945 finishCheck.CheckSignalNotReceived();
1946 DALI_TEST_EQUALS( actor.GetProperty<int>(index), static_cast<int>(startValue+(relativeValue*0.5f)+0.5f), TEST_LOCATION );
1948 application.SendNotification();
1949 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
1951 // We did expect the animation to finish
1952 application.SendNotification();
1953 finishCheck.CheckSignalReceived();
1954 DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
1956 // Check that nothing has changed after a couple of buffer swaps
1957 application.Render(0);
1958 DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
1959 application.Render(0);
1960 DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
1964 int UtcDaliAnimationAnimateByIntegerAlphaFunctionTimePeriod(void)
1966 TestApplication application;
1968 Actor actor = Actor::New();
1970 // Register an integer property
1972 Property::Index index = actor.RegisterProperty( "test-property", startValue );
1973 Stage::GetCurrent().Add(actor);
1974 DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
1976 // Build the animation
1977 float durationSeconds(1.0f);
1978 Animation animation = Animation::New(durationSeconds);
1979 int targetValue(30);
1980 int relativeValue(targetValue - startValue);
1982 animation.AnimateBy(Property(actor, index),
1984 AlphaFunctions::Linear,
1985 TimePeriod(delay, durationSeconds - delay));
1987 // Start the animation
1990 bool signalReceived(false);
1991 AnimationFinishCheck finishCheck(signalReceived);
1992 animation.FinishedSignal().Connect(&application, finishCheck);
1994 application.SendNotification();
1995 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
1997 // We didn't expect the animation to finish yet
1998 application.SendNotification();
1999 finishCheck.CheckSignalNotReceived();
2000 DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
2002 application.SendNotification();
2003 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
2005 // We didn't expect the animation to finish yet
2006 application.SendNotification();
2007 finishCheck.CheckSignalNotReceived();
2008 DALI_TEST_EQUALS( actor.GetProperty<int>(index), static_cast<int>(startValue+(relativeValue*0.5f)+0.5f), TEST_LOCATION );
2010 application.SendNotification();
2011 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
2013 // We did expect the animation to finish
2014 application.SendNotification();
2015 finishCheck.CheckSignalReceived();
2016 DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
2018 // Check that nothing has changed after a couple of buffer swaps
2019 application.Render(0);
2020 DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
2021 application.Render(0);
2022 DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
2026 int UtcDaliAnimationAnimateByVector2(void)
2028 TestApplication application;
2030 Actor actor = Actor::New();
2032 // Register a Vector2 property
2033 Vector2 startValue(10.0f, 10.0f);
2034 Property::Index index = actor.RegisterProperty( "test-property", startValue );
2035 Stage::GetCurrent().Add(actor);
2036 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
2038 // Build the animation
2039 float durationSeconds(2.0f);
2040 Animation animation = Animation::New(durationSeconds);
2041 Vector2 targetValue(60.0f, 60.0f);
2042 Vector2 relativeValue(targetValue - startValue);
2043 animation.AnimateBy(Property(actor, index), relativeValue);
2045 Vector2 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
2047 // Start the animation
2050 bool signalReceived(false);
2051 AnimationFinishCheck finishCheck(signalReceived);
2052 animation.FinishedSignal().Connect(&application, finishCheck);
2054 application.SendNotification();
2055 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
2057 // We didn't expect the animation to finish yet
2058 application.SendNotification();
2059 finishCheck.CheckSignalNotReceived();
2060 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), ninetyFivePercentProgress, TEST_LOCATION );
2062 application.SendNotification();
2063 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
2065 // We did expect the animation to finish
2066 application.SendNotification();
2067 finishCheck.CheckSignalReceived();
2068 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
2070 // Check that nothing has changed after a couple of buffer swaps
2071 application.Render(0);
2072 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
2073 application.Render(0);
2074 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
2078 int UtcDaliAnimationAnimateByVector2AlphaFunction(void)
2080 TestApplication application;
2082 Actor actor = Actor::New();
2084 // Register a Vector2 property
2085 Vector2 startValue(100.0f, 100.0f);
2086 Property::Index index = actor.RegisterProperty( "test-property", startValue );
2087 Stage::GetCurrent().Add(actor);
2088 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
2090 // Build the animation
2091 float durationSeconds(1.0f);
2092 Animation animation = Animation::New(durationSeconds);
2093 Vector2 targetValue(20.0f, 20.0f);
2094 Vector2 relativeValue(targetValue - startValue);
2095 animation.AnimateBy(Property(actor, index), relativeValue, AlphaFunctions::EaseOut);
2097 Vector2 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
2099 // Start the animation
2102 bool signalReceived(false);
2103 AnimationFinishCheck finishCheck(signalReceived);
2104 animation.FinishedSignal().Connect(&application, finishCheck);
2106 application.SendNotification();
2107 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
2109 // We didn't expect the animation to finish yet
2110 application.SendNotification();
2111 finishCheck.CheckSignalNotReceived();
2113 // The position should have moved more, than with a linear alpha function
2114 Vector2 current(actor.GetProperty<Vector2>(index));
2115 DALI_TEST_CHECK( current.x < ninetyFivePercentProgress.x );
2116 DALI_TEST_CHECK( current.y < ninetyFivePercentProgress.y );
2118 application.SendNotification();
2119 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
2121 // We did expect the animation to finish
2122 application.SendNotification();
2123 finishCheck.CheckSignalReceived();
2124 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
2126 // Check that nothing has changed after a couple of buffer swaps
2127 application.Render(0);
2128 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
2129 application.Render(0);
2130 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
2134 int UtcDaliAnimationAnimateByVector2TimePeriod(void)
2136 TestApplication application;
2138 Actor actor = Actor::New();
2140 // Register a Vector2 property
2141 Vector2 startValue(10.0f, 10.0f);
2142 Property::Index index = actor.RegisterProperty( "test-property", startValue );
2143 Stage::GetCurrent().Add(actor);
2144 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
2146 // Build the animation
2147 float durationSeconds(1.0f);
2148 Animation animation = Animation::New(durationSeconds);
2149 Vector2 targetValue(30.0f, 30.0f);
2150 Vector2 relativeValue(targetValue - startValue);
2152 animation.AnimateBy(Property(actor, index),
2154 TimePeriod(delay, durationSeconds - delay));
2156 // Start the animation
2159 bool signalReceived(false);
2160 AnimationFinishCheck finishCheck(signalReceived);
2161 animation.FinishedSignal().Connect(&application, finishCheck);
2163 application.SendNotification();
2164 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
2166 // We didn't expect the animation to finish yet
2167 application.SendNotification();
2168 finishCheck.CheckSignalNotReceived();
2169 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
2171 application.SendNotification();
2172 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
2174 // We didn't expect the animation to finish yet
2175 application.SendNotification();
2176 finishCheck.CheckSignalNotReceived();
2177 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
2179 application.SendNotification();
2180 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
2182 // We did expect the animation to finish
2183 application.SendNotification();
2184 finishCheck.CheckSignalReceived();
2185 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
2187 // Check that nothing has changed after a couple of buffer swaps
2188 application.Render(0);
2189 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
2190 application.Render(0);
2191 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
2195 int UtcDaliAnimationAnimateByVector2AlphaFunctionTimePeriod(void)
2197 TestApplication application;
2199 Actor actor = Actor::New();
2201 // Register a Vector2 property
2202 Vector2 startValue(5.0f, 5.0f);
2203 Property::Index index = actor.RegisterProperty( "test-property", startValue );
2204 Stage::GetCurrent().Add(actor);
2205 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
2207 // Build the animation
2208 float durationSeconds(1.0f);
2209 Animation animation = Animation::New(durationSeconds);
2210 Vector2 targetValue(10.0f, 10.0f);
2211 Vector2 relativeValue(targetValue - startValue);
2213 animation.AnimateBy(Property(actor, index),
2215 AlphaFunctions::Linear,
2216 TimePeriod(delay, durationSeconds - delay));
2218 // Start the animation
2221 bool signalReceived(false);
2222 AnimationFinishCheck finishCheck(signalReceived);
2223 animation.FinishedSignal().Connect(&application, finishCheck);
2225 application.SendNotification();
2226 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
2228 // We didn't expect the animation to finish yet
2229 application.SendNotification();
2230 finishCheck.CheckSignalNotReceived();
2231 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
2233 application.SendNotification();
2234 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
2236 // We didn't expect the animation to finish yet
2237 application.SendNotification();
2238 finishCheck.CheckSignalNotReceived();
2239 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
2241 application.SendNotification();
2242 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
2244 // We did expect the animation to finish
2245 application.SendNotification();
2246 finishCheck.CheckSignalReceived();
2247 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
2249 // Check that nothing has changed after a couple of buffer swaps
2250 application.Render(0);
2251 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
2252 application.Render(0);
2253 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
2257 int UtcDaliAnimationAnimateByVector3(void)
2259 TestApplication application;
2261 Actor actor = Actor::New();
2263 // Register a Vector3 property
2264 Vector3 startValue(10.0f, 10.0f, 10.0f);
2265 Property::Index index = actor.RegisterProperty( "test-property", startValue );
2266 Stage::GetCurrent().Add(actor);
2267 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
2269 // Build the animation
2270 float durationSeconds(2.0f);
2271 Animation animation = Animation::New(durationSeconds);
2272 Vector3 targetValue(60.0f, 60.0f, 60.0f);
2273 Vector3 relativeValue(targetValue - startValue);
2274 animation.AnimateBy(Property(actor, index), relativeValue);
2276 Vector3 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
2278 // Start the animation
2281 bool signalReceived(false);
2282 AnimationFinishCheck finishCheck(signalReceived);
2283 animation.FinishedSignal().Connect(&application, finishCheck);
2285 application.SendNotification();
2286 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
2288 // We didn't expect the animation to finish yet
2289 application.SendNotification();
2290 finishCheck.CheckSignalNotReceived();
2291 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), ninetyFivePercentProgress, TEST_LOCATION );
2293 application.SendNotification();
2294 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
2296 // We did expect the animation to finish
2297 application.SendNotification();
2298 finishCheck.CheckSignalReceived();
2299 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
2301 // Check that nothing has changed after a couple of buffer swaps
2302 application.Render(0);
2303 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
2304 application.Render(0);
2305 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
2309 int UtcDaliAnimationAnimateByVector3AlphaFunction(void)
2311 TestApplication application;
2313 Actor actor = Actor::New();
2315 // Register a Vector3 property
2316 Vector3 startValue(100.0f, 100.0f, 100.0f);
2317 Property::Index index = actor.RegisterProperty( "test-property", startValue );
2318 Stage::GetCurrent().Add(actor);
2319 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
2321 // Build the animation
2322 float durationSeconds(1.0f);
2323 Animation animation = Animation::New(durationSeconds);
2324 Vector3 targetValue(20.0f, 20.0f, 20.0f);
2325 Vector3 relativeValue(targetValue - startValue);
2326 animation.AnimateBy(Property(actor, index), relativeValue, AlphaFunctions::EaseOut);
2328 Vector3 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
2330 // Start the animation
2333 bool signalReceived(false);
2334 AnimationFinishCheck finishCheck(signalReceived);
2335 animation.FinishedSignal().Connect(&application, finishCheck);
2337 application.SendNotification();
2338 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
2340 // We didn't expect the animation to finish yet
2341 application.SendNotification();
2342 finishCheck.CheckSignalNotReceived();
2344 // The position should have moved more, than with a linear alpha function
2345 Vector3 current(actor.GetProperty<Vector3>(index));
2346 DALI_TEST_CHECK( current.x < ninetyFivePercentProgress.x );
2347 DALI_TEST_CHECK( current.y < ninetyFivePercentProgress.y );
2348 DALI_TEST_CHECK( current.z < ninetyFivePercentProgress.z );
2350 application.SendNotification();
2351 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
2353 // We did expect the animation to finish
2354 application.SendNotification();
2355 finishCheck.CheckSignalReceived();
2356 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
2358 // Check that nothing has changed after a couple of buffer swaps
2359 application.Render(0);
2360 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
2361 application.Render(0);
2362 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
2366 int UtcDaliAnimationAnimateByVector3TimePeriod(void)
2368 TestApplication application;
2370 Actor actor = Actor::New();
2372 // Register a Vector3 property
2373 Vector3 startValue(10.0f, 10.0f, 10.0f);
2374 Property::Index index = actor.RegisterProperty( "test-property", startValue );
2375 Stage::GetCurrent().Add(actor);
2376 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
2378 // Build the animation
2379 float durationSeconds(1.0f);
2380 Animation animation = Animation::New(durationSeconds);
2381 Vector3 targetValue(30.0f, 30.0f, 30.0f);
2382 Vector3 relativeValue(targetValue - startValue);
2384 animation.AnimateBy(Property(actor, index),
2386 TimePeriod(delay, durationSeconds - delay));
2388 // Start the animation
2391 bool signalReceived(false);
2392 AnimationFinishCheck finishCheck(signalReceived);
2393 animation.FinishedSignal().Connect(&application, finishCheck);
2395 application.SendNotification();
2396 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
2398 // We didn't expect the animation to finish yet
2399 application.SendNotification();
2400 finishCheck.CheckSignalNotReceived();
2401 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
2403 application.SendNotification();
2404 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
2406 // We didn't expect the animation to finish yet
2407 application.SendNotification();
2408 finishCheck.CheckSignalNotReceived();
2409 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
2411 application.SendNotification();
2412 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
2414 // We did expect the animation to finish
2415 application.SendNotification();
2416 finishCheck.CheckSignalReceived();
2417 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
2419 // Check that nothing has changed after a couple of buffer swaps
2420 application.Render(0);
2421 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
2422 application.Render(0);
2423 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
2427 int UtcDaliAnimationAnimateByVector3AlphaFunctionTimePeriod(void)
2429 TestApplication application;
2431 Actor actor = Actor::New();
2433 // Register a Vector3 property
2434 Vector3 startValue(5.0f, 5.0f, 5.0f);
2435 Property::Index index = actor.RegisterProperty( "test-property", startValue );
2436 Stage::GetCurrent().Add(actor);
2437 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
2439 // Build the animation
2440 float durationSeconds(1.0f);
2441 Animation animation = Animation::New(durationSeconds);
2442 Vector3 targetValue(10.0f, 10.0f, 10.0f);
2443 Vector3 relativeValue(targetValue - startValue);
2445 animation.AnimateBy(Property(actor, index),
2447 AlphaFunctions::Linear,
2448 TimePeriod(delay, durationSeconds - delay));
2450 // Start the animation
2453 bool signalReceived(false);
2454 AnimationFinishCheck finishCheck(signalReceived);
2455 animation.FinishedSignal().Connect(&application, finishCheck);
2457 application.SendNotification();
2458 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
2460 // We didn't expect the animation to finish yet
2461 application.SendNotification();
2462 finishCheck.CheckSignalNotReceived();
2463 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
2465 application.SendNotification();
2466 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
2468 // We didn't expect the animation to finish yet
2469 application.SendNotification();
2470 finishCheck.CheckSignalNotReceived();
2471 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
2473 application.SendNotification();
2474 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
2476 // We did expect the animation to finish
2477 application.SendNotification();
2478 finishCheck.CheckSignalReceived();
2479 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
2481 // Check that nothing has changed after a couple of buffer swaps
2482 application.Render(0);
2483 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
2484 application.Render(0);
2485 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
2489 int UtcDaliAnimationAnimateByVector4(void)
2491 TestApplication application;
2493 Actor actor = Actor::New();
2495 // Register a Vector4 property
2496 Vector4 startValue(10.0f, 10.0f, 10.0f, 10.0f);
2497 Property::Index index = actor.RegisterProperty( "test-property", startValue );
2498 Stage::GetCurrent().Add(actor);
2499 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
2501 // Build the animation
2502 float durationSeconds(2.0f);
2503 Animation animation = Animation::New(durationSeconds);
2504 Vector4 targetValue(60.0f, 60.0f, 60.0f, 60.0f);
2505 Vector4 relativeValue(targetValue - startValue);
2506 animation.AnimateBy(Property(actor, index), relativeValue);
2508 Vector4 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
2510 // Start the animation
2513 bool signalReceived(false);
2514 AnimationFinishCheck finishCheck(signalReceived);
2515 animation.FinishedSignal().Connect(&application, finishCheck);
2517 application.SendNotification();
2518 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
2520 // We didn't expect the animation to finish yet
2521 application.SendNotification();
2522 finishCheck.CheckSignalNotReceived();
2523 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), ninetyFivePercentProgress, TEST_LOCATION );
2525 application.SendNotification();
2526 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
2528 // We did expect the animation to finish
2529 application.SendNotification();
2530 finishCheck.CheckSignalReceived();
2531 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
2533 // Check that nothing has changed after a couple of buffer swaps
2534 application.Render(0);
2535 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
2536 application.Render(0);
2537 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
2541 int UtcDaliAnimationAnimateByVector4AlphaFunction(void)
2543 TestApplication application;
2545 Actor actor = Actor::New();
2547 // Register a Vector4 property
2548 Vector4 startValue(100.0f, 100.0f, 100.0f, 100.0f);
2549 Property::Index index = actor.RegisterProperty( "test-property", startValue );
2550 Stage::GetCurrent().Add(actor);
2551 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
2553 // Build the animation
2554 float durationSeconds(1.0f);
2555 Animation animation = Animation::New(durationSeconds);
2556 Vector4 targetValue(20.0f, 20.0f, 20.0f, 20.0f);
2557 Vector4 relativeValue(targetValue - startValue);
2558 animation.AnimateBy(Property(actor, index), relativeValue, AlphaFunctions::EaseOut);
2560 Vector4 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
2562 // Start the animation
2565 bool signalReceived(false);
2566 AnimationFinishCheck finishCheck(signalReceived);
2567 animation.FinishedSignal().Connect(&application, finishCheck);
2569 application.SendNotification();
2570 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
2572 // We didn't expect the animation to finish yet
2573 application.SendNotification();
2574 finishCheck.CheckSignalNotReceived();
2576 // The position should have moved more, than with a linear alpha function
2577 Vector4 current(actor.GetProperty<Vector4>(index));
2578 DALI_TEST_CHECK( current.x < ninetyFivePercentProgress.x );
2579 DALI_TEST_CHECK( current.y < ninetyFivePercentProgress.y );
2580 DALI_TEST_CHECK( current.z < ninetyFivePercentProgress.z );
2581 DALI_TEST_CHECK( current.w < ninetyFivePercentProgress.w );
2583 application.SendNotification();
2584 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
2586 // We did expect the animation to finish
2587 application.SendNotification();
2588 finishCheck.CheckSignalReceived();
2589 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
2591 // Check that nothing has changed after a couple of buffer swaps
2592 application.Render(0);
2593 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
2594 application.Render(0);
2595 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
2599 int UtcDaliAnimationAnimateByVector4TimePeriod(void)
2601 TestApplication application;
2603 Actor actor = Actor::New();
2605 // Register a Vector4 property
2606 Vector4 startValue(10.0f, 10.0f, 10.0f, 10.0f);
2607 Property::Index index = actor.RegisterProperty( "test-property", startValue );
2608 Stage::GetCurrent().Add(actor);
2609 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
2611 // Build the animation
2612 float durationSeconds(1.0f);
2613 Animation animation = Animation::New(durationSeconds);
2614 Vector4 targetValue(30.0f, 30.0f, 30.0f, 30.0f);
2615 Vector4 relativeValue(targetValue - startValue);
2617 animation.AnimateBy(Property(actor, index),
2619 TimePeriod(delay, durationSeconds - delay));
2621 // Start the animation
2624 bool signalReceived(false);
2625 AnimationFinishCheck finishCheck(signalReceived);
2626 animation.FinishedSignal().Connect(&application, finishCheck);
2628 application.SendNotification();
2629 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
2631 // We didn't expect the animation to finish yet
2632 application.SendNotification();
2633 finishCheck.CheckSignalNotReceived();
2634 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
2636 application.SendNotification();
2637 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
2639 // We didn't expect the animation to finish yet
2640 application.SendNotification();
2641 finishCheck.CheckSignalNotReceived();
2642 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
2644 application.SendNotification();
2645 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
2647 // We did expect the animation to finish
2648 application.SendNotification();
2649 finishCheck.CheckSignalReceived();
2650 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
2652 // Check that nothing has changed after a couple of buffer swaps
2653 application.Render(0);
2654 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
2655 application.Render(0);
2656 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
2660 int UtcDaliAnimationAnimateByVector4AlphaFunctionTimePeriod(void)
2662 TestApplication application;
2664 Actor actor = Actor::New();
2666 // Register a Vector4 property
2667 Vector4 startValue(5.0f, 5.0f, 5.0f, 5.0f);
2668 Property::Index index = actor.RegisterProperty( "test-property", startValue );
2669 Stage::GetCurrent().Add(actor);
2670 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
2672 // Build the animation
2673 float durationSeconds(1.0f);
2674 Animation animation = Animation::New(durationSeconds);
2675 Vector4 targetValue(10.0f, 10.0f, 10.0f, 10.0f);
2676 Vector4 relativeValue(targetValue - startValue);
2678 animation.AnimateBy(Property(actor, index),
2680 AlphaFunctions::Linear,
2681 TimePeriod(delay, durationSeconds - delay));
2683 // Start the animation
2686 bool signalReceived(false);
2687 AnimationFinishCheck finishCheck(signalReceived);
2688 animation.FinishedSignal().Connect(&application, finishCheck);
2690 application.SendNotification();
2691 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
2693 // We didn't expect the animation to finish yet
2694 application.SendNotification();
2695 finishCheck.CheckSignalNotReceived();
2696 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
2698 application.SendNotification();
2699 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
2701 // We didn't expect the animation to finish yet
2702 application.SendNotification();
2703 finishCheck.CheckSignalNotReceived();
2704 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
2706 application.SendNotification();
2707 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
2709 // We did expect the animation to finish
2710 application.SendNotification();
2711 finishCheck.CheckSignalReceived();
2712 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
2714 // Check that nothing has changed after a couple of buffer swaps
2715 application.Render(0);
2716 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
2717 application.Render(0);
2718 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
2722 int UtcDaliAnimationAnimateByActorPosition(void)
2724 TestApplication application;
2726 Actor actor = Actor::New();
2727 Vector3 startPosition(10.0f, 10.0f, 10.0f);
2728 actor.SetPosition(startPosition);
2729 Stage::GetCurrent().Add(actor);
2730 application.SendNotification();
2731 application.Render(0);
2732 DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION );
2734 // Build the animation
2735 float durationSeconds(1.0f);
2736 Animation animation = Animation::New(durationSeconds);
2737 Vector3 targetPosition(20.0f, 20.0f, 20.0f);
2738 Vector3 relativePosition(targetPosition - startPosition);
2739 animation.AnimateBy(Property(actor, Actor::POSITION), relativePosition);
2741 Vector3 ninetyFivePercentProgress(startPosition + relativePosition*0.95f);
2743 // Start the animation
2746 bool signalReceived(false);
2747 AnimationFinishCheck finishCheck(signalReceived);
2748 animation.FinishedSignal().Connect(&application, finishCheck);
2750 application.SendNotification();
2751 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
2753 // We didn't expect the animation to finish yet
2754 application.SendNotification();
2755 finishCheck.CheckSignalNotReceived();
2756 DALI_TEST_EQUALS( actor.GetCurrentPosition(), ninetyFivePercentProgress, TEST_LOCATION );
2758 application.SendNotification();
2759 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
2761 // We did expect the animation to finish
2762 application.SendNotification();
2763 finishCheck.CheckSignalReceived();
2764 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
2766 // Check that nothing has changed after a couple of buffer swaps
2767 application.Render(0);
2768 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
2769 application.Render(0);
2770 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
2774 int UtcDaliAnimationAnimateByActorPositionAlphaFunction(void)
2776 TestApplication application;
2778 Actor actor = Actor::New();
2779 Vector3 startPosition(10.0f, 10.0f, 10.0f);
2780 actor.SetPosition(startPosition);
2781 Stage::GetCurrent().Add(actor);
2782 application.SendNotification();
2783 application.Render(0);
2784 DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION );
2786 // Build the animation
2787 float durationSeconds(1.0f);
2788 Animation animation = Animation::New(durationSeconds);
2789 Vector3 targetPosition(20.0f, 20.0f, 20.0f);
2790 Vector3 relativePosition(targetPosition - startPosition);
2791 animation.AnimateBy(Property(actor, Actor::POSITION), relativePosition, AlphaFunctions::EaseOut);
2793 Vector3 ninetyFivePercentProgress(startPosition + relativePosition*0.95f);
2795 // Start the animation
2798 bool signalReceived(false);
2799 AnimationFinishCheck finishCheck(signalReceived);
2800 animation.FinishedSignal().Connect(&application, finishCheck);
2802 application.SendNotification();
2803 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
2805 // We didn't expect the animation to finish yet
2806 application.SendNotification();
2807 finishCheck.CheckSignalNotReceived();
2809 // The position should have moved more, than with a linear alpha function
2810 Vector3 current(actor.GetCurrentPosition());
2811 DALI_TEST_CHECK( current.x > ninetyFivePercentProgress.x );
2812 DALI_TEST_CHECK( current.y > ninetyFivePercentProgress.y );
2813 DALI_TEST_CHECK( current.z > ninetyFivePercentProgress.z );
2815 application.SendNotification();
2816 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
2818 // We did expect the animation to finish
2819 application.SendNotification();
2820 finishCheck.CheckSignalReceived();
2821 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
2823 // Check that nothing has changed after a couple of buffer swaps
2824 application.Render(0);
2825 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
2826 application.Render(0);
2827 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
2831 int UtcDaliAnimationAnimateByActorPositionTimePeriod(void)
2833 TestApplication application;
2835 Actor actor = Actor::New();
2836 Vector3 startPosition(10.0f, 10.0f, 10.0f);
2837 actor.SetPosition(startPosition);
2838 Stage::GetCurrent().Add(actor);
2839 application.SendNotification();
2840 application.Render(0);
2841 DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION );
2843 // Build the animation
2844 float durationSeconds(1.0f);
2845 Animation animation = Animation::New(durationSeconds);
2846 Vector3 targetPosition(20.0f, 20.0f, 20.0f);
2847 Vector3 relativePosition(targetPosition - startPosition);
2849 animation.AnimateBy(Property(actor, Actor::POSITION),
2851 TimePeriod(delay, durationSeconds - delay));
2853 Vector3 ninetyFivePercentProgress(startPosition + relativePosition*0.95f);
2855 // Start the animation
2858 bool signalReceived(false);
2859 AnimationFinishCheck finishCheck(signalReceived);
2860 animation.FinishedSignal().Connect(&application, finishCheck);
2862 application.SendNotification();
2863 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
2865 // We didn't expect the animation to finish yet
2866 application.SendNotification();
2867 finishCheck.CheckSignalNotReceived();
2868 DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION );
2870 application.SendNotification();
2871 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
2873 // We did expect the animation to finish
2874 application.SendNotification();
2875 finishCheck.CheckSignalReceived();
2876 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
2878 // Check that nothing has changed after a couple of buffer swaps
2879 application.Render(0);
2880 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
2881 application.Render(0);
2882 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
2886 int UtcDaliAnimationAnimateByActorPositionAlphaFunctionTimePeriod(void)
2888 TestApplication application;
2890 Actor actor = Actor::New();
2891 Vector3 startPosition(10.0f, 10.0f, 10.0f);
2892 actor.SetPosition(startPosition);
2893 Stage::GetCurrent().Add(actor);
2894 application.SendNotification();
2895 application.Render(0);
2896 DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION );
2898 // Build the animation
2899 float durationSeconds(1.0f);
2900 Animation animation = Animation::New(durationSeconds);
2901 Vector3 targetPosition(20.0f, 20.0f, 20.0f);
2902 Vector3 relativePosition(targetPosition - startPosition);
2904 animation.AnimateBy(Property(actor, Actor::POSITION),
2906 AlphaFunctions::Linear,
2907 TimePeriod(delay, durationSeconds - delay));
2909 Vector3 ninetyFivePercentProgress(startPosition + relativePosition*0.95f);
2911 // Start the animation
2914 bool signalReceived(false);
2915 AnimationFinishCheck finishCheck(signalReceived);
2916 animation.FinishedSignal().Connect(&application, finishCheck);
2918 application.SendNotification();
2919 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
2921 // We didn't expect the animation to finish yet
2922 application.SendNotification();
2923 finishCheck.CheckSignalNotReceived();
2924 DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION );
2926 application.SendNotification();
2927 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
2929 // We did expect the animation to finish
2930 application.SendNotification();
2931 finishCheck.CheckSignalReceived();
2932 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
2934 // Check that nothing has changed after a couple of buffer swaps
2935 application.Render(0);
2936 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
2937 application.Render(0);
2938 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
2942 int UtcDaliAnimationAnimateToBoolean(void)
2944 TestApplication application;
2946 Actor actor = Actor::New();
2948 // Register a boolean property
2949 const bool startValue(false);
2950 Property::Index index = actor.RegisterProperty( "test-property", startValue );
2951 Stage::GetCurrent().Add(actor);
2952 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
2954 // Build the animation
2955 float durationSeconds(2.0f);
2956 Animation animation = Animation::New(durationSeconds);
2957 const bool targetValue( !startValue );
2958 animation.AnimateTo(Property(actor, index), targetValue);
2960 // Start the animation
2963 bool signalReceived(false);
2964 AnimationFinishCheck finishCheck(signalReceived);
2965 animation.FinishedSignal().Connect(&application, finishCheck);
2967 application.SendNotification();
2968 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
2970 // We didn't expect the animation to finish yet
2971 application.SendNotification();
2972 finishCheck.CheckSignalNotReceived();
2973 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
2975 application.SendNotification();
2976 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
2978 // We did expect the animation to finish
2979 application.SendNotification();
2980 finishCheck.CheckSignalReceived();
2981 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == targetValue );
2983 // Check that nothing has changed after a couple of buffer swaps
2984 application.Render(0);
2985 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == targetValue );
2986 application.Render(0);
2987 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == targetValue );
2989 // Repeat with target value "false"
2990 animation = Animation::New(durationSeconds);
2991 const bool finalValue( !targetValue );
2992 animation.AnimateTo(Property(actor, index), finalValue);
2994 // Start the animation
2997 finishCheck.Reset();
2998 animation.FinishedSignal().Connect(&application, finishCheck);
3000 application.SendNotification();
3001 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3003 // We didn't expect the animation to finish yet
3004 application.SendNotification();
3005 finishCheck.CheckSignalNotReceived();
3006 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == targetValue );
3008 application.SendNotification();
3009 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3011 // We did expect the animation to finish
3012 application.SendNotification();
3013 finishCheck.CheckSignalReceived();
3014 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
3016 // Check that nothing has changed after a couple of buffer swaps
3017 application.Render(0);
3018 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
3019 application.Render(0);
3020 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
3024 int UtcDaliAnimationAnimateToBooleanAlphaFunction(void)
3026 TestApplication application;
3028 Actor actor = Actor::New();
3030 // Register a boolean property
3031 const bool startValue(false);
3032 Property::Index index = actor.RegisterProperty( "test-property", startValue );
3033 Stage::GetCurrent().Add(actor);
3034 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
3036 // Build the animation
3037 float durationSeconds(2.0f);
3038 Animation animation = Animation::New(durationSeconds);
3039 const bool targetValue( !startValue );
3040 animation.AnimateTo(Property(actor, "test-property"), targetValue, AlphaFunctions::EaseOut);
3042 // Start the animation
3045 bool signalReceived(false);
3046 AnimationFinishCheck finishCheck(signalReceived);
3047 animation.FinishedSignal().Connect(&application, finishCheck);
3049 application.SendNotification();
3050 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3052 // We didn't expect the animation to finish yet
3053 application.SendNotification();
3054 finishCheck.CheckSignalNotReceived();
3055 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
3057 application.SendNotification();
3058 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3060 // We did expect the animation to finish
3061 application.SendNotification();
3062 finishCheck.CheckSignalReceived();
3063 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == targetValue );
3065 // Check that nothing has changed after a couple of buffer swaps
3066 application.Render(0);
3067 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == targetValue );
3068 application.Render(0);
3069 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == targetValue );
3071 // Repeat with target value "false"
3072 animation = Animation::New(durationSeconds);
3073 const bool finalValue( !targetValue );
3074 animation.AnimateTo(Property(actor, index), finalValue, AlphaFunctions::EaseOut);
3076 // Start the animation
3079 finishCheck.Reset();
3080 animation.FinishedSignal().Connect(&application, finishCheck);
3082 application.SendNotification();
3083 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3085 // We didn't expect the animation to finish yet
3086 application.SendNotification();
3087 finishCheck.CheckSignalNotReceived();
3088 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == targetValue );
3090 application.SendNotification();
3091 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3093 // We did expect the animation to finish
3094 application.SendNotification();
3095 finishCheck.CheckSignalReceived();
3096 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
3098 // Check that nothing has changed after a couple of buffer swaps
3099 application.Render(0);
3100 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
3101 application.Render(0);
3102 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
3106 int UtcDaliAnimationAnimateToBooleanTimePeriod(void)
3108 TestApplication application;
3110 Actor actor = Actor::New();
3112 // Register a boolean property
3113 bool startValue(false);
3114 Property::Index index = actor.RegisterProperty( "test-property", startValue );
3115 Stage::GetCurrent().Add(actor);
3116 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
3118 // Build the animation
3119 float durationSeconds(2.0f);
3120 Animation animation = Animation::New(durationSeconds);
3121 bool finalValue( !startValue );
3122 float animatorDurationSeconds(durationSeconds * 0.5f);
3123 animation.AnimateTo( Property(actor, index),
3125 TimePeriod( animatorDurationSeconds ) );
3127 // Start the animation
3130 bool signalReceived(false);
3131 AnimationFinishCheck finishCheck(signalReceived);
3132 animation.FinishedSignal().Connect(&application, finishCheck);
3134 application.SendNotification();
3135 application.Render(static_cast<unsigned int>(animatorDurationSeconds*950.0f)/* 95% animator progress */);
3137 // We didn't expect the animation to finish yet
3138 application.SendNotification();
3139 finishCheck.CheckSignalNotReceived();
3140 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
3142 application.SendNotification();
3143 application.Render(static_cast<unsigned int>(animatorDurationSeconds*50.0f) + 1u/*just beyond the animator duration*/);
3145 // We didn't expect the animation to finish yet...
3146 application.SendNotification();
3147 finishCheck.CheckSignalNotReceived();
3149 // ...however we should have reached the final value
3150 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
3152 application.SendNotification();
3153 application.Render(static_cast<unsigned int>(animatorDurationSeconds*1000.0f)/*just beyond the animation duration*/);
3155 // We did expect the animation to finish
3156 application.SendNotification();
3157 finishCheck.CheckSignalReceived();
3158 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
3160 // Check that nothing has changed after a couple of buffer swaps
3161 application.Render(0);
3162 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
3163 application.Render(0);
3164 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
3168 int UtcDaliAnimationAnimateToBooleanAlphaFunctionTimePeriod(void)
3170 TestApplication application;
3172 Actor actor = Actor::New();
3174 // Register a boolean property
3175 bool startValue(false);
3176 Property::Index index = actor.RegisterProperty( "test-property", startValue );
3177 Stage::GetCurrent().Add(actor);
3178 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
3180 // Build the animation
3181 float durationSeconds(2.0f);
3182 Animation animation = Animation::New(durationSeconds);
3183 bool finalValue( !startValue );
3184 float animatorDurationSeconds(durationSeconds * 0.5f);
3185 animation.AnimateTo( Property(actor, index),
3187 AlphaFunctions::Linear,
3188 TimePeriod( animatorDurationSeconds ) );
3190 // Start the animation
3193 bool signalReceived(false);
3194 AnimationFinishCheck finishCheck(signalReceived);
3195 animation.FinishedSignal().Connect(&application, finishCheck);
3197 application.SendNotification();
3198 application.Render(static_cast<unsigned int>(animatorDurationSeconds*950.0f)/* 95% animator progress */);
3200 // We didn't expect the animation to finish yet
3201 application.SendNotification();
3202 finishCheck.CheckSignalNotReceived();
3203 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
3205 application.SendNotification();
3206 application.Render(static_cast<unsigned int>(animatorDurationSeconds*50.0f) + 1u/*just beyond the animator duration*/);
3208 // We didn't expect the animation to finish yet...
3209 application.SendNotification();
3210 finishCheck.CheckSignalNotReceived();
3212 // ...however we should have reached the final value
3213 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
3215 application.SendNotification();
3216 application.Render(static_cast<unsigned int>(animatorDurationSeconds*1000.0f)/*just beyond the animation duration*/);
3218 // We did expect the animation to finish
3219 application.SendNotification();
3220 finishCheck.CheckSignalReceived();
3221 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
3223 // Check that nothing has changed after a couple of buffer swaps
3224 application.Render(0);
3225 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
3226 application.Render(0);
3227 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
3231 int UtcDaliAnimationAnimateToFloat(void)
3233 TestApplication application;
3235 Actor actor = Actor::New();
3237 // Register a float property
3238 float startValue(10.0f);
3239 Property::Index index = actor.RegisterProperty( "test-property", startValue );
3240 Stage::GetCurrent().Add(actor);
3241 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
3243 // Build the animation
3244 float durationSeconds(2.0f);
3245 Animation animation = Animation::New(durationSeconds);
3246 float targetValue(50.0f);
3247 float relativeValue(targetValue - startValue);
3248 animation.AnimateTo(Property(actor, "test-property"), targetValue);
3250 float ninetyFivePercentProgress(startValue + relativeValue*0.95f);
3252 // Start the animation
3255 bool signalReceived(false);
3256 AnimationFinishCheck finishCheck(signalReceived);
3257 animation.FinishedSignal().Connect(&application, finishCheck);
3259 application.SendNotification();
3260 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3262 // We didn't expect the animation to finish yet
3263 application.SendNotification();
3264 finishCheck.CheckSignalNotReceived();
3265 DALI_TEST_EQUALS( actor.GetProperty<float>(index), ninetyFivePercentProgress, TEST_LOCATION );
3267 application.SendNotification();
3268 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3270 // We did expect the animation to finish
3271 application.SendNotification();
3272 finishCheck.CheckSignalReceived();
3273 DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
3277 int UtcDaliAnimationAnimateToFloatAlphaFunction(void)
3279 TestApplication application;
3281 Actor actor = Actor::New();
3283 // Register a float property
3284 float startValue(10.0f);
3285 Property::Index index = actor.RegisterProperty( "test-property", startValue );
3286 Stage::GetCurrent().Add(actor);
3287 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
3289 // Build the animation
3290 float durationSeconds(1.0f);
3291 Animation animation = Animation::New(durationSeconds);
3292 float targetValue(90.0f);
3293 float relativeValue(targetValue - startValue);
3294 animation.AnimateTo(Property(actor, index), targetValue, AlphaFunctions::EaseOut);
3296 float ninetyFivePercentProgress(startValue + relativeValue*0.95f);
3298 // Start the animation
3301 bool signalReceived(false);
3302 AnimationFinishCheck finishCheck(signalReceived);
3303 animation.FinishedSignal().Connect(&application, finishCheck);
3305 application.SendNotification();
3306 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3308 // We didn't expect the animation to finish yet
3309 application.SendNotification();
3310 finishCheck.CheckSignalNotReceived();
3312 // The position should have moved more, than with a linear alpha function
3313 float current(actor.GetProperty<float>(index));
3314 DALI_TEST_CHECK( current > ninetyFivePercentProgress );
3316 application.SendNotification();
3317 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3319 // We did expect the animation to finish
3320 application.SendNotification();
3321 finishCheck.CheckSignalReceived();
3322 DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
3326 int UtcDaliAnimationAnimateToFloatTimePeriod(void)
3328 TestApplication application;
3330 Actor actor = Actor::New();
3332 // Register a float property
3333 float startValue(10.0f);
3334 Property::Index index = actor.RegisterProperty( "test-property", startValue );
3335 Stage::GetCurrent().Add(actor);
3336 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
3338 // Build the animation
3339 float durationSeconds(1.0f);
3340 Animation animation = Animation::New(durationSeconds);
3341 float targetValue(30.0f);
3342 float relativeValue(targetValue - startValue);
3344 animation.AnimateTo(Property(actor, index),
3346 TimePeriod(delay, durationSeconds - delay));
3348 // Start the animation
3351 bool signalReceived(false);
3352 AnimationFinishCheck finishCheck(signalReceived);
3353 animation.FinishedSignal().Connect(&application, finishCheck);
3355 application.SendNotification();
3356 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
3358 // We didn't expect the animation to finish yet
3359 application.SendNotification();
3360 finishCheck.CheckSignalNotReceived();
3361 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
3363 application.SendNotification();
3364 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
3366 // We didn't expect the animation to finish yet
3367 application.SendNotification();
3368 finishCheck.CheckSignalNotReceived();
3369 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
3371 application.SendNotification();
3372 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
3374 // We did expect the animation to finish
3375 application.SendNotification();
3376 finishCheck.CheckSignalReceived();
3377 DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
3381 int UtcDaliAnimationAnimateToFloatAlphaFunctionTimePeriod(void)
3383 TestApplication application;
3385 Actor actor = Actor::New();
3387 // Register a float property
3388 float startValue(10.0f);
3389 Property::Index index = actor.RegisterProperty( "test-property", startValue );
3390 Stage::GetCurrent().Add(actor);
3391 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
3393 // Build the animation
3394 float durationSeconds(1.0f);
3395 Animation animation = Animation::New(durationSeconds);
3396 float targetValue(30.0f);
3397 float relativeValue(targetValue - startValue);
3399 animation.AnimateTo(Property(actor, index),
3401 AlphaFunctions::Linear,
3402 TimePeriod(delay, durationSeconds - delay));
3404 // Start the animation
3407 bool signalReceived(false);
3408 AnimationFinishCheck finishCheck(signalReceived);
3409 animation.FinishedSignal().Connect(&application, finishCheck);
3411 application.SendNotification();
3412 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
3414 // We didn't expect the animation to finish yet
3415 application.SendNotification();
3416 finishCheck.CheckSignalNotReceived();
3417 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
3419 application.SendNotification();
3420 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
3422 // We didn't expect the animation to finish yet
3423 application.SendNotification();
3424 finishCheck.CheckSignalNotReceived();
3425 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
3427 application.SendNotification();
3428 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
3430 // We did expect the animation to finish
3431 application.SendNotification();
3432 finishCheck.CheckSignalReceived();
3433 DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
3437 int UtcDaliAnimationAnimateToInteger(void)
3439 TestApplication application;
3441 Actor actor = Actor::New();
3443 // Register an integer property
3445 Property::Index index = actor.RegisterProperty( "test-property", startValue );
3446 Stage::GetCurrent().Add(actor);
3447 DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
3449 // Build the animation
3450 float durationSeconds(2.0f);
3451 Animation animation = Animation::New(durationSeconds);
3452 int targetValue(50);
3453 int relativeValue(targetValue - startValue);
3454 animation.AnimateTo(Property(actor, "test-property"), targetValue);
3456 int ninetyFivePercentProgress(static_cast<int>(startValue + relativeValue*0.95f + 0.5f));
3458 // Start the animation
3461 bool signalReceived(false);
3462 AnimationFinishCheck finishCheck(signalReceived);
3463 animation.FinishedSignal().Connect(&application, finishCheck);
3465 application.SendNotification();
3466 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3468 // We didn't expect the animation to finish yet
3469 application.SendNotification();
3470 finishCheck.CheckSignalNotReceived();
3471 DALI_TEST_EQUALS( actor.GetProperty<int>(index), ninetyFivePercentProgress, TEST_LOCATION );
3473 application.SendNotification();
3474 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3476 // We did expect the animation to finish
3477 application.SendNotification();
3478 finishCheck.CheckSignalReceived();
3479 DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
3483 int UtcDaliAnimationAnimateToIntegerAlphaFunction(void)
3485 TestApplication application;
3487 Actor actor = Actor::New();
3489 // Register an integer property
3491 Property::Index index = actor.RegisterProperty( "test-property", startValue );
3492 Stage::GetCurrent().Add(actor);
3493 DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
3495 // Build the animation
3496 float durationSeconds(1.0f);
3497 Animation animation = Animation::New(durationSeconds);
3498 int targetValue(90);
3499 int relativeValue(targetValue - startValue);
3500 animation.AnimateTo(Property(actor, index), targetValue, AlphaFunctions::EaseOut);
3502 int ninetyFivePercentProgress(static_cast<int>(startValue + relativeValue*0.95f + 0.5f));
3504 // Start the animation
3507 bool signalReceived(false);
3508 AnimationFinishCheck finishCheck(signalReceived);
3509 animation.FinishedSignal().Connect(&application, finishCheck);
3511 application.SendNotification();
3512 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3514 // We didn't expect the animation to finish yet
3515 application.SendNotification();
3516 finishCheck.CheckSignalNotReceived();
3518 // The position should have moved more, than with a linear alpha function
3519 int current(actor.GetProperty<int>(index));
3520 DALI_TEST_CHECK( current > ninetyFivePercentProgress );
3522 application.SendNotification();
3523 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3525 // We did expect the animation to finish
3526 application.SendNotification();
3527 finishCheck.CheckSignalReceived();
3528 DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
3532 int UtcDaliAnimationAnimateToIntegerTimePeriod(void)
3534 TestApplication application;
3536 Actor actor = Actor::New();
3538 // Register an integer property
3540 Property::Index index = actor.RegisterProperty( "test-property", startValue );
3541 Stage::GetCurrent().Add(actor);
3542 DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
3544 // Build the animation
3545 float durationSeconds(1.0f);
3546 Animation animation = Animation::New(durationSeconds);
3547 int targetValue(30);
3548 int relativeValue(targetValue - startValue);
3550 animation.AnimateTo(Property(actor, index),
3552 TimePeriod(delay, durationSeconds - delay));
3554 // Start the animation
3557 bool signalReceived(false);
3558 AnimationFinishCheck finishCheck(signalReceived);
3559 animation.FinishedSignal().Connect(&application, finishCheck);
3561 application.SendNotification();
3562 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
3564 // We didn't expect the animation to finish yet
3565 application.SendNotification();
3566 finishCheck.CheckSignalNotReceived();
3567 DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
3569 application.SendNotification();
3570 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
3572 // We didn't expect the animation to finish yet
3573 application.SendNotification();
3574 finishCheck.CheckSignalNotReceived();
3575 DALI_TEST_EQUALS( actor.GetProperty<int>(index), static_cast<int>(startValue+(relativeValue*0.5f)+0.5f), TEST_LOCATION );
3577 application.SendNotification();
3578 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
3580 // We did expect the animation to finish
3581 application.SendNotification();
3582 finishCheck.CheckSignalReceived();
3583 DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
3587 int UtcDaliAnimationAnimateToIntegerAlphaFunctionTimePeriod(void)
3589 TestApplication application;
3591 Actor actor = Actor::New();
3593 // Register an integer property
3595 Property::Index index = actor.RegisterProperty( "test-property", startValue );
3596 Stage::GetCurrent().Add(actor);
3597 DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
3599 // Build the animation
3600 float durationSeconds(1.0f);
3601 Animation animation = Animation::New(durationSeconds);
3602 int targetValue(30);
3603 int relativeValue(targetValue - startValue);
3605 animation.AnimateTo(Property(actor, index),
3607 AlphaFunctions::Linear,
3608 TimePeriod(delay, durationSeconds - delay));
3610 // Start the animation
3613 bool signalReceived(false);
3614 AnimationFinishCheck finishCheck(signalReceived);
3615 animation.FinishedSignal().Connect(&application, finishCheck);
3617 application.SendNotification();
3618 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
3620 // We didn't expect the animation to finish yet
3621 application.SendNotification();
3622 finishCheck.CheckSignalNotReceived();
3623 DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
3625 application.SendNotification();
3626 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
3628 // We didn't expect the animation to finish yet
3629 application.SendNotification();
3630 finishCheck.CheckSignalNotReceived();
3631 DALI_TEST_EQUALS( actor.GetProperty<int>(index), static_cast<int>(startValue+(relativeValue*0.5f)+0.5f), TEST_LOCATION );
3633 application.SendNotification();
3634 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
3636 // We did expect the animation to finish
3637 application.SendNotification();
3638 finishCheck.CheckSignalReceived();
3639 DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
3643 int UtcDaliAnimationAnimateToVector2(void)
3645 TestApplication application;
3647 Actor actor = Actor::New();
3649 // Register a Vector2 property
3650 Vector2 startValue(-50.0f, -50.0f);
3651 Property::Index index = actor.RegisterProperty( "test-property", startValue );
3652 Stage::GetCurrent().Add(actor);
3653 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
3655 // Build the animation
3656 float durationSeconds(2.0f);
3657 Animation animation = Animation::New(durationSeconds);
3658 Vector2 targetValue(50.0f, 50.0f);
3659 Vector2 relativeValue(targetValue - startValue);
3660 animation.AnimateTo(Property(actor, index), targetValue);
3662 Vector2 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
3664 // Start the animation
3667 bool signalReceived(false);
3668 AnimationFinishCheck finishCheck(signalReceived);
3669 animation.FinishedSignal().Connect(&application, finishCheck);
3671 application.SendNotification();
3672 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3674 // We didn't expect the animation to finish yet
3675 application.SendNotification();
3676 finishCheck.CheckSignalNotReceived();
3677 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), ninetyFivePercentProgress, TEST_LOCATION );
3679 application.SendNotification();
3680 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3682 // We did expect the animation to finish
3683 application.SendNotification();
3684 finishCheck.CheckSignalReceived();
3685 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
3689 int UtcDaliAnimationAnimateToVector2AlphaFunction(void)
3691 TestApplication application;
3693 Actor actor = Actor::New();
3695 // Register a Vector2 property
3696 Vector2 startValue(1000.0f, 1000.0f);
3697 Property::Index index = actor.RegisterProperty( "test-property", startValue );
3698 Stage::GetCurrent().Add(actor);
3699 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
3701 // Build the animation
3702 float durationSeconds(1.0f);
3703 Animation animation = Animation::New(durationSeconds);
3704 Vector2 targetValue(9000.0f, 9000.0f);
3705 Vector2 relativeValue(targetValue - startValue);
3706 animation.AnimateTo(Property(actor, "test-property"), targetValue, AlphaFunctions::EaseOut);
3708 Vector2 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
3710 // Start the animation
3713 bool signalReceived(false);
3714 AnimationFinishCheck finishCheck(signalReceived);
3715 animation.FinishedSignal().Connect(&application, finishCheck);
3717 application.SendNotification();
3718 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3720 // We didn't expect the animation to finish yet
3721 application.SendNotification();
3722 finishCheck.CheckSignalNotReceived();
3724 // The position should have moved more, than with a linear alpha function
3725 Vector2 current(actor.GetProperty<Vector2>(index));
3726 DALI_TEST_CHECK( current.x > ninetyFivePercentProgress.x );
3727 DALI_TEST_CHECK( current.y > ninetyFivePercentProgress.y );
3729 application.SendNotification();
3730 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3732 // We did expect the animation to finish
3733 application.SendNotification();
3734 finishCheck.CheckSignalReceived();
3735 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
3739 int UtcDaliAnimationAnimateToVector2TimePeriod(void)
3741 TestApplication application;
3743 Actor actor = Actor::New();
3745 // Register a Vector2 property
3746 Vector2 startValue(10.0f, 10.0f);
3747 Property::Index index = actor.RegisterProperty( "test-property", startValue );
3748 Stage::GetCurrent().Add(actor);
3749 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
3751 // Build the animation
3752 float durationSeconds(1.0f);
3753 Animation animation = Animation::New(durationSeconds);
3754 Vector2 targetValue(-10.0f, 20.0f);
3755 Vector2 relativeValue(targetValue - startValue);
3757 animation.AnimateTo(Property(actor, index),
3759 TimePeriod(delay, durationSeconds - delay));
3761 // Start the animation
3764 bool signalReceived(false);
3765 AnimationFinishCheck finishCheck(signalReceived);
3766 animation.FinishedSignal().Connect(&application, finishCheck);
3768 application.SendNotification();
3769 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
3771 // We didn't expect the animation to finish yet
3772 application.SendNotification();
3773 finishCheck.CheckSignalNotReceived();
3774 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
3776 application.SendNotification();
3777 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
3779 // We didn't expect the animation to finish yet
3780 application.SendNotification();
3781 finishCheck.CheckSignalNotReceived();
3782 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
3784 application.SendNotification();
3785 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
3787 // We did expect the animation to finish
3788 application.SendNotification();
3789 finishCheck.CheckSignalReceived();
3790 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
3794 int UtcDaliAnimationAnimateToVector2AlphaFunctionTimePeriod(void)
3796 TestApplication application;
3798 Actor actor = Actor::New();
3800 // Register a Vector2 property
3801 Vector2 startValue(10.0f, 10.0f);
3802 Property::Index index = actor.RegisterProperty( "test-property", startValue );
3803 Stage::GetCurrent().Add(actor);
3804 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
3806 // Build the animation
3807 float durationSeconds(1.0f);
3808 Animation animation = Animation::New(durationSeconds);
3809 Vector2 targetValue(30.0f, 30.0f);
3810 Vector2 relativeValue(targetValue - startValue);
3812 animation.AnimateTo(Property(actor, index),
3814 AlphaFunctions::Linear,
3815 TimePeriod(delay, durationSeconds - delay));
3817 // Start the animation
3820 bool signalReceived(false);
3821 AnimationFinishCheck finishCheck(signalReceived);
3822 animation.FinishedSignal().Connect(&application, finishCheck);
3824 application.SendNotification();
3825 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
3827 // We didn't expect the animation to finish yet
3828 application.SendNotification();
3829 finishCheck.CheckSignalNotReceived();
3830 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
3832 application.SendNotification();
3833 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
3835 // We didn't expect the animation to finish yet
3836 application.SendNotification();
3837 finishCheck.CheckSignalNotReceived();
3838 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
3840 application.SendNotification();
3841 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
3843 // We did expect the animation to finish
3844 application.SendNotification();
3845 finishCheck.CheckSignalReceived();
3846 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
3850 int UtcDaliAnimationAnimateToVector3(void)
3852 TestApplication application;
3854 Actor actor = Actor::New();
3856 // Register a Vector3 property
3857 Vector3 startValue(-50.0f, -50.0f, -50.0f);
3858 Property::Index index = actor.RegisterProperty( "test-property", startValue );
3859 Stage::GetCurrent().Add(actor);
3860 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
3862 // Build the animation
3863 float durationSeconds(2.0f);
3864 Animation animation = Animation::New(durationSeconds);
3865 Vector3 targetValue(50.0f, 50.0f, 50.0f);
3866 Vector3 relativeValue(targetValue - startValue);
3867 animation.AnimateTo(Property(actor, index), targetValue);
3869 Vector3 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
3871 // Start the animation
3874 bool signalReceived(false);
3875 AnimationFinishCheck finishCheck(signalReceived);
3876 animation.FinishedSignal().Connect(&application, finishCheck);
3878 application.SendNotification();
3879 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3881 // We didn't expect the animation to finish yet
3882 application.SendNotification();
3883 finishCheck.CheckSignalNotReceived();
3884 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), ninetyFivePercentProgress, TEST_LOCATION );
3886 application.SendNotification();
3887 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3889 // We did expect the animation to finish
3890 application.SendNotification();
3891 finishCheck.CheckSignalReceived();
3892 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
3896 int UtcDaliAnimationAnimateToVector3AlphaFunction(void)
3898 TestApplication application;
3900 Actor actor = Actor::New();
3902 // Register a Vector3 property
3903 Vector3 startValue(1000.0f, 1000.0f, 1000.0f);
3904 Property::Index index = actor.RegisterProperty( "test-property", startValue );
3905 Stage::GetCurrent().Add(actor);
3906 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
3908 // Build the animation
3909 float durationSeconds(1.0f);
3910 Animation animation = Animation::New(durationSeconds);
3911 Vector3 targetValue(9000.0f, 9000.0f, 9000.0f);
3912 Vector3 relativeValue(targetValue - startValue);
3913 animation.AnimateTo(Property(actor, index), targetValue, AlphaFunctions::EaseOut);
3915 Vector3 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
3917 // Start the animation
3920 bool signalReceived(false);
3921 AnimationFinishCheck finishCheck(signalReceived);
3922 animation.FinishedSignal().Connect(&application, finishCheck);
3924 application.SendNotification();
3925 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3927 // We didn't expect the animation to finish yet
3928 application.SendNotification();
3929 finishCheck.CheckSignalNotReceived();
3931 // The position should have moved more, than with a linear alpha function
3932 Vector3 current(actor.GetProperty<Vector3>(index));
3933 DALI_TEST_CHECK( current.x > ninetyFivePercentProgress.x );
3934 DALI_TEST_CHECK( current.y > ninetyFivePercentProgress.y );
3935 DALI_TEST_CHECK( current.z > ninetyFivePercentProgress.z );
3937 application.SendNotification();
3938 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3940 // We did expect the animation to finish
3941 application.SendNotification();
3942 finishCheck.CheckSignalReceived();
3943 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
3947 int UtcDaliAnimationAnimateToVector3TimePeriod(void)
3949 TestApplication application;
3951 Actor actor = Actor::New();
3953 // Register a Vector3 property
3954 Vector3 startValue(10.0f, 10.0f, 10.0f);
3955 Property::Index index = actor.RegisterProperty( "test-property", startValue );
3956 Stage::GetCurrent().Add(actor);
3957 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
3959 // Build the animation
3960 float durationSeconds(1.0f);
3961 Animation animation = Animation::New(durationSeconds);
3962 Vector3 targetValue(-10.0f, 20.0f, 100.0f);
3963 Vector3 relativeValue(targetValue - startValue);
3965 animation.AnimateTo(Property(actor, index),
3967 TimePeriod(delay, durationSeconds - delay));
3969 // Start the animation
3972 bool signalReceived(false);
3973 AnimationFinishCheck finishCheck(signalReceived);
3974 animation.FinishedSignal().Connect(&application, finishCheck);
3976 application.SendNotification();
3977 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
3979 // We didn't expect the animation to finish yet
3980 application.SendNotification();
3981 finishCheck.CheckSignalNotReceived();
3982 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
3984 application.SendNotification();
3985 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
3987 // We didn't expect the animation to finish yet
3988 application.SendNotification();
3989 finishCheck.CheckSignalNotReceived();
3990 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
3992 application.SendNotification();
3993 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
3995 // We did expect the animation to finish
3996 application.SendNotification();
3997 finishCheck.CheckSignalReceived();
3998 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
4002 int UtcDaliAnimationAnimateToVector3AlphaFunctionTimePeriod(void)
4004 TestApplication application;
4006 Actor actor = Actor::New();
4008 // Register a Vector3 property
4009 Vector3 startValue(10.0f, 10.0f, 10.0f);
4010 Property::Index index = actor.RegisterProperty( "test-property", startValue );
4011 Stage::GetCurrent().Add(actor);
4012 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
4014 // Build the animation
4015 float durationSeconds(1.0f);
4016 Animation animation = Animation::New(durationSeconds);
4017 Vector3 targetValue(30.0f, 30.0f, 30.0f);
4018 Vector3 relativeValue(targetValue - startValue);
4020 animation.AnimateTo(Property(actor, "test-property"),
4022 AlphaFunctions::Linear,
4023 TimePeriod(delay, durationSeconds - delay));
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*500.0f)/* 50% animation progress, 0% animator progress */);
4035 // We didn't expect the animation to finish yet
4036 application.SendNotification();
4037 finishCheck.CheckSignalNotReceived();
4038 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
4040 application.SendNotification();
4041 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
4043 // We didn't expect the animation to finish yet
4044 application.SendNotification();
4045 finishCheck.CheckSignalNotReceived();
4046 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
4048 application.SendNotification();
4049 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
4051 // We did expect the animation to finish
4052 application.SendNotification();
4053 finishCheck.CheckSignalReceived();
4054 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
4058 int UtcDaliAnimationAnimateToVector3Component(void)
4060 TestApplication application;
4062 Actor actor = Actor::New();
4064 // Register a Vector3 property
4065 Vector3 startValue(10.0f, 10.0f, 10.0f);
4066 Property::Index index = actor.RegisterProperty( "test-property", startValue );
4067 Stage::GetCurrent().Add(actor);
4068 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
4070 // Build the animation
4071 float durationSeconds(1.0f);
4072 Animation animation = Animation::New(durationSeconds);
4073 Vector3 targetValue(30.0f, 30.0f, 10.0f);
4074 Vector3 relativeValue(targetValue - startValue);
4076 animation.AnimateTo(Property(actor, "test-property", 0),
4078 AlphaFunctions::Linear,
4079 TimePeriod(delay, durationSeconds - delay));
4080 animation.AnimateTo(Property(actor, index, 1),
4082 AlphaFunctions::Linear,
4083 TimePeriod(delay, durationSeconds - delay));
4085 // Start the animation
4088 bool signalReceived(false);
4089 AnimationFinishCheck finishCheck(signalReceived);
4090 animation.FinishedSignal().Connect(&application, finishCheck);
4092 application.SendNotification();
4093 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
4095 // We didn't expect the animation to finish yet
4096 application.SendNotification();
4097 finishCheck.CheckSignalNotReceived();
4098 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
4100 application.SendNotification();
4101 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
4103 // We didn't expect the animation to finish yet
4104 application.SendNotification();
4105 finishCheck.CheckSignalNotReceived();
4106 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
4108 application.SendNotification();
4109 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
4111 // We did expect the animation to finish
4112 application.SendNotification();
4113 finishCheck.CheckSignalReceived();
4114 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
4118 int UtcDaliAnimationAnimateToVector4(void)
4120 TestApplication application;
4122 Actor actor = Actor::New();
4124 // Register a Vector4 property
4125 Vector4 startValue(-50.0f, -40.0f, -30.0f, -20.0f);
4126 Property::Index index = actor.RegisterProperty( "test-property", startValue );
4127 Stage::GetCurrent().Add(actor);
4128 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
4130 // Build the animation
4131 float durationSeconds(2.0f);
4132 Animation animation = Animation::New(durationSeconds);
4133 Vector4 targetValue(50.0f, 50.0f, 50.0f, 50.0f);
4134 Vector4 relativeValue(targetValue - startValue);
4135 animation.AnimateTo(Property(actor, index), targetValue);
4137 Vector4 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
4139 // Start the animation
4142 bool signalReceived(false);
4143 AnimationFinishCheck finishCheck(signalReceived);
4144 animation.FinishedSignal().Connect(&application, finishCheck);
4146 application.SendNotification();
4147 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
4149 // We didn't expect the animation to finish yet
4150 application.SendNotification();
4151 finishCheck.CheckSignalNotReceived();
4152 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), ninetyFivePercentProgress, TEST_LOCATION );
4154 application.SendNotification();
4155 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
4157 // We did expect the animation to finish
4158 application.SendNotification();
4159 finishCheck.CheckSignalReceived();
4160 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
4164 int UtcDaliAnimationAnimateToVector4AlphaFunction(void)
4166 TestApplication application;
4168 Actor actor = Actor::New();
4170 // Register a Vector4 property
4171 Vector4 startValue(1000.0f, 1000.0f, 1000.0f, 1000.0f);
4172 Property::Index index = actor.RegisterProperty( "test-property", startValue );
4173 Stage::GetCurrent().Add(actor);
4174 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
4176 // Build the animation
4177 float durationSeconds(1.0f);
4178 Animation animation = Animation::New(durationSeconds);
4179 Vector4 targetValue(9000.0f, 9000.0f, 9000.0f, 9000.0f);
4180 Vector4 relativeValue(targetValue - startValue);
4181 animation.AnimateTo(Property(actor, index), targetValue, AlphaFunctions::EaseOut);
4183 Vector4 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
4185 // Start the animation
4188 bool signalReceived(false);
4189 AnimationFinishCheck finishCheck(signalReceived);
4190 animation.FinishedSignal().Connect(&application, finishCheck);
4192 application.SendNotification();
4193 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
4195 // We didn't expect the animation to finish yet
4196 application.SendNotification();
4197 finishCheck.CheckSignalNotReceived();
4199 // The position should have moved more, than with a linear alpha function
4200 Vector4 current(actor.GetProperty<Vector4>(index));
4201 DALI_TEST_CHECK( current.x > ninetyFivePercentProgress.x );
4202 DALI_TEST_CHECK( current.y > ninetyFivePercentProgress.y );
4203 DALI_TEST_CHECK( current.z > ninetyFivePercentProgress.z );
4204 DALI_TEST_CHECK( current.w > ninetyFivePercentProgress.w );
4206 application.SendNotification();
4207 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
4209 // We did expect the animation to finish
4210 application.SendNotification();
4211 finishCheck.CheckSignalReceived();
4212 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
4216 int UtcDaliAnimationAnimateToVector4TimePeriod(void)
4218 TestApplication application;
4220 Actor actor = Actor::New();
4222 // Register a Vector4 property
4223 Vector4 startValue(10.0f, 10.0f, 10.0f, 10.0f);
4224 Property::Index index = actor.RegisterProperty( "test-property", startValue );
4225 Stage::GetCurrent().Add(actor);
4226 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, VECTOR4_EPSILON, TEST_LOCATION );
4228 // Build the animation
4229 float durationSeconds(1.0f);
4230 Animation animation = Animation::New(durationSeconds);
4231 Vector4 targetValue(-10.0f, 20.0f, 100.0f, 100.0f);
4232 Vector4 relativeValue(targetValue - startValue);
4234 animation.AnimateTo(Property(actor, index),
4236 TimePeriod(delay, durationSeconds - delay));
4238 // Start the animation
4241 bool signalReceived(false);
4242 AnimationFinishCheck finishCheck(signalReceived);
4243 animation.FinishedSignal().Connect(&application, finishCheck);
4245 application.SendNotification();
4246 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
4248 // We didn't expect the animation to finish yet
4249 application.SendNotification();
4250 finishCheck.CheckSignalNotReceived();
4251 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, VECTOR4_EPSILON, TEST_LOCATION );
4253 application.SendNotification();
4254 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
4256 // We didn't expect the animation to finish yet
4257 application.SendNotification();
4258 finishCheck.CheckSignalNotReceived();
4259 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue+(relativeValue*0.5f), VECTOR4_EPSILON, TEST_LOCATION );
4261 application.SendNotification();
4262 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
4264 // We did expect the animation to finish
4265 application.SendNotification();
4266 finishCheck.CheckSignalReceived();
4267 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, VECTOR4_EPSILON, TEST_LOCATION );
4271 int UtcDaliAnimationAnimateToVector4AlphaFunctionTimePeriod(void)
4273 TestApplication application;
4275 Actor actor = Actor::New();
4277 // Register a Vector4 property
4278 Vector4 startValue(10.0f, 10.0f, 10.0f, 10.0f);
4279 Property::Index index = actor.RegisterProperty( "test-property", startValue );
4280 Stage::GetCurrent().Add(actor);
4281 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
4283 // Build the animation
4284 float durationSeconds(1.0f);
4285 Animation animation = Animation::New(durationSeconds);
4286 Vector4 targetValue(30.0f, 30.0f, 30.0f, 30.0f);
4287 Vector4 relativeValue(targetValue - startValue);
4289 animation.AnimateTo(Property(actor, index),
4291 AlphaFunctions::Linear,
4292 TimePeriod(delay, durationSeconds - delay));
4294 // Start the animation
4297 bool signalReceived(false);
4298 AnimationFinishCheck finishCheck(signalReceived);
4299 animation.FinishedSignal().Connect(&application, finishCheck);
4301 application.SendNotification();
4302 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
4304 // We didn't expect the animation to finish yet
4305 application.SendNotification();
4306 finishCheck.CheckSignalNotReceived();
4307 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
4309 application.SendNotification();
4310 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
4312 // We didn't expect the animation to finish yet
4313 application.SendNotification();
4314 finishCheck.CheckSignalNotReceived();
4315 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
4317 application.SendNotification();
4318 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
4320 // We did expect the animation to finish
4321 application.SendNotification();
4322 finishCheck.CheckSignalReceived();
4323 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
4327 int UtcDaliAnimationAnimateToActorParentOrigin(void)
4329 TestApplication application;
4331 Actor actor = Actor::New();
4332 Stage::GetCurrent().Add(actor);
4333 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::TOP_LEFT, TEST_LOCATION );
4335 // Build the animation
4336 float durationSeconds(1.0f);
4337 Animation animation = Animation::New(durationSeconds);
4338 Vector3 targetParentOrigin(ParentOrigin::BOTTOM_RIGHT);
4342 animation.AnimateTo( Property(actor, Actor::PARENT_ORIGIN), targetParentOrigin );
4344 catch (Dali::DaliException& e)
4346 tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
4347 DALI_TEST_ASSERT(e, "IsPropertyAnimatable(index)", TEST_LOCATION);
4352 int UtcDaliAnimationAnimateToActorParentOriginX(void)
4354 TestApplication application;
4356 Actor actor = Actor::New();
4357 Stage::GetCurrent().Add(actor);
4358 float startValue(0.0f);
4359 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin().x, startValue, TEST_LOCATION );
4360 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::PARENT_ORIGIN_X), startValue, TEST_LOCATION );
4362 // Build the animation
4363 float durationSeconds(1.0f);
4364 Animation animation = Animation::New(durationSeconds);
4365 float targetX(1.0f);
4369 animation.AnimateTo( Property(actor, Actor::PARENT_ORIGIN_X), targetX );
4371 catch (Dali::DaliException& e)
4373 tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
4374 DALI_TEST_ASSERT(e, "IsPropertyAnimatable(index)", TEST_LOCATION);
4379 int UtcDaliAnimationAnimateToActorParentOriginY(void)
4381 TestApplication application;
4383 Actor actor = Actor::New();
4384 Stage::GetCurrent().Add(actor);
4385 float startValue(0.0f);
4386 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin().y, startValue, TEST_LOCATION );
4387 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::PARENT_ORIGIN_Y), startValue, TEST_LOCATION );
4389 // Build the animation
4390 float durationSeconds(1.0f);
4391 Animation animation = Animation::New(durationSeconds);
4392 float targetY(1.0f);
4396 animation.AnimateTo( Property(actor, Actor::PARENT_ORIGIN_Y), targetY );
4398 catch (Dali::DaliException& e)
4400 tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
4401 DALI_TEST_ASSERT(e, "IsPropertyAnimatable(index)", TEST_LOCATION);
4406 int UtcDaliAnimationAnimateToActorParentOriginZ(void)
4408 TestApplication application;
4410 Actor actor = Actor::New();
4411 Stage::GetCurrent().Add(actor);
4412 float startValue(0.5f);
4413 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin().z, startValue, TEST_LOCATION );
4414 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::PARENT_ORIGIN_Z), startValue, TEST_LOCATION );
4416 // Build the animation
4417 float durationSeconds(1.0f);
4418 Animation animation = Animation::New(durationSeconds);
4419 float targetZ(1.0f);
4423 animation.AnimateTo( Property(actor, Actor::PARENT_ORIGIN_Z), targetZ );
4425 catch (Dali::DaliException& e)
4427 tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
4428 DALI_TEST_ASSERT(e, "IsPropertyAnimatable(index)", TEST_LOCATION);
4433 int UtcDaliAnimationAnimateToActorAnchorPoint(void)
4435 TestApplication application;
4437 Actor actor = Actor::New();
4438 Stage::GetCurrent().Add(actor);
4439 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), AnchorPoint::CENTER, TEST_LOCATION );
4441 // Build the animation
4442 float durationSeconds(1.0f);
4443 Animation animation = Animation::New(durationSeconds);
4444 Vector3 targetAnchorPoint(AnchorPoint::TOP_LEFT);
4448 animation.AnimateTo( Property(actor, Actor::ANCHOR_POINT), targetAnchorPoint);
4450 catch (Dali::DaliException& e)
4452 tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
4453 DALI_TEST_ASSERT(e, "IsPropertyAnimatable(index)", TEST_LOCATION);
4458 int UtcDaliAnimationAnimateToActorAnchorPointX(void)
4460 TestApplication application;
4462 Actor actor = Actor::New();
4463 Stage::GetCurrent().Add(actor);
4464 float startValue(0.5f);
4465 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint().x, startValue, TEST_LOCATION );
4466 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::ANCHOR_POINT_X), startValue, TEST_LOCATION );
4468 // Build the animation
4469 float durationSeconds(1.0f);
4470 Animation animation = Animation::New(durationSeconds);
4471 float targetX(1.0f);
4475 animation.AnimateTo( Property(actor, Actor::ANCHOR_POINT_X), targetX );
4477 catch (Dali::DaliException& e)
4479 tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
4480 DALI_TEST_ASSERT(e, "IsPropertyAnimatable(index)", TEST_LOCATION);
4485 int UtcDaliAnimationAnimateToActorAnchorPointY(void)
4487 TestApplication application;
4489 Actor actor = Actor::New();
4490 Stage::GetCurrent().Add(actor);
4491 float startValue(0.5f);
4492 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint().y, startValue, TEST_LOCATION );
4493 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::ANCHOR_POINT_Y), startValue, TEST_LOCATION );
4495 // Build the animation
4496 float durationSeconds(1.0f);
4497 Animation animation = Animation::New(durationSeconds);
4498 float targetY(0.0f);
4502 animation.AnimateTo( Property(actor, Actor::ANCHOR_POINT_Y), targetY );
4504 catch (Dali::DaliException& e)
4506 tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
4507 DALI_TEST_ASSERT(e, "IsPropertyAnimatable(index)", TEST_LOCATION);
4512 int UtcDaliAnimationAnimateToActorAnchorPointZ(void)
4514 TestApplication application;
4516 Actor actor = Actor::New();
4517 Stage::GetCurrent().Add(actor);
4518 float startValue(0.5f);
4519 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint().z, startValue, TEST_LOCATION );
4520 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::ANCHOR_POINT_Z), startValue, TEST_LOCATION );
4522 // Build the animation
4523 float durationSeconds(1.0f);
4524 Animation animation = Animation::New(durationSeconds);
4525 float targetZ(100.0f);
4529 animation.AnimateTo( Property(actor, Actor::ANCHOR_POINT_Z), targetZ );
4531 catch (Dali::DaliException& e)
4533 tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
4534 DALI_TEST_ASSERT(e, "IsPropertyAnimatable(index)", TEST_LOCATION);
4539 int UtcDaliAnimationAnimateToActorSize(void)
4541 TestApplication application;
4543 Actor actor = Actor::New();
4544 Stage::GetCurrent().Add(actor);
4545 DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
4547 // Build the animation
4548 float durationSeconds(1.0f);
4549 Animation animation = Animation::New(durationSeconds);
4550 Vector3 targetSize(100.0f, 100.0f, 100.0f);
4551 animation.AnimateTo( Property(actor, Actor::SIZE), targetSize );
4553 Vector3 ninetyNinePercentProgress(targetSize * 0.99f);
4555 // Start the animation
4558 bool signalReceived(false);
4559 AnimationFinishCheck finishCheck(signalReceived);
4560 animation.FinishedSignal().Connect(&application, finishCheck);
4562 application.SendNotification();
4563 application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
4565 // We didn't expect the animation to finish yet
4566 application.SendNotification();
4567 finishCheck.CheckSignalNotReceived();
4568 DALI_TEST_EQUALS( actor.GetCurrentSize(), ninetyNinePercentProgress, TEST_LOCATION );
4570 application.SendNotification();
4571 application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
4573 // We did expect the animation to finish
4574 application.SendNotification();
4575 finishCheck.CheckSignalReceived();
4576 DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION );
4579 finishCheck.Reset();
4580 actor.SetSize(Vector3::ZERO);
4581 application.SendNotification();
4582 application.Render(0);
4583 DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
4585 // Repeat with a different (ease-in) alpha function
4586 animation = Animation::New(durationSeconds);
4587 animation.AnimateTo( Property(actor, Actor::SIZE), targetSize, AlphaFunctions::EaseIn);
4588 animation.FinishedSignal().Connect(&application, finishCheck);
4591 application.SendNotification();
4592 application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
4594 // We didn't expect the animation to finish yet
4595 application.SendNotification();
4596 finishCheck.CheckSignalNotReceived();
4598 // The size should have travelled less, than with a linear alpha function
4599 Vector3 current(actor.GetCurrentSize());
4600 DALI_TEST_CHECK( current.x > 0.0f );
4601 DALI_TEST_CHECK( current.y > 0.0f );
4602 DALI_TEST_CHECK( current.z > 0.0f );
4603 DALI_TEST_CHECK( current.x < ninetyNinePercentProgress.x );
4604 DALI_TEST_CHECK( current.y < ninetyNinePercentProgress.y );
4605 DALI_TEST_CHECK( current.z < ninetyNinePercentProgress.z );
4607 application.SendNotification();
4608 application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
4610 // We did expect the animation to finish
4611 application.SendNotification();
4612 finishCheck.CheckSignalReceived();
4613 DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION );
4616 finishCheck.Reset();
4617 actor.SetSize(Vector3::ZERO);
4618 application.SendNotification();
4619 application.Render(0);
4620 DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
4622 // Repeat with a delay
4624 animation = Animation::New(durationSeconds);
4625 animation.AnimateTo( Property(actor, Actor::SIZE), targetSize, AlphaFunctions::Linear, TimePeriod(delay, durationSeconds - delay));
4626 animation.FinishedSignal().Connect(&application, finishCheck);
4629 application.SendNotification();
4630 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
4632 // We didn't expect the animation to finish yet
4633 application.SendNotification();
4634 finishCheck.CheckSignalNotReceived();
4635 DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
4637 application.SendNotification();
4638 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
4640 // We did expect the animation to finish
4641 application.SendNotification();
4642 finishCheck.CheckSignalReceived();
4643 DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION );
4647 int UtcDaliAnimationAnimateToActorSizeWidth(void)
4649 TestApplication application;
4651 Actor actor = Actor::New();
4652 Stage::GetCurrent().Add(actor);
4653 float startValue(0.0f);
4654 DALI_TEST_EQUALS( actor.GetCurrentSize().width, startValue, TEST_LOCATION );
4655 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SIZE_WIDTH), startValue, TEST_LOCATION );
4657 // Build the animation
4658 float durationSeconds(1.0f);
4659 Animation animation = Animation::New(durationSeconds);
4660 float targetWidth(10.0f);
4661 animation.AnimateTo( Property(actor, Actor::SIZE_WIDTH), targetWidth );
4663 float fiftyPercentProgress(startValue + (targetWidth - startValue)*0.5f);
4665 // Start the animation
4668 bool signalReceived(false);
4669 AnimationFinishCheck finishCheck(signalReceived);
4670 animation.FinishedSignal().Connect(&application, finishCheck);
4672 application.SendNotification();
4673 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
4675 // We didn't expect the animation to finish yet
4676 application.SendNotification();
4677 finishCheck.CheckSignalNotReceived();
4678 DALI_TEST_EQUALS( actor.GetCurrentSize().width, fiftyPercentProgress, TEST_LOCATION );
4679 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SIZE_WIDTH), fiftyPercentProgress, TEST_LOCATION );
4681 application.SendNotification();
4682 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
4684 // We did expect the animation to finish
4685 application.SendNotification();
4686 finishCheck.CheckSignalReceived();
4687 DALI_TEST_EQUALS( actor.GetCurrentSize().width, targetWidth, TEST_LOCATION );
4688 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SIZE_WIDTH), targetWidth, TEST_LOCATION );
4692 int UtcDaliAnimationAnimateToActorSizeHeight(void)
4694 TestApplication application;
4696 Actor actor = Actor::New();
4697 Stage::GetCurrent().Add(actor);
4698 float startValue(0.0f);
4699 DALI_TEST_EQUALS( actor.GetCurrentSize().height, startValue, TEST_LOCATION );
4700 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SIZE_HEIGHT), startValue, TEST_LOCATION );
4702 // Build the animation
4703 float durationSeconds(1.0f);
4704 Animation animation = Animation::New(durationSeconds);
4705 float targetHeight(-10.0f);
4706 animation.AnimateTo( Property(actor, Actor::SIZE_HEIGHT), targetHeight );
4708 float fiftyPercentProgress(startValue + (targetHeight - startValue)*0.5f);
4710 // Start the animation
4713 bool signalReceived(false);
4714 AnimationFinishCheck finishCheck(signalReceived);
4715 animation.FinishedSignal().Connect(&application, finishCheck);
4717 application.SendNotification();
4718 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
4720 // We didn't expect the animation to finish yet
4721 application.SendNotification();
4722 finishCheck.CheckSignalNotReceived();
4723 DALI_TEST_EQUALS( actor.GetCurrentSize().height, fiftyPercentProgress, TEST_LOCATION );
4724 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SIZE_HEIGHT), fiftyPercentProgress, TEST_LOCATION );
4726 application.SendNotification();
4727 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
4729 // We did expect the animation to finish
4730 application.SendNotification();
4731 finishCheck.CheckSignalReceived();
4732 DALI_TEST_EQUALS( actor.GetCurrentSize().height, targetHeight, TEST_LOCATION );
4733 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SIZE_HEIGHT), targetHeight, TEST_LOCATION );
4737 int UtcDaliAnimationAnimateToActorSizeDepth(void)
4739 TestApplication application;
4741 Actor actor = Actor::New();
4742 Stage::GetCurrent().Add(actor);
4743 float startValue(0.0f);
4744 DALI_TEST_EQUALS( actor.GetCurrentSize().depth, startValue, TEST_LOCATION );
4745 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SIZE_DEPTH), startValue, TEST_LOCATION );
4747 // Build the animation
4748 float durationSeconds(1.0f);
4749 Animation animation = Animation::New(durationSeconds);
4750 float targetDepth(-10.0f);
4751 animation.AnimateTo( Property(actor, Actor::SIZE_DEPTH), targetDepth );
4753 float fiftyPercentProgress(startValue + (targetDepth - startValue)*0.5f);
4755 // Start the animation
4758 bool signalReceived(false);
4759 AnimationFinishCheck finishCheck(signalReceived);
4760 animation.FinishedSignal().Connect(&application, finishCheck);
4762 application.SendNotification();
4763 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
4765 // We didn't expect the animation to finish yet
4766 application.SendNotification();
4767 finishCheck.CheckSignalNotReceived();
4768 DALI_TEST_EQUALS( actor.GetCurrentSize().depth, fiftyPercentProgress, TEST_LOCATION );
4769 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SIZE_DEPTH), fiftyPercentProgress, TEST_LOCATION );
4771 application.SendNotification();
4772 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
4774 // We did expect the animation to finish
4775 application.SendNotification();
4776 finishCheck.CheckSignalReceived();
4777 DALI_TEST_EQUALS( actor.GetCurrentSize().depth, targetDepth, TEST_LOCATION );
4778 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SIZE_DEPTH), targetDepth, TEST_LOCATION );
4782 int UtcDaliAnimationAnimateToActorPosition(void)
4784 TestApplication application;
4786 Actor actor = Actor::New();
4787 Stage::GetCurrent().Add(actor);
4788 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
4790 // Build the animation
4791 float durationSeconds(1.0f);
4792 Animation animation = Animation::New(durationSeconds);
4793 Vector3 targetPosition(200.0f, 200.0f, 200.0f);
4794 animation.AnimateTo(Property(actor, Actor::POSITION), targetPosition);
4796 Vector3 seventyFivePercentProgress(targetPosition * 0.75f);
4798 // Start the animation
4801 bool signalReceived(false);
4802 AnimationFinishCheck finishCheck(signalReceived);
4803 animation.FinishedSignal().Connect(&application, finishCheck);
4805 application.SendNotification();
4806 application.Render(static_cast<unsigned int>(durationSeconds*750.0f)/* 75% progress */);
4808 // We didn't expect the animation to finish yet
4809 application.SendNotification();
4810 finishCheck.CheckSignalNotReceived();
4811 DALI_TEST_EQUALS( actor.GetCurrentPosition(), seventyFivePercentProgress, TEST_LOCATION );
4813 application.SendNotification();
4814 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
4816 // We did expect the animation to finish
4817 application.SendNotification();
4818 finishCheck.CheckSignalReceived();
4819 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
4823 int UtcDaliAnimationAnimateToActorPositionX(void)
4825 TestApplication application;
4827 Actor actor = Actor::New();
4828 Stage::GetCurrent().Add(actor);
4829 float startValue(0.0f);
4830 DALI_TEST_EQUALS( actor.GetCurrentPosition().x, startValue, TEST_LOCATION );
4831 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_X), startValue, TEST_LOCATION );
4832 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_Y), startValue, TEST_LOCATION );
4833 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_Z), startValue, TEST_LOCATION );
4835 // Build the animation
4836 float durationSeconds(1.0f);
4837 Animation animation = Animation::New(durationSeconds);
4838 float targetX(1.0f);
4839 animation.AnimateTo( Property(actor, Actor::POSITION_X), targetX );
4841 float fiftyPercentProgress(startValue + (targetX - startValue)*0.5f);
4843 // Start the animation
4846 bool signalReceived(false);
4847 AnimationFinishCheck finishCheck(signalReceived);
4848 animation.FinishedSignal().Connect(&application, finishCheck);
4850 application.SendNotification();
4851 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
4853 // We didn't expect the animation to finish yet
4854 application.SendNotification();
4855 finishCheck.CheckSignalNotReceived();
4856 DALI_TEST_EQUALS( actor.GetCurrentPosition().x, fiftyPercentProgress, TEST_LOCATION );
4857 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_X), fiftyPercentProgress, TEST_LOCATION );
4858 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_Y), startValue, TEST_LOCATION );
4859 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_Z), startValue, TEST_LOCATION );
4861 application.SendNotification();
4862 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
4864 // We did expect the animation to finish
4865 application.SendNotification();
4866 finishCheck.CheckSignalReceived();
4867 DALI_TEST_EQUALS( actor.GetCurrentPosition().x, targetX, TEST_LOCATION );
4868 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_X), targetX, TEST_LOCATION );
4869 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_Y), startValue, TEST_LOCATION );
4870 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_Z), startValue, TEST_LOCATION );
4874 int UtcDaliAnimationAnimateToActorPositionY(void)
4876 TestApplication application;
4878 Actor actor = Actor::New();
4879 Stage::GetCurrent().Add(actor);
4880 float startValue(0.0f);
4881 DALI_TEST_EQUALS( actor.GetCurrentPosition().y, startValue, TEST_LOCATION );
4882 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_X), startValue, TEST_LOCATION );
4883 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_Y), startValue, TEST_LOCATION );
4884 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_Z), startValue, TEST_LOCATION );
4886 // Build the animation
4887 float durationSeconds(1.0f);
4888 Animation animation = Animation::New(durationSeconds);
4889 float targetY(10.0f);
4890 animation.AnimateTo( Property(actor, Actor::POSITION_Y), targetY );
4892 float fiftyPercentProgress(startValue + (targetY - startValue)*0.5f);
4894 // Start the animation
4897 bool signalReceived(false);
4898 AnimationFinishCheck finishCheck(signalReceived);
4899 animation.FinishedSignal().Connect(&application, finishCheck);
4901 application.SendNotification();
4902 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
4904 // We didn't expect the animation to finish yet
4905 application.SendNotification();
4906 finishCheck.CheckSignalNotReceived();
4907 DALI_TEST_EQUALS( actor.GetCurrentPosition().y, fiftyPercentProgress, TEST_LOCATION );
4908 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_X), startValue, TEST_LOCATION );
4909 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_Y), fiftyPercentProgress, TEST_LOCATION );
4910 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_Z), startValue, TEST_LOCATION );
4912 application.SendNotification();
4913 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
4915 // We did expect the animation to finish
4916 application.SendNotification();
4917 finishCheck.CheckSignalReceived();
4918 DALI_TEST_EQUALS( actor.GetCurrentPosition().y, targetY, TEST_LOCATION );
4919 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_X), startValue, TEST_LOCATION );
4920 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_Y), targetY, TEST_LOCATION );
4921 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_Z), startValue, TEST_LOCATION );
4925 int UtcDaliAnimationAnimateToActorPositionZ(void)
4927 TestApplication application;
4929 Actor actor = Actor::New();
4930 Stage::GetCurrent().Add(actor);
4931 float startValue(0.0f);
4932 DALI_TEST_EQUALS( actor.GetCurrentPosition().z, startValue, TEST_LOCATION );
4933 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_X), startValue, TEST_LOCATION );
4934 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_Y), startValue, TEST_LOCATION );
4935 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_Z), startValue, TEST_LOCATION );
4937 // Build the animation
4938 float durationSeconds(1.0f);
4939 Animation animation = Animation::New(durationSeconds);
4940 float targetZ(-5.0f);
4941 animation.AnimateTo( Property(actor, Actor::POSITION_Z), targetZ );
4943 float fiftyPercentProgress(startValue + (targetZ - startValue)*0.5f);
4945 // Start the animation
4948 bool signalReceived(false);
4949 AnimationFinishCheck finishCheck(signalReceived);
4950 animation.FinishedSignal().Connect(&application, finishCheck);
4952 application.SendNotification();
4953 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
4955 // We didn't expect the animation to finish yet
4956 application.SendNotification();
4957 finishCheck.CheckSignalNotReceived();
4958 DALI_TEST_EQUALS( actor.GetCurrentPosition().z, fiftyPercentProgress, TEST_LOCATION );
4959 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_X), startValue, TEST_LOCATION );
4960 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_Y), startValue, TEST_LOCATION );
4961 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_Z), fiftyPercentProgress, TEST_LOCATION );
4963 application.SendNotification();
4964 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
4966 // We did expect the animation to finish
4967 application.SendNotification();
4968 finishCheck.CheckSignalReceived();
4969 DALI_TEST_EQUALS( actor.GetCurrentPosition().z, targetZ, TEST_LOCATION );
4970 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_X), startValue, TEST_LOCATION );
4971 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_Y), startValue, TEST_LOCATION );
4972 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_Z), targetZ, TEST_LOCATION );
4976 int UtcDaliAnimationAnimateToActorPositionAlphaFunction(void)
4978 TestApplication application;
4980 Actor actor = Actor::New();
4981 Stage::GetCurrent().Add(actor);
4982 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
4984 // Build the animation
4985 float durationSeconds(1.0f);
4986 Animation animation = Animation::New(durationSeconds);
4987 Vector3 targetPosition(200.0f, 200.0f, 200.0f);
4988 animation.AnimateTo(Property(actor, Actor::POSITION), targetPosition, AlphaFunctions::EaseIn);
4990 Vector3 seventyFivePercentProgress(targetPosition * 0.75f);
4992 // Start the animation
4995 bool signalReceived(false);
4996 AnimationFinishCheck finishCheck(signalReceived);
4997 animation.FinishedSignal().Connect(&application, finishCheck);
4999 application.SendNotification();
5000 application.Render(static_cast<unsigned int>(durationSeconds*750.0f)/* 75% progress */);
5002 // We didn't expect the animation to finish yet
5003 application.SendNotification();
5004 finishCheck.CheckSignalNotReceived();
5006 // The position should have moved less, than with a linear alpha function
5007 Vector3 current(actor.GetCurrentPosition());
5008 DALI_TEST_CHECK( current.x > Vector3::ZERO.x );
5009 DALI_TEST_CHECK( current.y > Vector3::ZERO.y );
5010 DALI_TEST_CHECK( current.z > Vector3::ZERO.z );
5011 DALI_TEST_CHECK( current.x < seventyFivePercentProgress.x );
5012 DALI_TEST_CHECK( current.y < seventyFivePercentProgress.y );
5013 DALI_TEST_CHECK( current.z < seventyFivePercentProgress.z );
5015 application.SendNotification();
5016 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
5018 // We did expect the animation to finish
5019 application.SendNotification();
5020 finishCheck.CheckSignalReceived();
5021 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
5025 int UtcDaliAnimationAnimateToActorPositionTimePeriod(void)
5027 TestApplication application;
5029 Actor actor = Actor::New();
5030 Stage::GetCurrent().Add(actor);
5031 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
5033 // Build the animation
5034 float durationSeconds(1.0f);
5035 Animation animation = Animation::New(durationSeconds);
5036 Vector3 targetPosition(200.0f, 200.0f, 200.0f);
5038 animation.AnimateTo( Property(actor, Actor::POSITION),
5040 TimePeriod( delay, durationSeconds - delay ) );
5042 Vector3 seventyFivePercentProgress(targetPosition * 0.75f);
5044 // Start the animation
5047 bool signalReceived(false);
5048 AnimationFinishCheck finishCheck(signalReceived);
5049 animation.FinishedSignal().Connect(&application, finishCheck);
5051 application.SendNotification();
5052 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
5054 // We didn't expect the animation to finish yet
5055 application.SendNotification();
5056 finishCheck.CheckSignalNotReceived();
5057 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
5059 application.SendNotification();
5060 application.Render(static_cast<unsigned int>(durationSeconds*500.0f*0.75)/* 7/8 animation progress, 3/4 animator progress */);
5062 // We didn't expect the animation to finish yet
5063 application.SendNotification();
5064 finishCheck.CheckSignalNotReceived();
5065 DALI_TEST_EQUALS( actor.GetCurrentPosition(), seventyFivePercentProgress, TEST_LOCATION );
5067 application.SendNotification();
5068 application.Render(static_cast<unsigned int>(durationSeconds*500.0f*0.25) + 1u/*just beyond the animation duration*/);
5070 // We did expect the animation to finish
5071 application.SendNotification();
5072 finishCheck.CheckSignalReceived();
5073 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
5077 int UtcDaliAnimationAnimateToActorPositionAlphaFunctionTimePeriod(void)
5079 TestApplication application;
5081 Actor actor = Actor::New();
5082 Stage::GetCurrent().Add(actor);
5083 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
5085 // Build the animation
5086 float durationSeconds(1.0f);
5087 Animation animation = Animation::New(durationSeconds);
5088 Vector3 targetPosition(200.0f, 200.0f, 200.0f);
5090 animation.AnimateTo( Property(actor, Actor::POSITION),
5092 AlphaFunctions::Linear,
5093 TimePeriod( delay, durationSeconds - delay ) );
5095 Vector3 seventyFivePercentProgress(targetPosition * 0.75f);
5097 // Start the animation
5100 bool signalReceived(false);
5101 AnimationFinishCheck finishCheck(signalReceived);
5102 animation.FinishedSignal().Connect(&application, finishCheck);
5104 application.SendNotification();
5105 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
5107 // We didn't expect the animation to finish yet
5108 application.SendNotification();
5109 finishCheck.CheckSignalNotReceived();
5110 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
5112 application.SendNotification();
5113 application.Render(static_cast<unsigned int>(durationSeconds*500.0f*0.75)/* 7/8 animation progress, 3/4 animator progress */);
5115 // We didn't expect the animation to finish yet
5116 application.SendNotification();
5117 finishCheck.CheckSignalNotReceived();
5118 DALI_TEST_EQUALS( actor.GetCurrentPosition(), seventyFivePercentProgress, TEST_LOCATION );
5120 application.SendNotification();
5121 application.Render(static_cast<unsigned int>(durationSeconds*500.0f*0.25) + 1u/*just beyond the animation duration*/);
5123 // We did expect the animation to finish
5124 application.SendNotification();
5125 finishCheck.CheckSignalReceived();
5126 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
5130 int UtcDaliAnimationAnimateToActorRotationAngleAxis(void)
5132 TestApplication application;
5134 Actor actor = Actor::New();
5135 actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
5136 Stage::GetCurrent().Add(actor);
5137 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5139 // Build the animation
5140 float durationSeconds(1.0f);
5141 Animation animation = Animation::New(durationSeconds);
5142 Degree targetRotationDegrees(90.0f);
5143 Radian targetRotationRadians(targetRotationDegrees);
5144 animation.AnimateTo( Property(actor, Actor::ROTATION), AngleAxis(targetRotationRadians, Vector3::YAXIS) );
5146 // Start the animation
5149 bool signalReceived(false);
5150 AnimationFinishCheck finishCheck(signalReceived);
5151 animation.FinishedSignal().Connect(&application, finishCheck);
5153 application.SendNotification();
5154 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
5156 // We didn't expect the animation to finish yet
5157 application.SendNotification();
5158 finishCheck.CheckSignalNotReceived();
5159 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.25f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5161 application.SendNotification();
5162 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
5164 // We didn't expect the animation to finish yet
5165 application.SendNotification();
5166 finishCheck.CheckSignalNotReceived();
5167 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.5f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5169 application.SendNotification();
5170 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
5172 // We didn't expect the animation to finish yet
5173 application.SendNotification();
5174 finishCheck.CheckSignalNotReceived();
5175 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.75f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5177 application.SendNotification();
5178 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
5180 // We did expect the animation to finish
5181 application.SendNotification();
5182 finishCheck.CheckSignalReceived();
5183 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5187 int UtcDaliAnimationAnimateToActorRotationQuaternion(void)
5189 TestApplication application;
5191 Actor actor = Actor::New();
5192 actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
5193 Stage::GetCurrent().Add(actor);
5194 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5196 // Build the animation
5197 float durationSeconds(1.0f);
5198 Animation animation = Animation::New(durationSeconds);
5199 Degree targetRotationDegrees(90.0f);
5200 Radian targetRotationRadians(targetRotationDegrees);
5201 Quaternion targetRotation(targetRotationRadians, Vector3::YAXIS);
5202 animation.AnimateTo( Property(actor, Actor::ROTATION), targetRotation );
5204 // Start the animation
5207 bool signalReceived(false);
5208 AnimationFinishCheck finishCheck(signalReceived);
5209 animation.FinishedSignal().Connect(&application, finishCheck);
5211 application.SendNotification();
5212 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
5214 // We didn't expect the animation to finish yet
5215 application.SendNotification();
5216 finishCheck.CheckSignalNotReceived();
5217 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.25f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5219 application.SendNotification();
5220 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
5222 // We didn't expect the animation to finish yet
5223 application.SendNotification();
5224 finishCheck.CheckSignalNotReceived();
5225 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.5f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5227 application.SendNotification();
5228 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
5230 // We didn't expect the animation to finish yet
5231 application.SendNotification();
5232 finishCheck.CheckSignalNotReceived();
5233 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.75f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5235 application.SendNotification();
5236 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
5238 // We did expect the animation to finish
5239 application.SendNotification();
5240 finishCheck.CheckSignalReceived();
5241 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5245 int UtcDaliAnimationAnimateToActorRotationAlphaFunction(void)
5247 TestApplication application;
5249 Actor actor = Actor::New();
5250 actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
5251 Stage::GetCurrent().Add(actor);
5252 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5254 // Build the animation
5255 float durationSeconds(1.0f);
5256 Animation animation = Animation::New(durationSeconds);
5257 Degree targetRotationDegrees(90.0f);
5258 Radian targetRotationRadians(targetRotationDegrees);
5259 animation.AnimateTo( Property(actor, Actor::ROTATION), AngleAxis(targetRotationDegrees, Vector3::YAXIS), AlphaFunctions::EaseIn);
5261 // Start the animation
5264 bool signalReceived(false);
5265 AnimationFinishCheck finishCheck(signalReceived);
5266 animation.FinishedSignal().Connect(&application, finishCheck);
5268 application.SendNotification();
5269 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
5271 // We didn't expect the animation to finish yet
5272 application.SendNotification();
5273 finishCheck.CheckSignalNotReceived();
5274 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(0.25f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5276 application.SendNotification();
5277 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
5279 // We didn't expect the animation to finish yet
5280 application.SendNotification();
5281 finishCheck.CheckSignalNotReceived();
5282 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(0.5f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5284 application.SendNotification();
5285 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
5287 // We didn't expect the animation to finish yet
5288 application.SendNotification();
5289 finishCheck.CheckSignalNotReceived();
5290 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(0.75f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5292 application.SendNotification();
5293 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
5295 // We did expect the animation to finish
5296 application.SendNotification();
5297 finishCheck.CheckSignalReceived();
5298 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5302 int UtcDaliAnimationAnimateToActorRotationTimePeriod(void)
5304 TestApplication application;
5306 Actor actor = Actor::New();
5307 actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
5308 Stage::GetCurrent().Add(actor);
5309 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5311 // Build the animation
5312 float durationSeconds(1.0f);
5313 Animation animation = Animation::New(durationSeconds);
5314 Degree targetRotationDegrees(90.0f);
5315 Radian targetRotationRadians(targetRotationDegrees);
5317 animation.AnimateTo( Property(actor, Actor::ROTATION), AngleAxis(targetRotationDegrees, Vector3::YAXIS), TimePeriod(delay, durationSeconds - delay));
5319 // Start the animation
5322 bool signalReceived(false);
5323 AnimationFinishCheck finishCheck(signalReceived);
5324 animation.FinishedSignal().Connect(&application, finishCheck);
5326 application.SendNotification();
5327 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
5329 // We didn't expect the animation to finish yet
5330 application.SendNotification();
5331 finishCheck.CheckSignalNotReceived();
5332 float progress = max(0.0f, 0.25f - delay) / (1.0f - delay);
5333 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * progress, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5335 application.SendNotification();
5336 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
5338 // We didn't expect the animation to finish yet
5339 application.SendNotification();
5340 finishCheck.CheckSignalNotReceived();
5341 progress = max(0.0f, 0.5f - delay) / (1.0f - delay);
5342 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * progress, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5344 application.SendNotification();
5345 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
5347 // We didn't expect the animation to finish yet
5348 application.SendNotification();
5349 finishCheck.CheckSignalNotReceived();
5350 progress = max(0.0f, 0.75f - delay) / (1.0f - delay);
5351 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * progress, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5353 application.SendNotification();
5354 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
5356 // We did expect the animation to finish
5357 application.SendNotification();
5358 finishCheck.CheckSignalReceived();
5359 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5363 int UtcDaliAnimationAnimateToActorRotationAlphaFunctionTimePeriod(void)
5365 TestApplication application;
5367 Actor actor = Actor::New();
5368 actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
5369 Stage::GetCurrent().Add(actor);
5370 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5372 // Build the animation
5373 float durationSeconds(1.0f);
5374 Animation animation = Animation::New(durationSeconds);
5375 Degree targetRotationDegrees(90.0f);
5376 Radian targetRotationRadians(targetRotationDegrees);
5378 animation.AnimateTo( Property(actor, Actor::ROTATION), AngleAxis(targetRotationDegrees, Vector3::YAXIS), AlphaFunctions::EaseIn, TimePeriod(delay, durationSeconds - delay));
5380 // Start the animation
5383 bool signalReceived(false);
5384 AnimationFinishCheck finishCheck(signalReceived);
5385 animation.FinishedSignal().Connect(&application, finishCheck);
5387 application.SendNotification();
5388 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
5390 // We didn't expect the animation to finish yet
5391 application.SendNotification();
5392 finishCheck.CheckSignalNotReceived();
5393 float progress = max(0.0f, 0.25f - delay) / (1.0f - delay);
5394 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5396 application.SendNotification();
5397 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
5399 // We didn't expect the animation to finish yet
5400 application.SendNotification();
5401 finishCheck.CheckSignalNotReceived();
5402 progress = max(0.0f, 0.5f - delay) / (1.0f - delay);
5403 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5405 application.SendNotification();
5406 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
5408 // We didn't expect the animation to finish yet
5409 application.SendNotification();
5410 finishCheck.CheckSignalNotReceived();
5411 progress = max(0.0f, 0.75f - delay) / (1.0f - delay);
5412 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5414 application.SendNotification();
5415 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
5417 // We did expect the animation to finish
5418 application.SendNotification();
5419 finishCheck.CheckSignalReceived();
5420 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5424 int UtcDaliAnimationAnimateToActorScale(void)
5426 TestApplication application;
5428 Actor actor = Actor::New();
5429 Stage::GetCurrent().Add(actor);
5430 DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
5432 // Build the animation
5433 float durationSeconds(1.0f);
5434 Animation animation = Animation::New(durationSeconds);
5435 Vector3 targetScale(2.0f, 2.0f, 2.0f);
5436 animation.AnimateTo( Property(actor, Actor::SCALE), targetScale );
5438 Vector3 ninetyNinePercentProgress(Vector3::ONE + (targetScale - Vector3::ONE)*0.99f);
5440 // Start the animation
5443 bool signalReceived(false);
5444 AnimationFinishCheck finishCheck(signalReceived);
5445 animation.FinishedSignal().Connect(&application, finishCheck);
5447 application.SendNotification();
5448 application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
5450 // We didn't expect the animation to finish yet
5451 application.SendNotification();
5452 finishCheck.CheckSignalNotReceived();
5453 DALI_TEST_EQUALS( actor.GetCurrentScale(), ninetyNinePercentProgress, TEST_LOCATION );
5455 application.SendNotification();
5456 application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
5458 // We did expect the animation to finish
5459 application.SendNotification();
5460 finishCheck.CheckSignalReceived();
5461 DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
5464 finishCheck.Reset();
5465 actor.SetScale(Vector3::ONE);
5466 application.SendNotification();
5467 application.Render(0);
5468 DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
5470 // Repeat with a different (ease-in) alpha function
5471 animation = Animation::New(durationSeconds);
5472 animation.AnimateTo( Property(actor, Actor::SCALE), targetScale, AlphaFunctions::EaseIn);
5473 animation.FinishedSignal().Connect(&application, finishCheck);
5476 application.SendNotification();
5477 application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
5479 // We didn't expect the animation to finish yet
5480 application.SendNotification();
5481 finishCheck.CheckSignalNotReceived();
5483 // The scale should have grown less, than with a linear alpha function
5484 Vector3 current(actor.GetCurrentScale());
5485 DALI_TEST_CHECK( current.x > 1.0f );
5486 DALI_TEST_CHECK( current.y > 1.0f );
5487 DALI_TEST_CHECK( current.z > 1.0f );
5488 DALI_TEST_CHECK( current.x < ninetyNinePercentProgress.x );
5489 DALI_TEST_CHECK( current.y < ninetyNinePercentProgress.y );
5490 DALI_TEST_CHECK( current.z < ninetyNinePercentProgress.z );
5492 application.SendNotification();
5493 application.Render(static_cast<unsigned int>(durationSeconds*10.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.GetCurrentScale(), targetScale, TEST_LOCATION );
5501 finishCheck.Reset();
5502 actor.SetScale(Vector3::ONE);
5503 application.SendNotification();
5504 application.Render(0);
5505 DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
5507 // Repeat with a delay
5509 animation = Animation::New(durationSeconds);
5510 animation.AnimateTo( Property(actor, Actor::SCALE), targetScale, AlphaFunctions::Linear, TimePeriod(delay, durationSeconds - delay));
5511 animation.FinishedSignal().Connect(&application, finishCheck);
5514 application.SendNotification();
5515 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
5517 // We didn't expect the animation to finish yet
5518 application.SendNotification();
5519 finishCheck.CheckSignalNotReceived();
5520 DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
5522 application.SendNotification();
5523 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
5525 // We did expect the animation to finish
5526 application.SendNotification();
5527 finishCheck.CheckSignalReceived();
5528 DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
5532 int UtcDaliAnimationAnimateToActorScaleX(void)
5534 TestApplication application;
5536 Actor actor = Actor::New();
5537 Stage::GetCurrent().Add(actor);
5538 float startValue(1.0f);
5539 DALI_TEST_EQUALS( actor.GetCurrentScale().x, startValue, TEST_LOCATION );
5540 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_X), startValue, TEST_LOCATION );
5541 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_Y), startValue, TEST_LOCATION );
5542 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_Z), startValue, TEST_LOCATION );
5544 // Build the animation
5545 float durationSeconds(1.0f);
5546 Animation animation = Animation::New(durationSeconds);
5547 float targetX(10.0f);
5548 animation.AnimateTo( Property(actor, Actor::SCALE_X), targetX );
5550 float fiftyPercentProgress(startValue + (targetX - startValue)*0.5f);
5552 // Start the animation
5555 bool signalReceived(false);
5556 AnimationFinishCheck finishCheck(signalReceived);
5557 animation.FinishedSignal().Connect(&application, finishCheck);
5559 application.SendNotification();
5560 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
5562 // We didn't expect the animation to finish yet
5563 application.SendNotification();
5564 finishCheck.CheckSignalNotReceived();
5565 DALI_TEST_EQUALS( actor.GetCurrentScale().x, fiftyPercentProgress, TEST_LOCATION );
5566 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_X), fiftyPercentProgress, TEST_LOCATION );
5567 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_Y), startValue, TEST_LOCATION );
5568 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_Z), startValue, TEST_LOCATION );
5570 application.SendNotification();
5571 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
5573 // We did expect the animation to finish
5574 application.SendNotification();
5575 finishCheck.CheckSignalReceived();
5576 DALI_TEST_EQUALS( actor.GetCurrentScale().x, targetX, TEST_LOCATION );
5577 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_X), targetX, TEST_LOCATION );
5578 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_Y), startValue, TEST_LOCATION );
5579 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_Z), startValue, TEST_LOCATION );
5583 int UtcDaliAnimationAnimateToActorScaleY(void)
5585 TestApplication application;
5587 Actor actor = Actor::New();
5588 Stage::GetCurrent().Add(actor);
5589 float startValue(1.0f);
5590 DALI_TEST_EQUALS( actor.GetCurrentScale().y, startValue, TEST_LOCATION );
5591 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_X), startValue, TEST_LOCATION );
5592 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_Y), startValue, TEST_LOCATION );
5593 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_Z), startValue, TEST_LOCATION );
5595 // Build the animation
5596 float durationSeconds(1.0f);
5597 Animation animation = Animation::New(durationSeconds);
5598 float targetY(1000.0f);
5599 animation.AnimateTo( Property(actor, Actor::SCALE_Y), targetY );
5601 float fiftyPercentProgress(startValue + (targetY - startValue)*0.5f);
5603 // Start the animation
5606 bool signalReceived(false);
5607 AnimationFinishCheck finishCheck(signalReceived);
5608 animation.FinishedSignal().Connect(&application, finishCheck);
5610 application.SendNotification();
5611 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
5613 // We didn't expect the animation to finish yet
5614 application.SendNotification();
5615 finishCheck.CheckSignalNotReceived();
5616 DALI_TEST_EQUALS( actor.GetCurrentScale().y, fiftyPercentProgress, TEST_LOCATION );
5617 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_X), startValue, TEST_LOCATION );
5618 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_Y), fiftyPercentProgress, TEST_LOCATION );
5619 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_Z), startValue, TEST_LOCATION );
5621 application.SendNotification();
5622 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
5624 // We did expect the animation to finish
5625 application.SendNotification();
5626 finishCheck.CheckSignalReceived();
5627 DALI_TEST_EQUALS( actor.GetCurrentScale().y, targetY, TEST_LOCATION );
5628 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_X), startValue, TEST_LOCATION );
5629 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_Y), targetY, TEST_LOCATION );
5630 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_Z), startValue, TEST_LOCATION );
5634 int UtcDaliAnimationAnimateToActorScaleZ(void)
5636 TestApplication application;
5638 Actor actor = Actor::New();
5639 Stage::GetCurrent().Add(actor);
5640 float startValue(1.0f);
5641 DALI_TEST_EQUALS( actor.GetCurrentScale().z, startValue, TEST_LOCATION );
5642 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_X), startValue, TEST_LOCATION );
5643 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_Y), startValue, TEST_LOCATION );
5644 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_Z), startValue, TEST_LOCATION );
5646 // Build the animation
5647 float durationSeconds(1.0f);
5648 Animation animation = Animation::New(durationSeconds);
5649 float targetZ(-1000.0f);
5650 animation.AnimateTo( Property(actor, Actor::SCALE_Z), targetZ );
5652 float fiftyPercentProgress(startValue + (targetZ - startValue)*0.5f);
5654 // Start the animation
5657 bool signalReceived(false);
5658 AnimationFinishCheck finishCheck(signalReceived);
5659 animation.FinishedSignal().Connect(&application, finishCheck);
5661 application.SendNotification();
5662 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
5664 // We didn't expect the animation to finish yet
5665 application.SendNotification();
5666 finishCheck.CheckSignalNotReceived();
5667 DALI_TEST_EQUALS( actor.GetCurrentScale().z, fiftyPercentProgress, TEST_LOCATION );
5668 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_X), startValue, TEST_LOCATION );
5669 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_Y), startValue, TEST_LOCATION );
5670 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_Z), fiftyPercentProgress, TEST_LOCATION );
5672 application.SendNotification();
5673 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
5675 // We did expect the animation to finish
5676 application.SendNotification();
5677 finishCheck.CheckSignalReceived();
5678 DALI_TEST_EQUALS( actor.GetCurrentScale().z, targetZ, TEST_LOCATION );
5679 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_X), startValue, TEST_LOCATION );
5680 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_Y), startValue, TEST_LOCATION );
5681 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_Z), targetZ, TEST_LOCATION );
5685 int UtcDaliAnimationAnimateToActorColor(void)
5687 TestApplication application;
5689 Actor actor = Actor::New();
5690 Stage::GetCurrent().Add(actor);
5691 DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
5693 // Build the animation
5694 float durationSeconds(1.0f);
5695 Animation animation = Animation::New(durationSeconds);
5696 Vector4 targetColor(Color::RED);
5697 animation.AnimateTo( Property(actor, Actor::COLOR), targetColor );
5699 Vector4 tenPercentProgress(Vector4(1.0f, 0.9f, 0.9f, 1.0f));
5700 Vector4 twentyPercentProgress(Vector4(1.0f, 0.8f, 0.8f, 1.0f));
5702 // Start the animation
5705 bool signalReceived(false);
5706 AnimationFinishCheck finishCheck(signalReceived);
5707 animation.FinishedSignal().Connect(&application, finishCheck);
5709 application.SendNotification();
5710 application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% progress */);
5712 // We didn't expect the animation to finish yet
5713 application.SendNotification();
5714 finishCheck.CheckSignalNotReceived();
5715 DALI_TEST_EQUALS( actor.GetCurrentColor(), tenPercentProgress, TEST_LOCATION );
5717 application.SendNotification();
5718 application.Render(static_cast<unsigned int>(durationSeconds*900.0f) + 1u/*just beyond the animation duration*/);
5720 // We did expect the animation to finish
5721 application.SendNotification();
5722 finishCheck.CheckSignalReceived();
5723 DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION );
5726 finishCheck.Reset();
5727 actor.SetColor(Color::WHITE);
5728 application.SendNotification();
5729 application.Render(0);
5730 DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
5732 // Repeat with a different (ease-in) alpha function
5733 animation = Animation::New(durationSeconds);
5734 animation.AnimateTo( Property(actor, Actor::COLOR), targetColor, AlphaFunctions::EaseIn);
5735 animation.FinishedSignal().Connect(&application, finishCheck);
5738 application.SendNotification();
5739 application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% progress */);
5741 // We didn't expect the animation to finish yet
5742 application.SendNotification();
5743 finishCheck.CheckSignalNotReceived();
5745 // The color should have changed less, than with a linear alpha function
5746 Vector4 current(actor.GetCurrentColor());
5747 DALI_TEST_CHECK( current.x == 1.0f ); // doesn't change
5748 DALI_TEST_CHECK( current.y < 1.0f );
5749 DALI_TEST_CHECK( current.y > tenPercentProgress.y );
5750 DALI_TEST_CHECK( current.z < 1.0f );
5751 DALI_TEST_CHECK( current.z > tenPercentProgress.z );
5752 DALI_TEST_CHECK( current.w == 1.0f ); // doesn't change
5754 application.SendNotification();
5755 application.Render(static_cast<unsigned int>(durationSeconds*900.0f) + 1u/*just beyond the animation duration*/);
5757 // We did expect the animation to finish
5758 application.SendNotification();
5759 finishCheck.CheckSignalReceived();
5760 DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION );
5763 finishCheck.Reset();
5764 actor.SetColor(Color::WHITE);
5765 application.SendNotification();
5766 application.Render(0);
5767 DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
5769 // Repeat with a shorter animator duration
5770 float animatorDuration = 0.5f;
5771 animation = Animation::New(durationSeconds);
5772 animation.AnimateTo( Property(actor, Actor::COLOR), targetColor, AlphaFunctions::Linear, TimePeriod(animatorDuration));
5773 animation.FinishedSignal().Connect(&application, finishCheck);
5776 application.SendNotification();
5777 application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% animation progress, 20% animator progress */);
5779 // We didn't expect the animation to finish yet
5780 application.SendNotification();
5781 finishCheck.CheckSignalNotReceived();
5782 DALI_TEST_EQUALS( actor.GetCurrentColor(), twentyPercentProgress, TEST_LOCATION );
5784 application.SendNotification();
5785 application.Render(static_cast<unsigned int>(durationSeconds*400.0f)/* 50% animation progress, 100% animator progress */);
5787 // We didn't expect the animation to finish yet
5788 application.SendNotification();
5789 finishCheck.CheckSignalNotReceived();
5790 DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION );
5792 application.SendNotification();
5793 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
5795 // We did expect the animation to finish
5796 application.SendNotification();
5797 finishCheck.CheckSignalReceived();
5798 DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION );
5802 int UtcDaliAnimationAnimateToActorColorRed(void)
5804 TestApplication application;
5806 Actor actor = Actor::New();
5807 Stage::GetCurrent().Add(actor);
5808 float startValue(1.0f);
5809 DALI_TEST_EQUALS( actor.GetCurrentColor().r, startValue, TEST_LOCATION );
5810 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
5811 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
5812 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
5813 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), startValue, TEST_LOCATION );
5815 // Build the animation
5816 float durationSeconds(1.0f);
5817 Animation animation = Animation::New(durationSeconds);
5818 float targetRed(0.5f);
5819 animation.AnimateTo( Property(actor, Actor::COLOR_RED), targetRed );
5821 float fiftyPercentProgress(startValue + (targetRed - startValue)*0.5f);
5823 // Start the animation
5826 bool signalReceived(false);
5827 AnimationFinishCheck finishCheck(signalReceived);
5828 animation.FinishedSignal().Connect(&application, finishCheck);
5830 application.SendNotification();
5831 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
5833 // We didn't expect the animation to finish yet
5834 application.SendNotification();
5835 finishCheck.CheckSignalNotReceived();
5836 DALI_TEST_EQUALS( actor.GetCurrentColor().r, fiftyPercentProgress, TEST_LOCATION );
5837 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), fiftyPercentProgress, TEST_LOCATION );
5838 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
5839 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
5840 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), startValue, TEST_LOCATION );
5842 application.SendNotification();
5843 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
5845 // We did expect the animation to finish
5846 application.SendNotification();
5847 finishCheck.CheckSignalReceived();
5848 DALI_TEST_EQUALS( actor.GetCurrentColor().r, targetRed, TEST_LOCATION );
5849 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), targetRed, TEST_LOCATION );
5850 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
5851 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
5852 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), startValue, TEST_LOCATION );
5856 int UtcDaliAnimationAnimateToActorColorGreen(void)
5858 TestApplication application;
5860 Actor actor = Actor::New();
5861 Stage::GetCurrent().Add(actor);
5862 float startValue(1.0f);
5863 DALI_TEST_EQUALS( actor.GetCurrentColor().g, startValue, TEST_LOCATION );
5864 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
5865 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
5866 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
5867 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), startValue, TEST_LOCATION );
5869 // Build the animation
5870 float durationSeconds(1.0f);
5871 Animation animation = Animation::New(durationSeconds);
5872 float targetGreen(0.5f);
5873 animation.AnimateTo( Property(actor, Actor::COLOR_GREEN), targetGreen );
5875 float fiftyPercentProgress(startValue + (targetGreen - startValue)*0.5f);
5877 // Start the animation
5880 bool signalReceived(false);
5881 AnimationFinishCheck finishCheck(signalReceived);
5882 animation.FinishedSignal().Connect(&application, finishCheck);
5884 application.SendNotification();
5885 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
5887 // We didn't expect the animation to finish yet
5888 application.SendNotification();
5889 finishCheck.CheckSignalNotReceived();
5890 DALI_TEST_EQUALS( actor.GetCurrentColor().g, fiftyPercentProgress, TEST_LOCATION );
5891 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
5892 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), fiftyPercentProgress, TEST_LOCATION );
5893 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
5894 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), startValue, TEST_LOCATION );
5896 application.SendNotification();
5897 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
5899 // We did expect the animation to finish
5900 application.SendNotification();
5901 finishCheck.CheckSignalReceived();
5902 DALI_TEST_EQUALS( actor.GetCurrentColor().g, targetGreen, TEST_LOCATION );
5903 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
5904 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), targetGreen, TEST_LOCATION );
5905 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
5906 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), startValue, TEST_LOCATION );
5910 int UtcDaliAnimationAnimateToActorColorBlue(void)
5912 TestApplication application;
5914 Actor actor = Actor::New();
5915 Stage::GetCurrent().Add(actor);
5916 float startValue(1.0f);
5917 DALI_TEST_EQUALS( actor.GetCurrentColor().b, startValue, TEST_LOCATION );
5918 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
5919 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
5920 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
5921 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), startValue, TEST_LOCATION );
5923 // Build the animation
5924 float durationSeconds(1.0f);
5925 Animation animation = Animation::New(durationSeconds);
5926 float targetBlue(0.5f);
5927 animation.AnimateTo( Property(actor, Actor::COLOR_BLUE), targetBlue );
5929 float fiftyPercentProgress(startValue + (targetBlue - startValue)*0.5f);
5931 // Start the animation
5934 bool signalReceived(false);
5935 AnimationFinishCheck finishCheck(signalReceived);
5936 animation.FinishedSignal().Connect(&application, finishCheck);
5938 application.SendNotification();
5939 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
5941 // We didn't expect the animation to finish yet
5942 application.SendNotification();
5943 finishCheck.CheckSignalNotReceived();
5944 DALI_TEST_EQUALS( actor.GetCurrentColor().b, fiftyPercentProgress, TEST_LOCATION );
5945 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
5946 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
5947 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), fiftyPercentProgress, TEST_LOCATION );
5948 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), startValue, TEST_LOCATION );
5950 application.SendNotification();
5951 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
5953 // We did expect the animation to finish
5954 application.SendNotification();
5955 finishCheck.CheckSignalReceived();
5956 DALI_TEST_EQUALS( actor.GetCurrentColor().b, targetBlue, TEST_LOCATION );
5957 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
5958 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
5959 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), targetBlue, TEST_LOCATION );
5960 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), startValue, TEST_LOCATION );
5964 int UtcDaliAnimationAnimateToActorColorAlpha(void)
5966 TestApplication application;
5968 Actor actor = Actor::New();
5969 Stage::GetCurrent().Add(actor);
5970 float startValue(1.0f);
5971 DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
5972 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
5973 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
5974 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
5975 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), startValue, TEST_LOCATION );
5977 // Build the animation
5978 float durationSeconds(1.0f);
5979 Animation animation = Animation::New(durationSeconds);
5980 float targetAlpha(0.5f);
5981 animation.AnimateTo( Property(actor, Actor::COLOR_ALPHA), targetAlpha );
5983 float fiftyPercentProgress(startValue + (targetAlpha - startValue)*0.5f);
5985 // Start the animation
5988 bool signalReceived(false);
5989 AnimationFinishCheck finishCheck(signalReceived);
5990 animation.FinishedSignal().Connect(&application, finishCheck);
5992 application.SendNotification();
5993 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
5995 // We didn't expect the animation to finish yet
5996 application.SendNotification();
5997 finishCheck.CheckSignalNotReceived();
5998 DALI_TEST_EQUALS( actor.GetCurrentColor().a, fiftyPercentProgress, TEST_LOCATION );
5999 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
6000 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
6001 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
6002 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), fiftyPercentProgress, TEST_LOCATION );
6004 application.SendNotification();
6005 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
6007 // We did expect the animation to finish
6008 application.SendNotification();
6009 finishCheck.CheckSignalReceived();
6010 DALI_TEST_EQUALS( actor.GetCurrentColor().a, targetAlpha, TEST_LOCATION );
6011 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
6012 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
6013 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
6014 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), targetAlpha, TEST_LOCATION );
6020 int UtcDaliAnimationKeyFrames01(void)
6022 TestApplication application;
6024 KeyFrames keyFrames = KeyFrames::New();
6025 DALI_TEST_EQUALS(keyFrames.GetType(), Property::NONE, TEST_LOCATION);
6027 keyFrames.Add(0.0f, 0.1f);
6028 keyFrames.Add(0.2f, 0.5f);
6029 keyFrames.Add(0.4f, 0.0f);
6030 keyFrames.Add(0.6f, 1.0f);
6031 keyFrames.Add(0.8f, 0.7f);
6032 keyFrames.Add(1.0f, 0.9f);
6034 DALI_TEST_EQUALS(keyFrames.GetType(), Property::FLOAT, TEST_LOCATION);
6038 keyFrames.Add(1.9f, false);
6040 catch (Dali::DaliException& e)
6042 tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
6043 DALI_TEST_ASSERT(e, "mType == value.GetType()", TEST_LOCATION);
6048 int UtcDaliAnimationKeyFrames02(void)
6050 TestApplication application;
6052 KeyFrames keyFrames = KeyFrames::New();
6053 DALI_TEST_EQUALS(keyFrames.GetType(), Property::NONE, TEST_LOCATION);
6055 keyFrames.Add(0.0f, true);
6056 keyFrames.Add(0.2f, false);
6057 keyFrames.Add(0.4f, false);
6058 keyFrames.Add(0.6f, true);
6059 keyFrames.Add(0.8f, true);
6060 keyFrames.Add(1.0f, false);
6062 DALI_TEST_EQUALS(keyFrames.GetType(), Property::BOOLEAN, TEST_LOCATION);
6066 keyFrames.Add(0.7f, Vector3(1.0f, 1.0f, 1.0f));
6068 catch (Dali::DaliException& e)
6070 tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
6071 DALI_TEST_ASSERT(e, "mType == value.GetType()", TEST_LOCATION);
6077 int UtcDaliAnimationKeyFrames03(void)
6079 TestApplication application;
6081 KeyFrames keyFrames = KeyFrames::New();
6082 DALI_TEST_EQUALS(keyFrames.GetType(), Property::NONE, TEST_LOCATION);
6084 keyFrames.Add(0.0f, Vector2(0.0f, 0.0f));
6085 keyFrames.Add(0.2f, Vector2(1.0f, 1.0f));
6086 keyFrames.Add(0.4f, Vector2(2.0f, 2.0f));
6087 keyFrames.Add(0.6f, Vector2(3.0f, 5.0f));
6088 keyFrames.Add(0.8f, Vector2(4.0f, 3.0f));
6089 keyFrames.Add(1.0f, Vector2(6.0f, 2.0f));
6091 DALI_TEST_EQUALS(keyFrames.GetType(), Property::VECTOR2, TEST_LOCATION);
6095 keyFrames.Add(0.7f, Vector3(1.0f, 1.0f, 1.0f));
6097 catch (Dali::DaliException& e)
6099 tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
6100 DALI_TEST_ASSERT(e, "mType == value.GetType()", TEST_LOCATION);
6106 int UtcDaliAnimationKeyFrames04(void)
6108 TestApplication application;
6110 KeyFrames keyFrames = KeyFrames::New();
6111 DALI_TEST_EQUALS(keyFrames.GetType(), Property::NONE, TEST_LOCATION);
6113 keyFrames.Add(0.0f, Vector3(0.0f, 4.0f, 0.0f));
6114 keyFrames.Add(0.2f, Vector3(1.0f, 3.0f, 1.0f));
6115 keyFrames.Add(0.4f, Vector3(2.0f, 2.0f, 2.0f));
6116 keyFrames.Add(0.6f, Vector3(3.0f, 2.0f, 5.0f));
6117 keyFrames.Add(0.8f, Vector3(4.0f, 4.0f, 3.0f));
6118 keyFrames.Add(1.0f, Vector3(6.0f, 8.0f, 2.0f));
6120 DALI_TEST_EQUALS(keyFrames.GetType(), Property::VECTOR3, TEST_LOCATION);
6124 keyFrames.Add(0.7f, 1.0f);
6126 catch (Dali::DaliException& e)
6128 tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
6129 DALI_TEST_ASSERT(e, "mType == value.GetType()", TEST_LOCATION);
6134 int UtcDaliAnimationKeyFrames05(void)
6136 TestApplication application;
6138 KeyFrames keyFrames = KeyFrames::New();
6139 DALI_TEST_EQUALS(keyFrames.GetType(), Property::NONE, TEST_LOCATION);
6141 keyFrames.Add(0.0f, Vector4(0.0f, 0.0f, 0.0f, 0.0f));
6142 keyFrames.Add(0.2f, Vector4(1.0f, 1.0f, 1.0f, 1.0f));
6143 keyFrames.Add(0.4f, Vector4(2.0f, 2.0f, 2.0f, 2.0f));
6144 keyFrames.Add(0.6f, Vector4(3.0f, 5.0f, 3.0f, 5.0f));
6145 keyFrames.Add(0.8f, Vector4(4.0f, 3.0f, 4.0f, 3.0f));
6146 keyFrames.Add(1.0f, Vector4(6.0f, 2.0f, 6.0f, 2.0f));
6148 DALI_TEST_EQUALS(keyFrames.GetType(), Property::VECTOR4, TEST_LOCATION);
6152 keyFrames.Add(0.7f, Quaternion(1.717f, Vector3::XAXIS));
6154 catch (Dali::DaliException& e)
6156 tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
6157 DALI_TEST_ASSERT(e, "mType == value.GetType()", TEST_LOCATION);
6163 int UtcDaliAnimationKeyFrames06(void)
6165 TestApplication application;
6167 KeyFrames keyFrames = KeyFrames::New();
6168 DALI_TEST_EQUALS(keyFrames.GetType(), Property::NONE, TEST_LOCATION);
6170 keyFrames.Add(0.0f, Quaternion(1.717f, Vector3::XAXIS));
6171 keyFrames.Add(0.2f, Quaternion(2.0f, Vector3::XAXIS));
6172 keyFrames.Add(0.4f, Quaternion(3.0f, Vector3::ZAXIS));
6173 keyFrames.Add(0.6f, Quaternion(4.0f, Vector3(1.0f, 1.0f, 1.0f)));
6174 keyFrames.Add(0.8f, AngleAxis(Degree(90), Vector3::XAXIS));
6175 keyFrames.Add(1.0f, Quaternion(3.0f, Vector3::YAXIS));
6177 DALI_TEST_EQUALS(keyFrames.GetType(), Property::ROTATION, TEST_LOCATION);
6181 keyFrames.Add(0.7f, 1.1f);
6183 catch (Dali::DaliException& e)
6185 tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
6186 DALI_TEST_ASSERT(e, "mType == value.GetType()", TEST_LOCATION);
6195 int UtcDaliAnimationAnimateBetweenActorColorAlpha(void)
6197 TestApplication application;
6199 float startValue(1.0f);
6200 Actor actor = Actor::New();
6201 actor.SetColor(Vector4(startValue, startValue, startValue, startValue));
6202 Stage::GetCurrent().Add(actor);
6204 DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
6205 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
6206 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
6207 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
6208 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), startValue, TEST_LOCATION );
6210 // Build the animation
6211 float durationSeconds(1.0f);
6212 Animation animation = Animation::New(durationSeconds);
6214 KeyFrames keyFrames = KeyFrames::New();
6215 keyFrames.Add(0.0f, 0.1f);
6216 keyFrames.Add(0.2f, 0.5f);
6217 keyFrames.Add(0.4f, 0.0f);
6218 keyFrames.Add(0.6f, 1.0f);
6219 keyFrames.Add(0.8f, 0.7f);
6220 keyFrames.Add(1.0f, 0.9f);
6222 animation.AnimateBetween( Property(actor, Actor::COLOR_ALPHA), keyFrames );
6224 // Start the animation
6227 bool signalReceived(false);
6228 AnimationFinishCheck finishCheck(signalReceived);
6229 animation.FinishedSignal().Connect(&application, finishCheck);
6230 application.SendNotification();
6231 application.Render(0);
6232 application.SendNotification();
6233 finishCheck.CheckSignalNotReceived();
6234 DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.1f, TEST_LOCATION );
6236 application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% progress */);
6237 application.SendNotification();
6238 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
6239 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
6240 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
6241 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.3f, 0.01f, TEST_LOCATION );
6242 DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.3f, 0.01f, TEST_LOCATION );
6244 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 30% progress */);
6245 application.SendNotification();
6246 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
6247 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
6248 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
6249 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.25f, 0.01f, TEST_LOCATION );
6250 DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.25f, 0.01f, TEST_LOCATION );
6252 application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 40% progress */);
6253 application.SendNotification();
6254 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
6255 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
6256 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
6257 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.0f, 0.01f, TEST_LOCATION );
6258 DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.0f, 0.01f, TEST_LOCATION );
6260 application.Render(static_cast<unsigned int>(durationSeconds*400.0f)/* 80% progress */);
6261 application.SendNotification();
6262 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
6263 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
6264 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
6265 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.7f, 0.01f, TEST_LOCATION );
6266 DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.7f, 0.01f, TEST_LOCATION );
6268 application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 90% progress */);
6269 application.SendNotification();
6270 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
6271 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
6272 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
6273 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.8f, 0.01f, TEST_LOCATION );
6274 DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.8f, 0.01f, TEST_LOCATION );
6276 application.Render(static_cast<unsigned int>(durationSeconds*100.0f)+1/* 100% progress */);
6277 application.SendNotification();
6278 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
6279 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
6280 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
6281 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.9f, 0.01f, TEST_LOCATION );
6282 DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.9f, 0.01f, TEST_LOCATION );
6284 // We did expect the animation to finish
6286 finishCheck.CheckSignalReceived();
6291 int UtcDaliAnimationAnimateBetweenActorColor(void)
6293 TestApplication application;
6295 float startValue(1.0f);
6296 Actor actor = Actor::New();
6297 actor.SetColor(Vector4(startValue, startValue, startValue, startValue));
6298 Stage::GetCurrent().Add(actor);
6300 DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
6301 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
6302 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
6303 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
6304 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), startValue, TEST_LOCATION );
6306 // Build the animation
6307 float durationSeconds(1.0f);
6308 Animation animation = Animation::New(durationSeconds);
6310 KeyFrames keyFrames = KeyFrames::New();
6311 keyFrames.Add(0.0f, Vector4(0.1f, 0.2f, 0.3f, 0.4f));
6312 keyFrames.Add(0.5f, Vector4(0.9f, 0.8f, 0.7f, 0.6f));
6313 keyFrames.Add(1.0f, Vector4(1.0f, 1.0f, 1.0f, 1.0f));
6315 animation.AnimateBetween( Property(actor, Actor::COLOR), keyFrames );
6317 // Start the animation
6320 bool signalReceived(false);
6321 AnimationFinishCheck finishCheck(signalReceived);
6322 animation.FinishedSignal().Connect(&application, finishCheck);
6323 application.SendNotification();
6324 application.Render(0);
6325 application.SendNotification();
6326 finishCheck.CheckSignalNotReceived();
6327 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), 0.1f, 0.01f, TEST_LOCATION );
6328 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 0.2f, 0.01f, TEST_LOCATION );
6329 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), 0.3f, 0.01f, TEST_LOCATION );
6330 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.4f, 0.01f, TEST_LOCATION );
6332 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
6333 application.SendNotification();
6334 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), 0.5f, 0.01f, TEST_LOCATION );
6335 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 0.5f, 0.01f, TEST_LOCATION );
6336 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), 0.5f, 0.01f, TEST_LOCATION );
6337 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.5f, 0.01f, TEST_LOCATION );
6339 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
6340 application.SendNotification();
6341 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), 0.9f, 0.01f, TEST_LOCATION );
6342 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 0.8f, 0.01f, TEST_LOCATION );
6343 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), 0.7f, 0.01f, TEST_LOCATION );
6344 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.6f, 0.01f, TEST_LOCATION );
6346 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
6347 application.SendNotification();
6348 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), 0.95f, 0.01f, TEST_LOCATION );
6349 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 0.90f, 0.01f, TEST_LOCATION );
6350 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), 0.85f, 0.01f, TEST_LOCATION );
6351 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.80f, 0.01f, TEST_LOCATION );
6353 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
6354 application.SendNotification();
6355 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), 1.0f, 0.01f, TEST_LOCATION );
6356 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 1.0f, 0.01f, TEST_LOCATION );
6357 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), 1.0f, 0.01f, TEST_LOCATION );
6358 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 1.0f, 0.01f, TEST_LOCATION );
6360 // We did expect the animation to finish
6362 finishCheck.CheckSignalReceived();
6366 int UtcDaliAnimationAnimateBetweenActorVisible01(void)
6368 TestApplication application;
6370 Actor actor = Actor::New();
6371 AngleAxis aa(Degree(90), Vector3::XAXIS);
6372 actor.SetRotation(aa.angle, aa.axis);
6373 Stage::GetCurrent().Add(actor);
6375 application.SendNotification();
6376 application.Render(0);
6378 DALI_TEST_EQUALS( actor.IsVisible(), true, TEST_LOCATION );
6380 // Build the animation
6381 float durationSeconds(1.0f);
6382 Animation animation = Animation::New(durationSeconds);
6384 KeyFrames keyFrames = KeyFrames::New();
6385 keyFrames.Add(0.0f, false);
6386 keyFrames.Add(0.2f, true);
6387 keyFrames.Add(0.4f, true);
6388 keyFrames.Add(0.8f, false);
6389 keyFrames.Add(1.0f, true);
6391 animation.AnimateBetween( Property(actor, Actor::VISIBLE), keyFrames );
6393 // Start the animation
6396 bool signalReceived(false);
6397 AnimationFinishCheck finishCheck(signalReceived);
6398 animation.FinishedSignal().Connect(&application, finishCheck);
6399 application.SendNotification();
6400 application.SendNotification();
6401 application.Render(static_cast<unsigned int>(durationSeconds*500.0f));
6402 application.SendNotification();
6403 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)+1);
6404 application.SendNotification();
6406 DALI_TEST_EQUALS( actor.IsVisible(), true, TEST_LOCATION);
6407 finishCheck.CheckSignalReceived();
6411 int UtcDaliAnimationAnimateBetweenActorRotation01(void)
6413 TestApplication application;
6415 Actor actor = Actor::New();
6416 AngleAxis aa(Degree(90), Vector3::XAXIS);
6417 actor.SetRotation(aa.angle, aa.axis);
6418 Stage::GetCurrent().Add(actor);
6420 application.SendNotification();
6421 application.Render(0);
6422 Quaternion start(Radian(aa.angle), aa.axis);
6423 DALI_TEST_EQUALS( actor.GetCurrentRotation(), start, 0.001f, TEST_LOCATION );
6425 // Build the animation
6426 float durationSeconds(1.0f);
6427 Animation animation = Animation::New(durationSeconds);
6429 KeyFrames keyFrames = KeyFrames::New();
6430 keyFrames.Add(0.0f, AngleAxis(Degree(60), Vector3::ZAXIS));
6432 animation.AnimateBetween( Property(actor, Actor::ROTATION), keyFrames );
6434 // Start the animation
6437 bool signalReceived(false);
6438 AnimationFinishCheck finishCheck(signalReceived);
6439 animation.FinishedSignal().Connect(&application, finishCheck);
6440 application.SendNotification();
6441 application.SendNotification();
6442 application.Render(static_cast<unsigned int>(durationSeconds*500.0f));
6443 application.SendNotification();
6444 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)+1);
6445 application.SendNotification();
6447 Quaternion check = Quaternion::FromAxisAngle(Vector4::ZAXIS, Radian(Degree(60)));
6449 DALI_TEST_EQUALS( actor.GetCurrentRotation(), check, 0.001f, TEST_LOCATION );
6450 finishCheck.CheckSignalReceived();
6454 int UtcDaliAnimationAnimateBetweenActorRotation02(void)
6456 TestApplication application;
6458 Actor actor = Actor::New();
6459 AngleAxis aa(Degree(90), Vector3::XAXIS);
6460 actor.SetRotation(aa.angle, aa.axis);
6461 application.SendNotification();
6462 application.Render(0);
6463 Stage::GetCurrent().Add(actor);
6465 Quaternion start(Radian(aa.angle), aa.axis);
6466 DALI_TEST_EQUALS( actor.GetCurrentRotation(), start, 0.001f, TEST_LOCATION );
6468 // Build the animation
6469 float durationSeconds(1.0f);
6470 Animation animation = Animation::New(durationSeconds);
6472 KeyFrames keyFrames = KeyFrames::New();
6473 keyFrames.Add(0.0f, AngleAxis(Degree(60), Vector3::XAXIS));
6474 keyFrames.Add(0.5f, AngleAxis(Degree(120), Vector3::XAXIS));
6475 keyFrames.Add(1.0f, AngleAxis(Degree(120), Vector3::YAXIS));
6477 animation.AnimateBetween( Property(actor, Actor::ROTATION), keyFrames );
6479 // Start the animation
6482 bool signalReceived(false);
6483 AnimationFinishCheck finishCheck(signalReceived);
6484 animation.FinishedSignal().Connect(&application, finishCheck);
6485 application.SendNotification();
6486 application.Render(0);
6487 application.SendNotification();
6488 finishCheck.CheckSignalNotReceived();
6490 Quaternion check(Radian(Degree(60)), Vector3::XAXIS);
6491 DALI_TEST_EQUALS( actor.GetCurrentRotation(), check, 0.001f, TEST_LOCATION );
6493 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
6494 application.SendNotification();
6495 check = Quaternion::FromAxisAngle(Vector4::XAXIS, Radian(Degree(90)));
6496 DALI_TEST_EQUALS( actor.GetCurrentRotation(), check, 0.001f, TEST_LOCATION );
6498 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
6499 application.SendNotification();
6500 check = Quaternion::FromAxisAngle(Vector4::XAXIS, Radian(Degree(120)));
6501 DALI_TEST_EQUALS( actor.GetCurrentRotation(), check, 0.001f, TEST_LOCATION );
6503 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
6504 application.SendNotification();
6505 check = Quaternion::FromAxisAngle(Vector4(0.5f, 0.5f, 0.0f, 0.0f), Radian(Degree(101.5)));
6506 DALI_TEST_EQUALS( actor.GetCurrentRotation(), check, 0.001f, TEST_LOCATION );
6508 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
6509 application.SendNotification();
6510 check = Quaternion::FromAxisAngle(Vector4::YAXIS, Radian(Degree(120)));
6511 DALI_TEST_EQUALS( actor.GetCurrentRotation(), check, 0.001f, TEST_LOCATION );
6513 // We did expect the animation to finish
6515 finishCheck.CheckSignalReceived();
6519 int UtcDaliAnimationMoveByFloat3(void)
6521 TestApplication application;
6523 Actor actor = Actor::New();
6524 Vector3 startPosition(10.0f, 10.0f, 10.0f);
6525 actor.SetPosition(startPosition);
6526 Stage::GetCurrent().Add(actor);
6527 application.SendNotification();
6528 application.Render(0);
6529 DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION );
6531 // Build the animation
6532 float durationSeconds(1.0f);
6533 Animation animation = Animation::New(durationSeconds);
6534 Vector3 targetPosition(20.0f, 20.0f, 20.0f);
6535 Vector3 relativePosition(targetPosition - startPosition);
6536 animation.MoveBy(actor, relativePosition.x, relativePosition.y, relativePosition.z);
6538 Vector3 ninetyFivePercentProgress(startPosition + relativePosition*0.95f);
6540 // Start the animation
6543 bool signalReceived(false);
6544 AnimationFinishCheck finishCheck(signalReceived);
6545 animation.FinishedSignal().Connect(&application, finishCheck);
6547 application.SendNotification();
6548 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
6550 // We didn't expect the animation to finish yet
6551 application.SendNotification();
6552 finishCheck.CheckSignalNotReceived();
6553 DALI_TEST_EQUALS( actor.GetCurrentPosition(), ninetyFivePercentProgress, TEST_LOCATION );
6555 application.SendNotification();
6556 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
6558 // We did expect the animation to finish
6559 application.SendNotification();
6560 finishCheck.CheckSignalReceived();
6561 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
6565 int UtcDaliAnimationMoveByVector3Alpha(void)
6567 TestApplication application;
6569 Actor actor = Actor::New();
6570 Vector3 startPosition(10.0f, 10.0f, 10.0f);
6571 actor.SetPosition(startPosition);
6572 Stage::GetCurrent().Add(actor);
6573 application.SendNotification();
6574 application.Render(0);
6575 DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION );
6577 // Build the animation
6578 float durationSeconds(1.0f);
6579 Animation animation = Animation::New(durationSeconds);
6580 Vector3 targetPosition(20.0f, 20.0f, 20.0f);
6581 Vector3 relativePosition(targetPosition - startPosition);
6582 animation.MoveBy(actor, relativePosition, AlphaFunctions::EaseOut);
6584 Vector3 ninetyFivePercentProgress(startPosition + relativePosition*0.95f);
6586 // Start the animation
6589 bool signalReceived(false);
6590 AnimationFinishCheck finishCheck(signalReceived);
6591 animation.FinishedSignal().Connect(&application, finishCheck);
6593 application.SendNotification();
6594 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
6596 // We didn't expect the animation to finish yet
6597 application.SendNotification();
6598 finishCheck.CheckSignalNotReceived();
6600 // The position should have moved more, than with a linear alpha function
6601 Vector3 current(actor.GetCurrentPosition());
6602 DALI_TEST_CHECK( current.x > ninetyFivePercentProgress.x );
6603 DALI_TEST_CHECK( current.y > ninetyFivePercentProgress.y );
6604 DALI_TEST_CHECK( current.z > ninetyFivePercentProgress.z );
6606 application.SendNotification();
6607 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
6609 // We did expect the animation to finish
6610 application.SendNotification();
6611 finishCheck.CheckSignalReceived();
6612 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
6616 int UtcDaliAnimationMoveByVector3AlphaFloat2(void)
6618 TestApplication application;
6620 Actor actor = Actor::New();
6621 Vector3 startPosition(10.0f, 10.0f, 10.0f);
6622 actor.SetPosition(startPosition);
6623 Stage::GetCurrent().Add(actor);
6624 application.SendNotification();
6625 application.Render(0);
6626 DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION );
6628 // Build the animation
6629 float durationSeconds(1.0f);
6630 Animation animation = Animation::New(durationSeconds);
6631 Vector3 targetPosition(20.0f, 20.0f, 20.0f);
6632 Vector3 relativePosition(targetPosition - startPosition);
6634 animation.MoveBy(actor, relativePosition, AlphaFunctions::Linear, delay, durationSeconds - delay);
6636 Vector3 ninetyFivePercentProgress(startPosition + relativePosition*0.95f);
6638 // Start the animation
6641 bool signalReceived(false);
6642 AnimationFinishCheck finishCheck(signalReceived);
6643 animation.FinishedSignal().Connect(&application, finishCheck);
6645 application.SendNotification();
6646 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
6648 // We didn't expect the animation to finish yet
6649 application.SendNotification();
6650 finishCheck.CheckSignalNotReceived();
6651 DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION );
6653 application.SendNotification();
6654 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
6656 // We did expect the animation to finish
6657 application.SendNotification();
6658 finishCheck.CheckSignalReceived();
6659 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
6663 int UtcDaliAnimationMoveToFloat3(void)
6665 TestApplication application;
6667 Actor actor = Actor::New();
6668 Stage::GetCurrent().Add(actor);
6669 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
6671 // Build the animation
6672 float durationSeconds(1.0f);
6673 Animation animation = Animation::New(durationSeconds);
6674 Vector3 targetPosition(200.0f, 200.0f, 200.0f);
6675 animation.MoveTo(actor, targetPosition.x, targetPosition.y, targetPosition.z);
6677 Vector3 seventyFivePercentProgress(targetPosition * 0.75f);
6679 // Start the animation
6682 bool signalReceived(false);
6683 AnimationFinishCheck finishCheck(signalReceived);
6684 animation.FinishedSignal().Connect(&application, finishCheck);
6686 application.SendNotification();
6687 application.Render(static_cast<unsigned int>(durationSeconds*750.0f)/* 75% progress */);
6689 // We didn't expect the animation to finish yet
6690 application.SendNotification();
6691 finishCheck.CheckSignalNotReceived();
6692 DALI_TEST_EQUALS( actor.GetCurrentPosition(), seventyFivePercentProgress, TEST_LOCATION );
6694 application.SendNotification();
6695 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
6697 // We did expect the animation to finish
6698 application.SendNotification();
6699 finishCheck.CheckSignalReceived();
6700 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
6704 int UtcDaliAnimationMoveToVector3Alpha(void)
6706 TestApplication application;
6708 Actor actor = Actor::New();
6709 Stage::GetCurrent().Add(actor);
6710 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
6712 // Build the animation
6713 float durationSeconds(1.0f);
6714 Animation animation = Animation::New(durationSeconds);
6715 Vector3 targetPosition(200.0f, 200.0f, 200.0f);
6716 animation.MoveTo(actor, targetPosition, AlphaFunctions::EaseIn);
6718 Vector3 seventyFivePercentProgress(targetPosition * 0.75f);
6720 // Start the animation
6723 bool signalReceived(false);
6724 AnimationFinishCheck finishCheck(signalReceived);
6725 animation.FinishedSignal().Connect(&application, finishCheck);
6727 application.SendNotification();
6728 application.Render(static_cast<unsigned int>(durationSeconds*750.0f)/* 75% progress */);
6730 // We didn't expect the animation to finish yet
6731 application.SendNotification();
6732 finishCheck.CheckSignalNotReceived();
6734 // The position should have moved less, than with a linear alpha function
6735 Vector3 current(actor.GetCurrentPosition());
6736 DALI_TEST_CHECK( current.x > Vector3::ZERO.x );
6737 DALI_TEST_CHECK( current.y > Vector3::ZERO.y );
6738 DALI_TEST_CHECK( current.z > Vector3::ZERO.z );
6739 DALI_TEST_CHECK( current.x < seventyFivePercentProgress.x );
6740 DALI_TEST_CHECK( current.y < seventyFivePercentProgress.y );
6741 DALI_TEST_CHECK( current.z < seventyFivePercentProgress.z );
6743 application.SendNotification();
6744 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
6746 // We did expect the animation to finish
6747 application.SendNotification();
6748 finishCheck.CheckSignalReceived();
6749 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
6753 int UtcDaliAnimationMoveToVector3AlphaFloat2(void)
6755 TestApplication application;
6757 Actor actor = Actor::New();
6758 Stage::GetCurrent().Add(actor);
6759 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
6761 // Build the animation
6762 float durationSeconds(1.0f);
6763 Animation animation = Animation::New(durationSeconds);
6764 Vector3 targetPosition(200.0f, 200.0f, 200.0f);
6766 animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear, delay, durationSeconds - delay);
6768 Vector3 seventyFivePercentProgress(targetPosition * 0.75f);
6770 // Start the animation
6773 bool signalReceived(false);
6774 AnimationFinishCheck finishCheck(signalReceived);
6775 animation.FinishedSignal().Connect(&application, finishCheck);
6777 application.SendNotification();
6778 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
6780 // We didn't expect the animation to finish yet
6781 application.SendNotification();
6782 finishCheck.CheckSignalNotReceived();
6783 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
6785 application.SendNotification();
6786 application.Render(static_cast<unsigned int>(durationSeconds*500.0f*0.75)/* 7/8 animation progress, 3/4 animator progress */);
6788 // We didn't expect the animation to finish yet
6789 application.SendNotification();
6790 finishCheck.CheckSignalNotReceived();
6791 DALI_TEST_EQUALS( actor.GetCurrentPosition(), seventyFivePercentProgress, TEST_LOCATION );
6793 application.SendNotification();
6794 application.Render(static_cast<unsigned int>(durationSeconds*500.0f*0.25) + 1u/*just beyond the animation duration*/);
6796 // We did expect the animation to finish
6797 application.SendNotification();
6798 finishCheck.CheckSignalReceived();
6799 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
6803 int UtcDaliAnimationMove(void)
6805 TestApplication application;
6807 Actor actor = Actor::New();
6808 Vector3 initialPosition(Vector3::ZERO);
6809 DALI_TEST_EQUALS( actor.GetCurrentPosition(), initialPosition, TEST_LOCATION );
6810 Stage::GetCurrent().Add(actor);
6812 // Build the animation
6813 float durationSeconds(10.0f);
6814 Animation animation = Animation::New(durationSeconds);
6815 Vector3 targetPosition(200.0f, 200.0f, 200.0f);
6816 BounceFunc func(0.0f, 0.0f, -100.0f);
6817 animation.Move(actor, func, AlphaFunctions::Linear, 0.0f, durationSeconds);
6819 // Start the animation
6822 bool signalReceived(false);
6823 AnimationFinishCheck finishCheck(signalReceived);
6824 animation.FinishedSignal().Connect(&application, finishCheck);
6826 application.SendNotification();
6827 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
6829 // We didn't expect the animation to finish yet
6830 application.SendNotification();
6831 finishCheck.CheckSignalNotReceived();
6832 DALI_TEST_EQUALS( actor.GetCurrentPosition(), func(0.25f, initialPosition), TEST_LOCATION );
6834 application.SendNotification();
6835 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
6837 // We didn't expect the animation to finish yet
6838 application.SendNotification();
6839 finishCheck.CheckSignalNotReceived();
6840 DALI_TEST_EQUALS( actor.GetCurrentPosition(), func(0.5f, initialPosition), TEST_LOCATION );
6842 application.SendNotification();
6843 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
6845 // We didn't expect the animation to finish yet
6846 application.SendNotification();
6847 finishCheck.CheckSignalNotReceived();
6848 DALI_TEST_EQUALS( actor.GetCurrentPosition(), func(0.75f, initialPosition), TEST_LOCATION );
6850 application.SendNotification();
6851 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
6853 // We did expect the animation to finish
6854 application.SendNotification();
6855 finishCheck.CheckSignalReceived();
6856 DALI_TEST_EQUALS( actor.GetCurrentPosition(), initialPosition, TEST_LOCATION );
6860 int UtcDaliAnimationRotateByDegreeVector3(void)
6862 TestApplication application;
6864 Actor actor = Actor::New();
6865 actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
6866 Stage::GetCurrent().Add(actor);
6867 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6869 // Build the animation
6870 float durationSeconds(1.0f);
6871 Animation animation = Animation::New(durationSeconds);
6872 Degree relativeRotationDegrees(360.0f);
6873 Radian relativeRotationRadians(relativeRotationDegrees);
6874 animation.RotateBy(actor, relativeRotationDegrees/*Degree version*/, Vector3::YAXIS);
6876 // Start the animation
6879 bool signalReceived(false);
6880 AnimationFinishCheck finishCheck(signalReceived);
6881 animation.FinishedSignal().Connect(&application, finishCheck);
6883 application.SendNotification();
6884 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
6886 // We didn't expect the animation to finish yet
6887 application.SendNotification();
6888 finishCheck.CheckSignalNotReceived();
6889 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * 0.25f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6891 application.SendNotification();
6892 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
6894 // We didn't expect the animation to finish yet
6895 application.SendNotification();
6896 finishCheck.CheckSignalNotReceived();
6897 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * 0.5f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6899 application.SendNotification();
6900 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
6902 // We didn't expect the animation to finish yet
6903 application.SendNotification();
6904 finishCheck.CheckSignalNotReceived();
6905 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * 0.75f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6907 application.SendNotification();
6908 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
6910 // We did expect the animation to finish
6911 application.SendNotification();
6912 finishCheck.CheckSignalReceived();
6913 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6917 int UtcDaliAnimationRotateByRadianVector3(void)
6919 TestApplication application;
6921 Actor actor = Actor::New();
6922 actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
6923 Stage::GetCurrent().Add(actor);
6924 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6926 // Build the animation
6927 float durationSeconds(1.0f);
6928 Animation animation = Animation::New(durationSeconds);
6929 Degree relativeRotationDegrees(360.0f);
6930 Radian relativeRotationRadians(relativeRotationDegrees);
6931 animation.RotateBy(actor, relativeRotationRadians/*Radian version*/, Vector3::YAXIS);
6933 // Start the animation
6936 bool signalReceived(false);
6937 AnimationFinishCheck finishCheck(signalReceived);
6938 animation.FinishedSignal().Connect(&application, finishCheck);
6940 application.SendNotification();
6941 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
6943 // We didn't expect the animation to finish yet
6944 application.SendNotification();
6945 finishCheck.CheckSignalNotReceived();
6946 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * 0.25f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6948 application.SendNotification();
6949 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
6951 // We didn't expect the animation to finish yet
6952 application.SendNotification();
6953 finishCheck.CheckSignalNotReceived();
6954 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * 0.5f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6956 application.SendNotification();
6957 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
6959 // We didn't expect the animation to finish yet
6960 application.SendNotification();
6961 finishCheck.CheckSignalNotReceived();
6962 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * 0.75f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6964 application.SendNotification();
6965 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
6967 // We did expect the animation to finish
6968 application.SendNotification();
6969 finishCheck.CheckSignalReceived();
6970 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6974 int UtcDaliAnimationRotateByDegreeVector3Alpha(void)
6976 TestApplication application;
6978 Actor actor = Actor::New();
6979 actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
6980 Stage::GetCurrent().Add(actor);
6981 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6983 // Build the animation
6984 float durationSeconds(1.0f);
6985 Animation animation = Animation::New(durationSeconds);
6986 Degree relativeRotationDegrees(360.0f);
6987 Radian relativeRotationRadians(relativeRotationDegrees);
6988 animation.RotateBy(actor, relativeRotationDegrees/*Degree version*/, Vector3::YAXIS, AlphaFunctions::EaseIn);
6990 // Start the animation
6993 bool signalReceived(false);
6994 AnimationFinishCheck finishCheck(signalReceived);
6995 animation.FinishedSignal().Connect(&application, finishCheck);
6997 application.SendNotification();
6998 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7000 // We didn't expect the animation to finish yet
7001 application.SendNotification();
7002 finishCheck.CheckSignalNotReceived();
7003 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * AlphaFunctions::EaseIn(0.25f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7005 application.SendNotification();
7006 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7008 // We didn't expect the animation to finish yet
7009 application.SendNotification();
7010 finishCheck.CheckSignalNotReceived();
7011 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * AlphaFunctions::EaseIn(0.5f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7013 application.SendNotification();
7014 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7016 // We didn't expect the animation to finish yet
7017 application.SendNotification();
7018 finishCheck.CheckSignalNotReceived();
7019 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * AlphaFunctions::EaseIn(0.75f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7021 application.SendNotification();
7022 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7024 // We did expect the animation to finish
7025 application.SendNotification();
7026 finishCheck.CheckSignalReceived();
7027 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7031 int UtcDaliAnimationRotateByRadianVector3Alpha(void)
7033 TestApplication application;
7035 Actor actor = Actor::New();
7036 actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
7037 Stage::GetCurrent().Add(actor);
7038 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7040 // Build the animation
7041 float durationSeconds(1.0f);
7042 Animation animation = Animation::New(durationSeconds);
7043 Degree relativeRotationDegrees(360.0f);
7044 Radian relativeRotationRadians(relativeRotationDegrees);
7045 animation.RotateBy(actor, relativeRotationRadians/*Radian version*/, Vector3::YAXIS, AlphaFunctions::EaseIn);
7047 // Start the animation
7050 bool signalReceived(false);
7051 AnimationFinishCheck finishCheck(signalReceived);
7052 animation.FinishedSignal().Connect(&application, finishCheck);
7054 application.SendNotification();
7055 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7057 // We didn't expect the animation to finish yet
7058 application.SendNotification();
7059 finishCheck.CheckSignalNotReceived();
7060 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * AlphaFunctions::EaseIn(0.25f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7062 application.SendNotification();
7063 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7065 // We didn't expect the animation to finish yet
7066 application.SendNotification();
7067 finishCheck.CheckSignalNotReceived();
7068 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * AlphaFunctions::EaseIn(0.5f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7070 application.SendNotification();
7071 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7073 // We didn't expect the animation to finish yet
7074 application.SendNotification();
7075 finishCheck.CheckSignalNotReceived();
7076 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * AlphaFunctions::EaseIn(0.75f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7078 application.SendNotification();
7079 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7081 // We did expect the animation to finish
7082 application.SendNotification();
7083 finishCheck.CheckSignalReceived();
7084 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7088 int UtcDaliAnimationRotateByDegreeVector3AlphaFloat2(void)
7090 TestApplication application;
7092 Actor actor = Actor::New();
7093 actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
7094 Stage::GetCurrent().Add(actor);
7095 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7097 // Build the animation
7098 float durationSeconds(1.0f);
7099 Animation animation = Animation::New(durationSeconds);
7100 Degree relativeRotationDegrees(360.0f);
7101 Radian relativeRotationRadians(relativeRotationDegrees);
7103 animation.RotateBy(actor, relativeRotationDegrees/*Degree version*/, Vector3::YAXIS, AlphaFunctions::EaseIn, delay, durationSeconds - delay);
7105 // Start the animation
7108 bool signalReceived(false);
7109 AnimationFinishCheck finishCheck(signalReceived);
7110 animation.FinishedSignal().Connect(&application, finishCheck);
7112 application.SendNotification();
7113 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7115 // We didn't expect the animation to finish yet
7116 application.SendNotification();
7117 finishCheck.CheckSignalNotReceived();
7118 float progress = max(0.0f, 0.25f - delay) / (1.0f - delay);
7119 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7121 application.SendNotification();
7122 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7124 // We didn't expect the animation to finish yet
7125 application.SendNotification();
7126 finishCheck.CheckSignalNotReceived();
7127 progress = max(0.0f, 0.5f - delay) / (1.0f - delay);
7128 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7130 application.SendNotification();
7131 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7133 // We didn't expect the animation to finish yet
7134 application.SendNotification();
7135 finishCheck.CheckSignalNotReceived();
7136 progress = max(0.0f, 0.75f - delay) / (1.0f - delay);
7137 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7139 application.SendNotification();
7140 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7142 // We did expect the animation to finish
7143 application.SendNotification();
7144 finishCheck.CheckSignalReceived();
7145 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7150 int UtcDaliAnimationRotateByRadianVector3AlphaFloat2(void)
7152 TestApplication application;
7154 Actor actor = Actor::New();
7155 actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
7156 Stage::GetCurrent().Add(actor);
7157 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7159 // Build the animation
7160 float durationSeconds(1.0f);
7161 Animation animation = Animation::New(durationSeconds);
7162 Degree relativeRotationDegrees(360.0f);
7163 Radian relativeRotationRadians(relativeRotationDegrees);
7165 animation.RotateBy(actor, relativeRotationRadians/*Radian version*/, Vector3::YAXIS, AlphaFunctions::EaseIn, delay, durationSeconds - delay);
7167 // Start the animation
7170 bool signalReceived(false);
7171 AnimationFinishCheck finishCheck(signalReceived);
7172 animation.FinishedSignal().Connect(&application, finishCheck);
7174 application.SendNotification();
7175 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7177 // We didn't expect the animation to finish yet
7178 application.SendNotification();
7179 finishCheck.CheckSignalNotReceived();
7180 float progress = max(0.0f, 0.25f - delay) / (1.0f - delay);
7181 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7183 application.SendNotification();
7184 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7186 // We didn't expect the animation to finish yet
7187 application.SendNotification();
7188 finishCheck.CheckSignalNotReceived();
7189 progress = max(0.0f, 0.5f - delay) / (1.0f - delay);
7190 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7192 application.SendNotification();
7193 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7195 // We didn't expect the animation to finish yet
7196 application.SendNotification();
7197 finishCheck.CheckSignalNotReceived();
7198 progress = max(0.0f, 0.75f - delay) / (1.0f - delay);
7199 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7201 application.SendNotification();
7202 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7204 // We did expect the animation to finish
7205 application.SendNotification();
7206 finishCheck.CheckSignalReceived();
7207 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7211 int UtcDaliAnimationRotateToDegreeVector3(void)
7213 TestApplication application;
7215 Actor actor = Actor::New();
7216 actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
7217 Stage::GetCurrent().Add(actor);
7218 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7220 // Build the animation
7221 float durationSeconds(1.0f);
7222 Animation animation = Animation::New(durationSeconds);
7223 Degree targetRotationDegrees(90.0f);
7224 Radian targetRotationRadians(targetRotationDegrees);
7225 animation.RotateTo(actor, targetRotationDegrees/*Degree version*/, Vector3::YAXIS);
7227 // Start the animation
7230 bool signalReceived(false);
7231 AnimationFinishCheck finishCheck(signalReceived);
7232 animation.FinishedSignal().Connect(&application, finishCheck);
7234 application.SendNotification();
7235 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7237 // We didn't expect the animation to finish yet
7238 application.SendNotification();
7239 finishCheck.CheckSignalNotReceived();
7240 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.25f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7242 application.SendNotification();
7243 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7245 // We didn't expect the animation to finish yet
7246 application.SendNotification();
7247 finishCheck.CheckSignalNotReceived();
7248 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.5f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7250 application.SendNotification();
7251 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7253 // We didn't expect the animation to finish yet
7254 application.SendNotification();
7255 finishCheck.CheckSignalNotReceived();
7256 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.75f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7258 application.SendNotification();
7259 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7261 // We did expect the animation to finish
7262 application.SendNotification();
7263 finishCheck.CheckSignalReceived();
7264 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7268 int UtcDaliAnimationRotateToRadianVector3(void)
7270 TestApplication application;
7272 Actor actor = Actor::New();
7273 actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
7274 Stage::GetCurrent().Add(actor);
7275 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7277 // Build the animation
7278 float durationSeconds(1.0f);
7279 Animation animation = Animation::New(durationSeconds);
7280 Degree targetRotationDegrees(90.0f);
7281 Radian targetRotationRadians(targetRotationDegrees);
7282 animation.RotateTo(actor, targetRotationRadians/*Radian version*/, Vector3::YAXIS);
7284 // Start the animation
7287 bool signalReceived(false);
7288 AnimationFinishCheck finishCheck(signalReceived);
7289 animation.FinishedSignal().Connect(&application, finishCheck);
7291 application.SendNotification();
7292 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7294 // We didn't expect the animation to finish yet
7295 application.SendNotification();
7296 finishCheck.CheckSignalNotReceived();
7297 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.25f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7299 application.SendNotification();
7300 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7302 // We didn't expect the animation to finish yet
7303 application.SendNotification();
7304 finishCheck.CheckSignalNotReceived();
7305 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.5f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7307 application.SendNotification();
7308 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7310 // We didn't expect the animation to finish yet
7311 application.SendNotification();
7312 finishCheck.CheckSignalNotReceived();
7313 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.75f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7315 application.SendNotification();
7316 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7318 // We did expect the animation to finish
7319 application.SendNotification();
7320 finishCheck.CheckSignalReceived();
7321 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7325 int UtcDaliAnimationRotateToQuaternion(void)
7327 TestApplication application;
7329 Actor actor = Actor::New();
7330 actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
7331 Stage::GetCurrent().Add(actor);
7332 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7334 // Build the animation
7335 float durationSeconds(1.0f);
7336 Animation animation = Animation::New(durationSeconds);
7337 Degree targetRotationDegrees(90.0f);
7338 Radian targetRotationRadians(targetRotationDegrees);
7339 Quaternion targetRotation(targetRotationRadians, Vector3::YAXIS);
7340 animation.RotateTo(actor, targetRotation/*Quaternion version*/);
7342 // Start the animation
7345 bool signalReceived(false);
7346 AnimationFinishCheck finishCheck(signalReceived);
7347 animation.FinishedSignal().Connect(&application, finishCheck);
7349 application.SendNotification();
7350 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7352 // We didn't expect the animation to finish yet
7353 application.SendNotification();
7354 finishCheck.CheckSignalNotReceived();
7355 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.25f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7357 application.SendNotification();
7358 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7360 // We didn't expect the animation to finish yet
7361 application.SendNotification();
7362 finishCheck.CheckSignalNotReceived();
7363 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.5f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7365 application.SendNotification();
7366 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7368 // We didn't expect the animation to finish yet
7369 application.SendNotification();
7370 finishCheck.CheckSignalNotReceived();
7371 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.75f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7373 application.SendNotification();
7374 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7376 // We did expect the animation to finish
7377 application.SendNotification();
7378 finishCheck.CheckSignalReceived();
7379 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7383 int UtcDaliAnimationRotateToDegreeVector3Alpha(void)
7385 TestApplication application;
7387 Actor actor = Actor::New();
7388 actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
7389 Stage::GetCurrent().Add(actor);
7390 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7392 // Build the animation
7393 float durationSeconds(1.0f);
7394 Animation animation = Animation::New(durationSeconds);
7395 Degree targetRotationDegrees(90.0f);
7396 Radian targetRotationRadians(targetRotationDegrees);
7397 animation.RotateTo(actor, targetRotationDegrees/*Degree version*/, Vector3::YAXIS, AlphaFunctions::EaseIn);
7399 // Start the animation
7402 bool signalReceived(false);
7403 AnimationFinishCheck finishCheck(signalReceived);
7404 animation.FinishedSignal().Connect(&application, finishCheck);
7406 application.SendNotification();
7407 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7409 // We didn't expect the animation to finish yet
7410 application.SendNotification();
7411 finishCheck.CheckSignalNotReceived();
7412 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(0.25f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7414 application.SendNotification();
7415 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7417 // We didn't expect the animation to finish yet
7418 application.SendNotification();
7419 finishCheck.CheckSignalNotReceived();
7420 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(0.5f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7422 application.SendNotification();
7423 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7425 // We didn't expect the animation to finish yet
7426 application.SendNotification();
7427 finishCheck.CheckSignalNotReceived();
7428 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(0.75f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7430 application.SendNotification();
7431 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7433 // We did expect the animation to finish
7434 application.SendNotification();
7435 finishCheck.CheckSignalReceived();
7436 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7440 int UtcDaliAnimationRotateToRadianVector3Alpha(void)
7442 TestApplication application;
7444 Actor actor = Actor::New();
7445 actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
7446 Stage::GetCurrent().Add(actor);
7447 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7449 // Build the animation
7450 float durationSeconds(1.0f);
7451 Animation animation = Animation::New(durationSeconds);
7452 Degree targetRotationDegrees(90.0f);
7453 Radian targetRotationRadians(targetRotationDegrees);
7454 animation.RotateTo(actor, targetRotationRadians/*Radian version*/, Vector3::YAXIS, AlphaFunctions::EaseIn);
7456 // Start the animation
7459 bool signalReceived(false);
7460 AnimationFinishCheck finishCheck(signalReceived);
7461 animation.FinishedSignal().Connect(&application, finishCheck);
7463 application.SendNotification();
7464 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7466 // We didn't expect the animation to finish yet
7467 application.SendNotification();
7468 finishCheck.CheckSignalNotReceived();
7469 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(0.25f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7471 application.SendNotification();
7472 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7474 // We didn't expect the animation to finish yet
7475 application.SendNotification();
7476 finishCheck.CheckSignalNotReceived();
7477 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(0.5f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7479 application.SendNotification();
7480 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7482 // We didn't expect the animation to finish yet
7483 application.SendNotification();
7484 finishCheck.CheckSignalNotReceived();
7485 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(0.75f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7487 application.SendNotification();
7488 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7490 // We did expect the animation to finish
7491 application.SendNotification();
7492 finishCheck.CheckSignalReceived();
7493 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7497 int UtcDaliAnimationRotateToQuaternionAlpha(void)
7499 TestApplication application;
7501 Actor actor = Actor::New();
7502 actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
7503 Stage::GetCurrent().Add(actor);
7504 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7506 // Build the animation
7507 float durationSeconds(1.0f);
7508 Animation animation = Animation::New(durationSeconds);
7509 Degree targetRotationDegrees(90.0f);
7510 Radian targetRotationRadians(targetRotationDegrees);
7511 Quaternion targetRotation(targetRotationRadians, Vector3::YAXIS);
7512 animation.RotateTo(actor, targetRotation/*Quaternion version*/, AlphaFunctions::EaseIn);
7514 // Start the animation
7517 bool signalReceived(false);
7518 AnimationFinishCheck finishCheck(signalReceived);
7519 animation.FinishedSignal().Connect(&application, finishCheck);
7521 application.SendNotification();
7522 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7524 // We didn't expect the animation to finish yet
7525 application.SendNotification();
7526 finishCheck.CheckSignalNotReceived();
7527 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(0.25f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7529 application.SendNotification();
7530 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7532 // We didn't expect the animation to finish yet
7533 application.SendNotification();
7534 finishCheck.CheckSignalNotReceived();
7535 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(0.5f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7537 application.SendNotification();
7538 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7540 // We didn't expect the animation to finish yet
7541 application.SendNotification();
7542 finishCheck.CheckSignalNotReceived();
7543 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(0.75f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7545 application.SendNotification();
7546 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7548 // We did expect the animation to finish
7549 application.SendNotification();
7550 finishCheck.CheckSignalReceived();
7551 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7555 int UtcDaliAnimationRotateToDegreeVector3AlphaFloat2(void)
7557 TestApplication application;
7559 Actor actor = Actor::New();
7560 actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
7561 Stage::GetCurrent().Add(actor);
7562 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7564 // Build the animation
7565 float durationSeconds(1.0f);
7566 Animation animation = Animation::New(durationSeconds);
7567 Degree targetRotationDegrees(90.0f);
7568 Radian targetRotationRadians(targetRotationDegrees);
7570 animation.RotateTo(actor, targetRotationDegrees/*Degree version*/, Vector3::YAXIS, AlphaFunctions::EaseIn, delay, durationSeconds - delay);
7572 // Start the animation
7575 bool signalReceived(false);
7576 AnimationFinishCheck finishCheck(signalReceived);
7577 animation.FinishedSignal().Connect(&application, finishCheck);
7579 application.SendNotification();
7580 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7582 // We didn't expect the animation to finish yet
7583 application.SendNotification();
7584 finishCheck.CheckSignalNotReceived();
7585 float progress = max(0.0f, 0.25f - delay) / (1.0f - delay);
7586 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7588 application.SendNotification();
7589 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7591 // We didn't expect the animation to finish yet
7592 application.SendNotification();
7593 finishCheck.CheckSignalNotReceived();
7594 progress = max(0.0f, 0.5f - delay) / (1.0f - delay);
7595 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7597 application.SendNotification();
7598 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7600 // We didn't expect the animation to finish yet
7601 application.SendNotification();
7602 finishCheck.CheckSignalNotReceived();
7603 progress = max(0.0f, 0.75f - delay) / (1.0f - delay);
7604 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7606 application.SendNotification();
7607 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7609 // We did expect the animation to finish
7610 application.SendNotification();
7611 finishCheck.CheckSignalReceived();
7612 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7616 int UtcDaliAnimationRotateToRadianVector3AlphaFloat2(void)
7618 TestApplication application;
7620 Actor actor = Actor::New();
7621 actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
7622 Stage::GetCurrent().Add(actor);
7623 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7625 // Build the animation
7626 float durationSeconds(1.0f);
7627 Animation animation = Animation::New(durationSeconds);
7628 Degree targetRotationDegrees(90.0f);
7629 Radian targetRotationRadians(targetRotationDegrees);
7631 animation.RotateTo(actor, targetRotationRadians/*Radian version*/, Vector3::YAXIS, AlphaFunctions::EaseIn, delay, durationSeconds - delay);
7633 // Start the animation
7636 bool signalReceived(false);
7637 AnimationFinishCheck finishCheck(signalReceived);
7638 animation.FinishedSignal().Connect(&application, finishCheck);
7640 application.SendNotification();
7641 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7643 // We didn't expect the animation to finish yet
7644 application.SendNotification();
7645 finishCheck.CheckSignalNotReceived();
7646 float progress = max(0.0f, 0.25f - delay) / (1.0f - delay);
7647 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7649 application.SendNotification();
7650 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7652 // We didn't expect the animation to finish yet
7653 application.SendNotification();
7654 finishCheck.CheckSignalNotReceived();
7655 progress = max(0.0f, 0.5f - delay) / (1.0f - delay);
7656 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7658 application.SendNotification();
7659 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7661 // We didn't expect the animation to finish yet
7662 application.SendNotification();
7663 finishCheck.CheckSignalNotReceived();
7664 progress = max(0.0f, 0.75f - delay) / (1.0f - delay);
7665 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7667 application.SendNotification();
7668 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7670 // We did expect the animation to finish
7671 application.SendNotification();
7672 finishCheck.CheckSignalReceived();
7673 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7677 int UtcDaliAnimationRotateToQuaternionAlphaFloat2(void)
7679 TestApplication application;
7681 Actor actor = Actor::New();
7682 actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
7683 Stage::GetCurrent().Add(actor);
7684 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7686 // Build the animation
7687 float durationSeconds(1.0f);
7688 Animation animation = Animation::New(durationSeconds);
7689 Degree targetRotationDegrees(90.0f);
7690 Radian targetRotationRadians(targetRotationDegrees);
7692 Quaternion targetRotation(targetRotationRadians, Vector3::YAXIS);
7693 animation.RotateTo(actor, targetRotation/*Quaternion version*/, AlphaFunctions::EaseIn, delay, durationSeconds - delay);
7695 // Start the animation
7698 bool signalReceived(false);
7699 AnimationFinishCheck finishCheck(signalReceived);
7700 animation.FinishedSignal().Connect(&application, finishCheck);
7702 application.SendNotification();
7703 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7705 // We didn't expect the animation to finish yet
7706 application.SendNotification();
7707 finishCheck.CheckSignalNotReceived();
7708 float progress = max(0.0f, 0.25f - delay) / (1.0f - delay);
7709 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7711 application.SendNotification();
7712 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7714 // We didn't expect the animation to finish yet
7715 application.SendNotification();
7716 finishCheck.CheckSignalNotReceived();
7717 progress = max(0.0f, 0.5f - delay) / (1.0f - delay);
7718 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7720 application.SendNotification();
7721 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7723 // We didn't expect the animation to finish yet
7724 application.SendNotification();
7725 finishCheck.CheckSignalNotReceived();
7726 progress = max(0.0f, 0.75f - delay) / (1.0f - delay);
7727 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7729 application.SendNotification();
7730 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7732 // We did expect the animation to finish
7733 application.SendNotification();
7734 finishCheck.CheckSignalReceived();
7735 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7739 int UtcDaliAnimationRotate(void)
7741 TestApplication application;
7743 Actor actor = Actor::New();
7744 Quaternion initialRotation(0.0f, Vector3::YAXIS);
7745 actor.SetRotation(initialRotation);
7746 Stage::GetCurrent().Add(actor);
7747 DALI_TEST_EQUALS( actor.GetCurrentRotation(), initialRotation, ROTATION_EPSILON, TEST_LOCATION );
7749 // Build the animation
7750 float durationSeconds(1.0f);
7751 Animation animation = Animation::New(durationSeconds);
7752 TumbleFunc func(Vector3::YAXIS);
7753 animation.Rotate(actor, func, AlphaFunctions::Linear, 0.0f, durationSeconds);
7755 // Start the animation
7758 bool signalReceived(false);
7759 AnimationFinishCheck finishCheck(signalReceived);
7760 animation.FinishedSignal().Connect(&application, finishCheck);
7762 application.SendNotification();
7763 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7765 // We didn't expect the animation to finish yet
7766 application.SendNotification();
7767 finishCheck.CheckSignalNotReceived();
7768 DALI_TEST_EQUALS( actor.GetCurrentRotation(), func(0.25f, initialRotation), ROTATION_EPSILON, TEST_LOCATION );
7770 application.SendNotification();
7771 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7773 // We didn't expect the animation to finish yet
7774 application.SendNotification();
7775 finishCheck.CheckSignalNotReceived();
7776 DALI_TEST_EQUALS( actor.GetCurrentRotation(), func(0.5f, initialRotation), ROTATION_EPSILON, TEST_LOCATION );
7778 application.SendNotification();
7779 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7781 // We didn't expect the animation to finish yet
7782 application.SendNotification();
7783 finishCheck.CheckSignalNotReceived();
7784 DALI_TEST_EQUALS( actor.GetCurrentRotation(), func(0.75f, initialRotation), ROTATION_EPSILON, TEST_LOCATION );
7786 application.SendNotification();
7787 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7789 // We did expect the animation to finish
7790 application.SendNotification();
7791 finishCheck.CheckSignalReceived();
7792 DALI_TEST_EQUALS( actor.GetCurrentRotation(), func(1.0f, initialRotation), ROTATION_EPSILON, TEST_LOCATION );
7796 int UtcDaliAnimationScaleBy(void)
7798 TestApplication application;
7800 Actor actor = Actor::New();
7801 Stage::GetCurrent().Add(actor);
7802 DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
7804 // Build the animation
7805 float durationSeconds(1.0f);
7806 Animation animation = Animation::New(durationSeconds);
7807 Vector3 targetScale(2.0f, 2.0f, 2.0f);
7808 Vector3 relativeScale(targetScale - Vector3::ONE);
7809 animation.ScaleBy(actor, relativeScale.x, relativeScale.y, relativeScale.z);
7811 Vector3 ninetyNinePercentProgress(Vector3::ONE + relativeScale*0.99f);
7813 // Start the animation
7816 bool signalReceived(false);
7817 AnimationFinishCheck finishCheck(signalReceived);
7818 animation.FinishedSignal().Connect(&application, finishCheck);
7820 application.SendNotification();
7821 application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
7823 // We didn't expect the animation to finish yet
7824 application.SendNotification();
7825 finishCheck.CheckSignalNotReceived();
7826 DALI_TEST_EQUALS( actor.GetCurrentScale(), ninetyNinePercentProgress, TEST_LOCATION );
7828 application.SendNotification();
7829 application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
7831 // We did expect the animation to finish
7832 application.SendNotification();
7833 finishCheck.CheckSignalReceived();
7834 DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
7837 finishCheck.Reset();
7838 actor.SetScale(Vector3::ONE);
7839 application.SendNotification();
7840 application.Render(0);
7841 DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
7843 // Repeat with a different (ease-in) alpha function
7844 animation = Animation::New(durationSeconds);
7845 animation.ScaleBy(actor, relativeScale, AlphaFunctions::EaseIn);
7846 animation.FinishedSignal().Connect(&application, finishCheck);
7849 application.SendNotification();
7850 application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
7852 // We didn't expect the animation to finish yet
7853 application.SendNotification();
7854 finishCheck.CheckSignalNotReceived();
7856 // The scale should have grown less, than with a linear alpha function
7857 Vector3 current(actor.GetCurrentScale());
7858 DALI_TEST_CHECK( current.x > 1.0f );
7859 DALI_TEST_CHECK( current.y > 1.0f );
7860 DALI_TEST_CHECK( current.z > 1.0f );
7861 DALI_TEST_CHECK( current.x < ninetyNinePercentProgress.x );
7862 DALI_TEST_CHECK( current.y < ninetyNinePercentProgress.y );
7863 DALI_TEST_CHECK( current.z < ninetyNinePercentProgress.z );
7865 application.SendNotification();
7866 application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
7868 // We did expect the animation to finish
7869 application.SendNotification();
7870 finishCheck.CheckSignalReceived();
7871 DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
7874 finishCheck.Reset();
7875 actor.SetScale(Vector3::ONE);
7876 application.SendNotification();
7877 application.Render(0);
7878 DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
7880 // Repeat with a delay
7882 animation = Animation::New(durationSeconds);
7883 animation.ScaleBy(actor, relativeScale, AlphaFunctions::Linear, delay, durationSeconds - delay);
7884 animation.FinishedSignal().Connect(&application, finishCheck);
7887 application.SendNotification();
7888 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
7890 // We didn't expect the animation to finish yet
7891 application.SendNotification();
7892 finishCheck.CheckSignalNotReceived();
7893 DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
7895 application.SendNotification();
7896 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
7898 // We did expect the animation to finish
7899 application.SendNotification();
7900 finishCheck.CheckSignalReceived();
7901 DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
7905 int UtcDaliAnimationScaleTo(void)
7907 TestApplication application;
7909 Actor actor = Actor::New();
7910 Stage::GetCurrent().Add(actor);
7911 DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
7913 // Build the animation
7914 float durationSeconds(1.0f);
7915 Animation animation = Animation::New(durationSeconds);
7916 Vector3 targetScale(2.0f, 2.0f, 2.0f);
7917 animation.ScaleTo(actor, targetScale.x, targetScale.y, targetScale.z);
7919 Vector3 ninetyNinePercentProgress(Vector3::ONE + (targetScale - Vector3::ONE)*0.99f);
7921 // Start the animation
7924 bool signalReceived(false);
7925 AnimationFinishCheck finishCheck(signalReceived);
7926 animation.FinishedSignal().Connect(&application, finishCheck);
7928 application.SendNotification();
7929 application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
7931 // We didn't expect the animation to finish yet
7932 application.SendNotification();
7933 finishCheck.CheckSignalNotReceived();
7934 DALI_TEST_EQUALS( actor.GetCurrentScale(), ninetyNinePercentProgress, TEST_LOCATION );
7936 application.SendNotification();
7937 application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
7939 // We did expect the animation to finish
7940 application.SendNotification();
7941 finishCheck.CheckSignalReceived();
7942 DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
7945 finishCheck.Reset();
7946 actor.SetScale(Vector3::ONE);
7947 application.SendNotification();
7948 application.Render(0);
7949 DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
7951 // Repeat with a different (ease-in) alpha function
7952 animation = Animation::New(durationSeconds);
7953 animation.ScaleTo(actor, targetScale, AlphaFunctions::EaseIn);
7954 animation.FinishedSignal().Connect(&application, finishCheck);
7957 application.SendNotification();
7958 application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
7960 // We didn't expect the animation to finish yet
7961 application.SendNotification();
7962 finishCheck.CheckSignalNotReceived();
7964 // The scale should have grown less, than with a linear alpha function
7965 Vector3 current(actor.GetCurrentScale());
7966 DALI_TEST_CHECK( current.x > 1.0f );
7967 DALI_TEST_CHECK( current.y > 1.0f );
7968 DALI_TEST_CHECK( current.z > 1.0f );
7969 DALI_TEST_CHECK( current.x < ninetyNinePercentProgress.x );
7970 DALI_TEST_CHECK( current.y < ninetyNinePercentProgress.y );
7971 DALI_TEST_CHECK( current.z < ninetyNinePercentProgress.z );
7973 application.SendNotification();
7974 application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
7976 // We did expect the animation to finish
7977 application.SendNotification();
7978 finishCheck.CheckSignalReceived();
7979 DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
7982 finishCheck.Reset();
7983 actor.SetScale(Vector3::ONE);
7984 application.SendNotification();
7985 application.Render(0);
7986 DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
7988 // Repeat with a delay
7990 animation = Animation::New(durationSeconds);
7991 animation.ScaleTo(actor, targetScale, AlphaFunctions::Linear, delay, durationSeconds - delay);
7992 animation.FinishedSignal().Connect(&application, finishCheck);
7995 application.SendNotification();
7996 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
7998 // We didn't expect the animation to finish yet
7999 application.SendNotification();
8000 finishCheck.CheckSignalNotReceived();
8001 DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
8003 application.SendNotification();
8004 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
8006 // We did expect the animation to finish
8007 application.SendNotification();
8008 finishCheck.CheckSignalReceived();
8009 DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
8013 int UtcDaliAnimationShow(void)
8015 TestApplication application;
8017 Actor actor = Actor::New();
8018 actor.SetVisible(false);
8019 application.SendNotification();
8020 application.Render(0);
8021 DALI_TEST_CHECK( !actor.IsVisible() );
8022 Stage::GetCurrent().Add(actor);
8024 // Start the animation
8025 float durationSeconds(10.0f);
8026 Animation animation = Animation::New(durationSeconds);
8027 animation.Show(actor, durationSeconds*0.5f);
8030 bool signalReceived(false);
8031 AnimationFinishCheck finishCheck(signalReceived);
8032 animation.FinishedSignal().Connect(&application, finishCheck);
8034 application.SendNotification();
8035 application.Render(static_cast<unsigned int>(durationSeconds*490.0f));
8037 // We didn't expect the animation to finish yet
8038 application.SendNotification();
8039 finishCheck.CheckSignalNotReceived();
8040 DALI_TEST_CHECK( !actor.IsVisible() );
8042 application.SendNotification();
8043 application.Render(static_cast<unsigned int>(durationSeconds*10.0f)/*Should be shown now*/);
8045 // We didn't expect the animation to finish yet
8046 application.SendNotification();
8047 finishCheck.CheckSignalNotReceived();
8048 DALI_TEST_CHECK( actor.IsVisible() );
8050 application.SendNotification();
8051 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
8053 // We did expect the animation to finish
8054 application.SendNotification();
8055 finishCheck.CheckSignalReceived();
8056 DALI_TEST_CHECK( actor.IsVisible() );
8060 int UtcDaliAnimationHide(void)
8062 TestApplication application;
8064 Actor actor = Actor::New();
8065 DALI_TEST_CHECK( actor.IsVisible() );
8066 Stage::GetCurrent().Add(actor);
8068 // Start the animation
8069 float durationSeconds(10.0f);
8070 Animation animation = Animation::New(durationSeconds);
8071 animation.Hide(actor, durationSeconds*0.5f);
8074 bool signalReceived(false);
8075 AnimationFinishCheck finishCheck(signalReceived);
8076 animation.FinishedSignal().Connect(&application, finishCheck);
8078 application.SendNotification();
8079 application.Render(static_cast<unsigned int>(durationSeconds*490.0f));
8081 // We didn't expect the animation to finish yet
8082 application.SendNotification();
8083 finishCheck.CheckSignalNotReceived();
8084 DALI_TEST_CHECK( actor.IsVisible() );
8086 application.SendNotification();
8087 application.Render(static_cast<unsigned int>(durationSeconds*10.0f)/*Should be hidden now*/);
8089 // We didn't expect the animation to finish yet
8090 application.SendNotification();
8091 finishCheck.CheckSignalNotReceived();
8092 DALI_TEST_CHECK( !actor.IsVisible() );
8094 application.SendNotification();
8095 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
8097 // We did expect the animation to finish
8098 application.SendNotification();
8099 finishCheck.CheckSignalReceived();
8100 DALI_TEST_CHECK( !actor.IsVisible() );
8104 int UtcDaliAnimationShowHideAtEnd(void)
8106 // Test that show/hide delay can be the same as animation duration
8107 // i.e. to show/hide at the end of the animation
8109 TestApplication application;
8111 Actor actor = Actor::New();
8112 DALI_TEST_CHECK( actor.IsVisible() );
8113 Stage::GetCurrent().Add(actor);
8115 // Start Hide animation
8116 float durationSeconds(10.0f);
8117 Animation animation = Animation::New(durationSeconds);
8118 animation.Hide(actor, durationSeconds/*Hide at end*/);
8121 bool signalReceived(false);
8122 AnimationFinishCheck finishCheck(signalReceived);
8123 animation.FinishedSignal().Connect(&application, finishCheck);
8125 application.SendNotification();
8126 application.Render(static_cast<unsigned int>(durationSeconds*1000.0f) + 1u/*just beyond the animation duration*/);
8128 // We did expect the animation to finish
8129 application.SendNotification();
8130 finishCheck.CheckSignalReceived();
8131 DALI_TEST_CHECK( !actor.IsVisible() );
8133 // Start Show animation
8134 animation = Animation::New(durationSeconds);
8135 animation.Show(actor, durationSeconds/*Show at end*/);
8136 animation.FinishedSignal().Connect(&application, finishCheck);
8139 application.SendNotification();
8140 application.Render(static_cast<unsigned int>(durationSeconds*1000.0f) + 1u/*just beyond the animation duration*/);
8142 // We did expect the animation to finish
8143 application.SendNotification();
8144 finishCheck.CheckSignalReceived();
8145 DALI_TEST_CHECK( actor.IsVisible() );
8149 int UtcDaliAnimationOpacityBy(void)
8151 TestApplication application;
8152 Actor actor = Actor::New();
8153 float startingOpacity(0.5f);
8154 actor.SetOpacity(startingOpacity);
8155 application.SendNotification();
8156 application.Render(0);
8157 DALI_TEST_EQUALS( actor.GetCurrentOpacity(), startingOpacity, TEST_LOCATION );
8158 Stage::GetCurrent().Add(actor);
8160 // Build the animation
8161 float durationSeconds(1.0f);
8162 Animation animation = Animation::New(durationSeconds);
8163 float relativeOpacity(-0.5f); // target of zero
8164 animation.OpacityBy(actor, relativeOpacity);
8166 float seventyFivePercentProgress((1.0f - 0.75f) * startingOpacity);
8168 // Start the animation
8171 bool signalReceived(false);
8172 AnimationFinishCheck finishCheck(signalReceived);
8173 animation.FinishedSignal().Connect(&application, finishCheck);
8175 application.SendNotification();
8176 application.Render(static_cast<unsigned int>(durationSeconds*750.0f)/* 75% progress */);
8178 // We didn't expect the animation to finish yet
8179 application.SendNotification();
8180 finishCheck.CheckSignalNotReceived();
8181 DALI_TEST_EQUALS( actor.GetCurrentOpacity(), seventyFivePercentProgress, TEST_LOCATION );
8183 application.SendNotification();
8184 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
8186 // We did expect the animation to finish
8187 application.SendNotification();
8188 finishCheck.CheckSignalReceived();
8189 DALI_TEST_EQUALS( actor.GetCurrentOpacity(), startingOpacity+relativeOpacity, TEST_LOCATION );
8192 finishCheck.Reset();
8193 actor.SetOpacity(startingOpacity);
8194 application.SendNotification();
8195 application.Render(0);
8196 DALI_TEST_EQUALS( actor.GetCurrentOpacity(), startingOpacity, TEST_LOCATION );
8198 // Repeat with a different (ease-in) alpha function
8199 animation = Animation::New(durationSeconds);
8200 animation.OpacityBy(actor, relativeOpacity, AlphaFunctions::EaseIn);
8201 animation.FinishedSignal().Connect(&application, finishCheck);
8204 application.SendNotification();
8205 application.Render(static_cast<unsigned int>(durationSeconds*750.0f)/* 75% progress */);
8207 // We didn't expect the animation to finish yet
8208 application.SendNotification();
8209 finishCheck.CheckSignalNotReceived();
8211 // The opacity should reduce less, than with a linear alpha function
8212 float current(actor.GetCurrentOpacity());
8213 DALI_TEST_CHECK( current < 1.0f );
8214 DALI_TEST_CHECK( current > seventyFivePercentProgress );
8216 application.SendNotification();
8217 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
8219 // We did expect the animation to finish
8220 application.SendNotification();
8221 finishCheck.CheckSignalReceived();
8222 DALI_TEST_EQUALS( actor.GetCurrentOpacity(), startingOpacity+relativeOpacity, TEST_LOCATION );
8225 finishCheck.Reset();
8226 actor.SetOpacity(startingOpacity);
8227 application.SendNotification();
8228 application.Render(0);
8229 DALI_TEST_EQUALS( actor.GetCurrentOpacity(), startingOpacity, TEST_LOCATION );
8231 // Repeat with a delay
8233 animation = Animation::New(durationSeconds);
8234 animation.OpacityBy(actor, relativeOpacity, AlphaFunctions::Linear, delay, durationSeconds - delay);
8235 animation.FinishedSignal().Connect(&application, finishCheck);
8238 application.SendNotification();
8239 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
8241 // We didn't expect the animation to finish yet
8242 application.SendNotification();
8243 finishCheck.CheckSignalNotReceived();
8244 DALI_TEST_EQUALS( actor.GetCurrentOpacity(), startingOpacity, TEST_LOCATION );
8246 application.SendNotification();
8247 application.Render(static_cast<unsigned int>(durationSeconds*500.0f*0.75)/* 7/8 animation progress, 3/4 animator progress */);
8249 // We didn't expect the animation to finish yet
8250 application.SendNotification();
8251 finishCheck.CheckSignalNotReceived();
8252 DALI_TEST_EQUALS( actor.GetCurrentOpacity(), seventyFivePercentProgress, TEST_LOCATION );
8254 application.SendNotification();
8255 application.Render(static_cast<unsigned int>(durationSeconds*500.0f*0.25) + 1u/*just beyond the animation duration*/);
8257 // We did expect the animation to finish
8258 application.SendNotification();
8259 finishCheck.CheckSignalReceived();
8260 DALI_TEST_EQUALS( actor.GetCurrentOpacity(), startingOpacity+relativeOpacity, TEST_LOCATION );
8264 int UtcDaliAnimationOpacityTo(void)
8266 TestApplication application;
8268 Actor actor = Actor::New();
8269 Stage::GetCurrent().Add(actor);
8270 DALI_TEST_EQUALS( actor.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
8272 // Build the animation
8273 float durationSeconds(1.0f);
8274 Animation animation = Animation::New(durationSeconds);
8275 float targetOpacity(0.0f);
8276 animation.OpacityTo(actor, targetOpacity);
8278 float ninetyNinePercentProgress(0.01f);
8280 // Start the animation
8283 bool signalReceived(false);
8284 AnimationFinishCheck finishCheck(signalReceived);
8285 animation.FinishedSignal().Connect(&application, finishCheck);
8287 application.SendNotification();
8288 application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
8290 // We didn't expect the animation to finish yet
8291 application.SendNotification();
8292 finishCheck.CheckSignalNotReceived();
8293 DALI_TEST_EQUALS( actor.GetCurrentOpacity(), ninetyNinePercentProgress, 0.001f, TEST_LOCATION );
8295 application.SendNotification();
8296 application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
8298 // We did expect the animation to finish
8299 application.SendNotification();
8300 finishCheck.CheckSignalReceived();
8301 DALI_TEST_EQUALS( actor.GetCurrentOpacity(), targetOpacity, TEST_LOCATION );
8304 finishCheck.Reset();
8305 actor.SetOpacity(1.0f);
8306 application.SendNotification();
8307 application.Render(0);
8308 DALI_TEST_EQUALS( actor.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
8310 // Repeat with a different (ease-in) alpha function
8311 animation = Animation::New(durationSeconds);
8312 animation.OpacityTo(actor, targetOpacity, AlphaFunctions::EaseIn);
8313 animation.FinishedSignal().Connect(&application, finishCheck);
8316 application.SendNotification();
8317 application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
8319 // We didn't expect the animation to finish yet
8320 application.SendNotification();
8321 finishCheck.CheckSignalNotReceived();
8323 // The opacity should reduce less, than with a linear alpha function
8324 float current(actor.GetCurrentOpacity());
8325 DALI_TEST_CHECK( current < 1.0f );
8326 DALI_TEST_CHECK( current > ninetyNinePercentProgress );
8328 application.SendNotification();
8329 application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
8331 // We did expect the animation to finish
8332 application.SendNotification();
8333 finishCheck.CheckSignalReceived();
8334 DALI_TEST_EQUALS( actor.GetCurrentOpacity(), targetOpacity, TEST_LOCATION );
8337 finishCheck.Reset();
8338 actor.SetOpacity(1.0f);
8339 application.SendNotification();
8340 application.Render(0);
8341 DALI_TEST_EQUALS( actor.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
8343 // Repeat with a delay
8345 animation = Animation::New(durationSeconds);
8346 animation.OpacityTo(actor, targetOpacity, AlphaFunctions::Linear, delay, durationSeconds - delay);
8347 animation.FinishedSignal().Connect(&application, finishCheck);
8350 application.SendNotification();
8351 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
8353 // We didn't expect the animation to finish yet
8354 application.SendNotification();
8355 finishCheck.CheckSignalNotReceived();
8356 DALI_TEST_EQUALS( actor.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
8358 application.SendNotification();
8359 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
8361 // We did expect the animation to finish
8362 application.SendNotification();
8363 finishCheck.CheckSignalReceived();
8364 DALI_TEST_EQUALS( actor.GetCurrentOpacity(), targetOpacity, TEST_LOCATION );
8368 int UtcDaliAnimationColorBy(void)
8370 TestApplication application;
8372 Actor actor = Actor::New();
8373 actor.SetColor(Color::BLACK);
8374 application.SendNotification();
8375 application.Render(0);
8376 DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::BLACK, TEST_LOCATION );
8377 Stage::GetCurrent().Add(actor);
8379 // Build the animation
8380 float durationSeconds(1.0f);
8381 Animation animation = Animation::New(durationSeconds);
8382 Vector4 targetColor(Color::GREEN);
8383 Vector4 relativeColor(Color::GREEN); // Note the alpha is automatically clamped <= 1.0f in world color
8384 animation.ColorBy(actor, relativeColor);
8386 Vector4 tenPercentProgress(Vector4(0.0f, 0.1f, 0.0f, 1.0f));
8387 Vector4 twentyPercentProgress(Vector4(0.0f, 0.2f, 0.0f, 1.0f));
8389 // Start the animation
8392 bool signalReceived(false);
8393 AnimationFinishCheck finishCheck(signalReceived);
8394 animation.FinishedSignal().Connect(&application, finishCheck);
8396 application.SendNotification();
8397 application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% progress */);
8399 // We didn't expect the animation to finish yet
8400 application.SendNotification();
8401 finishCheck.CheckSignalNotReceived();
8402 DALI_TEST_EQUALS( actor.GetCurrentWorldColor(), tenPercentProgress, TEST_LOCATION );
8404 application.SendNotification();
8405 application.Render(static_cast<unsigned int>(durationSeconds*900.0f) + 1u/*just beyond the animation duration*/);
8407 // We did expect the animation to finish
8408 application.SendNotification();
8409 finishCheck.CheckSignalReceived();
8410 DALI_TEST_EQUALS( actor.GetCurrentWorldColor(), targetColor, TEST_LOCATION );
8413 finishCheck.Reset();
8414 actor.SetColor(Color::BLACK);
8415 application.SendNotification();
8416 application.Render(0);
8417 DALI_TEST_EQUALS( actor.GetCurrentWorldColor(), Color::BLACK, TEST_LOCATION );
8419 // Repeat with a different (ease-in) alpha function
8420 animation = Animation::New(durationSeconds);
8421 animation.ColorBy(actor, relativeColor, AlphaFunctions::EaseIn);
8422 animation.FinishedSignal().Connect(&application, finishCheck);
8425 application.SendNotification();
8426 application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% progress */);
8428 // We didn't expect the animation to finish yet
8429 application.SendNotification();
8430 finishCheck.CheckSignalNotReceived();
8432 // The color should have changed less, than with a linear alpha function
8433 Vector4 current(actor.GetCurrentWorldColor());
8434 DALI_TEST_CHECK( current.x == 0.0f ); // doesn't change
8435 DALI_TEST_CHECK( current.y > 0.0f );
8436 DALI_TEST_CHECK( current.y < tenPercentProgress.y );
8437 DALI_TEST_CHECK( current.z == 0.0f ); // doesn't change
8438 DALI_TEST_CHECK( current.w == 1.0f ); // doesn't change
8440 application.SendNotification();
8441 application.Render(static_cast<unsigned int>(durationSeconds*900.0f) + 1u/*just beyond the animation duration*/);
8443 // We did expect the animation to finish
8444 application.SendNotification();
8445 finishCheck.CheckSignalReceived();
8446 DALI_TEST_EQUALS( actor.GetCurrentWorldColor(), targetColor, TEST_LOCATION );
8449 finishCheck.Reset();
8450 actor.SetColor(Color::BLACK);
8451 application.SendNotification();
8452 application.Render(0);
8453 DALI_TEST_EQUALS( actor.GetCurrentWorldColor(), Color::BLACK, TEST_LOCATION );
8455 // Repeat with a shorter animator duration
8456 float animatorDuration = 0.5f;
8457 animation = Animation::New(durationSeconds);
8458 animation.ColorBy(actor, relativeColor, AlphaFunctions::Linear, 0, animatorDuration);
8459 animation.FinishedSignal().Connect(&application, finishCheck);
8462 application.SendNotification();
8463 application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% animation progress, 20% animator progress */);
8465 // We didn't expect the animation to finish yet
8466 application.SendNotification();
8467 finishCheck.CheckSignalNotReceived();
8468 DALI_TEST_EQUALS( actor.GetCurrentWorldColor(), twentyPercentProgress, TEST_LOCATION );
8470 application.SendNotification();
8471 application.Render(static_cast<unsigned int>(durationSeconds*400.0f)/* 50% animation progress, 100% animator progress */);
8473 // We didn't expect the animation to finish yet
8474 application.SendNotification();
8475 finishCheck.CheckSignalNotReceived();
8476 DALI_TEST_EQUALS( actor.GetCurrentWorldColor(), targetColor, TEST_LOCATION );
8478 application.SendNotification();
8479 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
8481 // We did expect the animation to finish
8482 application.SendNotification();
8483 finishCheck.CheckSignalReceived();
8484 DALI_TEST_EQUALS( actor.GetCurrentWorldColor(), targetColor, TEST_LOCATION );
8488 int UtcDaliAnimationColorTo(void)
8490 TestApplication application;
8492 Actor actor = Actor::New();
8493 Stage::GetCurrent().Add(actor);
8494 DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
8496 // Build the animation
8497 float durationSeconds(1.0f);
8498 Animation animation = Animation::New(durationSeconds);
8499 Vector4 targetColor(Color::RED);
8500 animation.ColorTo(actor, targetColor);
8502 Vector4 tenPercentProgress(Vector4(1.0f, 0.9f, 0.9f, 1.0f));
8503 Vector4 twentyPercentProgress(Vector4(1.0f, 0.8f, 0.8f, 1.0f));
8505 // Start the animation
8508 bool signalReceived(false);
8509 AnimationFinishCheck finishCheck(signalReceived);
8510 animation.FinishedSignal().Connect(&application, finishCheck);
8512 application.SendNotification();
8513 application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% progress */);
8515 // We didn't expect the animation to finish yet
8516 application.SendNotification();
8517 finishCheck.CheckSignalNotReceived();
8518 DALI_TEST_EQUALS( actor.GetCurrentColor(), tenPercentProgress, TEST_LOCATION );
8520 application.SendNotification();
8521 application.Render(static_cast<unsigned int>(durationSeconds*900.0f) + 1u/*just beyond the animation duration*/);
8523 // We did expect the animation to finish
8524 application.SendNotification();
8525 finishCheck.CheckSignalReceived();
8526 DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION );
8529 finishCheck.Reset();
8530 actor.SetColor(Color::WHITE);
8531 application.SendNotification();
8532 application.Render(0);
8533 DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
8535 // Repeat with a different (ease-in) alpha function
8536 animation = Animation::New(durationSeconds);
8537 animation.ColorTo(actor, targetColor, AlphaFunctions::EaseIn);
8538 animation.FinishedSignal().Connect(&application, finishCheck);
8541 application.SendNotification();
8542 application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% progress */);
8544 // We didn't expect the animation to finish yet
8545 application.SendNotification();
8546 finishCheck.CheckSignalNotReceived();
8548 // The color should have changed less, than with a linear alpha function
8549 Vector4 current(actor.GetCurrentColor());
8550 DALI_TEST_CHECK( current.x == 1.0f ); // doesn't change
8551 DALI_TEST_CHECK( current.y < 1.0f );
8552 DALI_TEST_CHECK( current.y > tenPercentProgress.y );
8553 DALI_TEST_CHECK( current.z < 1.0f );
8554 DALI_TEST_CHECK( current.z > tenPercentProgress.z );
8555 DALI_TEST_CHECK( current.w == 1.0f ); // doesn't change
8557 application.SendNotification();
8558 application.Render(static_cast<unsigned int>(durationSeconds*900.0f) + 1u/*just beyond the animation duration*/);
8560 // We did expect the animation to finish
8561 application.SendNotification();
8562 finishCheck.CheckSignalReceived();
8563 DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION );
8566 finishCheck.Reset();
8567 actor.SetColor(Color::WHITE);
8568 application.SendNotification();
8569 application.Render(0);
8570 DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
8572 // Repeat with a shorter animator duration
8573 float animatorDuration = 0.5f;
8574 animation = Animation::New(durationSeconds);
8575 animation.ColorTo(actor, targetColor, AlphaFunctions::Linear, 0, animatorDuration);
8576 animation.FinishedSignal().Connect(&application, finishCheck);
8579 application.SendNotification();
8580 application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% animation progress, 20% animator progress */);
8582 // We didn't expect the animation to finish yet
8583 application.SendNotification();
8584 finishCheck.CheckSignalNotReceived();
8585 DALI_TEST_EQUALS( actor.GetCurrentColor(), twentyPercentProgress, TEST_LOCATION );
8587 application.SendNotification();
8588 application.Render(static_cast<unsigned int>(durationSeconds*400.0f)/* 50% animation progress, 100% animator progress */);
8590 // We didn't expect the animation to finish yet
8591 application.SendNotification();
8592 finishCheck.CheckSignalNotReceived();
8593 DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION );
8595 application.SendNotification();
8596 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
8598 // We did expect the animation to finish
8599 application.SendNotification();
8600 finishCheck.CheckSignalReceived();
8601 DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION );
8605 int UtcDaliAnimationResize(void)
8607 TestApplication application;
8609 Actor actor = Actor::New();
8610 Stage::GetCurrent().Add(actor);
8611 DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
8613 // Build the animation
8614 float durationSeconds(1.0f);
8615 Animation animation = Animation::New(durationSeconds);
8616 Vector3 targetSize(100.0f, 100.0f, 100.0f);
8617 animation.Resize(actor, targetSize);
8619 Vector3 ninetyNinePercentProgress(targetSize * 0.99f);
8621 // Start the animation
8624 bool signalReceived(false);
8625 AnimationFinishCheck finishCheck(signalReceived);
8626 animation.FinishedSignal().Connect(&application, finishCheck);
8628 application.SendNotification();
8629 application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
8631 // We didn't expect the animation to finish yet
8632 application.SendNotification();
8633 finishCheck.CheckSignalNotReceived();
8634 DALI_TEST_EQUALS( actor.GetCurrentSize(), ninetyNinePercentProgress, TEST_LOCATION );
8636 application.SendNotification();
8637 application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
8639 // We did expect the animation to finish
8640 application.SendNotification();
8641 finishCheck.CheckSignalReceived();
8642 DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION );
8645 finishCheck.Reset();
8646 actor.SetSize(Vector3::ZERO);
8647 application.SendNotification();
8648 application.Render(0);
8649 DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
8651 // Repeat with a different (ease-in) alpha function
8652 animation = Animation::New(durationSeconds);
8653 animation.Resize(actor, targetSize, AlphaFunctions::EaseIn);
8654 animation.FinishedSignal().Connect(&application, finishCheck);
8657 application.SendNotification();
8658 application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
8660 // We didn't expect the animation to finish yet
8661 application.SendNotification();
8662 finishCheck.CheckSignalNotReceived();
8664 // The size should have travelled less, than with a linear alpha function
8665 Vector3 current(actor.GetCurrentSize());
8666 DALI_TEST_CHECK( current.x > 0.0f );
8667 DALI_TEST_CHECK( current.y > 0.0f );
8668 DALI_TEST_CHECK( current.z > 0.0f );
8669 DALI_TEST_CHECK( current.x < ninetyNinePercentProgress.x );
8670 DALI_TEST_CHECK( current.y < ninetyNinePercentProgress.y );
8671 DALI_TEST_CHECK( current.z < ninetyNinePercentProgress.z );
8673 application.SendNotification();
8674 application.Render(static_cast<unsigned int>(durationSeconds*10.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.GetCurrentSize(), targetSize, TEST_LOCATION );
8682 finishCheck.Reset();
8683 actor.SetSize(Vector3::ZERO);
8684 application.SendNotification();
8685 application.Render(0);
8686 DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
8688 // Repeat with a delay
8690 animation = Animation::New(durationSeconds);
8691 animation.Resize(actor, targetSize, AlphaFunctions::Linear, delay, durationSeconds - delay);
8692 animation.FinishedSignal().Connect(&application, finishCheck);
8695 application.SendNotification();
8696 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
8698 // We didn't expect the animation to finish yet
8699 application.SendNotification();
8700 finishCheck.CheckSignalNotReceived();
8701 DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
8703 application.SendNotification();
8704 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
8706 // We did expect the animation to finish
8707 application.SendNotification();
8708 finishCheck.CheckSignalReceived();
8709 DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION );
8713 int UtcDaliAnimationAnimateBool(void)
8715 TestApplication application;
8717 Actor actor = Actor::New();
8718 DALI_TEST_EQUALS( actor.IsVisible(), true, TEST_LOCATION );
8719 Stage::GetCurrent().Add(actor);
8721 // Build the animation
8722 float durationSeconds(10.0f);
8723 Animation animation = Animation::New(durationSeconds);
8724 animation.Animate<bool>( Property(actor, Actor::VISIBLE), ReturnFalseAfterProgressOne, TimePeriod(durationSeconds*0.25f/*delay*/, durationSeconds*0.1f) );
8726 // Start the animation
8729 bool signalReceived(false);
8730 AnimationFinishCheck finishCheck(signalReceived);
8731 animation.FinishedSignal().Connect(&application, finishCheck);
8733 application.SendNotification();
8734 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
8736 // We didn't expect the animation to finish yet
8737 application.SendNotification();
8738 finishCheck.CheckSignalNotReceived();
8740 // Should still be visible
8741 DALI_TEST_EQUALS( actor.IsVisible(), true, TEST_LOCATION );
8743 application.SendNotification();
8744 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
8746 // We didn't expect the animation to finish yet
8747 application.SendNotification();
8748 finishCheck.CheckSignalNotReceived();
8750 // Now animate functor should have hidden the actor
8751 DALI_TEST_EQUALS( actor.IsVisible(), false, TEST_LOCATION );
8753 application.SendNotification();
8754 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
8756 // We did expect the animation to finish
8757 application.SendNotification();
8758 finishCheck.CheckSignalReceived();
8759 DALI_TEST_EQUALS( actor.IsVisible(), false, TEST_LOCATION );
8763 int UtcDaliAnimationAnimateFloat(void)
8765 TestApplication application;
8767 Actor actor = Actor::New();
8768 Stage::GetCurrent().Add(actor);
8770 // Register a float property
8771 float startValue(10.0f);
8772 Property::Index index = actor.RegisterProperty( "test-property", startValue );
8773 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
8775 // Build the animation
8776 float durationSeconds(10.0f);
8777 Animation animation = Animation::New(durationSeconds);
8778 float targetPosition(0.0f);
8779 AnimateFloatTestFunctor func( 100, targetPosition );
8780 animation.Animate<float>( Property(actor, index), func );
8782 // Start the animation
8785 bool signalReceived(false);
8786 AnimationFinishCheck finishCheck(signalReceived);
8787 animation.FinishedSignal().Connect(&application, finishCheck);
8789 application.SendNotification();
8790 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
8792 // We didn't expect the animation to finish yet
8793 application.SendNotification();
8794 finishCheck.CheckSignalNotReceived();
8795 DALI_TEST_EQUALS( actor.GetProperty<float>(index), 75.0f, TEST_LOCATION );
8797 application.SendNotification();
8798 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
8800 // We didn't expect the animation to finish yet
8801 application.SendNotification();
8802 finishCheck.CheckSignalNotReceived();
8803 DALI_TEST_EQUALS( actor.GetProperty<float>(index), 50.0f, TEST_LOCATION );
8805 application.SendNotification();
8806 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
8808 // We didn't expect the animation to finish yet
8809 application.SendNotification();
8810 finishCheck.CheckSignalNotReceived();
8811 DALI_TEST_EQUALS( actor.GetProperty<float>(index), 25.0f, TEST_LOCATION );
8813 application.SendNotification();
8814 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
8816 // We did expect the animation to finish
8817 application.SendNotification();
8818 finishCheck.CheckSignalReceived();
8819 DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetPosition, TEST_LOCATION );
8823 int UtcDaliAnimationAnimateInteger(void)
8825 TestApplication application;
8827 Actor actor = Actor::New();
8828 Stage::GetCurrent().Add(actor);
8830 // Register an integer property
8832 Property::Index index = actor.RegisterProperty( "test-property", startValue );
8833 DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
8835 // Build the animation
8836 float durationSeconds(10.0f);
8837 Animation animation = Animation::New(durationSeconds);
8838 int targetPosition(0);
8839 AnimateIntegerTestFunctor func( 100, targetPosition );
8840 animation.Animate<int>( Property(actor, index), func );
8842 // Start the animation
8845 bool signalReceived(false);
8846 AnimationFinishCheck finishCheck(signalReceived);
8847 animation.FinishedSignal().Connect(&application, finishCheck);
8849 application.SendNotification();
8850 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
8852 // We didn't expect the animation to finish yet
8853 application.SendNotification();
8854 finishCheck.CheckSignalNotReceived();
8855 DALI_TEST_EQUALS( actor.GetProperty<int>(index), 75, TEST_LOCATION );
8857 application.SendNotification();
8858 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
8860 // We didn't expect the animation to finish yet
8861 application.SendNotification();
8862 finishCheck.CheckSignalNotReceived();
8863 DALI_TEST_EQUALS( actor.GetProperty<int>(index), 50, TEST_LOCATION );
8865 application.SendNotification();
8866 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
8868 // We didn't expect the animation to finish yet
8869 application.SendNotification();
8870 finishCheck.CheckSignalNotReceived();
8871 DALI_TEST_EQUALS( actor.GetProperty<int>(index), 25, TEST_LOCATION );
8873 application.SendNotification();
8874 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
8876 // We did expect the animation to finish
8877 application.SendNotification();
8878 finishCheck.CheckSignalReceived();
8879 DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetPosition, TEST_LOCATION );
8883 int UtcDaliAnimationAnimateVector2(void)
8885 TestApplication application;
8887 Actor actor = Actor::New();
8888 Stage::GetCurrent().Add(actor);
8890 // Register a Vector2 property
8891 Vector2 startValue(10.0f, 10.0f);
8892 Property::Index index = actor.RegisterProperty( "test-property", startValue );
8893 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
8895 // Build the animation
8896 float durationSeconds(10.0f);
8897 Animation animation = Animation::New(durationSeconds);
8898 Vector2 targetPosition(0.0f, 0.0f);
8899 AnimateVector2TestFunctor func( Vector2(100,100), targetPosition );
8900 animation.Animate<Vector2>( Property(actor, index), func );
8902 // Start the animation
8905 bool signalReceived(false);
8906 AnimationFinishCheck finishCheck(signalReceived);
8907 animation.FinishedSignal().Connect(&application, finishCheck);
8909 application.SendNotification();
8910 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
8912 // We didn't expect the animation to finish yet
8913 application.SendNotification();
8914 finishCheck.CheckSignalNotReceived();
8915 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), Vector2(75,75), TEST_LOCATION );
8917 application.SendNotification();
8918 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
8920 // We didn't expect the animation to finish yet
8921 application.SendNotification();
8922 finishCheck.CheckSignalNotReceived();
8923 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), Vector2(50,50), TEST_LOCATION );
8925 application.SendNotification();
8926 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
8928 // We didn't expect the animation to finish yet
8929 application.SendNotification();
8930 finishCheck.CheckSignalNotReceived();
8931 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), Vector2(25,25), TEST_LOCATION );
8933 application.SendNotification();
8934 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
8936 // We did expect the animation to finish
8937 application.SendNotification();
8938 finishCheck.CheckSignalReceived();
8939 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetPosition, TEST_LOCATION );
8943 int UtcDaliAnimationAnimateVector3(void)
8945 TestApplication application;
8947 Actor actor = Actor::New();
8948 Vector3 initialPosition(Vector3::ZERO);
8949 DALI_TEST_EQUALS( actor.GetCurrentPosition(), initialPosition, TEST_LOCATION );
8950 Stage::GetCurrent().Add(actor);
8952 // Build the animation
8953 float durationSeconds(10.0f);
8954 Animation animation = Animation::New(durationSeconds);
8955 Vector3 targetPosition(200.0f, 200.0f, 200.0f);
8956 BounceFunc func(0.0f, 0.0f, -100.0f);
8957 animation.Animate<Vector3>( Property(actor, Actor::POSITION), func, AlphaFunctions::Linear, durationSeconds );
8959 // Start the animation
8962 bool signalReceived(false);
8963 AnimationFinishCheck finishCheck(signalReceived);
8964 animation.FinishedSignal().Connect(&application, finishCheck);
8966 application.SendNotification();
8967 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
8969 // We didn't expect the animation to finish yet
8970 application.SendNotification();
8971 finishCheck.CheckSignalNotReceived();
8972 DALI_TEST_EQUALS( actor.GetCurrentPosition(), func(0.25f, initialPosition), TEST_LOCATION );
8974 application.SendNotification();
8975 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
8977 // We didn't expect the animation to finish yet
8978 application.SendNotification();
8979 finishCheck.CheckSignalNotReceived();
8980 DALI_TEST_EQUALS( actor.GetCurrentPosition(), func(0.5f, initialPosition), TEST_LOCATION );
8982 application.SendNotification();
8983 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
8985 // We didn't expect the animation to finish yet
8986 application.SendNotification();
8987 finishCheck.CheckSignalNotReceived();
8988 DALI_TEST_EQUALS( actor.GetCurrentPosition(), func(0.75f, initialPosition), TEST_LOCATION );
8990 application.SendNotification();
8991 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
8993 // We did expect the animation to finish
8994 application.SendNotification();
8995 finishCheck.CheckSignalReceived();
8996 DALI_TEST_EQUALS( actor.GetCurrentPosition(), initialPosition, TEST_LOCATION );
9000 int UtcDaliAnimationAnimateVector4(void)
9002 TestApplication application;
9004 Actor actor = Actor::New();
9005 Stage::GetCurrent().Add(actor);
9007 // Register a Vector4 property
9008 Vector4 startValue(10.0f, 10.0f, 10.0f, 10.0f);
9009 Property::Index index = actor.RegisterProperty( "test-property", startValue );
9010 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
9012 // Build the animation
9013 float durationSeconds(10.0f);
9014 Animation animation = Animation::New(durationSeconds);
9015 Vector4 targetPosition(200,400,0,-1000);
9016 AnimateVector4TestFunctor func( Vector4(1000,1000,1000,1000), targetPosition );
9017 animation.Animate<Vector4>( Property(actor, index), func );
9019 // Start the animation
9022 bool signalReceived(false);
9023 AnimationFinishCheck finishCheck(signalReceived);
9024 animation.FinishedSignal().Connect(&application, finishCheck);
9026 application.SendNotification();
9027 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
9029 // We didn't expect the animation to finish yet
9030 application.SendNotification();
9031 finishCheck.CheckSignalNotReceived();
9032 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), Vector4(800,850,750,500), TEST_LOCATION );
9034 application.SendNotification();
9035 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
9037 // We didn't expect the animation to finish yet
9038 application.SendNotification();
9039 finishCheck.CheckSignalNotReceived();
9040 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), Vector4(600,700,500,0), TEST_LOCATION );
9042 application.SendNotification();
9043 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
9045 // We didn't expect the animation to finish yet
9046 application.SendNotification();
9047 finishCheck.CheckSignalNotReceived();
9048 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), Vector4(400,550,250,-500), TEST_LOCATION );
9050 application.SendNotification();
9051 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
9053 // We did expect the animation to finish
9054 application.SendNotification();
9055 finishCheck.CheckSignalReceived();
9056 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetPosition, TEST_LOCATION );
9060 int UtcDaliAnimationAnimateQuaternion(void)
9062 TestApplication application;
9064 Actor actor = Actor::New();
9065 actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
9066 Stage::GetCurrent().Add(actor);
9067 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
9069 // Build the animation
9070 float durationSeconds(1.0f);
9071 Animation animation = Animation::New(durationSeconds);
9073 Degree sourceRotationDegrees(90.0f);
9074 Radian sourceRotationRadians(sourceRotationDegrees);
9075 Quaternion sourceRotation(sourceRotationRadians, Vector3::YAXIS);
9077 Degree targetRotationDegrees(150.0f);
9078 Radian targetRotationRadians(targetRotationDegrees);
9079 Quaternion targetRotation(targetRotationRadians, Vector3::YAXIS);
9081 AnimateQuaternionTestFunctor func( sourceRotation, targetRotation );
9082 animation.Animate<Quaternion>( Property(actor, Actor::ROTATION), func );
9084 // Start the animation
9087 bool signalReceived(false);
9088 AnimationFinishCheck finishCheck(signalReceived);
9089 animation.FinishedSignal().Connect(&application, finishCheck);
9091 application.SendNotification();
9092 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
9094 // We didn't expect the animation to finish yet
9095 application.SendNotification();
9096 finishCheck.CheckSignalNotReceived();
9097 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(Radian(Degree(105)), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
9099 application.SendNotification();
9100 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
9102 // We didn't expect the animation to finish yet
9103 application.SendNotification();
9104 finishCheck.CheckSignalNotReceived();
9105 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(Radian(Degree(120)), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
9107 application.SendNotification();
9108 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
9110 // We didn't expect the animation to finish yet
9111 application.SendNotification();
9112 finishCheck.CheckSignalNotReceived();
9113 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(Radian(Degree(135)), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
9115 application.SendNotification();
9116 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
9118 // We did expect the animation to finish
9119 application.SendNotification();
9120 finishCheck.CheckSignalReceived();
9121 DALI_TEST_EQUALS( actor.GetCurrentRotation(), targetRotation, ROTATION_EPSILON, TEST_LOCATION );
9125 int UtcDaliKeyFramesCreateDestroy(void)
9127 tet_infoline("Testing Dali::Animation::UtcDaliKeyFramesCreateDestroy()");
9129 KeyFrames* keyFrames = new KeyFrames;
9131 DALI_TEST_CHECK( true );
9135 int UtcDaliKeyFramesDownCast(void)
9137 TestApplication application;
9138 tet_infoline("Testing Dali::Animation::KeyFramesDownCast()");
9140 KeyFrames keyFrames = KeyFrames::New();
9141 BaseHandle object(keyFrames);
9143 KeyFrames keyFrames2 = KeyFrames::DownCast(object);
9144 DALI_TEST_CHECK(keyFrames2);
9146 KeyFrames keyFrames3 = DownCast< KeyFrames >(object);
9147 DALI_TEST_CHECK(keyFrames3);
9149 BaseHandle unInitializedObject;
9150 KeyFrames keyFrames4 = KeyFrames::DownCast(unInitializedObject);
9151 DALI_TEST_CHECK(!keyFrames4);
9153 KeyFrames keyFrames5 = DownCast< KeyFrames >(unInitializedObject);
9154 DALI_TEST_CHECK(!keyFrames5);
9158 int UtcDaliAnimationResizeByXY(void)
9160 TestApplication application;
9162 Actor actor = Actor::New();
9163 Stage::GetCurrent().Add(actor);
9164 DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
9166 // Build the animation
9167 float durationSeconds(1.0f);
9168 Animation animation = Animation::New(durationSeconds);
9169 Vector3 targetSize(100.0f, 100.0f, 100.0f);
9170 animation.Resize(actor, targetSize);
9172 Vector3 ninetyNinePercentProgress(targetSize * 0.99f);
9174 // Start the animation
9177 bool signalReceived(false);
9178 AnimationFinishCheck finishCheck(signalReceived);
9179 animation.FinishedSignal().Connect(&application, finishCheck);
9181 application.SendNotification();
9182 application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
9184 // We didn't expect the animation to finish yet
9185 application.SendNotification();
9186 finishCheck.CheckSignalNotReceived();
9187 DALI_TEST_EQUALS( actor.GetCurrentSize(), ninetyNinePercentProgress, TEST_LOCATION );
9189 application.SendNotification();
9190 application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
9192 // We did expect the animation to finish
9193 application.SendNotification();
9194 finishCheck.CheckSignalReceived();
9195 DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION );
9198 finishCheck.Reset();
9199 actor.SetSize(Vector3::ZERO);
9200 application.SendNotification();
9201 application.Render(0);
9202 DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
9204 // Repeat with a different (ease-in) alpha function
9205 animation = Animation::New(durationSeconds);
9206 animation.Resize(actor, targetSize.x, targetSize.y, AlphaFunctions::EaseIn);
9207 animation.FinishedSignal().Connect(&application, finishCheck);
9210 application.SendNotification();
9211 application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
9213 // We didn't expect the animation to finish yet
9214 application.SendNotification();
9215 finishCheck.CheckSignalNotReceived();
9217 // The size should have travelled less, than with a linear alpha function
9218 Vector3 current(actor.GetCurrentSize());
9219 DALI_TEST_CHECK( current.x > 0.0f );
9220 DALI_TEST_CHECK( current.y > 0.0f );
9221 DALI_TEST_CHECK( current.z > 0.0f );
9222 DALI_TEST_CHECK( current.x < ninetyNinePercentProgress.x );
9223 DALI_TEST_CHECK( current.y < ninetyNinePercentProgress.y );
9224 DALI_TEST_CHECK( current.z < ninetyNinePercentProgress.z );
9226 application.SendNotification();
9227 application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
9229 // We did expect the animation to finish
9230 application.SendNotification();
9231 finishCheck.CheckSignalReceived();
9232 DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION );
9235 finishCheck.Reset();
9236 actor.SetSize(Vector3::ZERO);
9237 application.SendNotification();
9238 application.Render(0);
9239 DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
9241 // Repeat with a delay
9243 animation = Animation::New(durationSeconds);
9244 animation.Resize(actor, targetSize.x, targetSize.y, AlphaFunctions::Linear, delay, durationSeconds - delay);
9245 animation.FinishedSignal().Connect(&application, finishCheck);
9248 application.SendNotification();
9249 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
9251 // We didn't expect the animation to finish yet
9252 application.SendNotification();
9253 finishCheck.CheckSignalNotReceived();
9254 DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
9256 application.SendNotification();
9257 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
9259 // We did expect the animation to finish
9260 application.SendNotification();
9261 finishCheck.CheckSignalReceived();
9262 DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION );
9267 int UtcDaliAnimationAnimateBetweenActorColorTimePeriod(void)
9269 TestApplication application;
9271 float startValue(1.0f);
9272 Actor actor = Actor::New();
9273 actor.SetColor(Vector4(startValue, startValue, startValue, startValue));
9274 Stage::GetCurrent().Add(actor);
9276 DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
9277 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
9278 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
9279 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
9280 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), startValue, TEST_LOCATION );
9282 // Build the animation
9283 float durationSeconds(1.0f);
9284 Animation animation = Animation::New(durationSeconds);
9286 KeyFrames keyFrames = KeyFrames::New();
9287 keyFrames.Add(0.0f, Vector4(0.1f, 0.2f, 0.3f, 0.4f));
9288 keyFrames.Add(0.5f, Vector4(0.9f, 0.8f, 0.7f, 0.6f));
9289 keyFrames.Add(1.0f, Vector4(1.0f, 1.0f, 1.0f, 1.0f));
9291 animation.AnimateBetween( Property(actor, Actor::COLOR), keyFrames, TimePeriod( 1.0f) );
9293 // Start the animation
9296 bool signalReceived(false);
9297 AnimationFinishCheck finishCheck(signalReceived);
9298 animation.FinishedSignal().Connect(&application, finishCheck);
9299 application.SendNotification();
9300 application.Render(0);
9301 application.SendNotification();
9302 finishCheck.CheckSignalNotReceived();
9303 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), 0.1f, 0.01f, TEST_LOCATION );
9304 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 0.2f, 0.01f, TEST_LOCATION );
9305 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), 0.3f, 0.01f, TEST_LOCATION );
9306 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.4f, 0.01f, TEST_LOCATION );
9308 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
9309 application.SendNotification();
9310 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), 0.5f, 0.01f, TEST_LOCATION );
9311 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 0.5f, 0.01f, TEST_LOCATION );
9312 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), 0.5f, 0.01f, TEST_LOCATION );
9313 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.5f, 0.01f, TEST_LOCATION );
9315 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
9316 application.SendNotification();
9317 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), 0.9f, 0.01f, TEST_LOCATION );
9318 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 0.8f, 0.01f, TEST_LOCATION );
9319 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), 0.7f, 0.01f, TEST_LOCATION );
9320 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.6f, 0.01f, TEST_LOCATION );
9322 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
9323 application.SendNotification();
9324 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), 0.95f, 0.01f, TEST_LOCATION );
9325 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 0.90f, 0.01f, TEST_LOCATION );
9326 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), 0.85f, 0.01f, TEST_LOCATION );
9327 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.80f, 0.01f, TEST_LOCATION );
9329 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
9330 application.SendNotification();
9331 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), 1.0f, 0.01f, TEST_LOCATION );
9332 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 1.0f, 0.01f, TEST_LOCATION );
9333 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), 1.0f, 0.01f, TEST_LOCATION );
9334 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 1.0f, 0.01f, TEST_LOCATION );
9336 // We did expect the animation to finish
9338 finishCheck.CheckSignalReceived();
9342 int UtcDaliAnimationAnimateBetweenActorColorFunction(void)
9344 TestApplication application;
9346 float startValue(1.0f);
9347 Actor actor = Actor::New();
9348 actor.SetColor(Vector4(startValue, startValue, startValue, startValue));
9349 Stage::GetCurrent().Add(actor);
9351 DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
9352 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
9353 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
9354 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
9355 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), startValue, TEST_LOCATION );
9357 // Build the animation
9358 float durationSeconds(1.0f);
9359 Animation animation = Animation::New(durationSeconds);
9361 KeyFrames keyFrames = KeyFrames::New();
9362 keyFrames.Add(0.0f, Vector4(0.1f, 0.2f, 0.3f, 0.4f));
9363 keyFrames.Add(0.5f, Vector4(0.9f, 0.8f, 0.7f, 0.6f));
9364 keyFrames.Add(1.0f, Vector4(1.0f, 1.0f, 1.0f, 1.0f));
9366 animation.AnimateBetween( Property(actor, Actor::COLOR), keyFrames, AlphaFunctions::Linear );
9368 // Start the animation
9371 bool signalReceived(false);
9372 AnimationFinishCheck finishCheck(signalReceived);
9373 animation.FinishedSignal().Connect(&application, finishCheck);
9374 application.SendNotification();
9375 application.Render(0);
9376 application.SendNotification();
9377 finishCheck.CheckSignalNotReceived();
9378 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), 0.1f, 0.01f, TEST_LOCATION );
9379 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 0.2f, 0.01f, TEST_LOCATION );
9380 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), 0.3f, 0.01f, TEST_LOCATION );
9381 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.4f, 0.01f, TEST_LOCATION );
9383 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
9384 application.SendNotification();
9385 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), 0.5f, 0.01f, TEST_LOCATION );
9386 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 0.5f, 0.01f, TEST_LOCATION );
9387 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), 0.5f, 0.01f, TEST_LOCATION );
9388 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.5f, 0.01f, TEST_LOCATION );
9390 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
9391 application.SendNotification();
9392 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), 0.9f, 0.01f, TEST_LOCATION );
9393 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 0.8f, 0.01f, TEST_LOCATION );
9394 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), 0.7f, 0.01f, TEST_LOCATION );
9395 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.6f, 0.01f, TEST_LOCATION );
9397 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
9398 application.SendNotification();
9399 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), 0.95f, 0.01f, TEST_LOCATION );
9400 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 0.90f, 0.01f, TEST_LOCATION );
9401 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), 0.85f, 0.01f, TEST_LOCATION );
9402 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.80f, 0.01f, TEST_LOCATION );
9404 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
9405 application.SendNotification();
9406 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), 1.0f, 0.01f, TEST_LOCATION );
9407 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 1.0f, 0.01f, TEST_LOCATION );
9408 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), 1.0f, 0.01f, TEST_LOCATION );
9409 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 1.0f, 0.01f, TEST_LOCATION );
9411 // We did expect the animation to finish
9413 finishCheck.CheckSignalReceived();
9417 int UtcDaliAnimationAnimateBetweenActorColorFunctionTimePeriod(void)
9419 TestApplication application;
9421 float startValue(1.0f);
9422 Actor actor = Actor::New();
9423 actor.SetColor(Vector4(startValue, startValue, startValue, startValue));
9424 Stage::GetCurrent().Add(actor);
9426 DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
9427 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
9428 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
9429 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
9430 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), startValue, TEST_LOCATION );
9432 // Build the animation
9433 float durationSeconds(1.0f);
9434 Animation animation = Animation::New(durationSeconds);
9436 KeyFrames keyFrames = KeyFrames::New();
9437 keyFrames.Add(0.0f, Vector4(0.1f, 0.2f, 0.3f, 0.4f));
9438 keyFrames.Add(0.5f, Vector4(0.9f, 0.8f, 0.7f, 0.6f));
9439 keyFrames.Add(1.0f, Vector4(1.0f, 1.0f, 1.0f, 1.0f));
9441 animation.AnimateBetween( Property(actor, Actor::COLOR), keyFrames, AlphaFunctions::Linear, TimePeriod( 1.0f) );
9443 // Start the animation
9446 bool signalReceived(false);
9447 AnimationFinishCheck finishCheck(signalReceived);
9448 animation.FinishedSignal().Connect(&application, finishCheck);
9449 application.SendNotification();
9450 application.Render(0);
9451 application.SendNotification();
9452 finishCheck.CheckSignalNotReceived();
9453 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), 0.1f, 0.01f, TEST_LOCATION );
9454 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 0.2f, 0.01f, TEST_LOCATION );
9455 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), 0.3f, 0.01f, TEST_LOCATION );
9456 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.4f, 0.01f, TEST_LOCATION );
9458 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
9459 application.SendNotification();
9460 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), 0.5f, 0.01f, TEST_LOCATION );
9461 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 0.5f, 0.01f, TEST_LOCATION );
9462 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), 0.5f, 0.01f, TEST_LOCATION );
9463 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.5f, 0.01f, TEST_LOCATION );
9465 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
9466 application.SendNotification();
9467 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), 0.9f, 0.01f, TEST_LOCATION );
9468 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 0.8f, 0.01f, TEST_LOCATION );
9469 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), 0.7f, 0.01f, TEST_LOCATION );
9470 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.6f, 0.01f, TEST_LOCATION );
9472 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
9473 application.SendNotification();
9474 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), 0.95f, 0.01f, TEST_LOCATION );
9475 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 0.90f, 0.01f, TEST_LOCATION );
9476 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), 0.85f, 0.01f, TEST_LOCATION );
9477 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.80f, 0.01f, TEST_LOCATION );
9479 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
9480 application.SendNotification();
9481 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), 1.0f, 0.01f, TEST_LOCATION );
9482 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 1.0f, 0.01f, TEST_LOCATION );
9483 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), 1.0f, 0.01f, TEST_LOCATION );
9484 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 1.0f, 0.01f, TEST_LOCATION );
9486 // We did expect the animation to finish
9488 finishCheck.CheckSignalReceived();
9492 int UtcDaliAnimationAnimateVector3Func(void)
9494 TestApplication application;
9496 Actor actor = Actor::New();
9497 Vector3 initialPosition(Vector3::ZERO);
9498 DALI_TEST_EQUALS( actor.GetCurrentPosition(), initialPosition, TEST_LOCATION );
9499 Stage::GetCurrent().Add(actor);
9501 // Build the animation
9502 float durationSeconds(10.0f);
9503 Animation animation = Animation::New(durationSeconds);
9504 Vector3 targetPosition(200.0f, 200.0f, 200.0f);
9505 BounceFunc func(0.0f, 0.0f, -100.0f);
9506 animation.Animate<Vector3>( Property(actor, Actor::POSITION), func, AlphaFunctions::Linear );
9508 // Start the animation
9511 bool signalReceived(false);
9512 AnimationFinishCheck finishCheck(signalReceived);
9513 animation.FinishedSignal().Connect(&application, finishCheck);
9515 application.SendNotification();
9516 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
9518 // We didn't expect the animation to finish yet
9519 application.SendNotification();
9520 finishCheck.CheckSignalNotReceived();
9521 DALI_TEST_EQUALS( actor.GetCurrentPosition(), func(0.25f, initialPosition), TEST_LOCATION );
9523 application.SendNotification();
9524 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
9526 // We didn't expect the animation to finish yet
9527 application.SendNotification();
9528 finishCheck.CheckSignalNotReceived();
9529 DALI_TEST_EQUALS( actor.GetCurrentPosition(), func(0.5f, initialPosition), TEST_LOCATION );
9531 application.SendNotification();
9532 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
9534 // We didn't expect the animation to finish yet
9535 application.SendNotification();
9536 finishCheck.CheckSignalNotReceived();
9537 DALI_TEST_EQUALS( actor.GetCurrentPosition(), func(0.75f, initialPosition), TEST_LOCATION );
9539 application.SendNotification();
9540 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
9542 // We did expect the animation to finish
9543 application.SendNotification();
9544 finishCheck.CheckSignalReceived();
9545 DALI_TEST_EQUALS( actor.GetCurrentPosition(), initialPosition, TEST_LOCATION );
9549 int UtcDaliAnimationCreateDestroy(void)
9551 TestApplication application;
9552 Animation* animation = new Animation;
9553 DALI_TEST_CHECK( animation );
9558 struct UpdateManagerTestConstraint
9560 UpdateManagerTestConstraint(TestApplication& application)
9561 : mApplication(application)
9565 Vector3 operator()(const Vector3& current)
9567 mApplication.SendNotification(); // Process events
9571 TestApplication& mApplication;
9574 int UtcDaliAnimationUpdateManager(void)
9576 TestApplication application;
9578 Actor actor = Actor::New();
9579 Stage::GetCurrent().Add( actor );
9581 // Build the animation
9582 Animation animation = Animation::New( 0.0f );
9584 bool signalReceived = false;
9585 AnimationFinishCheck finishCheck( signalReceived );
9586 animation.FinishedSignal().Connect( &application, finishCheck );
9588 Vector3 startValue(1.0f, 1.0f, 1.0f);
9589 Property::Index index = actor.RegisterProperty( "test-property", startValue );
9590 Constraint constraint = Constraint::New<Vector3>( index, UpdateManagerTestConstraint( application ) );
9591 actor.ApplyConstraint( constraint );
9593 // Apply animation to actor
9594 BounceFunc func(0.0f, 0.0f, -100.0f);
9595 animation.Animate<Vector3>( Property(actor, Actor::POSITION), func, AlphaFunctions::Linear );
9599 application.SendNotification();
9600 application.UpdateOnly( 16 );
9602 finishCheck.CheckSignalNotReceived();
9604 application.SendNotification(); // Process events
9606 finishCheck.CheckSignalReceived();
9611 int UtcDaliAnimationSignalOrder(void)
9613 TestApplication application;
9615 Actor actor = Actor::New();
9616 Stage::GetCurrent().Add( actor );
9618 // Build the animations
9619 Animation animation1 = Animation::New( 0.0f ); // finishes first frame
9620 Animation animation2 = Animation::New( 0.02f ); // finishes in 20 ms
9622 bool signal1Received = false;
9623 animation1.FinishedSignal().Connect( &application, AnimationFinishCheck( signal1Received ) );
9625 bool signal2Received = false;
9626 animation2.FinishedSignal().Connect( &application, AnimationFinishCheck( signal2Received ) );
9628 // Apply animations to actor
9629 animation1.AnimateTo( Property(actor, Actor::POSITION), Vector3( 3.0f, 2.0f, 1.0f ), AlphaFunctions::Linear );
9631 animation2.AnimateTo( Property(actor, Actor::SIZE ), Vector3( 10.0f, 20.0f, 30.0f ), AlphaFunctions::Linear );
9634 DALI_TEST_EQUALS( signal1Received, false, TEST_LOCATION );
9635 DALI_TEST_EQUALS( signal2Received, false, TEST_LOCATION );
9637 application.SendNotification();
9638 application.UpdateOnly( 10 ); // 10ms progress
9640 // no notifications yet
9641 DALI_TEST_EQUALS( signal1Received, false, TEST_LOCATION );
9642 DALI_TEST_EQUALS( signal2Received, false, TEST_LOCATION );
9644 application.SendNotification();
9647 DALI_TEST_EQUALS( signal1Received, true, TEST_LOCATION );
9648 DALI_TEST_EQUALS( signal2Received, false, TEST_LOCATION );
9649 signal1Received = false;
9651 // 1st animation is complete now, do another update with no ProcessEvents in between
9652 application.UpdateOnly( 20 ); // 20ms progress
9655 application.SendNotification();
9657 // 2nd should complete now
9658 DALI_TEST_EQUALS( signal1Received, false, TEST_LOCATION );
9659 DALI_TEST_EQUALS( signal2Received, true, TEST_LOCATION );
9664 int UtcDaliAnimationExtendDuration(void)
9666 TestApplication application;
9668 Actor actor = Actor::New();
9670 // Register a float property
9671 float startValue(10.0f);
9672 Property::Index index = actor.RegisterProperty( "test-property", startValue );
9673 Stage::GetCurrent().Add(actor);
9674 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
9676 // Build the animation
9677 float initialDurationSeconds(1.0f);
9678 float animatorDelay = 5.0f;
9679 float animatorDurationSeconds(5.0f);
9680 float extendedDurationSeconds(animatorDelay+animatorDurationSeconds);
9681 Animation animation = Animation::New(initialDurationSeconds);
9682 float targetValue(30.0f);
9683 float relativeValue(targetValue - startValue);
9685 animation.AnimateTo(Property(actor, index),
9687 TimePeriod(animatorDelay, animatorDurationSeconds));
9689 // The duration should have been extended
9690 DALI_TEST_EQUALS( animation.GetDuration(), extendedDurationSeconds, TEST_LOCATION );
9692 // Start the animation
9695 bool signalReceived(false);
9696 AnimationFinishCheck finishCheck(signalReceived);
9697 animation.FinishedSignal().Connect(&application, finishCheck);
9699 application.SendNotification();
9700 application.Render(static_cast<unsigned int>(extendedDurationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
9702 // We didn't expect the animation to finish yet
9703 application.SendNotification();
9704 finishCheck.CheckSignalNotReceived();
9705 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
9707 application.SendNotification();
9708 application.Render(static_cast<unsigned int>(extendedDurationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
9710 // We didn't expect the animation to finish yet
9711 application.SendNotification();
9712 finishCheck.CheckSignalNotReceived();
9713 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
9715 application.SendNotification();
9716 application.Render(static_cast<unsigned int>(extendedDurationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
9718 // We did expect the animation to finish
9719 application.SendNotification();
9720 finishCheck.CheckSignalReceived();
9721 DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );